Unlock support
This commit is contained in:
		| @@ -87,6 +87,32 @@ namespace Novell.CASA.DataEngines.GK | |||||||
| 	public static extern int SetItemAttributes (string keyring, int itemid, IntPtr[] attrs, int length); | 	public static extern int SetItemAttributes (string keyring, int itemid, IntPtr[] attrs, int length); | ||||||
| 	[DllImport("libad_gk.so")] | 	[DllImport("libad_gk.so")] | ||||||
| 	public static extern int CreateItem(string keyringName, int itemType, string displayName, string password, IntPtr[] arrptr, int attrCount); | 	public static extern int CreateItem(string keyringName, int itemType, string displayName, string password, IntPtr[] arrptr, int attrCount); | ||||||
|  | 	[DllImport("libad_gk.so")] | ||||||
|  | 	public static extern int UnlockRing(string sKeyringName, string sPassword); | ||||||
|  |  | ||||||
|  | 	public static void AttemptGKUnlock(string sPassword) | ||||||
|  | 	{ | ||||||
|  | 		ArrayList alKeyRings = GKGetKeyrings(); | ||||||
|  | 		IEnumerator kEtor = alKeyRings.GetEnumerator(); | ||||||
|  | 		while (kEtor.MoveNext()) | ||||||
|  | 		{ | ||||||
|  | 			string sKeyring = (string)(kEtor.Current); | ||||||
|  | 			try  | ||||||
|  | 			{ | ||||||
|  | 				UnlockGnomeKeyring(sKeyring, sPassword); | ||||||
|  | 			} | ||||||
|  | 			catch {} | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public static int UnlockGnomeKeyring(string sKeyringName, string sPassword) | ||||||
|  | 	{ | ||||||
|  | 		int rcode = UnlockRing(sKeyringName, sPassword); | ||||||
|  | 		return rcode; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
| 	 | 	 | ||||||
|  |  | ||||||
|         public static KeyringInfo GKGetKeyringInfo(string name) |         public static KeyringInfo GKGetKeyringInfo(string name) | ||||||
|   | |||||||
| @@ -12,7 +12,6 @@ OperationCompletedCb  (GnomeKeyringResult result, | |||||||
|         g_main_loop_quit (loop); |         g_main_loop_quit (loop); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| static void | static void | ||||||
| CreateItemCb  (GnomeKeyringResult result, | CreateItemCb  (GnomeKeyringResult result, | ||||||
|                 guint32            id, |                 guint32            id, | ||||||
| @@ -28,6 +27,21 @@ CreateItemCb  (GnomeKeyringResult result, | |||||||
|         g_main_loop_quit (loop); |         g_main_loop_quit (loop); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int | ||||||
|  | UnlockRing(char *keyring, | ||||||
|  |         char *password) | ||||||
|  | { | ||||||
|  |  | ||||||
|  |         // unlock the named keyring | ||||||
|  |         OperationCompleted cbData; | ||||||
|  |         cbData.OperationName = "Unlock Ring"; | ||||||
|  |  | ||||||
|  |         loop = g_main_loop_new (NULL, FALSE); | ||||||
|  |         gnome_keyring_unlock(keyring, password, OperationCompletedCb, &cbData, NULL); | ||||||
|  |  | ||||||
|  |         g_main_loop_run (loop); | ||||||
|  | 	return cbData.result; | ||||||
|  | } | ||||||
|  |  | ||||||
| static int | static int | ||||||
| CreateItemInKeyring(char *keyring, int32_t itemType, char *display_name, char *secret, Attribute **attrs, int attrcnt) | CreateItemInKeyring(char *keyring, int32_t itemType, char *display_name, char *secret, Attribute **attrs, int attrcnt) | ||||||
| @@ -37,7 +51,6 @@ CreateItemInKeyring(char *keyring, int32_t itemType, char *display_name, char *s | |||||||
|         OperationCompleted cbData; |         OperationCompleted cbData; | ||||||
|  |  | ||||||
|         int i; |         int i; | ||||||
|         printf("ad:gk.c :In CreateItemInKeyring\n"); |  | ||||||
|         printf("ad.gk.c : CreateItemInKeyring : Keyring %s, itemType %d displayname %s, secret %s \n",keyring,itemType, display_name,secret); |         printf("ad.gk.c : CreateItemInKeyring : Keyring %s, itemType %d displayname %s, secret %s \n",keyring,itemType, display_name,secret); | ||||||
|         cbData.OperationName = "Create Item"; |         cbData.OperationName = "Create Item"; | ||||||
|         loop = g_main_loop_new (NULL, FALSE); |         loop = g_main_loop_new (NULL, FALSE); | ||||||
|   | |||||||
| @@ -54,6 +54,8 @@ int GetItemInfo(char *keyring, int itemId, ItemInfo *info); | |||||||
| int GetAttributeList(char *keyring, int itemId, GList **); | int GetAttributeList(char *keyring, int itemId, GList **); | ||||||
| int FreeAttributeList(GList *attrList); | int FreeAttributeList(GList *attrList); | ||||||
|  |  | ||||||
|  | int | ||||||
|  | UnlockRing(char *keyring, char *password); | ||||||
| int | int | ||||||
| SetItemAttributes (char *keyring, guint32 item_id, Attribute **attrs, int length); | SetItemAttributes (char *keyring, guint32 item_id, Attribute **attrs, int length); | ||||||
| int | int | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user