Bug 235624. Fix GUI hang on multiple file imports.

This commit is contained in:
Jim Norman 2007-01-18 06:39:03 +00:00
parent 03c5d13eee
commit ca7b9ebb9b
4 changed files with 58 additions and 23 deletions

View File

@ -2189,11 +2189,12 @@ namespace Novell.CASA.GUI
public void on_importSecrets_activate(object obj, EventArgs args)
{
ImportSecrets importSecrets = new ImportSecrets(config, objMiCasa);
importSecrets.Run();
if (objMiCasa != null)
{
objMiCasa.DoFileImport(config);
objMiCasa.AggregateStore();
}
}
public void on_buttonChooseDirectory_clicked(object obj, EventArgs args)

View File

@ -43,8 +43,9 @@ namespace Novell.CASA.GUI
Gtk.CheckButton cbShowValues;
#endregion
public ImportSecrets(Config config, MiCasa objMiCasa)
public ImportSecrets(SecretStore ss, Config config, MiCasa objMiCasa)
{
m_ss = ss;
m_config = config;
m_objMiCasa = objMiCasa;
}

View File

@ -1426,6 +1426,9 @@ public class MiCasa : Store
if (tvKeyValue.Selection.GetSelected(out model, out iter))
{
byte[] baValue = new byte[0];
byte[] baTarget = new byte[0];
selected = (string)model.GetValue(iter, 0);
value = (string)model.GetValue(iter, 1);
@ -1436,14 +1439,14 @@ public class MiCasa : Store
Secret secret = ss.GetSecret(entrySecretID.Text);
value = secret.GetKeyValue(selected);
// strip of header data
byte[] baValue = System.Text.Encoding.ASCII.GetBytes(value);
byte[] baTarget = new byte[baValue.Length - 16];
baValue = System.Text.Encoding.ASCII.GetBytes(value);
if (baValue.Length > 16)
{
baTarget = new byte[baValue.Length - 16];
Array.Copy(baValue, 13, baTarget, 0, baValue.Length - 16);
try
}
/* try
{
baValue = Convert.FromBase64String(System.Text.Encoding.ASCII.GetString(baTarget));
value = System.Text.Encoding.ASCII.GetString(baValue);
@ -1452,7 +1455,7 @@ public class MiCasa : Store
{
value = e.ToString();
}
*/
}
if (selected != null && selected.Length > 0)
@ -1462,16 +1465,31 @@ public class MiCasa : Store
// display decoded value
//textviewClear.Buffer.Text = value;
char[] array = value.ToCharArray();
//char[] array = value.ToCharArray();
try
{
byte[] bytes = Convert.FromBase64CharArray(array, 0, array.Length);
textviewClear.Buffer.Text = System.Text.Encoding.ASCII.GetString(bytes);
if (baTarget.Length > 0)
{
baValue = Convert.FromBase64String(System.Text.Encoding.ASCII.GetString(baTarget));
value = System.Text.Encoding.ASCII.GetString(baValue);
textviewClear.Buffer.Text = value;
}
else
{
textviewClear.Buffer.Text = value;
}
//byte[] bytes = Convert.FromBase64CharArray(array, 0, array.Length);
//textviewClear.Buffer.Text = System.Text.Encoding.ASCII.GetString(bytes);
}
catch (Exception e)
{
// decode failed, open it all
textviewClear.Buffer.Text = e.ToString();
bttnExpand_Clicked(null, null);
textviewEncoded.Buffer.Text = value;
}
// hook up button handlers
@ -1531,6 +1549,13 @@ public class MiCasa : Store
}
}
internal void DoFileImport(Config config)
{
ImportSecrets importSecrets = new ImportSecrets(GetMiCasaStore(), config, this);
importSecrets.Run();
}
}
}
///##################################################################

View File

@ -46,6 +46,11 @@ namespace Novell.CASA
DoSetup();
}
~SecretStore()
{
ReleaseInstance();
}
private void DoSetup()
{
m_NativeCalls = new NativeCalls();
@ -62,7 +67,10 @@ namespace Novell.CASA
public void ReleaseInstance()
{
if (m_hsc != IntPtr.Zero)
{
m_NativeCalls.CloseSecretStore(m_hsc);
m_hsc = IntPtr.Zero;
}
}
/*