Depurple sipe_group_buddy
[siplcs.git] / src / api / sipe-core.h
blob5ca1d88482fd6d5f186906d473d67f6d799e8bf4
1 /**
2 * @file sipe-core.h
4 * pidgin-sipe
6 * Copyright (C) 2010-11 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 /**
25 * Backend -> SIPE Core API - functions called by backend code
27 ***************** !!! IMPORTANT NOTE FOR BACKEND CODERS !!! *****************
29 * The SIPE core assumes atomicity and is *NOT* thread-safe.
31 * It *does not* protect any of its data structures or code paths with locks!
33 * In no circumstances it must be interrupted by another thread calling
34 * sipe_core_xxx() while the first thread has entered the SIPE core through
35 * a sipe_core_xxx() function.
37 ***************** !!! IMPORTANT NOTE FOR BACKEND CODERS !!! *****************
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /**
45 * Activity
46 * - core: maps this to OCS protocol values
47 * - backend: maps this to backend status values
49 typedef enum
51 SIPE_ACTIVITY_UNSET = 0,
52 SIPE_ACTIVITY_ONLINE,
53 SIPE_ACTIVITY_INACTIVE,
54 SIPE_ACTIVITY_BUSY,
55 SIPE_ACTIVITY_BUSYIDLE,
56 SIPE_ACTIVITY_DND,
57 SIPE_ACTIVITY_BRB,
58 SIPE_ACTIVITY_AWAY,
59 SIPE_ACTIVITY_LUNCH,
60 SIPE_ACTIVITY_OFFLINE,
61 SIPE_ACTIVITY_ON_PHONE,
62 SIPE_ACTIVITY_IN_CONF,
63 SIPE_ACTIVITY_IN_MEETING,
64 SIPE_ACTIVITY_OOF,
65 SIPE_ACTIVITY_URGENT_ONLY,
66 SIPE_ACTIVITY_NUM_TYPES
67 } sipe_activity;
69 /**
70 * Transport type
72 #define SIPE_TRANSPORT_AUTO 0
73 #define SIPE_TRANSPORT_TLS 1
74 #define SIPE_TRANSPORT_TCP 2
76 /**
77 * Transport connection (public part)
79 * The receiver in the backend fills "buffer". The backend has to zero
80 * terminate the buffer before calling the processing function in the core.
82 * The processing function in the core can remove content from the buffer.
83 * It has to update buffer_used accordingly.
86 struct sipe_transport_connection {
87 gpointer user_data;
88 gchar *buffer;
89 gsize buffer_used; /* 0 < buffer_used < buffer_length */
90 gsize buffer_length; /* read-only */
91 guint type; /* read-only */
92 guint client_port; /* read-only */
95 /**
96 * Opaque data type for chat session
98 struct sipe_chat_session;
101 * File transport (public part)
103 struct sipe_file_transfer {
104 struct sipe_backend_file_transfer *backend_private;
108 * Opaque data type for backend private data.
109 * The backend is responsible to allocate and free it.
111 struct sipe_backend_private;
114 * Flags
116 #define SIPE_CORE_FLAG_KRB5 0x00000001 /* user enabled Kerberos 5 */
117 #define SIPE_CORE_FLAG_SSO 0x00000002 /* user enabled Single-Sign On */
119 #define SIPE_CORE_FLAG_IS(flag) \
120 ((sipe_public->flags & SIPE_CORE_FLAG_ ## flag) == SIPE_CORE_FLAG_ ## flag)
121 #define SIPE_CORE_FLAG_SET(flag) \
122 (sipe_public->flags |= SIPE_CORE_FLAG_ ## flag)
123 #define SIPE_CORE_FLAG_UNSET(flag) \
124 (sipe_public->flags &= ~SIPE_CORE_FLAG_ ## flag)
127 * Public part of the Sipe data structure
129 * This part contains the information needed by the core and the backend.
131 struct sipe_core_public {
133 * This points to the private data for the backend.
134 * The backend is responsible to allocate and free it.
136 struct sipe_backend_private *backend_private;
138 /* flags (see above) */
139 guint32 flags;
141 /* user information */
142 gchar *sip_name;
143 gchar *sip_domain;
145 /* server information */
146 guint keepalive_timeout;
150 * Initialize & destroy functions for the SIPE core
151 * Should be called on loading and unloading of the plugin.
153 void sipe_core_init(const char *locale_dir);
154 void sipe_core_destroy(void);
156 /** Utility functions exported by the core to backends ***********************/
157 gboolean sipe_strequal(const gchar *left, const gchar *right);
159 GSList *
160 sipe_utils_nameval_add(GSList *list, const gchar *name, const gchar *value);
162 const gchar *
163 sipe_utils_nameval_find(const GSList *list, const gchar *name);
165 const gchar *
166 sipe_utils_nameval_find_instance(const GSList *list, const gchar *name, int which);
168 void
169 sipe_utils_nameval_free(GSList *list);
171 gboolean sipe_utils_is_avconf_uri(const gchar *uri);
173 /*****************************************************************************/
176 * Other functions (need to be sorted once structure becomes clear.
179 /* Get translated about string. Must be g_free'd(). */
180 gchar *sipe_core_about(void);
182 /* Execute a scheduled action */
183 void sipe_core_schedule_execute(gpointer data);
185 /* menu actions */
186 void sipe_core_update_calendar(struct sipe_core_public *sipe_public);
187 void sipe_core_reset_status(struct sipe_core_public *sipe_public);
189 /* buddy actions */
191 * Get status text for buddy.
193 * @param sipe_public Sipe core public data structure.
194 * @param name backend-specific buddy name.
195 * @param activity activity value for buddy
196 * @param status_text backend-specific buddy status text for activity.
198 * @return HTML status text for the buddy or NULL. Must be g_free()'d.
200 gchar *sipe_core_buddy_status(struct sipe_core_public *sipe_public,
201 const gchar *name,
202 const sipe_activity activity,
203 const gchar *status_text);
205 void sipe_core_buddy_got_status(struct sipe_core_public *sipe_public,
206 const gchar* uri,
207 const gchar *status_id);
210 * Return a list with buddy information label/text pairs
212 * @param sipe_public Sipe core public data structure.
213 * @param name backend-specific buddy name.
214 * @param status_text backend-specific buddy status text for ID.
215 * @param is_online backend considers buddy to be online.
217 * @return GSList of struct sipe_buddy_info or NULL. Must be freed by caller.
219 struct sipe_buddy_info { /* must be g_free()'d */
220 const gchar *label;
221 gchar *text; /* must be g_free()'d */
223 GSList *sipe_core_buddy_info(struct sipe_core_public *sipe_public,
224 const gchar *name,
225 const gchar *status_name,
226 gboolean is_online);
228 void sipe_core_contact_allow_deny(struct sipe_core_public *sipe_public,
229 const gchar *who, gboolean allow);
230 void sipe_core_group_set_user(struct sipe_core_public *sipe_public,
231 const gchar * who);
234 * Setup core data
236 struct sipe_core_public *sipe_core_allocate(const gchar *signin_name,
237 const gchar *login_domain,
238 const gchar *login_account,
239 const gchar *password,
240 const gchar *email,
241 const gchar *email_url,
242 const gchar **errmsg);
243 void sipe_core_deallocate(struct sipe_core_public *sipe_public);
246 * Connect to SIP server
248 void sipe_core_transport_sip_connect(struct sipe_core_public *sipe_public,
249 guint transport,
250 const gchar *server,
251 const gchar *port);
252 void sipe_core_transport_sip_keepalive(struct sipe_core_public *sipe_public);
255 * Invite to chat
257 void sipe_core_chat_invite(struct sipe_core_public *sipe_public,
258 struct sipe_chat_session *chat_session,
259 const char *name);
262 * Rejoin a chat after connection re-establishment
264 void sipe_core_chat_rejoin(struct sipe_core_public *sipe_public,
265 struct sipe_chat_session *chat_session);
268 * Leave a chat
270 void sipe_core_chat_leave(struct sipe_core_public *sipe_public,
271 struct sipe_chat_session *chat_session);
274 * Send message to chat
276 void sipe_core_chat_send(struct sipe_core_public *sipe_public,
277 struct sipe_chat_session *chat_session,
278 const char *what);
281 * Check chat lock status
283 typedef enum {
284 SIPE_CHAT_LOCK_STATUS_NOT_ALLOWED = 0,
285 SIPE_CHAT_LOCK_STATUS_UNLOCKED,
286 SIPE_CHAT_LOCK_STATUS_LOCKED
287 } sipe_chat_lock_status;
288 sipe_chat_lock_status sipe_core_chat_lock_status(struct sipe_core_public *sipe_public,
289 struct sipe_chat_session *chat_session);
292 * Lock chat
294 void sipe_core_chat_modify_lock(struct sipe_core_public *sipe_public,
295 struct sipe_chat_session *chat_session,
296 const gboolean locked);
299 * Create new session with Focus URI
301 * @param sipe_public (in) SIPE core data.
302 * @param focus_uri (in) focus URI string
304 * @return new SIP session
306 struct sip_session *
307 sipe_core_conf_create(struct sipe_core_public *sipe_public,
308 const gchar *focus_uri);
310 /* media */
311 void sipe_core_media_initiate_call(struct sipe_core_public *sipe_public,
312 const char *participant,
313 gboolean with_video);
315 * Connects to a conference call specified by given chat session
317 * @param sipe_public (in) SIPE core data.
318 * @param chat_session (in) chat session structure
320 void sipe_core_media_connect_conference(struct sipe_core_public *sipe_public,
321 struct sipe_chat_session *chat_session);
324 * Checks whether there is a media call in progress
326 * @param sipe_public (in) SIPE core data.
328 * @return @c TRUE if media call is in progress
330 gboolean sipe_core_media_in_call(struct sipe_core_public *sipe_public);
332 /* file transfer */
333 struct sipe_file_transfer *sipe_core_ft_allocate(struct sipe_core_public *sipe_public);
334 void sipe_core_ft_deallocate(struct sipe_file_transfer *ft);
335 void sipe_core_ft_cancel(struct sipe_file_transfer *ft);
336 void sipe_core_ft_incoming_init(struct sipe_file_transfer *ft);
337 void sipe_core_ft_outgoing_init(struct sipe_file_transfer *ft,
338 const gchar *filename, gsize size,
339 const gchar *who);
341 void sipe_core_tftp_incoming_start(struct sipe_file_transfer *ft,
342 gsize total_size);
343 gboolean sipe_core_tftp_incoming_stop(struct sipe_file_transfer *ft);
344 void sipe_core_tftp_outgoing_start(struct sipe_file_transfer *ft,
345 gsize total_size);
346 gboolean sipe_core_tftp_outgoing_stop(struct sipe_file_transfer *ft);
347 gssize sipe_core_tftp_read(struct sipe_file_transfer *ft, guchar **buffer,
348 gsize bytes_remaining, gsize bytes_available);
349 gssize sipe_core_tftp_write(struct sipe_file_transfer *ft, const guchar *buffer,
350 gsize size);
351 /* group chat */
352 gboolean sipe_core_groupchat_query_rooms(struct sipe_core_public *sipe_public);
353 void sipe_core_groupchat_join(struct sipe_core_public *sipe_public,
354 const gchar *uri);
356 /* IM */
357 void sipe_core_im_send(struct sipe_core_public *sipe_public,
358 const gchar *who,
359 const gchar *what);
361 /* user */
362 void sipe_core_user_feedback_typing(struct sipe_core_public *sipe_public,
363 const gchar *to);
365 void sipe_core_user_ask_cb(gpointer key, gboolean accepted);
367 /* groups */
368 void sipe_core_group_rename(struct sipe_core_public *sipe_public,
369 const gchar *old_name,
370 const gchar *new_name);
372 void sipe_core_group_remove(struct sipe_core_public *sipe_public,
373 const gchar *name);
375 /* buddies */
376 void sipe_core_buddy_group(struct sipe_core_public *sipe_public,
377 const gchar *who,
378 const gchar *old_group_name,
379 const gchar *new_group_name);
381 #ifdef __cplusplus
383 #endif
386 Local Variables:
387 mode: c
388 c-file-style: "bsd"
389 indent-tabs-mode: t
390 tab-width: 8
391 End: