[Merge] lp:~tiagosh/telepathy-ofono/use-accounts-service into lp:telepathy-ofono
Gustavo Pichorim Boiko
gustavo.boiko at canonical.com
Mon Mar 28 15:13:14 UTC 2016
Review: Needs Fixing
Just one more thing to fix.
Diff comments:
> === modified file 'mc-plugin/mcp-account-manager-ofono.c'
> --- mc-plugin/mcp-account-manager-ofono.c 2015-07-08 20:01:30 +0000
> +++ mc-plugin/mcp-account-manager-ofono.c 2016-03-24 17:12:16 +0000
> @@ -106,11 +106,49 @@
> }
> }
>
> - GSettings *settings = NULL;
> - GSettingsSchemaSource *source = g_settings_schema_source_get_default();
> - if (source != NULL && g_settings_schema_source_lookup(source, "com.ubuntu.phone", TRUE) != NULL) {
> - settings = g_settings_new("com.ubuntu.phone");
> + GHashTable *sim_names = g_hash_table_new(g_str_hash, g_str_equal);
> + char dbus_path[80] = {0};
> + sprintf(dbus_path, "/org/freedesktop/Accounts/User%d", getuid());
> + GError *bus_error = NULL;
> + GDBusConnection *bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &bus_error);
> + if (bus_error) {
> + g_warning("Failed to get system bugs: %s", bus_error->message);
> + g_error_free (bus_error);
> + } else if (bus) {
> + GError *call_error = NULL;
> +
> + /* Retrieve all SimNames from Accounts Service */
> + GVariant *result = g_dbus_connection_call_sync (bus,
> + "org.freedesktop.Accounts",
> + dbus_path,
> + "org.freedesktop.DBus.Properties",
> + "Get",
> + g_variant_new ("(ss)", "com.ubuntu.touch.AccountsService.Phone", "SimNames"),
> + G_VARIANT_TYPE ("(v)"),
> + G_DBUS_CALL_FLAGS_NONE,
> + -1,
> + NULL,
> + &call_error);
> +
> +
> + if (call_error) {
> + g_warning ("Failed to get SimNames property: %s", call_error->message);
> + g_error_free (call_error);
> + } else {
> + GVariantIter *_iter;
> + gchar *key;
> + gchar *value;
> + GVariant *dict;
> + g_variant_get (result, "(v)", &dict);
> + g_variant_get(dict, "a{ss}", &_iter);
> + while (g_variant_iter_loop (_iter, "{ss}", &key, &value)) {
> + g_hash_table_insert(sim_names, g_strdup(key), g_strdup(value));
> + }
> + g_variant_iter_free(_iter);
You need to unref result here too using g_variant_unref().
I'm not sure about the dict variable, but I think you need to unref it too.
> + }
> + g_object_unref(bus);
> }
> +
> for (index = 0; index < num_modems; index++) {
> OfonoAccount *account = (OfonoAccount*)malloc(sizeof(OfonoAccount));
> char account_name[30] = {0};
--
https://code.launchpad.net/~tiagosh/telepathy-ofono/use-accounts-service/+merge/289539
Your team Ubuntu Phablet Team is subscribed to branch lp:telepathy-ofono.
More information about the Ubuntu-reviews
mailing list