build,core,plugins: Port to GDBus and GVariant
[profile/ivi/rygel.git] / src / plugins / media-export / rygel-media-export-dbus-service.vala
1 /*
2  * Copyright (C) 2009 Jens Georg <mail@jensge.org>.
3  *
4  * This file is part of Rygel.
5  *
6  * Rygel is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * Rygel is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 [DBus (name = "org.gnome.Rygel.MediaExport1")]
22 public class Rygel.MediaExport.DBusService : Object {
23     private const string RYGEL_MEDIA_EXPORT_PATH =
24                                         "/org/gnome/Rygel/MediaExport1";
25
26     private RootContainer root_container;
27
28     public DBusService (RootContainer root_container) throws GLib.Error {
29         this.root_container = root_container;
30
31         try {
32             var connection = Bus.get_sync (BusType.SESSION);
33
34             if (likely (connection != null)) {
35                 connection.register_object (RYGEL_MEDIA_EXPORT_PATH, this);
36             }
37         } catch (IOError err) {
38             warning (_("Failed to attach to D-Bus session bus: %s"),
39                      err.message);
40         }
41     }
42
43     public void AddUri (string uri) {
44         this.root_container.add_uri (uri);
45     }
46
47     public void RemoveUri (string uri) {
48         this.root_container.remove_uri (uri);
49     }
50
51     public string[] GetUris () {
52         return this.root_container.get_dynamic_uris ();
53     }
54 }