added timer to suppress viewing values(passwords) for micasa store after a preset time in seconds.

This commit is contained in:
Jim Norman 2006-04-04 20:27:23 +00:00
parent 22fb775d99
commit 64cfa770fc
3 changed files with 815 additions and 32 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Apr 4 14:24:10 MST 2006 - jnorman@novell.com
- added timer to suppress viewing values(passwords) for micasa store
after a preset time in seconds.
-------------------------------------------------------------------
Mon Apr 3 8:45:10 MST 2006 - cmashayekhi@novell.com
- micasad is set to be off on install and be turned on from YAST

View File

@ -26,6 +26,8 @@ namespace Novell.CASA.GUI {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Threading;
using Gtk;
using Glade;
using Novell.CASA.MiCasa.Common;
@ -46,6 +48,10 @@ public class MiCasa : Store
ArrayList arrDeletedKeys = null;
private SecretStore m_store = null;
private String m_sRememberFor = "5";
private DateTime m_dtRememberMPUntil = DateTime.Now;
private Thread m_tRememberTimer = null;
private int m_iRememberSeconds = 5;
#region Glade Widgets
@ -98,7 +104,12 @@ public class MiCasa : Store
Gtk.Label labelLinkSecretID,
labelLinkKeyID,
label86,
label88;
label88,
labelRememberFor,
labelSeconds;
[Glade.Widget]
Gtk.SpinButton spinbuttonRememberFor;
#endregion
@ -472,29 +483,43 @@ public class MiCasa : Store
{
TreeViewColumn tvCol;
if( tvKeyValue.Model.IterNChildren() > 0 )
if( true == cbuttonShowPassword.Active)
{
// prompt user for MasterPassword
if (tvKeyValue.Model.IterNChildren() > 0)
{
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogLogin", null);
gxmlTemp.Autoconnect (this);
dialogLogin.TransientFor = dialogManageSecret;
if ((true == cbuttonShowPassword.Active) && (m_dtRememberMPUntil.CompareTo(DateTime.Now) > 0))
{
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
tvKeyValue.InsertColumn(tvCol, 1);
}
else if (true == cbuttonShowPassword.Active)
{
// prompt user for MasterPassword
label86.Text = "Enter your Master Password to view values";
entryMasterPassword3.Text="";
entryMasterPassword3.HasFocus = true;
label88.Hide();
entryMasterPassword4.Hide();
dialogLogin.Show();
}
else
{
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
tvKeyValue.InsertColumn(tvCol, 1);
}
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogLogin", null);
gxmlTemp.Autoconnect(this);
dialogLogin.TransientFor = dialogManageSecret;
label86.Text = "Enter your Master Password to view values";
entryMasterPassword3.Text = "";
entryMasterPassword3.HasFocus = true;
label88.Hide();
entryMasterPassword4.Hide();
labelRememberFor.Visible = true;
labelSeconds.Visible = true;
spinbuttonRememberFor.Visible = true;
spinbuttonRememberFor.Text = m_sRememberFor;
dialogLogin.Show();
}
else
{
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
tvKeyValue.InsertColumn(tvCol, 1);
}
}
}
public void okbuttonLogin_clicked(object abj, EventArgs args)
@ -508,7 +533,18 @@ public class MiCasa : Store
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
tvKeyValue.InsertColumn(tvCol, 1);
// get seconds to remember
m_sRememberFor = spinbuttonRememberFor.Text;
if (m_sRememberFor != null)
{
DateTime dtNow = DateTime.Now;
m_iRememberSeconds = int.Parse(m_sRememberFor);
m_dtRememberMPUntil = dtNow.AddSeconds(m_iRememberSeconds);
}
dialogLogin.Destroy();
if (m_iRememberSeconds > 0)
StartRememberTimer();
}
else
{
@ -539,6 +575,35 @@ public class MiCasa : Store
args.RetVal = true;
}
public void StartRememberTimer()
{
//if (m_tRememberTimer == null)
{
m_tRememberTimer = new Thread(new ThreadStart(ResetTimerThreadFn));
m_tRememberTimer.Start();
}
}
internal void ResetTimerThreadFn()
{
TreeViewColumn tvCol;
Thread.Sleep(m_iRememberSeconds * 1000);
if (tvKeyValue != null)
{
try
{
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
tvKeyValue.InsertColumn(tvCol, 1);
cbuttonShowPassword.Active = false;
}
catch
{
}
}
}
public void on_entryMasterPassword3_activate(object obj, EventArgs args)
{
if( "" != entryMasterPassword3.Text )

File diff suppressed because it is too large Load Diff