diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-12-15 20:41:49 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:34 +0100 |
commit | 00b2e2d2dd72e920fae5b1d6f12a4158a775d604 (patch) | |
tree | ae58514647a9db465ab8728d77699af214f421d6 | |
parent | 48f0061355780dfb6ebc61c0df94abd338872846 (diff) |
bearer: new property to define whether the bearer is allowed to connect
Modems will allow bearers to get connected once they are registered in the
network.
-rw-r--r-- | src/mm-bearer.c | 32 | ||||
-rw-r--r-- | src/mm-bearer.h | 10 |
2 files changed, 38 insertions, 4 deletions
diff --git a/src/mm-bearer.c b/src/mm-bearer.c index 459377c1..35621f09 100644 --- a/src/mm-bearer.c +++ b/src/mm-bearer.c @@ -43,6 +43,7 @@ enum { PROP_PATH, PROP_CONNECTION, PROP_MODEM, + PROP_CONNECTION_ALLOWED, PROP_LAST }; @@ -55,6 +56,8 @@ struct _MMBearerPrivate { MMBaseModem *modem; /* The path where the BEARER object is exported */ gchar *path; + /* Flag to specify whether the bearer can be connected */ + gboolean connection_allowed; }; /*****************************************************************************/ @@ -176,7 +179,18 @@ mm_bearer_get_path (MMBearer *self) return self->priv->path; } -/*****************************************************************************/ +void +mm_bearer_set_connection_allowed (MMBearer *self) +{ + self->priv->connection_allowed = TRUE; +} + +void +mm_bearer_set_connection_forbidden (MMBearer *self) +{ + self->priv->connection_allowed = FALSE; + /* TODO: possibly, force disconnection */ +} void mm_bearer_expose_properties (MMBearer *bearer, @@ -208,6 +222,8 @@ mm_bearer_expose_properties (MMBearer *bearer, g_variant_builder_end (&builder)); } +/*****************************************************************************/ + static void set_property (GObject *object, guint prop_id, @@ -243,6 +259,9 @@ set_property (GObject *object, self, MM_BEARER_CONNECTION, G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); break; + case PROP_CONNECTION_ALLOWED: + self->priv->connection_allowed = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -267,6 +286,9 @@ get_property (GObject *object, case PROP_MODEM: g_value_set_object (value, self->priv->modem); break; + case PROP_CONNECTION_ALLOWED: + g_value_set_boolean (value, self->priv->connection_allowed); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -352,4 +374,12 @@ mm_bearer_class_init (MMBearerClass *klass) MM_TYPE_BASE_MODEM, G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_MODEM, properties[PROP_MODEM]); + + properties[PROP_CONNECTION_ALLOWED] = + g_param_spec_boolean (MM_BEARER_CONNECTION_ALLOWED, + "Connection allowed", + "Flag to specify whether the bearer is allowed to get connected", + FALSE, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_CONNECTION_ALLOWED, properties[PROP_CONNECTION_ALLOWED]); } diff --git a/src/mm-bearer.h b/src/mm-bearer.h index 8a73caa3..aeec20d9 100644 --- a/src/mm-bearer.h +++ b/src/mm-bearer.h @@ -35,9 +35,10 @@ typedef struct _MMBearer MMBearer; typedef struct _MMBearerClass MMBearerClass; typedef struct _MMBearerPrivate MMBearerPrivate; -#define MM_BEARER_PATH "bearer-path" -#define MM_BEARER_CONNECTION "bearer-connection" -#define MM_BEARER_MODEM "bearer-modem" +#define MM_BEARER_PATH "bearer-path" +#define MM_BEARER_CONNECTION "bearer-connection" +#define MM_BEARER_MODEM "bearer-modem" +#define MM_BEARER_CONNECTION_ALLOWED "bearer-connection-allowed" /* Prefix for all bearer object paths */ #define MM_DBUS_BEARER_PREFIX MM_DBUS_PATH "/Bearers" @@ -76,4 +77,7 @@ void mm_bearer_expose_properties (MMBearer *bearer, const gchar *first_property_name, ...); +void mm_bearer_set_connection_allowed (MMBearer *bearer); +void mm_bearer_set_connection_forbidden (MMBearer *bearer); + #endif /* MM_BEARER_H */ |