lms plugin: add trackable container support (based on lms update id signal)
[profile/ivi/rygel.git] / src / plugins / lms / rygel-lms-root-container.vala
1 /*
2  * Copyright (C) 2013 Intel Corporation.
3  *
4  * Author: Jussi Kukkonen <jussi.kukkonen@intel.com>
5  *
6  * This file is part of Rygel.
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 using Rygel;
24
25 using Sqlite;
26
27 public class Rygel.LMS.RootContainer : Rygel.SimpleContainer {
28
29     private LMS.Database lms_db = null;
30
31     public RootContainer() {
32         var config = MetaConfig.get_default ();
33
34         var title = _("Shared media");
35         try {
36             title = config.get_string ("LightMediaScanner", "title");
37         } catch (GLib.Error error) {}
38
39         base.root(title);
40
41         try {
42             this.lms_db = new LMS.Database ();
43
44             this.add_child_container (new MusicRoot ("music", this, _("Music"), this.lms_db));
45             this.add_child_container (new AllVideos ("all-videos", this, _("Videos"), this.lms_db));
46             this.add_child_container (new ImageRoot ("images", this, _("Pictures"), this.lms_db));
47
48         } catch (DatabaseError e) {
49             warning ("%s\n", e.message);
50
51             /* TODO if db does not exist we should
52                wait for it to be created and then add folders.  Best to wait for the
53                LMS notification API. */
54         }
55
56     }
57
58 }