purple: take renamed API 3.x.x headers in use
[siplcs.git] / src / core / sipe-buddy.h
blob41cfc75bfdacad676e5d088a69151533728687c0
1 /**
2 * @file sipe-buddy.h
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 /* Forward declarations */
24 struct sipe_cal_working_hours;
25 struct sipe_core_private;
26 struct sipe_group;
28 struct sipe_buddy {
29 gchar *name;
30 gchar *exchange_key;
31 gchar *change_key;
32 gchar *activity;
33 gchar *meeting_subject;
34 gchar *meeting_location;
35 /* Sipe internal format for Note is HTML.
36 * All incoming plain text should be html-escaped
37 * for example by g_markup_escape_text()
39 gchar *note;
40 gboolean is_oof_note;
41 time_t note_since;
43 /* Calendar related fields */
44 gchar *cal_start_time;
45 int cal_granularity;
46 gchar *cal_free_busy_base64;
47 gchar *cal_free_busy;
48 time_t cal_free_busy_published;
49 /* for 2005 systems */
50 int user_avail;
51 time_t user_avail_since;
52 time_t activity_since;
53 const char *last_non_cal_status_id;
54 gchar *last_non_cal_activity;
56 struct sipe_cal_working_hours *cal_working_hours;
58 gchar *device_name;
59 GSList *groups;
60 /** flag to control sending 'context' element in 2007 subscriptions */
61 gboolean just_added;
62 gboolean is_obsolete;
65 /**
66 * Adds UCS Exchange/Change keys to a @c sipe_buddy structure
68 * @param sipe_private SIPE core data
69 * @param buddy sipe_buddy data structure
70 * @param exchange_key Exchange key (may be @c NULL)
71 * @param change_key Change key (may be @c NULL)
73 void sipe_buddy_add_keys(struct sipe_core_private *sipe_private,
74 struct sipe_buddy *buddy,
75 const gchar *exchange_key,
76 const gchar *change_key);
78 /**
79 * Creates @c sipe_buddy structure for a new buddy and adds it into the buddy
80 * list of given account. If buddy is already in the list, its existing
81 * structure is returned.
83 * @param sipe_private SIPE core data
84 * @param uri SIP URI of a buddy
85 * @param exchange_key Exchange key (may be @c NULL)
86 * @param change_key Change key (may be @c NULL)
88 * @return @c sipe_buddy structure
90 struct sipe_buddy *sipe_buddy_add(struct sipe_core_private *sipe_private,
91 const gchar *uri,
92 const gchar *exchange_key,
93 const gchar *change_key);
95 /**
96 * Add buddy to a group.
98 * @param sipe_private SIPE core data
99 * @param buddy sipe_buddy data structure
100 * @param group sipe_group data structure
101 * @param alias alias for the buddy in that group (may be @c NULL)
103 void sipe_buddy_add_to_group(struct sipe_core_private *sipe_private,
104 struct sipe_buddy *buddy,
105 struct sipe_group *group,
106 const gchar *alias);
109 * Insert a group to buddy group list
111 * @param buddy sipe_buddy data structure
112 * @param group sipe_group data structure
114 void sipe_buddy_insert_group(struct sipe_buddy *buddy,
115 struct sipe_group *group);
118 * Update group list for a buddy
120 * @param sipe_private SIPE core data
121 * @param buddy sipe_buddy data structure
122 * @param group list with new sipe_group data structures
124 void sipe_buddy_update_groups(struct sipe_core_private *sipe_private,
125 struct sipe_buddy *buddy,
126 GSList *new_groups);
129 * Returns string of group IDs the buddy belongs to, e.g. "2 4 7 8"
131 * @param buddy sipe_buddy data structure
133 * @result group string. Must be @c g_free()'d after use.
135 gchar *sipe_buddy_groups_string(struct sipe_buddy *buddy);
138 * Remove entries from local buddy list that do not have corresponding entries
139 * in the ones in the contact list sent by the server
141 * @param sipe_private SIPE core data
143 void sipe_buddy_cleanup_local_list(struct sipe_core_private *sipe_private);
146 * Prepare buddy list for an update
148 * @param sipe_private SIPE core data
150 void sipe_buddy_update_start(struct sipe_core_private *sipe_private);
153 * Finish buddy list update. This will remove obsolete buddies.
155 * @param sipe_private SIPE core data
157 void sipe_buddy_update_finish(struct sipe_core_private *sipe_private);
160 * Find buddy by URI
162 * @param sipe_private SIPE core data
163 * @param uri SIP URI of a buddy
165 * @return @c sipe_buddy structure
167 struct sipe_buddy *sipe_buddy_find_by_uri(struct sipe_core_private *sipe_private,
168 const gchar *uri);
171 * Find buddy by Exchange Key
173 * @param sipe_private SIPE core data
174 * @param uri Exchange Key of a buddy
176 * @return @c sipe_buddy structure
178 struct sipe_buddy *sipe_buddy_find_by_exchange_key(struct sipe_core_private *sipe_private,
179 const gchar *exchange_key);
182 * Iterate buddy list
184 * @param sipe_private SIPE core data
185 * @param callback function to call on each buddy
186 * @param callback_data user data for the callback
188 void sipe_buddy_foreach(struct sipe_core_private *sipe_private,
189 GHFunc callback,
190 gpointer callback_data);
193 * Cancels buddy subscriptions and then deletes the buddy
195 * @param sipe_private SIPE core data
196 * @param buddy @c sipe_buddy structure to remove
198 void sipe_buddy_remove(struct sipe_core_private *sipe_private,
199 struct sipe_buddy *buddy);
202 * Tries to retrieve a real user's name associated with given SIP URI.
204 * Result must be g_free'd after use.
206 * @param sipe_private SIPE core data
207 * @param with a SIP URI
209 * @return Name of the user if the URI is found in buddy list, otherwise @c NULL
211 gchar *sipe_buddy_get_alias(struct sipe_core_private *sipe_private,
212 const gchar *with);
215 * Update the value of a buddy property with given SIP URI
217 * @param sipe_private SIPE core data
218 * @param uri a SIP URI
219 * @param propkey property id (see sipe-backend.h)
220 * @param property_value new value for the property
222 void sipe_buddy_update_property(struct sipe_core_private *sipe_private,
223 const gchar *uri,
224 sipe_buddy_info_fields propkey,
225 gchar *property_value);
228 * Triggers a download of all buddy photos that were changed on the server.
230 * @param sipe_private SIPE core data
232 void sipe_buddy_refresh_photos(struct sipe_core_private *sipe_private);
235 * Number of buddies
237 * @param sipe_private SIPE core data
239 guint sipe_buddy_count(struct sipe_core_private *sipe_private);
242 * Initialize buddy data
244 * @param sipe_private SIPE core data
246 void sipe_buddy_init(struct sipe_core_private *sipe_private);
249 * Free buddy data
251 * @param sipe_private SIPE core data
253 void sipe_buddy_free(struct sipe_core_private *sipe_private);