Hello everyone, OK, this is my second attempt. Let's see how this goes:) It adds 3 files to libbanshee (inotify.h inotify-syscalls.h inotify-glue.c), adds Inotify.cs and Watch.cs to src. The inotify files are taken from beagle's source code, and the InotifiedWatch class is mostly ported from Muine's InotifyPlugin.cs (which did not have a copyright notice, so I did not put anything in Watch.cs). I overloaded the Library.Remove function, because it does not actually need the whole track info, id and uri is enough. Also, I changed FileLoadTransaction a bit, it can load more than 1 paths at once now. The rest of the changes are basic stuff, like initializing the watch, etc. The code works to a degree but has some major and minor problems: 1) Banshee almost always crashes when new music is added. Note that after a restart, the new files are in the library. 2) When a file or folder is deleted, I both delete it from the database and also remove it from the library, but the UI does not reflect the change. Again, after a restart you won't see the files. 3) If you don't have inotify banshee won't compile. (Heh, actually I added code to monitor files with FileSystemWatcher too in case there is no inotify, but, since there is no check for inotify at configure, this is useless.) I don't really know how to solve these problems. So, my choices were either sitting on this code forever or posting it to the mailinglist, and I chose the latter:). Sorry, if I am creating too much noise. Good day, Doğacan Güney
Attachment:
watch.tar.gz
Description: GNU Zip compressed data
? sync.patch
? burn-sharp/.deps
? burn-sharp/.libs
? burn-sharp/glue.lo
? burn-sharp/libnautilusburnglue.la
? libbanshee/.deps
? libbanshee/.libs
? libbanshee/cd-detect.lo
? libbanshee/cd-rip.lo
? libbanshee/gst-encode.lo
? libbanshee/gst-init.lo
? libbanshee/gst-misc.lo
? libbanshee/gst-player-engine.lo
? libbanshee/inotify-glue.c
? libbanshee/inotify-glue.lo
? libbanshee/inotify-syscalls.h
? libbanshee/inotify.h
? libbanshee/libbanshee.la
? libbanshee/xing/.deps
? po/.intltool-merge-cache
? src/FSWWatch.cs
? src/InotifiedWatch.cs
? src/Inotify.cs
? src/MusicBrainz.dll
? src/MusicBrainz.dll.mdb
? src/Watch.cs
? src/burn-sharp.dll
? src/burn-sharp.dll.mdb
? src/entagged-sharp.dll
? src/entagged-sharp.dll.mdb
? src/hal-sharp.dll
? src/hal-sharp.dll.mdb
? src/plugin-core.dll
? src/plugin-core.dll.mdb
Index: libbanshee/Makefile.am
===================================================================
RCS file: /cvs/gnome/banshee/libbanshee/Makefile.am,v
retrieving revision 1.12
diff -p -u -2 -r1.12 Makefile.am
--- libbanshee/Makefile.am 7 Nov 2005 08:30:01 -0000 1.12
+++ libbanshee/Makefile.am 12 Nov 2005 13:39:54 -0000
@@ -26,5 +26,8 @@ libbanshee_la_SOURCES = \
gst-player-engine.h \
gst-misc.c \
- gst-misc.h
+ gst-misc.h \
+ inotify.h \
+ inotify-syscalls.h \
+ inotify-glue.c
libbanshee_la_LIBADD = $(GTK_LIBS) $(HAL_LIBS) $(GST_LIBS)
Index: src/Library.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/Library.cs,v
retrieving revision 1.27
diff -p -u -2 -r1.27 Library.cs
--- src/Library.cs 31 Oct 2005 05:35:01 -0000 1.27
+++ src/Library.cs 12 Nov 2005 13:40:06 -0000
@@ -167,4 +167,16 @@ namespace Banshee
}
+ public void Remove(int trackID, System.Uri trackUri)
+ {
+ lock(Tracks.SyncRoot) {
+ Tracks.Remove(trackID);
+ }
+
+ lock(TracksFnKeyed.SyncRoot) {
+ TracksFnKeyed.Remove(MakeFilenameKey(trackUri));
+ }
+
+ }
+
public static string MakeFilenameKey(Uri uri)
{
Index: src/LibraryTransactions.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/LibraryTransactions.cs,v
retrieving revision 1.27
diff -p -u -2 -r1.27 LibraryTransactions.cs
--- src/LibraryTransactions.cs 10 Nov 2005 03:38:00 -0000 1.27
+++ src/LibraryTransactions.cs 12 Nov 2005 13:40:06 -0000
@@ -203,5 +203,5 @@ namespace Banshee
public class FileLoadTransaction : LibraryTransaction
{
- private string path;
+ private ArrayList paths;
private bool allowLibrary, preload;
@@ -223,9 +223,16 @@ namespace Banshee
bool preload)
{
- this.path = path;
+ paths = new ArrayList();
+ if(path != null)
+ paths.Add(path);
this.allowLibrary = allowLibrary;
this.preload = preload;
}
+ public void AddPath(string path)
+ {
+ paths.Add(path);
+ }
+
public override void Run()
{
@@ -234,5 +241,8 @@ namespace Banshee
statusMessage = Catalog.GetString("Processing");
- AddMultipleFilesRaw(path);
+ foreach(string path in paths)
+ AddMultipleFilesRaw(path);
+
+ paths.Clear();
}
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/banshee/src/Makefile.am,v
retrieving revision 1.66
diff -p -u -2 -r1.66 Makefile.am
--- src/Makefile.am 11 Nov 2005 18:19:53 -0000 1.66
+++ src/Makefile.am 12 Nov 2005 13:40:06 -0000
@@ -3,5 +3,5 @@ SUBDIRS = \
MusicBrainz
-MCS_FLAGS = -debug -nowarn:0169
+MCS_FLAGS = -debug -nowarn:0169 -unsafe
TARGET = banshee.exe
@@ -91,5 +91,7 @@ banshee_sources = \
ActiveUserEventsManager.cs \
ActiveUserEvent.cs \
- LogCoreViewer.cs
+ LogCoreViewer.cs \
+ Inotify.cs \
+ Watch.cs
banshee_resources = \
Index: src/PlayerInterface.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlayerInterface.cs,v
retrieving revision 1.92
diff -p -u -2 -r1.92 PlayerInterface.cs
--- src/PlayerInterface.cs 11 Nov 2005 19:22:27 -0000 1.92
+++ src/PlayerInterface.cs 12 Nov 2005 13:40:16 -0000
@@ -102,4 +102,6 @@ namespace Banshee
private int ipodDiskUsageTextViewState;
+
+ private Watcher watcher;
private static TargetEntry [] playlistViewSourceEntries =
@@ -137,4 +139,6 @@ namespace Banshee
InstallTrayIcon();
+ watcher = new Watcher();
+
Core.Instance.DBusServer.RegisterObject(
new BansheeCore(Window, this, Core.Instance), "/org/gnome/Banshee/Core");
@@ -563,4 +567,5 @@ namespace Banshee
private void Quit()
{
+ watcher.Stop();
ActiveUserEventsManager.Instance.CancelAll();
playlistView.Shutdown();