[rygel] media-export: Fix search result



commit 88cf7020be5f96886070ce2b5525fbf4e3caee8d
Author: Jens Georg <mail jensge org>
Date:   Mon Jun 7 01:16:48 2010 +0200

    media-export: Fix search result
    
    Search was returning the the result for the current limits, not the
    overall result count. This lead to strange behaviour on e.g. XBox 360

 .../rygel-media-export-db-container.vala           |   11 +++++------
 .../rygel-media-export-media-cache.vala            |   19 +++++++++----------
 .../rygel-media-export-query-container.vala        |   11 +++++------
 3 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-db-container.vala b/src/plugins/media-export/rygel-media-export-db-container.vala
index d725c6e..55ae2f5 100644
--- a/src/plugins/media-export/rygel-media-export-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-db-container.vala
@@ -78,12 +78,11 @@ public class Rygel.MediaExport.DBContainer : MediaContainer {
         }
 
         var children = this.media_db.get_objects_by_search_expression (
-                                                                expression,
-                                                                this.id,
-                                                                offset,
-                                                                max_objects);
-
-        total_matches = children.size;
+                                        expression,
+                                        this.id,
+                                        offset,
+                                        max_objects,
+                                        out total_matches);
 
         return children;
     }
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 14eef40..c649d48 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -188,8 +188,7 @@ public class Rygel.MediaExport.MediaCache : Object {
         "JOIN Closure c ON o.upnp_id = c.descendant AND c.ancestor = ? " +
         "JOIN meta_data m " +
             "ON o.upnp_id = m.object_fk " +
-    "WHERE %s " +
-    "LIMIT ?,?";
+    "WHERE %s ";
 
 
     private const string CHILDREN_COUNT_STRING =
@@ -359,7 +358,8 @@ public class Rygel.MediaExport.MediaCache : Object {
                                         SearchExpression? expression,
                                         string            container_id,
                                         uint              offset,
-                                        uint              max_count)
+                                        uint              max_count,
+                                        out uint          total_matches)
                                         throws Error {
         var args = new GLib.ValueArray (0);
         var filter = this.search_expression_to_sql (expression, args);
@@ -376,6 +376,11 @@ public class Rygel.MediaExport.MediaCache : Object {
         }
 
         var max_objects = modify_limit (max_count);
+        total_matches = (uint) get_object_count_by_filter (filter,
+                                                           args,
+                                                           container_id,
+                                                           offset,
+                                                           max_objects);
 
         return this.get_objects_by_filter (filter,
                                            args,
@@ -422,10 +427,6 @@ public class Rygel.MediaExport.MediaCache : Object {
                                         throws Error {
         GLib.Value v = container_id;
         args.prepend (v);
-        v = offset;
-        args.append (v);
-        v = max_count;
-        args.append (v);
         long count = 0;
 
         debug ("Parameters to bind: %u", args.n_values);
@@ -452,9 +453,7 @@ public class Rygel.MediaExport.MediaCache : Object {
                                         long            max_count)
                                         throws Error {
         ArrayList<MediaObject> children = new ArrayList<MediaObject> ();
-        GLib.Value v = container_id;
-        args.prepend (v);
-        v = offset;
+        GLib.Value v = offset;
         args.append (v);
         v = max_count;
         args.append (v);
diff --git a/src/plugins/media-export/rygel-media-export-query-container.vala b/src/plugins/media-export/rygel-media-export-query-container.vala
index 8a776cc..02cd3df 100644
--- a/src/plugins/media-export/rygel-media-export-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container.vala
@@ -164,12 +164,11 @@ internal class Rygel.MediaExport.QueryContainer : DBContainer {
         }
 
         var children = this.media_db.get_objects_by_search_expression (
-                                                          combined_expression,
-                                                          "0",
-                                                          offset,
-                                                          max_objects);
-
-        total_matches = children.size;
+                                        combined_expression,
+                                        "0",
+                                        offset,
+                                        max_objects,
+                                        out total_matches);
 
         return children;
     }



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