[rygel/rygel-0-18] ui: Check that autostart file exists



commit f1e5cf7971ce5f7b0b4c89a6730e842e4e3ba8de
Author: Jens Georg <jensg openismus com>
Date:   Tue Apr 30 03:57:11 2013 +0200

    ui: Check that autostart file exists
    
    Preferences should only claim that sharing is enabled when the autostart file
    exists in addition to the enable_upnp setting.
    
    Fixes confusion in http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=703281
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698572

 src/ui/rygel-writable-user-config.vala |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/ui/rygel-writable-user-config.vala b/src/ui/rygel-writable-user-config.vala
index ecd30fb..d702370 100644
--- a/src/ui/rygel-writable-user-config.vala
+++ b/src/ui/rygel-writable-user-config.vala
@@ -46,7 +46,8 @@ public class Rygel.WritableUserConfig : Rygel.UserConfig {
     public bool is_upnp_enabled () {
         try {
             var file = File.new_for_path (this.user_config);
-            if (file.query_exists ()) {
+            var autostart_file = this.get_autostart_file ();
+            if (file.query_exists () && autostart_file.query_exists ()) {
                 return this.get_upnp_enabled ();
             }
 
@@ -145,15 +146,21 @@ public class Rygel.WritableUserConfig : Rygel.UserConfig {
         this.key_file.set_boolean (section, key, value);
     }
 
+    private File get_autostart_file () throws Error {
+        var config_dir = Environment.get_user_config_dir ();
+        this.ensure_dir_exists (config_dir);
+        var dest_dir = Path.build_filename (config_dir, "autostart");
+        this.ensure_dir_exists (dest_dir);
+
+        var dest_path = Path.build_filename (dest_dir, "rygel.desktop");
+        var dest = File.new_for_path (dest_path);
+
+        return dest;
+    }
+
     private void enable_upnp (bool enable) {
         try {
-            var config_dir = Environment.get_user_config_dir ();
-            this.ensure_dir_exists (config_dir);
-            var dest_dir = Path.build_filename (config_dir, "autostart");
-            this.ensure_dir_exists (dest_dir);
-
-            var dest_path = Path.build_filename (dest_dir, "rygel.desktop");
-            var dest = File.new_for_path (dest_path);
+            var dest = this.get_autostart_file ();
 
             if (enable) {
                 // Creating the proxy starts the service


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]