diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 18:17:01 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-16 14:53:26 +0100 |
commit | 473c5fee4d920d723366cef1f406279e48eaf3d2 (patch) | |
tree | c5d8e630a8648c17299d0950d25fe77c5a5e1f0a /src | |
parent | 4f06aa5106be4688a751bf34601d1a03e3c49ce6 (diff) |
bearer: properties are exposed before exporting the bearer object
And we let subclasses to specify which of the input properties need to be
exposed.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-bearer.c | 31 | ||||
-rw-r--r-- | src/mm-bearer.h | 4 | ||||
-rw-r--r-- | src/mm-broadband-bearer.c | 34 |
3 files changed, 36 insertions, 33 deletions
diff --git a/src/mm-bearer.c b/src/mm-bearer.c index 7f92677b..4a7e7b49 100644 --- a/src/mm-bearer.c +++ b/src/mm-bearer.c @@ -68,12 +68,28 @@ struct _MMBearerPrivate { /*****************************************************************************/ +static void +bearer_expose_properties (MMBearer *self) +{ + MMBearerProperties *properties; + GVariant *dictionary; + + properties = MM_BEARER_GET_CLASS (self)->expose_properties (self); + dictionary = mm_bearer_properties_get_dictionary (properties); + mm_gdbus_bearer_set_properties (MM_GDBUS_BEARER (self), dictionary); + g_variant_unref (dictionary); + g_object_unref (properties); +} + void mm_bearer_export (MMBearer *self) { static guint id = 0; gchar *path; + /* Expose properties before exporting */ + bearer_expose_properties (self); + path = g_strdup_printf (MM_DBUS_BEARER_PREFIX "/%d", id++); g_object_set (self, MM_BEARER_PATH, path, @@ -637,21 +653,6 @@ mm_bearer_cmp_properties (MMBearer *self, /*****************************************************************************/ -void -mm_bearer_expose_properties (MMBearer *bearer, - MMBearerProperties *properties) -{ - GVariant *dictionary; - - /* Keep the whole list of properties in the interface */ - dictionary = mm_bearer_properties_get_dictionary (properties); - mm_gdbus_bearer_set_properties (MM_GDBUS_BEARER (bearer), - dictionary); - g_variant_unref (dictionary); -} - -/*****************************************************************************/ - static void set_property (GObject *object, guint prop_id, diff --git a/src/mm-bearer.h b/src/mm-bearer.h index 809bf161..84fbcb37 100644 --- a/src/mm-bearer.h +++ b/src/mm-bearer.h @@ -79,6 +79,10 @@ struct _MMBearerClass { /* Check if the bearer has the exact same properties */ gboolean (* cmp_properties) (MMBearer *self, MMBearerProperties *properties); + + /* Builder of the properties to be exposed in DBus. Bearers should expose only + * the input properties they actually ended up using */ + MMBearerProperties * (* expose_properties) (MMBearer *self); }; GType mm_bearer_get_type (void); diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c index 42a525e4..4425412d 100644 --- a/src/mm-broadband-bearer.c +++ b/src/mm-broadband-bearer.c @@ -1660,6 +1660,21 @@ cmp_properties (MMBearer *self, mm_bearer_properties_get_rm_protocol (properties))); } +static MMBearerProperties * +expose_properties (MMBearer *self) +{ + MMBroadbandBearer *broadband = MM_BROADBAND_BEARER (self); + MMBearerProperties *properties; + + properties = mm_bearer_properties_new (); + mm_bearer_properties_set_apn (properties, broadband->priv->apn); + mm_bearer_properties_set_number (properties, broadband->priv->number); + mm_bearer_properties_set_rm_protocol (properties, broadband->priv->rm_protocol); + mm_bearer_properties_set_ip_type (properties, broadband->priv->ip_type); + mm_bearer_properties_set_allow_roaming (properties, broadband->priv->allow_roaming); + return properties; +} + /*****************************************************************************/ typedef struct _InitAsyncContext InitAsyncContext; @@ -1668,7 +1683,6 @@ static void interface_initialization_step (InitAsyncContext *ctx); typedef enum { INITIALIZATION_STEP_FIRST, INITIALIZATION_STEP_CDMA_RM_PROTOCOL, - INITIALIZATION_STEP_EXPOSE_PROPERTIES, INITIALIZATION_STEP_LAST } InitializationStep; @@ -1874,23 +1888,6 @@ interface_initialization_step (InitAsyncContext *ctx) /* Fall down to next step */ ctx->step++; - case INITIALIZATION_STEP_EXPOSE_PROPERTIES: { - MMBearerProperties *properties; - - /* We create a new properties object just with the stuff we really used */ - properties = mm_bearer_properties_new (); - mm_bearer_properties_set_apn (properties, ctx->self->priv->apn); - mm_bearer_properties_set_number (properties, ctx->self->priv->number); - mm_bearer_properties_set_rm_protocol (properties, ctx->self->priv->rm_protocol); - mm_bearer_properties_set_ip_type (properties, ctx->self->priv->ip_type); - mm_bearer_properties_set_allow_roaming (properties, ctx->self->priv->allow_roaming); - mm_bearer_expose_properties (MM_BEARER (ctx->self), properties); - g_object_unref (properties); - - /* Fall down to next step */ - ctx->step++; - } - case INITIALIZATION_STEP_LAST: if (mm_iface_modem_is_3gpp (MM_IFACE_MODEM (ctx->modem))) { @@ -2135,6 +2132,7 @@ mm_broadband_bearer_class_init (MMBroadbandBearerClass *klass) object_class->dispose = dispose; bearer_class->cmp_properties = cmp_properties; + bearer_class->expose_properties = expose_properties; bearer_class->connect = connect; bearer_class->connect_finish = connect_finish; bearer_class->disconnect = disconnect; |