diff --git a/MacPass/Base.lproj/GeneralPreferences.xib b/MacPass/Base.lproj/GeneralPreferences.xib
index 3de597b8..4ce5887d 100644
--- a/MacPass/Base.lproj/GeneralPreferences.xib
+++ b/MacPass/Base.lproj/GeneralPreferences.xib
@@ -14,6 +14,7 @@
+
@@ -24,16 +25,16 @@
-
+
-
+
-
+
-
+
@@ -44,10 +45,10 @@
-
+
-
+
-
+
-
+
-
+
@@ -113,7 +114,7 @@
-
+
Enabling this compromises security. If enabled, your preferences will contain mappings from database to keyfile. Key locations for databases without a password will not be saved.
@@ -130,42 +131,53 @@
-
+
-
+
Disabling this compromises security. If enabled, anything copied to the Clipboard in MacPass will be available on your connected iOS devices. You should clear the clipboard on those devices manually.
+
+
+
-
+
+
-
+
+
@@ -197,7 +209,7 @@
-
+
@@ -219,7 +231,7 @@
-
+
@@ -236,7 +248,7 @@
-
+
@@ -273,7 +285,7 @@
-
+
diff --git a/MacPass/MPGeneralPreferencesController.h b/MacPass/MPGeneralPreferencesController.h
index f216249b..498f7f4d 100644
--- a/MacPass/MPGeneralPreferencesController.h
+++ b/MacPass/MPGeneralPreferencesController.h
@@ -32,6 +32,7 @@
@property (strong) IBOutlet NSPopUpButton *idleTimeOutPopup;
@property (strong) IBOutlet NSButton *lockOnSleepCheckButton;
@property (strong) IBOutlet NSButton *lockOnLogoutCheckButton;
+@property (weak) IBOutlet NSButton *lockOnScreenSleepCheckButton;
@property (strong) IBOutlet NSButton *reopenLastDatabase;
@property (strong) IBOutlet NSButton *enableAutosaveCheckButton;
@property (strong) IBOutlet NSButton *rememberKeyFileCheckButton;
diff --git a/MacPass/MPGeneralPreferencesController.m b/MacPass/MPGeneralPreferencesController.m
index 20428a82..759e4132 100644
--- a/MacPass/MPGeneralPreferencesController.m
+++ b/MacPass/MPGeneralPreferencesController.m
@@ -50,6 +50,7 @@
[self.preventUniversalClipboardSupportCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyPreventUniversalClipboard] options:nil];
[self.lockOnSleepCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLockOnSleep] options:nil];
[self.lockOnLogoutCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnLogout] options:nil];
+ [self.lockOnScreenSleepCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnScreenSleep] options:nil];
[self.idleTimeOutPopup bind:NSSelectedTagBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyIdleLockTimeOut] options:nil];
[self.reopenLastDatabase bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch] options:nil];
[self.enableAutosaveCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEnableAutosave] options:nil];
diff --git a/MacPass/MPLockDaemon.m b/MacPass/MPLockDaemon.m
index 5180f37d..8851198c 100644
--- a/MacPass/MPLockDaemon.m
+++ b/MacPass/MPLockDaemon.m
@@ -28,6 +28,7 @@
@property (nonatomic,assign) BOOL lockOnSleep;
@property (nonatomic,assign) BOOL lockOnLogout;
+@property (nonatomic,assign) BOOL lockOnScreenSleep;
@property (nonatomic,assign) NSUInteger idleLockTime;
@property (nonatomic,strong) id localEventHandler;
@property (nonatomic,strong) NSTimer *idleCheckTimer;
@@ -59,6 +60,7 @@ static MPLockDaemon *_sharedInstance;
[self bind:NSStringFromSelector(@selector(lockOnSleep)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLockOnSleep] options:nil];
[self bind:NSStringFromSelector(@selector(idleLockTime)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyIdleLockTimeOut] options:nil];
[self bind:NSStringFromSelector(@selector(lockOnLogout)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnLogout] options:nil];
+ [self bind:NSStringFromSelector(@selector(lockOnScreenSleep)) toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingskeyLockOnScreenSleep] options:nil];
}
return self;
}
@@ -95,6 +97,18 @@ static MPLockDaemon *_sharedInstance;
}
}
+- (void)setLockOnScreenSleep:(BOOL)lockOnScreenSleep {
+ if(_lockOnScreenSleep != lockOnScreenSleep) {
+ _lockOnScreenSleep = lockOnScreenSleep;
+ if(_lockOnScreenSleep) {
+ [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_willScreenSleepNotification:) name:NSWorkspaceScreensDidSleepNotification object:nil];
+ }
+ else {
+ [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:NSWorkspaceScreensDidSleepNotification object:nil];
+ }
+ }
+}
+
- (void)setIdleLockTime:(NSUInteger)idleLockTime {
if(_idleLockTime != idleLockTime) {
_idleLockTime = idleLockTime;
@@ -113,6 +127,9 @@ static MPLockDaemon *_sharedInstance;
- (void)_willSleepNotification:(NSNotification *)notification {
[((MPAppDelegate *)NSApp.delegate) lockAllDocuments];
}
+- (void)_willScreenSleepNotification:(NSNotification *)notification {
+ [((MPAppDelegate *)NSApp.delegate) lockAllDocuments];
+}
- (void)_checkIdleTime:(NSTimer *)timer {
if(timer != self.idleCheckTimer) {
diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h
index 9c366a87..786b8b17 100644
--- a/MacPass/MPSettingsHelper.h
+++ b/MacPass/MPSettingsHelper.h
@@ -42,6 +42,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyBrowserBundleId;
APPKIT_EXTERN NSString *const kMPSettingsKeyLockOnSleep;
APPKIT_EXTERN NSString *const kMPSettingskeyLockOnLogout;
APPKIT_EXTERN NSString *const kMPSettingsKeyIdleLockTimeOut;
+APPKIT_EXTERN NSString *const kMPSettingskeyLockOnScreenSleep;
/* Autosaving states */
APPKIT_EXTERN NSString *const kMPSettingsKeyShowInspector;
diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m
index 63dea553..c08a4876 100644
--- a/MacPass/MPSettingsHelper.m
+++ b/MacPass/MPSettingsHelper.m
@@ -37,6 +37,7 @@ NSString *const kMPSettingsKeyFileChangeStrategy = @"FileCh
NSString *const kMPSettingsKeyEnableAutosave = @"EnableAutosave";
NSString *const kMPSettingsKeyLockOnSleep = @"LockOnSleep";
NSString *const kMPSettingskeyLockOnLogout = @"LockOnLogout";
+NSString *const kMPSettingskeyLockOnScreenSleep = @"LockOnScreenSleep";
NSString *const kMPSettingsKeyIdleLockTimeOut = @"IdleLockTimeOut";
NSString *const kMPSettingsKeyShowInspector = @"ShowInspector";
NSString *const kMPSettingsKeyEntryTableSortDescriptors = @"EntryTableSortDescriptors";
@@ -132,6 +133,7 @@ NSString *const kMPDepricatedSettingsKeyAutotypeHideAccessibiltyWarning = @"Au
kMPSettingsKeyFileChangeStrategy: @(MPFileChangeStrategyAsk), // Ask what to do on a file change!
kMPSettingsKeyLockOnSleep: @YES,
kMPSettingskeyLockOnLogout: @NO,
+ kMPSettingskeyLockOnScreenSleep: @NO,
kMPSettingsKeyIdleLockTimeOut: @0, // 5 minutes
kMPSettingsKeyLegacyHideNotes: @NO,
kMPSettingsKeyLegacyHidePassword: @YES,