crypt: add TLS stream cipher type
[siplcs.git] / src / api / sipe-backend.h
blob538efafae41b0de5a45f7d93ecefab1f09fce5d2
1 /**
2 * @file sipe-backend.h
4 * pidgin-sipe
6 * Copyright (C) 2010-2015 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;
69 /**
70 * Output debug information without formatting
72 * Shouldn't be used directly. Instead use SIPE_DEBUG_xxx() macros
74 * @param level debug level
75 * @param msg debug message "\n" will be automatically appended.
77 void sipe_backend_debug_literal(sipe_debug_level level,
78 const gchar *msg);
80 /**
81 * Output debug information
83 * Shouldn't be used directly. Instead use SIPE_DEBUG_xxx() macros
85 * @param level debug level
86 * @param format format string. "\n" will be automatically appended.
88 void sipe_backend_debug(sipe_debug_level level,
89 const gchar *format,
90 ...) G_GNUC_PRINTF(2, 3);
92 /* Convenience macros */
93 #define SIPE_DEBUG_INFO(fmt, ...) sipe_backend_debug(SIPE_DEBUG_LEVEL_INFO, fmt, __VA_ARGS__)
94 #define SIPE_DEBUG_INFO_NOFORMAT(msg) sipe_backend_debug_literal(SIPE_DEBUG_LEVEL_INFO, msg)
95 #define SIPE_DEBUG_WARNING(fmt, ...) sipe_backend_debug(SIPE_DEBUG_LEVEL_WARNING, fmt, __VA_ARGS__)
96 #define SIPE_DEBUG_WARNING_NOFORMAT(msg) sipe_backend_debug_literal(SIPE_DEBUG_LEVEL_WARNING, msg)
97 #define SIPE_DEBUG_ERROR(fmt, ...) sipe_backend_debug(SIPE_DEBUG_LEVEL_ERROR, fmt, __VA_ARGS__)
98 #define SIPE_DEBUG_ERROR_NOFORMAT(msg) sipe_backend_debug_literal(SIPE_DEBUG_LEVEL_ERROR, msg)
101 * Check backend debugging status
103 * @return TRUE if debugging is enabled
105 gboolean sipe_backend_debug_enabled(void);
107 /** CHAT *********************************************************************/
109 void sipe_backend_chat_session_destroy(struct sipe_backend_chat_session *session);
110 void sipe_backend_chat_add(struct sipe_backend_chat_session *backend_session,
111 const gchar *uri,
112 gboolean is_new);
113 void sipe_backend_chat_close(struct sipe_backend_chat_session *backend_session);
116 * Joined a new chat
118 struct sipe_backend_chat_session *sipe_backend_chat_create(struct sipe_core_public *sipe_public,
119 struct sipe_chat_session *session,
120 const gchar *title,
121 const gchar *nick);
122 gboolean sipe_backend_chat_find(struct sipe_backend_chat_session *backend_session,
123 const gchar *uri);
124 gboolean sipe_backend_chat_is_operator(struct sipe_backend_chat_session *backend_session,
125 const gchar *uri);
126 void sipe_backend_chat_message(struct sipe_core_public *sipe_public,
127 struct sipe_backend_chat_session *backend_session,
128 const gchar *from,
129 time_t when,
130 const gchar *html);
131 void sipe_backend_chat_operator(struct sipe_backend_chat_session *backend_session,
132 const gchar *uri);
135 * Rejoin an existing chat window after connection re-establishment
137 void sipe_backend_chat_rejoin(struct sipe_core_public *sipe_public,
138 struct sipe_backend_chat_session *backend_session,
139 const gchar *nick,
140 const gchar *title);
143 * Core has completed connection re-establishment.
144 * Should call sipe_core_chat_rejoin() for existing chats.
146 void sipe_backend_chat_rejoin_all(struct sipe_core_public *sipe_public);
147 void sipe_backend_chat_remove(struct sipe_backend_chat_session *backend_session,
148 const gchar *uri);
151 * Move chat window to the front. Will be called when
152 * a user tries to join an already joined chat again.
154 void sipe_backend_chat_show(struct sipe_backend_chat_session *backend_session);
155 void sipe_backend_chat_topic(struct sipe_backend_chat_session *backend_session,
156 const gchar *topic);
158 /** CONNECTION ***************************************************************/
160 void sipe_backend_connection_completed(struct sipe_core_public *sipe_public);
162 typedef enum {
163 SIPE_CONNECTION_ERROR_NETWORK = 0,
164 SIPE_CONNECTION_ERROR_INVALID_USERNAME,
165 SIPE_CONNECTION_ERROR_INVALID_SETTINGS,
166 SIPE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
167 SIPE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
168 SIPE_CONNECTION_ERROR_LAST
169 } sipe_connection_error;
170 void sipe_backend_connection_error(struct sipe_core_public *sipe_public,
171 sipe_connection_error error,
172 const gchar *msg);
174 gboolean sipe_backend_connection_is_disconnecting(struct sipe_core_public *sipe_public);
175 gboolean sipe_backend_connection_is_valid(struct sipe_core_public *sipe_public);
177 /** DNS QUERY ****************************************************************/
179 typedef void (*sipe_dns_resolved_cb)(gpointer data, const gchar *hostname, guint port);
181 struct sipe_dns_query *sipe_backend_dns_query_srv(struct sipe_core_public *sipe_public,
182 const gchar *protocol,
183 const gchar *transport,
184 const gchar *domain,
185 sipe_dns_resolved_cb callback,
186 gpointer data);
188 struct sipe_dns_query *sipe_backend_dns_query_a(struct sipe_core_public *sipe_public,
189 const gchar *hostname,
190 guint 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_UDP,
337 SIPE_NETWORK_PROTOCOL_TCP_ACTIVE,
338 SIPE_NETWORK_PROTOCOL_TCP_PASSIVE,
339 SIPE_NETWORK_PROTOCOL_TCP_SO,
340 } SipeNetworkProtocol;
342 typedef enum {
343 SIPE_ENCRYPTION_POLICY_REJECTED,
344 SIPE_ENCRYPTION_POLICY_OPTIONAL,
345 SIPE_ENCRYPTION_POLICY_REQUIRED,
346 SIPE_ENCRYPTION_POLICY_OBEY_SERVER
347 } SipeEncryptionPolicy;
349 struct sipe_media_call;
350 struct sipe_backend_media;
351 struct sipe_backend_codec;
352 struct sipe_backend_candidate;
353 struct sipe_backend_media_stream;
354 struct sipe_backend_media_relays;
356 struct sipe_media_stream {
357 struct sipe_backend_media_stream *backend_private;
359 gchar *id;
362 struct sipe_media_call {
363 struct sipe_backend_media *backend_private;
365 gchar *with;
367 void (*stream_initialized_cb)(struct sipe_media_call *,
368 struct sipe_media_stream *);
369 void (*stream_end_cb)(struct sipe_media_call *,
370 struct sipe_media_stream *);
371 void (*media_end_cb)(struct sipe_media_call *);
372 void (*call_accept_cb)(struct sipe_media_call *, gboolean local);
373 void (*call_reject_cb)(struct sipe_media_call *, gboolean local);
374 void (*call_hold_cb) (struct sipe_media_call *, gboolean local,
375 gboolean state);
376 void (*call_hangup_cb)(struct sipe_media_call *, gboolean local);
377 void (*error_cb)(struct sipe_media_call *, gchar *message);
380 struct sipe_media_relay {
381 gchar *hostname;
382 guint udp_port;
383 guint tcp_port;
384 struct sipe_dns_query *dns_query;
387 /* Media handling */
388 struct sipe_backend_media *sipe_backend_media_new(struct sipe_core_public *sipe_public,
389 struct sipe_media_call *call,
390 const gchar *participant,
391 gboolean initiator);
392 void sipe_backend_media_free(struct sipe_backend_media *media);
394 void sipe_backend_media_set_cname(struct sipe_backend_media *media, gchar *cname);
396 struct sipe_backend_media_relays * sipe_backend_media_relays_convert(GSList *media_relays,
397 gchar *username,
398 gchar *password);
399 void sipe_backend_media_relays_free(struct sipe_backend_media_relays *media_relays);
401 struct sipe_backend_media_stream *sipe_backend_media_add_stream(struct sipe_media_call *media,
402 const gchar *id,
403 const gchar *participant,
404 SipeMediaType type,
405 SipeIceVersion ice_version,
406 gboolean initiator,
407 struct sipe_backend_media_relays *media_relays);
408 void sipe_backend_media_add_remote_candidates(struct sipe_media_call *media,
409 struct sipe_media_stream *stream,
410 GList *candidates);
411 gboolean sipe_backend_media_is_initiator(struct sipe_media_call *media,
412 struct sipe_media_stream *stream);
413 gboolean sipe_backend_media_accepted(struct sipe_backend_media *media);
414 gboolean sipe_backend_stream_initialized(struct sipe_media_call *media,
415 struct sipe_media_stream *stream);
416 GList *sipe_backend_media_get_active_local_candidates(struct sipe_media_call *media,
417 struct sipe_media_stream *stream);
418 GList *sipe_backend_media_get_active_remote_candidates(struct sipe_media_call *media,
419 struct sipe_media_stream *stream);
420 void sipe_backend_media_set_encryption_keys(struct sipe_media_call *media,
421 struct sipe_media_stream *stream,
422 const guchar *encryption_key,
423 const guchar *decryption_key);
425 /* Stream handling */
426 void sipe_backend_stream_hold(struct sipe_media_call *media,
427 struct sipe_media_stream *stream,
428 gboolean local);
429 void sipe_backend_stream_unhold(struct sipe_media_call *media,
430 struct sipe_media_stream *stream,
431 gboolean local);
432 gboolean sipe_backend_stream_is_held(struct sipe_media_stream *stream);
433 void sipe_backend_media_stream_end(struct sipe_media_call *media,
434 struct sipe_media_stream *stream);
435 void sipe_backend_media_stream_free(struct sipe_backend_media_stream *stream);
437 /* Codec handling */
438 struct sipe_backend_codec *sipe_backend_codec_new(int id,
439 const char *name,
440 SipeMediaType type, guint clock_rate);
441 void sipe_backend_codec_free(struct sipe_backend_codec *codec);
442 int sipe_backend_codec_get_id(struct sipe_backend_codec *codec);
444 * @return codec name. Will be g_free'd() by the core.
446 gchar *sipe_backend_codec_get_name(struct sipe_backend_codec *codec);
447 guint sipe_backend_codec_get_clock_rate(struct sipe_backend_codec *codec);
448 void sipe_backend_codec_add_optional_parameter(struct sipe_backend_codec *codec,
449 const gchar *name,
450 const gchar *value);
451 GList *sipe_backend_codec_get_optional_parameters(struct sipe_backend_codec *codec);
452 gboolean sipe_backend_set_remote_codecs(struct sipe_media_call *media,
453 struct sipe_media_stream *stream,
454 GList *codecs);
455 GList* sipe_backend_get_local_codecs(struct sipe_media_call *media,
456 struct sipe_media_stream *stream);
458 /* Candidate handling */
459 struct sipe_backend_candidate * sipe_backend_candidate_new(const gchar *foundation,
460 SipeComponentType component,
461 SipeCandidateType type,
462 SipeNetworkProtocol proto,
463 const gchar *ip, guint port,
464 const gchar *username,
465 const gchar *password);
466 void sipe_backend_candidate_free(struct sipe_backend_candidate *candidate);
468 * @return user name. Will be g_free'd() by the core.
470 gchar *sipe_backend_candidate_get_username(struct sipe_backend_candidate *candidate);
472 * @return password. Will be g_free'd() by the core.
474 gchar *sipe_backend_candidate_get_password(struct sipe_backend_candidate *candidate);
476 * @return foundation. Will be g_free'd() by the core.
478 gchar *sipe_backend_candidate_get_foundation(struct sipe_backend_candidate *candidate);
480 * @return IP address string. Will be g_free'd() by the core.
482 gchar *sipe_backend_candidate_get_ip(struct sipe_backend_candidate *candidate);
483 guint sipe_backend_candidate_get_port(struct sipe_backend_candidate *candidate);
485 * @return IP address string. Will be g_free'd() by the core.
487 gchar *sipe_backend_candidate_get_base_ip(struct sipe_backend_candidate *candidate);
488 guint sipe_backend_candidate_get_base_port(struct sipe_backend_candidate *candidate);
489 guint32 sipe_backend_candidate_get_priority(struct sipe_backend_candidate *candidate);
490 void sipe_backend_candidate_set_priority(struct sipe_backend_candidate *candidate, guint32 priority);
491 SipeComponentType sipe_backend_candidate_get_component_type(struct sipe_backend_candidate *candidate);
492 SipeCandidateType sipe_backend_candidate_get_type(struct sipe_backend_candidate *candidate);
493 SipeNetworkProtocol sipe_backend_candidate_get_protocol(struct sipe_backend_candidate *candidate);
494 GList* sipe_backend_get_local_candidates(struct sipe_media_call *media,
495 struct sipe_media_stream *stream);
496 void sipe_backend_media_accept(struct sipe_backend_media *media, gboolean local);
497 void sipe_backend_media_hangup(struct sipe_backend_media *media, gboolean local);
498 void sipe_backend_media_reject(struct sipe_backend_media *media, gboolean local);
500 /** NETWORK ******************************************************************/
502 const gchar *sipe_backend_network_ip_address(struct sipe_core_public *sipe_public);
504 struct sipe_backend_listendata;
506 typedef void (*sipe_listen_start_cb)(unsigned short port, gpointer data);
507 typedef void (*sipe_client_connected_cb)(struct sipe_backend_fd *fd, gpointer data);
509 struct sipe_backend_listendata *
510 sipe_backend_network_listen_range(unsigned short port_min,
511 unsigned short port_max,
512 sipe_listen_start_cb listen_cb,
513 sipe_client_connected_cb connect_cb,
514 gpointer data);
515 void sipe_backend_network_listen_cancel(struct sipe_backend_listendata *ldata);
517 gboolean sipe_backend_fd_is_valid(struct sipe_backend_fd *fd);
518 void sipe_backend_fd_free(struct sipe_backend_fd *fd);
520 /** NOTIFICATIONS *************************************************************/
522 void sipe_backend_notify_message_error(struct sipe_core_public *sipe_public,
523 struct sipe_backend_chat_session *backend_session,
524 const gchar *who,
525 const gchar *message);
526 void sipe_backend_notify_message_info(struct sipe_core_public *sipe_public,
527 struct sipe_backend_chat_session *backend_session,
528 const gchar *who,
529 const gchar *message);
532 * @param msg error message. Maybe @NULL
534 void sipe_backend_notify_error(struct sipe_core_public *sipe_public,
535 const gchar *title,
536 const gchar *msg);
538 /** SCHEDULE *****************************************************************/
540 gpointer sipe_backend_schedule_seconds(struct sipe_core_public *sipe_public,
541 guint timeout,
542 gpointer data);
543 gpointer sipe_backend_schedule_mseconds(struct sipe_core_public *sipe_public,
544 guint timeout,
545 gpointer data);
546 void sipe_backend_schedule_cancel(struct sipe_core_public *sipe_public,
547 gpointer data);
549 /** SEARCH *******************************************************************/
551 struct sipe_backend_search_results;
552 struct sipe_backend_search_token;
554 void sipe_backend_search_failed(struct sipe_core_public *sipe_public,
555 struct sipe_backend_search_token *token,
556 const gchar *msg);
557 struct sipe_backend_search_results *sipe_backend_search_results_start(struct sipe_core_public *sipe_public,
558 struct sipe_backend_search_token *token);
559 void sipe_backend_search_results_add(struct sipe_core_public *sipe_public,
560 struct sipe_backend_search_results *results,
561 const gchar *uri,
562 const gchar *name,
563 const gchar *company,
564 const gchar *country,
565 const gchar *email);
566 void sipe_backend_search_results_finalize(struct sipe_core_public *sipe_public,
567 struct sipe_backend_search_results *results,
568 const gchar *description,
569 gboolean more);
571 /** SETTINGS *****************************************************************/
573 typedef enum {
574 SIPE_SETTING_EMAIL_URL = 0,
575 SIPE_SETTING_EMAIL_LOGIN,
576 SIPE_SETTING_EMAIL_PASSWORD,
577 SIPE_SETTING_GROUPCHAT_USER,
578 SIPE_SETTING_USER_AGENT,
579 SIPE_SETTING_LAST
580 } sipe_setting;
581 const gchar *sipe_backend_setting(struct sipe_core_public *sipe_public,
582 sipe_setting type);
584 /** STATUS *******************************************************************/
586 guint sipe_backend_status(struct sipe_core_public *sipe_public);
587 gboolean sipe_backend_status_changed(struct sipe_core_public *sipe_public,
588 guint activity,
589 const gchar *message);
592 * Update user client with new status and note received from server
594 * NOTE: this must *NOT* trigger a call to @c sipe_core_status_set()!
596 * @param sipe_public The handle representing the protocol instance
597 * @param activity New activity
598 * @param message New note text
600 void sipe_backend_status_and_note(struct sipe_core_public *sipe_public,
601 guint activity,
602 const gchar *message);
604 /** TRANSPORT ****************************************************************/
606 typedef void transport_connected_cb(struct sipe_transport_connection *conn);
607 typedef void transport_input_cb(struct sipe_transport_connection *conn);
608 typedef void transport_error_cb(struct sipe_transport_connection *conn,
609 const gchar *msg);
611 typedef struct {
612 guint type;
613 const gchar *server_name;
614 guint server_port;
615 gpointer user_data;
616 transport_connected_cb *connected;
617 transport_input_cb *input;
618 transport_error_cb *error;
619 } sipe_connect_setup;
620 struct sipe_transport_connection *sipe_backend_transport_connect(struct sipe_core_public *sipe_public,
621 const sipe_connect_setup *setup);
622 void sipe_backend_transport_disconnect(struct sipe_transport_connection *conn);
623 void sipe_backend_transport_message(struct sipe_transport_connection *conn,
624 const gchar *buffer);
625 void sipe_backend_transport_flush(struct sipe_transport_connection *conn);
627 /** USER *********************************************************************/
629 void sipe_backend_user_feedback_typing(struct sipe_core_public *sipe_public,
630 const gchar *from);
631 void sipe_backend_user_feedback_typing_stop(struct sipe_core_public *sipe_public,
632 const gchar *from);
635 * Present a query that is to be accepted or declined by the user
637 * @param sipe_public The handle representing the protocol instance
638 * @param message Text of the query to be shown to user
639 * @param accept_label Label to be displayed on UI control that accepts query
640 * @param decline_label Label to be displayed on UI control that declines query
641 * @param key Opaque handle uniquely identifying the query. Backend
642 * should store it for the case SIPE core requests the
643 * query to be closed prematurely.
645 void sipe_backend_user_ask(struct sipe_core_public *sipe_public,
646 const gchar *message,
647 const gchar *accept_label,
648 const gchar *decline_label,
649 gpointer key);
652 * Closes the pending user query
654 * @param key Opaque handle uniquely identifying the query.
656 void sipe_backend_user_close_ask(gpointer key);
658 /** BUDDIES ******************************************************************/
661 * sipe_backend_buddy_get/set_string(): properties a buddy can have
662 * sipe_backend_buddy_info_add(): mapped, e.g. to a string label
664 typedef enum
666 SIPE_BUDDY_INFO_DISPLAY_NAME = 0,
667 SIPE_BUDDY_INFO_JOB_TITLE,
668 SIPE_BUDDY_INFO_CITY,
669 SIPE_BUDDY_INFO_STATE,
670 SIPE_BUDDY_INFO_OFFICE,
671 SIPE_BUDDY_INFO_DEPARTMENT,
672 SIPE_BUDDY_INFO_COUNTRY,
673 SIPE_BUDDY_INFO_WORK_PHONE,
674 SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY,
675 SIPE_BUDDY_INFO_COMPANY,
676 SIPE_BUDDY_INFO_EMAIL,
677 SIPE_BUDDY_INFO_SITE,
678 SIPE_BUDDY_INFO_ZIPCODE,
679 SIPE_BUDDY_INFO_STREET,
680 SIPE_BUDDY_INFO_MOBILE_PHONE,
681 SIPE_BUDDY_INFO_MOBILE_PHONE_DISPLAY,
682 SIPE_BUDDY_INFO_HOME_PHONE,
683 SIPE_BUDDY_INFO_HOME_PHONE_DISPLAY,
684 SIPE_BUDDY_INFO_OTHER_PHONE,
685 SIPE_BUDDY_INFO_OTHER_PHONE_DISPLAY,
686 SIPE_BUDDY_INFO_CUSTOM1_PHONE,
687 SIPE_BUDDY_INFO_CUSTOM1_PHONE_DISPLAY,
688 SIPE_BUDDY_INFO_ALIAS, /* only for sipe_backend_buddy_info_add() */
689 SIPE_BUDDY_INFO_DEVICE, /* only for sipe_backend_buddy_info_add() */
690 } sipe_buddy_info_fields;
692 /* Opaque token */
693 typedef void* sipe_backend_buddy;
696 * Find a buddy in the given group of the buddy list, or anywhere on the
697 * list if @group_name is empty
699 * @param sipe_public The handle representing the protocol instance making the call
700 * @param buddy_name The name of the buddy
701 * @param group_name The name of the group to look in, or NULL for any group
702 * @return opaque handle to the buddy, or NULL if no buddy found
704 sipe_backend_buddy sipe_backend_buddy_find(struct sipe_core_public *sipe_public,
705 const gchar *buddy_name,
706 const gchar *group_name);
709 * Find all named buddies in the given group of the buddy list, or anywhere on the
710 * list if @group_name is empty; or all buddies if @name is empty
712 * @param sipe_public The handle representing the protocol instance making the call
713 * @param name The name of the buddy
714 * @param group_name The name of the group to look in, or NULL for any group
715 * @return GSList of opaque handles to the buddies
717 GSList* sipe_backend_buddy_find_all(struct sipe_core_public *sipe_public,
718 const gchar *buddy_name,
719 const gchar *group_name);
722 * Gets the name of a contact.
724 * @param sipe_public The handle representing the protocol instance making the call
725 * @param who The opaque handle to the contact as found by find_buddy
726 * @return The name. Must be freed.
728 gchar* sipe_backend_buddy_get_name(struct sipe_core_public *sipe_public,
729 const sipe_backend_buddy who);
732 * Gets the alias for a contact.
734 * @param sipe_public The handle representing the protocol instance making the call
735 * @param who The opaque handle to the contact as found by find_buddy
736 * @return The alias. Must be gfree'd.
738 gchar* sipe_backend_buddy_get_alias(struct sipe_core_public *sipe_public,
739 const sipe_backend_buddy who);
742 * Gets the server alias for a contact.
744 * @param sipe_public The handle representing the protocol instance making the call
745 * @param who The opaque handle to the contact as found by find_buddy
746 * @return The alias. Must be freed.
748 gchar* sipe_backend_buddy_get_server_alias(struct sipe_core_public *sipe_public,
749 const sipe_backend_buddy who);
752 * Gets the local alias for a contact
754 * @param sipe_public The handle representing the protocol instance making the call
755 * @param uri the budyy name
757 * @return the alias. Must be @g_free()'d.
759 gchar *sipe_backend_buddy_get_local_alias(struct sipe_core_public *sipe_public,
760 const sipe_backend_buddy who);
763 * Gets the name of the group a contact belongs to.
765 * @param sipe_public The handle representing the protocol instance making the call
766 * @param who The opaque handle to the contact as found by find_buddy
767 * @return The name. Must be freed.
769 gchar* sipe_backend_buddy_get_group_name(struct sipe_core_public *sipe_public,
770 const sipe_backend_buddy who);
773 * Called to retrieve a buddy-specific setting.
775 * @param sipe_public The handle representing the protocol instance making the call
776 * @param buddy The handle representing the buddy
777 * @param key The name of the setting
778 * @return The value of the setting. Must be freed.
780 gchar* sipe_backend_buddy_get_string(struct sipe_core_public *sipe_public,
781 sipe_backend_buddy buddy,
782 const sipe_buddy_info_fields key);
785 * Called to set a buddy-specific setting.
787 * @param sipe_public The handle representing the protocol instance making the call
788 * @param buddy The handle representing the buddy
789 * @param key The name of the setting
790 * @param val The value to set
792 void sipe_backend_buddy_set_string(struct sipe_core_public *sipe_public,
793 sipe_backend_buddy buddy,
794 const sipe_buddy_info_fields key,
795 const gchar *val);
798 * Called after one ore more buddy-specific settings have been updated.
800 * Can be used by the backend to trigger an UI update event
802 * @param sipe_public The handle representing the protocol instance making the call
803 * @param uri SIP URI of the contact
805 void sipe_backend_buddy_refresh_properties(struct sipe_core_public *sipe_public,
806 const gchar *uri);
809 * Get the status token for a contact
811 * @param sipe_public The handle representing the protocol instance making the call
812 * @param uri SIP URI of the contact
814 * @return activity
816 guint sipe_backend_buddy_get_status(struct sipe_core_public *sipe_public,
817 const gchar *uri);
820 * Sets the alias for a contact.
822 * @param sipe_public The handle representing the protocol instance making the call
823 * @param who The opaque handle to the contact as found by find_buddy
824 * @param alias The location where the alias will be put
825 * case. FALSE if the buddy was not found. The value of alias will not be changed.
827 void sipe_backend_buddy_set_alias(struct sipe_core_public *sipe_public,
828 const sipe_backend_buddy who,
829 const gchar *alias);
832 * Sets the server alias for a contact.
834 * @param sipe_public The handle representing the protocol instance making the call
835 * @param who The opaque handle to the contact as found by find_buddy
836 * @param alias The server alias of the contact
838 void sipe_backend_buddy_set_server_alias(struct sipe_core_public *sipe_public,
839 const sipe_backend_buddy who,
840 const gchar *alias);
843 * Start processing buddy list
845 * Will be called every time we receive a buddy list in roaming contacts
847 * @param sipe_public The handle representing the protocol instance making the call
849 void sipe_backend_buddy_list_processing_start(struct sipe_core_public *sipe_public);
852 * Finished processing buddy list
854 * Will be called every time we receive a buddy list in roaming contacts
856 * @param sipe_public The handle representing the protocol instance making the call
858 void sipe_backend_buddy_list_processing_finish(struct sipe_core_public *sipe_public);
861 * Add a contact to the buddy list
863 * @param sipe_public The handle representing the protocol instance making the call
864 * @param name The name of the contact
865 * @param alias The alias of the contact
866 * @param groupname The name of the group to add this contact to
867 * @return A handle to the newly created buddy
869 sipe_backend_buddy sipe_backend_buddy_add(struct sipe_core_public *sipe_public,
870 const gchar *name,
871 const gchar *alias,
872 const gchar *groupname);
875 * Remove a contact from the buddy list
877 * @param sipe_public The handle representing the protocol instance making the call
878 * @param who The opaque handle to the contact as found by find_buddy
880 void sipe_backend_buddy_remove(struct sipe_core_public *sipe_public,
881 const sipe_backend_buddy who);
884 * Notifies the user that a remote user has wants to add the local user to his
885 * or her buddy list and requires authorization to do so.
887 * @param sipe_public The handle representing the protocol instance making the call
888 * @param who The name of the user that added this account
889 * @param alias The optional alias of the remote user
890 * @param on_list True if the user is already in our list
891 * @param auth_cb The callback called when the local user accepts
892 * @param deny_cb The callback called when the local user rejects
893 * @param data Data to be passed back to the above callbacks
895 typedef void (*sipe_backend_buddy_request_authorization_cb)(void *);
897 void sipe_backend_buddy_request_add(struct sipe_core_public *sipe_public,
898 const gchar *who,
899 const gchar *alias);
901 void sipe_backend_buddy_request_authorization(struct sipe_core_public *sipe_public,
902 const gchar *who,
903 const gchar *alias,
904 gboolean on_list,
905 sipe_backend_buddy_request_authorization_cb auth_cb,
906 sipe_backend_buddy_request_authorization_cb deny_cb,
907 gpointer data);
909 gboolean sipe_backend_buddy_is_blocked(struct sipe_core_public *sipe_public,
910 const gchar *who);
912 void sipe_backend_buddy_set_blocked_status(struct sipe_core_public *sipe_public,
913 const gchar *who,
914 gboolean blocked);
916 void sipe_backend_buddy_set_status(struct sipe_core_public *sipe_public,
917 const gchar *who,
918 guint activity);
921 * Checks whether backend has a capability to use buddy photos. If this function
922 * returns @c FALSE, SIPE core will not attempt to download the photos from
923 * server to save bandwidth.
925 * @return @c TRUE if backend is photo capable, otherwise @FALSE
927 gboolean sipe_backend_uses_photo(void);
930 * Gives backend a photo image associated with a SIP URI. Backend has ownership
931 * of the data and must free it when not needed.
933 * @param sipe_public The handle representing the protocol instance making the call
934 * @param who The name of the user whose photo is being set
935 * @param image_data The photo image data, must be g_free()'d by backend
936 * @param image_len Size of the image in Bytes
937 * @param photo_hash A data checksum provided by the server
939 void sipe_backend_buddy_set_photo(struct sipe_core_public *sipe_public,
940 const gchar *who,
941 gpointer image_data,
942 gsize image_len,
943 const gchar *photo_hash);
946 * Retrieves a photo hash stored together with image data by
947 * @c sipe_backend_buddy_set_photo. Value is used by the core to detect photo
948 * file changes on server.
950 * @param sipe_public The handle representing the protocol instance making the call
951 * @param who The name of the user whose photo hash to retrieve
952 * @return a photo hash (may be NULL)
954 const gchar *sipe_backend_buddy_get_photo_hash(struct sipe_core_public *sipe_public,
955 const gchar *who);
958 * Called when a new internal group is about to be added. If this returns FALSE,
959 * the group will not be added.
961 * @param sipe_public The handle representing the protocol instance making the call
962 * @param group_name The group being added
963 * @return TRUE if everything is ok, FALSE if the group should not be added
965 gboolean sipe_backend_buddy_group_add(struct sipe_core_public *sipe_public,
966 const gchar *group_name);
969 * Called when a new internal group has been renamed
971 * @param sipe_public The handle representing the protocol instance making the call
972 * @param old_name old name of the group
973 * @param new_name new name of the group
974 * @return TRUE if the group was found and renamed
976 gboolean sipe_backend_buddy_group_rename(struct sipe_core_public *sipe_public,
977 const gchar *old_name,
978 const gchar *new_name);
981 * Called when a new internal group should be deleted
983 * NOTE: this will only be called on empty groups.
985 * @param sipe_public The handle representing the protocol instance making the call
986 * @param group_name The group that should be removed
988 void sipe_backend_buddy_group_remove(struct sipe_core_public *sipe_public,
989 const gchar *group_name);
992 * Present requested buddy information to the user
994 struct sipe_backend_buddy_info;
995 struct sipe_backend_buddy_info *sipe_backend_buddy_info_start(struct sipe_core_public *sipe_public);
996 void sipe_backend_buddy_info_add(struct sipe_core_public *sipe_public,
997 struct sipe_backend_buddy_info *info,
998 sipe_buddy_info_fields key,
999 const gchar *value);
1000 void sipe_backend_buddy_info_break(struct sipe_core_public *sipe_public,
1001 struct sipe_backend_buddy_info *info);
1002 void sipe_backend_buddy_info_finalize(struct sipe_core_public *sipe_public,
1003 struct sipe_backend_buddy_info *info,
1004 const gchar *uri);
1006 struct sipe_backend_buddy_tooltip;
1007 void sipe_backend_buddy_tooltip_add(struct sipe_core_public *sipe_public,
1008 struct sipe_backend_buddy_tooltip *tooltip,
1009 const gchar *description,
1010 const gchar *value);
1013 * Buddy menu creation
1015 enum sipe_buddy_menu_type {
1016 SIPE_BUDDY_MENU_MAKE_CHAT_LEADER = 0,
1017 SIPE_BUDDY_MENU_REMOVE_FROM_CHAT,
1018 SIPE_BUDDY_MENU_INVITE_TO_CHAT,
1019 SIPE_BUDDY_MENU_NEW_CHAT,
1020 SIPE_BUDDY_MENU_MAKE_CALL,
1021 SIPE_BUDDY_MENU_SEND_EMAIL,
1022 SIPE_BUDDY_MENU_ACCESS_LEVEL_HELP,
1023 SIPE_BUDDY_MENU_CHANGE_ACCESS_LEVEL,
1024 SIPE_BUDDY_MENU_ADD_NEW_DOMAIN,
1025 SIPE_BUDDY_MENU_TYPES
1028 struct sipe_backend_buddy_menu *sipe_backend_buddy_menu_start(struct sipe_core_public *sipe_public);
1029 struct sipe_backend_buddy_menu *sipe_backend_buddy_menu_add(struct sipe_core_public *sipe_public,
1030 struct sipe_backend_buddy_menu *menu,
1031 const gchar *label,
1032 enum sipe_buddy_menu_type type,
1033 gpointer parameter);
1034 struct sipe_backend_buddy_menu *sipe_backend_buddy_menu_separator(struct sipe_core_public *sipe_public,
1035 struct sipe_backend_buddy_menu *menu,
1036 const gchar *label);
1037 struct sipe_backend_buddy_menu *sipe_backend_buddy_sub_menu_add(struct sipe_core_public *sipe_public,
1038 struct sipe_backend_buddy_menu *menu,
1039 const gchar *label,
1040 struct sipe_backend_buddy_menu *sub);
1042 SipeEncryptionPolicy sipe_backend_media_get_encryption_policy(struct sipe_core_public *sipe_public);
1044 #ifdef __cplusplus
1046 #endif
1049 Local Variables:
1050 mode: c
1051 c-file-style: "bsd"
1052 indent-tabs-mode: t
1053 tab-width: 8
1054 End: