void msn_sbconn_send_part(MsnSlpLink *slplink, MsnSlpMessagePart *part) { MsnMessage *msg; const char *passport; char *data; size_t size; msg = msn_message_new_msnslp(); passport = purple_normalize(slplink->session->account, slplink->remote_user); msn_message_set_header(msg, "P2P-Dest", passport); msg->part = msn_slpmsgpart_ref(part); data = msn_slpmsgpart_serialize(part, &size); msn_message_set_bin_data(msg, data, size); g_free(data); if (slplink->swboard == NULL) { slplink->swboard = msn_session_get_swboard(slplink->session, slplink->remote_user, MSN_SB_FLAG_FT); g_return_if_fail(slplink->swboard != NULL); /* If swboard is destroyed we will be too */ slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); } msn_switchboard_send_msg(slplink->swboard, msg, TRUE); msn_message_unref(msg); }
static void msn_slplink_send_msg(MsnSlpLink *slplink, MsnMessage *msg) { #if 0 if (slplink->directconn != NULL) { msn_directconn_send_msg(slplink->directconn, msg); } else #endif { if (slplink->swboard == NULL) { slplink->swboard = msn_session_get_swboard(slplink->session, slplink->remote_user, MSN_SB_FLAG_FT); g_return_if_fail(slplink->swboard != NULL); /* If swboard is destroyed we will be too */ slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); } msn_switchboard_send_msg(slplink->swboard, msg, TRUE); } }
void msn_slp_session_send_ack(MsnSlpSession *slpsession, MsnMessage *acked_msg) { MsnMessage *msg; gboolean new_base_id = FALSE; g_return_if_fail(slpsession != NULL); g_return_if_fail(acked_msg != NULL); g_return_if_fail(acked_msg->msnslp_message); g_return_if_fail(slpsession->outgoing_msg == NULL); msg = msn_message_new_msnslp_ack(acked_msg); if (slpsession->base_id == 0) { slpsession->base_id = rand() % 0x0FFFFE00 + 10; slpsession->prev_msg_id = slpsession->base_id; new_base_id = TRUE; } else slpsession->prev_msg_id = ++slpsession->base_id; msg->msnslp_header.id = slpsession->prev_msg_id; if (new_base_id) slpsession->prev_msg_id -= 4; msn_switchboard_send_msg(slpsession->swboard, msg); }
static void send_clientcaps(MsnSwitchBoard *swboard) { MsnMessage *msg; msg = msn_message_new(MSN_MSG_CAPS); msn_message_set_content_type(msg, "text/x-clientcaps"); msn_message_set_flag(msg, 'U'); msn_message_set_bin_data(msg, MSN_CLIENTINFO, strlen(MSN_CLIENTINFO)); msn_switchboard_send_msg(swboard, msg, TRUE); msn_message_destroy(msg); }
void msn_slplink_send_msg(MsnSlpLink *slplink, MsnMessage *msg) { if (slplink->swboard == NULL) { slplink->swboard = msn_session_get_swboard(slplink->session, slplink->remote_user, MSN_SB_FLAG_FT); if (slplink->swboard == NULL) return; /* If swboard is destroyed we will be too */ slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); } msn_switchboard_send_msg(slplink->swboard, msg, TRUE); }
static void send_msg_part(MsnSlpSession *slpsession, MsnMessage *msg) { msg->msnslp_header.length = (slpsession->orig_len - slpsession->offset > 1202 ? 1202 : slpsession->orig_len - slpsession->offset); if (slpsession->offset > 0) { if (msg->bin_content) { msn_message_set_bin_data(msg, slpsession->orig_body + slpsession->offset, msg->msnslp_header.length); } else { msn_message_set_body(msg, slpsession->orig_body + slpsession->offset); } } msg->msnslp_header.offset_1 = slpsession->offset; msn_switchboard_send_msg(slpsession->swboard, msg); if (slpsession->offset + msg->msnslp_header.length == slpsession->orig_len) { msn_message_destroy(msg); g_free(slpsession->orig_body); slpsession->offset = 0; slpsession->orig_len = 0; slpsession->orig_body = NULL; slpsession->outgoing_msg = NULL; } else slpsession->offset += msg->msnslp_header.length; }
void msn_slplink_send_msg(MsnSlpLink *slplink, MsnMessage *msg) { if (slplink->dc != NULL && slplink->dc->state == DC_STATE_ESTABLISHED) { msn_dc_enqueue_msg(slplink->dc, msg); } else { if (slplink->swboard == NULL) { slplink->swboard = msn_session_get_swboard(slplink->session, slplink->remote_user, MSN_SB_FLAG_FT); g_return_if_fail(slplink->swboard != NULL); /* If swboard is destroyed we will be too */ slplink->swboard->slplinks = g_list_prepend(slplink->swboard->slplinks, slplink); } msn_switchboard_send_msg(slplink->swboard, msg, TRUE); } }
void msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { GHashTable *body; const gchar *command; const gchar *cookie; gboolean accepted = FALSE; g_return_if_fail(cmdproc != NULL); g_return_if_fail(msg != NULL); body = msn_message_get_hashtable_from_body(msg); if (body == NULL) { purple_debug_warning("msn", "Unable to parse invite msg body.\n"); return; } /* * GUID is NOT always present but Invitation-Command and Invitation-Cookie * are mandatory. */ command = g_hash_table_lookup(body, "Invitation-Command"); cookie = g_hash_table_lookup(body, "Invitation-Cookie"); if (command == NULL || cookie == NULL) { purple_debug_warning("msn", "Invalid invitation message: either Invitation-Command " "or Invitation-Cookie is missing or invalid.\n" ); return; } else if (!strcmp(command, "INVITE")) { const gchar *guid = g_hash_table_lookup(body, "Application-GUID"); if (guid == NULL) { purple_debug_warning("msn", "Invite msg missing Application-GUID.\n"); accepted = TRUE; } else if (!strcmp(guid, MSN_FT_GUID)) { } else if (!strcmp(guid, "{02D3C01F-BF30-4825-A83A-DE7AF41648AA}")) { purple_debug_info("msn", "Computer call\n"); if (cmdproc->session) { PurpleIMConversation *im = NULL; gchar *from = msg->remote_user; gchar *buf = NULL; if (from) im = purple_conversations_find_im_with_account( from, cmdproc->session->account); if (im) buf = g_strdup_printf( _("%s sent you a voice chat " "invite, which is not yet " "supported."), from); if (buf) { purple_conversation_write(PURPLE_CONVERSATION(im), NULL, buf, PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY, time(NULL)); g_free(buf); } } } else { const gchar *application = g_hash_table_lookup(body, "Application-Name"); purple_debug_warning("msn", "Unhandled invite msg with GUID %s: %s.\n", guid, application ? application : "(null)"); } if (!accepted) { MsnSwitchBoard *swboard = cmdproc->data; char *text; MsnMessage *cancel; cancel = msn_message_new(MSN_MSG_TEXT); msn_message_set_content_type(cancel, "text/x-msmsgsinvite"); msn_message_set_charset(cancel, "UTF-8"); msn_message_set_flag(cancel, 'U'); text = g_strdup_printf("Invitation-Command: CANCEL\r\n" "Invitation-Cookie: %s\r\n" "Cancel-Code: REJECT_NOT_INSTALLED\r\n", cookie); msn_message_set_bin_data(cancel, text, strlen(text)); g_free(text); msn_switchboard_send_msg(swboard, cancel, TRUE); msn_message_unref(cancel); } } else if (!strcmp(command, "CANCEL")) { const gchar *code = g_hash_table_lookup(body, "Cancel-Code"); purple_debug_info("msn", "MSMSGS invitation cancelled: %s.\n", code ? code : "no reason given"); } else { /* * Some other already established invitation session. * Can be retrieved by Invitation-Cookie. */ } g_hash_table_destroy(body); }