Changeset 4452e69
- Timestamp:
- 2010-08-14T13:06:11Z (14 years ago)
- Branches:
- master
- Children:
- 5848675
- Parents:
- d93c0eb9
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/xmltree.c
rd93c0eb9 r4452e69 174 174 if( node->flags & XT_COMPLETE && !( node->flags & XT_SEEN ) ) 175 175 { 176 for( i = 0; xt->handlers[i].func; i ++ )176 if( xt->handlers ) for( i = 0; xt->handlers[i].func; i ++ ) 177 177 { 178 178 /* This one is fun! \o/ */ 179 179 180 180 /* If handler.name == NULL it means it should always match. */ 181 181 if( ( xt->handlers[i].name == NULL || 182 182 /* If it's not, compare. There should always be a name. */ 183 183 g_strcasecmp( xt->handlers[i].name, node->name ) == 0 ) && 184 184 /* If handler.parent == NULL, it's a match. */ 185 185 ( xt->handlers[i].parent == NULL || 186 186 /* If there's a parent node, see if the name matches. */ 187 187 ( node->parent ? g_strcasecmp( xt->handlers[i].parent, node->parent->name ) == 0 : 188 189 g_strcasecmp( xt->handlers[i].parent, "<root>" ) == 0 ) ) )188 /* If there's no parent, the handler should mention <root> as a parent. */ 189 strcmp( xt->handlers[i].parent, "<root>" ) == 0 ) ) ) 190 190 { 191 191 st = xt->handlers[i].func( node, xt->data ); -
protocols/msn/msn.c
rd93c0eb9 r4452e69 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 ); … … 203 207 } 204 208 205 static void msn_set_my_name( struct im_connection *ic, char *info )206 {207 msn_set_display_name( ic, info );208 }209 210 209 static void msn_get_info(struct im_connection *ic, char *who) 211 210 { … … 332 331 account_t *acc = set->data; 333 332 struct im_connection *ic = acc->ic; 334 335 /* Allow any name if we're offline. */ 336 if( ic == NULL ) 337 return value; 333 struct msn_data *md = ic->proto_data; 334 char buf[512]; 335 char *fn; 338 336 339 337 if( strlen( value ) > 129 ) … … 343 341 } 344 342 345 /* Returning NULL would be better, because the server still has to 346 confirm the name change. However, it looks a bit confusing to the 347 user. */ 348 return msn_set_display_name( ic, value ) ? value : NULL; 343 msn_soap_addressbook_set_display_name( ic, value ); 344 345 fn = g_malloc( strlen( value ) * 3 + 1 ); 346 strcpy( fn, value ); 347 http_encode( fn ); 348 g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", 349 ++md->trId, fn ); 350 g_free( fn ); 351 352 /* Note: We don't actually know if the server accepted the new name, 353 and won't give proper feedback yet if it doesn't. */ 354 return msn_write( ic, buf, strlen( buf ) ) ? value : NULL; 349 355 } 350 356 … … 375 381 ret->set_away = msn_set_away; 376 382 ret->get_info = msn_get_info; 377 ret->set_my_name = msn_set_my_name;378 383 ret->add_buddy = msn_add_buddy; 379 384 ret->remove_buddy = msn_remove_buddy; -
protocols/msn/msn.h
rd93c0eb9 r4452e69 207 207 char **msn_linesplit( char *line ); 208 208 int msn_handler( struct msn_handler_data *h ); 209 char *msn_http_encode( const char *input );210 209 void msn_msgq_purge( struct im_connection *ic, GSList **list ); 211 210 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); -
protocols/msn/msn_util.c
rd93c0eb9 r4452e69 61 61 { 62 62 struct msn_data *md = ic->proto_data; 63 char buf[1024], *realname, groupid[8];63 char buf[1024], realname[strlen(realname_)*3+1], groupid[8]; 64 64 65 65 *groupid = '\0'; … … 94 94 if( l == NULL ) 95 95 { 96 char *groupname = msn_http_encode( group ); 96 char groupname[strlen(group)+1]; 97 strcpy( groupname, group ); 98 http_encode( groupname ); 97 99 g_snprintf( buf, sizeof( buf ), "ADG %d %s %d\r\n", ++md->trId, groupname, 0 ); 98 g_free( groupname );99 100 return msn_write( ic, buf, strlen( buf ) ); 100 101 } … … 109 110 } 110 111 111 realname = msn_http_encode( realname_ ); 112 strcpy( realname, realname_ ); 113 http_encode( realname ); 112 114 g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s%s\r\n", ++md->trId, list, who, realname, groupid ); 113 g_free( realname );114 115 115 116 return msn_write( ic, buf, strlen( buf ) ); … … 380 381 } 381 382 382 /* The difference between this function and the normal http_encode() function383 is that this one escapes every 7-bit ASCII character because this is said384 to avoid some lame server-side checks when setting a real-name. Also,385 non-ASCII characters are not escaped because MSN servers don't seem to386 appreciate that! */387 char *msn_http_encode( const char *input )388 {389 char *ret, *s;390 int i;391 392 ret = s = g_new0( char, strlen( input ) * 3 + 1 );393 for( i = 0; input[i]; i ++ )394 if( input[i] & 128 )395 {396 *s = input[i];397 s ++;398 }399 else400 {401 g_snprintf( s, 4, "%%%02X", input[i] );402 s += 3;403 }404 405 return ret;406 }407 408 383 void msn_msgq_purge( struct im_connection *ic, GSList **list ) 409 384 { … … 444 419 imcb_log( ic, "%s", ret->str ); 445 420 g_string_free( ret, TRUE ); 446 }447 448 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname )449 {450 char *fn = msn_http_encode( rawname );451 struct msn_data *md = ic->proto_data;452 char buf[1024];453 454 g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );455 g_free( fn );456 457 return msn_write( ic, buf, strlen( buf ) ) != 0;458 421 } 459 422 -
protocols/msn/ns.c
rd93c0eb9 r4452e69 35 35 static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int num_parts ); 36 36 37 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name );38 37 static void msn_ns_send_adl( struct im_connection *ic ); 39 38 … … 474 473 return( 0 ); 475 474 } 476 #if 0477 /* Discard this one completely for now since I don't care about the ack478 and since MSN servers can apparently screw up the formatting. */479 else if( strcmp( cmd[0], "REA" ) == 0 )480 {481 if( num_parts < 5 )482 {483 imcb_error( ic, "Syntax error" );484 imc_logout( ic, TRUE );485 return( 0 );486 }487 488 if( g_strcasecmp( cmd[3], ic->acc->user ) == 0 )489 {490 set_t *s;491 492 http_decode( cmd[4] );493 strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) );494 ic->displayname[sizeof(ic->displayname)-1] = 0;495 496 if( ( s = set_find( &ic->acc->set, "display_name" ) ) )497 {498 g_free( s->value );499 s->value = g_strdup( cmd[4] );500 }501 }502 else503 {504 /* This is not supposed to happen, but let's handle it anyway... */505 http_decode( cmd[4] );506 imcb_rename_buddy( ic, cmd[3], cmd[4] );507 }508 }509 #endif510 475 else if( strcmp( cmd[0], "IPG" ) == 0 ) 511 476 { … … 801 766 xt_free_node( adl ); 802 767 } 803 804 static gboolean msn_ns_got_display_name( struct im_connection *ic, char *name )805 {806 set_t *s;807 808 if( ( s = set_find( &ic->acc->set, "display_name" ) ) == NULL )809 return FALSE; /* Shouldn't happen.. */810 811 http_decode( name );812 813 if( s->value && strcmp( s->value, name ) == 0 )814 {815 return TRUE;816 /* The names match, nothing to worry about. */817 }818 else if( s->value != NULL &&819 ( strcmp( name, ic->acc->user ) == 0 ||820 set_getbool( &ic->acc->set, "local_display_name" ) ) )821 {822 /* The server thinks our display name is our e-mail address823 which is probably wrong, or the user *wants* us to do this:824 Always use the locally set display_name. */825 return msn_set_display_name( ic, s->value );826 }827 else828 {829 if( s->value && *s->value )830 imcb_log( ic, "BitlBee thinks your display name is `%s' but "831 "the MSN server says it's `%s'. Using the MSN "832 "server's name. Set local_display_name to true "833 "to use the local name.", s->value, name );834 835 if( g_utf8_validate( name, -1, NULL ) )836 {837 g_free( s->value );838 s->value = g_strdup( name );839 }840 else841 {842 imcb_log( ic, "Warning: Friendly name in server response was corrupted" );843 }844 845 return TRUE;846 }847 } -
protocols/msn/soap.c
rd93c0eb9 r4452e69 609 609 msn_soap_addressbook_free_data ); 610 610 } 611 612 /* Variant: Change our display name. */ 613 static int msn_soap_ab_namechange_build_request( struct msn_soap_req_data *soap_req ) 614 { 615 struct msn_data *md = soap_req->ic->proto_data; 616 617 soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); 618 soap_req->action = g_strdup( SOAP_AB_NAMECHANGE_ACTION ); 619 soap_req->payload = g_markup_printf_escaped( SOAP_AB_NAMECHANGE_PAYLOAD, 620 md->tokens[1], (char *) soap_req->data ); 621 622 return 1; 623 } 624 625 static int msn_soap_ab_namechange_handle_response( struct msn_soap_req_data *soap_req ) 626 { 627 /* TODO: Ack the change? Not sure what the NAKs look like.. */ 628 return MSN_SOAP_OK; 629 } 630 631 static int msn_soap_ab_namechange_free_data( struct msn_soap_req_data *soap_req ) 632 { 633 g_free( soap_req->data ); 634 return 0; 635 } 636 637 int msn_soap_addressbook_set_display_name( struct im_connection *ic, const char *new ) 638 { 639 return msn_soap_start( ic, g_strdup( new ), 640 msn_soap_ab_namechange_build_request, 641 NULL, 642 msn_soap_ab_namechange_handle_response, 643 msn_soap_ab_namechange_free_data ); 644 } -
protocols/msn/soap.h
rd93c0eb9 r4452e69 220 220 "</soap:Envelope>" 221 221 222 #define SOAP_AB_NAMECHANGE_ACTION "http://www.msn.com/webservices/AddressBook/ABContactUpdate" 223 224 #define SOAP_AB_NAMECHANGE_PAYLOAD \ 225 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ 226 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\">" \ 227 "<soap:Header>" \ 228 "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 229 "<ApplicationId>CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \ 230 "<IsMigration>false</IsMigration>" \ 231 "<PartnerScenario>Initial</PartnerScenario>" \ 232 "</ABApplicationHeader>" \ 233 "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 234 "<ManagedGroupRequest>false</ManagedGroupRequest>" \ 235 "<TicketToken>%s</TicketToken>" \ 236 "</ABAuthHeader>" \ 237 "</soap:Header>" \ 238 "<soap:Body>" \ 239 "<ABContactUpdate xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 240 "<abId>00000000-0000-0000-0000-000000000000</abId>" \ 241 "<contacts>" \ 242 "<Contact xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 243 "<contactInfo>" \ 244 "<contactType>Me</contactType>" \ 245 "<displayName>%s</displayName>" \ 246 "</contactInfo>" \ 247 "<propertiesChanged>DisplayName</propertiesChanged>" \ 248 "</Contact>" \ 249 "</contacts>" \ 250 "</ABContactUpdate>" \ 251 "</soap:Body>" \ 252 "</soap:Envelope>" 253 222 254 int msn_soap_addressbook_request( struct im_connection *ic ); 255 int msn_soap_addressbook_set_display_name( struct im_connection *ic, const char *new ); 223 256 224 257 -
protocols/nogaim.h
rd93c0eb9 r4452e69 194 194 this info via imcb_log(). Implementing these are optional. */ 195 195 void (* get_info) (struct im_connection *, char *who); 196 /* set_my_name is *DEPRECATED*, not used by the UI anymore. Use the 197 display_name setting instead. */ 196 198 void (* set_my_name) (struct im_connection *, char *name); 197 199 void (* set_name) (struct im_connection *, char *who, char *name); -
storage_xml.c
rd93c0eb9 r4452e69 320 320 else if( g_strcasecmp( g_markup_parse_context_get_element( ctx ), "setting" ) == 0 && xd->current_setting ) 321 321 { 322 if( xd->current_account ) 323 { 324 set_t *s = set_find( xd->current_set_head, xd->current_setting ); 325 if( s && ( s->flags & ACC_SET_ONLINE_ONLY ) ) 326 { 327 g_free( xd->current_setting ); 328 xd->current_setting = NULL; 329 return; 330 } 331 } 322 332 set_setstr( xd->current_set_head, xd->current_setting, (char*) text ); 323 333 g_free( xd->current_setting );
Note: See TracChangeset
for help on using the changeset viewer.