1257 lines
38 KiB
C#
1257 lines
38 KiB
C#
/***********************************************************************
|
|
*
|
|
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; version 2.1
|
|
* of the License.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, Novell, Inc.
|
|
*
|
|
* To contact Novell about this file by physical or electronic mail,
|
|
* you may find current contact information at www.novell.com.
|
|
*
|
|
***********************************************************************/
|
|
|
|
|
|
namespace Novell.CASA.GUI {
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Specialized;
|
|
using Gtk;
|
|
using Glade;
|
|
using Novell.CASA.MiCasa.Common;
|
|
using Novell.CASA.MiCasa.Communication;
|
|
|
|
public class Firefox : Store
|
|
{
|
|
Gtk.TreeStore tsSecretIDFirefox,
|
|
tsNativeInfoFirefox,
|
|
tsKeyValue;
|
|
|
|
CellRendererText cellEditable;
|
|
CellRendererToggle cellToggle;
|
|
|
|
ArrayList arrDeletedKeys = null;
|
|
bool isPasswordToggled;
|
|
|
|
public bool IS_STORE_AGGREGATED = false;
|
|
|
|
private int m_iRememberSeconds = 5;
|
|
private String m_sRememberFor = "5";
|
|
private Config m_config = null;
|
|
static Char[] SpecialCharacters = new Char[]{ '*', '\'', '\\', '&', '=', '<', '>' };
|
|
|
|
#region Glade Widgets
|
|
|
|
[Glade.Widget]
|
|
public Gtk.Window windowMain;
|
|
|
|
public Gtk.TreeView tvSecretIDFirefox;
|
|
|
|
[Glade.Widget]
|
|
Gtk.TreeView tvKeyValue,
|
|
tvNativeInfoFirefox;
|
|
|
|
[Glade.Widget]
|
|
Gtk.Dialog dialogNewSecret,
|
|
dialogManageSecret,
|
|
dialogLogin,
|
|
dialogConfirmDelete,
|
|
dialogFPMInvalidSecret,
|
|
dialogFPMIdenticalSecret,
|
|
dialogSpecialCharacter;
|
|
|
|
[Glade.Widget]
|
|
Gtk.Menu menuRightClick;
|
|
|
|
[Glade.Widget]
|
|
Gtk.Entry entrySecretID,
|
|
entryKey,
|
|
entryValue,
|
|
entryMasterPassword3,
|
|
entryMasterPassword4,
|
|
entryDeleteSecretID;
|
|
|
|
[Glade.Widget]
|
|
Gtk.CheckButton cbuttonShowPassword;
|
|
|
|
[Glade.Widget]
|
|
Gtk.Label label86,
|
|
label88;
|
|
|
|
[Glade.Widget]
|
|
Gtk.Button buttonNewAdd,
|
|
buttonNewRemove;
|
|
|
|
[Glade.Widget]
|
|
Gtk.MenuItem cmiNewSecret,
|
|
cmiNewKey,
|
|
cmiDelete,
|
|
cmiView,
|
|
cmiLink,
|
|
cmiCopy;
|
|
|
|
[Glade.Widget]
|
|
Gtk.Label labelRememberFor,
|
|
labelSeconds;
|
|
|
|
[Glade.Widget]
|
|
Gtk.SpinButton spinbuttonRememberFor;
|
|
#endregion
|
|
|
|
///#######################################################################
|
|
/// CONSTRUCTOR
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Firefox(Config config)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.Firefox() - BEGIN");
|
|
|
|
m_config = config;
|
|
/// SecretID TreeStore
|
|
tvSecretIDFirefox = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDFirefox");
|
|
tsSecretIDFirefox = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]), typeof(bool[]));
|
|
tvSecretIDFirefox.AppendColumn("Secret ID",new CellRendererText(),"text",0);
|
|
tvSecretIDFirefox.Model = tsSecretIDFirefox;
|
|
tvSecretIDFirefox.RowActivated += new RowActivatedHandler(OntvSecretIDFirefoxRowActivated);
|
|
tvSecretIDFirefox.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClicked);
|
|
tvSecretIDFirefox.CursorChanged += new EventHandler(OnCursorChanged);
|
|
/// NativeInfo TreeStore
|
|
tvNativeInfoFirefox = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvNativeInfoFirefox");
|
|
tsNativeInfoFirefox = new TreeStore(typeof(string), typeof(string));
|
|
tvNativeInfoFirefox.AppendColumn("NativeKey",new CellRendererText(),"text",0);
|
|
tvNativeInfoFirefox.AppendColumn("NativeValue",new CellRendererText(),"text",1);
|
|
tvNativeInfoFirefox.Model = tsNativeInfoFirefox;
|
|
tvNativeInfoFirefox.ModifyBase(StateType.Normal,new Gdk.Color(0xff,0xff,0xe6));
|
|
|
|
Logger.DbgLog("GUI:Firefox.Firefox() - END");
|
|
}
|
|
|
|
///#######################################################################
|
|
/// AGGREGATE STORE
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public override void AggregateStore()
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.AggregateStore() - BEGIN");
|
|
|
|
try
|
|
{
|
|
tsSecretIDFirefox.Clear();
|
|
tsNativeInfoFirefox.Clear();
|
|
StoreDataInterface.AggregateStore(Common.STORE_FIREFOX);
|
|
StoreDataInterface.ReadStore(Common.STORE_FIREFOX,ref tsSecretIDFirefox);
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.AggregateStore() - EXCEPTION" + exp.ToString());
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.AggregateStore() - END");
|
|
}
|
|
|
|
|
|
public override void ClearViewOnStore()
|
|
{
|
|
tsSecretIDFirefox.Clear();
|
|
tsNativeInfoFirefox.Clear();
|
|
}
|
|
|
|
///#######################################################################
|
|
/// DISPLAY NATIVE INFO
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
private void OnCursorChanged(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnCursorChanged() - BEGIN");
|
|
|
|
TreeModel model;
|
|
TreeIter iter;
|
|
string selected = null;
|
|
string[] NativeKeys = null,
|
|
NativeValues = null;
|
|
|
|
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
|
|
selected = (string) model.GetValue(iter, 0);
|
|
|
|
if( (null != selected) && (selected.Length > 0) )
|
|
{
|
|
tsNativeInfoFirefox.Clear();
|
|
/// Populate NativeInfo
|
|
tsNativeInfoFirefox.AppendValues("Profile Name","= "+ model.GetValue(iter,3));
|
|
NativeKeys = (string[]) model.GetValue(iter, 4);
|
|
NativeValues= (string[]) model.GetValue(iter, 5);
|
|
for( int i=0; i< NativeKeys.Length; i++ )
|
|
if( (NativeValues[i] != null) && (NativeValues[i] != "") )
|
|
tsNativeInfoFirefox.AppendValues(NativeKeys[i], "= "+NativeValues[i]);
|
|
tvNativeInfoFirefox.ShowAll();
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.OnCursorChanged() - END");
|
|
}
|
|
|
|
///#######################################################################
|
|
/// RIGHT-CLICK CONTEXT MENU
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void OnRightClicked(object obj, ButtonReleaseEventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnRightClicked() - BEGIN");
|
|
|
|
if( 3 == args.Event.Button )
|
|
{
|
|
try
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnRightClicked() - Context menu opened.");
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "menuRightClick", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
menuRightClick.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
|
|
|
|
if( 0 != tvSecretIDFirefox.Selection.CountSelectedRows() )
|
|
{
|
|
cmiNewSecret.Sensitive = cmiNewKey.Sensitive = cmiCopy.Sensitive = true;
|
|
cmiLink.Sensitive = false;
|
|
}
|
|
else
|
|
{
|
|
cmiNewSecret.Sensitive = true;
|
|
cmiNewKey.Sensitive = cmiDelete.Sensitive = cmiLink.Sensitive = cmiCopy.Sensitive = cmiView.Sensitive = false;
|
|
}
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnRightClicked() - EXCEPTION" + exp.ToString());
|
|
}
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.OnRightClicked() - END");
|
|
}
|
|
|
|
///#######################################################################
|
|
/// VIEW KEY-VALUES
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public override void ViewKeyValues()
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.ViewKeyValues() - BEGIN");
|
|
|
|
TreeModel model;
|
|
TreeIter iter;
|
|
string selected= null;
|
|
string[] keys = null,
|
|
values = null;
|
|
bool[] ispassword = null;
|
|
isPasswordToggled = false;
|
|
try
|
|
{
|
|
|
|
if( null == arrDeletedKeys )
|
|
arrDeletedKeys = new ArrayList();
|
|
else
|
|
arrDeletedKeys.Clear();
|
|
|
|
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
|
|
{
|
|
selected = (string) model.GetValue(iter, 0);
|
|
keys = (string[]) model.GetValue(iter, 1);
|
|
values = (string[]) model.GetValue(iter, 2);
|
|
ispassword = (bool[]) model.GetValue(iter, 6);
|
|
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogManageSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogManageSecret.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");
|
|
dialogManageSecret.Title = "Firefox - Manage Secret";
|
|
|
|
cellEditable = new CellRendererText();
|
|
cellEditable.Editable = true;
|
|
cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
|
|
|
|
cellToggle = new CellRendererToggle();
|
|
cellToggle.Activatable = true;
|
|
cellToggle.Toggled += new ToggledHandler(OnIsPasswordToggled);
|
|
|
|
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 ISPASSWORD:5
|
|
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool), typeof(string),typeof(bool));
|
|
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
|
|
tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
|
|
tvKeyValue.AppendColumn("Password", cellToggle, "active", 5);
|
|
tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4);
|
|
entrySecretID.MaxLength=1028;
|
|
entrySecretID.Text=selected;
|
|
|
|
for( int i=0; i< keys.Length; i++ )
|
|
{
|
|
if( (null != keys[i]) && (null != values[i]) )
|
|
tsKeyValue.AppendValues(keys[i], values[i], "********", false, "No", ispassword[i]);
|
|
}
|
|
tvKeyValue.Model = tsKeyValue;
|
|
}
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.ViewKeyValues() - EXCEPTION" + exp.ToString());
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.ViewKeyValues() - END");
|
|
}
|
|
|
|
/// <summary>
|
|
/// TOGGLE ISPASSWORD
|
|
///</summary>
|
|
public void OnIsPasswordToggled(object obj, ToggledArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnIsPasswordToggled() - BEGIN");
|
|
|
|
TreeIter iter;
|
|
bool old;
|
|
string keyID;
|
|
|
|
try
|
|
{
|
|
if (tsKeyValue.GetIter (out iter, new TreePath(args.Path)))
|
|
{
|
|
isPasswordToggled = true;
|
|
old = (bool)tsKeyValue.GetValue(iter,5);
|
|
keyID = tsKeyValue.GetValue(iter,0).ToString();
|
|
tsKeyValue.SetValue(iter, 5, !old);
|
|
if (tsKeyValue.IterNChildren()==2)
|
|
{
|
|
tsKeyValue.GetIterFirst(out iter);
|
|
do
|
|
{
|
|
if(!(tsKeyValue.GetValue(iter,0).ToString().Equals(keyID)))
|
|
tsKeyValue.SetValue(iter, 5, old);
|
|
}while (tsKeyValue.IterNext(ref iter));
|
|
}
|
|
|
|
}
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnIsPasswordToggled() - EXCEPTION:" + exp.ToString());
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.OnIsPasswordToggled() - END");
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// EDIT KEY-VALUE
|
|
/// </summary>
|
|
public void OnKeyValueEdited(object obj, EditedArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnKeyValueEdited() - BEGIN");
|
|
|
|
TreeModel model;
|
|
TreeIter iter;
|
|
object val;
|
|
string KeyName = null,
|
|
KeyValue = null;
|
|
bool KeyIsPassword;
|
|
string[] Keys = null,
|
|
Values = null;
|
|
|
|
try
|
|
{
|
|
tvKeyValue.Selection.GetSelected (out model, out iter);
|
|
val = tsKeyValue.GetValue(iter,0);
|
|
KeyName = val.ToString();
|
|
if( true == cbuttonShowPassword.Active )
|
|
val = tsKeyValue.GetValue(iter,1);
|
|
else
|
|
val = tsKeyValue.GetValue(iter,2);
|
|
KeyValue = val.ToString();
|
|
KeyIsPassword = (bool)tsKeyValue.GetValue(iter,5);
|
|
|
|
tvSecretIDFirefox.Selection.GetSelected (out model, out iter);
|
|
|
|
if( false == entrySecretID.Editable )
|
|
{
|
|
if( ("" != args.NewText) && (Common.MAX_LEN >= args.NewText.Length) && (KeyValue != args.NewText) )
|
|
{
|
|
//check for duplicate secret name
|
|
if (KeyIsPassword == false && entrySecretID.Text.EndsWith(")") == true)
|
|
{
|
|
string sname = entrySecretID.Text;
|
|
sname = sname.Remove ((sname.LastIndexOf(" (") + 2),sname.Length - (sname.LastIndexOf(" (") +2));
|
|
sname = String.Concat ( sname, args.NewText, ")");
|
|
if (sname != entrySecretID.Text && checkDuplicateSecretName(sname, null, ref tsSecretIDFirefox, 1))
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogFPMIdenticalSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogFPMIdenticalSecret.Show();
|
|
|
|
return;
|
|
}
|
|
}
|
|
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_MODIFY_KEY, KeyName, args.NewText, ref model, ref iter) )
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnKeyValueEdited() - StoreDataInterface.UpdateStore() succeeded");
|
|
tvKeyValue.Selection.GetSelected (out model, out iter);
|
|
tsKeyValue.SetValue(iter, 1, args.NewText);
|
|
tsKeyValue.SetValue(iter, 2, "********");
|
|
|
|
tvSecretIDFirefox.Selection.GetSelected (out model, out iter);
|
|
Keys = (string[]) model.GetValue(iter, 1);
|
|
Values = (string[]) model.GetValue(iter, 2);
|
|
for( int i=0; i< Keys.Length; i++ )
|
|
{
|
|
if( Keys[i] == KeyName )
|
|
{
|
|
Values[i] = args.NewText;
|
|
tsSecretIDFirefox.SetValue(iter, 2, Values);
|
|
break;
|
|
}
|
|
}
|
|
//AggregateStore();
|
|
}
|
|
else
|
|
Logger.DbgLog("GUI:Firefox.OnKeyValueEdited() - ERROR: STATUS_STORE_UPDATEFAILED");
|
|
}
|
|
}
|
|
else if( (Common.MAX_LEN >= args.NewText.Length) )
|
|
{
|
|
tvKeyValue.Selection.GetSelected (out model, out iter);
|
|
tsKeyValue.SetValue(iter, 1, args.NewText);
|
|
tsKeyValue.SetValue(iter, 2, "********");
|
|
}
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnKeyValueEdited() - EXCEPTION:" + exp.ToString());
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.OnKeyValueEdited() - END");
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// ADD BUTTON CLICKED
|
|
/// </summary>
|
|
public void on_buttonNewAdd_clicked(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewAdd_clicked() - BEGIN");
|
|
|
|
if( ("" != entryKey.Text) && ("" != entryValue.Text) )
|
|
{
|
|
TreeIter iterKey;
|
|
ArrayList arrKeys = null,
|
|
arrValues = null,
|
|
arrIsPassword = null;
|
|
object val = null;
|
|
arrKeys = new ArrayList();
|
|
arrValues = new ArrayList();
|
|
arrIsPassword = new ArrayList();
|
|
bool ispass = false;
|
|
|
|
if (tvKeyValue.Model.IterNChildren() == 2)
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogFPMInvalidSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogFPMInvalidSecret.Show();
|
|
return;
|
|
}
|
|
|
|
if(tsKeyValue.GetIterFirst(out iterKey))
|
|
{
|
|
do
|
|
{
|
|
val = tsKeyValue.GetValue(iterKey,0);
|
|
arrKeys.Add(val.ToString());
|
|
val = tsKeyValue.GetValue(iterKey,1);
|
|
arrValues.Add(val.ToString());
|
|
ispass = (bool)tsKeyValue.GetValue(iterKey,5);
|
|
if (ispass)
|
|
{
|
|
ispass = false;
|
|
arrIsPassword.Add(true);
|
|
}
|
|
else
|
|
{
|
|
ispass = true;
|
|
arrIsPassword.Add(false);
|
|
}
|
|
}
|
|
while( tsKeyValue.IterNext(ref iterKey) );
|
|
}
|
|
if( -1 == arrKeys.IndexOf(entryKey.Text) )
|
|
if( true == Common.ValidateString(entryKey.Text) )
|
|
{
|
|
iterKey = tsKeyValue.AppendValues(entryKey.Text, entryValue.Text, "********", true, "No",ispass);
|
|
entryKey.Text = entryValue.Text = "";
|
|
}
|
|
else
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogSpecialCharacter", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
//dialogSpecialCharacter.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("dialogNewSecret");
|
|
}
|
|
//tvKeyValue.Selection.SelectIter(iterKey);
|
|
entryKey.HasFocus = true;
|
|
}
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewAdd_clicked() - END");
|
|
|
|
}
|
|
|
|
public void on_buttonSCClose_clicked(object obj, EventArgs args)
|
|
{
|
|
dialogSpecialCharacter.Destroy();
|
|
}
|
|
|
|
public void on_buttonInvalidSecretClose_clicked(object obj, EventArgs args)
|
|
{
|
|
dialogFPMInvalidSecret.Destroy();
|
|
}
|
|
|
|
public void on_buttonIdenticalSecretClose_clicked(object obj, EventArgs args)
|
|
{
|
|
dialogFPMIdenticalSecret.Destroy();
|
|
}
|
|
|
|
/// <summary>
|
|
/// REMOVE BUTTON CLICKED
|
|
/// </summary>
|
|
public void on_buttonNewRemove_clicked(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewRemove_clicked() - BEGIN");
|
|
|
|
TreeModel modelKey;
|
|
TreeIter iterKey;
|
|
|
|
if(tvKeyValue.Selection.GetSelected (out modelKey, out iterKey)){
|
|
if( false == (bool)tsKeyValue.GetValue(iterKey,3) )
|
|
arrDeletedKeys.Add(tsKeyValue.GetValue(iterKey,0));
|
|
}
|
|
|
|
if( 0 != tvKeyValue.Selection.CountSelectedRows() )
|
|
{
|
|
TreeModel model;
|
|
TreeIter iter;
|
|
|
|
tvKeyValue.Selection.GetSelected (out model, out iter);
|
|
tsKeyValue.Remove(ref iter);
|
|
tvKeyValue.ColumnsAutosize();
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewRemove_clicked() - END");
|
|
}
|
|
|
|
public bool checkDuplicateSecretName(String secretID, String uname, ref TreeStore model, int method)
|
|
{
|
|
TreeIter iter;
|
|
switch(method)
|
|
{
|
|
case 1:
|
|
if(model.GetIterFirst(out iter))
|
|
{
|
|
do
|
|
{
|
|
if(String.Compare((string)model.GetValue(iter,0),secretID,true) == 0)
|
|
return true;
|
|
}while(model.IterNext(ref iter));
|
|
}
|
|
return false;
|
|
case 2:
|
|
if(model.GetIterFirst(out iter))
|
|
{
|
|
secretID = String.Concat(secretID, " (");
|
|
do
|
|
{
|
|
if(((string)model.GetValue(iter,0)).StartsWith(secretID))
|
|
return true;
|
|
}while(model.IterNext(ref iter));
|
|
}
|
|
return false;
|
|
case 3:
|
|
bool[] ispassarr;
|
|
string[] valarr;
|
|
if(model.GetIterFirst(out iter))
|
|
{
|
|
do
|
|
{
|
|
if(String.Compare((string)model.GetValue(iter,0),secretID,true) == 0)
|
|
{
|
|
ispassarr = (bool[])model.GetValue(iter, 6);
|
|
valarr = (string[])model.GetValue(iter, 2);
|
|
for(int i=0;i<ispassarr.Length;i++)
|
|
{
|
|
if(!ispassarr[i])
|
|
{
|
|
if(String.Compare(valarr[i],uname,true) == 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}while(model.IterNext(ref iter));
|
|
}
|
|
return false;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// MANAGE SECRET ID DIALOG OK-BUTTON CLICKED
|
|
/// </summary>
|
|
public void on_buttonManageOk_clicked(object obj, EventArgs args)
|
|
{
|
|
TreeModel modelSecret;
|
|
TreeIter iterSecret,
|
|
iterKey;
|
|
string NewKey = null,
|
|
NewValue = null;
|
|
bool NewIsPassword;
|
|
string[] strDeletedKeys = null;
|
|
bool dirtyBit = false;
|
|
bool doCheck = false;
|
|
//ArrayList arrKeys = null,
|
|
// arrValues = null;
|
|
String sname = null;
|
|
|
|
try
|
|
{
|
|
if (tvKeyValue.Model.IterNChildren() == 1)
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogFPMInvalidSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogFPMInvalidSecret.Show();
|
|
return;
|
|
}
|
|
|
|
if( (0 == tvKeyValue.Model.IterNChildren()) && tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret) )
|
|
{
|
|
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_DELETE_SECRET, "", "", ref modelSecret, ref iterSecret) )
|
|
{
|
|
tsSecretIDFirefox.Remove(ref iterSecret);
|
|
tvSecretIDFirefox.ColumnsAutosize();
|
|
tsNativeInfoFirefox.Clear();
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_SECRET_SUCCEEDED");
|
|
}
|
|
else
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_SECRET_FAILED");
|
|
AggregateStore();
|
|
}
|
|
else
|
|
{
|
|
//check for duplicate secret names before updating the store
|
|
tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret);
|
|
sname = (string)modelSecret.GetValue(iterSecret, 0);
|
|
doCheck = sname.EndsWith(")");
|
|
if( tsKeyValue.GetIterFirst(out iterKey) && doCheck == true)
|
|
{
|
|
do
|
|
{
|
|
NewValue = (string) tsKeyValue.GetValue(iterKey,1);
|
|
NewIsPassword = (bool) tsKeyValue.GetValue(iterKey,5);
|
|
dirtyBit = (bool) tsKeyValue.GetValue(iterKey,3);
|
|
|
|
if((true == dirtyBit && false == NewIsPassword) || ( false == NewIsPassword && true == isPasswordToggled))
|
|
{
|
|
sname = sname.Remove ((sname.LastIndexOf(" (") + 2),sname.Length - (sname.LastIndexOf(" (") +2));
|
|
sname = String.Concat ( sname, NewValue, ")");
|
|
if (sname != entrySecretID.Text && checkDuplicateSecretName(sname, null, ref tsSecretIDFirefox, 1))
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogFPMIdenticalSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogFPMIdenticalSecret.Show();
|
|
return;
|
|
}
|
|
break;
|
|
}
|
|
}while(tsKeyValue.IterNext(ref iterKey));
|
|
}
|
|
|
|
if( (null != arrDeletedKeys) && (arrDeletedKeys.Count > 0) )
|
|
{
|
|
tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret);
|
|
strDeletedKeys = (string[])arrDeletedKeys.ToArray(typeof(string));
|
|
|
|
for( int i=0; i < strDeletedKeys.Length; i++)
|
|
{
|
|
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_DELETE_KEY, strDeletedKeys[i], null, ref modelSecret, ref iterSecret) )
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_KEY_SUCCEEDED.");
|
|
else
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - DELETE_KEY_FAILED.");
|
|
}
|
|
arrDeletedKeys.Clear();
|
|
}
|
|
|
|
if( tsKeyValue.GetIterFirst(out iterKey) && tvSecretIDFirefox.Selection.GetSelected (out modelSecret, out iterSecret) )
|
|
{
|
|
do
|
|
{
|
|
NewKey = (string) tsKeyValue.GetValue(iterKey,0);
|
|
NewValue = (string) tsKeyValue.GetValue(iterKey,1);
|
|
NewIsPassword = (bool) tsKeyValue.GetValue(iterKey,5);
|
|
dirtyBit = (bool) tsKeyValue.GetValue(iterKey,3);
|
|
|
|
if( true == dirtyBit )
|
|
{
|
|
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_ADD_KEY, NewKey, NewValue, NewIsPassword, ref modelSecret, ref iterSecret) )
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - ADD_KEY_VALUE_SUCCEEDED.");
|
|
else
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - ADD_KEY_VALUE_FAILED.");
|
|
}
|
|
else if(true == isPasswordToggled)
|
|
{
|
|
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_MODIFY_KEY, NewKey, NewValue, NewIsPassword, ref modelSecret, ref iterSecret))
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - SET_PASSWORD_STATE_SUCCEEDED.");
|
|
else
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - SET_PASSWORD_STATE_FAILED.");
|
|
}
|
|
}
|
|
while( tsKeyValue.IterNext(ref iterKey) );
|
|
}
|
|
AggregateStore();
|
|
}
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonManageOk_clicked() - EXCEPTION:" + exp.ToString());
|
|
}
|
|
tsKeyValue.Dispose();
|
|
dialogManageSecret.Destroy();
|
|
}
|
|
|
|
/// <summary>
|
|
/// MANAGE SECRET ID DIALOG CANCEL-BUTTON CLICKED
|
|
/// </summary>
|
|
public void on_buttonManageCancel_clicked(object obj, EventArgs args)
|
|
{
|
|
tsKeyValue.Dispose();
|
|
dialogManageSecret.Destroy();
|
|
}
|
|
|
|
public void on_buttonhelpEditSecret_clicked(object obj, EventArgs args)
|
|
{
|
|
Common.ShowHelpUrl("EditingSecrets.html");
|
|
}
|
|
|
|
///#######################################################################
|
|
/// <summary>
|
|
/// SHOW PASSWORD CHECK BUTTON CLICKED
|
|
/// </summary>
|
|
public void on_cbuttonShowPassword_toggled(object obj, EventArgs args)
|
|
{
|
|
TreeViewColumn tvCol;
|
|
|
|
if (tvKeyValue.Model.IterNChildren() > 0)
|
|
{
|
|
if ((true == cbuttonShowPassword.Active)
|
|
&& (CommonGUI.GetRememberMPUntil().CompareTo(DateTime.Now) > 0))
|
|
{
|
|
// set and start the timer if needed
|
|
TimeSpan ts = CommonGUI.GetRememberMPUntil().Subtract(DateTime.Now);
|
|
m_iRememberSeconds = ts.Seconds;
|
|
StartRememberTimer();
|
|
|
|
// display the values
|
|
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
|
|
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
|
|
tvKeyValue.InsertColumn(tvCol, 1);
|
|
}
|
|
else if (true == cbuttonShowPassword.Active)
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogLogin", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogLogin.TransientFor = dialogManageSecret;
|
|
|
|
label86.Text = "Enter your Master Password to view passwords";
|
|
entryMasterPassword3.Text="";
|
|
entryMasterPassword3.HasFocus = true;
|
|
label88.Hide();
|
|
entryMasterPassword4.Hide();
|
|
labelRememberFor.Visible = true;
|
|
labelSeconds.Visible = true;
|
|
spinbuttonRememberFor.Visible = true;
|
|
spinbuttonRememberFor.Text = m_config.GetConfigSetting(CommonGUI.REMEMBER_SETTING, 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)
|
|
{
|
|
TreeViewColumn tvCol;
|
|
|
|
if( tvKeyValue.Model.IterNChildren() > 0 )
|
|
|
|
if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) )
|
|
{
|
|
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);
|
|
CommonGUI.SetRememberMPUntil(dtNow.AddSeconds(m_iRememberSeconds));
|
|
}
|
|
|
|
// save off remember time if user changed it
|
|
string sSaveTimed = m_config.GetConfigSetting(CommonGUI.REMEMBER_SETTING, "5");
|
|
if (!sSaveTimed.Equals(m_sRememberFor))
|
|
{
|
|
m_config.SetConfigSetting(CommonGUI.REMEMBER_SETTING,m_sRememberFor);
|
|
m_config.WriteConfig();
|
|
}
|
|
dialogLogin.Destroy();
|
|
if (m_iRememberSeconds > 0)
|
|
StartRememberTimer();
|
|
}
|
|
else
|
|
{
|
|
// prompt user
|
|
MessageDialog md=new MessageDialog(dialogLogin,Gtk.DialogFlags.Modal,
|
|
Gtk.MessageType.Warning,
|
|
Gtk.ButtonsType.Ok,
|
|
"Master Password incorrect");
|
|
|
|
md.Response +=new ResponseHandler(md_Response2);
|
|
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
|
|
md.Modal = true;
|
|
md.Show();
|
|
}
|
|
}
|
|
|
|
public void closebuttonLogin_clicked(object abj, EventArgs args)
|
|
{
|
|
cbuttonShowPassword.Active = false;
|
|
dialogLogin.Destroy();
|
|
}
|
|
|
|
public void OnDialogLoginDeleted(object obj, DeleteEventArgs args)
|
|
{
|
|
cbuttonShowPassword.Active = false;
|
|
dialogLogin.Destroy();
|
|
args.RetVal = true;
|
|
}
|
|
|
|
private bool bTimerActive = false;
|
|
public void StartRememberTimer()
|
|
{
|
|
if (!bTimerActive)
|
|
{
|
|
GLib.Timeout.Add ((uint)(m_iRememberSeconds * 1000), new GLib.TimeoutHandler (update_gui));
|
|
bTimerActive = true;
|
|
}
|
|
}
|
|
|
|
private bool update_gui()
|
|
{
|
|
TreeViewColumn tvCol;
|
|
try
|
|
{
|
|
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
|
|
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
|
|
tvKeyValue.InsertColumn(tvCol, 1);
|
|
cbuttonShowPassword.Active = false;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//Console.WriteLine(e.ToString());
|
|
}
|
|
bTimerActive = false;
|
|
|
|
return false;
|
|
}
|
|
|
|
public void on_helpbuttonAuthentication_clicked(object obj, EventArgs args)
|
|
{
|
|
Common.ShowHelpUrl("CASAMasterPasswordAuthentication.htm");
|
|
}
|
|
|
|
public void on_entryMasterPassword3_activate(object obj, EventArgs args)
|
|
{
|
|
if( "" != entryMasterPassword3.Text )
|
|
okbuttonLogin_clicked(obj, args);
|
|
}
|
|
|
|
public void on_entryMasterPassword4_activate(object obj, EventArgs args)
|
|
{
|
|
okbuttonLogin_clicked(obj, args);
|
|
}
|
|
|
|
private void md_Response2(object o, ResponseArgs args)
|
|
{
|
|
MessageDialog md = (MessageDialog)o;
|
|
if (md != null)
|
|
{
|
|
md.Destroy();
|
|
entryMasterPassword3.Text="";
|
|
entryMasterPassword3.HasFocus = true;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// SECRET ID DOUBLE CLICKED
|
|
/// </summary>
|
|
private void OntvSecretIDFirefoxRowActivated( object obj, RowActivatedArgs args )
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OntvSecretIDFirefoxRowActivated() - ViewKeyValues() called.");
|
|
|
|
ViewKeyValues();
|
|
}
|
|
|
|
/// <summary>
|
|
/// VIEW KEY-VALUES CALLED VIA MAIN-MENU/CONTEXT-MENU
|
|
/// </summary>
|
|
public void OnViewActivated(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnViewActivated() - ViewKeyValues() called.");
|
|
|
|
ViewKeyValues();
|
|
}
|
|
|
|
public void on_buttonNewOk_clicked(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - BEGIN");
|
|
|
|
TreeModel modelSecret;
|
|
TreeIter iterSecret,
|
|
iterKey;
|
|
string NewKey = null,
|
|
NewValue = null;
|
|
bool NewIsPassword;
|
|
string[] Keys = null,
|
|
Values = null,
|
|
NativeKeys = null,
|
|
NativeValues = null;
|
|
bool[] IsPassword =null;
|
|
object val = null;
|
|
string sname = null;
|
|
ArrayList arrKeys = null,
|
|
arrValues = null,
|
|
arrIsPassword = null;
|
|
if (tvKeyValue.Model.IterNChildren() == 1)
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogFPMInvalidSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogFPMInvalidSecret.Show();
|
|
return;
|
|
}
|
|
if ( true == entrySecretID.Editable && false == ValidateString(entrySecretID.Text) )
|
|
{
|
|
/*// prompt user
|
|
MessageDialog md=new MessageDialog(this.windowMain,Gtk.DialogFlags.Modal,
|
|
Gtk.MessageType.Warning,
|
|
Gtk.ButtonsType.Ok,
|
|
"Secret ID may not contain \"*\"");
|
|
|
|
md.Response += new ResponseHandler(md_Response);
|
|
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
|
|
md.Modal = true;
|
|
md.Show();*/
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogSpecialCharacter", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
entrySecretID.HasFocus = true;
|
|
return;
|
|
}
|
|
|
|
if( (true == entrySecretID.Editable) && ("" != entrySecretID.Text) && (tvKeyValue.Model.IterNChildren() > 0) )
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - Adding New Secrets and KeyValues.");
|
|
|
|
arrKeys = new ArrayList();
|
|
arrValues = new ArrayList();
|
|
arrIsPassword = new ArrayList();
|
|
try
|
|
{
|
|
if(tsKeyValue.GetIterFirst(out iterKey))
|
|
{
|
|
do
|
|
{
|
|
val = tsKeyValue.GetValue(iterKey,0);
|
|
NewKey = val.ToString();
|
|
val = tsKeyValue.GetValue(iterKey,1);
|
|
NewValue = val.ToString();
|
|
NewIsPassword = (bool)tsKeyValue.GetValue(iterKey,5);
|
|
if( -1 == (arrKeys.IndexOf(NewKey)) )
|
|
{
|
|
arrKeys.Add(NewKey);
|
|
arrValues.Add(NewValue);
|
|
arrIsPassword.Add(NewIsPassword);
|
|
}
|
|
if(NewIsPassword == false)
|
|
{
|
|
sname = entrySecretID.Text;
|
|
if (checkDuplicateSecretName(entrySecretID.Text, null, ref tsSecretIDFirefox, 1))
|
|
{
|
|
if (checkDuplicateSecretName(entrySecretID.Text, NewValue, ref tsSecretIDFirefox, 3))
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogFPMIdenticalSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogFPMIdenticalSecret.Show();
|
|
|
|
return;
|
|
}
|
|
|
|
}
|
|
else if(checkDuplicateSecretName(entrySecretID.Text, null, ref tsSecretIDFirefox, 2))
|
|
{
|
|
sname = String.Concat ( sname, " (", NewValue, ")");
|
|
|
|
if (checkDuplicateSecretName(sname, null, ref tsSecretIDFirefox, 1))
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogFPMIdenticalSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogFPMIdenticalSecret.Show();
|
|
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
while( tsKeyValue.IterNext(ref iterKey) );
|
|
|
|
Keys = (string[])arrKeys.ToArray(typeof(string));
|
|
Values = (string[])arrValues.ToArray(typeof(string));
|
|
IsPassword = (bool[])arrIsPassword.ToArray(typeof(bool));
|
|
|
|
NativeKeys = new string[Common.MAX_NATIVE_ELEMENTS];
|
|
NativeValues = new string[Common.MAX_NATIVE_ELEMENTS];
|
|
NativeKeys[Common.INDEX_NATIVEINFO_FOLDERNAME] = Common.NATIVEINFO_FOLDERNAME;
|
|
NativeKeys[Common.INDEX_NATIVEINFO_TYPEID] = Common.NATIVEINFO_TYPEID;
|
|
NativeKeys[Common.INDEX_NATIVEINFO_SYNC] = Common.NATIVEINFO_SYNC;
|
|
NativeKeys[Common.INDEX_NATIVEINFO_SYNCTYPE] = Common.NATIVEINFO_SYNCTYPE;
|
|
NativeKeys[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = Common.NATIVEINFO_MODIFIEDTIME;
|
|
NativeValues[Common.INDEX_NATIVEINFO_FOLDERNAME] = null;
|
|
NativeValues[Common.INDEX_NATIVEINFO_TYPEID] = "Signon";
|
|
NativeValues[Common.INDEX_NATIVEINFO_SYNC] = null;
|
|
NativeValues[Common.INDEX_NATIVEINFO_SYNCTYPE] = null;
|
|
NativeValues[Common.INDEX_NATIVEINFO_MODIFIEDTIME] = null;
|
|
iterSecret = tsSecretIDFirefox.AppendValues(sname, Keys, Values, DataEngines.AD.GetDefaultProfileName(Common.STORE_FIREFOX), NativeKeys, NativeValues, IsPassword);
|
|
modelSecret = tvSecretIDFirefox.Model;
|
|
|
|
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_ADD_SECRET, "", "", ref modelSecret, ref iterSecret) )
|
|
{
|
|
AggregateStore();
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - ADD_NEW_SECRET_SUCCEEDED.");
|
|
}
|
|
else
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - ERROR: ADD_NEW_SECRET_FAILED");
|
|
}
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - EXCEPTION:" + exp.ToString());
|
|
}
|
|
tsKeyValue.Dispose();
|
|
dialogNewSecret.Destroy();
|
|
}
|
|
Logger.DbgLog("GUI:Firefox.on_buttonNewOk_clicked() - END");
|
|
}
|
|
|
|
public void on_buttonNewCancel_clicked(object obj, EventArgs args)
|
|
{
|
|
dialogNewSecret.Destroy();
|
|
}
|
|
|
|
public void on_helpbuttonNewSecret_clicked(object obj, EventArgs args)
|
|
{
|
|
Common.ShowHelpUrl("AddNewSecrets.htm");
|
|
}
|
|
|
|
///#######################################################################
|
|
/// ADD NEW SECRET
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void OnNewSecretActivated(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnNewSecretActivated() - BEGIN");
|
|
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogNewSecret", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogNewSecret.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");
|
|
dialogNewSecret.Title = "Firefox - New Secret";
|
|
|
|
cellEditable = new CellRendererText();
|
|
cellEditable.Editable = true;
|
|
cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
|
|
|
|
cellToggle = new CellRendererToggle();
|
|
cellToggle.Activatable = true;
|
|
cellToggle.Toggled += new ToggledHandler(OnIsPasswordToggled);
|
|
|
|
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 ISPASSWORD:5
|
|
tsKeyValue = new TreeStore(typeof(string),typeof(string), typeof(string), typeof(bool), typeof(string),typeof(bool));
|
|
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
|
|
tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
|
|
tvKeyValue.AppendColumn("Password", cellToggle,"active",5);
|
|
tvKeyValue.AppendColumn("Linked",new CellRendererText(),"text",4);
|
|
tvKeyValue.Model = tsKeyValue;
|
|
tsKeyValue.Clear();
|
|
entrySecretID.HasFocus = true;
|
|
entrySecretID.Text = "";
|
|
|
|
Logger.DbgLog("GUI:Firefox.OnNewSecretActivated() - END");
|
|
}
|
|
|
|
///#######################################################################
|
|
/// ADD NEW KEY-VALUES TO EXISTING SECRET
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void OnNewKeyActivated(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnNewKeyActivated() - BEGIN");
|
|
|
|
ViewKeyValues();
|
|
|
|
Logger.DbgLog("GUI:Firefox.OnNewKeyActivated() - END");
|
|
}
|
|
|
|
///#######################################################################
|
|
/// DELETE SECRET
|
|
/// <summary>
|
|
/// DELETE Secret
|
|
/// </summary>
|
|
public void OnDeleteActivated(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.OnDeleteActivated() - BEGIN");
|
|
if( 0 != tvSecretIDFirefox.Selection.CountSelectedRows() )
|
|
{
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogConfirmDelete", null);
|
|
gxmlTemp.Autoconnect (this);
|
|
dialogConfirmDelete.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");
|
|
dialogConfirmDelete.Title = "Firefox - Delete Secret";
|
|
|
|
TreeModel model;
|
|
TreeIter iter;
|
|
string selected = null;
|
|
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
|
|
{
|
|
selected = (string) model.GetValue (iter, 0);
|
|
if( (null != selected) && (selected.Length > 0) )
|
|
entryDeleteSecretID.Text = selected;
|
|
}
|
|
}
|
|
Logger.DbgLog("GUI:Firefox.OnDeleteActivated() - END");
|
|
}
|
|
|
|
public void on_buttonYes_clicked(object obj, EventArgs args)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - BEGIN");
|
|
|
|
TreeModel model;
|
|
TreeIter iter;
|
|
|
|
try
|
|
{
|
|
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
|
|
{
|
|
if( Common.STATUS_SUCCESS == StoreDataInterface.UpdateStore(Common.STORE_FIREFOX, Common.OPERATION_DELETE_SECRET, "", "", ref model, ref iter) )
|
|
{
|
|
tsSecretIDFirefox.Remove(ref iter);
|
|
tvSecretIDFirefox.ColumnsAutosize();
|
|
tsNativeInfoFirefox.Clear();
|
|
dialogConfirmDelete.Destroy();
|
|
AggregateStore();
|
|
Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - DELETE_SECRET_SUCCEEDED");
|
|
|
|
}
|
|
else
|
|
Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - DELETE_SECRET_FAILED");
|
|
}
|
|
}
|
|
catch(Exception exp)
|
|
{
|
|
Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - EXCEPTION:" + exp.ToString());
|
|
}
|
|
|
|
Logger.DbgLog("GUI:Firefox.on_buttonYes_clicked() - END");
|
|
}
|
|
|
|
public void on_buttonNo_clicked(object obj, EventArgs args)
|
|
{
|
|
dialogConfirmDelete.Destroy();
|
|
}
|
|
|
|
///#######################################################################
|
|
/// LINK
|
|
/// <summary>
|
|
/// LINK Key-Values
|
|
/// </summary>
|
|
public void OnLinkActivated(object obj, EventArgs args)
|
|
{
|
|
|
|
}
|
|
|
|
///#######################################################################
|
|
/// COPY
|
|
/// <summary>
|
|
/// COPY Key-Values
|
|
/// </summary>
|
|
public void OnCopyActivated(object obj, EventArgs args)
|
|
{
|
|
TreeModel model;
|
|
TreeIter iter;
|
|
|
|
try
|
|
{
|
|
if( tvSecretIDFirefox.Selection.GetSelected (out model, out iter) )
|
|
{
|
|
string selected = null;
|
|
string[] saKeys, saValues;
|
|
|
|
selected = (string) model.GetValue (iter, 0);
|
|
saKeys = (string[]) model.GetValue(iter, 1);
|
|
saValues = (string[]) model.GetValue(iter, 2);
|
|
|
|
CopySecret cs = new CopySecret(selected, saKeys, saValues);
|
|
cs.Show();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
///#######################################################################
|
|
/// VALIDATE STRINGS FOR SPECIAL CHARACTERS
|
|
|
|
/// <summary>
|
|
/// Validate strings for special characters
|
|
/// </summary>
|
|
public static bool ValidateString(string sString)
|
|
{
|
|
if( -1 == sString.IndexOfAny(SpecialCharacters) )
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
}
|
|
}
|
|
///##################################################################
|
|
/// END OF FILE
|
|
///##################################################################
|