Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0346CEB2A for ; Fri, 23 Nov 2012 02:22:52 +0000 (UTC) Received: (qmail 5967 invoked by uid 500); 23 Nov 2012 02:22:51 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 5936 invoked by uid 500); 23 Nov 2012 02:22:51 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 5926 invoked by uid 99); 23 Nov 2012 02:22:51 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Nov 2012 02:22:51 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A3295319207; Fri, 23 Nov 2012 02:22:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: agrieve@apache.org To: commits@cordova.apache.org X-Mailer: ASF-Git Admin Mailer Subject: ios commit: Uncrustify Message-Id: <20121123022251.A3295319207@tyr.zones.apache.org> Date: Fri, 23 Nov 2012 02:22:51 +0000 (UTC) Updated Branches: refs/heads/master d494d7c05 -> eb48666d6 Uncrustify Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/eb48666d Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/eb48666d Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/eb48666d Branch: refs/heads/master Commit: eb48666d6e5f12eb1e8df0c7a0f2ac36dd18e71d Parents: d494d7c Author: Andrew Grieve Authored: Thu Nov 22 21:22:18 2012 -0500 Committer: Andrew Grieve Committed: Thu Nov 22 21:22:18 2012 -0500 ---------------------------------------------------------------------- CordovaLib/Classes/CDVContacts.m | 22 ++++---- CordovaLib/Classes/CDVGlobalization.h | 63 +++++++++++----------- CordovaLib/Classes/CDVInvokedUrlCommand.m | 7 ++- CordovaLib/Classes/CDVWhitelist.h | 4 +- CordovaLib/Classes/CDVWhitelist.m | 2 +- CordovaLibTests/CDVInvokedUrlCommandTests.m | 2 +- CordovaLibTests/CDVWhitelistTests.m | 15 +++--- 7 files changed, 58 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb48666d/CordovaLib/Classes/CDVContacts.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVContacts.m b/CordovaLib/Classes/CDVContacts.m index 429e7ec..1e8e084 100644 --- a/CordovaLib/Classes/CDVContacts.m +++ b/CordovaLib/Classes/CDVContacts.m @@ -250,10 +250,9 @@ // 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 + if (&ABAddressBookCreateWithOptions != NULL) { + addrBook = ABAddressBookCreateWithOptions(NULL, NULL); + } else #endif { // iOS 4 & 5 @@ -564,12 +563,12 @@ 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) { + 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) { @@ -582,8 +581,7 @@ } }); }); - } - else + } else #endif { // iOS 4 or 5 no checks needed http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb48666d/CordovaLib/Classes/CDVGlobalization.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVGlobalization.h b/CordovaLib/Classes/CDVGlobalization.h index a7f5a8f..0384656 100644 --- a/CordovaLib/Classes/CDVGlobalization.h +++ b/CordovaLib/Classes/CDVGlobalization.h @@ -6,9 +6,9 @@ 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 @@ -20,12 +20,12 @@ #import #import "CDVPlugin.h" -#define CDV_FORMAT_SHORT 0 -#define CDV_FORMAT_MEDIUM 1 -#define CDV_FORMAT_LONG 2 -#define CDV_FORMAT_FULL 3 +#define CDV_FORMAT_SHORT 0 +#define CDV_FORMAT_MEDIUM 1 +#define CDV_FORMAT_LONG 2 +#define CDV_FORMAT_FULL 3 #define CDV_SELECTOR_MONTHS 0 -#define CDV_SELECTOR_DAYS 1 +#define CDV_SELECTOR_DAYS 1 enum CDVGlobalizationError { CDV_UNKNOWN_ERROR = 0, @@ -35,33 +35,32 @@ enum CDVGlobalizationError { }; typedef NSUInteger CDVGlobalizationError; - @interface CDVGlobalization : CDVPlugin { CFLocaleRef currentLocale; } -- (void) getPreferredLanguage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)getPreferredLanguage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns the string identifier for the client’s current locale setting. + * Returns the string identifier for the clients current locale setting. * It returns the locale identifier string to the successCB callback with a * properties object as a parameter. If there is an error getting the locale, * then the errorCB callback is invoked. */ -- (void) getLocaleName:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)getLocaleName:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns a date formatted as a string according to the client’s user preferences and + * Returns a date formatted as a string according to the clients user preferences and * calendar using the time zone of the client. It returns the formatted date string to the * successCB callback with a properties object as a parameter. If there is an error * formatting the date, then the errorCB callback is invoked. * * options: "date" contains the number of milliseconds that represents the JavaScript date */ -- (void) dateToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)dateToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Parses a date formatted as a string according to the client’s user + * Parses a date formatted as a string according to the clients user * preferences and calendar using the time zone of the client and returns * the corresponding date object. It returns the date to the successCB * callback with a properties object as a parameter. If there is an error @@ -69,28 +68,28 @@ typedef NSUInteger CDVGlobalizationError; * * options: "dateString" contains the JavaScript string to parse for a date */ -- (void) stringToDate:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)stringToDate:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns a pattern string for formatting and parsing dates according to the client’s + * Returns a pattern string for formatting and parsing dates according to the clients * user preferences. It returns the pattern to the successCB callback with a * properties object as a parameter. If there is an error obtaining the pattern, * then the errorCB callback is invoked. * */ -- (void) getDatePattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)getDatePattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** * Returns an array of either the names of the months or days of the week - * according to the client’s user preferences and calendar. It returns the array of names to the + * according to the clients user preferences and calendar. It returns the array of names to the * successCB callback with a properties object as a parameter. If there is an error obtaining the * names, then the errorCB callback is invoked. * */ -- (void) getDateNames:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)getDateNames:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns whether daylight savings time is in effect for a given date using the client’s + * Returns whether daylight savings time is in effect for a given date using the clients * time zone and calendar. It returns whether or not daylight savings time is in effect * to the successCB callback with a properties object as a parameter. If there is an error * reading the date, then the errorCB callback is invoked. @@ -98,29 +97,29 @@ typedef NSUInteger CDVGlobalizationError; * options: "date" contains the number of milliseconds that represents the JavaScript date * */ -- (void) isDayLightSavingsTime:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)isDayLightSavingsTime:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns the first day of the week according to the client’s user preferences and calendar. + * Returns the first day of the week according to the clients user preferences and calendar. * The days of the week are numbered starting from 1 where 1 is considered to be Sunday. * It returns the day to the successCB callback with a properties object as a parameter. * If there is an error obtaining the pattern, then the errorCB callback is invoked. * */ -- (void) getFirstDayOfWeek:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)getFirstDayOfWeek:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns a number formatted as a string according to the client’s user preferences. + * Returns a number formatted as a string according to the clients user preferences. * It returns the formatted number string to the successCB callback with a properties object as a * parameter. If there is an error formatting the number, then the errorCB callback is invoked. * * options: "number" contains the JavaScript number to format * */ -- (void) numberToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)numberToString:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Parses a number formatted as a string according to the client’s user preferences and + * Parses a number formatted as a string according to the clients user preferences and * returns the corresponding number. It returns the number to the successCB callback with a * properties object as a parameter. If there is an error parsing the number string, then * the errorCB callback is invoked. @@ -128,24 +127,24 @@ typedef NSUInteger CDVGlobalizationError; * options: "numberString" contains the JavaScript string to parse for a number * */ -- (void) stringToNumber:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)stringToNumber:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns a pattern string for formatting and parsing numbers according to the client’s user + * Returns a pattern string for formatting and parsing numbers according to the clients user * preferences. It returns the pattern to the successCB callback with a properties object as a * parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked. * */ -- (void) getNumberPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)getNumberPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; /** - * Returns a pattern string for formatting and parsing currency values according to the client’s + * Returns a pattern string for formatting and parsing currency values according to the clients * user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a * properties object as a parameter. If there is an error obtaining the pattern, then the errorCB * callback is invoked. * * options: "currencyCode" contains the ISO currency code from JavaScript */ -- (void) getCurrencyPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void)getCurrencyPattern:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; -@end \ No newline at end of file +@end http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb48666d/CordovaLib/Classes/CDVInvokedUrlCommand.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.m b/CordovaLib/Classes/CDVInvokedUrlCommand.m index b8c7d1e..d79df50 100644 --- a/CordovaLib/Classes/CDVInvokedUrlCommand.m +++ b/CordovaLib/Classes/CDVInvokedUrlCommand.m @@ -84,11 +84,13 @@ } } -- (id)argumentAtIndex:(NSUInteger)index { +- (id)argumentAtIndex:(NSUInteger)index +{ return [self argumentAtIndex:index withDefault:nil]; } -- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue { +- (id)argumentAtIndex:(NSUInteger)index withDefault:(id)defaultValue +{ if (index >= [_arguments count]) { return defaultValue; } @@ -98,4 +100,5 @@ } return ret; } + @end http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb48666d/CordovaLib/Classes/CDVWhitelist.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVWhitelist.h b/CordovaLib/Classes/CDVWhitelist.h index b848342..3741e94 100644 --- a/CordovaLib/Classes/CDVWhitelist.h +++ b/CordovaLib/Classes/CDVWhitelist.h @@ -19,14 +19,14 @@ #import -extern NSString * const kCDVDefaultWhitelistRejectionString; +extern NSString* const kCDVDefaultWhitelistRejectionString; @interface CDVWhitelist : NSObject @property (nonatomic, readonly, strong) NSArray* whitelist; @property (nonatomic, readonly, strong) NSArray* expandedWhitelist; @property (nonatomic, readonly, assign) BOOL allowAll; -@property (nonatomic, copy) NSString *whitelistRejectionFormatString; +@property (nonatomic, copy) NSString* whitelistRejectionFormatString; - (id)initWithArray:(NSArray*)array; - (BOOL)URLIsAllowed:(NSURL*)url; http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb48666d/CordovaLib/Classes/CDVWhitelist.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVWhitelist.m b/CordovaLib/Classes/CDVWhitelist.m index 1bf0f56..77e20ac 100644 --- a/CordovaLib/Classes/CDVWhitelist.m +++ b/CordovaLib/Classes/CDVWhitelist.m @@ -19,7 +19,7 @@ #import "CDVWhitelist.h" -NSString * const kCDVDefaultWhitelistRejectionString = @"ERROR whitelist rejection: url='%@'"; +NSString* const kCDVDefaultWhitelistRejectionString = @"ERROR whitelist rejection: url='%@'"; @interface CDVWhitelist () http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb48666d/CordovaLibTests/CDVInvokedUrlCommandTests.m ---------------------------------------------------------------------- diff --git a/CordovaLibTests/CDVInvokedUrlCommandTests.m b/CordovaLibTests/CDVInvokedUrlCommandTests.m index 5e0275f..cdaff0b 100644 --- a/CordovaLibTests/CDVInvokedUrlCommandTests.m +++ b/CordovaLibTests/CDVInvokedUrlCommandTests.m @@ -97,11 +97,11 @@ { NSArray* jsonArr = [NSArray arrayWithObjects:[NSNull null], @"className", @"methodName", [NSArray array], nil]; CDVInvokedUrlCommand* command = [CDVInvokedUrlCommand commandFromJson:jsonArr]; + STAssertNil([command argumentAtIndex:0], @"NSNull to nil"); STAssertNil([command argumentAtIndex:100], @"Invalid index to nil"); STAssertEquals(@"default", [command argumentAtIndex:0 withDefault:@"default"], @"NSNull to default"); STAssertEquals(@"default", [command argumentAtIndex:100 withDefault:@"default"], @"Invalid index to default"); } - @end http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/eb48666d/CordovaLibTests/CDVWhitelistTests.m ---------------------------------------------------------------------- diff --git a/CordovaLibTests/CDVWhitelistTests.m b/CordovaLibTests/CDVWhitelistTests.m index 2e26779..c1bc757 100644 --- a/CordovaLibTests/CDVWhitelistTests.m +++ b/CordovaLibTests/CDVWhitelistTests.m @@ -247,14 +247,15 @@ - (void)testWhitelistRejectionString { - NSArray *allowedHosts = [NSArray arrayWithObject:@"http://www.yahoo.com/"]; // Doesn't matter in this test. - CDVWhitelist *whitelist = [[CDVWhitelist alloc] initWithArray:allowedHosts]; - - NSURL *testUrl = [NSURL URLWithString:@"http://www/google.com"]; - NSString *errorString = [whitelist errorStringForURL:testUrl]; - NSString *expectedErrorString = [NSString stringWithFormat:kCDVDefaultWhitelistRejectionString, [testUrl absoluteString]]; + NSArray* allowedHosts = [NSArray arrayWithObject:@"http://www.yahoo.com/"]; // Doesn't matter in this test. + CDVWhitelist* whitelist = [[CDVWhitelist alloc] initWithArray:allowedHosts]; + + NSURL* testUrl = [NSURL URLWithString:@"http://www/google.com"]; + NSString* errorString = [whitelist errorStringForURL:testUrl]; + NSString* expectedErrorString = [NSString stringWithFormat:kCDVDefaultWhitelistRejectionString, [testUrl absoluteString]]; + STAssertTrue([expectedErrorString isEqualToString:errorString], @"Default error string has an unexpected value."); - + whitelist.whitelistRejectionFormatString = @"Hey, '%@' is, like, bogus man!"; errorString = [whitelist errorStringForURL:testUrl]; expectedErrorString = [NSString stringWithFormat:whitelist.whitelistRejectionFormatString, [testUrl absoluteString]];