rygel r322 - trunk/src/rygel



Author: zeeshanak
Date: Mon Dec  1 16:39:18 2008
New Revision: 322
URL: http://svn.gnome.org/viewvc/rygel?rev=322&view=rev

Log:
Refactor MediaServerFactory.

Put the saving of modified desc into a separate method.

Modified:
   trunk/src/rygel/rygel-media-server-factory.vala

Modified: trunk/src/rygel/rygel-media-server-factory.vala
==============================================================================
--- trunk/src/rygel/rygel-media-server-factory.vala	(original)
+++ trunk/src/rygel/rygel-media-server-factory.vala	Mon Dec  1 16:39:18 2008
@@ -73,7 +73,6 @@
                                 modified_desc);
     }
 
-    /* FIXME: No need to create modified desc if it already exists */
     private Xml.Doc * create_desc (Plugin plugin,
                                    string desc_path,
                                    string gconf_path) throws GLib.Error {
@@ -107,23 +106,7 @@
             /* Put/Set XboX specific stuff to description */
             add_xbox_specifics (doc);
 
-        /* Save the modified description.xml into the user's config dir.
-         * We do this so that we can host the modified file, and also to
-         * make sure the generated UDN stays the same between sessions. */
-        FileStream f = FileStream.open (desc_path, "w+");
-        int res = -1;
-
-        if (f != null)
-            res = Xml.Doc.dump (f, doc);
-
-        if (f == null || res == -1) {
-            string message = "Failed to write modified description" +
-                             " to %s.\n".printf (desc_path);
-
-            delete doc;
-
-            throw new IOError.FAILED (message);
-        }
+        save_modified_desc (doc, desc_path);
 
         return doc;
     }
@@ -337,5 +320,23 @@
         this.context.host_path (icon_info.path, "/" + url);
         icon_node->new_child (null, "url", url);
     }
+
+    private void save_modified_desc (Xml.Doc *doc,
+                                     string   desc_path) throws GLib.Error {
+        FileStream f = FileStream.open (desc_path, "w+");
+        int res = -1;
+
+        if (f != null)
+            res = Xml.Doc.dump (f, doc);
+
+        if (f == null || res == -1) {
+            string message = "Failed to write modified description" +
+                             " to %s.\n".printf (desc_path);
+
+            delete doc;
+
+            throw new IOError.FAILED (message);
+        }
+    }
 }
 



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