[rygel] Add simple gconf configuration



commit a112db84f28239912446214500beba94be415dd6
Author: Jens Georg <mail jensge org>
Date:   Wed Apr 29 23:17:47 2009 +0200

    Add simple gconf configuration
---
 src/plugins/folder/Makefile.am                     |   53 +++++++++++--------
 src/plugins/folder/rygel-folder-media-item.vala    |   55 ++++++++++++++++++++
 src/plugins/folder/rygel-folder-plugin.vala        |   46 ++++-------------
 src/plugins/folder/rygel-folder-rootcontainer.vala |    4 +-
 4 files changed, 99 insertions(+), 59 deletions(-)

diff --git a/src/plugins/folder/Makefile.am b/src/plugins/folder/Makefile.am
index cad99af..d802d67 100644
--- a/src/plugins/folder/Makefile.am
+++ b/src/plugins/folder/Makefile.am
@@ -3,35 +3,46 @@ plugindir = $(libdir)/rygel-1.0
 plugin_LTLIBRARIES = librygel-media-folder.la
 
 AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
-	    $(LIBGUPNP_AV_CFLAGS) \
-	    $(LIBDBUS_GLIB_CFLAGS) \
-	    $(LIBGSTREAMER_CFLAGS) \
-	    $(GEE_CFLAGS) \
-	    -I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"'
+	$(LIBGUPNP_AV_CFLAGS) \
+	$(LIBDBUS_GLIB_CFLAGS) \
+	$(LIBGSTREAMER_CFLAGS) \
+	$(LIBGCONF_CFLAGS) \
+	$(GEE_CFLAGS) \
+	-I$(top_srcdir)/src/rygel -DDATA_DIR='"$(datadir)"'
 
 BUILT_SOURCES = rygel-media-folder.stamp \
-				rygel-folder-plugin.c
+	rygel-folder-rootcontainer.c \
+	rygel-folder-media-item.c \
+	rygel-folder-plugin.c
 
 librygel_media_folder_la_SOURCES = \
-									rygel-folder-plugin.h \
-									rygel-folder-plugin.c \
-									rygel-folder-plugin.vala \
-									rygel-folder-rootcontainer.h \
-									rygel-folder-rootcontainer.c \
-									rygel-folder-rootcontainer.vala
+	rygel-folder-plugin.c \
+	rygel-folder-plugin.vala \
+	rygel-folder-rootcontainer.c \
+	rygel-folder-rootcontainer.vala \
+	rygel-folder-media-item.c \
+	rygel-folder-media-item.vala
 
 rygel-media-folder.stamp: $(filter %.vala,$(librygel_media_folder_la_SOURCES))
-	$(VALAC) -C --vapidir=$(top_srcdir)/src/rygel \
-	--pkg rygel-1.0 --pkg cstuff \
-	--pkg gupnp-1.0 --pkg gupnp-av-1.0 \
-        --pkg libsoup-2.4 --pkg gee-1.0 --pkg libxml-2.0 $^
+	$(VALAC) -g -C --vapidir=$(top_srcdir)/src/rygel \
+	--pkg rygel-1.0 \
+	--pkg cstuff \
+	--pkg gupnp-1.0 \
+	--pkg gupnp-av-1.0 \
+	--pkg libsoup-2.4 \
+	--pkg gee-1.0 \
+	--pkg libxml-2.0 \
+	--pkg gconf-2.0 \
+	$^
 	touch $@
 
-librygel_media_folder_la_LIBADD = $(LIBGUPNP_LIBS) \
-			       	   $(LIBGUPNP_AV_LIBS) \
-                          $(LIBDBUS_GLIB_LIBS) \
-	                  $(LIBGSTREAMER_LIBS) \
-				   $(GEE_LIBS)
+librygel_media_folder_la_LIBADD = \
+	$(LIBGUPNP_LIBS) \
+	$(LIBGUPNP_AV_LIBS) \
+	$(LIBDBUS_GLIB_LIBS) \
+	$(LIBGSTREAMER_LIBS) \
+	$(LIBGCONF_LIBS) \
+	$(GEE_LIBS)
 librygel_media_folder_la_LDFLAGS = -shared -fPIC -module -avoid-version
 
 CLEANFILES = $(BUILT_SOURCES)
diff --git a/src/plugins/folder/rygel-folder-media-item.vala b/src/plugins/folder/rygel-folder-media-item.vala
new file mode 100644
index 0000000..f11dddf
--- /dev/null
+++ b/src/plugins/folder/rygel-folder-media-item.vala
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008-2009 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using GLib;
+using Rygel;
+
+/**
+ * Very simple media item. 
+ */
+public class Folder.FilesystemMediaItem : Rygel.MediaItem {
+    public FilesystemMediaItem(MediaContainer parent, 
+                               File file, 
+                               FileInfo file_info) {
+        string item_class;
+        var content_type = file_info.get_content_type();
+
+        if (content_type.has_prefix("video/")) {
+            item_class = MediaItem.VIDEO_CLASS;
+        }
+        else if (content_type.has_prefix("audio/")) {
+            item_class = MediaItem.AUDIO_CLASS;
+        }
+        else if (content_type.has_prefix("image/")) {
+            item_class = MediaItem.IMAGE_CLASS;
+        }
+        else {
+            return;
+        }
+
+        base(Checksum.compute_for_string(ChecksumType.MD5, file_info.get_name()), 
+             parent,
+             file_info.get_name(),
+             item_class);
+
+        this.mime_type = content_type;
+        this.uris.add(GLib.Markup.escape_text(file.get_uri()));
+    }
+}
diff --git a/src/plugins/folder/rygel-folder-plugin.vala b/src/plugins/folder/rygel-folder-plugin.vala
index 1ebe505..b133df1 100644
--- a/src/plugins/folder/rygel-folder-plugin.vala
+++ b/src/plugins/folder/rygel-folder-plugin.vala
@@ -22,6 +22,7 @@ using Rygel;
 using GUPnP;
 using Gee;
 using GLib;
+using GConf;
 
 /**
  * Simple plugin which exposes the media contents of a directory via UPnP.
@@ -49,44 +50,17 @@ public Plugin load_plugin() {
 }
 
 public class Folder.FolderContentDir : ContentDirectory {
-
-    // FIXME get some configuration for this
-    public static const string DIR = "/home/jens/Media";
-
     public override MediaContainer? create_root_container () {
-        return new FolderRootContainer (DIR);
-    }
-}
-
-/**
- * Very simple media item. 
- */
-public class Folder.FilesystemMediaItem : Rygel.MediaItem {
-    public FilesystemMediaItem(MediaContainer parent, 
-                               File file, 
-                               FileInfo file_info) {
-        string item_class;
-        var content_type = file_info.get_content_type();
-
-        if (content_type.has_prefix("video/")) {
-            item_class = MediaItem.VIDEO_CLASS;
-        }
-        else if (content_type.has_prefix("audio/")) {
-            item_class = MediaItem.AUDIO_CLASS;
+        GConf.Client client = GConf.Client.get_default();
+        try {
+            string dir = client.get_string("/apps/rygel/Folder/folder");
+            message("Using folder %s", dir);
+            return new FolderRootContainer (dir);
         }
-        else if (content_type.has_prefix("image/")) {
-            item_class = MediaItem.IMAGE_CLASS;
+        catch (GLib.Error error) {
+            return null;
         }
-        else {
-            return;
-        }
-
-        base(Checksum.compute_for_string(ChecksumType.MD5, file_info.get_name()), 
-             parent,
-             file_info.get_name(),
-             item_class);
-
-        this.mime_type = content_type;
-        this.uris.add(GLib.Markup.escape_text(file.get_uri()));
     }
 }
+
+
diff --git a/src/plugins/folder/rygel-folder-rootcontainer.vala b/src/plugins/folder/rygel-folder-rootcontainer.vala
index a6dd69e..3a139b8 100644
--- a/src/plugins/folder/rygel-folder-rootcontainer.vala
+++ b/src/plugins/folder/rygel-folder-rootcontainer.vala
@@ -99,8 +99,8 @@ public class Folder.FolderRootContainer : MediaContainer {
                 foreach (FileInfo info in list) {
                     var file = this.root_dir.get_child(info.get_name());
                     var item = new FilesystemMediaItem(this, file, info);
-                    if (item != null)
-                        items.add(item);
+                    /*if (item != null)
+                        items.add(item); */
                 }
                 file_enumerator.next_files_async (MAX_CHILDREN, 
                                                   Priority.DEFAULT, 



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