Migration scheme

pull/1/head
Frederic Jacobs 10 years ago
parent 17571b6c54
commit c2d78bba12

@ -12,8 +12,7 @@
#ifdef DEBUG
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
// As long as we have call initialization issues we'll log a bit more aggressively
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
static const int ddLogLevel = LOG_LEVEL_ERROR;
#endif
#endif

@ -4,6 +4,7 @@
#import "CategorizingLogger.h"
#import "DialerViewController.h"
#import "DiscardingLog.h"
#import "Environment.h"
#import "InCallViewController.h"
#import "LeftSideMenuViewController.h"
#import "MMDrawerController.h"
@ -15,9 +16,7 @@
#import "SettingsViewController.h"
#import "TabBarParentViewController.h"
#import "Util.h"
#import <UICKeyChainStore/UICKeyChainStore.h>
#import "Environment.h"
#import "CallServerRequestsManager.h"
#import "VersionMigrations.h"
#define kSignalVersionKey @"SignalUpdateVersionKey"
@ -49,6 +48,7 @@
// Application was updated, let's see if we have a migration scheme for it.
if ([previousVersion isEqualToString:@"1.0.2"]) {
// Migrate from custom preferences to NSUserDefaults
[VersionMigrations migrationFrom1Dot0Dot2toLarger];
}
}
@ -63,13 +63,12 @@
*/
- (void)protectPreferenceFiles{
NSMutableArray *pathsToExclude = [NSMutableArray array];
[pathsToExclude addObject:[[[NSHomeDirectory() stringByAppendingString:@"/Library/Preferences/"] stringByAppendingString:[[NSBundle mainBundle] bundleIdentifier]] stringByAppendingString:@".plist"]];
NSError *error;
NSString *logPath = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"];
NSArray *logsFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logPath error:&error];
@ -79,17 +78,17 @@
for (NSUInteger i = 0; i < [pathsToExclude count]; i++) {
[[NSURL fileURLWithPath:[pathsToExclude objectAtIndex:i]] setResourceValue: [NSNumber numberWithBool: YES]
forKey: NSURLIsExcludedFromBackupKey error: &error];
forKey: NSURLIsExcludedFromBackupKey error: &error];
}
if (error) {
NSLog(@"Error: %@", error.description);
DDLogError(@"Error while removing log files from backup: %@", error.description);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:NSLocalizedString(@"WARNING", @"") message:NSLocalizedString(@"DISABLING_BACKUP_FAILED", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil, nil];
[alert show];
return;
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@ -112,27 +111,27 @@
[[Environment getCurrent].phoneDirectoryManager startUntilCancelled:nil];
[[Environment getCurrent].contactsManager doAfterEnvironmentInitSetup];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
LeftSideMenuViewController *leftSideMenuViewController = [LeftSideMenuViewController new];
self.drawerController = [[MMDrawerController alloc] initWithCenterViewController:leftSideMenuViewController.centerTabBarViewController leftDrawerViewController:leftSideMenuViewController];
self.window.rootViewController = _drawerController;
[self.window makeKeyAndVisible];
//Accept push notification when app is not open
NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteNotif) {
DDLogInfo(@"Application was launched by tapping a push notification.");
[self application:application didReceiveRemoteNotification:remoteNotif];
}
[[[Environment phoneManager] currentCallObservable] watchLatestValue:^(CallState* latestCall) {
if (latestCall == nil){
return;
}
InCallViewController *callViewController = [InCallViewController inCallViewControllerWithCallState:latestCall
andOptionallyKnownContact:[latestCall potentiallySpecifiedContact]];
andOptionallyKnownContact:[latestCall potentiallySpecifiedContact]];
[_drawerController.centerViewController presentViewController:callViewController animated:YES completion:nil];
} onThread:[NSThread mainThread] untilCancelled:nil];
@ -158,7 +157,7 @@
DDLogError(@"Error parsing remote notification. Error: %@.", ex);
return;
}
[[Environment phoneManager] incomingCallWithSession:call];
}

@ -10,9 +10,6 @@
#import "PreferencesUtil.h"
#import "Util.h"
//@TODO: Split Up into Seperate components.
#define ADDRESSBOOK_QUEUE dispatch_get_main_queue()
static NSString *const FAVOURITES_DEFAULT_KEY = @"FAVOURITES_DEFAULT_KEY";

@ -21,7 +21,6 @@
#define TXT_END_CALL_HANGUP_REMOTE NSLocalizedString(@"END_CALL_HANGUP_REMOTE", @"")
#define TXT_END_CALL_HANGUP_LOCAL NSLocalizedString(@"END_CALL_HANGUP_LOCAL", @"")
#define TXT_END_CALL_REPLACED_BY_NEXT NSLocalizedString(@"END_CALL_REPLACED_BY_NEXT", @"")
// @todo: some languages probably don't prefix this sort of thing
#define TXT_END_CALL_MESSAGE_FROM_SERVER_PREFIX NSLocalizedString(@"END_CALL_MESSAGE_FROM_SERVER_PREFIX", @"")
#pragma mark - Menu Table Cell Titles

@ -45,7 +45,6 @@ static unsigned char DH3K_PRIME[]={
@implementation Release
+(Environment*) releaseEnvironmentWithLogging:(id<Logging>)logging {
// @todo: turn off error notification
//ErrorHandlerBlock errorDiscarder = ^(id error, id relatedInfo, bool causedTermination) {};
ErrorHandlerBlock errorNoter = ^(id error, id relatedInfo, bool causedTermination) { DDLogError(@"%@: %@, %d", error, relatedInfo, causedTermination); };

@ -6,23 +6,26 @@
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "PushManager.h"
#import "VersionMigrations.h"
@implementation VersionMigrations
+ (void)migrationFrom1Dot0Dot2toLarger{
// Read everything in preference file, drop into NSUserDefaults
// Preferences were stored in both a preference file and a plist in the documents folder, as a temporary measure, we are going to move all the preferences to the NSUserDefaults preference store, those will be migrated to a SQLCipher-backed database
NSString* documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"/Documents/"];
NSString *path = [NSString stringWithFormat:@"%@/%@.plist", documentsDirectory, @"RedPhone-Data"];
NSData *plistData = [NSData dataWithContentsOfFile:path];
NSString *error;
NSError *error;
NSPropertyListFormat format;
NSDictionary *dict = [NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error];
NSDictionary *dict = [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListImmutable format:&format error:&error];
NSLog(@"%@", dict);
NSArray *entries = [dict allKeys];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@ -33,7 +36,17 @@
[defaults synchronize];
// delete
[[NSFileManager defaultManager]removeItemAtPath:path error:&error];
if (error) {
DDLogError(@"Error while migrating data: %@", error.description);
}
// Some users push IDs were not correctly registered, by precaution, we are going to re-register all of them
[[PushManager sharedManager] askForPushRegistration];
return;
}
@end

@ -12,7 +12,6 @@
+ (instancetype)sharedManager;
- (void)verifyPushActivated;
- (void)askForPushRegistration;

@ -124,7 +124,6 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN
}
-(NSURL*) toUrl {
// @todo: can we return a more user-friendly link (using original text) in some limited cases?
NSString* link = [NSString stringWithFormat:@"telprompt://%@", e164];
return [NSURL URLWithString:link];
}

Loading…
Cancel
Save