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 SIPE_DEBUG_INFO_NOFORMAT("process_invite_conf_focus_response: INVITE response is not 200. Failed to join focus.");
265 /* @TODO notify user of failure to join focus */
266 sipe_session_remove(sipe_private
, session
);
269 } else if (msg
->response
== 200) {
270 sipe_xml
*xn_response
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
271 const gchar
*code
= sipe_xml_attribute(xn_response
, "code");
272 if (sipe_strequal(code
, "success")) {
273 /* subscribe to focus */
274 sipe_subscribe_conference(sipe_private
, session
, FALSE
);
276 if (session
->is_call
)
277 sipe_core_media_connect_conference(SIPE_CORE_PUBLIC
,
278 session
->chat_session
);
281 sipe_xml_free(xn_response
);
288 /** Create new session with Focus URI */
290 sipe_conf_create(struct sipe_core_private
*sipe_private
,
291 struct sipe_chat_session
*chat_session
,
292 const gchar
*focus_uri
)
298 struct sip_session
*session
= sipe_session_add_chat(sipe_private
,
303 session
->focus_dialog
= g_new0(struct sip_dialog
, 1);
304 session
->focus_dialog
->callid
= gencallid();
305 session
->focus_dialog
->with
= g_strdup(session
->chat_session
->id
);
306 session
->focus_dialog
->endpoint_GUID
= rand_guid();
307 session
->focus_dialog
->ourtag
= gentag();
309 contact
= get_contact(sipe_private
);
310 hdr
= g_strdup_printf(
311 "Supported: ms-sender\r\n"
313 "Content-Type: application/cccp+xml\r\n",
317 /* @TODO put request_id to queue to further compare with incoming one */
318 /* focus_URI, from, request_id, focus_URI, from, endpoint_GUID */
319 self
= sip_uri_self(sipe_private
);
320 body
= g_strdup_printf(
321 SIPE_SEND_CONF_ADD_USER
,
322 session
->focus_dialog
->with
,
324 session
->request_id
++,
325 session
->focus_dialog
->with
,
327 session
->focus_dialog
->endpoint_GUID
);
329 session
->focus_dialog
->outgoing_invite
=
330 sip_transport_invite(sipe_private
,
333 session
->focus_dialog
,
334 process_invite_conf_focus_response
);
338 /* Rejoin existing session? */
340 SIPE_DEBUG_INFO("sipe_conf_create: rejoin '%s' (%s)",
343 sipe_backend_chat_rejoin(SIPE_CORE_PUBLIC
,
344 chat_session
->backend
,
346 chat_session
->title
);
353 /** Modify User Role */
355 sipe_conf_modify_user_role(struct sipe_core_private
*sipe_private
,
356 struct sip_session
*session
,
363 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
364 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_modify_user_role: no dialog with focus, exiting.");
369 "Content-Type: application/cccp+xml\r\n");
371 /* @TODO put request_id to queue to further compare with incoming one */
372 self
= sip_uri_self(sipe_private
);
373 body
= g_strdup_printf(
374 SIPE_SEND_CONF_MODIFY_USER_ROLES
,
375 session
->focus_dialog
->with
,
377 session
->request_id
++,
378 session
->focus_dialog
->with
,
382 sip_transport_info(sipe_private
,
385 session
->focus_dialog
,
392 * Check conference lock status
394 sipe_chat_lock_status
sipe_core_chat_lock_status(struct sipe_core_public
*sipe_public
,
395 struct sipe_chat_session
*chat_session
)
397 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
398 sipe_chat_lock_status status
= SIPE_CHAT_LOCK_STATUS_NOT_ALLOWED
;
401 (chat_session
->type
== SIPE_CHAT_TYPE_CONFERENCE
)) {
402 struct sip_session
*session
= sipe_session_find_chat(sipe_private
,
405 gchar
*self
= sip_uri_self(sipe_private
);
407 /* Only operators are allowed to change the lock status */
408 if (sipe_backend_chat_is_operator(chat_session
->backend
, self
)) {
409 status
= session
->locked
?
410 SIPE_CHAT_LOCK_STATUS_LOCKED
:
411 SIPE_CHAT_LOCK_STATUS_UNLOCKED
;
422 * Modify Conference Lock
423 * Sends request to Focus.
424 * INFO method is a carrier of application/cccp+xml
427 sipe_core_chat_modify_lock(struct sipe_core_public
*sipe_public
,
428 struct sipe_chat_session
*chat_session
,
429 const gboolean locked
)
431 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
436 struct sip_session
*session
= sipe_session_find_chat(sipe_private
,
439 if (!session
) return;
440 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
441 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_modify_conference_lock: no dialog with focus, exiting.");
446 "Content-Type: application/cccp+xml\r\n");
448 /* @TODO put request_id to queue to further compare with incoming one */
449 self
= sip_uri_self(sipe_private
);
450 body
= g_strdup_printf(
451 SIPE_SEND_CONF_MODIFY_CONF_LOCK
,
452 session
->focus_dialog
->with
,
454 session
->request_id
++,
455 session
->focus_dialog
->with
,
456 locked
? "true" : "false");
459 sip_transport_info(sipe_private
,
462 session
->focus_dialog
,
468 /** Modify Delete User */
470 sipe_conf_delete_user(struct sipe_core_private
*sipe_private
,
471 struct sip_session
*session
,
478 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
479 SIPE_DEBUG_INFO_NOFORMAT("sipe_conf_delete_user: no dialog with focus, exiting.");
484 "Content-Type: application/cccp+xml\r\n");
486 /* @TODO put request_id to queue to further compare with incoming one */
487 self
= sip_uri_self(sipe_private
);
488 body
= g_strdup_printf(
489 SIPE_SEND_CONF_DELETE_USER
,
490 session
->focus_dialog
->with
,
492 session
->request_id
++,
493 session
->focus_dialog
->with
,
497 sip_transport_info(sipe_private
,
500 session
->focus_dialog
,
506 /** Invite counterparty to join conference callback */
508 process_invite_conf_response(struct sipe_core_private
*sipe_private
,
510 SIPE_UNUSED_PARAMETER
struct transaction
*trans
)
512 struct sip_dialog
*dialog
= g_new0(struct sip_dialog
, 1);
514 dialog
->callid
= g_strdup(sipmsg_find_header(msg
, "Call-ID"));
515 dialog
->cseq
= sipmsg_parse_cseq(msg
);
516 dialog
->with
= parse_from(sipmsg_find_header(msg
, "To"));
517 sipe_dialog_parse(dialog
, msg
, TRUE
);
519 if (msg
->response
>= 200) {
520 /* send ACK to counterparty */
522 sip_transport_ack(sipe_private
, dialog
);
523 dialog
->outgoing_invite
= NULL
;
524 dialog
->is_established
= TRUE
;
527 if (msg
->response
>= 400) {
528 SIPE_DEBUG_INFO("process_invite_conf_response: INVITE response is not 200. Failed to invite %s.", dialog
->with
);
529 /* @TODO notify user of failure to invite counterparty */
530 sipe_dialog_free(dialog
);
534 if (msg
->response
>= 200) {
535 struct sip_session
*session
= sipe_session_find_im(sipe_private
, dialog
->with
);
536 struct sip_dialog
*im_dialog
= sipe_dialog_find(session
, dialog
->with
);
538 /* close IM session to counterparty */
540 sip_transport_bye(sipe_private
, im_dialog
);
541 sipe_dialog_remove(session
, dialog
->with
);
545 sipe_dialog_free(dialog
);
550 * Invites counterparty to join conference.
553 sipe_invite_conf(struct sipe_core_private
*sipe_private
,
554 struct sip_session
*session
,
560 struct sip_dialog
*dialog
= NULL
;
562 /* It will be short lived special dialog.
563 * Will not be stored in session.
565 dialog
= g_new0(struct sip_dialog
, 1);
566 dialog
->callid
= gencallid();
567 dialog
->with
= g_strdup(who
);
568 dialog
->ourtag
= gentag();
570 contact
= get_contact(sipe_private
);
571 hdr
= g_strdup_printf(
572 "Supported: ms-sender\r\n"
574 "Content-Type: application/ms-conf-invite+xml\r\n",
578 body
= g_strdup_printf(
579 SIPE_SEND_CONF_INVITE
,
580 session
->chat_session
->id
,
581 session
->subject
? session
->subject
: ""
584 sip_transport_invite(sipe_private
,
588 process_invite_conf_response
);
590 sipe_dialog_free(dialog
);
595 /** Create conference callback */
597 process_conf_add_response(struct sipe_core_private
*sipe_private
,
599 struct transaction
*trans
)
601 if (msg
->response
>= 400) {
602 SIPE_DEBUG_INFO_NOFORMAT("process_conf_add_response: SERVICE response is not 200. Failed to create conference.");
603 /* @TODO notify user of failure to create conference */
606 if (msg
->response
== 200) {
607 sipe_xml
*xn_response
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
608 if (sipe_strequal("success", sipe_xml_attribute(xn_response
, "code")))
610 gchar
*who
= trans
->payload
->data
;
611 const sipe_xml
*xn_conference_info
= sipe_xml_child(xn_response
, "addConference/conference-info");
612 struct sip_session
*session
= sipe_conf_create(sipe_private
,
614 sipe_xml_attribute(xn_conference_info
,
617 SIPE_DEBUG_INFO("process_conf_add_response: session->focus_uri=%s",
618 session
->chat_session
->id
);
620 session
->pending_invite_queue
= slist_insert_unique_sorted(
621 session
->pending_invite_queue
, g_strdup(who
), (GCompareFunc
)strcmp
);
623 sipe_xml_free(xn_response
);
630 * Creates conference.
633 sipe_conf_add(struct sipe_core_private
*sipe_private
,
637 gchar
*conference_id
;
641 struct transaction
*trans
;
642 struct sip_dialog
*dialog
= NULL
;
643 time_t expiry
= time(NULL
) + 7*60*60; /* 7 hours */
645 struct transaction_payload
*payload
;
647 contact
= get_contact(sipe_private
);
648 hdr
= g_strdup_printf(
649 "Supported: ms-sender\r\n"
651 "Content-Type: application/cccp+xml\r\n",
655 expiry_time
= sipe_utils_time_to_str(expiry
);
656 self
= sip_uri_self(sipe_private
);
657 conference_id
= genconfid();
658 body
= g_strdup_printf(
660 sipe_private
->focus_factory_uri
,
666 g_free(conference_id
);
669 trans
= sip_transport_service(sipe_private
,
670 sipe_private
->focus_factory_uri
,
673 process_conf_add_response
);
675 payload
= g_new0(struct transaction_payload
, 1);
676 payload
->destroy
= g_free
;
677 payload
->data
= g_strdup(who
);
678 trans
->payload
= payload
;
680 sipe_dialog_free(dialog
);
686 process_incoming_invite_conf(struct sipe_core_private
*sipe_private
,
689 sipe_xml
*xn_conferencing
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
690 const sipe_xml
*xn_focus_uri
= sipe_xml_child(xn_conferencing
, "focus-uri");
691 const sipe_xml
*xn_audio
= sipe_xml_child(xn_conferencing
, "audio");
692 gchar
*focus_uri
= sipe_xml_data(xn_focus_uri
);
693 gboolean audio
= sipe_strequal(sipe_xml_attribute(xn_audio
, "available"), "true");
694 gchar
*newTag
= gentag();
695 const gchar
*oldHeader
= sipmsg_find_header(msg
, "To");
697 struct sip_session
*session
;
699 sipe_xml_free(xn_conferencing
);
702 SIPE_DEBUG_INFO("We have received invitation to Conference. Focus URI=%s", focus_uri
);
704 newHeader
= g_strdup_printf("%s;tag=%s", oldHeader
, newTag
);
706 sipmsg_remove_header_now(msg
, "To");
707 sipmsg_add_header_now(msg
, "To", newHeader
);
710 /* acknowledge invite */
711 sip_transport_response(sipe_private
, msg
, 200, "OK", NULL
);
713 /* add self to conf */
714 session
= sipe_conf_create(sipe_private
, NULL
, focus_uri
);
715 session
->is_call
= audio
;
720 sipe_process_conference(struct sipe_core_private
*sipe_private
,
723 sipe_xml
*xn_conference_info
;
724 const sipe_xml
*node
;
725 const sipe_xml
*xn_subject
;
726 const gchar
*focus_uri
;
727 struct sip_session
*session
;
728 gboolean just_joined
= FALSE
;
730 gboolean audio_was_added
= FALSE
;
733 if (msg
->response
!= 0 && msg
->response
!= 200) return;
735 if (msg
->bodylen
== 0 || msg
->body
== NULL
|| !sipe_strequal(sipmsg_find_header(msg
, "Event"), "conference")) return;
737 xn_conference_info
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
738 if (!xn_conference_info
) return;
740 focus_uri
= sipe_xml_attribute(xn_conference_info
, "entity");
741 session
= sipe_session_find_conference(sipe_private
, focus_uri
);
744 SIPE_DEBUG_INFO("sipe_process_conference: unable to find conf session with focus=%s", focus_uri
);
748 if (!session
->chat_session
->backend
) {
749 gchar
*self
= sip_uri_self(sipe_private
);
752 session
->chat_session
->backend
= sipe_backend_chat_create(SIPE_CORE_PUBLIC
,
753 session
->chat_session
,
754 session
->chat_session
->title
,
757 /* @TODO ask for full state (re-subscribe) if it was a partial one -
758 * this is to obtain full list of conference participants.
764 if ((xn_subject
= sipe_xml_child(xn_conference_info
, "conference-description/subject"))) {
765 g_free(session
->subject
);
766 session
->subject
= sipe_xml_data(xn_subject
);
767 sipe_backend_chat_topic(session
->chat_session
->backend
, session
->subject
);
768 SIPE_DEBUG_INFO("sipe_process_conference: subject=%s", session
->subject
? session
->subject
: "");
772 if (!session
->im_mcu_uri
) {
773 for (node
= sipe_xml_child(xn_conference_info
, "conference-description/conf-uris/entry");
775 node
= sipe_xml_twin(node
))
777 gchar
*purpose
= sipe_xml_data(sipe_xml_child(node
, "purpose"));
779 if (sipe_strequal("chat", purpose
)) {
781 session
->im_mcu_uri
= sipe_xml_data(sipe_xml_child(node
, "uri"));
782 SIPE_DEBUG_INFO("sipe_process_conference: im_mcu_uri=%s", session
->im_mcu_uri
);
790 for (node
= sipe_xml_child(xn_conference_info
, "users/user"); node
; node
= sipe_xml_twin(node
)) {
791 const gchar
*user_uri
= sipe_xml_attribute(node
, "entity");
792 const gchar
*state
= sipe_xml_attribute(node
, "state");
793 gchar
*role
= sipe_xml_data(sipe_xml_child(node
, "roles/entry"));
794 gboolean is_operator
= sipe_strequal(role
, "presenter");
795 gboolean is_in_im_mcu
= FALSE
;
796 gchar
*self
= sip_uri_self(sipe_private
);
798 if (sipe_strequal("deleted", state
)) {
799 if (sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
800 sipe_backend_chat_remove(session
->chat_session
->backend
,
805 const sipe_xml
*endpoint
;
806 for (endpoint
= sipe_xml_child(node
, "endpoint"); endpoint
; endpoint
= sipe_xml_twin(endpoint
)) {
807 const gchar
*session_type
;
808 gchar
*status
= sipe_xml_data(sipe_xml_child(endpoint
, "status"));
809 gboolean connected
= sipe_strequal("connected", status
);
815 session_type
= sipe_xml_attribute(endpoint
, "session-type");
817 if (sipe_strequal("chat", session_type
)) {
819 if (!sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
820 sipe_backend_chat_add(session
->chat_session
->backend
,
822 !just_joined
&& g_strcasecmp(user_uri
, self
));
825 sipe_backend_chat_operator(session
->chat_session
->backend
,
828 } else if (sipe_strequal("audio-video", session_type
)) {
830 if (!session
->is_call
)
831 audio_was_added
= TRUE
;
836 if (sipe_backend_chat_find(session
->chat_session
->backend
, user_uri
)) {
837 sipe_backend_chat_remove(session
->chat_session
->backend
,
847 if (audio_was_added
) {
848 session
->is_call
= TRUE
;
849 sipe_core_media_connect_conference(SIPE_CORE_PUBLIC
,
850 session
->chat_session
);
854 /* entity-view, locked */
855 for (node
= sipe_xml_child(xn_conference_info
, "conference-view/entity-view");
857 node
= sipe_xml_twin(node
)) {
859 const sipe_xml
*xn_type
= sipe_xml_child(node
, "entity-state/media/entry/type");
861 if (xn_type
&& sipe_strequal("chat", (tmp
= sipe_xml_data(xn_type
)))) {
862 const sipe_xml
*xn_locked
= sipe_xml_child(node
, "entity-state/locked");
864 gchar
*locked
= sipe_xml_data(xn_locked
);
865 gboolean prev_locked
= session
->locked
;
866 session
->locked
= sipe_strequal(locked
, "true");
867 if (prev_locked
&& !session
->locked
) {
868 sipe_user_present_info(sipe_private
, session
,
869 _("This conference is no longer locked. Additional participants can now join."));
871 if (!prev_locked
&& session
->locked
) {
872 sipe_user_present_info(sipe_private
, session
,
873 _("This conference is locked. Nobody else can join the conference while it is locked."));
876 SIPE_DEBUG_INFO("sipe_process_conference: session->locked=%s",
877 session
->locked
? "TRUE" : "FALSE");
883 sipe_xml_free(xn_conference_info
);
885 if (session
->im_mcu_uri
) {
886 struct sip_dialog
*dialog
= sipe_dialog_find(session
, session
->im_mcu_uri
);
888 dialog
= sipe_dialog_add(session
);
890 dialog
->callid
= g_strdup(session
->callid
);
891 dialog
->with
= g_strdup(session
->im_mcu_uri
);
893 /* send INVITE to IM MCU */
894 sipe_im_invite(sipe_private
, session
, dialog
->with
, NULL
, NULL
, NULL
, FALSE
);
898 sipe_process_pending_invite_queue(sipe_private
, session
);
902 sipe_conf_immcu_closed(struct sipe_core_private
*sipe_private
,
903 struct sip_session
*session
)
905 sipe_user_present_info(sipe_private
, session
,
906 _("You have been disconnected from this conference."));
907 sipe_backend_chat_close(session
->chat_session
->backend
);
911 conf_session_close(struct sipe_core_private
*sipe_private
,
912 struct sip_session
*session
)
915 /* unsubscribe from focus */
916 sipe_subscribe_conference(sipe_private
, session
, TRUE
);
918 if (session
->focus_dialog
) {
919 /* send BYE to focus */
920 sip_transport_bye(sipe_private
, session
->focus_dialog
);
926 sipe_process_imdn(struct sipe_core_private
*sipe_private
,
929 gchar
*with
= parse_from(sipmsg_find_header(msg
, "From"));
930 const gchar
*callid
= sipmsg_find_header(msg
, "Call-ID");
931 static struct sip_session
*session
;
933 const sipe_xml
*node
;
937 session
= sipe_session_find_chat_or_im(sipe_private
, callid
, with
);
939 SIPE_DEBUG_INFO("sipe_process_imdn: unable to find conf session with callid=%s", callid
);
944 xn_imdn
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
945 message_id
= sipe_xml_data(sipe_xml_child(xn_imdn
, "message-id"));
947 message
= g_hash_table_lookup(session
->conf_unconfirmed_messages
, message_id
);
950 for (node
= sipe_xml_child(xn_imdn
, "recipient"); node
; node
= sipe_xml_twin(node
)) {
951 gchar
*tmp
= parse_from(sipe_xml_attribute(node
, "uri"));
952 gchar
*uri
= parse_from(tmp
);
953 sipe_user_present_message_undelivered(sipe_private
, session
, -1, -1, uri
, message
);
958 sipe_xml_free(xn_imdn
);
960 g_hash_table_remove(session
->conf_unconfirmed_messages
, message_id
);
961 SIPE_DEBUG_INFO("sipe_process_imdn: removed message %s from conf_unconfirmed_messages(count=%d)",
962 message_id
, g_hash_table_size(session
->conf_unconfirmed_messages
));