Changes in protocols/jabber/presence.c [17fa798:1baaef8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/presence.c
r17fa798 r1baaef8 31 31 struct xt_node *c; 32 32 struct jabber_buddy *bud; 33 int is_chat = 0, is_away = 0; 33 34 char *s; 34 35 … … 36 37 return XT_HANDLED; 37 38 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 38 47 if( type == NULL ) 39 48 { 40 int is_away = 0;41 42 49 if( !( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT | GET_BUDDY_CREAT ) ) ) 43 50 { … … 72 79 bud->priority = 0; 73 80 74 if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) ) 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 ) ) 75 84 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, 76 85 ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, … … 79 88 else if( strcmp( type, "unavailable" ) == 0 ) 80 89 { 81 if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT) == NULL )90 if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) == NULL ) 82 91 { 83 92 if( set_getbool( &ic->irc->set, "debug" ) ) … … 86 95 } 87 96 97 /* Handle this before we delete the JID. */ 98 if( is_chat ) 99 { 100 jabber_chat_pkt_presence( ic, bud, node ); 101 } 102 88 103 jabber_buddy_remove( ic, from ); 89 104 90 if( ( s = strchr( from, '/' ) ) ) 105 if( is_chat ) 106 { 107 /* Nothing else to do for now? */ 108 } 109 else if( ( s = strchr( from, '/' ) ) ) 91 110 { 92 111 *s = 0; 93 112 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 ) 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. */ 97 128 imcb_buddy_status( ic, from, 0, NULL, NULL ); 129 } 98 130 99 131 *s = '/'; … … 126 158 else if( strcmp( type, "error" ) == 0 ) 127 159 { 128 /* What to do with it? */ 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? */ 129 171 } 130 172 else … … 145 187 char *show = jd->away_state->code; 146 188 char *status = jd->away_message; 189 struct groupchat *c; 147 190 int st; 148 191 … … 156 199 st = jabber_write_packet( ic, node ); 157 200 201 /* Have to send this update to all groupchats too, the server won't 202 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 158 211 xt_free_node( node ); 159 212 return st;
Note: See TracChangeset
for help on using the changeset viewer.