[banshee] [Gio] Fix GIO backend, requiring glib >= 2.22



commit dae871c745db9eb27c2ff9bce080b4d6fb2a8a84
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Fri Jan 15 16:06:39 2010 -0800

    [Gio] Fix GIO backend, requiring glib >= 2.22

 build/m4/banshee/gio.m4                            |    4 +++
 configure.ac                                       |    2 +-
 .../Banshee.Gio/Banshee.IO.Gio/DemuxVfs.cs         |    6 +---
 src/Backends/Banshee.Gio/Banshee.IO.Gio/Tests.cs   |   21 ++++++++++++++++---
 4 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/build/m4/banshee/gio.m4 b/build/m4/banshee/gio.m4
index e475465..e0700be 100644
--- a/build/m4/banshee/gio.m4
+++ b/build/m4/banshee/gio.m4
@@ -12,6 +12,10 @@ AC_DEFUN([BANSHEE_CHECK_GIO_SHARP],
 		gio-sharp-2.0 >= $GNOMESHARP_REQUIRED,
         enable_gio="$enable_gio", enable_gio=no)
 
+	PKG_CHECK_MODULES(GLIB_2_22,
+		glib-2.0 >= 2.22,
+        enable_gio="$enable_gio", enable_gio=no)
+
 	AM_CONDITIONAL(ENABLE_GIO, test "x$enable_gio" = "xyes")
 ])
 
diff --git a/configure.ac b/configure.ac
index 9a4cf55..bbdf37d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,7 +336,7 @@ ${PACKAGE}-${VERSION}
     Podcast Support:   ${enable_podcast}
     Boo Scripting:     ${enable_boo}
     Builtin Equalizer: ${enable_builtin_equalizer}
-    GIO Support:       ${enable_gio} (requires gtk-sharp-beans and gio-sharp)
+    GIO Support:       ${enable_gio} (requires glib >= 2.22, gtk-sharp-beans, and gio-sharp)
 
   Build/Development:
     Unit Tests:        ${do_tests} (requires nunit >= ${NUNIT_REQUIRED})
diff --git a/src/Backends/Banshee.Gio/Banshee.IO.Gio/DemuxVfs.cs b/src/Backends/Banshee.Gio/Banshee.IO.Gio/DemuxVfs.cs
index e5aaa51..6dd7142 100644
--- a/src/Backends/Banshee.Gio/Banshee.IO.Gio/DemuxVfs.cs
+++ b/src/Backends/Banshee.Gio/Banshee.IO.Gio/DemuxVfs.cs
@@ -61,11 +61,9 @@ namespace Banshee.IO.Gio
         }
 
         public System.IO.Stream WriteStream {
-            // FIXME we really need GFileIOStream here, but that depends on glib 2.22 (and a binding for it in gio#)
-            // as-is, this stream is write-only (not readable) which breaks taglib-sharp
             get { return new GioStream (file.Exists
-                    ? file.Replace (file_info.Etag, false, FileCreateFlags.None, null)
-                    : file.Create (FileCreateFlags.None, null)
+                    ? file.OpenReadwrite (null)
+                    : file.CreateReadwrite (FileCreateFlags.None, null)
                 );
             }
         }
diff --git a/src/Backends/Banshee.Gio/Banshee.IO.Gio/Tests.cs b/src/Backends/Banshee.Gio/Banshee.IO.Gio/Tests.cs
index 8becf44..d5a573d 100644
--- a/src/Backends/Banshee.Gio/Banshee.IO.Gio/Tests.cs
+++ b/src/Backends/Banshee.Gio/Banshee.IO.Gio/Tests.cs
@@ -155,19 +155,32 @@ namespace Banshee.IO.Gio
             var demux = new DemuxVfs (foo.AbsoluteUri);
             Assert.IsTrue (demux.IsWritable);
             Assert.IsTrue (demux.IsReadable);
+
             var stream = demux.WriteStream;
             Assert.IsTrue (stream.CanWrite);
+            Assert.IsTrue (stream.CanRead);
 
-            // Make sure can read from WriteStream - required by TagLib#
-            // FIXME - depends on glib 2.22 and new gio# - see gio DemuxVfs.cs
-            Assert.AreEqual ((byte)'b', stream.ReadByte (), "Known failure, bug in Gio backend, depends on glib 2.22 for fix");
+            // Make sure can actually read from WriteStream - required by TagLib#
+            // stream should contain 'bar', eg first byte == 'b'
+            Assert.AreEqual (3, stream.Length);
+            Assert.AreEqual ((byte)'b', stream.ReadByte (), "Error in GIO backend - shouldn't happen - fix (and the Banshee GIO backend) requires gio 2.22");
             stream.Position = 0;
 
+            // Replace the first two bytes, and truncate the third
             stream.WriteByte (0xAB);
+            stream.WriteByte (0xCD);
+            stream.SetLength (2);
+
+            // And verify those bytes are readable
+            stream.Position = 1;
+            Assert.AreEqual (0xCD, stream.ReadByte ());
+            stream.Position = 0;
+            Assert.AreEqual (0xAB, stream.ReadByte ());
 
+            // And make sure the file is now the right size; 2 bytes
             demux.CloseStream (stream);
             Assert.IsTrue (file.Exists (foo));
-            Assert.AreEqual (1, file.GetSize (foo));
+            Assert.AreEqual (2, file.GetSize (foo));
         }
 
         [Test]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]