Changeset 1ba7e8f for protocols/msn/sb.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/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
Note: See TracChangeset
for help on using the changeset viewer.