[rygel] all: Hide MediaObject.uris
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] all: Hide MediaObject.uris
- Date: Sat, 12 Jul 2014 10:18:57 +0000 (UTC)
commit 2179c5273e38f0ef858eadb76ee77839d7e2687c
Author: Jens Georg <mail jensge org>
Date: Mon Jul 7 22:04:29 2014 +0200
all: Hide MediaObject.uris
Signed-off-by: Jens Georg <mail jensge org>
examples/standalone-server.c | 4 +---
src/librygel-server/rygel-http-item-uri.vala | 2 +-
src/librygel-server/rygel-http-server.vala | 2 +-
src/librygel-server/rygel-import-resource.vala | 8 ++++----
src/librygel-server/rygel-media-container.vala | 2 +-
src/librygel-server/rygel-media-item.vala | 12 ++++--------
src/librygel-server/rygel-media-object.vala | 16 +++++++++++++++-
src/librygel-server/rygel-object-creator.vala | 8 ++++----
.../rygel-media-export-dummy-container.vala | 2 +-
.../rygel-media-export-media-cache.vala | 6 +++---
.../rygel-media-export-playlist-container.vala | 2 +-
...rygel-media-export-playlist-root-container.vala | 2 +-
.../rygel-media-export-writable-db-container.vala | 6 +++---
.../rygel-tracker-category-all-container.vala | 2 +-
.../tracker/rygel-tracker-insertion-query.vala | 6 +++---
15 files changed, 44 insertions(+), 36 deletions(-)
---
diff --git a/examples/standalone-server.c b/examples/standalone-server.c
index dd9a6a3..67ef199 100644
--- a/examples/standalone-server.c
+++ b/examples/standalone-server.c
@@ -119,13 +119,11 @@ int main (int argc, char *argv[])
g_free (id);
if (item != NULL) {
- RygelMediaObject *object;
GeeArrayList* uris;
rygel_media_item_set_mime_type (RYGEL_MEDIA_ITEM (item), content_type);
- object = RYGEL_MEDIA_OBJECT (item);
- gee_collection_add (GEE_COLLECTION (object->uris), uri);
+ rygel_media_object_add_uri (RYGEL_MEDIA_OBJECT (item), uri);
rygel_simple_container_add_child_item (root_container, item);
}
diff --git a/src/librygel-server/rygel-http-item-uri.vala b/src/librygel-server/rygel-http-item-uri.vala
index 2b92237..cf00df4 100644
--- a/src/librygel-server/rygel-http-item-uri.vala
+++ b/src/librygel-server/rygel-http-item-uri.vala
@@ -100,7 +100,7 @@ internal class Rygel.HTTPItemURI : Object {
if (this.extension == "") {
string uri_extension = "";
- foreach (string uri_string in item.uris) {
+ foreach (string uri_string in item.get_uris ()) {
string basename = Path.get_basename (uri_string);
int dot_index = basename.last_index_of(".");
diff --git a/src/librygel-server/rygel-http-server.vala b/src/librygel-server/rygel-http-server.vala
index 0472d2a..42a5116 100644
--- a/src/librygel-server/rygel-http-server.vala
+++ b/src/librygel-server/rygel-http-server.vala
@@ -77,7 +77,7 @@ public class Rygel.HTTPServer : Rygel.TranscodeManager, Rygel.StateMachine {
private bool http_uri_present (MediaItem item) {
bool present = false;
- foreach (var uri in item.uris) {
+ foreach (var uri in item.get_uris ()) {
if (!this.need_proxy (uri)) {
present = true;
diff --git a/src/librygel-server/rygel-import-resource.vala b/src/librygel-server/rygel-import-resource.vala
index 2ecdbc2..f76aa7a 100644
--- a/src/librygel-server/rygel-import-resource.vala
+++ b/src/librygel-server/rygel-import-resource.vala
@@ -136,7 +136,7 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
queue.dequeue (this.item);
try {
- var source_file = File.new_for_uri (this.item.uris[0]);
+ var source_file = File.new_for_uri (this.item.get_primary_uri ());
this.output_stream = yield source_file.replace_async (null,
false,
FileCreateFlags.PRIVATE,
@@ -154,7 +154,7 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
debug ("Importing resource from %s to %s",
source_uri,
- this.item.uris[0]);
+ this.item.get_primary_uri ());
yield;
} catch (Error err) {
@@ -187,7 +187,7 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
} else if (!(media_object as MediaItem).place_holder) {
msg = _("Pushing data to non-empty item '%s' not allowed").printf
(media_object.id);
- } else if (media_object.uris.size < 1) {
+ } else if (media_object.get_uris ().is_empty) {
assert_not_reached ();
}
@@ -207,7 +207,7 @@ internal class Rygel.ImportResource : GLib.Object, Rygel.StateMachine {
this.status = TransferStatus.ERROR;
try {
this.output_stream.close (this.cancellable);
- var file = File.new_for_uri (this.item.uris[0]);
+ var file = File.new_for_uri (this.item.get_primary_uri ());
file.delete (this.cancellable);
} catch (Error error) {};
diff --git a/src/librygel-server/rygel-media-container.vala b/src/librygel-server/rygel-media-container.vala
index 2c290a7..86c3309 100644
--- a/src/librygel-server/rygel-media-container.vala
+++ b/src/librygel-server/rygel-media-container.vala
@@ -127,7 +127,7 @@ public abstract class Rygel.MediaContainer : MediaObject {
public override OCMFlags ocm_flags {
get {
- if (!(this is WritableContainer) || this.uris.size == 0) {
+ if (!(this is WritableContainer) || this.get_uris ().is_empty) {
return OCMFlags.NONE;
}
diff --git a/src/librygel-server/rygel-media-item.vala b/src/librygel-server/rygel-media-item.vala
index 8ce7bf9..ad0f158 100644
--- a/src/librygel-server/rygel-media-item.vala
+++ b/src/librygel-server/rygel-media-item.vala
@@ -110,15 +110,15 @@ public abstract class Rygel.MediaItem : MediaObject {
// Live media items need to provide a nice working implementation of this
// method if they can/do not provide a valid URI
public virtual DataSource? create_stream_source (string? host_ip = null) {
- if (this.uris.size == 0) {
+ if (this.get_uris ().is_empty) {
return null;
}
- string translated_uri = this.uris.get (0);
+ string translated_uri = this.get_primary_uri ();
if (host_ip != null) {
try {
translated_uri = MediaItem.address_regex.replace_literal
- (this.uris.get (0), -1, 0, host_ip);
+ (this.get_primary_uri (), -1, 0, host_ip);
} catch (Error error) {
assert_not_reached ();
}
@@ -133,10 +133,6 @@ public abstract class Rygel.MediaItem : MediaObject {
public abstract bool streamable ();
- public virtual void add_uri (string uri) {
- this.uris.add (uri);
- }
-
internal int compare_transcoders (Transcoder transcoder1,
Transcoder transcoder2) {
return (int) transcoder1.get_distance (this) -
@@ -329,7 +325,7 @@ public abstract class Rygel.MediaItem : MediaObject {
protected virtual void add_resources (DIDLLiteItem didl_item,
bool allow_internal)
throws Error {
- foreach (var uri in this.uris) {
+ foreach (var uri in this.get_uris ()) {
var protocol = this.get_protocol_for_uri (uri);
if (allow_internal || protocol != "internal") {
diff --git a/src/librygel-server/rygel-media-object.vala b/src/librygel-server/rygel-media-object.vala
index 29659e1..7446ed1 100644
--- a/src/librygel-server/rygel-media-object.vala
+++ b/src/librygel-server/rygel-media-object.vala
@@ -53,7 +53,21 @@ public abstract class Rygel.MediaObject : GLib.Object {
//TODO: { get; private set; } or, even better,
// add virtual set_uri in Object and make add_uri() in Item into set_uri()
// and make the uri property single-value.
- public Gee.ArrayList<string> uris;
+ private Gee.ArrayList<string> uris;
+
+ public Gee.List<string> get_uris () { return this.uris; }
+
+ public string? get_primary_uri () {
+ if (this.uris.is_empty) {
+ return null;
+ }
+
+ return this.uris[0];
+ }
+
+ public virtual void add_uri (string uri) {
+ this.uris.add (uri);
+ }
// You can keep both an unowned and owned ref to parent of this MediaObject.
// In most cases, one will only need to keep an unowned ref to avoid cyclic
diff --git a/src/librygel-server/rygel-object-creator.vala b/src/librygel-server/rygel-object-creator.vala
index 5010d8f..cd28655 100644
--- a/src/librygel-server/rygel-object-creator.vala
+++ b/src/librygel-server/rygel-object-creator.vala
@@ -513,20 +513,20 @@ internal class Rygel.ObjectCreator: GLib.Object, Rygel.StateMachine {
}
// extract_item_parameters could not find an uri
- if (this.object.uris.size == 0) {
+ if (this.object.get_uris ().is_empty) {
var uri = yield this.create_uri (container, this.object.title);
- this.object.uris.add (uri);
+ this.object.add_uri (uri);
if (this.object is MediaItem) {
(this.object as MediaItem).place_holder = true;
}
} else {
if (this.object is MediaItem) {
- var file = File.new_for_uri (this.object.uris[0]);
+ var file = File.new_for_uri (this.object.get_primary_uri ());
(this.object as MediaItem).place_holder = !file.is_native ();
}
}
- this.object.id = this.object.uris[0];
+ this.object.id = this.object.get_primary_uri ();
this.parse_and_verify_didl_date ();
}
diff --git a/src/plugins/media-export/rygel-media-export-dummy-container.vala
b/src/plugins/media-export/rygel-media-export-dummy-container.vala
index ff8ca98..7d1ab06 100644
--- a/src/plugins/media-export/rygel-media-export-dummy-container.vala
+++ b/src/plugins/media-export/rygel-media-export-dummy-container.vala
@@ -40,7 +40,7 @@ internal class Rygel.MediaExport.DummyContainer : TrackableDbContainer {
this.parent_ref = parent;
this.file = file;
- this.uris.add (file.get_uri ());
+ this.add_uri (file.get_uri ());
try {
this.children = cache.get_child_ids (this.id);
this.child_count = this.children.size;
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala
b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 4ca3a86..3221e61 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -769,7 +769,7 @@ public class Rygel.MediaExport.MediaCache : Object {
GLib.Value[] values = { type,
parent,
object.modified,
- object.uris.is_empty ? null : object.uris[0],
+ object.get_primary_uri (),
object.object_update_id,
-1,
-1,
@@ -804,7 +804,7 @@ public class Rygel.MediaExport.MediaCache : Object {
type,
parent,
object.modified,
- object.uris.is_empty ? null : object.uris[0],
+ object.get_primary_uri (),
object.object_update_id,
-1,
-1,
@@ -887,7 +887,7 @@ public class Rygel.MediaExport.MediaCache : Object {
var container = object as MediaContainer;
if (uri != null) {
- container.uris.add (uri);
+ container.add_uri (uri);
}
container.total_deleted_child_count = (uint32) statement.column_int64
(DetailColumn.DELETED_CHILD_COUNT);
diff --git a/src/plugins/media-export/rygel-media-export-playlist-container.vala
b/src/plugins/media-export/rygel-media-export-playlist-container.vala
index 09e9316..cb20146 100644
--- a/src/plugins/media-export/rygel-media-export-playlist-container.vala
+++ b/src/plugins/media-export/rygel-media-export-playlist-container.vala
@@ -48,7 +48,7 @@ internal class Rygel.MediaExport.PlaylistContainer : DBContainer,
// Need to add an URI otherwise core doesn't mark the container as
// writable
- this.uris.add (PlaylistContainer.URI);
+ this.add_uri (PlaylistContainer.URI);
}
public override OCMFlags ocm_flags {
diff --git a/src/plugins/media-export/rygel-media-export-playlist-root-container.vala
b/src/plugins/media-export/rygel-media-export-playlist-root-container.vala
index 03ee6f1..224626d 100644
--- a/src/plugins/media-export/rygel-media-export-playlist-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-playlist-root-container.vala
@@ -54,7 +54,7 @@ internal class Rygel.MediaExport.PlaylistRootContainer : Rygel.WritableContainer
// Need to add an URI otherwise core doesn't mark the container as
// writable
- this.uris.add (PlaylistRootContainer.URI);
+ this.add_uri (PlaylistRootContainer.URI);
}
public override OCMFlags ocm_flags {
diff --git a/src/plugins/media-export/rygel-media-export-writable-db-container.vala
b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
index 13b5f83..d027fc8 100644
--- a/src/plugins/media-export/rygel-media-export-writable-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
@@ -60,7 +60,7 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
Cancellable? cancellable)
throws Error {
item.parent = this;
- var file = File.new_for_uri (item.uris[0]);
+ var file = File.new_for_uri (item.get_primary_uri ());
// TODO: Mark as place-holder. Make this proper some time.
if (file.is_native ()) {
item.modified = int64.MAX;
@@ -83,7 +83,7 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
switch (container.upnp_class) {
case MediaContainer.STORAGE_FOLDER:
case MediaContainer.UPNP_CLASS:
- var file = File.new_for_uri (container.uris[0]);
+ var file = File.new_for_uri (container.get_primary_uri ());
container.id = MediaCache.get_id (file);
if (file.is_native ()) {
file.make_directory_with_parents (cancellable);
@@ -101,7 +101,7 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
protected override async void remove_child (MediaObject object) {
yield base.remove_child (object);
- var file = File.new_for_uri (object.uris[0]);
+ var file = File.new_for_uri (object.get_primary_uri ());
try {
yield file.delete_async ();
} catch (Error error) {
diff --git a/src/plugins/tracker/rygel-tracker-category-all-container.vala
b/src/plugins/tracker/rygel-tracker-category-all-container.vala
index 3b1392e..d5bd213 100644
--- a/src/plugins/tracker/rygel-tracker-category-all-container.vala
+++ b/src/plugins/tracker/rygel-tracker-category-all-container.vala
@@ -57,7 +57,7 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
try {
var uri = Filename.to_uri (item_factory.upload_dir, null);
- this.uris.add (uri);
+ this.add_uri (uri);
} catch (ConvertError error) {
warning (_("Failed to construct URI for folder '%s': %s"),
item_factory.upload_dir,
diff --git a/src/plugins/tracker/rygel-tracker-insertion-query.vala
b/src/plugins/tracker/rygel-tracker-insertion-query.vala
index 9b7a10e..564e24c 100644
--- a/src/plugins/tracker/rygel-tracker-insertion-query.vala
+++ b/src/plugins/tracker/rygel-tracker-insertion-query.vala
@@ -55,7 +55,7 @@ public class Rygel.Tracker.InsertionQuery : Query {
public InsertionQuery (MediaItem item, string category) {
var type = "nie:DataObject";
- var file = File.new_for_uri (item.uris[0]);
+ var file = File.new_for_uri (item.get_primary_uri ());
if (!file.is_native ()) {
type = "nfo:RemoteDataObject";
@@ -92,7 +92,7 @@ public class Rygel.Tracker.InsertionQuery : Query {
triplets.add (new QueryTriplet (QUERY_ID,
"nie:url",
- "\"" + item.uris[0] + "\""));
+ "\"" + item.get_primary_uri () + "\""));
string date;
if (item.date == null) {
var now = TimeVal ();
@@ -115,7 +115,7 @@ public class Rygel.Tracker.InsertionQuery : Query {
base (triplets);
- this.uri = item.uris[0];
+ this.uri = item.get_primary_uri ();
}
public override async void execute (Sparql.Connection resources)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]