Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
* MainWindow.cs, Main.cs, CreateTorrentDialog.cs, TorrentController.cs,
Browse files Browse the repository at this point in the history
  PeerTreeView.cs, RssManager/RssManagerDialog.cs,
  RssManager/TorrentRssWatcher.cs,
  RssManager/RssManagerController.cs, TorrentTreeView.cs: Ensure all
  events are synced on the main loop
* libs/MonoTorrent.dll: Update to head of the 0.50 branch

svn path=/trunk/monsoon/; revision=114328
  • Loading branch information
alanmcgovern committed Sep 28, 2008
1 parent 9bc6bba commit 59d2053
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 155 deletions.
9 changes: 9 additions & 0 deletions Monsoon/ChangeLog
@@ -1,3 +1,12 @@
2008-09-28 Alan McGovern <alan.mcgovern@gmail.com>

* MainWindow.cs, Main.cs, CreateTorrentDialog.cs, TorrentController.cs,
PeerTreeView.cs, RssManager/RssManagerDialog.cs,
RssManager/TorrentRssWatcher.cs,
RssManager/RssManagerController.cs, TorrentTreeView.cs: Ensure all
events are synced on the main loop
* libs/MonoTorrent.dll: Update to head of the 0.50 branch

2008-09-22 Alan McGovern <alan.mcgovern@gmail.com>

* Settings/GconfTorrentSettingsController.cs,
Expand Down
16 changes: 9 additions & 7 deletions Monsoon/CreateTorrentDialog.cs
Expand Up @@ -201,10 +201,14 @@ private void createTorrent()
creator.Comment = Comment;
creator.CreatedBy = Defines.ApplicationName;

creator.Path = SavePath;

creator.Hashed += OnHashed;

creator.Path = SavePath;

creator.Hashed += delegate(object o, TorrentCreatorEventArgs e) {
GLib.Idle.Add(delegate {
OnHashed(o, e);
return false;
});
};
TorrentCreatorAsyncResult creatorResult = creator.BeginCreate(null, BeginCreateCb);

ResponseType cancelResult = (ResponseType) progressDialog.Run();
Expand All @@ -221,9 +225,7 @@ private void createTorrent()

private void OnHashed(object sender, TorrentCreatorEventArgs args)
{
Gtk.Application.Invoke (delegate {
progressDialog.Progress = args.OverallCompletion;
});
progressDialog.Progress = args.OverallCompletion;
}

private void BeginCreateCb(IAsyncResult result)
Expand Down
1 change: 1 addition & 0 deletions Monsoon/Main.cs
Expand Up @@ -82,6 +82,7 @@ public MainClass(string [] args)

if (DBusInstance.AlreadyRunning)
{
Console.WriteLine("Already running");
DBusInstance.CommandParser.ParseCommands (args);
return;
}
Expand Down
66 changes: 46 additions & 20 deletions Monsoon/MainWindow.cs
Expand Up @@ -76,7 +76,7 @@ public partial class MainWindow: Gtk.Window

private PeerTreeView peerTreeView;
private ListStore peerListStore;
private Dictionary<PeerId, TreeIter> peers;
private Dictionary<PeerId, TreePath> peers;
private TreeModelFilter peerFilter;

private FileTreeView fileTreeView;
Expand All @@ -97,7 +97,7 @@ public partial class MainWindow: Gtk.Window

private RssManagerController rssManagerController;

internal Dictionary<PeerId, TreeIter> Peers
internal Dictionary<PeerId, TreePath> Peers
{
get { return peers; }
}
Expand Down Expand Up @@ -187,8 +187,19 @@ public MainWindow (EngineSettings engineSettings, ListenPortController portContr
{
this.engineSettings = engineSettings;
this.portController = portController;
portController.PortMapped += delegate { natStatus.PortForwarded = true; };
portController.RouterFound += delegate { natStatus.RouterFound = true; };
portController.PortMapped += delegate {
GLib.Idle.Add(delegate {
natStatus.PortForwarded = true;
return false;
});
};

portController.RouterFound += delegate {
GLib.Idle.Add(delegate {
natStatus.RouterFound = true;
return false;
});
};

interfaceSettings = new GConfInterfaceSettingsController ();
defaultTorrentSettings = new GconfTorrentSettingsController ();
Expand All @@ -203,7 +214,9 @@ public MainWindow (EngineSettings engineSettings, ListenPortController portContr

Ticker.Tick ();
Ticker.Tick ();

Build ();

Ticker.Tock ("Build");
Ticker.Tick();
BuildStatusBar();
Expand Down Expand Up @@ -251,8 +264,13 @@ public MainWindow (EngineSettings engineSettings, ListenPortController portContr
RestoreLabels ();
Ticker.Tock ("Restored labels");

folderWatcher = new TorrentFolderWatcher (new DirectoryInfo (Preferences.ImportLocation));
folderWatcher.TorrentFound += torrentController.OnTorrentFound;
folderWatcher = new TorrentFolderWatcher (new DirectoryInfo (Preferences.ImportLocation));
folderWatcher.TorrentFound += delegate(object o, TorrentWatcherEventArgs e) {
GLib.Idle.Add(delegate {
torrentController.OnTorrentFound(o, e);
return false;
});
};

if (Preferences.ImportEnabled) {
logger.Info ("Starting import folder watcher");
Expand Down Expand Up @@ -654,8 +672,8 @@ private bool FilterTorrentTree (TreeModel model, TreeIter iter)
*/

private void BuildPeerTreeView ()
{
peers = new Dictionary<MonoTorrent.Client.PeerId,Gtk.TreeIter> ();
{
peers = new Dictionary<MonoTorrent.Client.PeerId, Gtk.TreePath>();
peerTreeView = new PeerTreeView ();
peerListStore = new ListStore (typeof(PeerId));

Expand Down Expand Up @@ -771,15 +789,18 @@ private void OnLabelSelectionChanged (object sender, System.EventArgs e)

//torrentTreeView.Selection.UnselectAll();
//torrentFilter.Refilter();
}

private void updatePeersPage()
{
lock(peers)
foreach(TreeIter iter in peers.Values){
peerListStore.EmitRowChanged(peerListStore.GetPath(iter), iter);
}
}
}

private void updatePeersPage()
{
lock (peers)
{
peerListStore.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter) {
peerListStore.EmitRowChanged(path, iter);
return true;
});
}
}

private void updateStatusBar()
{
Expand Down Expand Up @@ -1182,7 +1203,7 @@ private void updateGeneralPage ()
}
}

swarmSpeedLabel.Text = ByteConverter.ConvertSpeed (torrentController.GetTorrentSwarm(manager) * manager.Torrent.PieceLength);
swarmSpeedLabel.Text = ByteConverter.ConvertSpeed (torrentController.GetTorrentSwarm(manager));
savePathValueLabel.Text = manager.SavePath;
sizeValueLabel.Text = ByteConverter.ConvertSize (manager.Torrent.Size);
createdOnValueLabel.Text = manager.Torrent.CreationDate.ToLongDateString ();
Expand Down Expand Up @@ -1543,8 +1564,13 @@ public void LoadTorrent (string path, bool ask)

try
{
TorrentManager manager = torrentController.addTorrent (torrent, savePath);
manager.PeerConnected += PeerConnected;
TorrentManager manager = torrentController.addTorrent (torrent, savePath);
manager.PeerConnected += delegate(object o, PeerConnectionEventArgs e) {
GLib.Idle.Add(delegate {
PeerConnected(o, e);
return false;
});
};
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion Monsoon/PeerTreeView.cs
Expand Up @@ -110,7 +110,7 @@ private void RenderAddress (Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gt
PeerId peer = (PeerId) model.GetValue (iter, 0);

if(peer.IsConnected)
(cell as Gtk.CellRendererText).Text = peer.Uri.Host;
(cell as Gtk.CellRendererText).Text = peer.Uri.Host + ":" + peer.Uri.Port;
}


Expand Down
28 changes: 19 additions & 9 deletions Monsoon/RssManager/RssManagerController.cs
Expand Up @@ -83,8 +83,13 @@ public bool AddWatcher(string url)
return false;

TorrentRssWatcher watcher = new TorrentRssWatcher(url);
feeds.Add(url);
watcher.TorrentFound += OnTorrentMatched;
feeds.Add(url);
watcher.TorrentFound += delegate(object o, TorrentRssWatcherEventArgs e) {
GLib.Idle.Add(delegate {
OnTorrentMatched(o, e);
return false;
});
};
watchers.Add(url, watcher);
watcher.StartWatching();
return true;
Expand All @@ -104,13 +109,18 @@ public bool RemoveWatcher(string url)


public void RestoreWatchers()
{
foreach(string feed in feeds){
TorrentRssWatcher watcher = new TorrentRssWatcher(feed);
watcher.TorrentFound += OnTorrentMatched;
watchers.Add(feed, watcher);
}

{
foreach (string feed in feeds)
{
TorrentRssWatcher watcher = new TorrentRssWatcher(feed);
watcher.TorrentFound += delegate(object o, TorrentRssWatcherEventArgs e) {
GLib.Idle.Add(delegate {
OnTorrentMatched(o, e);
return false;
});
};
watchers.Add(feed, watcher);
}
}

public void StartWatchers()
Expand Down
10 changes: 4 additions & 6 deletions Monsoon/RssManager/RssManagerDialog.cs
Expand Up @@ -98,12 +98,10 @@ private void FetchFeeds(object sender, DoWorkEventArgs args)

private void FetchFeedsCompleted(object sender, RunWorkerCompletedEventArgs args)
{
Gtk.Application.Invoke (delegate {
itemListStore.Clear();
foreach(RssItem item in controller.Items){
itemListStore.AppendValues(item);
}
});
itemListStore.Clear();
foreach(RssItem item in controller.Items){
itemListStore.AppendValues(item);
}
}


Expand Down
9 changes: 7 additions & 2 deletions Monsoon/RssManager/TorrentRssWatcher.cs
Expand Up @@ -82,8 +82,13 @@ public void StartWatching()
return;


timer = new Timer();
timer.Elapsed += OnTimedEvent;
timer = new Timer();
timer.Elapsed += delegate {
GLib.Idle.Add(delegate {
OnTimedEvent(null, null);
return false;
});
};

// Set the Interval to 30 seconds.
timer.Interval=30000;
Expand Down

0 comments on commit 59d2053

Please sign in to comment.