static DBusMessage* service_method_unlock (GkdSecretService *self, DBusMessage *message) { GkdSecretUnlock *unlock; ServiceClient *client; DBusMessage *reply; const char *caller; const gchar *path; int n_objpaths, i; char **objpaths; if (!dbus_message_get_args (message, NULL, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &objpaths, &n_objpaths, DBUS_TYPE_INVALID)) return NULL; caller = dbus_message_get_sender (message); unlock = gkd_secret_unlock_new (self, caller); for (i = 0; i < n_objpaths; ++i) gkd_secret_unlock_queue (unlock, objpaths[i]); dbus_free_string_array (objpaths); /* So do we need to prompt? */ if (gkd_secret_unlock_have_queued (unlock)) { client = g_hash_table_lookup (self->clients, caller); g_return_val_if_fail (client, NULL); path = gkd_secret_dispatch_get_object_path (GKD_SECRET_DISPATCH (unlock)); g_hash_table_replace (client->prompts, (gpointer)path, g_object_ref (unlock)); /* No need to prompt */ } else { path = "/"; } reply = dbus_message_new_method_return (message); objpaths = gkd_secret_unlock_get_results (unlock, &n_objpaths); dbus_message_append_args (reply, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &objpaths, n_objpaths, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID); gkd_secret_unlock_reset_results (unlock); g_object_unref (unlock); return reply; }
static gboolean service_method_unlock (GkdExportedService *skeleton, GDBusMethodInvocation *invocation, gchar **objpaths, GkdSecretService *self) { GkdSecretUnlock *unlock; const char *caller; const gchar *path; int i, n_unlocked; gchar **unlocked; caller = g_dbus_method_invocation_get_sender (invocation); unlock = gkd_secret_unlock_new (self, caller, NULL); for (i = 0; objpaths[i] != NULL; ++i) gkd_secret_unlock_queue (unlock, objpaths[i]); /* So do we need to prompt? */ if (gkd_secret_unlock_have_queued (unlock)) { gkd_secret_service_publish_dispatch (self, caller, GKD_SECRET_DISPATCH (unlock)); path = gkd_secret_dispatch_get_object_path (GKD_SECRET_DISPATCH (unlock)); /* No need to prompt */ } else { path = "/"; } unlocked = gkd_secret_unlock_get_results (unlock, &n_unlocked); gkd_exported_service_complete_unlock (skeleton, invocation, (const gchar **) unlocked, path); gkd_secret_unlock_reset_results (unlock); g_object_unref (unlock); return TRUE; }