diff --git a/NTSynchronousTask.m b/NTSynchronousTask.m index 06ca7fea..8375a2ec 100644 --- a/NTSynchronousTask.m +++ b/NTSynchronousTask.m @@ -78,8 +78,9 @@ { BOOL success = NO; - if (currentDirectory) + if (currentDirectory) { self.task.currentDirectoryPath = currentDirectory; + } self.task.launchPath = toolPath; self.task.arguments = args; @@ -141,8 +142,9 @@ [task run:toolPath directory:currentDirectory withArgs:args input:input]; - if ([task result] == 0) + if ([task result] == 0) { result = [[task output] retain]; + } [task release]; } @@ -162,8 +164,9 @@ // we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int taskResult = 0; - if( outData ) + if (outData) { *outData = nil; + } @try { NTSynchronousTask* task = [[NTSynchronousTask alloc] init]; @@ -171,8 +174,9 @@ [task run:toolPath directory:currentDirectory withArgs:args input:input]; taskResult = [task result]; - if( outData ) + if (outData) { *outData = [[task output] retain]; + } [task release]; } @catch (NSException *localException) { @@ -182,8 +186,9 @@ [pool drain]; // retained above - if( outData ) + if (outData) { [*outData autorelease]; + } return taskResult; } diff --git a/SUAppcast.m b/SUAppcast.m index b1999320..98ce5965 100644 --- a/SUAppcast.m +++ b/SUAppcast.m @@ -60,8 +60,9 @@ - (void)fetchAppcastFromURL:(NSURL *)url { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; - if (userAgentString) + if (userAgentString) { [request setValue:userAgentString forHTTPHeaderField:@"User-Agent"]; + } self.download = [[[NSURLDownload alloc] initWithRequest:request delegate:self] autorelease]; } @@ -264,8 +265,9 @@ } lang = [NSBundle preferredLocalizationsFromArray:languages][0]; i = [languages indexOfObject:([languages containsObject:lang] ? lang : @"")]; - if (i == NSNotFound) + if (i == NSNotFound) { i = 0; + } return nodes[i]; } diff --git a/SUAppcastItem.m b/SUAppcastItem.m index f66191c9..4f086fde 100644 --- a/SUAppcastItem.m +++ b/SUAppcastItem.m @@ -120,8 +120,9 @@ NSString* enclosureURLString = enclosure[@"url"]; if( !enclosureURLString && !theInfoURL ) { - if (error) + if (error) { *error = @"Feed item's enclosure lacks URL"; + } [self release]; return nil; } @@ -130,16 +131,18 @@ NSString *fileURLString = [[enclosureURLString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; self.fileURL = [NSURL URLWithString:fileURLString]; } - if( enclosure ) + if (enclosure) { self.DSASignature = enclosure[@"sparkle:dsaSignature"]; + } self.versionString = newVersion; self.minimumSystemVersion = dict[@"sparkle:minimumSystemVersion"]; self.maximumSystemVersion = dict[@"sparkle:maximumSystemVersion"]; NSString *shortVersionString = enclosure[@"sparkle:shortVersionString"]; - if (nil == shortVersionString) + if (nil == shortVersionString) { shortVersionString = dict[@"sparkle:shortVersionString"]; // fall back on the + } if (shortVersionString) self.displayVersionString = shortVersionString; diff --git a/SUAutomaticUpdateDriver.m b/SUAutomaticUpdateDriver.m index 5b146b74..14c39bae 100644 --- a/SUAutomaticUpdateDriver.m +++ b/SUAutomaticUpdateDriver.m @@ -144,8 +144,9 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI { - if (relaunch) + if (relaunch) { [self stopUpdatingOnTermination]; + } showErrors = YES; [super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI]; diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 11a14932..cad0aac5 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -55,12 +55,14 @@ id comparator = nil; // Give the delegate a chance to provide a custom version comparator - if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) + if ([[updater delegate] respondsToSelector:@selector(versionComparatorForUpdater:)]) { comparator = [[updater delegate] versionComparatorForUpdater:updater]; + } // If we don't get a comparator from the delegate, use the default comparator - if (!comparator) + if (!comparator) { comparator = [SUStandardVersionComparator defaultComparator]; + } return comparator; } @@ -103,8 +105,9 @@ - (void)appcastDidFinishLoading:(SUAppcast *)ac { - if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) + if ([[updater delegate] respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) { [[updater delegate] updater:updater didFinishLoadingAppcast:ac]; + } NSDictionary *userInfo = (ac != nil) ? @{SUUpdaterAppcastNotificationKey : ac} : nil; [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFinishLoadingAppCastNotification object:updater userInfo:userInfo]; @@ -160,8 +163,9 @@ - (void)didNotFindUpdate { - if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) + if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { [[updater delegate] updaterDidNotFindUpdate:updater]; + } [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater]; [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNoUpdateError userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"You already have the newest version of %@.", nil), [host name]]}]]; @@ -309,13 +313,15 @@ [invocation setArgument:&relaunch atIndex:2]; [invocation setTarget:self]; postponedOnce = YES; - if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) + if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) { return; } + } - if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)]) + if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)]) { [[updater delegate] updater:updater willInstallUpdate:updateItem]; + } NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING; @@ -348,8 +354,9 @@ } NSString *pathToRelaunch = [host bundlePath]; - if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)]) + if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)]) { pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater]; + } NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName]; [NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:@[[host bundlePath], pathToRelaunch, @@ -391,12 +398,15 @@ - (void)abortUpdateWithError:(NSError *)error { - if ([error code] != SUNoUpdateError) // Let's not bother logging this. + if ([error code] != SUNoUpdateError) { // Let's not bother logging this. SULog(@"Sparkle Error: %@", [error localizedDescription]); - if ([error localizedFailureReason]) + } + if ([error localizedFailureReason]) { SULog(@"Sparkle Error (continued): %@", [error localizedFailureReason]); - if (download) + } + if (download) { [download cancel]; + } [self abortUpdate]; } diff --git a/SUBinaryDeltaTool.m b/SUBinaryDeltaTool.m index e98efbec..6e0568df 100644 --- a/SUBinaryDeltaTool.m +++ b/SUBinaryDeltaTool.m @@ -74,8 +74,9 @@ static NSDictionary *infoForFile(FTSENT *ent) { NSData *hash = hashOfFile(ent); NSNumber *size = nil; - if (ent->fts_info != FTS_D) + if (ent->fts_info != FTS_D) { size = [NSNumber numberWithUnsignedLongLong:ent->fts_statp->st_size]; + } return [NSDictionary dictionaryWithObjectsAndKeys:hash, @"hash", [NSNumber numberWithUnsignedShort:ent->fts_info], @"type", size, @"size", nil]; } @@ -96,25 +97,30 @@ static NSString *temporaryPatchFile(NSString *patchFile) static BOOL shouldSkipDeltaCompression(NSString *key, NSDictionary* originalInfo, NSDictionary *newInfo) { unsigned long long fileSize = [[newInfo objectForKey:@"size"] unsignedLongLongValue]; - if (fileSize < 4096) + if (fileSize < 4096) { return YES; + } - if (!originalInfo) + if (!originalInfo) { return YES; + } - if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue]) + if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue]) { return YES; + } return NO; } static BOOL shouldDeleteThenExtract(NSString *key, NSDictionary* originalInfo, NSDictionary *newInfo) { - if (!originalInfo) + if (!originalInfo) { return NO; + } - if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue]) + if ([[originalInfo objectForKey:@"type"] unsignedShortValue] != [[newInfo objectForKey:@"type"] unsignedShortValue]) { return YES; + } return NO; } @@ -157,12 +163,14 @@ usage: fprintf(stderr, "Processing %s...", [oldPath UTF8String]); FTSENT *ent = 0; while ((ent = fts_read(fts))) { - if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) + if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) { continue; + } NSString *key = pathRelativeToDirectory(oldPath, stringWithFileSystemRepresentation(ent->fts_path)); - if (![key length]) + if (![key length]) { continue; + } NSDictionary *info = infoForFile(ent); [originalTreeState setObject:info forKey:key]; @@ -188,12 +196,14 @@ usage: while ((ent = fts_read(fts))) { - if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) + if (ent->fts_info != FTS_F && ent->fts_info != FTS_SL && ent->fts_info != FTS_D) { continue; + } NSString *key = pathRelativeToDirectory(newPath, stringWithFileSystemRepresentation(ent->fts_path)); - if (![key length]) + if (![key length]) { continue; + } NSDictionary *info = infoForFile(ent); NSDictionary *oldInfo = [originalTreeState objectForKey:key]; @@ -236,8 +246,9 @@ usage: NSString *path = [newPath stringByAppendingPathComponent:key]; xar_file_t newFile = xar_add_frompath(x, 0, [key fileSystemRepresentation], [path fileSystemRepresentation]); assert(newFile); - if (shouldDeleteThenExtract(key, originalInfo, newInfo)) + if (shouldDeleteThenExtract(key, originalInfo, newInfo)) { xar_prop_set(newFile, "delete-then-extract", "true"); + } } else { CreateBinaryDeltaOperation *operation = [[CreateBinaryDeltaOperation alloc] initWithRelativePath:key oldTree:oldPath newTree:newPath]; [deltaQueue addOperation:operation]; diff --git a/SUDiskImageUnarchiver.m b/SUDiskImageUnarchiver.m index ddb27667..dece9ac8 100644 --- a/SUDiskImageUnarchiver.m +++ b/SUDiskImageUnarchiver.m @@ -107,8 +107,9 @@ NSString *toPath = [[archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item]; // We skip any files in the DMG which are not readable. - if (![manager isReadableFileAtPath:fromPath]) + if (![manager isReadableFileAtPath:fromPath]) { continue; + } SULog(@"copyItemAtPath:%@ toPath:%@", fromPath, toPath); diff --git a/SUHost.m b/SUHost.m index c5c6caa5..ea9fa472 100644 --- a/SUHost.m +++ b/SUHost.m @@ -25,12 +25,14 @@ { if (aBundle == nil) aBundle = [NSBundle mainBundle]; self.bundle = aBundle; - if (![bundle bundleIdentifier]) + if (![bundle bundleIdentifier]) { SULog(@"Sparkle Error: the bundle being updated at %@ has no CFBundleIdentifier! This will cause preference read/write to not work properly.", bundle); + } defaultsDomain = [[bundle objectForInfoDictionaryKey:SUDefaultsDomainKey] retain]; - if (!defaultsDomain) + if (!defaultsDomain) { defaultsDomain = [[bundle bundleIdentifier] retain]; + } // If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y. usesStandardUserDefaults = [defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]]; @@ -61,8 +63,9 @@ SULog(@"Failed to find app support directory! Using ~/Library/Application Support..."); appSupportPath = [@"~/Library/Application Support" stringByExpandingTildeInPath]; } - else + else { appSupportPath = appSupportPaths[0]; + } appSupportPath = [appSupportPath stringByAppendingPathComponent:[self name]]; appSupportPath = [appSupportPath stringByAppendingPathComponent:@".Sparkle"]; return appSupportPath; @@ -73,8 +76,9 @@ #if NORMALIZE_INSTALLED_APP_NAME // We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name. NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]; - if (![[NSFileManager defaultManager] fileExistsAtPath:[[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]]) + if (![[NSFileManager defaultManager] fileExistsAtPath:[[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat: @"%@.%@", [bundle objectForInfoDictionaryKey:@"CFBundleName"], [[bundle bundlePath] pathExtension]]]]) { return normalizedAppPath; + } #endif return [bundle bundlePath]; } @@ -116,8 +120,9 @@ // extension, although it may." // // However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try: - if (!iconPath) + if (!iconPath) { iconPath = [bundle pathForResource:[bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType: nil]; + } NSImage *icon = [[[NSImage alloc] initWithContentsOfFile:iconPath] autorelease]; // Use a default icon if none is defined. if (!icon) { @@ -174,8 +179,9 @@ // Under Tiger, CFPreferencesCopyAppValue doesn't get values from NSRegistrationDomain, so anything // passed into -[NSUserDefaults registerDefaults:] is ignored. The following line falls // back to using NSUserDefaults, but only if the host bundle is the main bundle. - if (usesStandardUserDefaults) + if (usesStandardUserDefaults) { return [[NSUserDefaults standardUserDefaults] objectForKey:defaultName]; + } CFPropertyListRef obj = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain); return [(id)CFMakeCollectable(obj) autorelease]; @@ -196,13 +202,15 @@ - (BOOL)boolForUserDefaultsKey:(NSString *)defaultName { - if (usesStandardUserDefaults) + if (usesStandardUserDefaults) { return [[NSUserDefaults standardUserDefaults] boolForKey:defaultName]; + } BOOL value; CFPropertyListRef plr = CFPreferencesCopyAppValue((CFStringRef)defaultName, (CFStringRef)defaultsDomain); - if (plr == NULL) + if (plr == NULL) { value = NO; + } else { value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr); diff --git a/SUPipedUnarchiver.m b/SUPipedUnarchiver.m index b2f77bbe..51530ece 100644 --- a/SUPipedUnarchiver.m +++ b/SUPipedUnarchiver.m @@ -83,8 +83,9 @@ } pclose(cmdFP); - if( ferror( fp ) ) + if (ferror(fp)) { goto reportError; + } [self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO]; goto finally; diff --git a/SUPlainInstallerInternals.m b/SUPlainInstallerInternals.m index 6bed7038..f3d9a597 100644 --- a/SUPlainInstallerInternals.m +++ b/SUPlainInstallerInternals.m @@ -136,8 +136,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza [validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]]; postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]]; } - else + else { postFix = @"old"; + } NSString *prefix = [NSString stringWithFormat: @"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix]; #else NSString *prefix = [[path lastPathComponent] stringByDeletingPathExtension]; @@ -147,8 +148,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // Now let's make sure we get a unique path. int cnt=2; - while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999) + while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999) { tempDir = [[tempDir stringByDeletingLastPathComponent] stringByAppendingPathComponent: [NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]]]; + } return tempDir; } @@ -489,8 +491,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (!success) { // We better move the old version back to its old location - if( hadFileAtDest ) + if (hadFileAtDest) { success = [manager moveItemAtPath:tmpPath toPath:dst error:error]; + } if (!success && error != NULL) *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath]}]; return NO; diff --git a/SUProbingUpdateDriver.m b/SUProbingUpdateDriver.m index 28ed6a7a..a58acedf 100644 --- a/SUProbingUpdateDriver.m +++ b/SUProbingUpdateDriver.m @@ -24,8 +24,9 @@ - (void)didNotFindUpdate { - if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) + if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { [[updater delegate] updaterDidNotFindUpdate:updater]; + } [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater]; [self abortUpdate]; diff --git a/SUScheduledUpdateDriver.m b/SUScheduledUpdateDriver.m index 2fc51a49..9e534c0b 100644 --- a/SUScheduledUpdateDriver.m +++ b/SUScheduledUpdateDriver.m @@ -23,8 +23,9 @@ - (void)didNotFindUpdate { - if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) + if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { [[updater delegate] updaterDidNotFindUpdate:updater]; + } [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater]; [self abortUpdate]; // Don't tell the user that no update was found; this was a scheduled update. diff --git a/SUStandardVersionComparator.m b/SUStandardVersionComparator.m index 870bd53e..6818c447 100644 --- a/SUStandardVersionComparator.m +++ b/SUStandardVersionComparator.m @@ -18,8 +18,9 @@ + (SUStandardVersionComparator *)defaultComparator { static SUStandardVersionComparator *defaultComparator = nil; - if (defaultComparator == nil) + if (defaultComparator == nil) { defaultComparator = [[SUStandardVersionComparator alloc] init]; + } return defaultComparator; } diff --git a/SUSystemProfiler.m b/SUSystemProfiler.m index 758604e7..ef8ad6f6 100644 --- a/SUSystemProfiler.m +++ b/SUSystemProfiler.m @@ -16,8 +16,9 @@ + (SUSystemProfiler *)sharedSystemProfiler { static SUSystemProfiler *sharedSystemProfiler = nil; - if (!sharedSystemProfiler) + if (!sharedSystemProfiler) { sharedSystemProfiler = [[self alloc] init]; + } return sharedSystemProfiler; } @@ -40,8 +41,9 @@ // OS version NSString *currentSystemVersion = [SUHost systemVersionString]; - if (currentSystemVersion != nil) + if (currentSystemVersion != nil) { [profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"osVersion",@"OS Version",currentSystemVersion,currentSystemVersion] forKeys:profileDictKeys]]; + } // CPU type (decoder info for values found here is in mach/machine.h) error = sysctlbyname("hw.cputype", &value, &length, NULL, 0); @@ -57,10 +59,12 @@ [profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"cputype",@"CPU Type", @(value), visibleCPUType] forKeys:profileDictKeys]]; } error = sysctlbyname("hw.cpu64bit_capable", &value, &length, NULL, 0); - if(error != 0) + if (error != 0) { error = sysctlbyname("hw.optional.x86_64", &value, &length, NULL, 0); //x86 specific - if(error != 0) + } + if (error != 0) { error = sysctlbyname("hw.optional.64bitops", &value, &length, NULL, 0); //PPC specific + } BOOL is64bit = NO; @@ -95,8 +99,9 @@ if (error == 0) { NSString *rawModelName = @(cpuModel); NSString *visibleModelName = modelTranslation[rawModelName]; - if (visibleModelName == nil) + if (visibleModelName == nil) { visibleModelName = rawModelName; + } [profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"model",@"Mac Model", rawModelName, visibleModelName] forKeys:profileDictKeys]]; } free(cpuModel); @@ -105,22 +110,26 @@ // Number of CPUs error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0); - if (error == 0) + if (error == 0) { [profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"ncpu",@"Number of CPUs", @(value), @(value)] forKeys:profileDictKeys]]; + } // User preferred language NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; NSArray *languages = [defs objectForKey:@"AppleLanguages"]; - if ([languages count] > 0) + if ([languages count] > 0) { [profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"lang",@"Preferred Language", languages[0], languages[0]] forKeys:profileDictKeys]]; + } // Application sending the request NSString *appName = [host name]; - if (appName) + if (appName) { [profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appName",@"Application Name", appName, appName] forKeys:profileDictKeys]]; + } NSString *appVersion = [host version]; - if (appVersion) + if (appVersion) { [profileArray addObject:[NSDictionary dictionaryWithObjects:@[@"appVersion",@"Application Version", appVersion, appVersion] forKeys:profileDictKeys]]; + } // Number of displays? diff --git a/SUUIBasedUpdateDriver.m b/SUUIBasedUpdateDriver.m index 738b73b9..b22f6e88 100644 --- a/SUUIBasedUpdateDriver.m +++ b/SUUIBasedUpdateDriver.m @@ -22,12 +22,14 @@ [updateAlert setDelegate:self]; id versDisp = nil; - if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) + if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) { versDisp = [[updater delegate] versionDisplayerForUpdater: updater]; + } [updateAlert setVersionDisplayer: versDisp]; - if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) + if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) { [[updater delegate] updater:updater didFindValidUpdate:updateItem]; + } // If the app is a menubar app or the like, we need to focus it first and alter the // update prompt to behave like a normal window. Otherwise if the window were hidden @@ -99,14 +101,17 @@ - (NSString *)humanReadableSizeFromDouble:(double)value { - if (value < 1000) + if (value < 1000) { return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")]; + } - if (value < 1000 * 1000) + if (value < 1000 * 1000) { return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, SULocalizedString(@"KB", @"the unit for kilobytes")]; + } - if (value < 1000 * 1000 * 1000) + if (value < 1000 * 1000 * 1000) { return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, SULocalizedString(@"MB", @"the unit for megabytes")]; + } return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, SULocalizedString(@"GB", @"the unit for gigabytes")]; } @@ -202,8 +207,9 @@ - (void)showModalAlert:(NSAlert *)alert { - if ([[updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) + if ([[updater delegate] respondsToSelector:@selector(updaterWillShowModalAlert:)]) { [[updater delegate] updaterWillShowModalAlert: updater]; + } // When showing a modal alert we need to ensure that background applications // are focused to inform the user since there is no dock icon to notify them. diff --git a/SUUnarchiver.m b/SUUnarchiver.m index 47ff5fa2..907b82a1 100644 --- a/SUUnarchiver.m +++ b/SUUnarchiver.m @@ -22,8 +22,9 @@ { for (id current in [self unarchiverImplementations]) { - if ([current canUnarchivePath:path]) + if ([current canUnarchivePath:path]) { return [[[current alloc] initWithPath:path host:host] autorelease]; + } } return nil; } diff --git a/SUUnarchiver_Private.m b/SUUnarchiver_Private.m index 862774c3..d97c01f2 100644 --- a/SUUnarchiver_Private.m +++ b/SUUnarchiver_Private.m @@ -57,8 +57,9 @@ static NSMutableArray *gUnarchiverImplementations; + (void)registerImplementation:(Class)implementation { - if (!gUnarchiverImplementations) + if (!gUnarchiverImplementations) { gUnarchiverImplementations = [[NSMutableArray alloc] init]; + } [gUnarchiverImplementations addObject:implementation]; } diff --git a/SUUpdateAlert.m b/SUUpdateAlert.m index 0edaf3fe..e44fab43 100644 --- a/SUUpdateAlert.m +++ b/SUUpdateAlert.m @@ -162,8 +162,9 @@ { NSString* sizeStr = [host objectForInfoDictionaryKey:SUFixedHTMLDisplaySizeKey]; - if( [host isBackgroundApplication] ) + if ([host isBackgroundApplication]) { [[self window] setLevel:NSFloatingWindowLevel]; // This means the window will float over all other apps, if our app is switched out ?! UK 2007-09-04 + } [[self window] setFrameAutosaveName: sizeStr ? @"" : @"SUUpdateAlertFrame"]; // We're gonna do some frame magic to match the window's size to the description field and the presence of the release notes view. @@ -174,8 +175,9 @@ // Resize the window to be appropriate for not having a huge release notes view. frame.size.height -= [releaseNotesView frame].size.height + 40; // Extra 40 is for the release notes label and margin. - if ([self allowsAutomaticUpdates]) + if ([self allowsAutomaticUpdates]) { frame.size.height += 10; // Make room for the check box. + } // Hiding the resize handles is not enough on 10.5, you can still click // where they would be, so we set the min/max sizes to be equal to @@ -250,8 +252,9 @@ } } - if( frame.size.width < minimumWindowWidth ) + if (frame.size.width < minimumWindowWidth) { frame.size.width = minimumWindowWidth; + } [[self window] setFrame: frame display: NO]; [[self window] center]; @@ -297,8 +300,9 @@ updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [updateItem versionString]]; hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", [host version]]; } - else + else { [versionDisplayer formatVersion: &updateItemVersion andVersion: &hostVersion]; + } return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", nil), [host name], updateItemVersion, hostVersion]; } diff --git a/SUUpdateDriver.m b/SUUpdateDriver.m index 924cc223..ba56e5ec 100644 --- a/SUUpdateDriver.m +++ b/SUUpdateDriver.m @@ -17,8 +17,9 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; - (instancetype) initWithUpdater:(SUUpdater *)anUpdater { - if ((self = [super init])) + if ((self = [super init])) { updater = anUpdater; + } return self; } diff --git a/SUUpdatePermissionPrompt.m b/SUUpdatePermissionPrompt.m index a2bbffef..4d0fcc10 100644 --- a/SUUpdatePermissionPrompt.m +++ b/SUUpdatePermissionPrompt.m @@ -125,8 +125,9 @@ - (IBAction)finishPrompt:(id)sender { - if (![delegate respondsToSelector:@selector(updatePermissionPromptFinishedWithResult:)]) + if (![delegate respondsToSelector:@selector(updatePermissionPromptFinishedWithResult:)]) { [NSException raise:@"SUInvalidDelegate" format:@"SUUpdatePermissionPrompt's delegate (%@) doesn't respond to updatePermissionPromptFinishedWithResult:!", delegate]; + } [host setBool:shouldSendProfile forUserDefaultsKey:SUSendProfileInfoKey]; [delegate updatePermissionPromptFinishedWithResult:([sender tag] == 1 ? SUAutomaticallyCheck : SUDoNotAutomaticallyCheck)]; [[self window] close]; diff --git a/SUUpdater.m b/SUUpdater.m index 1e7dfc39..06510d0c 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -63,8 +63,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault { if (bundle == nil) bundle = [NSBundle mainBundle]; id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]]; - if (updater == nil) + if (updater == nil) { updater = [[[[self class] alloc] initForBundle:bundle] autorelease]; + } return updater; } @@ -75,8 +76,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault if (bundle == nil) bundle = [NSBundle mainBundle]; // Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called: - if (self) + if (self) { [self registerAsObserver]; + } id updater = sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]]; if (updater) @@ -86,8 +88,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault } else if (self) { - if (sharedUpdaters == nil) + if (sharedUpdaters == nil) { sharedUpdaters = [[NSMutableDictionary alloc] init]; + } sharedUpdaters[[NSValue valueWithNonretainedObject:bundle]] = self; host = [[SUHost alloc] initWithBundle:bundle]; @@ -153,8 +156,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault // Has he been asked already? And don't ask if the host has a default value set in its Info.plist. else if ([host objectForKey:SUEnableAutomaticChecksKey] == nil) { - if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]) + if ([host objectForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]) { [self setAutomaticallyChecksForUpdates:[host boolForUserDefaultsKey:SUEnableAutomaticChecksKeyOld]]; + } // Now, we don't want to ask the user for permission to do a weird thing on the first launch. // We wait until the second launch, unless explicitly overridden via SUPromptUserOnFirstLaunchKey. else if (![host objectForKey:SUPromptUserOnFirstLaunchKey]) @@ -172,8 +176,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault { NSArray *profileInfo = [host systemProfile]; // Always say we're sending the system profile here so that the delegate displays the parameters it would send. - if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) + if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) { profileInfo = [profileInfo arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:YES]]; + } [SUUpdatePermissionPrompt promptWithHost:host systemProfile:profileInfo delegate:self]; // We start the update checks and register as observer for changes after the prompt finishes } @@ -303,8 +308,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (IBAction)checkForUpdates: (id)sender { - if (driver && [driver isInterruptible]) + if (driver && [driver isInterruptible]) { [driver abortUpdate]; + } [self checkForUpdatesWithDriver:[[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self] autorelease]]; } @@ -395,8 +401,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault [host setBool:automaticallyCheckForUpdates forUserDefaultsKey:SUEnableAutomaticChecksKey]; // Hack to support backwards compatibility with older Sparkle versions, which supported // disabling updates by setting the check interval to 0. - if (automaticallyCheckForUpdates && [self updateCheckInterval] == 0) + if (automaticallyCheckForUpdates && [self updateCheckInterval] == 0) { [self setUpdateCheckInterval:SU_DEFAULT_CHECK_INTERVAL]; + } [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil]; // Provide a small delay in case multiple preferences are being updated simultaneously. [self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1]; @@ -405,8 +412,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (BOOL)automaticallyChecksForUpdates { // Don't automatically update when the check interval is 0, to be compatible with 1.1 settings. - if ([self updateCheckInterval] == 0) + if ([self updateCheckInterval] == 0) { return NO; + } return [host boolForKey:SUEnableAutomaticChecksKey]; } @@ -418,8 +426,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (BOOL)automaticallyDownloadsUpdates { // If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO. - if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO) + if ([host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO) { return NO; + } // Otherwise, automatically downloading updates is allowed. Does the user want it? return [host boolForUserDefaultsKey:SUAutomaticallyUpdateKey]; @@ -457,8 +466,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (NSString *)userAgentString { - if (customUserAgentString) + if (customUserAgentString) { return customUserAgentString; + } NSString *version = [SPARKLE_BUNDLE objectForInfoDictionaryKey:@"CFBundleVersion"]; NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [host name], [host displayVersion], version ? version : @"?"]; @@ -485,14 +495,16 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault // Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such. NSDate *lastSubmitDate = [host objectForUserDefaultsKey:SULastProfileSubmitDateKey]; - if(!lastSubmitDate) + if (!lastSubmitDate) { lastSubmitDate = [NSDate distantPast]; + } const NSTimeInterval oneWeek = 60 * 60 * 24 * 7; sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek); NSArray *parameters = @[]; - if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) + if ([delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) { parameters = [parameters arrayByAddingObjectsFromArray:[delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]]; + } if (sendingSystemProfile) { parameters = [parameters arrayByAddingObjectsFromArray:[host systemProfile]]; @@ -502,12 +514,14 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault // Build up the parameterized URL. NSMutableArray *parameterStrings = [NSMutableArray array]; - for (NSDictionary *currentProfileInfo in parameters) + for (NSDictionary *currentProfileInfo in parameters) { [parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [[currentProfileInfo[@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[currentProfileInfo[@"value"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; + } NSString *separatorCharacter = @"?"; - if ([baseFeedURL query]) + if ([baseFeedURL query]) { separatorCharacter = @"&"; // In case the URL is already http://foo.org/baz.xml?bat=4 + } NSString *appcastStringWithProfile = [NSString stringWithFormat:@"%@%@%@", [baseFeedURL absoluteString], separatorCharacter, [parameterStrings componentsJoinedByString:@"&"]]; // Clean it up so it's a valid URL @@ -517,8 +531,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval { [host setObject:@(updateCheckInterval) forUserDefaultsKey:SUScheduledCheckIntervalKey]; - if (updateCheckInterval == 0) // For compatibility with 1.1's settings. + if (updateCheckInterval == 0) { // For compatibility with 1.1's settings. [self setAutomaticallyChecksForUpdates:NO]; + } [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil]; // Provide a small delay in case multiple preferences are being updated simultaneously. @@ -545,8 +560,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (BOOL)validateMenuItem:(NSMenuItem *)item { - if ([item action] == @selector(checkForUpdates:)) + if ([item action] == @selector(checkForUpdates:)) { return ![self updateInProgress]; + } return YES; } diff --git a/finish_installation.m b/finish_installation.m index 6cde63be..5e00eeed 100644 --- a/finish_installation.m +++ b/finish_installation.m @@ -41,8 +41,9 @@ - (instancetype) initWithHostPath:(const char *)inhostpath executablePath:(const char *)execpath parentProcessId:(pid_t)ppid folderPath:(const char*)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString*)inSelfPath { - if( !(self = [super init]) ) + if (!(self = [super init])) { return nil; + } hostpath = inhostpath; executablepath = execpath; @@ -173,8 +174,9 @@ int main (int argc, const char * argv[]) { - if( argc < 5 || argc > 7 ) + if (argc < 5 || argc > 7) { return EXIT_FAILURE; + } NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -183,8 +185,9 @@ int main (int argc, const char * argv[]) #if 0 // Cmdline tool NSString* selfPath = nil; - if( argv[0][0] == '/' ) + if (argv[0][0] == '/') { selfPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation: argv[0] length: strlen(argv[0])]; + } else { selfPath = [[NSFileManager defaultManager] currentDirectoryPath];