diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-07-29 16:32:10 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-07-29 16:44:17 -0500 |
commit | a2d310642f47e2d139538ec04d08945bbf2f887a (patch) | |
tree | 1573d6a286e4af9315b9537c0f885c354a75da69 /src/manager.c | |
parent | ea4886816f57e588009112127974b0c4552b12b0 (diff) | |
download | ofono-a2d310642f47e2d139538ec04d08945bbf2f887a.tar.bz2 |
Move ofono_modem functions to modem.c
Diffstat (limited to 'src/manager.c')
-rw-r--r-- | src/manager.c | 101 |
1 files changed, 4 insertions, 97 deletions
diff --git a/src/manager.c b/src/manager.c index 92437a2c..9353eae6 100644 --- a/src/manager.c +++ b/src/manager.c @@ -32,102 +32,26 @@ #include "modem.h" #include "driver.h" -static GSList *g_modem_list = NULL; -static int g_next_modem_id = 1; - -/* Clients only need to free *modems */ -static int modem_list(char ***modems) -{ - GSList *l; - int i; - struct ofono_modem *modem; - - *modems = g_new0(char *, g_slist_length(g_modem_list) + 1); - - if (!*modems) - return -1; - - for (l = g_modem_list, i = 0; l; l = l->next, i++) { - modem = l->data; - - (*modems)[i] = modem->path; - } - - return 0; -} - GSList *ofono_manager_get_modems() { return g_modem_list; } -struct ofono_modem *ofono_modem_register(struct ofono_modem_attribute_ops *ops) -{ - struct ofono_modem *modem; - DBusConnection *conn = ofono_dbus_get_connection(); - char **modems; - - modem = modem_create(g_next_modem_id, ops); - - if (modem == NULL) - return 0; - - ++g_next_modem_id; - - __ofono_history_probe_drivers(modem); - g_modem_list = g_slist_prepend(g_modem_list, modem); - - if (modem_list(&modems) == 0) { - ofono_dbus_signal_array_property_changed(conn, - OFONO_MANAGER_PATH, - OFONO_MANAGER_INTERFACE, "Modems", - DBUS_TYPE_OBJECT_PATH, &modems); - - g_free(modems); - } - - return modem; -} - -int ofono_modem_unregister(struct ofono_modem *m) -{ - struct ofono_modem *modem = m; - DBusConnection *conn = ofono_dbus_get_connection(); - char **modems; - - if (modem == NULL) - return -1; - - __ofono_history_remove_drivers(modem); - modem_remove(modem); - - g_modem_list = g_slist_remove(g_modem_list, modem); - - if (modem_list(&modems) == 0) { - ofono_dbus_signal_array_property_changed(conn, - OFONO_MANAGER_PATH, - OFONO_MANAGER_INTERFACE, "Modems", - DBUS_TYPE_OBJECT_PATH, &modems); - - g_free(modems); - } - - return 0; -} - static DBusMessage *manager_get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessageIter iter; DBusMessageIter dict; DBusMessage *reply; - char **modems; + const char **modems; reply = dbus_message_new_method_return(msg); if (!reply) return NULL; - if (modem_list(&modems) == -1) + modems = __ofono_modem_get_list(); + + if (!modems) return NULL; dbus_message_iter_init_append(reply, &iter); @@ -174,25 +98,8 @@ int __ofono_manager_init() void __ofono_manager_cleanup() { - GSList *l; - struct ofono_modem *modem; DBusConnection *conn = ofono_dbus_get_connection(); - /* Clean up in case plugins didn't unregister the modems */ - for (l = g_modem_list; l; l = l->next) { - modem = l->data; - - if (!modem) - continue; - - ofono_debug("plugin owning %s forgot to unregister, cleaning up", - modem->path); - modem_remove(modem); - } - - g_slist_free(g_modem_list); - g_modem_list = 0; - g_dbus_unregister_interface(conn, OFONO_MANAGER_PATH, OFONO_MANAGER_INTERFACE); } |