Changeset 1ba7e8f for protocols/jabber/presence.c
- Timestamp:
- 2008-02-15T17:38:57Z (17 years ago)
- Branches:
- master
- Children:
- 506e61b
- Parents:
- 0fbd3a6d (diff), eeb85a8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/presence.c
r0fbd3a6d r1ba7e8f 29 29 char *from = xt_find_attr( node, "from" ); 30 30 char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */ 31 struct xt_node *c ;32 struct jabber_buddy *bud ;33 int is_chat = 0 , is_away = 0;31 struct xt_node *c, *cap; 32 struct jabber_buddy *bud, *send_presence = NULL; 33 int is_chat = 0; 34 34 char *s; 35 35 … … 50 50 { 51 51 if( set_getbool( &ic->irc->set, "debug" ) ) 52 imcb_log( ic, "W ARNING: Could not handle presence information from JID: %s", from );52 imcb_log( ic, "Warning: Could not handle presence information from JID: %s", from ); 53 53 return XT_HANDLED; 54 54 } … … 63 63 { 64 64 bud->away_state = (void*) jabber_away_state_by_code( c->text ); 65 if( strcmp( c->text, "chat" ) != 0 )66 is_away = OPT_AWAY;67 65 } 68 66 else … … 79 77 bud->priority = 0; 80 78 79 if( bud && ( cap = xt_find_node( node->children, "c" ) ) && 80 ( s = xt_find_attr( cap, "xmlns" ) ) && strcmp( s, XMLNS_CAPS ) == 0 ) 81 { 82 /* This <presence> stanza includes an XEP-0115 83 capabilities part. Not too interesting, but we can 84 see if it has an ext= attribute. */ 85 s = xt_find_attr( cap, "ext" ); 86 if( s && ( strstr( s, "cstates" ) || strstr( s, "chatstate" ) ) ) 87 bud->flags |= JBFLAG_DOES_XEP85; 88 89 /* This field can contain more information like xhtml 90 support, but we don't support that ourselves. 91 Officially the ext= tag was deprecated, but enough 92 clients do send it. 93 94 (I'm aware that this is not the right way to use 95 this field.) See for an explanation of ext=: 96 http://www.xmpp.org/extensions/attic/xep-0115-1.3.html*/ 97 } 98 81 99 if( is_chat ) 82 100 jabber_chat_pkt_presence( ic, bud, node ); 83 else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) ) 84 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, 85 ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, 86 bud->away_message ); 101 else 102 send_presence = jabber_buddy_by_jid( ic, bud->bare_jid, 0 ); 87 103 } 88 104 else if( strcmp( type, "unavailable" ) == 0 ) … … 91 107 { 92 108 if( set_getbool( &ic->irc->set, "debug" ) ) 93 imcb_log( ic, "W ARNING: Received presence information from unknown JID: %s", from );109 imcb_log( ic, "Warning: Received presence information from unknown JID: %s", from ); 94 110 return XT_HANDLED; 95 111 } … … 119 135 /* If another resource is still available, send its presence 120 136 information. */ 121 if( ( bud = jabber_buddy_by_jid( ic, from, 0 ) ) ) 122 { 123 if( bud->away_state && ( *bud->away_state->code == 0 || 124 strcmp( bud->away_state->code, "chat" ) == 0 ) ) 125 is_away = OPT_AWAY; 126 127 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, 128 ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, 129 bud->away_message ); 130 } 131 else 137 if( ( send_presence = jabber_buddy_by_jid( ic, from, 0 ) ) == NULL ) 132 138 { 133 139 /* Otherwise, count him/her as offline now. */ … … 177 183 } */ 178 184 } 185 186 if( send_presence ) 187 { 188 int is_away = 0; 189 190 if( send_presence->away_state && !( *send_presence->away_state->code == 0 || 191 strcmp( send_presence->away_state->code, "chat" ) == 0 ) ) 192 is_away = OPT_AWAY; 193 194 imcb_buddy_status( ic, send_presence->bare_jid, OPT_LOGGED_IN | is_away, 195 ( is_away && send_presence->away_state ) ? 196 send_presence->away_state->full_name : NULL, 197 send_presence->away_message ); 198 } 179 199 180 200 return XT_HANDLED; … … 186 206 { 187 207 struct jabber_data *jd = ic->proto_data; 188 struct xt_node *node ;208 struct xt_node *node, *cap; 189 209 char *show = jd->away_state->code; 190 210 char *status = jd->away_message; … … 199 219 xt_add_child( node, xt_new_node( "status", status, NULL ) ); 200 220 221 /* This makes the packet slightly bigger, but clients interested in 222 capabilities can now cache the discovery info. This reduces the 223 usual post-login iq-flood. See XEP-0115. At least libpurple and 224 Trillian seem to do this right. */ 225 cap = xt_new_node( "c", NULL, NULL ); 226 xt_add_attr( cap, "xmlns", XMLNS_CAPS ); 227 xt_add_attr( cap, "node", "http://bitlbee.org/xmpp/caps" ); 228 xt_add_attr( cap, "ver", BITLBEE_VERSION ); /* The XEP wants this hashed, but nobody's doing that. */ 229 xt_add_child( node, cap ); 230 201 231 st = jabber_write_packet( ic, node ); 202 232
Note: See TracChangeset
for help on using the changeset viewer.