]> git.0d.be Git - empathy.git/blob - libempathy/empathy-utils.h
Fixed copyright and author headers. (Jonny Lamb)
[empathy.git] / libempathy / empathy-utils.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * Copyright (C) 2003-2007 Imendio AB
4  * Copyright (C) 2007-2008 Collabora Ltd.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  * Authors: Richard Hult <richard@imendio.com>
22  *          Martyn Russell <martyn@imendio.com>
23  *          Xavier Claessens <xclaesse@gmail.com>
24  *          Jonny Lamb <jonny.lamb@collabora.co.uk>
25  */
26
27 #ifndef __EMPATHY_UTILS_H__
28 #define __EMPATHY_UTILS_H__
29
30 #include <glib.h>
31 #include <glib-object.h>
32
33 #include <libxml/parser.h>
34 #include <libxml/tree.h>
35
36 #include <libmissioncontrol/mc-account.h>
37 #include <libmissioncontrol/mission-control.h>
38
39 #include "empathy-contact.h"
40 #include "empathy-tp-file.h"
41
42 G_BEGIN_DECLS
43
44 #define EMPATHY_GET_PRIV(obj,type) ((type##Priv*) ((type*)obj)->priv)
45 #define G_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
46
47 typedef enum {
48         EMPATHY_REGEX_AS_IS,
49         EMPATHY_REGEX_BROWSER,
50         EMPATHY_REGEX_APT,
51         EMPATHY_REGEX_EMAIL,
52         EMPATHY_REGEX_OTHER,
53         EMPATHY_REGEX_ALL,
54 } EmpathyRegExType;
55
56 /* Regular expressions */
57 gchar *      empathy_substring                      (const gchar     *str,
58                                                     gint             start,
59                                                     gint             end);
60 gint         empathy_regex_match                    (EmpathyRegExType  type,
61                                                     const gchar     *msg,
62                                                     GArray          *start,
63                                                     GArray          *end);
64
65 /* Strings */
66 gint         empathy_strcasecmp                     (const gchar     *s1,
67                                                     const gchar     *s2);
68 gint         empathy_strncasecmp                    (const gchar     *s1,
69                                                     const gchar     *s2,
70                                                     gsize            n);
71
72 /* XML */
73 gboolean     empathy_xml_validate                   (xmlDoc          *doc,
74                                                     const gchar     *dtd_filename);
75 xmlNodePtr   empathy_xml_node_get_child             (xmlNodePtr       node,
76                                                     const gchar     *child_name);
77 xmlChar *    empathy_xml_node_get_child_content     (xmlNodePtr       node,
78                                                     const gchar     *child_name);
79 xmlNodePtr   empathy_xml_node_find_child_prop_value (xmlNodePtr       node,
80                                                     const gchar     *prop_name,
81                                                     const gchar     *prop_value);
82
83 /* Others */
84 guint        empathy_account_hash                   (gconstpointer    key);
85 gboolean     empathy_account_equal                  (gconstpointer    a,
86                                                     gconstpointer    b);
87 MissionControl *empathy_mission_control_new         (void);
88 const gchar * empathy_presence_get_default_message  (McPresence       presence);
89 const gchar * empathy_presence_to_str               (McPresence       presence);
90 McPresence    empathy_presence_from_str             (const gchar     *str);
91 gchar *       empathy_file_lookup                   (const gchar     *filename,
92                                                      const gchar     *subdir);
93
94 typedef gboolean (*EmpathyRunUntilReadyFunc)        (GObject         *object,
95                                                      gpointer         user_data);
96 void          empathy_run_until_ready               (gpointer         object);
97 void          empathy_run_until_ready_full          (gpointer         object,
98                                                      const gchar     *signal,
99                                                      EmpathyRunUntilReadyFunc  func,
100                                                      gpointer         user_data,
101                                                      GMainLoop      **loop);
102 McAccount *  empathy_channel_get_account            (TpChannel       *channel);
103 gpointer     empathy_connect_to_account_status_changed (MissionControl *mc,
104                                                          GCallback       handler,
105                                                          gpointer        user_data,
106                                                          GClosureNotify  free_func);
107 void         empathy_disconnect_account_status_changed (gpointer      token);
108 gboolean     empathy_proxy_equal                    (gconstpointer    a,
109                                                      gconstpointer    b);
110 guint        empathy_proxy_hash                     (gconstpointer    key);
111
112 typedef void (*empathy_connection_callback_for_request_channel) (TpConnection *connection,
113                                                                  TpChannel *channel,
114                                                                  const GError *error,
115                                                                  gpointer user_data,
116                                                                  GObject *weak_object);
117 void empathy_connection_request_channel (TpConnection *proxy,
118                                          gint timeout_ms,
119                                          const gchar *channel_type,
120                                          guint handle_type,
121                                          const gchar *name,
122                                          gboolean suppress_handler,
123                                          empathy_connection_callback_for_request_channel callback,
124                                          gpointer user_data,
125                                          GDestroyNotify destroy,
126                                          GObject *weak_object);
127 EmpathyFile *  empathy_send_file_from_stream        (EmpathyContact  *contact,
128                                                      GInputStream    *in_stream,
129                                                      const gchar     *filename,
130                                                      guint64          size);
131 EmpathyFile *  empathy_send_file                    (EmpathyContact  *contact,
132                                                      GFile           *file);
133 /* File transfer */
134 EmpathyTpFile *empathy_send_file                      (EmpathyContact  *contact,
135                                                        GFile           *file);
136
137 G_END_DECLS
138
139 #endif /*  __EMPATHY_UTILS_H__ */