diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-01-05 10:14:20 +0200 |
---|---|---|
committer | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-01-05 11:11:08 +0100 |
commit | b4bd4ecb4de9a13f5094c5e3d07446ae9dfd9b79 (patch) | |
tree | 4353827319e29dc1bc733fd1e640aecb0e4fa944 | |
parent | 70ce3cd0a6130605a5f3c1f4f334bd501bece184 (diff) | |
download | connman-b4bd4ecb4de9a13f5094c5e3d07446ae9dfd9b79.tar.gz connman-b4bd4ecb4de9a13f5094c5e3d07446ae9dfd9b79.tar.bz2 connman-b4bd4ecb4de9a13f5094c5e3d07446ae9dfd9b79.zip |
technology: Add 'TechnologyAdded' and 'TechnologyRemoved' signals
-rw-r--r-- | src/manager.c | 2 | ||||
-rw-r--r-- | src/technology.c | 59 |
2 files changed, 48 insertions, 13 deletions
diff --git a/src/manager.c b/src/manager.c index d949714f..e821df3c 100644 --- a/src/manager.c +++ b/src/manager.c @@ -516,6 +516,8 @@ static GDBusMethodTable manager_methods[] = { static GDBusSignalTable manager_signals[] = { { "PropertyChanged", "sv" }, + { "TechnologyAdded", "a{sv}" }, + { "TechnologyRemoved", "o" }, { }, }; diff --git a/src/technology.c b/src/technology.c index de0fab8f..100d138e 100644 --- a/src/technology.c +++ b/src/technology.c @@ -424,21 +424,13 @@ static connman_bool_t connman_technology_load_offlinemode() return offlinemode; } -static DBusMessage *get_properties(DBusConnection *conn, - DBusMessage *message, void *user_data) +static void append_properties(DBusMessageIter *iter, + struct connman_technology *technology) { - struct connman_technology *technology = user_data; - DBusMessage *reply; - DBusMessageIter array, dict; + DBusMessageIter dict; const char *str; - reply = dbus_message_new_method_return(message); - if (reply == NULL) - return NULL; - - dbus_message_iter_init_append(reply, &array); - - connman_dbus_dict_open(&array, &dict); + connman_dbus_dict_open(iter, &dict); str = state2string(technology->state); if (str != NULL) @@ -469,7 +461,46 @@ static DBusMessage *get_properties(DBusConnection *conn, DBUS_TYPE_STRING, &technology->tethering_passphrase); - connman_dbus_dict_close(&array, &dict); + connman_dbus_dict_close(iter, &dict); +} + +static void technology_added_signal(struct connman_technology *technology) +{ + DBusMessage *signal; + DBusMessageIter iter; + + signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "TechnologyAdded"); + if (signal == NULL) + return; + + dbus_message_iter_init_append(signal, &iter); + append_properties(&iter, technology); + + dbus_connection_send(connection, signal, NULL); + dbus_message_unref(signal); +} + +static void technology_removed_signal(struct connman_technology *technology) +{ + g_dbus_emit_signal(connection, CONNMAN_MANAGER_PATH, + CONNMAN_MANAGER_INTERFACE, "TechnologyRemoved", + DBUS_TYPE_OBJECT_PATH, technology->path); +} + +static DBusMessage *get_properties(DBusConnection *conn, + DBusMessage *message, void *user_data) +{ + struct connman_technology *technology = user_data; + DBusMessage *reply; + DBusMessageIter iter; + + reply = dbus_message_new_method_return(message); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &iter); + append_properties(&iter, technology); return reply; } @@ -614,6 +645,7 @@ static struct connman_technology *technology_get(enum connman_service_type type) technology_list = g_slist_append(technology_list, technology); technologies_changed(); + technology_added_signal(technology); if (technology->driver != NULL) goto done; @@ -653,6 +685,7 @@ static void technology_put(struct connman_technology *technology) technology_list = g_slist_remove(technology_list, technology); technologies_changed(); + technology_removed_signal(technology); g_dbus_unregister_interface(connection, technology->path, CONNMAN_TECHNOLOGY_INTERFACE); |