void gkd_secret_service_set_alias (GkdSecretService *self, const gchar *alias, const gchar *identifier) { g_return_if_fail (GKD_SECRET_IS_SERVICE (self)); g_return_if_fail (alias); g_hash_table_replace (self->aliases, g_strdup (alias), g_strdup (identifier)); if (g_str_equal (alias, "default")) store_default (self); }
static DBusMessage* service_method_set_alias (GkdSecretService *self, DBusMessage *message) { GP11Object *collection; gchar *identifier; const char *alias; const char *path; if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &alias, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) return NULL; g_return_val_if_fail (alias, NULL); if (!g_str_equal (alias, "default")) return dbus_message_new_error (message, DBUS_ERROR_NOT_SUPPORTED, "Only the 'default' alias is supported"); /* Find a collection with that path */ if (!object_path_has_prefix (path, SECRET_COLLECTION_PREFIX) || !gkd_secret_util_parse_path (path, &identifier, NULL)) return dbus_message_new_error (message, DBUS_ERROR_INVALID_ARGS, "Invalid collection object path"); collection = gkd_secret_objects_lookup_collection (self->objects, dbus_message_get_sender (message), path); if (collection == NULL) { g_free (identifier); return dbus_message_new_error (message, SECRET_ERROR_NO_SUCH_OBJECT, "No such collection exists"); } g_object_unref (collection); gkd_secret_objects_set_alias (self->objects, alias, identifier); g_free (identifier); store_default (self); return dbus_message_new_method_return (message); }