1 /* csd-smartcard-manager.h - object for monitoring smartcard insertion and
2  *                           removal events
3  *
4  * Copyright (C) 2006, 2009 Red Hat, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street - Suite 500, Boston, MA
19  * 02110-1335, USA.
20  *
21  * Written by: Ray Strode
22  */
23 #ifndef CSD_SMARTCARD_MANAGER_H
24 #define CSD_SMARTCARD_MANAGER_H
25 
26 #define CSD_SMARTCARD_ENABLE_INTERNAL_API
27 #include "csd-smartcard.h"
28 
29 #include <glib.h>
30 #include <glib-object.h>
31 
32 G_BEGIN_DECLS
33 #define CSD_TYPE_SMARTCARD_MANAGER            (csd_smartcard_manager_get_type ())
34 #define CSD_SMARTCARD_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CSD_TYPE_SMARTCARD_MANAGER, CsdSmartcardManager))
35 #define CSD_SMARTCARD_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CSD_TYPE_SMARTCARD_MANAGER, CsdSmartcardManagerClass))
36 #define CSD_IS_SMARTCARD_MANAGER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_SMARTCARD_MANAGER))
37 #define CSD_IS_SMARTCARD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_SMARTCARD_MANAGER))
38 #define CSD_SMARTCARD_MANAGER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), CSD_TYPE_SMARTCARD_MANAGER, CsdSmartcardManagerClass))
39 #define CSD_SMARTCARD_MANAGER_ERROR           (csd_smartcard_manager_error_quark ())
40 typedef struct _CsdSmartcardManager CsdSmartcardManager;
41 typedef struct _CsdSmartcardManagerClass CsdSmartcardManagerClass;
42 typedef struct _CsdSmartcardManagerPrivate CsdSmartcardManagerPrivate;
43 typedef enum _CsdSmartcardManagerError CsdSmartcardManagerError;
44 
45 struct _CsdSmartcardManager {
46     GObject parent;
47 
48     /*< private > */
49     CsdSmartcardManagerPrivate *priv;
50 };
51 
52 struct _CsdSmartcardManagerClass {
53         GObjectClass parent_class;
54 
55         /* Signals */
56         void (*smartcard_inserted) (CsdSmartcardManager *manager,
57                                     CsdSmartcard        *token);
58         void (*smartcard_removed) (CsdSmartcardManager *manager,
59                                    CsdSmartcard        *token);
60         void (*error) (CsdSmartcardManager *manager,
61                        GError              *error);
62 };
63 
64 enum _CsdSmartcardManagerError {
65     CSD_SMARTCARD_MANAGER_ERROR_GENERIC = 0,
66     CSD_SMARTCARD_MANAGER_ERROR_WITH_NSS,
67     CSD_SMARTCARD_MANAGER_ERROR_LOADING_DRIVER,
68     CSD_SMARTCARD_MANAGER_ERROR_WATCHING_FOR_EVENTS,
69     CSD_SMARTCARD_MANAGER_ERROR_REPORTING_EVENTS
70 };
71 
72 GType csd_smartcard_manager_get_type (void) G_GNUC_CONST;
73 GQuark csd_smartcard_manager_error_quark (void) G_GNUC_CONST;
74 
75 CsdSmartcardManager *csd_smartcard_manager_new_default (void);
76 
77 CsdSmartcardManager *csd_smartcard_manager_new (const char *module);
78 
79 gboolean csd_smartcard_manager_start (CsdSmartcardManager  *manager,
80                                       GError              **error);
81 
82 void csd_smartcard_manager_stop (CsdSmartcardManager *manager);
83 
84 char *csd_smartcard_manager_get_module_path (CsdSmartcardManager *manager);
85 gboolean csd_smartcard_manager_login_card_is_inserted (CsdSmartcardManager *manager);
86 
87 G_END_DECLS
88 #endif                                /* CSD_SMARTCARD_MANAGER_H */
89