From: Stefan Walter Date: Sat, 28 Feb 2009 03:05:45 +0000 (+0000) Subject: Fix problem with looking up pin initialized flag in the wrong X-Git-Tag: split~323 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1e3ac2e2ba1d5d06548cdd780b7a445eb53de2d;p=platform%2Fupstream%2Fgcr.git Fix problem with looking up pin initialized flag in the wrong structure. svn path=/trunk/; revision=1632 --- diff --git a/gcr/gcr-importer.c b/gcr/gcr-importer.c index 7478b85..8a04889 100644 --- a/gcr/gcr-importer.c +++ b/gcr/gcr-importer.c @@ -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 index 0000000..aea19cb --- /dev/null +++ b/gcr/gcr-initializer.h @@ -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 + +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__ */