Export/import changes
This commit is contained in:
parent
deb207f913
commit
94c34b99e7
@ -1,200 +1,200 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using Gtk;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for FileChooser.
|
||||
/// </summary>
|
||||
public class FileChooser
|
||||
{
|
||||
private string m_currentDirectory;
|
||||
private string m_hintFile = null;
|
||||
private string m_sFileSelected = null;
|
||||
private bool m_bFileChoosing = true;
|
||||
|
||||
private Gtk.TreeStore tsDrives = new TreeStore(typeof(string));
|
||||
private Gtk.TreeStore ts = new TreeStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string));
|
||||
|
||||
private string m_pathSeparator = "/";
|
||||
|
||||
Thread tChooserThread = null;
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using Gtk;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for FileChooser.
|
||||
/// </summary>
|
||||
public class FileChooser
|
||||
{
|
||||
private string m_currentDirectory;
|
||||
private string m_hintFile = null;
|
||||
private string m_sFileSelected = null;
|
||||
private bool m_bFileChoosing = true;
|
||||
|
||||
private Gtk.TreeStore tsDrives = new TreeStore(typeof(string));
|
||||
private Gtk.TreeStore ts = new TreeStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string));
|
||||
|
||||
private string m_pathSeparator = "/";
|
||||
|
||||
Thread tChooserThread = null;
|
||||
|
||||
|
||||
#region Glade Widgets
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Dialog dialogFileChooser;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.TreeView treeviewFavorites,
|
||||
treeviewListing;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Entry entrySelectedFile,
|
||||
entryCurrentDir;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Button buttonUP;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public FileChooser()
|
||||
{
|
||||
|
||||
if (Common.IS_WINDOWS)
|
||||
m_pathSeparator = "\\";
|
||||
|
||||
SetCurrentDirectory(Common.GetUserHomeDir());
|
||||
}
|
||||
|
||||
private void SetCurrentDirectory(string dir)
|
||||
{
|
||||
// replace all instances of the path separator with correct one
|
||||
if (Common.IS_WINDOWS)
|
||||
m_currentDirectory = dir.Replace("/", "\\");
|
||||
else
|
||||
m_currentDirectory = dir;
|
||||
|
||||
|
||||
//if (m_currentDirectory.EndsWith(m_pathSeparator))
|
||||
// m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1);
|
||||
|
||||
DisplayDirectory();
|
||||
}
|
||||
|
||||
public string GetFile(string sHintDir, string sHintFile)
|
||||
{
|
||||
if (sHintDir != null)
|
||||
{
|
||||
if (Directory.Exists(sHintDir))
|
||||
SetCurrentDirectory(sHintDir);
|
||||
}
|
||||
|
||||
if (sHintFile != null)
|
||||
{
|
||||
m_hintFile = sHintFile;
|
||||
}
|
||||
|
||||
DoWork();
|
||||
return m_currentDirectory + m_pathSeparator + m_sFileSelected;
|
||||
|
||||
}
|
||||
|
||||
private void DoWork()
|
||||
{
|
||||
|
||||
// display chooser
|
||||
Show();
|
||||
|
||||
// wait for user
|
||||
while (m_bFileChoosing)
|
||||
{
|
||||
// Flush pending events to keep the GUI reponsive
|
||||
while (Gtk.Application.EventsPending ())
|
||||
Gtk.Application.RunIteration ();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
public void Show(string sHintDir, string sHintFile)
|
||||
{
|
||||
|
||||
if (sHintDir != null)
|
||||
{
|
||||
if (Directory.Exists(sHintDir))
|
||||
SetCurrentDirectory(sHintDir);
|
||||
}
|
||||
|
||||
if (sHintFile != null)
|
||||
{
|
||||
m_hintFile = sHintFile;
|
||||
}
|
||||
|
||||
this.Show();
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
// load and connect handlers
|
||||
[Glade.Widget]
|
||||
Gtk.TreeView treeviewFavorites,
|
||||
treeviewListing;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Entry entrySelectedFile,
|
||||
entryCurrentDir;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Button buttonUP;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public FileChooser()
|
||||
{
|
||||
|
||||
if (Common.IS_WINDOWS)
|
||||
m_pathSeparator = "\\";
|
||||
|
||||
SetCurrentDirectory(Common.GetUserHomeDir());
|
||||
}
|
||||
|
||||
private void SetCurrentDirectory(string dir)
|
||||
{
|
||||
// replace all instances of the path separator with correct one
|
||||
if (Common.IS_WINDOWS)
|
||||
m_currentDirectory = dir.Replace("/", "\\");
|
||||
else
|
||||
m_currentDirectory = dir;
|
||||
|
||||
|
||||
//if (m_currentDirectory.EndsWith(m_pathSeparator))
|
||||
// m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1);
|
||||
|
||||
DisplayDirectory();
|
||||
}
|
||||
|
||||
public string GetFile(string sHintDir, string sHintFile)
|
||||
{
|
||||
if (sHintDir != null)
|
||||
{
|
||||
if (Directory.Exists(sHintDir))
|
||||
SetCurrentDirectory(sHintDir);
|
||||
}
|
||||
|
||||
if (sHintFile != null)
|
||||
{
|
||||
m_hintFile = sHintFile;
|
||||
}
|
||||
|
||||
DoWork();
|
||||
return m_currentDirectory + m_pathSeparator + m_sFileSelected;
|
||||
|
||||
}
|
||||
|
||||
private void DoWork()
|
||||
{
|
||||
|
||||
// display chooser
|
||||
Show();
|
||||
|
||||
// wait for user
|
||||
while (m_bFileChoosing)
|
||||
{
|
||||
// Flush pending events to keep the GUI reponsive
|
||||
while (Gtk.Application.EventsPending ())
|
||||
Gtk.Application.RunIteration ();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
public void Show(string sHintDir, string sHintFile)
|
||||
{
|
||||
|
||||
if (sHintDir != null)
|
||||
{
|
||||
if (Directory.Exists(sHintDir))
|
||||
SetCurrentDirectory(sHintDir);
|
||||
}
|
||||
|
||||
if (sHintFile != null)
|
||||
{
|
||||
m_hintFile = sHintFile;
|
||||
}
|
||||
|
||||
this.Show();
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
// load and connect handlers
|
||||
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogFileChooser", null);
|
||||
gxmlTemp.Autoconnect(this);
|
||||
|
||||
// show logical drives
|
||||
string[] drives = Directory.GetLogicalDrives();
|
||||
for (int i=0; i<drives.Length; i++)
|
||||
{
|
||||
tsDrives.AppendValues(drives[i]);
|
||||
}
|
||||
treeviewFavorites.AppendColumn("Drive", new CellRendererText(), "text", 0);
|
||||
treeviewFavorites.Model = tsDrives;
|
||||
|
||||
treeviewFavorites.RowActivated += new RowActivatedHandler(treeviewFavorites_RowActivated);
|
||||
|
||||
// FILE LISTING
|
||||
// hook up the model
|
||||
TreeViewColumn col1 = new TreeViewColumn("", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
|
||||
treeviewListing.AppendColumn(col1);
|
||||
treeviewListing.AppendColumn("Name",new CellRendererText(),"text",1);
|
||||
treeviewListing.AppendColumn("Size",new CellRendererText(),"text",2);
|
||||
treeviewListing.AppendColumn("Date Modified",new CellRendererText(),"text",3);
|
||||
treeviewListing.Model = ts;
|
||||
|
||||
// hook up the events
|
||||
treeviewListing.RowActivated +=new RowActivatedHandler(treeviewListing_RowActivated);
|
||||
|
||||
DisplayDirectory();
|
||||
DisplayFileListing();
|
||||
|
||||
if (m_hintFile != null)
|
||||
entrySelectedFile.Text = m_hintFile;
|
||||
}
|
||||
|
||||
public string GetSelectedFile()
|
||||
{
|
||||
return m_sFileSelected;
|
||||
}
|
||||
|
||||
private void DisplayDirectory()
|
||||
{
|
||||
if (entryCurrentDir != null)
|
||||
entryCurrentDir.Text = m_currentDirectory;
|
||||
}
|
||||
|
||||
private void DisplayFileListing()
|
||||
{
|
||||
ts.Clear();
|
||||
|
||||
// add in the dirs and files
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(m_currentDirectory);
|
||||
DirectoryInfo[] dirs = dirInfo.GetDirectories();
|
||||
|
||||
for (int i=0; i<dirs.Length; i++)
|
||||
{
|
||||
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "folder.png", 16, 16), dirs[i].Name, "", "File folder");
|
||||
}
|
||||
|
||||
FileInfo[] files = dirInfo.GetFiles();
|
||||
for (int i=0; i<files.Length; i++)
|
||||
{
|
||||
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "CASA_16.png"), files[i].Name, (files[i].Length/1000).ToString() + " KB", files[i].LastWriteTime.ToShortDateString() + " " + files[i].LastWriteTime.ToShortTimeString());
|
||||
}
|
||||
}
|
||||
|
||||
private int GetItemCount(string sDir)
|
||||
{
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(sDir);
|
||||
DirectoryInfo[] dirs = dirInfo.GetDirectories();
|
||||
FileInfo[] files = dirInfo.GetFiles();
|
||||
return dirs.Length + files.Length;
|
||||
}
|
||||
|
||||
private void treeviewListing_RowActivated(object o, RowActivatedArgs args)
|
||||
{
|
||||
gxmlTemp.Autoconnect(this);
|
||||
|
||||
// show logical drives
|
||||
string[] drives = Directory.GetLogicalDrives();
|
||||
for (int i=0; i<drives.Length; i++)
|
||||
{
|
||||
tsDrives.AppendValues(drives[i]);
|
||||
}
|
||||
treeviewFavorites.AppendColumn("Drive", new CellRendererText(), "text", 0);
|
||||
treeviewFavorites.Model = tsDrives;
|
||||
|
||||
treeviewFavorites.RowActivated += new RowActivatedHandler(treeviewFavorites_RowActivated);
|
||||
|
||||
// FILE LISTING
|
||||
// hook up the model
|
||||
TreeViewColumn col1 = new TreeViewColumn("", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
|
||||
treeviewListing.AppendColumn(col1);
|
||||
treeviewListing.AppendColumn("Name",new CellRendererText(),"text",1);
|
||||
treeviewListing.AppendColumn("Size",new CellRendererText(),"text",2);
|
||||
treeviewListing.AppendColumn("Date Modified",new CellRendererText(),"text",3);
|
||||
treeviewListing.Model = ts;
|
||||
|
||||
// hook up the events
|
||||
treeviewListing.RowActivated +=new RowActivatedHandler(treeviewListing_RowActivated);
|
||||
|
||||
DisplayDirectory();
|
||||
DisplayFileListing();
|
||||
|
||||
if (m_hintFile != null)
|
||||
entrySelectedFile.Text = m_hintFile;
|
||||
}
|
||||
|
||||
public string GetSelectedFile()
|
||||
{
|
||||
return m_sFileSelected;
|
||||
}
|
||||
|
||||
private void DisplayDirectory()
|
||||
{
|
||||
if (entryCurrentDir != null)
|
||||
entryCurrentDir.Text = m_currentDirectory;
|
||||
}
|
||||
|
||||
private void DisplayFileListing()
|
||||
{
|
||||
ts.Clear();
|
||||
|
||||
// add in the dirs and files
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(m_currentDirectory);
|
||||
DirectoryInfo[] dirs = dirInfo.GetDirectories();
|
||||
|
||||
for (int i=0; i<dirs.Length; i++)
|
||||
{
|
||||
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "folder.png"), dirs[i].Name, "", "File folder");
|
||||
}
|
||||
|
||||
FileInfo[] files = dirInfo.GetFiles();
|
||||
for (int i=0; i<files.Length; i++)
|
||||
{
|
||||
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "CASA_16.png"), files[i].Name, (files[i].Length/1000).ToString() + " KB", files[i].LastWriteTime.ToShortDateString() + " " + files[i].LastWriteTime.ToShortTimeString());
|
||||
}
|
||||
}
|
||||
|
||||
private int GetItemCount(string sDir)
|
||||
{
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(sDir);
|
||||
DirectoryInfo[] dirs = dirInfo.GetDirectories();
|
||||
FileInfo[] files = dirInfo.GetFiles();
|
||||
return dirs.Length + files.Length;
|
||||
}
|
||||
|
||||
private void treeviewListing_RowActivated(object o, RowActivatedArgs args)
|
||||
{
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
string selected;
|
||||
@ -206,92 +206,92 @@ namespace Novell.CASA.GUI
|
||||
|
||||
try
|
||||
{
|
||||
if( treeviewListing.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string) model.GetValue(iter, 1);
|
||||
|
||||
if (Directory.Exists(m_currentDirectory + "/" + selected))
|
||||
{
|
||||
SetCurrentDirectory(m_currentDirectory + "/" + selected);
|
||||
|
||||
// clear current view
|
||||
ts.Clear();
|
||||
DisplayFileListing();
|
||||
}
|
||||
else
|
||||
{
|
||||
// file selected
|
||||
entrySelectedFile.Text = selected;
|
||||
m_sFileSelected = selected;
|
||||
// destroy dialog
|
||||
dialogFileChooser.Destroy();
|
||||
m_bFileChoosing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void treeviewFavorites_RowActivated(object o, RowActivatedArgs args)
|
||||
{
|
||||
// change drive
|
||||
if( treeviewListing.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string) model.GetValue(iter, 1);
|
||||
|
||||
if (Directory.Exists(m_currentDirectory + "/" + selected))
|
||||
{
|
||||
SetCurrentDirectory(m_currentDirectory + "/" + selected);
|
||||
|
||||
// clear current view
|
||||
ts.Clear();
|
||||
DisplayFileListing();
|
||||
}
|
||||
else
|
||||
{
|
||||
// file selected
|
||||
entrySelectedFile.Text = selected;
|
||||
m_sFileSelected = selected;
|
||||
// destroy dialog
|
||||
dialogFileChooser.Destroy();
|
||||
m_bFileChoosing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void treeviewFavorites_RowActivated(object o, RowActivatedArgs args)
|
||||
{
|
||||
// change drive
|
||||
TreeModel model;
|
||||
TreeIter iter;
|
||||
string selected;
|
||||
|
||||
try
|
||||
{
|
||||
if( treeviewFavorites.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string)model.GetValue(iter, 0);
|
||||
SetCurrentDirectory(selected);
|
||||
DisplayFileListing();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void on_btnCancelFileChooser_clicked(object obj, EventArgs args)
|
||||
{
|
||||
m_bFileChoosing = false;
|
||||
if (dialogFileChooser != null)
|
||||
{
|
||||
dialogFileChooser.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void on_dialogFileChooser_destroy(object o, EventArgs args)
|
||||
{
|
||||
m_bFileChoosing = false;
|
||||
}
|
||||
|
||||
public void on_buttonUP_clicked(object o, EventArgs args)
|
||||
{
|
||||
int iSlashIndex = m_currentDirectory.LastIndexOf(m_pathSeparator);
|
||||
// back up one directory
|
||||
if (iSlashIndex > 1)
|
||||
{
|
||||
// if windows drive letter, keep the slash
|
||||
if ((Common.IS_WINDOWS) && (iSlashIndex == 2))
|
||||
SetCurrentDirectory(m_currentDirectory.Substring(0, iSlashIndex + 1));
|
||||
else
|
||||
SetCurrentDirectory(m_currentDirectory.Substring(0, iSlashIndex));
|
||||
|
||||
DisplayFileListing();
|
||||
}
|
||||
}
|
||||
|
||||
private void imageUp_ButtonPressEvent(object o, ButtonPressEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if( treeviewFavorites.Selection.GetSelected (out model, out iter) )
|
||||
{
|
||||
selected = (string)model.GetValue(iter, 0);
|
||||
SetCurrentDirectory(selected);
|
||||
DisplayFileListing();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void on_btnCancelFileChooser_clicked(object obj, EventArgs args)
|
||||
{
|
||||
m_bFileChoosing = false;
|
||||
if (dialogFileChooser != null)
|
||||
{
|
||||
dialogFileChooser.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void on_dialogFileChooser_destroy(object o, EventArgs args)
|
||||
{
|
||||
m_bFileChoosing = false;
|
||||
}
|
||||
|
||||
public void on_buttonUP_clicked(object o, EventArgs args)
|
||||
{
|
||||
int iSlashIndex = m_currentDirectory.LastIndexOf(m_pathSeparator);
|
||||
// back up one directory
|
||||
if (iSlashIndex > 1)
|
||||
{
|
||||
// if windows drive letter, keep the slash
|
||||
if ((Common.IS_WINDOWS) && (iSlashIndex == 2))
|
||||
SetCurrentDirectory(m_currentDirectory.Substring(0, iSlashIndex + 1));
|
||||
else
|
||||
SetCurrentDirectory(m_currentDirectory.Substring(0, iSlashIndex));
|
||||
|
||||
DisplayFileListing();
|
||||
}
|
||||
}
|
||||
|
||||
private void imageUp_ButtonPressEvent(object o, ButtonPressEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,91 +1,92 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Novell.CASA.MiCasa.Communication;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ImportSecrets.
|
||||
/// </summary>
|
||||
public class ImportSecrets
|
||||
{
|
||||
Config m_config = null;
|
||||
public MiCasa m_objMiCasa = null;
|
||||
byte[] buffer = null;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for ImportSecrets.
|
||||
/// </summary>
|
||||
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);
|
||||
string sFile = null;
|
||||
|
||||
Gtk.Dialog dialogImport,
|
||||
dialogLogin;
|
||||
|
||||
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);
|
||||
string sFile = null;
|
||||
|
||||
FileChooser fc = new FileChooser();
|
||||
sFile = fc.GetFile(sHintDir, sHintFilename);
|
||||
|
||||
//fc.Show(sHintDir, sHintFilename);
|
||||
//sFile = fc.GetSelectedFile();
|
||||
|
||||
#if W32
|
||||
// ask the user to locate the secret file to import
|
||||
//sFile = CommonGUI.FileChooser(Gtk.FileChooserAction.Open, "Select import file", sHintDir, sHintFilename);
|
||||
#else
|
||||
//sFile = null;
|
||||
//CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Not implemented");
|
||||
#endif
|
||||
if (sFile != null)
|
||||
{
|
||||
// parse of the file:///
|
||||
if (sFile.StartsWith("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("<?xml"))
|
||||
{
|
||||
ImportXMLSecrets addSecrets = new ImportXMLSecrets(null, buffer);
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets);
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete");
|
||||
}
|
||||
else
|
||||
{
|
||||
GetMasterPasswordUsedForImport();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void GetMasterPasswordUsedForImport()
|
||||
{
|
||||
// prompt for master password, and optional passphrase to encrypt
|
||||
//fc.Show(sHintDir, sHintFilename);
|
||||
//sFile = fc.GetSelectedFile();
|
||||
|
||||
#if W32
|
||||
// ask the user to locate the secret file to import
|
||||
//sFile = CommonGUI.FileChooser(Gtk.FileChooserAction.Open, "Select import file", sHintDir, sHintFilename);
|
||||
#else
|
||||
//sFile = null;
|
||||
//CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Not implemented");
|
||||
#endif
|
||||
if (sFile != null)
|
||||
{
|
||||
// parse of the file:///
|
||||
if (sFile.StartsWith("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("<?xml"))
|
||||
{
|
||||
ImportXMLSecrets addSecrets = new ImportXMLSecrets(null, buffer);
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets);
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete");
|
||||
}
|
||||
else
|
||||
{
|
||||
GetMasterPasswordUsedForImport();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void GetMasterPasswordUsedForImport()
|
||||
{
|
||||
// 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", "dialogImport", null);
|
||||
@ -97,45 +98,67 @@ namespace Novell.CASA.GUI
|
||||
gxmlTemp.Autoconnect (this);
|
||||
dialogImport.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");;
|
||||
dialogImport.Modal = true;
|
||||
dialogImport.Show();
|
||||
}
|
||||
|
||||
public void OnDialogLoginDeleted(object obj, DeleteEventArgs args)
|
||||
dialogImport.Show();
|
||||
}
|
||||
|
||||
public void OnDialogLoginDeleted(object obj, EventArgs args)
|
||||
{
|
||||
//cbuttonShowPassword.Active = false;
|
||||
dialogLogin.Destroy();
|
||||
args.RetVal = true;
|
||||
}
|
||||
|
||||
private void on_buttonImportOK_clicked(object sender, EventArgs args)
|
||||
{
|
||||
if (entryMasterPassword != null)
|
||||
{
|
||||
ImportXMLSecrets addSecrets = new ImportXMLSecrets(entryMasterPassword.Text, buffer);
|
||||
addSecrets = (ImportXMLSecrets)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets);
|
||||
|
||||
}
|
||||
|
||||
public void okbuttonLogin_clicked(object obj, EventArgs args)
|
||||
{
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
|
||||
public void closebuttonLogin_clicked(object obj, EventArgs args)
|
||||
{
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword3_activate(object obj, EventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword4_activate(object obj, EventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
public void on_helpbuttonAuthentication_clicked(object obj, EventArgs args)
|
||||
{
|
||||
Common.ShowHelpUrl("CASAMasterPasswordAuthentication.htm");
|
||||
}
|
||||
|
||||
private void on_buttonImportOK_clicked(object sender, EventArgs args)
|
||||
{
|
||||
if (entryMasterPassword != null)
|
||||
{
|
||||
ImportXMLSecrets addSecrets = new ImportXMLSecrets(entryMasterPassword.Text, buffer);
|
||||
addSecrets = (ImportXMLSecrets)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets);
|
||||
|
||||
if (dialogImport != null)
|
||||
{
|
||||
dialogImport.Destroy();
|
||||
}
|
||||
if (m_objMiCasa != null)
|
||||
{
|
||||
m_objMiCasa.AggregateStore();
|
||||
}
|
||||
|
||||
if (addSecrets.GetStatus().Equals("Success"))
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete");
|
||||
else
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Failed: " + addSecrets.GetStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private void on_buttonImportClose_clicked(object sender, EventArgs args)
|
||||
{
|
||||
}
|
||||
if (m_objMiCasa != null)
|
||||
{
|
||||
m_objMiCasa.AggregateStore();
|
||||
}
|
||||
|
||||
if (addSecrets.GetStatus().Equals("Success"))
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete");
|
||||
else
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Failed: " + addSecrets.GetStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private void on_buttonImportClose_clicked(object sender, EventArgs args)
|
||||
{
|
||||
if (dialogImport != null)
|
||||
{
|
||||
dialogImport.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,9 @@ CSFILES =$(srcdir)/AssemblyInfo.cs \
|
||||
$(srcdir)/CasaMain.cs \
|
||||
$(srcdir)/CasaTray.cs \
|
||||
$(srcdir)/TrayLib.cs \
|
||||
$(srcdir)/ExportSecrets.cs \
|
||||
$(srcdir)/FileChooser.cs \
|
||||
$(srcdir)/ImportSecrets.cs \
|
||||
$(srcdir)/Firefox.cs \
|
||||
$(srcdir)/GnomeKeyring.cs \
|
||||
$(srcdir)/KdeWallet.cs \
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 502 B |
Loading…
Reference in New Issue
Block a user