You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/03/19 16:00:17 UTC
[2/2] ios commit: Uncrustified with v0.60 of the tool (up from 0.59).
Updated Branches:
refs/heads/master b2e97073d -> 9e47ed817
Uncrustified with v0.60 of the tool (up from 0.59).
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/9e47ed81
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/9e47ed81
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/9e47ed81
Branch: refs/heads/master
Commit: 9e47ed817fdad4669a8ce92908eb63320dda593a
Parents: b2e9707
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Mar 19 10:59:25 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Mar 19 10:59:25 2013 -0400
----------------------------------------------------------------------
CordovaLib/Classes/CDVAvailability.h | 6 +-
CordovaLib/Classes/CDVCamera.h | 4 +-
CordovaLib/Classes/CDVCamera.m | 10 +-
CordovaLib/Classes/CDVCapture.m | 10 +-
CordovaLib/Classes/CDVCommandDelegateImpl.m | 2 +-
CordovaLib/Classes/CDVCommandQueue.m | 4 +-
CordovaLib/Classes/CDVConfigParser.m | 2 +-
CordovaLib/Classes/CDVConnection.m | 2 +-
CordovaLib/Classes/CDVContact.m | 28 +-
CordovaLib/Classes/CDVContacts.h | 14 +-
CordovaLib/Classes/CDVContacts.m | 490 +++++++-------
CordovaLib/Classes/CDVFileTransfer.h | 8 +-
CordovaLib/Classes/CDVFileTransfer.m | 42 +-
CordovaLib/Classes/CDVGlobalization.m | 62 +-
CordovaLib/Classes/CDVInAppBrowser.m | 16 +-
CordovaLib/Classes/CDVInvokedUrlCommand.h | 6 +-
CordovaLib/Classes/CDVLocalStorage.h | 4 +-
CordovaLib/Classes/CDVLocalStorage.m | 36 +-
CordovaLib/Classes/CDVLocation.h | 8 +-
CordovaLib/Classes/CDVLocation.m | 24 +-
CordovaLib/Classes/CDVNotification.m | 2 +-
CordovaLib/Classes/CDVReachability.m | 28 +-
CordovaLib/Classes/CDVSound.m | 6 +-
CordovaLib/Classes/CDVSplashScreen.m | 11 +-
CordovaLib/Classes/CDVURLProtocol.m | 12 +-
CordovaLib/Classes/CDVUserAgentUtil.m | 2 +-
CordovaLib/Classes/CDVViewController.m | 40 +-
CordovaLib/Classes/NSDictionary+Extensions.m | 2 +-
CordovaLibTests/CDVFakeFileManager.h | 2 +-
CordovaLibTests/CDVFileTransferTests.m | 12 +-
CordovaLibTests/CDVLocalStorageTests.m | 24 +-
CordovaLibTests/CDVUserAgentTest.m | 4 +-
CordovaLibTests/CDVWebViewTest.m | 4 +-
.../project/__TESTING__/Classes/AppDelegate.m | 4 +-
34 files changed, 465 insertions(+), 466 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVAvailability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVAvailability.h b/CordovaLib/Classes/CDVAvailability.h
index 1d7dfea..30176e4 100644
--- a/CordovaLib/Classes/CDVAvailability.h
+++ b/CordovaLib/Classes/CDVAvailability.h
@@ -65,9 +65,9 @@
/* Return the string version of the decimal version */
#define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \
- (CORDOVA_VERSION_MIN_REQUIRED / 10000), \
- (CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
- (CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100]
+ (CORDOVA_VERSION_MIN_REQUIRED / 10000), \
+ (CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
+ (CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100]
#ifdef __clang__
#define CDV_DEPRECATED(version, msg) __attribute__((deprecated("Deprecated in Cordova " #version ". " msg)))
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVCamera.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h
index 204d25f..65eac77 100644
--- a/CordovaLib/Classes/CDVCamera.h
+++ b/CordovaLib/Classes/CDVCamera.h
@@ -61,8 +61,8 @@ typedef NSUInteger CDVMediaType;
// ======================================================================= //
@interface CDVCamera : CDVPlugin <UIImagePickerControllerDelegate,
- UINavigationControllerDelegate,
- UIPopoverControllerDelegate>
+ UINavigationControllerDelegate,
+ UIPopoverControllerDelegate>
{}
@property (strong) CDVCameraPicker* pickerController;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVCamera.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m
index e2f8640..0205e92 100644
--- a/CordovaLib/Classes/CDVCamera.m
+++ b/CordovaLib/Classes/CDVCamera.m
@@ -136,13 +136,13 @@ static NSSet* org_apache_cordova_validArrowDirections;
} else if (mediaType == MediaTypeAll) {
cameraPicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:sourceType];
} else {
- NSArray* mediaArray = [NSArray arrayWithObjects:(NSString*)(mediaType == MediaTypeVideo ? kUTTypeMovie:kUTTypeImage), nil];
+ 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];
+ cameraPicker.popoverController = [[NSClassFromString(@"UIPopoverController")alloc] initWithContentViewController:cameraPicker];
}
NSDictionary* options = [command.arguments objectAtIndex:10 withDefault:nil];
[self displayPopover:options];
@@ -303,7 +303,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
if (cameraPicker.returnType == DestinationTypeFileUri) {
// write to temp directory and return URI
// get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory ()stringByStandardizingPath];
+ 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
@@ -428,7 +428,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
rotation_radians = 0.0;
break;
- case UIImageOrientationDown :
+ case UIImageOrientationDown:
rotation_radians = M_PI; // don't be scared of radians, if you're reading this, you're good at math
break;
@@ -527,7 +527,7 @@ static NSSet* org_apache_cordova_validArrowDirections;
// 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:[@"Content-Type: image/png\r\n\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
[postBody appendData:imageData];
// // second parameter information
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVCapture.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m
index ed9f664..d89e3d3 100644
--- a/CordovaLib/Classes/CDVCapture.m
+++ b/CordovaLib/Classes/CDVCapture.m
@@ -169,7 +169,7 @@
}
// write to temp directory and return URI
- NSString* docsPath = [NSTemporaryDirectory ()stringByStandardizingPath]; // use file system temporary directory
+ NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
NSError* err = nil;
NSFileManager* fileMgr = [[NSFileManager alloc] init];
@@ -439,7 +439,7 @@
if ([command isKindOfClass:[CDVFile class]]) {
CDVFile* cdvFile = (CDVFile*)command;
NSString* mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType:[NSNull null]) forKey:@"type"];
+ [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType : [NSNull null]) forKey:@"type"];
}
}
NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:nil];
@@ -533,7 +533,6 @@
// delegate to CVDAudioRecorderViewController
return [self.topViewController supportedInterfaceOrientations];
}
-
#endif
@end
@@ -663,7 +662,7 @@
// create file to record to in temporary dir
- NSString* docsPath = [NSTemporaryDirectory ()stringByStandardizingPath]; // use file system temporary directory
+ NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
NSError* err = nil;
NSFileManager* fileMgr = [[NSFileManager alloc] init];
@@ -701,7 +700,6 @@
orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
return orientation;
}
-
#endif
- (void)viewDidUnload
@@ -766,7 +764,7 @@
BOOL isUIAccessibilityAnnouncementNotification = (&UIAccessibilityAnnouncementNotification != NULL);
if (isUIAccessibilityAnnouncementNotification) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 500ull * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
- UIAccessibilityPostNotification (UIAccessibilityAnnouncementNotification, NSLocalizedString (@"timed recording complete", nil));
+ UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, NSLocalizedString(@"timed recording complete", nil));
});
}
} else {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVCommandDelegateImpl.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegateImpl.m b/CordovaLib/Classes/CDVCommandDelegateImpl.m
index 9fcc674..fa0e5e0 100644
--- a/CordovaLib/Classes/CDVCommandDelegateImpl.m
+++ b/CordovaLib/Classes/CDVCommandDelegateImpl.m
@@ -84,7 +84,7 @@
{
CDV_EXEC_LOG(@"Exec(%@): Sending result. Status=%@", callbackId, result.status);
// This occurs when there is are no win/fail callbacks for the call.
- if ([@"INVALID" isEqualToString:callbackId]) {
+ if ([@"INVALID" isEqualToString : callbackId]) {
return;
}
int status = [result.status intValue];
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVCommandQueue.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.m b/CordovaLib/Classes/CDVCommandQueue.m
index 1ed862a..1a0dfa0 100644
--- a/CordovaLib/Classes/CDVCommandQueue.m
+++ b/CordovaLib/Classes/CDVCommandQueue.m
@@ -110,8 +110,8 @@
NSString* commandJson = [jsonEntry JSONString];
static NSUInteger maxLogLength = 1024;
NSString* commandString = ([commandJson length] > maxLogLength) ?
- [NSString stringWithFormat:@"%@[...]", [commandJson substringToIndex:maxLogLength]] :
- commandJson;
+ [NSString stringWithFormat:@"%@[...]", [commandJson substringToIndex:maxLogLength]] :
+ commandJson;
DLog(@"FAILED pluginJSON = %@", commandString);
#endif
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVConfigParser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConfigParser.m b/CordovaLib/Classes/CDVConfigParser.m
index 6fd5913..ffc8ede 100644
--- a/CordovaLib/Classes/CDVConfigParser.m
+++ b/CordovaLib/Classes/CDVConfigParser.m
@@ -52,7 +52,7 @@
} else if ([elementName isEqualToString:@"plugin"]) {
NSString* name = [attributeDict[@"name"] lowercaseString];
pluginsDict[name] = attributeDict[@"value"];
- if ([@"true" isEqualToString:attributeDict[@"onload"]]) {
+ if ([@"true" isEqualToString : attributeDict[@"onload"]]) {
[self.startupPluginNames addObject:name];
}
} else if ([elementName isEqualToString:@"access"]) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVConnection.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.m b/CordovaLib/Classes/CDVConnection.m
index 3a534b0..b3f5cab 100644
--- a/CordovaLib/Classes/CDVConnection.m
+++ b/CordovaLib/Classes/CDVConnection.m
@@ -53,7 +53,7 @@
case ReachableViaWWAN:
// Return value of '2g' is deprecated as of 2.6.0 and will be replaced with 'cellular' in 3.0.0
- return @"2g";
+ return @"2g";
case ReachableViaWiFi:
return @"wifi";
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVContact.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContact.m b/CordovaLib/Classes/CDVContact.m
index 497ee08..3844525 100644
--- a/CordovaLib/Classes/CDVContact.m
+++ b/CordovaLib/Classes/CDVContact.m
@@ -169,9 +169,9 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if (org_apache_cordova_contacts_objectAndProperties == nil) {
org_apache_cordova_contacts_objectAndProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:kW3ContactGivenName, kW3ContactFamilyName,
- kW3ContactMiddleName, kW3ContactHonorificPrefix, kW3ContactHonorificSuffix, kW3ContactFormattedName, nil], kW3ContactName,
+ kW3ContactMiddleName, kW3ContactHonorificPrefix, kW3ContactHonorificSuffix, kW3ContactFormattedName, nil], kW3ContactName,
[NSArray arrayWithObjects:kW3ContactStreetAddress, kW3ContactLocality, kW3ContactRegion,
- kW3ContactPostalCode, kW3ContactCountry, /*kW3ContactAddressFormatted,*/ nil], kW3ContactAddresses,
+ 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,
@@ -230,7 +230,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
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
+ 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];
}
@@ -300,9 +300,9 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
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];
+ [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
@@ -660,7 +660,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
[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]];
+ valueAB = [(__bridge NSDictionary*)existingDictionary valueForKey : [[CDVContact defaultW3CtoAB] valueForKey:k]];
if (valueAB != nil) {
[dict setValue:valueAB forKey:[[CDVContact defaultW3CtoAB] valueForKey:k]];
}
@@ -895,7 +895,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
if (data != nil) {
[nc setObject:data forKey:kW3ContactName];
}
- if ([self.returnFields objectForKey:kW3ContactDisplayName] && ((data == nil) || ([(NSDictionary*) data objectForKey:kW3ContactFormattedName] == [NSNull null]))) {
+ 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);
@@ -1116,7 +1116,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
// always set id
value = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
[newDict setObject:(value != nil) ? value:[NSNull null] forKey:kW3ContactFieldId];
- [(NSMutableArray*) valuesArray addObject:newDict];
+ [(NSMutableArray*)valuesArray addObject : newDict];
}
} else {
valuesArray = [NSNull null];
@@ -1190,7 +1190,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
}
if ([newAddress count] > 0) { // ?? this will always be true since we set id,label,primary field??
- [(NSMutableArray*) addresses addObject:newAddress];
+ [(NSMutableArray*)addresses addObject : newAddress];
}
CFRelease(dict);
} // end of loop through addresses
@@ -1246,7 +1246,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
bFound = CFDictionaryGetValueIfPresent(dict, kABPersonInstantMessageServiceKey, (void*)&value);
if (bFound && (value != NULL)) {
CFRetain(value);
- [newDict setObject:(id)[[CDVContact class] convertPropertyLabelToContactType:(__bridge NSString*)value] forKey:kW3ContactFieldType];
+ [newDict setObject:(id)[[CDVContact class] convertPropertyLabelToContactType : (__bridge NSString*)value] forKey:kW3ContactFieldType];
CFRelease(value);
} else {
[newDict setObject:[NSNull null] forKey:kW3ContactFieldType];
@@ -1256,7 +1256,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
id identifier = [NSNumber numberWithUnsignedInt:ABMultiValueGetIdentifierAtIndex(multi, i)];
[newDict setObject:(identifier != nil) ? identifier:[NSNull null] forKey:kW3ContactFieldId];
- [(NSMutableArray*) imArray addObject:newDict];
+ [(NSMutableArray*)imArray addObject : newDict];
CFRelease(dict);
}
} else {
@@ -1310,7 +1310,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
[newDict setObject:@"false" forKey:kW3ContactFieldPrimary];
[newDict setObject:[NSNull null] forKey:kW3ContactFieldType];
array = [NSMutableArray arrayWithCapacity:1];
- [(NSMutableArray*) array addObject:newDict];
+ [(NSMutableArray*)array addObject : newDict];
} else {
array = [NSNull null];
}
@@ -1329,7 +1329,7 @@ static NSDictionary* org_apache_cordova_contacts_defaultFields = nil;
NSData* data = (__bridge NSData*)photoData;
// write to temp directory and store URI in photos array
// get the temp directory path
- NSString* docsPath = [NSTemporaryDirectory ()stringByStandardizingPath];
+ NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath];
NSError* err = nil;
NSString* filePath = [NSString stringWithFormat:@"%@/photo_XXXXX", docsPath];
char template[filePath.length + 1];
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVContacts.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.h b/CordovaLib/Classes/CDVContacts.h
index 17470c0..0342f5b 100644
--- a/CordovaLib/Classes/CDVContacts.h
+++ b/CordovaLib/Classes/CDVContacts.h
@@ -24,9 +24,9 @@
#import "CDVContact.h"
@interface CDVContacts : CDVPlugin <ABNewPersonViewControllerDelegate,
- ABPersonViewControllerDelegate,
- ABPeoplePickerNavigationControllerDelegate
- >
+ ABPersonViewControllerDelegate,
+ ABPeoplePickerNavigationControllerDelegate
+ >
{
ABAddressBookRef addressBook;
}
@@ -63,7 +63,7 @@
- (void)newPersonViewController:(ABNewPersonViewController*)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person;
- (BOOL)personViewController:(ABPersonViewController*)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person
- property :(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue;
+ property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue;
/*
* search - searches for contacts. Only person records are currently supported.
@@ -140,9 +140,9 @@
- (CDVAddressBookAccessError*)initWithCode:(CDVContactError)code;
@end
-typedef void (^CDVAddressBookWorkerBlock)(
- ABAddressBookRef addressBook,
- CDVAddressBookAccessError * error
+typedef void (^ CDVAddressBookWorkerBlock)(
+ ABAddressBookRef addressBook,
+ CDVAddressBookAccessError* error
);
@interface CDVAddressBookHelper : NSObject
{}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVContacts.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m
index 3faf6ba..6cb9f08 100644
--- a/CordovaLib/Classes/CDVContacts.m
+++ b/CordovaLib/Classes/CDVContacts.m
@@ -77,26 +77,26 @@
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);
+ [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;
+ npController.newPersonViewDelegate = self;
+ npController.callbackId = callbackId;
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:npController];
+ 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];
- }
- }];
+ 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
@@ -130,48 +130,48 @@
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;
+ [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);
- // create this so DisplayContactViewController will have a "back" button.
- UIViewController* parentController = [[UIViewController alloc] init];
- UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:parentController];
+ if (rec) {
+ CDVDisplayContactViewController* personController = [[CDVDisplayContactViewController alloc] init];
+ personController.displayedPerson = rec;
+ personController.personViewDelegate = self;
+ personController.allowsEditing = NO;
- [navController pushViewController:personController animated:YES];
+ // create this so DisplayContactViewController will have a "back" button.
+ UIViewController* parentController = [[UIViewController alloc] init];
+ UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:parentController];
- if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
- [self.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- [self.viewController presentModalViewController:navController animated:YES];
- }
+ [navController pushViewController:personController 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];
- }
+ if ([self.viewController respondsToSelector:@selector(presentViewController:::)]) {
+ [self.viewController presentViewController:navController animated:YES completion:nil];
} else {
- // no record, return error
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:UNKNOWN_ERROR];
- [weakSelf.commandDelegate sendPluginResult:result callbackId:callbackId];
+ [self.viewController presentModalViewController:navController animated:YES];
}
- CFRelease (addrBook);
- }];
+
+ 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
@@ -284,95 +284,95 @@
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;
- }
+ // 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);
- }
- }
+ 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;
- }
- }
+ 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;
}
- 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];
- }
+ }
+ } 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;
}
- // 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);
+ }
+ }
+ 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];
}
- }];
- }]; // end of workQueue block
+ }
+ }
+ // 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;
}
@@ -383,81 +383,10 @@
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
+ CDVAddressBookHelper* abHelper = [[CDVAddressBookHelper alloc] init];
+ CDVContacts* __weak weakSelf = self; // play it safe to avoid retain cycles
- [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError * errorCode) {
+ [abHelper createAddressBook: ^(ABAddressBookRef addrBook, CDVAddressBookAccessError* errorCode) {
CDVPluginResult* result = nil;
if (addrBook == NULL) {
// permission was denied or other error - return error
@@ -467,50 +396,121 @@
}
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]] && ([cId intValue] != kABRecordInvalidID)) {
- rec = ABAddressBookGetPersonWithRecordID (addrBook, [cId intValue]);
+ if (cId && ![cId isKindOfClass:[NSNull class]]) {
+ 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
+ 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 = UNKNOWN_ERROR;
+ 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 {
- // invalid contact id provided
bIsError = TRUE;
- errCode = INVALID_ARGUMENT_ERROR;
+ errCode = IO_ERROR;
}
+ CFRelease(addrBook);
- if (addrBook) {
- 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;
}
@@ -569,24 +569,24 @@
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 (), ^{
+ // 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]);
+ workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
} else if (!granted) {
- workerBlock (NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
+ workerBlock(NULL, [[CDVAddressBookAccessError alloc] initWithCode:PERMISSION_DENIED_ERROR]);
} else {
// access granted
- workerBlock (addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
+ workerBlock(addressBook, [[CDVAddressBookAccessError alloc] initWithCode:UNKNOWN_ERROR]);
}
});
- });
+ });
} else
#endif
{
// iOS 4 or 5 no checks needed
- addressBook = ABAddressBookCreate ();
- workerBlock (addressBook, NULL);
+ addressBook = ABAddressBookCreate();
+ workerBlock(addressBook, NULL);
}
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
index f96bb7d..d82cdd3 100644
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ b/CordovaLib/Classes/CDVFileTransfer.h
@@ -48,10 +48,10 @@ extern NSString* const kOptionsKeyCookie;
- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target;
- (NSMutableDictionary*)createFileTransferError:(int)code
- AndSource :(NSString*)source
- AndTarget :(NSString*)target
- AndHttpStatus :(int)httpStatus
- AndBody :(NSString*)body;
+ AndSource:(NSString*)source
+ AndTarget:(NSString*)target
+ AndHttpStatus:(int)httpStatus
+ AndBody:(NSString*)body;
@property (readonly) NSMutableDictionary* activeTransfers;
@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index ad674ad..5741aca 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -52,8 +52,8 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
while (totalBytesWritten < bytesToWrite) {
CFIndex result = CFWriteStreamWrite(stream,
- bytes + totalBytesWritten,
- bytesToWrite - totalBytesWritten);
+ bytes + totalBytesWritten,
+ bytesToWrite - totalBytesWritten);
if (result < 0) {
CFStreamError error = CFWriteStreamGetError(stream);
NSLog(@"WriteStreamError domain: %ld error: %ld", error.domain, error.error);
@@ -190,7 +190,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
[postBodyBeforeFile appendData:formBoundaryData];
[postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
[postBodyBeforeFile appendData:[val dataUsingEncoding:NSUTF8StringEncoding]];
- [postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+ [postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding : NSUTF8StringEncoding]];
}
[postBodyBeforeFile appendData:formBoundaryData];
@@ -213,22 +213,22 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
[req setHTTPBodyStream:CFBridgingRelease(readStream)];
[self.commandDelegate runInBackground:^{
- if (CFWriteStreamOpen (writeStream)) {
- NSData* chunks[] = {postBodyBeforeFile, fileData, postBodyAfterFile};
- int numChunks = sizeof (chunks) / sizeof (chunks[0]);
-
- for (int i = 0; i < numChunks; ++i) {
- CFIndex result = WriteDataToStream (chunks[i], writeStream);
- if (result <= 0) {
- break;
- }
+ if (CFWriteStreamOpen(writeStream)) {
+ NSData* chunks[] = {postBodyBeforeFile, fileData, postBodyAfterFile};
+ int numChunks = sizeof(chunks) / sizeof(chunks[0]);
+
+ for (int i = 0; i < numChunks; ++i) {
+ CFIndex result = WriteDataToStream(chunks[i], writeStream);
+ if (result <= 0) {
+ break;
}
- } else {
- NSLog (@"FileTransfer: Failed to open writeStream");
}
- CFWriteStreamClose (writeStream);
- CFRelease (writeStream);
- }];
+ } else {
+ NSLog(@"FileTransfer: Failed to open writeStream");
+ }
+ CFWriteStreamClose(writeStream);
+ CFRelease(writeStream);
+ }];
} else {
[postBodyBeforeFile appendData:fileData];
[postBodyBeforeFile appendData:postBodyAfterFile];
@@ -265,11 +265,11 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
// return unsupported result for assets-library URLs
if ([target hasPrefix:kCDVAssetsLibraryPrefix]) {
// Instead, we return after calling the asynchronous method and send `result` in each of the blocks.
- ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset * asset) {
+ ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
if (asset) {
// We have the asset! Get the data and send it off.
ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
- Byte* buffer = (Byte*)malloc ([assetRepresentation size]);
+ Byte* buffer = (Byte*)malloc([assetRepresentation size]);
NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];
NSData* fileData = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
[self uploadData:fileData command:command];
@@ -279,7 +279,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}
};
- ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError * error) {
+ ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError* error) {
// Retrieving the asset failed for some reason. Send the appropriate error.
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsString:[error localizedDescription]];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
@@ -302,7 +302,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];
if (err != nil) {
- NSLog (@"Error opening file %@: %@", target, err);
+ NSLog(@"Error opening file %@: %@", target, err);
}
[self uploadData:fileData command:command];
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVGlobalization.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVGlobalization.m b/CordovaLib/Classes/CDVGlobalization.m
index 4d960cd..9eb9721 100644
--- a/CordovaLib/Classes/CDVGlobalization.m
+++ b/CordovaLib/Classes/CDVGlobalization.m
@@ -138,14 +138,14 @@
// create the formatter using the user's current default locale and formats for dates and times
CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
+ currentLocale,
+ dateStyle,
+ timeStyle);
// if we have a valid date object then call the formatter
if (date) {
dateString = (__bridge_transfer NSString*)CFDateFormatterCreateStringWithDate(kCFAllocatorDefault,
- formatter,
- (__bridge CFDateRef)date);
+ formatter,
+ (__bridge CFDateRef)date);
}
// if the date was converted to a string successfully then return the result
@@ -227,18 +227,18 @@
// get the user's default settings for date and time formats
CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
+ currentLocale,
+ dateStyle,
+ timeStyle);
// set the parsing to be more lenient
CFDateFormatterSetProperty(formatter, kCFDateFormatterIsLenient, kCFBooleanTrue);
// parse tha date and time string
CFDateRef date = CFDateFormatterCreateDateFromString(kCFAllocatorDefault,
- formatter,
- (__bridge CFStringRef)dateString,
- NULL);
+ formatter,
+ (__bridge CFStringRef)dateString,
+ NULL);
// if we were able to parse the date then get the date and time components
if (date != NULL) {
@@ -336,9 +336,9 @@
// get the user's default settings for date and time formats
CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- dateStyle,
- timeStyle);
+ currentLocale,
+ dateStyle,
+ timeStyle);
// get the date pattern to apply when formatting and parsing
CFStringRef datePattern = CFDateFormatterGetFormat(formatter);
@@ -415,9 +415,9 @@
}
CFDateFormatterRef formatter = CFDateFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- kCFDateFormatterFullStyle,
- kCFDateFormatterFullStyle);
+ currentLocale,
+ kCFDateFormatterFullStyle,
+ kCFDateFormatterFullStyle);
if ((selector == CDV_SELECTOR_MONTHS) && (style == CDV_FORMAT_LONG)) {
dataStyle = kCFDateFormatterMonthSymbols;
@@ -545,13 +545,13 @@
}
CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
+ currentLocale,
+ style);
// get the localized string based upon the locale and user preferences
NSString* numberString = (__bridge_transfer NSString*)CFNumberFormatterCreateStringWithNumber(kCFAllocatorDefault,
- formatter,
- (__bridge CFNumberRef)number);
+ formatter,
+ (__bridge CFNumberRef)number);
if (numberString) {
NSDictionary* dictionary = [NSDictionary dictionaryWithObject:numberString forKey:@"value"];
@@ -612,8 +612,8 @@
}
CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
+ currentLocale,
+ style);
// we need to make this lenient so as to avoid problems with parsing currencies that have non-breaking space characters
if (style == kCFNumberFormatterCurrencyStyle) {
@@ -622,10 +622,10 @@
// parse againist the largest type to avoid data loss
Boolean rc = CFNumberFormatterGetValueFromString(formatter,
- (__bridge CFStringRef)numberString,
- NULL,
- kCFNumberDoubleType,
- &doubleValue);
+ (__bridge CFStringRef)numberString,
+ NULL,
+ kCFNumberDoubleType,
+ &doubleValue);
if (rc) {
NSDictionary* dictionary = [NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:doubleValue] forKey:@"value"];
@@ -681,8 +681,8 @@
}
CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- style);
+ currentLocale,
+ style);
NSString* numberPattern = (__bridge NSString*)CFNumberFormatterGetFormat(formatter);
@@ -749,8 +749,8 @@
// now set the currency code in the formatter
if (rc) {
CFNumberFormatterRef formatter = CFNumberFormatterCreate(kCFAllocatorDefault,
- currentLocale,
- kCFNumberFormatterCurrencyStyle);
+ currentLocale,
+ kCFNumberFormatterCurrencyStyle);
CFNumberFormatterSetProperty(formatter, kCFNumberFormatterCurrencyCode, (__bridge CFStringRef)currencyCode);
CFNumberFormatterSetProperty(formatter, kCFNumberFormatterInternationalCurrencySymbol, (__bridge CFStringRef)currencyCode);
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index 92f7124..de06db3 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -165,7 +165,7 @@
{
if (self.callbackId != nil) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@ {@"type":@"loadstart", @"url":[url absoluteString]}];
+ messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}];
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
@@ -176,7 +176,7 @@
{
if (self.callbackId != nil) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@ {@"type":@"loadstop", @"url":[url absoluteString]}];
+ messageAsDictionary:@{@"type":@"loadstop", @"url":[url absoluteString]}];
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
@@ -187,7 +187,7 @@
{
if (self.callbackId != nil) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
- messageAsDictionary:@ {@"type":@"exit"}];
+ messageAsDictionary:@{@"type":@"exit"}];
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
@@ -392,10 +392,10 @@
[self.webView loadRequest:request];
} else {
[CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
- _userAgentLockToken = lockToken;
- [CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
- [self.webView loadRequest:request];
- }];
+ _userAgentLockToken = lockToken;
+ [CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
+ [self.webView loadRequest:request];
+ }];
}
}
@@ -451,7 +451,7 @@
// 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"]];
+ BOOL isPDF = [@"true" isEqualToString :[theWebView stringByEvaluatingJavaScriptFromString:@"document.body==null"]];
if (isPDF) {
[CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVInvokedUrlCommand.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.h b/CordovaLib/Classes/CDVInvokedUrlCommand.h
index 6eb0099..7be8884 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.h
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.h
@@ -34,9 +34,9 @@
+ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry;
- (id)initWithArguments:(NSArray*)arguments
- callbackId :(NSString*)callbackId
- className :(NSString*)className
- methodName :(NSString*)methodName;
+ callbackId:(NSString*)callbackId
+ className:(NSString*)className
+ methodName:(NSString*)methodName;
- (id)initFromJson:(NSArray*)jsonEntry;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVLocalStorage.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.h b/CordovaLib/Classes/CDVLocalStorage.h
index cc6613f..dec6ab3 100644
--- a/CordovaLib/Classes/CDVLocalStorage.h
+++ b/CordovaLib/Classes/CDVLocalStorage.h
@@ -34,8 +34,8 @@
+ (void)__fixupDatabaseLocationsWithBackupType:(NSString*)backupType;
// Visible for testing.
+ (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
- bundlePath :(NSString*)bundlePath
- fileManager :(NSFileManager*)fileManager;
+ bundlePath:(NSString*)bundlePath
+ fileManager:(NSFileManager*)fileManager;
@end
@interface CDVBackupInfo : NSObject
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVLocalStorage.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.m b/CordovaLib/Classes/CDVLocalStorage.m
index 68175f1..238d680 100644
--- a/CordovaLib/Classes/CDVLocalStorage.m
+++ b/CordovaLib/Classes/CDVLocalStorage.m
@@ -35,7 +35,7 @@
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResignActive)
name:UIApplicationWillResignActiveNotification object:nil];
- BOOL cloudBackup = [@"cloud" isEqualToString:self.commandDelegate.settings[@"BackupWebStorage"]];
+ BOOL cloudBackup = [@"cloud" isEqualToString : self.commandDelegate.settings[@"BackupWebStorage"]];
self.backupInfo = [[self class] createBackupInfoWithCloudBackup:cloudBackup];
}
@@ -64,8 +64,8 @@
// ////////// LOCALSTORAGE
original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/file__0.localstorage":@"file__0.localstorage"];
- backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage":@"")];
- backup = [backup stringByAppendingPathComponent:(rename ? @"localstorage.appdata.db":@"file__0.localstorage")];
+ backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
+ backup = [backup stringByAppendingPathComponent:(rename ? @"localstorage.appdata.db" : @"file__0.localstorage")];
backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
@@ -77,8 +77,8 @@
// ////////// WEBSQL MAIN DB
original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/Databases.db":@"Databases.db"];
- backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage":@"")];
- backup = [backup stringByAppendingPathComponent:(rename ? @"websqlmain.appdata.db":@"Databases.db")];
+ backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
+ backup = [backup stringByAppendingPathComponent:(rename ? @"websqlmain.appdata.db" : @"Databases.db")];
backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
@@ -90,8 +90,8 @@
// ////////// WEBSQL DATABASES
original = [targetDir stringByAppendingPathComponent:targetDirNests ? @"WebKit/LocalStorage/file__0":@"file__0"];
- backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage":@"")];
- backup = [backup stringByAppendingPathComponent:(rename ? @"websqldbs.appdata.db":@"file__0")];
+ backup = [backupDir stringByAppendingPathComponent:(backupDirNests ? @"WebKit/LocalStorage" : @"")];
+ backup = [backup stringByAppendingPathComponent:(rename ? @"websqldbs.appdata.db" : @"file__0")];
backupItem = [[CDVBackupInfo alloc] init];
backupItem.backup = backup;
@@ -106,8 +106,8 @@
+ (NSMutableArray*)createBackupInfoWithCloudBackup:(BOOL)cloudBackup
{
// create backup info from backup folder to caches folder
- NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains (NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
- NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* cacheFolder = [appLibraryFolder stringByAppendingPathComponent:@"Caches"];
NSString* backupsFolder = [appDocumentsFolder stringByAppendingPathComponent:@"Backups"];
@@ -131,7 +131,7 @@
return success;
}
-+ (BOOL)copyFrom:(NSString*)src to:(NSString*)dest error:(NSError * __autoreleasing*)error
++ (BOOL)copyFrom:(NSString*)src to:(NSString*)dest error:(NSError* __autoreleasing*)error
{
NSFileManager* fileManager = [NSFileManager defaultManager];
@@ -149,7 +149,7 @@
// generate unique filepath in temp directory
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
- NSString* tempBackup = [[NSTemporaryDirectory () stringByAppendingPathComponent:(__bridge NSString*)uuidString] stringByAppendingPathExtension:@"bak"];
+ NSString* tempBackup = [[NSTemporaryDirectory() stringByAppendingPathComponent:(__bridge NSString*)uuidString] stringByAppendingPathExtension:@"bak"];
CFRelease(uuidString);
CFRelease(uuidRef);
@@ -334,8 +334,8 @@
return;
}
- NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains (NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
- NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSMutableArray* backupInfo = [NSMutableArray arrayWithCapacity:0];
@@ -386,15 +386,15 @@
backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
backgroundTaskID = UIBackgroundTaskInvalid;
- NSLog (@"Background task to backup WebSQL/LocalStorage expired.");
+ NSLog(@"Background task to backup WebSQL/LocalStorage expired.");
}];
CDVLocalStorage __weak* weakSelf = self;
[self.commandDelegate runInBackground:^{
- [weakSelf backup:nil];
+ [weakSelf backup:nil];
- [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
- backgroundTaskID = UIBackgroundTaskInvalid;
- }];
+ [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
+ backgroundTaskID = UIBackgroundTaskInvalid;
+ }];
}
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVLocation.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.h b/CordovaLib/Classes/CDVLocation.h
index 7087d43..caf0798 100644
--- a/CordovaLib/Classes/CDVLocation.h
+++ b/CordovaLib/Classes/CDVLocation.h
@@ -83,11 +83,11 @@ typedef NSUInteger CDVLocationStatus;
- (void)startLocation:(BOOL)enableHighAccuracy;
- (void)locationManager:(CLLocationManager*)manager
- didUpdateToLocation :(CLLocation*)newLocation
- fromLocation :(CLLocation*)oldLocation;
+ didUpdateToLocation:(CLLocation*)newLocation
+ fromLocation:(CLLocation*)oldLocation;
- (void)locationManager:(CLLocationManager*)manager
- didFailWithError :(NSError*)error;
+ didFailWithError:(NSError*)error;
- (BOOL)isLocationServicesEnabled;
@@ -97,7 +97,7 @@ typedef NSUInteger CDVLocationStatus;
- (void)stopHeading:(CDVInvokedUrlCommand*)command;
- (void)startHeadingWithFilter:(CLLocationDegrees)filter;
- (void)locationManager:(CLLocationManager*)manager
- didUpdateHeading :(CLHeading*)heading;
+ didUpdateHeading:(CLHeading*)heading;
- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVLocation.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.m b/CordovaLib/Classes/CDVLocation.m
index 07af30e..ed9ec26 100644
--- a/CordovaLib/Classes/CDVLocation.m
+++ b/CordovaLib/Classes/CDVLocation.m
@@ -591,17 +591,17 @@
- (NSString*)JSONRepresentation
{
return [NSString stringWithFormat:
- @"{ timestamp: %.00f, \
+ @"{ 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
+ [self.timestamp timeIntervalSince1970] * 1000.0,
+ self.coordinate.latitude,
+ self.coordinate.longitude,
+ self.altitude,
+ self.course,
+ self.speed,
+ self.horizontalAccuracy,
+ self.verticalAccuracy
];
}
@@ -614,9 +614,9 @@
- (NSString*)JSONRepresentation
{
return [NSString stringWithFormat:
- @"{ code: %d, message: '%@'}",
- self.code,
- [self localizedDescription]
+ @"{ code: %d, message: '%@'}",
+ self.code,
+ [self localizedDescription]
];
}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVNotification.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.m b/CordovaLib/Classes/CDVNotification.m
index 6b1b35f..5c2dfda 100644
--- a/CordovaLib/Classes/CDVNotification.m
+++ b/CordovaLib/Classes/CDVNotification.m
@@ -25,7 +25,7 @@
- (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons callbackId:(NSString*)callbackId
{
CDVAlertView* alertView = [[CDVAlertView alloc]
- initWithTitle:title
+ initWithTitle:title
message:message
delegate:self
cancelButtonTitle:nil
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVReachability.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVReachability.m b/CordovaLib/Classes/CDVReachability.m
index 3c5a48b..89f4ec9 100644
--- a/CordovaLib/Classes/CDVReachability.m
+++ b/CordovaLib/Classes/CDVReachability.m
@@ -61,18 +61,18 @@ static void CDVPrintReachabilityFlags(SCNetworkReachabilityFlags flags, const ch
{
#if kShouldPrintReachabilityFlags
NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
- (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
- (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
-
- (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
- (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
- (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
- (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
- (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
- comment
- );
+ (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
+ (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
+
+ (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
+ (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
+ (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
+ (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
+ (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
+ (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
+ (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-',
+ comment
+ );
#endif
}
@@ -90,7 +90,7 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe
return;
}
- if (![(__bridge NSObject*) info isKindOfClass:[CDVReachability class]]) {
+ if (![(__bridge NSObject*)info isKindOfClass :[CDVReachability class]]) {
NSLog(@"info was wrong class in ReachabilityCallback");
return;
}
@@ -214,7 +214,7 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe
}
if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
- ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))) {
+ ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))) {
// ... and the connection is on-demand (or on-traffic) if the
// calling application is using the CFSocketStream or higher APIs
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVSound.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSound.m b/CordovaLib/Classes/CDVSound.m
index 1fd5ed3..88fbbd6 100644
--- a/CordovaLib/Classes/CDVSound.m
+++ b/CordovaLib/Classes/CDVSound.m
@@ -87,7 +87,7 @@
NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
} else {
// if resourcePath is not from FileSystem put in tmp dir, else attempt to use provided resource path
- NSString* tmpPath = [NSTemporaryDirectory ()stringByStandardizingPath];
+ NSString* tmpPath = [NSTemporaryDirectory()stringByStandardizingPath];
BOOL isTmp = [resourcePath rangeOfString:tmpPath].location != NSNotFound;
BOOL isDoc = [resourcePath rangeOfString:docsPath].location != NSNotFound;
if (!isTmp && !isDoc) {
@@ -127,7 +127,7 @@
filePath = [self.commandDelegate pathForResource:resourcePath];
if (filePath == nil) {
// see if this exists in the documents/temp directory from a previous recording
- NSString* testPath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory ()stringByStandardizingPath], resourcePath];
+ NSString* testPath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory()stringByStandardizingPath], resourcePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:testPath]) {
// inefficient as existence will be checked again below but only way to determine if file exists from previous recording
filePath = testPath;
@@ -385,7 +385,7 @@
// bug in AVAudioPlayer when playing downloaded data in NSData - we have to download the file and play from disk
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
- NSString* filePath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory ()stringByStandardizingPath], uuidString];
+ NSString* filePath = [NSString stringWithFormat:@"%@/%@", [NSTemporaryDirectory()stringByStandardizingPath], uuidString];
CFRelease(uuidString);
CFRelease(uuidRef);
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/9e47ed81/CordovaLib/Classes/CDVSplashScreen.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.m b/CordovaLib/Classes/CDVSplashScreen.m
index 8778094..b06c486 100644
--- a/CordovaLib/Classes/CDVSplashScreen.m
+++ b/CordovaLib/Classes/CDVSplashScreen.m
@@ -205,12 +205,13 @@
duration:fadeDuration
options:UIViewAnimationOptionTransitionNone
animations:^(void) {
- [_imageView setAlpha:0];
- [_activityView setAlpha:0];
- }
+ [_imageView setAlpha:0];
+ [_activityView setAlpha:0];
+ }
+
completion:^(BOOL finished) {
- [self destroyViews];
- }];
+ [self destroyViews];
+ }];
}
}