build,core,plugins: Port to GDBus and GVariant
[profile/ivi/rygel.git] / src / plugins / external / rygel-external-plugin.vala
1 /*
2  * Copyright (C) 2009 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
3  * Copyright (C) 2009 Nokia Corporation.
4  *
5  * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
6  *                               <zeeshan.ali@nokia.com>
7  *
8  * This file is part of Rygel.
9  *
10  * Rygel is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * Rygel is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software Foundation,
22  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  */
24
25 using FreeDesktop;
26
27 public class Rygel.External.Plugin : Rygel.MediaServerPlugin {
28     public string service_name;
29     public string root_object;
30
31     // Root container properties
32     public uint child_count;
33     public bool searchable;
34
35     public Plugin (string    service_name,
36                    string    title,
37                    uint      child_count,
38                    bool      searchable,
39                    string    root_object,
40                    IconInfo? icon) {
41         base (service_name,
42               title,
43               "Rygel External " + title);
44
45         this.service_name = service_name;
46         this.child_count = child_count;
47         this.searchable = searchable;
48         this.root_object = root_object;
49         if (icon != null) {
50             this.add_icon (icon);
51         }
52     }
53
54     public override MediaContainer? get_root_container (GUPnP.Context context) {
55         Container root_container = null;
56
57         try {
58             root_container = new Container ("0",
59                                             this.title,
60                                             this.child_count,
61                                             this.searchable,
62                                             this.service_name,
63                                             this.root_object,
64                                             context.host_ip,
65                                             null);
66         } catch (IOError err) {
67             critical ("Failed to connect to session bus: %s", err.message);
68         }
69
70         return root_container;
71     }
72 }