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
);
286 sipe_xml_free(xn_response
);
294 sipe_core_conf_create(struct sipe_core_public
*sipe_public
,
295 const gchar
*focus_uri
)
298 const gchar
*focus_uri_ue
;
299 struct sip_session
*session
= NULL
;
301 focus_uri_ue
= buf
= sipe_utils_uri_unescape(focus_uri
);
303 // URI can have this prefix if it was typed in by the user
304 if (g_str_has_prefix(focus_uri_ue
, "meet:"))
307 if (!focus_uri_ue
|| !g_str_has_prefix(focus_uri_ue
, "sip:") ||
308 strlen(focus_uri_ue
) == 4 || g_strstr_len(focus_uri_ue
, -1, "%")) {
309 gchar
*error
= g_strdup_printf(_("\"%s\" is not a valid focus URI"),
310 focus_uri
? focus_uri
: "");
311 sipe_backend_notify_error(_("Failed to join the conference"),
315 gchar
*querystr
= g_strstr_len(focus_uri_ue
, -1, "?");
317 /* TODO: Investigate how conf-key field should be used,
318 * ignoring for now */
322 session
= sipe_conf_create(SIPE_CORE_PRIVATE
, NULL
, focus_uri_ue
);
330 /** Create new session with Focus URI */
332 sipe_conf_create(struct sipe_core_private
*sipe_private
,
333 struct sipe_chat_session
*chat_session
,
334 const gchar
*focus_uri
)
340 struct sip_session
*session
= sipe_session_add_chat(sipe_private
,
345 session
->focus_dialog
= g_new0(struct sip_dialog
, 1);
346 session
->focus_dialog
->callid
= gencallid();
347 session
->focus_dialog
->with
= g_strdup(session
->chat_session
->id
);
348 session
->focus_dialog
->endpoint_GUID
= rand_guid();
349 session
->focus_dialog
->ourtag
= gentag();
351 contact
= get_contact(sipe_private
);
352 hdr
= g_strdup_printf(
353 "Supported: ms-sender\r\n"
355 "Content-Type: application/cccp+xml\r\n",
359 /* @TODO put request_id to queue to further compare with incoming one */
360 /* focus_URI, from, request_id, focus_URI, from, endpoint_GUID */
361 self
= sip_uri_self(sipe_private
);
362 body
= g_strdup_printf(
363 SIPE_SEND_CONF_ADD_USER
,
364 session
->focus_dialog
->with
,
366 session
->request_id
++,
367 session
->focus_dialog
->with
,
369 session
->focus_dialog
->endpoint_GUID
);
371 session
->focus_dialog
->outgoing_invite
=
372 sip_transport_invite(sipe_private
,
375 session
->focus_dialog
,
376 process_invite_conf_focus_response
);
380 /* Rejoin existing session? */
382 SIPE_DEBUG_INFO("sipe_conf_create: rejoin '%s' (%s)",
385 sipe_backend_chat_rejoin(SIPE_CORE_PUBLIC
,
386 chat_session
->backend
,
388 chat_session
->title
);
395 /** Modify User Role */
397 sipe_conf_modify_user_role(struct sipe_core_private
*sipe_private
,
398 struct sip_session
*session
,
405 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
406 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_modify_user_role: no dialog with focus, exiting.");
411 "Content-Type: application/cccp+xml\r\n");
413 /* @TODO put request_id to queue to further compare with incoming one */
414 self
= sip_uri_self(sipe_private
);
415 body
= g_strdup_printf(
416 SIPE_SEND_CONF_MODIFY_USER_ROLES
,
417 session
->focus_dialog
->with
,
419 session
->request_id
++,
420 session
->focus_dialog
->with
,
424 sip_transport_info(sipe_private
,
427 session
->focus_dialog
,
434 * Check conference lock status
436 sipe_chat_lock_status
sipe_core_chat_lock_status(struct sipe_core_public
*sipe_public
,
437 struct sipe_chat_session
*chat_session
)
439 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
440 sipe_chat_lock_status status
= SIPE_CHAT_LOCK_STATUS_NOT_ALLOWED
;
443 (chat_session
->type
== SIPE_CHAT_TYPE_CONFERENCE
)) {
444 struct sip_session
*session
= sipe_session_find_chat(sipe_private
,
447 gchar
*self
= sip_uri_self(sipe_private
);
449 /* Only operators are allowed to change the lock status */
450 if (sipe_backend_chat_is_operator(chat_session
->backend
, self
)) {
451 status
= session
->locked
?
452 SIPE_CHAT_LOCK_STATUS_LOCKED
:
453 SIPE_CHAT_LOCK_STATUS_UNLOCKED
;
464 * Modify Conference Lock
465 * Sends request to Focus.
466 * INFO method is a carrier of application/cccp+xml
469 sipe_core_chat_modify_lock(struct sipe_core_public
*sipe_public
,
470 struct sipe_chat_session
*chat_session
,
471 const gboolean locked
)
473 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
478 struct sip_session
*session
= sipe_session_find_chat(sipe_private
,
481 if (!session
) return;
482 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
483 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_modify_conference_lock: no dialog with focus, exiting.");
488 "Content-Type: application/cccp+xml\r\n");
490 /* @TODO put request_id to queue to further compare with incoming one */
491 self
= sip_uri_self(sipe_private
);
492 body
= g_strdup_printf(
493 SIPE_SEND_CONF_MODIFY_CONF_LOCK
,
494 session
->focus_dialog
->with
,
496 session
->request_id
++,
497 session
->focus_dialog
->with
,
498 locked
? "true" : "false");
501 sip_transport_info(sipe_private
,
504 session
->focus_dialog
,
510 /** Modify Delete User */
512 sipe_conf_delete_user(struct sipe_core_private
*sipe_private
,
513 struct sip_session
*session
,
520 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
521 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_delete_user: no dialog with focus, exiting.");
526 "Content-Type: application/cccp+xml\r\n");
528 /* @TODO put request_id to queue to further compare with incoming one */
529 self
= sip_uri_self(sipe_private
);
530 body
= g_strdup_printf(
531 SIPE_SEND_CONF_DELETE_USER
,
532 session
->focus_dialog
->with
,
534 session
->request_id
++,
535 session
->focus_dialog
->with
,
539 sip_transport_info(sipe_private
,
542 session
->focus_dialog
,
548 /** Invite counterparty to join conference callback */
550 process_invite_conf_response(struct sipe_core_private
*sipe_private
,
552 SIPE_UNUSED_PARAMETER
struct transaction
*trans
)
554 struct sip_dialog
*dialog
= g_new0(struct sip_dialog
, 1);
556 dialog
->callid
= g_strdup(sipmsg_find_header(msg
, "Call-ID"));
557 dialog
->cseq
= sipmsg_parse_cseq(msg
);
558 dialog
->with
= parse_from(sipmsg_find_header(msg
, "To"));
559 sipe_dialog_parse(dialog
, msg
, TRUE
);
561 if (msg
->response
>= 200) {
562 /* send ACK to counterparty */
564 sip_transport_ack(sipe_private
, dialog
);
565 dialog
->outgoing_invite
= NULL
;
566 dialog
->is_established
= TRUE
;
569 if (msg
->response
>= 400) {
570 SIPE_DEBUG_INFO("process_invite_conf_response: INVITE response is not 200. Failed to invite %s.", dialog
->with
);
571 /* @TODO notify user of failure to invite counterparty */
572 sipe_dialog_free(dialog
);
576 if (msg
->response
>= 200) {
577 struct sip_session
*session
= sipe_session_find_im(sipe_private
, dialog
->with
);
578 struct sip_dialog
*im_dialog
= sipe_dialog_find(session
, dialog
->with
);
580 /* close IM session to counterparty */
582 sip_transport_bye(sipe_private
, im_dialog
);
583 sipe_dialog_remove(session
, dialog
->with
);
587 sipe_dialog_free(dialog
);
592 * Invites counterparty to join conference.
595 sipe_invite_conf(struct sipe_core_private
*sipe_private
,
596 struct sip_session
*session
,
602 struct sip_dialog
*dialog
= NULL
;
604 /* It will be short lived special dialog.
605 * Will not be stored in session.
607 dialog
= g_new0(struct sip_dialog
, 1);
608 dialog
->callid
= gencallid();
609 dialog
->with
= g_strdup(who
);
610 dialog
->ourtag
= gentag();
612 contact
= get_contact(sipe_private
);
613 hdr
= g_strdup_printf(
614 "Supported: ms-sender\r\n"
616 "Content-Type: application/ms-conf-invite+xml\r\n",
620 body
= g_strdup_printf(
621 SIPE_SEND_CONF_INVITE
,
622 session
->chat_session
->id
,
623 session
->subject
? session
->subject
: ""
626 sip_transport_invite(sipe_private
,
630 process_invite_conf_response
);
632 sipe_dialog_free(dialog
);
637 /** Create conference callback */
639 process_conf_add_response(struct sipe_core_private
*sipe_private
,
641 struct transaction
*trans
)
643 if (msg
->response
>= 400) {
644 SIPE_DEBUG_INFO_NOFORMAT("process_conf_add_response: SERVICE response is not 200. Failed to create conference.");
645 /* @TODO notify user of failure to create conference */
648 if (msg
->response
== 200) {
649 sipe_xml
*xn_response
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
650 if (sipe_strequal("success", sipe_xml_attribute(xn_response
, "code")))
652 gchar
*who
= trans
->payload
->data
;
653 const sipe_xml
*xn_conference_info
= sipe_xml_child(xn_response
, "addConference/conference-info");
654 struct sip_session
*session
= sipe_conf_create(sipe_private
,
656 sipe_xml_attribute(xn_conference_info
,
659 SIPE_DEBUG_INFO("process_conf_add_response: session->focus_uri=%s",
660 session
->chat_session
->id
);
662 session
->pending_invite_queue
= slist_insert_unique_sorted(
663 session
->pending_invite_queue
, g_strdup(who
), (GCompareFunc
)strcmp
);
665 sipe_xml_free(xn_response
);
672 * Creates conference.
675 sipe_conf_add(struct sipe_core_private
*sipe_private
,
679 gchar
*conference_id
;
683 struct transaction
*trans
;
684 struct sip_dialog
*dialog
= NULL
;
685 time_t expiry
= time(NULL
) + 7*60*60; /* 7 hours */
687 struct transaction_payload
*payload
;
689 contact
= get_contact(sipe_private
);
690 hdr
= g_strdup_printf(
691 "Supported: ms-sender\r\n"
693 "Content-Type: application/cccp+xml\r\n",
697 expiry_time
= sipe_utils_time_to_str(expiry
);
698 self
= sip_uri_self(sipe_private
);
699 conference_id
= genconfid();
700 body
= g_strdup_printf(
702 sipe_private
->focus_factory_uri
,
708 g_free(conference_id
);
711 trans
= sip_transport_service(sipe_private
,
712 sipe_private
->focus_factory_uri
,
715 process_conf_add_response
);
717 payload
= g_new0(struct transaction_payload
, 1);
718 payload
->destroy
= g_free
;
719 payload
->data
= g_strdup(who
);
720 trans
->payload
= payload
;
722 sipe_dialog_free(dialog
);
728 process_incoming_invite_conf(struct sipe_core_private
*sipe_private
,
731 sipe_xml
*xn_conferencing
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
732 const sipe_xml
*xn_focus_uri
= sipe_xml_child(xn_conferencing
, "focus-uri");
733 const sipe_xml
*xn_audio
= sipe_xml_child(xn_conferencing
, "audio");
734 gchar
*focus_uri
= sipe_xml_data(xn_focus_uri
);
735 gboolean audio
= sipe_strequal(sipe_xml_attribute(xn_audio
, "available"), "true");
736 gchar
*newTag
= gentag();
737 const gchar
*oldHeader
= sipmsg_find_header(msg
, "To");
739 struct sip_session
*session
;
741 sipe_xml_free(xn_conferencing
);
744 SIPE_DEBUG_INFO("We have received invitation to Conference. Focus URI=%s", focus_uri
);
746 newHeader
= g_strdup_printf("%s;tag=%s", oldHeader
, newTag
);
748 sipmsg_remove_header_now(msg
, "To");
749 sipmsg_add_header_now(msg
, "To", newHeader
);
752 /* acknowledge invite */
753 sip_transport_response(sipe_private
, msg
, 200, "OK", NULL
);
755 /* add self to conf */
756 session
= sipe_conf_create(sipe_private
, NULL
, focus_uri
);
757 session
->is_call
= audio
;
762 sipe_process_conference(struct sipe_core_private
*sipe_private
,
765 sipe_xml
*xn_conference_info
;
766 const sipe_xml
*node
;
767 const sipe_xml
*xn_subject
;
768 const gchar
*focus_uri
;
769 struct sip_session
*session
;
770 gboolean just_joined
= FALSE
;
772 gboolean audio_was_added
= FALSE
;
775 if (msg
->response
!= 0 && msg
->response
!= 200) return;
777 if (msg
->bodylen
== 0 || msg
->body
== NULL
|| !sipe_strequal(sipmsg_find_header(msg
, "Event"), "conference")) return;
779 xn_conference_info
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
780 if (!xn_conference_info
) return;
782 focus_uri
= sipe_xml_attribute(xn_conference_info
, "entity");
783 session
= sipe_session_find_conference(sipe_private
, focus_uri
);
786 SIPE_DEBUG_INFO("sipe_process_conference: unable to find conf session with focus=%s", focus_uri
);
790 if (!session
->chat_session
->backend
) {
791 gchar
*self
= sip_uri_self(sipe_private
);
794 session
->chat_session
->backend
= sipe_backend_chat_create(SIPE_CORE_PUBLIC
,
795 session
->chat_session
,
796 session
->chat_session
->title
,
799 /* @TODO ask for full state (re-subscribe) if it was a partial one -
800 * this is to obtain full list of conference participants.
806 if ((xn_subject
= sipe_xml_child(xn_conference_info
, "conference-description/subject"))) {
807 g_free(session
->subject
);
808 session
->subject
= sipe_xml_data(xn_subject
);
809 sipe_backend_chat_topic(session
->chat_session
->backend
, session
->subject
);
810 SIPE_DEBUG_INFO("sipe_process_conference: subject=%s", session
->subject
? session
->subject
: "");
814 if (!session
->im_mcu_uri
) {
815 for (node
= sipe_xml_child(xn_conference_info
, "conference-description/conf-uris/entry");
817 node
= sipe_xml_twin(node
))
819 gchar
*purpose
= sipe_xml_data(sipe_xml_child(node
, "purpose"));
821 if (sipe_strequal("chat", purpose
)) {
823 session
->im_mcu_uri
= sipe_xml_data(sipe_xml_child(node
, "uri"));
824 SIPE_DEBUG_INFO("sipe_process_conference: im_mcu_uri=%s", session
->im_mcu_uri
);
832 for (node
= sipe_xml_child(xn_conference_info
, "users/user"); node
; node
= sipe_xml_twin(node
)) {
833 const gchar
*user_uri
= sipe_xml_attribute(node
, "entity");
834 const gchar
*state
= sipe_xml_attribute(node
, "state");
835 gchar
*role
= sipe_xml_data(sipe_xml_child(node
, "roles/entry"));
836 gboolean is_operator
= sipe_strequal(role
, "presenter");
837 gboolean is_in_im_mcu
= FALSE
;
838 gchar
*self
= sip_uri_self(sipe_private
);
840 if (sipe_strequal("deleted", state
)) {
841 if (sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
842 sipe_backend_chat_remove(session
->chat_session
->backend
,
847 const sipe_xml
*endpoint
;
848 for (endpoint
= sipe_xml_child(node
, "endpoint"); endpoint
; endpoint
= sipe_xml_twin(endpoint
)) {
849 const gchar
*session_type
;
850 gchar
*status
= sipe_xml_data(sipe_xml_child(endpoint
, "status"));
851 gboolean connected
= sipe_strequal("connected", status
);
857 session_type
= sipe_xml_attribute(endpoint
, "session-type");
859 if (sipe_strequal("chat", session_type
)) {
861 if (!sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
862 sipe_backend_chat_add(session
->chat_session
->backend
,
864 !just_joined
&& g_strcasecmp(user_uri
, self
));
867 sipe_backend_chat_operator(session
->chat_session
->backend
,
870 } else if (sipe_strequal("audio-video", session_type
)) {
872 if (!session
->is_call
)
873 audio_was_added
= TRUE
;
878 if (sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
879 sipe_backend_chat_remove(session
->chat_session
->backend
,
889 if (audio_was_added
) {
890 session
->is_call
= TRUE
;
891 sipe_core_media_connect_conference(SIPE_CORE_PUBLIC
,
892 session
->chat_session
);
896 /* entity-view, locked */
897 for (node
= sipe_xml_child(xn_conference_info
, "conference-view/entity-view");
899 node
= sipe_xml_twin(node
)) {
901 const sipe_xml
*xn_type
= sipe_xml_child(node
, "entity-state/media/entry/type");
903 if (xn_type
&& sipe_strequal("chat", (tmp
= sipe_xml_data(xn_type
)))) {
904 const sipe_xml
*xn_locked
= sipe_xml_child(node
, "entity-state/locked");
906 gchar
*locked
= sipe_xml_data(xn_locked
);
907 gboolean prev_locked
= session
->locked
;
908 session
->locked
= sipe_strequal(locked
, "true");
909 if (prev_locked
&& !session
->locked
) {
910 sipe_user_present_info(sipe_private
, session
,
911 _("This conference is no longer locked. Additional participants can now join."));
913 if (!prev_locked
&& session
->locked
) {
914 sipe_user_present_info(sipe_private
, session
,
915 _("This conference is locked. Nobody else can join the conference while it is locked."));
918 SIPE_DEBUG_INFO("sipe_process_conference: session->locked=%s",
919 session
->locked
? "TRUE" : "FALSE");
925 sipe_xml_free(xn_conference_info
);
927 if (session
->im_mcu_uri
) {
928 struct sip_dialog
*dialog
= sipe_dialog_find(session
, session
->im_mcu_uri
);
930 dialog
= sipe_dialog_add(session
);
932 dialog
->callid
= g_strdup(session
->callid
);
933 dialog
->with
= g_strdup(session
->im_mcu_uri
);
935 /* send INVITE to IM MCU */
936 sipe_im_invite(sipe_private
, session
, dialog
->with
, NULL
, NULL
, NULL
, FALSE
);
940 sipe_process_pending_invite_queue(sipe_private
, session
);
944 sipe_conf_immcu_closed(struct sipe_core_private
*sipe_private
,
945 struct sip_session
*session
)
947 sipe_user_present_info(sipe_private
, session
,
948 _("You have been disconnected from this conference."));
949 sipe_backend_chat_close(session
->chat_session
->backend
);
953 conf_session_close(struct sipe_core_private
*sipe_private
,
954 struct sip_session
*session
)
957 /* unsubscribe from focus */
958 sipe_subscribe_conference(sipe_private
, session
, TRUE
);
960 if (session
->focus_dialog
) {
961 /* send BYE to focus */
962 sip_transport_bye(sipe_private
, session
->focus_dialog
);
968 sipe_process_imdn(struct sipe_core_private
*sipe_private
,
971 gchar
*with
= parse_from(sipmsg_find_header(msg
, "From"));
972 const gchar
*callid
= sipmsg_find_header(msg
, "Call-ID");
973 static struct sip_session
*session
;
975 const sipe_xml
*node
;
979 session
= sipe_session_find_chat_or_im(sipe_private
, callid
, with
);
981 SIPE_DEBUG_INFO("sipe_process_imdn: unable to find conf session with callid=%s", callid
);
986 xn_imdn
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
987 message_id
= sipe_xml_data(sipe_xml_child(xn_imdn
, "message-id"));
989 message
= g_hash_table_lookup(session
->conf_unconfirmed_messages
, message_id
);
992 for (node
= sipe_xml_child(xn_imdn
, "recipient"); node
; node
= sipe_xml_twin(node
)) {
993 gchar
*tmp
= parse_from(sipe_xml_attribute(node
, "uri"));
994 gchar
*uri
= parse_from(tmp
);
995 sipe_user_present_message_undelivered(sipe_private
, session
, -1, -1, uri
, message
);
1000 sipe_xml_free(xn_imdn
);
1002 g_hash_table_remove(session
->conf_unconfirmed_messages
, message_id
);
1003 SIPE_DEBUG_INFO("sipe_process_imdn: removed message %s from conf_unconfirmed_messages(count=%d)",
1004 message_id
, g_hash_table_size(session
->conf_unconfirmed_messages
));