Changeset 7f34ce2
- Timestamp:
- 2010-08-11T23:03:33Z (14 years ago)
- Branches:
- master
- Children:
- ca7de3a
- Parents:
- 523fb23
- Location:
- protocols/msn
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
r523fb23 r7f34ce2 332 332 user. */ 333 333 return msn_set_display_name( ic, value ) ? value : NULL; 334 } 335 336 static void msn_buddy_data_add( bee_user_t *bu ) 337 { 338 bu->data = g_new0( struct msn_buddy_data, 1 ); 339 } 340 341 static void msn_buddy_data_free( bee_user_t *bu ) 342 { 343 g_free( bu->data ); 334 344 } 335 345 … … 360 370 ret->send_typing = msn_send_typing; 361 371 ret->handle_cmp = g_strcasecmp; 372 ret->buddy_data_add = msn_buddy_data_add; 373 ret->buddy_data_free = msn_buddy_data_free; 374 362 375 //ret->transfer_request = msn_ftp_transfer_request; 363 376 -
protocols/msn/msn.h
r523fb23 r7f34ce2 149 149 int (*exec_command) ( gpointer data, char **cmd, int count ); 150 150 int (*exec_message) ( gpointer data, char *msg, int msglen, char **cmd, int count ); 151 }; 152 153 typedef enum 154 { 155 MSN_BUDDY_FL = 1, 156 MSN_BUDDY_AL = 2, 157 MSN_BUDDY_BL = 4, 158 MSN_BUDDY_RL = 8, 159 MSN_BUDDY_PL = 16, 160 } msn_buddy_flags_t; 161 162 struct msn_buddy_data 163 { 164 char *cid; 165 msn_buddy_flags_t flags; 151 166 }; 152 167 -
protocols/msn/soap.c
r523fb23 r7f34ce2 423 423 /* memlist: Fetching the membership list (NOT address book) */ 424 424 425 #if 0426 struct msn_soap_oim_send_data427 {428 char *to;429 char *msg;430 int number;431 int need_retry;432 };433 #endif434 435 425 static int msn_soap_memlist_build_request( struct msn_soap_req_data *soap_req ) 436 426 { 427 struct msn_data *md = soap_req->ic->proto_data; 428 437 429 soap_req->url = g_strdup( SOAP_MEMLIST_URL ); 438 430 soap_req->action = g_strdup( SOAP_MEMLIST_ACTION ); 439 soap_req->payload = g_ strdup( SOAP_MEMLIST_PAYLOAD);431 soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_PAYLOAD, md->tokens[1] ); 440 432 441 433 return 1; 442 434 } 443 435 436 static xt_status msn_soap_memlist_member( struct xt_node *node, gpointer data ) 437 { 438 bee_user_t *bu; 439 struct msn_buddy_data *bd; 440 struct xt_node *p; 441 char *role = NULL, *handle = NULL; 442 struct msn_soap_req_data *soap_req = data; 443 struct im_connection *ic = soap_req->ic; 444 445 if( ( p = node->parent ) && ( p = p->parent ) && 446 ( p = xt_find_node( p->children, "MemberRole" ) ) ) 447 role = p->text; 448 449 if( ( p = xt_find_node( node->children, "PassportName" ) ) ) 450 handle = p->text; 451 452 if( !role || !handle || 453 !( ( bu = bee_user_by_handle( ic->bee, ic, handle ) ) || 454 ( bu = bee_user_new( ic->bee, ic, handle, 0 ) ) ) ) 455 return XT_HANDLED; 456 457 bd = bu->data; 458 if( strcmp( role, "Allow" ) == 0 ) 459 bd->flags |= MSN_BUDDY_AL; 460 else if( strcmp( role, "Block" ) == 0 ) 461 bd->flags |= MSN_BUDDY_BL; 462 else if( strcmp( role, "Reverse" ) == 0 ) 463 bd->flags |= MSN_BUDDY_RL; 464 else if( strcmp( role, "Pending" ) == 0 ) 465 bd->flags |= MSN_BUDDY_PL; 466 467 return XT_HANDLED; 468 } 469 444 470 static const struct xt_handler_entry msn_soap_memlist_parser[] = { 471 { "Member", "Members", msn_soap_memlist_member }, 445 472 { NULL, NULL, NULL } 446 473 }; … … 448 475 static int msn_soap_memlist_handle_response( struct msn_soap_req_data *soap_req ) 449 476 { 450 return 0; 477 msn_soap_addressbook_request( soap_req->ic ); 478 479 return MSN_SOAP_OK; 451 480 } 452 481 … … 463 492 msn_soap_memlist_free_data ); 464 493 } 494 495 496 /* addressbook: Fetching the membership list (NOT address book) */ 497 498 static int msn_soap_addressbook_build_request( struct msn_soap_req_data *soap_req ) 499 { 500 struct msn_data *md = soap_req->ic->proto_data; 501 502 soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); 503 soap_req->action = g_strdup( SOAP_ADDRESSBOOK_ACTION ); 504 soap_req->payload = g_markup_printf_escaped( SOAP_ADDRESSBOOK_PAYLOAD, md->tokens[1] ); 505 506 return 1; 507 } 508 509 static xt_status msn_soap_addressbook_group( struct xt_node *node, gpointer data ) 510 { 511 struct xt_node *p; 512 char *id = NULL, *name = NULL; 513 struct msn_soap_req_data *soap_req = data; 514 struct im_connection *ic = soap_req->ic; 515 516 if( ( p = node->parent ) && 517 ( p = xt_find_node( p->children, "groupId" ) ) ) 518 id = p->text; 519 520 if( ( p = xt_find_node( node->children, "name" ) ) ) 521 name = p->text; 522 523 printf( "%s %s\n", id, name ); 524 525 return XT_HANDLED; 526 } 527 528 static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer data ) 529 { 530 bee_user_t *bu; 531 struct msn_buddy_data *bd; 532 struct xt_node *p; 533 char *id = NULL, *type = NULL, *handle = NULL, *display_name = NULL; 534 struct msn_soap_req_data *soap_req = data; 535 struct im_connection *ic = soap_req->ic; 536 537 if( ( p = node->parent ) && 538 ( p = xt_find_node( p->children, "contactId" ) ) ) 539 id = p->text; 540 if( ( p = xt_find_node( node->children, "contactType" ) ) ) 541 type = p->text; 542 if( ( p = xt_find_node( node->children, "passportName" ) ) ) 543 handle = p->text; 544 if( ( p = xt_find_node( node->children, "displayName" ) ) ) 545 display_name = p->text; 546 547 if( type && g_strcasecmp( type, "me" ) == 0 ) 548 { 549 set_t *set = set_find( &ic->acc->set, "display_name" ); 550 g_free( set->value ); 551 set->value = g_strdup( display_name ); 552 553 return XT_HANDLED; 554 } 555 556 if( !( bu = bee_user_by_handle( ic->bee, ic, handle ) ) && 557 !( bu = bee_user_new( ic->bee, ic, handle, 0 ) ) ) 558 return XT_HANDLED; 559 560 bd = bu->data; 561 bd->flags |= MSN_BUDDY_FL; 562 g_free( bd->cid ); 563 bd->cid = g_strdup( id ); 564 565 imcb_rename_buddy( ic, handle, display_name ); 566 567 printf( "%s %s %s %s\n", id, type, handle, display_name ); 568 569 return XT_HANDLED; 570 } 571 572 static const struct xt_handler_entry msn_soap_addressbook_parser[] = { 573 { "contactInfo", "Contact", msn_soap_addressbook_contact }, 574 { "groupInfo", "Group", msn_soap_addressbook_group }, 575 { NULL, NULL, NULL } 576 }; 577 578 static int msn_soap_addressbook_handle_response( struct msn_soap_req_data *soap_req ) 579 { 580 return MSN_SOAP_OK; 581 } 582 583 static int msn_soap_addressbook_free_data( struct msn_soap_req_data *soap_req ) 584 { 585 return 0; 586 } 587 588 int msn_soap_addressbook_request( struct im_connection *ic ) 589 { 590 return msn_soap_start( ic, NULL, msn_soap_addressbook_build_request, 591 msn_soap_addressbook_parser, 592 msn_soap_addressbook_handle_response, 593 msn_soap_addressbook_free_data ); 594 } -
protocols/msn/soap.h
r523fb23 r7f34ce2 152 152 153 153 154 #define SOAP_MEMLIST_URL "http s://byrdr.omega.contacts.msn.com/abservice/SharingService.asmx"154 #define SOAP_MEMLIST_URL "http://contacts.msn.com/abservice/SharingService.asmx" 155 155 #define SOAP_MEMLIST_ACTION "http://www.msn.com/webservices/AddressBook/FindMembership" 156 156 … … 166 166 "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 167 167 "<ManagedGroupRequest xmlns=\"http://www.msn.com/webservices/AddressBook\">false</ManagedGroupRequest>" \ 168 "<TicketToken>%s</TicketToken>" \ 168 169 "</ABAuthHeader>" \ 169 170 "</soap:Header>" \ … … 177 178 178 179 180 #define SOAP_ADDRESSBOOK_URL "http://contacts.msn.com/abservice/abservice.asmx" 181 #define SOAP_ADDRESSBOOK_ACTION "http://www.msn.com/webservices/AddressBook/ABFindAll" 182 183 #define SOAP_ADDRESSBOOK_PAYLOAD \ 184 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ 185 "<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/\">" \ 186 "<soap:Header>" \ 187 "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 188 "<ApplicationId>CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \ 189 "<IsMigration>false</IsMigration>" \ 190 "<PartnerScenario>Initial</PartnerScenario>" \ 191 "</ABApplicationHeader>" \ 192 "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 193 "<ManagedGroupRequest>false</ManagedGroupRequest>" \ 194 "<TicketToken>%s</TicketToken>" \ 195 "</ABAuthHeader>" \ 196 "</soap:Header>" \ 197 "<soap:Body>" \ 198 "<ABFindAll xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 199 "<abId>00000000-0000-0000-0000-000000000000</abId>" \ 200 "<abView>Full</abView>" \ 201 "<deltasOnly>false</deltasOnly>" \ 202 "<lastChange>0001-01-01T00:00:00.0000000-08:00</lastChange>" \ 203 "</ABFindAll>" \ 204 "</soap:Body>" \ 205 "</soap:Envelope>" 206 207 int msn_soap_addressbook_request( struct im_connection *ic ); 208 209 179 210 #endif /* __SOAP_H__ */
Note: See TracChangeset
for help on using the changeset viewer.