diff --git a/CASA/gui/CASAManager.csproj b/CASA/gui/CASAManager.csproj
index cc37bdc4..6af1cf2a 100644
--- a/CASA/gui/CASAManager.csproj
+++ b/CASA/gui/CASAManager.csproj
@@ -185,6 +185,11 @@
SubType = "Code"
BuildAction = "Compile"
/>
+
+
-
/// ********************************************************************
/// private void HandleQuit()
diff --git a/CASA/gui/CommonGUI.cs b/CASA/gui/CommonGUI.cs
index 6f5cdd61..7ea8c990 100644
--- a/CASA/gui/CommonGUI.cs
+++ b/CASA/gui/CommonGUI.cs
@@ -39,6 +39,9 @@ namespace Novell.CASA.GUI
public class CommonGUI
{
+ public static string HINT_DIR = "Export Directory";
+ public static string HINT_FILENAME = "Export Filename";
+
[Glade.Widget]
Gtk.Label label86,
label88;
@@ -155,7 +158,7 @@ namespace Novell.CASA.GUI
{
// prompt user
MessageDialog md=new MessageDialog(
- mainWindow,Gtk.DialogFlags.Modal,
+ mainWindow,Gtk.DialogFlags.Modal,
Gtk.MessageType.Warning,
Gtk.ButtonsType.Ok,
"Master Password entered is incorrect");
@@ -212,6 +215,106 @@ namespace Novell.CASA.GUI
mTrayInstance.UpdateTrayIcon(false);
}
}
+
+ public static string FileChooser(FileChooserAction action, String sWindowTitle, String sCurrentFolder, String sHintFileName)
+ {
+ FileChooserDialog chooser = new FileChooserDialog (sWindowTitle,
+ null,
+ action);
+
+ if (sCurrentFolder != null)
+ chooser.SetCurrentFolder(sCurrentFolder);
+
+ if (sHintFileName != null)
+ chooser.SetFilename(sCurrentFolder+sHintFileName);
+
+
+ // set location
+ chooser.SetPosition(Gtk.WindowPosition.CenterAlways);
+ chooser.AddButton (Stock.Cancel, ResponseType.Cancel);
+
+ if (action == FileChooserAction.Open)
+ chooser.AddButton (Stock.Open, ResponseType.Ok);
+ else
+ chooser.AddButton(Stock.Save, ResponseType.Ok);
+
+ int response = chooser.Run ();
+
+ string ret = null;
+ if ((ResponseType) response == ResponseType.Ok)
+ {
+ ret = chooser.Uri;
+ }
+
+/*
+ // if the action is SAVE, and the file that is choosen exists, prompt the user for overwrite
+ if (action == FileChooserAction.Save)
+ {
+ string sFilename = ret.Substring(8);
+ if (System.IO.File.Exists(sFilename))
+ {
+ // prompt user for overwrite
+
+
+
+ }
+ }
+*/
+ chooser.Destroy();
+ return ret;
+ }
+
+ ///
+ /// VerifyMasterPasswordWithUser dialog
+ ///
+ public void VerifyMasterPasswordWithUser()
+ {
+
+ //Logger.DbgLog("GUI:CasaMain.Login() - IsMasterPasswordSet returned false");
+#if W32
+ Glade.XML gxmlTemp = new Glade.XML ("../images/casa.glade", "dialogLogin", null);
+#endif
+#if LINUX
+ Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogLogin", null);
+#endif
+
+ gxmlTemp.Autoconnect (this);
+ dialogLogin.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");;
+
+ label86.Text = "Enter your Master Password to continue.";
+ entryMasterPassword3.Text="";
+ label88.Hide();
+ entryMasterPassword4.Hide();
+ //dialogLogin.SetPosition(Gtk.WindowPosition.Center);
+ dialogLogin.Destroyed += new EventHandler(dialogLogin_Destroyed);
+ dialogLogin.Modal = true;
+ dialogLogin.Show();
+ }
+
+ public static void DisplayMessage(Gtk.MessageType messageType, String sMessage)
+ {
+ MessageDialog md = new MessageDialog(null,
+ Gtk.DialogFlags.Modal,
+ messageType,
+ Gtk.ButtonsType.Close,
+ sMessage);
+
+ md.SetPosition(Gtk.WindowPosition.CenterAlways);
+ md.Response +=new ResponseHandler(md_Response3);
+ md.Show();
+
+ }
+
+ private static void md_Response3(object o, ResponseArgs args)
+ {
+ MessageDialog md = (MessageDialog)o;
+ if (md != null)
+ {
+ md.Destroy();
+ }
+ }
+
+
#if W32
public static bool IsGTKSharpInstalled()
diff --git a/CASA/gui/ExportSecrets.cs b/CASA/gui/ExportSecrets.cs
new file mode 100644
index 00000000..5f46663a
--- /dev/null
+++ b/CASA/gui/ExportSecrets.cs
@@ -0,0 +1,150 @@
+using System;
+using System.IO;
+
+using Novell.CASA.MiCasa.Communication;
+using Novell.CASA.MiCasa.Common;
+
+using Gtk;
+using Glade;
+
+namespace Novell.CASA.GUI
+{
+ ///
+ /// Summary description for ExportSecrets.
+ ///
+ public class ExportSecrets
+ {
+
+ private Config m_config = null;
+
+ [Glade.Widget]
+ Gtk.Label label86,
+ label88;
+
+ [Glade.Widget]
+ Gtk.Entry entryMasterPassword;
+
+ [Glade.Widget]
+ Gtk.Dialog dialogExport;
+
+ [Glade.Widget]
+ Gtk.CheckButton checkbuttonNoEncrypt;
+
+ public ExportSecrets(Config config)
+ {
+ m_config = config;
+ }
+
+ public void Run()
+ {
+ // prompt for master password, and optional passphrase to encrypt
+ //Logger.DbgLog("GUI:CasaMain.Login() - IsMasterPasswordSet returned false");
+#if W32
+ Glade.XML gxmlTemp = new Glade.XML ("../images/casa.glade", "dialogExport", null);
+#endif
+#if LINUX
+ Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogLogin", null);
+#endif
+
+ gxmlTemp.Autoconnect (this);
+ dialogExport.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");;
+
+
+ dialogExport.Destroyed += new EventHandler(dialogExport_Destroyed);
+ dialogExport.Modal = true;
+ dialogExport.Show();
+ }
+ private void dialogExport_Destroyed(object sender, EventArgs e)
+ {
+
+ }
+
+ private void on_buttonCloseExportSecrets_clicked(object sender, EventArgs args)
+ {
+ if (dialogExport != null)
+ {
+ dialogExport.Destroy();
+ }
+ }
+
+ private void on_buttonOkExportSecrets_clicked(object sender, EventArgs args)
+ {
+ if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword.Text) )
+ {
+ string sMasterPWD = entryMasterPassword.Text;
+ string sEncryptString = entryMasterPassword.Text;
+
+ if (checkbuttonNoEncrypt.Active)
+ sEncryptString = null;
+
+ if (dialogExport != null)
+ {
+ dialogExport.Destroy();
+ }
+
+ string sHintDir = m_config.GetConfigSetting(CommonGUI.HINT_DIR, null);
+ string sHintFile = m_config.GetConfigSetting(CommonGUI.HINT_FILENAME, null);
+
+ // prompt the user for storage location
+ string sFileName = GetStorageFileName(sHintDir, sHintFile);
+
+ if (sFileName != null)
+ {
+ //Store off this location for next export
+ int iLastSlash = sFileName.LastIndexOf("/");
+ if (iLastSlash > 0)
+ {
+ sHintFile = sFileName.Substring(iLastSlash + 1);
+ sHintDir = sFileName.Substring(8, sFileName.Length - sHintFile.Length - 8);
+ }
+
+ // save for later use
+ m_config.SetConfigSetting(CommonGUI.HINT_DIR, sHintDir);
+ m_config.SetConfigSetting(CommonGUI.HINT_FILENAME, sHintFile);
+ m_config.WriteConfig();
+
+ // call our daemon to get the users secrets
+ ExportXMLSecrets exportSecrets = new ExportXMLSecrets(sMasterPWD, sEncryptString);
+ byte[] theSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets);
+
+ // write em out.
+ FileStream fs = new FileStream(sFileName.Substring(8), FileMode.Create);
+ fs.Write(theSecrets, 0, theSecrets.Length);
+ fs.Flush();
+ fs.Close();
+
+ CommonGUI.DisplayMessage(MessageType.Info, "Secrets saved to: \r\n" + sFileName.Substring(8));
+
+ }
+ }
+ else
+ {
+ // prompt user
+ MessageDialog md=new MessageDialog(dialogExport,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();
+ }
+ }
+
+ private string GetStorageFileName(string sHintDir, string sHintFile)
+ {
+ String sFileName = CommonGUI.FileChooser(FileChooserAction.Save, "Select filename and location for secrets", sHintDir, sHintFile);
+ return sFileName;
+ }
+
+ private void md_Response2(object o, ResponseArgs args)
+ {
+ MessageDialog md = (MessageDialog)o;
+ if (md != null)
+ {
+ md.Destroy();
+ }
+ }
+ }
+}
diff --git a/CASA/gui/ImportSecrets.cs b/CASA/gui/ImportSecrets.cs
new file mode 100644
index 00000000..cdea0b02
--- /dev/null
+++ b/CASA/gui/ImportSecrets.cs
@@ -0,0 +1,119 @@
+using System;
+using System.IO;
+
+using Novell.CASA.MiCasa.Communication;
+using Novell.CASA.MiCasa.Common;
+
+namespace Novell.CASA.GUI
+{
+ ///
+ /// Summary description for ImportSecrets.
+ ///
+ public class ImportSecrets
+ {
+ Config m_config = null;
+ public MiCasa m_objMiCasa = null;
+ byte[] buffer = null;
+
+ [Glade.Widget]
+ Gtk.Entry entryMasterPassword;
+
+ [Glade.Widget]
+ Gtk.Dialog dialogImport;
+
+ public ImportSecrets(Config config, MiCasa objMiCasa)
+ {
+ m_config = config;
+ m_objMiCasa = objMiCasa;
+ }
+
+ public void Run()
+ {
+ String sHintDir = m_config.GetConfigSetting(CommonGUI.HINT_DIR, null);;
+ String sHintFilename = m_config.GetConfigSetting(CommonGUI.HINT_FILENAME, null);
+
+ // ask the user to locate the secret file to import
+ string sFile = CommonGUI.FileChooser(Gtk.FileChooserAction.Open, "Select import file", sHintDir, sHintFilename);
+ if (sFile != null)
+ {
+ // parse of the file:///
+ sFile = sFile.Substring(8);
+
+ if (File.Exists(sFile))
+ {
+
+ // let's read it
+ FileStream fs = new FileStream(sFile, FileMode.Open);
+ buffer = new byte[fs.Length];
+
+ int iBytes = fs.Read(buffer, 0, (int)fs.Length);
+ string data = System.Text.Encoding.ASCII.GetString(buffer);
+
+ fs.Flush();
+ fs.Close();
+
+ // check for clear text secrets
+ if (data.StartsWith("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
@@ -213,6 +213,54 @@
+
+
+
+
+
+
+
+
+
+
+
+