Changes in protocols/jabber/presence.c [1baaef8:1bf1ae6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/presence.c
r1baaef8 r1bf1ae6 31 31 struct xt_node *c; 32 32 struct jabber_buddy *bud; 33 int is_chat = 0, is_away = 0;34 33 char *s; 35 34 … … 37 36 return XT_HANDLED; 38 37 39 if( ( s = strchr( from, '/' ) ) )40 {41 *s = 0;42 if( jabber_chat_by_name( ic, from ) )43 is_chat = 1;44 *s = '/';45 }46 47 38 if( type == NULL ) 48 39 { 40 int is_away = 0; 41 49 42 if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) ) 50 43 { … … 79 72 bud->priority = 0; 80 73 81 if( is_chat ) 82 jabber_chat_pkt_presence( ic, bud, node ); 83 else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) ) 74 if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) ) 84 75 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, 85 76 ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, … … 88 79 else if( strcmp( type, "unavailable" ) == 0 ) 89 80 { 90 if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT )) == NULL )81 if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) == NULL ) 91 82 { 92 83 if( set_getbool( &ic->irc->set, "debug" ) ) … … 95 86 } 96 87 97 /* Handle this before we delete the JID. */98 if( is_chat )99 {100 jabber_chat_pkt_presence( ic, bud, node );101 }102 103 88 jabber_buddy_remove( ic, from ); 104 89 105 if( is_chat ) 106 { 107 /* Nothing else to do for now? */ 108 } 109 else if( ( s = strchr( from, '/' ) ) ) 90 if( ( s = strchr( from, '/' ) ) ) 110 91 { 111 92 *s = 0; 112 93 113 /* If another resource is still available, send its presence 114 information. */ 115 if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) ) 116 { 117 if( bud->away_state && ( *bud->away_state->code == 0 || 118 strcmp( bud->away_state->code, "chat" ) == 0 ) ) 119 is_away = OPT_AWAY; 120 121 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, 122 ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, 123 bud->away_message ); 124 } 125 else 126 { 127 /* Otherwise, count him/her as offline now. */ 94 /* Only count this as offline if there's no other resource 95 available anymore. */ 96 if( jabber_buddy_by_jid( ic, from, 0 ) == NULL ) 128 97 imcb_buddy_status( ic, from, 0, NULL, NULL ); 129 }130 98 131 99 *s = '/'; … … 158 126 else if( strcmp( type, "error" ) == 0 ) 159 127 { 160 struct jabber_error *err; 161 162 if( ( c = xt_find_node( node->children, "error" ) ) ) 163 { 164 err = jabber_error_parse( c, XMLNS_STANZA_ERROR ); 165 imcb_error( ic, "Stanza (%s) error: %s%s%s", node->name, 166 err->code, err->text ? ": " : "", 167 err->text ? err->text : "" ); 168 jabber_error_free( err ); 169 } 170 /* What else to do with it? */ 171 } 172 else 173 { 174 printf( "Received PRES from %s:\n", from ); 175 xt_print( node ); 128 /* What to do with it? */ 176 129 } 177 130 … … 187 140 char *show = jd->away_state->code; 188 141 char *status = jd->away_message; 189 struct groupchat *c;190 142 int st; 191 143 … … 198 150 199 151 st = jabber_write_packet( ic, node ); 200 201 /* Have to send this update to all groupchats too, the server won't202 do this automatically. */203 for( c = ic->groupchats; c && st; c = c->next )204 {205 struct jabber_chat *jc = c->data;206 207 xt_add_attr( node, "to", jc->my_full_jid );208 st = jabber_write_packet( ic, node );209 }210 152 211 153 xt_free_node( node );
Note: See TracChangeset
for help on using the changeset viewer.