media-export: Provide a custom MediaItem class
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 4 Jun 2009 16:40:28 +0000 (19:40 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 4 Jun 2009 17:12:17 +0000 (20:12 +0300)
src/plugins/media-export/Makefile.am
src/plugins/media-export/rygel-media-export-directory-search-result.vala

index 0dba7fe..8a6182e 100644 (file)
@@ -12,6 +12,7 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
 
 BUILT_SOURCES = rygel-media-export-root-container.c \
                rygel-media-export-container.c \
+               rygel-media-export-item.c \
                rygel-media-export-directory-search-result.c \
                rygel-media-export-plugin.c
 
@@ -24,6 +25,8 @@ librygel_media_media_export_la_SOURCES = \
        rygel-media-export-root-container.vala \
        rygel-media-export-container.c \
        rygel-media-export-container.vala \
+       rygel-media-export-item.c \
+       rygel-media-export-item.vala \
        rygel-media-export-directory-search-result.c \
        rygel-media-export-directory-search-result.vala
 
index 18e1602..f1ba194 100644 (file)
@@ -67,7 +67,7 @@ public class Rygel.MediaExportDirectorySearchResult :
                                                f);
 
                     } else {
-                        media_obj = get_media_item (
+                        media_obj = new Rygel.MediaExportItem (
                                                (MediaContainer) source_object,
                                                f,
                                                file_info);
@@ -115,38 +115,5 @@ public class Rygel.MediaExportDirectorySearchResult :
 
         return children;
     }
-
-    private MediaItem? get_media_item (MediaContainer parent,
-                                       File           file,
-                                       FileInfo       info) {
-        string content_type = info.get_content_type ();
-        string item_class = null;
-        string id = Checksum.compute_for_string (ChecksumType.MD5,
-                                                 info.get_name ());
-
-        // use heuristics based on content type; will use MediaHarvester
-        // when it's ready
-
-        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;
-        }
-
-        if (null == item_class) {
-            return null;
-        }
-
-        MediaItem item = new Rygel.MediaItem (id,
-                                              parent,
-                                              info.get_name (),
-                                              item_class);
-        item.mime_type = content_type;
-        item.uris.add (file.get_uri ());
-
-        return item;
-    }
 }