bearer: properties are exposed before exporting the bearer object
And we let subclasses to specify which of the input properties need to be exposed.
This commit is contained in:
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user