[rygel] media-export: Properly fill child-count on virtual containers



commit 9cfbc14eb6c44f9ea74976024f4684a697c6a1c4
Author: Jens Georg <mail jensge org>
Date:   Mon Feb 8 16:44:15 2010 +0100

    media-export: Properly fill child-count on virtual containers

 .../rygel-media-export-query-container.vala        |   31 ++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-query-container.vala b/src/plugins/media-export/rygel-media-export-query-container.vala
index b1f3484..2a77105 100644
--- a/src/plugins/media-export/rygel-media-export-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container.vala
@@ -74,6 +74,37 @@ internal class Rygel.MediaExportQueryContainer : Rygel.MediaDBContainer {
             }
             i += 2;
         }
+        this.child_count = this.count_children ();
+        debug ("We have %u children", this.child_count);
+    }
+
+    private uint count_children () {
+        try {
+            if (this.pattern == "") {
+                var children = this.media_db.get_objects_by_search_expression (
+                        this.expression,
+                        "0",
+                        0,
+                        -1);
+                return (uint) children.size;
+            } else {
+                uint retval = 0;
+                var data = this.media_db.get_object_attribute_by_search_expression (
+                        this.attribute,
+                        this.expression,
+                        0,
+                        -1);
+                foreach (var meta_data in data) {
+                    if (meta_data != null) {
+                        retval++;
+                    }
+                }
+
+                return retval;
+            }
+        } catch (Error e) {
+            return 0;
+        }
     }
 
     public override async Gee.List<MediaObject>? search (



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