You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/06/11 02:51:15 UTC
[01/36] ios commit: Add a .reviewboardrc file to make using
post-review easier.
Updated Branches:
refs/heads/3.0.0 14ef47f2c -> 882b06cd3 (forced update)
Add a .reviewboardrc file to make using post-review easier.
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/e4b02176
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/e4b02176
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/e4b02176
Branch: refs/heads/3.0.0
Commit: e4b021760c83442682caeee2f3f34e57fe3a4e6b
Parents: d2b1c4b
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue May 21 12:37:34 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue May 21 12:38:04 2013 -0400
----------------------------------------------------------------------
.reviewboardrc | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e4b02176/.reviewboardrc
----------------------------------------------------------------------
diff --git a/.reviewboardrc b/.reviewboardrc
new file mode 100644
index 0000000..30e9587
--- /dev/null
+++ b/.reviewboardrc
@@ -0,0 +1,8 @@
+#
+# Settings for post-review (used for uploading diffs to reviews.apache.org).
+#
+GUESS_FIELDS = True
+OPEN_BROWSER = True
+TARGET_GROUPS = 'cordova'
+REVIEWBOARD_URL = 'http://reviews.apache.org'
+
[16/36] ios commit: [CB-3031] Fix for emulate script when project
name has a space
Posted by st...@apache.org.
[CB-3031] Fix for emulate script when project name has a space
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/dad34250
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/dad34250
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/dad34250
Branch: refs/heads/3.0.0
Commit: dad34250dc56283e65e7ef14c4d2e5d7217a233e
Parents: 6caaa62
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed May 29 15:37:05 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed May 29 15:37:05 2013 -0400
----------------------------------------------------------------------
bin/templates/project/cordova/emulate | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/dad34250/bin/templates/project/cordova/emulate
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/emulate b/bin/templates/project/cordova/emulate
index 9a3c3c4..b0ab99b 100755
--- a/bin/templates/project/cordova/emulate
+++ b/bin/templates/project/cordova/emulate
@@ -26,12 +26,15 @@ if [[ "$XCODE_VER" < "$XCODE_MIN_VERSION" ]]; then
exit 1
fi
+SDK=`xcodebuild -showsdks | grep Sim | tail -1 | awk '{print $6}'`
+
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}
+APP_PATH=${1:-$PROJECT_PATH/build/$(xcodebuild -project $PROJECT_NAME.xcodeproj -arch i386 -target $PROJECT_NAME -configuration Debug -sdk $SDK -showBuildSettings | grep FULL_PRODUCT_NAME | awk -F ' = ' '{print $2}')}
+
DEVICE_FAMILY=${2:-${DEVICE_FAMILY:-iphone}}
if [ ! -d "$APP_PATH" ]; then
[10/36] ios commit: [CB-3507] Wrong Linker Flag for project template
Posted by st...@apache.org.
[CB-3507] Wrong Linker Flag for project template
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/c6f22ff9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/c6f22ff9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/c6f22ff9
Branch: refs/heads/3.0.0
Commit: c6f22ff993aad6868038327660794c1626d0db90
Parents: 3a887de
Author: Song Zheng <co...@gmail.com>
Authored: Fri May 24 12:59:51 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 28 13:52:44 2013 -0700
----------------------------------------------------------------------
bin/templates/project/__TESTING__.xcodeproj/project.pbxproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c6f22ff9/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
index 6b81e10..bb0ec86 100755
--- a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
+++ b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
@@ -545,7 +545,7 @@
CoreMedia,
"-weak-lSystem",
"-all_load",
- "-Obj-C",
+ "-ObjC",
);
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
@@ -585,7 +585,7 @@
CoreMedia,
"-weak-lSystem",
"-all_load",
- "-Obj-C",
+ "-ObjC",
);
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
[35/36] ios commit: removed camera code
Posted by st...@apache.org.
removed camera code
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/3efb25bb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/3efb25bb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/3efb25bb
Branch: refs/heads/3.0.0
Commit: 3efb25bb669207186da6a106bce65c1779a3afed
Parents: 592e389
Author: Steven Gill <st...@gmail.com>
Authored: Thu May 23 15:04:08 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:49:43 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVCamera.h | 102 ---
CordovaLib/Classes/CDVCamera.m | 729 -------------------
CordovaLib/Classes/CDVExif.h | 43 --
CordovaLib/Classes/CDVJpegHeaderWriter.h | 62 --
CordovaLib/Classes/CDVJpegHeaderWriter.m | 547 --------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 20 -
CordovaLib/cordova.js | 14 +
bin/templates/project/__TESTING__/config.xml | 3 -
9 files changed, 14 insertions(+), 1507 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 9da128a..03c2a3e 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,7 +25,6 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVCamera.h"
#import "CDVCapture.h"
#import "CDVConnection.h"
#import "CDVDebug.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h
deleted file mode 100644
index 2932e3b..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
deleted file mode 100644
index 1ee641c..0000000
--- a/CordovaLib/Classes/CDVCamera.m
+++ /dev/null
@@ -1,729 +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 {
- self.data = UIImageJPEGRepresentation(scaledImage == nil ? image : scaledImage, cameraPicker.quality / 100.0f);
-
- NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
- if (controllerMetadata) {
- 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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/Classes/CDVExif.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVExif.h b/CordovaLib/Classes/CDVExif.h
deleted file mode 100644
index 3e8adbd..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/Classes/CDVJpegHeaderWriter.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJpegHeaderWriter.h b/CordovaLib/Classes/CDVJpegHeaderWriter.h
deleted file mode 100644
index 3b43ef0..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/Classes/CDVJpegHeaderWriter.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVJpegHeaderWriter.m b/CordovaLib/Classes/CDVJpegHeaderWriter.m
deleted file mode 100644
index 93cafb8..0000000
--- a/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:¤tDataOffset];
-
- //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:¤tDataOffset];
- /*
- 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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 01e44cd..c4803a0 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -36,15 +36,10 @@
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 */; };
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD301090FBE7009987E8 /* CDVFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -120,16 +115,11 @@
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>"; };
8887FD301090FBE7009987E8 /* CDVFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CDVFile.h; path = Classes/CDVFile.h; sourceTree = "<group>"; };
@@ -258,13 +248,8 @@
307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 8887FD261090FBE7009987E8 /* CDVCamera.h */,
- 8887FD271090FBE7009987E8 /* CDVCamera.m */,
1F584B991385A28900ED25E8 /* CDVCapture.h */,
1F584B9A1385A28900ED25E8 /* CDVCapture.m */,
- 68B7516A16FD18190076A8B4 /* CDVExif.h */,
- 68B7516B16FD18190076A8B4 /* CDVJpegHeaderWriter.h */,
- 68B7516C16FD18190076A8B4 /* CDVJpegHeaderWriter.m */,
EB80C2AA15DEA63D004D9E7B /* CDVEcho.h */,
EB80C2AB15DEA63D004D9E7B /* CDVEcho.m */,
8887FD301090FBE7009987E8 /* CDVFile.h */,
@@ -327,9 +312,6 @@
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 */,
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
@@ -421,7 +403,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 8887FD671090FBE7009987E8 /* CDVCamera.m in Sources */,
8887FD691090FBE7009987E8 /* NSDictionary+Extensions.m in Sources */,
8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
@@ -450,7 +431,6 @@
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;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index d4a7758..706ce47 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -2,6 +2,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.8.0-0-g6208c95
=======
// 2.7.0rc1-80-geda98d1
@@ -12,6 +13,9 @@
=======
// 2.7.0rc1-82-g32587e6
>>>>>>> removed splashscreen
+=======
+// 2.7.0rc1-84-gdba3744
+>>>>>>> removed camera code
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -34,6 +38,7 @@
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-80-geda98d1';
@@ -44,6 +49,9 @@ var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-81-gc09114e';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-82-g32587e6';
>>>>>>> removed splashscreen
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-gdba3744';
+>>>>>>> removed camera code
// file: lib/scripts/require.js
var require,
@@ -1169,6 +1177,7 @@ module.exports = {
});
+<<<<<<< HEAD
// file: lib/common/plugin/Acceleration.js
define("cordova/plugin/Acceleration", function(require, exports, module) {
@@ -1320,6 +1329,8 @@ module.exports = CameraPopoverOptions;
});
+=======
+>>>>>>> removed camera code
// file: lib/common/plugin/CaptureAudioOptions.js
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
@@ -3712,6 +3723,7 @@ module.exports = ProgressEvent;
});
<<<<<<< HEAD
+<<<<<<< HEAD
// file: lib/common/plugin/accelerometer.js
define("cordova/plugin/accelerometer", function(require, exports, module) {
@@ -3986,6 +3998,8 @@ modulemapper.defaults('cordova/plugin/CameraPopoverOptions', 'CameraPopoverOptio
});
+=======
+>>>>>>> removed camera code
// file: lib/common/plugin/capture.js
define("cordova/plugin/capture", function(require, exports, module) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3efb25bb/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index f1a6dce..3c4d704 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -59,9 +59,6 @@
<feature name="Media">
<param name="ios-package" value="CDVSound"/>
</feature>
- <feature name="Camera">
- <param name="ios-package" value="CDVCamera"/>
- </feature>
<feature name="File">
<param name="ios-package" value="CDVFile"/>
</feature>
[07/36] ios commit: [CB-3469] Adding missing license found by RAT
Posted by st...@apache.org.
[CB-3469] Adding missing license found by RAT
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/951b6cb2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/951b6cb2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/951b6cb2
Branch: refs/heads/3.0.0
Commit: 951b6cb2f6d920b2cd28dd9598274331ad5a0d47
Parents: 7bc06d5
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue May 28 15:59:20 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue May 28 15:59:20 2013 -0400
----------------------------------------------------------------------
CordovaLibTests/CordovaLibApp/config.xml | 18 ++
CordovaLibTests/ExifTests.h | 45 +++--
CordovaLibTests/ExifTests.m | 195 ++++++++++---------
bin/templates/project/__TESTING__/config.xml | 18 ++
.../project/cordova/lib/sim.applescript | 17 ++
bin/uncrustify.cfg | 18 +-
6 files changed, 204 insertions(+), 107 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/951b6cb2/CordovaLibTests/CordovaLibApp/config.xml
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CordovaLibApp/config.xml b/CordovaLibTests/CordovaLibApp/config.xml
index 3e84967..136804e 100644
--- a/CordovaLibTests/CordovaLibApp/config.xml
+++ b/CordovaLibTests/CordovaLibApp/config.xml
@@ -1,4 +1,22 @@
<?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 = "io.cordova.helloCordova"
version = "2.0.0">
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/951b6cb2/CordovaLibTests/ExifTests.h
----------------------------------------------------------------------
diff --git a/CordovaLibTests/ExifTests.h b/CordovaLibTests/ExifTests.h
index b46241b..45e17c4 100644
--- a/CordovaLibTests/ExifTests.h
+++ b/CordovaLibTests/ExifTests.h
@@ -1,10 +1,21 @@
-//
-// ExifTestTests.h
-// ExifTestTests
-//
-// Created by Lorin Beer on 2013-03-18.
-//
-//
+/*
+ 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 <SenTestingKit/SenTestingKit.h>
@@ -13,15 +24,15 @@
#define ARC4RANDOM_MAX 0x100000000
@interface ExifTestTests : SenTestCase {
- CDVJpegHeaderWriter * testHeaderWriter;
- NSNumber * testErrorThreshhold;
+ CDVJpegHeaderWriter* testHeaderWriter;
+ NSNumber* testErrorThreshhold;
}
-- (void) testContinuedFractionWithUInt;
-- (void) testContinuedFractionWithUFloat;
-- (void) testContinuedFractionsWorstCase;
-- (void) testFormatHexFromDecimal;
-- (void) testFormatNumberWithLeadingZeroes;
-- (void) testUnsignedRationalToString;
-- (void) testSignedRationalToString;
-@end
\ No newline at end of file
+- (void)testContinuedFractionWithUInt;
+- (void)testContinuedFractionWithUFloat;
+- (void)testContinuedFractionsWorstCase;
+- (void)testFormatHexFromDecimal;
+- (void)testFormatNumberWithLeadingZeroes;
+- (void)testUnsignedRationalToString;
+- (void)testSignedRationalToString;
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/951b6cb2/CordovaLibTests/ExifTests.m
----------------------------------------------------------------------
diff --git a/CordovaLibTests/ExifTests.m b/CordovaLibTests/ExifTests.m
index 960ac95..dfd6da4 100644
--- a/CordovaLibTests/ExifTests.m
+++ b/CordovaLibTests/ExifTests.m
@@ -1,154 +1,171 @@
-//
-// ExifTestTests.m
-// ExifTestTests
-//
-// Created by Lorin Beer on 2013-03-18.
-//
-//
+/*
+ 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 <SenTestingKit/SenTestingKit.h>
#import "ExifTestTests.h"
#import "../ExifTest/CDVJpegHeaderWriter.m"
-
@implementation ExifTestTests
- (void)setUp
{
[super setUp];
testHeaderWriter = [[CDVJpegHeaderWriter alloc] init];
- testErrorThreshhold = [NSNumber numberWithDouble: 0.000001];
- NSLog(@"%x", ~10+1);
-
-
+ testErrorThreshhold = [NSNumber numberWithDouble:0.000001];
+ NSLog(@"%x", ~10 + 1);
}
- (void)tearDown
{
// Tear-down code here.
-
+
[super tearDown];
}
-//==================================================================================================
+// ==================================================================================================
// rational approximation of decimal by continued fraction tests
-//==================================================================================================
+// ==================================================================================================
// tests continued fraction with random int
-- (void)testContinuedFractionWithUInt {
+- (void)testContinuedFractionWithUInt
+{
NSLog(@"Continued Fraction Test with random int value, numerator should be generated value, denominator should be 1");
- NSNumber * numerator = @0;
- NSNumber * denominator = @0;
- NSNumber * testValue = [NSNumber numberWithInt: abs(arc4random())];
- [testHeaderWriter decimalToUnsignedRational: testValue
- withResultNumerator: &numerator
- withResultDenominator: &denominator];
+ NSNumber* numerator = @0;
+ NSNumber* denominator = @0;
+ NSNumber* testValue = [NSNumber numberWithInt:abs(arc4random())];
+ [testHeaderWriter decimalToUnsignedRational:testValue
+ withResultNumerator:&numerator
+ withResultDenominator:&denominator];
STAssertEquals([numerator intValue],
- [testValue intValue],
- @"Numerator did not match");
+ [testValue intValue],
+ @"Numerator did not match");
STAssertEquals([denominator intValue],
- 1,
- @"denominator was not one");
+ 1,
+ @"denominator was not one");
}
// tests continued fraction with random float
-- (void)testContinuedFractionWithUFloat {
+- (void)testContinuedFractionWithUFloat
+{
NSLog(@"Continued Fraction Test with random double value, resulting fraction should be within acceptable error threshhold");
- NSNumber * threshhold = @0.1;
- NSNumber * numerator = @0;
- NSNumber * denominator = @0;
- NSLog(@"%f",((double)arc4random() / ARC4RANDOM_MAX) * 100.0f);
- NSNumber * testValue = [NSNumber numberWithDouble:
- ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f];
-
- [testHeaderWriter decimalToUnsignedRational: testValue
- withResultNumerator: &numerator
- withResultDenominator: &denominator];
- NSLog(@"%lf, %lf",[testValue doubleValue], [numerator doubleValue]/[denominator doubleValue]);
+ NSNumber* threshhold = @0.1;
+ NSNumber* numerator = @0;
+ NSNumber* denominator = @0;
+ NSLog(@"%f", ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f);
+ NSNumber* testValue = [NSNumber numberWithDouble:
+ ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f];
+
+ [testHeaderWriter decimalToUnsignedRational:testValue
+ withResultNumerator:&numerator
+ withResultDenominator:&denominator];
+ NSLog(@"%lf, %lf", [testValue doubleValue], [numerator doubleValue] / [denominator doubleValue]);
STAssertEqualsWithAccuracy([testValue doubleValue],
- [numerator doubleValue]/[denominator doubleValue],
- [threshhold doubleValue],
- @"rational approximation did not meet acceptable error threshhold");
-
+ [numerator doubleValue] / [denominator doubleValue],
+ [threshhold doubleValue],
+ @"rational approximation did not meet acceptable error threshhold");
}
// tests continued fraction in sqrt(2) worst case
-- (void)testContinuedFractionsWorstCase {
+- (void)testContinuedFractionsWorstCase
+{
NSLog(@"Continued Fraction Test with provable worst case ~sqrt(2), resulting fraction should be within acceptable error threshhold");
- NSNumber * threshhold = @0.1;
- NSNumber * numerator = @0;
- NSNumber * denominator = @0;
- NSNumber * testValue = [NSNumber numberWithDouble: sqrt(2)];
- [testHeaderWriter decimalToUnsignedRational: testValue
- withResultNumerator: &numerator
- withResultDenominator: &denominator];
+ NSNumber* threshhold = @0.1;
+ NSNumber* numerator = @0;
+ NSNumber* denominator = @0;
+ NSNumber* testValue = [NSNumber numberWithDouble:sqrt(2)];
+ [testHeaderWriter decimalToUnsignedRational:testValue
+ withResultNumerator:&numerator
+ withResultDenominator:&denominator];
STAssertEqualsWithAccuracy([testValue doubleValue],
- [numerator doubleValue]/[denominator doubleValue],
- [threshhold doubleValue],
- @"rational approximation did not meet acceptable error threshhold");
+ [numerator doubleValue] / [denominator doubleValue],
+ [threshhold doubleValue],
+ @"rational approximation did not meet acceptable error threshhold");
}
// tests format hex from a decimal
-- (void) testFormatHexFromDecimal {
- NSNumber * testValue = @1;
- NSNumber * testPlaces = @8;
- NSString * result = nil;
- result = [testHeaderWriter formattedHexStringFromDecimalNumber: testValue
- withPlaces: testPlaces];
+- (void)testFormatHexFromDecimal
+{
+ NSNumber* testValue = @1;
+ NSNumber* testPlaces = @8;
+ NSString* result = nil;
+
+ result = [testHeaderWriter formattedHexStringFromDecimalNumber:testValue
+ withPlaces:testPlaces];
// assert not nil
STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
// assert correct number of places
STAssertEquals([result length], [testPlaces unsignedIntegerValue],
- @"returned string to wrong number of places. Should be = %i Was = %i",
- [testPlaces intValue],
- [result length]);
+ @"returned string to wrong number of places. Should be = %i Was = %i",
+ [testPlaces intValue],
+ [result length]);
// assert correct hex representation
STAssertTrueNoThrow([result isEqualToString:@"00000001"], @"result should be equal to @00000001");
-
}
// tests format number string with leading zeroes
-- (void) testFormatNumberWithLeadingZeroes {
- NSString * result = nil;
- NSNumber * testValue = @8769; // Exif SubIFD Offset Tag
- NSNumber * testPlaces = @6;
- result = [testHeaderWriter formatNumberWithLeadingZeroes: testValue
- withPlaces: testPlaces];
+- (void)testFormatNumberWithLeadingZeroes
+{
+ NSString* result = nil;
+ NSNumber* testValue = @8769; // Exif SubIFD Offset Tag
+ NSNumber* testPlaces = @6;
+
+ result = [testHeaderWriter formatNumberWithLeadingZeroes:testValue
+ withPlaces:testPlaces];
STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
STAssertEquals([result length],
- [testPlaces unsignedIntegerValue],
- @"returned string to wrong number of places. Should be = %i Was = %i",
- [testPlaces intValue],
- [result length]);
+ [testPlaces unsignedIntegerValue],
+ @"returned string to wrong number of places. Should be = %i Was = %i",
+ [testPlaces intValue],
+ [result length]);
// assert correct hex representation
STAssertTrueNoThrow([result isEqualToString:@"008769"], @"result was = %@ should be = @008769", result);
}
-- (void) testUnsignedRationalToString {
- NSString * result = nil;
- NSNumber * numerator = @1;
- NSNumber * denominator = @10;
- result = [testHeaderWriter formatRationalWithNumerator: numerator
- withDenominator: denominator
- asSigned: FALSE];
+- (void)testUnsignedRationalToString
+{
+ NSString* result = nil;
+ NSNumber* numerator = @1;
+ NSNumber* denominator = @10;
+
+ result = [testHeaderWriter formatRationalWithNumerator:numerator
+ withDenominator:denominator
+ asSigned:FALSE];
NSLog(result);
STAssertNotNil(result, @"nil returned from testUnsignedRationalToString");
- STAssertTrueNoThrow([result length]==16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes",[result length]/2);
+ STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
STAssertTrueNoThrow([result isEqualToString:@"000000010000000a"], @"result was = %@ should be = @0000000100000010", result);
}
-- (void) testSignedRationalToString {
- NSString * result = nil;
- NSNumber * numerator = @-1;
- NSNumber * denominator = @-10;
- result = [testHeaderWriter formatRationalWithNumerator: numerator
- withDenominator: denominator
- asSigned: TRUE];
+- (void)testSignedRationalToString
+{
+ NSString* result = nil;
+ NSNumber* numerator = @ - 1;
+ NSNumber* denominator = @ - 10;
+
+ result = [testHeaderWriter formatRationalWithNumerator:numerator
+ withDenominator:denominator
+ asSigned:TRUE];
NSLog(result);
STAssertNotNil(result, @"nil returned from testSignedRationalToString");
- STAssertTrueNoThrow([result length]==16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes",[result length]/2);
+ STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
STAssertTrueNoThrow([result isEqualToString:@"fffffffffffffff6"], @"result was = %@ should be = @000000FF000000F6", result);
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/951b6cb2/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index ca292c8..db64661 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -1,4 +1,22 @@
<?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 = "io.cordova.helloCordova"
version = "2.0.0">
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/951b6cb2/bin/templates/project/cordova/lib/sim.applescript
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/sim.applescript b/bin/templates/project/cordova/lib/sim.applescript
index 5f6b152..8425625 100755
--- a/bin/templates/project/cordova/lib/sim.applescript
+++ b/bin/templates/project/cordova/lib/sim.applescript
@@ -1,3 +1,20 @@
+# 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.
+
tell application "System Events"
set UI elements enabled to true
end tell
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/951b6cb2/bin/uncrustify.cfg
----------------------------------------------------------------------
diff --git a/bin/uncrustify.cfg b/bin/uncrustify.cfg
index d52ce33..1e3099b 100644
--- a/bin/uncrustify.cfg
+++ b/bin/uncrustify.cfg
@@ -1,4 +1,20 @@
-# Uncrustify 0.59
+# 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.
+
# Based off of https://gist.github.com/261662/
#
[21/36] ios commit: CB-3420: add hidden option to InAppBrowser
Posted by st...@apache.org.
CB-3420: add hidden option to InAppBrowser
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/fde980a4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/fde980a4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/fde980a4
Branch: refs/heads/3.0.0
Commit: fde980a492ae96ff11ccb77ad8b9aae3bed55322
Parents: f81d5b2
Author: David Kemp <dr...@dhcp-172-23-180-121.wat.corp.google.com>
Authored: Tue Jun 4 13:54:43 2013 -0400
Committer: David Kemp <dr...@dhcp-172-23-180-121.wat.corp.google.com>
Committed: Tue Jun 4 13:54:43 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVInAppBrowser.h | 2 ++
CordovaLib/Classes/CDVInAppBrowser.m | 15 ++++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/fde980a4/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
index f87baff..248274a 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/CordovaLib/Classes/CDVInAppBrowser.h
@@ -34,6 +34,7 @@
- (void)open:(CDVInvokedUrlCommand*)command;
- (void)close:(CDVInvokedUrlCommand*)command;
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
+- (void)show:(CDVInvokedUrlCommand*)command;
@end
@@ -81,6 +82,7 @@
@property (nonatomic, assign) BOOL allowinlinemediaplayback;
@property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction;
@property (nonatomic, assign) BOOL suppressesincrementalrendering;
+@property (nonatomic, assign) BOOL hidden;
+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/fde980a4/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index d5f06ec..b832e23 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -101,13 +101,13 @@
}
}
+
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) {
@@ -130,6 +130,7 @@
}
self.inAppBrowserViewController.modalTransitionStyle = transitionStyle;
+
// UIWebView options
self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale;
self.inAppBrowserViewController.webView.mediaPlaybackRequiresUserAction = browserOptions.mediaplaybackrequiresuseraction;
@@ -138,13 +139,20 @@
self.inAppBrowserViewController.webView.keyboardDisplayRequiresUserAction = browserOptions.keyboarddisplayrequiresuseraction;
self.inAppBrowserViewController.webView.suppressesIncrementalRendering = browserOptions.suppressesincrementalrendering;
}
-
- if (self.viewController.modalViewController != self.inAppBrowserViewController) {
+
+ 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]) {
@@ -764,6 +772,7 @@
self.allowinlinemediaplayback = NO;
self.keyboarddisplayrequiresuseraction = YES;
self.suppressesincrementalrendering = NO;
+ self.hidden = NO;
}
return self;
[32/36] ios commit: removed contact code
Posted by st...@apache.org.
removed contact code
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/1d828c25
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/1d828c25
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/1d828c25
Branch: refs/heads/3.0.0
Commit: 1d828c253cbac03d893c0bee895eb54bbdfe430d
Parents: 00c97c9
Author: Steven Gill <st...@gmail.com>
Authored: Wed May 22 13:54:57 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:49:10 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 2 -
CordovaLib/Classes/CDVContact.h | 136 --
CordovaLib/Classes/CDVContact.m | 1752 ------------------
CordovaLib/Classes/CDVContacts.h | 151 --
CordovaLib/Classes/CDVContacts.m | 592 ------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 16 -
bin/templates/project/__TESTING__/config.xml | 3 -
7 files changed, 2652 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1d828c25/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index e9c8e16..9da128a 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -28,8 +28,6 @@
#import "CDVCamera.h"
#import "CDVCapture.h"
#import "CDVConnection.h"
-#import "CDVContact.h"
-#import "CDVContacts.h"
#import "CDVDebug.h"
#import "CDVDevice.h"
#import "CDVFile.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1d828c25/CordovaLib/Classes/CDVContact.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.h b/CordovaLib/Classes/CDVContact.h
deleted file mode 100644
index 5187efc..0000000
--- a/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"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1d828c25/CordovaLib/Classes/CDVContact.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.m b/CordovaLib/Classes/CDVContact.m
deleted file mode 100644
index 3844525..0000000
--- a/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
[28/36] ios commit: fixed merge commit
Posted by st...@apache.org.
fixed merge commit
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/03877488
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/03877488
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/03877488
Branch: refs/heads/3.0.0
Commit: 038774882b73d278308a2c744f972fbb66d1a67a
Parents: 6188b0f
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 10 17:47:08 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:47:08 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVInAppBrowser.h | 89 --
CordovaLib/Classes/CDVInAppBrowser.m | 818 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 -
CordovaLib/cordova.js | 94 +--
bin/templates/project/__TESTING__/config.xml | 3 -
6 files changed, 8 insertions(+), 1005 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/03877488/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 49342be..267ad8a 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -41,7 +41,6 @@
#import "CDVSplashScreen.h"
#import "CDVWhitelist.h"
#import "CDVLocalStorage.h"
-#import "CDVInAppBrowser.h"
#import "CDVScreenOrientationDelegate.h"
#import "CDVTimer.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/03877488/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
deleted file mode 100644
index 248274a..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/03877488/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
deleted file mode 100644
index b832e23..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/03877488/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 0c2715c..224d8fa 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -22,8 +22,6 @@
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 */; };
@@ -104,8 +102,6 @@
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>"; };
@@ -309,8 +305,6 @@
3E76876C156A90EE00EB6FA3 /* CDVLogger.h */,
9D76CF3A1625A4C50008A0F6 /* CDVGlobalization.h */,
9D76CF3B1625A4C50008A0F6 /* CDVGlobalization.m */,
- 3073E9E71656D37700957977 /* CDVInAppBrowser.h */,
- 3073E9E81656D37700957977 /* CDVInAppBrowser.m */,
3073E9EC1656D51200957977 /* CDVScreenOrientationDelegate.h */,
30F39309169F839700B22307 /* CDVJSON.h */,
30F3930A169F839700B22307 /* CDVJSON.m */,
@@ -392,7 +386,6 @@
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 */,
@@ -485,7 +478,6 @@
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 */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/03877488/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index e5c56d1..6c42712 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,9 @@
// Platform: ios
+<<<<<<< HEAD
// 2.8.0-0-g6208c95
+=======
+// 2.7.0rc1-80-geda98d1
+>>>>>>> removed InAppBrowser
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +23,11 @@
under the License.
*/
;(function() {
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-80-geda98d1';
+>>>>>>> removed InAppBrowser
// file: lib/scripts/require.js
var require,
@@ -3275,82 +3283,6 @@ 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", []);
- },
- 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) {
@@ -5231,16 +5163,6 @@ 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) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/03877488/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 470e656..7bb5448 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -89,9 +89,6 @@
<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>
[26/36] ios commit: removed accel & compass from config.xml
Posted by st...@apache.org.
removed accel & compass from config.xml
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/8cb40ae4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/8cb40ae4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/8cb40ae4
Branch: refs/heads/3.0.0
Commit: 8cb40ae4cf7bfaf8b56b810d8136092afcd77573
Parents: f3b05c3
Author: Steven Gill <st...@gmail.com>
Authored: Mon May 13 14:00:07 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:35:55 2013 -0700
----------------------------------------------------------------------
bin/templates/project/__TESTING__/config.xml | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8cb40ae4/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index db64661..1a5836f 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -59,12 +59,6 @@
<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>
[33/36] ios commit: updated template to arc
Posted by st...@apache.org.
updated template to arc
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/c73d91e5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/c73d91e5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/c73d91e5
Branch: refs/heads/3.0.0
Commit: c73d91e526e2e4b527622c89e5b31087221b8208
Parents: 1d828c2
Author: Steven Gill <st...@gmail.com>
Authored: Wed May 22 15:20:32 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:49:11 2013 -0700
----------------------------------------------------------------------
bin/templates/project/__TESTING__.xcodeproj/project.pbxproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/c73d91e5/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
index f0f80bb..8617ccb 100755
--- a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
+++ b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
@@ -481,7 +481,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ENABLE_OBJC_ARC = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -500,7 +500,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- CLANG_ENABLE_OBJC_ARC = NO;
+ CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "__TESTING__/__TESTING__-Prefix.pch";
[08/36] ios commit: [CB-3524] cordova/emulate and cordova/run
silently fails when ios-sim is not installed
Posted by st...@apache.org.
[CB-3524] cordova/emulate and cordova/run silently fails when ios-sim is not installed
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/ab85edc6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/ab85edc6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/ab85edc6
Branch: refs/heads/3.0.0
Commit: ab85edc68c284aa8221dc150e0fbcd8f94c4ea73
Parents: 951b6cb
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue May 28 12:43:37 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 28 13:08:15 2013 -0700
----------------------------------------------------------------------
bin/templates/project/cordova/emulate | 2 --
bin/templates/project/cordova/run | 2 --
2 files changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/ab85edc6/bin/templates/project/cordova/emulate
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/emulate b/bin/templates/project/cordova/emulate
index e81c1bd..9a3c3c4 100755
--- a/bin/templates/project/cordova/emulate
+++ b/bin/templates/project/cordova/emulate
@@ -18,8 +18,6 @@
# under the License.
#
-set -e
-
XCODE_VER=$(xcodebuild -version | head -n 1 | sed -e 's/Xcode //')
XCODE_MIN_VERSION="4.5"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/ab85edc6/bin/templates/project/cordova/run
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/run b/bin/templates/project/cordova/run
index da0916c..a616352 100755
--- a/bin/templates/project/cordova/run
+++ b/bin/templates/project/cordova/run
@@ -24,8 +24,6 @@
# "iPad"
# "iPad (Retina)"
-set -e
-
OPTION_RESULT=()
TARGET="iPhone (Retina 3.5-inch)"
TARGET_FLAG='--family iphone --retina'
[05/36] ios commit: Update RELEASENOTES for 2.8.0
Posted by st...@apache.org.
Update RELEASENOTES for 2.8.0
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/bd995370
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/bd995370
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/bd995370
Branch: refs/heads/3.0.0
Commit: bd99537034d4917bb4677dab1c45d85d409ac22f
Parents: 8b18210
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri May 24 16:22:21 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 24 16:22:21 2013 -0400
----------------------------------------------------------------------
RELEASENOTES.md | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/bd995370/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 3c2031a..72a48c6 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -19,8 +19,43 @@
#
-->
## Release Notes for Cordova (iOS) ##
-
- Cordova is a static library that enables developers to include the Cordova API in their iOS application projects easily, and also create new Cordova-based iOS application projects through the command-line.
+
+Update these notes using: git log --pretty=format:'* %s' --topo-order --no-merges origin/2.7.x...HEAD
+
+Cordova is a static library that enables developers to include the Cordova API in their iOS application projects easily, and also create new Cordova-based iOS application projects through the command-line.
+
+### 2.8.0 (201305XX) ###
+
+* [CB-2840] Nil checks to avoid crash when network disconnected
+* [CB-3416] adding empty <plugins> element during deprecation window.
+* [CB-3006] Customize InAppBrowser location bar
+* [CB-3405] InAppBrowser option to hide bottom bar with Done/History buttons
+* [CB-3394] Cordova iOS crashes when multiple access elements in config.xml
+* [CB-3166] Add deprecation notice for use of <plugin> in config.xml in iOS
+* [CB-2905] Exif geolocation meta data tag writing
+* [CB-3307] Rename cordova-ios.js -> cordova.js
+* [CB-1108] Convert <plugin> -> <feature> with <param>
+* [CB-3321] Fix bogus "failed whitelist" log messages
+* [CB-3311] add default textbox for notification prompt
+* [CB-2846] SplashScreen crashes app when image not available
+* [CB-2789] Remove CaptureOptions.mode support.
+* [CB-3295] Send InAppBrowser loadstart events when redirects occur
+* [CB-2896] added ImageIO and OpenAL system frameworks to support new exif functionality in CDVCamera
+* [CB-2896] writing data to object through CGImageDestinationRef, enables multipart exif tag writing
+* [CB-2958] simple fix, moved write to photealbum code and sourced from modified data. Photo data returned by cordova will match photo on cameraroll
+* [CB-3339] add version to command line scripts
+* [CB-3377] Remove cordova/release script
+* [CB-2974] Add a ./cordova/lib/list-devices project-level helper script to iOS
+* [CB-2951] Add a ./cordova/lib/list-emulator-images project-level helper script to iOS
+* [CB-2974] Add a ./cordova/lib/list-devices project-level helper script to iOS
+* [CB-2966] Add a ./cordova/lib/list-started-emulators as project-level helper script to iOS
+* [CB-2990] Add a ./cordova/lib/install-device project-level helper script to iOS
+* [CB-2982] Add a ./cordova/lib/install-emulator project-level helper script to iOS
+* [CB-2998] Add a ./cordova/lib/start-emulator project-level helper script to iOS
+* [CB-2916] Add a ./cordova/clean project-level script for iOS
+* [CB-2053] Update UIImagePickerController label to reflect video media type in CDVCamera
+
+<br />
### 2.7.0 (201304XX) ###
[30/36] ios commit: removed splashscreen
Posted by st...@apache.org.
removed splashscreen
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/00c97c92
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/00c97c92
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/00c97c92
Branch: refs/heads/3.0.0
Commit: 00c97c9212bea625a823d5c53d5674d0ad435f94
Parents: 69a53dc
Author: Steven Gill <st...@gmail.com>
Authored: Tue May 21 13:03:38 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:49:10 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVSplashScreen.h | 33 ---
CordovaLib/Classes/CDVSplashScreen.m | 230 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 -
CordovaLib/cordova.js | 36 +--
bin/templates/project/__TESTING__/config.xml | 3 -
6 files changed, 8 insertions(+), 303 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/00c97c92/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 50fe28d..e9c8e16 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -37,7 +37,6 @@
#import "CDVPluginResult.h"
#import "CDVReachability.h"
#import "CDVSound.h"
-#import "CDVSplashScreen.h"
#import "CDVWhitelist.h"
#import "CDVLocalStorage.h"
#import "CDVScreenOrientationDelegate.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/00c97c92/CordovaLib/Classes/CDVSplashScreen.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.h b/CordovaLib/Classes/CDVSplashScreen.h
deleted file mode 100644
index 704ab43..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/00c97c92/CordovaLib/Classes/CDVSplashScreen.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.m b/CordovaLib/Classes/CDVSplashScreen.m
deleted file mode 100644
index fdb79fa..0000000
--- a/CordovaLib/Classes/CDVSplashScreen.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 "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];
- 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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/00c97c92/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index da4e2f0..4cd9dd9 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -23,8 +23,6 @@
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, ); }; };
@@ -101,8 +99,6 @@
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>"; };
@@ -264,8 +260,6 @@
30C684931407044A004C1A8E /* CDVURLProtocol.m */,
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */,
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
- 30B39EBC13D0268B0009682A /* CDVSplashScreen.h */,
- 30B39EBD13D0268B0009682A /* CDVSplashScreen.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
30E33AF113A7E24B00594D64 /* CDVPlugin.m */,
307A8F9C1385A2EC00E43782 /* CDVConnection.h */,
@@ -362,7 +356,6 @@
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 */,
30C684801406CB38004C1A8E /* CDVWhitelist.h in Headers */,
30C684941407044B004C1A8E /* CDVURLProtocol.h in Headers */,
@@ -456,7 +449,6 @@
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 */,
30C684821406CB38004C1A8E /* CDVWhitelist.m in Sources */,
30C684961407044B004C1A8E /* CDVURLProtocol.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/00c97c92/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index eb17a61..d4a7758 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,6 +1,7 @@
// Platform: ios
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.8.0-0-g6208c95
=======
// 2.7.0rc1-80-geda98d1
@@ -8,6 +9,9 @@
=======
// 2.7.0rc1-81-gc09114e
>>>>>>> removed battery code
+=======
+// 2.7.0rc1-82-g32587e6
+>>>>>>> removed splashscreen
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -29,6 +33,7 @@
;(function() {
<<<<<<< HEAD
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-80-geda98d1';
@@ -36,6 +41,9 @@ var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-80-geda98d1';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-81-gc09114e';
>>>>>>> removed battery code
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-82-g32587e6';
+>>>>>>> removed splashscreen
// file: lib/scripts/require.js
var require,
@@ -5844,34 +5852,6 @@ module.exports = function(uri, successCallback, errorCallback) {
});
-// 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) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/00c97c92/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index dbe25bb..832ef9e 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -77,9 +77,6 @@
<feature name="Capture">
<param name="ios-package" value="CDVCapture"/>
</feature>
- <feature name="SplashScreen">
- <param name="ios-package" value="CDVSplashScreen"/>
- </feature>
<feature name="Echo">
<param name="ios-package" value="CDVEcho"/>
</feature>
[15/36] ios commit: [CB-2200] Remove device.name (deprecated)
Posted by st...@apache.org.
[CB-2200] Remove device.name (deprecated)
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/6caaa626
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/6caaa626
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/6caaa626
Branch: refs/heads/3.0.0
Commit: 6caaa6267bdc6959b34c984610b51df46b663e2f
Parents: e18d69a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed May 29 10:52:44 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed May 29 10:52:44 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVDevice.m | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6caaa626/CordovaLib/Classes/CDVDevice.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVDevice.m b/CordovaLib/Classes/CDVDevice.m
index cc7ad89..a331b81 100644
--- a/CordovaLib/Classes/CDVDevice.m
+++ b/CordovaLib/Classes/CDVDevice.m
@@ -75,7 +75,6 @@
[devProps setObject:@"iOS" forKey:@"platform"];
[devProps setObject:[device systemVersion] forKey:@"version"];
[devProps setObject:[device uniqueAppInstanceIdentifier] forKey:@"uuid"];
- [devProps setObject:[device model] forKey:@"name"];
[devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"];
NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
[04/36] ios commit: [CB-3469] Add a version macro for 2.8.0.
Posted by st...@apache.org.
[CB-3469] Add a version macro for 2.8.0.
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/8b182105
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/8b182105
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/8b182105
Branch: refs/heads/3.0.0
Commit: 8b1821055b9d88e18cf02e0a040763775ef0366b
Parents: 4c63589
Author: Andrew Grieve <ag...@chromium.org>
Authored: Fri May 24 15:50:37 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri May 24 15:51:20 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVAvailability.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/8b182105/CordovaLib/Classes/CDVAvailability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAvailability.h b/CordovaLib/Classes/CDVAvailability.h
index b288522..324237d 100644
--- a/CordovaLib/Classes/CDVAvailability.h
+++ b/CordovaLib/Classes/CDVAvailability.h
@@ -41,6 +41,7 @@
#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_NA 99999 /* not available */
/*
@@ -51,7 +52,7 @@
#endif
*/
#ifndef CORDOVA_VERSION_MIN_REQUIRED
- #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_7_0
+ #define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_2_8_0
#endif
/*
[36/36] ios commit: updated js
Posted by st...@apache.org.
updated js
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/882b06cd
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/882b06cd
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/882b06cd
Branch: refs/heads/3.0.0
Commit: 882b06cd3d2a4f881a5de0d8192425e8798d0bc8
Parents: 3efb25b
Author: Steven Gill <st...@gmail.com>
Authored: Mon Jun 10 17:50:24 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:50:24 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 289 ++++++++++++++++++++++++++++++++++++++-------
1 file changed, 246 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/882b06cd/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 706ce47..22dd433 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,21 +1,5 @@
// Platform: ios
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-// 2.8.0-0-g6208c95
-=======
-// 2.7.0rc1-80-geda98d1
->>>>>>> removed InAppBrowser
-=======
-// 2.7.0rc1-81-gc09114e
->>>>>>> removed battery code
-=======
-// 2.7.0rc1-82-g32587e6
->>>>>>> removed splashscreen
-=======
-// 2.7.0rc1-84-gdba3744
->>>>>>> removed camera code
+// 2.7.0rc1-84-g62c5786
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -35,23 +19,7 @@
under the License.
*/
;(function() {
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-<<<<<<< HEAD
-var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-80-geda98d1';
->>>>>>> removed InAppBrowser
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-81-gc09114e';
->>>>>>> removed battery code
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-82-g32587e6';
->>>>>>> removed splashscreen
-=======
-var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-gdba3744';
->>>>>>> removed camera code
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-84-g62c5786';
// file: lib/scripts/require.js
var require,
@@ -1177,7 +1145,6 @@ module.exports = {
});
-<<<<<<< HEAD
// file: lib/common/plugin/Acceleration.js
define("cordova/plugin/Acceleration", function(require, exports, module) {
@@ -1329,8 +1296,6 @@ module.exports = CameraPopoverOptions;
});
-=======
->>>>>>> removed camera code
// file: lib/common/plugin/CaptureAudioOptions.js
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
@@ -3310,6 +3275,85 @@ 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) {
@@ -3722,8 +3766,6 @@ module.exports = ProgressEvent;
});
-<<<<<<< HEAD
-<<<<<<< HEAD
// file: lib/common/plugin/accelerometer.js
define("cordova/plugin/accelerometer", function(require, exports, module) {
@@ -3984,8 +4026,6 @@ modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
});
-=======
->>>>>>> removed battery code
// file: lib/common/plugin/camera/symbols.js
define("cordova/plugin/camera/symbols", function(require, exports, module) {
@@ -3998,8 +4038,6 @@ modulemapper.defaults('cordova/plugin/CameraPopoverOptions', 'CameraPopoverOptio
});
-=======
->>>>>>> removed camera code
// file: lib/common/plugin/capture.js
define("cordova/plugin/capture", function(require, exports, module) {
@@ -5196,6 +5234,16 @@ 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) {
@@ -5336,6 +5384,19 @@ 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) {
@@ -5771,6 +5832,120 @@ 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) {
@@ -5866,6 +6041,34 @@ module.exports = function(uri, successCallback, errorCallback) {
});
+// 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) {
[11/36] ios commit: [CB-3458] remove all_load dependency. Use force
load instead
Posted by st...@apache.org.
[CB-3458] remove all_load dependency. Use force load instead
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/46702460
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/46702460
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/46702460
Branch: refs/heads/3.0.0
Commit: 46702460b5d17fe824e20a45f84cf85f4215d52d
Parents: c6f22ff
Author: Song Zheng <co...@gmail.com>
Authored: Fri May 24 12:47:04 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 28 13:59:27 2013 -0700
----------------------------------------------------------------------
.../project/__TESTING__.xcodeproj/project.pbxproj | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/46702460/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
index bb0ec86..885089f 100755
--- a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
+++ b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
@@ -544,8 +544,9 @@
"-weak_framework",
CoreMedia,
"-weak-lSystem",
- "-all_load",
- "-ObjC",
+ "-force_load",
+ "${TARGET_BUILD_DIR}/libCordova.a",
+ "-Obj-C",
);
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
@@ -584,8 +585,9 @@
"-weak_framework",
CoreMedia,
"-weak-lSystem",
- "-all_load",
- "-ObjC",
+ "-force_load",
+ "${TARGET_BUILD_DIR}/libCordova.a",
+ "-Obj-C",
);
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
[17/36] ios commit: [CB-3530] PhoneGap app crashes on iOS with error
"CDVWebViewDelegate: Navigation started when state=1"
Posted by st...@apache.org.
[CB-3530] PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/e7fbca99
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/e7fbca99
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/e7fbca99
Branch: refs/heads/3.0.0
Commit: e7fbca99e3e38586f68771bfc2a09f5ee420dd67
Parents: dad3425
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri May 31 15:45:44 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Fri May 31 15:45:44 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVWebViewDelegate.m | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e7fbca99/CordovaLib/Classes/CDVWebViewDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVWebViewDelegate.m b/CordovaLib/Classes/CDVWebViewDelegate.m
index fd9c032..1ee7aea 100644
--- a/CordovaLib/Classes/CDVWebViewDelegate.m
+++ b/CordovaLib/Classes/CDVWebViewDelegate.m
@@ -193,11 +193,16 @@ typedef enum {
break;
default:
- NSLog(@"CDVWebViewDelegate: Navigation started when state=%d", _state);
- _loadCount = 0;
- _state = STATE_WAITING_FOR_LOAD_START;
- if ([_delegate respondsToSelector:@selector(webView:didFailLoadWithError:)]) {
- [_delegate webView:webView didFailLoadWithError:nil];
+ {
+ NSString* description = [NSString stringWithFormat:@"CDVWebViewDelegate: Navigation started when state=%d", _state];
+ NSLog(@"%@", description);
+ _loadCount = 0;
+ _state = STATE_WAITING_FOR_LOAD_START;
+ 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 {
[19/36] ios commit: Added/renamed CDVExifTests to project.
Posted by st...@apache.org.
Added/renamed CDVExifTests to project.
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/0561c6ba
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/0561c6ba
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/0561c6ba
Branch: refs/heads/3.0.0
Commit: 0561c6ba8bf4eaaa0086d6dea27bb37b3150974b
Parents: 2ad214a
Author: Shazron Abdullah <sh...@apache.org>
Authored: Mon Jun 3 14:57:14 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Jun 3 14:57:14 2013 -0700
----------------------------------------------------------------------
CordovaLibTests/CDVExifTests.h | 38 ++++
CordovaLibTests/CDVExifTests.m | 171 ++++++++++++++++++
.../CordovaTests.xcodeproj/project.pbxproj | 6 +
CordovaLibTests/ExifTests.h | 38 ----
CordovaLibTests/ExifTests.m | 172 -------------------
5 files changed, 215 insertions(+), 210 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0561c6ba/CordovaLibTests/CDVExifTests.h
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CDVExifTests.h b/CordovaLibTests/CDVExifTests.h
new file mode 100644
index 0000000..2f41c4c
--- /dev/null
+++ b/CordovaLibTests/CDVExifTests.h
@@ -0,0 +1,38 @@
+/*
+ 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 <SenTestingKit/SenTestingKit.h>
+
+#import <Cordova/CDVJpegHeaderWriter.h>
+
+#define ARC4RANDOM_MAX 0x100000000
+
+@interface CDVExifTests : SenTestCase {
+ CDVJpegHeaderWriter* testHeaderWriter;
+ NSNumber* testErrorThreshhold;
+}
+
+- (void)testContinuedFractionWithUInt;
+- (void)testContinuedFractionWithUFloat;
+- (void)testContinuedFractionsWorstCase;
+- (void)testFormatHexFromDecimal;
+- (void)testFormatNumberWithLeadingZeroes;
+- (void)testUnsignedRationalToString;
+- (void)testSignedRationalToString;
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0561c6ba/CordovaLibTests/CDVExifTests.m
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CDVExifTests.m b/CordovaLibTests/CDVExifTests.m
new file mode 100644
index 0000000..aa456c8
--- /dev/null
+++ b/CordovaLibTests/CDVExifTests.m
@@ -0,0 +1,171 @@
+/*
+ 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 <SenTestingKit/SenTestingKit.h>
+
+#import "CDVExifTests.h"
+
+@implementation CDVExifTests
+
+- (void)setUp
+{
+ [super setUp];
+ testHeaderWriter = [[CDVJpegHeaderWriter alloc] init];
+ testErrorThreshhold = [NSNumber numberWithDouble:0.000001];
+ NSLog(@"%x", ~10 + 1);
+}
+
+- (void)tearDown
+{
+ // Tear-down code here.
+
+ [super tearDown];
+}
+
+// ==================================================================================================
+// rational approximation of decimal by continued fraction tests
+// ==================================================================================================
+
+// tests continued fraction with random int
+- (void)testContinuedFractionWithUInt
+{
+ NSLog(@"Continued Fraction Test with random int value, numerator should be generated value, denominator should be 1");
+ NSNumber* numerator = @0;
+ NSNumber* denominator = @0;
+ NSNumber* testValue = [NSNumber numberWithInt:abs(arc4random())];
+ [testHeaderWriter decimalToUnsignedRational:testValue
+ withResultNumerator:&numerator
+ withResultDenominator:&denominator];
+ STAssertEquals([numerator intValue],
+ [testValue intValue],
+ @"Numerator did not match");
+ STAssertEquals([denominator intValue],
+ 1,
+ @"denominator was not one");
+}
+
+// tests continued fraction with random float
+- (void)testContinuedFractionWithUFloat
+{
+ NSLog(@"Continued Fraction Test with random double value, resulting fraction should be within acceptable error threshhold");
+ NSNumber* threshhold = @0.1;
+ NSNumber* numerator = @0;
+ NSNumber* denominator = @0;
+ NSLog(@"%f", ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f);
+ NSNumber* testValue = [NSNumber numberWithDouble:
+ ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f];
+
+ [testHeaderWriter decimalToUnsignedRational:testValue
+ withResultNumerator:&numerator
+ withResultDenominator:&denominator];
+ NSLog(@"%lf, %lf", [testValue doubleValue], [numerator doubleValue] / [denominator doubleValue]);
+
+ STAssertEqualsWithAccuracy([testValue doubleValue],
+ [numerator doubleValue] / [denominator doubleValue],
+ [threshhold doubleValue],
+ @"rational approximation did not meet acceptable error threshhold");
+}
+
+// tests continued fraction in sqrt(2) worst case
+- (void)testContinuedFractionsWorstCase
+{
+ NSLog(@"Continued Fraction Test with provable worst case ~sqrt(2), resulting fraction should be within acceptable error threshhold");
+ NSNumber* threshhold = @0.1;
+ NSNumber* numerator = @0;
+ NSNumber* denominator = @0;
+ NSNumber* testValue = [NSNumber numberWithDouble:sqrt(2)];
+ [testHeaderWriter decimalToUnsignedRational:testValue
+ withResultNumerator:&numerator
+ withResultDenominator:&denominator];
+ STAssertEqualsWithAccuracy([testValue doubleValue],
+ [numerator doubleValue] / [denominator doubleValue],
+ [threshhold doubleValue],
+ @"rational approximation did not meet acceptable error threshhold");
+}
+
+// tests format hex from a decimal
+- (void)testFormatHexFromDecimal
+{
+ NSNumber* testValue = @1;
+ NSNumber* testPlaces = @8;
+ NSString* result = nil;
+
+ result = [testHeaderWriter formattedHexStringFromDecimalNumber:testValue
+ withPlaces:testPlaces];
+ // assert not nil
+ STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
+ // assert correct number of places
+ STAssertEquals([result length], [testPlaces unsignedIntegerValue],
+ @"returned string to wrong number of places. Should be = %i Was = %i",
+ [testPlaces intValue],
+ [result length]);
+ // assert correct hex representation
+ STAssertTrueNoThrow([result isEqualToString:@"00000001"], @"result should be equal to @00000001");
+}
+
+// tests format number string with leading zeroes
+- (void)testFormatNumberWithLeadingZeroes
+{
+ NSString* result = nil;
+ NSNumber* testValue = @8769; // Exif SubIFD Offset Tag
+ NSNumber* testPlaces = @6;
+
+ result = [testHeaderWriter formatNumberWithLeadingZeroes:testValue
+ withPlaces:testPlaces];
+ STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
+ STAssertEquals([result length],
+ [testPlaces unsignedIntegerValue],
+ @"returned string to wrong number of places. Should be = %i Was = %i",
+ [testPlaces intValue],
+ [result length]);
+ // assert correct hex representation
+ STAssertTrueNoThrow([result isEqualToString:@"008769"], @"result was = %@ should be = @008769", result);
+}
+
+- (void)testUnsignedRationalToString
+{
+ NSString* result = nil;
+ NSNumber* numerator = @1;
+ NSNumber* denominator = @10;
+
+ result = [testHeaderWriter formatRationalWithNumerator:numerator
+ withDenominator:denominator
+ asSigned:FALSE];
+ NSLog(@"%@", result);
+ STAssertNotNil(result, @"nil returned from testUnsignedRationalToString");
+ STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
+ STAssertTrueNoThrow([result isEqualToString:@"000000010000000a"], @"result was = %@ should be = @0000000100000010", result);
+}
+
+- (void)testSignedRationalToString
+{
+ NSString* result = nil;
+ NSNumber* numerator = @ - 1;
+ NSNumber* denominator = @ - 10;
+
+ result = [testHeaderWriter formatRationalWithNumerator:numerator
+ withDenominator:denominator
+ asSigned:TRUE];
+ NSLog(@"%@", result);
+ STAssertNotNil(result, @"nil returned from testSignedRationalToString");
+ STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
+ STAssertTrueNoThrow([result isEqualToString:@"fffffffffffffff6"], @"result was = %@ should be = @000000FF000000F6", result);
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0561c6ba/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj b/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
index 220d189..3ac6c85 100644
--- a/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
+++ b/CordovaLibTests/CordovaTests.xcodeproj/project.pbxproj
@@ -42,6 +42,7 @@
68A32D7D141030E4006B237C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 686357AE141002F100DF4CF2 /* CoreGraphics.framework */; };
68A32D7E141030EB006B237C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 686357AA141002F100DF4CF2 /* UIKit.framework */; };
68A32D7F141030F3006B237C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 686357AC141002F100DF4CF2 /* Foundation.framework */; };
+ 7E13A295175D487B00E522AB /* CDVExifTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E13A294175D487B00E522AB /* CDVExifTests.m */; };
8220B5C216D541BD00EC3921 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8220B5C116D541BD00EC3921 /* AssetsLibrary.framework */; };
8220B5C616D542F500EC3921 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8220B5C116D541BD00EC3921 /* AssetsLibrary.framework */; };
EB3B34E9161B5532003DBE7D /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EB3B34E6161B5454003DBE7D /* libCordova.a */; };
@@ -107,6 +108,8 @@
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; };
68A32D7414103017006B237C /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
+ 7E13A293175D487B00E522AB /* CDVExifTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVExifTests.h; sourceTree = "<group>"; };
+ 7E13A294175D487B00E522AB /* CDVExifTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVExifTests.m; sourceTree = "<group>"; };
8220B5C116D541BD00EC3921 /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
EB37018115D18B2D00BEBC43 /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = ../CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; };
EB89634915FE66EA00E12277 /* CDVInvokedUrlCommandTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVInvokedUrlCommandTests.m; sourceTree = "<group>"; };
@@ -247,6 +250,8 @@
EB3B34F4161B585D003DBE7D /* CordovaLibTests */ = {
isa = PBXGroup;
children = (
+ 7E13A293175D487B00E522AB /* CDVExifTests.h */,
+ 7E13A294175D487B00E522AB /* CDVExifTests.m */,
EB96677116ADBCF500D86CDF /* CDVUserAgentTest.m */,
EBA3554415A731F100F4DE24 /* CDVFakeFileManager.h */,
EBA3554515A731F100F4DE24 /* CDVFakeFileManager.m */,
@@ -429,6 +434,7 @@
EBA3556F15ABD0C900F4DE24 /* CDVFileTransferTests.m in Sources */,
EB89634A15FE66EA00E12277 /* CDVInvokedUrlCommandTests.m in Sources */,
EB96677216ADBCF500D86CDF /* CDVUserAgentTest.m in Sources */,
+ 7E13A295175D487B00E522AB /* CDVExifTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0561c6ba/CordovaLibTests/ExifTests.h
----------------------------------------------------------------------
diff --git a/CordovaLibTests/ExifTests.h b/CordovaLibTests/ExifTests.h
deleted file mode 100644
index 45e17c4..0000000
--- a/CordovaLibTests/ExifTests.h
+++ /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 <SenTestingKit/SenTestingKit.h>
-
-#import "../ExifTest/CDVJpegHeaderWriter.h"
-
-#define ARC4RANDOM_MAX 0x100000000
-
-@interface ExifTestTests : SenTestCase {
- CDVJpegHeaderWriter* testHeaderWriter;
- NSNumber* testErrorThreshhold;
-}
-
-- (void)testContinuedFractionWithUInt;
-- (void)testContinuedFractionWithUFloat;
-- (void)testContinuedFractionsWorstCase;
-- (void)testFormatHexFromDecimal;
-- (void)testFormatNumberWithLeadingZeroes;
-- (void)testUnsignedRationalToString;
-- (void)testSignedRationalToString;
-@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0561c6ba/CordovaLibTests/ExifTests.m
----------------------------------------------------------------------
diff --git a/CordovaLibTests/ExifTests.m b/CordovaLibTests/ExifTests.m
deleted file mode 100644
index dfd6da4..0000000
--- a/CordovaLibTests/ExifTests.m
+++ /dev/null
@@ -1,172 +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 <SenTestingKit/SenTestingKit.h>
-
-#import "ExifTestTests.h"
-#import "../ExifTest/CDVJpegHeaderWriter.m"
-
-@implementation ExifTestTests
-
-- (void)setUp
-{
- [super setUp];
- testHeaderWriter = [[CDVJpegHeaderWriter alloc] init];
- testErrorThreshhold = [NSNumber numberWithDouble:0.000001];
- NSLog(@"%x", ~10 + 1);
-}
-
-- (void)tearDown
-{
- // Tear-down code here.
-
- [super tearDown];
-}
-
-// ==================================================================================================
-// rational approximation of decimal by continued fraction tests
-// ==================================================================================================
-
-// tests continued fraction with random int
-- (void)testContinuedFractionWithUInt
-{
- NSLog(@"Continued Fraction Test with random int value, numerator should be generated value, denominator should be 1");
- NSNumber* numerator = @0;
- NSNumber* denominator = @0;
- NSNumber* testValue = [NSNumber numberWithInt:abs(arc4random())];
- [testHeaderWriter decimalToUnsignedRational:testValue
- withResultNumerator:&numerator
- withResultDenominator:&denominator];
- STAssertEquals([numerator intValue],
- [testValue intValue],
- @"Numerator did not match");
- STAssertEquals([denominator intValue],
- 1,
- @"denominator was not one");
-}
-
-// tests continued fraction with random float
-- (void)testContinuedFractionWithUFloat
-{
- NSLog(@"Continued Fraction Test with random double value, resulting fraction should be within acceptable error threshhold");
- NSNumber* threshhold = @0.1;
- NSNumber* numerator = @0;
- NSNumber* denominator = @0;
- NSLog(@"%f", ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f);
- NSNumber* testValue = [NSNumber numberWithDouble:
- ((double)arc4random() / ARC4RANDOM_MAX) * 100.0f];
-
- [testHeaderWriter decimalToUnsignedRational:testValue
- withResultNumerator:&numerator
- withResultDenominator:&denominator];
- NSLog(@"%lf, %lf", [testValue doubleValue], [numerator doubleValue] / [denominator doubleValue]);
-
- STAssertEqualsWithAccuracy([testValue doubleValue],
- [numerator doubleValue] / [denominator doubleValue],
- [threshhold doubleValue],
- @"rational approximation did not meet acceptable error threshhold");
-}
-
-// tests continued fraction in sqrt(2) worst case
-- (void)testContinuedFractionsWorstCase
-{
- NSLog(@"Continued Fraction Test with provable worst case ~sqrt(2), resulting fraction should be within acceptable error threshhold");
- NSNumber* threshhold = @0.1;
- NSNumber* numerator = @0;
- NSNumber* denominator = @0;
- NSNumber* testValue = [NSNumber numberWithDouble:sqrt(2)];
- [testHeaderWriter decimalToUnsignedRational:testValue
- withResultNumerator:&numerator
- withResultDenominator:&denominator];
- STAssertEqualsWithAccuracy([testValue doubleValue],
- [numerator doubleValue] / [denominator doubleValue],
- [threshhold doubleValue],
- @"rational approximation did not meet acceptable error threshhold");
-}
-
-// tests format hex from a decimal
-- (void)testFormatHexFromDecimal
-{
- NSNumber* testValue = @1;
- NSNumber* testPlaces = @8;
- NSString* result = nil;
-
- result = [testHeaderWriter formattedHexStringFromDecimalNumber:testValue
- withPlaces:testPlaces];
- // assert not nil
- STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
- // assert correct number of places
- STAssertEquals([result length], [testPlaces unsignedIntegerValue],
- @"returned string to wrong number of places. Should be = %i Was = %i",
- [testPlaces intValue],
- [result length]);
- // assert correct hex representation
- STAssertTrueNoThrow([result isEqualToString:@"00000001"], @"result should be equal to @00000001");
-}
-
-// tests format number string with leading zeroes
-- (void)testFormatNumberWithLeadingZeroes
-{
- NSString* result = nil;
- NSNumber* testValue = @8769; // Exif SubIFD Offset Tag
- NSNumber* testPlaces = @6;
-
- result = [testHeaderWriter formatNumberWithLeadingZeroes:testValue
- withPlaces:testPlaces];
- STAssertNotNil(result, @"nil renturned from formattedHexStringFromDecimalNumber");
- STAssertEquals([result length],
- [testPlaces unsignedIntegerValue],
- @"returned string to wrong number of places. Should be = %i Was = %i",
- [testPlaces intValue],
- [result length]);
- // assert correct hex representation
- STAssertTrueNoThrow([result isEqualToString:@"008769"], @"result was = %@ should be = @008769", result);
-}
-
-- (void)testUnsignedRationalToString
-{
- NSString* result = nil;
- NSNumber* numerator = @1;
- NSNumber* denominator = @10;
-
- result = [testHeaderWriter formatRationalWithNumerator:numerator
- withDenominator:denominator
- asSigned:FALSE];
- NSLog(result);
- STAssertNotNil(result, @"nil returned from testUnsignedRationalToString");
- STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
- STAssertTrueNoThrow([result isEqualToString:@"000000010000000a"], @"result was = %@ should be = @0000000100000010", result);
-}
-
-- (void)testSignedRationalToString
-{
- NSString* result = nil;
- NSNumber* numerator = @ - 1;
- NSNumber* denominator = @ - 10;
-
- result = [testHeaderWriter formatRationalWithNumerator:numerator
- withDenominator:denominator
- asSigned:TRUE];
- NSLog(result);
- STAssertNotNil(result, @"nil returned from testSignedRationalToString");
- STAssertTrueNoThrow([result length] == 16, @"returned string with wrong length. Exif rationals are 8 bytes, string has %ld bytes", [result length] / 2);
- STAssertTrueNoThrow([result isEqualToString:@"fffffffffffffff6"], @"result was = %@ should be = @000000FF000000F6", result);
-}
-
-@end
[24/36] ios commit: removed CDVLocation Plugin
Posted by st...@apache.org.
removed CDVLocation Plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f3b05c32
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f3b05c32
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f3b05c32
Branch: refs/heads/3.0.0
Commit: f3b05c32669af9e41085dd49c958190c0e3bda9b
Parents: 1ed4457
Author: Steven Gill <st...@gmail.com>
Authored: Fri May 10 18:25:23 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:32:27 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVLocation.h | 104 ----
CordovaLib/Classes/CDVLocation.m | 623 -------------------
CordovaLib/Classes/CDVViewController.m | 9 -
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 -
5 files changed, 745 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f3b05c32/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 593e9b5..b559f2d 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -35,7 +35,6 @@
#import "CDVDevice.h"
#import "CDVFile.h"
#import "CDVFileTransfer.h"
-#import "CDVLocation.h"
#import "CDVNotification.h"
#import "CDVPluginResult.h"
#import "CDVReachability.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f3b05c32/CordovaLib/Classes/CDVLocation.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.h b/CordovaLib/Classes/CDVLocation.h
deleted file mode 100644
index caf0798..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f3b05c32/CordovaLib/Classes/CDVLocation.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.m b/CordovaLib/Classes/CDVLocation.m
deleted file mode 100644
index ed9ec26..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f3b05c32/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 94f4552..5bd347f 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -276,15 +276,6 @@
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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f3b05c32/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 60b3547..513bc2f 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -61,8 +61,6 @@
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, ); }; };
@@ -160,8 +158,6 @@
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>"; };
@@ -309,8 +305,6 @@
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
C937A4541337599E002C4C79 /* CDVFileTransfer.h */,
C937A4551337599E002C4C79 /* CDVFileTransfer.m */,
- 8887FD461090FBE7009987E8 /* CDVLocation.h */,
- 8887FD471090FBE7009987E8 /* CDVLocation.m */,
8887FD4E1090FBE7009987E8 /* CDVNotification.h */,
8887FD4F1090FBE7009987E8 /* CDVNotification.m */,
8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
@@ -376,7 +370,6 @@
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 */,
@@ -475,7 +468,6 @@
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 */,
[18/36] ios commit: Updated RELEASENOTES for 2.8.0 final
Posted by st...@apache.org.
Updated RELEASENOTES for 2.8.0 final
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/2ad214ab
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/2ad214ab
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/2ad214ab
Branch: refs/heads/3.0.0
Commit: 2ad214abf2ce471b38c88995f4ee83120cbe9a90
Parents: e7fbca9
Author: Shazron Abdullah <sh...@apache.org>
Authored: Mon Jun 3 12:05:11 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Jun 3 12:05:11 2013 -0700
----------------------------------------------------------------------
RELEASENOTES.md | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2ad214ab/RELEASENOTES.md
----------------------------------------------------------------------
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 72a48c6..9c50659 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -54,6 +54,7 @@ Cordova is a static library that enables developers to include the Cordova API i
* [CB-2998] Add a ./cordova/lib/start-emulator project-level helper script to iOS
* [CB-2916] Add a ./cordova/clean project-level script for iOS
* [CB-2053] Update UIImagePickerController label to reflect video media type in CDVCamera
+* [CB-3530] PhoneGap app crashes on iOS with error "CDVWebViewDelegate: Navigation started when state=1"
<br />
[27/36] ios commit: removed notification code
Posted by st...@apache.org.
removed notification code
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/6188b0ff
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/6188b0ff
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/6188b0ff
Branch: refs/heads/3.0.0
Commit: 6188b0ff6f4a13a814b63f1e29e0f08752f3eea4
Parents: 0ecd899
Author: Steven Gill <st...@gmail.com>
Authored: Thu May 16 14:28:43 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:36:26 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVContacts.m | 1 -
CordovaLib/Classes/CDVNotification.h | 37 ------
CordovaLib/Classes/CDVNotification.m | 130 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 --
CordovaLib/cordova.js | 127 ------------------
bin/templates/project/__TESTING__/config.xml | 3 -
7 files changed, 307 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6188b0ff/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index b559f2d..49342be 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -35,7 +35,6 @@
#import "CDVDevice.h"
#import "CDVFile.h"
#import "CDVFileTransfer.h"
-#import "CDVNotification.h"
#import "CDVPluginResult.h"
#import "CDVReachability.h"
#import "CDVSound.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6188b0ff/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
index 6cb9f08..40c038e 100644
--- a/CordovaLib/Classes/CDVContacts.m
+++ b/CordovaLib/Classes/CDVContacts.m
@@ -21,7 +21,6 @@
#import <UIKit/UIKit.h>
#import "NSArray+Comparisons.h"
#import "NSDictionary+Extensions.h"
-#import "CDVNotification.h"
@implementation CDVContactsPicker
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6188b0ff/CordovaLib/Classes/CDVNotification.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.h b/CordovaLib/Classes/CDVNotification.h
deleted file mode 100644
index 5b5b89f..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6188b0ff/CordovaLib/Classes/CDVNotification.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.m b/CordovaLib/Classes/CDVNotification.m
deleted file mode 100644
index 464eb1f..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6188b0ff/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 513bc2f..0c2715c 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -61,8 +61,6 @@
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 */; };
- 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, ); }; };
@@ -158,8 +156,6 @@
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>"; };
- 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>"; };
@@ -305,8 +301,6 @@
8887FD351090FBE7009987E8 /* CDVInvokedUrlCommand.m */,
C937A4541337599E002C4C79 /* CDVFileTransfer.h */,
C937A4551337599E002C4C79 /* CDVFileTransfer.m */,
- 8887FD4E1090FBE7009987E8 /* CDVNotification.h */,
- 8887FD4F1090FBE7009987E8 /* CDVNotification.m */,
8887FD5E1090FBE7009987E8 /* CDVReachability.h */,
8887FD5F1090FBE7009987E8 /* CDVReachability.m */,
8887FD601090FBE7009987E8 /* CDVSound.h */,
@@ -370,7 +364,6 @@
8887FD6A1090FBE7009987E8 /* CDVContacts.h in Headers */,
8887FD701090FBE7009987E8 /* CDVFile.h in Headers */,
8887FD741090FBE7009987E8 /* CDVInvokedUrlCommand.h in Headers */,
- 8887FD8D1090FBE7009987E8 /* CDVNotification.h in Headers */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
@@ -468,7 +461,6 @@
8887FD6B1090FBE7009987E8 /* CDVContacts.m in Sources */,
8887FD711090FBE7009987E8 /* CDVFile.m in Sources */,
8887FD751090FBE7009987E8 /* CDVInvokedUrlCommand.m in Sources */,
- 8887FD8E1090FBE7009987E8 /* CDVNotification.m in Sources */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6188b0ff/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 0dc412a..e5c56d1 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -5381,19 +5381,6 @@ 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) {
@@ -5829,120 +5816,6 @@ 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) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/6188b0ff/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 6c42a3b..470e656 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -71,9 +71,6 @@
<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>
[22/36] ios commit: Updated cordova.js to 2.8.0 final
Posted by st...@apache.org.
Updated cordova.js to 2.8.0 final
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/835abd8f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/835abd8f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/835abd8f
Branch: refs/heads/3.0.0
Commit: 835abd8fe569efdfb8b7eab62d56a317ba2eaa0f
Parents: fde980a
Author: Shazron Abdullah <sh...@apache.org>
Authored: Thu Jun 6 16:59:44 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Thu Jun 6 16:59:44 2013 -0700
----------------------------------------------------------------------
CordovaLib/cordova.js | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/835abd8f/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index f48d6f9..0dc412a 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,5 +1,5 @@
// Platform: ios
-// 2.8.0rc1-0-g22bc4d8
+// 2.8.0-0-g6208c95
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '2.8.0rc1-0-g22bc4d8';
+var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
// file: lib/scripts/require.js
var require,
@@ -2383,11 +2383,7 @@ function initRead(reader, file) {
reader._error = null;
reader._readyState = FileReader.LOADING;
- if (typeof file == 'string') {
- // Deprecated in Cordova 2.4.
- console.warn('Using a string argument with FileReader.readAs functions is deprecated.');
- reader._fileName = file;
- } else if (typeof file.fullPath == 'string') {
+ if (typeof file.fullPath == 'string') {
reader._fileName = file.fullPath;
} else {
reader._fileName = '';
@@ -4502,7 +4498,6 @@ function Device() {
this.available = false;
this.platform = null;
this.version = null;
- this.name = null;
this.uuid = null;
this.cordova = null;
this.model = null;
@@ -4518,7 +4513,6 @@ function Device() {
me.available = true;
me.platform = info.platform;
me.version = info.version;
- me.name = info.name;
me.uuid = info.uuid;
me.cordova = buildLabel;
me.model = info.model;
@@ -6259,6 +6253,11 @@ 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];
[23/36] ios commit: removed cdvaccelerometer and all references
Posted by st...@apache.org.
removed cdvaccelerometer and all references
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/1ed44570
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/1ed44570
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/1ed44570
Branch: refs/heads/3.0.0
Commit: 1ed445706665d2d19ac1f444492afee4e2a28934
Parents: 835abd8
Author: Steven Gill <st...@gmail.com>
Authored: Mon Apr 29 15:28:08 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:31:05 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVAccelerometer.h | 39 ------
CordovaLib/Classes/CDVAccelerometer.m | 128 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 --
CordovaLibTests/CordovaLibApp/config.xml | 1 -
5 files changed, 177 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1ed44570/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 15d9316..593e9b5 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,7 +25,6 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVAccelerometer.h"
#import "CDVBattery.h"
#import "CDVCamera.h"
#import "CDVCapture.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1ed44570/CordovaLib/Classes/CDVAccelerometer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.h b/CordovaLib/Classes/CDVAccelerometer.h
deleted file mode 100644
index 044ca53..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1ed44570/CordovaLib/Classes/CDVAccelerometer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAccelerometer.m b/CordovaLib/Classes/CDVAccelerometer.m
deleted file mode 100644
index 33093d0..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1ed44570/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 7abb3cc..60b3547 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -71,8 +71,6 @@
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, ); }; };
@@ -172,8 +170,6 @@
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; };
@@ -294,8 +290,6 @@
307A8F9D1385A2EC00E43782 /* CDVConnection.m */,
1F92F49E1314023E0046367C /* CDVPluginResult.h */,
1F92F49F1314023E0046367C /* CDVPluginResult.m */,
- 88BA573B109BB46F00FB5E78 /* CDVAccelerometer.h */,
- 88BA573C109BB46F00FB5E78 /* CDVAccelerometer.m */,
8887FD261090FBE7009987E8 /* CDVCamera.h */,
8887FD271090FBE7009987E8 /* CDVCamera.m */,
1F584B991385A28900ED25E8 /* CDVCapture.h */,
@@ -387,7 +381,6 @@
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 */,
@@ -487,7 +480,6 @@
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 */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1ed44570/CordovaLibTests/CordovaLibApp/config.xml
----------------------------------------------------------------------
diff --git a/CordovaLibTests/CordovaLibApp/config.xml b/CordovaLibTests/CordovaLibApp/config.xml
index 136804e..62fa75e 100644
--- a/CordovaLibTests/CordovaLibApp/config.xml
+++ b/CordovaLibTests/CordovaLibApp/config.xml
@@ -52,7 +52,6 @@
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
-
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation"/>
</feature>
[29/36] ios commit: removed battery code
Posted by st...@apache.org.
removed battery code
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/69a53dc7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/69a53dc7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/69a53dc7
Branch: refs/heads/3.0.0
Commit: 69a53dc7f0a302514113baaad32726f57dd95c23
Parents: 0387748
Author: Steven Gill <st...@gmail.com>
Authored: Mon May 20 17:39:30 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:48:46 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDV.h | 1 -
CordovaLib/Classes/CDVBattery.h | 40 -----
CordovaLib/Classes/CDVBattery.m | 152 -------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 8 -
CordovaLib/cordova.js | 11 ++
bin/templates/project/__TESTING__/config.xml | 3 -
6 files changed, 11 insertions(+), 204 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/Classes/CDV.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDV.h b/CordovaLib/Classes/CDV.h
index 267ad8a..50fe28d 100644
--- a/CordovaLib/Classes/CDV.h
+++ b/CordovaLib/Classes/CDV.h
@@ -25,7 +25,6 @@
#import "CDVURLProtocol.h"
#import "CDVInvokedUrlCommand.h"
-#import "CDVBattery.h"
#import "CDVCamera.h"
#import "CDVCapture.h"
#import "CDVConnection.h"
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/Classes/CDVBattery.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.h b/CordovaLib/Classes/CDVBattery.h
deleted file mode 100644
index ba26c3a..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/Classes/CDVBattery.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVBattery.m b/CordovaLib/Classes/CDVBattery.m
deleted file mode 100644
index 681511c..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 224d8fa..da4e2f0 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,8 +7,6 @@
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, ); }; };
@@ -86,8 +84,6 @@
/* 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>"; };
@@ -268,8 +264,6 @@
30C684931407044A004C1A8E /* CDVURLProtocol.m */,
30C6847E1406CB38004C1A8E /* CDVWhitelist.h */,
30C6847F1406CB38004C1A8E /* CDVWhitelist.m */,
- 1F2BECBE13F9785B00A93BF6 /* CDVBattery.h */,
- 1F2BECBF13F9785B00A93BF6 /* CDVBattery.m */,
30B39EBC13D0268B0009682A /* CDVSplashScreen.h */,
30B39EBD13D0268B0009682A /* CDVSplashScreen.m */,
30E33AF013A7E24B00594D64 /* CDVPlugin.h */,
@@ -370,7 +364,6 @@
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 */,
@@ -465,7 +458,6 @@
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 */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index 6c42712..eb17a61 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,9 +1,13 @@
// Platform: ios
<<<<<<< HEAD
+<<<<<<< HEAD
// 2.8.0-0-g6208c95
=======
// 2.7.0rc1-80-geda98d1
>>>>>>> removed InAppBrowser
+=======
+// 2.7.0rc1-81-gc09114e
+>>>>>>> removed battery code
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -24,10 +28,14 @@
*/
;(function() {
<<<<<<< HEAD
+<<<<<<< HEAD
var CORDOVA_JS_BUILD_LABEL = '2.8.0-0-g6208c95';
=======
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-80-geda98d1';
>>>>>>> removed InAppBrowser
+=======
+var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-81-gc09114e';
+>>>>>>> removed battery code
// file: lib/scripts/require.js
var require,
@@ -3695,6 +3703,7 @@ module.exports = ProgressEvent;
});
+<<<<<<< HEAD
// file: lib/common/plugin/accelerometer.js
define("cordova/plugin/accelerometer", function(require, exports, module) {
@@ -3955,6 +3964,8 @@ modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
});
+=======
+>>>>>>> removed battery code
// file: lib/common/plugin/camera/symbols.js
define("cordova/plugin/camera/symbols", function(require, exports, module) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/69a53dc7/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 7bb5448..dbe25bb 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -77,9 +77,6 @@
<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>
[13/36] ios commit: [CB-3490] Update CordovaLib iOS Deployment Target
in Project Setting to 5.0
Posted by st...@apache.org.
[CB-3490] Update CordovaLib iOS Deployment Target in Project Setting to 5.0
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/ec682c5d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/ec682c5d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/ec682c5d
Branch: refs/heads/3.0.0
Commit: ec682c5dfee6b374e4040cabe1798abeeb937794
Parents: a49be10
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue May 28 16:22:08 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 28 16:22:08 2013 -0700
----------------------------------------------------------------------
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/ec682c5d/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index c637d60..7abb3cc 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -598,7 +598,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 4.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_CFLAGS = "-DDEBUG";
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
@@ -630,7 +630,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 4.3;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
ONLY_ACTIVE_ARCH = NO;
PUBLIC_HEADERS_FOLDER_PATH = include/Cordova;
SDKROOT = iphoneos;
[06/36] ios commit: [CB-3514] Remove partially-downloaded files when
FileTransfer fails
Posted by st...@apache.org.
[CB-3514] Remove partially-downloaded files when FileTransfer fails
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/7bc06d59
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/7bc06d59
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/7bc06d59
Branch: refs/heads/3.0.0
Commit: 7bc06d59fb30bc56b6b824c7374d2e5b7f62dda7
Parents: bd99537
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri May 24 23:34:26 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri May 24 23:41:48 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVFileTransfer.h | 1 +
CordovaLib/Classes/CDVFileTransfer.m | 28 +++++++++++++++++-----------
2 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7bc06d59/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
index 233a114..35e3fdd 100644
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ b/CordovaLib/Classes/CDVFileTransfer.h
@@ -61,6 +61,7 @@ extern NSString* const kOptionsKeyCookie;
@interface CDVFileTransferDelegate : NSObject {}
- (void)updateBytesExpected:(NSInteger)newBytesExpected;
+- (void)cancelTransfer:(NSURLConnection*)connection;
@property (strong) NSMutableData* responseData; // atomic
@property (nonatomic, strong) CDVFileTransfer* command;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/7bc06d59/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index 8391b3b..0f6b174 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -348,13 +348,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
CDVFileTransferDelegate* delegate = [activeTransfers objectForKey:objectId];
if (delegate != nil) {
- [delegate.connection cancel];
- [activeTransfers removeObjectForKey:objectId];
-
- // delete uncomplete file
- NSFileManager* fileMgr = [NSFileManager defaultManager];
- [fileMgr removeItemAtPath:delegate.target error: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];
}
@@ -570,13 +564,26 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
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);
- [connection cancel];
- [self.command.activeTransfers removeObjectForKey:self.objectId];
+ [self cancelTransfer:connection];
[self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
}
@@ -641,8 +648,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
NSLog(@"File Transfer Error: %@", [error localizedDescription]);
- // remove connection for activeTransfers
- [command.activeTransfers removeObjectForKey:objectId];
+ [self cancelTransfer:connection];
[self.command.commandDelegate sendPluginResult:result callbackId:callbackId];
}
[09/36] ios commit: [CB-3526] typo in cordova/lib/install-emulator -
does not check for ios-sim
Posted by st...@apache.org.
[CB-3526] typo in cordova/lib/install-emulator - does not check for ios-sim
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/3a887de7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/3a887de7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/3a887de7
Branch: refs/heads/3.0.0
Commit: 3a887de7b548760d7c618489200e9f3b683f73f5
Parents: ab85edc
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue May 28 13:12:34 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 28 13:12:34 2013 -0700
----------------------------------------------------------------------
bin/templates/project/cordova/lib/install-emulator | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/3a887de7/bin/templates/project/cordova/lib/install-emulator
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/install-emulator b/bin/templates/project/cordova/lib/install-emulator
index a5485cf..4fd0fbb 100755
--- a/bin/templates/project/cordova/lib/install-emulator
+++ b/bin/templates/project/cordova/lib/install-emulator
@@ -24,8 +24,6 @@
# "iPad"
# "iPad (Retina)"
-set -e
-
OPTION_RESULT=()
TARGET="iPhone (Retina 3.5-inch)"
TARGET_FLAG='--family iphone --retina'
@@ -111,7 +109,7 @@ if [ ! -d "$APP_PATH" ]; then
fi
IOS_SIM_MIN_VERSION="1.5"
-IOS_SIM_LOCATION=$(which xcodebuild)
+IOS_SIM_LOCATION=$(which ios-sim)
if [ $? != 0 ]; then
echo -e "\033[31mError: ios-sim was not found. Please download, build and install version $IOS_SIM_MIN_VERSION 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;
exit 1
[03/36] ios commit: [CB-2840] Nil checks to avoid crash when network
disconnected
Posted by st...@apache.org.
[CB-2840] Nil checks to avoid crash when network disconnected
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/4c63589a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/4c63589a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/4c63589a
Branch: refs/heads/3.0.0
Commit: 4c63589acbc1f37e8aa70c30e1a57560a496af0a
Parents: f45d4de
Author: Ian Clelland <ic...@chromium.org>
Authored: Fri May 24 13:58:27 2013 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Fri May 24 13:58:27 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVFileTransfer.m | 20 +++++++++++++++-----
iphone/beep.wav | Bin 0 -> 8114 bytes
2 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4c63589a/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index 5536715..8391b3b 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -429,8 +429,12 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:3];
[result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
- [result setObject:source forKey:@"source"];
- [result setObject:target forKey:@"target"];
+ if (source != nil) {
+ [result setObject:source forKey:@"source"];
+ }
+ if (target != nil) {
+ [result setObject:target forKey:@"target"];
+ }
NSLog(@"FileTransferError %@", result);
return result;
@@ -445,10 +449,16 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:5];
[result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
- [result setObject:source forKey:@"source"];
- [result setObject:target forKey:@"target"];
+ if (source != nil) {
+ [result setObject:source forKey:@"source"];
+ }
+ if (target != nil) {
+ [result setObject:target forKey:@"target"];
+ }
[result setObject:[NSNumber numberWithInt:httpStatus] forKey:@"http_status"];
- [result setObject:body forKey:@"body"];
+ if (body != nil) {
+ [result setObject:body forKey:@"body"];
+ }
NSLog(@"FileTransferError %@", result);
return result;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/4c63589a/iphone/beep.wav
----------------------------------------------------------------------
diff --git a/iphone/beep.wav b/iphone/beep.wav
new file mode 100644
index 0000000..05f5997
Binary files /dev/null and b/iphone/beep.wav differ
[02/36] ios commit: Update JS snapshot to version 2.8.0rc1
Posted by st...@apache.org.
Update JS snapshot to version 2.8.0rc1
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f45d4de1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f45d4de1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f45d4de1
Branch: refs/heads/3.0.0
Commit: f45d4de1129b18c6476151f268883a710feb6981
Parents: e4b0217
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu May 23 00:22:28 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu May 23 00:22:28 2013 -0400
----------------------------------------------------------------------
CordovaLib/cordova.js | 158 +++++++++++++++++++++++++++------------------
1 file changed, 96 insertions(+), 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f45d4de1/CordovaLib/cordova.js
----------------------------------------------------------------------
diff --git a/CordovaLib/cordova.js b/CordovaLib/cordova.js
index b716939..f48d6f9 100644
--- a/CordovaLib/cordova.js
+++ b/CordovaLib/cordova.js
@@ -1,9 +1,5 @@
// Platform: ios
-
-// commit cd29cf0f224ccf25e9d422a33fd02ef67d3a78f4
-
-// File generated at :: Mon Apr 29 2013 16:14:47 GMT-0700 (PDT)
-
+// 2.8.0rc1-0-g22bc4d8
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -22,26 +18,36 @@
specific language governing permissions and limitations
under the License.
*/
-
;(function() {
-
+var CORDOVA_JS_BUILD_LABEL = '2.8.0rc1-0-g22bc4d8';
// file: lib/scripts/require.js
var require,
define;
(function () {
- var modules = {};
+ var modules = {},
// Stack of moduleIds currently being built.
- var requireStack = [];
+ requireStack = [],
// Map of module ID -> index into requireStack of modules currently being built.
- var inProgressModules = {};
+ inProgressModules = {},
+ SEPERATOR = ".";
+
+
function build(module) {
- var factory = module.factory;
+ 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(require, module.exports, module);
+ factory(localRequire, module.exports, module);
return module.exports;
}
@@ -1301,8 +1307,6 @@ var CaptureAudioOptions = function(){
this.limit = 1;
// Maximum duration of a single sound clip in seconds.
this.duration = 0;
- // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
- this.mode = null;
};
module.exports = CaptureAudioOptions;
@@ -1343,8 +1347,6 @@ define("cordova/plugin/CaptureImageOptions", function(require, exports, module)
var CaptureImageOptions = function(){
// Upper limit of images user can take. Value must be equal or greater than 1.
this.limit = 1;
- // The selected image mode. Must match with one of the elements in supportedImageModes array.
- this.mode = null;
};
module.exports = CaptureImageOptions;
@@ -1362,8 +1364,6 @@ var CaptureVideoOptions = function(){
this.limit = 1;
// Maximum duration of a single video clip in seconds.
this.duration = 0;
- // The selected video mode. Must match with one of the elements in supportedVideoModes array.
- this.mode = null;
};
module.exports = CaptureVideoOptions;
@@ -4511,12 +4511,16 @@ function Device() {
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.name = info.name;
me.uuid = info.uuid;
- me.cordova = info.cordova;
+ me.cordova = buildLabel;
me.model = info.model;
channel.onCordovaInfoReady.fire();
},function(e) {
@@ -5369,7 +5373,7 @@ define("cordova/plugin/ios/logger/plugininit", function(require, exports, module
// use the native logger
var logger = require("cordova/plugin/logger");
-logger.useConsole(false);
+logger.useConsole(true);
});
@@ -5426,10 +5430,13 @@ 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
*/
@@ -5490,8 +5497,7 @@ logger.level = function (value) {
* Getter/Setter for the useConsole functionality
*
* When useConsole is true, the logger will log via the
- * browser 'console' object. Otherwise, it will use the
- * native Logger plugin.
+ * browser 'console' object.
*/
logger.useConsole = function (value) {
if (arguments.length) UseConsole = !!value;
@@ -5516,6 +5522,18 @@ logger.useConsole = function (value) {
};
/**
+ * 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
@@ -5584,24 +5602,26 @@ logger.logLevel = function(level /* , ... */) {
return;
}
- // if not using the console, use the native logger
- if (!UseConsole) {
+ // Log using the native logger if that is enabled
+ if (UseLogger) {
exec(null, null, "Logger", "logLevel", [level, message]);
- return;
}
- // make sure console is not using logger
- if (console.__usingCordovaLogger) {
- throw new Error("console and logger are too intertwingly");
- }
+ // 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: console.log(message); break;
- case logger.ERROR: console.log("ERROR: " + message); break;
- case logger.WARN: console.log("WARN: " + message); break;
- case logger.INFO: console.log("INFO: " + message); break;
- case logger.DEBUG: console.log("DEBUG: " + message); break;
+ // 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;
+ }
}
};
@@ -5862,7 +5882,7 @@ module.exports = {
// 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") {
+ 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
@@ -5886,12 +5906,14 @@ module.exports = {
* @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) {
+ prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
var _message = (message || "Prompt message");
var _title = (title || "Prompt");
var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
- exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels]);
+ var _defaultText = (defaultText || "Default text");
+ exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);
},
/**
@@ -6233,9 +6255,7 @@ function UUIDcreatePart(length) {
});
-
window.cordova = require('cordova');
-
// file: lib/scripts/bootstrap.js
(function (context) {
@@ -6351,7 +6371,7 @@ require('cordova/channel').onNativeReady.fire();
// 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 XHR response handler will just call finishPluginLoading().
- function handlePluginsObject(modules) {
+ function handlePluginsObject(modules, path) {
// First create the callback for when all plugins are loaded.
var mapper = context.cordova.require('cordova/modulemapper');
onScriptLoadingComplete = function() {
@@ -6385,35 +6405,49 @@ require('cordova/channel').onNativeReady.fire();
// Now inject the scripts.
for (var i = 0; i < modules.length; i++) {
- injectScript(modules[i].file);
+ 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;
+ }
+ }
// Try to XHR the cordova_plugins.json file asynchronously.
- try { // we commented we were going to try, so let us actually try and catch
- var xhr = new context.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 = this.responseText && JSON.parse(this.responseText);
- if (obj && obj instanceof Array && obj.length > 0) {
- handlePluginsObject(obj);
- } else {
- finishPluginLoading();
- }
- };
- xhr.onerror = function() {
+ 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.open('GET', 'cordova_plugins.json', true); // Async
+ }
+ };
+ xhr.onerror = function() {
+ finishPluginLoading();
+ };
+ var plugins_json = path + 'cordova_plugins.json';
+ 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){
+ } catch(err){
finishPluginLoading();
}
}(window));
-
})();
\ No newline at end of file
[25/36] ios commit: removed geolocation from config.xml
Posted by st...@apache.org.
removed geolocation from config.xml
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/0ecd899a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/0ecd899a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/0ecd899a
Branch: refs/heads/3.0.0
Commit: 0ecd899abc6ea86855c3f977d5cee822b114e438
Parents: 8cb40ae
Author: Steven Gill <st...@gmail.com>
Authored: Tue May 14 14:30:11 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:35:55 2013 -0700
----------------------------------------------------------------------
bin/templates/project/__TESTING__/config.xml | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/0ecd899a/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 1a5836f..6c42a3b 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -53,9 +53,6 @@
<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>
[12/36] ios commit: Re-apply [CB-3507] (was clobbered)
Posted by st...@apache.org.
Re-apply [CB-3507] (was clobbered)
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/a49be10f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/a49be10f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/a49be10f
Branch: refs/heads/3.0.0
Commit: a49be10f64b835accf027672ea891ae69e5f36f5
Parents: 4670246
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue May 28 14:05:13 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 28 14:05:13 2013 -0700
----------------------------------------------------------------------
bin/templates/project/__TESTING__.xcodeproj/project.pbxproj | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/a49be10f/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
index 885089f..f0f80bb 100755
--- a/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
+++ b/bin/templates/project/__TESTING__.xcodeproj/project.pbxproj
@@ -546,7 +546,7 @@
"-weak-lSystem",
"-force_load",
"${TARGET_BUILD_DIR}/libCordova.a",
- "-Obj-C",
+ "-ObjC",
);
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
@@ -587,7 +587,7 @@
"-weak-lSystem",
"-force_load",
"${TARGET_BUILD_DIR}/libCordova.a",
- "-Obj-C",
+ "-ObjC",
);
SDKROOT = iphoneos;
SKIP_INSTALL = NO;
[34/36] ios commit: removed enableLocation from view controller
Posted by st...@apache.org.
removed enableLocation from view controller
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/592e3892
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/592e3892
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/592e3892
Branch: refs/heads/3.0.0
Commit: 592e389275001257fcaa0d2921428207ec1399b8
Parents: c73d91e
Author: Steven Gill <st...@gmail.com>
Authored: Wed May 22 15:57:37 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Mon Jun 10 17:49:11 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVViewController.m | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/592e3892/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 5bd347f..a5b51ec 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -262,7 +262,6 @@
// /////////////////
- NSNumber* enableLocation = [self.settings objectForKey:@"EnableLocation"];
NSString* enableViewportScale = [self.settings objectForKey:@"EnableViewportScale"];
NSNumber* allowInlineMediaPlayback = [self.settings objectForKey:@"AllowInlineMediaPlayback"];
BOOL mediaPlaybackRequiresUserAction = YES; // default value
[31/36] removed contact code
Posted by st...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1d828c25/CordovaLib/Classes/CDVContacts.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.h b/CordovaLib/Classes/CDVContacts.h
deleted file mode 100644
index 0342f5b..0000000
--- a/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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1d828c25/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
deleted file mode 100644
index 40c038e..0000000
--- a/CordovaLib/Classes/CDVContacts.m
+++ /dev/null
@@ -1,592 +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"
-
-@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
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1d828c25/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 4cd9dd9..01e44cd 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -7,8 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 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, ); }; };
@@ -49,8 +47,6 @@
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, ); }; };
@@ -82,8 +78,6 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
- 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>"; };
@@ -138,8 +132,6 @@
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>"; };
@@ -273,10 +265,6 @@
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 */,
@@ -343,13 +331,11 @@
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 */,
8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
8887FD9D1090FBE7009987E8 /* CDVReachability.h in Headers */,
8887FD9F1090FBE7009987E8 /* CDVSound.h in Headers */,
- 1F3C04CE12BC247D004F9E10 /* CDVContact.h in Headers */,
1F92F4A01314023E0046367C /* CDVPluginResult.h in Headers */,
C937A4561337599E002C4C79 /* CDVFileTransfer.h in Headers */,
307A8F9E1385A2EC00E43782 /* CDVConnection.h in Headers */,
@@ -437,13 +423,11 @@
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 */,
8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
8887FD9E1090FBE7009987E8 /* CDVReachability.m in Sources */,
8887FDA01090FBE7009987E8 /* CDVSound.m in Sources */,
- 1F3C04CF12BC247D004F9E10 /* CDVContact.m in Sources */,
1F92F4A11314023E0046367C /* CDVPluginResult.m in Sources */,
C937A4571337599E002C4C79 /* CDVFileTransfer.m in Sources */,
307A8F9F1385A2EC00E43782 /* CDVConnection.m in Sources */,
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/1d828c25/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index 832ef9e..f1a6dce 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -62,9 +62,6 @@
<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>
[20/36] ios commit: removing "build" from gitignore as one of our cli
scripts is named build :)
Posted by st...@apache.org.
removing "build" from gitignore as one of our cli scripts is named build :)
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f81d5b24
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f81d5b24
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f81d5b24
Branch: refs/heads/3.0.0
Commit: f81d5b240258a01a968a62c53cabbe9c4c7a6803
Parents: 0561c6b
Author: Fil Maj <ma...@gmail.com>
Authored: Mon Jun 3 17:25:22 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Mon Jun 3 17:25:22 2013 -0700
----------------------------------------------------------------------
.gitignore | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f81d5b24/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index e0ac686..e72193b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,9 +4,8 @@
tmp
*.mode1v3
*.pbxuser
-build
*.xcworkspace
xcuserdata
CordovaLib/javascript/cordova-*.js
CordovaLib/CordovaLibApp/www/cordova.ios.js
-console.log
\ No newline at end of file
+console.log
[14/36] ios commit: [CB-3528] Update Plugin Upgrade Guide for iOS
Posted by st...@apache.org.
[CB-3528] Update Plugin Upgrade Guide for iOS
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/e18d69ad
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/e18d69ad
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/e18d69ad
Branch: refs/heads/3.0.0
Commit: e18d69ad43a73d33806f00346b6264ede7013d39
Parents: ec682c5
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue May 28 17:07:18 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue May 28 17:07:18 2013 -0700
----------------------------------------------------------------------
guides/Cordova Plugin Upgrade Guide.md | 65 +++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/e18d69ad/guides/Cordova Plugin Upgrade Guide.md
----------------------------------------------------------------------
diff --git a/guides/Cordova Plugin Upgrade Guide.md b/guides/Cordova Plugin Upgrade Guide.md
index 7a03bc4..8fc3776 100644
--- a/guides/Cordova Plugin Upgrade Guide.md
+++ b/guides/Cordova Plugin Upgrade Guide.md
@@ -22,6 +22,71 @@
This document is for developers who need to upgrade their Cordova plugins to a newer Cordova version. Starting with Cordova 1.5.0, some classes have been renamed, which will require the plugin to be upgraded. Make sure your project itself has been upgraded using the [Cordova iOS Upgrading Guide](http://cordova.apache.org/docs/en/edge/guide_upgrading_ios_index.md.html#Upgrading%20Cordova%20iOS) document.
+## Upgrading older Cordova plugins to 2.8.0 ##
+
+1. **Install** Cordova 2.8.0
+2. Follow the **"Upgrading older Cordova plugins to 2.7.0"** section, if necessary
+3. The <plugin> tag in **config.xml** has been deprecated and support will be removed in 3.0.0. To upgrade to the <feature> tag, see this example:
+
+ <plugins>
+ <plugin name="LocalStorage" value="CDVLocalStorage" />
+ <!-- other plugins -->
+ </plugins>
+
+ <!-- change to: (note that a <feature> tag is on the same level as <plugins> -->
+ <feature name="LocalStorage">
+ <param name="ios-package" value="CDVLocalStorage" />
+ </feature>
+
+
+## Upgrading older Cordova plugins to 2.7.0 ##
+
+1. **Install** Cordova 2.7.0
+2. Follow the **"Upgrading older Cordova plugins to 2.6.0"** section, if necessary
+3. The old cordova.exec signature has been deprecated since 2.1, and removed in 2.7.0. See upgrade steps below.
+
+When you use a method signature in JavaScript like this:
+
+ cordova.exec('MyService.myMethod', myArg1, myArg2, myArg3);
+
+
+The console log will ask you to upgrade it like this:
+
+ The old format of this exec call has been removed (deprecated since 2.1).
+ Change to: cordova.exec(null, null, "MyService", "myMethod", [ myArg1, myArg2, myArg3 ]);
+
+
+But, if your corresponding Objective-C method uses the old signature like so:
+
+ - (void) myMethod:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
+
+
+Update it to this new signature:
+
+ - (void) myMethod:(CDVInvokedUrlCommand*)command;
+
+Also update any references to "arguments" in the method body with "command.arguments".
+
+So if your method looked like this:
+
+ - (void) myMethod:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
+ {
+ NSString* myArgs1 = [arguments objectAtIndex:0];
+ NSString* myArgs2 = [arguments objectAtIndex:1];
+ NSString* myArgs3 = [arguments objectAtIndex:2];
+ }
+
+Change it to this:
+
+ - (void) myMethod:(CDVInvokedUrlCommand*)command
+ {
+ NSString* myArgs1 = [command.arguments objectAtIndex:0];
+ NSString* myArgs2 = [command.arguments objectAtIndex:1];
+ NSString* myArgs3 = [command.arguments objectAtIndex:2];
+ }
+
+This is the easiest upgrade path. If you want to further use the more powerful callback mechanisms provided, see the [Plugin Development Guide](http://docs.phonegap.com/en/2.7.0/guide_plugin-development_ios_index.md.html#Developing%20a%20Plugin%20on%20iOS) to upgrade your plugin.
+
## Upgrading older Cordova plugins to 2.6.0 ##
1. **Install** Cordova 2.6.0