/** Invite us to the focus callback */ static gboolean process_invite_conf_focus_response(struct sipe_core_private *sipe_private, struct sipmsg *msg, SIPE_UNUSED_PARAMETER struct transaction *trans) { struct sip_session *session = NULL; char *focus_uri = parse_from(sipmsg_find_header(msg, "To")); session = sipe_session_find_conference(sipe_private, focus_uri); if (!session) { SIPE_DEBUG_INFO("process_invite_conf_focus_response: unable to find conf session with focus=%s", focus_uri); g_free(focus_uri); return FALSE; } if (!session->focus_dialog) { SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: session's focus_dialog is NULL"); g_free(focus_uri); return FALSE; } sipe_dialog_parse(session->focus_dialog, msg, TRUE); if (msg->response >= 200) { /* send ACK to focus */ session->focus_dialog->cseq = 0; sip_transport_ack(sipe_private, session->focus_dialog); session->focus_dialog->outgoing_invite = NULL; session->focus_dialog->is_established = TRUE; } if (msg->response >= 400) { SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: INVITE response is not 200. Failed to join focus."); /* @TODO notify user of failure to join focus */ sipe_session_remove(sipe_private, session); g_free(focus_uri); return FALSE; } else if (msg->response == 200) { sipe_xml *xn_response = sipe_xml_parse(msg->body, msg->bodylen); const gchar *code = sipe_xml_attribute(xn_response, "code"); if (sipe_strequal(code, "success")) { /* subscribe to focus */ sipe_subscribe_conference(sipe_private, session, FALSE); } sipe_xml_free(xn_response); } g_free(focus_uri); return TRUE; }
/** Invite counterparty to join conference callback */ static gboolean process_invite_conf_response(struct sipe_core_private *sipe_private, struct sipmsg *msg, SIPE_UNUSED_PARAMETER struct transaction *trans) { struct sip_dialog *dialog = g_new0(struct sip_dialog, 1); dialog->callid = g_strdup(sipmsg_find_header(msg, "Call-ID")); dialog->cseq = sipmsg_parse_cseq(msg); dialog->with = parse_from(sipmsg_find_header(msg, "To")); sipe_dialog_parse(dialog, msg, TRUE); if (msg->response >= 200) { /* send ACK to counterparty */ dialog->cseq--; sip_transport_ack(sipe_private, dialog); dialog->outgoing_invite = NULL; dialog->is_established = TRUE; } if (msg->response >= 400) { SIPE_DEBUG_INFO("process_invite_conf_response: INVITE response is not 200. Failed to invite %s.", dialog->with); /* @TODO notify user of failure to invite counterparty */ sipe_dialog_free(dialog); return FALSE; } if (msg->response >= 200) { struct sip_session *session = sipe_session_find_im(sipe_private, dialog->with); struct sip_dialog *im_dialog = sipe_dialog_find(session, dialog->with); /* close IM session to counterparty */ if (im_dialog) { sip_transport_bye(sipe_private, im_dialog); sipe_dialog_remove(session, dialog->with); } } sipe_dialog_free(dialog); return TRUE; }
/** Invite us to the focus callback */ static gboolean process_invite_conf_focus_response(struct sipe_core_private *sipe_private, struct sipmsg *msg, SIPE_UNUSED_PARAMETER struct transaction *trans) { struct sip_session *session = NULL; char *focus_uri = parse_from(sipmsg_find_header(msg, "To")); session = sipe_session_find_conference(sipe_private, focus_uri); if (!session) { SIPE_DEBUG_INFO("process_invite_conf_focus_response: unable to find conf session with focus=%s", focus_uri); g_free(focus_uri); return FALSE; } if (!session->focus_dialog) { SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: session's focus_dialog is NULL"); g_free(focus_uri); return FALSE; } sipe_dialog_parse(session->focus_dialog, msg, TRUE); if (msg->response >= 200) { /* send ACK to focus */ session->focus_dialog->cseq = 0; sip_transport_ack(sipe_private, session->focus_dialog); session->focus_dialog->outgoing_invite = NULL; session->focus_dialog->is_established = TRUE; } if (msg->response >= 400) { gchar *reason = sipmsg_get_ms_diagnostics_reason(msg); SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: INVITE response is not 200. Failed to join focus."); sipe_backend_notify_error(SIPE_CORE_PUBLIC, _("Failed to join the conference"), reason ? reason : _("no reason given")); g_free(reason); sipe_session_remove(sipe_private, session); g_free(focus_uri); return FALSE; } else if (msg->response == 200) { sipe_xml *xn_response = sipe_xml_parse(msg->body, msg->bodylen); const gchar *code = sipe_xml_attribute(xn_response, "code"); if (sipe_strequal(code, "success")) { /* subscribe to focus */ sipe_subscribe_conference(sipe_private, session->chat_session->id, FALSE); #ifdef HAVE_VV if (session->is_call) sipe_core_media_connect_conference(SIPE_CORE_PUBLIC, session->chat_session); #endif } sipe_xml_free(xn_response); } g_free(focus_uri); return TRUE; }