From 94ec1ccde30ce63a5aa39e2a7752209f4c1cc945 Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 18 Feb 2013 02:20:57 +0100 Subject: [PATCH] Added EntryViewController Fixed issues with firstResponder in MainWindowController --- MacPass.xcodeproj/project.pbxproj | 14 +- MacPass/EntryView.xib | 44 ++- MacPass/MPAppDelegate.m | 14 +- MacPass/MPDatabaseController.h | 15 +- MacPass/MPDatabaseController.m | 22 +- MacPass/MPEntryViewController.h | 13 + MacPass/MPEntryViewController.m | 21 ++ MacPass/MPMainWindowController.h | 11 +- MacPass/MPMainWindowController.m | 98 ++++-- MacPass/MPMainWindowDelegate.h | 13 - MacPass/MPMainWindowDelegate.m | 14 - MacPass/MPPasswordInputController.h | 5 +- MacPass/MPPasswordInputController.m | 21 +- MacPass/MPViewController.h | 1 + MacPass/MPViewController.m | 4 + MacPass/MPViewControllerProtocol.h | 16 - MacPass/PasswordInputView.xib | 476 ++++++++++++++-------------- 17 files changed, 448 insertions(+), 354 deletions(-) create mode 100644 MacPass/MPEntryViewController.h create mode 100644 MacPass/MPEntryViewController.m delete mode 100644 MacPass/MPMainWindowDelegate.h delete mode 100644 MacPass/MPMainWindowDelegate.m delete mode 100644 MacPass/MPViewControllerProtocol.h diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index ad5051fb..3e653311 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -63,7 +63,6 @@ 4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C77E37915B84A240093A587 /* MPAppDelegate.m */; }; 4C77E37D15B84A240093A587 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C77E37B15B84A240093A587 /* MainMenu.xib */; }; 4C83814215BF4677001AE468 /* MPMainWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C83814115BF4677001AE468 /* MPMainWindowController.m */; }; - 4C90D9B416CA4B18003081E7 /* MPMainWindowDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C90D9B316CA4B18003081E7 /* MPMainWindowDelegate.m */; }; 4CA0B2ED15BCADAC00654E32 /* SettingsWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */; }; 4CA0B2F015BCADC800654E32 /* GeneralSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CA0B2EF15BCADC800654E32 /* GeneralSettings.xib */; }; 4CA0B2F915BCAF6700654E32 /* MPGeneralSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */; }; @@ -83,6 +82,7 @@ 4CD78ABF16D155FF00768A1D /* 10_ContactTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78ABA16D155FF00768A1D /* 10_ContactTemplate.pdf */; }; 4CD78AC016D155FF00768A1D /* 11_CameraTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CD78ABB16D155FF00768A1D /* 11_CameraTemplate.pdf */; }; 4CD884B715BD47080042BBF8 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4CD884B615BD47080042BBF8 /* MainWindow.xib */; }; + 4CDF01A316D1B76700D0AC08 /* MPEntryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -102,7 +102,6 @@ 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 02_MessageBoxWarningTemplate.pdf; sourceTree = ""; }; 4C65FAE616D16DDB006E0577 /* MPPasswordInputController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasswordInputController.h; sourceTree = ""; }; 4C65FAE716D16DDB006E0577 /* MPPasswordInputController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasswordInputController.m; sourceTree = ""; }; - 4C65FAEB16D16FB5006E0577 /* MPViewControllerProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPViewControllerProtocol.h; sourceTree = ""; }; 4C669B3016760ED100DD0774 /* AesInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AesInputStream.h; sourceTree = ""; }; 4C669B3116760ED100DD0774 /* AesInputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AesInputStream.m; sourceTree = ""; }; 4C669B3216760ED100DD0774 /* AesOutputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AesOutputStream.h; sourceTree = ""; }; @@ -194,8 +193,6 @@ 4C77E37C15B84A240093A587 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; 4C83814015BF4677001AE468 /* MPMainWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMainWindowController.h; sourceTree = ""; }; 4C83814115BF4677001AE468 /* MPMainWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMainWindowController.m; sourceTree = ""; }; - 4C90D9B216CA4B18003081E7 /* MPMainWindowDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMainWindowDelegate.h; sourceTree = ""; }; - 4C90D9B316CA4B18003081E7 /* MPMainWindowDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMainWindowDelegate.m; sourceTree = ""; }; 4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsWindow.xib; sourceTree = ""; }; 4CA0B2EF15BCADC800654E32 /* GeneralSettings.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GeneralSettings.xib; sourceTree = ""; }; 4CA0B2F715BCAF6700654E32 /* MPGeneralSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPGeneralSettingsController.h; sourceTree = ""; }; @@ -227,6 +224,8 @@ 4CD78ABA16D155FF00768A1D /* 10_ContactTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 10_ContactTemplate.pdf; sourceTree = ""; }; 4CD78ABB16D155FF00768A1D /* 11_CameraTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 11_CameraTemplate.pdf; sourceTree = ""; }; 4CD884B615BD47080042BBF8 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; + 4CDF01A116D1B76700D0AC08 /* MPEntryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPEntryViewController.h; sourceTree = ""; }; + 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPEntryViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -273,8 +272,6 @@ 4C77E37915B84A240093A587 /* MPAppDelegate.m */, 4CC6258F15BA1C99002F5B11 /* MPOutlineViewDelegate.h */, 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */, - 4C90D9B216CA4B18003081E7 /* MPMainWindowDelegate.h */, - 4C90D9B316CA4B18003081E7 /* MPMainWindowDelegate.m */, ); name = Delegates; sourceTree = ""; @@ -487,6 +484,8 @@ 4C2E382516D1470200037A9D /* MPViewController.m */, 4C65FAE616D16DDB006E0577 /* MPPasswordInputController.h */, 4C65FAE716D16DDB006E0577 /* MPPasswordInputController.m */, + 4CDF01A116D1B76700D0AC08 /* MPEntryViewController.h */, + 4CDF01A216D1B76700D0AC08 /* MPEntryViewController.m */, ); name = Controller; sourceTree = ""; @@ -495,7 +494,6 @@ isa = PBXGroup; children = ( 4CA0B30D15BCB6FD00654E32 /* MPSettingsTabProtocoll.h */, - 4C65FAEB16D16FB5006E0577 /* MPViewControllerProtocol.h */, ); name = Protocolls; sourceTree = ""; @@ -690,11 +688,11 @@ 4C669BA016760ED100DD0774 /* Salsa20RandomStream.m in Sources */, 4C669BA116760ED100DD0774 /* Utils.m in Sources */, 4C669BA216760ED100DD0774 /* UUID.m in Sources */, - 4C90D9B416CA4B18003081E7 /* MPMainWindowDelegate.m in Sources */, 4C75CE3C16CB128700F61A4D /* MPDatabaseController.m in Sources */, 4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */, 4C2E382616D1470200037A9D /* MPViewController.m in Sources */, 4C65FAE916D16DDB006E0577 /* MPPasswordInputController.m in Sources */, + 4CDF01A316D1B76700D0AC08 /* MPEntryViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/EntryView.xib b/MacPass/EntryView.xib index aa0beb44..440ec5bb 100644 --- a/MacPass/EntryView.xib +++ b/MacPass/EntryView.xib @@ -34,7 +34,7 @@ - NSObject + MPEntryViewController FirstResponder @@ -68,7 +68,7 @@ {351, 544} - + _NS:13 YES NO @@ -232,6 +232,7 @@ {{1, 119}, {223, 15}} + _NS:60 NO 1 @@ -258,7 +259,7 @@ {353, 562} - + _NS:9 133682 @@ -274,6 +275,7 @@ {353, 563} + _NS:11 NSView @@ -287,6 +289,7 @@ {{13, 10}, {323, 539}} + _NS:9 @@ -297,7 +300,7 @@ {{10, 33}, {303, 493}} - + _NS:11 Tab @@ -335,6 +338,7 @@ {{354, 0}, {349, 563}} + _NS:13 NSView @@ -342,6 +346,7 @@ {703, 563} + _NS:9 YES 2 @@ -350,12 +355,21 @@ {703, 563} - + NSView - + + + + view + + + + 42 + + @@ -825,10 +839,26 @@ - 41 + 42 + + MPEntryViewController + MPViewController + + IBProjectSource + ./Classes/MPEntryViewController.h + + + + MPViewController + NSViewController + + IBProjectSource + ./Classes/MPViewController.h + + NSLayoutConstraint NSObject diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index bb2dd802..7e750a16 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -44,19 +44,7 @@ } - (void)openDocument:(id)sender { - NSOpenPanel *openPanel = [NSOpenPanel openPanel]; - [openPanel setCanChooseDirectories:NO]; - [openPanel setCanChooseFiles:YES]; - [openPanel setCanCreateDirectories:NO]; - [openPanel setAllowsMultipleSelection:NO]; - [openPanel beginSheetModalForWindow:[self.mainWindowController window] completionHandler:^(NSInteger result){ - if(result == NSFileHandlingPanelOKButton) { - NSURL *file = [[openPanel URLs] lastObject]; - if(file) { - [self.mainWindowController presentPasswordInput:(NSURL *)file]; - } - } - }]; + [self.mainWindowController openDocument]; } diff --git a/MacPass/MPDatabaseController.h b/MacPass/MPDatabaseController.h index bce3b72e..ff5dc1f5 100644 --- a/MacPass/MPDatabaseController.h +++ b/MacPass/MPDatabaseController.h @@ -8,17 +8,28 @@ #import -@class MPDatabaseDocument; +/* + Notification is posted, when a database is loaded + The userInfo dictionary contains the following keys + MPDatabaseControllerDatabaseKey + */ +APPKIT_EXTERN NSString *const MPDatabaseControllerDidLoadDatabaseNotification; +APPKIT_EXTERN NSString *const MPDatabaseControllerDidCloseDatabaseNotification; +/* + Database loaded or closed + */ +APPKIT_EXTERN NSString *const MPDatabaseControllerDatabaseKey; typedef enum{ MPDatabaseVersion1, MPDatabaseVersion2 } MPDatabaseVersion; +@class MPDatabaseDocument; @interface MPDatabaseController : NSObject -@property (retain, readonly) MPDatabaseDocument *database; +@property (retain, readonly, nonatomic) MPDatabaseDocument *database; + (MPDatabaseController *)defaultController; diff --git a/MacPass/MPDatabaseController.m b/MacPass/MPDatabaseController.m index 528e62ce..e0943743 100644 --- a/MacPass/MPDatabaseController.m +++ b/MacPass/MPDatabaseController.m @@ -9,6 +9,10 @@ #import "MPDatabaseController.h" #import "MPDatabaseDocument.h" +NSString *const MPDatabaseControllerDidLoadDatabaseNotification = @"MPDatabaseControllerDidLoadDatabaseNotification"; +NSString *const MPDatabaseControllerDidCloseDatabaseNotification = @"MPDatabaseControllerDidCloseDatabaseNotification"; +NSString *const MPDatabaseControllerDatabaseKey = @"MPDatabaseControllerDatabaseKey"; + @interface MPDatabaseController () @property (retain) MPDatabaseDocument *database; @@ -37,7 +41,6 @@ } - (MPDatabaseDocument *)createDatabase:(MPDatabaseVersion)version password:(NSString *)password keyfile:(NSURL *)key { - return self.database; } @@ -46,4 +49,21 @@ return self.database; } +- (void)setDatabase:(MPDatabaseDocument *)database { + if(_database != database) { + if(_database) { + NSDictionary *userInfo = @{ MPDatabaseControllerDatabaseKey: _database }; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDatabaseControllerDidCloseDatabaseNotification + object:self + userInfo:userInfo]; + } + [_database release]; + _database = [database retain]; + NSDictionary *userInfo = @{ MPDatabaseControllerDatabaseKey: _database }; + [[NSNotificationCenter defaultCenter] postNotificationName:MPDatabaseControllerDidLoadDatabaseNotification + object:self + userInfo:userInfo]; + } +} + @end diff --git a/MacPass/MPEntryViewController.h b/MacPass/MPEntryViewController.h new file mode 100644 index 00000000..243c3ff1 --- /dev/null +++ b/MacPass/MPEntryViewController.h @@ -0,0 +1,13 @@ +// +// MPEntryViewController.h +// MacPass +// +// Created by michael starke on 18.02.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPViewController.h" + +@interface MPEntryViewController : MPViewController + +@end diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m new file mode 100644 index 00000000..0a0f2298 --- /dev/null +++ b/MacPass/MPEntryViewController.m @@ -0,0 +1,21 @@ +// +// MPEntryViewController.m +// MacPass +// +// Created by michael starke on 18.02.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPEntryViewController.h" + +@interface MPEntryViewController () + +@end + +@implementation MPEntryViewController + +- (id)init { + return [[MPEntryViewController alloc] initWithNibName:@"EntryView" bundle:nil]; +} + +@end diff --git a/MacPass/MPMainWindowController.h b/MacPass/MPMainWindowController.h index 903eee56..5e37f728 100644 --- a/MacPass/MPMainWindowController.h +++ b/MacPass/MPMainWindowController.h @@ -12,11 +12,16 @@ APPKIT_EXTERN NSString *const MPMainWindowControllerPasswordKey; APPKIT_EXTERN NSString *const MPMainWindowControllerKeyfileKey; @class MPDatabaseDocument; +@class MPViewController; @interface MPMainWindowController : NSWindowController -@property (readonly, retain) MPDatabaseDocument *database; - -- (void)presentPasswordInput:(NSURL *)file; +- (void)openDocument; +- (void)showEntries; +/* + Sets the content View controller + @param viewController - use nil to reset to welcome screen + */ +- (void)setContentViewController:(MPViewController *)viewController; @end diff --git a/MacPass/MPMainWindowController.m b/MacPass/MPMainWindowController.m index ec4ef0f4..06946753 100644 --- a/MacPass/MPMainWindowController.m +++ b/MacPass/MPMainWindowController.m @@ -9,9 +9,10 @@ #import "MPMainWindowController.h" #import "MPOutlineDataSource.h" #import "MPOutlineViewDelegate.h" -#import "MPMainWindowDelegate.h" #import "MPDatabaseController.h" #import "MPDatabaseDocument.h" +#import "MPPasswordInputController.h" +#import "MPEntryViewController.h" NSString *const MPMainWindowControllerPasswordKey = @"MPMainWindowControllerPasswordKey"; NSString *const MPMainWindowControllerKeyfileKey = @"MPMainWindowControllerKeyfileKey"; @@ -27,12 +28,14 @@ NSString *const kOutlineViewIdentifier = @"OutlineView"; @property (assign) IBOutlet NSView *contentView; @property (retain) IBOutlet NSView *welcomeView; -@property (retain) NSURL *openFile; @property (retain) MPOutlineDataSource *datasource; @property (retain) MPOutlineViewDelegate *outlineDelegate; -@property (retain) MPMainWindowDelegate *windowDelegate; + +@property (retain) MPPasswordInputController *passwordInputController; +@property (retain) MPEntryViewController *entryViewController; - (void)updateData; +- (void)didOpenDocument:(NSNotification *)notification; @end @@ -42,35 +45,69 @@ NSString *const kOutlineViewIdentifier = @"OutlineView"; self = [super initWithWindowNibName:@"MainWindow" owner:self]; if( self ) { NSArray *topLevelObjects; - self.windowDelegate = [[[MPMainWindowDelegate alloc] init] autorelease]; self.outlineDelegate = [[[MPOutlineViewDelegate alloc] init] autorelease]; self.datasource = [[[MPOutlineDataSource alloc] init] autorelease]; [[NSBundle mainBundle] loadNibNamed:@"WelcomeView" owner:self topLevelObjects:&topLevelObjects]; [self.welcomeView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(didOpenDocument:) + name:MPDatabaseControllerDidLoadDatabaseNotification + object:nil]; } return self; } +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; +} + - (void)windowDidLoad { [super windowDidLoad]; - /* - Setup Connections for Outline View - */ - [self.window setDelegate:self.windowDelegate]; [[self.outlineView outlineTableColumn] setIdentifier:kColumnIdentifier]; [self.outlineView setDelegate:self.outlineDelegate]; [self.outlineView setDataSource:self.datasource]; + [self setContentViewController:nil]; +} + +- (void)setContentViewController:(MPViewController *)viewController { + NSView *newContentView = self.welcomeView; + if(viewController && viewController.view) { + newContentView = viewController.view; + } + /* + Set correct size and resizing for view + */ + [newContentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + NSSize frameSize = [self.contentView frame].size; + [newContentView setFrame:NSMakeRect(0,0, frameSize.width, frameSize.height)]; /* - Add Welcome Screen + Add or replace subview */ - NSSize frameSize = [self.contentView frame].size; - [self.contentView setFrame:NSMakeRect(0,0, frameSize.width, frameSize.height)]; - [self.contentView addSubview:self.welcomeView]; - + NSArray *subViews = [self.contentView subviews]; + BOOL hasSubViews = ([subViews count] > 0); + if(hasSubViews) { + NSView *subView = subViews[0]; + assert(subView); + [self.contentView replaceSubview:subView with:newContentView]; + } + else { + [self.contentView addSubview:newContentView]; + } + /* + Set focus AFTER having added the view + */ + [self.window makeFirstResponder:[viewController reconmendedFirstResponder]]; +} + +- (void)didOpenDocument:(NSNotification *)notification { + [self updateData]; + [self showEntries]; } - (void)updateData { @@ -79,16 +116,31 @@ NSString *const kOutlineViewIdentifier = @"OutlineView"; [self.outlineView expandItem:dbContoller.database.root expandChildren:NO]; } -- (void)presentPasswordInput:(NSURL *)file { - NSArray *topLevelObjects; - self.openFile = file; - [[NSBundle mainBundle] loadNibNamed:@"PasswordView" owner:self topLevelObjects:&topLevelObjects]; - [self.passwordView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - NSSize frameSize = [self.contentView frame].size; - [self.passwordView setFrame:NSMakeRect(0,0, frameSize.width, frameSize.height)]; - [self.contentView setAutoresizesSubviews:YES]; - [self.contentView replaceSubview:self.welcomeView with:self.passwordView]; - [self.window makeFirstResponder:self.passwordView]; +- (void)openDocument { + + if(!self.passwordInputController) { + self.passwordInputController = [[[MPPasswordInputController alloc] init] autorelease]; + } + + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + [openPanel setCanChooseDirectories:NO]; + [openPanel setCanChooseFiles:YES]; + [openPanel setCanCreateDirectories:NO]; + [openPanel setAllowsMultipleSelection:NO]; + [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result){ + if(result == NSFileHandlingPanelOKButton) { + NSURL *file = [[openPanel URLs] lastObject]; + self.passwordInputController.fileURL = file; + [self setContentViewController:self.passwordInputController]; + } + }]; +} + +- (void)showEntries { + if(!self.entryViewController) { + self.entryViewController = [[[MPEntryViewController alloc] init] autorelease]; + } + [self setContentViewController:self.entryViewController]; } @end diff --git a/MacPass/MPMainWindowDelegate.h b/MacPass/MPMainWindowDelegate.h deleted file mode 100644 index 554f61ed..00000000 --- a/MacPass/MPMainWindowDelegate.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// MPMainWindowDelegate.h -// MacPass -// -// Created by michael starke on 12.02.13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import - -@interface MPMainWindowDelegate : NSObject - -@end diff --git a/MacPass/MPMainWindowDelegate.m b/MacPass/MPMainWindowDelegate.m deleted file mode 100644 index 5e82e4c5..00000000 --- a/MacPass/MPMainWindowDelegate.m +++ /dev/null @@ -1,14 +0,0 @@ -// -// MPMainWindowDelegate.m -// MacPass -// -// Created by michael starke on 12.02.13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import "MPMainWindowDelegate.h" - -@implementation MPMainWindowDelegate - - -@end diff --git a/MacPass/MPPasswordInputController.h b/MacPass/MPPasswordInputController.h index 8b39bffc..9e15d17c 100644 --- a/MacPass/MPPasswordInputController.h +++ b/MacPass/MPPasswordInputController.h @@ -7,8 +7,9 @@ // #import "MPViewController.h" -#import "MPViewControllerProtocol.h" -@interface MPPasswordInputController : MPViewController +@interface MPPasswordInputController : MPViewController + +@property (retain) NSURL *fileURL; @end diff --git a/MacPass/MPPasswordInputController.m b/MacPass/MPPasswordInputController.m index d0545148..34c31276 100644 --- a/MacPass/MPPasswordInputController.m +++ b/MacPass/MPPasswordInputController.m @@ -15,27 +15,36 @@ - (IBAction)selectKeyFile:(id)sender; - (IBAction)open:(id)sender; +- (void)showError; @end @implementation MPPasswordInputController - (id)init { - return [[MPPasswordInputController alloc] initWithNibName:@"PasswordView" bundle:nil]; + return [[MPPasswordInputController alloc] initWithNibName:@"PasswordInputView" bundle:nil]; } -- (NSResponder *)reconmendetFirstResponder { - return nil; +- (NSResponder *)reconmendedFirstResponder { + return self.passwordTextField; } - - (IBAction)selectKeyFile:(id)sender { } - (IBAction)open:(id)sender { - NSString *password = [self.passwordTextField stringValue]; - [[MPDatabaseController defaultController] openDatabase:self.openFile password:password keyfile:nil]; + NSString *password = [self.passwordTextField stringValue]; + [self.passwordTextField setStringValue:@""]; + MPDatabaseDocument *document = [[MPDatabaseController defaultController] openDatabase:self.fileURL + password:password + keyfile:nil]; + if(!document) { + [self showError]; } } + +- (void)showError { + NSLog(@"Something went wrong"); +} @end diff --git a/MacPass/MPViewController.h b/MacPass/MPViewController.h index ae87f663..5672e948 100644 --- a/MacPass/MPViewController.h +++ b/MacPass/MPViewController.h @@ -11,5 +11,6 @@ @interface MPViewController : NSViewController - (void)didLoadView; +- (NSResponder *)reconmendedFirstResponder; @end diff --git a/MacPass/MPViewController.m b/MacPass/MPViewController.m index e4dfdb66..20d2259b 100644 --- a/MacPass/MPViewController.m +++ b/MacPass/MPViewController.m @@ -19,4 +19,8 @@ // override } +- (NSResponder *)reconmendedFirstResponder { + return nil; +} + @end diff --git a/MacPass/MPViewControllerProtocol.h b/MacPass/MPViewControllerProtocol.h deleted file mode 100644 index 3555458b..00000000 --- a/MacPass/MPViewControllerProtocol.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// MPViewControllerProtocol.h -// MacPass -// -// Created by Michael Starke on 17.02.13. -// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. -// - -#import - -@protocol MPViewControllerProtocol - -@required -- (NSResponder *)reconmendetFirstResponder; - -@end diff --git a/MacPass/PasswordInputView.xib b/MacPass/PasswordInputView.xib index adea6105..db2d995c 100644 --- a/MacPass/PasswordInputView.xib +++ b/MacPass/PasswordInputView.xib @@ -42,10 +42,54 @@ 268 + + + 268 + {{128, 163}, {191, 22}} + + + _NS:9 + YES + + 342884416 + 272630848 + + + LucidaGrande + 13 + 1044 + + _NS:9 + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + NSAllRomanInputSourcesLocaleIdentifier + + + NO + 268 - {{186, 69}, {97, 32}} + {{228, 127}, {97, 32}} @@ -55,11 +99,7 @@ 67108864 134217728 Browse... - - LucidaGrande - 13 - 1044 - + _NS:9 -2038284288 @@ -74,10 +114,10 @@ 268 - {{17, 108}, {64, 17}} + {{59, 166}, {64, 17}} - + _NS:1535 YES @@ -100,10 +140,7 @@ 6 System controlTextColor - - 3 - MAA - + NO @@ -111,7 +148,7 @@ 268 - {{35, 78}, {46, 17}} + {{77, 136}, {46, 17}} @@ -129,48 +166,10 @@ NO - - - 268 - {{86, 105}, {191, 22}} - - - - _NS:9 - YES - - 342884416 - 272630848 - - - _NS:9 - - YES - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 6 - System - textColor - - - - NSAllRomanInputSourcesLocaleIdentifier - - - NO - 268 - {{209, 13}, {74, 32}} + {{251, 71}, {74, 32}} _NS:9 @@ -192,7 +191,7 @@ NO - {363, 232} + {447, 347} @@ -209,14 +208,6 @@ 143 - - - passwordTextField - - - - 151 - selectKeyFile: @@ -233,6 +224,22 @@ 154 + + + passwordTextField + + + + 196 + + + + nextKeyView + + + + 197 + @@ -316,7 +323,7 @@ 3 0 - + 4 1 @@ -328,11 +335,59 @@ 40 3 + + + 5 + 0 + + 6 + 1 + + 8 + + 1000 + + 9 + 40 + 3 + + + + 9 + 0 + + 9 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + - + 6 0 - + 6 1 @@ -344,6 +399,22 @@ 24 2 + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + 10 @@ -360,92 +431,12 @@ 24 2 - - - 6 - 0 - - 6 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 10 - 0 - - 10 - 1 - - 0.0 - - 1000 - - 9 - 40 - 2 - - - - 6 - 1 - - 6 - 1 - - 20 - - 1000 - - 9 - 40 - 3 - - - - 9 - 0 - - 9 - 1 - - 0.0 - - 1000 - - 9 - 40 - 2 - - - - 5 - 0 - - 6 - 1 - - 8 - - 1000 - - 9 - 40 - 3 - - + - 10 + 6 0 - - 10 + + 6 1 0.0 @@ -472,11 +463,11 @@ 40 3 - + @@ -493,35 +484,6 @@ - - 6 - - - - - - 7 - 0 - - 0 - 1 - - 191 - - 1000 - - 9 - 40 - 1 - - - - - - 7 - - - 17 @@ -566,11 +528,6 @@ - - 89 - - - 122 @@ -581,53 +538,82 @@ - - 131 - - - 132 - - 142 - - - 133 - 107 - + 177 + + + + + + 7 + 0 + + 0 + 1 + + 191 + + 1000 + + 9 + 40 + 1 + + - 45 - - + 178 + + - 123 - - - - - 134 + 181 - 119 + 182 + + + + + 184 + + + + + 187 + + + + + 188 - 112 + 193 + + + + + 194 + + + + + 195 @@ -639,14 +625,13 @@ com.apple.InterfaceBuilder.CocoaPlugin - - - - - - + + + + + @@ -656,72 +641,71 @@ 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 + 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 - 154 + 197 MPPasswordInputController MPViewController - - selectKeyFile: - id - - - selectKeyFile: - + + id + id + + + + open: + id + + selectKeyFile: id - - - NSButton - NSSecureTextField - - - openDocument - NSButton - - + + passwordTextField + NSSecureTextField + + + passwordTextField + passwordTextField NSSecureTextField - + IBProjectSource ./Classes/MPPasswordInputController.h