2017-04-05 20:56:22 +00:00
|
|
|
//==============================================================================
|
|
|
|
// This file is part of Master Password.
|
|
|
|
// Copyright (c) 2011-2017, Maarten Billemont.
|
2012-07-17 20:57:11 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00: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-07-17 20:57:11 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00: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-07-17 20:57:11 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// You can find a copy of the GNU General Public License in the
|
|
|
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
|
|
|
//==============================================================================
|
2012-07-17 20:57:11 +00:00
|
|
|
|
|
|
|
#import "MPAlgorithmV1.h"
|
|
|
|
#import "MPEntities.h"
|
|
|
|
|
|
|
|
@implementation MPAlgorithmV1
|
|
|
|
|
2015-01-15 22:43:41 +00:00
|
|
|
- (MPAlgorithmVersion)version {
|
2012-07-17 20:57:11 +00:00
|
|
|
|
2015-01-15 22:43:41 +00:00
|
|
|
return MPAlgorithmVersion1;
|
2012-07-17 20:57:11 +00:00
|
|
|
}
|
|
|
|
|
2014-09-24 11:58:23 +00:00
|
|
|
- (BOOL)tryMigrateSite:(MPSiteEntity *)site explicit:(BOOL)explicit {
|
2012-07-17 20:57:11 +00:00
|
|
|
|
2015-02-28 15:01:41 +00:00
|
|
|
if ([site.algorithm version] != [self version] - 1)
|
2014-07-21 03:54:32 +00:00
|
|
|
// Only migrate from previous version.
|
2012-07-17 20:57:11 +00:00
|
|
|
return NO;
|
|
|
|
|
|
|
|
if (!explicit) {
|
2017-08-13 01:57:47 +00:00
|
|
|
if (site.type & MPResultTypeClassTemplate) {
|
2012-07-17 20:57:11 +00:00
|
|
|
// This migration requires explicit permission for types of the generated class.
|
2014-09-21 15:47:53 +00:00
|
|
|
site.requiresExplicitMigration = YES;
|
2012-07-17 20:57:11 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply migration.
|
2014-09-21 15:47:53 +00:00
|
|
|
site.requiresExplicitMigration = NO;
|
2015-02-28 15:01:41 +00:00
|
|
|
site.algorithm = self;
|
2012-07-17 20:57:11 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|