From: Jens Georg Date: Thu, 13 Dec 2012 11:13:06 +0000 (+0100) Subject: media-export: Extract some common functionality X-Git-Tag: RYGEL_0_17_5~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7313273e6c00e546a84021c2620fa0baeb6fbca1;p=profile%2Fivi%2Frygel.git media-export: Extract some common functionality --- 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); }