6 * Copyright (C) 2010-11 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2009 pier11 <pier11@operamail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include "sipe-common.h"
37 #include "sip-transport.h"
38 #include "sipe-backend.h"
39 #include "sipe-chat.h"
40 #include "sipe-conf.h"
41 #include "sipe-core.h"
42 #include "sipe-core-private.h"
43 #include "sipe-dialog.h"
46 #include "sipe-media.h"
49 #include "sipe-session.h"
50 #include "sipe-subscriptions.h"
51 #include "sipe-user.h"
52 #include "sipe-utils.h"
57 #define ENTITY_VIEW_AUDIO_VIDEO "<msci:entity-view entity=\"audio-video\"/>"
59 #define ENTITY_VIEW_AUDIO_VIDEO
63 * Add Conference request to FocusFactory.
64 * @param focus_factory_uri (%s) Ex.: sip:bob7@boston.local;gruu;opaque=app:conf:focusfactory
65 * @param from (%s) Ex.: sip:bob7@boston.local
66 * @param request_id (%d) Ex.: 1094520
67 * @param conference_id (%s) Ex.: 8386E6AEAAA41E4AA6627BA76D43B6D1
68 * @param expiry_time (%s) Ex.: 2009-07-13T17:57:09Z , Default duration: 7 hours
70 #define SIPE_SEND_CONF_ADD \
71 "<?xml version=\"1.0\"?>"\
72 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" "\
73 "xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
79 "<ci:conference-info xmlns:ci=\"urn:ietf:params:xml:ns:conference-info\" entity=\"\" xmlns:msci=\"http://schemas.microsoft.com/rtc/2005/08/confinfoextensions\">"\
80 "<ci:conference-description>"\
82 "<msci:conference-id>%s</msci:conference-id>"\
83 "<msci:expiry-time>%s</msci:expiry-time>"\
84 "<msci:admission-policy>openAuthenticated</msci:admission-policy>"\
85 "</ci:conference-description>"\
86 "<msci:conference-view>"\
87 "<msci:entity-view entity=\"chat\"/>"\
88 ENTITY_VIEW_AUDIO_VIDEO \
89 "</msci:conference-view>"\
90 "</ci:conference-info>"\
95 * AddUser request to Focus.
97 * focus_URI, from, request_id, focus_URI, from, endpoint_GUID
99 #define SIPE_SEND_CONF_ADD_USER \
100 "<?xml version=\"1.0\"?>"\
101 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
107 "<conferenceKeys confEntity=\"%s\"/>"\
108 "<ci:user xmlns:ci=\"urn:ietf:params:xml:ns:conference-info\" entity=\"%s\">"\
110 "<ci:entry>attendee</ci:entry>"\
112 "<ci:endpoint entity=\"{%s}\" xmlns:msci=\"http://schemas.microsoft.com/rtc/2005/08/confinfoextensions\"/>"\
118 * ModifyUserRoles request to Focus. Makes user a leader.
119 * @param focus_uri (%s)
121 * @param request_id (%d)
122 * @param focus_uri (%s)
125 #define SIPE_SEND_CONF_MODIFY_USER_ROLES \
126 "<?xml version=\"1.0\"?>"\
127 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
133 "<userKeys confEntity=\"%s\" userEntity=\"%s\"/>"\
134 "<user-roles xmlns=\"urn:ietf:params:xml:ns:conference-info\">"\
135 "<entry>presenter</entry>"\
137 "</modifyUserRoles>"\
141 * ModifyConferenceLock request to Focus. Locks/unlocks conference.
142 * @param focus_uri (%s)
144 * @param request_id (%d)
145 * @param focus_uri (%s)
146 * @param locked (%s) "true" or "false" values applicable
148 #define SIPE_SEND_CONF_MODIFY_CONF_LOCK \
149 "<?xml version=\"1.0\"?>"\
150 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
155 "<modifyConferenceLock>"\
156 "<conferenceKeys confEntity=\"%s\"/>"\
157 "<locked>%s</locked>"\
158 "</modifyConferenceLock>"\
162 * ModifyConferenceLock request to Focus. Locks/unlocks conference.
163 * @param focus_uri (%s)
165 * @param request_id (%d)
166 * @param focus_uri (%s)
169 #define SIPE_SEND_CONF_DELETE_USER \
170 "<?xml version=\"1.0\"?>"\
171 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
177 "<userKeys confEntity=\"%s\" userEntity=\"%s\"/>"\
182 * Invite counterparty to join conference.
183 * @param focus_uri (%s)
184 * @param subject (%s) of conference
186 #define SIPE_SEND_CONF_INVITE \
187 "<Conferencing version=\"2.0\">"\
188 "<focus-uri>%s</focus-uri>"\
189 "<subject>%s</subject>"\
190 "<im available=\"true\">"\
196 * Generates random GUID.
197 * This method is borrowed from pidgin's msnutils.c
202 return g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X",
203 rand() % 0xAAFF + 0x1111,
204 rand() % 0xAAFF + 0x1111,
205 rand() % 0xAAFF + 0x1111,
206 rand() % 0xAAFF + 0x1111,
207 rand() % 0xAAFF + 0x1111,
208 rand() % 0xAAFF + 0x1111,
209 rand() % 0xAAFF + 0x1111,
210 rand() % 0xAAFF + 0x1111);
214 * @param expires not respected if set to negative value (E.g. -1)
217 sipe_subscribe_conference(struct sipe_core_private
*sipe_private
,
218 struct sip_session
*session
,
221 sipe_subscribe(sipe_private
,
222 session
->chat_session
->id
,
224 "application/conference-info+xml",
225 expires
? "Expires: 0\r\n" : NULL
,
230 /** Invite us to the focus callback */
232 process_invite_conf_focus_response(struct sipe_core_private
*sipe_private
,
234 SIPE_UNUSED_PARAMETER
struct transaction
*trans
)
236 struct sip_session
*session
= NULL
;
237 char *focus_uri
= parse_from(sipmsg_find_header(msg
, "To"));
239 session
= sipe_session_find_conference(sipe_private
, focus_uri
);
242 SIPE_DEBUG_INFO("process_invite_conf_focus_response: unable to find conf session with focus=%s", focus_uri
);
247 if (!session
->focus_dialog
) {
248 SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: session's focus_dialog is NULL");
253 sipe_dialog_parse(session
->focus_dialog
, msg
, TRUE
);
255 if (msg
->response
>= 200) {
256 /* send ACK to focus */
257 session
->focus_dialog
->cseq
= 0;
258 sip_transport_ack(sipe_private
, session
->focus_dialog
);
259 session
->focus_dialog
->outgoing_invite
= NULL
;
260 session
->focus_dialog
->is_established
= TRUE
;
263 if (msg
->response
>= 400) {
264 gchar
*reason
= sipmsg_get_ms_diagnostics_reason(msg
);
266 SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: INVITE response is not 200. Failed to join focus.");
267 sipe_backend_notify_error(_("Failed to join the conference"),
268 reason
? reason
: _("no reason given"));
271 sipe_session_remove(sipe_private
, session
);
274 } else if (msg
->response
== 200) {
275 sipe_xml
*xn_response
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
276 const gchar
*code
= sipe_xml_attribute(xn_response
, "code");
277 if (sipe_strequal(code
, "success")) {
278 /* subscribe to focus */
279 sipe_subscribe_conference(sipe_private
, session
, FALSE
);
281 if (session
->is_call
)
282 sipe_core_media_connect_conference(SIPE_CORE_PUBLIC
,
283 session
->chat_session
,
287 sipe_xml_free(xn_response
);
295 sipe_core_conf_create(struct sipe_core_public
*sipe_public
,
296 const gchar
*focus_uri
)
299 const gchar
*focus_uri_ue
;
300 struct sip_session
*session
= NULL
;
302 focus_uri_ue
= buf
= sipe_utils_uri_unescape(focus_uri
);
304 // URI can have this prefix if it was typed in by the user
305 if (g_str_has_prefix(focus_uri_ue
, "meet:"))
308 if (!focus_uri_ue
|| !g_str_has_prefix(focus_uri_ue
, "sip:") ||
309 strlen(focus_uri_ue
) == 4 || g_strstr_len(focus_uri_ue
, -1, "%")) {
310 gchar
*error
= g_strdup_printf(_("\"%s\" is not a valid focus URI"),
311 focus_uri
? focus_uri
: "");
312 sipe_backend_notify_error(_("Failed to join the conference"),
316 gchar
*querystr
= g_strstr_len(focus_uri_ue
, -1, "?");
318 /* TODO: Investigate how conf-key field should be used,
319 * ignoring for now */
323 session
= sipe_conf_create(SIPE_CORE_PRIVATE
, NULL
, focus_uri_ue
);
331 /** Create new session with Focus URI */
333 sipe_conf_create(struct sipe_core_private
*sipe_private
,
334 struct sipe_chat_session
*chat_session
,
335 const gchar
*focus_uri
)
341 struct sip_session
*session
= sipe_session_add_chat(sipe_private
,
346 session
->focus_dialog
= g_new0(struct sip_dialog
, 1);
347 session
->focus_dialog
->callid
= gencallid();
348 session
->focus_dialog
->with
= g_strdup(session
->chat_session
->id
);
349 session
->focus_dialog
->endpoint_GUID
= rand_guid();
350 session
->focus_dialog
->ourtag
= gentag();
352 contact
= get_contact(sipe_private
);
353 hdr
= g_strdup_printf(
354 "Supported: ms-sender\r\n"
356 "Content-Type: application/cccp+xml\r\n",
360 /* @TODO put request_id to queue to further compare with incoming one */
361 /* focus_URI, from, request_id, focus_URI, from, endpoint_GUID */
362 self
= sip_uri_self(sipe_private
);
363 body
= g_strdup_printf(
364 SIPE_SEND_CONF_ADD_USER
,
365 session
->focus_dialog
->with
,
367 session
->request_id
++,
368 session
->focus_dialog
->with
,
370 session
->focus_dialog
->endpoint_GUID
);
372 session
->focus_dialog
->outgoing_invite
=
373 sip_transport_invite(sipe_private
,
376 session
->focus_dialog
,
377 process_invite_conf_focus_response
);
381 /* Rejoin existing session? */
383 SIPE_DEBUG_INFO("sipe_conf_create: rejoin '%s' (%s)",
386 sipe_backend_chat_rejoin(SIPE_CORE_PUBLIC
,
387 chat_session
->backend
,
389 chat_session
->title
);
396 /** Modify User Role */
398 sipe_conf_modify_user_role(struct sipe_core_private
*sipe_private
,
399 struct sip_session
*session
,
406 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
407 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_modify_user_role: no dialog with focus, exiting.");
412 "Content-Type: application/cccp+xml\r\n");
414 /* @TODO put request_id to queue to further compare with incoming one */
415 self
= sip_uri_self(sipe_private
);
416 body
= g_strdup_printf(
417 SIPE_SEND_CONF_MODIFY_USER_ROLES
,
418 session
->focus_dialog
->with
,
420 session
->request_id
++,
421 session
->focus_dialog
->with
,
425 sip_transport_info(sipe_private
,
428 session
->focus_dialog
,
435 * Check conference lock status
437 sipe_chat_lock_status
sipe_core_chat_lock_status(struct sipe_core_public
*sipe_public
,
438 struct sipe_chat_session
*chat_session
)
440 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
441 sipe_chat_lock_status status
= SIPE_CHAT_LOCK_STATUS_NOT_ALLOWED
;
444 (chat_session
->type
== SIPE_CHAT_TYPE_CONFERENCE
)) {
445 struct sip_session
*session
= sipe_session_find_chat(sipe_private
,
448 gchar
*self
= sip_uri_self(sipe_private
);
450 /* Only operators are allowed to change the lock status */
451 if (sipe_backend_chat_is_operator(chat_session
->backend
, self
)) {
452 status
= session
->locked
?
453 SIPE_CHAT_LOCK_STATUS_LOCKED
:
454 SIPE_CHAT_LOCK_STATUS_UNLOCKED
;
465 * Modify Conference Lock
466 * Sends request to Focus.
467 * INFO method is a carrier of application/cccp+xml
470 sipe_core_chat_modify_lock(struct sipe_core_public
*sipe_public
,
471 struct sipe_chat_session
*chat_session
,
472 const gboolean locked
)
474 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
479 struct sip_session
*session
= sipe_session_find_chat(sipe_private
,
482 if (!session
) return;
483 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
484 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_modify_conference_lock: no dialog with focus, exiting.");
489 "Content-Type: application/cccp+xml\r\n");
491 /* @TODO put request_id to queue to further compare with incoming one */
492 self
= sip_uri_self(sipe_private
);
493 body
= g_strdup_printf(
494 SIPE_SEND_CONF_MODIFY_CONF_LOCK
,
495 session
->focus_dialog
->with
,
497 session
->request_id
++,
498 session
->focus_dialog
->with
,
499 locked
? "true" : "false");
502 sip_transport_info(sipe_private
,
505 session
->focus_dialog
,
511 /** Modify Delete User */
513 sipe_conf_delete_user(struct sipe_core_private
*sipe_private
,
514 struct sip_session
*session
,
521 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
522 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_delete_user: no dialog with focus, exiting.");
527 "Content-Type: application/cccp+xml\r\n");
529 /* @TODO put request_id to queue to further compare with incoming one */
530 self
= sip_uri_self(sipe_private
);
531 body
= g_strdup_printf(
532 SIPE_SEND_CONF_DELETE_USER
,
533 session
->focus_dialog
->with
,
535 session
->request_id
++,
536 session
->focus_dialog
->with
,
540 sip_transport_info(sipe_private
,
543 session
->focus_dialog
,
549 /** Invite counterparty to join conference callback */
551 process_invite_conf_response(struct sipe_core_private
*sipe_private
,
553 SIPE_UNUSED_PARAMETER
struct transaction
*trans
)
555 struct sip_dialog
*dialog
= g_new0(struct sip_dialog
, 1);
557 dialog
->callid
= g_strdup(sipmsg_find_header(msg
, "Call-ID"));
558 dialog
->cseq
= sipmsg_parse_cseq(msg
);
559 dialog
->with
= parse_from(sipmsg_find_header(msg
, "To"));
560 sipe_dialog_parse(dialog
, msg
, TRUE
);
562 if (msg
->response
>= 200) {
563 /* send ACK to counterparty */
565 sip_transport_ack(sipe_private
, dialog
);
566 dialog
->outgoing_invite
= NULL
;
567 dialog
->is_established
= TRUE
;
570 if (msg
->response
>= 400) {
571 SIPE_DEBUG_INFO("process_invite_conf_response: INVITE response is not 200. Failed to invite %s.", dialog
->with
);
572 /* @TODO notify user of failure to invite counterparty */
573 sipe_dialog_free(dialog
);
577 if (msg
->response
>= 200) {
578 struct sip_session
*session
= sipe_session_find_im(sipe_private
, dialog
->with
);
579 struct sip_dialog
*im_dialog
= sipe_dialog_find(session
, dialog
->with
);
581 /* close IM session to counterparty */
583 sip_transport_bye(sipe_private
, im_dialog
);
584 sipe_dialog_remove(session
, dialog
->with
);
588 sipe_dialog_free(dialog
);
593 * Invites counterparty to join conference.
596 sipe_invite_conf(struct sipe_core_private
*sipe_private
,
597 struct sip_session
*session
,
603 struct sip_dialog
*dialog
= NULL
;
605 /* It will be short lived special dialog.
606 * Will not be stored in session.
608 dialog
= g_new0(struct sip_dialog
, 1);
609 dialog
->callid
= gencallid();
610 dialog
->with
= g_strdup(who
);
611 dialog
->ourtag
= gentag();
613 contact
= get_contact(sipe_private
);
614 hdr
= g_strdup_printf(
615 "Supported: ms-sender\r\n"
617 "Content-Type: application/ms-conf-invite+xml\r\n",
621 body
= g_strdup_printf(
622 SIPE_SEND_CONF_INVITE
,
623 session
->chat_session
->id
,
624 session
->subject
? session
->subject
: ""
627 sip_transport_invite(sipe_private
,
631 process_invite_conf_response
);
633 sipe_dialog_free(dialog
);
638 /** Create conference callback */
640 process_conf_add_response(struct sipe_core_private
*sipe_private
,
642 struct transaction
*trans
)
644 if (msg
->response
>= 400) {
645 SIPE_DEBUG_INFO_NOFORMAT("process_conf_add_response: SERVICE response is not 200. Failed to create conference.");
646 /* @TODO notify user of failure to create conference */
649 if (msg
->response
== 200) {
650 sipe_xml
*xn_response
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
651 if (sipe_strequal("success", sipe_xml_attribute(xn_response
, "code")))
653 gchar
*who
= trans
->payload
->data
;
654 const sipe_xml
*xn_conference_info
= sipe_xml_child(xn_response
, "addConference/conference-info");
655 struct sip_session
*session
= sipe_conf_create(sipe_private
,
657 sipe_xml_attribute(xn_conference_info
,
660 SIPE_DEBUG_INFO("process_conf_add_response: session->focus_uri=%s",
661 session
->chat_session
->id
);
663 session
->pending_invite_queue
= slist_insert_unique_sorted(
664 session
->pending_invite_queue
, g_strdup(who
), (GCompareFunc
)strcmp
);
666 sipe_xml_free(xn_response
);
673 * Creates conference.
676 sipe_conf_add(struct sipe_core_private
*sipe_private
,
680 gchar
*conference_id
;
684 struct transaction
*trans
;
685 struct sip_dialog
*dialog
= NULL
;
686 time_t expiry
= time(NULL
) + 7*60*60; /* 7 hours */
688 struct transaction_payload
*payload
;
690 contact
= get_contact(sipe_private
);
691 hdr
= g_strdup_printf(
692 "Supported: ms-sender\r\n"
694 "Content-Type: application/cccp+xml\r\n",
698 expiry_time
= sipe_utils_time_to_str(expiry
);
699 self
= sip_uri_self(sipe_private
);
700 conference_id
= genconfid();
701 body
= g_strdup_printf(
703 sipe_private
->focus_factory_uri
,
709 g_free(conference_id
);
712 trans
= sip_transport_service(sipe_private
,
713 sipe_private
->focus_factory_uri
,
716 process_conf_add_response
);
718 payload
= g_new0(struct transaction_payload
, 1);
719 payload
->destroy
= g_free
;
720 payload
->data
= g_strdup(who
);
721 trans
->payload
= payload
;
723 sipe_dialog_free(dialog
);
729 process_incoming_invite_conf(struct sipe_core_private
*sipe_private
,
732 sipe_xml
*xn_conferencing
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
733 const sipe_xml
*xn_focus_uri
= sipe_xml_child(xn_conferencing
, "focus-uri");
734 const sipe_xml
*xn_audio
= sipe_xml_child(xn_conferencing
, "audio");
735 gchar
*focus_uri
= sipe_xml_data(xn_focus_uri
);
736 gboolean audio
= sipe_strequal(sipe_xml_attribute(xn_audio
, "available"), "true");
737 gchar
*newTag
= gentag();
738 const gchar
*oldHeader
= sipmsg_find_header(msg
, "To");
740 struct sip_session
*session
;
742 sipe_xml_free(xn_conferencing
);
745 SIPE_DEBUG_INFO("We have received invitation to Conference. Focus URI=%s", focus_uri
);
747 newHeader
= g_strdup_printf("%s;tag=%s", oldHeader
, newTag
);
749 sipmsg_remove_header_now(msg
, "To");
750 sipmsg_add_header_now(msg
, "To", newHeader
);
753 /* acknowledge invite */
754 sip_transport_response(sipe_private
, msg
, 200, "OK", NULL
);
756 /* add self to conf */
757 session
= sipe_conf_create(sipe_private
, NULL
, focus_uri
);
758 session
->is_call
= audio
;
763 sipe_process_conference(struct sipe_core_private
*sipe_private
,
766 sipe_xml
*xn_conference_info
;
767 const sipe_xml
*node
;
768 const sipe_xml
*xn_subject
;
769 const gchar
*focus_uri
;
770 struct sip_session
*session
;
771 gboolean just_joined
= FALSE
;
773 gboolean audio_was_added
= FALSE
;
776 if (msg
->response
!= 0 && msg
->response
!= 200) return;
778 if (msg
->bodylen
== 0 || msg
->body
== NULL
|| !sipe_strequal(sipmsg_find_header(msg
, "Event"), "conference")) return;
780 xn_conference_info
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
781 if (!xn_conference_info
) return;
783 focus_uri
= sipe_xml_attribute(xn_conference_info
, "entity");
784 session
= sipe_session_find_conference(sipe_private
, focus_uri
);
787 SIPE_DEBUG_INFO("sipe_process_conference: unable to find conf session with focus=%s", focus_uri
);
791 if (!session
->chat_session
->backend
) {
792 gchar
*self
= sip_uri_self(sipe_private
);
795 session
->chat_session
->backend
= sipe_backend_chat_create(SIPE_CORE_PUBLIC
,
796 session
->chat_session
,
797 session
->chat_session
->title
,
800 /* @TODO ask for full state (re-subscribe) if it was a partial one -
801 * this is to obtain full list of conference participants.
807 if ((xn_subject
= sipe_xml_child(xn_conference_info
, "conference-description/subject"))) {
808 g_free(session
->subject
);
809 session
->subject
= sipe_xml_data(xn_subject
);
810 sipe_backend_chat_topic(session
->chat_session
->backend
, session
->subject
);
811 SIPE_DEBUG_INFO("sipe_process_conference: subject=%s", session
->subject
? session
->subject
: "");
815 if (!session
->im_mcu_uri
) {
816 for (node
= sipe_xml_child(xn_conference_info
, "conference-description/conf-uris/entry");
818 node
= sipe_xml_twin(node
))
820 gchar
*purpose
= sipe_xml_data(sipe_xml_child(node
, "purpose"));
822 if (sipe_strequal("chat", purpose
)) {
824 session
->im_mcu_uri
= sipe_xml_data(sipe_xml_child(node
, "uri"));
825 SIPE_DEBUG_INFO("sipe_process_conference: im_mcu_uri=%s", session
->im_mcu_uri
);
833 for (node
= sipe_xml_child(xn_conference_info
, "users/user"); node
; node
= sipe_xml_twin(node
)) {
834 const gchar
*user_uri
= sipe_xml_attribute(node
, "entity");
835 const gchar
*state
= sipe_xml_attribute(node
, "state");
836 gchar
*role
= sipe_xml_data(sipe_xml_child(node
, "roles/entry"));
837 gboolean is_operator
= sipe_strequal(role
, "presenter");
838 gboolean is_in_im_mcu
= FALSE
;
839 gchar
*self
= sip_uri_self(sipe_private
);
841 if (sipe_strequal("deleted", state
)) {
842 if (sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
843 sipe_backend_chat_remove(session
->chat_session
->backend
,
848 const sipe_xml
*endpoint
;
849 for (endpoint
= sipe_xml_child(node
, "endpoint"); endpoint
; endpoint
= sipe_xml_twin(endpoint
)) {
850 const gchar
*session_type
;
851 gchar
*status
= sipe_xml_data(sipe_xml_child(endpoint
, "status"));
852 gboolean connected
= sipe_strequal("connected", status
);
858 session_type
= sipe_xml_attribute(endpoint
, "session-type");
860 if (sipe_strequal("chat", session_type
)) {
862 if (!sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
863 sipe_backend_chat_add(session
->chat_session
->backend
,
865 !just_joined
&& g_strcasecmp(user_uri
, self
));
868 sipe_backend_chat_operator(session
->chat_session
->backend
,
871 } else if (sipe_strequal("audio-video", session_type
)) {
873 if (!session
->is_call
)
874 audio_was_added
= TRUE
;
879 if (sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
880 sipe_backend_chat_remove(session
->chat_session
->backend
,
890 if (audio_was_added
) {
891 session
->is_call
= TRUE
;
892 sipe_core_media_connect_conference(SIPE_CORE_PUBLIC
,
893 session
->chat_session
, FALSE
);
897 /* entity-view, locked */
898 for (node
= sipe_xml_child(xn_conference_info
, "conference-view/entity-view");
900 node
= sipe_xml_twin(node
)) {
902 const sipe_xml
*xn_type
= sipe_xml_child(node
, "entity-state/media/entry/type");
904 if (xn_type
&& sipe_strequal("chat", (tmp
= sipe_xml_data(xn_type
)))) {
905 const sipe_xml
*xn_locked
= sipe_xml_child(node
, "entity-state/locked");
907 gchar
*locked
= sipe_xml_data(xn_locked
);
908 gboolean prev_locked
= session
->locked
;
909 session
->locked
= sipe_strequal(locked
, "true");
910 if (prev_locked
&& !session
->locked
) {
911 sipe_user_present_info(sipe_private
, session
,
912 _("This conference is no longer locked. Additional participants can now join."));
914 if (!prev_locked
&& session
->locked
) {
915 sipe_user_present_info(sipe_private
, session
,
916 _("This conference is locked. Nobody else can join the conference while it is locked."));
919 SIPE_DEBUG_INFO("sipe_process_conference: session->locked=%s",
920 session
->locked
? "TRUE" : "FALSE");
926 sipe_xml_free(xn_conference_info
);
928 if (session
->im_mcu_uri
) {
929 struct sip_dialog
*dialog
= sipe_dialog_find(session
, session
->im_mcu_uri
);
931 dialog
= sipe_dialog_add(session
);
933 dialog
->callid
= g_strdup(session
->callid
);
934 dialog
->with
= g_strdup(session
->im_mcu_uri
);
936 /* send INVITE to IM MCU */
937 sipe_im_invite(sipe_private
, session
, dialog
->with
, NULL
, NULL
, NULL
, FALSE
);
941 sipe_process_pending_invite_queue(sipe_private
, session
);
945 sipe_conf_immcu_closed(struct sipe_core_private
*sipe_private
,
946 struct sip_session
*session
)
948 sipe_user_present_info(sipe_private
, session
,
949 _("You have been disconnected from this conference."));
950 sipe_backend_chat_close(session
->chat_session
->backend
);
954 conf_session_close(struct sipe_core_private
*sipe_private
,
955 struct sip_session
*session
)
958 /* unsubscribe from focus */
959 sipe_subscribe_conference(sipe_private
, session
, TRUE
);
961 if (session
->focus_dialog
) {
962 /* send BYE to focus */
963 sip_transport_bye(sipe_private
, session
->focus_dialog
);
969 sipe_process_imdn(struct sipe_core_private
*sipe_private
,
972 gchar
*with
= parse_from(sipmsg_find_header(msg
, "From"));
973 const gchar
*callid
= sipmsg_find_header(msg
, "Call-ID");
974 static struct sip_session
*session
;
976 const sipe_xml
*node
;
980 session
= sipe_session_find_chat_or_im(sipe_private
, callid
, with
);
982 SIPE_DEBUG_INFO("sipe_process_imdn: unable to find conf session with callid=%s", callid
);
987 xn_imdn
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
988 message_id
= sipe_xml_data(sipe_xml_child(xn_imdn
, "message-id"));
990 message
= g_hash_table_lookup(session
->conf_unconfirmed_messages
, message_id
);
993 for (node
= sipe_xml_child(xn_imdn
, "recipient"); node
; node
= sipe_xml_twin(node
)) {
994 gchar
*tmp
= parse_from(sipe_xml_attribute(node
, "uri"));
995 gchar
*uri
= parse_from(tmp
);
996 sipe_user_present_message_undelivered(sipe_private
, session
, -1, -1, uri
, message
);
1001 sipe_xml_free(xn_imdn
);
1003 g_hash_table_remove(session
->conf_unconfirmed_messages
, message_id
);
1004 SIPE_DEBUG_INFO("sipe_process_imdn: removed message %s from conf_unconfirmed_messages(count=%d)",
1005 message_id
, g_hash_table_size(session
->conf_unconfirmed_messages
));