[rygel] media-export: Simplify the code slightly.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Simplify the code slightly.
- Date: Thu, 17 Jan 2013 12:29:34 +0000 (UTC)
commit cd15e7dcca9bb43f749b0afcaf1f059be6efafc7
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jan 17 13:28:47 2013 +0100
media-export: Simplify the code slightly.
There is no sense in taking the MediaCache as a parameter because
it is a singleton and other parts of the code assume that.
.../rygel-media-export-db-container.vala | 7 +++++--
.../rygel-media-export-dummy-container.vala | 2 +-
.../rygel-media-export-leaf-query-container.vala | 5 ++---
.../rygel-media-export-media-cache.vala | 2 +-
.../rygel-media-export-node-query-container.vala | 5 ++---
.../rygel-media-export-object-factory.vala | 4 ++--
...rygel-media-export-query-container-factory.vala | 6 ++----
.../rygel-media-export-query-container.vala | 5 ++---
.../rygel-media-export-root-container.vala | 11 +++++++----
.../rygel-media-export-trackable-db-container.vala | 4 ++--
.../rygel-media-export-writable-db-container.vala | 4 ++--
11 files changed, 28 insertions(+), 27 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-db-container.vala b/src/plugins/media-export/rygel-media-export-db-container.vala
index 48d580e..79415d2 100644
--- a/src/plugins/media-export/rygel-media-export-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-db-container.vala
@@ -27,10 +27,13 @@ public class Rygel.MediaExport.DBContainer : MediaContainer,
protected MediaCache media_db;
public ArrayList<string> search_classes { get; set; }
- public DBContainer (MediaCache media_db, string id, string title) {
+ public DBContainer (string id, string title) {
base (id, null, title, 0);
- this.media_db = media_db;
+ try {
+ this.media_db = MediaCache.get_default ();
+ } catch (Error error) { }
+
this.search_classes = new ArrayList<string> ();
this.container_updated.connect ( () => { this.count_children (); });
this.count_children ();
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 7942eb8..6329e44 100644
--- a/src/plugins/media-export/rygel-media-export-dummy-container.vala
+++ b/src/plugins/media-export/rygel-media-export-dummy-container.vala
@@ -30,7 +30,7 @@ internal class Rygel.MediaExport.DummyContainer : TrackableDbContainer {
cache = MediaCache.get_default ();
} catch (Error error) { }
- base (cache, MediaCache.get_id (file), file.get_basename ());
+ base (MediaCache.get_id (file), file.get_basename ());
uint32 object_update_id, container_update_id, total_deleted_child_count;
this.media_db.get_track_properties (this.id,
diff --git a/src/plugins/media-export/rygel-media-export-leaf-query-container.vala b/src/plugins/media-export/rygel-media-export-leaf-query-container.vala
index bd82a88..31c03d4 100644
--- a/src/plugins/media-export/rygel-media-export-leaf-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-leaf-query-container.vala
@@ -19,11 +19,10 @@
*/
internal class Rygel.MediaExport.LeafQueryContainer : QueryContainer {
- public LeafQueryContainer (MediaCache cache,
- SearchExpression expression,
+ public LeafQueryContainer (SearchExpression expression,
string id,
string name) {
- base (cache, expression, id, name);
+ base (expression, id, name);
}
public override async MediaObjects? get_children
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 7e8c7f4..aeb7615 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -45,7 +45,7 @@ internal struct Rygel.MediaExport.ExistsCacheEntry {
/**
* Persistent storage of media objects
*
- * MediaExportDB is a sqlite3 backed persistent storage of media objects
+ * MediaExportDB is a sqlite3 backed persistent storage of media objects.
*/
public class Rygel.MediaExport.MediaCache : Object {
// Private members
diff --git a/src/plugins/media-export/rygel-media-export-node-query-container.vala b/src/plugins/media-export/rygel-media-export-node-query-container.vala
index f619288..8d65cd8 100644
--- a/src/plugins/media-export/rygel-media-export-node-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-node-query-container.vala
@@ -22,13 +22,12 @@ internal class Rygel.MediaExport.NodeQueryContainer : QueryContainer {
private string template;
private string attribute;
- public NodeQueryContainer (MediaCache cache,
- SearchExpression expression,
+ public NodeQueryContainer (SearchExpression expression,
string id,
string name,
string template,
string attribute) {
- base (cache, expression, id, name);
+ base (expression, id, name);
this.template = template;
this.attribute = attribute;
diff --git a/src/plugins/media-export/rygel-media-export-object-factory.vala b/src/plugins/media-export/rygel-media-export-object-factory.vala
index a56c154..d56c11c 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -56,10 +56,10 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
}
if (uri == null) {
- return new TrackableDbContainer (media_db, id, title);
+ return new TrackableDbContainer (id, title);
}
- return new WritableDbContainer (media_db, id, title);
+ return new WritableDbContainer (id, title);
}
/**
diff --git a/src/plugins/media-export/rygel-media-export-query-container-factory.vala b/src/plugins/media-export/rygel-media-export-query-container-factory.vala
index c2120a6..5a3c21f 100644
--- a/src/plugins/media-export/rygel-media-export-query-container-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container-factory.vala
@@ -129,13 +129,11 @@ internal class Rygel.MediaExport.QueryContainerFactory : Object {
ref title);
if (pattern == null || pattern == "") {
- container = new LeafQueryContainer (cache,
- expression,
+ container = new LeafQueryContainer (expression,
id,
title);
} else {
- container = new NodeQueryContainer (cache,
- expression,
+ container = new NodeQueryContainer (expression,
id,
title,
pattern,
diff --git a/src/plugins/media-export/rygel-media-export-query-container.vala b/src/plugins/media-export/rygel-media-export-query-container.vala
index 99f77cd..49f1e48 100644
--- a/src/plugins/media-export/rygel-media-export-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container.vala
@@ -29,11 +29,10 @@ internal abstract class Rygel.MediaExport.QueryContainer : DBContainer {
protected SearchExpression expression;
// constructors
- public QueryContainer (MediaCache cache,
- SearchExpression expression,
+ public QueryContainer (SearchExpression expression,
string id,
string name) {
- base (cache, id, name);
+ base (id, name);
this.expression = expression;
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 89b73f4..4665e69 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -313,9 +313,13 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
* Create a new root container.
*/
private RootContainer () throws Error {
- var db = MediaCache.get_default ();
- base (db, "0", _("@REALNAME@'s media"));
+ /**
+ * The MediaCache contains metadata details of all files
+ * found by the Harvester, which uses the same
+ * MediaCache from get_default().
+ */
+ base ("0", _("@REALNAME@'s media"));
}
private bool initialized = false;
@@ -346,8 +350,7 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
try {
this.filesystem_container = new TrackableDbContainer
- (media_db,
- FILESYSTEM_FOLDER_ID,
+ (FILESYSTEM_FOLDER_ID,
_(FILESYSTEM_FOLDER_NAME));
this.filesystem_container.parent = this;
this.media_db.save_container (this.filesystem_container);
diff --git a/src/plugins/media-export/rygel-media-export-trackable-db-container.vala b/src/plugins/media-export/rygel-media-export-trackable-db-container.vala
index f110ae2..b5d705c 100644
--- a/src/plugins/media-export/rygel-media-export-trackable-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-trackable-db-container.vala
@@ -23,8 +23,8 @@ using Gee;
public class Rygel.MediaExport.TrackableDbContainer : TrackableContainer,
DBContainer {
- public TrackableDbContainer (MediaCache cache, string id, string title) {
- base (cache, id, title);
+ public TrackableDbContainer (string id, string title) {
+ base (id, title);
}
public async void add_child (MediaObject object) {
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 2d16967..de7a310 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
@@ -25,8 +25,8 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
Rygel.WritableContainer {
public ArrayList<string> create_classes { get; set; }
- public WritableDbContainer (MediaCache media_db, string id, string title) {
- base (media_db, id, title);
+ public WritableDbContainer (string id, string title) {
+ base (id, title);
this.create_classes = new ArrayList<string> ();
this.create_classes.add (Rygel.ImageItem.UPNP_CLASS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]