comparison libpurple/protocols/msn/slpcall.c @ 31558:ce968e115c95

propagate from branch 'im.pidgin.cpw.masca.p2p' (head 33ca865dacb9e5bcf763d06f6a42cbaca337cc64) to branch 'im.pidgin.pidgin' (head 92f47f4e8b0cbb107fd97e1ab814d1cedbf109ad)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 06 May 2011 06:25:14 +0000
parents 34da321b60f1
children eb1bbaae3427
comparison
equal deleted inserted replaced
31557:f021d93a1f9b 31558:ce968e115c95
509 else if (!strcmp(euf_guid, MSN_FT_GUID)) 509 else if (!strcmp(euf_guid, MSN_FT_GUID))
510 { 510 {
511 /* File Transfer */ 511 /* File Transfer */
512 PurpleAccount *account; 512 PurpleAccount *account;
513 PurpleXfer *xfer; 513 PurpleXfer *xfer;
514 MsnFileContext *header; 514 MsnFileContext *file_context;
515 char *buf; 515 char *buf;
516 gsize bin_len; 516 gsize bin_len;
517 guint32 file_size; 517 guint32 file_size;
518 char *file_name; 518 char *file_name;
519 519
526 526
527 xfer = purple_xfer_new(account, PURPLE_XFER_RECEIVE, 527 xfer = purple_xfer_new(account, PURPLE_XFER_RECEIVE,
528 slpcall->slplink->remote_user); 528 slpcall->slplink->remote_user);
529 529
530 buf = (char *)purple_base64_decode(context, &bin_len); 530 buf = (char *)purple_base64_decode(context, &bin_len);
531 header = msn_file_context_from_wire(buf, bin_len); 531 file_context = msn_file_context_from_wire(buf, bin_len);
532 532
533 if (header != NULL) { 533 if (file_context != NULL) {
534 file_size = header->file_size; 534 file_size = file_context->file_size;
535 535
536 file_name = g_convert((const gchar *)&header->file_name, 536 file_name = g_convert((const gchar *)&file_context->file_name,
537 MAX_FILE_NAME_LEN * 2, 537 MAX_FILE_NAME_LEN * 2,
538 "UTF-8", "UTF-16LE", 538 "UTF-8", "UTF-16LE",
539 NULL, NULL, NULL); 539 NULL, NULL, NULL);
540 540
541 purple_xfer_set_filename(xfer, file_name ? file_name : ""); 541 purple_xfer_set_filename(xfer, file_name ? file_name : "");
552 slpcall->xfer = xfer; 552 slpcall->xfer = xfer;
553 purple_xfer_ref(slpcall->xfer); 553 purple_xfer_ref(slpcall->xfer);
554 554
555 xfer->data = slpcall; 555 xfer->data = slpcall;
556 556
557 if (header->preview) { 557 if (file_context->preview) {
558 purple_xfer_set_thumbnail(xfer, header->preview, 558 purple_xfer_set_thumbnail(xfer, file_context->preview,
559 header->preview_len, 559 file_context->preview_len,
560 "image/png"); 560 "image/png");
561 g_free(header->preview); 561 g_free(file_context->preview);
562 } 562 }
563 563
564 purple_xfer_request(xfer); 564 purple_xfer_request(xfer);
565 } 565 }
566 g_free(header); 566 g_free(file_context);
567 g_free(buf); 567 g_free(buf);
568 568
569 accepted = TRUE; 569 accepted = TRUE;
570 570
571 } else if (!strcmp(euf_guid, MSN_CAM_REQUEST_GUID)) { 571 } else if (!strcmp(euf_guid, MSN_CAM_REQUEST_GUID)) {
1057 msn_slp_process_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg) 1057 msn_slp_process_msg(MsnSlpLink *slplink, MsnSlpMessage *slpmsg)
1058 { 1058 {
1059 MsnSlpCall *slpcall; 1059 MsnSlpCall *slpcall;
1060 const guchar *body; 1060 const guchar *body;
1061 gsize body_len; 1061 gsize body_len;
1062 guint32 session_id;
1063 guint32 flags;
1062 1064
1063 slpcall = NULL; 1065 slpcall = NULL;
1064 body = slpmsg->buffer; 1066 body = slpmsg->buffer;
1065 body_len = slpmsg->header->offset; 1067 body_len = msn_p2p_info_get_offset(slpmsg->p2p_info);
1066 1068
1067 if (slpmsg->header->flags == P2P_NO_FLAG || slpmsg->header->flags == P2P_WLM2009_COMP) 1069 session_id = msn_p2p_info_get_session_id(slpmsg->p2p_info);
1070 flags = msn_p2p_info_get_flags(slpmsg->p2p_info);
1071
1072 if (flags == P2P_NO_FLAG || flags == P2P_WLM2009_COMP)
1068 { 1073 {
1069 char *body_str; 1074 char *body_str;
1070 1075
1071 if (slpmsg->header->session_id == 64) 1076 if (session_id == 64)
1072 { 1077 {
1073 /* This is for handwritten messages (Ink) */ 1078 /* This is for handwritten messages (Ink) */
1074 GError *error = NULL; 1079 GError *error = NULL;
1075 gsize bytes_read, bytes_written; 1080 gsize bytes_read, bytes_written;
1076 1081
1123 body_str = g_strndup((const char *)body, body_len); 1128 body_str = g_strndup((const char *)body, body_len);
1124 slpcall = msn_slp_sip_recv(slplink, body_str); 1129 slpcall = msn_slp_sip_recv(slplink, body_str);
1125 } 1130 }
1126 g_free(body_str); 1131 g_free(body_str);
1127 } 1132 }
1128 else if (msn_p2p_msg_is_data(slpmsg->header->flags)) 1133 else if (msn_p2p_msg_is_data(flags))
1129 { 1134 {
1130 slpcall = msn_slplink_find_slp_call_with_session_id(slplink, slpmsg->header->session_id); 1135 slpcall = msn_slplink_find_slp_call_with_session_id(slplink, session_id);
1131 1136
1132 if (slpcall != NULL) 1137 if (slpcall != NULL)
1133 { 1138 {
1134 if (slpcall->timer) { 1139 if (slpcall->timer) {
1135 purple_timeout_remove(slpcall->timer); 1140 purple_timeout_remove(slpcall->timer);
1140 slpcall->cb(slpcall, body, body_len); 1145 slpcall->cb(slpcall, body, body_len);
1141 1146
1142 slpcall->wasted = TRUE; 1147 slpcall->wasted = TRUE;
1143 } 1148 }
1144 } 1149 }
1145 #if 0 1150 else if (flags == P2P_ACK)
1146 else if (slpmsg->header->flags == 0x100)
1147 {
1148 slpcall = slplink->directconn->initial_call;
1149
1150 if (slpcall != NULL)
1151 msn_slpcall_session_init(slpcall);
1152 }
1153 #endif
1154 else if (slpmsg->header->flags == P2P_ACK)
1155 { 1151 {
1156 /* Acknowledgement of previous message. Don't do anything currently. */ 1152 /* Acknowledgement of previous message. Don't do anything currently. */
1157 } 1153 }
1158 else 1154 else
1159 purple_debug_warning("msn", "Unprocessed SLP message with flags 0x%04x\n", 1155 purple_debug_warning("msn", "Unprocessed SLP message with flags 0x%04x\n",
1160 slpmsg->header->flags); 1156 flags);
1161 1157
1162 return slpcall; 1158 return slpcall;
1163 } 1159 }