GcrImporter

## GcrImporter GcrImporter — Import objects into PKCS#11 slots. |

## Synopsis

    struct              GcrImporter;
    struct              GcrImporterClass;
    enum                GcrImporterPromptBehavior;
    GcrImporter *       gcr_importer_new                    (void);
    void                gcr_importer_listen                 (GcrImporter *self,
                                                             GcrParser *parser);
    void                gcr_importer_queue                  (GcrImporter *self,
                                                             const gchar *label,
                                                             GckAttributes *attrs);
    gboolean            gcr_importer_import                 (GcrImporter *self,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                gcr_importer_import_async           (GcrImporter *self,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            gcr_importer_import_finish          (GcrImporter *self,
                                                             GAsyncResult *result,
                                                             GError **error);
    GckSlot *           gcr_importer_get_slot               (GcrImporter *self);
    void                gcr_importer_set_slot               (GcrImporter *self,
                                                             GckSlot *slot);
    GcrImporterPromptBehavior gcr_importer_get_prompt_behavior
                                                            (GcrImporter *self);
    void                gcr_importer_set_prompt_behavior    (GcrImporter *self,
                                                             GcrImporterPromptBehavior behavior);
    GcrParser *         gcr_importer_get_parser             (GcrImporter *self);
    void                gcr_importer_set_parser             (GcrImporter *self,
                                                             GcrParser *parser);

## Object Hierarchy

      GObject
       +----GcrImporter

## Implemented Interfaces

GcrImporter implements GAsyncResult.

## Properties

      "prompt-behavior"          gint                  : Read / Write
      "slot"                     GckSlot*              : Read / Write

## Signals

      "imported"                                       : Run First
      "queued"                                         : Run First

## Description

A GcrImporter can be used to import items into PKCS#11 slots. It's most often used to parse the objects parsed with a GcrParser. Use `gcr_importer_listen()` to hook up the importer to the parser.

Items are queued, and then imported with `gcr_importer_import()` or `gcr_importer_import_async()`.

## Details

### struct GcrImporter

    struct GcrImporter;

Imports items into PKCS#11

### struct GcrImporterClass

    struct GcrImporterClass {
    	GObjectClass parent_class;

    	/* signals */
    	void (*queued) (GcrImporter *self, const gchar *label, GckAttributes *attrs);
    	void (*imported) (GcrImporter *self, GckObject *object);
    };

The class for GcrImporter.

GObjectClass `parent_class`; | The parent class
`queued` () | Signal which is fired when an item is queued
`imported` () | Signal which is fired when an item is imported

### enum GcrImporterPromptBehavior

    typedef enum {
    	GCR_IMPORTER_PROMPT_NEEDED,
    	GCR_IMPORTER_PROMPT_ALWAYS,
    	GCR_IMPORTER_PROMPT_NEVER
    } GcrImporterPromptBehavior;

Flags for the prompting behavior of GcrImporter.

`GCR_IMPORTER_PROMPT_NEEDED` | Prompt when needed.
`GCR_IMPORTER_PROMPT_ALWAYS` | Always prompt.
`GCR_IMPORTER_PROMPT_NEVER` | Never prompt.

### gcr_importer_new ()

    GcrImporter *       gcr_importer_new                    (void);

Create a new GcrImporter.

Returns : | A newly allocated importer, which should be released with `g_object_unref()`.

### gcr_importer_listen ()

    void                gcr_importer_listen                 (GcrImporter *self,
                                                             GcrParser *parser);

Listen for parse events from the GcrParser, and queue parsed items for importing.

`self` : | The importer
`parser` : | The parser to listen to

### gcr_importer_queue ()

    void                gcr_importer_queue                  (GcrImporter *self,
                                                             const gchar *label,
                                                             GckAttributes *attrs);

Queue the importing of an item. Use `gcr_importer_listen()` to automatically queue items parsed by a GcrParser.

`self` : | The importer
`label` : | Label of item to import
`attrs` : | Attributes of item to import

### gcr_importer_import ()

    gboolean            gcr_importer_import                 (GcrImporter *self,
                                                             GCancellable *cancellable,
                                                             GError **error);

Start an synchronous import operation of the items that have been queued.

`self` : | The importer
`cancellable` : | An optional cancellation object
`error` : | A location to raise an error on failure
Returns : | Whether the import was successful or not.

### gcr_importer_import_async ()

    void                gcr_importer_import_async           (GcrImporter *self,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Start an asynchronous import operation of the items that have been queued.

`self` : | The importer
`cancellable` : | An optional cancellation object
`callback` : | Call when the operation result is ready
`user_data` : | Data to pass to the callback

### gcr_importer_import_finish ()

    gboolean            gcr_importer_import_finish          (GcrImporter *self,
                                                             GAsyncResult *result,
                                                             GError **error);

Complete an asynchronous import operation.

`self` : | The importer
`result` : | The operation result
`error` : | A location to raise an error on failure.
Returns : | Whether the operation was successful or not.

### gcr_importer_get_slot ()

    GckSlot *           gcr_importer_get_slot               (GcrImporter *self);

Get the PKCS#11 slot the items will be imported to, or after an import operation, which slot they have been imported to.

`self` : | The importer
Returns : | The slot.

### gcr_importer_set_slot ()

    void                gcr_importer_set_slot               (GcrImporter *self,
                                                             GckSlot *slot);

Set the PKCS#11 slot to import the items to.

`self` : | The importer
`slot` : | The slot to import to

### gcr_importer_get_prompt_behavior ()

    GcrImporterPromptBehavior gcr_importer_get_prompt_behavior
                                                            (GcrImporter *self);

Get the type of prompting configured for this importer.

`self` : | The importer
Returns : | The prompting flags.

### gcr_importer_set_prompt_behavior ()

    void                gcr_importer_set_prompt_behavior    (GcrImporter *self,
                                                             GcrImporterPromptBehavior behavior);

Set the type of prompting desired during import.

`self` : | The importer
`behavior` : | The prompt behavior flag

### gcr_importer_get_parser ()

    GcrParser *         gcr_importer_get_parser             (GcrImporter *self);

### Warning

`gcr_importer_get_parser` is deprecated and should not be used in newly-written code. Since 3.0.0

Has no effect. Use `gcr_importer_listen()` instead.

`self` : | An importer
Returns : | `NULL` is always returned.

### gcr_importer_set_parser ()

    void                gcr_importer_set_parser             (GcrImporter *self,
                                                             GcrParser *parser);

### Warning

`gcr_importer_set_parser` is deprecated and should not be used in newly-written code. Since 3.0.0

Has no effect. Use `gcr_importer_listen()` instead.

`self` : | An importer
`parser` : | A parser

## Property Details

### The `"prompt-behavior"` property

      "prompt-behavior"          gint                  : Read / Write

Import Prompt Behavior.

Allowed values: >= 0

Default value: 0

### The `"slot"` property

      "slot"                     GckSlot*              : Read / Write

PKCS#11 slot to import data into.

## Signal Details

### The `"imported"` signal

    void                user_function                      (GcrImporter *object,
                                                            GckObject   *arg1,
                                                            gpointer     user_data)      : Run First

This signal is emitted when an item has been imported.

`object` : | The object which was imported.
`user_data` : | user data set when the signal handler was connected.

### The `"queued"` signal

    void                user_function                      (GcrImporter *label,
                                                            gchar       *attrs,
                                                            gpointer     user_data)      : Run First

This signal is emitted when an item is queued for import.

`label` : | The label of the queued item.
`attrs` : | The attributes of the queued item.
`user_data` : | user data set when the signal handler was connected.