1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* gkr-keyring.h - represents a keyring in memory, and functionality save/load
Copyright (C) 2007 Stefan Walter
The Gnome Keyring Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Keyring Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Stef Walter <stef@memberwebs.com>
*/
#ifndef __GKR_KEYRING_H__
#define __GKR_KEYRING_H__
/*
* TODO: The internals of a GkrKeyring should probably be further
* abstracted away and accessed via accessor methods and properties.
*/
#include <glib-object.h>
#include "gkr-keyring-item.h"
#include "egg/egg-buffer.h"
#include "library/gnome-keyring.h"
#include "ui/gkr-ask-request.h"
G_BEGIN_DECLS
#define GKR_TYPE_KEYRING (gkr_keyring_get_type())
#define GKR_KEYRING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GKR_TYPE_KEYRING, GkrKeyring))
#define GKR_KEYRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GKR_TYPE_KEYRING, GObject))
#define GKR_IS_KEYRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GKR_TYPE_KEYRING))
#define GKR_IS_KEYRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GKR_TYPE_KEYRING))
#define GKR_KEYRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GKR_TYPE_KEYRING, GkrKeyringClass))
typedef struct _GkrKeyringClass GkrKeyringClass;
struct _GkrKeyring {
GObject parent;
/* NULL if memory only */
GQuark location;
/* If known: */
char *password;
gboolean locked;
gboolean asking_password;
/* Whether the salt and hash_iterations members are populated */
gboolean salt_valid;
/* On disk data: */
guchar salt[8];
guint32 hash_iterations;
char *keyring_name;
GList *items;
time_t ctime;
time_t mtime;
gboolean lock_on_idle;
guint lock_timeout;
};
struct _GkrKeyringClass {
GObjectClass parent_class;
void (*item_added) (GkrKeyring* keyring, GkrKeyringItem* item);
void (*item_removed) (GkrKeyring* keyring, GkrKeyringItem* item);
};
GType gkr_keyring_get_type (void) G_GNUC_CONST;
GkrKeyring* gkr_keyring_new (const gchar* name, GQuark location);
GkrKeyring* gkr_keyring_create (GQuark volume, const gchar* name, const gchar* password);
guint gkr_keyring_get_new_id (GkrKeyring *keyring);
GkrKeyringItem* gkr_keyring_get_item (GkrKeyring *keyring, guint id);
GkrKeyringItem* gkr_keyring_find_item (GkrKeyring *keyring, GnomeKeyringItemType type,
GnomeKeyringAttributeList *attrs, gboolean match_all);
void gkr_keyring_add_item (GkrKeyring* keyring, GkrKeyringItem* item);
void gkr_keyring_remove_item (GkrKeyring* keyring, GkrKeyringItem* item);
gboolean gkr_keyring_update_from_disk (GkrKeyring *keyring);
gboolean gkr_keyring_remove_from_disk (GkrKeyring *keyring);
gboolean gkr_keyring_save_to_disk (GkrKeyring *keyring);
gboolean gkr_keyring_lock (GkrKeyring *keyring);
gboolean gkr_keyring_unlock (GkrKeyring *keyring, const gchar *password);
void gkr_keyrings_set_item (GkrKeyring *keyring, GnomeKeyringItemType type,
const gchar *display_name, const gchar *secret,
GnomeKeyringAttributeList *attrs);
gboolean gkr_keyring_is_insecure (GkrKeyring *keyring);
/* Used with the check-request signal on GkrAskRequest to unlock a keyring */
gboolean gkr_keyring_ask_check_unlock (GkrAskRequest* ask);
/* -----------------------------------------------------------------------------
* FILE FORMATS
*
* gint return value:
* -1 : error
* 0 : unrecognized
* 1 : successful
*/
gboolean gkr_keyring_textual_generate (GkrKeyring *keyring, EggBuffer *buffer);
gboolean gkr_keyring_binary_generate (GkrKeyring *keyring, EggBuffer *buffer);
gint gkr_keyring_textual_parse (GkrKeyring *keyring, EggBuffer *buffer);
gint gkr_keyring_binary_parse (GkrKeyring *keyring, EggBuffer *buffer);
G_END_DECLS
#endif /* __GKR_KEYRING_H__ */
|