GcrImporter: Gcr Library Reference Manual

## GcrImporter GcrImporter — Import certificates and keys |

## Functions

GTlsInteraction * | gcr_importer_get_interaction ()
void | gcr_importer_set_interaction ()
gboolean | gcr_importer_import ()
void | gcr_importer_import_async ()
gboolean | gcr_importer_import_finish ()
void | gcr_importer_register ()
void | gcr_importer_register_well_known ()
GList * | gcr_importer_create_for_parsed ()
gboolean | gcr_importer_queue_for_parsed ()
GList * | gcr_importer_queue_and_filter_for_parsed ()

## Properties

GIcon * | icon | Read
GTlsInteraction * | interaction | Read / Write
char * | label | Read
char * | uri | Read

## Types and Values

| GcrImporter
struct | GcrImporterIface

## Object Hierarchy

        GInterface
        ├── GcrImportInteraction
        ╰── GcrImporter

## Prerequisites

GcrImporter requires GObject.

GcrImportInteraction requires GTlsInteraction.

## Description

An interface which allows importing of certificates and keys. Each GcrImporter is registered with a set of PKCS#11 attributes to match stuff that it can import.

An importer gets passed a GcrParser and accesses the currently parsed item. To create a set of importers that can import the currently parsed item in a GcrParser, use `gcr_importer_create_for_parsed()`. The list of importers returned has the parsed item queued for import.

To queue additional items with a importer use `gcr_importer_queue_for_parsed()`. In addition you can try and queue an additional item with a set of importers using the `gcr_importer_queue_and_filter_for_parsed()`.

To start the import use `gcr_importer_import()` or the async variants.

## Functions

### gcr_importer_get_interaction ()

    GTlsInteraction *
    gcr_importer_get_interaction (GcrImporter *importer);

Get the interaction used to prompt the user when needed by this importer.

#### Parameters

importer | the importer |

#### Returns

the interaction or `NULL`.

[transfer none][nullable]

### gcr_importer_set_interaction ()

    void
    gcr_importer_set_interaction (GcrImporter *importer,
                                  GTlsInteraction *interaction);

Set the interaction used to prompt the user when needed by this importer.

#### Parameters

importer | the importer |
interaction | the interaction used by the importer |

### gcr_importer_import ()

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

Import the queued items in the importer. This call will block until the operation completes.

#### Parameters

importer | the importer |
cancellable | a GCancellable, or `NULL` |
error | the location to place an error on failure, or `NULL` |

#### Returns

whether the items were imported successfully or not

### gcr_importer_import_async ()

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

Import the queued items in the importer. This function returns immediately and completes asynchronously.

#### Parameters

importer | the importer |
cancellable | a GCancellable, or `NULL` |
callback | called when the operation completes |
user_data | data to be passed to the callback |

### gcr_importer_import_finish ()

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

Complete an asynchronous operation to import queued items.

#### Parameters

importer | the importer |
result | an asynchronous result |
error | the location to place an error on failure, or `NULL` |

#### Returns

whether the import succeeded or failed

### gcr_importer_register ()

    void
    gcr_importer_register (GType importer_type,
                           GckAttributes *attrs);

Register an importer to handle parsed items that match the given attributes.

If `attrs` are a floating reference, then it is consumed.

#### Parameters

importer_type | the GType of the importer being registered |
attrs | the attributes that this importer is compatible with |

### gcr_importer_register_well_known ()

    void
    gcr_importer_register_well_known (void);

Register built-in PKCS#11 and GnuPG importers.

### gcr_importer_create_for_parsed ()

    GList *
    gcr_importer_create_for_parsed (GcrParsed *parsed);

Create a set of importers which can import this parsed item. The parsed item is represented by the state of the GcrParser at the time of calling this method.

#### Parameters

parsed | a parser with a parsed item to import |

#### Returns

a list of importers which can import the parsed item, which should be freed with `g_object_unref()`, or `NULL` if no types of importers can be created.

[element-type Gcr.Importer][transfer full]

### gcr_importer_queue_for_parsed ()

    gboolean
    gcr_importer_queue_for_parsed (GcrImporter *importer,
                                   GcrParsed *parsed);

Queues an additional item to be imported. The parsed item is represented by the state of the GcrParser at the time of calling this method.

If the parsed item is incompatible with the importer, then this will fail and the item will not be queued.

#### Parameters

importer | an importer to add additional items to |
parsed | a parsed item to import |

#### Returns

whether the item was queued or not

### gcr_importer_queue_and_filter_for_parsed ()

    GList *
    gcr_importer_queue_and_filter_for_parsed
                                   (GList *importers,
                                    GcrParsed *parsed);

Queues an additional item to be imported in all compattible importers in the set. The parsed item is represented by the state of the GcrParser at the time of calling this method.

If the parsed item is incompatible with an importer, then that the item will not be queued on that importer.

#### Parameters

importers | a set of importers. | [element-type Gcr.Importer]
parsed | a parsed item |

#### Returns

a new set of importers that queued the item, which should be freed with `gck_list_unref_free()`.

[transfer full][element-type Gcr.Importer]

## Types and Values

### GcrImporter

    typedef struct _GcrImporter GcrImporter;

Imports certificates and keys

### struct GcrImporterIface

    struct GcrImporterIface {
    	GTypeInterface parent;

    	GList *     (*create_for_parsed)      (GcrParsed *parsed);

    	gboolean    (*queue_for_parsed)       (GcrImporter *importer,
    	                                       GcrParsed *parsed);

    	gboolean    (*import_sync)            (GcrImporter *importer,
    	                                       GCancellable *cancellable,
    	                                       GError **error);

    	void        (*import_async)           (GcrImporter *importer,
    	                                       GCancellable *cancellable,
    	                                       GAsyncReadyCallback callback,
    	                                       gpointer user_data);

    	gboolean    (*import_finish)          (GcrImporter *importer,
    	                                       GAsyncResult *result,
    	                                       GError **error);
    };

Interface implemented for a GcrImporter.

#### Members

GTypeInterface `parent`; | parent interface |
`create_for_parsed` () | implementation of `gcr_importer_create_for_parsed()`, required |
`queue_for_parsed` () | implementation of `gcr_importer_queue_for_parsed()`, required |
`import_sync` () | optional implemantionon of `gcr_importer_import()` |
`import_async` () | implementation of `gcr_importer_import_async()`, required |
`import_finish` () | implementation of `gcr_importer_import_finish()` |

## Property Details

### The `“icon”` property

      “icon”                     GIcon *

The icon for the importer.

Owner: GcrImporter

Flags: Read

### The `“interaction”` property

      “interaction”              GTlsInteraction *

The interaction for the importer.

Owner: GcrImporter

Flags: Read / Write

### The `“label”` property

      “label”                    char *

The label for the importer.

Owner: GcrImporter

Flags: Read

Default value: ""

### The `“uri”` property

      “uri”                      char *

The URI of the location imported to.

Owner: GcrImporter

Flags: Read

Default value: NULL