diff --git a/File.cs b/File.cs
index c294d7d..46f7611 100644
--- a/File.cs
+++ b/File.cs
@@ -42,17 +42,17 @@ namespace Dizzy
public class File
{
- public ulong size;
+
public string user;
public string name;
public string path;
public FileType type;
- public File (string path, ulong size, string user)
+ public File (string path, string user)
{
// Determino il tipo di file
type = new FileType (path);
- this.size = size;
+
this.user = user;
string[] pieces = path.Split ('/');
@@ -60,21 +60,6 @@ namespace Dizzy
}
- public string SizeToString()
- {
- ulong t_size = size;
- if(t_size < 1024)
- return t_size.ToString () + " B";
- t_size /= 1024;
- if(t_size < 1024)
- return t_size.ToString () + " KB";
- t_size /= 1024;
- if(t_size < 1024)
- return t_size.ToString () + "MB";
- t_size /= 1024;
- if(t_size < 1024)
- return t_size.ToString () + "GB";
- return "Unknown";
- }
+
}
}
diff --git a/FileTreeView.cs b/FileTreeView.cs
index 9a5d2c0..74d47fa 100644
--- a/FileTreeView.cs
+++ b/FileTreeView.cs
@@ -13,7 +13,6 @@ namespace Dizzy
// Le colonne che ci servono
Gtk.TreeViewColumn filenameColumn;
- Gtk.TreeViewColumn sizeColumn;
Gtk.TreeViewColumn userColumn;
// La listStore per memorizzare i file
@@ -28,18 +27,14 @@ namespace Dizzy
this.filenameColumn = new Gtk.TreeViewColumn ();
filenameColumn.Title = "Nome del file";
- this.sizeColumn = new Gtk.TreeViewColumn ();
- sizeColumn.Title = "Dimensione";
-
+
this.userColumn = new Gtk.TreeViewColumn ();
userColumn.Title = "Utente";
this.tree.AppendColumn (filenameColumn);
- this.tree.AppendColumn (sizeColumn);
this.tree.AppendColumn (userColumn);
this.fileListStore = new Gtk.ListStore (typeof(string), // Nome del file
- typeof(string), // Dimensione
typeof(string), // Utente
typeof(string));// Path del file.
@@ -55,22 +50,17 @@ namespace Dizzy
filenameColumn.PackStart (filenameRenderer, true);
filenameColumn.AddAttribute (filenameRenderer, "text", 0);
- // Dimensione del file
- Gtk.CellRendererText sizeRenderer = new Gtk.CellRendererText ();
- sizeColumn.PackStart (sizeRenderer, true);
- sizeColumn.AddAttribute (sizeRenderer, "text", 1);
- // Tipo di file
+ // Utente
Gtk.CellRendererText userRenderer = new Gtk.CellRendererText ();
userColumn.PackStart (userRenderer, true);
- userColumn.AddAttribute (userRenderer, "text", 2);
+ userColumn.AddAttribute (userRenderer, "text", 1);
}
public void AddFile(Dizzy.File file)
{
// Aggiungo i valori effettivi nel liststore.
fileListStore.AppendValues(file.name,
- file.SizeToString () ,
file.user,
file.path);
}
@@ -80,5 +70,14 @@ namespace Dizzy
fileListStore.Clear ();
}
+ public File GetFileFromPath (TreePath path)
+ {
+ TreeIter iter = new TreeIter ();
+ fileListStore.GetIter(out iter, path);
+ File f = new File((string) fileListStore.GetValue(iter, 0),
+ (string) fileListStore.GetValue(iter, 1));
+ return f;
+ }
+
}
}
diff --git a/Main.cs b/Main.cs
index 23aec21..b5f5c13 100644
--- a/Main.cs
+++ b/Main.cs
@@ -3,14 +3,38 @@ using Gtk;
namespace Dizzy
{
+
class MainClass
{
+
public static void Main (string[] args)
{
Application.Init ();
- MainWindow win = new MainWindow ();
- win.Show ();
- Application.Run ();
+
+ // Inizializziamo la configurazione generale.
+ // Forse sarebbe il caso di salvarla su file e
+ // poi passarla per riferimento a tutte le form.
+ GlobalConfig config = new GlobalConfig ();
+
+ // Cosa vogliamo fare
+ MainWindow win;
+ StartupDialog s;
+
+ s = new StartupDialog (ref config);
+ s.Run ();
+
+ try
+ {
+ win = new MainWindow (config.user, config.password);
+ win.ShowAll ();
+ Application.Run ();
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(" => Problemi di autenticazione...non riprovo");
+ Console.WriteLine(e.Message);
+ }
+
}
}
}
diff --git a/MainWindow.cs b/MainWindow.cs
index cf17566..72938a8 100644
--- a/MainWindow.cs
+++ b/MainWindow.cs
@@ -9,7 +9,7 @@ public partial class MainWindow : Gtk.Window
FileTreeView files;
TaskTreeView tasks;
- public MainWindow () : base(Gtk.WindowType.Toplevel)
+ public MainWindow (string user, string password) : base(Gtk.WindowType.Toplevel)
{
Build ();
@@ -20,7 +20,7 @@ public partial class MainWindow : Gtk.Window
// .. e anche quella dei download
tasks = new Dizzy.TaskTreeView (tasklist);
- this.protocol = new Protocol ("robol", "E2omhj99");
+ this.protocol = new Protocol (user, password);
}
@@ -35,5 +35,12 @@ public partial class MainWindow : Gtk.Window
{
this.protocol.Search(searchBox.Text, ref this.files);
}
+
+ protected virtual void OnRowActivated (object o, Gtk.RowActivatedArgs args)
+ {
+ File f = this.files.GetFileFromPath (args.Path);
+ // this.tasks.AddTask (f.name, 24);
+ this.protocol.Download(f, ref tasks);
+ }
}
diff --git a/Protocol.cs b/Protocol.cs
index 2eba354..60043c0 100644
--- a/Protocol.cs
+++ b/Protocol.cs
@@ -92,12 +92,23 @@ namespace Dizzy
this.sftpUpdater.Disconnect ();
}
+
+ public void Download(File f, ref TaskTreeView tasks)
+ {
+ SFTPConnection sftp = new SFTPConnection(this.user, this.password);
+ sftp.Connect ();
+
+ }
+
}
public class SFTPConnection
{
- Sftp sftp;
+ public Sftp sftp;
+
+ public delegate void Delegate (string src, string dest,
+ int transferredBytes, int totalBytes, string message);
public SFTPConnection (string user, string password)
{
@@ -106,26 +117,20 @@ namespace Dizzy
this.sftp = new Sftp ("poisson.phc.unipi.it", user);
this.sftp.Password = password;
+ }
+
+ public void SetTransferHandlers(Delegate OnTransferStart,
+ Delegate OnTransferProgress,
+ Delegate OnTransferEnd)
+ {
+
this.sftp.OnTransferStart += new FileTransferEvent (OnTransferStart);
this.sftp.OnTransferProgress += new FileTransferEvent (OnTransferProgress);
this.sftp.OnTransferEnd += new FileTransferEvent (OnTransferEnd);
}
- private void OnTransferStart (string src, string dest, int transferredBytes, int totalBytes, string message)
- {
- System.Console.WriteLine(" => Transfer Starting...");
- }
-
- private void OnTransferProgress (string src, string dest, int trasferredBytes, int totalBytes, string message)
- {
- System.Console.WriteLine(" => Tranfer progress....");
- }
- private void OnTransferEnd (string src, string dest, int trasferredBytes, int totalBytes, string message)
- {
- System.Console.WriteLine(" => Tranfer Finished!");
- }
public void Connect()
{
@@ -173,7 +178,7 @@ namespace Dizzy
user = folder;
if(user.Contains("/"))
user = user.Substring(0, user.IndexOf("/"));
- f = new File(folder + "/" + entry, 0, user );
+ f = new File(folder + "/" + entry, user );
matches.Add(f);
}
}
diff --git a/gtk-gui/MainWindow.cs b/gtk-gui/MainWindow.cs
index ae6039d..b2df7e0 100644
--- a/gtk-gui/MainWindow.cs
+++ b/gtk-gui/MainWindow.cs
@@ -76,7 +76,7 @@ public partial class MainWindow {
this.notebook1 = new Gtk.Notebook();
this.notebook1.CanFocus = true;
this.notebook1.Name = "notebook1";
- this.notebook1.CurrentPage = 1;
+ this.notebook1.CurrentPage = 0;
// Container child notebook1.Gtk.Notebook+NotebookChild
this.vbox3 = new Gtk.VBox();
this.vbox3.Name = "vbox3";
@@ -209,5 +209,6 @@ public partial class MainWindow {
this.DeleteEvent += new Gtk.DeleteEventHandler(this.OnDeleteEvent);
this.searchBox.Activated += new System.EventHandler(this.OnSearchRequested);
this.button1.Clicked += new System.EventHandler(this.OnSearchRequested);
+ this.filelist.RowActivated += new Gtk.RowActivatedHandler(this.OnRowActivated);
}
}
diff --git a/gtk-gui/gui.stetic b/gtk-gui/gui.stetic
index 58d1ecc..86d9e7b 100644
--- a/gtk-gui/gui.stetic
+++ b/gtk-gui/gui.stetic
@@ -36,7 +36,7 @@
<widget class="Gtk.Notebook" id="notebook1">
<property name="MemberName" />
<property name="CanFocus">True</property>
- <property name="CurrentPage">1</property>
+ <property name="CurrentPage">0</property>
<child>
<widget class="Gtk.VBox" id="vbox3">
<property name="MemberName" />
@@ -104,6 +104,7 @@
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="ShowScrollbars">True</property>
+ <signal name="RowActivated" handler="OnRowActivated" />
</widget>
</child>
</widget>
@@ -221,4 +222,192 @@
</widget>
</child>
</widget>
+ <widget class="Gtk.Dialog" id="Dizzy.StartupDialog" design-size="508 178">
+ <property name="MemberName" />
+ <property name="Title" translatable="yes">DIzzy Login</property>
+ <property name="WindowPosition">CenterOnParent</property>
+ <property name="Buttons">2</property>
+ <property name="HelpButton">False</property>
+ <child internal-child="VBox">
+ <widget class="Gtk.VBox" id="dialog1_VBox">
+ <property name="MemberName" />
+ <property name="Spacing">5</property>
+ <property name="BorderWidth">5</property>
+ <child>
+ <widget class="Gtk.VBox" id="vbox2">
+ <property name="MemberName" />
+ <property name="Spacing">6</property>
+ <child>
+ <widget class="Gtk.Label" id="label1">
+ <property name="MemberName" />
+ <property name="LabelProp" translatable="yes">Inserire nome utente e password per autenticarsi su <b>poisson.phc.unipi.it</b></property>
+ <property name="UseMarkup">True</property>
+ </widget>
+ <packing>
+ <property name="Position">0</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.HSeparator" id="hseparator1">
+ <property name="MemberName" />
+ </widget>
+ <packing>
+ <property name="Position">1</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Table" id="table1">
+ <property name="MemberName" />
+ <property name="NRows">2</property>
+ <property name="NColumns">2</property>
+ <property name="RowSpacing">6</property>
+ <property name="ColumnSpacing">6</property>
+ <property name="BorderWidth">5</property>
+ <child>
+ <widget class="Gtk.Entry" id="entryPassword">
+ <property name="MemberName" />
+ <property name="CanFocus">True</property>
+ <property name="IsEditable">True</property>
+ <property name="InvisibleChar">•</property>
+ </widget>
+ <packing>
+ <property name="TopAttach">1</property>
+ <property name="BottomAttach">2</property>
+ <property name="LeftAttach">1</property>
+ <property name="RightAttach">2</property>
+ <property name="AutoSize">True</property>
+ <property name="YOptions">Fill</property>
+ <property name="XExpand">True</property>
+ <property name="XFill">True</property>
+ <property name="XShrink">False</property>
+ <property name="YExpand">False</property>
+ <property name="YFill">True</property>
+ <property name="YShrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Entry" id="entryUser">
+ <property name="MemberName" />
+ <property name="CanFocus">True</property>
+ <property name="IsEditable">True</property>
+ <property name="InvisibleChar">•</property>
+ </widget>
+ <packing>
+ <property name="LeftAttach">1</property>
+ <property name="RightAttach">2</property>
+ <property name="AutoSize">True</property>
+ <property name="YOptions">Fill</property>
+ <property name="XExpand">True</property>
+ <property name="XFill">True</property>
+ <property name="XShrink">False</property>
+ <property name="YExpand">False</property>
+ <property name="YFill">True</property>
+ <property name="YShrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Label" id="label4">
+ <property name="MemberName" />
+ <property name="LabelProp" translatable="yes">Utente</property>
+ </widget>
+ <packing>
+ <property name="AutoSize">True</property>
+ <property name="XOptions">Fill</property>
+ <property name="YOptions">Fill</property>
+ <property name="XExpand">False</property>
+ <property name="XFill">True</property>
+ <property name="XShrink">False</property>
+ <property name="YExpand">False</property>
+ <property name="YFill">True</property>
+ <property name="YShrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Label" id="label5">
+ <property name="MemberName" />
+ <property name="LabelProp" translatable="yes">Password</property>
+ </widget>
+ <packing>
+ <property name="TopAttach">1</property>
+ <property name="BottomAttach">2</property>
+ <property name="AutoSize">True</property>
+ <property name="XOptions">Fill</property>
+ <property name="YOptions">Fill</property>
+ <property name="XExpand">False</property>
+ <property name="XFill">True</property>
+ <property name="XShrink">False</property>
+ <property name="YExpand">False</property>
+ <property name="YFill">True</property>
+ <property name="YShrink">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="Position">2</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="Position">0</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child internal-child="ActionArea">
+ <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
+ <property name="MemberName" />
+ <property name="Spacing">10</property>
+ <property name="BorderWidth">5</property>
+ <property name="Size">2</property>
+ <property name="LayoutStyle">End</property>
+ <child>
+ <widget class="Gtk.Button" id="buttonCancel">
+ <property name="MemberName" />
+ <property name="CanDefault">True</property>
+ <property name="CanFocus">True</property>
+ <property name="UseStock">True</property>
+ <property name="Type">StockItem</property>
+ <property name="StockId">gtk-cancel</property>
+ <property name="ResponseId">-6</property>
+ <property name="label">gtk-cancel</property>
+ </widget>
+ <packing>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Button" id="buttonOk">
+ <property name="MemberName" />
+ <property name="CanDefault">True</property>
+ <property name="CanFocus">True</property>
+ <property name="UseStock">True</property>
+ <property name="Type">StockItem</property>
+ <property name="StockId">gtk-ok</property>
+ <property name="ResponseId">-5</property>
+ <signal name="Activated" handler="OnOkClicked" />
+ <signal name="Clicked" handler="OnOkClicked" />
+ <property name="label">gtk-ok</property>
+ </widget>
+ <packing>
+ <property name="Position">1</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</stetic-interface>
\ No newline at end of file