[rygel] core: Hack XBox search for upnp:class



commit 593bdbbb49a26066636c0bbb9d864dacad64eb21
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Sep 22 23:50:37 2010 +0300

    core: Hack XBox search for upnp:class
    
    Yet another XBox quirk: It can't handle '0' as value for TotalMatches in
    response of search for upnp:class.

 src/rygel/rygel-search.vala     |   21 ++++++++++++++-------
 src/rygel/rygel-xbox-hacks.vala |   24 ++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/src/rygel/rygel-search.vala b/src/rygel/rygel-search.vala
index 05c418e..d6a48a5 100644
--- a/src/rygel/rygel-search.vala
+++ b/src/rygel/rygel-search.vala
@@ -65,13 +65,20 @@ internal class Rygel.Search:  Rygel.MediaQueryAction {
             throw parser.err;
         }
 
-        var results = yield container.search (parser.expression,
-                                              this.index,
-                                              this.requested_count,
-                                              out this.total_matches,
-                                              this.cancellable);
-
-        return results;
+        if (this.xbox_hacks != null) {
+            return yield this.xbox_hacks.search (container,
+                                                 parser.expression,
+                                                 this.index,
+                                                 this.requested_count,
+                                                 out this.total_matches,
+                                                 this.cancellable);
+        } else {
+            return yield container.search (parser.expression,
+                                           this.index,
+                                           this.requested_count,
+                                           out this.total_matches,
+                                           this.cancellable);
+        }
     }
 
     protected override void handle_error (Error error) {
diff --git a/src/rygel/rygel-xbox-hacks.vala b/src/rygel/rygel-xbox-hacks.vala
index 8a0676f..1c325f4 100644
--- a/src/rygel/rygel-xbox-hacks.vala
+++ b/src/rygel/rygel-xbox-hacks.vala
@@ -85,6 +85,30 @@ internal class Rygel.XBoxHacks : GLib.Object {
         }
     }
 
+    public async MediaObjects? search (MediaContainer container,
+                                       SearchExpression? expression,
+                                       uint              offset,
+                                       uint              max_count,
+                                       out uint          total_matches,
+                                       Cancellable?      cancellable)
+                                       throws Error {
+        var results = yield container.search (expression,
+                                              offset,
+                                              max_count,
+                                              out total_matches,
+                                              cancellable);
+        if (total_matches == 0 && expression is RelationalExpression) {
+            var rel_expression = expression as RelationalExpression;
+
+            if (likely (rel_expression.operand1 != null) &&
+                rel_expression.operand1 == "upnp:class") {
+                total_matches = results.size;
+            }
+        }
+
+        return results;
+    }
+
     private void modify_dms_desc (Xml.Doc doc) {
         Xml.Node *element = XMLUtils.get_element ((Xml.Node *) doc,
                                                   "root",



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