Fix problem with looking up pin initialized flag in the wrong
authorStefan Walter <stefw@src.gnome.org>
Sat, 28 Feb 2009 03:05:45 +0000 (03:05 +0000)
committerStefan Walter <stefw@src.gnome.org>
Sat, 28 Feb 2009 03:05:45 +0000 (03:05 +0000)
structure.

svn path=/trunk/; revision=1632

gcr/gcr-importer.c
gcr/gcr-initializer.h [new file with mode: 0644]

index 7478b85..8a04889 100644 (file)
@@ -315,7 +315,8 @@ hacky_perform_initialize_pin (GP11Slot *slot)
 static void
 state_initialize_pin (GcrImporter *self, gboolean async)
 {
-       GP11SlotInfo *info;
+       GP11TokenInfo *info;
+       gboolean initialize;
        CK_RV rv;
 
        g_assert (GCR_IS_IMPORTER (self));
@@ -323,10 +324,13 @@ state_initialize_pin (GcrImporter *self, gboolean async)
        /* HACK: Doesn't function when async */
        if (!async) {
                g_return_if_fail (self->pv->slot);
-               info = gp11_slot_get_info (self->pv->slot);
+               info = gp11_slot_get_token_info (self->pv->slot);
                g_return_if_fail (info);
 
-               if (!(info->flags & CKF_USER_PIN_INITIALIZED)) {
+               initialize = !(info->flags & CKF_USER_PIN_INITIALIZED);
+               gp11_token_info_free (info);
+
+               if (initialize) {
                        rv = hacky_perform_initialize_pin (self->pv->slot);
                        if (rv != CKR_OK) {
                                g_propagate_error (&self->pv->error, g_error_new (GP11_ERROR, rv, "%s", gp11_message_from_rv (rv)));
diff --git a/gcr/gcr-initializer.h b/gcr/gcr-initializer.h
new file mode 100644 (file)
index 0000000..aea19cb
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * gnome-keyring
+ *
+ * Copyright (C) 2008 Stefan Walter
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 __GCR_TOKEN_MANAGER_H__
+#define __GCR_TOKEN_MANAGER_H__
+
+#include "gcr-types.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GCR_TYPE_TOKEN_MANAGER               (gcr_token_manager_get_type ())
+#define GCR_TOKEN_MANAGER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCR_TYPE_TOKEN_MANAGER, GcrTokenManager))
+#define GCR_TOKEN_MANAGER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GCR_TYPE_TOKEN_MANAGER, GcrTokenManagerClass))
+#define GCR_IS_TOKEN_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCR_TYPE_TOKEN_MANAGER))
+#define GCR_IS_TOKEN_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), GCR_TYPE_TOKEN_MANAGER))
+#define GCR_TOKEN_MANAGER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GCR_TYPE_TOKEN_MANAGER, GcrTokenManagerClass))
+
+typedef struct _GcrTokenManager GcrTokenManager;
+typedef struct _GcrTokenManagerClass GcrTokenManagerClass;
+typedef struct _GcrTokenManagerPrivate GcrTokenManagerPrivate;
+
+struct _GcrTokenManager {
+       GObject parent;
+       GcrTokenManagerPrivate *pv;
+};
+
+struct _GcrTokenManagerClass {
+       GObjectClass parent_class;
+};
+
+GType                     gcr_token_manager_get_type             (void);
+
+GcrTokenManager*          gcr_token_manager_new                  (struct _GP11Slot *slot);
+
+struct _GP11Slot*         gcr_token_manager_get_slot             (GcrTokenManager *self);
+
+gboolean                  gcr_token_manager_initialize           (GcrTokenManager *self,
+                                                                  GCancellable *cancel,
+                                                                  GError **error);
+
+void                      gcr_token_manager_initialize_async     (GcrTokenManager *self,
+                                                                  GCancellable *cancel,
+                                                                  GAsyncReadyCallback callback,
+                                                                  gpointer user_data);
+
+gboolean                  gcr_token_manager_initialize_finish    (GcrTokenManager *self,
+                                                                  GAsyncResult *res,
+                                                                  GError **error);
+
+gboolean                  gcr_token_manager_change_pin           (GcrTokenManager *self,
+                                                                  GCancellable *cancel,
+                                                                  GError **error);
+
+void                      gcr_token_manager_change_pin_async     (GcrTokenManager *self,
+                                                                  GCancellable *cancel,
+                                                                  GAsyncReadyCallback callback,
+                                                                  gpointer user_data);
+
+gboolean                  gcr_token_manager_change_pin_finish    (GcrTokenManager *self,
+                                                                  GAsyncResult *res,
+                                                                  GError **error);
+
+G_END_DECLS
+
+#endif /* __GCR_TOKEN_MANAGER_H__ */