From a70aedb51e8ef9ddced7352ae89482469cb27d1e Mon Sep 17 00:00:00 2001 From: michael starke Date: Sun, 31 Mar 2013 15:57:41 +0200 Subject: [PATCH] First drafting for Password generator. Extended Settings handling to be able to use Tabs --- MacPass.xcodeproj/project.pbxproj | 46 +- MacPass/Defaults.plist | 12 + MacPass/GeneralSettings.xib | 743 +++++++++++++++--- MacPass/MPAbstractSettingsViewController.h | 14 + MacPass/MPAbstractSettingsViewController.m | 17 + MacPass/MPAppDelegate.m | 17 +- MacPass/MPGeneralSettingsController.h | 5 +- MacPass/MPGeneralSettingsController.m | 12 +- MacPass/MPSettingsController.h | 8 +- MacPass/MPSettingsController.m | 136 +++- MacPass/MPSettingsKeys.h | 13 + MacPass/MPSettingsKeys.m | 13 + ...SettingsTabProtocoll.h => MPSettingsTab.h} | 11 +- MacPass/MacPass-Info.plist | 2 +- MacPass/NSData+MPRandomBytes.h | 15 + MacPass/NSData+MPRandomBytes.m | 20 + MacPass/NSString+MPPasswordAnalysis.h | 23 + MacPass/NSString+MPPasswordAnalysis.m | 17 + MacPass/NSString+MPPasswordCreation.h | 45 ++ MacPass/NSString+MPPasswordCreation.m | 65 ++ MacPass/SettingsWindow.xib | 14 +- MacPass/en.lproj/Localizable.strings | Bin 3116 -> 3240 bytes 22 files changed, 1123 insertions(+), 125 deletions(-) create mode 100644 MacPass/Defaults.plist create mode 100644 MacPass/MPAbstractSettingsViewController.h create mode 100644 MacPass/MPAbstractSettingsViewController.m create mode 100644 MacPass/MPSettingsKeys.h create mode 100644 MacPass/MPSettingsKeys.m rename MacPass/{MPSettingsTabProtocoll.h => MPSettingsTab.h} (50%) create mode 100644 MacPass/NSData+MPRandomBytes.h create mode 100644 MacPass/NSData+MPRandomBytes.m create mode 100644 MacPass/NSString+MPPasswordAnalysis.h create mode 100644 MacPass/NSString+MPPasswordAnalysis.m create mode 100644 MacPass/NSString+MPPasswordCreation.h create mode 100644 MacPass/NSString+MPPasswordCreation.m diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 570c737f..6f574ba2 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -18,8 +18,13 @@ 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */; }; 4C3BD51516D276F800389F1F /* MPToolbarDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3BD51416D276F800389F1F /* MPToolbarDelegate.m */; }; 4C3FFD9E16DAF60600DF9186 /* FilterBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */; }; + 4C40AC5C170782730073D1C3 /* MPAbstractSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C40AC5B170782730073D1C3 /* MPAbstractSettingsViewController.m */; }; + 4C40AC5F170876D90073D1C3 /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4C40AC5E170876D90073D1C3 /* Defaults.plist */; }; 4C431BCD16E2A82800700A81 /* MPPasteBoardController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C431BCC16E2A82700700A81 /* MPPasteBoardController.m */; }; 4C431BCF16E2BAB000700A81 /* OverlayWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C431BCE16E2BAB000700A81 /* OverlayWindow.xib */; }; + 4C46B88517063A070046109A /* NSString+MPPasswordCreation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46B88417063A070046109A /* NSString+MPPasswordCreation.m */; }; + 4C46B88817063A170046109A /* NSString+MPPasswordAnalysis.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46B88717063A170046109A /* NSString+MPPasswordAnalysis.m */; }; + 4C46B88B1706D16E0046109A /* NSData+MPRandomBytes.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C46B88A1706D16E0046109A /* NSData+MPRandomBytes.m */; }; 4C586F9E16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586F9D16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf */; }; 4C586FA016D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586F9F16D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf */; }; 4C586FA216D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */; }; @@ -94,6 +99,7 @@ 4CAD748C15B889B700104512 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748B15B889B700104512 /* Security.framework */; }; 4CAD748E15B88AC100104512 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CAD748D15B88AC100104512 /* libz.dylib */; }; 4CB9339916D3A0DD00A13B5D /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 4CB9339716D3A0DD00A13B5D /* Credits.rtf */; }; + 4CBA2ABA17074C07006D8139 /* MPSettingsKeys.m in Resources */ = {isa = PBXBuildFile; fileRef = 4CBA2AB917074C07006D8139 /* MPSettingsKeys.m */; }; 4CBA981815BA0DB600721965 /* MPDatabaseDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CBA981715BA0DB600721965 /* MPDatabaseDocument.m */; }; 4CC1AEBE16D4467C006D2AAB /* KdbTree+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC1AEBD16D4467C006D2AAB /* KdbTree+MPAdditions.m */; }; 4CC6259115BA1C99002F5B11 /* MPOutlineViewDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CC6259015BA1C99002F5B11 /* MPOutlineViewDelegate.m */; }; @@ -129,9 +135,18 @@ 4C3BD51316D276F800389F1F /* MPToolbarDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPToolbarDelegate.h; sourceTree = ""; }; 4C3BD51416D276F800389F1F /* MPToolbarDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPToolbarDelegate.m; sourceTree = ""; }; 4C3FFD9D16DAF60600DF9186 /* FilterBar.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FilterBar.xib; sourceTree = ""; }; + 4C40AC581707819A0073D1C3 /* MPAbstractSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAbstractSettingsViewController.h; sourceTree = ""; }; + 4C40AC5B170782730073D1C3 /* MPAbstractSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAbstractSettingsViewController.m; sourceTree = ""; }; + 4C40AC5E170876D90073D1C3 /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Defaults.plist; sourceTree = ""; }; 4C431BCB16E2A82700700A81 /* MPPasteBoardController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPasteBoardController.h; sourceTree = ""; }; 4C431BCC16E2A82700700A81 /* MPPasteBoardController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPasteBoardController.m; sourceTree = ""; }; 4C431BCE16E2BAB000700A81 /* OverlayWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OverlayWindow.xib; sourceTree = ""; }; + 4C46B88317063A070046109A /* NSString+MPPasswordCreation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MPPasswordCreation.h"; sourceTree = ""; }; + 4C46B88417063A070046109A /* NSString+MPPasswordCreation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MPPasswordCreation.m"; sourceTree = ""; }; + 4C46B88617063A170046109A /* NSString+MPPasswordAnalysis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MPPasswordAnalysis.h"; sourceTree = ""; }; + 4C46B88717063A170046109A /* NSString+MPPasswordAnalysis.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MPPasswordAnalysis.m"; sourceTree = ""; }; + 4C46B8891706D16E0046109A /* NSData+MPRandomBytes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+MPRandomBytes.h"; sourceTree = ""; }; + 4C46B88A1706D16E0046109A /* NSData+MPRandomBytes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+MPRandomBytes.m"; sourceTree = ""; }; 4C586F9D16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 00_PasswordTemplate.pdf; sourceTree = ""; }; 4C586F9F16D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 01_PackageNetworkTemplate.pdf; sourceTree = ""; }; 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 02_MessageBoxWarningTemplate.pdf; sourceTree = ""; }; @@ -253,7 +268,7 @@ 4CA0B2F815BCAF6700654E32 /* MPGeneralSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPGeneralSettingsController.m; sourceTree = ""; }; 4CA0B2FA15BCAF8600654E32 /* MPSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsController.h; sourceTree = ""; }; 4CA0B2FB15BCAF8600654E32 /* MPSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsController.m; sourceTree = ""; }; - 4CA0B30D15BCB6FD00654E32 /* MPSettingsTabProtocoll.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPSettingsTabProtocoll.h; sourceTree = ""; }; + 4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPSettingsTab.h; sourceTree = ""; }; 4CAC6F7616D2B54800D79D5E /* MPMainWindowSplitViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMainWindowSplitViewDelegate.h; sourceTree = ""; }; 4CAC6F7716D2B54800D79D5E /* MPMainWindowSplitViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMainWindowSplitViewDelegate.m; sourceTree = ""; }; 4CACB72A16F7C9B600D47C9E /* KdbEntry+Copying.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbEntry+Copying.h"; sourceTree = ""; }; @@ -275,6 +290,8 @@ 4CAD748B15B889B700104512 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 4CAD748D15B88AC100104512 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 4CB9339816D3A0DD00A13B5D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; + 4CBA2AB617074B59006D8139 /* MPSettingsKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSettingsKeys.h; sourceTree = ""; }; + 4CBA2AB917074C07006D8139 /* MPSettingsKeys.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSettingsKeys.m; sourceTree = ""; }; 4CBA981615BA0DB600721965 /* MPDatabaseDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatabaseDocument.h; sourceTree = ""; }; 4CBA981715BA0DB600721965 /* MPDatabaseDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPDatabaseDocument.m; sourceTree = ""; }; 4CC1AEBC16D4467C006D2AAB /* KdbTree+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KdbTree+MPAdditions.h"; sourceTree = ""; }; @@ -364,6 +381,8 @@ 4C2E382216D1421B00037A9D /* MPIconHelper.m */, 4C920E2816DCDFA00083839B /* MPLoggerProxy.h */, 4C920E2916DCDFA00083839B /* MPLoggerProxy.m */, + 4CBA2AB617074B59006D8139 /* MPSettingsKeys.h */, + 4CBA2AB917074C07006D8139 /* MPSettingsKeys.m */, ); name = Helper; sourceTree = ""; @@ -396,6 +415,19 @@ name = Model; sourceTree = ""; }; + 4C46B8821706397A0046109A /* Security Additions */ = { + isa = PBXGroup; + children = ( + 4C46B8891706D16E0046109A /* NSData+MPRandomBytes.h */, + 4C46B88A1706D16E0046109A /* NSData+MPRandomBytes.m */, + 4C46B88317063A070046109A /* NSString+MPPasswordCreation.h */, + 4C46B88417063A070046109A /* NSString+MPPasswordCreation.m */, + 4C46B88617063A170046109A /* NSString+MPPasswordAnalysis.h */, + 4C46B88717063A170046109A /* NSString+MPPasswordAnalysis.m */, + ); + name = "Security Additions"; + sourceTree = ""; + }; 4C586F9C16D07ABD00E7DB57 /* Icons */ = { isa = PBXGroup; children = ( @@ -554,6 +586,7 @@ 4C77E36C15B84A240093A587 /* MacPass */ = { isa = PBXGroup; children = ( + 4C46B8821706397A0046109A /* Security Additions */, 4C2C4C2516D3BCEA00D49295 /* KeePassLibAdditions */, 4C2E382016D141F700037A9D /* Helper */, 4C586F9C16D07ABD00E7DB57 /* Icons */, @@ -581,6 +614,7 @@ 4C77E36F15B84A240093A587 /* InfoPlist.strings */, 4C77E37215B84A240093A587 /* main.m */, 4C77E37415B84A240093A587 /* MacPass-Prefix.pch */, + 4C40AC5E170876D90073D1C3 /* Defaults.plist */, ); name = "Supporting Files"; sourceTree = ""; @@ -602,6 +636,8 @@ 4C77547416E55FE800970E02 /* MPInspectorTabViewController.m */, 4CE39ABD16ECE34A000FE29D /* MPIconSelectViewController.h */, 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */, + 4C40AC581707819A0073D1C3 /* MPAbstractSettingsViewController.h */, + 4C40AC5B170782730073D1C3 /* MPAbstractSettingsViewController.m */, ); name = "View Controller"; sourceTree = ""; @@ -609,7 +645,7 @@ 4CA0B30E15BCB70200654E32 /* Protocolls */ = { isa = PBXGroup; children = ( - 4CA0B30D15BCB6FD00654E32 /* MPSettingsTabProtocoll.h */, + 4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */, ); name = Protocolls; sourceTree = ""; @@ -799,6 +835,8 @@ 4C77547716E55FFC00970E02 /* InspectorTabView.xib in Resources */, 4C888C9016EB6C91003D34A1 /* Localizable.strings in Resources */, 4CE39AC116ECE359000FE29D /* IconSelection.xib in Resources */, + 4CBA2ABA17074C07006D8139 /* MPSettingsKeys.m in Resources */, + 4C40AC5F170876D90073D1C3 /* Defaults.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -898,6 +936,10 @@ 4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */, 4CACB72C16F7C9B600D47C9E /* KdbEntry+Copying.m in Sources */, 4CACB72F16F7CA5100D47C9E /* Kdb4Entry+Copying.m in Sources */, + 4C46B88517063A070046109A /* NSString+MPPasswordCreation.m in Sources */, + 4C46B88817063A170046109A /* NSString+MPPasswordAnalysis.m in Sources */, + 4C46B88B1706D16E0046109A /* NSData+MPRandomBytes.m in Sources */, + 4C40AC5C170782730073D1C3 /* MPAbstractSettingsViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/Defaults.plist b/MacPass/Defaults.plist new file mode 100644 index 00000000..d2874589 --- /dev/null +++ b/MacPass/Defaults.plist @@ -0,0 +1,12 @@ + + + + + PasswordEncoding + 0 + ClearClipboardOnQuit + + ClearClipboardIntervall + 10 + + diff --git a/MacPass/GeneralSettings.xib b/MacPass/GeneralSettings.xib index 499ddc09..11e8c7fa 100644 --- a/MacPass/GeneralSettings.xib +++ b/MacPass/GeneralSettings.xib @@ -2,16 +2,19 @@ 1080 - 12C3103 + 12D78 3084 - 1187.34 - 625.00 + 1187.37 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin 3084 IBNSLayoutConstraint + NSBox + NSButton + NSButtonCell NSCustomObject NSCustomView NSMenu @@ -42,23 +45,232 @@ 268 + + + 12 + + + + 274 + + + + 268 + {{10, 42}, {124, 17}} + + + + _NS:1535 + YES + + 68157504 + 272630784 + Clear Copied Items + + LucidaGrande + 13 + 1044 + + _NS:1535 + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + NO + + + + 268 + {{137, 37}, {112, 26}} + + + + _NS:9 + YES + + -2076180416 + 2048 + + _NS:9 + + 109199360 + 129 + + + 400 + 75 + + + Never + + 2147483647 + 1 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + _popUpItemAction: + + + YES + + OtherViews + + + + + 10 Seconds + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + 30 Seconds + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + 1 Minute + + 1048576 + 2147483647 + + + _popUpItemAction: + + + + + + -1 + 1 + YES + YES + 2 + + NO + + + + 268 + {{11, 12}, {172, 18}} + + + + _NS:9 + {250, 150} + YES + + -2080374784 + 268435456 + Clear Clipboard on Quit + + _NS:9 + + 1211912448 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + NO + + + {{1, 1}, {258, 68}} + + + + _NS:11 + + + {{17, 16}, {260, 84}} + + + + _NS:9 + {0, 0} + + 67108864 + 0 + Clipboard + + LucidaGrande + 11 + 3100 + + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 3 + MCAwLjgwMDAwMDAxMTkAA + + + + 1 + 0 + 2 + NO + 268 - {{146, 91}, {127, 26}} + {{156, 102}, {75, 26}} + _NS:9 {750, 751} YES -2076180416 2048 - - LucidaGrande - 13 - 1044 - + _NS:9 109199360 @@ -74,14 +286,8 @@ 1048576 2147483647 1 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - + + _popUpItemAction: @@ -96,8 +302,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -107,14 +313,15 @@ 1048576 2147483647 - - + + _popUpItemAction: + -1 1 YES YES @@ -125,7 +332,7 @@ 268 - {{17, 97}, {127, 17}} + {{27, 108}, {126, 17}} @@ -138,29 +345,13 @@ _NS:1505 - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - controlTextColor - - 3 - MAA - - + + NO - {290, 135} + {294, 146} @@ -230,26 +421,10 @@ 1000 - 6 - 24 + 9 + 40 2 - - - 6 - 0 - - 6 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - 3 @@ -262,8 +437,8 @@ 1000 - 8 - 29 + 9 + 40 3 @@ -298,24 +473,56 @@ 40 3 - - - 7 + + + 4 0 - - 7 + + 4 1 - - 0.0 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 4 + 1 + + 4 + 1 + + 20 1000 9 40 - 5 + 3 + + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 9 + 40 + 3 - + 5 0 @@ -330,6 +537,38 @@ 40 3 + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 9 + 40 + 3 + + + + 5 + 0 + + 5 + 1 + + 30 + + 1000 + + 3 + 9 + 3 + 5 @@ -346,6 +585,7 @@ 40 3 + @@ -408,11 +648,6 @@ - - 62 - - - 66 @@ -428,41 +663,313 @@ - - 129 - - - - - 130 - - - 131 + + 465 + + + + + + 6 + 1 + + 6 + 1 + + 10 + + 1000 + + 9 + 40 + 3 + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 9 + 40 + 2 + + + + 5 + 0 + + 6 + 1 + + 8 + + 1000 + + 9 + 40 + 3 + + + + 3 + 0 + + 4 + 1 + + 14 + + 1000 + + 9 + 40 + 3 + + + + 4 + 0 + + 4 + 1 + + 11 + + 1000 + + 9 + 40 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 5 + 0 + + 5 + 1 + + 11 + + 1000 + + 9 + 40 + 3 + + + + + + + + 431 + + + + + + + + 432 + + + + + 471 + + + + + 473 + + + + + 475 + + + + + 419 + + + + + 7 + 0 + + 0 + 1 + + 107 + + 1000 + + 3 + 9 + 1 + + + + + + + 458 + + + + + 420 + + + + + + + + 421 + + + + + + + + + + + 429 + + + + + 424 + + + + + 423 + + + + + 422 + + + + + 478 + + + + + 479 + + + + + 447 + + + + + + + + 448 + + + + + 481 + + + + + 482 + + + + + 485 + + + + + 486 + + + + + 487 + + + + + 489 + + + + + 492 + + + + + 494 + + + 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 @@ -471,8 +978,49 @@ 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 @@ -483,13 +1031,21 @@ - 418 + 494 - MPGeneralSettingsController + MPAbstractSettingsViewController MPViewController + + IBProjectSource + ./Classes/MPAbstractSettingsViewController.h + + + + MPGeneralSettingsController + MPAbstractSettingsViewController NSPopUpButton NSImageView @@ -534,6 +1090,7 @@ {11, 11} {10, 3} + {15, 15} YES diff --git a/MacPass/MPAbstractSettingsViewController.h b/MacPass/MPAbstractSettingsViewController.h new file mode 100644 index 00000000..6eef21f7 --- /dev/null +++ b/MacPass/MPAbstractSettingsViewController.h @@ -0,0 +1,14 @@ +// +// 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 + +@end diff --git a/MacPass/MPAbstractSettingsViewController.m b/MacPass/MPAbstractSettingsViewController.m new file mode 100644 index 00000000..fca70f3a --- /dev/null +++ b/MacPass/MPAbstractSettingsViewController.m @@ -0,0 +1,17 @@ +// +// 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 diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index b29b7c1d..39c67edb 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -12,18 +12,27 @@ #import "MPSettingsController.h" #import "MPDatabaseController.h" #import "MPActionHelper.h" +#import "NSString+MPPasswordCreation.h" @interface MPAppDelegate () -@property (retain) MPSettingsController *settingsController; -@property (retain) MPMainWindowController *mainWindowController; +@property (retain, nonatomic) MPSettingsController *settingsController; +@property (retain, nonatomic) MPMainWindowController *mainWindowController; - (IBAction)showPreferences:(id)sender; + @end @implementation MPAppDelegate ++ (void)initialize { + NSURL *defaultURL = [[NSBundle mainBundle] URLForResource:@"Defaults" withExtension:@"plst"]; + NSDictionary *defaultsDictionary = [NSDictionary dictionaryWithContentsOfURL:defaultURL]; + [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary]; +} + - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + //NSString *string = [NSString passwordFromString:@"BOJA" length:10]; self.mainWindowController = [[[MPMainWindowController alloc] init] autorelease]; [self.mainWindowController showWindow:[self.mainWindowController window]]; @@ -49,7 +58,7 @@ if(self.settingsController == nil) { self.settingsController = [[[MPSettingsController alloc] init] autorelease]; } - [self.settingsController showWindow:_settingsController.window]; + [self.settingsController showSettings]; } - (NSArray *)contextMenuItemsWithItems:(MPContextMenuItemsFlags)flags { @@ -117,4 +126,6 @@ return items; } + + @end diff --git a/MacPass/MPGeneralSettingsController.h b/MacPass/MPGeneralSettingsController.h index 8de18047..df39aeb0 100644 --- a/MacPass/MPGeneralSettingsController.h +++ b/MacPass/MPGeneralSettingsController.h @@ -7,10 +7,9 @@ // #import -#import "MPSettingsTabProtocoll.h" -#import "MPViewController.h" +#import "MPAbstractSettingsViewController.h" -@interface MPGeneralSettingsController : MPViewController +@interface MPGeneralSettingsController : MPAbstractSettingsViewController @property (assign) IBOutlet NSImageView *imageView; @end diff --git a/MacPass/MPGeneralSettingsController.m b/MacPass/MPGeneralSettingsController.m index 9fc5a088..68b87de5 100644 --- a/MacPass/MPGeneralSettingsController.m +++ b/MacPass/MPGeneralSettingsController.m @@ -21,10 +21,6 @@ NSString *const MPGeneralSetingsIdentifier = @"GeneralSettingsTab"; return MPGeneralSetingsIdentifier; } -+ (NSImage *)image { - return [NSImage imageNamed:NSImageNamePreferencesGeneral]; -} - - (id)init { return [self initWithNibName:@"GeneralSettings" bundle:[NSBundle mainBundle]]; } @@ -34,6 +30,14 @@ NSString *const MPGeneralSetingsIdentifier = @"GeneralSettingsTab"; return self; } +- (NSImage *)image { + return [NSImage imageNamed:NSImageNamePreferencesGeneral]; +} + +- (NSString *)label { + return NSLocalizedString(@"GENERAL_SETTINGS", @"General Settings Label"); +} + - (void)didLoadView { // setup connections NSMenu *encodingMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] init]; diff --git a/MacPass/MPSettingsController.h b/MacPass/MPSettingsController.h index fb0ed9a6..b0cb800f 100644 --- a/MacPass/MPSettingsController.h +++ b/MacPass/MPSettingsController.h @@ -8,7 +8,11 @@ #import -APPKIT_EXTERN NSString const* kMPPasswordEnvodingSettingsKey; +@protocol MPSettingsTab; + +@interface MPSettingsController : NSWindowController + +- (void)showSettings; +- (void)showSettingsTabWithIdentifier:(NSString *)identifier; -@interface MPSettingsController : NSWindowController @end diff --git a/MacPass/MPSettingsController.m b/MacPass/MPSettingsController.m index 194ab2ed..c60e0932 100644 --- a/MacPass/MPSettingsController.m +++ b/MacPass/MPSettingsController.m @@ -9,28 +9,148 @@ #import "MPSettingsController.h" #import "MPGeneralSettingsController.h" -NSString const* kMPPasswordEnvodingSettingsKey = @"PasswordEncoding"; - @interface MPSettingsController () -@property (retain) MPGeneralSettingsController *generalController; + +@property (retain, nonatomic) NSToolbar *toolbar; +@property (retain, nonatomic) NSMutableDictionary *settingsController; +@property (retain, nonatomic) NSMutableDictionary *toolbarItems; + +- (void)_addSettingsTab:(id)tabController; +- (void)_setupDefaultSettingsTabs; +- (void)_showSettingsTab:(id)sender; + @end @implementation MPSettingsController -(id)init { self = [super initWithWindowNibName:@"SettingsWindow"]; + if(self) { + _toolbar = [[NSToolbar alloc] initWithIdentifier:@"SettingsToolBar"]; + [self.toolbar setAllowsUserCustomization:NO]; + [self.toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel]; + _settingsController = [[NSMutableDictionary alloc] initWithCapacity:5]; + _toolbarItems = [[NSMutableDictionary alloc] initWithCapacity:5]; + + [self _setupDefaultSettingsTabs]; + + [self.toolbar setDelegate:self]; + [[self window] setToolbar:self.toolbar]; + } return self; } - (void)dealloc { - self.generalController = nil; + [_settingsController release]; + [_toolbar release]; + [_toolbarItems release]; [super dealloc]; } -- (void)windowDidLoad { - _generalController = [[MPGeneralSettingsController alloc] init]; - [_generalController loadView]; - [[self window] setContentView:[_generalController view]]; +- (void)showSettings { + if([self.settingsController count] > 0) { + id tab = [self.settingsController allValues][0]; + NSString *identifier = [[tab class] identifier]; + [self showSettingsTabWithIdentifier:identifier]; + } +} + +- (void)showSettingsTabWithIdentifier:(NSString *)identifier { + if(nil == identifier) { + @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"Identifier cannot be nil" userInfo:nil]; + } + id tab = self.settingsController[identifier]; + if(tab == nil){ + 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]; + [[self window] makeKeyAndOrderFront:[self window]]; +} + +- (void)_addSettingsTab:(id)tabController { + if(NO == [tabController conformsToProtocol:@protocol(MPSettingsTab)]) { + NSException *protocollException = [NSException exceptionWithName:NSInvalidArgumentException + reason:@"Controller must conform to MPSettingsTabProtrocoll" + userInfo:nil]; + @throw protocollException; + } + if(NO == [tabController isKindOfClass:[NSViewController class]]) { + NSException *controllerException = [NSException exceptionWithName:NSInvalidArgumentException + reason:@"Controller is no NSViewController" + userInfo:nil]; + @throw controllerException; + } + NSString *identifier = [[tabController class] identifier]; + if(nil != self.settingsController[identifier]) { + NSLog(@"Warning: Settingscontroller with identifer %@ already present!", identifier); + } + else { + self.settingsController[identifier] = tabController; + } +} + +- (void)_setupDefaultSettingsTabs { + MPGeneralSettingsController *generalSettingsController = [[MPGeneralSettingsController alloc] init]; + + [self _addSettingsTab:generalSettingsController]; + + [generalSettingsController release]; +} + +- (void)_showSettingsTab:(id)sender { + if([sender respondsToSelector:@selector(identifier)]) { + NSString *identfier = [sender identifier]; + [self showSettingsTabWithIdentifier:identfier]; + } +} + +#pragma mark NSToolbarDelegate + +- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar { + return [self.settingsController allKeys]; +} + +- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar { + return [self.settingsController allKeys]; +} + +- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar { + return [self.settingsController allKeys]; +} + +- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag { + NSToolbarItem *item = self.toolbarItems[itemIdentifier]; + if(nil == item) { + item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; + /* + Setup the item to use the controllers label if one is present + and supports the appropriate @optional protocoll messages + */ + id tab = self.settingsController[itemIdentifier]; + if([tab respondsToSelector:@selector(label)]) { + [item setLabel:[tab label]]; + } + else { + [item setLabel:itemIdentifier]; + } + if([tab respondsToSelector:@selector(image)]) { + [item setImage:[tab image]]; + } + else { + [item setImage:[NSImage imageNamed:NSImageNameCaution ]]; + } + + [item setAction:@selector(_showSettingsTab:)]; + self.toolbarItems[itemIdentifier] = item; + } + return item; } @end diff --git a/MacPass/MPSettingsKeys.h b/MacPass/MPSettingsKeys.h new file mode 100644 index 00000000..c713cc9c --- /dev/null +++ b/MacPass/MPSettingsKeys.h @@ -0,0 +1,13 @@ +// +// MPSettingsKeys.h +// MacPass +// +// Created by Michael Starke on 30.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +extern NSString *const kMPSettingsKeyClearClipboardIntervall; +extern NSString *const kMPSettingsKeyClearClipboardOnQuit; +extern NSString *const kMPSettingsKeyPasswordEncoding; \ No newline at end of file diff --git a/MacPass/MPSettingsKeys.m b/MacPass/MPSettingsKeys.m new file mode 100644 index 00000000..b7ce751c --- /dev/null +++ b/MacPass/MPSettingsKeys.m @@ -0,0 +1,13 @@ +// +// MPSettingsKeys.m +// MacPass +// +// Created by Michael Starke on 30.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "MPSettingsKeys.h" + +NSString *const kMPSettingsKeyClearClipboardIntervall = @"ClearClipboardIntervall"; +NSString *const kMPSettingsKeyClearClipboardOnQuit = @"ClearClipboardOnQuit"; +NSString *const kMPSettingsKeyPasswordEncoding = @"PasswordEncoding"; \ No newline at end of file diff --git a/MacPass/MPSettingsTabProtocoll.h b/MacPass/MPSettingsTab.h similarity index 50% rename from MacPass/MPSettingsTabProtocoll.h rename to MacPass/MPSettingsTab.h index 41333a92..878de98f 100644 --- a/MacPass/MPSettingsTabProtocoll.h +++ b/MacPass/MPSettingsTab.h @@ -8,10 +8,17 @@ #import -@protocol MPSettingsTabProtocoll +/* + Protrocoll to be implemented by ViewControllers that can be added to + the settings windows. Tabs are orded as the controllers are included. + */ +@protocol MPSettingsTab @required + (NSString *)identifier; -+ (NSImage *)image; + +@optional +- (NSString *)label; +- (NSImage *)image; @end diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 8bd08f9c..5a78e76d 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 599 + 5EA LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/MacPass/NSData+MPRandomBytes.h b/MacPass/NSData+MPRandomBytes.h new file mode 100644 index 00000000..3c59df30 --- /dev/null +++ b/MacPass/NSData+MPRandomBytes.h @@ -0,0 +1,15 @@ +// +// NSData+MPRandomBytes.h +// MacPass +// +// Created by Michael Starke on 30.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface NSData (MPRandomBytes) + ++ (NSData *)dataWithRandomBytes:(NSUInteger)lenght; + +@end diff --git a/MacPass/NSData+MPRandomBytes.m b/MacPass/NSData+MPRandomBytes.m new file mode 100644 index 00000000..a63a3a13 --- /dev/null +++ b/MacPass/NSData+MPRandomBytes.m @@ -0,0 +1,20 @@ +// +// NSData+MPRandomBytes.m +// MacPass +// +// Created by Michael Starke on 30.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "NSData+MPRandomBytes.h" +#import + +@implementation NSData (MPRandomBytes) + ++ (NSData *)dataWithRandomBytes:(NSUInteger)length { + unsigned char *bytes = malloc(sizeof(unsigned char) * length); + SecRandomCopyBytes(kSecRandomDefault, length, bytes); + return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:YES]; +} + +@end diff --git a/MacPass/NSString+MPPasswordAnalysis.h b/MacPass/NSString+MPPasswordAnalysis.h new file mode 100644 index 00000000..5bfdf1bc --- /dev/null +++ b/MacPass/NSString+MPPasswordAnalysis.h @@ -0,0 +1,23 @@ +// +// NSString+MPPasswordAnalysis.h +// MacPass +// +// Created by Michael Starke on 29.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +typedef enum { + MPPasswordWeak, + MPPasswordOK, + MPPasswordGood, + MPPasswordStrong, + MPPasswordExcelent, +} MPPasswordStrength; + +@interface NSString (MPPasswordAnalysis) + +- (MPPasswordStrength)passwordStrenght; + +@end diff --git a/MacPass/NSString+MPPasswordAnalysis.m b/MacPass/NSString+MPPasswordAnalysis.m new file mode 100644 index 00000000..a3eb9438 --- /dev/null +++ b/MacPass/NSString+MPPasswordAnalysis.m @@ -0,0 +1,17 @@ +// +// NSString+MPPasswordAnalysis.m +// MacPass +// +// Created by Michael Starke on 29.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "NSString+MPPasswordAnalysis.h" + +@implementation NSString (MPPasswordAnalysis) + +- (MPPasswordStrength)passwordStrenght { + return MPPasswordOK; +} + +@end diff --git a/MacPass/NSString+MPPasswordCreation.h b/MacPass/NSString+MPPasswordCreation.h new file mode 100644 index 00000000..dc289604 --- /dev/null +++ b/MacPass/NSString+MPPasswordCreation.h @@ -0,0 +1,45 @@ +// +// NSString+MPPasswordCreation.h +// MacPass +// +// Created by Michael Starke on 29.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +typedef enum { + MPPasswordCharactersUpperCase = (1<<0), // NSCharacterset lowerCaseCharacterSet + MPPasswordCharactersLowerCase = (1<<1), // NSCharacterSet upperCaseCharacterSet + MPPasswordCharactersNumbers = (1<<2), // NSCharacterSet numberCharacterSet + MPPasswordCharactersSymbols = (1<<3) // NSCharacterSet symbolCharacterSet +} MPPasswordCharacterFlags; + +@interface NSString (MPPasswordCreation) + +/* + Generates a new password with the allowed charaters an the requests lenght + @param array with allowed NSChractersSets for creation + @param lenght lenght of the password to create + */ ++ (NSString *)passwordWithCharactersets:(MPPasswordCharacterFlags)allowedCharacters length:(NSUInteger)theLength; +/* + Generates a new password with the given length and allowed characters + @param Source string of allowed characters + @param lenght Lenght of the password to create + @return Password + */ ++ (NSString *)passwordFromString:(NSString *)source length:(NSUInteger)length; + +/* + Creates a password containing only the characters in the string + @param Lenght of the password + */ +- (NSString *)passwordWithLength:(NSUInteger)length; + +/* + Returns a random Character from the String + */ +- (NSString *)randomCharacter; + +@end diff --git a/MacPass/NSString+MPPasswordCreation.m b/MacPass/NSString+MPPasswordCreation.m new file mode 100644 index 00000000..2c0aed11 --- /dev/null +++ b/MacPass/NSString+MPPasswordCreation.m @@ -0,0 +1,65 @@ +// +// NSString+MPPasswordCreation.m +// MacPass +// +// Created by Michael Starke on 29.03.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "NSString+MPPasswordCreation.h" +#import "NSData+MPRandomBytes.h" + + +@implementation NSString (MPPasswordCreationTools) + ++ (NSDictionary *)_createPasswordSet:(MPPasswordCharacterFlags)flags { + return [NSDictionary dictionary]; +} + +- (NSDictionary *)_createPasswordSet:(MPPasswordCharacterFlags)flags { + return [NSString _createPasswordSet:flags]; +} + +@end + +@implementation NSString (MPPasswordCreation) + ++ (NSString *)passwordFromString:(NSString *)source length:(NSUInteger)length { + NSMutableString *password = [[NSMutableString alloc] initWithCapacity:length]; + while([password length] < length) { + NSData *randomData = [NSData dataWithRandomBytes:2]; + NSNumber *number = [NSNumber numberWithUnsignedChar:(unsigned char)[randomData bytes]]; + NSLog(@"Random number:%@", number); + [password appendString:@"U"]; + } + return [password autorelease]; +} + ++ (NSString *)passwordWithCharactersets:(MPPasswordCharacterFlags)allowedCharacters length:(NSUInteger)length { + NSDictionary *characterSet = [self _createPasswordSet:allowedCharacters]; + NSMutableString *password = [NSMutableString stringWithCapacity:length]; + while([password length] < length) { + // decide what charactersupset to use + // gather random character of selected set + NSString *characters = characterSet[@(MPPasswordCharactersLowerCase)]; + [password appendString:[characters randomCharacter]]; + } + return password; +} + +- (NSString *)passwordWithLength:(NSUInteger)length { + return [NSString passwordFromString:self length:length]; +} + +- (NSString *)randomCharacter { + NSUInteger randomByteSize = floor(log2([self length])); + NSData *randomData = [NSData dataWithRandomBytes:randomByteSize]; + NSNumber *number = [NSNumber numberWithUnsignedChar:(unsigned char)[randomData bytes]]; + NSUInteger randomIndex = [number integerValue]; + if(randomIndex > 0 || randomIndex >= [self length]) { + return nil; + } + return [self substringFromIndex:[number integerValue]]; +} + +@end diff --git a/MacPass/SettingsWindow.xib b/MacPass/SettingsWindow.xib index fc6a2c33..23d4b0b9 100644 --- a/MacPass/SettingsWindow.xib +++ b/MacPass/SettingsWindow.xib @@ -2,10 +2,10 @@ 1080 - 12C60 + 12D78 3084 - 1187.34 - 625.00 + 1187.37 + 626.00 com.apple.InterfaceBuilder.CocoaPlugin 3084 @@ -33,9 +33,9 @@ NSApplication - 15 + 7 2 - {{196, 240}, {473, 263}} + {{196, 240}, {223, 156}} 544735232 Window NSWindow @@ -45,11 +45,11 @@ 256 - {473, 263} + {223, 156} - {{0, 0}, {2560, 1418}} + {{0, 0}, {1680, 1028}} {10000000000000, 10000000000000} YES diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 8264d3c93f71a185e9333fd78863c82b1db5e77a..9e4dd45a189c51e4afb0c8b65ca92fe39c43ce83 100644 GIT binary patch delta 155 zcmZ1@u|je}4tohhCPO|$-sFj_ksHq(V6As&NM*xkh3_4tpj;K0_Wu$>fQwksHq(VBO5YzJL_~gi;A^