aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/GeneratePreviewForURL.m12
-rw-r--r--Source/SPAppController.m3
-rw-r--r--Source/SPConstants.h3
-rw-r--r--Source/SPConstants.m2
-rw-r--r--Source/SPPreferenceController.m7
-rw-r--r--Source/SPPreferencesUpgrade.h1
-rw-r--r--Source/SPPreferencesUpgrade.m28
-rw-r--r--Source/SPTableContent.h1
8 files changed, 43 insertions, 14 deletions
diff --git a/Source/GeneratePreviewForURL.m b/Source/GeneratePreviewForURL.m
index b9292599..9b66d3e7 100644
--- a/Source/GeneratePreviewForURL.m
+++ b/Source/GeneratePreviewForURL.m
@@ -97,7 +97,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
// Dispatch different spf formats
if([[spf objectForKey:@"format"] isEqualToString:@"connection"]) {
- template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginConnectionTemplate" ofType:@"html"]
+ template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginConnectionTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
if (template == nil || ![template length] || templateReadError != nil) {
@@ -154,7 +154,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
else if([[spf objectForKey:@"format"] isEqualToString:@"content filters"]) {
- template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginContentFiltersTemplate" ofType:@"html"]
+ template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginContentFiltersTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
if (template == nil || ![template length] || templateReadError != nil) {
@@ -170,7 +170,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
else if([[spf objectForKey:@"format"] isEqualToString:@"query favorites"]) {
- template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginQueryFavoritesTemplate" ofType:@"html"]
+ template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginQueryFavoritesTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
if (template == nil || ![template length] || templateReadError != nil) {
@@ -190,7 +190,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
else if([urlExtension isEqualToString:@"spfs"]) {
- template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginConnectionBundleTemplate" ofType:@"html"]
+ template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginConnectionBundleTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
if (template == nil || ![template length] || templateReadError != nil) {
@@ -198,7 +198,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
return noErr;
}
- NSString *windowTemplate = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginConnectionBundleWindowTemplate" ofType:@"html"]
+ NSString *windowTemplate = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginConnectionBundleWindowTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
if (windowTemplate == nil || ![windowTemplate length] || templateReadError != nil) {
@@ -331,7 +331,7 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
else if([urlExtension isEqualToString:@"sql"]) {
- template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.google.code.sequel-pro.qlgenerator"] pathForResource:@"SPQLPluginSQLTemplate" ofType:@"html"]
+ template = [NSString stringWithContentsOfFile:[[NSBundle bundleWithIdentifier:@"com.sequelpro.SequelPro.qlgenerator"] pathForResource:@"SPQLPluginSQLTemplate" ofType:@"html"]
encoding:NSUTF8StringEncoding error:&templateReadError];
if (template == nil || ![template length] || templateReadError != nil) {
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index c10b8370..da70ceb9 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -112,6 +112,9 @@ YY_BUFFER_STATE yy_scan_string (const char *);
{
// Register application defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PreferenceDefaults" ofType:@"plist"]]];
+
+ // Upgrade prefs before any other parts of the app pick up on the values
+ SPApplyRevisionChanges();
}
/**
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 03da11a6..81a7310e 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -278,7 +278,8 @@ extern NSString *SPDataSupportFolder;
extern NSString *SPTableContentFilterKey;
// Preference key constants
-//
+extern NSString *SPFirstRun;
+
// General Prefpane
extern NSString *SPDefaultFavorite;
extern NSString *SPSelectLastFavoriteUsed;
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index 33f5e22a..7dae561c 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -72,6 +72,8 @@ NSString *SPDataSupportFolder = @"Data";
NSString *SPTableContentFilterKey = @"filter";
// Preference key constants
+NSString *SPFirstRun = @"SPFirstRun";
+
// General Prefpane
NSString *SPDefaultFavorite = @"DefaultFavorite";
NSString *SPSelectLastFavoriteUsed = @"SelectLastFavoriteUsed";
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 0716acf4..f6670a03 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -31,7 +31,6 @@
// More info at <http://code.google.com/p/sequel-pro/>
#import "SPPreferenceController.h"
-#import "SPPreferencesUpgrade.h"
#import "SPTablesPreferencePane.h"
#import "SPEditorPreferencePane.h"
#import "SPGeneralPreferencePane.h"
@@ -60,11 +59,7 @@
*/
- (id)init
{
- if ((self = [super initWithWindowNibName:@"Preferences"])) {
-
- // Upgrade prefs
- SPApplyRevisionChanges();
-
+ if ((self = [super initWithWindowNibName:@"Preferences"])) {
fontChangeTarget = 0;
}
diff --git a/Source/SPPreferencesUpgrade.h b/Source/SPPreferencesUpgrade.h
index db1b67cd..1f50a2f9 100644
--- a/Source/SPPreferencesUpgrade.h
+++ b/Source/SPPreferencesUpgrade.h
@@ -41,5 +41,6 @@
void SPApplyRevisionChanges(void);
void SPMigrateConnectionFavoritesData(void);
+void SPMigratePreferencesFromPreviousIdentifer(void);
@end
diff --git a/Source/SPPreferencesUpgrade.m b/Source/SPPreferencesUpgrade.m
index 3dbd7647..208bbab4 100644
--- a/Source/SPPreferencesUpgrade.m
+++ b/Source/SPPreferencesUpgrade.m
@@ -48,7 +48,14 @@ void SPApplyRevisionChanges(void)
NSUInteger currentVersionNumber, recordedVersionNumber = 0;
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
-
+
+ // If this is the first run, check for a preferences with the old bundle identifier and
+ // migrate them before running any preference upgrade routines
+ if ([prefs boolForKey:SPFirstRun]) {
+ SPMigratePreferencesFromPreviousIdentifer();
+ [prefs setBool:NO forKey:SPFirstRun];
+ }
+
// Get the current bundle version number (the SVN build number) for per-version upgrades
currentVersionNumber = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] integerValue];
@@ -386,4 +393,23 @@ void SPMigrateConnectionFavoritesData(void)
[favorites release];
}
+/**
+ * Migrates across all preferences for an old bundle identifier to the current preferences file.
+ */
+void SPMigratePreferencesFromPreviousIdentifer(void)
+{
+ NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
+
+ CFStringRef oldIdentifier = CFSTR("com.google.code.sequel-pro");
+ CFArrayRef oldPrefKeys = CFPreferencesCopyKeyList(oldIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ NSDictionary *oldPrefs = (NSDictionary *)CFPreferencesCopyMultiple(oldPrefKeys, oldIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+
+ for (id eachKey in oldPrefs) {
+ [prefs setObject:[oldPrefs objectForKey:eachKey] forKey:eachKey];
+ }
+
+ [oldPrefs release];
+ CFRelease(oldPrefKeys);
+}
+
@end
diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h
index c9fa1d7c..1eb6b678 100644
--- a/Source/SPTableContent.h
+++ b/Source/SPTableContent.h
@@ -207,6 +207,7 @@
// Table loading methods and information
- (void)loadTable:(NSString *)aTable;
+- (void)setTableDetails:(NSDictionary *)tableDetails;
- (void)clearTableValues;
- (void)loadTableValues;
- (NSString *)tableFilterString;