[rygel/rygel-0-18] media-export: Fix invalid browse response
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/rygel-0-18] media-export: Fix invalid browse response
- Date: Fri, 9 Aug 2013 08:10:35 +0000 (UTC)
commit 009b1f90fd62a7ca7e99bc4bb065c45ed6905a2d
Author: Jens Georg <jensg openismus com>
Date: Tue Jul 30 19:21:44 2013 +0200
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
.../rygel-media-export-media-cache.vala | 15 ++++++--
.../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 907f6f0..8669311 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -423,7 +423,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);
@@ -432,7 +433,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) {
@@ -449,7 +454,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,
@@ -465,7 +471,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 c1a7dc5..f534910 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]