2008-08-17 Zeeshan Ali Khattak <zeenix@gmail.com>
+ * src/media-providers/tracker/gupnp-media-tracker.vala:
+ * src/media-server/gupnp-content-directory.vala:
+ * src/media-server/gupnp-media-manager.vala:
+ * src/media-server/gupnp-media-provider.vala:
+
+ Use Exceptions rather than returning null.
+
+2008-08-17 Zeeshan Ali Khattak <zeenix@gmail.com>
+
* src/media-server/gupnp-media-server.vala:
Use real name of the user rather than username in FriendlyName.
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);
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 */
/* 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;
}
}
- 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;
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);
update_id = this.system_update_id;
}
} else {
- didl = null;
+ throw new MediaProviderError.NO_SUCH_OBJECT ("No such object");
}
}
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);
update_id = this.system_update_id;
}
} else {
- didl = null;
+ throw new MediaProviderError.NO_SUCH_OBJECT ("No such object");
}
}
* 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; }
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 ();
}