Changes in / [ba86713:2a6da96]
- Location:
- protocols/msn
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/msn.c
rba86713 r2a6da96 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-201 2Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 98 98 g_free( md->lock_key ); 99 99 g_free( md->pp_policy ); 100 g_free( md->uuid );101 100 102 101 while( md->groups ) … … 191 190 md->away_state = msn_away_state_list + 1; 192 191 193 if( !msn_ns_write( ic, -1, "CHG %d %s %d:%02d\r\n", ++md->trId, md->away_state->code, MSN_CAP1, MSN_CAP2) )192 if( !msn_ns_write( ic, -1, "CHG %d %s\r\n", ++md->trId, md->away_state->code ) ) 194 193 return; 195 194 196 uux = g_markup_printf_escaped( "<EndpointData><Capabilities>%d:%02d" 197 "</Capabilities></EndpointData>", 198 MSN_CAP1, MSN_CAP2 ); 199 msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux ); 200 g_free( uux ); 201 202 uux = g_markup_printf_escaped( "<PrivateEndpointData><EpName>%s</EpName>" 203 "<Idle>%s</Idle><ClientType>%d</ClientType>" 204 "<State>%s</State></PrivateEndpointData>", 205 md->uuid, 206 strcmp( md->away_state->code, "IDL" ) ? "false" : "true", 207 1, /* ? */ 208 md->away_state->code ); 209 msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux ); 210 g_free( uux ); 211 212 uux = g_markup_printf_escaped( "<Data><DDP></DDP><PSM>%s</PSM>" 213 "<CurrentMedia></CurrentMedia>" 214 "<MachineGuid>%s</MachineGuid></Data>", 215 message ? message : "", md->uuid ); 195 uux = g_markup_printf_escaped( "<Data><PSM>%s</PSM><CurrentMedia></CurrentMedia>" 196 "</Data>", message ? message : "" ); 216 197 msn_ns_write( ic, -1, "UUX %d %zd\r\n%s", ++md->trId, strlen( uux ), uux ); 217 198 g_free( uux ); … … 251 232 { 252 233 struct msn_switchboard *sb = msn_sb_by_chat( c ); 234 char buf[1024]; 253 235 254 236 if( sb ) 255 msn_sb_write( sb, "CAL %d %s\r\n", ++sb->trId, who ); 237 { 238 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who ); 239 msn_sb_write( sb, buf, strlen( buf ) ); 240 } 256 241 } 257 242 … … 261 246 262 247 if( sb ) 263 msn_sb_write( sb, "OUT\r\n" );248 msn_sb_write( sb, "OUT\r\n", 5 ); 264 249 } 265 250 -
protocols/msn/msn.h
rba86713 r2a6da96 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-201 2Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 53 53 */ 54 54 55 /* <= BitlBee 3.0.556 55 #define MSNP11_PROD_KEY "ILTXC!4IXB5FB*PX" 57 56 #define MSNP11_PROD_ID "PROD0119GSJUC$18" 58 */ 59 60 #define MSNP11_PROD_KEY "C1BX{V4W}Q3*10SM" 61 #define MSNP11_PROD_ID "PROD0120PW!CCV9@" 62 #define MSNP_VER "MSNP18" 63 #define MSNP_BUILD "14.0.8117.416" 57 #define MSNP_VER "MSNP15" 58 #define MSNP_BUILD "8.5.1288" 64 59 65 60 #define MSN_SB_NEW -24062002 66 67 #define MSN_CAP1 0xC00068 #define MSN_CAP2 0x000069 61 70 62 #define MSN_MESSAGE_HEADERS "MIME-Version: 1.0\r\n" \ … … 126 118 char *tokens[4]; 127 119 char *lock_key, *pp_policy; 128 char *uuid;129 120 130 121 GSList *msgq, *grpq, *soapq; … … 231 222 232 223 /* ns.c */ 233 int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ) G_GNUC_PRINTF( 3, 4 );224 int msn_ns_write( struct im_connection *ic, int fd, const char *fmt, ... ); 234 225 gboolean msn_ns_connect( struct im_connection *ic, struct msn_handler_data *handler, const char *host, int port ); 235 226 void msn_ns_close( struct msn_handler_data *handler ); … … 237 228 void msn_auth_got_contact_list( struct im_connection *ic ); 238 229 int msn_ns_finish_login( struct im_connection *ic ); 239 int msn_ns_sendmessage( struct im_connection *ic, struct bee_user *bu, const char *text );240 void msn_ns_oim_send_queue( struct im_connection *ic, GSList **msgq );241 230 242 231 /* msn_util.c */ … … 253 242 struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id ); 254 243 int msn_ns_set_display_name( struct im_connection *ic, const char *value ); 255 const char *msn_normalize_handle( const char *handle );256 244 257 245 /* tables.c */ … … 262 250 263 251 /* sb.c */ 264 int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ) G_GNUC_PRINTF( 2, 3 );;252 int msn_sb_write( struct msn_switchboard *sb, const char *fmt, ... ); 265 253 struct msn_switchboard *msn_sb_create( struct im_connection *ic, char *host, int port, char *key, int session ); 266 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, c onst char *handle );254 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ); 267 255 struct msn_switchboard *msn_sb_by_chat( struct groupchat *c ); 268 256 struct msn_switchboard *msn_sb_spare( struct im_connection *ic ); -
protocols/msn/msn_util.c
rba86713 r2a6da96 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-201 2Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 537 537 return msn_ns_write( ic, -1, "PRP %d MFN %s\r\n", ++md->trId, fn ); 538 538 } 539 540 const char *msn_normalize_handle( const char *handle )541 {542 if( strncmp( handle, "1:", 2 ) == 0 )543 return handle + 2;544 else545 return handle;546 } -
protocols/msn/ns.c
rba86713 r2a6da96 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-201 2Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 25 25 26 26 #include <ctype.h> 27 #include <sys/utsname.h>28 27 #include "nogaim.h" 29 28 #include "msn.h" 30 29 #include "md5.h" 31 #include "sha1.h"32 30 #include "soap.h" 33 31 #include "xmltree.h" … … 112 110 handler->rxlen = 0; 113 111 handler->rxq = g_new0( char, 1 ); 114 115 if( md->uuid == NULL )116 {117 struct utsname name;118 sha1_state_t sha[1];119 120 /* UUID == SHA1("BitlBee" + my hostname + MSN username) */121 sha1_init( sha );122 sha1_append( sha, (void*) "BitlBee", 7 );123 if( uname( &name ) == 0 )124 {125 sha1_append( sha, (void*) name.nodename, strlen( name.nodename ) );126 }127 sha1_append( sha, (void*) ic->acc->user, strlen( ic->acc->user ) );128 md->uuid = sha1_random_uuid( sha );129 memcpy( md->uuid, "b171be3e", 8 ); /* :-P */130 }131 112 132 113 if( msn_ns_write( ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER ) ) … … 372 353 return st; 373 354 } 374 else if( strcmp( cmd[0], "ILN" ) == 0 || strcmp( cmd[0], "NLN" ) == 0)355 else if( strcmp( cmd[0], "ILN" ) == 0 ) 375 356 { 376 357 const struct msn_away_state *st; 377 const char *handle;378 int cap = 0;379 358 380 359 if( num_parts < 6 ) … … 384 363 return( 0 ); 385 364 } 386 /* ILN and NLN are more or less the same, except ILN has a trId 387 at the start, and NLN has a capability field at the end. 388 Does ILN still exist BTW? */ 389 if( cmd[0][1] == 'I' ) 390 cmd ++; 391 else 392 cap = atoi( cmd[4] ); 393 394 handle = msn_normalize_handle( cmd[2] ); 395 if( strcmp( handle, ic->acc->user ) == 0 ) 396 return 1; /* That's me! */ 397 398 http_decode( cmd[3] ); 399 imcb_rename_buddy( ic, handle, cmd[3] ); 365 366 http_decode( cmd[5] ); 367 imcb_rename_buddy( ic, cmd[3], cmd[5] ); 368 369 st = msn_away_state_by_code( cmd[2] ); 370 if( !st ) 371 { 372 /* FIXME: Warn/Bomb about unknown away state? */ 373 st = msn_away_state_list + 1; 374 } 375 376 imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | 377 ( st != msn_away_state_list ? OPT_AWAY : 0 ), 378 st->name, NULL ); 379 } 380 else if( strcmp( cmd[0], "FLN" ) == 0 ) 381 { 382 if( cmd[1] == NULL ) 383 return 1; 384 385 imcb_buddy_status( ic, cmd[1], 0, NULL, NULL ); 386 387 msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE ); 388 } 389 else if( strcmp( cmd[0], "NLN" ) == 0 ) 390 { 391 const struct msn_away_state *st; 392 int cap; 393 394 if( num_parts < 6 ) 395 { 396 imcb_error( ic, "Syntax error" ); 397 imc_logout( ic, TRUE ); 398 return( 0 ); 399 } 400 401 http_decode( cmd[4] ); 402 cap = atoi( cmd[5] ); 403 imcb_rename_buddy( ic, cmd[2], cmd[4] ); 400 404 401 405 st = msn_away_state_by_code( cmd[1] ); … … 406 410 } 407 411 408 imcb_buddy_status( ic, handle, OPT_LOGGED_IN |412 imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | 409 413 ( st != msn_away_state_list ? OPT_AWAY : 0 ) | 410 414 ( cap & 1 ? OPT_MOBILE : 0 ), 411 415 st->name, NULL ); 412 416 413 msn_sb_stop_keepalives( msn_sb_by_handle( ic, handle ) ); 414 } 415 else if( strcmp( cmd[0], "FLN" ) == 0 ) 416 { 417 const char *handle; 418 419 if( cmd[1] == NULL ) 420 return 1; 421 422 handle = msn_normalize_handle( cmd[1] ); 423 imcb_buddy_status( ic, handle, 0, NULL, NULL ); 424 msn_sb_start_keepalives( msn_sb_by_handle( ic, handle ), TRUE ); 417 msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) ); 425 418 } 426 419 else if( strcmp( cmd[0], "RNG" ) == 0 ) … … 469 462 else 470 463 { 471 sb->who = g_strdup( msn_normalize_handle( cmd[5] ));464 sb->who = g_strdup( cmd[5] ); 472 465 } 473 466 } … … 562 555 { 563 556 /* Status message. */ 564 if( num_parts >= 3)565 handler->msglen = atoi( cmd[ 2] );557 if( num_parts >= 4 ) 558 handler->msglen = atoi( cmd[3] ); 566 559 } 567 560 else if( strcmp( cmd[0], "NOT" ) == 0 ) … … 675 668 else if( g_strncasecmp( ct, "text/x-msmsgsactivemailnotification", 35 ) == 0 ) 676 669 { 677 } 678 else if( g_strncasecmp( ct, "text/x-msmsgsinitialmdatanotification", 37 ) == 0 || 679 g_strncasecmp( ct, "text/x-msmsgsoimnotification", 28 ) == 0 ) 680 { 681 /* We received an offline message. Or at least notification 682 that there is one waiting for us. Fetching the message(s) 683 and purging them from the server is a lot of SOAPy work 684 not worth doing IMHO. Also I thought it was possible to 685 have the notification server send them directly, I was 686 pretty sure I saw Pidgin do it.. 687 688 At least give a notification for now, seems like a 689 reasonable thing to do. Only problem is, they'll keep 690 coming back at login time until you read them using a 691 different client. :-( */ 692 693 char *xml = get_rfc822_header( body, "Mail-Data:", blen ); 694 struct xt_node *md, *m; 695 696 if( !xml ) 697 return 1; 698 md = xt_from_string( xml, 0 ); 699 if( !md ) 700 return 1; 701 702 for( m = md->children; ( m = xt_find_node( m, "M" ) ); m = m->next ) 703 { 704 struct xt_node *e = xt_find_node( m->children, "E" ); 705 struct xt_node *rt = xt_find_node( m->children, "RT" ); 706 struct tm tp; 707 time_t msgtime = 0; 708 709 if( !e || !e->text ) 710 continue; 711 712 memset( &tp, 0, sizeof( tp ) ); 713 if( rt && rt->text && 714 sscanf( rt->text, "%4d-%2d-%2dT%2d:%2d:%2d.", 715 &tp.tm_year, &tp.tm_mon, &tp.tm_mday, 716 &tp.tm_hour, &tp.tm_min, &tp.tm_sec ) == 6 ) 717 { 718 tp.tm_year -= 1900; 719 tp.tm_mon --; 720 msgtime = mktime_utc( &tp ); 721 722 } 723 imcb_buddy_msg( ic, e->text, "<< \002BitlBee\002 - Received offline message. BitlBee can't show these. >>", 0, msgtime ); 724 } 725 726 g_free( xml ); 727 xt_free_node( md ); 670 /* Sorry, but this one really is *USELESS* */ 728 671 } 729 672 else … … 745 688 psm_text = psm->text; 746 689 747 imcb_buddy_status_msg( ic, msn_normalize_handle( cmd[1] ), psm_text );690 imcb_buddy_status_msg( ic, cmd[1], psm_text ); 748 691 xt_free_node( ubx ); 749 692 } … … 814 757 if( token ) 815 758 { 816 msn_ns_write( ic, -1, "USR %d SSO S %s %s {%s}\r\n", ++md->trId, md->tokens[0], token, md->uuid);759 msn_ns_write( ic, -1, "USR %d SSO S %s %s\r\n", ++md->trId, md->tokens[0], token ); 817 760 } 818 761 else … … 943 886 return 1; 944 887 } 945 946 int msn_ns_sendmessage( struct im_connection *ic, bee_user_t *bu, const char *text )947 {948 struct msn_data *md = ic->proto_data;949 char *buf;950 951 if( strncmp( text, "\r\r\r", 3 ) == 0 )952 /* Err. Shouldn't happen but I guess it can. Don't send others953 any of the "SHAKE THAT THING" messages. :-D */954 return 1;955 956 buf = g_strdup_printf( "%s%s", MSN_MESSAGE_HEADERS, text );957 958 if( msn_ns_write( ic, -1, "UUM %d %s %d %d %zd\r\n%s",959 ++md->trId, bu->handle,960 1, /* type == MSN offline message */961 1, /* type == IM (not nudge/typing) */962 strlen( buf ), buf ) )963 return 1;964 else965 return 0;966 }967 968 void msn_ns_oim_send_queue( struct im_connection *ic, GSList **msgq )969 {970 GSList *l;971 972 for( l = *msgq; l; l = l->next )973 {974 struct msn_message *m = l->data;975 bee_user_t *bu = bee_user_by_handle( ic->bee, ic, m->who );976 977 if( bu )978 if( !msn_ns_sendmessage( ic, bu, m->text ) )979 return;980 }981 982 while( *msgq != NULL )983 {984 struct msn_message *m = (*msgq)->data;985 986 g_free( m->who );987 g_free( m->text );988 g_free( m );989 990 *msgq = g_slist_remove( *msgq, m );991 }992 } -
protocols/msn/sb.c
rba86713 r2a6da96 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-201 2Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 122 122 } 123 123 124 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, c onst char *handle )124 struct msn_switchboard *msn_sb_by_handle( struct im_connection *ic, char *handle ) 125 125 { 126 126 struct msn_data *md = ic->proto_data; … … 308 308 struct msn_switchboard *sb = data; 309 309 struct im_connection *ic; 310 struct msn_data *md;311 310 char buf[1024]; 312 311 … … 316 315 317 316 ic = sb->ic; 318 md = ic->proto_data;319 317 320 318 if( source != sb->fd ) … … 334 332 335 333 if( sb->session == MSN_SB_NEW ) 336 g_snprintf( buf, sizeof( buf ), "USR %d %s ;{%s} %s\r\n", ++sb->trId, ic->acc->user, md->uuid, sb->key );334 g_snprintf( buf, sizeof( buf ), "USR %d %s %s\r\n", ++sb->trId, ic->acc->user, sb->key ); 337 335 else 338 g_snprintf( buf, sizeof( buf ), "ANS %d %s ;{%s} %s %d\r\n", ++sb->trId, ic->acc->user, md->uuid, sb->key, sb->session );336 g_snprintf( buf, sizeof( buf ), "ANS %d %s %s %d\r\n", ++sb->trId, ic->acc->user, sb->key, sb->session ); 339 337 340 338 if( msn_sb_write( sb, "%s", buf ) ) … … 455 453 char buf[1024]; 456 454 457 /* For as much as I understand this MPOP stuff now, a 458 switchboard has two (or more) roster entries per 459 participant. One "bare JID" and one JID;UUID. Ignore 460 the latter. */ 461 if( !strchr( cmd[4], ';' ) ) 455 if( num == 1 ) 462 456 { 463 /* HACK: Since even 1:1 chats now have >2 participants 464 (ourselves included) it gets hard to tell them apart 465 from rooms. Let's hope this is enough: */ 466 if( sb->chat == NULL && num != tot ) 467 { 468 g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); 469 sb->chat = imcb_chat_new( ic, buf ); 470 471 g_free( sb->who ); 472 sb->who = NULL; 473 } 457 g_snprintf( buf, sizeof( buf ), "MSN groupchat session %d", sb->session ); 458 sb->chat = imcb_chat_new( ic, buf ); 474 459 475 if( sb->chat )476 imcb_chat_add_buddy( sb->chat, cmd[4] );477 } 478 479 /* We have the full roster, start showing the channel to480 the user. */481 if( num == tot && sb->chat)460 g_free( sb->who ); 461 sb->who = NULL; 462 } 463 464 imcb_chat_add_buddy( sb->chat, cmd[4] ); 465 466 if( num == tot ) 482 467 { 483 468 imcb_chat_add_buddy( sb->chat, ic->acc->user ); … … 521 506 return( 0 ); 522 507 } 523 524 /* See IRO above. Handle "bare JIDs" only. */525 if( strchr( cmd[1], ';' ) )526 return 1;527 508 528 509 if( sb->who && g_strcasecmp( cmd[1], sb->who ) == 0 ) … … 560 541 return( st ); 561 542 } 562 else if( strcmp( cmd[1], ic->acc->user ) == 0 )563 {564 /* Well, gee thanks. Thanks for letting me know I've arrived.. */565 }566 543 else if( sb->who ) 567 544 { … … 636 613 The server will clean it up when it's idle for too long. */ 637 614 } 638 else if( sb->chat && !strchr( cmd[1], ';' ))615 else if( sb->chat ) 639 616 { 640 617 imcb_chat_remove_buddy( sb->chat, cmd[1], "" ); … … 652 629 /* If the person is offline, send an offline message instead, 653 630 and don't report an error. */ 631 /* TODO: Support for OIMs that works. (#874) */ 632 /* 654 633 if( num == 217 ) 655 msn_ ns_oim_send_queue( ic, &sb->msgq );634 msn_soap_oim_send_queue( ic, &sb->msgq ); 656 635 else 636 */ 657 637 imcb_error( ic, "Error reported by switchboard server: %s", err->text ); 658 638
Note: See TracChangeset
for help on using the changeset viewer.