From 71d3889af4c19745e28948e95be0b1a86d1082d4 Mon Sep 17 00:00:00 2001 From: michael starke Date: Sun, 23 Jun 2013 23:18:19 +0200 Subject: [PATCH] Added lock on idle --- MacPass/Base.lproj/InspectorView.xib | 438 +++++++++++++++------------ MacPass/KdbEntry+Undo.m | 5 + MacPass/MPInspectorViewController.m | 23 +- MacPass/MPLockDaemon.m | 24 +- MacPass/MPOutlineDataSource.m | 9 +- MacPass/MacPass-Info.plist | 2 +- 6 files changed, 303 insertions(+), 198 deletions(-) diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 646ca00f..2ae6688e 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -66,7 +66,7 @@ NeXT Encapsulated PostScript v1.2 pasteboard type NeXT TIFF v4.0 pasteboard type - {{20, 514}, {48, 48}} + {{20, 461}, {48, 48}} @@ -91,7 +91,7 @@ 268 - {{73, 530}, {209, 17}} + {{73, 477}, {209, 17}} @@ -144,7 +144,7 @@ 268 - {{73, 482}, {154, 25}} + {{73, 429}, {154, 25}} @@ -175,7 +175,7 @@ 12 - {{0, 31}, {299, 452}} + {{0, 31}, {299, 399}} @@ -190,7 +190,7 @@ 268 - {{17, 418}, {35, 14}} + {{17, 365}, {35, 14}} _NS:1535 @@ -222,7 +222,7 @@ 268 - {{20, 388}, {259, 22}} + {{20, 335}, {259, 22}} _NS:9 @@ -256,7 +256,7 @@ 268 - {{17, 366}, {58, 14}} + {{17, 313}, {58, 14}} _NS:1535 @@ -276,7 +276,7 @@ 268 - {{20, 336}, {259, 22}} + {{20, 283}, {259, 22}} _NS:9 @@ -297,7 +297,7 @@ 268 - {{20, 285}, {259, 22}} + {{20, 231}, {259, 22}} _NS:9 @@ -318,7 +318,7 @@ 268 - {{17, 315}, {25, 13}} + {{17, 261}, {25, 14}} _NS:1535 @@ -338,7 +338,7 @@ 268 - {{17, 263}, {58, 14}} + {{17, 209}, {58, 14}} _NS:1535 @@ -358,7 +358,7 @@ 268 - {{20, 233}, {259, 22}} + {{20, 179}, {259, 22}} _NS:9 @@ -379,7 +379,7 @@ 268 - {{20, 206}, {259, 19}} + {{20, 152}, {259, 19}} _NS:9 @@ -408,7 +408,7 @@ 268 - {{17, 185}, {42, 14}} + {{17, 131}, {42, 14}} _NS:1535 @@ -428,9 +428,9 @@ 268 - {{20, 159}, {259, 18}} + {{20, 105}, {259, 18}} - + _NS:9 YES @@ -446,8 +446,28 @@ NO + + + 268 + {{17, 20}, {46, 14}} + + + _NS:1535 + YES + + 68157504 + 272761856 + Created + + _NS:1535 + + + + + NO + - {299, 452} + {299, 399} _NS:11 @@ -590,7 +610,7 @@ 0.99487179487179489 - {{20, 282}, {259, 125}} + {{20, 229}, {259, 125}} @@ -634,7 +654,7 @@ WebURLsWithTitlesPboardType public.url - {257, 201} + {257, 148} @@ -697,7 +717,7 @@ - {{1, 1}, {257, 201}} + {{1, 1}, {257, 148}} @@ -728,7 +748,7 @@ 256 - {{242, 1}, {16, 201}} + {{242, 1}, {16, 148}} @@ -755,7 +775,7 @@ 0.94565218687057495 - {{20, 20}, {259, 203}} + {{20, 20}, {259, 150}} @@ -771,7 +791,7 @@ 268 - {{17, 415}, {79, 17}} + {{17, 362}, {79, 17}} @@ -792,7 +812,7 @@ 268 - {{17, 231}, {35, 17}} + {{17, 178}, {35, 17}} @@ -813,7 +833,7 @@ 268 - {{217, 255}, {62, 19}} + {{217, 202}, {62, 19}} @@ -838,7 +858,7 @@ 268 - {{145, 255}, {64, 19}} + {{145, 202}, {64, 19}} @@ -861,7 +881,7 @@ NO - {299, 452} + {299, 399} @@ -882,7 +902,7 @@ - {299, 582} + {299, 529} @@ -1011,6 +1031,14 @@ 1556 + + + infoTextField + + + + 1888 + imageView @@ -1167,6 +1195,38 @@ 29 3 + + + 9 + 0 + + 9 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + 3 @@ -1231,38 +1291,6 @@ 29 3 - - - 9 - 0 - - 9 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 3 - 0 - - 4 - 1 - - 8 - - 1000 - - 6 - 24 - 3 - 6 @@ -1798,7 +1826,55 @@ 1397 - + + + 3 + 1 + + 4 + 1 + + 8 + + 1000 + + 9 + 40 + 3 + + + + 4 + 0 + + 4 + 1 + + 20 + + 1000 + + 9 + 40 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + 3 0 @@ -1810,8 +1886,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -1846,23 +1922,7 @@ 29 3 - - - 4 - 1 - - 4 - 1 - - 20 - - 1000 - - 9 - 40 - 3 - - + 3 0 @@ -1874,8 +1934,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -1894,7 +1954,7 @@ 29 3 - + 3 0 @@ -1906,8 +1966,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -1942,7 +2002,7 @@ 29 3 - + 3 0 @@ -1954,8 +2014,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -1990,7 +2050,7 @@ 29 3 - + 3 0 @@ -2002,8 +2062,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -2022,7 +2082,7 @@ 29 3 - + 3 0 @@ -2034,8 +2094,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -2082,8 +2142,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -2114,8 +2174,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -2162,8 +2222,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -2210,8 +2270,8 @@ 1000 - 6 - 24 + 9 + 40 3 @@ -2258,8 +2318,8 @@ 1000 - 8 - 29 + 9 + 40 3 @@ -2281,6 +2341,7 @@ + @@ -2288,7 +2349,7 @@ - + @@ -2377,22 +2438,6 @@ - - - 8 - 0 - - 0 - 1 - - 13 - - 1000 - - 3 - 9 - 1 - @@ -2896,11 +2941,6 @@ - - 1626 - - - 1665 @@ -2996,11 +3036,6 @@ - - 1824 - - - 1849 @@ -3026,36 +3061,6 @@ - - 1856 - - - - - 1858 - - - - - 1859 - - - - - 1860 - - - - - 1861 - - - - - 1862 - - - 1869 @@ -3097,7 +3102,65 @@ - 1883 + 1898 + + + + + 1900 + + + + + 1901 + + + + + 1903 + + + + + 1904 + + + + + 1905 + + + + + 1884 + + + + + + + + 1885 + + + + + 1910 + + + + + 1918 + + + + + 1919 + + + + + 1917 @@ -3123,9 +3186,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - - - com.apple.InterfaceBuilder.CocoaPlugin @@ -3174,7 +3234,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - + @@ -3190,21 +3250,23 @@ - + - + - + - + - - + - + + + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3294,7 +3356,6 @@ com.apple.InterfaceBuilder.CocoaPlugin HNHLevelIndicatorCell com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3315,18 +3376,11 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -3334,19 +3388,31 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + - - + + @@ -3381,7 +3447,7 @@ - 1883 + 1920 diff --git a/MacPass/KdbEntry+Undo.m b/MacPass/KdbEntry+Undo.m index 07f04a6a..0be9b928 100644 --- a/MacPass/KdbEntry+Undo.m +++ b/MacPass/KdbEntry+Undo.m @@ -45,30 +45,35 @@ NSString *const MPEntryNotesUndoableKey = @"notesUndoable"; - (void)setTitleUndoable:(NSString *)title { [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_TITLE", "Undo set title")]; + [self setLastModificationTime:[NSDate date]]; [self setTitle:title]; } - (void)setUsernameUndoable:(NSString *)username { [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_USERNAME", "Undo set username")]; + [self setLastModificationTime:[NSDate date]]; [self setUsername:username]; } - (void)setPasswordUndoable:(NSString *)password { [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_PASSWORT", "Undo set password")]; + [self setLastModificationTime:[NSDate date]]; [self setPassword:password]; } - (void)setUrlUndoable:(NSString *)url { [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_URL", "Undo set URL")]; + [self setLastModificationTime:[NSDate date]]; [self setUrl:url]; } - (void)setNotesUndoable:(NSString *)notes { [[KdbEntry undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes]; [[KdbEntry undoManager] setActionName:NSLocalizedString(@"UNDO_SET_NOTES", "Undo set notes")]; + [self setLastModificationTime:[NSDate date]]; [self setNotes:notes]; } diff --git a/MacPass/MPInspectorViewController.m b/MacPass/MPInspectorViewController.m index d3246750..75b64142 100644 --- a/MacPass/MPInspectorViewController.m +++ b/MacPass/MPInspectorViewController.m @@ -45,7 +45,7 @@ enum { @property (nonatomic, assign) NSDate *modificationDate; @property (nonatomic, assign) NSDate *creationDate; -@property (assign) NSUInteger activeTab; +@property (nonatomic, assign) NSUInteger activeTab; @property (assign) IBOutlet NSTabView *tabView; @property (retain) NSArrayController *attachmentsController; @@ -102,7 +102,7 @@ enum { - (void)_updateInfoString { NSDate *modificationDate; - NSDate *creationDate; + NSDate *creationDate; if(self.selectedEntry) { modificationDate = self.selectedEntry.lastModificationTime; creationDate = self.selectedEntry.creationTime; @@ -111,7 +111,14 @@ enum { modificationDate = self.selectedGroup.lastModificationTime; creationDate = self.selectedGroup.creationTime; } - [self.infoTextField setStringValue:[NSString stringWithFormat:@"created: %@ modified: %@", creationDate, modificationDate]]; + NSString *modificationString = [NSDateFormatter localizedStringFromDate:modificationDate + dateStyle:NSDateFormatterShortStyle + timeStyle:NSDateFormatterShortStyle]; + NSString *creationString = [NSDateFormatter localizedStringFromDate:modificationDate + dateStyle:NSDateFormatterShortStyle + timeStyle:NSDateFormatterShortStyle]; + + [self.infoTextField setStringValue:[NSString stringWithFormat:@"created: %@ modified: %@", creationString, modificationString]]; } - (void)setModificationDate:(NSDate *)modificationDate { @@ -190,9 +197,8 @@ enum { [self.usernameTextField setStringValue:@""]; [self.URLTextField setStringValue:@""]; - // Reste toggle - [self.infoTabControl setSelected:YES forSegment:MPGeneralTab]; - [self.infoTabControl setSelected:NO forSegment:MPAdvancedTab]; + // Reste toggle. Do not call setter on control or the bindings wont update + self.activeTab = MPGeneralTab; [self _setInputEnabled:YES]; } @@ -264,6 +270,7 @@ enum { /* We do not enable the button all the time, but it's wokring find this way */ [self.generatePasswordButton setEnabled:YES]; id controller = _activePopover.contentViewController; + /* Check for password wizzard */ if([controller respondsToSelector:@selector(generatedPassword)]) { NSString *password = [controller generatedPassword]; /* We should only use the password if there is actally one */ @@ -271,6 +278,8 @@ enum { [self.selectedEntry setPasswordUndoable:[controller generatedPassword]]; } } + /* TODO: Check for Icon wizzard */ + [_activePopover release]; _activePopover = nil; } @@ -294,6 +303,8 @@ enum { [self _updateContent]; } + +#pragma mark NSTableViewDelegate - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { NSTableCellView *view = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:tableView]; if([self.selectedEntry isKindOfClass:[Kdb4Entry class]]) { diff --git a/MacPass/MPLockDaemon.m b/MacPass/MPLockDaemon.m index fe4d9029..e9de529c 100644 --- a/MacPass/MPLockDaemon.m +++ b/MacPass/MPLockDaemon.m @@ -13,7 +13,7 @@ NSString *const MPShouldLockDatabaseNotification = @"com.hicknhack.macpass.MPShouldLockDatabaseNotification"; @interface MPLockDaemon () { - NSTimer *idleTimer; + NSTimer *idleCheckTimer; } @property (nonatomic,assign) BOOL lockOnSleep; @@ -46,7 +46,13 @@ NSString *const MPShouldLockDatabaseNotification = @"com.hicknhack.macpass.MPSho - (void)dealloc { + /* Notifications */ [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; + + /* Timer */ + [idleCheckTimer invalidate]; + [idleCheckTimer release]; + [super dealloc]; } @@ -67,10 +73,15 @@ NSString *const MPShouldLockDatabaseNotification = @"com.hicknhack.macpass.MPSho if(_idleLockTime != idleLockTime) { _idleLockTime = idleLockTime; if(_idleLockTime == 0) { - // disable + [idleCheckTimer invalidate]; + [idleCheckTimer release]; + idleCheckTimer = nil; } else { - // update timer + [idleCheckTimer invalidate]; + [idleCheckTimer release]; + idleCheckTimer = [[NSTimer timerWithTimeInterval:15 target:self selector:@selector(_checkIdleTime:) userInfo:nil repeats:YES] retain]; + [[NSRunLoop mainRunLoop] addTimer:idleCheckTimer forMode:NSDefaultRunLoopMode]; } } } @@ -79,4 +90,11 @@ NSString *const MPShouldLockDatabaseNotification = @"com.hicknhack.macpass.MPSho [[NSApp delegate] lockAllDocuments]; } +- (void)_checkIdleTime:(NSTimer *)timer { + CFTimeInterval interval = CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateCombinedSessionState,kCGAnyInputEventType); + if(interval >= _idleLockTime) { + [[NSApp delegate] lockAllDocuments]; + } +} + @end diff --git a/MacPass/MPOutlineDataSource.m b/MacPass/MPOutlineDataSource.m index 7f6719b2..d4b1587f 100644 --- a/MacPass/MPOutlineDataSource.m +++ b/MacPass/MPOutlineDataSource.m @@ -32,9 +32,14 @@ - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id)info proposedItem:(id)item proposedChildIndex:(NSInteger)index { if(_draggedItem) { info.animatesToDestination = YES; + NSDragOperation oprationMask = NSDragOperationMove; + if([info draggingSourceOperationMask] == NSDragOperationCopy) { + oprationMask = NSDragOperationCopy; + } + KdbGroup *target = [item representedObject]; if( target == nil) { - return NSDragOperationNone; // Draggin over root + return oprationMask; // Draggin over root } BOOL validTarget = YES; if( _draggedItem.parent == target ) { @@ -42,7 +47,7 @@ validTarget &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem]; } if( validTarget ) { - return NSDragOperationMove; + return oprationMask; } } NSPasteboard *pasteBoard = [info draggingPasteboard]; diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 1e01031a..1a936f95 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -48,7 +48,7 @@ CFBundleSignature ???? CFBundleVersion - 950 + 990 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright