buddy: use sipe_ucs_get_photo() only when contact list has been migrated
[siplcs.git] / src / core / sipe-buddy.c
blob7467177e670e251f064ae3c6399259d09ae4d27f
1 /**
2 * @file sipe-buddy.c
4 * pidgin-sipe
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
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 #include <stdlib.h>
28 #include <string.h>
29 #include <time.h>
31 #include <glib.h>
33 #include "sipe-common.h"
34 #include "sipmsg.h"
35 #include "sip-csta.h"
36 #include "sip-soap.h"
37 #include "sip-transport.h"
38 #include "sipe-backend.h"
39 #include "sipe-buddy.h"
40 #include "sipe-cal.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"
47 #include "sipe-im.h"
48 #include "sipe-nls.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"
55 #include "sipe-svc.h"
56 #include "sipe-ucs.h"
57 #include "sipe-utils.h"
58 #include "sipe-webticket.h"
59 #include "sipe-xml.h"
61 struct sipe_buddies {
62 GHashTable *uri;
63 GHashTable *exchange_key;
65 /* Pending photo download HTTP requests */
66 GSList *pending_photo_requests;
69 struct buddy_group_data {
70 const struct sipe_group *group;
71 gboolean is_obsolete;
74 struct photo_response_data {
75 gchar *who;
76 gchar *photo_hash;
77 struct sipe_http_request *request;
80 static void buddy_fetch_photo(struct sipe_core_private *sipe_private,
81 const gchar *uri);
82 static void photo_response_data_free(struct photo_response_data *data);
84 void sipe_buddy_add_keys(struct sipe_core_private *sipe_private,
85 struct sipe_buddy *buddy,
86 const gchar *exchange_key,
87 const gchar *change_key)
89 if (exchange_key) {
90 buddy->exchange_key = g_strdup(exchange_key);
91 g_hash_table_insert(sipe_private->buddies->exchange_key,
92 buddy->exchange_key,
93 buddy);
95 if (change_key)
96 buddy->change_key = g_strdup(change_key);
99 struct sipe_buddy *sipe_buddy_add(struct sipe_core_private *sipe_private,
100 const gchar *uri,
101 const gchar *exchange_key,
102 const gchar *change_key)
104 /* Buddy name must be lower case as we use purple_normalize_nocase() to compare */
105 gchar *normalized_uri = g_ascii_strdown(uri, -1);
106 struct sipe_buddy *buddy = sipe_buddy_find_by_uri(sipe_private,
107 normalized_uri);
109 if (!buddy) {
110 buddy = g_new0(struct sipe_buddy, 1);
111 buddy->name = normalized_uri;
112 g_hash_table_insert(sipe_private->buddies->uri,
113 buddy->name,
114 buddy);
116 sipe_buddy_add_keys(sipe_private,
117 buddy,
118 exchange_key,
119 change_key);
121 SIPE_DEBUG_INFO("sipe_buddy_add: Added buddy %s", normalized_uri);
123 if (SIPE_CORE_PRIVATE_FLAG_IS(SUBSCRIBED_BUDDIES)) {
124 buddy->just_added = TRUE;
125 sipe_subscribe_presence_single_cb(sipe_private,
126 buddy->name);
129 buddy_fetch_photo(sipe_private, normalized_uri);
131 normalized_uri = NULL; /* buddy takes ownership */
132 } else {
133 SIPE_DEBUG_INFO("sipe_buddy_add: Buddy %s already exists", normalized_uri);
134 buddy->is_obsolete = FALSE;
136 g_free(normalized_uri);
138 return(buddy);
141 static gboolean is_buddy_in_group(struct sipe_buddy *buddy,
142 const gchar *name)
144 if (buddy) {
145 GSList *entry = buddy->groups;
147 while (entry) {
148 struct buddy_group_data *bgd = entry->data;
149 if (sipe_strequal(bgd->group->name, name)) {
150 bgd->is_obsolete = FALSE;
151 return(TRUE);
153 entry = entry->next;
157 return(FALSE);
160 void sipe_buddy_add_to_group(struct sipe_core_private *sipe_private,
161 struct sipe_buddy *buddy,
162 struct sipe_group *group,
163 const gchar *alias)
165 const gchar *uri = buddy->name;
166 const gchar *group_name = group->name;
167 sipe_backend_buddy bb = sipe_backend_buddy_find(SIPE_CORE_PUBLIC,
168 uri,
169 group_name);
171 if (!bb) {
172 bb = sipe_backend_buddy_add(SIPE_CORE_PUBLIC,
173 uri,
174 alias,
175 group_name);
176 SIPE_DEBUG_INFO("sipe_buddy_add_to_group: created backend buddy '%s' with alias '%s'",
177 uri, alias ? alias : "<NONE>");
181 if (!is_empty(alias)) {
182 gchar *old_alias = sipe_backend_buddy_get_alias(SIPE_CORE_PUBLIC,
183 bb);
185 if (sipe_strcase_equal(sipe_get_no_sip_uri(uri),
186 old_alias)) {
187 sipe_backend_buddy_set_alias(SIPE_CORE_PUBLIC,
189 alias);
190 SIPE_DEBUG_INFO("sipe_buddy_add_to_group: replaced alias for buddy '%s': old '%s' new '%s'",
191 uri, old_alias, alias);
193 g_free(old_alias);
196 if (!is_buddy_in_group(buddy, group_name)) {
197 sipe_buddy_insert_group(buddy, group);
198 SIPE_DEBUG_INFO("sipe_buddy_add_to_group: added buddy %s to group %s",
199 uri, group_name);
203 static gint buddy_group_compare(gconstpointer a, gconstpointer b)
205 return(((const struct buddy_group_data *)a)->group->id -
206 ((const struct buddy_group_data *)b)->group->id);
209 void sipe_buddy_insert_group(struct sipe_buddy *buddy,
210 struct sipe_group *group)
212 struct buddy_group_data *bgd = g_new0(struct buddy_group_data, 1);
214 bgd->group = group;
216 buddy->groups = sipe_utils_slist_insert_unique_sorted(buddy->groups,
217 bgd,
218 buddy_group_compare,
219 NULL);
222 static void buddy_group_free(gpointer data)
224 g_free(data);
227 static void buddy_group_remove(struct sipe_buddy *buddy,
228 struct buddy_group_data *bgd)
230 buddy->groups = g_slist_remove(buddy->groups, bgd);
231 buddy_group_free(bgd);
234 static void sipe_buddy_remove_group(struct sipe_buddy *buddy,
235 const struct sipe_group *group)
237 GSList *entry = buddy->groups;
238 struct buddy_group_data *bgd = NULL;
240 while (entry) {
241 bgd = entry->data;
242 if (bgd->group == group)
243 break;
244 entry = entry->next;
247 buddy_group_remove(buddy, bgd);
250 void sipe_buddy_update_groups(struct sipe_core_private *sipe_private,
251 struct sipe_buddy *buddy,
252 GSList *new_groups)
254 const gchar *uri = buddy->name;
255 GSList *entry = buddy->groups;
257 while (entry) {
258 struct buddy_group_data *bgd = entry->data;
259 const struct sipe_group *group = bgd->group;
261 /* next buddy group */
262 entry = entry->next;
264 /* old group NOT found in new list? */
265 if (g_slist_find(new_groups, group) == NULL) {
266 sipe_backend_buddy oldb = sipe_backend_buddy_find(SIPE_CORE_PUBLIC,
267 uri,
268 group->name);
269 SIPE_DEBUG_INFO("sipe_buddy_update_groups: removing buddy %s from group '%s'",
270 uri, group->name);
271 /* this should never be NULL */
272 if (oldb)
273 sipe_backend_buddy_remove(SIPE_CORE_PUBLIC,
274 oldb);
275 buddy_group_remove(buddy, bgd);
280 gchar *sipe_buddy_groups_string(struct sipe_buddy *buddy)
282 guint i = 0;
283 gchar *string;
284 /* creating array from GList, converting guint to gchar * */
285 gchar **ids_arr = g_new(gchar *, g_slist_length(buddy->groups) + 1);
286 GSList *entry = buddy->groups;
288 if (!ids_arr)
289 return(NULL);
291 while (entry) {
292 const struct sipe_group *group = ((struct buddy_group_data *) entry->data)->group;
293 ids_arr[i] = g_strdup_printf("%u", group->id);
294 entry = entry->next;
295 i++;
297 ids_arr[i] = NULL;
299 string = g_strjoinv(" ", ids_arr);
300 g_strfreev(ids_arr);
302 return(string);
305 void sipe_buddy_cleanup_local_list(struct sipe_core_private *sipe_private)
307 GSList *buddies = sipe_backend_buddy_find_all(SIPE_CORE_PUBLIC,
308 NULL,
309 NULL);
310 GSList *entry = buddies;
312 SIPE_DEBUG_INFO("sipe_buddy_cleanup_local_list: overall %d backend buddies (including clones)",
313 g_slist_length(buddies));
314 SIPE_DEBUG_INFO("sipe_buddy_cleanup_local_list: %d sipe buddies (unique)",
315 sipe_buddy_count(sipe_private));
316 while (entry) {
317 sipe_backend_buddy bb = entry->data;
318 gchar *bname = sipe_backend_buddy_get_name(SIPE_CORE_PUBLIC,
319 bb);
320 gchar *gname = sipe_backend_buddy_get_group_name(SIPE_CORE_PUBLIC,
321 bb);
322 struct sipe_buddy *buddy = sipe_buddy_find_by_uri(sipe_private,
323 bname);
325 if (!is_buddy_in_group(buddy, gname)) {
326 SIPE_DEBUG_INFO("sipe_buddy_cleanup_local_list: REMOVING '%s' from local group '%s', as buddy is not in that group on remote contact list",
327 bname, gname);
328 sipe_backend_buddy_remove(SIPE_CORE_PUBLIC, bb);
331 g_free(gname);
332 g_free(bname);
334 entry = entry->next;
337 g_slist_free(buddies);
340 struct sipe_buddy *sipe_buddy_find_by_uri(struct sipe_core_private *sipe_private,
341 const gchar *uri)
343 return(g_hash_table_lookup(sipe_private->buddies->uri, uri));
346 struct sipe_buddy *sipe_buddy_find_by_exchange_key(struct sipe_core_private *sipe_private,
347 const gchar *exchange_key)
349 return(g_hash_table_lookup(sipe_private->buddies->exchange_key,
350 exchange_key));
353 void sipe_buddy_foreach(struct sipe_core_private *sipe_private,
354 GHFunc callback,
355 gpointer callback_data)
357 g_hash_table_foreach(sipe_private->buddies->uri,
358 callback,
359 callback_data);
362 static void buddy_free(struct sipe_buddy *buddy)
364 #ifndef _WIN32
366 * We are calling g_hash_table_foreach_steal(). That means that no
367 * key/value deallocation functions are called. Therefore the glib
368 * hash code does not touch the key (buddy->name) or value (buddy)
369 * of the to-be-deleted hash node at all. It follows that we
371 * - MUST free the memory for the key ourselves and
372 * - ARE allowed to do it in this function
374 * Conclusion: glib must be broken on the Windows platform if sipe
375 * crashes with SIGTRAP when closing. You'll have to live
376 * with the memory leak until this is fixed.
378 g_free(buddy->name);
379 #endif
380 g_free(buddy->exchange_key);
381 g_free(buddy->change_key);
382 g_free(buddy->activity);
383 g_free(buddy->meeting_subject);
384 g_free(buddy->meeting_location);
385 g_free(buddy->note);
387 g_free(buddy->cal_start_time);
388 g_free(buddy->cal_free_busy_base64);
389 g_free(buddy->cal_free_busy);
390 g_free(buddy->last_non_cal_activity);
392 sipe_cal_free_working_hours(buddy->cal_working_hours);
394 g_free(buddy->device_name);
395 sipe_utils_slist_free_full(buddy->groups, buddy_group_free);
396 g_free(buddy);
399 static gboolean buddy_free_cb(SIPE_UNUSED_PARAMETER gpointer key,
400 gpointer buddy,
401 SIPE_UNUSED_PARAMETER gpointer user_data)
403 buddy_free(buddy);
404 /* We must return TRUE as the key/value have already been deleted */
405 return(TRUE);
408 void sipe_buddy_free(struct sipe_core_private *sipe_private)
410 struct sipe_buddies *buddies = sipe_private->buddies;
412 g_hash_table_foreach_steal(buddies->uri,
413 buddy_free_cb,
414 NULL);
416 /* core is being deallocated, remove all its pending photo requests */
417 while (buddies->pending_photo_requests) {
418 struct photo_response_data *data =
419 buddies->pending_photo_requests->data;
420 buddies->pending_photo_requests =
421 g_slist_remove(buddies->pending_photo_requests, data);
422 photo_response_data_free(data);
425 g_hash_table_destroy(buddies->uri);
426 g_hash_table_destroy(buddies->exchange_key);
427 g_free(buddies);
428 sipe_private->buddies = NULL;
431 static void buddy_set_obsolete_flag(SIPE_UNUSED_PARAMETER gpointer key,
432 gpointer value,
433 SIPE_UNUSED_PARAMETER gpointer user_data)
435 struct sipe_buddy *buddy = value;
436 GSList *entry = buddy->groups;
438 buddy->is_obsolete = TRUE;
439 while (entry) {
440 ((struct buddy_group_data *) entry->data)->is_obsolete = TRUE;
441 entry = entry->next;
445 void sipe_buddy_update_start(struct sipe_core_private *sipe_private)
447 g_hash_table_foreach(sipe_private->buddies->uri,
448 buddy_set_obsolete_flag,
449 NULL);
452 static gboolean buddy_check_obsolete_flag(SIPE_UNUSED_PARAMETER gpointer key,
453 gpointer value,
454 gpointer user_data)
456 struct sipe_core_private *sipe_private = user_data;
457 struct sipe_buddy *buddy = value;
458 const gchar *uri = buddy->name;
460 if (buddy->is_obsolete) {
461 /* all backend buddies in different groups */
462 GSList *buddies = sipe_backend_buddy_find_all(SIPE_CORE_PUBLIC,
463 uri,
464 NULL);
465 GSList *entry = buddies;
467 SIPE_DEBUG_INFO("buddy_check_obsolete_flag: REMOVING %d backend buddies for '%s'",
468 g_slist_length(buddies),
469 uri);
471 while (entry) {
472 sipe_backend_buddy_remove(SIPE_CORE_PUBLIC,
473 entry->data);
474 entry = entry->next;
476 g_slist_free(buddies);
478 buddy_free(buddy);
479 /* return TRUE as the key/value have already been deleted */
480 return(TRUE);
482 } else {
483 GSList *entry = buddy->groups;
485 while (entry) {
486 struct buddy_group_data *bgd = entry->data;
488 /* next buddy group */
489 entry = entry->next;
491 if (bgd->is_obsolete) {
492 const struct sipe_group *group = bgd->group;
493 sipe_backend_buddy oldb = sipe_backend_buddy_find(SIPE_CORE_PUBLIC,
494 uri,
495 group->name);
496 SIPE_DEBUG_INFO("buddy_check_obsolete_flag: removing buddy '%s' from group '%s'",
497 uri, group->name);
498 /* this should never be NULL */
499 if (oldb)
500 sipe_backend_buddy_remove(SIPE_CORE_PUBLIC,
501 oldb);
502 buddy_group_remove(buddy, bgd);
505 return(FALSE);
509 void sipe_buddy_update_finish(struct sipe_core_private *sipe_private)
511 g_hash_table_foreach_remove(sipe_private->buddies->uri,
512 buddy_check_obsolete_flag,
513 sipe_private);
516 gchar *sipe_core_buddy_status(struct sipe_core_public *sipe_public,
517 const gchar *uri,
518 guint activity,
519 const gchar *status_text)
521 struct sipe_buddy *sbuddy;
522 const char *activity_str;
524 if (!sipe_public) return NULL; /* happens on pidgin exit */
526 sbuddy = sipe_buddy_find_by_uri(SIPE_CORE_PRIVATE, uri);
527 if (!sbuddy) return NULL;
529 activity_str = sbuddy->activity ? sbuddy->activity :
530 (activity == SIPE_ACTIVITY_BUSY) || (activity == SIPE_ACTIVITY_BRB) ?
531 status_text : NULL;
533 if (activity_str && sbuddy->note) {
534 return g_strdup_printf("%s - <i>%s</i>", activity_str, sbuddy->note);
535 } else if (activity_str) {
536 return g_strdup(activity_str);
537 } else if (sbuddy->note) {
538 return g_strdup_printf("<i>%s</i>", sbuddy->note);
539 } else {
540 return NULL;
544 gchar *sipe_buddy_get_alias(struct sipe_core_private *sipe_private,
545 const gchar *with)
547 sipe_backend_buddy pbuddy;
548 gchar *alias = NULL;
549 if ((pbuddy = sipe_backend_buddy_find(SIPE_CORE_PUBLIC, with, NULL))) {
550 alias = sipe_backend_buddy_get_alias(SIPE_CORE_PUBLIC, pbuddy);
552 return alias;
555 void sipe_core_buddy_group(struct sipe_core_public *sipe_public,
556 const gchar *who,
557 const gchar *old_group_name,
558 const gchar *new_group_name)
560 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
561 struct sipe_buddy *buddy = sipe_buddy_find_by_uri(sipe_private,
562 who);
563 struct sipe_group *old_group = NULL;
564 struct sipe_group *new_group;
565 struct sipe_ucs_transaction *ucs_trans = NULL;
567 SIPE_DEBUG_INFO("sipe_core_buddy_group: buddy '%s' old group '%s' new group '%s'",
568 who ? who : "",
569 old_group_name ? old_group_name : "<UNDEFINED>",
570 new_group_name ? new_group_name : "<UNDEFINED>");
572 if (!buddy)
573 /* buddy not in roaming list */
574 return;
576 old_group = sipe_group_find_by_name(sipe_private, old_group_name);
577 if (old_group) {
578 sipe_buddy_remove_group(buddy, old_group);
579 SIPE_DEBUG_INFO("sipe_core_buddy_group: buddy '%s' removed from old group '%s'",
580 who, old_group_name);
583 new_group = sipe_group_find_by_name(sipe_private, new_group_name);
584 if (new_group) {
585 sipe_buddy_insert_group(buddy, new_group);
586 SIPE_DEBUG_INFO("sipe_core_buddy_group: buddy '%s' added to new group '%s'",
587 who, new_group_name);
590 if (sipe_ucs_is_migrated(sipe_private)) {
592 /* UCS handling */
593 ucs_trans = sipe_ucs_transaction(sipe_private);
595 if (new_group) {
597 * 1. new buddy added to existing group
598 * 2. existing buddy moved from old to existing group
600 sipe_ucs_group_add_buddy(sipe_private,
601 ucs_trans,
602 new_group,
603 buddy,
604 buddy->name);
605 if (old_group)
606 sipe_ucs_group_remove_buddy(sipe_private,
607 ucs_trans,
608 old_group,
609 buddy);
611 } else if (old_group) {
613 * 3. existing buddy removed from one of its groups
614 * 4. existing buddy removed from last group
616 sipe_ucs_group_remove_buddy(sipe_private,
617 ucs_trans,
618 old_group,
619 buddy);
620 if (g_slist_length(buddy->groups) < 1)
621 sipe_buddy_remove(sipe_private,
622 buddy);
623 /* buddy no longer valid */
626 /* non-UCS handling */
627 } else if (new_group)
628 sipe_group_update_buddy(sipe_private, buddy);
630 /* 5. buddy added to new group */
631 if (!new_group)
632 sipe_group_create(sipe_private,
633 ucs_trans,
634 new_group_name,
635 who);
638 void sipe_core_buddy_add(struct sipe_core_public *sipe_public,
639 const gchar *uri,
640 const gchar *group_name)
642 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
644 if (!sipe_buddy_find_by_uri(sipe_private, uri))
645 sipe_buddy_add(sipe_private,
646 uri,
647 NULL,
648 NULL);
649 else
650 SIPE_DEBUG_INFO("sipe_core_buddy_add: buddy %s already in internal list",
651 uri);
653 sipe_core_buddy_group(sipe_public,
654 uri,
655 NULL,
656 group_name);
659 void sipe_buddy_remove(struct sipe_core_private *sipe_private,
660 struct sipe_buddy *buddy)
662 struct sipe_buddies *buddies = sipe_private->buddies;
663 const gchar *uri = buddy->name;
664 GSList *entry = buddy->groups;
665 gchar *action_name = sipe_utils_presence_key(uri);
667 sipe_schedule_cancel(sipe_private, action_name);
668 g_free(action_name);
670 /* If the buddy still has groups, we need to delete backend buddies */
671 while (entry) {
672 const struct sipe_group *group = ((struct buddy_group_data *) entry->data)->group;
673 sipe_backend_buddy oldb = sipe_backend_buddy_find(SIPE_CORE_PUBLIC,
674 uri,
675 group->name);
676 /* this should never be NULL */
677 if (oldb)
678 sipe_backend_buddy_remove(SIPE_CORE_PUBLIC, oldb);
680 entry = entry->next;
683 g_hash_table_remove(buddies->uri, uri);
684 if (buddy->exchange_key)
685 g_hash_table_remove(buddies->exchange_key,
686 buddy->exchange_key);
688 buddy_free(buddy);
692 * Unassociates buddy from group first.
693 * Then see if no groups left, removes buddy completely.
694 * Otherwise updates buddy groups on server.
696 void sipe_core_buddy_remove(struct sipe_core_public *sipe_public,
697 const gchar *uri,
698 const gchar *group_name)
700 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
701 struct sipe_buddy *buddy = sipe_buddy_find_by_uri(sipe_private,
702 uri);
703 struct sipe_group *group = NULL;
705 if (!buddy) return;
707 if (group_name) {
708 group = sipe_group_find_by_name(sipe_private, group_name);
709 if (group) {
710 sipe_buddy_remove_group(buddy, group);
711 SIPE_DEBUG_INFO("sipe_core_buddy_remove: buddy '%s' removed from group '%s'",
712 uri, group->name);
716 if (g_slist_length(buddy->groups) < 1) {
718 if (sipe_ucs_is_migrated(sipe_private)) {
719 sipe_ucs_group_remove_buddy(sipe_private,
720 NULL,
721 group,
722 buddy);
723 } else {
724 gchar *request = g_strdup_printf("<m:URI>%s</m:URI>",
725 buddy->name);
726 sip_soap_request(sipe_private,
727 "deleteContact",
728 request);
729 g_free(request);
732 sipe_buddy_remove(sipe_private, buddy);
733 } else {
734 if (sipe_ucs_is_migrated(sipe_private)) {
735 sipe_ucs_group_remove_buddy(sipe_private,
736 NULL,
737 group,
738 buddy);
739 } else
740 /* updates groups on server */
741 sipe_group_update_buddy(sipe_private, buddy);
745 void sipe_core_buddy_got_status(struct sipe_core_public *sipe_public,
746 const gchar *uri,
747 guint activity)
749 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
750 struct sipe_buddy *sbuddy = sipe_buddy_find_by_uri(sipe_private,
751 uri);
753 if (!sbuddy) return;
755 /* Check if on 2005 system contact's calendar,
756 * then set/preserve it.
758 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007)) {
759 sipe_backend_buddy_set_status(sipe_public, uri, activity);
760 } else {
761 sipe_ocs2005_apply_calendar_status(sipe_private,
762 sbuddy,
763 sipe_status_activity_to_token(activity));
767 void sipe_core_buddy_tooltip_info(struct sipe_core_public *sipe_public,
768 const gchar *uri,
769 const gchar *status_name,
770 gboolean is_online,
771 struct sipe_backend_buddy_tooltip *tooltip)
773 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
774 gchar *note = NULL;
775 gboolean is_oof_note = FALSE;
776 const gchar *activity = NULL;
777 gchar *calendar = NULL;
778 const gchar *meeting_subject = NULL;
779 const gchar *meeting_location = NULL;
780 gchar *access_text = NULL;
782 #define SIPE_ADD_BUDDY_INFO(l, t) \
784 gchar *tmp = g_markup_escape_text((t), -1); \
785 sipe_backend_buddy_tooltip_add(sipe_public, tooltip, (l), tmp); \
786 g_free(tmp); \
788 #define SIPE_ADD_BUDDY_INFO_NOESCAPE(l, t) \
789 sipe_backend_buddy_tooltip_add(sipe_public, tooltip, (l), (t))
791 if (sipe_public) { /* happens on pidgin exit */
792 struct sipe_buddy *sbuddy = sipe_buddy_find_by_uri(sipe_private,
793 uri);
794 if (sbuddy) {
795 note = sbuddy->note;
796 is_oof_note = sbuddy->is_oof_note;
797 activity = sbuddy->activity;
798 calendar = sipe_cal_get_description(sbuddy);
799 meeting_subject = sbuddy->meeting_subject;
800 meeting_location = sbuddy->meeting_location;
802 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007)) {
803 gboolean is_group_access = FALSE;
804 const int container_id = sipe_ocs2007_find_access_level(sipe_private,
805 "user",
806 sipe_get_no_sip_uri(uri),
807 &is_group_access);
808 const char *access_level = sipe_ocs2007_access_level_name(container_id);
809 access_text = is_group_access ?
810 g_strdup(access_level) :
811 g_strdup_printf(SIPE_OCS2007_INDENT_MARKED_FMT,
812 access_level);
816 if (is_online) {
817 const gchar *status_str = activity ? activity : status_name;
819 SIPE_ADD_BUDDY_INFO(_("Status"), status_str);
821 if (is_online && !is_empty(calendar)) {
822 SIPE_ADD_BUDDY_INFO(_("Calendar"), calendar);
824 g_free(calendar);
825 if (!is_empty(meeting_location)) {
826 SIPE_DEBUG_INFO("sipe_tooltip_text: %s meeting location: '%s'", uri, meeting_location);
827 SIPE_ADD_BUDDY_INFO(_("Meeting in"), meeting_location);
829 if (!is_empty(meeting_subject)) {
830 SIPE_DEBUG_INFO("sipe_tooltip_text: %s meeting subject: '%s'", uri, meeting_subject);
831 SIPE_ADD_BUDDY_INFO(_("Meeting about"), meeting_subject);
833 if (note) {
834 gchar *note_italics = g_strdup_printf("<i>%s</i>", note);
835 SIPE_DEBUG_INFO("sipe_tooltip_text: %s note: '%s'", uri, note);
836 SIPE_ADD_BUDDY_INFO_NOESCAPE(is_oof_note ? _("Out of office note") : _("Note"),
837 note_italics);
838 g_free(note_italics);
840 if (access_text) {
841 SIPE_ADD_BUDDY_INFO(_("Access level"), access_text);
842 g_free(access_text);
846 void sipe_buddy_update_property(struct sipe_core_private *sipe_private,
847 const char *uri,
848 sipe_buddy_info_fields propkey,
849 char *property_value)
851 GSList *buddies, *entry;
853 if (property_value)
854 property_value = g_strstrip(property_value);
856 entry = buddies = sipe_backend_buddy_find_all(SIPE_CORE_PUBLIC, uri, NULL); /* all buddies in different groups */
857 while (entry) {
858 gchar *prop_str;
859 sipe_backend_buddy p_buddy = entry->data;
861 /* for Display Name */
862 if (propkey == SIPE_BUDDY_INFO_DISPLAY_NAME) {
863 gchar *alias;
864 alias = sipe_backend_buddy_get_alias(SIPE_CORE_PUBLIC, p_buddy);
865 if (property_value && sipe_is_bad_alias(uri, alias)) {
866 SIPE_DEBUG_INFO("Replacing alias for %s with %s", uri, property_value);
867 sipe_backend_buddy_set_alias(SIPE_CORE_PUBLIC, p_buddy, property_value);
869 g_free(alias);
871 alias = sipe_backend_buddy_get_server_alias(SIPE_CORE_PUBLIC, p_buddy);
872 if (!is_empty(property_value) &&
873 (!sipe_strequal(property_value, alias) || is_empty(alias)) )
875 SIPE_DEBUG_INFO("Replacing service alias for %s with %s", uri, property_value);
876 sipe_backend_buddy_set_server_alias(SIPE_CORE_PUBLIC, p_buddy, property_value);
878 g_free(alias);
880 /* for other properties */
881 else {
882 if (!is_empty(property_value)) {
883 prop_str = sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC, p_buddy, propkey);
884 if (!prop_str || !sipe_strcase_equal(prop_str, property_value)) {
885 sipe_backend_buddy_set_string(SIPE_CORE_PUBLIC, p_buddy, propkey, property_value);
887 g_free(prop_str);
891 entry = entry->next;
893 g_slist_free(buddies);
897 struct ms_dlx_data;
898 struct ms_dlx_data {
899 GSList *search_rows;
900 gchar *other;
901 guint max_returns;
902 sipe_svc_callback *callback;
903 struct sipe_svc_session *session;
904 gchar *wsse_security;
905 struct sipe_backend_search_token *token;
906 /* must call ms_dlx_free() */
907 void (*failed_callback)(struct sipe_core_private *sipe_private,
908 struct ms_dlx_data *mdd);
911 static void ms_dlx_free(struct ms_dlx_data *mdd)
913 sipe_utils_slist_free_full(mdd->search_rows, g_free);
914 sipe_svc_session_close(mdd->session);
915 g_free(mdd->other);
916 g_free(mdd->wsse_security);
917 g_free(mdd);
920 #define SIPE_SOAP_SEARCH_ROW "<m:row m:attrib=\"%s\" m:value=\"%s\"/>"
921 #define DLX_SEARCH_ITEM \
922 "<AbEntryRequest.ChangeSearchQuery>" \
923 " <SearchOn>%s</SearchOn>" \
924 " <Value>%s</Value>" \
925 "</AbEntryRequest.ChangeSearchQuery>"
927 static gchar * prepare_buddy_search_query(GSList *query_rows, gboolean use_dlx) {
928 gchar **attrs = g_new(gchar *, (g_slist_length(query_rows) / 2) + 1);
929 guint i = 0;
930 gchar *query = NULL;
932 while (query_rows) {
933 gchar *attr;
934 gchar *value;
936 attr = query_rows->data;
937 query_rows = g_slist_next(query_rows);
938 value = query_rows->data;
939 query_rows = g_slist_next(query_rows);
941 if (!attr || !value)
942 break;
944 attrs[i++] = g_markup_printf_escaped(use_dlx ? DLX_SEARCH_ITEM : SIPE_SOAP_SEARCH_ROW,
945 attr, value);
947 attrs[i] = NULL;
949 if (i) {
950 query = g_strjoinv(NULL, attrs);
951 SIPE_DEBUG_INFO("prepare_buddy_search_query: rows:\n%s",
952 query ? query : "");
955 g_strfreev(attrs);
957 return query;
960 static void ms_dlx_webticket(struct sipe_core_private *sipe_private,
961 const gchar *base_uri,
962 const gchar *auth_uri,
963 const gchar *wsse_security,
964 SIPE_UNUSED_PARAMETER const gchar *failure_msg,
965 gpointer callback_data)
967 struct ms_dlx_data *mdd = callback_data;
969 if (wsse_security) {
970 gchar *query = prepare_buddy_search_query(mdd->search_rows, TRUE);
972 SIPE_DEBUG_INFO("ms_dlx_webticket: got ticket for %s",
973 base_uri);
975 if (sipe_svc_ab_entry_request(sipe_private,
976 mdd->session,
977 auth_uri,
978 wsse_security,
979 query,
980 g_slist_length(mdd->search_rows) / 2,
981 mdd->max_returns,
982 mdd->callback,
983 mdd)) {
985 /* keep webticket security token for potential further use */
986 mdd->wsse_security = g_strdup(wsse_security);
988 /* callback data passed down the line */
989 mdd = NULL;
991 g_free(query);
993 } else {
994 /* no ticket: this will show the minmum information */
995 SIPE_DEBUG_ERROR("ms_dlx_webticket: no web ticket for %s",
996 base_uri);
999 if (mdd)
1000 mdd->failed_callback(sipe_private, mdd);
1003 static void ms_dlx_webticket_request(struct sipe_core_private *sipe_private,
1004 struct ms_dlx_data *mdd)
1006 if (!sipe_webticket_request(sipe_private,
1007 mdd->session,
1008 sipe_private->dlx_uri,
1009 "AddressBookWebTicketBearer",
1010 ms_dlx_webticket,
1011 mdd)) {
1012 SIPE_DEBUG_ERROR("ms_dlx_webticket_request: couldn't request webticket for %s",
1013 sipe_private->dlx_uri);
1014 mdd->failed_callback(sipe_private, mdd);
1018 static void search_contacts_finalize(struct sipe_core_private *sipe_private,
1019 struct sipe_backend_search_results *results,
1020 guint match_count,
1021 gboolean more)
1023 gchar *secondary = g_strdup_printf(
1024 dngettext(PACKAGE_NAME,
1025 "Found %d contact%s:",
1026 "Found %d contacts%s:", match_count),
1027 match_count, more ? _(" (more matched your query)") : "");
1029 sipe_backend_search_results_finalize(SIPE_CORE_PUBLIC,
1030 results,
1031 secondary,
1032 more);
1033 g_free(secondary);
1036 static void search_ab_entry_response(struct sipe_core_private *sipe_private,
1037 const gchar *uri,
1038 SIPE_UNUSED_PARAMETER const gchar *raw,
1039 sipe_xml *soap_body,
1040 gpointer callback_data)
1042 struct ms_dlx_data *mdd = callback_data;
1044 if (soap_body) {
1045 const sipe_xml *node;
1046 struct sipe_backend_search_results *results;
1047 GHashTable *found;
1049 SIPE_DEBUG_INFO("search_ab_entry_response: received valid SOAP message from service %s",
1050 uri);
1052 /* any matches? */
1053 node = sipe_xml_child(soap_body, "Body/SearchAbEntryResponse/SearchAbEntryResult/Items/AbEntry");
1054 if (!node) {
1055 SIPE_DEBUG_ERROR_NOFORMAT("search_ab_entry_response: no matches");
1056 sipe_backend_search_failed(SIPE_CORE_PUBLIC,
1057 mdd->token,
1058 _("No contacts found"));
1059 ms_dlx_free(mdd);
1060 return;
1063 /* OK, we found something - show the results to the user */
1064 results = sipe_backend_search_results_start(SIPE_CORE_PUBLIC,
1065 mdd->token);
1066 if (!results) {
1067 SIPE_DEBUG_ERROR_NOFORMAT("search_ab_entry_response: Unable to display the search results.");
1068 sipe_backend_search_failed(SIPE_CORE_PUBLIC,
1069 mdd->token,
1070 _("Unable to display the search results"));
1071 ms_dlx_free(mdd);
1072 return;
1075 /* SearchAbEntryResult can contain duplicates */
1076 found = g_hash_table_new_full(g_str_hash, g_str_equal,
1077 g_free, NULL);
1079 for (/* initialized above */ ; node; node = sipe_xml_twin(node)) {
1080 const sipe_xml *attrs;
1081 gchar *sip_uri = NULL;
1082 gchar *displayname = NULL;
1083 gchar *company = NULL;
1084 gchar *country = NULL;
1085 gchar *email = NULL;
1087 for (attrs = sipe_xml_child(node, "Attributes/Attribute");
1088 attrs;
1089 attrs = sipe_xml_twin(attrs)) {
1090 gchar *name = sipe_xml_data(sipe_xml_child(attrs,
1091 "Name"));
1092 gchar *value = sipe_xml_data(sipe_xml_child(attrs,
1093 "Value"));
1095 if (!is_empty(value)) {
1096 if (sipe_strcase_equal(name, "msrtcsip-primaryuseraddress")) {
1097 g_free(sip_uri);
1098 sip_uri = value;
1099 value = NULL;
1100 } else if (sipe_strcase_equal(name, "displayname")) {
1101 g_free(displayname);
1102 displayname = value;
1103 value = NULL;
1104 } else if (sipe_strcase_equal(name, "mail")) {
1105 g_free(email);
1106 email = value;
1107 value = NULL;
1108 } else if (sipe_strcase_equal(name, "company")) {
1109 g_free(company);
1110 company = value;
1111 value = NULL;
1112 } else if (sipe_strcase_equal(name, "country")) {
1113 g_free(country);
1114 country = value;
1115 value = NULL;
1119 g_free(value);
1120 g_free(name);
1123 if (sip_uri && !g_hash_table_lookup(found, sip_uri)) {
1124 gchar **uri_parts = g_strsplit(sip_uri, ":", 2);
1125 sipe_backend_search_results_add(SIPE_CORE_PUBLIC,
1126 results,
1127 uri_parts[1],
1128 displayname,
1129 company,
1130 country,
1131 email);
1132 g_strfreev(uri_parts);
1134 g_hash_table_insert(found, sip_uri, (gpointer) TRUE);
1135 sip_uri = NULL;
1138 g_free(email);
1139 g_free(country);
1140 g_free(company);
1141 g_free(displayname);
1142 g_free(sip_uri);
1145 search_contacts_finalize(sipe_private, results,
1146 g_hash_table_size(found),
1147 FALSE);
1148 g_hash_table_destroy(found);
1149 ms_dlx_free(mdd);
1151 } else {
1152 mdd->failed_callback(sipe_private, mdd);
1156 static gboolean process_search_contact_response(struct sipe_core_private *sipe_private,
1157 struct sipmsg *msg,
1158 struct transaction *trans)
1160 struct sipe_backend_search_token *token = trans->payload->data;
1161 struct sipe_backend_search_results *results;
1162 sipe_xml *searchResults;
1163 const sipe_xml *mrow;
1164 guint match_count = 0;
1165 gboolean more = FALSE;
1167 /* valid response? */
1168 if (msg->response != 200) {
1169 SIPE_DEBUG_ERROR("process_search_contact_response: request failed (%d)",
1170 msg->response);
1171 sipe_backend_search_failed(SIPE_CORE_PUBLIC,
1172 token,
1173 _("Contact search failed"));
1174 return(FALSE);
1177 SIPE_DEBUG_INFO("process_search_contact_response: body:\n%s", msg->body ? msg->body : "");
1179 /* valid XML? */
1180 searchResults = sipe_xml_parse(msg->body, msg->bodylen);
1181 if (!searchResults) {
1182 SIPE_DEBUG_INFO_NOFORMAT("process_search_contact_response: no parseable searchResults");
1183 sipe_backend_search_failed(SIPE_CORE_PUBLIC,
1184 token,
1185 _("Contact search failed"));
1186 return(FALSE);
1189 /* any matches? */
1190 mrow = sipe_xml_child(searchResults, "Body/Array/row");
1191 if (!mrow) {
1192 SIPE_DEBUG_ERROR_NOFORMAT("process_search_contact_response: no matches");
1193 sipe_backend_search_failed(SIPE_CORE_PUBLIC,
1194 token,
1195 _("No contacts found"));
1197 sipe_xml_free(searchResults);
1198 return(FALSE);
1201 /* OK, we found something - show the results to the user */
1202 results = sipe_backend_search_results_start(SIPE_CORE_PUBLIC,
1203 trans->payload->data);
1204 if (!results) {
1205 SIPE_DEBUG_ERROR_NOFORMAT("process_search_contact_response: Unable to display the search results.");
1206 sipe_backend_search_failed(SIPE_CORE_PUBLIC,
1207 token,
1208 _("Unable to display the search results"));
1210 sipe_xml_free(searchResults);
1211 return FALSE;
1214 for (/* initialized above */ ; mrow; mrow = sipe_xml_twin(mrow)) {
1215 gchar **uri_parts = g_strsplit(sipe_xml_attribute(mrow, "uri"), ":", 2);
1216 sipe_backend_search_results_add(SIPE_CORE_PUBLIC,
1217 results,
1218 uri_parts[1],
1219 sipe_xml_attribute(mrow, "displayName"),
1220 sipe_xml_attribute(mrow, "company"),
1221 sipe_xml_attribute(mrow, "country"),
1222 sipe_xml_attribute(mrow, "email"));
1223 g_strfreev(uri_parts);
1224 match_count++;
1227 if ((mrow = sipe_xml_child(searchResults, "Body/directorySearch/moreAvailable")) != NULL) {
1228 char *data = sipe_xml_data(mrow);
1229 more = (g_ascii_strcasecmp(data, "true") == 0);
1230 g_free(data);
1233 search_contacts_finalize(sipe_private, results, match_count, more);
1234 sipe_xml_free(searchResults);
1236 return(TRUE);
1239 static void search_soap_request(struct sipe_core_private *sipe_private,
1240 struct sipe_backend_search_token *token,
1241 GSList *search_rows)
1243 gchar *query = prepare_buddy_search_query(search_rows, FALSE);
1244 struct transaction_payload *payload = g_new0(struct transaction_payload, 1);
1246 payload->data = token;
1248 sip_soap_directory_search(sipe_private,
1249 100,
1250 query,
1251 process_search_contact_response,
1252 payload);
1253 g_free(query);
1256 static void search_ab_entry_failed(struct sipe_core_private *sipe_private,
1257 struct ms_dlx_data *mdd)
1259 /* error using [MS-DLX] server, retry using Active Directory */
1260 search_soap_request(sipe_private, mdd->token, mdd->search_rows);
1261 ms_dlx_free(mdd);
1264 void sipe_core_buddy_search(struct sipe_core_public *sipe_public,
1265 struct sipe_backend_search_token *token,
1266 const gchar *given_name,
1267 const gchar *surname,
1268 const gchar *email,
1269 const gchar *company,
1270 const gchar *country)
1272 GSList *query_rows = NULL;
1274 #define ADD_QUERY_ROW(attr, val) \
1275 if (val) { \
1276 query_rows = g_slist_append(query_rows, g_strdup(attr)); \
1277 query_rows = g_slist_append(query_rows, g_strdup(val)); \
1280 ADD_QUERY_ROW("givenName", given_name);
1281 ADD_QUERY_ROW("sn", surname);
1282 ADD_QUERY_ROW("mail", email);
1283 ADD_QUERY_ROW("company", company);
1284 ADD_QUERY_ROW("c", country);
1286 if (query_rows) {
1287 if (SIPE_CORE_PRIVATE->dlx_uri != NULL) {
1288 struct ms_dlx_data *mdd = g_new0(struct ms_dlx_data, 1);
1290 mdd->search_rows = query_rows;
1291 mdd->max_returns = 100;
1292 mdd->callback = search_ab_entry_response;
1293 mdd->failed_callback = search_ab_entry_failed;
1294 mdd->session = sipe_svc_session_start();
1295 mdd->token = token;
1297 ms_dlx_webticket_request(SIPE_CORE_PRIVATE, mdd);
1299 } else {
1300 /* no [MS-DLX] server, use Active Directory search instead */
1301 search_soap_request(SIPE_CORE_PRIVATE, token, query_rows);
1302 sipe_utils_slist_free_full(query_rows, g_free);
1304 } else
1305 sipe_backend_search_failed(sipe_public,
1306 token,
1307 _("Invalid contact search query"));
1310 static void get_info_finalize(struct sipe_core_private *sipe_private,
1311 struct sipe_backend_buddy_info *info,
1312 const gchar *uri,
1313 const gchar *server_alias,
1314 const gchar *email)
1316 sipe_backend_buddy bbuddy;
1317 struct sipe_buddy *sbuddy;
1318 gchar *alias;
1319 gchar *value;
1321 if (!info) {
1322 info = sipe_backend_buddy_info_start(SIPE_CORE_PUBLIC);
1323 } else {
1324 sipe_backend_buddy_info_break(SIPE_CORE_PUBLIC, info);
1326 if (!info)
1327 return;
1329 bbuddy = sipe_backend_buddy_find(SIPE_CORE_PUBLIC, uri, NULL);
1331 if (is_empty(server_alias)) {
1332 value = sipe_backend_buddy_get_server_alias(SIPE_CORE_PUBLIC,
1333 bbuddy);
1334 if (value) {
1335 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1336 info,
1337 SIPE_BUDDY_INFO_DISPLAY_NAME,
1338 value);
1340 } else {
1341 value = g_strdup(server_alias);
1344 /* present alias if it differs from server alias */
1345 alias = sipe_backend_buddy_get_local_alias(SIPE_CORE_PUBLIC, bbuddy);
1346 if (alias && !sipe_strequal(alias, value))
1348 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1349 info,
1350 SIPE_BUDDY_INFO_ALIAS,
1351 alias);
1353 g_free(alias);
1354 g_free(value);
1356 if (is_empty(email)) {
1357 value = sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC,
1358 bbuddy,
1359 SIPE_BUDDY_INFO_EMAIL);
1360 if (value) {
1361 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1362 info,
1363 SIPE_BUDDY_INFO_EMAIL,
1364 value);
1365 g_free(value);
1369 value = sipe_backend_buddy_get_string(SIPE_CORE_PUBLIC,
1370 bbuddy,
1371 SIPE_BUDDY_INFO_SITE);
1372 if (value) {
1373 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1374 info,
1375 SIPE_BUDDY_INFO_SITE,
1376 value);
1377 g_free(value);
1380 sbuddy = sipe_buddy_find_by_uri(sipe_private, uri);
1381 if (sbuddy && sbuddy->device_name) {
1382 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1383 info,
1384 SIPE_BUDDY_INFO_DEVICE,
1385 sbuddy->device_name);
1388 sipe_backend_buddy_info_finalize(SIPE_CORE_PUBLIC, info, uri);
1392 static void get_info_ab_entry_response(struct sipe_core_private *sipe_private,
1393 const gchar *uri,
1394 SIPE_UNUSED_PARAMETER const gchar *raw,
1395 sipe_xml *soap_body,
1396 gpointer callback_data)
1398 struct ms_dlx_data *mdd = callback_data;
1399 struct sipe_backend_buddy_info *info = NULL;
1400 gchar *server_alias = NULL;
1401 gchar *email = NULL;
1403 if (soap_body) {
1404 const sipe_xml *node;
1406 SIPE_DEBUG_INFO("get_info_ab_entry_response: received valid SOAP message from service %s",
1407 uri);
1409 info = sipe_backend_buddy_info_start(SIPE_CORE_PUBLIC);
1411 for (node = sipe_xml_child(soap_body, "Body/SearchAbEntryResponse/SearchAbEntryResult/Items/AbEntry/Attributes/Attribute");
1412 node;
1413 node = sipe_xml_twin(node)) {
1414 gchar *name = sipe_xml_data(sipe_xml_child(node,
1415 "Name"));
1416 gchar *value = sipe_xml_data(sipe_xml_child(node,
1417 "Value"));
1418 const sipe_xml *values = sipe_xml_child(node,
1419 "Values");
1421 /* Single value entries */
1422 if (!is_empty(value)) {
1424 if (sipe_strcase_equal(name, "displayname")) {
1425 g_free(server_alias);
1426 server_alias = value;
1427 value = NULL;
1428 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1429 info,
1430 SIPE_BUDDY_INFO_DISPLAY_NAME,
1431 server_alias);
1432 } else if (sipe_strcase_equal(name, "mail")) {
1433 g_free(email);
1434 email = value;
1435 value = NULL;
1436 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1437 info,
1438 SIPE_BUDDY_INFO_EMAIL,
1439 email);
1440 } else if (sipe_strcase_equal(name, "title")) {
1441 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1442 info,
1443 SIPE_BUDDY_INFO_JOB_TITLE,
1444 value);
1445 } else if (sipe_strcase_equal(name, "company")) {
1446 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1447 info,
1448 SIPE_BUDDY_INFO_COMPANY,
1449 value);
1450 } else if (sipe_strcase_equal(name, "country")) {
1451 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1452 info,
1453 SIPE_BUDDY_INFO_COUNTRY,
1454 value);
1457 } else if (values) {
1458 gchar *first = sipe_xml_data(sipe_xml_child(values,
1459 "string"));
1461 if (sipe_strcase_equal(name, "telephonenumber")) {
1462 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1463 info,
1464 SIPE_BUDDY_INFO_WORK_PHONE,
1465 first);
1468 g_free(first);
1471 g_free(value);
1472 g_free(name);
1476 /* this will show the minmum information */
1477 get_info_finalize(sipe_private,
1478 info,
1479 mdd->other,
1480 server_alias,
1481 email);
1483 g_free(email);
1484 g_free(server_alias);
1485 ms_dlx_free(mdd);
1488 static gboolean process_get_info_response(struct sipe_core_private *sipe_private,
1489 struct sipmsg *msg,
1490 struct transaction *trans)
1492 const gchar *uri = trans->payload->data;
1493 struct sipe_backend_buddy_info *info = NULL;
1494 gchar *server_alias = NULL;
1495 gchar *email = NULL;
1497 SIPE_DEBUG_INFO("Fetching %s's user info for %s",
1498 uri, sipe_private->username);
1500 if (msg->response != 200) {
1501 SIPE_DEBUG_INFO("process_get_info_response: SERVICE response is %d", msg->response);
1502 } else {
1503 sipe_xml *searchResults;
1504 const sipe_xml *mrow;
1506 SIPE_DEBUG_INFO("process_get_info_response: body:\n%s",
1507 msg->body ? msg->body : "");
1509 searchResults = sipe_xml_parse(msg->body, msg->bodylen);
1510 if (!searchResults) {
1512 SIPE_DEBUG_INFO_NOFORMAT("process_get_info_response: no parseable searchResults");
1514 } else if ((mrow = sipe_xml_child(searchResults, "Body/Array/row"))) {
1515 const gchar *value;
1516 gchar *phone_number;
1518 info = sipe_backend_buddy_info_start(SIPE_CORE_PUBLIC);
1520 server_alias = g_strdup(sipe_xml_attribute(mrow, "displayName"));
1521 email = g_strdup(sipe_xml_attribute(mrow, "email"));
1522 phone_number = g_strdup(sipe_xml_attribute(mrow, "phone"));
1525 * For 2007 system we will take this from ContactCard -
1526 * it has cleaner tel: URIs at least
1528 if (!SIPE_CORE_PRIVATE_FLAG_IS(OCS2007)) {
1529 char *tel_uri = sip_to_tel_uri(phone_number);
1530 /* trims its parameters, so call first */
1531 sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_DISPLAY_NAME, server_alias);
1532 sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_EMAIL, email);
1533 sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_WORK_PHONE, tel_uri);
1534 sipe_buddy_update_property(sipe_private, uri, SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY, phone_number);
1535 g_free(tel_uri);
1537 sipe_backend_buddy_refresh_properties(SIPE_CORE_PUBLIC,
1538 uri);
1541 if (!is_empty(server_alias)) {
1542 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1543 info,
1544 SIPE_BUDDY_INFO_DISPLAY_NAME,
1545 server_alias);
1547 if ((value = sipe_xml_attribute(mrow, "title")) && strlen(value) > 0) {
1548 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1549 info,
1550 SIPE_BUDDY_INFO_JOB_TITLE,
1551 value);
1553 if ((value = sipe_xml_attribute(mrow, "office")) && strlen(value) > 0) {
1554 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1555 info,
1556 SIPE_BUDDY_INFO_OFFICE,
1557 value);
1559 if (!is_empty(phone_number)) {
1560 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1561 info,
1562 SIPE_BUDDY_INFO_WORK_PHONE,
1563 phone_number);
1565 g_free(phone_number);
1566 if ((value = sipe_xml_attribute(mrow, "company")) && strlen(value) > 0) {
1567 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1568 info,
1569 SIPE_BUDDY_INFO_COMPANY,
1570 value);
1572 if ((value = sipe_xml_attribute(mrow, "city")) && strlen(value) > 0) {
1573 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1574 info,
1575 SIPE_BUDDY_INFO_CITY,
1576 value);
1578 if ((value = sipe_xml_attribute(mrow, "state")) && strlen(value) > 0) {
1579 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1580 info,
1581 SIPE_BUDDY_INFO_STATE,
1582 value);
1584 if ((value = sipe_xml_attribute(mrow, "country")) && strlen(value) > 0) {
1585 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1586 info,
1587 SIPE_BUDDY_INFO_COUNTRY,
1588 value);
1590 if (!is_empty(email)) {
1591 sipe_backend_buddy_info_add(SIPE_CORE_PUBLIC,
1592 info,
1593 SIPE_BUDDY_INFO_EMAIL,
1594 email);
1597 sipe_xml_free(searchResults);
1600 /* this will show the minmum information */
1601 get_info_finalize(sipe_private,
1602 info,
1603 uri,
1604 server_alias,
1605 email);
1607 g_free(server_alias);
1608 g_free(email);
1610 return TRUE;
1613 static void get_info_ab_entry_failed(struct sipe_core_private *sipe_private,
1614 struct ms_dlx_data *mdd)
1616 /* error using [MS-DLX] server, retry using Active Directory */
1617 gchar *query = prepare_buddy_search_query(mdd->search_rows, FALSE);
1618 struct transaction_payload *payload = g_new0(struct transaction_payload, 1);
1620 payload->destroy = g_free;
1621 payload->data = mdd->other;
1622 mdd->other = NULL;
1624 sip_soap_directory_search(sipe_private,
1626 query,
1627 process_get_info_response,
1628 payload);
1630 ms_dlx_free(mdd);
1631 g_free(query);
1634 void sipe_core_buddy_get_info(struct sipe_core_public *sipe_public,
1635 const gchar *who)
1637 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
1639 if (sipe_private->dlx_uri) {
1640 struct ms_dlx_data *mdd = g_new0(struct ms_dlx_data, 1);
1642 mdd->search_rows = g_slist_append(mdd->search_rows, g_strdup("msRTCSIP-PrimaryUserAddress"));
1643 mdd->search_rows = g_slist_append(mdd->search_rows, g_strdup(who));
1645 mdd->other = g_strdup(who);
1646 mdd->max_returns = 1;
1647 mdd->callback = get_info_ab_entry_response;
1648 mdd->failed_callback = get_info_ab_entry_failed;
1649 mdd->session = sipe_svc_session_start();
1651 ms_dlx_webticket_request(sipe_private, mdd);
1653 } else {
1654 /* no [MS-DLX] server, use Active Directory search instead */
1655 gchar *row = g_markup_printf_escaped(SIPE_SOAP_SEARCH_ROW,
1656 "msRTCSIP-PrimaryUserAddress",
1657 who);
1658 struct transaction_payload *payload = g_new0(struct transaction_payload, 1);
1660 SIPE_DEBUG_INFO("sipe_core_buddy_get_info: row: %s",
1661 row ? row : "");
1663 payload->destroy = g_free;
1664 payload->data = g_strdup(who);
1666 sip_soap_directory_search(sipe_private,
1668 row,
1669 process_get_info_response,
1670 payload);
1671 g_free(row);
1675 static void photo_response_data_free(struct photo_response_data *data)
1677 g_free(data->who);
1678 g_free(data->photo_hash);
1679 if (data->request) {
1680 sipe_http_request_cancel(data->request);
1682 g_free(data);
1685 static void process_buddy_photo_response(struct sipe_core_private *sipe_private,
1686 guint status,
1687 GSList *headers,
1688 const char *body,
1689 gpointer data)
1691 struct photo_response_data *rdata = (struct photo_response_data *) data;
1693 rdata->request = NULL;
1695 if (status == SIPE_HTTP_STATUS_OK) {
1696 const gchar *len_str = sipe_utils_nameval_find(headers,
1697 "Content-Length");
1698 if (len_str) {
1699 gsize photo_size = atoi(len_str);
1700 gpointer photo = g_new(char, photo_size);
1702 if (photo) {
1703 memcpy(photo, body, photo_size);
1705 sipe_backend_buddy_set_photo(SIPE_CORE_PUBLIC,
1706 rdata->who,
1707 photo,
1708 photo_size,
1709 rdata->photo_hash);
1714 sipe_private->buddies->pending_photo_requests =
1715 g_slist_remove(sipe_private->buddies->pending_photo_requests, rdata);
1717 photo_response_data_free(rdata);
1720 static gchar *create_x_ms_webticket_header(const gchar *wsse_security)
1722 gchar *assertion = sipe_xml_extract_raw(wsse_security, "saml:Assertion", TRUE);
1723 gchar *wsse_security_base64;
1724 gchar *x_ms_webticket_header;
1726 if (!assertion) {
1727 return NULL;
1730 wsse_security_base64 = g_base64_encode((const guchar *)assertion,
1731 strlen(assertion));
1732 x_ms_webticket_header = g_strdup_printf("X-MS-WebTicket: opaque=%s\r\n",
1733 wsse_security_base64);
1735 g_free(assertion);
1736 g_free(wsse_security_base64);
1738 return x_ms_webticket_header;
1741 static void get_photo_ab_entry_response(struct sipe_core_private *sipe_private,
1742 const gchar *uri,
1743 SIPE_UNUSED_PARAMETER const gchar *raw,
1744 sipe_xml *soap_body,
1745 gpointer callback_data)
1747 struct ms_dlx_data *mdd = callback_data;
1748 gchar *photo_rel_path = NULL;
1749 gchar *photo_hash = NULL;
1750 const gchar *photo_hash_old =
1751 sipe_backend_buddy_get_photo_hash(SIPE_CORE_PUBLIC, mdd->other);
1753 if (soap_body) {
1754 const sipe_xml *node;
1756 SIPE_DEBUG_INFO("get_photo_ab_entry_response: received valid SOAP message from service %s",
1757 uri);
1759 for (node = sipe_xml_child(soap_body, "Body/SearchAbEntryResponse/SearchAbEntryResult/Items/AbEntry/Attributes/Attribute");
1760 node;
1761 node = sipe_xml_twin(node)) {
1762 gchar *name = sipe_xml_data(sipe_xml_child(node, "Name"));
1763 gchar *value = sipe_xml_data(sipe_xml_child(node, "Value"));
1765 if (!is_empty(value)) {
1766 if (sipe_strcase_equal(name, "PhotoRelPath")) {
1767 g_free(photo_rel_path);
1768 photo_rel_path = value;
1769 value = NULL;
1770 } else if (sipe_strcase_equal(name, "PhotoHash")) {
1771 g_free(photo_hash);
1772 photo_hash = value;
1773 value = NULL;
1777 g_free(value);
1778 g_free(name);
1782 if (sipe_private->addressbook_uri && photo_rel_path &&
1783 photo_hash && !sipe_strequal(photo_hash, photo_hash_old)) {
1784 gchar *photo_url = g_strdup_printf("%s/%s",
1785 sipe_private->addressbook_uri, photo_rel_path);
1786 gchar *x_ms_webticket_header = create_x_ms_webticket_header(mdd->wsse_security);
1788 struct photo_response_data *data = g_new(struct photo_response_data, 1);
1789 data->who = g_strdup(mdd->other);
1790 data->photo_hash = photo_hash;
1791 photo_hash = NULL;
1793 data->request = sipe_http_request_get(sipe_private,
1794 photo_url,
1795 x_ms_webticket_header,
1796 process_buddy_photo_response,
1797 data);
1799 if (data->request) {
1800 sipe_private->buddies->pending_photo_requests =
1801 g_slist_append(sipe_private->buddies->pending_photo_requests, data);
1802 sipe_http_request_ready(data->request);
1803 } else {
1804 photo_response_data_free(data);
1807 g_free(x_ms_webticket_header);
1808 g_free(photo_url);
1811 g_free(photo_rel_path);
1812 g_free(photo_hash);
1813 ms_dlx_free(mdd);
1816 static void get_photo_ab_entry_failed(SIPE_UNUSED_PARAMETER struct sipe_core_private *sipe_private,
1817 struct ms_dlx_data *mdd)
1819 ms_dlx_free(mdd);
1822 static void buddy_fetch_photo(struct sipe_core_private *sipe_private,
1823 const gchar *uri)
1825 if (sipe_backend_uses_photo()) {
1827 /* Lync 2013 or newer: use UCS if contacts are migrated */
1828 if (SIPE_CORE_PRIVATE_FLAG_IS(LYNC2013) &&
1829 sipe_ucs_is_migrated(sipe_private)) {
1831 sipe_ucs_get_photo(sipe_private, uri);
1833 /* Lync 2010: use [MS-DLX] */
1834 } else if (sipe_private->dlx_uri &&
1835 sipe_private->addressbook_uri) {
1836 struct ms_dlx_data *mdd = g_new0(struct ms_dlx_data, 1);
1838 mdd->search_rows = g_slist_append(mdd->search_rows, g_strdup("msRTCSIP-PrimaryUserAddress"));
1839 mdd->search_rows = g_slist_append(mdd->search_rows, g_strdup(uri));
1841 mdd->other = g_strdup(uri);
1842 mdd->max_returns = 1;
1843 mdd->callback = get_photo_ab_entry_response;
1844 mdd->failed_callback = get_photo_ab_entry_failed;
1845 mdd->session = sipe_svc_session_start();
1847 ms_dlx_webticket_request(sipe_private, mdd);
1852 static void buddy_refresh_photos_cb(gpointer uri,
1853 SIPE_UNUSED_PARAMETER gpointer value,
1854 gpointer sipe_private)
1856 buddy_fetch_photo(sipe_private, uri);
1859 void sipe_buddy_refresh_photos(struct sipe_core_private *sipe_private)
1861 g_hash_table_foreach(sipe_private->buddies->uri,
1862 buddy_refresh_photos_cb,
1863 sipe_private);
1866 /* Buddy menu callbacks*/
1868 void sipe_core_buddy_new_chat(struct sipe_core_public *sipe_public,
1869 const gchar *who)
1871 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
1873 /* 2007+ conference */
1874 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007)) {
1875 sipe_conf_add(sipe_private, who);
1877 /* 2005- multiparty chat */
1878 } else {
1879 gchar *self = sip_uri_self(sipe_private);
1880 struct sip_session *session;
1882 session = sipe_session_add_chat(sipe_private,
1883 NULL,
1884 TRUE,
1885 self);
1886 session->chat_session->backend = sipe_backend_chat_create(SIPE_CORE_PUBLIC,
1887 session->chat_session,
1888 session->chat_session->title,
1889 self);
1890 g_free(self);
1892 sipe_im_invite(sipe_private, session, who,
1893 NULL, NULL, NULL, FALSE);
1897 void sipe_core_buddy_send_email(struct sipe_core_public *sipe_public,
1898 const gchar *who)
1900 sipe_backend_buddy buddy = sipe_backend_buddy_find(sipe_public,
1901 who,
1902 NULL);
1903 gchar *email = sipe_backend_buddy_get_string(sipe_public,
1904 buddy,
1905 SIPE_BUDDY_INFO_EMAIL);
1907 if (email) {
1908 gchar *command_line = g_strdup_printf(
1909 #ifdef _WIN32
1910 "cmd /c start"
1911 #else
1912 "xdg-email"
1913 #endif
1914 " mailto:%s", email);
1915 g_free(email);
1917 SIPE_DEBUG_INFO("sipe_core_buddy_send_email: going to call email client: %s",
1918 command_line);
1919 g_spawn_command_line_async(command_line, NULL);
1920 g_free(command_line);
1922 } else {
1923 SIPE_DEBUG_INFO("sipe_core_buddy_send_email: no email address stored for buddy=%s",
1924 who);
1928 /* Buddy menu */
1930 static struct sipe_backend_buddy_menu *buddy_menu_phone(struct sipe_core_public *sipe_public,
1931 struct sipe_backend_buddy_menu *menu,
1932 sipe_backend_buddy buddy,
1933 sipe_buddy_info_fields id_phone,
1934 sipe_buddy_info_fields id_display,
1935 const gchar *type)
1937 gchar *phone = sipe_backend_buddy_get_string(sipe_public,
1938 buddy,
1939 id_phone);
1940 if (phone) {
1941 gchar *display = sipe_backend_buddy_get_string(sipe_public,
1942 buddy,
1943 id_display);
1944 gchar *tmp = NULL;
1945 gchar *label = g_strdup_printf("%s %s",
1946 type,
1947 display ? display :
1948 (tmp = sip_tel_uri_denormalize(phone)));
1949 menu = sipe_backend_buddy_menu_add(sipe_public,
1950 menu,
1951 label,
1952 SIPE_BUDDY_MENU_MAKE_CALL,
1953 phone);
1954 g_free(tmp);
1955 g_free(label);
1956 g_free(display);
1957 g_free(phone);
1960 return(menu);
1963 struct sipe_backend_buddy_menu *sipe_core_buddy_create_menu(struct sipe_core_public *sipe_public,
1964 const gchar *buddy_name,
1965 struct sipe_backend_buddy_menu *menu)
1967 struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE;
1968 sipe_backend_buddy buddy = sipe_backend_buddy_find(sipe_public,
1969 buddy_name,
1970 NULL);
1971 gchar *self = sip_uri_self(sipe_private);
1973 SIPE_SESSION_FOREACH {
1974 if (!sipe_strcase_equal(self, buddy_name) && session->chat_session)
1976 struct sipe_chat_session *chat_session = session->chat_session;
1977 gboolean is_conf = (chat_session->type == SIPE_CHAT_TYPE_CONFERENCE);
1979 if (sipe_backend_chat_find(chat_session->backend, buddy_name))
1981 gboolean conf_op = sipe_backend_chat_is_operator(chat_session->backend, self);
1983 if (is_conf &&
1984 /* Not conf OP */
1985 !sipe_backend_chat_is_operator(chat_session->backend, buddy_name) &&
1986 /* We are a conf OP */
1987 conf_op) {
1988 gchar *label = g_strdup_printf(_("Make leader of '%s'"),
1989 chat_session->title);
1990 menu = sipe_backend_buddy_menu_add(sipe_public,
1991 menu,
1992 label,
1993 SIPE_BUDDY_MENU_MAKE_CHAT_LEADER,
1994 chat_session);
1995 g_free(label);
1998 if (is_conf &&
1999 /* We are a conf OP */
2000 conf_op) {
2001 gchar *label = g_strdup_printf(_("Remove from '%s'"),
2002 chat_session->title);
2003 menu = sipe_backend_buddy_menu_add(sipe_public,
2004 menu,
2005 label,
2006 SIPE_BUDDY_MENU_REMOVE_FROM_CHAT,
2007 chat_session);
2008 g_free(label);
2011 else
2013 if (!is_conf ||
2014 (is_conf && !session->locked)) {
2015 gchar *label = g_strdup_printf(_("Invite to '%s'"),
2016 chat_session->title);
2017 menu = sipe_backend_buddy_menu_add(sipe_public,
2018 menu,
2019 label,
2020 SIPE_BUDDY_MENU_INVITE_TO_CHAT,
2021 chat_session);
2022 g_free(label);
2026 } SIPE_SESSION_FOREACH_END;
2027 g_free(self);
2029 menu = sipe_backend_buddy_menu_add(sipe_public,
2030 menu,
2031 _("New chat"),
2032 SIPE_BUDDY_MENU_NEW_CHAT,
2033 NULL);
2035 /* add buddy's phone numbers if we have call control */
2036 if (sip_csta_is_idle(sipe_private)) {
2038 /* work phone */
2039 menu = buddy_menu_phone(sipe_public,
2040 menu,
2041 buddy,
2042 SIPE_BUDDY_INFO_WORK_PHONE,
2043 SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY,
2044 _("Work"));
2045 /* mobile phone */
2046 menu = buddy_menu_phone(sipe_public,
2047 menu,
2048 buddy,
2049 SIPE_BUDDY_INFO_MOBILE_PHONE,
2050 SIPE_BUDDY_INFO_MOBILE_PHONE_DISPLAY,
2051 _("Mobile"));
2053 /* home phone */
2054 menu = buddy_menu_phone(sipe_public,
2055 menu,
2056 buddy,
2057 SIPE_BUDDY_INFO_HOME_PHONE,
2058 SIPE_BUDDY_INFO_HOME_PHONE_DISPLAY,
2059 _("Home"));
2061 /* other phone */
2062 menu = buddy_menu_phone(sipe_public,
2063 menu,
2064 buddy,
2065 SIPE_BUDDY_INFO_OTHER_PHONE,
2066 SIPE_BUDDY_INFO_OTHER_PHONE_DISPLAY,
2067 _("Other"));
2069 /* custom1 phone */
2070 menu = buddy_menu_phone(sipe_public,
2071 menu,
2072 buddy,
2073 SIPE_BUDDY_INFO_CUSTOM1_PHONE,
2074 SIPE_BUDDY_INFO_CUSTOM1_PHONE_DISPLAY,
2075 _("Custom1"));
2079 gchar *email = sipe_backend_buddy_get_string(sipe_public,
2080 buddy,
2081 SIPE_BUDDY_INFO_EMAIL);
2082 if (email) {
2083 menu = sipe_backend_buddy_menu_add(sipe_public,
2084 menu,
2085 _("Send email..."),
2086 SIPE_BUDDY_MENU_SEND_EMAIL,
2087 NULL);
2088 g_free(email);
2092 /* access level control */
2093 if (SIPE_CORE_PRIVATE_FLAG_IS(OCS2007))
2094 menu = sipe_backend_buddy_sub_menu_add(sipe_public,
2095 menu,
2096 _("Access level"),
2097 sipe_ocs2007_access_control_menu(sipe_private,
2098 buddy_name));
2100 return(menu);
2103 guint sipe_buddy_count(struct sipe_core_private *sipe_private)
2105 return(g_hash_table_size(sipe_private->buddies->uri));
2108 static guint sipe_ht_hash_nick(const char *nick)
2110 char *lc = g_utf8_strdown(nick, -1);
2111 guint bucket = g_str_hash(lc);
2112 g_free(lc);
2114 return bucket;
2117 static gboolean sipe_ht_equals_nick(const char *nick1, const char *nick2)
2119 char *nick1_norm = NULL;
2120 char *nick2_norm = NULL;
2121 gboolean equal;
2123 if (nick1 == NULL && nick2 == NULL) return TRUE;
2124 if (nick1 == NULL || nick2 == NULL ||
2125 !g_utf8_validate(nick1, -1, NULL) ||
2126 !g_utf8_validate(nick2, -1, NULL)) return FALSE;
2128 nick1_norm = g_utf8_casefold(nick1, -1);
2129 nick2_norm = g_utf8_casefold(nick2, -1);
2130 equal = g_utf8_collate(nick1_norm, nick2_norm) == 0;
2131 g_free(nick2_norm);
2132 g_free(nick1_norm);
2134 return equal;
2137 void sipe_buddy_init(struct sipe_core_private *sipe_private)
2139 struct sipe_buddies *buddies = g_new0(struct sipe_buddies, 1);
2140 buddies->uri = g_hash_table_new((GHashFunc) sipe_ht_hash_nick,
2141 (GEqualFunc) sipe_ht_equals_nick);
2142 buddies->exchange_key = g_hash_table_new(g_str_hash,
2143 g_str_equal);
2144 sipe_private->buddies = buddies;
2148 Local Variables:
2149 mode: c
2150 c-file-style: "bsd"
2151 indent-tabs-mode: t
2152 tab-width: 8
2153 End: