[rygel/wip/create-reference] wip
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/create-reference] wip
- Date: Thu, 28 Feb 2013 12:55:37 +0000 (UTC)
commit c0cec2577e4c8197e7e920e836f10099d8121f4a
Author: Jens Georg <jensg openismus com>
Date: Thu Feb 28 12:46:32 2013 +0100
wip
src/librygel-server/rygel-reference-creator.vala | 64 +++++++++++++++++++++-
1 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/src/librygel-server/rygel-reference-creator.vala
b/src/librygel-server/rygel-reference-creator.vala
index 9f84796..474334b 100644
--- a/src/librygel-server/rygel-reference-creator.vala
+++ b/src/librygel-server/rygel-reference-creator.vala
@@ -1,3 +1,25 @@
+/*
+ * Copyright (C) 2013 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
using GUPnP;
internal class Rygel.ReferenceCreator : GLib.Object, Rygel.StateMachine {
@@ -13,6 +35,46 @@ internal class Rygel.ReferenceCreator : GLib.Object, Rygel.StateMachine {
}
public async void run () {
- Idle.add ( () => { this.action.return(); this.completed (); return false; } );
+ var container = yield this.fetch_container ();
}
+
+ /**
+ * Get the container to create the item in.
+ *
+ * This will either try to fetch the container supplied by the caller or
+ * search for a container if the caller supplied the "DLNA.ORG_AnyContainer"
+ * id.
+ *
+ * @return an instance of WritableContainer matching the criteria
+ * @throws ContentDirectoryError for various problems
+ */
+ private async WritableContainer fetch_container () throws Error {
+ MediaObject media_object = null;
+
+ if (this.container_id == MediaContainer.ANY) {
+ media_object = yield this.find_any_container ();
+ } else {
+ media_object = yield this.content_dir.root_container.find_object
+ (this.container_id, this.cancellable);
+ }
+
+ if (media_object == null || !(media_object is MediaContainer)) {
+ throw new ContentDirectoryError.NO_SUCH_OBJECT
+ (_("No such object"));
+ } else if (!(OCMFlags.UPLOAD in media_object.ocm_flags) ||
+ !(media_object is WritableContainer)) {
+ debug ("=> %s %s", (OCMFlags.UPLOAD in
+ media_object.ocm_flags).to_string (),
+ (media_object is WritableContainer).to_string ());
+ throw new ContentDirectoryError.RESTRICTED_PARENT
+ (_("Object creation in %s not allowed"),
+ media_object.id);
+ }
+
+ // FIXME: Check for @restricted=1 missing?
+
+ return media_object as WritableContainer;
+ }
+
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]