1
/* FILE: vala-dmap-db.vala -- A DMAPDb implementation in Vala
2
* AUTHOR: W. Michael Petullo <mike@flyn.org>
3
* DATE: 21 December 2010
5
* Copyright (c) 2010 W. Michael Petullo <new@flyn.org>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
private class ValaDMAPDb : GLib.Object, DMAP.Db {
24
// A dumb database that stores everything in an array
26
/* FIXME: What is with this unowned? */
27
private Gee.ArrayList<unowned DMAP.Record> db = new Gee.ArrayList<DMAP.Record> ();
29
public uint add (DMAP.Record record) {
30
db.add (((DMAP.Record) record));
31
db.add (((DMAP.Record) record));
35
public uint add_path (string path) {
36
GLib.error ("add_path not implemented");
39
public uint add_with_id (DMAP.Record record, uint id) {
40
GLib.error ("add_with_id not implemented");
43
public int64 count () {
47
public void @foreach (GLib.HFunc func) {
49
for (i = 0; i < db.size; i++) {
50
// NOTE: iPhoto does not like a record ID of 0,
51
// so we pretend to start with 1
52
func ((i + 1).to_pointer (), db[i]);
56
public unowned DMAP.Record lookup_by_id (uint id) {
57
// NOTE: iPhoto does not like a record ID of 0,
58
// so we pretend to start with 1
59
return db.get ((int) id - 1);
63
public uint lookup_id_by_location (string location){
64
GLib.error ("lookup_id_by_location not implemented");