summaryrefslogtreecommitdiff
path: root/plugins/smartcard/gsd-smartcard.h
blob: c8c1ea76e8923838c3f61df21cc852a15e00266e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* securitycard.h - api for reading and writing data to a security card
 *
 * Copyright (C) 2006 Ray Strode
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */
#ifndef GSD_SMARTCARD_H
#define GSD_SMARTCARD_H

#include <glib.h>
#include <glib-object.h>

#include <secmod.h>

#ifdef __cplusplus
extern "C" {
#endif
#define GSD_TYPE_SMARTCARD            (gsd_smartcard_get_type ())
#define GSD_SMARTCARD(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_SMARTCARD, GsdSmartcard))
#define GSD_SMARTCARD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_SMARTCARD, GsdSmartcardClass))
#define GSD_IS_SMARTCARD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSD_TYPE_SMARTCARD))
#define GSD_IS_SMARTCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSD_TYPE_SMARTCARD))
#define GSD_SMARTCARD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GSD_TYPE_SMARTCARD, GsdSmartcardClass))
#define GSD_SMARTCARD_ERROR           (gsd_smartcard_error_quark ())
typedef struct _GsdSmartcardClass GsdSmartcardClass;
typedef struct _GsdSmartcard GsdSmartcard;
typedef struct _GsdSmartcardPrivate GsdSmartcardPrivate;
typedef enum _GsdSmartcardError GsdSmartcardError;
typedef enum _GsdSmartcardState GsdSmartcardState;

typedef struct _GsdSmartcardRequest GsdSmartcardRequest;

struct _GsdSmartcard {
    GObject parent;

    /*< private > */
    GsdSmartcardPrivate *priv;
};

struct _GsdSmartcardClass {
    GObjectClass parent_class;

    void (* inserted) (GsdSmartcard *card);
    void (* removed)  (GsdSmartcard *card);
};

enum _GsdSmartcardError {
    GSD_SMARTCARD_ERROR_GENERIC = 0,
};

enum _GsdSmartcardState {
    GSD_SMARTCARD_STATE_INSERTED = 0,
    GSD_SMARTCARD_STATE_REMOVED,
};

GType gsd_smartcard_get_type (void) G_GNUC_CONST;
GQuark gsd_smartcard_error_quark (void) G_GNUC_CONST;

CK_SLOT_ID gsd_smartcard_get_slot_id (GsdSmartcard *card);
gint gsd_smartcard_get_slot_series (GsdSmartcard *card);
GsdSmartcardState gsd_smartcard_get_state (GsdSmartcard *card);

char *gsd_smartcard_get_name (GsdSmartcard *card);
gboolean gsd_smartcard_is_login_card (GsdSmartcard *card);

gboolean gsd_smartcard_unlock (GsdSmartcard *card,
                               const char   *password);

/* don't under any circumstances call these functions */
#ifdef GSD_SMARTCARD_ENABLE_INTERNAL_API

GsdSmartcard *_gsd_smartcard_new (SECMODModule *module,
                                  CK_SLOT_ID    slot_id,
                                  gint          slot_series);
GsdSmartcard *_gsd_smartcard_new_from_name (SECMODModule *module,
                                            const char   *name);

void _gsd_smartcard_set_state (GsdSmartcard      *card,
                               GsdSmartcardState  state);
#endif

#ifdef __cplusplus
}
#endif
#endif                                /* GSD_SMARTCARD_H */