Changeset 85d7b85 for protocols/msn/msn_util.c
- Timestamp:
- 2008-04-02T14:22:57Z (16 years ago)
- Branches:
- master
- Children:
- f9dbc99
- Parents:
- 875ad42 (diff), dd34575 (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/msn_util.c
r875ad42 r85d7b85 28 28 #include <ctype.h> 29 29 30 int msn_write( struct gaim_connection *gc, char *s, int len )31 { 32 struct msn_data *md = gc->proto_data;30 int msn_write( struct im_connection *ic, char *s, int len ) 31 { 32 struct msn_data *md = ic->proto_data; 33 33 int st; 34 34 … … 36 36 if( st != len ) 37 37 { 38 hide_login_progress_error( gc, "Short write() to main server" );39 signoff( gc);38 imcb_error( ic, "Short write() to main server" ); 39 imc_logout( ic, TRUE ); 40 40 return( 0 ); 41 41 } … … 44 44 } 45 45 46 int msn_logged_in( struct gaim_connection *gc )47 { 48 account_online( gc );46 int msn_logged_in( struct im_connection *ic ) 47 { 48 imcb_connected( ic ); 49 49 50 50 return( 0 ); 51 51 } 52 52 53 int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char *realname_ ) 54 { 55 struct msn_data *md = gc->proto_data; 56 GSList *l, **lp = NULL; 53 int msn_buddy_list_add( struct im_connection *ic, char *list, char *who, char *realname_ ) 54 { 55 struct msn_data *md = ic->proto_data; 57 56 char buf[1024], *realname; 58 57 59 if( strcmp( list, "AL" ) == 0 ) 60 lp = &gc->permit; 61 else if( strcmp( list, "BL" ) == 0 ) 62 lp = &gc->deny; 63 64 if( lp ) 65 for( l = *lp; l; l = l->next ) 66 if( g_strcasecmp( l->data, who ) == 0 ) 67 return( 1 ); 68 69 realname = g_new0( char, strlen( realname_ ) * 3 + 1 ); 70 strcpy( realname, realname_ ); 71 http_encode( realname ); 58 realname = msn_http_encode( realname_ ); 72 59 73 60 g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname ); 74 if( msn_write( gc, buf, strlen( buf ) ) )61 if( msn_write( ic, buf, strlen( buf ) ) ) 75 62 { 76 63 g_free( realname ); 77 64 78 if( lp )79 *lp = g_slist_append( *lp, g_strdup( who ) );80 81 65 return( 1 ); 82 66 } … … 87 71 } 88 72 89 int msn_buddy_list_remove( struct gaim_connection *gc, char *list, char *who ) 90 { 91 struct msn_data *md = gc->proto_data; 92 GSList *l = NULL, **lp = NULL; 73 int msn_buddy_list_remove( struct im_connection *ic, char *list, char *who ) 74 { 75 struct msn_data *md = ic->proto_data; 93 76 char buf[1024]; 94 77 95 if( strcmp( list, "AL" ) == 0 )96 lp = &gc->permit;97 else if( strcmp( list, "BL" ) == 0 )98 lp = &gc->deny;99 100 if( lp )101 {102 for( l = *lp; l; l = l->next )103 if( g_strcasecmp( l->data, who ) == 0 )104 break;105 106 if( !l )107 return( 1 );108 }109 110 78 g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who ); 111 if( msn_write( gc, buf, strlen( buf ) ) ) 112 { 113 if( lp ) 114 *lp = g_slist_remove( *lp, l->data ); 115 79 if( msn_write( ic, buf, strlen( buf ) ) ) 116 80 return( 1 ); 117 }118 81 119 82 return( 0 ); … … 122 85 struct msn_buddy_ask_data 123 86 { 124 struct gaim_connection *gc;87 struct im_connection *ic; 125 88 char *handle; 126 89 char *realname; … … 129 92 static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) 130 93 { 131 msn_buddy_list_add( bla-> gc, "AL", bla->handle, bla->realname );132 133 if( find_buddy( bla->gc, bla->handle ) == NULL )134 show_got_added( bla->gc, bla->handle, NULL );94 msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname ); 95 96 if( imcb_find_buddy( bla->ic, bla->handle ) == NULL ) 97 imcb_ask_add( bla->ic, bla->handle, NULL ); 135 98 136 99 g_free( bla->handle ); … … 141 104 static void msn_buddy_ask_no( gpointer w, struct msn_buddy_ask_data *bla ) 142 105 { 143 msn_buddy_list_add( bla-> gc, "BL", bla->handle, bla->realname );106 msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname ); 144 107 145 108 g_free( bla->handle ); … … 148 111 } 149 112 150 void msn_buddy_ask( struct gaim_connection *gc, char *handle, char *realname )113 void msn_buddy_ask( struct im_connection *ic, char *handle, char *realname ) 151 114 { 152 115 struct msn_buddy_ask_data *bla = g_new0( struct msn_buddy_ask_data, 1 ); 153 116 char buf[1024]; 154 117 155 bla-> gc = gc;118 bla->ic = ic; 156 119 bla->handle = g_strdup( handle ); 157 120 bla->realname = g_strdup( realname ); … … 160 123 "The user %s (%s) wants to add you to his/her buddy list.", 161 124 handle, realname ); 162 do_ask_dialog( gc, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no );125 imcb_ask( ic, buf, bla, msn_buddy_ask_yes, msn_buddy_ask_no ); 163 126 } 164 127 … … 350 313 return( 1 ); 351 314 } 315 316 /* The difference between this function and the normal http_encode() function 317 is that this one escapes every 7-bit ASCII character because this is said 318 to avoid some lame server-side checks when setting a real-name. Also, 319 non-ASCII characters are not escaped because MSN servers don't seem to 320 appreciate that! */ 321 char *msn_http_encode( const char *input ) 322 { 323 char *ret, *s; 324 int i; 325 326 ret = s = g_new0( char, strlen( input ) * 3 + 1 ); 327 for( i = 0; input[i]; i ++ ) 328 if( input[i] & 128 ) 329 { 330 *s = input[i]; 331 s ++; 332 } 333 else 334 { 335 g_snprintf( s, 4, "%%%02X", input[i] ); 336 s += 3; 337 } 338 339 return ret; 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 }
Note: See TracChangeset
for help on using the changeset viewer.