static gboolean service_method_change_with_master_password (GkdExportedInternal *skeleton, GDBusMethodInvocation *invocation, gchar *path, GVariant *original_variant, GVariant *master_variant, GkdSecretService *self) { GkdSecretSecret *original, *master; GckObject *collection; GError *error = NULL; const gchar *sender; sender = g_dbus_method_invocation_get_sender (invocation); /* Parse the incoming message */ original = gkd_secret_secret_parse (self, sender, original_variant, &error); if (original == NULL) { g_dbus_method_invocation_take_error (invocation, error); return TRUE; } master = gkd_secret_secret_parse (self, sender, master_variant, &error); if (master == NULL) { g_dbus_method_invocation_take_error (invocation, error); return TRUE; } /* Make sure we have such a collection */ collection = gkd_secret_objects_lookup_collection (self->objects, sender, path); /* No such collection */ if (collection == NULL) { g_dbus_method_invocation_return_error_literal (invocation, GKD_SECRET_ERROR, GKD_SECRET_ERROR_NO_SUCH_OBJECT, "The collection does not exist"); } /* Success */ else if (gkd_secret_change_with_secrets (collection, NULL, original, master, &error)) gkd_exported_internal_complete_change_with_master_password (skeleton, invocation); /* Failure */ else gkd_secret_propagate_error (invocation, "Couldn't change collection password", error); gkd_secret_secret_free (original); gkd_secret_secret_free (master); if (collection) g_object_unref (collection); return TRUE; }
static DBusMessage* service_method_change_with_master_password (GkdSecretService *self, DBusMessage *message) { DBusError derr = DBUS_ERROR_INIT; GkdSecretSecret *original, *master; GckObject *collection; DBusMessageIter iter; DBusMessage *reply; GError *error = NULL; const gchar *path; /* Parse the incoming message */ if (!dbus_message_has_signature (message, "o(oayays)(oayays)")) return NULL; if (!dbus_message_iter_init (message, &iter)) g_return_val_if_reached (NULL); dbus_message_iter_get_basic (&iter, &path); dbus_message_iter_next (&iter); original = gkd_secret_secret_parse (self, message, &iter, &derr); if (original == NULL) return gkd_secret_error_to_reply (message, &derr); dbus_message_iter_next (&iter); master = gkd_secret_secret_parse (self, message, &iter, &derr); if (master == NULL) { gkd_secret_secret_free (original); return gkd_secret_error_to_reply (message, &derr); } /* Make sure we have such a collection */ collection = gkd_secret_objects_lookup_collection (self->objects, dbus_message_get_sender (message), path); /* No such collection */ if (collection == NULL) reply = dbus_message_new_error (message, SECRET_ERROR_NO_SUCH_OBJECT, "The collection does not exist"); /* Success */ else if (gkd_secret_change_with_secrets (collection, NULL, original, master, &error)) reply = dbus_message_new_method_return (message); /* Failure */ else reply = gkd_secret_propagate_error (message, "Couldn't change collection password", error); gkd_secret_secret_free (original); gkd_secret_secret_free (master); if (collection) g_object_unref (collection); return reply; }