Changeset 6a1128d for protocols/jabber/presence.c
- Timestamp:
- 2006-10-09T18:19:05Z (18 years ago)
- Branches:
- master
- Children:
- a21a8ac
- Parents:
- 861c199
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/presence.c
r861c199 r6a1128d 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 char *s;31 struct xt_node *c; 32 32 33 33 if( !from ) 34 34 return XT_HANDLED; 35 35 36 s = strchr( from, '/' );37 if( s )38 *s = 0;39 40 /* Will implement better parsing of away states/msgs when we41 finally do those API changes. Which will probably be after42 merging this module into the main tree. */43 36 if( type == NULL ) 44 serv_got_update( gc, from, 1, 0, 0, 0, 0, 0 ); 37 { 38 struct jabber_buddy *bud; 39 40 if( !( bud = jabber_buddy_by_jid( gc, from ) ) ) 41 { 42 bud = jabber_buddy_add( gc, from ); 43 } 44 45 g_free( bud->away_message ); 46 if( ( c = xt_find_node( node->children, "status" ) ) && c->text_len > 0 ) 47 bud->away_message = g_strdup( c->text ); 48 else 49 bud->away_message = NULL; 50 51 if( ( c = xt_find_node( node->children, "show" ) ) && c->text_len > 0 ) 52 bud->away_state = (void*) jabber_away_state_by_code( c->text ); 53 else 54 bud->away_state = NULL; 55 56 if( ( c = xt_find_node( node->children, "priority" ) ) && c->text_len > 0 ) 57 bud->priority = atoi( c->text ); 58 else 59 bud->priority = 0; 60 61 serv_got_update( gc, bud->handle, 1, 0, 0, 0, 0, 0 ); 62 } 45 63 else if( strcmp( type, "unavailable" ) == 0 ) 46 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 ); 64 { 65 char *s; 66 67 jabber_buddy_remove( gc, from ); 68 69 if( ( s = strchr( from, '/' ) ) ) 70 *s = 0; 71 72 /* Only count this as offline if there's no other resource 73 available anymore. */ 74 if( jabber_buddy_by_jid( gc, from ) == NULL ) 75 serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 ); 76 77 *s = '/'; 78 } 47 79 else if( strcmp( type, "subscribe" ) == 0 ) 80 { 48 81 jabber_buddy_ask( gc, from ); 82 } 49 83 else if( strcmp( type, "subscribed" ) == 0 ) 84 { 50 85 serv_got_crap( gc, "%s just accepted your authorization request", from ); 86 } 51 87 else if( strcmp( type, "unsubscribe" ) == 0 || strcmp( type, "unsubscribed" ) == 0 ) 52 88 { … … 69 105 xt_print( node ); 70 106 } 71 72 if( s )73 *s = '/';74 107 75 108 return XT_HANDLED;
Note: See TracChangeset
for help on using the changeset viewer.