[rygel] Fix crash if no gconf key; Use XDG dirs then
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Subject: [rygel] Fix crash if no gconf key; Use XDG dirs then
- Date: Sun, 3 May 2009 15:16:00 -0400 (EDT)
commit 7df93dd6a6e5ed4a091d681b7a32d5eba2842b6e
Author: Jens Georg <mail jensge org>
Date: Sat May 2 16:37:07 2009 +0200
Fix crash if no gconf key; Use XDG dirs then
---
.../folder/rygel-folder-directorysearch.vala | 3 +-
.../folder/rygel-folder-foldercontainer.vala | 9 ++---
src/plugins/folder/rygel-folder-plugin.vala | 12 +-------
src/plugins/folder/rygel-folder-rootcontainer.vala | 31 +++++++++++++++++--
4 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/src/plugins/folder/rygel-folder-directorysearch.vala b/src/plugins/folder/rygel-folder-directorysearch.vala
index 3ba40b5..3e77088 100644
--- a/src/plugins/folder/rygel-folder-directorysearch.vala
+++ b/src/plugins/folder/rygel-folder-directorysearch.vala
@@ -73,8 +73,7 @@ public class Folder.DirectorySearchResult : Rygel.SimpleAsyncResult<Gee.List<Med
MediaObject item = null;
if (file_info.get_file_type() == FileType.DIRECTORY) {
item = new FolderContainer((MediaContainer)source_object,
- Checksum.compute_for_string(ChecksumType.MD5, f.get_uri()),
- f.get_uri(), false);
+ f, false);
}
else {
diff --git a/src/plugins/folder/rygel-folder-foldercontainer.vala b/src/plugins/folder/rygel-folder-foldercontainer.vala
index 8dbd926..11e6f49 100644
--- a/src/plugins/folder/rygel-folder-foldercontainer.vala
+++ b/src/plugins/folder/rygel-folder-foldercontainer.vala
@@ -140,9 +140,10 @@ public class Folder.FolderContainer : MediaContainer {
*
* @parameter directory_path, directory you want to expose
*/
- public FolderContainer (MediaContainer parent, string id, string directory_path, bool full) {
- base(id, parent, directory_path, 0);
- this.root_dir = GLib.File.new_for_uri(directory_path);
+ public FolderContainer (MediaContainer parent, File file, bool full) {
+ string id = Checksum.compute_for_string(ChecksumType.MD5, file.get_uri());
+ base(id, parent, file.get_uri(), 0);
+ this.root_dir = file;
if (!full && parent is FolderContainer) {
this.title = ((FolderContainer)parent).strip_parent(root_dir);
@@ -151,7 +152,5 @@ public class Folder.FolderContainer : MediaContainer {
this.items = new ArrayList<MediaObject> ();
this.child_count = 0;
this.results = new ArrayList<AsyncResult>();
-
-
}
}
diff --git a/src/plugins/folder/rygel-folder-plugin.vala b/src/plugins/folder/rygel-folder-plugin.vala
index da4a7b0..e33db85 100644
--- a/src/plugins/folder/rygel-folder-plugin.vala
+++ b/src/plugins/folder/rygel-folder-plugin.vala
@@ -22,7 +22,6 @@ using Rygel;
using GUPnP;
using Gee;
using GLib;
-using GConf;
/**
* Simple plugin which exposes the media contents of a directory via UPnP.
@@ -51,16 +50,7 @@ public Plugin load_plugin() {
public class Folder.FolderContentDir : ContentDirectory {
public override MediaContainer? create_root_container () {
- GConf.Client client = GConf.Client.get_default();
- try {
- string dir = client.get_string("/apps/rygel/Folder/folder");
- message("Using folder %s", dir);
- File f = File.new_for_commandline_arg(dir);
- return new FolderRootContainer (f.get_uri());
- }
- catch (GLib.Error error) {
- return null;
- }
+ return new FolderRootContainer();
}
}
diff --git a/src/plugins/folder/rygel-folder-rootcontainer.vala b/src/plugins/folder/rygel-folder-rootcontainer.vala
index 1b05952..ae981d3 100644
--- a/src/plugins/folder/rygel-folder-rootcontainer.vala
+++ b/src/plugins/folder/rygel-folder-rootcontainer.vala
@@ -21,6 +21,7 @@
using Gee;
using GLib;
using Rygel;
+using GConf;
/**
* MediaContainer which exposes the contents of a directory
@@ -90,10 +91,32 @@ public class Folder.FolderRootContainer : MediaContainer {
*
* @parameter directory_path, directory you want to expose
*/
- public FolderRootContainer (string uri) {
- base.root(uri, 0);
+ public FolderRootContainer () {
+ base.root("FolderRoot", 0);
+ GConf.Client client = GConf.Client.get_default();
this.items = new ArrayList<FolderContainer> ();
- items.add(new FolderContainer(this, "12", uri, true));
- this.child_count = 1;
+ unowned SList<string> dirs = null;
+ try {
+ dirs = client.get_list("/apps/rygel/Folder/folder", GConf.ValueType.STRING);
+ }
+ catch (GLib.Error error) {
+ message("Error fetching configuration, error was %s", error.message);
+ }
+
+ // either an error occured or the gconf key is not set
+ if (dirs == null) {
+ dirs.append(Environment.get_user_special_dir(UserDirectory.MUSIC));
+ dirs.append(Environment.get_user_special_dir(UserDirectory.PICTURES));
+ dirs.append(Environment.get_user_special_dir(UserDirectory.VIDEOS));
+ }
+
+ foreach (var dir in dirs) {
+ var f = File.new_for_commandline_arg(dir);
+ if (f.query_exists(null)) {
+ items.add(new FolderContainer(this, f, true));
+ }
+ }
+
+ this.child_count = items.size;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]