rygel r563 - trunk/src/plugins/tracker
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r563 - trunk/src/plugins/tracker
- Date: Sat, 14 Feb 2009 15:21:45 +0000 (UTC)
Author: zeeshanak
Date: Sat Feb 14 15:21:45 2009
New Revision: 563
URL: http://svn.gnome.org/viewvc/rygel?rev=563&view=rev
Log:
Prefix items' IDs with parent container's ID.
This is to recognise the parent of the item without having to ask anything
from Tracker over DBus.
Modified:
trunk/src/plugins/tracker/rygel-tracker-container.vala
trunk/src/plugins/tracker/rygel-tracker-root-container.vala
Modified: trunk/src/plugins/tracker/rygel-tracker-container.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-container.vala (original)
+++ trunk/src/plugins/tracker/rygel-tracker-container.vala Sat Feb 14 15:21:45 2009
@@ -129,7 +129,7 @@
/* Iterate through all items */
for (uint i = 0; i < child_paths.length; i++) {
- MediaObject item = this.find_item (child_paths[i]);
+ MediaObject item = this.find_item_by_path (child_paths[i]);
children.add (item);
}
@@ -153,24 +153,25 @@
}
}
- public static string get_file_category (string uri) throws GLib.Error {
- string category;
+ public MediaItem? find_item (string id) throws GLib.Error {
+ string path = this.get_item_path (id);
- category = TrackerContainer.files.GetServiceType (uri);
+ if (path == null) {
+ return null;
+ }
- return category;
+ return this.find_item_by_path (path);
}
- public MediaItem? find_item (string id) throws GLib.Error {
+ public MediaItem? find_item_by_path (string path) throws GLib.Error {
MediaItem item;
- string path = id;
if (this.child_class == MediaItem.VIDEO_CLASS) {
- item = new TrackerVideoItem (path, path, this);
+ item = new TrackerVideoItem (this.id + ":" + path, path, this);
} else if (this.child_class == MediaItem.IMAGE_CLASS) {
- item = new TrackerImageItem (path, path, this);
+ item = new TrackerImageItem (this.id + ":" + path, path, this);
} else {
- item = new TrackerMusicItem (path, path, this);
+ item = new TrackerMusicItem (this.id + ":" + path, path, this);
}
return item;
@@ -200,5 +201,35 @@
return simple_res.data;
}
}
+
+ public bool is_thy_child (string item_id) {
+ var parent_id = this.get_item_parent_id (item_id);
+
+ if (parent_id != null && parent_id == this.id) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private string? get_item_path (string item_id) {
+ var tokens = item_id.split (":", 2);
+
+ if (tokens[0] != null && tokens[1] != null) {
+ return tokens[1];
+ } else {
+ return null;
+ }
+ }
+
+ private string? get_item_parent_id (string item_id) {
+ var tokens = item_id.split (":", 2);
+
+ if (tokens[0] != null) {
+ return tokens[0];
+ } else {
+ return null;
+ }
+ }
}
Modified: trunk/src/plugins/tracker/rygel-tracker-root-container.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-root-container.vala (original)
+++ trunk/src/plugins/tracker/rygel-tracker-root-container.vala Sat Feb 14 15:21:45 2009
@@ -128,22 +128,10 @@
return container;
}
- private TrackerContainer? get_item_parent (string uri) {
+ private TrackerContainer? get_item_parent (string item_id) {
TrackerContainer container = null;
- string category;
-
- try {
- category = TrackerContainer.get_file_category (uri);
- } catch (GLib.Error error) {
- critical ("failed to find service type for %s: %s",
- uri,
- error.message);
-
- return null;
- }
-
foreach (TrackerContainer tmp in this.containers) {
- if (tmp.category == category) {
+ if (tmp.is_thy_child (item_id)) {
container = tmp;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]