filetransfer: Do not use raw file descriptors in sipe core
[siplcs.git] / src / api / sipe-backend.h
bloba1fe9706d1383c84cc0fbaff7a27d40a888e7c7f
1 /**
2 * @file sipe-backend.h
4 * pidgin-sipe
6 * Copyright (C) 2010 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 * SIPE Core -> Backend API - functions called by SIPE core 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 possible that a sipe_core_xxx() function can
34 * be entered through another thread while the first thread has entered the
35 * backend specific code through a sipe_backend_xxx() function.
37 ***************** !!! IMPORTANT NOTE FOR BACKEND CODERS !!! *****************
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /* Forward declarations */
45 struct sipe_backend_chat_session;
46 struct sipe_chat_session;
47 struct sipe_core_public;
48 struct sipe_transport_connection;
49 struct sipe_file_transfer;
50 struct sipe_media_call;
51 struct sipe_media;
53 /** MISC. STUFF **************************************************************/
54 /**
55 * Get the version of the backend suitable for e.g. UserAgent
57 * @return backend version string. Will be g_free()'d.by the core.
59 gchar *sipe_backend_version(void);
61 /** DEBUGGING ****************************************************************/
63 typedef enum {
64 SIPE_DEBUG_LEVEL_INFO,
65 SIPE_DEBUG_LEVEL_WARNING,
66 SIPE_DEBUG_LEVEL_ERROR,
67 SIPE_DEBUG_LEVEL_FATAL,
68 } sipe_debug_level;
70 /**
71 * Output debug information without formatting
73 * Shouldn't be used directly. Instead use SIPE_DEBUG_xxx() macros
75 * @param level debug level
76 * @param msg debug message "\n" will be automatically appended.
78 void sipe_backend_debug_literal(sipe_debug_level level,
79 const gchar *msg);
81 /**
82 * Output debug information
84 * Shouldn't be used directly. Instead use SIPE_DEBUG_xxx() macros
86 * @param level debug level
87 * @param format format string. "\n" will be automatically appended.
89 void sipe_backend_debug(sipe_debug_level level,
90 const gchar *format,
91 ...) G_GNUC_PRINTF(2, 3);
93 /* Convenience macros */
94 #define SIPE_DEBUG_INFO(fmt, ...) sipe_backend_debug(SIPE_DEBUG_LEVEL_INFO, fmt, __VA_ARGS__)
95 #define SIPE_DEBUG_INFO_NOFORMAT(msg) sipe_backend_debug_literal(SIPE_DEBUG_LEVEL_INFO, msg)
96 #define SIPE_DEBUG_WARNING(fmt, ...) sipe_backend_debug(SIPE_DEBUG_LEVEL_WARNING, fmt, __VA_ARGS__)
97 #define SIPE_DEBUG_WARNING_NOFORMAT(msg) sipe_backend_debug_literal(SIPE_DEBUG_LEVEL_WARNING, msg)
98 #define SIPE_DEBUG_ERROR(fmt, ...) sipe_backend_debug(SIPE_DEBUG_LEVEL_ERROR, fmt, __VA_ARGS__)
99 #define SIPE_DEBUG_ERROR_NOFORMAT(msg) sipe_backend_debug_literal(SIPE_DEBUG_LEVEL_ERROR, msg)
100 #define SIPE_DEBUG_FATAL(fmt, ...) sipe_backend_debug(SIPE_DEBUG_LEVEL_FATAL, fmt, __VA_ARGS__)
101 #define SIPE_DEBUG_FATAL_NOFORMAT(msg) sipe_backend_debug_literal(SIPE_DEBUG_LEVEL_FATAL, msg)
104 * Check backend debugging status
106 * @return TRUE if debugging is enabled
108 gboolean sipe_backend_debug_enabled(void);
110 /** CHAT *********************************************************************/
112 void sipe_backend_chat_session_destroy(struct sipe_backend_chat_session *session);
113 void sipe_backend_chat_add(struct sipe_backend_chat_session *backend_session,
114 const gchar *uri,
115 gboolean is_new);
116 void sipe_backend_chat_close(struct sipe_backend_chat_session *backend_session);
119 * Joined a new chat
121 struct sipe_backend_chat_session *sipe_backend_chat_create(struct sipe_core_public *sipe_public,
122 struct sipe_chat_session *session,
123 const gchar *title,
124 const gchar *nick);
125 gboolean sipe_backend_chat_find(struct sipe_backend_chat_session *backend_session,
126 const gchar *uri);
127 gboolean sipe_backend_chat_is_operator(struct sipe_backend_chat_session *backend_session,
128 const gchar *uri);
129 void sipe_backend_chat_message(struct sipe_core_public *sipe_public,
130 struct sipe_backend_chat_session *backend_session,
131 const gchar *from,
132 const gchar *html);
133 void sipe_backend_chat_operator(struct sipe_backend_chat_session *backend_session,
134 const gchar *uri);
137 * Rejoin an existing chat window after connection re-establishment
139 void sipe_backend_chat_rejoin(struct sipe_core_public *sipe_public,
140 struct sipe_backend_chat_session *backend_session,
141 const gchar *nick,
142 const gchar *title);
145 * Core has completed connection re-establishment.
146 * Should call sipe_core_chat_rejoin() for existing chats.
148 void sipe_backend_chat_rejoin_all(struct sipe_core_public *sipe_public);
149 void sipe_backend_chat_remove(struct sipe_backend_chat_session *backend_session,
150 const gchar *uri);
153 * Move chat window to the front. Will be called when
154 * a user tries to join an already joined chat again.
156 void sipe_backend_chat_show(struct sipe_backend_chat_session *backend_session);
157 void sipe_backend_chat_topic(struct sipe_backend_chat_session *backend_session,
158 const gchar *topic);
160 /** CONNECTION ***************************************************************/
162 void sipe_backend_connection_completed(struct sipe_core_public *sipe_public);
164 typedef enum {
165 SIPE_CONNECTION_ERROR_NETWORK = 0,
166 SIPE_CONNECTION_ERROR_INVALID_USERNAME,
167 SIPE_CONNECTION_ERROR_INVALID_SETTINGS,
168 SIPE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
169 SIPE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
170 SIPE_CONNECTION_ERROR_LAST
171 } sipe_connection_error;
172 void sipe_backend_connection_error(struct sipe_core_public *sipe_public,
173 sipe_connection_error error,
174 const gchar *msg);
176 gboolean sipe_backend_connection_is_disconnecting(struct sipe_core_public *sipe_public);
177 gboolean sipe_backend_connection_is_valid(struct sipe_core_public *sipe_public);
179 /** DNS QUERY ****************************************************************/
181 typedef void (*sipe_dns_resolved_cb)(gpointer data, const gchar *hostname, guint port);
183 struct sipe_dns_query *sipe_backend_dns_query_srv(const gchar *protocol,
184 const gchar *transport,
185 const gchar *domain,
186 sipe_dns_resolved_cb callback,
187 gpointer data);
189 struct sipe_dns_query *sipe_backend_dns_query_a(const gchar *hostname,
190 int port,
191 sipe_dns_resolved_cb callback,
192 gpointer data);
194 void sipe_backend_dns_query_cancel(struct sipe_dns_query *query);
196 /** FILE TRANSFER ************************************************************/
198 struct sipe_backend_fd;
200 void sipe_backend_ft_error(struct sipe_file_transfer *ft,
201 const gchar *errmsg);
202 const gchar *sipe_backend_ft_get_error(struct sipe_file_transfer *ft);
203 void sipe_backend_ft_deallocate(struct sipe_file_transfer *ft);
206 * Try to read up to @c size bytes from file transfer connection
208 * @param ft file transfer data.
209 * @param data buffer to read data into.
210 * @param size buffer size in bytes.
212 * @return number of bytes read or negative on failure.
213 * EAGAIN should return 0 bytes read.
215 gssize sipe_backend_ft_read(struct sipe_file_transfer *ft,
216 guchar *data,
217 gsize size);
220 * Try to write up to @c size bytes to file transfer connection
222 * @param ft file transfer data.
223 * @param data data to write
224 * @param size buffer size in bytes.
226 * @return number of bytes read or negative on failure.
227 * EAGAIN should return 0 bytes written.
229 gssize sipe_backend_ft_write(struct sipe_file_transfer *ft,
230 const guchar *data,
231 gsize size);
234 void sipe_backend_ft_cancel_local(struct sipe_file_transfer *ft);
235 void sipe_backend_ft_cancel_remote(struct sipe_file_transfer *ft);
237 void sipe_backend_ft_incoming(struct sipe_core_public *sipe_public,
238 struct sipe_file_transfer *ft,
239 const gchar *who,
240 const gchar *file_name,
241 gsize file_size);
243 * Begins file transfer with remote peer.
245 * You can provide either opened file descriptor to use for read/write operations
246 * or ip address and port where the backend should connect.
248 * @param ft file transfer data
249 * @param fd opaque file descriptor pointer or NULL if ip and port are used
250 * @param ip ip address to connect of NULL when file descriptor is used
251 * @param port port to connect or 0 when file descriptor is used
253 void sipe_backend_ft_start(struct sipe_file_transfer *ft,
254 struct sipe_backend_fd *fd,
255 const char* ip, unsigned port);
258 * Check whether file transfer is incoming or outgoing
260 * @param ft file transfer data
261 * @return @c TRUE if @c ft is incoming, otherwise @c FALSE
263 gboolean sipe_backend_ft_is_incoming(struct sipe_file_transfer *ft);
265 /** GROUP CHAT ***************************************************************/
267 #define SIPE_GROUPCHAT_ROOM_FILEPOST 0x00000001
268 #define SIPE_GROUPCHAT_ROOM_INVITE 0x00000002
269 #define SIPE_GROUPCHAT_ROOM_LOGGED 0x00000004
270 #define SIPE_GROUPCHAT_ROOM_PRIVATE 0x00000008
273 * Add a room found through room query
275 * @param uri room URI
276 * @param name human readable name for room
277 * @param description room description
278 * @param users number of users in the room
279 * @param flags SIPE_GROUPCHAT_ROOM_* flags
281 void sipe_backend_groupchat_room_add(struct sipe_core_public *sipe_public,
282 const gchar *uri,
283 const gchar *name,
284 const gchar *description,
285 guint users,
286 guint32 flags);
289 * Terminate room query
291 void sipe_backend_groupchat_room_terminate(struct sipe_core_public *sipe_public);
293 /** IM ***********************************************************************/
295 void sipe_backend_im_message(struct sipe_core_public *sipe_public,
296 const gchar *from,
297 const gchar *html);
298 void sipe_backend_im_topic(struct sipe_core_public *sipe_public,
299 const gchar *with,
300 const gchar *topic);
302 /** MARKUP *******************************************************************/
304 gchar *sipe_backend_markup_css_property(const gchar *style,
305 const gchar *option);
306 gchar *sipe_backend_markup_strip_html(const gchar *html);
308 /** MEDIA ********************************************************************/
310 typedef enum {
311 SIPE_ICE_NO_ICE,
312 SIPE_ICE_DRAFT_6,
313 SIPE_ICE_RFC_5245
314 } SipeIceVersion;
316 typedef enum {
317 SIPE_CANDIDATE_TYPE_ANY,
318 SIPE_CANDIDATE_TYPE_HOST,
319 SIPE_CANDIDATE_TYPE_RELAY,
320 SIPE_CANDIDATE_TYPE_SRFLX,
321 SIPE_CANDIDATE_TYPE_PRFLX
322 } SipeCandidateType;
324 typedef enum {
325 SIPE_COMPONENT_NONE = 0,
326 SIPE_COMPONENT_RTP = 1,
327 SIPE_COMPONENT_RTCP = 2
328 } SipeComponentType;
330 typedef enum {
331 SIPE_MEDIA_AUDIO,
332 SIPE_MEDIA_VIDEO
333 } SipeMediaType;
335 typedef enum {
336 SIPE_NETWORK_PROTOCOL_TCP,
337 SIPE_NETWORK_PROTOCOL_UDP
338 } SipeNetworkProtocol;
340 struct sipe_media_call;
341 struct sipe_backend_media;
342 struct sipe_backend_codec;
343 struct sipe_backend_candidate;
344 struct sipe_backend_stream;
345 struct sipe_backend_media_relays;
347 struct sipe_media_call {
348 struct sipe_backend_media *backend_private;
350 void (*candidates_prepared_cb)(struct sipe_media_call *,
351 struct sipe_backend_stream *);
352 void (*media_end_cb)(struct sipe_media_call *);
353 void (*call_accept_cb)(struct sipe_media_call *, gboolean local);
354 void (*call_reject_cb)(struct sipe_media_call *, gboolean local);
355 void (*call_hold_cb) (struct sipe_media_call *, gboolean local,
356 gboolean state);
357 void (*call_hangup_cb)(struct sipe_media_call *, gboolean local);
358 void (*error_cb)(struct sipe_media_call *, gchar *message);
361 struct sipe_media_relay {
362 gchar *hostname;
363 guint udp_port;
364 guint tcp_port;
365 struct sipe_dns_query *dns_query;
368 /* Media handling */
369 struct sipe_backend_media *sipe_backend_media_new(struct sipe_core_public *sipe_public,
370 struct sipe_media_call *call,
371 const gchar *participant,
372 gboolean initiator);
373 void sipe_backend_media_free(struct sipe_backend_media *media);
375 void sipe_backend_media_set_cname(struct sipe_backend_media *media, gchar *cname);
377 struct sipe_backend_media_relays * sipe_backend_media_relays_convert(GSList *media_relays,
378 gchar *username,
379 gchar *password);
380 void sipe_backend_media_relays_free(struct sipe_backend_media_relays *media_relays);
382 struct sipe_backend_stream *sipe_backend_media_add_stream(struct sipe_backend_media *media,
383 const gchar *id,
384 const gchar *participant,
385 SipeMediaType type,
386 SipeIceVersion ice_version,
387 gboolean initiator,
388 struct sipe_backend_media_relays *media_relays);
389 void sipe_backend_media_remove_stream(struct sipe_backend_media *media,
390 struct sipe_backend_stream *stream);
391 GSList *sipe_backend_media_get_streams(struct sipe_backend_media *media);
392 struct sipe_backend_stream *sipe_backend_media_get_stream_by_id(struct sipe_backend_media *media,
393 const gchar *id);
394 void sipe_backend_media_add_remote_candidates(struct sipe_backend_media *media,
395 struct sipe_backend_stream *stream,
396 GList *candidates);
397 gboolean sipe_backend_media_is_initiator(struct sipe_backend_media *media,
398 struct sipe_backend_stream *stream);
399 gboolean sipe_backend_media_accepted(struct sipe_backend_media *media);
400 gboolean sipe_backend_candidates_prepared(struct sipe_backend_media *media);
401 GList *sipe_backend_media_get_active_local_candidates(struct sipe_backend_media *media,
402 struct sipe_backend_stream *stream);
403 GList *sipe_backend_media_get_active_remote_candidates(struct sipe_backend_media *media,
404 struct sipe_backend_stream *stream);
406 /* Stream handling */
407 gchar *sipe_backend_stream_get_id(struct sipe_backend_stream *stream);
408 SipeMediaType sipe_backend_stream_get_type(struct sipe_backend_stream *stream);
409 void sipe_backend_stream_hold(struct sipe_backend_media *media,
410 struct sipe_backend_stream *stream,
411 gboolean local);
412 void sipe_backend_stream_unhold(struct sipe_backend_media *media,
413 struct sipe_backend_stream *stream,
414 gboolean local);
415 gboolean sipe_backend_stream_is_held(struct sipe_backend_stream *stream);
417 /* Codec handling */
418 struct sipe_backend_codec *sipe_backend_codec_new(int id,
419 const char *name,
420 SipeMediaType type, guint clock_rate);
421 void sipe_backend_codec_free(struct sipe_backend_codec *codec);
422 int sipe_backend_codec_get_id(struct sipe_backend_codec *codec);
424 * @return codec name. Will be g_free'd() by the core.
426 gchar *sipe_backend_codec_get_name(struct sipe_backend_codec *codec);
427 guint sipe_backend_codec_get_clock_rate(struct sipe_backend_codec *codec);
428 void sipe_backend_codec_add_optional_parameter(struct sipe_backend_codec *codec,
429 const gchar *name,
430 const gchar *value);
431 GList *sipe_backend_codec_get_optional_parameters(struct sipe_backend_codec *codec);
432 gboolean sipe_backend_set_remote_codecs(struct sipe_backend_media *media,
433 struct sipe_backend_stream *stream,
434 GList *codecs);
435 GList* sipe_backend_get_local_codecs(struct sipe_backend_media *media,
436 struct sipe_backend_stream *stream);
438 /* Candidate handling */
439 struct sipe_backend_candidate * sipe_backend_candidate_new(const gchar *foundation,
440 SipeComponentType component,
441 SipeCandidateType type,
442 SipeNetworkProtocol proto,
443 const gchar *ip, guint port,
444 const gchar *username,
445 const gchar *password);
446 void sipe_backend_candidate_free(struct sipe_backend_candidate *candidate);
448 * @return user name. Will be g_free'd() by the core.
450 gchar *sipe_backend_candidate_get_username(struct sipe_backend_candidate *candidate);
452 * @return password. Will be g_free'd() by the core.
454 gchar *sipe_backend_candidate_get_password(struct sipe_backend_candidate *candidate);
456 * @return foundation. Will be g_free'd() by the core.
458 gchar *sipe_backend_candidate_get_foundation(struct sipe_backend_candidate *candidate);
460 * @return IP address string. Will be g_free'd() by the core.
462 gchar *sipe_backend_candidate_get_ip(struct sipe_backend_candidate *candidate);
463 guint sipe_backend_candidate_get_port(struct sipe_backend_candidate *candidate);
465 * @return IP address string. Will be g_free'd() by the core.
467 gchar *sipe_backend_candidate_get_base_ip(struct sipe_backend_candidate *candidate);
468 guint sipe_backend_candidate_get_base_port(struct sipe_backend_candidate *candidate);
469 guint32 sipe_backend_candidate_get_priority(struct sipe_backend_candidate *candidate);
470 void sipe_backend_candidate_set_priority(struct sipe_backend_candidate *candidate, guint32 priority);
471 SipeComponentType sipe_backend_candidate_get_component_type(struct sipe_backend_candidate *candidate);
472 SipeCandidateType sipe_backend_candidate_get_type(struct sipe_backend_candidate *candidate);
473 SipeNetworkProtocol sipe_backend_candidate_get_protocol(struct sipe_backend_candidate *candidate);
474 GList* sipe_backend_get_local_candidates(struct sipe_backend_media *media,
475 struct sipe_backend_stream *stream);
476 void sipe_backend_media_accept(struct sipe_backend_media *media, gboolean local);
477 void sipe_backend_media_hangup(struct sipe_backend_media *media, gboolean local);
478 void sipe_backend_media_reject(struct sipe_backend_media *media, gboolean local);
480 /** NETWORK ******************************************************************/
482 const gchar *sipe_backend_network_ip_address(void);
484 struct sipe_backend_listendata;
486 typedef void (*sipe_listen_start_cb)(unsigned short port, gpointer data);
487 typedef void (*sipe_client_connected_cb)(struct sipe_backend_fd *fd, gpointer data);
489 struct sipe_backend_listendata *
490 sipe_backend_network_listen_range(unsigned short port_min,
491 unsigned short port_max,
492 sipe_listen_start_cb listen_cb,
493 sipe_client_connected_cb connect_cb,
494 gpointer data);
495 void sipe_backend_network_listen_cancel(struct sipe_backend_listendata *ldata);
497 gboolean sipe_backend_fd_is_valid(struct sipe_backend_fd *fd);
498 void sipe_backend_fd_free(struct sipe_backend_fd *fd);
500 /** NOTIFICATIONS *************************************************************/
502 void sipe_backend_notify_message_error(struct sipe_core_public *sipe_public,
503 struct sipe_backend_chat_session *backend_session,
504 const gchar *who,
505 const gchar *message);
506 void sipe_backend_notify_message_info(struct sipe_core_public *sipe_public,
507 struct sipe_backend_chat_session *backend_session,
508 const gchar *who,
509 const gchar *message);
510 void sipe_backend_notify_error(const gchar *title, const gchar *msg);
512 /** SCHEDULE *****************************************************************/
514 gpointer sipe_backend_schedule_seconds(struct sipe_core_public *sipe_public,
515 guint timeout,
516 gpointer data);
517 gpointer sipe_backend_schedule_mseconds(struct sipe_core_public *sipe_public,
518 guint timeout,
519 gpointer data);
520 void sipe_backend_schedule_cancel(struct sipe_core_public *sipe_public,
521 gpointer data);
523 /** SETTINGS *****************************************************************/
525 typedef enum {
526 SIPE_SETTING_EMAIL_URL = 0,
527 SIPE_SETTING_EMAIL_LOGIN,
528 SIPE_SETTING_EMAIL_PASSWORD,
529 SIPE_SETTING_GROUPCHAT_USER,
530 SIPE_SETTING_USER_AGENT,
531 SIPE_SETTING_LAST
532 } sipe_setting;
533 const gchar *sipe_backend_setting(struct sipe_core_public *sipe_public,
534 sipe_setting type);
536 /** TRANSPORT ****************************************************************/
538 typedef void transport_connected_cb(struct sipe_transport_connection *conn);
539 typedef void transport_input_cb(struct sipe_transport_connection *conn);
540 typedef void transport_error_cb(struct sipe_transport_connection *conn,
541 const gchar *msg);
543 typedef struct {
544 guint type;
545 const gchar *server_name;
546 guint server_port;
547 gpointer user_data;
548 transport_connected_cb *connected;
549 transport_input_cb *input;
550 transport_error_cb *error;
551 } sipe_connect_setup;
552 struct sipe_transport_connection *sipe_backend_transport_connect(struct sipe_core_public *sipe_public,
553 const sipe_connect_setup *setup);
554 void sipe_backend_transport_disconnect(struct sipe_transport_connection *conn);
555 void sipe_backend_transport_message(struct sipe_transport_connection *conn,
556 const gchar *buffer);
557 void sipe_backend_transport_flush(struct sipe_transport_connection *conn);
559 /** USER *********************************************************************/
561 void sipe_backend_user_feedback_typing(struct sipe_core_public *sipe_public,
562 const gchar *from);
563 void sipe_backend_user_feedback_typing_stop(struct sipe_core_public *sipe_public,
564 const gchar *from);
567 * Present a query that is to be accepted or declined by the user
569 * @param sipe_public The handle representing the protocol instance
570 * @param message Text of the query to be shown to user
571 * @param accept_label Label to be displayed on UI control that accepts query
572 * @param decline_label Label to be displayed on UI control that declines query
573 * @param key Opaque handle uniquely identifying the query. Backend
574 * should store it for the case SIPE core requests the
575 * query to be closed prematurely.
577 void sipe_backend_user_ask(struct sipe_core_public *sipe_public,
578 const gchar *message,
579 const gchar *accept_label,
580 const gchar *decline_label,
581 gpointer key);
584 * Closes the pending user query
586 * @param key Opaque handle uniquely identifying the query.
588 void sipe_backend_user_close_ask(gpointer key);
590 /** BUDDIES ******************************************************************/
592 /* The list of properties a buddy can have */
593 typedef enum
595 SIPE_BUDDY_INFO_DISPLAY_NAME,
596 SIPE_BUDDY_INFO_JOB_TITLE,
597 SIPE_BUDDY_INFO_CITY,
598 SIPE_BUDDY_INFO_STATE,
599 SIPE_BUDDY_INFO_OFFICE,
600 SIPE_BUDDY_INFO_DEPARTMENT,
601 SIPE_BUDDY_INFO_COUNTRY,
602 SIPE_BUDDY_INFO_WORK_PHONE,
603 SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY,
604 SIPE_BUDDY_INFO_COMPANY,
605 SIPE_BUDDY_INFO_EMAIL,
606 SIPE_BUDDY_INFO_DEVICE,
607 SIPE_BUDDY_INFO_SITE,
608 SIPE_BUDDY_INFO_ZIPCODE,
609 SIPE_BUDDY_INFO_STREET,
610 SIPE_BUDDY_INFO_MOBILE_PHONE,
611 SIPE_BUDDY_INFO_MOBILE_PHONE_DISPLAY,
612 SIPE_BUDDY_INFO_HOME_PHONE,
613 SIPE_BUDDY_INFO_HOME_PHONE_DISPLAY,
614 SIPE_BUDDY_INFO_OTHER_PHONE,
615 SIPE_BUDDY_INFO_OTHER_PHONE_DISPLAY,
616 SIPE_BUDDY_INFO_CUSTOM1_PHONE,
617 SIPE_BUDDY_INFO_CUSTOM1_PHONE_DISPLAY,
618 } sipe_buddy_info_fields;
620 /* Opaque token */
621 typedef void* sipe_backend_buddy;
624 * Find a buddy in the given group of the buddy list, or anywhere on the
625 * list if @group_name is empty
627 * @param sipe_public The handle representing the protocol instance making the call
628 * @param buddy_name The name of the buddy
629 * @param group_name The name of the group to look in, or NULL for any group
630 * @return opaque handle to the buddy, or NULL if no buddy found
632 sipe_backend_buddy sipe_backend_buddy_find(struct sipe_core_public *sipe_public,
633 const gchar *buddy_name,
634 const gchar *group_name);
637 * Find all named buddies in the given group of the buddy list, or anywhere on the
638 * list if @group_name is empty; or all buddies if @name is empty
640 * @param sipe_public The handle representing the protocol instance making the call
641 * @param name The name of the buddy
642 * @param group_name The name of the group to look in, or NULL for any group
643 * @return GSList of opaque handles to the buddies
645 GSList* sipe_backend_buddy_find_all(struct sipe_core_public *sipe_public,
646 const gchar *buddy_name,
647 const gchar *group_name);
650 * Gets the name of a contact.
652 * @param sipe_public The handle representing the protocol instance making the call
653 * @param who The opaque handle to the contact as found by find_buddy
654 * @return The name. Must be freed.
656 gchar* sipe_backend_buddy_get_name(struct sipe_core_public *sipe_public,
657 const sipe_backend_buddy who);
660 * Gets the alias for a contact.
662 * @param sipe_public The handle representing the protocol instance making the call
663 * @param who The opaque handle to the contact as found by find_buddy
664 * @return The alias. Must be gfree'd.
666 gchar* sipe_backend_buddy_get_alias(struct sipe_core_public *sipe_public,
667 const sipe_backend_buddy who);
670 * Gets the server alias for a contact.
672 * @param sipe_public The handle representing the protocol instance making the call
673 * @param who The opaque handle to the contact as found by find_buddy
674 * @return The alias. Must be freed.
676 gchar* sipe_backend_buddy_get_server_alias(struct sipe_core_public *sipe_public,
677 const sipe_backend_buddy who);
680 * Gets the name of the group a contact belongs to.
682 * @param sipe_public The handle representing the protocol instance making the call
683 * @param who The opaque handle to the contact as found by find_buddy
684 * @return The name. Must be freed.
686 gchar* sipe_backend_buddy_get_group_name(struct sipe_core_public *sipe_public,
687 const sipe_backend_buddy who);
690 * Called to retrieve a buddy-specific setting.
692 * @param sipe_public The handle representing the protocol instance making the call
693 * @param buddy The handle representing the buddy
694 * @param key The name of the setting
695 * @return The value of the setting. Must be freed.
697 gchar* sipe_backend_buddy_get_string(struct sipe_core_public *sipe_public,
698 sipe_backend_buddy buddy,
699 const sipe_buddy_info_fields key);
702 * Called to retrieve a buddy-specific setting.
704 * @param sipe_public The handle representing the protocol instance making the call
705 * @param buddy The handle representing the buddy
706 * @param key The name of the setting
707 * @param val The value to set
709 void sipe_backend_buddy_set_string(struct sipe_core_public *sipe_public,
710 sipe_backend_buddy buddy,
711 const sipe_buddy_info_fields key,
712 const gchar *val);
715 * Sets the alias for a contact.
717 * @param sipe_public The handle representing the protocol instance making the call
718 * @param who The opaque handle to the contact as found by find_buddy
719 * @param alias The location where the alias will be put
720 * case. FALSE if the buddy was not found. The value of alias will not be changed.
722 void sipe_backend_buddy_set_alias(struct sipe_core_public *sipe_public,
723 const sipe_backend_buddy who,
724 const gchar *alias);
727 * Sets the server alias for a contact.
729 * @param sipe_public The handle representing the protocol instance making the call
730 * @param who The opaque handle to the contact as found by find_buddy
731 * @param alias The server alias of the contact
733 void sipe_backend_buddy_set_server_alias(struct sipe_core_public *sipe_public,
734 const sipe_backend_buddy who,
735 const gchar *alias);
738 * Add a contact to the buddy list
740 * @param sipe_public The handle representing the protocol instance making the call
741 * @param name The name of the contact
742 * @param alias The alias of the contact
743 * @param groupname The name of the group to add this contact to
744 * @return A handle to the newly created buddy
746 sipe_backend_buddy sipe_backend_buddy_add(struct sipe_core_public *sipe_public,
747 const gchar *name,
748 const gchar *alias,
749 const gchar *groupname);
752 * Remove a contact from the buddy list
754 * @param sipe_public The handle representing the protocol instance making the call
755 * @param who The opaque handle to the contact as found by find_buddy
757 void sipe_backend_buddy_remove(struct sipe_core_public *sipe_public,
758 const sipe_backend_buddy who);
761 * Notifies the user that a remote user has wants to add the local user to his
762 * or her buddy list and requires authorization to do so.
764 * @param sipe_public The handle representing the protocol instance making the call
765 * @param who The name of the user that added this account
766 * @param alias The optional alias of the remote user
767 * @param on_list True if the user is already in our list
768 * @param auth_cb The callback called when the local user accepts
769 * @param deny_cb The callback called when the local user rejects
770 * @param data Data to be passed back to the above callbacks
772 typedef void (*sipe_backend_buddy_request_authorization_cb)(void *);
774 void sipe_backend_buddy_request_add(struct sipe_core_public *sipe_public,
775 const gchar *who,
776 const gchar *alias);
778 void sipe_backend_buddy_request_authorization(struct sipe_core_public *sipe_public,
779 const gchar *who,
780 const gchar *alias,
781 gboolean on_list,
782 sipe_backend_buddy_request_authorization_cb auth_cb,
783 sipe_backend_buddy_request_authorization_cb deny_cb,
784 gpointer data);
786 gboolean sipe_backend_buddy_is_blocked(struct sipe_core_public *sipe_public,
787 const gchar *who);
789 void sipe_backend_buddy_set_blocked_status(struct sipe_core_public *sipe_public,
790 const gchar *who,
791 gboolean blocked);
793 void sipe_backend_buddy_set_status(struct sipe_core_public *sipe_public,
794 const gchar *who,
795 const gchar *status_id);
798 * Called when a new internal group is about to be added. If this returns FALSE,
799 * the group will not be added.
801 * @param sipe_public The handle representing the protocol instance making the call
802 * @param group The group being added
803 * @return TRUE if everything is ok, FALSE if the group should not be added
805 gboolean sipe_backend_buddy_group_add(struct sipe_core_public *sipe_public,
806 const gchar *group_name);
808 #ifdef __cplusplus
810 #endif
813 Local Variables:
814 mode: c
815 c-file-style: "bsd"
816 indent-tabs-mode: t
817 tab-width: 8
818 End: