2 * Copyright (C) 2013 Intel Corporation.
4 * Author: Jussi Kukkonen <jussi.kukkonen@intel.com>
6 * This file is part of Rygel.
8 * Rygel is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser 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 * Rygel 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 Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 public class Rygel.LMS.AllImages : Rygel.LMS.CategoryContainer {
27 private static const string SQL_ALL =
28 "SELECT images.id, title, artist, date, width, height, path, size, dlna_profile, dlna_mime " +
29 "FROM images, files " +
30 "WHERE dtime = 0 AND images.id = files.id " +
33 private static const string SQL_COUNT =
34 "SELECT count(images.id) " +
35 "FROM images, files " +
36 "WHERE dtime = 0 AND images.id = files.id;";
38 private static const string SQL_FIND_OBJECT =
39 "SELECT images.id, title, artist, date, width, height, path, size, dlna_profile, dlna_mime " +
40 "FROM images, files " +
41 "WHERE dtime = 0 AND files.id = ? AND images.id = files.id;";
43 private static const string SQL_ADDED =
44 "SELECT images.id, title, artist, date, width, height, path, size, dlna_profile, dlna_mime " +
45 "FROM images, files " +
46 "WHERE dtime = 0 AND images.id = files.id " +
47 "AND update_id > ? AND update_id <= ?;";
49 private static const string SQL_REMOVED =
50 "SELECT images.id, title, artist, date, width, height, path, size, dlna_profile, dlna_mime " +
51 "FROM images, files " +
52 "WHERE dtime <> 0 AND images.id = files.id " +
53 "AND update_id > ? AND update_id <= ?;";
55 protected override MediaObject? object_from_statement (Statement statement) {
56 var id = statement.column_int(0);
57 var path = statement.column_text(6);
58 var mime_type = statement.column_text(9);
60 if (mime_type == null || mime_type.length == 0){
61 /* TODO is this correct? */
62 debug ("Image item %d (%s) has no MIME type",
67 var title = statement.column_text(1);
68 var image = new ImageItem(this.build_child_id (id), this, title);
69 image.creator = statement.column_text(2);
70 TimeVal tv = { (long) statement.column_int(3), (long) 0 };
71 image.date = tv.to_iso8601 ();
72 image.width = statement.column_int(4);
73 image.height = statement.column_int(5);
74 image.size = statement.column_int(7);
75 image.mime_type = mime_type;
76 image.dlna_profile = statement.column_text(8);
77 File file = File.new_for_path(path);
78 image.add_uri (file.get_uri ());
83 public AllImages (MediaContainer parent, LMS.Database lms_db) {
89 AllImages.SQL_FIND_OBJECT,