aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPPreferencesUpgrade.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-11-18 15:38:41 +0000
committerrowanbeentje <rowan@beent.je>2012-11-18 15:38:41 +0000
commitfb1d481a1d9420bffc830696de66b2874e64a67a (patch)
tree1f894750378b873c1328f81ed30099b888d540d5 /Source/SPPreferencesUpgrade.m
parent5d87d8f8cd268e753a1b2ed647ee413c43360ba6 (diff)
downloadsequelpro-fb1d481a1d9420bffc830696de66b2874e64a67a.tar.gz
sequelpro-fb1d481a1d9420bffc830696de66b2874e64a67a.tar.bz2
sequelpro-fb1d481a1d9420bffc830696de66b2874e64a67a.zip
* Please note this revision will re-prompt for access to all KeyChain passwords *
- Change the bundle identifier from com.google.code.sequel-pro to com.sequelpro.SequelPro - Change the code signing process to use a new identity and requirement, to add Developer ID support on 10.7+ but to also maintain functionality on 10.5+ - Add a preference migration routine to copy the old application defaults to the new bundle identifier's defaults - Re-order the default keys to alphabetical to more easily locate values
Diffstat (limited to 'Source/SPPreferencesUpgrade.m')
-rw-r--r--Source/SPPreferencesUpgrade.m28
1 files changed, 27 insertions, 1 deletions
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