To emit emulator object list when any emulator is created or removed.
---
 src/emulator.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index f1cb9ef..5ad0d78 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -55,6 +55,7 @@ struct emulator {
 
 static void notify_status_watches(struct emulator *e, void *data);
 static void emulator_dbus_unregister(void *data, void *user_data);
+static gboolean emit_emulator_list_changed(void *data);
 
 static unsigned int emulator_next_id(struct ofono_emulator *oe)
 {
@@ -189,11 +190,14 @@ error:
 static gboolean real_destroy(void *data)
 {
        struct emulator *e = data;
+       struct ofono_emulator *oe = e->oe;
 
        e->timeout_source = 0;
 
        emulator_dbus_unregister(e, NULL);
 
+       emit_emulator_list_changed(oe);
+
        return FALSE;
 }
 
@@ -309,6 +313,25 @@ static int emulators_path_list(struct ofono_emulator *oe, 
char ***objlist)
        return 0;
 }
 
+static gboolean emit_emulator_list_changed(void *data)
+{
+       struct ofono_emulator *oe = data;
+       DBusConnection *conn = ofono_dbus_get_connection();
+       const char *path = __ofono_atom_get_path(oe->atom);
+       char **objpath_list;
+
+       emulators_path_list(oe, &objpath_list);
+
+       ofono_dbus_signal_array_property_changed(conn, path,
+                                       OFONO_EMULATOR_MANAGER_INTERFACE,
+                                       "Emulators", DBUS_TYPE_OBJECT_PATH,
+                                       &objpath_list);
+
+       g_strfreev(objpath_list);
+
+       return FALSE;
+}
+
 static DBusMessage *manager_destroy(DBusConnection *conn, DBusMessage *msg,
                                                void *data)
 {
@@ -323,6 +346,8 @@ static DBusMessage *manager_destroy(DBusConnection *conn, 
DBusMessage *msg,
 
        __ofono_watchlist_remove_all(oe->status_watches);
 
+       emit_emulator_list_changed(oe);
+
        return dbus_message_new_method_return(msg);
 }
 
@@ -472,6 +497,8 @@ static void emulator_remove_all(struct ofono_atom *atom)
                g_slist_free(oe->emulator_list);
        }
 
+       emit_emulator_list_changed(oe);
+
        __ofono_watchlist_free(oe->status_watches);
 
        g_free(oe);
-- 
1.6.3.3

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to