Changeset 0da65d5 for protocols/msn/msn.c
- Timestamp:
- 2007-03-31T05:40:45Z (18 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
rfa29d093 r0da65d5 29 29 static char *msn_set_display_name( set_t *set, char *value ); 30 30 31 static void msn_ acc_init( account_t *acc )31 static void msn_init( account_t *acc ) 32 32 { 33 33 set_t *s; … … 39 39 static void msn_login( account_t *acc ) 40 40 { 41 struct gaim_connection *gc = new_gaim_conn( acc );41 struct im_connection *ic = new_gaim_conn( acc ); 42 42 struct msn_data *md = g_new0( struct msn_data, 1 ); 43 43 44 gc->proto_data = md;44 ic->proto_data = md; 45 45 md->fd = -1; 46 46 47 47 if( strchr( acc->user, '@' ) == NULL ) 48 48 { 49 hide_login_progress( gc, "Invalid account name" );50 signoff( gc );49 hide_login_progress( ic, "Invalid account name" ); 50 signoff( ic ); 51 51 return; 52 52 } 53 53 54 set_login_progress( gc, 1, "Connecting" );55 56 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, gc );54 set_login_progress( ic, 1, "Connecting" ); 55 56 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic ); 57 57 if( md->fd < 0 ) 58 58 { 59 hide_login_progress( gc, "Could not connect to server" );60 signoff( gc );59 hide_login_progress( ic, "Could not connect to server" ); 60 signoff( ic ); 61 61 return; 62 62 } 63 63 64 md-> gc = gc;64 md->ic = ic; 65 65 md->away_state = msn_away_state_list; 66 66 67 msn_connections = g_slist_append( msn_connections, gc );68 } 69 70 static void msn_ close( struct gaim_connection *gc )71 { 72 struct msn_data *md = gc->proto_data;67 msn_connections = g_slist_append( msn_connections, ic ); 68 } 69 70 static void msn_logout( struct im_connection *ic ) 71 { 72 struct msn_data *md = ic->proto_data; 73 73 GSList *l; 74 74 … … 96 96 m = l->data; 97 97 98 serv_got_crap( gc, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who );98 serv_got_crap( ic, "Warning: Closing down MSN connection with unsent message to %s, you'll have to resend it.", m->who ); 99 99 g_free( m->who ); 100 100 g_free( m->text ); … … 111 111 } 112 112 113 for( l = gc->permit; l; l = l->next )113 for( l = ic->permit; l; l = l->next ) 114 114 g_free( l->data ); 115 g_slist_free( gc->permit );116 117 for( l = gc->deny; l; l = l->next )115 g_slist_free( ic->permit ); 116 117 for( l = ic->deny; l; l = l->next ) 118 118 g_free( l->data ); 119 g_slist_free( gc->deny );120 121 msn_connections = g_slist_remove( msn_connections, gc );122 } 123 124 static int msn_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )119 g_slist_free( ic->deny ); 120 121 msn_connections = g_slist_remove( msn_connections, ic ); 122 } 123 124 static int msn_send_im( struct im_connection *ic, char *who, char *message, int away ) 125 125 { 126 126 struct msn_switchboard *sb; 127 struct msn_data *md = gc->proto_data;128 129 if( ( sb = msn_sb_by_handle( gc, who ) ) )127 struct msn_data *md = ic->proto_data; 128 129 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 130 130 { 131 131 return( msn_sb_sendmessage( sb, message ) ); … … 142 142 143 143 /* FIXME: *CHECK* the reliability of using spare sb's! */ 144 if( ( sb = msn_sb_spare( gc ) ) )144 if( ( sb = msn_sb_spare( ic ) ) ) 145 145 { 146 146 debug( "Trying to use a spare switchboard to message %s", who ); … … 160 160 /* If we reach this line, there was no spare switchboard, so let's make one. */ 161 161 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 162 if( !msn_write( gc, buf, strlen( buf ) ) )162 if( !msn_write( ic, buf, strlen( buf ) ) ) 163 163 { 164 164 g_free( m->who ); … … 180 180 } 181 181 182 static GList *msn_away_states( struct gaim_connection *gc )182 static GList *msn_away_states( struct im_connection *ic ) 183 183 { 184 184 static GList *l = NULL; … … 192 192 } 193 193 194 static char *msn_get_status_string( struct gaim_connection *gc, int number )194 static char *msn_get_status_string( struct im_connection *ic, int number ) 195 195 { 196 196 const struct msn_away_state *st = msn_away_state_by_number( number ); … … 202 202 } 203 203 204 static void msn_set_away( struct gaim_connection *gc, char *state, char *message )204 static void msn_set_away( struct im_connection *ic, char *state, char *message ) 205 205 { 206 206 char buf[1024]; 207 struct msn_data *md = gc->proto_data;207 struct msn_data *md = ic->proto_data; 208 208 const struct msn_away_state *st; 209 209 … … 217 217 218 218 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, st->code ); 219 msn_write( gc, buf, strlen( buf ) );220 } 221 222 static void msn_set_ info( struct gaim_connection *gc, char *info )223 { 224 msn_set_display_name( set_find( & gc->acc->set, "display_name" ), info );225 } 226 227 static void msn_get_info(struct gaim_connection *gc, char *who)219 msn_write( ic, buf, strlen( buf ) ); 220 } 221 222 static void msn_set_my_name( struct im_connection *ic, char *info ) 223 { 224 msn_set_display_name( set_find( &ic->acc->set, "display_name" ), info ); 225 } 226 227 static void msn_get_info(struct im_connection *ic, char *who) 228 228 { 229 229 /* Just make an URL and let the user fetch the info */ 230 serv_got_crap( gc, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who );231 } 232 233 static void msn_add_buddy( struct gaim_connection *gc, char *who)234 { 235 msn_buddy_list_add( gc, "FL", who, who );236 } 237 238 static void msn_remove_buddy( struct gaim_connection *gc, char *who, char *group )239 { 240 msn_buddy_list_remove( gc, "FL", who );241 } 242 243 static int msn_chat_send( struct conversation *c, char *message)230 serv_got_crap( ic, "%s\n%s: %s%s", _("User Info"), _("For now, fetch yourself"), PROFILE_URL, who ); 231 } 232 233 static void msn_add_buddy( struct im_connection *ic, char *who, char *group ) 234 { 235 msn_buddy_list_add( ic, "FL", who, who ); 236 } 237 238 static void msn_remove_buddy( struct im_connection *ic, char *who, char *group ) 239 { 240 msn_buddy_list_remove( ic, "FL", who ); 241 } 242 243 static void msn_chat_send( struct groupchat *c, char *message, int flags ) 244 244 { 245 245 struct msn_switchboard *sb = msn_sb_by_chat( c ); 246 246 247 247 if( sb ) 248 return( msn_sb_sendmessage( sb, message ));249 else250 return( 0 );251 } 252 253 static void msn_chat_invite( struct conversation*c, char *msg, char *who )248 msn_sb_sendmessage( sb, message ); 249 /* FIXME: Error handling (although this can't happen unless something's 250 already severely broken) disappeared here! */ 251 } 252 253 static void msn_chat_invite( struct groupchat *c, char *msg, char *who ) 254 254 { 255 255 struct msn_switchboard *sb = msn_sb_by_chat( c ); … … 263 263 } 264 264 265 static void msn_chat_leave( struct conversation*c )265 static void msn_chat_leave( struct groupchat *c ) 266 266 { 267 267 struct msn_switchboard *sb = msn_sb_by_chat( c ); … … 271 271 } 272 272 273 static struct conversation *msn_chat_open( struct gaim_connection *gc, char *who )273 static struct groupchat *msn_chat_with( struct im_connection *ic, char *who ) 274 274 { 275 275 struct msn_switchboard *sb; 276 struct msn_data *md = gc->proto_data;276 struct msn_data *md = ic->proto_data; 277 277 char buf[1024]; 278 278 279 if( ( sb = msn_sb_by_handle( gc, who ) ) )279 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 280 280 { 281 281 debug( "Converting existing switchboard to %s to a groupchat", who ); … … 286 286 struct msn_message *m; 287 287 288 if( ( sb = msn_sb_spare( gc ) ) )288 if( ( sb = msn_sb_spare( ic ) ) ) 289 289 { 290 290 debug( "Trying to reuse an existing switchboard as a groupchat with %s", who ); … … 299 299 /* Request a new switchboard. */ 300 300 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 301 if( !msn_write( gc, buf, strlen( buf ) ) )301 if( !msn_write( ic, buf, strlen( buf ) ) ) 302 302 return( 0 ); 303 303 … … 317 317 } 318 318 319 static void msn_keepalive( struct gaim_connection *gc )320 { 321 msn_write( gc, "PNG\r\n", strlen( "PNG\r\n" ) );322 } 323 324 static void msn_add_permit( struct gaim_connection *gc, char *who )325 { 326 msn_buddy_list_add( gc, "AL", who, who );327 } 328 329 static void msn_rem_permit( struct gaim_connection *gc, char *who )330 { 331 msn_buddy_list_remove( gc, "AL", who );332 } 333 334 static void msn_add_deny( struct gaim_connection *gc, char *who )319 static void msn_keepalive( struct im_connection *ic ) 320 { 321 msn_write( ic, "PNG\r\n", strlen( "PNG\r\n" ) ); 322 } 323 324 static void msn_add_permit( struct im_connection *ic, char *who ) 325 { 326 msn_buddy_list_add( ic, "AL", who, who ); 327 } 328 329 static void msn_rem_permit( struct im_connection *ic, char *who ) 330 { 331 msn_buddy_list_remove( ic, "AL", who ); 332 } 333 334 static void msn_add_deny( struct im_connection *ic, char *who ) 335 335 { 336 336 struct msn_switchboard *sb; 337 337 338 msn_buddy_list_add( gc, "BL", who, who );338 msn_buddy_list_add( ic, "BL", who, who ); 339 339 340 340 /* If there's still a conversation with this person, close it. */ 341 if( ( sb = msn_sb_by_handle( gc, who ) ) )341 if( ( sb = msn_sb_by_handle( ic, who ) ) ) 342 342 { 343 343 msn_sb_destroy( sb ); … … 345 345 } 346 346 347 static void msn_rem_deny( struct gaim_connection *gc, char *who )348 { 349 msn_buddy_list_remove( gc, "BL", who );350 } 351 352 static int msn_send_typing( struct gaim_connection *gc, char *who, int typing )347 static void msn_rem_deny( struct im_connection *ic, char *who ) 348 { 349 msn_buddy_list_remove( ic, "BL", who ); 350 } 351 352 static int msn_send_typing( struct im_connection *ic, char *who, int typing ) 353 353 { 354 354 if( typing ) 355 return( msn_send_im( gc, who, TYPING_NOTIFICATION_MESSAGE, strlen( TYPING_NOTIFICATION_MESSAGE ), 0 ) );355 return( msn_send_im( ic, who, TYPING_NOTIFICATION_MESSAGE, 0 ) ); 356 356 else 357 357 return( 1 ); … … 361 361 { 362 362 account_t *acc = set->data; 363 struct gaim_connection *gc = acc->gc;363 struct im_connection *ic = acc->ic; 364 364 struct msn_data *md; 365 365 char buf[1024], *fn; 366 366 367 367 /* Double-check. */ 368 if( gc == NULL )368 if( ic == NULL ) 369 369 return NULL; 370 370 371 md = gc->proto_data;371 md = ic->proto_data; 372 372 373 373 if( strlen( value ) > 129 ) 374 374 { 375 serv_got_crap( gc, "Maximum name length exceeded" );375 serv_got_crap( ic, "Maximum name length exceeded" ); 376 376 return NULL; 377 377 } … … 379 379 fn = msn_http_encode( value ); 380 380 381 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );382 msn_write( gc, buf, strlen( buf ) );381 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->username, fn ); 382 msn_write( ic, buf, strlen( buf ) ); 383 383 g_free( fn ); 384 384 … … 389 389 } 390 390 391 void msn_init ()391 void msn_initmodule() 392 392 { 393 393 struct prpl *ret = g_new0(struct prpl, 1); … … 395 395 ret->name = "msn"; 396 396 ret->login = msn_login; 397 ret-> acc_init = msn_acc_init;398 ret-> close = msn_close;397 ret->init = msn_init; 398 ret->logout = msn_logout; 399 399 ret->send_im = msn_send_im; 400 400 ret->away_states = msn_away_states; 401 401 ret->get_status_string = msn_get_status_string; 402 402 ret->set_away = msn_set_away; 403 ret->set_info = msn_set_info;404 403 ret->get_info = msn_get_info; 404 ret->set_my_name = msn_set_my_name; 405 405 ret->add_buddy = msn_add_buddy; 406 406 ret->remove_buddy = msn_remove_buddy; … … 408 408 ret->chat_invite = msn_chat_invite; 409 409 ret->chat_leave = msn_chat_leave; 410 ret->chat_ open = msn_chat_open;410 ret->chat_with = msn_chat_with; 411 411 ret->keepalive = msn_keepalive; 412 412 ret->add_permit = msn_add_permit;
Note: See TracChangeset
for help on using the changeset viewer.