- 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. - Location:
- protocols
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/conference.c
r0fbd3a6d r1ba7e8f 37 37 xt_add_attr( node, "xmlns", XMLNS_MUC ); 38 38 node = jabber_make_packet( "presence", NULL, roomjid, node ); 39 if( password ) 40 xt_add_child( node, xt_new_node( "password", password, NULL ) ); 39 41 jabber_cache_add( ic, node, jabber_chat_join_failed ); 40 42 … … 73 75 74 76 room = xt_find_attr( orig, "to" ); 75 if( ( bud = jabber_buddy_by_jid( ic, room, 0 ) ) ) 76 jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) ); 77 77 bud = jabber_buddy_by_jid( ic, room, 0 ); 78 78 err = jabber_error_parse( xt_find_node( node->children, "error" ), XMLNS_STANZA_ERROR ); 79 79 if( err ) 80 80 { 81 imcb_error( ic, "Error joining groupchat %s: %s%s%s", 82 bud->bare_jid, err->code, err->text ? ": " : "", 83 err->text ? err->text : "" ); 81 imcb_error( ic, "Error joining groupchat %s: %s%s%s", room, err->code, 82 err->text ? ": " : "", err->text ? err->text : "" ); 84 83 jabber_error_free( err ); 85 84 } 85 if( bud ) 86 jabber_chat_free( jabber_chat_by_jid( ic, bud->bare_jid ) ); 86 87 87 88 return XT_HANDLED; … … 123 124 struct jabber_chat *jc = c->data; 124 125 struct xt_node *node; 126 127 jc->flags |= JCFLAG_MESSAGE_SENT; 125 128 126 129 node = xt_new_node( "body", message, NULL ); … … 296 299 struct xt_node *subject = xt_find_node( node->children, "subject" ); 297 300 struct xt_node *body = xt_find_node( node->children, "body" ); 298 struct groupchat *chat; 301 struct groupchat *chat = bud ? jabber_chat_by_jid( ic, bud->bare_jid ) : NULL; 302 struct jabber_chat *jc = chat ? chat->data : NULL; 299 303 char *s; 300 304 301 if( bud == NULL ) 302 { 305 if( bud == NULL || ( jc && ~jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me ) ) 306 { 307 char *nick; 308 309 if( body == NULL || body->text_len == 0 ) 310 /* Meh. Empty messages aren't very interesting, no matter 311 how much some servers love to send them. */ 312 return; 313 303 314 s = xt_find_attr( node, "from" ); /* pkt_message() already NULL-checked this one. */ 304 if( strchr( s, '/' ) == NULL ) 315 nick = strchr( s, '/' ); 316 if( nick ) 317 { 318 /* If this message included a resource/nick we don't know, 319 we might still know the groupchat itself. */ 320 *nick = 0; 321 chat = jabber_chat_by_jid( ic, s ); 322 *nick = '/'; 323 324 nick ++; 325 } 326 else 327 { 328 /* message.c uses the EXACT_JID option, so bud should 329 always be NULL here for bare JIDs. */ 330 chat = jabber_chat_by_jid( ic, s ); 331 } 332 333 if( nick == NULL ) 334 { 305 335 /* This is fine, the groupchat itself isn't in jd->buddies. */ 306 imcb_log( ic, "System message from groupchat %s: %s", s, body? body->text : "NULL" ); 336 if( chat ) 337 imcb_chat_log( chat, "From conference server: %s", body->text ); 338 else 339 imcb_log( ic, "System message from unknown groupchat %s: %s", s, body->text ); 340 } 307 341 else 308 /* This, however, isn't fine! */ 309 imcb_log( ic, "Groupchat message from unknown participant %s: %s", s, body ? body->text : "NULL" ); 342 { 343 /* This can happen too, at least when receiving a backlog when 344 just joining a channel. */ 345 if( chat ) 346 imcb_chat_log( chat, "Message from unknown participant %s: %s", nick, body->text ); 347 else 348 imcb_log( ic, "Groupchat message from unknown JID %s: %s", s, body->text ); 349 } 310 350 311 351 return; 312 352 } 313 else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) )== NULL )353 else if( chat == NULL ) 314 354 { 315 355 /* How could this happen?? We could do kill( self, 11 ) -
protocols/jabber/io.c
r0fbd3a6d r1ba7e8f 249 249 struct im_connection *ic = data; 250 250 251 if( g_slist_find( jabber_connections, ic ) == NULL ) 252 return FALSE; 253 251 254 if( source == -1 ) 252 255 { … … 264 267 { 265 268 struct im_connection *ic = data; 266 struct jabber_data *jd = ic->proto_data; 269 struct jabber_data *jd; 270 271 if( g_slist_find( jabber_connections, ic ) == NULL ) 272 return FALSE; 273 274 jd = ic->proto_data; 267 275 268 276 if( source == NULL ) -
protocols/jabber/iq.c
r0fbd3a6d r1ba7e8f 54 54 !( s = xt_find_attr( c, "xmlns" ) ) ) 55 55 { 56 imcb_log( ic, "W ARNING: Received incomplete IQ-%s packet", type );56 imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type ); 57 57 return XT_HANDLED; 58 58 } … … 92 92 else if( strcmp( s, XMLNS_DISCO_INFO ) == 0 ) 93 93 { 94 const char *features[] = { XMLNS_VERSION, 94 const char *features[] = { XMLNS_DISCO_INFO, 95 XMLNS_VERSION, 95 96 XMLNS_TIME, 96 97 XMLNS_CHATSTATES, … … 132 133 !( s = xt_find_attr( c, "xmlns" ) ) ) 133 134 { 134 imcb_log( ic, "W ARNING: Received incomplete IQ-%s packet", type );135 imcb_log( ic, "Warning: Received incomplete IQ-%s packet", type ); 135 136 return XT_HANDLED; 136 137 } else if( strcmp( s, XMLNS_ROSTER ) == 0 ) … … 152 153 else 153 154 { 154 imcb_log( ic, "W ARNING: %s tried to fake a roster push!", s ? s : "(unknown)" );155 imcb_log( ic, "Warning: %s tried to fake a roster push!", s ? s : "(unknown)" ); 155 156 156 157 xt_free_node( reply ); … … 220 221 if( !( query = xt_find_node( node->children, "query" ) ) ) 221 222 { 222 imcb_log( ic, "W ARNING: Received incomplete IQ packet while authenticating" );223 imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" ); 223 224 imc_logout( ic, FALSE ); 224 225 return XT_HANDLED; … … 278 279 if( !( type = xt_find_attr( node, "type" ) ) ) 279 280 { 280 imcb_log( ic, "W ARNING: Received incomplete IQ packet while authenticating" );281 imcb_log( ic, "Warning: Received incomplete IQ packet while authenticating" ); 281 282 imc_logout( ic, FALSE ); 282 283 return XT_HANDLED; … … 354 355 if( !( query = xt_find_node( node->children, "query" ) ) ) 355 356 { 356 imcb_log( ic, "W ARNING: Received NULL roster packet" );357 imcb_log( ic, "Warning: Received NULL roster packet" ); 357 358 return XT_HANDLED; 358 359 } -
protocols/jabber/jabber.c
r0fbd3a6d r1ba7e8f 35 35 #include "base64.h" 36 36 37 GSList *jabber_connections; 38 37 39 static void jabber_init( account_t *acc ) 38 40 { … … 70 72 struct ns_srv_reply *srv = NULL; 71 73 char *connect_to, *s; 74 75 /* For now this is needed in the _connected() handlers if using 76 GLib event handling, to make sure we're not handling events 77 on dead connections. */ 78 jabber_connections = g_slist_prepend( jabber_connections, ic ); 72 79 73 80 jd->ic = ic; … … 197 204 imcb_error( ic, "Could not connect to server" ); 198 205 imc_logout( ic, TRUE ); 206 207 return; 199 208 } 200 209 … … 261 270 g_free( jd->username ); 262 271 g_free( jd ); 272 273 jabber_connections = g_slist_remove( jabber_connections, ic ); 263 274 } 264 275 -
protocols/jabber/jabber.h
r0fbd3a6d r1ba7e8f 29 29 #include "xmltree.h" 30 30 #include "bitlbee.h" 31 32 extern GSList *jabber_connections; 31 33 32 34 typedef enum … … 47 49 typedef enum 48 50 { 49 JBFLAG_PROBED_XEP85 = 1, 51 JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make 50 52 sure it gets sent only once. */ 51 JBFLAG_DOES_XEP85 = 2, 53 JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support 52 54 XEP85 (typing notification shite). */ 53 JBFLAG_IS_CHATROOM = 4, 55 JBFLAG_IS_CHATROOM = 4, /* It's convenient to use this JID thingy for 54 56 groupchat state info too. */ 55 JBFLAG_IS_ANONYMOUS = 8, 57 JBFLAG_IS_ANONYMOUS = 8, /* For anonymous chatrooms, when we don't have 56 58 have a real JID. */ 57 59 } jabber_buddy_flags_t; … … 64 66 char port[6]; 65 67 } jabber_streamhost_t; 68 69 typedef enum 70 { 71 JCFLAG_MESSAGE_SENT = 1, /* Set this after sending the first message, so 72 we can detect echoes/backlogs. */ 73 } jabber_chat_flags_t; 66 74 67 75 struct jabber_data … … 105 113 struct jabber_cache_entry 106 114 { 115 time_t saved_at; 107 116 struct xt_node *node; 108 117 jabber_cache_event func; … … 175 184 #define JABBER_PACKET_ID "BeeP" 176 185 #define JABBER_CACHED_ID "BeeC" 186 187 /* The number of seconds to keep cached packets before garbage collecting 188 them. This gc is done on every keepalive (every minute). */ 189 #define JABBER_CACHE_MAX_AGE 600 177 190 178 191 /* RFC 392[01] stuff */ … … 198 211 #define XMLNS_MUC "http://jabber.org/protocol/muc" /* XEP-0045 */ 199 212 #define XMLNS_MUC_USER "http://jabber.org/protocol/muc#user" /* XEP-0045 */ 213 #define XMLNS_CAPS "http://jabber.org/protocol/caps" /* XEP-0115 */ 200 214 #define XMLNS_FEATURE "http://jabber.org/protocol/feature-neg" /* XEP-0020 */ 201 215 #define XMLNS_SI "http://jabber.org/protocol/si" /* XEP-0095 */ -
protocols/jabber/jabber_util.c
r0fbd3a6d r1ba7e8f 146 146 entry->node = node; 147 147 entry->func = func; 148 entry->saved_at = time( NULL ); 148 149 g_hash_table_insert( jd->node_cache, xt_find_attr( node, "id" ), entry ); 149 150 } … … 167 168 { 168 169 struct jabber_data *jd = ic->proto_data; 169 170 g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL ); 171 } 172 173 gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer nullpointer ) 170 time_t threshold = time( NULL ) - JABBER_CACHE_MAX_AGE; 171 172 g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, &threshold ); 173 } 174 175 gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer threshold_ ) 174 176 { 175 177 struct jabber_cache_entry *entry = entry_; 176 struct xt_node *node = entry->node; 177 178 if( node->flags & XT_SEEN ) 179 return TRUE; 180 else 181 { 182 node->flags |= XT_SEEN; 183 return FALSE; 184 } 178 time_t *threshold = threshold_; 179 180 return entry->saved_at < *threshold; 185 181 } 186 182 … … 204 200 if( entry == NULL ) 205 201 { 206 imcb_log( ic, "W ARNING: Received %s-%s packet with unknown/expired ID %s!",202 imcb_log( ic, "Warning: Received %s-%s packet with unknown/expired ID %s!", 207 203 node->name, xt_find_attr( node, "type" ) ? : "(no type)", s ); 208 204 } … … 403 399 if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) ) 404 400 { 401 /* Just return the first one for this bare JID. */ 402 if( flags & GET_BUDDY_FIRST ) 403 { 404 *s = '/'; 405 g_free( jid ); 406 return bud; 407 } 408 405 409 /* Is this one of those no-resource buddies? */ 406 410 if( bud->resource == NULL ) 407 411 { 412 *s = '/'; 408 413 g_free( jid ); 409 414 return NULL; 410 415 } 411 else 412 { 413 /* See if there's an exact match. */ 414 for( ; bud; bud = bud->next ) 415 if( g_strcasecmp( bud->resource, s + 1 ) == 0 ) 416 break; 417 } 416 417 /* See if there's an exact match. */ 418 for( ; bud; bud = bud->next ) 419 if( g_strcasecmp( bud->resource, s + 1 ) == 0 ) 420 break; 418 421 } 419 422 else … … 424 427 is done to handle conferences properly. */ 425 428 none_found = 1; 429 /* TODO(wilmer): Find out what I was thinking when I 430 wrote this??? And then fix it. This makes me sad... */ 426 431 } 427 432 … … 453 458 else if( ( bud->resource == NULL || bud->next == NULL ) ) 454 459 /* No need for selection if there's only one option. */ 460 return bud; 461 else if( flags & GET_BUDDY_FIRST ) 462 /* Looks like the caller doesn't care about details. */ 455 463 return bud; 456 464 -
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 -
protocols/msn/msn.c
r0fbd3a6d r1ba7e8f 35 35 s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc ); 36 36 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 37 38 s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 37 39 } 38 40 … … 88 90 msn_sb_destroy( md->switchboards->data ); 89 91 90 if( md->msgq ) 91 { 92 struct msn_message *m; 93 94 for( l = md->msgq; l; l = l->next ) 95 { 96 m = l->data; 97 98 imcb_log( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); 99 g_free( m->who ); 100 g_free( m->text ); 101 g_free( m ); 102 } 103 g_slist_free( md->msgq ); 104 } 92 msn_msgq_purge( ic, &md->msgq ); 105 93 106 94 while( md->groupcount > 0 ) -
protocols/msn/msn.h
r0fbd3a6d r1ba7e8f 29 29 #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r" 30 30 31 #ifdef _WIN3232 #define debug 31 #ifdef DEBUG 32 #define debug( text... ) imcb_log( ic, text ); 33 33 #else 34 #define debug( text... ) irc_usermsg( IRC, text );35 #undef debug36 34 #define debug( text... ) 37 35 #endif … … 66 64 GSList *msgq; 67 65 GSList *switchboards; 66 int sb_failures; 67 time_t first_sb_failure; 68 68 69 const struct msn_away_state *away_state; 69 70 70 int buddycount; 71 71 int groupcount; … … 158 158 int msn_handler( struct msn_handler_data *h ); 159 159 char *msn_http_encode( const char *input ); 160 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 160 161 161 162 /* tables.c */ -
protocols/msn/msn_util.c
r0fbd3a6d r1ba7e8f 339 339 return ret; 340 340 } 341 342 void msn_msgq_purge( struct im_connection *ic, GSList **list ) 343 { 344 struct msn_message *m; 345 GString *ret; 346 GSList *l; 347 348 l = *list; 349 if( l == NULL ) 350 return; 351 352 m = l->data; 353 ret = g_string_sized_new( 1024 ); 354 g_string_printf( ret, "Warning: Cleaning up MSN (switchboard) connection with unsent " 355 "messages to %s:", m->who ? m->who : "unknown recipient" ); 356 357 while( l ) 358 { 359 m = l->data; 360 361 g_string_append_printf( ret, "\n%s", m->text ); 362 363 g_free( m->who ); 364 g_free( m->text ); 365 g_free( m ); 366 367 l = l->next; 368 } 369 g_slist_free( *list ); 370 *list = NULL; 371 372 imcb_log( ic, ret->str ); 373 g_string_free( ret, TRUE ); 374 } -
protocols/msn/ns.c
r0fbd3a6d r1ba7e8f 584 584 else 585 585 { 586 debug( "Received unknown command from main server: %s", cmd[0] );586 /* debug( "Received unknown command from main server: %s", cmd[0] ); */ 587 587 } 588 588 … … 643 643 char *folders = msn_findheader( body, "Folders-Unread:", blen ); 644 644 645 if( inbox && folders )645 if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) ) 646 646 { 647 647 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); … … 653 653 char *fromname = msn_findheader( body, "From:", blen ); 654 654 655 if( from && fromname )655 if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) ) 656 656 { 657 657 imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); -
protocols/msn/sb.c
r0fbd3a6d r1ba7e8f 128 128 if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 ) 129 129 { 130 buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 );130 buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 + 1 ); 131 131 i = strlen( MSN_MESSAGE_HEADERS ); 132 132 … … 207 207 debug( "Destroying switchboard: %s", sb->who ? sb->who : sb->key ? sb->key : "" ); 208 208 209 if( sb->msgq ) 210 { 211 struct msn_message *m; 212 GSList *l; 213 214 for( l = sb->msgq; l; l = l->next ) 215 { 216 m = l->data; 217 218 g_free( m->who ); 219 g_free( m->text ); 220 g_free( m ); 221 } 222 g_slist_free( sb->msgq ); 223 224 imcb_log( ic, "Warning: Closing down MSN switchboard connection with " 225 "unsent message to %s, you'll have to resend it.", 226 sb->who ? sb->who : "(unknown)" ); 227 } 209 msn_msgq_purge( ic, &sb->msgq ); 228 210 229 211 if( sb->key ) g_free( sb->key ); … … 266 248 if( source != sb->fd ) 267 249 { 268 debug( "E RROR%d while connecting to switchboard server", 1 );250 debug( "Error %d while connecting to switchboard server", 1 ); 269 251 msn_sb_destroy( sb ); 270 252 return FALSE; … … 287 269 sb->inp = b_input_add( sb->fd, GAIM_INPUT_READ, msn_sb_callback, sb ); 288 270 else 289 debug( "E RROR%d while connecting to switchboard server", 2 );271 debug( "Error %d while connecting to switchboard server", 2 ); 290 272 291 273 return FALSE; … … 295 277 { 296 278 struct msn_switchboard *sb = data; 279 struct im_connection *ic = sb->ic; 280 struct msn_data *md = ic->proto_data; 297 281 298 282 if( msn_handler( sb->handler ) == -1 ) 299 283 { 300 debug( "ERROR: Switchboard died" ); 284 time_t now = time( NULL ); 285 286 if( now - md->first_sb_failure > 600 ) 287 { 288 /* It's not really the first one, but the start of this "series". 289 With this, the warning below will be shown only if this happens 290 at least three times in ten minutes. This algorithm isn't 291 perfect, but for this purpose it will do. */ 292 md->first_sb_failure = now; 293 md->sb_failures = 0; 294 } 295 296 debug( "Error: Switchboard died" ); 297 if( ++ md->sb_failures >= 3 ) 298 imcb_log( ic, "Warning: Many switchboard failures on MSN connection. " 299 "There might be problems delivering your messages." ); 300 301 if( sb->msgq != NULL ) 302 { 303 char buf[1024]; 304 305 if( md->msgq == NULL ) 306 { 307 md->msgq = sb->msgq; 308 } 309 else 310 { 311 GSList *l; 312 313 for( l = md->msgq; l->next; l = l->next ); 314 l->next = sb->msgq; 315 } 316 sb->msgq = NULL; 317 318 debug( "Moved queued messages back to the main queue, creating a new switchboard to retry." ); 319 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 320 if( !msn_write( ic, buf, strlen( buf ) ) ) 321 return FALSE; 322 } 323 301 324 msn_sb_destroy( sb ); 302 325 … … 304 327 } 305 328 else 329 { 306 330 return TRUE; 331 } 307 332 } 308 333 … … 491 516 } 492 517 } 518 else if( strcmp( cmd[0], "NAK" ) == 0 ) 519 { 520 if( sb->who ) 521 { 522 imcb_log( ic, "The MSN servers could not deliver one of your messages to %s.", sb->who ); 523 } 524 else 525 { 526 imcb_log( ic, "The MSN servers could not deliver one of your groupchat messages to all participants." ); 527 } 528 } 493 529 else if( strcmp( cmd[0], "BYE" ) == 0 ) 494 530 { … … 544 580 if( sb->who ) 545 581 { 546 struct msn_message *m;547 GSList *l;548 549 582 /* Apparently some invitation failed. We might want to use this 550 583 board later, so keep it as a spare. */ … … 553 586 554 587 /* Also clear the msgq, otherwise someone else might get them. */ 555 for( l = sb->msgq; l; l = l->next ) 556 { 557 m = l->data; 558 g_free( m->who ); 559 g_free( m->text ); 560 g_free( m ); 561 } 562 g_slist_free( sb->msgq ); 563 sb->msgq = NULL; 588 msn_msgq_purge( ic, &sb->msgq ); 564 589 } 565 590 … … 569 594 else 570 595 { 571 debug( "Received unknown command from switchboard server: %s", cmd[0] );596 /* debug( "Received unknown command from switchboard server: %s", cmd[0] ); */ 572 597 } 573 598 -
protocols/nogaim.c
r0fbd3a6d r1ba7e8f 625 625 } 626 626 627 void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u _int32_t flags, time_t sent_at )627 void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at ) 628 628 { 629 629 irc_t *irc = ic->irc; … … 676 676 } 677 677 678 void imcb_buddy_typing( struct im_connection *ic, char *handle, u _int32_t flags )678 void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ) 679 679 { 680 680 user_t *u; … … 690 690 irc_privmsg( ic->irc, u, "PRIVMSG", ic->irc->nick, NULL, buf ); 691 691 } 692 } 693 694 struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ) 695 { 696 struct groupchat *c; 697 698 /* This one just creates the conversation structure, user won't see anything yet */ 699 700 if( ic->groupchats ) 701 { 702 for( c = ic->groupchats; c->next; c = c->next ); 703 c = c->next = g_new0( struct groupchat, 1 ); 704 } 705 else 706 ic->groupchats = c = g_new0( struct groupchat, 1 ); 707 708 c->ic = ic; 709 c->title = g_strdup( handle ); 710 c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ ); 711 c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title ); 712 713 if( set_getbool( &ic->irc->set, "debug" ) ) 714 imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle ); 715 716 return c; 692 717 } 693 718 … … 728 753 g_free( c->channel ); 729 754 g_free( c->title ); 755 g_free( c->topic ); 730 756 g_free( c ); 731 757 } 732 758 } 733 759 734 void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u _int32_t flags, time_t sent_at )760 void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ) 735 761 { 736 762 struct im_connection *ic = c->ic; … … 758 784 } 759 785 g_free( wrapped ); 786 } 787 788 void imcb_chat_log( struct groupchat *c, char *format, ... ) 789 { 790 irc_t *irc = c->ic->irc; 791 va_list params; 792 char *text; 793 user_t *u; 794 795 va_start( params, format ); 796 text = g_strdup_vprintf( format, params ); 797 va_end( params ); 798 799 u = user_find( irc, irc->mynick ); 800 801 irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text ); 802 803 g_free( text ); 760 804 } 761 805 … … 781 825 if( c->joined && u ) 782 826 irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic ); 783 }784 785 struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )786 {787 struct groupchat *c;788 789 /* This one just creates the conversation structure, user won't see anything yet */790 791 if( ic->groupchats )792 {793 for( c = ic->groupchats; c->next; c = c->next );794 c = c->next = g_new0( struct groupchat, 1 );795 }796 else797 ic->groupchats = c = g_new0( struct groupchat, 1 );798 799 c->ic = ic;800 c->title = g_strdup( handle );801 c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );802 c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title );803 804 if( set_getbool( &ic->irc->set, "debug" ) )805 imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );806 807 return c;808 827 } 809 828 -
protocols/nogaim.h
r0fbd3a6d r1ba7e8f 69 69 { 70 70 account_t *acc; 71 u _int32_t flags;71 uint32_t flags; 72 72 73 73 /* each connection then can have its own protocol-specific data */ … … 286 286 /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle ); 287 287 /* Call when a handle says something. 'flags' and 'sent_at may be just 0. */ 288 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u _int32_t flags, time_t sent_at );289 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u _int32_t flags );288 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, uint32_t flags, time_t sent_at ); 289 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, uint32_t flags ); 290 290 G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle ); 291 291 … … 303 303 G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ); 304 304 /* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */ 305 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ); 305 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, uint32_t flags, time_t sent_at ); 306 /* System messages specific to a groupchat, so they can be displayed in the right context. */ 307 G_MODULE_EXPORT void imcb_chat_log( struct groupchat *c, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 306 308 /* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */ 307 309 G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ); -
protocols/oscar/oscar.c
r0fbd3a6d r1ba7e8f 91 91 gboolean icq; 92 92 GSList *evilhack; 93 94 GHashTable *ips; 93 95 94 96 struct { … … 356 358 struct oscar_data *odata = ic->proto_data = g_new0(struct oscar_data, 1); 357 359 358 if (!isdigit(acc->user[0])) { 360 if (isdigit(acc->user[0])) 361 odata->icq = TRUE; 362 else 359 363 ic->flags |= OPT_DOES_HTML; 360 }361 364 362 365 sess = g_new0(aim_session_t, 1); … … 411 414 g_free(cr); 412 415 } 416 if (odata->ips) 417 g_hash_table_destroy(odata->ips); 413 418 if (odata->email) 414 419 g_free(odata->email); … … 987 992 signon = time(NULL) - info->sessionlen; 988 993 994 if (info->present & AIM_USERINFO_PRESENT_ICQIPADDR) { 995 uint32_t *uin = g_new0(uint32_t, 1); 996 997 if (od->ips == NULL) 998 od->ips = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, NULL); 999 1000 if (sscanf(info->sn, "%d", uin) == 1) 1001 g_hash_table_insert(od->ips, uin, (gpointer) (long) info->icqinfo.ipaddr); 1002 } 1003 989 1004 tmp = g_strdup(normalize(ic->acc->user)); 990 1005 if (!strcmp(tmp, normalize(info->sn))) … … 1051 1066 g_snprintf(tmp, BUF_LONG, "%s", args->msg); 1052 1067 } else { 1053 int i;1068 aim_mpmsg_section_t *part; 1054 1069 1055 1070 *tmp = 0; 1056 for (i = 0; i < args->mpmsg.numparts; i ++) { 1057 g_strlcat(tmp, (char*) args->mpmsg.parts[i].data, BUF_LONG); 1058 g_strlcat(tmp, "\n", BUF_LONG); 1071 for (part = args->mpmsg.parts; part; part = part->next) { 1072 if (part->data) { 1073 g_strlcat(tmp, (char*) part->data, BUF_LONG); 1074 g_strlcat(tmp, "\n", BUF_LONG); 1075 } 1059 1076 } 1060 1077 } … … 2219 2236 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) 2220 2237 { 2221 struct im_connection *ic = sess->aux_data; 2222 gchar who[16]; 2223 GString *str; 2224 va_list ap; 2225 struct aim_icq_info *info; 2226 2227 va_start(ap, fr); 2228 info = va_arg(ap, struct aim_icq_info *); 2229 va_end(ap); 2230 2231 if (!info->uin) 2232 return 0; 2233 2234 str = g_string_sized_new(100); 2235 g_snprintf(who, sizeof(who), "%u", info->uin); 2236 2237 g_string_sprintfa(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), 2238 info->nick ? info->nick : "-"); 2239 info_string_append(str, "\n", _("First Name"), info->first); 2240 info_string_append(str, "\n", _("Last Name"), info->last); 2241 info_string_append(str, "\n", _("Email Address"), info->email); 2242 if (info->numaddresses && info->email2) { 2243 int i; 2244 for (i = 0; i < info->numaddresses; i++) { 2245 info_string_append(str, "\n", _("Email Address"), info->email2[i]); 2246 } 2247 } 2248 info_string_append(str, "\n", _("Mobile Phone"), info->mobile); 2249 if (info->gender != 0) 2250 info_string_append(str, "\n", _("Gender"), info->gender==1 ? _("Female") : _("Male")); 2251 if (info->birthyear || info->birthmonth || info->birthday) { 2252 char date[30]; 2253 struct tm tm; 2254 tm.tm_mday = (int)info->birthday; 2255 tm.tm_mon = (int)info->birthmonth-1; 2256 tm.tm_year = (int)info->birthyear%100; 2257 strftime(date, sizeof(date), "%Y-%m-%d", &tm); 2258 info_string_append(str, "\n", _("Birthday"), date); 2259 } 2260 if (info->age) { 2261 char age[5]; 2262 g_snprintf(age, sizeof(age), "%hhd", info->age); 2263 info_string_append(str, "\n", _("Age"), age); 2264 } 2265 info_string_append(str, "\n", _("Personal Web Page"), info->personalwebpage); 2266 if (info->info && info->info[0]) { 2267 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), 2268 info->info, _("End of Additional Information")); 2269 } 2270 g_string_sprintfa(str, "\n"); 2271 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 2272 g_string_sprintfa(str, "%s:", _("Home Address")); 2273 info_string_append(str, "\n", _("Address"), info->homeaddr); 2274 info_string_append(str, "\n", _("City"), info->homecity); 2275 info_string_append(str, "\n", _("State"), info->homestate); 2276 info_string_append(str, "\n", _("Zip Code"), info->homezip); 2277 g_string_sprintfa(str, "\n"); 2278 } 2279 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 2280 g_string_sprintfa(str, "%s:", _("Work Address")); 2281 info_string_append(str, "\n", _("Address"), info->workaddr); 2282 info_string_append(str, "\n", _("City"), info->workcity); 2283 info_string_append(str, "\n", _("State"), info->workstate); 2284 info_string_append(str, "\n", _("Zip Code"), info->workzip); 2285 g_string_sprintfa(str, "\n"); 2286 } 2287 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 2288 g_string_sprintfa(str, "%s:", _("Work Information")); 2289 info_string_append(str, "\n", _("Company"), info->workcompany); 2290 info_string_append(str, "\n", _("Division"), info->workdivision); 2291 info_string_append(str, "\n", _("Position"), info->workposition); 2292 if (info->workwebpage && info->workwebpage[0]) { 2293 info_string_append(str, "\n", _("Web Page"), info->workwebpage); 2294 } 2295 g_string_sprintfa(str, "\n"); 2296 } 2297 2298 imcb_log(ic, "%s\n%s", _("User Info"), str->str); 2299 g_string_free(str, TRUE); 2300 2301 return 1; 2238 struct im_connection *ic = sess->aux_data; 2239 struct oscar_data *od = ic->proto_data; 2240 gchar who[16]; 2241 GString *str; 2242 va_list ap; 2243 struct aim_icq_info *info; 2244 uint32_t ip; 2245 2246 va_start(ap, fr); 2247 info = va_arg(ap, struct aim_icq_info *); 2248 va_end(ap); 2249 2250 if (!info->uin) 2251 return 0; 2252 2253 str = g_string_sized_new(512); 2254 g_snprintf(who, sizeof(who), "%u", info->uin); 2255 2256 g_string_printf(str, "%s: %s - %s: %s", _("UIN"), who, _("Nick"), 2257 info->nick ? info->nick : "-"); 2258 g_string_append_printf(str, "\n%s: %s", _("First Name"), info->first); 2259 g_string_append_printf(str, "\n%s: %s", _("Last Name"), info->last); 2260 g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email); 2261 if (info->numaddresses && info->email2) { 2262 int i; 2263 for (i = 0; i < info->numaddresses; i++) { 2264 g_string_append_printf(str, "\n%s: %s", _("Email Address"), info->email2[i]); 2265 } 2266 } 2267 if ((ip = (long) g_hash_table_lookup(od->ips, &info->uin)) != 0) { 2268 g_string_append_printf(str, "\n%s: %d.%d.%d.%d", _("Last used IP address"), 2269 (ip >> 24), (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); 2270 } 2271 g_string_append_printf(str, "\n%s: %s", _("Mobile Phone"), info->mobile); 2272 if (info->gender != 0) 2273 g_string_append_printf(str, "\n%s: %s", _("Gender"), info->gender==1 ? _("Female") : _("Male")); 2274 if (info->birthyear || info->birthmonth || info->birthday) { 2275 char date[30]; 2276 struct tm tm; 2277 memset(&tm, 0, sizeof(struct tm)); 2278 tm.tm_mday = (int)info->birthday; 2279 tm.tm_mon = (int)info->birthmonth-1; 2280 tm.tm_year = (int)info->birthyear%100; 2281 strftime(date, sizeof(date), "%Y-%m-%d", &tm); 2282 g_string_append_printf(str, "\n%s: %s", _("Birthday"), date); 2283 } 2284 if (info->age) { 2285 char age[5]; 2286 g_snprintf(age, sizeof(age), "%hhd", info->age); 2287 g_string_append_printf(str, "\n%s: %s", _("Age"), age); 2288 } 2289 g_string_append_printf(str, "\n%s: %s", _("Personal Web Page"), info->personalwebpage); 2290 if (info->info && info->info[0]) { 2291 g_string_sprintfa(str, "\n%s:\n%s\n%s", _("Additional Information"), 2292 info->info, _("End of Additional Information")); 2293 } 2294 g_string_append_c(str, '\n'); 2295 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 2296 g_string_append_printf(str, "%s:", _("Home Address")); 2297 g_string_append_printf(str, "\n%s: %s", _("Address"), info->homeaddr); 2298 g_string_append_printf(str, "\n%s: %s", _("City"), info->homecity); 2299 g_string_append_printf(str, "\n%s: %s", _("State"), info->homestate); 2300 g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->homezip); 2301 g_string_append_c(str, '\n'); 2302 } 2303 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 2304 g_string_append_printf(str, "%s:", _("Work Address")); 2305 g_string_append_printf(str, "\n%s: %s", _("Address"), info->workaddr); 2306 g_string_append_printf(str, "\n%s: %s", _("City"), info->workcity); 2307 g_string_append_printf(str, "\n%s: %s", _("State"), info->workstate); 2308 g_string_append_printf(str, "\n%s: %s", _("Zip Code"), info->workzip); 2309 g_string_append_c(str, '\n'); 2310 } 2311 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 2312 g_string_append_printf(str, "%s:", _("Work Information")); 2313 g_string_append_printf(str, "\n%s: %s", _("Company"), info->workcompany); 2314 g_string_append_printf(str, "\n%s: %s", _("Division"), info->workdivision); 2315 g_string_append_printf(str, "\n%s: %s", _("Position"), info->workposition); 2316 if (info->workwebpage && info->workwebpage[0]) { 2317 g_string_append_printf(str, "\n%s: %s", _("Web Page"), info->workwebpage); 2318 } 2319 g_string_append_c(str, '\n'); 2320 } 2321 2322 imcb_log(ic, "%s\n%s", _("User Info"), str->str); 2323 g_string_free(str, TRUE); 2324 2325 return 1; 2302 2326 2303 2327 } … … 2433 2457 /* User has stopped typing */ 2434 2458 imcb_buddy_typing(ic, sn, 0); 2435 } 2459 } 2436 2460 2437 2461 return 1; -
protocols/oscar/service.c
r0fbd3a6d r1ba7e8f 894 894 */ 895 895 } else 896 imcb_error(sess->aux_data, "W ARNING: unknown hash request");896 imcb_error(sess->aux_data, "Warning: unknown hash request"); 897 897 898 898 } -
protocols/oscar/txqueue.c
r0fbd3a6d r1ba7e8f 80 80 81 81 if (!fr->conn) { 82 imcb_error(sess->aux_data, "W ARNING: enqueueing packet with no connection");82 imcb_error(sess->aux_data, "Warning: enqueueing packet with no connection"); 83 83 fr->conn = aim_getconn_type(sess, AIM_CONN_TYPE_BOS); 84 84 } -
protocols/yahoo/yahoo.c
r0fbd3a6d r1ba7e8f 125 125 126 126 return( g_strndup( in, len ) ); 127 } 128 129 static void byahoo_init( account_t *acc ) 130 { 131 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 127 132 } 128 133 … … 349 354 struct prpl *ret = g_new0(struct prpl, 1); 350 355 ret->name = "yahoo"; 356 ret->init = byahoo_init; 351 357 352 358 ret->login = byahoo_login; … … 618 624 { 619 625 struct im_connection *ic = byahoo_get_ic_by_id( id ); 620 char *m = byahoo_strip( msg ); 621 622 imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); 623 g_free( m ); 626 char *m; 627 628 if( msg ) 629 { 630 m = byahoo_strip( msg ); 631 imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); 632 g_free( m ); 633 } 624 634 } 625 635 … … 923 933 struct im_connection *ic = byahoo_get_ic_by_id( id ); 924 934 925 if( from && subj ) 935 if( !set_getbool( &ic->acc->set, "mail_notifications" ) ) 936 ; /* The user doesn't care. */ 937 else if( from && subj ) 926 938 imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); 927 939 else if( cnt > 0 )
Note: See TracChangeset
for help on using the changeset viewer.