[rygel] media-db: Rename get_children_with_filter



commit e8ee82fb7fe097ed3da74dc346dc37b3dfc8b8cc
Author: Jens Georg <mail jensge org>
Date:   Sat Nov 21 01:21:52 2009 +0100

    media-db: Rename get_children_with_filter
    
    The function is not fetching children but arbitrary objects.

 src/rygel/rygel-media-db-container.vala |   13 +++++++------
 src/rygel/rygel-media-db.vala           |   27 ++++++++++++++++-----------
 2 files changed, 23 insertions(+), 17 deletions(-)
---
diff --git a/src/rygel/rygel-media-db-container.vala b/src/rygel/rygel-media-db-container.vala
index 0f62b38..623b779 100644
--- a/src/rygel/rygel-media-db-container.vala
+++ b/src/rygel/rygel-media-db-container.vala
@@ -87,12 +87,13 @@ public class Rygel.MediaDBContainer : MediaContainer {
         for (int i = 0; i < args.n_values; i++)
             debug ("Arg %d: %s", i, args.get_nth(i).get_string());
 
-        var children = this.media_db.get_children_with_filter (
-                                            filter,
-                                            args,
-                                            this.id,
-                                            offset,
-                                            max_count == 0 ? -1 :  max_count);
+        var children = this.media_db.get_objects_by_filter (
+                                             filter,
+                                             args,
+                                             this.id,
+                                             offset,
+                                             max_count == 0 ? -1 : max_count);
+        total_matches = children.size;
         return children;
     }
 
diff --git a/src/rygel/rygel-media-db.vala b/src/rygel/rygel-media-db.vala
index 1481c89..b4aea52 100644
--- a/src/rygel/rygel-media-db.vala
+++ b/src/rygel/rygel-media-db.vala
@@ -190,7 +190,7 @@ public class Rygel.MediaDB : Object {
                  "o.title ASC " +
     "LIMIT ?,?";
 
-    private const string GET_CHILDREN_STRING_WITH_FILTER =
+    private const string GET_OBJECTS_STRING_WITH_FILTER =
     "SELECT o.type_fk, o.title, m.size, m.mime_type, " +
             "m.width, m.height, m.class, m.author, m.album, " +
             "m.date, m.bitrate, m.sample_freq, m.bits_per_sample, " +
@@ -725,7 +725,7 @@ public class Rygel.MediaDB : Object {
         return children;
     }
 
-    public Gee.ArrayList<MediaObject> get_children_with_filter (
+    public Gee.ArrayList<MediaObject> get_objects_by_filter (
                                                  string filter,
                                                  GLib.ValueArray args,
                                                  string container_id,
@@ -744,17 +744,22 @@ public class Rygel.MediaDB : Object {
         Rygel.Database.RowCallback cb = (stmt) => {
             var child_id = stmt.column_text (17);
             var parent_id = stmt.column_text (18);
-            var parent = (MediaContainer) get_object (parent_id);
-            children.add (get_object_from_statement (parent,
-                                                     child_id,
-                                                     stmt));
-            children[children.size - 1].parent = parent;
-            children[children.size - 1].parent_ref = parent;
-
-            return true;
+            try {
+                var parent = (MediaContainer) get_object (parent_id);
+                children.add (get_object_from_statement (parent,
+                            child_id,
+                            stmt));
+                children[children.size - 1].parent = parent;
+                children[children.size - 1].parent_ref = parent;
+
+                return true;
+            } catch (DatabaseError e) {
+                warning ("Failed to get parent item: %s", e.message);
+                return false;
+            }
         };
 
-        this.db.exec (GET_CHILDREN_STRING_WITH_FILTER.printf(filter), args.values, cb);
+        this.db.exec (GET_OBJECTS_STRING_WITH_FILTER.printf(filter), args.values, cb);
         return children;
     }
 }



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