Unlock support

This commit is contained in:
Jim Norman 2006-01-04 23:49:07 +00:00
parent 7880ab744b
commit bed0ba9d0f
3 changed files with 43 additions and 2 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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