From: Zeeshan Ali (Khattak) Date: Wed, 30 Sep 2009 12:39:32 +0000 (+0300) Subject: core: UserConfig doesn't bail-out on D-Bus unavailability X-Git-Tag: RYGEL_0_4_2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d20a625c7f90b0b7412c9cd69b549833e372442;p=profile%2Fivi%2Frygel.git core: UserConfig doesn't bail-out on D-Bus unavailability --- diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala index 2902d0d..8ea5a1b 100644 --- a/src/rygel/rygel-user-config.vala +++ b/src/rygel/rygel-user-config.vala @@ -147,16 +147,20 @@ public class Rygel.UserConfig : GLib.Object, Configuration { 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 () { @@ -290,9 +294,11 @@ public class Rygel.UserConfig : GLib.Object, Configuration { 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, @@ -304,7 +310,9 @@ public class Rygel.UserConfig : GLib.Object, Configuration { 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 {