aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2015-07-17 15:51:54 +0100
committerDave Arter <davea@mysociety.org>2015-08-28 14:27:15 +0100
commitaf7c5ce2233eb14a5ba57cc581948ffa9658ecc2 (patch)
treeb22ed93c540aaa58a3aa91f71d5e3329a5641be6
parente1fc2b466ae83d221864232851b1f55ff012f38c (diff)
Upgrade iOS version of the app to latest Cordova; remove old phonegap 2 bits
-rw-r--r--config.xml15
-rwxr-xr-xiPhone/CordovaLib/Classes/CDV.h57
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVAccelerometer.h39
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVAccelerometer.m128
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVAvailability.h90
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVBattery.h40
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVBattery.m152
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCamera.h102
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCamera.m730
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCapture.h118
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCapture.m845
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCommandDelegate.h54
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCommandDelegateImpl.h33
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCommandDelegateImpl.m145
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCommandQueue.h40
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVCommandQueue.m169
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVConfigParser.h31
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVConfigParser.m96
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVConnection.h34
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVConnection.m132
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVContact.h136
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVContact.m1752
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVContacts.h151
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVContacts.m593
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVDebug.h25
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVDevice.h30
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVDevice.m89
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVEcho.h23
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVEcho.m61
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVExif.h43
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVFile.h107
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVFile.m1426
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVFileTransfer.h82
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVFileTransfer.m730
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVGlobalization.h150
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVGlobalization.m790
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVInAppBrowser.h89
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVInAppBrowser.m818
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVInvokedUrlCommand.h57
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m140
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVJSON.h30
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVJSON.m77
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVJpegHeaderWriter.h62
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVJpegHeaderWriter.m547
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVLocalStorage.h50
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVLocalStorage.m485
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVLocation.h104
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVLocation.m623
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVLogger.h26
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVLogger.m38
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVNotification.h37
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVNotification.m130
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVPlugin.h64
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVPlugin.m152
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVPluginResult.h68
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVPluginResult.m224
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVReachability.h85
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVReachability.m260
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVScreenOrientationDelegate.h28
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVSound.h116
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVSound.m702
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVSplashScreen.h33
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVSplashScreen.m233
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVTimer.h27
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVTimer.m123
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVURLProtocol.h29
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVURLProtocol.m230
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVUserAgentUtil.h27
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVUserAgentUtil.m120
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVViewController.h73
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVViewController.m933
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVWebViewDelegate.h39
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVWebViewDelegate.m380
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVWhitelist.h34
-rwxr-xr-xiPhone/CordovaLib/Classes/CDVWhitelist.m238
-rwxr-xr-xiPhone/CordovaLib/Classes/NSArray+Comparisons.h26
-rwxr-xr-xiPhone/CordovaLib/Classes/NSArray+Comparisons.m41
-rwxr-xr-xiPhone/CordovaLib/Classes/NSData+Base64.h33
-rwxr-xr-xiPhone/CordovaLib/Classes/NSData+Base64.m281
-rwxr-xr-xiPhone/CordovaLib/Classes/NSDictionary+Extensions.h35
-rwxr-xr-xiPhone/CordovaLib/Classes/NSDictionary+Extensions.m159
-rwxr-xr-xiPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.h29
-rwxr-xr-xiPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.m58
-rwxr-xr-xiPhone/CordovaLib/Classes/UIDevice+Extensions.h31
-rwxr-xr-xiPhone/CordovaLib/Classes/UIDevice+Extensions.m47
-rwxr-xr-xiPhone/CordovaLib/CordovaLib.xcodeproj/project.pbxproj682
-rwxr-xr-xiPhone/CordovaLib/CordovaLib_Prefix.pch22
-rwxr-xr-xiPhone/CordovaLib/VERSION1
-rwxr-xr-xiPhone/CordovaLib/cordova.js6521
-rw-r--r--iPhone/FixMyStreet.xcodeproj/project.pbxproj694
-rw-r--r--iPhone/FixMyStreet.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--iPhone/FixMyStreet.xcodeproj/project.xcworkspace/xcshareddata/FixMyStreet.xccheckout41
-rw-r--r--iPhone/FixMyStreet/Classes/AppDelegate.h42
-rw-r--r--iPhone/FixMyStreet/Classes/AppDelegate.m133
-rw-r--r--iPhone/FixMyStreet/Classes/MainViewController.h40
-rw-r--r--iPhone/FixMyStreet/Classes/MainViewController.m174
-rw-r--r--iPhone/FixMyStreet/Classes/MainViewController.xib138
-rw-r--r--iPhone/FixMyStreet/FixMyStreet-Info.plist64
-rw-r--r--iPhone/FixMyStreet/FixMyStreet-Prefix.pch7
-rw-r--r--iPhone/FixMyStreet/Plugins/README1
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg.pngbin955 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg@2x.pngbin971 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg~ipad.pngbin969 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/microphone.pngbin72226 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/microphone@2x.pngbin282409 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/microphone~ipad.pngbin393975 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/record_button.pngbin5852 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/record_button@2x.pngbin13875 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/record_button~ipad.pngbin7547 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg.pngbin973 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg@2x.pngbin990 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg~ipad.pngbin996 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/stop_button.pngbin5514 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/stop_button@2x.pngbin12965 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/Capture.bundle/stop_button~ipad.pngbin7119 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/de.lproj/Localizable.strings26
-rw-r--r--iPhone/FixMyStreet/Resources/en.lproj/Localizable.strings25
-rw-r--r--iPhone/FixMyStreet/Resources/es.lproj/Localizable.strings25
-rw-r--r--iPhone/FixMyStreet/Resources/icons/fms-Icon-120.pngbin5539 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/icons/fms-Icon-80.pngbin5420 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29.pngbin1003 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29@2x.pngbin2081 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/icons/fms-Icon.pngbin2002 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/icons/fms-Icon@2x.pngbin4832 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/se.lproj/Localizable.strings26
-rw-r--r--iPhone/FixMyStreet/Resources/splash/Default.pngbin6002 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/Resources/splash/Default@2x.pngbin12206 -> 0 bytes
-rw-r--r--iPhone/FixMyStreet/config.xml120
-rw-r--r--iPhone/FixMyStreet/en.lproj/InfoPlist.strings2
-rw-r--r--iPhone/FixMyStreet/main.m35
-rw-r--r--iPhone/Icon.pngbin1580 -> 0 bytes
-rw-r--r--iPhone/Icon@2x.pngbin3690 -> 0 bytes
-rwxr-xr-xiPhone/cordova/build51
-rwxr-xr-xiPhone/cordova/emulate55
-rwxr-xr-xiPhone/cordova/log23
-rwxr-xr-xiPhone/cordova/release51
-rwxr-xr-xiPhone/cordova/run58
-rw-r--r--iPhone/fms-Icon-120.pngbin5539 -> 0 bytes
-rw-r--r--iPhone/fms-Icon-80.pngbin5420 -> 0 bytes
-rw-r--r--iPhone/fms-Icon-Small-29.pngbin1003 -> 0 bytes
-rw-r--r--iPhone/fms-Icon-Small-29@2x.pngbin2081 -> 0 bytes
-rwxr-xr-xiPhone/www/cordova.js6521
-rw-r--r--res/ios/Default-568h@2x.png (renamed from iPhone/Default-568h@2x.png)bin12832 -> 12832 bytes
-rw-r--r--res/ios/Default.png (renamed from iPhone/Default.png)bin6002 -> 6002 bytes
-rw-r--r--res/ios/Default@2x.png (renamed from iPhone/Default@2x.png)bin12206 -> 12206 bytes
-rw-r--r--res/ios/Icon-120.png (renamed from iPhone/Icon-120.png)bin5584 -> 5584 bytes
-rw-r--r--res/ios/Icon.png (renamed from iPhone/FixMyStreet/Icon.png)bin1580 -> 1580 bytes
-rw-r--r--res/ios/Icon@2x.png (renamed from iPhone/FixMyStreet/Icon@2x.png)bin3690 -> 3690 bytes
148 files changed, 15 insertions, 33079 deletions
diff --git a/config.xml b/config.xml
index 7fa3427..f0081ed 100644
--- a/config.xml
+++ b/config.xml
@@ -25,6 +25,8 @@
<preference name="android-minSdkVersion" value="16" />
<preference name="orientation" value="portrait" />
+ <preference name="StatusBarOverlaysWebView" value="false" />
+ <preference name="StatusBarBackgroundColor" value="#000000" />
<platform name="android">
<icon src="res/android/ldpi.png" density="ldpi" />
@@ -32,4 +34,17 @@
<icon src="res/android/hdpi.png" density="hdpi" />
<icon src="res/android/xhdpi.png" density="xhdpi" />
</platform>
+
+ <platform name="ios">
+ <!-- iPhone / iPod Touch -->
+ <icon src="res/ios/Icon.png" width="57" height="57" />
+ <icon src="res/ios/Icon@2x.png" width="114" height="114" />
+ <!-- iPad -->
+ <icon src="res/ios/Icon-120.png" width="120" height="120" />
+
+ <!-- Splash Screens -->
+ <splash src="res/ios/Default.png" width="320" height="480"/>
+ <splash src="res/ios/Default@2x.png" width="640" height="960"/>
+ <splash src="res/ios/Default-568h@2x.png" width="640" height="1136"/>
+ </platform>
</widget>
diff --git a/iPhone/CordovaLib/Classes/CDV.h b/iPhone/CordovaLib/Classes/CDV.h
deleted file mode 100755
index 15d9316..0000000
--- a/iPhone/CordovaLib/Classes/CDV.h
+++ /dev/null
@@ -1,57 +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 "CDVAvailability.h"
-
-#import "CDVPlugin.h"
-#import "CDVViewController.h"
-#import "CDVCommandDelegate.h"
-#import "CDVURLProtocol.h"
-#import "CDVInvokedUrlCommand.h"
-
-#import "CDVAccelerometer.h"
-#import "CDVBattery.h"
-#import "CDVCamera.h"
-#import "CDVCapture.h"
-#import "CDVConnection.h"
-#import "CDVContact.h"
-#import "CDVContacts.h"
-#import "CDVDebug.h"
-#import "CDVDevice.h"
-#import "CDVFile.h"
-#import "CDVFileTransfer.h"
-#import "CDVLocation.h"
-#import "CDVNotification.h"
-#import "CDVPluginResult.h"
-#import "CDVReachability.h"
-#import "CDVSound.h"
-#import "CDVSplashScreen.h"
-#import "CDVWhitelist.h"
-#import "CDVLocalStorage.h"
-#import "CDVInAppBrowser.h"
-#import "CDVScreenOrientationDelegate.h"
-#import "CDVTimer.h"
-
-#import "NSArray+Comparisons.h"
-#import "NSData+Base64.h"
-#import "NSDictionary+Extensions.h"
-#import "NSMutableArray+QueueAdditions.h"
-#import "UIDevice+Extensions.h"
-
-#import "CDVJSON.h"
diff --git a/iPhone/CordovaLib/Classes/CDVAccelerometer.h b/iPhone/CordovaLib/Classes/CDVAccelerometer.h
deleted file mode 100755
index 044ca53..0000000
--- a/iPhone/CordovaLib/Classes/CDVAccelerometer.h
+++ /dev/null
@@ -1,39 +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 CDVAccelerometer : CDVPlugin <UIAccelerometerDelegate>
-{
- double x;
- double y;
- double z;
- NSTimeInterval timestamp;
-}
-
-@property (readonly, assign) BOOL isRunning;
-@property (nonatomic, strong) NSString* callbackId;
-
-- (CDVAccelerometer*)init;
-
-- (void)start:(CDVInvokedUrlCommand*)command;
-- (void)stop:(CDVInvokedUrlCommand*)command;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVAccelerometer.m b/iPhone/CordovaLib/Classes/CDVAccelerometer.m
deleted file mode 100755
index 33093d0..0000000
--- a/iPhone/CordovaLib/Classes/CDVAccelerometer.m
+++ /dev/null
@@ -1,128 +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 "CDVAccelerometer.h"
-
-@interface CDVAccelerometer () {}
-@property (readwrite, assign) BOOL isRunning;
-@end
-
-@implementation CDVAccelerometer
-
-@synthesize callbackId, isRunning;
-
-// defaults to 10 msec
-#define kAccelerometerInterval 40
-// g constant: -9.81 m/s^2
-#define kGravitationalConstant -9.81
-
-- (CDVAccelerometer*)init
-{
- self = [super init];
- if (self) {
- x = 0;
- y = 0;
- z = 0;
- timestamp = 0;
- self.callbackId = nil;
- self.isRunning = NO;
- }
- return self;
-}
-
-- (void)dealloc
-{
- [self stop:nil];
-}
-
-- (void)start:(CDVInvokedUrlCommand*)command
-{
- NSString* cbId = command.callbackId;
- NSTimeInterval desiredFrequency_num = kAccelerometerInterval;
- UIAccelerometer* pAccel = [UIAccelerometer sharedAccelerometer];
-
- // accelerometer expects fractional seconds, but we have msecs
- pAccel.updateInterval = desiredFrequency_num / 1000;
- self.callbackId = cbId;
- if (!self.isRunning) {
- pAccel.delegate = self;
- self.isRunning = YES;
- }
-}
-
-- (void)onReset
-{
- [self stop:nil];
-}
-
-- (void)stop:(CDVInvokedUrlCommand*)command
-{
- UIAccelerometer* theAccelerometer = [UIAccelerometer sharedAccelerometer];
-
- theAccelerometer.delegate = nil;
- self.isRunning = NO;
-}
-
-/**
- * Picks up accel updates from device and stores them in this class
- */
-- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
-{
- if (self.isRunning) {
- x = acceleration.x;
- y = acceleration.y;
- z = acceleration.z;
- timestamp = ([[NSDate date] timeIntervalSince1970] * 1000);
- [self returnAccelInfo];
- }
-}
-
-- (void)returnAccelInfo
-{
- // Create an acceleration object
- NSMutableDictionary* accelProps = [NSMutableDictionary dictionaryWithCapacity:4];
-
- [accelProps setValue:[NSNumber numberWithDouble:x * kGravitationalConstant] forKey:@"x"];
- [accelProps setValue:[NSNumber numberWithDouble:y * kGravitationalConstant] forKey:@"y"];
- [accelProps setValue:[NSNumber numberWithDouble:z * kGravitationalConstant] forKey:@"z"];
- [accelProps setValue:[NSNumber numberWithDouble:timestamp] forKey:@"timestamp"];
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:accelProps];
- [result setKeepCallback:[NSNumber numberWithBool:YES]];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
-}
-
-// TODO: Consider using filtering to isolate instantaneous data vs. gravity data -jm
-
-/*
- #define kFilteringFactor 0.1
-
- // Use a basic low-pass filter to keep only the gravity component of each axis.
- grav_accelX = (acceleration.x * kFilteringFactor) + ( grav_accelX * (1.0 - kFilteringFactor));
- grav_accelY = (acceleration.y * kFilteringFactor) + ( grav_accelY * (1.0 - kFilteringFactor));
- grav_accelZ = (acceleration.z * kFilteringFactor) + ( grav_accelZ * (1.0 - kFilteringFactor));
-
- // Subtract the low-pass value from the current value to get a simplified high-pass filter
- instant_accelX = acceleration.x - ( (acceleration.x * kFilteringFactor) + (instant_accelX * (1.0 - kFilteringFactor)) );
- instant_accelY = acceleration.y - ( (acceleration.y * kFilteringFactor) + (instant_accelY * (1.0 - kFilteringFactor)) );
- instant_accelZ = acceleration.z - ( (acceleration.z * kFilteringFactor) + (instant_accelZ * (1.0 - kFilteringFactor)) );
-
-
- */
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVAvailability.h b/iPhone/CordovaLib/Classes/CDVAvailability.h
deleted file mode 100755
index 7e8157c..0000000
--- a/iPhone/CordovaLib/Classes/CDVAvailability.h
+++ /dev/null
@@ -1,90 +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.
- */
-
-#define __CORDOVA_IOS__
-
-#define __CORDOVA_0_9_6 906
-#define __CORDOVA_1_0_0 10000
-#define __CORDOVA_1_1_0 10100
-#define __CORDOVA_1_2_0 10200
-#define __CORDOVA_1_3_0 10300
-#define __CORDOVA_1_4_0 10400
-#define __CORDOVA_1_4_1 10401
-#define __CORDOVA_1_5_0 10500
-#define __CORDOVA_1_6_0 10600
-#define __CORDOVA_1_6_1 10601
-#define __CORDOVA_1_7_0 10700
-#define __CORDOVA_1_8_0 10800
-#define __CORDOVA_1_8_1 10801
-#define __CORDOVA_1_9_0 10900
-#define __CORDOVA_2_0_0 20000
-#define __CORDOVA_2_1_0 20100
-#define __CORDOVA_2_2_0 20200
-#define __CORDOVA_2_3_0 20300
-#define __CORDOVA_2_4_0 20400
-#define __CORDOVA_2_5_0 20500
-#define __CORDOVA_2_6_0 20600
-#define __CORDOVA_2_7_0 20700
-#define __CORDOVA_2_8_0 20800
-#define __CORDOVA_2_9_0 20900
-#define __CORDOVA_NA 99999 /* not available */
-
-/*
- #if CORDOVA_VERSION_MIN_REQUIRED >= __CORDOVA_1_7_0
- // do something when its at least 1.7.0
- #else
- // do something else (non 1.7.0)
- #endif
- */
-#ifndef CORDOVA_VERSION_MIN_REQUIRED
- #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_9_0
-#endif
-
-/*
- Returns YES if it is at least version specified as NSString(X)
- Usage:
- if (IsAtLeastiOSVersion(@"5.1")) {
- // do something for iOS 5.1 or greater
- }
- */
-#define IsAtLeastiOSVersion(X) ([[[UIDevice currentDevice] systemVersion] compare:X options:NSNumericSearch] != NSOrderedAscending)
-
-#define CDV_IsIPad() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad))
-
-#define CDV_IsIPhone5() ([[UIScreen mainScreen] bounds].size.height == 568 && [[UIScreen mainScreen] bounds].size.width == 320)
-
-/* Return the string version of the decimal version */
-#define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \
- (CORDOVA_VERSION_MIN_REQUIRED / 10000), \
- (CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
- (CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100]
-
-#ifdef __clang__
- #define CDV_DEPRECATED(version, msg) __attribute__((deprecated("Deprecated in Cordova " #version ". " msg)))
-#else
- #define CDV_DEPRECATED(version, msg) __attribute__((deprecated()))
-#endif
-
-// Enable this to log all exec() calls.
-#define CDV_ENABLE_EXEC_LOGGING 0
-#if CDV_ENABLE_EXEC_LOGGING
- #define CDV_EXEC_LOG NSLog
-#else
- #define CDV_EXEC_LOG(...) do {} while (NO)
-#endif
diff --git a/iPhone/CordovaLib/Classes/CDVBattery.h b/iPhone/CordovaLib/Classes/CDVBattery.h
deleted file mode 100755
index ba26c3a..0000000
--- a/iPhone/CordovaLib/Classes/CDVBattery.h
+++ /dev/null
@@ -1,40 +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"
-
-@interface CDVBattery : CDVPlugin {
- UIDeviceBatteryState state;
- float level;
- bool isPlugged;
- NSString* callbackId;
-}
-
-@property (nonatomic) UIDeviceBatteryState state;
-@property (nonatomic) float level;
-@property (nonatomic) bool isPlugged;
-@property (strong) NSString* callbackId;
-
-- (void)updateBatteryStatus:(NSNotification*)notification;
-- (NSDictionary*)getBatteryStatus;
-- (void)start:(CDVInvokedUrlCommand*)command;
-- (void)stop:(CDVInvokedUrlCommand*)command;
-- (void)dealloc;
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVBattery.m b/iPhone/CordovaLib/Classes/CDVBattery.m
deleted file mode 100755
index 681511c..0000000
--- a/iPhone/CordovaLib/Classes/CDVBattery.m
+++ /dev/null
@@ -1,152 +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 "CDVBattery.h"
-
-@interface CDVBattery (PrivateMethods)
-- (void)updateOnlineStatus;
-@end
-
-@implementation CDVBattery
-
-@synthesize state, level, callbackId, isPlugged;
-
-/* determining type of event occurs on JavaScript side
-- (void) updateBatteryLevel:(NSNotification*)notification
-{
- // send batterylow event for less than 25% battery
- // send batterycritical event for less than 10% battery
- // W3c says to send batteryStatus event when batterylevel changes by more than 1% (iOS seems to notify each 5%)
- // always update the navigator.device.battery info
- float currentLevel = [[UIDevice currentDevice] batteryLevel];
- NSString* type = @"";
- // no check for level == -1 since this api is only called when monitoring is enabled so level should be valid
- if (currentLevel < 0.10){
- type = @"batterycritical";
- } else if (currentLevel < 0.25) {
- type = @"batterylow";
- } else {
- float onePercent = 0.1;
- if (self.level >= 0 ){
- onePercent = self.level * 0.01;
- }
- if (fabsf(currentLevel - self.level) > onePercent){
- // issue batteryStatus event
- type = @"batterystatus";
- }
- }
- // update the battery info and fire event
- NSString* jsString = [NSString stringWithFormat:@"navigator.device.battery._status(\"%@\", %@)", type,[[self getBatteryStatus] JSONRepresentation]];
- [super writeJavascript:jsString];
-}
- */
-
-- (void)updateBatteryStatus:(NSNotification*)notification
-{
- NSDictionary* batteryData = [self getBatteryStatus];
-
- if (self.callbackId) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:batteryData];
- [result setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
- }
-}
-
-/* Get the current battery status and level. Status will be unknown and level will be -1.0 if
- * monitoring is turned off.
- */
-- (NSDictionary*)getBatteryStatus
-{
- UIDevice* currentDevice = [UIDevice currentDevice];
- UIDeviceBatteryState currentState = [currentDevice batteryState];
-
- isPlugged = FALSE; // UIDeviceBatteryStateUnknown or UIDeviceBatteryStateUnplugged
- if ((currentState == UIDeviceBatteryStateCharging) || (currentState == UIDeviceBatteryStateFull)) {
- isPlugged = TRUE;
- }
- float currentLevel = [currentDevice batteryLevel];
-
- if ((currentLevel != self.level) || (currentState != self.state)) {
- self.level = currentLevel;
- self.state = currentState;
- }
-
- // W3C spec says level must be null if it is unknown
- NSObject* w3cLevel = nil;
- if ((currentState == UIDeviceBatteryStateUnknown) || (currentLevel == -1.0)) {
- w3cLevel = [NSNull null];
- } else {
- w3cLevel = [NSNumber numberWithFloat:(currentLevel * 100)];
- }
- NSMutableDictionary* batteryData = [NSMutableDictionary dictionaryWithCapacity:2];
- [batteryData setObject:[NSNumber numberWithBool:isPlugged] forKey:@"isPlugged"];
- [batteryData setObject:w3cLevel forKey:@"level"];
- return batteryData;
-}
-
-/* turn on battery monitoring*/
-- (void)start:(CDVInvokedUrlCommand*)command
-{
- self.callbackId = command.callbackId;
-
- if ([UIDevice currentDevice].batteryMonitoringEnabled == NO) {
- [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
- name:UIDeviceBatteryStateDidChangeNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateBatteryStatus:)
- name:UIDeviceBatteryLevelDidChangeNotification object:nil];
- }
-}
-
-/* turn off battery monitoring */
-- (void)stop:(CDVInvokedUrlCommand*)command
-{
- // callback one last time to clear the callback function on JS side
- if (self.callbackId) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self getBatteryStatus]];
- [result setKeepCallbackAsBool:NO];
- [self.commandDelegate sendPluginResult:result callbackId:self.callbackId];
- }
- self.callbackId = nil;
- [[UIDevice currentDevice] setBatteryMonitoringEnabled:NO];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryStateDidChangeNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceBatteryLevelDidChangeNotification object:nil];
-}
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVBattery*)[super initWithWebView:theWebView];
- if (self) {
- self.state = UIDeviceBatteryStateUnknown;
- self.level = -1.0;
- }
- return self;
-}
-
-- (void)dealloc
-{
- [self stop:nil];
-}
-
-- (void)onReset
-{
- [self stop:nil];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVCamera.h b/iPhone/CordovaLib/Classes/CDVCamera.h
deleted file mode 100755
index 2932e3b..0000000
--- a/iPhone/CordovaLib/Classes/CDVCamera.h
+++ /dev/null
@@ -1,102 +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 <CoreLocation/CoreLocation.h>
-#import <CoreLocation/CLLocationManager.h>
-#import "CDVPlugin.h"
-
-enum CDVDestinationType {
- DestinationTypeDataUrl = 0,
- DestinationTypeFileUri,
- DestinationTypeNativeUri
-};
-typedef NSUInteger CDVDestinationType;
-
-enum CDVEncodingType {
- EncodingTypeJPEG = 0,
- EncodingTypePNG
-};
-typedef NSUInteger CDVEncodingType;
-
-enum CDVMediaType {
- MediaTypePicture = 0,
- MediaTypeVideo,
- MediaTypeAll
-};
-typedef NSUInteger CDVMediaType;
-
-@interface CDVCameraPicker : UIImagePickerController
-{}
-
-@property (assign) NSInteger quality;
-@property (copy) NSString* callbackId;
-@property (copy) NSString* postUrl;
-@property (nonatomic) enum CDVDestinationType returnType;
-@property (nonatomic) enum CDVEncodingType encodingType;
-@property (strong) UIPopoverController* popoverController;
-@property (assign) CGSize targetSize;
-@property (assign) bool correctOrientation;
-@property (assign) bool saveToPhotoAlbum;
-@property (assign) bool cropToSize;
-@property (strong) UIWebView* webView;
-@property (assign) BOOL popoverSupported;
-
-@end
-
-// ======================================================================= //
-
-@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
- UINavigationControllerDelegate,
- UIPopoverControllerDelegate,
- CLLocationManagerDelegate>
-{}
-
-@property (strong) CDVCameraPicker* pickerController;
-@property (strong) NSMutableDictionary *metadata;
-@property (strong, nonatomic) CLLocationManager *locationManager;
-@property (strong) NSData* data;
-
-/*
- * getPicture
- *
- * arguments:
- * 1: this is the javascript function that will be called with the results, the first parameter passed to the
- * javascript function is the picture as a Base64 encoded string
- * 2: this is the javascript function to be called if there was an error
- * options:
- * quality: integer between 1 and 100
- */
-- (void)takePicture:(CDVInvokedUrlCommand*)command;
-- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url;
-- (void)cleanup:(CDVInvokedUrlCommand*)command;
-- (void)repositionPopover:(CDVInvokedUrlCommand*)command;
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated;
-- (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize;
-- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize;
-- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage;
-
-- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation;
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVCamera.m b/iPhone/CordovaLib/Classes/CDVCamera.m
deleted file mode 100755
index d0a36dd..0000000
--- a/iPhone/CordovaLib/Classes/CDVCamera.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 "CDVCamera.h"
-#import "CDVJpegHeaderWriter.h"
-#import "NSArray+Comparisons.h"
-#import "NSData+Base64.h"
-#import "NSDictionary+Extensions.h"
-#import <ImageIO/CGImageProperties.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <ImageIO/CGImageSource.h>
-#import <ImageIO/CGImageProperties.h>
-#import <ImageIO/CGImageDestination.h>
-#import <MobileCoreServices/UTCoreTypes.h>
-
-#define CDV_PHOTO_PREFIX @"cdv_photo_"
-
-static NSSet* org_apache_cordova_validArrowDirections;
-
-@interface CDVCamera ()
-
-@property (readwrite, assign) BOOL hasPendingOperation;
-
-@end
-
-@implementation CDVCamera
-
-+ (void)initialize
-{
- org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown], [NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
-}
-
-@synthesize hasPendingOperation, pickerController, locationManager;
-
-- (BOOL)popoverSupported
-{
- return (NSClassFromString(@"UIPopoverController") != nil) &&
- (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
-}
-
-/* takePicture arguments:
- * INDEX ARGUMENT
- * 0 quality
- * 1 destination type
- * 2 source type
- * 3 targetWidth
- * 4 targetHeight
- * 5 encodingType
- * 6 mediaType
- * 7 allowsEdit
- * 8 correctOrientation
- * 9 saveToPhotoAlbum
- * 10 popoverOptions
- * 11 cameraDirection
- */
-- (void)takePicture:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSArray* arguments = command.arguments;
-
- self.hasPendingOperation = NO;
-
- NSString* sourceTypeString = [arguments objectAtIndex:2];
- UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default
- if (sourceTypeString != nil) {
- sourceType = (UIImagePickerControllerSourceType)[sourceTypeString intValue];
- }
-
- bool hasCamera = [UIImagePickerController isSourceTypeAvailable:sourceType];
- if (!hasCamera) {
- NSLog(@"Camera.getPicture: source type %d not available.", sourceType);
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no camera available"];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- bool allowEdit = [[arguments objectAtIndex:7] boolValue];
- NSNumber* targetWidth = [arguments objectAtIndex:3];
- NSNumber* targetHeight = [arguments objectAtIndex:4];
- NSNumber* mediaValue = [arguments objectAtIndex:6];
- CDVMediaType mediaType = (mediaValue) ? [mediaValue intValue] : MediaTypePicture;
-
- CGSize targetSize = CGSizeMake(0, 0);
- if ((targetWidth != nil) && (targetHeight != nil)) {
- targetSize = CGSizeMake([targetWidth floatValue], [targetHeight floatValue]);
- }
-
- // If a popover is already open, close it; we only want one at a time.
- if (([[self pickerController] popoverController] != nil) && [[[self pickerController] popoverController] isPopoverVisible]) {
- [[[self pickerController] popoverController] dismissPopoverAnimated:YES];
- [[[self pickerController] popoverController] setDelegate:nil];
- [[self pickerController] setPopoverController:nil];
- }
-
- CDVCameraPicker* cameraPicker = [[CDVCameraPicker alloc] init];
- self.pickerController = cameraPicker;
-
- cameraPicker.delegate = self;
- cameraPicker.sourceType = sourceType;
- cameraPicker.allowsEditing = allowEdit; // THIS IS ALL IT TAKES FOR CROPPING - jm
- cameraPicker.callbackId = callbackId;
- cameraPicker.targetSize = targetSize;
- cameraPicker.cropToSize = NO;
- // we need to capture this state for memory warnings that dealloc this object
- cameraPicker.webView = self.webView;
- cameraPicker.popoverSupported = [self popoverSupported];
-
- cameraPicker.correctOrientation = [[arguments objectAtIndex:8] boolValue];
- cameraPicker.saveToPhotoAlbum = [[arguments objectAtIndex:9] boolValue];
-
- cameraPicker.encodingType = ([arguments objectAtIndex:5]) ? [[arguments objectAtIndex:5] intValue] : EncodingTypeJPEG;
-
- cameraPicker.quality = ([arguments objectAtIndex:0]) ? [[arguments objectAtIndex:0] intValue] : 50;
- cameraPicker.returnType = ([arguments objectAtIndex:1]) ? [[arguments objectAtIndex:1] intValue] : DestinationTypeFileUri;
-
- if (sourceType == UIImagePickerControllerSourceTypeCamera) {
- // We only allow taking pictures (no video) in this API.
- cameraPicker.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
-
- // We can only set the camera device if we're actually using the camera.
- NSNumber* cameraDirection = [command argumentAtIndex:11 withDefault:[NSNumber numberWithInteger:UIImagePickerControllerCameraDeviceRear]];
- cameraPicker.cameraDevice = (UIImagePickerControllerCameraDevice)[cameraDirection intValue];
- } else if (mediaType == MediaTypeAll) {
- cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
- } else {
- NSArray* mediaArray = [NSArray arrayWithObjects:(NSString*)(mediaType == MediaTypeVideo ? kUTTypeMovie : kUTTypeImage), nil];
- cameraPicker.mediaTypes = mediaArray;
- }
-
- if ([self popoverSupported] && (sourceType != UIImagePickerControllerSourceTypeCamera)) {
- if (cameraPicker.popoverController == nil) {
- cameraPicker.popoverController = [[NSClassFromString(@"UIPopoverController")alloc] initWithContentViewController:cameraPicker];
- }
- NSDictionary* options = [command.arguments objectAtIndex:10 withDefault:nil];
- [self displayPopover:options];
- } else {
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:cameraPicker animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:cameraPicker animated:YES];
- }
- }
- self.hasPendingOperation = YES;
-}
-
-- (void)repositionPopover:(CDVInvokedUrlCommand*)command
-{
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
-
- [self displayPopover:options];
-}
-
-- (void)displayPopover:(NSDictionary*)options
-{
- int x = 0;
- int y = 32;
- int width = 320;
- int height = 480;
- UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny;
-
- if (options) {
- x = [options integerValueForKey:@"x" defaultValue:0];
- y = [options integerValueForKey:@"y" defaultValue:32];
- width = [options integerValueForKey:@"width" defaultValue:320];
- height = [options integerValueForKey:@"height" defaultValue:480];
- arrowDirection = [options integerValueForKey:@"arrowDir" defaultValue:UIPopoverArrowDirectionAny];
- if (![org_apache_cordova_validArrowDirections containsObject:[NSNumber numberWithInt:arrowDirection]]) {
- arrowDirection = UIPopoverArrowDirectionAny;
- }
- }
-
- [[[self pickerController] popoverController] setDelegate:self];
- [[[self pickerController] popoverController] presentPopoverFromRect:CGRectMake(x, y, width, height)
- inView:[self.webView superview]
- permittedArrowDirections:arrowDirection
- animated:YES];
-}
-
-- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
-{
- if([navigationController isKindOfClass:[UIImagePickerController class]]){
- UIImagePickerController * cameraPicker = (UIImagePickerController*)navigationController;
-
- if(![cameraPicker.mediaTypes containsObject:(NSString*) kUTTypeImage]){
- [viewController.navigationItem setTitle:NSLocalizedString(@"Videos title", nil)];
- }
- }
-}
-
-- (void)cleanup:(CDVInvokedUrlCommand*)command
-{
- // empty the tmp directory
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* err = nil;
- BOOL hasErrors = NO;
-
- // clear contents of NSTemporaryDirectory
- NSString* tempDirectoryPath = NSTemporaryDirectory();
- NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
- NSString* fileName = nil;
- BOOL result;
-
- while ((fileName = [directoryEnumerator nextObject])) {
- // only delete the files we created
- if (![fileName hasPrefix:CDV_PHOTO_PREFIX]) {
- continue;
- }
- NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
- result = [fileMgr removeItemAtPath:filePath error:&err];
- if (!result && err) {
- NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
- hasErrors = YES;
- }
- }
-
- CDVPluginResult* pluginResult;
- if (hasErrors) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:@"One or more files failed to be deleted."];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- }
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)popoverControllerDidDismissPopover:(id)popoverController
-{
- // [ self imagePickerControllerDidCancel:self.pickerController ]; '
- UIPopoverController* pc = (UIPopoverController*)popoverController;
-
- [pc dismissPopoverAnimated:YES];
- pc.delegate = nil;
- if (self.pickerController && self.pickerController.callbackId && self.pickerController.popoverController) {
- self.pickerController.popoverController = nil;
- NSString* callbackId = self.pickerController.callbackId;
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- self.hasPendingOperation = NO;
-}
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
-{
- CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
-
- if (cameraPicker.popoverSupported && (cameraPicker.popoverController != nil)) {
- [cameraPicker.popoverController dismissPopoverAnimated:YES];
- cameraPicker.popoverController.delegate = nil;
- cameraPicker.popoverController = nil;
- } else {
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
- [[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- }
-
- CDVPluginResult* result = nil;
-
- NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
- // IMAGE TYPE
- if ([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
- if (cameraPicker.returnType == DestinationTypeNativeUri) {
- NSString* nativeUri = [(NSURL*)[info objectForKey:UIImagePickerControllerReferenceURL] absoluteString];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nativeUri];
- } else {
- // get the image
- UIImage* image = nil;
- if (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage]) {
- image = [info objectForKey:UIImagePickerControllerEditedImage];
- } else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
-
- if (cameraPicker.correctOrientation) {
- image = [self imageCorrectedForCaptureOrientation:image];
- }
-
- UIImage* scaledImage = nil;
-
- if ((cameraPicker.targetSize.width > 0) && (cameraPicker.targetSize.height > 0)) {
- // if cropToSize, resize image and crop to target size, otherwise resize to fit target without cropping
- if (cameraPicker.cropToSize) {
- scaledImage = [self imageByScalingAndCroppingForSize:image toSize:cameraPicker.targetSize];
- } else {
- scaledImage = [self imageByScalingNotCroppingForSize:image toSize:cameraPicker.targetSize];
- }
- }
-
- NSData* data = nil;
-
- if (cameraPicker.encodingType == EncodingTypePNG) {
- data = UIImagePNGRepresentation(scaledImage == nil ? image : scaledImage);
- } else {
- data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
-
- NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
- if (controllerMetadata) {
- self.data = data;
- self.metadata = [[NSMutableDictionary alloc] init];
-
- NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];
- if (EXIFDictionary) [self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];
-
- [[self locationManager] startUpdatingLocation];
- return;
- }
- }
-
- if (cameraPicker.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:data], nil, nil, nil);
- }
-
- if (cameraPicker.returnType == DestinationTypeFileUri) {
- // write to temp directory and return URI
- // get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by apple (vs [NSFileManager defaultManager]) to be threadsafe
- // generate unique file name
- NSString* filePath;
-
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, cameraPicker.encodingType == EncodingTypePNG ? @"png":@"jpg"];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- // save file
- if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]];
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSURL fileURLWithPath:filePath] absoluteString]];
- }
- } else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[data base64EncodedString]];
- }
- }
- }
- // NOT IMAGE TYPE (MOVIE)
- else {
- NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] absoluteString];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:moviePath];
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId];
- }
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
-}
-
-// older api calls newer didFinishPickingMediaWithInfo
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
-{
- NSDictionary* imageInfo = [NSDictionary dictionaryWithObject:image forKey:UIImagePickerControllerOriginalImage];
-
- [self imagePickerController:picker didFinishPickingMediaWithInfo:imageInfo];
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
- CDVCameraPicker* cameraPicker = (CDVCameraPicker*)picker;
-
- if ([cameraPicker respondsToSelector:@selector(presentingViewController)]) {
- [[cameraPicker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[cameraPicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- // popoverControllerDidDismissPopover:(id)popoverController is called if popover is cancelled
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"no image selected"]; // error callback expects string ATM
- [self.commandDelegate sendPluginResult:result callbackId:cameraPicker.callbackId];
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
-}
-
-- (UIImage*)imageByScalingAndCroppingForSize:(UIImage*)anImage toSize:(CGSize)targetSize
-{
- UIImage* sourceImage = anImage;
- UIImage* newImage = nil;
- CGSize imageSize = sourceImage.size;
- CGFloat width = imageSize.width;
- CGFloat height = imageSize.height;
- CGFloat targetWidth = targetSize.width;
- CGFloat targetHeight = targetSize.height;
- CGFloat scaleFactor = 0.0;
- CGFloat scaledWidth = targetWidth;
- CGFloat scaledHeight = targetHeight;
- CGPoint thumbnailPoint = CGPointMake(0.0, 0.0);
-
- if (CGSizeEqualToSize(imageSize, targetSize) == NO) {
- CGFloat widthFactor = targetWidth / width;
- CGFloat heightFactor = targetHeight / height;
-
- if (widthFactor > heightFactor) {
- scaleFactor = widthFactor; // scale to fit height
- } else {
- scaleFactor = heightFactor; // scale to fit width
- }
- scaledWidth = width * scaleFactor;
- scaledHeight = height * scaleFactor;
-
- // center the image
- if (widthFactor > heightFactor) {
- thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
- } else if (widthFactor < heightFactor) {
- thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
- }
- }
-
- UIGraphicsBeginImageContext(targetSize); // this will crop
-
- CGRect thumbnailRect = CGRectZero;
- thumbnailRect.origin = thumbnailPoint;
- thumbnailRect.size.width = scaledWidth;
- thumbnailRect.size.height = scaledHeight;
-
- [sourceImage drawInRect:thumbnailRect];
-
- newImage = UIGraphicsGetImageFromCurrentImageContext();
- if (newImage == nil) {
- NSLog(@"could not scale image");
- }
-
- // pop the context to get back to the default
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (UIImage*)imageCorrectedForCaptureOrientation:(UIImage*)anImage
-{
- float rotation_radians = 0;
- bool perpendicular = false;
-
- switch ([anImage imageOrientation]) {
- case UIImageOrientationUp :
- rotation_radians = 0.0;
- break;
-
- case UIImageOrientationDown:
- rotation_radians = M_PI; // don't be scared of radians, if you're reading this, you're good at math
- break;
-
- case UIImageOrientationRight:
- rotation_radians = M_PI_2;
- perpendicular = true;
- break;
-
- case UIImageOrientationLeft:
- rotation_radians = -M_PI_2;
- perpendicular = true;
- break;
-
- default:
- break;
- }
-
- UIGraphicsBeginImageContext(CGSizeMake(anImage.size.width, anImage.size.height));
- CGContextRef context = UIGraphicsGetCurrentContext();
-
- // Rotate around the center point
- CGContextTranslateCTM(context, anImage.size.width / 2, anImage.size.height / 2);
- CGContextRotateCTM(context, rotation_radians);
-
- CGContextScaleCTM(context, 1.0, -1.0);
- float width = perpendicular ? anImage.size.height : anImage.size.width;
- float height = perpendicular ? anImage.size.width : anImage.size.height;
- CGContextDrawImage(context, CGRectMake(-width / 2, -height / 2, width, height), [anImage CGImage]);
-
- // Move the origin back since the rotation might've change it (if its 90 degrees)
- if (perpendicular) {
- CGContextTranslateCTM(context, -anImage.size.height / 2, -anImage.size.width / 2);
- }
-
- UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (UIImage*)imageByScalingNotCroppingForSize:(UIImage*)anImage toSize:(CGSize)frameSize
-{
- UIImage* sourceImage = anImage;
- UIImage* newImage = nil;
- CGSize imageSize = sourceImage.size;
- CGFloat width = imageSize.width;
- CGFloat height = imageSize.height;
- CGFloat targetWidth = frameSize.width;
- CGFloat targetHeight = frameSize.height;
- CGFloat scaleFactor = 0.0;
- CGSize scaledSize = frameSize;
-
- if (CGSizeEqualToSize(imageSize, frameSize) == NO) {
- CGFloat widthFactor = targetWidth / width;
- CGFloat heightFactor = targetHeight / height;
-
- // opposite comparison to imageByScalingAndCroppingForSize in order to contain the image within the given bounds
- if (widthFactor > heightFactor) {
- scaleFactor = heightFactor; // scale to fit height
- } else {
- scaleFactor = widthFactor; // scale to fit width
- }
- scaledSize = CGSizeMake(MIN(width * scaleFactor, targetWidth), MIN(height * scaleFactor, targetHeight));
- }
-
- UIGraphicsBeginImageContext(scaledSize); // this will resize
-
- [sourceImage drawInRect:CGRectMake(0, 0, scaledSize.width, scaledSize.height)];
-
- newImage = UIGraphicsGetImageFromCurrentImageContext();
- if (newImage == nil) {
- NSLog(@"could not scale image");
- }
-
- // pop the context to get back to the default
- UIGraphicsEndImageContext();
- return newImage;
-}
-
-- (void)postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url
-{
- self.hasPendingOperation = YES;
-
- NSString* boundary = @"----BOUNDARY_IS_I";
-
- NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
- [req setHTTPMethod:@"POST"];
-
- NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
- [req setValue:contentType forHTTPHeaderField:@"Content-type"];
-
- NSData* imageData = UIImagePNGRepresentation(anImage);
-
- // adding the body
- NSMutableData* postBody = [NSMutableData data];
-
- // first parameter an image
- [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upload\"; filename=\"%@\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
- [postBody appendData:[@"Content-Type: image/png\r\n\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
- [postBody appendData:imageData];
-
- // // second parameter information
- // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[@"Content-Disposition: form-data; name=\"some_other_name\"\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[@"some_other_value" dataUsingEncoding:NSUTF8StringEncoding]];
- // [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r \n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
-
- [req setHTTPBody:postBody];
-
- NSURLResponse* response;
- NSError* error;
- [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
-
- // NSData* result = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
- // NSString * resultStr = [[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding] autorelease];
-
- self.hasPendingOperation = NO;
-}
-
-
-- (CLLocationManager *)locationManager {
-
- if (locationManager != nil) {
- return locationManager;
- }
-
- locationManager = [[CLLocationManager alloc] init];
- [locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
- [locationManager setDelegate:self];
-
- return locationManager;
-}
-
-- (void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
-{
- if (locationManager != nil) {
- [self.locationManager stopUpdatingLocation];
- self.locationManager = nil;
-
- NSMutableDictionary *GPSDictionary = [[NSMutableDictionary dictionary] init];
-
- CLLocationDegrees latitude = newLocation.coordinate.latitude;
- CLLocationDegrees longitude = newLocation.coordinate.longitude;
-
- // latitude
- if (latitude < 0.0) {
- latitude = latitude * -1.0f;
- [GPSDictionary setObject:@"S" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
- } else {
- [GPSDictionary setObject:@"N" forKey:(NSString*)kCGImagePropertyGPSLatitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:latitude] forKey:(NSString*)kCGImagePropertyGPSLatitude];
-
- // longitude
- if (longitude < 0.0) {
- longitude = longitude * -1.0f;
- [GPSDictionary setObject:@"W" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
- }
- else {
- [GPSDictionary setObject:@"E" forKey:(NSString*)kCGImagePropertyGPSLongitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:longitude] forKey:(NSString*)kCGImagePropertyGPSLongitude];
-
- // altitude
- CGFloat altitude = newLocation.altitude;
- if (!isnan(altitude)){
- if (altitude < 0) {
- altitude = -altitude;
- [GPSDictionary setObject:@"1" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
- } else {
- [GPSDictionary setObject:@"0" forKey:(NSString *)kCGImagePropertyGPSAltitudeRef];
- }
- [GPSDictionary setObject:[NSNumber numberWithFloat:altitude] forKey:(NSString *)kCGImagePropertyGPSAltitude];
- }
-
- // Time and date
- NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
- [formatter setDateFormat:@"HH:mm:ss.SSSSSS"];
- [formatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
- [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSTimeStamp];
- [formatter setDateFormat:@"yyyy:MM:dd"];
- [GPSDictionary setObject:[formatter stringFromDate:newLocation.timestamp] forKey:(NSString *)kCGImagePropertyGPSDateStamp];
-
- [self.metadata setObject:GPSDictionary forKey:(NSString *)kCGImagePropertyGPSDictionary];
- [self imagePickerControllerReturnImageResult];
- }
-}
-
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
- if (locationManager != nil) {
- [self.locationManager stopUpdatingLocation];
- self.locationManager = nil;
-
- [self imagePickerControllerReturnImageResult];
- }
-}
-
-- (void)imagePickerControllerReturnImageResult
-{
- CDVPluginResult* result = nil;
-
- if (self.metadata) {
- CGImageSourceRef sourceImage = CGImageSourceCreateWithData((__bridge_retained CFDataRef)self.data, NULL);
- CFStringRef sourceType = CGImageSourceGetType(sourceImage);
-
- CGImageDestinationRef destinationImage = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)self.data, sourceType, 1, NULL);
- CGImageDestinationAddImageFromSource(destinationImage, sourceImage, 0, (__bridge CFDictionaryRef)self.metadata);
- CGImageDestinationFinalize(destinationImage);
-
- CFRelease(sourceImage);
- CFRelease(destinationImage);
- }
-
- if (self.pickerController.saveToPhotoAlbum) {
- UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[self data]], nil, nil, nil);
- }
-
- if (self.pickerController.returnType == DestinationTypeFileUri) {
- // write to temp directory and return URI
- // get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init]; // recommended by apple (vs [NSFileManager defaultManager]) to be threadsafe
- // generate unique file name
- NSString* filePath;
-
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/%@%03d.%@", docsPath, CDV_PHOTO_PREFIX, i++, self.pickerController.encodingType == EncodingTypePNG ? @"png":@"jpg"];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- // save file
- if (![self.data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[err localizedDescription]];
- }
- else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSURL fileURLWithPath:filePath] absoluteString]];
- }
- }
- else {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[self.data base64EncodedString]];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:self.pickerController.callbackId];
- }
-
- self.hasPendingOperation = NO;
- self.pickerController = nil;
- self.data = nil;
- self.metadata = nil;
-}
-
-@end
-
-@implementation CDVCameraPicker
-
-@synthesize quality, postUrl;
-@synthesize returnType;
-@synthesize callbackId;
-@synthesize popoverController;
-@synthesize targetSize;
-@synthesize correctOrientation;
-@synthesize saveToPhotoAlbum;
-@synthesize encodingType;
-@synthesize cropToSize;
-@synthesize webView;
-@synthesize popoverSupported;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVCapture.h b/iPhone/CordovaLib/Classes/CDVCapture.h
deleted file mode 100755
index afb82b4..0000000
--- a/iPhone/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
diff --git a/iPhone/CordovaLib/Classes/CDVCapture.m b/iPhone/CordovaLib/Classes/CDVCapture.m
deleted file mode 100755
index 884702d..0000000
--- a/iPhone/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
- // 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
diff --git a/iPhone/CordovaLib/Classes/CDVCommandDelegate.h b/iPhone/CordovaLib/Classes/CDVCommandDelegate.h
deleted file mode 100755
index 0401136..0000000
--- a/iPhone/CordovaLib/Classes/CDVCommandDelegate.h
+++ /dev/null
@@ -1,54 +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 "CDVAvailability.h"
-#import "CDVInvokedUrlCommand.h"
-
-@class CDVPlugin;
-@class CDVPluginResult;
-@class CDVWhitelist;
-
-@protocol CDVCommandDelegate <NSObject>
-
-@property (nonatomic, readonly) NSDictionary* settings;
-
-- (NSString*)pathForResource:(NSString*)resourcepath;
-- (id)getCommandInstance:(NSString*)pluginName;
-
-// Plugins should not be using this interface to call other plugins since it
-// will result in bogus callbacks being made.
-- (BOOL)execute:(CDVInvokedUrlCommand*)command CDV_DEPRECATED(2.2, "Use direct method calls instead.");
-
-// Sends a plugin result to the JS. This is thread-safe.
-- (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId;
-// Evaluates the given JS. This is thread-safe.
-- (void)evalJs:(NSString*)js;
-// Can be used to evaluate JS right away instead of scheduling it on the run-loop.
-// This is required for dispatch resign and pause events, but should not be used
-// without reason. Without the run-loop delay, alerts used in JS callbacks may result
-// in dead-lock. This method must be called from the UI thread.
-- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop;
-// Runs the given block on a background thread using a shared thread-pool.
-- (void)runInBackground:(void (^)())block;
-// Returns the User-Agent of the associated UIWebView.
-- (NSString*)userAgent;
-// Returns whether the given URL passes the white-list.
-- (BOOL)URLIsWhitelisted:(NSURL*)url;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVCommandDelegateImpl.h b/iPhone/CordovaLib/Classes/CDVCommandDelegateImpl.h
deleted file mode 100755
index 6735136..0000000
--- a/iPhone/CordovaLib/Classes/CDVCommandDelegateImpl.h
+++ /dev/null
@@ -1,33 +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 "CDVCommandDelegate.h"
-
-@class CDVViewController;
-@class CDVCommandQueue;
-
-@interface CDVCommandDelegateImpl : NSObject <CDVCommandDelegate>{
- @private
- __weak CDVViewController* _viewController;
- @protected
- __weak CDVCommandQueue* _commandQueue;
-}
-- (id)initWithViewController:(CDVViewController*)viewController;
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVCommandDelegateImpl.m b/iPhone/CordovaLib/Classes/CDVCommandDelegateImpl.m
deleted file mode 100755
index fa0e5e0..0000000
--- a/iPhone/CordovaLib/Classes/CDVCommandDelegateImpl.m
+++ /dev/null
@@ -1,145 +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 "CDVCommandDelegateImpl.h"
-#import "CDVJSON.h"
-#import "CDVCommandQueue.h"
-#import "CDVPluginResult.h"
-#import "CDVViewController.h"
-
-@implementation CDVCommandDelegateImpl
-
-- (id)initWithViewController:(CDVViewController*)viewController
-{
- self = [super init];
- if (self != nil) {
- _viewController = viewController;
- _commandQueue = _viewController.commandQueue;
- }
- return self;
-}
-
-- (NSString*)pathForResource:(NSString*)resourcepath
-{
- NSBundle* mainBundle = [NSBundle mainBundle];
- NSMutableArray* directoryParts = [NSMutableArray arrayWithArray:[resourcepath componentsSeparatedByString:@"/"]];
- NSString* filename = [directoryParts lastObject];
-
- [directoryParts removeLastObject];
-
- NSString* directoryPartsJoined = [directoryParts componentsJoinedByString:@"/"];
- NSString* directoryStr = _viewController.wwwFolderName;
-
- if ([directoryPartsJoined length] > 0) {
- directoryStr = [NSString stringWithFormat:@"%@/%@", _viewController.wwwFolderName, [directoryParts componentsJoinedByString:@"/"]];
- }
-
- return [mainBundle pathForResource:filename ofType:@"" inDirectory:directoryStr];
-}
-
-- (void)evalJsHelper2:(NSString*)js
-{
- CDV_EXEC_LOG(@"Exec: evalling: %@", [js substringToIndex:MIN([js length], 160)]);
- NSString* commandsJSON = [_viewController.webView stringByEvaluatingJavaScriptFromString:js];
- if ([commandsJSON length] > 0) {
- CDV_EXEC_LOG(@"Exec: Retrieved new exec messages by chaining.");
- }
-
- [_commandQueue enqueCommandBatch:commandsJSON];
-}
-
-- (void)evalJsHelper:(NSString*)js
-{
- // Cycle the run-loop before executing the JS.
- // This works around a bug where sometimes alerts() within callbacks can cause
- // dead-lock.
- // If the commandQueue is currently executing, then we know that it is safe to
- // execute the callback immediately.
- // Using (dispatch_get_main_queue()) does *not* fix deadlocks for some reaon,
- // but performSelectorOnMainThread: does.
- if (![NSThread isMainThread] || !_commandQueue.currentlyExecuting) {
- [self performSelectorOnMainThread:@selector(evalJsHelper2:) withObject:js waitUntilDone:NO];
- } else {
- [self evalJsHelper2:js];
- }
-}
-
-- (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId
-{
- CDV_EXEC_LOG(@"Exec(%@): Sending result. Status=%@", callbackId, result.status);
- // This occurs when there is are no win/fail callbacks for the call.
- if ([@"INVALID" isEqualToString : callbackId]) {
- return;
- }
- int status = [result.status intValue];
- BOOL keepCallback = [result.keepCallback boolValue];
- NSString* argumentsAsJSON = [result argumentsAsJSON];
-
- NSString* js = [NSString stringWithFormat:@"cordova.require('cordova/exec').nativeCallback('%@',%d,%@,%d)", callbackId, status, argumentsAsJSON, keepCallback];
-
- [self evalJsHelper:js];
-}
-
-- (void)evalJs:(NSString*)js
-{
- [self evalJs:js scheduledOnRunLoop:YES];
-}
-
-- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop
-{
- js = [NSString stringWithFormat:@"cordova.require('cordova/exec').nativeEvalAndFetch(function(){%@})", js];
- if (scheduledOnRunLoop) {
- [self evalJsHelper:js];
- } else {
- [self evalJsHelper2:js];
- }
-}
-
-- (BOOL)execute:(CDVInvokedUrlCommand*)command
-{
- return [_commandQueue execute:command];
-}
-
-- (id)getCommandInstance:(NSString*)pluginName
-{
- return [_viewController getCommandInstance:pluginName];
-}
-
-- (void)runInBackground:(void (^)())block
-{
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
-}
-
-- (NSString*)userAgent
-{
- return [_viewController userAgent];
-}
-
-- (BOOL)URLIsWhitelisted:(NSURL*)url
-{
- return ![_viewController.whitelist schemeIsAllowed:[url scheme]] ||
- [_viewController.whitelist URLIsAllowed:url];
-}
-
-- (NSDictionary*)settings
-{
- return _viewController.settings;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVCommandQueue.h b/iPhone/CordovaLib/Classes/CDVCommandQueue.h
deleted file mode 100755
index 27c47b5..0000000
--- a/iPhone/CordovaLib/Classes/CDVCommandQueue.h
+++ /dev/null
@@ -1,40 +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>
-
-@class CDVInvokedUrlCommand;
-@class CDVViewController;
-
-@interface CDVCommandQueue : NSObject
-
-@property (nonatomic, readonly) BOOL currentlyExecuting;
-
-- (id)initWithViewController:(CDVViewController*)viewController;
-- (void)dispose;
-
-- (void)resetRequestId;
-- (void)enqueCommandBatch:(NSString*)batchJSON;
-
-- (void)maybeFetchCommandsFromJs:(NSNumber*)requestId;
-- (void)fetchCommandsFromJs;
-- (void)executePending;
-- (BOOL)execute:(CDVInvokedUrlCommand*)command;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVCommandQueue.m b/iPhone/CordovaLib/Classes/CDVCommandQueue.m
deleted file mode 100755
index 1a0dfa0..0000000
--- a/iPhone/CordovaLib/Classes/CDVCommandQueue.m
+++ /dev/null
@@ -1,169 +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 <objc/message.h>
-#import "CDV.h"
-#import "CDVCommandQueue.h"
-#import "CDVViewController.h"
-#import "CDVCommandDelegateImpl.h"
-
-@interface CDVCommandQueue () {
- NSInteger _lastCommandQueueFlushRequestId;
- __weak CDVViewController* _viewController;
- NSMutableArray* _queue;
- BOOL _currentlyExecuting;
-}
-@end
-
-@implementation CDVCommandQueue
-
-@synthesize currentlyExecuting = _currentlyExecuting;
-
-- (id)initWithViewController:(CDVViewController*)viewController
-{
- self = [super init];
- if (self != nil) {
- _viewController = viewController;
- _queue = [[NSMutableArray alloc] init];
- }
- return self;
-}
-
-- (void)dispose
-{
- // TODO(agrieve): Make this a zeroing weak ref once we drop support for 4.3.
- _viewController = nil;
-}
-
-- (void)resetRequestId
-{
- _lastCommandQueueFlushRequestId = 0;
-}
-
-- (void)enqueCommandBatch:(NSString*)batchJSON
-{
- if ([batchJSON length] > 0) {
- [_queue addObject:batchJSON];
- [self executePending];
- }
-}
-
-- (void)maybeFetchCommandsFromJs:(NSNumber*)requestId
-{
- // Use the request ID to determine if we've already flushed for this request.
- // This is required only because the NSURLProtocol enqueues the same request
- // multiple times.
- if ([requestId integerValue] > _lastCommandQueueFlushRequestId) {
- _lastCommandQueueFlushRequestId = [requestId integerValue];
- [self fetchCommandsFromJs];
- }
-}
-
-- (void)fetchCommandsFromJs
-{
- // Grab all the queued commands from the JS side.
- NSString* queuedCommandsJSON = [_viewController.webView stringByEvaluatingJavaScriptFromString:
- @"cordova.require('cordova/exec').nativeFetchMessages()"];
-
- [self enqueCommandBatch:queuedCommandsJSON];
- if ([queuedCommandsJSON length] > 0) {
- CDV_EXEC_LOG(@"Exec: Retrieved new exec messages by request.");
- }
-}
-
-- (void)executePending
-{
- // Make us re-entrant-safe.
- if (_currentlyExecuting) {
- return;
- }
- @try {
- _currentlyExecuting = YES;
-
- for (NSUInteger i = 0; i < [_queue count]; ++i) {
- // Parse the returned JSON array.
- NSArray* commandBatch = [[_queue objectAtIndex:i] JSONObject];
-
- // Iterate over and execute all of the commands.
- for (NSArray* jsonEntry in commandBatch) {
- CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonEntry];
- CDV_EXEC_LOG(@"Exec(%@): Calling %@.%@", command.callbackId, command.className, command.methodName);
-
- if (![self execute:command]) {
-#ifdef DEBUG
- NSString* commandJson = [jsonEntry JSONString];
- static NSUInteger maxLogLength = 1024;
- NSString* commandString = ([commandJson length] > maxLogLength) ?
- [NSString stringWithFormat:@"%@[...]", [commandJson substringToIndex:maxLogLength]] :
- commandJson;
-
- DLog(@"FAILED pluginJSON = %@", commandString);
-#endif
- }
- }
- }
-
- [_queue removeAllObjects];
- } @finally
- {
- _currentlyExecuting = NO;
- }
-}
-
-- (BOOL)execute:(CDVInvokedUrlCommand*)command
-{
- if ((command.className == nil) || (command.methodName == nil)) {
- NSLog(@"ERROR: Classname and/or methodName not found for command.");
- return NO;
- }
-
- // Fetch an instance of this class
- CDVPlugin* obj = [_viewController.commandDelegate getCommandInstance:command.className];
-
- if (!([obj isKindOfClass:[CDVPlugin class]])) {
- NSLog(@"ERROR: Plugin '%@' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.", command.className);
- return NO;
- }
- BOOL retVal = YES;
-
- // Find the proper selector to call.
- NSString* methodName = [NSString stringWithFormat:@"%@:", command.methodName];
- NSString* methodNameWithDict = [NSString stringWithFormat:@"%@:withDict:", command.methodName];
- SEL normalSelector = NSSelectorFromString(methodName);
- SEL legacySelector = NSSelectorFromString(methodNameWithDict);
- // Test for the legacy selector first in case they both exist.
- if ([obj respondsToSelector:legacySelector]) {
- NSMutableArray* arguments = nil;
- NSMutableDictionary* dict = nil;
- [command legacyArguments:&arguments andDict:&dict];
- // [obj performSelector:legacySelector withObject:arguments withObject:dict];
- objc_msgSend(obj, legacySelector, arguments, dict);
- } else if ([obj respondsToSelector:normalSelector]) {
- // [obj performSelector:normalSelector withObject:command];
- objc_msgSend(obj, normalSelector, command);
- } else {
- // There's no method to call, so throw an error.
- NSLog(@"ERROR: Method '%@' not defined in Plugin '%@'", methodName, command.className);
- retVal = NO;
- }
-
- return retVal;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVConfigParser.h b/iPhone/CordovaLib/Classes/CDVConfigParser.h
deleted file mode 100755
index 2e06c88..0000000
--- a/iPhone/CordovaLib/Classes/CDVConfigParser.h
+++ /dev/null
@@ -1,31 +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.
- */
-
-@interface CDVConfigParser : NSObject <NSXMLParserDelegate>
-{
- NSString* featureName;
-}
-
-@property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict;
-@property (nonatomic, readonly, strong) NSMutableDictionary* settings;
-@property (nonatomic, readonly, strong) NSMutableArray* whitelistHosts;
-@property (nonatomic, readonly, strong) NSMutableArray* startupPluginNames;
-@property (nonatomic, readonly, strong) NSString* startPage;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVConfigParser.m b/iPhone/CordovaLib/Classes/CDVConfigParser.m
deleted file mode 100755
index 55b25e6..0000000
--- a/iPhone/CordovaLib/Classes/CDVConfigParser.m
+++ /dev/null
@@ -1,96 +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 "CDVConfigParser.h"
-
-@interface CDVConfigParser ()
-
-@property (nonatomic, readwrite, strong) NSMutableDictionary* pluginsDict;
-@property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
-@property (nonatomic, readwrite, strong) NSMutableArray* whitelistHosts;
-@property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
-@property (nonatomic, readwrite, strong) NSString* startPage;
-
-@end
-
-@implementation CDVConfigParser
-
-@synthesize pluginsDict, settings, whitelistHosts, startPage, startupPluginNames;
-
-- (id)init
-{
- self = [super init];
- if (self != nil) {
- self.pluginsDict = [[NSMutableDictionary alloc] initWithCapacity:30];
- self.settings = [[NSMutableDictionary alloc] initWithCapacity:30];
- self.whitelistHosts = [[NSMutableArray alloc] initWithCapacity:30];
- self.startupPluginNames = [[NSMutableArray alloc] initWithCapacity:8];
- featureName = nil;
- }
- return self;
-}
-
-- (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName attributes:(NSDictionary*)attributeDict
-{
- if ([elementName isEqualToString:@"preference"]) {
- settings[attributeDict[@"name"]] = attributeDict[@"value"];
- } else if ([elementName isEqualToString:@"plugin"]) {
- NSString* name = [attributeDict[@"name"] lowercaseString];
- pluginsDict[name] = attributeDict[@"value"];
- if ([@"true" isEqualToString : attributeDict[@"onload"]]) {
- [self.startupPluginNames addObject:name];
- }
- NSLog(@"\nUse of the <plugin> tag has been deprecated. Use a <feature> tag instead. Change:\n"
- @" <plugin name=\"%@\" value=\"%@\" />\n"
- @"To:\n"
- @" <feature name=\"%@\">\n"
- @" <param name=\"ios-package\" value=\"%@\" />\n"
- @" </feature>\n"
- , attributeDict[@"name"], attributeDict[@"value"], attributeDict[@"name"], attributeDict[@"value"]);
- } else if ([elementName isEqualToString:@"feature"]) { // store feature name to use with correct parameter set
- featureName = [attributeDict[@"name"] lowercaseString];
- } else if ((featureName != nil) && [elementName isEqualToString:@"param"]) {
- NSString* paramName = [attributeDict[@"name"] lowercaseString];
- id value = attributeDict[@"value"];
- if ([paramName isEqualToString:@"ios-package"]) {
- pluginsDict[featureName] = value;
- }
- if ([paramName isEqualToString:@"onload"] && [@"true" isEqualToString : value]) {
- [self.startupPluginNames addObject:featureName];
- }
- } else if ([elementName isEqualToString:@"access"]) {
- [whitelistHosts addObject:attributeDict[@"origin"]];
- } else if ([elementName isEqualToString:@"content"]) {
- self.startPage = attributeDict[@"src"];
- }
-}
-
-- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI qualifiedName:(NSString*)qualifiedName
-{
- if ([elementName isEqualToString:@"feature"]) { // no longer handling a feature so release
- featureName = nil;
- }
-}
-
-- (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
-{
- NSAssert(NO, @"config.xml parse error line %d col %d", [parser lineNumber], [parser columnNumber]);
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVConnection.h b/iPhone/CordovaLib/Classes/CDVConnection.h
deleted file mode 100755
index d3e8c5d..0000000
--- a/iPhone/CordovaLib/Classes/CDVConnection.h
+++ /dev/null
@@ -1,34 +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"
-#import "CDVReachability.h"
-
-@interface CDVConnection : CDVPlugin {
- NSString* type;
- NSString* _callbackId;
-
- CDVReachability* internetReach;
-}
-
-@property (copy) NSString* connectionType;
-@property (strong) CDVReachability* internetReach;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVConnection.m b/iPhone/CordovaLib/Classes/CDVConnection.m
deleted file mode 100755
index b3f5cab..0000000
--- a/iPhone/CordovaLib/Classes/CDVConnection.m
+++ /dev/null
@@ -1,132 +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 "CDVConnection.h"
-#import "CDVReachability.h"
-
-@interface CDVConnection (PrivateMethods)
-- (void)updateOnlineStatus;
-- (void)sendPluginResult;
-@end
-
-@implementation CDVConnection
-
-@synthesize connectionType, internetReach;
-
-- (void)getConnectionInfo:(CDVInvokedUrlCommand*)command
-{
- _callbackId = command.callbackId;
- [self sendPluginResult];
-}
-
-- (void)sendPluginResult
-{
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:self.connectionType];
-
- [result setKeepCallbackAsBool:YES];
- [self.commandDelegate sendPluginResult:result callbackId:_callbackId];
-}
-
-- (NSString*)w3cConnectionTypeFor:(CDVReachability*)reachability
-{
- NetworkStatus networkStatus = [reachability currentReachabilityStatus];
-
- switch (networkStatus) {
- case NotReachable:
- return @"none";
-
- case ReachableViaWWAN:
- // Return value of '2g' is deprecated as of 2.6.0 and will be replaced with 'cellular' in 3.0.0
- return @"2g";
-
- case ReachableViaWiFi:
- return @"wifi";
-
- default:
- return @"unknown";
- }
-}
-
-- (BOOL)isCellularConnection:(NSString*)theConnectionType
-{
- return [theConnectionType isEqualToString:@"2g"] ||
- [theConnectionType isEqualToString:@"3g"] ||
- [theConnectionType isEqualToString:@"4g"] ||
- [theConnectionType isEqualToString:@"cellular"];
-}
-
-- (void)updateReachability:(CDVReachability*)reachability
-{
- if (reachability) {
- // check whether the connection type has changed
- NSString* newConnectionType = [self w3cConnectionTypeFor:reachability];
- if ([newConnectionType isEqualToString:self.connectionType]) { // the same as before, remove dupes
- return;
- } else {
- self.connectionType = [self w3cConnectionTypeFor:reachability];
- }
- }
- [self sendPluginResult];
-}
-
-- (void)updateConnectionType:(NSNotification*)note
-{
- CDVReachability* curReach = [note object];
-
- if ((curReach != nil) && [curReach isKindOfClass:[CDVReachability class]]) {
- [self updateReachability:curReach];
- }
-}
-
-- (void)onPause
-{
- [self.internetReach stopNotifier];
-}
-
-- (void)onResume
-{
- [self.internetReach startNotifier];
- [self updateReachability:self.internetReach];
-}
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = [super initWithWebView:theWebView];
- if (self) {
- self.connectionType = @"none";
- self.internetReach = [CDVReachability reachabilityForInternetConnection];
- self.connectionType = [self w3cConnectionTypeFor:self.internetReach];
- [self.internetReach startNotifier];
- [self printDeprecationNotice];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
- name:kReachabilityChangedNotification object:nil];
- if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
- }
- }
- return self;
-}
-
-- (void)printDeprecationNotice
-{
- NSLog(@"DEPRECATION NOTICE: The Connection ReachableViaWWAN return value of '2g' is deprecated as of Cordova version 2.6.0 and will be changed to 'cellular' in a future release. ");
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVContact.h b/iPhone/CordovaLib/Classes/CDVContact.h
deleted file mode 100755
index 5187efc..0000000
--- a/iPhone/CordovaLib/Classes/CDVContact.h
+++ /dev/null
@@ -1,136 +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 <AddressBook/ABAddressBook.h>
-#import <AddressBookUI/AddressBookUI.h>
-
-enum CDVContactError {
- UNKNOWN_ERROR = 0,
- INVALID_ARGUMENT_ERROR = 1,
- TIMEOUT_ERROR = 2,
- PENDING_OPERATION_ERROR = 3,
- IO_ERROR = 4,
- NOT_SUPPORTED_ERROR = 5,
- PERMISSION_DENIED_ERROR = 20
-};
-typedef NSUInteger CDVContactError;
-
-@interface CDVContact : NSObject {
- ABRecordRef record; // the ABRecord associated with this contact
- NSDictionary* returnFields; // dictionary of fields to return when performing search
-}
-
-@property (nonatomic, assign) ABRecordRef record;
-@property (nonatomic, strong) NSDictionary* returnFields;
-
-+ (NSDictionary*)defaultABtoW3C;
-+ (NSDictionary*)defaultW3CtoAB;
-+ (NSSet*)defaultW3CtoNull;
-+ (NSDictionary*)defaultObjectAndProperties;
-+ (NSDictionary*)defaultFields;
-
-+ (NSDictionary*)calcReturnFields:(NSArray*)fields;
-- (id)init;
-- (id)initFromABRecord:(ABRecordRef)aRecord;
-- (bool)setFromContactDict:(NSDictionary*)aContact asUpdate:(BOOL)bUpdate;
-
-+ (BOOL)needsConversion:(NSString*)W3Label;
-+ (CFStringRef)convertContactTypeToPropertyLabel:(NSString*)label;
-+ (NSString*)convertPropertyLabelToContactType:(NSString*)label;
-+ (BOOL)isValidW3ContactType:(NSString*)label;
-- (bool)setValue:(id)aValue forProperty:(ABPropertyID)aProperty inRecord:(ABRecordRef)aRecord asUpdate:(BOOL)bUpdate;
-
-- (NSDictionary*)toDictionary:(NSDictionary*)withFields;
-- (NSNumber*)getDateAsNumber:(ABPropertyID)datePropId;
-- (NSObject*)extractName;
-- (NSObject*)extractMultiValue:(NSString*)propertyId;
-- (NSObject*)extractAddresses;
-- (NSObject*)extractIms;
-- (NSObject*)extractOrganizations;
-- (NSObject*)extractPhotos;
-
-- (NSMutableDictionary*)translateW3Dict:(NSDictionary*)dict forProperty:(ABPropertyID)prop;
-- (bool)setMultiValueStrings:(NSArray*)fieldArray forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate;
-- (bool)setMultiValueDictionary:(NSArray*)array forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate;
-- (ABMultiValueRef)allocStringMultiValueFromArray:array;
-- (ABMultiValueRef)allocDictMultiValueFromArray:array forProperty:(ABPropertyID)prop;
-- (BOOL)foundValue:(NSString*)testValue inFields:(NSDictionary*)searchFields;
-- (BOOL)testStringValue:(NSString*)testValue forW3CProperty:(NSString*)property;
-- (BOOL)testDateValue:(NSString*)testValue forW3CProperty:(NSString*)property;
-- (BOOL)searchContactFields:(NSArray*)fields forMVStringProperty:(ABPropertyID)propId withValue:testValue;
-- (BOOL)testMultiValueStrings:(NSString*)testValue forProperty:(ABPropertyID)propId ofType:(NSString*)type;
-- (NSArray*)valuesForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord;
-- (NSArray*)labelsForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord;
-- (BOOL)searchContactFields:(NSArray*)fields forMVDictionaryProperty:(ABPropertyID)propId withValue:(NSString*)testValue;
-
-@end
-
-// generic ContactField types
-#define kW3ContactFieldType @"type"
-#define kW3ContactFieldValue @"value"
-#define kW3ContactFieldPrimary @"pref"
-// Various labels for ContactField types
-#define kW3ContactWorkLabel @"work"
-#define kW3ContactHomeLabel @"home"
-#define kW3ContactOtherLabel @"other"
-#define kW3ContactPhoneFaxLabel @"fax"
-#define kW3ContactPhoneMobileLabel @"mobile"
-#define kW3ContactPhonePagerLabel @"pager"
-#define kW3ContactUrlBlog @"blog"
-#define kW3ContactUrlProfile @"profile"
-#define kW3ContactImAIMLabel @"aim"
-#define kW3ContactImICQLabel @"icq"
-#define kW3ContactImMSNLabel @"msn"
-#define kW3ContactImYahooLabel @"yahoo"
-#define kW3ContactFieldId @"id"
-// special translation for IM field value and type
-#define kW3ContactImType @"type"
-#define kW3ContactImValue @"value"
-
-// Contact object
-#define kW3ContactId @"id"
-#define kW3ContactName @"name"
-#define kW3ContactFormattedName @"formatted"
-#define kW3ContactGivenName @"givenName"
-#define kW3ContactFamilyName @"familyName"
-#define kW3ContactMiddleName @"middleName"
-#define kW3ContactHonorificPrefix @"honorificPrefix"
-#define kW3ContactHonorificSuffix @"honorificSuffix"
-#define kW3ContactDisplayName @"displayName"
-#define kW3ContactNickname @"nickname"
-#define kW3ContactPhoneNumbers @"phoneNumbers"
-#define kW3ContactAddresses @"addresses"
-#define kW3ContactAddressFormatted @"formatted"
-#define kW3ContactStreetAddress @"streetAddress"
-#define kW3ContactLocality @"locality"
-#define kW3ContactRegion @"region"
-#define kW3ContactPostalCode @"postalCode"
-#define kW3ContactCountry @"country"
-#define kW3ContactEmails @"emails"
-#define kW3ContactIms @"ims"
-#define kW3ContactOrganizations @"organizations"
-#define kW3ContactOrganizationName @"name"
-#define kW3ContactTitle @"title"
-#define kW3ContactDepartment @"department"
-#define kW3ContactBirthday @"birthday"
-#define kW3ContactNote @"note"
-#define kW3ContactPhotos @"photos"
-#define kW3ContactCategories @"categories"
-#define kW3ContactUrls @"urls"
diff --git a/iPhone/CordovaLib/Classes/CDVContact.m b/iPhone/CordovaLib/Classes/CDVContact.m
deleted file mode 100755
index 3844525..0000000
--- a/iPhone/CordovaLib/Classes/CDVContact.m
+++ /dev/null
@@ -1,1752 +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 "CDVContact.h"
-#import "NSDictionary+Extensions.h"
-
-#define DATE_OR_NULL(dateObj) ((aDate != nil) ? (id)([aDate descriptionWithLocale:[NSLocale currentLocale]]) : (id)([NSNull null]))
-#define IS_VALID_VALUE(value) ((value != nil) && (![value isKindOfClass:[NSNull class]]))
-
-static NSDictionary* org_apache_cordova_contacts_W3CtoAB = nil;
-static NSDictionary* org_apache_cordova_contacts_ABtoW3C = nil;
-static NSSet* org_apache_cordova_contacts_W3CtoNull = nil;
-static NSDictionary* org_apache_cordova_contacts_objectAndProperties = nil;
-static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
-
-@implementation CDVContact : NSObject
-
- @synthesize returnFields;
-
-- (id)init
-{
- if ((self = [super init]) != nil) {
- ABRecordRef rec = ABPersonCreate();
- self.record = rec;
- if (rec) {
- CFRelease(rec);
- }
- }
- return self;
-}
-
-- (id)initFromABRecord:(ABRecordRef)aRecord
-{
- if ((self = [super init]) != nil) {
- self.record = aRecord;
- }
- return self;
-}
-
-/* synthesize 'record' ourselves to have retain properties for CF types */
-
-- (void)setRecord:(ABRecordRef)aRecord
-{
- if (record != NULL) {
- CFRelease(record);
- }
- if (aRecord != NULL) {
- record = CFRetain(aRecord);
- }
-}
-
-- (ABRecordRef)record
-{
- return record;
-}
-
-/* Rather than creating getters and setters for each AddressBook (AB) Property, generic methods are used to deal with
- * simple properties, MultiValue properties( phone numbers and emails) and MultiValueDictionary properties (Ims and addresses).
- * The dictionaries below are used to translate between the W3C identifiers and the AB properties. Using the dictionaries,
- * allows looping through sets of properties to extract from or set into the W3C dictionary to/from the ABRecord.
- */
-
-/* The two following dictionaries translate between W3C properties and AB properties. It currently mixes both
- * Properties (kABPersonAddressProperty for example) and Strings (kABPersonAddressStreetKey) so users should be aware of
- * what types of values are expected.
- * a bit.
-*/
-+ (NSDictionary*)defaultABtoW3C
-{
- if (org_apache_cordova_contacts_ABtoW3C == nil) {
- org_apache_cordova_contacts_ABtoW3C = [NSDictionary dictionaryWithObjectsAndKeys:
- kW3ContactNickname, [NSNumber numberWithInt:kABPersonNicknameProperty],
- kW3ContactGivenName, [NSNumber numberWithInt:kABPersonFirstNameProperty],
- kW3ContactFamilyName, [NSNumber numberWithInt:kABPersonLastNameProperty],
- kW3ContactMiddleName, [NSNumber numberWithInt:kABPersonMiddleNameProperty],
- kW3ContactHonorificPrefix, [NSNumber numberWithInt:kABPersonPrefixProperty],
- kW3ContactHonorificSuffix, [NSNumber numberWithInt:kABPersonSuffixProperty],
- kW3ContactPhoneNumbers, [NSNumber numberWithInt:kABPersonPhoneProperty],
- kW3ContactAddresses, [NSNumber numberWithInt:kABPersonAddressProperty],
- kW3ContactStreetAddress, kABPersonAddressStreetKey,
- kW3ContactLocality, kABPersonAddressCityKey,
- kW3ContactRegion, kABPersonAddressStateKey,
- kW3ContactPostalCode, kABPersonAddressZIPKey,
- kW3ContactCountry, kABPersonAddressCountryKey,
- kW3ContactEmails, [NSNumber numberWithInt:kABPersonEmailProperty],
- kW3ContactIms, [NSNumber numberWithInt:kABPersonInstantMessageProperty],
- kW3ContactOrganizations, [NSNumber numberWithInt:kABPersonOrganizationProperty],
- kW3ContactOrganizationName, [NSNumber numberWithInt:kABPersonOrganizationProperty],
- kW3ContactTitle, [NSNumber numberWithInt:kABPersonJobTitleProperty],
- kW3ContactDepartment, [NSNumber numberWithInt:kABPersonDepartmentProperty],
- kW3ContactBirthday, [NSNumber numberWithInt:kABPersonBirthdayProperty],
- kW3ContactUrls, [NSNumber numberWithInt:kABPersonURLProperty],
- kW3ContactNote, [NSNumber numberWithInt:kABPersonNoteProperty],
- nil];
- }
-
- return org_apache_cordova_contacts_ABtoW3C;
-}
-
-+ (NSDictionary*)defaultW3CtoAB
-{
- if (org_apache_cordova_contacts_W3CtoAB == nil) {
- org_apache_cordova_contacts_W3CtoAB = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:kABPersonNicknameProperty], kW3ContactNickname,
- [NSNumber numberWithInt:kABPersonFirstNameProperty], kW3ContactGivenName,
- [NSNumber numberWithInt:kABPersonLastNameProperty], kW3ContactFamilyName,
- [NSNumber numberWithInt:kABPersonMiddleNameProperty], kW3ContactMiddleName,
- [NSNumber numberWithInt:kABPersonPrefixProperty], kW3ContactHonorificPrefix,
- [NSNumber numberWithInt:kABPersonSuffixProperty], kW3ContactHonorificSuffix,
- [NSNumber numberWithInt:kABPersonPhoneProperty], kW3ContactPhoneNumbers,
- [NSNumber numberWithInt:kABPersonAddressProperty], kW3ContactAddresses,
- kABPersonAddressStreetKey, kW3ContactStreetAddress,
- kABPersonAddressCityKey, kW3ContactLocality,
- kABPersonAddressStateKey, kW3ContactRegion,
- kABPersonAddressZIPKey, kW3ContactPostalCode,
- kABPersonAddressCountryKey, kW3ContactCountry,
- [NSNumber numberWithInt:kABPersonEmailProperty], kW3ContactEmails,
- [NSNumber numberWithInt:kABPersonInstantMessageProperty], kW3ContactIms,
- [NSNumber numberWithInt:kABPersonOrganizationProperty], kW3ContactOrganizations,
- [NSNumber numberWithInt:kABPersonJobTitleProperty], kW3ContactTitle,
- [NSNumber numberWithInt:kABPersonDepartmentProperty], kW3ContactDepartment,
- [NSNumber numberWithInt:kABPersonBirthdayProperty], kW3ContactBirthday,
- [NSNumber numberWithInt:kABPersonNoteProperty], kW3ContactNote,
- [NSNumber numberWithInt:kABPersonURLProperty], kW3ContactUrls,
- kABPersonInstantMessageUsernameKey, kW3ContactImValue,
- kABPersonInstantMessageServiceKey, kW3ContactImType,
- [NSNull null], kW3ContactFieldType, /* include entries in dictionary to indicate ContactField properties */
- [NSNull null], kW3ContactFieldValue,
- [NSNull null], kW3ContactFieldPrimary,
- [NSNull null], kW3ContactFieldId,
- [NSNumber numberWithInt:kABPersonOrganizationProperty], kW3ContactOrganizationName, /* careful, name is used multiple times*/
- nil];
- }
- return org_apache_cordova_contacts_W3CtoAB;
-}
-
-+ (NSSet*)defaultW3CtoNull
-{
- // these are values that have no AddressBook Equivalent OR have not been implemented yet
- if (org_apache_cordova_contacts_W3CtoNull == nil) {
- org_apache_cordova_contacts_W3CtoNull = [NSSet setWithObjects:kW3ContactDisplayName,
- kW3ContactCategories, kW3ContactFormattedName, nil];
- }
- return org_apache_cordova_contacts_W3CtoNull;
-}
-
-/*
- * The objectAndProperties dictionary contains the all of the properties of the W3C Contact Objects specified by the key
- * Used in calcReturnFields, and various extract<Property> methods
- */
-+ (NSDictionary*)defaultObjectAndProperties
-{
- if (org_apache_cordova_contacts_objectAndProperties == nil) {
- org_apache_cordova_contacts_objectAndProperties = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSArray arrayWithObjects:kW3ContactGivenName, kW3ContactFamilyName,
- kW3ContactMiddleName, kW3ContactHonorificPrefix, kW3ContactHonorificSuffix, kW3ContactFormattedName, nil], kW3ContactName,
- [NSArray arrayWithObjects:kW3ContactStreetAddress, kW3ContactLocality, kW3ContactRegion,
- kW3ContactPostalCode, kW3ContactCountry, /*kW3ContactAddressFormatted,*/ nil], kW3ContactAddresses,
- [NSArray arrayWithObjects:kW3ContactOrganizationName, kW3ContactTitle, kW3ContactDepartment, nil], kW3ContactOrganizations,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactPhoneNumbers,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactEmails,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactPhotos,
- [NSArray arrayWithObjects:kW3ContactFieldType, kW3ContactFieldValue, kW3ContactFieldPrimary, nil], kW3ContactUrls,
- [NSArray arrayWithObjects:kW3ContactImValue, kW3ContactImType, nil], kW3ContactIms,
- nil];
- }
- return org_apache_cordova_contacts_objectAndProperties;
-}
-
-+ (NSDictionary*)defaultFields
-{
- if (org_apache_cordova_contacts_defaultFields == nil) {
- org_apache_cordova_contacts_defaultFields = [NSDictionary dictionaryWithObjectsAndKeys:
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactName], kW3ContactName,
- [NSNull null], kW3ContactNickname,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactAddresses], kW3ContactAddresses,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactOrganizations], kW3ContactOrganizations,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactPhoneNumbers], kW3ContactPhoneNumbers,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactEmails], kW3ContactEmails,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactIms], kW3ContactIms,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactPhotos], kW3ContactPhotos,
- [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactUrls], kW3ContactUrls,
- [NSNull null], kW3ContactBirthday,
- [NSNull null], kW3ContactNote,
- nil];
- }
- return org_apache_cordova_contacts_defaultFields;
-}
-
-/* Translate W3C Contact data into ABRecordRef
- *
- * New contact information comes in as a NSMutableDictionary. All Null entries in Contact object are set
- * as [NSNull null] in the dictionary when translating from the JSON input string of Contact data. However, if
- * user did not set a value within a Contact object or sub-object (by not using the object constructor) some data
- * may not exist.
- * bUpdate = YES indicates this is a save of an existing record
- */
-- (bool)setFromContactDict:(NSDictionary*)aContact asUpdate:(BOOL)bUpdate
-{
- if (![aContact isKindOfClass:[NSDictionary class]]) {
- return FALSE; // can't do anything if no dictionary!
- }
-
- ABRecordRef person = self.record;
- bool bSuccess = TRUE;
- CFErrorRef error;
-
- // set name info
- // iOS doesn't have displayName - might have to pull parts from it to create name
- bool bName = false;
- NSDictionary* dict = [aContact valueForKey:kW3ContactName];
- if ([dict isKindOfClass:[NSDictionary class]]) {
- bName = true;
- NSArray* propArray = [[CDVContact defaultObjectAndProperties] objectForKey:kW3ContactName];
-
- for (id i in propArray) {
- if (![(NSString*)i isEqualToString : kW3ContactFormattedName]) { // kW3ContactFormattedName is generated from ABRecordCopyCompositeName() and can't be set
- [self setValue:[dict valueForKey:i] forProperty:(ABPropertyID)[(NSNumber*)[[CDVContact defaultW3CtoAB] objectForKey:i] intValue]
- inRecord:person asUpdate:bUpdate];
- }
- }
- }
-
- id nn = [aContact valueForKey:kW3ContactNickname];
- if (![nn isKindOfClass:[NSNull class]]) {
- bName = true;
- [self setValue:nn forProperty:kABPersonNicknameProperty inRecord:person asUpdate:bUpdate];
- }
- if (!bName) {
- // if no name or nickname - try and use displayName as W3Contact must have displayName or ContactName
- [self setValue:[aContact valueForKey:kW3ContactDisplayName] forProperty:kABPersonNicknameProperty
- inRecord:person asUpdate:bUpdate];
- }
-
- // set phoneNumbers
- // NSLog(@"setting phoneNumbers");
- NSArray* array = [aContact valueForKey:kW3ContactPhoneNumbers];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueStrings:array forProperty:kABPersonPhoneProperty inRecord:person asUpdate:bUpdate];
- }
- // set Emails
- // NSLog(@"setting emails");
- array = [aContact valueForKey:kW3ContactEmails];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueStrings:array forProperty:kABPersonEmailProperty inRecord:person asUpdate:bUpdate];
- }
- // set Urls
- // NSLog(@"setting urls");
- array = [aContact valueForKey:kW3ContactUrls];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueStrings:array forProperty:kABPersonURLProperty inRecord:person asUpdate:bUpdate];
- }
-
- // set multivalue dictionary properties
- // set addresses: streetAddress, locality, region, postalCode, country
- // set ims: value = username, type = servicetype
- // iOS addresses and im are a MultiValue Properties with label, value=dictionary of info, and id
- // NSLog(@"setting addresses");
- error = nil;
- array = [aContact valueForKey:kW3ContactAddresses];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueDictionary:array forProperty:kABPersonAddressProperty inRecord:person asUpdate:bUpdate];
- }
- // ims
- // NSLog(@"setting ims");
- array = [aContact valueForKey:kW3ContactIms];
- if ([array isKindOfClass:[NSArray class]]) {
- [self setMultiValueDictionary:array forProperty:kABPersonInstantMessageProperty inRecord:person asUpdate:bUpdate];
- }
-
- // organizations
- // W3C ContactOrganization has pref, type, name, title, department
- // iOS only supports name, title, department
- // NSLog(@"setting organizations");
- // TODO this may need work - should Organization information be removed when array is empty??
- array = [aContact valueForKey:kW3ContactOrganizations]; // iOS only supports one organization - use first one
- if ([array isKindOfClass:[NSArray class]]) {
- BOOL bRemove = NO;
- NSDictionary* dict = nil;
- if ([array count] > 0) {
- dict = [array objectAtIndex:0];
- } else {
- // remove the organization info entirely
- bRemove = YES;
- }
- if ([dict isKindOfClass:[NSDictionary class]] || (bRemove == YES)) {
- [self setValue:(bRemove ? @"" : [dict valueForKey:@"name"]) forProperty:kABPersonOrganizationProperty inRecord:person asUpdate:bUpdate];
- [self setValue:(bRemove ? @"" : [dict valueForKey:kW3ContactTitle]) forProperty:kABPersonJobTitleProperty inRecord:person asUpdate:bUpdate];
- [self setValue:(bRemove ? @"" : [dict valueForKey:kW3ContactDepartment]) forProperty:kABPersonDepartmentProperty inRecord:person asUpdate:bUpdate];
- }
- }
- // add dates
- // Dates come in as milliseconds in NSNumber Object
- id ms = [aContact valueForKey:kW3ContactBirthday];
- NSDate* aDate = nil;
- if (ms && [ms isKindOfClass:[NSNumber class]]) {
- double msValue = [ms doubleValue];
- msValue = msValue / 1000;
- aDate = [NSDate dateWithTimeIntervalSince1970:msValue];
- }
- if ((aDate != nil) || [ms isKindOfClass:[NSString class]]) {
- [self setValue:aDate != nil ? aDate:ms forProperty:kABPersonBirthdayProperty inRecord:person asUpdate:bUpdate];
- }
- // don't update creation date
- // modification date will get updated when save
- // anniversary is removed from W3C Contact api Dec 9, 2010 spec - don't waste time on it yet
-
- // kABPersonDateProperty
-
- // kABPersonAnniversaryLabel
-
- // iOS doesn't have gender - ignore
- // note
- [self setValue:[aContact valueForKey:kW3ContactNote] forProperty:kABPersonNoteProperty inRecord:person asUpdate:bUpdate];
-
- // iOS doesn't have preferredName- ignore
-
- // photo
- array = [aContact valueForKey:kW3ContactPhotos];
- if ([array isKindOfClass:[NSArray class]]) {
- if (bUpdate && ([array count] == 0)) {
- // remove photo
- bSuccess = ABPersonRemoveImageData(person, &error);
- } else if ([array count] > 0) {
- NSDictionary* dict = [array objectAtIndex:0]; // currently only support one photo
- if ([dict isKindOfClass:[NSDictionary class]]) {
- id value = [dict objectForKey:kW3ContactFieldValue];
- if ([value isKindOfClass:[NSString class]]) {
- if (bUpdate && ([value length] == 0)) {
- // remove the current image
- bSuccess = ABPersonRemoveImageData(person, &error);
- } else {
- // use this image
- // don't know if string is encoded or not so first unencode it then encode it again
- NSString* cleanPath = [value stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL* photoUrl = [NSURL URLWithString:[cleanPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
- // caller is responsible for checking for a connection, if no connection this will fail
- NSError* err = nil;
- NSData* data = nil;
- if (photoUrl) {
- data = [NSData dataWithContentsOfURL:photoUrl options:NSDataReadingUncached error:&err];
- }
- if (data && ([data length] > 0)) {
- bSuccess = ABPersonSetImageData(person, (__bridge CFDataRef)data, &error);
- }
- if (!data || !bSuccess) {
- NSLog(@"error setting contact image: %@", (err != nil ? [err localizedDescription] : @""));
- }
- }
- }
- }
- }
- }
-
- // TODO WebURLs
-
- // TODO timezone
-
- return bSuccess;
-}
-
-/* Set item into an AddressBook Record for the specified property.
- * aValue - the value to set into the address book (code checks for null or [NSNull null]
- * aProperty - AddressBook property ID
- * aRecord - the record to update
- * bUpdate - whether this is a possible update vs a new entry
- * RETURN
- * true - property was set (or input value as null)
- * false - property was not set
- */
-- (bool)setValue:(id)aValue forProperty:(ABPropertyID)aProperty inRecord:(ABRecordRef)aRecord asUpdate:(BOOL)bUpdate
-{
- bool bSuccess = true; // if property was null, just ignore and return success
- CFErrorRef error;
-
- if (aValue && ![aValue isKindOfClass:[NSNull class]]) {
- if (bUpdate && ([aValue isKindOfClass:[NSString class]] && ([aValue length] == 0))) { // if updating, empty string means to delete
- aValue = NULL;
- } // really only need to set if different - more efficient to just update value or compare and only set if necessary???
- bSuccess = ABRecordSetValue(aRecord, aProperty, (__bridge CFTypeRef)aValue, &error);
- if (!bSuccess) {
- NSLog(@"error setting %d property", aProperty);
- }
- }
-
- return bSuccess;
-}
-
-- (bool)removeProperty:(ABPropertyID)aProperty inRecord:(ABRecordRef)aRecord
-{
- CFErrorRef err;
- bool bSuccess = ABRecordRemoveValue(aRecord, aProperty, &err);
-
- if (!bSuccess) {
- CFStringRef errDescription = CFErrorCopyDescription(err);
- NSLog(@"Unable to remove property %d: %@", aProperty, errDescription);
- CFRelease(errDescription);
- }
- return bSuccess;
-}
-
-- (bool)addToMultiValue:(ABMultiValueRef)multi fromDictionary:dict
-{
- bool bSuccess = FALSE;
- id value = [dict valueForKey:kW3ContactFieldValue];
-
- if (IS_VALID_VALUE(value)) {
- CFStringRef label = [CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
- bSuccess = ABMultiValueAddValueAndLabel(multi, (__bridge CFTypeRef)value, label, NULL);
- if (!bSuccess) {
- NSLog(@"Error setting Value: %@ and label: %@", value, label);
- }
- }
- return bSuccess;
-}
-
-- (ABMultiValueRef)allocStringMultiValueFromArray:array
-{
- ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABMultiStringPropertyType);
-
- for (NSDictionary* dict in array) {
- [self addToMultiValue:multi fromDictionary:dict];
- }
-
- return multi; // caller is responsible for releasing multi
-}
-
-- (bool)setValue:(CFTypeRef)value forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person
-{
- CFErrorRef error;
- bool bSuccess = ABRecordSetValue(person, prop, value, &error);
-
- if (!bSuccess) {
- NSLog(@"Error setting value for property: %d", prop);
- }
- return bSuccess;
-}
-
-/* Set MultiValue string properties into Address Book Record.
- * NSArray* fieldArray - array of dictionaries containing W3C properties to be set into record
- * ABPropertyID prop - the property to be set (generally used for phones and emails)
- * ABRecordRef person - the record to set values into
- * BOOL bUpdate - whether or not to update date or set as new.
- * When updating:
- * empty array indicates to remove entire property
- * empty string indicates to remove
- * [NSNull null] do not modify (keep existing record value)
- * RETURNS
- * bool false indicates error
- *
- * used for phones and emails
- */
-- (bool)setMultiValueStrings:(NSArray*)fieldArray forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate
-{
- bool bSuccess = TRUE;
- ABMutableMultiValueRef multi = nil;
-
- if (!bUpdate) {
- multi = [self allocStringMultiValueFromArray:fieldArray];
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- } else if (bUpdate && ([fieldArray count] == 0)) {
- // remove entire property
- bSuccess = [self removeProperty:prop inRecord:person];
- } else { // check for and apply changes
- ABMultiValueRef copy = ABRecordCopyValue(person, prop);
- if (copy != nil) {
- multi = ABMultiValueCreateMutableCopy(copy);
- CFRelease(copy);
-
- for (NSDictionary* dict in fieldArray) {
- id val;
- NSString* label = nil;
- val = [dict valueForKey:kW3ContactFieldValue];
- label = (__bridge NSString*)[CDVContact convertContactTypeToPropertyLabel:[dict valueForKey:kW3ContactFieldType]];
- if (IS_VALID_VALUE(val)) {
- // is an update, find index of entry with matching id, if values are different, update.
- id idValue = [dict valueForKey:kW3ContactFieldId];
- int identifier = [idValue isKindOfClass:[NSNumber class]] ? [idValue intValue] : -1;
- CFIndex i = identifier >= 0 ? ABMultiValueGetIndexForIdentifier(multi, identifier) : kCFNotFound;
- if (i != kCFNotFound) {
- if ([val length] == 0) {
- // remove both value and label
- ABMultiValueRemoveValueAndLabelAtIndex(multi, i);
- } else {
- NSString* valueAB = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, i);
- NSString* labelAB = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
- if ((valueAB == nil) || ![val isEqualToString:valueAB]) {
- ABMultiValueReplaceValueAtIndex(multi, (__bridge CFTypeRef)val, i);
- }
- if ((labelAB == nil) || ![label isEqualToString:labelAB]) {
- ABMultiValueReplaceLabelAtIndex(multi, (__bridge CFStringRef)label, i);
- }
- }
- } else {
- // is a new value - insert
- [self addToMultiValue:multi fromDictionary:dict];
- }
- } // end of if value
- } // end of for
- } else { // adding all new value(s)
- multi = [self allocStringMultiValueFromArray:fieldArray];
- }
- // set the (updated) copy as the new value
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- }
-
- if (multi) {
- CFRelease(multi);
- }
-
- return bSuccess;
-}
-
-// used for ims and addresses
-- (ABMultiValueRef)allocDictMultiValueFromArray:array forProperty:(ABPropertyID)prop
-{
- ABMutableMultiValueRef multi = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
- NSMutableDictionary* newDict;
- NSMutableDictionary* addDict;
-
- for (NSDictionary* dict in array) {
- newDict = [self translateW3Dict:dict forProperty:prop];
- addDict = [NSMutableDictionary dictionaryWithCapacity:2];
- if (newDict) { // create a new dictionary with a Label and Value, value is the dictionary previously created
- // June, 2011 W3C Contact spec adds type into ContactAddress book
- // get the type out of the original dictionary for address
- NSString* addrType = (NSString*)[dict valueForKey:kW3ContactFieldType];
- if (!addrType) {
- addrType = (NSString*)kABOtherLabel;
- }
- NSObject* typeValue = ((prop == kABPersonInstantMessageProperty) ? (NSObject*)kABOtherLabel : addrType);
- // NSLog(@"typeValue: %@", typeValue);
- [addDict setObject:typeValue forKey:kW3ContactFieldType]; // im labels will be set as Other and address labels as type from dictionary
- [addDict setObject:newDict forKey:kW3ContactFieldValue];
- [self addToMultiValue:multi fromDictionary:addDict];
- }
- }
-
- return multi; // caller is responsible for releasing
-}
-
-// used for ims and addresses to convert W3 dictionary of values to AB Dictionary
-// got messier when June, 2011 W3C Contact spec added type field into ContactAddress
-- (NSMutableDictionary*)translateW3Dict:(NSDictionary*)dict forProperty:(ABPropertyID)prop
-{
- NSArray* propArray = [[CDVContact defaultObjectAndProperties] valueForKey:[[CDVContact defaultABtoW3C] objectForKey:[NSNumber numberWithInt:prop]]];
-
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:1];
- id value;
-
- for (NSString* key in propArray) { // for each W3 Contact key get the value
- if (((value = [dict valueForKey:key]) != nil) && ![value isKindOfClass:[NSNull class]]) {
- // if necessary convert the W3 value to AB Property label
- NSString* setValue = value;
- if ([CDVContact needsConversion:key]) { // IM types must be converted
- setValue = (NSString*)[CDVContact convertContactTypeToPropertyLabel:value];
- // IMs must have a valid AB value!
- if ((prop == kABPersonInstantMessageProperty) && [setValue isEqualToString:(NSString*)kABOtherLabel]) {
- setValue = @""; // try empty string
- }
- }
- // set the AB value into the dictionary
- [newDict setObject:setValue forKey:(NSString*)[[CDVContact defaultW3CtoAB] valueForKey:(NSString*)key]];
- }
- }
-
- if ([newDict count] == 0) {
- newDict = nil; // no items added
- }
- return newDict;
-}
-
-/* set multivalue dictionary properties into an AddressBook Record
- * NSArray* array - array of dictionaries containing the W3C properties to set into the record
- * ABPropertyID prop - the property id for the multivalue dictionary (addresses and ims)
- * ABRecordRef person - the record to set the values into
- * BOOL bUpdate - YES if this is an update to an existing record
- * When updating:
- * empty array indicates to remove entire property
- * value/label == "" indicates to remove
- * value/label == [NSNull null] do not modify (keep existing record value)
- * RETURN
- * bool false indicates fatal error
- *
- * iOS addresses and im are a MultiValue Properties with label, value=dictionary of info, and id
- * set addresses: streetAddress, locality, region, postalCode, country
- * set ims: value = username, type = servicetype
- * there are some special cases in here for ims - needs cleanup / simplification
- *
- */
-- (bool)setMultiValueDictionary:(NSArray*)array forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate
-{
- bool bSuccess = FALSE;
- ABMutableMultiValueRef multi = nil;
-
- if (!bUpdate) {
- multi = [self allocDictMultiValueFromArray:array forProperty:prop];
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- } else if (bUpdate && ([array count] == 0)) {
- // remove property
- bSuccess = [self removeProperty:prop inRecord:person];
- } else { // check for and apply changes
- ABMultiValueRef copy = ABRecordCopyValue(person, prop);
- if (copy) {
- multi = ABMultiValueCreateMutableCopy(copy);
- CFRelease(copy);
- // get the W3C values for this property
- NSArray* propArray = [[CDVContact defaultObjectAndProperties] valueForKey:[[CDVContact defaultABtoW3C] objectForKey:[NSNumber numberWithInt:prop]]];
- id value;
- id valueAB;
-
- for (NSDictionary* field in array) {
- NSMutableDictionary* dict;
- // find the index for the current property
- id idValue = [field valueForKey:kW3ContactFieldId];
- int identifier = [idValue isKindOfClass:[NSNumber class]] ? [idValue intValue] : -1;
- CFIndex idx = identifier >= 0 ? ABMultiValueGetIndexForIdentifier(multi, identifier) : kCFNotFound;
- BOOL bUpdateLabel = NO;
- if (idx != kCFNotFound) {
- dict = [NSMutableDictionary dictionaryWithCapacity:1];
- // NSDictionary* existingDictionary = (NSDictionary*)ABMultiValueCopyValueAtIndex(multi, idx);
- CFTypeRef existingDictionary = ABMultiValueCopyValueAtIndex(multi, idx);
- NSString* existingABLabel = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, idx);
- NSString* testLabel = [field valueForKey:kW3ContactFieldType];
- // fixes cb-143 where setting empty label could cause address to not be removed
- // (because empty label would become 'other' in convertContactTypeToPropertyLabel
- // which may not have matched existing label thus resulting in an incorrect updating of the label
- // and the address not getting removed at the end of the for loop)
- if (testLabel && [testLabel isKindOfClass:[NSString class]] && ([testLabel length] > 0)) {
- CFStringRef w3cLabel = [CDVContact convertContactTypeToPropertyLabel:testLabel];
- if (w3cLabel && ![existingABLabel isEqualToString:(__bridge NSString*)w3cLabel]) {
- // replace the label
- ABMultiValueReplaceLabelAtIndex(multi, w3cLabel, idx);
- bUpdateLabel = YES;
- }
- } // else was invalid or empty label string so do not update
-
- for (id k in propArray) {
- value = [field valueForKey:k];
- bool bSet = (value != nil && ![value isKindOfClass:[NSNull class]] && ([value isKindOfClass:[NSString class]] && [value length] > 0));
- // if there is a contact value, put it into dictionary
- if (bSet) {
- NSString* setValue = [CDVContact needsConversion:(NSString*)k] ? (NSString*)[CDVContact convertContactTypeToPropertyLabel:value] : value;
- [dict setObject:setValue forKey:(NSString*)[[CDVContact defaultW3CtoAB] valueForKey:(NSString*)k]];
- } else if ((value == nil) || ([value isKindOfClass:[NSString class]] && ([value length] != 0))) {
- // value not provided in contact dictionary - if prop exists in AB dictionary, preserve it
- valueAB = [(__bridge NSDictionary*)existingDictionary valueForKey : [[CDVContact defaultW3CtoAB] valueForKey:k]];
- if (valueAB != nil) {
- [dict setValue:valueAB forKey:[[CDVContact defaultW3CtoAB] valueForKey:k]];
- }
- } // else if value == "" it will not be added into updated dict and thus removed
- } // end of for loop (moving here fixes cb-143, need to end for loop before replacing or removing multivalue)
-
- if ([dict count] > 0) {
- // something was added into new dict,
- ABMultiValueReplaceValueAtIndex(multi, (__bridge CFTypeRef)dict, idx);
- } else if (!bUpdateLabel) {
- // nothing added into new dict and no label change so remove this property entry
- ABMultiValueRemoveValueAndLabelAtIndex(multi, idx);
- }
-
- CFRelease(existingDictionary);
- } else {
- // not found in multivalue so add it
- dict = [self translateW3Dict:field forProperty:prop];
- if (dict) {
- NSMutableDictionary* addDict = [NSMutableDictionary dictionaryWithCapacity:2];
- // get the type out of the original dictionary for address
- NSObject* typeValue = ((prop == kABPersonInstantMessageProperty) ? (NSObject*)kABOtherLabel : (NSString*)[field valueForKey:kW3ContactFieldType]);
- // NSLog(@"typeValue: %@", typeValue);
- [addDict setObject:typeValue forKey:kW3ContactFieldType]; // im labels will be set as Other and address labels as type from dictionary
- [addDict setObject:dict forKey:kW3ContactFieldValue];
- [self addToMultiValue:multi fromDictionary:addDict];
- }
- }
- } // end of looping through dictionaries
-
- // set the (updated) copy as the new value
- bSuccess = [self setValue:multi forProperty:prop inRecord:person];
- }
- } // end of copy and apply changes
- if (multi) {
- CFRelease(multi);
- }
-
- return bSuccess;
-}
-
-/* Determine which W3C labels need to be converted
- */
-+ (BOOL)needsConversion:(NSString*)W3Label
-{
- BOOL bConvert = NO;
-
- if ([W3Label isEqualToString:kW3ContactFieldType] || [W3Label isEqualToString:kW3ContactImType]) {
- bConvert = YES;
- }
- return bConvert;
-}
-
-/* Translation of property type labels contact API ---> iPhone
- *
- * phone: work, home, other, mobile, fax, pager -->
- * kABWorkLabel, kABHomeLabel, kABOtherLabel, kABPersonPhoneMobileLabel, kABPersonHomeFAXLabel || kABPersonHomeFAXLabel, kABPersonPhonePagerLabel
- * emails: work, home, other ---> kABWorkLabel, kABHomeLabel, kABOtherLabel
- * ims: aim, gtalk, icq, xmpp, msn, skype, qq, yahoo --> kABPersonInstantMessageService + (AIM, ICG, MSN, Yahoo). No support for gtalk, xmpp, skype, qq
- * addresses: work, home, other --> kABWorkLabel, kABHomeLabel, kABOtherLabel
- *
- *
- */
-+ (CFStringRef)convertContactTypeToPropertyLabel:(NSString*)label
-{
- CFStringRef type;
-
- if ([label isKindOfClass:[NSNull class]] || ![label isKindOfClass:[NSString class]]) {
- type = NULL; // no label
- } else if ([label caseInsensitiveCompare:kW3ContactWorkLabel] == NSOrderedSame) {
- type = kABWorkLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactHomeLabel] == NSOrderedSame) {
- type = kABHomeLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactOtherLabel] == NSOrderedSame) {
- type = kABOtherLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactPhoneMobileLabel] == NSOrderedSame) {
- type = kABPersonPhoneMobileLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactPhonePagerLabel] == NSOrderedSame) {
- type = kABPersonPhonePagerLabel;
- } else if ([label caseInsensitiveCompare:kW3ContactImAIMLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceAIM;
- } else if ([label caseInsensitiveCompare:kW3ContactImICQLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceICQ;
- } else if ([label caseInsensitiveCompare:kW3ContactImMSNLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceMSN;
- } else if ([label caseInsensitiveCompare:kW3ContactImYahooLabel] == NSOrderedSame) {
- type = kABPersonInstantMessageServiceYahoo;
- } else if ([label caseInsensitiveCompare:kW3ContactUrlProfile] == NSOrderedSame) {
- type = kABPersonHomePageLabel;
- } else {
- type = kABOtherLabel;
- }
-
- return type;
-}
-
-+ (NSString*)convertPropertyLabelToContactType:(NSString*)label
-{
- NSString* type = nil;
-
- if (label != nil) { // improve efficiency......
- if ([label isEqualToString:(NSString*)kABPersonPhoneMobileLabel]) {
- type = kW3ContactPhoneMobileLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonPhoneHomeFAXLabel] ||
- [label isEqualToString:(NSString*)kABPersonPhoneWorkFAXLabel]) {
- type = kW3ContactPhoneFaxLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonPhonePagerLabel]) {
- type = kW3ContactPhonePagerLabel;
- } else if ([label isEqualToString:(NSString*)kABHomeLabel]) {
- type = kW3ContactHomeLabel;
- } else if ([label isEqualToString:(NSString*)kABWorkLabel]) {
- type = kW3ContactWorkLabel;
- } else if ([label isEqualToString:(NSString*)kABOtherLabel]) {
- type = kW3ContactOtherLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceAIM]) {
- type = kW3ContactImAIMLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceICQ]) {
- type = kW3ContactImICQLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceJabber]) {
- type = kW3ContactOtherLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceMSN]) {
- type = kW3ContactImMSNLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonInstantMessageServiceYahoo]) {
- type = kW3ContactImYahooLabel;
- } else if ([label isEqualToString:(NSString*)kABPersonHomePageLabel]) {
- type = kW3ContactUrlProfile;
- } else {
- type = kW3ContactOtherLabel;
- }
- }
- return type;
-}
-
-/* Check if the input label is a valid W3C ContactField.type. This is used when searching,
- * only search field types if the search string is a valid type. If we converted any search
- * string to a ABPropertyLabel it could convert to kABOtherLabel which is probably not want
- * the user wanted to search for and could skew the results.
- */
-+ (BOOL)isValidW3ContactType:(NSString*)label
-{
- BOOL isValid = NO;
-
- if ([label isKindOfClass:[NSNull class]] || ![label isKindOfClass:[NSString class]]) {
- isValid = NO; // no label
- } else if ([label caseInsensitiveCompare:kW3ContactWorkLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactHomeLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactOtherLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactPhoneMobileLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactPhonePagerLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImAIMLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImICQLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImMSNLabel] == NSOrderedSame) {
- isValid = YES;
- } else if ([label caseInsensitiveCompare:kW3ContactImYahooLabel] == NSOrderedSame) {
- isValid = YES;
- } else {
- isValid = NO;
- }
-
- return isValid;
-}
-
-/* Create a new Contact Dictionary object from an ABRecordRef that contains information in a format such that
- * it can be returned to JavaScript callback as JSON object string.
- * Uses:
- * ABRecordRef set into Contact Object
- * NSDictionary withFields indicates which fields to return from the AddressBook Record
- *
- * JavaScript Contact:
- * @param {DOMString} id unique identifier
- * @param {DOMString} displayName
- * @param {ContactName} name
- * @param {DOMString} nickname
- * @param {ContactField[]} phoneNumbers array of phone numbers
- * @param {ContactField[]} emails array of email addresses
- * @param {ContactAddress[]} addresses array of addresses
- * @param {ContactField[]} ims instant messaging user ids
- * @param {ContactOrganization[]} organizations
- * @param {DOMString} published date contact was first created
- * @param {DOMString} updated date contact was last updated
- * @param {DOMString} birthday contact's birthday
- * @param (DOMString} anniversary contact's anniversary
- * @param {DOMString} gender contact's gender
- * @param {DOMString} note user notes about contact
- * @param {DOMString} preferredUsername
- * @param {ContactField[]} photos
- * @param {ContactField[]} tags
- * @param {ContactField[]} relationships
- * @param {ContactField[]} urls contact's web sites
- * @param {ContactAccounts[]} accounts contact's online accounts
- * @param {DOMString} timezone UTC time zone offset
- * @param {DOMString} connected
- */
-
-- (NSDictionary*)toDictionary:(NSDictionary*)withFields
-{
- // if not a person type record bail out for now
- if (ABRecordGetRecordType(self.record) != kABPersonType) {
- return NULL;
- }
- id value = nil;
- self.returnFields = withFields;
-
- NSMutableDictionary* nc = [NSMutableDictionary dictionaryWithCapacity:1]; // new contact dictionary to fill in from ABRecordRef
- // id
- [nc setObject:[NSNumber numberWithInt:ABRecordGetRecordID(self.record)] forKey:kW3ContactId];
- if (self.returnFields == nil) {
- // if no returnFields specified, W3C says to return empty contact (but Cordova will at least return id)
- return nc;
- }
- if ([self.returnFields objectForKey:kW3ContactDisplayName]) {
- // displayname requested - iOS doesn't have so return null
- [nc setObject:[NSNull null] forKey:kW3ContactDisplayName];
- // may overwrite below if requested ContactName and there are no values
- }
- // nickname
- if ([self.returnFields valueForKey:kW3ContactNickname]) {
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty);
- [nc setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactNickname];
- }
-
- // name dictionary
- // NSLog(@"getting name info");
- NSObject* data = [self extractName];
- if (data != nil) {
- [nc setObject:data forKey:kW3ContactName];
- }
- if ([self.returnFields objectForKey:kW3ContactDisplayName] && ((data == nil) || ([(NSDictionary*)data objectForKey : kW3ContactFormattedName] == [NSNull null]))) {
- // user asked for displayName which iOS doesn't support but there is no other name data being returned
- // try and use Composite Name so some name is returned
- id tryName = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
- if (tryName != nil) {
- [nc setObject:tryName forKey:kW3ContactDisplayName];
- } else {
- // use nickname or empty string
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNicknameProperty);
- [nc setObject:(value != nil) ? value:@"" forKey:kW3ContactDisplayName];
- }
- }
- // phoneNumbers array
- // NSLog(@"getting phoneNumbers");
- value = [self extractMultiValue:kW3ContactPhoneNumbers];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactPhoneNumbers];
- }
- // emails array
- // NSLog(@"getting emails");
- value = [self extractMultiValue:kW3ContactEmails];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactEmails];
- }
- // urls array
- value = [self extractMultiValue:kW3ContactUrls];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactUrls];
- }
- // addresses array
- // NSLog(@"getting addresses");
- value = [self extractAddresses];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactAddresses];
- }
- // im array
- // NSLog(@"getting ims");
- value = [self extractIms];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactIms];
- }
- // organization array (only info for one organization in iOS)
- // NSLog(@"getting organizations");
- value = [self extractOrganizations];
- if (value != nil) {
- [nc setObject:value forKey:kW3ContactOrganizations];
- }
-
- // for simple properties, could make this a bit more efficient by storing all simple properties in a single
- // array in the returnFields dictionary and setting them via a for loop through the array
-
- // add dates
- // NSLog(@"getting dates");
- NSNumber* ms;
-
- /** Contact Revision field removed from June 16, 2011 version of specification
-
- if ([self.returnFields valueForKey:kW3ContactUpdated]){
- ms = [self getDateAsNumber: kABPersonModificationDateProperty];
- if (!ms){
- // try and get published date
- ms = [self getDateAsNumber: kABPersonCreationDateProperty];
- }
- if (ms){
- [nc setObject: ms forKey:kW3ContactUpdated];
- }
-
- }
- */
-
- if ([self.returnFields valueForKey:kW3ContactBirthday]) {
- ms = [self getDateAsNumber:kABPersonBirthdayProperty];
- if (ms) {
- [nc setObject:ms forKey:kW3ContactBirthday];
- }
- }
-
- /* Anniversary removed from 12-09-2010 W3C Contacts api spec
- if ([self.returnFields valueForKey:kW3ContactAnniversary]){
- // Anniversary date is stored in a multivalue property
- ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonDateProperty);
- if (multi){
- CFStringRef label = nil;
- CFIndex count = ABMultiValueGetCount(multi);
- // see if contains an Anniversary date
- for(CFIndex i=0; i<count; i++){
- label = ABMultiValueCopyLabelAtIndex(multi, i);
- if(label && [(NSString*)label isEqualToString:(NSString*)kABPersonAnniversaryLabel]){
- CFDateRef aDate = ABMultiValueCopyValueAtIndex(multi, i);
- if(aDate){
- [nc setObject: (NSString*)aDate forKey: kW3ContactAnniversary];
- CFRelease(aDate);
- }
- CFRelease(label);
- break;
- }
- }
- CFRelease(multi);
- }
- }*/
-
- if ([self.returnFields valueForKey:kW3ContactNote]) {
- // note
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, kABPersonNoteProperty);
- [nc setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactNote];
- }
-
- if ([self.returnFields valueForKey:kW3ContactPhotos]) {
- value = [self extractPhotos];
- [nc setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactPhotos];
- }
-
- /* TimeZone removed from June 16, 2011 Contacts spec
- *
- if ([self.returnFields valueForKey:kW3ContactTimezone]){
- [NSTimeZone resetSystemTimeZone];
- NSTimeZone* currentTZ = [NSTimeZone localTimeZone];
- NSInteger seconds = [currentTZ secondsFromGMT];
- NSString* tz = [NSString stringWithFormat:@"%2d:%02u", seconds/3600, seconds % 3600 ];
- [nc setObject:tz forKey:kW3ContactTimezone];
- }
- */
- // TODO WebURLs
- // [nc setObject:[NSNull null] forKey:kW3ContactUrls];
- // online accounts - not available on iOS
-
- return nc;
-}
-
-- (NSNumber*)getDateAsNumber:(ABPropertyID)datePropId
-{
- NSNumber* msDate = nil;
- NSDate* aDate = nil;
- CFTypeRef cfDate = ABRecordCopyValue(self.record, datePropId);
-
- if (cfDate) {
- aDate = (__bridge NSDate*)cfDate;
- msDate = [NSNumber numberWithDouble:([aDate timeIntervalSince1970] * 1000)];
- CFRelease(cfDate);
- }
- return msDate;
-}
-
-/* Create Dictionary to match JavaScript ContactName object:
- * formatted - ABRecordCopyCompositeName
- * familyName
- * givenName
- * middleName
- * honorificPrefix
- * honorificSuffix
-*/
-
-- (NSObject*)extractName
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactName];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
-
- NSMutableDictionary* newName = [NSMutableDictionary dictionaryWithCapacity:6];
- id value;
-
- for (NSString* i in fields) {
- if ([i isEqualToString:kW3ContactFormattedName]) {
- value = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
- [newName setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFormattedName];
- } else {
- // W3CtoAB returns NSNumber for AB name properties, get intValue and cast to ABPropertyID)
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]);
- [newName setObject:(value != nil) ? value:[NSNull null] forKey:(NSString*)i];
- }
- }
-
- return newName;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactField object for simple multiValue properties phoneNumbers, emails
- * Input: (NSString*) W3Contact Property name
- * type
- * for phoneNumbers type is one of (work,home,other, mobile, fax, pager)
- * for emails type is one of (work,home, other)
- * value - phone number or email address
- * (bool) primary (not supported on iphone)
- * id
-*/
-- (NSObject*)extractMultiValue:(NSString*)propertyId
-{
- NSArray* fields = [self.returnFields objectForKey:propertyId];
-
- if (fields == nil) {
- return nil;
- }
- ABMultiValueRef multi = nil;
- NSObject* valuesArray = nil;
- NSNumber* propNumber = [[CDVContact defaultW3CtoAB] valueForKey:propertyId];
- ABPropertyID propId = [propNumber intValue];
- multi = ABRecordCopyValue(self.record, propId);
- // multi = ABRecordCopyValue(self.record, (ABPropertyID)[[[Contact defaultW3CtoAB] valueForKey:propertyId] intValue]);
- CFIndex count = multi != nil ? ABMultiValueGetCount(multi) : 0;
- id value;
- if (count) {
- valuesArray = [NSMutableArray arrayWithCapacity:count];
-
- for (CFIndex i = 0; i < count; i++) {
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:4];
- if ([fields containsObject:kW3ContactFieldType]) {
- NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
- value = [CDVContact convertPropertyLabelToContactType:label];
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFieldType];
- }
- if ([fields containsObject:kW3ContactFieldValue]) {
- value = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, i);
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFieldValue];
- }
- if ([fields containsObject:kW3ContactFieldPrimary]) {
- [newDict setObject:[NSNumber numberWithBool:(BOOL)NO] forKey:kW3ContactFieldPrimary]; // iOS doesn't support primary so set all to false
- }
- // always set id
- value = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFieldId];
- [(NSMutableArray*)valuesArray addObject : newDict];
- }
- } else {
- valuesArray = [NSNull null];
- }
- if (multi) {
- CFRelease(multi);
- }
-
- return valuesArray;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactAddress object for addresses
- * pref - not supported
- * type - address type
- * formatted - formatted for mailing label (what about localization?)
- * streetAddress
- * locality
- * region;
- * postalCode
- * country
- * id
- *
- * iOS addresses are a MultiValue Properties with label, value=dictionary of address info, and id
- */
-- (NSObject*)extractAddresses
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactAddresses];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
- CFStringRef value;
- NSObject* addresses;
- ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonAddressProperty);
- CFIndex count = multi ? ABMultiValueGetCount(multi) : 0;
- if (count) {
- addresses = [NSMutableArray arrayWithCapacity:count];
-
- for (CFIndex i = 0; i < count; i++) {
- NSMutableDictionary* newAddress = [NSMutableDictionary dictionaryWithCapacity:7];
- // if we got this far, at least some address info is being requested.
-
- // Always set id
- id identifier = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
- [newAddress setObject:(identifier != nil) ? identifier:[NSNull null] forKey:kW3ContactFieldId];
- // set the type label
- NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
-
- [newAddress setObject:(label != nil) ? (NSObject*)[[CDVContact class] convertPropertyLabelToContactType:label]:[NSNull null] forKey:kW3ContactFieldType];
- // set the pref - iOS doesn't support so set to default of false
- [newAddress setObject:@"false" forKey:kW3ContactFieldPrimary];
- // get dictionary of values for this address
- CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(multi, i);
-
- for (id k in fields) {
- bool bFound;
- id key = [[CDVContact defaultW3CtoAB] valueForKey:k];
- if (key && ![k isKindOfClass:[NSNull class]]) {
- bFound = CFDictionaryGetValueIfPresent(dict, (__bridge const void*)key, (void*)&value);
- if (bFound && (value != NULL)) {
- CFRetain(value);
- [newAddress setObject:(__bridge id)value forKey:k];
- CFRelease(value);
- } else {
- [newAddress setObject:[NSNull null] forKey:k];
- }
- } else {
- // was a property that iPhone doesn't support
- [newAddress setObject:[NSNull null] forKey:k];
- }
- }
-
- if ([newAddress count] > 0) { // ?? this will always be true since we set id,label,primary field??
- [(NSMutableArray*)addresses addObject : newAddress];
- }
- CFRelease(dict);
- } // end of loop through addresses
- } else {
- addresses = [NSNull null];
- }
- if (multi) {
- CFRelease(multi);
- }
-
- return addresses;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactField object for ims
- * type one of [aim, gtalk, icq, xmpp, msn, skype, qq, yahoo] needs other as well
- * value
- * (bool) primary
- * id
- *
- * iOS IMs are a MultiValue Properties with label, value=dictionary of IM details (service, username), and id
- */
-- (NSObject*)extractIms
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactIms];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
- NSObject* imArray;
- ABMultiValueRef multi = ABRecordCopyValue(self.record, kABPersonInstantMessageProperty);
- CFIndex count = multi ? ABMultiValueGetCount(multi) : 0;
- if (count) {
- imArray = [NSMutableArray arrayWithCapacity:count];
-
- for (CFIndex i = 0; i < ABMultiValueGetCount(multi); i++) {
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:3];
- // iOS has label property (work, home, other) for each IM but W3C contact API doesn't use
- CFDictionaryRef dict = (CFDictionaryRef)ABMultiValueCopyValueAtIndex(multi, i);
- CFStringRef value; // all values should be CFStringRefs / NSString*
- bool bFound;
- if ([fields containsObject:kW3ContactFieldValue]) {
- // value = user name
- bFound = CFDictionaryGetValueIfPresent(dict, kABPersonInstantMessageUsernameKey, (void*)&value);
- if (bFound && (value != NULL)) {
- CFRetain(value);
- [newDict setObject:(__bridge id)value forKey:kW3ContactFieldValue];
- CFRelease(value);
- } else {
- [newDict setObject:[NSNull null] forKey:kW3ContactFieldValue];
- }
- }
- if ([fields containsObject:kW3ContactFieldType]) {
- bFound = CFDictionaryGetValueIfPresent(dict, kABPersonInstantMessageServiceKey, (void*)&value);
- if (bFound && (value != NULL)) {
- CFRetain(value);
- [newDict setObject:(id)[[CDVContact class] convertPropertyLabelToContactType : (__bridge NSString*)value] forKey:kW3ContactFieldType];
- CFRelease(value);
- } else {
- [newDict setObject:[NSNull null] forKey:kW3ContactFieldType];
- }
- }
- // always set ID
- id identifier = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
- [newDict setObject:(identifier != nil) ? identifier:[NSNull null] forKey:kW3ContactFieldId];
-
- [(NSMutableArray*)imArray addObject : newDict];
- CFRelease(dict);
- }
- } else {
- imArray = [NSNull null];
- }
-
- if (multi) {
- CFRelease(multi);
- }
- return imArray;
-}
-
-/* Create array of Dictionaries to match JavaScript ContactOrganization object
- * pref - not supported in iOS
- * type - not supported in iOS
- * name
- * department
- * title
- */
-
-- (NSObject*)extractOrganizations
-{
- NSArray* fields = [self.returnFields objectForKey:kW3ContactOrganizations];
-
- if (fields == nil) { // no name fields requested
- return nil;
- }
- NSObject* array = nil;
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:5];
- id value;
- int validValueCount = 0;
-
- for (id i in fields) {
- id key = [[CDVContact defaultW3CtoAB] valueForKey:i];
- if (key && [key isKindOfClass:[NSNumber class]]) {
- value = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, (ABPropertyID)[[[CDVContact defaultW3CtoAB] valueForKey:i] intValue]);
- if (value != nil) {
- // if there are no organization values we should return null for organization
- // this counter keeps indicates if any organization values have been set
- validValueCount++;
- }
- [newDict setObject:(value != nil) ? value:[NSNull null] forKey:i];
- } else { // not a key iOS supports, set to null
- [newDict setObject:[NSNull null] forKey:i];
- }
- }
-
- if (([newDict count] > 0) && (validValueCount > 0)) {
- // add pref and type
- // they are not supported by iOS and thus these values never change
- [newDict setObject:@"false" forKey:kW3ContactFieldPrimary];
- [newDict setObject:[NSNull null] forKey:kW3ContactFieldType];
- array = [NSMutableArray arrayWithCapacity:1];
- [(NSMutableArray*)array addObject : newDict];
- } else {
- array = [NSNull null];
- }
- return array;
-}
-
-// W3C Contacts expects an array of photos. Can return photos in more than one format, currently
-// just returning the default format
-// Save the photo data into tmp directory and return FileURI - temp directory is deleted upon application exit
-- (NSObject*)extractPhotos
-{
- NSMutableArray* photos = nil;
-
- if (ABPersonHasImageData(self.record)) {
- CFDataRef photoData = ABPersonCopyImageData(self.record);
- NSData* data = (__bridge NSData*)photoData;
- // write to temp directory and store URI in photos array
- // get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];
- NSError* err = nil;
- NSString* filePath = [NSString stringWithFormat:@"%@/photo_XXXXX", docsPath];
- char template[filePath.length + 1];
- strcpy(template, [filePath cStringUsingEncoding:NSASCIIStringEncoding]);
- mkstemp(template);
- filePath = [[NSFileManager defaultManager]
- stringWithFileSystemRepresentation:template
- length:strlen(template)];
-
- // save file
- if ([data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- photos = [NSMutableArray arrayWithCapacity:1];
- NSMutableDictionary* newDict = [NSMutableDictionary dictionaryWithCapacity:2];
- [newDict setObject:filePath forKey:kW3ContactFieldValue];
- [newDict setObject:@"url" forKey:kW3ContactFieldType];
- [newDict setObject:@"false" forKey:kW3ContactFieldPrimary];
- [photos addObject:newDict];
- }
-
- CFRelease(photoData);
- }
- return photos;
-}
-
-/**
- * given an array of W3C Contact field names, create a dictionary of field names to extract
- * if field name represents an object, return all properties for that object: "name" - returns all properties in ContactName
- * if field name is an explicit property, return only those properties: "name.givenName - returns a ContactName with only ContactName.givenName
- * if field contains ONLY ["*"] return all fields
- * dictionary format:
- * key is W3Contact #define
- * value is NSMutableArray* for complex keys: name,addresses,organizations, phone, emails, ims
- * value is [NSNull null] for simple keys
-*/
-+ (NSDictionary*)calcReturnFields:(NSArray*)fieldsArray // NSLog(@"getting self.returnFields");
-{
- NSMutableDictionary* d = [NSMutableDictionary dictionaryWithCapacity:1];
-
- if ((fieldsArray != nil) && [fieldsArray isKindOfClass:[NSArray class]]) {
- if (([fieldsArray count] == 1) && [[fieldsArray objectAtIndex:0] isEqualToString:@"*"]) {
- return [CDVContact defaultFields]; // return all fields
- }
-
- for (id i in fieldsArray) {
- NSMutableArray* keys = nil;
- NSString* fieldStr = nil;
- if ([i isKindOfClass:[NSNumber class]]) {
- fieldStr = [i stringValue];
- } else {
- fieldStr = i;
- }
-
- // see if this is specific property request in object - object.property
- NSArray* parts = [fieldStr componentsSeparatedByString:@"."]; // returns original string if no separator found
- NSString* name = [parts objectAtIndex:0];
- NSString* property = nil;
- if ([parts count] > 1) {
- property = [parts objectAtIndex:1];
- }
- // see if this is a complex field by looking for its array of properties in objectAndProperties dictionary
- id fields = [[CDVContact defaultObjectAndProperties] objectForKey:name];
-
- // if find complex name (name,addresses,organizations, phone, emails, ims) in fields, add name as key
- // with array of associated properties as the value
- if ((fields != nil) && (property == nil)) { // request was for full object
- keys = [NSMutableArray arrayWithArray:fields];
- if (keys != nil) {
- [d setObject:keys forKey:name]; // will replace if prop array already exists
- }
- } else if ((fields != nil) && (property != nil)) {
- // found an individual property request in form of name.property
- // verify is real property name by using it as key in W3CtoAB
- id abEquiv = [[CDVContact defaultW3CtoAB] objectForKey:property];
- if (abEquiv || [[CDVContact defaultW3CtoNull] containsObject:property]) {
- // if existing array add to it
- if ((keys = [d objectForKey:name]) != nil) {
- [keys addObject:property];
- } else {
- keys = [NSMutableArray arrayWithObject:property];
- [d setObject:keys forKey:name];
- }
- } else {
- NSLog(@"Contacts.find -- request for invalid property ignored: %@.%@", name, property);
- }
- } else { // is an individual property, verify is real property name by using it as key in W3CtoAB
- id valid = [[CDVContact defaultW3CtoAB] objectForKey:name];
- if (valid || [[CDVContact defaultW3CtoNull] containsObject:name]) {
- [d setObject:[NSNull null] forKey:name];
- }
- }
- }
- }
- if ([d count] == 0) {
- // no array or nothing in the array. W3C spec says to return nothing
- return nil; // [Contact defaultFields];
- }
- return d;
-}
-
-/*
- * Search for the specified value in each of the fields specified in the searchFields dictionary.
- * NSString* value - the string value to search for (need clarification from W3C on how to search for dates)
- * NSDictionary* searchFields - a dictionary created via calcReturnFields where the key is the top level W3C
- * object and the object is the array of specific fields within that object or null if it is a single property
- * RETURNS
- * YES as soon as a match is found in any of the fields
- * NO - the specified value does not exist in any of the fields in this contact
- *
- * Note: I'm not a fan of returning in the middle of methods but have done it some in this method in order to
- * keep the code simpler. bgibson
- */
-- (BOOL)foundValue:(NSString*)testValue inFields:(NSDictionary*)searchFields
-{
- BOOL bFound = NO;
-
- if ((testValue == nil) || ![testValue isKindOfClass:[NSString class]] || ([testValue length] == 0)) {
- // nothing to find so return NO
- return NO;
- }
- NSInteger valueAsInt = [testValue integerValue];
-
- // per W3C spec, always include id in search
- int recordId = ABRecordGetRecordID(self.record);
- if (valueAsInt && (recordId == valueAsInt)) {
- return YES;
- }
-
- if (searchFields == nil) {
- // no fields to search
- return NO;
- }
-
- if ([searchFields valueForKey:kW3ContactNickname]) {
- bFound = [self testStringValue:testValue forW3CProperty:kW3ContactNickname];
- if (bFound == YES) {
- return bFound;
- }
- }
-
- if ([searchFields valueForKeyIsArray:kW3ContactName]) {
- // test name fields. All are string properties obtained via ABRecordCopyValue except kW3ContactFormattedName
- NSArray* fields = [searchFields valueForKey:kW3ContactName];
-
- for (NSString* testItem in fields) {
- if ([testItem isEqualToString:kW3ContactFormattedName]) {
- NSString* propValue = (__bridge_transfer NSString*)ABRecordCopyCompositeName(self.record);
- if ((propValue != nil) && ([propValue length] > 0)) {
- NSRange range = [propValue rangeOfString:testValue options:NSCaseInsensitiveSearch];
- bFound = (range.location != NSNotFound);
- propValue = nil;
- }
- } else {
- bFound = [self testStringValue:testValue forW3CProperty:testItem];
- }
-
- if (bFound) {
- break;
- }
- }
- }
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactPhoneNumbers]) {
- bFound = [self searchContactFields:(NSArray*)[searchFields valueForKey:kW3ContactPhoneNumbers]
- forMVStringProperty:kABPersonPhoneProperty withValue:testValue];
- }
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactEmails]) {
- bFound = [self searchContactFields:(NSArray*)[searchFields valueForKey:kW3ContactEmails]
- forMVStringProperty:kABPersonEmailProperty withValue:testValue];
- }
-
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactAddresses]) {
- bFound = [self searchContactFields:[searchFields valueForKey:kW3ContactAddresses]
- forMVDictionaryProperty:kABPersonAddressProperty withValue:testValue];
- }
-
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactIms]) {
- bFound = [self searchContactFields:[searchFields valueForKey:kW3ContactIms]
- forMVDictionaryProperty:kABPersonInstantMessageProperty withValue:testValue];
- }
-
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactOrganizations]) {
- NSArray* fields = [searchFields valueForKey:kW3ContactOrganizations];
-
- for (NSString* testItem in fields) {
- bFound = [self testStringValue:testValue forW3CProperty:testItem];
- if (bFound == YES) {
- break;
- }
- }
- }
- if (!bFound && [searchFields valueForKey:kW3ContactNote]) {
- bFound = [self testStringValue:testValue forW3CProperty:kW3ContactNote];
- }
-
- // if searching for a date field is requested, get the date field as a localized string then look for match against testValue in date string
- // searching for photos is not supported
- if (!bFound && [searchFields valueForKey:kW3ContactBirthday]) {
- bFound = [self testDateValue:testValue forW3CProperty:kW3ContactBirthday];
- }
- if (!bFound && [searchFields valueForKeyIsArray:kW3ContactUrls]) {
- bFound = [self searchContactFields:(NSArray*)[searchFields valueForKey:kW3ContactUrls]
- forMVStringProperty:kABPersonURLProperty withValue:testValue];
- }
-
- return bFound;
-}
-
-/*
- * Test for the existence of a given string within the value of a ABPersonRecord string property based on the W3c property name.
- *
- * IN:
- * NSString* testValue - the value to find - search is case insensitive
- * NSString* property - the W3c property string
- * OUT:
- * BOOL YES if the given string was found within the property value
- * NO if the testValue was not found, W3C property string was invalid or the AddressBook property was not a string
- */
-- (BOOL)testStringValue:(NSString*)testValue forW3CProperty:(NSString*)property
-{
- BOOL bFound = NO;
-
- if ([[CDVContact defaultW3CtoAB] valueForKeyIsNumber:property]) {
- ABPropertyID propId = [[[CDVContact defaultW3CtoAB] objectForKey:property] intValue];
- if (ABPersonGetTypeOfProperty(propId) == kABStringPropertyType) {
- NSString* propValue = (__bridge_transfer NSString*)ABRecordCopyValue(self.record, propId);
- if ((propValue != nil) && ([propValue length] > 0)) {
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
- bFound = [containPred evaluateWithObject:propValue];
- // NSRange range = [propValue rangeOfString:testValue options: NSCaseInsensitiveSearch];
- // bFound = (range.location != NSNotFound);
- }
- }
- }
- return bFound;
-}
-
-/*
- * Test for the existence of a given Date string within the value of a ABPersonRecord datetime property based on the W3c property name.
- *
- * IN:
- * NSString* testValue - the value to find - search is case insensitive
- * NSString* property - the W3c property string
- * OUT:
- * BOOL YES if the given string was found within the localized date string value
- * NO if the testValue was not found, W3C property string was invalid or the AddressBook property was not a DateTime
- */
-- (BOOL)testDateValue:(NSString*)testValue forW3CProperty:(NSString*)property
-{
- BOOL bFound = NO;
-
- if ([[CDVContact defaultW3CtoAB] valueForKeyIsNumber:property]) {
- ABPropertyID propId = [[[CDVContact defaultW3CtoAB] objectForKey:property] intValue];
- if (ABPersonGetTypeOfProperty(propId) == kABDateTimePropertyType) {
- NSDate* date = (__bridge_transfer NSDate*)ABRecordCopyValue(self.record, propId);
- if (date != nil) {
- NSString* dateString = [date descriptionWithLocale:[NSLocale currentLocale]];
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
- bFound = [containPred evaluateWithObject:dateString];
- }
- }
- }
- return bFound;
-}
-
-/*
- * Search the specified fields within an AddressBook multivalue string property for the specified test value.
- * Used for phoneNumbers, emails and urls.
- * IN:
- * NSArray* fields - the fields to search for within the multistring property (value and/or type)
- * ABPropertyID - the property to search
- * NSString* testValue - the value to search for. Will convert between W3C types and AB types. Will only
- * search for types if the testValue is a valid ContactField type.
- * OUT:
- * YES if the test value was found in one of the specified fields
- * NO if the test value was not found
- */
-- (BOOL)searchContactFields:(NSArray*)fields forMVStringProperty:(ABPropertyID)propId withValue:testValue
-{
- BOOL bFound = NO;
-
- for (NSString* type in fields) {
- NSString* testString = nil;
- if ([type isEqualToString:kW3ContactFieldType]) {
- if ([CDVContact isValidW3ContactType:testValue]) {
- // only search types if the filter string is a valid ContactField.type
- testString = (NSString*)[CDVContact convertContactTypeToPropertyLabel:testValue];
- }
- } else {
- testString = testValue;
- }
-
- if (testString != nil) {
- bFound = [self testMultiValueStrings:testString forProperty:propId ofType:type];
- }
- if (bFound == YES) {
- break;
- }
- }
-
- return bFound;
-}
-
-/*
- * Searches a multiString value of the specified type for the specified test value.
- *
- * IN:
- * NSString* testValue - the value to test for
- * ABPropertyID propId - the property id of the multivalue property to search
- * NSString* type - the W3C contact type to search for (value or type)
- * OUT:
- * YES is the test value was found
- * NO if the test value was not found
- */
-- (BOOL)testMultiValueStrings:(NSString*)testValue forProperty:(ABPropertyID)propId ofType:(NSString*)type
-{
- BOOL bFound = NO;
-
- if (ABPersonGetTypeOfProperty(propId) == kABMultiStringPropertyType) {
- NSArray* valueArray = nil;
- if ([type isEqualToString:kW3ContactFieldType]) {
- valueArray = [self labelsForProperty:propId inRecord:self.record];
- } else if ([type isEqualToString:kW3ContactFieldValue]) {
- valueArray = [self valuesForProperty:propId inRecord:self.record];
- }
- if (valueArray) {
- NSString* valuesAsString = [valueArray componentsJoinedByString:@" "];
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testValue];
- bFound = [containPred evaluateWithObject:valuesAsString];
- }
- }
- return bFound;
-}
-
-/*
- * Returns the array of values for a multivalue string property of the specified property id
- */
-- (__autoreleasing NSArray*)valuesForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord
-{
- ABMultiValueRef multi = ABRecordCopyValue(aRecord, propId);
- NSArray* values = (__bridge_transfer NSArray*)ABMultiValueCopyArrayOfAllValues(multi);
-
- CFRelease(multi);
- return values;
-}
-
-/*
- * Returns the array of labels for a multivalue string property of the specified property id
- */
-- (NSArray*)labelsForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord
-{
- ABMultiValueRef multi = ABRecordCopyValue(aRecord, propId);
- CFIndex count = ABMultiValueGetCount(multi);
- NSMutableArray* labels = [NSMutableArray arrayWithCapacity:count];
-
- for (int i = 0; i < count; i++) {
- NSString* label = (__bridge_transfer NSString*)ABMultiValueCopyLabelAtIndex(multi, i);
- if (label) {
- [labels addObject:label];
- }
- }
-
- CFRelease(multi);
- return labels;
-}
-
-/* search for values within MultiValue Dictionary properties Address or IM property
- * IN:
- * (NSArray*) fields - the array of W3C field names to search within
- * (ABPropertyID) propId - the AddressBook property that returns a multivalue dictionary
- * (NSString*) testValue - the string to search for within the specified fields
- *
- */
-- (BOOL)searchContactFields:(NSArray*)fields forMVDictionaryProperty:(ABPropertyID)propId withValue:(NSString*)testValue
-{
- BOOL bFound = NO;
-
- NSArray* values = [self valuesForProperty:propId inRecord:self.record]; // array of dictionaries (as CFDictionaryRef)
- int dictCount = [values count];
-
- // for ims dictionary contains with service (w3C type) and username (W3c value)
- // for addresses dictionary contains street, city, state, zip, country
- for (int i = 0; i < dictCount; i++) {
- CFDictionaryRef dict = (__bridge CFDictionaryRef)[values objectAtIndex:i];
-
- for (NSString* member in fields) {
- NSString* abKey = [[CDVContact defaultW3CtoAB] valueForKey:member]; // im and address fields are all strings
- CFStringRef abValue = nil;
- if (abKey) {
- NSString* testString = nil;
- if ([member isEqualToString:kW3ContactImType]) {
- if ([CDVContact isValidW3ContactType:testValue]) {
- // only search service/types if the filter string is a valid ContactField.type
- testString = (NSString*)[CDVContact convertContactTypeToPropertyLabel:testValue];
- }
- } else {
- testString = testValue;
- }
- if (testString != nil) {
- BOOL bExists = CFDictionaryGetValueIfPresent(dict, (__bridge const void*)abKey, (void*)&abValue);
- if (bExists) {
- CFRetain(abValue);
- NSPredicate* containPred = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", testString];
- bFound = [containPred evaluateWithObject:(__bridge id)abValue];
- CFRelease(abValue);
- }
- }
- }
- if (bFound == YES) {
- break;
- }
- } // end of for each member in fields
-
- if (bFound == YES) {
- break;
- }
- } // end of for each dictionary
-
- return bFound;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVContacts.h b/iPhone/CordovaLib/Classes/CDVContacts.h
deleted file mode 100755
index 0342f5b..0000000
--- a/iPhone/CordovaLib/Classes/CDVContacts.h
+++ /dev/null
@@ -1,151 +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 <AddressBook/ABAddressBook.h>
-#import <AddressBookUI/AddressBookUI.h>
-#import "CDVPlugin.h"
-#import "CDVContact.h"
-
-@interface CDVContacts : CDVPlugin <ABNewPersonViewControllerDelegate,
- ABPersonViewControllerDelegate,
- ABPeoplePickerNavigationControllerDelegate
- >
-{
- ABAddressBookRef addressBook;
-}
-
-/*
- * newContact - create a new contact via the GUI
- *
- * arguments:
- * 1: successCallback: this is the javascript function that will be called with the newly created contactId
- */
-- (void)newContact:(CDVInvokedUrlCommand*)command;
-
-/*
- * displayContact - IN PROGRESS
- *
- * arguments:
- * 1: recordID of the contact to display in the iPhone contact display
- * 2: successCallback - currently not used
- * 3: error callback
- * options:
- * allowsEditing: set to true to allow the user to edit the contact - currently not supported
- */
-- (void)displayContact:(CDVInvokedUrlCommand*)command;
-
-/*
- * chooseContact
- *
- * arguments:
- * 1: this is the javascript function that will be called with the contact data as a JSON object (as the first param)
- * options:
- * allowsEditing: set to true to not choose the contact, but to edit it in the iPhone contact editor
- */
-- (void)chooseContact:(CDVInvokedUrlCommand*)command;
-
-- (void)newPersonViewController:(ABNewPersonViewController*)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person;
-- (BOOL)personViewController:(ABPersonViewController*)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person
- property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue;
-
-/*
- * search - searches for contacts. Only person records are currently supported.
- *
- * arguments:
- * 1: successcallback - this is the javascript function that will be called with the array of found contacts
- * 2: errorCallback - optional javascript function to be called in the event of an error with an error code.
- * options: dictionary containing ContactFields and ContactFindOptions
- * fields - ContactFields array
- * findOptions - ContactFindOptions object as dictionary
- *
- */
-- (void)search:(CDVInvokedUrlCommand*)command;
-
-/*
- * save - saves a new contact or updates and existing contact
- *
- * arguments:
- * 1: success callback - this is the javascript function that will be called with the JSON representation of the saved contact
- * search calls a fixed navigator.service.contacts._findCallback which then calls the success callback stored before making the call into obj-c
- */
-- (void)save:(CDVInvokedUrlCommand*)command;
-
-/*
- * remove - removes a contact from the address book
- *
- * arguments:
- * 1: 1: successcallback - this is the javascript function that will be called with a (now) empty contact object
- *
- * options: dictionary containing Contact object to remove
- * contact - Contact object as dictionary
- */
-- (void)remove:(CDVInvokedUrlCommand*)command;
-
-// - (void) dealloc;
-
-@end
-
-@interface CDVContactsPicker : ABPeoplePickerNavigationController
-{
- BOOL allowsEditing;
- NSString* callbackId;
- NSDictionary* options;
- NSDictionary* pickedContactDictionary;
-}
-
-@property BOOL allowsEditing;
-@property (copy) NSString* callbackId;
-@property (nonatomic, strong) NSDictionary* options;
-@property (nonatomic, strong) NSDictionary* pickedContactDictionary;
-
-@end
-
-@interface CDVNewContactsController : ABNewPersonViewController
-{
- NSString* callbackId;
-}
-@property (copy) NSString* callbackId;
-@end
-
-/* ABPersonViewController does not have any UI to dismiss. Adding navigationItems to it does not work properly, the navigationItems are lost when the app goes into the background.
- The solution was to create an empty NavController in front of the ABPersonViewController. This
- causes the ABPersonViewController to have a back button. By subclassing the ABPersonViewController,
- we can override viewWillDisappear and take down the entire NavigationController at that time.
- */
-@interface CDVDisplayContactViewController : ABPersonViewController
-{}
-@property (nonatomic, strong) CDVPlugin* contactsPlugin;
-
-@end
-@interface CDVAddressBookAccessError : NSObject
-{}
-@property (assign) CDVContactError errorCode;
-- (CDVAddressBookAccessError*)initWithCode:(CDVContactError)code;
-@end
-
-typedef void (^ CDVAddressBookWorkerBlock)(
- ABAddressBookRef addressBook,
- CDVAddressBookAccessError* error
- );
-@interface CDVAddressBookHelper : NSObject
-{}
-
-- (void)createAddressBook:(CDVAddressBookWorkerBlock)workerBlock;
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVContacts.m b/iPhone/CordovaLib/Classes/CDVContacts.m
deleted file mode 100755
index 6cb9f08..0000000
--- a/iPhone/CordovaLib/Classes/CDVContacts.m
+++ /dev/null
@@ -1,593 +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 "CDVContacts.h"
-#import <UIKit/UIKit.h>
-#import "NSArray+Comparisons.h"
-#import "NSDictionary+Extensions.h"
-#import "CDVNotification.h"
-
-@implementation CDVContactsPicker
-
-@synthesize allowsEditing;
-@synthesize callbackId;
-@synthesize options;
-@synthesize pickedContactDictionary;
-
-@end
-@implementation CDVNewContactsController
-
-@synthesize callbackId;
-
-@end
-
-@implementation CDVContacts
-
-// no longer used since code gets AddressBook for each operation.
-// If address book changes during save or remove operation, may get error but not much we can do about it
-// If address book changes during UI creation, display or edit, we don't control any saves so no need for callback
-
-/*void addressBookChanged(ABAddressBookRef addressBook, CFDictionaryRef info, void* context)
-{
- // note that this function is only called when another AddressBook instance modifies
- // the address book, not the current one. For example, through an OTA MobileMe sync
- Contacts* contacts = (Contacts*)context;
- [contacts addressBookDirty];
-}*/
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVContacts*)[super initWithWebView:(UIWebView*)theWebView];
-
- /*if (self) {
- addressBook = ABAddressBookCreate();
- ABAddressBookRegisterExternalChangeCallback(addressBook, addressBookChanged, self);
- }*/
-
- return self;
-}
-
-// overridden to clean up Contact statics
-- (void)onAppTerminate
-{
- // NSLog(@"Contacts::onAppTerminate");
-}
-
-// iPhone only method to create a new contact through the GUI
-- (void)newContact:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errCode) {
- if (addrBook == NULL) {
- // permission was denied or other error just return (no error callback)
- return;
- }
- CDVNewContactsController* npController = [[CDVNewContactsController alloc] init];
- npController.addressBook = addrBook; // a CF retaining assign
- CFRelease(addrBook);
-
- npController.newPersonViewDelegate = self;
- npController.callbackId = callbackId;
-
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:npController];
-
- if ([weakSelf.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [weakSelf.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- [weakSelf.viewController presentModalViewController:navController animated:YES];
- }
- }];
-}
-
-- (void)newPersonViewController:(ABNewPersonViewController*)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person
-{
- ABRecordID recordId = kABRecordInvalidID;
- CDVNewContactsController* newCP = (CDVNewContactsController*)newPersonViewController;
- NSString* callbackId = newCP.callbackId;
-
- if (person != NULL) {
- // return the contact id
- recordId = ABRecordGetRecordID(person);
- }
-
- if ([newPersonViewController respondsToSelector:@selector(presentingViewController)]) {
- [[newPersonViewController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[newPersonViewController parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:recordId];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)displayContact:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- ABRecordID recordID = [[command.arguments objectAtIndex:0] intValue];
- NSDictionary* options = [command.arguments objectAtIndex:1 withDefault:[NSNull null]];
- bool bEdit = [options isKindOfClass:[NSNull class]] ? false : [options existsValue:@"true" forKey:@"allowsEditing"];
-
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errCode) {
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:errCode ? errCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
- ABRecordRef rec = ABAddressBookGetPersonWithRecordID(addrBook, recordID);
-
- if (rec) {
- CDVDisplayContactViewController* personController = [[CDVDisplayContactViewController alloc] init];
- personController.displayedPerson = rec;
- personController.personViewDelegate = self;
- personController.allowsEditing = NO;
-
- // create this so DisplayContactViewController will have a "back" button.
- UIViewController* parentController = [[UIViewController alloc] init];
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:parentController];
-
- [navController pushViewController:personController animated:YES];
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:navController animated:YES];
- }
-
- if (bEdit) {
- // create the editing controller and push it onto the stack
- ABPersonViewController* editPersonController = [[ABPersonViewController alloc] init];
- editPersonController.displayedPerson = rec;
- editPersonController.personViewDelegate = self;
- editPersonController.allowsEditing = YES;
- [navController pushViewController:editPersonController animated:YES];
- }
- } else {
- // no record, return error
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- CFRelease(addrBook);
- }];
-}
-
-- (BOOL)personViewController:(ABPersonViewController*)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person
- property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
-{
- return YES;
-}
-
-- (void)chooseContact:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:[NSNull null]];
-
- CDVContactsPicker* pickerController = [[CDVContactsPicker alloc] init];
-
- pickerController.peoplePickerDelegate = self;
- pickerController.callbackId = callbackId;
- pickerController.options = options;
- pickerController.pickedContactDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kABRecordInvalidID], kW3ContactId, nil];
- pickerController.allowsEditing = (BOOL)[options existsValue : @"true" forKey : @"allowsEditing"];
-
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
-}
-
-- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
- shouldContinueAfterSelectingPerson:(ABRecordRef)person
-{
- CDVContactsPicker* picker = (CDVContactsPicker*)peoplePicker;
- NSNumber* pickedId = [NSNumber numberWithInt:ABRecordGetRecordID(person)];
-
- if (picker.allowsEditing) {
- ABPersonViewController* personController = [[ABPersonViewController alloc] init];
- personController.displayedPerson = person;
- personController.personViewDelegate = self;
- personController.allowsEditing = picker.allowsEditing;
- // store id so can get info in peoplePickerNavigationControllerDidCancel
- picker.pickedContactDictionary = [NSDictionary dictionaryWithObjectsAndKeys:pickedId, kW3ContactId, nil];
-
- [peoplePicker pushViewController:personController animated:YES];
- } else {
- // Retrieve and return pickedContact information
- CDVContact* pickedContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)person];
- NSArray* fields = [picker.options objectForKey:@"fields"];
- NSDictionary* returnFields = [[CDVContact class] calcReturnFields:fields];
- picker.pickedContactDictionary = [pickedContact toDictionary:returnFields];
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary];
- [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId];
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
- }
- return NO;
-}
-
-- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker
- shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
-{
- return YES;
-}
-
-- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController*)peoplePicker
-{
- // return contactId or invalid if none picked
- CDVContactsPicker* picker = (CDVContactsPicker*)peoplePicker;
-
- if (picker.allowsEditing) {
- // get the info after possible edit
- // if we got this far, user has already approved/ disapproved addressBook access
- ABAddressBookRef addrBook = nil;
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- if (&ABAddressBookCreateWithOptions != NULL) {
- addrBook = ABAddressBookCreateWithOptions(NULL, NULL);
- } else
-#endif
- {
- // iOS 4 & 5
- addrBook = ABAddressBookCreate();
- }
- ABRecordRef person = ABAddressBookGetPersonWithRecordID(addrBook, [[picker.pickedContactDictionary objectForKey:kW3ContactId] integerValue]);
- if (person) {
- CDVContact* pickedContact = [[CDVContact alloc] initFromABRecord:(ABRecordRef)person];
- NSArray* fields = [picker.options objectForKey:@"fields"];
- NSDictionary* returnFields = [[CDVContact class] calcReturnFields:fields];
- picker.pickedContactDictionary = [pickedContact toDictionary:returnFields];
- }
- CFRelease(addrBook);
- }
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:picker.pickedContactDictionary];
- [self.commandDelegate sendPluginResult:result callbackId:picker.callbackId];
-
- if ([peoplePicker respondsToSelector:@selector(presentingViewController)]) {
- [[peoplePicker presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[peoplePicker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-}
-
-- (void)search:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSArray* fields = [command.arguments objectAtIndex:0];
- NSDictionary* findOptions = [command.arguments objectAtIndex:1 withDefault:[NSNull null]];
-
- [self.commandDelegate runInBackground:^{
- // from Apple: Important You must ensure that an instance of ABAddressBookRef is used by only one thread.
- // which is why address book is created within the dispatch queue.
- // more details here: http: //blog.byadrian.net/2012/05/05/ios-addressbook-framework-and-gcd/
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
- // it gets uglier, block within block.....
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errCode) {
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:errCode ? errCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- NSArray* foundRecords = nil;
- // get the findOptions values
- BOOL multiple = NO; // default is false
- NSString* filter = nil;
- if (![findOptions isKindOfClass:[NSNull class]]) {
- id value = nil;
- filter = (NSString*)[findOptions objectForKey:@"filter"];
- value = [findOptions objectForKey:@"multiple"];
- if ([value isKindOfClass:[NSNumber class]]) {
- // multiple is a boolean that will come through as an NSNumber
- multiple = [(NSNumber*)value boolValue];
- // NSLog(@"multiple is: %d", multiple);
- }
- }
-
- NSDictionary* returnFields = [[CDVContact class] calcReturnFields:fields];
-
- NSMutableArray* matches = nil;
- if (!filter || [filter isEqualToString:@""]) {
- // get all records
- foundRecords = (__bridge_transfer NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
- if (foundRecords && ([foundRecords count] > 0)) {
- // create Contacts and put into matches array
- // doesn't make sense to ask for all records when multiple == NO but better check
- int xferCount = multiple == YES ? [foundRecords count] : 1;
- matches = [NSMutableArray arrayWithCapacity:xferCount];
-
- for (int k = 0; k < xferCount; k++) {
- CDVContact* xferContact = [[CDVContact alloc] initFromABRecord:(__bridge ABRecordRef)[foundRecords objectAtIndex:k]];
- [matches addObject:xferContact];
- xferContact = nil;
- }
- }
- } else {
- foundRecords = (__bridge_transfer NSArray*)ABAddressBookCopyArrayOfAllPeople(addrBook);
- matches = [NSMutableArray arrayWithCapacity:1];
- BOOL bFound = NO;
- int testCount = [foundRecords count];
-
- for (int j = 0; j < testCount; j++) {
- CDVContact* testContact = [[CDVContact alloc] initFromABRecord:(__bridge ABRecordRef)[foundRecords objectAtIndex:j]];
- if (testContact) {
- bFound = [testContact foundValue:filter inFields:returnFields];
- if (bFound) {
- [matches addObject:testContact];
- }
- testContact = nil;
- }
- }
- }
- NSMutableArray* returnContacts = [NSMutableArray arrayWithCapacity:1];
-
- if ((matches != nil) && ([matches count] > 0)) {
- // convert to JS Contacts format and return in callback
- // - returnFields determines what properties to return
- @autoreleasepool {
- int count = multiple == YES ? [matches count] : 1;
-
- for (int i = 0; i < count; i++) {
- CDVContact* newContact = [matches objectAtIndex:i];
- NSDictionary* aContact = [newContact toDictionary:returnFields];
- [returnContacts addObject:aContact];
- }
- }
- }
- // return found contacts (array is empty if no contacts found)
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:returnContacts];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- // NSLog(@"findCallback string: %@", jsString);
-
- if (addrBook) {
- CFRelease(addrBook);
- }
- }];
- }]; // end of workQueue block
-
- return;
-}
-
-- (void)save:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* contactDict = [command.arguments objectAtIndex:0];
-
- [self.commandDelegate runInBackground:^{
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errorCode) {
- CDVPluginResult* result = nil;
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode ? errorCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- bool bIsError = FALSE, bSuccess = FALSE;
- BOOL bUpdate = NO;
- CDVContactError errCode = UNKNOWN_ERROR;
- CFErrorRef error;
- NSNumber* cId = [contactDict valueForKey:kW3ContactId];
- CDVContact* aContact = nil;
- ABRecordRef rec = nil;
- if (cId && ![cId isKindOfClass:[NSNull class]]) {
- rec = ABAddressBookGetPersonWithRecordID(addrBook, [cId intValue]);
- if (rec) {
- aContact = [[CDVContact alloc] initFromABRecord:rec];
- bUpdate = YES;
- }
- }
- if (!aContact) {
- aContact = [[CDVContact alloc] init];
- }
-
- bSuccess = [aContact setFromContactDict:contactDict asUpdate:bUpdate];
- if (bSuccess) {
- if (!bUpdate) {
- bSuccess = ABAddressBookAddRecord(addrBook, [aContact record], &error);
- }
- if (bSuccess) {
- bSuccess = ABAddressBookSave(addrBook, &error);
- }
- if (!bSuccess) { // need to provide error codes
- bIsError = TRUE;
- errCode = IO_ERROR;
- } else {
- // give original dictionary back? If generate dictionary from saved contact, have no returnFields specified
- // so would give back all fields (which W3C spec. indicates is not desired)
- // for now (while testing) give back saved, full contact
- NSDictionary* newContact = [aContact toDictionary:[CDVContact defaultFields]];
- // NSString* contactStr = [newContact JSONRepresentation];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:newContact];
- }
- } else {
- bIsError = TRUE;
- errCode = IO_ERROR;
- }
- CFRelease(addrBook);
-
- if (bIsError) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
- }
-
- if (result) {
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- }];
- }]; // end of queue
-}
-
-- (void)remove:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSNumber* cId = [command.arguments objectAtIndex:0];
-
- CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
- CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
-
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errorCode) {
- CDVPluginResult* result = nil;
- if (addrBook == NULL) {
- // permission was denied or other error - return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errorCode ? errorCode.errorCode:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- return;
- }
-
- bool bIsError = FALSE, bSuccess = FALSE;
- CDVContactError errCode = UNKNOWN_ERROR;
- CFErrorRef error;
- ABRecordRef rec = nil;
- if (cId && ![cId isKindOfClass:[NSNull class]] && ([cId intValue] != kABRecordInvalidID)) {
- rec = ABAddressBookGetPersonWithRecordID(addrBook, [cId intValue]);
- if (rec) {
- bSuccess = ABAddressBookRemoveRecord(addrBook, rec, &error);
- if (!bSuccess) {
- bIsError = TRUE;
- errCode = IO_ERROR;
- } else {
- bSuccess = ABAddressBookSave(addrBook, &error);
- if (!bSuccess) {
- bIsError = TRUE;
- errCode = IO_ERROR;
- } else {
- // set id to null
- // [contactDict setObject:[NSNull null] forKey:kW3ContactId];
- // result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: contactDict];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- // NSString* contactStr = [contactDict JSONRepresentation];
- }
- }
- } else {
- // no record found return error
- bIsError = TRUE;
- errCode = UNKNOWN_ERROR;
- }
- } else {
- // invalid contact id provided
- bIsError = TRUE;
- errCode = INVALID_ARGUMENT_ERROR;
- }
-
- if (addrBook) {
- CFRelease(addrBook);
- }
- if (bIsError) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:errCode];
- }
- if (result) {
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- }];
- return;
-}
-
-@end
-
-/* ABPersonViewController does not have any UI to dismiss. Adding navigationItems to it does not work properly
- * The navigationItems are lost when the app goes into the background. The solution was to create an empty
- * NavController in front of the ABPersonViewController. This will cause the ABPersonViewController to have a back button. By subclassing the ABPersonViewController, we can override viewDidDisappear and take down the entire NavigationController.
- */
-@implementation CDVDisplayContactViewController
-@synthesize contactsPlugin;
-
-- (void)viewWillDisappear:(BOOL)animated
-{
- [super viewWillDisappear:animated];
-
- if ([self respondsToSelector:@selector(presentingViewController)]) {
- [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
- }
-}
-
-@end
-@implementation CDVAddressBookAccessError
-
-@synthesize errorCode;
-
-- (CDVAddressBookAccessError*)initWithCode:(CDVContactError)code
-{
- self = [super init];
- if (self) {
- self.errorCode = code;
- }
- return self;
-}
-
-@end
-
-@implementation CDVAddressBookHelper
-
-/**
- * NOTE: workerBlock is responsible for releasing the addressBook that is passed to it
- */
-- (void)createAddressBook:(CDVAddressBookWorkerBlock)workerBlock
-{
- // TODO: this probably should be reworked - seems like the workerBlock can just create and release its own AddressBook,
- // and also this important warning from (http://developer.apple.com/library/ios/#documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/BasicObjects.html):
- // "Important: Instances of ABAddressBookRef cannot be used by multiple threads. Each thread must make its own instance."
- ABAddressBookRef addressBook;
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- if (&ABAddressBookCreateWithOptions != NULL) {
- CFErrorRef error = nil;
- // CFIndex status = ABAddressBookGetAuthorizationStatus();
- addressBook = ABAddressBookCreateWithOptions(NULL, &error);
- // NSLog(@"addressBook access: %lu", status);
- ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
- // callback can occur in background, address book must be accessed on thread it was created on
- dispatch_sync(dispatch_get_main_queue(), ^{
- if (error) {
- workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
- } else if (!granted) {
- workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
- } else {
- // access granted
- workerBlock(addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
- }
- });
- });
- } else
-#endif
- {
- // iOS 4 or 5 no checks needed
- addressBook = ABAddressBookCreate();
- workerBlock(addressBook, NULL);
- }
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVDebug.h b/iPhone/CordovaLib/Classes/CDVDebug.h
deleted file mode 100755
index 4a0d9f9..0000000
--- a/iPhone/CordovaLib/Classes/CDVDebug.h
+++ /dev/null
@@ -1,25 +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.
- */
-
-#ifdef DEBUG
- #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
-#else
- #define DLog(...)
-#endif
-#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
diff --git a/iPhone/CordovaLib/Classes/CDVDevice.h b/iPhone/CordovaLib/Classes/CDVDevice.h
deleted file mode 100755
index fd6ea12..0000000
--- a/iPhone/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
diff --git a/iPhone/CordovaLib/Classes/CDVDevice.m b/iPhone/CordovaLib/Classes/CDVDevice.m
deleted file mode 100755
index a331b81..0000000
--- a/iPhone/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
diff --git a/iPhone/CordovaLib/Classes/CDVEcho.h b/iPhone/CordovaLib/Classes/CDVEcho.h
deleted file mode 100755
index 76a4a96..0000000
--- a/iPhone/CordovaLib/Classes/CDVEcho.h
+++ /dev/null
@@ -1,23 +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 "CDVPlugin.h"
-
-@interface CDVEcho : CDVPlugin
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVEcho.m b/iPhone/CordovaLib/Classes/CDVEcho.m
deleted file mode 100755
index c74990d..0000000
--- a/iPhone/CordovaLib/Classes/CDVEcho.m
+++ /dev/null
@@ -1,61 +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 "CDVEcho.h"
-#import "CDV.h"
-
-@implementation CDVEcho
-
-- (void)echo:(CDVInvokedUrlCommand*)command
-{
- id message = [command.arguments objectAtIndex:0];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)echoAsyncHelper:(NSArray*)args
-{
- [self.commandDelegate sendPluginResult:[args objectAtIndex:0] callbackId:[args objectAtIndex:1]];
-}
-
-- (void)echoAsync:(CDVInvokedUrlCommand*)command
-{
- id message = [command.arguments objectAtIndex:0];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
-
- [self performSelector:@selector(echoAsyncHelper:) withObject:[NSArray arrayWithObjects:pluginResult, command.callbackId, nil] afterDelay:0];
-}
-
-- (void)echoArrayBuffer:(CDVInvokedUrlCommand*)command
-{
- id message = [command.arguments objectAtIndex:0];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArrayBuffer:message];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)echoMultiPart:(CDVInvokedUrlCommand*)command
-{
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsMultipart:command.arguments];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVExif.h b/iPhone/CordovaLib/Classes/CDVExif.h
deleted file mode 100755
index 3e8adbd..0000000
--- a/iPhone/CordovaLib/Classes/CDVExif.h
+++ /dev/null
@@ -1,43 +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.
- */
-
-#ifndef CordovaLib_ExifData_h
-#define CordovaLib_ExifData_h
-
-// exif data types
-typedef enum exifDataTypes {
- EDT_UBYTE = 1, // 8 bit unsigned integer
- EDT_ASCII_STRING, // 8 bits containing 7 bit ASCII code, null terminated
- EDT_USHORT, // 16 bit unsigned integer
- EDT_ULONG, // 32 bit unsigned integer
- EDT_URATIONAL, // 2 longs, first is numerator and second is denominator
- EDT_SBYTE,
- EDT_UNDEFINED, // 8 bits
- EDT_SSHORT,
- EDT_SLONG, // 32bit signed integer (2's complement)
- EDT_SRATIONAL, // 2 SLONGS, first long is numerator, second is denominator
- EDT_SINGLEFLOAT,
- EDT_DOUBLEFLOAT
-} ExifDataTypes;
-
-// maps integer code for exif data types to width in bytes
-static const int DataTypeToWidth[] = {1,1,2,4,8,1,1,2,4,8,4,8};
-
-static const int RECURSE_HORIZON = 8;
-#endif
diff --git a/iPhone/CordovaLib/Classes/CDVFile.h b/iPhone/CordovaLib/Classes/CDVFile.h
deleted file mode 100755
index 017b066..0000000
--- a/iPhone/CordovaLib/Classes/CDVFile.h
+++ /dev/null
@@ -1,107 +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:(NSData*)data append:(BOOL)shouldAppend callback:(NSString*)callbackId;
-- (void)writeToFile:(NSString*)fileName withString:(NSString*)data encoding:(NSStringEncoding)encoding 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"
diff --git a/iPhone/CordovaLib/Classes/CDVFile.m b/iPhone/CordovaLib/Classes/CDVFile.m
deleted file mode 100755
index 9487dd4..0000000
--- a/iPhone/CordovaLib/Classes/CDVFile.m
+++ /dev/null
@@ -1,1426 +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* or NSData* 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];
- id 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];
-
- if ([argData isKindOfClass:[NSString class]]) {
- [self writeToFile:fullPath withString:argData encoding:NSUTF8StringEncoding append:YES callback:callbackId];
- } else if ([argData isKindOfClass:[NSData class]]) {
- [self writeToFile:fullPath withData:argData append:YES callback:callbackId];
- } else {
- CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid parameter type"];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-
-}
-
-- (void)writeToFile:(NSString*)filePath withData:(NSData*)encData append:(BOOL)shouldAppend callback:(NSString*)callbackId
-{
- CDVPluginResult* result = nil;
- CDVFileError errCode = INVALID_MODIFICATION_ERR;
- int bytesWritten = 0;
-
- 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)writeToFile:(NSString*)filePath withString:(NSString*)stringData encoding:(NSStringEncoding)encoding append:(BOOL)shouldAppend callback:(NSString*)callbackId
-{
- [self writeToFile:filePath withData:[stringData dataUsingEncoding:encoding allowLossyConversion:YES] append:shouldAppend callback: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
diff --git a/iPhone/CordovaLib/Classes/CDVFileTransfer.h b/iPhone/CordovaLib/Classes/CDVFileTransfer.h
deleted file mode 100755
index 35e3fdd..0000000
--- a/iPhone/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;
diff --git a/iPhone/CordovaLib/Classes/CDVFileTransfer.m b/iPhone/CordovaLib/Classes/CDVFileTransfer.m
deleted file mode 100755
index 0f6b174..0000000
--- a/iPhone/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;
diff --git a/iPhone/CordovaLib/Classes/CDVGlobalization.h b/iPhone/CordovaLib/Classes/CDVGlobalization.h
deleted file mode 100755
index 0384656..0000000
--- a/iPhone/CordovaLib/Classes/CDVGlobalization.h
+++ /dev/null
@@ -1,150 +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"
-
-#define CDV_FORMAT_SHORT 0
-#define CDV_FORMAT_MEDIUM 1
-#define CDV_FORMAT_LONG 2
-#define CDV_FORMAT_FULL 3
-#define CDV_SELECTOR_MONTHS 0
-#define CDV_SELECTOR_DAYS 1
-
-enum CDVGlobalizationError {
- CDV_UNKNOWN_ERROR = 0,
- CDV_FORMATTING_ERROR = 1,
- CDV_PARSING_ERROR = 2,
- CDV_PATTERN_ERROR = 3,
-};
-typedef NSUInteger CDVGlobalizationError;
-
-@interface CDVGlobalization : CDVPlugin {
- CFLocaleRef currentLocale;
-}
-
-- (void)getPreferredLanguage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns the string identifier for the clients current locale setting.
- * It returns the locale identifier string to the successCB callback with a
- * properties object as a parameter. If there is an error getting the locale,
- * then the errorCB callback is invoked.
- */
-- (void)getLocaleName:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a date formatted as a string according to the clients user preferences and
- * calendar using the time zone of the client. It returns the formatted date string to the
- * successCB callback with a properties object as a parameter. If there is an error
- * formatting the date, then the errorCB callback is invoked.
- *
- * options: "date" contains the number of milliseconds that represents the JavaScript date
- */
-- (void)dateToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Parses a date formatted as a string according to the clients user
- * preferences and calendar using the time zone of the client and returns
- * the corresponding date object. It returns the date to the successCB
- * callback with a properties object as a parameter. If there is an error
- * parsing the date string, then the errorCB callback is invoked.
- *
- * options: "dateString" contains the JavaScript string to parse for a date
- */
-- (void)stringToDate:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a pattern string for formatting and parsing dates according to the clients
- * user preferences. It returns the pattern to the successCB callback with a
- * properties object as a parameter. If there is an error obtaining the pattern,
- * then the errorCB callback is invoked.
- *
- */
-- (void)getDatePattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns an array of either the names of the months or days of the week
- * according to the clients user preferences and calendar. It returns the array of names to the
- * successCB callback with a properties object as a parameter. If there is an error obtaining the
- * names, then the errorCB callback is invoked.
- *
- */
-- (void)getDateNames:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns whether daylight savings time is in effect for a given date using the clients
- * time zone and calendar. It returns whether or not daylight savings time is in effect
- * to the successCB callback with a properties object as a parameter. If there is an error
- * reading the date, then the errorCB callback is invoked.
- *
- * options: "date" contains the number of milliseconds that represents the JavaScript date
- *
- */
-- (void)isDayLightSavingsTime:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns the first day of the week according to the clients user preferences and calendar.
- * The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
- * It returns the day to the successCB callback with a properties object as a parameter.
- * If there is an error obtaining the pattern, then the errorCB callback is invoked.
- *
- */
-- (void)getFirstDayOfWeek:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a number formatted as a string according to the clients user preferences.
- * It returns the formatted number string to the successCB callback with a properties object as a
- * parameter. If there is an error formatting the number, then the errorCB callback is invoked.
- *
- * options: "number" contains the JavaScript number to format
- *
- */
-- (void)numberToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Parses a number formatted as a string according to the clients user preferences and
- * returns the corresponding number. It returns the number to the successCB callback with a
- * properties object as a parameter. If there is an error parsing the number string, then
- * the errorCB callback is invoked.
- *
- * options: "numberString" contains the JavaScript string to parse for a number
- *
- */
-- (void)stringToNumber:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a pattern string for formatting and parsing numbers according to the clients user
- * preferences. It returns the pattern to the successCB callback with a properties object as a
- * parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
- *
- */
-- (void)getNumberPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-/**
- * Returns a pattern string for formatting and parsing currency values according to the clients
- * user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
- * properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
- * callback is invoked.
- *
- * options: "currencyCode" contains the ISO currency code from JavaScript
- */
-- (void)getCurrencyPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVGlobalization.m b/iPhone/CordovaLib/Classes/CDVGlobalization.m
deleted file mode 100755
index 9eb9721..0000000
--- a/iPhone/CordovaLib/Classes/CDVGlobalization.m
+++ /dev/null
@@ -1,790 +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 "CDVGlobalization.h"
-
-@implementation CDVGlobalization
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVGlobalization*)[super initWithWebView:theWebView];
- if (self) {
- currentLocale = CFLocaleCopyCurrent();
- }
- return self;
-}
-
-- (void)getPreferredLanguage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- NSString* callbackId = [arguments objectAtIndex:0];
- CDVPluginResult* result = nil;
-
- NSLog(@"log1");
- // Source: http://stackoverflow.com/questions/3910244/getting-current-device-language-in-ios
- // (should be OK)
- NSString* language = [[NSLocale preferredLanguages] objectAtIndex:0];
-
- if (language) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:language forKey:@"value"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:dictionary];
- } else {
- // TBD is this ever expected to happen?
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)getLocaleName:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callbackId = [arguments objectAtIndex:0];
- NSDictionary* dictionary = nil;
-
- NSLocale* locale = [NSLocale currentLocale];
-
- if (locale) {
- dictionary = [NSDictionary dictionaryWithObject:[locale localeIdentifier] forKey:@"value"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- } else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-}
-
-- (void)dateToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CFDateFormatterStyle style = kCFDateFormatterShortStyle;
- CFDateFormatterStyle dateStyle = kCFDateFormatterShortStyle;
- CFDateFormatterStyle timeStyle = kCFDateFormatterShortStyle;
- NSDate* date = nil;
- NSString* dateString = nil;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- id milliseconds = [options valueForKey:@"date"];
-
- if (milliseconds && [milliseconds isKindOfClass:[NSNumber class]]) {
- // get the number of seconds since 1970 and create the date object
- date = [NSDate dateWithTimeIntervalSince1970:[milliseconds doubleValue] / 1000];
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired format length
- if ([key isEqualToString:@"formatLength"]) {
- if ([item isEqualToString:@"short"]) {
- style = kCFDateFormatterShortStyle;
- } else if ([item isEqualToString:@"medium"]) {
- style = kCFDateFormatterMediumStyle;
- } else if ([item isEqualToString:@"long"]) {
- style = kCFDateFormatterLongStyle;
- } else if ([item isEqualToString:@"full"]) {
- style = kCFDateFormatterFullStyle;
- }
- }
- // get the type of date and time to generate
- else if ([key isEqualToString:@"selector"]) {
- if ([item isEqualToString:@"date"]) {
- dateStyle = style;
- timeStyle = kCFDateFormatterNoStyle;
- } else if ([item isEqualToString:@"time"]) {
- dateStyle = kCFDateFormatterNoStyle;
- timeStyle = style;
- } else if ([item isEqualToString:@"date and time"]) {
- dateStyle = style;
- timeStyle = style;
- }
- }
- }
- }
- }
-
- // create the formatter using the user's current default locale and formats for dates and times
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
- // if we have a valid date object then call the formatter
- if (date) {
- dateString = (__bridge_transfer NSString*)CFDateFormatterCreateStringWithDate(kCFAllocatorDefault,
- formatter,
- (__bridge CFDateRef)date);
- }
-
- // if the date was converted to a string successfully then return the result
- if (dateString) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:dateString forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // DLog(@"GlobalizationCommand dateToString unable to format %@", [date description]);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_FORMATTING_ERROR] forKey:@"code"];
- [dictionary setValue:@"Formatting error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)stringToDate:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CFDateFormatterStyle style = kCFDateFormatterShortStyle;
- CFDateFormatterStyle dateStyle = kCFDateFormatterShortStyle;
- CFDateFormatterStyle timeStyle = kCFDateFormatterShortStyle;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- NSString* dateString = nil;
- NSDateComponents* comps = nil;
-
- // get the string that is to be parsed for a date
- id ms = [options valueForKey:@"dateString"];
-
- if (ms && [ms isKindOfClass:[NSString class]]) {
- dateString = ms;
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired format length
- if ([key isEqualToString:@"formatLength"]) {
- if ([item isEqualToString:@"short"]) {
- style = kCFDateFormatterShortStyle;
- } else if ([item isEqualToString:@"medium"]) {
- style = kCFDateFormatterMediumStyle;
- } else if ([item isEqualToString:@"long"]) {
- style = kCFDateFormatterLongStyle;
- } else if ([item isEqualToString:@"full"]) {
- style = kCFDateFormatterFullStyle;
- }
- }
- // get the type of date and time to generate
- else if ([key isEqualToString:@"selector"]) {
- if ([item isEqualToString:@"date"]) {
- dateStyle = style;
- timeStyle = kCFDateFormatterNoStyle;
- } else if ([item isEqualToString:@"time"]) {
- dateStyle = kCFDateFormatterNoStyle;
- timeStyle = style;
- } else if ([item isEqualToString:@"date and time"]) {
- dateStyle = style;
- timeStyle = style;
- }
- }
- }
- }
- }
-
- // get the user's default settings for date and time formats
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
-
- // set the parsing to be more lenient
- CFDateFormatterSetProperty(formatter, kCFDateFormatterIsLenient, kCFBooleanTrue);
-
- // parse tha date and time string
- CFDateRef date = CFDateFormatterCreateDateFromString(kCFAllocatorDefault,
- formatter,
- (__bridge CFStringRef)dateString,
- NULL);
-
- // if we were able to parse the date then get the date and time components
- if (date != NULL) {
- NSCalendar* calendar = [NSCalendar currentCalendar];
-
- unsigned unitFlags = NSYearCalendarUnit |
- NSMonthCalendarUnit |
- NSDayCalendarUnit |
- NSHourCalendarUnit |
- NSMinuteCalendarUnit |
- NSSecondCalendarUnit;
-
- comps = [calendar components:unitFlags fromDate:(__bridge NSDate*)date];
- CFRelease(date);
- }
-
- // put the various elements of the date and time into a dictionary
- if (comps != nil) {
- NSArray* keys = [NSArray arrayWithObjects:@"year", @"month", @"day", @"hour", @"minute", @"second", @"millisecond", nil];
- NSArray* values = [NSArray arrayWithObjects:[NSNumber numberWithInt:[comps year]],
- [NSNumber numberWithInt:[comps month] - 1],
- [NSNumber numberWithInt:[comps day]],
- [NSNumber numberWithInt:[comps hour]],
- [NSNumber numberWithInt:[comps minute]],
- [NSNumber numberWithInt:[comps second]],
- [NSNumber numberWithInt:0], /* iOS does not provide milliseconds */
- nil];
-
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // Dlog(@"GlobalizationCommand stringToDate unable to parse %@", dateString);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PARSING_ERROR] forKey:@"code"];
- [dictionary setValue:@"unable to parse" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)getDatePattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CFDateFormatterStyle style = kCFDateFormatterShortStyle;
- CFDateFormatterStyle dateStyle = kCFDateFormatterShortStyle;
- CFDateFormatterStyle timeStyle = kCFDateFormatterShortStyle;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
-
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired format length
- if ([key isEqualToString:@"formatLength"]) {
- if ([item isEqualToString:@"short"]) {
- style = kCFDateFormatterShortStyle;
- } else if ([item isEqualToString:@"medium"]) {
- style = kCFDateFormatterMediumStyle;
- } else if ([item isEqualToString:@"long"]) {
- style = kCFDateFormatterLongStyle;
- } else if ([item isEqualToString:@"full"]) {
- style = kCFDateFormatterFullStyle;
- }
- }
- // get the type of date and time to generate
- else if ([key isEqualToString:@"selector"]) {
- if ([item isEqualToString:@"date"]) {
- dateStyle = style;
- timeStyle = kCFDateFormatterNoStyle;
- } else if ([item isEqualToString:@"time"]) {
- dateStyle = kCFDateFormatterNoStyle;
- timeStyle = style;
- } else if ([item isEqualToString:@"date and time"]) {
- dateStyle = style;
- timeStyle = style;
- }
- }
- }
- }
- }
-
- // get the user's default settings for date and time formats
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
-
- // get the date pattern to apply when formatting and parsing
- CFStringRef datePattern = CFDateFormatterGetFormat(formatter);
- // get the user's current time zone information
- CFTimeZoneRef timezone = (CFTimeZoneRef)CFDateFormatterCopyProperty(formatter, kCFDateFormatterTimeZone);
-
- // put the pattern and time zone information into the dictionary
- if ((datePattern != nil) && (timezone != nil)) {
- NSArray* keys = [NSArray arrayWithObjects:@"pattern", @"timezone", @"utc_offset", @"dst_offset", nil];
- NSArray* values = [NSArray arrayWithObjects:((__bridge NSString*)datePattern),
- [((__bridge NSTimeZone*)timezone)abbreviation],
- [NSNumber numberWithLong:[((__bridge NSTimeZone*)timezone)secondsFromGMT]],
- [NSNumber numberWithDouble:[((__bridge NSTimeZone*)timezone)daylightSavingTimeOffset]],
- nil];
-
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PATTERN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Pattern error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- if (timezone) {
- CFRelease(timezone);
- }
- CFRelease(formatter);
-}
-
-- (void)getDateNames:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- int style = CDV_FORMAT_LONG;
- int selector = CDV_SELECTOR_MONTHS;
- CFStringRef dataStyle = kCFDateFormatterMonthSymbols;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
-
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired type of name
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"narrow"]) {
- style = CDV_FORMAT_SHORT;
- } else if ([item isEqualToString:@"wide"]) {
- style = CDV_FORMAT_LONG;
- }
- }
- // determine if months or days are needed
- else if ([key isEqualToString:@"item"]) {
- if ([item isEqualToString:@"months"]) {
- selector = CDV_SELECTOR_MONTHS;
- } else if ([item isEqualToString:@"days"]) {
- selector = CDV_SELECTOR_DAYS;
- }
- }
- }
- }
- }
-
- CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- kCFDateFormatterFullStyle,
- kCFDateFormatterFullStyle);
-
- if ((selector == CDV_SELECTOR_MONTHS) && (style == CDV_FORMAT_LONG)) {
- dataStyle = kCFDateFormatterMonthSymbols;
- } else if ((selector == CDV_SELECTOR_MONTHS) && (style == CDV_FORMAT_SHORT)) {
- dataStyle = kCFDateFormatterShortMonthSymbols;
- } else if ((selector == CDV_SELECTOR_DAYS) && (style == CDV_FORMAT_LONG)) {
- dataStyle = kCFDateFormatterWeekdaySymbols;
- } else if ((selector == CDV_SELECTOR_DAYS) && (style == CDV_FORMAT_SHORT)) {
- dataStyle = kCFDateFormatterShortWeekdaySymbols;
- }
-
- CFArrayRef names = (CFArrayRef)CFDateFormatterCopyProperty(formatter, dataStyle);
-
- if (names) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:((__bridge NSArray*)names) forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- CFRelease(names);
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)isDayLightSavingsTime:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- NSDate* date = nil;
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- id milliseconds = [options valueForKey:@"date"];
-
- if (milliseconds && [milliseconds isKindOfClass:[NSNumber class]]) {
- // get the number of seconds since 1970 and create the date object
- date = [NSDate dateWithTimeIntervalSince1970:[milliseconds doubleValue] / 1000];
- }
-
- if (date) {
- // get the current calendar for the user and check if the date is using DST
- NSCalendar* calendar = [NSCalendar currentCalendar];
- NSTimeZone* timezone = [calendar timeZone];
- NSNumber* dst = [NSNumber numberWithBool:[timezone isDaylightSavingTimeForDate:date]];
-
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:dst forKey:@"dst"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-}
-
-- (void)getFirstDayOfWeek:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
-
- NSCalendar* calendar = [NSCalendar autoupdatingCurrentCalendar];
-
- NSNumber* day = [NSNumber numberWithInt:[calendar firstWeekday]];
-
- if (day) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:day forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_UNKNOWN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unknown error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-}
-
-- (void)numberToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- CFNumberFormatterStyle style = kCFNumberFormatterDecimalStyle;
- NSNumber* number = nil;
-
- id value = [options valueForKey:@"number"];
-
- if (value && [value isKindOfClass:[NSNumber class]]) {
- number = (NSNumber*)value;
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired style of formatting
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"percent"]) {
- style = kCFNumberFormatterPercentStyle;
- } else if ([item isEqualToString:@"currency"]) {
- style = kCFNumberFormatterCurrencyStyle;
- } else if ([item isEqualToString:@"decimal"]) {
- style = kCFNumberFormatterDecimalStyle;
- }
- }
- }
- }
- }
-
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
-
- // get the localized string based upon the locale and user preferences
- NSString* numberString = (__bridge_transfer NSString*)CFNumberFormatterCreateStringWithNumber(kCFAllocatorDefault,
- formatter,
- (__bridge CFNumberRef)number);
-
- if (numberString) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:numberString forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // DLog(@"GlobalizationCommand numberToString unable to format %@", [number stringValue]);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_FORMATTING_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unable to format" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)stringToNumber:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- CFNumberFormatterStyle style = kCFNumberFormatterDecimalStyle;
- NSString* numberString = nil;
- double doubleValue;
-
- id value = [options valueForKey:@"numberString"];
-
- if (value && [value isKindOfClass:[NSString class]]) {
- numberString = (NSString*)value;
- }
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired style of formatting
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"percent"]) {
- style = kCFNumberFormatterPercentStyle;
- } else if ([item isEqualToString:@"currency"]) {
- style = kCFNumberFormatterCurrencyStyle;
- } else if ([item isEqualToString:@"decimal"]) {
- style = kCFNumberFormatterDecimalStyle;
- }
- }
- }
- }
- }
-
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
-
- // we need to make this lenient so as to avoid problems with parsing currencies that have non-breaking space characters
- if (style == kCFNumberFormatterCurrencyStyle) {
- CFNumberFormatterSetProperty(formatter, kCFNumberFormatterIsLenient, kCFBooleanTrue);
- }
-
- // parse againist the largest type to avoid data loss
- Boolean rc = CFNumberFormatterGetValueFromString(formatter,
- (__bridge CFStringRef)numberString,
- NULL,
- kCFNumberDoubleType,
- &doubleValue);
-
- if (rc) {
- NSDictionary* dictionary = [NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:doubleValue] forKey:@"value"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- // DLog(@"GlobalizationCommand stringToNumber unable to parse %@", numberString);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PARSING_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unable to parse" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)getNumberPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- CFNumberFormatterStyle style = kCFNumberFormatterDecimalStyle;
- CFStringRef symbolType = NULL;
- NSString* symbol = @"";
-
- // see if any options have been specified
- id items = [options valueForKey:@"options"];
-
- if (items && [items isKindOfClass:[NSMutableDictionary class]]) {
- NSEnumerator* enumerator = [items keyEnumerator];
- id key;
-
- // iterate through all the options
- while ((key = [enumerator nextObject])) {
- id item = [items valueForKey:key];
-
- // make sure that only string values are present
- if ([item isKindOfClass:[NSString class]]) {
- // get the desired style of formatting
- if ([key isEqualToString:@"type"]) {
- if ([item isEqualToString:@"percent"]) {
- style = kCFNumberFormatterPercentStyle;
- } else if ([item isEqualToString:@"currency"]) {
- style = kCFNumberFormatterCurrencyStyle;
- } else if ([item isEqualToString:@"decimal"]) {
- style = kCFNumberFormatterDecimalStyle;
- }
- }
- }
- }
- }
-
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
-
- NSString* numberPattern = (__bridge NSString*)CFNumberFormatterGetFormat(formatter);
-
- if (style == kCFNumberFormatterCurrencyStyle) {
- symbolType = kCFNumberFormatterCurrencySymbol;
- } else if (style == kCFNumberFormatterPercentStyle) {
- symbolType = kCFNumberFormatterPercentSymbol;
- }
-
- if (symbolType) {
- symbol = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, symbolType);
- }
-
- NSString* decimal = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterDecimalSeparator);
- NSString* grouping = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterGroupingSeparator);
- NSString* posSign = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterPlusSign);
- NSString* negSign = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterMinusSign);
- NSNumber* fracDigits = (__bridge_transfer NSNumber*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterMinFractionDigits);
- NSNumber* roundingDigits = (__bridge_transfer NSNumber*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterRoundingIncrement);
-
- // put the pattern information into the dictionary
- if (numberPattern != nil) {
- NSArray* keys = [NSArray arrayWithObjects:@"pattern", @"symbol", @"fraction", @"rounding",
- @"positive", @"negative", @"decimal", @"grouping", nil];
- NSArray* values = [NSArray arrayWithObjects:numberPattern, symbol, fracDigits, roundingDigits,
- posSign, negSign, decimal, grouping, nil];
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- }
- // error
- else {
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PATTERN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Pattern error" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-
- CFRelease(formatter);
-}
-
-- (void)getCurrencyPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
-{
- CDVPluginResult* result = nil;
- NSString* callBackId = [arguments objectAtIndex:0];
- NSString* currencyCode = nil;
- NSString* numberPattern = nil;
- NSString* decimal = nil;
- NSString* grouping = nil;
- int32_t defaultFractionDigits;
- double roundingIncrement;
- Boolean rc;
-
- id value = [options valueForKey:@"currencyCode"];
-
- if (value && [value isKindOfClass:[NSString class]]) {
- currencyCode = (NSString*)value;
- }
-
- // first see if there is base currency info available and fill in the currency_info structure
- rc = CFNumberFormatterGetDecimalInfoForCurrencyCode((__bridge CFStringRef)currencyCode, &defaultFractionDigits, &roundingIncrement);
-
- // now set the currency code in the formatter
- if (rc) {
- CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- kCFNumberFormatterCurrencyStyle);
-
- CFNumberFormatterSetProperty(formatter, kCFNumberFormatterCurrencyCode, (__bridge CFStringRef)currencyCode);
- CFNumberFormatterSetProperty(formatter, kCFNumberFormatterInternationalCurrencySymbol, (__bridge CFStringRef)currencyCode);
-
- numberPattern = (__bridge NSString*)CFNumberFormatterGetFormat(formatter);
- decimal = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterCurrencyDecimalSeparator);
- grouping = (__bridge_transfer NSString*)CFNumberFormatterCopyProperty(formatter, kCFNumberFormatterCurrencyGroupingSeparator);
-
- NSArray* keys = [NSArray arrayWithObjects:@"pattern", @"code", @"fraction", @"rounding",
- @"decimal", @"grouping", nil];
- NSArray* values = [NSArray arrayWithObjects:numberPattern, currencyCode, [NSNumber numberWithInt:defaultFractionDigits],
- [NSNumber numberWithDouble:roundingIncrement], decimal, grouping, nil];
- NSDictionary* dictionary = [NSDictionary dictionaryWithObjects:values forKeys:keys];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dictionary];
- CFRelease(formatter);
- }
- // error
- else {
- // DLog(@"GlobalizationCommand getCurrencyPattern unable to get pattern for %@", currencyCode);
- NSMutableDictionary* dictionary = [NSMutableDictionary dictionaryWithCapacity:2];
- [dictionary setValue:[NSNumber numberWithInt:CDV_PATTERN_ERROR] forKey:@"code"];
- [dictionary setValue:@"Unable to get pattern" forKey:@"message"];
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dictionary];
- }
-
- [self.commandDelegate sendPluginResult:result callbackId:callBackId];
-}
-
-- (void)dealloc
-{
- if (currentLocale) {
- CFRelease(currentLocale);
- currentLocale = nil;
- }
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVInAppBrowser.h b/iPhone/CordovaLib/Classes/CDVInAppBrowser.h
deleted file mode 100755
index 248274a..0000000
--- a/iPhone/CordovaLib/Classes/CDVInAppBrowser.h
+++ /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.
- */
-
-#import "CDVPlugin.h"
-#import "CDVInvokedUrlCommand.h"
-#import "CDVScreenOrientationDelegate.h"
-#import "CDVWebViewDelegate.h"
-
-@class CDVInAppBrowserViewController;
-
-@interface CDVInAppBrowser : CDVPlugin {
- BOOL _injectedIframeBridge;
-}
-
-@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
-@property (nonatomic, copy) NSString* callbackId;
-
-- (void)open:(CDVInvokedUrlCommand*)command;
-- (void)close:(CDVInvokedUrlCommand*)command;
-- (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
-- (void)show:(CDVInvokedUrlCommand*)command;
-
-@end
-
-@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{
- @private
- NSString* _userAgent;
- NSString* _prevUserAgent;
- NSInteger _userAgentLockToken;
- CDVWebViewDelegate* _webViewDelegate;
-}
-
-@property (nonatomic, strong) IBOutlet UIWebView* webView;
-@property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
-@property (nonatomic, strong) IBOutlet UILabel* addressLabel;
-@property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton;
-@property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton;
-@property (nonatomic, strong) IBOutlet UIActivityIndicatorView* spinner;
-@property (nonatomic, strong) IBOutlet UIToolbar* toolbar;
-
-@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
-@property (nonatomic, weak) CDVInAppBrowser* navigationDelegate;
-@property (nonatomic) NSURL* currentURL;
-
-- (void)close;
-- (void)navigateTo:(NSURL*)url;
-- (void)showLocationBar:(BOOL)show;
-- (void)showToolBar:(BOOL)show;
-- (void)setCloseButtonTitle:(NSString*)title;
-
-- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent;
-
-@end
-
-@interface CDVInAppBrowserOptions : NSObject {}
-
-@property (nonatomic, assign) BOOL location;
-@property (nonatomic, assign) BOOL toolbar;
-@property (nonatomic, copy) NSString* closebuttoncaption;
-
-@property (nonatomic, copy) NSString* presentationstyle;
-@property (nonatomic, copy) NSString* transitionstyle;
-
-@property (nonatomic, assign) BOOL enableviewportscale;
-@property (nonatomic, assign) BOOL mediaplaybackrequiresuseraction;
-@property (nonatomic, assign) BOOL allowinlinemediaplayback;
-@property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction;
-@property (nonatomic, assign) BOOL suppressesincrementalrendering;
-@property (nonatomic, assign) BOOL hidden;
-
-+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVInAppBrowser.m b/iPhone/CordovaLib/Classes/CDVInAppBrowser.m
deleted file mode 100755
index b832e23..0000000
--- a/iPhone/CordovaLib/Classes/CDVInAppBrowser.m
+++ /dev/null
@@ -1,818 +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 "CDVInAppBrowser.h"
-#import "CDVPluginResult.h"
-#import "CDVUserAgentUtil.h"
-#import "CDVJSON.h"
-
-#define kInAppBrowserTargetSelf @"_self"
-#define kInAppBrowserTargetSystem @"_system"
-#define kInAppBrowserTargetBlank @"_blank"
-
-#define TOOLBAR_HEIGHT 44.0
-#define LOCATIONBAR_HEIGHT 21.0
-#define FOOTER_HEIGHT ((TOOLBAR_HEIGHT) + (LOCATIONBAR_HEIGHT))
-
-#pragma mark CDVInAppBrowser
-
-@implementation CDVInAppBrowser
-
-- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
-{
- self = [super initWithWebView:theWebView];
- if (self != nil) {
- // your initialization here
- }
-
- return self;
-}
-
-- (void)onReset
-{
- [self close:nil];
-}
-
-- (void)close:(CDVInvokedUrlCommand*)command
-{
- if (self.inAppBrowserViewController != nil) {
- [self.inAppBrowserViewController close];
- self.inAppBrowserViewController = nil;
- }
-
- self.callbackId = nil;
-}
-
-- (void)open:(CDVInvokedUrlCommand*)command
-{
- CDVPluginResult* pluginResult;
-
- NSString* url = [command argumentAtIndex:0];
- NSString* target = [command argumentAtIndex:1 withDefault:kInAppBrowserTargetSelf];
- NSString* options = [command argumentAtIndex:2 withDefault:@"" andClass:[NSString class]];
-
- self.callbackId = command.callbackId;
-
- if (url != nil) {
- NSURL* baseUrl = [self.webView.request URL];
- NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
- if ([target isEqualToString:kInAppBrowserTargetSelf]) {
- [self openInCordovaWebView:absoluteUrl withOptions:options];
- } else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
- [self openInSystem:absoluteUrl];
- } else { // _blank or anything else
- [self openInInAppBrowser:absoluteUrl withOptions:options];
- }
-
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"incorrect number of arguments"];
- }
-
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
- [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
-}
-
-- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
-{
- if (self.inAppBrowserViewController == nil) {
- NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
- self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent]];
- self.inAppBrowserViewController.navigationDelegate = self;
-
- if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
- self.inAppBrowserViewController.orientationDelegate = (UIViewController <CDVScreenOrientationDelegate>*)self.viewController;
- }
- }
-
-
- CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
- [self.inAppBrowserViewController showLocationBar:browserOptions.location];
- [self.inAppBrowserViewController showToolBar:browserOptions.toolbar];
- if (browserOptions.closebuttoncaption != nil) {
- [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption];
- }
- // Set Presentation Style
- UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
- if (browserOptions.presentationstyle != nil) {
- if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"pagesheet"]) {
- presentationStyle = UIModalPresentationPageSheet;
- } else if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"formsheet"]) {
- presentationStyle = UIModalPresentationFormSheet;
- }
- }
- self.inAppBrowserViewController.modalPresentationStyle = presentationStyle;
-
- // Set Transition Style
- UIModalTransitionStyle transitionStyle = UIModalTransitionStyleCoverVertical; // default
- if (browserOptions.transitionstyle != nil) {
- if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"fliphorizontal"]) {
- transitionStyle = UIModalTransitionStyleFlipHorizontal;
- } else if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"crossdissolve"]) {
- transitionStyle = UIModalTransitionStyleCrossDissolve;
- }
- }
- self.inAppBrowserViewController.modalTransitionStyle = transitionStyle;
-
-
- // UIWebView options
- self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale;
- self.inAppBrowserViewController.webView.mediaPlaybackRequiresUserAction = browserOptions.mediaplaybackrequiresuseraction;
- self.inAppBrowserViewController.webView.allowsInlineMediaPlayback = browserOptions.allowinlinemediaplayback;
- if (IsAtLeastiOSVersion(@"6.0")) {
- self.inAppBrowserViewController.webView.keyboardDisplayRequiresUserAction = browserOptions.keyboarddisplayrequiresuseraction;
- self.inAppBrowserViewController.webView.suppressesIncrementalRendering = browserOptions.suppressesincrementalrendering;
- }
-
- if (! browserOptions.hidden) {
- if (self.viewController.modalViewController != self.inAppBrowserViewController) {
- [self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
- }
- }
- [self.inAppBrowserViewController navigateTo:url];
-}
-
-- (void)show:(CDVInvokedUrlCommand*)command
-{
- [self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
-}
-
-- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
-{
- if ([self.commandDelegate URLIsWhitelisted:url]) {
- NSURLRequest* request = [NSURLRequest requestWithURL:url];
- [self.webView loadRequest:request];
- } else { // this assumes the InAppBrowser can be excepted from the white-list
- [self openInInAppBrowser:url withOptions:options];
- }
-}
-
-- (void)openInSystem:(NSURL*)url
-{
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- [[UIApplication sharedApplication] openURL:url];
- } else { // handle any custom schemes to plugins
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
- }
-}
-
-// This is a helper method for the inject{Script|Style}{Code|File} API calls, which
-// provides a consistent method for injecting JavaScript code into the document.
-//
-// If a wrapper string is supplied, then the source string will be JSON-encoded (adding
-// quotes) and wrapped using string formatting. (The wrapper string should have a single
-// '%@' marker).
-//
-// If no wrapper is supplied, then the source string is executed directly.
-
-- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
-{
- if (!_injectedIframeBridge) {
- _injectedIframeBridge = YES;
- // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"];
- }
-
- if (jsWrapper != nil) {
- NSString* sourceArrayString = [@[source] JSONString];
- if (sourceArrayString) {
- NSString* sourceString = [sourceArrayString substringWithRange:NSMakeRange(1, [sourceArrayString length] - 2)];
- NSString* jsToInject = [NSString stringWithFormat:jsWrapper, sourceString];
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:jsToInject];
- }
- } else {
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:source];
- }
-}
-
-- (void)injectScriptCode:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper = nil;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"_cdvIframeBridge.src='gap-iab://%@/'+window.escape(JSON.stringify([eval(%%@)]));", command.callbackId];
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-- (void)injectScriptFile:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('script'); c.src = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
- } else {
- jsWrapper = @"(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document)";
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-- (void)injectStyleCode:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('style'); c.innerHTML = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
- } else {
- jsWrapper = @"(function(d) { var c = d.createElement('style'); c.innerHTML = %@; d.body.appendChild(c); })(document)";
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-- (void)injectStyleFile:(CDVInvokedUrlCommand*)command
-{
- NSString* jsWrapper;
-
- if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
- jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
- } else {
- jsWrapper = @"(function(d) { var c = d.createElement('link'); c.rel='stylesheet', c.type='text/css'; c.href = %@; d.body.appendChild(c); })(document)";
- }
- [self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
-}
-
-/**
- * The iframe bridge provided for the InAppBrowser is capable of executing any oustanding callback belonging
- * to the InAppBrowser plugin. Care has been taken that other callbacks cannot be triggered, and that no
- * other code execution is possible.
- *
- * To trigger the bridge, the iframe (or any other resource) should attempt to load a url of the form:
- *
- * gap-iab://<callbackId>/<arguments>
- *
- * where <callbackId> is the string id of the callback to trigger (something like "InAppBrowser0123456789")
- *
- * If present, the path component of the special gap-iab:// url is expected to be a URL-escaped JSON-encoded
- * value to pass to the callback. [NSURL path] should take care of the URL-unescaping, and a JSON_EXCEPTION
- * is returned if the JSON is invalid.
- */
-- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- NSURL* url = request.URL;
- BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
-
- // See if the url uses the 'gap-iab' protocol. If so, the host should be the id of a callback to execute,
- // and the path, if present, should be a JSON-encoded value to pass to the callback.
- if ([[url scheme] isEqualToString:@"gap-iab"]) {
- NSString* scriptCallbackId = [url host];
- CDVPluginResult* pluginResult = nil;
-
- if ([scriptCallbackId hasPrefix:@"InAppBrowser"]) {
- NSString* scriptResult = [url path];
- NSError* __autoreleasing error = nil;
-
- // The message should be a JSON-encoded array of the result of the script which executed.
- if ((scriptResult != nil) && ([scriptResult length] > 1)) {
- scriptResult = [scriptResult substringFromIndex:1];
- NSData* decodedResult = [NSJSONSerialization JSONObjectWithData:[scriptResult dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
- if ((error == nil) && [decodedResult isKindOfClass:[NSArray class]]) {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:(NSArray*)decodedResult];
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_JSON_EXCEPTION];
- }
- } else {
- pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:@[]];
- }
- [self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId];
- return NO;
- }
- } else if ((self.callbackId != nil) && isTopLevelNavigation) {
- // Send a loadstart event for each top-level navigation (includes redirects).
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
-
- return YES;
-}
-
-- (void)webViewDidStartLoad:(UIWebView*)theWebView
-{
- _injectedIframeBridge = NO;
-}
-
-- (void)webViewDidFinishLoad:(UIWebView*)theWebView
-{
- if (self.callbackId != nil) {
- // TODO: It would be more useful to return the URL the page is actually on (e.g. if it's been redirected).
- NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@{@"type":@"loadstop", @"url":url}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
-}
-
-- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
-{
- if (self.callbackId != nil) {
- NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsDictionary:@{@"type":@"loaderror", @"url":url, @"code": [NSNumber numberWithInt:error.code], @"message": error.localizedDescription}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
-}
-
-- (void)browserExit
-{
- if (self.callbackId != nil) {
- CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@{@"type":@"exit"}];
- [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
-
- [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
- }
- // Don't recycle the ViewController since it may be consuming a lot of memory.
- // Also - this is required for the PDF/User-Agent bug work-around.
- self.inAppBrowserViewController = nil;
-}
-
-@end
-
-#pragma mark CDVInAppBrowserViewController
-
-@implementation CDVInAppBrowserViewController
-
-@synthesize currentURL;
-
-- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent
-{
- self = [super init];
- if (self != nil) {
- _userAgent = userAgent;
- _prevUserAgent = prevUserAgent;
- _webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
- [self createViews];
- }
-
- return self;
-}
-
-- (void)createViews
-{
- // We create the views in code for primarily for ease of upgrades and not requiring an external .xib to be included
-
- CGRect webViewBounds = self.view.bounds;
-
- webViewBounds.size.height -= FOOTER_HEIGHT;
-
- self.webView = [[UIWebView alloc] initWithFrame:webViewBounds];
- self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
-
- [self.view addSubview:self.webView];
- [self.view sendSubviewToBack:self.webView];
-
- self.webView.delegate = _webViewDelegate;
- self.webView.backgroundColor = [UIColor whiteColor];
-
- self.webView.clearsContextBeforeDrawing = YES;
- self.webView.clipsToBounds = YES;
- self.webView.contentMode = UIViewContentModeScaleToFill;
- self.webView.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.webView.multipleTouchEnabled = YES;
- self.webView.opaque = YES;
- self.webView.scalesPageToFit = NO;
- self.webView.userInteractionEnabled = YES;
-
- self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
- self.spinner.alpha = 1.000;
- self.spinner.autoresizesSubviews = YES;
- self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
- self.spinner.clearsContextBeforeDrawing = NO;
- self.spinner.clipsToBounds = NO;
- self.spinner.contentMode = UIViewContentModeScaleToFill;
- self.spinner.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
- self.spinner.hidden = YES;
- self.spinner.hidesWhenStopped = YES;
- self.spinner.multipleTouchEnabled = NO;
- self.spinner.opaque = NO;
- self.spinner.userInteractionEnabled = NO;
- [self.spinner stopAnimating];
-
- self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
- self.closeButton.enabled = YES;
-
- UIBarButtonItem* flexibleSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
-
- UIBarButtonItem* fixedSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- fixedSpaceButton.width = 20;
-
- self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, (self.view.bounds.size.height - TOOLBAR_HEIGHT), self.view.bounds.size.width, TOOLBAR_HEIGHT)];
- self.toolbar.alpha = 1.000;
- self.toolbar.autoresizesSubviews = YES;
- self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
- self.toolbar.barStyle = UIBarStyleBlackOpaque;
- self.toolbar.clearsContextBeforeDrawing = NO;
- self.toolbar.clipsToBounds = NO;
- self.toolbar.contentMode = UIViewContentModeScaleToFill;
- self.toolbar.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.toolbar.hidden = NO;
- self.toolbar.multipleTouchEnabled = NO;
- self.toolbar.opaque = NO;
- self.toolbar.userInteractionEnabled = YES;
-
- CGFloat labelInset = 5.0;
- self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelInset, (self.view.bounds.size.height - FOOTER_HEIGHT), self.view.bounds.size.width - labelInset, LOCATIONBAR_HEIGHT)];
- self.addressLabel.adjustsFontSizeToFitWidth = NO;
- self.addressLabel.alpha = 1.000;
- self.addressLabel.autoresizesSubviews = YES;
- self.addressLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
- self.addressLabel.backgroundColor = [UIColor clearColor];
- self.addressLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
- self.addressLabel.clearsContextBeforeDrawing = YES;
- self.addressLabel.clipsToBounds = YES;
- self.addressLabel.contentMode = UIViewContentModeScaleToFill;
- self.addressLabel.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
- self.addressLabel.enabled = YES;
- self.addressLabel.hidden = NO;
- self.addressLabel.lineBreakMode = UILineBreakModeTailTruncation;
- self.addressLabel.minimumFontSize = 10.000;
- self.addressLabel.multipleTouchEnabled = NO;
- self.addressLabel.numberOfLines = 1;
- self.addressLabel.opaque = NO;
- self.addressLabel.shadowOffset = CGSizeMake(0.0, -1.0);
- self.addressLabel.text = @"Loading...";
- self.addressLabel.textAlignment = UITextAlignmentLeft;
- self.addressLabel.textColor = [UIColor colorWithWhite:1.000 alpha:1.000];
- self.addressLabel.userInteractionEnabled = NO;
-
- NSString* frontArrowString = @"â–º"; // create arrow from Unicode char
- self.forwardButton = [[UIBarButtonItem alloc] initWithTitle:frontArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goForward:)];
- self.forwardButton.enabled = YES;
- self.forwardButton.imageInsets = UIEdgeInsetsZero;
-
- NSString* backArrowString = @"â—„"; // create arrow from Unicode char
- self.backButton = [[UIBarButtonItem alloc] initWithTitle:backArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)];
- self.backButton.enabled = YES;
- self.backButton.imageInsets = UIEdgeInsetsZero;
-
- [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
-
- self.view.backgroundColor = [UIColor grayColor];
- [self.view addSubview:self.toolbar];
- [self.view addSubview:self.addressLabel];
- [self.view addSubview:self.spinner];
-}
-
-- (void)setCloseButtonTitle:(NSString*)title
-{
- // the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically
- // but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one)
- self.closeButton = nil;
- self.closeButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)];
- self.closeButton.enabled = YES;
- self.closeButton.tintColor = [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
-
- NSMutableArray* items = [self.toolbar.items mutableCopy];
- [items replaceObjectAtIndex:0 withObject:self.closeButton];
- [self.toolbar setItems:items];
-}
-
-- (void)showLocationBar:(BOOL)show
-{
- CGRect locationbarFrame = self.addressLabel.frame;
-
- BOOL toolbarVisible = !self.toolbar.hidden;
-
- // prevent double show/hide
- if (show == !(self.addressLabel.hidden)) {
- return;
- }
-
- if (show) {
- self.addressLabel.hidden = NO;
-
- if (toolbarVisible) {
- // toolBar at the bottom, leave as is
- // put locationBar on top of the toolBar
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= FOOTER_HEIGHT;
- self.webView.frame = webViewBounds;
-
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
- } else {
- // no toolBar, so put locationBar at the bottom
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
- self.webView.frame = webViewBounds;
-
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
- }
- } else {
- self.addressLabel.hidden = YES;
-
- if (toolbarVisible) {
- // locationBar is on top of toolBar, hide locationBar
-
- // webView take up whole height less toolBar height
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= TOOLBAR_HEIGHT;
- self.webView.frame = webViewBounds;
- } else {
- // no toolBar, expand webView to screen dimensions
-
- CGRect webViewBounds = self.view.bounds;
- self.webView.frame = webViewBounds;
- }
- }
-}
-
-- (void)showToolBar:(BOOL)show
-{
- CGRect toolbarFrame = self.toolbar.frame;
- CGRect locationbarFrame = self.addressLabel.frame;
-
- BOOL locationbarVisible = !self.addressLabel.hidden;
-
- // prevent double show/hide
- if (show == !(self.toolbar.hidden)) {
- return;
- }
-
- if (show) {
- self.toolbar.hidden = NO;
-
- if (locationbarVisible) {
- // locationBar at the bottom, move locationBar up
- // put toolBar at the bottom
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= FOOTER_HEIGHT;
- self.webView.frame = webViewBounds;
-
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
-
- toolbarFrame.origin.y = (webViewBounds.size.height + LOCATIONBAR_HEIGHT);
- self.toolbar.frame = toolbarFrame;
- } else {
- // no locationBar, so put toolBar at the bottom
-
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= TOOLBAR_HEIGHT;
- self.webView.frame = webViewBounds;
-
- toolbarFrame.origin.y = webViewBounds.size.height;
- self.toolbar.frame = toolbarFrame;
- }
- } else {
- self.toolbar.hidden = YES;
-
- if (locationbarVisible) {
- // locationBar is on top of toolBar, hide toolBar
- // put locationBar at the bottom
-
- // webView take up whole height less locationBar height
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
- self.webView.frame = webViewBounds;
-
- // move locationBar down
- locationbarFrame.origin.y = webViewBounds.size.height;
- self.addressLabel.frame = locationbarFrame;
- } else {
- // no locationBar, expand webView to screen dimensions
-
- CGRect webViewBounds = self.view.bounds;
- self.webView.frame = webViewBounds;
- }
- }
-}
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
-}
-
-- (void)viewDidUnload
-{
- [self.webView loadHTMLString:nil baseURL:nil];
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
- [super viewDidUnload];
-}
-
-- (void)close
-{
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
-
- if ([self respondsToSelector:@selector(presentingViewController)]) {
- [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
- } else {
- [[self parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- self.currentURL = nil;
-
- if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserExit)]) {
- [self.navigationDelegate browserExit];
- }
-}
-
-- (void)navigateTo:(NSURL*)url
-{
- NSURLRequest* request = [NSURLRequest requestWithURL:url];
-
- if (_userAgentLockToken != 0) {
- [self.webView loadRequest:request];
- } else {
- [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
- _userAgentLockToken = lockToken;
- [CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
- [self.webView loadRequest:request];
- }];
- }
-}
-
-- (void)goBack:(id)sender
-{
- [self.webView goBack];
-}
-
-- (void)goForward:(id)sender
-{
- [self.webView goForward];
-}
-
-#pragma mark UIWebViewDelegate
-
-- (void)webViewDidStartLoad:(UIWebView*)theWebView
-{
- // loading url, start spinner, update back/forward
-
- self.addressLabel.text = @"Loading...";
- self.backButton.enabled = theWebView.canGoBack;
- self.forwardButton.enabled = theWebView.canGoForward;
-
- [self.spinner startAnimating];
-
- return [self.navigationDelegate webViewDidStartLoad:theWebView];
-}
-
-- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
-
- if (isTopLevelNavigation) {
- self.currentURL = request.URL;
- }
- return [self.navigationDelegate webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
-}
-
-- (void)webViewDidFinishLoad:(UIWebView*)theWebView
-{
- // update url, stop spinner, update back/forward
-
- self.addressLabel.text = [self.currentURL absoluteString];
- self.backButton.enabled = theWebView.canGoBack;
- self.forwardButton.enabled = theWebView.canGoForward;
-
- [self.spinner stopAnimating];
-
- // Work around a bug where the first time a PDF is opened, all UIWebViews
- // reload their User-Agent from NSUserDefaults.
- // This work-around makes the following assumptions:
- // 1. The app has only a single Cordova Webview. If not, then the app should
- // take it upon themselves to load a PDF in the background as a part of
- // their start-up flow.
- // 2. That the PDF does not require any additional network requests. We change
- // the user-agent here back to that of the CDVViewController, so requests
- // from it must pass through its white-list. This *does* break PDFs that
- // contain links to other remote PDF/websites.
- // More info at https://issues.apache.org/jira/browse/CB-2225
- BOOL isPDF = [@"true" isEqualToString :[theWebView stringByEvaluatingJavaScriptFromString:@"document.body==null"]];
- if (isPDF) {
- [CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
- }
-
- [self.navigationDelegate webViewDidFinishLoad:theWebView];
-}
-
-- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
-{
- // log fail message, stop spinner, update back/forward
- NSLog(@"webView:didFailLoadWithError - %@", [error localizedDescription]);
-
- self.backButton.enabled = theWebView.canGoBack;
- self.forwardButton.enabled = theWebView.canGoForward;
- [self.spinner stopAnimating];
-
- self.addressLabel.text = @"Load Error";
-
- [self.navigationDelegate webView:theWebView didFailLoadWithError:error];
-}
-
-#pragma mark CDVScreenOrientationDelegate
-
-- (BOOL)shouldAutorotate
-{
- if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) {
- return [self.orientationDelegate shouldAutorotate];
- }
- return YES;
-}
-
-- (NSUInteger)supportedInterfaceOrientations
-{
- if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
- return [self.orientationDelegate supportedInterfaceOrientations];
- }
-
- return 1 << UIInterfaceOrientationPortrait;
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
- return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
- }
-
- return YES;
-}
-
-@end
-
-@implementation CDVInAppBrowserOptions
-
-- (id)init
-{
- if (self = [super init]) {
- // default values
- self.location = YES;
- self.toolbar = YES;
- self.closebuttoncaption = nil;
-
- self.enableviewportscale = NO;
- self.mediaplaybackrequiresuseraction = NO;
- self.allowinlinemediaplayback = NO;
- self.keyboarddisplayrequiresuseraction = YES;
- self.suppressesincrementalrendering = NO;
- self.hidden = NO;
- }
-
- return self;
-}
-
-+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options
-{
- CDVInAppBrowserOptions* obj = [[CDVInAppBrowserOptions alloc] init];
-
- // NOTE: this parsing does not handle quotes within values
- NSArray* pairs = [options componentsSeparatedByString:@","];
-
- // parse keys and values, set the properties
- for (NSString* pair in pairs) {
- NSArray* keyvalue = [pair componentsSeparatedByString:@"="];
-
- if ([keyvalue count] == 2) {
- NSString* key = [[keyvalue objectAtIndex:0] lowercaseString];
- NSString* value = [keyvalue objectAtIndex:1];
- NSString* value_lc = [value lowercaseString];
-
- BOOL isBoolean = [value_lc isEqualToString:@"yes"] || [value_lc isEqualToString:@"no"];
- NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
- [numberFormatter setAllowsFloats:YES];
- BOOL isNumber = [numberFormatter numberFromString:value_lc] != nil;
-
- // set the property according to the key name
- if ([obj respondsToSelector:NSSelectorFromString(key)]) {
- if (isNumber) {
- [obj setValue:[numberFormatter numberFromString:value_lc] forKey:key];
- } else if (isBoolean) {
- [obj setValue:[NSNumber numberWithBool:[value_lc isEqualToString:@"yes"]] forKey:key];
- } else {
- [obj setValue:value forKey:key];
- }
- }
- }
- }
-
- return obj;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.h b/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.h
deleted file mode 100755
index 7be8884..0000000
--- a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.h
+++ /dev/null
@@ -1,57 +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>
-
-@interface CDVInvokedUrlCommand : NSObject {
- NSString* _callbackId;
- NSString* _className;
- NSString* _methodName;
- NSArray* _arguments;
-}
-
-@property (nonatomic, readonly) NSArray* arguments;
-@property (nonatomic, readonly) NSString* callbackId;
-@property (nonatomic, readonly) NSString* className;
-@property (nonatomic, readonly) NSString* methodName;
-
-+ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry;
-
-- (id)initWithArguments:(NSArray*)arguments
- callbackId:(NSString*)callbackId
- className:(NSString*)className
- methodName:(NSString*)methodName;
-
-- (id)initFromJson:(NSArray*)jsonEntry;
-
-// The first NSDictionary found in the arguments will be returned in legacyDict.
-// The arguments array with be prepended with the callbackId and have the first
-// dict removed from it.
-- (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict;
-
-// Returns the argument at the given index.
-// If index >= the number of arguments, returns nil.
-// If the argument at the given index is NSNull, returns nil.
-- (id)argumentAtIndex:(NSUInteger)index;
-// Same as above, but returns defaultValue instead of nil.
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue;
-// Same as above, but returns defaultValue instead of nil, and if the argument is not of the expected class, returns defaultValue
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m b/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m
deleted file mode 100755
index 6c7a856..0000000
--- a/iPhone/CordovaLib/Classes/CDVInvokedUrlCommand.m
+++ /dev/null
@@ -1,140 +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 "CDVInvokedUrlCommand.h"
-#import "CDVJSON.h"
-#import "NSData+Base64.h"
-
-@implementation CDVInvokedUrlCommand
-
-@synthesize arguments = _arguments;
-@synthesize callbackId = _callbackId;
-@synthesize className = _className;
-@synthesize methodName = _methodName;
-
-+ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry
-{
- return [[CDVInvokedUrlCommand alloc] initFromJson:jsonEntry];
-}
-
-- (id)initFromJson:(NSArray*)jsonEntry
-{
- id tmp = [jsonEntry objectAtIndex:0];
- NSString* callbackId = tmp == [NSNull null] ? nil : tmp;
- NSString* className = [jsonEntry objectAtIndex:1];
- NSString* methodName = [jsonEntry objectAtIndex:2];
- NSMutableArray* arguments = [jsonEntry objectAtIndex:3];
-
- return [self initWithArguments:arguments
- callbackId:callbackId
- className:className
- methodName:methodName];
-}
-
-- (id)initWithArguments:(NSArray*)arguments
- callbackId:(NSString*)callbackId
- className:(NSString*)className
- methodName:(NSString*)methodName
-{
- self = [super init];
- if (self != nil) {
- _arguments = arguments;
- _callbackId = callbackId;
- _className = className;
- _methodName = methodName;
- }
- [self massageArguments];
- return self;
-}
-
-- (void)massageArguments
-{
- NSMutableArray* newArgs = nil;
-
- for (NSUInteger i = 0, count = [_arguments count]; i < count; ++i) {
- id arg = [_arguments objectAtIndex:i];
- if (![arg isKindOfClass:[NSDictionary class]]) {
- continue;
- }
- NSDictionary* dict = arg;
- NSString* type = [dict objectForKey:@"CDVType"];
- if (!type || ![type isEqualToString:@"ArrayBuffer"]) {
- continue;
- }
- NSString* data = [dict objectForKey:@"data"];
- if (!data) {
- continue;
- }
- if (newArgs == nil) {
- newArgs = [NSMutableArray arrayWithArray:_arguments];
- _arguments = newArgs;
- }
- [newArgs replaceObjectAtIndex:i withObject:[NSData dataFromBase64String:data]];
- }
-}
-
-- (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict
-{
- NSMutableArray* newArguments = [NSMutableArray arrayWithArray:_arguments];
-
- for (NSUInteger i = 0; i < [newArguments count]; ++i) {
- if ([[newArguments objectAtIndex:i] isKindOfClass:[NSDictionary class]]) {
- if (legacyDict != NULL) {
- *legacyDict = [newArguments objectAtIndex:i];
- }
- [newArguments removeObjectAtIndex:i];
- break;
- }
- }
-
- // Legacy (two versions back) has no callbackId.
- if (_callbackId != nil) {
- [newArguments insertObject:_callbackId atIndex:0];
- }
- if (legacyArguments != NULL) {
- *legacyArguments = newArguments;
- }
-}
-
-- (id)argumentAtIndex:(NSUInteger)index
-{
- return [self argumentAtIndex:index withDefault:nil];
-}
-
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue
-{
- return [self argumentAtIndex:index withDefault:defaultValue andClass:nil];
-}
-
-- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue andClass:(Class)aClass
-{
- if (index >= [_arguments count]) {
- return defaultValue;
- }
- id ret = [_arguments objectAtIndex:index];
- if (ret == [NSNull null]) {
- ret = defaultValue;
- }
- if ((aClass != nil) && ![ret isKindOfClass:aClass]) {
- ret = defaultValue;
- }
- return ret;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVJSON.h b/iPhone/CordovaLib/Classes/CDVJSON.h
deleted file mode 100755
index eaa895e..0000000
--- a/iPhone/CordovaLib/Classes/CDVJSON.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.
- */
-
-@interface NSArray (CDVJSONSerializing)
-- (NSString*)JSONString;
-@end
-
-@interface NSDictionary (CDVJSONSerializing)
-- (NSString*)JSONString;
-@end
-
-@interface NSString (CDVJSONSerializing)
-- (id)JSONObject;
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVJSON.m b/iPhone/CordovaLib/Classes/CDVJSON.m
deleted file mode 100755
index 78267e5..0000000
--- a/iPhone/CordovaLib/Classes/CDVJSON.m
+++ /dev/null
@@ -1,77 +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 "CDVJSON.h"
-#import <Foundation/NSJSONSerialization.h>
-
-@implementation NSArray (CDVJSONSerializing)
-
-- (NSString*)JSONString
-{
- NSError* error = nil;
- NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
- options:NSJSONWritingPrettyPrinted
- error:&error];
-
- if (error != nil) {
- NSLog(@"NSArray JSONString error: %@", [error localizedDescription]);
- return nil;
- } else {
- return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
-}
-
-@end
-
-@implementation NSDictionary (CDVJSONSerializing)
-
-- (NSString*)JSONString
-{
- NSError* error = nil;
- NSData* jsonData = [NSJSONSerialization dataWithJSONObject:self
- options:NSJSONWritingPrettyPrinted
- error:&error];
-
- if (error != nil) {
- NSLog(@"NSDictionary JSONString error: %@", [error localizedDescription]);
- return nil;
- } else {
- return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
-}
-
-@end
-
-@implementation NSString (CDVJSONSerializing)
-
-- (id)JSONObject
-{
- NSError* error = nil;
- id object = [NSJSONSerialization JSONObjectWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
- options:kNilOptions
- error:&error];
-
- if (error != nil) {
- NSLog(@"NSString JSONObject error: %@", [error localizedDescription]);
- }
-
- return object;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVJpegHeaderWriter.h b/iPhone/CordovaLib/Classes/CDVJpegHeaderWriter.h
deleted file mode 100755
index 3b43ef0..0000000
--- a/iPhone/CordovaLib/Classes/CDVJpegHeaderWriter.h
+++ /dev/null
@@ -1,62 +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>
-
-@interface CDVJpegHeaderWriter : NSObject {
- NSDictionary * SubIFDTagFormatDict;
- NSDictionary * IFD0TagFormatDict;
-}
-
-- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata
- withExifBlock: (NSString*) exifstr;
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict;
-- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb
- withPlaces: (NSNumber*) width;
-- (NSString*) formatNumberWithLeadingZeroes: (NSNumber*) numb
- withPlaces: (NSNumber*) places;
-- (NSString*) decimalToUnsignedRational: (NSNumber*) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator;
-- (void) continuedFraction: (double) val
- withFractionList: (NSMutableArray*) fractionlist
- withHorizon: (int) horizon;
-//- (void) expandContinuedFraction: (NSArray*) fractionlist;
-- (void) splitDouble: (double) val
- withIntComponent: (int*) rightside
- withFloatRemainder: (double*) leftside;
-- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator
- withDenominator: (NSNumber*) denominator
- asSigned: (Boolean) signedFlag;
-- (NSString*) hexStringFromData : (NSData*) data;
-- (NSNumber*) numericFromHexString : (NSString *) hexstring;
-
-/*
-- (void) readExifMetaData : (NSData*) imgdata;
-- (void) spliceImageData : (NSData*) imgdata withExifData: (NSDictionary*) exifdata;
-- (void) locateExifMetaData : (NSData*) imgdata;
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict;
-- (void) createExifDataString : (NSDictionary*) datadict;
-- (NSString*) createDataElement : (NSString*) element
- withElementData: (NSString*) data
- withExternalDataBlock: (NSDictionary*) memblock;
-- (NSString*) hexStringFromData : (NSData*) data;
-- (NSNumber*) numericFromHexString : (NSString *) hexstring;
-*/
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVJpegHeaderWriter.m b/iPhone/CordovaLib/Classes/CDVJpegHeaderWriter.m
deleted file mode 100755
index 93cafb8..0000000
--- a/iPhone/CordovaLib/Classes/CDVJpegHeaderWriter.m
+++ /dev/null
@@ -1,547 +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 "CDVJpegHeaderWriter.h"
-#include "CDVExif.h"
-
-/* macros for tag info shorthand:
- tagno : tag number
- typecode : data type
- components : number of components
- appendString (TAGINF_W_APPEND only) : string to append to data
- Exif date data format include an extra 0x00 to the end of the data
- */
-#define TAGINF(tagno, typecode, components) [NSArray arrayWithObjects: tagno, typecode, components, nil]
-#define TAGINF_W_APPEND(tagno, typecode, components, appendString) [NSArray arrayWithObjects: tagno, typecode, components, appendString, nil]
-
-const uint mJpegId = 0xffd8; // JPEG format marker
-const uint mExifMarker = 0xffe1; // APP1 jpeg header marker
-const uint mExif = 0x45786966; // ASCII 'Exif', first characters of valid exif header after size
-const uint mMotorallaByteAlign = 0x4d4d; // 'MM', motorola byte align, msb first or 'sane'
-const uint mIntelByteAlgin = 0x4949; // 'II', Intel byte align, lsb first or 'batshit crazy reverso world'
-const uint mTiffLength = 0x2a; // after byte align bits, next to bits are 0x002a(MM) or 0x2a00(II), tiff version number
-
-
-@implementation CDVJpegHeaderWriter
-
-- (id) init {
- self = [super init];
- // supported tags for exif IFD
- IFD0TagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- // TAGINF(@"010e", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"ImageDescription",
- TAGINF_W_APPEND(@"0132", [NSNumber numberWithInt:EDT_ASCII_STRING], @20, @"00"), @"DateTime",
- TAGINF(@"010f", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Make",
- TAGINF(@"0110", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Model",
- TAGINF(@"0131", [NSNumber numberWithInt:EDT_ASCII_STRING], @0), @"Software",
- TAGINF(@"011a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"XResolution",
- TAGINF(@"011b", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"YResolution",
- // currently supplied outside of Exif data block by UIImagePickerControllerMediaMetadata, this is set manually in CDVCamera.m
- /* TAGINF(@"0112", [NSNumber numberWithInt:EDT_USHORT], @1), @"Orientation",
-
- // rest of the tags are supported by exif spec, but are not specified by UIImagePickerControllerMediaMedadata
- // should camera hardware supply these values in future versions, or if they can be derived, ImageHeaderWriter will include them gracefully
- TAGINF(@"0128", [NSNumber numberWithInt:EDT_USHORT], @1), @"ResolutionUnit",
- TAGINF(@"013e", [NSNumber numberWithInt:EDT_URATIONAL], @2), @"WhitePoint",
- TAGINF(@"013f", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"PrimaryChromaticities",
- TAGINF(@"0211", [NSNumber numberWithInt:EDT_URATIONAL], @3), @"YCbCrCoefficients",
- TAGINF(@"0213", [NSNumber numberWithInt:EDT_USHORT], @1), @"YCbCrPositioning",
- TAGINF(@"0214", [NSNumber numberWithInt:EDT_URATIONAL], @6), @"ReferenceBlackWhite",
- TAGINF(@"8298", [NSNumber numberWithInt:EDT_URATIONAL], @0), @"Copyright",
-
- // offset to exif subifd, we determine this dynamically based on the size of the main exif IFD
- TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset",*/
- nil];
-
-
- // supported tages for exif subIFD
- SubIFDTagFormatDict = [[NSDictionary alloc] initWithObjectsAndKeys:
- //TAGINF(@"9000", [NSNumber numberWithInt:], @), @"ExifVersion",
- //TAGINF(@"9202",[NSNumber numberWithInt:EDT_URATIONAL],@1), @"ApertureValue",
- //TAGINF(@"9203",[NSNumber numberWithInt:EDT_SRATIONAL],@1), @"BrightnessValue",
- TAGINF(@"a001",[NSNumber numberWithInt:EDT_USHORT],@1), @"ColorSpace",
- TAGINF_W_APPEND(@"9004",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeDigitized",
- TAGINF_W_APPEND(@"9003",[NSNumber numberWithInt:EDT_ASCII_STRING],@20,@"00"), @"DateTimeOriginal",
- TAGINF(@"a402", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureMode",
- TAGINF(@"8822", [NSNumber numberWithInt:EDT_USHORT], @1), @"ExposureProgram",
- //TAGINF(@"829a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"ExposureTime",
- //TAGINF(@"829d", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FNumber",
- TAGINF(@"9209", [NSNumber numberWithInt:EDT_USHORT], @1), @"Flash",
- // FocalLengthIn35mmFilm
- TAGINF(@"a405", [NSNumber numberWithInt:EDT_USHORT], @1), @"FocalLenIn35mmFilm",
- //TAGINF(@"920a", [NSNumber numberWithInt:EDT_URATIONAL], @1), @"FocalLength",
- //TAGINF(@"8827", [NSNumber numberWithInt:EDT_USHORT], @2), @"ISOSpeedRatings",
- TAGINF(@"9207", [NSNumber numberWithInt:EDT_USHORT],@1), @"MeteringMode",
- // specific to compressed data
- TAGINF(@"a002", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelXDimension",
- TAGINF(@"a003", [NSNumber numberWithInt:EDT_ULONG],@1), @"PixelYDimension",
- // data type undefined, but this is a DSC camera, so value is always 1, treat as ushort
- TAGINF(@"a301", [NSNumber numberWithInt:EDT_USHORT],@1), @"SceneType",
- TAGINF(@"a217",[NSNumber numberWithInt:EDT_USHORT],@1), @"SensingMethod",
- //TAGINF(@"9201", [NSNumber numberWithInt:EDT_SRATIONAL], @1), @"ShutterSpeedValue",
- // specifies location of main subject in scene (x,y,wdith,height) expressed before rotation processing
- //TAGINF(@"9214", [NSNumber numberWithInt:EDT_USHORT], @4), @"SubjectArea",
- TAGINF(@"a403", [NSNumber numberWithInt:EDT_USHORT], @1), @"WhiteBalance",
- nil];
- return self;
-}
-
-- (NSData*) spliceExifBlockIntoJpeg: (NSData*) jpegdata withExifBlock: (NSString*) exifstr {
-
- CDVJpegHeaderWriter * exifWriter = [[CDVJpegHeaderWriter alloc] init];
-
- NSMutableData * exifdata = [NSMutableData dataWithCapacity: [exifstr length]/2];
- int idx;
- for (idx = 0; idx+1 < [exifstr length]; idx+=2) {
- NSRange range = NSMakeRange(idx, 2);
- NSString* hexStr = [exifstr substringWithRange:range];
- NSScanner* scanner = [NSScanner scannerWithString:hexStr];
- unsigned int intValue;
- [scanner scanHexInt:&intValue];
- [exifdata appendBytes:&intValue length:1];
- }
-
- NSMutableData * ddata = [NSMutableData dataWithCapacity: [jpegdata length]];
- NSMakeRange(0,4);
- int loc = 0;
- bool done = false;
- // read the jpeg data until we encounter the app1==0xFFE1 marker
- while (loc+1 < [jpegdata length]) {
- NSData * blag = [jpegdata subdataWithRange: NSMakeRange(loc,2)];
- if( [[blag description] isEqualToString : @"<ffe1>"]) {
- // read the APP1 block size bits
- NSString * the = [exifWriter hexStringFromData:[jpegdata subdataWithRange: NSMakeRange(loc+2,2)]];
- NSNumber * app1width = [exifWriter numericFromHexString:the];
- //consume the original app1 block
- [ddata appendData:exifdata];
- // advance our loc marker past app1
- loc += [app1width intValue] + 2;
- done = true;
- } else {
- if(!done) {
- [ddata appendData:blag];
- loc += 2;
- } else {
- break;
- }
- }
- }
- // copy the remaining data
- [ddata appendData:[jpegdata subdataWithRange: NSMakeRange(loc,[jpegdata length]-loc)]];
- return ddata;
-}
-
-
-
-/**
- * Create the Exif data block as a hex string
- * jpeg uses Application Markers (APP's) as markers for application data
- * APP1 is the application marker reserved for exif data
- *
- * (NSDictionary*) datadict - with subdictionaries marked '{TIFF}' and '{EXIF}' as returned by imagePickerController with a valid
- * didFinishPickingMediaWithInfo data dict, under key @"UIImagePickerControllerMediaMetadata"
- *
- * the following constructs a hex string to Exif specifications, and is therefore brittle
- * altering the order of arguments to the string constructors, modifying field sizes or formats,
- * and any other minor change will likely prevent the exif data from being read
- */
-- (NSString*) createExifAPP1 : (NSDictionary*) datadict {
- NSMutableString * app1; // holds finalized product
- NSString * exifIFD; // exif information file directory
- NSString * subExifIFD; // subexif information file directory
-
- // FFE1 is the hex APP1 marker code, and will allow client apps to read the data
- NSString * app1marker = @"ffe1";
- // SSSS size, to be determined
- // EXIF ascii characters followed by 2bytes of zeros
- NSString * exifmarker = @"457869660000";
- // Tiff header: 4d4d is motorolla byte align (big endian), 002a is hex for 42
- NSString * tiffheader = @"4d4d002a";
- //first IFD offset from the Tiff header to IFD0. Since we are writing it, we know it's address 0x08
- NSString * ifd0offset = @"00000008";
- // current offset to next data area
- int currentDataOffset = 0;
-
- //data labeled as TIFF in UIImagePickerControllerMediaMetaData is part of the EXIF IFD0 portion of APP1
- exifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{TIFF}"] withFormatDict: IFD0TagFormatDict isIFD0:YES currentDataOffset:&currentDataOffset];
-
- //data labeled as EXIF in UIImagePickerControllerMediaMetaData is part of the EXIF Sub IFD portion of APP1
- subExifIFD = [self createExifIFDFromDict: [datadict objectForKey:@"{Exif}"] withFormatDict: SubIFDTagFormatDict isIFD0:NO currentDataOffset:&currentDataOffset];
- /*
- NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",exifIFD,[exifIFD length]);
-
- NSLog(@"SUB EXIF IFD %@ WITH SIZE: %d",subExifIFD,[subExifIFD length]);
- */
- // construct the complete app1 data block
- app1 = [[NSMutableString alloc] initWithFormat: @"%@%04x%@%@%@%@%@",
- app1marker,
- 16 + ([exifIFD length]/2) + ([subExifIFD length]/2) /*16+[exifIFD length]/2*/,
- exifmarker,
- tiffheader,
- ifd0offset,
- exifIFD,
- subExifIFD];
-
- return app1;
-}
-
-// returns hex string representing a valid exif information file directory constructed from the datadict and formatdict
-- (NSString*) createExifIFDFromDict : (NSDictionary*) datadict
- withFormatDict : (NSDictionary*) formatdict
- isIFD0 : (BOOL) ifd0flag
- currentDataOffset : (int*) dataoffset {
- NSArray * datakeys = [datadict allKeys]; // all known data keys
- NSArray * knownkeys = [formatdict allKeys]; // only keys in knowkeys are considered for entry in this IFD
- NSMutableArray * ifdblock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // all ifd entries
- NSMutableArray * ifddatablock = [[NSMutableArray alloc] initWithCapacity: [datadict count]]; // data block entries
- // ifd0flag = NO; // ifd0 requires a special flag and has offset to next ifd appended to end
-
- // iterate through known provided data keys
- for (int i = 0; i < [datakeys count]; i++) {
- NSString * key = [datakeys objectAtIndex:i];
- // don't muck about with unknown keys
- if ([knownkeys indexOfObject: key] != NSNotFound) {
- // create new IFD entry
- NSString * entry = [self createIFDElement: key
- withFormat: [formatdict objectForKey:key]
- withElementData: [datadict objectForKey:key]];
- // create the IFD entry's data block
- NSString * data = [self createIFDElementDataWithFormat: [formatdict objectForKey:key]
- withData: [datadict objectForKey:key]];
- if (entry) {
- [ifdblock addObject:entry];
- if(!data) {
- [ifdblock addObject:@""];
- } else {
- [ifddatablock addObject:data];
- }
- }
- }
- }
-
- NSMutableString * exifstr = [[NSMutableString alloc] initWithCapacity: [ifdblock count] * 24];
- NSMutableString * dbstr = [[NSMutableString alloc] initWithCapacity: 100];
-
- int addr=*dataoffset; // current offset/address in datablock
- if (ifd0flag) {
- // calculate offset to datablock based on ifd file entry count
- addr += 14+(12*([ifddatablock count]+1)); // +1 for tag 0x8769, exifsubifd offset
- } else {
- // current offset + numSubIFDs (2-bytes) + 12*numSubIFDs + endMarker (4-bytes)
- addr += 2+(12*[ifddatablock count])+4;
- }
-
- for (int i = 0; i < [ifdblock count]; i++) {
- NSString * entry = [ifdblock objectAtIndex:i];
- NSString * data = [ifddatablock objectAtIndex:i];
-
- // check if the data fits into 4 bytes
- if( [data length] <= 8) {
- // concatenate the entry and the (4byte) data entry into the final IFD entry and append to exif ifd string
- [exifstr appendFormat : @"%@%@", entry, data];
- } else {
- [exifstr appendFormat : @"%@%08x", entry, addr];
- [dbstr appendFormat: @"%@", data];
- addr+= [data length] / 2;
- /*
- NSLog(@"=====data-length[%i]=======",[data length]);
- NSLog(@"addr-offset[%i]",addr);
- NSLog(@"entry[%@]",entry);
- NSLog(@"data[%@]",data);
- */
- }
- }
-
- // calculate IFD0 terminal offset tags, currently ExifSubIFD
- int entrycount = [ifdblock count];
- if (ifd0flag) {
- // 18 accounts for 8769's width + offset to next ifd, 8 accounts for start of header
- NSNumber * offset = [NSNumber numberWithInt:[exifstr length] / 2 + [dbstr length] / 2 + 18+8];
-
- [self appendExifOffsetTagTo: exifstr
- withOffset : offset];
- entrycount++;
- }
- *dataoffset = addr;
- return [[NSString alloc] initWithFormat: @"%04x%@%@%@",
- entrycount,
- exifstr,
- @"00000000", // offset to next IFD, 0 since there is none
- dbstr]; // lastly, the datablock
-}
-
-// Creates an exif formatted exif information file directory entry
-- (NSString*) createIFDElement: (NSString*) elementName withFormat: (NSArray*) formtemplate withElementData: (NSString*) data {
- //NSArray * fielddata = [formatdict objectForKey: elementName];// format data of desired field
- if (formtemplate) {
- // format string @"%@%@%@%@", tag number, data format, components, value
- NSNumber * dataformat = [formtemplate objectAtIndex:1];
- NSNumber * components = [formtemplate objectAtIndex:2];
- if([components intValue] == 0) {
- components = [NSNumber numberWithInt: [data length] * DataTypeToWidth[[dataformat intValue]-1]];
- }
-
- return [[NSString alloc] initWithFormat: @"%@%@%08x",
- [formtemplate objectAtIndex:0], // the field code
- [self formatNumberWithLeadingZeroes: dataformat withPlaces: @4], // the data type code
- [components intValue]]; // number of components
- }
- return NULL;
-}
-
-/**
- * appends exif IFD0 tag 8769 "ExifOffset" to the string provided
- * (NSMutableString*) str - string you wish to append the 8769 tag to: APP1 or IFD0 hex data string
- * // TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1), @"ExifOffset",
- */
-- (void) appendExifOffsetTagTo: (NSMutableString*) str withOffset : (NSNumber*) offset {
- NSArray * format = TAGINF(@"8769", [NSNumber numberWithInt:EDT_ULONG], @1);
-
- NSString * entry = [self createIFDElement: @"ExifOffset"
- withFormat: format
- withElementData: [offset stringValue]];
-
- NSString * data = [self createIFDElementDataWithFormat: format
- withData: [offset stringValue]];
- [str appendFormat:@"%@%@", entry, data];
-}
-
-// formats the Information File Directory Data to exif format
-- (NSString*) createIFDElementDataWithFormat: (NSArray*) dataformat withData: (NSString*) data {
- NSMutableString * datastr = nil;
- NSNumber * tmp = nil;
- NSNumber * formatcode = [dataformat objectAtIndex:1];
- NSUInteger formatItemsCount = [dataformat count];
- NSNumber * num = @0;
- NSNumber * denom = @0;
-
- switch ([formatcode intValue]) {
- case EDT_UBYTE:
- break;
- case EDT_ASCII_STRING:
- datastr = [[NSMutableString alloc] init];
- for (int i = 0; i < [data length]; i++) {
- [datastr appendFormat:@"%02x",[data characterAtIndex:i]];
- }
- if (formatItemsCount > 3) {
- // We have additional data to append.
- // currently used by Date format to append final 0x00 but can be used by other data types as well in the future
- [datastr appendString:[dataformat objectAtIndex:3]];
- }
- if ([datastr length] < 8) {
- NSString * format = [NSString stringWithFormat:@"%%0%dd", 8 - [datastr length]];
- [datastr appendFormat:format,0];
- }
- return datastr;
- case EDT_USHORT:
- return [[NSString alloc] initWithFormat : @"%@%@",
- [self formattedHexStringFromDecimalNumber: [NSNumber numberWithInt: [data intValue]] withPlaces: @4],
- @"0000"];
- case EDT_ULONG:
- tmp = [NSNumber numberWithUnsignedLong:[data intValue]];
- return [NSString stringWithFormat : @"%@",
- [self formattedHexStringFromDecimalNumber: tmp withPlaces: @8]];
- case EDT_URATIONAL:
- return [self decimalToUnsignedRational: [NSNumber numberWithDouble:[data doubleValue]]
- withResultNumerator: &num
- withResultDenominator: &denom];
- case EDT_SBYTE:
-
- break;
- case EDT_UNDEFINED:
- break; // 8 bits
- case EDT_SSHORT:
- break;
- case EDT_SLONG:
- break; // 32bit signed integer (2's complement)
- case EDT_SRATIONAL:
- break; // 2 SLONGS, first long is numerator, second is denominator
- case EDT_SINGLEFLOAT:
- break;
- case EDT_DOUBLEFLOAT:
- break;
- }
- return datastr;
-}
-
-//======================================================================================================================
-// Utility Methods
-//======================================================================================================================
-
-// creates a formatted little endian hex string from a number and width specifier
-- (NSString*) formattedHexStringFromDecimalNumber: (NSNumber*) numb withPlaces: (NSNumber*) width {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:[width intValue]];
- NSString * formatstr = [[NSString alloc] initWithFormat: @"%%%@%dx", @"0", [width intValue]];
- [str appendFormat:formatstr, [numb intValue]];
- return str;
-}
-
-// format number as string with leading 0's
-- (NSString*) formatNumberWithLeadingZeroes: (NSNumber *) numb withPlaces: (NSNumber *) places {
- NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init];
- NSString *formatstr = [@"" stringByPaddingToLength:[places unsignedIntegerValue] withString:@"0" startingAtIndex:0];
- [formatter setPositiveFormat:formatstr];
- return [formatter stringFromNumber:numb];
-}
-
-// approximate a decimal with a rational by method of continued fraction
-// can be collasped into decimalToUnsignedRational after testing
-- (void) decimalToRational: (NSNumber *) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8];
-
- [self continuedFraction: [numb doubleValue]
- withFractionList: fractionlist
- withHorizon: 8];
-
- // simplify complex fraction represented by partial fraction list
- [self expandContinuedFraction: fractionlist
- withResultNumerator: numerator
- withResultDenominator: denominator];
-
-}
-
-// approximate a decimal with an unsigned rational by method of continued fraction
-- (NSString*) decimalToUnsignedRational: (NSNumber *) numb
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- NSMutableArray * fractionlist = [[NSMutableArray alloc] initWithCapacity:8];
-
- // generate partial fraction list
- [self continuedFraction: [numb doubleValue]
- withFractionList: fractionlist
- withHorizon: 8];
-
- // simplify complex fraction represented by partial fraction list
- [self expandContinuedFraction: fractionlist
- withResultNumerator: numerator
- withResultDenominator: denominator];
-
- return [self formatFractionList: fractionlist];
-}
-
-// recursive implementation of decimal approximation by continued fraction
-- (void) continuedFraction: (double) val
- withFractionList: (NSMutableArray*) fractionlist
- withHorizon: (int) horizon {
- int whole;
- double remainder;
- // 1. split term
- [self splitDouble: val withIntComponent: &whole withFloatRemainder: &remainder];
- [fractionlist addObject: [NSNumber numberWithInt:whole]];
-
- // 2. calculate reciprocal of remainder
- if (!remainder) return; // early exit, exact fraction found, avoids recip/0
- double recip = 1 / remainder;
-
- // 3. exit condition
- if ([fractionlist count] > horizon) {
- return;
- }
-
- // 4. recurse
- [self continuedFraction:recip withFractionList: fractionlist withHorizon: horizon];
-
-}
-
-// expand continued fraction list, creating a single level rational approximation
--(void) expandContinuedFraction: (NSArray*) fractionlist
- withResultNumerator: (NSNumber**) numerator
- withResultDenominator: (NSNumber**) denominator {
- int i = 0;
- int den = 0;
- int num = 0;
- if ([fractionlist count] == 1) {
- *numerator = [NSNumber numberWithInt:[[fractionlist objectAtIndex:0] intValue]];
- *denominator = @1;
- return;
- }
-
- //begin at the end of the list
- i = [fractionlist count] - 1;
- num = 1;
- den = [[fractionlist objectAtIndex:i] intValue];
-
- while (i > 0) {
- int t = [[fractionlist objectAtIndex: i-1] intValue];
- num = t * den + num;
- if (i==1) {
- break;
- } else {
- t = num;
- num = den;
- den = t;
- }
- i--;
- }
- // set result parameters values
- *numerator = [NSNumber numberWithInt: num];
- *denominator = [NSNumber numberWithInt: den];
-}
-
-// formats expanded fraction list to string matching exif specification
-- (NSString*) formatFractionList: (NSArray *) fractionlist {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16];
-
- if ([fractionlist count] == 1){
- [str appendFormat: @"%08x00000001", [[fractionlist objectAtIndex:0] intValue]];
- }
- return str;
-}
-
-// format rational as
-- (NSString*) formatRationalWithNumerator: (NSNumber*) numerator withDenominator: (NSNumber*) denominator asSigned: (Boolean) signedFlag {
- NSMutableString * str = [[NSMutableString alloc] initWithCapacity:16];
- if (signedFlag) {
- long num = [numerator longValue];
- long den = [denominator longValue];
- [str appendFormat: @"%08lx%08lx", num >= 0 ? num : ~ABS(num) + 1, num >= 0 ? den : ~ABS(den) + 1];
- } else {
- [str appendFormat: @"%08lx%08lx", [numerator unsignedLongValue], [denominator unsignedLongValue]];
- }
- return str;
-}
-
-// split a floating point number into two integer values representing the left and right side of the decimal
-- (void) splitDouble: (double) val withIntComponent: (int*) rightside withFloatRemainder: (double*) leftside {
- *rightside = val; // convert numb to int representation, which truncates the decimal portion
- *leftside = val - *rightside;
-}
-
-
-//
-- (NSString*) hexStringFromData : (NSData*) data {
- //overflow detection
- const unsigned char *dataBuffer = [data bytes];
- return [[NSString alloc] initWithFormat: @"%02x%02x",
- (unsigned char)dataBuffer[0],
- (unsigned char)dataBuffer[1]];
-}
-
-// convert a hex string to a number
-- (NSNumber*) numericFromHexString : (NSString *) hexstring {
- NSScanner * scan = NULL;
- unsigned int numbuf= 0;
-
- scan = [NSScanner scannerWithString:hexstring];
- [scan scanHexInt:&numbuf];
- return [NSNumber numberWithInt:numbuf];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVLocalStorage.h b/iPhone/CordovaLib/Classes/CDVLocalStorage.h
deleted file mode 100755
index dec6ab3..0000000
--- a/iPhone/CordovaLib/Classes/CDVLocalStorage.h
+++ /dev/null
@@ -1,50 +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 "CDVPlugin.h"
-
-#define kCDVLocalStorageErrorDomain @"kCDVLocalStorageErrorDomain"
-#define kCDVLocalStorageFileOperationError 1
-
-@interface CDVLocalStorage : CDVPlugin
-
-@property (nonatomic, readonly, strong) NSMutableArray* backupInfo;
-
-- (BOOL)shouldBackup;
-- (BOOL)shouldRestore;
-- (void)backup:(CDVInvokedUrlCommand*)command;
-- (void)restore:(CDVInvokedUrlCommand*)command;
-
-+ (void)__fixupDatabaseLocationsWithBackupType:(NSString*)backupType;
-// Visible for testing.
-+ (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
- bundlePath:(NSString*)bundlePath
- fileManager:(NSFileManager*)fileManager;
-@end
-
-@interface CDVBackupInfo : NSObject
-
-@property (nonatomic, copy) NSString* original;
-@property (nonatomic, copy) NSString* backup;
-@property (nonatomic, copy) NSString* label;
-
-- (BOOL)shouldBackup;
-- (BOOL)shouldRestore;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVLocalStorage.m b/iPhone/CordovaLib/Classes/CDVLocalStorage.m
deleted file mode 100755
index 238d680..0000000
--- a/iPhone/CordovaLib/Classes/CDVLocalStorage.m
+++ /dev/null
@@ -1,485 +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 "CDVLocalStorage.h"
-#import "CDV.h"
-
-@interface CDVLocalStorage ()
-
-@property (nonatomic, readwrite, strong) NSMutableArray* backupInfo; // array of CDVBackupInfo objects
-@property (nonatomic, readwrite, weak) id <UIWebViewDelegate> webviewDelegate;
-
-@end
-
-@implementation CDVLocalStorage
-
-@synthesize backupInfo, webviewDelegate;
-
-- (void)pluginInitialize
-{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResignActive)
- name:UIApplicationWillResignActiveNotification object:nil];
- BOOL cloudBackup = [@"cloud" isEqualToString : self.commandDelegate.settings[@"BackupWebStorage"]];
-
- self.backupInfo = [[self class] createBackupInfoWithCloudBackup:cloudBackup];
-}
-
-#pragma mark -
-#pragma mark Plugin interface methods
-
-+ (NSMutableArray*)createBackupInfoWithTargetDir:(NSString*)targetDir backupDir:(NSString*)backupDir targetDirNests:(BOOL)targetDirNests backupDirNests:(BOOL)backupDirNests rename:(BOOL)rename
-{
- /*
- This "helper" does so much work and has so many options it would probably be clearer to refactor the whole thing.
- Basically, there are three database locations:
-
- 1. "Normal" dir -- LIB/<nested dires WebKit/LocalStorage etc>/<normal filenames>
- 2. "Caches" dir -- LIB/Caches/<normal filenames>
- 3. "Backup" dir -- DOC/Backups/<renamed filenames>
-
- And between these three, there are various migration paths, most of which only consider 2 of the 3, which is why this helper is based on 2 locations and has a notion of "direction".
- */
- NSMutableArray* backupInfo = [NSMutableArray arrayWithCapacity:3];
-
- NSString* original;
- NSString* backup;
- CDVBackupInfo* backupItem;
-
- // ////////// LOCALSTORAGE
-
- original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/file__0.localstorage":@"file__0.localstorage"];
- backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
- backup = [backup stringByAppendingPathComponent:(rename ? @"localstorage.appdata.db" : @"file__0.localstorage")];
-
- backupItem = [[CDVBackupInfo alloc] init];
- backupItem.backup = backup;
- backupItem.original = original;
- backupItem.label = @"localStorage database";
-
- [backupInfo addObject:backupItem];
-
- // ////////// WEBSQL MAIN DB
-
- original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/Databases.db":@"Databases.db"];
- backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
- backup = [backup stringByAppendingPathComponent:(rename ? @"websqlmain.appdata.db" : @"Databases.db")];
-
- backupItem = [[CDVBackupInfo alloc] init];
- backupItem.backup = backup;
- backupItem.original = original;
- backupItem.label = @"websql main database";
-
- [backupInfo addObject:backupItem];
-
- // ////////// WEBSQL DATABASES
-
- original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/file__0":@"file__0"];
- backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
- backup = [backup stringByAppendingPathComponent:(rename ? @"websqldbs.appdata.db" : @"file__0")];
-
- backupItem = [[CDVBackupInfo alloc] init];
- backupItem.backup = backup;
- backupItem.original = original;
- backupItem.label = @"websql databases";
-
- [backupInfo addObject:backupItem];
-
- return backupInfo;
-}
-
-+ (NSMutableArray*)createBackupInfoWithCloudBackup:(BOOL)cloudBackup
-{
- // create backup info from backup folder to caches folder
- NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
- NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
- NSString* cacheFolder = [appLibraryFolder stringByAppendingPathComponent:@"Caches"];
- NSString* backupsFolder = [appDocumentsFolder stringByAppendingPathComponent:@"Backups"];
-
- // create the backups folder, if needed
- [[NSFileManager defaultManager] createDirectoryAtPath:backupsFolder withIntermediateDirectories:YES attributes:nil error:nil];
-
- [self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:backupsFolder] skip:!cloudBackup];
-
- return [self createBackupInfoWithTargetDir:cacheFolder backupDir:backupsFolder targetDirNests:NO backupDirNests:NO rename:YES];
-}
-
-+ (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL*)URL skip:(BOOL)skip
-{
- NSAssert(IsAtLeastiOSVersion(@"5.1"), @"Cannot mark files for NSURLIsExcludedFromBackupKey on iOS less than 5.1");
-
- NSError* error = nil;
- BOOL success = [URL setResourceValue:[NSNumber numberWithBool:skip] forKey:NSURLIsExcludedFromBackupKey error:&error];
- if (!success) {
- NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
- }
- return success;
-}
-
-+ (BOOL)copyFrom:(NSString*)src to:(NSString*)dest error:(NSError* __autoreleasing*)error
-{
- NSFileManager* fileManager = [NSFileManager defaultManager];
-
- if (![fileManager fileExistsAtPath:src]) {
- NSString* errorString = [NSString stringWithFormat:@"%@ file does not exist.", src];
- if (error != NULL) {
- (*error) = [NSError errorWithDomain:kCDVLocalStorageErrorDomain
- code:kCDVLocalStorageFileOperationError
- userInfo:[NSDictionary dictionaryWithObject:errorString
- forKey:NSLocalizedDescriptionKey]];
- }
- return NO;
- }
-
- // generate unique filepath in temp directory
- CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
- CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
- NSString* tempBackup = [[NSTemporaryDirectory() stringByAppendingPathComponent:(__bridge NSString*)uuidString] stringByAppendingPathExtension:@"bak"];
- CFRelease(uuidString);
- CFRelease(uuidRef);
-
- BOOL destExists = [fileManager fileExistsAtPath:dest];
-
- // backup the dest
- if (destExists && ![fileManager copyItemAtPath:dest toPath:tempBackup error:error]) {
- return NO;
- }
-
- // remove the dest
- if (destExists && ![fileManager removeItemAtPath:dest error:error]) {
- return NO;
- }
-
- // create path to dest
- if (!destExists && ![fileManager createDirectoryAtPath:[dest stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:error]) {
- return NO;
- }
-
- // copy src to dest
- if ([fileManager copyItemAtPath:src toPath:dest error:error]) {
- // success - cleanup - delete the backup to the dest
- if ([fileManager fileExistsAtPath:tempBackup]) {
- [fileManager removeItemAtPath:tempBackup error:error];
- }
- return YES;
- } else {
- // failure - we restore the temp backup file to dest
- [fileManager copyItemAtPath:tempBackup toPath:dest error:error];
- // cleanup - delete the backup to the dest
- if ([fileManager fileExistsAtPath:tempBackup]) {
- [fileManager removeItemAtPath:tempBackup error:error];
- }
- return NO;
- }
-}
-
-- (BOOL)shouldBackup
-{
- for (CDVBackupInfo* info in self.backupInfo) {
- if ([info shouldBackup]) {
- return YES;
- }
- }
-
- return NO;
-}
-
-- (BOOL)shouldRestore
-{
- for (CDVBackupInfo* info in self.backupInfo) {
- if ([info shouldRestore]) {
- return YES;
- }
- }
-
- return NO;
-}
-
-/* copy from webkitDbLocation to persistentDbLocation */
-- (void)backup:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
- NSError* __autoreleasing error = nil;
- CDVPluginResult* result = nil;
- NSString* message = nil;
-
- for (CDVBackupInfo* info in self.backupInfo) {
- if ([info shouldBackup]) {
- [[self class] copyFrom:info.original to:info.backup error:&error];
-
- if (callbackId) {
- if (error == nil) {
- message = [NSString stringWithFormat:@"Backed up: %@", info.label];
- NSLog(@"%@", message);
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) backup: %@", info.label, [error localizedDescription]];
- NSLog(@"%@", message);
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
- }
- }
- }
-}
-
-/* copy from persistentDbLocation to webkitDbLocation */
-- (void)restore:(CDVInvokedUrlCommand*)command
-{
- NSError* __autoreleasing error = nil;
- CDVPluginResult* result = nil;
- NSString* message = nil;
-
- for (CDVBackupInfo* info in self.backupInfo) {
- if ([info shouldRestore]) {
- [[self class] copyFrom:info.backup to:info.original error:&error];
-
- if (error == nil) {
- message = [NSString stringWithFormat:@"Restored: %@", info.label];
- NSLog(@"%@", message);
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- } else {
- message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) restore: %@", info.label, [error localizedDescription]];
- NSLog(@"%@", message);
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }
- }
- }
-}
-
-+ (void)__fixupDatabaseLocationsWithBackupType:(NSString*)backupType
-{
- [self __verifyAndFixDatabaseLocations];
- [self __restoreLegacyDatabaseLocationsWithBackupType:backupType];
-}
-
-+ (void)__verifyAndFixDatabaseLocations
-{
- NSBundle* mainBundle = [NSBundle mainBundle];
- NSString* bundlePath = [[mainBundle bundlePath] stringByDeletingLastPathComponent];
- NSString* bundleIdentifier = [[mainBundle infoDictionary] objectForKey:@"CFBundleIdentifier"];
- NSString* appPlistPath = [bundlePath stringByAppendingPathComponent:[NSString stringWithFormat:@"Library/Preferences/%@.plist", bundleIdentifier]];
-
- NSMutableDictionary* appPlistDict = [NSMutableDictionary dictionaryWithContentsOfFile:appPlistPath];
- BOOL modified = [[self class] __verifyAndFixDatabaseLocationsWithAppPlistDict:appPlistDict
- bundlePath:bundlePath
- fileManager:[NSFileManager defaultManager]];
-
- if (modified) {
- BOOL ok = [appPlistDict writeToFile:appPlistPath atomically:YES];
- [[NSUserDefaults standardUserDefaults] synchronize];
- NSLog(@"Fix applied for database locations?: %@", ok ? @"YES" : @"NO");
- }
-}
-
-+ (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
- bundlePath:(NSString*)bundlePath
- fileManager:(NSFileManager*)fileManager
-{
- NSString* libraryCaches = @"Library/Caches";
- NSString* libraryWebKit = @"Library/WebKit";
-
- NSArray* keysToCheck = [NSArray arrayWithObjects:
- @"WebKitLocalStorageDatabasePathPreferenceKey",
- @"WebDatabaseDirectory",
- nil];
-
- BOOL dirty = NO;
-
- for (NSString* key in keysToCheck) {
- NSString* value = [appPlistDict objectForKey:key];
- // verify key exists, and path is in app bundle, if not - fix
- if ((value != nil) && ![value hasPrefix:bundlePath]) {
- // the pathSuffix to use may be wrong - OTA upgrades from < 5.1 to 5.1 do keep the old path Library/WebKit,
- // while Xcode synced ones do change the storage location to Library/Caches
- NSString* newBundlePath = [bundlePath stringByAppendingPathComponent:libraryCaches];
- if (![fileManager fileExistsAtPath:newBundlePath]) {
- newBundlePath = [bundlePath stringByAppendingPathComponent:libraryWebKit];
- }
- [appPlistDict setValue:newBundlePath forKey:key];
- dirty = YES;
- }
- }
-
- return dirty;
-}
-
-+ (void)__restoreLegacyDatabaseLocationsWithBackupType:(NSString*)backupType
-{
- // on iOS 6, if you toggle between cloud/local backup, you must move database locations. Default upgrade from iOS5.1 to iOS6 is like a toggle from local to cloud.
- if (!IsAtLeastiOSVersion(@"6.0")) {
- return;
- }
-
- NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
- NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
-
- NSMutableArray* backupInfo = [NSMutableArray arrayWithCapacity:0];
-
- if ([backupType isEqualToString:@"cloud"]) {
- // We would like to restore old backups/caches databases to the new destination (nested in lib folder)
- [backupInfo addObjectsFromArray:[self createBackupInfoWithTargetDir:appLibraryFolder backupDir:[appDocumentsFolder stringByAppendingPathComponent:@"Backups"] targetDirNests:YES backupDirNests:NO rename:YES]];
- [backupInfo addObjectsFromArray:[self createBackupInfoWithTargetDir:appLibraryFolder backupDir:[appLibraryFolder stringByAppendingPathComponent:@"Caches"] targetDirNests:YES backupDirNests:NO rename:NO]];
- } else {
- // For ios6 local backups we also want to restore from Backups dir -- but we don't need to do that here, since the plugin will do that itself.
- [backupInfo addObjectsFromArray:[self createBackupInfoWithTargetDir:[appLibraryFolder stringByAppendingPathComponent:@"Caches"] backupDir:appLibraryFolder targetDirNests:NO backupDirNests:YES rename:NO]];
- }
-
- NSFileManager* manager = [NSFileManager defaultManager];
-
- for (CDVBackupInfo* info in backupInfo) {
- if ([manager fileExistsAtPath:info.backup]) {
- if ([info shouldRestore]) {
- NSLog(@"Restoring old webstorage backup. From: '%@' To: '%@'.", info.backup, info.original);
- [self copyFrom:info.backup to:info.original error:nil];
- }
- NSLog(@"Removing old webstorage backup: '%@'.", info.backup);
- [manager removeItemAtPath:info.backup error:nil];
- }
- }
-
- [[NSUserDefaults standardUserDefaults] setBool:[backupType isEqualToString:@"cloud"] forKey:@"WebKitStoreWebDataForBackup"];
-}
-
-#pragma mark -
-#pragma mark Notification handlers
-
-- (void)onResignActive
-{
- UIDevice* device = [UIDevice currentDevice];
- NSNumber* exitsOnSuspend = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIApplicationExitsOnSuspend"];
-
- BOOL isMultitaskingSupported = [device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported];
-
- if (exitsOnSuspend == nil) { // if it's missing, it should be NO (i.e. multi-tasking on by default)
- exitsOnSuspend = [NSNumber numberWithBool:NO];
- }
-
- if (exitsOnSuspend) {
- [self backup:nil];
- } else if (isMultitaskingSupported) {
- __block UIBackgroundTaskIdentifier backgroundTaskID = UIBackgroundTaskInvalid;
-
- backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
- [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
- backgroundTaskID = UIBackgroundTaskInvalid;
- NSLog(@"Background task to backup WebSQL/LocalStorage expired.");
- }];
- CDVLocalStorage __weak* weakSelf = self;
- [self.commandDelegate runInBackground:^{
- [weakSelf backup:nil];
-
- [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
- backgroundTaskID = UIBackgroundTaskInvalid;
- }];
- }
-}
-
-- (void)onAppTerminate
-{
- [self onResignActive];
-}
-
-- (void)onReset
-{
- [self restore:nil];
-}
-
-@end
-
-#pragma mark -
-#pragma mark CDVBackupInfo implementation
-
-@implementation CDVBackupInfo
-
-@synthesize original, backup, label;
-
-- (BOOL)file:(NSString*)aPath isNewerThanFile:(NSString*)bPath
-{
- NSFileManager* fileManager = [NSFileManager defaultManager];
- NSError* __autoreleasing error = nil;
-
- NSDictionary* aPathAttribs = [fileManager attributesOfItemAtPath:aPath error:&error];
- NSDictionary* bPathAttribs = [fileManager attributesOfItemAtPath:bPath error:&error];
-
- NSDate* aPathModDate = [aPathAttribs objectForKey:NSFileModificationDate];
- NSDate* bPathModDate = [bPathAttribs objectForKey:NSFileModificationDate];
-
- if ((nil == aPathModDate) && (nil == bPathModDate)) {
- return NO;
- }
-
- return [aPathModDate compare:bPathModDate] == NSOrderedDescending || bPathModDate == nil;
-}
-
-- (BOOL)item:(NSString*)aPath isNewerThanItem:(NSString*)bPath
-{
- NSFileManager* fileManager = [NSFileManager defaultManager];
-
- BOOL aPathIsDir = NO, bPathIsDir = NO;
- BOOL aPathExists = [fileManager fileExistsAtPath:aPath isDirectory:&aPathIsDir];
-
- [fileManager fileExistsAtPath:bPath isDirectory:&bPathIsDir];
-
- if (!aPathExists) {
- return NO;
- }
-
- if (!(aPathIsDir && bPathIsDir)) { // just a file
- return [self file:aPath isNewerThanFile:bPath];
- }
-
- // essentially we want rsync here, but have to settle for our poor man's implementation
- // we get the files in aPath, and see if it is newer than the file in bPath
- // (it is newer if it doesn't exist in bPath) if we encounter the FIRST file that is newer,
- // we return YES
- NSDirectoryEnumerator* directoryEnumerator = [fileManager enumeratorAtPath:aPath];
- NSString* path;
-
- while ((path = [directoryEnumerator nextObject])) {
- NSString* aPathFile = [aPath stringByAppendingPathComponent:path];
- NSString* bPathFile = [bPath stringByAppendingPathComponent:path];
-
- BOOL isNewer = [self file:aPathFile isNewerThanFile:bPathFile];
- if (isNewer) {
- return YES;
- }
- }
-
- return NO;
-}
-
-- (BOOL)shouldBackup
-{
- return [self item:self.original isNewerThanItem:self.backup];
-}
-
-- (BOOL)shouldRestore
-{
- return [self item:self.backup isNewerThanItem:self.original];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVLocation.h b/iPhone/CordovaLib/Classes/CDVLocation.h
deleted file mode 100755
index caf0798..0000000
--- a/iPhone/CordovaLib/Classes/CDVLocation.h
+++ /dev/null
@@ -1,104 +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 <CoreLocation/CoreLocation.h>
-#import "CDVPlugin.h"
-
-enum CDVHeadingStatus {
- HEADINGSTOPPED = 0,
- HEADINGSTARTING,
- HEADINGRUNNING,
- HEADINGERROR
-};
-typedef NSUInteger CDVHeadingStatus;
-
-enum CDVLocationStatus {
- PERMISSIONDENIED = 1,
- POSITIONUNAVAILABLE,
- TIMEOUT
-};
-typedef NSUInteger CDVLocationStatus;
-
-// simple object to keep track of heading information
-@interface CDVHeadingData : NSObject {}
-
-@property (nonatomic, assign) CDVHeadingStatus headingStatus;
-@property (nonatomic, strong) CLHeading* headingInfo;
-@property (nonatomic, strong) NSMutableArray* headingCallbacks;
-@property (nonatomic, copy) NSString* headingFilter;
-@property (nonatomic, strong) NSDate* headingTimestamp;
-@property (assign) NSInteger timeout;
-
-@end
-
-// simple object to keep track of location information
-@interface CDVLocationData : NSObject {
- CDVLocationStatus locationStatus;
- NSMutableArray* locationCallbacks;
- NSMutableDictionary* watchCallbacks;
- CLLocation* locationInfo;
-}
-
-@property (nonatomic, assign) CDVLocationStatus locationStatus;
-@property (nonatomic, strong) CLLocation* locationInfo;
-@property (nonatomic, strong) NSMutableArray* locationCallbacks;
-@property (nonatomic, strong) NSMutableDictionary* watchCallbacks;
-
-@end
-
-@interface CDVLocation : CDVPlugin <CLLocationManagerDelegate>{
- @private BOOL __locationStarted;
- @private BOOL __highAccuracyEnabled;
- CDVHeadingData* headingData;
- CDVLocationData* locationData;
-}
-
-@property (nonatomic, strong) CLLocationManager* locationManager;
-@property (strong) CDVHeadingData* headingData;
-@property (nonatomic, strong) CDVLocationData* locationData;
-
-- (BOOL)hasHeadingSupport;
-- (void)getLocation:(CDVInvokedUrlCommand*)command;
-- (void)addWatch:(CDVInvokedUrlCommand*)command;
-- (void)clearWatch:(CDVInvokedUrlCommand*)command;
-- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback;
-- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message;
-- (void)startLocation:(BOOL)enableHighAccuracy;
-
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateToLocation:(CLLocation*)newLocation
- fromLocation:(CLLocation*)oldLocation;
-
-- (void)locationManager:(CLLocationManager*)manager
- didFailWithError:(NSError*)error;
-
-- (BOOL)isLocationServicesEnabled;
-
-- (void)getHeading:(CDVInvokedUrlCommand*)command;
-- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain;
-- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command;
-- (void)stopHeading:(CDVInvokedUrlCommand*)command;
-- (void)startHeadingWithFilter:(CLLocationDegrees)filter;
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateHeading:(CLHeading*)heading;
-
-- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVLocation.m b/iPhone/CordovaLib/Classes/CDVLocation.m
deleted file mode 100755
index ed9ec26..0000000
--- a/iPhone/CordovaLib/Classes/CDVLocation.m
+++ /dev/null
@@ -1,623 +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 "CDVLocation.h"
-#import "NSArray+Comparisons.h"
-
-#pragma mark Constants
-
-#define kPGLocationErrorDomain @"kPGLocationErrorDomain"
-#define kPGLocationDesiredAccuracyKey @"desiredAccuracy"
-#define kPGLocationForcePromptKey @"forcePrompt"
-#define kPGLocationDistanceFilterKey @"distanceFilter"
-#define kPGLocationFrequencyKey @"frequency"
-
-#pragma mark -
-#pragma mark Categories
-
-@interface NSError (JSONMethods)
-
-- (NSString*)JSONRepresentation;
-
-@end
-
-@interface CLLocation (JSONMethods)
-
-- (NSString*)JSONRepresentation;
-
-@end
-
-@interface CLHeading (JSONMethods)
-
-- (NSString*)JSONRepresentation;
-
-@end
-
-#pragma mark -
-#pragma mark CDVHeadingData
-
-@implementation CDVHeadingData
-
-@synthesize headingStatus, headingInfo, headingCallbacks, headingFilter, headingTimestamp, timeout;
-- (CDVHeadingData*)init
-{
- self = (CDVHeadingData*)[super init];
- if (self) {
- self.headingStatus = HEADINGSTOPPED;
- self.headingInfo = nil;
- self.headingCallbacks = nil;
- self.headingFilter = nil;
- self.headingTimestamp = nil;
- self.timeout = 10;
- }
- return self;
-}
-
-@end
-
-@implementation CDVLocationData
-
-@synthesize locationStatus, locationInfo, locationCallbacks, watchCallbacks;
-- (CDVLocationData*)init
-{
- self = (CDVLocationData*)[super init];
- if (self) {
- self.locationInfo = nil;
- self.locationCallbacks = nil;
- self.watchCallbacks = nil;
- }
- return self;
-}
-
-@end
-
-#pragma mark -
-#pragma mark CDVLocation
-
-@implementation CDVLocation
-
-@synthesize locationManager, headingData, locationData;
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVLocation*)[super initWithWebView:(UIWebView*)theWebView];
- if (self) {
- self.locationManager = [[CLLocationManager alloc] init];
- self.locationManager.delegate = self; // Tells the location manager to send updates to this object
- __locationStarted = NO;
- __highAccuracyEnabled = NO;
- self.headingData = nil;
- self.locationData = nil;
- }
- return self;
-}
-
-- (BOOL)hasHeadingSupport
-{
- BOOL headingInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(headingAvailable)]; // iOS 3.x
- BOOL headingClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(headingAvailable)]; // iOS 4.x
-
- if (headingInstancePropertyAvailable) { // iOS 3.x
- return [(id)self.locationManager headingAvailable];
- } else if (headingClassPropertyAvailable) { // iOS 4.x
- return [CLLocationManager headingAvailable];
- } else { // iOS 2.x
- return NO;
- }
-}
-
-- (BOOL)isAuthorized
-{
- BOOL authorizationStatusClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
-
- if (authorizationStatusClassPropertyAvailable) {
- NSUInteger authStatus = [CLLocationManager authorizationStatus];
- return (authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusNotDetermined);
- }
-
- // by default, assume YES (for iOS < 4.2)
- return YES;
-}
-
-- (BOOL)isLocationServicesEnabled
-{
- BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x
- BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x
-
- if (locationServicesEnabledClassPropertyAvailable) { // iOS 4.x
- return [CLLocationManager locationServicesEnabled];
- } else if (locationServicesEnabledInstancePropertyAvailable) { // iOS 2.x, iOS 3.x
- return [(id)self.locationManager locationServicesEnabled];
- } else {
- return NO;
- }
-}
-
-- (void)startLocation:(BOOL)enableHighAccuracy
-{
- if (![self isLocationServicesEnabled]) {
- [self returnLocationError:PERMISSIONDENIED withMessage:@"Location services are not enabled."];
- return;
- }
- if (![self isAuthorized]) {
- NSString* message = nil;
- BOOL authStatusAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
- if (authStatusAvailable) {
- NSUInteger code = [CLLocationManager authorizationStatus];
- if (code == kCLAuthorizationStatusNotDetermined) {
- // could return POSITION_UNAVAILABLE but need to coordinate with other platforms
- message = @"User undecided on application's use of location services.";
- } else if (code == kCLAuthorizationStatusRestricted) {
- message = @"Application's use of location services is restricted.";
- }
- }
- // PERMISSIONDENIED is only PositionError that makes sense when authorization denied
- [self returnLocationError:PERMISSIONDENIED withMessage:message];
-
- return;
- }
-
- // Tell the location manager to start notifying us of location updates. We
- // first stop, and then start the updating to ensure we get at least one
- // update, even if our location did not change.
- [self.locationManager stopUpdatingLocation];
- [self.locationManager startUpdatingLocation];
- __locationStarted = YES;
- if (enableHighAccuracy) {
- __highAccuracyEnabled = YES;
- // Set to distance filter to "none" - which should be the minimum for best results.
- self.locationManager.distanceFilter = kCLDistanceFilterNone;
- // Set desired accuracy to Best.
- self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
- } else {
- __highAccuracyEnabled = NO;
- // TODO: Set distance filter to 10 meters? and desired accuracy to nearest ten meters? arbitrary.
- self.locationManager.distanceFilter = 10;
- self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
- }
-}
-
-- (void)_stopLocation
-{
- if (__locationStarted) {
- if (![self isLocationServicesEnabled]) {
- return;
- }
-
- [self.locationManager stopUpdatingLocation];
- __locationStarted = NO;
- __highAccuracyEnabled = NO;
- }
-}
-
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateToLocation:(CLLocation*)newLocation
- fromLocation:(CLLocation*)oldLocation
-{
- CDVLocationData* cData = self.locationData;
-
- cData.locationInfo = newLocation;
- if (self.locationData.locationCallbacks.count > 0) {
- for (NSString* callbackId in self.locationData.locationCallbacks) {
- [self returnLocationInfo:callbackId andKeepCallback:NO];
- }
-
- [self.locationData.locationCallbacks removeAllObjects];
- }
- if (self.locationData.watchCallbacks.count > 0) {
- for (NSString* timerId in self.locationData.watchCallbacks) {
- [self returnLocationInfo:[self.locationData.watchCallbacks objectForKey:timerId] andKeepCallback:YES];
- }
- } else {
- // No callbacks waiting on us anymore, turn off listening.
- [self _stopLocation];
- }
-}
-
-- (void)getLocation:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- BOOL enableHighAccuracy = [[command.arguments objectAtIndex:0] boolValue];
-
- if ([self isLocationServicesEnabled] == NO) {
- NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
- [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
- [posError setObject:@"Location services are disabled." forKey:@"message"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (!self.locationData) {
- self.locationData = [[CDVLocationData alloc] init];
- }
- CDVLocationData* lData = self.locationData;
- if (!lData.locationCallbacks) {
- lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
- }
-
- if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
- // add the callbackId into the array so we can call back when get data
- if (callbackId != nil) {
- [lData.locationCallbacks addObject:callbackId];
- }
- // Tell the location manager to start notifying us of heading updates
- [self startLocation:enableHighAccuracy];
- } else {
- [self returnLocationInfo:callbackId andKeepCallback:NO];
- }
- }
-}
-
-- (void)addWatch:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* timerId = [command.arguments objectAtIndex:0];
- BOOL enableHighAccuracy = [[command.arguments objectAtIndex:1] boolValue];
-
- if (!self.locationData) {
- self.locationData = [[CDVLocationData alloc] init];
- }
- CDVLocationData* lData = self.locationData;
-
- if (!lData.watchCallbacks) {
- lData.watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1];
- }
-
- // add the callbackId into the dictionary so we can call back whenever get data
- [lData.watchCallbacks setObject:callbackId forKey:timerId];
-
- if ([self isLocationServicesEnabled] == NO) {
- NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
- [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
- [posError setObject:@"Location services are disabled." forKey:@"message"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
- // Tell the location manager to start notifying us of location updates
- [self startLocation:enableHighAccuracy];
- }
- }
-}
-
-- (void)clearWatch:(CDVInvokedUrlCommand*)command
-{
- NSString* timerId = [command.arguments objectAtIndex:0];
-
- if (self.locationData && self.locationData.watchCallbacks && [self.locationData.watchCallbacks objectForKey:timerId]) {
- [self.locationData.watchCallbacks removeObjectForKey:timerId];
- }
-}
-
-- (void)stopLocation:(CDVInvokedUrlCommand*)command
-{
- [self _stopLocation];
-}
-
-- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback
-{
- CDVPluginResult* result = nil;
- CDVLocationData* lData = self.locationData;
-
- if (lData && !lData.locationInfo) {
- // return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:POSITIONUNAVAILABLE];
- } else if (lData && lData.locationInfo) {
- CLLocation* lInfo = lData.locationInfo;
- NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:8];
- NSNumber* timestamp = [NSNumber numberWithDouble:([lInfo.timestamp timeIntervalSince1970] * 1000)];
- [returnInfo setObject:timestamp forKey:@"timestamp"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.speed] forKey:@"velocity"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.verticalAccuracy] forKey:@"altitudeAccuracy"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.horizontalAccuracy] forKey:@"accuracy"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.course] forKey:@"heading"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.altitude] forKey:@"altitude"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.latitude] forKey:@"latitude"];
- [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.longitude] forKey:@"longitude"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
- [result setKeepCallbackAsBool:keepCallback];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message
-{
- NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
-
- [posError setObject:[NSNumber numberWithInt:errorCode] forKey:@"code"];
- [posError setObject:message ? message:@"" forKey:@"message"];
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
-
- for (NSString* callbackId in self.locationData.locationCallbacks) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-
- [self.locationData.locationCallbacks removeAllObjects];
-
- for (NSString* callbackId in self.locationData.watchCallbacks) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-// called to get the current heading
-// Will call location manager to startUpdatingHeading if necessary
-
-- (void)getHeading:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
- NSNumber* filter = [options valueForKey:@"filter"];
-
- if (filter) {
- [self watchHeadingFilter:command];
- return;
- }
- if ([self hasHeadingSupport] == NO) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- // heading retrieval does is not affected by disabling locationServices and authorization of app for location services
- if (!self.headingData) {
- self.headingData = [[CDVHeadingData alloc] init];
- }
- CDVHeadingData* hData = self.headingData;
-
- if (!hData.headingCallbacks) {
- hData.headingCallbacks = [NSMutableArray arrayWithCapacity:1];
- }
- // add the callbackId into the array so we can call back when get data
- [hData.headingCallbacks addObject:callbackId];
-
- if ((hData.headingStatus != HEADINGRUNNING) && (hData.headingStatus != HEADINGERROR)) {
- // Tell the location manager to start notifying us of heading updates
- [self startHeadingWithFilter:0.2];
- } else {
- [self returnHeadingInfo:callbackId keepCallback:NO];
- }
- }
-}
-
-// called to request heading updates when heading changes by a certain amount (filter)
-- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
- NSNumber* filter = [options valueForKey:@"filter"];
- CDVHeadingData* hData = self.headingData;
-
- if ([self hasHeadingSupport] == NO) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (!hData) {
- self.headingData = [[CDVHeadingData alloc] init];
- hData = self.headingData;
- }
- if (hData.headingStatus != HEADINGRUNNING) {
- // Tell the location manager to start notifying us of heading updates
- [self startHeadingWithFilter:[filter doubleValue]];
- } else {
- // if already running check to see if due to existing watch filter
- if (hData.headingFilter && ![hData.headingFilter isEqualToString:callbackId]) {
- // new watch filter being specified
- // send heading data one last time to clear old successCallback
- [self returnHeadingInfo:hData.headingFilter keepCallback:NO];
- }
- }
- // save the new filter callback and update the headingFilter setting
- hData.headingFilter = callbackId;
- // check if need to stop and restart in order to change value???
- self.locationManager.headingFilter = [filter doubleValue];
- }
-}
-
-- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain
-{
- CDVPluginResult* result = nil;
- CDVHeadingData* hData = self.headingData;
-
- self.headingData.headingTimestamp = [NSDate date];
-
- if (hData && (hData.headingStatus == HEADINGERROR)) {
- // return error
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
- } else if (hData && (hData.headingStatus == HEADINGRUNNING) && hData.headingInfo) {
- // if there is heading info, return it
- CLHeading* hInfo = hData.headingInfo;
- NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:4];
- NSNumber* timestamp = [NSNumber numberWithDouble:([hInfo.timestamp timeIntervalSince1970] * 1000)];
- [returnInfo setObject:timestamp forKey:@"timestamp"];
- [returnInfo setObject:[NSNumber numberWithDouble:hInfo.magneticHeading] forKey:@"magneticHeading"];
- id trueHeading = __locationStarted ? (id)[NSNumber numberWithDouble : hInfo.trueHeading] : (id)[NSNull null];
- [returnInfo setObject:trueHeading forKey:@"trueHeading"];
- [returnInfo setObject:[NSNumber numberWithDouble:hInfo.headingAccuracy] forKey:@"headingAccuracy"];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
- [result setKeepCallbackAsBool:bRetain];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)stopHeading:(CDVInvokedUrlCommand*)command
-{
- // CDVHeadingData* hData = self.headingData;
- if (self.headingData && (self.headingData.headingStatus != HEADINGSTOPPED)) {
- if (self.headingData.headingFilter) {
- // callback one last time to clear callback
- [self returnHeadingInfo:self.headingData.headingFilter keepCallback:NO];
- self.headingData.headingFilter = nil;
- }
- [self.locationManager stopUpdatingHeading];
- NSLog(@"heading STOPPED");
- self.headingData = nil;
- }
-}
-
-// helper method to check the orientation and start updating headings
-- (void)startHeadingWithFilter:(CLLocationDegrees)filter
-{
- // FYI UIDeviceOrientation and CLDeviceOrientation enums are currently the same
- self.locationManager.headingOrientation = (CLDeviceOrientation)self.viewController.interfaceOrientation;
- self.locationManager.headingFilter = filter;
- [self.locationManager startUpdatingHeading];
- self.headingData.headingStatus = HEADINGSTARTING;
-}
-
-- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager
-{
- return YES;
-}
-
-- (void)locationManager:(CLLocationManager*)manager
- didUpdateHeading:(CLHeading*)heading
-{
- CDVHeadingData* hData = self.headingData;
-
- // normally we would clear the delegate to stop getting these notifications, but
- // we are sharing a CLLocationManager to get location data as well, so we do a nil check here
- // ideally heading and location should use their own CLLocationManager instances
- if (hData == nil) {
- return;
- }
-
- // save the data for next call into getHeadingData
- hData.headingInfo = heading;
- BOOL bTimeout = NO;
- if (!hData.headingFilter && hData.headingTimestamp) {
- bTimeout = fabs([hData.headingTimestamp timeIntervalSinceNow]) > hData.timeout;
- }
-
- if (hData.headingStatus == HEADINGSTARTING) {
- hData.headingStatus = HEADINGRUNNING; // so returnHeading info will work
-
- // this is the first update
- for (NSString* callbackId in hData.headingCallbacks) {
- [self returnHeadingInfo:callbackId keepCallback:NO];
- }
-
- [hData.headingCallbacks removeAllObjects];
- }
- if (hData.headingFilter) {
- [self returnHeadingInfo:hData.headingFilter keepCallback:YES];
- } else if (bTimeout) {
- [self stopHeading:nil];
- }
- hData.headingStatus = HEADINGRUNNING; // to clear any error
-}
-
-- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
-{
- NSLog(@"locationManager::didFailWithError %@", [error localizedFailureReason]);
-
- // Compass Error
- if ([error code] == kCLErrorHeadingFailure) {
- CDVHeadingData* hData = self.headingData;
- if (hData) {
- if (hData.headingStatus == HEADINGSTARTING) {
- // heading error during startup - report error
- for (NSString* callbackId in hData.headingCallbacks) {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-
- [hData.headingCallbacks removeAllObjects];
- } // else for frequency watches next call to getCurrentHeading will report error
- if (hData.headingFilter) {
- CDVPluginResult* resultFilter = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
- [self.commandDelegate sendPluginResult:resultFilter callbackId:hData.headingFilter];
- }
- hData.headingStatus = HEADINGERROR;
- }
- }
- // Location Error
- else {
- CDVLocationData* lData = self.locationData;
- if (lData && __locationStarted) {
- // TODO: probably have to once over the various error codes and return one of:
- // PositionError.PERMISSION_DENIED = 1;
- // PositionError.POSITION_UNAVAILABLE = 2;
- // PositionError.TIMEOUT = 3;
- NSUInteger positionError = POSITIONUNAVAILABLE;
- if (error.code == kCLErrorDenied) {
- positionError = PERMISSIONDENIED;
- }
- [self returnLocationError:positionError withMessage:[error localizedDescription]];
- }
- }
-
- [self.locationManager stopUpdatingLocation];
- __locationStarted = NO;
-}
-
-- (void)dealloc
-{
- self.locationManager.delegate = nil;
-}
-
-- (void)onReset
-{
- [self _stopLocation];
- [self.locationManager stopUpdatingHeading];
- self.headingData = nil;
-}
-
-@end
-
-#pragma mark -
-#pragma mark CLLocation(JSONMethods)
-
-@implementation CLLocation (JSONMethods)
-
-- (NSString*)JSONRepresentation
-{
- return [NSString stringWithFormat:
- @"{ timestamp: %.00f, \
- coords: { latitude: %f, longitude: %f, altitude: %.02f, heading: %.02f, speed: %.02f, accuracy: %.02f, altitudeAccuracy: %.02f } \
- }",
- [self.timestamp timeIntervalSince1970] * 1000.0,
- self.coordinate.latitude,
- self.coordinate.longitude,
- self.altitude,
- self.course,
- self.speed,
- self.horizontalAccuracy,
- self.verticalAccuracy
- ];
-}
-
-@end
-
-#pragma mark NSError(JSONMethods)
-
-@implementation NSError (JSONMethods)
-
-- (NSString*)JSONRepresentation
-{
- return [NSString stringWithFormat:
- @"{ code: %d, message: '%@'}",
- self.code,
- [self localizedDescription]
- ];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVLogger.h b/iPhone/CordovaLib/Classes/CDVLogger.h
deleted file mode 100755
index eeba63c..0000000
--- a/iPhone/CordovaLib/Classes/CDVLogger.h
+++ /dev/null
@@ -1,26 +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 "CDVPlugin.h"
-
-@interface CDVLogger : CDVPlugin
-
-- (void)logLevel:(CDVInvokedUrlCommand*)command;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVLogger.m b/iPhone/CordovaLib/Classes/CDVLogger.m
deleted file mode 100755
index a37cf8a..0000000
--- a/iPhone/CordovaLib/Classes/CDVLogger.m
+++ /dev/null
@@ -1,38 +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 "CDVLogger.h"
-#import "CDV.h"
-
-@implementation CDVLogger
-
-/* log a message */
-- (void)logLevel:(CDVInvokedUrlCommand*)command
-{
- id level = [command.arguments objectAtIndex:0];
- id message = [command.arguments objectAtIndex:1];
-
- if ([level isEqualToString:@"LOG"]) {
- NSLog(@"%@", message);
- } else {
- NSLog(@"%@: %@", level, message);
- }
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVNotification.h b/iPhone/CordovaLib/Classes/CDVNotification.h
deleted file mode 100755
index 5b5b89f..0000000
--- a/iPhone/CordovaLib/Classes/CDVNotification.h
+++ /dev/null
@@ -1,37 +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 <UIKit/UIKit.h>
-#import <AudioToolbox/AudioServices.h>
-#import "CDVPlugin.h"
-
-@interface CDVNotification : CDVPlugin <UIAlertViewDelegate>{}
-
-- (void)alert:(CDVInvokedUrlCommand*)command;
-- (void)confirm:(CDVInvokedUrlCommand*)command;
-- (void)prompt:(CDVInvokedUrlCommand*)command;
-- (void)vibrate:(CDVInvokedUrlCommand*)command;
-
-@end
-
-@interface CDVAlertView : UIAlertView {}
-@property (nonatomic, copy) NSString* callbackId;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVNotification.m b/iPhone/CordovaLib/Classes/CDVNotification.m
deleted file mode 100755
index 464eb1f..0000000
--- a/iPhone/CordovaLib/Classes/CDVNotification.m
+++ /dev/null
@@ -1,130 +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 "CDVNotification.h"
-#import "NSDictionary+Extensions.h"
-
-#define DIALOG_TYPE_ALERT @"alert"
-#define DIALOG_TYPE_PROMPT @"prompt"
-
-@implementation CDVNotification
-
-/*
- * showDialogWithMessage - Common method to instantiate the alert view for alert, confirm, and prompt notifications.
- * Parameters:
- * message The alert view message.
- * title The alert view title.
- * buttons The array of customized strings for the buttons.
- * defaultText The input text for the textbox (if textbox exists).
- * callbackId The commmand callback id.
- * dialogType The type of alert view [alert | prompt].
- */
-- (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType
-{
- CDVAlertView* alertView = [[CDVAlertView alloc]
- initWithTitle:title
- message:message
- delegate:self
- cancelButtonTitle:nil
- otherButtonTitles:nil];
-
- alertView.callbackId = callbackId;
-
- int count = [buttons count];
-
- for (int n = 0; n < count; n++) {
- [alertView addButtonWithTitle:[buttons objectAtIndex:n]];
- }
-
- if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
- alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
- UITextField* textField = [alertView textFieldAtIndex:0];
- textField.text = defaultText;
- }
-
- [alertView show];
-}
-
-- (void)alert:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* message = [command argumentAtIndex:0];
- NSString* title = [command argumentAtIndex:1];
- NSString* buttons = [command argumentAtIndex:2];
-
- [self showDialogWithMessage:message title:title buttons:@[buttons] defaultText:nil callbackId:callbackId dialogType:DIALOG_TYPE_ALERT];
-}
-
-- (void)confirm:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* message = [command argumentAtIndex:0];
- NSString* title = [command argumentAtIndex:1];
- NSArray* buttons = [command argumentAtIndex:2];
-
- [self showDialogWithMessage:message title:title buttons:buttons defaultText:nil callbackId:callbackId dialogType:DIALOG_TYPE_ALERT];
-}
-
-- (void)prompt:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* message = [command argumentAtIndex:0];
- NSString* title = [command argumentAtIndex:1];
- NSArray* buttons = [command argumentAtIndex:2];
- NSString* defaultText = [command argumentAtIndex:3];
-
- [self showDialogWithMessage:message title:title buttons:buttons defaultText:defaultText callbackId:callbackId dialogType:DIALOG_TYPE_PROMPT];
-}
-
-/**
- * Callback invoked when an alert dialog's buttons are clicked.
- */
-- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
-{
- CDVAlertView* cdvAlertView = (CDVAlertView*)alertView;
- CDVPluginResult* result;
-
- // Determine what gets returned to JS based on the alert view type.
- if (alertView.alertViewStyle == UIAlertViewStyleDefault) {
- // For alert and confirm, return button index as int back to JS.
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:buttonIndex + 1];
- } else {
- // For prompt, return button index and input text back to JS.
- NSString* value0 = [[alertView textFieldAtIndex:0] text];
- NSDictionary* info = @{
- @"buttonIndex":@(buttonIndex + 1),
- @"input1":(value0 ? value0 : [NSNull null])
- };
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
- }
- [self.commandDelegate sendPluginResult:result callbackId:cdvAlertView.callbackId];
-}
-
-- (void)vibrate:(CDVInvokedUrlCommand*)command
-{
- AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
-}
-
-@end
-
-@implementation CDVAlertView
-
-@synthesize callbackId;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVPlugin.h b/iPhone/CordovaLib/Classes/CDVPlugin.h
deleted file mode 100755
index 33ba1c4..0000000
--- a/iPhone/CordovaLib/Classes/CDVPlugin.h
+++ /dev/null
@@ -1,64 +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 <UIKit/UIKit.h>
-#import "CDVPluginResult.h"
-#import "NSMutableArray+QueueAdditions.h"
-#import "CDVCommandDelegate.h"
-
-extern NSString* const CDVPageDidLoadNotification;
-extern NSString* const CDVPluginHandleOpenURLNotification;
-extern NSString* const CDVPluginResetNotification;
-extern NSString* const CDVLocalNotification;
-
-@interface CDVPlugin : NSObject {}
-
-@property (nonatomic, weak) UIWebView* webView;
-@property (nonatomic, weak) UIViewController* viewController;
-@property (nonatomic, weak) id <CDVCommandDelegate> commandDelegate;
-
-@property (readonly, assign) BOOL hasPendingOperation;
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView;
-- (void)pluginInitialize;
-
-- (void)handleOpenURL:(NSNotification*)notification;
-- (void)onAppTerminate;
-- (void)onMemoryWarning;
-- (void)onReset;
-- (void)dispose;
-
-/*
- // see initWithWebView implementation
- - (void) onPause {}
- - (void) onResume {}
- - (void) onOrientationWillChange {}
- - (void) onOrientationDidChange {}
- - (void)didReceiveLocalNotification:(NSNotification *)notification;
- */
-
-- (id)appDelegate;
-
-// TODO(agrieve): Deprecate these in favour of using CDVCommandDelegate directly.
-- (NSString*)writeJavascript:(NSString*)javascript;
-- (NSString*)success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId;
-- (NSString*)error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVPlugin.m b/iPhone/CordovaLib/Classes/CDVPlugin.m
deleted file mode 100755
index 8c932a0..0000000
--- a/iPhone/CordovaLib/Classes/CDVPlugin.m
+++ /dev/null
@@ -1,152 +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 "CDVPlugin.h"
-
-NSString* const CDVPageDidLoadNotification = @"CDVPageDidLoadNotification";
-NSString* const CDVPluginHandleOpenURLNotification = @"CDVPluginHandleOpenURLNotification";
-NSString* const CDVPluginResetNotification = @"CDVPluginResetNotification";
-NSString* const CDVLocalNotification = @"CDVLocalNotification";
-
-@interface CDVPlugin ()
-
-@property (readwrite, assign) BOOL hasPendingOperation;
-
-@end
-
-@implementation CDVPlugin
-@synthesize webView, viewController, commandDelegate, hasPendingOperation;
-
-// Do not override these methods. Use pluginInitialize instead.
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings
-{
- return [self initWithWebView:theWebView];
-}
-
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
-{
- self = [super init];
- if (self) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:theWebView];
-
- self.webView = theWebView;
- }
- return self;
-}
-
-- (void)pluginInitialize
-{
- // You can listen to more app notifications, see:
- // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
-
- // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler
-
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
-
- // Added in 2.3.0
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil];
-
- // Added in 2.5.0
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad:) name:CDVPageDidLoadNotification object:self.webView];
-}
-
-- (void)dispose
-{
- viewController = nil;
- commandDelegate = nil;
- webView = nil;
-}
-
-/*
-// NOTE: for onPause and onResume, calls into JavaScript must not call or trigger any blocking UI, like alerts
-- (void) onPause {}
-- (void) onResume {}
-- (void) onOrientationWillChange {}
-- (void) onOrientationDidChange {}
-*/
-
-/* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
-- (void)handleOpenURL:(NSNotification*)notification
-{
- // override to handle urls sent to your app
- // register your url schemes in your App-Info.plist
-
- NSURL* url = [notification object];
-
- if ([url isKindOfClass:[NSURL class]]) {
- /* Do your thing! */
- }
-}
-
-/* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
-- (void)onAppTerminate
-{
- // override this if you need to do any cleanup on app exit
-}
-
-- (void)onMemoryWarning
-{
- // override to remove caches, etc
-}
-
-- (void)onReset
-{
- // Override to cancel any long-running requests when the WebView navigates or refreshes.
-}
-
-- (void)dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver:self]; // this will remove all notification unless added using addObserverForName:object:queue:usingBlock:
-}
-
-- (id)appDelegate
-{
- return [[UIApplication sharedApplication] delegate];
-}
-
-- (NSString*)writeJavascript:(NSString*)javascript
-{
- return [self.webView stringByEvaluatingJavaScriptFromString:javascript];
-}
-
-- (NSString*)success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
-{
- [self.commandDelegate evalJs:[pluginResult toSuccessCallbackString:callbackId]];
- return @"";
-}
-
-- (NSString*)error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
-{
- [self.commandDelegate evalJs:[pluginResult toErrorCallbackString:callbackId]];
- return @"";
-}
-
-// default implementation does nothing, ideally, we are not registered for notification if we aren't going to do anything.
-// - (void)didReceiveLocalNotification:(NSNotification *)notification
-// {
-// // UILocalNotification* localNotification = [notification object]; // get the payload as a LocalNotification
-// }
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVPluginResult.h b/iPhone/CordovaLib/Classes/CDVPluginResult.h
deleted file mode 100755
index 11b5377..0000000
--- a/iPhone/CordovaLib/Classes/CDVPluginResult.h
+++ /dev/null
@@ -1,68 +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>
-
-typedef enum {
- CDVCommandStatus_NO_RESULT = 0,
- CDVCommandStatus_OK,
- CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION,
- CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION,
- CDVCommandStatus_INSTANTIATION_EXCEPTION,
- CDVCommandStatus_MALFORMED_URL_EXCEPTION,
- CDVCommandStatus_IO_EXCEPTION,
- CDVCommandStatus_INVALID_ACTION,
- CDVCommandStatus_JSON_EXCEPTION,
- CDVCommandStatus_ERROR
-} CDVCommandStatus;
-
-@interface CDVPluginResult : NSObject {}
-
-@property (nonatomic, strong, readonly) NSNumber* status;
-@property (nonatomic, strong, readonly) id message;
-@property (nonatomic, strong) NSNumber* keepCallback;
-// This property can be used to scope the lifetime of another object. For example,
-// Use it to store the associated NSData when `message` is created using initWithBytesNoCopy.
-@property (nonatomic, strong) id associatedObject;
-
-- (CDVPluginResult*)init;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages;
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode;
-
-+ (void)setVerbose:(BOOL)verbose;
-+ (BOOL)isVerbose;
-
-- (void)setKeepCallbackAsBool:(BOOL)bKeepCallback;
-
-- (NSString*)argumentsAsJSON;
-
-// These methods are used by the legacy plugin return result method
-- (NSString*)toJSONString;
-- (NSString*)toSuccessCallbackString:(NSString*)callbackId;
-- (NSString*)toErrorCallbackString:(NSString*)callbackId;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVPluginResult.m b/iPhone/CordovaLib/Classes/CDVPluginResult.m
deleted file mode 100755
index af7c528..0000000
--- a/iPhone/CordovaLib/Classes/CDVPluginResult.m
+++ /dev/null
@@ -1,224 +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 "CDVPluginResult.h"
-#import "CDVJSON.h"
-#import "CDVDebug.h"
-#import "NSData+Base64.h"
-
-@interface CDVPluginResult ()
-
-- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage;
-
-@end
-
-@implementation CDVPluginResult
-@synthesize status, message, keepCallback, associatedObject;
-
-static NSArray* org_apache_cordova_CommandStatusMsgs;
-
-id messageFromArrayBuffer(NSData* data)
-{
- return @{
- @"CDVType" : @"ArrayBuffer",
- @"data" :[data base64EncodedString]
- };
-}
-
-id massageMessage(id message)
-{
- if ([message isKindOfClass:[NSData class]]) {
- return messageFromArrayBuffer(message);
- }
- return message;
-}
-
-id messageFromMultipart(NSArray* theMessages)
-{
- NSMutableArray* messages = [NSMutableArray arrayWithArray:theMessages];
-
- for (NSUInteger i = 0; i < messages.count; ++i) {
- [messages replaceObjectAtIndex:i withObject:massageMessage([messages objectAtIndex:i])];
- }
-
- return @{
- @"CDVType" : @"MultiPart",
- @"messages" : messages
- };
-}
-
-+ (void)initialize
-{
- org_apache_cordova_CommandStatusMsgs = [[NSArray alloc] initWithObjects:@"No result",
- @"OK",
- @"Class not found",
- @"Illegal access",
- @"Instantiation error",
- @"Malformed url",
- @"IO error",
- @"Invalid action",
- @"JSON error",
- @"Error",
- nil];
-}
-
-- (CDVPluginResult*)init
-{
- return [self initWithStatus:CDVCommandStatus_NO_RESULT message:nil];
-}
-
-- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage
-{
- self = [super init];
- if (self) {
- status = [NSNumber numberWithInt:statusOrdinal];
- message = theMessage;
- keepCallback = [NSNumber numberWithBool:NO];
- }
- return self;
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal
-{
- return [[self alloc] initWithStatus:statusOrdinal message:[org_apache_cordova_CommandStatusMsgs objectAtIndex:statusOrdinal]];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInt:theMessage]];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithDouble:theMessage]];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsBool:(BOOL)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithBool:theMessage]];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArrayBuffer:(NSData*)theMessage
-{
- return [[self alloc] initWithStatus:statusOrdinal message:messageFromArrayBuffer(theMessage)];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsMultipart:(NSArray*)theMessages
-{
- return [[self alloc] initWithStatus:statusOrdinal message:messageFromMultipart(theMessages)];
-}
-
-+ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode
-{
- NSDictionary* errDict = @{@"code" :[NSNumber numberWithInt:errorCode]};
-
- return [[self alloc] initWithStatus:statusOrdinal message:errDict];
-}
-
-- (void)setKeepCallbackAsBool:(BOOL)bKeepCallback
-{
- [self setKeepCallback:[NSNumber numberWithBool:bKeepCallback]];
-}
-
-- (NSString*)argumentsAsJSON
-{
- id arguments = (self.message == nil ? [NSNull null] : self.message);
- NSArray* argumentsWrappedInArray = [NSArray arrayWithObject:arguments];
-
- NSString* argumentsJSON = [argumentsWrappedInArray JSONString];
-
- argumentsJSON = [argumentsJSON substringWithRange:NSMakeRange(1, [argumentsJSON length] - 2)];
-
- return argumentsJSON;
-}
-
-// These methods are used by the legacy plugin return result method
-- (NSString*)toJSONString
-{
- NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:
- self.status, @"status",
- self.message ? self. message:[NSNull null], @"message",
- self.keepCallback, @"keepCallback",
- nil];
-
- NSError* error = nil;
- NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dict
- options:NSJSONWritingPrettyPrinted
- error:&error];
- NSString* resultString = nil;
-
- if (error != nil) {
- NSLog(@"toJSONString error: %@", [error localizedDescription]);
- } else {
- resultString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- }
-
- if ([[self class] isVerbose]) {
- NSLog(@"PluginResult:toJSONString - %@", resultString);
- }
- return resultString;
-}
-
-- (NSString*)toSuccessCallbackString:(NSString*)callbackId
-{
- NSString* successCB = [NSString stringWithFormat:@"cordova.callbackSuccess('%@',%@);", callbackId, [self toJSONString]];
-
- if ([[self class] isVerbose]) {
- NSLog(@"PluginResult toSuccessCallbackString: %@", successCB);
- }
- return successCB;
-}
-
-- (NSString*)toErrorCallbackString:(NSString*)callbackId
-{
- NSString* errorCB = [NSString stringWithFormat:@"cordova.callbackError('%@',%@);", callbackId, [self toJSONString]];
-
- if ([[self class] isVerbose]) {
- NSLog(@"PluginResult toErrorCallbackString: %@", errorCB);
- }
- return errorCB;
-}
-
-static BOOL gIsVerbose = NO;
-+ (void)setVerbose:(BOOL)verbose
-{
- gIsVerbose = verbose;
-}
-
-+ (BOOL)isVerbose
-{
- return gIsVerbose;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVReachability.h b/iPhone/CordovaLib/Classes/CDVReachability.h
deleted file mode 100755
index 01a95c3..0000000
--- a/iPhone/CordovaLib/Classes/CDVReachability.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-
- File: Reachability.h
- Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs.
- Version: 2.2
-
- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under
- Apple's copyrights in this original Apple software (the "Apple Software"), to
- use, reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions
- of the Apple Software.
- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
- to endorse or promote products derived from the Apple Software without specific
- prior written permission from Apple. Except as expressly stated in this notice,
- no other rights or licenses, express or implied, are granted by Apple herein,
- including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be
- incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <Foundation/Foundation.h>
-#import <SystemConfiguration/SystemConfiguration.h>
-#import <netinet/in.h>
-
-typedef enum {
- NotReachable = 0,
- ReachableViaWWAN, // this value has been swapped with ReachableViaWiFi for Cordova backwards compat. reasons
- ReachableViaWiFi // this value has been swapped with ReachableViaWWAN for Cordova backwards compat. reasons
-} NetworkStatus;
-#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
-
-@interface CDVReachability : NSObject
-{
- BOOL localWiFiRef;
- SCNetworkReachabilityRef reachabilityRef;
-}
-
-// reachabilityWithHostName- Use to check the reachability of a particular host name.
-+ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
-
-// reachabilityWithAddress- Use to check the reachability of a particular IP address.
-+ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
-
-// reachabilityForInternetConnection- checks whether the default route is available.
-// Should be used by applications that do not connect to a particular host
-+ (CDVReachability*)reachabilityForInternetConnection;
-
-// reachabilityForLocalWiFi- checks whether a local wifi connection is available.
-+ (CDVReachability*)reachabilityForLocalWiFi;
-
-// Start listening for reachability notifications on the current run loop
-- (BOOL)startNotifier;
-- (void)stopNotifier;
-
-- (NetworkStatus)currentReachabilityStatus;
-// WWAN may be available, but not active until a connection has been established.
-// WiFi may require a connection for VPN on Demand.
-- (BOOL)connectionRequired;
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVReachability.m b/iPhone/CordovaLib/Classes/CDVReachability.m
deleted file mode 100755
index 89f4ec9..0000000
--- a/iPhone/CordovaLib/Classes/CDVReachability.m
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-
- File: Reachability.m
- Abstract: Basic demonstration of how to use the SystemConfiguration Reachability APIs.
- Version: 2.2
-
- Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
- ("Apple") in consideration of your agreement to the following terms, and your
- use, installation, modification or redistribution of this Apple software
- constitutes acceptance of these terms. If you do not agree with these terms,
- please do not use, install, modify or redistribute this Apple software.
-
- In consideration of your agreement to abide by the following terms, and subject
- to these terms, Apple grants you a personal, non-exclusive license, under
- Apple's copyrights in this original Apple software (the "Apple Software"), to
- use, reproduce, modify and redistribute the Apple Software, with or without
- modifications, in source and/or binary forms; provided that if you redistribute
- the Apple Software in its entirety and without modifications, you must retain
- this notice and the following text and disclaimers in all such redistributions
- of the Apple Software.
- Neither the name, trademarks, service marks or logos of Apple Inc. may be used
- to endorse or promote products derived from the Apple Software without specific
- prior written permission from Apple. Except as expressly stated in this notice,
- no other rights or licenses, express or implied, are granted by Apple herein,
- including but not limited to any patent rights that may be infringed by your
- derivative works or by other works in which the Apple Software may be
- incorporated.
-
- The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
- WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
- COMBINATION WITH YOUR PRODUCTS.
-
- IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR
- DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
- CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
- APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- Copyright (C) 2010 Apple Inc. All Rights Reserved.
-
-*/
-
-#import <sys/socket.h>
-#import <netinet/in.h>
-#import <netinet6/in6.h>
-#import <arpa/inet.h>
-#import <ifaddrs.h>
-#import <netdb.h>
-
-#import <CoreFoundation/CoreFoundation.h>
-
-#import "CDVReachability.h"
-
-#define kShouldPrintReachabilityFlags 0
-
-static void CDVPrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
-{
-#if kShouldPrintReachabilityFlags
- NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
- (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
- (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
-
- (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
- (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
- (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
- (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
- comment
- );
-#endif
-}
-
-@implementation CDVReachability
-
-static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
-{
-#pragma unused (target, flags)
- // NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
- // NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
-
- // Converted the asserts above to conditionals, with safe return from the function
- if (info == NULL) {
- NSLog(@"info was NULL in ReachabilityCallback");
- return;
- }
-
- if (![(__bridge NSObject*)info isKindOfClass :[CDVReachability class]]) {
- NSLog(@"info was wrong class in ReachabilityCallback");
- return;
- }
-
- // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
- // in case someon uses the Reachability object in a different thread.
- @autoreleasepool {
- CDVReachability* noteObject = (__bridge CDVReachability*)info;
- // Post a notification to notify the client that the network reachability changed.
- [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
- }
-}
-
-- (BOOL)startNotifier
-{
- BOOL retVal = NO;
- SCNetworkReachabilityContext context = {0, (__bridge void*)(self), NULL, NULL, NULL};
-
- if (SCNetworkReachabilitySetCallback(reachabilityRef, CDVReachabilityCallback, &context)) {
- if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
- retVal = YES;
- }
- }
- return retVal;
-}
-
-- (void)stopNotifier
-{
- if (reachabilityRef != NULL) {
- SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
- }
-}
-
-- (void)dealloc
-{
- [self stopNotifier];
- if (reachabilityRef != NULL) {
- CFRelease(reachabilityRef);
- }
-}
-
-+ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
-{
- CDVReachability* retVal = NULL;
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
- if (reachability != NULL) {
- retVal = [[self alloc] init];
- if (retVal != NULL) {
- retVal->reachabilityRef = reachability;
- retVal->localWiFiRef = NO;
- }
- }
- return retVal;
-}
-
-+ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
-{
- SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
- CDVReachability* retVal = NULL;
- if (reachability != NULL) {
- retVal = [[self alloc] init];
- if (retVal != NULL) {
- retVal->reachabilityRef = reachability;
- retVal->localWiFiRef = NO;
- }
- }
- return retVal;
-}
-
-+ (CDVReachability*)reachabilityForInternetConnection;
-{
- struct sockaddr_in zeroAddress;
- bzero(&zeroAddress, sizeof(zeroAddress));
- zeroAddress.sin_len = sizeof(zeroAddress);
- zeroAddress.sin_family = AF_INET;
- return [self reachabilityWithAddress:&zeroAddress];
-}
-
-+ (CDVReachability*)reachabilityForLocalWiFi;
-{
- struct sockaddr_in localWifiAddress;
- bzero(&localWifiAddress, sizeof(localWifiAddress));
- localWifiAddress.sin_len = sizeof(localWifiAddress);
- localWifiAddress.sin_family = AF_INET;
- // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
- localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
- CDVReachability* retVal = [self reachabilityWithAddress:&localWifiAddress];
- if (retVal != NULL) {
- retVal->localWiFiRef = YES;
- }
- return retVal;
-}
-
-#pragma mark Network Flag Handling
-
-- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags
-{
- CDVPrintReachabilityFlags(flags, "localWiFiStatusForFlags");
-
- BOOL retVal = NotReachable;
- if ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect)) {
- retVal = ReachableViaWiFi;
- }
- return retVal;
-}
-
-- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
-{
- CDVPrintReachabilityFlags(flags, "networkStatusForFlags");
- if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
- // if target host is not reachable
- return NotReachable;
- }
-
- BOOL retVal = NotReachable;
-
- if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) {
- // if target host is reachable and no connection is required
- // then we'll assume (for now) that your on Wi-Fi
- retVal = ReachableViaWiFi;
- }
-
- if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
- ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))) {
- // ... and the connection is on-demand (or on-traffic) if the
- // calling application is using the CFSocketStream or higher APIs
-
- if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) {
- // ... and no [user] intervention is needed
- retVal = ReachableViaWiFi;
- }
- }
-
- if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
- // ... but WWAN connections are OK if the calling application
- // is using the CFNetwork (CFSocketStream?) APIs.
- retVal = ReachableViaWWAN;
- }
- return retVal;
-}
-
-- (BOOL)connectionRequired;
-{
- NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
- SCNetworkReachabilityFlags flags;
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
- return flags & kSCNetworkReachabilityFlagsConnectionRequired;
- }
- return NO;
-}
-
-- (NetworkStatus)currentReachabilityStatus
-{
- NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
- NetworkStatus retVal = NotReachable;
- SCNetworkReachabilityFlags flags;
- if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
- if (localWiFiRef) {
- retVal = [self localWiFiStatusForFlags:flags];
- } else {
- retVal = [self networkStatusForFlags:flags];
- }
- }
- return retVal;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVScreenOrientationDelegate.h b/iPhone/CordovaLib/Classes/CDVScreenOrientationDelegate.h
deleted file mode 100755
index 7226205..0000000
--- a/iPhone/CordovaLib/Classes/CDVScreenOrientationDelegate.h
+++ /dev/null
@@ -1,28 +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>
-
-@protocol CDVScreenOrientationDelegate <NSObject>
-
-- (NSUInteger)supportedInterfaceOrientations;
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
-- (BOOL)shouldAutorotate;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVSound.h b/iPhone/CordovaLib/Classes/CDVSound.h
deleted file mode 100755
index 8dcf98e..0000000
--- a/iPhone/CordovaLib/Classes/CDVSound.h
+++ /dev/null
@@ -1,116 +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 <AudioToolbox/AudioServices.h>
-#import <AVFoundation/AVFoundation.h>
-
-#import "CDVPlugin.h"
-
-enum CDVMediaError {
- MEDIA_ERR_ABORTED = 1,
- MEDIA_ERR_NETWORK = 2,
- MEDIA_ERR_DECODE = 3,
- MEDIA_ERR_NONE_SUPPORTED = 4
-};
-typedef NSUInteger CDVMediaError;
-
-enum CDVMediaStates {
- MEDIA_NONE = 0,
- MEDIA_STARTING = 1,
- MEDIA_RUNNING = 2,
- MEDIA_PAUSED = 3,
- MEDIA_STOPPED = 4
-};
-typedef NSUInteger CDVMediaStates;
-
-enum CDVMediaMsg {
- MEDIA_STATE = 1,
- MEDIA_DURATION = 2,
- MEDIA_POSITION = 3,
- MEDIA_ERROR = 9
-};
-typedef NSUInteger CDVMediaMsg;
-
-@interface CDVAudioPlayer : AVAudioPlayer
-{
- NSString* mediaId;
-}
-@property (nonatomic, copy) NSString* mediaId;
-@end
-
-@interface CDVAudioRecorder : AVAudioRecorder
-{
- NSString* mediaId;
-}
-@property (nonatomic, copy) NSString* mediaId;
-@end
-
-@interface CDVAudioFile : NSObject
-{
- NSString* resourcePath;
- NSURL* resourceURL;
- CDVAudioPlayer* player;
- CDVAudioRecorder* recorder;
- NSNumber* volume;
-}
-
-@property (nonatomic, strong) NSString* resourcePath;
-@property (nonatomic, strong) NSURL* resourceURL;
-@property (nonatomic, strong) CDVAudioPlayer* player;
-@property (nonatomic, strong) NSNumber* volume;
-
-@property (nonatomic, strong) CDVAudioRecorder* recorder;
-
-@end
-
-@interface CDVSound : CDVPlugin <AVAudioPlayerDelegate, AVAudioRecorderDelegate>
-{
- NSMutableDictionary* soundCache;
- AVAudioSession* avSession;
-}
-@property (nonatomic, strong) NSMutableDictionary* soundCache;
-@property (nonatomic, strong) AVAudioSession* avSession;
-
-- (void)startPlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void)pausePlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void)stopPlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void)seekToAudio:(CDVInvokedUrlCommand*)command;
-- (void)release:(CDVInvokedUrlCommand*)command;
-- (void)getCurrentPositionAudio:(CDVInvokedUrlCommand*)command;
-
-- (BOOL)hasAudioSession;
-
-// helper methods
-- (NSURL*)urlForRecording:(NSString*)resourcePath;
-- (NSURL*)urlForPlaying:(NSString*)resourcePath;
-- (NSURL*)urlForResource:(NSString*)resourcePath CDV_DEPRECATED(2.5, "Use specific api for playing or recording");
-
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId CDV_DEPRECATED(2.5, "Use updated audioFileForResource api");
-
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId doValidation:(BOOL)bValidate forRecording:(BOOL)bRecord;
-- (BOOL)prepareToPlay:(CDVAudioFile*)audioFile withId:(NSString*)mediaId;
-- (NSString*)createMediaErrorWithCode:(CDVMediaError)code message:(NSString*)message;
-
-- (void)startRecordingAudio:(CDVInvokedUrlCommand*)command;
-- (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command;
-
-- (void)setVolume:(CDVInvokedUrlCommand*)command;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVSound.m b/iPhone/CordovaLib/Classes/CDVSound.m
deleted file mode 100755
index 71eab59..0000000
--- a/iPhone/CordovaLib/Classes/CDVSound.m
+++ /dev/null
@@ -1,702 +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 "CDVSound.h"
-#import "NSArray+Comparisons.h"
-#import "CDVJSON.h"
-
-#define DOCUMENTS_SCHEME_PREFIX @"documents://"
-#define HTTP_SCHEME_PREFIX @"http://"
-#define HTTPS_SCHEME_PREFIX @"https://"
-#define RECORDING_WAV @"wav"
-
-@implementation CDVSound
-
-@synthesize soundCache, avSession;
-
-- (NSURL*)urlForResource:(NSString*)resourcePath
-{
- NSURL* resourceURL = nil;
- NSString* filePath = nil;
-
- // first try to find HTTP:// or Documents:// resources
-
- if ([resourcePath hasPrefix:HTTP_SCHEME_PREFIX] || [resourcePath hasPrefix:HTTPS_SCHEME_PREFIX]) {
- // if it is a http url, use it
- NSLog(@"Will use resource '%@' from the Internet.", resourcePath);
- resourceURL = [NSURL URLWithString:resourcePath];
- } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
- NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
- filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]];
- NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
- } else {
- // attempt to find file path in www directory
- filePath = [self.commandDelegate pathForResource:resourcePath];
- if (filePath != nil) {
- NSLog(@"Found resource '%@' in the web folder.", filePath);
- } else {
- filePath = resourcePath;
- NSLog(@"Will attempt to use file resource '%@'", filePath);
- }
- }
- // check that file exists for all but HTTP_SHEME_PREFIX
- if (filePath != nil) {
- // try to access file
- NSFileManager* fMgr = [[NSFileManager alloc] init];
- if (![fMgr fileExistsAtPath:filePath]) {
- resourceURL = nil;
- NSLog(@"Unknown resource '%@'", resourcePath);
- } else {
- // it's a valid file url, use it
- resourceURL = [NSURL fileURLWithPath:filePath];
- }
- }
- return resourceURL;
-}
-
-// Maps a url for a resource path for recording
-- (NSURL*)urlForRecording:(NSString*)resourcePath
-{
- NSURL* resourceURL = nil;
- NSString* filePath = nil;
- NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
-
- // first check for correct extension
- if ([[resourcePath pathExtension] caseInsensitiveCompare:RECORDING_WAV] != NSOrderedSame) {
- resourceURL = nil;
- NSLog(@"Resource for recording must have %@ extension", RECORDING_WAV);
- } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
- // try to find Documents:// resources
- filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]];
- NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
- } else {
- // if resourcePath is not from FileSystem put in tmp dir, else attempt to use provided resource path
- NSString* tmpPath = [NSTemporaryDirectory()stringByStandardizingPath];
- BOOL isTmp = [resourcePath rangeOfString:tmpPath].location != NSNotFound;
- BOOL isDoc = [resourcePath rangeOfString:docsPath].location != NSNotFound;
- if (!isTmp && !isDoc) {
- // put in temp dir
- filePath = [NSString stringWithFormat:@"%@/%@", tmpPath, resourcePath];
- } else {
- filePath = resourcePath;
- }
- }
-
- if (filePath != nil) {
- // create resourceURL
- resourceURL = [NSURL fileURLWithPath:filePath];
- }
- return resourceURL;
-}
-
-// Maps a url for a resource path for playing
-// "Naked" resource paths are assumed to be from the www folder as its base
-- (NSURL*)urlForPlaying:(NSString*)resourcePath
-{
- NSURL* resourceURL = nil;
- NSString* filePath = nil;
-
- // first try to find HTTP:// or Documents:// resources
-
- if ([resourcePath hasPrefix:HTTP_SCHEME_PREFIX] || [resourcePath hasPrefix:HTTPS_SCHEME_PREFIX]) {
- // if it is a http url, use it
- NSLog(@"Will use resource '%@' from the Internet.", resourcePath);
- resourceURL = [NSURL URLWithString:resourcePath];
- } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
- NSString* docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
- filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", docsPath]];
- NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
- } else {
- // attempt to find file path in www directory or LocalFileSystem.TEMPORARY directory
- filePath = [self.commandDelegate pathForResource:resourcePath];
- if (filePath == nil) {
- // see if this exists in the documents/temp directory from a previous recording
- NSString* testPath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory()stringByStandardizingPath], resourcePath];
- if ([[NSFileManager defaultManager] fileExistsAtPath:testPath]) {
- // inefficient as existence will be checked again below but only way to determine if file exists from previous recording
- filePath = testPath;
- NSLog(@"Will attempt to use file resource from LocalFileSystem.TEMPORARY directory");
- } else {
- // attempt to use path provided
- filePath = resourcePath;
- NSLog(@"Will attempt to use file resource '%@'", filePath);
- }
- } else {
- NSLog(@"Found resource '%@' in the web folder.", filePath);
- }
- }
- // check that file exists for all but HTTP_SHEME_PREFIX
- if (filePath != nil) {
- // create resourceURL
- resourceURL = [NSURL fileURLWithPath:filePath];
- // try to access file
- NSFileManager* fMgr = [NSFileManager defaultManager];
- if (![fMgr fileExistsAtPath:filePath]) {
- resourceURL = nil;
- NSLog(@"Unknown resource '%@'", resourcePath);
- }
- }
-
- return resourceURL;
-}
-
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId
-{
- // will maintain backwards compatibility with original implementation
- return [self audioFileForResource:resourcePath withId:mediaId doValidation:YES forRecording:NO];
-}
-
-// Creates or gets the cached audio file resource object
-- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId doValidation:(BOOL)bValidate forRecording:(BOOL)bRecord
-{
- BOOL bError = NO;
- CDVMediaError errcode = MEDIA_ERR_NONE_SUPPORTED;
- NSString* errMsg = @"";
- NSString* jsString = nil;
- CDVAudioFile* audioFile = nil;
- NSURL* resourceURL = nil;
-
- if ([self soundCache] == nil) {
- [self setSoundCache:[NSMutableDictionary dictionaryWithCapacity:1]];
- } else {
- audioFile = [[self soundCache] objectForKey:mediaId];
- }
- if (audioFile == nil) {
- // validate resourcePath and create
- if ((resourcePath == nil) || ![resourcePath isKindOfClass:[NSString class]] || [resourcePath isEqualToString:@""]) {
- bError = YES;
- errcode = MEDIA_ERR_ABORTED;
- errMsg = @"invalid media src argument";
- } else {
- audioFile = [[CDVAudioFile alloc] init];
- audioFile.resourcePath = resourcePath;
- audioFile.resourceURL = nil; // validate resourceURL when actually play or record
- [[self soundCache] setObject:audioFile forKey:mediaId];
- }
- }
- if (bValidate && (audioFile.resourceURL == nil)) {
- if (bRecord) {
- resourceURL = [self urlForRecording:resourcePath];
- } else {
- resourceURL = [self urlForPlaying:resourcePath];
- }
- if (resourceURL == nil) {
- bError = YES;
- errcode = MEDIA_ERR_ABORTED;
- errMsg = [NSString stringWithFormat:@"Cannot use audio file from resource '%@'", resourcePath];
- } else {
- audioFile.resourceURL = resourceURL;
- }
- }
-
- if (bError) {
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:errcode message:errMsg]];
- [self.commandDelegate evalJs:jsString];
- }
-
- return audioFile;
-}
-
-// returns whether or not audioSession is available - creates it if necessary
-- (BOOL)hasAudioSession
-{
- BOOL bSession = YES;
-
- if (!self.avSession) {
- NSError* error = nil;
-
- self.avSession = [AVAudioSession sharedInstance];
- if (error) {
- // is not fatal if can't get AVAudioSession , just log the error
- NSLog(@"error creating audio session: %@", [[error userInfo] description]);
- self.avSession = nil;
- bSession = NO;
- }
- }
- return bSession;
-}
-
-// helper function to create a error object string
-- (NSString*)createMediaErrorWithCode:(CDVMediaError)code message:(NSString*)message
-{
- NSMutableDictionary* errorDict = [NSMutableDictionary dictionaryWithCapacity:2];
-
- [errorDict setObject:[NSNumber numberWithUnsignedInt:code] forKey:@"code"];
- [errorDict setObject:message ? message:@"" forKey:@"message"];
- return [errorDict JSONString];
-}
-
-- (void)create:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSString* resourcePath = [command.arguments objectAtIndex:1];
-
- CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:NO forRecording:NO];
-
- if (audioFile == nil) {
- NSString* errorMessage = [NSString stringWithFormat:@"Failed to initialize Media file with path %@", resourcePath];
- NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMessage]];
- [self.commandDelegate evalJs:jsString];
- } else {
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- }
-}
-
-- (void)setVolume:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
-#pragma unused(callbackId)
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSNumber* volume = [command.arguments objectAtIndex:1 withDefault:[NSNumber numberWithFloat:1.0]];
-
- CDVAudioFile* audioFile;
- if ([self soundCache] == nil) {
- [self setSoundCache:[NSMutableDictionary dictionaryWithCapacity:1]];
- } else {
- audioFile = [[self soundCache] objectForKey:mediaId];
- audioFile.volume = volume;
- if (audioFile.player) {
- audioFile.player.volume = [volume floatValue];
- }
- [[self soundCache] setObject:audioFile forKey:mediaId];
- }
-
- // don't care for any callbacks
-}
-
-- (void)startPlayingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
-#pragma unused(callbackId)
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSString* resourcePath = [command.arguments objectAtIndex:1];
- NSDictionary* options = [command.arguments objectAtIndex:2 withDefault:nil];
-
- BOOL bError = NO;
- NSString* jsString = nil;
-
- CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId doValidation:YES forRecording:NO];
- if ((audioFile != nil) && (audioFile.resourceURL != nil)) {
- if (audioFile.player == nil) {
- bError = [self prepareToPlay:audioFile withId:mediaId];
- }
- if (!bError) {
- // audioFile.player != nil or player was successfully created
- // get the audioSession and set the category to allow Playing when device is locked or ring/silent switch engaged
- if ([self hasAudioSession]) {
- NSError* __autoreleasing err = nil;
- NSNumber* playAudioWhenScreenIsLocked = [options objectForKey:@"playAudioWhenScreenIsLocked"];
- BOOL bPlayAudioWhenScreenIsLocked = YES;
- if (playAudioWhenScreenIsLocked != nil) {
- bPlayAudioWhenScreenIsLocked = [playAudioWhenScreenIsLocked boolValue];
- }
-
- NSString* sessionCategory = bPlayAudioWhenScreenIsLocked ? AVAudioSessionCategoryPlayback : AVAudioSessionCategorySoloAmbient;
- [self.avSession setCategory:sessionCategory error:&err];
- if (![self.avSession setActive:YES error:&err]) {
- // other audio with higher priority that does not allow mixing could cause this to fail
- NSLog(@"Unable to play audio: %@", [err localizedFailureReason]);
- bError = YES;
- }
- }
- if (!bError) {
- NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
- NSNumber* loopOption = [options objectForKey:@"numberOfLoops"];
- NSInteger numberOfLoops = 0;
- if (loopOption != nil) {
- numberOfLoops = [loopOption intValue] - 1;
- }
- audioFile.player.numberOfLoops = numberOfLoops;
- if (audioFile.player.isPlaying) {
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- }
- if (audioFile.volume != nil) {
- audioFile.player.volume = [audioFile.volume floatValue];
- }
-
- [audioFile.player play];
- double position = round(audioFile.player.duration * 1000) / 1000;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
- [self.commandDelegate evalJs:jsString];
- }
- }
- if (bError) {
- /* I don't see a problem playing previously recorded audio so removing this section - BG
- NSError* error;
- // try loading it one more time, in case the file was recorded previously
- audioFile.player = [[ AVAudioPlayer alloc ] initWithContentsOfURL:audioFile.resourceURL error:&error];
- if (error != nil) {
- NSLog(@"Failed to initialize AVAudioPlayer: %@\n", error);
- audioFile.player = nil;
- } else {
- NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
- audioFile.player.numberOfLoops = numberOfLoops;
- [audioFile.player play];
- } */
- // error creating the session or player
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_NONE_SUPPORTED];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_NONE_SUPPORTED message:nil]];
- [self.commandDelegate evalJs:jsString];
- }
- }
- // else audioFile was nil - error already returned from audioFile for resource
- return;
-}
-
-- (BOOL)prepareToPlay:(CDVAudioFile*)audioFile withId:(NSString*)mediaId
-{
- BOOL bError = NO;
- NSError* __autoreleasing playerError = nil;
-
- // create the player
- NSURL* resourceURL = audioFile.resourceURL;
-
- if ([resourceURL isFileURL]) {
- audioFile.player = [[CDVAudioPlayer alloc] initWithContentsOfURL:resourceURL error:&playerError];
- } else {
- NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:resourceURL];
- NSString* userAgent = [self.commandDelegate userAgent];
- if (userAgent) {
- [request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
- }
-
- NSURLResponse* __autoreleasing response = nil;
- NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&playerError];
- if (playerError) {
- NSLog(@"Unable to download audio from: %@", [resourceURL absoluteString]);
- } else {
- // bug in AVAudioPlayer when playing downloaded data in NSData - we have to download the file and play from disk
- CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
- CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
- NSString* filePath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory()stringByStandardizingPath], uuidString];
- CFRelease(uuidString);
- CFRelease(uuidRef);
-
- [data writeToFile:filePath atomically:YES];
- NSURL* fileURL = [NSURL fileURLWithPath:filePath];
- audioFile.player = [[CDVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&playerError];
- }
- }
-
- if (playerError != nil) {
- NSLog(@"Failed to initialize AVAudioPlayer: %@\n", [playerError localizedDescription]);
- audioFile.player = nil;
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- bError = YES;
- } else {
- audioFile.player.mediaId = mediaId;
- audioFile.player.delegate = self;
- bError = ![audioFile.player prepareToPlay];
- }
- return bError;
-}
-
-- (void)stopPlayingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if ((audioFile != nil) && (audioFile.player != nil)) {
- NSLog(@"Stopped playing audio sample '%@'", audioFile.resourcePath);
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- } // ignore if no media playing
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)pausePlayingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
- NSString* jsString = nil;
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
-
- if ((audioFile != nil) && (audioFile.player != nil)) {
- NSLog(@"Paused playing audio sample '%@'", audioFile.resourcePath);
- [audioFile.player pause];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_PAUSED];
- }
- // ignore if no media playing
-
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)seekToAudio:(CDVInvokedUrlCommand*)command
-{
- // args:
- // 0 = Media id
- // 1 = path to resource
- // 2 = seek to location in milliseconds
-
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- double position = [[command.arguments objectAtIndex:1] doubleValue];
-
- if ((audioFile != nil) && (audioFile.player != nil)) {
- NSString* jsString;
- double posInSeconds = position / 1000;
- if (posInSeconds >= audioFile.player.duration) {
- // The seek is past the end of file. Stop media and reset to beginning instead of seeking past the end.
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, 0.0, @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- // NSLog(@"seekToEndJsString=%@",jsString);
- } else {
- audioFile.player.currentTime = posInSeconds;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%f);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, posInSeconds];
- // NSLog(@"seekJsString=%@",jsString);
- }
-
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)release:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
- if (mediaId != nil) {
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- if (audioFile != nil) {
- if (audioFile.player && [audioFile.player isPlaying]) {
- [audioFile.player stop];
- }
- if (audioFile.recorder && [audioFile.recorder isRecording]) {
- [audioFile.recorder stop];
- }
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- self.avSession = nil;
- }
- [[self soundCache] removeObjectForKey:mediaId];
- NSLog(@"Media with id %@ released", mediaId);
- }
- }
-}
-
-- (void)getCurrentPositionAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
-#pragma unused(mediaId)
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- double position = -1;
-
- if ((audioFile != nil) && (audioFile.player != nil) && [audioFile.player isPlaying]) {
- position = round(audioFile.player.currentTime * 1000) / 1000;
- }
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:position];
- NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, position, [result toSuccessCallbackString:callbackId]];
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)startRecordingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
-
-#pragma unused(callbackId)
-
- NSString* mediaId = [command.arguments objectAtIndex:0];
- CDVAudioFile* audioFile = [self audioFileForResource:[command.arguments objectAtIndex:1] withId:mediaId doValidation:YES forRecording:YES];
- NSString* jsString = nil;
- NSString* errorMsg = @"";
-
- if ((audioFile != nil) && (audioFile.resourceURL != nil)) {
- NSError* __autoreleasing error = nil;
-
- if (audioFile.recorder != nil) {
- [audioFile.recorder stop];
- audioFile.recorder = nil;
- }
- // get the audioSession and set the category to allow recording when device is locked or ring/silent switch engaged
- if ([self hasAudioSession]) {
- [self.avSession setCategory:AVAudioSessionCategoryRecord error:nil];
- if (![self.avSession setActive:YES error:&error]) {
- // other audio with higher priority that does not allow mixing could cause this to fail
- errorMsg = [NSString stringWithFormat:@"Unable to record audio: %@", [error localizedFailureReason]];
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
- [self.commandDelegate evalJs:jsString];
- return;
- }
- }
-
- // create a new recorder for each start record
- audioFile.recorder = [[CDVAudioRecorder alloc] initWithURL:audioFile.resourceURL settings:nil error:&error];
-
- bool recordingSuccess = NO;
- if (error == nil) {
- audioFile.recorder.delegate = self;
- audioFile.recorder.mediaId = mediaId;
- recordingSuccess = [audioFile.recorder record];
- if (recordingSuccess) {
- NSLog(@"Started recording audio sample '%@'", audioFile.resourcePath);
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
- }
- }
-
- if ((error != nil) || (recordingSuccess == NO)) {
- if (error != nil) {
- errorMsg = [NSString stringWithFormat:@"Failed to initialize AVAudioRecorder: %@\n", [error localizedFailureReason]];
- } else {
- errorMsg = @"Failed to start recording using AVAudioRecorder";
- }
- audioFile.recorder = nil;
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
- }
- } else {
- // file did not validate
- NSString* errorMsg = [NSString stringWithFormat:@"Could not record audio at '%@'", audioFile.resourcePath];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
- }
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
- return;
-}
-
-- (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* mediaId = [command.arguments objectAtIndex:0];
-
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if ((audioFile != nil) && (audioFile.recorder != nil)) {
- NSLog(@"Stopped recording audio sample '%@'", audioFile.resourcePath);
- [audioFile.recorder stop];
- // no callback - that will happen in audioRecorderDidFinishRecording
- }
- // ignore if no media recording
- if (jsString) {
- [self.commandDelegate evalJs:jsString];
- }
-}
-
-- (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag
-{
- CDVAudioRecorder* aRecorder = (CDVAudioRecorder*)recorder;
- NSString* mediaId = aRecorder.mediaId;
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if (audioFile != nil) {
- NSLog(@"Finished recording audio sample '%@'", audioFile.resourcePath);
- }
- if (flag) {
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- } else {
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
- }
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag
-{
- CDVAudioPlayer* aPlayer = (CDVAudioPlayer*)player;
- NSString* mediaId = aPlayer.mediaId;
- CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
- NSString* jsString = nil;
-
- if (audioFile != nil) {
- NSLog(@"Finished playing audio sample '%@'", audioFile.resourcePath);
- }
- if (flag) {
- audioFile.player.currentTime = 0;
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
- } else {
- // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
- jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
- }
- if (self.avSession) {
- [self.avSession setActive:NO error:nil];
- }
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)onMemoryWarning
-{
- [[self soundCache] removeAllObjects];
- [self setSoundCache:nil];
- [self setAvSession:nil];
-
- [super onMemoryWarning];
-}
-
-- (void)dealloc
-{
- [[self soundCache] removeAllObjects];
-}
-
-- (void)onReset
-{
- for (CDVAudioFile* audioFile in [[self soundCache] allValues]) {
- if (audioFile != nil) {
- if (audioFile.player != nil) {
- [audioFile.player stop];
- audioFile.player.currentTime = 0;
- }
- if (audioFile.recorder != nil) {
- [audioFile.recorder stop];
- }
- }
- }
-
- [[self soundCache] removeAllObjects];
-}
-
-@end
-
-@implementation CDVAudioFile
-
-@synthesize resourcePath;
-@synthesize resourceURL;
-@synthesize player, volume;
-@synthesize recorder;
-
-@end
-@implementation CDVAudioPlayer
-@synthesize mediaId;
-
-@end
-
-@implementation CDVAudioRecorder
-@synthesize mediaId;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVSplashScreen.h b/iPhone/CordovaLib/Classes/CDVSplashScreen.h
deleted file mode 100755
index 704ab43..0000000
--- a/iPhone/CordovaLib/Classes/CDVSplashScreen.h
+++ /dev/null
@@ -1,33 +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"
-
-@interface CDVSplashScreen : CDVPlugin {
- UIActivityIndicatorView* _activityView;
- UIImageView* _imageView;
- NSString* _curImageName;
- BOOL _visible;
-}
-
-- (void)show:(CDVInvokedUrlCommand*)command;
-- (void)hide:(CDVInvokedUrlCommand*)command;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVSplashScreen.m b/iPhone/CordovaLib/Classes/CDVSplashScreen.m
deleted file mode 100755
index 8ce1191..0000000
--- a/iPhone/CordovaLib/Classes/CDVSplashScreen.m
+++ /dev/null
@@ -1,233 +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 "CDVSplashScreen.h"
-
-#define kSplashScreenDurationDefault 0.25f
-
-@implementation CDVSplashScreen
-
-- (void)pluginInitialize
-{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad) name:CDVPageDidLoadNotification object:self.webView];
-
- [self setVisible:YES];
-}
-
-- (void)show:(CDVInvokedUrlCommand*)command
-{
- [self setVisible:YES];
-}
-
-- (void)hide:(CDVInvokedUrlCommand*)command
-{
- [self setVisible:NO];
-}
-
-- (void)pageDidLoad
-{
- id autoHideSplashScreenValue = [self.commandDelegate.settings objectForKey:@"AutoHideSplashScreen"];
-
- // if value is missing, default to yes
- if ((autoHideSplashScreenValue == nil) || [autoHideSplashScreenValue boolValue]) {
- [self setVisible:NO];
- }
-}
-
-- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
-{
- [self updateImage];
-}
-
-- (void)createViews
-{
- /*
- * The Activity View is the top spinning throbber in the status/battery bar. We init it with the default Grey Style.
- *
- * whiteLarge = UIActivityIndicatorViewStyleWhiteLarge
- * white = UIActivityIndicatorViewStyleWhite
- * gray = UIActivityIndicatorViewStyleGray
- *
- */
- NSString* topActivityIndicator = [self.commandDelegate.settings objectForKey:@"TopActivityIndicator"];
- UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray;
-
- if ([topActivityIndicator isEqualToString:@"whiteLarge"]) {
- topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhiteLarge;
- } else if ([topActivityIndicator isEqualToString:@"white"]) {
- topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhite;
- } else if ([topActivityIndicator isEqualToString:@"gray"]) {
- topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray;
- }
-
- UIView* parentView = self.viewController.view;
- parentView.userInteractionEnabled = NO; // disable user interaction while splashscreen is shown
- _activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:topActivityIndicatorStyle];
- _activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2);
- _activityView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin
- | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin;
- [_activityView startAnimating];
-
- // Set the frame & image later.
- _imageView = [[UIImageView alloc] init];
- [parentView addSubview:_imageView];
-
- id showSplashScreenSpinnerValue = [self.commandDelegate.settings objectForKey:@"ShowSplashScreenSpinner"];
- // backwards compatibility - if key is missing, default to true
- if ((showSplashScreenSpinnerValue == nil) || [showSplashScreenSpinnerValue boolValue]) {
- [parentView addSubview:_activityView];
- }
-
- // Frame is required when launching in portrait mode.
- // Bounds for landscape since it captures the rotation.
- [parentView addObserver:self forKeyPath:@"frame" options:0 context:nil];
- [parentView addObserver:self forKeyPath:@"bounds" options:0 context:nil];
-
- [self updateImage];
-}
-
-- (void)destroyViews
-{
- [_imageView removeFromSuperview];
- [_activityView removeFromSuperview];
- _imageView = nil;
- _activityView = nil;
- _curImageName = nil;
-
- self.viewController.view.userInteractionEnabled = YES; // re-enable user interaction upon completion
- [self.viewController.view removeObserver:self forKeyPath:@"frame"];
- [self.viewController.view removeObserver:self forKeyPath:@"bounds"];
-}
-
-// Sets the view's frame and image.
-- (void)updateImage
-{
- UIInterfaceOrientation orientation = self.viewController.interfaceOrientation;
-
- // Use UILaunchImageFile if specified in plist. Otherwise, use Default.
- NSString* imageName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UILaunchImageFile"];
-
- if (imageName) {
- imageName = [imageName stringByDeletingPathExtension];
- } else {
- imageName = @"Default";
- }
-
- if (CDV_IsIPhone5()) {
- imageName = [imageName stringByAppendingString:@"-568h"];
- } else if (CDV_IsIPad()) {
- switch (orientation) {
- case UIInterfaceOrientationLandscapeLeft:
- case UIInterfaceOrientationLandscapeRight:
- imageName = [imageName stringByAppendingString:@"-Landscape"];
- break;
-
- case UIInterfaceOrientationPortrait:
- case UIInterfaceOrientationPortraitUpsideDown:
- default:
- imageName = [imageName stringByAppendingString:@"-Portrait"];
- break;
- }
- }
-
- if (![imageName isEqualToString:_curImageName]) {
- UIImage* img = [UIImage imageNamed:imageName];
- _imageView.image = img;
- _curImageName = imageName;
- }
-
- // Check that splash screen's image exists before updating bounds
- if (_imageView.image) {
- [self updateBounds];
- } else {
- NSLog(@"WARNING: The splashscreen image named %@ was not found", imageName);
- }
-}
-
-- (void)updateBounds
-{
- UIImage* img = _imageView.image;
- CGRect imgBounds = CGRectMake(0, 0, img.size.width, img.size.height);
-
- CGSize screenSize = [self.viewController.view convertRect:[UIScreen mainScreen].bounds fromView:nil].size;
-
- // There's a special case when the image is the size of the screen.
- if (CGSizeEqualToSize(screenSize, imgBounds.size)) {
- CGRect statusFrame = [self.viewController.view convertRect:[UIApplication sharedApplication].statusBarFrame fromView:nil];
- // fix for splash screen bounce from http://stackoverflow.com/questions/18927141/ios7-startup-screen-splash-screen-leave-a-space-on-the-bottom
- if (!(IsAtLeastiOSVersion(@"7.0"))) {
- imgBounds.origin.y -= statusFrame.size.height;
- }
- } else {
- CGRect viewBounds = self.viewController.view.bounds;
- CGFloat imgAspect = imgBounds.size.width / imgBounds.size.height;
- CGFloat viewAspect = viewBounds.size.width / viewBounds.size.height;
- // This matches the behaviour of the native splash screen.
- CGFloat ratio;
- if (viewAspect > imgAspect) {
- ratio = viewBounds.size.width / imgBounds.size.width;
- } else {
- ratio = viewBounds.size.height / imgBounds.size.height;
- }
- imgBounds.size.height *= ratio;
- imgBounds.size.width *= ratio;
- }
-
- _imageView.frame = imgBounds;
-}
-
-- (void)setVisible:(BOOL)visible
-{
- if (visible == _visible) {
- return;
- }
- _visible = visible;
-
- id fadeSplashScreenValue = [self.commandDelegate.settings objectForKey:@"FadeSplashScreen"];
- id fadeSplashScreenDuration = [self.commandDelegate.settings objectForKey:@"FadeSplashScreenDuration"];
-
- float fadeDuration = fadeSplashScreenDuration == nil ? kSplashScreenDurationDefault : [fadeSplashScreenDuration floatValue];
-
- if ((fadeSplashScreenValue == nil) || ![fadeSplashScreenValue boolValue]) {
- fadeDuration = 0;
- }
-
- // Never animate the showing of the splash screen.
- if (visible) {
- if (_imageView == nil) {
- [self createViews];
- }
- } else if (fadeDuration == 0) {
- [self destroyViews];
- } else {
- [UIView transitionWithView:self.viewController.view
- duration:fadeDuration
- options:UIViewAnimationOptionTransitionNone
- animations:^(void) {
- [_imageView setAlpha:0];
- [_activityView setAlpha:0];
- }
-
- completion:^(BOOL finished) {
- [self destroyViews];
- }];
- }
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVTimer.h b/iPhone/CordovaLib/Classes/CDVTimer.h
deleted file mode 100755
index 6d31593..0000000
--- a/iPhone/CordovaLib/Classes/CDVTimer.h
+++ /dev/null
@@ -1,27 +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>
-
-@interface CDVTimer : NSObject
-
-+ (void)start:(NSString*)name;
-+ (void)stop:(NSString*)name;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVTimer.m b/iPhone/CordovaLib/Classes/CDVTimer.m
deleted file mode 100755
index 784e94d..0000000
--- a/iPhone/CordovaLib/Classes/CDVTimer.m
+++ /dev/null
@@ -1,123 +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 "CDVTimer.h"
-
-#pragma mark CDVTimerItem
-
-@interface CDVTimerItem : NSObject
-
-@property (nonatomic, strong) NSString* name;
-@property (nonatomic, strong) NSDate* started;
-@property (nonatomic, strong) NSDate* ended;
-
-- (void)log;
-
-@end
-
-@implementation CDVTimerItem
-
-- (void)log
-{
- NSLog(@"[CDVTimer][%@] %fms", self.name, [self.ended timeIntervalSinceDate:self.started] * 1000.0);
-}
-
-@end
-
-#pragma mark CDVTimer
-
-@interface CDVTimer ()
-
-@property (nonatomic, strong) NSMutableDictionary* items;
-
-@end
-
-@implementation CDVTimer
-
-#pragma mark object methods
-
-- (id)init
-{
- if (self = [super init]) {
- self.items = [NSMutableDictionary dictionaryWithCapacity:6];
- }
-
- return self;
-}
-
-- (void)add:(NSString*)name
-{
- if ([self.items objectForKey:[name lowercaseString]] == nil) {
- CDVTimerItem* item = [CDVTimerItem new];
- item.name = name;
- item.started = [NSDate new];
- [self.items setObject:item forKey:[name lowercaseString]];
- } else {
- NSLog(@"Timer called '%@' already exists.", name);
- }
-}
-
-- (void)remove:(NSString*)name
-{
- CDVTimerItem* item = [self.items objectForKey:[name lowercaseString]];
-
- if (item != nil) {
- item.ended = [NSDate new];
- [item log];
- [self.items removeObjectForKey:[name lowercaseString]];
- } else {
- NSLog(@"Timer called '%@' does not exist.", name);
- }
-}
-
-- (void)removeAll
-{
- [self.items removeAllObjects];
-}
-
-#pragma mark class methods
-
-+ (void)start:(NSString*)name
-{
- [[CDVTimer sharedInstance] add:name];
-}
-
-+ (void)stop:(NSString*)name
-{
- [[CDVTimer sharedInstance] remove:name];
-}
-
-+ (void)clearAll
-{
- [[CDVTimer sharedInstance] removeAll];
-}
-
-+ (CDVTimer*)sharedInstance
-{
- static dispatch_once_t pred = 0;
- __strong static CDVTimer* _sharedObject = nil;
-
- dispatch_once(&pred, ^{
- _sharedObject = [[self alloc] init];
- });
-
- return _sharedObject;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVURLProtocol.h b/iPhone/CordovaLib/Classes/CDVURLProtocol.h
deleted file mode 100755
index 5444f6d..0000000
--- a/iPhone/CordovaLib/Classes/CDVURLProtocol.h
+++ /dev/null
@@ -1,29 +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 "CDVAvailability.h"
-
-@class CDVViewController;
-
-@interface CDVURLProtocol : NSURLProtocol {}
-
-+ (void)registerViewController:(CDVViewController*)viewController;
-+ (void)unregisterViewController:(CDVViewController*)viewController;
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVURLProtocol.m b/iPhone/CordovaLib/Classes/CDVURLProtocol.m
deleted file mode 100755
index afc10de..0000000
--- a/iPhone/CordovaLib/Classes/CDVURLProtocol.m
+++ /dev/null
@@ -1,230 +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 <AssetsLibrary/ALAsset.h>
-#import <AssetsLibrary/ALAssetRepresentation.h>
-#import <AssetsLibrary/ALAssetsLibrary.h>
-#import <MobileCoreServices/MobileCoreServices.h>
-#import "CDVURLProtocol.h"
-#import "CDVCommandQueue.h"
-#import "CDVWhitelist.h"
-#import "CDVViewController.h"
-#import "CDVFile.h"
-
-@interface CDVHTTPURLResponse : NSHTTPURLResponse
-@property (nonatomic) NSInteger statusCode;
-@end
-
-static CDVWhitelist* gWhitelist = nil;
-// Contains a set of NSNumbers of addresses of controllers. It doesn't store
-// the actual pointer to avoid retaining.
-static NSMutableSet* gRegisteredControllers = nil;
-
-// Returns the registered view controller that sent the given request.
-// If the user-agent is not from a UIWebView, or if it's from an unregistered one,
-// then nil is returned.
-static CDVViewController *viewControllerForRequest(NSURLRequest* request)
-{
- // The exec bridge explicitly sets the VC address in a header.
- // This works around the User-Agent not being set for file: URLs.
- NSString* addrString = [request valueForHTTPHeaderField:@"vc"];
-
- if (addrString == nil) {
- NSString* userAgent = [request valueForHTTPHeaderField:@"User-Agent"];
- if (userAgent == nil) {
- return nil;
- }
- NSUInteger bracketLocation = [userAgent rangeOfString:@"(" options:NSBackwardsSearch].location;
- if (bracketLocation == NSNotFound) {
- return nil;
- }
- addrString = [userAgent substringFromIndex:bracketLocation + 1];
- }
-
- long long viewControllerAddress = [addrString longLongValue];
- @synchronized(gRegisteredControllers) {
- if (![gRegisteredControllers containsObject:[NSNumber numberWithLongLong:viewControllerAddress]]) {
- return nil;
- }
- }
-
- return (__bridge CDVViewController*)(void*)viewControllerAddress;
-}
-
-@implementation CDVURLProtocol
-
-+ (void)registerPGHttpURLProtocol {}
-
-+ (void)registerURLProtocol {}
-
-// Called to register the URLProtocol, and to make it away of an instance of
-// a ViewController.
-+ (void)registerViewController:(CDVViewController*)viewController
-{
- if (gRegisteredControllers == nil) {
- [NSURLProtocol registerClass:[CDVURLProtocol class]];
- gRegisteredControllers = [[NSMutableSet alloc] initWithCapacity:8];
- // The whitelist doesn't change, so grab the first one and store it.
- gWhitelist = viewController.whitelist;
-
- // Note that we grab the whitelist from the first viewcontroller for now - but this will change
- // when we allow a registered viewcontroller to have its own whitelist (e.g InAppBrowser)
- // Differentiating the requests will be through the 'vc' http header below as used for the js->objc bridge.
- // The 'vc' value is generated by casting the viewcontroller object to a (long long) value (see CDVViewController::webViewDidFinishLoad)
- if (gWhitelist == nil) {
- NSLog(@"WARNING: NO whitelist has been set in CDVURLProtocol.");
- }
- }
-
- @synchronized(gRegisteredControllers) {
- [gRegisteredControllers addObject:[NSNumber numberWithLongLong:(long long)viewController]];
- }
-}
-
-+ (void)unregisterViewController:(CDVViewController*)viewController
-{
- @synchronized(gRegisteredControllers) {
- [gRegisteredControllers removeObject:[NSNumber numberWithLongLong:(long long)viewController]];
- }
-}
-
-+ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest
-{
- NSURL* theUrl = [theRequest URL];
- CDVViewController* viewController = viewControllerForRequest(theRequest);
-
- if ([[theUrl absoluteString] hasPrefix:kCDVAssetsLibraryPrefix]) {
- return YES;
- } else if (viewController != nil) {
- if ([[theUrl path] isEqualToString:@"/!gap_exec"]) {
- NSString* queuedCommandsJSON = [theRequest valueForHTTPHeaderField:@"cmds"];
- NSString* requestId = [theRequest valueForHTTPHeaderField:@"rc"];
- if (requestId == nil) {
- NSLog(@"!cordova request missing rc header");
- return NO;
- }
- BOOL hasCmds = [queuedCommandsJSON length] > 0;
- if (hasCmds) {
- SEL sel = @selector(enqueCommandBatch:);
- [viewController.commandQueue performSelectorOnMainThread:sel withObject:queuedCommandsJSON waitUntilDone:NO];
- } else {
- SEL sel = @selector(maybeFetchCommandsFromJs:);
- [viewController.commandQueue performSelectorOnMainThread:sel withObject:[NSNumber numberWithInteger:[requestId integerValue]] waitUntilDone:NO];
- }
- // Returning NO here would be 20% faster, but it spams WebInspector's console with failure messages.
- // If JS->Native bridge speed is really important for an app, they should use the iframe bridge.
- // Returning YES here causes the request to come through canInitWithRequest two more times.
- // For this reason, we return NO when cmds exist.
- return !hasCmds;
- }
- // we only care about http and https connections.
- // CORS takes care of http: trying to access file: URLs.
- if ([gWhitelist schemeIsAllowed:[theUrl scheme]]) {
- // if it FAILS the whitelist, we return TRUE, so we can fail the connection later
- return ![gWhitelist URLIsAllowed:theUrl];
- }
- }
-
- return NO;
-}
-
-+ (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)request
-{
- // NSLog(@"%@ received %@", self, NSStringFromSelector(_cmd));
- return request;
-}
-
-- (void)startLoading
-{
- // NSLog(@"%@ received %@ - start", self, NSStringFromSelector(_cmd));
- NSURL* url = [[self request] URL];
-
- if ([[url path] isEqualToString:@"/!gap_exec"]) {
- [self sendResponseWithResponseCode:200 data:nil mimeType:nil];
- return;
- } else if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefix]) {
- ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
- if (asset) {
- // We have the asset! Get the data and send it along.
- ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
- NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
- 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];
- [self sendResponseWithResponseCode:200 data:data mimeType:MIMEType];
- } else {
- // Retrieving the asset failed for some reason. Send an error.
- [self sendResponseWithResponseCode:404 data:nil mimeType:nil];
- }
- };
- ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
- // Retrieving the asset failed for some reason. Send an error.
- [self sendResponseWithResponseCode:401 data:nil mimeType:nil];
- };
-
- ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
- [assetsLibrary assetForURL:url resultBlock:resultBlock failureBlock:failureBlock];
- return;
- }
-
- NSString* body = [gWhitelist errorStringForURL:url];
- [self sendResponseWithResponseCode:401 data:[body dataUsingEncoding:NSASCIIStringEncoding] mimeType:nil];
-}
-
-- (void)stopLoading
-{
- // do any cleanup here
-}
-
-+ (BOOL)requestIsCacheEquivalent:(NSURLRequest*)requestA toRequest:(NSURLRequest*)requestB
-{
- return NO;
-}
-
-- (void)sendResponseWithResponseCode:(NSInteger)statusCode data:(NSData*)data mimeType:(NSString*)mimeType
-{
- if (mimeType == nil) {
- mimeType = @"text/plain";
- }
- NSString* encodingName = [@"text/plain" isEqualToString : mimeType] ? @"UTF-8" : nil;
- CDVHTTPURLResponse* response =
- [[CDVHTTPURLResponse alloc] initWithURL:[[self request] URL]
- MIMEType:mimeType
- expectedContentLength:[data length]
- textEncodingName:encodingName];
- response.statusCode = statusCode;
-
- [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
- if (data != nil) {
- [[self client] URLProtocol:self didLoadData:data];
- }
- [[self client] URLProtocolDidFinishLoading:self];
-}
-
-@end
-
-@implementation CDVHTTPURLResponse
-@synthesize statusCode;
-
-- (NSDictionary*)allHeaderFields
-{
- return nil;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVUserAgentUtil.h b/iPhone/CordovaLib/Classes/CDVUserAgentUtil.h
deleted file mode 100755
index 4de382f..0000000
--- a/iPhone/CordovaLib/Classes/CDVUserAgentUtil.h
+++ /dev/null
@@ -1,27 +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>
-
-@interface CDVUserAgentUtil : NSObject
-+ (NSString*)originalUserAgent;
-+ (void)acquireLock:(void (^)(NSInteger lockToken))block;
-+ (void)releaseLock:(NSInteger*)lockToken;
-+ (void)setUserAgent:(NSString*)value lockToken:(NSInteger)lockToken;
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVUserAgentUtil.m b/iPhone/CordovaLib/Classes/CDVUserAgentUtil.m
deleted file mode 100755
index 9923d47..0000000
--- a/iPhone/CordovaLib/Classes/CDVUserAgentUtil.m
+++ /dev/null
@@ -1,120 +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 "CDVUserAgentUtil.h"
-
-#import <UIKit/UIKit.h>
-
-// #define VerboseLog NSLog
-#define VerboseLog(...) do {} while (0)
-
-static NSString* const kCdvUserAgentKey = @"Cordova-User-Agent";
-static NSString* const kCdvUserAgentVersionKey = @"Cordova-User-Agent-Version";
-
-static NSString* gOriginalUserAgent = nil;
-static NSInteger gNextLockToken = 0;
-static NSInteger gCurrentLockToken = 0;
-static NSMutableArray* gPendingSetUserAgentBlocks = nil;
-
-@implementation CDVUserAgentUtil
-
-+ (NSString*)originalUserAgent
-{
- if (gOriginalUserAgent == nil) {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppLocaleDidChange:)
- name:NSCurrentLocaleDidChangeNotification object:nil];
-
- NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
- NSString* localeStr = [[NSLocale currentLocale] localeIdentifier];
- NSString* systemAndLocale = [NSString stringWithFormat:@"%@ %@", systemVersion, localeStr];
-
- NSString* cordovaUserAgentVersion = [userDefaults stringForKey:kCdvUserAgentVersionKey];
- gOriginalUserAgent = [userDefaults stringForKey:kCdvUserAgentKey];
- BOOL cachedValueIsOld = ![systemAndLocale isEqualToString:cordovaUserAgentVersion];
-
- if ((gOriginalUserAgent == nil) || cachedValueIsOld) {
- UIWebView* sampleWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
- gOriginalUserAgent = [sampleWebView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
-
- [userDefaults setObject:gOriginalUserAgent forKey:kCdvUserAgentKey];
- [userDefaults setObject:systemAndLocale forKey:kCdvUserAgentVersionKey];
-
- [userDefaults synchronize];
- }
- }
- return gOriginalUserAgent;
-}
-
-+ (void)onAppLocaleDidChange:(NSNotification*)notification
-{
- // TODO: We should figure out how to update the user-agent of existing UIWebViews when this happens.
- // Maybe use the PDF bug (noted in setUserAgent:).
- gOriginalUserAgent = nil;
-}
-
-+ (void)acquireLock:(void (^)(NSInteger lockToken))block
-{
- if (gCurrentLockToken == 0) {
- gCurrentLockToken = ++gNextLockToken;
- VerboseLog(@"Gave lock %d", gCurrentLockToken);
- block(gCurrentLockToken);
- } else {
- if (gPendingSetUserAgentBlocks == nil) {
- gPendingSetUserAgentBlocks = [[NSMutableArray alloc] initWithCapacity:4];
- }
- VerboseLog(@"Waiting for lock");
- [gPendingSetUserAgentBlocks addObject:block];
- }
-}
-
-+ (void)releaseLock:(NSInteger*)lockToken
-{
- if (*lockToken == 0) {
- return;
- }
- NSAssert(gCurrentLockToken == *lockToken, @"Got token %d, expected %d", *lockToken, gCurrentLockToken);
-
- VerboseLog(@"Released lock %d", *lockToken);
- if ([gPendingSetUserAgentBlocks count] > 0) {
- void (^block)() = [gPendingSetUserAgentBlocks objectAtIndex:0];
- [gPendingSetUserAgentBlocks removeObjectAtIndex:0];
- gCurrentLockToken = ++gNextLockToken;
- NSLog(@"Gave lock %d", gCurrentLockToken);
- block(gCurrentLockToken);
- } else {
- gCurrentLockToken = 0;
- }
- *lockToken = 0;
-}
-
-+ (void)setUserAgent:(NSString*)value lockToken:(NSInteger)lockToken
-{
- NSAssert(gCurrentLockToken == lockToken, @"Got token %d, expected %d", lockToken, gCurrentLockToken);
- VerboseLog(@"User-Agent set to: %@", value);
-
- // Setting the UserAgent must occur before a UIWebView is instantiated.
- // It is read per instantiation, so it does not affect previously created views.
- // Except! When a PDF is loaded, all currently active UIWebViews reload their
- // User-Agent from the NSUserDefaults some time after the DidFinishLoad of the PDF bah!
- NSDictionary* dict = [[NSDictionary alloc] initWithObjectsAndKeys:value, @"UserAgent", nil];
- [[NSUserDefaults standardUserDefaults] registerDefaults:dict];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVViewController.h b/iPhone/CordovaLib/Classes/CDVViewController.h
deleted file mode 100755
index 2338baf..0000000
--- a/iPhone/CordovaLib/Classes/CDVViewController.h
+++ /dev/null
@@ -1,73 +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 <Foundation/NSJSONSerialization.h>
-#import "CDVAvailability.h"
-#import "CDVInvokedUrlCommand.h"
-#import "CDVCommandDelegate.h"
-#import "CDVCommandQueue.h"
-#import "CDVWhitelist.h"
-#import "CDVScreenOrientationDelegate.h"
-#import "CDVPlugin.h"
-
-@interface CDVViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
- @protected
- id <CDVCommandDelegate> _commandDelegate;
- @protected
- CDVCommandQueue* _commandQueue;
- NSString* _userAgent;
-}
-
-@property (nonatomic, strong) IBOutlet UIWebView* webView;
-
-@property (nonatomic, readonly, strong) NSMutableDictionary* pluginObjects;
-@property (nonatomic, readonly, strong) NSDictionary* pluginsMap;
-@property (nonatomic, readonly, strong) NSMutableDictionary* settings;
-@property (nonatomic, readonly, strong) NSXMLParser* configParser;
-@property (nonatomic, readonly, strong) CDVWhitelist* whitelist; // readonly for public
-@property (nonatomic, readonly, assign) BOOL loadFromString;
-@property (nonatomic, readwrite, assign) BOOL useSplashScreen CDV_DEPRECATED(2.5, "Add/Remove the SplashScreen plugin instead of setting this property.");
-
-@property (nonatomic, readwrite, copy) NSString* wwwFolderName;
-@property (nonatomic, readwrite, copy) NSString* startPage;
-@property (nonatomic, readonly, strong) CDVCommandQueue* commandQueue;
-@property (nonatomic, readonly, strong) id <CDVCommandDelegate> commandDelegate;
-@property (nonatomic, readonly) NSString* userAgent;
-
-+ (NSDictionary*)getBundlePlist:(NSString*)plistName;
-+ (NSString*)applicationDocumentsDirectory;
-
-- (void)printMultitaskingInfo;
-- (void)createGapView;
-- (UIWebView*)newCordovaViewWithFrame:(CGRect)bounds;
-
-- (void)javascriptAlert:(NSString*)text;
-- (NSString*)appURLScheme;
-
-- (NSArray*)parseInterfaceOrientations:(NSArray*)orientations;
-- (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation;
-
-- (id)getCommandInstance:(NSString*)pluginName;
-- (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className;
-- (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
-
-- (BOOL)URLisAllowed:(NSURL*)url;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVViewController.m b/iPhone/CordovaLib/Classes/CDVViewController.m
deleted file mode 100755
index 94f4552..0000000
--- a/iPhone/CordovaLib/Classes/CDVViewController.m
+++ /dev/null
@@ -1,933 +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 <objc/message.h>
-#import "CDV.h"
-#import "CDVCommandDelegateImpl.h"
-#import "CDVConfigParser.h"
-#import "CDVUserAgentUtil.h"
-#import "CDVWebViewDelegate.h"
-
-#define degreesToRadian(x) (M_PI * (x) / 180.0)
-
-@interface CDVViewController () {
- NSInteger _userAgentLockToken;
- CDVWebViewDelegate* _webViewDelegate;
-}
-
-@property (nonatomic, readwrite, strong) NSXMLParser* configParser;
-@property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
-@property (nonatomic, readwrite, strong) CDVWhitelist* whitelist;
-@property (nonatomic, readwrite, strong) NSMutableDictionary* pluginObjects;
-@property (nonatomic, readwrite, strong) NSArray* startupPluginNames;
-@property (nonatomic, readwrite, strong) NSDictionary* pluginsMap;
-@property (nonatomic, readwrite, strong) NSArray* supportedOrientations;
-@property (nonatomic, readwrite, assign) BOOL loadFromString;
-
-@property (readwrite, assign) BOOL initialized;
-
-@property (atomic, strong) NSURL* openURL;
-
-@end
-
-@implementation CDVViewController
-
-@synthesize webView, supportedOrientations;
-@synthesize pluginObjects, pluginsMap, whitelist, startupPluginNames;
-@synthesize configParser, settings, loadFromString;
-@synthesize useSplashScreen;
-@synthesize wwwFolderName, startPage, initialized, openURL;
-@synthesize commandDelegate = _commandDelegate;
-@synthesize commandQueue = _commandQueue;
-
-- (void)__init
-{
- if ((self != nil) && !self.initialized) {
- _commandQueue = [[CDVCommandQueue alloc] initWithViewController:self];
- _commandDelegate = [[CDVCommandDelegateImpl alloc] initWithViewController:self];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillTerminate:)
- name:UIApplicationWillTerminateNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:)
- name:UIApplicationWillResignActiveNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:)
- name:UIApplicationDidBecomeActiveNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillEnterForeground:)
- name:UIApplicationWillEnterForegroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:)
- name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
-
- // read from UISupportedInterfaceOrientations (or UISupportedInterfaceOrientations~iPad, if its iPad) from -Info.plist
- self.supportedOrientations = [self parseInterfaceOrientations:
- [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"]];
-
- [self printMultitaskingInfo];
- [self printDeprecationNotice];
- self.initialized = YES;
-
- // load config.xml settings
- [self loadSettings];
- useSplashScreen = YES;
- }
-}
-
-- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
-{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- [self __init];
- return self;
-}
-
-- (id)init
-{
- self = [super init];
- [self __init];
- return self;
-}
-
-- (void)viewWillAppear:(BOOL)animated
-{
- [super viewWillAppear:animated];
-
- NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
- [nc addObserver:self
- selector:@selector(keyboardWillShowOrHide:)
- name:UIKeyboardWillShowNotification
- object:nil];
- [nc addObserver:self
- selector:@selector(keyboardWillShowOrHide:)
- name:UIKeyboardWillHideNotification
- object:nil];
-}
-
-- (void)viewWillDisappear:(BOOL)animated
-{
- [super viewWillDisappear:animated];
-
- NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
- [nc removeObserver:self name:UIKeyboardWillShowNotification object:nil];
- [nc removeObserver:self name:UIKeyboardWillHideNotification object:nil];
-}
-
-- (void)keyboardWillShowOrHide:(NSNotification*)notif
-{
- if (![@"true" isEqualToString : self.settings[@"KeyboardShrinksView"]]) {
- return;
- }
- BOOL showEvent = [notif.name isEqualToString:UIKeyboardWillShowNotification];
-
- CGRect keyboardFrame = [notif.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
- keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];
-
- CGRect newFrame = self.view.bounds;
- if (showEvent) {
- newFrame.size.height -= keyboardFrame.size.height;
- }
- self.webView.frame = newFrame;
- self.webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0, -keyboardFrame.size.height, 0);
-}
-
-- (void)printDeprecationNotice
-{
- if (!IsAtLeastiOSVersion(@"5.0")) {
- NSLog(@"CRITICAL: For Cordova 2.0, you will need to upgrade to at least iOS 5.0 or greater. Your current version of iOS is %@.",
- [[UIDevice currentDevice] systemVersion]
- );
- }
-}
-
-- (void)printMultitaskingInfo
-{
- UIDevice* device = [UIDevice currentDevice];
- BOOL backgroundSupported = NO;
-
- if ([device respondsToSelector:@selector(isMultitaskingSupported)]) {
- backgroundSupported = device.multitaskingSupported;
- }
-
- NSNumber* exitsOnSuspend = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIApplicationExitsOnSuspend"];
- if (exitsOnSuspend == nil) { // if it's missing, it should be NO (i.e. multi-tasking on by default)
- exitsOnSuspend = [NSNumber numberWithBool:NO];
- }
-
- NSLog(@"Multi-tasking -> Device: %@, App: %@", (backgroundSupported ? @"YES" : @"NO"), (![exitsOnSuspend intValue]) ? @"YES" : @"NO");
-}
-
-- (BOOL)URLisAllowed:(NSURL*)url
-{
- if (self.whitelist == nil) {
- return YES;
- }
-
- return [self.whitelist URLIsAllowed:url];
-}
-
-- (void)loadSettings
-{
- CDVConfigParser* delegate = [[CDVConfigParser alloc] init];
-
- // read from config.xml in the app bundle
- NSString* path = [[NSBundle mainBundle] pathForResource:@"config" ofType:@"xml"];
-
- if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
- NSAssert(NO, @"ERROR: config.xml does not exist. Please run cordova-ios/bin/cordova_plist_to_config_xml path/to/project.");
- return;
- }
-
- NSURL* url = [NSURL fileURLWithPath:path];
-
- configParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
- if (configParser == nil) {
- NSLog(@"Failed to initialize XML parser.");
- return;
- }
- [configParser setDelegate:((id < NSXMLParserDelegate >)delegate)];
- [configParser parse];
-
- // Get the plugin dictionary, whitelist and settings from the delegate.
- self.pluginsMap = delegate.pluginsDict;
- self.startupPluginNames = delegate.startupPluginNames;
- self.whitelist = [[CDVWhitelist alloc] initWithArray:delegate.whitelistHosts];
- self.settings = delegate.settings;
-
- // And the start folder/page.
- self.wwwFolderName = @"www";
- self.startPage = delegate.startPage;
- if (self.startPage == nil) {
- self.startPage = @"index.html";
- }
-
- // Initialize the plugin objects dict.
- self.pluginObjects = [[NSMutableDictionary alloc] initWithCapacity:20];
-}
-
-// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-- (void)viewDidLoad
-{
- [super viewDidLoad];
-
- NSURL* appURL = nil;
- NSString* loadErr = nil;
-
- if ([self.startPage rangeOfString:@"://"].location != NSNotFound) {
- appURL = [NSURL URLWithString:self.startPage];
- } else if ([self.wwwFolderName rangeOfString:@"://"].location != NSNotFound) {
- appURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.wwwFolderName, self.startPage]];
- } else {
- NSString* startFilePath = [self.commandDelegate pathForResource:self.startPage];
- if (startFilePath == nil) {
- loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", self.wwwFolderName, self.startPage];
- NSLog(@"%@", loadErr);
- self.loadFromString = YES;
- appURL = nil;
- } else {
- appURL = [NSURL fileURLWithPath:startFilePath];
- }
- }
-
- // // Fix the iOS 5.1 SECURITY_ERR bug (CB-347), this must be before the webView is instantiated ////
-
- NSString* backupWebStorageType = @"cloud"; // default value
-
- id backupWebStorage = self.settings[@"BackupWebStorage"];
- if ([backupWebStorage isKindOfClass:[NSString class]]) {
- backupWebStorageType = backupWebStorage;
- }
- self.settings[@"BackupWebStorage"] = backupWebStorageType;
-
- if (IsAtLeastiOSVersion(@"5.1")) {
- [CDVLocalStorage __fixupDatabaseLocationsWithBackupType:backupWebStorageType];
- }
-
- // // Instantiate the WebView ///////////////
-
- [self createGapView];
-
- // /////////////////
-
- NSNumber* enableLocation = [self.settings objectForKey:@"EnableLocation"];
- NSString* enableViewportScale = [self.settings objectForKey:@"EnableViewportScale"];
- NSNumber* allowInlineMediaPlayback = [self.settings objectForKey:@"AllowInlineMediaPlayback"];
- BOOL mediaPlaybackRequiresUserAction = YES; // default value
- if ([self.settings objectForKey:@"MediaPlaybackRequiresUserAction"]) {
- mediaPlaybackRequiresUserAction = [(NSNumber*)[settings objectForKey:@"MediaPlaybackRequiresUserAction"] boolValue];
- }
- BOOL hideKeyboardFormAccessoryBar = NO; // default value
- if ([self.settings objectForKey:@"HideKeyboardFormAccessoryBar"]) {
- hideKeyboardFormAccessoryBar = [(NSNumber*)[settings objectForKey:@"HideKeyboardFormAccessoryBar"] boolValue];
- }
-
- self.webView.scalesPageToFit = [enableViewportScale boolValue];
-
- /*
- * Fire up the GPS Service right away as it takes a moment for data to come back.
- */
-
- if ([enableLocation boolValue]) {
- NSLog(@"Deprecated: The 'EnableLocation' boolean property is deprecated in 2.5.0, and will be removed in 3.0.0. Use the 'onload' boolean attribute (of the CDVLocation plugin.");
- [[self.commandDelegate getCommandInstance:@"Geolocation"] getLocation:[CDVInvokedUrlCommand new]];
- }
-
- if (hideKeyboardFormAccessoryBar) {
- __weak CDVViewController* weakSelf = self;
- [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillShowNotification
- object:nil
- queue:[NSOperationQueue mainQueue]
- usingBlock:^(NSNotification* notification) {
- // we can't hide it here because the accessory bar hasn't been created yet, so we delay on the queue
- [weakSelf performSelector:@selector(hideKeyboardFormAccessoryBar) withObject:nil afterDelay:0];
- }];
- }
-
- /*
- * Fire up CDVLocalStorage to work-around WebKit storage limitations: on all iOS 5.1+ versions for local-only backups, but only needed on iOS 5.1 for cloud backup.
- */
- if (IsAtLeastiOSVersion(@"5.1") && (([backupWebStorageType isEqualToString:@"local"]) ||
- ([backupWebStorageType isEqualToString:@"cloud"] && !IsAtLeastiOSVersion(@"6.0")))) {
- [self registerPlugin:[[CDVLocalStorage alloc] initWithWebView:self.webView] withClassName:NSStringFromClass([CDVLocalStorage class])];
- }
-
- /*
- * This is for iOS 4.x, where you can allow inline <video> and <audio>, and also autoplay them
- */
- if ([allowInlineMediaPlayback boolValue] && [self.webView respondsToSelector:@selector(allowsInlineMediaPlayback)]) {
- self.webView.allowsInlineMediaPlayback = YES;
- }
- if ((mediaPlaybackRequiresUserAction == NO) && [self.webView respondsToSelector:@selector(mediaPlaybackRequiresUserAction)]) {
- self.webView.mediaPlaybackRequiresUserAction = NO;
- }
-
- // By default, overscroll bouncing is allowed.
- // UIWebViewBounce has been renamed to DisallowOverscroll, but both are checked.
- BOOL bounceAllowed = YES;
- NSNumber* disallowOverscroll = [self.settings objectForKey:@"DisallowOverscroll"];
- if (disallowOverscroll == nil) {
- NSNumber* bouncePreference = [self.settings objectForKey:@"UIWebViewBounce"];
- bounceAllowed = (bouncePreference == nil || [bouncePreference boolValue]);
- } else {
- bounceAllowed = ![disallowOverscroll boolValue];
- }
-
- // prevent webView from bouncing
- // based on the DisallowOverscroll/UIWebViewBounce key in config.xml
- if (!bounceAllowed) {
- if ([self.webView respondsToSelector:@selector(scrollView)]) {
- ((UIScrollView*)[self.webView scrollView]).bounces = NO;
- } else {
- for (id subview in self.webView.subviews) {
- if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
- ((UIScrollView*)subview).bounces = NO;
- }
- }
- }
- }
-
- /*
- * iOS 6.0 UIWebView properties
- */
- if (IsAtLeastiOSVersion(@"6.0")) {
- BOOL keyboardDisplayRequiresUserAction = YES; // KeyboardDisplayRequiresUserAction - defaults to YES
- if ([self.settings objectForKey:@"KeyboardDisplayRequiresUserAction"] != nil) {
- if ([self.settings objectForKey:@"KeyboardDisplayRequiresUserAction"]) {
- keyboardDisplayRequiresUserAction = [(NSNumber*)[self.settings objectForKey:@"KeyboardDisplayRequiresUserAction"] boolValue];
- }
- }
-
- // property check for compiling under iOS < 6
- if ([self.webView respondsToSelector:@selector(setKeyboardDisplayRequiresUserAction:)]) {
- [self.webView setValue:[NSNumber numberWithBool:keyboardDisplayRequiresUserAction] forKey:@"keyboardDisplayRequiresUserAction"];
- }
-
- BOOL suppressesIncrementalRendering = NO; // SuppressesIncrementalRendering - defaults to NO
- if ([self.settings objectForKey:@"SuppressesIncrementalRendering"] != nil) {
- if ([self.settings objectForKey:@"SuppressesIncrementalRendering"]) {
- suppressesIncrementalRendering = [(NSNumber*)[self.settings objectForKey:@"SuppressesIncrementalRendering"] boolValue];
- }
- }
-
- // property check for compiling under iOS < 6
- if ([self.webView respondsToSelector:@selector(setSuppressesIncrementalRendering:)]) {
- [self.webView setValue:[NSNumber numberWithBool:suppressesIncrementalRendering] forKey:@"suppressesIncrementalRendering"];
- }
- }
-
- if ([self.startupPluginNames count] > 0) {
- [CDVTimer start:@"TotalPluginStartup"];
-
- for (NSString* pluginName in self.startupPluginNames) {
- [CDVTimer start:pluginName];
- [self getCommandInstance:pluginName];
- [CDVTimer stop:pluginName];
- }
-
- [CDVTimer stop:@"TotalPluginStartup"];
- }
-
- // TODO: Remove this explicit instantiation once we move to cordova-CLI.
- if (useSplashScreen) {
- [self getCommandInstance:@"splashscreen"];
- }
-
- // /////////////////
- [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
- _userAgentLockToken = lockToken;
- [CDVUserAgentUtil setUserAgent:self.userAgent lockToken:lockToken];
- if (!loadErr) {
- NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
- [self.webView loadRequest:appReq];
- } else {
- NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>", loadErr];
- [self.webView loadHTMLString:html baseURL:nil];
- }
- }];
-}
-
-- (void)hideKeyboardFormAccessoryBar
-{
- NSArray* windows = [[UIApplication sharedApplication] windows];
-
- for (UIWindow* window in windows) {
- for (UIView* view in window.subviews) {
- if ([[view description] hasPrefix:@"<UIPeripheralHostView"]) {
- for (UIView* peripheralView in view.subviews) {
- // hides the accessory bar
- if ([[peripheralView description] hasPrefix:@"<UIWebFormAccessory"]) {
- // remove the extra scroll space for the form accessory bar
- CGRect newFrame = self.webView.scrollView.frame;
- newFrame.size.height += peripheralView.frame.size.height;
- self.webView.scrollView.frame = newFrame;
-
- // remove the form accessory bar
- [peripheralView removeFromSuperview];
- }
- // hides the thin grey line used to adorn the bar (iOS 6)
- if ([[peripheralView description] hasPrefix:@"<UIImageView"]) {
- [[peripheralView layer] setOpacity:0.0];
- }
- }
- }
- }
- }
-}
-
-- (NSArray*)parseInterfaceOrientations:(NSArray*)orientations
-{
- NSMutableArray* result = [[NSMutableArray alloc] init];
-
- if (orientations != nil) {
- NSEnumerator* enumerator = [orientations objectEnumerator];
- NSString* orientationString;
-
- while (orientationString = [enumerator nextObject]) {
- if ([orientationString isEqualToString:@"UIInterfaceOrientationPortrait"]) {
- [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
- } else if ([orientationString isEqualToString:@"UIInterfaceOrientationPortraitUpsideDown"]) {
- [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]];
- } else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeLeft"]) {
- [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];
- } else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeRight"]) {
- [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];
- }
- }
- }
-
- // default
- if ([result count] == 0) {
- [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
- }
-
- return result;
-}
-
-- (NSInteger)mapIosOrientationToJsOrientation:(UIInterfaceOrientation)orientation
-{
- switch (orientation) {
- case UIInterfaceOrientationPortraitUpsideDown:
- return 180;
-
- case UIInterfaceOrientationLandscapeLeft:
- return -90;
-
- case UIInterfaceOrientationLandscapeRight:
- return 90;
-
- case UIInterfaceOrientationPortrait:
- return 0;
-
- default:
- return 0;
- }
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- // First, ask the webview via JS if it supports the new orientation
- NSString* jsCall = [NSString stringWithFormat:
- @"window.shouldRotateToOrientation && window.shouldRotateToOrientation(%d);"
- , [self mapIosOrientationToJsOrientation:interfaceOrientation]];
- NSString* res = [webView stringByEvaluatingJavaScriptFromString:jsCall];
-
- if ([res length] > 0) {
- return [res boolValue];
- }
-
- // if js did not handle the new orientation (no return value), use values from the plist (via supportedOrientations)
- return [self supportsOrientation:interfaceOrientation];
-}
-
-- (BOOL)shouldAutorotate
-{
- return YES;
-}
-
-- (NSUInteger)supportedInterfaceOrientations
-{
- NSUInteger ret = 0;
-
- if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait]) {
- ret = ret | (1 << UIInterfaceOrientationPortrait);
- }
- if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown]) {
- ret = ret | (1 << UIInterfaceOrientationPortraitUpsideDown);
- }
- if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight]) {
- ret = ret | (1 << UIInterfaceOrientationLandscapeRight);
- }
- if ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft]) {
- ret = ret | (1 << UIInterfaceOrientationLandscapeLeft);
- }
-
- return ret;
-}
-
-- (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation
-{
- return [self.supportedOrientations containsObject:[NSNumber numberWithInt:orientation]];
-}
-
-- (UIWebView*)newCordovaViewWithFrame:(CGRect)bounds
-{
- return [[UIWebView alloc] initWithFrame:bounds];
-}
-
-- (NSString*)userAgent
-{
- if (_userAgent == nil) {
- NSString* originalUserAgent = [CDVUserAgentUtil originalUserAgent];
- // Use our address as a unique number to append to the User-Agent.
- _userAgent = [NSString stringWithFormat:@"%@ (%lld)", originalUserAgent, (long long)self];
- }
- return _userAgent;
-}
-
-- (void)createGapView
-{
- CGRect webViewBounds = self.view.bounds;
-
- webViewBounds.origin = self.view.bounds.origin;
-
- if (!self.webView) {
- self.webView = [self newCordovaViewWithFrame:webViewBounds];
- self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
-
- [self.view addSubview:self.webView];
- [self.view sendSubviewToBack:self.webView];
-
- _webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
- self.webView.delegate = _webViewDelegate;
-
- // register this viewcontroller with the NSURLProtocol, only after the User-Agent is set
- [CDVURLProtocol registerViewController:self];
- }
-}
-
-- (void)didReceiveMemoryWarning
-{
- // iterate through all the plugin objects, and call hasPendingOperation
- // if at least one has a pending operation, we don't call [super didReceiveMemoryWarning]
-
- NSEnumerator* enumerator = [self.pluginObjects objectEnumerator];
- CDVPlugin* plugin;
-
- BOOL doPurge = YES;
-
- while ((plugin = [enumerator nextObject])) {
- if (plugin.hasPendingOperation) {
- NSLog(@"Plugin '%@' has a pending operation, memory purge is delayed for didReceiveMemoryWarning.", NSStringFromClass([plugin class]));
- doPurge = NO;
- }
- }
-
- if (doPurge) {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
- }
-
- // Release any cached data, images, etc. that aren't in use.
-}
-
-- (void)viewDidUnload
-{
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
-
- self.webView.delegate = nil;
- self.webView = nil;
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
-}
-
-#pragma mark UIWebViewDelegate
-
-/**
- When web application loads Add stuff to the DOM, mainly the user-defined settings from the Settings.plist file, and
- the device's data such as device ID, platform version, etc.
- */
-- (void)webViewDidStartLoad:(UIWebView*)theWebView
-{
- NSLog(@"Resetting plugins due to page load.");
- [_commandQueue resetRequestId];
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginResetNotification object:self.webView]];
-}
-
-/**
- Called when the webview finishes loading. This stops the activity view.
- */
-- (void)webViewDidFinishLoad:(UIWebView*)theWebView
-{
- NSLog(@"Finished load of: %@", theWebView.request.URL);
- // It's safe to release the lock even if this is just a sub-frame that's finished loading.
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
-
- /*
- * Hide the Top Activity THROBBER in the Battery Bar
- */
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
-
- [self processOpenUrl];
-
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:self.webView]];
-}
-
-- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
-{
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
-
- NSLog(@"Failed to load webpage with error: %@", [error localizedDescription]);
-}
-
-- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- NSURL* url = [request URL];
-
- /*
- * Execute any commands queued with cordova.exec() on the JS side.
- * The part of the URL after gap:// is irrelevant.
- */
- if ([[url scheme] isEqualToString:@"gap"]) {
- [_commandQueue fetchCommandsFromJs];
- return NO;
- }
-
- /*
- * If a URL is being loaded that's a file/http/https URL, just load it internally
- */
- else if ([url isFileURL]) {
- return YES;
- }
-
- /*
- * If we loaded the HTML from a string, we let the app handle it
- */
- else if (self.loadFromString == YES) {
- self.loadFromString = NO;
- return YES;
- }
-
- /*
- * all tel: scheme urls we let the UIWebview handle it using the default behavior
- */
- else if ([[url scheme] isEqualToString:@"tel"]) {
- return YES;
- }
-
- /*
- * all about: scheme urls are not handled
- */
- else if ([[url scheme] isEqualToString:@"about"]) {
- return NO;
- }
-
- /*
- * all data: scheme urls are handled
- */
- else if ([[url scheme] isEqualToString:@"data"]) {
- return YES;
- }
-
- /*
- * Handle all other types of urls (tel:, sms:), and requests to load a url in the main webview.
- */
- else {
- if ([self.whitelist schemeIsAllowed:[url scheme]]) {
- return [self.whitelist URLIsAllowed:url];
- } else {
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- [[UIApplication sharedApplication] openURL:url];
- } else { // handle any custom schemes to plugins
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
- }
- }
-
- return NO;
- }
-
- return YES;
-}
-
-#pragma mark GapHelpers
-
-- (void)javascriptAlert:(NSString*)text
-{
- NSString* jsString = [NSString stringWithFormat:@"alert('%@');", text];
-
- [self.commandDelegate evalJs:jsString];
-}
-
-+ (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 (isLessThaniOS4) {
- if (CDV_IsIPad()) {
- return [NSString stringWithFormat:@"%@~ipad.png", resource];
- } else {
- return [NSString stringWithFormat:@"%@.png", resource];
- }
- }
-
- return resource;
-}
-
-+ (NSString*)applicationDocumentsDirectory
-{
- NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString* basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
-
- return basePath;
-}
-
-#pragma mark CordovaCommands
-
-- (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
-{
- if ([plugin respondsToSelector:@selector(setViewController:)]) {
- [plugin setViewController:self];
- }
-
- if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
- [plugin setCommandDelegate:_commandDelegate];
- }
-
- [self.pluginObjects setObject:plugin forKey:className];
- [plugin pluginInitialize];
-}
-
-- (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName
-{
- if ([plugin respondsToSelector:@selector(setViewController:)]) {
- [plugin setViewController:self];
- }
-
- if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
- [plugin setCommandDelegate:_commandDelegate];
- }
-
- NSString* className = NSStringFromClass([plugin class]);
- [self.pluginObjects setObject:plugin forKey:className];
- [self.pluginsMap setValue:className forKey:[pluginName lowercaseString]];
- [plugin pluginInitialize];
-}
-
-/**
- Returns an instance of a CordovaCommand object, based on its name. If one exists already, it is returned.
- */
-- (id)getCommandInstance:(NSString*)pluginName
-{
- // first, we try to find the pluginName in the pluginsMap
- // (acts as a whitelist as well) if it does not exist, we return nil
- // NOTE: plugin names are matched as lowercase to avoid problems - however, a
- // possible issue is there can be duplicates possible if you had:
- // "org.apache.cordova.Foo" and "org.apache.cordova.foo" - only the lower-cased entry will match
- NSString* className = [self.pluginsMap objectForKey:[pluginName lowercaseString]];
-
- if (className == nil) {
- return nil;
- }
-
- id obj = [self.pluginObjects objectForKey:className];
- if (!obj) {
- obj = [[NSClassFromString(className)alloc] initWithWebView:webView];
-
- if (obj != nil) {
- [self registerPlugin:obj withClassName:className];
- } else {
- NSLog(@"CDVPlugin class %@ (pluginName: %@) does not exist.", className, pluginName);
- }
- }
- return obj;
-}
-
-#pragma mark -
-
-- (NSString*)appURLScheme
-{
- NSString* URLScheme = nil;
-
- NSArray* URLTypes = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleURLTypes"];
-
- if (URLTypes != nil) {
- NSDictionary* dict = [URLTypes objectAtIndex:0];
- if (dict != nil) {
- NSArray* URLSchemes = [dict objectForKey:@"CFBundleURLSchemes"];
- if (URLSchemes != nil) {
- URLScheme = [URLSchemes objectAtIndex:0];
- }
- }
- }
-
- return URLScheme;
-}
-
-/**
- Returns the contents of the named plist bundle, loaded as a dictionary object
- */
-+ (NSDictionary*)getBundlePlist:(NSString*)plistName
-{
- NSString* errorDesc = nil;
- NSPropertyListFormat format;
- NSString* plistPath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
- NSData* plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
- NSDictionary* temp = (NSDictionary*)[NSPropertyListSerialization
- propertyListFromData:plistXML
- mutabilityOption:NSPropertyListMutableContainersAndLeaves
- format:&format errorDescription:&errorDesc];
-
- return temp;
-}
-
-#pragma mark -
-#pragma mark UIApplicationDelegate impl
-
-/*
- This method lets your application know that it is about to be terminated and purged from memory entirely
- */
-- (void)onAppWillTerminate:(NSNotification*)notification
-{
- // empty the tmp directory
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSError* __autoreleasing err = nil;
-
- // clear contents of NSTemporaryDirectory
- NSString* tempDirectoryPath = NSTemporaryDirectory();
- NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
- NSString* fileName = nil;
- BOOL result;
-
- while ((fileName = [directoryEnumerator nextObject])) {
- NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
- result = [fileMgr removeItemAtPath:filePath error:&err];
- if (!result && err) {
- NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
- }
- }
-}
-
-/*
- This method is called to let your application know that it is about to move from the active to inactive state.
- You should use this method to pause ongoing tasks, disable timer, ...
- */
-- (void)onAppWillResignActive:(NSNotification*)notification
-{
- // NSLog(@"%@",@"applicationWillResignActive");
- [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');" scheduledOnRunLoop:NO];
-}
-
-/*
- In iOS 4.0 and later, this method is called as part of the transition from the background to the inactive state.
- You can use this method to undo many of the changes you made to your application upon entering the background.
- invariably followed by applicationDidBecomeActive
- */
-- (void)onAppWillEnterForeground:(NSNotification*)notification
-{
- // NSLog(@"%@",@"applicationWillEnterForeground");
- [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resume');"];
-}
-
-// This method is called to let your application know that it moved from the inactive to active state.
-- (void)onAppDidBecomeActive:(NSNotification*)notification
-{
- // NSLog(@"%@",@"applicationDidBecomeActive");
- [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('active');"];
-}
-
-/*
- In iOS 4.0 and later, this method is called instead of the applicationWillTerminate: method
- when the user quits an application that supports background execution.
- */
-- (void)onAppDidEnterBackground:(NSNotification*)notification
-{
- // NSLog(@"%@",@"applicationDidEnterBackground");
- [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('pause', null, true);" scheduledOnRunLoop:NO];
-}
-
-// ///////////////////////
-
-- (void)handleOpenURL:(NSNotification*)notification
-{
- self.openURL = notification.object;
-}
-
-- (void)processOpenUrl
-{
- if (self.openURL) {
- // calls into javascript global function 'handleOpenURL'
- NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", [self.openURL description]];
- [self.webView stringByEvaluatingJavaScriptFromString:jsString];
- self.openURL = nil;
- }
-}
-
-// ///////////////////////
-
-- (void)dealloc
-{
- [CDVURLProtocol unregisterViewController:self];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-
- self.webView.delegate = nil;
- self.webView = nil;
- [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
- [_commandQueue dispose];
- [[self.pluginObjects allValues] makeObjectsPerformSelector:@selector(dispose)];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVWebViewDelegate.h b/iPhone/CordovaLib/Classes/CDVWebViewDelegate.h
deleted file mode 100755
index dd71807..0000000
--- a/iPhone/CordovaLib/Classes/CDVWebViewDelegate.h
+++ /dev/null
@@ -1,39 +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>
-
-/**
- * Distinguishes top-level navigations from sub-frame navigations.
- * shouldStartLoadWithRequest is called for every request, but didStartLoad
- * and didFinishLoad is called only for top-level navigations.
- * Relevant bug: CB-2389
- */
-@interface CDVWebViewDelegate : NSObject <UIWebViewDelegate>{
- __weak NSObject <UIWebViewDelegate>* _delegate;
- NSInteger _loadCount;
- NSInteger _state;
- NSInteger _curLoadToken;
- NSInteger _loadStartPollCount;
-}
-
-- (id)initWithDelegate:(NSObject <UIWebViewDelegate>*)delegate;
-- (BOOL)request:(NSURLRequest*)newRequest isFragmentIdentifierToRequest:(NSURLRequest*)originalRequest;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVWebViewDelegate.m b/iPhone/CordovaLib/Classes/CDVWebViewDelegate.m
deleted file mode 100755
index 7254c2e..0000000
--- a/iPhone/CordovaLib/Classes/CDVWebViewDelegate.m
+++ /dev/null
@@ -1,380 +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.
- */
-
-//
-// Testing shows:
-//
-// In all cases, webView.request.URL is the previous page's URL (or empty) during the didStartLoad callback.
-// When loading a page with a redirect:
-// 1. shouldStartLoading (requestURL is target page)
-// 2. didStartLoading
-// 3. shouldStartLoading (requestURL is redirect target)
-// 4. didFinishLoad (request.URL is redirect target)
-//
-// Note the lack of a second didStartLoading **
-//
-// When loading a page with iframes:
-// 1. shouldStartLoading (requestURL is main page)
-// 2. didStartLoading
-// 3. shouldStartLoading (requestURL is one of the iframes)
-// 4. didStartLoading
-// 5. didFinishLoad
-// 6. didFinishLoad
-//
-// Note there is no way to distinguish which didFinishLoad maps to which didStartLoad **
-//
-// Loading a page by calling window.history.go(-1):
-// 1. didStartLoading
-// 2. didFinishLoad
-//
-// Note the lack of a shouldStartLoading call **
-// Actually - this is fixed on iOS6. iOS6 has a shouldStart. **
-//
-// Loading a page by calling location.reload()
-// 1. shouldStartLoading
-// 2. didStartLoading
-// 3. didFinishLoad
-//
-// Loading a page with an iframe that fails to load:
-// 1. shouldStart (main page)
-// 2. didStart
-// 3. shouldStart (iframe)
-// 4. didStart
-// 5. didFailWithError
-// 6. didFinish
-//
-// Loading a page with an iframe that fails to load due to an invalid URL:
-// 1. shouldStart (main page)
-// 2. didStart
-// 3. shouldStart (iframe)
-// 5. didFailWithError
-// 6. didFinish
-//
-// This case breaks our logic since there is a missing didStart. To prevent this,
-// we check URLs in shouldStart and return NO if they are invalid.
-//
-// Loading a page with an invalid URL
-// 1. shouldStart (main page)
-// 2. didFailWithError
-//
-// TODO: Record order when page is re-navigated before the first navigation finishes.
-//
-
-#import "CDVWebViewDelegate.h"
-#import "CDVAvailability.h"
-
-// #define VerboseLog NSLog
-#define VerboseLog(...) do {} while (0)
-
-typedef enum {
- STATE_IDLE,
- STATE_WAITING_FOR_LOAD_START,
- STATE_WAITING_FOR_LOAD_FINISH,
- STATE_IOS5_POLLING_FOR_LOAD_START,
- STATE_IOS5_POLLING_FOR_LOAD_FINISH
-} State;
-
-@implementation CDVWebViewDelegate
-
-- (id)initWithDelegate:(NSObject <UIWebViewDelegate>*)delegate
-{
- self = [super init];
- if (self != nil) {
- _delegate = delegate;
- _loadCount = -1;
- _state = STATE_IDLE;
- }
- return self;
-}
-
-- (BOOL)request:(NSURLRequest*)newRequest isFragmentIdentifierToRequest:(NSURLRequest*)originalRequest
-{
- if (originalRequest.URL && newRequest.URL) {
- NSString* originalRequestUrl = [originalRequest.URL absoluteString];
- NSString* newRequestUrl = [newRequest.URL absoluteString];
-
- // no fragment, easy
- if (newRequest.URL.fragment == nil) {
- return NO;
- }
-
- // if the urls have fragments and they are equal
- if ((originalRequest.URL.fragment && newRequest.URL.fragment) && [originalRequestUrl isEqualToString:newRequestUrl]) {
- return YES;
- }
-
- NSString* urlFormat = @"%@://%@:%d/%@#%@";
- // reconstruct the URLs (ignoring basic auth credentials, query string)
- NSString* baseOriginalRequestUrl = [NSString stringWithFormat:urlFormat,
- [originalRequest.URL scheme],
- [originalRequest.URL host],
- [[originalRequest.URL port] intValue],
- [originalRequest.URL path],
- [newRequest.URL fragment] // add the new request's fragment
- ];
- NSString* baseNewRequestUrl = [NSString stringWithFormat:urlFormat,
- [newRequest.URL scheme],
- [newRequest.URL host],
- [[newRequest.URL port] intValue],
- [newRequest.URL path],
- [newRequest.URL fragment]
- ];
-
- return [baseOriginalRequestUrl isEqualToString:baseNewRequestUrl];
- }
-
- return NO;
-}
-
-- (BOOL)isPageLoaded:(UIWebView*)webView
-{
- NSString* readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"];
-
- return [readyState isEqualToString:@"loaded"] || [readyState isEqualToString:@"complete"];
-}
-
-- (BOOL)isJsLoadTokenSet:(UIWebView*)webView
-{
- NSString* loadToken = [webView stringByEvaluatingJavaScriptFromString:@"window.__cordovaLoadToken"];
-
- return [[NSString stringWithFormat:@"%d", _curLoadToken] isEqualToString:loadToken];
-}
-
-- (void)setLoadToken:(UIWebView*)webView
-{
- _curLoadToken += 1;
- [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.__cordovaLoadToken=%d", _curLoadToken]];
-}
-
-- (void)pollForPageLoadStart:(UIWebView*)webView
-{
- if (_state != STATE_IOS5_POLLING_FOR_LOAD_START) {
- return;
- }
- if (![self isJsLoadTokenSet:webView]) {
- VerboseLog(@"Polled for page load start. result = YES!");
- _state = STATE_IOS5_POLLING_FOR_LOAD_FINISH;
- [self setLoadToken:webView];
- if ([_delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
- [_delegate webViewDidStartLoad:webView];
- }
- [self pollForPageLoadFinish:webView];
- } else {
- VerboseLog(@"Polled for page load start. result = NO");
- // Poll only for 1 second, and then fall back on checking only when delegate methods are called.
- ++_loadStartPollCount;
- if (_loadStartPollCount < (1000 * .05)) {
- [self performSelector:@selector(pollForPageLoadStart:) withObject:webView afterDelay:.05];
- }
- }
-}
-
-- (void)pollForPageLoadFinish:(UIWebView*)webView
-{
- if (_state != STATE_IOS5_POLLING_FOR_LOAD_FINISH) {
- return;
- }
- if ([self isPageLoaded:webView]) {
- VerboseLog(@"Polled for page load finish. result = YES!");
- _state = STATE_IDLE;
- if ([_delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
- [_delegate webViewDidFinishLoad:webView];
- }
- } else {
- VerboseLog(@"Polled for page load finish. result = NO");
- [self performSelector:@selector(pollForPageLoadFinish:) withObject:webView afterDelay:.05];
- }
-}
-
-- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- BOOL shouldLoad = YES;
-
- if ([_delegate respondsToSelector:@selector(webView:shouldStartLoadWithRequest:navigationType:)]) {
- shouldLoad = [_delegate webView:webView shouldStartLoadWithRequest:request navigationType:navigationType];
- }
-
- VerboseLog(@"webView shouldLoad=%d (before) state=%d loadCount=%d URL=%@", shouldLoad, _state, _loadCount, request.URL);
-
- if (shouldLoad) {
- BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
- if (isTopLevelNavigation) {
- switch (_state) {
- case STATE_WAITING_FOR_LOAD_FINISH:
- // Redirect case.
- // We expect loadCount == 1.
- if (_loadCount != 1) {
- NSLog(@"CDVWebViewDelegate: Detected redirect when loadCount=%d", _loadCount);
- }
- break;
-
- case STATE_IDLE:
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- // Page navigation start.
- _loadCount = 0;
- _state = STATE_WAITING_FOR_LOAD_START;
- break;
-
- default:
- {
- NSString* description = [NSString stringWithFormat:@"CDVWebViewDelegate: Navigation started when state=%d", _state];
- NSLog(@"%@", description);
- _loadCount = 0;
- _state = STATE_WAITING_FOR_LOAD_START;
- if (![self request:request isFragmentIdentifierToRequest:webView.request]) {
- if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
- NSDictionary* errorDictionary = @{NSLocalizedDescriptionKey : description};
- NSError* error = [[NSError alloc] initWithDomain:@"CDVWebViewDelegate" code:1 userInfo:errorDictionary];
- [_delegate webView:webView didFailLoadWithError:error];
- }
- }
- }
- }
- } else {
- // Deny invalid URLs so that we don't get the case where we go straight from
- // webViewShouldLoad -> webViewDidFailLoad (messes up _loadCount).
- shouldLoad = shouldLoad && [NSURLConnection canHandleRequest:request];
- }
- VerboseLog(@"webView shouldLoad=%d (after) isTopLevelNavigation=%d state=%d loadCount=%d", shouldLoad, isTopLevelNavigation, _state, _loadCount);
- }
- return shouldLoad;
-}
-
-- (void)webViewDidStartLoad:(UIWebView*)webView
-{
- VerboseLog(@"webView didStartLoad (before). state=%d loadCount=%d", _state, _loadCount);
- BOOL fireCallback = NO;
- switch (_state) {
- case STATE_IDLE:
- if (IsAtLeastiOSVersion(@"6.0")) {
- break;
- }
- // If history.go(-1) is used pre-iOS6, the shouldStartLoadWithRequest function is not called.
- // Without shouldLoad, we can't distinguish an iframe from a top-level navigation.
- // We could try to distinguish using [UIWebView canGoForward], but that's too much complexity,
- // and would work only on the first time it was used.
-
- // Our work-around is to set a JS variable and poll until it disappears (from a naviagtion).
- _state = STATE_IOS5_POLLING_FOR_LOAD_START;
- _loadStartPollCount = 0;
- [self setLoadToken:webView];
- [self pollForPageLoadStart:webView];
- break;
-
- case STATE_WAITING_FOR_LOAD_START:
- if (_loadCount != 0) {
- NSLog(@"CDVWebViewDelegate: Unexpected loadCount in didStart. count=%d", _loadCount);
- }
- fireCallback = YES;
- _state = STATE_WAITING_FOR_LOAD_FINISH;
- _loadCount = 1;
- break;
-
- case STATE_WAITING_FOR_LOAD_FINISH:
- _loadCount += 1;
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- [self pollForPageLoadStart:webView];
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_FINISH:
- [self pollForPageLoadFinish:webView];
- break;
-
- default:
- NSLog(@"CDVWebViewDelegate: Unexpected didStart with state=%d loadCount=%d", _state, _loadCount);
- }
- VerboseLog(@"webView didStartLoad (after). state=%d loadCount=%d fireCallback=%d", _state, _loadCount, fireCallback);
- if (fireCallback && [_delegate respondsToSelector:@selector(webViewDidStartLoad:)]) {
- [_delegate webViewDidStartLoad:webView];
- }
-}
-
-- (void)webViewDidFinishLoad:(UIWebView*)webView
-{
- VerboseLog(@"webView didFinishLoad (before). state=%d loadCount=%d", _state, _loadCount);
- BOOL fireCallback = NO;
- switch (_state) {
- case STATE_IDLE:
- break;
-
- case STATE_WAITING_FOR_LOAD_START:
- NSLog(@"CDVWebViewDelegate: Unexpected didFinish while waiting for load start.");
- break;
-
- case STATE_WAITING_FOR_LOAD_FINISH:
- if (_loadCount == 1) {
- fireCallback = YES;
- _state = STATE_IDLE;
- }
- _loadCount -= 1;
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- [self pollForPageLoadStart:webView];
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_FINISH:
- [self pollForPageLoadFinish:webView];
- break;
- }
- VerboseLog(@"webView didFinishLoad (after). state=%d loadCount=%d fireCallback=%d", _state, _loadCount, fireCallback);
- if (fireCallback && [_delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) {
- [_delegate webViewDidFinishLoad:webView];
- }
-}
-
-- (void)webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error
-{
- VerboseLog(@"webView didFailLoad (before). state=%d loadCount=%d", _state, _loadCount);
- BOOL fireCallback = NO;
-
- switch (_state) {
- case STATE_IDLE:
- break;
-
- case STATE_WAITING_FOR_LOAD_START:
- _state = STATE_IDLE;
- fireCallback = YES;
- break;
-
- case STATE_WAITING_FOR_LOAD_FINISH:
- if (_loadCount == 1) {
- _state = STATE_IDLE;
- fireCallback = YES;
- }
- _loadCount = -1;
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_START:
- [self pollForPageLoadStart:webView];
- break;
-
- case STATE_IOS5_POLLING_FOR_LOAD_FINISH:
- [self pollForPageLoadFinish:webView];
- break;
- }
- VerboseLog(@"webView didFailLoad (after). state=%d loadCount=%d, fireCallback=%d", _state, _loadCount, fireCallback);
- if (fireCallback && [_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
- [_delegate webView:webView didFailLoadWithError:error];
- }
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVWhitelist.h b/iPhone/CordovaLib/Classes/CDVWhitelist.h
deleted file mode 100755
index 9165097..0000000
--- a/iPhone/CordovaLib/Classes/CDVWhitelist.h
+++ /dev/null
@@ -1,34 +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>
-
-extern NSString* const kCDVDefaultWhitelistRejectionString;
-
-@interface CDVWhitelist : NSObject
-
-@property (nonatomic, copy) NSString* whitelistRejectionFormatString;
-
-- (id)initWithArray:(NSArray*)array;
-- (BOOL)schemeIsAllowed:(NSString*)scheme;
-- (BOOL)URLIsAllowed:(NSURL*)url;
-- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure;
-- (NSString*)errorStringForURL:(NSURL*)url;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/CDVWhitelist.m b/iPhone/CordovaLib/Classes/CDVWhitelist.m
deleted file mode 100755
index e6807bd..0000000
--- a/iPhone/CordovaLib/Classes/CDVWhitelist.m
+++ /dev/null
@@ -1,238 +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 "CDVWhitelist.h"
-
-NSString* const kCDVDefaultWhitelistRejectionString = @"ERROR whitelist rejection: url='%@'";
-NSString* const kCDVDefaultSchemeName = @"cdv-default-scheme";
-
-@interface CDVWhitelist ()
-
-@property (nonatomic, readwrite, strong) NSArray* whitelist;
-@property (nonatomic, readwrite, strong) NSDictionary* expandedWhitelists;
-
-- (void)processWhitelist;
-
-@end
-
-@implementation CDVWhitelist
-
-@synthesize whitelist, expandedWhitelists, whitelistRejectionFormatString;
-
-- (id)initWithArray:(NSArray*)array
-{
- self = [super init];
- if (self) {
- self.whitelist = array;
- self.expandedWhitelists = nil;
- self.whitelistRejectionFormatString = kCDVDefaultWhitelistRejectionString;
- [self processWhitelist];
- }
-
- return self;
-}
-
-- (BOOL)isIPv4Address:(NSString*)externalHost
-{
- // an IPv4 address has 4 octets b.b.b.b where b is a number between 0 and 255.
- // for our purposes, b can also be the wildcard character '*'
-
- // we could use a regex to solve this problem but then I would have two problems
- // anyways, this is much clearer and maintainable
- NSArray* octets = [externalHost componentsSeparatedByString:@"."];
- NSUInteger num_octets = [octets count];
-
- // quick check
- if (num_octets != 4) {
- return NO;
- }
-
- // restrict number parsing to 0-255
- NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
- [numberFormatter setMinimum:[NSNumber numberWithUnsignedInteger:0]];
- [numberFormatter setMaximum:[NSNumber numberWithUnsignedInteger:255]];
-
- // iterate through each octet, and test for a number between 0-255 or if it equals '*'
- for (NSUInteger i = 0; i < num_octets; ++i) {
- NSString* octet = [octets objectAtIndex:i];
-
- if ([octet isEqualToString:@"*"]) { // passes - check next octet
- continue;
- } else if ([numberFormatter numberFromString:octet] == nil) { // fails - not a number and not within our range, return
- return NO;
- }
- }
-
- return YES;
-}
-
-- (NSString*)extractHostFromUrlString:(NSString*)url
-{
- NSURL* aUrl = [NSURL URLWithString:url];
-
- if ((aUrl != nil) && ([aUrl scheme] != nil)) { // found scheme
- return [aUrl host];
- } else {
- return url;
- }
-}
-
-- (NSString*)extractSchemeFromUrlString:(NSString*)url
-{
- NSURL* aUrl = [NSURL URLWithString:url];
-
- if ((aUrl != nil) && ([aUrl scheme] != nil)) { // found scheme
- return [aUrl scheme];
- } else {
- return kCDVDefaultSchemeName;
- }
-}
-
-- (void)processWhitelist
-{
- if (self.whitelist == nil) {
- NSLog(@"ERROR: CDVWhitelist was not initialized properly, all urls will be disallowed.");
- return;
- }
-
- NSMutableDictionary* _expandedWhitelists = [@{kCDVDefaultSchemeName: [NSMutableArray array]} mutableCopy];
-
- // only allow known TLDs (since Aug 23rd 2011), and two character country codes
- // does not match internationalized domain names with non-ASCII characters
- NSString* tld_match = @"(aero|asia|arpa|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|xxx|[a-z][a-z])";
-
- // iterate through settings ExternalHosts, check for equality
- for (NSString* externalHost in self.whitelist) {
- NSString* host = [self extractHostFromUrlString:externalHost];
- NSString* scheme = [self extractSchemeFromUrlString:externalHost];
-
- // check for single wildcard '*', if found set allowAll to YES
- if ([host isEqualToString:@"*"]) {
- [_expandedWhitelists setObject:[NSMutableArray arrayWithObject:host] forKey:scheme];
- continue;
- }
-
- // if this is the first value for this scheme, create a new entry
- if ([_expandedWhitelists objectForKey:scheme] == nil) {
- [_expandedWhitelists setObject:[NSMutableArray array] forKey:scheme];
- }
-
- // starts with wildcard match - we make the first '.' optional (so '*.org.apache.cordova' will match 'org.apache.cordova')
- NSString* prefix = @"*.";
- if ([host hasPrefix:prefix]) {
- // replace the first two characters '*.' with our regex
- host = [host stringByReplacingCharactersInRange:NSMakeRange(0, [prefix length]) withString:@"(\\s{0}|*.)"]; // the '*' and '.' will be substituted later
- }
-
- // ends with wildcard match for TLD
- if (![self isIPv4Address:host] && [host hasSuffix:@".*"]) {
- // replace * with tld_match
- host = [host stringByReplacingCharactersInRange:NSMakeRange([host length] - 1, 1) withString:tld_match];
- }
- // escape periods - since '.' means any character in regex
- host = [host stringByReplacingOccurrencesOfString:@"." withString:@"\\."];
- // wildcard is match 1 or more characters (to make it simple, since we are not doing verification whether the hostname is valid)
- host = [host stringByReplacingOccurrencesOfString:@"*" withString:@".*"];
-
- [[_expandedWhitelists objectForKey:scheme] addObject:host];
- }
-
- self.expandedWhitelists = _expandedWhitelists;
-}
-
-- (BOOL)schemeIsAllowed:(NSString*)scheme
-{
- if ([scheme isEqualToString:@"http"] ||
- [scheme isEqualToString:@"https"] ||
- [scheme isEqualToString:@"ftp"] ||
- [scheme isEqualToString:@"ftps"]) {
- return YES;
- }
-
- return (self.expandedWhitelists != nil) && ([self.expandedWhitelists objectForKey:scheme] != nil);
-}
-
-- (BOOL)URLIsAllowed:(NSURL*)url
-{
- return [self URLIsAllowed:url logFailure:YES];
-}
-
-- (BOOL)URLIsAllowed:(NSURL*)url logFailure:(BOOL)logFailure
-{
- NSString* scheme = [url scheme];
-
- // http[s] and ftp[s] should also validate against the common set in the kCDVDefaultSchemeName list
- if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [scheme isEqualToString:@"ftp"] || [scheme isEqualToString:@"ftps"]) {
- NSURL* newUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", kCDVDefaultSchemeName, [url host]]];
- // If it is allowed, we are done. If not, continue to check for the actual scheme-specific list
- if ([self URLIsAllowed:newUrl logFailure:NO]) {
- return YES;
- }
- }
-
- // Check that the scheme is supported
- if (![self schemeIsAllowed:scheme]) {
- if (logFailure) {
- NSLog(@"%@", [self errorStringForURL:url]);
- }
- return NO;
- }
-
- NSArray* expandedWhitelist = [self.expandedWhitelists objectForKey:scheme];
-
- // Are we allowing everything for this scheme?
- // TODO: consider just having a static sentinel value for the "allow all" list, so we can use object equality
- if (([expandedWhitelist count] == 1) && [[expandedWhitelist objectAtIndex:0] isEqualToString:@"*"]) {
- return YES;
- }
-
- // iterate through settings ExternalHosts, check for equality
- NSEnumerator* enumerator = [expandedWhitelist objectEnumerator];
- id regex = nil;
- NSString* urlHost = [url host];
-
- // if the url host IS found in the whitelist, load it in the app (however UIWebViewNavigationTypeOther kicks it out to Safari)
- // if the url host IS NOT found in the whitelist, we do nothing
- while (regex = [enumerator nextObject]) {
- NSPredicate* regex_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
-
- // if wildcard, break out and allow
- if ([regex isEqualToString:@"*"]) {
- return YES;
- }
-
- if ([regex_test evaluateWithObject:urlHost] == YES) {
- // if it matches at least one rule, return
- return YES;
- }
- }
-
- if (logFailure) {
- NSLog(@"%@", [self errorStringForURL:url]);
- }
- // if we got here, the url host is not in the white-list, do nothing
- return NO;
-}
-
-- (NSString*)errorStringForURL:(NSURL*)url
-{
- return [NSString stringWithFormat:self.whitelistRejectionFormatString, [url absoluteString]];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSArray+Comparisons.h b/iPhone/CordovaLib/Classes/NSArray+Comparisons.h
deleted file mode 100755
index cd02b71..0000000
--- a/iPhone/CordovaLib/Classes/NSArray+Comparisons.h
+++ /dev/null
@@ -1,26 +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>
-
-@interface NSArray (Comparisons)
-
-- (id)objectAtIndex:(NSUInteger)index withDefault:(id)aDefault;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSArray+Comparisons.m b/iPhone/CordovaLib/Classes/NSArray+Comparisons.m
deleted file mode 100755
index 485e3c8..0000000
--- a/iPhone/CordovaLib/Classes/NSArray+Comparisons.m
+++ /dev/null
@@ -1,41 +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 "NSArray+Comparisons.h"
-
-@implementation NSArray (Comparisons)
-
-- (id)objectAtIndex:(NSUInteger)index withDefault:(id)aDefault
-{
- id obj = nil;
-
- @try {
- obj = [self objectAtIndex:index];
- if ((obj == [NSNull null]) || (obj == nil)) {
- return aDefault;
- }
- }
- @catch(NSException* exception) {
- NSLog(@"Exception - Name: %@ Reason: %@", [exception name], [exception reason]);
- }
-
- return obj;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSData+Base64.h b/iPhone/CordovaLib/Classes/NSData+Base64.h
deleted file mode 100755
index ffe9c83..0000000
--- a/iPhone/CordovaLib/Classes/NSData+Base64.h
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// NSData+Base64.h
-// base64
-//
-// Created by Matt Gallagher on 2009/06/03.
-// Copyright 2009 Matt Gallagher. All rights reserved.
-//
-// Permission is given to use this source code file, free of charge, in any
-// project, commercial or otherwise, entirely at your risk, with the condition
-// that any redistribution (in part or whole) of source code must retain
-// this copyright and permission notice. Attribution in compiled projects is
-// appreciated but not required.
-//
-
-#import <Foundation/Foundation.h>
-
-void *CDVNewBase64Decode(
- const char* inputBuffer,
- size_t length,
- size_t * outputLength);
-
-char *CDVNewBase64Encode(
- const void* inputBuffer,
- size_t length,
- bool separateLines,
- size_t * outputLength);
-
-@interface NSData (CDVBase64)
-
-+ (NSData*)dataFromBase64String:(NSString*)aString;
-- (NSString*)base64EncodedString;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSData+Base64.m b/iPhone/CordovaLib/Classes/NSData+Base64.m
deleted file mode 100755
index d0f2189..0000000
--- a/iPhone/CordovaLib/Classes/NSData+Base64.m
+++ /dev/null
@@ -1,281 +0,0 @@
-//
-// NSData+Base64.m
-// base64
-//
-// Created by Matt Gallagher on 2009/06/03.
-// Copyright 2009 Matt Gallagher. All rights reserved.
-//
-// Permission is given to use this source code file, free of charge, in any
-// project, commercial or otherwise, entirely at your risk, with the condition
-// that any redistribution (in part or whole) of source code must retain
-// this copyright and permission notice. Attribution in compiled projects is
-// appreciated but not required.
-//
-
-#import "NSData+Base64.h"
-
-//
-// Mapping from 6 bit pattern to ASCII character.
-//
-static unsigned char cdvbase64EncodeLookup[65] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-//
-// Definition for "masked-out" areas of the base64DecodeLookup mapping
-//
-#define xx 65
-
-//
-// Mapping from ASCII character to 6 bit pattern.
-//
-static unsigned char cdvbase64DecodeLookup[256] =
-{
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, 62, xx, xx, xx, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, xx, xx, xx, xx, xx, xx,
- xx, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, xx, xx, xx, xx, xx,
- xx, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
- xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx,
-};
-
-//
-// Fundamental sizes of the binary and base64 encode/decode units in bytes
-//
-#define CDV_BINARY_UNIT_SIZE 3
-#define CDV_BASE64_UNIT_SIZE 4
-
-//
-// NewBase64Decode
-//
-// Decodes the base64 ASCII string in the inputBuffer to a newly malloced
-// output buffer.
-//
-// inputBuffer - the source ASCII string for the decode
-// length - the length of the string or -1 (to specify strlen should be used)
-// outputLength - if not-NULL, on output will contain the decoded length
-//
-// returns the decoded buffer. Must be freed by caller. Length is given by
-// outputLength.
-//
-void *CDVNewBase64Decode(
- const char* inputBuffer,
- size_t length,
- size_t * outputLength)
-{
- if (length == -1) {
- length = strlen(inputBuffer);
- }
-
- size_t outputBufferSize = (length / CDV_BASE64_UNIT_SIZE) * CDV_BINARY_UNIT_SIZE;
- unsigned char* outputBuffer = (unsigned char*)malloc(outputBufferSize);
-
- size_t i = 0;
- size_t j = 0;
-
- while (i < length) {
- //
- // Accumulate 4 valid characters (ignore everything else)
- //
- unsigned char accumulated[CDV_BASE64_UNIT_SIZE];
- bzero(accumulated, sizeof(unsigned char) * CDV_BASE64_UNIT_SIZE);
- size_t accumulateIndex = 0;
-
- while (i < length) {
- unsigned char decode = cdvbase64DecodeLookup[inputBuffer[i++]];
- if (decode != xx) {
- accumulated[accumulateIndex] = decode;
- accumulateIndex++;
-
- if (accumulateIndex == CDV_BASE64_UNIT_SIZE) {
- break;
- }
- }
- }
-
- //
- // Store the 6 bits from each of the 4 characters as 3 bytes
- //
- outputBuffer[j] = (accumulated[0] << 2) | (accumulated[1] >> 4);
- outputBuffer[j + 1] = (accumulated[1] << 4) | (accumulated[2] >> 2);
- outputBuffer[j + 2] = (accumulated[2] << 6) | accumulated[3];
- j += accumulateIndex - 1;
- }
-
- if (outputLength) {
- *outputLength = j;
- }
- return outputBuffer;
-}
-
-//
-// NewBase64Decode
-//
-// Encodes the arbitrary data in the inputBuffer as base64 into a newly malloced
-// output buffer.
-//
-// inputBuffer - the source data for the encode
-// length - the length of the input in bytes
-// separateLines - if zero, no CR/LF characters will be added. Otherwise
-// a CR/LF pair will be added every 64 encoded chars.
-// outputLength - if not-NULL, on output will contain the encoded length
-// (not including terminating 0 char)
-//
-// returns the encoded buffer. Must be freed by caller. Length is given by
-// outputLength.
-//
-char *CDVNewBase64Encode(
- const void* buffer,
- size_t length,
- bool separateLines,
- size_t * outputLength)
-{
- const unsigned char* inputBuffer = (const unsigned char*)buffer;
-
-#define MAX_NUM_PADDING_CHARS 2
-#define OUTPUT_LINE_LENGTH 64
-#define INPUT_LINE_LENGTH ((OUTPUT_LINE_LENGTH / CDV_BASE64_UNIT_SIZE) * CDV_BINARY_UNIT_SIZE)
-#define CR_LF_SIZE 0
-
- //
- // Byte accurate calculation of final buffer size
- //
- size_t outputBufferSize =
- ((length / CDV_BINARY_UNIT_SIZE)
- + ((length % CDV_BINARY_UNIT_SIZE) ? 1 : 0))
- * CDV_BASE64_UNIT_SIZE;
- if (separateLines) {
- outputBufferSize +=
- (outputBufferSize / OUTPUT_LINE_LENGTH) * CR_LF_SIZE;
- }
-
- //
- // Include space for a terminating zero
- //
- outputBufferSize += 1;
-
- //
- // Allocate the output buffer
- //
- char* outputBuffer = (char*)malloc(outputBufferSize);
- if (!outputBuffer) {
- return NULL;
- }
-
- size_t i = 0;
- size_t j = 0;
- const size_t lineLength = separateLines ? INPUT_LINE_LENGTH : length;
- size_t lineEnd = lineLength;
-
- while (true) {
- if (lineEnd > length) {
- lineEnd = length;
- }
-
- for (; i + CDV_BINARY_UNIT_SIZE - 1 < lineEnd; i += CDV_BINARY_UNIT_SIZE) {
- //
- // Inner loop: turn 48 bytes into 64 base64 characters
- //
- outputBuffer[j++] = cdvbase64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];
- outputBuffer[j++] = cdvbase64EncodeLookup[((inputBuffer[i] & 0x03) << 4)
- | ((inputBuffer[i + 1] & 0xF0) >> 4)];
- outputBuffer[j++] = cdvbase64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2)
- | ((inputBuffer[i + 2] & 0xC0) >> 6)];
- outputBuffer[j++] = cdvbase64EncodeLookup[inputBuffer[i + 2] & 0x3F];
- }
-
- if (lineEnd == length) {
- break;
- }
-
- //
- // Add the newline
- //
- // outputBuffer[j++] = '\r';
- // outputBuffer[j++] = '\n';
- lineEnd += lineLength;
- }
-
- if (i + 1 < length) {
- //
- // Handle the single '=' case
- //
- outputBuffer[j++] = cdvbase64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];
- outputBuffer[j++] = cdvbase64EncodeLookup[((inputBuffer[i] & 0x03) << 4)
- | ((inputBuffer[i + 1] & 0xF0) >> 4)];
- outputBuffer[j++] = cdvbase64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2];
- outputBuffer[j++] = '=';
- } else if (i < length) {
- //
- // Handle the double '=' case
- //
- outputBuffer[j++] = cdvbase64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2];
- outputBuffer[j++] = cdvbase64EncodeLookup[(inputBuffer[i] & 0x03) << 4];
- outputBuffer[j++] = '=';
- outputBuffer[j++] = '=';
- }
- outputBuffer[j] = 0;
-
- //
- // Set the output length and return the buffer
- //
- if (outputLength) {
- *outputLength = j;
- }
- return outputBuffer;
-}
-
-@implementation NSData (CDVBase64)
-
-//
-// dataFromBase64String:
-//
-// Creates an NSData object containing the base64 decoded representation of
-// the base64 string 'aString'
-//
-// Parameters:
-// aString - the base64 string to decode
-//
-// returns the autoreleased NSData representation of the base64 string
-//
-+ (NSData*)dataFromBase64String:(NSString*)aString
-{
- size_t outputLength = 0;
- void* outputBuffer = CDVNewBase64Decode([aString UTF8String], [aString length], &outputLength);
-
- return [NSData dataWithBytesNoCopy:outputBuffer length:outputLength freeWhenDone:YES];
-}
-
-//
-// base64EncodedString
-//
-// Creates an NSString object that contains the base 64 encoding of the
-// receiver's data. Lines are broken at 64 characters long.
-//
-// returns an autoreleased NSString being the base 64 representation of the
-// receiver.
-//
-- (NSString*)base64EncodedString
-{
- size_t outputLength = 0;
- char* outputBuffer =
- CDVNewBase64Encode([self bytes], [self length], true, &outputLength);
-
- NSString* result = [[NSString alloc] initWithBytesNoCopy:outputBuffer
- length:outputLength
- encoding:NSASCIIStringEncoding
- freeWhenDone:YES];
-
- return result;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSDictionary+Extensions.h b/iPhone/CordovaLib/Classes/NSDictionary+Extensions.h
deleted file mode 100755
index d38a6fc..0000000
--- a/iPhone/CordovaLib/Classes/NSDictionary+Extensions.h
+++ /dev/null
@@ -1,35 +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>
-
-@interface NSDictionary (org_apache_cordova_NSDictionary_Extension)
-
-- (bool)existsValue:(NSString*)expectedValue forKey:(NSString*)key;
-- (NSInteger)integerValueForKey:(NSString*)key defaultValue:(NSInteger)defaultValue withRange:(NSRange)range;
-- (NSInteger)integerValueForKey:(NSString*)key defaultValue:(NSInteger)defaultValue;
-- (BOOL)typeValueForKey:(NSString*)key isArray:(BOOL*)bArray isNull:(BOOL*)bNull isNumber:(BOOL*)bNumber isString:(BOOL*)bString;
-- (BOOL)valueForKeyIsArray:(NSString*)key;
-- (BOOL)valueForKeyIsNull:(NSString*)key;
-- (BOOL)valueForKeyIsString:(NSString*)key;
-- (BOOL)valueForKeyIsNumber:(NSString*)key;
-
-- (NSDictionary*)dictionaryWithLowercaseKeys;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSDictionary+Extensions.m b/iPhone/CordovaLib/Classes/NSDictionary+Extensions.m
deleted file mode 100755
index 0361ff9..0000000
--- a/iPhone/CordovaLib/Classes/NSDictionary+Extensions.m
+++ /dev/null
@@ -1,159 +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 "NSDictionary+Extensions.h"
-#import <math.h>
-
-@implementation NSDictionary (org_apache_cordova_NSDictionary_Extension)
-
-- (bool)existsValue:(NSString*)expectedValue forKey:(NSString*)key
-{
- id val = [self valueForKey:key];
- bool exists = false;
-
- if (val != nil) {
- exists = [(NSString*)val compare : expectedValue options : NSCaseInsensitiveSearch] == 0;
- }
-
- return exists;
-}
-
-- (NSInteger)integerValueForKey:(NSString*)key defaultValue:(NSInteger)defaultValue withRange:(NSRange)range
-{
- NSInteger value = defaultValue;
-
- NSNumber* val = [self valueForKey:key]; // value is an NSNumber
-
- if (val != nil) {
- value = [val integerValue];
- }
-
- // min, max checks
- value = MAX(range.location, value);
- value = MIN(range.length, value);
-
- return value;
-}
-
-- (NSInteger)integerValueForKey:(NSString*)key defaultValue:(NSInteger)defaultValue
-{
- NSInteger value = defaultValue;
-
- NSNumber* val = [self valueForKey:key]; // value is an NSNumber
-
- if (val != nil) {
- value = [val integerValue];
- }
- return value;
-}
-
-/*
- * Determine the type of object stored in a dictionary
- * IN:
- * (BOOL*) bString - if exists will be set to YES if object is an NSString, NO if not
- * (BOOL*) bNull - if exists will be set to YES if object is an NSNull, NO if not
- * (BOOL*) bArray - if exists will be set to YES if object is an NSArray, NO if not
- * (BOOL*) bNumber - if exists will be set to YES if object is an NSNumber, NO if not
- *
- * OUT:
- * YES if key exists
- * NO if key does not exist. Input parameters remain untouched
- *
- */
-
-- (BOOL)typeValueForKey:(NSString*)key isArray:(BOOL*)bArray isNull:(BOOL*)bNull isNumber:(BOOL*)bNumber isString:(BOOL*)bString
-{
- BOOL bExists = YES;
- NSObject* value = [self objectForKey:key];
-
- if (value) {
- bExists = YES;
- if (bString) {
- *bString = [value isKindOfClass:[NSString class]];
- }
- if (bNull) {
- *bNull = [value isKindOfClass:[NSNull class]];
- }
- if (bArray) {
- *bArray = [value isKindOfClass:[NSArray class]];
- }
- if (bNumber) {
- *bNumber = [value isKindOfClass:[NSNumber class]];
- }
- }
- return bExists;
-}
-
-- (BOOL)valueForKeyIsArray:(NSString*)key
-{
- BOOL bArray = NO;
- NSObject* value = [self objectForKey:key];
-
- if (value) {
- bArray = [value isKindOfClass:[NSArray class]];
- }
- return bArray;
-}
-
-- (BOOL)valueForKeyIsNull:(NSString*)key
-{
- BOOL bNull = NO;
- NSObject* value = [self objectForKey:key];
-
- if (value) {
- bNull = [value isKindOfClass:[NSNull class]];
- }
- return bNull;
-}
-
-- (BOOL)valueForKeyIsString:(NSString*)key
-{
- BOOL bString = NO;
- NSObject* value = [self objectForKey:key];
-
- if (value) {
- bString = [value isKindOfClass:[NSString class]];
- }
- return bString;
-}
-
-- (BOOL)valueForKeyIsNumber:(NSString*)key
-{
- BOOL bNumber = NO;
- NSObject* value = [self objectForKey:key];
-
- if (value) {
- bNumber = [value isKindOfClass:[NSNumber class]];
- }
- return bNumber;
-}
-
-- (NSDictionary*)dictionaryWithLowercaseKeys
-{
- NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:self.count];
- NSString* key;
-
- for (key in self) {
- [result setObject:[self objectForKey:key] forKey:[key lowercaseString]];
- }
-
- return result;
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.h b/iPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.h
deleted file mode 100755
index 3194094..0000000
--- a/iPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.h
+++ /dev/null
@@ -1,29 +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>
-
-@interface NSMutableArray (QueueAdditions)
-
-- (id)pop;
-- (id)queueHead;
-- (id)dequeue;
-- (void)enqueue:(id)obj;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.m b/iPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.m
deleted file mode 100755
index 9e67ede..0000000
--- a/iPhone/CordovaLib/Classes/NSMutableArray+QueueAdditions.m
+++ /dev/null
@@ -1,58 +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 "NSMutableArray+QueueAdditions.h"
-
-@implementation NSMutableArray (QueueAdditions)
-
-- (id)queueHead
-{
- if ([self count] == 0) {
- return nil;
- }
-
- return [self objectAtIndex:0];
-}
-
-- (__autoreleasing id)dequeue
-{
- if ([self count] == 0) {
- return nil;
- }
-
- id head = [self objectAtIndex:0];
- if (head != nil) {
- // [[head retain] autorelease]; ARC - the __autoreleasing on the return value should so the same thing
- [self removeObjectAtIndex:0];
- }
-
- return head;
-}
-
-- (id)pop
-{
- return [self dequeue];
-}
-
-- (void)enqueue:(id)object
-{
- [self addObject:object];
-}
-
-@end
diff --git a/iPhone/CordovaLib/Classes/UIDevice+Extensions.h b/iPhone/CordovaLib/Classes/UIDevice+Extensions.h
deleted file mode 100755
index dab73e6..0000000
--- a/iPhone/CordovaLib/Classes/UIDevice+Extensions.h
+++ /dev/null
@@ -1,31 +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>
-
-@interface UIDevice (org_apache_cordova_UIDevice_Extension)
-
-/*
- Get the unique identifier from the app bundle's folder, which is already a GUID
- Upgrading and/or deleting the app and re-installing will get you a new GUID, so
- this is only unique per install per device.
- */
-- (NSString*)uniqueAppInstanceIdentifier;
-
-@end
diff --git a/iPhone/CordovaLib/Classes/UIDevice+Extensions.m b/iPhone/CordovaLib/Classes/UIDevice+Extensions.m
deleted file mode 100755
index c0c91af..0000000
--- a/iPhone/CordovaLib/Classes/UIDevice+Extensions.m
+++ /dev/null
@@ -1,47 +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 "UIDevice+Extensions.h"
-
-@implementation UIDevice (org_apache_cordova_UIDevice_Extension)
-
-- (NSString*)uniqueAppInstanceIdentifier
-{
- NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
- static NSString* UUID_KEY = @"CDVUUID";
-
- NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
-
- if (app_uuid == nil) {
- CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
- CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
-
- app_uuid = [NSString stringWithString:(__bridge NSString*)uuidString];
- [userDefaults setObject:app_uuid forKey:UUID_KEY];
- [userDefaults synchronize];
-
- CFRelease(uuidString);
- CFRelease(uuidRef);
- }
-
- return app_uuid;
-}
-
-@end
diff --git a/iPhone/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/iPhone/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
deleted file mode 100755
index 63ab4dd..0000000
--- a/iPhone/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,682 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- 1F2BECC013F9785B00A93BF6 /* CDVBattery.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 1F2BECC113F9785B00A93BF6 /* CDVBattery.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */; };
- 1F3C04CE12BC247D004F9E10 /* CDVContact.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3C04CC12BC247D004F9E10 /* CDVContact.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 1F3C04CF12BC247D004F9E10 /* CDVContact.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F3C04CD12BC247D004F9E10 /* CDVContact.m */; };
- 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 */; };
- 3073E9E91656D37700957977 /* CDVInAppBrowser.h in Headers */ = {isa = PBXBuildFile; fileRef = 3073E9E71656D37700957977 /* CDVInAppBrowser.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 3073E9EA1656D37700957977 /* CDVInAppBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = 3073E9E81656D37700957977 /* CDVInAppBrowser.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 */; };
- 30B39EBE13D0268B0009682A /* CDVSplashScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 30B39EBC13D0268B0009682A /* CDVSplashScreen.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 30B39EBF13D0268B0009682A /* CDVSplashScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 30B39EBD13D0268B0009682A /* CDVSplashScreen.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, ); }; };
- 30C684961407044B004C1A8E /* CDVURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 30C684931407044A004C1A8E /* CDVURLProtocol.m */; };
- 30E33AF213A7E24B00594D64 /* CDVPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E33AF013A7E24B00594D64 /* CDVPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 30E33AF313A7E24B00594D64 /* CDVPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 30E33AF113A7E24B00594D64 /* CDVPlugin.m */; };
- 30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E563CD13E217EC00C949AA /* NSMutableArray+QueueAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */; };
- 30F3930B169F839700B22307 /* CDVJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = 30F39309169F839700B22307 /* CDVJSON.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 30F3930C169F839700B22307 /* CDVJSON.m in Sources */ = {isa = PBXBuildFile; fileRef = 30F3930A169F839700B22307 /* CDVJSON.m */; };
- 30F5EBAB14CA26E700987760 /* CDVCommandDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30F5EBA914CA26E700987760 /* CDVCommandDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 3E76876D156A90EE00EB6FA3 /* CDVLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E76876B156A90EE00EB6FA3 /* CDVLogger.m */; };
- 3E76876F156A90EE00EB6FA3 /* CDVLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 3E76876C156A90EE00EB6FA3 /* CDVLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 68B7516E16FD18190076A8B4 /* CDVJpegHeaderWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 68B7516F16FD18190076A8B4 /* CDVJpegHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */; };
- 68B7517016FD19F80076A8B4 /* CDVExif.h in Headers */ = {isa = PBXBuildFile; fileRef = 68B7516A16FD18190076A8B4 /* CDVExif.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 7E14B5A81705050A0032169E /* CDVTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E14B5A61705050A0032169E /* CDVTimer.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 7E14B5A91705050A0032169E /* CDVTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E14B5A71705050A0032169E /* CDVTimer.m */; };
- 8852C43A14B65FD800F0E735 /* CDVViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43614B65FD800F0E735 /* CDVViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8852C43C14B65FD800F0E735 /* CDVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* CDVViewController.m */; };
- 8887FD661090FBE7009987E8 /* CDVCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD261090FBE7009987E8 /* CDVCamera.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD271090FBE7009987E8 /* CDVCamera.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 */; };
- 8887FD6A1090FBE7009987E8 /* CDVContacts.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD2A1090FBE7009987E8 /* CDVContacts.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD6B1090FBE7009987E8 /* CDVContacts.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD2B1090FBE7009987E8 /* CDVContacts.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 */; };
- 8887FD851090FBE7009987E8 /* CDVLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD461090FBE7009987E8 /* CDVLocation.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD861090FBE7009987E8 /* CDVLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD471090FBE7009987E8 /* CDVLocation.m */; };
- 8887FD8D1090FBE7009987E8 /* CDVNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD4E1090FBE7009987E8 /* CDVNotification.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD8E1090FBE7009987E8 /* CDVNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD4F1090FBE7009987E8 /* CDVNotification.m */; };
- 8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
- 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, ); }; };
- 8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD611090FBE7009987E8 /* CDVSound.m */; };
- 88BA573D109BB46F00FB5E78 /* CDVAccelerometer.h in Headers */ = {isa = PBXBuildFile; fileRef = 88BA573B109BB46F00FB5E78 /* CDVAccelerometer.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 88BA573E109BB46F00FB5E78 /* CDVAccelerometer.m in Sources */ = {isa = PBXBuildFile; fileRef = 88BA573C109BB46F00FB5E78 /* CDVAccelerometer.m */; };
- 9D76CF3C1625A4C50008A0F6 /* CDVGlobalization.h in Headers */ = {isa = PBXBuildFile; fileRef = 9D76CF3A1625A4C50008A0F6 /* CDVGlobalization.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 9D76CF3D1625A4C50008A0F6 /* CDVGlobalization.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D76CF3B1625A4C50008A0F6 /* CDVGlobalization.m */; };
- 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, ); }; };
- EB3B357D161F2A45003DBE7D /* CDVCommandDelegateImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = EB3B357B161F2A45003DBE7D /* CDVCommandDelegateImpl.m */; };
- EB80C2AC15DEA63D004D9E7B /* CDVEcho.h in Headers */ = {isa = PBXBuildFile; fileRef = EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */; settings = {ATTRIBUTES = (Public, ); }; };
- EB80C2AD15DEA63D004D9E7B /* CDVEcho.m in Sources */ = {isa = PBXBuildFile; fileRef = EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */; };
- EB96673B16A8970A00D86CDF /* CDVUserAgentUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = EB96673916A8970900D86CDF /* CDVUserAgentUtil.h */; settings = {ATTRIBUTES = (Public, ); }; };
- EB96673C16A8970A00D86CDF /* CDVUserAgentUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = EB96673A16A8970900D86CDF /* CDVUserAgentUtil.m */; };
- EBA3557315ABD38C00F4DE24 /* NSArray+Comparisons.h in Headers */ = {isa = PBXBuildFile; fileRef = EBA3557115ABD38C00F4DE24 /* NSArray+Comparisons.h */; settings = {ATTRIBUTES = (Public, ); }; };
- EBA3557515ABD38C00F4DE24 /* NSArray+Comparisons.m in Sources */ = {isa = PBXBuildFile; fileRef = EBA3557215ABD38C00F4DE24 /* NSArray+Comparisons.m */; };
- EBFF4DBC16D3FE2E008F452B /* CDVWebViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EBFF4DBA16D3FE2E008F452B /* CDVWebViewDelegate.m */; };
- EBFF4DBD16D3FE2E008F452B /* CDVWebViewDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = EBFF4DBB16D3FE2E008F452B /* CDVWebViewDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
- F858FBC6166009A8007DA594 /* CDVConfigParser.h in Headers */ = {isa = PBXBuildFile; fileRef = F858FBC4166009A8007DA594 /* CDVConfigParser.h */; settings = {ATTRIBUTES = (Public, ); }; };
- F858FBC7166009A8007DA594 /* CDVConfigParser.m in Sources */ = {isa = PBXBuildFile; fileRef = F858FBC5166009A8007DA594 /* CDVConfigParser.m */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
- 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVBattery.h; path = Classes/CDVBattery.h; sourceTree = "<group>"; };
- 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVBattery.m; path = Classes/CDVBattery.m; sourceTree = "<group>"; };
- 1F3C04CC12BC247D004F9E10 /* CDVContact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVContact.h; path = Classes/CDVContact.h; sourceTree = "<group>"; };
- 1F3C04CD12BC247D004F9E10 /* CDVContact.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVContact.m; path = Classes/CDVContact.m; sourceTree = "<group>"; };
- 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>"; };
- 3073E9E71656D37700957977 /* CDVInAppBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVInAppBrowser.h; path = Classes/CDVInAppBrowser.h; sourceTree = "<group>"; };
- 3073E9E81656D37700957977 /* CDVInAppBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVInAppBrowser.m; path = Classes/CDVInAppBrowser.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>"; };
- 30B39EBC13D0268B0009682A /* CDVSplashScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVSplashScreen.h; path = Classes/CDVSplashScreen.h; sourceTree = "<group>"; };
- 30B39EBD13D0268B0009682A /* CDVSplashScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVSplashScreen.m; path = Classes/CDVSplashScreen.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>"; };
- 30C684931407044A004C1A8E /* CDVURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVURLProtocol.m; path = Classes/CDVURLProtocol.m; sourceTree = "<group>"; };
- 30E33AF013A7E24B00594D64 /* CDVPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVPlugin.h; path = Classes/CDVPlugin.h; sourceTree = "<group>"; };
- 30E33AF113A7E24B00594D64 /* CDVPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVPlugin.m; path = Classes/CDVPlugin.m; sourceTree = "<group>"; };
- 30E563CD13E217EC00C949AA /* NSMutableArray+QueueAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSMutableArray+QueueAdditions.h"; path = "Classes/NSMutableArray+QueueAdditions.h"; sourceTree = "<group>"; };
- 30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSMutableArray+QueueAdditions.m"; path = "Classes/NSMutableArray+QueueAdditions.m"; sourceTree = "<group>"; };
- 30F39309169F839700B22307 /* CDVJSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVJSON.h; path = Classes/CDVJSON.h; sourceTree = "<group>"; };
- 30F3930A169F839700B22307 /* CDVJSON.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVJSON.m; path = Classes/CDVJSON.m; sourceTree = "<group>"; };
- 30F5EBA914CA26E700987760 /* CDVCommandDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCommandDelegate.h; path = Classes/CDVCommandDelegate.h; sourceTree = "<group>"; };
- 3E76876B156A90EE00EB6FA3 /* CDVLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVLogger.m; path = Classes/CDVLogger.m; sourceTree = "<group>"; };
- 3E76876C156A90EE00EB6FA3 /* CDVLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVLogger.h; path = Classes/CDVLogger.h; sourceTree = "<group>"; };
- 686357AA141002F100DF4CF2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
- 686357AC141002F100DF4CF2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- 686357AE141002F100DF4CF2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- 686357CC14100AAD00DF4CF2 /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; };
- 686357CE14100ADA00DF4CF2 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
- 686357CF14100ADB00DF4CF2 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
- 686357D014100ADE00DF4CF2 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
- 686357D214100AE700DF4CF2 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
- 686357D414100AF200DF4CF2 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
- 686357DC14100B1600DF4CF2 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
- 68A32D7114102E1C006B237C /* libCordova.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCordova.a; sourceTree = BUILT_PRODUCTS_DIR; };
- 68A32D7414103017006B237C /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
- 68B7516A16FD18190076A8B4 /* CDVExif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVExif.h; path = Classes/CDVExif.h; sourceTree = "<group>"; };
- 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVJpegHeaderWriter.h; path = Classes/CDVJpegHeaderWriter.h; sourceTree = "<group>"; };
- 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVJpegHeaderWriter.m; path = Classes/CDVJpegHeaderWriter.m; sourceTree = "<group>"; };
- 7E14B5A61705050A0032169E /* CDVTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVTimer.h; path = Classes/CDVTimer.h; sourceTree = "<group>"; };
- 7E14B5A71705050A0032169E /* CDVTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVTimer.m; path = Classes/CDVTimer.m; sourceTree = "<group>"; };
- 8220B5C316D5427E00EC3921 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
- 8852C43614B65FD800F0E735 /* CDVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVViewController.h; path = Classes/CDVViewController.h; sourceTree = "<group>"; };
- 8852C43714B65FD800F0E735 /* CDVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVViewController.m; path = Classes/CDVViewController.m; sourceTree = "<group>"; };
- 8887FD261090FBE7009987E8 /* CDVCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVCamera.h; path = Classes/CDVCamera.h; sourceTree = "<group>"; };
- 8887FD271090FBE7009987E8 /* CDVCamera.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCamera.m; path = Classes/CDVCamera.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>"; };
- 8887FD2A1090FBE7009987E8 /* CDVContacts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVContacts.h; path = Classes/CDVContacts.h; sourceTree = "<group>"; };
- 8887FD2B1090FBE7009987E8 /* CDVContacts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVContacts.m; path = Classes/CDVContacts.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>"; };
- 8887FD461090FBE7009987E8 /* CDVLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVLocation.h; path = Classes/CDVLocation.h; sourceTree = "<group>"; };
- 8887FD471090FBE7009987E8 /* CDVLocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVLocation.m; path = Classes/CDVLocation.m; sourceTree = "<group>"; };
- 8887FD4E1090FBE7009987E8 /* CDVNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVNotification.h; path = Classes/CDVNotification.h; sourceTree = "<group>"; };
- 8887FD4F1090FBE7009987E8 /* CDVNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVNotification.m; path = Classes/CDVNotification.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>"; };
- 8887FD511090FBE7009987E8 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+Base64.m"; path = "Classes/NSData+Base64.m"; sourceTree = "<group>"; };
- 8887FD5E1090FBE7009987E8 /* CDVReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVReachability.h; path = Classes/CDVReachability.h; sourceTree = "<group>"; };
- 8887FD5F1090FBE7009987E8 /* CDVReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVReachability.m; path = Classes/CDVReachability.m; sourceTree = "<group>"; };
- 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>"; };
- 88BA573B109BB46F00FB5E78 /* CDVAccelerometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVAccelerometer.h; path = Classes/CDVAccelerometer.h; sourceTree = "<group>"; };
- 88BA573C109BB46F00FB5E78 /* CDVAccelerometer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVAccelerometer.m; path = Classes/CDVAccelerometer.m; sourceTree = "<group>"; };
- 9D76CF3A1625A4C50008A0F6 /* CDVGlobalization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVGlobalization.h; path = Classes/CDVGlobalization.h; sourceTree = "<group>"; };
- 9D76CF3B1625A4C50008A0F6 /* CDVGlobalization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVGlobalization.m; path = Classes/CDVGlobalization.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>"; };
- EB3B357B161F2A45003DBE7D /* CDVCommandDelegateImpl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVCommandDelegateImpl.m; path = Classes/CDVCommandDelegateImpl.m; sourceTree = "<group>"; };
- EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVEcho.h; path = Classes/CDVEcho.h; sourceTree = "<group>"; };
- EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVEcho.m; path = Classes/CDVEcho.m; sourceTree = "<group>"; };
- EB96673916A8970900D86CDF /* CDVUserAgentUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVUserAgentUtil.h; path = Classes/CDVUserAgentUtil.h; sourceTree = "<group>"; };
- EB96673A16A8970900D86CDF /* CDVUserAgentUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVUserAgentUtil.m; path = Classes/CDVUserAgentUtil.m; sourceTree = "<group>"; };
- EBA3557115ABD38C00F4DE24 /* NSArray+Comparisons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSArray+Comparisons.h"; path = "Classes/NSArray+Comparisons.h"; sourceTree = "<group>"; };
- EBA3557215ABD38C00F4DE24 /* NSArray+Comparisons.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSArray+Comparisons.m"; path = "Classes/NSArray+Comparisons.m"; sourceTree = "<group>"; };
- EBFF4DBA16D3FE2E008F452B /* CDVWebViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVWebViewDelegate.m; path = Classes/CDVWebViewDelegate.m; sourceTree = "<group>"; };
- EBFF4DBB16D3FE2E008F452B /* CDVWebViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVWebViewDelegate.h; path = Classes/CDVWebViewDelegate.h; sourceTree = "<group>"; };
- F858FBC4166009A8007DA594 /* CDVConfigParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVConfigParser.h; path = Classes/CDVConfigParser.h; sourceTree = "<group>"; };
- F858FBC5166009A8007DA594 /* CDVConfigParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CDVConfigParser.m; path = Classes/CDVConfigParser.m; sourceTree = "<group>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- D2AAC07C0554694100DB518D /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 034768DFFF38A50411DB9C8B /* Products */ = {
- isa = PBXGroup;
- children = (
- 68A32D7114102E1C006B237C /* libCordova.a */,
- );
- name = Products;
- sourceTree = CORDOVALIB;
- };
- 0867D691FE84028FC02AAC07 /* CordovaLib */ = {
- isa = PBXGroup;
- children = (
- 8887FD101090FB43009987E8 /* Classes */,
- 32C88DFF0371C24200C91783 /* Other Sources */,
- 0867D69AFE84028FC02AAC07 /* Frameworks */,
- 034768DFFF38A50411DB9C8B /* Products */,
- 30325A0B136B343700982B63 /* VERSION */,
- );
- name = CordovaLib;
- sourceTree = "<group>";
- };
- 0867D69AFE84028FC02AAC07 /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- 68A32D7414103017006B237C /* AddressBook.framework */,
- 8220B5C316D5427E00EC3921 /* AssetsLibrary.framework */,
- 686357DC14100B1600DF4CF2 /* CoreMedia.framework */,
- 686357CE14100ADA00DF4CF2 /* AudioToolbox.framework */,
- 686357CF14100ADB00DF4CF2 /* AVFoundation.framework */,
- 686357D014100ADE00DF4CF2 /* CoreLocation.framework */,
- 686357D214100AE700DF4CF2 /* MobileCoreServices.framework */,
- 686357D414100AF200DF4CF2 /* SystemConfiguration.framework */,
- 686357CC14100AAD00DF4CF2 /* AddressBookUI.framework */,
- 686357AA141002F100DF4CF2 /* UIKit.framework */,
- 686357AC141002F100DF4CF2 /* Foundation.framework */,
- 686357AE141002F100DF4CF2 /* CoreGraphics.framework */,
- );
- name = Frameworks;
- sourceTree = "<group>";
- };
- 3054098714B77FF3009841CA /* Cleaver */ = {
- isa = PBXGroup;
- children = (
- F858FBC4166009A8007DA594 /* CDVConfigParser.h */,
- F858FBC5166009A8007DA594 /* CDVConfigParser.m */,
- 8852C43614B65FD800F0E735 /* CDVViewController.h */,
- 8852C43714B65FD800F0E735 /* CDVViewController.m */,
- EB3B3545161CB44D003DBE7D /* CDVCommandQueue.h */,
- EB3B3546161CB44D003DBE7D /* CDVCommandQueue.m */,
- );
- name = Cleaver;
- sourceTree = "<group>";
- };
- 32C88DFF0371C24200C91783 /* Other Sources */ = {
- isa = PBXGroup;
- children = (
- AA747D9E0F9514B9006C5449 /* CordovaLib_Prefix.pch */,
- );
- name = "Other Sources";
- sourceTree = "<group>";
- };
- 888700D710922F56009987E8 /* Commands */ = {
- isa = PBXGroup;
- 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 */,
- EB3B357B161F2A45003DBE7D /* CDVCommandDelegateImpl.m */,
- 30C684921407044A004C1A8E /* CDVURLProtocol.h */,
- 30C684931407044A004C1A8E /* CDVURLProtocol.m */,
- 30C6847E1406CB38004C1A8E /* CDVWhitelist.h */,
- 30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
- 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */,
- 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */,
- 30B39EBC13D0268B0009682A /* CDVSplashScreen.h */,
- 30B39EBD13D0268B0009682A /* CDVSplashScreen.m */,
- 30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
- 30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
- 307A8F9C1385A2EC00E43782 /* CDVConnection.h */,
- 307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
- 1F92F49E1314023E0046367C /* CDVPluginResult.h */,
- 1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 88BA573B109BB46F00FB5E78 /* CDVAccelerometer.h */,
- 88BA573C109BB46F00FB5E78 /* CDVAccelerometer.m */,
- 8887FD261090FBE7009987E8 /* CDVCamera.h */,
- 8887FD271090FBE7009987E8 /* CDVCamera.m */,
- 1F584B991385A28900ED25E8 /* CDVCapture.h */,
- 1F584B9A1385A28900ED25E8 /* CDVCapture.m */,
- 68B7516A16FD18190076A8B4 /* CDVExif.h */,
- 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */,
- 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */,
- 1F3C04CC12BC247D004F9E10 /* CDVContact.h */,
- 1F3C04CD12BC247D004F9E10 /* CDVContact.m */,
- 8887FD2A1090FBE7009987E8 /* CDVContacts.h */,
- 8887FD2B1090FBE7009987E8 /* CDVContacts.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 */,
- 8887FD461090FBE7009987E8 /* CDVLocation.h */,
- 8887FD471090FBE7009987E8 /* CDVLocation.m */,
- 8887FD4E1090FBE7009987E8 /* CDVNotification.h */,
- 8887FD4F1090FBE7009987E8 /* CDVNotification.m */,
- 8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
- 8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
- 8887FD601090FBE7009987E8 /* CDVSound.h */,
- 8887FD611090FBE7009987E8 /* CDVSound.m */,
- 3E76876B156A90EE00EB6FA3 /* CDVLogger.m */,
- 3E76876C156A90EE00EB6FA3 /* CDVLogger.h */,
- 9D76CF3A1625A4C50008A0F6 /* CDVGlobalization.h */,
- 9D76CF3B1625A4C50008A0F6 /* CDVGlobalization.m */,
- 3073E9E71656D37700957977 /* CDVInAppBrowser.h */,
- 3073E9E81656D37700957977 /* CDVInAppBrowser.m */,
- 3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */,
- 30F39309169F839700B22307 /* CDVJSON.h */,
- 30F3930A169F839700B22307 /* CDVJSON.m */,
- EB96673916A8970900D86CDF /* CDVUserAgentUtil.h */,
- EB96673A16A8970900D86CDF /* CDVUserAgentUtil.m */,
- );
- name = Commands;
- sourceTree = "<group>";
- };
- 888700D910923009009987E8 /* Util */ = {
- isa = PBXGroup;
- children = (
- 3062D11E151D0EDB000D9128 /* UIDevice+Extensions.h */,
- 3062D11F151D0EDB000D9128 /* UIDevice+Extensions.m */,
- EBA3557115ABD38C00F4DE24 /* NSArray+Comparisons.h */,
- EBA3557215ABD38C00F4DE24 /* NSArray+Comparisons.m */,
- 8887FD281090FBE7009987E8 /* NSDictionary+Extensions.h */,
- 8887FD291090FBE7009987E8 /* NSDictionary+Extensions.m */,
- 302965BB13A94E9D007046C5 /* CDVDebug.h */,
- 30E563CD13E217EC00C949AA /* NSMutableArray+QueueAdditions.h */,
- 30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */,
- 8887FD501090FBE7009987E8 /* NSData+Base64.h */,
- 8887FD511090FBE7009987E8 /* NSData+Base64.m */,
- 7E14B5A61705050A0032169E /* CDVTimer.h */,
- 7E14B5A71705050A0032169E /* CDVTimer.m */,
- );
- name = Util;
- sourceTree = "<group>";
- };
- 8887FD101090FB43009987E8 /* Classes */ = {
- isa = PBXGroup;
- children = (
- 3054098714B77FF3009841CA /* Cleaver */,
- 888700D710922F56009987E8 /* Commands */,
- 888700D910923009009987E8 /* Util */,
- );
- name = Classes;
- sourceTree = "<group>";
- };
-/* End PBXGroup section */
-
-/* Begin PBXHeadersBuildPhase section */
- D2AAC07A0554694100DB518D /* Headers */ = {
- isa = PBXHeadersBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 68B7517016FD19F80076A8B4 /* CDVExif.h in Headers */,
- 68B7516E16FD18190076A8B4 /* CDVJpegHeaderWriter.h in Headers */,
- 8887FD661090FBE7009987E8 /* CDVCamera.h in Headers */,
- 8887FD681090FBE7009987E8 /* NSDictionary+Extensions.h in Headers */,
- 8887FD6A1090FBE7009987E8 /* CDVContacts.h in Headers */,
- 8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
- 8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
- 8887FD851090FBE7009987E8 /* CDVLocation.h in Headers */,
- 8887FD8D1090FBE7009987E8 /* CDVNotification.h in Headers */,
- 8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
- 8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
- 8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
- 88BA573D109BB46F00FB5E78 /* CDVAccelerometer.h in Headers */,
- 1F3C04CE12BC247D004F9E10 /* CDVContact.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 */,
- 30B39EBE13D0268B0009682A /* CDVSplashScreen.h in Headers */,
- 30E563CF13E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
- 1F2BECC013F9785B00A93BF6 /* CDVBattery.h in Headers */,
- 30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */,
- 30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */,
- 8852C43A14B65FD800F0E735 /* CDVViewController.h in Headers */,
- 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 */,
- 9D76CF3C1625A4C50008A0F6 /* CDVGlobalization.h in Headers */,
- 3073E9E91656D37700957977 /* CDVInAppBrowser.h in Headers */,
- 3073E9ED1656D51200957977 /* CDVScreenOrientationDelegate.h in Headers */,
- F858FBC6166009A8007DA594 /* CDVConfigParser.h in Headers */,
- 30F3930B169F839700B22307 /* CDVJSON.h in Headers */,
- EBFF4DBD16D3FE2E008F452B /* CDVWebViewDelegate.h in Headers */,
- EB96673B16A8970A00D86CDF /* CDVUserAgentUtil.h in Headers */,
- 7E14B5A81705050A0032169E /* CDVTimer.h in Headers */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXHeadersBuildPhase section */
-
-/* Begin PBXNativeTarget section */
- D2AAC07D0554694100DB518D /* CordovaLib */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "CordovaLib" */;
- buildPhases = (
- D2AAC07A0554694100DB518D /* Headers */,
- D2AAC07B0554694100DB518D /* Sources */,
- D2AAC07C0554694100DB518D /* Frameworks */,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = CordovaLib;
- productName = CordovaLib;
- productReference = 68A32D7114102E1C006B237C /* libCordova.a */;
- productType = "com.apple.product-type.library.static";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 0867D690FE84028FC02AAC07 /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 0500;
- };
- buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CordovaLib" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 1;
- knownRegions = (
- English,
- Japanese,
- French,
- German,
- en,
- );
- mainGroup = 0867D691FE84028FC02AAC07 /* CordovaLib */;
- productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
- projectDirPath = "";
- projectRoot = "";
- targets = (
- D2AAC07D0554694100DB518D /* CordovaLib */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXSourcesBuildPhase section */
- D2AAC07B0554694100DB518D /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */,
- 8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
- 8887FD6B1090FBE7009987E8 /* CDVContacts.m in Sources */,
- 8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
- 8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
- 8887FD861090FBE7009987E8 /* CDVLocation.m in Sources */,
- 8887FD8E1090FBE7009987E8 /* CDVNotification.m in Sources */,
- 8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
- 8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
- 8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
- 88BA573E109BB46F00FB5E78 /* CDVAccelerometer.m in Sources */,
- 1F3C04CF12BC247D004F9E10 /* CDVContact.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 */,
- 30B39EBF13D0268B0009682A /* CDVSplashScreen.m in Sources */,
- 30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */,
- 1F2BECC113F9785B00A93BF6 /* CDVBattery.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 */,
- 9D76CF3D1625A4C50008A0F6 /* CDVGlobalization.m in Sources */,
- 3073E9EA1656D37700957977 /* CDVInAppBrowser.m in Sources */,
- F858FBC7166009A8007DA594 /* CDVConfigParser.m in Sources */,
- 30F3930C169F839700B22307 /* CDVJSON.m in Sources */,
- EB96673C16A8970A00D86CDF /* CDVUserAgentUtil.m in Sources */,
- EBFF4DBC16D3FE2E008F452B /* CDVWebViewDelegate.m in Sources */,
- 68B7516F16FD18190076A8B4 /* CDVJpegHeaderWriter.m in Sources */,
- 7E14B5A91705050A0032169E /* CDVTimer.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin XCBuildConfiguration section */
- 1DEB921F08733DC00010E9CD /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- "ARCHS[sdk=iphoneos*]" = armv7;
- "ARCHS[sdk=iphoneos6.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphoneos7.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphonesimulator*]" = i386;
- CLANG_ENABLE_OBJC_ARC = YES;
- COPY_PHASE_STRIP = NO;
- DSTROOT = "/tmp/$(PROJECT_NAME).dst";
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_MODEL_TUNING = G5;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = CordovaLib_Prefix.pch;
- GCC_PREPROCESSOR_DEFINITIONS = "";
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- INSTALL_PATH = /usr/local/lib;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- PRODUCT_NAME = Cordova;
- PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
- SKIP_INSTALL = YES;
- };
- name = Debug;
- };
- 1DEB922008733DC00010E9CD /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- "ARCHS[sdk=iphoneos*]" = armv7;
- "ARCHS[sdk=iphoneos6.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphoneos7.*]" = (
- armv7,
- armv7s,
- );
- "ARCHS[sdk=iphonesimulator*]" = i386;
- CLANG_ENABLE_OBJC_ARC = YES;
- DSTROOT = "/tmp/$(PROJECT_NAME).dst";
- GCC_MODEL_TUNING = G5;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = CordovaLib_Prefix.pch;
- GCC_PREPROCESSOR_DEFINITIONS = "";
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- INSTALL_PATH = /usr/local/lib;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- PRODUCT_NAME = Cordova;
- PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
- SKIP_INSTALL = YES;
- };
- name = Release;
- };
- 1DEB922308733DC00010E9CD /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)";
- "ARCHS[sdk=iphoneos6.*]" = "$(ARCHS_STANDARD)";
- "ARCHS[sdk=iphoneos7.*]" = "$(ARCHS_STANDARD)";
- "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)";
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- GCC_C_LANGUAGE_STANDARD = c99;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PREPROCESSOR_DEFINITIONS = "";
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- ONLY_ACTIVE_ARCH = YES;
- OTHER_CFLAGS = "-DDEBUG";
- PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
- SDKROOT = iphoneos;
- SKIP_INSTALL = YES;
- TARGETED_DEVICE_FAMILY = "1,2";
- USER_HEADER_SEARCH_PATHS = "";
- VALID_ARCHS = "arm64 armv7 armv7s";
- };
- name = Debug;
- };
- 1DEB922408733DC00010E9CD /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)";
- "ARCHS[sdk=iphoneos6.*]" = "$(ARCHS_STANDARD)";
- "ARCHS[sdk=iphoneos7.*]" = "$(ARCHS_STANDARD)";
- "ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD)";
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- GCC_C_LANGUAGE_STANDARD = c99;
- GCC_PREPROCESSOR_DEFINITIONS = "";
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- "IPHONEOS_DEPLOYMENT_TARGET[sdk=iphoneos6.*]" = 5.1.1;
- ONLY_ACTIVE_ARCH = NO;
- PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
- SDKROOT = iphoneos;
- SKIP_INSTALL = YES;
- TARGETED_DEVICE_FAMILY = "1,2";
- VALID_ARCHS = "arm64 armv7 armv7s";
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "CordovaLib" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 1DEB921F08733DC00010E9CD /* Debug */,
- 1DEB922008733DC00010E9CD /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CordovaLib" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 1DEB922308733DC00010E9CD /* Debug */,
- 1DEB922408733DC00010E9CD /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
-}
diff --git a/iPhone/CordovaLib/CordovaLib_Prefix.pch b/iPhone/CordovaLib/CordovaLib_Prefix.pch
deleted file mode 100755
index 9545580..0000000
--- a/iPhone/CordovaLib/CordovaLib_Prefix.pch
+++ /dev/null
@@ -1,22 +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.
- */
-
-#ifdef __OBJC__
- #import <Foundation/Foundation.h>
-#endif
diff --git a/iPhone/CordovaLib/VERSION b/iPhone/CordovaLib/VERSION
deleted file mode 100755
index c8e38b6..0000000
--- a/iPhone/CordovaLib/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-2.9.0
diff --git a/iPhone/CordovaLib/cordova.js b/iPhone/CordovaLib/cordova.js
deleted file mode 100755
index 9bd85e2..0000000
--- a/iPhone/CordovaLib/cordova.js
+++ /dev/null
@@ -1,6521 +0,0 @@
-// Platform: ios
-// 2.9.0-0-g83dc4bd
-/*
- 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.
-*/
-;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.9.0-0-g83dc4bd';
-// file: lib/scripts/require.js
-
-var require,
- define;
-
-(function () {
- var modules = {},
- // Stack of moduleIds currently being built.
- requireStack = [],
- // Map of module ID -> index into requireStack of modules currently being built.
- inProgressModules = {},
- SEPERATOR = ".";
-
-
-
- function build(module) {
- var factory = module.factory,
- localRequire = function (id) {
- var resultantId = id;
- //Its a relative path, so lop off the last portion and add the id (minus "./")
- if (id.charAt(0) === ".") {
- resultantId = module.id.slice(0, module.id.lastIndexOf(SEPERATOR)) + SEPERATOR + id.slice(2);
- }
- return require(resultantId);
- };
- module.exports = {};
- delete module.factory;
- factory(localRequire, module.exports, module);
- return module.exports;
- }
-
- require = function (id) {
- if (!modules[id]) {
- throw "module " + id + " not found";
- } else if (id in inProgressModules) {
- var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
- throw "Cycle in require graph: " + cycle;
- }
- if (modules[id].factory) {
- try {
- inProgressModules[id] = requireStack.length;
- requireStack.push(id);
- return build(modules[id]);
- } finally {
- delete inProgressModules[id];
- requireStack.pop();
- }
- }
- return modules[id].exports;
- };
-
- define = function (id, factory) {
- if (modules[id]) {
- throw "module " + id + " already defined";
- }
-
- modules[id] = {
- id: id,
- factory: factory
- };
- };
-
- define.remove = function (id) {
- delete modules[id];
- };
-
- define.moduleMap = modules;
-})();
-
-//Export for use in node
-if (typeof module === "object" && typeof require === "function") {
- module.exports.require = require;
- module.exports.define = define;
-}
-
-// file: lib/cordova.js
-define("cordova", function(require, exports, module) {
-
-
-var channel = require('cordova/channel');
-
-/**
- * Listen for DOMContentLoaded and notify our channel subscribers.
- */
-document.addEventListener('DOMContentLoaded', function() {
- channel.onDOMContentLoaded.fire();
-}, false);
-if (document.readyState == 'complete' || document.readyState == 'interactive') {
- channel.onDOMContentLoaded.fire();
-}
-
-/**
- * Intercept calls to addEventListener + removeEventListener and handle deviceready,
- * resume, and pause events.
- */
-var m_document_addEventListener = document.addEventListener;
-var m_document_removeEventListener = document.removeEventListener;
-var m_window_addEventListener = window.addEventListener;
-var m_window_removeEventListener = window.removeEventListener;
-
-/**
- * Houses custom event handlers to intercept on document + window event listeners.
- */
-var documentEventHandlers = {},
- windowEventHandlers = {};
-
-document.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof documentEventHandlers[e] != 'undefined') {
- documentEventHandlers[e].subscribe(handler);
- } else {
- m_document_addEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof windowEventHandlers[e] != 'undefined') {
- windowEventHandlers[e].subscribe(handler);
- } else {
- m_window_addEventListener.call(window, evt, handler, capture);
- }
-};
-
-document.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubscribing from an event that is handled by a plugin
- if (typeof documentEventHandlers[e] != "undefined") {
- documentEventHandlers[e].unsubscribe(handler);
- } else {
- m_document_removeEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubscribing from an event that is handled by a plugin
- if (typeof windowEventHandlers[e] != "undefined") {
- windowEventHandlers[e].unsubscribe(handler);
- } else {
- m_window_removeEventListener.call(window, evt, handler, capture);
- }
-};
-
-function createEvent(type, data) {
- var event = document.createEvent('Events');
- event.initEvent(type, false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- }
- return event;
-}
-
-if(typeof window.console === "undefined") {
- window.console = {
- log:function(){}
- };
-}
-
-var cordova = {
- define:define,
- require:require,
- /**
- * Methods to add/remove your own addEventListener hijacking on document + window.
- */
- addWindowEventHandler:function(event) {
- return (windowEventHandlers[event] = channel.create(event));
- },
- addStickyDocumentEventHandler:function(event) {
- return (documentEventHandlers[event] = channel.createSticky(event));
- },
- addDocumentEventHandler:function(event) {
- return (documentEventHandlers[event] = channel.create(event));
- },
- removeWindowEventHandler:function(event) {
- delete windowEventHandlers[event];
- },
- removeDocumentEventHandler:function(event) {
- delete documentEventHandlers[event];
- },
- /**
- * Retrieve original event handlers that were replaced by Cordova
- *
- * @return object
- */
- getOriginalHandlers: function() {
- return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
- 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
- },
- /**
- * Method to fire event from native code
- * bNoDetach is required for events which cause an exception which needs to be caught in native code
- */
- fireDocumentEvent: function(type, data, bNoDetach) {
- var evt = createEvent(type, data);
- if (typeof documentEventHandlers[type] != 'undefined') {
- if( bNoDetach ) {
- documentEventHandlers[type].fire(evt);
- }
- else {
- setTimeout(function() {
- // Fire deviceready on listeners that were registered before cordova.js was loaded.
- if (type == 'deviceready') {
- document.dispatchEvent(evt);
- }
- documentEventHandlers[type].fire(evt);
- }, 0);
- }
- } else {
- document.dispatchEvent(evt);
- }
- },
- fireWindowEvent: function(type, data) {
- var evt = createEvent(type,data);
- if (typeof windowEventHandlers[type] != 'undefined') {
- setTimeout(function() {
- windowEventHandlers[type].fire(evt);
- }, 0);
- } else {
- window.dispatchEvent(evt);
- }
- },
-
- /**
- * Plugin callback mechanism.
- */
- // Randomize the starting callbackId to avoid collisions after refreshing or navigating.
- // This way, it's very unlikely that any new callback would get the same callbackId as an old callback.
- callbackId: Math.floor(Math.random() * 2000000000),
- callbacks: {},
- callbackStatus: {
- NO_RESULT: 0,
- OK: 1,
- CLASS_NOT_FOUND_EXCEPTION: 2,
- ILLEGAL_ACCESS_EXCEPTION: 3,
- INSTANTIATION_EXCEPTION: 4,
- MALFORMED_URL_EXCEPTION: 5,
- IO_EXCEPTION: 6,
- INVALID_ACTION: 7,
- JSON_EXCEPTION: 8,
- ERROR: 9
- },
-
- /**
- * Called by native code when returning successful result from an action.
- */
- callbackSuccess: function(callbackId, args) {
- try {
- cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
- } catch (e) {
- console.log("Error in error callback: " + callbackId + " = "+e);
- }
- },
-
- /**
- * Called by native code when returning error result from an action.
- */
- callbackError: function(callbackId, args) {
- // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
- // Derive success from status.
- try {
- cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
- } catch (e) {
- console.log("Error in error callback: " + callbackId + " = "+e);
- }
- },
-
- /**
- * Called by native code when returning the result from an action.
- */
- callbackFromNative: function(callbackId, success, status, args, keepCallback) {
- var callback = cordova.callbacks[callbackId];
- if (callback) {
- if (success && status == cordova.callbackStatus.OK) {
- callback.success && callback.success.apply(null, args);
- } else if (!success) {
- callback.fail && callback.fail.apply(null, args);
- }
-
- // Clear callback if not expecting any more results
- if (!keepCallback) {
- delete cordova.callbacks[callbackId];
- }
- }
- },
- addConstructor: function(func) {
- channel.onCordovaReady.subscribe(function() {
- try {
- func();
- } catch(e) {
- console.log("Failed to run constructor: " + e);
- }
- });
- }
-};
-
-// Register pause, resume and deviceready channels as events on document.
-channel.onPause = cordova.addDocumentEventHandler('pause');
-channel.onResume = cordova.addDocumentEventHandler('resume');
-channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
-
-module.exports = cordova;
-
-});
-
-// file: lib/common/argscheck.js
-define("cordova/argscheck", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var utils = require('cordova/utils');
-
-var moduleExports = module.exports;
-
-var typeMap = {
- 'A': 'Array',
- 'D': 'Date',
- 'N': 'Number',
- 'S': 'String',
- 'F': 'Function',
- 'O': 'Object'
-};
-
-function extractParamName(callee, argIndex) {
- return (/.*?\((.*?)\)/).exec(callee)[1].split(', ')[argIndex];
-}
-
-function checkArgs(spec, functionName, args, opt_callee) {
- if (!moduleExports.enableChecks) {
- return;
- }
- var errMsg = null;
- var typeName;
- for (var i = 0; i < spec.length; ++i) {
- var c = spec.charAt(i),
- cUpper = c.toUpperCase(),
- arg = args[i];
- // Asterix means allow anything.
- if (c == '*') {
- continue;
- }
- typeName = utils.typeName(arg);
- if ((arg === null || arg === undefined) && c == cUpper) {
- continue;
- }
- if (typeName != typeMap[cUpper]) {
- errMsg = 'Expected ' + typeMap[cUpper];
- break;
- }
- }
- if (errMsg) {
- errMsg += ', but got ' + typeName + '.';
- errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
- // Don't log when running jake test.
- if (typeof jasmine == 'undefined') {
- console.error(errMsg);
- }
- throw TypeError(errMsg);
- }
-}
-
-function getValue(value, defaultValue) {
- return value === undefined ? defaultValue : value;
-}
-
-moduleExports.checkArgs = checkArgs;
-moduleExports.getValue = getValue;
-moduleExports.enableChecks = true;
-
-
-});
-
-// file: lib/common/builder.js
-define("cordova/builder", function(require, exports, module) {
-
-var utils = require('cordova/utils');
-
-function each(objects, func, context) {
- for (var prop in objects) {
- if (objects.hasOwnProperty(prop)) {
- func.apply(context, [objects[prop], prop]);
- }
- }
-}
-
-function clobber(obj, key, value) {
- exports.replaceHookForTesting(obj, key);
- obj[key] = value;
- // Getters can only be overridden by getters.
- if (obj[key] !== value) {
- utils.defineGetter(obj, key, function() {
- return value;
- });
- }
-}
-
-function assignOrWrapInDeprecateGetter(obj, key, value, message) {
- if (message) {
- utils.defineGetter(obj, key, function() {
- console.log(message);
- delete obj[key];
- clobber(obj, key, value);
- return value;
- });
- } else {
- clobber(obj, key, value);
- }
-}
-
-function include(parent, objects, clobber, merge) {
- each(objects, function (obj, key) {
- try {
- var result = obj.path ? require(obj.path) : {};
-
- if (clobber) {
- // Clobber if it doesn't exist.
- if (typeof parent[key] === 'undefined') {
- assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
- } else if (typeof obj.path !== 'undefined') {
- // If merging, merge properties onto parent, otherwise, clobber.
- if (merge) {
- recursiveMerge(parent[key], result);
- } else {
- assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
- }
- }
- result = parent[key];
- } else {
- // Overwrite if not currently defined.
- if (typeof parent[key] == 'undefined') {
- assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
- } else {
- // Set result to what already exists, so we can build children into it if they exist.
- result = parent[key];
- }
- }
-
- if (obj.children) {
- include(result, obj.children, clobber, merge);
- }
- } catch(e) {
- utils.alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
- }
- });
-}
-
-/**
- * Merge properties from one object onto another recursively. Properties from
- * the src object will overwrite existing target property.
- *
- * @param target Object to merge properties into.
- * @param src Object to merge properties from.
- */
-function recursiveMerge(target, src) {
- for (var prop in src) {
- if (src.hasOwnProperty(prop)) {
- if (target.prototype && target.prototype.constructor === target) {
- // If the target object is a constructor override off prototype.
- clobber(target.prototype, prop, src[prop]);
- } else {
- if (typeof src[prop] === 'object' && typeof target[prop] === 'object') {
- recursiveMerge(target[prop], src[prop]);
- } else {
- clobber(target, prop, src[prop]);
- }
- }
- }
- }
-}
-
-exports.buildIntoButDoNotClobber = function(objects, target) {
- include(target, objects, false, false);
-};
-exports.buildIntoAndClobber = function(objects, target) {
- include(target, objects, true, false);
-};
-exports.buildIntoAndMerge = function(objects, target) {
- include(target, objects, true, true);
-};
-exports.recursiveMerge = recursiveMerge;
-exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
-exports.replaceHookForTesting = function() {};
-
-});
-
-// file: lib/common/channel.js
-define("cordova/channel", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- nextGuid = 1;
-
-/**
- * Custom pub-sub "channel" that can have functions subscribed to it
- * This object is used to define and control firing of events for
- * cordova initialization, as well as for custom events thereafter.
- *
- * The order of events during page load and Cordova startup is as follows:
- *
- * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
- * onNativeReady* Internal event that indicates the Cordova native side is ready.
- * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
- * onCordovaInfoReady* Internal event fired when device properties are available.
- * onCordovaConnectionReady* Internal event fired when the connection property has been set.
- * onDeviceReady* User event fired to indicate that Cordova is ready
- * onResume User event fired to indicate a start/resume lifecycle event
- * onPause User event fired to indicate a pause lifecycle event
- * onDestroy* Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
- *
- * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
- * All listeners that subscribe after the event is fired will be executed right away.
- *
- * The only Cordova events that user code should register for are:
- * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
- * pause App has moved to background
- * resume App has returned to foreground
- *
- * Listeners can be registered as:
- * document.addEventListener("deviceready", myDeviceReadyListener, false);
- * document.addEventListener("resume", myResumeListener, false);
- * document.addEventListener("pause", myPauseListener, false);
- *
- * The DOM lifecycle events should be used for saving and restoring state
- * window.onload
- * window.onunload
- *
- */
-
-/**
- * Channel
- * @constructor
- * @param type String the channel name
- */
-var Channel = function(type, sticky) {
- this.type = type;
- // Map of guid -> function.
- this.handlers = {};
- // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
- this.state = sticky ? 1 : 0;
- // Used in sticky mode to remember args passed to fire().
- this.fireArgs = null;
- // Used by onHasSubscribersChange to know if there are any listeners.
- this.numHandlers = 0;
- // Function that is called when the first listener is subscribed, or when
- // the last listener is unsubscribed.
- this.onHasSubscribersChange = null;
-},
- channel = {
- /**
- * Calls the provided function only after all of the channels specified
- * have been fired. All channels must be sticky channels.
- */
- join: function(h, c) {
- var len = c.length,
- i = len,
- f = function() {
- if (!(--i)) h();
- };
- for (var j=0; j<len; j++) {
- if (c[j].state === 0) {
- throw Error('Can only use join with sticky channels.');
- }
- c[j].subscribe(f);
- }
- if (!len) h();
- },
- create: function(type) {
- return channel[type] = new Channel(type, false);
- },
- createSticky: function(type) {
- return channel[type] = new Channel(type, true);
- },
-
- /**
- * cordova Channels that must fire before "deviceready" is fired.
- */
- deviceReadyChannelsArray: [],
- deviceReadyChannelsMap: {},
-
- /**
- * Indicate that a feature needs to be initialized before it is ready to be used.
- * This holds up Cordova's "deviceready" event until the feature has been initialized
- * and Cordova.initComplete(feature) is called.
- *
- * @param feature {String} The unique feature name
- */
- waitForInitialization: function(feature) {
- if (feature) {
- var c = channel[feature] || this.createSticky(feature);
- this.deviceReadyChannelsMap[feature] = c;
- this.deviceReadyChannelsArray.push(c);
- }
- },
-
- /**
- * Indicate that initialization code has completed and the feature is ready to be used.
- *
- * @param feature {String} The unique feature name
- */
- initializationComplete: function(feature) {
- var c = this.deviceReadyChannelsMap[feature];
- if (c) {
- c.fire();
- }
- }
- };
-
-function forceFunction(f) {
- if (typeof f != 'function') throw "Function required as first argument!";
-}
-
-/**
- * Subscribes the given function to the channel. Any time that
- * Channel.fire is called so too will the function.
- * Optionally specify an execution context for the function
- * and a guid that can be used to stop subscribing to the channel.
- * Returns the guid.
- */
-Channel.prototype.subscribe = function(f, c) {
- // need a function to call
- forceFunction(f);
- if (this.state == 2) {
- f.apply(c || this, this.fireArgs);
- return;
- }
-
- var func = f,
- guid = f.observer_guid;
- if (typeof c == "object") { func = utils.close(c, f); }
-
- if (!guid) {
- // first time any channel has seen this subscriber
- guid = '' + nextGuid++;
- }
- func.observer_guid = guid;
- f.observer_guid = guid;
-
- // Don't add the same handler more than once.
- if (!this.handlers[guid]) {
- this.handlers[guid] = func;
- this.numHandlers++;
- if (this.numHandlers == 1) {
- this.onHasSubscribersChange && this.onHasSubscribersChange();
- }
- }
-};
-
-/**
- * Unsubscribes the function with the given guid from the channel.
- */
-Channel.prototype.unsubscribe = function(f) {
- // need a function to unsubscribe
- forceFunction(f);
-
- var guid = f.observer_guid,
- handler = this.handlers[guid];
- if (handler) {
- delete this.handlers[guid];
- this.numHandlers--;
- if (this.numHandlers === 0) {
- this.onHasSubscribersChange && this.onHasSubscribersChange();
- }
- }
-};
-
-/**
- * Calls all functions subscribed to this channel.
- */
-Channel.prototype.fire = function(e) {
- var fail = false,
- fireArgs = Array.prototype.slice.call(arguments);
- // Apply stickiness.
- if (this.state == 1) {
- this.state = 2;
- this.fireArgs = fireArgs;
- }
- if (this.numHandlers) {
- // Copy the values first so that it is safe to modify it from within
- // callbacks.
- var toCall = [];
- for (var item in this.handlers) {
- toCall.push(this.handlers[item]);
- }
- for (var i = 0; i < toCall.length; ++i) {
- toCall[i].apply(this, fireArgs);
- }
- if (this.state == 2 && this.numHandlers) {
- this.numHandlers = 0;
- this.handlers = {};
- this.onHasSubscribersChange && this.onHasSubscribersChange();
- }
- }
-};
-
-
-// defining them here so they are ready super fast!
-// DOM event that is received when the web page is loaded and parsed.
-channel.createSticky('onDOMContentLoaded');
-
-// Event to indicate the Cordova native side is ready.
-channel.createSticky('onNativeReady');
-
-// Event to indicate that all Cordova JavaScript objects have been created
-// and it's time to run plugin constructors.
-channel.createSticky('onCordovaReady');
-
-// Event to indicate that device properties are available
-channel.createSticky('onCordovaInfoReady');
-
-// Event to indicate that the connection property has been set.
-channel.createSticky('onCordovaConnectionReady');
-
-// Event to indicate that all automatically loaded JS plugins are loaded and ready.
-channel.createSticky('onPluginsReady');
-
-// Event to indicate that Cordova is ready
-channel.createSticky('onDeviceReady');
-
-// Event to indicate a resume lifecycle event
-channel.create('onResume');
-
-// Event to indicate a pause lifecycle event
-channel.create('onPause');
-
-// Event to indicate a destroy lifecycle event
-channel.createSticky('onDestroy');
-
-// Channels that must fire before "deviceready" is fired.
-channel.waitForInitialization('onCordovaReady');
-channel.waitForInitialization('onCordovaConnectionReady');
-channel.waitForInitialization('onDOMContentLoaded');
-
-module.exports = channel;
-
-});
-
-// file: lib/common/commandProxy.js
-define("cordova/commandProxy", function(require, exports, module) {
-
-
-// internal map of proxy function
-var CommandProxyMap = {};
-
-module.exports = {
-
- // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
- add:function(id,proxyObj) {
- console.log("adding proxy for " + id);
- CommandProxyMap[id] = proxyObj;
- return proxyObj;
- },
-
- // cordova.commandProxy.remove("Accelerometer");
- remove:function(id) {
- var proxy = CommandProxyMap[id];
- delete CommandProxyMap[id];
- CommandProxyMap[id] = null;
- return proxy;
- },
-
- get:function(service,action) {
- return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
- }
-};
-});
-
-// file: lib/ios/exec.js
-define("cordova/exec", function(require, exports, module) {
-
-/**
- * Creates a gap bridge iframe used to notify the native code about queued
- * commands.
- *
- * @private
- */
-var cordova = require('cordova'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- jsToNativeModes = {
- IFRAME_NAV: 0,
- XHR_NO_PAYLOAD: 1,
- XHR_WITH_PAYLOAD: 2,
- XHR_OPTIONAL_PAYLOAD: 3
- },
- bridgeMode,
- execIframe,
- execXhr,
- requestCount = 0,
- vcHeaderValue = null,
- commandQueue = [], // Contains pending JS->Native messages.
- isInContextOfEvalJs = 0;
-
-function createExecIframe() {
- var iframe = document.createElement("iframe");
- iframe.style.display = 'none';
- document.body.appendChild(iframe);
- return iframe;
-}
-
-function shouldBundleCommandJson() {
- if (bridgeMode == jsToNativeModes.XHR_WITH_PAYLOAD) {
- return true;
- }
- if (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD) {
- var payloadLength = 0;
- for (var i = 0; i < commandQueue.length; ++i) {
- payloadLength += commandQueue[i].length;
- }
- // The value here was determined using the benchmark within CordovaLibApp on an iPad 3.
- return payloadLength < 4500;
- }
- return false;
-}
-
-function massageArgsJsToNative(args) {
- if (!args || utils.typeName(args) != 'Array') {
- return args;
- }
- var ret = [];
- var encodeArrayBufferAs8bitString = function(ab) {
- return String.fromCharCode.apply(null, new Uint8Array(ab));
- };
- var encodeArrayBufferAsBase64 = function(ab) {
- return window.btoa(encodeArrayBufferAs8bitString(ab));
- };
- args.forEach(function(arg, i) {
- if (utils.typeName(arg) == 'ArrayBuffer') {
- ret.push({
- 'CDVType': 'ArrayBuffer',
- 'data': encodeArrayBufferAsBase64(arg)
- });
- } else {
- ret.push(arg);
- }
- });
- return ret;
-}
-
-function massageMessageNativeToJs(message) {
- if (message.CDVType == 'ArrayBuffer') {
- var stringToArrayBuffer = function(str) {
- var ret = new Uint8Array(str.length);
- for (var i = 0; i < str.length; i++) {
- ret[i] = str.charCodeAt(i);
- }
- return ret.buffer;
- };
- var base64ToArrayBuffer = function(b64) {
- return stringToArrayBuffer(atob(b64));
- };
- message = base64ToArrayBuffer(message.data);
- }
- return message;
-}
-
-function convertMessageToArgsNativeToJs(message) {
- var args = [];
- if (!message || !message.hasOwnProperty('CDVType')) {
- args.push(message);
- } else if (message.CDVType == 'MultiPart') {
- message.messages.forEach(function(e) {
- args.push(massageMessageNativeToJs(e));
- });
- } else {
- args.push(massageMessageNativeToJs(message));
- }
- return args;
-}
-
-function iOSExec() {
- // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices.
- // XHR mode's main advantage is working around a bug in -webkit-scroll, which
- // doesn't exist in 4.X devices anyways.
- if (bridgeMode === undefined) {
- bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_NO_PAYLOAD : jsToNativeModes.IFRAME_NAV;
- }
-
- var successCallback, failCallback, service, action, actionArgs, splitCommand;
- var callbackId = null;
- if (typeof arguments[0] !== "string") {
- // FORMAT ONE
- successCallback = arguments[0];
- failCallback = arguments[1];
- service = arguments[2];
- action = arguments[3];
- actionArgs = arguments[4];
-
- // Since we need to maintain backwards compatibility, we have to pass
- // an invalid callbackId even if no callback was provided since plugins
- // will be expecting it. The Cordova.exec() implementation allocates
- // an invalid callbackId and passes it even if no callbacks were given.
- callbackId = 'INVALID';
- } else {
- // FORMAT TWO, REMOVED
- try {
- splitCommand = arguments[0].split(".");
- action = splitCommand.pop();
- service = splitCommand.join(".");
- actionArgs = Array.prototype.splice.call(arguments, 1);
-
- console.log('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' +
- "cordova.exec(null, null, \"" + service + "\", \"" + action + "\"," + JSON.stringify(actionArgs) + ");"
- );
- return;
- } catch (e) {
- }
- }
-
- // Register the callbacks and add the callbackId to the positional
- // arguments if given.
- if (successCallback || failCallback) {
- callbackId = service + cordova.callbackId++;
- cordova.callbacks[callbackId] =
- {success:successCallback, fail:failCallback};
- }
-
- actionArgs = massageArgsJsToNative(actionArgs);
-
- var command = [callbackId, service, action, actionArgs];
-
- // Stringify and queue the command. We stringify to command now to
- // effectively clone the command arguments in case they are mutated before
- // the command is executed.
- commandQueue.push(JSON.stringify(command));
-
- // If we're in the context of a stringByEvaluatingJavaScriptFromString call,
- // then the queue will be flushed when it returns; no need for a poke.
- // Also, if there is already a command in the queue, then we've already
- // poked the native side, so there is no reason to do so again.
- if (!isInContextOfEvalJs && commandQueue.length == 1) {
- if (bridgeMode != jsToNativeModes.IFRAME_NAV) {
- // This prevents sending an XHR when there is already one being sent.
- // This should happen only in rare circumstances (refer to unit tests).
- if (execXhr && execXhr.readyState != 4) {
- execXhr = null;
- }
- // Re-using the XHR improves exec() performance by about 10%.
- execXhr = execXhr || new XMLHttpRequest();
- // Changing this to a GET will make the XHR reach the URIProtocol on 4.2.
- // For some reason it still doesn't work though...
- // Add a timestamp to the query param to prevent caching.
- execXhr.open('HEAD', "/!gap_exec?" + (+new Date()), true);
- if (!vcHeaderValue) {
- vcHeaderValue = /.*\((.*)\)/.exec(navigator.userAgent)[1];
- }
- execXhr.setRequestHeader('vc', vcHeaderValue);
- execXhr.setRequestHeader('rc', ++requestCount);
- if (shouldBundleCommandJson()) {
- execXhr.setRequestHeader('cmds', iOSExec.nativeFetchMessages());
- }
- execXhr.send(null);
- } else {
- execIframe = execIframe || createExecIframe();
- execIframe.src = "gap://ready";
- }
- }
-}
-
-iOSExec.jsToNativeModes = jsToNativeModes;
-
-iOSExec.setJsToNativeBridgeMode = function(mode) {
- // Remove the iFrame since it may be no longer required, and its existence
- // can trigger browser bugs.
- // https://issues.apache.org/jira/browse/CB-593
- if (execIframe) {
- execIframe.parentNode.removeChild(execIframe);
- execIframe = null;
- }
- bridgeMode = mode;
-};
-
-iOSExec.nativeFetchMessages = function() {
- // Each entry in commandQueue is a JSON string already.
- if (!commandQueue.length) {
- return '';
- }
- var json = '[' + commandQueue.join(',') + ']';
- commandQueue.length = 0;
- return json;
-};
-
-iOSExec.nativeCallback = function(callbackId, status, message, keepCallback) {
- return iOSExec.nativeEvalAndFetch(function() {
- var success = status === 0 || status === 1;
- var args = convertMessageToArgsNativeToJs(message);
- cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
- });
-};
-
-iOSExec.nativeEvalAndFetch = function(func) {
- // This shouldn't be nested, but better to be safe.
- isInContextOfEvalJs++;
- try {
- func();
- return iOSExec.nativeFetchMessages();
- } finally {
- isInContextOfEvalJs--;
- }
-};
-
-module.exports = iOSExec;
-
-});
-
-// file: lib/common/modulemapper.js
-define("cordova/modulemapper", function(require, exports, module) {
-
-var builder = require('cordova/builder'),
- moduleMap = define.moduleMap,
- symbolList,
- deprecationMap;
-
-exports.reset = function() {
- symbolList = [];
- deprecationMap = {};
-};
-
-function addEntry(strategy, moduleName, symbolPath, opt_deprecationMessage) {
- if (!(moduleName in moduleMap)) {
- throw new Error('Module ' + moduleName + ' does not exist.');
- }
- symbolList.push(strategy, moduleName, symbolPath);
- if (opt_deprecationMessage) {
- deprecationMap[symbolPath] = opt_deprecationMessage;
- }
-}
-
-// Note: Android 2.3 does have Function.bind().
-exports.clobbers = function(moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-exports.merges = function(moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-exports.defaults = function(moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-function prepareNamespace(symbolPath, context) {
- if (!symbolPath) {
- return context;
- }
- var parts = symbolPath.split('.');
- var cur = context;
- for (var i = 0, part; part = parts[i]; ++i) {
- cur = cur[part] = cur[part] || {};
- }
- return cur;
-}
-
-exports.mapModules = function(context) {
- var origSymbols = {};
- context.CDV_origSymbols = origSymbols;
- for (var i = 0, len = symbolList.length; i < len; i += 3) {
- var strategy = symbolList[i];
- var moduleName = symbolList[i + 1];
- var symbolPath = symbolList[i + 2];
- var lastDot = symbolPath.lastIndexOf('.');
- var namespace = symbolPath.substr(0, lastDot);
- var lastName = symbolPath.substr(lastDot + 1);
-
- var module = require(moduleName);
- var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
- var parentObj = prepareNamespace(namespace, context);
- var target = parentObj[lastName];
-
- if (strategy == 'm' && target) {
- builder.recursiveMerge(target, module);
- } else if ((strategy == 'd' && !target) || (strategy != 'd')) {
- if (!(symbolPath in origSymbols)) {
- origSymbols[symbolPath] = target;
- }
- builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
- }
- }
-};
-
-exports.getOriginalSymbol = function(context, symbolPath) {
- var origSymbols = context.CDV_origSymbols;
- if (origSymbols && (symbolPath in origSymbols)) {
- return origSymbols[symbolPath];
- }
- var parts = symbolPath.split('.');
- var obj = context;
- for (var i = 0; i < parts.length; ++i) {
- obj = obj && obj[parts[i]];
- }
- return obj;
-};
-
-exports.loadMatchingModules = function(matchingRegExp) {
- for (var k in moduleMap) {
- if (matchingRegExp.exec(k)) {
- require(k);
- }
- }
-};
-
-exports.reset();
-
-
-});
-
-// file: lib/ios/platform.js
-define("cordova/platform", function(require, exports, module) {
-
-module.exports = {
- id: "ios",
- initialize:function() {
- var modulemapper = require('cordova/modulemapper');
-
- modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
- modulemapper.mapModules(window);
- }
-};
-
-
-});
-
-// file: lib/common/plugin/Acceleration.js
-define("cordova/plugin/Acceleration", function(require, exports, module) {
-
-var Acceleration = function(x, y, z, timestamp) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = timestamp || (new Date()).getTime();
-};
-
-module.exports = Acceleration;
-
-});
-
-// file: lib/common/plugin/Camera.js
-define("cordova/plugin/Camera", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- Camera = require('cordova/plugin/CameraConstants'),
- CameraPopoverHandle = require('cordova/plugin/CameraPopoverHandle');
-
-var cameraExport = {};
-
-// Tack on the Camera Constants to the base camera plugin.
-for (var key in Camera) {
- cameraExport[key] = Camera[key];
-}
-
-/**
- * Gets a picture from source defined by "options.sourceType", and returns the
- * image as defined by the "options.destinationType" option.
-
- * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
- *
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @param {Object} options
- */
-cameraExport.getPicture = function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
- options = options || {};
- var getValue = argscheck.getValue;
-
- var quality = getValue(options.quality, 50);
- var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
- var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
- var targetWidth = getValue(options.targetWidth, -1);
- var targetHeight = getValue(options.targetHeight, -1);
- var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
- var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
- var allowEdit = !!options.allowEdit;
- var correctOrientation = !!options.correctOrientation;
- var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
- var popoverOptions = getValue(options.popoverOptions, null);
- var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
-
- var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
- mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
-
- exec(successCallback, errorCallback, "Camera", "takePicture", args);
- return new CameraPopoverHandle();
-};
-
-cameraExport.cleanup = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "Camera", "cleanup", []);
-};
-
-module.exports = cameraExport;
-
-});
-
-// file: lib/common/plugin/CameraConstants.js
-define("cordova/plugin/CameraConstants", function(require, exports, module) {
-
-module.exports = {
- DestinationType:{
- DATA_URL: 0, // Return base64 encoded string
- FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android)
- NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS)
- },
- EncodingType:{
- JPEG: 0, // Return JPEG encoded image
- PNG: 1 // Return PNG encoded image
- },
- MediaType:{
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
- ALLMEDIA : 2 // allow selection from all media types
- },
- PictureSourceType:{
- PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
- CAMERA : 1, // Take picture from camera
- SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
- },
- PopoverArrowDirection:{
- ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants to specify arrow location on popover
- ARROW_DOWN : 2,
- ARROW_LEFT : 4,
- ARROW_RIGHT : 8,
- ARROW_ANY : 15
- },
- Direction:{
- BACK: 0,
- FRONT: 1
- }
-};
-
-});
-
-// file: lib/ios/plugin/CameraPopoverHandle.js
-define("cordova/plugin/CameraPopoverHandle", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * A handle to an image picker popover.
- */
-var CameraPopoverHandle = function() {
- this.setPosition = function(popoverOptions) {
- var args = [ popoverOptions ];
- exec(null, null, "Camera", "repositionPopover", args);
- };
-};
-
-module.exports = CameraPopoverHandle;
-
-});
-
-// file: lib/common/plugin/CameraPopoverOptions.js
-define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
-
-var Camera = require('cordova/plugin/CameraConstants');
-
-/**
- * Encapsulates options for iOS Popover image picker
- */
-var CameraPopoverOptions = function(x,y,width,height,arrowDir){
- // information of rectangle that popover should be anchored to
- this.x = x || 0;
- this.y = y || 32;
- this.width = width || 320;
- this.height = height || 480;
- // The direction of the popover arrow
- this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
-};
-
-module.exports = CameraPopoverOptions;
-
-});
-
-// file: lib/common/plugin/CaptureAudioOptions.js
-define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureAudioOptions;
-
-});
-
-// file: lib/common/plugin/CaptureError.js
-define("cordova/plugin/CaptureError", function(require, exports, module) {
-
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(c) {
- this.code = c || null;
-};
-
-// Camera or microphone failed to capture image or sound.
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-// Camera application or audio capture application is currently serving other capture request.
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-// Invalid use of the API (e.g. limit parameter has value less than one).
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-// User exited camera application or audio capture application before capturing anything.
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-// The requested capture operation is not supported.
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-module.exports = CaptureError;
-
-});
-
-// file: lib/common/plugin/CaptureImageOptions.js
-define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
-};
-
-module.exports = CaptureImageOptions;
-
-});
-
-// file: lib/common/plugin/CaptureVideoOptions.js
-define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureVideoOptions;
-
-});
-
-// file: lib/common/plugin/CompassError.js
-define("cordova/plugin/CompassError", function(require, exports, module) {
-
-/**
- * CompassError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var CompassError = function(err) {
- this.code = (err !== undefined ? err : null);
-};
-
-CompassError.COMPASS_INTERNAL_ERR = 0;
-CompassError.COMPASS_NOT_SUPPORTED = 20;
-
-module.exports = CompassError;
-
-});
-
-// file: lib/common/plugin/CompassHeading.js
-define("cordova/plugin/CompassHeading", function(require, exports, module) {
-
-var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = magneticHeading;
- this.trueHeading = trueHeading;
- this.headingAccuracy = headingAccuracy;
- this.timestamp = timestamp || new Date().getTime();
-};
-
-module.exports = CompassHeading;
-
-});
-
-// file: lib/common/plugin/ConfigurationData.js
-define("cordova/plugin/ConfigurationData", function(require, exports, module) {
-
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-function ConfigurationData() {
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-}
-
-module.exports = ConfigurationData;
-
-});
-
-// file: lib/common/plugin/Connection.js
-define("cordova/plugin/Connection", function(require, exports, module) {
-
-/**
- * Network status
- */
-module.exports = {
- UNKNOWN: "unknown",
- ETHERNET: "ethernet",
- WIFI: "wifi",
- CELL_2G: "2g",
- CELL_3G: "3g",
- CELL_4G: "4g",
- CELL:"cellular",
- NONE: "none"
-};
-
-});
-
-// file: lib/common/plugin/Contact.js
-define("cordova/plugin/Contact", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils');
-
-/**
-* Converts primitives into Complex Object
-* Currently only used for Date fields
-*/
-function convertIn(contact) {
- var value = contact.birthday;
- try {
- contact.birthday = new Date(parseFloat(value));
- } catch (exception){
- console.log("Cordova Contact convertIn error: exception creating date.");
- }
- return contact;
-}
-
-/**
-* Converts Complex objects into primitives
-* Only conversion at present is for Dates.
-**/
-
-function convertOut(contact) {
- var value = contact.birthday;
- if (value !== null) {
- // try to make it a Date object if it is not already
- if (!utils.isDate(value)){
- try {
- value = new Date(value);
- } catch(exception){
- value = null;
- }
- }
- if (utils.isDate(value)){
- value = value.valueOf(); // convert to milliseconds
- }
- contact.birthday = value;
- }
- return contact;
-}
-
-/**
-* Contains information about a single contact.
-* @constructor
-* @param {DOMString} id unique identifier
-* @param {DOMString} displayName
-* @param {ContactName} name
-* @param {DOMString} nickname
-* @param {Array.<ContactField>} phoneNumbers array of phone numbers
-* @param {Array.<ContactField>} emails array of email addresses
-* @param {Array.<ContactAddress>} addresses array of addresses
-* @param {Array.<ContactField>} ims instant messaging user ids
-* @param {Array.<ContactOrganization>} organizations
-* @param {DOMString} birthday contact's birthday
-* @param {DOMString} note user notes about contact
-* @param {Array.<ContactField>} photos
-* @param {Array.<ContactField>} categories
-* @param {Array.<ContactField>} urls contact's web sites
-*/
-var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
- ims, organizations, birthday, note, photos, categories, urls) {
- this.id = id || null;
- this.rawId = null;
- this.displayName = displayName || null;
- this.name = name || null; // ContactName
- this.nickname = nickname || null;
- this.phoneNumbers = phoneNumbers || null; // ContactField[]
- this.emails = emails || null; // ContactField[]
- this.addresses = addresses || null; // ContactAddress[]
- this.ims = ims || null; // ContactField[]
- this.organizations = organizations || null; // ContactOrganization[]
- this.birthday = birthday || null;
- this.note = note || null;
- this.photos = photos || null; // ContactField[]
- this.categories = categories || null; // ContactField[]
- this.urls = urls || null; // ContactField[]
-};
-
-/**
-* Removes contact from device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.remove = function(successCB, errorCB) {
- argscheck.checkArgs('FF', 'Contact.remove', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- if (this.id === null) {
- fail(ContactError.UNKNOWN_ERROR);
- }
- else {
- exec(successCB, fail, "Contacts", "remove", [this.id]);
- }
-};
-
-/**
-* Creates a deep copy of this Contact.
-* With the contact ID set to null.
-* @return copy of this Contact
-*/
-Contact.prototype.clone = function() {
- var clonedContact = utils.clone(this);
- clonedContact.id = null;
- clonedContact.rawId = null;
-
- function nullIds(arr) {
- if (arr) {
- for (var i = 0; i < arr.length; ++i) {
- arr[i].id = null;
- }
- }
- }
-
- // Loop through and clear out any id's in phones, emails, etc.
- nullIds(clonedContact.phoneNumbers);
- nullIds(clonedContact.emails);
- nullIds(clonedContact.addresses);
- nullIds(clonedContact.ims);
- nullIds(clonedContact.organizations);
- nullIds(clonedContact.categories);
- nullIds(clonedContact.photos);
- nullIds(clonedContact.urls);
- return clonedContact;
-};
-
-/**
-* Persists contact to device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.save = function(successCB, errorCB) {
- argscheck.checkArgs('FFO', 'Contact.save', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- var success = function(result) {
- if (result) {
- if (successCB) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCB(convertIn(fullContact));
- }
- }
- else {
- // no Entry object returned
- fail(ContactError.UNKNOWN_ERROR);
- }
- };
- var dupContact = convertOut(utils.clone(this));
- exec(success, fail, "Contacts", "save", [dupContact]);
-};
-
-
-module.exports = Contact;
-
-});
-
-// file: lib/common/plugin/ContactAddress.js
-define("cordova/plugin/ContactAddress", function(require, exports, module) {
-
-/**
-* Contact address.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param formatted // NOTE: not a W3C standard
-* @param streetAddress
-* @param locality
-* @param region
-* @param postalCode
-* @param country
-*/
-
-var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.formatted = formatted || null;
- this.streetAddress = streetAddress || null;
- this.locality = locality || null;
- this.region = region || null;
- this.postalCode = postalCode || null;
- this.country = country || null;
-};
-
-module.exports = ContactAddress;
-
-});
-
-// file: lib/common/plugin/ContactError.js
-define("cordova/plugin/ContactError", function(require, exports, module) {
-
-/**
- * ContactError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var ContactError = function(err) {
- this.code = (typeof err != 'undefined' ? err : null);
-};
-
-/**
- * Error codes
- */
-ContactError.UNKNOWN_ERROR = 0;
-ContactError.INVALID_ARGUMENT_ERROR = 1;
-ContactError.TIMEOUT_ERROR = 2;
-ContactError.PENDING_OPERATION_ERROR = 3;
-ContactError.IO_ERROR = 4;
-ContactError.NOT_SUPPORTED_ERROR = 5;
-ContactError.PERMISSION_DENIED_ERROR = 20;
-
-module.exports = ContactError;
-
-});
-
-// file: lib/common/plugin/ContactField.js
-define("cordova/plugin/ContactField", function(require, exports, module) {
-
-/**
-* Generic contact field.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param type
-* @param value
-* @param pref
-*/
-var ContactField = function(type, value, pref) {
- this.id = null;
- this.type = (type && type.toString()) || null;
- this.value = (value && value.toString()) || null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
-};
-
-module.exports = ContactField;
-
-});
-
-// file: lib/common/plugin/ContactFindOptions.js
-define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
-
-/**
- * ContactFindOptions.
- * @constructor
- * @param filter used to match contacts against
- * @param multiple boolean used to determine if more than one contact should be returned
- */
-
-var ContactFindOptions = function(filter, multiple) {
- this.filter = filter || '';
- this.multiple = (typeof multiple != 'undefined' ? multiple : false);
-};
-
-module.exports = ContactFindOptions;
-
-});
-
-// file: lib/common/plugin/ContactName.js
-define("cordova/plugin/ContactName", function(require, exports, module) {
-
-/**
-* Contact name.
-* @constructor
-* @param formatted // NOTE: not part of W3C standard
-* @param familyName
-* @param givenName
-* @param middle
-* @param prefix
-* @param suffix
-*/
-var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
- this.formatted = formatted || null;
- this.familyName = familyName || null;
- this.givenName = givenName || null;
- this.middleName = middle || null;
- this.honorificPrefix = prefix || null;
- this.honorificSuffix = suffix || null;
-};
-
-module.exports = ContactName;
-
-});
-
-// file: lib/common/plugin/ContactOrganization.js
-define("cordova/plugin/ContactOrganization", function(require, exports, module) {
-
-/**
-* Contact organization.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param name
-* @param dept
-* @param title
-* @param startDate
-* @param endDate
-* @param location
-* @param desc
-*/
-
-var ContactOrganization = function(pref, type, name, dept, title) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.name = name || null;
- this.department = dept || null;
- this.title = title || null;
-};
-
-module.exports = ContactOrganization;
-
-});
-
-// file: lib/common/plugin/Coordinates.js
-define("cordova/plugin/Coordinates", function(require, exports, module) {
-
-/**
- * This class contains position information.
- * @param {Object} lat
- * @param {Object} lng
- * @param {Object} alt
- * @param {Object} acc
- * @param {Object} head
- * @param {Object} vel
- * @param {Object} altacc
- * @constructor
- */
-var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
- /**
- * The latitude of the position.
- */
- this.latitude = lat;
- /**
- * The longitude of the position,
- */
- this.longitude = lng;
- /**
- * The accuracy of the position.
- */
- this.accuracy = acc;
- /**
- * The altitude of the position.
- */
- this.altitude = (alt !== undefined ? alt : null);
- /**
- * The direction the device is moving at the position.
- */
- this.heading = (head !== undefined ? head : null);
- /**
- * The velocity with which the device is moving at the position.
- */
- this.speed = (vel !== undefined ? vel : null);
-
- if (this.speed === 0 || this.speed === null) {
- this.heading = NaN;
- }
-
- /**
- * The altitude accuracy of the position.
- */
- this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
-};
-
-module.exports = Coordinates;
-
-});
-
-// file: lib/common/plugin/DirectoryEntry.js
-define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileError = require('cordova/plugin/FileError'),
- DirectoryReader = require('cordova/plugin/DirectoryReader');
-
-/**
- * An interface representing a directory on the file system.
- *
- * {boolean} isFile always false (readonly)
- * {boolean} isDirectory always true (readonly)
- * {DOMString} name of the directory, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the directory (readonly)
- * TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
- */
-var DirectoryEntry = function(name, fullPath) {
- DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
-};
-
-utils.extend(DirectoryEntry, Entry);
-
-/**
- * Creates a new DirectoryReader to read entries from this directory
- */
-DirectoryEntry.prototype.createReader = function() {
- return new DirectoryReader(this.fullPath);
-};
-
-/**
- * Creates or looks up a directory
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or exclusively create the directory
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
- var win = successCallback && function(result) {
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
-};
-
-/**
- * Deletes a directory and all of it's contents
- *
- * @param {Function} successCallback is called with no parameters
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
-};
-
-/**
- * Creates or looks up a file
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or exclusively create the file
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
- var win = successCallback && function(result) {
- var FileEntry = require('cordova/plugin/FileEntry');
- var entry = new FileEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
-};
-
-module.exports = DirectoryEntry;
-
-});
-
-// file: lib/common/plugin/DirectoryReader.js
-define("cordova/plugin/DirectoryReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError') ;
-
-/**
- * An interface that lists the files and directories in a directory.
- */
-function DirectoryReader(path) {
- this.path = path || null;
-}
-
-/**
- * Returns a list of entries from a directory.
- *
- * @param {Function} successCallback is called with a list of entries
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var retVal = [];
- for (var i=0; i<result.length; i++) {
- var entry = null;
- if (result[i].isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result[i].isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result[i].isDirectory;
- entry.isFile = result[i].isFile;
- entry.name = result[i].name;
- entry.fullPath = result[i].fullPath;
- retVal.push(entry);
- }
- successCallback(retVal);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "readEntries", [this.path]);
-};
-
-module.exports = DirectoryReader;
-
-});
-
-// file: lib/common/plugin/Entry.js
-define("cordova/plugin/Entry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- Metadata = require('cordova/plugin/Metadata');
-
-/**
- * Represents a file or directory on the local file system.
- *
- * @param isFile
- * {boolean} true if Entry is a file (readonly)
- * @param isDirectory
- * {boolean} true if Entry is a directory (readonly)
- * @param name
- * {DOMString} name of the file or directory, excluding the path
- * leading to it (readonly)
- * @param fullPath
- * {DOMString} the absolute full path to the file or directory
- * (readonly)
- */
-function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
- this.isFile = !!isFile;
- this.isDirectory = !!isDirectory;
- this.name = name || '';
- this.fullPath = fullPath || '';
- this.filesystem = fileSystem || null;
-}
-
-/**
- * Look up the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- */
-Entry.prototype.getMetadata = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
- var success = successCallback && function(lastModified) {
- var metadata = new Metadata(lastModified);
- successCallback(metadata);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- exec(success, fail, "File", "getMetadata", [this.fullPath]);
-};
-
-/**
- * Set the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- * @param metadataObject
- * {Object} keys and values to set
- */
-Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
- argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
- exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
-};
-
-/**
- * Move a file or directory to a new location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to move this entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new DirectoryEntry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Copy a directory to a different location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to copy the entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new Entry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- // success callback
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Return a URL that can be used to identify this entry.
- */
-Entry.prototype.toURL = function() {
- // fullPath attribute contains the full URL
- return this.fullPath;
-};
-
-/**
- * Returns a URI that can be used to identify this entry.
- *
- * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
- * @return uri
- */
-Entry.prototype.toURI = function(mimeType) {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- // fullPath attribute contains the full URI
- return this.toURL();
-};
-
-/**
- * Remove a file or directory. It is an error to attempt to delete a
- * directory that is not empty. It is an error to attempt to delete a
- * root directory of a file system.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.remove = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.remove', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "remove", [this.fullPath]);
-};
-
-/**
- * Look up the parent DirectoryEntry of this entry.
- *
- * @param successCallback {Function} called with the parent DirectoryEntry object
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.getParent = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getParent', arguments);
- var win = successCallback && function(result) {
- var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getParent", [this.fullPath]);
-};
-
-module.exports = Entry;
-
-});
-
-// file: lib/common/plugin/File.js
-define("cordova/plugin/File", function(require, exports, module) {
-
-/**
- * Constructor.
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-
-var File = function(name, fullPath, type, lastModifiedDate, size){
- this.name = name || '';
- this.fullPath = fullPath || null;
- this.type = type || null;
- this.lastModifiedDate = lastModifiedDate || null;
- this.size = size || 0;
-
- // These store the absolute start and end for slicing the file.
- this.start = 0;
- this.end = this.size;
-};
-
-/**
- * Returns a "slice" of the file. Since Cordova Files don't contain the actual
- * content, this really returns a File with adjusted start and end.
- * Slices of slices are supported.
- * start {Number} The index at which to start the slice (inclusive).
- * end {Number} The index at which to end the slice (exclusive).
- */
-File.prototype.slice = function(start, end) {
- var size = this.end - this.start;
- var newStart = 0;
- var newEnd = size;
- if (arguments.length) {
- if (start < 0) {
- newStart = Math.max(size + start, 0);
- } else {
- newStart = Math.min(size, start);
- }
- }
-
- if (arguments.length >= 2) {
- if (end < 0) {
- newEnd = Math.max(size + end, 0);
- } else {
- newEnd = Math.min(end, size);
- }
- }
-
- var newFile = new File(this.name, this.fullPath, this.type, this.lastModifiedData, this.size);
- newFile.start = this.start + newStart;
- newFile.end = this.start + newEnd;
- return newFile;
-};
-
-
-module.exports = File;
-
-});
-
-// file: lib/common/plugin/FileEntry.js
-define("cordova/plugin/FileEntry", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileWriter = require('cordova/plugin/FileWriter'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface representing a file on the file system.
- *
- * {boolean} isFile always true (readonly)
- * {boolean} isDirectory always false (readonly)
- * {DOMString} name of the file, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the file (readonly)
- * {FileSystem} filesystem on which the file resides (readonly)
- */
-var FileEntry = function(name, fullPath) {
- FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
-};
-
-utils.extend(FileEntry, Entry);
-
-/**
- * Creates a new FileWriter associated with the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new FileWriter
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
- this.file(function(filePointer) {
- var writer = new FileWriter(filePointer);
-
- if (writer.fileName === null || writer.fileName === "") {
- errorCallback && errorCallback(new FileError(FileError.INVALID_STATE_ERR));
- } else {
- successCallback && successCallback(writer);
- }
- }, errorCallback);
-};
-
-/**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new File object
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.file = function(successCallback, errorCallback) {
- var win = successCallback && function(f) {
- var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
- successCallback(file);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
-};
-
-
-module.exports = FileEntry;
-
-});
-
-// file: lib/common/plugin/FileError.js
-define("cordova/plugin/FileError", function(require, exports, module) {
-
-/**
- * FileError
- */
-function FileError(error) {
- this.code = error || null;
-}
-
-// File error codes
-// Found in DOMException
-FileError.NOT_FOUND_ERR = 1;
-FileError.SECURITY_ERR = 2;
-FileError.ABORT_ERR = 3;
-
-// Added by File API specification
-FileError.NOT_READABLE_ERR = 4;
-FileError.ENCODING_ERR = 5;
-FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
-FileError.INVALID_STATE_ERR = 7;
-FileError.SYNTAX_ERR = 8;
-FileError.INVALID_MODIFICATION_ERR = 9;
-FileError.QUOTA_EXCEEDED_ERR = 10;
-FileError.TYPE_MISMATCH_ERR = 11;
-FileError.PATH_EXISTS_ERR = 12;
-
-module.exports = FileError;
-
-});
-
-// file: lib/common/plugin/FileReader.js
-define("cordova/plugin/FileReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper'),
- utils = require('cordova/utils'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent'),
- origFileReader = modulemapper.getOriginalSymbol(this, 'FileReader');
-
-/**
- * This class reads the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To read from the SD card, the file name is "sdcard/my_file.txt"
- * @constructor
- */
-var FileReader = function() {
- this._readyState = 0;
- this._error = null;
- this._result = null;
- this._fileName = '';
- this._realReader = origFileReader ? new origFileReader() : {};
-};
-
-// States
-FileReader.EMPTY = 0;
-FileReader.LOADING = 1;
-FileReader.DONE = 2;
-
-utils.defineGetter(FileReader.prototype, 'readyState', function() {
- return this._fileName ? this._readyState : this._realReader.readyState;
-});
-
-utils.defineGetter(FileReader.prototype, 'error', function() {
- return this._fileName ? this._error: this._realReader.error;
-});
-
-utils.defineGetter(FileReader.prototype, 'result', function() {
- return this._fileName ? this._result: this._realReader.result;
-});
-
-function defineEvent(eventName) {
- utils.defineGetterSetter(FileReader.prototype, eventName, function() {
- return this._realReader[eventName] || null;
- }, function(value) {
- this._realReader[eventName] = value;
- });
-}
-defineEvent('onloadstart'); // When the read starts.
-defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
-defineEvent('onload'); // When the read has successfully completed.
-defineEvent('onerror'); // When the read has failed (see errors).
-defineEvent('onloadend'); // When the request has completed (either in success or failure).
-defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method.
-
-function initRead(reader, file) {
- // Already loading something
- if (reader.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- reader._result = null;
- reader._error = null;
- reader._readyState = FileReader.LOADING;
-
- if (typeof file.fullPath == 'string') {
- reader._fileName = file.fullPath;
- } else {
- reader._fileName = '';
- return true;
- }
-
- reader.onloadstart && reader.onloadstart(new ProgressEvent("loadstart", {target:reader}));
-}
-
-/**
- * Abort reading file.
- */
-FileReader.prototype.abort = function() {
- if (origFileReader && !this._fileName) {
- return this._realReader.abort();
- }
- this._result = null;
-
- if (this._readyState == FileReader.DONE || this._readyState == FileReader.EMPTY) {
- return;
- }
-
- this._readyState = FileReader.DONE;
-
- // If abort callback
- if (typeof this.onabort === 'function') {
- this.onabort(new ProgressEvent('abort', {target:this}));
- }
- // If load end callback
- if (typeof this.onloadend === 'function') {
- this.onloadend(new ProgressEvent('loadend', {target:this}));
- }
-};
-
-/**
- * Read text file.
- *
- * @param file {File} File object containing file properties
- * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
- */
-FileReader.prototype.readAsText = function(file, encoding) {
- if (initRead(this, file)) {
- return this._realReader.readAsText(file, encoding);
- }
-
- // Default encoding is UTF-8
- var enc = encoding ? encoding : "UTF-8";
- var me = this;
- var execArgs = [this._fileName, enc, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // null result
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsText", execArgs);
-};
-
-
-/**
- * Read file and return data as a base64 encoded data url.
- * A data url is of the form:
- * data:[<mediatype>][;base64],<data>
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsDataURL = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsDataURL(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsDataURL", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsBinaryString = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsBinaryString(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsBinaryString", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsArrayBuffer = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsArrayBuffer(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsArrayBuffer", execArgs);
-};
-
-module.exports = FileReader;
-
-});
-
-// file: lib/common/plugin/FileSystem.js
-define("cordova/plugin/FileSystem", function(require, exports, module) {
-
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-
-/**
- * An interface representing a file system
- *
- * @constructor
- * {DOMString} name the unique name of the file system (readonly)
- * {DirectoryEntry} root directory of the file system (readonly)
- */
-var FileSystem = function(name, root) {
- this.name = name || null;
- if (root) {
- this.root = new DirectoryEntry(root.name, root.fullPath);
- }
-};
-
-module.exports = FileSystem;
-
-});
-
-// file: lib/common/plugin/FileTransfer.js
-define("cordova/plugin/FileTransfer", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileTransferError = require('cordova/plugin/FileTransferError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-function newProgressEvent(result) {
- var pe = new ProgressEvent();
- pe.lengthComputable = result.lengthComputable;
- pe.loaded = result.loaded;
- pe.total = result.total;
- return pe;
-}
-
-function getBasicAuthHeader(urlString) {
- var header = null;
-
- if (window.btoa) {
- // parse the url using the Location object
- var url = document.createElement('a');
- url.href = urlString;
-
- var credentials = null;
- var protocol = url.protocol + "//";
- var origin = protocol + url.host;
-
- // check whether there are the username:password credentials in the url
- if (url.href.indexOf(origin) !== 0) { // credentials found
- var atIndex = url.href.indexOf("@");
- credentials = url.href.substring(protocol.length, atIndex);
- }
-
- if (credentials) {
- var authHeader = "Authorization";
- var authHeaderValue = "Basic " + window.btoa(credentials);
-
- header = {
- name : authHeader,
- value : authHeaderValue
- };
- }
- }
-
- return header;
-}
-
-var idCounter = 0;
-
-/**
- * FileTransfer uploads a file to a remote server.
- * @constructor
- */
-var FileTransfer = function() {
- this._id = ++idCounter;
- this.onprogress = null; // optional callback
-};
-
-/**
-* Given an absolute file path, uploads a file on the device to a remote server
-* using a multipart HTTP request.
-* @param filePath {String} Full path of the file on the device
-* @param server {String} URL of the server to receive the file
-* @param successCallback (Function} Callback to be invoked when upload has completed
-* @param errorCallback {Function} Callback to be invoked upon error
-* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
-* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
-*/
-FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
- argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments);
- // check for options
- var fileKey = null;
- var fileName = null;
- var mimeType = null;
- var params = null;
- var chunkedMode = true;
- var headers = null;
- var httpMethod = null;
- var basicAuthHeader = getBasicAuthHeader(server);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- if (options) {
- fileKey = options.fileKey;
- fileName = options.fileName;
- mimeType = options.mimeType;
- headers = options.headers;
- httpMethod = options.httpMethod || "POST";
- if (httpMethod.toUpperCase() == "PUT"){
- httpMethod = "PUT";
- } else {
- httpMethod = "POST";
- }
- if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
- chunkedMode = options.chunkedMode;
- }
- if (options.params) {
- params = options.params;
- }
- else {
- params = {};
- }
- }
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- var self = this;
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- self.onprogress(newProgressEvent(result));
- }
- } else {
- successCallback && successCallback(result);
- }
- };
- exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
-};
-
-/**
- * Downloads a file form a given URL and saves it to the specified directory.
- * @param source {String} URL of the server to receive the file
- * @param target {String} Full path of the file on the device
- * @param successCallback (Function} Callback to be invoked when upload has completed
- * @param errorCallback {Function} Callback to be invoked upon error
- * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
- * @param options {FileDownloadOptions} Optional parameters such as headers
- */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) {
- argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
- var self = this;
-
- var basicAuthHeader = getBasicAuthHeader(source);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- var headers = null;
- if (options) {
- headers = options.headers || null;
- }
-
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- return self.onprogress(newProgressEvent(result));
- }
- } else if (successCallback) {
- var entry = null;
- if (result.isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result.isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result.isDirectory;
- entry.isFile = result.isFile;
- entry.name = result.name;
- entry.fullPath = result.fullPath;
- successCallback(entry);
- }
- };
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
-};
-
-/**
- * Aborts the ongoing file transfer on this object. The original error
- * callback for the file transfer will be called if necessary.
- */
-FileTransfer.prototype.abort = function() {
- exec(null, null, 'FileTransfer', 'abort', [this._id]);
-};
-
-module.exports = FileTransfer;
-
-});
-
-// file: lib/common/plugin/FileTransferError.js
-define("cordova/plugin/FileTransferError", function(require, exports, module) {
-
-/**
- * FileTransferError
- * @constructor
- */
-var FileTransferError = function(code, source, target, status, body) {
- this.code = code || null;
- this.source = source || null;
- this.target = target || null;
- this.http_status = status || null;
- this.body = body || null;
-};
-
-FileTransferError.FILE_NOT_FOUND_ERR = 1;
-FileTransferError.INVALID_URL_ERR = 2;
-FileTransferError.CONNECTION_ERR = 3;
-FileTransferError.ABORT_ERR = 4;
-
-module.exports = FileTransferError;
-
-});
-
-// file: lib/common/plugin/FileUploadOptions.js
-define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
-
-/**
- * Options to customize the HTTP request used to upload files.
- * @constructor
- * @param fileKey {String} Name of file request parameter.
- * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
- * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
- * @param params {Object} Object with key: value params to send to the server.
- * @param headers {Object} Keys are header names, values are header values. Multiple
- * headers of the same name are not supported.
- */
-var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) {
- this.fileKey = fileKey || null;
- this.fileName = fileName || null;
- this.mimeType = mimeType || null;
- this.params = params || null;
- this.headers = headers || null;
- this.httpMethod = httpMethod || null;
-};
-
-module.exports = FileUploadOptions;
-
-});
-
-// file: lib/common/plugin/FileUploadResult.js
-define("cordova/plugin/FileUploadResult", function(require, exports, module) {
-
-/**
- * FileUploadResult
- * @constructor
- */
-var FileUploadResult = function() {
- this.bytesSent = 0;
- this.responseCode = null;
- this.response = null;
-};
-
-module.exports = FileUploadResult;
-
-});
-
-// file: lib/common/plugin/FileWriter.js
-define("cordova/plugin/FileWriter", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class writes to the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To write to the SD card, the file name is "sdcard/my_file.txt"
- *
- * @constructor
- * @param file {File} File object containing file properties
- * @param append if true write to the end of the file, otherwise overwrite the file
- */
-var FileWriter = function(file) {
- this.fileName = "";
- this.length = 0;
- if (file) {
- this.fileName = file.fullPath || file;
- this.length = file.size || 0;
- }
- // default is to write at the beginning of the file
- this.position = 0;
-
- this.readyState = 0; // EMPTY
-
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onwritestart = null; // When writing starts
- this.onprogress = null; // While writing the file, and reporting partial file data
- this.onwrite = null; // When the write has successfully completed.
- this.onwriteend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
- this.onerror = null; // When the write has failed (see errors).
-};
-
-// States
-FileWriter.INIT = 0;
-FileWriter.WRITING = 1;
-FileWriter.DONE = 2;
-
-/**
- * Abort writing file.
- */
-FileWriter.prototype.abort = function() {
- // check for invalid state
- if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // set error
- this.error = new FileError(FileError.ABORT_ERR);
-
- this.readyState = FileWriter.DONE;
-
- // If abort callback
- if (typeof this.onabort === "function") {
- this.onabort(new ProgressEvent("abort", {"target":this}));
- }
-
- // If write end callback
- if (typeof this.onwriteend === "function") {
- this.onwriteend(new ProgressEvent("writeend", {"target":this}));
- }
-};
-
-/**
- * Writes data to the file
- *
- * @param data text or blob to be written
- */
-FileWriter.prototype.write = function(data) {
-
- var isBinary = false;
-
- // If we don't have Blob or ArrayBuffer support, don't bother.
- if (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined') {
-
- // Check to see if the incoming data is a blob
- if (data instanceof Blob) {
- var that=this;
- var fileReader = new FileReader();
- fileReader.onload = function() {
- // Call this method again, with the arraybuffer as argument
- FileWriter.prototype.write.call(that, this.result);
- };
- fileReader.readAsArrayBuffer(data);
- return;
- }
-
- // Mark data type for safer transport over the binary bridge
- isBinary = (data instanceof ArrayBuffer);
- }
-
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":me}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // position always increases by bytes written because file would be extended
- me.position += r;
- // The length of the file is now where we are done writing.
-
- me.length = me.position;
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "write", [this.fileName, data, this.position, isBinary]);
-};
-
-/**
- * Moves the file pointer to the location specified.
- *
- * If the offset is a negative number the position of the file
- * pointer is rewound. If the offset is greater than the file
- * size the position is set to the end of the file.
- *
- * @param offset is the location to move the file pointer to.
- */
-FileWriter.prototype.seek = function(offset) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- if (!offset && offset !== 0) {
- return;
- }
-
- // See back from end of file.
- if (offset < 0) {
- this.position = Math.max(offset + this.length, 0);
- }
- // Offset is bigger than file size so set position
- // to the end of the file.
- else if (offset > this.length) {
- this.position = this.length;
- }
- // Offset is between 0 and file size so set the position
- // to start writing.
- else {
- this.position = offset;
- }
-};
-
-/**
- * Truncates the file to the size specified.
- *
- * @param size to chop the file at.
- */
-FileWriter.prototype.truncate = function(size) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":this}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Update the length of the file
- me.length = r;
- me.position = Math.min(me.position, r);
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "truncate", [this.fileName, size]);
-};
-
-module.exports = FileWriter;
-
-});
-
-// file: lib/common/plugin/Flags.js
-define("cordova/plugin/Flags", function(require, exports, module) {
-
-/**
- * Supplies arguments to methods that lookup or create files and directories.
- *
- * @param create
- * {boolean} file or directory if it doesn't exist
- * @param exclusive
- * {boolean} used with create; if true the command will fail if
- * target path exists
- */
-function Flags(create, exclusive) {
- this.create = create || false;
- this.exclusive = exclusive || false;
-}
-
-module.exports = Flags;
-
-});
-
-// file: lib/common/plugin/GlobalizationError.js
-define("cordova/plugin/GlobalizationError", function(require, exports, module) {
-
-
-/**
- * Globalization error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var GlobalizationError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-// Globalization error codes
-GlobalizationError.UNKNOWN_ERROR = 0;
-GlobalizationError.FORMATTING_ERROR = 1;
-GlobalizationError.PARSING_ERROR = 2;
-GlobalizationError.PATTERN_ERROR = 3;
-
-module.exports = GlobalizationError;
-
-});
-
-// file: lib/common/plugin/InAppBrowser.js
-define("cordova/plugin/InAppBrowser", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var channel = require('cordova/channel');
-var modulemapper = require('cordova/modulemapper');
-
-function InAppBrowser() {
- this.channels = {
- 'loadstart': channel.create('loadstart'),
- 'loadstop' : channel.create('loadstop'),
- 'loaderror' : channel.create('loaderror'),
- 'exit' : channel.create('exit')
- };
-}
-
-InAppBrowser.prototype = {
- _eventHandler: function (event) {
- if (event.type in this.channels) {
- this.channels[event.type].fire(event);
- }
- },
- close: function (eventname) {
- exec(null, null, "InAppBrowser", "close", []);
- },
- show: function (eventname) {
- exec(null, null, "InAppBrowser", "show", []);
- },
- addEventListener: function (eventname,f) {
- if (eventname in this.channels) {
- this.channels[eventname].subscribe(f);
- }
- },
- removeEventListener: function(eventname, f) {
- if (eventname in this.channels) {
- this.channels[eventname].unsubscribe(f);
- }
- },
-
- executeScript: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('executeScript requires exactly one of code or file to be specified');
- }
- },
-
- insertCSS: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('insertCSS requires exactly one of code or file to be specified');
- }
- }
-};
-
-module.exports = function(strUrl, strWindowName, strWindowFeatures) {
- var iab = new InAppBrowser();
- var cb = function(eventname) {
- iab._eventHandler(eventname);
- };
-
- // Don't catch calls that write to existing frames (e.g. named iframes).
- if (window.frames && window.frames[strWindowName]) {
- var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
- return origOpenFunc.apply(window, arguments);
- }
-
- exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
- return iab;
-};
-
-
-});
-
-// file: lib/common/plugin/LocalFileSystem.js
-define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Represents a local file system.
- */
-var LocalFileSystem = function() {
-
-};
-
-LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
-LocalFileSystem.PERSISTENT = 1; //persistent
-
-module.exports = LocalFileSystem;
-
-});
-
-// file: lib/common/plugin/Media.js
-define("cordova/plugin/Media", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-var mediaObjects = {};
-
-/**
- * This class provides access to the device media, interfaces to both sound and video
- *
- * @constructor
- * @param src The file name or url to play
- * @param successCallback The callback to be called when the file is done playing or recording.
- * successCallback()
- * @param errorCallback The callback to be called if there is an error.
- * errorCallback(int errorCode) - OPTIONAL
- * @param statusCallback The callback to be called when media status has changed.
- * statusCallback(int statusCode) - OPTIONAL
- */
-var Media = function(src, successCallback, errorCallback, statusCallback) {
- argscheck.checkArgs('SFFF', 'Media', arguments);
- this.id = utils.createUUID();
- mediaObjects[this.id] = this;
- this.src = src;
- this.successCallback = successCallback;
- this.errorCallback = errorCallback;
- this.statusCallback = statusCallback;
- this._duration = -1;
- this._position = -1;
- exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
-};
-
-// Media messages
-Media.MEDIA_STATE = 1;
-Media.MEDIA_DURATION = 2;
-Media.MEDIA_POSITION = 3;
-Media.MEDIA_ERROR = 9;
-
-// Media states
-Media.MEDIA_NONE = 0;
-Media.MEDIA_STARTING = 1;
-Media.MEDIA_RUNNING = 2;
-Media.MEDIA_PAUSED = 3;
-Media.MEDIA_STOPPED = 4;
-Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"];
-
-// "static" function to return existing objs.
-Media.get = function(id) {
- return mediaObjects[id];
-};
-
-/**
- * Start or resume playing audio file.
- */
-Media.prototype.play = function(options) {
- exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
-};
-
-/**
- * Stop playing audio file.
- */
-Media.prototype.stop = function() {
- var me = this;
- exec(function() {
- me._position = 0;
- }, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
-};
-
-/**
- * Seek or jump to a new time in the track..
- */
-Media.prototype.seekTo = function(milliseconds) {
- var me = this;
- exec(function(p) {
- me._position = p;
- }, this.errorCallback, "Media", "seekToAudio", [this.id, milliseconds]);
-};
-
-/**
- * Pause playing audio file.
- */
-Media.prototype.pause = function() {
- exec(null, this.errorCallback, "Media", "pausePlayingAudio", [this.id]);
-};
-
-/**
- * Get duration of an audio file.
- * The duration is only set for audio that is playing, paused or stopped.
- *
- * @return duration or -1 if not known.
- */
-Media.prototype.getDuration = function() {
- return this._duration;
-};
-
-/**
- * Get position of audio.
- */
-Media.prototype.getCurrentPosition = function(success, fail) {
- var me = this;
- exec(function(p) {
- me._position = p;
- success(p);
- }, fail, "Media", "getCurrentPositionAudio", [this.id]);
-};
-
-/**
- * Start recording audio file.
- */
-Media.prototype.startRecord = function() {
- exec(null, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
-};
-
-/**
- * Stop recording audio file.
- */
-Media.prototype.stopRecord = function() {
- exec(null, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
-};
-
-/**
- * Release the resources.
- */
-Media.prototype.release = function() {
- exec(null, this.errorCallback, "Media", "release", [this.id]);
-};
-
-/**
- * Adjust the volume.
- */
-Media.prototype.setVolume = function(volume) {
- exec(null, null, "Media", "setVolume", [this.id, volume]);
-};
-
-/**
- * Audio has status update.
- * PRIVATE
- *
- * @param id The media object id (string)
- * @param msgType The 'type' of update this is
- * @param value Use of value is determined by the msgType
- */
-Media.onStatus = function(id, msgType, value) {
-
- var media = mediaObjects[id];
-
- if(media) {
- switch(msgType) {
- case Media.MEDIA_STATE :
- media.statusCallback && media.statusCallback(value);
- if(value == Media.MEDIA_STOPPED) {
- media.successCallback && media.successCallback();
- }
- break;
- case Media.MEDIA_DURATION :
- media._duration = value;
- break;
- case Media.MEDIA_ERROR :
- media.errorCallback && media.errorCallback(value);
- break;
- case Media.MEDIA_POSITION :
- media._position = Number(value);
- break;
- default :
- console.error && console.error("Unhandled Media.onStatus :: " + msgType);
- break;
- }
- }
- else {
- console.error && console.error("Received Media.onStatus callback for unknown media :: " + id);
- }
-
-};
-
-module.exports = Media;
-
-});
-
-// file: lib/common/plugin/MediaError.js
-define("cordova/plugin/MediaError", function(require, exports, module) {
-
-/**
- * This class contains information about any Media errors.
-*/
-/*
- According to :: http://dev.w3.org/html5/spec-author-view/video.html#mediaerror
- We should never be creating these objects, we should just implement the interface
- which has 1 property for an instance, 'code'
-
- instead of doing :
- errorCallbackFunction( new MediaError(3,'msg') );
-we should simply use a literal :
- errorCallbackFunction( {'code':3} );
- */
-
- var _MediaError = window.MediaError;
-
-
-if(!_MediaError) {
- window.MediaError = _MediaError = function(code, msg) {
- this.code = (typeof code != 'undefined') ? code : null;
- this.message = msg || ""; // message is NON-standard! do not use!
- };
-}
-
-_MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
-_MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1;
-_MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2;
-_MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3;
-_MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
-// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
-// as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes
-_MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
-
-module.exports = _MediaError;
-
-});
-
-// file: lib/common/plugin/MediaFile.js
-define("cordova/plugin/MediaFile", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- File = require('cordova/plugin/File'),
- CaptureError = require('cordova/plugin/CaptureError');
-/**
- * Represents a single file.
- *
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
-};
-
-utils.extend(MediaFile, File);
-
-/**
- * Request capture format data for a specific file and type
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
- if (typeof this.fullPath === "undefined" || this.fullPath === null) {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- } else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
- }
-};
-
-module.exports = MediaFile;
-
-});
-
-// file: lib/common/plugin/MediaFileData.js
-define("cordova/plugin/MediaFileData", function(require, exports, module) {
-
-/**
- * MediaFileData encapsulates format information of a media file.
- *
- * @param {DOMString} codecs
- * @param {long} bitrate
- * @param {long} height
- * @param {long} width
- * @param {float} duration
- */
-var MediaFileData = function(codecs, bitrate, height, width, duration){
- this.codecs = codecs || null;
- this.bitrate = bitrate || 0;
- this.height = height || 0;
- this.width = width || 0;
- this.duration = duration || 0;
-};
-
-module.exports = MediaFileData;
-
-});
-
-// file: lib/common/plugin/Metadata.js
-define("cordova/plugin/Metadata", function(require, exports, module) {
-
-/**
- * Information about the state of the file or directory
- *
- * {Date} modificationTime (readonly)
- */
-var Metadata = function(time) {
- this.modificationTime = (typeof time != 'undefined'?new Date(time):null);
-};
-
-module.exports = Metadata;
-
-});
-
-// file: lib/common/plugin/Position.js
-define("cordova/plugin/Position", function(require, exports, module) {
-
-var Coordinates = require('cordova/plugin/Coordinates');
-
-var Position = function(coords, timestamp) {
- if (coords) {
- this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
- } else {
- this.coords = new Coordinates();
- }
- this.timestamp = (timestamp !== undefined) ? timestamp : new Date();
-};
-
-module.exports = Position;
-
-});
-
-// file: lib/common/plugin/PositionError.js
-define("cordova/plugin/PositionError", function(require, exports, module) {
-
-/**
- * Position error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var PositionError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-PositionError.PERMISSION_DENIED = 1;
-PositionError.POSITION_UNAVAILABLE = 2;
-PositionError.TIMEOUT = 3;
-
-module.exports = PositionError;
-
-});
-
-// file: lib/common/plugin/ProgressEvent.js
-define("cordova/plugin/ProgressEvent", function(require, exports, module) {
-
-// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
-// Feature test: See if we can instantiate a native ProgressEvent;
-// if so, use that approach,
-// otherwise fill-in with our own implementation.
-//
-// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
-var ProgressEvent = (function() {
- /*
- var createEvent = function(data) {
- var event = document.createEvent('Events');
- event.initEvent('ProgressEvent', false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- if (data.target) {
- // TODO: cannot call <some_custom_object>.dispatchEvent
- // need to first figure out how to implement EventTarget
- }
- }
- return event;
- };
- try {
- var ev = createEvent({type:"abort",target:document});
- return function ProgressEvent(type, data) {
- data.type = type;
- return createEvent(data);
- };
- } catch(e){
- */
- return function ProgressEvent(type, dict) {
- this.type = type;
- this.bubbles = false;
- this.cancelBubble = false;
- this.cancelable = false;
- this.lengthComputable = false;
- this.loaded = dict && dict.loaded ? dict.loaded : 0;
- this.total = dict && dict.total ? dict.total : 0;
- this.target = dict && dict.target ? dict.target : null;
- };
- //}
-})();
-
-module.exports = ProgressEvent;
-
-});
-
-// file: lib/common/plugin/accelerometer.js
-define("cordova/plugin/accelerometer", function(require, exports, module) {
-
-/**
- * This class provides access to device accelerometer data.
- * @constructor
- */
-var argscheck = require('cordova/argscheck'),
- utils = require("cordova/utils"),
- exec = require("cordova/exec"),
- Acceleration = require('cordova/plugin/Acceleration');
-
-// Is the accel sensor running?
-var running = false;
-
-// Keeps reference to watchAcceleration calls.
-var timers = {};
-
-// Array of listeners; used to keep track of when we should call start and stop.
-var listeners = [];
-
-// Last returned acceleration object from native
-var accel = null;
-
-// Tells native to start.
-function start() {
- exec(function(a) {
- var tempListeners = listeners.slice(0);
- accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].win(accel);
- }
- }, function(e) {
- var tempListeners = listeners.slice(0);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].fail(e);
- }
- }, "Accelerometer", "start", []);
- running = true;
-}
-
-// Tells native to stop.
-function stop() {
- exec(null, null, "Accelerometer", "stop", []);
- running = false;
-}
-
-// Adds a callback pair to the listeners array
-function createCallbackPair(win, fail) {
- return {win:win, fail:fail};
-}
-
-// Removes a win/fail listener pair from the listeners array
-function removeListeners(l) {
- var idx = listeners.indexOf(l);
- if (idx > -1) {
- listeners.splice(idx, 1);
- if (listeners.length === 0) {
- stop();
- }
- }
-}
-
-var accelerometer = {
- /**
- * Asynchronously acquires the current acceleration.
- *
- * @param {Function} successCallback The function to call when the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- */
- getCurrentAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
-
- var p;
- var win = function(a) {
- removeListeners(p);
- successCallback(a);
- };
- var fail = function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- };
-
- p = createCallbackPair(win, fail);
- listeners.push(p);
-
- if (!running) {
- start();
- }
- },
-
- /**
- * Asynchronously acquires the acceleration repeatedly at a given interval.
- *
- * @param {Function} successCallback The function to call each time the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
- // Default interval (10 sec)
- var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
-
- // Keep reference to watch id, and report accel readings as often as defined in frequency
- var id = utils.createUUID();
-
- var p = createCallbackPair(function(){}, function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- });
- listeners.push(p);
-
- timers[id] = {
- timer:window.setInterval(function() {
- if (accel) {
- successCallback(accel);
- }
- }, frequency),
- listeners:p
- };
-
- if (running) {
- // If we're already running then immediately invoke the success callback
- // but only if we have retrieved a value, sample code does not check for null ...
- if (accel) {
- successCallback(accel);
- }
- } else {
- start();
- }
-
- return id;
- },
-
- /**
- * Clears the specified accelerometer watch.
- *
- * @param {String} id The id of the watch returned from #watchAcceleration.
- */
- clearWatch: function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- window.clearInterval(timers[id].timer);
- removeListeners(timers[id].listeners);
- delete timers[id];
- }
- }
-};
-
-module.exports = accelerometer;
-
-});
-
-// file: lib/common/plugin/accelerometer/symbols.js
-define("cordova/plugin/accelerometer/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Acceleration', 'Acceleration');
-modulemapper.defaults('cordova/plugin/accelerometer', 'navigator.accelerometer');
-
-});
-
-// file: lib/common/plugin/battery.js
-define("cordova/plugin/battery", function(require, exports, module) {
-
-/**
- * This class contains information about the current battery status.
- * @constructor
- */
-var cordova = require('cordova'),
- exec = require('cordova/exec');
-
-function handlers() {
- return battery.channels.batterystatus.numHandlers +
- battery.channels.batterylow.numHandlers +
- battery.channels.batterycritical.numHandlers;
-}
-
-var Battery = function() {
- this._level = null;
- this._isPlugged = null;
- // Create new event handlers on the window (returns a channel instance)
- this.channels = {
- batterystatus:cordova.addWindowEventHandler("batterystatus"),
- batterylow:cordova.addWindowEventHandler("batterylow"),
- batterycritical:cordova.addWindowEventHandler("batterycritical")
- };
- for (var key in this.channels) {
- this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
- }
-};
-/**
- * Event handlers for when callbacks get registered for the battery.
- * Keep track of how many handlers we have so we can start and stop the native battery listener
- * appropriately (and hopefully save on battery life!).
- */
-Battery.onHasSubscribersChange = function() {
- // If we just registered the first handler, make sure native listener is started.
- if (this.numHandlers === 1 && handlers() === 1) {
- exec(battery._status, battery._error, "Battery", "start", []);
- } else if (handlers() === 0) {
- exec(null, null, "Battery", "stop", []);
- }
-};
-
-/**
- * Callback for battery status
- *
- * @param {Object} info keys: level, isPlugged
- */
-Battery.prototype._status = function(info) {
- if (info) {
- var me = battery;
- var level = info.level;
- if (me._level !== level || me._isPlugged !== info.isPlugged) {
- // Fire batterystatus event
- cordova.fireWindowEvent("batterystatus", info);
-
- // Fire low battery event
- if (level === 20 || level === 5) {
- if (level === 20) {
- cordova.fireWindowEvent("batterylow", info);
- }
- else {
- cordova.fireWindowEvent("batterycritical", info);
- }
- }
- }
- me._level = level;
- me._isPlugged = info.isPlugged;
- }
-};
-
-/**
- * Error callback for battery start
- */
-Battery.prototype._error = function(e) {
- console.log("Error initializing Battery: " + e);
-};
-
-var battery = new Battery();
-
-module.exports = battery;
-
-});
-
-// file: lib/common/plugin/battery/symbols.js
-define("cordova/plugin/battery/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
-
-});
-
-// file: lib/common/plugin/camera/symbols.js
-define("cordova/plugin/camera/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Camera', 'navigator.camera');
-modulemapper.defaults('cordova/plugin/CameraConstants', 'Camera');
-modulemapper.defaults('cordova/plugin/CameraPopoverOptions', 'CameraPopoverOptions');
-
-});
-
-// file: lib/common/plugin/capture.js
-define("cordova/plugin/capture", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
-
-/**
- * Launches a capture of different types.
- *
- * @param (DOMString} type
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-function _capture(type, successCallback, errorCallback, options) {
- var win = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult[i].name;
- mediaFile.fullPath = pluginResult[i].fullPath;
- mediaFile.type = pluginResult[i].type;
- mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
- mediaFile.size = pluginResult[i].size;
- mediaFiles.push(mediaFile);
- }
- successCallback(mediaFiles);
- };
- exec(win, errorCallback, "Capture", type, [options]);
-}
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-function Capture() {
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- _capture("captureAudio", successCallback, errorCallback, options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function(successCallback, errorCallback, options){
- _capture("captureImage", successCallback, errorCallback, options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- _capture("captureVideo", successCallback, errorCallback, options);
-};
-
-
-module.exports = new Capture();
-
-});
-
-// file: lib/common/plugin/capture/symbols.js
-define("cordova/plugin/capture/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/CaptureError', 'CaptureError');
-modulemapper.clobbers('cordova/plugin/CaptureAudioOptions', 'CaptureAudioOptions');
-modulemapper.clobbers('cordova/plugin/CaptureImageOptions', 'CaptureImageOptions');
-modulemapper.clobbers('cordova/plugin/CaptureVideoOptions', 'CaptureVideoOptions');
-modulemapper.clobbers('cordova/plugin/ConfigurationData', 'ConfigurationData');
-modulemapper.clobbers('cordova/plugin/MediaFile', 'MediaFile');
-modulemapper.clobbers('cordova/plugin/MediaFileData', 'MediaFileData');
-modulemapper.clobbers('cordova/plugin/capture', 'navigator.device.capture');
-
-});
-
-// file: lib/common/plugin/compass.js
-define("cordova/plugin/compass", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- utils = require('cordova/utils'),
- CompassHeading = require('cordova/plugin/CompassHeading'),
- CompassError = require('cordova/plugin/CompassError'),
- timers = {},
- compass = {
- /**
- * Asynchronously acquires the current heading.
- * @param {Function} successCallback The function to call when the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {CompassOptions} options The options for getting the heading data (not used).
- */
- getCurrentHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments);
-
- var win = function(result) {
- var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
- successCallback(ch);
- };
- var fail = errorCallback && function(code) {
- var ce = new CompassError(code);
- errorCallback(ce);
- };
-
- // Get heading
- exec(win, fail, "Compass", "getHeading", [options]);
- },
-
- /**
- * Asynchronously acquires the heading repeatedly at a given interval.
- * @param {Function} successCallback The function to call each time the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {HeadingOptions} options The options for getting the heading data
- * such as timeout and the frequency of the watch. For iOS, filter parameter
- * specifies to watch via a distance filter rather than time.
- */
- watchHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.watchHeading', arguments);
- // Default interval (100 msec)
- var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
- var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
-
- var id = utils.createUUID();
- if (filter > 0) {
- // is an iOS request for watch by filter, no timer needed
- timers[id] = "iOS";
- compass.getCurrentHeading(successCallback, errorCallback, options);
- } else {
- // Start watch timer to get headings
- timers[id] = window.setInterval(function() {
- compass.getCurrentHeading(successCallback, errorCallback);
- }, frequency);
- }
-
- return id;
- },
-
- /**
- * Clears the specified heading watch.
- * @param {String} watchId The ID of the watch returned from #watchHeading.
- */
- clearWatch:function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- if (timers[id] != "iOS") {
- clearInterval(timers[id]);
- } else {
- // is iOS watch by filter so call into device to stop
- exec(null, null, "Compass", "stopHeading", []);
- }
- delete timers[id];
- }
- }
- };
-
-module.exports = compass;
-
-});
-
-// file: lib/common/plugin/compass/symbols.js
-define("cordova/plugin/compass/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/CompassHeading', 'CompassHeading');
-modulemapper.clobbers('cordova/plugin/CompassError', 'CompassError');
-modulemapper.clobbers('cordova/plugin/compass', 'navigator.compass');
-
-});
-
-// file: lib/common/plugin/console-via-logger.js
-define("cordova/plugin/console-via-logger", function(require, exports, module) {
-
-//------------------------------------------------------------------------------
-
-var logger = require("cordova/plugin/logger");
-var utils = require("cordova/utils");
-
-//------------------------------------------------------------------------------
-// object that we're exporting
-//------------------------------------------------------------------------------
-var console = module.exports;
-
-//------------------------------------------------------------------------------
-// copy of the original console object
-//------------------------------------------------------------------------------
-var WinConsole = window.console;
-
-//------------------------------------------------------------------------------
-// whether to use the logger
-//------------------------------------------------------------------------------
-var UseLogger = false;
-
-//------------------------------------------------------------------------------
-// Timers
-//------------------------------------------------------------------------------
-var Timers = {};
-
-//------------------------------------------------------------------------------
-// used for unimplemented methods
-//------------------------------------------------------------------------------
-function noop() {}
-
-//------------------------------------------------------------------------------
-// used for unimplemented methods
-//------------------------------------------------------------------------------
-console.useLogger = function (value) {
- if (arguments.length) UseLogger = !!value;
-
- if (UseLogger) {
- if (logger.useConsole()) {
- throw new Error("console and logger are too intertwingly");
- }
- }
-
- return UseLogger;
-};
-
-//------------------------------------------------------------------------------
-console.log = function() {
- if (logger.useConsole()) return;
- logger.log.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.error = function() {
- if (logger.useConsole()) return;
- logger.error.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.warn = function() {
- if (logger.useConsole()) return;
- logger.warn.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.info = function() {
- if (logger.useConsole()) return;
- logger.info.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.debug = function() {
- if (logger.useConsole()) return;
- logger.debug.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.assert = function(expression) {
- if (expression) return;
-
- var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
- console.log("ASSERT: " + message);
-};
-
-//------------------------------------------------------------------------------
-console.clear = function() {};
-
-//------------------------------------------------------------------------------
-console.dir = function(object) {
- console.log("%o", object);
-};
-
-//------------------------------------------------------------------------------
-console.dirxml = function(node) {
- console.log(node.innerHTML);
-};
-
-//------------------------------------------------------------------------------
-console.trace = noop;
-
-//------------------------------------------------------------------------------
-console.group = console.log;
-
-//------------------------------------------------------------------------------
-console.groupCollapsed = console.log;
-
-//------------------------------------------------------------------------------
-console.groupEnd = noop;
-
-//------------------------------------------------------------------------------
-console.time = function(name) {
- Timers[name] = new Date().valueOf();
-};
-
-//------------------------------------------------------------------------------
-console.timeEnd = function(name) {
- var timeStart = Timers[name];
- if (!timeStart) {
- console.warn("unknown timer: " + name);
- return;
- }
-
- var timeElapsed = new Date().valueOf() - timeStart;
- console.log(name + ": " + timeElapsed + "ms");
-};
-
-//------------------------------------------------------------------------------
-console.timeStamp = noop;
-
-//------------------------------------------------------------------------------
-console.profile = noop;
-
-//------------------------------------------------------------------------------
-console.profileEnd = noop;
-
-//------------------------------------------------------------------------------
-console.count = noop;
-
-//------------------------------------------------------------------------------
-console.exception = console.log;
-
-//------------------------------------------------------------------------------
-console.table = function(data, columns) {
- console.log("%o", data);
-};
-
-//------------------------------------------------------------------------------
-// return a new function that calls both functions passed as args
-//------------------------------------------------------------------------------
-function wrappedOrigCall(orgFunc, newFunc) {
- return function() {
- var args = [].slice.call(arguments);
- try { orgFunc.apply(WinConsole, args); } catch (e) {}
- try { newFunc.apply(console, args); } catch (e) {}
- };
-}
-
-//------------------------------------------------------------------------------
-// For every function that exists in the original console object, that
-// also exists in the new console object, wrap the new console method
-// with one that calls both
-//------------------------------------------------------------------------------
-for (var key in console) {
- if (typeof WinConsole[key] == "function") {
- console[key] = wrappedOrigCall(WinConsole[key], console[key]);
- }
-}
-
-});
-
-// file: lib/common/plugin/contacts.js
-define("cordova/plugin/contacts", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils'),
- Contact = require('cordova/plugin/Contact');
-
-/**
-* Represents a group of Contacts.
-* @constructor
-*/
-var contacts = {
- /**
- * Returns an array of Contacts matching the search criteria.
- * @param fields that should be searched
- * @param successCB success callback
- * @param errorCB error callback
- * @param {ContactFindOptions} options that can be applied to contact searching
- * @return array of Contacts matching search criteria
- */
- find:function(fields, successCB, errorCB, options) {
- argscheck.checkArgs('afFO', 'contacts.find', arguments);
- if (!fields.length) {
- errorCB && errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
- } else {
- var win = function(result) {
- var cs = [];
- for (var i = 0, l = result.length; i < l; i++) {
- cs.push(contacts.create(result[i]));
- }
- successCB(cs);
- };
- exec(win, errorCB, "Contacts", "search", [fields, options]);
- }
- },
-
- /**
- * This function creates a new contact, but it does not persist the contact
- * to device storage. To persist the contact to device storage, invoke
- * contact.save().
- * @param properties an object whose properties will be examined to create a new Contact
- * @returns new Contact object
- */
- create:function(properties) {
- argscheck.checkArgs('O', 'contacts.create', arguments);
- var contact = new Contact();
- for (var i in properties) {
- if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
- contact[i] = properties[i];
- }
- }
- return contact;
- }
-};
-
-module.exports = contacts;
-
-});
-
-// file: lib/common/plugin/contacts/symbols.js
-define("cordova/plugin/contacts/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/contacts', 'navigator.contacts');
-modulemapper.clobbers('cordova/plugin/Contact', 'Contact');
-modulemapper.clobbers('cordova/plugin/ContactAddress', 'ContactAddress');
-modulemapper.clobbers('cordova/plugin/ContactError', 'ContactError');
-modulemapper.clobbers('cordova/plugin/ContactField', 'ContactField');
-modulemapper.clobbers('cordova/plugin/ContactFindOptions', 'ContactFindOptions');
-modulemapper.clobbers('cordova/plugin/ContactName', 'ContactName');
-modulemapper.clobbers('cordova/plugin/ContactOrganization', 'ContactOrganization');
-
-});
-
-// file: lib/common/plugin/device.js
-define("cordova/plugin/device", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
-
-/**
- * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
- * phone, etc.
- * @constructor
- */
-function Device() {
- this.available = false;
- this.platform = null;
- this.version = null;
- this.uuid = null;
- this.cordova = null;
- this.model = null;
-
- var me = this;
-
- channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- var buildLabel = info.cordova;
- if (buildLabel != CORDOVA_JS_BUILD_LABEL) {
- buildLabel += ' JS=' + CORDOVA_JS_BUILD_LABEL;
- }
- me.available = true;
- me.platform = info.platform;
- me.version = info.version;
- me.uuid = info.uuid;
- me.cordova = buildLabel;
- me.model = info.model;
- channel.onCordovaInfoReady.fire();
- },function(e) {
- me.available = false;
- utils.alert("[ERROR] Error initializing Cordova: " + e);
- });
- });
-}
-
-/**
- * Get device info
- *
- * @param {Function} successCallback The function to call when the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- */
-Device.prototype.getInfo = function(successCallback, errorCallback) {
- argscheck.checkArgs('fF', 'Device.getInfo', arguments);
- exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
-};
-
-module.exports = new Device();
-
-});
-
-// file: lib/common/plugin/device/symbols.js
-define("cordova/plugin/device/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/device', 'device');
-
-});
-
-// file: lib/common/plugin/echo.js
-define("cordova/plugin/echo", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- utils = require('cordova/utils');
-
-/**
- * Sends the given message through exec() to the Echo plugin, which sends it back to the successCallback.
- * @param successCallback invoked with a FileSystem object
- * @param errorCallback invoked if error occurs retrieving file system
- * @param message The string to be echoed.
- * @param forceAsync Whether to force an async return value (for testing native->js bridge).
- */
-module.exports = function(successCallback, errorCallback, message, forceAsync) {
- var action = 'echo';
- var messageIsMultipart = (utils.typeName(message) == "Array");
- var args = messageIsMultipart ? message : [message];
-
- if (utils.typeName(message) == 'ArrayBuffer') {
- if (forceAsync) {
- console.warn('Cannot echo ArrayBuffer with forced async, falling back to sync.');
- }
- action += 'ArrayBuffer';
- } else if (messageIsMultipart) {
- if (forceAsync) {
- console.warn('Cannot echo MultiPart Array with forced async, falling back to sync.');
- }
- action += 'MultiPart';
- } else if (forceAsync) {
- action += 'Async';
- }
-
- exec(successCallback, errorCallback, "Echo", action, args);
-};
-
-
-});
-
-// file: lib/ios/plugin/file/symbols.js
-define("cordova/plugin/file/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper'),
- symbolshelper = require('cordova/plugin/file/symbolshelper');
-
-symbolshelper(modulemapper.clobbers);
-modulemapper.merges('cordova/plugin/ios/Entry', 'Entry');
-
-});
-
-// file: lib/common/plugin/file/symbolshelper.js
-define("cordova/plugin/file/symbolshelper", function(require, exports, module) {
-
-module.exports = function(exportFunc) {
- exportFunc('cordova/plugin/DirectoryEntry', 'DirectoryEntry');
- exportFunc('cordova/plugin/DirectoryReader', 'DirectoryReader');
- exportFunc('cordova/plugin/Entry', 'Entry');
- exportFunc('cordova/plugin/File', 'File');
- exportFunc('cordova/plugin/FileEntry', 'FileEntry');
- exportFunc('cordova/plugin/FileError', 'FileError');
- exportFunc('cordova/plugin/FileReader', 'FileReader');
- exportFunc('cordova/plugin/FileSystem', 'FileSystem');
- exportFunc('cordova/plugin/FileUploadOptions', 'FileUploadOptions');
- exportFunc('cordova/plugin/FileUploadResult', 'FileUploadResult');
- exportFunc('cordova/plugin/FileWriter', 'FileWriter');
- exportFunc('cordova/plugin/Flags', 'Flags');
- exportFunc('cordova/plugin/LocalFileSystem', 'LocalFileSystem');
- exportFunc('cordova/plugin/Metadata', 'Metadata');
- exportFunc('cordova/plugin/ProgressEvent', 'ProgressEvent');
- exportFunc('cordova/plugin/requestFileSystem', 'requestFileSystem');
- exportFunc('cordova/plugin/resolveLocalFileSystemURI', 'resolveLocalFileSystemURI');
-};
-
-});
-
-// file: lib/common/plugin/filetransfer/symbols.js
-define("cordova/plugin/filetransfer/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/FileTransfer', 'FileTransfer');
-modulemapper.clobbers('cordova/plugin/FileTransferError', 'FileTransferError');
-
-});
-
-// file: lib/common/plugin/geolocation.js
-define("cordova/plugin/geolocation", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- PositionError = require('cordova/plugin/PositionError'),
- Position = require('cordova/plugin/Position');
-
-var timers = {}; // list of timers in use
-
-// Returns default params, overrides if provided with values
-function parseParameters(options) {
- var opt = {
- maximumAge: 0,
- enableHighAccuracy: false,
- timeout: Infinity
- };
-
- if (options) {
- if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) {
- opt.maximumAge = options.maximumAge;
- }
- if (options.enableHighAccuracy !== undefined) {
- opt.enableHighAccuracy = options.enableHighAccuracy;
- }
- if (options.timeout !== undefined && !isNaN(options.timeout)) {
- if (options.timeout < 0) {
- opt.timeout = 0;
- } else {
- opt.timeout = options.timeout;
- }
- }
- }
-
- return opt;
-}
-
-// Returns a timeout failure, closed over a specified timeout value and error callback.
-function createTimeout(errorCallback, timeout) {
- var t = setTimeout(function() {
- clearTimeout(t);
- t = null;
- errorCallback({
- code:PositionError.TIMEOUT,
- message:"Position retrieval timed out."
- });
- }, timeout);
- return t;
-}
-
-var geolocation = {
- lastPosition:null, // reference to last known (cached) position returned
- /**
- * Asynchronously acquires the current position.
- *
- * @param {Function} successCallback The function to call when the position data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
- */
- getCurrentPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- // Timer var that will fire an error callback if no position is retrieved from native
- // before the "timeout" param provided expires
- var timeoutTimer = {timer:null};
-
- var win = function(p) {
- clearTimeout(timeoutTimer.timer);
- if (!(timeoutTimer.timer)) {
- // Timeout already happened, or native fired error callback for
- // this geo request.
- // Don't continue with success callback.
- return;
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
- var fail = function(e) {
- clearTimeout(timeoutTimer.timer);
- timeoutTimer.timer = null;
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just
- // fire the success callback with the cached position.
- if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) {
- successCallback(geolocation.lastPosition);
- // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
- } else if (options.timeout === 0) {
- fail({
- code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
- });
- // Otherwise we have to call into native to retrieve a position.
- } else {
- if (options.timeout !== Infinity) {
- // If the timeout value was not set to Infinity (default), then
- // set up a timeout function that will fire the error callback
- // if no successful position was retrieved before timeout expired.
- timeoutTimer.timer = createTimeout(fail, options.timeout);
- } else {
- // This is here so the check in the win function doesn't mess stuff up
- // may seem weird but this guarantees timeoutTimer is
- // always truthy before we call into native
- timeoutTimer.timer = true;
- }
- exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
- }
- return timeoutTimer;
- },
- /**
- * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
- * the successCallback is called with the new location.
- *
- * @param {Function} successCallback The function to call each time the location data is available
- * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- var id = utils.createUUID();
-
- // Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition
- timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
-
- var fail = function(e) {
- clearTimeout(timers[id].timer);
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- var win = function(p) {
- clearTimeout(timers[id].timer);
- if (options.timeout !== Infinity) {
- timers[id].timer = createTimeout(fail, options.timeout);
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
-
- exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]);
-
- return id;
- },
- /**
- * Clears the specified heading watch.
- *
- * @param {String} id The ID of the watch returned from #watchPosition
- */
- clearWatch:function(id) {
- if (id && timers[id] !== undefined) {
- clearTimeout(timers[id].timer);
- timers[id].timer = false;
- exec(null, null, "Geolocation", "clearWatch", [id]);
- }
- }
-};
-
-module.exports = geolocation;
-
-});
-
-// file: lib/common/plugin/geolocation/symbols.js
-define("cordova/plugin/geolocation/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/geolocation', 'navigator.geolocation');
-modulemapper.clobbers('cordova/plugin/PositionError', 'PositionError');
-modulemapper.clobbers('cordova/plugin/Position', 'Position');
-modulemapper.clobbers('cordova/plugin/Coordinates', 'Coordinates');
-
-});
-
-// file: lib/common/plugin/globalization.js
-define("cordova/plugin/globalization", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- GlobalizationError = require('cordova/plugin/GlobalizationError');
-
-var globalization = {
-
-/**
-* Returns the string identifier for the client's current language.
-* It returns the language identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the language,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The language identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
-* function () {});
-*/
-getPreferredLanguage:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
- exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);
-},
-
-/**
-* Returns the string identifier for the client's current locale setting.
-* It returns the locale identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the locale,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The locale identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
-* function () {});
-*/
-getLocaleName:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
- exec(successCB, failureCB, "Globalization","getLocaleName", []);
-},
-
-
-/**
-* Returns a date formatted as a string according to the client's user preferences and
-* calendar using the time zone of the client. It returns the formatted date string to the
-* successCB callback with a properties object as a parameter. If there is an error
-* formatting the date, then the errorCB callback is invoked.
-*
-* The defaults are: formatLenght="short" and selector="date and time"
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.value {String}: The localized date string
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.dateToString(new Date(),
-* function (date) {alert('date:' + date.value + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {formatLength:'short'});
-*/
-dateToString:function(date, successCB, failureCB, options) {
- argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);
-},
-
-
-/**
-* Parses a date formatted as a string according to the client's user
-* preferences and calendar using the time zone of the client and returns
-* the corresponding date object. It returns the date to the successCB
-* callback with a properties object as a parameter. If there is an error
-* parsing the date string, then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {String} dateString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.year {Number}: The four digit year
-* Object.month {Number}: The month from (0 - 11)
-* Object.day {Number}: The day from (1 - 31)
-* Object.hour {Number}: The hour from (0 - 23)
-* Object.minute {Number}: The minute from (0 - 59)
-* Object.second {Number}: The second from (0 - 59)
-* Object.millisecond {Number}: The milliseconds (from 0 - 999),
-* not available on all platforms
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToDate('4/11/2011',
-* function (date) { alert('Month:' + date.month + '\n' +
-* 'Day:' + date.day + '\n' +
-* 'Year:' + date.year + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {selector:'date'});
-*/
-stringToDate:function(dateString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
- exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);
-},
-
-
-/**
-* Returns a pattern string for formatting and parsing dates according to the client's
-* user preferences. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern,
-* then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.timezone {String}: The abbreviated name of the time zone on the client
-* Object.utc_offset {Number}: The current difference in seconds between the client's
-* time zone and coordinated universal time.
-* Object.dst_offset {Number}: The current daylight saving time offset in seconds
-* between the client's non-daylight saving's time zone
-* and the client's daylight saving's time zone.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getDatePattern(
-* function (date) {alert('pattern:' + date.pattern + '\n');},
-* function () {},
-* {formatLength:'short'});
-*/
-getDatePattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
- exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);
-},
-
-
-/**
-* Returns an array of either the names of the months or days of the week
-* according to the client's user preferences and calendar. It returns the array of names to the
-* successCB callback with a properties object as a parameter. If there is an error obtaining the
-* names, then the errorCB callback is invoked.
-*
-* The defaults are: type="wide" and item="months"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'narrow' or 'wide'
-* item {String}: 'months', or 'days'
-*
-* @return Object.value {Array{String}}: The array of names starting from either
-* the first month in the year or the
-* first day of the week.
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getDateNames(function (names) {
-* for(var i = 0; i < names.value.length; i++) {
-* alert('Month:' + names.value[i] + '\n');}},
-* function () {});
-*/
-getDateNames:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
- exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);
-},
-
-/**
-* Returns whether daylight savings time is in effect for a given date using the client's
-* time zone and calendar. It returns whether or not daylight savings time is in effect
-* to the successCB callback with a properties object as a parameter. If there is an error
-* reading the date, then the errorCB callback is invoked.
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
-* in effect for the given date and "false" indicate that it is not.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.isDayLightSavingsTime(new Date(),
-* function (date) {alert('dst:' + date.dst + '\n');}
-* function () {});
-*/
-isDayLightSavingsTime:function(date, successCB, failureCB) {
- argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);
-},
-
-/**
-* Returns the first day of the week according to the client's user preferences and calendar.
-* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
-* It returns the day to the successCB callback with a properties object as a parameter.
-* If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {Number}: The number of the first day of the week.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getFirstDayOfWeek(function (day)
-* { alert('Day:' + day.value + '\n');},
-* function () {});
-*/
-getFirstDayOfWeek:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
- exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);
-},
-
-
-/**
-* Returns a number formatted as a string according to the client's user preferences.
-* It returns the formatted number string to the successCB callback with a properties object as a
-* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Number} number
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {String}: The formatted number string.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.numberToString(3.25,
-* function (number) {alert('number:' + number.value + '\n');},
-* function () {},
-* {type:'decimal'});
-*/
-numberToString:function(number, successCB, failureCB, options) {
- argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
- exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);
-},
-
-/**
-* Parses a number formatted as a string according to the client's user preferences and
-* returns the corresponding number. It returns the number to the successCB callback with a
-* properties object as a parameter. If there is an error parsing the number string, then
-* the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {String} numberString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {Number}: The parsed number.
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToNumber('1234.56',
-* function (number) {alert('Number:' + number.value + '\n');},
-* function () { alert('Error parsing number');});
-*/
-stringToNumber:function(numberString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
- exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing numbers according to the client's user
-* preferences. It returns the pattern to the successCB callback with a properties object as a
-* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
-* The patterns follow Unicode Technical Standard #35.
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.symbol {String}: The symbol to be used when formatting and parsing
-* e.g., percent or currency symbol.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting numbers.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
-* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getNumberPattern(
-* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
-* function () {});
-*/
-getNumberPattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing currency values according to the client's
-* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
-* callback is invoked.
-*
-* @param {String} currencyCode
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.code {String}: The ISO 4217 currency code for the pattern.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting currency.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.getCurrencyPattern('EUR',
-* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
-* function () {});
-*/
-getCurrencyPattern:function(currencyCode, successCB, failureCB) {
- argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);
-}
-
-};
-
-module.exports = globalization;
-
-});
-
-// file: lib/common/plugin/globalization/symbols.js
-define("cordova/plugin/globalization/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/globalization', 'navigator.globalization');
-modulemapper.clobbers('cordova/plugin/GlobalizationError', 'GlobalizationError');
-
-});
-
-// file: lib/ios/plugin/inappbrowser/symbols.js
-define("cordova/plugin/inappbrowser/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/InAppBrowser', 'open');
-
-});
-
-// file: lib/ios/plugin/ios/Contact.js
-define("cordova/plugin/ios/Contact", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError');
-
-/**
- * Provides iOS Contact.display API.
- */
-module.exports = {
- display : function(errorCB, options) {
- /*
- * Display a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- */
-
- if (this.id === null) {
- if (typeof errorCB === "function") {
- var errorObj = new ContactError(ContactError.UNKNOWN_ERROR);
- errorCB(errorObj);
- }
- }
- else {
- exec(null, errorCB, "Contacts","displayContact", [this.id, options]);
- }
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/Entry.js
-define("cordova/plugin/ios/Entry", function(require, exports, module) {
-
-module.exports = {
- toURL:function() {
- // TODO: refactor path in a cross-platform way so we can eliminate
- // these kinds of platform-specific hacks.
- return "file://localhost" + this.fullPath;
- },
- toURI: function() {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- return "file://localhost" + this.fullPath;
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/contacts.js
-define("cordova/plugin/ios/contacts", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Provides iOS enhanced contacts API.
- */
-module.exports = {
- newContactUI : function(successCallback) {
- /*
- * Create a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * returns: the id of the created contact as param to successCallback
- */
- exec(successCallback, null, "Contacts","newContact", []);
- },
- chooseContact : function(successCallback, options) {
- /*
- * Select a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- * fields: array of fields to return in contact object (see ContactOptions.fields)
- *
- * @returns
- * id of contact selected
- * ContactObject
- * if no fields provided contact contains just id information
- * if fields provided contact object contains information for the specified fields
- *
- */
- var win = function(result) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCallback(fullContact.id, fullContact);
- };
- exec(win, null, "Contacts","chooseContact", [options]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/contacts/symbols.js
-define("cordova/plugin/ios/contacts/symbols", function(require, exports, module) {
-
-require('cordova/plugin/contacts/symbols');
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/ios/contacts', 'navigator.contacts');
-modulemapper.merges('cordova/plugin/ios/Contact', 'Contact');
-
-});
-
-// file: lib/ios/plugin/ios/geolocation/symbols.js
-define("cordova/plugin/ios/geolocation/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/geolocation', 'navigator.geolocation');
-
-});
-
-// file: lib/ios/plugin/ios/logger/plugininit.js
-define("cordova/plugin/ios/logger/plugininit", function(require, exports, module) {
-
-// use the native logger
-var logger = require("cordova/plugin/logger");
-logger.useConsole(true);
-
-});
-
-// file: lib/ios/plugin/ios/logger/symbols.js
-define("cordova/plugin/ios/logger/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/logger', 'console');
-
-});
-
-// file: lib/ios/plugin/ios/notification.js
-define("cordova/plugin/ios/notification", function(require, exports, module) {
-
-var Media = require('cordova/plugin/Media');
-
-module.exports = {
- beep:function(count) {
- (new Media('beep.wav')).play();
- }
-};
-
-});
-
-// file: lib/common/plugin/logger.js
-define("cordova/plugin/logger", function(require, exports, module) {
-
-//------------------------------------------------------------------------------
-// The logger module exports the following properties/functions:
-//
-// LOG - constant for the level LOG
-// ERROR - constant for the level ERROR
-// WARN - constant for the level WARN
-// INFO - constant for the level INFO
-// DEBUG - constant for the level DEBUG
-// logLevel() - returns current log level
-// logLevel(value) - sets and returns a new log level
-// useConsole() - returns whether logger is using console
-// useConsole(value) - sets and returns whether logger is using console
-// log(message,...) - logs a message at level LOG
-// error(message,...) - logs a message at level ERROR
-// warn(message,...) - logs a message at level WARN
-// info(message,...) - logs a message at level INFO
-// debug(message,...) - logs a message at level DEBUG
-// logLevel(level,message,...) - logs a message specified level
-//
-//------------------------------------------------------------------------------
-
-var logger = exports;
-
-var exec = require('cordova/exec');
-var utils = require('cordova/utils');
-
-var UseConsole = true;
-var UseLogger = true;
-var Queued = [];
-var DeviceReady = false;
-var CurrentLevel;
-
-var originalConsole = console;
-
-/**
- * Logging levels
- */
-
-var Levels = [
- "LOG",
- "ERROR",
- "WARN",
- "INFO",
- "DEBUG"
-];
-
-/*
- * add the logging levels to the logger object and
- * to a separate levelsMap object for testing
- */
-
-var LevelsMap = {};
-for (var i=0; i<Levels.length; i++) {
- var level = Levels[i];
- LevelsMap[level] = i;
- logger[level] = level;
-}
-
-CurrentLevel = LevelsMap.WARN;
-
-/**
- * Getter/Setter for the logging level
- *
- * Returns the current logging level.
- *
- * When a value is passed, sets the logging level to that value.
- * The values should be one of the following constants:
- * logger.LOG
- * logger.ERROR
- * logger.WARN
- * logger.INFO
- * logger.DEBUG
- *
- * The value used determines which messages get printed. The logging
- * values above are in order, and only messages logged at the logging
- * level or above will actually be displayed to the user. E.g., the
- * default level is WARN, so only messages logged with LOG, ERROR, or
- * WARN will be displayed; INFO and DEBUG messages will be ignored.
- */
-logger.level = function (value) {
- if (arguments.length) {
- if (LevelsMap[value] === null) {
- throw new Error("invalid logging level: " + value);
- }
- CurrentLevel = LevelsMap[value];
- }
-
- return Levels[CurrentLevel];
-};
-
-/**
- * Getter/Setter for the useConsole functionality
- *
- * When useConsole is true, the logger will log via the
- * browser 'console' object.
- */
-logger.useConsole = function (value) {
- if (arguments.length) UseConsole = !!value;
-
- if (UseConsole) {
- if (typeof console == "undefined") {
- throw new Error("global console object is not defined");
- }
-
- if (typeof console.log != "function") {
- throw new Error("global console object does not have a log function");
- }
-
- if (typeof console.useLogger == "function") {
- if (console.useLogger()) {
- throw new Error("console and logger are too intertwingly");
- }
- }
- }
-
- return UseConsole;
-};
-
-/**
- * Getter/Setter for the useLogger functionality
- *
- * When useLogger is true, the logger will log via the
- * native Logger plugin.
- */
-logger.useLogger = function (value) {
- // Enforce boolean
- if (arguments.length) UseLogger = !!value;
- return UseLogger;
-};
-
-/**
- * Logs a message at the LOG level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.log = function(message) { logWithArgs("LOG", arguments); };
-
-/**
- * Logs a message at the ERROR level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.error = function(message) { logWithArgs("ERROR", arguments); };
-
-/**
- * Logs a message at the WARN level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.warn = function(message) { logWithArgs("WARN", arguments); };
-
-/**
- * Logs a message at the INFO level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.info = function(message) { logWithArgs("INFO", arguments); };
-
-/**
- * Logs a message at the DEBUG level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
-
-// log at the specified level with args
-function logWithArgs(level, args) {
- args = [level].concat([].slice.call(args));
- logger.logLevel.apply(logger, args);
-}
-
-/**
- * Logs a message at the specified level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.logLevel = function(level /* , ... */) {
- // format the message with the parameters
- var formatArgs = [].slice.call(arguments, 1);
- var message = logger.format.apply(logger.format, formatArgs);
-
- if (LevelsMap[level] === null) {
- throw new Error("invalid logging level: " + level);
- }
-
- if (LevelsMap[level] > CurrentLevel) return;
-
- // queue the message if not yet at deviceready
- if (!DeviceReady && !UseConsole) {
- Queued.push([level, message]);
- return;
- }
-
- // Log using the native logger if that is enabled
- if (UseLogger) {
- exec(null, null, "Logger", "logLevel", [level, message]);
- }
-
- // Log using the console if that is enabled
- if (UseConsole) {
- // make sure console is not using logger
- if (console.__usingCordovaLogger) {
- throw new Error("console and logger are too intertwingly");
- }
-
- // log to the console
- switch (level) {
- case logger.LOG: originalConsole.log(message); break;
- case logger.ERROR: originalConsole.log("ERROR: " + message); break;
- case logger.WARN: originalConsole.log("WARN: " + message); break;
- case logger.INFO: originalConsole.log("INFO: " + message); break;
- case logger.DEBUG: originalConsole.log("DEBUG: " + message); break;
- }
- }
-};
-
-
-/**
- * Formats a string and arguments following it ala console.log()
- *
- * Any remaining arguments will be appended to the formatted string.
- *
- * for rationale, see FireBug's Console API:
- * http://getfirebug.com/wiki/index.php/Console_API
- */
-logger.format = function(formatString, args) {
- return __format(arguments[0], [].slice.call(arguments,1)).join(' ');
-};
-
-
-//------------------------------------------------------------------------------
-/**
- * Formats a string and arguments following it ala vsprintf()
- *
- * format chars:
- * %j - format arg as JSON
- * %o - format arg as JSON
- * %c - format arg as ''
- * %% - replace with '%'
- * any other char following % will format it's
- * arg via toString().
- *
- * Returns an array containing the formatted string and any remaining
- * arguments.
- */
-function __format(formatString, args) {
- if (formatString === null || formatString === undefined) return [""];
- if (arguments.length == 1) return [formatString.toString()];
-
- if (typeof formatString != "string")
- formatString = formatString.toString();
-
- var pattern = /(.*?)%(.)(.*)/;
- var rest = formatString;
- var result = [];
-
- while (args.length) {
- var match = pattern.exec(rest);
- if (!match) break;
-
- var arg = args.shift();
- rest = match[3];
- result.push(match[1]);
-
- if (match[2] == '%') {
- result.push('%');
- args.unshift(arg);
- continue;
- }
-
- result.push(__formatted(arg, match[2]));
- }
-
- result.push(rest);
-
- var remainingArgs = [].slice.call(args);
- remainingArgs.unshift(result.join(''));
- return remainingArgs;
-}
-
-function __formatted(object, formatChar) {
-
- try {
- switch(formatChar) {
- case 'j':
- case 'o': return JSON.stringify(object);
- case 'c': return '';
- }
- }
- catch (e) {
- return "error JSON.stringify()ing argument: " + e;
- }
-
- if ((object === null) || (object === undefined)) {
- return Object.prototype.toString.call(object);
- }
-
- return object.toString();
-}
-
-
-//------------------------------------------------------------------------------
-// when deviceready fires, log queued messages
-logger.__onDeviceReady = function() {
- if (DeviceReady) return;
-
- DeviceReady = true;
-
- for (var i=0; i<Queued.length; i++) {
- var messageArgs = Queued[i];
- logger.logLevel(messageArgs[0], messageArgs[1]);
- }
-
- Queued = null;
-};
-
-// add a deviceready event to log queued messages
-document.addEventListener("deviceready", logger.__onDeviceReady, false);
-
-});
-
-// file: lib/common/plugin/logger/symbols.js
-define("cordova/plugin/logger/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/logger', 'cordova.logger');
-
-});
-
-// file: lib/ios/plugin/media/symbols.js
-define("cordova/plugin/media/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Media', 'Media');
-modulemapper.clobbers('cordova/plugin/MediaError', 'MediaError');
-
-});
-
-// file: lib/common/plugin/network.js
-define("cordova/plugin/network", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- cordova = require('cordova'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils');
-
-// Link the onLine property with the Cordova-supplied network info.
-// This works because we clobber the naviagtor object with our own
-// object in bootstrap.js.
-if (typeof navigator != 'undefined') {
- utils.defineGetter(navigator, 'onLine', function() {
- return this.connection.type != 'none';
- });
-}
-
-function NetworkConnection() {
- this.type = 'unknown';
-}
-
-/**
- * Get connection info
- *
- * @param {Function} successCallback The function to call when the Connection data is available
- * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
- */
-NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
-};
-
-var me = new NetworkConnection();
-var timerId = null;
-var timeout = 500;
-
-channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- me.type = info;
- if (info === "none") {
- // set a timer if still offline at the end of timer send the offline event
- timerId = setTimeout(function(){
- cordova.fireDocumentEvent("offline");
- timerId = null;
- }, timeout);
- } else {
- // If there is a current offline event pending clear it
- if (timerId !== null) {
- clearTimeout(timerId);
- timerId = null;
- }
- cordova.fireDocumentEvent("online");
- }
-
- // should only fire this once
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- },
- function (e) {
- // If we can't get the network info we should still tell Cordova
- // to fire the deviceready event.
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- console.log("Error initializing Network Connection: " + e);
- });
-});
-
-module.exports = me;
-
-});
-
-// file: lib/common/plugin/networkstatus/symbols.js
-define("cordova/plugin/networkstatus/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/network', 'navigator.network.connection', 'navigator.network.connection is deprecated. Use navigator.connection instead.');
-modulemapper.clobbers('cordova/plugin/network', 'navigator.connection');
-modulemapper.defaults('cordova/plugin/Connection', 'Connection');
-
-});
-
-// file: lib/common/plugin/notification.js
-define("cordova/plugin/notification", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var platform = require('cordova/platform');
-
-/**
- * Provides access to notifications on the device.
- */
-
-module.exports = {
-
- /**
- * Open a native alert dialog, with a customizable title and button text.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} completeCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Alert)
- * @param {String} buttonLabel Label of the close button (default: OK)
- */
- alert: function(message, completeCallback, title, buttonLabel) {
- var _title = (title || "Alert");
- var _buttonLabel = (buttonLabel || "OK");
- exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
- },
-
- /**
- * Open a native confirm dialog, with a customizable title and button text.
- * The result that the user selects is returned to the result callback.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Confirm)
- * @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel'])
- */
- confirm: function(message, resultCallback, title, buttonLabels) {
- var _title = (title || "Confirm");
- var _buttonLabels = (buttonLabels || ["OK", "Cancel"]);
-
- // Strings are deprecated!
- if (typeof _buttonLabels === 'string') {
- console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).");
- }
-
- // Some platforms take an array of button label names.
- // Other platforms take a comma separated list.
- // For compatibility, we convert to the desired type based on the platform.
- if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone" || platform.id == "blackberry10") {
- if (typeof _buttonLabels === 'string') {
- var buttonLabelString = _buttonLabels;
- _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
- }
- } else {
- if (Array.isArray(_buttonLabels)) {
- var buttonLabelArray = _buttonLabels;
- _buttonLabels = buttonLabelArray.toString();
- }
- }
- exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
- },
-
- /**
- * Open a native prompt dialog, with a customizable title and button text.
- * The following results are returned to the result callback:
- * buttonIndex Index number of the button selected.
- * input1 The text entered in the prompt dialog box.
- *
- * @param {String} message Dialog message to display (default: "Prompt message")
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the dialog (default: "Prompt")
- * @param {Array} buttonLabels Array of strings for the button labels (default: ["OK","Cancel"])
- * @param {String} defaultText Textbox input value (default: "Default text")
- */
- prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
- var _message = (message || "Prompt message");
- var _title = (title || "Prompt");
- var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
- var _defaultText = (defaultText || "Default text");
- exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);
- },
-
- /**
- * Causes the device to vibrate.
- *
- * @param {Integer} mills The number of milliseconds to vibrate for.
- */
- vibrate: function(mills) {
- exec(null, null, "Notification", "vibrate", [mills]);
- },
-
- /**
- * Causes the device to beep.
- * On Android, the default notification ringtone is played "count" times.
- *
- * @param {Integer} count The number of beeps.
- */
- beep: function(count) {
- exec(null, null, "Notification", "beep", [count]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/notification/symbols.js
-define("cordova/plugin/notification/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/notification', 'navigator.notification');
-modulemapper.merges('cordova/plugin/ios/notification', 'navigator.notification');
-
-});
-
-// file: lib/common/plugin/requestFileSystem.js
-define("cordova/plugin/requestFileSystem", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- FileError = require('cordova/plugin/FileError'),
- FileSystem = require('cordova/plugin/FileSystem'),
- exec = require('cordova/exec');
-
-/**
- * Request a file system in which to store application data.
- * @param type local file system type
- * @param size indicates how much storage space, in bytes, the application expects to need
- * @param successCallback invoked with a FileSystem object
- * @param errorCallback invoked if error occurs retrieving file system
- */
-var requestFileSystem = function(type, size, successCallback, errorCallback) {
- argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
- var fail = function(code) {
- errorCallback && errorCallback(new FileError(code));
- };
-
- if (type < 0 || type > 3) {
- fail(FileError.SYNTAX_ERR);
- } else {
- // if successful, return a FileSystem object
- var success = function(file_system) {
- if (file_system) {
- if (successCallback) {
- // grab the name and root from the file system object
- var result = new FileSystem(file_system.name, file_system.root);
- successCallback(result);
- }
- }
- else {
- // no FileSystem object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
- exec(success, fail, "File", "requestFileSystem", [type, size]);
- }
-};
-
-module.exports = requestFileSystem;
-
-});
-
-// file: lib/common/plugin/resolveLocalFileSystemURI.js
-define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileError = require('cordova/plugin/FileError'),
- exec = require('cordova/exec');
-
-/**
- * Look up file system Entry referred to by local URI.
- * @param {DOMString} uri URI referring to a local file or directory
- * @param successCallback invoked with Entry object corresponding to URI
- * @param errorCallback invoked if error occurs retrieving file system entry
- */
-module.exports = function(uri, successCallback, errorCallback) {
- argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
- // error callback
- var fail = function(error) {
- errorCallback && errorCallback(new FileError(error));
- };
- // sanity check for 'not:valid:filename'
- if(!uri || uri.split(":").length > 2) {
- setTimeout( function() {
- fail(FileError.ENCODING_ERR);
- },0);
- return;
- }
- // if successful, return either a file or directory entry
- var success = function(entry) {
- var result;
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
-};
-
-});
-
-// file: lib/common/plugin/splashscreen.js
-define("cordova/plugin/splashscreen", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-var splashscreen = {
- show:function() {
- exec(null, null, "SplashScreen", "show", []);
- },
- hide:function() {
- exec(null, null, "SplashScreen", "hide", []);
- }
-};
-
-module.exports = splashscreen;
-
-});
-
-// file: lib/common/plugin/splashscreen/symbols.js
-define("cordova/plugin/splashscreen/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/splashscreen', 'navigator.splashscreen');
-
-});
-
-// file: lib/common/symbols.js
-define("cordova/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-// Use merges here in case others symbols files depend on this running first,
-// but fail to declare the dependency with a require().
-modulemapper.merges('cordova', 'cordova');
-modulemapper.clobbers('cordova/exec', 'cordova.exec');
-modulemapper.clobbers('cordova/exec', 'Cordova.exec');
-
-});
-
-// file: lib/common/utils.js
-define("cordova/utils", function(require, exports, module) {
-
-var utils = exports;
-
-/**
- * Defines a property getter / setter for obj[key].
- */
-utils.defineGetterSetter = function(obj, key, getFunc, opt_setFunc) {
- if (Object.defineProperty) {
- var desc = {
- get: getFunc,
- configurable: true
- };
- if (opt_setFunc) {
- desc.set = opt_setFunc;
- }
- Object.defineProperty(obj, key, desc);
- } else {
- obj.__defineGetter__(key, getFunc);
- if (opt_setFunc) {
- obj.__defineSetter__(key, opt_setFunc);
- }
- }
-};
-
-/**
- * Defines a property getter for obj[key].
- */
-utils.defineGetter = utils.defineGetterSetter;
-
-utils.arrayIndexOf = function(a, item) {
- if (a.indexOf) {
- return a.indexOf(item);
- }
- var len = a.length;
- for (var i = 0; i < len; ++i) {
- if (a[i] == item) {
- return i;
- }
- }
- return -1;
-};
-
-/**
- * Returns whether the item was found in the array.
- */
-utils.arrayRemove = function(a, item) {
- var index = utils.arrayIndexOf(a, item);
- if (index != -1) {
- a.splice(index, 1);
- }
- return index != -1;
-};
-
-utils.typeName = function(val) {
- return Object.prototype.toString.call(val).slice(8, -1);
-};
-
-/**
- * Returns an indication of whether the argument is an array or not
- */
-utils.isArray = function(a) {
- return utils.typeName(a) == 'Array';
-};
-
-/**
- * Returns an indication of whether the argument is a Date or not
- */
-utils.isDate = function(d) {
- return utils.typeName(d) == 'Date';
-};
-
-/**
- * Does a deep clone of the object.
- */
-utils.clone = function(obj) {
- if(!obj || typeof obj == 'function' || utils.isDate(obj) || typeof obj != 'object') {
- return obj;
- }
-
- var retVal, i;
-
- if(utils.isArray(obj)){
- retVal = [];
- for(i = 0; i < obj.length; ++i){
- retVal.push(utils.clone(obj[i]));
- }
- return retVal;
- }
-
- retVal = {};
- for(i in obj){
- if(!(i in retVal) || retVal[i] != obj[i]) {
- retVal[i] = utils.clone(obj[i]);
- }
- }
- return retVal;
-};
-
-/**
- * Returns a wrapped version of the function
- */
-utils.close = function(context, func, params) {
- if (typeof params == 'undefined') {
- return function() {
- return func.apply(context, arguments);
- };
- } else {
- return function() {
- return func.apply(context, params);
- };
- }
-};
-
-/**
- * Create a UUID
- */
-utils.createUUID = function() {
- return UUIDcreatePart(4) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(6);
-};
-
-/**
- * Extends a child object from a parent object using classical inheritance
- * pattern.
- */
-utils.extend = (function() {
- // proxy used to establish prototype chain
- var F = function() {};
- // extend Child from Parent
- return function(Child, Parent) {
- F.prototype = Parent.prototype;
- Child.prototype = new F();
- Child.__super__ = Parent.prototype;
- Child.prototype.constructor = Child;
- };
-}());
-
-/**
- * Alerts a message in any available way: alert or console.log.
- */
-utils.alert = function(msg) {
- if (window.alert) {
- window.alert(msg);
- } else if (console && console.log) {
- console.log(msg);
- }
-};
-
-
-//------------------------------------------------------------------------------
-function UUIDcreatePart(length) {
- var uuidpart = "";
- for (var i=0; i<length; i++) {
- var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
- if (uuidchar.length == 1) {
- uuidchar = "0" + uuidchar;
- }
- uuidpart += uuidchar;
- }
- return uuidpart;
-}
-
-
-});
-
-window.cordova = require('cordova');
-// file: lib/scripts/bootstrap.js
-
-(function (context) {
- if (context._cordovaJsLoaded) {
- throw new Error('cordova.js included multiple times.');
- }
- context._cordovaJsLoaded = true;
-
- var channel = require('cordova/channel');
- var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
-
- function logUnfiredChannels(arr) {
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i].state != 2) {
- console.log('Channel not fired: ' + arr[i].type);
- }
- }
- }
-
- window.setTimeout(function() {
- if (channel.onDeviceReady.state != 2) {
- console.log('deviceready has not fired after 5 seconds.');
- logUnfiredChannels(platformInitChannelsArray);
- logUnfiredChannels(channel.deviceReadyChannelsArray);
- }
- }, 5000);
-
- // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
- // We replace it so that properties that can't be clobbered can instead be overridden.
- function replaceNavigator(origNavigator) {
- var CordovaNavigator = function() {};
- CordovaNavigator.prototype = origNavigator;
- var newNavigator = new CordovaNavigator();
- // This work-around really only applies to new APIs that are newer than Function.bind.
- // Without it, APIs such as getGamepads() break.
- if (CordovaNavigator.bind) {
- for (var key in origNavigator) {
- if (typeof origNavigator[key] == 'function') {
- newNavigator[key] = origNavigator[key].bind(origNavigator);
- }
- }
- }
- return newNavigator;
- }
- if (context.navigator) {
- context.navigator = replaceNavigator(context.navigator);
- }
-
- // _nativeReady is global variable that the native side can set
- // to signify that the native code is ready. It is a global since
- // it may be called before any cordova JS is ready.
- if (window._nativeReady) {
- channel.onNativeReady.fire();
- }
-
- /**
- * Create all cordova objects once native side is ready.
- */
- channel.join(function() {
- // Call the platform-specific initialization
- require('cordova/platform').initialize();
-
- // Fire event to notify that all objects are created
- channel.onCordovaReady.fire();
-
- // Fire onDeviceReady event once page has fully loaded, all
- // constructors have run and cordova info has been received from native
- // side.
- // This join call is deliberately made after platform.initialize() in
- // order that plugins may manipulate channel.deviceReadyChannelsArray
- // if necessary.
- channel.join(function() {
- require('cordova').fireDocumentEvent('deviceready');
- }, channel.deviceReadyChannelsArray);
-
- }, platformInitChannelsArray);
-
-}(window));
-
-// file: lib/scripts/bootstrap-ios.js
-
-require('cordova/channel').onNativeReady.fire();
-
-// file: lib/scripts/plugin_loader.js
-
-// Tries to load all plugins' js-modules.
-// This is an async process, but onDeviceReady is blocked on onPluginsReady.
-// onPluginsReady is fired when there are no plugins to load, or they are all done.
-(function (context) {
- // To be populated with the handler by handlePluginsObject.
- var onScriptLoadingComplete;
-
- var scriptCounter = 0;
- function scriptLoadedCallback() {
- scriptCounter--;
- if (scriptCounter === 0) {
- onScriptLoadingComplete && onScriptLoadingComplete();
- }
- }
-
- function scriptErrorCallback(err) {
- // Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
- // this is currently just continuing.
- scriptCounter--;
- if (scriptCounter === 0) {
- onScriptLoadingComplete && onScriptLoadingComplete();
- }
- }
-
- // Helper function to inject a <script> tag.
- function injectScript(path) {
- scriptCounter++;
- var script = document.createElement("script");
- script.onload = scriptLoadedCallback;
- script.onerror = scriptErrorCallback;
- script.src = path;
- document.head.appendChild(script);
- }
-
- // Called when:
- // * There are plugins defined and all plugins are finished loading.
- // * There are no plugins to load.
- function finishPluginLoading() {
- context.cordova.require('cordova/channel').onPluginsReady.fire();
- }
-
- // Handler for the cordova_plugins.js content.
- // See plugman's plugin_loader.js for the details of this object.
- // This function is only called if the really is a plugins array that isn't empty.
- // Otherwise the onerror response handler will just call finishPluginLoading().
- function handlePluginsObject(modules, path) {
- // First create the callback for when all plugins are loaded.
- var mapper = context.cordova.require('cordova/modulemapper');
- onScriptLoadingComplete = function() {
- // Loop through all the plugins and then through their clobbers and merges.
- for (var i = 0; i < modules.length; i++) {
- var module = modules[i];
- if (module) {
- try {
- if (module.clobbers && module.clobbers.length) {
- for (var j = 0; j < module.clobbers.length; j++) {
- mapper.clobbers(module.id, module.clobbers[j]);
- }
- }
-
- if (module.merges && module.merges.length) {
- for (var k = 0; k < module.merges.length; k++) {
- mapper.merges(module.id, module.merges[k]);
- }
- }
-
- // Finally, if runs is truthy we want to simply require() the module.
- // This can be skipped if it had any merges or clobbers, though,
- // since the mapper will already have required the module.
- if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
- context.cordova.require(module.id);
- }
- }
- catch(err) {
- // error with module, most likely clobbers, should we continue?
- }
- }
- }
-
- finishPluginLoading();
- };
-
- // Now inject the scripts.
- for (var i = 0; i < modules.length; i++) {
- injectScript(path + modules[i].file);
- }
- }
-
- // Find the root of the app
- var path = '';
- var scripts = document.getElementsByTagName('script');
- var term = 'cordova.js';
- for (var n = scripts.length-1; n>-1; n--) {
- var src = scripts[n].src;
- if (src.indexOf(term) == (src.length - term.length)) {
- path = src.substring(0, src.length - term.length);
- break;
- }
- }
-
- var plugins_json = path + 'cordova_plugins.json';
- var plugins_js = path + 'cordova_plugins.js';
-
- // One some phones (Windows) this xhr.open throws an Access Denied exception
- // So lets keep trying, but with a script tag injection technique instead of XHR
- var injectPluginScript = function injectPluginScript() {
- try {
- var script = document.createElement("script");
- script.onload = function(){
- var list = cordova.require("cordova/plugin_list");
- handlePluginsObject(list,path);
- };
- script.onerror = function() {
- // Error loading cordova_plugins.js, file not found or something
- // this is an acceptable error, pre-3.0.0, so we just move on.
- finishPluginLoading();
- };
- script.src = plugins_js;
- document.head.appendChild(script);
-
- } catch(err){
- finishPluginLoading();
- }
- }
-
-
- // Try to XHR the cordova_plugins.json file asynchronously.
- var xhr = new XMLHttpRequest();
- xhr.onload = function() {
- // If the response is a JSON string which composes an array, call handlePluginsObject.
- // If the request fails, or the response is not a JSON array, just call finishPluginLoading.
- var obj;
- try {
- obj = (this.status == 0 || this.status == 200) && this.responseText && JSON.parse(this.responseText);
- } catch (err) {
- // obj will be undefined.
- }
- if (Array.isArray(obj) && obj.length > 0) {
- handlePluginsObject(obj, path);
- } else {
- finishPluginLoading();
- }
- };
- xhr.onerror = function() {
- // In this case, the json file was not present, but XHR was allowed,
- // so we should still try the script injection technique with the js file
- // in case that is there.
- injectPluginScript();
- };
- try { // we commented we were going to try, so let us actually try and catch
- xhr.open('GET', plugins_json, true); // Async
- xhr.send();
- } catch(err){
- injectPluginScript();
- }
-}(window));
-
-
-})();var PhoneGap = cordova;
diff --git a/iPhone/FixMyStreet.xcodeproj/project.pbxproj b/iPhone/FixMyStreet.xcodeproj/project.pbxproj
deleted file mode 100644
index 2016103..0000000
--- a/iPhone/FixMyStreet.xcodeproj/project.pbxproj
+++ /dev/null
@@ -1,694 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 46;
- objects = {
-
-/* Begin PBXBuildFile section */
- 1D3623260D0F684500981E51 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* AppDelegate.m */; };
- 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
- 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
- 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
- 1F766FE113BBADB100FB74C0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1F766FDC13BBADB100FB74C0 /* Localizable.strings */; };
- 1F766FE213BBADB100FB74C0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1F766FDF13BBADB100FB74C0 /* Localizable.strings */; };
- 2425571F178DA08700E2E208 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2425571E178DA08700E2E208 /* ImageIO.framework */; };
- 24255721178DA08D00E2E208 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24255720178DA08D00E2E208 /* OpenAL.framework */; };
- 244F330B1774574C00699B27 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 244F330A1774574C00699B27 /* Default.png */; };
- 244F330D1774575000699B27 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 244F330C1774575000699B27 /* Default@2x.png */; };
- 244F330F17746FC200699B27 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 244F330E17746FC200699B27 /* Default-568h@2x.png */; };
- 246C8F801700A4010052666F /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 246C8F7F1700A4010052666F /* AssetsLibrary.framework */; };
- 24CD373C17FC3F91008BFB5C /* fms-Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 24CD373817FC3F91008BFB5C /* fms-Icon-120.png */; };
- 24CD373D17FC3F91008BFB5C /* fms-Icon-Small-29.png in Resources */ = {isa = PBXBuildFile; fileRef = 24CD373917FC3F91008BFB5C /* fms-Icon-Small-29.png */; };
- 24CD373E17FC3F91008BFB5C /* fms-Icon-Small-29@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 24CD373A17FC3F91008BFB5C /* fms-Icon-Small-29@2x.png */; };
- 24CD374117FC3FCE008BFB5C /* fms-Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 24CD373F17FC3FCE008BFB5C /* fms-Icon.png */; };
- 24CD374217FC3FCE008BFB5C /* fms-Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 24CD374017FC3FCE008BFB5C /* fms-Icon@2x.png */; };
- 24CD374417FC411D008BFB5C /* fms-Icon-80.png in Resources */ = {isa = PBXBuildFile; fileRef = 24CD374317FC411D008BFB5C /* fms-Icon-80.png */; };
- 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
- 301BF552109A68D80062928A /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF535109A57CC0062928A /* libCordova.a */; };
- 301BF570109A69640062928A /* www in Resources */ = {isa = PBXBuildFile; fileRef = 301BF56E109A69640062928A /* www */; };
- 301BF5B5109A6A2B0062928A /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5B4109A6A2B0062928A /* AddressBook.framework */; };
- 301BF5B7109A6A2B0062928A /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5B6109A6A2B0062928A /* AddressBookUI.framework */; };
- 301BF5B9109A6A2B0062928A /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5B8109A6A2B0062928A /* AudioToolbox.framework */; };
- 301BF5BB109A6A2B0062928A /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5BA109A6A2B0062928A /* AVFoundation.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
- 301BF5BD109A6A2B0062928A /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5BC109A6A2B0062928A /* CFNetwork.framework */; };
- 301BF5BF109A6A2B0062928A /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5BE109A6A2B0062928A /* CoreLocation.framework */; };
- 301BF5C1109A6A2B0062928A /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5C0109A6A2B0062928A /* MediaPlayer.framework */; };
- 301BF5C3109A6A2B0062928A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5C2109A6A2B0062928A /* QuartzCore.framework */; };
- 301BF5C5109A6A2B0062928A /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5C4109A6A2B0062928A /* SystemConfiguration.framework */; };
- 302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; };
- 302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 302D95F014D2391D003F00A1 /* MainViewController.xib */; };
- 305D5FD1115AB8F900A74A75 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */; };
- 3072F99713A8081B00425683 /* Capture.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 3072F99613A8081B00425683 /* Capture.bundle */; };
- 30A0434814DC770100060A13 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30A0434314DC770100060A13 /* Localizable.strings */; };
- 30A0434914DC770100060A13 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30A0434614DC770100060A13 /* Localizable.strings */; };
- 30E5649213A7FCAF007403D8 /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30E5649113A7FCAF007403D8 /* CoreMedia.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
- F840E1F1165FE0F500CFE078 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = F840E1F0165FE0F500CFE078 /* config.xml */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXContainerItemProxy section */
- 301BF534109A57CC0062928A /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */;
- proxyType = 2;
- remoteGlobalIDString = D2AAC07E0554694100DB518D;
- remoteInfo = CordovaLib;
- };
- 301BF550109A68C00062928A /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = D2AAC07D0554694100DB518D;
- remoteInfo = CordovaLib;
- };
-/* End PBXContainerItemProxy section */
-
-/* Begin PBXFileReference section */
- 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
- 1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
- 1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
- 1D6058910D05DD3D006BFB54 /* FixMyStreet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FixMyStreet.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
- 1F766FDD13BBADB100FB74C0 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Localizable.strings; sourceTree = "<group>"; };
- 1F766FE013BBADB100FB74C0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = Localizable.strings; sourceTree = "<group>"; };
- 2425571E178DA08700E2E208 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; };
- 24255720178DA08D00E2E208 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
- 244F330A1774574C00699B27 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
- 244F330C1774575000699B27 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
- 244F330E17746FC200699B27 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
- 246C8F7F1700A4010052666F /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
- 24CD373817FC3F91008BFB5C /* fms-Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fms-Icon-120.png"; sourceTree = "<group>"; };
- 24CD373917FC3F91008BFB5C /* fms-Icon-Small-29.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fms-Icon-Small-29.png"; sourceTree = "<group>"; };
- 24CD373A17FC3F91008BFB5C /* fms-Icon-Small-29@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fms-Icon-Small-29@2x.png"; sourceTree = "<group>"; };
- 24CD373F17FC3FCE008BFB5C /* fms-Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fms-Icon.png"; sourceTree = "<group>"; };
- 24CD374017FC3FCE008BFB5C /* fms-Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fms-Icon@2x.png"; sourceTree = "<group>"; };
- 24CD374317FC411D008BFB5C /* fms-Icon-80.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fms-Icon-80.png"; sourceTree = "<group>"; };
- 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
- 301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; };
- 301BF56E109A69640062928A /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = SOURCE_ROOT; };
- 301BF5B4109A6A2B0062928A /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
- 301BF5B6109A6A2B0062928A /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; };
- 301BF5B8109A6A2B0062928A /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
- 301BF5BA109A6A2B0062928A /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
- 301BF5BC109A6A2B0062928A /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
- 301BF5BE109A6A2B0062928A /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
- 301BF5C0109A6A2B0062928A /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
- 301BF5C2109A6A2B0062928A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
- 301BF5C4109A6A2B0062928A /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
- 302D95EE14D2391D003F00A1 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
- 302D95EF14D2391D003F00A1 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
- 302D95F014D2391D003F00A1 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = "<group>"; };
- 305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
- 3072F99613A8081B00425683 /* Capture.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Capture.bundle; sourceTree = "<group>"; };
- 3088BBB7154F3926009F9C59 /* Default-Landscape@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape@2x~ipad.png"; sourceTree = "<group>"; };
- 3088BBB8154F3926009F9C59 /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape~ipad.png"; sourceTree = "<group>"; };
- 3088BBB9154F3926009F9C59 /* Default-Portrait@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait@2x~ipad.png"; sourceTree = "<group>"; };
- 3088BBBA154F3926009F9C59 /* Default-Portrait~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait~ipad.png"; sourceTree = "<group>"; };
- 3088BBBB154F3926009F9C59 /* Default@2x~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x~iphone.png"; sourceTree = "<group>"; };
- 3088BBBC154F3926009F9C59 /* Default~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default~iphone.png"; sourceTree = "<group>"; };
- 30A0434414DC770100060A13 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = Localizable.strings; sourceTree = "<group>"; };
- 30A0434714DC770100060A13 /* se */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = se; path = Localizable.strings; sourceTree = "<group>"; };
- 30E5649113A7FCAF007403D8 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
- 32CA4F630368D1EE00C91783 /* FixMyStreet-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FixMyStreet-Prefix.pch"; sourceTree = "<group>"; };
- 8D1107310486CEB800E47090 /* FixMyStreet-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "FixMyStreet-Info.plist"; path = "../FixMyStreet-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = "<group>"; };
- D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x~iphone.png"; sourceTree = "<group>"; };
- F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = FixMyStreet/config.xml; sourceTree = "<group>"; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
- 1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
- isa = PBXFrameworksBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 24255721178DA08D00E2E208 /* OpenAL.framework in Frameworks */,
- 2425571F178DA08700E2E208 /* ImageIO.framework in Frameworks */,
- 246C8F801700A4010052666F /* AssetsLibrary.framework in Frameworks */,
- 301BF552109A68D80062928A /* libCordova.a in Frameworks */,
- 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
- 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
- 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */,
- 301BF5B5109A6A2B0062928A /* AddressBook.framework in Frameworks */,
- 301BF5B7109A6A2B0062928A /* AddressBookUI.framework in Frameworks */,
- 301BF5B9109A6A2B0062928A /* AudioToolbox.framework in Frameworks */,
- 301BF5BB109A6A2B0062928A /* AVFoundation.framework in Frameworks */,
- 301BF5BD109A6A2B0062928A /* CFNetwork.framework in Frameworks */,
- 301BF5BF109A6A2B0062928A /* CoreLocation.framework in Frameworks */,
- 301BF5C1109A6A2B0062928A /* MediaPlayer.framework in Frameworks */,
- 301BF5C3109A6A2B0062928A /* QuartzCore.framework in Frameworks */,
- 301BF5C5109A6A2B0062928A /* SystemConfiguration.framework in Frameworks */,
- 305D5FD1115AB8F900A74A75 /* MobileCoreServices.framework in Frameworks */,
- 30E5649213A7FCAF007403D8 /* CoreMedia.framework in Frameworks */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
- 080E96DDFE201D6D7F000001 /* Classes */ = {
- isa = PBXGroup;
- children = (
- 302D95EE14D2391D003F00A1 /* MainViewController.h */,
- 302D95EF14D2391D003F00A1 /* MainViewController.m */,
- 302D95F014D2391D003F00A1 /* MainViewController.xib */,
- 1D3623240D0F684500981E51 /* AppDelegate.h */,
- 1D3623250D0F684500981E51 /* AppDelegate.m */,
- );
- name = Classes;
- path = FixMyStreet/Classes;
- sourceTree = SOURCE_ROOT;
- };
- 19C28FACFE9D520D11CA2CBB /* Products */ = {
- isa = PBXGroup;
- children = (
- 1D6058910D05DD3D006BFB54 /* FixMyStreet.app */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- 1F766FDB13BBADB100FB74C0 /* en.lproj */ = {
- isa = PBXGroup;
- children = (
- 1F766FDC13BBADB100FB74C0 /* Localizable.strings */,
- );
- path = en.lproj;
- sourceTree = "<group>";
- };
- 1F766FDE13BBADB100FB74C0 /* es.lproj */ = {
- isa = PBXGroup;
- children = (
- 1F766FDF13BBADB100FB74C0 /* Localizable.strings */,
- );
- path = es.lproj;
- sourceTree = "<group>";
- };
- 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
- isa = PBXGroup;
- children = (
- 24255720178DA08D00E2E208 /* OpenAL.framework */,
- 2425571E178DA08700E2E208 /* ImageIO.framework */,
- 244F330E17746FC200699B27 /* Default-568h@2x.png */,
- 244F330C1774575000699B27 /* Default@2x.png */,
- 244F330A1774574C00699B27 /* Default.png */,
- 246C8F7F1700A4010052666F /* AssetsLibrary.framework */,
- F840E1F0165FE0F500CFE078 /* config.xml */,
- 301BF56E109A69640062928A /* www */,
- 301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */,
- 080E96DDFE201D6D7F000001 /* Classes */,
- 307C750510C5A3420062BCA9 /* Plugins */,
- 29B97315FDCFA39411CA2CEA /* Other Sources */,
- 29B97317FDCFA39411CA2CEA /* Resources */,
- 29B97323FDCFA39411CA2CEA /* Frameworks */,
- 19C28FACFE9D520D11CA2CBB /* Products */,
- );
- name = CustomTemplate;
- sourceTree = "<group>";
- };
- 29B97315FDCFA39411CA2CEA /* Other Sources */ = {
- isa = PBXGroup;
- children = (
- 32CA4F630368D1EE00C91783 /* FixMyStreet-Prefix.pch */,
- 29B97316FDCFA39411CA2CEA /* main.m */,
- );
- name = "Other Sources";
- path = FixMyStreet;
- sourceTree = "<group>";
- };
- 29B97317FDCFA39411CA2CEA /* Resources */ = {
- isa = PBXGroup;
- children = (
- 30A0434214DC770100060A13 /* de.lproj */,
- 30A0434514DC770100060A13 /* se.lproj */,
- 1F766FDB13BBADB100FB74C0 /* en.lproj */,
- 1F766FDE13BBADB100FB74C0 /* es.lproj */,
- 3072F99613A8081B00425683 /* Capture.bundle */,
- 308D052D1370CCF300D202BF /* icons */,
- 308D05311370CCF300D202BF /* splash */,
- 8D1107310486CEB800E47090 /* FixMyStreet-Info.plist */,
- );
- name = Resources;
- path = FixMyStreet/Resources;
- sourceTree = "<group>";
- };
- 29B97323FDCFA39411CA2CEA /* Frameworks */ = {
- isa = PBXGroup;
- children = (
- 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
- 1D30AB110D05D00D00671497 /* Foundation.framework */,
- 288765FC0DF74451002DB57D /* CoreGraphics.framework */,
- 301BF5B4109A6A2B0062928A /* AddressBook.framework */,
- 301BF5B6109A6A2B0062928A /* AddressBookUI.framework */,
- 301BF5B8109A6A2B0062928A /* AudioToolbox.framework */,
- 301BF5BA109A6A2B0062928A /* AVFoundation.framework */,
- 301BF5BC109A6A2B0062928A /* CFNetwork.framework */,
- 301BF5BE109A6A2B0062928A /* CoreLocation.framework */,
- 301BF5C0109A6A2B0062928A /* MediaPlayer.framework */,
- 301BF5C2109A6A2B0062928A /* QuartzCore.framework */,
- 301BF5C4109A6A2B0062928A /* SystemConfiguration.framework */,
- 305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */,
- 30E5649113A7FCAF007403D8 /* CoreMedia.framework */,
- );
- name = Frameworks;
- sourceTree = "<group>";
- };
- 301BF52E109A57CC0062928A /* Products */ = {
- isa = PBXGroup;
- children = (
- 301BF535109A57CC0062928A /* libCordova.a */,
- );
- name = Products;
- sourceTree = "<group>";
- };
- 307C750510C5A3420062BCA9 /* Plugins */ = {
- isa = PBXGroup;
- children = (
- );
- name = Plugins;
- path = FixMyStreet/Plugins;
- sourceTree = SOURCE_ROOT;
- };
- 308D052D1370CCF300D202BF /* icons */ = {
- isa = PBXGroup;
- children = (
- 24CD373F17FC3FCE008BFB5C /* fms-Icon.png */,
- 24CD374317FC411D008BFB5C /* fms-Icon-80.png */,
- 24CD374017FC3FCE008BFB5C /* fms-Icon@2x.png */,
- 24CD373817FC3F91008BFB5C /* fms-Icon-120.png */,
- 24CD373917FC3F91008BFB5C /* fms-Icon-Small-29.png */,
- 24CD373A17FC3F91008BFB5C /* fms-Icon-Small-29@2x.png */,
- );
- path = icons;
- sourceTree = "<group>";
- };
- 308D05311370CCF300D202BF /* splash */ = {
- isa = PBXGroup;
- children = (
- D4A0D8751607E02300AEF8BB /* Default-568h@2x~iphone.png */,
- 3088BBB7154F3926009F9C59 /* Default-Landscape@2x~ipad.png */,
- 3088BBB8154F3926009F9C59 /* Default-Landscape~ipad.png */,
- 3088BBB9154F3926009F9C59 /* Default-Portrait@2x~ipad.png */,
- 3088BBBA154F3926009F9C59 /* Default-Portrait~ipad.png */,
- 3088BBBB154F3926009F9C59 /* Default@2x~iphone.png */,
- 3088BBBC154F3926009F9C59 /* Default~iphone.png */,
- );
- path = splash;
- sourceTree = "<group>";
- };
- 30A0434214DC770100060A13 /* de.lproj */ = {
- isa = PBXGroup;
- children = (
- 30A0434314DC770100060A13 /* Localizable.strings */,
- );
- path = de.lproj;
- sourceTree = "<group>";
- };
- 30A0434514DC770100060A13 /* se.lproj */ = {
- isa = PBXGroup;
- children = (
- 30A0434614DC770100060A13 /* Localizable.strings */,
- );
- path = se.lproj;
- sourceTree = "<group>";
- };
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
- 1D6058900D05DD3D006BFB54 /* FixMyStreet */ = {
- isa = PBXNativeTarget;
- buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FixMyStreet" */;
- buildPhases = (
- 304B58A110DAC018002A0835 /* Touch www folder */,
- 1D60588D0D05DD3D006BFB54 /* Resources */,
- 1D60588E0D05DD3D006BFB54 /* Sources */,
- 1D60588F0D05DD3D006BFB54 /* Frameworks */,
- 246EF6D0178FFB6A006C1C4C /* ShellScript */,
- );
- buildRules = (
- );
- dependencies = (
- 301BF551109A68C00062928A /* PBXTargetDependency */,
- );
- name = FixMyStreet;
- productName = FixMyStreet;
- productReference = 1D6058910D05DD3D006BFB54 /* FixMyStreet.app */;
- productType = "com.apple.product-type.application";
- };
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
- 29B97313FDCFA39411CA2CEA /* Project object */ = {
- isa = PBXProject;
- attributes = {
- LastUpgradeCheck = 0500;
- TargetAttributes = {
- 1D6058900D05DD3D006BFB54 = {
- DevelopmentTeam = RK6M3EU4Y6;
- };
- };
- };
- buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FixMyStreet" */;
- compatibilityVersion = "Xcode 3.2";
- developmentRegion = English;
- hasScannedForEncodings = 1;
- knownRegions = (
- English,
- Japanese,
- French,
- German,
- en,
- es,
- de,
- se,
- );
- mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
- projectDirPath = "";
- projectReferences = (
- {
- ProductGroup = 301BF52E109A57CC0062928A /* Products */;
- ProjectRef = 301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */;
- },
- );
- projectRoot = "";
- targets = (
- 1D6058900D05DD3D006BFB54 /* FixMyStreet */,
- );
- };
-/* End PBXProject section */
-
-/* Begin PBXReferenceProxy section */
- 301BF535109A57CC0062928A /* libCordova.a */ = {
- isa = PBXReferenceProxy;
- fileType = archive.ar;
- path = libCordova.a;
- remoteRef = 301BF534109A57CC0062928A /* PBXContainerItemProxy */;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
-/* End PBXReferenceProxy section */
-
-/* Begin PBXResourcesBuildPhase section */
- 1D60588D0D05DD3D006BFB54 /* Resources */ = {
- isa = PBXResourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- F840E1F1165FE0F500CFE078 /* config.xml in Resources */,
- 24CD373E17FC3F91008BFB5C /* fms-Icon-Small-29@2x.png in Resources */,
- 301BF570109A69640062928A /* www in Resources */,
- 3072F99713A8081B00425683 /* Capture.bundle in Resources */,
- 1F766FE113BBADB100FB74C0 /* Localizable.strings in Resources */,
- 1F766FE213BBADB100FB74C0 /* Localizable.strings in Resources */,
- 302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */,
- 30A0434814DC770100060A13 /* Localizable.strings in Resources */,
- 24CD374417FC411D008BFB5C /* fms-Icon-80.png in Resources */,
- 24CD374117FC3FCE008BFB5C /* fms-Icon.png in Resources */,
- 30A0434914DC770100060A13 /* Localizable.strings in Resources */,
- 244F330B1774574C00699B27 /* Default.png in Resources */,
- 244F330D1774575000699B27 /* Default@2x.png in Resources */,
- 24CD373C17FC3F91008BFB5C /* fms-Icon-120.png in Resources */,
- 24CD374217FC3FCE008BFB5C /* fms-Icon@2x.png in Resources */,
- 244F330F17746FC200699B27 /* Default-568h@2x.png in Resources */,
- 24CD373D17FC3F91008BFB5C /* fms-Icon-Small-29.png in Resources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXShellScriptBuildPhase section */
- 246EF6D0178FFB6A006C1C4C /* ShellScript */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/bash;
- shellScript = "DIR_SRC=\"$PROJECT_DIR/../src\"\nDIR_DEST=\"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/www\"\nCOMMAND=(rsync -pvtrlL --cvs-exclude \"$DIR_SRC\" \"$DIR_DEST\")\n\n\"${COMMAND[@]}\"";
- };
- 304B58A110DAC018002A0835 /* Touch www folder */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "Touch www folder";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "touch -cm ${PROJECT_DIR}/www";
- };
-/* End PBXShellScriptBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
- 1D60588E0D05DD3D006BFB54 /* Sources */ = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 1D60589B0D05DD56006BFB54 /* main.m in Sources */,
- 1D3623260D0F684500981E51 /* AppDelegate.m in Sources */,
- 302D95F114D2391D003F00A1 /* MainViewController.m in Sources */,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXTargetDependency section */
- 301BF551109A68C00062928A /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- name = CordovaLib;
- targetProxy = 301BF550109A68C00062928A /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
-/* Begin PBXVariantGroup section */
- 1F766FDC13BBADB100FB74C0 /* Localizable.strings */ = {
- isa = PBXVariantGroup;
- children = (
- 1F766FDD13BBADB100FB74C0 /* en */,
- );
- name = Localizable.strings;
- sourceTree = "<group>";
- };
- 1F766FDF13BBADB100FB74C0 /* Localizable.strings */ = {
- isa = PBXVariantGroup;
- children = (
- 1F766FE013BBADB100FB74C0 /* es */,
- );
- name = Localizable.strings;
- sourceTree = "<group>";
- };
- 30A0434314DC770100060A13 /* Localizable.strings */ = {
- isa = PBXVariantGroup;
- children = (
- 30A0434414DC770100060A13 /* de */,
- );
- name = Localizable.strings;
- sourceTree = "<group>";
- };
- 30A0434614DC770100060A13 /* Localizable.strings */ = {
- isa = PBXVariantGroup;
- children = (
- 30A0434714DC770100060A13 /* se */,
- );
- name = Localizable.strings;
- sourceTree = "<group>";
- };
-/* End PBXVariantGroup section */
-
-/* Begin XCBuildConfiguration section */
- 1D6058940D05DD3E006BFB54 /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = (
- armv7,
- armv7s,
- );
- CLANG_ENABLE_OBJC_ARC = NO;
- CODE_SIGN_IDENTITY = "iPhone Developer";
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- COPY_PHASE_STRIP = NO;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_OPTIMIZATION_LEVEL = 0;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "FixMyStreet/FixMyStreet-Prefix.pch";
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- INFOPLIST_FILE = "FixMyStreet/FixMyStreet-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- OTHER_LDFLAGS = (
- "-weak_framework",
- CoreFoundation,
- "-weak_framework",
- UIKit,
- "-weak_framework",
- AVFoundation,
- "-weak_framework",
- CoreMedia,
- "-weak-lSystem",
- "-ObjC",
- );
- PRODUCT_NAME = FixMyStreet;
- PROVISIONING_PROFILE = "";
- "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
- TARGETED_DEVICE_FAMILY = 1;
- VALID_ARCHS = "armv7 armv7s";
- };
- name = Debug;
- };
- 1D6058950D05DD3E006BFB54 /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = (
- armv7,
- armv7s,
- );
- CLANG_ENABLE_OBJC_ARC = NO;
- CODE_SIGN_IDENTITY = "iPhone Distribution";
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
- COPY_PHASE_STRIP = YES;
- GCC_PRECOMPILE_PREFIX_HEADER = YES;
- GCC_PREFIX_HEADER = "FixMyStreet/FixMyStreet-Prefix.pch";
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- INFOPLIST_FILE = "FixMyStreet/FixMyStreet-Info.plist";
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- OTHER_LDFLAGS = (
- "-weak_framework",
- CoreFoundation,
- "-weak_framework",
- UIKit,
- "-weak_framework",
- AVFoundation,
- "-weak_framework",
- CoreMedia,
- "-weak-lSystem",
- "-ObjC",
- );
- PRODUCT_NAME = FixMyStreet;
- PROVISIONING_PROFILE = "";
- "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
- TARGETED_DEVICE_FAMILY = 1;
- VALID_ARCHS = "armv7 armv7s";
- };
- name = Release;
- };
- C01FCF4F08A954540054247B /* Debug */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- GCC_C_LANGUAGE_STANDARD = c99;
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = (
- "\"$(TARGET_BUILD_DIR)/usr/local/lib/include\"",
- "\"$(OBJROOT)/UninstalledProducts/include\"",
- "\"$(BUILT_PRODUCTS_DIR)\"",
- );
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- ONLY_ACTIVE_ARCH = YES;
- OTHER_LDFLAGS = (
- "-weak_framework",
- CoreFoundation,
- "-weak_framework",
- UIKit,
- "-weak_framework",
- AVFoundation,
- "-weak_framework",
- CoreMedia,
- "-weak-lSystem",
- "-all_load",
- "-Obj-C",
- );
- SDKROOT = iphoneos;
- SKIP_INSTALL = NO;
- USER_HEADER_SEARCH_PATHS = "";
- };
- name = Debug;
- };
- C01FCF5008A954540054247B /* Release */ = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CLANG_WARN_BOOL_CONVERSION = YES;
- CLANG_WARN_CONSTANT_CONVERSION = YES;
- CLANG_WARN_EMPTY_BODY = YES;
- CLANG_WARN_ENUM_CONVERSION = YES;
- CLANG_WARN_INT_CONVERSION = YES;
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
- "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
- GCC_C_LANGUAGE_STANDARD = c99;
- GCC_THUMB_SUPPORT = NO;
- GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
- GCC_WARN_ABOUT_RETURN_TYPE = YES;
- GCC_WARN_UNDECLARED_SELECTOR = YES;
- GCC_WARN_UNINITIALIZED_AUTOS = YES;
- GCC_WARN_UNUSED_FUNCTION = YES;
- GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = (
- "\"$(TARGET_BUILD_DIR)/usr/local/lib/include\"",
- "\"$(OBJROOT)/UninstalledProducts/include\"",
- "\"$(BUILT_PRODUCTS_DIR)\"",
- );
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
- OTHER_LDFLAGS = (
- "-weak_framework",
- CoreFoundation,
- "-weak_framework",
- UIKit,
- "-weak_framework",
- AVFoundation,
- "-weak_framework",
- CoreMedia,
- "-weak-lSystem",
- "-all_load",
- "-Obj-C",
- );
- SDKROOT = iphoneos;
- SKIP_INSTALL = NO;
- USER_HEADER_SEARCH_PATHS = "";
- };
- name = Release;
- };
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
- 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FixMyStreet" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 1D6058940D05DD3E006BFB54 /* Debug */,
- 1D6058950D05DD3E006BFB54 /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
- C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FixMyStreet" */ = {
- isa = XCConfigurationList;
- buildConfigurations = (
- C01FCF4F08A954540054247B /* Debug */,
- C01FCF5008A954540054247B /* Release */,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Release;
- };
-/* End XCConfigurationList section */
- };
- rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
-}
diff --git a/iPhone/FixMyStreet.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/iPhone/FixMyStreet.xcodeproj/project.xcworkspace/contents.xcworkspacedata
deleted file mode 100644
index f65be0e..0000000
--- a/iPhone/FixMyStreet.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Workspace
- version = "1.0">
- <FileRef
- location = "self:FixMyStreet.xcodeproj">
- </FileRef>
-</Workspace>
diff --git a/iPhone/FixMyStreet.xcodeproj/project.xcworkspace/xcshareddata/FixMyStreet.xccheckout b/iPhone/FixMyStreet.xcodeproj/project.xcworkspace/xcshareddata/FixMyStreet.xccheckout
deleted file mode 100644
index 7756c52..0000000
--- a/iPhone/FixMyStreet.xcodeproj/project.xcworkspace/xcshareddata/FixMyStreet.xccheckout
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IDESourceControlProjectFavoriteDictionaryKey</key>
- <false/>
- <key>IDESourceControlProjectIdentifier</key>
- <string>974147E5-3721-440F-874B-BE8E2FD35F53</string>
- <key>IDESourceControlProjectName</key>
- <string>FixMyStreet</string>
- <key>IDESourceControlProjectOriginsDictionary</key>
- <dict>
- <key>76028608-9C0B-4A78-85BA-C9A7B884576D</key>
- <string>ssh://git.mysociety.org/data/git/public/fixmystreet-mobile.git</string>
- </dict>
- <key>IDESourceControlProjectPath</key>
- <string>iPhone/FixMyStreet.xcodeproj/project.xcworkspace</string>
- <key>IDESourceControlProjectRelativeInstallPathDictionary</key>
- <dict>
- <key>76028608-9C0B-4A78-85BA-C9A7B884576D</key>
- <string>../../..</string>
- </dict>
- <key>IDESourceControlProjectURL</key>
- <string>ssh://git.mysociety.org/data/git/public/fixmystreet-mobile.git</string>
- <key>IDESourceControlProjectVersion</key>
- <integer>110</integer>
- <key>IDESourceControlProjectWCCIdentifier</key>
- <string>76028608-9C0B-4A78-85BA-C9A7B884576D</string>
- <key>IDESourceControlProjectWCConfigurations</key>
- <array>
- <dict>
- <key>IDESourceControlRepositoryExtensionIdentifierKey</key>
- <string>public.vcs.git</string>
- <key>IDESourceControlWCCIdentifierKey</key>
- <string>76028608-9C0B-4A78-85BA-C9A7B884576D</string>
- <key>IDESourceControlWCCName</key>
- <string>fixmystreet-mobile</string>
- </dict>
- </array>
-</dict>
-</plist>
diff --git a/iPhone/FixMyStreet/Classes/AppDelegate.h b/iPhone/FixMyStreet/Classes/AppDelegate.h
deleted file mode 100644
index cda3473..0000000
--- a/iPhone/FixMyStreet/Classes/AppDelegate.h
+++ /dev/null
@@ -1,42 +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.
- */
-
-//
-// AppDelegate.h
-// tmp_ios
-//
-// Created by ___FULLUSERNAME___ on ___DATE___.
-// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-#import <Cordova/CDVViewController.h>
-
-@interface AppDelegate : NSObject <UIApplicationDelegate>{}
-
-// invoke string is passed to your app on launch, this is only valid if you
-// edit tmp_ios-Info.plist to add a protocol
-// a simple tutorial can be found here :
-// http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
-
-@property (nonatomic, strong) IBOutlet UIWindow* window;
-@property (nonatomic, strong) IBOutlet CDVViewController* viewController;
-
-@end
diff --git a/iPhone/FixMyStreet/Classes/AppDelegate.m b/iPhone/FixMyStreet/Classes/AppDelegate.m
deleted file mode 100644
index 2982e6f..0000000
--- a/iPhone/FixMyStreet/Classes/AppDelegate.m
+++ /dev/null
@@ -1,133 +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.
- */
-
-//
-// AppDelegate.m
-// sample
-//
-// Created by ___FULLUSERNAME___ on ___DATE___.
-// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
-//
-
-#import "AppDelegate.h"
-#import "MainViewController.h"
-
-#import <Cordova/CDVPlugin.h>
-
-@implementation AppDelegate
-
-@synthesize window, viewController;
-
-- (id)init
-{
- /** If you need to do any extra app-specific initialization, you can do it here
- * -jm
- **/
- NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
-
- [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
-
- int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
- int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
-#if __has_feature(objc_arc)
- NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
-#else
- NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
-#endif
- [NSURLCache setSharedURLCache:sharedCache];
-
- self = [super init];
- return self;
-}
-
-#pragma mark UIApplicationDelegate implementation
-
-/**
- * This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
- */
-- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
-{
- CGRect screenBounds = [[UIScreen mainScreen] bounds];
-
-#if __has_feature(objc_arc)
- self.window = [[UIWindow alloc] initWithFrame:screenBounds];
-#else
- self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
-#endif
- self.window.autoresizesSubviews = YES;
-
-#if __has_feature(objc_arc)
- self.viewController = [[MainViewController alloc] init];
-#else
- self.viewController = [[[MainViewController alloc] init] autorelease];
-#endif
-
- // Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
- // If necessary, uncomment the line below to override it.
- // self.viewController.startPage = @"index.html";
-
- // NOTE: To customize the view's frame size (which defaults to full screen), override
- // [self.viewController viewWillAppear:] in your view controller.
-
- self.window.rootViewController = self.viewController;
- [self.window makeKeyAndVisible];
-
- return YES;
-}
-
-// this happens while we are running ( in the background, or from within our own app )
-// only valid if sample-Info.plist specifies a protocol to handle
-- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url
-{
- if (!url) {
- return NO;
- }
-
- // calls into javascript global function 'handleOpenURL'
- NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", url];
- [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];
-
- // all plugins will get the notification, and their handlers will be called
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
-
- return YES;
-}
-
-// repost the localnotification using the default NSNotificationCenter so multiple plugins may respond
-- (void) application:(UIApplication*)application
- didReceiveLocalNotification:(UILocalNotification*)notification
-{
- // re-post ( broadcast )
- [[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification];
-}
-
-- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
-{
- // iPhone doesn't support upside down by default, while the iPad does. Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected).
- NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);
-
- return supportedInterfaceOrientations;
-}
-
-- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
-{
- [[NSURLCache sharedURLCache] removeAllCachedResponses];
-}
-
-@end
diff --git a/iPhone/FixMyStreet/Classes/MainViewController.h b/iPhone/FixMyStreet/Classes/MainViewController.h
deleted file mode 100644
index e483f72..0000000
--- a/iPhone/FixMyStreet/Classes/MainViewController.h
+++ /dev/null
@@ -1,40 +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.
- */
-
-//
-// MainViewController.h
-// tmp_ios
-//
-// Created by ___FULLUSERNAME___ on ___DATE___.
-// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
-//
-
-#import <Cordova/CDVViewController.h>
-#import <Cordova/CDVCommandDelegateImpl.h>
-#import <Cordova/CDVCommandQueue.h>
-
-@interface MainViewController : CDVViewController
-
-@end
-
-@interface MainCommandDelegate : CDVCommandDelegateImpl
-@end
-
-@interface MainCommandQueue : CDVCommandQueue
-@end
diff --git a/iPhone/FixMyStreet/Classes/MainViewController.m b/iPhone/FixMyStreet/Classes/MainViewController.m
deleted file mode 100644
index 9fcf65d..0000000
--- a/iPhone/FixMyStreet/Classes/MainViewController.m
+++ /dev/null
@@ -1,174 +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.
- */
-
-//
-// MainViewController.h
-// tmp_ios
-//
-// Created by ___FULLUSERNAME___ on ___DATE___.
-// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
-//
-
-#import "MainViewController.h"
-
-@implementation MainViewController
-
-- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
-{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Uncomment to override the CDVCommandDelegateImpl used
- // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
- // Uncomment to override the CDVCommandQueue used
- // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
- }
- return self;
-}
-
-- (id)init
-{
- self = [super init];
- if (self) {
- // Uncomment to override the CDVCommandDelegateImpl used
- // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
- // Uncomment to override the CDVCommandQueue used
- // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
- }
- return self;
-}
-
-- (void)didReceiveMemoryWarning
-{
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
-
- // Release any cached data, images, etc that aren't in use.
-}
-
-#pragma mark View lifecycle
-
-- (void)viewWillAppear:(BOOL)animated
-{
- // View defaults to full size. If you want to customize the view's size, or its subviews (e.g. webView),
- // you can do so here.
-
- [super viewWillAppear:animated];
-}
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
- // Do any additional setup after loading the view from its nib.
-}
-
-- (void)viewDidUnload
-{
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
-}
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- // Return YES for supported orientations
- return [super shouldAutorotateToInterfaceOrientation:interfaceOrientation];
-}
-
-/* Comment out the block below to over-ride */
-
-/*
-- (UIWebView*) newCordovaViewWithFrame:(CGRect)bounds
-{
- return[super newCordovaViewWithFrame:bounds];
-}
-*/
-
-#pragma mark UIWebDelegate implementation
-
-- (void)webViewDidFinishLoad:(UIWebView*)theWebView
-{
- // Black base color for background matches the native apps
- theWebView.backgroundColor = [UIColor blackColor];
-
- return [super webViewDidFinishLoad:theWebView];
-}
-
-/* Comment out the block below to over-ride */
-
-/*
-
-- (void) webViewDidStartLoad:(UIWebView*)theWebView
-{
- return [super webViewDidStartLoad:theWebView];
-}
-
-- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
-{
- return [super webView:theWebView didFailLoadWithError:error];
-}
-
-- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
-{
- return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
-}
-*/
-
-@end
-
-@implementation MainCommandDelegate
-
-/* To override the methods, uncomment the line in the init function(s)
- in MainViewController.m
- */
-
-#pragma mark CDVCommandDelegate implementation
-
-- (id)getCommandInstance:(NSString*)className
-{
- return [super getCommandInstance:className];
-}
-
-/*
- NOTE: this will only inspect execute calls coming explicitly from native plugins,
- not the commandQueue (from JavaScript). To see execute calls from JavaScript, see
- MainCommandQueue below
-*/
-- (BOOL)execute:(CDVInvokedUrlCommand*)command
-{
- return [super execute:command];
-}
-
-- (NSString*)pathForResource:(NSString*)resourcepath;
-{
- return [super pathForResource:resourcepath];
-}
-
-@end
-
-@implementation MainCommandQueue
-
-/* To override, uncomment the line in the init function(s)
- in MainViewController.m
- */
-- (BOOL)execute:(CDVInvokedUrlCommand*)command
-{
- return [super execute:command];
-}
-
-@end
diff --git a/iPhone/FixMyStreet/Classes/MainViewController.xib b/iPhone/FixMyStreet/Classes/MainViewController.xib
deleted file mode 100644
index e45d65c..0000000
--- a/iPhone/FixMyStreet/Classes/MainViewController.xib
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-#
-# 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.
-#
--->
-<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
- <data>
- <int key="IBDocument.SystemTarget">1280</int>
- <string key="IBDocument.SystemVersion">11C25</string>
- <string key="IBDocument.InterfaceBuilderVersion">1919</string>
- <string key="IBDocument.AppKitVersion">1138.11</string>
- <string key="IBDocument.HIToolboxVersion">566.00</string>
- <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
- <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">916</string>
- </object>
- <array key="IBDocument.IntegratedClassDependencies">
- <string>IBProxyObject</string>
- <string>IBUIView</string>
- </array>
- <array key="IBDocument.PluginDependencies">
- <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- </array>
- <object class="NSMutableDictionary" key="IBDocument.Metadata">
- <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
- <integer value="1" key="NS.object.0"/>
- </object>
- <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
- <object class="IBProxyObject" id="372490531">
- <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- <object class="IBProxyObject" id="975951072">
- <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- <object class="IBUIView" id="191373211">
- <reference key="NSNextResponder"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrame">{{0, 20}, {320, 460}}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
- <object class="NSColor" key="IBUIBackgroundColor">
- <int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MQA</bytes>
- <object class="NSColorSpace" key="NSCustomColorSpace">
- <int key="NSID">2</int>
- </object>
- </object>
- <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
- <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- </object>
- </array>
- <object class="IBObjectContainer" key="IBDocument.Objects">
- <array class="NSMutableArray" key="connectionRecords">
- <object class="IBConnectionRecord">
- <object class="IBCocoaTouchOutletConnection" key="connection">
- <string key="label">view</string>
- <reference key="source" ref="372490531"/>
- <reference key="destination" ref="191373211"/>
- </object>
- <int key="connectionID">3</int>
- </object>
- </array>
- <object class="IBMutableOrderedSet" key="objectRecords">
- <array key="orderedObjects">
- <object class="IBObjectRecord">
- <int key="objectID">0</int>
- <array key="object" id="0"/>
- <reference key="children" ref="1000"/>
- <nil key="parent"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">1</int>
- <reference key="object" ref="191373211"/>
- <reference key="parent" ref="0"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-1</int>
- <reference key="object" ref="372490531"/>
- <reference key="parent" ref="0"/>
- <string key="objectName">File's Owner</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-2</int>
- <reference key="object" ref="975951072"/>
- <reference key="parent" ref="0"/>
- </object>
- </array>
- </object>
- <dictionary class="NSMutableDictionary" key="flattenedProperties">
- <string key="-1.CustomClassName">MainViewController</string>
- <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="-2.CustomClassName">UIResponder</string>
- <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- </dictionary>
- <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
- <nil key="activeLocalization"/>
- <dictionary class="NSMutableDictionary" key="localizations"/>
- <nil key="sourceID"/>
- <int key="maxID">3</int>
- </object>
- <object class="IBClassDescriber" key="IBDocument.Classes">
- <array class="NSMutableArray" key="referencedPartialClassDescriptions">
- <object class="IBPartialClassDescription">
- <string key="className">MainViewController</string>
- <string key="superclassName">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">./Classes/MainViewController.h</string>
- </object>
- </object>
- </array>
- </object>
- <int key="IBDocument.localizationMode">0</int>
- <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
- <int key="IBDocument.defaultPropertyAccessControl">3</int>
- <string key="IBCocoaTouchPluginVersion">916</string>
- </data>
-</archive>
diff --git a/iPhone/FixMyStreet/FixMyStreet-Info.plist b/iPhone/FixMyStreet/FixMyStreet-Info.plist
deleted file mode 100644
index 64fb331..0000000
--- a/iPhone/FixMyStreet/FixMyStreet-Info.plist
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleDisplayName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIconFiles</key>
- <array/>
- <key>CFBundleIcons</key>
- <dict>
- <key>CFBundlePrimaryIcon</key>
- <dict>
- <key>CFBundleIconFiles</key>
- <array>
- <string>fms-Icon</string>
- <string>fms-Icon-Small-29</string>
- <string>fms-Icon-80</string>
- <string>fms-Icon-120</string>
- </array>
- <key>UIPrerenderedIcon</key>
- <true/>
- </dict>
- </dict>
- <key>CFBundleIdentifier</key>
- <string>org.mysociety.FixMyStreet</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>2.0.4</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>27</string>
- <key>LSRequiresIPhoneOS</key>
- <true/>
- <key>NSMainNibFile~ipad</key>
- <string></string>
- <key>UIPrerenderedIcon</key>
- <true/>
- <key>UIStatusBarHidden</key>
- <false/>
- <key>UIStatusBarStyle</key>
- <string>UIStatusBarStyleBlackOpaque</string>
- <key>UISupportedInterfaceOrientations</key>
- <array>
- <string>UIInterfaceOrientationPortrait</string>
- </array>
- <key>UISupportedInterfaceOrientations~ipad</key>
- <array>
- <string>UIInterfaceOrientationPortrait</string>
- <string>UIInterfaceOrientationLandscapeLeft</string>
- <string>UIInterfaceOrientationPortraitUpsideDown</string>
- <string>UIInterfaceOrientationLandscapeRight</string>
- </array>
-</dict>
-</plist>
diff --git a/iPhone/FixMyStreet/FixMyStreet-Prefix.pch b/iPhone/FixMyStreet/FixMyStreet-Prefix.pch
deleted file mode 100644
index b740790..0000000
--- a/iPhone/FixMyStreet/FixMyStreet-Prefix.pch
+++ /dev/null
@@ -1,7 +0,0 @@
-//
-// Prefix header for all source files of the 'FixMyStreet' target in the 'FixMyStreet' project
-//
-
-#ifdef __OBJC__
- #import <UIKit/UIKit.h>
-#endif
diff --git a/iPhone/FixMyStreet/Plugins/README b/iPhone/FixMyStreet/Plugins/README
deleted file mode 100644
index 438840d..0000000
--- a/iPhone/FixMyStreet/Plugins/README
+++ /dev/null
@@ -1 +0,0 @@
-Put the .h and .m files of your plugin here. The .js files of your plugin belong in the www folder. \ No newline at end of file
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg.png b/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg.png
deleted file mode 100644
index 784e9c7..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg@2x.png b/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg@2x.png
deleted file mode 100644
index 1e28c6d..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg~ipad.png b/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg~ipad.png
deleted file mode 100644
index efbef8a..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/controls_bg~ipad.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/microphone.png b/iPhone/FixMyStreet/Resources/Capture.bundle/microphone.png
deleted file mode 100644
index 155b88c..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/microphone.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/microphone@2x.png b/iPhone/FixMyStreet/Resources/Capture.bundle/microphone@2x.png
deleted file mode 100644
index 79ef16b..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/microphone@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/microphone~ipad.png b/iPhone/FixMyStreet/Resources/Capture.bundle/microphone~ipad.png
deleted file mode 100644
index ef1c472..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/microphone~ipad.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/record_button.png b/iPhone/FixMyStreet/Resources/Capture.bundle/record_button.png
deleted file mode 100644
index ceb9589..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/record_button.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/record_button@2x.png b/iPhone/FixMyStreet/Resources/Capture.bundle/record_button@2x.png
deleted file mode 100644
index d6ce302..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/record_button@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/record_button~ipad.png b/iPhone/FixMyStreet/Resources/Capture.bundle/record_button~ipad.png
deleted file mode 100644
index d8e24a4..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/record_button~ipad.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg.png b/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg.png
deleted file mode 100644
index bafc087..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg@2x.png b/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg@2x.png
deleted file mode 100644
index 798490b..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg~ipad.png b/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg~ipad.png
deleted file mode 100644
index 3b467f6..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/recording_bg~ipad.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button.png b/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button.png
deleted file mode 100644
index 9c31838..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button@2x.png b/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button@2x.png
deleted file mode 100644
index 8cf657e..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button~ipad.png b/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button~ipad.png
deleted file mode 100644
index 59bb7a5..0000000
--- a/iPhone/FixMyStreet/Resources/Capture.bundle/stop_button~ipad.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/de.lproj/Localizable.strings b/iPhone/FixMyStreet/Resources/de.lproj/Localizable.strings
deleted file mode 100644
index f1cdb42..0000000
--- a/iPhone/FixMyStreet/Resources/de.lproj/Localizable.strings
+++ /dev/null
@@ -1,26 +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.
- */
-
-
-// accessibility label for recording button
-"toggle audio recording" = "starten/beenden der Tonaufnahme";
-// notification spoken by VoiceOver when timed recording finishes
-"timed recording complete" = "programmierte Aufnahme beendet";
-// accessibility hint for display of recorded elapsed time
-"recorded time in minutes and seconds" = "aufgenommene Zeit in Minuten und Sekunden"; \ No newline at end of file
diff --git a/iPhone/FixMyStreet/Resources/en.lproj/Localizable.strings b/iPhone/FixMyStreet/Resources/en.lproj/Localizable.strings
deleted file mode 100644
index 8972684..0000000
--- a/iPhone/FixMyStreet/Resources/en.lproj/Localizable.strings
+++ /dev/null
@@ -1,25 +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.
- */
-
-// accessibility label for recording button
-"toggle audio recording" = "toggle audio recording";
-// notification spoken by VoiceOver when timed recording finishes
-"timed recording complete" = "timed recording complete";
-// accessibility hint for display of recorded elapsed time
-"recorded time in minutes and seconds" = "recorded time in minutes and seconds"; \ No newline at end of file
diff --git a/iPhone/FixMyStreet/Resources/es.lproj/Localizable.strings b/iPhone/FixMyStreet/Resources/es.lproj/Localizable.strings
deleted file mode 100644
index 23831e6..0000000
--- a/iPhone/FixMyStreet/Resources/es.lproj/Localizable.strings
+++ /dev/null
@@ -1,25 +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.
- */
-
-// accessibility label for recording button
-"toggle audio recording" = "grabación de audio cambiar";
-// notification spoken by VoiceOver when timed recording finishes
-"timed recording complete" = "tiempo de grabación completo";
-// accessibility hint for display of recorded elapsed time
-"recorded time in minutes and seconds" = "tiempo registrado en minutos y segundos"; \ No newline at end of file
diff --git a/iPhone/FixMyStreet/Resources/icons/fms-Icon-120.png b/iPhone/FixMyStreet/Resources/icons/fms-Icon-120.png
deleted file mode 100644
index 860f35f..0000000
--- a/iPhone/FixMyStreet/Resources/icons/fms-Icon-120.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/icons/fms-Icon-80.png b/iPhone/FixMyStreet/Resources/icons/fms-Icon-80.png
deleted file mode 100644
index bc432ff..0000000
--- a/iPhone/FixMyStreet/Resources/icons/fms-Icon-80.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29.png b/iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29.png
deleted file mode 100644
index a7c8db8..0000000
--- a/iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29@2x.png b/iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29@2x.png
deleted file mode 100644
index 45e0ced..0000000
--- a/iPhone/FixMyStreet/Resources/icons/fms-Icon-Small-29@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/icons/fms-Icon.png b/iPhone/FixMyStreet/Resources/icons/fms-Icon.png
deleted file mode 100644
index 6333abd..0000000
--- a/iPhone/FixMyStreet/Resources/icons/fms-Icon.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/icons/fms-Icon@2x.png b/iPhone/FixMyStreet/Resources/icons/fms-Icon@2x.png
deleted file mode 100644
index 1b6e199..0000000
--- a/iPhone/FixMyStreet/Resources/icons/fms-Icon@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/se.lproj/Localizable.strings b/iPhone/FixMyStreet/Resources/se.lproj/Localizable.strings
deleted file mode 100644
index 0af9646..0000000
--- a/iPhone/FixMyStreet/Resources/se.lproj/Localizable.strings
+++ /dev/null
@@ -1,26 +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.
- */
-
-
-// accessibility label for recording button
-"toggle audio recording" = "börja/avsluta inspelning";
-// notification spoken by VoiceOver when timed recording finishes
-"timed recording complete" = "inspelning har avslutad";
-// accessibility hint for display of recorded elapsed time
-"recorded time in minutes and seconds" = "inspelad tid in minuter och sekund"; \ No newline at end of file
diff --git a/iPhone/FixMyStreet/Resources/splash/Default.png b/iPhone/FixMyStreet/Resources/splash/Default.png
deleted file mode 100644
index 9c373ff..0000000
--- a/iPhone/FixMyStreet/Resources/splash/Default.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/Resources/splash/Default@2x.png b/iPhone/FixMyStreet/Resources/splash/Default@2x.png
deleted file mode 100644
index 92fe138..0000000
--- a/iPhone/FixMyStreet/Resources/splash/Default@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/FixMyStreet/config.xml b/iPhone/FixMyStreet/config.xml
deleted file mode 100644
index 636f86e..0000000
--- a/iPhone/FixMyStreet/config.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<widget xmlns = "http://www.w3.org/ns/widgets"
- id = "org.mysociety.fixmystreet"
- version = "2.0.0">
- <name>FixMyStreet</name>
-
- <description>
- Report problems on FixMyStreet
- </description>
-
- <author href="http://mysociety.org" email="team@mysociety.org">
- mySociety
- </author>
-
- <access origin="*.tile.openstreetmap.org"/>
- <access origin="*.tilma.mysociety.org"/>
- <access origin="*.virtualearth.net"/>
- <access origin="mapit.mysociety.org"/>
- <access origin="www.fixmystreet.com"/>
-
- <!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
- <content src="src/index.html" />
-
- <!-- Preferences for iOS -->
- <preference name="AllowInlineMediaPlayback" value="false" />
- <preference name="AutoHideSplashScreen" value="true" />
- <preference name="BackupWebStorage" value="cloud" />
- <preference name="DisallowOverscroll" value="true" />
- <preference name="EnableLocation" value="false" /><!-- DEPRECATED -->
- <preference name="EnableViewportScale" value="false" />
- <preference name="FadeSplashScreen" value="false" />
- <preference name="FadeSplashScreenDuration" value="0" />
- <preference name="HideKeyboardFormAccessoryBar" value="false" />
- <preference name="KeyboardDisplayRequiresUserAction" value="false" />
- <preference name="KeyboardShrinksView" value="false" />
- <preference name="MediaPlaybackRequiresUserAction" value="false" />
- <preference name="ShowSplashScreenSpinner" value="true" />
- <preference name="SuppressesIncrementalRendering" value="false" />
- <preference name="TopActivityIndicator" value="gray" />
-
-
- <feature name="Geolocation">
- <param name="ios-package" value="CDVLocation"/>
- </feature>
- <feature name="Device">
- <param name="ios-package" value="CDVDevice"/>
- </feature>
- <feature name="Accelerometer">
- <param name="ios-package" value="CDVAccelerometer"/>
- </feature>
- <feature name="Compass">
- <param name="ios-package" value="CDVLocation"/>
- </feature>
- <feature name="Media">
- <param name="ios-package" value="CDVSound"/>
- </feature>
- <feature name="Camera">
- <param name="ios-package" value="CDVCamera"/>
- </feature>
- <feature name="Contacts">
- <param name="ios-package" value="CDVContacts"/>
- </feature>
- <feature name="File">
- <param name="ios-package" value="CDVFile"/>
- </feature>
- <feature name="NetworkStatus">
- <param name="ios-package" value="CDVConnection"/>
- </feature>
- <feature name="Notification">
- <param name="ios-package" value="CDVNotification"/>
- </feature>
- <feature name="FileTransfer">
- <param name="ios-package" value="CDVFileTransfer"/>
- </feature>
- <feature name="Capture">
- <param name="ios-package" value="CDVCapture"/>
- </feature>
- <feature name="Battery">
- <param name="ios-package" value="CDVBattery"/>
- </feature>
- <feature name="SplashScreen">
- <param name="ios-package" value="CDVSplashScreen"/>
- </feature>
- <feature name="Echo">
- <param name="ios-package" value="CDVEcho"/>
- </feature>
- <feature name="Globalization">
- <param name="ios-package" value="CDVGlobalization"/>
- </feature>
- <feature name="InAppBrowser">
- <param name="ios-package" value="CDVInAppBrowser"/>
- </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>
-</widget>
diff --git a/iPhone/FixMyStreet/en.lproj/InfoPlist.strings b/iPhone/FixMyStreet/en.lproj/InfoPlist.strings
deleted file mode 100644
index 477b28f..0000000
--- a/iPhone/FixMyStreet/en.lproj/InfoPlist.strings
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Localized versions of Info.plist keys */
-
diff --git a/iPhone/FixMyStreet/main.m b/iPhone/FixMyStreet/main.m
deleted file mode 100644
index b6fba52..0000000
--- a/iPhone/FixMyStreet/main.m
+++ /dev/null
@@ -1,35 +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.
- */
-//
-// main.m
-// FixMyStreet
-//
-// Created by Struan Donald on 08/03/2012.
-// Copyright __MyCompanyName__ 2012. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-int main(int argc, char *argv[]) {
-
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
- [pool release];
- return retVal;
-}
diff --git a/iPhone/Icon.png b/iPhone/Icon.png
deleted file mode 100644
index 6a045b6..0000000
--- a/iPhone/Icon.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/Icon@2x.png b/iPhone/Icon@2x.png
deleted file mode 100644
index 8ff853c..0000000
--- a/iPhone/Icon@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/cordova/build b/iPhone/cordova/build
deleted file mode 100755
index 1574c5e..0000000
--- a/iPhone/cordova/build
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-#
-# 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.
-#
-
-#
-# compile and launch a Cordova/iOS project to the simulator
-#
-
-set -e
-
-XCODE_VER=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //')
-XCODE_MIN_VERSION="4.5"
-
-if [[ "$XCODE_VER" < "$XCODE_MIN_VERSION" ]]; then
- echo "Cordova can only run in Xcode version $XCODE_MIN_VERSION or greater."
- exit 1
-fi
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
-XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj )
-PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-
-cd "$PROJECT_PATH"
-
-APP=build/$PROJECT_NAME.app
-SDK=`xcodebuild -showsdks | grep Sim | tail -1 | awk '{print $6}'`
-
-xcodebuild -project $PROJECT_NAME.xcodeproj -arch i386 -target $PROJECT_NAME -configuration Debug -sdk $SDK clean build VALID_ARCHS="i386" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build"
-
-
-
-
-
diff --git a/iPhone/cordova/emulate b/iPhone/cordova/emulate
deleted file mode 100755
index f26cb3a..0000000
--- a/iPhone/cordova/emulate
+++ /dev/null
@@ -1,55 +0,0 @@
-#! /bin/bash
-#
-# 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.
-#
-
-set -e
-
-XCODE_VER=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //')
-XCODE_MIN_VERSION="4.5"
-
-if [[ "$XCODE_VER" < "$XCODE_MIN_VERSION" ]]; then
- echo "Cordova can only run in Xcode version $XCODE_MIN_VERSION or greater."
- exit 1
-fi
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
-XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj )
-PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-
-APP_PATH=${1:-$PROJECT_PATH/build/$PROJECT_NAME.app}
-DEVICE_FAMILY=${2:-${DEVICE_FAMILY:-iphone}}
-
-if [ ! -d "$APP_PATH" ]; then
- echo "Project '$APP_PATH' is not built. Building."
- $CORDOVA_PATH/build || exit $?
-fi
-
-if [ ! -d "$APP_PATH" ]; then
- echo "$APP_PATH not found to emulate."
- exit 1
-fi
-
-# launch using ios-sim
-if which ios-sim >/dev/null; then
- ios-sim launch "$APP_PATH" --family "$DEVICE_FAMILY" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" &
-else
- echo -e '\033[31mError: ios-sim was not found. Please download, build and install version 1.4 or greater from https://github.com/phonegap/ios-sim into your path. Or "brew install ios-sim" using homebrew: http://mxcl.github.com/homebrew/\033[m'; exit 1;
-fi
-
diff --git a/iPhone/cordova/log b/iPhone/cordova/log
deleted file mode 100755
index b235b09..0000000
--- a/iPhone/cordova/log
+++ /dev/null
@@ -1,23 +0,0 @@
-#! /bin/sh
-#
-# 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.
-#
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-
-tail -f "$CORDOVA_PATH/console.log"
diff --git a/iPhone/cordova/release b/iPhone/cordova/release
deleted file mode 100755
index 7263934..0000000
--- a/iPhone/cordova/release
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash
-
-#
-# 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.
-#
-
-#
-# compile and launch a Cordova/iOS project to the simulator
-#
-
-set -e
-
-XCODE_VER=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //')
-XCODE_MIN_VERSION="4.5"
-
-if [[ "$XCODE_VER" < "$XCODE_MIN_VERSION" ]]; then
- echo "Cordova can only run in Xcode version $XCODE_MIN_VERSION or greater."
- exit 1
-fi
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
-XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj )
-PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-
-cd "$PROJECT_PATH"
-
-APP=build/$PROJECT_NAME.app
-SDK=`xcodebuild -showsdks | grep Sim | tail -1 | awk '{print $6}'`
-
-xcodebuild -project $PROJECT_NAME.xcodeproj -arch i386 -target $PROJECT_NAME -configuration Release -sdk $SDK clean build VALID_ARCHS="i386" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build"
-
-
-
-
-
diff --git a/iPhone/cordova/run b/iPhone/cordova/run
deleted file mode 100755
index ef7198e..0000000
--- a/iPhone/cordova/run
+++ /dev/null
@@ -1,58 +0,0 @@
-#! /bin/sh
-#
-# 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.
-#
-
-set -e
-
-XCODE_VER=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //')
-XCODE_MIN_VERSION="4.5"
-
-if [[ "$XCODE_VER" < "$XCODE_MIN_VERSION" ]]; then
- echo "Cordova can only run in Xcode version $XCODE_MIN_VERSION or greater."
- exit 1
-fi
-
-CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
-PROJECT_PATH="$(dirname "$CORDOVA_PATH")"
-XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj )
-PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
-
-APP_PATH=$1
-
-if [ $# -lt 1 ]; then
- APP_PATH="$PROJECT_PATH/build/$PROJECT_NAME.app"
-fi
-
-if [ ! -d "$APP_PATH" ]; then
- echo "Project '$APP_PATH' is not built. Building."
- $CORDOVA_PATH/build || exit $?
-fi
-
-if [ ! -d "$APP_PATH" ]; then
- echo "$APP_PATH not found to emulate."
- exit 1
-fi
-
-# launch using ios-sim
-if which ios-sim >/dev/null; then
- ios-sim launch "$APP_PATH" --stderr "$CORDOVA_PATH/console.log" --stdout "$CORDOVA_PATH/console.log" &
-else
- echo -e '\033[31mError: ios-sim was not found. Please download, build and install version 1.4 or greater from https://github.com/phonegap/ios-sim into your path. Or "brew install ios-sim" using homebrew: http://mxcl.github.com/homebrew/\033[m'; exit 1;
-fi
-
diff --git a/iPhone/fms-Icon-120.png b/iPhone/fms-Icon-120.png
deleted file mode 100644
index 860f35f..0000000
--- a/iPhone/fms-Icon-120.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/fms-Icon-80.png b/iPhone/fms-Icon-80.png
deleted file mode 100644
index bc432ff..0000000
--- a/iPhone/fms-Icon-80.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/fms-Icon-Small-29.png b/iPhone/fms-Icon-Small-29.png
deleted file mode 100644
index a7c8db8..0000000
--- a/iPhone/fms-Icon-Small-29.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/fms-Icon-Small-29@2x.png b/iPhone/fms-Icon-Small-29@2x.png
deleted file mode 100644
index 45e0ced..0000000
--- a/iPhone/fms-Icon-Small-29@2x.png
+++ /dev/null
Binary files differ
diff --git a/iPhone/www/cordova.js b/iPhone/www/cordova.js
deleted file mode 100755
index 9bd85e2..0000000
--- a/iPhone/www/cordova.js
+++ /dev/null
@@ -1,6521 +0,0 @@
-// Platform: ios
-// 2.9.0-0-g83dc4bd
-/*
- 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.
-*/
-;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.9.0-0-g83dc4bd';
-// file: lib/scripts/require.js
-
-var require,
- define;
-
-(function () {
- var modules = {},
- // Stack of moduleIds currently being built.
- requireStack = [],
- // Map of module ID -> index into requireStack of modules currently being built.
- inProgressModules = {},
- SEPERATOR = ".";
-
-
-
- function build(module) {
- var factory = module.factory,
- localRequire = function (id) {
- var resultantId = id;
- //Its a relative path, so lop off the last portion and add the id (minus "./")
- if (id.charAt(0) === ".") {
- resultantId = module.id.slice(0, module.id.lastIndexOf(SEPERATOR)) + SEPERATOR + id.slice(2);
- }
- return require(resultantId);
- };
- module.exports = {};
- delete module.factory;
- factory(localRequire, module.exports, module);
- return module.exports;
- }
-
- require = function (id) {
- if (!modules[id]) {
- throw "module " + id + " not found";
- } else if (id in inProgressModules) {
- var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
- throw "Cycle in require graph: " + cycle;
- }
- if (modules[id].factory) {
- try {
- inProgressModules[id] = requireStack.length;
- requireStack.push(id);
- return build(modules[id]);
- } finally {
- delete inProgressModules[id];
- requireStack.pop();
- }
- }
- return modules[id].exports;
- };
-
- define = function (id, factory) {
- if (modules[id]) {
- throw "module " + id + " already defined";
- }
-
- modules[id] = {
- id: id,
- factory: factory
- };
- };
-
- define.remove = function (id) {
- delete modules[id];
- };
-
- define.moduleMap = modules;
-})();
-
-//Export for use in node
-if (typeof module === "object" && typeof require === "function") {
- module.exports.require = require;
- module.exports.define = define;
-}
-
-// file: lib/cordova.js
-define("cordova", function(require, exports, module) {
-
-
-var channel = require('cordova/channel');
-
-/**
- * Listen for DOMContentLoaded and notify our channel subscribers.
- */
-document.addEventListener('DOMContentLoaded', function() {
- channel.onDOMContentLoaded.fire();
-}, false);
-if (document.readyState == 'complete' || document.readyState == 'interactive') {
- channel.onDOMContentLoaded.fire();
-}
-
-/**
- * Intercept calls to addEventListener + removeEventListener and handle deviceready,
- * resume, and pause events.
- */
-var m_document_addEventListener = document.addEventListener;
-var m_document_removeEventListener = document.removeEventListener;
-var m_window_addEventListener = window.addEventListener;
-var m_window_removeEventListener = window.removeEventListener;
-
-/**
- * Houses custom event handlers to intercept on document + window event listeners.
- */
-var documentEventHandlers = {},
- windowEventHandlers = {};
-
-document.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof documentEventHandlers[e] != 'undefined') {
- documentEventHandlers[e].subscribe(handler);
- } else {
- m_document_addEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.addEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- if (typeof windowEventHandlers[e] != 'undefined') {
- windowEventHandlers[e].subscribe(handler);
- } else {
- m_window_addEventListener.call(window, evt, handler, capture);
- }
-};
-
-document.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubscribing from an event that is handled by a plugin
- if (typeof documentEventHandlers[e] != "undefined") {
- documentEventHandlers[e].unsubscribe(handler);
- } else {
- m_document_removeEventListener.call(document, evt, handler, capture);
- }
-};
-
-window.removeEventListener = function(evt, handler, capture) {
- var e = evt.toLowerCase();
- // If unsubscribing from an event that is handled by a plugin
- if (typeof windowEventHandlers[e] != "undefined") {
- windowEventHandlers[e].unsubscribe(handler);
- } else {
- m_window_removeEventListener.call(window, evt, handler, capture);
- }
-};
-
-function createEvent(type, data) {
- var event = document.createEvent('Events');
- event.initEvent(type, false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- }
- return event;
-}
-
-if(typeof window.console === "undefined") {
- window.console = {
- log:function(){}
- };
-}
-
-var cordova = {
- define:define,
- require:require,
- /**
- * Methods to add/remove your own addEventListener hijacking on document + window.
- */
- addWindowEventHandler:function(event) {
- return (windowEventHandlers[event] = channel.create(event));
- },
- addStickyDocumentEventHandler:function(event) {
- return (documentEventHandlers[event] = channel.createSticky(event));
- },
- addDocumentEventHandler:function(event) {
- return (documentEventHandlers[event] = channel.create(event));
- },
- removeWindowEventHandler:function(event) {
- delete windowEventHandlers[event];
- },
- removeDocumentEventHandler:function(event) {
- delete documentEventHandlers[event];
- },
- /**
- * Retrieve original event handlers that were replaced by Cordova
- *
- * @return object
- */
- getOriginalHandlers: function() {
- return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
- 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
- },
- /**
- * Method to fire event from native code
- * bNoDetach is required for events which cause an exception which needs to be caught in native code
- */
- fireDocumentEvent: function(type, data, bNoDetach) {
- var evt = createEvent(type, data);
- if (typeof documentEventHandlers[type] != 'undefined') {
- if( bNoDetach ) {
- documentEventHandlers[type].fire(evt);
- }
- else {
- setTimeout(function() {
- // Fire deviceready on listeners that were registered before cordova.js was loaded.
- if (type == 'deviceready') {
- document.dispatchEvent(evt);
- }
- documentEventHandlers[type].fire(evt);
- }, 0);
- }
- } else {
- document.dispatchEvent(evt);
- }
- },
- fireWindowEvent: function(type, data) {
- var evt = createEvent(type,data);
- if (typeof windowEventHandlers[type] != 'undefined') {
- setTimeout(function() {
- windowEventHandlers[type].fire(evt);
- }, 0);
- } else {
- window.dispatchEvent(evt);
- }
- },
-
- /**
- * Plugin callback mechanism.
- */
- // Randomize the starting callbackId to avoid collisions after refreshing or navigating.
- // This way, it's very unlikely that any new callback would get the same callbackId as an old callback.
- callbackId: Math.floor(Math.random() * 2000000000),
- callbacks: {},
- callbackStatus: {
- NO_RESULT: 0,
- OK: 1,
- CLASS_NOT_FOUND_EXCEPTION: 2,
- ILLEGAL_ACCESS_EXCEPTION: 3,
- INSTANTIATION_EXCEPTION: 4,
- MALFORMED_URL_EXCEPTION: 5,
- IO_EXCEPTION: 6,
- INVALID_ACTION: 7,
- JSON_EXCEPTION: 8,
- ERROR: 9
- },
-
- /**
- * Called by native code when returning successful result from an action.
- */
- callbackSuccess: function(callbackId, args) {
- try {
- cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
- } catch (e) {
- console.log("Error in error callback: " + callbackId + " = "+e);
- }
- },
-
- /**
- * Called by native code when returning error result from an action.
- */
- callbackError: function(callbackId, args) {
- // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
- // Derive success from status.
- try {
- cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
- } catch (e) {
- console.log("Error in error callback: " + callbackId + " = "+e);
- }
- },
-
- /**
- * Called by native code when returning the result from an action.
- */
- callbackFromNative: function(callbackId, success, status, args, keepCallback) {
- var callback = cordova.callbacks[callbackId];
- if (callback) {
- if (success && status == cordova.callbackStatus.OK) {
- callback.success && callback.success.apply(null, args);
- } else if (!success) {
- callback.fail && callback.fail.apply(null, args);
- }
-
- // Clear callback if not expecting any more results
- if (!keepCallback) {
- delete cordova.callbacks[callbackId];
- }
- }
- },
- addConstructor: function(func) {
- channel.onCordovaReady.subscribe(function() {
- try {
- func();
- } catch(e) {
- console.log("Failed to run constructor: " + e);
- }
- });
- }
-};
-
-// Register pause, resume and deviceready channels as events on document.
-channel.onPause = cordova.addDocumentEventHandler('pause');
-channel.onResume = cordova.addDocumentEventHandler('resume');
-channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
-
-module.exports = cordova;
-
-});
-
-// file: lib/common/argscheck.js
-define("cordova/argscheck", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var utils = require('cordova/utils');
-
-var moduleExports = module.exports;
-
-var typeMap = {
- 'A': 'Array',
- 'D': 'Date',
- 'N': 'Number',
- 'S': 'String',
- 'F': 'Function',
- 'O': 'Object'
-};
-
-function extractParamName(callee, argIndex) {
- return (/.*?\((.*?)\)/).exec(callee)[1].split(', ')[argIndex];
-}
-
-function checkArgs(spec, functionName, args, opt_callee) {
- if (!moduleExports.enableChecks) {
- return;
- }
- var errMsg = null;
- var typeName;
- for (var i = 0; i < spec.length; ++i) {
- var c = spec.charAt(i),
- cUpper = c.toUpperCase(),
- arg = args[i];
- // Asterix means allow anything.
- if (c == '*') {
- continue;
- }
- typeName = utils.typeName(arg);
- if ((arg === null || arg === undefined) && c == cUpper) {
- continue;
- }
- if (typeName != typeMap[cUpper]) {
- errMsg = 'Expected ' + typeMap[cUpper];
- break;
- }
- }
- if (errMsg) {
- errMsg += ', but got ' + typeName + '.';
- errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
- // Don't log when running jake test.
- if (typeof jasmine == 'undefined') {
- console.error(errMsg);
- }
- throw TypeError(errMsg);
- }
-}
-
-function getValue(value, defaultValue) {
- return value === undefined ? defaultValue : value;
-}
-
-moduleExports.checkArgs = checkArgs;
-moduleExports.getValue = getValue;
-moduleExports.enableChecks = true;
-
-
-});
-
-// file: lib/common/builder.js
-define("cordova/builder", function(require, exports, module) {
-
-var utils = require('cordova/utils');
-
-function each(objects, func, context) {
- for (var prop in objects) {
- if (objects.hasOwnProperty(prop)) {
- func.apply(context, [objects[prop], prop]);
- }
- }
-}
-
-function clobber(obj, key, value) {
- exports.replaceHookForTesting(obj, key);
- obj[key] = value;
- // Getters can only be overridden by getters.
- if (obj[key] !== value) {
- utils.defineGetter(obj, key, function() {
- return value;
- });
- }
-}
-
-function assignOrWrapInDeprecateGetter(obj, key, value, message) {
- if (message) {
- utils.defineGetter(obj, key, function() {
- console.log(message);
- delete obj[key];
- clobber(obj, key, value);
- return value;
- });
- } else {
- clobber(obj, key, value);
- }
-}
-
-function include(parent, objects, clobber, merge) {
- each(objects, function (obj, key) {
- try {
- var result = obj.path ? require(obj.path) : {};
-
- if (clobber) {
- // Clobber if it doesn't exist.
- if (typeof parent[key] === 'undefined') {
- assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
- } else if (typeof obj.path !== 'undefined') {
- // If merging, merge properties onto parent, otherwise, clobber.
- if (merge) {
- recursiveMerge(parent[key], result);
- } else {
- assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
- }
- }
- result = parent[key];
- } else {
- // Overwrite if not currently defined.
- if (typeof parent[key] == 'undefined') {
- assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
- } else {
- // Set result to what already exists, so we can build children into it if they exist.
- result = parent[key];
- }
- }
-
- if (obj.children) {
- include(result, obj.children, clobber, merge);
- }
- } catch(e) {
- utils.alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
- }
- });
-}
-
-/**
- * Merge properties from one object onto another recursively. Properties from
- * the src object will overwrite existing target property.
- *
- * @param target Object to merge properties into.
- * @param src Object to merge properties from.
- */
-function recursiveMerge(target, src) {
- for (var prop in src) {
- if (src.hasOwnProperty(prop)) {
- if (target.prototype && target.prototype.constructor === target) {
- // If the target object is a constructor override off prototype.
- clobber(target.prototype, prop, src[prop]);
- } else {
- if (typeof src[prop] === 'object' && typeof target[prop] === 'object') {
- recursiveMerge(target[prop], src[prop]);
- } else {
- clobber(target, prop, src[prop]);
- }
- }
- }
- }
-}
-
-exports.buildIntoButDoNotClobber = function(objects, target) {
- include(target, objects, false, false);
-};
-exports.buildIntoAndClobber = function(objects, target) {
- include(target, objects, true, false);
-};
-exports.buildIntoAndMerge = function(objects, target) {
- include(target, objects, true, true);
-};
-exports.recursiveMerge = recursiveMerge;
-exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
-exports.replaceHookForTesting = function() {};
-
-});
-
-// file: lib/common/channel.js
-define("cordova/channel", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- nextGuid = 1;
-
-/**
- * Custom pub-sub "channel" that can have functions subscribed to it
- * This object is used to define and control firing of events for
- * cordova initialization, as well as for custom events thereafter.
- *
- * The order of events during page load and Cordova startup is as follows:
- *
- * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
- * onNativeReady* Internal event that indicates the Cordova native side is ready.
- * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
- * onCordovaInfoReady* Internal event fired when device properties are available.
- * onCordovaConnectionReady* Internal event fired when the connection property has been set.
- * onDeviceReady* User event fired to indicate that Cordova is ready
- * onResume User event fired to indicate a start/resume lifecycle event
- * onPause User event fired to indicate a pause lifecycle event
- * onDestroy* Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
- *
- * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
- * All listeners that subscribe after the event is fired will be executed right away.
- *
- * The only Cordova events that user code should register for are:
- * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
- * pause App has moved to background
- * resume App has returned to foreground
- *
- * Listeners can be registered as:
- * document.addEventListener("deviceready", myDeviceReadyListener, false);
- * document.addEventListener("resume", myResumeListener, false);
- * document.addEventListener("pause", myPauseListener, false);
- *
- * The DOM lifecycle events should be used for saving and restoring state
- * window.onload
- * window.onunload
- *
- */
-
-/**
- * Channel
- * @constructor
- * @param type String the channel name
- */
-var Channel = function(type, sticky) {
- this.type = type;
- // Map of guid -> function.
- this.handlers = {};
- // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
- this.state = sticky ? 1 : 0;
- // Used in sticky mode to remember args passed to fire().
- this.fireArgs = null;
- // Used by onHasSubscribersChange to know if there are any listeners.
- this.numHandlers = 0;
- // Function that is called when the first listener is subscribed, or when
- // the last listener is unsubscribed.
- this.onHasSubscribersChange = null;
-},
- channel = {
- /**
- * Calls the provided function only after all of the channels specified
- * have been fired. All channels must be sticky channels.
- */
- join: function(h, c) {
- var len = c.length,
- i = len,
- f = function() {
- if (!(--i)) h();
- };
- for (var j=0; j<len; j++) {
- if (c[j].state === 0) {
- throw Error('Can only use join with sticky channels.');
- }
- c[j].subscribe(f);
- }
- if (!len) h();
- },
- create: function(type) {
- return channel[type] = new Channel(type, false);
- },
- createSticky: function(type) {
- return channel[type] = new Channel(type, true);
- },
-
- /**
- * cordova Channels that must fire before "deviceready" is fired.
- */
- deviceReadyChannelsArray: [],
- deviceReadyChannelsMap: {},
-
- /**
- * Indicate that a feature needs to be initialized before it is ready to be used.
- * This holds up Cordova's "deviceready" event until the feature has been initialized
- * and Cordova.initComplete(feature) is called.
- *
- * @param feature {String} The unique feature name
- */
- waitForInitialization: function(feature) {
- if (feature) {
- var c = channel[feature] || this.createSticky(feature);
- this.deviceReadyChannelsMap[feature] = c;
- this.deviceReadyChannelsArray.push(c);
- }
- },
-
- /**
- * Indicate that initialization code has completed and the feature is ready to be used.
- *
- * @param feature {String} The unique feature name
- */
- initializationComplete: function(feature) {
- var c = this.deviceReadyChannelsMap[feature];
- if (c) {
- c.fire();
- }
- }
- };
-
-function forceFunction(f) {
- if (typeof f != 'function') throw "Function required as first argument!";
-}
-
-/**
- * Subscribes the given function to the channel. Any time that
- * Channel.fire is called so too will the function.
- * Optionally specify an execution context for the function
- * and a guid that can be used to stop subscribing to the channel.
- * Returns the guid.
- */
-Channel.prototype.subscribe = function(f, c) {
- // need a function to call
- forceFunction(f);
- if (this.state == 2) {
- f.apply(c || this, this.fireArgs);
- return;
- }
-
- var func = f,
- guid = f.observer_guid;
- if (typeof c == "object") { func = utils.close(c, f); }
-
- if (!guid) {
- // first time any channel has seen this subscriber
- guid = '' + nextGuid++;
- }
- func.observer_guid = guid;
- f.observer_guid = guid;
-
- // Don't add the same handler more than once.
- if (!this.handlers[guid]) {
- this.handlers[guid] = func;
- this.numHandlers++;
- if (this.numHandlers == 1) {
- this.onHasSubscribersChange && this.onHasSubscribersChange();
- }
- }
-};
-
-/**
- * Unsubscribes the function with the given guid from the channel.
- */
-Channel.prototype.unsubscribe = function(f) {
- // need a function to unsubscribe
- forceFunction(f);
-
- var guid = f.observer_guid,
- handler = this.handlers[guid];
- if (handler) {
- delete this.handlers[guid];
- this.numHandlers--;
- if (this.numHandlers === 0) {
- this.onHasSubscribersChange && this.onHasSubscribersChange();
- }
- }
-};
-
-/**
- * Calls all functions subscribed to this channel.
- */
-Channel.prototype.fire = function(e) {
- var fail = false,
- fireArgs = Array.prototype.slice.call(arguments);
- // Apply stickiness.
- if (this.state == 1) {
- this.state = 2;
- this.fireArgs = fireArgs;
- }
- if (this.numHandlers) {
- // Copy the values first so that it is safe to modify it from within
- // callbacks.
- var toCall = [];
- for (var item in this.handlers) {
- toCall.push(this.handlers[item]);
- }
- for (var i = 0; i < toCall.length; ++i) {
- toCall[i].apply(this, fireArgs);
- }
- if (this.state == 2 && this.numHandlers) {
- this.numHandlers = 0;
- this.handlers = {};
- this.onHasSubscribersChange && this.onHasSubscribersChange();
- }
- }
-};
-
-
-// defining them here so they are ready super fast!
-// DOM event that is received when the web page is loaded and parsed.
-channel.createSticky('onDOMContentLoaded');
-
-// Event to indicate the Cordova native side is ready.
-channel.createSticky('onNativeReady');
-
-// Event to indicate that all Cordova JavaScript objects have been created
-// and it's time to run plugin constructors.
-channel.createSticky('onCordovaReady');
-
-// Event to indicate that device properties are available
-channel.createSticky('onCordovaInfoReady');
-
-// Event to indicate that the connection property has been set.
-channel.createSticky('onCordovaConnectionReady');
-
-// Event to indicate that all automatically loaded JS plugins are loaded and ready.
-channel.createSticky('onPluginsReady');
-
-// Event to indicate that Cordova is ready
-channel.createSticky('onDeviceReady');
-
-// Event to indicate a resume lifecycle event
-channel.create('onResume');
-
-// Event to indicate a pause lifecycle event
-channel.create('onPause');
-
-// Event to indicate a destroy lifecycle event
-channel.createSticky('onDestroy');
-
-// Channels that must fire before "deviceready" is fired.
-channel.waitForInitialization('onCordovaReady');
-channel.waitForInitialization('onCordovaConnectionReady');
-channel.waitForInitialization('onDOMContentLoaded');
-
-module.exports = channel;
-
-});
-
-// file: lib/common/commandProxy.js
-define("cordova/commandProxy", function(require, exports, module) {
-
-
-// internal map of proxy function
-var CommandProxyMap = {};
-
-module.exports = {
-
- // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
- add:function(id,proxyObj) {
- console.log("adding proxy for " + id);
- CommandProxyMap[id] = proxyObj;
- return proxyObj;
- },
-
- // cordova.commandProxy.remove("Accelerometer");
- remove:function(id) {
- var proxy = CommandProxyMap[id];
- delete CommandProxyMap[id];
- CommandProxyMap[id] = null;
- return proxy;
- },
-
- get:function(service,action) {
- return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
- }
-};
-});
-
-// file: lib/ios/exec.js
-define("cordova/exec", function(require, exports, module) {
-
-/**
- * Creates a gap bridge iframe used to notify the native code about queued
- * commands.
- *
- * @private
- */
-var cordova = require('cordova'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- jsToNativeModes = {
- IFRAME_NAV: 0,
- XHR_NO_PAYLOAD: 1,
- XHR_WITH_PAYLOAD: 2,
- XHR_OPTIONAL_PAYLOAD: 3
- },
- bridgeMode,
- execIframe,
- execXhr,
- requestCount = 0,
- vcHeaderValue = null,
- commandQueue = [], // Contains pending JS->Native messages.
- isInContextOfEvalJs = 0;
-
-function createExecIframe() {
- var iframe = document.createElement("iframe");
- iframe.style.display = 'none';
- document.body.appendChild(iframe);
- return iframe;
-}
-
-function shouldBundleCommandJson() {
- if (bridgeMode == jsToNativeModes.XHR_WITH_PAYLOAD) {
- return true;
- }
- if (bridgeMode == jsToNativeModes.XHR_OPTIONAL_PAYLOAD) {
- var payloadLength = 0;
- for (var i = 0; i < commandQueue.length; ++i) {
- payloadLength += commandQueue[i].length;
- }
- // The value here was determined using the benchmark within CordovaLibApp on an iPad 3.
- return payloadLength < 4500;
- }
- return false;
-}
-
-function massageArgsJsToNative(args) {
- if (!args || utils.typeName(args) != 'Array') {
- return args;
- }
- var ret = [];
- var encodeArrayBufferAs8bitString = function(ab) {
- return String.fromCharCode.apply(null, new Uint8Array(ab));
- };
- var encodeArrayBufferAsBase64 = function(ab) {
- return window.btoa(encodeArrayBufferAs8bitString(ab));
- };
- args.forEach(function(arg, i) {
- if (utils.typeName(arg) == 'ArrayBuffer') {
- ret.push({
- 'CDVType': 'ArrayBuffer',
- 'data': encodeArrayBufferAsBase64(arg)
- });
- } else {
- ret.push(arg);
- }
- });
- return ret;
-}
-
-function massageMessageNativeToJs(message) {
- if (message.CDVType == 'ArrayBuffer') {
- var stringToArrayBuffer = function(str) {
- var ret = new Uint8Array(str.length);
- for (var i = 0; i < str.length; i++) {
- ret[i] = str.charCodeAt(i);
- }
- return ret.buffer;
- };
- var base64ToArrayBuffer = function(b64) {
- return stringToArrayBuffer(atob(b64));
- };
- message = base64ToArrayBuffer(message.data);
- }
- return message;
-}
-
-function convertMessageToArgsNativeToJs(message) {
- var args = [];
- if (!message || !message.hasOwnProperty('CDVType')) {
- args.push(message);
- } else if (message.CDVType == 'MultiPart') {
- message.messages.forEach(function(e) {
- args.push(massageMessageNativeToJs(e));
- });
- } else {
- args.push(massageMessageNativeToJs(message));
- }
- return args;
-}
-
-function iOSExec() {
- // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices.
- // XHR mode's main advantage is working around a bug in -webkit-scroll, which
- // doesn't exist in 4.X devices anyways.
- if (bridgeMode === undefined) {
- bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_NO_PAYLOAD : jsToNativeModes.IFRAME_NAV;
- }
-
- var successCallback, failCallback, service, action, actionArgs, splitCommand;
- var callbackId = null;
- if (typeof arguments[0] !== "string") {
- // FORMAT ONE
- successCallback = arguments[0];
- failCallback = arguments[1];
- service = arguments[2];
- action = arguments[3];
- actionArgs = arguments[4];
-
- // Since we need to maintain backwards compatibility, we have to pass
- // an invalid callbackId even if no callback was provided since plugins
- // will be expecting it. The Cordova.exec() implementation allocates
- // an invalid callbackId and passes it even if no callbacks were given.
- callbackId = 'INVALID';
- } else {
- // FORMAT TWO, REMOVED
- try {
- splitCommand = arguments[0].split(".");
- action = splitCommand.pop();
- service = splitCommand.join(".");
- actionArgs = Array.prototype.splice.call(arguments, 1);
-
- console.log('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' +
- "cordova.exec(null, null, \"" + service + "\", \"" + action + "\"," + JSON.stringify(actionArgs) + ");"
- );
- return;
- } catch (e) {
- }
- }
-
- // Register the callbacks and add the callbackId to the positional
- // arguments if given.
- if (successCallback || failCallback) {
- callbackId = service + cordova.callbackId++;
- cordova.callbacks[callbackId] =
- {success:successCallback, fail:failCallback};
- }
-
- actionArgs = massageArgsJsToNative(actionArgs);
-
- var command = [callbackId, service, action, actionArgs];
-
- // Stringify and queue the command. We stringify to command now to
- // effectively clone the command arguments in case they are mutated before
- // the command is executed.
- commandQueue.push(JSON.stringify(command));
-
- // If we're in the context of a stringByEvaluatingJavaScriptFromString call,
- // then the queue will be flushed when it returns; no need for a poke.
- // Also, if there is already a command in the queue, then we've already
- // poked the native side, so there is no reason to do so again.
- if (!isInContextOfEvalJs && commandQueue.length == 1) {
- if (bridgeMode != jsToNativeModes.IFRAME_NAV) {
- // This prevents sending an XHR when there is already one being sent.
- // This should happen only in rare circumstances (refer to unit tests).
- if (execXhr && execXhr.readyState != 4) {
- execXhr = null;
- }
- // Re-using the XHR improves exec() performance by about 10%.
- execXhr = execXhr || new XMLHttpRequest();
- // Changing this to a GET will make the XHR reach the URIProtocol on 4.2.
- // For some reason it still doesn't work though...
- // Add a timestamp to the query param to prevent caching.
- execXhr.open('HEAD', "/!gap_exec?" + (+new Date()), true);
- if (!vcHeaderValue) {
- vcHeaderValue = /.*\((.*)\)/.exec(navigator.userAgent)[1];
- }
- execXhr.setRequestHeader('vc', vcHeaderValue);
- execXhr.setRequestHeader('rc', ++requestCount);
- if (shouldBundleCommandJson()) {
- execXhr.setRequestHeader('cmds', iOSExec.nativeFetchMessages());
- }
- execXhr.send(null);
- } else {
- execIframe = execIframe || createExecIframe();
- execIframe.src = "gap://ready";
- }
- }
-}
-
-iOSExec.jsToNativeModes = jsToNativeModes;
-
-iOSExec.setJsToNativeBridgeMode = function(mode) {
- // Remove the iFrame since it may be no longer required, and its existence
- // can trigger browser bugs.
- // https://issues.apache.org/jira/browse/CB-593
- if (execIframe) {
- execIframe.parentNode.removeChild(execIframe);
- execIframe = null;
- }
- bridgeMode = mode;
-};
-
-iOSExec.nativeFetchMessages = function() {
- // Each entry in commandQueue is a JSON string already.
- if (!commandQueue.length) {
- return '';
- }
- var json = '[' + commandQueue.join(',') + ']';
- commandQueue.length = 0;
- return json;
-};
-
-iOSExec.nativeCallback = function(callbackId, status, message, keepCallback) {
- return iOSExec.nativeEvalAndFetch(function() {
- var success = status === 0 || status === 1;
- var args = convertMessageToArgsNativeToJs(message);
- cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
- });
-};
-
-iOSExec.nativeEvalAndFetch = function(func) {
- // This shouldn't be nested, but better to be safe.
- isInContextOfEvalJs++;
- try {
- func();
- return iOSExec.nativeFetchMessages();
- } finally {
- isInContextOfEvalJs--;
- }
-};
-
-module.exports = iOSExec;
-
-});
-
-// file: lib/common/modulemapper.js
-define("cordova/modulemapper", function(require, exports, module) {
-
-var builder = require('cordova/builder'),
- moduleMap = define.moduleMap,
- symbolList,
- deprecationMap;
-
-exports.reset = function() {
- symbolList = [];
- deprecationMap = {};
-};
-
-function addEntry(strategy, moduleName, symbolPath, opt_deprecationMessage) {
- if (!(moduleName in moduleMap)) {
- throw new Error('Module ' + moduleName + ' does not exist.');
- }
- symbolList.push(strategy, moduleName, symbolPath);
- if (opt_deprecationMessage) {
- deprecationMap[symbolPath] = opt_deprecationMessage;
- }
-}
-
-// Note: Android 2.3 does have Function.bind().
-exports.clobbers = function(moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-exports.merges = function(moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-exports.defaults = function(moduleName, symbolPath, opt_deprecationMessage) {
- addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
-};
-
-function prepareNamespace(symbolPath, context) {
- if (!symbolPath) {
- return context;
- }
- var parts = symbolPath.split('.');
- var cur = context;
- for (var i = 0, part; part = parts[i]; ++i) {
- cur = cur[part] = cur[part] || {};
- }
- return cur;
-}
-
-exports.mapModules = function(context) {
- var origSymbols = {};
- context.CDV_origSymbols = origSymbols;
- for (var i = 0, len = symbolList.length; i < len; i += 3) {
- var strategy = symbolList[i];
- var moduleName = symbolList[i + 1];
- var symbolPath = symbolList[i + 2];
- var lastDot = symbolPath.lastIndexOf('.');
- var namespace = symbolPath.substr(0, lastDot);
- var lastName = symbolPath.substr(lastDot + 1);
-
- var module = require(moduleName);
- var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
- var parentObj = prepareNamespace(namespace, context);
- var target = parentObj[lastName];
-
- if (strategy == 'm' && target) {
- builder.recursiveMerge(target, module);
- } else if ((strategy == 'd' && !target) || (strategy != 'd')) {
- if (!(symbolPath in origSymbols)) {
- origSymbols[symbolPath] = target;
- }
- builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
- }
- }
-};
-
-exports.getOriginalSymbol = function(context, symbolPath) {
- var origSymbols = context.CDV_origSymbols;
- if (origSymbols && (symbolPath in origSymbols)) {
- return origSymbols[symbolPath];
- }
- var parts = symbolPath.split('.');
- var obj = context;
- for (var i = 0; i < parts.length; ++i) {
- obj = obj && obj[parts[i]];
- }
- return obj;
-};
-
-exports.loadMatchingModules = function(matchingRegExp) {
- for (var k in moduleMap) {
- if (matchingRegExp.exec(k)) {
- require(k);
- }
- }
-};
-
-exports.reset();
-
-
-});
-
-// file: lib/ios/platform.js
-define("cordova/platform", function(require, exports, module) {
-
-module.exports = {
- id: "ios",
- initialize:function() {
- var modulemapper = require('cordova/modulemapper');
-
- modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
-
- modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
- modulemapper.mapModules(window);
- }
-};
-
-
-});
-
-// file: lib/common/plugin/Acceleration.js
-define("cordova/plugin/Acceleration", function(require, exports, module) {
-
-var Acceleration = function(x, y, z, timestamp) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = timestamp || (new Date()).getTime();
-};
-
-module.exports = Acceleration;
-
-});
-
-// file: lib/common/plugin/Camera.js
-define("cordova/plugin/Camera", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- Camera = require('cordova/plugin/CameraConstants'),
- CameraPopoverHandle = require('cordova/plugin/CameraPopoverHandle');
-
-var cameraExport = {};
-
-// Tack on the Camera Constants to the base camera plugin.
-for (var key in Camera) {
- cameraExport[key] = Camera[key];
-}
-
-/**
- * Gets a picture from source defined by "options.sourceType", and returns the
- * image as defined by the "options.destinationType" option.
-
- * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
- *
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @param {Object} options
- */
-cameraExport.getPicture = function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
- options = options || {};
- var getValue = argscheck.getValue;
-
- var quality = getValue(options.quality, 50);
- var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
- var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
- var targetWidth = getValue(options.targetWidth, -1);
- var targetHeight = getValue(options.targetHeight, -1);
- var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
- var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
- var allowEdit = !!options.allowEdit;
- var correctOrientation = !!options.correctOrientation;
- var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
- var popoverOptions = getValue(options.popoverOptions, null);
- var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
-
- var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
- mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
-
- exec(successCallback, errorCallback, "Camera", "takePicture", args);
- return new CameraPopoverHandle();
-};
-
-cameraExport.cleanup = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "Camera", "cleanup", []);
-};
-
-module.exports = cameraExport;
-
-});
-
-// file: lib/common/plugin/CameraConstants.js
-define("cordova/plugin/CameraConstants", function(require, exports, module) {
-
-module.exports = {
- DestinationType:{
- DATA_URL: 0, // Return base64 encoded string
- FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android)
- NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS)
- },
- EncodingType:{
- JPEG: 0, // Return JPEG encoded image
- PNG: 1 // Return PNG encoded image
- },
- MediaType:{
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
- ALLMEDIA : 2 // allow selection from all media types
- },
- PictureSourceType:{
- PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
- CAMERA : 1, // Take picture from camera
- SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
- },
- PopoverArrowDirection:{
- ARROW_UP : 1, // matches iOS UIPopoverArrowDirection constants to specify arrow location on popover
- ARROW_DOWN : 2,
- ARROW_LEFT : 4,
- ARROW_RIGHT : 8,
- ARROW_ANY : 15
- },
- Direction:{
- BACK: 0,
- FRONT: 1
- }
-};
-
-});
-
-// file: lib/ios/plugin/CameraPopoverHandle.js
-define("cordova/plugin/CameraPopoverHandle", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * A handle to an image picker popover.
- */
-var CameraPopoverHandle = function() {
- this.setPosition = function(popoverOptions) {
- var args = [ popoverOptions ];
- exec(null, null, "Camera", "repositionPopover", args);
- };
-};
-
-module.exports = CameraPopoverHandle;
-
-});
-
-// file: lib/common/plugin/CameraPopoverOptions.js
-define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
-
-var Camera = require('cordova/plugin/CameraConstants');
-
-/**
- * Encapsulates options for iOS Popover image picker
- */
-var CameraPopoverOptions = function(x,y,width,height,arrowDir){
- // information of rectangle that popover should be anchored to
- this.x = x || 0;
- this.y = y || 32;
- this.width = width || 320;
- this.height = height || 480;
- // The direction of the popover arrow
- this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
-};
-
-module.exports = CameraPopoverOptions;
-
-});
-
-// file: lib/common/plugin/CaptureAudioOptions.js
-define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureAudioOptions;
-
-});
-
-// file: lib/common/plugin/CaptureError.js
-define("cordova/plugin/CaptureError", function(require, exports, module) {
-
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(c) {
- this.code = c || null;
-};
-
-// Camera or microphone failed to capture image or sound.
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-// Camera application or audio capture application is currently serving other capture request.
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-// Invalid use of the API (e.g. limit parameter has value less than one).
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-// User exited camera application or audio capture application before capturing anything.
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-// The requested capture operation is not supported.
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-module.exports = CaptureError;
-
-});
-
-// file: lib/common/plugin/CaptureImageOptions.js
-define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
-};
-
-module.exports = CaptureImageOptions;
-
-});
-
-// file: lib/common/plugin/CaptureVideoOptions.js
-define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
-
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureVideoOptions;
-
-});
-
-// file: lib/common/plugin/CompassError.js
-define("cordova/plugin/CompassError", function(require, exports, module) {
-
-/**
- * CompassError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var CompassError = function(err) {
- this.code = (err !== undefined ? err : null);
-};
-
-CompassError.COMPASS_INTERNAL_ERR = 0;
-CompassError.COMPASS_NOT_SUPPORTED = 20;
-
-module.exports = CompassError;
-
-});
-
-// file: lib/common/plugin/CompassHeading.js
-define("cordova/plugin/CompassHeading", function(require, exports, module) {
-
-var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = magneticHeading;
- this.trueHeading = trueHeading;
- this.headingAccuracy = headingAccuracy;
- this.timestamp = timestamp || new Date().getTime();
-};
-
-module.exports = CompassHeading;
-
-});
-
-// file: lib/common/plugin/ConfigurationData.js
-define("cordova/plugin/ConfigurationData", function(require, exports, module) {
-
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-function ConfigurationData() {
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-}
-
-module.exports = ConfigurationData;
-
-});
-
-// file: lib/common/plugin/Connection.js
-define("cordova/plugin/Connection", function(require, exports, module) {
-
-/**
- * Network status
- */
-module.exports = {
- UNKNOWN: "unknown",
- ETHERNET: "ethernet",
- WIFI: "wifi",
- CELL_2G: "2g",
- CELL_3G: "3g",
- CELL_4G: "4g",
- CELL:"cellular",
- NONE: "none"
-};
-
-});
-
-// file: lib/common/plugin/Contact.js
-define("cordova/plugin/Contact", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils');
-
-/**
-* Converts primitives into Complex Object
-* Currently only used for Date fields
-*/
-function convertIn(contact) {
- var value = contact.birthday;
- try {
- contact.birthday = new Date(parseFloat(value));
- } catch (exception){
- console.log("Cordova Contact convertIn error: exception creating date.");
- }
- return contact;
-}
-
-/**
-* Converts Complex objects into primitives
-* Only conversion at present is for Dates.
-**/
-
-function convertOut(contact) {
- var value = contact.birthday;
- if (value !== null) {
- // try to make it a Date object if it is not already
- if (!utils.isDate(value)){
- try {
- value = new Date(value);
- } catch(exception){
- value = null;
- }
- }
- if (utils.isDate(value)){
- value = value.valueOf(); // convert to milliseconds
- }
- contact.birthday = value;
- }
- return contact;
-}
-
-/**
-* Contains information about a single contact.
-* @constructor
-* @param {DOMString} id unique identifier
-* @param {DOMString} displayName
-* @param {ContactName} name
-* @param {DOMString} nickname
-* @param {Array.<ContactField>} phoneNumbers array of phone numbers
-* @param {Array.<ContactField>} emails array of email addresses
-* @param {Array.<ContactAddress>} addresses array of addresses
-* @param {Array.<ContactField>} ims instant messaging user ids
-* @param {Array.<ContactOrganization>} organizations
-* @param {DOMString} birthday contact's birthday
-* @param {DOMString} note user notes about contact
-* @param {Array.<ContactField>} photos
-* @param {Array.<ContactField>} categories
-* @param {Array.<ContactField>} urls contact's web sites
-*/
-var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
- ims, organizations, birthday, note, photos, categories, urls) {
- this.id = id || null;
- this.rawId = null;
- this.displayName = displayName || null;
- this.name = name || null; // ContactName
- this.nickname = nickname || null;
- this.phoneNumbers = phoneNumbers || null; // ContactField[]
- this.emails = emails || null; // ContactField[]
- this.addresses = addresses || null; // ContactAddress[]
- this.ims = ims || null; // ContactField[]
- this.organizations = organizations || null; // ContactOrganization[]
- this.birthday = birthday || null;
- this.note = note || null;
- this.photos = photos || null; // ContactField[]
- this.categories = categories || null; // ContactField[]
- this.urls = urls || null; // ContactField[]
-};
-
-/**
-* Removes contact from device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.remove = function(successCB, errorCB) {
- argscheck.checkArgs('FF', 'Contact.remove', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- if (this.id === null) {
- fail(ContactError.UNKNOWN_ERROR);
- }
- else {
- exec(successCB, fail, "Contacts", "remove", [this.id]);
- }
-};
-
-/**
-* Creates a deep copy of this Contact.
-* With the contact ID set to null.
-* @return copy of this Contact
-*/
-Contact.prototype.clone = function() {
- var clonedContact = utils.clone(this);
- clonedContact.id = null;
- clonedContact.rawId = null;
-
- function nullIds(arr) {
- if (arr) {
- for (var i = 0; i < arr.length; ++i) {
- arr[i].id = null;
- }
- }
- }
-
- // Loop through and clear out any id's in phones, emails, etc.
- nullIds(clonedContact.phoneNumbers);
- nullIds(clonedContact.emails);
- nullIds(clonedContact.addresses);
- nullIds(clonedContact.ims);
- nullIds(clonedContact.organizations);
- nullIds(clonedContact.categories);
- nullIds(clonedContact.photos);
- nullIds(clonedContact.urls);
- return clonedContact;
-};
-
-/**
-* Persists contact to device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.save = function(successCB, errorCB) {
- argscheck.checkArgs('FFO', 'Contact.save', arguments);
- var fail = errorCB && function(code) {
- errorCB(new ContactError(code));
- };
- var success = function(result) {
- if (result) {
- if (successCB) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCB(convertIn(fullContact));
- }
- }
- else {
- // no Entry object returned
- fail(ContactError.UNKNOWN_ERROR);
- }
- };
- var dupContact = convertOut(utils.clone(this));
- exec(success, fail, "Contacts", "save", [dupContact]);
-};
-
-
-module.exports = Contact;
-
-});
-
-// file: lib/common/plugin/ContactAddress.js
-define("cordova/plugin/ContactAddress", function(require, exports, module) {
-
-/**
-* Contact address.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param formatted // NOTE: not a W3C standard
-* @param streetAddress
-* @param locality
-* @param region
-* @param postalCode
-* @param country
-*/
-
-var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.formatted = formatted || null;
- this.streetAddress = streetAddress || null;
- this.locality = locality || null;
- this.region = region || null;
- this.postalCode = postalCode || null;
- this.country = country || null;
-};
-
-module.exports = ContactAddress;
-
-});
-
-// file: lib/common/plugin/ContactError.js
-define("cordova/plugin/ContactError", function(require, exports, module) {
-
-/**
- * ContactError.
- * An error code assigned by an implementation when an error has occurred
- * @constructor
- */
-var ContactError = function(err) {
- this.code = (typeof err != 'undefined' ? err : null);
-};
-
-/**
- * Error codes
- */
-ContactError.UNKNOWN_ERROR = 0;
-ContactError.INVALID_ARGUMENT_ERROR = 1;
-ContactError.TIMEOUT_ERROR = 2;
-ContactError.PENDING_OPERATION_ERROR = 3;
-ContactError.IO_ERROR = 4;
-ContactError.NOT_SUPPORTED_ERROR = 5;
-ContactError.PERMISSION_DENIED_ERROR = 20;
-
-module.exports = ContactError;
-
-});
-
-// file: lib/common/plugin/ContactField.js
-define("cordova/plugin/ContactField", function(require, exports, module) {
-
-/**
-* Generic contact field.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param type
-* @param value
-* @param pref
-*/
-var ContactField = function(type, value, pref) {
- this.id = null;
- this.type = (type && type.toString()) || null;
- this.value = (value && value.toString()) || null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
-};
-
-module.exports = ContactField;
-
-});
-
-// file: lib/common/plugin/ContactFindOptions.js
-define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
-
-/**
- * ContactFindOptions.
- * @constructor
- * @param filter used to match contacts against
- * @param multiple boolean used to determine if more than one contact should be returned
- */
-
-var ContactFindOptions = function(filter, multiple) {
- this.filter = filter || '';
- this.multiple = (typeof multiple != 'undefined' ? multiple : false);
-};
-
-module.exports = ContactFindOptions;
-
-});
-
-// file: lib/common/plugin/ContactName.js
-define("cordova/plugin/ContactName", function(require, exports, module) {
-
-/**
-* Contact name.
-* @constructor
-* @param formatted // NOTE: not part of W3C standard
-* @param familyName
-* @param givenName
-* @param middle
-* @param prefix
-* @param suffix
-*/
-var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
- this.formatted = formatted || null;
- this.familyName = familyName || null;
- this.givenName = givenName || null;
- this.middleName = middle || null;
- this.honorificPrefix = prefix || null;
- this.honorificSuffix = suffix || null;
-};
-
-module.exports = ContactName;
-
-});
-
-// file: lib/common/plugin/ContactOrganization.js
-define("cordova/plugin/ContactOrganization", function(require, exports, module) {
-
-/**
-* Contact organization.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param name
-* @param dept
-* @param title
-* @param startDate
-* @param endDate
-* @param location
-* @param desc
-*/
-
-var ContactOrganization = function(pref, type, name, dept, title) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.name = name || null;
- this.department = dept || null;
- this.title = title || null;
-};
-
-module.exports = ContactOrganization;
-
-});
-
-// file: lib/common/plugin/Coordinates.js
-define("cordova/plugin/Coordinates", function(require, exports, module) {
-
-/**
- * This class contains position information.
- * @param {Object} lat
- * @param {Object} lng
- * @param {Object} alt
- * @param {Object} acc
- * @param {Object} head
- * @param {Object} vel
- * @param {Object} altacc
- * @constructor
- */
-var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
- /**
- * The latitude of the position.
- */
- this.latitude = lat;
- /**
- * The longitude of the position,
- */
- this.longitude = lng;
- /**
- * The accuracy of the position.
- */
- this.accuracy = acc;
- /**
- * The altitude of the position.
- */
- this.altitude = (alt !== undefined ? alt : null);
- /**
- * The direction the device is moving at the position.
- */
- this.heading = (head !== undefined ? head : null);
- /**
- * The velocity with which the device is moving at the position.
- */
- this.speed = (vel !== undefined ? vel : null);
-
- if (this.speed === 0 || this.speed === null) {
- this.heading = NaN;
- }
-
- /**
- * The altitude accuracy of the position.
- */
- this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
-};
-
-module.exports = Coordinates;
-
-});
-
-// file: lib/common/plugin/DirectoryEntry.js
-define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileError = require('cordova/plugin/FileError'),
- DirectoryReader = require('cordova/plugin/DirectoryReader');
-
-/**
- * An interface representing a directory on the file system.
- *
- * {boolean} isFile always false (readonly)
- * {boolean} isDirectory always true (readonly)
- * {DOMString} name of the directory, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the directory (readonly)
- * TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
- */
-var DirectoryEntry = function(name, fullPath) {
- DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
-};
-
-utils.extend(DirectoryEntry, Entry);
-
-/**
- * Creates a new DirectoryReader to read entries from this directory
- */
-DirectoryEntry.prototype.createReader = function() {
- return new DirectoryReader(this.fullPath);
-};
-
-/**
- * Creates or looks up a directory
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or exclusively create the directory
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
- var win = successCallback && function(result) {
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
-};
-
-/**
- * Deletes a directory and all of it's contents
- *
- * @param {Function} successCallback is called with no parameters
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
-};
-
-/**
- * Creates or looks up a file
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or exclusively create the file
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
- argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
- var win = successCallback && function(result) {
- var FileEntry = require('cordova/plugin/FileEntry');
- var entry = new FileEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
-};
-
-module.exports = DirectoryEntry;
-
-});
-
-// file: lib/common/plugin/DirectoryReader.js
-define("cordova/plugin/DirectoryReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError') ;
-
-/**
- * An interface that lists the files and directories in a directory.
- */
-function DirectoryReader(path) {
- this.path = path || null;
-}
-
-/**
- * Returns a list of entries from a directory.
- *
- * @param {Function} successCallback is called with a list of entries
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var retVal = [];
- for (var i=0; i<result.length; i++) {
- var entry = null;
- if (result[i].isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result[i].isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result[i].isDirectory;
- entry.isFile = result[i].isFile;
- entry.name = result[i].name;
- entry.fullPath = result[i].fullPath;
- retVal.push(entry);
- }
- successCallback(retVal);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "readEntries", [this.path]);
-};
-
-module.exports = DirectoryReader;
-
-});
-
-// file: lib/common/plugin/Entry.js
-define("cordova/plugin/Entry", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- Metadata = require('cordova/plugin/Metadata');
-
-/**
- * Represents a file or directory on the local file system.
- *
- * @param isFile
- * {boolean} true if Entry is a file (readonly)
- * @param isDirectory
- * {boolean} true if Entry is a directory (readonly)
- * @param name
- * {DOMString} name of the file or directory, excluding the path
- * leading to it (readonly)
- * @param fullPath
- * {DOMString} the absolute full path to the file or directory
- * (readonly)
- */
-function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
- this.isFile = !!isFile;
- this.isDirectory = !!isDirectory;
- this.name = name || '';
- this.fullPath = fullPath || '';
- this.filesystem = fileSystem || null;
-}
-
-/**
- * Look up the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- */
-Entry.prototype.getMetadata = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
- var success = successCallback && function(lastModified) {
- var metadata = new Metadata(lastModified);
- successCallback(metadata);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- exec(success, fail, "File", "getMetadata", [this.fullPath]);
-};
-
-/**
- * Set the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- * @param metadataObject
- * {Object} keys and values to set
- */
-Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
- argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
- exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
-};
-
-/**
- * Move a file or directory to a new location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to move this entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new DirectoryEntry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Copy a directory to a different location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to copy the entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new Entry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
- argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
-
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- // success callback
- success = function(entry) {
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail && fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // copy
- exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Return a URL that can be used to identify this entry.
- */
-Entry.prototype.toURL = function() {
- // fullPath attribute contains the full URL
- return this.fullPath;
-};
-
-/**
- * Returns a URI that can be used to identify this entry.
- *
- * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
- * @return uri
- */
-Entry.prototype.toURI = function(mimeType) {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- // fullPath attribute contains the full URI
- return this.toURL();
-};
-
-/**
- * Remove a file or directory. It is an error to attempt to delete a
- * directory that is not empty. It is an error to attempt to delete a
- * root directory of a file system.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.remove = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.remove', arguments);
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "remove", [this.fullPath]);
-};
-
-/**
- * Look up the parent DirectoryEntry of this entry.
- *
- * @param successCallback {Function} called with the parent DirectoryEntry object
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.getParent = function(successCallback, errorCallback) {
- argscheck.checkArgs('FF', 'Entry.getParent', arguments);
- var win = successCallback && function(result) {
- var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getParent", [this.fullPath]);
-};
-
-module.exports = Entry;
-
-});
-
-// file: lib/common/plugin/File.js
-define("cordova/plugin/File", function(require, exports, module) {
-
-/**
- * Constructor.
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-
-var File = function(name, fullPath, type, lastModifiedDate, size){
- this.name = name || '';
- this.fullPath = fullPath || null;
- this.type = type || null;
- this.lastModifiedDate = lastModifiedDate || null;
- this.size = size || 0;
-
- // These store the absolute start and end for slicing the file.
- this.start = 0;
- this.end = this.size;
-};
-
-/**
- * Returns a "slice" of the file. Since Cordova Files don't contain the actual
- * content, this really returns a File with adjusted start and end.
- * Slices of slices are supported.
- * start {Number} The index at which to start the slice (inclusive).
- * end {Number} The index at which to end the slice (exclusive).
- */
-File.prototype.slice = function(start, end) {
- var size = this.end - this.start;
- var newStart = 0;
- var newEnd = size;
- if (arguments.length) {
- if (start < 0) {
- newStart = Math.max(size + start, 0);
- } else {
- newStart = Math.min(size, start);
- }
- }
-
- if (arguments.length >= 2) {
- if (end < 0) {
- newEnd = Math.max(size + end, 0);
- } else {
- newEnd = Math.min(end, size);
- }
- }
-
- var newFile = new File(this.name, this.fullPath, this.type, this.lastModifiedData, this.size);
- newFile.start = this.start + newStart;
- newFile.end = this.start + newEnd;
- return newFile;
-};
-
-
-module.exports = File;
-
-});
-
-// file: lib/common/plugin/FileEntry.js
-define("cordova/plugin/FileEntry", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileWriter = require('cordova/plugin/FileWriter'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface representing a file on the file system.
- *
- * {boolean} isFile always true (readonly)
- * {boolean} isDirectory always false (readonly)
- * {DOMString} name of the file, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the file (readonly)
- * {FileSystem} filesystem on which the file resides (readonly)
- */
-var FileEntry = function(name, fullPath) {
- FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
-};
-
-utils.extend(FileEntry, Entry);
-
-/**
- * Creates a new FileWriter associated with the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new FileWriter
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
- this.file(function(filePointer) {
- var writer = new FileWriter(filePointer);
-
- if (writer.fileName === null || writer.fileName === "") {
- errorCallback && errorCallback(new FileError(FileError.INVALID_STATE_ERR));
- } else {
- successCallback && successCallback(writer);
- }
- }, errorCallback);
-};
-
-/**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new File object
- * @param {Function} errorCallback is called with a FileError
- */
-FileEntry.prototype.file = function(successCallback, errorCallback) {
- var win = successCallback && function(f) {
- var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
- successCallback(file);
- };
- var fail = errorCallback && function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
-};
-
-
-module.exports = FileEntry;
-
-});
-
-// file: lib/common/plugin/FileError.js
-define("cordova/plugin/FileError", function(require, exports, module) {
-
-/**
- * FileError
- */
-function FileError(error) {
- this.code = error || null;
-}
-
-// File error codes
-// Found in DOMException
-FileError.NOT_FOUND_ERR = 1;
-FileError.SECURITY_ERR = 2;
-FileError.ABORT_ERR = 3;
-
-// Added by File API specification
-FileError.NOT_READABLE_ERR = 4;
-FileError.ENCODING_ERR = 5;
-FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
-FileError.INVALID_STATE_ERR = 7;
-FileError.SYNTAX_ERR = 8;
-FileError.INVALID_MODIFICATION_ERR = 9;
-FileError.QUOTA_EXCEEDED_ERR = 10;
-FileError.TYPE_MISMATCH_ERR = 11;
-FileError.PATH_EXISTS_ERR = 12;
-
-module.exports = FileError;
-
-});
-
-// file: lib/common/plugin/FileReader.js
-define("cordova/plugin/FileReader", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- modulemapper = require('cordova/modulemapper'),
- utils = require('cordova/utils'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent'),
- origFileReader = modulemapper.getOriginalSymbol(this, 'FileReader');
-
-/**
- * This class reads the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To read from the SD card, the file name is "sdcard/my_file.txt"
- * @constructor
- */
-var FileReader = function() {
- this._readyState = 0;
- this._error = null;
- this._result = null;
- this._fileName = '';
- this._realReader = origFileReader ? new origFileReader() : {};
-};
-
-// States
-FileReader.EMPTY = 0;
-FileReader.LOADING = 1;
-FileReader.DONE = 2;
-
-utils.defineGetter(FileReader.prototype, 'readyState', function() {
- return this._fileName ? this._readyState : this._realReader.readyState;
-});
-
-utils.defineGetter(FileReader.prototype, 'error', function() {
- return this._fileName ? this._error: this._realReader.error;
-});
-
-utils.defineGetter(FileReader.prototype, 'result', function() {
- return this._fileName ? this._result: this._realReader.result;
-});
-
-function defineEvent(eventName) {
- utils.defineGetterSetter(FileReader.prototype, eventName, function() {
- return this._realReader[eventName] || null;
- }, function(value) {
- this._realReader[eventName] = value;
- });
-}
-defineEvent('onloadstart'); // When the read starts.
-defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
-defineEvent('onload'); // When the read has successfully completed.
-defineEvent('onerror'); // When the read has failed (see errors).
-defineEvent('onloadend'); // When the request has completed (either in success or failure).
-defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method.
-
-function initRead(reader, file) {
- // Already loading something
- if (reader.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- reader._result = null;
- reader._error = null;
- reader._readyState = FileReader.LOADING;
-
- if (typeof file.fullPath == 'string') {
- reader._fileName = file.fullPath;
- } else {
- reader._fileName = '';
- return true;
- }
-
- reader.onloadstart && reader.onloadstart(new ProgressEvent("loadstart", {target:reader}));
-}
-
-/**
- * Abort reading file.
- */
-FileReader.prototype.abort = function() {
- if (origFileReader && !this._fileName) {
- return this._realReader.abort();
- }
- this._result = null;
-
- if (this._readyState == FileReader.DONE || this._readyState == FileReader.EMPTY) {
- return;
- }
-
- this._readyState = FileReader.DONE;
-
- // If abort callback
- if (typeof this.onabort === 'function') {
- this.onabort(new ProgressEvent('abort', {target:this}));
- }
- // If load end callback
- if (typeof this.onloadend === 'function') {
- this.onloadend(new ProgressEvent('loadend', {target:this}));
- }
-};
-
-/**
- * Read text file.
- *
- * @param file {File} File object containing file properties
- * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
- */
-FileReader.prototype.readAsText = function(file, encoding) {
- if (initRead(this, file)) {
- return this._realReader.readAsText(file, encoding);
- }
-
- // Default encoding is UTF-8
- var enc = encoding ? encoding : "UTF-8";
- var me = this;
- var execArgs = [this._fileName, enc, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // null result
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsText", execArgs);
-};
-
-
-/**
- * Read file and return data as a base64 encoded data url.
- * A data url is of the form:
- * data:[<mediatype>][;base64],<data>
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsDataURL = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsDataURL(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- // Save result
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsDataURL", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsBinaryString = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsBinaryString(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsBinaryString", execArgs);
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsArrayBuffer = function(file) {
- if (initRead(this, file)) {
- return this._realReader.readAsArrayBuffer(file);
- }
-
- var me = this;
- var execArgs = [this._fileName, file.start, file.end];
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me._readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me._readyState = FileReader.DONE;
-
- me._result = null;
-
- // Save error
- me._error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }, "File", "readAsArrayBuffer", execArgs);
-};
-
-module.exports = FileReader;
-
-});
-
-// file: lib/common/plugin/FileSystem.js
-define("cordova/plugin/FileSystem", function(require, exports, module) {
-
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-
-/**
- * An interface representing a file system
- *
- * @constructor
- * {DOMString} name the unique name of the file system (readonly)
- * {DirectoryEntry} root directory of the file system (readonly)
- */
-var FileSystem = function(name, root) {
- this.name = name || null;
- if (root) {
- this.root = new DirectoryEntry(root.name, root.fullPath);
- }
-};
-
-module.exports = FileSystem;
-
-});
-
-// file: lib/common/plugin/FileTransfer.js
-define("cordova/plugin/FileTransfer", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- FileTransferError = require('cordova/plugin/FileTransferError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-function newProgressEvent(result) {
- var pe = new ProgressEvent();
- pe.lengthComputable = result.lengthComputable;
- pe.loaded = result.loaded;
- pe.total = result.total;
- return pe;
-}
-
-function getBasicAuthHeader(urlString) {
- var header = null;
-
- if (window.btoa) {
- // parse the url using the Location object
- var url = document.createElement('a');
- url.href = urlString;
-
- var credentials = null;
- var protocol = url.protocol + "//";
- var origin = protocol + url.host;
-
- // check whether there are the username:password credentials in the url
- if (url.href.indexOf(origin) !== 0) { // credentials found
- var atIndex = url.href.indexOf("@");
- credentials = url.href.substring(protocol.length, atIndex);
- }
-
- if (credentials) {
- var authHeader = "Authorization";
- var authHeaderValue = "Basic " + window.btoa(credentials);
-
- header = {
- name : authHeader,
- value : authHeaderValue
- };
- }
- }
-
- return header;
-}
-
-var idCounter = 0;
-
-/**
- * FileTransfer uploads a file to a remote server.
- * @constructor
- */
-var FileTransfer = function() {
- this._id = ++idCounter;
- this.onprogress = null; // optional callback
-};
-
-/**
-* Given an absolute file path, uploads a file on the device to a remote server
-* using a multipart HTTP request.
-* @param filePath {String} Full path of the file on the device
-* @param server {String} URL of the server to receive the file
-* @param successCallback (Function} Callback to be invoked when upload has completed
-* @param errorCallback {Function} Callback to be invoked upon error
-* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
-* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
-*/
-FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
- argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments);
- // check for options
- var fileKey = null;
- var fileName = null;
- var mimeType = null;
- var params = null;
- var chunkedMode = true;
- var headers = null;
- var httpMethod = null;
- var basicAuthHeader = getBasicAuthHeader(server);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- if (options) {
- fileKey = options.fileKey;
- fileName = options.fileName;
- mimeType = options.mimeType;
- headers = options.headers;
- httpMethod = options.httpMethod || "POST";
- if (httpMethod.toUpperCase() == "PUT"){
- httpMethod = "PUT";
- } else {
- httpMethod = "POST";
- }
- if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
- chunkedMode = options.chunkedMode;
- }
- if (options.params) {
- params = options.params;
- }
- else {
- params = {};
- }
- }
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- var self = this;
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- self.onprogress(newProgressEvent(result));
- }
- } else {
- successCallback && successCallback(result);
- }
- };
- exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
-};
-
-/**
- * Downloads a file form a given URL and saves it to the specified directory.
- * @param source {String} URL of the server to receive the file
- * @param target {String} Full path of the file on the device
- * @param successCallback (Function} Callback to be invoked when upload has completed
- * @param errorCallback {Function} Callback to be invoked upon error
- * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
- * @param options {FileDownloadOptions} Optional parameters such as headers
- */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) {
- argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
- var self = this;
-
- var basicAuthHeader = getBasicAuthHeader(source);
- if (basicAuthHeader) {
- options = options || {};
- options.headers = options.headers || {};
- options.headers[basicAuthHeader.name] = basicAuthHeader.value;
- }
-
- var headers = null;
- if (options) {
- headers = options.headers || null;
- }
-
- var win = function(result) {
- if (typeof result.lengthComputable != "undefined") {
- if (self.onprogress) {
- return self.onprogress(newProgressEvent(result));
- }
- } else if (successCallback) {
- var entry = null;
- if (result.isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result.isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result.isDirectory;
- entry.isFile = result.isFile;
- entry.name = result.name;
- entry.fullPath = result.fullPath;
- successCallback(entry);
- }
- };
-
- var fail = errorCallback && function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
- errorCallback(error);
- };
-
- exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
-};
-
-/**
- * Aborts the ongoing file transfer on this object. The original error
- * callback for the file transfer will be called if necessary.
- */
-FileTransfer.prototype.abort = function() {
- exec(null, null, 'FileTransfer', 'abort', [this._id]);
-};
-
-module.exports = FileTransfer;
-
-});
-
-// file: lib/common/plugin/FileTransferError.js
-define("cordova/plugin/FileTransferError", function(require, exports, module) {
-
-/**
- * FileTransferError
- * @constructor
- */
-var FileTransferError = function(code, source, target, status, body) {
- this.code = code || null;
- this.source = source || null;
- this.target = target || null;
- this.http_status = status || null;
- this.body = body || null;
-};
-
-FileTransferError.FILE_NOT_FOUND_ERR = 1;
-FileTransferError.INVALID_URL_ERR = 2;
-FileTransferError.CONNECTION_ERR = 3;
-FileTransferError.ABORT_ERR = 4;
-
-module.exports = FileTransferError;
-
-});
-
-// file: lib/common/plugin/FileUploadOptions.js
-define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
-
-/**
- * Options to customize the HTTP request used to upload files.
- * @constructor
- * @param fileKey {String} Name of file request parameter.
- * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
- * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
- * @param params {Object} Object with key: value params to send to the server.
- * @param headers {Object} Keys are header names, values are header values. Multiple
- * headers of the same name are not supported.
- */
-var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers, httpMethod) {
- this.fileKey = fileKey || null;
- this.fileName = fileName || null;
- this.mimeType = mimeType || null;
- this.params = params || null;
- this.headers = headers || null;
- this.httpMethod = httpMethod || null;
-};
-
-module.exports = FileUploadOptions;
-
-});
-
-// file: lib/common/plugin/FileUploadResult.js
-define("cordova/plugin/FileUploadResult", function(require, exports, module) {
-
-/**
- * FileUploadResult
- * @constructor
- */
-var FileUploadResult = function() {
- this.bytesSent = 0;
- this.responseCode = null;
- this.response = null;
-};
-
-module.exports = FileUploadResult;
-
-});
-
-// file: lib/common/plugin/FileWriter.js
-define("cordova/plugin/FileWriter", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class writes to the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To write to the SD card, the file name is "sdcard/my_file.txt"
- *
- * @constructor
- * @param file {File} File object containing file properties
- * @param append if true write to the end of the file, otherwise overwrite the file
- */
-var FileWriter = function(file) {
- this.fileName = "";
- this.length = 0;
- if (file) {
- this.fileName = file.fullPath || file;
- this.length = file.size || 0;
- }
- // default is to write at the beginning of the file
- this.position = 0;
-
- this.readyState = 0; // EMPTY
-
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onwritestart = null; // When writing starts
- this.onprogress = null; // While writing the file, and reporting partial file data
- this.onwrite = null; // When the write has successfully completed.
- this.onwriteend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
- this.onerror = null; // When the write has failed (see errors).
-};
-
-// States
-FileWriter.INIT = 0;
-FileWriter.WRITING = 1;
-FileWriter.DONE = 2;
-
-/**
- * Abort writing file.
- */
-FileWriter.prototype.abort = function() {
- // check for invalid state
- if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // set error
- this.error = new FileError(FileError.ABORT_ERR);
-
- this.readyState = FileWriter.DONE;
-
- // If abort callback
- if (typeof this.onabort === "function") {
- this.onabort(new ProgressEvent("abort", {"target":this}));
- }
-
- // If write end callback
- if (typeof this.onwriteend === "function") {
- this.onwriteend(new ProgressEvent("writeend", {"target":this}));
- }
-};
-
-/**
- * Writes data to the file
- *
- * @param data text or blob to be written
- */
-FileWriter.prototype.write = function(data) {
-
- var isBinary = false;
-
- // If we don't have Blob or ArrayBuffer support, don't bother.
- if (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined') {
-
- // Check to see if the incoming data is a blob
- if (data instanceof Blob) {
- var that=this;
- var fileReader = new FileReader();
- fileReader.onload = function() {
- // Call this method again, with the arraybuffer as argument
- FileWriter.prototype.write.call(that, this.result);
- };
- fileReader.readAsArrayBuffer(data);
- return;
- }
-
- // Mark data type for safer transport over the binary bridge
- isBinary = (data instanceof ArrayBuffer);
- }
-
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":me}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // position always increases by bytes written because file would be extended
- me.position += r;
- // The length of the file is now where we are done writing.
-
- me.length = me.position;
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "write", [this.fileName, data, this.position, isBinary]);
-};
-
-/**
- * Moves the file pointer to the location specified.
- *
- * If the offset is a negative number the position of the file
- * pointer is rewound. If the offset is greater than the file
- * size the position is set to the end of the file.
- *
- * @param offset is the location to move the file pointer to.
- */
-FileWriter.prototype.seek = function(offset) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- if (!offset && offset !== 0) {
- return;
- }
-
- // See back from end of file.
- if (offset < 0) {
- this.position = Math.max(offset + this.length, 0);
- }
- // Offset is bigger than file size so set position
- // to the end of the file.
- else if (offset > this.length) {
- this.position = this.length;
- }
- // Offset is between 0 and file size so set the position
- // to start writing.
- else {
- this.position = offset;
- }
-};
-
-/**
- * Truncates the file to the size specified.
- *
- * @param size to chop the file at.
- */
-FileWriter.prototype.truncate = function(size) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":this}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Update the length of the file
- me.length = r;
- me.position = Math.min(me.position, r);
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "truncate", [this.fileName, size]);
-};
-
-module.exports = FileWriter;
-
-});
-
-// file: lib/common/plugin/Flags.js
-define("cordova/plugin/Flags", function(require, exports, module) {
-
-/**
- * Supplies arguments to methods that lookup or create files and directories.
- *
- * @param create
- * {boolean} file or directory if it doesn't exist
- * @param exclusive
- * {boolean} used with create; if true the command will fail if
- * target path exists
- */
-function Flags(create, exclusive) {
- this.create = create || false;
- this.exclusive = exclusive || false;
-}
-
-module.exports = Flags;
-
-});
-
-// file: lib/common/plugin/GlobalizationError.js
-define("cordova/plugin/GlobalizationError", function(require, exports, module) {
-
-
-/**
- * Globalization error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var GlobalizationError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-// Globalization error codes
-GlobalizationError.UNKNOWN_ERROR = 0;
-GlobalizationError.FORMATTING_ERROR = 1;
-GlobalizationError.PARSING_ERROR = 2;
-GlobalizationError.PATTERN_ERROR = 3;
-
-module.exports = GlobalizationError;
-
-});
-
-// file: lib/common/plugin/InAppBrowser.js
-define("cordova/plugin/InAppBrowser", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var channel = require('cordova/channel');
-var modulemapper = require('cordova/modulemapper');
-
-function InAppBrowser() {
- this.channels = {
- 'loadstart': channel.create('loadstart'),
- 'loadstop' : channel.create('loadstop'),
- 'loaderror' : channel.create('loaderror'),
- 'exit' : channel.create('exit')
- };
-}
-
-InAppBrowser.prototype = {
- _eventHandler: function (event) {
- if (event.type in this.channels) {
- this.channels[event.type].fire(event);
- }
- },
- close: function (eventname) {
- exec(null, null, "InAppBrowser", "close", []);
- },
- show: function (eventname) {
- exec(null, null, "InAppBrowser", "show", []);
- },
- addEventListener: function (eventname,f) {
- if (eventname in this.channels) {
- this.channels[eventname].subscribe(f);
- }
- },
- removeEventListener: function(eventname, f) {
- if (eventname in this.channels) {
- this.channels[eventname].unsubscribe(f);
- }
- },
-
- executeScript: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('executeScript requires exactly one of code or file to be specified');
- }
- },
-
- insertCSS: function(injectDetails, cb) {
- if (injectDetails.code) {
- exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
- } else if (injectDetails.file) {
- exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
- } else {
- throw new Error('insertCSS requires exactly one of code or file to be specified');
- }
- }
-};
-
-module.exports = function(strUrl, strWindowName, strWindowFeatures) {
- var iab = new InAppBrowser();
- var cb = function(eventname) {
- iab._eventHandler(eventname);
- };
-
- // Don't catch calls that write to existing frames (e.g. named iframes).
- if (window.frames && window.frames[strWindowName]) {
- var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
- return origOpenFunc.apply(window, arguments);
- }
-
- exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
- return iab;
-};
-
-
-});
-
-// file: lib/common/plugin/LocalFileSystem.js
-define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Represents a local file system.
- */
-var LocalFileSystem = function() {
-
-};
-
-LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
-LocalFileSystem.PERSISTENT = 1; //persistent
-
-module.exports = LocalFileSystem;
-
-});
-
-// file: lib/common/plugin/Media.js
-define("cordova/plugin/Media", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-var mediaObjects = {};
-
-/**
- * This class provides access to the device media, interfaces to both sound and video
- *
- * @constructor
- * @param src The file name or url to play
- * @param successCallback The callback to be called when the file is done playing or recording.
- * successCallback()
- * @param errorCallback The callback to be called if there is an error.
- * errorCallback(int errorCode) - OPTIONAL
- * @param statusCallback The callback to be called when media status has changed.
- * statusCallback(int statusCode) - OPTIONAL
- */
-var Media = function(src, successCallback, errorCallback, statusCallback) {
- argscheck.checkArgs('SFFF', 'Media', arguments);
- this.id = utils.createUUID();
- mediaObjects[this.id] = this;
- this.src = src;
- this.successCallback = successCallback;
- this.errorCallback = errorCallback;
- this.statusCallback = statusCallback;
- this._duration = -1;
- this._position = -1;
- exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
-};
-
-// Media messages
-Media.MEDIA_STATE = 1;
-Media.MEDIA_DURATION = 2;
-Media.MEDIA_POSITION = 3;
-Media.MEDIA_ERROR = 9;
-
-// Media states
-Media.MEDIA_NONE = 0;
-Media.MEDIA_STARTING = 1;
-Media.MEDIA_RUNNING = 2;
-Media.MEDIA_PAUSED = 3;
-Media.MEDIA_STOPPED = 4;
-Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"];
-
-// "static" function to return existing objs.
-Media.get = function(id) {
- return mediaObjects[id];
-};
-
-/**
- * Start or resume playing audio file.
- */
-Media.prototype.play = function(options) {
- exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
-};
-
-/**
- * Stop playing audio file.
- */
-Media.prototype.stop = function() {
- var me = this;
- exec(function() {
- me._position = 0;
- }, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
-};
-
-/**
- * Seek or jump to a new time in the track..
- */
-Media.prototype.seekTo = function(milliseconds) {
- var me = this;
- exec(function(p) {
- me._position = p;
- }, this.errorCallback, "Media", "seekToAudio", [this.id, milliseconds]);
-};
-
-/**
- * Pause playing audio file.
- */
-Media.prototype.pause = function() {
- exec(null, this.errorCallback, "Media", "pausePlayingAudio", [this.id]);
-};
-
-/**
- * Get duration of an audio file.
- * The duration is only set for audio that is playing, paused or stopped.
- *
- * @return duration or -1 if not known.
- */
-Media.prototype.getDuration = function() {
- return this._duration;
-};
-
-/**
- * Get position of audio.
- */
-Media.prototype.getCurrentPosition = function(success, fail) {
- var me = this;
- exec(function(p) {
- me._position = p;
- success(p);
- }, fail, "Media", "getCurrentPositionAudio", [this.id]);
-};
-
-/**
- * Start recording audio file.
- */
-Media.prototype.startRecord = function() {
- exec(null, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
-};
-
-/**
- * Stop recording audio file.
- */
-Media.prototype.stopRecord = function() {
- exec(null, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
-};
-
-/**
- * Release the resources.
- */
-Media.prototype.release = function() {
- exec(null, this.errorCallback, "Media", "release", [this.id]);
-};
-
-/**
- * Adjust the volume.
- */
-Media.prototype.setVolume = function(volume) {
- exec(null, null, "Media", "setVolume", [this.id, volume]);
-};
-
-/**
- * Audio has status update.
- * PRIVATE
- *
- * @param id The media object id (string)
- * @param msgType The 'type' of update this is
- * @param value Use of value is determined by the msgType
- */
-Media.onStatus = function(id, msgType, value) {
-
- var media = mediaObjects[id];
-
- if(media) {
- switch(msgType) {
- case Media.MEDIA_STATE :
- media.statusCallback && media.statusCallback(value);
- if(value == Media.MEDIA_STOPPED) {
- media.successCallback && media.successCallback();
- }
- break;
- case Media.MEDIA_DURATION :
- media._duration = value;
- break;
- case Media.MEDIA_ERROR :
- media.errorCallback && media.errorCallback(value);
- break;
- case Media.MEDIA_POSITION :
- media._position = Number(value);
- break;
- default :
- console.error && console.error("Unhandled Media.onStatus :: " + msgType);
- break;
- }
- }
- else {
- console.error && console.error("Received Media.onStatus callback for unknown media :: " + id);
- }
-
-};
-
-module.exports = Media;
-
-});
-
-// file: lib/common/plugin/MediaError.js
-define("cordova/plugin/MediaError", function(require, exports, module) {
-
-/**
- * This class contains information about any Media errors.
-*/
-/*
- According to :: http://dev.w3.org/html5/spec-author-view/video.html#mediaerror
- We should never be creating these objects, we should just implement the interface
- which has 1 property for an instance, 'code'
-
- instead of doing :
- errorCallbackFunction( new MediaError(3,'msg') );
-we should simply use a literal :
- errorCallbackFunction( {'code':3} );
- */
-
- var _MediaError = window.MediaError;
-
-
-if(!_MediaError) {
- window.MediaError = _MediaError = function(code, msg) {
- this.code = (typeof code != 'undefined') ? code : null;
- this.message = msg || ""; // message is NON-standard! do not use!
- };
-}
-
-_MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
-_MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1;
-_MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2;
-_MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3;
-_MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
-// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
-// as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes
-_MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
-
-module.exports = _MediaError;
-
-});
-
-// file: lib/common/plugin/MediaFile.js
-define("cordova/plugin/MediaFile", function(require, exports, module) {
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- File = require('cordova/plugin/File'),
- CaptureError = require('cordova/plugin/CaptureError');
-/**
- * Represents a single file.
- *
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
-};
-
-utils.extend(MediaFile, File);
-
-/**
- * Request capture format data for a specific file and type
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
- if (typeof this.fullPath === "undefined" || this.fullPath === null) {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- } else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
- }
-};
-
-module.exports = MediaFile;
-
-});
-
-// file: lib/common/plugin/MediaFileData.js
-define("cordova/plugin/MediaFileData", function(require, exports, module) {
-
-/**
- * MediaFileData encapsulates format information of a media file.
- *
- * @param {DOMString} codecs
- * @param {long} bitrate
- * @param {long} height
- * @param {long} width
- * @param {float} duration
- */
-var MediaFileData = function(codecs, bitrate, height, width, duration){
- this.codecs = codecs || null;
- this.bitrate = bitrate || 0;
- this.height = height || 0;
- this.width = width || 0;
- this.duration = duration || 0;
-};
-
-module.exports = MediaFileData;
-
-});
-
-// file: lib/common/plugin/Metadata.js
-define("cordova/plugin/Metadata", function(require, exports, module) {
-
-/**
- * Information about the state of the file or directory
- *
- * {Date} modificationTime (readonly)
- */
-var Metadata = function(time) {
- this.modificationTime = (typeof time != 'undefined'?new Date(time):null);
-};
-
-module.exports = Metadata;
-
-});
-
-// file: lib/common/plugin/Position.js
-define("cordova/plugin/Position", function(require, exports, module) {
-
-var Coordinates = require('cordova/plugin/Coordinates');
-
-var Position = function(coords, timestamp) {
- if (coords) {
- this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
- } else {
- this.coords = new Coordinates();
- }
- this.timestamp = (timestamp !== undefined) ? timestamp : new Date();
-};
-
-module.exports = Position;
-
-});
-
-// file: lib/common/plugin/PositionError.js
-define("cordova/plugin/PositionError", function(require, exports, module) {
-
-/**
- * Position error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var PositionError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-PositionError.PERMISSION_DENIED = 1;
-PositionError.POSITION_UNAVAILABLE = 2;
-PositionError.TIMEOUT = 3;
-
-module.exports = PositionError;
-
-});
-
-// file: lib/common/plugin/ProgressEvent.js
-define("cordova/plugin/ProgressEvent", function(require, exports, module) {
-
-// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
-// Feature test: See if we can instantiate a native ProgressEvent;
-// if so, use that approach,
-// otherwise fill-in with our own implementation.
-//
-// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
-var ProgressEvent = (function() {
- /*
- var createEvent = function(data) {
- var event = document.createEvent('Events');
- event.initEvent('ProgressEvent', false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- if (data.target) {
- // TODO: cannot call <some_custom_object>.dispatchEvent
- // need to first figure out how to implement EventTarget
- }
- }
- return event;
- };
- try {
- var ev = createEvent({type:"abort",target:document});
- return function ProgressEvent(type, data) {
- data.type = type;
- return createEvent(data);
- };
- } catch(e){
- */
- return function ProgressEvent(type, dict) {
- this.type = type;
- this.bubbles = false;
- this.cancelBubble = false;
- this.cancelable = false;
- this.lengthComputable = false;
- this.loaded = dict && dict.loaded ? dict.loaded : 0;
- this.total = dict && dict.total ? dict.total : 0;
- this.target = dict && dict.target ? dict.target : null;
- };
- //}
-})();
-
-module.exports = ProgressEvent;
-
-});
-
-// file: lib/common/plugin/accelerometer.js
-define("cordova/plugin/accelerometer", function(require, exports, module) {
-
-/**
- * This class provides access to device accelerometer data.
- * @constructor
- */
-var argscheck = require('cordova/argscheck'),
- utils = require("cordova/utils"),
- exec = require("cordova/exec"),
- Acceleration = require('cordova/plugin/Acceleration');
-
-// Is the accel sensor running?
-var running = false;
-
-// Keeps reference to watchAcceleration calls.
-var timers = {};
-
-// Array of listeners; used to keep track of when we should call start and stop.
-var listeners = [];
-
-// Last returned acceleration object from native
-var accel = null;
-
-// Tells native to start.
-function start() {
- exec(function(a) {
- var tempListeners = listeners.slice(0);
- accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].win(accel);
- }
- }, function(e) {
- var tempListeners = listeners.slice(0);
- for (var i = 0, l = tempListeners.length; i < l; i++) {
- tempListeners[i].fail(e);
- }
- }, "Accelerometer", "start", []);
- running = true;
-}
-
-// Tells native to stop.
-function stop() {
- exec(null, null, "Accelerometer", "stop", []);
- running = false;
-}
-
-// Adds a callback pair to the listeners array
-function createCallbackPair(win, fail) {
- return {win:win, fail:fail};
-}
-
-// Removes a win/fail listener pair from the listeners array
-function removeListeners(l) {
- var idx = listeners.indexOf(l);
- if (idx > -1) {
- listeners.splice(idx, 1);
- if (listeners.length === 0) {
- stop();
- }
- }
-}
-
-var accelerometer = {
- /**
- * Asynchronously acquires the current acceleration.
- *
- * @param {Function} successCallback The function to call when the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- */
- getCurrentAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
-
- var p;
- var win = function(a) {
- removeListeners(p);
- successCallback(a);
- };
- var fail = function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- };
-
- p = createCallbackPair(win, fail);
- listeners.push(p);
-
- if (!running) {
- start();
- }
- },
-
- /**
- * Asynchronously acquires the acceleration repeatedly at a given interval.
- *
- * @param {Function} successCallback The function to call each time the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchAcceleration: function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
- // Default interval (10 sec)
- var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
-
- // Keep reference to watch id, and report accel readings as often as defined in frequency
- var id = utils.createUUID();
-
- var p = createCallbackPair(function(){}, function(e) {
- removeListeners(p);
- errorCallback && errorCallback(e);
- });
- listeners.push(p);
-
- timers[id] = {
- timer:window.setInterval(function() {
- if (accel) {
- successCallback(accel);
- }
- }, frequency),
- listeners:p
- };
-
- if (running) {
- // If we're already running then immediately invoke the success callback
- // but only if we have retrieved a value, sample code does not check for null ...
- if (accel) {
- successCallback(accel);
- }
- } else {
- start();
- }
-
- return id;
- },
-
- /**
- * Clears the specified accelerometer watch.
- *
- * @param {String} id The id of the watch returned from #watchAcceleration.
- */
- clearWatch: function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- window.clearInterval(timers[id].timer);
- removeListeners(timers[id].listeners);
- delete timers[id];
- }
- }
-};
-
-module.exports = accelerometer;
-
-});
-
-// file: lib/common/plugin/accelerometer/symbols.js
-define("cordova/plugin/accelerometer/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Acceleration', 'Acceleration');
-modulemapper.defaults('cordova/plugin/accelerometer', 'navigator.accelerometer');
-
-});
-
-// file: lib/common/plugin/battery.js
-define("cordova/plugin/battery", function(require, exports, module) {
-
-/**
- * This class contains information about the current battery status.
- * @constructor
- */
-var cordova = require('cordova'),
- exec = require('cordova/exec');
-
-function handlers() {
- return battery.channels.batterystatus.numHandlers +
- battery.channels.batterylow.numHandlers +
- battery.channels.batterycritical.numHandlers;
-}
-
-var Battery = function() {
- this._level = null;
- this._isPlugged = null;
- // Create new event handlers on the window (returns a channel instance)
- this.channels = {
- batterystatus:cordova.addWindowEventHandler("batterystatus"),
- batterylow:cordova.addWindowEventHandler("batterylow"),
- batterycritical:cordova.addWindowEventHandler("batterycritical")
- };
- for (var key in this.channels) {
- this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
- }
-};
-/**
- * Event handlers for when callbacks get registered for the battery.
- * Keep track of how many handlers we have so we can start and stop the native battery listener
- * appropriately (and hopefully save on battery life!).
- */
-Battery.onHasSubscribersChange = function() {
- // If we just registered the first handler, make sure native listener is started.
- if (this.numHandlers === 1 && handlers() === 1) {
- exec(battery._status, battery._error, "Battery", "start", []);
- } else if (handlers() === 0) {
- exec(null, null, "Battery", "stop", []);
- }
-};
-
-/**
- * Callback for battery status
- *
- * @param {Object} info keys: level, isPlugged
- */
-Battery.prototype._status = function(info) {
- if (info) {
- var me = battery;
- var level = info.level;
- if (me._level !== level || me._isPlugged !== info.isPlugged) {
- // Fire batterystatus event
- cordova.fireWindowEvent("batterystatus", info);
-
- // Fire low battery event
- if (level === 20 || level === 5) {
- if (level === 20) {
- cordova.fireWindowEvent("batterylow", info);
- }
- else {
- cordova.fireWindowEvent("batterycritical", info);
- }
- }
- }
- me._level = level;
- me._isPlugged = info.isPlugged;
- }
-};
-
-/**
- * Error callback for battery start
- */
-Battery.prototype._error = function(e) {
- console.log("Error initializing Battery: " + e);
-};
-
-var battery = new Battery();
-
-module.exports = battery;
-
-});
-
-// file: lib/common/plugin/battery/symbols.js
-define("cordova/plugin/battery/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
-
-});
-
-// file: lib/common/plugin/camera/symbols.js
-define("cordova/plugin/camera/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Camera', 'navigator.camera');
-modulemapper.defaults('cordova/plugin/CameraConstants', 'Camera');
-modulemapper.defaults('cordova/plugin/CameraPopoverOptions', 'CameraPopoverOptions');
-
-});
-
-// file: lib/common/plugin/capture.js
-define("cordova/plugin/capture", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
-
-/**
- * Launches a capture of different types.
- *
- * @param (DOMString} type
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-function _capture(type, successCallback, errorCallback, options) {
- var win = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult[i].name;
- mediaFile.fullPath = pluginResult[i].fullPath;
- mediaFile.type = pluginResult[i].type;
- mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
- mediaFile.size = pluginResult[i].size;
- mediaFiles.push(mediaFile);
- }
- successCallback(mediaFiles);
- };
- exec(win, errorCallback, "Capture", type, [options]);
-}
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-function Capture() {
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- _capture("captureAudio", successCallback, errorCallback, options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function(successCallback, errorCallback, options){
- _capture("captureImage", successCallback, errorCallback, options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- _capture("captureVideo", successCallback, errorCallback, options);
-};
-
-
-module.exports = new Capture();
-
-});
-
-// file: lib/common/plugin/capture/symbols.js
-define("cordova/plugin/capture/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/CaptureError', 'CaptureError');
-modulemapper.clobbers('cordova/plugin/CaptureAudioOptions', 'CaptureAudioOptions');
-modulemapper.clobbers('cordova/plugin/CaptureImageOptions', 'CaptureImageOptions');
-modulemapper.clobbers('cordova/plugin/CaptureVideoOptions', 'CaptureVideoOptions');
-modulemapper.clobbers('cordova/plugin/ConfigurationData', 'ConfigurationData');
-modulemapper.clobbers('cordova/plugin/MediaFile', 'MediaFile');
-modulemapper.clobbers('cordova/plugin/MediaFileData', 'MediaFileData');
-modulemapper.clobbers('cordova/plugin/capture', 'navigator.device.capture');
-
-});
-
-// file: lib/common/plugin/compass.js
-define("cordova/plugin/compass", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- utils = require('cordova/utils'),
- CompassHeading = require('cordova/plugin/CompassHeading'),
- CompassError = require('cordova/plugin/CompassError'),
- timers = {},
- compass = {
- /**
- * Asynchronously acquires the current heading.
- * @param {Function} successCallback The function to call when the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {CompassOptions} options The options for getting the heading data (not used).
- */
- getCurrentHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments);
-
- var win = function(result) {
- var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
- successCallback(ch);
- };
- var fail = errorCallback && function(code) {
- var ce = new CompassError(code);
- errorCallback(ce);
- };
-
- // Get heading
- exec(win, fail, "Compass", "getHeading", [options]);
- },
-
- /**
- * Asynchronously acquires the heading repeatedly at a given interval.
- * @param {Function} successCallback The function to call each time the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {HeadingOptions} options The options for getting the heading data
- * such as timeout and the frequency of the watch. For iOS, filter parameter
- * specifies to watch via a distance filter rather than time.
- */
- watchHeading:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'compass.watchHeading', arguments);
- // Default interval (100 msec)
- var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
- var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
-
- var id = utils.createUUID();
- if (filter > 0) {
- // is an iOS request for watch by filter, no timer needed
- timers[id] = "iOS";
- compass.getCurrentHeading(successCallback, errorCallback, options);
- } else {
- // Start watch timer to get headings
- timers[id] = window.setInterval(function() {
- compass.getCurrentHeading(successCallback, errorCallback);
- }, frequency);
- }
-
- return id;
- },
-
- /**
- * Clears the specified heading watch.
- * @param {String} watchId The ID of the watch returned from #watchHeading.
- */
- clearWatch:function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- if (timers[id] != "iOS") {
- clearInterval(timers[id]);
- } else {
- // is iOS watch by filter so call into device to stop
- exec(null, null, "Compass", "stopHeading", []);
- }
- delete timers[id];
- }
- }
- };
-
-module.exports = compass;
-
-});
-
-// file: lib/common/plugin/compass/symbols.js
-define("cordova/plugin/compass/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/CompassHeading', 'CompassHeading');
-modulemapper.clobbers('cordova/plugin/CompassError', 'CompassError');
-modulemapper.clobbers('cordova/plugin/compass', 'navigator.compass');
-
-});
-
-// file: lib/common/plugin/console-via-logger.js
-define("cordova/plugin/console-via-logger", function(require, exports, module) {
-
-//------------------------------------------------------------------------------
-
-var logger = require("cordova/plugin/logger");
-var utils = require("cordova/utils");
-
-//------------------------------------------------------------------------------
-// object that we're exporting
-//------------------------------------------------------------------------------
-var console = module.exports;
-
-//------------------------------------------------------------------------------
-// copy of the original console object
-//------------------------------------------------------------------------------
-var WinConsole = window.console;
-
-//------------------------------------------------------------------------------
-// whether to use the logger
-//------------------------------------------------------------------------------
-var UseLogger = false;
-
-//------------------------------------------------------------------------------
-// Timers
-//------------------------------------------------------------------------------
-var Timers = {};
-
-//------------------------------------------------------------------------------
-// used for unimplemented methods
-//------------------------------------------------------------------------------
-function noop() {}
-
-//------------------------------------------------------------------------------
-// used for unimplemented methods
-//------------------------------------------------------------------------------
-console.useLogger = function (value) {
- if (arguments.length) UseLogger = !!value;
-
- if (UseLogger) {
- if (logger.useConsole()) {
- throw new Error("console and logger are too intertwingly");
- }
- }
-
- return UseLogger;
-};
-
-//------------------------------------------------------------------------------
-console.log = function() {
- if (logger.useConsole()) return;
- logger.log.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.error = function() {
- if (logger.useConsole()) return;
- logger.error.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.warn = function() {
- if (logger.useConsole()) return;
- logger.warn.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.info = function() {
- if (logger.useConsole()) return;
- logger.info.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.debug = function() {
- if (logger.useConsole()) return;
- logger.debug.apply(logger, [].slice.call(arguments));
-};
-
-//------------------------------------------------------------------------------
-console.assert = function(expression) {
- if (expression) return;
-
- var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
- console.log("ASSERT: " + message);
-};
-
-//------------------------------------------------------------------------------
-console.clear = function() {};
-
-//------------------------------------------------------------------------------
-console.dir = function(object) {
- console.log("%o", object);
-};
-
-//------------------------------------------------------------------------------
-console.dirxml = function(node) {
- console.log(node.innerHTML);
-};
-
-//------------------------------------------------------------------------------
-console.trace = noop;
-
-//------------------------------------------------------------------------------
-console.group = console.log;
-
-//------------------------------------------------------------------------------
-console.groupCollapsed = console.log;
-
-//------------------------------------------------------------------------------
-console.groupEnd = noop;
-
-//------------------------------------------------------------------------------
-console.time = function(name) {
- Timers[name] = new Date().valueOf();
-};
-
-//------------------------------------------------------------------------------
-console.timeEnd = function(name) {
- var timeStart = Timers[name];
- if (!timeStart) {
- console.warn("unknown timer: " + name);
- return;
- }
-
- var timeElapsed = new Date().valueOf() - timeStart;
- console.log(name + ": " + timeElapsed + "ms");
-};
-
-//------------------------------------------------------------------------------
-console.timeStamp = noop;
-
-//------------------------------------------------------------------------------
-console.profile = noop;
-
-//------------------------------------------------------------------------------
-console.profileEnd = noop;
-
-//------------------------------------------------------------------------------
-console.count = noop;
-
-//------------------------------------------------------------------------------
-console.exception = console.log;
-
-//------------------------------------------------------------------------------
-console.table = function(data, columns) {
- console.log("%o", data);
-};
-
-//------------------------------------------------------------------------------
-// return a new function that calls both functions passed as args
-//------------------------------------------------------------------------------
-function wrappedOrigCall(orgFunc, newFunc) {
- return function() {
- var args = [].slice.call(arguments);
- try { orgFunc.apply(WinConsole, args); } catch (e) {}
- try { newFunc.apply(console, args); } catch (e) {}
- };
-}
-
-//------------------------------------------------------------------------------
-// For every function that exists in the original console object, that
-// also exists in the new console object, wrap the new console method
-// with one that calls both
-//------------------------------------------------------------------------------
-for (var key in console) {
- if (typeof WinConsole[key] == "function") {
- console[key] = wrappedOrigCall(WinConsole[key], console[key]);
- }
-}
-
-});
-
-// file: lib/common/plugin/contacts.js
-define("cordova/plugin/contacts", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils'),
- Contact = require('cordova/plugin/Contact');
-
-/**
-* Represents a group of Contacts.
-* @constructor
-*/
-var contacts = {
- /**
- * Returns an array of Contacts matching the search criteria.
- * @param fields that should be searched
- * @param successCB success callback
- * @param errorCB error callback
- * @param {ContactFindOptions} options that can be applied to contact searching
- * @return array of Contacts matching search criteria
- */
- find:function(fields, successCB, errorCB, options) {
- argscheck.checkArgs('afFO', 'contacts.find', arguments);
- if (!fields.length) {
- errorCB && errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
- } else {
- var win = function(result) {
- var cs = [];
- for (var i = 0, l = result.length; i < l; i++) {
- cs.push(contacts.create(result[i]));
- }
- successCB(cs);
- };
- exec(win, errorCB, "Contacts", "search", [fields, options]);
- }
- },
-
- /**
- * This function creates a new contact, but it does not persist the contact
- * to device storage. To persist the contact to device storage, invoke
- * contact.save().
- * @param properties an object whose properties will be examined to create a new Contact
- * @returns new Contact object
- */
- create:function(properties) {
- argscheck.checkArgs('O', 'contacts.create', arguments);
- var contact = new Contact();
- for (var i in properties) {
- if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
- contact[i] = properties[i];
- }
- }
- return contact;
- }
-};
-
-module.exports = contacts;
-
-});
-
-// file: lib/common/plugin/contacts/symbols.js
-define("cordova/plugin/contacts/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/contacts', 'navigator.contacts');
-modulemapper.clobbers('cordova/plugin/Contact', 'Contact');
-modulemapper.clobbers('cordova/plugin/ContactAddress', 'ContactAddress');
-modulemapper.clobbers('cordova/plugin/ContactError', 'ContactError');
-modulemapper.clobbers('cordova/plugin/ContactField', 'ContactField');
-modulemapper.clobbers('cordova/plugin/ContactFindOptions', 'ContactFindOptions');
-modulemapper.clobbers('cordova/plugin/ContactName', 'ContactName');
-modulemapper.clobbers('cordova/plugin/ContactOrganization', 'ContactOrganization');
-
-});
-
-// file: lib/common/plugin/device.js
-define("cordova/plugin/device", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
-
-/**
- * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
- * phone, etc.
- * @constructor
- */
-function Device() {
- this.available = false;
- this.platform = null;
- this.version = null;
- this.uuid = null;
- this.cordova = null;
- this.model = null;
-
- var me = this;
-
- channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- var buildLabel = info.cordova;
- if (buildLabel != CORDOVA_JS_BUILD_LABEL) {
- buildLabel += ' JS=' + CORDOVA_JS_BUILD_LABEL;
- }
- me.available = true;
- me.platform = info.platform;
- me.version = info.version;
- me.uuid = info.uuid;
- me.cordova = buildLabel;
- me.model = info.model;
- channel.onCordovaInfoReady.fire();
- },function(e) {
- me.available = false;
- utils.alert("[ERROR] Error initializing Cordova: " + e);
- });
- });
-}
-
-/**
- * Get device info
- *
- * @param {Function} successCallback The function to call when the heading data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
- */
-Device.prototype.getInfo = function(successCallback, errorCallback) {
- argscheck.checkArgs('fF', 'Device.getInfo', arguments);
- exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
-};
-
-module.exports = new Device();
-
-});
-
-// file: lib/common/plugin/device/symbols.js
-define("cordova/plugin/device/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/device', 'device');
-
-});
-
-// file: lib/common/plugin/echo.js
-define("cordova/plugin/echo", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- utils = require('cordova/utils');
-
-/**
- * Sends the given message through exec() to the Echo plugin, which sends it back to the successCallback.
- * @param successCallback invoked with a FileSystem object
- * @param errorCallback invoked if error occurs retrieving file system
- * @param message The string to be echoed.
- * @param forceAsync Whether to force an async return value (for testing native->js bridge).
- */
-module.exports = function(successCallback, errorCallback, message, forceAsync) {
- var action = 'echo';
- var messageIsMultipart = (utils.typeName(message) == "Array");
- var args = messageIsMultipart ? message : [message];
-
- if (utils.typeName(message) == 'ArrayBuffer') {
- if (forceAsync) {
- console.warn('Cannot echo ArrayBuffer with forced async, falling back to sync.');
- }
- action += 'ArrayBuffer';
- } else if (messageIsMultipart) {
- if (forceAsync) {
- console.warn('Cannot echo MultiPart Array with forced async, falling back to sync.');
- }
- action += 'MultiPart';
- } else if (forceAsync) {
- action += 'Async';
- }
-
- exec(successCallback, errorCallback, "Echo", action, args);
-};
-
-
-});
-
-// file: lib/ios/plugin/file/symbols.js
-define("cordova/plugin/file/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper'),
- symbolshelper = require('cordova/plugin/file/symbolshelper');
-
-symbolshelper(modulemapper.clobbers);
-modulemapper.merges('cordova/plugin/ios/Entry', 'Entry');
-
-});
-
-// file: lib/common/plugin/file/symbolshelper.js
-define("cordova/plugin/file/symbolshelper", function(require, exports, module) {
-
-module.exports = function(exportFunc) {
- exportFunc('cordova/plugin/DirectoryEntry', 'DirectoryEntry');
- exportFunc('cordova/plugin/DirectoryReader', 'DirectoryReader');
- exportFunc('cordova/plugin/Entry', 'Entry');
- exportFunc('cordova/plugin/File', 'File');
- exportFunc('cordova/plugin/FileEntry', 'FileEntry');
- exportFunc('cordova/plugin/FileError', 'FileError');
- exportFunc('cordova/plugin/FileReader', 'FileReader');
- exportFunc('cordova/plugin/FileSystem', 'FileSystem');
- exportFunc('cordova/plugin/FileUploadOptions', 'FileUploadOptions');
- exportFunc('cordova/plugin/FileUploadResult', 'FileUploadResult');
- exportFunc('cordova/plugin/FileWriter', 'FileWriter');
- exportFunc('cordova/plugin/Flags', 'Flags');
- exportFunc('cordova/plugin/LocalFileSystem', 'LocalFileSystem');
- exportFunc('cordova/plugin/Metadata', 'Metadata');
- exportFunc('cordova/plugin/ProgressEvent', 'ProgressEvent');
- exportFunc('cordova/plugin/requestFileSystem', 'requestFileSystem');
- exportFunc('cordova/plugin/resolveLocalFileSystemURI', 'resolveLocalFileSystemURI');
-};
-
-});
-
-// file: lib/common/plugin/filetransfer/symbols.js
-define("cordova/plugin/filetransfer/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/FileTransfer', 'FileTransfer');
-modulemapper.clobbers('cordova/plugin/FileTransferError', 'FileTransferError');
-
-});
-
-// file: lib/common/plugin/geolocation.js
-define("cordova/plugin/geolocation", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- PositionError = require('cordova/plugin/PositionError'),
- Position = require('cordova/plugin/Position');
-
-var timers = {}; // list of timers in use
-
-// Returns default params, overrides if provided with values
-function parseParameters(options) {
- var opt = {
- maximumAge: 0,
- enableHighAccuracy: false,
- timeout: Infinity
- };
-
- if (options) {
- if (options.maximumAge !== undefined && !isNaN(options.maximumAge) && options.maximumAge > 0) {
- opt.maximumAge = options.maximumAge;
- }
- if (options.enableHighAccuracy !== undefined) {
- opt.enableHighAccuracy = options.enableHighAccuracy;
- }
- if (options.timeout !== undefined && !isNaN(options.timeout)) {
- if (options.timeout < 0) {
- opt.timeout = 0;
- } else {
- opt.timeout = options.timeout;
- }
- }
- }
-
- return opt;
-}
-
-// Returns a timeout failure, closed over a specified timeout value and error callback.
-function createTimeout(errorCallback, timeout) {
- var t = setTimeout(function() {
- clearTimeout(t);
- t = null;
- errorCallback({
- code:PositionError.TIMEOUT,
- message:"Position retrieval timed out."
- });
- }, timeout);
- return t;
-}
-
-var geolocation = {
- lastPosition:null, // reference to last known (cached) position returned
- /**
- * Asynchronously acquires the current position.
- *
- * @param {Function} successCallback The function to call when the position data is available
- * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
- */
- getCurrentPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- // Timer var that will fire an error callback if no position is retrieved from native
- // before the "timeout" param provided expires
- var timeoutTimer = {timer:null};
-
- var win = function(p) {
- clearTimeout(timeoutTimer.timer);
- if (!(timeoutTimer.timer)) {
- // Timeout already happened, or native fired error callback for
- // this geo request.
- // Don't continue with success callback.
- return;
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
- var fail = function(e) {
- clearTimeout(timeoutTimer.timer);
- timeoutTimer.timer = null;
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just
- // fire the success callback with the cached position.
- if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) {
- successCallback(geolocation.lastPosition);
- // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object.
- } else if (options.timeout === 0) {
- fail({
- code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
- });
- // Otherwise we have to call into native to retrieve a position.
- } else {
- if (options.timeout !== Infinity) {
- // If the timeout value was not set to Infinity (default), then
- // set up a timeout function that will fire the error callback
- // if no successful position was retrieved before timeout expired.
- timeoutTimer.timer = createTimeout(fail, options.timeout);
- } else {
- // This is here so the check in the win function doesn't mess stuff up
- // may seem weird but this guarantees timeoutTimer is
- // always truthy before we call into native
- timeoutTimer.timer = true;
- }
- exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
- }
- return timeoutTimer;
- },
- /**
- * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
- * the successCallback is called with the new location.
- *
- * @param {Function} successCallback The function to call each time the location data is available
- * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
- * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchPosition:function(successCallback, errorCallback, options) {
- argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
- options = parseParameters(options);
-
- var id = utils.createUUID();
-
- // Tell device to get a position ASAP, and also retrieve a reference to the timeout timer generated in getCurrentPosition
- timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
-
- var fail = function(e) {
- clearTimeout(timers[id].timer);
- var err = new PositionError(e.code, e.message);
- if (errorCallback) {
- errorCallback(err);
- }
- };
-
- var win = function(p) {
- clearTimeout(timers[id].timer);
- if (options.timeout !== Infinity) {
- timers[id].timer = createTimeout(fail, options.timeout);
- }
- var pos = new Position(
- {
- latitude:p.latitude,
- longitude:p.longitude,
- altitude:p.altitude,
- accuracy:p.accuracy,
- heading:p.heading,
- velocity:p.velocity,
- altitudeAccuracy:p.altitudeAccuracy
- },
- (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp)))
- );
- geolocation.lastPosition = pos;
- successCallback(pos);
- };
-
- exec(win, fail, "Geolocation", "addWatch", [id, options.enableHighAccuracy]);
-
- return id;
- },
- /**
- * Clears the specified heading watch.
- *
- * @param {String} id The ID of the watch returned from #watchPosition
- */
- clearWatch:function(id) {
- if (id && timers[id] !== undefined) {
- clearTimeout(timers[id].timer);
- timers[id].timer = false;
- exec(null, null, "Geolocation", "clearWatch", [id]);
- }
- }
-};
-
-module.exports = geolocation;
-
-});
-
-// file: lib/common/plugin/geolocation/symbols.js
-define("cordova/plugin/geolocation/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/geolocation', 'navigator.geolocation');
-modulemapper.clobbers('cordova/plugin/PositionError', 'PositionError');
-modulemapper.clobbers('cordova/plugin/Position', 'Position');
-modulemapper.clobbers('cordova/plugin/Coordinates', 'Coordinates');
-
-});
-
-// file: lib/common/plugin/globalization.js
-define("cordova/plugin/globalization", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- exec = require('cordova/exec'),
- GlobalizationError = require('cordova/plugin/GlobalizationError');
-
-var globalization = {
-
-/**
-* Returns the string identifier for the client's current language.
-* It returns the language identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the language,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The language identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
-* function () {});
-*/
-getPreferredLanguage:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
- exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);
-},
-
-/**
-* Returns the string identifier for the client's current locale setting.
-* It returns the locale identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the locale,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The locale identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
-* function () {});
-*/
-getLocaleName:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
- exec(successCB, failureCB, "Globalization","getLocaleName", []);
-},
-
-
-/**
-* Returns a date formatted as a string according to the client's user preferences and
-* calendar using the time zone of the client. It returns the formatted date string to the
-* successCB callback with a properties object as a parameter. If there is an error
-* formatting the date, then the errorCB callback is invoked.
-*
-* The defaults are: formatLenght="short" and selector="date and time"
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.value {String}: The localized date string
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.dateToString(new Date(),
-* function (date) {alert('date:' + date.value + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {formatLength:'short'});
-*/
-dateToString:function(date, successCB, failureCB, options) {
- argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);
-},
-
-
-/**
-* Parses a date formatted as a string according to the client's user
-* preferences and calendar using the time zone of the client and returns
-* the corresponding date object. It returns the date to the successCB
-* callback with a properties object as a parameter. If there is an error
-* parsing the date string, then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {String} dateString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.year {Number}: The four digit year
-* Object.month {Number}: The month from (0 - 11)
-* Object.day {Number}: The day from (1 - 31)
-* Object.hour {Number}: The hour from (0 - 23)
-* Object.minute {Number}: The minute from (0 - 59)
-* Object.second {Number}: The second from (0 - 59)
-* Object.millisecond {Number}: The milliseconds (from 0 - 999),
-* not available on all platforms
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToDate('4/11/2011',
-* function (date) { alert('Month:' + date.month + '\n' +
-* 'Day:' + date.day + '\n' +
-* 'Year:' + date.year + '\n');},
-* function (errorCode) {alert(errorCode);},
-* {selector:'date'});
-*/
-stringToDate:function(dateString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
- exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);
-},
-
-
-/**
-* Returns a pattern string for formatting and parsing dates according to the client's
-* user preferences. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern,
-* then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* formatLength {String}: 'short', 'medium', 'long', or 'full'
-* selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.timezone {String}: The abbreviated name of the time zone on the client
-* Object.utc_offset {Number}: The current difference in seconds between the client's
-* time zone and coordinated universal time.
-* Object.dst_offset {Number}: The current daylight saving time offset in seconds
-* between the client's non-daylight saving's time zone
-* and the client's daylight saving's time zone.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getDatePattern(
-* function (date) {alert('pattern:' + date.pattern + '\n');},
-* function () {},
-* {formatLength:'short'});
-*/
-getDatePattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
- exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);
-},
-
-
-/**
-* Returns an array of either the names of the months or days of the week
-* according to the client's user preferences and calendar. It returns the array of names to the
-* successCB callback with a properties object as a parameter. If there is an error obtaining the
-* names, then the errorCB callback is invoked.
-*
-* The defaults are: type="wide" and item="months"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'narrow' or 'wide'
-* item {String}: 'months', or 'days'
-*
-* @return Object.value {Array{String}}: The array of names starting from either
-* the first month in the year or the
-* first day of the week.
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getDateNames(function (names) {
-* for(var i = 0; i < names.value.length; i++) {
-* alert('Month:' + names.value[i] + '\n');}},
-* function () {});
-*/
-getDateNames:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
- exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);
-},
-
-/**
-* Returns whether daylight savings time is in effect for a given date using the client's
-* time zone and calendar. It returns whether or not daylight savings time is in effect
-* to the successCB callback with a properties object as a parameter. If there is an error
-* reading the date, then the errorCB callback is invoked.
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
-* in effect for the given date and "false" indicate that it is not.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.isDayLightSavingsTime(new Date(),
-* function (date) {alert('dst:' + date.dst + '\n');}
-* function () {});
-*/
-isDayLightSavingsTime:function(date, successCB, failureCB) {
- argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', arguments);
- var dateValue = date.valueOf();
- exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);
-},
-
-/**
-* Returns the first day of the week according to the client's user preferences and calendar.
-* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
-* It returns the day to the successCB callback with a properties object as a parameter.
-* If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {Number}: The number of the first day of the week.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-* globalization.getFirstDayOfWeek(function (day)
-* { alert('Day:' + day.value + '\n');},
-* function () {});
-*/
-getFirstDayOfWeek:function(successCB, failureCB) {
- argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
- exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);
-},
-
-
-/**
-* Returns a number formatted as a string according to the client's user preferences.
-* It returns the formatted number string to the successCB callback with a properties object as a
-* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Number} number
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {String}: The formatted number string.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.numberToString(3.25,
-* function (number) {alert('number:' + number.value + '\n');},
-* function () {},
-* {type:'decimal'});
-*/
-numberToString:function(number, successCB, failureCB, options) {
- argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
- exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);
-},
-
-/**
-* Parses a number formatted as a string according to the client's user preferences and
-* returns the corresponding number. It returns the number to the successCB callback with a
-* properties object as a parameter. If there is an error parsing the number string, then
-* the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {String} numberString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {Number}: The parsed number.
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-* globalization.stringToNumber('1234.56',
-* function (number) {alert('Number:' + number.value + '\n');},
-* function () { alert('Error parsing number');});
-*/
-stringToNumber:function(numberString, successCB, failureCB, options) {
- argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
- exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing numbers according to the client's user
-* preferences. It returns the pattern to the successCB callback with a properties object as a
-* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-* type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
-* The patterns follow Unicode Technical Standard #35.
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.symbol {String}: The symbol to be used when formatting and parsing
-* e.g., percent or currency symbol.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting numbers.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
-* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-* globalization.getNumberPattern(
-* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
-* function () {});
-*/
-getNumberPattern:function(successCB, failureCB, options) {
- argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing currency values according to the client's
-* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
-* callback is invoked.
-*
-* @param {String} currencyCode
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
-* The patterns follow Unicode Technical Standard #35
-* http://unicode.org/reports/tr35/tr35-4.html
-* Object.code {String}: The ISO 4217 currency code for the pattern.
-* Object.fraction {Number}: The number of fractional digits to use when parsing and
-* formatting currency.
-* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
-* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
-* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-* globalization.getCurrencyPattern('EUR',
-* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
-* function () {});
-*/
-getCurrencyPattern:function(currencyCode, successCB, failureCB) {
- argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
- exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);
-}
-
-};
-
-module.exports = globalization;
-
-});
-
-// file: lib/common/plugin/globalization/symbols.js
-define("cordova/plugin/globalization/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/globalization', 'navigator.globalization');
-modulemapper.clobbers('cordova/plugin/GlobalizationError', 'GlobalizationError');
-
-});
-
-// file: lib/ios/plugin/inappbrowser/symbols.js
-define("cordova/plugin/inappbrowser/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/InAppBrowser', 'open');
-
-});
-
-// file: lib/ios/plugin/ios/Contact.js
-define("cordova/plugin/ios/Contact", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError');
-
-/**
- * Provides iOS Contact.display API.
- */
-module.exports = {
- display : function(errorCB, options) {
- /*
- * Display a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- */
-
- if (this.id === null) {
- if (typeof errorCB === "function") {
- var errorObj = new ContactError(ContactError.UNKNOWN_ERROR);
- errorCB(errorObj);
- }
- }
- else {
- exec(null, errorCB, "Contacts","displayContact", [this.id, options]);
- }
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/Entry.js
-define("cordova/plugin/ios/Entry", function(require, exports, module) {
-
-module.exports = {
- toURL:function() {
- // TODO: refactor path in a cross-platform way so we can eliminate
- // these kinds of platform-specific hacks.
- return "file://localhost" + this.fullPath;
- },
- toURI: function() {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- return "file://localhost" + this.fullPath;
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/contacts.js
-define("cordova/plugin/ios/contacts", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-/**
- * Provides iOS enhanced contacts API.
- */
-module.exports = {
- newContactUI : function(successCallback) {
- /*
- * Create a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * returns: the id of the created contact as param to successCallback
- */
- exec(successCallback, null, "Contacts","newContact", []);
- },
- chooseContact : function(successCallback, options) {
- /*
- * Select a contact using the iOS Contact Picker UI
- * NOT part of W3C spec so no official documentation
- *
- * @param errorCB error callback
- * @param options object
- * allowsEditing: boolean AS STRING
- * "true" to allow editing the contact
- * "false" (default) display contact
- * fields: array of fields to return in contact object (see ContactOptions.fields)
- *
- * @returns
- * id of contact selected
- * ContactObject
- * if no fields provided contact contains just id information
- * if fields provided contact object contains information for the specified fields
- *
- */
- var win = function(result) {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCallback(fullContact.id, fullContact);
- };
- exec(win, null, "Contacts","chooseContact", [options]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/ios/contacts/symbols.js
-define("cordova/plugin/ios/contacts/symbols", function(require, exports, module) {
-
-require('cordova/plugin/contacts/symbols');
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/ios/contacts', 'navigator.contacts');
-modulemapper.merges('cordova/plugin/ios/Contact', 'Contact');
-
-});
-
-// file: lib/ios/plugin/ios/geolocation/symbols.js
-define("cordova/plugin/ios/geolocation/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.merges('cordova/plugin/geolocation', 'navigator.geolocation');
-
-});
-
-// file: lib/ios/plugin/ios/logger/plugininit.js
-define("cordova/plugin/ios/logger/plugininit", function(require, exports, module) {
-
-// use the native logger
-var logger = require("cordova/plugin/logger");
-logger.useConsole(true);
-
-});
-
-// file: lib/ios/plugin/ios/logger/symbols.js
-define("cordova/plugin/ios/logger/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/logger', 'console');
-
-});
-
-// file: lib/ios/plugin/ios/notification.js
-define("cordova/plugin/ios/notification", function(require, exports, module) {
-
-var Media = require('cordova/plugin/Media');
-
-module.exports = {
- beep:function(count) {
- (new Media('beep.wav')).play();
- }
-};
-
-});
-
-// file: lib/common/plugin/logger.js
-define("cordova/plugin/logger", function(require, exports, module) {
-
-//------------------------------------------------------------------------------
-// The logger module exports the following properties/functions:
-//
-// LOG - constant for the level LOG
-// ERROR - constant for the level ERROR
-// WARN - constant for the level WARN
-// INFO - constant for the level INFO
-// DEBUG - constant for the level DEBUG
-// logLevel() - returns current log level
-// logLevel(value) - sets and returns a new log level
-// useConsole() - returns whether logger is using console
-// useConsole(value) - sets and returns whether logger is using console
-// log(message,...) - logs a message at level LOG
-// error(message,...) - logs a message at level ERROR
-// warn(message,...) - logs a message at level WARN
-// info(message,...) - logs a message at level INFO
-// debug(message,...) - logs a message at level DEBUG
-// logLevel(level,message,...) - logs a message specified level
-//
-//------------------------------------------------------------------------------
-
-var logger = exports;
-
-var exec = require('cordova/exec');
-var utils = require('cordova/utils');
-
-var UseConsole = true;
-var UseLogger = true;
-var Queued = [];
-var DeviceReady = false;
-var CurrentLevel;
-
-var originalConsole = console;
-
-/**
- * Logging levels
- */
-
-var Levels = [
- "LOG",
- "ERROR",
- "WARN",
- "INFO",
- "DEBUG"
-];
-
-/*
- * add the logging levels to the logger object and
- * to a separate levelsMap object for testing
- */
-
-var LevelsMap = {};
-for (var i=0; i<Levels.length; i++) {
- var level = Levels[i];
- LevelsMap[level] = i;
- logger[level] = level;
-}
-
-CurrentLevel = LevelsMap.WARN;
-
-/**
- * Getter/Setter for the logging level
- *
- * Returns the current logging level.
- *
- * When a value is passed, sets the logging level to that value.
- * The values should be one of the following constants:
- * logger.LOG
- * logger.ERROR
- * logger.WARN
- * logger.INFO
- * logger.DEBUG
- *
- * The value used determines which messages get printed. The logging
- * values above are in order, and only messages logged at the logging
- * level or above will actually be displayed to the user. E.g., the
- * default level is WARN, so only messages logged with LOG, ERROR, or
- * WARN will be displayed; INFO and DEBUG messages will be ignored.
- */
-logger.level = function (value) {
- if (arguments.length) {
- if (LevelsMap[value] === null) {
- throw new Error("invalid logging level: " + value);
- }
- CurrentLevel = LevelsMap[value];
- }
-
- return Levels[CurrentLevel];
-};
-
-/**
- * Getter/Setter for the useConsole functionality
- *
- * When useConsole is true, the logger will log via the
- * browser 'console' object.
- */
-logger.useConsole = function (value) {
- if (arguments.length) UseConsole = !!value;
-
- if (UseConsole) {
- if (typeof console == "undefined") {
- throw new Error("global console object is not defined");
- }
-
- if (typeof console.log != "function") {
- throw new Error("global console object does not have a log function");
- }
-
- if (typeof console.useLogger == "function") {
- if (console.useLogger()) {
- throw new Error("console and logger are too intertwingly");
- }
- }
- }
-
- return UseConsole;
-};
-
-/**
- * Getter/Setter for the useLogger functionality
- *
- * When useLogger is true, the logger will log via the
- * native Logger plugin.
- */
-logger.useLogger = function (value) {
- // Enforce boolean
- if (arguments.length) UseLogger = !!value;
- return UseLogger;
-};
-
-/**
- * Logs a message at the LOG level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.log = function(message) { logWithArgs("LOG", arguments); };
-
-/**
- * Logs a message at the ERROR level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.error = function(message) { logWithArgs("ERROR", arguments); };
-
-/**
- * Logs a message at the WARN level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.warn = function(message) { logWithArgs("WARN", arguments); };
-
-/**
- * Logs a message at the INFO level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.info = function(message) { logWithArgs("INFO", arguments); };
-
-/**
- * Logs a message at the DEBUG level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
-
-// log at the specified level with args
-function logWithArgs(level, args) {
- args = [level].concat([].slice.call(args));
- logger.logLevel.apply(logger, args);
-}
-
-/**
- * Logs a message at the specified level.
- *
- * Parameters passed after message are used applied to
- * the message with utils.format()
- */
-logger.logLevel = function(level /* , ... */) {
- // format the message with the parameters
- var formatArgs = [].slice.call(arguments, 1);
- var message = logger.format.apply(logger.format, formatArgs);
-
- if (LevelsMap[level] === null) {
- throw new Error("invalid logging level: " + level);
- }
-
- if (LevelsMap[level] > CurrentLevel) return;
-
- // queue the message if not yet at deviceready
- if (!DeviceReady && !UseConsole) {
- Queued.push([level, message]);
- return;
- }
-
- // Log using the native logger if that is enabled
- if (UseLogger) {
- exec(null, null, "Logger", "logLevel", [level, message]);
- }
-
- // Log using the console if that is enabled
- if (UseConsole) {
- // make sure console is not using logger
- if (console.__usingCordovaLogger) {
- throw new Error("console and logger are too intertwingly");
- }
-
- // log to the console
- switch (level) {
- case logger.LOG: originalConsole.log(message); break;
- case logger.ERROR: originalConsole.log("ERROR: " + message); break;
- case logger.WARN: originalConsole.log("WARN: " + message); break;
- case logger.INFO: originalConsole.log("INFO: " + message); break;
- case logger.DEBUG: originalConsole.log("DEBUG: " + message); break;
- }
- }
-};
-
-
-/**
- * Formats a string and arguments following it ala console.log()
- *
- * Any remaining arguments will be appended to the formatted string.
- *
- * for rationale, see FireBug's Console API:
- * http://getfirebug.com/wiki/index.php/Console_API
- */
-logger.format = function(formatString, args) {
- return __format(arguments[0], [].slice.call(arguments,1)).join(' ');
-};
-
-
-//------------------------------------------------------------------------------
-/**
- * Formats a string and arguments following it ala vsprintf()
- *
- * format chars:
- * %j - format arg as JSON
- * %o - format arg as JSON
- * %c - format arg as ''
- * %% - replace with '%'
- * any other char following % will format it's
- * arg via toString().
- *
- * Returns an array containing the formatted string and any remaining
- * arguments.
- */
-function __format(formatString, args) {
- if (formatString === null || formatString === undefined) return [""];
- if (arguments.length == 1) return [formatString.toString()];
-
- if (typeof formatString != "string")
- formatString = formatString.toString();
-
- var pattern = /(.*?)%(.)(.*)/;
- var rest = formatString;
- var result = [];
-
- while (args.length) {
- var match = pattern.exec(rest);
- if (!match) break;
-
- var arg = args.shift();
- rest = match[3];
- result.push(match[1]);
-
- if (match[2] == '%') {
- result.push('%');
- args.unshift(arg);
- continue;
- }
-
- result.push(__formatted(arg, match[2]));
- }
-
- result.push(rest);
-
- var remainingArgs = [].slice.call(args);
- remainingArgs.unshift(result.join(''));
- return remainingArgs;
-}
-
-function __formatted(object, formatChar) {
-
- try {
- switch(formatChar) {
- case 'j':
- case 'o': return JSON.stringify(object);
- case 'c': return '';
- }
- }
- catch (e) {
- return "error JSON.stringify()ing argument: " + e;
- }
-
- if ((object === null) || (object === undefined)) {
- return Object.prototype.toString.call(object);
- }
-
- return object.toString();
-}
-
-
-//------------------------------------------------------------------------------
-// when deviceready fires, log queued messages
-logger.__onDeviceReady = function() {
- if (DeviceReady) return;
-
- DeviceReady = true;
-
- for (var i=0; i<Queued.length; i++) {
- var messageArgs = Queued[i];
- logger.logLevel(messageArgs[0], messageArgs[1]);
- }
-
- Queued = null;
-};
-
-// add a deviceready event to log queued messages
-document.addEventListener("deviceready", logger.__onDeviceReady, false);
-
-});
-
-// file: lib/common/plugin/logger/symbols.js
-define("cordova/plugin/logger/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/logger', 'cordova.logger');
-
-});
-
-// file: lib/ios/plugin/media/symbols.js
-define("cordova/plugin/media/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.defaults('cordova/plugin/Media', 'Media');
-modulemapper.clobbers('cordova/plugin/MediaError', 'MediaError');
-
-});
-
-// file: lib/common/plugin/network.js
-define("cordova/plugin/network", function(require, exports, module) {
-
-var exec = require('cordova/exec'),
- cordova = require('cordova'),
- channel = require('cordova/channel'),
- utils = require('cordova/utils');
-
-// Link the onLine property with the Cordova-supplied network info.
-// This works because we clobber the naviagtor object with our own
-// object in bootstrap.js.
-if (typeof navigator != 'undefined') {
- utils.defineGetter(navigator, 'onLine', function() {
- return this.connection.type != 'none';
- });
-}
-
-function NetworkConnection() {
- this.type = 'unknown';
-}
-
-/**
- * Get connection info
- *
- * @param {Function} successCallback The function to call when the Connection data is available
- * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
- */
-NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
- exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
-};
-
-var me = new NetworkConnection();
-var timerId = null;
-var timeout = 500;
-
-channel.onCordovaReady.subscribe(function() {
- me.getInfo(function(info) {
- me.type = info;
- if (info === "none") {
- // set a timer if still offline at the end of timer send the offline event
- timerId = setTimeout(function(){
- cordova.fireDocumentEvent("offline");
- timerId = null;
- }, timeout);
- } else {
- // If there is a current offline event pending clear it
- if (timerId !== null) {
- clearTimeout(timerId);
- timerId = null;
- }
- cordova.fireDocumentEvent("online");
- }
-
- // should only fire this once
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- },
- function (e) {
- // If we can't get the network info we should still tell Cordova
- // to fire the deviceready event.
- if (channel.onCordovaConnectionReady.state !== 2) {
- channel.onCordovaConnectionReady.fire();
- }
- console.log("Error initializing Network Connection: " + e);
- });
-});
-
-module.exports = me;
-
-});
-
-// file: lib/common/plugin/networkstatus/symbols.js
-define("cordova/plugin/networkstatus/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/network', 'navigator.network.connection', 'navigator.network.connection is deprecated. Use navigator.connection instead.');
-modulemapper.clobbers('cordova/plugin/network', 'navigator.connection');
-modulemapper.defaults('cordova/plugin/Connection', 'Connection');
-
-});
-
-// file: lib/common/plugin/notification.js
-define("cordova/plugin/notification", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-var platform = require('cordova/platform');
-
-/**
- * Provides access to notifications on the device.
- */
-
-module.exports = {
-
- /**
- * Open a native alert dialog, with a customizable title and button text.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} completeCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Alert)
- * @param {String} buttonLabel Label of the close button (default: OK)
- */
- alert: function(message, completeCallback, title, buttonLabel) {
- var _title = (title || "Alert");
- var _buttonLabel = (buttonLabel || "OK");
- exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
- },
-
- /**
- * Open a native confirm dialog, with a customizable title and button text.
- * The result that the user selects is returned to the result callback.
- *
- * @param {String} message Message to print in the body of the alert
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the alert dialog (default: Confirm)
- * @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel'])
- */
- confirm: function(message, resultCallback, title, buttonLabels) {
- var _title = (title || "Confirm");
- var _buttonLabels = (buttonLabels || ["OK", "Cancel"]);
-
- // Strings are deprecated!
- if (typeof _buttonLabels === 'string') {
- console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).");
- }
-
- // Some platforms take an array of button label names.
- // Other platforms take a comma separated list.
- // For compatibility, we convert to the desired type based on the platform.
- if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone" || platform.id == "blackberry10") {
- if (typeof _buttonLabels === 'string') {
- var buttonLabelString = _buttonLabels;
- _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
- }
- } else {
- if (Array.isArray(_buttonLabels)) {
- var buttonLabelArray = _buttonLabels;
- _buttonLabels = buttonLabelArray.toString();
- }
- }
- exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
- },
-
- /**
- * Open a native prompt dialog, with a customizable title and button text.
- * The following results are returned to the result callback:
- * buttonIndex Index number of the button selected.
- * input1 The text entered in the prompt dialog box.
- *
- * @param {String} message Dialog message to display (default: "Prompt message")
- * @param {Function} resultCallback The callback that is called when user clicks on a button.
- * @param {String} title Title of the dialog (default: "Prompt")
- * @param {Array} buttonLabels Array of strings for the button labels (default: ["OK","Cancel"])
- * @param {String} defaultText Textbox input value (default: "Default text")
- */
- prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
- var _message = (message || "Prompt message");
- var _title = (title || "Prompt");
- var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
- var _defaultText = (defaultText || "Default text");
- exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);
- },
-
- /**
- * Causes the device to vibrate.
- *
- * @param {Integer} mills The number of milliseconds to vibrate for.
- */
- vibrate: function(mills) {
- exec(null, null, "Notification", "vibrate", [mills]);
- },
-
- /**
- * Causes the device to beep.
- * On Android, the default notification ringtone is played "count" times.
- *
- * @param {Integer} count The number of beeps.
- */
- beep: function(count) {
- exec(null, null, "Notification", "beep", [count]);
- }
-};
-
-});
-
-// file: lib/ios/plugin/notification/symbols.js
-define("cordova/plugin/notification/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/notification', 'navigator.notification');
-modulemapper.merges('cordova/plugin/ios/notification', 'navigator.notification');
-
-});
-
-// file: lib/common/plugin/requestFileSystem.js
-define("cordova/plugin/requestFileSystem", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- FileError = require('cordova/plugin/FileError'),
- FileSystem = require('cordova/plugin/FileSystem'),
- exec = require('cordova/exec');
-
-/**
- * Request a file system in which to store application data.
- * @param type local file system type
- * @param size indicates how much storage space, in bytes, the application expects to need
- * @param successCallback invoked with a FileSystem object
- * @param errorCallback invoked if error occurs retrieving file system
- */
-var requestFileSystem = function(type, size, successCallback, errorCallback) {
- argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
- var fail = function(code) {
- errorCallback && errorCallback(new FileError(code));
- };
-
- if (type < 0 || type > 3) {
- fail(FileError.SYNTAX_ERR);
- } else {
- // if successful, return a FileSystem object
- var success = function(file_system) {
- if (file_system) {
- if (successCallback) {
- // grab the name and root from the file system object
- var result = new FileSystem(file_system.name, file_system.root);
- successCallback(result);
- }
- }
- else {
- // no FileSystem object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
- exec(success, fail, "File", "requestFileSystem", [type, size]);
- }
-};
-
-module.exports = requestFileSystem;
-
-});
-
-// file: lib/common/plugin/resolveLocalFileSystemURI.js
-define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
-
-var argscheck = require('cordova/argscheck'),
- DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileError = require('cordova/plugin/FileError'),
- exec = require('cordova/exec');
-
-/**
- * Look up file system Entry referred to by local URI.
- * @param {DOMString} uri URI referring to a local file or directory
- * @param successCallback invoked with Entry object corresponding to URI
- * @param errorCallback invoked if error occurs retrieving file system entry
- */
-module.exports = function(uri, successCallback, errorCallback) {
- argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
- // error callback
- var fail = function(error) {
- errorCallback && errorCallback(new FileError(error));
- };
- // sanity check for 'not:valid:filename'
- if(!uri || uri.split(":").length > 2) {
- setTimeout( function() {
- fail(FileError.ENCODING_ERR);
- },0);
- return;
- }
- // if successful, return either a file or directory entry
- var success = function(entry) {
- var result;
- if (entry) {
- if (successCallback) {
- // create appropriate Entry object
- result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
- successCallback(result);
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
-};
-
-});
-
-// file: lib/common/plugin/splashscreen.js
-define("cordova/plugin/splashscreen", function(require, exports, module) {
-
-var exec = require('cordova/exec');
-
-var splashscreen = {
- show:function() {
- exec(null, null, "SplashScreen", "show", []);
- },
- hide:function() {
- exec(null, null, "SplashScreen", "hide", []);
- }
-};
-
-module.exports = splashscreen;
-
-});
-
-// file: lib/common/plugin/splashscreen/symbols.js
-define("cordova/plugin/splashscreen/symbols", function(require, exports, module) {
-
-
-var modulemapper = require('cordova/modulemapper');
-
-modulemapper.clobbers('cordova/plugin/splashscreen', 'navigator.splashscreen');
-
-});
-
-// file: lib/common/symbols.js
-define("cordova/symbols", function(require, exports, module) {
-
-var modulemapper = require('cordova/modulemapper');
-
-// Use merges here in case others symbols files depend on this running first,
-// but fail to declare the dependency with a require().
-modulemapper.merges('cordova', 'cordova');
-modulemapper.clobbers('cordova/exec', 'cordova.exec');
-modulemapper.clobbers('cordova/exec', 'Cordova.exec');
-
-});
-
-// file: lib/common/utils.js
-define("cordova/utils", function(require, exports, module) {
-
-var utils = exports;
-
-/**
- * Defines a property getter / setter for obj[key].
- */
-utils.defineGetterSetter = function(obj, key, getFunc, opt_setFunc) {
- if (Object.defineProperty) {
- var desc = {
- get: getFunc,
- configurable: true
- };
- if (opt_setFunc) {
- desc.set = opt_setFunc;
- }
- Object.defineProperty(obj, key, desc);
- } else {
- obj.__defineGetter__(key, getFunc);
- if (opt_setFunc) {
- obj.__defineSetter__(key, opt_setFunc);
- }
- }
-};
-
-/**
- * Defines a property getter for obj[key].
- */
-utils.defineGetter = utils.defineGetterSetter;
-
-utils.arrayIndexOf = function(a, item) {
- if (a.indexOf) {
- return a.indexOf(item);
- }
- var len = a.length;
- for (var i = 0; i < len; ++i) {
- if (a[i] == item) {
- return i;
- }
- }
- return -1;
-};
-
-/**
- * Returns whether the item was found in the array.
- */
-utils.arrayRemove = function(a, item) {
- var index = utils.arrayIndexOf(a, item);
- if (index != -1) {
- a.splice(index, 1);
- }
- return index != -1;
-};
-
-utils.typeName = function(val) {
- return Object.prototype.toString.call(val).slice(8, -1);
-};
-
-/**
- * Returns an indication of whether the argument is an array or not
- */
-utils.isArray = function(a) {
- return utils.typeName(a) == 'Array';
-};
-
-/**
- * Returns an indication of whether the argument is a Date or not
- */
-utils.isDate = function(d) {
- return utils.typeName(d) == 'Date';
-};
-
-/**
- * Does a deep clone of the object.
- */
-utils.clone = function(obj) {
- if(!obj || typeof obj == 'function' || utils.isDate(obj) || typeof obj != 'object') {
- return obj;
- }
-
- var retVal, i;
-
- if(utils.isArray(obj)){
- retVal = [];
- for(i = 0; i < obj.length; ++i){
- retVal.push(utils.clone(obj[i]));
- }
- return retVal;
- }
-
- retVal = {};
- for(i in obj){
- if(!(i in retVal) || retVal[i] != obj[i]) {
- retVal[i] = utils.clone(obj[i]);
- }
- }
- return retVal;
-};
-
-/**
- * Returns a wrapped version of the function
- */
-utils.close = function(context, func, params) {
- if (typeof params == 'undefined') {
- return function() {
- return func.apply(context, arguments);
- };
- } else {
- return function() {
- return func.apply(context, params);
- };
- }
-};
-
-/**
- * Create a UUID
- */
-utils.createUUID = function() {
- return UUIDcreatePart(4) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(2) + '-' +
- UUIDcreatePart(6);
-};
-
-/**
- * Extends a child object from a parent object using classical inheritance
- * pattern.
- */
-utils.extend = (function() {
- // proxy used to establish prototype chain
- var F = function() {};
- // extend Child from Parent
- return function(Child, Parent) {
- F.prototype = Parent.prototype;
- Child.prototype = new F();
- Child.__super__ = Parent.prototype;
- Child.prototype.constructor = Child;
- };
-}());
-
-/**
- * Alerts a message in any available way: alert or console.log.
- */
-utils.alert = function(msg) {
- if (window.alert) {
- window.alert(msg);
- } else if (console && console.log) {
- console.log(msg);
- }
-};
-
-
-//------------------------------------------------------------------------------
-function UUIDcreatePart(length) {
- var uuidpart = "";
- for (var i=0; i<length; i++) {
- var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
- if (uuidchar.length == 1) {
- uuidchar = "0" + uuidchar;
- }
- uuidpart += uuidchar;
- }
- return uuidpart;
-}
-
-
-});
-
-window.cordova = require('cordova');
-// file: lib/scripts/bootstrap.js
-
-(function (context) {
- if (context._cordovaJsLoaded) {
- throw new Error('cordova.js included multiple times.');
- }
- context._cordovaJsLoaded = true;
-
- var channel = require('cordova/channel');
- var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
-
- function logUnfiredChannels(arr) {
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i].state != 2) {
- console.log('Channel not fired: ' + arr[i].type);
- }
- }
- }
-
- window.setTimeout(function() {
- if (channel.onDeviceReady.state != 2) {
- console.log('deviceready has not fired after 5 seconds.');
- logUnfiredChannels(platformInitChannelsArray);
- logUnfiredChannels(channel.deviceReadyChannelsArray);
- }
- }, 5000);
-
- // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
- // We replace it so that properties that can't be clobbered can instead be overridden.
- function replaceNavigator(origNavigator) {
- var CordovaNavigator = function() {};
- CordovaNavigator.prototype = origNavigator;
- var newNavigator = new CordovaNavigator();
- // This work-around really only applies to new APIs that are newer than Function.bind.
- // Without it, APIs such as getGamepads() break.
- if (CordovaNavigator.bind) {
- for (var key in origNavigator) {
- if (typeof origNavigator[key] == 'function') {
- newNavigator[key] = origNavigator[key].bind(origNavigator);
- }
- }
- }
- return newNavigator;
- }
- if (context.navigator) {
- context.navigator = replaceNavigator(context.navigator);
- }
-
- // _nativeReady is global variable that the native side can set
- // to signify that the native code is ready. It is a global since
- // it may be called before any cordova JS is ready.
- if (window._nativeReady) {
- channel.onNativeReady.fire();
- }
-
- /**
- * Create all cordova objects once native side is ready.
- */
- channel.join(function() {
- // Call the platform-specific initialization
- require('cordova/platform').initialize();
-
- // Fire event to notify that all objects are created
- channel.onCordovaReady.fire();
-
- // Fire onDeviceReady event once page has fully loaded, all
- // constructors have run and cordova info has been received from native
- // side.
- // This join call is deliberately made after platform.initialize() in
- // order that plugins may manipulate channel.deviceReadyChannelsArray
- // if necessary.
- channel.join(function() {
- require('cordova').fireDocumentEvent('deviceready');
- }, channel.deviceReadyChannelsArray);
-
- }, platformInitChannelsArray);
-
-}(window));
-
-// file: lib/scripts/bootstrap-ios.js
-
-require('cordova/channel').onNativeReady.fire();
-
-// file: lib/scripts/plugin_loader.js
-
-// Tries to load all plugins' js-modules.
-// This is an async process, but onDeviceReady is blocked on onPluginsReady.
-// onPluginsReady is fired when there are no plugins to load, or they are all done.
-(function (context) {
- // To be populated with the handler by handlePluginsObject.
- var onScriptLoadingComplete;
-
- var scriptCounter = 0;
- function scriptLoadedCallback() {
- scriptCounter--;
- if (scriptCounter === 0) {
- onScriptLoadingComplete && onScriptLoadingComplete();
- }
- }
-
- function scriptErrorCallback(err) {
- // Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
- // this is currently just continuing.
- scriptCounter--;
- if (scriptCounter === 0) {
- onScriptLoadingComplete && onScriptLoadingComplete();
- }
- }
-
- // Helper function to inject a <script> tag.
- function injectScript(path) {
- scriptCounter++;
- var script = document.createElement("script");
- script.onload = scriptLoadedCallback;
- script.onerror = scriptErrorCallback;
- script.src = path;
- document.head.appendChild(script);
- }
-
- // Called when:
- // * There are plugins defined and all plugins are finished loading.
- // * There are no plugins to load.
- function finishPluginLoading() {
- context.cordova.require('cordova/channel').onPluginsReady.fire();
- }
-
- // Handler for the cordova_plugins.js content.
- // See plugman's plugin_loader.js for the details of this object.
- // This function is only called if the really is a plugins array that isn't empty.
- // Otherwise the onerror response handler will just call finishPluginLoading().
- function handlePluginsObject(modules, path) {
- // First create the callback for when all plugins are loaded.
- var mapper = context.cordova.require('cordova/modulemapper');
- onScriptLoadingComplete = function() {
- // Loop through all the plugins and then through their clobbers and merges.
- for (var i = 0; i < modules.length; i++) {
- var module = modules[i];
- if (module) {
- try {
- if (module.clobbers && module.clobbers.length) {
- for (var j = 0; j < module.clobbers.length; j++) {
- mapper.clobbers(module.id, module.clobbers[j]);
- }
- }
-
- if (module.merges && module.merges.length) {
- for (var k = 0; k < module.merges.length; k++) {
- mapper.merges(module.id, module.merges[k]);
- }
- }
-
- // Finally, if runs is truthy we want to simply require() the module.
- // This can be skipped if it had any merges or clobbers, though,
- // since the mapper will already have required the module.
- if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
- context.cordova.require(module.id);
- }
- }
- catch(err) {
- // error with module, most likely clobbers, should we continue?
- }
- }
- }
-
- finishPluginLoading();
- };
-
- // Now inject the scripts.
- for (var i = 0; i < modules.length; i++) {
- injectScript(path + modules[i].file);
- }
- }
-
- // Find the root of the app
- var path = '';
- var scripts = document.getElementsByTagName('script');
- var term = 'cordova.js';
- for (var n = scripts.length-1; n>-1; n--) {
- var src = scripts[n].src;
- if (src.indexOf(term) == (src.length - term.length)) {
- path = src.substring(0, src.length - term.length);
- break;
- }
- }
-
- var plugins_json = path + 'cordova_plugins.json';
- var plugins_js = path + 'cordova_plugins.js';
-
- // One some phones (Windows) this xhr.open throws an Access Denied exception
- // So lets keep trying, but with a script tag injection technique instead of XHR
- var injectPluginScript = function injectPluginScript() {
- try {
- var script = document.createElement("script");
- script.onload = function(){
- var list = cordova.require("cordova/plugin_list");
- handlePluginsObject(list,path);
- };
- script.onerror = function() {
- // Error loading cordova_plugins.js, file not found or something
- // this is an acceptable error, pre-3.0.0, so we just move on.
- finishPluginLoading();
- };
- script.src = plugins_js;
- document.head.appendChild(script);
-
- } catch(err){
- finishPluginLoading();
- }
- }
-
-
- // Try to XHR the cordova_plugins.json file asynchronously.
- var xhr = new XMLHttpRequest();
- xhr.onload = function() {
- // If the response is a JSON string which composes an array, call handlePluginsObject.
- // If the request fails, or the response is not a JSON array, just call finishPluginLoading.
- var obj;
- try {
- obj = (this.status == 0 || this.status == 200) && this.responseText && JSON.parse(this.responseText);
- } catch (err) {
- // obj will be undefined.
- }
- if (Array.isArray(obj) && obj.length > 0) {
- handlePluginsObject(obj, path);
- } else {
- finishPluginLoading();
- }
- };
- xhr.onerror = function() {
- // In this case, the json file was not present, but XHR was allowed,
- // so we should still try the script injection technique with the js file
- // in case that is there.
- injectPluginScript();
- };
- try { // we commented we were going to try, so let us actually try and catch
- xhr.open('GET', plugins_json, true); // Async
- xhr.send();
- } catch(err){
- injectPluginScript();
- }
-}(window));
-
-
-})();var PhoneGap = cordova;
diff --git a/iPhone/Default-568h@2x.png b/res/ios/Default-568h@2x.png
index a56b662..a56b662 100644
--- a/iPhone/Default-568h@2x.png
+++ b/res/ios/Default-568h@2x.png
Binary files differ
diff --git a/iPhone/Default.png b/res/ios/Default.png
index 9c373ff..9c373ff 100644
--- a/iPhone/Default.png
+++ b/res/ios/Default.png
Binary files differ
diff --git a/iPhone/Default@2x.png b/res/ios/Default@2x.png
index 92fe138..92fe138 100644
--- a/iPhone/Default@2x.png
+++ b/res/ios/Default@2x.png
Binary files differ
diff --git a/iPhone/Icon-120.png b/res/ios/Icon-120.png
index f019a23..f019a23 100644
--- a/iPhone/Icon-120.png
+++ b/res/ios/Icon-120.png
Binary files differ
diff --git a/iPhone/FixMyStreet/Icon.png b/res/ios/Icon.png
index 6a045b6..6a045b6 100644
--- a/iPhone/FixMyStreet/Icon.png
+++ b/res/ios/Icon.png
Binary files differ
diff --git a/iPhone/FixMyStreet/Icon@2x.png b/res/ios/Icon@2x.png
index 8ff853c..8ff853c 100644
--- a/iPhone/FixMyStreet/Icon@2x.png
+++ b/res/ios/Icon@2x.png
Binary files differ