mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-23 10:19:26 +00:00
Creating with templates not supported yet. Templates are listed in Context-Menu under the AddEntry Toolbar Toolbar Button is missing an Arrow for now. Control-Size is not working correctly for now Nested Template or Trash groups aren't considered, this is a bug! Minor changes to the UI (Settings tabs now use common icons) Added Workflow-Settings tab to extract all the custom action possible on entries. The copy or open on URL dbl-click setting will move over to this tab.
54 lines
1.8 KiB
Objective-C
54 lines
1.8 KiB
Objective-C
//
|
|
// MPActionHelper.m
|
|
// MacPass
|
|
//
|
|
// Created by Michael Starke on 09.03.13.
|
|
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
|
//
|
|
|
|
#import "MPActionHelper.h"
|
|
|
|
@implementation MPActionHelper
|
|
|
|
+ (NSDictionary *)_actionDictionary {
|
|
static NSDictionary *actionDict;
|
|
static dispatch_once_t onceToken;
|
|
dispatch_once(&onceToken, ^{
|
|
actionDict = @{
|
|
@(MPActionAddEntry) : @"createEntry:",
|
|
@(MPActionAddGroup) : @"createGroup:",
|
|
@(MPActionCopyPassword) : @"copyPassword:",
|
|
@(MPActionCopyURL) : @"copyURL:",
|
|
@(MPActionCopyUsername) : @"copyUsername:",
|
|
@(MPActionDelete) : @"deleteNode:",
|
|
@(MPActionOpenURL) : @"openURL:",
|
|
@(MPActionToggleInspector) : @"toggleInspector:",
|
|
@(MPActionLock) : @"lock:",
|
|
@(MPActionEmptyTrash) : @"emptyTrash:",
|
|
@(MPActionDatabaseSettings) : @"showDatabaseSettings:",
|
|
@(MPActionEditTemplateGroup) : @"editTemplateGroup:"
|
|
};
|
|
});
|
|
return actionDict;
|
|
}
|
|
|
|
+ (SEL)actionOfType:(MPActionType)type {
|
|
NSDictionary *actionDict = [self _actionDictionary];
|
|
return NSSelectorFromString(actionDict[@(type)]);
|
|
}
|
|
|
|
+ (MPActionType)typeForAction:(SEL)action {
|
|
NSString *selectorString = NSStringFromSelector(action);
|
|
NSArray *selectors = [[self _actionDictionary] allValues];
|
|
NSUInteger index = [selectors indexOfObject:selectorString];
|
|
if(index == NSNotFound) {
|
|
return MPUnkownAction;
|
|
}
|
|
NSArray *keys = [[self _actionDictionary] allKeysForObject:selectorString];
|
|
NSAssert([keys count] == 1, @"There should only be one object for the specified key");
|
|
return [[keys lastObject] integerValue];
|
|
}
|
|
|
|
|
|
@end
|