1 /*
2  * dbus.h - Header for D-Bus utilities
3  *
4  * Copyright (C) 2005-2009 Collabora Ltd. <http://www.collabora.co.uk/>
5  * Copyright (C) 2005-2009 Nokia Corporation
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION)
23 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly."
24 #endif
25 
26 #ifndef __TELEPATHY_DBUS_H__
27 #define __TELEPATHY_DBUS_H__
28 #define __TP_IN_DBUS_H__
29 
30 #include <telepathy-glib/defs.h>
31 #include <telepathy-glib/dbus-daemon.h>
32 
33 #include <telepathy-glib/_gen/genums.h>
34 
35 G_BEGIN_DECLS
36 
37 void tp_dbus_g_method_return_not_implemented (DBusGMethodInvocation *context);
38 
39 typedef enum /*< flags >*/
40 {
41   TP_DBUS_NAME_TYPE_UNIQUE = 1,
42   TP_DBUS_NAME_TYPE_WELL_KNOWN = 2,
43   TP_DBUS_NAME_TYPE_BUS_DAEMON = 4,
44   TP_DBUS_NAME_TYPE_NOT_BUS_DAEMON = TP_DBUS_NAME_TYPE_UNIQUE | TP_DBUS_NAME_TYPE_WELL_KNOWN,
45   TP_DBUS_NAME_TYPE_ANY = TP_DBUS_NAME_TYPE_NOT_BUS_DAEMON | TP_DBUS_NAME_TYPE_BUS_DAEMON
46 } TpDBusNameType;
47 
48 gboolean tp_dbus_check_valid_bus_name (const gchar *name,
49     TpDBusNameType allow_types, GError **error);
50 
51 gboolean tp_dbus_check_valid_interface_name (const gchar *name,
52     GError **error);
53 
54 gboolean tp_dbus_check_valid_member_name (const gchar *name,
55     GError **error);
56 
57 gboolean tp_dbus_check_valid_object_path (const gchar *path,
58     GError **error);
59 
60 /* The scanner warns about these, but they're skipped anyway.
61  * See GNOME bug#656743 */
62 #ifndef __GI_SCANNER__
63 GValue *tp_g_value_slice_new_bytes (guint length, gconstpointer bytes)
64   G_GNUC_WARN_UNUSED_RESULT;
65 GValue *tp_g_value_slice_new_take_bytes (GArray *bytes)
66   G_GNUC_WARN_UNUSED_RESULT;
67 GValue *tp_g_value_slice_new_object_path (const gchar *path)
68   G_GNUC_WARN_UNUSED_RESULT;
69 GValue *tp_g_value_slice_new_static_object_path (const gchar *path)
70   G_GNUC_WARN_UNUSED_RESULT;
71 GValue *tp_g_value_slice_new_take_object_path (gchar *path)
72   G_GNUC_WARN_UNUSED_RESULT;
73 #endif /* __GI_SCANNER__ */
74 
75 #define tp_asv_size(asv) _tp_asv_size_inline (asv)
76 
77 static inline guint
_tp_asv_size_inline(const GHashTable * asv)78 _tp_asv_size_inline (const GHashTable *asv)
79 {
80   /* The empty comment here is to stop gtkdoc thinking g_hash_table_size is
81    * a declaration. */
82   return g_hash_table_size /* */ ((GHashTable *) asv);
83 }
84 
85 GHashTable *tp_asv_new (const gchar *first_key, ...)
86   G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT;
87 gboolean tp_asv_get_boolean (const GHashTable *asv, const gchar *key,
88     gboolean *valid);
89 void tp_asv_set_boolean (GHashTable *asv, const gchar *key, gboolean value);
90 gpointer tp_asv_get_boxed (const GHashTable *asv, const gchar *key,
91     GType type);
92 void tp_asv_set_boxed (GHashTable *asv, const gchar *key, GType type,
93     gconstpointer value);
94 void tp_asv_take_boxed (GHashTable *asv, const gchar *key, GType type,
95     gpointer value);
96 void tp_asv_set_static_boxed (GHashTable *asv, const gchar *key, GType type,
97     gconstpointer value);
98 const GArray *tp_asv_get_bytes (const GHashTable *asv, const gchar *key);
99 void tp_asv_set_bytes (GHashTable *asv, const gchar *key, guint length,
100     gconstpointer bytes);
101 void tp_asv_take_bytes (GHashTable *asv, const gchar *key, GArray *value);
102 gdouble tp_asv_get_double (const GHashTable *asv, const gchar *key,
103     gboolean *valid);
104 void tp_asv_set_double (GHashTable *asv, const gchar *key, gdouble value);
105 gint32 tp_asv_get_int32 (const GHashTable *asv, const gchar *key,
106     gboolean *valid);
107 void tp_asv_set_int32 (GHashTable *asv, const gchar *key, gint32 value);
108 gint64 tp_asv_get_int64 (const GHashTable *asv, const gchar *key,
109     gboolean *valid);
110 void tp_asv_set_int64 (GHashTable *asv, const gchar *key, gint64 value);
111 const gchar *tp_asv_get_object_path (const GHashTable *asv, const gchar *key);
112 void tp_asv_set_object_path (GHashTable *asv, const gchar *key,
113     const gchar *value);
114 void tp_asv_take_object_path (GHashTable *asv, const gchar *key,
115     gchar *value);
116 void tp_asv_set_static_object_path (GHashTable *asv, const gchar *key,
117     const gchar *value);
118 const gchar *tp_asv_get_string (const GHashTable *asv, const gchar *key);
119 void tp_asv_set_string (GHashTable *asv, const gchar *key, const gchar *value);
120 void tp_asv_take_string (GHashTable *asv, const gchar *key, gchar *value);
121 void tp_asv_set_static_string (GHashTable *asv, const gchar *key,
122     const gchar *value);
123 guint32 tp_asv_get_uint32 (const GHashTable *asv, const gchar *key,
124     gboolean *valid);
125 void tp_asv_set_uint32 (GHashTable *asv, const gchar *key, guint32 value);
126 guint64 tp_asv_get_uint64 (const GHashTable *asv, const gchar *key,
127     gboolean *valid);
128 void tp_asv_set_uint64 (GHashTable *asv, const gchar *key, guint64 value);
129 const GValue *tp_asv_lookup (const GHashTable *asv, const gchar *key);
130 
131 const gchar * const *
132 /* this comment stops gtkdoc denying that this function exists */
133 tp_asv_get_strv (const GHashTable *asv, const gchar *key);
134 void tp_asv_set_strv (GHashTable *asv, const gchar *key, gchar **value);
135 void tp_asv_dump (GHashTable *asv);
136 
137 #ifndef TP_DISABLE_DEPRECATED
138 _TP_DEPRECATED
139 DBusGConnection * tp_get_bus (void);
140 
141 _TP_DEPRECATED
142 DBusGProxy * tp_get_bus_proxy (void);
143 #endif
144 
145 G_END_DECLS
146 
147 #undef __TP_IN_DBUS_H__
148 #endif /* __TELEPATHY_DBUS_H__ */
149