Changeset 62f53b50 for protocols/msn/msn.c
- Timestamp:
- 2010-10-02T05:34:53Z (14 years ago)
- Branches:
- master
- Children:
- 2af3e23
- Parents:
- 05bf2a0 (diff), 04cd284 (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.c
r05bf2a0 r62f53b50 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 04Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 25 25 26 26 #include "nogaim.h" 27 #include "soap.h" 27 28 #include "msn.h" 28 29 … … 35 36 static void msn_init( account_t *acc ) 36 37 { 37 set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); 38 set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc ); 38 set_t *s; 39 40 s = set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc ); 41 s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY; 42 39 43 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 40 44 set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc ); 45 46 acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; 41 47 } 42 48 … … 47 53 48 54 ic->proto_data = md; 49 md->fd = -1;50 55 51 56 if( strchr( acc->user, '@' ) == NULL ) … … 56 61 } 57 62 58 imcb_log( ic, "Connecting" );59 60 md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, ic );61 if( md->fd < 0 )62 {63 imcb_error( ic, "Could not connect to server" );64 imc_logout( ic, TRUE );65 return;66 }67 68 63 md->ic = ic; 69 64 md->away_state = msn_away_state_list; 70 71 msn_connections = g_slist_append( msn_connections, ic ); 65 md->domaintree = g_tree_new( msn_domaintree_cmp ); 66 md->ns->fd = -1; 67 68 msn_connections = g_slist_prepend( msn_connections, ic ); 69 70 imcb_log( ic, "Connecting" ); 71 msn_ns_connect( ic, md->ns, MSN_NS_HOST, MSN_NS_PORT ); 72 72 } 73 73 … … 76 76 struct msn_data *md = ic->proto_data; 77 77 GSList *l; 78 int i; 78 79 79 80 if( md ) … … 85 86 */ 86 87 87 if( md->fd >= 0 ) 88 closesocket( md->fd ); 89 90 if( md->handler ) 91 { 92 if( md->handler->rxq ) g_free( md->handler->rxq ); 93 if( md->handler->cmd_text ) g_free( md->handler->cmd_text ); 94 g_free( md->handler ); 95 } 88 msn_ns_close( md->ns ); 96 89 97 90 while( md->switchboards ) … … 99 92 100 93 msn_msgq_purge( ic, &md->msgq ); 101 102 while( md->groupcount > 0 ) 103 g_free( md->grouplist[--md->groupcount] ); 104 g_free( md->grouplist ); 94 msn_soapq_flush( ic, FALSE ); 95 96 for( i = 0; i < sizeof( md->tokens ) / sizeof( md->tokens[0] ); i ++ ) 97 g_free( md->tokens[i] ); 98 g_free( md->lock_key ); 99 g_free( md->pp_policy ); 100 101 while( md->groups ) 102 { 103 struct msn_group *mg = md->groups->data; 104 g_free( mg->id ); 105 g_free( mg->name ); 106 g_free( mg ); 107 md->groups = g_slist_remove( md->groups, mg ); 108 } 109 110 g_tree_destroy( md->domaintree ); 111 md->domaintree = NULL; 105 112 106 113 while( md->grpq ) … … 134 141 if( strcmp( who, "raw" ) == 0 ) 135 142 { 136 msn_write( ic, message, strlen( message ) ); 137 msn_write( ic, "\r\n", 2 ); 143 msn_ns_write( ic, -1, "%s\r\n", message ); 138 144 } 139 145 else … … 173 179 static void msn_set_away( struct im_connection *ic, char *state, char *message ) 174 180 { 175 char buf[1024];181 char *uux; 176 182 struct msn_data *md = ic->proto_data; 177 183 … … 181 187 md->away_state = msn_away_state_list + 1; 182 188 183 g_snprintf( buf, sizeof( buf ), "CHG %d %s\r\n", ++md->trId, md->away_state->code );184 msn_write( ic, buf, strlen( buf ) );185 } 186 187 static void msn_set_my_name( struct im_connection *ic, char *info ) 188 { 189 msn_set_display_name( ic, info);189 if( !msn_ns_write( ic, -1, "CHG %d %s\r\n", ++md->trId, md->away_state->code ) ) 190 return; 191 192 uux = g_markup_printf_escaped( "<Data><PSM>%s</PSM><CurrentMedia></CurrentMedia>" 193 "</Data>", message ? message : "" ); 194 msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux ); 195 g_free( uux ); 190 196 } 191 197 … … 200 206 struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who ); 201 207 202 msn_buddy_list_add( ic, "FL", who, who, group );208 msn_buddy_list_add( ic, MSN_BUDDY_FL, who, who, group ); 203 209 if( bu && bu->group ) 204 msn_buddy_list_remove( ic, "FL", who, bu->group->name );210 msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, bu->group->name ); 205 211 } 206 212 207 213 static void msn_remove_buddy( struct im_connection *ic, char *who, char *group ) 208 214 { 209 msn_buddy_list_remove( ic, "FL", who, NULL );215 msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, NULL ); 210 216 } 211 217 … … 267 273 static void msn_keepalive( struct im_connection *ic ) 268 274 { 269 msn_ write( ic, "PNG\r\n", strlen( "PNG\r\n" ));275 msn_ns_write( ic, -1, "PNG\r\n" ); 270 276 } 271 277 272 278 static void msn_add_permit( struct im_connection *ic, char *who ) 273 279 { 274 msn_buddy_list_add( ic, "AL", who, who, NULL );280 msn_buddy_list_add( ic, MSN_BUDDY_AL, who, who, NULL ); 275 281 } 276 282 277 283 static void msn_rem_permit( struct im_connection *ic, char *who ) 278 284 { 279 msn_buddy_list_remove( ic, "AL", who, NULL );285 msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL ); 280 286 } 281 287 … … 284 290 struct msn_switchboard *sb; 285 291 286 msn_buddy_list_add( ic, "BL", who, who, NULL );292 msn_buddy_list_add( ic, MSN_BUDDY_BL, who, who, NULL ); 287 293 288 294 /* If there's still a conversation with this person, close it. */ … … 295 301 static void msn_rem_deny( struct im_connection *ic, char *who ) 296 302 { 297 msn_buddy_list_remove( ic, "BL", who, NULL );303 msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL ); 298 304 } 299 305 … … 314 320 account_t *acc = set->data; 315 321 struct im_connection *ic = acc->ic; 316 317 /* Allow any name if we're offline. */ 318 if( ic == NULL ) 319 return value; 322 struct msn_data *md = ic->proto_data; 320 323 321 324 if( strlen( value ) > 129 ) … … 325 328 } 326 329 327 /* Returning NULL would be better, because the server still has to 328 confirm the name change. However, it looks a bit confusing to the 329 user. */ 330 return msn_set_display_name( ic, value ) ? value : NULL; 330 if( md->flags & MSN_GOT_PROFILE_DN ) 331 imcb_log( ic, "Warning: Persistent name changes for this account have to be done " 332 "in the profile. BitlBee doesn't currently support this." ); 333 334 msn_soap_addressbook_set_display_name( ic, value ); 335 return msn_ns_set_display_name( ic, value ) ? value : NULL; 336 } 337 338 static void msn_buddy_data_add( bee_user_t *bu ) 339 { 340 struct msn_data *md = bu->ic->proto_data; 341 bu->data = g_new0( struct msn_buddy_data, 1 ); 342 g_tree_insert( md->domaintree, bu->handle, bu ); 343 } 344 345 static void msn_buddy_data_free( bee_user_t *bu ) 346 { 347 struct msn_data *md = bu->ic->proto_data; 348 g_tree_remove( md->domaintree, bu->handle ); 349 g_free( bu->data ); 331 350 } 332 351 … … 343 362 ret->set_away = msn_set_away; 344 363 ret->get_info = msn_get_info; 345 ret->set_my_name = msn_set_my_name;346 364 ret->add_buddy = msn_add_buddy; 347 365 ret->remove_buddy = msn_remove_buddy; … … 357 375 ret->send_typing = msn_send_typing; 358 376 ret->handle_cmp = g_strcasecmp; 377 ret->buddy_data_add = msn_buddy_data_add; 378 ret->buddy_data_free = msn_buddy_data_free; 379 359 380 //ret->transfer_request = msn_ftp_transfer_request; 360 381
Note: See TracChangeset
for help on using the changeset viewer.