2011-11-30 21:42:40 +00:00
|
|
|
//
|
2013-04-25 01:26:04 +00:00
|
|
|
// MPiOSAppDelegate.m
|
2012-02-03 07:45:09 +00:00
|
|
|
// MasterPassword
|
2011-11-30 21:42:40 +00:00
|
|
|
//
|
|
|
|
// Created by Maarten Billemont on 24/11/11.
|
|
|
|
// Copyright (c) 2011 Lyndir. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2013-04-25 01:26:04 +00:00
|
|
|
#import "MPiOSAppDelegate.h"
|
2012-05-11 20:45:05 +00:00
|
|
|
#import "MPAppDelegate_Key.h"
|
|
|
|
#import "MPAppDelegate_Store.h"
|
2012-02-05 21:01:37 +00:00
|
|
|
#import "IASKSettingsReader.h"
|
2013-04-27 21:14:05 +00:00
|
|
|
#import "GPPSignIn.h"
|
2012-05-03 14:49:15 +00:00
|
|
|
|
2013-04-25 01:26:04 +00:00
|
|
|
@implementation MPiOSAppDelegate
|
2011-11-30 21:42:40 +00:00
|
|
|
|
2012-01-05 00:44:15 +00:00
|
|
|
+ (void)initialize {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-03-05 21:19:05 +00:00
|
|
|
[MPiOSConfig get];
|
2013-04-30 01:15:14 +00:00
|
|
|
[PearlLogger get].historyLevel = [[MPiOSConfig get].traceMode boolValue]? PearlLogLevelTrace: PearlLogLevelInfo;
|
2012-01-24 23:30:43 +00:00
|
|
|
#ifdef DEBUG
|
2012-08-04 21:15:50 +00:00
|
|
|
[PearlLogger get].printLevel = PearlLogLevelDebug;
|
2012-05-06 23:15:19 +00:00
|
|
|
//[NSClassFromString(@"WebView") performSelector:NSSelectorFromString(@"_enableRemoteInspector")];
|
2012-01-24 23:30:43 +00:00
|
|
|
#endif
|
2012-01-05 00:44:15 +00:00
|
|
|
}
|
2012-05-11 20:45:05 +00:00
|
|
|
|
2012-01-24 23:30:43 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-27 20:31:22 +00:00
|
|
|
[[[NSBundle mainBundle] mutableInfoDictionary] setObject:@"Master Password" forKey:@"CFBundleDisplayName"];
|
2012-05-27 12:26:13 +00:00
|
|
|
[[[NSBundle mainBundle] mutableLocalizedInfoDictionary] setObject:@"Master Password" forKey:@"CFBundleDisplayName"];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-09-19 21:29:21 +00:00
|
|
|
#ifdef TESTFLIGHT_SDK_VERSION
|
2012-06-14 19:56:54 +00:00
|
|
|
@try {
|
|
|
|
NSString *testFlightToken = [self testFlightToken];
|
|
|
|
if ([testFlightToken length]) {
|
|
|
|
inf(@"Initializing TestFlight");
|
2012-09-21 08:26:53 +00:00
|
|
|
#ifdef ADHOC
|
2012-06-14 19:56:54 +00:00
|
|
|
[TestFlight setDeviceIdentifier:[(id)[UIDevice currentDevice] uniqueIdentifier]];
|
2012-09-21 08:26:53 +00:00
|
|
|
#else
|
|
|
|
[TestFlight setDeviceIdentifier:[PearlKeyChain deviceIdentifier]];
|
|
|
|
#endif
|
2012-08-24 08:12:15 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:@"Anonymous" forKey:@"username"];
|
|
|
|
[TestFlight addCustomEnvironmentInformation:[PearlKeyChain deviceIdentifier] forKey:@"deviceIdentifier"];
|
2013-04-20 17:51:37 +00:00
|
|
|
[TestFlight setOptions:@{
|
|
|
|
@"logToConsole" : @NO,
|
|
|
|
@"logToSTDERR" : @NO
|
|
|
|
}];
|
2012-06-14 19:56:54 +00:00
|
|
|
[TestFlight takeOff:testFlightToken];
|
|
|
|
[[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) {
|
|
|
|
PearlLogLevel level = PearlLogLevelWarn;
|
|
|
|
if ([[MPiOSConfig get].sendInfo boolValue])
|
|
|
|
level = PearlLogLevelInfo;
|
|
|
|
|
|
|
|
if (message.level >= level)
|
2013-04-20 18:11:19 +00:00
|
|
|
TFLog( @"%@", [message messageDescription] );
|
2012-06-14 19:56:54 +00:00
|
|
|
|
|
|
|
return YES;
|
|
|
|
}];
|
2013-04-20 18:11:19 +00:00
|
|
|
TFLog( @"TestFlight (%@) initialized for: %@ v%@.", //
|
|
|
|
TESTFLIGHT_SDK_VERSION, [PearlInfoPlist get].CFBundleName, [PearlInfoPlist get].CFBundleVersion );
|
2012-05-03 14:49:15 +00:00
|
|
|
}
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
@catch (id exception) {
|
|
|
|
err(@"TestFlight: %@", exception);
|
|
|
|
}
|
2012-08-04 21:15:50 +00:00
|
|
|
#endif
|
2013-01-31 21:22:37 +00:00
|
|
|
@try {
|
|
|
|
NSString *googlePlusClientID = [self googlePlusClientID];
|
|
|
|
if ([googlePlusClientID length]) {
|
|
|
|
inf(@"Initializing Google+");
|
2013-04-27 21:14:05 +00:00
|
|
|
[[GPPSignIn sharedInstance] setClientID:googlePlusClientID];
|
2013-01-31 21:22:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@catch (id exception) {
|
|
|
|
err(@"Google+: %@", exception);
|
|
|
|
}
|
2012-06-14 19:56:54 +00:00
|
|
|
@try {
|
|
|
|
NSString *crashlyticsAPIKey = [self crashlyticsAPIKey];
|
|
|
|
if ([crashlyticsAPIKey length]) {
|
|
|
|
inf(@"Initializing Crashlytics");
|
2012-06-15 09:34:53 +00:00
|
|
|
#if defined (DEBUG) || defined (ADHOC)
|
2012-06-14 19:56:54 +00:00
|
|
|
[Crashlytics sharedInstance].debugMode = YES;
|
2012-06-15 09:34:53 +00:00
|
|
|
#endif
|
2012-08-24 08:12:15 +00:00
|
|
|
[Crashlytics setUserIdentifier:[PearlKeyChain deviceIdentifier]];
|
|
|
|
[Crashlytics setObjectValue:[PearlKeyChain deviceIdentifier] forKey:@"deviceIdentifier"];
|
|
|
|
[Crashlytics setUserName:@"Anonymous"];
|
|
|
|
[Crashlytics setObjectValue:@"Anonymous" forKey:@"username"];
|
|
|
|
[Crashlytics startWithAPIKey:crashlyticsAPIKey];
|
2012-06-14 19:56:54 +00:00
|
|
|
[[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) {
|
|
|
|
PearlLogLevel level = PearlLogLevelWarn;
|
|
|
|
if ([[MPiOSConfig get].sendInfo boolValue])
|
|
|
|
level = PearlLogLevelInfo;
|
|
|
|
|
|
|
|
if (message.level >= level)
|
2013-04-20 18:11:19 +00:00
|
|
|
CLSLog( @"%@", [message messageDescription] );
|
2012-06-14 19:56:54 +00:00
|
|
|
|
|
|
|
return YES;
|
|
|
|
}];
|
2013-04-20 18:11:19 +00:00
|
|
|
CLSLog( @"Crashlytics (%@) initialized for: %@ v%@.", //
|
|
|
|
[Crashlytics sharedInstance].version, [PearlInfoPlist get].CFBundleName, [PearlInfoPlist get].CFBundleVersion );
|
2012-05-03 14:49:15 +00:00
|
|
|
}
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
@catch (id exception) {
|
|
|
|
err(@"Crashlytics: %@", exception);
|
|
|
|
}
|
2012-05-23 06:58:01 +00:00
|
|
|
@try {
|
2012-06-14 19:56:54 +00:00
|
|
|
NSString *localyticsKey = [self localyticsKey];
|
|
|
|
if ([localyticsKey length]) {
|
|
|
|
inf(@"Initializing Localytics");
|
2012-09-12 22:37:46 +00:00
|
|
|
[[LocalyticsSession sharedLocalyticsSession] LocalyticsSession:localyticsKey];
|
2012-09-21 08:26:53 +00:00
|
|
|
[[LocalyticsSession sharedLocalyticsSession] open];
|
2012-09-12 13:58:54 +00:00
|
|
|
[LocalyticsSession sharedLocalyticsSession].enableHTTPS = YES;
|
2013-04-27 20:24:29 +00:00
|
|
|
[[LocalyticsSession sharedLocalyticsSession] setCustomerId:[PearlKeyChain deviceIdentifier]];
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] setCustomerName:@"Anonymous"];
|
2012-09-21 08:26:53 +00:00
|
|
|
[[LocalyticsSession sharedLocalyticsSession] upload];
|
2012-06-14 19:56:54 +00:00
|
|
|
[[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) {
|
|
|
|
if (message.level >= PearlLogLevelWarn)
|
2013-04-20 17:51:37 +00:00
|
|
|
MPCheckpoint( @"Problem", @{
|
|
|
|
@"level" : @(PearlLogLevelStr( message.level )),
|
|
|
|
@"message" : message.message
|
|
|
|
} );
|
2012-06-14 19:56:54 +00:00
|
|
|
|
|
|
|
return YES;
|
|
|
|
}];
|
2012-05-23 06:58:01 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-14 19:56:54 +00:00
|
|
|
@catch (id exception) {
|
|
|
|
err(@"Localytics exception: %@", exception);
|
2012-05-23 06:58:01 +00:00
|
|
|
}
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2013-04-20 18:11:19 +00:00
|
|
|
UIImage *navBarImage = [[UIImage imageNamed:@"ui_navbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake( 0, 5, 0, 5 )];
|
2012-01-24 23:30:43 +00:00
|
|
|
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault];
|
|
|
|
[[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsLandscapePhone];
|
|
|
|
[[UINavigationBar appearance] setTitleTextAttributes:
|
2013-04-20 18:11:19 +00:00
|
|
|
@{
|
|
|
|
UITextAttributeTextColor : [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f],
|
|
|
|
UITextAttributeTextShadowColor : [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f],
|
|
|
|
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake( 0, -1 )],
|
|
|
|
UITextAttributeFont : [UIFont fontWithName:@"Exo-Bold" size:20.0f]
|
|
|
|
}];
|
|
|
|
|
|
|
|
UIImage *navBarButton = [[UIImage imageNamed:@"ui_navbar_button"] resizableImageWithCapInsets:UIEdgeInsetsMake( 0, 5, 0, 5 )];
|
|
|
|
UIImage *navBarBack = [[UIImage imageNamed:@"ui_navbar_back"] resizableImageWithCapInsets:UIEdgeInsetsMake( 0, 13, 0, 5 )];
|
2012-01-24 23:30:43 +00:00
|
|
|
[[UIBarButtonItem appearance] setBackgroundImage:navBarButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
|
|
|
[[UIBarButtonItem appearance] setBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
|
|
|
|
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:navBarBack forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
|
|
|
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
|
|
|
|
[[UIBarButtonItem appearance] setTitleTextAttributes:
|
2013-04-20 18:11:19 +00:00
|
|
|
@{
|
|
|
|
UITextAttributeTextColor : [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f],
|
|
|
|
UITextAttributeTextShadowColor : [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f],
|
|
|
|
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake( 0, 1 )]//,
|
|
|
|
// Causes a bug in iOS where image views get oddly stretched... or something.
|
|
|
|
//UITextAttributeFont: [UIFont fontWithName:@"HelveticaNeue" size:13.0f]
|
|
|
|
}
|
2012-08-04 21:15:50 +00:00
|
|
|
forState:UIControlStateNormal];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2013-04-20 18:11:19 +00:00
|
|
|
UIImage *toolBarImage = [[UIImage imageNamed:@"ui_toolbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake( 25, 5, 5, 5 )];
|
2012-01-24 23:30:43 +00:00
|
|
|
[[UISearchBar appearance] setBackgroundImage:toolBarImage];
|
|
|
|
[[UIToolbar appearance] setBackgroundImage:toolBarImage forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-01-24 23:30:43 +00:00
|
|
|
/*
|
2012-06-14 19:56:54 +00:00
|
|
|
UIImage *minImage = [[UIImage imageNamed:@"slider-minimum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
|
|
|
|
UIImage *maxImage = [[UIImage imageNamed:@"slider-maximum.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
|
|
|
|
UIImage *thumbImage = [UIImage imageNamed:@"slider-handle.png"];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
[[UISlider appearance] setMaximumTrackImage:maxImage forState:UIControlStateNormal];
|
|
|
|
[[UISlider appearance] setMinimumTrackImage:minImage forState:UIControlStateNormal];
|
|
|
|
[[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateNormal];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
UIImage *segmentSelected = [[UIImage imageNamed:@"segcontrol_sel.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
|
|
|
|
UIImage *segmentUnselected = [[UIImage imageNamed:@"segcontrol_uns.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 15, 0, 15)];
|
|
|
|
UIImage *segmentSelectedUnselected = [UIImage imageNamed:@"segcontrol_sel-uns.png"];
|
|
|
|
UIImage *segUnselectedSelected = [UIImage imageNamed:@"segcontrol_uns-sel.png"];
|
|
|
|
UIImage *segmentUnselectedUnselected = [UIImage imageNamed:@"segcontrol_uns-uns.png"];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
[[UISegmentedControl appearance] setBackgroundImage:segmentUnselected forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
|
|
|
[[UISegmentedControl appearance] setBackgroundImage:segmentSelected forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
[[UISegmentedControl appearance] setDividerImage:segmentUnselectedUnselected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
|
|
|
[[UISegmentedControl appearance] setDividerImage:segmentSelectedUnselected forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
|
|
|
|
[[UISegmentedControl appearance] setDividerImage:segUnselectedSelected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
|
|
|
|
*/
|
2012-06-07 22:40:30 +00:00
|
|
|
|
2013-01-31 05:42:32 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:MPCheckConfigNotification object:nil queue:nil usingBlock:
|
2013-04-20 18:11:19 +00:00
|
|
|
^(NSNotification *note) {
|
|
|
|
if ([[MPiOSConfig get].sendInfo boolValue]) {
|
|
|
|
if ([PearlLogger get].printLevel > PearlLogLevelInfo)
|
|
|
|
[PearlLogger get].printLevel = PearlLogLevelInfo;
|
|
|
|
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[[MPConfig get].rememberLogin boolValue] forKey:@"rememberLogin"];
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[self storeManager].cloudEnabled forKey:@"iCloud"];
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[[MPConfig get].iCloudDecided boolValue] forKey:@"iCloudDecided"];
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[[MPiOSConfig get].sendInfo boolValue] forKey:@"sendInfo"];
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[[MPiOSConfig get].helpHidden boolValue] forKey:@"helpHidden"];
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[[MPiOSConfig get].showSetup boolValue] forKey:@"showQuickStart"];
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[[PearlConfig get].firstRun boolValue] forKey:@"firstRun"];
|
|
|
|
[[Crashlytics sharedInstance] setIntValue:[[PearlConfig get].launchCount intValue] forKey:@"launchCount"];
|
|
|
|
[[Crashlytics sharedInstance] setBoolValue:[[PearlConfig get].askForReviews boolValue] forKey:@"askForReviews"];
|
|
|
|
[[Crashlytics sharedInstance]
|
|
|
|
setIntValue:[[PearlConfig get].reviewAfterLaunches intValue] forKey:@"reviewAfterLaunches"];
|
|
|
|
[[Crashlytics sharedInstance] setObjectValue:[PearlConfig get].reviewedVersion forKey:@"reviewedVersion"];
|
2013-01-31 05:42:32 +00:00
|
|
|
|
|
|
|
#ifdef TESTFLIGHT_SDK_VERSION
|
2013-05-02 15:19:34 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPConfig get].rememberLogin)
|
2013-04-20 18:11:19 +00:00
|
|
|
forKey:@"rememberLogin"];
|
2013-05-02 15:19:34 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringB([self storeManager].cloudEnabled)
|
|
|
|
forKey:@"iCloud"];
|
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPConfig get].iCloudDecided)
|
2013-04-20 18:11:19 +00:00
|
|
|
forKey:@"iCloudDecided"];
|
2013-05-02 15:19:34 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPiOSConfig get].sendInfo)
|
|
|
|
forKey:@"sendInfo"];
|
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPiOSConfig get].helpHidden)
|
2013-04-20 18:11:19 +00:00
|
|
|
forKey:@"helpHidden"];
|
2013-05-02 15:19:34 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPiOSConfig get].showSetup)
|
2013-04-20 18:11:19 +00:00
|
|
|
forKey:@"showQuickStart"];
|
2013-05-02 15:19:34 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].firstRun)
|
|
|
|
forKey:@"firstRun"];
|
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].launchCount)
|
|
|
|
forKey:@"launchCount"];
|
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].askForReviews)
|
2013-04-20 18:11:19 +00:00
|
|
|
forKey:@"askForReviews"];
|
2013-05-02 15:19:34 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].reviewAfterLaunches)
|
2013-04-20 18:11:19 +00:00
|
|
|
forKey:@"reviewAfterLaunches"];
|
2013-05-02 15:19:34 +00:00
|
|
|
[TestFlight addCustomEnvironmentInformation:[PearlConfig get].reviewedVersion
|
|
|
|
forKey:@"reviewedVersion"];
|
2013-01-31 05:42:32 +00:00
|
|
|
#endif
|
2013-04-20 18:11:19 +00:00
|
|
|
MPCheckpoint( MPCheckpointConfig, @{
|
|
|
|
@"rememberLogin" : @([[MPConfig get].rememberLogin boolValue]),
|
|
|
|
@"iCloud" : @([self storeManager].cloudEnabled),
|
|
|
|
@"iCloudDecided" : @([[MPConfig get].iCloudDecided boolValue]),
|
|
|
|
@"sendInfo" : @([[MPiOSConfig get].sendInfo boolValue]),
|
|
|
|
@"helpHidden" : @([[MPiOSConfig get].helpHidden boolValue]),
|
|
|
|
@"showQuickStart" : @([[MPiOSConfig get].showSetup boolValue]),
|
|
|
|
@"firstRun" : @([[PearlConfig get].firstRun boolValue]),
|
2013-05-02 15:19:34 +00:00
|
|
|
@"launchCount" : NilToNSNull([PearlConfig get].launchCount),
|
2013-04-20 18:11:19 +00:00
|
|
|
@"askForReviews" : @([[PearlConfig get].askForReviews boolValue]),
|
2013-05-02 15:19:34 +00:00
|
|
|
@"reviewAfterLaunches" : NilToNSNull([PearlConfig get].reviewAfterLaunches),
|
2013-04-20 18:11:19 +00:00
|
|
|
@"reviewedVersion" : NilToNSNull([PearlConfig get].reviewedVersion)
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
addObserverForName:kIASKAppSettingChanged object:nil queue:nil usingBlock:^(NSNotification *note) {
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:note userInfo:nil];
|
|
|
|
}];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
#ifdef ADHOC
|
2012-02-29 01:10:46 +00:00
|
|
|
[PearlAlert showAlertWithTitle:@"Welcome, tester!" message:
|
|
|
|
@"Thank you for taking the time to test Master Password.\n\n"
|
|
|
|
@"Please provide any feedback, however minor it may seem, via the Feedback action item accessible from the top right.\n\n"
|
|
|
|
@"Contact me directly at:\n"
|
|
|
|
@"lhunath@lyndir.com\n"
|
|
|
|
@"Or report detailed issues at:\n"
|
|
|
|
@"https://youtrack.lyndir.com\n"
|
2012-06-10 19:43:18 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault initAlert:nil tappedButtonBlock:nil
|
2012-02-29 01:10:46 +00:00
|
|
|
cancelTitle:nil otherTitles:[PearlStrings get].commonButtonOkay, nil];
|
|
|
|
#endif
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
[super application:application didFinishLaunchingWithOptions:launchOptions];
|
|
|
|
|
|
|
|
inf(@"Started up with device identifier: %@", [PearlKeyChain deviceIdentifier]);
|
|
|
|
|
2013-04-20 18:11:19 +00:00
|
|
|
dispatch_async( dispatch_get_main_queue(), ^{
|
2013-04-14 14:24:24 +00:00
|
|
|
if ([[MPiOSConfig get].showSetup boolValue])
|
2013-04-25 01:26:04 +00:00
|
|
|
[[MPiOSAppDelegate get] showSetup];
|
2013-04-20 18:11:19 +00:00
|
|
|
} );
|
2013-04-13 17:40:17 +00:00
|
|
|
|
2013-05-07 15:22:01 +00:00
|
|
|
MPCheckpoint(MPCheckpointStarted, @{
|
|
|
|
@"simulator" : PearlStringB([PearlDeviceUtils isSimulator]),
|
|
|
|
@"encrypted" : PearlStringB([PearlDeviceUtils isAppEncrypted]),
|
|
|
|
@"jailbroken" : PearlStringB([PearlDeviceUtils isJailbroken]),
|
|
|
|
@"platform" : [PearlDeviceUtils platform],
|
|
|
|
#ifdef APPSTORE
|
|
|
|
@"legal" : PearlStringB([PearlDeviceUtils isAppEncrypted]),
|
|
|
|
#else
|
|
|
|
@"legal" : @"YES",
|
|
|
|
#endif
|
|
|
|
});
|
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
return YES;
|
2012-01-29 11:41:48 +00:00
|
|
|
}
|
2012-02-29 00:56:58 +00:00
|
|
|
|
2012-05-09 08:11:34 +00:00
|
|
|
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
|
|
|
|
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-08-25 10:38:29 +00:00
|
|
|
// No URL?
|
|
|
|
if (!url)
|
|
|
|
return NO;
|
|
|
|
|
2013-01-31 21:22:37 +00:00
|
|
|
// Google+
|
2013-04-27 21:14:05 +00:00
|
|
|
if ([[GPPSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation])
|
2013-04-27 20:24:29 +00:00
|
|
|
return YES;
|
|
|
|
|
2012-08-25 10:38:29 +00:00
|
|
|
// Arbitrary URL to mpsites data.
|
2013-04-20 18:11:19 +00:00
|
|
|
dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
|
|
|
|
NSError *error;
|
2012-08-25 10:38:29 +00:00
|
|
|
NSURLResponse *response;
|
2013-04-20 18:11:19 +00:00
|
|
|
NSData *importedSitesData = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:url]
|
|
|
|
returningResponse:&response error:&error];
|
2012-08-25 10:38:29 +00:00
|
|
|
if (error)
|
|
|
|
err(@"While reading imported sites from %@: %@", url, error);
|
|
|
|
if (!importedSitesData)
|
|
|
|
return;
|
|
|
|
|
2012-09-01 20:14:57 +00:00
|
|
|
PearlAlert *activityAlert = [PearlAlert showActivityWithTitle:@"Importing"];
|
2012-08-19 07:34:49 +00:00
|
|
|
|
|
|
|
NSString *importedSitesString = [[NSString alloc] initWithData:importedSitesData encoding:NSUTF8StringEncoding];
|
|
|
|
MPImportResult result = [self importSites:importedSitesString askImportPassword:^NSString *(NSString *userName) {
|
|
|
|
__block NSString *masterPassword = nil;
|
|
|
|
|
|
|
|
dispatch_group_t importPasswordGroup = dispatch_group_create();
|
2013-04-20 18:11:19 +00:00
|
|
|
dispatch_group_enter( importPasswordGroup );
|
|
|
|
dispatch_async( dispatch_get_main_queue(), ^{
|
2012-08-19 07:34:49 +00:00
|
|
|
[PearlAlert showAlertWithTitle:@"Import File's Master Password"
|
2013-04-20 18:11:19 +00:00
|
|
|
message:PearlString( @"%@'s export was done using a different master password.\n"
|
|
|
|
@"Enter that master password to unlock the exported data.", userName )
|
2012-08-19 07:34:49 +00:00
|
|
|
viewStyle:UIAlertViewStyleSecureTextInput
|
|
|
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
|
|
|
@try {
|
|
|
|
if (buttonIndex_ == [alert_ cancelButtonIndex])
|
|
|
|
return;
|
|
|
|
|
|
|
|
masterPassword = [alert_ textFieldAtIndex:0].text;
|
|
|
|
}
|
|
|
|
@finally {
|
2013-04-20 18:11:19 +00:00
|
|
|
dispatch_group_leave( importPasswordGroup );
|
2012-08-19 07:34:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Unlock Import", nil];
|
2013-04-20 18:11:19 +00:00
|
|
|
} );
|
|
|
|
dispatch_group_wait( importPasswordGroup, DISPATCH_TIME_FOREVER );
|
2012-08-19 07:34:49 +00:00
|
|
|
|
|
|
|
return masterPassword;
|
|
|
|
} askUserPassword:^NSString *(NSString *userName, NSUInteger importCount, NSUInteger deleteCount) {
|
|
|
|
__block NSString *masterPassword = nil;
|
|
|
|
|
|
|
|
dispatch_group_t userPasswordGroup = dispatch_group_create();
|
2013-04-20 18:11:19 +00:00
|
|
|
dispatch_group_enter( userPasswordGroup );
|
|
|
|
dispatch_async( dispatch_get_main_queue(), ^{
|
|
|
|
[PearlAlert showAlertWithTitle:PearlString( @"Master Password for\n%@", userName )
|
|
|
|
message:PearlString( @"Imports %d sites, overwriting %d.", importCount,
|
|
|
|
deleteCount )
|
2012-08-19 07:34:49 +00:00
|
|
|
viewStyle:UIAlertViewStyleSecureTextInput
|
|
|
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
|
|
|
@try {
|
|
|
|
if (buttonIndex_ == [alert_ cancelButtonIndex])
|
|
|
|
return;
|
|
|
|
|
|
|
|
masterPassword = [alert_ textFieldAtIndex:0].text;
|
|
|
|
}
|
|
|
|
@finally {
|
2013-04-20 18:11:19 +00:00
|
|
|
dispatch_group_leave( userPasswordGroup );
|
2012-08-19 07:34:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Import", nil];
|
2013-04-20 18:11:19 +00:00
|
|
|
} );
|
|
|
|
dispatch_group_wait( userPasswordGroup, DISPATCH_TIME_FOREVER );
|
2012-08-19 07:34:49 +00:00
|
|
|
|
|
|
|
return masterPassword;
|
|
|
|
}];
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case MPImportResultSuccess:
|
|
|
|
case MPImportResultCancelled:
|
|
|
|
break;
|
|
|
|
case MPImportResultInternalError:
|
|
|
|
[PearlAlert showError:@"Import failed because of an internal error."];
|
|
|
|
break;
|
|
|
|
case MPImportResultMalformedInput:
|
|
|
|
[PearlAlert showError:@"The import doesn't look like a Master Password export."];
|
|
|
|
break;
|
|
|
|
case MPImportResultInvalidPassword:
|
|
|
|
[PearlAlert showError:@"Incorrect master password for the import sites."];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-04-18 02:00:15 +00:00
|
|
|
[activityAlert cancelAlertAnimated:YES];
|
2013-04-20 18:11:19 +00:00
|
|
|
} );
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-09 08:11:34 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2012-07-29 10:32:26 +00:00
|
|
|
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
|
2012-08-04 21:15:50 +00:00
|
|
|
|
2012-09-12 13:58:54 +00:00
|
|
|
inf(@"Received memory warning.");
|
2012-08-04 21:15:50 +00:00
|
|
|
|
2012-07-29 10:32:26 +00:00
|
|
|
[super applicationDidReceiveMemoryWarning:application];
|
|
|
|
}
|
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
[[LocalyticsSession sharedLocalyticsSession] close];
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] upload];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
[super applicationDidEnterBackground:application];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
[[LocalyticsSession sharedLocalyticsSession] resume];
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] upload];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
[super applicationWillEnterForeground:application];
|
2011-11-30 21:42:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-04 23:36:19 +00:00
|
|
|
- (void)applicationWillTerminate:(UIApplication *)application {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
[[LocalyticsSession sharedLocalyticsSession] close];
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] upload];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
[super applicationWillTerminate:application];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)applicationWillResignActive:(UIApplication *)application {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
inf(@"Will deactivate");
|
2012-06-07 22:40:30 +00:00
|
|
|
if (![[MPiOSConfig get].rememberLogin boolValue])
|
2012-06-27 22:00:41 +00:00
|
|
|
[self signOutAnimated:NO];
|
2012-09-12 13:58:54 +00:00
|
|
|
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] close];
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] upload];
|
|
|
|
|
|
|
|
[super applicationWillResignActive:application];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
|
|
|
|
|
|
|
inf(@"Re-activated");
|
2013-04-20 18:11:19 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:application userInfo:nil];
|
2012-09-12 13:58:54 +00:00
|
|
|
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] resume];
|
|
|
|
[[LocalyticsSession sharedLocalyticsSession] upload];
|
|
|
|
|
|
|
|
[super applicationDidBecomeActive:application];
|
2011-11-30 21:42:40 +00:00
|
|
|
}
|
|
|
|
|
2012-06-15 09:16:02 +00:00
|
|
|
#pragma mark - Behavior
|
2012-06-14 19:56:54 +00:00
|
|
|
|
|
|
|
- (void)showGuide {
|
|
|
|
|
|
|
|
[self.navigationController performSegueWithIdentifier:@"MP_Guide" sender:self];
|
|
|
|
|
2013-04-20 17:51:37 +00:00
|
|
|
MPCheckpoint( MPCheckpointShowGuide, nil );
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
|
2013-04-13 17:40:17 +00:00
|
|
|
- (void)showSetup {
|
|
|
|
|
|
|
|
[self.navigationController performSegueWithIdentifier:@"MP_Setup" sender:self];
|
|
|
|
|
2013-04-20 17:51:37 +00:00
|
|
|
MPCheckpoint( MPCheckpointShowSetup, nil );
|
2013-04-13 17:40:17 +00:00
|
|
|
}
|
|
|
|
|
2012-09-01 12:57:55 +00:00
|
|
|
- (void)showReview {
|
|
|
|
|
2013-04-20 17:51:37 +00:00
|
|
|
MPCheckpoint( MPCheckpointReview, nil );
|
2012-09-01 12:57:55 +00:00
|
|
|
|
|
|
|
[super showReview];
|
2012-08-26 22:14:33 +00:00
|
|
|
}
|
|
|
|
|
2012-08-26 15:40:32 +00:00
|
|
|
- (void)showFeedbackWithLogs:(BOOL)logs forVC:(UIViewController *)viewController {
|
|
|
|
|
|
|
|
if (![PearlEMail canSendMail])
|
|
|
|
[PearlAlert showAlertWithTitle:@"Feedback"
|
|
|
|
message:
|
2013-04-20 18:11:19 +00:00
|
|
|
@"Have a question, comment, issue or just saying thanks?\n\n"
|
|
|
|
@"We'd love to hear what you think!\n"
|
|
|
|
@"masterpassword@lyndir.com"
|
2012-08-26 15:40:32 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault
|
|
|
|
initAlert:nil tappedButtonBlock:nil cancelTitle:[PearlStrings get].commonButtonOkay
|
|
|
|
otherTitles:nil];
|
|
|
|
|
2013-04-20 18:11:19 +00:00
|
|
|
else if (logs)
|
|
|
|
[PearlAlert showAlertWithTitle:@"Feedback"
|
|
|
|
message:
|
|
|
|
@"Have a question, comment, issue or just saying thanks?\n\n"
|
|
|
|
@"If you're having trouble, it may help us if you can first reproduce the problem "
|
|
|
|
@"and then include log files in your message."
|
|
|
|
viewStyle:UIAlertViewStyleDefault
|
|
|
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
|
|
|
[self openFeedbackWithLogs:(buttonIndex_ == [alert_ firstOtherButtonIndex]) forVC:viewController];
|
|
|
|
} cancelTitle:nil otherTitles:@"Include Logs", @"No Logs", nil];
|
2012-08-26 15:40:32 +00:00
|
|
|
else
|
2013-04-20 18:11:19 +00:00
|
|
|
[self openFeedbackWithLogs:NO forVC:viewController];
|
2012-08-26 15:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)openFeedbackWithLogs:(BOOL)logs forVC:(UIViewController *)viewController {
|
|
|
|
|
2013-04-25 01:26:04 +00:00
|
|
|
NSString *userName = [[MPiOSAppDelegate get] activeUserForThread].name;
|
2013-04-30 05:49:53 +00:00
|
|
|
PearlLogLevel logLevel = PearlLogLevelInfo;
|
|
|
|
if (logs && ([[MPiOSConfig get].sendInfo boolValue] || [[MPiOSConfig get].traceMode boolValue]))
|
|
|
|
logLevel = PearlLogLevelDebug;
|
2012-08-26 15:40:32 +00:00
|
|
|
|
|
|
|
[[[PearlEMail alloc] initForEMailTo:@"Master Password Development <masterpassword@lyndir.com>"
|
2013-04-20 18:11:19 +00:00
|
|
|
subject:PearlString( @"Feedback for Master Password [%@]",
|
|
|
|
[[PearlKeyChain deviceIdentifier] stringByDeletingMatchesOf:@"-.*"] )
|
|
|
|
body:PearlString( @"\n\n\n"
|
|
|
|
@"--\n"
|
|
|
|
@"%@"
|
|
|
|
@"Master Password %@, build %@",
|
|
|
|
userName? ([userName stringByAppendingString:@"\n"]): @"",
|
|
|
|
[PearlInfoPlist get].CFBundleShortVersionString,
|
|
|
|
[PearlInfoPlist get].CFBundleVersion )
|
2012-08-26 15:40:32 +00:00
|
|
|
|
2012-09-20 19:37:58 +00:00
|
|
|
attachments:(logs
|
2013-04-20 18:11:19 +00:00
|
|
|
? [[PearlEMailAttachment alloc]
|
|
|
|
initWithContent:[[[PearlLogger get] formatMessagesWithLevel:logLevel]
|
|
|
|
dataUsingEncoding:NSUTF8StringEncoding]
|
|
|
|
mimeType:@"text/plain"
|
|
|
|
fileName:PearlString( @"%@-%@.log",
|
|
|
|
[[NSDateFormatter rfc3339DateFormatter] stringFromDate:[NSDate date]],
|
|
|
|
[PearlKeyChain deviceIdentifier] )]
|
|
|
|
: nil), nil]
|
|
|
|
showComposerForVC:viewController];
|
2012-08-26 15:40:32 +00:00
|
|
|
}
|
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
- (void)export {
|
|
|
|
|
|
|
|
[PearlAlert showNotice:
|
2013-04-20 18:11:19 +00:00
|
|
|
@"This will export all your site names.\n\n"
|
|
|
|
@"You can open the export with a text editor to get an overview of all your sites.\n\n"
|
|
|
|
@"The file also acts as a personal backup of your site list in case you don't sync with iCloud/iTunes."
|
2012-06-14 19:56:54 +00:00
|
|
|
tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
|
|
|
[PearlAlert showAlertWithTitle:@"Reveal Passwords?" message:
|
2013-04-20 18:11:19 +00:00
|
|
|
@"Would you like to make all your passwords visible in the export?\n\n"
|
|
|
|
@"A safe export will only include your stored passwords, in an encrypted manner, "
|
|
|
|
@"making the result safe from falling in the wrong hands.\n\n"
|
|
|
|
@"If all your passwords are shown and somebody else finds the export, "
|
|
|
|
@"they could gain access to all your sites!"
|
2012-06-14 19:56:54 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault initAlert:nil
|
|
|
|
tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) {
|
|
|
|
if (buttonIndex_ == [alert_ firstOtherButtonIndex] + 0)
|
2013-04-20 18:11:19 +00:00
|
|
|
// Safe Export
|
2012-06-14 19:56:54 +00:00
|
|
|
[self exportShowPasswords:NO];
|
|
|
|
if (buttonIndex_ == [alert_ firstOtherButtonIndex] + 1)
|
2013-04-20 18:11:19 +00:00
|
|
|
// Show Passwords
|
2012-06-14 19:56:54 +00:00
|
|
|
[self exportShowPasswords:YES];
|
2012-08-04 21:15:50 +00:00
|
|
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:@"Safe Export", @"Show Passwords", nil];
|
|
|
|
} otherTitles:nil];
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)exportShowPasswords:(BOOL)showPasswords {
|
2012-07-12 06:41:18 +00:00
|
|
|
|
2012-08-26 15:40:32 +00:00
|
|
|
if (![PearlEMail canSendMail]) {
|
2012-06-22 14:52:33 +00:00
|
|
|
[PearlAlert showAlertWithTitle:@"Cannot Send Mail"
|
|
|
|
message:
|
2013-04-20 18:11:19 +00:00
|
|
|
@"Your device is not yet set up for sending mail.\n"
|
|
|
|
@"Close Master Password, go into Settings and add a Mail account."
|
2012-06-22 14:52:33 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault
|
2012-08-04 21:15:50 +00:00
|
|
|
initAlert:nil tappedButtonBlock:nil cancelTitle:[PearlStrings get].commonButtonOkay
|
2012-06-22 14:52:33 +00:00
|
|
|
otherTitles:nil];
|
|
|
|
return;
|
|
|
|
}
|
2012-06-14 19:56:54 +00:00
|
|
|
|
|
|
|
NSString *exportedSites = [self exportSitesShowingPasswords:showPasswords];
|
|
|
|
NSString *message;
|
2012-06-22 14:52:33 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
if (showPasswords)
|
2013-04-20 18:11:19 +00:00
|
|
|
message = PearlString( @"Export of Master Password sites with passwords included.\n\n"
|
|
|
|
@"REMINDER: Make sure nobody else sees this file! Passwords are visible!\n\n\n"
|
|
|
|
@"--\n"
|
|
|
|
@"%@\n"
|
|
|
|
@"Master Password %@, build %@",
|
|
|
|
[self activeUserForThread].name,
|
|
|
|
[PearlInfoPlist get].CFBundleShortVersionString,
|
|
|
|
[PearlInfoPlist get].CFBundleVersion );
|
2012-06-14 19:56:54 +00:00
|
|
|
else
|
2013-04-20 18:11:19 +00:00
|
|
|
message = PearlString( @"Backup of Master Password sites.\n\n\n"
|
|
|
|
@"--\n"
|
|
|
|
@"%@\n"
|
|
|
|
@"Master Password %@, build %@",
|
|
|
|
[self activeUserForThread].name,
|
|
|
|
[PearlInfoPlist get].CFBundleShortVersionString,
|
|
|
|
[PearlInfoPlist get].CFBundleVersion );
|
2012-07-12 06:41:18 +00:00
|
|
|
|
2012-06-14 19:56:54 +00:00
|
|
|
NSDateFormatter *exportDateFormatter = [NSDateFormatter new];
|
2012-07-29 10:32:26 +00:00
|
|
|
[exportDateFormatter setDateFormat:@"yyyy'-'MM'-'dd"];
|
2012-06-14 19:56:54 +00:00
|
|
|
|
2012-08-26 15:40:32 +00:00
|
|
|
[PearlEMail sendEMailTo:nil subject:@"Master Password Export" body:message
|
|
|
|
attachments:[[PearlEMailAttachment alloc] initWithContent:[exportedSites dataUsingEncoding:NSUTF8StringEncoding]
|
|
|
|
mimeType:@"text/plain" fileName:
|
2013-04-20 18:11:19 +00:00
|
|
|
PearlString( @"%@ (%@).mpsites", [self activeUserForThread].name,
|
|
|
|
[exportDateFormatter stringFromDate:[NSDate date]] )],
|
2012-08-26 15:40:32 +00:00
|
|
|
nil];
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 05:49:53 +00:00
|
|
|
- (void)changeMasterPasswordFor:(MPUserEntity *)user saveInContext:(NSManagedObjectContext *)moc didResetBlock:(void (^)(void))didReset {
|
2012-06-14 19:56:54 +00:00
|
|
|
|
|
|
|
[PearlAlert showAlertWithTitle:@"Changing Master Password"
|
|
|
|
message:
|
2013-04-20 18:11:19 +00:00
|
|
|
@"If you continue, you'll be able to set a new master password.\n\n"
|
|
|
|
@"Changing your master password will cause all your generated passwords to change!\n"
|
|
|
|
@"Changing the master password back to the old one will cause your passwords to revert as well."
|
2012-06-14 19:56:54 +00:00
|
|
|
viewStyle:UIAlertViewStyleDefault
|
|
|
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
|
|
|
if (buttonIndex == [alert cancelButtonIndex])
|
|
|
|
return;
|
|
|
|
|
2013-04-14 14:24:24 +00:00
|
|
|
[moc performBlockAndWait:^{
|
2013-01-31 05:42:32 +00:00
|
|
|
inf(@"Unsetting master password for: %@.", user.userID);
|
|
|
|
user.keyID = nil;
|
|
|
|
[self forgetSavedKeyFor:user];
|
2013-04-13 17:40:17 +00:00
|
|
|
[moc saveToStore];
|
2013-04-14 14:24:24 +00:00
|
|
|
}];
|
2012-06-14 19:56:54 +00:00
|
|
|
|
2013-04-14 14:24:24 +00:00
|
|
|
[self signOutAnimated:YES];
|
|
|
|
if (didReset)
|
|
|
|
didReset();
|
2012-07-29 10:32:26 +00:00
|
|
|
|
2013-04-20 17:51:37 +00:00
|
|
|
MPCheckpoint( MPCheckpointChangeMP, nil );
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
2012-08-04 21:15:50 +00:00
|
|
|
cancelTitle:[PearlStrings get].commonButtonAbort
|
|
|
|
otherTitles:[PearlStrings get].commonButtonContinue, nil];
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - PearlConfigDelegate
|
|
|
|
|
|
|
|
- (void)didUpdateConfigForKey:(SEL)configKey fromValue:(id)value {
|
|
|
|
|
2013-04-30 01:15:14 +00:00
|
|
|
if (configKey == @selector(traceMode)) {
|
|
|
|
[PearlLogger get].historyLevel = [[MPiOSConfig get].traceMode boolValue]? PearlLogLevelTrace: PearlLogLevelInfo;
|
|
|
|
inf(@"Trace is now: %@", [[MPiOSConfig get].traceMode boolValue]? @"ON": @"OFF");
|
|
|
|
}
|
|
|
|
|
2013-04-20 18:11:19 +00:00
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:MPCheckConfigNotification object:NSStringFromSelector( configKey ) userInfo:nil];
|
2012-06-14 19:56:54 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
|
2013-01-31 21:22:37 +00:00
|
|
|
#pragma mark - Google+
|
|
|
|
|
|
|
|
- (NSDictionary *)googlePlusInfo {
|
2013-04-03 23:25:15 +00:00
|
|
|
|
2013-01-31 21:22:37 +00:00
|
|
|
static NSDictionary *googlePlusInfo = nil;
|
|
|
|
if (googlePlusInfo == nil)
|
|
|
|
googlePlusInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
2013-04-20 18:11:19 +00:00
|
|
|
[[NSBundle mainBundle] URLForResource:@"Google+" withExtension:@"plist"]];
|
2013-04-03 23:25:15 +00:00
|
|
|
|
2013-01-31 21:22:37 +00:00
|
|
|
return googlePlusInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)googlePlusClientID {
|
2013-04-03 23:25:15 +00:00
|
|
|
|
2013-04-27 21:39:31 +00:00
|
|
|
NSString *googlePlusClientID = NSNullToNil([[self googlePlusInfo] valueForKeyPath:@"ClientID"]);
|
|
|
|
if (![googlePlusClientID length])
|
|
|
|
wrn(@"Google+ client ID not set. User won't be able to share via Google+.");
|
|
|
|
|
|
|
|
return googlePlusClientID;
|
2013-01-31 21:22:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - TestFlight
|
2012-05-03 14:49:15 +00:00
|
|
|
|
|
|
|
- (NSDictionary *)testFlightInfo {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-11 20:45:05 +00:00
|
|
|
static NSDictionary *testFlightInfo = nil;
|
2012-05-03 14:49:15 +00:00
|
|
|
if (testFlightInfo == nil)
|
|
|
|
testFlightInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
2013-04-20 18:11:19 +00:00
|
|
|
[[NSBundle mainBundle] URLForResource:@"TestFlight" withExtension:@"plist"]];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
return testFlightInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)testFlightToken {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2013-04-27 21:39:31 +00:00
|
|
|
NSString *testFlightToken = NSNullToNil([[self testFlightInfo] valueForKeyPath:@"Application Token"]);
|
|
|
|
if (![testFlightToken length])
|
|
|
|
wrn(@"TestFlight token not set. Test Flight won't be aware of this test.");
|
|
|
|
|
|
|
|
return testFlightToken;
|
2012-05-03 14:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Crashlytics
|
|
|
|
|
|
|
|
- (NSDictionary *)crashlyticsInfo {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-11 20:45:05 +00:00
|
|
|
static NSDictionary *crashlyticsInfo = nil;
|
2012-05-03 14:49:15 +00:00
|
|
|
if (crashlyticsInfo == nil)
|
|
|
|
crashlyticsInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
2013-04-20 18:11:19 +00:00
|
|
|
[[NSBundle mainBundle] URLForResource:@"Crashlytics" withExtension:@"plist"]];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
return crashlyticsInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)crashlyticsAPIKey {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2013-04-27 21:39:31 +00:00
|
|
|
NSString *crashlyticsAPIKey = NSNullToNil([[self crashlyticsInfo] valueForKeyPath:@"API Key"]);
|
|
|
|
if (![crashlyticsAPIKey length])
|
|
|
|
wrn(@"Crashlytics API key not set. Crash logs won't be recorded.");
|
|
|
|
|
|
|
|
return crashlyticsAPIKey;
|
2012-05-03 14:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Localytics
|
|
|
|
|
|
|
|
- (NSDictionary *)localyticsInfo {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-11 20:45:05 +00:00
|
|
|
static NSDictionary *localyticsInfo = nil;
|
2012-05-03 14:49:15 +00:00
|
|
|
if (localyticsInfo == nil)
|
|
|
|
localyticsInfo = [[NSDictionary alloc] initWithContentsOfURL:
|
2013-04-20 18:11:19 +00:00
|
|
|
[[NSBundle mainBundle] URLForResource:@"Localytics" withExtension:@"plist"]];
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
return localyticsInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)localyticsKey {
|
2012-06-08 21:46:13 +00:00
|
|
|
|
2012-05-03 14:49:15 +00:00
|
|
|
#ifdef DEBUG
|
2013-04-27 21:39:31 +00:00
|
|
|
NSString *localyticsKey = NSNullToNil([[self localyticsInfo] valueForKeyPath:@"Key.development"]);
|
2012-05-03 14:49:15 +00:00
|
|
|
#else
|
2013-04-27 21:39:31 +00:00
|
|
|
NSString *localyticsKey = NSNullToNil([[self localyticsInfo] valueForKeyPath:@"Key.distribution"]);
|
2012-05-03 14:49:15 +00:00
|
|
|
#endif
|
2013-04-27 21:39:31 +00:00
|
|
|
if (![localyticsKey length])
|
|
|
|
wrn(@"Localytics key not set. Demographics won't be collected.");
|
|
|
|
|
|
|
|
return localyticsKey;
|
2012-05-03 14:49:15 +00:00
|
|
|
}
|
|
|
|
|
2011-11-30 21:42:40 +00:00
|
|
|
@end
|