Remove DMSplitView as it's never used

Updated Readme to reflect new modules
Added CocoaHTTPServer submodule
Fixed SettingsWindow, works now with multiple tabs
Added ServerSettings tab
This commit is contained in:
michael starke
2013-06-17 01:29:29 +02:00
parent 32b45c0006
commit 236e7036bc
32 changed files with 918 additions and 203 deletions

View File

@@ -176,28 +176,28 @@
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
<nil key="NSMenuItem"/>
<object class="NSMenuItem" key="NSMenuItem" id="855032005">
<reference key="NSMenu" ref="437492746"/>
<string key="NSTitle">Never</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<int key="NSState">1</int>
<object class="NSCustomResource" key="NSOnImage" id="45262901">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage" id="738594033">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="934584997"/>
</object>
<bool key="NSMenuItemRespectAlignment">YES</bool>
<object class="NSMenu" key="NSMenu" id="437492746">
<string key="NSTitle">ClipboardClearInterval</string>
<array class="NSMutableArray" key="NSMenuItems">
<object class="NSMenuItem" id="855032005">
<reference key="NSMenu" ref="437492746"/>
<string key="NSTitle">Never</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<int key="NSState">1</int>
<object class="NSCustomResource" key="NSOnImage" id="45262901">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string>
</object>
<object class="NSCustomResource" key="NSMixedImage" id="738594033">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string>
</object>
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="934584997"/>
</object>
<reference ref="855032005"/>
<object class="NSMenuItem" id="303393620">
<reference key="NSMenu" ref="437492746"/>
<string key="NSTitle">10 Seconds</string>
@@ -294,23 +294,24 @@
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
<nil key="NSMenuItem"/>
<object class="NSMenuItem" key="NSMenuItem" id="158936574">
<reference key="NSMenu" ref="552398563"/>
<string key="NSTitle">1 Minute</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<int key="NSState">1</int>
<reference key="NSOnImage" ref="45262901"/>
<reference key="NSMixedImage" ref="738594033"/>
<string key="NSAction">_popUpItemAction:</string>
<int key="NSTag">60</int>
<reference key="NSTarget" ref="52406626"/>
</object>
<bool key="NSMenuItemRespectAlignment">YES</bool>
<object class="NSMenu" key="NSMenu" id="552398563">
<string key="NSTitle">LockTimes</string>
<array class="NSMutableArray" key="NSMenuItems">
<object class="NSMenuItem" id="158936574">
<reference key="NSMenu" ref="552398563"/>
<string key="NSTitle">1 Minute</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="45262901"/>
<reference key="NSMixedImage" ref="738594033"/>
<string key="NSAction">_popUpItemAction:</string>
<int key="NSTag">60</int>
<reference key="NSTarget" ref="52406626"/>
</object>
<reference ref="158936574"/>
<object class="NSMenuItem" id="492507667">
<reference key="NSMenu" ref="552398563"/>
<string key="NSTitle">5 Minutes</string>
@@ -636,6 +637,38 @@
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="250630005">
<reference key="firstItem" ref="1005"/>
<int key="firstAttribute">8</int>
<int key="relation">0</int>
<nil key="secondItem"/>
<int key="secondAttribute">0</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">230</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">9</int>
<float key="scoringTypeFloat">40</float>
<int key="contentType">1</int>
</object>
<object class="IBNSLayoutConstraint" id="1063893674">
<reference key="firstItem" ref="1005"/>
<int key="firstAttribute">7</int>
<int key="relation">0</int>
<nil key="secondItem"/>
<int key="secondAttribute">0</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">400</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">9</int>
<float key="scoringTypeFloat">40</float>
<int key="contentType">1</int>
</object>
<reference ref="60918609"/>
<reference ref="145041823"/>
<reference ref="297534459"/>
@@ -1239,13 +1272,25 @@
<reference key="object" ref="484547610"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">798</int>
<reference key="object" ref="1063893674"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">799</int>
<reference key="object" ref="250630005"/>
<reference key="parent" ref="1005"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<array class="NSMutableArray" key="1.IBNSViewMetadataConstraints">
<array key="1.IBNSViewMetadataConstraints">
<reference ref="1063893674"/>
<reference ref="250630005"/>
<reference ref="285907299"/>
<reference ref="799708645"/>
<reference ref="1065146703"/>
@@ -1343,26 +1388,20 @@
<string key="788.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="789.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="792.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="798.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="799.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">797</int>
<int key="maxID">799</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">MPAbstractSettingsViewController</string>
<string key="superclassName">MPViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPAbstractSettingsViewController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPGeneralSettingsController</string>
<string key="superclassName">MPAbstractSettingsViewController</string>
<string key="superclassName">NSViewController</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="clearPasteboardOnQuitCheckButton">NSButton</string>
<string key="clearPasteboardTimeoutPopup">NSPopUpButton</string>
@@ -1387,14 +1426,6 @@
<string key="minorKey">./Classes/MPGeneralSettingsController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPViewController</string>
<string key="superclassName">NSViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPViewController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>

View File

@@ -2519,7 +2519,6 @@
<reference ref="80019053"/>
</array>
<string key="814.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="833.CustomClassName">MPTableCellView</string>
<array class="NSMutableArray" key="833.IBNSViewMetadataConstraints">
<reference ref="553918146"/>
<reference ref="880978105"/>
@@ -2770,14 +2769,6 @@
<string key="minorKey">./Classes/MPPopupImageView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPTableCellView</string>
<string key="superclassName">NSTableCellView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPTableCellView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPViewController</string>
<string key="superclassName">NSViewController</string>

View File

@@ -1,14 +0,0 @@
//
// MPAbstractSettingsViewController.h
// MacPass
//
// Created by Michael Starke on 30.03.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPSettingsTab.h"
#import "MPViewController.h"
@interface MPAbstractSettingsViewController : MPViewController <MPSettingsTab>
@end

View File

@@ -1,17 +0,0 @@
//
// MPAbstractSettingsViewController.m
// MacPass
//
// Created by Michael Starke on 30.03.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPAbstractSettingsViewController.h"
@implementation MPAbstractSettingsViewController
+ (NSString *)identifier {
return @"NONAME";
}
@end

View File

@@ -12,8 +12,12 @@
#import "MPPasswordCreatorViewController.h"
#import "MPSettingsHelper.h"
#import "MPUppercaseStringValueTransformer.h"
#import "MPServerDaemon.h"
@interface MPAppDelegate ()
@interface MPAppDelegate () {
@private
MPServerDaemon *serverDaemon;
}
@property (retain, nonatomic) MPSettingsWindowController *settingsController;
@property (retain, nonatomic) MPPasswordCreatorViewController *passwordCreatorController;
@@ -33,9 +37,15 @@
return [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyOpenEmptyDatabaseOnLaunch];
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
serverDaemon = [[MPServerDaemon alloc] init];
}
- (void)dealloc {
[_settingsController release];
[_passwordCreatorController release];
[serverDaemon release];
[super dealloc];
}

View File

@@ -1,13 +1,13 @@
//
// MPTableCellView.h
// MPConnection.h
// MacPass
//
// Created by Michael Starke on 16.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "HTTPConnection.h"
@interface MPTableCellView : NSTableCellView
@interface MPConnection : HTTPConnection
@end

17
MacPass/MPConnection.m Normal file
View File

@@ -0,0 +1,17 @@
//
// MPConnection.m
// MacPass
//
// Created by Michael Starke on 16.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPConnection.h"
@implementation MPConnection
- (NSObject<HTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path {
return [super httpResponseForMethod:method URI:path];
}
@end

View File

@@ -219,7 +219,6 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
self.selectedEntry = [self.entryArrayController arrangedObjects][[self.entryTable selectedRow]];
}
[[NSNotificationCenter defaultCenter] postNotificationName:MPDidChangeSelectedEntryNotification object:self userInfo:nil];
}
#pragma mark Notifications

View File

@@ -7,9 +7,9 @@
//
#import <Cocoa/Cocoa.h>
#import "MPAbstractSettingsViewController.h"
#import "MPSettingsTab.h"
@interface MPGeneralSettingsController : MPAbstractSettingsViewController <MPSettingsTab>
@interface MPGeneralSettingsController : NSViewController <MPSettingsTab>
@property (assign) IBOutlet NSImageView *imageView;
@property (assign) IBOutlet NSButton *clearPasteboardOnQuitCheckButton;
@property (assign) IBOutlet NSPopUpButton *clearPasteboardTimeoutPopup;

View File

@@ -8,21 +8,22 @@
#import "MPGeneralSettingsController.h"
#import "MPSettingsHelper.h"
#import "MPIconHelper.h"
NSString *const MPGeneralSetingsIdentifier = @"GeneralSettingsTab";
@implementation MPGeneralSettingsController
+ (NSString *)identifier {
return MPGeneralSetingsIdentifier;
}
- (id)init {
return [self initWithNibName:@"GeneralSettings" bundle:[NSBundle mainBundle]];
}
- (NSString *)identifier {
return MPGeneralSetingsIdentifier;
}
- (NSImage *)image {
return [NSImage imageNamed:NSImageNamePreferencesGeneral];
return [MPIconHelper icon:MPIconWarning];
}
- (NSString *)label {

View File

@@ -277,9 +277,11 @@
NSTableCellView *tableCellView = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:tableView];
BinaryRef *binaryRef = [self.attachmentController arrangedObjects][row];
[tableCellView.textField bind:NSValueBinding toObject:binaryRef withKeyPath:@"key" options:nil];
[[tableCellView.textField cell] setBackgroundStyle:NSBackgroundStyleRaised];
[[tableCellView.imageView cell] setBackgroundStyle:NSBackgroundStyleLight];
return tableCellView;
}
- (void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row {
NSLog(@"didAddRowView");
}
@end

View File

@@ -67,7 +67,7 @@
[self _resetCharacters];
}
- (IBAction)_generatePassword:(id)sender {
- (IBAction)_generatePassword:(id)sender {
if(_useCustomString) {
if([[_customCharactersTextField stringValue] length] > 0) {
self.password = [[_customCharactersTextField stringValue] passwordWithLength:_passwordLength];

13
MacPass/MPServerDaemon.h Normal file
View File

@@ -0,0 +1,13 @@
//
// MPServerDaemon.h
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MPServerDaemon : NSObject
@end

69
MacPass/MPServerDaemon.m Normal file
View File

@@ -0,0 +1,69 @@
//
// MPServerDaemon.m
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPServerDaemon.h"
#import "MPSettingsHelper.h"
#import "HTTPServer.h"
@interface MPServerDaemon () {
@private
HTTPServer *server;
}
@property (nonatomic, assign) BOOL isEnabled;
@end
@implementation MPServerDaemon
- (id)init {
self = [super init];
if (self) {
NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController];
NSString *defaultsKeyPath = [NSString stringWithFormat:@"values.%@", kMPSettingsKeyEnableHttpServer];
[self bind:@"isEnabled" toObject:defaultsController withKeyPath:defaultsKeyPath options:nil];
}
return self;
}
- (void)dealloc
{
[server release];
[super dealloc];
}
- (void)setIsEnabled:(BOOL)enabled {
if(_isEnabled == enabled) {
return; // NO changes
}
_isEnabled = enabled;
if(enabled) {
if(!server) {
[self _setupServer];
}
NSError *error= nil;
if(![server start:&error]) {
[NSApp presentError:error];
}
}
else {
/* Do not let the resource linger around */
[server release];
server = nil;
}
}
- (void)_setupServer {
NSAssert(server == nil, @"Server should be nil");
server = [[HTTPServer alloc] init];
[server setInterface:@"localhost"];
NSInteger port = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyHttpPort];
[server setPort:port];
}
@end

View File

@@ -0,0 +1,16 @@
//
// MPServerSettingsController.h
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPViewController.h"
#import "MPSettingsTab.h"
@interface MPServerSettingsController : MPViewController <MPSettingsTab>
@property (assign) IBOutlet NSButton *enableServerCheckbutton;
@end

View File

@@ -0,0 +1,42 @@
//
// MPServerSettingsController.m
// MacPass
//
// Created by Michael Starke on 17.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPServerSettingsController.h"
#import "MPSettingsHelper.h"
#import "MPIconHelper.h"
@interface MPServerSettingsController ()
@end
@implementation MPServerSettingsController
- (NSString *)identifier {
return @"ServerSettings";
}
- (NSImage *)image {
return [MPIconHelper icon:MPIconServer];
}
- (NSString *)label {
return NSLocalizedString(@"SERVER_SETTINGS", "");
}
- (id)init {
self = [super initWithNibName:@"ServerSettings" bundle:nil];
return self;
}
- (void)didLoadView {
NSUserDefaultsController *defaultsController = [NSUserDefaultsController sharedUserDefaultsController];
NSString *serverKeyPath = [NSString stringWithFormat:@"values.%@", kMPSettingsKeyEnableHttpServer];
[self.enableServerCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:serverKeyPath options:nil];
}
@end

View File

@@ -12,6 +12,8 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyPasteboardClearTimeout;
APPKIT_EXTERN NSString *const kMPSettingsKeyClearPasteboardOnQuit;
APPKIT_EXTERN NSString *const kMPSettingsKeyPasswordEncoding;
APPKIT_EXTERN NSString *const kMPSettingsKeyOpenEmptyDatabaseOnLaunch;
APPKIT_EXTERN NSString *const kMPSettingsKeyHttpPort;
APPKIT_EXTERN NSString *const kMPSettingsKeyEnableHttpServer;
typedef NS_ENUM(NSUInteger, MPPasswordEncoding) {
MPPasswordEncodingUTF8,

View File

@@ -11,6 +11,8 @@
NSString *const kMPSettingsKeyPasteboardClearTimeout = @"ClipboardClearTimeout";
NSString *const kMPSettingsKeyClearPasteboardOnQuit = @"ClearClipboardOnQuit";
NSString *const kMPSettingsKeyOpenEmptyDatabaseOnLaunch = @"OpenEmptyDatabaseOnLaunch";
NSString *const kMPSettingsKeyHttpPort =@"HttpPort";
NSString *const kMPSettingsKeyEnableHttpServer = @"kMPSettingsKeyEnableHttpServer";
@implementation MPSettingsHelper
@@ -23,6 +25,8 @@ NSString *const kMPSettingsKeyOpenEmptyDatabaseOnLaunch = @"OpenEmptyDatabaseOnL
kMPSettingsKeyPasteboardClearTimeout: @10,
kMPSettingsKeyClearPasteboardOnQuit: @YES,
kMPSettingsKeyOpenEmptyDatabaseOnLaunch: @YES,
kMPSettingsKeyHttpPort: @19455,
kMPSettingsKeyEnableHttpServer: @NO
};
}

View File

@@ -15,7 +15,7 @@
@protocol MPSettingsTab <NSObject>
@required
+ (NSString *)identifier;
- (NSString *)identifier;
@optional
- (NSString *)label;

View File

@@ -8,6 +8,7 @@
#import "MPSettingsWindowController.h"
#import "MPGeneralSettingsController.h"
#import "MPServerSettingsController.h"
@interface MPSettingsWindowController ()
@@ -46,7 +47,7 @@
- (void)showSettings {
if([self.settingsController count] > 0) {
id<MPSettingsTab> tab = [self.settingsController allValues][0];
NSString *identifier = [[tab class] identifier];
NSString *identifier = [tab identifier];
[self showSettingsTabWithIdentifier:identifier];
}
}
@@ -60,13 +61,30 @@
NSLog(@"Warning. Unknow settingscontroller for identifier: %@. Did you miss to add the controller?", identifier);
return;
}
NSViewController *tabViewController = (NSViewController *)tab;
[self.toolbar setSelectedItemIdentifier:identifier];
NSRect newRect = [[self window] frameRectForContentRect:[tabViewController.view frame]];
newRect.origin = [[self window] frame].origin;
newRect.origin.y += [[self window] frame].size.height - newRect.size.height;
[[self window] setFrame:newRect display:YES animate:YES];
[[self window] setContentView:tabViewController.view];
if([tab respondsToSelector:@selector(label)]) {
[[self window] setTitle:[tab label]];
}
else {
[[self window] setTitle:[tab identifier]];
}
NSView *tabView = [(NSViewController *)tab view];
NSView *contentView = [[self window] contentView];
if( [[contentView subviews] count] == 1) {
[[contentView subviews][0] removeFromSuperview];
}
[contentView addSubview:tabView];
[contentView layout];
[contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[tabView]-0-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(tabView)]];
[contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[tabView]-0-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(tabView)]];
[contentView layoutSubtreeIfNeeded];
[[self window] makeKeyAndOrderFront:[self window]];
}
@@ -83,7 +101,7 @@
userInfo:nil];
@throw controllerException;
}
NSString *identifier = [[tabController class] identifier];
NSString *identifier = [tabController identifier];
if(nil != self.settingsController[identifier]) {
NSLog(@"Warning: Settingscontroller with identifer %@ already present!", identifier);
}
@@ -94,15 +112,19 @@
- (void)_setupDefaultSettingsTabs {
MPGeneralSettingsController *generalSettingsController = [[MPGeneralSettingsController alloc] init];
MPServerSettingsController *serverSettingsController = [[MPServerSettingsController alloc] init];
[self _addSettingsTab:generalSettingsController];
[self _addSettingsTab:serverSettingsController];
[generalSettingsController release];
for(id controller in _settingsController) {
[controller release];
}
}
- (void)_showSettingsTab:(id)sender {
if([sender respondsToSelector:@selector(identifier)]) {
NSString *identfier = [sender identifier];
if([sender respondsToSelector:@selector(itemIdentifier)]) {
NSString *identfier = [sender itemIdentifier];
[self showSettingsTabWithIdentifier:identfier];
}
}

View File

@@ -1,17 +0,0 @@
//
// MPTableCellView.m
// MacPass
//
// Created by Michael Starke on 16.06.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPTableCellView.h"
@implementation MPTableCellView
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle {
[super setBackgroundStyle:NSBackgroundStyleRaised];
}
@end

View File

@@ -48,7 +48,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>382</string>
<string>497</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>

View File

@@ -12,6 +12,7 @@
@implementation NSData (MPRandomBytes)
+ (NSData *)dataWithRandomBytes:(NSUInteger)length {
NSLog(@"requesting %ld bytes", length);
unsigned char *bytes = malloc(sizeof(unsigned char) * length);
SecRandomCopyBytes(kSecRandomDefault, length, bytes);
return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:YES];

View File

@@ -16,11 +16,6 @@ typedef NS_OPTIONS(NSUInteger, MPPasswordCharacterFlags) {
MPPasswordCharactersAll = MPPasswordCharactersUpperCase | MPPasswordCharactersLowerCase | MPPasswordCharactersNumbers | MPPasswordCharactersSymbols
};
/*
Generates a random integer in between (inkluding) minimum and maxium
*/
static NSUInteger randomInteger(NSUInteger minimum, NSUInteger maximum);
@interface NSString (MPPasswordCreation)
/*

View File

@@ -13,35 +13,18 @@ NSString *const kMPLowercaseLetterCharacters = @"abcdefghijklmnopqrstuvw";
NSString *const kMPNumberCharacters = @"1234567890";
NSString *const kMPSymbolCharacters = @"!$%&\\|/<>(){}[]=?*'+#-_.:,;";
static NSUInteger randomInteger(NSUInteger minimum, NSUInteger maximum) {
NSInteger delta = maximum - minimum;
if( delta == 0) {
return maximum;
}
if( delta < 0 ) {
minimum -= delta;
delta = -delta;
}
NSUInteger randomByteSize = floor(log2(delta));
NSData *randomData = [NSData dataWithRandomBytes:randomByteSize];
NSNumber *number = [NSNumber numberWithUnsignedChar:(unsigned char)[randomData bytes]];
NSUInteger randomNumber = [number integerValue];
return minimum + (randomNumber % delta);
}
static NSString *allowedCharactersString(MPPasswordCharacterFlags flags) {
NSMutableString *characterString = [NSMutableString stringWithCapacity:30];
if( 0 != (flags & MPPasswordCharactersLowerCase) ) {
if(flags & MPPasswordCharactersLowerCase) {
[characterString appendString:kMPLowercaseLetterCharacters];
}
if( 0 != (flags & MPPasswordCharactersUpperCase) ) {
if(flags & MPPasswordCharactersUpperCase) {
[characterString appendString:[kMPLowercaseLetterCharacters uppercaseString]];
}
if(0 != (flags & MPPasswordCharactersNumbers) ) {
if(flags & MPPasswordCharactersNumbers) {
[characterString appendString:kMPNumberCharacters];
}
if(0 != (flags & MPPasswordCharactersSymbols) ){
if(flags & MPPasswordCharactersSymbols){
[characterString appendString:kMPSymbolCharacters];
}
return characterString;
@@ -83,11 +66,10 @@ static NSString *allowedCharactersString(MPPasswordCharacterFlags flags) {
}
- (NSString *)randomCharacter {
NSUInteger randomIndex = randomInteger(0, [self length] - 1);
if(randomIndex >= [self length]) {
return nil;
}
return [self substringWithRange:NSMakeRange(randomIndex, 1)];
NSData *data = [NSData dataWithRandomBytes:sizeof(unsigned long)];
NSUInteger randomIndex;
[data getBytes:&randomIndex length:[data length]];
return [self substringWithRange:NSMakeRange(randomIndex % [self length], 1)];
}
@end

312
MacPass/ServerSettings.xib Normal file
View File

@@ -0,0 +1,312 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">12E55</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.39</string>
<string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">3084</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBNSLayoutConstraint</string>
<string>NSButton</string>
<string>NSButtonCell</string>
<string>NSCustomObject</string>
<string>NSCustomView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<object class="NSCustomObject" id="1001">
<string key="NSClassName">MPServerSettingsController</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomView" id="1005">
<reference key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="NSButton" id="95771987">
<reference key="NSNextResponder" ref="1005"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 18}, {189, 18}}</string>
<reference key="NSSuperview" ref="1005"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="538739429">
<int key="NSCellFlags">-2080374784</int>
<int key="NSCellFlags2">268435456</int>
<string key="NSContents">Enable KeePassHttp server</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="95771987"/>
<int key="NSButtonFlags">1211912448</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSSwitch</string>
</object>
<object class="NSButtonImageSource" key="NSAlternateImage">
<string key="NSImageName">NSSwitch</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">200</int>
<int key="NSPeriodicInterval">25</int>
</object>
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
</object>
</array>
<string key="NSFrameSize">{400, 54}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="95771987"/>
<string key="NSClassName">NSView</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">enableServerCheckbutton</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="95771987"/>
</object>
<int key="connectionID">17</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="1005"/>
</object>
<int key="connectionID">18</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="1005"/>
<array class="NSMutableArray" key="children">
<reference ref="95771987"/>
<object class="IBNSLayoutConstraint" id="575589126">
<reference key="firstItem" ref="95771987"/>
<int key="firstAttribute">5</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1005"/>
<int key="secondAttribute">5</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="867686541">
<reference key="firstItem" ref="95771987"/>
<int key="firstAttribute">3</int>
<int key="relation">0</int>
<reference key="secondItem" ref="1005"/>
<int key="secondAttribute">3</int>
<float key="multiplier">1</float>
<object class="IBNSLayoutSymbolicConstant" key="constant">
<double key="value">20</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">8</int>
<float key="scoringTypeFloat">29</float>
<int key="contentType">3</int>
</object>
<object class="IBNSLayoutConstraint" id="515116036">
<reference key="firstItem" ref="1005"/>
<int key="firstAttribute">8</int>
<int key="relation">0</int>
<nil key="secondItem"/>
<int key="secondAttribute">0</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">54</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">9</int>
<float key="scoringTypeFloat">40</float>
<int key="contentType">1</int>
</object>
<object class="IBNSLayoutConstraint" id="120297329">
<reference key="firstItem" ref="1005"/>
<int key="firstAttribute">7</int>
<int key="relation">0</int>
<nil key="secondItem"/>
<int key="secondAttribute">0</int>
<float key="multiplier">1</float>
<object class="IBLayoutConstant" key="constant">
<double key="value">400</double>
</object>
<float key="priority">1000</float>
<reference key="containingView" ref="1005"/>
<int key="scoringType">9</int>
<float key="scoringTypeFloat">40</float>
<int key="contentType">1</int>
</object>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="95771987"/>
<array class="NSMutableArray" key="children">
<reference ref="538739429"/>
</array>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="538739429"/>
<reference key="parent" ref="95771987"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="867686541"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">5</int>
<reference key="object" ref="575589126"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">19</int>
<reference key="object" ref="120297329"/>
<reference key="parent" ref="1005"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">20</int>
<reference key="object" ref="515116036"/>
<reference key="parent" ref="1005"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<array key="1.IBNSViewMetadataConstraints">
<reference ref="120297329"/>
<reference ref="515116036"/>
<reference ref="867686541"/>
<reference ref="575589126"/>
</array>
<boolean value="NO" key="1.IBNSViewMetadataLastInspectedTranslatesAutoresizingMaskIntoConstraints"/>
<boolean value="NO" key="1.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO" key="2.IBNSViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="20.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">20</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">MPServerSettingsController</string>
<string key="superclassName">MPViewController</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">enableServerCheckbutton</string>
<string key="NS.object.0">NSButton</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">enableServerCheckbutton</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">enableServerCheckbutton</string>
<string key="candidateClassName">NSButton</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPServerSettingsController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MPViewController</string>
<string key="superclassName">NSViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MPViewController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NS.key.0">NSSwitch</string>
<string key="NS.object.0">{15, 15}</string>
</object>
<bool key="IBDocument.UseAutolayout">YES</bool>
</data>
</archive>

View File

@@ -36,7 +36,7 @@
<int key="NSWindowStyleMask">7</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{196, 240}, {400, 200}}</string>
<int key="NSWTFlags">544735232</int>
<int key="NSWTFlags">544736256</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
@@ -111,9 +111,11 @@
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="YES" key="1.IBNSWindowAutoPositionCentersHorizontal"/>
<boolean value="YES" key="1.IBNSWindowAutoPositionCentersVertical"/>
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1.IBWindowTemplateEditedContentRect">{{357, 418}, {480, 270}}</string>
<integer value="1" key="1.NSWindowTemplate.visibleAtLaunch"/>
<boolean value="NO" key="1.NSWindowTemplate.visibleAtLaunch"/>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>

Binary file not shown.