[rygel] Re-use existing description
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Subject: [rygel] Re-use existing description
- Date: Sun, 24 May 2009 17:03:44 -0400 (EDT)
commit 15d485ac106dde56651fbe9f8762c1f6e35ba1b5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sat May 23 02:34:57 2009 +0300
Re-use existing description
No need to always build the description from template. This will allow
us to keep some modification to the description limited to first time
user runs rygel.
---
src/rygel/rygel-media-server-factory.vala | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/rygel/rygel-media-server-factory.vala b/src/rygel/rygel-media-server-factory.vala
index 7f40a9d..0315316 100644
--- a/src/rygel/rygel-media-server-factory.vala
+++ b/src/rygel/rygel-media-server-factory.vala
@@ -76,12 +76,18 @@ public class Rygel.MediaServerFactory {
private Xml.Doc * create_desc (Plugin plugin,
string desc_path) throws GLib.Error {
- var orig_desc_path = Path.build_filename (BuildConfig.DATA_DIR,
- DESC_DOC);
+ string path;
- Xml.Doc *doc = Xml.Parser.parse_file (orig_desc_path);
+ if (this.check_path_exist (desc_path)) {
+ path = desc_path;
+ } else {
+ /* Use the template */
+ path = Path.build_filename (BuildConfig.DATA_DIR, DESC_DOC);
+ }
+
+ Xml.Doc *doc = Xml.Parser.parse_file (path);
if (doc == null) {
- string message = "Failed to parse %s".printf (orig_desc_path);
+ string message = "Failed to parse %s".printf (path);
throw new MediaServerFactoryError.XML_PARSE (message);
}
@@ -262,5 +268,11 @@ public class Rygel.MediaServerFactory {
throw new IOError.FAILED (message);
}
}
+
+ private bool check_path_exist (string path) {
+ var file = File.new_for_path (path);
+
+ return file.query_exists (null);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]