Line data Source code
1 : /*
2 : * gnome-keyring
3 : *
4 : * Copyright (C) 2009 Stefan Walter
5 : *
6 : * This program is free software; you can redistribute it and/or modify
7 : * it under the terms of the GNU Lesser General Public License as
8 : * published by the Free Software Foundation; either version 2.1 of
9 : * the License, or (at your option) any later version.
10 : *
11 : * This program is distributed in the hope that it will be useful, but
12 : * WITHOUT ANY WARRANTY; without even the implied warranty of
13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : * Lesser General Public License for more details.
15 : *
16 : * You should have received a copy of the GNU Lesser General Public
17 : * License along with this program; if not, see
18 : * <http://www.gnu.org/licenses/>.
19 : */
20 :
21 : #include "config.h"
22 :
23 : #include "gkm-secret-compat.h"
24 :
25 : #include <string.h>
26 :
27 : void
28 71 : gkm_secret_compat_access_free (gpointer data)
29 : {
30 71 : GkmSecretAccess *ac = data;
31 71 : if (ac) {
32 71 : g_free (ac->display_name);
33 71 : g_free (ac->pathname);
34 71 : g_free (ac);
35 : }
36 71 : }
37 :
38 : void
39 186 : gkm_secret_compat_acl_free (gpointer acl)
40 : {
41 : GList *l;
42 256 : for (l = acl; l; l = g_list_next (l))
43 70 : gkm_secret_compat_access_free (l->data);
44 186 : g_list_free (acl);
45 186 : }
46 :
47 : guint
48 32 : gkm_secret_compat_parse_item_type (const gchar *value)
49 : {
50 32 : if (value == NULL)
51 15 : return 0; /* The default */
52 17 : if (strcmp (value, "org.freedesktop.Secret.Generic") == 0)
53 11 : return 0; /* GNOME_KEYRING_ITEM_GENERIC_SECRET */
54 6 : if (strcmp (value, "org.gnome.keyring.NetworkPassword") == 0)
55 1 : return 1; /* GNOME_KEYRING_ITEM_NETWORK_PASSWORD */
56 5 : if (strcmp (value, "org.gnome.keyring.Note") == 0)
57 1 : return 2; /* GNOME_KEYRING_ITEM_NOTE */
58 4 : if (strcmp (value, "org.gnome.keyring.ChainedKeyring") == 0)
59 1 : return 3; /* GNOME_KEYRING_ITEM_CHAINED_KEYRING_PASSWORD */
60 3 : if (strcmp (value, "org.gnome.keyring.EncryptionKey") == 0)
61 1 : return 4; /* GNOME_KEYRING_ITEM_ENCRYPTION_KEY_PASSWORD */
62 2 : if (strcmp (value, "org.gnome.keyring.PkStorage") == 0)
63 1 : return 0x100; /* GNOME_KEYRING_ITEM_PK_STORAGE */
64 :
65 : /* The default: GNOME_KEYRING_ITEM_GENERIC_SECRET */
66 1 : return 0;
67 : }
68 :
69 : const gchar*
70 173 : gkm_secret_compat_format_item_type (guint value)
71 : {
72 : /* Only GNOME_KEYRING_ITEM_TYPE_MASK */
73 173 : switch (value & 0x0000ffff)
74 : {
75 148 : case 0: /* GNOME_KEYRING_ITEM_GENERIC_SECRET */
76 148 : return "org.freedesktop.Secret.Generic";
77 11 : case 1: /* GNOME_KEYRING_ITEM_NETWORK_PASSWORD */
78 11 : return "org.gnome.keyring.NetworkPassword";
79 10 : case 2: /* GNOME_KEYRING_ITEM_NOTE */
80 10 : return "org.gnome.keyring.Note";
81 1 : case 3: /* GNOME_KEYRING_ITEM_CHAINED_KEYRING_PASSWORD */
82 1 : return "org.gnome.keyring.ChainedKeyring";
83 1 : case 4: /* GNOME_KEYRING_ITEM_ENCRYPTION_KEY_PASSWORD */
84 1 : return "org.gnome.keyring.EncryptionKey";
85 1 : case 0x100: /* GNOME_KEYRING_ITEM_PK_STORAGE */
86 1 : return "org.gnome.keyring.PkStorage";
87 1 : default:
88 1 : return NULL;
89 : };
90 : }
|