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