]> git.0d.be Git - empathy.git/blob - libempathy/empathy-utils.h
Don't destroy MainWindow on delete-event, just hide it
[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
31 #include <gnutls/gnutls.h>
32 #include <gnutls/x509.h>
33 #include <libxml/parser.h>
34 #include <libxml/tree.h>
35 #include <folks/folks.h>
36 #include <folks/folks-telepathy.h>
37 #include <telepathy-glib/account-manager.h>
38
39 #include "empathy-contact.h"
40
41 #define EMPATHY_GET_PRIV(obj,type) ((type##Priv *) ((type *) obj)->priv)
42 #define EMP_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
43
44 G_BEGIN_DECLS
45
46 void empathy_init (void);
47
48 /* XML */
49 gboolean empathy_xml_validate (xmlDoc *doc,
50     const gchar *dtd_filename);
51 xmlNodePtr empathy_xml_node_get_child (xmlNodePtr node,
52     const gchar *child_name);
53 xmlChar * empathy_xml_node_get_child_content (xmlNodePtr node,
54     const gchar *child_name);
55 xmlNodePtr empathy_xml_node_find_child_prop_value (xmlNodePtr node,
56     const gchar *prop_name,
57     const gchar *prop_value);
58
59 /* Others */
60 const gchar * empathy_presence_get_default_message (
61     TpConnectionPresenceType presence);
62 const gchar * empathy_presence_to_str (TpConnectionPresenceType presence);
63 TpConnectionPresenceType empathy_presence_from_str (const gchar *str);
64 gchar * empathy_file_lookup (const gchar *filename,
65     const gchar *subdir);
66 gboolean empathy_proxy_equal (gconstpointer a,
67     gconstpointer    b);
68 guint empathy_proxy_hash (gconstpointer key);
69 gboolean empathy_check_available_state (void);
70 gint empathy_uint_compare (gconstpointer a,
71     gconstpointer b);
72
73 const gchar * empathy_account_get_error_message (TpAccount *account,
74     gboolean *user_requested);
75
76 gchar *empathy_protocol_icon_name (const gchar *protocol);
77 const gchar *empathy_protocol_name_to_display_name (const gchar *proto_name);
78 const gchar *empathy_service_name_to_display_name (const gchar *proto_name);
79
80 #define EMPATHY_ARRAY_TYPE_OBJECT (empathy_type_dbus_ao ())
81 GType empathy_type_dbus_ao (void);
82
83 gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting);
84
85 void empathy_connect_new_account (TpAccount *account,
86     TpAccountManager *account_manager);
87
88 TpConnectionPresenceType empathy_folks_presence_type_to_tp (
89     FolksPresenceType type);
90 gboolean empathy_folks_individual_contains_contact (
91     FolksIndividual *individual);
92 EmpathyContact * empathy_contact_dup_from_folks_individual (
93     FolksIndividual *individual);
94 TpChannelGroupChangeReason tp_channel_group_change_reason_from_folks_groups_change_reason (
95     FolksGroupDetailsChangeReason reason);
96 TpfPersonaStore * empathy_dup_persona_store_for_connection (
97     TpConnection *connection);
98 gboolean empathy_connection_can_add_personas (TpConnection *connection);
99 gboolean empathy_connection_can_alias_personas (TpConnection *connection);
100 gboolean empathy_connection_can_group_personas (TpConnection *connection);
101 gboolean empathy_folks_persona_is_interesting (FolksPersona *persona);
102
103 gchar * empathy_get_x509_certificate_hostname (gnutls_x509_crt_t cert);
104
105 gchar *empathy_format_currency (gint amount,
106     guint scale,
107     const gchar *currency);
108
109 gboolean empathy_account_has_uri_scheme_tel (TpAccount *account);
110
111 TpContact * empathy_get_tp_contact_for_individual (FolksIndividual *individual,
112     TpConnection *conn);
113
114 /* Copied from wocky/wocky-utils.h */
115
116 #define empathy_implement_finish_void(source, tag) \
117     if (g_simple_async_result_propagate_error (\
118       G_SIMPLE_ASYNC_RESULT (result), error)) \
119       return FALSE; \
120     g_return_val_if_fail (g_simple_async_result_is_valid (result, \
121             G_OBJECT(source), tag), \
122         FALSE); \
123     return TRUE;
124
125 #define empathy_implement_finish_copy_pointer(source, tag, copy_func, \
126     out_param) \
127     GSimpleAsyncResult *_simple; \
128     _simple = (GSimpleAsyncResult *) result; \
129     if (g_simple_async_result_propagate_error (_simple, 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     if (out_param != NULL) \
135       *out_param = copy_func ( \
136           g_simple_async_result_get_op_res_gpointer (_simple)); \
137     return TRUE;
138
139 #define empathy_implement_finish_return_copy_pointer(source, tag, copy_func) \
140     GSimpleAsyncResult *_simple; \
141     _simple = (GSimpleAsyncResult *) result; \
142     if (g_simple_async_result_propagate_error (_simple, error)) \
143       return NULL; \
144     g_return_val_if_fail (g_simple_async_result_is_valid (result, \
145             G_OBJECT (source), tag), \
146         NULL); \
147     return copy_func (g_simple_async_result_get_op_res_gpointer (_simple));
148
149 #define empathy_implement_finish_return_pointer(source, tag) \
150     GSimpleAsyncResult *_simple; \
151     _simple = (GSimpleAsyncResult *) result; \
152     if (g_simple_async_result_propagate_error (_simple, error)) \
153       return NULL; \
154     g_return_val_if_fail (g_simple_async_result_is_valid (result, \
155             G_OBJECT (source), tag), \
156         NULL); \
157     return g_simple_async_result_get_op_res_gpointer (_simple);
158
159 G_END_DECLS
160
161 #endif /*  __EMPATHY_UTILS_H__ */