static void sipe_invite_mime_cb(gpointer user_data, const GSList *fields, const gchar *body, gsize length) { const gchar *type = sipe_utils_nameval_find(fields, "Content-Type"); const gchar *cd = sipe_utils_nameval_find(fields, "Content-Disposition"); if (!g_str_has_prefix(type, "application/sdp")) return; if (!cd || !strstr(cd, "ms-proxy-2007fallback")) { struct sipmsg *msg = user_data; const gchar* msg_ct = sipmsg_find_header(msg, "Content-Type"); if (g_str_has_prefix(msg_ct, "application/sdp")) { /* We have already found suitable alternative and set message's body * and Content-Type accordingly */ return; } sipmsg_remove_header_now(msg, "Content-Type"); sipmsg_add_header_now(msg, "Content-Type", type); /* Replace message body with chosen alternative, so we can continue to * process it as a normal single part message. */ g_free(msg->body); msg->body = g_strndup(body, length); msg->bodylen = length; } }
static void get_html_message_mime_cb(gpointer user_data, const GSList *fields, const gchar *body, gsize length) { const gchar *type = sipe_utils_nameval_find(fields, "Content-Type"); struct html_message_data *data = user_data; if (!data->preferred) { gboolean copy = FALSE; /* preferred format */ if (g_str_has_prefix(type, "text/html")) { copy = TRUE; data->preferred = TRUE; /* fallback format */ } else if (g_str_has_prefix(type, "text/plain")) { copy = TRUE; } if (copy) { g_free(data->ms_text_format); g_free(data->body); data->ms_text_format = g_strdup(type); data->body = g_strndup(body, length); } } }
static void sipe_invite_mime_mixed_cb(gpointer user_data, const GSList *fields, SIPE_UNUSED_PARAMETER const gchar *body, SIPE_UNUSED_PARAMETER gsize length) { const gchar *ctype = sipe_utils_nameval_find(fields, "Content-Type"); /* Lync 2010 file transfer */ if (g_str_has_prefix(ctype, "application/ms-filetransfer+xml")) { struct sipmsg *msg = user_data; sipmsg_remove_header_now(msg, "Content-Type"); sipmsg_add_header_now(msg, "Content-Type", ctype); /* Right now, we do not care about the message body, only detect new * file transfer protocol from Content-Type and reply with * 488 Not Acceptable Here to force the old MSOC behavior. * * TODO: Extend sipmsg so that it supports multipart messages, as to * implement the new protocol, we need access to both parts of the * message for further processing. */ } }
static gboolean sipe_process_incoming_x_msmsgsinvite(struct sipe_core_private *sipe_private, struct sip_dialog *dialog, GSList *parsed_body) { gboolean found = FALSE; if (parsed_body) { const gchar *invitation_command = sipe_utils_nameval_find(parsed_body, "Invitation-Command"); if (sipe_strequal(invitation_command, "INVITE")) { sipe_ft_incoming_transfer(sipe_private, dialog, parsed_body); found = TRUE; } else if (sipe_strequal(invitation_command, "CANCEL")) { sipe_ft_incoming_cancel(dialog, parsed_body); found = TRUE; } else if (sipe_strequal(invitation_command, "ACCEPT")) { sipe_ft_incoming_accept(dialog, parsed_body); found = TRUE; } } return found; }