diff --git a/CASA/gui/MiCasa.cs b/CASA/gui/MiCasa.cs
index a445a7f3..1a7ab9ac 100644
--- a/CASA/gui/MiCasa.cs
+++ b/CASA/gui/MiCasa.cs
@@ -75,10 +75,12 @@ public class MiCasa : Store
dialogConfirmDelete,
dialogLogin,
dialogLinkKeyValue,
- dialogSpecialCharacter;
+ dialogSpecialCharacter,
+ dialogDecode;
[Glade.Widget]
- Gtk.Menu menuRightClick;
+ Gtk.Menu menuRightClick,
+ menuRightClickKeyValue;
[Glade.Widget]
Gtk.Entry entrySecretID,
@@ -91,14 +93,17 @@ public class MiCasa : Store
[Glade.Widget]
Gtk.CheckButton cbuttonShowPassword,
- checkbuttonShowDeleteDialog;
-
- [Glade.Widget]
- Gtk.MenuItem cmiNewKey,
- cmiDelete,
- cmiView,
- cmiLink,
- cmiCopy;
+ checkbuttonShowDeleteDialog;
+
+ [Glade.Widget]
+ Gtk.MenuItem cmiNewKey,
+ cmiDelete,
+ cmiView,
+ cmiLink,
+ cmiCopy,
+ menuItemLinkKey,
+ menuItemDecodeValue;
+
[Glade.Widget]
Gtk.Notebook notebook2;
@@ -112,7 +117,20 @@ public class MiCasa : Store
labelSeconds;
[Glade.Widget]
- Gtk.SpinButton spinbuttonRememberFor;
+ Gtk.SpinButton spinbuttonRememberFor;
+
+ [Glade.Widget]
+ Gtk.TextView textviewEncoded,
+ textviewClear;
+
+ [Glade.Widget]
+ Gtk.Button bttnDecode,
+ bttnEncode,
+ bttnExpand,
+ bttnCloseDecode;
+
+ [Glade.Widget]
+ Gtk.ScrolledWindow scrolledwindowEncoded;
#endregion
@@ -296,7 +314,10 @@ public class MiCasa : Store
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4);
- tvKeyValue.RowActivated += new RowActivatedHandler(tvKeyValue_RowActivated);
+ tvKeyValue.RowActivated += new RowActivatedHandler(tvKeyValue_RowActivated);
+
+
+ //tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue);
entrySecretID.Text = selected;
SecretStore ss = GetMiCasaStore();
@@ -514,6 +535,7 @@ public class MiCasa : Store
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
tvKeyValue.InsertColumn(tvCol, 1);
+ tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue);
}
else if (true == cbuttonShowPassword.Active)
{
@@ -541,6 +563,7 @@ public class MiCasa : Store
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
tvKeyValue.InsertColumn(tvCol, 1);
+ tvKeyValue.ButtonReleaseEvent -= (OnRightClickedKeyValue);
}
}
}
@@ -553,9 +576,10 @@ public class MiCasa : Store
if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) )
{
- tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
- tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
- tvKeyValue.InsertColumn(tvCol, 1);
+ tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
+ tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
+ tvKeyValue.InsertColumn(tvCol, 1);
+ tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue);
// get seconds to remember
m_sRememberFor = spinbuttonRememberFor.Text;
@@ -626,7 +650,8 @@ public class MiCasa : Store
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
tvKeyValue.InsertColumn(tvCol, 1);
- cbuttonShowPassword.Active = false;
+ cbuttonShowPassword.Active = false;
+ tvKeyValue.ButtonReleaseEvent -= (OnRightClickedKeyValue);
}
catch (Exception e)
{
@@ -1335,6 +1360,139 @@ public class MiCasa : Store
md.Destroy();
}
}
+
+ // handlers for keyvalue context menu
+ public void OnRightClickedKeyValue(object obj, ButtonReleaseEventArgs args)
+ {
+ Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - BEGIN");
+
+ if (3 == args.Event.Button)
+ {
+ try
+ {
+ Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - Context menu opened.");
+ Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "menuRightClickKeyValue", null);
+ gxmlTemp.Autoconnect(this);
+ menuRightClickKeyValue.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
+ }
+ catch (Exception exp)
+ {
+ Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - EXCEPTION:" + exp.ToString());
+ }
+ }
+ Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - BEGIN");
+ }
+
+ private void on_menuItemLinkKey_activate(object o, EventArgs args)
+ {
+ // display link dialog
+ tvKeyValue_RowActivated(o, null);
+
+ }
+
+ private void on_menuItemDecodeValue_activate(object o, EventArgs args)
+ {
+ // get selected key/value
+ // display decode window
+ TreeModel model;
+ TreeIter iter;
+ string selected=null;
+ string value = null;
+
+ if (tvKeyValue.Selection.GetSelected(out model, out iter))
+ {
+ selected = (string)model.GetValue(iter, 0);
+ value = (string)model.GetValue(iter, 1);
+
+ if ((value == null) || (value.Length <1))
+ {
+ // read value from store
+ SecretStore ss = GetMiCasaStore();
+ 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];
+
+ Array.Copy(baValue, 13, baTarget, 0, baValue.Length - 16);
+ try
+ {
+ baValue = Convert.FromBase64String(System.Text.Encoding.ASCII.GetString(baTarget));
+ value = System.Text.Encoding.ASCII.GetString(baValue);
+ }
+ catch (Exception e)
+ {
+ value = e.ToString();
+ }
+
+ }
+
+ if (selected != null && selected.Length > 0)
+ {
+ Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogDecode", null);
+ gxmlTemp.Autoconnect(this);
+
+ // display values
+ textviewClear.Buffer.Text = value;
+
+ // hook up button handlers
+ bttnDecode.Clicked += new EventHandler(bttnDecode_Clicked);
+ bttnEncode.Clicked += new EventHandler(bttnEncode_Clicked);
+ bttnExpand.Clicked += new EventHandler(bttnExpand_Clicked);
+ dialogDecode.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("dialogManageSecret");
+ dialogDecode.Modal = true;
+ dialogDecode.Show();
+ }
+ }
+ }
+
+ void bttnExpand_Clicked(object sender, EventArgs e)
+ {
+ bttnDecode.Visible =
+ bttnEncode.Visible =
+ textviewEncoded.Visible =
+ scrolledwindowEncoded.Visible = !bttnDecode.Visible;
+
+ if (bttnDecode.Visible)
+ {
+ bttnExpand.Label = " << ";
+ }
+ else
+ {
+ bttnExpand.Label = " >> ";
+ }
+ }
+
+ void bttnEncode_Clicked(object sender, EventArgs e)
+ {
+ string sClear = textviewClear.Buffer.Text.Trim();
+ if (sClear.Length > 0)
+ {
+ textviewEncoded.Buffer.Clear();
+ textviewEncoded.Buffer.Text = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(sClear));
+ }
+ }
+
+ void bttnDecode_Clicked(object sender, EventArgs e)
+ {
+ string sEncoded = textviewEncoded.Buffer.Text.Trim();
+ if (sEncoded.Length > 0)
+ {
+ char[] array = sEncoded.ToCharArray();
+ byte[] bytes = Convert.FromBase64CharArray(array, 0, array.Length);
+ textviewClear.Buffer.Text = System.Text.Encoding.ASCII.GetString(bytes);
+ }
+ }
+
+ private void on_bttnCloseDecode_clicked(object sender, EventArgs args)
+ {
+ if (dialogDecode != null)
+ {
+ dialogDecode.Destroy();
+ }
+
+ }
}
}
///##################################################################
diff --git a/CASA/gui/images/casa.glade b/CASA/gui/images/casa.glade
index 95f48429..4c65a1fa 100644
--- a/CASA/gui/images/casa.glade
+++ b/CASA/gui/images/casa.glade
@@ -56,7 +56,7 @@
True
-
+
True
gtk-new
1
@@ -78,7 +78,7 @@
-
+
True
gtk-new
1
@@ -99,7 +99,7 @@
-
+
True
gtk-new
1
@@ -125,7 +125,7 @@
-
+
True
gtk-refresh
1
@@ -152,7 +152,7 @@
-
+
True
gtk-dialog-authentication
1
@@ -173,7 +173,7 @@
-
+
True
gtk-open
1
@@ -194,7 +194,7 @@
-
+
True
gtk-delete
1
@@ -221,7 +221,7 @@
-
+
True
gtk-floppy
1
@@ -242,7 +242,7 @@
-
+
True
gtk-open
1
@@ -264,13 +264,13 @@