import/export changes
This commit is contained in:
parent
52e89dd71a
commit
8a5d4808b9
@ -124,6 +124,12 @@ public class Common
|
|||||||
|
|
||||||
public static string LINUX_HELP_PATH = "file:///usr/share/doc/packages/CASA/help/";
|
public static string LINUX_HELP_PATH = "file:///usr/share/doc/packages/CASA/help/";
|
||||||
public static string WINDOWS_HELP_PATH = "..\\help\\";
|
public static string WINDOWS_HELP_PATH = "..\\help\\";
|
||||||
|
|
||||||
|
#if W32
|
||||||
|
public static string IMAGE_PATH = "..\\images\\";
|
||||||
|
#else
|
||||||
|
public static string IMAGE_PATH = "/usr/share/doc/packages/CASA/images/";
|
||||||
|
#endif
|
||||||
|
|
||||||
///##############################################################
|
///##############################################################
|
||||||
/// ARG CONSTANTS
|
/// ARG CONSTANTS
|
||||||
|
@ -95,7 +95,8 @@ namespace Novell.CASA.GUI
|
|||||||
if (iLastSlash > 0)
|
if (iLastSlash > 0)
|
||||||
{
|
{
|
||||||
sHintFile = sFileName.Substring(iLastSlash + 1);
|
sHintFile = sFileName.Substring(iLastSlash + 1);
|
||||||
sHintDir = sFileName.Substring(8, sFileName.Length - sHintFile.Length - 8); }
|
sHintDir = sFileName.Substring(0, sFileName.Length - sHintFile.Length);
|
||||||
|
}
|
||||||
|
|
||||||
// save for later use
|
// save for later use
|
||||||
m_config.SetConfigSetting(CommonGUI.HINT_DIR, sHintDir);
|
m_config.SetConfigSetting(CommonGUI.HINT_DIR, sHintDir);
|
||||||
@ -107,7 +108,9 @@ namespace Novell.CASA.GUI
|
|||||||
byte[] theSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets);
|
byte[] theSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets);
|
||||||
|
|
||||||
// write em out.
|
// write em out.
|
||||||
FileStream fs = new FileStream(sFileName.Substring(8), FileMode.Create);
|
|
||||||
|
|
||||||
|
FileStream fs = new FileStream(sFileName, FileMode.Create);
|
||||||
fs.Write(theSecrets, 0, theSecrets.Length);
|
fs.Write(theSecrets, 0, theSecrets.Length);
|
||||||
fs.Flush();
|
fs.Flush();
|
||||||
fs.Close();
|
fs.Close();
|
||||||
@ -133,13 +136,18 @@ namespace Novell.CASA.GUI
|
|||||||
|
|
||||||
private string GetStorageFileName(string sHintDir, string sHintFile)
|
private string GetStorageFileName(string sHintDir, string sHintFile)
|
||||||
{
|
{
|
||||||
#if W32
|
|
||||||
|
FileChooser fc = new FileChooser();
|
||||||
|
String sFileName = fc.GetFile(sHintDir, sHintFile);
|
||||||
|
|
||||||
|
/*
|
||||||
|
#if W32
|
||||||
String sFileName = CommonGUI.FileChooser(FileChooserAction.Save, "Select filename and location for secrets", sHintDir, sHintFile);
|
String sFileName = CommonGUI.FileChooser(FileChooserAction.Save, "Select filename and location for secrets", sHintDir, sHintFile);
|
||||||
#else
|
#else
|
||||||
String sFileName = null;
|
String sFileName = null;
|
||||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Not implemented");
|
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Not implemented");
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
return sFileName;
|
return sFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,11 @@ namespace Novell.CASA.GUI
|
|||||||
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(string), typeof(string));
|
private Gtk.TreeStore ts = new TreeStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string), typeof(string));
|
||||||
|
|
||||||
Thread tChooserThread = null;
|
private string m_pathSeparator = "/";
|
||||||
Thread tMainThread = null;
|
|
||||||
|
Thread tChooserThread = null;
|
||||||
|
|
||||||
|
|
||||||
#region Glade Widgets
|
#region Glade Widgets
|
||||||
@ -44,10 +45,26 @@ namespace Novell.CASA.GUI
|
|||||||
|
|
||||||
public FileChooser()
|
public FileChooser()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// TODO: Add constructor logic here
|
if (Common.IS_WINDOWS)
|
||||||
//
|
m_pathSeparator = "\\";
|
||||||
m_currentDirectory = Common.GetUserHomeDir();
|
|
||||||
|
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)
|
public string GetFile(string sHintDir, string sHintFile)
|
||||||
@ -55,7 +72,7 @@ namespace Novell.CASA.GUI
|
|||||||
if (sHintDir != null)
|
if (sHintDir != null)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(sHintDir))
|
if (Directory.Exists(sHintDir))
|
||||||
m_currentDirectory = sHintDir;
|
SetCurrentDirectory(sHintDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sHintFile != null)
|
if (sHintFile != null)
|
||||||
@ -63,28 +80,8 @@ namespace Novell.CASA.GUI
|
|||||||
m_hintFile = sHintFile;
|
m_hintFile = sHintFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DoWork();
|
||||||
if (true)
|
return m_currentDirectory + m_pathSeparator + m_sFileSelected;
|
||||||
{
|
|
||||||
DoWork();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//start a FileChooser Thread, and suspend this one until a file is selected or user cancels
|
|
||||||
tChooserThread = new Thread(new ThreadStart(DoWork));
|
|
||||||
tChooserThread.Start();
|
|
||||||
|
|
||||||
// wait for it to start
|
|
||||||
while (!tChooserThread.IsAlive);
|
|
||||||
|
|
||||||
// allow filechooser to run
|
|
||||||
Thread.Sleep(1);
|
|
||||||
|
|
||||||
// wait for FileChooserThread to complete
|
|
||||||
tChooserThread.Join();
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_currentDirectory + m_sFileSelected;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +107,7 @@ namespace Novell.CASA.GUI
|
|||||||
if (sHintDir != null)
|
if (sHintDir != null)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(sHintDir))
|
if (Directory.Exists(sHintDir))
|
||||||
m_currentDirectory = sHintDir;
|
SetCurrentDirectory(sHintDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sHintFile != null)
|
if (sHintFile != null)
|
||||||
@ -136,18 +133,21 @@ namespace Novell.CASA.GUI
|
|||||||
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
|
||||||
treeviewListing.AppendColumn("Name",new CellRendererText(),"text",0);
|
TreeViewColumn col1 = new TreeViewColumn("", new Gtk.CellRendererPixbuf(), "pixbuf", 0);
|
||||||
treeviewListing.AppendColumn("Date Modified",new CellRendererText(),"text",1);
|
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;
|
treeviewListing.Model = ts;
|
||||||
|
|
||||||
// hook up the events
|
// hook up the events
|
||||||
treeviewListing.RowActivated +=new RowActivatedHandler(treeviewListing_RowActivated);
|
treeviewListing.RowActivated +=new RowActivatedHandler(treeviewListing_RowActivated);
|
||||||
|
|
||||||
|
DisplayDirectory();
|
||||||
DisplayFileListing();
|
DisplayFileListing();
|
||||||
|
|
||||||
if (m_hintFile != null)
|
if (m_hintFile != null)
|
||||||
@ -161,27 +161,36 @@ namespace Novell.CASA.GUI
|
|||||||
|
|
||||||
private void DisplayDirectory()
|
private void DisplayDirectory()
|
||||||
{
|
{
|
||||||
entryCurrentDir.Text = m_currentDirectory;
|
if (entryCurrentDir != null)
|
||||||
|
entryCurrentDir.Text = m_currentDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayFileListing()
|
private void DisplayFileListing()
|
||||||
{
|
{
|
||||||
DisplayDirectory();
|
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(dirs[i].Name, "Folder");
|
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "folder.png", 16, 16), 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(files[i].Name, 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)
|
||||||
|
{
|
||||||
|
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)
|
private void treeviewListing_RowActivated(object o, RowActivatedArgs args)
|
||||||
@ -190,19 +199,20 @@ namespace Novell.CASA.GUI
|
|||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
string selected;
|
string selected;
|
||||||
|
|
||||||
|
// trim any trailing \
|
||||||
|
if (m_currentDirectory.EndsWith("\\"))
|
||||||
|
m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.Length - 1);
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( treeviewListing.Selection.GetSelected (out model, out iter) )
|
if( treeviewListing.Selection.GetSelected (out model, out iter) )
|
||||||
{
|
{
|
||||||
selected = (string) model.GetValue(iter, 0);
|
selected = (string) model.GetValue(iter, 1);
|
||||||
if (selected.Equals(".."))
|
|
||||||
|
if (Directory.Exists(m_currentDirectory + "/" + selected))
|
||||||
{
|
{
|
||||||
// backup one directory
|
SetCurrentDirectory(m_currentDirectory + "/" + selected);
|
||||||
m_currentDirectory = m_currentDirectory.Substring(0, m_currentDirectory.LastIndexOf("/"));
|
|
||||||
}
|
|
||||||
else if (Directory.Exists(m_currentDirectory + "/" + selected))
|
|
||||||
{
|
|
||||||
m_currentDirectory = m_currentDirectory + "/" + selected;
|
|
||||||
|
|
||||||
// clear current view
|
// clear current view
|
||||||
ts.Clear();
|
ts.Clear();
|
||||||
@ -238,8 +248,7 @@ namespace Novell.CASA.GUI
|
|||||||
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);
|
||||||
m_currentDirectory = selected;
|
SetCurrentDirectory(selected);
|
||||||
ts.Clear();
|
|
||||||
DisplayFileListing();
|
DisplayFileListing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,12 +275,23 @@ namespace Novell.CASA.GUI
|
|||||||
|
|
||||||
public void on_buttonUP_clicked(object o, EventArgs args)
|
public void on_buttonUP_clicked(object o, EventArgs args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Button clicked");
|
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)
|
private void imageUp_ButtonPressEvent(object o, ButtonPressEventArgs args)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,10 +520,10 @@ public class MiCasa : Store
|
|||||||
label88.Hide();
|
label88.Hide();
|
||||||
entryMasterPassword4.Hide();
|
entryMasterPassword4.Hide();
|
||||||
|
|
||||||
//labelRememberFor.Visible = true;
|
labelRememberFor.Visible = true;
|
||||||
//labelSeconds.Visible = true;
|
labelSeconds.Visible = true;
|
||||||
//spinbuttonRememberFor.Visible = true;
|
spinbuttonRememberFor.Visible = true;
|
||||||
//spinbuttonRememberFor.Text = m_sRememberFor;
|
spinbuttonRememberFor.Text = m_sRememberFor;
|
||||||
|
|
||||||
dialogLogin.Show();
|
dialogLogin.Show();
|
||||||
}
|
}
|
||||||
@ -549,7 +549,7 @@ public class MiCasa : Store
|
|||||||
tvKeyValue.InsertColumn(tvCol, 1);
|
tvKeyValue.InsertColumn(tvCol, 1);
|
||||||
|
|
||||||
// get seconds to remember
|
// get seconds to remember
|
||||||
/*
|
|
||||||
m_sRememberFor = spinbuttonRememberFor.Text;
|
m_sRememberFor = spinbuttonRememberFor.Text;
|
||||||
if (m_sRememberFor != null)
|
if (m_sRememberFor != null)
|
||||||
{
|
{
|
||||||
@ -557,11 +557,11 @@ public class MiCasa : Store
|
|||||||
m_iRememberSeconds = int.Parse(m_sRememberFor);
|
m_iRememberSeconds = int.Parse(m_sRememberFor);
|
||||||
m_dtRememberMPUntil = dtNow.AddSeconds(m_iRememberSeconds);
|
m_dtRememberMPUntil = dtNow.AddSeconds(m_iRememberSeconds);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
dialogLogin.Destroy();
|
dialogLogin.Destroy();
|
||||||
|
|
||||||
//if (m_iRememberSeconds > 0)
|
if (m_iRememberSeconds > 0)
|
||||||
// StartRememberTimer();
|
StartRememberTimer();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -594,7 +594,8 @@ public class MiCasa : Store
|
|||||||
|
|
||||||
public void StartRememberTimer()
|
public void StartRememberTimer()
|
||||||
{
|
{
|
||||||
//if (m_tRememberTimer == null)
|
// NOTE: USE A TIMER RATHER THAN A THREAD
|
||||||
|
if (m_tRememberTimer == null)
|
||||||
{
|
{
|
||||||
m_tRememberTimer = new Thread(new ThreadStart(ResetTimerThreadFn));
|
m_tRememberTimer = new Thread(new ThreadStart(ResetTimerThreadFn));
|
||||||
m_tRememberTimer.Start();
|
m_tRememberTimer.Start();
|
||||||
|
BIN
CASA/gui/images/folder.png
Normal file
BIN
CASA/gui/images/folder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
Loading…
Reference in New Issue
Block a user