You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2012/04/07 00:41:33 UTC
ios commit: Clean-up of CDFileTransfer class.
Updated Branches:
refs/heads/master 2bf695b0b -> eb4f713ad
Clean-up of CDFileTransfer class.
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/eb4f713a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/eb4f713a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/eb4f713a
Branch: refs/heads/master
Commit: eb4f713adfd2b9a902b4cd88449f641b55c4cef1
Parents: 2bf695b
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Apr 6 15:41:25 2012 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri Apr 6 15:41:25 2012 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVFileTransfer.h | 15 ++++-----------
CordovaLib/Classes/CDVFileTransfer.m | 25 ++++++++++++++-----------
2 files changed, 18 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/eb4f713a/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
index 38fe3b2..1535ed9 100644
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ b/CordovaLib/Classes/CDVFileTransfer.h
@@ -46,23 +46,16 @@ typedef int CDVFileTransferDirection;
@interface CDVFileTransferDelegate : NSObject {
- CDVFileTransfer* command;
- CDVFileTransferDirection direction;
- NSString* callbackId;
- NSString* source;
- NSString* target;
- NSInteger bytesWritten;
- int responseCode;
}
@property (nonatomic, retain) NSMutableData* responseData;
@property (nonatomic, retain) CDVFileTransfer* command;
@property (nonatomic, assign) CDVFileTransferDirection direction;
-@property (nonatomic, retain) NSString* callbackId;
-@property (nonatomic, retain) NSString* source;
-@property (nonatomic, retain) NSString* target;
+@property (nonatomic, copy) NSString* callbackId;
+@property (nonatomic, copy) NSString* source;
+@property (nonatomic, copy) NSString* target;
@property (nonatomic, assign) int responseCode;
-@property NSInteger bytesWritten;
+@property (nonatomic, assign) NSInteger bytesWritten;
@end;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/eb4f713a/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index 01a77cf..a166038 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -235,7 +235,7 @@
BOOL bDirRequest = NO;
CDVFile * file;
- if(direction == CDV_TRANSFER_UPLOAD)
+ if(self.direction == CDV_TRANSFER_UPLOAD)
{
// create dictionary to return FileUploadResult object
uploadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
@@ -247,13 +247,13 @@
[uploadResult setObject:[NSNull null] forKey: @"responseCode"];
result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: uploadResult cast: @"navigator.fileTransfer._castUploadResult"];
}
- if(direction == CDV_TRANSFER_DOWNLOAD)
+ if(self.direction == CDV_TRANSFER_DOWNLOAD)
{
DLog(@"Write file %@", target);
error=[[[NSError alloc]init] autorelease];
- NSLog(@"File Transfer Finished with response code %d", responseCode);
+ NSLog(@"File Transfer Finished with response code %d", self.responseCode);
- if(responseCode >= 200 && responseCode < 300)
+ if(self.responseCode >= 200 && self.responseCode < 300)
{
@try {
parentPath = [ self.target stringByDeletingLastPathComponent ];
@@ -282,26 +282,26 @@
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError:[NSString stringWithFormat:@"%d", CONNECTION_ERR] AndSource:source AndTarget:target]];
}
}
- [command writeJavascript:[result toSuccessCallbackString: callbackId]];
+ [self.command writeJavascript:[result toSuccessCallbackString: callbackId]];
[uploadResponse release];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
- responseCode = [response statusCode];
+ self.responseCode = [httpResponse statusCode];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError: [NSString stringWithFormat: @"%d", CONNECTION_ERR] AndSource:source AndTarget:target]];
NSLog(@"File Transfer Error: %@", [error localizedDescription]);
- [command writeJavascript:[result toErrorCallbackString: callbackId]];
+ [self.command writeJavascript:[result toErrorCallbackString: callbackId]];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
- [responseData appendData:data];
+ [self.responseData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
@@ -344,9 +344,12 @@
- (void) dealloc
{
- [callbackId release];
- [responseData release];
- [command release];
+ self.callbackId = nil;
+ self.responseData = nil;
+ self.command = nil;
+ self.source = nil;
+ self.target = nil;
+
[super dealloc];
}