diff --git a/c_adlib/ad_gk/GnomeKeyring.cs b/c_adlib/ad_gk/GnomeKeyring.cs index 4e4efdfc..9ea2f540 100644 --- a/c_adlib/ad_gk/GnomeKeyring.cs +++ b/c_adlib/ad_gk/GnomeKeyring.cs @@ -87,6 +87,32 @@ namespace Novell.CASA.DataEngines.GK public static extern int SetItemAttributes (string keyring, int itemid, IntPtr[] attrs, int length); [DllImport("libad_gk.so")] 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) diff --git a/c_adlib/ad_gk/native/ad_gk.c b/c_adlib/ad_gk/native/ad_gk.c index 095b5a58..1e467547 100644 --- a/c_adlib/ad_gk/native/ad_gk.c +++ b/c_adlib/ad_gk/native/ad_gk.c @@ -12,7 +12,6 @@ OperationCompletedCb (GnomeKeyringResult result, g_main_loop_quit (loop); } - static void CreateItemCb (GnomeKeyringResult result, guint32 id, @@ -28,6 +27,21 @@ CreateItemCb (GnomeKeyringResult result, 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 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; 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); cbData.OperationName = "Create Item"; loop = g_main_loop_new (NULL, FALSE); diff --git a/c_adlib/ad_gk/native/ad_gk.h b/c_adlib/ad_gk/native/ad_gk.h index 8ff28b7c..497ab423 100644 --- a/c_adlib/ad_gk/native/ad_gk.h +++ b/c_adlib/ad_gk/native/ad_gk.h @@ -54,6 +54,8 @@ int GetItemInfo(char *keyring, int itemId, ItemInfo *info); int GetAttributeList(char *keyring, int itemId, GList **); int FreeAttributeList(GList *attrList); +int +UnlockRing(char *keyring, char *password); int SetItemAttributes (char *keyring, guint32 item_id, Attribute **attrs, int length); int