KeyFileFlags.KEEP_TRANSLATIONS);
debug ("Loaded user configuration from file '%s'", path);
- DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
-
- // Create proxy to Rygel
- this.rygel_obj = connection.get_object (RYGEL_SERVICE,
- RYGEL_PATH,
- RYGEL_INTERFACE);
- // and DBus
- this.dbus_obj = connection.get_object (DBUS_SERVICE,
- DBUS_PATH,
- DBUS_INTERFACE);
+ try {
+ DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
+
+ // Create proxy to Rygel
+ this.rygel_obj = connection.get_object (RYGEL_SERVICE,
+ RYGEL_PATH,
+ RYGEL_INTERFACE);
+ // and DBus
+ this.dbus_obj = connection.get_object (DBUS_SERVICE,
+ DBUS_PATH,
+ DBUS_INTERFACE);
+ } catch (DBus.Error err) {
+ debug ("Failed to connect to session bus: %s", err.message);
+ }
}
public void save () {
uint32 res;
// Start service first
- this.dbus_obj.StartServiceByName (RYGEL_SERVICE,
- (uint32) 0,
- out res);
+ if (this.dbus_obj != null) {
+ this.dbus_obj.StartServiceByName (RYGEL_SERVICE,
+ (uint32) 0,
+ out res);
+ }
// Then symlink the desktop file to user's autostart dir
var source_path = Path.build_filename (BuildConfig.DESKTOP_DIR,
this.set_bool ("general", ENABLED_KEY, true);
} else {
// Stop service first
- this.rygel_obj.Shutdown ();
+ if (this.rygel_obj != null) {
+ this.rygel_obj.Shutdown ();
+ }
// Then delete the symlink from user's autostart dir
try {