- Timestamp:
- 2015-10-30T10:28:32Z (9 years ago)
- Branches:
- master
- Children:
- 0edc2fb
- Parents:
- fb2338d
- git-author:
- dequis <dx@…> (13-09-15 04:57:25)
- git-committer:
- dequis <dx@…> (30-10-15 10:28:32)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/ns.c
rfb2338d r884577f 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 … … 475 475 } 476 476 477 /* returns newly allocated string */ 478 static char *msn_ns_parse_header_address(struct msn_data *md, char *headers, char *header_name) 479 { 480 char *semicolon = NULL; 481 char *header = NULL; 482 char *address = NULL; 483 484 if (!(header = get_rfc822_header(headers, header_name, 0))) { 485 return NULL; 486 } 487 488 /* either the semicolon or the end of the string */ 489 semicolon = strchr(header, ';') ? : (header + strlen(header)); 490 491 address = g_strndup(header + 2, semicolon - header - 2); 492 493 g_free(header); 494 return address; 495 } 496 477 497 static void msn_ns_structured_message(struct msn_data *md, char *msg, int msglen, char **cmd) 478 498 { 479 499 char **parts = NULL; 480 char *semicolon = NULL;481 500 char *action = NULL; 482 char *from = NULL;483 501 char *who = NULL; 502 gboolean selfmessage = FALSE; 484 503 485 504 parts = g_strsplit(msg, "\r\n\r\n", 4); 486 505 487 if (!( from = get_rfc822_header(parts[0], "From", 0))) {506 if (!(who = msn_ns_parse_header_address(md, parts[0], "From"))) { 488 507 goto cleanup; 489 508 } 490 509 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); 510 if (strcmp(who, md->ic->acc->user) == 0) { 511 selfmessage = TRUE; 512 g_free(who); 513 if (!(who = msn_ns_parse_header_address(md, parts[0], "To"))) { 514 goto cleanup; 515 } 516 } 495 517 496 518 if ((strcmp(cmd[0], "SDG") == 0) && (action = get_rfc822_header(parts[2], "Message-Type", 0))) { 497 msn_ns_sdg(md, who, parts, action );519 msn_ns_sdg(md, who, parts, action, selfmessage); 498 520 499 521 } else if ((strcmp(cmd[0], "NFY") == 0) && (action = get_rfc822_header(parts[2], "Uri", 0))) { … … 505 527 g_strfreev(parts); 506 528 g_free(action); 507 g_free(from);508 529 g_free(who); 509 530 } 510 531 511 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action )532 static void msn_ns_sdg(struct msn_data *md, char *who, char **parts, char *action, gboolean selfmessage) 512 533 { 513 534 struct im_connection *ic = md->ic; 514 535 515 if (strcmp(action, "Control/Typing") == 0 ) {536 if (strcmp(action, "Control/Typing") == 0 && !selfmessage) { 516 537 imcb_buddy_typing(ic, who, OPT_TYPING); 517 538 } else if (strcmp(action, "Text") == 0) { 518 imcb_buddy_msg(ic, who, parts[3], 0, 0);539 imcb_buddy_msg(ic, who, parts[3], selfmessage ? OPT_SELFMESSAGE : 0, 0); 519 540 } 520 541 }
Note: See TracChangeset
for help on using the changeset viewer.