return media_object;
}
+ public override async void add_item (MediaItem item,
+ Cancellable? cancellable)
+ throws Error {
+ throw new ContentDirectoryError.RESTRICTED_PARENT (
+ _("Object creation in %s not allowed"),
+ this.id);
+ }
+
private async MediaObjects create_media_objects (
HashTable<string,Variant>[] all_props,
MediaContainer? parent
throws Error {
return new MediaObjects ();
}
+
+ public override async void add_item (MediaItem item,
+ Cancellable? cancellable)
+ throws Error {
+ throw new ContentDirectoryError.RESTRICTED_PARENT (
+ _("Object creation in %s not allowed"),
+ this.id);
+ }
}
public override async void add_item (Rygel.MediaItem item,
Cancellable? cancellable)
throws Error {
- yield base.add_item (item, cancellable);
-
item.parent = this;
item.id = MediaCache.get_id (File.new_for_uri (item.uris[0]));
this.media_db.save_item (item);
throws Error {
return new MediaObjects ();
}
+
+ public override async void add_item (MediaItem item,
+ Cancellable? cancellable)
+ throws Error {
+ throw new ContentDirectoryError.RESTRICTED_PARENT (
+ _("Object creation in %s not allowed"),
+ this.id);
+ }
}
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);
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);
public async override void add_item (MediaItem item,
Cancellable? cancellable)
throws Error {
- assert (this.uris.size > 0);
-
- 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);
- }
+ var 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);
string[] after);
}
-[DBus (name = "org.freedesktop.Tracker1.Miner")]
-public interface Rygel.Tracker.MinerIface : DBusProxy {
- public abstract async void ignore_next_update (string[] urls)
- throws IOError;
-}
-
namespace Rygel {
public const string RESOURCES_CLASS_PATH = "/org/freedesktop/Tracker1/" +
"Resources/Classes/";
}
}
+ public override async void add_item (MediaItem item,
+ Cancellable? cancellable)
+ throws Error {
+ throw new ContentDirectoryError.RESTRICTED_PARENT (
+ _("Object creation in %s not allowed"),
+ this.id);
+ }
+
public string create_child_id_for_urn (string urn) {
return this.id + "," + urn;
}
this.item.size = 0;
}
+ if (this.item.uris.size == 0) {
+ var uri = yield this.create_uri (container, this.item.title);
+ this.item.uris.add (uri);
+ }
+
+ this.item.id = this.item.uris[0];
+
yield container.add_item (this.item, this.cancellable);
this.item.serialize (didl_writer, this.content_dir.http_server);
return true;
}
+
+ public async string create_uri (MediaContainer container, string title)
+ throws Error {
+ var dir = yield container.get_writable (this.cancellable);
+ if (dir == null) {
+ throw new ContentDirectoryError.RESTRICTED_PARENT (
+ _("Object creation in %s not allowed"),
+ container.id);
+ }
+
+ var file = dir.get_child_for_display_name (title);
+
+ return file.get_uri ();
+ }
}
throws Error;
/**
+ * Add a new item directly under this container.
+ *
+ * @param item The item to add to this container
+ * @param cancellable optional cancellable for this operation
+ *
+ * return nothing.
+ *
+ */
+ public async abstract void add_item (MediaItem item, Cancellable? cancellable)
+ throws Error;
+
+ /**
* Recursively searches for all media objects the satisfy the given search
* expression in this container.
*
}
/**
- * Add a new item directly under this container.
- *
- * @param didl_item The item to add to this container.
- *
- * return nothing.
- *
- * This implementation is very basic: If no URI is provided for the item,
- * it creates the file under the first writable URI it can find for this
- * container. It also sets the ID of the item to that of the URI of the
- * item. If your subclass doesn't ID the items by their original URIs, you
- * definitely want to override this method.
- */
- public async virtual void add_item (MediaItem item,
- Cancellable? cancellable)
- throws Error {
- if (item.uris.size == 0) {
- var file = yield create_child (item.title, cancellable);
- item.uris.add (file.get_uri ());
- }
-
- item.id = item.uris[0];
- }
-
- /**
* Method to be be called each time this container is updated (metadata
* changes for this container, items under it gets removed/added or their
* metadata changes etc).
this.parent.container_updated (updated_container);
}
}
-
- private async File create_child (string title, 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 (title);
- yield file.create_async (FileCreateFlags.NONE,
- Priority.DEFAULT,
- cancellable);
-
- return file;
- }
}
foreach (var uri in this.uris) {
var file = File.new_for_uri (uri);
- var info = yield file.query_info_async (
+ try {
+ var info = yield file.query_info_async (
FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
FileQueryInfoFlags.NONE,
Priority.DEFAULT,
cancellable);
- if (info.get_attribute_boolean (FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
+
+ if (info.get_attribute_boolean (
+ FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
+ return file;
+ }
+ } catch (IOError.NOT_FOUND error) {
return file;
}
}
return media_object;
}
+
+ public override async void add_item (MediaItem item,
+ Cancellable? cancellable)
+ throws Error {
+ throw new ContentDirectoryError.RESTRICTED_PARENT (
+ _("Object creation in %s not allowed"),
+ this.id);
+ }
}