aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-10-10 03:49:58 +0200
committerMax <post@wickenrode.com>2015-10-10 03:49:58 +0200
commit01ef3ad33d260119ee61b949414f038be2c8d00e (patch)
treed4ea4eff90c6ae334adb17ba5573213f029f86d1
parent2cb875fb99e0c017b545b8e8427eb565e15cca1e (diff)
downloadsequelpro-01ef3ad33d260119ee61b949414f038be2c8d00e.tar.gz
sequelpro-01ef3ad33d260119ee61b949414f038be2c8d00e.tar.bz2
sequelpro-01ef3ad33d260119ee61b949414f038be2c8d00e.zip
Change two magic strings into constants
-rw-r--r--Source/GeneratePreviewForURL.m6
-rw-r--r--Source/SPConstants.h3
-rw-r--r--Source/SPConstants.m3
-rw-r--r--Source/SPContentFilterManager.m4
-rw-r--r--Source/SPDatabaseDocument.m14
-rw-r--r--Source/SPQueryFavoriteManager.m4
6 files changed, 20 insertions, 14 deletions
diff --git a/Source/GeneratePreviewForURL.m b/Source/GeneratePreviewForURL.m
index ef20b852..2209f746 100644
--- a/Source/GeneratePreviewForURL.m
+++ b/Source/GeneratePreviewForURL.m
@@ -84,7 +84,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
}
// Dispatch different spf formats
- if([[spf objectForKey:@"format"] isEqualToString:@"connection"]) {
+ if([[spf objectForKey:SPFFormatKey] isEqualToString:@"connection"]) {
template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginConnectionTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
@@ -140,7 +140,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
[dateFormatter release];
}
- else if([[spf objectForKey:@"format"] isEqualToString:@"content filters"]) {
+ else if([[spf objectForKey:SPFFormatKey] isEqualToString:@"content filters"]) {
template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginContentFiltersTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
@@ -156,7 +156,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
];
}
- else if([[spf objectForKey:@"format"] isEqualToString:@"query favorites"]) {
+ else if([[spf objectForKey:SPFFormatKey] isEqualToString:@"query favorites"]) {
template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginQueryFavoritesTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index f2816745..80df6ba4 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -492,6 +492,9 @@ extern NSString *SPFavoriteSSLCACertFileLocationKey;
extern NSString *SPFavoriteUseCompressionKey;
extern NSString *SPConnectionFavoritesChangedNotification;
+extern NSString *SPFFormatKey;
+extern NSString *SPFVersionKey;
+
// Favorites import/export
extern NSString *SPFavoritesDataRootKey;
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index 42631dab..ca8164e3 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -302,6 +302,9 @@ NSString *SPFavoriteSSLCACertFileLocationKey = @"sslCACertFileLocati
NSString *SPFavoriteUseCompressionKey = @"useCompression";
NSString *SPConnectionFavoritesChangedNotification = @"SPConnectionFavoritesChanged";
+NSString *SPFFormatKey = @"format";
+NSString *SPFVersionKey = @"version";
+
// Favorites import/export
NSString *SPFavoritesDataRootKey = @"SPConnectionFavorites";
diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m
index a8e747e2..dca1fda8 100644
--- a/Source/SPContentFilterManager.m
+++ b/Source/SPContentFilterManager.m
@@ -930,8 +930,8 @@ static NSString *SPExportFilterAction = @"SPExportFilter";
NSMutableArray *filterData = [NSMutableArray array];
- [spfdata setObject:@1 forKey:@"version"];
- [spfdata setObject:@"content filters" forKey:@"format"];
+ [spfdata setObject:@1 forKey:SPFVersionKey];
+ [spfdata setObject:@"content filters" forKey:SPFFormatKey];
[spfdata setObject:@NO forKey:@"encrypted"];
NSIndexSet *indexes = [contentFilterTableView selectedRowIndexes];
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index dd3baae3..57ecdd97 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -3143,8 +3143,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
[info setObject:[NSNumber numberWithBool:[[spfDocData_temp objectForKey:@"save_password"] boolValue]] forKey:@"save_password"];
[info setObject:[NSNumber numberWithBool:[[spfDocData_temp objectForKey:@"include_session"] boolValue]] forKey:@"include_session"];
[info setObject:[NSNumber numberWithBool:[[spfDocData_temp objectForKey:@"save_editor_content"] boolValue]] forKey:@"save_editor_content"];
- [info setObject:@1 forKey:@"version"];
- [info setObject:@"connection bundle" forKey:@"format"];
+ [info setObject:@1 forKey:SPFVersionKey];
+ [info setObject:@"connection bundle" forKey:SPFFormatKey];
// Loop through all windows
for(NSWindow *window in [SPAppDelegate orderedDatabaseConnectionWindows]) {
@@ -3303,7 +3303,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
}
// For dispatching later
- if(![[spf objectForKey:@"format"] isEqualToString:@"connection"]) {
+ if(![[spf objectForKey:SPFFormatKey] isEqualToString:@"connection"]) {
NSLog(@"SPF file format is not 'connection'.");
[spf release];
return NO;
@@ -3352,8 +3352,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
NSMutableDictionary *spfData = [NSMutableDictionary dictionary];
// Add basic details
- [spfStructure setObject:@1 forKey:@"version"];
- [spfStructure setObject:@"connection" forKey:@"format"];
+ [spfStructure setObject:@1 forKey:SPFVersionKey];
+ [spfStructure setObject:@"connection" forKey:SPFFormatKey];
[spfStructure setObject:@"mysql" forKey:@"rdbms_type"];
if([self mySQLVersion])
[spfStructure setObject:[self mySQLVersion] forKey:@"rdbms_version"];
@@ -4817,12 +4817,12 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
}
// If the .spf format is unhandled, error.
- if (![[spf objectForKey:@"format"] isEqualToString:@"connection"]) {
+ if (![[spf objectForKey:SPFFormatKey] isEqualToString:@"connection"]) {
NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Warning", @"warning")]
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
- informativeTextWithFormat:NSLocalizedString(@"The chosen file “%@” contains ‘%@’ data.", @"message while reading a spf file which matches non-supported formats."), path, [spf objectForKey:@"format"]];
+ informativeTextWithFormat:NSLocalizedString(@"The chosen file “%@” contains ‘%@’ data.", @"message while reading a spf file which matches non-supported formats."), path, [spf objectForKey:SPFFormatKey]];
[alert setAlertStyle:NSWarningAlertStyle];
[spf release];
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 3738fe0d..b1ea9a49 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -917,8 +917,8 @@
NSMutableArray *favoriteData = [NSMutableArray array];
- [spfdata setObject:@1 forKey:@"version"];
- [spfdata setObject:@"query favorites" forKey:@"format"];
+ [spfdata setObject:@1 forKey:SPFVersionKey];
+ [spfdata setObject:@"query favorites" forKey:SPFFormatKey];
[spfdata setObject:@NO forKey:@"encrypted"];
NSIndexSet *indexes = [favoritesTableView selectedRowIndexes];