2017-04-05 16:56:22 -04:00
|
|
|
//==============================================================================
|
|
|
|
// This file is part of Master Password.
|
|
|
|
// Copyright (c) 2011-2017, Maarten Billemont.
|
2012-06-04 11:27:02 +02:00
|
|
|
//
|
2017-04-05 16:56:22 -04:00
|
|
|
// Master Password is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2012-06-04 11:27:02 +02:00
|
|
|
//
|
2017-04-05 16:56:22 -04:00
|
|
|
// Master Password is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2012-06-04 11:27:02 +02:00
|
|
|
//
|
2017-04-05 16:56:22 -04:00
|
|
|
// You can find a copy of the GNU General Public License in the
|
|
|
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
|
|
|
//==============================================================================
|
2012-06-04 11:27:02 +02:00
|
|
|
|
|
|
|
#import "MPPreferencesViewController.h"
|
2013-04-24 21:26:04 -04:00
|
|
|
#import "MPiOSAppDelegate.h"
|
2012-06-08 00:40:30 +02:00
|
|
|
#import "MPAppDelegate_Key.h"
|
2012-06-11 16:15:49 +02:00
|
|
|
#import "MPAppDelegate_Store.h"
|
2014-04-20 11:09:49 -04:00
|
|
|
#import "UIColor+Expanded.h"
|
2017-05-07 18:36:01 -04:00
|
|
|
#import "MPSitesViewController.h"
|
2016-01-14 10:03:30 -05:00
|
|
|
#import "MPAppDelegate_InApp.h"
|
2012-06-04 11:27:02 +02:00
|
|
|
|
2013-04-20 14:11:19 -04:00
|
|
|
@interface MPPreferencesViewController()
|
2012-06-04 11:27:02 +02:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MPPreferencesViewController
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
2012-06-08 23:46:13 +02:00
|
|
|
|
2012-06-04 11:27:02 +02:00
|
|
|
[super viewDidLoad];
|
2014-04-20 11:09:49 -04:00
|
|
|
|
|
|
|
self.view.backgroundColor = [UIColor clearColor];
|
2016-01-14 10:03:30 -05:00
|
|
|
|
|
|
|
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
|
|
|
self.tableView.estimatedRowHeight = 100;
|
|
|
|
self.tableView.contentInset = UIEdgeInsetsMake( 64, 0, 49, 0 );
|
2012-06-04 11:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
2012-06-08 23:46:13 +02:00
|
|
|
|
2014-04-26 14:03:44 -04:00
|
|
|
inf( @"Preferences will appear" );
|
2014-04-20 11:09:49 -04:00
|
|
|
[super viewWillAppear:animated];
|
2014-09-28 22:15:55 -04:00
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"tipped.passwordsPreferences"];
|
2014-10-24 00:35:05 -04:00
|
|
|
if (![[NSUserDefaults standardUserDefaults] synchronize])
|
|
|
|
wrn( @"Couldn't synchronize after preferences appearance." );
|
2012-06-06 00:59:09 +02:00
|
|
|
|
2016-01-14 09:58:04 -05:00
|
|
|
[self reload];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)reload {
|
|
|
|
|
2013-06-16 12:39:52 -04:00
|
|
|
MPUserEntity *activeUser = [[MPiOSAppDelegate get] activeUserForMainThread];
|
2016-01-14 09:58:04 -05:00
|
|
|
self.avatarImage.image = [UIImage imageNamed:strf( @"avatar-%lu", (unsigned long)activeUser.avatar )];
|
2013-04-17 22:00:15 -04:00
|
|
|
self.savePasswordSwitch.on = activeUser.saveKey;
|
2016-01-14 02:14:36 -05:00
|
|
|
self.touchIDSwitch.on = activeUser.touchID;
|
2016-01-14 11:22:15 -05:00
|
|
|
self.touchIDSwitch.enabled = self.savePasswordSwitch.on && [[MPiOSAppDelegate get] isFeatureUnlocked:MPProductTouchID];
|
2017-04-17 21:57:08 -04:00
|
|
|
|
2017-08-12 21:57:47 -04:00
|
|
|
MPResultType defaultType = activeUser.defaultType;
|
2017-04-17 21:57:08 -04:00
|
|
|
self.generated1TypeControl.selectedSegmentIndex = [self generated1SegmentIndexForType:defaultType];
|
|
|
|
self.generated2TypeControl.selectedSegmentIndex = [self generated2SegmentIndexForType:defaultType];
|
|
|
|
self.storedTypeControl.selectedSegmentIndex = [self storedSegmentIndexForType:defaultType];
|
|
|
|
PearlNotMainQueue( ^{
|
|
|
|
NSString *examplePassword = nil;
|
2017-08-12 21:57:47 -04:00
|
|
|
if (defaultType & MPResultTypeClassTemplate)
|
|
|
|
examplePassword = [MPAlgorithmDefault mpwTemplateForSiteNamed:@"test" ofType:defaultType
|
|
|
|
withCounter:1 usingKey:[MPiOSAppDelegate get].key];
|
2017-04-17 21:57:08 -04:00
|
|
|
PearlMainQueue( ^{
|
2017-05-07 18:36:01 -04:00
|
|
|
self.typeSamplePassword.text = [examplePassword length]? [NSString stringWithFormat:@"eg. %@", examplePassword]: nil;
|
2017-04-17 21:57:08 -04:00
|
|
|
} );
|
|
|
|
} );
|
2012-06-04 11:27:02 +02:00
|
|
|
}
|
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
#pragma mark - UITableViewDelegate
|
2013-04-29 21:15:14 -04:00
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
2013-04-29 21:15:14 -04:00
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
|
|
|
|
if (cell.selectionStyle != UITableViewCellSelectionStyleNone) {
|
|
|
|
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.bounds];
|
|
|
|
cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRGBAHex:0x78DDFB33];
|
2013-04-29 21:15:14 -04:00
|
|
|
}
|
2013-04-20 14:11:19 -04:00
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
return cell;
|
2012-06-04 11:27:02 +02:00
|
|
|
}
|
|
|
|
|
2016-01-14 10:03:30 -05:00
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
|
|
return UITableViewAutomaticDimension;
|
|
|
|
}
|
|
|
|
|
2012-06-06 00:59:09 +02:00
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
2012-06-08 23:46:13 +02:00
|
|
|
|
2012-06-06 00:59:09 +02:00
|
|
|
UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
|
2014-05-17 20:12:59 -04:00
|
|
|
if (cell == self.signOutCell) {
|
2014-05-17 23:52:51 -04:00
|
|
|
[self dismissPopup];
|
2020-04-04 16:30:14 -04:00
|
|
|
[[MPiOSAppDelegate get] signOut];
|
2014-05-17 20:12:59 -04:00
|
|
|
}
|
2017-04-17 21:57:08 -04:00
|
|
|
|
2014-04-24 21:43:47 -04:00
|
|
|
if (cell == self.feedbackCell)
|
|
|
|
[[MPiOSAppDelegate get] showFeedbackWithLogs:YES forVC:self];
|
2017-04-17 21:57:08 -04:00
|
|
|
|
2012-06-06 00:59:09 +02:00
|
|
|
if (cell == self.exportCell)
|
2014-04-24 21:43:47 -04:00
|
|
|
[[MPiOSAppDelegate get] showExportForVC:self];
|
2017-04-17 21:57:08 -04:00
|
|
|
|
2014-06-21 21:59:14 -04:00
|
|
|
if (cell == self.showHelpCell) {
|
2017-05-07 18:36:01 -04:00
|
|
|
MPSitesViewController *passwordsVC = [self dismissPopup];
|
2014-06-21 21:59:14 -04:00
|
|
|
[passwordsVC performSegueWithIdentifier:@"guide" sender:self];
|
2014-04-24 21:43:47 -04:00
|
|
|
}
|
2017-04-17 21:57:08 -04:00
|
|
|
|
2014-04-26 14:03:44 -04:00
|
|
|
if (cell == self.checkInconsistencies)
|
2020-03-05 11:29:10 -05:00
|
|
|
[MPiOSAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *context) {
|
2020-01-14 13:59:32 -05:00
|
|
|
if ([[MPiOSAppDelegate get] findAndFixInconsistenciesSaveInContext:context] == MPFixableResultNoProblems) {
|
|
|
|
UIAlertController *controller = [UIAlertController alertControllerWithTitle:@"No Inconsistencies" message:
|
2017-04-01 00:30:25 -04:00
|
|
|
@"No inconsistencies were detected in your sites."
|
2020-01-14 13:59:32 -05:00
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
[controller addAction:[UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil]];
|
|
|
|
[self.navigationController presentViewController:controller animated:YES completion:nil];
|
|
|
|
}
|
2014-04-26 14:03:44 -04:00
|
|
|
}];
|
2012-06-06 00:59:09 +02:00
|
|
|
|
2012-06-06 22:38:43 +02:00
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
2012-06-06 00:59:09 +02:00
|
|
|
}
|
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
#pragma mark - IBActions
|
2012-06-11 16:15:49 +02:00
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
- (IBAction)valueChanged:(id)sender {
|
2012-06-11 16:15:49 +02:00
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
if (sender == self.savePasswordSwitch)
|
2020-03-25 12:16:19 -04:00
|
|
|
[MPiOSAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *context) {
|
2014-04-20 11:09:49 -04:00
|
|
|
MPUserEntity *activeUser = [[MPiOSAppDelegate get] activeUserInContext:context];
|
|
|
|
if ((activeUser.saveKey = self.savePasswordSwitch.on))
|
|
|
|
[[MPiOSAppDelegate get] storeSavedKeyFor:activeUser];
|
2016-01-14 02:14:36 -05:00
|
|
|
else
|
|
|
|
[[MPiOSAppDelegate get] forgetSavedKeyFor:activeUser];
|
|
|
|
[context saveToStore];
|
2016-01-14 09:58:04 -05:00
|
|
|
|
2020-03-25 12:16:19 -04:00
|
|
|
[self reload];
|
2016-01-14 02:14:36 -05:00
|
|
|
}];
|
|
|
|
|
|
|
|
if (sender == self.touchIDSwitch)
|
2020-03-25 12:16:19 -04:00
|
|
|
[MPiOSAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *context) {
|
2016-01-14 02:14:36 -05:00
|
|
|
MPUserEntity *activeUser = [[MPiOSAppDelegate get] activeUserInContext:context];
|
|
|
|
if ((activeUser.touchID = self.touchIDSwitch.on))
|
|
|
|
[[MPiOSAppDelegate get] storeSavedKeyFor:activeUser];
|
2014-04-20 11:09:49 -04:00
|
|
|
else
|
|
|
|
[[MPiOSAppDelegate get] forgetSavedKeyFor:activeUser];
|
|
|
|
[context saveToStore];
|
2016-01-14 09:58:04 -05:00
|
|
|
|
2020-03-25 12:16:19 -04:00
|
|
|
[self reload];
|
2014-04-20 11:09:49 -04:00
|
|
|
}];
|
|
|
|
|
2017-04-17 21:57:08 -04:00
|
|
|
if (sender == self.generated1TypeControl || sender == self.generated2TypeControl || sender == self.storedTypeControl) {
|
|
|
|
if (sender != self.generated1TypeControl)
|
|
|
|
self.generated1TypeControl.selectedSegmentIndex = -1;
|
|
|
|
if (sender != self.generated2TypeControl)
|
|
|
|
self.generated2TypeControl.selectedSegmentIndex = -1;
|
|
|
|
if (sender != self.storedTypeControl)
|
2014-04-25 20:02:58 -04:00
|
|
|
self.storedTypeControl.selectedSegmentIndex = -1;
|
2014-04-26 14:03:44 -04:00
|
|
|
|
2017-08-12 21:57:47 -04:00
|
|
|
MPResultType defaultType = [self typeForSelectedSegment];
|
2020-03-25 12:16:19 -04:00
|
|
|
[MPiOSAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *context) {
|
2016-01-14 09:58:04 -05:00
|
|
|
[[MPiOSAppDelegate get] activeUserInContext:context].defaultType = defaultType;
|
2014-04-20 11:09:49 -04:00
|
|
|
[context saveToStore];
|
2014-04-25 20:02:58 -04:00
|
|
|
|
2020-03-25 12:16:19 -04:00
|
|
|
[self reload];
|
2014-04-20 11:09:49 -04:00
|
|
|
}];
|
2014-04-25 20:02:58 -04:00
|
|
|
}
|
2014-04-20 11:09:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)previousAvatar:(id)sender {
|
2012-06-11 16:15:49 +02:00
|
|
|
|
2020-03-25 12:16:19 -04:00
|
|
|
[MPiOSAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *context) {
|
2013-05-15 22:42:21 -04:00
|
|
|
MPUserEntity *activeUser = [[MPiOSAppDelegate get] activeUserInContext:context];
|
2014-04-20 11:09:49 -04:00
|
|
|
activeUser.avatar = (activeUser.avatar - 1 + MPAvatarCount) % MPAvatarCount;
|
2013-05-15 22:42:21 -04:00
|
|
|
[context saveToStore];
|
2014-04-20 11:09:49 -04:00
|
|
|
|
2020-03-25 12:16:19 -04:00
|
|
|
self.avatarImage.image = [UIImage imageNamed:strf( @"avatar-%lu", (unsigned long)activeUser.avatar )];
|
2013-05-15 22:42:21 -04:00
|
|
|
}];
|
2012-06-11 16:15:49 +02:00
|
|
|
}
|
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
- (IBAction)nextAvatar:(id)sender {
|
2012-06-11 16:15:49 +02:00
|
|
|
|
2020-03-25 12:16:19 -04:00
|
|
|
[MPiOSAppDelegate managedObjectContextForMainThreadPerformBlock:^(NSManagedObjectContext *context) {
|
2014-04-20 11:09:49 -04:00
|
|
|
MPUserEntity *activeUser = [[MPiOSAppDelegate get] activeUserInContext:context];
|
|
|
|
activeUser.avatar = (activeUser.avatar + 1 + MPAvatarCount) % MPAvatarCount;
|
|
|
|
[context saveToStore];
|
2012-06-11 16:15:49 +02:00
|
|
|
|
2020-03-25 12:16:19 -04:00
|
|
|
self.avatarImage.image = [UIImage imageNamed:strf( @"avatar-%lu", (unsigned long)activeUser.avatar )];
|
2014-04-20 11:09:49 -04:00
|
|
|
}];
|
|
|
|
}
|
2012-06-06 00:59:09 +02:00
|
|
|
|
2014-06-03 21:04:22 -04:00
|
|
|
- (IBAction)homePageButton:(id)sender {
|
|
|
|
|
|
|
|
[[self dismissPopup].navigationController performSegueWithIdentifier:@"web" sender:
|
2018-06-03 16:26:08 -04:00
|
|
|
[NSURL URLWithString:@"https://masterpassword.app"]];
|
2014-06-03 21:04:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)securityButton:(id)sender {
|
|
|
|
|
|
|
|
[[self dismissPopup].navigationController performSegueWithIdentifier:@"web" sender:
|
2020-03-05 11:29:10 -05:00
|
|
|
[NSURL URLWithString:@"https://masterpassword.app/masterpassword-algorithm.pdf"]];
|
2014-06-03 21:04:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)sourceButton:(id)sender {
|
|
|
|
|
|
|
|
[[self dismissPopup].navigationController performSegueWithIdentifier:@"web" sender:
|
2018-07-05 17:14:50 -04:00
|
|
|
[NSURL URLWithString:@"https://gitlab.com/MasterPassword/MasterPassword/"]];
|
2014-06-03 21:04:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)thanksButton:(id)sender {
|
|
|
|
|
|
|
|
[[self dismissPopup].navigationController performSegueWithIdentifier:@"web" sender:
|
2017-04-30 18:45:08 -04:00
|
|
|
[NSURL URLWithString:@"https://thanks.lhunath.com"]];
|
2014-06-03 21:04:22 -04:00
|
|
|
}
|
|
|
|
|
2014-04-20 11:09:49 -04:00
|
|
|
#pragma mark - Private
|
|
|
|
|
2017-05-07 18:36:01 -04:00
|
|
|
- (MPSitesViewController *)dismissPopup {
|
2014-05-17 20:12:59 -04:00
|
|
|
|
|
|
|
for (UIViewController *vc = self; (vc = vc.parentViewController);)
|
2017-05-07 18:36:01 -04:00
|
|
|
if ([vc isKindOfClass:[MPSitesViewController class]]) {
|
|
|
|
MPSitesViewController *passwordsVC = (MPSitesViewController *)vc;
|
2014-05-17 20:12:59 -04:00
|
|
|
[passwordsVC dismissPopdown:self];
|
|
|
|
return passwordsVC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2017-08-12 21:57:47 -04:00
|
|
|
- (MPResultType)typeForSelectedSegment {
|
2014-04-20 11:09:49 -04:00
|
|
|
|
2017-04-17 21:57:08 -04:00
|
|
|
NSInteger selectedGenerated1Index = self.generated1TypeControl.selectedSegmentIndex;
|
|
|
|
NSInteger selectedGenerated2Index = self.generated2TypeControl.selectedSegmentIndex;
|
2014-04-25 20:02:58 -04:00
|
|
|
NSInteger selectedStoredIndex = self.storedTypeControl.selectedSegmentIndex;
|
|
|
|
|
2017-04-17 21:57:08 -04:00
|
|
|
switch (selectedGenerated1Index) {
|
|
|
|
case 0:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplatePhrase;
|
2017-04-17 21:57:08 -04:00
|
|
|
case 1:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplateName;
|
2017-04-17 21:57:08 -04:00
|
|
|
default:
|
2017-05-07 18:36:01 -04:00
|
|
|
switch (selectedGenerated2Index) {
|
2014-04-25 20:02:58 -04:00
|
|
|
case 0:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplateMaximum;
|
2014-04-25 20:02:58 -04:00
|
|
|
case 1:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplateLong;
|
2017-05-07 18:36:01 -04:00
|
|
|
case 2:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplateMedium;
|
2017-05-07 18:36:01 -04:00
|
|
|
case 3:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplateBasic;
|
2017-05-07 18:36:01 -04:00
|
|
|
case 4:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplateShort;
|
2017-05-07 18:36:01 -04:00
|
|
|
case 5:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeTemplatePIN;
|
2014-04-25 20:02:58 -04:00
|
|
|
default:
|
2017-05-07 18:36:01 -04:00
|
|
|
|
|
|
|
switch (selectedStoredIndex) {
|
|
|
|
case 0:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeStatefulPersonal;
|
2017-05-07 18:36:01 -04:00
|
|
|
case 1:
|
2017-08-12 21:57:47 -04:00
|
|
|
return MPResultTypeStatefulDevice;
|
2017-05-07 18:36:01 -04:00
|
|
|
default:
|
|
|
|
Throw( @"unsupported selected type index: generated1=%ld, generated2=%ld, stored=%ld",
|
|
|
|
(long)selectedGenerated1Index, (long)selectedGenerated2Index, (long)selectedStoredIndex );
|
|
|
|
}
|
2014-04-25 20:02:58 -04:00
|
|
|
}
|
2017-04-17 21:57:08 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-12 21:57:47 -04:00
|
|
|
- (NSInteger)generated1SegmentIndexForType:(MPResultType)type {
|
2017-04-17 21:57:08 -04:00
|
|
|
|
|
|
|
switch (type) {
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplatePhrase:
|
2017-04-17 21:57:08 -04:00
|
|
|
return 0;
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplateName:
|
2017-04-17 21:57:08 -04:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
2014-04-20 11:09:49 -04:00
|
|
|
}
|
2012-06-08 23:46:13 +02:00
|
|
|
|
2017-08-12 21:57:47 -04:00
|
|
|
- (NSInteger)generated2SegmentIndexForType:(MPResultType)type {
|
2014-04-20 11:09:49 -04:00
|
|
|
|
|
|
|
switch (type) {
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplateMaximum:
|
2014-04-20 11:09:49 -04:00
|
|
|
return 0;
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplateLong:
|
2014-04-20 11:09:49 -04:00
|
|
|
return 1;
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplateMedium:
|
2014-04-20 11:09:49 -04:00
|
|
|
return 2;
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplateBasic:
|
2014-04-20 11:09:49 -04:00
|
|
|
return 3;
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplateShort:
|
2014-04-20 11:09:49 -04:00
|
|
|
return 4;
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeTemplatePIN:
|
2014-04-20 11:09:49 -04:00
|
|
|
return 5;
|
|
|
|
default:
|
2014-04-25 20:02:58 -04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-12 21:57:47 -04:00
|
|
|
- (NSInteger)storedSegmentIndexForType:(MPResultType)type {
|
2014-04-25 20:02:58 -04:00
|
|
|
|
|
|
|
switch (type) {
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeStatefulPersonal:
|
2014-04-25 20:02:58 -04:00
|
|
|
return 0;
|
2017-08-12 21:57:47 -04:00
|
|
|
case MPResultTypeStatefulDevice:
|
2014-04-25 20:02:58 -04:00
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return -1;
|
2014-04-20 11:09:49 -04:00
|
|
|
}
|
2012-06-04 11:27:02 +02:00
|
|
|
}
|
2012-06-06 00:59:09 +02:00
|
|
|
|
2012-06-04 11:27:02 +02:00
|
|
|
@end
|