Changeset e35d1a1
- Timestamp:
- 2007-04-22T20:44:27Z (18 years ago)
- Branches:
- master
- Children:
- 43671b9
- Parents:
- c737ba7
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/Makefile
rc737ba7 re35d1a1 10 10 11 11 # [SH] Program variables 12 objects = io.o iq.o jabber.o jabber_util.o message.o presence.o sasl.o xmltree.o12 objects = conference.o io.o iq.o jabber.o jabber_util.o message.o presence.o sasl.o xmltree.o 13 13 14 14 CFLAGS += -Wall -
protocols/jabber/jabber.c
rc737ba7 re35d1a1 324 324 } 325 325 326 static struct groupchat *jabber_chat_join_( struct im_connection *ic, char *room, char *nick, char *password ) 327 { 328 if( strchr( room, '@' ) == NULL ) 329 imcb_error( ic, "Invalid room name: %s", room ); 330 else if( jabber_chat_by_name( ic, room ) ) 331 imcb_error( ic, "Already present in chat `%s'", room ); 332 else 333 return jabber_chat_join( ic, room, nick, password ); 334 335 return NULL; 336 } 337 338 static void jabber_chat_leave_( struct groupchat *c ) 339 { 340 if( c ) 341 jabber_chat_leave( c, NULL ); 342 } 343 326 344 static void jabber_keepalive( struct im_connection *ic ) 327 345 { … … 396 414 // ret->chat_msg = jabber_chat_msg; 397 415 // ret->chat_invite = jabber_chat_invite; 398 // ret->chat_leave = jabber_chat_leave;399 // ret->chat_open = jabber_chat_open;416 ret->chat_leave = jabber_chat_leave_; 417 ret->chat_join = jabber_chat_join_; 400 418 ret->keepalive = jabber_keepalive; 401 419 ret->send_typing = jabber_send_typing; -
protocols/jabber/jabber.h
rc737ba7 re35d1a1 50 50 JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support 51 51 XEP85 (typing notification shite). */ 52 JBFLAG_IS_CHATROOM = 4, /* It's convenient to use this JID thingy for 53 groupchat state info too. */ 52 54 } jabber_buddy_flags_t; 53 55 … … 101 103 char *resource; 102 104 105 /* Groupchat-only */ 106 char *orig_jid; 107 103 108 int priority; 104 109 struct jabber_away_state *away_state; … … 109 114 110 115 struct jabber_buddy *next; 116 }; 117 118 struct jabber_chat 119 { 120 int flags; 121 char *name; 122 struct jabber_buddy *me; 111 123 }; 112 124 … … 134 146 #define XMLNS_CHATSTATES "http://jabber.org/protocol/chatstates" /* 0085 */ 135 147 #define XMLNS_DISCOVER "http://jabber.org/protocol/disco#info" /* 0030 */ 148 #define XMLNS_MUC "http://jabber.org/protocol/muc" /* XEP-0045 */ 149 #define XMLNS_MUC_USER "http://jabber.org/protocol/muc#user"/* XEP-0045 */ 136 150 137 151 /* iq.c */ … … 164 178 const struct jabber_away_state *jabber_away_state_by_name( char *name ); 165 179 void jabber_buddy_ask( struct im_connection *ic, char *handle ); 166 char *jabber_normalize( c har *orig );180 char *jabber_normalize( const char *orig ); 167 181 168 182 typedef enum 169 183 { 170 184 GET_BUDDY_CREAT = 1, /* Try to create it, if necessary. */ 171 GET_BUDDY_EXACT = 2, /* Get an exact message (only makes sense with bare JIDs). */ 185 GET_BUDDY_EXACT = 2, /* Get an exact match (only makes sense with bare JIDs). */ 186 GET_BUDDY_FIRST = 4, /* No selection, simply get the first resource for this JID. */ 172 187 } get_buddy_flags_t; 173 188 … … 176 191 int jabber_buddy_remove( struct im_connection *ic, char *full_jid ); 177 192 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid ); 193 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name ); 178 194 179 195 extern const struct jabber_away_state jabber_away_state_list[]; … … 193 209 gboolean sasl_supported( struct im_connection *ic ); 194 210 211 /* conference.c */ 212 struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ); 213 int jabber_chat_leave( struct groupchat *c, const char *reason ); 214 void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); 215 void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); 216 195 217 #endif -
protocols/jabber/jabber_util.c
rc737ba7 re35d1a1 48 48 call p_s_u() now to send the new prio setting, it would 49 49 send the old setting because the set->value gets changed 50 when theeval returns a non-NULL value.50 after the (this) eval returns a non-NULL value. 51 51 52 52 So now I can choose between implementing post-set … … 129 129 /* Cache a node/packet for later use. Mainly useful for IQ packets if you need 130 130 them when you receive the response. Use this BEFORE sending the packet so 131 it'll get a new id= tag, and do NOT free() the packet after writing it! */131 it'll get a new id= tag, and do NOT free() the packet after sending it! */ 132 132 void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_cache_event func ) 133 133 { … … 252 252 253 253 /* Returns a new string. Don't leak it! */ 254 char *jabber_normalize( c har *orig )254 char *jabber_normalize( const char *orig ) 255 255 { 256 256 int len, i; … … 353 353 if( ( s = strchr( jid, '/' ) ) ) 354 354 { 355 int none_found = 0; 356 355 357 *s = 0; 356 358 if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) ) … … 370 372 } 371 373 } 372 373 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && imcb_find_buddy( ic, jid ) ) 374 else 375 { 376 /* This hack is there to make sure that O_CREAT will 377 work if there's already another resouce present 378 for this JID, even if it's an unknown buddy. This 379 is done to handle conferences properly. */ 380 none_found = 1; 381 } 382 383 if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && ( imcb_find_buddy( ic, jid ) || !none_found ) ) 374 384 { 375 385 *s = '/'; … … 531 541 } 532 542 } 543 544 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name ) 545 { 546 char *normalized = jabber_normalize( name ); 547 struct groupchat *ret; 548 struct jabber_chat *jc; 549 550 for( ret = ic->groupchats; ret; ret = ret->next ) 551 { 552 jc = ret->data; 553 if( strcmp( normalized, jc->name ) == 0 ) 554 break; 555 } 556 g_free( normalized ); 557 558 return ret; 559 } -
protocols/jabber/message.c
rc737ba7 re35d1a1 30 30 char *type = xt_find_attr( node, "type" ); 31 31 struct xt_node *body = xt_find_node( node->children, "body" ), *c; 32 struct jabber_buddy *bud = NULL; 32 33 char *s; 34 35 if( !from ) 36 return XT_HANDLED; /* Consider this packet corrupted. */ 37 38 bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ); 33 39 34 40 if( type && strcmp( type, "error" ) == 0 ) … … 36 42 /* Handle type=error packet. */ 37 43 } 38 else if( type && strcmp( type, "groupchat" ) == 0 )44 else if( type && from && strcmp( type, "groupchat" ) == 0 ) 39 45 { 40 /* TODO! */46 jabber_chat_pkt_message( ic, bud, node ); 41 47 } 42 48 else /* "chat", "normal", "headline", no-type or whatever. Should all be pretty similar. */ 43 49 { 44 struct jabber_buddy *bud = NULL;45 50 GString *fullmsg = g_string_new( "" ); 46 51 47 52 if( ( s = strchr( from, '/' ) ) ) 48 53 { 49 if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ))54 if( bud ) 50 55 bud->last_act = time( NULL ); 51 56 else -
protocols/jabber/presence.c
rc737ba7 re35d1a1 31 31 struct xt_node *c; 32 32 struct jabber_buddy *bud; 33 int is_chat = 0; 33 34 char *s; 34 35 35 36 if( !from ) 36 37 return XT_HANDLED; 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 } 37 46 38 47 if( type == NULL ) … … 72 81 bud->priority = 0; 73 82 74 if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) ) 83 if( is_chat ) 84 jabber_chat_pkt_presence( ic, bud, node ); 85 else if( bud == jabber_buddy_by_jid( ic, bud->bare_jid, 0 ) ) 75 86 imcb_buddy_status( ic, bud->bare_jid, OPT_LOGGED_IN | is_away, 76 87 ( is_away && bud->away_state ) ? bud->away_state->full_name : NULL, … … 79 90 else if( strcmp( type, "unavailable" ) == 0 ) 80 91 { 81 if( jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT) == NULL )92 if( ( bud = jabber_buddy_by_jid( ic, from, GET_BUDDY_EXACT ) ) == NULL ) 82 93 { 83 94 if( set_getbool( &ic->irc->set, "debug" ) ) … … 86 97 } 87 98 99 /* Handle this before we delete the JID. */ 100 if( is_chat ) 101 { 102 jabber_chat_pkt_presence( ic, bud, node ); 103 } 104 88 105 jabber_buddy_remove( ic, from ); 89 106 90 if( ( s = strchr( from, '/' ) ) ) 107 if( is_chat ) 108 { 109 /* Nothing else to do for now? */ 110 } 111 else if( ( s = strchr( from, '/' ) ) ) 91 112 { 92 113 *s = 0; … … 96 117 if( jabber_buddy_by_jid( ic, from, 0 ) == NULL ) 97 118 imcb_buddy_status( ic, from, 0, NULL, NULL ); 119 /* FIXME: If this resource was not away and another resource is, 120 we should definitely send an update here. */ 98 121 99 122 *s = '/'; -
protocols/jabber/xmltree.c
rc737ba7 re35d1a1 188 188 g_strcasecmp( xt->handlers[i].parent, "<root>" ) == 0 ) ) ) 189 189 { 190 xt_print( node ); 191 190 192 st = xt->handlers[i].func( node, xt->data ); 191 193 -
protocols/msn/sb.c
rc737ba7 re35d1a1 232 232 if( sb->chat ) 233 233 { 234 imcb_chat_ removed( sb->chat );234 imcb_chat_free( sb->chat ); 235 235 } 236 236 -
protocols/nogaim.c
rc737ba7 re35d1a1 554 554 u->online = 0; 555 555 556 /* Remove him/her from the conversations to prevent PART messages after he/she QUIT already */557 for( c = ic-> conversations; c; c = c->next )556 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */ 557 for( c = ic->groupchats; c; c = c->next ) 558 558 remove_chat_buddy_silent( c, (char*) handle ); 559 559 } … … 685 685 } 686 686 687 void imcb_chat_ removed( struct groupchat *c )687 void imcb_chat_free( struct groupchat *c ) 688 688 { 689 689 struct im_connection *ic = c->ic; 690 struct groupchat *l = NULL;690 struct groupchat *l; 691 691 GList *ir; 692 692 … … 708 708 } 709 709 710 /* Find the previous chat in the linked list. */ 711 for( l = ic->groupchats; l && l->next != c; l = l->next ); 712 710 713 if( l ) 711 714 l->next = c->next; 712 715 else 713 ic-> conversations = c->next;716 ic->groupchats = c->next; 714 717 715 718 for( ir = c->in_room; ir; ir = ir->next ) … … 749 752 /* This one just creates the conversation structure, user won't see anything yet */ 750 753 751 if( ic-> conversations )752 { 753 for( c = ic-> conversations; c->next; c = c->next );754 if( ic->groupchats ) 755 { 756 for( c = ic->groupchats; c->next; c = c->next ); 754 757 c = c->next = g_new0( struct groupchat, 1 ); 755 758 } 756 759 else 757 ic-> conversations = c = g_new0( struct groupchat, 1 );760 ic->groupchats = c = g_new0( struct groupchat, 1 ); 758 761 759 762 c->ic = ic; … … 863 866 { 864 867 ic = l->data; 865 for( c = ic-> conversations; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next );868 for( c = ic->groupchats; c && g_strcasecmp( c->channel, channel ) != 0; c = c->next ); 866 869 if( c ) 867 870 return c; -
protocols/nogaim.h
rc737ba7 re35d1a1 91 91 irc_t *irc; 92 92 93 struct groupchat * conversations;93 struct groupchat *groupchats; 94 94 }; 95 95 … … 97 97 struct im_connection *ic; 98 98 99 /* stuff used just for chat */100 99 GList *in_room; 101 100 GList *ignored; 102 101 103 /* BitlBee */104 102 struct groupchat *next; 105 103 char *channel; … … 208 206 G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ); 209 207 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ); 210 G_MODULE_EXPORT void imcb_chat_ removed( struct groupchat *c );208 G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c ); 211 209 struct groupchat *chat_by_channel( char *channel ); 212 210 -
protocols/oscar/oscar.c
rc737ba7 re35d1a1 2513 2513 2514 2514 /* Notify the conversation window that we've left the chat */ 2515 imcb_chat_ removed(cc->cnv);2515 imcb_chat_free(cc->cnv); 2516 2516 2517 2517 /* Destroy the chat_connection */ -
protocols/yahoo/yahoo.c
rc737ba7 re35d1a1 145 145 GSList *l; 146 146 147 while( ic-> conversations )148 imcb_chat_ removed( ic->conversations );147 while( ic->groupchats ) 148 imcb_chat_free( ic->groupchats ); 149 149 150 150 for( l = yd->buddygroups; l; l = l->next ) … … 318 318 319 319 yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); 320 imcb_chat_ removed( c );320 imcb_chat_free( c ); 321 321 } 322 322 … … 798 798 { 799 799 yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); 800 imcb_chat_ removed( inv->c );800 imcb_chat_free( inv->c ); 801 801 g_free( inv->name ); 802 802 g_free( inv ); … … 841 841 struct groupchat *c; 842 842 843 for( c = ic-> conversations; c && strcmp( c->title, room ) != 0; c = c->next );843 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 844 844 845 845 if( c ) … … 853 853 struct groupchat *c; 854 854 855 for( c = ic-> conversations; c && strcmp( c->title, room ) != 0; c = c->next );855 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 856 856 857 857 if( c ) … … 865 865 struct groupchat *c; 866 866 867 for( c = ic-> conversations; c && strcmp( c->title, room ) != 0; c = c->next );867 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 868 868 869 869 if( c ) -
root_commands.c
rc737ba7 re35d1a1 924 924 if( cmd[3] && cmd[4] ) 925 925 nick = cmd[4]; 926 else 927 nick = irc->nick; 926 928 if( cmd[3] && cmd[4] && cmd[5] ) 927 929 password = cmd[5]; 928 930 929 c = a->prpl->chat_join( ic, chat, nick, password ); 930 931 g_free( channel ); 931 if( ( c = a->prpl->chat_join( ic, chat, nick, password ) ) ) 932 { 933 g_free( c->channel ); 934 c->channel = channel; 935 } 936 else 937 { 938 irc_usermsg( irc, "Tried to join chat, not sure if this was successful" ); 939 g_free( channel ); 940 } 932 941 } 933 942
Note: See TracChangeset
for help on using the changeset viewer.