[CB-836] Readonly property, duplicate activeTransfer, send pluginResult on abort
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/d1ff5a71 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/d1ff5a71 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/d1ff5a71 Branch: refs/heads/master Commit: d1ff5a711e3175c0769e5f2036798a032b00fdd7 Parents: 7c4fa19 Author: Cory Thompson <coryjthomp...@gmail.com> Authored: Mon Aug 27 19:09:12 2012 +1000 Committer: Andrew Grieve <agri...@chromium.org> Committed: Thu Sep 20 22:34:46 2012 -0400 ---------------------------------------------------------------------- CordovaLib/Classes/CDVFileTransfer.h | 5 +++-- CordovaLib/Classes/CDVFileTransfer.m | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/d1ff5a71/CordovaLib/Classes/CDVFileTransfer.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h index 63be7d6..7ca96a3 100755 --- a/CordovaLib/Classes/CDVFileTransfer.h +++ b/CordovaLib/Classes/CDVFileTransfer.h @@ -24,7 +24,8 @@ enum CDVFileTransferError { FILE_NOT_FOUND_ERR = 1, INVALID_URL_ERR = 2, - CONNECTION_ERR = 3 + CONNECTION_ERR = 3, + CONNECTION_ABORTED = 4 }; typedef int CDVFileTransferError; @@ -53,7 +54,7 @@ extern NSString* const kOptionsKeyCookie; AndSource:(NSString*)source AndTarget:(NSString*)target AndHttpStatus:(int)httpStatus; -@property (nonatomic, copy) NSMutableDictionary* activeTransfers; +@property (readonly) NSMutableDictionary* activeTransfers; @end http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/d1ff5a71/CordovaLib/Classes/CDVFileTransfer.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m index 65fc01e..3660486 100755 --- a/CordovaLib/Classes/CDVFileTransfer.m +++ b/CordovaLib/Classes/CDVFileTransfer.m @@ -289,6 +289,11 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) { CDVFileTransferDelegate *delegate = [activeTransfers objectForKey:objectId]; [delegate.connection cancel]; [activeTransfers removeObjectForKey:objectId]; + + CDVPlugin Result *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [self createFileTransferError:CONNECTION_ABORTED AndSource:delegate.source AndTarget:delegate.target]]; + + [self writeJavascript:[result toErrorCallbackString:command.callbackId]]; + } - (void) download:(CDVInvokedUrlCommand*)command { @@ -336,7 +341,6 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) { delegate.target = filePath; delegate.connection = [NSURLConnection connectionWithRequest:req delegate:delegate]; - [activeTransfers setObject: delegate forKey:delegate.objectId]; if (activeTransfers == nil) { activeTransfers = [[NSMutableDictionary alloc] init];