Changeset 3fbce97 for protocols/msn/ns.c
- Timestamp:
- 2016-09-24T20:14:34Z (8 years ago)
- Children:
- ba52ac5
- Parents:
- 63cad66 (diff), 82cb190 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/ns.c
r63cad66 r3fbce97 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 );41 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action, gboolean selfmessage); 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 112 115 if (source == -1 && !md->is_http) { 113 116 imcb_error(ic, "Could not connect to server"); … … 135 138 } 136 139 137 if (msn_ns_write(ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER)) { 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 138 147 if (!md->is_http) { 139 148 md->inpa = b_input_add(md->fd, B_EV_IO_READ, msn_ns_callback, md); … … 208 217 } 209 218 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));212 219 } else if (strcmp(cmd[0], "CVR") == 0) { 213 220 /* 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);215 221 } else if (strcmp(cmd[0], "XFR") == 0) { 216 222 char *server; … … 280 286 md->msglen = atoi(cmd[2]); 281 287 } 288 } else if (strcmp(cmd[0], "RML") == 0) { 289 /* Move along, nothing to see here */ 282 290 } else if (strcmp(cmd[0], "CHL") == 0) { 283 291 char *resp; … … 475 483 } 476 484 485 /* returns newly allocated string */ 486 static char *msn_ns_parse_header_address(struct msn_data *md, char *headers, char *header_name) 487 { 488 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; 494 } 495 496 /* 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 477 505 static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd) 478 506 { 479 507 char **parts = NULL; 480 char *semicolon = NULL;481 508 char *action = NULL; 482 char *from = NULL;483 509 char *who = NULL; 510 gboolean selfmessage = FALSE; 484 511 485 512 parts = g_strsplit(msg, "\r\n\r\n", 4); 486 513 487 if (!( from = get_rfc822_header(parts[0], "From", 0))) {514 if (!(who = msn_ns_parse_header_address(md, parts[0], "From"))) { 488 515 goto cleanup; 489 516 } 490 517 491 /* either the semicolon or the end of the string */ 492 semicolon = strchr(from, ';') ? : (from + strlen(from)); 493 494 who = g_strndup(from + 2, semicolon - from - 2); 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 } 495 525 496 526 if ((strcmp(cmd[0], "SDG") == 0) && (action = get_rfc822_header(parts[2], "Message-Type", 0))) { 497 msn_ns_sdg(md, who, parts, action );527 msn_ns_sdg(md, who, parts, action, selfmessage); 498 528 499 529 } else if ((strcmp(cmd[0], "NFY") == 0) && (action = get_rfc822_header(parts[2], "Uri", 0))) { … … 505 535 g_strfreev(parts); 506 536 g_free(action); 507 g_free(from);508 537 g_free(who); 509 538 } 510 539 511 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action )540 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action, gboolean selfmessage) 512 541 { 513 542 struct im_connection *ic = md->ic; 514 543 515 if (strcmp(action, "Control/Typing") == 0 ) {544 if (strcmp(action, "Control/Typing") == 0 && !selfmessage) { 516 545 imcb_buddy_typing(ic, who, OPT_TYPING); 517 546 } else if (strcmp(action, "Text") == 0) { 518 imcb_buddy_msg(ic, who, parts[3], 0, 0);547 imcb_buddy_msg(ic, who, parts[3], selfmessage ? OPT_SELFMESSAGE : 0, 0); 519 548 } 520 549 } … … 595 624 } else { 596 625 imcb_error(ic, "Error during Passport authentication: %s", error); 597 imc_logout(ic, TRUE); 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 } 598 633 } 599 634 }
Note: See TracChangeset
for help on using the changeset viewer.