[rygel] Move class guessing to factory method
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Subject: [rygel] Move class guessing to factory method
- Date: Sun, 3 May 2009 15:17:06 -0400 (EDT)
commit 0049f639af80a6d5fbd797ab41293e263ee53e19
Author: Jens Georg <mail jensge org>
Date: Sun May 3 01:54:19 2009 +0200
Move class guessing to factory method
---
.../rygel-folder-directory-search-result.vala | 23 ++++------------
.../folder/rygel-folder-gio-media-item.vala | 27 ++++++++++++++++++-
2 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/src/plugins/folder/rygel-folder-directory-search-result.vala b/src/plugins/folder/rygel-folder-directory-search-result.vala
index bf4a818..184a605 100644
--- a/src/plugins/folder/rygel-folder-directory-search-result.vala
+++ b/src/plugins/folder/rygel-folder-directory-search-result.vala
@@ -48,20 +48,6 @@ public class Rygel.FolderDirectorySearchResult : Rygel.SimpleAsyncResult<Gee.Lis
this.complete();
}
- private string? get_upnp_class_from_content_type(string content_type) {
- if (content_type.has_prefix("video/")) {
- return MediaItem.VIDEO_CLASS;
- }
- else if (content_type.has_prefix("audio/")) {
- return MediaItem.AUDIO_CLASS;
- }
- else if (content_type.has_prefix("image/")) {
- return MediaItem.IMAGE_CLASS;
- }
-
- return null;
- }
-
public void enumerate_next_ready(Object obj, AsyncResult res) {
var enumerator = (FileEnumerator)obj;
try {
@@ -76,11 +62,14 @@ public class Rygel.FolderDirectorySearchResult : Rygel.SimpleAsyncResult<Gee.Lis
}
else {
- var upnp_class = get_upnp_class_from_content_type(file_info.get_content_type());
- item = new Rygel.FolderGioMediaItem((MediaContainer)source_object, f, upnp_class, file_info);
+ try {
+ item = FolderGioMediaItem.create((MediaContainer)source_object, f, file_info);
+ } catch (Error error) {
+ }
}
- if (item != null)
+ if (item != null) {
data.add(item);
+ }
}
enumerator.next_files_async(MAX_CHILDREN,
diff --git a/src/plugins/folder/rygel-folder-gio-media-item.vala b/src/plugins/folder/rygel-folder-gio-media-item.vala
index 956d8f2..6efa240 100644
--- a/src/plugins/folder/rygel-folder-gio-media-item.vala
+++ b/src/plugins/folder/rygel-folder-gio-media-item.vala
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2009 Jens Georg <mail jensge org>.
+ * Copyright (C) 2009 Jens Georg <mail jensge org>.
*
* This file is part of Rygel.
*
@@ -29,6 +29,30 @@ public class Rygel.FolderGioMediaItem : Rygel.MediaItem {
private bool need_source;
private string raw_uri;
+ private static string? get_upnp_class_from_content_type(string content_type) {
+ if (content_type.has_prefix("video/")) {
+ return MediaItem.VIDEO_CLASS;
+ }
+ else if (content_type.has_prefix("audio/")) {
+ return MediaItem.AUDIO_CLASS;
+ }
+ else if (content_type.has_prefix("image/")) {
+ return MediaItem.IMAGE_CLASS;
+ }
+
+ return null;
+ }
+
+
+ public static FolderGioMediaItem? create(MediaContainer parent, File file, FileInfo file_info) {
+ var upnp_class = get_upnp_class_from_content_type(file_info.get_content_type());
+ if (upnp_class != null) {
+ return new FolderGioMediaItem(parent, file, upnp_class, file_info);
+ }
+
+ return null;
+ }
+
public FolderGioMediaItem(MediaContainer parent,
File file,
string item_class,
@@ -59,7 +83,6 @@ public class Rygel.FolderGioMediaItem : Rygel.MediaItem {
if (need_source) {
dynamic Element src = ElementFactory.make("giosrc", null);
if (src != null) {
- src.is_live = true;
src.location = raw_uri;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]