filetransfer: add sipe_backend_ft_set_completed()
[siplcs.git] / src / api / sipe-backend.h
blobc77a5679cce6d65c5fe7c73efda82691f9a30f8b
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);
233 void sipe_backend_ft_set_completed(struct sipe_file_transfer *ft);
235 void sipe_backend_ft_cancel_local(struct sipe_file_transfer *ft);
236 void sipe_backend_ft_cancel_remote(struct sipe_file_transfer *ft);
238 void sipe_backend_ft_incoming(struct sipe_core_public *sipe_public,
239 struct sipe_file_transfer *ft,
240 const gchar *who,
241 const gchar *file_name,
242 gsize file_size);
244 * Begins file transfer with remote peer.
246 * You can provide either opened file descriptor to use for read/write operations
247 * or ip address and port where the backend should connect.
249 * @param ft file transfer data
250 * @param fd opaque file descriptor pointer or NULL if ip and port are used
251 * @param ip ip address to connect of NULL when file descriptor is used
252 * @param port port to connect or 0 when file descriptor is used
254 void sipe_backend_ft_start(struct sipe_file_transfer *ft,
255 struct sipe_backend_fd *fd,
256 const char* ip, unsigned port);
259 * Check whether file transfer is incoming or outgoing
261 * @param ft file transfer data
262 * @return @c TRUE if @c ft is incoming, otherwise @c FALSE
264 gboolean sipe_backend_ft_is_incoming(struct sipe_file_transfer *ft);
266 /** GROUP CHAT ***************************************************************/
268 #define SIPE_GROUPCHAT_ROOM_FILEPOST 0x00000001
269 #define SIPE_GROUPCHAT_ROOM_INVITE 0x00000002
270 #define SIPE_GROUPCHAT_ROOM_LOGGED 0x00000004
271 #define SIPE_GROUPCHAT_ROOM_PRIVATE 0x00000008
274 * Add a room found through room query
276 * @param uri room URI
277 * @param name human readable name for room
278 * @param description room description
279 * @param users number of users in the room
280 * @param flags SIPE_GROUPCHAT_ROOM_* flags
282 void sipe_backend_groupchat_room_add(struct sipe_core_public *sipe_public,
283 const gchar *uri,
284 const gchar *name,
285 const gchar *description,
286 guint users,
287 guint32 flags);
290 * Terminate room query
292 void sipe_backend_groupchat_room_terminate(struct sipe_core_public *sipe_public);
294 /** IM ***********************************************************************/
296 void sipe_backend_im_message(struct sipe_core_public *sipe_public,
297 const gchar *from,
298 const gchar *html);
299 void sipe_backend_im_topic(struct sipe_core_public *sipe_public,
300 const gchar *with,
301 const gchar *topic);
303 /** MARKUP *******************************************************************/
305 gchar *sipe_backend_markup_css_property(const gchar *style,
306 const gchar *option);
307 gchar *sipe_backend_markup_strip_html(const gchar *html);
309 /** MEDIA ********************************************************************/
311 typedef enum {
312 /* This client is the one who invites other participant to the call. */
313 SIPE_MEDIA_CALL_INITIATOR = 1,
314 /* Don't show any user interface elements for the call. */
315 SIPE_MEDIA_CALL_NO_UI = 2
316 } SipeMediaCallFlags;
318 typedef enum {
319 SIPE_ICE_NO_ICE,
320 SIPE_ICE_DRAFT_6,
321 SIPE_ICE_RFC_5245
322 } SipeIceVersion;
324 typedef enum {
325 SIPE_CANDIDATE_TYPE_ANY,
326 SIPE_CANDIDATE_TYPE_HOST,
327 SIPE_CANDIDATE_TYPE_RELAY,
328 SIPE_CANDIDATE_TYPE_SRFLX,
329 SIPE_CANDIDATE_TYPE_PRFLX
330 } SipeCandidateType;
332 typedef enum {
333 SIPE_COMPONENT_NONE = 0,
334 SIPE_COMPONENT_RTP = 1,
335 SIPE_COMPONENT_RTCP = 2
336 } SipeComponentType;
338 typedef enum {
339 SIPE_MEDIA_AUDIO,
340 SIPE_MEDIA_VIDEO,
341 SIPE_MEDIA_APPLICATION
342 } SipeMediaType;
344 typedef enum {
345 SIPE_NETWORK_PROTOCOL_UDP,
346 SIPE_NETWORK_PROTOCOL_TCP_ACTIVE,
347 SIPE_NETWORK_PROTOCOL_TCP_PASSIVE,
348 SIPE_NETWORK_PROTOCOL_TCP_SO,
349 } SipeNetworkProtocol;
351 typedef enum {
352 SIPE_ENCRYPTION_POLICY_REJECTED,
353 SIPE_ENCRYPTION_POLICY_OPTIONAL,
354 SIPE_ENCRYPTION_POLICY_REQUIRED,
355 SIPE_ENCRYPTION_POLICY_OBEY_SERVER
356 } SipeEncryptionPolicy;
358 struct sipe_media_call;
359 struct sipe_backend_media;
360 struct sipe_backend_codec;
361 struct sipe_backend_candidate;
362 struct sipe_backend_media_stream;
363 struct sipe_backend_media_relays;
365 struct sipe_media_stream {
366 struct sipe_backend_media_stream *backend_private;
368 gchar *id;
371 struct sipe_media_call {
372 struct sipe_backend_media *backend_private;
374 gchar *with;
376 void (*stream_initialized_cb)(struct sipe_media_call *,
377 struct sipe_media_stream *);
378 void (*stream_end_cb)(struct sipe_media_call *,
379 struct sipe_media_stream *);
380 void (*media_end_cb)(struct sipe_media_call *);
381 void (*call_accept_cb)(struct sipe_media_call *, gboolean local);
382 void (*call_reject_cb)(struct sipe_media_call *, gboolean local);
383 void (*call_hold_cb) (struct sipe_media_call *, gboolean local,
384 gboolean state);
385 void (*candidate_pair_established_cb)(struct sipe_media_call *,
386 struct sipe_media_stream *);
387 void (*call_hangup_cb)(struct sipe_media_call *, gboolean local);
388 void (*error_cb)(struct sipe_media_call *, gchar *message);
391 struct sipe_media_relay {
392 gchar *hostname;
393 guint udp_port;
394 guint tcp_port;
395 struct sipe_dns_query *dns_query;
398 /* Media handling */
399 struct sipe_backend_media *sipe_backend_media_new(struct sipe_core_public *sipe_public,
400 struct sipe_media_call *call,
401 const gchar *participant,
402 SipeMediaCallFlags flags);
403 void sipe_backend_media_free(struct sipe_backend_media *media);
405 void sipe_backend_media_set_cname(struct sipe_backend_media *media, gchar *cname);
407 struct sipe_backend_media_relays * sipe_backend_media_relays_convert(GSList *media_relays,
408 gchar *username,
409 gchar *password);
410 void sipe_backend_media_relays_free(struct sipe_backend_media_relays *media_relays);
412 struct sipe_backend_media_stream *sipe_backend_media_add_stream(struct sipe_media_call *media,
413 const gchar *id,
414 const gchar *participant,
415 SipeMediaType type,
416 SipeIceVersion ice_version,
417 gboolean initiator,
418 struct sipe_backend_media_relays *media_relays);
419 void sipe_backend_media_add_remote_candidates(struct sipe_media_call *media,
420 struct sipe_media_stream *stream,
421 GList *candidates);
422 gboolean sipe_backend_media_is_initiator(struct sipe_media_call *media,
423 struct sipe_media_stream *stream);
424 gboolean sipe_backend_media_accepted(struct sipe_backend_media *media);
425 gboolean sipe_backend_stream_initialized(struct sipe_media_call *media,
426 struct sipe_media_stream *stream);
427 GList *sipe_backend_media_get_active_local_candidates(struct sipe_media_call *media,
428 struct sipe_media_stream *stream);
429 GList *sipe_backend_media_get_active_remote_candidates(struct sipe_media_call *media,
430 struct sipe_media_stream *stream);
431 void sipe_backend_media_set_encryption_keys(struct sipe_media_call *media,
432 struct sipe_media_stream *stream,
433 const guchar *encryption_key,
434 const guchar *decryption_key);
436 /* Stream handling */
437 void sipe_backend_stream_hold(struct sipe_media_call *media,
438 struct sipe_media_stream *stream,
439 gboolean local);
440 void sipe_backend_stream_unhold(struct sipe_media_call *media,
441 struct sipe_media_stream *stream,
442 gboolean local);
443 gboolean sipe_backend_stream_is_held(struct sipe_media_stream *stream);
444 void sipe_backend_media_stream_end(struct sipe_media_call *media,
445 struct sipe_media_stream *stream);
446 void sipe_backend_media_stream_free(struct sipe_backend_media_stream *stream);
448 /* Codec handling */
449 struct sipe_backend_codec *sipe_backend_codec_new(int id,
450 const char *name,
451 SipeMediaType type, guint clock_rate);
452 void sipe_backend_codec_free(struct sipe_backend_codec *codec);
453 int sipe_backend_codec_get_id(struct sipe_backend_codec *codec);
455 * @return codec name. Will be g_free'd() by the core.
457 gchar *sipe_backend_codec_get_name(struct sipe_backend_codec *codec);
458 guint sipe_backend_codec_get_clock_rate(struct sipe_backend_codec *codec);
459 void sipe_backend_codec_add_optional_parameter(struct sipe_backend_codec *codec,
460 const gchar *name,
461 const gchar *value);
462 GList *sipe_backend_codec_get_optional_parameters(struct sipe_backend_codec *codec);
463 gboolean sipe_backend_set_remote_codecs(struct sipe_media_call *media,
464 struct sipe_media_stream *stream,
465 GList *codecs);
466 GList* sipe_backend_get_local_codecs(struct sipe_media_call *media,
467 struct sipe_media_stream *stream);
469 /* Candidate handling */
470 struct sipe_backend_candidate * sipe_backend_candidate_new(const gchar *foundation,
471 SipeComponentType component,
472 SipeCandidateType type,
473 SipeNetworkProtocol proto,
474 const gchar *ip, guint port,
475 const gchar *username,
476 const gchar *password);
477 void sipe_backend_candidate_free(struct sipe_backend_candidate *candidate);
479 * @return user name. Will be g_free'd() by the core.
481 gchar *sipe_backend_candidate_get_username(struct sipe_backend_candidate *candidate);
483 * @return password. Will be g_free'd() by the core.
485 gchar *sipe_backend_candidate_get_password(struct sipe_backend_candidate *candidate);
487 * @return foundation. Will be g_free'd() by the core.
489 gchar *sipe_backend_candidate_get_foundation(struct sipe_backend_candidate *candidate);
491 * @return IP address string. Will be g_free'd() by the core.
493 gchar *sipe_backend_candidate_get_ip(struct sipe_backend_candidate *candidate);
494 guint sipe_backend_candidate_get_port(struct sipe_backend_candidate *candidate);
496 * @return IP address string. Will be g_free'd() by the core.
498 gchar *sipe_backend_candidate_get_base_ip(struct sipe_backend_candidate *candidate);
499 guint sipe_backend_candidate_get_base_port(struct sipe_backend_candidate *candidate);
500 guint32 sipe_backend_candidate_get_priority(struct sipe_backend_candidate *candidate);
501 void sipe_backend_candidate_set_priority(struct sipe_backend_candidate *candidate, guint32 priority);
502 SipeComponentType sipe_backend_candidate_get_component_type(struct sipe_backend_candidate *candidate);
503 SipeCandidateType sipe_backend_candidate_get_type(struct sipe_backend_candidate *candidate);
504 SipeNetworkProtocol sipe_backend_candidate_get_protocol(struct sipe_backend_candidate *candidate);
505 GList* sipe_backend_get_local_candidates(struct sipe_media_call *media,
506 struct sipe_media_stream *stream);
507 void sipe_backend_media_accept(struct sipe_backend_media *media, gboolean local);
508 void sipe_backend_media_hangup(struct sipe_backend_media *media, gboolean local);
509 void sipe_backend_media_reject(struct sipe_backend_media *media, gboolean local);
511 /** NETWORK ******************************************************************/
513 const gchar *sipe_backend_network_ip_address(struct sipe_core_public *sipe_public);
515 struct sipe_backend_listendata;
517 typedef void (*sipe_listen_start_cb)(unsigned short port, gpointer data);
518 typedef void (*sipe_client_connected_cb)(struct sipe_backend_fd *fd, gpointer data);
520 struct sipe_backend_listendata *
521 sipe_backend_network_listen_range(unsigned short port_min,
522 unsigned short port_max,
523 sipe_listen_start_cb listen_cb,
524 sipe_client_connected_cb connect_cb,
525 gpointer data);
526 void sipe_backend_network_listen_cancel(struct sipe_backend_listendata *ldata);
528 gboolean sipe_backend_fd_is_valid(struct sipe_backend_fd *fd);
529 void sipe_backend_fd_free(struct sipe_backend_fd *fd);
531 /** NOTIFICATIONS *************************************************************/
533 void sipe_backend_notify_message_error(struct sipe_core_public *sipe_public,
534 struct sipe_backend_chat_session *backend_session,
535 const gchar *who,
536 const gchar *message);
537 void sipe_backend_notify_message_info(struct sipe_core_public *sipe_public,
538 struct sipe_backend_chat_session *backend_session,
539 const gchar *who,
540 const gchar *message);
543 * @param msg error message. Maybe @NULL
545 void sipe_backend_notify_error(struct sipe_core_public *sipe_public,
546 const gchar *title,
547 const gchar *msg);
549 /** SCHEDULE *****************************************************************/
551 gpointer sipe_backend_schedule_seconds(struct sipe_core_public *sipe_public,
552 guint timeout,
553 gpointer data);
554 gpointer sipe_backend_schedule_mseconds(struct sipe_core_public *sipe_public,
555 guint timeout,
556 gpointer data);
557 void sipe_backend_schedule_cancel(struct sipe_core_public *sipe_public,
558 gpointer data);
560 /** SEARCH *******************************************************************/
562 struct sipe_backend_search_results;
563 struct sipe_backend_search_token;
565 void sipe_backend_search_failed(struct sipe_core_public *sipe_public,
566 struct sipe_backend_search_token *token,
567 const gchar *msg);
568 struct sipe_backend_search_results *sipe_backend_search_results_start(struct sipe_core_public *sipe_public,
569 struct sipe_backend_search_token *token);
570 void sipe_backend_search_results_add(struct sipe_core_public *sipe_public,
571 struct sipe_backend_search_results *results,
572 const gchar *uri,
573 const gchar *name,
574 const gchar *company,
575 const gchar *country,
576 const gchar *email);
577 void sipe_backend_search_results_finalize(struct sipe_core_public *sipe_public,
578 struct sipe_backend_search_results *results,
579 const gchar *description,
580 gboolean more);
582 /** SETTINGS *****************************************************************/
584 typedef enum {
585 SIPE_SETTING_EMAIL_URL = 0,
586 SIPE_SETTING_EMAIL_LOGIN,
587 SIPE_SETTING_EMAIL_PASSWORD,
588 SIPE_SETTING_GROUPCHAT_USER,
589 SIPE_SETTING_USER_AGENT,
590 SIPE_SETTING_LAST
591 } sipe_setting;
592 const gchar *sipe_backend_setting(struct sipe_core_public *sipe_public,
593 sipe_setting type);
595 /** STATUS *******************************************************************/
597 guint sipe_backend_status(struct sipe_core_public *sipe_public);
598 gboolean sipe_backend_status_changed(struct sipe_core_public *sipe_public,
599 guint activity,
600 const gchar *message);
603 * Update user client with new status and note received from server
605 * NOTE: this must *NOT* trigger a call to @c sipe_core_status_set()!
607 * @param sipe_public The handle representing the protocol instance
608 * @param activity New activity
609 * @param message New note text
611 void sipe_backend_status_and_note(struct sipe_core_public *sipe_public,
612 guint activity,
613 const gchar *message);
615 /** TRANSPORT ****************************************************************/
617 typedef void transport_connected_cb(struct sipe_transport_connection *conn);
618 typedef void transport_input_cb(struct sipe_transport_connection *conn);
619 typedef void transport_error_cb(struct sipe_transport_connection *conn,
620 const gchar *msg);
622 typedef struct {
623 guint type;
624 const gchar *server_name;
625 guint server_port;
626 gpointer user_data;
627 transport_connected_cb *connected;
628 transport_input_cb *input;
629 transport_error_cb *error;
630 } sipe_connect_setup;
631 struct sipe_transport_connection *sipe_backend_transport_connect(struct sipe_core_public *sipe_public,
632 const sipe_connect_setup *setup);
633 void sipe_backend_transport_disconnect(struct sipe_transport_connection *conn);
634 void sipe_backend_transport_message(struct sipe_transport_connection *conn,
635 const gchar *buffer);
636 void sipe_backend_transport_flush(struct sipe_transport_connection *conn);
638 /** USER *********************************************************************/
640 void sipe_backend_user_feedback_typing(struct sipe_core_public *sipe_public,
641 const gchar *from);
642 void sipe_backend_user_feedback_typing_stop(struct sipe_core_public *sipe_public,
643 const gchar *from);
646 * Present a query that is to be accepted or declined by the user
648 * @param sipe_public The handle representing the protocol instance
649 * @param message Text of the query to be shown to user
650 * @param accept_label Label to be displayed on UI control that accepts query
651 * @param decline_label Label to be displayed on UI control that declines query
652 * @param key Opaque handle uniquely identifying the query. Backend
653 * should store it for the case SIPE core requests the
654 * query to be closed prematurely.
656 void sipe_backend_user_ask(struct sipe_core_public *sipe_public,
657 const gchar *message,
658 const gchar *accept_label,
659 const gchar *decline_label,
660 gpointer key);
663 * Closes the pending user query
665 * @param key Opaque handle uniquely identifying the query.
667 void sipe_backend_user_close_ask(gpointer key);
669 /** BUDDIES ******************************************************************/
672 * sipe_backend_buddy_get/set_string(): properties a buddy can have
673 * sipe_backend_buddy_info_add(): mapped, e.g. to a string label
675 typedef enum
677 SIPE_BUDDY_INFO_DISPLAY_NAME = 0,
678 SIPE_BUDDY_INFO_JOB_TITLE,
679 SIPE_BUDDY_INFO_CITY,
680 SIPE_BUDDY_INFO_STATE,
681 SIPE_BUDDY_INFO_OFFICE,
682 SIPE_BUDDY_INFO_DEPARTMENT,
683 SIPE_BUDDY_INFO_COUNTRY,
684 SIPE_BUDDY_INFO_WORK_PHONE,
685 SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY,
686 SIPE_BUDDY_INFO_COMPANY,
687 SIPE_BUDDY_INFO_EMAIL,
688 SIPE_BUDDY_INFO_SITE,
689 SIPE_BUDDY_INFO_ZIPCODE,
690 SIPE_BUDDY_INFO_STREET,
691 SIPE_BUDDY_INFO_MOBILE_PHONE,
692 SIPE_BUDDY_INFO_MOBILE_PHONE_DISPLAY,
693 SIPE_BUDDY_INFO_HOME_PHONE,
694 SIPE_BUDDY_INFO_HOME_PHONE_DISPLAY,
695 SIPE_BUDDY_INFO_OTHER_PHONE,
696 SIPE_BUDDY_INFO_OTHER_PHONE_DISPLAY,
697 SIPE_BUDDY_INFO_CUSTOM1_PHONE,
698 SIPE_BUDDY_INFO_CUSTOM1_PHONE_DISPLAY,
699 SIPE_BUDDY_INFO_ALIAS, /* only for sipe_backend_buddy_info_add() */
700 SIPE_BUDDY_INFO_DEVICE, /* only for sipe_backend_buddy_info_add() */
701 } sipe_buddy_info_fields;
703 /* Opaque token */
704 typedef void* sipe_backend_buddy;
707 * Find a buddy in the given group of the buddy list, or anywhere on the
708 * list if @group_name is empty
710 * @param sipe_public The handle representing the protocol instance making the call
711 * @param buddy_name The name of the buddy
712 * @param group_name The name of the group to look in, or NULL for any group
713 * @return opaque handle to the buddy, or NULL if no buddy found
715 sipe_backend_buddy sipe_backend_buddy_find(struct sipe_core_public *sipe_public,
716 const gchar *buddy_name,
717 const gchar *group_name);
720 * Find all named buddies in the given group of the buddy list, or anywhere on the
721 * list if @group_name is empty; or all buddies if @name is empty
723 * @param sipe_public The handle representing the protocol instance making the call
724 * @param name The name of the buddy
725 * @param group_name The name of the group to look in, or NULL for any group
726 * @return GSList of opaque handles to the buddies
728 GSList* sipe_backend_buddy_find_all(struct sipe_core_public *sipe_public,
729 const gchar *buddy_name,
730 const gchar *group_name);
733 * Gets the name of a contact.
735 * @param sipe_public The handle representing the protocol instance making the call
736 * @param who The opaque handle to the contact as found by find_buddy
737 * @return The name. Must be freed.
739 gchar* sipe_backend_buddy_get_name(struct sipe_core_public *sipe_public,
740 const sipe_backend_buddy who);
743 * Gets the alias for a contact.
745 * @param sipe_public The handle representing the protocol instance making the call
746 * @param who The opaque handle to the contact as found by find_buddy
747 * @return The alias. Must be gfree'd.
749 gchar* sipe_backend_buddy_get_alias(struct sipe_core_public *sipe_public,
750 const sipe_backend_buddy who);
753 * Gets the server alias for a contact.
755 * @param sipe_public The handle representing the protocol instance making the call
756 * @param who The opaque handle to the contact as found by find_buddy
757 * @return The alias. Must be freed.
759 gchar* sipe_backend_buddy_get_server_alias(struct sipe_core_public *sipe_public,
760 const sipe_backend_buddy who);
763 * Gets the local alias for a contact
765 * @param sipe_public The handle representing the protocol instance making the call
766 * @param uri the budyy name
768 * @return the alias. Must be @g_free()'d.
770 gchar *sipe_backend_buddy_get_local_alias(struct sipe_core_public *sipe_public,
771 const sipe_backend_buddy who);
774 * Gets the name of the group a contact belongs to.
776 * @param sipe_public The handle representing the protocol instance making the call
777 * @param who The opaque handle to the contact as found by find_buddy
778 * @return The name. Must be freed.
780 gchar* sipe_backend_buddy_get_group_name(struct sipe_core_public *sipe_public,
781 const sipe_backend_buddy who);
784 * Called to retrieve a buddy-specific setting.
786 * @param sipe_public The handle representing the protocol instance making the call
787 * @param buddy The handle representing the buddy
788 * @param key The name of the setting
789 * @return The value of the setting. Must be freed.
791 gchar* sipe_backend_buddy_get_string(struct sipe_core_public *sipe_public,
792 sipe_backend_buddy buddy,
793 const sipe_buddy_info_fields key);
796 * Called to set a buddy-specific setting.
798 * @param sipe_public The handle representing the protocol instance making the call
799 * @param buddy The handle representing the buddy
800 * @param key The name of the setting
801 * @param val The value to set
803 void sipe_backend_buddy_set_string(struct sipe_core_public *sipe_public,
804 sipe_backend_buddy buddy,
805 const sipe_buddy_info_fields key,
806 const gchar *val);
809 * Called after one ore more buddy-specific settings have been updated.
811 * Can be used by the backend to trigger an UI update event
813 * @param sipe_public The handle representing the protocol instance making the call
814 * @param uri SIP URI of the contact
816 void sipe_backend_buddy_refresh_properties(struct sipe_core_public *sipe_public,
817 const gchar *uri);
820 * Get the status token for a contact
822 * @param sipe_public The handle representing the protocol instance making the call
823 * @param uri SIP URI of the contact
825 * @return activity
827 guint sipe_backend_buddy_get_status(struct sipe_core_public *sipe_public,
828 const gchar *uri);
831 * Sets the alias for a contact.
833 * @param sipe_public The handle representing the protocol instance making the call
834 * @param who The opaque handle to the contact as found by find_buddy
835 * @param alias The location where the alias will be put
836 * case. FALSE if the buddy was not found. The value of alias will not be changed.
838 void sipe_backend_buddy_set_alias(struct sipe_core_public *sipe_public,
839 const sipe_backend_buddy who,
840 const gchar *alias);
843 * Sets the server alias for a contact.
845 * @param sipe_public The handle representing the protocol instance making the call
846 * @param who The opaque handle to the contact as found by find_buddy
847 * @param alias The server alias of the contact
849 void sipe_backend_buddy_set_server_alias(struct sipe_core_public *sipe_public,
850 const sipe_backend_buddy who,
851 const gchar *alias);
854 * Start processing buddy list
856 * Will be called every time we receive a buddy list in roaming contacts
858 * @param sipe_public The handle representing the protocol instance making the call
860 void sipe_backend_buddy_list_processing_start(struct sipe_core_public *sipe_public);
863 * Finished processing buddy list
865 * Will be called every time we receive a buddy list in roaming contacts
867 * @param sipe_public The handle representing the protocol instance making the call
869 void sipe_backend_buddy_list_processing_finish(struct sipe_core_public *sipe_public);
872 * Add a contact to the buddy list
874 * @param sipe_public The handle representing the protocol instance making the call
875 * @param name The name of the contact
876 * @param alias The alias of the contact
877 * @param groupname The name of the group to add this contact to
878 * @return A handle to the newly created buddy
880 sipe_backend_buddy sipe_backend_buddy_add(struct sipe_core_public *sipe_public,
881 const gchar *name,
882 const gchar *alias,
883 const gchar *groupname);
886 * Remove a contact from the buddy list
888 * @param sipe_public The handle representing the protocol instance making the call
889 * @param who The opaque handle to the contact as found by find_buddy
891 void sipe_backend_buddy_remove(struct sipe_core_public *sipe_public,
892 const sipe_backend_buddy who);
895 * Notifies the user that a remote user has wants to add the local user to his
896 * or her buddy list and requires authorization to do so.
898 * @param sipe_public The handle representing the protocol instance making the call
899 * @param who The name of the user that added this account
900 * @param alias The optional alias of the remote user
901 * @param on_list True if the user is already in our list
902 * @param auth_cb The callback called when the local user accepts
903 * @param deny_cb The callback called when the local user rejects
904 * @param data Data to be passed back to the above callbacks
906 typedef void (*sipe_backend_buddy_request_authorization_cb)(void *);
908 void sipe_backend_buddy_request_add(struct sipe_core_public *sipe_public,
909 const gchar *who,
910 const gchar *alias);
912 void sipe_backend_buddy_request_authorization(struct sipe_core_public *sipe_public,
913 const gchar *who,
914 const gchar *alias,
915 gboolean on_list,
916 sipe_backend_buddy_request_authorization_cb auth_cb,
917 sipe_backend_buddy_request_authorization_cb deny_cb,
918 gpointer data);
920 gboolean sipe_backend_buddy_is_blocked(struct sipe_core_public *sipe_public,
921 const gchar *who);
923 void sipe_backend_buddy_set_blocked_status(struct sipe_core_public *sipe_public,
924 const gchar *who,
925 gboolean blocked);
927 void sipe_backend_buddy_set_status(struct sipe_core_public *sipe_public,
928 const gchar *who,
929 guint activity);
932 * Checks whether backend has a capability to use buddy photos. If this function
933 * returns @c FALSE, SIPE core will not attempt to download the photos from
934 * server to save bandwidth.
936 * @return @c TRUE if backend is photo capable, otherwise @FALSE
938 gboolean sipe_backend_uses_photo(void);
941 * Gives backend a photo image associated with a SIP URI. Backend has ownership
942 * of the data and must free it when not needed.
944 * @param sipe_public The handle representing the protocol instance making the call
945 * @param who The name of the user whose photo is being set
946 * @param image_data The photo image data, must be g_free()'d by backend
947 * @param image_len Size of the image in Bytes
948 * @param photo_hash A data checksum provided by the server
950 void sipe_backend_buddy_set_photo(struct sipe_core_public *sipe_public,
951 const gchar *who,
952 gpointer image_data,
953 gsize image_len,
954 const gchar *photo_hash);
957 * Retrieves a photo hash stored together with image data by
958 * @c sipe_backend_buddy_set_photo. Value is used by the core to detect photo
959 * file changes on server.
961 * @param sipe_public The handle representing the protocol instance making the call
962 * @param who The name of the user whose photo hash to retrieve
963 * @return a photo hash (may be NULL)
965 const gchar *sipe_backend_buddy_get_photo_hash(struct sipe_core_public *sipe_public,
966 const gchar *who);
969 * Called when a new internal group is about to be added. If this returns FALSE,
970 * the group will not be added.
972 * @param sipe_public The handle representing the protocol instance making the call
973 * @param group_name The group being added
974 * @return TRUE if everything is ok, FALSE if the group should not be added
976 gboolean sipe_backend_buddy_group_add(struct sipe_core_public *sipe_public,
977 const gchar *group_name);
980 * Called when a new internal group has been renamed
982 * @param sipe_public The handle representing the protocol instance making the call
983 * @param old_name old name of the group
984 * @param new_name new name of the group
985 * @return TRUE if the group was found and renamed
987 gboolean sipe_backend_buddy_group_rename(struct sipe_core_public *sipe_public,
988 const gchar *old_name,
989 const gchar *new_name);
992 * Called when a new internal group should be deleted
994 * NOTE: this will only be called on empty groups.
996 * @param sipe_public The handle representing the protocol instance making the call
997 * @param group_name The group that should be removed
999 void sipe_backend_buddy_group_remove(struct sipe_core_public *sipe_public,
1000 const gchar *group_name);
1003 * Present requested buddy information to the user
1005 struct sipe_backend_buddy_info;
1006 struct sipe_backend_buddy_info *sipe_backend_buddy_info_start(struct sipe_core_public *sipe_public);
1007 void sipe_backend_buddy_info_add(struct sipe_core_public *sipe_public,
1008 struct sipe_backend_buddy_info *info,
1009 sipe_buddy_info_fields key,
1010 const gchar *value);
1011 void sipe_backend_buddy_info_break(struct sipe_core_public *sipe_public,
1012 struct sipe_backend_buddy_info *info);
1013 void sipe_backend_buddy_info_finalize(struct sipe_core_public *sipe_public,
1014 struct sipe_backend_buddy_info *info,
1015 const gchar *uri);
1017 struct sipe_backend_buddy_tooltip;
1018 void sipe_backend_buddy_tooltip_add(struct sipe_core_public *sipe_public,
1019 struct sipe_backend_buddy_tooltip *tooltip,
1020 const gchar *description,
1021 const gchar *value);
1024 * Buddy menu creation
1026 enum sipe_buddy_menu_type {
1027 SIPE_BUDDY_MENU_MAKE_CHAT_LEADER = 0,
1028 SIPE_BUDDY_MENU_REMOVE_FROM_CHAT,
1029 SIPE_BUDDY_MENU_INVITE_TO_CHAT,
1030 SIPE_BUDDY_MENU_NEW_CHAT,
1031 SIPE_BUDDY_MENU_MAKE_CALL,
1032 SIPE_BUDDY_MENU_SEND_EMAIL,
1033 SIPE_BUDDY_MENU_ACCESS_LEVEL_HELP,
1034 SIPE_BUDDY_MENU_CHANGE_ACCESS_LEVEL,
1035 SIPE_BUDDY_MENU_ADD_NEW_DOMAIN,
1036 SIPE_BUDDY_MENU_TYPES
1039 struct sipe_backend_buddy_menu *sipe_backend_buddy_menu_start(struct sipe_core_public *sipe_public);
1040 struct sipe_backend_buddy_menu *sipe_backend_buddy_menu_add(struct sipe_core_public *sipe_public,
1041 struct sipe_backend_buddy_menu *menu,
1042 const gchar *label,
1043 enum sipe_buddy_menu_type type,
1044 gpointer parameter);
1045 struct sipe_backend_buddy_menu *sipe_backend_buddy_menu_separator(struct sipe_core_public *sipe_public,
1046 struct sipe_backend_buddy_menu *menu,
1047 const gchar *label);
1048 struct sipe_backend_buddy_menu *sipe_backend_buddy_sub_menu_add(struct sipe_core_public *sipe_public,
1049 struct sipe_backend_buddy_menu *menu,
1050 const gchar *label,
1051 struct sipe_backend_buddy_menu *sub);
1053 SipeEncryptionPolicy sipe_backend_media_get_encryption_policy(struct sipe_core_public *sipe_public);
1055 #ifdef __cplusplus
1057 #endif
1060 Local Variables:
1061 mode: c
1062 c-file-style: "bsd"
1063 indent-tabs-mode: t
1064 tab-width: 8
1065 End: