diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-12-12 17:54:14 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:33 +0100 |
commit | 667e3edfbd62d4b2f9ceb90eaaf38571441eaf36 (patch) | |
tree | 4d5417fa282661af62089f415f3dfe9a9bf72984 | |
parent | e00d3127d5589dd1ae72e87f4330ce7502ea0921 (diff) |
bearer: ensure only valid bearers are exported
We setup bearer export in DBus only if the input properties are the expected
ones.
-rw-r--r-- | src/mm-bearer.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mm-bearer.c b/src/mm-bearer.c index 01afd3b3..c5a73f6f 100644 --- a/src/mm-bearer.c +++ b/src/mm-bearer.c @@ -235,14 +235,10 @@ mm_bearer_new (MMBaseModem *modem, /* Ensure only one capability is set */ g_assert_cmpuint (mm_count_bits_set (capability), ==, 1); - /* Build the unique path for the Bearer, and create the object */ - path = g_strdup_printf (MM_DBUS_BEARER_PREFIX "%d", id++); + /* Create the object */ bearer = g_object_new (MM_TYPE_BEARER, - MM_BEARER_PATH, path, - MM_BEARER_MODEM, modem, MM_BEARER_CAPABILITY, capability, NULL); - g_free (path); /* Parse and set input properties */ if (!parse_input_properties (bearer, capability, properties, error)) { @@ -257,6 +253,15 @@ mm_bearer_new (MMBaseModem *modem, mm_gdbus_bearer_set_ip4_config (MM_GDBUS_BEARER (bearer), NULL); mm_gdbus_bearer_set_ip6_config (MM_GDBUS_BEARER (bearer), NULL); + /* Set modem and path ONLY after having checked input properties, so that + * we don't export invalid bearers. */ + path = g_strdup_printf (MM_DBUS_BEARER_PREFIX "%d", id++); + g_object_set (bearer, + MM_BEARER_PATH, path, + MM_BEARER_MODEM, modem, + NULL); + g_free (path); + return bearer; } @@ -433,7 +438,7 @@ mm_bearer_class_init (MMBearerClass *klass) "Path", "DBus path of the Bearer", NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_PATH, properties[PROP_PATH]); properties[PROP_MODEM] = |