]> git.0d.be Git - empathy.git/blob - libempathy/empathy-utils.h
tpaw-utils: move functions for protocol and service display information
[empathy.git] / libempathy / empathy-utils.h
1 /*
2  * Copyright (C) 2003-2007 Imendio AB
3  * Copyright (C) 2007-2011 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA  02110-1301  USA
19  *
20  * Authors: Richard Hult <richard@imendio.com>
21  *          Martyn Russell <martyn@imendio.com>
22  *          Xavier Claessens <xclaesse@gmail.com>
23  */
24
25 #ifndef __EMPATHY_UTILS_H__
26 #define __EMPATHY_UTILS_H__
27
28 #include <glib.h>
29 #include <glib-object.h>
30 #include <gnutls/x509.h>
31 #include <libxml/tree.h>
32 #include <folks/folks.h>
33 #include <folks/folks-telepathy.h>
34 #include <telepathy-glib/telepathy-glib.h>
35
36 #include "empathy-contact.h"
37
38 #define EMPATHY_GET_PRIV(obj,type) ((type##Priv *) ((type *) obj)->priv)
39 #define EMP_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
40
41 G_BEGIN_DECLS
42
43 void empathy_init (void);
44
45 /* XML */
46 gboolean empathy_xml_validate_from_resource (xmlDoc *doc,
47     const gchar *dtd_resourcename);
48 xmlNodePtr empathy_xml_node_get_child (xmlNodePtr node,
49     const gchar *child_name);
50 xmlChar * empathy_xml_node_get_child_content (xmlNodePtr node,
51     const gchar *child_name);
52 xmlNodePtr empathy_xml_node_find_child_prop_value (xmlNodePtr node,
53     const gchar *prop_name,
54     const gchar *prop_value);
55
56 /* Others */
57 const gchar * empathy_presence_get_default_message (
58     TpConnectionPresenceType presence);
59 const gchar * empathy_presence_to_str (TpConnectionPresenceType presence);
60 TpConnectionPresenceType empathy_presence_from_str (const gchar *str);
61 gchar * empathy_file_lookup (const gchar *filename,
62     const gchar *subdir);
63 gint empathy_uint_compare (gconstpointer a,
64     gconstpointer b);
65
66 const gchar * empathy_account_get_error_message (TpAccount *account,
67     gboolean *user_requested);
68
69 #define EMPATHY_ARRAY_TYPE_OBJECT (empathy_type_dbus_ao ())
70 GType empathy_type_dbus_ao (void);
71
72 gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting);
73
74 TpConnectionPresenceType empathy_folks_presence_type_to_tp (
75     FolksPresenceType type);
76 gboolean empathy_folks_individual_contains_contact (
77     FolksIndividual *individual);
78 EmpathyContact * empathy_contact_dup_from_folks_individual (
79     FolksIndividual *individual);
80 TpChannelGroupChangeReason tp_channel_group_change_reason_from_folks_groups_change_reason (
81     FolksGroupDetailsChangeReason reason);
82 TpfPersonaStore * empathy_dup_persona_store_for_connection (
83     TpConnection *connection);
84 gboolean empathy_connection_can_add_personas (TpConnection *connection);
85 gboolean empathy_connection_can_alias_personas (TpConnection *connection,
86                                                 FolksIndividual *individual);
87 gboolean empathy_connection_can_group_personas (TpConnection *connection,
88                                                 FolksIndividual *individual);
89 gboolean empathy_folks_persona_is_interesting (FolksPersona *persona);
90
91 gchar * empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert);
92
93 gchar *empathy_format_currency (gint amount,
94     guint scale,
95     const gchar *currency);
96
97 gboolean empathy_account_has_uri_scheme_tel (TpAccount *account);
98
99 TpContact * empathy_get_tp_contact_for_individual (FolksIndividual *individual,
100     TpConnection *conn);
101
102 void empathy_individual_can_audio_video_call (FolksIndividual *individual,
103     gboolean *can_audio_call,
104     gboolean *can_video_call,
105     EmpathyContact **out_contact);
106
107 gboolean empathy_client_types_contains_mobile_device (
108     const GStrv types);
109
110 FolksIndividual * empathy_create_individual_from_tp_contact (
111     TpContact *contact);
112
113 FolksIndividual * empathy_ensure_individual_from_tp_contact (
114     TpContact *contact);
115
116 const gchar * const * empathy_individual_get_client_types (
117     FolksIndividual *individual);
118
119 GVariant * empathy_asv_to_vardict (const GHashTable *asv);
120
121 GVariant * empathy_boxed_to_variant (GType gtype,
122     const gchar *variant_type,
123     gpointer boxed);
124
125 /* Copied from wocky/wocky-utils.h */
126
127 #define empathy_implement_finish_void(source, tag) \
128     if (g_simple_async_result_propagate_error (\
129       G_SIMPLE_ASYNC_RESULT (result), error)) \
130       return FALSE; \
131     g_return_val_if_fail (g_simple_async_result_is_valid (result, \
132             G_OBJECT(source), tag), \
133         FALSE); \
134     return TRUE;
135
136 #define empathy_implement_finish_copy_pointer(source, tag, copy_func, \
137     out_param) \
138     GSimpleAsyncResult *_simple; \
139     _simple = (GSimpleAsyncResult *) result; \
140     if (g_simple_async_result_propagate_error (_simple, error)) \
141       return FALSE; \
142     g_return_val_if_fail (g_simple_async_result_is_valid (result, \
143             G_OBJECT (source), tag), \
144         FALSE); \
145     if (out_param != NULL) \
146       *out_param = copy_func ( \
147           g_simple_async_result_get_op_res_gpointer (_simple)); \
148     return TRUE;
149
150 #define empathy_implement_finish_return_copy_pointer(source, tag, copy_func) \
151     GSimpleAsyncResult *_simple; \
152     _simple = (GSimpleAsyncResult *) result; \
153     if (g_simple_async_result_propagate_error (_simple, error)) \
154       return NULL; \
155     g_return_val_if_fail (g_simple_async_result_is_valid (result, \
156             G_OBJECT (source), tag), \
157         NULL); \
158     return copy_func (g_simple_async_result_get_op_res_gpointer (_simple));
159
160 #define empathy_implement_finish_return_pointer(source, tag) \
161     GSimpleAsyncResult *_simple; \
162     _simple = (GSimpleAsyncResult *) result; \
163     if (g_simple_async_result_propagate_error (_simple, error)) \
164       return NULL; \
165     g_return_val_if_fail (g_simple_async_result_is_valid (result, \
166             G_OBJECT (source), tag), \
167         NULL); \
168     return g_simple_async_result_get_op_res_gpointer (_simple);
169
170 G_END_DECLS
171
172 #endif /*  __EMPATHY_UTILS_H__ */