diff options
author | Jens Georg <jensg@openismus.com> | 2013-07-30 19:21:44 +0200 |
---|---|---|
committer | Jens Georg <jensg@openismus.com> | 2013-08-05 09:54:08 +0200 |
commit | ff1ef88e06f27e254721c0f57a447b02b2de348e (patch) | |
tree | 73cbf4138202e2263bff99824d926f386d4262f0 /src | |
parent | b587606168f0bb0742aa82c650172340e4361358 (diff) | |
download | rygel-ff1ef88e06f27e254721c0f57a447b02b2de348e.tar.gz |
media-export: Fix invalid browse response
Instead of manually adding the "All" container causing all kinds of issues
with response count and slicing we just generate a "fake" result from the SQL
query so limit and offset work as expected.
https://bugzilla.gnome.org/show_bug.cgi?id=704146
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/media-export/rygel-media-export-media-cache.vala | 15 | ||||
-rw-r--r-- | src/plugins/media-export/rygel-media-export-node-query-container.vala | 34 |
2 files changed, 27 insertions, 22 deletions
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 0fce8efb..b8912c08 100644 --- a/src/plugins/media-export/rygel-media-export-media-cache.vala +++ b/src/plugins/media-export/rygel-media-export-media-cache.vala @@ -431,7 +431,8 @@ public class Rygel.MediaExport.MediaCache : Object { string filter, GLib.ValueArray args, long offset, - long max_count) + long max_count, + bool add_all_container) throws Error { GLib.Value v = offset; args.append (v); @@ -440,7 +441,11 @@ public class Rygel.MediaExport.MediaCache : Object { var data = new ArrayList<string> (); - unowned string sql = this.sql.make (SQLString.GET_META_DATA_COLUMN); + var sql = this.sql.make (SQLString.GET_META_DATA_COLUMN); + if (add_all_container) { + sql = "SELECT 'all_place_holder' AS _column UNION " + sql; + } + var cursor = this.db.exec_cursor (sql.printf (column, filter), args.values); foreach (var statement in cursor) { @@ -457,7 +462,8 @@ public class Rygel.MediaExport.MediaCache : Object { (string attribute, SearchExpression? expression, long offset, - uint max_count) + uint max_count, + bool add_all_container) throws Error { var args = new ValueArray (0); var filter = MediaCache.translate_search_expression (expression, @@ -473,7 +479,8 @@ public class Rygel.MediaExport.MediaCache : Object { filter, args, offset, - max_objects); + max_objects, + add_all_container); } public string get_reset_token () { diff --git a/src/plugins/media-export/rygel-media-export-node-query-container.vala b/src/plugins/media-export/rygel-media-export-node-query-container.vala index c1a7dc5d..f5349101 100644 --- a/src/plugins/media-export/rygel-media-export-node-query-container.vala +++ b/src/plugins/media-export/rygel-media-export-node-query-container.vala @@ -47,28 +47,28 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer { var children = new MediaObjects (); var factory = QueryContainerFactory.get_default (); - if (this.add_all_container ()) { - var id = this.template.replace (",upnp:album,%s",""); - var container = factory.create_from_description_id (id, - _("All")); - container.parent = this; - children.add (container); - } - var data = this.media_db.get_object_attribute_by_search_expression (this.attribute, this.expression, // sort criteria offset, - max_count); + max_count, + this.add_all_container ()); foreach (var meta_data in data) { - var new_id = Uri.escape_string (meta_data, "", true); - // template contains URL escaped text. This means it might - // contain '%' chars which will makes sprintf crash - new_id = this.template.replace ("%s", new_id); - var container = factory.create_from_description_id (new_id, + string id; + MediaContainer container; + if (meta_data == "all_place_holder") { + id = this.template.replace (",upnp:album,%s", ""); + container = factory.create_from_description_id (id, _("All")); + } else { + id = Uri.escape_string (meta_data, "", true); + // template contains URL escaped text. This means it might + // contain '%' chars which will makes sprintf crash + id = this.template.replace ("%s", id); + container = factory.create_from_description_id (id, meta_data); + } container.parent = this; children.add (container); } @@ -84,10 +84,8 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer { (this.attribute, this.expression, 0, - -1); - if (this.add_all_container ()) { - return data.size + 1; - } + -1, + this.add_all_container ()); return data.size; } catch (Error error) { |