6 * Copyright (C) 2009 pier11 <pier11@operamail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include "conversation.h"
39 #include "sipe-chat.h"
40 #include "sipe-conf.h"
41 #include "sipe-dialog.h"
43 #include "sipe-session.h"
44 #include "sipe-utils.h"
48 * Add Conference request to FocusFactory.
49 * @param focus_factory_uri (%s) Ex.: sip:bob7@boston.local;gruu;opaque=app:conf:focusfactory
50 * @param from (%s) Ex.: sip:bob7@boston.local
51 * @param request_id (%d) Ex.: 1094520
52 * @param conference_id (%s) Ex.: 8386E6AEAAA41E4AA6627BA76D43B6D1
53 * @param expiry_time (%s) Ex.: 2009-07-13T17:57:09Z , Default duration: 7 hours
55 #define SIPE_SEND_CONF_ADD \
56 "<?xml version=\"1.0\"?>"\
57 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" "\
58 "xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
64 "<ci:conference-info xmlns:ci=\"urn:ietf:params:xml:ns:conference-info\" entity=\"\" xmlns:msci=\"http://schemas.microsoft.com/rtc/2005/08/confinfoextensions\">"\
65 "<ci:conference-description>"\
67 "<msci:conference-id>%s</msci:conference-id>"\
68 "<msci:expiry-time>%s</msci:expiry-time>"\
69 "<msci:admission-policy>openAuthenticated</msci:admission-policy>"\
70 "</ci:conference-description>"\
71 "<msci:conference-view>"\
72 "<msci:entity-view entity=\"chat\"/>"\
73 "</msci:conference-view>"\
74 "</ci:conference-info>"\
79 * AddUser request to Focus.
81 * focus_URI, from, request_id, focus_URI, from, endpoint_GUID
83 #define SIPE_SEND_CONF_ADD_USER \
84 "<?xml version=\"1.0\"?>"\
85 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
91 "<conferenceKeys confEntity=\"%s\"/>"\
92 "<ci:user xmlns:ci=\"urn:ietf:params:xml:ns:conference-info\" entity=\"%s\">"\
94 "<ci:entry>attendee</ci:entry>"\
96 "<ci:endpoint entity=\"{%s}\" xmlns:msci=\"http://schemas.microsoft.com/rtc/2005/08/confinfoextensions\"/>"\
102 * ModifyUserRoles request to Focus. Makes user a leader.
103 * @param focus_uri (%s)
105 * @param request_id (%d)
106 * @param focus_uri (%s)
109 #define SIPE_SEND_CONF_MODIFY_USER_ROLES \
110 "<?xml version=\"1.0\"?>"\
111 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
117 "<userKeys confEntity=\"%s\" userEntity=\"%s\"/>"\
118 "<user-roles xmlns=\"urn:ietf:params:xml:ns:conference-info\">"\
119 "<entry>presenter</entry>"\
121 "</modifyUserRoles>"\
125 * ModifyConferenceLock request to Focus. Locks/unlocks conference.
126 * @param focus_uri (%s)
128 * @param request_id (%d)
129 * @param focus_uri (%s)
130 * @param locked (%s) "true" or "false" values applicable
132 #define SIPE_SEND_CONF_MODIFY_CONF_LOCK \
133 "<?xml version=\"1.0\"?>"\
134 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
139 "<modifyConferenceLock>"\
140 "<conferenceKeys confEntity=\"%s\"/>"\
141 "<locked>%s</locked>"\
142 "</modifyConferenceLock>"\
146 * ModifyConferenceLock request to Focus. Locks/unlocks conference.
147 * @param focus_uri (%s)
149 * @param request_id (%d)
150 * @param focus_uri (%s)
153 #define SIPE_SEND_CONF_DELETE_USER \
154 "<?xml version=\"1.0\"?>"\
155 "<request xmlns=\"urn:ietf:params:xml:ns:cccp\" xmlns:mscp=\"http://schemas.microsoft.com/rtc/2005/08/cccpextensions\" "\
161 "<userKeys confEntity=\"%s\" userEntity=\"%s\"/>"\
166 * Invite counterparty to join conference.
167 * @param focus_uri (%s)
168 * @param subject (%s) of conference
170 #define SIPE_SEND_CONF_INVITE \
171 "<Conferencing version=\"2.0\">"\
172 "<focus-uri>%s</focus-uri>"\
173 "<subject>%s</subject>"\
174 "<im available=\"true\">"\
180 * Generates random GUID.
181 * This method is borrowed from pidgin's msnutils.c
186 return g_strdup_printf("%4X%4X-%4X-%4X-%4X-%4X%4X%4X",
187 rand() % 0xAAFF + 0x1111,
188 rand() % 0xAAFF + 0x1111,
189 rand() % 0xAAFF + 0x1111,
190 rand() % 0xAAFF + 0x1111,
191 rand() % 0xAAFF + 0x1111,
192 rand() % 0xAAFF + 0x1111,
193 rand() % 0xAAFF + 0x1111,
194 rand() % 0xAAFF + 0x1111);
198 * @param expires not respected if set to negative value (E.g. -1)
201 sipe_subscribe_conference(struct sipe_account_data
*sip
,
202 struct sip_session
*session
,
205 gchar
*expires_hdr
= (expires
>= 0) ? g_strdup_printf("Expires: %d\r\n", expires
) : g_strdup("");
206 gchar
*contact
= get_contact(sip
);
207 gchar
*hdr
= g_strdup_printf(
208 "Event: conference\r\n"
210 "Accept: application/conference-info+xml\r\n"
211 "Supported: com.microsoft.autoextend\r\n"
212 "Supported: ms-benotify\r\n"
213 "Proxy-Require: ms-benotify\r\n"
214 "Supported: ms-piggyback-first-notify\r\n"
221 send_sip_request(sip
->gc
,
228 process_subscribe_response
);
232 /** Invite us to the focus callback */
234 process_invite_conf_focus_response(struct sipe_account_data
*sip
,
236 SIPE_UNUSED_PARAMETER
struct transaction
*trans
)
238 struct sip_session
*session
= NULL
;
239 char *focus_uri
= parse_from(sipmsg_find_header(msg
, "To"));
241 session
= sipe_session_find_conference(sip
, focus_uri
);
244 purple_debug_info("sipe", "process_invite_conf_focus_response: unable to find conf session with focus=%s\n", focus_uri
);
249 if (!session
->focus_dialog
) {
250 purple_debug_info("sipe", "process_invite_conf_focus_response: session's focus_dialog is NULL\n");
255 sipe_dialog_parse(session
->focus_dialog
, msg
, TRUE
);
257 if (msg
->response
>= 200) {
258 /* send ACK to focus */
259 session
->focus_dialog
->cseq
= 0;
260 send_sip_request(sip
->gc
, "ACK", session
->focus_dialog
->with
, session
->focus_dialog
->with
, NULL
, NULL
, session
->focus_dialog
, NULL
);
261 session
->focus_dialog
->outgoing_invite
= NULL
;
262 session
->focus_dialog
->is_established
= TRUE
;
265 if (msg
->response
>= 400) {
266 purple_debug_info("sipe", "process_invite_conf_focus_response: INVITE response is not 200. Failed to join focus.\n");
267 /* @TODO notify user of failure to join focus */
268 sipe_session_remove(sip
, session
);
271 } else if (msg
->response
== 200) {
272 xmlnode
*xn_response
= xmlnode_from_str(msg
->body
, msg
->bodylen
);
273 const gchar
*code
= xmlnode_get_attrib(xn_response
, "code");
274 if (sipe_strequal(code
, "success")) {
275 /* subscribe to focus */
276 sipe_subscribe_conference(sip
, session
, -1);
278 xmlnode_free(xn_response
);
285 /** Invite us to the focus */
287 sipe_invite_conf_focus(struct sipe_account_data
*sip
,
288 struct sip_session
*session
)
295 if (session
->focus_dialog
&& session
->focus_dialog
->is_established
) {
296 purple_debug_info("sipe", "session with %s already has a dialog open\n", session
->focus_uri
);
300 if(!session
->focus_dialog
) {
301 session
->focus_dialog
= g_new0(struct sip_dialog
, 1);
302 session
->focus_dialog
->callid
= gencallid();
303 session
->focus_dialog
->with
= g_strdup(session
->focus_uri
);
304 session
->focus_dialog
->endpoint_GUID
= rand_guid();
306 if (!(session
->focus_dialog
->ourtag
)) {
307 session
->focus_dialog
->ourtag
= gentag();
310 contact
= get_contact(sip
);
311 hdr
= g_strdup_printf(
312 "Supported: ms-sender\r\n"
314 "Content-Type: application/cccp+xml\r\n",
318 /* @TODO put request_id to queue to further compare with incoming one */
319 /* focus_URI, from, request_id, focus_URI, from, endpoint_GUID */
320 self
= sip_uri_self(sip
);
321 body
= g_strdup_printf(
322 SIPE_SEND_CONF_ADD_USER
,
323 session
->focus_dialog
->with
,
325 session
->request_id
++,
326 session
->focus_dialog
->with
,
328 session
->focus_dialog
->endpoint_GUID
);
331 session
->focus_dialog
->outgoing_invite
= send_sip_request(sip
->gc
,
333 session
->focus_dialog
->with
,
334 session
->focus_dialog
->with
,
337 session
->focus_dialog
,
338 process_invite_conf_focus_response
);
343 /** Modify User Role */
345 sipe_conf_modify_user_role(struct sipe_account_data
*sip
,
346 struct sip_session
*session
,
353 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
354 purple_debug_info("sipe", "sipe_conf_modify_user_role: no dialog with focus, exiting.\n");
359 "Content-Type: application/cccp+xml\r\n");
361 /* @TODO put request_id to queue to further compare with incoming one */
362 self
= sip_uri_self(sip
);
363 body
= g_strdup_printf(
364 SIPE_SEND_CONF_MODIFY_USER_ROLES
,
365 session
->focus_dialog
->with
,
367 session
->request_id
++,
368 session
->focus_dialog
->with
,
372 send_sip_request(sip
->gc
,
374 session
->focus_dialog
->with
,
375 session
->focus_dialog
->with
,
378 session
->focus_dialog
,
384 /** Modify Conference Lock */
386 sipe_conf_modify_conference_lock(struct sipe_account_data
*sip
,
387 struct sip_session
*session
,
388 const gboolean locked
)
394 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
395 purple_debug_info("sipe", "sipe_conf_modify_conference_lock: no dialog with focus, exiting.\n");
400 "Content-Type: application/cccp+xml\r\n");
402 /* @TODO put request_id to queue to further compare with incoming one */
403 self
= sip_uri_self(sip
);
404 body
= g_strdup_printf(
405 SIPE_SEND_CONF_MODIFY_CONF_LOCK
,
406 session
->focus_dialog
->with
,
408 session
->request_id
++,
409 session
->focus_dialog
->with
,
410 locked
? "true" : "false");
413 send_sip_request(sip
->gc
,
415 session
->focus_dialog
->with
,
416 session
->focus_dialog
->with
,
419 session
->focus_dialog
,
425 /** Modify Delete User */
427 sipe_conf_delete_user(struct sipe_account_data
*sip
,
428 struct sip_session
*session
,
435 if (!session
->focus_dialog
|| !session
->focus_dialog
->is_established
) {
436 purple_debug_info("sipe", "sipe_conf_delete_user: no dialog with focus, exiting.\n");
441 "Content-Type: application/cccp+xml\r\n");
443 /* @TODO put request_id to queue to further compare with incoming one */
444 self
= sip_uri_self(sip
);
445 body
= g_strdup_printf(
446 SIPE_SEND_CONF_DELETE_USER
,
447 session
->focus_dialog
->with
,
449 session
->request_id
++,
450 session
->focus_dialog
->with
,
454 send_sip_request(sip
->gc
,
456 session
->focus_dialog
->with
,
457 session
->focus_dialog
->with
,
460 session
->focus_dialog
,
466 /** Invite counterparty to join conference callback */
468 process_invite_conf_response(struct sipe_account_data
*sip
,
470 SIPE_UNUSED_PARAMETER
struct transaction
*trans
)
472 struct sip_dialog
*dialog
= g_new0(struct sip_dialog
, 1);
474 dialog
->callid
= g_strdup(sipmsg_find_header(msg
, "Call-ID"));
475 dialog
->cseq
= parse_cseq(sipmsg_find_header(msg
, "CSeq"));
476 dialog
->with
= parse_from(sipmsg_find_header(msg
, "To"));
477 sipe_dialog_parse(dialog
, msg
, TRUE
);
479 if (msg
->response
>= 200) {
480 /* send ACK to counterparty */
482 send_sip_request(sip
->gc
, "ACK", dialog
->with
, dialog
->with
, NULL
, NULL
, dialog
, NULL
);
483 dialog
->outgoing_invite
= NULL
;
484 dialog
->is_established
= TRUE
;
487 if (msg
->response
>= 400) {
488 purple_debug_info("sipe", "process_invite_conf_response: INVITE response is not 200. Failed to invite %s.\n", dialog
->with
);
489 /* @TODO notify user of failure to invite counterparty */
490 sipe_dialog_free(dialog
);
494 if (msg
->response
>= 200) {
495 struct sip_session
*session
= sipe_session_find_im(sip
, dialog
->with
);
496 struct sip_dialog
*im_dialog
= sipe_dialog_find(session
, dialog
->with
);
498 /* close IM session to counterparty */
500 send_sip_request(sip
->gc
, "BYE", im_dialog
->with
, im_dialog
->with
, NULL
, NULL
, im_dialog
, NULL
);
501 sipe_dialog_remove(session
, dialog
->with
);
505 sipe_dialog_free(dialog
);
510 * Invites counterparty to join conference.
513 sipe_invite_conf(struct sipe_account_data
*sip
,
514 struct sip_session
*session
,
520 struct sip_dialog
*dialog
= NULL
;
522 /* It will be short lived special dialog.
523 * Will not be stored in session.
525 dialog
= g_new0(struct sip_dialog
, 1);
526 dialog
->callid
= gencallid();
527 dialog
->with
= g_strdup(who
);
528 dialog
->ourtag
= gentag();
530 contact
= get_contact(sip
);
531 hdr
= g_strdup_printf(
532 "Supported: ms-sender\r\n"
534 "Content-Type: application/ms-conf-invite+xml\r\n",
538 body
= g_strdup_printf(
539 SIPE_SEND_CONF_INVITE
,
541 session
->subject
? session
->subject
: ""
544 send_sip_request( sip
->gc
,
551 process_invite_conf_response
);
553 sipe_dialog_free(dialog
);
558 /** Create conference callback */
560 process_conf_add_response(struct sipe_account_data
*sip
,
562 struct transaction
*trans
)
564 if (msg
->response
>= 400) {
565 purple_debug_info("sipe", "process_conf_add_response: SERVICE response is not 200. Failed to create conference.\n");
566 /* @TODO notify user of failure to create conference */
569 if (msg
->response
== 200) {
570 xmlnode
*xn_response
= xmlnode_from_str(msg
->body
, msg
->bodylen
);
571 if (sipe_strequal("success", xmlnode_get_attrib(xn_response
, "code")))
573 gchar
*who
= trans
->payload
->data
;
574 struct sip_session
*session
;
575 xmlnode
*xn_conference_info
= xmlnode_get_descendant(xn_response
, "addConference", "conference-info", NULL
);
577 session
= sipe_session_add_chat(sip
);
578 session
->is_multiparty
= FALSE
;
579 session
->focus_uri
= g_strdup(xmlnode_get_attrib(xn_conference_info
, "entity"));
580 purple_debug_info("sipe", "process_conf_add_response: session->focus_uri=%s\n",
581 session
->focus_uri
? session
->focus_uri
: "");
583 session
->pending_invite_queue
= slist_insert_unique_sorted(
584 session
->pending_invite_queue
, g_strdup(who
), (GCompareFunc
)strcmp
);
586 /* add self to conf */
587 sipe_invite_conf_focus(sip
, session
);
589 xmlnode_free(xn_response
);
596 * Creates conference.
599 sipe_conf_add(struct sipe_account_data
*sip
,
603 gchar
*conference_id
;
607 struct transaction
*trans
;
608 struct sip_dialog
*dialog
= NULL
;
609 time_t expiry
= time(NULL
) + 7*60*60; /* 7 hours */
611 struct transaction_payload
*payload
;
613 contact
= get_contact(sip
);
614 hdr
= g_strdup_printf(
615 "Supported: ms-sender\r\n"
617 "Content-Type: application/cccp+xml\r\n",
621 expiry_time
= sipe_utils_time_to_str(expiry
);
622 self
= sip_uri_self(sip
);
623 conference_id
= genconfid();
624 body
= g_strdup_printf(
626 sip
->focus_factory_uri
,
632 g_free(conference_id
);
635 trans
= send_sip_request( sip
->gc
,
637 sip
->focus_factory_uri
,
638 sip
->focus_factory_uri
,
642 process_conf_add_response
);
644 payload
= g_new0(struct transaction_payload
, 1);
645 payload
->destroy
= g_free
;
646 payload
->data
= g_strdup(who
);
647 trans
->payload
= payload
;
649 sipe_dialog_free(dialog
);
655 process_incoming_invite_conf(struct sipe_account_data
*sip
,
658 struct sip_session
*session
= NULL
;
659 struct sip_dialog
*dialog
= NULL
;
660 xmlnode
*xn_conferencing
= xmlnode_from_str(msg
->body
, msg
->bodylen
);
661 xmlnode
*xn_focus_uri
= xmlnode_get_child(xn_conferencing
, "focus-uri");
662 char *focus_uri
= xmlnode_get_data(xn_focus_uri
);
663 gchar
*newTag
= gentag();
664 const gchar
*oldHeader
= sipmsg_find_header(msg
, "To");
667 xmlnode_free(xn_conferencing
);
670 purple_debug_info("sipe", "We have received invitation to Conference. Focus URI=%s\n", focus_uri
);
672 newHeader
= g_strdup_printf("%s;tag=%s", oldHeader
, newTag
);
673 sipmsg_remove_header_now(msg
, "To");
674 sipmsg_add_header_now(msg
, "To", newHeader
);
677 /* temporary dialog with invitor */
678 /* take data before 'msg' will be modified by send_sip_response */
679 dialog
= g_new0(struct sip_dialog
, 1);
680 dialog
->callid
= g_strdup(sipmsg_find_header(msg
, "Call-ID"));
681 dialog
->cseq
= parse_cseq(sipmsg_find_header(msg
, "CSeq"));
682 dialog
->with
= parse_from(sipmsg_find_header(msg
, "From"));
683 sipe_dialog_parse(dialog
, msg
, FALSE
);
685 send_sip_response(sip
->gc
, msg
, 200, "OK", NULL
);
687 session
= sipe_session_add_chat(sip
);
688 session
->focus_uri
= focus_uri
;
689 session
->is_multiparty
= FALSE
;
691 /* send BYE to invitor */
692 send_sip_request(sip
->gc
, "BYE", dialog
->with
, dialog
->with
, NULL
, NULL
, dialog
, NULL
);
693 sipe_dialog_free(dialog
);
695 /* add self to conf */
696 sipe_invite_conf_focus(sip
, session
);
700 sipe_process_conference(struct sipe_account_data
*sip
,
703 xmlnode
*xn_conference_info
;
706 const gchar
*focus_uri
;
707 struct sip_session
*session
;
708 gboolean just_joined
= FALSE
;
710 if (msg
->response
!= 0 && msg
->response
!= 200) return;
712 if (msg
->bodylen
== 0 || msg
->body
== NULL
|| !sipe_strequal(sipmsg_find_header(msg
, "Event"), "conference")) return;
714 xn_conference_info
= xmlnode_from_str(msg
->body
, msg
->bodylen
);
715 if (!xn_conference_info
) return;
717 focus_uri
= xmlnode_get_attrib(xn_conference_info
, "entity");
718 session
= sipe_session_find_conference(sip
, focus_uri
);
721 purple_debug_info("sipe", "sipe_process_conference: unable to find conf session with focus=%s\n", focus_uri
);
725 if (session
->focus_uri
&& !session
->conv
) {
726 gchar
*chat_title
= sipe_chat_get_name(session
->focus_uri
);
727 gchar
*self
= sip_uri_self(sip
);
728 /* can't be find by chat id as it won't survive acc reinstantation */
729 PurpleConversation
*conv
= NULL
;
732 conv
= purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT
,
736 /* to be able to rejoin existing chat/window */
737 if (conv
&& !purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv
))) {
738 PURPLE_CONV_CHAT(conv
)->left
= TRUE
;
740 /* create prpl chat */
741 session
->conv
= serv_got_joined_chat(sip
->gc
, session
->chat_id
, chat_title
);
742 session
->chat_title
= chat_title
;
743 purple_conv_chat_set_nick(PURPLE_CONV_CHAT(session
->conv
), self
);
745 /* @TODO ask for full state (re-subscribe) if it was a partial one -
746 * this is to obtain full list of conference participants.
752 if ((xn_subject
= xmlnode_get_descendant(xn_conference_info
, "conference-description", "subject", NULL
))) {
753 g_free(session
->subject
);
754 session
->subject
= xmlnode_get_data(xn_subject
);
755 purple_conv_chat_set_topic(PURPLE_CONV_CHAT(session
->conv
), NULL
, session
->subject
);
756 purple_debug_info("sipe", "sipe_process_conference: subject=%s\n", session
->subject
? session
->subject
: "");
760 if (!session
->im_mcu_uri
) {
761 for (node
= xmlnode_get_descendant(xn_conference_info
, "conference-description", "conf-uris", "entry", NULL
);
763 node
= xmlnode_get_next_twin(node
))
765 gchar
*purpose
= xmlnode_get_data(xmlnode_get_child(node
, "purpose"));
767 if (sipe_strequal("chat", purpose
)) {
769 session
->im_mcu_uri
= xmlnode_get_data(xmlnode_get_child(node
, "uri"));
770 purple_debug_info("sipe", "sipe_process_conference: im_mcu_uri=%s\n", session
->im_mcu_uri
);
778 for (node
= xmlnode_get_descendant(xn_conference_info
, "users", "user", NULL
); node
; node
= xmlnode_get_next_twin(node
)) {
779 xmlnode
*endpoint
= NULL
;
780 const gchar
*user_uri
= xmlnode_get_attrib(node
, "entity");
781 const gchar
*state
= xmlnode_get_attrib(node
, "state");
782 gchar
*role
= xmlnode_get_data(xmlnode_get_descendant(node
, "roles", "entry", NULL
));
783 PurpleConvChatBuddyFlags flags
= PURPLE_CBFLAGS_NONE
;
784 PurpleConvChat
*chat
= PURPLE_CONV_CHAT(session
->conv
);
785 gboolean is_in_im_mcu
= FALSE
;
786 gchar
*self
= sip_uri_self(sip
);
788 if (sipe_strequal(role
, "presenter")) {
789 flags
|= PURPLE_CBFLAGS_OP
;
792 if (sipe_strequal("deleted", state
)) {
793 if (purple_conv_chat_find_user(chat
, user_uri
)) {
794 purple_conv_chat_remove_user(chat
, user_uri
, NULL
/* reason */);
798 for (endpoint
= xmlnode_get_child(node
, "endpoint"); endpoint
; endpoint
= xmlnode_get_next_twin(endpoint
)) {
799 if (sipe_strequal("chat", xmlnode_get_attrib(endpoint
, "session-type"))) {
800 gchar
*status
= xmlnode_get_data(xmlnode_get_child(endpoint
, "status"));
801 if (sipe_strequal("connected", status
)) {
803 if (!purple_conv_chat_find_user(chat
, user_uri
)) {
804 purple_conv_chat_add_user(chat
, user_uri
, NULL
, flags
,
805 !just_joined
&& g_strcasecmp(user_uri
, self
));
807 purple_conv_chat_user_set_flags(chat
, user_uri
, flags
);
815 if (purple_conv_chat_find_user(chat
, user_uri
)) {
816 purple_conv_chat_remove_user(chat
, user_uri
, NULL
/* reason */);
824 /* entity-view, locked */
825 for (node
= xmlnode_get_descendant(xn_conference_info
, "conference-view", "entity-view", NULL
);
827 node
= xmlnode_get_next_twin(node
)) {
829 xmlnode
*xn_type
= xmlnode_get_descendant(node
, "entity-state", "media", "entry", "type", NULL
);
831 if (xn_type
&& sipe_strequal("chat", (tmp
= xmlnode_get_data(xn_type
)))) {
832 xmlnode
*xn_locked
= xmlnode_get_descendant(node
, "entity-state", "locked", NULL
);
834 gchar
*locked
= xmlnode_get_data(xn_locked
);
835 gboolean prev_locked
= session
->locked
;
836 session
->locked
= sipe_strequal(locked
, "true");
837 if (prev_locked
&& !session
->locked
) {
838 sipe_present_info(sip
, session
,
839 _("This conference is no longer locked. Additional participants can now join."));
841 if (!prev_locked
&& session
->locked
) {
842 sipe_present_info(sip
, session
,
843 _("This conference is locked. Nobody else can join the conference while it is locked."));
846 purple_debug_info("sipe", "sipe_process_conference: session->locked=%s\n",
847 session
->locked
? "TRUE" : "FALSE");
853 xmlnode_free(xn_conference_info
);
855 if (session
->im_mcu_uri
) {
856 struct sip_dialog
*dialog
= sipe_dialog_find(session
, session
->im_mcu_uri
);
858 dialog
= sipe_dialog_add(session
);
860 dialog
->callid
= g_strdup(session
->callid
);
861 dialog
->with
= g_strdup(session
->im_mcu_uri
);
863 /* send INVITE to IM MCU */
864 sipe_invite(sip
, session
, dialog
->with
, NULL
, NULL
, NULL
, FALSE
);
868 sipe_process_pending_invite_queue(sip
, session
);
872 sipe_conf_immcu_closed(struct sipe_account_data
*sip
,
873 struct sip_session
*session
)
875 sipe_present_info(sip
, session
,
876 _("You have been disconnected from this conference."));
877 purple_conv_chat_clear_users(PURPLE_CONV_CHAT(session
->conv
));
881 conf_session_close(struct sipe_account_data
*sip
,
882 struct sip_session
*session
)
885 /* unsubscribe from focus */
886 sipe_subscribe_conference(sip
, session
, 0);
888 if (session
->focus_dialog
) {
889 /* send BYE to focus */
890 send_sip_request(sip
->gc
,
892 session
->focus_dialog
->with
,
893 session
->focus_dialog
->with
,
896 session
->focus_dialog
,
903 sipe_process_imdn(struct sipe_account_data
*sip
,
906 gchar
*with
= parse_from(sipmsg_find_header(msg
, "From"));
907 const gchar
*call_id
= sipmsg_find_header(msg
, "Call-ID");
908 static struct sip_session
*session
;
914 session
= sipe_session_find_chat_by_callid(sip
, call_id
);
916 session
= sipe_session_find_im(sip
, with
);
919 purple_debug_info("sipe", "sipe_process_imdn: unable to find conf session with call_id=%s\n", call_id
);
924 xn_imdn
= xmlnode_from_str(msg
->body
, msg
->bodylen
);
925 message_id
= xmlnode_get_data(xmlnode_get_child(xn_imdn
, "message-id"));
927 message
= g_hash_table_lookup(session
->conf_unconfirmed_messages
, message_id
);
930 for (node
= xmlnode_get_child(xn_imdn
, "recipient"); node
; node
= xmlnode_get_next_twin(node
)) {
931 gchar
*tmp
= parse_from(xmlnode_get_attrib(node
, "uri"));
932 gchar
*uri
= parse_from(tmp
);
933 sipe_present_message_undelivered_err(sip
, session
, -1, -1, uri
, message
);
938 xmlnode_free(xn_imdn
);
940 g_hash_table_remove(session
->conf_unconfirmed_messages
, message_id
);
941 purple_debug_info("sipe", "sipe_process_imdn: removed message %s from conf_unconfirmed_messages(count=%d)\n",
942 message_id
, g_hash_table_size(session
->conf_unconfirmed_messages
));