string connection_id;
action.get ("ConnectionID", typeof (string), out connection_id);
- if (connection_id == null || connection_id != "0") {
- action.return_error (706, _("Invalid connection reference"));
+ if (connection_id == null || action.get_argument_count () != 1 ||
+ (connection_id != "0" && int.parse (connection_id) == 0)) {
+ action.return_error (402, _("Invalid argument"));
return;
}
- if (action.get_argument_count () != 1) {
- action.return_error (402, _("Invalid argument"));
+ if (connection_id != "0") {
+ action.return_error (706, _("Invalid connection reference"));
return;
}
RESTRICTED_OBJECT = 711,
BAD_METADATA = 712,
RESTRICTED_PARENT = 713,
+ NO_SUCH_FILE_TRANSFER = 717,
NO_SUCH_DESTINATION_RESOURCE = 718,
CANT_PROCESS = 720,
OUTDATED_OBJECT_METADATA = 728,
return;
}
- var import = find_import_for_action (action);
- if (import != null) {
+ try {
+ var import = this.find_import_for_action (action);
+
action.set ("TransferStatus",
typeof (string),
import.status_as_string,
import.bytes_total);
action.return ();
- } else {
- action.return_error (717, _("No such file transfer"));
+ } catch (Error error) {
+ action.return_error (error.code, error.message);
}
}
return;
}
- var import = find_import_for_action (action);
- if (import != null) {
+ try {
+ var import = find_import_for_action (action);
import.cancellable.cancel ();
action.return ();
- } else {
- action.return_error (717, _("No such file transfer"));
+ } catch (Error error) {
+ action.return_error (error.code, error.message);
}
}
});
}
- private ImportResource? find_import_for_action (ServiceAction action) {
+ private ImportResource? find_import_for_action (ServiceAction action)
+ throws ContentDirectoryError {
ImportResource ret = null;
uint32 transfer_id;
+ string transfer_id_string;
+ // TODO: Remove string hack once bgo#705516 is fixed
action.get ("TransferID",
typeof (uint32),
- out transfer_id);
+ out transfer_id,
+ "TransferID",
+ typeof (string),
+ out transfer_id_string);
+ if (transfer_id == 0 &&
+ (transfer_id_string == null || transfer_id_string != "0")) {
+ throw new ContentDirectoryError.INVALID_ARGS
+ (_("Invalid argument"));
+ }
foreach (var import in this.active_imports) {
if (import.transfer_id == transfer_id) {
}
}
+ if (ret == null) {
+ throw new ContentDirectoryError.NO_SUCH_FILE_TRANSFER
+ (_("No such file transfer"));
+ }
+
return ret;
}
this.destination_uri,
error.message);
- int code;
- if (error is ContentDirectoryError) {
- code = error.code;
- } else {
- code = 719;
- }
-
- this.action.return_error (code, error.message);
+ this.action.return_error (error.code, error.message);
this.status = TransferStatus.ERROR;
this.completed ();
}
private async MediaItem fetch_item () throws Error {
- var uri = new HTTPItemURI.from_string (this.destination_uri,
+ HTTPItemURI uri;
+ try {
+ uri = new HTTPItemURI.from_string (this.destination_uri,
this.http_server);
+ } catch (Error error) {
+ throw new ContentDirectoryError.NO_SUCH_DESTINATION_RESOURCE
+ (error.message);
+ }
var media_object = yield this.root_container.find_object (uri.item_id,
null);
string msg = null;