## SecretItem SecretItem — A secret item |

## Synopsis

    #include <secret/secret-unstable.h>

                        SecretItem;
    struct              SecretItemClass;
    void                secret_item_new                     (SecretService *service,
                                                             const gchar *item_path,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    SecretItem *        secret_item_new_finish              (GAsyncResult *result,
                                                             GError **error);
    SecretItem *        secret_item_new_sync                (SecretService *service,
                                                             const gchar *item_path,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                secret_item_create                  (SecretCollection *collection,
                                                             const gchar *label,
                                                             GHashTable *attributes,
                                                             SecretValue *value,
                                                             gboolean replace,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    SecretItem *        secret_item_create_finish           (GAsyncResult *result,
                                                             GError **error);
    SecretItem *        secret_item_create_sync             (SecretCollection *collection,
                                                             const gchar *label,
                                                             GHashTable *attributes,
                                                             SecretValue *value,
                                                             gboolean replace,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                secret_item_delete                  (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            secret_item_delete_finish           (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);
    gboolean            secret_item_delete_sync             (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GError **error);
    GHashTable *        secret_item_get_attributes          (SecretItem *self);
    void                secret_item_set_attributes          (SecretItem *self,
                                                             GHashTable *attributes,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            secret_item_set_attributes_finish   (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);
    gboolean            secret_item_set_attributes_sync     (SecretItem *self,
                                                             GHashTable *attributes,
                                                             GCancellable *cancellable,
                                                             GError **error);
    guint64             secret_item_get_created             (SecretItem *self);
    gchar *             secret_item_get_label               (SecretItem *self);
    void                secret_item_set_label               (SecretItem *self,
                                                             const gchar *label,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            secret_item_set_label_finish        (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);
    gboolean            secret_item_set_label_sync          (SecretItem *self,
                                                             const gchar *label,
                                                             GCancellable *cancellable,
                                                             GError **error);
    gboolean            secret_item_get_locked              (SecretItem *self);
    guint64             secret_item_get_modified            (SecretItem *self);
    void                secret_item_get_secret              (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    SecretValue *       secret_item_get_secret_finish       (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);
    SecretValue *       secret_item_get_secret_sync         (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                secret_item_set_secret              (SecretItem *self,
                                                             SecretValue *value,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            secret_item_set_secret_finish       (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);
    gboolean            secret_item_set_secret_sync         (SecretItem *self,
                                                             SecretValue *value,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                secret_item_refresh                 (SecretItem *self);

## Object Hierarchy

      GObject
       +----GDBusProxy
             +----SecretItem

## Implemented Interfaces

SecretItem implements GDBusInterface, GInitable and GAsyncInitable.

## Properties

      "attributes"               GHashTable*           : Read / Write
      "created"                  guint64               : Read / Write
      "label"                    gchar*                : Read / Write
      "locked"                   gboolean              : Read
      "modified"                 guint64               : Read / Write
      "service"                  SecretService*        : Read / Write / Construct Only

## Description

SecretItem represents a secret item stored in the Secret Service.

Each item has a value, represented by a SecretValue, which can be retrieved by `secret_item_get_secret()` or set by `secret_item_set_secret()`. The item is only available when the item is not locked.

Items can be locked or unlocked using the `secret_service_lock()` or `secret_service_unlock()` functions. The Secret Service may not be able to unlock individual items, and may unlock an entire collection when a single item is unlocked.

Each item has a set of attributes, which are used to locate the item later. These are not stored or transferred in a secure manner. Each attribute has a string name and a string value. Use `secret_service_search()` to search for items based on their attributes, and secret_item_set_attributes to change the attributes associated with an item.

Items can be created with `secret_item_create()` or `secret_service_store()`.

`stability`: Unstable

## Details

### SecretItem

    typedef struct _SecretItem SecretItem;

A proxy object representing a secret item in the Secret Service.

### struct SecretItemClass

    struct SecretItemClass {
    	GDBusProxyClass parent_class;
    };

The class for SecretItem.

GDBusProxyClass `parent_class`; | the parent class

### secret_item_new ()

    void                secret_item_new                     (SecretService *service,
                                                             const gchar *item_path,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Get a new item proxy for a secret item in the secret service.

This method will return immediately and complete asynchronously.

`service` : | a secret service object
`item_path` : | the D-Bus path of the collection
`cancellable` : | optional cancellation object
`callback` : | called when the operation completes
`user_data` : | data to be passed to the callback

### secret_item_new_finish ()

    SecretItem *        secret_item_new_finish              (GAsyncResult *result,
                                                             GError **error);

Finish asynchronous operation to get a new item proxy for an secret item in the secret service.

`result` : | the asynchronous result passed to the callback
`error` : | location to place an error on failure
Returns : | the new item, which should be unreferenced with `g_object_unref()`. [transfer full]

### secret_item_new_sync ()

    SecretItem *        secret_item_new_sync                (SecretService *service,
                                                             const gchar *item_path,
                                                             GCancellable *cancellable,
                                                             GError **error);

Get a new item proxy for a secret item in the secret service.

This method may block indefinitely and should not be used in user interface threads.

`service` : | a secret service object
`item_path` : | the D-Bus path of the item
`cancellable` : | optional cancellation object
`error` : | location to place an error on failure
Returns : | the new item, which should be unreferenced with `g_object_unref()`. [transfer full]

### secret_item_create ()

    void                secret_item_create                  (SecretCollection *collection,
                                                             const gchar *label,
                                                             GHashTable *attributes,
                                                             SecretValue *value,
                                                             gboolean replace,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Create a new item in the secret service.

If the `replace` is set to `TRUE`, then the secret service will search for an item matching the `attributes`, and update that item instead of creating a new one.

This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. `secret_service_prompt()` will be used to handle any prompts that are required.

`collection` : | a secret collection to create this item in
`label` : | label for the new item
`attributes` : | attributes for the new item. [element-type utf8 utf8]
`value` : | secret value for the new item
`replace` : | whether to replace an existing item with the same attributes
`cancellable` : | optional cancellation object
`callback` : | called when the operation completes
`user_data` : | data to pass to the callback

### secret_item_create_finish ()

    SecretItem *        secret_item_create_finish           (GAsyncResult *result,
                                                             GError **error);

Finish operation to create a new item in the secret service.

`result` : | the asynchronous result passed to the callback
`error` : | location to place an error on failure
Returns : | the new item, which should be unreferenced with `g_object_unref()`. [transfer full]

### secret_item_create_sync ()

    SecretItem *        secret_item_create_sync             (SecretCollection *collection,
                                                             const gchar *label,
                                                             GHashTable *attributes,
                                                             SecretValue *value,
                                                             gboolean replace,
                                                             GCancellable *cancellable,
                                                             GError **error);

Create a new item in the secret service.

If the `replace` is set to `TRUE`, then the secret service will search for an item matching the `attributes`, and update that item instead of creating a new one.

This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. `secret_service_prompt()` will be used to handle any prompts that are required.

`collection` : | a secret collection to create this item in
`label` : | label for the new item
`attributes` : | attributes for the new item. [element-type utf8 utf8]
`value` : | secret value for the new item
`replace` : | whether to replace an existing item with the same attributes
`cancellable` : | optional cancellation object
`error` : | location to place an error on failure
Returns : | the new item, which should be unreferenced with `g_object_unref()`. [transfer full]

### secret_item_delete ()

    void                secret_item_delete                  (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

### secret_item_delete_finish ()

    gboolean            secret_item_delete_finish           (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);

Complete asynchronous operation to delete the secret item.

`self` : | an item
`result` : | asynchronous result passed to the callback
`error` : | location to place an error on failure
Returns : | whether the item was successfully deleted or not

### secret_item_delete_sync ()

    gboolean            secret_item_delete_sync             (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GError **error);

Delete this secret item.

This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. `secret_service_prompt()` will be used to handle any prompts that show up.

`self` : | an item
`cancellable` : | optional cancellation object
`error` : | location to place an error on failure
Returns : | whether the item was successfully deleted or not

### secret_item_get_attributes ()

    GHashTable *        secret_item_get_attributes          (SecretItem *self);

Set the attributes of this item.

The `attributes` are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

Do not modify the attributes returned by this method. Use `secret_item_set_attributes()` instead.

`self` : | an item
Returns : | a new reference to the attributes, which should not be modified, and released with `g_hash_table_unref()`. [transfer full]

### secret_item_set_attributes ()

    void                secret_item_set_attributes          (SecretItem *self,
                                                             GHashTable *attributes,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Set the attributes of this item.

The `attributes` are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

This function returns immediately and completes asynchronously.

`self` : | an item
`attributes` : | a new set of attributes. [element-type utf8 utf8]
`cancellable` : | optional cancellation object
`callback` : | called when the asynchronous operation completes
`user_data` : | data to pass to the callback

### secret_item_set_attributes_finish ()

    gboolean            secret_item_set_attributes_finish   (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);

Complete operation to set the attributes of this item.

`self` : | an item
`result` : | asynchronous result passed to the callback
`error` : | location to place error on failure
Returns : | whether the change was successful or not

### secret_item_set_attributes_sync ()

    gboolean            secret_item_set_attributes_sync     (SecretItem *self,
                                                             GHashTable *attributes,
                                                             GCancellable *cancellable,
                                                             GError **error);

Set the attributes of this item.

The `attributes` are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

This function may block indefinetely. Use the asynchronous version in user interface threads.

`self` : | an item
`attributes` : | a new set of attributes. [element-type utf8 utf8]
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | whether the change was successful or not

### secret_item_get_created ()

    guint64             secret_item_get_created             (SecretItem *self);

Get the created date and time of the item. The return value is the number of seconds since the unix epoch, January 1st 1970.

`self` : | an item
Returns : | the created date and time

### secret_item_get_label ()

    gchar *             secret_item_get_label               (SecretItem *self);

Get the label of this item.

`self` : | an item
Returns : | the label, which should be freed with `g_free()`. [transfer full]

### secret_item_set_label ()

    void                secret_item_set_label               (SecretItem *self,
                                                             const gchar *label,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Set the label of this item.

This function returns immediately and completes asynchronously.

`self` : | an item
`label` : | a new label
`cancellable` : | optional cancellation object
`callback` : | called when the operation completes
`user_data` : | data to pass to the callback

### secret_item_set_label_finish ()

    gboolean            secret_item_set_label_finish        (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);

Complete asynchronous operation to set the label of this collection.

`self` : | an item
`result` : | asynchronous result passed to callback
`error` : | location to place error on failure
Returns : | whether the change was successful or not

### secret_item_set_label_sync ()

    gboolean            secret_item_set_label_sync          (SecretItem *self,
                                                             const gchar *label,
                                                             GCancellable *cancellable,
                                                             GError **error);

Set the label of this item.

This function may block indefinetely. Use the asynchronous version in user interface threads.

`self` : | an item
`label` : | a new label
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | whether the change was successful or not

### secret_item_get_locked ()

    gboolean            secret_item_get_locked              (SecretItem *self);

Get whether the item is locked or not.

Depending on the secret service an item may not be able to be locked independently from the collection that it is in.

`self` : | an item
Returns : | whether the item is locked or not

### secret_item_get_modified ()

    guint64             secret_item_get_modified            (SecretItem *self);

Get the modified date and time of the item. The return value is the number of seconds since the unix epoch, January 1st 1970.

`self` : | an item
Returns : | the modified date and time

### secret_item_get_secret ()

    void                secret_item_get_secret              (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Get the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function returns immediately and completes asynchronously.

`self` : | an item
`cancellable` : | optional cancellation object
`callback` : | called when the operation completes
`user_data` : | data to pass to the callback

### secret_item_get_secret_finish ()

    SecretValue *       secret_item_get_secret_finish       (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);

Get the secret value of this item.

Complete asynchronous operation to get the secret value of this item.

`self` : | an item
`result` : | asynchronous result passed to callback
`error` : | location to place error on failure
Returns : | the newly allocated secret value in this item, which should be released with `secret_value_unref()`. [transfer full]

### secret_item_get_secret_sync ()

    SecretValue *       secret_item_get_secret_sync         (SecretItem *self,
                                                             GCancellable *cancellable,
                                                             GError **error);

Get the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function may block indefinetely. Use the asynchronous version in user interface threads.

`self` : | an item
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | the newly allocated secret value in this item, which should be released with `secret_value_unref()`. [transfer full]

### secret_item_set_secret ()

    void                secret_item_set_secret              (SecretItem *self,
                                                             SecretValue *value,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Set the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function returns immediately and completes asynchronously.

`self` : | an item
`value` : | a new secret value
`cancellable` : | optional cancellation object
`callback` : | called when the operation completes
`user_data` : | data to pass to the callback

### secret_item_set_secret_finish ()

    gboolean            secret_item_set_secret_finish       (SecretItem *self,
                                                             GAsyncResult *result,
                                                             GError **error);

Complete asynchronous operation to set the secret value of this item.

`self` : | an item
`result` : | asynchronous result passed to callback
`error` : | location to place error on failure
Returns : | whether the change was successful or not

### secret_item_set_secret_sync ()

    gboolean            secret_item_set_secret_sync         (SecretItem *self,
                                                             SecretValue *value,
                                                             GCancellable *cancellable,
                                                             GError **error);

Set the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function may block indefinetely. Use the asynchronous version in user interface threads.

`self` : | an item
`value` : | a new secret value
`cancellable` : | optional cancellation object
`error` : | location to place error on failure
Returns : | whether the change was successful or not

### secret_item_refresh ()

    void                secret_item_refresh                 (SecretItem *self);

Refresh the properties on this item. This fires off a request to refresh, and the properties will be updated later.

Calling this method is not normally necessary, as the secret service will notify the client when properties change.

`self` : | the collection

## Property Details

### The `"attributes"` property

      "attributes"               GHashTable*           : Read / Write

The attributes set on this item. Attributes are used to locate an item. They are not guaranteed to be stored or transferred securely.

### The `"created"` property

      "created"                  guint64               : Read / Write

The date and time (in seconds since the UNIX epoch) that this item was created.

Default value: 0

### The `"label"` property

      "label"                    gchar*                : Read / Write

The human readable label for the item.

Setting this property will result in the label of the item being set asynchronously. To properly track the changing of the label use the `secret_item_set_label()` function.

Default value: NULL

### The `"locked"` property

      "locked"                   gboolean              : Read

Whether the item is locked or not. An item may not be independently lockable separate from other items in its collection.

To lock or unlock a item use the `secret_service_lock()` or `secret_service_unlock()` functions.

Default value: TRUE

### The `"modified"` property

      "modified"                 guint64               : Read / Write

The date and time (in seconds since the UNIX epoch) that this item was last modified.

Default value: 0

### The `"service"` property

      "service"                  SecretService*        : Read / Write / Construct Only

The SecretService object that this item is associated with and uses to interact with the actual D-Bus Secret Service.