[libdmapsharing] Work on Vala code, including adding requirement for GObject to DMAPDb, ContainerDb, Record and DACPP



commit f9d0b728c35644f8f120bc4baa298610b3e9a2af
Author: W. Michael Petullo <mike flyn org>
Date:   Fri Jan 7 10:52:55 2011 -0600

    Work on Vala code, including adding requirement for GObject to DMAPDb, ContainerDb, Record and DACPPlayer interfaces
    Signed-off-by: W. Michael Petullo <mike flyn org>

 libdmapsharing/dacp-player.c       |    1 +
 libdmapsharing/dmap-container-db.c |    1 +
 libdmapsharing/dmap-db.c           |    1 +
 libdmapsharing/dmap-record.c       |    1 +
 tests/Makefile.am                  |    4 ++-
 tests/dacplisten.vala              |   41 ++++++++++++++++++------
 tests/dmapserve.vala               |   62 ++++++++++++++++++++++++++++++++++++
 tests/vala-dmap-container-db.vala  |   43 +++++++++++++++++++++++++
 tests/vala-dmap-db.vala            |    4 +-
 vala/Makefile.am                   |    4 ++
 10 files changed, 149 insertions(+), 13 deletions(-)
---
diff --git a/libdmapsharing/dacp-player.c b/libdmapsharing/dacp-player.c
index e2a4bda..3a22e46 100644
--- a/libdmapsharing/dacp-player.c
+++ b/libdmapsharing/dacp-player.c
@@ -91,6 +91,7 @@ dacp_player_get_type (void)
 		object_type = g_type_register_static(G_TYPE_INTERFACE,
 		                                     "DACPPlayer",
 		                                     &object_info, 0);
+		g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
 	}
 	return object_type;
 }
diff --git a/libdmapsharing/dmap-container-db.c b/libdmapsharing/dmap-container-db.c
index 8ad2535..4198301 100644
--- a/libdmapsharing/dmap-container-db.c
+++ b/libdmapsharing/dmap-container-db.c
@@ -49,6 +49,7 @@ dmap_container_db_get_type (void)
 		    g_type_register_static(G_TYPE_INTERFACE,
 					   "DMAPContainerDb",
 					   &object_info, 0);
+		g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
 	}
 	return object_type;
 }
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index c12ca2c..193073f 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -57,6 +57,7 @@ dmap_db_get_type (void)
 		    g_type_register_static(G_TYPE_INTERFACE,
 					   "DMAPDb",
 					   &object_info, 0);
+		g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
 	}
 	return object_type;
 }
diff --git a/libdmapsharing/dmap-record.c b/libdmapsharing/dmap-record.c
index d876e0b..e40f8a4 100644
--- a/libdmapsharing/dmap-record.c
+++ b/libdmapsharing/dmap-record.c
@@ -49,6 +49,7 @@ dmap_record_get_type (void)
 		    g_type_register_static(G_TYPE_INTERFACE,
 					   "DMAPRecord",
 					   &object_info, 0);
+		g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
 	}
 	return object_type;
 }
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3c9b648..59511de 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -66,7 +66,9 @@ endif
 
 if HAVE_VALA
 dacplisten_VALASOURCES = \
-	dacplisten.vala
+	dacplisten.vala \
+	vala-dmap-db.vala \
+	vala-dmap-container-db.vala
 
 dacplisten_VALABUILTSOURCES = $(dacplisten_VALASOURCES:.vala=.c)
 
diff --git a/tests/dacplisten.vala b/tests/dacplisten.vala
index 1ff9bff..b11b52f 100644
--- a/tests/dacplisten.vala
+++ b/tests/dacplisten.vala
@@ -20,45 +20,66 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-private class ValaDACPPlayer : DACP.Player {
+private class ValaDACPPlayer : GLib.Object, DACP.Player {
 
 	unowned DAAP.Record now_playing_record () {
-		stdout.printf ("Now playing record request received");
+		stdout.printf ("Now playing record request received\n");
 		return null;
 	}
 
 	/* FIXME: This should return uint8[], modify dacp-player.h? */
 	unowned string now_playing_artwork (uint width, uint heigth) {
-		stdout.printf ("Now playing artwork request received");
+		stdout.printf ("Now playing artwork request received\n");
 		return null;
 	}
 
 	void play_pause () {
-		stdout.printf ("Play/pause request received");
+		stdout.printf ("Play/pause request received\n");
 	}
 
 	void pause () {
-		stdout.printf ("Pause request received");
+		stdout.printf ("Pause request received\n");
 	}
 
 	void next_item () {
-		stdout.printf ("Next item request received");
+		stdout.printf ("Next item request received\n");
 	}
 
 	void prev_item () {
-		stdout.printf ("Previous item request received");
+		stdout.printf ("Previous item request received\n");
 	}
 
 	void cue_clear () {
-		stdout.printf ("Cue clear request received");
+		stdout.printf ("Cue clear request received\n");
 	}
 
 	void cue_play (GLib.List records, uint index) {
-		stdout.printf ("Cue play request received");
+		stdout.printf ("Cue play request received\n");
 	}
 }
 
-private class DACPListener {
+private class DACPListener : GLib.Object {
+	private DMAP.Db db;
+	private DMAP.ContainerDb container_db;
+	private DACP.Player player;
+	private DACP.Share share;
+
+	public DACPListener () {
+		db = new ValaDMAPDb ();
+		container_db = new ValaDMAPContainerDb ();
+		player = new ValaDACPPlayer ();
+		share = new DACP.Share ("dacplisten", player, db, container_db);
+
+		share.remote_found.connect ((service_name, display_name) => {
+			stdout.printf ("Found remote: %s, %s\n", service_name, display_name);
+		});
+
+		share.add_guid.connect ((guid) => {
+			stdout.printf ("Add GUID request received\n");
+		});
+
+		share.start_lookup ();
+	}
 }
 
 int main (string[] args) {     
diff --git a/tests/dmapserve.vala b/tests/dmapserve.vala
new file mode 100644
index 0000000..5f5b260
--- /dev/null
+++ b/tests/dmapserve.vala
@@ -0,0 +1,62 @@
+/*   FILE: dmapserve.vala -- Serve media using DMAP
+ * AUTHOR: W. Michael Petullo <mike flyn org>
+ *   DATE: 21 December 2010 
+ *
+ * Copyright (c) 2010 W. Michael Petullo <new flyn org>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+private class DPAPServe {
+	ValaDPAPRecord record;
+	ValaDMAPDb db;
+	ValaDMAPContainerDb container_db;
+	DPAP.Share share;
+
+	public DPAPServe () throws GLib.Error {
+		record = new ValaDPAPRecord ();
+		db = new ValaDMAPDb ();
+		db.add (record);
+		container_db = new ValaDMAPContainerDb ();
+		share = new DPAP.Share ("dmapserve", null, db, container_db, null);
+	}
+}
+
+void debug_printf (string? log_domain,
+		   GLib.LogLevelFlags log_level,
+		   string? message)
+{
+	stdout.printf ("%s\n", message);
+}
+
+void debug_null (string? log_domain,
+		 GLib.LogLevelFlags log_level,
+		 string? message)
+{
+}
+
+int main (string[] args) {     
+	var loop = new GLib.MainLoop ();
+
+	GLib.Log.set_handler ("libdmapsharing", GLib.LogLevelFlags.LEVEL_DEBUG, debug_printf);
+	GLib.Log.set_handler (null, GLib.LogLevelFlags.LEVEL_DEBUG, debug_printf);
+
+	var dmapcopy = new DPAPServe ();
+
+	loop.run ();
+
+	return 0;
+}
diff --git a/tests/vala-dmap-container-db.vala b/tests/vala-dmap-container-db.vala
new file mode 100644
index 0000000..645eba0
--- /dev/null
+++ b/tests/vala-dmap-container-db.vala
@@ -0,0 +1,43 @@
+/*   FILE: vala-dmap-db.vala -- A DMAPContainerDb implementation in Vala
+ * AUTHOR: W. Michael Petullo <mike flyn org>
+ *   DATE: 21 December 2010 
+ *
+ * Copyright (c) 2010 W. Michael Petullo <new flyn org>
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+private class ValaDMAPContainerDb : GLib.Object, DMAP.ContainerDb {
+	// A dumb database that stores everything in an array
+
+	/* FIXME: What is with this unowned? */
+	private Gee.ArrayList<unowned DMAP.Record> db = new Gee.ArrayList<DMAP.Record> ();
+
+	public int64 count () {
+		return db.size;
+	}
+
+	public void @foreach (GLib.HFunc func) {
+		int i;
+		for (i = 0; i < db.size; i++) {
+			func (i.to_pointer (), db[i]);
+		}
+	}
+
+	public unowned DMAP.ContainerRecord lookup_by_id (uint id) {
+		GLib.error ("lookup_by_id not implemented");
+	}
+}
diff --git a/tests/vala-dmap-db.vala b/tests/vala-dmap-db.vala
index 846e8b5..92ca811 100644
--- a/tests/vala-dmap-db.vala
+++ b/tests/vala-dmap-db.vala
@@ -24,10 +24,10 @@ private class ValaDMAPDb : GLib.Object, DMAP.Db {
 	// A dumb database that stores everything in an array
 
 	/* FIXME: What is with this unowned? */
-	private Gee.ArrayList<unowned ValaDPAPRecord> db = new Gee.ArrayList<ValaDPAPRecord> ();
+	private Gee.ArrayList<unowned DMAP.Record> db = new Gee.ArrayList<DMAP.Record> ();
 
 	public uint add (DMAP.Record record) {
-		db.add (((ValaDPAPRecord) record));
+		db.add (((DMAP.Record) record));
 		return db.size;
 	}
 
diff --git a/vala/Makefile.am b/vala/Makefile.am
index 2eaef10..9bc7f5a 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -33,6 +33,10 @@ libdmapsharing- API_VERSION@.vapi: libdmapsharing- API_VERSION@-daap.vapi libdma
 	cat libdmapsharing- API_VERSION@.vapi | \
 		sed 's/DAAP\.DMAPDb/DMAP.Db/g' | \
 		sed 's/DPAP\.DMAPDb/DMAP.Db/g' | \
+		sed 's/DACP\.DMAPDb/DMAP.Db/g' | \
+		sed 's/DAAP\.DMAPContainerDb/DMAP.ContainerDb/g' | \
+		sed 's/DPAP\.DMAPContainerDb/DMAP.ContainerDb/g' | \
+		sed 's/DACP\.DMAPContainerDb/DMAP.ContainerDb/g' | \
 		sed 's/DAAP\.DMAPRecordFactory/DMAP.RecordFactory/g' | \
 		sed 's/DPAP\.DMAPRecordFactory/DMAP.RecordFactory/g' | \
 		sed 's/DACP\.DAAPRecord/DAAP.Record/g' | \



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