static void assert_int_attribute(const sipe_xml *xml, const gchar *key, gint value, gint fallback) { gint attr = sipe_xml_int_attribute(xml, key, fallback); if ((attr == value) || (attr == fallback)) { succeeded++; } else { printf("[%s]\nXML int attr FAILED: '%s': %d expected: %d/%d\n", teststring, key ? key : "(nil)", attr, value, fallback); failed++; } }
void process_incoming_info(struct sipe_core_private *sipe_private, struct sipmsg *msg) { const gchar *contenttype = sipmsg_find_header(msg, "Content-Type"); const gchar *callid = sipmsg_find_header(msg, "Call-ID"); gchar *from; struct sip_session *session; SIPE_DEBUG_INFO_NOFORMAT("process_incoming_info"); /* Call Control protocol */ if (g_str_has_prefix(contenttype, "application/csta+xml")) { process_incoming_info_csta(sipe_private, msg); return; } else if (g_str_has_prefix(contenttype, "application/xml+conversationinfo")) { process_incoming_info_conversation(sipe_private, msg); return; } from = parse_from(sipmsg_find_header(msg, "From")); session = sipe_session_find_chat_or_im(sipe_private, callid, from); if (!session) { g_free(from); return; } /* Group Chat uses text/plain */ if (session->is_groupchat) { process_incoming_info_groupchat(sipe_private, msg, session); g_free(from); return; } if (g_str_has_prefix(contenttype, "application/x-ms-mim")) { sipe_xml *xn_action = sipe_xml_parse(msg->body, msg->bodylen); const sipe_xml *xn_request_rm = sipe_xml_child(xn_action, "RequestRM"); const sipe_xml *xn_set_rm = sipe_xml_child(xn_action, "SetRM"); sipmsg_add_header(msg, "Content-Type", "application/x-ms-mim"); if (xn_request_rm) { //const char *rm = sipe_xml_attribute(xn_request_rm, "uri"); int bid = sipe_xml_int_attribute(xn_request_rm, "bid", 0); gchar *body = g_strdup_printf( "<?xml version=\"1.0\"?>\r\n" "<action xmlns=\"http://schemas.microsoft.com/sip/multiparty/\">" "<RequestRMResponse uri=\"sip:%s\" allow=\"%s\"/></action>\r\n", sipe_private->username, session->bid < bid ? "true" : "false"); sip_transport_response(sipe_private, msg, 200, "OK", body); g_free(body); } else if (xn_set_rm) { gchar *body; sipe_chat_set_roster_manager(session, sipe_xml_attribute(xn_set_rm, "uri")); body = g_strdup_printf( "<?xml version=\"1.0\"?>\r\n" "<action xmlns=\"http://schemas.microsoft.com/sip/multiparty/\">" "<SetRMResponse uri=\"sip:%s\"/></action>\r\n", sipe_private->username); sip_transport_response(sipe_private, msg, 200, "OK", body); g_free(body); } sipe_xml_free(xn_action); } else { /* looks like purple lacks typing notification for chat */ if (!session->chat_session) { sipe_xml *xn_keyboard_activity = sipe_xml_parse(msg->body, msg->bodylen); const char *status = sipe_xml_attribute(sipe_xml_child(xn_keyboard_activity, "status"), "status"); if (sipe_strequal(status, "type")) { sipe_backend_user_feedback_typing(SIPE_CORE_PUBLIC, from); } else if (sipe_strequal(status, "idle")) { sipe_backend_user_feedback_typing_stop(SIPE_CORE_PUBLIC, from); } sipe_xml_free(xn_keyboard_activity); } sip_transport_response(sipe_private, msg, 200, "OK", NULL); } g_free(from); }