Added "delete user", fixed some minor UI issues.
This commit is contained in:
parent
113c3790fb
commit
a713a639cd
@ -47,10 +47,12 @@
|
||||
|
||||
- (NSString *)generateContentNamed:(NSString *)name ofType:(MPElementType)type withCounter:(NSUInteger)counter usingKey:(MPKey *)key {
|
||||
|
||||
static NSDictionary *MPTypes_ciphers = nil;
|
||||
if (MPTypes_ciphers == nil)
|
||||
static __strong NSDictionary *MPTypes_ciphers = nil;
|
||||
static dispatch_once_t once = 0;
|
||||
dispatch_once(&once, ^{
|
||||
MPTypes_ciphers = [NSDictionary dictionaryWithContentsOfURL:
|
||||
[[NSBundle mainBundle] URLForResource:@"ciphers" withExtension:@"plist"]];
|
||||
});
|
||||
|
||||
// Determine the seed whose bytes will be used for calculating a password
|
||||
uint32_t ncounter = htonl(counter), nnameLength = htonl(name.length);
|
||||
|
@ -23,6 +23,7 @@
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *openAtLoginItem;
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *savePasswordItem;
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *createUserItem;
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *deleteUserItem;
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *usersItem;
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *dialogStyleRegular;
|
||||
@property(nonatomic, weak) IBOutlet NSMenuItem *dialogStyleHUD;
|
||||
|
@ -68,7 +68,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
- (void)updateUsers {
|
||||
|
||||
[[[self.usersItem submenu] itemArray] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
if (idx > 1)
|
||||
if (idx > 2)
|
||||
[[self.usersItem submenu] removeItem:obj];
|
||||
}];
|
||||
|
||||
@ -77,15 +77,24 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
self.createUserItem.title = @"New User (Not ready)";
|
||||
self.createUserItem.enabled = NO;
|
||||
self.createUserItem.toolTip = @"Please wait until the app is fully loaded.";
|
||||
self.deleteUserItem.title = @"Delete User (Not ready)";
|
||||
self.deleteUserItem.enabled = NO;
|
||||
self.deleteUserItem.toolTip = @"Please wait until the app is fully loaded.";
|
||||
[self.usersItem.submenu addItemWithTitle:@"Loading..." action:NULL keyEquivalent:@""].enabled = NO;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MPUserEntity *activeUser = [self activeUserInContext:context];
|
||||
|
||||
self.createUserItem.title = @"New User";
|
||||
self.createUserItem.enabled = YES;
|
||||
self.createUserItem.toolTip = nil;
|
||||
|
||||
self.deleteUserItem.title = activeUser? @"Delete User": @"Delete User (None Selected)";
|
||||
self.deleteUserItem.enabled = activeUser != nil;
|
||||
self.deleteUserItem.toolTip = activeUser? nil: @"First select the user to delete.";
|
||||
|
||||
NSError *error = nil;
|
||||
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPUserEntity class] )];
|
||||
fetchRequest.sortDescriptors = @[ [NSSortDescriptor sortDescriptorWithKey:@"lastUsed" ascending:NO] ];
|
||||
@ -100,7 +109,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
@"Then give iCloud some time to sync the new user to your Mac.";
|
||||
}
|
||||
|
||||
MPUserEntity *activeUser = [self activeUserInContext:context];
|
||||
self.usersItem.state = NSMixedState;
|
||||
for (MPUserEntity *user in users) {
|
||||
NSMenuItem *userItem = [[NSMenuItem alloc] initWithTitle:user.name action:@selector(selectUser:) keyEquivalent:@""];
|
||||
[userItem setTarget:self];
|
||||
@ -108,7 +117,14 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
[[self.usersItem submenu] addItem:userItem];
|
||||
|
||||
if (!activeUser && [user.name isEqualToString:[MPMacConfig get].usedUserName])
|
||||
[self selectUser:userItem];
|
||||
[super setActiveUser:activeUser = user];
|
||||
|
||||
if ([activeUser isEqual:user]) {
|
||||
userItem.state = NSOnState;
|
||||
self.usersItem.state = NSOffState;
|
||||
}
|
||||
else
|
||||
userItem.state = NSOffState;
|
||||
}
|
||||
|
||||
[self updateMenuItems];
|
||||
@ -200,6 +216,26 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)deleteUser:(NSMenuItem *)sender {
|
||||
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Delete User"
|
||||
defaultButton:@"Delete" alternateButton:nil otherButton:@"Cancel"
|
||||
informativeTextWithFormat:@"This will delete %@ and all his sites.", self.activeUserForMainThread.name];
|
||||
if ([alert runModal] != NSAlertDefaultReturn)
|
||||
return;
|
||||
|
||||
[MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *moc) {
|
||||
[moc deleteObject:[self activeUserInContext:moc]];
|
||||
[self setActiveUser:nil];
|
||||
[moc saveToStore];
|
||||
|
||||
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
|
||||
[self updateUsers];
|
||||
[self showPasswordWindow:nil];
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
- (IBAction)lock:(id)sender {
|
||||
|
||||
self.key = nil;
|
||||
@ -334,17 +370,11 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
|
||||
|
||||
[super setActiveUser:activeUser];
|
||||
|
||||
self.usersItem.state = NSMixedState;
|
||||
[[[self.usersItem submenu] itemArray] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
if ([[obj representedObject] isEqual:[activeUser objectID]]) {
|
||||
[obj setState:NSOnState];
|
||||
self.usersItem.state = NSOffState;
|
||||
}
|
||||
else
|
||||
[obj setState:NSOffState];
|
||||
}];
|
||||
|
||||
[MPMacConfig get].usedUserName = activeUser.name;
|
||||
|
||||
PearlMainQueue(^{
|
||||
[self updateUsers];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)updateMenuItems {
|
||||
|
@ -1876,7 +1876,7 @@
|
||||
);
|
||||
GCC_PREFIX_HEADER = "MasterPassword-Prefix.pch";
|
||||
INFOPLIST_FILE = "MasterPassword-Info.plist";
|
||||
PROVISIONING_PROFILE = "923BEF9D-3682-4969-A451-8CAA949E579A";
|
||||
PROVISIONING_PROFILE = "9FCC90BB-24CA-40E2-8565-860F95CCC039";
|
||||
SKIP_INSTALL = NO;
|
||||
WRAPPER_NAME = "Master Password.${WRAPPER_EXTENSION}";
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B3116" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13D65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment version="1070" defaultVersion="1080" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
@ -16,6 +16,7 @@
|
||||
<customObject id="494" customClass="MPMacAppDelegate">
|
||||
<connections>
|
||||
<outlet property="createUserItem" destination="757" id="763"/>
|
||||
<outlet property="deleteUserItem" destination="ZgZ-p2-463" id="smU-PF-mKA"/>
|
||||
<outlet property="dialogStyleHUD" destination="768" id="771"/>
|
||||
<outlet property="dialogStyleRegular" destination="767" id="772"/>
|
||||
<outlet property="lockItem" destination="720" id="726"/>
|
||||
@ -41,6 +42,12 @@
|
||||
<action selector="newUser:" target="494" id="761"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Delete User" enabled="NO" toolTip="Creating users is not yet supported. Please use the iOS app with iCloud enabled to create users and sites." id="ZgZ-p2-463">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="deleteUser:" target="494" id="eia-X5-QMc"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="759"/>
|
||||
</items>
|
||||
</menu>
|
||||
@ -146,7 +153,7 @@
|
||||
<action selector="rebuildCloud:" target="494" id="780"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Force our version of the truth upon all other devices." enabled="NO" id="779">
|
||||
<menuItem title="Force this device's version of the truth upon all others." enabled="NO" id="779">
|
||||
<attributedString key="attributedTitle">
|
||||
<fragment content="Force this device's version of the truth upon all others.">
|
||||
<attributes>
|
||||
@ -163,7 +170,7 @@
|
||||
<action selector="corruptCloud:" target="494" id="asr-sb-Zkz"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Mark ourselves as corrupt and pull the truth from another." enabled="NO" id="6NL-ki-Jff">
|
||||
<menuItem title="Force this device's version of the truth upon all others." enabled="NO" id="6NL-ki-Jff">
|
||||
<attributedString key="attributedTitle">
|
||||
<fragment content="Force this device's version of the truth upon all others.">
|
||||
<attributes>
|
||||
|
@ -26,7 +26,7 @@
|
||||
if ([self class] == [MPiOSAppDelegate class]) {
|
||||
[PearlLogger get].historyLevel = [[MPiOSConfig get].traceMode boolValue]? PearlLogLevelTrace: PearlLogLevelInfo;
|
||||
#ifdef DEBUG
|
||||
[PearlLogger get].printLevel = PearlLogLevelDebug;
|
||||
[PearlLogger get].printLevel = PearlLogLevelDebug; //Trace;
|
||||
#else
|
||||
[PearlLogger get].printLevel = [[MPiOSConfig get].traceMode boolValue]? PearlLogLevelDebug: PearlLogLevelInfo;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user