Commit f9d0b728 authored by W. Michael Petullo's avatar W. Michael Petullo
Browse files

Work on Vala code, including adding requirement for GObject to DMAPDb,...


Work on Vala code, including adding requirement for GObject to DMAPDb, ContainerDb, Record and DACPPlayer interfaces
Signed-off-by: W. Michael Petullo's avatarW. Michael Petullo <mike@flyn.org>
parent 07b3a22a
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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) {
......
/* 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;
}
/* 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");
}
}
......@@ -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;
}
......
......@@ -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' | \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment