From 65969cf82ef3082bff5d721a90cf60f61a3a36e3 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sun, 18 Mar 2012 13:45:54 +0100 Subject: [PATCH] WIP schemas --- library/secret-schema.c | 36 ------------------------------------ library/secret-schema.h | 11 +---------- library/secret-schemas.c | 31 +++++++++++++++++++++++++++++++ library/secret-schemas.h | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 46 deletions(-) create mode 100644 library/secret-schemas.c create mode 100644 library/secret-schemas.h diff --git a/library/secret-schema.c b/library/secret-schema.c index d95b715..68cc7a4 100644 --- a/library/secret-schema.c +++ b/library/secret-schema.c @@ -83,42 +83,6 @@ * to store integer and boolean values as strings. */ -static const SecretSchema network_schema = { - SECRET_SCHEMA_IDENTIFIER_NETWORK, - SECRET_SCHEMA_NONE, - { - { "user", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "domain", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "object", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "protocol", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "port", SECRET_SCHEMA_ATTRIBUTE_INTEGER }, - { "server", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "NULL", 0 }, - } -}; - -const SecretSchema * SECRET_SCHEMA_NETWORK = &network_schema; - -static const SecretSchema generic_schema = { - SECRET_SCHEMA_IDENTIFIER_GENERIC, - SECRET_SCHEMA_ALLOW_UNDEFINED, - { - { "NULL", 0 }, - } -}; - -const SecretSchema * SECRET_SCHEMA_GENERIC = &generic_schema; - -static const SecretSchema note_schema = { - SECRET_SCHEMA_IDENTIFIER_NOTE, - SECRET_SCHEMA_ALLOW_UNDEFINED, - { - { "NULL", 0 }, - } -}; - -const SecretSchema * SECRET_SCHEMA_NOTE = ¬e_schema; - static SecretSchemaAttribute * schema_attribute_copy (SecretSchemaAttribute *attribute) { diff --git a/library/secret-schema.h b/library/secret-schema.h index 1473d69..3bf7ab4 100644 --- a/library/secret-schema.h +++ b/library/secret-schema.h @@ -21,10 +21,6 @@ G_BEGIN_DECLS -#define SECRET_SCHEMA_IDENTIFIER_GENERIC "org.freedesktop.Secret.Generic" -#define SECRET_SCHEMA_IDENTIFIER_NETWORK "org.gnome.keyring.NetworkPassword" -#define SECRET_SCHEMA_IDENTIFIER_NOTE "org.gnome.keyring.Note" - typedef enum { SECRET_SCHEMA_ATTRIBUTE_STRING = 0, SECRET_SCHEMA_ATTRIBUTE_INTEGER = 1, @@ -39,6 +35,7 @@ typedef struct { typedef enum { SECRET_SCHEMA_NONE = 0, SECRET_SCHEMA_ALLOW_UNDEFINED = 1 << 0, + SECRET_SCHEMA_IGNORE_IDENTIFIER = 1 << 1 } SecretSchemaFlags; typedef struct { @@ -57,12 +54,6 @@ typedef struct { gpointer reserved7; } SecretSchema; -extern const SecretSchema * SECRET_SCHEMA_NETWORK; - -extern const SecretSchema * SECRET_SCHEMA_GENERIC; - -extern const SecretSchema * SECRET_SCHEMA_NOTE; - GType secret_schema_get_type (void) G_GNUC_CONST; SecretSchema * secret_schema_new (const gchar *identifier, diff --git a/library/secret-schemas.c b/library/secret-schemas.c new file mode 100644 index 0000000..ad6056b --- /dev/null +++ b/library/secret-schemas.c @@ -0,0 +1,31 @@ +/* libsecret - GLib wrapper for Secret Service + * + * Copyright 2012 Stef Walter + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the licence or (at + * your option) any later version. + * + * See the included COPYING file for more information. + */ + +#include "config.h" + +#include "secret-schema.h" + +static const SecretSchema network_schema = { + "org.gnome.keyring.NetworkPassword", + SECRET_SCHEMA_NONE, + { + { "user", SECRET_SCHEMA_ATTRIBUTE_STRING }, + { "domain", SECRET_SCHEMA_ATTRIBUTE_STRING }, + { "object", SECRET_SCHEMA_ATTRIBUTE_STRING }, + { "protocol", SECRET_SCHEMA_ATTRIBUTE_STRING }, + { "port", SECRET_SCHEMA_ATTRIBUTE_INTEGER }, + { "server", SECRET_SCHEMA_ATTRIBUTE_STRING }, + { "NULL", 0 }, + } +}; + +const SecretSchema * SECRET_SCHEMA_COMPAT_NETWORK = &network_schema; diff --git a/library/secret-schemas.h b/library/secret-schemas.h new file mode 100644 index 0000000..2eb55fc --- /dev/null +++ b/library/secret-schemas.h @@ -0,0 +1,35 @@ +/* libsecret - GLib wrapper for Secret Service + * + * Copyright 2012 Stef Walter + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the licence or (at + * your option) any later version. + * + * See the included COPYING file for more information. + */ + +#if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __SECRET_SCHEMAS_H__ +#define __SECRET_SCHEMAS_H__ + +#include + +#include "secret-schema.h" + +G_BEGIN_DECLS + +/* + * This schema is here for compatibility with libgnome-keyring's network + * password functions. + */ + +extern const SecretSchema * SECRET_SCHEMA_COMPAT_NETWORK; + +G_END_DECLS + +#endif /* __SECRET_SCHEMAS_H___ */