| 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 |
gkm_secret_compat_access_free (gpointer data) |
| 29 |
{ |
| 30 |
GkmSecretAccess *ac = data; |
| 31 |
if (ac) { |
| 32 |
g_free (ac->display_name); |
| 33 |
g_free (ac->pathname); |
| 34 |
g_free (ac); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
void |
| 39 |
gkm_secret_compat_acl_free (gpointer acl) |
| 40 |
{ |
| 41 |
GList *l; |
| 42 |
for (l = acl; l; l = g_list_next (l)) |
| 43 |
gkm_secret_compat_access_free (l->data); |
| 44 |
g_list_free (acl); |
| 45 |
} |
| 46 |
|
| 47 |
guint |
| 48 |
gkm_secret_compat_parse_item_type (const gchar *value) |
| 49 |
{ |
| 50 |
if (value == NULL) |
| 51 |
return 0; /* The default */ |
| 52 |
if (strcmp (value, "org.freedesktop.Secret.Generic") == 0) |
| 53 |
return 0; /* GNOME_KEYRING_ITEM_GENERIC_SECRET */ |
| 54 |
if (strcmp (value, "org.gnome.keyring.NetworkPassword") == 0) |
| 55 |
return 1; /* GNOME_KEYRING_ITEM_NETWORK_PASSWORD */ |
| 56 |
if (strcmp (value, "org.gnome.keyring.Note") == 0) |
| 57 |
return 2; /* GNOME_KEYRING_ITEM_NOTE */ |
| 58 |
if (strcmp (value, "org.gnome.keyring.ChainedKeyring") == 0) |
| 59 |
return 3; /* GNOME_KEYRING_ITEM_CHAINED_KEYRING_PASSWORD */ |
| 60 |
if (strcmp (value, "org.gnome.keyring.EncryptionKey") == 0) |
| 61 |
return 4; /* GNOME_KEYRING_ITEM_ENCRYPTION_KEY_PASSWORD */ |
| 62 |
if (strcmp (value, "org.gnome.keyring.PkStorage") == 0) |
| 63 |
return 0x100; /* GNOME_KEYRING_ITEM_PK_STORAGE */ |
| 64 |
|
| 65 |
/* The default: GNOME_KEYRING_ITEM_GENERIC_SECRET */ |
| 66 |
return 0; |
| 67 |
} |
| 68 |
|
| 69 |
const gchar* |
| 70 |
gkm_secret_compat_format_item_type (guint value) |
| 71 |
{ |
| 72 |
/* Only GNOME_KEYRING_ITEM_TYPE_MASK */ |
| 73 |
switch (value & 0x0000ffff) |
| 74 |
{ |
| 75 |
case 0: /* GNOME_KEYRING_ITEM_GENERIC_SECRET */ |
| 76 |
return "org.freedesktop.Secret.Generic"; |
| 77 |
case 1: /* GNOME_KEYRING_ITEM_NETWORK_PASSWORD */ |
| 78 |
return "org.gnome.keyring.NetworkPassword"; |
| 79 |
case 2: /* GNOME_KEYRING_ITEM_NOTE */ |
| 80 |
return "org.gnome.keyring.Note"; |
| 81 |
case 3: /* GNOME_KEYRING_ITEM_CHAINED_KEYRING_PASSWORD */ |
| 82 |
return "org.gnome.keyring.ChainedKeyring"; |
| 83 |
case 4: /* GNOME_KEYRING_ITEM_ENCRYPTION_KEY_PASSWORD */ |
| 84 |
return "org.gnome.keyring.EncryptionKey"; |
| 85 |
case 0x100: /* GNOME_KEYRING_ITEM_PK_STORAGE */ |
| 86 |
return "org.gnome.keyring.PkStorage"; |
| 87 |
default: |
| 88 |
return NULL; |
| 89 |
}; |
| 90 |
} |