Mailinglist Archive: opensuse-gnome (128 mails)
| < Previous | Next > |
[opensuse-gnome] Fwd: Patch for monsoon for #386548
- From: "Alan McGovern" <alan.mcgovern@xxxxxxxxx>
- Date: Wed, 7 May 2008 23:48:29 +0100
- Message-id: <117799f00805071548x139a6868i6ffae80690f767b0@xxxxxxxxxxxxxx>
(sorry for double-post, my first email was bounced because it wasn't plaintext)
Hi,
I've created a patch for #386548[1], but i'm unsure who needs to get
it so that it can become part of the build. I've attached it here
anyway in the hopes someone knows where it should go.
Alan.
[1] https://bugzilla.novell.com/show_bug.cgi?id=386548
Index: Monsoon/MainWindow.cs
===================================================================
--- Monsoon/MainWindow.cs (revision 102555)
+++ Monsoon/MainWindow.cs (working copy)
@@ -354,6 +354,11 @@
}
}
+ public void LoadTorrent (string path)
+ {
+ torrentController.addTorrent (path, true, true);
+ }
+
private void RestoreInterfaceSettings ()
{
InterfaceSettings settings = interfaceSettings.Settings;
Index: Monsoon/Main.cs
===================================================================
--- Monsoon/Main.cs (revision 102555)
+++ Monsoon/Main.cs (working copy)
@@ -81,7 +81,7 @@
GLib.Timeout.Add (1000, delegate {
try
{
-
mainWindow.TorrentController.addTorrent(arg);
+
mainWindow.TorrentController.addTorrent (arg, true, true);
}
catch (Exception ex)
{
@@ -120,12 +120,38 @@
Console.WriteLine(_("Starting Monsoon"));
Application.Init("monsoon", ref args);
+ Monsoon.GconfPreferencesSettingsController sets = new
GconfPreferencesSettingsController();
+ sets.Load ();
+
+ try
+ {
+ mainWindow = new MainWindow (settingsStorage,
engineSettings.Settings,
+ portController,
isFirstRun);
+ }
+ catch(Exception ex)
+ {
+ logger.Info("Existing instance detected");
+ if (args.Length > 0 && File.Exists(args[0]))
+ {
+ logger.Info ("Informing existing
instance of new torrent");
+ string oldPath = args[0];
+ string newPath =
Path.Combine(sets.Settings.TorrentStorageLocation, Path.GetFileName(args[0]));
+ logger.Info ("Copying: {0} to {1}",
oldPath, newPath);
+
+ if (File.Exists (newPath))
+ File.Delete (newPath);
+
+ File.Copy(oldPath, newPath ,true);
+ }
+ else
+ {
+ logger.Info ("No new torrents
detected");
+ }
+ Environment.Exit (0);
+ }
- mainWindow = new MainWindow (settingsStorage,
engineSettings.Settings,
-
portController, isFirstRun);
-
+ StartLocalFileWatcher (mainWindow,
sets.Settings.TorrentStorageLocation);
GLib.ExceptionManager.UnhandledException += new
GLib.UnhandledExceptionHandler(OnUnhandledException);
-
Application.Run();
try {
@@ -138,6 +164,20 @@
mainWindow.Stop ();
mainWindow.Destroy ();
}
+
+ private static void StartLocalFileWatcher (MainWindow window,
string path)
+ {
+ FileSystemWatcher watcher = new FileSystemWatcher(path,
"*.torrent");
+
+ watcher.Created += delegate (object o,
System.IO.FileSystemEventArgs e) {
+ logger.Info ("Loading: {0}", e.FullPath);
+ GLib.Timeout.Add (250, delegate {
+ window.LoadTorrent (e.FullPath);
+ return false;
+ });
+ };
+ watcher.EnableRaisingEvents = true;
+ }
public static void SetProcessName(string name)
{
Index: Monsoon/TorrentController.cs
===================================================================
--- Monsoon/TorrentController.cs (revision 102555)
+++ Monsoon/TorrentController.cs (working copy)
@@ -53,6 +53,10 @@
private Dictionary<TorrentManager, long> torrentPreviousUpload;
private Dictionary<TorrentManager, long>
torrentPreviousDownload;
private MainWindow mainWindow;
+ public MainWindow MainWindow
+ {
+ get { return mainWindow; }
+ }
private List<TorrentManager> torrentsDownloading;
private List<TorrentManager> torrentsSeeding;
@@ -197,7 +201,8 @@
if (!isUrl && moveToStorage &&
(prefSettings.TorrentStorageLocation !=
Directory.GetParent(torrentPath).ToString()) ) {
newPath =
Path.Combine(prefSettings.TorrentStorageLocation,
Path.GetFileName(torrentPath));
logger.Debug("Copying torrent to " + newPath);
- File.Copy(torrentPath, newPath, true);
+ // The files should already be in the
TorrentStorageLocation
+ //File.Copy(torrentPath, newPath, true);
if (removeOriginal) {
logger.Info("Deleting original torrent
" + torrentPath);
@@ -462,9 +467,24 @@
{
if(!prefSettings.ImportEnabled)
return;
-
- logger.Info("New torrent detected, adding " +
args.TorrentPath);
- addTorrent(args.TorrentPath,
prefSettings.StartNewTorrents, true, prefSettings.RemoveOnImport, null);
+
+ GLib.Timeout.Add (250, delegate {
+ string newPath =
Path.Combine(MainWindow.Preferences.TorrentStorageLocation,
Path.GetFileName(args.TorrentPath));
+ logger.Info ("Copying: {0} to {1}",
args.TorrentPath, newPath);
+ try
+ {
+ if (File.Exists (newPath))
+ File.Delete (newPath);
+
+ File.Copy(args.TorrentPath, newPath
,true);
+ }
+ catch (Exception ex)
+ {
+
+ }
+ return false;
+ });
+ //addTorrent(args.TorrentPath,
prefSettings.StartNewTorrents, true, prefSettings.RemoveOnImport, null);
}
public void LoadStoredTorrents()
Index: Monsoon/TorrentTreeView.cs
===================================================================
--- Monsoon/TorrentTreeView.cs (revision 102555)
+++ Monsoon/TorrentTreeView.cs (working copy)
@@ -130,7 +130,20 @@
Uri uri = new Uri(s.TrimEnd());
if(uri.IsFile){
logger.Info("URI dropped " + uri);
-
torrentController.addTorrent(uri.LocalPath);
+ string newPath =
System.IO.Path.Combine(torrentController.MainWindow.Preferences.TorrentStorageLocation,
+
System.IO.Path.GetFileName(uri.LocalPath));
+ Console.Error.WriteLine("Copying: {0}
to {1}", uri.LocalPath, newPath);
+
+ try
+ {
+ if (System.IO.File.Exists
(newPath))
+ System.IO.File.Delete
(newPath);
+
System.IO.File.Copy(uri.LocalPath, newPath ,true);
+ }
+ catch (Exception ex)
+ {
+ logger.Error ("Could not load
DND torrent: {0}", ex);
+ }
}
}
}
Hi,
I've created a patch for #386548[1], but i'm unsure who needs to get
it so that it can become part of the build. I've attached it here
anyway in the hopes someone knows where it should go.
Alan.
[1] https://bugzilla.novell.com/show_bug.cgi?id=386548
Index: Monsoon/MainWindow.cs
===================================================================
--- Monsoon/MainWindow.cs (revision 102555)
+++ Monsoon/MainWindow.cs (working copy)
@@ -354,6 +354,11 @@
}
}
+ public void LoadTorrent (string path)
+ {
+ torrentController.addTorrent (path, true, true);
+ }
+
private void RestoreInterfaceSettings ()
{
InterfaceSettings settings = interfaceSettings.Settings;
Index: Monsoon/Main.cs
===================================================================
--- Monsoon/Main.cs (revision 102555)
+++ Monsoon/Main.cs (working copy)
@@ -81,7 +81,7 @@
GLib.Timeout.Add (1000, delegate {
try
{
-
mainWindow.TorrentController.addTorrent(arg);
+
mainWindow.TorrentController.addTorrent (arg, true, true);
}
catch (Exception ex)
{
@@ -120,12 +120,38 @@
Console.WriteLine(_("Starting Monsoon"));
Application.Init("monsoon", ref args);
+ Monsoon.GconfPreferencesSettingsController sets = new
GconfPreferencesSettingsController();
+ sets.Load ();
+
+ try
+ {
+ mainWindow = new MainWindow (settingsStorage,
engineSettings.Settings,
+ portController,
isFirstRun);
+ }
+ catch(Exception ex)
+ {
+ logger.Info("Existing instance detected");
+ if (args.Length > 0 && File.Exists(args[0]))
+ {
+ logger.Info ("Informing existing
instance of new torrent");
+ string oldPath = args[0];
+ string newPath =
Path.Combine(sets.Settings.TorrentStorageLocation, Path.GetFileName(args[0]));
+ logger.Info ("Copying: {0} to {1}",
oldPath, newPath);
+
+ if (File.Exists (newPath))
+ File.Delete (newPath);
+
+ File.Copy(oldPath, newPath ,true);
+ }
+ else
+ {
+ logger.Info ("No new torrents
detected");
+ }
+ Environment.Exit (0);
+ }
- mainWindow = new MainWindow (settingsStorage,
engineSettings.Settings,
-
portController, isFirstRun);
-
+ StartLocalFileWatcher (mainWindow,
sets.Settings.TorrentStorageLocation);
GLib.ExceptionManager.UnhandledException += new
GLib.UnhandledExceptionHandler(OnUnhandledException);
-
Application.Run();
try {
@@ -138,6 +164,20 @@
mainWindow.Stop ();
mainWindow.Destroy ();
}
+
+ private static void StartLocalFileWatcher (MainWindow window,
string path)
+ {
+ FileSystemWatcher watcher = new FileSystemWatcher(path,
"*.torrent");
+
+ watcher.Created += delegate (object o,
System.IO.FileSystemEventArgs e) {
+ logger.Info ("Loading: {0}", e.FullPath);
+ GLib.Timeout.Add (250, delegate {
+ window.LoadTorrent (e.FullPath);
+ return false;
+ });
+ };
+ watcher.EnableRaisingEvents = true;
+ }
public static void SetProcessName(string name)
{
Index: Monsoon/TorrentController.cs
===================================================================
--- Monsoon/TorrentController.cs (revision 102555)
+++ Monsoon/TorrentController.cs (working copy)
@@ -53,6 +53,10 @@
private Dictionary<TorrentManager, long> torrentPreviousUpload;
private Dictionary<TorrentManager, long>
torrentPreviousDownload;
private MainWindow mainWindow;
+ public MainWindow MainWindow
+ {
+ get { return mainWindow; }
+ }
private List<TorrentManager> torrentsDownloading;
private List<TorrentManager> torrentsSeeding;
@@ -197,7 +201,8 @@
if (!isUrl && moveToStorage &&
(prefSettings.TorrentStorageLocation !=
Directory.GetParent(torrentPath).ToString()) ) {
newPath =
Path.Combine(prefSettings.TorrentStorageLocation,
Path.GetFileName(torrentPath));
logger.Debug("Copying torrent to " + newPath);
- File.Copy(torrentPath, newPath, true);
+ // The files should already be in the
TorrentStorageLocation
+ //File.Copy(torrentPath, newPath, true);
if (removeOriginal) {
logger.Info("Deleting original torrent
" + torrentPath);
@@ -462,9 +467,24 @@
{
if(!prefSettings.ImportEnabled)
return;
-
- logger.Info("New torrent detected, adding " +
args.TorrentPath);
- addTorrent(args.TorrentPath,
prefSettings.StartNewTorrents, true, prefSettings.RemoveOnImport, null);
+
+ GLib.Timeout.Add (250, delegate {
+ string newPath =
Path.Combine(MainWindow.Preferences.TorrentStorageLocation,
Path.GetFileName(args.TorrentPath));
+ logger.Info ("Copying: {0} to {1}",
args.TorrentPath, newPath);
+ try
+ {
+ if (File.Exists (newPath))
+ File.Delete (newPath);
+
+ File.Copy(args.TorrentPath, newPath
,true);
+ }
+ catch (Exception ex)
+ {
+
+ }
+ return false;
+ });
+ //addTorrent(args.TorrentPath,
prefSettings.StartNewTorrents, true, prefSettings.RemoveOnImport, null);
}
public void LoadStoredTorrents()
Index: Monsoon/TorrentTreeView.cs
===================================================================
--- Monsoon/TorrentTreeView.cs (revision 102555)
+++ Monsoon/TorrentTreeView.cs (working copy)
@@ -130,7 +130,20 @@
Uri uri = new Uri(s.TrimEnd());
if(uri.IsFile){
logger.Info("URI dropped " + uri);
-
torrentController.addTorrent(uri.LocalPath);
+ string newPath =
System.IO.Path.Combine(torrentController.MainWindow.Preferences.TorrentStorageLocation,
+
System.IO.Path.GetFileName(uri.LocalPath));
+ Console.Error.WriteLine("Copying: {0}
to {1}", uri.LocalPath, newPath);
+
+ try
+ {
+ if (System.IO.File.Exists
(newPath))
+ System.IO.File.Delete
(newPath);
+
System.IO.File.Copy(uri.LocalPath, newPath ,true);
+ }
+ catch (Exception ex)
+ {
+ logger.Error ("Could not load
DND torrent: {0}", ex);
+ }
}
}
}
| < Previous | Next > |