4 *****************************************************************************
5 *** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ***
7 *** THIS MODULE IS DEPECRATED ***
9 *** DO NOT ADD ANY NEW CODE TO THIS MODULE ***
11 *** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ***
12 *****************************************************************************
16 * Copyright (C) 2010-11 SIPE Project <http://sipe.sourceforge.net/>
17 * Copyright (C) 2010 pier11 <pier11@operamail.com>
18 * Copyright (C) 2009 Anibal Avelar <debianmx@gmail.com>
19 * Copyright (C) 2009 pier11 <pier11@operamail.com>
20 * Copyright (C) 2008 Novell, Inc., Anibal Avelar <debianmx@gmail.com>
21 * Copyright (C) 2007 Anibal Avelar <debianmx@gmail.com>
22 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de>
25 * Thanks to Google's Summer of Code Program and the helpful mentors
28 * Session-based SIP MESSAGE documentation:
29 * http://tools.ietf.org/html/draft-ietf-simple-im-session-00
31 * This program is free software; you can redistribute it and/or modify
32 * it under the terms of the GNU General Public License as published by
33 * the Free Software Foundation; either version 2 of the License, or
34 * (at your option) any later version.
36 * This program is distributed in the hope that it will be useful,
37 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 * GNU General Public License for more details.
41 * You should have received a copy of the GNU General Public License
42 * along with this program; if not, write to the Free Software
43 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
52 #include "sipe-common.h"
56 #include "connection.h"
60 #include "core-depurple.h" /* Temporary for the core de-purple transition */
63 #include "sipe-backend.h"
64 #include "sipe-chat.h"
65 #include "sipe-conf.h"
66 #include "sipe-core.h"
67 #include "sipe-core-private.h"
70 #include "sipe-ocs2007.h"
71 #include "sipe-session.h"
72 #include "sipe-utils.h"
76 /** for Access levels menu */
77 #define INDENT_FMT " %s"
79 /** Member is indirectly belong to access level container.
80 * For example 'sameEnterprise' is in the container and user
81 * belongs to that same enterprise.
83 #define INDENT_MARKED_INHERITED_FMT "= %s"
86 purple_blist_add_buddy_clone(PurpleGroup
* group
, PurpleBuddy
* buddy
)
88 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
90 gchar
*server_alias
, *email
;
91 const PurpleStatus
*status
= purple_presence_get_active_status(purple_buddy_get_presence(buddy
));
93 clone
= sipe_backend_buddy_add(SIPE_CORE_PUBLIC
,
98 server_alias
= sipe_backend_buddy_get_server_alias(SIPE_CORE_PUBLIC
,
101 sipe_backend_buddy_set_server_alias(SIPE_CORE_PUBLIC
,
104 g_free(server_alias
);
107 email
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
109 SIPE_BUDDY_INFO_EMAIL
);
111 sipe_backend_buddy_set_string(SIPE_CORE_PUBLIC
,
113 SIPE_BUDDY_INFO_EMAIL
,
118 purple_presence_set_status_active(purple_buddy_get_presence(clone
),
119 purple_status_get_id(status
),
121 /* for UI to update */
122 sipe_backend_buddy_set_status(SIPE_CORE_PUBLIC
,
124 purple_status_get_id(status
));
130 sipe_buddy_menu_copy_to_cb(PurpleBlistNode
*node
, const char *group_name
)
132 PurpleBuddy
*buddy
, *b
;
133 PurpleGroup
* group
= purple_find_group(group_name
);
135 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node
));
137 buddy
= (PurpleBuddy
*)node
;
139 SIPE_DEBUG_INFO("sipe_buddy_menu_copy_to_cb: copying %s to %s",
140 buddy
->name
, group_name
);
142 b
= purple_find_buddy_in_group(buddy
->account
, buddy
->name
, group
);
144 b
= purple_blist_add_buddy_clone(group
, buddy
);
147 PurpleConnection
*gc
= purple_account_get_connection(b
->account
);
149 sipe_core_buddy_add(PURPLE_GC_TO_SIPE_CORE_PUBLIC
,
156 sipe_buddy_menu_chat_new_cb(PurpleBuddy
*buddy
)
158 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
160 SIPE_DEBUG_INFO("sipe_buddy_menu_chat_new_cb: buddy->name=%s", buddy
->name
);
162 /* 2007+ conference */
163 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007
))
165 sipe_conf_add(sipe_private
, buddy
->name
);
167 else /* 2005- multiparty chat */
169 gchar
*self
= sip_uri_self(sipe_private
);
170 struct sip_session
*session
;
172 session
= sipe_session_add_chat(sipe_private
,
176 session
->chat_session
->backend
= sipe_backend_chat_create(SIPE_CORE_PUBLIC
,
177 session
->chat_session
,
178 session
->chat_session
->title
,
182 sipe_im_invite(sipe_private
, session
, buddy
->name
, NULL
, NULL
, NULL
, FALSE
);
187 * For 2007+ conference only.
190 sipe_buddy_menu_chat_make_leader_cb(PurpleBuddy
*buddy
,
191 struct sipe_chat_session
*chat_session
)
193 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
194 struct sip_session
*session
;
196 SIPE_DEBUG_INFO("sipe_buddy_menu_chat_make_leader_cb: buddy->name=%s", buddy
->name
);
197 SIPE_DEBUG_INFO("sipe_buddy_menu_chat_make_leader_cb: chat_title=%s", chat_session
->title
);
199 session
= sipe_session_find_chat(sipe_private
, chat_session
);
201 sipe_conf_modify_user_role(sipe_private
, session
, buddy
->name
);
205 * For 2007+ conference only.
208 sipe_buddy_menu_chat_remove_cb(PurpleBuddy
*buddy
,
209 struct sipe_chat_session
*chat_session
)
211 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
212 struct sip_session
*session
;
214 SIPE_DEBUG_INFO("sipe_buddy_menu_chat_remove_cb: buddy->name=%s", buddy
->name
);
215 SIPE_DEBUG_INFO("sipe_buddy_menu_chat_remove_cb: chat_title=%s", chat_session
->title
);
217 session
= sipe_session_find_chat(sipe_private
, chat_session
);
219 sipe_conf_delete_user(sipe_private
, session
, buddy
->name
);
223 sipe_buddy_menu_chat_invite_cb(PurpleBuddy
*buddy
,
224 struct sipe_chat_session
*chat_session
)
226 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
228 SIPE_DEBUG_INFO("sipe_buddy_menu_chat_invite_cb: buddy->name=%s", buddy
->name
);
229 SIPE_DEBUG_INFO("sipe_buddy_menu_chat_invite_cb: chat_title=%s", chat_session
->title
);
231 sipe_core_chat_invite(SIPE_CORE_PUBLIC
, chat_session
, buddy
->name
);
235 sipe_buddy_menu_make_call_cb(PurpleBuddy
*buddy
, const char *phone
)
237 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
239 SIPE_DEBUG_INFO("sipe_buddy_menu_make_call_cb: buddy->name=%s", buddy
->name
);
241 char *tel_uri
= sip_to_tel_uri(phone
);
243 SIPE_DEBUG_INFO("sipe_buddy_menu_make_call_cb: going to call number: %s", tel_uri
? tel_uri
: "");
244 sip_csta_make_call(sipe_private
, tel_uri
);
251 sipe_buddy_menu_access_level_help_cb(PurpleBuddy
*buddy
)
253 /** Translators: replace with URL to localized page
254 * If it doesn't exist copy the original URL */
255 purple_notify_uri(buddy
->account
->gc
, _("https://sourceforge.net/apps/mediawiki/sipe/index.php?title=Access_Levels"));
259 sipe_buddy_menu_send_email_cb(PurpleBuddy
*buddy
)
261 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
263 SIPE_DEBUG_INFO("sipe_buddy_menu_send_email_cb: buddy->name=%s", buddy
->name
);
265 email
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
267 SIPE_BUDDY_INFO_EMAIL
);
270 char *command_line
= g_strdup_printf(
276 " mailto:%s", email
);
277 SIPE_DEBUG_INFO("sipe_buddy_menu_send_email_cb: going to call email client: %s", command_line
);
280 g_spawn_command_line_async(command_line
, NULL
);
281 g_free(command_line
);
285 SIPE_DEBUG_INFO("sipe_buddy_menu_send_email_cb: no email address stored for buddy=%s", buddy
->name
);
290 sipe_buddy_menu_access_level_cb(PurpleBuddy
*buddy
,
291 struct sipe_container
*container
)
293 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
294 sipe_ocs2007_change_access_level_from_container(sipe_private
,
299 sipe_get_access_control_menu(struct sipe_core_private
*sipe_private
,
303 * A menu which appear when right-clicking on buddy in contact list.
306 sipe_buddy_menu(PurpleBuddy
*buddy
)
308 PurpleBlistNode
*g_node
;
309 PurpleGroup
*gr_parent
;
310 PurpleMenuAction
*act
;
312 GList
*menu_groups
= NULL
;
313 struct sipe_core_private
*sipe_private
= PURPLE_BUDDY_TO_SIPE_CORE_PRIVATE
;
315 gchar
*self
= sip_uri_self(sipe_private
);
317 SIPE_SESSION_FOREACH
{
318 if (!sipe_strcase_equal(self
, buddy
->name
) && session
->chat_session
)
320 struct sipe_chat_session
*chat_session
= session
->chat_session
;
321 gboolean is_conf
= (chat_session
->type
== SIPE_CHAT_TYPE_CONFERENCE
);
323 if (sipe_backend_chat_find(chat_session
->backend
, buddy
->name
))
325 gboolean conf_op
= sipe_backend_chat_is_operator(chat_session
->backend
, self
);
328 && !sipe_backend_chat_is_operator(chat_session
->backend
, buddy
->name
) /* Not conf OP */
329 && conf_op
) /* We are a conf OP */
331 gchar
*label
= g_strdup_printf(_("Make leader of '%s'"),
332 chat_session
->title
);
333 act
= purple_menu_action_new(label
,
334 PURPLE_CALLBACK(sipe_buddy_menu_chat_make_leader_cb
),
337 menu
= g_list_prepend(menu
, act
);
341 && conf_op
) /* We are a conf OP */
343 gchar
*label
= g_strdup_printf(_("Remove from '%s'"),
344 chat_session
->title
);
345 act
= purple_menu_action_new(label
,
346 PURPLE_CALLBACK(sipe_buddy_menu_chat_remove_cb
),
349 menu
= g_list_prepend(menu
, act
);
355 || (is_conf
&& !session
->locked
))
357 gchar
*label
= g_strdup_printf(_("Invite to '%s'"),
358 chat_session
->title
);
359 act
= purple_menu_action_new(label
,
360 PURPLE_CALLBACK(sipe_buddy_menu_chat_invite_cb
),
363 menu
= g_list_prepend(menu
, act
);
367 } SIPE_SESSION_FOREACH_END
;
369 act
= purple_menu_action_new(_("New chat"),
370 PURPLE_CALLBACK(sipe_buddy_menu_chat_new_cb
),
372 menu
= g_list_prepend(menu
, act
);
374 if (sipe_private
->csta
&& !sipe_private
->csta
->line_status
) {
376 gchar
*phone_disp_str
;
379 phone
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
381 SIPE_BUDDY_INFO_WORK_PHONE
);
382 phone_disp_str
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
384 SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY
);
386 gchar
*label
= g_strdup_printf(_("Work %s"),
387 phone_disp_str
? phone_disp_str
: (tmp
= sip_tel_uri_denormalize(phone
)));
388 act
= purple_menu_action_new(label
, PURPLE_CALLBACK(sipe_buddy_menu_make_call_cb
), (gpointer
) phone
, NULL
);
392 menu
= g_list_prepend(menu
, act
);
395 g_free(phone_disp_str
);
398 phone
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
400 SIPE_BUDDY_INFO_MOBILE_PHONE
);
401 phone_disp_str
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
403 SIPE_BUDDY_INFO_MOBILE_PHONE_DISPLAY
);
405 gchar
*label
= g_strdup_printf(_("Mobile %s"),
406 phone_disp_str
? phone_disp_str
: (tmp
= sip_tel_uri_denormalize(phone
)));
407 act
= purple_menu_action_new(label
, PURPLE_CALLBACK(sipe_buddy_menu_make_call_cb
), (gpointer
) phone
, NULL
);
411 menu
= g_list_prepend(menu
, act
);
414 g_free(phone_disp_str
);
417 phone
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
419 SIPE_BUDDY_INFO_HOME_PHONE
);
420 phone_disp_str
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
422 SIPE_BUDDY_INFO_HOME_PHONE_DISPLAY
);
424 gchar
*label
= g_strdup_printf(_("Home %s"),
425 phone_disp_str
? phone_disp_str
: (tmp
= sip_tel_uri_denormalize(phone
)));
426 act
= purple_menu_action_new(label
, PURPLE_CALLBACK(sipe_buddy_menu_make_call_cb
), (gpointer
) phone
, NULL
);
430 menu
= g_list_prepend(menu
, act
);
433 g_free(phone_disp_str
);
436 phone
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
438 SIPE_BUDDY_INFO_OTHER_PHONE
);
439 phone_disp_str
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
441 SIPE_BUDDY_INFO_OTHER_PHONE_DISPLAY
);
443 gchar
*label
= g_strdup_printf(_("Other %s"),
444 phone_disp_str
? phone_disp_str
: (tmp
= sip_tel_uri_denormalize(phone
)));
445 act
= purple_menu_action_new(label
, PURPLE_CALLBACK(sipe_buddy_menu_make_call_cb
), (gpointer
) phone
, NULL
);
449 menu
= g_list_prepend(menu
, act
);
452 g_free(phone_disp_str
);
455 phone
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
457 SIPE_BUDDY_INFO_CUSTOM1_PHONE
);
458 phone_disp_str
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
460 SIPE_BUDDY_INFO_CUSTOM1_PHONE_DISPLAY
);
462 gchar
*label
= g_strdup_printf(_("Custom1 %s"),
463 phone_disp_str
? phone_disp_str
: (tmp
= sip_tel_uri_denormalize(phone
)));
464 act
= purple_menu_action_new(label
, PURPLE_CALLBACK(sipe_buddy_menu_make_call_cb
), (gpointer
) phone
, NULL
);
468 menu
= g_list_prepend(menu
, act
);
471 g_free(phone_disp_str
);
474 email
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
476 SIPE_BUDDY_INFO_EMAIL
);
478 act
= purple_menu_action_new(_("Send email..."),
479 PURPLE_CALLBACK(sipe_buddy_menu_send_email_cb
),
481 menu
= g_list_prepend(menu
, act
);
486 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007
)) {
487 GList
*menu_access_levels
= sipe_get_access_control_menu(sipe_private
, buddy
->name
);
489 act
= purple_menu_action_new(_("Access level"),
491 NULL
, menu_access_levels
);
492 menu
= g_list_prepend(menu
, act
);
496 gr_parent
= purple_buddy_get_group(buddy
);
497 for (g_node
= purple_blist_get_root(); g_node
; g_node
= g_node
->next
) {
500 if (g_node
->type
!= PURPLE_BLIST_GROUP_NODE
)
503 group
= (PurpleGroup
*)g_node
;
504 if (group
== gr_parent
)
507 if (purple_find_buddy_in_group(buddy
->account
, buddy
->name
, group
))
510 act
= purple_menu_action_new(purple_group_get_name(group
),
511 PURPLE_CALLBACK(sipe_buddy_menu_copy_to_cb
),
513 menu_groups
= g_list_prepend(menu_groups
, act
);
515 /* Coverity complains about RESOURCE_LEAK here - no idea how to fix it */
516 menu_groups
= g_list_reverse(menu_groups
);
518 act
= purple_menu_action_new(_("Copy to"),
521 menu
= g_list_prepend(menu
, act
);
523 menu
= g_list_reverse(menu
);
530 sipe_ask_access_domain_cb(PurpleConnection
*gc
, PurpleRequestFields
*fields
)
532 struct sipe_core_private
*sipe_private
= PURPLE_GC_TO_SIPE_CORE_PRIVATE
;
533 const char *domain
= purple_request_fields_get_string(fields
, "access_domain");
534 guint index
= purple_request_fields_get_choice(fields
, "container_id");
535 sipe_ocs2007_change_access_level_for_domain(sipe_private
,
540 static void sipe_buddy_menu_access_level_add_domain_cb(PurpleBuddy
*buddy
)
542 PurpleConnection
*gc
= purple_account_get_connection(buddy
->account
);
543 PurpleRequestFields
*fields
;
544 PurpleRequestFieldGroup
*g
;
545 PurpleRequestField
*f
;
547 fields
= purple_request_fields_new();
549 g
= purple_request_field_group_new(NULL
);
550 f
= purple_request_field_string_new("access_domain", _("Domain"), "partner-company.com", FALSE
);
551 purple_request_field_set_required(f
, TRUE
);
552 purple_request_field_group_add_field(g
, f
);
554 f
= purple_request_field_choice_new("container_id", _("Access level"), 0);
555 purple_request_field_choice_add(f
, _("Personal")); /* index 0 */
556 purple_request_field_choice_add(f
, _("Team"));
557 purple_request_field_choice_add(f
, _("Company"));
558 purple_request_field_choice_add(f
, _("Public"));
559 purple_request_field_choice_add(f
, _("Blocked")); /* index 4 */
560 purple_request_field_choice_set_default_value(f
, 3); /* index */
561 purple_request_field_set_required(f
, TRUE
);
562 purple_request_field_group_add_field(g
, f
);
564 purple_request_fields_add_group(fields
, g
);
566 purple_request_fields(gc
, _("Add new domain"),
567 _("Add new domain"), NULL
, fields
,
568 _("Add"), G_CALLBACK(sipe_ask_access_domain_cb
),
570 buddy
->account
, NULL
, NULL
, gc
);
574 * Workaround for missing libpurple API to release resources allocated
575 * during blist_node_menu() callback. See also:
577 * <http://developer.pidgin.im/ticket/12597>
579 * We remember all memory blocks in a list and deallocate them when
581 * - the next time we enter the callback, or
582 * - the account is disconnected
584 * That means that after the buddy menu has been closed we have unused
585 * resources but at least we don't leak them anymore...
587 void sipe_blist_menu_free_containers(struct sipe_core_private
*sipe_private
)
589 GSList
*entry
= sipe_private
->blist_menu_containers
;
591 sipe_ocs2007_free_container(entry
->data
);
594 g_slist_free(sipe_private
->blist_menu_containers
);
595 sipe_private
->blist_menu_containers
= NULL
;
599 sipe_blist_menu_remember_container(struct sipe_core_private
*sipe_private
,
600 struct sipe_container
*container
)
602 sipe_private
->blist_menu_containers
= g_slist_prepend(sipe_private
->blist_menu_containers
,
607 sipe_get_access_levels_menu(struct sipe_core_private
*sipe_private
,
608 const char* member_type
,
609 const char* member_value
,
610 const gboolean extra_menu
)
612 GList
*menu_access_levels
= NULL
;
615 PurpleMenuAction
*act
;
616 struct sipe_container
*container
;
617 gboolean is_group_access
= FALSE
;
618 int container_id
= sipe_ocs2007_find_access_level(sipe_private
,
622 guint container_max
= sipe_ocs2007_containers();
624 for (i
= 1; i
<= container_max
; i
++) {
625 /* to put Blocked level last in menu list.
626 * Blocked should remaim in the first place in the containers[] array.
628 unsigned int j
= (i
== container_max
) ? 0 : i
;
629 int container_j
= sipe_ocs2007_container_id(j
);
630 const gchar
*acc_level_name
= sipe_ocs2007_access_level_name(container_j
);
632 container
= sipe_ocs2007_create_container(j
,
637 /* libpurple memory leak workaround */
638 sipe_blist_menu_remember_container(sipe_private
, container
);
640 /* current container/access level */
641 if (container_j
== container_id
) {
642 menu_name
= is_group_access
?
643 g_strdup_printf(INDENT_MARKED_INHERITED_FMT
, acc_level_name
) :
644 g_strdup_printf(SIPE_OCS2007_INDENT_MARKED_FMT
, acc_level_name
);
646 menu_name
= g_strdup_printf(INDENT_FMT
, acc_level_name
);
649 act
= purple_menu_action_new(menu_name
,
650 PURPLE_CALLBACK(sipe_buddy_menu_access_level_cb
),
653 menu_access_levels
= g_list_prepend(menu_access_levels
, act
);
656 if (extra_menu
&& (container_id
>= 0)) {
658 act
= purple_menu_action_new(" --------------", NULL
, NULL
, NULL
);
659 menu_access_levels
= g_list_prepend(menu_access_levels
, act
);
661 if (!is_group_access
) {
662 container
= sipe_ocs2007_create_container(0,
667 /* libpurple memory leak workaround */
668 sipe_blist_menu_remember_container(sipe_private
, container
);
670 /* Translators: remove (clear) previously assigned access level */
671 menu_name
= g_strdup_printf(INDENT_FMT
, _("Unspecify"));
672 act
= purple_menu_action_new(menu_name
,
673 PURPLE_CALLBACK(sipe_buddy_menu_access_level_cb
),
676 menu_access_levels
= g_list_prepend(menu_access_levels
, act
);
680 menu_access_levels
= g_list_reverse(menu_access_levels
);
681 return menu_access_levels
;
685 sipe_get_access_groups_menu(struct sipe_core_private
*sipe_private
)
687 GList
*menu_access_groups
= NULL
;
688 PurpleMenuAction
*act
;
689 GSList
*access_domains
;
692 act
= purple_menu_action_new(_("People in my company"),
694 NULL
, sipe_get_access_levels_menu(sipe_private
, "sameEnterprise", NULL
, FALSE
));
695 menu_access_groups
= g_list_prepend(menu_access_groups
, act
);
697 /* this is original name, don't edit */
698 act
= purple_menu_action_new(_("People in domains connected with my company"),
700 NULL
, sipe_get_access_levels_menu(sipe_private
, "federated", NULL
, FALSE
));
701 menu_access_groups
= g_list_prepend(menu_access_groups
, act
);
703 act
= purple_menu_action_new(_("People in public domains"),
705 NULL
, sipe_get_access_levels_menu(sipe_private
, "publicCloud", NULL
, TRUE
));
706 menu_access_groups
= g_list_prepend(menu_access_groups
, act
);
708 access_domains
= sipe_ocs2007_get_access_domains(sipe_private
);
709 entry
= access_domains
;
711 gchar
*domain
= entry
->data
;
712 gchar
*menu_name
= g_strdup_printf(_("People at %s"), domain
);
714 /* takes over ownership of entry->data (= domain) */
715 act
= purple_menu_action_new(menu_name
,
717 NULL
, sipe_get_access_levels_menu(sipe_private
, "domain", domain
, TRUE
));
718 menu_access_groups
= g_list_prepend(menu_access_groups
, act
);
723 g_slist_free(access_domains
);
726 /* People in domains connected with my company */
727 act
= purple_menu_action_new("-------------------------------------------", NULL
, NULL
, NULL
);
728 menu_access_groups
= g_list_prepend(menu_access_groups
, act
);
730 act
= purple_menu_action_new(_("Add new domain..."),
731 PURPLE_CALLBACK(sipe_buddy_menu_access_level_add_domain_cb
),
733 menu_access_groups
= g_list_prepend(menu_access_groups
, act
);
735 menu_access_groups
= g_list_reverse(menu_access_groups
);
737 return menu_access_groups
;
741 sipe_get_access_control_menu(struct sipe_core_private
*sipe_private
,
744 GList
*menu_access_levels
= NULL
;
745 GList
*menu_access_groups
= NULL
;
747 PurpleMenuAction
*act
;
749 /* libpurple memory leak workaround */
750 sipe_blist_menu_free_containers(sipe_private
);
752 menu_access_levels
= sipe_get_access_levels_menu(sipe_private
, "user", sipe_get_no_sip_uri(uri
), TRUE
);
754 menu_access_groups
= sipe_get_access_groups_menu(sipe_private
);
756 menu_name
= g_strdup_printf(INDENT_FMT
, _("Access groups"));
757 act
= purple_menu_action_new(menu_name
,
759 NULL
, menu_access_groups
);
761 menu_access_levels
= g_list_append(menu_access_levels
, act
);
763 menu_name
= g_strdup_printf(INDENT_FMT
, _("Online help..."));
764 act
= purple_menu_action_new(menu_name
,
765 PURPLE_CALLBACK(sipe_buddy_menu_access_level_help_cb
),
768 menu_access_levels
= g_list_append(menu_access_levels
, act
);
770 return menu_access_levels
;