From 81bcd15d8006a3164d7cc6d2238a0e82f395af02 Mon Sep 17 00:00:00 2001 From: michael starke Date: Tue, 18 Feb 2014 13:00:56 +0100 Subject: [PATCH] Combined KeePassHttp and Autotype preferences in one window Added enable auto type preferences key --- KeePassKit | 2 +- MacPass.xcodeproj/project.pbxproj | 40 ++++--- MacPass/Base.lproj/GeneralSettings.xib | 13 ++- MacPass/IntegrationSettings.xib | 105 ++++++++++++++++++ MacPass/MPAutotypeDaemon.m | 22 +++- ...er.h => MPIntegrationSettingsController.h} | 2 +- ...er.m => MPIntegrationSettingsController.m} | 14 +-- MacPass/MPSettingsHelper.h | 1 + MacPass/MPSettingsHelper.m | 4 +- MacPass/MPSettingsWindowController.m | 8 +- MacPass/ServerSettings.xib | 37 ------ MacPass/UpdateSettings.xib | 5 +- MacPass/WorkflowSettings.xib | 3 +- MacPass/de.lproj/Localizable.strings | Bin 8450 -> 8702 bytes MacPass/en.lproj/Localizable.strings | Bin 8150 -> 8172 bytes MacPass/fr.lproj/Localizable.strings | Bin 7736 -> 8950 bytes MacPassTests/KPKTestNSCoding.m | 4 +- MacPassTests/KPKTestNSCopying.m | 7 +- 18 files changed, 184 insertions(+), 83 deletions(-) create mode 100644 MacPass/IntegrationSettings.xib rename MacPass/{MPServerSettingsController.h => MPIntegrationSettingsController.h} (78%) rename MacPass/{MPServerSettingsController.m => MPIntegrationSettingsController.m} (68%) delete mode 100644 MacPass/ServerSettings.xib diff --git a/KeePassKit b/KeePassKit index 178ac05c..82474805 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 178ac05ceeff4577e890761715d763ea83e19bc7 +Subproject commit 824748058c205c242aeb966851b0706293f70743 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 37498dee..42335bbe 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -281,8 +281,8 @@ 4CF78057176E5CFD0032EE71 /* MPConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF78056176E5CFD0032EE71 /* MPConnection.m */; }; 4CF7805A176E6D5F0032EE71 /* HNHTableRowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF78059176E6D5F0032EE71 /* HNHTableRowView.m */; }; 4CF7805D176E71170032EE71 /* MPServerDaemon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF7805C176E71170032EE71 /* MPServerDaemon.m */; }; - 4CF7805F176E75110032EE71 /* ServerSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CF7805E176E75110032EE71 /* ServerSettings.xib */; }; - 4CF78064176E75AD0032EE71 /* MPServerSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF78063176E75AD0032EE71 /* MPServerSettingsController.m */; }; + 4CF7805F176E75110032EE71 /* IntegrationSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CF7805E176E75110032EE71 /* IntegrationSettings.xib */; }; + 4CF78064176E75AD0032EE71 /* MPIntegrationSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF78063176E75AD0032EE71 /* MPIntegrationSettingsController.m */; }; 4CFB18E418A17FA20097A34B /* MPUpdateSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFB18E318A17FA20097A34B /* MPUpdateSettingsController.m */; }; 4CFB18E618A180430097A34B /* UpdateSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CFB18E518A180430097A34B /* UpdateSettings.xib */; }; 4CFC53BF16E94729007396BE /* MPShadowBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFC53BE16E94729007396BE /* MPShadowBox.m */; }; @@ -838,9 +838,9 @@ 4CF78059176E6D5F0032EE71 /* HNHTableRowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HNHTableRowView.m; sourceTree = ""; }; 4CF7805B176E71170032EE71 /* MPServerDaemon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPServerDaemon.h; sourceTree = ""; }; 4CF7805C176E71170032EE71 /* MPServerDaemon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPServerDaemon.m; sourceTree = ""; }; - 4CF7805E176E75110032EE71 /* ServerSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ServerSettings.xib; sourceTree = ""; }; - 4CF78062176E75AD0032EE71 /* MPServerSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPServerSettingsController.h; sourceTree = ""; }; - 4CF78063176E75AD0032EE71 /* MPServerSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPServerSettingsController.m; sourceTree = ""; }; + 4CF7805E176E75110032EE71 /* IntegrationSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IntegrationSettings.xib; sourceTree = ""; }; + 4CF78062176E75AD0032EE71 /* MPIntegrationSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIntegrationSettingsController.h; sourceTree = ""; }; + 4CF78063176E75AD0032EE71 /* MPIntegrationSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIntegrationSettingsController.m; sourceTree = ""; }; 4CFB18E218A17FA20097A34B /* MPUpdateSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPUpdateSettingsController.h; sourceTree = ""; }; 4CFB18E318A17FA20097A34B /* MPUpdateSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPUpdateSettingsController.m; sourceTree = ""; }; 4CFB18E518A180430097A34B /* UpdateSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UpdateSettings.xib; sourceTree = ""; }; @@ -1262,6 +1262,21 @@ name = "Supporting Files"; sourceTree = ""; }; + 4C47D77718B37911002755E4 /* Settings */ = { + isa = PBXGroup; + children = ( + 4CA0B2F715BCAF6700654E32 /* MPGeneralSettingsController.h */, + 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */, + 4CF78062176E75AD0032EE71 /* MPIntegrationSettingsController.h */, + 4CF78063176E75AD0032EE71 /* MPIntegrationSettingsController.m */, + 4CD7223917A7CB0700F5A1E1 /* MPWorkflowSettingsController.h */, + 4CD7223A17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m */, + 4CFB18E218A17FA20097A34B /* MPUpdateSettingsController.h */, + 4CFB18E318A17FA20097A34B /* MPUpdateSettingsController.m */, + ); + name = Settings; + sourceTree = ""; + }; 4C4B7EF517A46815000234C7 /* Inspector */ = { isa = PBXGroup; children = ( @@ -1439,16 +1454,9 @@ 4CA0B2F115BCAEE600654E32 /* View Controller */ = { isa = PBXGroup; children = ( + 4C47D77718B37911002755E4 /* Settings */, 4C2E382416D1470200037A9D /* MPViewController.h */, 4C2E382516D1470200037A9D /* MPViewController.m */, - 4CA0B2F715BCAF6700654E32 /* MPGeneralSettingsController.h */, - 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */, - 4CF78062176E75AD0032EE71 /* MPServerSettingsController.h */, - 4CF78063176E75AD0032EE71 /* MPServerSettingsController.m */, - 4CD7223917A7CB0700F5A1E1 /* MPWorkflowSettingsController.h */, - 4CD7223A17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m */, - 4CFB18E218A17FA20097A34B /* MPUpdateSettingsController.h */, - 4CFB18E318A17FA20097A34B /* MPUpdateSettingsController.m */, 4C65FAE616D16DDB006E0577 /* MPPasswordInputController.h */, 4C65FAE716D16DDB006E0577 /* MPPasswordInputController.m */, 4C5A11FB1708DE8700223D8A /* MPPasswordCreatorViewController.h */, @@ -1794,7 +1802,7 @@ isa = PBXGroup; children = ( 4C76155E1764C04C0015A1A6 /* GeneralSettings.xib */, - 4CF7805E176E75110032EE71 /* ServerSettings.xib */, + 4CF7805E176E75110032EE71 /* IntegrationSettings.xib */, 4CD7223717A7C9EA00F5A1E1 /* WorkflowSettings.xib */, 4CFB18E518A180430097A34B /* UpdateSettings.xib */, ); @@ -1985,7 +1993,7 @@ 4C1DDCDD1711ECEB00C98DA3 /* PasswordCreatorWindow.xib in Resources */, 4C7714AA176C998F00549F2A /* 43_TrashTemplate.pdf in Resources */, 4C7714AC176C9D4600549F2A /* 99_InfoTemplate.pdf in Resources */, - 4CF7805F176E75110032EE71 /* ServerSettings.xib in Resources */, + 4CF7805F176E75110032EE71 /* IntegrationSettings.xib in Resources */, 4CA3531218A5577300839B0F /* dsa_sparkle_pub.pem in Resources */, 4CD5D702177A5EE400100649 /* DatabaseSettingsWindow.xib in Resources */, 4C6D1D25178579570014C5A5 /* 48_FolderTemplate.pdf in Resources */, @@ -2149,7 +2157,7 @@ 4CF78057176E5CFD0032EE71 /* MPConnection.m in Sources */, 4CF7805A176E6D5F0032EE71 /* HNHTableRowView.m in Sources */, 4CF7805D176E71170032EE71 /* MPServerDaemon.m in Sources */, - 4CF78064176E75AD0032EE71 /* MPServerSettingsController.m in Sources */, + 4CF78064176E75AD0032EE71 /* MPIntegrationSettingsController.m in Sources */, 4CF6C711176F4533007A811D /* MPStringLengthValueTransformer.m in Sources */, 4CF6C718176F5234007A811D /* MPAssociateRequestHandler.m in Sources */, 4CC299FF176F99E50050C939 /* MPRequestHandlerService.m in Sources */, diff --git a/MacPass/Base.lproj/GeneralSettings.xib b/MacPass/Base.lproj/GeneralSettings.xib index c364ea59..a375c720 100644 --- a/MacPass/Base.lproj/GeneralSettings.xib +++ b/MacPass/Base.lproj/GeneralSettings.xib @@ -25,7 +25,7 @@ - + @@ -49,7 +49,7 @@ - + @@ -143,7 +143,7 @@ - + @@ -180,18 +180,22 @@ + + + + - + @@ -239,7 +243,6 @@ - diff --git a/MacPass/IntegrationSettings.xib b/MacPass/IntegrationSettings.xib new file mode 100644 index 00000000..2f6c87d6 --- /dev/null +++ b/MacPass/IntegrationSettings.xib @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MacPass/MPAutotypeDaemon.m b/MacPass/MPAutotypeDaemon.m index 261ea0bc..01bd952d 100644 --- a/MacPass/MPAutotypeDaemon.m +++ b/MacPass/MPAutotypeDaemon.m @@ -12,6 +12,7 @@ #import "MPDocument.h" #import "MPDocument+Autotype.h" #import "MPAutotypeCommand.h" +#import "MPSettingsHelper.h" #import "KPKEntry.h" @@ -20,16 +21,31 @@ NSString *const kMPWindowTitleKey = @"windowTitle"; NSString *const kMPApplciationNameKey = @"applicationName"; +@interface MPAutotypeDaemon () + +@property (nonatomic, assign) BOOL enabled; + +@end + @implementation MPAutotypeDaemon - (id)init { self = [super init]; if (self) { - [self _registerHotKey]; + _enabled = NO; + [[NSUserDefaults standardUserDefaults] bind:kMPSettingsKeyEnableGlobalAutotype toObject:self withKeyPath:@"enabled" options:nil]; } return self; } +#pragma mark Properties +- (void)setEnabled:(BOOL)enabled { + if(_enabled != enabled) { + _enabled = enabled; + self.enabled ? [self _registerHotKey] : [self _unregisterHotKey]; + } +} + - (void)exectureAutotypeForEntry:(KPKEntry *)entry withWindowTitle:(NSString *)title { NSAssert(NO,@"Not Implemented"); } @@ -101,6 +117,10 @@ NSString *const kMPApplciationNameKey = @"applicationName"; object:nil]; } +- (void)_unregisterHotKey { + [[DDHotKeyCenter sharedHotKeyCenter] unregisterHotKeysWithTarget:self action:@selector(_didPressHotKey)]; +} + - (NSDictionary *)_frontMostApplicationInfoDict { NSRunningApplication *frontApplication = [[NSWorkspace sharedWorkspace] frontmostApplication]; NSString *name = frontApplication.localizedName; diff --git a/MacPass/MPServerSettingsController.h b/MacPass/MPIntegrationSettingsController.h similarity index 78% rename from MacPass/MPServerSettingsController.h rename to MacPass/MPIntegrationSettingsController.h index 69f860b9..bda2554f 100644 --- a/MacPass/MPServerSettingsController.h +++ b/MacPass/MPIntegrationSettingsController.h @@ -9,7 +9,7 @@ #import "MPViewController.h" #import "MPSettingsTab.h" -@interface MPServerSettingsController : MPViewController +@interface MPIntegrationSettingsController : MPViewController @property (weak) IBOutlet NSButton *enableServerCheckbutton; diff --git a/MacPass/MPServerSettingsController.m b/MacPass/MPIntegrationSettingsController.m similarity index 68% rename from MacPass/MPServerSettingsController.m rename to MacPass/MPIntegrationSettingsController.m index 22053b62..110e6729 100644 --- a/MacPass/MPServerSettingsController.m +++ b/MacPass/MPIntegrationSettingsController.m @@ -6,30 +6,30 @@ // Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. // -#import "MPServerSettingsController.h" +#import "MPIntegrationSettingsController.h" #import "MPSettingsHelper.h" #import "MPIconHelper.h" -@interface MPServerSettingsController () +@interface MPIntegrationSettingsController () @end -@implementation MPServerSettingsController +@implementation MPIntegrationSettingsController - (NSString *)identifier { - return @"ServerSettings"; + return @"Integration"; } - (NSImage *)image { - return [NSImage imageNamed:NSImageNameNetwork]; + return [NSImage imageNamed:NSImageNameComputer]; } - (NSString *)label { - return NSLocalizedString(@"SERVER_SETTINGS", ""); + return NSLocalizedString(@"INTEGRATION_SETTINGS", ""); } - (id)init { - self = [super initWithNibName:@"ServerSettings" bundle:nil]; + self = [super initWithNibName:@"IntegrationSettings" bundle:nil]; return self; } diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index a66ce191..e0341717 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -48,6 +48,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyRememberKeyFilesForDatabases; /* Autotype */ APPKIT_EXTERN NSString *const kMPSettingsKeySendCommandForControlKey; +APPKIT_EXTERN NSString *const kMPSettingsKeyEnableGlobalAutotype; /* Search */ APPKIT_EXTERN NSString *const kMPSettingsKeyEntrySearchFilterMode; diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index d91f26c8..72339d68 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -33,6 +33,7 @@ NSString *const kMPSettingsKeyRememeberdKeysForDatabases = @"RememeberdKeysFo NSString *const kMPSettingsKeyRememberKeyFilesForDatabases = @"RememberKeyFilesForDatabases"; NSString *const kMPSettingsKeySendCommandForControlKey = @"SendCommandKeyForControlKey"; +NSString *const kMPSettingsKeyEnableGlobalAutotype = @"EnableGlobalAutotype"; NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilterMode"; @@ -66,7 +67,8 @@ NSString *const kMPSettingsKeyEntrySearchFilterMode = @"EntrySearchFilte kMPSettingsKeyLegacyHideUsername: @NO, kMPSettingsKeyRememberKeyFilesForDatabases: @NO, kMPSettingsKeySendCommandForControlKey: @YES, - kMPSettingsKeyEntrySearchFilterMode: @0 + kMPSettingsKeyEntrySearchFilterMode: @0, + kMPSettingsKeyEnableGlobalAutotype: @NO, }; } diff --git a/MacPass/MPSettingsWindowController.m b/MacPass/MPSettingsWindowController.m index 92267300..35cfa2c1 100644 --- a/MacPass/MPSettingsWindowController.m +++ b/MacPass/MPSettingsWindowController.m @@ -8,7 +8,7 @@ #import "MPSettingsWindowController.h" #import "MPGeneralSettingsController.h" -#import "MPServerSettingsController.h" +#import "MPIntegrationSettingsController.h" #import "MPWorkflowSettingsController.h" #import "MPUpdateSettingsController.h" @@ -116,18 +116,18 @@ - (void)_setupDefaultSettingsTabs { MPGeneralSettingsController *generalSettingsController = [[MPGeneralSettingsController alloc] init]; - MPServerSettingsController *serverSettingsController = [[MPServerSettingsController alloc] init]; + MPIntegrationSettingsController *integrationSettingsController = [[MPIntegrationSettingsController alloc] init]; MPWorkflowSettingsController *workflowSettingsController = [[MPWorkflowSettingsController alloc] init]; MPUpdateSettingsController *updateSettingsController = [[MPUpdateSettingsController alloc] init]; [self _addSettingsTab:generalSettingsController]; - [self _addSettingsTab:serverSettingsController]; + [self _addSettingsTab:integrationSettingsController]; [self _addSettingsTab:workflowSettingsController]; [self _addSettingsTab:updateSettingsController]; self.defaultToolbarItems = @[ [generalSettingsController identifier], + [integrationSettingsController identifier], [workflowSettingsController identifier], - [serverSettingsController identifier], [updateSettingsController identifier]]; diff --git a/MacPass/ServerSettings.xib b/MacPass/ServerSettings.xib deleted file mode 100644 index 2993d07a..00000000 --- a/MacPass/ServerSettings.xib +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/MacPass/UpdateSettings.xib b/MacPass/UpdateSettings.xib index 1277664d..9255bc9d 100644 --- a/MacPass/UpdateSettings.xib +++ b/MacPass/UpdateSettings.xib @@ -16,7 +16,7 @@ -