6 * Copyright (C) 2010-2013 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 !!! *****************
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
;
53 /** MISC. STUFF **************************************************************/
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 ****************************************************************/
64 SIPE_DEBUG_LEVEL_INFO
,
65 SIPE_DEBUG_LEVEL_WARNING
,
66 SIPE_DEBUG_LEVEL_ERROR
,
67 SIPE_DEBUG_LEVEL_FATAL
,
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
,
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
,
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
,
116 void sipe_backend_chat_close(struct sipe_backend_chat_session
*backend_session
);
121 struct sipe_backend_chat_session
*sipe_backend_chat_create(struct sipe_core_public
*sipe_public
,
122 struct sipe_chat_session
*session
,
125 gboolean
sipe_backend_chat_find(struct sipe_backend_chat_session
*backend_session
,
127 gboolean
sipe_backend_chat_is_operator(struct sipe_backend_chat_session
*backend_session
,
129 void sipe_backend_chat_message(struct sipe_core_public
*sipe_public
,
130 struct sipe_backend_chat_session
*backend_session
,
134 void sipe_backend_chat_operator(struct sipe_backend_chat_session
*backend_session
,
138 * Rejoin an existing chat window after connection re-establishment
140 void sipe_backend_chat_rejoin(struct sipe_core_public
*sipe_public
,
141 struct sipe_backend_chat_session
*backend_session
,
146 * Core has completed connection re-establishment.
147 * Should call sipe_core_chat_rejoin() for existing chats.
149 void sipe_backend_chat_rejoin_all(struct sipe_core_public
*sipe_public
);
150 void sipe_backend_chat_remove(struct sipe_backend_chat_session
*backend_session
,
154 * Move chat window to the front. Will be called when
155 * a user tries to join an already joined chat again.
157 void sipe_backend_chat_show(struct sipe_backend_chat_session
*backend_session
);
158 void sipe_backend_chat_topic(struct sipe_backend_chat_session
*backend_session
,
161 /** CONNECTION ***************************************************************/
163 void sipe_backend_connection_completed(struct sipe_core_public
*sipe_public
);
166 SIPE_CONNECTION_ERROR_NETWORK
= 0,
167 SIPE_CONNECTION_ERROR_INVALID_USERNAME
,
168 SIPE_CONNECTION_ERROR_INVALID_SETTINGS
,
169 SIPE_CONNECTION_ERROR_AUTHENTICATION_FAILED
,
170 SIPE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE
,
171 SIPE_CONNECTION_ERROR_LAST
172 } sipe_connection_error
;
173 void sipe_backend_connection_error(struct sipe_core_public
*sipe_public
,
174 sipe_connection_error error
,
177 gboolean
sipe_backend_connection_is_disconnecting(struct sipe_core_public
*sipe_public
);
178 gboolean
sipe_backend_connection_is_valid(struct sipe_core_public
*sipe_public
);
180 /** DNS QUERY ****************************************************************/
182 typedef void (*sipe_dns_resolved_cb
)(gpointer data
, const gchar
*hostname
, guint port
);
184 struct sipe_dns_query
*sipe_backend_dns_query_srv(struct sipe_core_public
*sipe_public
,
185 const gchar
*protocol
,
186 const gchar
*transport
,
188 sipe_dns_resolved_cb callback
,
191 struct sipe_dns_query
*sipe_backend_dns_query_a(struct sipe_core_public
*sipe_public
,
192 const gchar
*hostname
,
194 sipe_dns_resolved_cb callback
,
197 void sipe_backend_dns_query_cancel(struct sipe_dns_query
*query
);
199 /** FILE TRANSFER ************************************************************/
201 struct sipe_backend_fd
;
203 void sipe_backend_ft_error(struct sipe_file_transfer
*ft
,
204 const gchar
*errmsg
);
205 const gchar
*sipe_backend_ft_get_error(struct sipe_file_transfer
*ft
);
206 void sipe_backend_ft_deallocate(struct sipe_file_transfer
*ft
);
209 * Try to read up to @c size bytes from file transfer connection
211 * @param ft file transfer data.
212 * @param data buffer to read data into.
213 * @param size buffer size in bytes.
215 * @return number of bytes read or negative on failure.
216 * EAGAIN should return 0 bytes read.
218 gssize
sipe_backend_ft_read(struct sipe_file_transfer
*ft
,
223 * Try to write up to @c size bytes to file transfer connection
225 * @param ft file transfer data.
226 * @param data data to write
227 * @param size buffer size in bytes.
229 * @return number of bytes read or negative on failure.
230 * EAGAIN should return 0 bytes written.
232 gssize
sipe_backend_ft_write(struct sipe_file_transfer
*ft
,
237 void sipe_backend_ft_cancel_local(struct sipe_file_transfer
*ft
);
238 void sipe_backend_ft_cancel_remote(struct sipe_file_transfer
*ft
);
240 void sipe_backend_ft_incoming(struct sipe_core_public
*sipe_public
,
241 struct sipe_file_transfer
*ft
,
243 const gchar
*file_name
,
246 * Begins file transfer with remote peer.
248 * You can provide either opened file descriptor to use for read/write operations
249 * or ip address and port where the backend should connect.
251 * @param ft file transfer data
252 * @param fd opaque file descriptor pointer or NULL if ip and port are used
253 * @param ip ip address to connect of NULL when file descriptor is used
254 * @param port port to connect or 0 when file descriptor is used
256 void sipe_backend_ft_start(struct sipe_file_transfer
*ft
,
257 struct sipe_backend_fd
*fd
,
258 const char* ip
, unsigned port
);
261 * Check whether file transfer is incoming or outgoing
263 * @param ft file transfer data
264 * @return @c TRUE if @c ft is incoming, otherwise @c FALSE
266 gboolean
sipe_backend_ft_is_incoming(struct sipe_file_transfer
*ft
);
268 /** GROUP CHAT ***************************************************************/
270 #define SIPE_GROUPCHAT_ROOM_FILEPOST 0x00000001
271 #define SIPE_GROUPCHAT_ROOM_INVITE 0x00000002
272 #define SIPE_GROUPCHAT_ROOM_LOGGED 0x00000004
273 #define SIPE_GROUPCHAT_ROOM_PRIVATE 0x00000008
276 * Add a room found through room query
278 * @param uri room URI
279 * @param name human readable name for room
280 * @param description room description
281 * @param users number of users in the room
282 * @param flags SIPE_GROUPCHAT_ROOM_* flags
284 void sipe_backend_groupchat_room_add(struct sipe_core_public
*sipe_public
,
287 const gchar
*description
,
292 * Terminate room query
294 void sipe_backend_groupchat_room_terminate(struct sipe_core_public
*sipe_public
);
296 /** IM ***********************************************************************/
298 void sipe_backend_im_message(struct sipe_core_public
*sipe_public
,
301 void sipe_backend_im_topic(struct sipe_core_public
*sipe_public
,
305 /** MARKUP *******************************************************************/
307 gchar
*sipe_backend_markup_css_property(const gchar
*style
,
308 const gchar
*option
);
309 gchar
*sipe_backend_markup_strip_html(const gchar
*html
);
311 /** MEDIA ********************************************************************/
320 SIPE_CANDIDATE_TYPE_ANY
,
321 SIPE_CANDIDATE_TYPE_HOST
,
322 SIPE_CANDIDATE_TYPE_RELAY
,
323 SIPE_CANDIDATE_TYPE_SRFLX
,
324 SIPE_CANDIDATE_TYPE_PRFLX
328 SIPE_COMPONENT_NONE
= 0,
329 SIPE_COMPONENT_RTP
= 1,
330 SIPE_COMPONENT_RTCP
= 2
339 SIPE_NETWORK_PROTOCOL_TCP_ACTIVE
,
340 SIPE_NETWORK_PROTOCOL_TCP_PASSIVE
,
341 SIPE_NETWORK_PROTOCOL_UDP
342 } SipeNetworkProtocol
;
344 struct sipe_media_call
;
345 struct sipe_backend_media
;
346 struct sipe_backend_codec
;
347 struct sipe_backend_candidate
;
348 struct sipe_backend_stream
;
349 struct sipe_backend_media_relays
;
351 struct sipe_media_call
{
352 struct sipe_backend_media
*backend_private
;
354 void (*stream_initialized_cb
)(struct sipe_media_call
*,
355 struct sipe_backend_stream
*);
356 void (*media_end_cb
)(struct sipe_media_call
*);
357 void (*call_accept_cb
)(struct sipe_media_call
*, gboolean local
);
358 void (*call_reject_cb
)(struct sipe_media_call
*, gboolean local
);
359 void (*call_hold_cb
) (struct sipe_media_call
*, gboolean local
,
361 void (*call_hangup_cb
)(struct sipe_media_call
*, gboolean local
);
362 void (*error_cb
)(struct sipe_media_call
*, gchar
*message
);
365 struct sipe_media_relay
{
369 struct sipe_dns_query
*dns_query
;
373 struct sipe_backend_media
*sipe_backend_media_new(struct sipe_core_public
*sipe_public
,
374 struct sipe_media_call
*call
,
375 const gchar
*participant
,
377 void sipe_backend_media_free(struct sipe_backend_media
*media
);
379 void sipe_backend_media_set_cname(struct sipe_backend_media
*media
, gchar
*cname
);
381 struct sipe_backend_media_relays
* sipe_backend_media_relays_convert(GSList
*media_relays
,
384 void sipe_backend_media_relays_free(struct sipe_backend_media_relays
*media_relays
);
386 struct sipe_backend_stream
*sipe_backend_media_add_stream(struct sipe_backend_media
*media
,
388 const gchar
*participant
,
390 SipeIceVersion ice_version
,
392 struct sipe_backend_media_relays
*media_relays
);
393 void sipe_backend_media_remove_stream(struct sipe_backend_media
*media
,
394 struct sipe_backend_stream
*stream
);
395 GSList
*sipe_backend_media_get_streams(struct sipe_backend_media
*media
);
396 struct sipe_backend_stream
*sipe_backend_media_get_stream_by_id(struct sipe_backend_media
*media
,
398 void sipe_backend_media_add_remote_candidates(struct sipe_backend_media
*media
,
399 struct sipe_backend_stream
*stream
,
401 gboolean
sipe_backend_media_is_initiator(struct sipe_backend_media
*media
,
402 struct sipe_backend_stream
*stream
);
403 gboolean
sipe_backend_media_accepted(struct sipe_backend_media
*media
);
404 gboolean
sipe_backend_stream_initialized(struct sipe_backend_media
*media
,
405 struct sipe_backend_stream
*stream
);
406 GList
*sipe_backend_media_get_active_local_candidates(struct sipe_backend_media
*media
,
407 struct sipe_backend_stream
*stream
);
408 GList
*sipe_backend_media_get_active_remote_candidates(struct sipe_backend_media
*media
,
409 struct sipe_backend_stream
*stream
);
411 /* Stream handling */
412 const gchar
*sipe_backend_stream_get_id(struct sipe_backend_stream
*stream
);
413 void sipe_backend_stream_hold(struct sipe_backend_media
*media
,
414 struct sipe_backend_stream
*stream
,
416 void sipe_backend_stream_unhold(struct sipe_backend_media
*media
,
417 struct sipe_backend_stream
*stream
,
419 gboolean
sipe_backend_stream_is_held(struct sipe_backend_stream
*stream
);
422 struct sipe_backend_codec
*sipe_backend_codec_new(int id
,
424 SipeMediaType type
, guint clock_rate
);
425 void sipe_backend_codec_free(struct sipe_backend_codec
*codec
);
426 int sipe_backend_codec_get_id(struct sipe_backend_codec
*codec
);
428 * @return codec name. Will be g_free'd() by the core.
430 gchar
*sipe_backend_codec_get_name(struct sipe_backend_codec
*codec
);
431 guint
sipe_backend_codec_get_clock_rate(struct sipe_backend_codec
*codec
);
432 void sipe_backend_codec_add_optional_parameter(struct sipe_backend_codec
*codec
,
435 GList
*sipe_backend_codec_get_optional_parameters(struct sipe_backend_codec
*codec
);
436 gboolean
sipe_backend_set_remote_codecs(struct sipe_backend_media
*media
,
437 struct sipe_backend_stream
*stream
,
439 GList
* sipe_backend_get_local_codecs(struct sipe_backend_media
*media
,
440 struct sipe_backend_stream
*stream
);
442 /* Candidate handling */
443 struct sipe_backend_candidate
* sipe_backend_candidate_new(const gchar
*foundation
,
444 SipeComponentType component
,
445 SipeCandidateType type
,
446 SipeNetworkProtocol proto
,
447 const gchar
*ip
, guint port
,
448 const gchar
*username
,
449 const gchar
*password
);
450 void sipe_backend_candidate_free(struct sipe_backend_candidate
*candidate
);
452 * @return user name. Will be g_free'd() by the core.
454 gchar
*sipe_backend_candidate_get_username(struct sipe_backend_candidate
*candidate
);
456 * @return password. Will be g_free'd() by the core.
458 gchar
*sipe_backend_candidate_get_password(struct sipe_backend_candidate
*candidate
);
460 * @return foundation. Will be g_free'd() by the core.
462 gchar
*sipe_backend_candidate_get_foundation(struct sipe_backend_candidate
*candidate
);
464 * @return IP address string. Will be g_free'd() by the core.
466 gchar
*sipe_backend_candidate_get_ip(struct sipe_backend_candidate
*candidate
);
467 guint
sipe_backend_candidate_get_port(struct sipe_backend_candidate
*candidate
);
469 * @return IP address string. Will be g_free'd() by the core.
471 gchar
*sipe_backend_candidate_get_base_ip(struct sipe_backend_candidate
*candidate
);
472 guint
sipe_backend_candidate_get_base_port(struct sipe_backend_candidate
*candidate
);
473 guint32
sipe_backend_candidate_get_priority(struct sipe_backend_candidate
*candidate
);
474 void sipe_backend_candidate_set_priority(struct sipe_backend_candidate
*candidate
, guint32 priority
);
475 SipeComponentType
sipe_backend_candidate_get_component_type(struct sipe_backend_candidate
*candidate
);
476 SipeCandidateType
sipe_backend_candidate_get_type(struct sipe_backend_candidate
*candidate
);
477 SipeNetworkProtocol
sipe_backend_candidate_get_protocol(struct sipe_backend_candidate
*candidate
);
478 GList
* sipe_backend_get_local_candidates(struct sipe_backend_media
*media
,
479 struct sipe_backend_stream
*stream
);
480 void sipe_backend_media_accept(struct sipe_backend_media
*media
, gboolean local
);
481 void sipe_backend_media_hangup(struct sipe_backend_media
*media
, gboolean local
);
482 void sipe_backend_media_reject(struct sipe_backend_media
*media
, gboolean local
);
484 /** NETWORK ******************************************************************/
486 const gchar
*sipe_backend_network_ip_address(struct sipe_core_public
*sipe_public
);
488 struct sipe_backend_listendata
;
490 typedef void (*sipe_listen_start_cb
)(unsigned short port
, gpointer data
);
491 typedef void (*sipe_client_connected_cb
)(struct sipe_backend_fd
*fd
, gpointer data
);
493 struct sipe_backend_listendata
*
494 sipe_backend_network_listen_range(unsigned short port_min
,
495 unsigned short port_max
,
496 sipe_listen_start_cb listen_cb
,
497 sipe_client_connected_cb connect_cb
,
499 void sipe_backend_network_listen_cancel(struct sipe_backend_listendata
*ldata
);
501 gboolean
sipe_backend_fd_is_valid(struct sipe_backend_fd
*fd
);
502 void sipe_backend_fd_free(struct sipe_backend_fd
*fd
);
504 /** NOTIFICATIONS *************************************************************/
506 void sipe_backend_notify_message_error(struct sipe_core_public
*sipe_public
,
507 struct sipe_backend_chat_session
*backend_session
,
509 const gchar
*message
);
510 void sipe_backend_notify_message_info(struct sipe_core_public
*sipe_public
,
511 struct sipe_backend_chat_session
*backend_session
,
513 const gchar
*message
);
516 * @param msg error message. Maybe @NULL
518 void sipe_backend_notify_error(struct sipe_core_public
*sipe_public
,
522 /** SCHEDULE *****************************************************************/
524 gpointer
sipe_backend_schedule_seconds(struct sipe_core_public
*sipe_public
,
527 gpointer
sipe_backend_schedule_mseconds(struct sipe_core_public
*sipe_public
,
530 void sipe_backend_schedule_cancel(struct sipe_core_public
*sipe_public
,
533 /** SEARCH *******************************************************************/
535 struct sipe_backend_search_results
;
536 struct sipe_backend_search_token
;
538 void sipe_backend_search_failed(struct sipe_core_public
*sipe_public
,
539 struct sipe_backend_search_token
*token
,
541 struct sipe_backend_search_results
*sipe_backend_search_results_start(struct sipe_core_public
*sipe_public
,
542 struct sipe_backend_search_token
*token
);
543 void sipe_backend_search_results_add(struct sipe_core_public
*sipe_public
,
544 struct sipe_backend_search_results
*results
,
547 const gchar
*company
,
548 const gchar
*country
,
550 void sipe_backend_search_results_finalize(struct sipe_core_public
*sipe_public
,
551 struct sipe_backend_search_results
*results
,
552 const gchar
*description
,
555 /** SETTINGS *****************************************************************/
558 SIPE_SETTING_EMAIL_URL
= 0,
559 SIPE_SETTING_EMAIL_LOGIN
,
560 SIPE_SETTING_EMAIL_PASSWORD
,
561 SIPE_SETTING_GROUPCHAT_USER
,
562 SIPE_SETTING_USER_AGENT
,
565 const gchar
*sipe_backend_setting(struct sipe_core_public
*sipe_public
,
568 /** STATUS *******************************************************************/
570 guint
sipe_backend_status(struct sipe_core_public
*sipe_public
);
571 gboolean
sipe_backend_status_changed(struct sipe_core_public
*sipe_public
,
573 const gchar
*message
);
574 void sipe_backend_status_and_note(struct sipe_core_public
*sipe_public
,
576 const gchar
*message
);
578 /** TRANSPORT ****************************************************************/
580 typedef void transport_connected_cb(struct sipe_transport_connection
*conn
);
581 typedef void transport_input_cb(struct sipe_transport_connection
*conn
);
582 typedef void transport_error_cb(struct sipe_transport_connection
*conn
,
587 const gchar
*server_name
;
590 transport_connected_cb
*connected
;
591 transport_input_cb
*input
;
592 transport_error_cb
*error
;
593 } sipe_connect_setup
;
594 struct sipe_transport_connection
*sipe_backend_transport_connect(struct sipe_core_public
*sipe_public
,
595 const sipe_connect_setup
*setup
);
596 void sipe_backend_transport_disconnect(struct sipe_transport_connection
*conn
);
597 void sipe_backend_transport_message(struct sipe_transport_connection
*conn
,
598 const gchar
*buffer
);
599 void sipe_backend_transport_flush(struct sipe_transport_connection
*conn
);
601 /** USER *********************************************************************/
603 void sipe_backend_user_feedback_typing(struct sipe_core_public
*sipe_public
,
605 void sipe_backend_user_feedback_typing_stop(struct sipe_core_public
*sipe_public
,
609 * Present a query that is to be accepted or declined by the user
611 * @param sipe_public The handle representing the protocol instance
612 * @param message Text of the query to be shown to user
613 * @param accept_label Label to be displayed on UI control that accepts query
614 * @param decline_label Label to be displayed on UI control that declines query
615 * @param key Opaque handle uniquely identifying the query. Backend
616 * should store it for the case SIPE core requests the
617 * query to be closed prematurely.
619 void sipe_backend_user_ask(struct sipe_core_public
*sipe_public
,
620 const gchar
*message
,
621 const gchar
*accept_label
,
622 const gchar
*decline_label
,
626 * Closes the pending user query
628 * @param key Opaque handle uniquely identifying the query.
630 void sipe_backend_user_close_ask(gpointer key
);
632 /** BUDDIES ******************************************************************/
635 * sipe_backend_buddy_get/set_string(): properties a buddy can have
636 * sipe_backend_buddy_info_add(): mapped, e.g. to a string label
640 SIPE_BUDDY_INFO_DISPLAY_NAME
= 0,
641 SIPE_BUDDY_INFO_JOB_TITLE
,
642 SIPE_BUDDY_INFO_CITY
,
643 SIPE_BUDDY_INFO_STATE
,
644 SIPE_BUDDY_INFO_OFFICE
,
645 SIPE_BUDDY_INFO_DEPARTMENT
,
646 SIPE_BUDDY_INFO_COUNTRY
,
647 SIPE_BUDDY_INFO_WORK_PHONE
,
648 SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY
,
649 SIPE_BUDDY_INFO_COMPANY
,
650 SIPE_BUDDY_INFO_EMAIL
,
651 SIPE_BUDDY_INFO_SITE
,
652 SIPE_BUDDY_INFO_ZIPCODE
,
653 SIPE_BUDDY_INFO_STREET
,
654 SIPE_BUDDY_INFO_MOBILE_PHONE
,
655 SIPE_BUDDY_INFO_MOBILE_PHONE_DISPLAY
,
656 SIPE_BUDDY_INFO_HOME_PHONE
,
657 SIPE_BUDDY_INFO_HOME_PHONE_DISPLAY
,
658 SIPE_BUDDY_INFO_OTHER_PHONE
,
659 SIPE_BUDDY_INFO_OTHER_PHONE_DISPLAY
,
660 SIPE_BUDDY_INFO_CUSTOM1_PHONE
,
661 SIPE_BUDDY_INFO_CUSTOM1_PHONE_DISPLAY
,
662 SIPE_BUDDY_INFO_ALIAS
, /* only for sipe_backend_buddy_info_add() */
663 SIPE_BUDDY_INFO_DEVICE
, /* only for sipe_backend_buddy_info_add() */
664 } sipe_buddy_info_fields
;
667 typedef void* sipe_backend_buddy
;
670 * Find a buddy in the given group of the buddy list, or anywhere on the
671 * list if @group_name is empty
673 * @param sipe_public The handle representing the protocol instance making the call
674 * @param buddy_name The name of the buddy
675 * @param group_name The name of the group to look in, or NULL for any group
676 * @return opaque handle to the buddy, or NULL if no buddy found
678 sipe_backend_buddy
sipe_backend_buddy_find(struct sipe_core_public
*sipe_public
,
679 const gchar
*buddy_name
,
680 const gchar
*group_name
);
683 * Find all named buddies in the given group of the buddy list, or anywhere on the
684 * list if @group_name is empty; or all buddies if @name is empty
686 * @param sipe_public The handle representing the protocol instance making the call
687 * @param name The name of the buddy
688 * @param group_name The name of the group to look in, or NULL for any group
689 * @return GSList of opaque handles to the buddies
691 GSList
* sipe_backend_buddy_find_all(struct sipe_core_public
*sipe_public
,
692 const gchar
*buddy_name
,
693 const gchar
*group_name
);
696 * Gets the name of a contact.
698 * @param sipe_public The handle representing the protocol instance making the call
699 * @param who The opaque handle to the contact as found by find_buddy
700 * @return The name. Must be freed.
702 gchar
* sipe_backend_buddy_get_name(struct sipe_core_public
*sipe_public
,
703 const sipe_backend_buddy who
);
706 * Gets the alias for a contact.
708 * @param sipe_public The handle representing the protocol instance making the call
709 * @param who The opaque handle to the contact as found by find_buddy
710 * @return The alias. Must be gfree'd.
712 gchar
* sipe_backend_buddy_get_alias(struct sipe_core_public
*sipe_public
,
713 const sipe_backend_buddy who
);
716 * Gets the server alias for a contact.
718 * @param sipe_public The handle representing the protocol instance making the call
719 * @param who The opaque handle to the contact as found by find_buddy
720 * @return The alias. Must be freed.
722 gchar
* sipe_backend_buddy_get_server_alias(struct sipe_core_public
*sipe_public
,
723 const sipe_backend_buddy who
);
726 * Gets the local alias for a contact
728 * @param sipe_public The handle representing the protocol instance making the call
729 * @param uri the budyy name
731 * @return the alias. Must be @g_free()'d.
733 gchar
*sipe_backend_buddy_get_local_alias(struct sipe_core_public
*sipe_public
,
734 const sipe_backend_buddy who
);
737 * Gets the name of the group a contact belongs to.
739 * @param sipe_public The handle representing the protocol instance making the call
740 * @param who The opaque handle to the contact as found by find_buddy
741 * @return The name. Must be freed.
743 gchar
* sipe_backend_buddy_get_group_name(struct sipe_core_public
*sipe_public
,
744 const sipe_backend_buddy who
);
747 * Called to retrieve a buddy-specific setting.
749 * @param sipe_public The handle representing the protocol instance making the call
750 * @param buddy The handle representing the buddy
751 * @param key The name of the setting
752 * @return The value of the setting. Must be freed.
754 gchar
* sipe_backend_buddy_get_string(struct sipe_core_public
*sipe_public
,
755 sipe_backend_buddy buddy
,
756 const sipe_buddy_info_fields key
);
759 * Called to set a buddy-specific setting.
761 * @param sipe_public The handle representing the protocol instance making the call
762 * @param buddy The handle representing the buddy
763 * @param key The name of the setting
764 * @param val The value to set
766 void sipe_backend_buddy_set_string(struct sipe_core_public
*sipe_public
,
767 sipe_backend_buddy buddy
,
768 const sipe_buddy_info_fields key
,
772 * Called after one ore more buddy-specific settings have been updated.
774 * Can be used by the backend to trigger an UI update event
776 * @param sipe_public The handle representing the protocol instance making the call
777 * @param uri SIP URI of the contact
779 void sipe_backend_buddy_refresh_properties(struct sipe_core_public
*sipe_public
,
783 * Get the status token for a contact
785 * @param sipe_public The handle representing the protocol instance making the call
786 * @param uri SIP URI of the contact
790 guint
sipe_backend_buddy_get_status(struct sipe_core_public
*sipe_public
,
794 * Sets the alias for a contact.
796 * @param sipe_public The handle representing the protocol instance making the call
797 * @param who The opaque handle to the contact as found by find_buddy
798 * @param alias The location where the alias will be put
799 * case. FALSE if the buddy was not found. The value of alias will not be changed.
801 void sipe_backend_buddy_set_alias(struct sipe_core_public
*sipe_public
,
802 const sipe_backend_buddy who
,
806 * Sets the server alias for a contact.
808 * @param sipe_public The handle representing the protocol instance making the call
809 * @param who The opaque handle to the contact as found by find_buddy
810 * @param alias The server alias of the contact
812 void sipe_backend_buddy_set_server_alias(struct sipe_core_public
*sipe_public
,
813 const sipe_backend_buddy who
,
817 * Start processing buddy list
819 * Will be called every time we receive a buddy list in roaming contacts
821 * @param sipe_public The handle representing the protocol instance making the call
823 void sipe_backend_buddy_list_processing_start(struct sipe_core_public
*sipe_public
);
826 * Finished processing buddy list
828 * Will be called every time we receive a buddy list in roaming contacts
830 * @param sipe_public The handle representing the protocol instance making the call
832 void sipe_backend_buddy_list_processing_finish(struct sipe_core_public
*sipe_public
);
835 * Add a contact to the buddy list
837 * @param sipe_public The handle representing the protocol instance making the call
838 * @param name The name of the contact
839 * @param alias The alias of the contact
840 * @param groupname The name of the group to add this contact to
841 * @return A handle to the newly created buddy
843 sipe_backend_buddy
sipe_backend_buddy_add(struct sipe_core_public
*sipe_public
,
846 const gchar
*groupname
);
849 * Remove a contact from the buddy list
851 * @param sipe_public The handle representing the protocol instance making the call
852 * @param who The opaque handle to the contact as found by find_buddy
854 void sipe_backend_buddy_remove(struct sipe_core_public
*sipe_public
,
855 const sipe_backend_buddy who
);
858 * Notifies the user that a remote user has wants to add the local user to his
859 * or her buddy list and requires authorization to do so.
861 * @param sipe_public The handle representing the protocol instance making the call
862 * @param who The name of the user that added this account
863 * @param alias The optional alias of the remote user
864 * @param on_list True if the user is already in our list
865 * @param auth_cb The callback called when the local user accepts
866 * @param deny_cb The callback called when the local user rejects
867 * @param data Data to be passed back to the above callbacks
869 typedef void (*sipe_backend_buddy_request_authorization_cb
)(void *);
871 void sipe_backend_buddy_request_add(struct sipe_core_public
*sipe_public
,
875 void sipe_backend_buddy_request_authorization(struct sipe_core_public
*sipe_public
,
879 sipe_backend_buddy_request_authorization_cb auth_cb
,
880 sipe_backend_buddy_request_authorization_cb deny_cb
,
883 gboolean
sipe_backend_buddy_is_blocked(struct sipe_core_public
*sipe_public
,
886 void sipe_backend_buddy_set_blocked_status(struct sipe_core_public
*sipe_public
,
890 void sipe_backend_buddy_set_status(struct sipe_core_public
*sipe_public
,
895 * Checks whether backend has a capability to use buddy photos. If this function
896 * returns @c FALSE, SIPE core will not attempt to download the photos from
897 * server to save bandwidth.
899 * @return @c TRUE if backend is photo capable, otherwise @FALSE
901 gboolean
sipe_backend_uses_photo(void);
904 * Gives backend a photo image associated with a SIP URI. Backend has ownership
905 * of the data and must free it when not needed.
907 * @param sipe_public The handle representing the protocol instance making the call
908 * @param who The name of the user whose photo is being set
909 * @param image_data The photo image data, must be g_free()'d by backend
910 * @param image_len Size of the image in Bytes
911 * @param photo_hash A data checksum provided by the server
913 void sipe_backend_buddy_set_photo(struct sipe_core_public
*sipe_public
,
917 const gchar
*photo_hash
);
920 * Retrieves a photo hash stored together with image data by
921 * @c sipe_backend_buddy_set_photo. Value is used by the core to detect photo
922 * file changes on server.
924 * @param sipe_public The handle representing the protocol instance making the call
925 * @param who The name of the user whose photo hash to retrieve
926 * @return a photo hash (may be NULL)
928 const gchar
*sipe_backend_buddy_get_photo_hash(struct sipe_core_public
*sipe_public
,
932 * Called when a new internal group is about to be added. If this returns FALSE,
933 * the group will not be added.
935 * @param sipe_public The handle representing the protocol instance making the call
936 * @param group_name The group being added
937 * @return TRUE if everything is ok, FALSE if the group should not be added
939 gboolean
sipe_backend_buddy_group_add(struct sipe_core_public
*sipe_public
,
940 const gchar
*group_name
);
943 * Called when a new internal group has been renamed
945 * @param sipe_public The handle representing the protocol instance making the call
946 * @param old_name old name of the group
947 * @param new_name new name of the group
948 * @return TRUE if the group was found and renamed
950 gboolean
sipe_backend_buddy_group_rename(struct sipe_core_public
*sipe_public
,
951 const gchar
*old_name
,
952 const gchar
*new_name
);
955 * Called when a new internal group should be deleted
957 * NOTE: this will only be called on empty groups.
959 * @param sipe_public The handle representing the protocol instance making the call
960 * @param group_name The group that should be removed
962 void sipe_backend_buddy_group_remove(struct sipe_core_public
*sipe_public
,
963 const gchar
*group_name
);
966 * Present requested buddy information to the user
968 struct sipe_backend_buddy_info
;
969 struct sipe_backend_buddy_info
*sipe_backend_buddy_info_start(struct sipe_core_public
*sipe_public
);
970 void sipe_backend_buddy_info_add(struct sipe_core_public
*sipe_public
,
971 struct sipe_backend_buddy_info
*info
,
972 sipe_buddy_info_fields key
,
974 void sipe_backend_buddy_info_break(struct sipe_core_public
*sipe_public
,
975 struct sipe_backend_buddy_info
*info
);
976 void sipe_backend_buddy_info_finalize(struct sipe_core_public
*sipe_public
,
977 struct sipe_backend_buddy_info
*info
,
980 struct sipe_backend_buddy_tooltip
;
981 void sipe_backend_buddy_tooltip_add(struct sipe_core_public
*sipe_public
,
982 struct sipe_backend_buddy_tooltip
*tooltip
,
983 const gchar
*description
,
987 * Buddy menu creation
989 enum sipe_buddy_menu_type
{
990 SIPE_BUDDY_MENU_MAKE_CHAT_LEADER
= 0,
991 SIPE_BUDDY_MENU_REMOVE_FROM_CHAT
,
992 SIPE_BUDDY_MENU_INVITE_TO_CHAT
,
993 SIPE_BUDDY_MENU_NEW_CHAT
,
994 SIPE_BUDDY_MENU_MAKE_CALL
,
995 SIPE_BUDDY_MENU_SEND_EMAIL
,
996 SIPE_BUDDY_MENU_ACCESS_LEVEL_HELP
,
997 SIPE_BUDDY_MENU_CHANGE_ACCESS_LEVEL
,
998 SIPE_BUDDY_MENU_ADD_NEW_DOMAIN
,
999 SIPE_BUDDY_MENU_TYPES
1002 struct sipe_backend_buddy_menu
*sipe_backend_buddy_menu_start(struct sipe_core_public
*sipe_public
);
1003 struct sipe_backend_buddy_menu
*sipe_backend_buddy_menu_add(struct sipe_core_public
*sipe_public
,
1004 struct sipe_backend_buddy_menu
*menu
,
1006 enum sipe_buddy_menu_type type
,
1007 gpointer parameter
);
1008 struct sipe_backend_buddy_menu
*sipe_backend_buddy_menu_separator(struct sipe_core_public
*sipe_public
,
1009 struct sipe_backend_buddy_menu
*menu
,
1010 const gchar
*label
);
1011 struct sipe_backend_buddy_menu
*sipe_backend_buddy_sub_menu_add(struct sipe_core_public
*sipe_public
,
1012 struct sipe_backend_buddy_menu
*menu
,
1014 struct sipe_backend_buddy_menu
*sub
);