rygel r137 - in trunk: . src/media-providers/tracker src/media-server
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r137 - in trunk: . src/media-providers/tracker src/media-server
- Date: Tue, 28 Oct 2008 21:01:15 +0000 (UTC)
Author: zeeshanak
Date: Tue Oct 28 21:01:15 2008
New Revision: 137
URL: http://svn.gnome.org/viewvc/rygel?rev=137&view=rev
Log:
Use Exceptions rather than returning null.
Modified:
trunk/ChangeLog
trunk/src/media-providers/tracker/gupnp-media-tracker.vala
trunk/src/media-server/gupnp-content-directory.vala
trunk/src/media-server/gupnp-media-manager.vala
trunk/src/media-server/gupnp-media-provider.vala
Modified: trunk/src/media-providers/tracker/gupnp-media-tracker.vala
==============================================================================
--- trunk/src/media-providers/tracker/gupnp-media-tracker.vala (original)
+++ trunk/src/media-providers/tracker/gupnp-media-tracker.vala Tue Oct 28 21:01:15 2008
@@ -118,15 +118,15 @@
this.context = context;
}
- public override string? browse (string container_id,
- string filter,
- uint starting_index,
- uint requested_count,
- string sort_criteria,
- out uint number_returned,
- out uint total_matches,
- out uint update_id) {
- string didl;
+ public override string browse (string container_id,
+ string filter,
+ uint starting_index,
+ uint requested_count,
+ string sort_criteria,
+ out uint number_returned,
+ out uint total_matches,
+ out uint update_id) throws GLib.Error {
+ string didl = null;
/* Start DIDL-Lite fragment */
this.didl_writer.start_didl_lite (null, null, true);
@@ -162,20 +162,23 @@
didl = this.didl_writer.get_string ();
update_id = uint32.MAX;
- } else
- didl = null;
+ }
/* Reset the parser state */
this.didl_writer.reset ();
+ if (didl == null) {
+ throw new MediaProviderError.NO_SUCH_OBJECT ("No such object");
+ }
+
return didl;
}
public override string get_metadata (string object_id,
string filter,
string sort_criteria,
- out uint update_id) {
- string didl;
+ out uint update_id) throws GLib.Error {
+ string didl = null;
bool found;
/* Start DIDL-Lite fragment */
@@ -213,12 +216,15 @@
/* Retrieve generated string */
didl = this.didl_writer.get_string ();
- } else
- didl = null;
+ }
/* Reset the parser state */
this.didl_writer.reset ();
+ if (didl == null) {
+ throw new MediaProviderError.NO_SUCH_OBJECT ("No such object");
+ }
+
update_id = uint32.MAX;
return didl;
Modified: trunk/src/media-server/gupnp-content-directory.vala
==============================================================================
--- trunk/src/media-server/gupnp-content-directory.vala (original)
+++ trunk/src/media-server/gupnp-content-directory.vala Tue Oct 28 21:01:15 2008
@@ -105,26 +105,26 @@
}
}
- if (browse_metadata) {
- didl = this.media_manager.get_metadata (object_id,
- filter,
- sort_criteria,
- out update_id);
-
- num_returned = 1;
- total_matches = 1;
- } else {
- didl = this.media_manager.browse (object_id,
- filter,
- starting_index,
- requested_count,
- sort_criteria,
- out num_returned,
- out total_matches,
- out update_id);
- }
-
- if (didl == null) {
+ try {
+ if (browse_metadata) {
+ didl = this.media_manager.get_metadata (object_id,
+ filter,
+ sort_criteria,
+ out update_id);
+
+ num_returned = 1;
+ total_matches = 1;
+ } else {
+ didl = this.media_manager.browse (object_id,
+ filter,
+ starting_index,
+ requested_count,
+ sort_criteria,
+ out num_returned,
+ out total_matches,
+ out update_id);
+ }
+ } catch (Error error) {
action.return_error (701, "No such object");
return;
Modified: trunk/src/media-server/gupnp-media-manager.vala
==============================================================================
--- trunk/src/media-server/gupnp-media-manager.vala (original)
+++ trunk/src/media-server/gupnp-media-manager.vala Tue Oct 28 21:01:15 2008
@@ -64,14 +64,14 @@
this.context = context;
}
- public override string? browse (string container_id,
- string filter,
- uint starting_index,
- uint requested_count,
- string sort_criteria,
- out uint number_returned,
- out uint total_matches,
- out uint update_id) {
+ public override string browse (string container_id,
+ string filter,
+ uint starting_index,
+ uint requested_count,
+ string sort_criteria,
+ out uint number_returned,
+ out uint total_matches,
+ out uint update_id) throws Error {
string didl;
string root_id = this.get_root_id_from_id (container_id);
@@ -96,7 +96,7 @@
update_id = this.system_update_id;
}
} else {
- didl = null;
+ throw new MediaProviderError.NO_SUCH_OBJECT ("No such object");
}
}
@@ -106,7 +106,7 @@
public override string get_metadata (string object_id,
string filter,
string sort_criteria,
- out uint update_id) {
+ out uint update_id) throws Error {
string didl;
string root_id = this.get_root_id_from_id (object_id);
@@ -124,7 +124,7 @@
update_id = this.system_update_id;
}
} else {
- didl = null;
+ throw new MediaProviderError.NO_SUCH_OBJECT ("No such object");
}
}
Modified: trunk/src/media-server/gupnp-media-provider.vala
==============================================================================
--- trunk/src/media-server/gupnp-media-provider.vala (original)
+++ trunk/src/media-server/gupnp-media-provider.vala Tue Oct 28 21:01:15 2008
@@ -22,6 +22,10 @@
* version 2 of the License, or (at your option) any later version.
*/
+public errordomain GUPnP.MediaProviderError {
+ NO_SUCH_OBJECT
+}
+
public abstract class GUPnP.MediaProvider : GLib.Object {
/* Properties */
public string# root_id { get; construct; }
@@ -29,19 +33,19 @@
public string# title { get; private construct; }
public GUPnP.Context context { get; construct; }
- public abstract string? browse (string container_id,
+ public abstract string browse (string container_id,
string filter,
uint starting_index,
uint requested_count,
string sort_criteria,
out uint number_returned,
out uint total_matches,
- out uint update_id);
+ out uint update_id) throws Error;
public abstract string get_metadata (string object_id,
string filter,
string sort_criteria,
- out uint update_id);
+ out uint update_id) throws Error;
public abstract uint get_root_children_count ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]