]> git.0d.be Git - empathy.git/blob - libempathy/gossip-utils.h
052dfb78166150a4b15a46b9b603f18e9d04591a
[empathy.git] / libempathy / gossip-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 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 __GOSSIP_UTILS_H__
27 #define __GOSSIP_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/mission-control.h>
36
37 #include "gossip-contact.h"
38
39 G_BEGIN_DECLS
40
41 #define G_STR_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
42
43 typedef enum {
44         GOSSIP_REGEX_AS_IS,
45         GOSSIP_REGEX_BROWSER,
46         GOSSIP_REGEX_EMAIL,
47         GOSSIP_REGEX_OTHER,
48         GOSSIP_REGEX_ALL,
49 } GossipRegExType;
50
51 /* Regular expressions */
52 gchar *      gossip_substring                      (const gchar     *str,
53                                                     gint             start,
54                                                     gint             end);
55 gint         gossip_regex_match                    (GossipRegExType  type,
56                                                     const gchar     *msg,
57                                                     GArray          *start,
58                                                     GArray          *end);
59
60 /* Strings */
61 gint         gossip_strcasecmp                     (const gchar     *s1,
62                                                     const gchar     *s2);
63 gint         gossip_strncasecmp                    (const gchar     *s1,
64                                                     const gchar     *s2,
65                                                     gsize            n);
66
67 /* XML */
68 gboolean     gossip_xml_validate                   (xmlDoc          *doc,
69                                                     const gchar     *dtd_filename);
70 xmlNodePtr   gossip_xml_node_get_child             (xmlNodePtr       node,
71                                                     const gchar     *child_name);
72 xmlChar *    gossip_xml_node_get_child_content     (xmlNodePtr       node,
73                                                     const gchar     *child_name);
74 xmlNodePtr   gossip_xml_node_find_child_prop_value (xmlNodePtr       node,
75                                                     const gchar     *prop_name,
76                                                     const gchar     *prop_value);
77
78
79 /* GValue/GType */
80 GType        gossip_dbus_type_to_g_type            (const gchar     *dbus_type_string);
81 const gchar *gossip_g_type_to_dbus_type            (GType            g_type);
82 gchar *      gossip_g_value_to_string              (const GValue    *value);
83 GValue *     gossip_string_to_g_value              (const gchar     *str,
84                                                     GType            type);
85 gboolean     gossip_g_value_equal                  (const GValue    *value1,
86                                                     const GValue    *value2);
87
88 guint        gossip_account_hash                    (gconstpointer   key);
89 gboolean     gossip_account_equal                   (gconstpointer   a,
90                                                      gconstpointer   b);
91 MissionControl *gossip_mission_control_new (void);
92
93 G_END_DECLS
94
95 #endif /*  __GOSSIP_UTILS_H__ */