Imported Upstream version 2.34.0
[platform/upstream/glib-networking.git] / tls / pkcs11 / gpkcs11slot.h
1 /* GIO - Small GLib wrapper of PKCS#11 for use in GTls
2  *
3  * Copyright 2011 Collabora, Ltd.
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 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@collabora.co.uk>
13  */
14
15 #ifndef __G_PKCS11_SLOT_H__
16 #define __G_PKCS11_SLOT_H__
17
18 #include <gio/gio.h>
19
20 #include "gpkcs11array.h"
21
22 #include <p11-kit/pkcs11.h>
23 #include <p11-kit/uri.h>
24
25 G_BEGIN_DECLS
26
27 typedef enum
28 {
29   G_PKCS11_ENUMERATE_FAILED,
30   G_PKCS11_ENUMERATE_STOP,
31   G_PKCS11_ENUMERATE_CONTINUE
32 } GPkcs11EnumerateState;
33
34 #define G_TYPE_PKCS11_SLOT            (g_pkcs11_slot_get_type ())
35 #define G_PKCS11_SLOT(inst)           (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_PKCS11_SLOT, GPkcs11Slot))
36 #define G_PKCS11_SLOT_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_PKCS11_SLOT, GPkcs11SlotClass))
37 #define G_IS_PKCS11_SLOT(inst)        (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_PKCS11_SLOT))
38 #define G_IS_PKCS11_SLOT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_PKCS11_SLOT))
39 #define G_PKCS11_SLOT_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), G_TYPE_PKCS11_SLOT, GPkcs11SlotClass))
40
41 typedef struct _GPkcs11SlotPrivate                   GPkcs11SlotPrivate;
42 typedef struct _GPkcs11SlotClass                     GPkcs11SlotClass;
43 typedef struct _GPkcs11Slot                          GPkcs11Slot;
44
45 struct _GPkcs11SlotClass
46 {
47   GObjectClass parent_class;
48 };
49
50 struct _GPkcs11Slot
51 {
52   GObject parent_instance;
53   GPkcs11SlotPrivate *priv;
54 };
55
56 typedef gboolean             (*GPkcs11Accumulator)            (gpointer result,
57                                                                gpointer user_data);
58
59 GType                        g_pkcs11_slot_get_type           (void) G_GNUC_CONST;
60
61 GPkcs11EnumerateState        g_pkcs11_slot_enumerate          (GPkcs11Slot             *self,
62                                                                GTlsInteraction         *interaction,
63                                                                CK_ATTRIBUTE_PTR         match,
64                                                                CK_ULONG                 match_count,
65                                                                gboolean                 match_private,
66                                                                const CK_ATTRIBUTE_TYPE *attr_types,
67                                                                guint                    attr_types_length,
68                                                                GPkcs11Accumulator       accumulator,
69                                                                gpointer                 user_data,
70                                                                GCancellable            *cancellable,
71                                                                GError                 **error);
72
73 gboolean                     g_pkcs11_slot_get_token_info     (GPkcs11Slot             *self,
74                                                                CK_TOKEN_INFO_PTR        token_info);
75
76 gboolean                     g_pkcs11_slot_matches_uri        (GPkcs11Slot             *self,
77                                                                P11KitUri               *uri);
78
79 G_END_DECLS
80
81 #endif /* __G_PKCS11_SLOT_H___ */