diff options
author | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2010-05-24 17:43:38 +0100 |
---|---|---|
committer | Vivek Dasmohapatra <vivek@collabora.co.uk> | 2010-05-24 17:43:38 +0100 |
commit | 8a2752bf7a9af0dca7c8cfecd012d67438fa401b (patch) | |
tree | 08e87cb3d099f89f56537df52535d60e82cafc4d /src/mcd-dbusprop.c | |
parent | 5fbaaa0c09fe1fda85f2e48e5ee035e991ede62a (diff) | |
download | telepathy-mission-control-8a2752bf7a9af0dca7c8cfecd012d67438fa401b.tar.gz |
Provide ACL wrapped DBus property get/set/get_all helpers
Diffstat (limited to 'src/mcd-dbusprop.c')
-rw-r--r-- | src/mcd-dbusprop.c | 121 |
1 files changed, 117 insertions, 4 deletions
diff --git a/src/mcd-dbusprop.c b/src/mcd-dbusprop.c index 3d075d76..d612924f 100644 --- a/src/mcd-dbusprop.c +++ b/src/mcd-dbusprop.c @@ -30,6 +30,9 @@ #include "mcd-dbusprop.h" #include "mcd-debug.h" +#include "mission-control-plugins/mission-control-plugins.h" +#include "mission-control-plugins/implementation.h" + #include <libmcclient/mc-interfaces.h> #include <libmcclient/mc-gtypes.h> @@ -129,11 +132,30 @@ mcd_dbusprop_set_property (TpSvcDBusProperties *self, } void +dbusprop_acl_set (TpSvcDBusProperties *self, + const gchar *interface, + const gchar *property, + const GValue *value, + DBusGMethodInvocation *context, + TpDBusDaemon *dbus, + GHashTable *params) +{ + gchar *name = g_strdup_printf ("%s.%s", interface, property); + gboolean ok = mcp_dbus_acl_authorised (dbus, context, + DBUS_ACL_TYPE_SET_PROPERTY, + name, params); + g_free (name); + + if (ok) + dbusprop_set (self, interface, property, value, context); +} + +void dbusprop_set (TpSvcDBusProperties *self, - const gchar *interface_name, - const gchar *property_name, - const GValue *value, - DBusGMethodInvocation *context) + const gchar *interface_name, + const gchar *property_name, + const GValue *value, + DBusGMethodInvocation *context) { GError *error = NULL; @@ -184,6 +206,25 @@ dbusprop_get_cb (TpSvcDBusProperties *self, const GValue *value, } void +dbusprop_acl_get (TpSvcDBusProperties *self, + const gchar *interface, + const gchar *property, + DBusGMethodInvocation *context, + TpDBusDaemon *dbus, + GHashTable *params) +{ + gchar *name = g_strdup_printf ("%s.%s", interface, property); + gboolean ok = mcp_dbus_acl_authorised (dbus, context, + DBUS_ACL_TYPE_GET_PROPERTY, + name, params); + g_free (name); + + if (ok) + dbusprop_get (self, interface, property, context); +} + + +void dbusprop_get (TpSvcDBusProperties *self, const gchar *interface_name, const gchar *property_name, @@ -282,6 +323,78 @@ get_all_iter (TpSvcDBusProperties *self, } void +dbusprop_acl_get_all (TpSvcDBusProperties *self, + const gchar *interface, + DBusGMethodInvocation *context, + TpDBusDaemon *dbus, + GHashTable *params) +{ + gchar *name = g_strdup_printf ("%s.*", interface); + gboolean ok = mcp_dbus_acl_authorised (dbus, context, + DBUS_ACL_TYPE_GET_PROPERTY, + name, params); + + g_free (name); + + if (ok) + dbusprop_get_all (self, interface, context); +} + +typedef struct +{ + TpSvcDBusProperties *tp_svc_props; + gchar *interface; + gchar *property; +} DBusPropAsyncData; + +static void +dbusprop_acl_get_all_async_complete (DBusGMethodInvocation *context, + gpointer data) +{ + DBusPropAsyncData *ad = data; + + dbusprop_get_all (ad->tp_svc_props, ad->interface, context); +} + +static void +dbusprop_acl_get_all_async_cleanup (gpointer data) +{ + DBusPropAsyncData *ad = data; + + g_object_unref (ad->tp_svc_props); + g_free (ad->interface); + g_free (ad->property); + g_slice_free (DBusPropAsyncData, data); +} + +void +dbusprop_acl_get_all_async_start (TpSvcDBusProperties *self, + const gchar *interface, + DBusGMethodInvocation *context, + TpDBusDaemon *dbus, + GHashTable *params) +{ + DBusPropAsyncData *data = g_slice_new0 (DBusPropAsyncData); + gchar *name = g_strdup_printf ("%s.*", interface); + + data->tp_svc_props = g_object_ref (self); + data->interface = g_strdup (interface); + data->property = NULL; + + mcp_dbus_acl_authorised_async (dbus, + context, + DBUS_ACL_TYPE_GET_PROPERTY, + name, + params, + dbusprop_acl_get_all_async_complete, + data, + dbusprop_acl_get_all_async_cleanup); + + g_free (name); +} + + +void dbusprop_get_all (TpSvcDBusProperties *self, const gchar *interface_name, DBusGMethodInvocation *context) |