1 /* vi: set et sw=4 ts=8 cino=t0,(0: */ 2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ 3 /* 4 * This file is part of mission-control 5 * 6 * Copyright (C) 2008-2009 Nokia Corporation. 7 * Copyright (C) 2009 Collabora Ltd. 8 * 9 * Contact: Alberto Mardegan <alberto.mardegan@nokia.com> 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public License 13 * version 2.1 as published by the Free Software Foundation. 14 * 15 * This library is distributed in the hope that it will be useful, but 16 * WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 23 * 02110-1301 USA 24 * 25 */ 26 27 #ifndef __MCD_DBUSPROP_H__ 28 #define __MCD_DBUSPROP_H__ 29 30 #include <telepathy-glib/telepathy-glib.h> 31 #include <telepathy-glib/telepathy-glib-dbus.h> 32 33 G_BEGIN_DECLS 34 35 typedef enum { 36 MCD_DBUS_PROP_SET_FLAG_NONE = 0, 37 MCD_DBUS_PROP_SET_FLAG_ALREADY_IN_STORAGE = 1 38 } McdDBusPropSetFlags; 39 40 typedef gboolean (*mcd_setprop) (TpSvcDBusProperties *self, 41 const gchar *name, 42 const GValue *value, 43 McdDBusPropSetFlags flags, 44 GError **error); 45 typedef void (*mcd_getprop) (TpSvcDBusProperties *self, const gchar *name, 46 GValue *value); 47 48 typedef void (*mcddbus_get_cb) (TpSvcDBusProperties *self, const GValue *value, 49 const GError *error, gpointer user_data); 50 typedef void (*mcd_async_getprop) (TpSvcDBusProperties *self, const gchar *name, 51 mcddbus_get_cb callback, gpointer user_data); 52 53 typedef void (*McdInterfaceInit) (TpSvcDBusProperties *self); 54 55 typedef struct _McdDBusProp 56 { 57 const gchar *name; 58 mcd_setprop setprop; 59 mcd_getprop getprop; 60 } McdDBusProp; 61 62 typedef struct _McdInterfaceData 63 { 64 GType (*get_type)(void); 65 const gchar *interface; 66 const McdDBusProp *properties; 67 GInterfaceInitFunc iface_init; 68 McdInterfaceInit instance_init; 69 gboolean optional; 70 } McdInterfaceData; 71 72 #define MCD_IMPLEMENT_IFACE(type, type_name, dbus_name) \ 73 { \ 74 type, \ 75 dbus_name, \ 76 type_name##_properties, \ 77 (GInterfaceInitFunc)type_name##_iface_init, \ 78 NULL, \ 79 FALSE, \ 80 } 81 82 #define MCD_IMPLEMENT_IFACE_WITH_INIT(type, type_name, dbus_name) \ 83 { \ 84 type, \ 85 dbus_name, \ 86 type_name##_properties, \ 87 (GInterfaceInitFunc)type_name##_iface_init, \ 88 type_name##_instance_init, \ 89 FALSE, \ 90 } 91 92 #define MCD_IMPLEMENT_OPTIONAL_IFACE(type, type_name, dbus_name) \ 93 { \ 94 type, \ 95 dbus_name, \ 96 type_name##_properties, \ 97 (GInterfaceInitFunc)type_name##_iface_init, \ 98 NULL, \ 99 TRUE, \ 100 } 101 102 #define MCD_IMPLEMENT_OPTIONAL_IFACE_WITH_INIT(type, type_name, dbus_name) \ 103 { \ 104 type, \ 105 dbus_name, \ 106 type_name##_properties, \ 107 (GInterfaceInitFunc)type_name##_iface_init, \ 108 type_name##_instance_init, \ 109 TRUE, \ 110 } 111 112 void mcd_dbus_init_interfaces (GType g_define_type_id, 113 const McdInterfaceData *iface_data); 114 #define MCD_DBUS_INIT_INTERFACES(iface_data) \ 115 mcd_dbus_init_interfaces (g_define_type_id, iface_data) 116 117 void mcd_dbus_init_interfaces_instances (gpointer self); 118 119 gboolean mcd_dbusprop_set_property (TpSvcDBusProperties *self, 120 const gchar *interface_name, 121 const gchar *property_name, 122 const GValue *value, 123 GError **error); 124 gboolean mcd_dbusprop_get_property (TpSvcDBusProperties *self, 125 const gchar *interface_name, 126 const gchar *property_name, 127 GValue *value, 128 GError **error); 129 130 void dbusprop_set (TpSvcDBusProperties *self, 131 const gchar *interface_name, 132 const gchar *property_name, 133 const GValue *value, 134 DBusGMethodInvocation *context); 135 136 void dbusprop_get (TpSvcDBusProperties *self, 137 const gchar *interface_name, 138 const gchar *property_name, 139 DBusGMethodInvocation *context); 140 141 void dbusprop_get_all (TpSvcDBusProperties *self, 142 const gchar *interface_name, 143 DBusGMethodInvocation *context); 144 145 void mcd_dbus_get_interfaces (TpSvcDBusProperties *self, 146 const gchar *name, 147 GValue *value); 148 149 void mcd_dbus_activate_optional_interface (TpSvcDBusProperties *object, 150 GType interface); 151 gboolean mcd_dbus_is_active_optional_interface (TpSvcDBusProperties *object, 152 GType interface); 153 154 G_END_DECLS 155 #endif /* __MCD_DBUSPROP_H__ */ 156