[telepathy-mission-control/master] Move McdClient::activatable to be a property on McdClientProxy
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Sep 21 09:44:42 PDT 2009
---
src/mcd-client-priv.h | 6 +++++-
src/mcd-client.c | 36 +++++++++++++++++++++++++++++++++++-
src/mcd-dispatcher.c | 15 ++++++---------
3 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/src/mcd-client-priv.h b/src/mcd-client-priv.h
index d6da038..6f2bd18 100644
--- a/src/mcd-client-priv.h
+++ b/src/mcd-client-priv.h
@@ -69,7 +69,8 @@ G_GNUC_INTERNAL GType _mcd_client_proxy_get_type (void);
G_GNUC_INTERNAL McdClientProxy *_mcd_client_proxy_new (
TpDBusDaemon *dbus_daemon, TpHandleRepoIface *string_pool,
- const gchar *name_suffix, const gchar *unique_name_if_known);
+ const gchar *name_suffix, const gchar *unique_name_if_known,
+ gboolean activatable);
G_GNUC_INTERNAL gboolean _mcd_client_proxy_is_ready (McdClientProxy *self);
@@ -77,12 +78,15 @@ G_GNUC_INTERNAL gboolean _mcd_client_check_valid_name (
const gchar *name_suffix, GError **error);
G_GNUC_INTERNAL gboolean _mcd_client_proxy_is_active (McdClientProxy *self);
+G_GNUC_INTERNAL gboolean _mcd_client_proxy_is_activatable
+ (McdClientProxy *self);
G_GNUC_INTERNAL const gchar *_mcd_client_proxy_get_unique_name (
McdClientProxy *self);
G_GNUC_INTERNAL void _mcd_client_proxy_set_inactive (McdClientProxy *self);
G_GNUC_INTERNAL void _mcd_client_proxy_set_active (McdClientProxy *self,
const gchar *unique_name);
+G_GNUC_INTERNAL void _mcd_client_proxy_set_activatable (McdClientProxy *self);
#define MC_CLIENT_BUS_NAME_BASE_LEN (sizeof (TP_CLIENT_BUS_NAME_BASE) - 1)
diff --git a/src/mcd-client.c b/src/mcd-client.c
index bdb1e87..ecac87c 100644
--- a/src/mcd-client.c
+++ b/src/mcd-client.c
@@ -38,6 +38,7 @@ G_DEFINE_TYPE (McdClientProxy, _mcd_client_proxy, TP_TYPE_CLIENT);
enum
{
PROP_0,
+ PROP_ACTIVATABLE,
PROP_STRING_POOL,
PROP_UNIQUE_NAME,
};
@@ -55,6 +56,11 @@ struct _McdClientProxyPrivate
TpHandleRepoIface *string_pool;
gchar *unique_name;
gboolean ready;
+
+ /* If a client was in the ListActivatableNames list, it must not be
+ * removed when it disappear from the bus.
+ */
+ gboolean activatable;
};
static void
@@ -82,6 +88,15 @@ _mcd_client_proxy_is_active (McdClientProxy *self)
self->priv->unique_name[0] != '\0';
}
+gboolean
+_mcd_client_proxy_is_activatable (McdClientProxy *self)
+{
+ g_return_val_if_fail (MCD_IS_CLIENT_PROXY (self), FALSE);
+ g_return_val_if_fail (self->priv->ready, FALSE);
+
+ return self->priv->activatable;
+}
+
const gchar *
_mcd_client_proxy_get_unique_name (McdClientProxy *self)
{
@@ -203,6 +218,10 @@ mcd_client_proxy_set_property (GObject *object,
switch (property)
{
+ case PROP_ACTIVATABLE:
+ self->priv->activatable = g_value_get_boolean (value);
+ break;
+
case PROP_STRING_POOL:
g_assert (self->priv->string_pool == NULL);
self->priv->string_pool = g_value_dup_object (value);
@@ -236,6 +255,11 @@ _mcd_client_proxy_class_init (McdClientProxyClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ g_object_class_install_property (object_class, PROP_ACTIVATABLE,
+ g_param_spec_boolean ("activatable", "Activatable?",
+ "TRUE if this client can be service-activated", FALSE,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property (object_class, PROP_STRING_POOL,
g_param_spec_object ("string-pool", "String pool",
"TpHandleRepoIface used to intern strings representing capability "
@@ -312,7 +336,8 @@ McdClientProxy *
_mcd_client_proxy_new (TpDBusDaemon *dbus_daemon,
TpHandleRepoIface *string_pool,
const gchar *name_suffix,
- const gchar *unique_name_if_known)
+ const gchar *unique_name_if_known,
+ gboolean activatable)
{
McdClientProxy *self;
gchar *bus_name, *object_path;
@@ -335,6 +360,7 @@ _mcd_client_proxy_new (TpDBusDaemon *dbus_daemon,
"object-path", object_path,
"bus-name", bus_name,
"unique-name", unique_name_if_known,
+ "activatable", activatable,
NULL);
g_free (object_path);
@@ -361,3 +387,11 @@ _mcd_client_proxy_set_active (McdClientProxy *self,
g_free (self->priv->unique_name);
self->priv->unique_name = g_strdup (unique_name);
}
+
+void
+_mcd_client_proxy_set_activatable (McdClientProxy *self)
+{
+ g_return_if_fail (MCD_IS_CLIENT_PROXY (self));
+
+ self->priv->activatable = TRUE;
+}
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 7f72866..fbe5964 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -166,11 +166,6 @@ typedef struct _McdClient
McdClientInterface interfaces;
guint bypass_approver : 1;
- /* If a client was in the ListActivatableNames list, it must not be
- * removed when it disappear from the bus.
- */
- guint activatable : 1;
-
/* Channel filters
* A channel filter is a GHashTable of
* - key: gchar *property_name
@@ -2590,12 +2585,12 @@ create_mcd_client (McdDispatcher *self,
client = g_slice_new0 (McdClient);
client->name = g_strdup (name + MC_CLIENT_BUS_NAME_BASE_LEN);
- client->activatable = activatable;
client->capability_tokens = tp_handle_set_new (self->priv->string_pool);
client->proxy = (TpClient *) _mcd_client_proxy_new (
- self->priv->dbus_daemon, self->priv->string_pool, client->name, owner);
+ self->priv->dbus_daemon, self->priv->string_pool, client->name, owner,
+ activatable);
DEBUG ("McdClient created for %s", name);
@@ -2729,7 +2724,8 @@ mcd_dispatcher_add_client (McdDispatcher *self,
*/
if (activatable)
{
- client->activatable = TRUE;
+ _mcd_client_proxy_set_activatable
+ ((McdClientProxy *) client->proxy);
}
else
{
@@ -2877,7 +2873,8 @@ name_owner_changed_cb (TpDBusDaemon *proxy,
{
_mcd_client_proxy_set_inactive ((McdClientProxy *) client->proxy);
- if (!client->activatable)
+ if (!_mcd_client_proxy_is_activatable
+ ((McdClientProxy *) client->proxy))
{
/* in ContactCapabilities we indicate the disappearance
* of a client by giving it an empty set of capabilities and
--
1.5.6.5
More information about the telepathy-commits
mailing list