1 /*
2  * dbus-properties-mixin.h - D-Bus core Properties
3  * Copyright (C) 2008 Collabora Ltd.
4  * Copyright (C) 2008 Nokia Corporation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library 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  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION)
22 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly."
23 #endif
24 
25 #ifndef __TP_DBUS_PROPERTIES_MIXIN_H__
26 #define __TP_DBUS_PROPERTIES_MIXIN_H__
27 
28 #include <glib-object.h>
29 
30 #include <telepathy-glib/defs.h>
31 #include <telepathy-glib/_gen/genums.h>
32 
33 G_BEGIN_DECLS
34 
35 /* ---- Semi-abstract property definition (used in TpSvc*) ---------- */
36 
37 typedef enum { /*< flags >*/
38     TP_DBUS_PROPERTIES_MIXIN_FLAG_READ = 1,
39     TP_DBUS_PROPERTIES_MIXIN_FLAG_WRITE = 2,
40     TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_CHANGED = 4,
41     TP_DBUS_PROPERTIES_MIXIN_FLAG_EMITS_INVALIDATED = 8
42 } TpDBusPropertiesMixinFlags;
43 
44 typedef struct {
45     GQuark name;
46     TpDBusPropertiesMixinFlags flags;
47     gchar *dbus_signature;
48     GType type;
49     /*<private>*/
50     GCallback _1;
51     GCallback _2;
52 } TpDBusPropertiesMixinPropInfo;
53 
54 typedef struct {
55     GQuark dbus_interface;
56     TpDBusPropertiesMixinPropInfo *props;
57     /*<private>*/
58     GCallback _1;
59     GCallback _2;
60 } TpDBusPropertiesMixinIfaceInfo;
61 
62 void tp_svc_interface_set_dbus_properties_info (GType g_interface,
63     TpDBusPropertiesMixinIfaceInfo *info);
64 _TP_AVAILABLE_IN_0_16
65 TpDBusPropertiesMixinIfaceInfo *tp_svc_interface_get_dbus_properties_info (
66     GType g_interface);
67 
68 /* ---- Concrete implementation (in GObject subclasses) ------------- */
69 
70 typedef void (*TpDBusPropertiesMixinGetter) (GObject *object,
71     GQuark iface, GQuark name, GValue *value, gpointer getter_data);
72 
73 void tp_dbus_properties_mixin_getter_gobject_properties (GObject *object,
74     GQuark iface, GQuark name, GValue *value, gpointer getter_data);
75 
76 typedef gboolean (*TpDBusPropertiesMixinSetter) (GObject *object,
77     GQuark iface, GQuark name, const GValue *value, gpointer setter_data,
78     GError **error);
79 
80 gboolean tp_dbus_properties_mixin_setter_gobject_properties (GObject *object,
81     GQuark iface, GQuark name, const GValue *value, gpointer setter_data,
82     GError **error);
83 
84 typedef struct {
85     const gchar *name;
86     gpointer getter_data;
87     gpointer setter_data;
88     /*<private>*/
89     GCallback _1;
90     GCallback _2;
91     gpointer mixin_priv;
92 } TpDBusPropertiesMixinPropImpl;
93 
94 typedef struct {
95     const gchar *name;
96     TpDBusPropertiesMixinGetter getter;
97     TpDBusPropertiesMixinSetter setter;
98     TpDBusPropertiesMixinPropImpl *props;
99     /*<private>*/
100     GCallback _1;
101     GCallback _2;
102     gpointer mixin_next;
103     gpointer mixin_priv;
104 } TpDBusPropertiesMixinIfaceImpl;
105 
106 struct _TpDBusPropertiesMixinClass {
107     TpDBusPropertiesMixinIfaceImpl *interfaces;
108     /*<private>*/
109     gpointer _1;
110     gpointer _2;
111     gpointer _3;
112     gpointer _4;
113     gpointer _5;
114     gpointer _6;
115     gpointer _7;
116 };
117 
118 typedef struct _TpDBusPropertiesMixinClass TpDBusPropertiesMixinClass;
119 
120 void tp_dbus_properties_mixin_class_init (GObjectClass *cls,
121     gsize offset);
122 
123 void tp_dbus_properties_mixin_implement_interface (GObjectClass *cls,
124     GQuark iface, TpDBusPropertiesMixinGetter getter,
125     TpDBusPropertiesMixinSetter setter, TpDBusPropertiesMixinPropImpl *props);
126 
127 void tp_dbus_properties_mixin_iface_init (gpointer g_iface,
128     gpointer iface_data);
129 
130 gboolean tp_dbus_properties_mixin_get (GObject *self,
131     const gchar *interface_name, const gchar *property_name,
132     GValue *value, GError **error);
133 _TP_AVAILABLE_IN_0_16
134 gboolean tp_dbus_properties_mixin_set (
135     GObject *self,
136     const gchar *interface_name,
137     const gchar *property_name,
138     const GValue *value,
139     GError **error);
140 
141 _TP_AVAILABLE_IN_0_22
142 GHashTable *tp_dbus_properties_mixin_dup_all (GObject *self,
143     const gchar *interface_name);
144 
145 GHashTable *tp_dbus_properties_mixin_make_properties_hash (
146     GObject *object, const gchar *first_interface,
147     const gchar *first_property, ...)
148   G_GNUC_NULL_TERMINATED G_GNUC_WARN_UNUSED_RESULT;
149 
150 void tp_dbus_properties_mixin_fill_properties_hash (GObject *object,
151     GHashTable *table,
152     const gchar *first_interface,
153     const gchar *first_property,
154     ...)
155   G_GNUC_NULL_TERMINATED;
156 
157 _TP_AVAILABLE_IN_0_16
158 void tp_dbus_properties_mixin_emit_properties_changed (
159     GObject *object,
160     const gchar *interface_name,
161     const gchar * const *properties);
162 
163 _TP_AVAILABLE_IN_0_16
164 void tp_dbus_properties_mixin_emit_properties_changed_varargs (
165     GObject *object,
166     const gchar *interface_name,
167     ...)
168   G_GNUC_NULL_TERMINATED;
169 
170 G_END_DECLS
171 
172 #endif /* #ifndef __TP_DBUS_PROPERTIES_MIXIN_H__ */
173