diff options
Diffstat (limited to 'telephony-binding/gdbus/ofono_manager.c')
-rw-r--r-- | telephony-binding/gdbus/ofono_manager.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/telephony-binding/gdbus/ofono_manager.c b/telephony-binding/gdbus/ofono_manager.c index 2f8c4df..bb99a43 100644 --- a/telephony-binding/gdbus/ofono_manager.c +++ b/telephony-binding/gdbus/ofono_manager.c @@ -36,18 +36,19 @@ static OrgOfonoManager *manager; static struct ofono_manager_modem default_modem; static const struct afb_binding_interface *interface; -void ofono_manager_init(const struct afb_binding_interface *iface) +int ofono_manager_init(const struct afb_binding_interface *iface) { GVariant *out_arg = NULL, *next, *value; GError *error = NULL; gchar *path, *key; - GVariantIter *iter, *iter2; + GVariantIter *iter, *iter2 = NULL; + int ret = 0; interface = iface; if (manager) { ERROR(interface, "Ofono Manager already initialized\n"); - return; + return -1; } manager = org_ofono_manager_proxy_new_for_bus_sync( @@ -56,26 +57,34 @@ void ofono_manager_init(const struct afb_binding_interface *iface) if (!manager) { ERROR(interface, "Ofono Manager not initialized\n"); - return; + return -1; } org_ofono_manager_call_get_modems_sync(manager, &out_arg, NULL, &error); if (error == NULL) { g_variant_get(out_arg, "a(oa{sv})", &iter); next = g_variant_iter_next_value(iter); - g_variant_get(next, "(oa{sv})", &path, &iter2); - default_modem.path = path; - while (g_variant_iter_loop(iter2, "{sv}", &key, &value)) { - if (!strcmp(key, "Name")) - default_modem.name = g_variant_get_string(value, NULL); - else if (!strcmp(key, "Type")) - default_modem.type = g_variant_get_string(value, NULL); - else if (!strcmp(key, "Powered")) - default_modem.powered = g_variant_get_boolean(value); - else if (!strcmp(key, "Online")) - default_modem.online = g_variant_get_boolean(value); + if (next) { + g_variant_get(next, "(oa{sv})", &path, &iter2); + default_modem.path = path; + while (g_variant_iter_loop(iter2, "{sv}", &key, &value)) { + if (!strcmp(key, "Name")) + default_modem.name = g_variant_get_string(value, NULL); + else if (!strcmp(key, "Type")) + default_modem.type = g_variant_get_string(value, NULL); + else if (!strcmp(key, "Powered")) + default_modem.powered = g_variant_get_boolean(value); + else if (!strcmp(key, "Online")) + default_modem.online = g_variant_get_boolean(value); + } + } else { + ret = -1; } + } else { + ret = -1; } + + return ret; } |