Changeset 788a1af for protocols/jabber
- Timestamp:
- 2006-10-15T20:24:01Z (18 years ago)
- Branches:
- master
- Children:
- d74c644
- Parents:
- e617b35
- Location:
- protocols/jabber
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
re617b35 r788a1af 147 147 148 148 node = xt_new_node( "body", message, NULL ); 149 node = jabber_make_packet( "message", "chat", bud ->full_jid, node );150 151 if( ( jd->flags & JFLAG_WANT_TYPING ) && 152 ( ( bud->flags & JBFLAG_DOES_ JEP85 ) ||153 !( bud->flags & JBFLAG_PROBED_ JEP85 ) ) )149 node = jabber_make_packet( "message", "chat", bud ? bud->full_jid : who, node ); 150 151 if( ( jd->flags & JFLAG_WANT_TYPING ) && bud && 152 ( ( bud->flags & JBFLAG_DOES_XEP85 ) || 153 !( bud->flags & JBFLAG_PROBED_XEP85 ) ) ) 154 154 { 155 155 struct xt_node *act; 156 156 157 157 /* If the user likes typing notification and if we don't know 158 (and didn't probe before) if this resource supports JEP85,158 (and didn't probe before) if this resource supports XEP85, 159 159 include a probe in this packet now. */ 160 160 act = xt_new_node( "active", NULL, NULL ); … … 163 163 164 164 /* Just make sure we do this only once. */ 165 bud->flags |= JBFLAG_PROBED_ JEP85;165 bud->flags |= JBFLAG_PROBED_XEP85; 166 166 } 167 167 … … 226 226 static void jabber_remove_buddy( struct gaim_connection *gc, char *who, char *group ) 227 227 { 228 /* We should always do this part. Clean up our administration a little bit. */ 229 jabber_buddy_remove_bare( gc, who ); 230 228 231 if( jabber_remove_from_roster( gc, who ) ) 229 232 presence_send_request( gc, who, "unsubscribe" ); … … 248 251 jd->flags |= JFLAG_WANT_TYPING; 249 252 250 bud = jabber_buddy_by_jid( gc, who ); 251 if( bud->flags & JBFLAG_DOES_JEP85 ) 253 if( ( bud = jabber_buddy_by_jid( gc, who ) ) == NULL ) 254 { 255 /* Sending typing notifications to unknown buddies is 256 unsupported for now. Shouldn't be a problem, I think. */ 257 return 0; 258 } 259 260 if( bud->flags & JBFLAG_DOES_XEP85 ) 252 261 { 253 262 /* We're only allowed to send this stuff if we know the other -
protocols/jabber/jabber.h
re617b35 r788a1af 41 41 JFLAG_WAIT_BIND = 16, /* ... for <bind> tag. */ 42 42 JFLAG_WANT_TYPING = 32, /* Set if we ever sent a typing notification, this 43 activates all JEP-85 related code. */43 activates all XEP-85 related code. */ 44 44 } jabber_flags_t; 45 45 46 46 typedef enum 47 47 { 48 JBFLAG_PROBED_ JEP85 = 1, /* Set this when we sent our probe packet to make48 JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make 49 49 sure it gets sent only once. */ 50 JBFLAG_DOES_ JEP85 = 2, /* Set this when the resource seems to support51 JEP85 (typing notification shite). */50 JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support 51 XEP85 (typing notification shite). */ 52 52 } jabber_buddy_flag_t; 53 53 … … 138 138 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid ); 139 139 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid ); 140 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid ); 140 141 141 142 extern const struct jabber_away_state jabber_away_state_list[]; -
protocols/jabber/jabber_util.c
re617b35 r788a1af 29 29 { 30 30 account_t *acc = set->data; 31 char *ret; 32 33 ret = set_eval_int( set, value ); 31 int i; 32 33 if( sscanf( value, "%d", &i ) == 1 ) 34 { 35 /* Priority is a signed 8-bit integer, according to RFC 3921. */ 36 if( i < -128 || i > 127 ) 37 return NULL; 38 } 39 else 40 return NULL; 34 41 35 42 /* Only run this stuff if the account is online ATM, 36 43 and if the setting seems to be acceptable. */ 37 if( acc->gc && ret)44 if( acc->gc ) 38 45 { 39 46 /* Although set_eval functions usually are very nice and … … 47 54 48 55 g_free( set->value ); 49 set->value = g_strdup( ret);56 set->value = g_strdup( value ); 50 57 51 58 /* (Yes, sorry, I prefer the hack. :-P) */ … … 54 61 } 55 62 56 return ret;63 return value; 57 64 } 58 65 … … 283 290 } 284 291 292 /* Finds a buddy from our structures. Can find both full- and bare JIDs. When 293 asked for a bare JID, it uses the "resource_select" setting to see which 294 resource to pick. */ 285 295 struct jabber_buddy *jabber_buddy_by_jid( struct gaim_connection *gc, char *jid ) 286 296 { … … 323 333 } 324 334 335 /* Remove one specific full JID from our list. Use this when a buddy goes 336 off-line (because (s)he can still be online from a different location. */ 325 337 int jabber_buddy_remove( struct gaim_connection *gc, char *full_jid ) 326 338 { … … 381 393 } 382 394 } 395 396 /* Remove a buddy completely; removes all resources that belong to the 397 specified bare JID. Use this when removing someone from the contact 398 list, for example. */ 399 int jabber_buddy_remove_bare( struct gaim_connection *gc, char *bare_jid ) 400 { 401 struct jabber_data *jd = gc->proto_data; 402 struct jabber_buddy *bud, *next; 403 404 if( strchr( bare_jid, '/' ) ) 405 return 0; 406 407 if( ( bud = g_hash_table_lookup( jd->buddies, bare_jid ) ) ) 408 { 409 /* Most important: Remove the hash reference. We don't know 410 this buddy anymore. */ 411 g_hash_table_remove( jd->buddies, bud->handle ); 412 413 /* Deallocate the linked list of resources. */ 414 while( bud ) 415 { 416 next = bud->next; 417 g_free( bud->full_jid ); 418 g_free( bud->away_message ); 419 g_free( bud ); 420 bud = next; 421 } 422 423 return 1; 424 } 425 else 426 { 427 return 0; 428 } 429 } -
protocols/jabber/message.c
re617b35 r788a1af 30 30 char *type = xt_find_attr( node, "type" ); 31 31 struct xt_node *body = xt_find_node( node->children, "body" ); 32 char *s; 32 33 33 34 if( !type ) … … 38 39 struct jabber_buddy *bud = NULL; 39 40 40 if( strchr( from, '/') == NULL )41 if( ( s = strchr( from, '/' ) ) == NULL ) 41 42 { 42 43 /* It just shouldn't happen. */ … … 46 47 } 47 48 48 bud = jabber_buddy_by_jid( gc, from ); 49 bud->last_act = time( NULL ); 49 if( ( bud = jabber_buddy_by_jid( gc, from ) ) ) 50 bud->last_act = time( NULL ); 51 else 52 *s = 0; /* We need to generate a bare JID now. */ 50 53 51 54 if( body ) /* Could be just a typing notification. */ 52 serv_got_im( gc, bud ->handle, body->text, 0, 0, 0 );55 serv_got_im( gc, bud ? bud->handle : from, body->text, 0, 0, 0 ); 53 56 57 /* Handling of incoming typing notifications. */ 54 58 if( xt_find_node( node->children, "composing" ) ) 55 59 { 56 bud->flags |= JBFLAG_DOES_ JEP85;57 serv_got_typing( gc, bud ->handle, 0, 1 );60 bud->flags |= JBFLAG_DOES_XEP85; 61 serv_got_typing( gc, bud ? bud->handle : from, 0, 1 ); 58 62 } 59 else if( xt_find_node( node->children, "active" ) ) 63 /* No need to send a "stopped typing" signal when there's a message. */ 64 else if( xt_find_node( node->children, "active" ) && ( body == NULL ) ) 60 65 { 61 bud->flags |= JBFLAG_DOES_JEP85; 66 bud->flags |= JBFLAG_DOES_XEP85; 67 serv_got_typing( gc, bud ? bud->handle : from, 0, 0 ); 62 68 } 69 else if( xt_find_node( node->children, "paused" ) ) 70 { 71 bud->flags |= JBFLAG_DOES_XEP85; 72 serv_got_typing( gc, bud ? bud->handle : from, 0, 2 ); 73 } 74 75 if( s ) 76 *s = '/'; /* And convert it back to a full JID. */ 63 77 } 64 78 else … … 70 84 return XT_HANDLED; 71 85 } 72 -
protocols/jabber/presence.c
re617b35 r788a1af 31 31 struct xt_node *c; 32 32 struct jabber_buddy *bud; 33 char *s; 33 34 34 35 if( !from ) … … 37 38 if( type == NULL ) 38 39 { 39 if( strchr( from, '/') == NULL )40 if( ( s = strchr( from, '/' ) ) == NULL ) 40 41 { 41 42 char *s = xt_to_string( node ); 42 serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s \n", s );43 serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s", s ); 43 44 g_free( s ); 44 45 return XT_HANDLED; … … 47 48 if( !( bud = jabber_buddy_by_jid( gc, from ) ) ) 48 49 { 50 /* FOR NOW, s still contains the location of the /. 51 Keep this in mind when changing things here. :-) */ 52 53 /* We check if the buddy is in the contact list, 54 because Jabber servers seem to like to send 55 presence information of buddies we removed 56 from our list sometimes, for example... */ 57 58 *s = 0; 59 if( find_buddy( gc, from ) == NULL ) 60 { 61 *s = '/'; 62 serv_got_crap( gc, "WARNING: Ignoring presence information from unknown JID: %s", from ); 63 return XT_HANDLED; 64 } 65 *s = '/'; 66 49 67 bud = jabber_buddy_add( gc, from ); 50 68 } … … 83 101 serv_got_crap( gc, "WARNING: Ignoring presence tag with bare JID: %s\n", s ); 84 102 g_free( s ); 103 return XT_HANDLED; 104 } 105 106 if( jabber_buddy_by_jid( gc, from ) == NULL ) 107 { 108 serv_got_crap( gc, "WARNING: Received presence information from unknown JID: %s", from ); 85 109 return XT_HANDLED; 86 110 }
Note: See TracChangeset
for help on using the changeset viewer.