2014-03-20 11:15:37 +00:00
|
|
|
/**
|
2014-07-21 03:54:32 +00:00
|
|
|
* Copyright Maarten Billemont (http://www.lhunath.com, lhunath@lyndir.com)
|
|
|
|
*
|
|
|
|
* See the enclosed file LICENSE for license information (LGPLv3). If you did
|
|
|
|
* not receive this file, see http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*
|
|
|
|
* @author Maarten Billemont <lhunath@lyndir.com>
|
|
|
|
* @license http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*/
|
2014-03-20 11:15:37 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// MPAvatarCell.h
|
|
|
|
// MPAvatarCell
|
|
|
|
//
|
|
|
|
// Created by lhunath on 2014-03-11.
|
|
|
|
// Copyright, lhunath (Maarten Billemont) 2014. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MPPasswordCell.h"
|
|
|
|
#import "MPiOSAppDelegate.h"
|
|
|
|
#import "MPAppDelegate_Store.h"
|
2014-09-15 05:00:23 +00:00
|
|
|
#import "UIColor+Expanded.h"
|
2014-09-21 14:29:18 +00:00
|
|
|
#import "MPAppDelegate_InApp.h"
|
2014-03-20 11:15:37 +00:00
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
@interface MPPasswordCell()
|
|
|
|
|
|
|
|
@property(nonatomic, strong) IBOutlet UILabel *siteNameLabel;
|
|
|
|
@property(nonatomic, strong) IBOutlet UITextField *passwordField;
|
2014-09-08 04:15:18 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UIView *loginNameContainer;
|
2014-07-21 03:54:32 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UITextField *loginNameField;
|
|
|
|
@property(nonatomic, strong) IBOutlet UILabel *strengthLabel;
|
|
|
|
@property(nonatomic, strong) IBOutlet UILabel *counterLabel;
|
|
|
|
@property(nonatomic, strong) IBOutlet UIButton *counterButton;
|
|
|
|
@property(nonatomic, strong) IBOutlet UIButton *upgradeButton;
|
2014-09-22 02:45:21 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UIButton *answersButton;
|
2014-07-21 03:54:32 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UIButton *modeButton;
|
2014-07-22 02:57:57 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UIButton *editButton;
|
2014-07-21 03:54:32 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UIScrollView *modeScrollView;
|
2014-09-08 04:15:18 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UIButton *contentButton;
|
|
|
|
@property(nonatomic, strong) IBOutlet UIButton *loginNameButton;
|
2014-08-22 01:51:47 +00:00
|
|
|
@property(nonatomic, strong) IBOutlet UIView *indicatorView;
|
2014-07-21 03:54:32 +00:00
|
|
|
|
|
|
|
@property(nonatomic) MPPasswordCellMode mode;
|
|
|
|
@property(nonatomic, copy) NSString *transientSite;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MPPasswordCell {
|
2014-09-21 15:47:53 +00:00
|
|
|
NSManagedObjectID *_siteOID;
|
2014-07-21 03:54:32 +00:00
|
|
|
}
|
2014-03-20 11:15:37 +00:00
|
|
|
|
|
|
|
#pragma mark - Life cycle
|
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
- (void)awakeFromNib {
|
|
|
|
|
|
|
|
[super awakeFromNib];
|
|
|
|
|
|
|
|
[self addGestureRecognizer:
|
|
|
|
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector( doRevealPassword: )]];
|
|
|
|
[self.counterButton addGestureRecognizer:
|
|
|
|
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector( doResetCounter: )]];
|
2015-02-28 15:01:41 +00:00
|
|
|
[self.upgradeButton addGestureRecognizer:
|
|
|
|
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector( doDowngrade: )]];
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
[self setupLayer];
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-24 05:07:02 +00:00
|
|
|
[self observeKeyPath:@"bounds" withBlock:^(id from, id to, NSKeyValueChange cause, MPPasswordCell *_self) {
|
2014-09-08 04:15:18 +00:00
|
|
|
if (from && !CGSizeEqualToSize( [from CGRectValue].size, [to CGRectValue].size ))
|
2014-09-16 04:34:22 +00:00
|
|
|
[_self setupLayer];
|
2014-09-08 04:15:18 +00:00
|
|
|
}];
|
|
|
|
[self.contentButton observeKeyPath:@"highlighted"
|
|
|
|
withBlock:^(id from, id to, NSKeyValueChange cause, UIButton *button) {
|
2014-09-16 04:34:22 +00:00
|
|
|
[UIView animateWithDuration:.2f delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
|
|
|
|
button.layer.shadowOpacity = button.selected? 0.7f: button.highlighted? 0.3f: 0;
|
|
|
|
} completion:nil];
|
2014-09-08 04:15:18 +00:00
|
|
|
}];
|
|
|
|
[self.contentButton observeKeyPath:@"selected"
|
|
|
|
withBlock:^(id from, id to, NSKeyValueChange cause, UIButton *button) {
|
2014-09-16 04:34:22 +00:00
|
|
|
[UIView animateWithDuration:.2f delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
|
|
|
|
button.layer.shadowOpacity = button.selected? 0.7f: button.highlighted? 0.3f: 0;
|
|
|
|
} completion:nil];
|
2014-09-08 04:15:18 +00:00
|
|
|
}];
|
|
|
|
[self.loginNameButton observeKeyPath:@"highlighted"
|
2014-07-22 02:57:57 +00:00
|
|
|
withBlock:^(id from, id to, NSKeyValueChange cause, UIButton *button) {
|
2014-09-16 04:34:22 +00:00
|
|
|
[UIView animateWithDuration:.2f delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
|
|
|
|
button.backgroundColor = [button.backgroundColor colorWithAlphaComponent:
|
|
|
|
button.selected || button.highlighted? 0.1f: 0];
|
|
|
|
button.layer.shadowOpacity = button.selected? 0.7f: button.highlighted? 0.3f: 0;
|
|
|
|
} completion:nil];
|
2014-08-22 01:51:47 +00:00
|
|
|
}];
|
2014-09-08 04:15:18 +00:00
|
|
|
[self.loginNameButton observeKeyPath:@"selected"
|
2014-07-22 02:57:57 +00:00
|
|
|
withBlock:^(id from, id to, NSKeyValueChange cause, UIButton *button) {
|
2014-09-16 04:34:22 +00:00
|
|
|
[UIView animateWithDuration:.2f delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
|
|
|
|
button.backgroundColor = [button.backgroundColor colorWithAlphaComponent:
|
|
|
|
button.selected || button.highlighted? 0.1f: 0];
|
|
|
|
button.layer.shadowOpacity = button.selected? 0.7f: button.highlighted? 0.3f: 0;
|
|
|
|
} completion:nil];
|
2014-08-22 01:51:47 +00:00
|
|
|
}];
|
|
|
|
|
|
|
|
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
|
|
|
|
animation.byValue = @(10);
|
|
|
|
animation.repeatCount = HUGE_VALF;
|
|
|
|
animation.autoreverses = YES;
|
|
|
|
animation.duration = 0.3f;
|
|
|
|
[self.indicatorView.layer addAnimation:animation forKey:@"bounce"];
|
2014-03-20 11:15:37 +00:00
|
|
|
}
|
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
- (void)setupLayer {
|
|
|
|
|
2014-09-16 04:34:22 +00:00
|
|
|
self.contentView.frame = self.bounds;
|
2014-09-08 04:15:18 +00:00
|
|
|
self.contentButton.layer.cornerRadius = 4;
|
|
|
|
self.contentButton.layer.shadowOffset = CGSizeZero;
|
|
|
|
self.contentButton.layer.shadowRadius = 5;
|
|
|
|
self.contentButton.layer.shadowOpacity = 0;
|
|
|
|
self.contentButton.layer.shadowColor = [UIColor whiteColor].CGColor;
|
|
|
|
self.contentButton.layer.borderWidth = 1;
|
|
|
|
self.contentButton.layer.borderColor = [UIColor colorWithWhite:0.15f alpha:0.6f].CGColor;
|
|
|
|
self.loginNameButton.layer.cornerRadius = 4;
|
|
|
|
self.loginNameButton.layer.shadowOffset = CGSizeZero;
|
|
|
|
self.loginNameButton.layer.shadowRadius = 5;
|
|
|
|
self.loginNameButton.layer.shadowOpacity = 0;
|
|
|
|
self.loginNameButton.layer.shadowColor = [UIColor whiteColor].CGColor;
|
|
|
|
self.contentView.layer.shadowRadius = 5;
|
|
|
|
self.contentView.layer.shadowOpacity = 1;
|
|
|
|
self.contentView.layer.shadowColor = [UIColor colorWithWhite:0 alpha:0.6f].CGColor;
|
|
|
|
self.contentView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.contentView.bounds cornerRadius:4].CGPath;
|
|
|
|
self.contentView.layer.masksToBounds = NO;
|
|
|
|
self.contentView.clipsToBounds = NO;
|
|
|
|
self.layer.masksToBounds = NO;
|
|
|
|
self.clipsToBounds = NO;
|
|
|
|
}
|
|
|
|
|
2014-07-22 02:57:57 +00:00
|
|
|
- (void)prepareForReuse {
|
2014-04-07 03:34:18 +00:00
|
|
|
|
2014-07-22 02:57:57 +00:00
|
|
|
[super prepareForReuse];
|
2014-03-20 11:15:37 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
_siteOID = nil;
|
2014-11-03 17:11:46 +00:00
|
|
|
_fuzzyGroups = nil;
|
2014-08-22 01:51:47 +00:00
|
|
|
self.transientSite = nil;
|
2014-07-26 05:26:33 +00:00
|
|
|
self.mode = MPPasswordCellModePassword;
|
|
|
|
[self updateAnimated:NO];
|
2014-03-20 11:15:37 +00:00
|
|
|
}
|
|
|
|
|
2014-09-16 04:34:22 +00:00
|
|
|
- (void)dealloc {
|
|
|
|
|
2014-09-24 05:07:02 +00:00
|
|
|
[self removeKeyPathObservers];
|
2014-09-16 04:34:22 +00:00
|
|
|
[self.contentButton removeKeyPathObservers];
|
|
|
|
[self.loginNameButton removeKeyPathObservers];
|
|
|
|
}
|
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
#pragma mark - State
|
2014-03-20 11:15:37 +00:00
|
|
|
|
2014-11-03 17:11:46 +00:00
|
|
|
- (void)setFuzzyGroups:(NSArray *)fuzzyGroups {
|
|
|
|
|
|
|
|
if (_fuzzyGroups == fuzzyGroups)
|
|
|
|
return;
|
|
|
|
_fuzzyGroups = fuzzyGroups;
|
|
|
|
|
|
|
|
[self updateSiteName:[self siteInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]]];
|
|
|
|
}
|
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
- (void)setMode:(MPPasswordCellMode)mode animated:(BOOL)animated {
|
2014-03-20 11:15:37 +00:00
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
if (mode == _mode)
|
|
|
|
return;
|
2014-03-20 11:15:37 +00:00
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
_mode = mode;
|
|
|
|
[self updateAnimated:animated];
|
|
|
|
}
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
- (void)setSite:(MPSiteEntity *)site animated:(BOOL)animated {
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
_siteOID = [site objectID];
|
2014-07-21 03:54:32 +00:00
|
|
|
[self updateAnimated:animated];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setTransientSite:(NSString *)siteName animated:(BOOL)animated {
|
|
|
|
|
|
|
|
self.transientSite = siteName;
|
|
|
|
[self updateAnimated:animated];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - UITextFieldDelegate
|
|
|
|
|
|
|
|
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
if (textField == self.passwordField)
|
|
|
|
[self.loginNameField becomeFirstResponder];
|
|
|
|
else
|
|
|
|
[textField resignFirstResponder];
|
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)textFieldDidBeginEditing:(UITextField *)textField {
|
|
|
|
|
|
|
|
UICollectionView *collectionView = [UICollectionView findAsSuperviewOf:self];
|
|
|
|
[collectionView scrollToItemAtIndexPath:[collectionView indexPathForCell:self]
|
|
|
|
atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:YES];
|
2014-09-16 04:34:22 +00:00
|
|
|
|
2014-09-15 05:00:23 +00:00
|
|
|
if (textField == self.loginNameField)
|
2014-09-16 04:34:22 +00:00
|
|
|
self.loginNameButton.titleLabel.alpha = [self.loginNameField.text length] || self.loginNameField.enabled? 0: 1;
|
2014-07-21 03:54:32 +00:00
|
|
|
}
|
|
|
|
|
2014-07-26 05:26:33 +00:00
|
|
|
- (IBAction)textFieldDidChange:(UITextField *)textField {
|
|
|
|
|
|
|
|
if (textField == self.passwordField) {
|
|
|
|
NSString *password = self.passwordField.text;
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
|
|
|
TimeToCrack timeToCrack;
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:context];
|
|
|
|
id<MPAlgorithm> algorithm = site.algorithm?: MPAlgorithmDefault;
|
2014-07-28 22:53:50 +00:00
|
|
|
MPAttacker attackHardware = [[MPConfig get].siteAttacker unsignedIntegerValue];
|
2014-09-21 15:47:53 +00:00
|
|
|
if ([algorithm timeToCrack:&timeToCrack passwordOfType:[self siteInContext:context].type byAttacker:attackHardware] ||
|
2014-07-26 05:26:33 +00:00
|
|
|
[algorithm timeToCrack:&timeToCrack passwordString:password byAttacker:attackHardware])
|
|
|
|
PearlMainQueue( ^{
|
|
|
|
self.strengthLabel.text = NSStringFromTimeToCrack( timeToCrack );
|
|
|
|
} );
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
- (void)textFieldDidEndEditing:(UITextField *)textField {
|
|
|
|
|
2014-07-22 02:57:57 +00:00
|
|
|
if (textField == self.passwordField || textField == self.loginNameField) {
|
2014-07-21 03:54:32 +00:00
|
|
|
textField.enabled = NO;
|
2014-09-08 04:15:18 +00:00
|
|
|
NSString *text = textField.text;
|
2014-07-21 03:54:32 +00:00
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:context];
|
|
|
|
if (!site)
|
2014-07-21 03:54:32 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (textField == self.passwordField) {
|
2014-09-21 15:47:53 +00:00
|
|
|
if ([site.algorithm savePassword:text toSite:site usingKey:[MPiOSAppDelegate get].key])
|
2014-09-08 04:15:18 +00:00
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:@"Password Updated" dismissAfter:2];
|
2014-07-21 03:54:32 +00:00
|
|
|
}
|
2014-09-16 04:34:22 +00:00
|
|
|
else if (textField == self.loginNameField &&
|
2014-09-21 15:47:53 +00:00
|
|
|
((site.loginGenerated && ![text length]) ||
|
|
|
|
(!site.loginGenerated && ![text isEqualToString:site.loginName]))) {
|
2014-09-29 02:15:55 +00:00
|
|
|
if (site.loginGenerated || !([site.loginName isEqualToString:text] || (!text && !site.loginName))) {
|
|
|
|
site.loginGenerated = NO;
|
|
|
|
site.loginName = text;
|
|
|
|
|
|
|
|
if ([text length])
|
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:@"Login Name Saved" dismissAfter:2];
|
|
|
|
else
|
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:@"Login Name Cleared" dismissAfter:2];
|
|
|
|
}
|
2014-07-21 03:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[context saveToStore];
|
|
|
|
[self updateAnimated:YES];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Actions
|
|
|
|
|
2014-07-22 02:57:57 +00:00
|
|
|
- (IBAction)doDelete:(UIButton *)sender {
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]];
|
|
|
|
if (!site)
|
2014-07-22 02:57:57 +00:00
|
|
|
return;
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
[PearlSheet showSheetWithTitle:strf( @"Delete %@?", site.name ) viewStyle:UIActionSheetStyleAutomatic
|
2014-07-22 02:57:57 +00:00
|
|
|
initSheet:nil tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
|
2014-08-22 01:51:47 +00:00
|
|
|
if (buttonIndex == [sheet cancelButtonIndex])
|
|
|
|
return;
|
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-10-23 01:17:02 +00:00
|
|
|
MPSiteEntity *site_ = [self siteInContext:context];
|
|
|
|
if (site_) {
|
|
|
|
[context deleteObject:site_];
|
|
|
|
[context saveToStore];
|
|
|
|
}
|
2014-08-22 01:51:47 +00:00
|
|
|
}];
|
|
|
|
} cancelTitle:@"Cancel" destructiveTitle:@"Delete Site" otherTitles:nil];
|
2014-07-22 02:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doChangeType:(UIButton *)sender {
|
|
|
|
|
|
|
|
[self setMode:MPPasswordCellModePassword animated:YES];
|
|
|
|
|
|
|
|
[PearlSheet showSheetWithTitle:@"Change Password Type" viewStyle:UIActionSheetStyleAutomatic
|
|
|
|
initSheet:^(UIActionSheet *sheet) {
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *mainSite = [self siteInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]];
|
2014-08-22 01:51:47 +00:00
|
|
|
for (NSNumber *typeNumber in [MPAlgorithmDefault allTypes]) {
|
2015-01-15 22:43:41 +00:00
|
|
|
MPSiteType type = (MPSiteType)[typeNumber unsignedIntegerValue];
|
2014-08-22 01:51:47 +00:00
|
|
|
NSString *typeName = [MPAlgorithmDefault nameOfType:type];
|
2014-09-21 15:47:53 +00:00
|
|
|
if (type == mainSite.type)
|
2014-08-22 01:51:47 +00:00
|
|
|
[sheet addButtonWithTitle:strf( @"● %@", typeName )];
|
|
|
|
else
|
|
|
|
[sheet addButtonWithTitle:typeName];
|
|
|
|
}
|
|
|
|
} tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
|
|
|
|
if (buttonIndex == [sheet cancelButtonIndex])
|
|
|
|
return;
|
|
|
|
|
2015-01-15 22:43:41 +00:00
|
|
|
MPSiteType type = (MPSiteType)[[MPAlgorithmDefault allTypes][buttonIndex] unsignedIntegerValue]?: MPSiteTypeGeneratedLong;
|
2014-08-22 01:51:47 +00:00
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:context];
|
|
|
|
site = [[MPiOSAppDelegate get] changeSite:site saveInContext:context toType:type];
|
|
|
|
[self setSite:site animated:YES];
|
2014-08-22 01:51:47 +00:00
|
|
|
}];
|
|
|
|
} cancelTitle:@"Cancel" destructiveTitle:nil otherTitles:nil];
|
2014-03-20 11:15:37 +00:00
|
|
|
}
|
|
|
|
|
2014-07-22 02:57:57 +00:00
|
|
|
- (IBAction)doEdit:(UIButton *)sender {
|
2014-03-20 11:15:37 +00:00
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
self.loginNameField.enabled = YES;
|
|
|
|
self.passwordField.enabled = YES;
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
if ([self siteInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]].type & MPSiteTypeClassStored)
|
2014-07-22 02:57:57 +00:00
|
|
|
[self.passwordField becomeFirstResponder];
|
2014-09-08 04:15:18 +00:00
|
|
|
else
|
|
|
|
[self.loginNameField becomeFirstResponder];
|
2014-07-21 03:54:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doMode:(UIButton *)sender {
|
|
|
|
|
|
|
|
switch (self.mode) {
|
|
|
|
case MPPasswordCellModePassword:
|
|
|
|
[self setMode:MPPasswordCellModeSettings animated:YES];
|
|
|
|
break;
|
|
|
|
case MPPasswordCellModeSettings:
|
|
|
|
[self setMode:MPPasswordCellModePassword animated:YES];
|
|
|
|
break;
|
|
|
|
}
|
2014-03-20 11:15:37 +00:00
|
|
|
}
|
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
- (IBAction)doUpgrade:(UIButton *)sender {
|
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2015-02-28 15:01:41 +00:00
|
|
|
MPSiteEntity *siteEntity = [self siteInContext:context];
|
|
|
|
if (![siteEntity tryMigrateExplicitly:YES]) {
|
2014-07-21 03:54:32 +00:00
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:@"Couldn't Upgrade Site" dismissAfter:2];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[context saveToStore];
|
2015-02-28 15:01:41 +00:00
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:strf( @"Site Upgraded to V%d", siteEntity.algorithm.version )
|
|
|
|
dismissAfter:2];
|
|
|
|
[self updateAnimated:YES];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doDowngrade:(UILongPressGestureRecognizer *)recognizer {
|
|
|
|
|
|
|
|
if (recognizer.state != UIGestureRecognizerStateBegan)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (![[MPiOSConfig get].allowDowngrade boolValue])
|
|
|
|
return;
|
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
|
|
|
MPSiteEntity *siteEntity = [self siteInContext:context];
|
|
|
|
if (siteEntity.algorithm.version <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
siteEntity.algorithm = MPAlgorithmForVersion( siteEntity.algorithm.version - 1 );
|
|
|
|
[context saveToStore];
|
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:strf( @"Site Downgraded to V%d", siteEntity.algorithm.version )
|
|
|
|
dismissAfter:2];
|
2014-07-21 03:54:32 +00:00
|
|
|
[self updateAnimated:YES];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doIncrementCounter:(UIButton *)sender {
|
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:context];
|
|
|
|
if (!site || ![site isKindOfClass:[MPGeneratedSiteEntity class]])
|
2014-07-21 03:54:32 +00:00
|
|
|
return;
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
++((MPGeneratedSiteEntity *)site).counter;
|
2014-07-21 03:54:32 +00:00
|
|
|
[context saveToStore];
|
|
|
|
|
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:@"Generating New Password" dismissAfter:2];
|
|
|
|
[self updateAnimated:YES];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doRevealPassword:(UILongPressGestureRecognizer *)recognizer {
|
|
|
|
|
|
|
|
if (recognizer.state != UIGestureRecognizerStateBegan)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (self.passwordField.secureTextEntry) {
|
|
|
|
self.passwordField.secureTextEntry = NO;
|
|
|
|
|
|
|
|
PearlMainQueueAfter( 3, ^{
|
|
|
|
self.passwordField.secureTextEntry = [[MPiOSConfig get].hidePasswords boolValue];
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doResetCounter:(UILongPressGestureRecognizer *)recognizer {
|
|
|
|
|
|
|
|
if (recognizer.state != UIGestureRecognizerStateBegan)
|
|
|
|
return;
|
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:context];
|
|
|
|
if (!site || ![site isKindOfClass:[MPGeneratedSiteEntity class]])
|
2014-07-21 03:54:32 +00:00
|
|
|
return;
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
((MPGeneratedSiteEntity *)site).counter = 1;
|
2014-07-21 03:54:32 +00:00
|
|
|
[context saveToStore];
|
|
|
|
|
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:@"Counter Reset" dismissAfter:2];
|
|
|
|
[self updateAnimated:YES];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
- (IBAction)doContent:(id)sender {
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
[UIView animateWithDuration:.2f animations:^{
|
|
|
|
self.contentButton.selected = YES;
|
|
|
|
}];
|
2014-07-21 03:54:32 +00:00
|
|
|
|
|
|
|
if (self.transientSite) {
|
|
|
|
[[UIResponder findFirstResponder] resignFirstResponder];
|
|
|
|
[PearlAlert showAlertWithTitle:@"Create Site"
|
|
|
|
message:strf( @"Remember site named:\n%@", self.transientSite )
|
|
|
|
viewStyle:UIAlertViewStyleDefault
|
|
|
|
initAlert:nil tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) {
|
2014-08-22 01:51:47 +00:00
|
|
|
if (buttonIndex == [alert cancelButtonIndex]) {
|
2014-09-08 04:15:18 +00:00
|
|
|
self.contentButton.selected = NO;
|
2014-08-22 01:51:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[MPiOSAppDelegate get]
|
2014-09-21 15:47:53 +00:00
|
|
|
addSiteNamed:self.transientSite completion:^(MPSiteEntity *site, NSManagedObjectContext *context) {
|
|
|
|
[self copyContentOfSite:site saveInContext:context];
|
2014-09-08 04:15:18 +00:00
|
|
|
|
|
|
|
PearlMainQueueAfter( .3f, ^{
|
|
|
|
[UIView animateWithDuration:.2f animations:^{
|
|
|
|
self.contentButton.selected = NO;
|
|
|
|
}];
|
2014-08-22 01:51:47 +00:00
|
|
|
} );
|
|
|
|
}];
|
|
|
|
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonYes, nil];
|
2014-07-21 03:54:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-09-21 15:47:53 +00:00
|
|
|
[self copyContentOfSite:[self siteInContext:context] saveInContext:context];
|
2014-09-08 04:15:18 +00:00
|
|
|
|
|
|
|
PearlMainQueueAfter( .3f, ^{
|
|
|
|
[UIView animateWithDuration:.2f animations:^{
|
|
|
|
self.contentButton.selected = NO;
|
|
|
|
}];
|
|
|
|
} );
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doLoginName:(id)sender {
|
|
|
|
|
|
|
|
[UIView animateWithDuration:.2f animations:^{
|
|
|
|
self.loginNameButton.selected = YES;
|
|
|
|
}];
|
|
|
|
|
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:context];
|
|
|
|
if (![self copyLoginOfSite:site saveInContext:context]) {
|
|
|
|
site.loginGenerated = YES;
|
2014-09-15 05:00:23 +00:00
|
|
|
[context saveToStore];
|
2014-09-16 04:34:22 +00:00
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:@"Login Name Generated" dismissAfter:2];
|
2014-09-15 05:00:23 +00:00
|
|
|
[self updateAnimated:YES];
|
|
|
|
}
|
2014-09-08 04:15:18 +00:00
|
|
|
|
|
|
|
PearlMainQueueAfter( .3f, ^{
|
|
|
|
[UIView animateWithDuration:.2f animations:^{
|
|
|
|
self.loginNameButton.selected = NO;
|
|
|
|
}];
|
2014-07-21 03:54:32 +00:00
|
|
|
} );
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - UIScrollViewDelegate
|
|
|
|
|
|
|
|
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|
|
|
|
2014-07-26 05:26:33 +00:00
|
|
|
if (roundf( (float)(scrollView.contentOffset.x / self.bounds.size.width) ) == 0.0f)
|
2014-07-21 03:54:32 +00:00
|
|
|
[self setMode:MPPasswordCellModePassword animated:YES];
|
|
|
|
else
|
|
|
|
[self setMode:MPPasswordCellModeSettings animated:YES];
|
|
|
|
}
|
|
|
|
|
2014-03-20 11:15:37 +00:00
|
|
|
#pragma mark - Private
|
|
|
|
|
|
|
|
- (void)updateAnimated:(BOOL)animated {
|
|
|
|
|
2014-04-07 03:34:18 +00:00
|
|
|
if (![NSThread isMainThread]) {
|
|
|
|
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
|
|
|
[self updateAnimated:animated];
|
2014-03-20 11:15:37 +00:00
|
|
|
}];
|
2014-04-07 03:34:18 +00:00
|
|
|
return;
|
2014-03-20 11:15:37 +00:00
|
|
|
}
|
2014-04-07 03:34:18 +00:00
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
[UIView animateWithDuration:animated? .3f: 0 animations:^{
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *mainSite = [self siteInContext:[MPiOSAppDelegate managedObjectContextForMainThreadIfReady]];
|
2014-07-21 03:54:32 +00:00
|
|
|
|
|
|
|
// UI
|
2015-02-28 15:01:41 +00:00
|
|
|
self.upgradeButton.gone = !mainSite.requiresExplicitMigration && ![[MPiOSConfig get].allowDowngrade boolValue];
|
2014-09-26 04:32:07 +00:00
|
|
|
self.answersButton.gone = ![[MPiOSAppDelegate get] isFeatureUnlocked:MPProductGenerateAnswers];
|
2014-09-16 04:34:22 +00:00
|
|
|
BOOL settingsMode = self.mode == MPPasswordCellModeSettings;
|
2014-09-21 15:47:53 +00:00
|
|
|
self.loginNameContainer.alpha = settingsMode || mainSite.loginGenerated || [mainSite.loginName length]? 0.7f: 0;
|
|
|
|
self.loginNameField.textColor = [UIColor colorWithHexString:mainSite.loginGenerated? @"5E636D": @"6D5E63"];
|
2014-09-16 04:34:22 +00:00
|
|
|
self.modeButton.alpha = self.transientSite? 0: settingsMode? 0.5f: 0.1f;
|
2014-09-21 15:47:53 +00:00
|
|
|
self.counterLabel.alpha = self.counterButton.alpha = mainSite.type & MPSiteTypeClassGenerated? 0.5f: 0;
|
2014-09-16 04:34:22 +00:00
|
|
|
self.modeButton.selected = settingsMode;
|
|
|
|
self.strengthLabel.gone = !settingsMode;
|
2014-08-22 01:51:47 +00:00
|
|
|
self.modeScrollView.scrollEnabled = !self.transientSite;
|
2014-07-22 02:57:57 +00:00
|
|
|
[self.modeScrollView setContentOffset:CGPointMake( self.mode * self.modeScrollView.frame.size.width, 0 ) animated:animated];
|
2014-09-16 04:34:22 +00:00
|
|
|
if (!settingsMode) {
|
|
|
|
[self.loginNameField resignFirstResponder];
|
|
|
|
[self.passwordField resignFirstResponder];
|
2014-08-22 01:51:47 +00:00
|
|
|
}
|
2014-09-26 04:32:07 +00:00
|
|
|
if ([[MPiOSAppDelegate get] isFeatureUnlocked:MPProductGenerateLogins])
|
2014-09-17 05:34:58 +00:00
|
|
|
[self.loginNameButton setTitle:@"Tap to generate username or use pencil to save one" forState:UIControlStateNormal];
|
|
|
|
else
|
|
|
|
[self.loginNameButton setTitle:@"Tap the pencil to save a username" forState:UIControlStateNormal];
|
2014-08-22 01:51:47 +00:00
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
// Site Name
|
2014-11-03 17:11:46 +00:00
|
|
|
[self updateSiteName:mainSite];
|
2014-07-21 03:54:32 +00:00
|
|
|
|
|
|
|
// Site Password
|
|
|
|
self.passwordField.secureTextEntry = [[MPiOSConfig get].hidePasswords boolValue];
|
|
|
|
self.passwordField.attributedPlaceholder = stra(
|
2014-09-21 15:47:53 +00:00
|
|
|
mainSite.type & MPSiteTypeClassStored? strl( @"No password" ):
|
|
|
|
mainSite.type & MPSiteTypeClassGenerated? strl( @"..." ): @"", @{
|
2017-04-01 04:30:25 +00:00
|
|
|
NSForegroundColorAttributeName: [UIColor whiteColor]
|
2016-07-06 05:16:10 +00:00
|
|
|
} );
|
2014-07-21 03:54:32 +00:00
|
|
|
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
|
2014-09-21 15:47:53 +00:00
|
|
|
MPSiteEntity *site = [self siteInContext:context];
|
2014-09-15 05:00:23 +00:00
|
|
|
MPKey *key = [MPiOSAppDelegate get].key;
|
2014-09-29 02:15:55 +00:00
|
|
|
if (!key)
|
|
|
|
return;
|
|
|
|
|
2016-07-06 05:16:10 +00:00
|
|
|
NSString *password = nil, *loginName = [site resolveLoginUsingKey:key];
|
|
|
|
MPSiteType transientType = [[MPiOSAppDelegate get] activeUserInContext:context].defaultType?: MPSiteTypeGeneratedLong;
|
|
|
|
if (self.transientSite && transientType & MPSiteTypeClassGenerated)
|
|
|
|
password = [MPAlgorithmDefault generatePasswordForSiteNamed:self.transientSite ofType:transientType
|
2014-09-15 05:00:23 +00:00
|
|
|
withCounter:1 usingKey:key];
|
2014-09-21 15:47:53 +00:00
|
|
|
else if (site)
|
|
|
|
password = [site resolvePasswordUsingKey:key];
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-07-26 05:26:33 +00:00
|
|
|
TimeToCrack timeToCrack;
|
|
|
|
NSString *timeToCrackString = nil;
|
2014-09-21 15:47:53 +00:00
|
|
|
id<MPAlgorithm> algorithm = site.algorithm?: MPAlgorithmDefault;
|
2014-10-14 03:39:07 +00:00
|
|
|
MPAttacker attackHardware = [[MPConfig get].siteAttacker integerValue];
|
2014-09-21 15:47:53 +00:00
|
|
|
if ([algorithm timeToCrack:&timeToCrack passwordOfType:site.type byAttacker:attackHardware] ||
|
2014-07-26 05:26:33 +00:00
|
|
|
[algorithm timeToCrack:&timeToCrack passwordString:password byAttacker:attackHardware])
|
|
|
|
timeToCrackString = NSStringFromTimeToCrack( timeToCrack );
|
|
|
|
|
2015-02-28 15:01:41 +00:00
|
|
|
BOOL requiresExplicitMigration = site.requiresExplicitMigration;
|
|
|
|
|
2014-07-21 03:54:32 +00:00
|
|
|
PearlMainQueue( ^{
|
2014-09-15 05:00:23 +00:00
|
|
|
self.loginNameField.text = loginName;
|
2014-07-21 03:54:32 +00:00
|
|
|
self.passwordField.text = password;
|
2014-07-26 05:26:33 +00:00
|
|
|
self.strengthLabel.text = timeToCrackString;
|
2014-09-16 04:34:22 +00:00
|
|
|
self.loginNameButton.titleLabel.alpha = [loginName length] || self.loginNameField.enabled? 0: 1;
|
2014-08-22 01:51:47 +00:00
|
|
|
|
2015-02-28 15:01:41 +00:00
|
|
|
if (![password length]) {
|
2014-09-08 04:15:18 +00:00
|
|
|
self.indicatorView.alpha = 1;
|
|
|
|
[self.indicatorView removeFromSuperview];
|
|
|
|
[self.modeScrollView addSubview:self.indicatorView];
|
|
|
|
[self.contentView addConstraintsWithVisualFormat:@"V:[indicator][target]" options:NSLayoutFormatAlignAllCenterX
|
|
|
|
metrics:nil views:@{
|
2017-04-01 04:30:25 +00:00
|
|
|
@"indicator": self.indicatorView,
|
|
|
|
@"target" : settingsMode? self.editButton: self.modeButton
|
2014-09-08 04:15:18 +00:00
|
|
|
}];
|
2014-08-22 01:51:47 +00:00
|
|
|
}
|
2015-02-28 15:01:41 +00:00
|
|
|
else if (requiresExplicitMigration) {
|
|
|
|
self.indicatorView.alpha = 1;
|
|
|
|
[self.indicatorView removeFromSuperview];
|
|
|
|
[self.modeScrollView addSubview:self.indicatorView];
|
|
|
|
[self.contentView addConstraintsWithVisualFormat:@"V:[indicator][target]" options:NSLayoutFormatAlignAllCenterX
|
|
|
|
metrics:nil views:@{
|
2017-04-01 04:30:25 +00:00
|
|
|
@"indicator": self.indicatorView,
|
|
|
|
@"target" : settingsMode? self.upgradeButton: self.modeButton
|
2015-02-28 15:01:41 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
self.indicatorView.alpha = 0;
|
2014-07-21 03:54:32 +00:00
|
|
|
} );
|
|
|
|
}];
|
|
|
|
|
|
|
|
// Site Counter
|
2014-09-21 15:47:53 +00:00
|
|
|
if ([mainSite isKindOfClass:[MPGeneratedSiteEntity class]])
|
|
|
|
self.counterLabel.text = strf( @"%lu", (unsigned long)((MPGeneratedSiteEntity *)mainSite).counter );
|
2014-07-21 03:54:32 +00:00
|
|
|
|
|
|
|
// Site Login Name
|
2014-09-08 04:15:18 +00:00
|
|
|
self.loginNameField.enabled = self.passwordField.enabled = //
|
|
|
|
[self.loginNameField isFirstResponder] || [self.passwordField isFirstResponder];
|
|
|
|
|
|
|
|
[self.contentView layoutIfNeeded];
|
2014-04-07 03:34:18 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2014-11-03 17:11:46 +00:00
|
|
|
- (void)updateSiteName:(MPSiteEntity *)site {
|
|
|
|
|
|
|
|
NSString *siteName = self.transientSite?: site.name;
|
|
|
|
NSMutableAttributedString *attributedSiteName = [[NSMutableAttributedString alloc] initWithString:siteName?: @""];
|
|
|
|
if ([attributedSiteName length])
|
|
|
|
for (NSUInteger f = 0, s = (NSUInteger)-1; f < [self.fuzzyGroups count]; ++f) {
|
|
|
|
s = [siteName rangeOfString:self.fuzzyGroups[f] options:NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch
|
|
|
|
range:NSMakeRange( s + 1, [siteName length] - (s + 1) )].location;
|
|
|
|
if (s == NSNotFound)
|
|
|
|
break;
|
|
|
|
|
|
|
|
[attributedSiteName addAttribute:NSBackgroundColorAttributeName value:[UIColor redColor]
|
|
|
|
range:NSMakeRange( s, [self.fuzzyGroups[f] length] )];
|
|
|
|
}
|
|
|
|
|
|
|
|
[attributedSiteName appendAttributedString:stra(
|
2017-04-01 04:30:25 +00:00
|
|
|
strf( @" - %@", self.transientSite? @"Tap to create": [site.algorithm shortNameOfType:site.type] ), @{} )];
|
2014-11-03 17:11:46 +00:00
|
|
|
self.siteNameLabel.attributedText = attributedSiteName;
|
|
|
|
}
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
- (BOOL)copyContentOfSite:(MPSiteEntity *)site saveInContext:(NSManagedObjectContext *)context {
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
inf( @"Copying password for: %@", site.name );
|
|
|
|
NSString *password = [site resolvePasswordUsingKey:[MPAppDelegate_Shared get].key];
|
2014-09-08 04:15:18 +00:00
|
|
|
if (![password length])
|
2014-09-15 05:00:23 +00:00
|
|
|
return NO;
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-08 04:15:18 +00:00
|
|
|
PearlMainQueue( ^{
|
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:strl( @"Password Copied" ) dismissAfter:2];
|
|
|
|
[UIPasteboard generalPasteboard].string = password;
|
|
|
|
} );
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
[site use];
|
2014-09-08 04:15:18 +00:00
|
|
|
[context saveToStore];
|
2014-09-15 05:00:23 +00:00
|
|
|
return YES;
|
2014-09-08 04:15:18 +00:00
|
|
|
}
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
- (BOOL)copyLoginOfSite:(MPSiteEntity *)site saveInContext:(NSManagedObjectContext *)context {
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
inf( @"Copying login for: %@", site.name );
|
|
|
|
NSString *loginName = [site.algorithm resolveLoginForSite:site usingKey:[MPiOSAppDelegate get].key];
|
2014-09-08 04:15:18 +00:00
|
|
|
if (![loginName length])
|
2014-09-15 05:00:23 +00:00
|
|
|
return NO;
|
2014-09-08 04:15:18 +00:00
|
|
|
|
|
|
|
PearlMainQueue( ^{
|
|
|
|
[PearlOverlay showTemporaryOverlayWithTitle:strl( @"Login Name Copied" ) dismissAfter:2];
|
|
|
|
[UIPasteboard generalPasteboard].string = loginName;
|
|
|
|
} );
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
[site use];
|
2014-09-08 04:15:18 +00:00
|
|
|
[context saveToStore];
|
2014-09-15 05:00:23 +00:00
|
|
|
return YES;
|
2014-07-21 03:54:32 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
- (MPSiteEntity *)siteInContext:(NSManagedObjectContext *)context {
|
2014-07-21 03:54:32 +00:00
|
|
|
|
2014-09-21 15:47:53 +00:00
|
|
|
return [MPSiteEntity existingObjectWithID:_siteOID inContext:context];
|
2014-07-21 03:54:32 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 11:15:37 +00:00
|
|
|
@end
|