WIP schemas

This commit is contained in:
Stef Walter 2012-03-18 13:45:54 +01:00
parent 966c1da87b
commit 65969cf82e
4 changed files with 67 additions and 46 deletions

View File

@ -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 = &note_schema;
static SecretSchemaAttribute *
schema_attribute_copy (SecretSchemaAttribute *attribute)
{

View File

@ -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,

31
library/secret-schemas.c Normal file
View File

@ -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;

35
library/secret-schemas.h Normal file
View File

@ -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 <secret/secret.h> can be included directly."
#endif
#ifndef __SECRET_SCHEMAS_H__
#define __SECRET_SCHEMAS_H__
#include <glib.h>
#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___ */