]> git.0d.be Git - empathy.git/blob - libempathy/empathy-utils.h
Added empathy_send_file* helper functions to empathy-utils. (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  */
25
26 #ifndef __EMPATHY_UTILS_H__
27 #define __EMPATHY_UTILS_H__
28
29 #include <glib.h>
30 #include <glib-object.h>
31
32 #include <libxml/parser.h>
33 #include <libxml/tree.h>
34
35 #include <libmissioncontrol/mc-account.h>
36 #include <libmissioncontrol/mission-control.h>
37
38 #include "empathy-contact.h"
39 #include "empathy-file.h"
40
41 G_BEGIN_DECLS
42
43 #define EMPATHY_GET_PRIV(obj,type) ((type##Priv*) ((type*)obj)->priv)
44 #define G_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
45
46 typedef enum {
47         EMPATHY_REGEX_AS_IS,
48         EMPATHY_REGEX_BROWSER,
49         EMPATHY_REGEX_APT,
50         EMPATHY_REGEX_EMAIL,
51         EMPATHY_REGEX_OTHER,
52         EMPATHY_REGEX_ALL,
53 } EmpathyRegExType;
54
55 /* Regular expressions */
56 gchar *      empathy_substring                      (const gchar     *str,
57                                                     gint             start,
58                                                     gint             end);
59 gint         empathy_regex_match                    (EmpathyRegExType  type,
60                                                     const gchar     *msg,
61                                                     GArray          *start,
62                                                     GArray          *end);
63
64 /* Strings */
65 gint         empathy_strcasecmp                     (const gchar     *s1,
66                                                     const gchar     *s2);
67 gint         empathy_strncasecmp                    (const gchar     *s1,
68                                                     const gchar     *s2,
69                                                     gsize            n);
70
71 /* XML */
72 gboolean     empathy_xml_validate                   (xmlDoc          *doc,
73                                                     const gchar     *dtd_filename);
74 xmlNodePtr   empathy_xml_node_get_child             (xmlNodePtr       node,
75                                                     const gchar     *child_name);
76 xmlChar *    empathy_xml_node_get_child_content     (xmlNodePtr       node,
77                                                     const gchar     *child_name);
78 xmlNodePtr   empathy_xml_node_find_child_prop_value (xmlNodePtr       node,
79                                                     const gchar     *prop_name,
80                                                     const gchar     *prop_value);
81
82 /* Others */
83 guint        empathy_account_hash                   (gconstpointer    key);
84 gboolean     empathy_account_equal                  (gconstpointer    a,
85                                                     gconstpointer    b);
86 MissionControl *empathy_mission_control_new         (void);
87 const gchar * empathy_presence_get_default_message  (McPresence       presence);
88 const gchar * empathy_presence_to_str               (McPresence       presence);
89 McPresence    empathy_presence_from_str             (const gchar     *str);
90 gchar *       empathy_file_lookup                   (const gchar     *filename,
91                                                      const gchar     *subdir);
92
93 typedef gboolean (*EmpathyRunUntilReadyFunc)        (GObject         *object,
94                                                      gpointer         user_data);
95 void          empathy_run_until_ready               (gpointer         object);
96 void          empathy_run_until_ready_full          (gpointer         object,
97                                                      const gchar     *signal,
98                                                      EmpathyRunUntilReadyFunc  func,
99                                                      gpointer         user_data,
100                                                      GMainLoop      **loop);
101 McAccount *  empathy_channel_get_account            (TpChannel       *channel);
102 gpointer     empathy_connect_to_account_status_changed (MissionControl *mc,
103                                                          GCallback       handler,
104                                                          gpointer        user_data,
105                                                          GClosureNotify  free_func);
106 void         empathy_disconnect_account_status_changed (gpointer      token);
107 gboolean     empathy_proxy_equal                    (gconstpointer    a,
108                                                      gconstpointer    b);
109 guint        empathy_proxy_hash                     (gconstpointer    key);
110
111 typedef void (*empathy_connection_callback_for_request_channel) (TpConnection *connection,
112                                                                  TpChannel *channel,
113                                                                  const GError *error,
114                                                                  gpointer user_data,
115                                                                  GObject *weak_object);
116 void empathy_connection_request_channel (TpConnection *proxy,
117                                          gint timeout_ms,
118                                          const gchar *channel_type,
119                                          guint handle_type,
120                                          const gchar *name,
121                                          gboolean suppress_handler,
122                                          empathy_connection_callback_for_request_channel callback,
123                                          gpointer user_data,
124                                          GDestroyNotify destroy,
125                                          GObject *weak_object);
126 EmpathyFile *  empathy_send_file_from_stream        (EmpathyContact  *contact,
127                                                      GInputStream    *in_stream,
128                                                      const gchar     *filename,
129                                                      guint64          size);
130 EmpathyFile *  empathy_send_file                    (EmpathyContact  *contact,
131                                                      GFile           *file);
132 void         empathy_init                           (void);
133
134 G_END_DECLS
135
136 #endif /*  __EMPATHY_UTILS_H__ */