[libdmapsharing] Get dpapview and dmapserve to work nicely together Signed-off-by: W. Michael Petullo <mike flyn org>



commit 384ff08bc5ac322a6b7b29c652f5efce8f97b086
Author: W. Michael Petullo <mike flyn org>
Date:   Wed Dec 22 21:43:07 2010 -0600

    Get dpapview and dmapserve to work nicely together
    Signed-off-by: W. Michael Petullo <mike flyn org>

 tests/dpapview.vala         |   17 ++++++++++-------
 tests/vala-dpap-record.vala |   36 +++++++++++++++++++++++++-----------
 2 files changed, 35 insertions(+), 18 deletions(-)
---
diff --git a/tests/dpapview.vala b/tests/dpapview.vala
index 21fd658..8173021 100644
--- a/tests/dpapview.vala
+++ b/tests/dpapview.vala
@@ -31,12 +31,15 @@ private class DPAPViewer {
 		GLib.debug ("%lld entries\n", db.count ());
 
 		db.foreach ((k, v) => {
-			string path;
-			int fd = GLib.FileUtils.open_tmp ("dpapview.XXXXXX", out path);
-			GLib.FileUtils.set_contents (path, (string) ((ValaDPAPRecord) v).thumbnail, ((ValaDPAPRecord) v).filesize);
-			var pixbuf = new Gdk.Pixbuf.from_file (path);
-			GLib.FileUtils.close (fd);
-			GLib.FileUtils.unlink (path);
+			Gdk.Pixbuf pixbuf = null;
+			if (((ValaDPAPRecord) v).filesize > 0) {
+				string path;
+				int fd = GLib.FileUtils.open_tmp ("dpapview.XXXXXX", out path);
+				GLib.FileUtils.set_contents (path, (string) ((ValaDPAPRecord) v).thumbnail, ((ValaDPAPRecord) v).filesize);
+				pixbuf = new Gdk.Pixbuf.from_file (path);
+				GLib.FileUtils.close (fd);
+				GLib.FileUtils.unlink (path);
+			}
 
 			Gtk.TreeIter iter;
 			liststore.append (out iter);
@@ -79,7 +82,7 @@ int main (string[] args) {
 
 	try {
 		var builder = new Gtk.Builder ();
-		builder.add_from_file ("dpapview.ui");
+		builder.add_from_file ("tests/dpapview.ui");
 
 		var dpapviewer = new DPAPViewer (builder);
 
diff --git a/tests/vala-dpap-record.vala b/tests/vala-dpap-record.vala
index e6f8b20..c1c972d 100644
--- a/tests/vala-dpap-record.vala
+++ b/tests/vala-dpap-record.vala
@@ -26,11 +26,11 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
 	private string _aspect_ratio;
 	private string _format;
 	private string _comments;
-	private uchar *_thumbnail;
+	private string _thumbnail;
 	private int _filesize;
 	private int _large_filesize;
-	private int _height;
-	private int _width;
+	private int _pixel_height;
+	private int _pixel_width;
 	private int _rating;
 	private int _creation_date;
 
@@ -54,7 +54,7 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
 		set { _format = value; }
 	}
 
-	public uchar *thumbnail {
+	public string thumbnail {
 		get { return _thumbnail; }
 		set { _thumbnail = value; }
 	}
@@ -74,14 +74,14 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
 		set { _large_filesize = value; }
 	}
 
-	public int height {
-		get { return _height; }
-		set { _height = value; }
+	public int pixel_height {
+		get { return _pixel_height; }
+		set { _pixel_height = value; }
 	}
 
-	public int width {
-		get { return _width; }
-		set { _width = value; }
+	public int pixel_width {
+		get { return _pixel_width; }
+		set { _pixel_width = value; }
 	}
 
 	public int rating {
@@ -107,7 +107,21 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
 	}
 
 	public ValaDPAPRecord () {
-		location = "FIXME";
+		_location = "file://" + GLib.Environment.get_current_dir () + "/media/test.jpeg";
+		_aspect_ratio = "1.333";
+		_filename = GLib.Path.get_basename (_location);
+		_format = "JPEG";
+		_comments = "Comments";
+		_large_filesize = 13953;
+		_pixel_height = 480;
+		_pixel_width = 640;
+		_rating = 5;
+		_creation_date = 0;
+
+		size_t size;
+		string path = GLib.Environment.get_current_dir () + "/media/test.jpeg";
+		GLib.FileUtils.get_contents (path, out _thumbnail, out size);
+		_filesize = (int) size;
 	}
 }
 



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