From b2f633368fa697e0b0ae4d4ed4cc79a1f1fd2d73 Mon Sep 17 00:00:00 2001 From: emsquared Date: Mon, 25 Jun 2012 18:10:11 -0400 Subject: [PATCH] Fix a few bugs. --- Classes/Controllers/TXMasterController.m | 52 +++++++++++-------- .../Preferences/TDCPreferencesController.m | 4 +- .../Preferences/TDCPreferencesScriptWrapper.m | 20 ++++--- Classes/IRC/IRCClient.m | 21 +++++--- Classes/IRC/IRCClientConfig.m | 6 +-- .../TPCPreferencesMigrationAssistant.m | 6 +-- Classes/Preferences/TPCPreferences.m | 2 +- ...l (Standard Release + No Sandbox).xcscheme | 2 +- .../Textual (Standard Release).xcscheme | 2 +- Resources/Info.plist | 4 +- Textual.entitlements | 2 + 11 files changed, 73 insertions(+), 48 deletions(-) diff --git a/Classes/Controllers/TXMasterController.m b/Classes/Controllers/TXMasterController.m index d301c370ab..3a4113c7d9 100755 --- a/Classes/Controllers/TXMasterController.m +++ b/Classes/Controllers/TXMasterController.m @@ -178,9 +178,9 @@ - (void)applicationDidChangeScreenParameters:(NSNotification *)aNotification if (visibleRect.size.width < windowRect.size.width) { windowRect.size.width = visibleRect.size.width; } - + windowRect.origin = visibleRect.origin; - + [self.window setFrame:windowRect display:NO]; } } @@ -795,29 +795,35 @@ - (void)completeNick:(BOOL)forward } } - NSArray *scriptPaths = [NSArray arrayWithObjects: - #ifdef TXUserScriptsFolderAvailable - [TPCPreferences whereScriptsUnsupervisedPath], + NSArray *scriptPaths = @[ + NSStringNilValueSubstitute([TPCPreferences whereScriptsLocalPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsUnsupervisedPath]) + ]; +#else + NSArray *scriptPaths = @[ + NSStringNilValueSubstitute([TPCPreferences whereScriptsLocalPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsPath]) + ]; #endif - - [TPCPreferences whereScriptsLocalPath], - [TPCPreferences whereScriptsPath], nil]; for (NSString *path in scriptPaths) { - NSArray *resourceFiles = [_NSFileManager() contentsOfDirectoryAtPath:path error:NULL]; - - if (NSObjectIsNotEmpty(resourceFiles)) { - for (NSString *file in resourceFiles) { - if ([file hasPrefix:@"."] || [file hasSuffix:@".rtf"]) { - continue; - } - - NSArray *parts = [NSArray arrayWithArray:[file componentsSeparatedByString:@"."]]; - NSString *cmdl = [[parts stringAtIndex:0] lowercaseString]; - - if ([choices containsObject:cmdl] == NO) { - [choices safeAddObject:cmdl]; + if (NSObjectIsNotEmpty(path)) { + NSArray *resourceFiles = [_NSFileManager() contentsOfDirectoryAtPath:path error:NULL]; + + if (NSObjectIsNotEmpty(resourceFiles)) { + for (NSString *file in resourceFiles) { + if ([file hasPrefix:@"."] || [file hasSuffix:@".rtf"]) { + continue; + } + + NSArray *parts = [NSArray arrayWithArray:[file componentsSeparatedByString:@"."]]; + NSString *cmdl = [[parts stringAtIndex:0] lowercaseString]; + + if ([choices containsObject:cmdl] == NO) { + [choices safeAddObject:cmdl]; + } } } } @@ -1375,8 +1381,8 @@ - (void)welcomeSheet:(TDCWelcomeSheet *)sender onOK:(NSDictionary *)config for (NSString *s in config[@"channelList"]) { if ([s isChannelName]) { [channels safeAddObject:@{@"channelName": s, - @"joinOnConnect": NSNumberWithBOOL(YES), - @"enableNotifications": NSNumberWithBOOL(YES)}]; + @"joinOnConnect": NSNumberWithBOOL(YES), + @"enableNotifications": NSNumberWithBOOL(YES)}]; } } diff --git a/Classes/Dialogs/Preferences/TDCPreferencesController.m b/Classes/Dialogs/Preferences/TDCPreferencesController.m index 81f37d3284..47bdd24397 100755 --- a/Classes/Dialogs/Preferences/TDCPreferencesController.m +++ b/Classes/Dialogs/Preferences/TDCPreferencesController.m @@ -640,7 +640,7 @@ - (void)onHighlightLoggingChanged:(id)sender - (void)onDownloadExtraAddons:(id)sender { - NSString *version = @"No Sandbox"; + NSString *version = @"No%20Sandbox"; if ([TPCPreferences featureAvailableToOSXLion]) { if ([TPCPreferences sandboxEnabled]) { @@ -650,7 +650,7 @@ - (void)onDownloadExtraAddons:(id)sender if ([TPCPreferences featureAvailableToOSXMountainLion]) { if ([TPCPreferences sandboxEnabled]) { - version = @"Mountain Lion"; + version = @"Mountain%20Lion"; } } diff --git a/Classes/Dialogs/Preferences/TDCPreferencesScriptWrapper.m b/Classes/Dialogs/Preferences/TDCPreferencesScriptWrapper.m index ec9fa76199..6c8df636ec 100755 --- a/Classes/Dialogs/Preferences/TDCPreferencesScriptWrapper.m +++ b/Classes/Dialogs/Preferences/TDCPreferencesScriptWrapper.m @@ -17,16 +17,24 @@ - (id)init - (void)populateData; { - NSArray *scriptPaths = [NSArray arrayWithObjects: - #ifdef TXUserScriptsFolderAvailable - [TPCPreferences whereScriptsUnsupervisedPath], + NSArray *scriptPaths = @[ + NSStringNilValueSubstitute([TPCPreferences whereScriptsLocalPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsUnsupervisedPath]) + ]; +#else + NSArray *scriptPaths = @[ + NSStringNilValueSubstitute([TPCPreferences whereScriptsLocalPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsPath]) + ]; #endif - - [TPCPreferences whereScriptsLocalPath], - [TPCPreferences whereScriptsPath], nil]; for (NSString *path in scriptPaths) { + if (NSObjectIsEmpty(path)) { + continue; + } + NSArray *resourceFiles = [_NSFileManager() contentsOfDirectoryAtPath:path error:NULL]; if (NSObjectIsNotEmpty(resourceFiles)) { diff --git a/Classes/IRC/IRCClient.m b/Classes/IRC/IRCClient.m index 8d298e8004..5bbe81a15b 100755 --- a/Classes/IRC/IRCClient.m +++ b/Classes/IRC/IRCClient.m @@ -2670,20 +2670,29 @@ - (BOOL)sendCommand:(id)str completeTarget:(BOOL)completeTarget target:(NSString NSString *command = [cmd lowercaseString]; NSArray *extensions = @[@".scpt", @".py", @".pyc", @".rb", @".pl", @".sh", @".bash", @""]; - NSArray *scriptPaths = [NSArray arrayWithObjects: - + #ifdef TXUserScriptsFolderAvailable - [TPCPreferences whereScriptsUnsupervisedPath], + NSArray *scriptPaths = @[ + NSStringNilValueSubstitute([TPCPreferences whereScriptsLocalPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsUnsupervisedPath]) + ]; +#else + NSArray *scriptPaths = @[ + NSStringNilValueSubstitute([TPCPreferences whereScriptsLocalPath]), + NSStringNilValueSubstitute([TPCPreferences whereScriptsPath]) + ]; #endif - - [TPCPreferences whereScriptsLocalPath], - [TPCPreferences whereScriptsPath], nil]; NSString *scriptPath = [NSString string]; BOOL scriptFound = NO; for (NSString *path in scriptPaths) { + if (NSObjectIsEmpty(path)) { + continue; + } + if (scriptFound == YES) { break; } diff --git a/Classes/IRC/IRCClientConfig.m b/Classes/IRC/IRCClientConfig.m index 9aa04b32bb..6cc5c0ac15 100755 --- a/Classes/IRC/IRCClientConfig.m +++ b/Classes/IRC/IRCClientConfig.m @@ -285,7 +285,7 @@ - (NSMutableDictionary *)dictionaryValue [floodControl setBool:self.outgoingFloodControl forKey:@"serviceEnabled"]; - dic[@"floodControl"] = floodControl; + [dic safeSetObject:floodControl forKey:@"floodControl"]; NSMutableArray *channelAry = [NSMutableArray array]; NSMutableArray *ignoreAry = [NSMutableArray array]; @@ -298,8 +298,8 @@ - (NSMutableDictionary *)dictionaryValue [ignoreAry safeAddObject:[e dictionaryValue]]; } - dic[@"channelList"] = channelAry; - dic[@"ignoreList"] = ignoreAry; + [dic safeSetObject:channelAry forKey:@"channelList"]; + [dic safeSetObject:ignoreAry forKey:@"ignoreList"]; [dic safeSetObject:TPCPreferencesMigrationAssistantUpgradePath forKey:TPCPreferencesMigrationAssistantVersionKey]; diff --git a/Classes/Preferences/Migration Assistant/TPCPreferencesMigrationAssistant.m b/Classes/Preferences/Migration Assistant/TPCPreferencesMigrationAssistant.m index 4116236388..21cbc44d35 100644 --- a/Classes/Preferences/Migration Assistant/TPCPreferencesMigrationAssistant.m +++ b/Classes/Preferences/Migration Assistant/TPCPreferencesMigrationAssistant.m @@ -61,10 +61,10 @@ + (NSDictionary *)convertIRCClientConfiguration:(NSDictionary *)config [floodControl setBool:[floodControl boolForKey:@"outgoing"] forKey:@"serviceEnabled"]; - nconfig[@"floodControl"] = floodControl; + [nconfig safeSetObject:floodControl forKey:@"floodControl"]; - nconfig[@"channelList"] = config[@"channels"]; - nconfig[@"ignoreList"] = config[@"ignores"]; + [nconfig safeSetObject:config[@"channels"] forKey:@"channelList"]; + [nconfig safeSetObject:config[@"ignores"] forKey:@"ignoreList"]; [nconfig safeSetObject:TPCPreferencesMigrationAssistantUpgradePath forKey:TPCPreferencesMigrationAssistantVersionKey]; diff --git a/Classes/Preferences/TPCPreferences.m b/Classes/Preferences/TPCPreferences.m index 95facbea26..89e3d9cd21 100755 --- a/Classes/Preferences/TPCPreferences.m +++ b/Classes/Preferences/TPCPreferences.m @@ -218,7 +218,7 @@ + (NSString *)whereScriptsPath if ([_NSFileManager() fileExistsAtPath:dest] == NO) { [_NSFileManager() createDirectoryAtPath:dest withIntermediateDirectories:YES attributes:nil error:NULL]; } - + return dest; } diff --git a/Main Project (Textual).xcodeproj/xcshareddata/xcschemes/Textual (Standard Release + No Sandbox).xcscheme b/Main Project (Textual).xcodeproj/xcshareddata/xcschemes/Textual (Standard Release + No Sandbox).xcscheme index 70ae622ed1..aab2544e2b 100644 --- a/Main Project (Textual).xcodeproj/xcshareddata/xcschemes/Textual (Standard Release + No Sandbox).xcscheme +++ b/Main Project (Textual).xcodeproj/xcshareddata/xcschemes/Textual (Standard Release + No Sandbox).xcscheme @@ -10,7 +10,7 @@ buildForTesting = "NO" buildForRunning = "YES" buildForProfiling = "YES" - buildForArchiving = "NO" + buildForArchiving = "YES" buildForAnalyzing = "YES"> NSPrincipalClass NSApplication TXBundleBuildNumber - 11443 + 11450 TXBundleBuildReference - 2.1.1-184-g7c58e71-appstore,llvm4.0 + 2.1.1-186-g33e54a7-stdbuild,nosndbox,llvm4.0 diff --git a/Textual.entitlements b/Textual.entitlements index f01920c087..c9665eb2ec 100644 --- a/Textual.entitlements +++ b/Textual.entitlements @@ -4,6 +4,8 @@ com.apple.security.app-sandbox + com.apple.security.files.bookmarks.app-scope + com.apple.security.network.client com.apple.security.temporary-exception.files.home-relative-path.read-write