[rygel] media-export: Use sort criteria in virtual folders



commit b89eb8a9d49335639b9fec1008172198c365c39b
Author: Jens Georg <jensg openismus com>
Date:   Fri Aug 2 15:20:30 2013 +0200

    media-export: Use sort criteria in virtual folders
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702228

 .../rygel-media-export-media-cache.vala            |   13 ++++++++++++-
 .../rygel-media-export-node-query-container.vala   |    3 ++-
 .../rygel-media-export-sql-factory.vala            |    2 +-
 3 files changed, 15 insertions(+), 3 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 b8912c0..603a556 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -431,6 +431,7 @@ public class Rygel.MediaExport.MediaCache : Object {
                                          string          filter,
                                          GLib.ValueArray args,
                                          long            offset,
+                                         string          sort_criteria,
                                          long            max_count,
                                          bool            add_all_container)
                                          throws Error {
@@ -441,12 +442,20 @@ public class Rygel.MediaExport.MediaCache : Object {
 
         var data = new ArrayList<string> ();
 
+        var sql_sort_order = MediaCache.translate_sort_criteria (sort_criteria);
+
+        // title here is actually the meta-data column, so if we had
+        // dc:title in the sort criteria, we need to change this
+        sql_sort_order = sql_sort_order.replace ("o.title", "_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),
+        var cursor = this.db.exec_cursor (sql.printf (column,
+                                                      filter,
+                                                      sql_sort_order),
                                           args.values);
         foreach (var statement in cursor) {
             data.add (statement.column_text (0));
@@ -461,6 +470,7 @@ public class Rygel.MediaExport.MediaCache : Object {
     public Gee.List<string> get_object_attribute_by_search_expression
                                         (string            attribute,
                                          SearchExpression? expression,
+                                         string            sort_criteria,
                                          long              offset,
                                          uint              max_count,
                                          bool              add_all_container)
@@ -479,6 +489,7 @@ public class Rygel.MediaExport.MediaCache : Object {
                                                     filter,
                                                     args,
                                                     offset,
+                                                    sort_criteria,
                                                     max_objects,
                                                     add_all_container);
     }
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 f534910..9259b3e 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
@@ -50,7 +50,7 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer {
         var data = this.media_db.get_object_attribute_by_search_expression
                                         (this.attribute,
                                          this.expression,
-                                         // sort criteria
+                                         sort_criteria,
                                          offset,
                                          max_count,
                                          this.add_all_container ());
@@ -83,6 +83,7 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer {
             var data = this.media_db.get_object_attribute_by_search_expression
                                         (this.attribute,
                                          this.expression,
+                                         "+dc:title",
                                          0,
                                          -1,
                                          this.add_all_container ());
diff --git a/src/plugins/media-export/rygel-media-export-sql-factory.vala 
b/src/plugins/media-export/rygel-media-export-sql-factory.vala
index ffd0064..09b6cd4 100644
--- a/src/plugins/media-export/rygel-media-export-sql-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-sql-factory.vala
@@ -185,7 +185,7 @@ internal class Rygel.MediaExport.SQLFactory : Object {
 
     private const string GET_META_DATA_COLUMN_STRING =
     "SELECT DISTINCT %s AS _column FROM meta_data AS m " +
-        "WHERE _column IS NOT NULL %s ORDER BY _column COLLATE CASEFOLD " +
+        "WHERE _column IS NOT NULL %s %s" +
     "LIMIT ?,?";
 
     internal const string SCHEMA_VERSION = "15";


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