[rygel] media-export: Implement special searches for XBox



commit 7a866ebab5c77d37f9d3f36edab616022b0ebe59
Author: Jens Georg <mail jensge org>
Date:   Mon Feb 8 13:07:35 2010 +0100

    media-export: Implement special searches for XBox
    
    Use virtual containers to implement special searches for XBox.

 .../rygel-media-export-root-container.vala         |   64 ++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index e74cea5..670044d 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -19,6 +19,7 @@
  */
 
 using Gee;
+using GUPnP;
 
 /**
  * Represents the root container.
@@ -99,6 +100,69 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
         }
     }
 
+    public override async Gee.List<MediaObject>? search (
+                                        SearchExpression expression,
+                                        uint             offset,
+                                        uint             max_count,
+                                        out uint         total_matches,
+                                        Cancellable?     cancellable)
+                                        throws GLib.Error {
+        if (expression is RelationalExpression) {
+            var exp = expression as RelationalExpression;
+                MediaExportQueryContainer query_cont;
+                Gee.List<MediaObject> list;
+            if (exp.operand1 == "upnp:class" &&
+                exp.op == SearchCriteriaOp.EQ) {
+                switch (exp.operand2) {
+                    case "object.container.album.musicAlbum":
+                        query_cont = new MediaExportQueryContainer (this.media_db,
+                                                                    "upnp:album",
+                                                                    "Albums");
+                        query_cont.parent = this;
+                        list = yield query_cont.get_children (offset, max_count, cancellable);
+                        foreach (MediaObject o1 in list) {
+                            o1.upnp_class =
+                            "object.container.album.musicAlbum";
+                        }
+                        total_matches = list.size;
+                        return list;
+                    case "object.container.person.musicArtist":
+                        query_cont = new MediaExportQueryContainer (this.media_db,
+                                                                    "upnp:author",
+                                                                    "Artists");
+                        query_cont.parent = this;
+                        list = yield query_cont.get_children (offset, max_count, cancellable);
+                        foreach (MediaObject o2 in list) {
+                            o2.upnp_class =
+                                "object.container.person.musicArtist";
+                        }
+                        total_matches = list.size;
+                        return list;
+                    default:
+                        break;
+                }
+            }
+
+            if (exp.operand1 == "@id" &&
+                exp.op == SearchCriteriaOp.EQ &&
+                exp.operand2.has_prefix ("upnp:")) {
+                    var args = exp.operand2.split(",");
+                    query_cont = new MediaExportQueryContainer (this.media_db,
+                                                                exp.operand2,
+                                                                args[args.length-1]);
+                    query_cont.parent = this;
+                    list = new ArrayList<MediaObject> ();
+                    list.add (query_cont);
+                    total_matches = list.size;
+                    return list;
+                }
+        }
+
+        return yield base.search (expression, offset, max_count, out total_matches,
+        cancellable);
+    }
+
+
     public string[] get_dynamic_uris () {
         string[] result = new string[0];
         var dynamic_uris = this.dynamic_elements.get_uris ();



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