From 0608b15caa35831a16aa7e5fd1490df24dd01784 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Wed, 2 Jun 2010 17:36:03 +0000 Subject: [Author: dmaclach] Cleans up builds of GTM on Snow Leopard with gcc 4.2. Cleans up iPhone configs Adds libgcov for Snow Leopard Fixes up some small bugs. R=thomasvl DELTA=2028 (972 added, 990 deleted, 66 changed) --- AddressBook/GTMABAddressBookTest.m | 6 + AppKit/GTMCarbonEvent.m | 1 + AppKit/GTMGetURLHandlerTest.m | 2 +- AppKit/GTMGoogleSearch.h | 144 ++++++ AppKit/GTMGoogleSearch.m | 536 +++++++++++++++++++++ AppKit/GTMGoogleSearchTest.m | 208 ++++++++ AppKit/GTMHotKeyTextFieldTest.m | 8 +- AppKit/GTMNSImage+Scaling.h | 6 +- AppKit/GTMNSImage+ScalingTest.m | 20 +- AppKit/GTMNSImage+SearchCache.h | 2 + ...lizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff | Bin 0 -> 30128 bytes ...lizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff | Bin 0 -> 42058 bytes ...lizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff | Bin 0 -> 28444 bytes DebugUtils/GTMDebugThreadValidation.m | 3 +- Foundation/GTMCalculatedRangeTest.m | 2 +- Foundation/GTMGoogleSearch.h | 144 ------ Foundation/GTMGoogleSearch.m | 534 -------------------- Foundation/GTMGoogleSearchTest.m | 208 -------- Foundation/GTMLogger.h | 24 +- Foundation/GTMLogger.m | 12 +- Foundation/GTMRegex.m | 15 +- Foundation/GTMSQLiteTest.m | 2 +- Foundation/GTMScriptRunnerTest.m | 30 +- Foundation/GTMStackTrace.h | 2 +- Foundation/GTMTransientRootProxyTest.m | 2 +- GTM.xcodeproj/project.pbxproj | 90 ++-- GTMDefines.h | 5 + GTM_Prefix.pch | 24 +- SnowLeopardGcov/%ReadMe.webloc | Bin 0 -> 751 bytes SnowLeopardGcov/ReadMe.webloc | Bin 0 -> 109 bytes SnowLeopardGcov/libgcov.a | Bin 0 -> 75360 bytes UnitTesting/GTMAppKitUnitTestingUtilities.h | 2 + UnitTesting/GTMNSObject+BindingUnitTesting.h | 2 +- UnitTesting/GTMNSObject+BindingUnitTesting.m | 1 + UnitTesting/GTMNSObject+UnitTesting.m | 2 +- UnitTesting/GTMUnitTestDevLog.h | 17 +- UnitTesting/GTMUnitTestDevLog.m | 6 +- UnitTesting/GTMUnitTestingBindingTest.m | 4 +- XcodeConfig/subconfig/GTMMerge.xcconfig | 2 +- XcodeConfig/subconfig/SnowLeopardOrLater.xcconfig | 6 +- XcodeConfig/subconfig/iPhone20.xcconfig | 2 - XcodeConfig/subconfig/iPhone21.xcconfig | 2 - XcodeConfig/subconfig/iPhone22.xcconfig | 2 - XcodeConfig/subconfig/iPhone221.xcconfig | 2 - XcodeConfig/subconfig/iPhone30.xcconfig | 3 - XcodeConfig/subconfig/iPhone31.xcconfig | 2 - XcodeConfig/subconfig/iPhone312.xcconfig | 2 - XcodeConfig/subconfig/iPhone313.xcconfig | 3 - XcodeConfig/subconfig/iPhone32.xcconfig | 3 - 49 files changed, 1035 insertions(+), 1058 deletions(-) create mode 100644 AppKit/GTMGoogleSearch.h create mode 100644 AppKit/GTMGoogleSearch.m create mode 100644 AppKit/GTMGoogleSearchTest.m create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff create mode 100644 AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff delete mode 100644 Foundation/GTMGoogleSearch.h delete mode 100644 Foundation/GTMGoogleSearch.m delete mode 100644 Foundation/GTMGoogleSearchTest.m create mode 100644 SnowLeopardGcov/%ReadMe.webloc create mode 100644 SnowLeopardGcov/ReadMe.webloc create mode 100644 SnowLeopardGcov/libgcov.a diff --git a/AddressBook/GTMABAddressBookTest.m b/AddressBook/GTMABAddressBookTest.m index 73b0eca..bd6e224 100644 --- a/AddressBook/GTMABAddressBookTest.m +++ b/AddressBook/GTMABAddressBookTest.m @@ -19,6 +19,12 @@ #import "GTMSenTestCase.h" #import "GTMABAddressBook.h" +#if GTM_IPHONE_SDK +#import "UIKit/UIKit.h" +#else +#import +#endif // GTM_IPHONE_SDK + static NSString *const kGTMABTestFirstName = @"GTMABAddressBookTestFirstName"; static NSString *const kGTMABTestLastName = @"GTMABAddressBookTestLastName"; static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName"; diff --git a/AppKit/GTMCarbonEvent.m b/AppKit/GTMCarbonEvent.m index 479e49e..28bfdb9 100644 --- a/AppKit/GTMCarbonEvent.m +++ b/AppKit/GTMCarbonEvent.m @@ -17,6 +17,7 @@ // #import "GTMCarbonEvent.h" +#import #import "GTMObjectSingleton.h" #import "GTMDebugSelectorValidation.h" #import "GTMTypeCasting.h" diff --git a/AppKit/GTMGetURLHandlerTest.m b/AppKit/GTMGetURLHandlerTest.m index 940d90f..a639176 100644 --- a/AppKit/GTMGetURLHandlerTest.m +++ b/AppKit/GTMGetURLHandlerTest.m @@ -51,7 +51,7 @@ static BOOL sURLHandlerWasHit; + (BOOL)gtm_openURL:(NSURL*)url { sURLHandlerWasHit = !sURLHandlerWasHit; - return sURLHandlerWasHit; + return YES; } - (void)testURLCall { diff --git a/AppKit/GTMGoogleSearch.h b/AppKit/GTMGoogleSearch.h new file mode 100644 index 0000000..06b8d51 --- /dev/null +++ b/AppKit/GTMGoogleSearch.h @@ -0,0 +1,144 @@ +// +// GTMGoogleSearch.h +// +// Copyright 2006-2009 Google Inc. +// +// Licensed 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 + +// Key for Info.plist for default global search args +#define GTMGoogleSearchClientAppArgsKey @"GTMGoogleSearchClientAppArgs" + +// Types to pass in to searchForURL:ofType:arguments +// and performQuery:ofType:arguments +#define GTMGoogleSearchFroogle @"products" +#define GTMGoogleSearchGroups @"groups" +#define GTMGoogleSearchImages @"images" +#define GTMGoogleSearchLocal @"local" +#define GTMGoogleSearchNews @"news" +#define GTMGoogleSearchFinance @"finance" +#define GTMGoogleSearchBooks @"books" +#define GTMGoogleSearchWeb @"search" + +// iPhone doesn't support distributed notifications, so this controls whether +// or not we enable them in this class. +#define GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS GTM_MACOS_SDK + +// Composes URLs and searches for google properties in the correct language +// and domain. +@interface GTMGoogleSearch : NSObject { + // the cached values + NSString *allAppsCachedDomain_; + NSString *allAppsCachedLanguage_; + NSString *curAppCachedDomain_; + NSString *curAppCachedLanguage_; + NSDictionary *globalSearchArguments_; +} + +// +// +sharedInstance +// +// fetches the common shared object for accessing this users preference +// ++ (GTMGoogleSearch*)sharedInstance; + +// +// searchURLFor:ofType:arguments: +// +// creates a search url of type |type| for |queryText| using the user's +// preferred domain and language settings. |args| is a set of arguments +// that will be added into your query, and you can use it to complement +// or override settings stored in globalSearchArguments. +// example dictionary to do an I'm feeling lucky search would be: +// [NSDictionary dictionaryWithObject:@"1" key:@"btnI"]; +// If queryText is nil, no query will be put in. +// Arguments passed in in args must be properly URL escaped. +// If you want to remove one of the arguments that will be included in the +// global search arguments, set the object for the key you want to remove to +// [NSNull null]. +- (NSString*)searchURLFor:(NSString *)queryText + ofType:(NSString *)type + arguments:(NSDictionary *)args; + +// +// performQuery:ofType:arguments: +// +// Asks NSWorkspace to open up a query for an url created by passing +// the args to searchURLFor:ofType:arguments: above. +// +- (BOOL)performQuery:(NSString *)queryText + ofType:(NSString *)type + arguments:(NSDictionary *)localArgs; + +// Global search arguments are initially picked up from your main bundle +// info.plist if there is a dictionary entry at the top level with the key +// "GTMGoogleSearchClientAppArgs". This dictionary should be a map of strings +// to strings where they are the args you want passed to all Google searches. +// You can override these with your localArgs when you actually perform the +// search if you wish. +// This arguments will affect all searches. Arguments must be properly URL +// escaped. +- (void)setGlobalSearchArguments:(NSDictionary *)args; + +// Returns the global search arguments. +- (NSDictionary *)globalSearchArguments; + +// +// -preferredDomainAndLanguage:areCurrentAppOnly +// +// fetches the user's preferred domain and language, and whether the values +// that were grabbed were from the anyapplication domain, or from the current +// application domain. You may pass in nil for |language| if you don't want +// a language back, and you may pass in NULL for |currentAppOnly| if you don't +// care about where it came from. +// +- (void)preferredDomain:(NSString **)domain + language:(NSString **)language + areCurrentAppOnly:(BOOL*)currentAppOnly; + +// +// -updatePreferredDomain:language:currentApplicationOnly: +// +// updated the users preferred domain and language to copies of |domain| and +// |language| respectively. |domain| can't be nil or an empty string, but +// |language| can't be nil, but can be an empty string to signify no language +// pref. If |currentAppOnly| is YES, only updates the preferred settings for the +// current app, otherwise updates them for all apps. +// +- (void)updatePreferredDomain:(NSString *)domain + language:(NSString *)language + currentApplicationOnly:(BOOL)currentAppOnly; + +// +// -clearPreferredDomainAndLanguageForCurrentApplication +// +// clears the setting for the current applications preferred domain and +// language so future fetches will get the system level ones. +// +- (void)clearPreferredDomainAndLanguageForCurrentApplication; + +// +// -clearPreferredDomainAndLanguageForAllApps +// +// clears the "AllApps" setting for preferred domain and language so future +// fetches end up having to use the default. Odds are this is only +// used by the unittests. +// NOTE: this doesn't do anything to any setting that's set in an individual +// apps preferences, so those settings will still override inplace of the +// "all apps" value (or default). +// +- (void)clearPreferredDomainAndLanguageForAllApps; + +@end diff --git a/AppKit/GTMGoogleSearch.m b/AppKit/GTMGoogleSearch.m new file mode 100644 index 0000000..9eb095f --- /dev/null +++ b/AppKit/GTMGoogleSearch.m @@ -0,0 +1,536 @@ +// +// GTMGoogleSearch.m +// +// Copyright 2006-2009 Google Inc. +// +// Licensed 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 "GTMGoogleSearch.h" +#import "GTMObjectSingleton.h" +#import "GTMGarbageCollection.h" + +#if GTM_IPHONE_SDK +#import +#else +#import +#endif // GTM_IPHONE_SDK + +typedef struct { + NSString *language; + NSString *country; + // we don't include a language, we'll use what we get from the OS + NSString *defaultDomain; +} LanguageDefaultInfo; + +// +// this is a seed mapping from languages to domains for google search. +// this doesn't have to be complete, as it is just a seed. +// +// +static LanguageDefaultInfo kLanguageListDefaultMappingTable[] = { + // order is important, first match is taken + // if country is |nil|, then only language has to match + { @"en", @"US", @"com" }, // english - united states + { @"en", @"GB", @"co.uk" }, // english - united kingdom + { @"en", @"CA", @"ca" }, // english - canada + { @"en", @"AU", @"com.au" }, // english - australia + { @"en", @"NZ", @"com" }, // english - new zealand + { @"en", @"IE", @"ie" }, // english - ireland + { @"en", @"IN", @"co.in" }, // english - india + { @"en", @"PH", @"com.ph" }, // english - philippines + { @"en", @"SG", @"com.sg" }, // english - singapore + { @"en", @"ZA", @"co.za" }, // english - south africa + { @"en", @"IL", @"co.il" }, // english - israel + { @"en", nil , @"com" }, // english (catch all) + { @"fr", @"CA", @"ca" }, // french - canada + { @"fr", @"CH", @"ch" }, // french - switzerland + { @"fr", nil , @"fr" }, // france + { @"it", nil , @"it" }, // italy + { @"de", @"AT", @"at" }, // german - austria + { @"de", nil , @"de" }, // germany + { @"es", @"MX", @"com.mx" }, // spanish - mexico + { @"es", @"AR", @"com.ar" }, // spanish - argentina + { @"es", @"CL", @"cl" }, // spanish - chile + { @"es", @"CO", @"com.co" }, // spanish - colombia + { @"es", @"PE", @"com.pe" }, // spanish - peru + { @"es", @"VE", @"co.ve" }, // venezuela + { @"es", nil , @"es" }, // spain + { @"zh", @"TW", @"com.tw" }, // taiwan + { @"zh", @"HK", @"com.hk" }, // hong kong + { @"zh", nil , @"cn" }, // chinese (catch all) + { @"ja", nil , @"co.jp" }, // japan + { @"ko", nil , @"co.kr" }, // korea + { @"nl", @"BE", @"be" }, // dutch - belgium + { @"nl", nil , @"nl" }, // (dutch) netherlands + { @"ru", nil , @"ru" }, // russia + { @"pt", @"BZ", @"com.br"}, // portuguese - brazil + { @"pt", nil , @"pt" }, // portugal + { @"sv", nil , @"se" }, // sweden + { @"nn", nil , @"no" }, // norway (two variants) + { @"nb", nil , @"no" }, // norway (two variants) + { @"da", nil , @"dk" }, // denmark + { @"fi", nil , @"fi" }, // finland + { @"bg", nil , @"bg" }, // bulgaria + { @"hr", nil , @"hr" }, // croatia + { @"cx", nil , @"cz" }, // czech republic + { @"el", nil , @"gr" }, // greece + { @"hu", nil , @"co.hu" }, // hungary + { @"ro", nil , @"ro" }, // romania + { @"sk", nil , @"sk" }, // slovakia + { @"sl", nil , @"si" }, // slovenia + { @"tr", nil , @"com.tr" }, // turkey + { @"my", nil , @"com.my" }, // malaysia + { @"th", nil , @"co.th" }, // thailand + { @"uk", nil , @"com.ua" }, // ukraine + { @"vi", nil , @"com.vn" }, // vietnam + { @"af", nil , @"com.za" }, // south africa (afrikaans) + { @"hi", nil , @"co.in" }, // india (hindi) + { @"id", nil , @"co.id" }, // indonesia + { @"pl", nil , @"pl" }, // poland +}; + +// the notification we use for syncing up instances in different processes +static NSString *const kNotificationName + = @"com.google.GoogleSearchAllApps.prefsWritten"; + +// this is the bundle id we use for the pref file used for all apps +static CFStringRef const kAllAppsBuildIdentifier + = CFSTR("com.google.GoogleSearchAllApps"); + +static CFStringRef const kPreferredDomainPrefKey + = CFSTR("com.google.PreferredDomain"); +static CFStringRef const kPreferredLanguagePrefKey + = CFSTR("com.google.PreferredLanguage"); + +static NSString *const kDefaultDomain = @"com"; +static NSString *const kDefaultLanguage = @"en"; + +#define SEARCH_URL_TEMPLATE @"http://www.google.%@/%@?%@" + +@interface GTMGoogleSearch (PrivateMethods) +- (void)defaultDomain:(NSString**)preferedDomain + language:(NSString**)preferredLanguage; +- (void)reloadAllAppCachedValues:(NSNotification*)notification; +- (void)updateAllAppsDomain:(NSString*)domain language:(NSString*)language; +@end + + +@implementation GTMGoogleSearch + +GTMOBJECT_SINGLETON_BOILERPLATE(GTMGoogleSearch, sharedInstance); + +- (id)init { + self = [super init]; + if (self != nil) { +#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + // register for the notification + NSDistributedNotificationCenter *distCenter = + [NSDistributedNotificationCenter defaultCenter]; + [distCenter addObserver:self + selector:@selector(reloadAllAppCachedValues:) + name:kNotificationName + object:nil]; +#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + // load the allApps value + [self reloadAllAppCachedValues:nil]; + + // load the cur app value + CFStringRef domain + = CFPreferencesCopyValue(kPreferredDomainPrefKey, + kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFStringRef lang = CFPreferencesCopyValue(kPreferredLanguagePrefKey, + kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + + // make sure we got values for both and domain is not empty + if (domain && CFStringGetLength(domain) == 0) { + CFRelease(domain); + domain = nil; + if (lang) { + CFRelease(lang); + lang = nil; + } + } + + curAppCachedDomain_ = GTMNSMakeCollectable(domain); + curAppCachedLanguage_ = GTMNSMakeCollectable(lang); + + NSBundle *bundle = [NSBundle mainBundle]; + + NSDictionary *appArgs + = [bundle objectForInfoDictionaryKey:GTMGoogleSearchClientAppArgsKey]; + globalSearchArguments_ = [appArgs retain]; + } + return self; +} + +#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS +- (void)finalize { + [[NSDistributedNotificationCenter defaultCenter] removeObject:self]; + [super finalize]; +} +#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + +- (void)dealloc { +#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + [[NSDistributedNotificationCenter defaultCenter] removeObject:self]; +#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + [allAppsCachedDomain_ release]; + [allAppsCachedLanguage_ release]; + [curAppCachedDomain_ release]; + [curAppCachedLanguage_ release]; + [globalSearchArguments_ release]; + [super dealloc]; +} + +- (void)preferredDomain:(NSString **)domain + language:(NSString**)language + areCurrentAppOnly:(BOOL*)currentAppOnly { + BOOL localCurrentAppOnly = YES; + NSString *localDomain = curAppCachedDomain_; + NSString *localLanguage = curAppCachedLanguage_; + + // if either one wasn't there, drop both, and use any app if we can + if (!localDomain || !localLanguage) { + localCurrentAppOnly = NO; + localDomain = allAppsCachedDomain_; + localLanguage = allAppsCachedLanguage_; + + // if we didn't get anything from the prefs, go with the defaults + if (!localDomain || !localLanguage) { + // if either one wasn't there, drop both, and use defaults + [self defaultDomain:&localDomain language:&localLanguage]; + } + } + if (!localDomain || !localLanguage) { + _GTMDevLog(@"GTMGoogleSearch: Failed to get the preferred domain/language " + @"from prefs or defaults"); + } + if (language) { + *language = [[localLanguage retain] autorelease]; + } + if (domain) { + *domain = [[localDomain retain] autorelease]; + } + if (currentAppOnly) { + *currentAppOnly = localCurrentAppOnly; + } +} + +- (void)updatePreferredDomain:(NSString*)domain + language:(NSString*)language + currentApplicationOnly:(BOOL)currentAppOnly { + // valid inputs? + if (!domain || ![domain length] || !language) { + return; + } + + if (currentAppOnly) { + // if they are the same, don't do anything + if ((domain == nil && curAppCachedDomain_ == nil && + language == nil && curAppCachedLanguage_ == nil) || + ([domain isEqualToString:curAppCachedDomain_] && + [language isEqualToString:curAppCachedLanguage_])) { + return; + } + + // save them out + CFPreferencesSetValue(kPreferredDomainPrefKey, + (CFStringRef)domain, + kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFPreferencesSetValue(kPreferredLanguagePrefKey, + (CFStringRef)language, + kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFPreferencesSynchronize(kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + // update our locals + [curAppCachedDomain_ release]; + [curAppCachedLanguage_ release]; + curAppCachedDomain_ = [domain copy]; + curAppCachedLanguage_ = [language copy]; + } else { + // Set the "any application" values + [self updateAllAppsDomain:domain language:language]; + + // Clear the current application values (if there were any) + [self clearPreferredDomainAndLanguageForCurrentApplication]; + } +} + +- (void)clearPreferredDomainAndLanguageForCurrentApplication { + // flush what's in the file + CFPreferencesSetValue(kPreferredDomainPrefKey, + NULL, + kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFPreferencesSetValue(kPreferredLanguagePrefKey, + NULL, + kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFPreferencesSynchronize(kCFPreferencesCurrentApplication, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + // clear our locals + [curAppCachedDomain_ release]; + [curAppCachedLanguage_ release]; + curAppCachedDomain_ = nil; + curAppCachedLanguage_ = nil; +} + +- (void)clearPreferredDomainAndLanguageForAllApps { + // nil/nil to clear things out, this will also update our cached values. + [self updateAllAppsDomain:nil language:nil]; +} + +- (NSDictionary *)globalSearchArguments { + return globalSearchArguments_; +} + +- (void)setGlobalSearchArguments:(NSDictionary *)args { + [globalSearchArguments_ autorelease]; + globalSearchArguments_ = [args copy]; +} + +- (NSString*)searchURLFor:(NSString*)queryText + ofType:(NSString*)type + arguments:(NSDictionary *)localArgs { + if (!type) { + return nil; + } + + NSString *language; + NSString *domain; + [self preferredDomain:&domain + language:&language + areCurrentAppOnly:NULL]; + + NSMutableDictionary *args + = [NSMutableDictionary dictionaryWithObjectsAndKeys: + @"UTF-8", @"ie", + @"UTF-8", @"oe", + language, @"hl", + nil]; + if (queryText) { + [args setObject:queryText forKey:@"q"]; + } + + NSDictionary *globalSearchArgs = [self globalSearchArguments]; + if (globalSearchArgs) { + [args addEntriesFromDictionary:globalSearchArgs]; + } + if (localArgs) { + [args addEntriesFromDictionary:localArgs]; + } + + NSMutableArray *clientArgs = [NSMutableArray array]; + NSString *key; + NSNull *nsNull = [NSNull null]; + GTM_FOREACH_KEY(key, args) { + NSString *object = [args objectForKey:key]; + if (![object isEqual:nsNull]) { +#if DEBUG + // In debug we check key and object for things that should be escaped. + // Note that percent is not in there because escaped strings will have + // percents in them + NSCharacterSet *cs = [NSCharacterSet characterSetWithCharactersInString: + @"!*'();:@&=+$,/?#[] "]; + NSRange range = [key rangeOfCharacterFromSet:cs]; + if (range.location != NSNotFound) { + _GTMDevLog(@"Unescaped string %@ in argument pair {%@, %@} in -[%@ %@]", + key, key, object, [self class], NSStringFromSelector(_cmd)); + } + range = [object rangeOfCharacterFromSet:cs]; + if (range.location != NSNotFound) { + _GTMDevLog(@"Unescaped string %@ in argument pair {%@,%@ } in -[%@ %@]", + object, key, object, [self class], + NSStringFromSelector(_cmd)); + } +#endif // DEBUG + NSString *arg = [NSString stringWithFormat:@"%@=%@", key, object]; + [clientArgs addObject:arg]; + } + } + NSString *clientArg = [clientArgs componentsJoinedByString:@"&"]; + NSString *url = [NSString stringWithFormat:SEARCH_URL_TEMPLATE, + domain, type, clientArg]; + return url; +} + +- (BOOL)performQuery:(NSString*)queryText + ofType:(NSString *)type + arguments:(NSDictionary *)localArgs { + BOOL success = NO; + NSString *urlString = [self searchURLFor:queryText + ofType:type + arguments:localArgs]; + if (urlString) { + NSURL *url = [NSURL URLWithString:urlString]; + if (url) { +#if GTM_IPHONE_SDK + success = [[UIApplication sharedApplication] openURL:url]; +#else // GTM_IPHONE_SDK + success = [[NSWorkspace sharedWorkspace] openURL:url]; +#endif // GTM_IPHONE_SDK + } + } + return success; +} + +@end + + +@implementation GTMGoogleSearch (PrivateMethods) + +- (void)defaultDomain:(NSString**)preferredDomain + language:(NSString**)preferredLanguage { + // must have both + if (!preferredDomain || !preferredLanguage) { + return; + } + + // make sure they are clear to start + *preferredDomain = nil; + *preferredLanguage = nil; + + // loop over their language list trying to find something we have in + // out default table. + + NSUserDefaults* defs = [NSUserDefaults standardUserDefaults]; + NSArray* languages = [defs objectForKey:@"AppleLanguages"]; + // the current locale is only based on what languages the running apps is + // localized to, so we stick that at the end in case we weren't able to + // find anything else as a match, we'll match that. + languages = + [languages arrayByAddingObject:[[NSLocale currentLocale] localeIdentifier]]; + + NSEnumerator *enumerator = [languages objectEnumerator]; + NSString *localeIdentifier; + while ((localeIdentifier = [enumerator nextObject])) { + NSDictionary *localeParts + = [NSLocale componentsFromLocaleIdentifier:localeIdentifier]; + NSString *localeLanguage = [localeParts objectForKey:NSLocaleLanguageCode]; + // we don't use NSLocaleScriptCode for now + NSString *localeCountry = [localeParts objectForKey:NSLocaleCountryCode]; + + LanguageDefaultInfo *scan = kLanguageListDefaultMappingTable; + LanguageDefaultInfo *end = (scan + (sizeof(kLanguageListDefaultMappingTable) + / sizeof(LanguageDefaultInfo))); + // find a match + // check language, and if country is not nil, check that + for ( ; scan < end ; ++scan) { + if ([localeLanguage isEqualToString:scan->language] && + (!(scan->country) || [localeCountry isEqualToString:scan->country])) { + *preferredDomain = scan->defaultDomain; + *preferredLanguage = localeLanguage; + return; // out of here + } + } + } + + *preferredDomain = kDefaultDomain; + *preferredLanguage = kDefaultLanguage; +} + +// -reloadAllAppCachedValues: +// +- (void)reloadAllAppCachedValues:(NSNotification*)notification { + // drop the old... + [allAppsCachedDomain_ release]; + [allAppsCachedLanguage_ release]; + allAppsCachedDomain_ = nil; + allAppsCachedLanguage_ = nil; + + // load the new + CFPreferencesSynchronize(kAllAppsBuildIdentifier, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFStringRef domain = CFPreferencesCopyValue(kPreferredDomainPrefKey, + kAllAppsBuildIdentifier, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFStringRef lang = CFPreferencesCopyValue(kPreferredLanguagePrefKey, + kAllAppsBuildIdentifier, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + + // make sure we got values for both and domain is not empty + if (domain && CFStringGetLength(domain) == 0) { + CFRelease(domain); + domain = nil; + if (lang) { + CFRelease(lang); + lang = nil; + } + } + + allAppsCachedDomain_ = GTMNSMakeCollectable(domain); + allAppsCachedLanguage_ = GTMNSMakeCollectable(lang); +} + +// -updateAllAppsDomain:language: +// +- (void)updateAllAppsDomain:(NSString*)domain language:(NSString*)language { + // domain and language can be nil to clear the values + + // if they are the same, don't do anything + if ((domain == nil && allAppsCachedDomain_ == nil && + language == nil && allAppsCachedLanguage_ == nil) || + ([domain isEqualToString:allAppsCachedDomain_] && + [language isEqualToString:allAppsCachedLanguage_])) { + return; + } + + // write it to the file + CFPreferencesSetValue(kPreferredDomainPrefKey, + (CFStringRef)domain, + kAllAppsBuildIdentifier, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFPreferencesSetValue(kPreferredLanguagePrefKey, + (CFStringRef)language, + kAllAppsBuildIdentifier, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + CFPreferencesSynchronize(kAllAppsBuildIdentifier, + kCFPreferencesCurrentUser, + kCFPreferencesAnyHost); + + // update our values + [allAppsCachedDomain_ release]; + [allAppsCachedLanguage_ release]; + allAppsCachedDomain_ = [domain copy]; + allAppsCachedLanguage_ = [language copy]; + +#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + // NOTE: we'll go ahead and reload when this comes back to ourselves since + // there is a race here if two folks wrote at about the same time. + NSDistributedNotificationCenter *distCenter = + [NSDistributedNotificationCenter defaultCenter]; + [distCenter postNotificationName:kNotificationName + object:nil + userInfo:nil]; +#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS +} + +@end diff --git a/AppKit/GTMGoogleSearchTest.m b/AppKit/GTMGoogleSearchTest.m new file mode 100644 index 0000000..45f7e66 --- /dev/null +++ b/AppKit/GTMGoogleSearchTest.m @@ -0,0 +1,208 @@ +// +// GTMGoogleSearchTest.m +// +// Copyright 2006-2009 Google Inc. +// +// Licensed 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 "GTMGoogleSearch.h" +#import "GTMSenTestCase.h" +#import "GTMUnitTestDevLog.h" +#import + +@interface GTMGoogleSearchTest : GTMTestCase +@end + +@implementation GTMGoogleSearchTest + +- (void)testSearches { + typedef struct { + NSString *type; + NSString *expectedPrefix; + } TestSearchDesc; + static TestSearchDesc testSearches[] = { + { GTMGoogleSearchFroogle, @"http://www.google.xxx/products?" }, + { GTMGoogleSearchGroups, @"http://www.google.xxx/groups?" }, + { GTMGoogleSearchImages, @"http://www.google.xxx/images?"}, + { GTMGoogleSearchLocal, @"http://www.google.xxx/local?"}, + { GTMGoogleSearchNews, @"http://www.google.xxx/news?"}, + { GTMGoogleSearchFinance, @"http://www.google.xxx/finance?"}, + { GTMGoogleSearchBooks, @"http://www.google.xxx/books?"}, + { GTMGoogleSearchWeb, @"http://www.google.xxx/search?"}, + }; + + GTMGoogleSearch *googleSearch = [GTMGoogleSearch sharedInstance]; + STAssertNotNil(googleSearch, nil); + + // force the current app values so we aren't at the mercy of the + // global setting the users locale. + [googleSearch updatePreferredDomain:@"xxx" + language:@"yyy" + currentApplicationOnly:TRUE]; + + size_t count = sizeof(testSearches) / sizeof(testSearches[0]); + NSDictionary *globalArgs + = [NSDictionary dictionaryWithObject:@"f" forKey:@"foo"]; + [googleSearch setGlobalSearchArguments:globalArgs]; + NSDictionary *args = [NSDictionary dictionaryWithObject:@"Baba" + forKey:@"BaR"]; + NSString *expectedStrings[] = { + @"oe=UTF-8", @"hl=yyy", @"q=Foobar", + @"foo=f", @"ie=UTF-8", @"BaR=Baba" + }; + for (size_t i = 0; i < count; i++) { + // test building the url + NSString *urlString = [googleSearch searchURLFor:@"Foobar" + ofType:testSearches[i].type + arguments:args]; + STAssertTrue([urlString hasPrefix:testSearches[i].expectedPrefix], + @"Bad URL? URL:%@ Expected Prefix:%@", + urlString, testSearches[i].expectedPrefix); + for (size_t j = 0; + j < sizeof(expectedStrings) / sizeof(expectedStrings[0]); + ++j) { + STAssertGreaterThan([urlString rangeOfString:expectedStrings[j]].length, + (NSUInteger)0, @"URL: %@ expectedString: %@", + urlString, expectedStrings[j]); + } + } + + // clear what we just set for this test + [googleSearch setGlobalSearchArguments:nil]; + [googleSearch clearPreferredDomainAndLanguageForCurrentApplication]; +} + +- (void)testBadInputs { + GTMGoogleSearch *googleSearch = [GTMGoogleSearch sharedInstance]; + STAssertNotNil(googleSearch, nil); + NSDictionary *args = [NSDictionary dictionaryWithObject:@"Ba!ba" + forKey:@"Ba=R"]; + [GTMUnitTestDevLogDebug expectString: + @"Unescaped string Foo bar in argument pair {q,Foo bar } " + @"in -[GTMGoogleSearch searchURLFor:ofType:arguments:]"]; + [GTMUnitTestDevLogDebug expectString: + @"Unescaped string Ba=R in argument pair {Ba=R, Ba!ba} " + @"in -[GTMGoogleSearch searchURLFor:ofType:arguments:]"]; + [GTMUnitTestDevLogDebug expectString: + @"Unescaped string Ba!ba in argument pair {Ba=R,Ba!ba } " + @"in -[GTMGoogleSearch searchURLFor:ofType:arguments:]"]; + NSString *urlString = [googleSearch searchURLFor:@"Foo bar" + ofType:GTMGoogleSearchFroogle + arguments:args]; + STAssertNotNil(urlString, nil); +} + +- (void)testPreferredDefaults { + GTMGoogleSearch *googleSearch = [GTMGoogleSearch sharedInstance]; + STAssertNotNil(googleSearch, nil); + + // hey, we're a unit test, so start by blowing away what we have at the + // app level. + [googleSearch clearPreferredDomainAndLanguageForCurrentApplication]; + + // in theory, we could fetch now and save off what we get to reset at the + // end of this, but we can't tell if that was an "all apps" setting, or if + // it was the default, so...hey, we're a unit test, we'll just stomp what's + // there and clear it out when done... + [googleSearch clearPreferredDomainAndLanguageForAllApps]; + + // make sure the individual accessors work... + + // since they system level default can be set by any app, we just have to + // check for non nil here (also the users locale could control what + // we get if nothing is set). + NSString *domain; + NSString *lang; + // now do a detailed check... + BOOL areCurrentAppOnly = YES; + [googleSearch preferredDomain:&domain + language:&lang + areCurrentAppOnly:&areCurrentAppOnly]; + // should get something for defaults... + STAssertNotNil(domain, nil); + STAssertNotNil(lang, nil); + STAssertFalse(areCurrentAppOnly, nil); + + // test it for "all apps"... + [googleSearch updatePreferredDomain:@"domain" + language:@"lang" + currentApplicationOnly:NO]; + [googleSearch preferredDomain:&domain + language:&lang + areCurrentAppOnly:&areCurrentAppOnly]; + STAssertEqualObjects(domain, @"domain", nil); + STAssertEqualObjects(lang, @"lang", nil); + STAssertFalse(areCurrentAppOnly, nil); + + // test it for this app... + [googleSearch updatePreferredDomain:@"domainThisApp" + language:@"langThisApp" + currentApplicationOnly:YES]; + [googleSearch preferredDomain:&domain + language:&lang + areCurrentAppOnly:&areCurrentAppOnly]; + STAssertEqualObjects(domain, @"domainThisApp", nil); + STAssertEqualObjects(lang, @"langThisApp", nil); + STAssertTrue(areCurrentAppOnly, nil); + + // clear what we just set for this app + [googleSearch clearPreferredDomainAndLanguageForCurrentApplication]; + + // should get back what we set for all apps + [googleSearch preferredDomain:&domain + language:&lang + areCurrentAppOnly:&areCurrentAppOnly]; + STAssertEqualObjects(domain, @"domain", nil); + STAssertEqualObjects(lang, @"lang", nil); + STAssertFalse(areCurrentAppOnly, nil); +#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + // We don't test launching other tasks on the phone since this isn't a valid + // case until we can support real multiple tasks on the phone. + + // try changing the value directly in the plist file (as if another app had + // done it) and sending our notification. + [[NSTask launchedTaskWithLaunchPath:@"/usr/bin/defaults" + arguments:[NSArray arrayWithObjects:@"write", + @"com.google.GoogleSearchAllApps", + @"{ \"com.google.PreferredDomain\" = xxx;" + @"\"com.google.PreferredLanguage\" = yyy; }", + nil]] waitUntilExit]; + // Sleep for a moment to let things flush + // (seen rarely as a problem on aharper's machine). + sleep(1); + NSDistributedNotificationCenter *distCenter = + [NSDistributedNotificationCenter defaultCenter]; + [distCenter postNotificationName:@"com.google.GoogleSearchAllApps.prefsWritten" + object:nil + userInfo:nil + options:NSNotificationDeliverImmediately]; + + // Spin the runloop so the notifications fire. + NSRunLoop *currentLoop = [NSRunLoop currentRunLoop]; + [currentLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]]; + // did we get what we expected? + [googleSearch preferredDomain:&domain + language:&lang + areCurrentAppOnly:&areCurrentAppOnly]; + STAssertEqualObjects(domain, @"xxx", nil); + STAssertEqualObjects(lang, @"yyy", nil); + STAssertFalse(areCurrentAppOnly, nil); +#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS + + // lastly, clean up what we set for all apps to leave the system at the + // default. + [googleSearch clearPreferredDomainAndLanguageForAllApps]; +} + +@end diff --git a/AppKit/GTMHotKeyTextFieldTest.m b/AppKit/GTMHotKeyTextFieldTest.m index b3e7e89..e48ee94 100644 --- a/AppKit/GTMHotKeyTextFieldTest.m +++ b/AppKit/GTMHotKeyTextFieldTest.m @@ -265,7 +265,7 @@ GTMHotKeyTextField *field = [controller_ view]; STAssertNotNil(field, nil); NSString *expectedNumberString = @"Hot key fields don't take numbers."; - [GTMUnitTestDevLog expect:6 casesOfString:expectedNumberString]; + [GTMUnitTestDevLog expect:6 casesOfString:@"%@", expectedNumberString]; [field setDoubleValue:2]; [field setIntValue:-1]; [field setFloatValue:0]; @@ -273,7 +273,7 @@ STAssertEquals([field intValue], 0, nil); STAssertEquals([field floatValue], 0.0f, nil); #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 - [GTMUnitTestDevLog expect:2 casesOfString:expectedNumberString]; + [GTMUnitTestDevLog expect:2 casesOfString:@"%@", expectedNumberString]; [field setIntegerValue:5]; STAssertEquals([field integerValue], (NSInteger)0, nil); #endif @@ -285,14 +285,14 @@ }; for (size_t i = 0; i < sizeof(takeNumberSels) / sizeof(takeNumberSels[0]); ++i) { - [GTMUnitTestDevLog expect:2 casesOfString:expectedNumberString]; + [GTMUnitTestDevLog expect:2 casesOfString:@"%@", expectedNumberString]; [field performSelector:takeNumberSels[i] withObject:self]; [field performSelector:takeNumberSels[i] withObject:nil]; } NSString *expectedStringString = @"Hot key fields want dictionaries, not strings."; - [GTMUnitTestDevLog expect:6 casesOfString:expectedStringString]; + [GTMUnitTestDevLog expect:6 casesOfString:@"%@", expectedStringString]; [field takeStringValueFrom:self]; [field takeStringValueFrom:nil]; [field setStringValue:nil]; diff --git a/AppKit/GTMNSImage+Scaling.h b/AppKit/GTMNSImage+Scaling.h index 7d48577..0f87709 100644 --- a/AppKit/GTMNSImage+Scaling.h +++ b/AppKit/GTMNSImage+Scaling.h @@ -19,7 +19,7 @@ // -#import +#import #import "GTMDefines.h" @interface NSImage (GTMNSImageScaling) @@ -30,7 +30,9 @@ #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 // Return the exact or next largest representation for a size // If you are on SnowLeopard use -// -[NSImage bestRepresentationForRect:context:hints:] +// -[NSImage bestRepresentationForRect:context:hints:] +// Also, please see http://openradar.appspot.com/radar?id=394401 +// and read notes in GTMNSImage+ScalingTest.m. Search for "8052200". - (NSImageRep *)gtm_bestRepresentationForSize:(NSSize)size; #endif diff --git a/AppKit/GTMNSImage+ScalingTest.m b/AppKit/GTMNSImage+ScalingTest.m index dddd00f..426e21b 100644 --- a/AppKit/GTMNSImage+ScalingTest.m +++ b/AppKit/GTMNSImage+ScalingTest.m @@ -49,7 +49,7 @@ STAssertNotNil([testImage gtm_representationOfSize:NSMakeSize(32, 32)], nil); NSImage *duplicate = [testImage gtm_duplicateOfSize:NSMakeSize(48, 48)]; - bestRepRect = NSMakeRect(0, 0, 50, 50); + bestRepRect = NSMakeRect(0, 0, 48, 48); #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 rep = [duplicate bestRepresentationForRect:bestRepRect context:nil @@ -60,6 +60,24 @@ STAssertTrue(NSEqualSizes([rep size], NSMakeSize(48, 48)), @"Size is %@", NSStringFromSize([rep size])); + // This should IMHO return 48,48 on both 10.6 and 10.5. It makes no sense + // at all that it returns 32,32 on 10_6 when the above code works for 48,48. + // rdar://8052200 "NSImage bestRepresentationForRect:context:hints: doesn't + // return the best rep" + // http://openradar.appspot.com/radar?id=394401 + bestRepRect = NSMakeRect(0, 0, 50, 50); +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + rep = [duplicate bestRepresentationForRect:bestRepRect + context:nil + hints:nil]; + STAssertFalse(NSEqualSizes([rep size], NSMakeSize(48, 48)), + @"Size is %@", NSStringFromSize([rep size])); +#else + rep = [duplicate gtm_bestRepresentationForSize:bestRepRect.size]; + STAssertTrue(NSEqualSizes([rep size], NSMakeSize(48, 48)), + @"Size is %@", NSStringFromSize([rep size])); +#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + } @end diff --git a/AppKit/GTMNSImage+SearchCache.h b/AppKit/GTMNSImage+SearchCache.h index b0999bf..4e3a10d 100644 --- a/AppKit/GTMNSImage+SearchCache.h +++ b/AppKit/GTMNSImage+SearchCache.h @@ -32,6 +32,8 @@ // TODO(alcor): this class should have basic MRU cache // +#import + @interface NSImage (GTMNSImageSearchCache) + (NSImage *)gtm_imageWithPath:(NSString *)path; + (NSImage *)gtm_imageNamed:(NSString *)name; diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff new file mode 100644 index 0000000..29c9762 Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff differ diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff new file mode 100644 index 0000000..eb9815e Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff differ diff --git a/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff new file mode 100644 index 0000000..f677712 Binary files /dev/null and b/AppKit/TestData/GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff differ diff --git a/DebugUtils/GTMDebugThreadValidation.m b/DebugUtils/GTMDebugThreadValidation.m index 5889cd8..30ee757 100644 --- a/DebugUtils/GTMDebugThreadValidation.m +++ b/DebugUtils/GTMDebugThreadValidation.m @@ -16,11 +16,10 @@ // the License. // +#import "GTMDebugThreadValidation.h" #if DEBUG && MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 -#import "GTMDebugThreadValidation.h" - static NSThread *gGTMMainThread = nil; static __attribute__((constructor)) void _GTMInitThread(void) { diff --git a/Foundation/GTMCalculatedRangeTest.m b/Foundation/GTMCalculatedRangeTest.m index 1790072..0806a0d 100644 --- a/Foundation/GTMCalculatedRangeTest.m +++ b/Foundation/GTMCalculatedRangeTest.m @@ -34,7 +34,7 @@ const NSUInteger kExisitingIndex = 2; - (void)setUp { range_ = [[GTMCalculatedRange alloc] init]; for(NSUInteger i = kStringCount; i > 0; --i) { - [range_ insertStop:kStrings[kStringCount - i] atPosition: 1.0f / i]; + [range_ insertStop:kStrings[kStringCount - i] atPosition:(CGFloat)(1.0 / i)]; } } diff --git a/Foundation/GTMGoogleSearch.h b/Foundation/GTMGoogleSearch.h deleted file mode 100644 index 06b8d51..0000000 --- a/Foundation/GTMGoogleSearch.h +++ /dev/null @@ -1,144 +0,0 @@ -// -// GTMGoogleSearch.h -// -// Copyright 2006-2009 Google Inc. -// -// Licensed 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 - -// Key for Info.plist for default global search args -#define GTMGoogleSearchClientAppArgsKey @"GTMGoogleSearchClientAppArgs" - -// Types to pass in to searchForURL:ofType:arguments -// and performQuery:ofType:arguments -#define GTMGoogleSearchFroogle @"products" -#define GTMGoogleSearchGroups @"groups" -#define GTMGoogleSearchImages @"images" -#define GTMGoogleSearchLocal @"local" -#define GTMGoogleSearchNews @"news" -#define GTMGoogleSearchFinance @"finance" -#define GTMGoogleSearchBooks @"books" -#define GTMGoogleSearchWeb @"search" - -// iPhone doesn't support distributed notifications, so this controls whether -// or not we enable them in this class. -#define GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS GTM_MACOS_SDK - -// Composes URLs and searches for google properties in the correct language -// and domain. -@interface GTMGoogleSearch : NSObject { - // the cached values - NSString *allAppsCachedDomain_; - NSString *allAppsCachedLanguage_; - NSString *curAppCachedDomain_; - NSString *curAppCachedLanguage_; - NSDictionary *globalSearchArguments_; -} - -// -// +sharedInstance -// -// fetches the common shared object for accessing this users preference -// -+ (GTMGoogleSearch*)sharedInstance; - -// -// searchURLFor:ofType:arguments: -// -// creates a search url of type |type| for |queryText| using the user's -// preferred domain and language settings. |args| is a set of arguments -// that will be added into your query, and you can use it to complement -// or override settings stored in globalSearchArguments. -// example dictionary to do an I'm feeling lucky search would be: -// [NSDictionary dictionaryWithObject:@"1" key:@"btnI"]; -// If queryText is nil, no query will be put in. -// Arguments passed in in args must be properly URL escaped. -// If you want to remove one of the arguments that will be included in the -// global search arguments, set the object for the key you want to remove to -// [NSNull null]. -- (NSString*)searchURLFor:(NSString *)queryText - ofType:(NSString *)type - arguments:(NSDictionary *)args; - -// -// performQuery:ofType:arguments: -// -// Asks NSWorkspace to open up a query for an url created by passing -// the args to searchURLFor:ofType:arguments: above. -// -- (BOOL)performQuery:(NSString *)queryText - ofType:(NSString *)type - arguments:(NSDictionary *)localArgs; - -// Global search arguments are initially picked up from your main bundle -// info.plist if there is a dictionary entry at the top level with the key -// "GTMGoogleSearchClientAppArgs". This dictionary should be a map of strings -// to strings where they are the args you want passed to all Google searches. -// You can override these with your localArgs when you actually perform the -// search if you wish. -// This arguments will affect all searches. Arguments must be properly URL -// escaped. -- (void)setGlobalSearchArguments:(NSDictionary *)args; - -// Returns the global search arguments. -- (NSDictionary *)globalSearchArguments; - -// -// -preferredDomainAndLanguage:areCurrentAppOnly -// -// fetches the user's preferred domain and language, and whether the values -// that were grabbed were from the anyapplication domain, or from the current -// application domain. You may pass in nil for |language| if you don't want -// a language back, and you may pass in NULL for |currentAppOnly| if you don't -// care about where it came from. -// -- (void)preferredDomain:(NSString **)domain - language:(NSString **)language - areCurrentAppOnly:(BOOL*)currentAppOnly; - -// -// -updatePreferredDomain:language:currentApplicationOnly: -// -// updated the users preferred domain and language to copies of |domain| and -// |language| respectively. |domain| can't be nil or an empty string, but -// |language| can't be nil, but can be an empty string to signify no language -// pref. If |currentAppOnly| is YES, only updates the preferred settings for the -// current app, otherwise updates them for all apps. -// -- (void)updatePreferredDomain:(NSString *)domain - language:(NSString *)language - currentApplicationOnly:(BOOL)currentAppOnly; - -// -// -clearPreferredDomainAndLanguageForCurrentApplication -// -// clears the setting for the current applications preferred domain and -// language so future fetches will get the system level ones. -// -- (void)clearPreferredDomainAndLanguageForCurrentApplication; - -// -// -clearPreferredDomainAndLanguageForAllApps -// -// clears the "AllApps" setting for preferred domain and language so future -// fetches end up having to use the default. Odds are this is only -// used by the unittests. -// NOTE: this doesn't do anything to any setting that's set in an individual -// apps preferences, so those settings will still override inplace of the -// "all apps" value (or default). -// -- (void)clearPreferredDomainAndLanguageForAllApps; - -@end diff --git a/Foundation/GTMGoogleSearch.m b/Foundation/GTMGoogleSearch.m deleted file mode 100644 index 56dcc82..0000000 --- a/Foundation/GTMGoogleSearch.m +++ /dev/null @@ -1,534 +0,0 @@ -// -// GTMGoogleSearch.m -// -// Copyright 2006-2009 Google Inc. -// -// Licensed 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 "GTMGoogleSearch.h" -#import "GTMObjectSingleton.h" -#import "GTMGarbageCollection.h" - -#if GTM_IPHONE_SDK -#import -#endif // GTM_IPHONE_SDK - -typedef struct { - NSString *language; - NSString *country; - // we don't include a language, we'll use what we get from the OS - NSString *defaultDomain; -} LanguageDefaultInfo; - -// -// this is a seed mapping from languages to domains for google search. -// this doesn't have to be complete, as it is just a seed. -// -// -static LanguageDefaultInfo kLanguageListDefaultMappingTable[] = { - // order is important, first match is taken - // if country is |nil|, then only language has to match - { @"en", @"US", @"com" }, // english - united states - { @"en", @"GB", @"co.uk" }, // english - united kingdom - { @"en", @"CA", @"ca" }, // english - canada - { @"en", @"AU", @"com.au" }, // english - australia - { @"en", @"NZ", @"com" }, // english - new zealand - { @"en", @"IE", @"ie" }, // english - ireland - { @"en", @"IN", @"co.in" }, // english - india - { @"en", @"PH", @"com.ph" }, // english - philippines - { @"en", @"SG", @"com.sg" }, // english - singapore - { @"en", @"ZA", @"co.za" }, // english - south africa - { @"en", @"IL", @"co.il" }, // english - israel - { @"en", nil , @"com" }, // english (catch all) - { @"fr", @"CA", @"ca" }, // french - canada - { @"fr", @"CH", @"ch" }, // french - switzerland - { @"fr", nil , @"fr" }, // france - { @"it", nil , @"it" }, // italy - { @"de", @"AT", @"at" }, // german - austria - { @"de", nil , @"de" }, // germany - { @"es", @"MX", @"com.mx" }, // spanish - mexico - { @"es", @"AR", @"com.ar" }, // spanish - argentina - { @"es", @"CL", @"cl" }, // spanish - chile - { @"es", @"CO", @"com.co" }, // spanish - colombia - { @"es", @"PE", @"com.pe" }, // spanish - peru - { @"es", @"VE", @"co.ve" }, // venezuela - { @"es", nil , @"es" }, // spain - { @"zh", @"TW", @"com.tw" }, // taiwan - { @"zh", @"HK", @"com.hk" }, // hong kong - { @"zh", nil , @"cn" }, // chinese (catch all) - { @"ja", nil , @"co.jp" }, // japan - { @"ko", nil , @"co.kr" }, // korea - { @"nl", @"BE", @"be" }, // dutch - belgium - { @"nl", nil , @"nl" }, // (dutch) netherlands - { @"ru", nil , @"ru" }, // russia - { @"pt", @"BZ", @"com.br"}, // portuguese - brazil - { @"pt", nil , @"pt" }, // portugal - { @"sv", nil , @"se" }, // sweden - { @"nn", nil , @"no" }, // norway (two variants) - { @"nb", nil , @"no" }, // norway (two variants) - { @"da", nil , @"dk" }, // denmark - { @"fi", nil , @"fi" }, // finland - { @"bg", nil , @"bg" }, // bulgaria - { @"hr", nil , @"hr" }, // croatia - { @"cx", nil , @"cz" }, // czech republic - { @"el", nil , @"gr" }, // greece - { @"hu", nil , @"co.hu" }, // hungary - { @"ro", nil , @"ro" }, // romania - { @"sk", nil , @"sk" }, // slovakia - { @"sl", nil , @"si" }, // slovenia - { @"tr", nil , @"com.tr" }, // turkey - { @"my", nil , @"com.my" }, // malaysia - { @"th", nil , @"co.th" }, // thailand - { @"uk", nil , @"com.ua" }, // ukraine - { @"vi", nil , @"com.vn" }, // vietnam - { @"af", nil , @"com.za" }, // south africa (afrikaans) - { @"hi", nil , @"co.in" }, // india (hindi) - { @"id", nil , @"co.id" }, // indonesia - { @"pl", nil , @"pl" }, // poland -}; - -// the notification we use for syncing up instances in different processes -static NSString *const kNotificationName - = @"com.google.GoogleSearchAllApps.prefsWritten"; - -// this is the bundle id we use for the pref file used for all apps -static CFStringRef const kAllAppsBuildIdentifier - = CFSTR("com.google.GoogleSearchAllApps"); - -static CFStringRef const kPreferredDomainPrefKey - = CFSTR("com.google.PreferredDomain"); -static CFStringRef const kPreferredLanguagePrefKey - = CFSTR("com.google.PreferredLanguage"); - -static NSString *const kDefaultDomain = @"com"; -static NSString *const kDefaultLanguage = @"en"; - -static NSString *const kSearchURLTemplate = @"http://www.google.%@/%@?%@"; - -@interface GTMGoogleSearch (PrivateMethods) -- (void)defaultDomain:(NSString**)preferedDomain - language:(NSString**)preferredLanguage; -- (void)reloadAllAppCachedValues:(NSNotification*)notification; -- (void)updateAllAppsDomain:(NSString*)domain language:(NSString*)language; -@end - - -@implementation GTMGoogleSearch - -GTMOBJECT_SINGLETON_BOILERPLATE(GTMGoogleSearch, sharedInstance); - -- (id)init { - self = [super init]; - if (self != nil) { -#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - // register for the notification - NSDistributedNotificationCenter *distCenter = - [NSDistributedNotificationCenter defaultCenter]; - [distCenter addObserver:self - selector:@selector(reloadAllAppCachedValues:) - name:kNotificationName - object:nil]; -#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - // load the allApps value - [self reloadAllAppCachedValues:nil]; - - // load the cur app value - CFStringRef domain - = CFPreferencesCopyValue(kPreferredDomainPrefKey, - kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFStringRef lang = CFPreferencesCopyValue(kPreferredLanguagePrefKey, - kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - - // make sure we got values for both and domain is not empty - if (domain && CFStringGetLength(domain) == 0) { - CFRelease(domain); - domain = nil; - if (lang) { - CFRelease(lang); - lang = nil; - } - } - - curAppCachedDomain_ = GTMNSMakeCollectable(domain); - curAppCachedLanguage_ = GTMNSMakeCollectable(lang); - - NSBundle *bundle = [NSBundle mainBundle]; - - NSDictionary *appArgs - = [bundle objectForInfoDictionaryKey:GTMGoogleSearchClientAppArgsKey]; - globalSearchArguments_ = [appArgs retain]; - } - return self; -} - -#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS -- (void)finalize { - [[NSDistributedNotificationCenter defaultCenter] removeObject:self]; - [super finalize]; -} -#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - -- (void)dealloc { -#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - [[NSDistributedNotificationCenter defaultCenter] removeObject:self]; -#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - [allAppsCachedDomain_ release]; - [allAppsCachedLanguage_ release]; - [curAppCachedDomain_ release]; - [curAppCachedLanguage_ release]; - [globalSearchArguments_ release]; - [super dealloc]; -} - -- (void)preferredDomain:(NSString **)domain - language:(NSString**)language - areCurrentAppOnly:(BOOL*)currentAppOnly { - BOOL localCurrentAppOnly = YES; - NSString *localDomain = curAppCachedDomain_; - NSString *localLanguage = curAppCachedLanguage_; - - // if either one wasn't there, drop both, and use any app if we can - if (!localDomain || !localLanguage) { - localCurrentAppOnly = NO; - localDomain = allAppsCachedDomain_; - localLanguage = allAppsCachedLanguage_; - - // if we didn't get anything from the prefs, go with the defaults - if (!localDomain || !localLanguage) { - // if either one wasn't there, drop both, and use defaults - [self defaultDomain:&localDomain language:&localLanguage]; - } - } - if (!localDomain || !localLanguage) { - _GTMDevLog(@"GTMGoogleSearch: Failed to get the preferred domain/language " - @"from prefs or defaults"); - } - if (language) { - *language = [[localLanguage retain] autorelease]; - } - if (domain) { - *domain = [[localDomain retain] autorelease]; - } - if (currentAppOnly) { - *currentAppOnly = localCurrentAppOnly; - } -} - -- (void)updatePreferredDomain:(NSString*)domain - language:(NSString*)language - currentApplicationOnly:(BOOL)currentAppOnly { - // valid inputs? - if (!domain || ![domain length] || !language) { - return; - } - - if (currentAppOnly) { - // if they are the same, don't do anything - if ((domain == nil && curAppCachedDomain_ == nil && - language == nil && curAppCachedLanguage_ == nil) || - ([domain isEqualToString:curAppCachedDomain_] && - [language isEqualToString:curAppCachedLanguage_])) { - return; - } - - // save them out - CFPreferencesSetValue(kPreferredDomainPrefKey, - (CFStringRef)domain, - kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFPreferencesSetValue(kPreferredLanguagePrefKey, - (CFStringRef)language, - kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFPreferencesSynchronize(kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - // update our locals - [curAppCachedDomain_ release]; - [curAppCachedLanguage_ release]; - curAppCachedDomain_ = [domain copy]; - curAppCachedLanguage_ = [language copy]; - } else { - // Set the "any application" values - [self updateAllAppsDomain:domain language:language]; - - // Clear the current application values (if there were any) - [self clearPreferredDomainAndLanguageForCurrentApplication]; - } -} - -- (void)clearPreferredDomainAndLanguageForCurrentApplication { - // flush what's in the file - CFPreferencesSetValue(kPreferredDomainPrefKey, - NULL, - kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFPreferencesSetValue(kPreferredLanguagePrefKey, - NULL, - kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFPreferencesSynchronize(kCFPreferencesCurrentApplication, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - // clear our locals - [curAppCachedDomain_ release]; - [curAppCachedLanguage_ release]; - curAppCachedDomain_ = nil; - curAppCachedLanguage_ = nil; -} - -- (void)clearPreferredDomainAndLanguageForAllApps { - // nil/nil to clear things out, this will also update our cached values. - [self updateAllAppsDomain:nil language:nil]; -} - -- (NSDictionary *)globalSearchArguments { - return globalSearchArguments_; -} - -- (void)setGlobalSearchArguments:(NSDictionary *)args { - [globalSearchArguments_ autorelease]; - globalSearchArguments_ = [args copy]; -} - -- (NSString*)searchURLFor:(NSString*)queryText - ofType:(NSString*)type - arguments:(NSDictionary *)localArgs { - if (!type) { - return nil; - } - - NSString *language; - NSString *domain; - [self preferredDomain:&domain - language:&language - areCurrentAppOnly:NULL]; - - NSMutableDictionary *args - = [NSMutableDictionary dictionaryWithObjectsAndKeys: - @"UTF-8", @"ie", - @"UTF-8", @"oe", - language, @"hl", - nil]; - if (queryText) { - [args setObject:queryText forKey:@"q"]; - } - - NSDictionary *globalSearchArgs = [self globalSearchArguments]; - if (globalSearchArgs) { - [args addEntriesFromDictionary:globalSearchArgs]; - } - if (localArgs) { - [args addEntriesFromDictionary:localArgs]; - } - - NSMutableArray *clientArgs = [NSMutableArray array]; - NSString *key; - NSNull *nsNull = [NSNull null]; - GTM_FOREACH_KEY(key, args) { - NSString *object = [args objectForKey:key]; - if (![object isEqual:nsNull]) { -#if DEBUG - // In debug we check key and object for things that should be escaped. - // Note that percent is not in there because escaped strings will have - // percents in them - NSCharacterSet *cs = [NSCharacterSet characterSetWithCharactersInString: - @"!*'();:@&=+$,/?#[] "]; - NSRange range = [key rangeOfCharacterFromSet:cs]; - if (range.location != NSNotFound) { - _GTMDevLog(@"Unescaped string %@ in argument pair {%@, %@} in -[%@ %@]", - key, key, object, [self class], NSStringFromSelector(_cmd)); - } - range = [object rangeOfCharacterFromSet:cs]; - if (range.location != NSNotFound) { - _GTMDevLog(@"Unescaped string %@ in argument pair {%@,%@ } in -[%@ %@]", - object, key, object, [self class], - NSStringFromSelector(_cmd)); - } -#endif // DEBUG - NSString *arg = [NSString stringWithFormat:@"%@=%@", key, object]; - [clientArgs addObject:arg]; - } - } - NSString *clientArg = [clientArgs componentsJoinedByString:@"&"]; - NSString *url = [NSString stringWithFormat:kSearchURLTemplate, - domain, type, clientArg]; - return url; -} - -- (BOOL)performQuery:(NSString*)queryText - ofType:(NSString *)type - arguments:(NSDictionary *)localArgs { - BOOL success = NO; - NSString *urlString = [self searchURLFor:queryText - ofType:type - arguments:localArgs]; - if (urlString) { - NSURL *url = [NSURL URLWithString:urlString]; - if (url) { -#if GTM_IPHONE_SDK - success = [[UIApplication sharedApplication] openURL:url]; -#else // GTM_IPHONE_SDK - success = [[NSWorkspace sharedWorkspace] openURL:url]; -#endif // GTM_IPHONE_SDK - } - } - return success; -} - -@end - - -@implementation GTMGoogleSearch (PrivateMethods) - -- (void)defaultDomain:(NSString**)preferredDomain - language:(NSString**)preferredLanguage { - // must have both - if (!preferredDomain || !preferredLanguage) { - return; - } - - // make sure they are clear to start - *preferredDomain = nil; - *preferredLanguage = nil; - - // loop over their language list trying to find something we have in - // out default table. - - NSUserDefaults* defs = [NSUserDefaults standardUserDefaults]; - NSArray* languages = [defs objectForKey:@"AppleLanguages"]; - // the current locale is only based on what languages the running apps is - // localized to, so we stick that at the end in case we weren't able to - // find anything else as a match, we'll match that. - languages = - [languages arrayByAddingObject:[[NSLocale currentLocale] localeIdentifier]]; - - NSEnumerator *enumerator = [languages objectEnumerator]; - NSString *localeIdentifier; - while ((localeIdentifier = [enumerator nextObject])) { - NSDictionary *localeParts - = [NSLocale componentsFromLocaleIdentifier:localeIdentifier]; - NSString *localeLanguage = [localeParts objectForKey:NSLocaleLanguageCode]; - // we don't use NSLocaleScriptCode for now - NSString *localeCountry = [localeParts objectForKey:NSLocaleCountryCode]; - - LanguageDefaultInfo *scan = kLanguageListDefaultMappingTable; - LanguageDefaultInfo *end = (scan + (sizeof(kLanguageListDefaultMappingTable) - / sizeof(LanguageDefaultInfo))); - // find a match - // check language, and if country is not nil, check that - for ( ; scan < end ; ++scan) { - if ([localeLanguage isEqualToString:scan->language] && - (!(scan->country) || [localeCountry isEqualToString:scan->country])) { - *preferredDomain = scan->defaultDomain; - *preferredLanguage = localeLanguage; - return; // out of here - } - } - } - - *preferredDomain = kDefaultDomain; - *preferredLanguage = kDefaultLanguage; -} - -// -reloadAllAppCachedValues: -// -- (void)reloadAllAppCachedValues:(NSNotification*)notification { - // drop the old... - [allAppsCachedDomain_ release]; - [allAppsCachedLanguage_ release]; - allAppsCachedDomain_ = nil; - allAppsCachedLanguage_ = nil; - - // load the new - CFPreferencesSynchronize(kAllAppsBuildIdentifier, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFStringRef domain = CFPreferencesCopyValue(kPreferredDomainPrefKey, - kAllAppsBuildIdentifier, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFStringRef lang = CFPreferencesCopyValue(kPreferredLanguagePrefKey, - kAllAppsBuildIdentifier, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - - // make sure we got values for both and domain is not empty - if (domain && CFStringGetLength(domain) == 0) { - CFRelease(domain); - domain = nil; - if (lang) { - CFRelease(lang); - lang = nil; - } - } - - allAppsCachedDomain_ = GTMNSMakeCollectable(domain); - allAppsCachedLanguage_ = GTMNSMakeCollectable(lang); -} - -// -updateAllAppsDomain:language: -// -- (void)updateAllAppsDomain:(NSString*)domain language:(NSString*)language { - // domain and language can be nil to clear the values - - // if they are the same, don't do anything - if ((domain == nil && allAppsCachedDomain_ == nil && - language == nil && allAppsCachedLanguage_ == nil) || - ([domain isEqualToString:allAppsCachedDomain_] && - [language isEqualToString:allAppsCachedLanguage_])) { - return; - } - - // write it to the file - CFPreferencesSetValue(kPreferredDomainPrefKey, - (CFStringRef)domain, - kAllAppsBuildIdentifier, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFPreferencesSetValue(kPreferredLanguagePrefKey, - (CFStringRef)language, - kAllAppsBuildIdentifier, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - CFPreferencesSynchronize(kAllAppsBuildIdentifier, - kCFPreferencesCurrentUser, - kCFPreferencesAnyHost); - - // update our values - [allAppsCachedDomain_ release]; - [allAppsCachedLanguage_ release]; - allAppsCachedDomain_ = [domain copy]; - allAppsCachedLanguage_ = [language copy]; - -#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - // NOTE: we'll go ahead and reload when this comes back to ourselves since - // there is a race here if two folks wrote at about the same time. - NSDistributedNotificationCenter *distCenter = - [NSDistributedNotificationCenter defaultCenter]; - [distCenter postNotificationName:kNotificationName - object:nil - userInfo:nil]; -#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS -} - -@end diff --git a/Foundation/GTMGoogleSearchTest.m b/Foundation/GTMGoogleSearchTest.m deleted file mode 100644 index 45f7e66..0000000 --- a/Foundation/GTMGoogleSearchTest.m +++ /dev/null @@ -1,208 +0,0 @@ -// -// GTMGoogleSearchTest.m -// -// Copyright 2006-2009 Google Inc. -// -// Licensed 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 "GTMGoogleSearch.h" -#import "GTMSenTestCase.h" -#import "GTMUnitTestDevLog.h" -#import - -@interface GTMGoogleSearchTest : GTMTestCase -@end - -@implementation GTMGoogleSearchTest - -- (void)testSearches { - typedef struct { - NSString *type; - NSString *expectedPrefix; - } TestSearchDesc; - static TestSearchDesc testSearches[] = { - { GTMGoogleSearchFroogle, @"http://www.google.xxx/products?" }, - { GTMGoogleSearchGroups, @"http://www.google.xxx/groups?" }, - { GTMGoogleSearchImages, @"http://www.google.xxx/images?"}, - { GTMGoogleSearchLocal, @"http://www.google.xxx/local?"}, - { GTMGoogleSearchNews, @"http://www.google.xxx/news?"}, - { GTMGoogleSearchFinance, @"http://www.google.xxx/finance?"}, - { GTMGoogleSearchBooks, @"http://www.google.xxx/books?"}, - { GTMGoogleSearchWeb, @"http://www.google.xxx/search?"}, - }; - - GTMGoogleSearch *googleSearch = [GTMGoogleSearch sharedInstance]; - STAssertNotNil(googleSearch, nil); - - // force the current app values so we aren't at the mercy of the - // global setting the users locale. - [googleSearch updatePreferredDomain:@"xxx" - language:@"yyy" - currentApplicationOnly:TRUE]; - - size_t count = sizeof(testSearches) / sizeof(testSearches[0]); - NSDictionary *globalArgs - = [NSDictionary dictionaryWithObject:@"f" forKey:@"foo"]; - [googleSearch setGlobalSearchArguments:globalArgs]; - NSDictionary *args = [NSDictionary dictionaryWithObject:@"Baba" - forKey:@"BaR"]; - NSString *expectedStrings[] = { - @"oe=UTF-8", @"hl=yyy", @"q=Foobar", - @"foo=f", @"ie=UTF-8", @"BaR=Baba" - }; - for (size_t i = 0; i < count; i++) { - // test building the url - NSString *urlString = [googleSearch searchURLFor:@"Foobar" - ofType:testSearches[i].type - arguments:args]; - STAssertTrue([urlString hasPrefix:testSearches[i].expectedPrefix], - @"Bad URL? URL:%@ Expected Prefix:%@", - urlString, testSearches[i].expectedPrefix); - for (size_t j = 0; - j < sizeof(expectedStrings) / sizeof(expectedStrings[0]); - ++j) { - STAssertGreaterThan([urlString rangeOfString:expectedStrings[j]].length, - (NSUInteger)0, @"URL: %@ expectedString: %@", - urlString, expectedStrings[j]); - } - } - - // clear what we just set for this test - [googleSearch setGlobalSearchArguments:nil]; - [googleSearch clearPreferredDomainAndLanguageForCurrentApplication]; -} - -- (void)testBadInputs { - GTMGoogleSearch *googleSearch = [GTMGoogleSearch sharedInstance]; - STAssertNotNil(googleSearch, nil); - NSDictionary *args = [NSDictionary dictionaryWithObject:@"Ba!ba" - forKey:@"Ba=R"]; - [GTMUnitTestDevLogDebug expectString: - @"Unescaped string Foo bar in argument pair {q,Foo bar } " - @"in -[GTMGoogleSearch searchURLFor:ofType:arguments:]"]; - [GTMUnitTestDevLogDebug expectString: - @"Unescaped string Ba=R in argument pair {Ba=R, Ba!ba} " - @"in -[GTMGoogleSearch searchURLFor:ofType:arguments:]"]; - [GTMUnitTestDevLogDebug expectString: - @"Unescaped string Ba!ba in argument pair {Ba=R,Ba!ba } " - @"in -[GTMGoogleSearch searchURLFor:ofType:arguments:]"]; - NSString *urlString = [googleSearch searchURLFor:@"Foo bar" - ofType:GTMGoogleSearchFroogle - arguments:args]; - STAssertNotNil(urlString, nil); -} - -- (void)testPreferredDefaults { - GTMGoogleSearch *googleSearch = [GTMGoogleSearch sharedInstance]; - STAssertNotNil(googleSearch, nil); - - // hey, we're a unit test, so start by blowing away what we have at the - // app level. - [googleSearch clearPreferredDomainAndLanguageForCurrentApplication]; - - // in theory, we could fetch now and save off what we get to reset at the - // end of this, but we can't tell if that was an "all apps" setting, or if - // it was the default, so...hey, we're a unit test, we'll just stomp what's - // there and clear it out when done... - [googleSearch clearPreferredDomainAndLanguageForAllApps]; - - // make sure the individual accessors work... - - // since they system level default can be set by any app, we just have to - // check for non nil here (also the users locale could control what - // we get if nothing is set). - NSString *domain; - NSString *lang; - // now do a detailed check... - BOOL areCurrentAppOnly = YES; - [googleSearch preferredDomain:&domain - language:&lang - areCurrentAppOnly:&areCurrentAppOnly]; - // should get something for defaults... - STAssertNotNil(domain, nil); - STAssertNotNil(lang, nil); - STAssertFalse(areCurrentAppOnly, nil); - - // test it for "all apps"... - [googleSearch updatePreferredDomain:@"domain" - language:@"lang" - currentApplicationOnly:NO]; - [googleSearch preferredDomain:&domain - language:&lang - areCurrentAppOnly:&areCurrentAppOnly]; - STAssertEqualObjects(domain, @"domain", nil); - STAssertEqualObjects(lang, @"lang", nil); - STAssertFalse(areCurrentAppOnly, nil); - - // test it for this app... - [googleSearch updatePreferredDomain:@"domainThisApp" - language:@"langThisApp" - currentApplicationOnly:YES]; - [googleSearch preferredDomain:&domain - language:&lang - areCurrentAppOnly:&areCurrentAppOnly]; - STAssertEqualObjects(domain, @"domainThisApp", nil); - STAssertEqualObjects(lang, @"langThisApp", nil); - STAssertTrue(areCurrentAppOnly, nil); - - // clear what we just set for this app - [googleSearch clearPreferredDomainAndLanguageForCurrentApplication]; - - // should get back what we set for all apps - [googleSearch preferredDomain:&domain - language:&lang - areCurrentAppOnly:&areCurrentAppOnly]; - STAssertEqualObjects(domain, @"domain", nil); - STAssertEqualObjects(lang, @"lang", nil); - STAssertFalse(areCurrentAppOnly, nil); -#if GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - // We don't test launching other tasks on the phone since this isn't a valid - // case until we can support real multiple tasks on the phone. - - // try changing the value directly in the plist file (as if another app had - // done it) and sending our notification. - [[NSTask launchedTaskWithLaunchPath:@"/usr/bin/defaults" - arguments:[NSArray arrayWithObjects:@"write", - @"com.google.GoogleSearchAllApps", - @"{ \"com.google.PreferredDomain\" = xxx;" - @"\"com.google.PreferredLanguage\" = yyy; }", - nil]] waitUntilExit]; - // Sleep for a moment to let things flush - // (seen rarely as a problem on aharper's machine). - sleep(1); - NSDistributedNotificationCenter *distCenter = - [NSDistributedNotificationCenter defaultCenter]; - [distCenter postNotificationName:@"com.google.GoogleSearchAllApps.prefsWritten" - object:nil - userInfo:nil - options:NSNotificationDeliverImmediately]; - - // Spin the runloop so the notifications fire. - NSRunLoop *currentLoop = [NSRunLoop currentRunLoop]; - [currentLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]]; - // did we get what we expected? - [googleSearch preferredDomain:&domain - language:&lang - areCurrentAppOnly:&areCurrentAppOnly]; - STAssertEqualObjects(domain, @"xxx", nil); - STAssertEqualObjects(lang, @"yyy", nil); - STAssertFalse(areCurrentAppOnly, nil); -#endif // GTM_GOOGLE_SEARCH_SUPPORTS_DISTRIBUTED_NOTIFICATIONS - - // lastly, clean up what we set for all apps to leave the system at the - // default. - [googleSearch clearPreferredDomainAndLanguageForAllApps]; -} - -@end diff --git a/Foundation/GTMLogger.h b/Foundation/GTMLogger.h index 3ebb366..6223999 100644 --- a/Foundation/GTMLogger.h +++ b/Foundation/GTMLogger.h @@ -55,12 +55,6 @@ // Predeclaration of used protocols that are declared later in this file. @protocol GTMLogWriter, GTMLogFormatter, GTMLogFilter; -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 -#define CHECK_FORMAT_NSSTRING(a, b) __attribute__((format(__NSString__, a, b))) -#else -#define CHECK_FORMAT_NSSTRING(a, b) -#endif - // GTMLogger // // GTMLogger is the primary user-facing class for an object-oriented logging @@ -274,13 +268,13 @@ // // Logs a message at the debug level (kGTMLoggerLevelDebug). -- (void)logDebug:(NSString *)fmt, ... CHECK_FORMAT_NSSTRING(1, 2); +- (void)logDebug:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); // Logs a message at the info level (kGTMLoggerLevelInfo). -- (void)logInfo:(NSString *)fmt, ... CHECK_FORMAT_NSSTRING(1, 2); +- (void)logInfo:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); // Logs a message at the error level (kGTMLoggerLevelError). -- (void)logError:(NSString *)fmt, ... CHECK_FORMAT_NSSTRING(1, 2); +- (void)logError:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); // Logs a message at the assert level (kGTMLoggerLevelAssert). -- (void)logAssert:(NSString *)fmt, ... CHECK_FORMAT_NSSTRING(1, 2); +- (void)logAssert:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); // @@ -310,13 +304,13 @@ // enable the logging of function names. @interface GTMLogger (GTMLoggerMacroHelpers) - (void)logFuncDebug:(const char *)func msg:(NSString *)fmt, ... - CHECK_FORMAT_NSSTRING(2, 3); + NS_FORMAT_FUNCTION(2, 3); - (void)logFuncInfo:(const char *)func msg:(NSString *)fmt, ... - CHECK_FORMAT_NSSTRING(2, 3); + NS_FORMAT_FUNCTION(2, 3); - (void)logFuncError:(const char *)func msg:(NSString *)fmt, ... - CHECK_FORMAT_NSSTRING(2, 3); + NS_FORMAT_FUNCTION(2, 3); - (void)logFuncAssert:(const char *)func msg:(NSString *)fmt, ... - CHECK_FORMAT_NSSTRING(2, 3); + NS_FORMAT_FUNCTION(2, 3); @end // GTMLoggerMacroHelpers @@ -407,7 +401,7 @@ typedef enum { - (NSString *)stringForFunc:(NSString *)func withFormat:(NSString *)fmt valist:(va_list)args - level:(GTMLoggerLevel)level; + level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); @end // GTMLogFormatter diff --git a/Foundation/GTMLogger.m b/Foundation/GTMLogger.m index de941d2..e40defc 100644 --- a/Foundation/GTMLogger.m +++ b/Foundation/GTMLogger.m @@ -37,7 +37,7 @@ - (void)logInternalFunc:(const char *)func format:(NSString *)fmt valist:(va_list)args - level:(GTMLoggerLevel)level; + level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); @end @@ -332,15 +332,9 @@ static GTMLogger *gSharedLogger = nil; withFormat:(NSString *)fmt valist:(va_list)args level:(GTMLoggerLevel)level { - // Performance note: since we always have to create a new NSString from the - // returned CFStringRef, we may want to do a quick check here to see if |fmt| + // Performance note: We may want to do a quick check here to see if |fmt| // contains a '%', and if not, simply return 'fmt'. - CFStringRef cfmsg = NULL; - cfmsg = CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, - NULL, // format options - (CFStringRef)fmt, - args); - return GTMCFAutorelease(cfmsg); + return [[[NSString alloc] initWithFormat:fmt arguments:args] autorelease]; } @end // GTMLogBasicFormatter diff --git a/Foundation/GTMRegex.m b/Foundation/GTMRegex.m index 4c393a6..f4d6362 100644 --- a/Foundation/GTMRegex.m +++ b/Foundation/GTMRegex.m @@ -719,13 +719,14 @@ static NSString *const kReplacementPattern = [NSMutableString stringWithFormat:@"%@<%p> { isMatch=\"%s\", subPatterns=(", [self class], self, (isMatch_ ? "YES" : "NO")]; for (NSUInteger x = 0; x <= numRegMatches_; ++x) { - NSString *format = @", \"%.*s\""; - if (x == 0) - format = @" \"%.*s\""; - - [result appendFormat:format, - (int)(regMatches_[x].rm_eo - regMatches_[x].rm_so), - (((const char*)[utf8StrBuf_ bytes]) + regMatches_[x].rm_so)]; + NSInteger length = (NSInteger)(regMatches_[x].rm_eo - regMatches_[x].rm_so); + const char* string + = (((const char*)[utf8StrBuf_ bytes]) + regMatches_[x].rm_so); + if (x == 0) { + [result appendFormat:@" \"%.*s\"", length , string]; + } else { + [result appendFormat:@", \"%.*s\"", length , string]; + } } [result appendString:@" ) }"]; diff --git a/Foundation/GTMSQLiteTest.m b/Foundation/GTMSQLiteTest.m index 50e893e..a158a4f 100644 --- a/Foundation/GTMSQLiteTest.m +++ b/Foundation/GTMSQLiteTest.m @@ -1778,7 +1778,7 @@ static NSArray* LikeGlobTestHelper(GTMSQLiteDatabase *db, NSString *sql) { @"-[GTMSQLiteStatement finalizeStatement] must be called " @"when statement is no longer needed"; - [GTMUnitTestDevLog expectString:expectedLog]; + [GTMUnitTestDevLog expectString:@"%@", expectedLog]; [GTMUnitTestDevLog expectPattern:@"Unable to close .*"]; [localPool drain]; diff --git a/Foundation/GTMScriptRunnerTest.m b/Foundation/GTMScriptRunnerTest.m index 1da7f78..f13fe6c 100644 --- a/Foundation/GTMScriptRunnerTest.m +++ b/Foundation/GTMScriptRunnerTest.m @@ -382,34 +382,34 @@ STAssertNotNil(sr, @"Script runner must not be nil"); NSString *output = nil, *err = nil, *cmd = nil; - NSString *generator_format_str = - @"import sys\n" - @"block = '.' * 512\n" - @"for x in [%@]:\n" - @" to_where = x[0]\n" - @" how_many = int(x[1:])\n" - @" for x in xrange(0, how_many):\n" - @" if to_where in [ 'o', 'b' ]:\n" - @" sys.stdout.write(block)\n" - @" if to_where in [ 'e', 'b' ]:\n" - @" sys.stderr.write(block)\n"; + #define GENERATOR_FORMAT_STR \ + @"import sys\n" \ + @"block = '.' * 512\n" \ + @"for x in [%@]:\n" \ + @" to_where = x[0]\n" \ + @" how_many = int(x[1:])\n" \ + @" for x in xrange(0, how_many):\n" \ + @" if to_where in [ 'o', 'b' ]:\n" \ + @" sys.stdout.write(block)\n" \ + @" if to_where in [ 'e', 'b' ]:\n" \ + @" sys.stderr.write(block)\n" // Make sure we get both blocks - cmd = [NSString stringWithFormat:generator_format_str, @"'b1'"]; + cmd = [NSString stringWithFormat:GENERATOR_FORMAT_STR, @"'b1'"]; STAssertNotNil(cmd, nil); output = [sr run:cmd standardError:&err]; STAssertEquals([output length], (NSUInteger)512, nil); STAssertEquals([err length], (NSUInteger)512, nil); // Test a large amount of data on only one connections at a time. - cmd = [NSString stringWithFormat:generator_format_str, @"'b1', 'o200'"]; + cmd = [NSString stringWithFormat:GENERATOR_FORMAT_STR, @"'b1', 'o200'"]; STAssertNotNil(cmd, nil); output = [sr run:cmd standardError:&err]; STAssertEquals([output length], (NSUInteger)(512 + 512*200), nil); STAssertEquals([err length], (NSUInteger)512, nil); #if 0 // Not fixed yet - cmd = [NSString stringWithFormat:generator_format_str, @"'b1', 'e200'"]; + cmd = [NSString stringWithFormat:GENERATOR_FORMAT_STR, @"'b1', 'e200'"]; STAssertNotNil(cmd, nil); output = [sr run:cmd standardError:&err]; STAssertEquals([output length], (NSUInteger)512, nil); @@ -419,7 +419,7 @@ // Now send a large amount down both to make sure we spool it all in. #if 0 // Not fixed yet - cmd = [NSString stringWithFormat:generator_format_str, @"'b200'"]; + cmd = [NSString stringWithFormat:GENERATOR_FORMAT_STR, @"'b200'"]; STAssertNotNil(cmd, nil); output = [sr run:cmd standardError:&err]; STAssertEquals([output length], (NSUInteger)(512*200), nil); diff --git a/Foundation/GTMStackTrace.h b/Foundation/GTMStackTrace.h index d8cc642..6574ab8 100644 --- a/Foundation/GTMStackTrace.h +++ b/Foundation/GTMStackTrace.h @@ -16,7 +16,7 @@ // the License. // -#include +#import #import "GTMDefines.h" #ifdef __cplusplus diff --git a/Foundation/GTMTransientRootProxyTest.m b/Foundation/GTMTransientRootProxyTest.m index 70b69a1..081aff3 100644 --- a/Foundation/GTMTransientRootProxyTest.m +++ b/Foundation/GTMTransientRootProxyTest.m @@ -63,7 +63,7 @@ enum { [NSThread exit]; } - NSConnection *conn = [NSConnection defaultConnection]; + NSConnection *conn = [[[NSConnection alloc] init] autorelease]; [conn setRootObject:self]; if (![conn registerName:serverName]) { _GTMDevLog(@"Failed to register DO root object with name '%@'", diff --git a/GTM.xcodeproj/project.pbxproj b/GTM.xcodeproj/project.pbxproj index 7903141..51c6121 100644 --- a/GTM.xcodeproj/project.pbxproj +++ b/GTM.xcodeproj/project.pbxproj @@ -189,6 +189,9 @@ 8B8EC8800EF17C2F0044D13F /* GTMNSFileManager+CarbonTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B8EC87F0EF17C2F0044D13F /* GTMNSFileManager+CarbonTest.m */; }; 8BA01B5D0F144BD800926923 /* GTMNSWorkspace+Running.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BA01B5B0F144BD800926923 /* GTMNSWorkspace+Running.m */; }; 8BA01B5E0F144BD800926923 /* GTMNSWorkspace+Running.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BA01B5C0F144BD800926923 /* GTMNSWorkspace+Running.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8BA7148111B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 8BA7147E11B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff */; }; + 8BA7148211B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 8BA7147F11B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff */; }; + 8BA7148311B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 8BA7148011B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff */; }; 8BA9FAF9119CA2E300E264C3 /* GTMUnitTestingTestApp.10.6.gtmUTState in Resources */ = {isa = PBXBuildFile; fileRef = 8BA9FAF8119CA2E300E264C3 /* GTMUnitTestingTestApp.10.6.gtmUTState */; }; 8BA9FB23119CA3F200E264C3 /* GTMUnitTestingWindow.10.6.gtmUTState in Resources */ = {isa = PBXBuildFile; fileRef = 8BA9FB22119CA3F200E264C3 /* GTMUnitTestingWindow.10.6.gtmUTState */; }; 8BA9FB8F119CAE7200E264C3 /* GTMUILocalizerAndLayoutTweakerTest4-1.10.6.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 8BA9FB8E119CAE7200E264C3 /* GTMUILocalizerAndLayoutTweakerTest4-1.10.6.tiff */; }; @@ -241,6 +244,9 @@ 8BAA9EFA0F7C2AB500DF4F12 /* GTMNSColor+LuminanceTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F511DF50F4B0378009F41B6 /* GTMNSColor+LuminanceTest.m */; }; 8BAA9EFB0F7C2AB500DF4F12 /* GTMNSImage+ScalingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F3EB3930E5E0A2100A7A75E /* GTMNSImage+ScalingTest.m */; }; 8BAA9EFC0F7C2AB500DF4F12 /* GTMNSWorkspace+RunningTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BA01B5F0F144BE500926923 /* GTMNSWorkspace+RunningTest.m */; }; + 8BB77A0511B5A09900AB31AF /* GTMGoogleSearchTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BB77A0311B5A09900AB31AF /* GTMGoogleSearchTest.m */; }; + 8BB77A0611B5A0A100AB31AF /* GTMGoogleSearch.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BB77A0211B5A09900AB31AF /* GTMGoogleSearch.m */; }; + 8BB7802E11B6C4EA00AB31AF /* GTMGoogleSearch.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BB77A0111B5A09900AB31AF /* GTMGoogleSearch.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8BC045C20DAE899100C2D1CA /* GTMGeometryUtilsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F48FE2800D198D0E009257D2 /* GTMGeometryUtilsTest.m */; }; 8BC046B90DAE8C4B00C2D1CA /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8BC046B80DAE8C4B00C2D1CA /* ApplicationServices.framework */; }; 8BC04CD80DB003D800C2D1CA /* GTMMethodCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B6F31F40DA3489B0052CA40 /* GTMMethodCheck.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -261,9 +267,6 @@ 8BEEA90E0DA7446300894774 /* GTMUnitTestingWindow.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 8BEEA90B0DA7446300894774 /* GTMUnitTestingWindow.tiff */; }; 8BEEA90F0DA7446300894774 /* GTMUnitTestingView.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 8BEEA90C0DA7446300894774 /* GTMUnitTestingView.tiff */; }; 8BF2555310F65B56000490C8 /* GTMTypeCasting.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BF2555110F65B56000490C8 /* GTMTypeCasting.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 8BF4D2E60FC7073A009ABC3F /* GTMGoogleSearch.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BF4D2E30FC7073A009ABC3F /* GTMGoogleSearch.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 8BF4D2E70FC7073A009ABC3F /* GTMGoogleSearch.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BF4D2E40FC7073A009ABC3F /* GTMGoogleSearch.m */; }; - 8BF4D2E80FC70751009ABC3F /* GTMGoogleSearchTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BF4D2E20FC7073A009ABC3F /* GTMGoogleSearchTest.m */; }; 8BFE13B60FB0F2C0001BE894 /* GTMABAddressBook.h in Headers */ = {isa = PBXBuildFile; fileRef = 8BFE13B00FB0F2B9001BE894 /* GTMABAddressBook.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8BFE13B70FB0F2C0001BE894 /* GTMABAddressBook.m in Sources */ = {isa = PBXBuildFile; fileRef = 8BFE13B10FB0F2B9001BE894 /* GTMABAddressBook.m */; }; 8BFE13ED0FB0F2D8001BE894 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; }; @@ -681,6 +684,9 @@ 8BA01B5B0F144BD800926923 /* GTMNSWorkspace+Running.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSWorkspace+Running.m"; sourceTree = ""; }; 8BA01B5C0F144BD800926923 /* GTMNSWorkspace+Running.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTMNSWorkspace+Running.h"; sourceTree = ""; }; 8BA01B5F0F144BE500926923 /* GTMNSWorkspace+RunningTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSWorkspace+RunningTest.m"; sourceTree = ""; }; + 8BA7147E11B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff"; sourceTree = ""; }; + 8BA7147F11B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff"; sourceTree = ""; }; + 8BA7148011B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff"; sourceTree = ""; }; 8BA9FAF8119CA2E300E264C3 /* GTMUnitTestingTestApp.10.6.gtmUTState */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = GTMUnitTestingTestApp.10.6.gtmUTState; sourceTree = ""; }; 8BA9FB22119CA3F200E264C3 /* GTMUnitTestingWindow.10.6.gtmUTState */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = GTMUnitTestingWindow.10.6.gtmUTState; sourceTree = ""; }; 8BA9FB8E119CAE7200E264C3 /* GTMUILocalizerAndLayoutTweakerTest4-1.10.6.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "GTMUILocalizerAndLayoutTweakerTest4-1.10.6.tiff"; sourceTree = ""; }; @@ -723,6 +729,9 @@ 8BAA9B540F7B4A5000DF4F12 /* GTMHotKeyTextFieldTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMHotKeyTextFieldTest.h; sourceTree = ""; }; 8BAA9B560F7B4C2400DF4F12 /* GTMHotKeyTextFieldTest.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GTMHotKeyTextFieldTest.xib; sourceTree = ""; }; 8BAA9E370F7C19D500DF4F12 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = UnitTesting/GTMUIUnitTestingHarness/English.lproj/MainMenu.xib; sourceTree = ""; }; + 8BB77A0111B5A09900AB31AF /* GTMGoogleSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMGoogleSearch.h; sourceTree = ""; }; + 8BB77A0211B5A09900AB31AF /* GTMGoogleSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMGoogleSearch.m; sourceTree = ""; }; + 8BB77A0311B5A09900AB31AF /* GTMGoogleSearchTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMGoogleSearchTest.m; sourceTree = ""; }; 8BC046B80DAE8C4B00C2D1CA /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = ""; }; 8BC04D140DB0061300C2D1CA /* RunMacOSUnitTests.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = RunMacOSUnitTests.sh; sourceTree = ""; }; 8BD35B8E0FB22980009058F5 /* GTMNSScanner+JSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTMNSScanner+JSON.h"; sourceTree = ""; }; @@ -740,9 +749,6 @@ 8BEEA90B0DA7446300894774 /* GTMUnitTestingWindow.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = GTMUnitTestingWindow.tiff; sourceTree = ""; }; 8BEEA90C0DA7446300894774 /* GTMUnitTestingView.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = GTMUnitTestingView.tiff; sourceTree = ""; }; 8BF2555110F65B56000490C8 /* GTMTypeCasting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMTypeCasting.h; sourceTree = ""; }; - 8BF4D2E20FC7073A009ABC3F /* GTMGoogleSearchTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMGoogleSearchTest.m; sourceTree = ""; }; - 8BF4D2E30FC7073A009ABC3F /* GTMGoogleSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMGoogleSearch.h; sourceTree = ""; }; - 8BF4D2E40FC7073A009ABC3F /* GTMGoogleSearch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMGoogleSearch.m; sourceTree = ""; }; 8BFE13B00FB0F2B9001BE894 /* GTMABAddressBook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMABAddressBook.h; sourceTree = ""; }; 8BFE13B10FB0F2B9001BE894 /* GTMABAddressBook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMABAddressBook.m; sourceTree = ""; }; 8BFE13B20FB0F2B9001BE894 /* GTMABAddressBook.strings */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; path = GTMABAddressBook.strings; sourceTree = ""; }; @@ -1191,6 +1197,9 @@ F4FC333A104EE94F000AB7BC /* GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.tiff */, F4FC333B104EE94F000AB7BC /* GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.tiff */, F4FC333C104EE94F000AB7BC /* GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.tiff */, + 8BA7147E11B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff */, + 8BA7147F11B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff */, + 8BA7148011B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff */, F4C0B9D7108E3142002FC8E4 /* GTMUILocalizerAndLayoutTweakerTest5-0.tiff */, 8BA9FC65119CB3E200E264C3 /* GTMUILocalizerAndLayoutTweakerTest5-0.10.6.tiff */, F4C0B9D8108E3142002FC8E4 /* GTMUILocalizerAndLayoutTweakerTest5-1.tiff */, @@ -1267,6 +1276,9 @@ 7F97DB2F104EBC8D004DDDEE /* GTMFadeTruncatingTextFieldCellTest.m */, 8B58E9940E547EB000A0E02E /* GTMGetURLHandler.m */, 8B8B10FF0EEB8CD000E543D0 /* GTMGetURLHandlerTest.m */, + 8BB77A0111B5A09900AB31AF /* GTMGoogleSearch.h */, + 8BB77A0211B5A09900AB31AF /* GTMGoogleSearch.m */, + 8BB77A0311B5A09900AB31AF /* GTMGoogleSearchTest.m */, F4A420EC0EDDF8E000397A11 /* GTMHotKeyTextField.h */, F4A420ED0EDDF8E000397A11 /* GTMHotKeyTextField.m */, 8BAA9B540F7B4A5000DF4F12 /* GTMHotKeyTextFieldTest.h */, @@ -1385,9 +1397,6 @@ F48FE27E0D198D0E009257D2 /* GTMGeometryUtils.h */, F48FE27F0D198D0E009257D2 /* GTMGeometryUtils.m */, F48FE2800D198D0E009257D2 /* GTMGeometryUtilsTest.m */, - 8BF4D2E30FC7073A009ABC3F /* GTMGoogleSearch.h */, - 8BF4D2E40FC7073A009ABC3F /* GTMGoogleSearch.m */, - 8BF4D2E20FC7073A009ABC3F /* GTMGoogleSearchTest.m */, F47F1D2D0D4914AD00925B8F /* GTMCalculatedRange.h */, F47F1D2E0D4914AD00925B8F /* GTMCalculatedRange.m */, F47F1D2F0D4914AD00925B8F /* GTMCalculatedRangeTest.m */, @@ -1634,7 +1643,6 @@ 8B40994B0F93C5CC00DF540E /* GTMUILocalizer.h in Headers */, 8BFE13B60FB0F2C0001BE894 /* GTMABAddressBook.h in Headers */, 8BD35B910FB22980009058F5 /* GTMNSScanner+JSON.h in Headers */, - 8BF4D2E60FC7073A009ABC3F /* GTMGoogleSearch.h in Headers */, 8207B89B0FEA7A9E008A527B /* GTMWindowSheetController.h in Headers */, F43C7A571021FAA300ABF03C /* GTMUILocalizerAndLayoutTweaker.h in Headers */, 7F97DB32104EBCA0004DDDEE /* GTMFadeTruncatingTextFieldCell.h in Headers */, @@ -1645,6 +1653,7 @@ 8BF2555310F65B56000490C8 /* GTMTypeCasting.h in Headers */, 8BDB8A991152E1B200C411B1 /* GTMNSAnimatablePropertyContainer.h in Headers */, 8B21DE56117E5CB7000E004F /* GTMLocalizedString.h in Headers */, + 8BB7802E11B6C4EA00AB31AF /* GTMGoogleSearch.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2017,6 +2026,9 @@ 8BA9FC75119CB48F00E264C3 /* GTMUILocalizerAndLayoutTweakerTest6-tab1-0.10.6.tiff in Resources */, 8BA9FC78119CB4A100E264C3 /* GTMUILocalizerAndLayoutTweakerTest6-tab1-1.10.6.tiff in Resources */, 8BA9FC7B119CB4B300E264C3 /* GTMUILocalizerAndLayoutTweakerTest6-tab1-2.10.6.tiff in Resources */, + 8BA7148111B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-0.10_4_SDK.10.6.tiff in Resources */, + 8BA7148211B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-1.10_4_SDK.10.6.tiff in Resources */, + 8BA7148311B57EC700EB4781 /* GTMUILocalizerAndLayoutTweakerTest4-2.10_4_SDK.10.6.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2179,7 +2191,6 @@ 10998F8B0F4B5F1B007F179D /* GTMTransientRootProxyTest.m in Sources */, 108930850F4CCB380018D4A0 /* GTMTransientRootPortProxyTest.m in Sources */, 8BD35B940FB22986009058F5 /* GTMNSScanner+JSONTest.m in Sources */, - 8BF4D2E80FC70751009ABC3F /* GTMGoogleSearchTest.m in Sources */, 0BFAD4CB104D06FE002BEB27 /* GTMNSData+HexTest.m in Sources */, 0BFAD4CC104D06FE002BEB27 /* GTMNSDictionary+CaseInsensitiveTest.m in Sources */, 8B3080151056B917006C4C7A /* GTMNSNumber+64BitTest.m in Sources */, @@ -2250,7 +2261,6 @@ 8B40994C0F93C5CC00DF540E /* GTMUILocalizer.m in Sources */, 8BFE13B70FB0F2C0001BE894 /* GTMABAddressBook.m in Sources */, 8BD35B920FB22980009058F5 /* GTMNSScanner+JSON.m in Sources */, - 8BF4D2E70FC7073A009ABC3F /* GTMGoogleSearch.m in Sources */, 8207B89C0FEA7AA1008A527B /* GTMWindowSheetController.m in Sources */, F43C7A581021FAA300ABF03C /* GTMUILocalizerAndLayoutTweaker.m in Sources */, 7F97DB33104EBCA3004DDDEE /* GTMFadeTruncatingTextFieldCell.m in Sources */, @@ -2262,6 +2272,7 @@ 8B158A9B10A8C31100C93125 /* GTMNSAnimation+Duration.m in Sources */, 0B1B9B8810FECD870084EE4B /* GTMStringEncoding.m in Sources */, 8BDB8A9A1152E1B200C411B1 /* GTMNSAnimatablePropertyContainer.m in Sources */, + 8BB77A0611B5A0A100AB31AF /* GTMGoogleSearch.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2295,6 +2306,7 @@ 8BDB8C3A115329EC00C411B1 /* GTMNSAnimatablePropertyContainerTest.m in Sources */, 8B17FD16117638D500E7A908 /* GTMFoundationUnitTestingUtilities.m in Sources */, 8B17FD1A117638F400E7A908 /* GTMAppKitUnitTestingUtilities.m in Sources */, + 8BB77A0511B5A09900AB31AF /* GTMGoogleSearchTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2412,13 +2424,9 @@ buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; }; name = "TigerOrLater-Debug"; }; @@ -2428,13 +2436,9 @@ buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; }; name = "TigerOrLater-Release"; }; @@ -2444,13 +2448,9 @@ buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; }; name = "SnowLeopardOrLater-Debug"; }; @@ -2550,13 +2550,9 @@ GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; OTHER_LDFLAGS = "-lgcov"; }; name = "SnowLeopardOrLater-Debug-gcov"; @@ -2567,13 +2563,9 @@ buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; }; name = "SnowLeopardOrLater-Release"; }; @@ -3102,13 +3094,9 @@ GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/TigerGcov\"", @@ -3204,13 +3192,9 @@ ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; }; name = "LeopardOrLater-Debug"; }; @@ -3301,13 +3285,9 @@ GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; OTHER_LDFLAGS = "-lgcov"; }; name = "LeopardOrLater-Debug-gcov"; @@ -3397,13 +3377,9 @@ ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = GTM_Prefix.pch; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - "COMPONENT_SIGNATURE=\"\\'GTM \\'\"", - "kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\"", - ); GCC_WARN_SHADOW = YES; GTM_EXTRA_WARNING_OVERRIDE_CFLAGS = "-Wno-unused-parameter"; + GTM_HOST_GCC_PREPROCESSOR_DEFINITIONS = "COMPONENT_SIGNATURE=\"\\'GTM \\'\" kComponentSignatureString=\"\\\"GoogleToolboxForMac\\\"\""; }; name = "LeopardOrLater-Release"; }; diff --git a/GTMDefines.h b/GTMDefines.h index 2bc3c5e..d10a26c 100644 --- a/GTMDefines.h +++ b/GTMDefines.h @@ -287,6 +287,11 @@ GTM_EXTERN void _GTMUnitTestDevLog(NSString *format, ...); #define NS_FORMAT_ARGUMENT(A) #endif +// Defined on 10.6 and above. +#ifndef NS_FORMAT_FUNCTION + #define NS_FORMAT_FUNCTION(F,A) +#endif + #ifndef GTM_NONNULL #define GTM_NONNULL(x) __attribute__((nonnull(x))) #endif diff --git a/GTM_Prefix.pch b/GTM_Prefix.pch index a7c0011..5434868 100644 --- a/GTM_Prefix.pch +++ b/GTM_Prefix.pch @@ -14,24 +14,12 @@ // the License. // -// We don't require a prefix to use any GTM code, so this prefix is just to -// speed up the basic compiles of *all* of the GTM projects/targets. +// We don't require a prefix to use any GTM code. This prefix is just for unit +// test logging. -// We don't want to drag GTMDefines into the prefix so we make sure each file -// that directly needs it includes it, so we just use the iphone test directly -// instead of our GTM_IPHONE_SDK symbol. -#ifdef __OBJC__ - #include - #if TARGET_OS_IPHONE // iPhone SDK - #import - #import - #else - #import - #endif - // This turns on unit test logging so that we can track unittests if we are - // doing them. See GTMUnitTestDevLog.h for details. - // (_GTMUnitTestDevLog comes from GTMDevLogUnitTestingBridge.m) - #define _GTMDevLog _GTMUnitTestDevLog -#endif +// This turns on unit test logging so that we can track unittests if we are +// doing them. See GTMUnitTestDevLog.h for details. +// (_GTMUnitTestDevLog comes from GTMDevLogUnitTestingBridge.m) +#define _GTMDevLog _GTMUnitTestDevLog diff --git a/SnowLeopardGcov/%ReadMe.webloc b/SnowLeopardGcov/%ReadMe.webloc new file mode 100644 index 0000000..161e15b Binary files /dev/null and b/SnowLeopardGcov/%ReadMe.webloc differ diff --git a/SnowLeopardGcov/ReadMe.webloc b/SnowLeopardGcov/ReadMe.webloc new file mode 100644 index 0000000..e0bf5cc Binary files /dev/null and b/SnowLeopardGcov/ReadMe.webloc differ diff --git a/SnowLeopardGcov/libgcov.a b/SnowLeopardGcov/libgcov.a new file mode 100644 index 0000000..c8e90e8 Binary files /dev/null and b/SnowLeopardGcov/libgcov.a differ diff --git a/UnitTesting/GTMAppKitUnitTestingUtilities.h b/UnitTesting/GTMAppKitUnitTestingUtilities.h index d6a653c..d29f63a 100644 --- a/UnitTesting/GTMAppKitUnitTestingUtilities.h +++ b/UnitTesting/GTMAppKitUnitTestingUtilities.h @@ -16,6 +16,8 @@ // the License. // +#import + #import "GTMFoundationUnitTestingUtilities.h" // Collection of utilities for unit testing diff --git a/UnitTesting/GTMNSObject+BindingUnitTesting.h b/UnitTesting/GTMNSObject+BindingUnitTesting.h index 55c3dfe..feac5b3 100644 --- a/UnitTesting/GTMNSObject+BindingUnitTesting.h +++ b/UnitTesting/GTMNSObject+BindingUnitTesting.h @@ -48,7 +48,7 @@ do { \ if (!isGood) { \ NSString *failString; \ GTM_FOREACH_OBJECT(failString, errors) { \ - if (description) { \ + if (description != nil) { \ STFail(@"%@: %@", failString, STComposeString(description, ##__VA_ARGS__)); \ } else { \ STFail(@"%@", failString); \ diff --git a/UnitTesting/GTMNSObject+BindingUnitTesting.m b/UnitTesting/GTMNSObject+BindingUnitTesting.m index 4718854..4b43f58 100644 --- a/UnitTesting/GTMNSObject+BindingUnitTesting.m +++ b/UnitTesting/GTMNSObject+BindingUnitTesting.m @@ -18,6 +18,7 @@ // the License. // +#import #import "GTMDefines.h" #import "GTMNSObject+BindingUnitTesting.h" #import "GTMSystemVersion.h" diff --git a/UnitTesting/GTMNSObject+UnitTesting.m b/UnitTesting/GTMNSObject+UnitTesting.m index 8529059..3796839 100644 --- a/UnitTesting/GTMNSObject+UnitTesting.m +++ b/UnitTesting/GTMNSObject+UnitTesting.m @@ -394,7 +394,7 @@ GTM_INLINE BOOL almostEqual(unsigned char a, unsigned char b) { } - (void)encodeBytes:(const uint8_t *)bytesp - length:(unsigned)lenv + length:(NSUInteger)lenv forKey:(NSString *)key { [self checkForKey:key]; [dictionary_ setObject:[NSData dataWithBytes:bytesp diff --git a/UnitTesting/GTMUnitTestDevLog.h b/UnitTesting/GTMUnitTestDevLog.h index 30c7077..f80743a 100644 --- a/UnitTesting/GTMUnitTestDevLog.h +++ b/UnitTesting/GTMUnitTestDevLog.h @@ -33,8 +33,8 @@ @interface GTMUnitTestDevLog : NSObject // Log a message -+ (void)log:(NSString*)format, ...; -+ (void)log:(NSString*)format args:(va_list)args; ++ (void)log:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2); ++ (void)log:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(1,0); // Turn tracking on/off + (void)enableTracking; @@ -43,21 +43,24 @@ // Note that you are expecting a string that has an exact match. No need to // escape any pattern characters. -+ (void)expectString:(NSString *)format, ...; ++ (void)expectString:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2); // Note that you are expecting a pattern. Pattern characters that you want // exact matches on must be escaped. See [GTMRegex escapedPatternForString]. // Patterns match across newlines (kGTMRegexOptionSupressNewlineSupport) making // it easier to match output from the descriptions of NS collection types such // as NSArray and NSDictionary. -+ (void)expectPattern:(NSString *)format, ...; ++ (void)expectPattern:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2); // Note that you are expecting exactly 'n' strings -+ (void)expect:(NSUInteger)n casesOfString:(NSString *)format, ...; ++ (void)expect:(NSUInteger)n + casesOfString:(NSString *)format, ... NS_FORMAT_FUNCTION(2,3); // Note that you are expecting exactly 'n' patterns -+ (void)expect:(NSUInteger)n casesOfPattern:(NSString*)format, ...; -+ (void)expect:(NSUInteger)n casesOfPattern:(NSString*)format args:(va_list)args; ++ (void)expect:(NSUInteger)n + casesOfPattern:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3); ++ (void)expect:(NSUInteger)n + casesOfPattern:(NSString*)format args:(va_list)args NS_FORMAT_FUNCTION(2,0); // Call when you want to verify that you have matched all the logs you expect // to match. If your unittests inherit from GTMTestcase (like they should) you diff --git a/UnitTesting/GTMUnitTestDevLog.m b/UnitTesting/GTMUnitTestDevLog.m index f2f9418..980fb93 100644 --- a/UnitTesting/GTMUnitTestDevLog.m +++ b/UnitTesting/GTMUnitTestDevLog.m @@ -199,7 +199,7 @@ static BOOL gTrackingEnabled = NO; arguments:argList] autorelease]; va_end(argList); NSString *pattern = [GTMRegex escapedPatternForString:string]; - [self expect:1 casesOfPattern:pattern]; + [self expect:1 casesOfPattern:@"%@", pattern]; } @@ -217,7 +217,7 @@ static BOOL gTrackingEnabled = NO; arguments:argList] autorelease]; va_end(argList); NSString *pattern = [GTMRegex escapedPatternForString:string]; - [self expect:n casesOfPattern:pattern]; + [self expect:n casesOfPattern:@"%@", pattern]; } + (void)expect:(NSUInteger)n casesOfPattern:(NSString*)format, ... { @@ -240,7 +240,7 @@ casesOfPattern:(NSString*)format [patterns addObject:regex]; } } -} +} + (void)verifyNoMoreLogsExpected { @synchronized(self) { diff --git a/UnitTesting/GTMUnitTestingBindingTest.m b/UnitTesting/GTMUnitTestingBindingTest.m index 19ab5b0..26ae5df 100644 --- a/UnitTesting/GTMUnitTestingBindingTest.m +++ b/UnitTesting/GTMUnitTestingBindingTest.m @@ -102,14 +102,14 @@ NSString *const kGTMKeyThatIsntEqual = @"keyThatIsntEqual"; - (id)valueForKey:(NSString*)binding { if ([binding isEqualTo:kGTMKeyWithNoValue]) { - [NSException raise:NSUndefinedKeyException format:nil]; + [NSException raise:NSUndefinedKeyException format:@""]; } return @"foo"; } - (void)setValue:(id)value forKey:(NSString*)binding { if ([binding isEqualTo:kGTMKeyWeCantSet]) { - [NSException raise:NSUndefinedKeyException format:nil]; + [NSException raise:NSUndefinedKeyException format:@""]; } } @end diff --git a/XcodeConfig/subconfig/GTMMerge.xcconfig b/XcodeConfig/subconfig/GTMMerge.xcconfig index 5ab141e..f7a3aa7 100644 --- a/XcodeConfig/subconfig/GTMMerge.xcconfig +++ b/XcodeConfig/subconfig/GTMMerge.xcconfig @@ -33,7 +33,7 @@ // for the host app to fill in. For example if you wanted to have stack // protection turned on for both debug and release builds you could set // GTM_HOST_OTHER_CFLAGS = -fstack-protector -fstack-protector-all -// in your own settings files, and then include the QSB ones. +// in your own settings files, and then include the GTM ones. WARNING_CFLAGS = $(inherited) $(GTM_GENERAL_WARNING_CFLAGS) $(GTM_PLATFORM_WARNING_CFLAGS) $(GTM_CONFIGURATION_WARNING_CFLAGS) $(GTM_HOST_WARNING_CFLAGS) OTHER_CFLAGS = $(inherited) $(GTM_GENERAL_OTHER_CFLAGS) $(GTM_PLATFORM_OTHER_CFLAGS) $(GTM_CONFIGURATION_OTHER_CFLAGS) $(GTM_HOST_OTHER_CFLAGS) diff --git a/XcodeConfig/subconfig/SnowLeopardOrLater.xcconfig b/XcodeConfig/subconfig/SnowLeopardOrLater.xcconfig index 0a7475e..666dbdc 100644 --- a/XcodeConfig/subconfig/SnowLeopardOrLater.xcconfig +++ b/XcodeConfig/subconfig/SnowLeopardOrLater.xcconfig @@ -23,4 +23,8 @@ // Default SDK and minimum OS version is 10.6 SDKROOT = ${DEVELOPER_SDK_DIR}/MacOSX10.6.sdk MACOSX_DEPLOYMENT_TARGET = 10.6 -GCC_VERSION = 4.0 +GCC_VERSION = 4.2 + +// Works around issues with the missing format attribute with gcc 4.2 +// on Snow Leopard. +GTM_PLATFORM_WARNING_CFLAGS=-Wno-missing-format-attribute diff --git a/XcodeConfig/subconfig/iPhone20.xcconfig b/XcodeConfig/subconfig/iPhone20.xcconfig index 0f92c95..0b742b0 100644 --- a/XcodeConfig/subconfig/iPhone20.xcconfig +++ b/XcodeConfig/subconfig/iPhone20.xcconfig @@ -20,5 +20,3 @@ // Set default SDK. SDKROOT = iphoneos2.0 -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone21.xcconfig b/XcodeConfig/subconfig/iPhone21.xcconfig index 61c59ed..44619d3 100644 --- a/XcodeConfig/subconfig/iPhone21.xcconfig +++ b/XcodeConfig/subconfig/iPhone21.xcconfig @@ -20,5 +20,3 @@ // Set default SDK. SDKROOT = iphoneos2.1 -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone22.xcconfig b/XcodeConfig/subconfig/iPhone22.xcconfig index 0b63278..ee8b707 100644 --- a/XcodeConfig/subconfig/iPhone22.xcconfig +++ b/XcodeConfig/subconfig/iPhone22.xcconfig @@ -20,5 +20,3 @@ // Set default SDK. SDKROOT = iphoneos2.2 -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone221.xcconfig b/XcodeConfig/subconfig/iPhone221.xcconfig index 1ce6e24..5f6f53b 100644 --- a/XcodeConfig/subconfig/iPhone221.xcconfig +++ b/XcodeConfig/subconfig/iPhone221.xcconfig @@ -20,5 +20,3 @@ // Set default SDK. SDKROOT = iphoneos2.2.1 -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone30.xcconfig b/XcodeConfig/subconfig/iPhone30.xcconfig index df60b05..c50daca 100644 --- a/XcodeConfig/subconfig/iPhone30.xcconfig +++ b/XcodeConfig/subconfig/iPhone30.xcconfig @@ -19,6 +19,3 @@ // Set default SDK. SDKROOT = iphoneos3.0 - -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone31.xcconfig b/XcodeConfig/subconfig/iPhone31.xcconfig index af7cee7..6b3781b 100644 --- a/XcodeConfig/subconfig/iPhone31.xcconfig +++ b/XcodeConfig/subconfig/iPhone31.xcconfig @@ -20,5 +20,3 @@ // Set default SDK. SDKROOT = iphoneos3.1 -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone312.xcconfig b/XcodeConfig/subconfig/iPhone312.xcconfig index 5480e0a..ff778f3 100644 --- a/XcodeConfig/subconfig/iPhone312.xcconfig +++ b/XcodeConfig/subconfig/iPhone312.xcconfig @@ -20,5 +20,3 @@ // Set default SDK. SDKROOT = iphoneos3.1.2 -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone313.xcconfig b/XcodeConfig/subconfig/iPhone313.xcconfig index 8cac36a..5b34dce 100644 --- a/XcodeConfig/subconfig/iPhone313.xcconfig +++ b/XcodeConfig/subconfig/iPhone313.xcconfig @@ -19,6 +19,3 @@ // Set default SDK. SDKROOT = iphoneos3.1.3 - -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 diff --git a/XcodeConfig/subconfig/iPhone32.xcconfig b/XcodeConfig/subconfig/iPhone32.xcconfig index bee82ef..d50c2d0 100644 --- a/XcodeConfig/subconfig/iPhone32.xcconfig +++ b/XcodeConfig/subconfig/iPhone32.xcconfig @@ -19,6 +19,3 @@ // Set default SDK. SDKROOT = iphoneos3.2 - -// iPhone currently deploys on 10.5 only -MACOSX_DEPLOYMENT_TARGET = 10.5 -- cgit v1.2.3