[rygel] media-export: Clean-up search method



commit ef6412948f65f1bd0c4590dfa8def9a289d92237
Author: Jens Georg <mail jensge org>
Date:   Mon Mar 29 18:42:59 2010 +0200

    media-export: Clean-up search method

 .../rygel-media-export-root-container.vala         |   47 +++++++++++--------
 1 files changed, 27 insertions(+), 20 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index c5bf86c..c853a0e 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -126,6 +126,19 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
         return null;
     }
 
+    private bool is_find_object (SearchExpression search_expression,
+                                 out string       id) {
+        if (!(search_expression is RelationalExpression)) {
+            return false;
+        }
+
+        var expression = search_expression as RelationalExpression;
+        id = expression.operand2;
+
+        return (expression.operand1 == "@id" &&
+                expression.op == SearchCriteriaOp.EQ);
+    }
+
     public override async Gee.List<MediaObject>? search (
                                         SearchExpression expression,
                                         uint             offset,
@@ -135,6 +148,20 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
                                         throws GLib.Error {
         Gee.List<MediaObject> list;
         MediaExportQueryContainer query_container;
+        string id;
+
+        if (is_find_object (expression, out id) &&
+            id.has_prefix (MediaExportQueryContainer.PREFIX)) {
+            query_container = new MediaExportQueryContainer (this.media_db,
+                                                             id);
+            query_container.parent = this;
+
+            list = new ArrayList<MediaObject> ();
+            list.add (query_container);
+            total_matches = list.size;
+
+            return list;
+        }
 
         if (expression is RelationalExpression) {
             var exp = expression as RelationalExpression;
@@ -152,26 +179,6 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
 
                 return list;
             }
-
-            if (exp.operand1 == "@id" &&
-                exp.op == SearchCriteriaOp.EQ &&
-                exp.operand2.has_prefix (MediaExportQueryContainer.PREFIX)) {
-                var real_id = MediaExportQueryContainer.get_virtual_container_definition
-                (exp.operand2);
-                list = new ArrayList<MediaObject> ();
-                if (real_id != null) {
-                    var args = real_id.split (",");
-                    query_container = new MediaExportQueryContainer (
-                                        this.media_db,
-                                        exp.operand2,
-                                        args[args.length - 1]);
-                    query_container.parent = this;
-                    list.add (query_container);
-                }
-                total_matches = list.size;
-
-                return list;
-            }
         }
 
         if (expression is LogicalExpression) {



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