[rygel] core, tracker: MetadataValues.is_child_id_unique -> SimpleContainer



commit c7d84f83f25491a7b53f0794f02acb9ea84d186c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Dec 22 14:56:10 2010 +0200

    core,tracker: MetadataValues.is_child_id_unique -> SimpleContainer
    
    Move is_child_id_unique() method of MetadataValues to parent
    SimpleContainer and make it 'public' as its useful for all users.
    
    This method was broken for (intially) empty containers after the
    introduction of SimpleContainer.add_child_container. This patch also fixes
    that issue by comparing the ID string in question with that of emtpy child
    containers as well.

 .../tracker/rygel-tracker-metadata-values.vala     |   14 -----------
 src/rygel/rygel-simple-container.vala              |   25 ++++++++++++++++++++
 2 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-metadata-values.vala b/src/plugins/tracker/rygel-tracker-metadata-values.vala
index 064fb58..beb664a 100644
--- a/src/plugins/tracker/rygel-tracker-metadata-values.vala
+++ b/src/plugins/tracker/rygel-tracker-metadata-values.vala
@@ -192,19 +192,5 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
                                          RESOURCES_PATH,
                                          DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
     }
-
-    private bool is_child_id_unique (string child_id) {
-        var unique = true;
-
-        foreach (var child in this.children) {
-            if (child.id == child_id) {
-                unique = false;
-
-                break;
-            }
-        }
-
-        return unique;
-    }
 }
 
diff --git a/src/rygel/rygel-simple-container.vala b/src/rygel/rygel-simple-container.vala
index 1abdb0c..55dd96b 100644
--- a/src/rygel/rygel-simple-container.vala
+++ b/src/rygel/rygel-simple-container.vala
@@ -80,6 +80,31 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer,
         this.child_count = 0;
     }
 
+    public bool is_child_id_unique (string child_id) {
+        var unique = true;
+
+        foreach (var child in this.children) {
+            if (child.id == child_id) {
+                unique = false;
+
+                break;
+            }
+        }
+
+        if (unique) {
+            // Check the pending empty containers
+            foreach (var child in this.empty_children) {
+                if (child.id == child_id) {
+                    unique = false;
+
+                    break;
+                }
+            }
+        }
+
+        return unique;
+    }
+
     public override async MediaObjects? get_children (uint         offset,
                                                       uint         max_count,
                                                       Cancellable? cancellable)



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