media-db: Rename get_children_with_filter
authorJens Georg <mail@jensge.org>
Sat, 21 Nov 2009 00:21:52 +0000 (01:21 +0100)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 19 Jan 2010 15:04:36 +0000 (17:04 +0200)
The function is not fetching children but arbitrary objects.

src/rygel/rygel-media-db-container.vala
src/rygel/rygel-media-db.vala

index 0f62b38..623b779 100644 (file)
@@ -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;
     }
 
index 1481c89..b4aea52 100644 (file)
@@ -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;
     }
 }