From d603a2abff4ab606fe2eb8e914693ffe42af55ec Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Mon, 1 Dec 2008 16:39:18 +0000 Subject: [PATCH] Refactor MediaServerFactory. Put the saving of modified desc into a separate method. svn path=/trunk/; revision=322 --- src/rygel/rygel-media-server-factory.vala | 37 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/rygel/rygel-media-server-factory.vala b/src/rygel/rygel-media-server-factory.vala index cf5968f..cb6e37c 100644 --- a/src/rygel/rygel-media-server-factory.vala +++ b/src/rygel/rygel-media-server-factory.vala @@ -73,7 +73,6 @@ public class Rygel.MediaServerFactory { 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 @@ public class Rygel.MediaServerFactory { /* 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 @@ public class Rygel.MediaServerFactory { 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); + } + } } -- 2.7.4