[rygel] media-export: Move public methods to top of class
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Move public methods to top of class
- Date: Sat, 14 Aug 2010 23:32:10 +0000 (UTC)
commit d09256428096668689068edd49314f204e6cc9bf
Author: Jens Georg <mail jensge org>
Date: Mon Aug 2 22:36:55 2010 +0300
media-export: Move public methods to top of class
.../rygel-media-export-root-container.vala | 196 ++++++++++----------
1 files changed, 101 insertions(+), 95 deletions(-)
---
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 dd355bf..7caceb2 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -32,24 +32,6 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
private static MediaContainer instance = null;
- private ArrayList<string> get_uris () {
- ArrayList<string> uris;
-
- var config = MetaConfig.get_default ();
-
- try {
- uris = config.get_string_list ("MediaExport", "uris");
- } catch (Error error) {
- uris = new ArrayList<string> ();
- }
-
- try {
- uris.add_all (this.media_db.get_flagged_uris ("DBUS"));
- } catch (Error error) {}
-
- return uris;
- }
-
public static MediaContainer get_instance () {
if (RootContainer.instance == null) {
try {
@@ -63,6 +45,8 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
return RootContainer.instance;
}
+ // DBus utility methods
+
public void add_uri (string uri) {
var file = File.new_for_commandline_arg (uri);
this.harvester.schedule (file, this, "DBUS");
@@ -80,6 +64,105 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
}
}
+ public string[] get_dynamic_uris () {
+ try {
+ var uris = this.media_db.get_flagged_uris ("DBUS");
+
+ return uris.to_array ();
+ } catch (Error error) { }
+
+ return new string[0];
+ }
+
+ // MediaContainer overrides
+
+ public override async MediaObject? find_object (string id,
+ Cancellable? cancellable)
+ throws Error {
+ var object = yield base.find_object (id, cancellable);
+
+ if (object == null && id.has_prefix (QueryContainer.PREFIX)) {
+ var container = new QueryContainer (this.media_db, id);
+ container.parent = this;
+
+ return container;
+ }
+
+ return object;
+ }
+
+ public override async MediaObjects? search (SearchExpression? expression,
+ uint offset,
+ uint max_count,
+ out uint total_matches,
+ Cancellable? cancellable)
+ throws GLib.Error {
+ if (expression == null) {
+ return yield base.search (expression,
+ offset,
+ max_count,
+ out total_matches,
+ cancellable);
+ }
+
+ MediaObjects list;
+ MediaContainer query_container = null;
+ string upnp_class = null;
+
+ if (expression is RelationalExpression) {
+ var relational_expression = expression as RelationalExpression;
+
+ query_container = search_to_virtual_container (
+ relational_expression);
+ upnp_class = relational_expression.operand2;
+ } else if (is_search_in_virtual_container (expression,
+ out query_container)) {
+ // do nothing. query_container is filled then
+ }
+
+ if (query_container != null) {
+ list = yield query_container.get_children (offset,
+ max_count,
+ cancellable);
+ // FIXME: This is wrong
+ total_matches = list.size;
+
+ if (upnp_class != null) {
+ foreach (var object in list) {
+ object.upnp_class = upnp_class;
+ }
+ }
+
+ return list;
+ } else {
+ return yield base.search (expression,
+ offset,
+ max_count,
+ out total_matches,
+ cancellable);
+ }
+ }
+
+
+
+ private ArrayList<string> get_uris () {
+ ArrayList<string> uris;
+
+ var config = MetaConfig.get_default ();
+
+ try {
+ uris = config.get_string_list ("MediaExport", "uris");
+ } catch (Error error) {
+ uris = new ArrayList<string> ();
+ }
+
+ try {
+ uris.add_all (this.media_db.get_flagged_uris ("DBUS"));
+ } catch (Error error) {}
+
+ return uris;
+ }
+
private QueryContainer? search_to_virtual_container (
RelationalExpression expression) {
if (expression.operand1 == "upnp:class" &&
@@ -173,83 +256,6 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
return true;
}
- public override async MediaObject? find_object (string id,
- Cancellable? cancellable)
- throws Error {
- var object = yield base.find_object (id, cancellable);
-
- if (object == null && id.has_prefix (QueryContainer.PREFIX)) {
- var container = new QueryContainer (this.media_db, id);
- container.parent = this;
-
- return container;
- }
-
- return object;
- }
-
- public override async MediaObjects? search (SearchExpression? expression,
- uint offset,
- uint max_count,
- out uint total_matches,
- Cancellable? cancellable)
- throws GLib.Error {
- if (expression == null) {
- return yield base.search (expression,
- offset,
- max_count,
- out total_matches,
- cancellable);
- }
-
- MediaObjects list;
- MediaContainer query_container = null;
- string upnp_class = null;
-
- if (expression is RelationalExpression) {
- var relational_expression = expression as RelationalExpression;
-
- query_container = search_to_virtual_container (
- relational_expression);
- upnp_class = relational_expression.operand2;
- } else if (is_search_in_virtual_container (expression,
- out query_container)) {
- // do nothing. query_container is filled then
- }
-
- if (query_container != null) {
- list = yield query_container.get_children (offset,
- max_count,
- cancellable);
- total_matches = list.size;
-
- if (upnp_class != null) {
- foreach (var object in list) {
- object.upnp_class = upnp_class;
- }
- }
-
- return list;
- } else {
- return yield base.search (expression,
- offset,
- max_count,
- out total_matches,
- cancellable);
- }
- }
-
-
- public string[] get_dynamic_uris () {
- try {
- var uris = this.media_db.get_flagged_uris ("DBUS");
-
- return uris.to_array ();
- } catch (Error error) { }
-
- return new string[0];
- }
-
/**
* Create a new root container.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]