[rygel] media-export: Extract some common functionality



commit 7313273e6c00e546a84021c2620fa0baeb6fbca1
Author: Jens Georg <jensg openismus com>
Date:   Thu Dec 13 12:13:06 2012 +0100

    media-export: Extract some common functionality

 .../media-export/rygel-media-export-harvester.vala |   24 ++++++++++++++-----
 .../rygel-media-export-harvesting-task.vala        |    8 +-----
 2 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index 82624ee..f0a0a0f 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -64,6 +64,22 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
     }
 
     /**
+     * Check if a FileInfo is considered for extraction
+     *
+     * @param info a FileInfo
+     * @return true if file should be extracted, false otherwise
+     */
+    public static bool is_eligible (FileInfo info) {
+        return info.get_content_type ().has_prefix ("image/") ||
+               info.get_content_type ().has_prefix ("video/") ||
+               info.get_content_type ().has_prefix ("audio/") ||
+               info.get_content_type () == "application/ogg" ||
+               info.get_content_type () == "application/xml" ||
+               info.get_content_type () == "text/xml" ||
+               info.get_content_type () == "text/plain";
+    }
+
+    /**
      * Put a file on queue for meta-data extraction
      *
      * @param file the file to investigate
@@ -153,13 +169,7 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
                                         FileQueryInfoFlags.NONE,
                                         this.cancellable);
             if (info.get_file_type () == FileType.DIRECTORY ||
-                info.get_content_type ().has_prefix ("image/") ||
-                info.get_content_type ().has_prefix ("video/") ||
-                info.get_content_type ().has_prefix ("audio/") ||
-                info.get_content_type () == "application/ogg" ||
-                info.get_content_type () == "application/xml" ||
-                info.get_content_type () == "text/xml" ||
-                info.get_content_type () == "text/plain") {
+                Harvester.is_eligible (info)) {
                 string id;
                 try {
                     MediaContainer parent_container = null;
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index 6bc32d5..e487a49 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -194,13 +194,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
         } else {
             // Check if the file needs to be harvested at all either because
             // it is denied by filter or it hasn't updated
-            if (info.get_content_type ().has_prefix ("image/") ||
-                info.get_content_type ().has_prefix ("video/") ||
-                info.get_content_type ().has_prefix ("audio/") ||
-                info.get_content_type () == "application/ogg" ||
-                info.get_content_type () == "application/xml" ||
-                info.get_content_type () == "text/xml" ||
-                info.get_content_type () == "text/plain") {
+            if (Harvester.is_eligible (info)) {
                 return this.push_if_changed_or_unknown (file, info);
             }
 



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