[rygel] tracker: No need for special item creation class
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] tracker: No need for special item creation class
- Date: Tue, 26 Oct 2010 13:39:44 +0000 (UTC)
commit ae263f0f6063e0a6dc18c3f2ff943dae9d23b690
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sat Oct 16 20:46:53 2010 +0300
tracker: No need for special item creation class
src/plugins/tracker/Makefile.am | 1 -
.../rygel-tracker-category-all-container.vala | 69 ++++++++++++-
.../tracker/rygel-tracker-item-creation.vala | 108 --------------------
3 files changed, 64 insertions(+), 114 deletions(-)
---
diff --git a/src/plugins/tracker/Makefile.am b/src/plugins/tracker/Makefile.am
index 209562e..a112391 100644
--- a/src/plugins/tracker/Makefile.am
+++ b/src/plugins/tracker/Makefile.am
@@ -30,7 +30,6 @@ librygel_media_tracker_la_SOURCES = rygel-tracker-root-container.vala \
rygel-tracker-query-triplet.vala \
rygel-tracker-query-triplets.vala \
rygel-tracker-item-factory.vala \
- rygel-tracker-item-creation.vala \
rygel-tracker-video-item-factory.vala \
rygel-tracker-music-item-factory.vala \
rygel-tracker-picture-item-factory.vala \
diff --git a/src/plugins/tracker/rygel-tracker-category-all-container.vala b/src/plugins/tracker/rygel-tracker-category-all-container.vala
index 021f872..0d12f77 100644
--- a/src/plugins/tracker/rygel-tracker-category-all-container.vala
+++ b/src/plugins/tracker/rygel-tracker-category-all-container.vala
@@ -25,13 +25,34 @@
using Gee;
/**
- * A simple search container that contains all the items in a category.
+ * A search container that contains all the items in a category.
*/
public class Rygel.Tracker.CategoryAllContainer : SearchContainer {
+ /* class-wide constants */
+ private const string TRACKER_SERVICE = "org.freedesktop.Tracker1";
+ private const string RESOURCES_PATH = "/org/freedesktop/Tracker1/Resources";
+ private const string MINER_SERVICE = "org.freedesktop.Tracker1.Miner.Files";
+ private const string MINER_PATH = "/org/freedesktop/Tracker1/Miner/Files";
+
+ private ResourcesIface resources;
+ private MinerIface miner;
+
public CategoryAllContainer (CategoryContainer parent) {
base ("All" + parent.id, parent, "All", parent.item_factory);
try {
+ this.resources = Bus.get_proxy_sync (BusType.SESSION,
+ TRACKER_SERVICE,
+ RESOURCES_PATH);
+ this.miner = Bus.get_proxy_sync (BusType.SESSION,
+ MINER_SERVICE,
+ MINER_PATH);
+ } catch (IOError io_error) {
+ critical (_("Failed to create D-Bus proxies: %s"),
+ io_error.message);
+ }
+
+ try {
var uri = Filename.to_uri (item_factory.upload_dir, null);
var create_classes = new ArrayList<string> ();
@@ -49,11 +70,49 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer {
throws Error {
assert (this.uris.size > 0);
- var creation = new ItemCreation (item, this, cancellable);
- yield creation.run ();
- if (creation.error != null) {
- throw creation.error;
+ string urn;
+
+ if (item.uris.size == 0) {
+ var file = yield this.prepare_file (item, cancellable);
+
+ urn = yield this.create_entry_in_store (item);
+
+ var uris = new string[] { item.uris[0] };
+ yield this.miner.ignore_next_update (uris);
+ yield file.create_async (FileCreateFlags.NONE,
+ Priority.DEFAULT,
+ cancellable);
+ } else {
+ urn = yield this.create_entry_in_store (item);
}
+
+ item.id = this.create_child_id_for_urn (urn);
+ item.parent = this;
+ }
+
+ private async File prepare_file (MediaItem item,
+ Cancellable? cancellable) throws Error {
+ var dir = yield this.get_writable (cancellable);
+ if (dir == null) {
+ throw new ContentDirectoryError.RESTRICTED_PARENT (
+ _("Object creation in %s not allowed"),
+ this.id);
+ }
+
+ var file = dir.get_child_for_display_name (item.title);
+
+ item.uris.add (file.get_uri ());
+
+ return file;
+ }
+
+ private async string create_entry_in_store (MediaItem item) throws Error {
+ var category = this.item_factory.category;
+ var query = new InsertionQuery (item, category);
+
+ yield query.execute (this.resources);
+
+ return query.id;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]