[rygel] core: Add MediaObject.get_writables()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Add MediaObject.get_writables()
- Date: Fri, 29 Oct 2010 12:35:40 +0000 (UTC)
commit 1cf6afdaf15b14da52de6da4da73c0ea6a2ae357
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Oct 28 17:43:05 2010 +0300
core: Add MediaObject.get_writables()
Add a method that fetches File objects for all its writable URIs.
src/rygel/rygel-media-object.vala | 48 +++++++++++++++++++++++++++---------
1 files changed, 36 insertions(+), 12 deletions(-)
---
diff --git a/src/rygel/rygel-media-object.vala b/src/rygel/rygel-media-object.vala
index 6eb651d..77915b3 100644
--- a/src/rygel/rygel-media-object.vala
+++ b/src/rygel/rygel-media-object.vala
@@ -109,18 +109,7 @@ public abstract class Rygel.MediaObject : GLib.Object {
foreach (var uri in this.uris) {
var file = File.new_for_uri (uri);
- 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)) {
- return file;
- }
- } catch (IOError.NOT_FOUND error) {
+ if (yield this.check_writable (file, cancellable)) {
return file;
}
}
@@ -128,6 +117,26 @@ public abstract class Rygel.MediaObject : GLib.Object {
return null;
}
+ /**
+ * Fetches File objects for all writable URIs available for this object.
+ *
+ * @param cancellable A GLib.Cancellable
+ */
+ public async ArrayList<File> get_writables (Cancellable? cancellable)
+ throws Error {
+ var writables = new ArrayList<File> ();
+
+ foreach (var uri in this.uris) {
+ var file = File.new_for_uri (uri);
+
+ if (yield this.check_writable (file, cancellable)) {
+ writables.add (file);
+ }
+ }
+
+ return writables;
+ }
+
internal abstract DIDLLiteObject serialize (DIDLLiteWriter writer,
HTTPServer http_server)
throws Error;
@@ -159,4 +168,19 @@ public abstract class Rygel.MediaObject : GLib.Object {
return prop1.collate (prop2);
}
}
+
+ private async bool check_writable (File file, Cancellable? cancellable)
+ throws Error {
+ try {
+ var info = yield file.query_info_async (
+ FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
+ FileQueryInfoFlags.NONE,
+ Priority.DEFAULT,
+ cancellable);
+
+ return info.get_attribute_boolean (FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+ } catch (IOError.NOT_FOUND error) {
+ return true;
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]