1 /* libsecret - GLib wrapper for Secret Service 2 * 3 * Copyright 2012 Red Hat Inc. 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public License as published 7 * by the Free Software Foundation; either version 2.1 of the licence or (at 8 * your option) any later version. 9 * 10 * See the included COPYING file for more information. 11 * 12 * Author: Stef Walter <stefw@gnome.org> 13 */ 14 15 #if !defined (__SECRET_INSIDE_HEADER__) && !defined (SECRET_COMPILATION) 16 #error "Only <libsecret/secret.h> can be included directly." 17 #endif 18 19 #ifndef __SECRET_ITEM_H__ 20 #define __SECRET_ITEM_H__ 21 22 #include <gio/gio.h> 23 24 #include "secret-collection.h" 25 #include "secret-item.h" 26 #include "secret-service.h" 27 #include "secret-value.h" 28 29 G_BEGIN_DECLS 30 31 typedef enum { 32 SECRET_ITEM_NONE, 33 SECRET_ITEM_LOAD_SECRET = 1 << 1 34 } SecretItemFlags; 35 36 typedef enum { 37 SECRET_ITEM_CREATE_NONE = 0, 38 SECRET_ITEM_CREATE_REPLACE = 1 << 1 39 } SecretItemCreateFlags; 40 41 #define SECRET_TYPE_ITEM (secret_item_get_type ()) 42 #define SECRET_ITEM(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), SECRET_TYPE_ITEM, SecretItem)) 43 #define SECRET_ITEM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), SECRET_TYPE_ITEM, SecretItemClass)) 44 #define SECRET_IS_ITEM(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), SECRET_TYPE_ITEM)) 45 #define SECRET_IS_ITEM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), SECRET_TYPE_ITEM)) 46 #define SECRET_ITEM_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), SECRET_TYPE_ITEM, SecretItemClass)) 47 48 typedef struct _SecretItemClass SecretItemClass; 49 typedef struct _SecretItemPrivate SecretItemPrivate; 50 51 struct _SecretItem { 52 GDBusProxy parent_instance; 53 54 /*< private >*/ 55 SecretItemPrivate *pv; 56 }; 57 58 struct _SecretItemClass { 59 GDBusProxyClass parent_class; 60 61 /*< private >*/ 62 gpointer padding[4]; 63 }; 64 65 GType secret_item_get_type (void) G_GNUC_CONST; 66 67 void secret_item_refresh (SecretItem *self); 68 69 void secret_item_create (SecretCollection *collection, 70 const SecretSchema *schema, 71 GHashTable *attributes, 72 const gchar *label, 73 SecretValue *value, 74 SecretItemCreateFlags flags, 75 GCancellable *cancellable, 76 GAsyncReadyCallback callback, 77 gpointer user_data); 78 79 SecretItem * secret_item_create_finish (GAsyncResult *result, 80 GError **error); 81 82 SecretItem * secret_item_create_sync (SecretCollection *collection, 83 const SecretSchema *schema, 84 GHashTable *attributes, 85 const gchar *label, 86 SecretValue *value, 87 SecretItemCreateFlags flags, 88 GCancellable *cancellable, 89 GError **error); 90 91 void secret_item_delete (SecretItem *self, 92 GCancellable *cancellable, 93 GAsyncReadyCallback callback, 94 gpointer user_data); 95 96 gboolean secret_item_delete_finish (SecretItem *self, 97 GAsyncResult *result, 98 GError **error); 99 100 gboolean secret_item_delete_sync (SecretItem *self, 101 GCancellable *cancellable, 102 GError **error); 103 104 SecretItemFlags secret_item_get_flags (SecretItem *self); 105 106 SecretService * secret_item_get_service (SecretItem *self); 107 108 SecretValue * secret_item_get_secret (SecretItem *self); 109 110 void secret_item_load_secret (SecretItem *self, 111 GCancellable *cancellable, 112 GAsyncReadyCallback callback, 113 gpointer user_data); 114 115 gboolean secret_item_load_secret_finish (SecretItem *self, 116 GAsyncResult *result, 117 GError **error); 118 119 gboolean secret_item_load_secret_sync (SecretItem *self, 120 GCancellable *cancellable, 121 GError **error); 122 123 void secret_item_load_secrets (GList *items, 124 GCancellable *cancellable, 125 GAsyncReadyCallback callback, 126 gpointer user_data); 127 128 gboolean secret_item_load_secrets_finish (GAsyncResult *result, 129 GError **error); 130 131 gboolean secret_item_load_secrets_sync (GList *items, 132 GCancellable *cancellable, 133 GError **error); 134 135 void secret_item_set_secret (SecretItem *self, 136 SecretValue *value, 137 GCancellable *cancellable, 138 GAsyncReadyCallback callback, 139 gpointer user_data); 140 141 gboolean secret_item_set_secret_finish (SecretItem *self, 142 GAsyncResult *result, 143 GError **error); 144 145 gboolean secret_item_set_secret_sync (SecretItem *self, 146 SecretValue *value, 147 GCancellable *cancellable, 148 GError **error); 149 150 gchar * secret_item_get_schema_name (SecretItem *self); 151 152 GHashTable* secret_item_get_attributes (SecretItem *self); 153 154 void secret_item_set_attributes (SecretItem *self, 155 const SecretSchema *schema, 156 GHashTable *attributes, 157 GCancellable *cancellable, 158 GAsyncReadyCallback callback, 159 gpointer user_data); 160 161 gboolean secret_item_set_attributes_finish (SecretItem *self, 162 GAsyncResult *result, 163 GError **error); 164 165 gboolean secret_item_set_attributes_sync (SecretItem *self, 166 const SecretSchema *schema, 167 GHashTable *attributes, 168 GCancellable *cancellable, 169 GError **error); 170 171 gchar * secret_item_get_label (SecretItem *self); 172 173 void secret_item_set_label (SecretItem *self, 174 const gchar *label, 175 GCancellable *cancellable, 176 GAsyncReadyCallback callback, 177 gpointer user_data); 178 179 gboolean secret_item_set_label_finish (SecretItem *self, 180 GAsyncResult *result, 181 GError **error); 182 183 gboolean secret_item_set_label_sync (SecretItem *self, 184 const gchar *label, 185 GCancellable *cancellable, 186 GError **error); 187 188 gboolean secret_item_get_locked (SecretItem *self); 189 190 guint64 secret_item_get_created (SecretItem *self); 191 192 guint64 secret_item_get_modified (SecretItem *self); 193 194 G_END_DECLS 195 196 #endif /* __SECRET_ITEM_H___ */ 197