Changes in protocols/msn/ns.c [c0db0d3:0864a52]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/ns.c
rc0db0d3 r0864a52 39 39 static void msn_ns_send_adl(struct im_connection *ic); 40 40 static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd); 41 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action , gboolean selfmessage);41 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action); 42 42 static void msn_ns_nfy(struct msn_data *md, char *who, char **parts, char *action, gboolean is_put); 43 43 … … 110 110 struct im_connection *ic = md->ic; 111 111 112 /* this should be taken from XFR, but hardcoding it for now. it also prevents more redirects. */113 const char *redir_data = "VmVyc2lvbjogMQ0KWGZyQ291bnQ6IDINCklzR2VvWGZyOiB0cnVlDQo=";114 115 112 if (source == -1 && !md->is_http) { 116 113 imcb_error(ic, "Could not connect to server"); … … 138 135 } 139 136 140 /* Having to handle potential errors in each write sure makes these ifs awkward...*/ 141 142 if (msn_ns_write(ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER) && 143 msn_ns_write(ic, source, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s %s\r\n", 144 ++md->trId, ic->acc->user, redir_data) && 145 msn_ns_write(ic, md->fd, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user)) { 146 137 if (msn_ns_write(ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER)) { 147 138 if (!md->is_http) { 148 139 md->inpa = b_input_add(md->fd, B_EV_IO_READ, msn_ns_callback, md); … … 217 208 } 218 209 210 return(msn_ns_write(ic, md->fd, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s VmVyc2lvbjogMQ0KWGZyQ291bnQ6IDINClhmclNlbnRVVENUaW1lOiA2MzU2MTQ3OTU5NzgzOTAwMDANCklzR2VvWGZyOiB0cnVlDQo=\r\n", 211 ++md->trId, ic->acc->user)); 219 212 } else if (strcmp(cmd[0], "CVR") == 0) { 220 213 /* We don't give a damn about the information we just received */ 214 return msn_ns_write(ic, md->fd, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user); 221 215 } else if (strcmp(cmd[0], "XFR") == 0) { 222 216 char *server; … … 286 280 md->msglen = atoi(cmd[2]); 287 281 } 288 } else if (strcmp(cmd[0], "RML") == 0) {289 /* Move along, nothing to see here */290 282 } else if (strcmp(cmd[0], "CHL") == 0) { 291 283 char *resp; … … 483 475 } 484 476 485 /* returns newly allocated string */ 486 static char *msn_ns_parse_header_address(struct msn_data *md, char *headers, char *header_name) 487 { 477 static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd) 478 { 479 char **parts = NULL; 488 480 char *semicolon = NULL; 489 char *header = NULL; 490 char *address = NULL; 491 492 if (!(header = get_rfc822_header(headers, header_name, 0))) { 493 return NULL; 481 char *action = NULL; 482 char *from = NULL; 483 char *who = NULL; 484 485 parts = g_strsplit(msg, "\r\n\r\n", 4); 486 487 if (!(from = get_rfc822_header(parts[0], "From", 0))) { 488 goto cleanup; 494 489 } 495 490 496 491 /* either the semicolon or the end of the string */ 497 semicolon = strchr(header, ';') ? : (header + strlen(header)); 498 499 address = g_strndup(header + 2, semicolon - header - 2); 500 501 g_free(header); 502 return address; 503 } 504 505 static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd) 506 { 507 char **parts = NULL; 508 char *action = NULL; 509 char *who = NULL; 510 gboolean selfmessage = FALSE; 511 512 parts = g_strsplit(msg, "\r\n\r\n", 4); 513 514 if (!(who = msn_ns_parse_header_address(md, parts[0], "From"))) { 515 goto cleanup; 516 } 517 518 if (strcmp(who, md->ic->acc->user) == 0) { 519 selfmessage = TRUE; 520 g_free(who); 521 if (!(who = msn_ns_parse_header_address(md, parts[0], "To"))) { 522 goto cleanup; 523 } 524 } 492 semicolon = strchr(from, ';') ? : (from + strlen(from)); 493 494 who = g_strndup(from + 2, semicolon - from - 2); 525 495 526 496 if ((strcmp(cmd[0], "SDG") == 0) && (action = get_rfc822_header(parts[2], "Message-Type", 0))) { 527 msn_ns_sdg(md, who, parts, action , selfmessage);497 msn_ns_sdg(md, who, parts, action); 528 498 529 499 } else if ((strcmp(cmd[0], "NFY") == 0) && (action = get_rfc822_header(parts[2], "Uri", 0))) { … … 535 505 g_strfreev(parts); 536 506 g_free(action); 507 g_free(from); 537 508 g_free(who); 538 509 } 539 510 540 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action , gboolean selfmessage)511 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action) 541 512 { 542 513 struct im_connection *ic = md->ic; 543 514 544 if (strcmp(action, "Control/Typing") == 0 && !selfmessage) {515 if (strcmp(action, "Control/Typing") == 0) { 545 516 imcb_buddy_typing(ic, who, OPT_TYPING); 546 517 } else if (strcmp(action, "Text") == 0) { 547 imcb_buddy_msg(ic, who, parts[3], selfmessage ? OPT_SELFMESSAGE :0, 0);518 imcb_buddy_msg(ic, who, parts[3], 0, 0); 548 519 } 549 520 } … … 624 595 } else { 625 596 imcb_error(ic, "Error during Passport authentication: %s", error); 626 627 /* don't reconnect with auth errors */ 628 if (error && g_str_has_prefix(error, "wsse:FailedAuthentication")) { 629 imc_logout(ic, FALSE); 630 } else { 631 imc_logout(ic, TRUE); 632 } 597 imc_logout(ic, TRUE); 633 598 } 634 599 }
Note: See TracChangeset
for help on using the changeset viewer.