62
61
public bool Set (string key, string val)
66
65
if (!Ring.Available) {
67
66
Log.Error (KeyringUnavailableMessage);
71
70
keyData = new Hashtable ();
72
keyData[AbsolutePathForKey (key)] = key;
75
AutoResetEvent completed = new AutoResetEvent (false);
77
Services.Application.RunOnMainThread (delegate {
79
Ring.CreateItem (Ring.GetDefaultKeyring (), ItemType.GenericSecret, AbsolutePathForKey (key), keyData, val.ToString (), true);
81
} catch (KeyringException e) {
82
Log.Error (ErrorSavingMessage, key, e.Message);
83
Log.Debug (e.StackTrace);
88
if (!completed.WaitOne (200)) {
71
keyData [AbsolutePathForKey (key)] = key;
74
Ring.CreateItem (Ring.GetDefaultKeyring (), ItemType.GenericSecret, AbsolutePathForKey (key), keyData, val.ToString (), true);
75
} catch (KeyringException e) {
76
Log.Error (ErrorSavingMessage, key, e.Message);
77
Log.Debug (e.StackTrace);
94
84
public bool TryGet (string key, out string val)
100
90
if (!Ring.Available) {
101
91
Log.Error (KeyringUnavailableMessage);
106
95
keyData = new Hashtable ();
107
keyData[AbsolutePathForKey (key)] = key;
96
keyData [AbsolutePathForKey (key)] = key;
109
bool success = false;
110
AutoResetEvent completed = new AutoResetEvent (false);
112
Services.Application.RunOnMainThread (delegate {
114
foreach (ItemData item in Ring.Find (ItemType.GenericSecret, keyData)) {
115
if (!item.Attributes.ContainsKey (AbsolutePathForKey (key)))
118
secret = item.Secret;
122
} catch (KeyringException) {
123
Log.Debug (KeyNotFoundMessage, AbsolutePathForKey (key));
99
foreach (ItemData item in Ring.Find (ItemType.GenericSecret, keyData)) {
100
if (!item.Attributes.ContainsKey (AbsolutePathForKey (key))) continue;
129
if (!completed.WaitOne (200)) {
105
} catch (KeyringException) {
106
Log.Debug (KeyNotFoundMessage, AbsolutePathForKey (key));