gnome-keyring r1657 - in trunk: . gp11



Author: nnielsen
Date: Tue Mar  3 22:25:00 2009
New Revision: 1657
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1657&view=rev

Log:
Allow specifying auto-authenticate property on a more fine grained level.

Modified:
   trunk/ChangeLog
   trunk/gp11/gp11-module.c
   trunk/gp11/gp11-session.c
   trunk/gp11/gp11-slot.c
   trunk/gp11/gp11.h

Modified: trunk/gp11/gp11-module.c
==============================================================================
--- trunk/gp11/gp11-module.c	(original)
+++ trunk/gp11/gp11-module.c	Tue Mar  3 22:25:00 2009
@@ -64,7 +64,7 @@
 	GStaticMutex mutex;
 	gboolean finalized;
 	GHashTable *open_sessions;
-	gboolean auto_authenticate;
+	gint auto_authenticate;
 } GP11ModulePrivate;
 
 #define GP11_MODULE_GET_DATA(o) \
@@ -438,7 +438,7 @@
 		g_value_set_pointer (value, gp11_module_get_functions (self));
 		break;
 	case PROP_AUTO_AUTHENTICATE:
-		g_value_set_boolean (value, gp11_module_get_auto_authenticate (self));
+		g_value_set_int (value, gp11_module_get_auto_authenticate (self));
 		break;
 	case PROP_POOL_SESSIONS:
 		g_value_set_boolean (value, gp11_module_get_pool_sessions (self));
@@ -464,7 +464,7 @@
 		data->funcs = g_value_get_pointer (value);
 		break;
 	case PROP_AUTO_AUTHENTICATE:
-		gp11_module_set_auto_authenticate (self, g_value_get_boolean (value));
+		gp11_module_set_auto_authenticate (self, g_value_get_int (value));
 		break;
 	case PROP_POOL_SESSIONS:
 		gp11_module_set_pool_sessions (self, g_value_get_boolean (value));
@@ -552,8 +552,8 @@
 		                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
 	g_object_class_install_property (gobject_class, PROP_AUTO_AUTHENTICATE,
-		g_param_spec_boolean ("auto-authenticate", "Auto Authenticate", "Auto Login to Token when necessary",
-		                      FALSE, G_PARAM_READWRITE));
+		g_param_spec_int ("auto-authenticate", "Auto Authenticate", "Auto Login to Token when necessary",
+		                  0, G_MAXINT, 0, G_PARAM_READWRITE));
 	
 	g_object_class_install_property (gobject_class, PROP_POOL_SESSIONS,
 		g_param_spec_boolean ("pool-sessions", "Pool Sessions", "Pool sessions?",
@@ -919,11 +919,11 @@
  * 
  * Return value: Whether auto login or not.
  **/
-gboolean
+gint
 gp11_module_get_auto_authenticate (GP11Module *self)
 {
 	GP11ModulePrivate *pv = lock_private (self);
-	gboolean ret;
+	gint ret;
 	
 	g_return_val_if_fail (pv, FALSE);
 	
@@ -947,9 +947,13 @@
  * signal when an object requires authintication.
  **/
 void
-gp11_module_set_auto_authenticate (GP11Module *self, gboolean auto_login)
+gp11_module_set_auto_authenticate (GP11Module *self, gint auto_login)
 {
 	GP11ModulePrivate *pv = lock_private (self);
+	
+	/* HACK: Get needed fix around API freeze. */
+	if (auto_login == 1)
+		auto_login = GP11_AUTHENTICATE_TOKENS | GP11_AUTHENTICATE_OBJECTS;
 
 	g_return_if_fail (pv);
 	

Modified: trunk/gp11/gp11-session.c
==============================================================================
--- trunk/gp11/gp11-session.c	(original)
+++ trunk/gp11/gp11-session.c	Tue Mar  3 22:25:00 2009
@@ -1136,7 +1136,7 @@
 	g_assert (GP11_IS_OBJECT (object));
 	
 	module = gp11_slot_get_module (slot);
-	if (gp11_module_get_auto_authenticate (module)) {
+	if (gp11_module_get_auto_authenticate (module) & GP11_AUTHENTICATE_OBJECTS) {
 		auth->state = AUTHENTICATE_CAN;
 		auth->protected_auth = gp11_slot_has_flags (slot, CKF_PROTECTED_AUTHENTICATION_PATH);
 		auth->module = module;

Modified: trunk/gp11/gp11-slot.c
==============================================================================
--- trunk/gp11/gp11-slot.c	(original)
+++ trunk/gp11/gp11-slot.c	Tue Mar  3 22:25:00 2009
@@ -822,7 +822,7 @@
 		args.slot = self;
 		args.flags = flags;
 		args.password = NULL;
-		args.auto_login = gp11_module_get_auto_authenticate (module);
+		args.auto_login = (gp11_module_get_auto_authenticate (module) & GP11_AUTHENTICATE_TOKENS) ? TRUE : FALSE;
 		args.session = 0;
 		
 		if (_gp11_call_sync (self, perform_open_session, complete_open_session, &args, cancellable, err))
@@ -871,7 +871,7 @@
 	module = gp11_slot_get_module (self);
 	slot_id = gp11_slot_get_handle (self);
 	args->session = _gp11_module_pooled_session_handle (module, slot_id, flags);
-	args->auto_login = gp11_module_get_auto_authenticate (module);
+	args->auto_login = (gp11_module_get_auto_authenticate (module) & GP11_AUTHENTICATE_TOKENS) ? TRUE : FALSE;
 	g_object_unref (module);
 	
 	call = _gp11_call_async_ready (args, cancellable, callback, user_data);

Modified: trunk/gp11/gp11.h
==============================================================================
--- trunk/gp11/gp11.h	(original)
+++ trunk/gp11/gp11.h	Tue Mar  3 22:25:00 2009
@@ -75,6 +75,11 @@
 
 #define GP11_INVALID G_MAXULONG
 
+enum {
+	GP11_AUTHENTICATE_TOKENS = 2,
+	GP11_AUTHENTICATE_OBJECTS = 4
+};
+
 /* Used on varargs functions that should end with GP11_INVALID */
 #ifdef NOT_YET_SUPPORTED
 #define GP11_INVALID_TERMINATED __attribute__((__sentinel__(G_MAXULONG)))
@@ -306,10 +311,10 @@
 void                  gp11_module_set_pool_sessions           (GP11Module *self, 
                                                                gboolean pool_sessions);
 
-gboolean              gp11_module_get_auto_authenticate       (GP11Module *self);
+gint                  gp11_module_get_auto_authenticate       (GP11Module *self);
 
 void                  gp11_module_set_auto_authenticate       (GP11Module *self, 
-                                                               gboolean auto_authenticate);
+                                                               gint auto_authenticate);
 
 gboolean              gp11_module_enumerate_objects           (GP11Module *self,
                                                                GP11ObjectForeachFunc func,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]