[rygel] media-export: Unify query limit modification



commit 3f3401f060d72b5cb94638f782b3a013b9eaa004
Author: Jens Georg <mail jensge org>
Date:   Sun Jul 25 14:01:56 2010 +0300

    media-export: Unify query limit modification
    
    UPnP uses different limit semantics than SQLite. The mapping was done
    twice in some cases as it was done in the calling function and the
    called function. Now it is always done within MediaCache.

 .../rygel-media-export-db-container.vala           |    7 +------
 .../rygel-media-export-media-cache.vala            |    5 +++--
 .../rygel-media-export-query-container.vala        |   14 ++------------
 3 files changed, 6 insertions(+), 20 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 bcd72d5..0e5f649 100644
--- a/src/plugins/media-export/rygel-media-export-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-db-container.vala
@@ -72,17 +72,12 @@ public class Rygel.MediaExport.DBContainer : MediaContainer {
                                                 throws GLib.Error {
         MediaObjects children = null;
 
-        var max_objects = max_count;
-        if (max_objects == 0) {
-            max_objects = -1;
-        }
-
         try {
             children = this.media_db.get_objects_by_search_expression (
                                         expression,
                                         this.id,
                                         offset,
-                                        max_objects,
+                                        max_count,
                                         out total_matches);
         } catch (MediaCacheError error) {
             if (error is MediaCacheError.UNSUPPORTED_SEARCH) {
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 f4fa83d..1675979 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -745,7 +745,7 @@ public class Rygel.MediaExport.MediaCache : Object {
                                         string            attribute,
                                         SearchExpression? expression,
                                         long              offset,
-                                        long              max_count)
+                                        uint              max_count)
                                         throws Error {
         var args = new ValueArray (0);
         var filter = this.translate_search_expression (expression,
@@ -755,12 +755,13 @@ public class Rygel.MediaExport.MediaCache : Object {
         debug ("Parsed filter: %s", filter);
 
         var column = this.map_operand_to_column (attribute);
+        var max_objects = modify_limit (max_count);
 
         return this.get_meta_data_column_by_filter (column,
                                                     filter,
                                                     args,
                                                     offset,
-                                                    max_count);
+                                                    max_objects);
     }
 
     public void flag_object (string id, string flag) throws Error {
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 7e4d92b..607f396 100644
--- a/src/plugins/media-export/rygel-media-export-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container.vala
@@ -157,17 +157,12 @@ internal class Rygel.MediaExport.QueryContainer : DBContainer {
             combined_expression = local_expression;
         }
 
-        var max_objects = max_count;
-        if (max_objects == 0) {
-            max_objects = -1;
-        }
-
         try {
             children = this.media_db.get_objects_by_search_expression (
                                             combined_expression,
                                             "0",
                                             offset,
-                                            max_objects,
+                                            max_count,
                                             out total_matches);
         } catch (MediaCacheError error) {
             if (error is MediaCacheError.UNSUPPORTED_SEARCH) {
@@ -197,17 +192,12 @@ internal class Rygel.MediaExport.QueryContainer : DBContainer {
                                           out total_matches,
                                           cancellable);
         } else {
-            var max_objects = max_count;
-            if (max_objects == 0) {
-                max_objects = -1;
-            }
-
             children = new MediaObjects ();
             var data = this.media_db.get_object_attribute_by_search_expression (
                                         this.attribute,
                                         this.expression,
                                         offset,
-                                        max_objects);
+                                        max_count);
             foreach (var meta_data in data) {
                 var new_id = Uri.escape_string (meta_data, "", true);
                 // pattern contains URL escaped text. This means it might



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