~ubuntu-branches/ubuntu/quantal/libdmapsharing/quantal

« back to all changes in this revision

Viewing changes to tests/vala-dmap-db.vala

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2011-03-29 19:52:57 UTC
  • mfrom: (0.1.2 experimental) (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110329195257-0zas0lq4c03gwo46
Tags: 2.9.7-1
Initial release. (Closes: #620060)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*   FILE: vala-dmap-db.vala -- A DMAPDb implementation in Vala
 
2
 * AUTHOR: W. Michael Petullo <mike@flyn.org>
 
3
 *   DATE: 21 December 2010 
 
4
 *
 
5
 * Copyright (c) 2010 W. Michael Petullo <new@flyn.org>
 
6
 * All rights reserved.
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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
 
21
 */
 
22
 
 
23
private class ValaDMAPDb : GLib.Object, DMAP.Db {
 
24
        // A dumb database that stores everything in an array
 
25
 
 
26
        /* FIXME: What is with this unowned? */
 
27
        private Gee.ArrayList<unowned DMAP.Record> db = new Gee.ArrayList<DMAP.Record> ();
 
28
 
 
29
        public uint add (DMAP.Record record) {
 
30
                db.add (((DMAP.Record) record));
 
31
                db.add (((DMAP.Record) record));
 
32
                return db.size;
 
33
        }
 
34
 
 
35
        public uint add_path (string path) {
 
36
                GLib.error ("add_path not implemented");
 
37
        }
 
38
 
 
39
        public uint add_with_id (DMAP.Record record, uint id) {
 
40
                GLib.error ("add_with_id not implemented");
 
41
        }
 
42
 
 
43
        public int64 count () {
 
44
                return db.size;
 
45
        }
 
46
 
 
47
        public void @foreach (GLib.HFunc func) {
 
48
                int i;
 
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]);
 
53
                }
 
54
        }
 
55
 
 
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);
 
60
        }
 
61
 
 
62
 
 
63
        public uint lookup_id_by_location (string location){
 
64
                GLib.error ("lookup_id_by_location not implemented");
 
65
        }
 
66
}