6 * Copyright (C) 2010-2013 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "sipe-common.h"
37 #include "sip-transport.h"
38 #include "sipe-backend.h"
39 #include "sipe-buddy.h"
41 #include "sipe-chat.h"
42 #include "sipe-conf.h"
43 #include "sipe-core.h"
44 #include "sipe-core-private.h"
45 #include "sipe-group.h"
46 #include "sipe-http.h"
49 #include "sipe-ocs2005.h"
50 #include "sipe-ocs2007.h"
51 #include "sipe-schedule.h"
52 #include "sipe-session.h"
53 #include "sipe-status.h"
54 #include "sipe-subscriptions.h"
56 #include "sipe-utils.h"
57 #include "sipe-webticket.h"
60 struct photo_response_data
{
63 struct sipe_http_request
*request
;
66 static void buddy_fetch_photo(struct sipe_core_private
*sipe_private
,
68 static void photo_response_data_free(struct photo_response_data
*data
);
70 struct sipe_buddy
*sipe_buddy_add(struct sipe_core_private
*sipe_private
,
73 struct sipe_buddy
*buddy
= g_hash_table_lookup(sipe_private
->buddies
, uri
);
75 buddy
= g_new0(struct sipe_buddy
, 1);
76 buddy
->name
= g_strdup(uri
);
77 g_hash_table_insert(sipe_private
->buddies
, buddy
->name
, buddy
);
79 SIPE_DEBUG_INFO("sipe_buddy_add: Added buddy %s", uri
);
81 buddy_fetch_photo(sipe_private
, uri
);
83 SIPE_DEBUG_INFO("sipe_buddy_add: Buddy %s already exists", uri
);
89 static void buddy_free(struct sipe_buddy
*buddy
)
93 * We are calling g_hash_table_foreach_steal(). That means that no
94 * key/value deallocation functions are called. Therefore the glib
95 * hash code does not touch the key (buddy->name) or value (buddy)
96 * of the to-be-deleted hash node at all. It follows that we
98 * - MUST free the memory for the key ourselves and
99 * - ARE allowed to do it in this function
101 * Conclusion: glib must be broken on the Windows platform if sipe
102 * crashes with SIGTRAP when closing. You'll have to live
103 * with the memory leak until this is fixed.
107 g_free(buddy
->activity
);
108 g_free(buddy
->meeting_subject
);
109 g_free(buddy
->meeting_location
);
112 g_free(buddy
->cal_start_time
);
113 g_free(buddy
->cal_free_busy_base64
);
114 g_free(buddy
->cal_free_busy
);
115 g_free(buddy
->last_non_cal_activity
);
117 sipe_cal_free_working_hours(buddy
->cal_working_hours
);
119 g_free(buddy
->device_name
);
120 g_slist_free(buddy
->groups
);
124 static gboolean
buddy_free_cb(SIPE_UNUSED_PARAMETER gpointer key
,
126 SIPE_UNUSED_PARAMETER gpointer user_data
)
129 /* We must return TRUE as the key/value have already been deleted */
133 void sipe_buddy_free_all(struct sipe_core_private
*sipe_private
)
135 g_hash_table_foreach_steal(sipe_private
->buddies
,
139 /* core is being deallocated, remove all its pending photo requests */
140 while (sipe_private
->pending_photo_requests
) {
141 struct photo_response_data
*data
=
142 sipe_private
->pending_photo_requests
->data
;
143 sipe_private
->pending_photo_requests
=
144 g_slist_remove(sipe_private
->pending_photo_requests
, data
);
145 photo_response_data_free(data
);
149 gchar
*sipe_core_buddy_status(struct sipe_core_public
*sipe_public
,
152 const gchar
*status_text
)
154 struct sipe_buddy
*sbuddy
;
155 const char *activity_str
;
157 if (!sipe_public
) return NULL
; /* happens on pidgin exit */
159 sbuddy
= g_hash_table_lookup(SIPE_CORE_PRIVATE
->buddies
, uri
);
160 if (!sbuddy
) return NULL
;
162 activity_str
= sbuddy
->activity
? sbuddy
->activity
:
163 (activity
== SIPE_ACTIVITY_BUSY
) || (activity
== SIPE_ACTIVITY_BRB
) ?
166 if (activity_str
&& sbuddy
->note
) {
167 return g_strdup_printf("%s - <i>%s</i>", activity_str
, sbuddy
->note
);
168 } else if (activity_str
) {
169 return g_strdup(activity_str
);
170 } else if (sbuddy
->note
) {
171 return g_strdup_printf("<i>%s</i>", sbuddy
->note
);
177 gchar
*sipe_buddy_get_alias(struct sipe_core_private
*sipe_private
,
180 sipe_backend_buddy pbuddy
;
182 if ((pbuddy
= sipe_backend_buddy_find(SIPE_CORE_PUBLIC
, with
, NULL
))) {
183 alias
= sipe_backend_buddy_get_alias(SIPE_CORE_PUBLIC
, pbuddy
);
188 void sipe_core_buddy_group(struct sipe_core_public
*sipe_public
,
190 const gchar
*old_group_name
,
191 const gchar
*new_group_name
)
193 struct sipe_buddy
* buddy
= g_hash_table_lookup(SIPE_CORE_PRIVATE
->buddies
, who
);
194 struct sipe_group
* old_group
= NULL
;
195 struct sipe_group
* new_group
;
197 SIPE_DEBUG_INFO("sipe_core_buddy_group: who:%s old_group_name:%s new_group_name:%s",
198 who
? who
: "", old_group_name
? old_group_name
: "", new_group_name
? new_group_name
: "");
200 if(!buddy
) { // buddy not in roaming list
204 if (old_group_name
) {
205 old_group
= sipe_group_find_by_name(SIPE_CORE_PRIVATE
, old_group_name
);
207 new_group
= sipe_group_find_by_name(SIPE_CORE_PRIVATE
, new_group_name
);
210 buddy
->groups
= g_slist_remove(buddy
->groups
, old_group
);
211 SIPE_DEBUG_INFO("sipe_core_buddy_group: buddy %s removed from old group %s", who
, old_group_name
);
215 sipe_group_create(SIPE_CORE_PRIVATE
, new_group_name
, who
);
217 buddy
->groups
= sipe_utils_slist_insert_unique_sorted(buddy
->groups
,
219 (GCompareFunc
)sipe_group_compare
,
221 sipe_group_update_buddy(SIPE_CORE_PRIVATE
, buddy
);
225 void sipe_core_buddy_add(struct sipe_core_public
*sipe_public
,
227 const gchar
*group_name
)
229 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
231 if (!g_hash_table_lookup(sipe_private
->buddies
, uri
)) {
232 struct sipe_buddy
*b
= sipe_buddy_add(sipe_private
, uri
);
233 b
->just_added
= TRUE
;
235 sipe_subscribe_presence_single_cb(sipe_private
, b
->name
);
238 SIPE_DEBUG_INFO("sipe_core_buddy_add: buddy %s already in internal list",
242 sipe_core_buddy_group(sipe_public
,
248 void sipe_buddy_remove(struct sipe_core_private
*sipe_private
,
249 struct sipe_buddy
*buddy
)
251 gchar
*action_name
= sipe_utils_presence_key(buddy
->name
);
252 sipe_schedule_cancel(sipe_private
, action_name
);
255 g_hash_table_remove(sipe_private
->buddies
, buddy
->name
);
261 * Unassociates buddy from group first.
262 * Then see if no groups left, removes buddy completely.
263 * Otherwise updates buddy groups on server.
265 void sipe_core_buddy_remove(struct sipe_core_public
*sipe_public
,
267 const gchar
*group_name
)
269 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
270 struct sipe_buddy
*b
= g_hash_table_lookup(sipe_private
->buddies
,
276 struct sipe_group
*g
= sipe_group_find_by_name(sipe_private
,
279 b
->groups
= g_slist_remove(b
->groups
, g
);
280 SIPE_DEBUG_INFO("sipe_core_buddy_remove: buddy %s removed from group %s",
285 if (g_slist_length(b
->groups
) < 1) {
286 gchar
*request
= g_strdup_printf("<m:URI>%s</m:URI>",
288 sip_soap_request(sipe_private
,
292 sipe_buddy_remove(sipe_private
, b
);
294 /* updates groups on server */
295 sipe_group_update_buddy(sipe_private
, b
);
300 void sipe_core_buddy_got_status(struct sipe_core_public
*sipe_public
,
304 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
305 struct sipe_buddy
*sbuddy
= g_hash_table_lookup(sipe_private
->buddies
,
310 /* Check if on 2005 system contact's calendar,
311 * then set/preserve it.
313 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007
)) {
314 sipe_backend_buddy_set_status(sipe_public
, uri
, activity
);
316 sipe_ocs2005_apply_calendar_status(sipe_private
,
318 sipe_status_activity_to_token(activity
));
322 void sipe_core_buddy_tooltip_info(struct sipe_core_public
*sipe_public
,
324 const gchar
*status_name
,
326 struct sipe_backend_buddy_tooltip
*tooltip
)
328 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
330 gboolean is_oof_note
= FALSE
;
331 const gchar
*activity
= NULL
;
332 gchar
*calendar
= NULL
;
333 const gchar
*meeting_subject
= NULL
;
334 const gchar
*meeting_location
= NULL
;
335 gchar
*access_text
= NULL
;
337 #define SIPE_ADD_BUDDY_INFO(l, t) \
339 gchar *tmp = g_markup_escape_text((t), -1); \
340 sipe_backend_buddy_tooltip_add(sipe_public, tooltip, (l), tmp); \
343 #define SIPE_ADD_BUDDY_INFO_NOESCAPE(l, t) \
344 sipe_backend_buddy_tooltip_add(sipe_public, tooltip, (l), (t))
346 if (sipe_public
) { /* happens on pidgin exit */
347 struct sipe_buddy
*sbuddy
= g_hash_table_lookup(sipe_private
->buddies
, uri
);
350 is_oof_note
= sbuddy
->is_oof_note
;
351 activity
= sbuddy
->activity
;
352 calendar
= sipe_cal_get_description(sbuddy
);
353 meeting_subject
= sbuddy
->meeting_subject
;
354 meeting_location
= sbuddy
->meeting_location
;
356 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007
)) {
357 gboolean is_group_access
= FALSE
;
358 const int container_id
= sipe_ocs2007_find_access_level(sipe_private
,
360 sipe_get_no_sip_uri(uri
),
362 const char *access_level
= sipe_ocs2007_access_level_name(container_id
);
363 access_text
= is_group_access
?
364 g_strdup(access_level
) :
365 g_strdup_printf(SIPE_OCS2007_INDENT_MARKED_FMT
,
371 const gchar
*status_str
= activity
? activity
: status_name
;
373 SIPE_ADD_BUDDY_INFO(_("Status"), status_str
);
375 if (is_online
&& !is_empty(calendar
)) {
376 SIPE_ADD_BUDDY_INFO(_("Calendar"), calendar
);
379 if (!is_empty(meeting_location
)) {
380 SIPE_DEBUG_INFO("sipe_tooltip_text: %s meeting location: '%s'", uri
, meeting_location
);
381 SIPE_ADD_BUDDY_INFO(_("Meeting in"), meeting_location
);
383 if (!is_empty(meeting_subject
)) {
384 SIPE_DEBUG_INFO("sipe_tooltip_text: %s meeting subject: '%s'", uri
, meeting_subject
);
385 SIPE_ADD_BUDDY_INFO(_("Meeting about"), meeting_subject
);
388 gchar
*note_italics
= g_strdup_printf("<i>%s</i>", note
);
389 SIPE_DEBUG_INFO("sipe_tooltip_text: %s note: '%s'", uri
, note
);
390 SIPE_ADD_BUDDY_INFO_NOESCAPE(is_oof_note
? _("Out of office note") : _("Note"),
392 g_free(note_italics
);
395 SIPE_ADD_BUDDY_INFO(_("Access level"), access_text
);
400 void sipe_buddy_update_property(struct sipe_core_private
*sipe_private
,
402 sipe_buddy_info_fields propkey
,
403 char *property_value
)
405 GSList
*buddies
, *entry
;
408 property_value
= g_strstrip(property_value
);
410 entry
= buddies
= sipe_backend_buddy_find_all(SIPE_CORE_PUBLIC
, uri
, NULL
); /* all buddies in different groups */
413 sipe_backend_buddy p_buddy
= entry
->data
;
415 /* for Display Name */
416 if (propkey
== SIPE_BUDDY_INFO_DISPLAY_NAME
) {
418 alias
= sipe_backend_buddy_get_alias(SIPE_CORE_PUBLIC
, p_buddy
);
419 if (property_value
&& sipe_is_bad_alias(uri
, alias
)) {
420 SIPE_DEBUG_INFO("Replacing alias for %s with %s", uri
, property_value
);
421 sipe_backend_buddy_set_alias(SIPE_CORE_PUBLIC
, p_buddy
, property_value
);
425 alias
= sipe_backend_buddy_get_server_alias(SIPE_CORE_PUBLIC
, p_buddy
);
426 if (!is_empty(property_value
) &&
427 (!sipe_strequal(property_value
, alias
) || is_empty(alias
)) )
429 SIPE_DEBUG_INFO("Replacing service alias for %s with %s", uri
, property_value
);
430 sipe_backend_buddy_set_server_alias(SIPE_CORE_PUBLIC
, p_buddy
, property_value
);
434 /* for other properties */
436 if (!is_empty(property_value
)) {
437 prop_str
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
, p_buddy
, propkey
);
438 if (!prop_str
|| !sipe_strcase_equal(prop_str
, property_value
)) {
439 sipe_backend_buddy_set_string(SIPE_CORE_PUBLIC
, p_buddy
, propkey
, property_value
);
447 g_slist_free(buddies
);
456 sipe_svc_callback
*callback
;
457 struct sipe_svc_session
*session
;
458 gchar
*wsse_security
;
459 struct sipe_backend_search_token
*token
;
460 /* must call ms_dlx_free() */
461 void (*failed_callback
)(struct sipe_core_private
*sipe_private
,
462 struct ms_dlx_data
*mdd
);
465 static void ms_dlx_free(struct ms_dlx_data
*mdd
)
467 sipe_utils_slist_free_full(mdd
->search_rows
, g_free
);
468 sipe_svc_session_close(mdd
->session
);
470 g_free(mdd
->wsse_security
);
474 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
475 #define DLX_SEARCH_ITEM \
476 "<AbEntryRequest.ChangeSearchQuery>" \
477 " <SearchOn>%s</SearchOn>" \
478 " <Value>%s</Value>" \
479 "</AbEntryRequest.ChangeSearchQuery>"
481 static gchar
* prepare_buddy_search_query(GSList
*query_rows
, gboolean use_dlx
) {
482 gchar
**attrs
= g_new(gchar
*, (g_slist_length(query_rows
) / 2) + 1);
490 attr
= query_rows
->data
;
491 query_rows
= g_slist_next(query_rows
);
492 value
= query_rows
->data
;
493 query_rows
= g_slist_next(query_rows
);
498 attrs
[i
++] = g_markup_printf_escaped(use_dlx
? DLX_SEARCH_ITEM
: SIPE_SOAP_SEARCH_ROW
,
504 query
= g_strjoinv(NULL
, attrs
);
505 SIPE_DEBUG_INFO("prepare_buddy_search_query: rows:\n%s",
514 static void ms_dlx_webticket(struct sipe_core_private
*sipe_private
,
515 const gchar
*base_uri
,
516 const gchar
*auth_uri
,
517 const gchar
*wsse_security
,
518 SIPE_UNUSED_PARAMETER
const gchar
*failure_msg
,
519 gpointer callback_data
)
521 struct ms_dlx_data
*mdd
= callback_data
;
524 gchar
*query
= prepare_buddy_search_query(mdd
->search_rows
, TRUE
);
526 SIPE_DEBUG_INFO("ms_dlx_webticket: got ticket for %s",
529 if (sipe_svc_ab_entry_request(sipe_private
,
534 g_slist_length(mdd
->search_rows
) / 2,
539 /* keep webticket security token for potential further use */
540 mdd
->wsse_security
= g_strdup(wsse_security
);
542 /* callback data passed down the line */
548 /* no ticket: this will show the minmum information */
549 SIPE_DEBUG_ERROR("ms_dlx_webticket: no web ticket for %s",
554 mdd
->failed_callback(sipe_private
, mdd
);
557 static void ms_dlx_webticket_request(struct sipe_core_private
*sipe_private
,
558 struct ms_dlx_data
*mdd
)
560 if (!sipe_webticket_request(sipe_private
,
562 sipe_private
->dlx_uri
,
563 "AddressBookWebTicketBearer",
566 SIPE_DEBUG_ERROR("ms_dlx_webticket_request: couldn't request webticket for %s",
567 sipe_private
->dlx_uri
);
568 mdd
->failed_callback(sipe_private
, mdd
);
572 static void search_contacts_finalize(struct sipe_core_private
*sipe_private
,
573 struct sipe_backend_search_results
*results
,
577 gchar
*secondary
= g_strdup_printf(
578 dngettext(PACKAGE_NAME
,
579 "Found %d contact%s:",
580 "Found %d contacts%s:", match_count
),
581 match_count
, more
? _(" (more matched your query)") : "");
583 sipe_backend_search_results_finalize(SIPE_CORE_PUBLIC
,
590 static void search_ab_entry_response(struct sipe_core_private
*sipe_private
,
592 SIPE_UNUSED_PARAMETER
const gchar
*raw
,
594 gpointer callback_data
)
596 struct ms_dlx_data
*mdd
= callback_data
;
599 const sipe_xml
*node
;
600 struct sipe_backend_search_results
*results
;
603 SIPE_DEBUG_INFO("search_ab_entry_response: received valid SOAP message from service %s",
607 node
= sipe_xml_child(soap_body
, "Body/SearchAbEntryResponse/SearchAbEntryResult/Items/AbEntry");
609 SIPE_DEBUG_ERROR_NOFORMAT("search_ab_entry_response: no matches");
610 sipe_backend_search_failed(SIPE_CORE_PUBLIC
,
612 _("No contacts found"));
617 /* OK, we found something - show the results to the user */
618 results
= sipe_backend_search_results_start(SIPE_CORE_PUBLIC
,
621 SIPE_DEBUG_ERROR_NOFORMAT("search_ab_entry_response: Unable to display the search results.");
622 sipe_backend_search_failed(SIPE_CORE_PUBLIC
,
624 _("Unable to display the search results"));
629 /* SearchAbEntryResult can contain duplicates */
630 found
= g_hash_table_new_full(g_str_hash
, g_str_equal
,
633 for (/* initialized above */ ; node
; node
= sipe_xml_twin(node
)) {
634 const sipe_xml
*attrs
;
635 gchar
*sip_uri
= NULL
;
636 gchar
*displayname
= NULL
;
637 gchar
*company
= NULL
;
638 gchar
*country
= NULL
;
641 for (attrs
= sipe_xml_child(node
, "Attributes/Attribute");
643 attrs
= sipe_xml_twin(attrs
)) {
644 gchar
*name
= sipe_xml_data(sipe_xml_child(attrs
,
646 gchar
*value
= sipe_xml_data(sipe_xml_child(attrs
,
649 if (!is_empty(value
)) {
650 if (sipe_strcase_equal(name
, "msrtcsip-primaryuseraddress")) {
654 } else if (sipe_strcase_equal(name
, "displayname")) {
658 } else if (sipe_strcase_equal(name
, "mail")) {
662 } else if (sipe_strcase_equal(name
, "company")) {
666 } else if (sipe_strcase_equal(name
, "country")) {
677 if (sip_uri
&& !g_hash_table_lookup(found
, sip_uri
)) {
678 gchar
**uri_parts
= g_strsplit(sip_uri
, ":", 2);
679 sipe_backend_search_results_add(SIPE_CORE_PUBLIC
,
686 g_strfreev(uri_parts
);
688 g_hash_table_insert(found
, sip_uri
, (gpointer
) TRUE
);
699 search_contacts_finalize(sipe_private
, results
,
700 g_hash_table_size(found
),
702 g_hash_table_destroy(found
);
706 mdd
->failed_callback(sipe_private
, mdd
);
710 static gboolean
process_search_contact_response(struct sipe_core_private
*sipe_private
,
712 struct transaction
*trans
)
714 struct sipe_backend_search_token
*token
= trans
->payload
->data
;
715 struct sipe_backend_search_results
*results
;
716 sipe_xml
*searchResults
;
717 const sipe_xml
*mrow
;
718 guint match_count
= 0;
719 gboolean more
= FALSE
;
721 /* valid response? */
722 if (msg
->response
!= 200) {
723 SIPE_DEBUG_ERROR("process_search_contact_response: request failed (%d)",
725 sipe_backend_search_failed(SIPE_CORE_PUBLIC
,
727 _("Contact search failed"));
731 SIPE_DEBUG_INFO("process_search_contact_response: body:\n%s", msg
->body
? msg
->body
: "");
734 searchResults
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
735 if (!searchResults
) {
736 SIPE_DEBUG_INFO_NOFORMAT("process_search_contact_response: no parseable searchResults");
737 sipe_backend_search_failed(SIPE_CORE_PUBLIC
,
739 _("Contact search failed"));
744 mrow
= sipe_xml_child(searchResults
, "Body/Array/row");
746 SIPE_DEBUG_ERROR_NOFORMAT("process_search_contact_response: no matches");
747 sipe_backend_search_failed(SIPE_CORE_PUBLIC
,
749 _("No contacts found"));
751 sipe_xml_free(searchResults
);
755 /* OK, we found something - show the results to the user */
756 results
= sipe_backend_search_results_start(SIPE_CORE_PUBLIC
,
757 trans
->payload
->data
);
759 SIPE_DEBUG_ERROR_NOFORMAT("process_search_contact_response: Unable to display the search results.");
760 sipe_backend_search_failed(SIPE_CORE_PUBLIC
,
762 _("Unable to display the search results"));
764 sipe_xml_free(searchResults
);
768 for (/* initialized above */ ; mrow
; mrow
= sipe_xml_twin(mrow
)) {
769 gchar
**uri_parts
= g_strsplit(sipe_xml_attribute(mrow
, "uri"), ":", 2);
770 sipe_backend_search_results_add(SIPE_CORE_PUBLIC
,
773 sipe_xml_attribute(mrow
, "displayName"),
774 sipe_xml_attribute(mrow
, "company"),
775 sipe_xml_attribute(mrow
, "country"),
776 sipe_xml_attribute(mrow
, "email"));
777 g_strfreev(uri_parts
);
781 if ((mrow
= sipe_xml_child(searchResults
, "Body/directorySearch/moreAvailable")) != NULL
) {
782 char *data
= sipe_xml_data(mrow
);
783 more
= (g_ascii_strcasecmp(data
, "true") == 0);
787 search_contacts_finalize(sipe_private
, results
, match_count
, more
);
788 sipe_xml_free(searchResults
);
793 static void search_soap_request(struct sipe_core_private
*sipe_private
,
794 struct sipe_backend_search_token
*token
,
797 gchar
*query
= prepare_buddy_search_query(search_rows
, FALSE
);
798 struct transaction_payload
*payload
= g_new0(struct transaction_payload
, 1);
800 payload
->data
= token
;
802 sip_soap_directory_search(sipe_private
,
805 process_search_contact_response
,
810 static void search_ab_entry_failed(struct sipe_core_private
*sipe_private
,
811 struct ms_dlx_data
*mdd
)
813 /* error using [MS-DLX] server, retry using Active Directory */
814 search_soap_request(sipe_private
, mdd
->token
, mdd
->search_rows
);
818 void sipe_core_buddy_search(struct sipe_core_public
*sipe_public
,
819 struct sipe_backend_search_token
*token
,
820 const gchar
*given_name
,
821 const gchar
*surname
,
823 const gchar
*company
,
824 const gchar
*country
)
826 GSList
*query_rows
= NULL
;
828 #define ADD_QUERY_ROW(attr, val) \
830 query_rows = g_slist_append(query_rows, g_strdup(attr)); \
831 query_rows = g_slist_append(query_rows, g_strdup(val)); \
834 ADD_QUERY_ROW("givenName", given_name
);
835 ADD_QUERY_ROW("sn", surname
);
836 ADD_QUERY_ROW("mail", email
);
837 ADD_QUERY_ROW("company", company
);
838 ADD_QUERY_ROW("c", country
);
841 if (SIPE_CORE_PRIVATE
->dlx_uri
!= NULL
) {
842 struct ms_dlx_data
*mdd
= g_new0(struct ms_dlx_data
, 1);
844 mdd
->search_rows
= query_rows
;
845 mdd
->max_returns
= 100;
846 mdd
->callback
= search_ab_entry_response
;
847 mdd
->failed_callback
= search_ab_entry_failed
;
848 mdd
->session
= sipe_svc_session_start();
851 ms_dlx_webticket_request(SIPE_CORE_PRIVATE
, mdd
);
854 /* no [MS-DLX] server, use Active Directory search instead */
855 search_soap_request(SIPE_CORE_PRIVATE
, token
, query_rows
);
856 sipe_utils_slist_free_full(query_rows
, g_free
);
859 sipe_backend_search_failed(sipe_public
,
861 _("Invalid contact search query"));
864 static void get_info_finalize(struct sipe_core_private
*sipe_private
,
865 struct sipe_backend_buddy_info
*info
,
867 const gchar
*server_alias
,
870 sipe_backend_buddy bbuddy
;
871 struct sipe_buddy
*sbuddy
;
876 info
= sipe_backend_buddy_info_start(SIPE_CORE_PUBLIC
);
878 sipe_backend_buddy_info_break(SIPE_CORE_PUBLIC
, info
);
883 bbuddy
= sipe_backend_buddy_find(SIPE_CORE_PUBLIC
, uri
, NULL
);
885 if (is_empty(server_alias
)) {
886 value
= sipe_backend_buddy_get_server_alias(SIPE_CORE_PUBLIC
,
889 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
891 SIPE_BUDDY_INFO_DISPLAY_NAME
,
895 value
= g_strdup(server_alias
);
898 /* present alias if it differs from server alias */
899 alias
= sipe_backend_buddy_get_local_alias(SIPE_CORE_PUBLIC
, bbuddy
);
900 if (alias
&& !sipe_strequal(alias
, value
))
902 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
904 SIPE_BUDDY_INFO_ALIAS
,
910 if (is_empty(email
)) {
911 value
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
913 SIPE_BUDDY_INFO_EMAIL
);
915 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
917 SIPE_BUDDY_INFO_EMAIL
,
923 value
= sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC
,
925 SIPE_BUDDY_INFO_SITE
);
927 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
929 SIPE_BUDDY_INFO_SITE
,
934 sbuddy
= g_hash_table_lookup(sipe_private
->buddies
, uri
);
935 if (sbuddy
&& sbuddy
->device_name
) {
936 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
938 SIPE_BUDDY_INFO_DEVICE
,
939 sbuddy
->device_name
);
942 sipe_backend_buddy_info_finalize(SIPE_CORE_PUBLIC
, info
, uri
);
946 static void get_info_ab_entry_response(struct sipe_core_private
*sipe_private
,
948 SIPE_UNUSED_PARAMETER
const gchar
*raw
,
950 gpointer callback_data
)
952 struct ms_dlx_data
*mdd
= callback_data
;
953 struct sipe_backend_buddy_info
*info
= NULL
;
954 gchar
*server_alias
= NULL
;
958 const sipe_xml
*node
;
960 SIPE_DEBUG_INFO("get_info_ab_entry_response: received valid SOAP message from service %s",
963 info
= sipe_backend_buddy_info_start(SIPE_CORE_PUBLIC
);
965 for (node
= sipe_xml_child(soap_body
, "Body/SearchAbEntryResponse/SearchAbEntryResult/Items/AbEntry/Attributes/Attribute");
967 node
= sipe_xml_twin(node
)) {
968 gchar
*name
= sipe_xml_data(sipe_xml_child(node
,
970 gchar
*value
= sipe_xml_data(sipe_xml_child(node
,
972 const sipe_xml
*values
= sipe_xml_child(node
,
975 /* Single value entries */
976 if (!is_empty(value
)) {
978 if (sipe_strcase_equal(name
, "displayname")) {
979 g_free(server_alias
);
980 server_alias
= value
;
982 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
984 SIPE_BUDDY_INFO_DISPLAY_NAME
,
986 } else if (sipe_strcase_equal(name
, "mail")) {
990 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
992 SIPE_BUDDY_INFO_EMAIL
,
994 } else if (sipe_strcase_equal(name
, "title")) {
995 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
997 SIPE_BUDDY_INFO_JOB_TITLE
,
999 } else if (sipe_strcase_equal(name
, "company")) {
1000 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1002 SIPE_BUDDY_INFO_COMPANY
,
1004 } else if (sipe_strcase_equal(name
, "country")) {
1005 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1007 SIPE_BUDDY_INFO_COUNTRY
,
1011 } else if (values
) {
1012 gchar
*first
= sipe_xml_data(sipe_xml_child(values
,
1015 if (sipe_strcase_equal(name
, "telephonenumber")) {
1016 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1018 SIPE_BUDDY_INFO_WORK_PHONE
,
1030 /* this will show the minmum information */
1031 get_info_finalize(sipe_private
,
1038 g_free(server_alias
);
1042 static gboolean
process_get_info_response(struct sipe_core_private
*sipe_private
,
1044 struct transaction
*trans
)
1046 const gchar
*uri
= trans
->payload
->data
;
1047 struct sipe_backend_buddy_info
*info
= NULL
;
1048 gchar
*server_alias
= NULL
;
1049 gchar
*email
= NULL
;
1051 SIPE_DEBUG_INFO("Fetching %s's user info for %s",
1052 uri
, sipe_private
->username
);
1054 if (msg
->response
!= 200) {
1055 SIPE_DEBUG_INFO("process_get_info_response: SERVICE response is %d", msg
->response
);
1057 sipe_xml
*searchResults
;
1058 const sipe_xml
*mrow
;
1060 SIPE_DEBUG_INFO("process_get_info_response: body:\n%s",
1061 msg
->body
? msg
->body
: "");
1063 searchResults
= sipe_xml_parse(msg
->body
, msg
->bodylen
);
1064 if (!searchResults
) {
1066 SIPE_DEBUG_INFO_NOFORMAT("process_get_info_response: no parseable searchResults");
1068 } else if ((mrow
= sipe_xml_child(searchResults
, "Body/Array/row"))) {
1070 gchar
*phone_number
;
1072 info
= sipe_backend_buddy_info_start(SIPE_CORE_PUBLIC
);
1074 server_alias
= g_strdup(sipe_xml_attribute(mrow
, "displayName"));
1075 email
= g_strdup(sipe_xml_attribute(mrow
, "email"));
1076 phone_number
= g_strdup(sipe_xml_attribute(mrow
, "phone"));
1079 * For 2007 system we will take this from ContactCard -
1080 * it has cleaner tel: URIs at least
1082 if (!SIPE_CORE_PRIVATE_FLAG_IS(OCS2007
)) {
1083 char *tel_uri
= sip_to_tel_uri(phone_number
);
1084 /* trims its parameters, so call first */
1085 sipe_buddy_update_property(sipe_private
, uri
, SIPE_BUDDY_INFO_DISPLAY_NAME
, server_alias
);
1086 sipe_buddy_update_property(sipe_private
, uri
, SIPE_BUDDY_INFO_EMAIL
, email
);
1087 sipe_buddy_update_property(sipe_private
, uri
, SIPE_BUDDY_INFO_WORK_PHONE
, tel_uri
);
1088 sipe_buddy_update_property(sipe_private
, uri
, SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY
, phone_number
);
1091 sipe_backend_buddy_refresh_properties(SIPE_CORE_PUBLIC
,
1095 if (!is_empty(server_alias
)) {
1096 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1098 SIPE_BUDDY_INFO_DISPLAY_NAME
,
1101 if ((value
= sipe_xml_attribute(mrow
, "title")) && strlen(value
) > 0) {
1102 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1104 SIPE_BUDDY_INFO_JOB_TITLE
,
1107 if ((value
= sipe_xml_attribute(mrow
, "office")) && strlen(value
) > 0) {
1108 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1110 SIPE_BUDDY_INFO_OFFICE
,
1113 if (!is_empty(phone_number
)) {
1114 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1116 SIPE_BUDDY_INFO_WORK_PHONE
,
1119 g_free(phone_number
);
1120 if ((value
= sipe_xml_attribute(mrow
, "company")) && strlen(value
) > 0) {
1121 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1123 SIPE_BUDDY_INFO_COMPANY
,
1126 if ((value
= sipe_xml_attribute(mrow
, "city")) && strlen(value
) > 0) {
1127 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1129 SIPE_BUDDY_INFO_CITY
,
1132 if ((value
= sipe_xml_attribute(mrow
, "state")) && strlen(value
) > 0) {
1133 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1135 SIPE_BUDDY_INFO_STATE
,
1138 if ((value
= sipe_xml_attribute(mrow
, "country")) && strlen(value
) > 0) {
1139 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1141 SIPE_BUDDY_INFO_COUNTRY
,
1144 if (!is_empty(email
)) {
1145 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC
,
1147 SIPE_BUDDY_INFO_EMAIL
,
1151 sipe_xml_free(searchResults
);
1154 /* this will show the minmum information */
1155 get_info_finalize(sipe_private
,
1161 g_free(server_alias
);
1167 static void get_info_ab_entry_failed(struct sipe_core_private
*sipe_private
,
1168 struct ms_dlx_data
*mdd
)
1170 /* error using [MS-DLX] server, retry using Active Directory */
1171 gchar
*query
= prepare_buddy_search_query(mdd
->search_rows
, FALSE
);
1172 struct transaction_payload
*payload
= g_new0(struct transaction_payload
, 1);
1174 payload
->destroy
= g_free
;
1175 payload
->data
= mdd
->other
;
1178 sip_soap_directory_search(sipe_private
,
1181 process_get_info_response
,
1188 void sipe_core_buddy_get_info(struct sipe_core_public
*sipe_public
,
1191 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
1193 if (sipe_private
->dlx_uri
) {
1194 struct ms_dlx_data
*mdd
= g_new0(struct ms_dlx_data
, 1);
1196 mdd
->search_rows
= g_slist_append(mdd
->search_rows
, g_strdup("msRTCSIP-PrimaryUserAddress"));
1197 mdd
->search_rows
= g_slist_append(mdd
->search_rows
, g_strdup(who
));
1199 mdd
->other
= g_strdup(who
);
1200 mdd
->max_returns
= 1;
1201 mdd
->callback
= get_info_ab_entry_response
;
1202 mdd
->failed_callback
= get_info_ab_entry_failed
;
1203 mdd
->session
= sipe_svc_session_start();
1205 ms_dlx_webticket_request(sipe_private
, mdd
);
1208 /* no [MS-DLX] server, use Active Directory search instead */
1209 gchar
*row
= g_markup_printf_escaped(SIPE_SOAP_SEARCH_ROW
,
1210 "msRTCSIP-PrimaryUserAddress",
1212 struct transaction_payload
*payload
= g_new0(struct transaction_payload
, 1);
1214 SIPE_DEBUG_INFO("sipe_core_buddy_get_info: row: %s",
1217 payload
->destroy
= g_free
;
1218 payload
->data
= g_strdup(who
);
1220 sip_soap_directory_search(sipe_private
,
1223 process_get_info_response
,
1229 static void photo_response_data_free(struct photo_response_data
*data
)
1232 g_free(data
->photo_hash
);
1233 if (data
->request
) {
1234 sipe_http_request_cancel(data
->request
);
1239 static void process_buddy_photo_response(struct sipe_core_private
*sipe_private
,
1245 struct photo_response_data
*rdata
= (struct photo_response_data
*) data
;
1247 rdata
->request
= NULL
;
1249 if (status
== SIPE_HTTP_STATUS_OK
) {
1250 const gchar
*len_str
= sipe_utils_nameval_find(headers
,
1253 gsize photo_size
= atoi(len_str
);
1254 gpointer photo
= g_new(char, photo_size
);
1257 memcpy(photo
, body
, photo_size
);
1259 sipe_backend_buddy_set_photo(SIPE_CORE_PUBLIC
,
1268 sipe_private
->pending_photo_requests
=
1269 g_slist_remove(sipe_private
->pending_photo_requests
, rdata
);
1271 photo_response_data_free(rdata
);
1274 static gchar
*create_x_ms_webticket_header(const gchar
*wsse_security
)
1276 gchar
*assertion
= sipe_xml_extract_raw(wsse_security
, "saml:Assertion", TRUE
);
1277 gchar
*wsse_security_base64
;
1278 gchar
*x_ms_webticket_header
;
1284 wsse_security_base64
= g_base64_encode((const guchar
*)assertion
,
1286 x_ms_webticket_header
= g_strdup_printf("X-MS-WebTicket: opaque=%s\r\n",
1287 wsse_security_base64
);
1290 g_free(wsse_security_base64
);
1292 return x_ms_webticket_header
;
1295 static void get_photo_ab_entry_response(struct sipe_core_private
*sipe_private
,
1297 SIPE_UNUSED_PARAMETER
const gchar
*raw
,
1298 sipe_xml
*soap_body
,
1299 gpointer callback_data
)
1301 struct ms_dlx_data
*mdd
= callback_data
;
1302 gchar
*photo_rel_path
= NULL
;
1303 gchar
*photo_hash
= NULL
;
1304 const gchar
*photo_hash_old
=
1305 sipe_backend_buddy_get_photo_hash(SIPE_CORE_PUBLIC
, mdd
->other
);
1308 const sipe_xml
*node
;
1310 SIPE_DEBUG_INFO("get_photo_ab_entry_response: received valid SOAP message from service %s",
1313 for (node
= sipe_xml_child(soap_body
, "Body/SearchAbEntryResponse/SearchAbEntryResult/Items/AbEntry/Attributes/Attribute");
1315 node
= sipe_xml_twin(node
)) {
1316 gchar
*name
= sipe_xml_data(sipe_xml_child(node
, "Name"));
1317 gchar
*value
= sipe_xml_data(sipe_xml_child(node
, "Value"));
1319 if (!is_empty(value
)) {
1320 if (sipe_strcase_equal(name
, "PhotoRelPath")) {
1321 g_free(photo_rel_path
);
1322 photo_rel_path
= value
;
1324 } else if (sipe_strcase_equal(name
, "PhotoHash")) {
1336 if (sipe_private
->addressbook_uri
&& photo_rel_path
&&
1337 photo_hash
&& !sipe_strequal(photo_hash
, photo_hash_old
)) {
1338 gchar
*photo_url
= g_strdup_printf("%s/%s",
1339 sipe_private
->addressbook_uri
, photo_rel_path
);
1340 gchar
*x_ms_webticket_header
= create_x_ms_webticket_header(mdd
->wsse_security
);
1342 struct photo_response_data
*data
= g_new(struct photo_response_data
, 1);
1343 data
->who
= g_strdup(mdd
->other
);
1344 data
->photo_hash
= photo_hash
;
1347 data
->request
= sipe_http_request_get(sipe_private
,
1349 x_ms_webticket_header
,
1350 process_buddy_photo_response
,
1353 if (data
->request
) {
1354 sipe_private
->pending_photo_requests
=
1355 g_slist_append(sipe_private
->pending_photo_requests
, data
);
1356 sipe_http_request_ready(data
->request
);
1358 photo_response_data_free(data
);
1361 g_free(x_ms_webticket_header
);
1365 g_free(photo_rel_path
);
1370 static void get_photo_ab_entry_failed(SIPE_UNUSED_PARAMETER
struct sipe_core_private
*sipe_private
,
1371 struct ms_dlx_data
*mdd
)
1376 static void buddy_fetch_photo(struct sipe_core_private
*sipe_private
,
1379 if (sipe_backend_uses_photo() &&
1380 sipe_private
->dlx_uri
&& sipe_private
->addressbook_uri
) {
1381 struct ms_dlx_data
*mdd
= g_new0(struct ms_dlx_data
, 1);
1383 mdd
->search_rows
= g_slist_append(mdd
->search_rows
, g_strdup("msRTCSIP-PrimaryUserAddress"));
1384 mdd
->search_rows
= g_slist_append(mdd
->search_rows
, g_strdup(uri
));
1386 mdd
->other
= g_strdup(uri
);
1387 mdd
->max_returns
= 1;
1388 mdd
->callback
= get_photo_ab_entry_response
;
1389 mdd
->failed_callback
= get_photo_ab_entry_failed
;
1390 mdd
->session
= sipe_svc_session_start();
1392 ms_dlx_webticket_request(sipe_private
, mdd
);
1396 static void buddy_refresh_photos_cb(gpointer uri
,
1397 SIPE_UNUSED_PARAMETER gpointer value
,
1398 gpointer sipe_private
)
1400 buddy_fetch_photo(sipe_private
, uri
);
1403 void sipe_buddy_refresh_photos(struct sipe_core_private
*sipe_private
)
1405 g_hash_table_foreach(sipe_private
->buddies
,
1406 buddy_refresh_photos_cb
,
1410 /* Buddy menu callbacks*/
1412 void sipe_core_buddy_new_chat(struct sipe_core_public
*sipe_public
,
1415 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
1417 /* 2007+ conference */
1418 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007
)) {
1419 sipe_conf_add(sipe_private
, who
);
1421 /* 2005- multiparty chat */
1423 gchar
*self
= sip_uri_self(sipe_private
);
1424 struct sip_session
*session
;
1426 session
= sipe_session_add_chat(sipe_private
,
1430 session
->chat_session
->backend
= sipe_backend_chat_create(SIPE_CORE_PUBLIC
,
1431 session
->chat_session
,
1432 session
->chat_session
->title
,
1436 sipe_im_invite(sipe_private
, session
, who
,
1437 NULL
, NULL
, NULL
, FALSE
);
1441 void sipe_core_buddy_send_email(struct sipe_core_public
*sipe_public
,
1444 sipe_backend_buddy buddy
= sipe_backend_buddy_find(sipe_public
,
1447 gchar
*email
= sipe_backend_buddy_get_string(sipe_public
,
1449 SIPE_BUDDY_INFO_EMAIL
);
1452 gchar
*command_line
= g_strdup_printf(
1458 " mailto:%s", email
);
1461 SIPE_DEBUG_INFO("sipe_core_buddy_send_email: going to call email client: %s",
1463 g_spawn_command_line_async(command_line
, NULL
);
1464 g_free(command_line
);
1467 SIPE_DEBUG_INFO("sipe_core_buddy_send_email: no email address stored for buddy=%s",
1474 static struct sipe_backend_buddy_menu
*buddy_menu_phone(struct sipe_core_public
*sipe_public
,
1475 struct sipe_backend_buddy_menu
*menu
,
1476 sipe_backend_buddy buddy
,
1477 sipe_buddy_info_fields id_phone
,
1478 sipe_buddy_info_fields id_display
,
1481 gchar
*phone
= sipe_backend_buddy_get_string(sipe_public
,
1485 gchar
*display
= sipe_backend_buddy_get_string(sipe_public
,
1489 gchar
*label
= g_strdup_printf("%s %s",
1492 (tmp
= sip_tel_uri_denormalize(phone
)));
1493 menu
= sipe_backend_buddy_menu_add(sipe_public
,
1496 SIPE_BUDDY_MENU_MAKE_CALL
,
1507 struct sipe_backend_buddy_menu
*sipe_core_buddy_create_menu(struct sipe_core_public
*sipe_public
,
1508 const gchar
*buddy_name
,
1509 struct sipe_backend_buddy_menu
*menu
)
1511 struct sipe_core_private
*sipe_private
= SIPE_CORE_PRIVATE
;
1512 sipe_backend_buddy buddy
= sipe_backend_buddy_find(sipe_public
,
1515 gchar
*self
= sip_uri_self(sipe_private
);
1517 SIPE_SESSION_FOREACH
{
1518 if (!sipe_strcase_equal(self
, buddy_name
) && session
->chat_session
)
1520 struct sipe_chat_session
*chat_session
= session
->chat_session
;
1521 gboolean is_conf
= (chat_session
->type
== SIPE_CHAT_TYPE_CONFERENCE
);
1523 if (sipe_backend_chat_find(chat_session
->backend
, buddy_name
))
1525 gboolean conf_op
= sipe_backend_chat_is_operator(chat_session
->backend
, self
);
1529 !sipe_backend_chat_is_operator(chat_session
->backend
, buddy_name
) &&
1530 /* We are a conf OP */
1532 gchar
*label
= g_strdup_printf(_("Make leader of '%s'"),
1533 chat_session
->title
);
1534 menu
= sipe_backend_buddy_menu_add(sipe_public
,
1537 SIPE_BUDDY_MENU_MAKE_CHAT_LEADER
,
1543 /* We are a conf OP */
1545 gchar
*label
= g_strdup_printf(_("Remove from '%s'"),
1546 chat_session
->title
);
1547 menu
= sipe_backend_buddy_menu_add(sipe_public
,
1550 SIPE_BUDDY_MENU_REMOVE_FROM_CHAT
,
1558 (is_conf
&& !session
->locked
)) {
1559 gchar
*label
= g_strdup_printf(_("Invite to '%s'"),
1560 chat_session
->title
);
1561 menu
= sipe_backend_buddy_menu_add(sipe_public
,
1564 SIPE_BUDDY_MENU_INVITE_TO_CHAT
,
1570 } SIPE_SESSION_FOREACH_END
;
1573 menu
= sipe_backend_buddy_menu_add(sipe_public
,
1576 SIPE_BUDDY_MENU_NEW_CHAT
,
1579 /* add buddy's phone numbers if we have call control */
1580 if (sip_csta_is_idle(sipe_private
)) {
1583 menu
= buddy_menu_phone(sipe_public
,
1586 SIPE_BUDDY_INFO_WORK_PHONE
,
1587 SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY
,
1590 menu
= buddy_menu_phone(sipe_public
,
1593 SIPE_BUDDY_INFO_MOBILE_PHONE
,
1594 SIPE_BUDDY_INFO_MOBILE_PHONE_DISPLAY
,
1598 menu
= buddy_menu_phone(sipe_public
,
1601 SIPE_BUDDY_INFO_HOME_PHONE
,
1602 SIPE_BUDDY_INFO_HOME_PHONE_DISPLAY
,
1606 menu
= buddy_menu_phone(sipe_public
,
1609 SIPE_BUDDY_INFO_OTHER_PHONE
,
1610 SIPE_BUDDY_INFO_OTHER_PHONE_DISPLAY
,
1614 menu
= buddy_menu_phone(sipe_public
,
1617 SIPE_BUDDY_INFO_CUSTOM1_PHONE
,
1618 SIPE_BUDDY_INFO_CUSTOM1_PHONE_DISPLAY
,
1623 gchar
*email
= sipe_backend_buddy_get_string(sipe_public
,
1625 SIPE_BUDDY_INFO_EMAIL
);
1627 menu
= sipe_backend_buddy_menu_add(sipe_public
,
1630 SIPE_BUDDY_MENU_SEND_EMAIL
,
1636 /* access level control */
1637 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007
))
1638 menu
= sipe_backend_buddy_sub_menu_add(sipe_public
,
1641 sipe_ocs2007_access_control_menu(sipe_private
,