- Timestamp:
- 2010-08-14T16:16:52Z (14 years ago)
- Branches:
- master
- Children:
- 6ddb223
- Parents:
- e5854a8
- Location:
- protocols/msn
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
re5854a8 r193dc74 217 217 struct bee_user *bu = bee_user_by_handle( ic->bee, ic, who ); 218 218 219 msn_buddy_list_add( ic, "FL", who, who, group );219 msn_buddy_list_add( ic, MSN_BUDDY_FL, who, who, group ); 220 220 if( bu && bu->group ) 221 msn_buddy_list_remove( ic, "FL", who, bu->group->name );221 msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, bu->group->name ); 222 222 } 223 223 224 224 static void msn_remove_buddy( struct im_connection *ic, char *who, char *group ) 225 225 { 226 msn_buddy_list_remove( ic, "FL", who, NULL );226 msn_buddy_list_remove( ic, MSN_BUDDY_FL, who, NULL ); 227 227 } 228 228 … … 289 289 static void msn_add_permit( struct im_connection *ic, char *who ) 290 290 { 291 msn_buddy_list_add( ic, "AL", who, who, NULL );291 msn_buddy_list_add( ic, MSN_BUDDY_AL, who, who, NULL ); 292 292 } 293 293 294 294 static void msn_rem_permit( struct im_connection *ic, char *who ) 295 295 { 296 msn_buddy_list_remove( ic, "AL", who, NULL );296 msn_buddy_list_remove( ic, MSN_BUDDY_AL, who, NULL ); 297 297 } 298 298 … … 301 301 struct msn_switchboard *sb; 302 302 303 msn_buddy_list_add( ic, "BL", who, who, NULL );303 msn_buddy_list_add( ic, MSN_BUDDY_BL, who, who, NULL ); 304 304 305 305 /* If there's still a conversation with this person, close it. */ … … 312 312 static void msn_rem_deny( struct im_connection *ic, char *who ) 313 313 { 314 msn_buddy_list_remove( ic, "BL", who, NULL );314 msn_buddy_list_remove( ic, MSN_BUDDY_BL, who, NULL ); 315 315 } 316 316 -
protocols/msn/msn.h
re5854a8 r193dc74 201 201 int msn_write( struct im_connection *ic, char *s, int len ); 202 202 int msn_logged_in( struct im_connection *ic ); 203 int msn_buddy_list_add( struct im_connection *ic, const char *list, const char *who, const char *realname_, const char *group );204 int msn_buddy_list_remove( struct im_connection *ic, char *list, const char *who, const char *group );203 int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group ); 204 int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group ); 205 205 void msn_buddy_ask( bee_user_t *bu ); 206 206 char *msn_findheader( char *text, char *header, int len ); -
protocols/msn/msn_util.c
re5854a8 r193dc74 27 27 #include "msn.h" 28 28 #include "md5.h" 29 #include "soap.h" 29 30 #include <ctype.h> 30 31 … … 58 59 } 59 60 60 int msn_buddy_list_add( struct im_connection *ic, const char *list, const char *who, const char *realname_, const char *group ) 61 static char *adlrml_entry( const char *handle_, msn_buddy_flags_t list ) 62 { 63 char *domain, handle[strlen(handle_)+1]; 64 65 strcpy( handle, handle_ ); 66 if( ( domain = strchr( handle, '@' ) ) ) 67 *(domain 68 ++) = '\0'; 69 else 70 return NULL; 71 72 return g_markup_printf_escaped( "<ml><d n=\"%s\"><c n=\"%s\" l=\"%d\" t=\"1\"/></d></ml>", 73 domain, handle, list ); 74 } 75 76 int msn_buddy_list_add( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *realname_, const char *group ) 61 77 { 62 78 struct msn_data *md = ic->proto_data; 63 char buf[1024], realname[strlen(realname_)*3+1], groupid[8]; 79 char buf[1024], groupid[8]; 80 bee_user_t *bu; 81 struct msn_buddy_data *bd; 82 char *adl; 64 83 65 84 *groupid = '\0'; 85 #if 0 66 86 if( group ) 67 87 { … … 109 129 } 110 130 } 111 112 strcpy( realname, realname_ ); 113 http_encode( realname ); 114 g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s%s\r\n", ++md->trId, list, who, realname, groupid ); 115 116 return msn_write( ic, buf, strlen( buf ) ); 117 } 118 119 int msn_buddy_list_remove( struct im_connection *ic, char *list, const char *who, const char *group ) 131 #endif 132 133 if( !( bu = bee_user_by_handle( ic->bee, ic, who ) ) || 134 !( bd = bu->data ) || bd->flags & list ) 135 return 1; 136 137 bd->flags |= list; 138 139 msn_soap_memlist_edit( ic, who, TRUE, list ); 140 141 if( ( adl = adlrml_entry( who, list ) ) ) 142 { 143 g_snprintf( buf, sizeof( buf ), "ADL %d %zd\r\n%s", 144 ++md->trId, strlen( adl ), adl ); 145 g_free( adl ); 146 147 return msn_write( ic, buf, strlen( buf ) ); 148 } 149 } 150 151 int msn_buddy_list_remove( struct im_connection *ic, msn_buddy_flags_t list, const char *who, const char *group ) 120 152 { 121 153 struct msn_data *md = ic->proto_data; 122 154 char buf[1024], groupid[8]; 155 bee_user_t *bu; 156 struct msn_buddy_data *bd; 157 char *adl; 123 158 124 159 *groupid = '\0'; 160 #if 0 125 161 if( group ) 126 162 { … … 133 169 } 134 170 } 135 136 g_snprintf( buf, sizeof( buf ), "REM %d %s %s%s\r\n", ++md->trId, list, who, groupid ); 137 if( msn_write( ic, buf, strlen( buf ) ) ) 138 return( 1 ); 171 #endif 172 173 if( !( bu = bee_user_by_handle( ic->bee, ic, who ) ) || 174 !( bd = bu->data ) || !( bd->flags & list ) ) 175 return 1; 176 177 bd->flags &= ~list; 178 179 msn_soap_memlist_edit( ic, who, FALSE, list ); 180 181 if( ( adl = adlrml_entry( who, list ) ) ) 182 { 183 g_snprintf( buf, sizeof( buf ), "RML %d %zd\r\n%s", 184 ++md->trId, strlen( adl ), adl ); 185 g_free( adl ); 186 187 return msn_write( ic, buf, strlen( buf ) ); 188 } 139 189 140 190 return( 0 ); … … 152 202 struct msn_buddy_ask_data *bla = data; 153 203 154 msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname, NULL );204 msn_buddy_list_add( bla->ic, MSN_BUDDY_AL, bla->handle, bla->realname, NULL ); 155 205 156 206 imcb_ask_add( bla->ic, bla->handle, NULL ); … … 165 215 struct msn_buddy_ask_data *bla = data; 166 216 167 msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname, NULL );217 msn_buddy_list_add( bla->ic, MSN_BUDDY_BL, bla->handle, bla->realname, NULL ); 168 218 169 219 g_free( bla->handle ); -
protocols/msn/ns.c
re5854a8 r193dc74 264 264 { 265 265 char buf[1024]; 266 char *fn_raw = set_getstr( &ic->acc->set, "display_name" );266 char *fn_raw; 267 267 char *fn; 268 268 269 if( fn_raw == NULL ) 269 if( ic->flags & OPT_LOGGED_IN ) 270 return 1; 271 272 if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) 270 273 fn_raw = ic->acc->user; 271 274 fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); -
protocols/msn/soap.c
re5854a8 r193dc74 517 517 } 518 518 519 /* Variant: Adding/Removing people */ 520 struct msn_soap_memlist_edit_data 521 { 522 char *handle; 523 gboolean add; 524 msn_buddy_flags_t list; 525 }; 526 527 static int msn_soap_memlist_edit_build_request( struct msn_soap_req_data *soap_req ) 528 { 529 struct msn_data *md = soap_req->ic->proto_data; 530 struct msn_soap_memlist_edit_data *med = soap_req->data; 531 char *add, *scenario, *list; 532 533 soap_req->url = g_strdup( SOAP_MEMLIST_URL ); 534 if( med->add ) 535 { 536 soap_req->action = g_strdup( SOAP_MEMLIST_ADD_ACTION ); 537 add = "Add"; 538 } 539 else 540 { 541 soap_req->action = g_strdup( SOAP_MEMLIST_DEL_ACTION ); 542 add = "Delete"; 543 } 544 switch( med->list ) 545 { 546 case MSN_BUDDY_AL: 547 scenario = "BlockUnblock"; 548 list = "Allow"; 549 break; 550 case MSN_BUDDY_BL: 551 scenario = "BlockUnblock"; 552 list = "Block"; 553 break; 554 case MSN_BUDDY_RL: 555 scenario = "Timer"; 556 list = "Reverse"; 557 break; 558 case MSN_BUDDY_PL: 559 default: 560 scenario = "Timer"; 561 list = "Pending"; 562 break; 563 } 564 soap_req->payload = g_markup_printf_escaped( SOAP_MEMLIST_EDIT_PAYLOAD, 565 scenario, md->tokens[1], add, list, med->handle, add ); 566 567 return 1; 568 } 569 570 static int msn_soap_memlist_edit_handle_response( struct msn_soap_req_data *soap_req ) 571 { 572 return MSN_SOAP_OK; 573 } 574 575 static int msn_soap_memlist_edit_free_data( struct msn_soap_req_data *soap_req ) 576 { 577 struct msn_soap_memlist_edit_data *med = soap_req->data; 578 579 g_free( med->handle ); 580 g_free( med ); 581 582 return 0; 583 } 584 585 int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolean add, int list ) 586 { 587 struct msn_soap_memlist_edit_data *med; 588 589 med = g_new0( struct msn_soap_memlist_edit_data, 1 ); 590 med->handle = g_strdup( handle ); 591 med->add = add; 592 med->list = list; 593 594 return msn_soap_start( ic, med, msn_soap_memlist_edit_build_request, 595 NULL, 596 msn_soap_memlist_edit_handle_response, 597 msn_soap_memlist_edit_free_data ); 598 } 599 519 600 520 601 /* addressbook: Fetching the membership list (NOT address book) */ -
protocols/msn/soap.h
re5854a8 r193dc74 190 190 "</soap:Envelope>" 191 191 192 #define SOAP_MEMLIST_ADD_ACTION "http://www.msn.com/webservices/AddressBook/AddMember" 193 #define SOAP_MEMLIST_DEL_ACTION "http://www.msn.com/webservices/AddressBook/DeleteMember" 194 195 #define SOAP_MEMLIST_EDIT_PAYLOAD \ 196 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ 197 "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ 198 "<soap:Header xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ 199 "<ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 200 "<ApplicationId xmlns=\"http://www.msn.com/webservices/AddressBook\">CFE80F9D-180F-4399-82AB-413F33A1FA11</ApplicationId>" \ 201 "<IsMigration xmlns=\"http://www.msn.com/webservices/AddressBook\">false</IsMigration>" \ 202 "<PartnerScenario xmlns=\"http://www.msn.com/webservices/AddressBook\">%s</PartnerScenario>" \ 203 "</ABApplicationHeader>" \ 204 "<ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 205 "<ManagedGroupRequest xmlns=\"http://www.msn.com/webservices/AddressBook\">false</ManagedGroupRequest>" \ 206 "<TicketToken>%s</TicketToken>" \ 207 "</ABAuthHeader>" \ 208 "</soap:Header>" \ 209 "<soap:Body xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" \ 210 "<%sMember xmlns=\"http://www.msn.com/webservices/AddressBook\">" \ 211 "<serviceHandle>" \ 212 "<Id>0</Id>" \ 213 "<Type>Messenger</Type>" \ 214 "<ForeignId></ForeignId>" \ 215 "</serviceHandle>" \ 216 "<memberships>" \ 217 "<Membership>" \ 218 "<MemberRole>%s</MemberRole>" \ 219 "<Members>" \ 220 "<Member xsi:type=\"PassportMember\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" \ 221 "<Type>Passport</Type>" \ 222 "<State>Accepted</State>" \ 223 "<PassportName>%s</PassportName>" \ 224 "</Member>" \ 225 "</Members>" \ 226 "</Membership>" \ 227 "</memberships>" \ 228 "</%sMember>" \ 229 "</soap:Body>" \ 230 "</soap:Envelope>" 231 192 232 int msn_soap_memlist_request( struct im_connection *ic ); 233 int msn_soap_memlist_edit( struct im_connection *ic, const char *handle, gboolean add, int list ); 193 234 194 235
Note: See TracChangeset
for help on using the changeset viewer.