diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2012-10-02 12:27:15 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-10-03 14:06:13 +0300 |
commit | 0f940b08ef2c39c7e0f85e134095f53e619698a8 (patch) | |
tree | ca4226a899fd8994e450b13f3517d503602c7f07 /src | |
parent | a748feddafc79f6f870bf737c81b5bbea5839b2c (diff) | |
download | connman-0f940b08ef2c39c7e0f85e134095f53e619698a8.tar.gz connman-0f940b08ef2c39c7e0f85e134095f53e619698a8.tar.bz2 connman-0f940b08ef2c39c7e0f85e134095f53e619698a8.zip |
technology: Add helpers for (un)registering a technology in D-Bus
Diffstat (limited to 'src')
-rw-r--r-- | src/technology.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/technology.c b/src/technology.c index e94e3b97..f62ad3f4 100644 --- a/src/technology.c +++ b/src/technology.c @@ -74,6 +74,7 @@ struct connman_technology { GSList *scan_pending; connman_bool_t hardblocked; + connman_bool_t dbus_registered; }; static GSList *driver_list = NULL; @@ -930,6 +931,25 @@ static const GDBusSignalTable technology_signals[] = { { }, }; +static gboolean technology_dbus_register(struct connman_technology *technology) +{ + if (technology->dbus_registered == TRUE) + return TRUE; + + if (g_dbus_register_interface(connection, technology->path, + CONNMAN_TECHNOLOGY_INTERFACE, + technology_methods, technology_signals, + NULL, technology, NULL) == FALSE) { + connman_error("Failed to register %s", technology->path); + return FALSE; + } + + technology_added_signal(technology); + technology->dbus_registered = TRUE; + + return TRUE; +} + static struct connman_technology *technology_get(enum connman_service_type type) { struct connman_technology *technology; @@ -987,19 +1007,13 @@ static struct connman_technology *technology_get(enum connman_service_type type) technology_load(technology); - if (g_dbus_register_interface(connection, technology->path, - CONNMAN_TECHNOLOGY_INTERFACE, - technology_methods, technology_signals, - NULL, technology, NULL) == FALSE) { - connman_error("Failed to register %s", technology->path); + if (technology_dbus_register(technology) == FALSE) { g_free(technology); return NULL; } technology_list = g_slist_prepend(technology_list, technology); - technology_added_signal(technology); - technology->driver = driver; err = driver->probe(technology); if (err != 0) @@ -1010,6 +1024,18 @@ static struct connman_technology *technology_get(enum connman_service_type type) return technology; } +static void technology_dbus_unregister(struct connman_technology *technology) +{ + if (technology->dbus_registered == FALSE) + return; + + technology_removed_signal(technology); + g_dbus_unregister_interface(connection, technology->path, + CONNMAN_TECHNOLOGY_INTERFACE); + + technology->dbus_registered = FALSE; +} + static void technology_put(struct connman_technology *technology) { DBG("technology %p", technology); @@ -1026,10 +1052,7 @@ static void technology_put(struct connman_technology *technology) technology_list = g_slist_remove(technology_list, technology); - technology_removed_signal(technology); - - g_dbus_unregister_interface(connection, technology->path, - CONNMAN_TECHNOLOGY_INTERFACE); + technology_dbus_unregister(technology); g_slist_free(technology->device_list); |