- Limit where persistent files can be saved.

This commit is contained in:
Jim Norman 2007-01-04 08:58:30 +00:00
parent d0a9891cdf
commit fbfa990210
3 changed files with 570 additions and 543 deletions

View File

@ -1750,6 +1750,7 @@ namespace Novell.CASA.GUI
public void okbuttonPreferences_clicked(object abj, EventArgs args)
{
Logger.DbgLog("GUI:CasaMain.okbuttonPreferences_clicked() - BEGIN");
bool bCloseDialog = true;
string[] storeID = new string[]{""};
@ -1757,7 +1758,7 @@ namespace Novell.CASA.GUI
Common.IS_MOZILLA = checkbuttonMozilla.Active;
Common.IS_GNOMEKEYRING = checkbuttonGnomeKeyring.Active;
Common.IS_KDEWALLET = checkbuttonKdeWallet.Active;
dialogPreferences.Destroy();
/// FIREFOX
if(Common.IS_FIREFOX)
@ -1841,11 +1842,17 @@ namespace Novell.CASA.GUI
string sOldDir = Common.GetUserPersistentDir(config);
try
{
if (MoveMiCASAFiles(sOldDir, sNewDir))
string sMoveMessage = MoveMiCASAFiles(sOldDir, sNewDir);
if (sMoveMessage.Equals("Success"))
{
// save off selected directory
Common.SetUserPersistentDir(config, sNewDir);
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Files moved from\r\n" + sOldDir + "\r\nto\r\n" + sNewDir);
}
else
{
CommonGUI.DisplayMessage(Gtk.MessageType.Warning, sMoveMessage);
bCloseDialog = false;
}
}
catch (Exception e)
@ -1854,6 +1861,11 @@ namespace Novell.CASA.GUI
}
config.WriteConfig();
if (bCloseDialog)
{
dialogPreferences.Destroy();
}
Logger.DbgLog("GUI:CasaMain.okbuttonPreferences_clicked() - END");
}
@ -2225,8 +2237,13 @@ namespace Novell.CASA.GUI
}
}
private bool MoveMiCASAFiles(string sOldDirectory, string sNewDirectory)
private string MoveMiCASAFiles(string sOldDirectory, string sNewDirectory)
{
if (sNewDirectory == null || sNewDirectory.Length == 0)
{
return "No persistent directory entered";
}
if ((sOldDirectory != null) && (sNewDirectory != null))
{
if (!sOldDirectory.Equals(sNewDirectory))
@ -2235,10 +2252,13 @@ namespace Novell.CASA.GUI
ChangePersistentDir cpd = new ChangePersistentDir(sOldDirectory, sNewDirectory);
cpd = (ChangePersistentDir)MiCasaRequestReply.Send(MiCasaRequestReply.VERB_CHANGE_PERSIST_DIR, cpd);
if (cpd.GetErrorMessage().Equals("Success"))
return true;
return "Success";
else
return cpd.GetErrorMessage();
}
}
return false;
return null;
}

View File

@ -441,9 +441,16 @@ public class Common
}
internal static string GetUserName()
{
if (Common.IS_LINUX)
{
return Environment.GetEnvironmentVariable("USER");
}
else
{
return Environment.GetEnvironmentVariable("USERNAME");
}
}
internal static string GetUserHomeDir()

View File

@ -29,7 +29,7 @@ namespace Novell.CASA.GUI
public const int ACTION_CHOOSE_DIR = 3;
#region Glade Widgets
#region Glade Widgets
[Glade.Widget]
Gtk.Dialog dialogFileChooser,
@ -52,7 +52,7 @@ namespace Novell.CASA.GUI
[Glade.Widget]
Gtk.Menu menuDeleteDirFile;
#endregion
#endregion
public FileChooser(int action)
{
@ -157,8 +157,8 @@ namespace Novell.CASA.GUI
while (m_bFileChoosing)
{
// Flush pending events to keep the GUI reponsive
while (Gtk.Application.EventsPending ())
Gtk.Application.RunIteration ();
while (Gtk.Application.EventsPending())
Gtk.Application.RunIteration();
Thread.Sleep(100);
}
}
@ -203,15 +203,15 @@ namespace Novell.CASA.GUI
dialogFileChooser.Title = "Save secrets to ....";
}
#if LINUX
tsDrives.AppendValues("/home");
tsDrives.AppendValues("/home/.casa/"+Common.GetUserName());
tsDrives.AppendValues(Common.GetUserHomeDir());
tsDrives.AppendValues("/media");
#else
// show logical drives
string[] drives = Directory.GetLogicalDrives();
for (int i=0; i<drives.Length; i++)
for (int i = 0; i < drives.Length; i++)
{
tsDrives.AppendValues(drives[i]);
}
@ -229,15 +229,15 @@ namespace Novell.CASA.GUI
// 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.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);
treeviewListing.MoveCursor +=new MoveCursorHandler(treeviewListing_MoveCursor);
treeviewListing.ButtonReleaseEvent +=new ButtonReleaseEventHandler(treeviewListing_ButtonReleaseEvent);
treeviewListing.RowActivated += new RowActivatedHandler(treeviewListing_RowActivated);
treeviewListing.MoveCursor += new MoveCursorHandler(treeviewListing_MoveCursor);
treeviewListing.ButtonReleaseEvent += new ButtonReleaseEventHandler(treeviewListing_ButtonReleaseEvent);
DisplayDirectory();
DisplayFileListing();
@ -267,18 +267,18 @@ namespace Novell.CASA.GUI
DirectoryInfo dirInfo = new DirectoryInfo(m_currentDirectory);
DirectoryInfo[] dirs = dirInfo.GetDirectories();
for (int i=0; i<dirs.Length; i++)
for (int i = 0; i < dirs.Length; i++)
{
//if (dirs[i].Name.StartsWith(".")) continue;
ts.AppendValues(new Gdk.Pixbuf (Common.IMAGE_PATH + "folder.png"), dirs[i].Name, "", "File folder");
ts.AppendValues(new Gdk.Pixbuf(Common.IMAGE_PATH + "folder.png"), dirs[i].Name, "", "File folder");
}
if (m_iAction < FileChooser.ACTION_CHOOSE_DIR)
{
FileInfo[] files = dirInfo.GetFiles(m_currentFilter);
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());
}
}
}
@ -366,7 +366,7 @@ namespace Novell.CASA.GUI
try
{
if( treeviewFavorites.Selection.GetSelected (out model, out iter) )
if (treeviewFavorites.Selection.GetSelected(out model, out iter))
{
selected = (string)model.GetValue(iter, 0);
SetCurrentDirectory(selected);
@ -452,16 +452,16 @@ namespace Novell.CASA.GUI
//Console.WriteLine("Button released");
DisplaySelectedFile();
if( 3 == args.Event.Button )
if (3 == args.Event.Button)
{
try
{
Logger.DbgLog("GUI:MiCasa.OnRightClicked() - Context menu opened.");
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "menuDeleteDirFile", null);
gxmlTemp.Autoconnect (this);
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "menuDeleteDirFile", null);
gxmlTemp.Autoconnect(this);
menuDeleteDirFile.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
}
catch(Exception exp)
catch (Exception exp)
{
Logger.DbgLog("GUI:MiCasa.OnRightClicked() - EXCEPTION:" + exp.ToString());
}
@ -502,9 +502,9 @@ namespace Novell.CASA.GUI
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);
entrySelectedFile.Text = selected;
}
}
@ -519,8 +519,7 @@ namespace Novell.CASA.GUI
{
if (buttonNewFolder != null)
{
if ((m_currentDirectory.Equals("/home/")) ||
(m_currentDirectory.Equals("/home/.casa/")) ||
if ((m_currentDirectory.Equals("/home/.casa/")) ||
(m_currentDirectory.Equals("/media/")))
{
buttonNewFolder.Sensitive = false;
@ -538,7 +537,8 @@ namespace Novell.CASA.GUI
{
if (buttonUP != null)
{
if ((m_currentDirectory.Equals("/home/")) ||
if ((m_currentDirectory.Equals(Common.GetUserHomeDir() + "/")) ||
(m_currentDirectory.Equals("/home/.casa/" + Common.GetUserName() + "/")) ||
(m_currentDirectory.Equals("/media/")))
{
buttonUP.Sensitive = false;