You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/06/18 01:40:30 UTC

[1/3] removed device, file, filetransfer, capture

Updated Branches:
  refs/heads/3.0.0 1b5b123b9 -> 8ac5128bd


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
deleted file mode 100644
index 0f6b174..0000000
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import "CDV.h"
-
-#import <AssetsLibrary/ALAsset.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <AssetsLibrary/ALAssetsLibrary.h>
-#import <CFNetwork/CFNetwork.h>
-
-@interface CDVFileTransfer ()
-// Sets the requests headers for the request.
-- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req;
-// Creates a delegate to handle an upload.
-- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command;
-// Creates an NSData* for the file for the given upload arguments.
-- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command;
-@end
-
-// Buffer size to use for streaming uploads.
-static const NSUInteger kStreamBufferSize = 32768;
-// Magic value within the options dict used to set a cookie.
-NSString* const kOptionsKeyCookie = @"__cookie";
-// Form boundary for multi-part requests.
-NSString* const kFormBoundary = @"+++++org.apache.cordova.formBoundary";
-
-// Writes the given data to the stream in a blocking way.
-// If successful, returns bytesToWrite.
-// If the stream was closed on the other end, returns 0.
-// If there was an error, returns -1.
-static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
-{
-    UInt8* bytes = (UInt8*)[data bytes];
-    NSUInteger bytesToWrite = [data length];
-    NSUInteger totalBytesWritten = 0;
-
-    while (totalBytesWritten < bytesToWrite) {
-        CFIndex result = CFWriteStreamWrite(stream,
-                bytes + totalBytesWritten,
-                bytesToWrite - totalBytesWritten);
-        if (result < 0) {
-            CFStreamError error = CFWriteStreamGetError(stream);
-            NSLog(@"WriteStreamError domain: %ld error: %ld", error.domain, error.error);
-            return result;
-        } else if (result == 0) {
-            return result;
-        }
-        totalBytesWritten += result;
-    }
-
-    return totalBytesWritten;
-}
-
-@implementation CDVFileTransfer
-@synthesize activeTransfers;
-
-- (NSString*)escapePathComponentForUrlString:(NSString*)urlString
-{
-    NSRange schemeAndHostRange = [urlString rangeOfString:@"://.*?/" options:NSRegularExpressionSearch];
-
-    if (schemeAndHostRange.length == 0) {
-        return urlString;
-    }
-
-    NSInteger schemeAndHostEndIndex = NSMaxRange(schemeAndHostRange);
-    NSString* schemeAndHost = [urlString substringToIndex:schemeAndHostEndIndex];
-    NSString* pathComponent = [urlString substringFromIndex:schemeAndHostEndIndex];
-    pathComponent = [pathComponent stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-
-    return [schemeAndHost stringByAppendingString:pathComponent];
-}
-
-- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req
-{
-    [req setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
-
-    NSString* userAgent = [self.commandDelegate userAgent];
-    if (userAgent) {
-        [req setValue:userAgent forHTTPHeaderField:@"User-Agent"];
-    }
-
-    for (NSString* headerName in headers) {
-        id value = [headers objectForKey:headerName];
-        if (!value || (value == [NSNull null])) {
-            value = @"null";
-        }
-
-        // First, remove an existing header if one exists.
-        [req setValue:nil forHTTPHeaderField:headerName];
-
-        if (![value isKindOfClass:[NSArray class]]) {
-            value = [NSArray arrayWithObject:value];
-        }
-
-        // Then, append all header values.
-        for (id __strong subValue in value) {
-            // Convert from an NSNumber -> NSString.
-            if ([subValue respondsToSelector:@selector(stringValue)]) {
-                subValue = [subValue stringValue];
-            }
-            if ([subValue isKindOfClass:[NSString class]]) {
-                [req addValue:subValue forHTTPHeaderField:headerName];
-            }
-        }
-    }
-}
-
-- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData
-{
-    // arguments order from js: [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]
-    // however, params is a JavaScript object and during marshalling is put into the options dict,
-    // thus debug and chunkedMode are the 6th and 7th arguments
-    NSString* target = [command argumentAtIndex:0];
-    NSString* server = [command argumentAtIndex:1];
-    NSString* fileKey = [command argumentAtIndex:2 withDefault:@"file"];
-    NSString* fileName = [command argumentAtIndex:3 withDefault:@"no-filename"];
-    NSString* mimeType = [command argumentAtIndex:4 withDefault:nil];
-    NSDictionary* options = [command argumentAtIndex:5 withDefault:nil];
-    //    BOOL trustAllHosts = [[arguments objectAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
-    BOOL chunkedMode = [[command argumentAtIndex:7 withDefault:[NSNumber numberWithBool:YES]] boolValue];
-    NSDictionary* headers = [command argumentAtIndex:8 withDefault:nil];
-    // Allow alternative http method, default to POST. JS side checks
-    // for allowed methods, currently PUT or POST (forces POST for
-    // unrecognised values)
-    NSString* httpMethod = [command argumentAtIndex:10 withDefault:@"POST"];
-    CDVPluginResult* result = nil;
-    CDVFileTransferError errorCode = 0;
-
-    // NSURL does not accepts URLs with spaces in the path. We escape the path in order
-    // to be more lenient.
-    NSURL* url = [NSURL URLWithString:server];
-
-    if (!url) {
-        errorCode = INVALID_URL_ERR;
-        NSLog(@"File Transfer Error: Invalid server URL %@", server);
-    } else if (!fileData) {
-        errorCode = FILE_NOT_FOUND_ERR;
-    }
-
-    if (errorCode > 0) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:target AndTarget:server]];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return nil;
-    }
-
-    NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
-
-    [req setHTTPMethod:httpMethod];
-
-    //    Magic value to set a cookie
-    if ([options objectForKey:kOptionsKeyCookie]) {
-        [req setValue:[options objectForKey:kOptionsKeyCookie] forHTTPHeaderField:@"Cookie"];
-        [req setHTTPShouldHandleCookies:NO];
-    }
-
-    NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kFormBoundary];
-    [req setValue:contentType forHTTPHeaderField:@"Content-Type"];
-    [self applyRequestHeaders:headers toRequest:req];
-
-    NSData* formBoundaryData = [[NSString stringWithFormat:@"--%@\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
-    NSMutableData* postBodyBeforeFile = [NSMutableData data];
-
-    for (NSString* key in options) {
-        id val = [options objectForKey:key];
-        if (!val || (val == [NSNull null]) || [key isEqualToString:kOptionsKeyCookie]) {
-            continue;
-        }
-        // if it responds to stringValue selector (eg NSNumber) get the NSString
-        if ([val respondsToSelector:@selector(stringValue)]) {
-            val = [val stringValue];
-        }
-        // finally, check whether it is a NSString (for dataUsingEncoding selector below)
-        if (![val isKindOfClass:[NSString class]]) {
-            continue;
-        }
-
-        [postBodyBeforeFile appendData:formBoundaryData];
-        [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
-        [postBodyBeforeFile appendData:[val dataUsingEncoding:NSUTF8StringEncoding]];
-        [postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
-    }
-
-    [postBodyBeforeFile appendData:formBoundaryData];
-    [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]];
-    if (mimeType != nil) {
-        [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]];
-    }
-    [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %d\r\n\r\n", [fileData length]] dataUsingEncoding:NSUTF8StringEncoding]];
-
-    DLog(@"fileData length: %d", [fileData length]);
-    NSData* postBodyAfterFile = [[NSString stringWithFormat:@"\r\n--%@--\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
-
-    NSUInteger totalPayloadLength = [postBodyBeforeFile length] + [fileData length] + [postBodyAfterFile length];
-    [req setValue:[[NSNumber numberWithInteger:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
-
-    if (chunkedMode) {
-        CFReadStreamRef readStream = NULL;
-        CFWriteStreamRef writeStream = NULL;
-        CFStreamCreateBoundPair(NULL, &readStream, &writeStream, kStreamBufferSize);
-        [req setHTTPBodyStream:CFBridgingRelease(readStream)];
-
-        self.backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
-                [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskID];
-                self.backgroundTaskID = UIBackgroundTaskInvalid;
-                NSLog(@"Background task to upload media finished.");
-            }];
-
-        [self.commandDelegate runInBackground:^{
-            if (CFWriteStreamOpen(writeStream)) {
-                NSData* chunks[] = {postBodyBeforeFile, fileData, postBodyAfterFile};
-                int numChunks = sizeof(chunks) / sizeof(chunks[0]);
-
-                for (int i = 0; i < numChunks; ++i) {
-                    CFIndex result = WriteDataToStream(chunks[i], writeStream);
-                    if (result <= 0) {
-                        break;
-                    }
-                }
-            } else {
-                NSLog(@"FileTransfer: Failed to open writeStream");
-            }
-            CFWriteStreamClose(writeStream);
-            CFRelease(writeStream);
-        }];
-    } else {
-        [postBodyBeforeFile appendData:fileData];
-        [postBodyBeforeFile appendData:postBodyAfterFile];
-        [req setHTTPBody:postBodyBeforeFile];
-    }
-    return req;
-}
-
-- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command
-{
-    NSString* source = [command.arguments objectAtIndex:0];
-    NSString* server = [command.arguments objectAtIndex:1];
-    BOOL trustAllHosts = [[command.arguments objectAtIndex:6 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
-    NSString* objectId = [command.arguments objectAtIndex:9];
-
-    CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
-
-    delegate.command = self;
-    delegate.callbackId = command.callbackId;
-    delegate.direction = CDV_TRANSFER_UPLOAD;
-    delegate.objectId = objectId;
-    delegate.source = source;
-    delegate.target = server;
-    delegate.trustAllHosts = trustAllHosts;
-
-    return delegate;
-}
-
-- (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
-{
-    NSString* target = (NSString*)[command.arguments objectAtIndex:0];
-    NSError* __autoreleasing err = nil;
-
-    // return unsupported result for assets-library URLs
-    if ([target hasPrefix:kCDVAssetsLibraryPrefix]) {
-        // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
-        ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
-            if (asset) {
-                // We have the asset!  Get the data and send it off.
-                ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
-                Byte* buffer = (Byte*)malloc([assetRepresentation size]);
-                NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];
-                NSData* fileData = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
-                [self uploadData:fileData command:command];
-            } else {
-                // We couldn't find the asset.  Send the appropriate error.
-                CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-                [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-            }
-        };
-        ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
-            // Retrieving the asset failed for some reason.  Send the appropriate error.
-            CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
-            [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        };
-
-        ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
-        [assetsLibrary assetForURL:[NSURL URLWithString:target] resultBlock:resultBlock failureBlock:failureBlock];
-        return;
-    } else {
-        // Extract the path part out of a file: URL.
-        NSString* filePath = [target hasPrefix:@"/"] ? [target copy] : [[NSURL URLWithString:target] path];
-        if (filePath == nil) {
-            // We couldn't find the asset.  Send the appropriate error.
-            CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-            [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-            return;
-        }
-
-        // Memory map the file so that it can be read efficiently even if it is large.
-        NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];
-
-        if (err != nil) {
-            NSLog(@"Error opening file %@: %@", target, err);
-        }
-        [self uploadData:fileData command:command];
-    }
-}
-
-- (void)upload:(CDVInvokedUrlCommand*)command
-{
-    // fileData and req are split into helper functions to ease the unit testing of delegateForUpload.
-    // First, get the file data.  This method will call `uploadData:command`.
-    [self fileDataForUploadCommand:command];
-}
-
-- (void)uploadData:(NSData*)fileData command:(CDVInvokedUrlCommand*)command
-{
-    NSURLRequest* req = [self requestForUploadCommand:command fileData:fileData];
-
-    if (req == nil) {
-        return;
-    }
-    CDVFileTransferDelegate* delegate = [self delegateForUploadCommand:command];
-    [NSURLConnection connectionWithRequest:req delegate:delegate];
-
-    if (activeTransfers == nil) {
-        activeTransfers = [[NSMutableDictionary alloc] init];
-    }
-
-    [activeTransfers setObject:delegate forKey:delegate.objectId];
-}
-
-- (void)abort:(CDVInvokedUrlCommand*)command
-{
-    NSString* objectId = [command.arguments objectAtIndex:0];
-
-    CDVFileTransferDelegate* delegate = [activeTransfers objectForKey:objectId];
-
-    if (delegate != nil) {
-        [delegate cancelTransfer:delegate.connection];
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:CONNECTION_ABORTED AndSource:delegate.source AndTarget:delegate.target]];
-        [self.commandDelegate sendPluginResult:result callbackId:delegate.callbackId];
-    }
-}
-
-- (void)download:(CDVInvokedUrlCommand*)command
-{
-    DLog(@"File Transfer downloading file...");
-    NSString* sourceUrl = [command.arguments objectAtIndex:0];
-    NSString* filePath = [command.arguments objectAtIndex:1];
-    BOOL trustAllHosts = [[command.arguments objectAtIndex:2 withDefault:[NSNumber numberWithBool:YES]] boolValue]; // allow self-signed certs
-    NSString* objectId = [command.arguments objectAtIndex:3];
-    NSDictionary* headers = [command.arguments objectAtIndex:4 withDefault:nil];
-
-    // return unsupported result for assets-library URLs
-    if ([filePath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"download not supported for assets-library URLs."];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    CDVPluginResult* result = nil;
-    CDVFileTransferError errorCode = 0;
-
-    NSURL* file;
-
-    if ([filePath hasPrefix:@"/"]) {
-        file = [NSURL fileURLWithPath:filePath];
-    } else {
-        file = [NSURL URLWithString:filePath];
-    }
-
-    NSURL* url = [NSURL URLWithString:sourceUrl];
-
-    if (!url) {
-        errorCode = INVALID_URL_ERR;
-        NSLog(@"File Transfer Error: Invalid server URL %@", sourceUrl);
-    } else if (![file isFileURL]) {
-        errorCode = FILE_NOT_FOUND_ERR;
-        NSLog(@"File Transfer Error: Invalid file path or URL %@", filePath);
-    }
-
-    if (errorCode > 0) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[self createFileTransferError:errorCode AndSource:sourceUrl AndTarget:filePath]];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
-    [self applyRequestHeaders:headers toRequest:req];
-
-    CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
-    delegate.command = self;
-    delegate.direction = CDV_TRANSFER_DOWNLOAD;
-    delegate.callbackId = command.callbackId;
-    delegate.objectId = objectId;
-    delegate.source = sourceUrl;
-    delegate.target = filePath;
-    delegate.trustAllHosts = trustAllHosts;
-
-    delegate.connection = [NSURLConnection connectionWithRequest:req delegate:delegate];
-
-    if (activeTransfers == nil) {
-        activeTransfers = [[NSMutableDictionary alloc] init];
-    }
-
-    [activeTransfers setObject:delegate forKey:delegate.objectId];
-}
-
-- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target
-{
-    NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:3];
-
-    [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
-    if (source != nil) {
-        [result setObject:source forKey:@"source"];
-    }
-    if (target != nil) {
-        [result setObject:target forKey:@"target"];
-    }
-    NSLog(@"FileTransferError %@", result);
-
-    return result;
-}
-
-- (NSMutableDictionary*)createFileTransferError:(int)code
-                                      AndSource:(NSString*)source
-                                      AndTarget:(NSString*)target
-                                  AndHttpStatus:(int)httpStatus
-                                        AndBody:(NSString*)body
-{
-    NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:5];
-
-    [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
-    if (source != nil) {
-        [result setObject:source forKey:@"source"];
-    }
-    if (target != nil) {
-        [result setObject:target forKey:@"target"];
-    }
-    [result setObject:[NSNumber numberWithInt:httpStatus] forKey:@"http_status"];
-    if (body != nil) {
-        [result setObject:body forKey:@"body"];
-    }
-    NSLog(@"FileTransferError %@", result);
-
-    return result;
-}
-
-- (void)onReset
-{
-    for (CDVFileTransferDelegate* delegate in [activeTransfers allValues]) {
-        [delegate.connection cancel];
-    }
-
-    [activeTransfers removeAllObjects];
-}
-
-@end
-
-@interface CDVFileTransferEntityLengthRequest : NSObject {
-    NSURLConnection* _connection;
-    CDVFileTransferDelegate* __weak _originalDelegate;
-}
-
-- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate;
-
-@end;
-
-@implementation CDVFileTransferEntityLengthRequest;
-
-- (CDVFileTransferEntityLengthRequest*)initWithOriginalRequest:(NSURLRequest*)originalRequest andDelegate:(CDVFileTransferDelegate*)originalDelegate
-{
-    if (self) {
-        DLog(@"Requesting entity length for GZIPped content...");
-
-        NSMutableURLRequest* req = [originalRequest mutableCopy];
-        [req setHTTPMethod:@"HEAD"];
-        [req setValue:@"identity" forHTTPHeaderField:@"Accept-Encoding"];
-
-        _originalDelegate = originalDelegate;
-        _connection = [NSURLConnection connectionWithRequest:req delegate:self];
-    }
-    return self;
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
-{
-    DLog(@"HEAD request returned; content-length is %lld", [response expectedContentLength]);
-    [_originalDelegate updateBytesExpected:[response expectedContentLength]];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-{}
-
-- (void)connectionDidFinishLoading:(NSURLConnection*)connection
-{}
-
-@end
-
-@implementation CDVFileTransferDelegate
-
-@synthesize callbackId, connection = _connection, source, target, responseData, command, bytesTransfered, bytesExpected, direction, responseCode, objectId, targetFileHandle;
-
-- (void)connectionDidFinishLoading:(NSURLConnection*)connection
-{
-    NSString* uploadResponse = nil;
-    NSString* downloadResponse = nil;
-    NSMutableDictionary* uploadResult;
-    CDVPluginResult* result = nil;
-    BOOL bDirRequest = NO;
-    CDVFile* file;
-
-    NSLog(@"File Transfer Finished with response code %d", self.responseCode);
-
-    if (self.direction == CDV_TRANSFER_UPLOAD) {
-        uploadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
-
-        if ((self.responseCode >= 200) && (self.responseCode < 300)) {
-            // create dictionary to return FileUploadResult object
-            uploadResult = [NSMutableDictionary dictionaryWithCapacity:3];
-            if (uploadResponse != nil) {
-                [uploadResult setObject:uploadResponse forKey:@"response"];
-            }
-            [uploadResult setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"bytesSent"];
-            [uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey:@"responseCode"];
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadResult];
-        } else {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:uploadResponse]];
-        }
-    }
-    if (self.direction == CDV_TRANSFER_DOWNLOAD) {
-        if (self.targetFileHandle) {
-            [self.targetFileHandle closeFile];
-            self.targetFileHandle = nil;
-            DLog(@"File Transfer Download success");
-
-            file = [[CDVFile alloc] init];
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[file getDirectoryEntry:target isDirectory:bDirRequest]];
-        } else {
-            downloadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:downloadResponse]];
-        }
-    }
-
-    [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-
-    // remove connection for activeTransfers
-    [command.activeTransfers removeObjectForKey:objectId];
-
-    // remove background id task in case our upload was done in the background
-    [[UIApplication sharedApplication] endBackgroundTask:self.command.backgroundTaskID];
-    self.command.backgroundTaskID = UIBackgroundTaskInvalid;
-}
-
-- (void)removeTargetFile
-{
-    NSFileManager* fileMgr = [NSFileManager defaultManager];
-
-    [fileMgr removeItemAtPath:self.target error:nil];
-}
-
-- (void)cancelTransfer:(NSURLConnection*)connection
-{
-    [connection cancel];
-    [self.command.activeTransfers removeObjectForKey:self.objectId];
-    [self removeTargetFile];
-}
-
-- (void)cancelTransferWithError:(NSURLConnection*)connection errorMessage:(NSString*)errorMessage
-{
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsDictionary:[self.command createFileTransferError:FILE_NOT_FOUND_ERR AndSource:self.source AndTarget:self.target AndHttpStatus:self.responseCode AndBody:errorMessage]];
-
-    NSLog(@"File Transfer Error: %@", errorMessage);
-    [self cancelTransfer:connection];
-    [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
-{
-    NSError* __autoreleasing error = nil;
-
-    self.mimeType = [response MIMEType];
-    self.targetFileHandle = nil;
-
-    // required for iOS 4.3, for some reason; response is
-    // a plain NSURLResponse, not the HTTP subclass
-    if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
-        NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
-
-        self.responseCode = [httpResponse statusCode];
-        self.bytesExpected = [response expectedContentLength];
-        if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode == 200) && (self.bytesExpected == NSURLResponseUnknownLength)) {
-            // Kick off HEAD request to server to get real length
-            // bytesExpected will be updated when that response is returned
-            self.entityLengthRequest = [[CDVFileTransferEntityLengthRequest alloc] initWithOriginalRequest:connection.currentRequest andDelegate:self];
-        }
-    } else if ([response.URL isFileURL]) {
-        NSDictionary* attr = [[NSFileManager defaultManager] attributesOfItemAtPath:[response.URL path] error:nil];
-        self.responseCode = 200;
-        self.bytesExpected = [attr[NSFileSize] longLongValue];
-    } else {
-        self.responseCode = 200;
-        self.bytesExpected = NSURLResponseUnknownLength;
-    }
-    if ((self.direction == CDV_TRANSFER_DOWNLOAD) && (self.responseCode >= 200) && (self.responseCode < 300)) {
-        // Download response is okay; begin streaming output to file
-        NSString* parentPath = [self.target stringByDeletingLastPathComponent];
-
-        // create parent directories if needed
-        if ([[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:&error] == NO) {
-            if (error) {
-                [self cancelTransferWithError:connection errorMessage:[NSString stringWithFormat:@"Could not create path to save downloaded file: %@", [error localizedDescription]]];
-            } else {
-                [self cancelTransferWithError:connection errorMessage:@"Could not create path to save downloaded file"];
-            }
-            return;
-        }
-        // create target file
-        if ([[NSFileManager defaultManager] createFileAtPath:self.target contents:nil attributes:nil] == NO) {
-            [self cancelTransferWithError:connection errorMessage:@"Could not create target file"];
-            return;
-        }
-        // open target file for writing
-        self.targetFileHandle = [NSFileHandle fileHandleForWritingAtPath:self.target];
-        if (self.targetFileHandle == nil) {
-            [self cancelTransferWithError:connection errorMessage:@"Could not open target file for writing"];
-        }
-        DLog(@"Streaming to file %@", target);
-    }
-}
-
-- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
-{
-    NSString* body = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode AndBody:body]];
-
-    NSLog(@"File Transfer Error: %@", [error localizedDescription]);
-
-    [self cancelTransfer:connection];
-    [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-{
-    self.bytesTransfered += data.length;
-    if (self.targetFileHandle) {
-        [self.targetFileHandle writeData:data];
-    } else {
-        [self.responseData appendData:data];
-    }
-    [self updateProgress];
-}
-
-- (void)updateBytesExpected:(NSInteger)newBytesExpected
-{
-    DLog(@"Updating bytesExpected to %d", newBytesExpected);
-    self.bytesExpected = newBytesExpected;
-    [self updateProgress];
-}
-
-- (void)updateProgress
-{
-    if (self.direction == CDV_TRANSFER_DOWNLOAD) {
-        BOOL lengthComputable = (self.bytesExpected != NSURLResponseUnknownLength);
-        // If the response is GZipped, and we have an outstanding HEAD request to get
-        // the length, then hold off on sending progress events.
-        if (!lengthComputable && (self.entityLengthRequest != nil)) {
-            return;
-        }
-        NSMutableDictionary* downloadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
-        [downloadProgress setObject:[NSNumber numberWithBool:lengthComputable] forKey:@"lengthComputable"];
-        [downloadProgress setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"loaded"];
-        [downloadProgress setObject:[NSNumber numberWithInt:self.bytesExpected] forKey:@"total"];
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:downloadProgress];
-        [result setKeepCallbackAsBool:true];
-        [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-    }
-}
-
-- (void)connection:(NSURLConnection*)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
-{
-    if (self.direction == CDV_TRANSFER_UPLOAD) {
-        NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
-
-        [uploadProgress setObject:[NSNumber numberWithBool:true] forKey:@"lengthComputable"];
-        [uploadProgress setObject:[NSNumber numberWithInt:totalBytesWritten] forKey:@"loaded"];
-        [uploadProgress setObject:[NSNumber numberWithInt:totalBytesExpectedToWrite] forKey:@"total"];
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadProgress];
-        [result setKeepCallbackAsBool:true];
-        [self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
-    }
-    self.bytesTransfered = totalBytesWritten;
-}
-
-// for self signed certificates
-- (void)connection:(NSURLConnection*)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
-{
-    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
-        if (self.trustAllHosts) {
-            NSURLCredential* credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
-            [challenge.sender useCredential:credential forAuthenticationChallenge:challenge];
-        }
-        [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
-    } else {
-        [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
-    }
-}
-
-- (id)init
-{
-    if ((self = [super init])) {
-        self.responseData = [NSMutableData data];
-        self.targetFileHandle = nil;
-    }
-    return self;
-}
-
-@end;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index d025e35..e180074 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,22 +7,16 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F584B991385A28900ED25E8 /* CDVCapture.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F584B9A1385A28900ED25E8 /* CDVCapture.m */; };
 		1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /* CDVPluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F92F49F1314023E0046367C /* CDVPluginResult.m */; };
 		301F2F2A14F3C9CA003FE9FC /* CDV.h in Headers */ = {isa = PBXBuildFile; fileRef = 301F2F2914F3C9CA003FE9FC /* CDV.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 302965BB13A94E9D007046C5 /* CDVDebug.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		3034979C1513D56A0090E688 /* CDVLocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 3034979A1513D56A0090E688 /* CDVLocalStorage.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		3034979E1513D56A0090E688 /* CDVLocalStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 3034979B1513D56A0090E688 /* CDVLocalStorage.m */; };
 		30392E4E14F4FCAB00B9E0B8 /* CDVAvailability.h in Headers */ = {isa = PBXBuildFile; fileRef = 30392E4D14F4FCAB00B9E0B8 /* CDVAvailability.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		3062D122151D0EDB000D9128 /* UIDevice+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */; };
 		3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 307A8F9C1385A2EC00E43782 /* CDVConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 307A8F9D1385A2EC00E43782 /* CDVConnection.m */; };
-		30C5F1DF15AF9E950052A00D /* CDVDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C5F1DD15AF9E950052A00D /* CDVDevice.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		30C5F1E015AF9E950052A00D /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C5F1DE15AF9E950052A00D /* CDVDevice.m */; };
 		30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C6847E1406CB38004C1A8E /* CDVWhitelist.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C6847F1406CB38004C1A8E /* CDVWhitelist.m */; };
 		30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 30C684921407044A004C1A8E /* CDVURLProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -42,8 +36,6 @@
 		8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* CDVViewController.m */; };
 		8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */; };
-		8887FD701090FBE7009987E8 /* CDVFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD301090FBE7009987E8 /* CDVFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		8887FD711090FBE7009987E8 /* CDVFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD311090FBE7009987E8 /* CDVFile.m */; };
 		8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */; };
 		8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -51,8 +43,6 @@
 		8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* CDVReachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* CDVReachability.m */; };
 		8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* CDVSound.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */ = {isa = PBXBuildFile; fileRef = C937A4541337599E002C4C79 /* CDVFileTransfer.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */ = {isa = PBXBuildFile; fileRef = C937A4551337599E002C4C79 /* CDVFileTransfer.m */; };
 		EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */; };
 		EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -70,23 +60,17 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
-		1F584B991385A28900ED25E8 /* CDVCapture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCapture.h; path = Classes/CDVCapture.h; sourceTree = "<group>"; };
-		1F584B9A1385A28900ED25E8 /* CDVCapture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCapture.m; path = Classes/CDVCapture.m; sourceTree = "<group>"; };
 		1F92F49E1314023E0046367C /* CDVPluginResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVPluginResult.h; path = Classes/CDVPluginResult.h; sourceTree = "<group>"; };
 		1F92F49F1314023E0046367C /* CDVPluginResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVPluginResult.m; path = Classes/CDVPluginResult.m; sourceTree = "<group>"; };
 		301F2F2914F3C9CA003FE9FC /* CDV.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDV.h; path = Classes/CDV.h; sourceTree = "<group>"; };
 		302965BB13A94E9D007046C5 /* CDVDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDebug.h; path = Classes/CDVDebug.h; sourceTree = "<group>"; };
 		30325A0B136B343700982B63 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VERSION; sourceTree = "<group>"; };
-		3034979A1513D56A0090E688 /* CDVLocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVLocalStorage.h; path = Classes/CDVLocalStorage.h; sourceTree = "<group>"; };
-		3034979B1513D56A0090E688 /* CDVLocalStorage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVLocalStorage.m; path = Classes/CDVLocalStorage.m; sourceTree = "<group>"; };
 		30392E4D14F4FCAB00B9E0B8 /* CDVAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVAvailability.h; path = Classes/CDVAvailability.h; sourceTree = "<group>"; };
 		3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+Extensions.h"; path = "Classes/UIDevice+Extensions.h"; sourceTree = "<group>"; };
 		3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+Extensions.m"; path = "Classes/UIDevice+Extensions.m"; sourceTree = "<group>"; };
 		3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVScreenOrientationDelegate.h; path = Classes/CDVScreenOrientationDelegate.h; sourceTree = "<group>"; };
 		307A8F9C1385A2EC00E43782 /* CDVConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVConnection.h; path = Classes/CDVConnection.h; sourceTree = "<group>"; };
 		307A8F9D1385A2EC00E43782 /* CDVConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVConnection.m; path = Classes/CDVConnection.m; sourceTree = "<group>"; };
-		30C5F1DD15AF9E950052A00D /* CDVDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVDevice.h; path = Classes/CDVDevice.h; sourceTree = "<group>"; };
-		30C5F1DE15AF9E950052A00D /* CDVDevice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVDevice.m; path = Classes/CDVDevice.m; sourceTree = "<group>"; };
 		30C6847E1406CB38004C1A8E /* CDVWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWhitelist.h; path = Classes/CDVWhitelist.h; sourceTree = "<group>"; };
 		30C6847F1406CB38004C1A8E /* CDVWhitelist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWhitelist.m; path = Classes/CDVWhitelist.m; sourceTree = "<group>"; };
 		30C684921407044A004C1A8E /* CDVURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVURLProtocol.h; path = Classes/CDVURLProtocol.h; sourceTree = "<group>"; };
@@ -119,8 +103,6 @@
 		8852C43714B65FD800F0E735 /* CDVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVViewController.m; path = Classes/CDVViewController.m; sourceTree = "<group>"; };
 		8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Extensions.h"; path = "Classes/NSDictionary+Extensions.h"; sourceTree = "<group>"; };
 		8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Extensions.m"; path = "Classes/NSDictionary+Extensions.m"; sourceTree = "<group>"; };
-		8887FD301090FBE7009987E8 /* CDVFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFile.h; path = Classes/CDVFile.h; sourceTree = "<group>"; };
-		8887FD311090FBE7009987E8 /* CDVFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFile.m; path = Classes/CDVFile.m; sourceTree = "<group>"; };
 		8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVInvokedUrlCommand.h; path = Classes/CDVInvokedUrlCommand.h; sourceTree = "<group>"; };
 		8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInvokedUrlCommand.m; path = Classes/CDVInvokedUrlCommand.m; sourceTree = "<group>"; };
 		8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
@@ -130,8 +112,6 @@
 		8887FD601090FBE7009987E8 /* CDVSound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSound.h; path = Classes/CDVSound.h; sourceTree = "<group>"; };
 		8887FD611090FBE7009987E8 /* CDVSound.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSound.m; path = Classes/CDVSound.m; sourceTree = "<group>"; };
 		AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CordovaLib_Prefix.pch; sourceTree = SOURCE_ROOT; };
-		C937A4541337599E002C4C79 /* CDVFileTransfer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFileTransfer.h; path = Classes/CDVFileTransfer.h; sourceTree = "<group>"; };
-		C937A4551337599E002C4C79 /* CDVFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVFileTransfer.m; path = Classes/CDVFileTransfer.m; sourceTree = "<group>"; };
 		EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandQueue.h; path = Classes/CDVCommandQueue.h; sourceTree = "<group>"; };
 		EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCommandQueue.m; path = Classes/CDVCommandQueue.m; sourceTree = "<group>"; };
 		EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandDelegateImpl.h; path = Classes/CDVCommandDelegateImpl.h; sourceTree = "<group>"; };
@@ -224,11 +204,7 @@
 			children = (
 				EBFF4DBA16D3FE2E008F452B /* CDVWebViewDelegate.m */,
 				EBFF4DBB16D3FE2E008F452B /* CDVWebViewDelegate.h */,
-				30C5F1DD15AF9E950052A00D /* CDVDevice.h */,
-				30C5F1DE15AF9E950052A00D /* CDVDevice.m */,
 				301F2F2914F3C9CA003FE9FC /* CDV.h */,
-				3034979A1513D56A0090E688 /* CDVLocalStorage.h */,
-				3034979B1513D56A0090E688 /* CDVLocalStorage.m */,
 				30392E4D14F4FCAB00B9E0B8 /* CDVAvailability.h */,
 				30F5EBA914CA26E700987760 /* CDVCommandDelegate.h */,
 				EB3B357A161F2A44003DBE7D /* CDVCommandDelegateImpl.h */,
@@ -243,16 +219,10 @@
 				307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
 				1F92F49E1314023E0046367C /* CDVPluginResult.h */,
 				1F92F49F1314023E0046367C /* CDVPluginResult.m */,
-				1F584B991385A28900ED25E8 /* CDVCapture.h */,
-				1F584B9A1385A28900ED25E8 /* CDVCapture.m */,
 				EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
 				EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
-				8887FD301090FBE7009987E8 /* CDVFile.h */,
-				8887FD311090FBE7009987E8 /* CDVFile.m */,
 				8887FD341090FBE7009987E8 /* CDVInvokedUrlCommand.h */,
 				8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
-				C937A4541337599E002C4C79 /* CDVFileTransfer.h */,
-				C937A4551337599E002C4C79 /* CDVFileTransfer.m */,
 				8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
 				8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
 				8887FD601090FBE7009987E8 /* CDVSound.h */,
@@ -306,15 +276,12 @@
 			buildActionMask = 2147483647;
 			files = (
 				8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
-				8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
 				8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
 				8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
 				8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
 				8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
 				1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
-				C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */,
 				307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */,
-				1F584B9B1385A28A00ED25E8 /* CDVCapture.h in Headers */,
 				30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */,
 				302965BC13A94E9D007046C5 /* CDVDebug.h in Headers */,
 				30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
@@ -324,11 +291,9 @@
 				30F5EBAB14CA26E700987760 /* CDVCommandDelegate.h in Headers */,
 				301F2F2A14F3C9CA003FE9FC /* CDV.h in Headers */,
 				30392E4E14F4FCAB00B9E0B8 /* CDVAvailability.h in Headers */,
-				3034979C1513D56A0090E688 /* CDVLocalStorage.h in Headers */,
 				3062D120151D0EDB000D9128 /* UIDevice+Extensions.h in Headers */,
 				3E76876F156A90EE00EB6FA3 /* CDVLogger.h in Headers */,
 				EBA3557315ABD38C00F4DE24 /* NSArray+Comparisons.h in Headers */,
-				30C5F1DF15AF9E950052A00D /* CDVDevice.h in Headers */,
 				EB80C2AC15DEA63D004D9E7B /* CDVEcho.h in Headers */,
 				EB3B3547161CB44D003DBE7D /* CDVCommandQueue.h in Headers */,
 				EB3B357C161F2A45003DBE7D /* CDVCommandDelegateImpl.h in Headers */,
@@ -396,25 +361,20 @@
 			buildActionMask = 2147483647;
 			files = (
 				8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
-				8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
 				8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
 				8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
 				8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
 				8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
 				1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
-				C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */,
 				307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */,
-				1F584B9C1385A28A00ED25E8 /* CDVCapture.m in Sources */,
 				30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */,
 				30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
 				30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
 				30C684961407044B004C1A8E /* CDVURLProtocol.m in Sources */,
 				8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */,
-				3034979E1513D56A0090E688 /* CDVLocalStorage.m in Sources */,
 				3062D122151D0EDB000D9128 /* UIDevice+Extensions.m in Sources */,
 				3E76876D156A90EE00EB6FA3 /* CDVLogger.m in Sources */,
 				EBA3557515ABD38C00F4DE24 /* NSArray+Comparisons.m in Sources */,
-				30C5F1E015AF9E950052A00D /* CDVDevice.m in Sources */,
 				EB80C2AD15DEA63D004D9E7B /* CDVEcho.m in Sources */,
 				EB3B3548161CB44D003DBE7D /* CDVCommandQueue.m in Sources */,
 				EB3B357D161F2A45003DBE7D /* CDVCommandDelegateImpl.m in Sources */,

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 38af0bc..9f1fc42 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -52,30 +52,9 @@
     <preference name="SuppressesIncrementalRendering" value="false" />
     <preference name="TopActivityIndicator" value="gray" />
 
-    <feature name="Device">
-      <param name="ios-package" value="CDVDevice"/>
-    </feature>
-    <feature name="Media">
-      <param name="ios-package" value="CDVSound"/>
-    </feature>
-    <feature name="File">
-      <param name="ios-package"  value="CDVFile"/>
-    </feature>
-    <feature name="NetworkStatus">
-      <param name="ios-package" value="CDVConnection"/>
-    </feature>
-    <feature name="FileTransfer">
-      <param name="ios-package" value="CDVFileTransfer"/>
-    </feature>
-    <feature name="Capture">
-      <param name="ios-package" value="CDVCapture"/>
-    </feature>
     <feature name="Logger">
       <param name="ios-package" value="CDVLogger"/>
     </feature>
-    <feature name="LocalStorage">
-        <param name="ios-package" value="CDVLocalStorage"/>
-    </feature>
     <!-- Deprecated plugins element. REmove in 3.0 -->
     <plugins>
     </plugins>


[3/3] ios commit: removed device, file, filetransfer, capture

Posted by st...@apache.org.
removed device, file, filetransfer, capture


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/8ac5128b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/8ac5128b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/8ac5128b

Branch: refs/heads/3.0.0
Commit: 8ac5128bd2635db4f13630ef60d7701d65e527d6
Parents: 1b5b123
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 17 16:40:23 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 17 16:40:23 2013 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDV.h                        |    3 -
 CordovaLib/Classes/CDVCapture.h                 |  118 --
 CordovaLib/Classes/CDVCapture.m                 |  845 -----------
 CordovaLib/Classes/CDVDevice.h                  |   30 -
 CordovaLib/Classes/CDVDevice.m                  |   89 --
 CordovaLib/Classes/CDVFile.h                    |  106 --
 CordovaLib/Classes/CDVFile.m                    | 1414 ------------------
 CordovaLib/Classes/CDVFileTransfer.h            |   82 -
 CordovaLib/Classes/CDVFileTransfer.m            |  730 ---------
 CordovaLib/CordovaLib.xcodeproj/project.pbxproj |   40 -
 bin/templates/project/__TESTING__/config.xml    |   21 -
 11 files changed, 3478 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 03c2a3e..66d763d 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -28,9 +28,6 @@
 #import "CDVCapture.h"
 #import "CDVConnection.h"
 #import "CDVDebug.h"
-#import "CDVDevice.h"
-#import "CDVFile.h"
-#import "CDVFileTransfer.h"
 #import "CDVPluginResult.h"
 #import "CDVReachability.h"
 #import "CDVSound.h"

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVCapture.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.h b/CordovaLib/Classes/CDVCapture.h
deleted file mode 100644
index afb82b4..0000000
--- a/CordovaLib/Classes/CDVCapture.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <Foundation/Foundation.h>
-#import <MobileCoreServices/MobileCoreServices.h>
-#import <AVFoundation/AVFoundation.h>
-#import "CDVPlugin.h"
-#import "CDVFile.h"
-
-enum CDVCaptureError {
-    CAPTURE_INTERNAL_ERR = 0,
-    CAPTURE_APPLICATION_BUSY = 1,
-    CAPTURE_INVALID_ARGUMENT = 2,
-    CAPTURE_NO_MEDIA_FILES = 3,
-    CAPTURE_NOT_SUPPORTED = 20
-};
-typedef NSUInteger CDVCaptureError;
-
-@interface CDVImagePicker : UIImagePickerController
-{
-    NSString* callbackid;
-    NSInteger quality;
-    NSString* mimeType;
-}
-@property (assign) NSInteger quality;
-@property (copy)   NSString* callbackId;
-@property (copy)   NSString* mimeType;
-
-@end
-
-@interface CDVCapture : CDVPlugin <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
-{
-    CDVImagePicker* pickerController;
-    BOOL inUse;
-}
-@property BOOL inUse;
-- (void)captureAudio:(CDVInvokedUrlCommand*)command;
-- (void)captureImage:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId;
-- (void)captureVideo:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId;
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command;
-- (void)getFormatData:(CDVInvokedUrlCommand*)command;
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-
-@end
-
-@interface CDVAudioNavigationController : UINavigationController
-
-@end
-
-/* AudioRecorderViewController is used to create a simple view for audio recording.
- *  It is created from [Capture captureAudio].  It creates a very simple interface for
- *  recording by presenting just a record/stop button and a Done button to close the view.
- *  The recording time is displayed and recording for a specified duration is supported. When duration
- *  is specified there is no UI to the user - recording just stops when the specified
- *  duration is reached.  The UI has been minimized to avoid localization.
- */
-@interface CDVAudioRecorderViewController : UIViewController <AVAudioRecorderDelegate>
-{
-    CDVCaptureError errorCode;
-    NSString* callbackId;
-    NSNumber* duration;
-    CDVCapture* captureCommand;
-    UIBarButtonItem* doneButton;
-    UIView* recordingView;
-    UIButton* recordButton;
-    UIImage* recordImage;
-    UIImage* stopRecordImage;
-    UILabel* timerLabel;
-    AVAudioRecorder* avRecorder;
-    AVAudioSession* avSession;
-    CDVPluginResult* pluginResult;
-    NSTimer* timer;
-    BOOL isTimed;
-}
-@property (nonatomic) CDVCaptureError errorCode;
-@property (nonatomic, copy) NSString* callbackId;
-@property (nonatomic, copy) NSNumber* duration;
-@property (nonatomic, strong) CDVCapture* captureCommand;
-@property (nonatomic, strong) UIBarButtonItem* doneButton;
-@property (nonatomic, strong) UIView* recordingView;
-@property (nonatomic, strong) UIButton* recordButton;
-@property (nonatomic, strong) UIImage* recordImage;
-@property (nonatomic, strong) UIImage* stopRecordImage;
-@property (nonatomic, strong) UILabel* timerLabel;
-@property (nonatomic, strong) AVAudioRecorder* avRecorder;
-@property (nonatomic, strong) AVAudioSession* avSession;
-@property (nonatomic, strong) CDVPluginResult* pluginResult;
-@property (nonatomic, strong) NSTimer* timer;
-@property (nonatomic) BOOL isTimed;
-
-- (id)initWithCommand:(CDVPlugin*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId;
-- (void)processButton:(id)sender;
-- (void)stopRecordingCleanup;
-- (void)dismissAudioView:(id)sender;
-- (NSString*)formatTime:(int)interval;
-- (void)updateTime;
-@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m
deleted file mode 100644
index 6b7ed44..0000000
--- a/CordovaLib/Classes/CDVCapture.m
+++ /dev/null
@@ -1,845 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import "CDVCapture.h"
-#import "CDVJSON.h"
-#import "CDVAvailability.h"
-
-#define kW3CMediaFormatHeight @"height"
-#define kW3CMediaFormatWidth @"width"
-#define kW3CMediaFormatCodecs @"codecs"
-#define kW3CMediaFormatBitrate @"bitrate"
-#define kW3CMediaFormatDuration @"duration"
-#define kW3CMediaModeType @"type"
-
-@implementation CDVImagePicker
-
-@synthesize quality;
-@synthesize callbackId;
-@synthesize mimeType;
-
-- (uint64_t)accessibilityTraits
-{
-    NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
-
-    if (([systemVersion compare:@"4.0" options:NSNumericSearch] != NSOrderedAscending)) { // this means system version is not less than 4.0
-        return UIAccessibilityTraitStartsMediaSession;
-    }
-
-    return UIAccessibilityTraitNone;
-}
-
-@end
-
-@implementation CDVCapture
-@synthesize inUse;
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
-    self = (CDVCapture*)[super initWithWebView:theWebView];
-    if (self) {
-        self.inUse = NO;
-    }
-    return self;
-}
-
-- (void)captureAudio:(CDVInvokedUrlCommand*)command
-{
-    NSString* callbackId = command.callbackId;
-    NSDictionary* options = [command.arguments objectAtIndex:0];
-
-    if ([options isKindOfClass:[NSNull class]]) {
-        options = [NSDictionary dictionary];
-    }
-
-    NSNumber* duration = [options objectForKey:@"duration"];
-    // the default value of duration is 0 so use nil (no duration) if default value
-    if (duration) {
-        duration = [duration doubleValue] == 0 ? nil : duration;
-    }
-    CDVPluginResult* result = nil;
-
-    if (NSClassFromString(@"AVAudioRecorder") == nil) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
-    } else if (self.inUse == YES) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_APPLICATION_BUSY];
-    } else {
-        // all the work occurs here
-        CDVAudioRecorderViewController* audioViewController = [[CDVAudioRecorderViewController alloc] initWithCommand:self duration:duration callbackId:callbackId];
-
-        // Now create a nav controller and display the view...
-        CDVAudioNavigationController* navController = [[CDVAudioNavigationController alloc] initWithRootViewController:audioViewController];
-
-        self.inUse = YES;
-
-        if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
-            [self.viewController presentViewController:navController animated:YES completion:nil];
-        } else {
-            [self.viewController presentModalViewController:navController animated:YES];
-        }
-    }
-
-    if (result) {
-        [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-    }
-}
-
-- (void)captureImage:(CDVInvokedUrlCommand*)command
-{
-    NSString* callbackId = command.callbackId;
-    NSDictionary* options = [command.arguments objectAtIndex:0];
-
-    if ([options isKindOfClass:[NSNull class]]) {
-        options = [NSDictionary dictionary];
-    }
-
-    // options could contain limit and mode neither of which are supported at this time
-    // taking more than one picture (limit) is only supported if provide own controls via cameraOverlayView property
-    // can support mode in OS
-
-    if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
-        NSLog(@"Capture.imageCapture: camera not available.");
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
-        [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-    } else {
-        if (pickerController == nil) {
-            pickerController = [[CDVImagePicker alloc] init];
-        }
-
-        pickerController.delegate = self;
-        pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
-        pickerController.allowsEditing = NO;
-        if ([pickerController respondsToSelector:@selector(mediaTypes)]) {
-            // iOS 3.0
-            pickerController.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
-        }
-
-        /*if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]){
-            // iOS 4.0
-            pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
-            pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
-            pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
-        }*/
-        // CDVImagePicker specific property
-        pickerController.callbackId = callbackId;
-
-        if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
-            [self.viewController presentViewController:pickerController animated:YES completion:nil];
-        } else {
-            [self.viewController presentModalViewController:pickerController animated:YES];
-        }
-    }
-}
-
-/* Process a still image from the camera.
- * IN:
- *  UIImage* image - the UIImage data returned from the camera
- *  NSString* callbackId
- */
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId
-{
-    CDVPluginResult* result = nil;
-
-    // save the image to photo album
-    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
-
-    NSData* data = nil;
-    if (mimeType && [mimeType isEqualToString:@"image/png"]) {
-        data = UIImagePNGRepresentation(image);
-    } else {
-        data = UIImageJPEGRepresentation(image, 0.5);
-    }
-
-    // write to temp directory and return URI
-    NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];   // use file system temporary directory
-    NSError* err = nil;
-    NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
-    // generate unique file name
-    NSString* filePath;
-    int i = 1;
-    do {
-        filePath = [NSString stringWithFormat:@"%@/photo_%03d.jpg", docsPath, i++];
-    } while ([fileMgr fileExistsAtPath:filePath]);
-
-    if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
-        if (err) {
-            NSLog(@"Error saving image: %@", [err localizedDescription]);
-        }
-    } else {
-        // create MediaFile object
-
-        NSDictionary* fileDict = [self getMediaDictionaryFromPath:filePath ofType:mimeType];
-        NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
-    }
-
-    return result;
-}
-
-- (void)captureVideo:(CDVInvokedUrlCommand*)command
-{
-    NSString* callbackId = command.callbackId;
-    NSDictionary* options = [command.arguments objectAtIndex:0];
-
-    if ([options isKindOfClass:[NSNull class]]) {
-        options = [NSDictionary dictionary];
-    }
-
-    // options could contain limit, duration and mode, only duration is supported (but is not due to apple bug)
-    // taking more than one video (limit) is only supported if provide own controls via cameraOverlayView property
-    // NSNumber* duration = [options objectForKey:@"duration"];
-    NSString* mediaType = nil;
-
-    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
-        // there is a camera, it is available, make sure it can do movies
-        pickerController = [[CDVImagePicker alloc] init];
-
-        NSArray* types = nil;
-        if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
-            types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
-            // NSLog(@"MediaTypes: %@", [types description]);
-
-            if ([types containsObject:(NSString*)kUTTypeMovie]) {
-                mediaType = (NSString*)kUTTypeMovie;
-            } else if ([types containsObject:(NSString*)kUTTypeVideo]) {
-                mediaType = (NSString*)kUTTypeVideo;
-            }
-        }
-    }
-    if (!mediaType) {
-        // don't have video camera return error
-        NSLog(@"Capture.captureVideo: video mode not available.");
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
-        [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-        pickerController = nil;
-    } else {
-        pickerController.delegate = self;
-        pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
-        pickerController.allowsEditing = NO;
-        // iOS 3.0
-        pickerController.mediaTypes = [NSArray arrayWithObjects:mediaType, nil];
-
-        /*if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]){
-            if (duration) {
-                pickerController.videoMaximumDuration = [duration doubleValue];
-            }
-            //NSLog(@"pickerController.videoMaximumDuration = %f", pickerController.videoMaximumDuration);
-        }*/
-
-        // iOS 4.0
-        if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]) {
-            pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
-            // pickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
-            // pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
-            // pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
-        }
-        // CDVImagePicker specific property
-        pickerController.callbackId = callbackId;
-
-        if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
-            [self.viewController presentViewController:pickerController animated:YES completion:nil];
-        } else {
-            [self.viewController presentModalViewController:pickerController animated:YES];
-        }
-    }
-}
-
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId
-{
-    // save the movie to photo album (only avail as of iOS 3.1)
-
-    /* don't need, it should automatically get saved
-     NSLog(@"can save %@: %d ?", moviePath, UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath));
-    if (&UIVideoAtPathIsCompatibleWithSavedPhotosAlbum != NULL && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) == YES) {
-        NSLog(@"try to save movie");
-        UISaveVideoAtPathToSavedPhotosAlbum(moviePath, nil, nil, nil);
-        NSLog(@"finished saving movie");
-    }*/
-    // create MediaFile object
-    NSDictionary* fileDict = [self getMediaDictionaryFromPath:moviePath ofType:nil];
-    NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
-    return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
-}
-
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command
-{
-    // NSString* callbackId = [arguments objectAtIndex:0];
-    // NSMutableDictionary* imageModes = nil;
-    NSArray* imageArray = nil;
-    NSArray* movieArray = nil;
-    NSArray* audioArray = nil;
-
-    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
-        // there is a camera, find the modes
-        // can get image/jpeg or image/png from camera
-
-        /* can't find a way to get the default height and width and other info
-         * for images/movies taken with UIImagePickerController
-         */
-        NSDictionary* jpg = [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
-            [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
-            @"image/jpeg", kW3CMediaModeType,
-            nil];
-        NSDictionary* png = [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
-            [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
-            @"image/png", kW3CMediaModeType,
-            nil];
-        imageArray = [NSArray arrayWithObjects:jpg, png, nil];
-
-        if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
-            NSArray* types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
-
-            if ([types containsObject:(NSString*)kUTTypeMovie]) {
-                NSDictionary* mov = [NSDictionary dictionaryWithObjectsAndKeys:
-                    [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
-                    [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
-                    @"video/quicktime", kW3CMediaModeType,
-                    nil];
-                movieArray = [NSArray arrayWithObject:mov];
-            }
-        }
-    }
-    NSDictionary* modes = [NSDictionary dictionaryWithObjectsAndKeys:
-        imageArray ? (NSObject*)                          imageArray:[NSNull null], @"image",
-        movieArray ? (NSObject*)                          movieArray:[NSNull null], @"video",
-        audioArray ? (NSObject*)                          audioArray:[NSNull null], @"audio",
-        nil];
-    NSString* jsString = [NSString stringWithFormat:@"navigator.device.capture.setSupportedModes(%@);", [modes JSONString]];
-    [self.commandDelegate evalJs:jsString];
-}
-
-- (void)getFormatData:(CDVInvokedUrlCommand*)command
-{
-    NSString* callbackId = command.callbackId;
-    // existence of fullPath checked on JS side
-    NSString* fullPath = [command.arguments objectAtIndex:0];
-    // mimeType could be null
-    NSString* mimeType = nil;
-
-    if ([command.arguments count] > 1) {
-        mimeType = [command.arguments objectAtIndex:1];
-    }
-    BOOL bError = NO;
-    CDVCaptureError errorCode = CAPTURE_INTERNAL_ERR;
-    CDVPluginResult* result = nil;
-
-    if (!mimeType || [mimeType isKindOfClass:[NSNull class]]) {
-        // try to determine mime type if not provided
-        id command = [self.commandDelegate getCommandInstance:@"File"];
-        bError = !([command isKindOfClass:[CDVFile class]]);
-        if (!bError) {
-            CDVFile* cdvFile = (CDVFile*)command;
-            mimeType = [cdvFile getMimeTypeFromPath:fullPath];
-            if (!mimeType) {
-                // can't do much without mimeType, return error
-                bError = YES;
-                errorCode = CAPTURE_INVALID_ARGUMENT;
-            }
-        }
-    }
-    if (!bError) {
-        // create and initialize return dictionary
-        NSMutableDictionary* formatData = [NSMutableDictionary dictionaryWithCapacity:5];
-        [formatData setObject:[NSNull null] forKey:kW3CMediaFormatCodecs];
-        [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatBitrate];
-        [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatHeight];
-        [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatWidth];
-        [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatDuration];
-
-        if ([mimeType rangeOfString:@"image/"].location != NSNotFound) {
-            UIImage* image = [UIImage imageWithContentsOfFile:fullPath];
-            if (image) {
-                CGSize imgSize = [image size];
-                [formatData setObject:[NSNumber numberWithInteger:imgSize.width] forKey:kW3CMediaFormatWidth];
-                [formatData setObject:[NSNumber numberWithInteger:imgSize.height] forKey:kW3CMediaFormatHeight];
-            }
-        } else if (([mimeType rangeOfString:@"video/"].location != NSNotFound) && (NSClassFromString(@"AVURLAsset") != nil)) {
-            NSURL* movieURL = [NSURL fileURLWithPath:fullPath];
-            AVURLAsset* movieAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
-            CMTime duration = [movieAsset duration];
-            [formatData setObject:[NSNumber numberWithFloat:CMTimeGetSeconds(duration)]  forKey:kW3CMediaFormatDuration];
-
-            NSArray* allVideoTracks = [movieAsset tracksWithMediaType:AVMediaTypeVideo];
-            if ([allVideoTracks count] > 0) {
-                AVAssetTrack* track = [[movieAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
-                CGSize size = [track naturalSize];
-
-                [formatData setObject:[NSNumber numberWithFloat:size.height] forKey:kW3CMediaFormatHeight];
-                [formatData setObject:[NSNumber numberWithFloat:size.width] forKey:kW3CMediaFormatWidth];
-                // not sure how to get codecs or bitrate???
-                // AVMetadataItem
-                // AudioFile
-            } else {
-                NSLog(@"No video tracks found for %@", fullPath);
-            }
-        } else if ([mimeType rangeOfString:@"audio/"].location != NSNotFound) {
-            if (NSClassFromString(@"AVAudioPlayer") != nil) {
-                NSURL* fileURL = [NSURL fileURLWithPath:fullPath];
-                NSError* err = nil;
-
-                AVAudioPlayer* avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&err];
-                if (!err) {
-                    // get the data
-                    [formatData setObject:[NSNumber numberWithDouble:[avPlayer duration]] forKey:kW3CMediaFormatDuration];
-                    if ([avPlayer respondsToSelector:@selector(settings)]) {
-                        NSDictionary* info = [avPlayer settings];
-                        NSNumber* bitRate = [info objectForKey:AVEncoderBitRateKey];
-                        if (bitRate) {
-                            [formatData setObject:bitRate forKey:kW3CMediaFormatBitrate];
-                        }
-                    }
-                } // else leave data init'ed to 0
-            }
-        }
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:formatData];
-        // NSLog(@"getFormatData: %@", [formatData description]);
-    }
-    if (bError) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:errorCode];
-    }
-    if (result) {
-        [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-    }
-}
-
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type
-{
-    NSFileManager* fileMgr = [[NSFileManager alloc] init];
-    NSMutableDictionary* fileDict = [NSMutableDictionary dictionaryWithCapacity:5];
-
-    [fileDict setObject:[fullPath lastPathComponent] forKey:@"name"];
-    [fileDict setObject:fullPath forKey:@"fullPath"];
-    // determine type
-    if (!type) {
-        id command = [self.commandDelegate getCommandInstance:@"File"];
-        if ([command isKindOfClass:[CDVFile class]]) {
-            CDVFile* cdvFile = (CDVFile*)command;
-            NSString* mimeType = [cdvFile getMimeTypeFromPath:fullPath];
-            [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType : [NSNull null]) forKey:@"type"];
-        }
-    }
-    NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:nil];
-    [fileDict setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
-    NSDate* modDate = [fileAttrs fileModificationDate];
-    NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000];
-    [fileDict setObject:msDate forKey:@"lastModifiedDate"];
-
-    return fileDict;
-}
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
-{
-    // older api calls new one
-    [self imagePickerController:picker didFinishPickingMediaWithInfo:editingInfo];
-}
-
-/* Called when image/movie is finished recording.
- * Calls success or error code as appropriate
- * if successful, result  contains an array (with just one entry since can only get one image unless build own camera UI) of MediaFile object representing the image
- *      name
- *      fullPath
- *      type
- *      lastModifiedDate
- *      size
- */
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
-{
-    CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
-    NSString* callbackId = cameraPicker.callbackId;
-
-    if ([picker respondsToSelector:@selector(presentingViewController)]) {
-        [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
-    } else {
-        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
-    }
-
-    CDVPluginResult* result = nil;
-
-    UIImage* image = nil;
-    NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
-    if (!mediaType || [mediaType isEqualToString:(NSString*)kUTTypeImage]) {
-        // mediaType is nil then only option is UIImagePickerControllerOriginalImage
-        if ([UIImagePickerController respondsToSelector:@selector(allowsEditing)] &&
-            (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage])) {
-            image = [info objectForKey:UIImagePickerControllerEditedImage];
-        } else {
-            image = [info objectForKey:UIImagePickerControllerOriginalImage];
-        }
-    }
-    if (image != nil) {
-        // mediaType was image
-        result = [self processImage:image type:cameraPicker.mimeType forCallbackId:callbackId];
-    } else if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]) {
-        // process video
-        NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
-        if (moviePath) {
-            result = [self processVideo:moviePath forCallbackId:callbackId];
-        }
-    }
-    if (!result) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_INTERNAL_ERR];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-    pickerController = nil;
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
-    CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
-    NSString* callbackId = cameraPicker.callbackId;
-
-    if ([picker respondsToSelector:@selector(presentingViewController)]) {
-        [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
-    } else {
-        [[picker parentViewController] dismissModalViewControllerAnimated:YES];
-    }
-
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NO_MEDIA_FILES];
-    [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-    pickerController = nil;
-}
-
-@end
-
-@implementation CDVAudioNavigationController
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
-    - (NSUInteger)supportedInterfaceOrientations
-    {
-        // delegate to CVDAudioRecorderViewController
-        return [self.topViewController supportedInterfaceOrientations];
-    }
-#endif
-
-@end
-
-@implementation CDVAudioRecorderViewController
-@synthesize errorCode, callbackId, duration, captureCommand, doneButton, recordingView, recordButton, recordImage, stopRecordImage, timerLabel, avRecorder, avSession, pluginResult, timer, isTimed;
-
-- (NSString*)resolveImageResource:(NSString*)resource
-{
-    NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
-    BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
-
-    // the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path
-    // if user wants iPhone only app to run on iPad they must remove *~ipad.* images from capture.bundle
-    if (isLessThaniOS4) {
-        NSString* iPadResource = [NSString stringWithFormat:@"%@~ipad.png", resource];
-        if (CDV_IsIPad() && [UIImage imageNamed:iPadResource]) {
-            return iPadResource;
-        } else {
-            return [NSString stringWithFormat:@"%@.png", resource];
-        }
-    }
-
-    return resource;
-}
-
-- (id)initWithCommand:(CDVCapture*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId
-{
-    if ((self = [super init])) {
-        self.captureCommand = theCommand;
-        self.duration = theDuration;
-        self.callbackId = theCallbackId;
-        self.errorCode = CAPTURE_NO_MEDIA_FILES;
-        self.isTimed = self.duration != nil;
-
-        return self;
-    }
-
-    return nil;
-}
-
-- (void)loadView
-{
-    // create view and display
-    CGRect viewRect = [[UIScreen mainScreen] applicationFrame];
-    UIView* tmp = [[UIView alloc] initWithFrame:viewRect];
-
-    // make backgrounds
-    NSString* microphoneResource = @"Capture.bundle/microphone";
-
-    if (CDV_IsIPhone5()) {
-        microphoneResource = @"Capture.bundle/microphone-568h";
-    }
-
-    UIImage* microphone = [UIImage imageNamed:[self resolveImageResource:microphoneResource]];
-    UIView* microphoneView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, microphone.size.height)];
-    [microphoneView setBackgroundColor:[UIColor colorWithPatternImage:microphone]];
-    [microphoneView setUserInteractionEnabled:NO];
-    [microphoneView setIsAccessibilityElement:NO];
-    [tmp addSubview:microphoneView];
-
-    // add bottom bar view
-    UIImage* grayBkg = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/controls_bg"]];
-    UIView* controls = [[UIView alloc] initWithFrame:CGRectMake(0, microphone.size.height, viewRect.size.width, grayBkg.size.height)];
-    [controls setBackgroundColor:[UIColor colorWithPatternImage:grayBkg]];
-    [controls setUserInteractionEnabled:NO];
-    [controls setIsAccessibilityElement:NO];
-    [tmp addSubview:controls];
-
-    // make red recording background view
-    UIImage* recordingBkg = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/recording_bg"]];
-    UIColor* background = [UIColor colorWithPatternImage:recordingBkg];
-    self.recordingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
-    [self.recordingView setBackgroundColor:background];
-    [self.recordingView setHidden:YES];
-    [self.recordingView setUserInteractionEnabled:NO];
-    [self.recordingView setIsAccessibilityElement:NO];
-    [tmp addSubview:self.recordingView];
-
-    // add label
-    self.timerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
-    // timerLabel.autoresizingMask = reSizeMask;
-    [self.timerLabel setBackgroundColor:[UIColor clearColor]];
-    [self.timerLabel setTextColor:[UIColor whiteColor]];
-    [self.timerLabel setTextAlignment:UITextAlignmentCenter];
-    [self.timerLabel setText:@"0:00"];
-    [self.timerLabel setAccessibilityHint:NSLocalizedString(@"recorded time in minutes and seconds", nil)];
-    self.timerLabel.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
-    self.timerLabel.accessibilityTraits &= ~UIAccessibilityTraitStaticText;
-    [tmp addSubview:self.timerLabel];
-
-    // Add record button
-
-    self.recordImage = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/record_button"]];
-    self.stopRecordImage = [UIImage imageNamed:[self resolveImageResource:@"Capture.bundle/stop_button"]];
-    self.recordButton.accessibilityTraits |= [self accessibilityTraits];
-    self.recordButton = [[UIButton alloc] initWithFrame:CGRectMake((viewRect.size.width - recordImage.size.width) / 2, (microphone.size.height + (grayBkg.size.height - recordImage.size.height) / 2), recordImage.size.width, recordImage.size.height)];
-    [self.recordButton setAccessibilityLabel:NSLocalizedString(@"toggle audio recording", nil)];
-    [self.recordButton setImage:recordImage forState:UIControlStateNormal];
-    [self.recordButton addTarget:self action:@selector(processButton:) forControlEvents:UIControlEventTouchUpInside];
-    [tmp addSubview:recordButton];
-
-    // make and add done button to navigation bar
-    self.doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissAudioView:)];
-    [self.doneButton setStyle:UIBarButtonItemStyleDone];
-    self.navigationItem.rightBarButtonItem = self.doneButton;
-
-    [self setView:tmp];
-}
-
-- (void)viewDidLoad
-{
-    [super viewDidLoad];
-    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
-    NSError* error = nil;
-
-    if (self.avSession == nil) {
-        // create audio session
-        self.avSession = [AVAudioSession sharedInstance];
-        if (error) {
-            // return error if can't create recording audio session
-            NSLog(@"error creating audio session: %@", [[error userInfo] description]);
-            self.errorCode = CAPTURE_INTERNAL_ERR;
-            [self dismissAudioView:nil];
-        }
-    }
-
-    // create file to record to in temporary dir
-
-    NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];   // use file system temporary directory
-    NSError* err = nil;
-    NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
-    // generate unique file name
-    NSString* filePath;
-    int i = 1;
-    do {
-        filePath = [NSString stringWithFormat:@"%@/audio_%03d.wav", docsPath, i++];
-    } while ([fileMgr fileExistsAtPath:filePath]);
-
-    NSURL* fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
-
-    // create AVAudioPlayer
-    self.avRecorder = [[AVAudioRecorder alloc] initWithURL:fileURL settings:nil error:&err];
-    if (err) {
-        NSLog(@"Failed to initialize AVAudioRecorder: %@\n", [err localizedDescription]);
-        self.avRecorder = nil;
-        // return error
-        self.errorCode = CAPTURE_INTERNAL_ERR;
-        [self dismissAudioView:nil];
-    } else {
-        self.avRecorder.delegate = self;
-        [self.avRecorder prepareToRecord];
-        self.recordButton.enabled = YES;
-        self.doneButton.enabled = YES;
-    }
-}
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
-    - (NSUInteger)supportedInterfaceOrientations
-    {
-        NSUInteger orientation = UIInterfaceOrientationMaskPortrait; // must support portrait
-        NSUInteger supported = [captureCommand.viewController supportedInterfaceOrientations];
-
-        orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
-        return orientation;
-    }
-#endif
-
-- (void)viewDidUnload
-{
-    [self setView:nil];
-    [self.captureCommand setInUse:NO];
-}
-
-- (void)processButton:(id)sender
-{
-    if (self.avRecorder.recording) {
-        // stop recording
-        [self.avRecorder stop];
-        self.isTimed = NO;  // recording was stopped via button so reset isTimed
-        // view cleanup will occur in audioRecordingDidFinishRecording
-    } else {
-        // begin recording
-        [self.recordButton setImage:stopRecordImage forState:UIControlStateNormal];
-        self.recordButton.accessibilityTraits &= ~[self accessibilityTraits];
-        [self.recordingView setHidden:NO];
-        NSError* error = nil;
-        [self.avSession setCategory:AVAudioSessionCategoryRecord error:&error];
-        [self.avSession setActive:YES error:&error];
-        if (error) {
-            // can't continue without active audio session
-            self.errorCode = CAPTURE_INTERNAL_ERR;
-            [self dismissAudioView:nil];
-        } else {
-            if (self.duration) {
-                self.isTimed = true;
-                [self.avRecorder recordForDuration:[duration doubleValue]];
-            } else {
-                [self.avRecorder record];
-            }
-            [self.timerLabel setText:@"0.00"];
-            self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
-            self.doneButton.enabled = NO;
-        }
-        UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
-    }
-}
-
-/*
- * helper method to clean up when stop recording
- */
-- (void)stopRecordingCleanup
-{
-    if (self.avRecorder.recording) {
-        [self.avRecorder stop];
-    }
-    [self.recordButton setImage:recordImage forState:UIControlStateNormal];
-    self.recordButton.accessibilityTraits |= [self accessibilityTraits];
-    [self.recordingView setHidden:YES];
-    self.doneButton.enabled = YES;
-    if (self.avSession) {
-        // deactivate session so sounds can come through
-        [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
-        [self.avSession setActive:NO error:nil];
-    }
-    if (self.duration && self.isTimed) {
-        // VoiceOver announcement so user knows timed recording has finished
-        BOOL isUIAccessibilityAnnouncementNotification = (&UIAccessibilityAnnouncementNotification != NULL);
-        if (isUIAccessibilityAnnouncementNotification) {
-            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 500ull * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
-                    UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, NSLocalizedString(@"timed recording complete", nil));
-                });
-        }
-    } else {
-        // issue a layout notification change so that VO will reannounce the button label when recording completes
-        UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
-    }
-}
-
-- (void)dismissAudioView:(id)sender
-{
-    // called when done button pressed or when error condition to do cleanup and remove view
-    if ([self.captureCommand.viewController.modalViewController respondsToSelector:@selector(presentingViewController)]) {
-        [[self.captureCommand.viewController.modalViewController presentingViewController] dismissModalViewControllerAnimated:YES];
-    } else {
-        [[self.captureCommand.viewController.modalViewController parentViewController] dismissModalViewControllerAnimated:YES];
-    }
-
-    if (!self.pluginResult) {
-        // return error
-        self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:self.errorCode];
-    }
-
-    self.avRecorder = nil;
-    [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
-    [self.avSession setActive:NO error:nil];
-    [self.captureCommand setInUse:NO];
-    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
-    // return result
-    [self.captureCommand.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
-}
-
-- (void)updateTime
-{
-    // update the label with the elapsed time
-    [self.timerLabel setText:[self formatTime:self.avRecorder.currentTime]];
-}
-
-- (NSString*)formatTime:(int)interval
-{
-    // is this format universal?
-    int secs = interval % 60;
-    int min = interval / 60;
-
-    if (interval < 60) {
-        return [NSString stringWithFormat:@"0:%02d", interval];
-    } else {
-        return [NSString stringWithFormat:@"%d:%02d", min, secs];
-    }
-}
-
-- (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag
-{
-    // may be called when timed audio finishes - need to stop time and reset buttons
-    [self.timer invalidate];
-    [self stopRecordingCleanup];
-
-    // generate success result
-    if (flag) {
-        NSString* filePath = [avRecorder.url path];
-        // NSLog(@"filePath: %@", filePath);
-        NSDictionary* fileDict = [captureCommand getMediaDictionaryFromPath:filePath ofType:@"audio/wav"];
-        NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
-        self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
-    } else {
-        self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
-    }
-}
-
-- (void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder*)recorder error:(NSError*)error
-{
-    [self.timer invalidate];
-    [self stopRecordingCleanup];
-
-    NSLog(@"error recording audio");
-    self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
-    [self dismissAudioView:nil];
-}
-
-@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVDevice.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.h b/CordovaLib/Classes/CDVDevice.h
deleted file mode 100644
index fd6ea12..0000000
--- a/CordovaLib/Classes/CDVDevice.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <UIKit/UIKit.h>
-#import "CDVPlugin.h"
-
-@interface CDVDevice : CDVPlugin
-{}
-
-+ (NSString*)cordovaVersion;
-
-- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
-
-@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.m b/CordovaLib/Classes/CDVDevice.m
deleted file mode 100644
index a331b81..0000000
--- a/CordovaLib/Classes/CDVDevice.m
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#import "CDV.h"
-
-@implementation UIDevice (ModelVersion)
-
-- (NSString*)modelVersion
-{
-    size_t size;
-
-    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
-    char* machine = malloc(size);
-    sysctlbyname("hw.machine", machine, &size, NULL, 0);
-    NSString* platform = [NSString stringWithUTF8String:machine];
-    free(machine);
-
-    return platform;
-}
-
-@end
-
-@interface CDVDevice () {}
-@end
-
-@implementation CDVDevice
-
-- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command
-{
-    NSDictionary* deviceProperties = [self deviceProperties];
-    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties];
-
-    /* Settings.plist
-     * Read the optional Settings.plist file and push these user-defined settings down into the web application.
-     * This can be useful for supplying build-time configuration variables down to the app to change its behavior,
-     * such as specifying Full / Lite version, or localization (English vs German, for instance).
-     */
-    // TODO: turn this into an iOS only plugin
-    NSDictionary* temp = [CDVViewController getBundlePlist:@"Settings"];
-
-    if ([temp respondsToSelector:@selector(JSONString)]) {
-        NSLog(@"Deprecation warning: window.Setting will be removed Aug 2013. Refer to https://issues.apache.org/jira/browse/CB-2433");
-        NSString* js = [NSString stringWithFormat:@"window.Settings = %@;", [temp JSONString]];
-        [self.commandDelegate evalJs:js];
-    }
-
-    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (NSDictionary*)deviceProperties
-{
-    UIDevice* device = [UIDevice currentDevice];
-    NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4];
-
-    [devProps setObject:[device modelVersion] forKey:@"model"];
-    [devProps setObject:@"iOS" forKey:@"platform"];
-    [devProps setObject:[device systemVersion] forKey:@"version"];
-    [devProps setObject:[device uniqueAppInstanceIdentifier] forKey:@"uuid"];
-    [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
-
-    NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
-    return devReturn;
-}
-
-+ (NSString*)cordovaVersion
-{
-    return CDV_VERSION;
-}
-
-@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVFile.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.h b/CordovaLib/Classes/CDVFile.h
deleted file mode 100644
index eaf8cbe..0000000
--- a/CordovaLib/Classes/CDVFile.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-enum CDVFileError {
-    NO_ERROR = 0,
-    NOT_FOUND_ERR = 1,
-    SECURITY_ERR = 2,
-    ABORT_ERR = 3,
-    NOT_READABLE_ERR = 4,
-    ENCODING_ERR = 5,
-    NO_MODIFICATION_ALLOWED_ERR = 6,
-    INVALID_STATE_ERR = 7,
-    SYNTAX_ERR = 8,
-    INVALID_MODIFICATION_ERR = 9,
-    QUOTA_EXCEEDED_ERR = 10,
-    TYPE_MISMATCH_ERR = 11,
-    PATH_EXISTS_ERR = 12
-};
-typedef int CDVFileError;
-
-enum CDVFileSystemType {
-    TEMPORARY = 0,
-    PERSISTENT = 1
-};
-typedef int CDVFileSystemType;
-
-extern NSString* const kCDVAssetsLibraryPrefix;
-
-@interface CDVFile : CDVPlugin {
-    NSString* appDocsPath;
-    NSString* appLibraryPath;
-    NSString* appTempPath;
-    NSString* persistentPath;
-    NSString* temporaryPath;
-
-    BOOL userHasAllowed;
-}
-- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath;
-- (NSString*)getAppPath:(NSString*)pathFragment;
-// -(NSString*) getFullPath: (NSString*)pathFragment;
-- (void)requestFileSystem:(CDVInvokedUrlCommand*)command;
-- (NSDictionary*)getDirectoryEntry:(NSString*)fullPath isDirectory:(BOOL)isDir;
-- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command;
-- (void)getDirectory:(CDVInvokedUrlCommand*)command;
-- (void)getFile:(CDVInvokedUrlCommand*)command;
-- (void)getParent:(CDVInvokedUrlCommand*)command;
-- (void)getMetadata:(CDVInvokedUrlCommand*)command;
-- (void)removeRecursively:(CDVInvokedUrlCommand*)command;
-- (void)remove:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)doRemove:(NSString*)fullPath;
-- (void)copyTo:(CDVInvokedUrlCommand*)command;
-- (void)moveTo:(CDVInvokedUrlCommand*)command;
-- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest;
-- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy;
-// - (void) toURI:(CDVInvokedUrlCommand*)command;
-- (void)getFileMetadata:(CDVInvokedUrlCommand*)command;
-- (void)readEntries:(CDVInvokedUrlCommand*)command;
-
-- (void)readAsText:(CDVInvokedUrlCommand*)command;
-- (void)readAsDataURL:(CDVInvokedUrlCommand*)command;
-- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command;
-- (NSString*)getMimeTypeFromPath:(NSString*)fullPath;
-- (void)write:(CDVInvokedUrlCommand*)command;
-- (void)testFileExists:(CDVInvokedUrlCommand*)command;
-- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command;
-// - (void) createDirectory:(CDVInvokedUrlCommand*)command;
-// - (void) deleteDirectory:(CDVInvokedUrlCommand*)command;
-// - (void) deleteFile:(CDVInvokedUrlCommand*)command;
-- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command;
-- (void)truncate:(CDVInvokedUrlCommand*)command;
-
-// - (BOOL) fileExists:(NSString*)fileName;
-// - (BOOL) directoryExists:(NSString*)dirName;
-- (void)writeToFile:(NSString*)fileName withData:(NSString*)data append:(BOOL)shouldAppend callback:(NSString*)callbackId;
-- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos;
-
-@property (nonatomic, strong) NSString* appDocsPath;
-@property (nonatomic, strong) NSString* appLibraryPath;
-@property (nonatomic, strong) NSString* appTempPath;
-@property (nonatomic, strong) NSString* persistentPath;
-@property (nonatomic, strong) NSString* temporaryPath;
-@property BOOL userHasAllowed;
-
-@end
-
-#define kW3FileTemporary @"temporary"
-#define kW3FilePersistent @"persistent"


[2/3] removed device, file, filetransfer, capture

Posted by st...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVFile.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFile.m b/CordovaLib/Classes/CDVFile.m
deleted file mode 100644
index 10908ce..0000000
--- a/CordovaLib/Classes/CDVFile.m
+++ /dev/null
@@ -1,1414 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import "CDVFile.h"
-#import "NSArray+Comparisons.h"
-#import "NSDictionary+Extensions.h"
-#import "CDVJSON.h"
-#import "NSData+Base64.h"
-#import <AssetsLibrary/ALAsset.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <AssetsLibrary/ALAssetsLibrary.h>
-#import <MobileCoreServices/MobileCoreServices.h>
-#import "CDVAvailability.h"
-#import "sys/xattr.h"
-
-extern NSString * const NSURLIsExcludedFromBackupKey __attribute__((weak_import));
-
-#ifndef __IPHONE_5_1
-    NSString* const NSURLIsExcludedFromBackupKey = @"NSURLIsExcludedFromBackupKey";
-#endif
-
-NSString* const kCDVAssetsLibraryPrefix = @"assets-library://";
-
-@implementation CDVFile
-
-@synthesize appDocsPath, appLibraryPath, appTempPath, persistentPath, temporaryPath, userHasAllowed;
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
-    self = (CDVFile*)[super initWithWebView:theWebView];
-    if (self) {
-        // get the documents directory path
-        NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-        self.appDocsPath = [paths objectAtIndex:0];
-
-        paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
-        self.appLibraryPath = [paths objectAtIndex:0];
-
-        self.appTempPath = [NSTemporaryDirectory()stringByStandardizingPath];   // remove trailing slash from NSTemporaryDirectory()
-
-        self.persistentPath = [NSString stringWithFormat:@"/%@", [self.appDocsPath lastPathComponent]];
-        self.temporaryPath = [NSString stringWithFormat:@"/%@", [self.appTempPath lastPathComponent]];
-        // NSLog(@"docs: %@ - temp: %@", self.appDocsPath, self.appTempPath);
-    }
-
-    return self;
-}
-
-- (NSNumber*)checkFreeDiskSpace:(NSString*)appPath
-{
-    NSFileManager* fMgr = [[NSFileManager alloc] init];
-
-    NSError* __autoreleasing pError = nil;
-
-    NSDictionary* pDict = [fMgr attributesOfFileSystemForPath:appPath error:&pError];
-    NSNumber* pNumAvail = (NSNumber*)[pDict objectForKey:NSFileSystemFreeSize];
-
-    return pNumAvail;
-}
-
-// figure out if the pathFragment represents a persistent of temporary directory and return the full application path.
-// returns nil if path is not persistent or temporary
-- (NSString*)getAppPath:(NSString*)pathFragment
-{
-    NSString* appPath = nil;
-    NSRange rangeP = [pathFragment rangeOfString:self.persistentPath];
-    NSRange rangeT = [pathFragment rangeOfString:self.temporaryPath];
-
-    if ((rangeP.location != NSNotFound) && (rangeT.location != NSNotFound)) {
-        // we found both in the path, return whichever one is first
-        if (rangeP.length < rangeT.length) {
-            appPath = self.appDocsPath;
-        } else {
-            appPath = self.appTempPath;
-        }
-    } else if (rangeP.location != NSNotFound) {
-        appPath = self.appDocsPath;
-    } else if (rangeT.location != NSNotFound) {
-        appPath = self.appTempPath;
-    }
-    return appPath;
-}
-
-/* get the full path to this resource
- * IN
- *	NSString* pathFragment - full Path from File or Entry object (includes system path info)
- * OUT
- *	NSString* fullPath - full iOS path to this resource,  nil if not found
- */
-
-/*  Was here in order to NOT have to return full path, but W3C synchronous DirectoryEntry.toURI() killed that idea since I can't call into iOS to
- * resolve full URI.  Leaving this code here in case W3C spec changes.
--(NSString*) getFullPath: (NSString*)pathFragment
-{
-    return pathFragment;
-    NSString* fullPath = nil;
-    NSString *appPath = [ self getAppPath: pathFragment];
-    if (appPath){
-
-        // remove last component from appPath
-        NSRange range = [appPath rangeOfString:@"/" options: NSBackwardsSearch];
-        NSString* newPath = [appPath substringToIndex:range.location];
-        // add pathFragment to get test Path
-        fullPath = [newPath stringByAppendingPathComponent:pathFragment];
-    }
-    return fullPath;
-} */
-
-/* Request the File System info
- *
- * IN:
- * arguments[0] - type (number as string)
- *	TEMPORARY = 0, PERSISTENT = 1;
- * arguments[1] - size
- *
- * OUT:
- *	Dictionary representing FileSystem object
- *		name - the human readable directory name
- *		root = DirectoryEntry object
- *			bool isDirectory
- *			bool isFile
- *			string name
- *			string fullPath
- *			fileSystem = FileSystem object - !! ignored because creates circular reference !!
- */
-
-- (void)requestFileSystem:(CDVInvokedUrlCommand*)command
-{
-    NSArray* arguments = command.arguments;
-
-    // arguments
-    NSString* strType = [arguments objectAtIndex:0];
-    unsigned long long size = [[arguments objectAtIndex:1] longLongValue];
-
-    int type = [strType intValue];
-    CDVPluginResult* result = nil;
-
-    if (type > 1) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:NOT_FOUND_ERR];
-        NSLog(@"iOS only supports TEMPORARY and PERSISTENT file systems");
-    } else {
-        // NSString* fullPath = [NSString stringWithFormat:@"/%@", (type == 0 ? [self.appTempPath lastPathComponent] : [self.appDocsPath lastPathComponent])];
-        NSString* fullPath = (type == 0 ? self.appTempPath  : self.appDocsPath);
-        // check for avail space for size request
-        NSNumber* pNumAvail = [self checkFreeDiskSpace:fullPath];
-        // NSLog(@"Free space: %@", [NSString stringWithFormat:@"%qu", [ pNumAvail unsignedLongLongValue ]]);
-        if (pNumAvail && ([pNumAvail unsignedLongLongValue] < size)) {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:QUOTA_EXCEEDED_ERR];
-        } else {
-            NSMutableDictionary* fileSystem = [NSMutableDictionary dictionaryWithCapacity:2];
-            [fileSystem setObject:(type == TEMPORARY ? kW3FileTemporary : kW3FilePersistent) forKey:@"name"];
-            NSDictionary* dirEntry = [self getDirectoryEntry:fullPath isDirectory:YES];
-            [fileSystem setObject:dirEntry forKey:@"root"];
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
-        }
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* Creates a dictionary representing an Entry Object
- *
- * IN:
- * NSString* fullPath of the entry
- * FileSystem type
- * BOOL isDirectory - YES if this is a directory, NO if is a file
- * OUT:
- * NSDictionary*
- Entry object
- *		bool as NSNumber isDirectory
- *		bool as NSNumber isFile
- *		NSString*  name - last part of path
- *		NSString* fullPath
- *		fileSystem = FileSystem object - !! ignored because creates circular reference FileSystem contains DirectoryEntry which contains FileSystem.....!!
- */
-- (NSDictionary*)getDirectoryEntry:(NSString*)fullPath isDirectory:(BOOL)isDir
-{
-    NSMutableDictionary* dirEntry = [NSMutableDictionary dictionaryWithCapacity:4];
-    NSString* lastPart = [fullPath lastPathComponent];
-
-    [dirEntry setObject:[NSNumber numberWithBool:!isDir]  forKey:@"isFile"];
-    [dirEntry setObject:[NSNumber numberWithBool:isDir]  forKey:@"isDirectory"];
-    // NSURL* fileUrl = [NSURL fileURLWithPath:fullPath];
-    // [dirEntry setObject: [fileUrl absoluteString] forKey: @"fullPath"];
-    [dirEntry setObject:fullPath forKey:@"fullPath"];
-    [dirEntry setObject:lastPart forKey:@"name"];
-
-    return dirEntry;
-}
-
-/*
- * Given a URI determine the File System information associated with it and return an appropriate W3C entry object
- * IN
- *	NSString* fileURI  - currently requires full file URI
- * OUT
- *	Entry object
- *		bool isDirectory
- *		bool isFile
- *		string name
- *		string fullPath
- *		fileSystem = FileSystem object - !! ignored because creates circular reference FileSystem contains DirectoryEntry which contains FileSystem.....!!
- */
-- (void)resolveLocalFileSystemURI:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* inputUri = [command.arguments objectAtIndex:0];
-
-    // don't know if string is encoded or not so unescape
-    NSString* cleanUri = [inputUri stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-    // now escape in order to create URL
-    NSString* strUri = [cleanUri stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-    NSURL* testUri = [NSURL URLWithString:strUri];
-    CDVPluginResult* result = nil;
-
-    if (!testUri) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
-    } else if ([testUri isFileURL]) {
-        NSFileManager* fileMgr = [[NSFileManager alloc] init];
-        NSString* path = [testUri path];
-        // NSLog(@"url path: %@", path);
-        BOOL isDir = NO;
-        // see if exists and is file or dir
-        BOOL bExists = [fileMgr fileExistsAtPath:path isDirectory:&isDir];
-        if (bExists) {
-            // see if it contains docs path
-            NSRange range = [path rangeOfString:self.appDocsPath];
-            NSString* foundFullPath = nil;
-            // there's probably an api or easier way to figure out the path type but I can't find it!
-            if ((range.location != NSNotFound) && (range.length == [self.appDocsPath length])) {
-                foundFullPath = self.appDocsPath;
-            } else {
-                // see if it contains the temp path
-                range = [path rangeOfString:self.appTempPath];
-                if ((range.location != NSNotFound) && (range.length == [self.appTempPath length])) {
-                    foundFullPath = self.appTempPath;
-                }
-            }
-            if (foundFullPath == nil) {
-                // error SECURITY_ERR - not one of the two paths types supported
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SECURITY_ERR];
-            } else {
-                NSDictionary* fileSystem = [self getDirectoryEntry:path isDirectory:isDir];
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
-            }
-        } else {
-            // return NOT_FOUND_ERR
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-        }
-    } else if ([strUri hasPrefix:@"assets-library://"]) {
-        NSDictionary* fileSystem = [self getDirectoryEntry:strUri isDirectory:NO];
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileSystem];
-    } else {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:ENCODING_ERR];
-    }
-
-    if (result != nil) {
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-    }
-}
-
-/* Part of DirectoryEntry interface,  creates or returns the specified directory
- * IN:
- *	NSString* fullPath - full path for this directory
- *	NSString* path - directory to be created/returned; may be full path or relative path
- *	NSDictionary* - Flags object
- *		boolean as NSNumber create -
- *			if create is true and directory does not exist, create dir and return directory entry
- *			if create is true and exclusive is true and directory does exist, return error
- *			if create is false and directory does not exist, return error
- *			if create is false and the path represents a file, return error
- *		boolean as NSNumber exclusive - used in conjunction with create
- *			if exclusive is true and create is true - specifies failure if directory already exists
- *
- *
- */
-- (void)getDirectory:(CDVInvokedUrlCommand*)command
-{
-    NSMutableArray* arguments = [NSMutableArray arrayWithArray:command.arguments];
-    NSMutableDictionary* options = nil;
-
-    if ([arguments count] >= 3) {
-        options = [arguments objectAtIndex:2 withDefault:nil];
-    }
-    // add getDir to options and call getFile()
-    if (options != nil) {
-        options = [NSMutableDictionary dictionaryWithDictionary:options];
-    } else {
-        options = [NSMutableDictionary dictionaryWithCapacity:1];
-    }
-    [options setObject:[NSNumber numberWithInt:1] forKey:@"getDir"];
-    if ([arguments count] >= 3) {
-        [arguments replaceObjectAtIndex:2 withObject:options];
-    } else {
-        [arguments addObject:options];
-    }
-    CDVInvokedUrlCommand* subCommand =
-        [[CDVInvokedUrlCommand alloc] initWithArguments:arguments
-                                             callbackId:command.callbackId
-                                              className:command.className
-                                             methodName:command.methodName];
-
-    [self getFile:subCommand];
-}
-
-/* Part of DirectoryEntry interface,  creates or returns the specified file
- * IN:
- *	NSString* fullPath - full path for this file
- *	NSString* path - file to be created/returned; may be full path or relative path
- *	NSDictionary* - Flags object
- *		boolean as NSNumber create -
- *			if create is true and file does not exist, create file and return File entry
- *			if create is true and exclusive is true and file does exist, return error
- *			if create is false and file does not exist, return error
- *			if create is false and the path represents a directory, return error
- *		boolean as NSNumber exclusive - used in conjunction with create
- *			if exclusive is true and create is true - specifies failure if file already exists
- *
- *
- */
-- (void)getFile:(CDVInvokedUrlCommand*)command
-{
-    // arguments are URL encoded
-    NSString* fullPath = [command.arguments objectAtIndex:0];
-    NSString* requestedPath = [command.arguments objectAtIndex:1];
-    NSDictionary* options = [command.arguments objectAtIndex:2 withDefault:nil];
-
-    // return unsupported result for assets-library URLs
-    if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"getFile not supported for assets-library URLs."];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    CDVPluginResult* result = nil;
-    BOOL bDirRequest = NO;
-    BOOL create = NO;
-    BOOL exclusive = NO;
-    int errorCode = 0;  // !!! risky - no error code currently defined for 0
-
-    if ([options valueForKeyIsNumber:@"create"]) {
-        create = [(NSNumber*)[options valueForKey:@"create"] boolValue];
-    }
-    if ([options valueForKeyIsNumber:@"exclusive"]) {
-        exclusive = [(NSNumber*)[options valueForKey:@"exclusive"] boolValue];
-    }
-
-    if ([options valueForKeyIsNumber:@"getDir"]) {
-        // this will not exist for calls directly to getFile but will have been set by getDirectory before calling this method
-        bDirRequest = [(NSNumber*)[options valueForKey:@"getDir"] boolValue];
-    }
-    // see if the requested path has invalid characters - should we be checking for  more than just ":"?
-    if ([requestedPath rangeOfString:@":"].location != NSNotFound) {
-        errorCode = ENCODING_ERR;
-    } else {
-        // was full or relative path provided?
-        NSRange range = [requestedPath rangeOfString:fullPath];
-        BOOL bIsFullPath = range.location != NSNotFound;
-
-        NSString* reqFullPath = nil;
-
-        if (!bIsFullPath) {
-            reqFullPath = [fullPath stringByAppendingPathComponent:requestedPath];
-        } else {
-            reqFullPath = requestedPath;
-        }
-
-        // NSLog(@"reqFullPath = %@", reqFullPath);
-        NSFileManager* fileMgr = [[NSFileManager alloc] init];
-        BOOL bIsDir;
-        BOOL bExists = [fileMgr fileExistsAtPath:reqFullPath isDirectory:&bIsDir];
-        if (bExists && (create == NO) && (bIsDir == !bDirRequest)) {
-            // path exists and is of requested type  - return TYPE_MISMATCH_ERR
-            errorCode = TYPE_MISMATCH_ERR;
-        } else if (!bExists && (create == NO)) {
-            // path does not exist and create is false - return NOT_FOUND_ERR
-            errorCode = NOT_FOUND_ERR;
-        } else if (bExists && (create == YES) && (exclusive == YES)) {
-            // file/dir already exists and exclusive and create are both true - return PATH_EXISTS_ERR
-            errorCode = PATH_EXISTS_ERR;
-        } else {
-            // if bExists and create == YES - just return data
-            // if bExists and create == NO  - just return data
-            // if !bExists and create == YES - create and return data
-            BOOL bSuccess = YES;
-            NSError __autoreleasing* pError = nil;
-            if (!bExists && (create == YES)) {
-                if (bDirRequest) {
-                    // create the dir
-                    bSuccess = [fileMgr createDirectoryAtPath:reqFullPath withIntermediateDirectories:NO attributes:nil error:&pError];
-                } else {
-                    // create the empty file
-                    bSuccess = [fileMgr createFileAtPath:reqFullPath contents:nil attributes:nil];
-                }
-            }
-            if (!bSuccess) {
-                errorCode = ABORT_ERR;
-                if (pError) {
-                    NSLog(@"error creating directory: %@", [pError localizedDescription]);
-                }
-            } else {
-                // NSLog(@"newly created file/dir (%@) exists: %d", reqFullPath, [fileMgr fileExistsAtPath:reqFullPath]);
-                // file existed or was created
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:reqFullPath isDirectory:bDirRequest]];
-            }
-        } // are all possible conditions met?
-    }
-
-    if (errorCode > 0) {
-        // create error callback
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
-    }
-
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * Look up the parent Entry containing this Entry.
- * If this Entry is the root of its filesystem, its parent is itself.
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath
- * NSMutableDictionary* options
- *	empty
- */
-- (void)getParent:(CDVInvokedUrlCommand*)command
-{
-    // arguments are URL encoded
-    NSString* fullPath = [command.arguments objectAtIndex:0];
-
-    // we don't (yet?) support getting the parent of an asset
-    if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_READABLE_ERR];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    CDVPluginResult* result = nil;
-    NSString* newPath = nil;
-
-    if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
-        // return self
-        newPath = fullPath;
-    } else {
-        // since this call is made from an existing Entry object - the parent should already exist so no additional error checking
-        // remove last component and return Entry
-        NSRange range = [fullPath rangeOfString:@"/" options:NSBackwardsSearch];
-        newPath = [fullPath substringToIndex:range.location];
-    }
-
-    if (newPath) {
-        NSFileManager* fileMgr = [[NSFileManager alloc] init];
-        BOOL bIsDir;
-        BOOL bExists = [fileMgr fileExistsAtPath:newPath isDirectory:&bIsDir];
-        if (bExists) {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:newPath isDirectory:bIsDir]];
-        }
-    }
-    if (!result) {
-        // invalid path or file does not exist
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * get MetaData of entry
- * Currently MetaData only includes modificationTime.
- */
-- (void)getMetadata:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* argPath = [command.arguments objectAtIndex:0];
-    __block CDVPluginResult* result = nil;
-
-    if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        // In this case, we need to use an asynchronous method to retrieve the file.
-        // Because of this, we can't just assign to `result` and send it at the end of the method.
-        // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
-        ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
-            if (asset) {
-                // We have the asset!  Retrieve the metadata and send it off.
-                NSDate* date = [asset valueForProperty:ALAssetPropertyDate];
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[date timeIntervalSince1970] * 1000];
-                [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-            } else {
-                // We couldn't find the asset.  Send the appropriate error.
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-                [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-            }
-        };
-        // TODO(maxw): Consider making this a class variable since it's the same every time.
-        ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
-            // Retrieving the asset failed for some reason.  Send the appropriate error.
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
-            [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        };
-
-        ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
-        [assetsLibrary assetForURL:[NSURL URLWithString:argPath] resultBlock:resultBlock failureBlock:failureBlock];
-        return;
-    }
-
-    NSString* testPath = argPath; // [self getFullPath: argPath];
-
-    NSFileManager* fileMgr = [[NSFileManager alloc] init];
-    NSError* __autoreleasing error = nil;
-
-    NSDictionary* fileAttribs = [fileMgr attributesOfItemAtPath:testPath error:&error];
-
-    if (fileAttribs) {
-        NSDate* modDate = [fileAttribs fileModificationDate];
-        if (modDate) {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:[modDate timeIntervalSince1970] * 1000];
-        }
-    } else {
-        // didn't get fileAttribs
-        CDVFileError errorCode = ABORT_ERR;
-        NSLog(@"error getting metadata: %@", [error localizedDescription]);
-        if ([error code] == NSFileNoSuchFileError) {
-            errorCode = NOT_FOUND_ERR;
-        }
-        // log [NSNumber numberWithDouble: theMessage] objCtype to see what it returns
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode];
-    }
-    if (!result) {
-        // invalid path or file does not exist
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/*
- * set MetaData of entry
- * Currently we only support "com.apple.MobileBackup" (boolean)
- */
-- (void)setMetadata:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* filePath = [command.arguments objectAtIndex:0];
-    NSDictionary* options = [command.arguments objectAtIndex:1 withDefault:nil];
-    CDVPluginResult* result = nil;
-    BOOL ok = NO;
-
-    // setMetadata doesn't make sense for asset library files
-    if (![filePath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        // we only care about this iCloud key for now.
-        // set to 1/true to skip backup, set to 0/false to back it up (effectively removing the attribute)
-        NSString* iCloudBackupExtendedAttributeKey = @"com.apple.MobileBackup";
-        id iCloudBackupExtendedAttributeValue = [options objectForKey:iCloudBackupExtendedAttributeKey];
-
-        if ((iCloudBackupExtendedAttributeValue != nil) && [iCloudBackupExtendedAttributeValue isKindOfClass:[NSNumber class]]) {
-            if (IsAtLeastiOSVersion(@"5.1")) {
-                NSURL* url = [NSURL fileURLWithPath:filePath];
-                NSError* __autoreleasing error = nil;
-
-                ok = [url setResourceValue:[NSNumber numberWithBool:[iCloudBackupExtendedAttributeValue boolValue]] forKey:NSURLIsExcludedFromBackupKey error:&error];
-            } else { // below 5.1 (deprecated - only really supported in 5.01)
-                u_int8_t value = [iCloudBackupExtendedAttributeValue intValue];
-                if (value == 0) { // remove the attribute (allow backup, the default)
-                    ok = (removexattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], 0) == 0);
-                } else { // set the attribute (skip backup)
-                    ok = (setxattr([filePath fileSystemRepresentation], [iCloudBackupExtendedAttributeKey cStringUsingEncoding:NSUTF8StringEncoding], &value, sizeof(value), 0, 0) == 0);
-                }
-            }
-        }
-    }
-
-    if (ok) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
-    } else {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* removes the directory or file entry
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath
- *
- * returns NO_MODIFICATION_ALLOWED_ERR  if is top level directory or no permission to delete dir
- * returns INVALID_MODIFICATION_ERR if is non-empty dir or asset library file
- * returns NOT_FOUND_ERR if file or dir is not found
-*/
-- (void)remove:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* fullPath = [command.arguments objectAtIndex:0];
-    CDVPluginResult* result = nil;
-    CDVFileError errorCode = 0;  // !! 0 not currently defined
-
-    // return error for assets-library URLs
-    if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        errorCode = INVALID_MODIFICATION_ERR;
-    } else if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
-        // error if try to remove top level (documents or tmp) dir
-        errorCode = NO_MODIFICATION_ALLOWED_ERR;
-    } else {
-        NSFileManager* fileMgr = [[NSFileManager alloc] init];
-        BOOL bIsDir = NO;
-        BOOL bExists = [fileMgr fileExistsAtPath:fullPath isDirectory:&bIsDir];
-        if (!bExists) {
-            errorCode = NOT_FOUND_ERR;
-        }
-        if (bIsDir && ([[fileMgr contentsOfDirectoryAtPath:fullPath error:nil] count] != 0)) {
-            // dir is not empty
-            errorCode = INVALID_MODIFICATION_ERR;
-        }
-    }
-    if (errorCode > 0) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
-    } else {
-        // perform actual remove
-        result = [self doRemove:fullPath];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* recursively removes the directory
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath
- *
- * returns NO_MODIFICATION_ALLOWED_ERR  if is top level directory or no permission to delete dir
- * returns NOT_FOUND_ERR if file or dir is not found
- */
-- (void)removeRecursively:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* fullPath = [command.arguments objectAtIndex:0];
-
-    // return unsupported result for assets-library URLs
-    if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"removeRecursively not supported for assets-library URLs."];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    CDVPluginResult* result = nil;
-
-    // error if try to remove top level (documents or tmp) dir
-    if ([fullPath isEqualToString:self.appDocsPath] || [fullPath isEqualToString:self.appTempPath]) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
-    } else {
-        result = [self doRemove:fullPath];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* remove the file or directory (recursively)
- * IN:
- * NSString* fullPath - the full path to the file or directory to be removed
- * NSString* callbackId
- * called from remove and removeRecursively - check all pubic api specific error conditions (dir not empty, etc) before calling
- */
-
-- (CDVPluginResult*)doRemove:(NSString*)fullPath
-{
-    CDVPluginResult* result = nil;
-    BOOL bSuccess = NO;
-    NSError* __autoreleasing pError = nil;
-    NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
-    @try {
-        bSuccess = [fileMgr removeItemAtPath:fullPath error:&pError];
-        if (bSuccess) {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
-        } else {
-            // see if we can give a useful error
-            CDVFileError errorCode = ABORT_ERR;
-            NSLog(@"error getting metadata: %@", [pError localizedDescription]);
-            if ([pError code] == NSFileNoSuchFileError) {
-                errorCode = NOT_FOUND_ERR;
-            } else if ([pError code] == NSFileWriteNoPermissionError) {
-                errorCode = NO_MODIFICATION_ALLOWED_ERR;
-            }
-
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
-        }
-    } @catch(NSException* e) {  // NSInvalidArgumentException if path is . or ..
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:SYNTAX_ERR];
-    }
-
-    return result;
-}
-
-- (void)copyTo:(CDVInvokedUrlCommand*)command
-{
-    [self doCopyMove:command isCopy:YES];
-}
-
-- (void)moveTo:(CDVInvokedUrlCommand*)command
-{
-    [self doCopyMove:command isCopy:NO];
-}
-
-/**
- * Helper function to check to see if the user attempted to copy an entry into its parent without changing its name,
- * or attempted to copy a directory into a directory that it contains directly or indirectly.
- *
- * IN:
- *  NSString* srcDir
- *  NSString* destinationDir
- * OUT:
- *  YES copy/ move is allows
- *  NO move is onto itself
- */
-- (BOOL)canCopyMoveSrc:(NSString*)src ToDestination:(NSString*)dest
-{
-    // This weird test is to determine if we are copying or moving a directory into itself.
-    // Copy /Documents/myDir to /Documents/myDir-backup is okay but
-    // Copy /Documents/myDir to /Documents/myDir/backup not okay
-    BOOL copyOK = YES;
-    NSRange range = [dest rangeOfString:src];
-
-    if (range.location != NSNotFound) {
-        NSRange testRange = {range.length - 1, ([dest length] - range.length)};
-        NSRange resultRange = [dest rangeOfString:@"/" options:0 range:testRange];
-        if (resultRange.location != NSNotFound) {
-            copyOK = NO;
-        }
-    }
-    return copyOK;
-}
-
-/* Copy/move a file or directory to a new location
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath of entry
- *  1 - NSString* newName the new name of the entry, defaults to the current name
- *	NSMutableDictionary* options - DirectoryEntry to which to copy the entry
- *	BOOL - bCopy YES if copy, NO if move
- *
- */
-- (void)doCopyMove:(CDVInvokedUrlCommand*)command isCopy:(BOOL)bCopy
-{
-    NSArray* arguments = command.arguments;
-
-    // arguments
-    NSString* srcFullPath = [arguments objectAtIndex:0];
-    NSString* destRootPath = [arguments objectAtIndex:1];
-    // optional argument
-    NSString* newName = ([arguments count] > 2) ? [arguments objectAtIndex:2] : [srcFullPath lastPathComponent];          // use last component from appPath if new name not provided
-
-    __block CDVPluginResult* result = nil;
-    CDVFileError errCode = 0;  // !! Currently 0 is not defined, use this to signal error !!
-
-    /*NSString* destRootPath = nil;
-    NSString* key = @"fullPath";
-    if([options valueForKeyIsString:key]){
-       destRootPath = [options objectForKey:@"fullPath"];
-    }*/
-
-    if (!destRootPath) {
-        // no destination provided
-        errCode = NOT_FOUND_ERR;
-    } else if ([newName rangeOfString:@":"].location != NSNotFound) {
-        // invalid chars in new name
-        errCode = ENCODING_ERR;
-    } else {
-        NSString* newFullPath = [destRootPath stringByAppendingPathComponent:newName];
-        NSFileManager* fileMgr = [[NSFileManager alloc] init];
-        if ([newFullPath isEqualToString:srcFullPath]) {
-            // source and destination can not be the same
-            errCode = INVALID_MODIFICATION_ERR;
-        } else if ([srcFullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-            if (bCopy) {
-                // Copying (as opposed to moving) an assets library file is okay.
-                // In this case, we need to use an asynchronous method to retrieve the file.
-                // Because of this, we can't just assign to `result` and send it at the end of the method.
-                // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
-                ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
-                    if (asset) {
-                        // We have the asset!  Get the data and try to copy it over.
-                        if (![fileMgr fileExistsAtPath:destRootPath]) {
-                            // The destination directory doesn't exist.
-                            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-                            [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-                            return;
-                        } else if ([fileMgr fileExistsAtPath:newFullPath]) {
-                            // A file already exists at the destination path.
-                            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:PATH_EXISTS_ERR];
-                            [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-                            return;
-                        }
-
-                        // We're good to go!  Write the file to the new destination.
-                        ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
-                        Byte* buffer = (Byte*)malloc([assetRepresentation size]);
-                        NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];
-                        NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
-                        [data writeToFile:newFullPath atomically:YES];
-                        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getDirectoryEntry:newFullPath isDirectory:NO]];
-                        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-                    } else {
-                        // We couldn't find the asset.  Send the appropriate error.
-                        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-                        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-                    }
-                };
-                ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
-                    // Retrieving the asset failed for some reason.  Send the appropriate error.
-                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
-                    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-                };
-
-                ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
-                [assetsLibrary assetForURL:[NSURL URLWithString:srcFullPath] resultBlock:resultBlock failureBlock:failureBlock];
-                return;
-            } else {
-                // Moving an assets library file is not doable, since we can't remove it.
-                errCode = INVALID_MODIFICATION_ERR;
-            }
-        } else {
-            BOOL bSrcIsDir = NO;
-            BOOL bDestIsDir = NO;
-            BOOL bNewIsDir = NO;
-            BOOL bSrcExists = [fileMgr fileExistsAtPath:srcFullPath isDirectory:&bSrcIsDir];
-            BOOL bDestExists = [fileMgr fileExistsAtPath:destRootPath isDirectory:&bDestIsDir];
-            BOOL bNewExists = [fileMgr fileExistsAtPath:newFullPath isDirectory:&bNewIsDir];
-            if (!bSrcExists || !bDestExists) {
-                // the source or the destination root does not exist
-                errCode = NOT_FOUND_ERR;
-            } else if (bSrcIsDir && (bNewExists && !bNewIsDir)) {
-                // can't copy/move dir to file
-                errCode = INVALID_MODIFICATION_ERR;
-            } else { // no errors yet
-                NSError* __autoreleasing error = nil;
-                BOOL bSuccess = NO;
-                if (bCopy) {
-                    if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFullPath] /*[newFullPath hasPrefix:srcFullPath]*/) {
-                        // can't copy dir into self
-                        errCode = INVALID_MODIFICATION_ERR;
-                    } else if (bNewExists) {
-                        // the full destination should NOT already exist if a copy
-                        errCode = PATH_EXISTS_ERR;
-                    } else {
-                        bSuccess = [fileMgr copyItemAtPath:srcFullPath toPath:newFullPath error:&error];
-                    }
-                } else { // move
-                    // iOS requires that destination must not exist before calling moveTo
-                    // is W3C INVALID_MODIFICATION_ERR error if destination dir exists and has contents
-                    //
-                    if (!bSrcIsDir && (bNewExists && bNewIsDir)) {
-                        // can't move a file to directory
-                        errCode = INVALID_MODIFICATION_ERR;
-                    } else if (bSrcIsDir && ![self canCopyMoveSrc:srcFullPath ToDestination:newFullPath]) {    // [newFullPath hasPrefix:srcFullPath]){
-                        // can't move a dir into itself
-                        errCode = INVALID_MODIFICATION_ERR;
-                    } else if (bNewExists) {
-                        if (bNewIsDir && ([[fileMgr contentsOfDirectoryAtPath:newFullPath error:NULL] count] != 0)) {
-                            // can't move dir to a dir that is not empty
-                            errCode = INVALID_MODIFICATION_ERR;
-                            newFullPath = nil;  // so we won't try to move
-                        } else {
-                            // remove destination so can perform the moveItemAtPath
-                            bSuccess = [fileMgr removeItemAtPath:newFullPath error:NULL];
-                            if (!bSuccess) {
-                                errCode = INVALID_MODIFICATION_ERR; // is this the correct error?
-                                newFullPath = nil;
-                            }
-                        }
-                    } else if (bNewIsDir && [newFullPath hasPrefix:srcFullPath]) {
-                        // can't move a directory inside itself or to any child at any depth;
-                        errCode = INVALID_MODIFICATION_ERR;
-                        newFullPath = nil;
-                    }
-
-                    if (newFullPath != nil) {
-                        bSuccess = [fileMgr moveItemAtPath:srcFullPath toPath:newFullPath error:&error];
-                    }
-                }
-                if (bSuccess) {
-                    // should verify it is there and of the correct type???
-                    NSDictionary* newEntry = [self getDirectoryEntry:newFullPath isDirectory:bSrcIsDir];  // should be the same type as source
-                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newEntry];
-                } else {
-                    errCode = INVALID_MODIFICATION_ERR; // catch all
-                    if (error) {
-                        if (([error code] == NSFileReadUnknownError) || ([error code] == NSFileReadTooLargeError)) {
-                            errCode = NOT_READABLE_ERR;
-                        } else if ([error code] == NSFileWriteOutOfSpaceError) {
-                            errCode = QUOTA_EXCEEDED_ERR;
-                        } else if ([error code] == NSFileWriteNoPermissionError) {
-                            errCode = NO_MODIFICATION_ALLOWED_ERR;
-                        }
-                    }
-                }
-            }
-        }
-    }
-    if (errCode > 0) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errCode];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-/* return the URI to the entry
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath of entry
- *	1 - desired mime type of entry - ignored - always returns file://
- */
-
-/*  Not needed since W3C toURI is synchronous.  Leaving code here for now in case W3C spec changes.....
-- (void) toURI:(CDVInvokedUrlCommand*)command
-{
-    NSString* callbackId = command.callbackId;
-    NSString* argPath = [command.arguments objectAtIndex:0];
-    PluginResult* result = nil;
-    NSString* jsString = nil;
-
-    NSString* fullPath = [self getFullPath: argPath];
-    if (fullPath) {
-        // do we need to make sure the file actually exists?
-        // create file uri
-        NSString* strUri = [fullPath stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
-        NSURL* fileUrl = [NSURL fileURLWithPath:strUri];
-        if (fileUrl) {
-            result = [PluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: [fileUrl absoluteString]];
-            jsString = [result toSuccessCallbackString:callbackId];
-        } // else NOT_FOUND_ERR
-    }
-    if(!jsString) {
-        // was error
-        result = [PluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt: NOT_FOUND_ERR cast:  @"window.localFileSystem._castError"];
-        jsString = [result toErrorCallbackString:callbackId];
-    }
-
-    [self writeJavascript:jsString];
-}*/
-- (void)getFileMetadata:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* argPath = [command.arguments objectAtIndex:0];
-
-    __block CDVPluginResult* result = nil;
-
-    NSString* fullPath = argPath; // [self getFullPath: argPath];
-
-    if (fullPath) {
-        if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-            // In this case, we need to use an asynchronous method to retrieve the file.
-            // Because of this, we can't just assign to `result` and send it at the end of the method.
-            // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
-            ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
-                if (asset) {
-                    // We have the asset!  Populate the dictionary and send it off.
-                    NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
-                    ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
-                    [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:[assetRepresentation size]] forKey:@"size"];
-                    [fileInfo setObject:argPath forKey:@"fullPath"];
-                    NSString* filename = [assetRepresentation filename];
-                    [fileInfo setObject:filename forKey:@"name"];
-                    [fileInfo setObject:[self getMimeTypeFromPath:filename] forKey:@"type"];
-                    NSDate* creationDate = [asset valueForProperty:ALAssetPropertyDate];
-                    NSNumber* msDate = [NSNumber numberWithDouble:[creationDate timeIntervalSince1970] * 1000];
-                    [fileInfo setObject:msDate forKey:@"lastModifiedDate"];
-
-                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo];
-                    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-                } else {
-                    // We couldn't find the asset.  Send the appropriate error.
-                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-                    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-                }
-            };
-            ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
-                // Retrieving the asset failed for some reason.  Send the appropriate error.
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
-                [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-            };
-
-            ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
-            [assetsLibrary assetForURL:[NSURL URLWithString:argPath] resultBlock:resultBlock failureBlock:failureBlock];
-            return;
-        } else {
-            NSFileManager* fileMgr = [[NSFileManager alloc] init];
-            BOOL bIsDir = NO;
-            // make sure it exists and is not a directory
-            BOOL bExists = [fileMgr fileExistsAtPath:fullPath isDirectory:&bIsDir];
-            if (!bExists || bIsDir) {
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-            } else {
-                // create dictionary of file info
-                NSError* __autoreleasing error = nil;
-                NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:&error];
-                NSMutableDictionary* fileInfo = [NSMutableDictionary dictionaryWithCapacity:5];
-                [fileInfo setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
-                [fileInfo setObject:argPath forKey:@"fullPath"];
-                [fileInfo setObject:@"" forKey:@"type"];  // can't easily get the mimetype unless create URL, send request and read response so skipping
-                [fileInfo setObject:[argPath lastPathComponent] forKey:@"name"];
-                NSDate* modDate = [fileAttrs fileModificationDate];
-                NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000];
-                [fileInfo setObject:msDate forKey:@"lastModifiedDate"];
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:fileInfo];
-            }
-        }
-    }
-    if (!result) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_INSTANTIATION_EXCEPTION];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)readEntries:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* fullPath = [command.arguments objectAtIndex:0];
-
-    // return unsupported result for assets-library URLs
-    if ([fullPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_MALFORMED_URL_EXCEPTION messageAsString:@"readEntries not supported for assets-library URLs."];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    CDVPluginResult* result = nil;
-
-    NSFileManager* fileMgr = [[NSFileManager alloc] init];
-    NSError* __autoreleasing error = nil;
-    NSArray* contents = [fileMgr contentsOfDirectoryAtPath:fullPath error:&error];
-
-    if (contents) {
-        NSMutableArray* entries = [NSMutableArray arrayWithCapacity:1];
-        if ([contents count] > 0) {
-            // create an Entry (as JSON) for each file/dir
-            for (NSString* name in contents) {
-                // see if is dir or file
-                NSString* entryPath = [fullPath stringByAppendingPathComponent:name];
-                BOOL bIsDir = NO;
-                [fileMgr fileExistsAtPath:entryPath isDirectory:&bIsDir];
-                NSDictionary* entryDict = [self getDirectoryEntry:entryPath isDirectory:bIsDir];
-                [entries addObject:entryDict];
-            }
-        }
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:entries];
-    } else {
-        // assume not found but could check error for more specific error conditions
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NOT_FOUND_ERR];
-    }
-
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)readFileWithPath:(NSString*)path start:(NSInteger)start end:(NSInteger)end callback:(void (^)(NSData*, NSString* mimeType, CDVFileError))callback
-{
-    if (path == nil) {
-        callback(nil, nil, SYNTAX_ERR);
-    } else {
-        [self.commandDelegate runInBackground:^ {
-            if ([path hasPrefix:kCDVAssetsLibraryPrefix]) {
-                // In this case, we need to use an asynchronous method to retrieve the file.
-                // Because of this, we can't just assign to `result` and send it at the end of the method.
-                // Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
-                ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
-                    if (asset) {
-                        // We have the asset!  Get the data and send it off.
-                        ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
-                        Byte* buffer = (Byte*)malloc([assetRepresentation size]);
-                        NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];
-                        NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
-                        NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
-
-                        callback(data, MIMEType, NO_ERROR);
-                    } else {
-                        callback(nil, nil, NOT_FOUND_ERR);
-                    }
-                };
-                ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
-                    // Retrieving the asset failed for some reason.  Send the appropriate error.
-                    NSLog(@"Error: %@", error);
-                    callback(nil, nil, SECURITY_ERR);
-                };
-
-                ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
-                [assetsLibrary assetForURL:[NSURL URLWithString:path] resultBlock:resultBlock failureBlock:failureBlock];
-            } else {
-                NSString* mimeType = [self getMimeTypeFromPath:path];
-                if (mimeType == nil) {
-                    mimeType = @"*/*";
-                }
-                NSFileHandle* file = [NSFileHandle fileHandleForReadingAtPath:path];
-                if (start > 0) {
-                    [file seekToFileOffset:start];
-                }
-
-                NSData* readData;
-                if (end < 0) {
-                    readData = [file readDataToEndOfFile];
-                } else {
-                    readData = [file readDataOfLength:(end - start)];
-                }
-
-                [file closeFile];
-
-                callback(readData, mimeType, readData != nil ? NO_ERROR : NOT_FOUND_ERR);
-            }
-        }];
-    }
-}
-
-/* read and return file data
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath
- *	1 - NSString* encoding
- *	2 - NSString* start
- *	3 - NSString* end
- */
-- (void)readAsText:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* path = [command argumentAtIndex:0];
-    NSString* encoding = [command argumentAtIndex:1];
-    NSInteger start = [[command argumentAtIndex:2] integerValue];
-    NSInteger end = [[command argumentAtIndex:3] integerValue];
-
-    // TODO: implement
-    if (![@"UTF-8" isEqualToString : encoding]) {
-        NSLog(@"Only UTF-8 encodings are currently supported by readAsText");
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:ENCODING_ERR];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
-        CDVPluginResult* result = nil;
-        if (data != nil) {
-            NSString* str = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSUTF8StringEncoding freeWhenDone:NO];
-            // Check that UTF8 conversion did not fail.
-            if (str != nil) {
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:str];
-                result.associatedObject = data;
-            } else {
-                errorCode = ENCODING_ERR;
-            }
-        }
-        if (result == nil) {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
-        }
-
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-    }];
-}
-
-/* Read content of text file and return as base64 encoded data url.
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath
- *	1 - NSString* start
- *	2 - NSString* end
- *
- * Determines the mime type from the file extension, returns ENCODING_ERR if mimetype can not be determined.
- */
-
-- (void)readAsDataURL:(CDVInvokedUrlCommand*)command
-{
-    NSString* path = [command argumentAtIndex:0];
-    NSInteger start = [[command argumentAtIndex:1] integerValue];
-    NSInteger end = [[command argumentAtIndex:2] integerValue];
-
-    [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
-        CDVPluginResult* result = nil;
-        if (data != nil) {
-            // TODO: Would be faster to base64 encode directly to the final string.
-            NSString* output = [NSString stringWithFormat:@"data:%@;base64,%@", mimeType, [data base64EncodedString]];
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:output];
-        } else {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
-        }
-
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-    }];
-}
-
-/* Read content of text file and return as an arraybuffer
- * IN:
- * NSArray* arguments
- *	0 - NSString* fullPath
- *	1 - NSString* start
- *	2 - NSString* end
- */
-
-- (void)readAsArrayBuffer:(CDVInvokedUrlCommand*)command
-{
-    NSString* path = [command argumentAtIndex:0];
-    NSInteger start = [[command argumentAtIndex:1] integerValue];
-    NSInteger end = [[command argumentAtIndex:2] integerValue];
-
-    [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
-        CDVPluginResult* result = nil;
-        if (data != nil) {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArrayBuffer:data];
-        } else {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
-        }
-
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-    }];
-}
-
-- (void)readAsBinaryString:(CDVInvokedUrlCommand*)command
-{
-    NSString* path = [command argumentAtIndex:0];
-    NSInteger start = [[command argumentAtIndex:1] integerValue];
-    NSInteger end = [[command argumentAtIndex:2] integerValue];
-
-    [self readFileWithPath:path start:start end:end callback:^(NSData* data, NSString* mimeType, CDVFileError errorCode) {
-        CDVPluginResult* result = nil;
-        if (data != nil) {
-            NSString* payload = [[NSString alloc] initWithBytesNoCopy:(void*)[data bytes] length:[data length] encoding:NSASCIIStringEncoding freeWhenDone:NO];
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload];
-            result.associatedObject = data;
-        } else {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:errorCode];
-        }
-
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-    }];
-}
-
-/* helper function to get the mimeType from the file extension
- * IN:
- *	NSString* fullPath - filename (may include path)
- * OUT:
- *	NSString* the mime type as type/subtype.  nil if not able to determine
- */
-- (NSString*)getMimeTypeFromPath:(NSString*)fullPath
-{
-    NSString* mimeType = nil;
-
-    if (fullPath) {
-        CFStringRef typeId = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[fullPath pathExtension], NULL);
-        if (typeId) {
-            mimeType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass(typeId, kUTTagClassMIMEType);
-            if (!mimeType) {
-                // special case for m4a
-                if ([(__bridge NSString*)typeId rangeOfString : @"m4a-audio"].location != NSNotFound) {
-                    mimeType = @"audio/mp4";
-                } else if ([[fullPath pathExtension] rangeOfString:@"wav"].location != NSNotFound) {
-                    mimeType = @"audio/wav";
-                }
-            }
-            CFRelease(typeId);
-        }
-    }
-    return mimeType;
-}
-
-- (void)truncate:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* argPath = [command.arguments objectAtIndex:0];
-    unsigned long long pos = (unsigned long long)[[command.arguments objectAtIndex:1] longLongValue];
-
-    // assets-library files can't be truncated
-    if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    NSString* appFile = argPath; // [self getFullPath:argPath];
-
-    unsigned long long newPos = [self truncateFile:appFile atPosition:pos];
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:newPos];
-
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (unsigned long long)truncateFile:(NSString*)filePath atPosition:(unsigned long long)pos
-{
-    unsigned long long newPos = 0UL;
-
-    NSFileHandle* file = [NSFileHandle fileHandleForWritingAtPath:filePath];
-
-    if (file) {
-        [file truncateFileAtOffset:(unsigned long long)pos];
-        newPos = [file offsetInFile];
-        [file synchronizeFile];
-        [file closeFile];
-    }
-    return newPos;
-}
-
-/* write
- * IN:
- * NSArray* arguments
- *  0 - NSString* file path to write to
- *  1 - NSString* data to write
- *  2 - NSNumber* position to begin writing
- */
-- (void)write:(CDVInvokedUrlCommand*)command
-{
-    NSString* callbackId = command.callbackId;
-    NSArray* arguments = command.arguments;
-
-    // arguments
-    NSString* argPath = [arguments objectAtIndex:0];
-    NSString* argData = [arguments objectAtIndex:1];
-    unsigned long long pos = (unsigned long long)[[arguments objectAtIndex:2] longLongValue];
-
-    // text can't be written into assets-library files
-    if ([argPath hasPrefix:kCDVAssetsLibraryPrefix]) {
-        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR];
-        [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-        return;
-    }
-
-    NSString* fullPath = argPath; // [self getFullPath:argPath];
-
-    [self truncateFile:fullPath atPosition:pos];
-
-    [self writeToFile:fullPath withData:argData append:YES callback:callbackId];
-}
-
-- (void)writeToFile:(NSString*)filePath withData:(NSString*)data append:(BOOL)shouldAppend callback:(NSString*)callbackId
-{
-    CDVPluginResult* result = nil;
-    CDVFileError errCode = INVALID_MODIFICATION_ERR;
-    int bytesWritten = 0;
-    NSData* encData = [data dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
-
-    if (filePath) {
-        NSOutputStream* fileStream = [NSOutputStream outputStreamToFileAtPath:filePath append:shouldAppend];
-        if (fileStream) {
-            NSUInteger len = [encData length];
-            [fileStream open];
-
-            bytesWritten = [fileStream write:[encData bytes] maxLength:len];
-
-            [fileStream close];
-            if (bytesWritten > 0) {
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:bytesWritten];
-                // } else {
-                // can probably get more detailed error info via [fileStream streamError]
-                // errCode already set to INVALID_MODIFICATION_ERR;
-                // bytesWritten = 0; // may be set to -1 on error
-            }
-        } // else fileStream not created return INVALID_MODIFICATION_ERR
-    } else {
-        // invalid filePath
-        errCode = NOT_FOUND_ERR;
-    }
-    if (!result) {
-        // was an error
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
-    }
-    [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)testFileExists:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* argPath = [command.arguments objectAtIndex:0];
-
-    // Get the file manager
-    NSFileManager* fMgr = [NSFileManager defaultManager];
-    NSString* appFile = argPath; // [ self getFullPath: argPath];
-
-    BOOL bExists = [fMgr fileExistsAtPath:appFile];
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(bExists ? 1 : 0)];
-
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-- (void)testDirectoryExists:(CDVInvokedUrlCommand*)command
-{
-    // arguments
-    NSString* argPath = [command.arguments objectAtIndex:0];
-
-    // Get the file manager
-    NSFileManager* fMgr = [[NSFileManager alloc] init];
-    NSString* appFile = argPath; // [self getFullPath: argPath];
-    BOOL bIsDir = NO;
-    BOOL bExists = [fMgr fileExistsAtPath:appFile isDirectory:&bIsDir];
-
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:((bExists && bIsDir) ? 1 : 0)];
-
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-// Returns number of bytes available via callback
-- (void)getFreeDiskSpace:(CDVInvokedUrlCommand*)command
-{
-    // no arguments
-
-    NSNumber* pNumAvail = [self checkFreeDiskSpace:self.appDocsPath];
-
-    NSString* strFreeSpace = [NSString stringWithFormat:@"%qu", [pNumAvail unsignedLongLongValue]];
-    // NSLog(@"Free space is %@", strFreeSpace );
-
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:strFreeSpace];
-
-    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
-}
-
-@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8ac5128b/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
deleted file mode 100644
index 35e3fdd..0000000
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <Foundation/Foundation.h>
-#import "CDVPlugin.h"
-
-enum CDVFileTransferError {
-    FILE_NOT_FOUND_ERR = 1,
-    INVALID_URL_ERR = 2,
-    CONNECTION_ERR = 3,
-    CONNECTION_ABORTED = 4
-};
-typedef int CDVFileTransferError;
-
-enum CDVFileTransferDirection {
-    CDV_TRANSFER_UPLOAD = 1,
-    CDV_TRANSFER_DOWNLOAD = 2,
-};
-typedef int CDVFileTransferDirection;
-
-// Magic value within the options dict used to set a cookie.
-extern NSString* const kOptionsKeyCookie;
-
-@interface CDVFileTransfer : CDVPlugin {}
-
-- (void)upload:(CDVInvokedUrlCommand*)command;
-- (void)download:(CDVInvokedUrlCommand*)command;
-- (NSString*)escapePathComponentForUrlString:(NSString*)urlString;
-
-// Visible for testing.
-- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData;
-- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target;
-
-- (NSMutableDictionary*)createFileTransferError:(int)code
-                                      AndSource:(NSString*)source
-                                      AndTarget:(NSString*)target
-                                  AndHttpStatus:(int)httpStatus
-                                        AndBody:(NSString*)body;
-@property (readonly) NSMutableDictionary* activeTransfers;
-@property (nonatomic, assign) UIBackgroundTaskIdentifier backgroundTaskID;
-@end
-
-@class CDVFileTransferEntityLengthRequest;
-
-@interface CDVFileTransferDelegate : NSObject {}
-
-- (void)updateBytesExpected:(NSInteger)newBytesExpected;
-- (void)cancelTransfer:(NSURLConnection*)connection;
-
-@property (strong) NSMutableData* responseData; // atomic
-@property (nonatomic, strong) CDVFileTransfer* command;
-@property (nonatomic, assign) CDVFileTransferDirection direction;
-@property (nonatomic, strong) NSURLConnection* connection;
-@property (nonatomic, copy) NSString* callbackId;
-@property (nonatomic, copy) NSString* objectId;
-@property (nonatomic, copy) NSString* source;
-@property (nonatomic, copy) NSString* target;
-@property (nonatomic, copy) NSString* mimeType;
-@property (assign) int responseCode; // atomic
-@property (nonatomic, assign) NSInteger bytesTransfered;
-@property (nonatomic, assign) NSInteger bytesExpected;
-@property (nonatomic, assign) BOOL trustAllHosts;
-@property (strong) NSFileHandle* targetFileHandle;
-@property (nonatomic, strong) CDVFileTransferEntityLengthRequest* entityLengthRequest;
-
-@end;