From c207b2b24a40cc835610c32b27bec32d7f841b11 Mon Sep 17 00:00:00 2001 From: michael starke Date: Sat, 20 Jul 2013 03:23:18 +0200 Subject: [PATCH] Experiments with token filed in Inspector --- KeePassKit | 2 +- MacPass.xcodeproj/project.pbxproj | 24 ++ MacPass/Base.lproj/InspectorView.xib | 304 ++++++++++++++++-- .../CustomIcon_Password_1234.xml | 0 MacPassTests/Images/image.png | Bin 0 -> 803 bytes MacPassTests/KPKIconLoading.h | 16 + MacPassTests/KPKIconLoading.m | 43 +++ 7 files changed, 362 insertions(+), 27 deletions(-) rename MacPassTests/{ => Databases}/CustomIcon_Password_1234.xml (100%) create mode 100644 MacPassTests/Images/image.png create mode 100644 MacPassTests/KPKIconLoading.h create mode 100644 MacPassTests/KPKIconLoading.m diff --git a/KeePassKit b/KeePassKit index 8b8d3406..3df84c73 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 8b8d3406a5dfa826b74823f02ff8e140ec0ff8c7 +Subproject commit 3df84c73318cdf96c8bce087e828ec43a6404b57 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 833516a6..e1be3c44 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -57,6 +57,9 @@ 4C2E381F16D11FF900037A9D /* 05_LanguagesTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C2E381C16D11FF900037A9D /* 05_LanguagesTemplate.pdf */; }; 4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382216D1421B00037A9D /* MPIconHelper.m */; }; 4C2E382616D1470200037A9D /* MPViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382516D1470200037A9D /* MPViewController.m */; }; + 4C305F36179A0BD70082334F /* KPKIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C305F35179A0BD70082334F /* KPKIcon.m */; }; + 4C305F3C179A19F90082334F /* KPKIconLoading.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C305F3B179A19F90082334F /* KPKIconLoading.m */; }; + 4C305F3E179A1A760082334F /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C305F3D179A1A760082334F /* image.png */; }; 4C3666411787327E00B249F1 /* MPDocument+Attachments.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */; }; 4C366643178748F500B249F1 /* 99_HarddiskTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C366642178748F500B249F1 /* 99_HarddiskTemplate.pdf */; }; 4C36E5B4177CD4FB00152132 /* Kdb4Tree+KVOAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C36E5B3177CD4FB00152132 /* Kdb4Tree+KVOAdditions.m */; }; @@ -330,6 +333,11 @@ 4C2E382216D1421B00037A9D /* MPIconHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconHelper.m; sourceTree = ""; }; 4C2E382416D1470200037A9D /* MPViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPViewController.h; sourceTree = ""; }; 4C2E382516D1470200037A9D /* MPViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPViewController.m; sourceTree = ""; }; + 4C305F34179A0BD70082334F /* KPKIcon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKIcon.h; sourceTree = ""; }; + 4C305F35179A0BD70082334F /* KPKIcon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKIcon.m; sourceTree = ""; }; + 4C305F3A179A19F90082334F /* KPKIconLoading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKIconLoading.h; sourceTree = ""; }; + 4C305F3B179A19F90082334F /* KPKIconLoading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKIconLoading.m; sourceTree = ""; }; + 4C305F3D179A1A760082334F /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = image.png; path = Images/image.png; sourceTree = ""; }; 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Attachments.m"; sourceTree = ""; }; 4C366642178748F500B249F1 /* 99_HarddiskTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 99_HarddiskTemplate.pdf; sourceTree = ""; }; 4C36E5B2177CD4FB00152132 /* Kdb4Tree+KVOAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Kdb4Tree+KVOAdditions.h"; sourceTree = ""; }; @@ -974,6 +982,14 @@ name = Helper; sourceTree = ""; }; + 4C305F3F179A1A790082334F /* Images */ = { + isa = PBXGroup; + children = ( + 4C305F3D179A1A760082334F /* image.png */, + ); + name = Images; + sourceTree = ""; + }; 4C37A84115B8B47D005EF8EE /* Delegates */ = { isa = PBXGroup; children = ( @@ -1021,6 +1037,7 @@ 4C45FB1E178E09ED0010007D /* MacPassTests */ = { isa = PBXGroup; children = ( + 4C305F3F179A1A790082334F /* Images */, 4C18F9AC178E123200890BCE /* Databases */, 4C45FB2B178E0BCB0010007D /* MPDatabaseLoading.h */, 4C45FB2C178E0BCB0010007D /* MPDatabaseLoading.m */, @@ -1029,6 +1046,8 @@ 4C19E501178E2871002F2CD0 /* MPDatabasePasswordAndKeyfile.h */, 4C19E502178E2871002F2CD0 /* MPDatabasePasswordAndKeyfile.m */, 4C45FB1F178E09ED0010007D /* Supporting Files */, + 4C305F3A179A19F90082334F /* KPKIconLoading.h */, + 4C305F3B179A19F90082334F /* KPKIconLoading.m */, ); path = MacPassTests; sourceTree = ""; @@ -1428,6 +1447,8 @@ 4CF62B85179385D700B660B6 /* KPKAttribute.m */, 4C5AA58F179549A1008ECAD7 /* KPKXmlTreeWriter.h */, 4C5AA590179549A1008ECAD7 /* KPKXmlTreeWriter.m */, + 4C305F34179A0BD70082334F /* KPKIcon.h */, + 4C305F35179A0BD70082334F /* KPKIcon.m */, ); path = Core; sourceTree = ""; @@ -1581,6 +1602,7 @@ 4C45FB23178E09ED0010007D /* InfoPlist.strings in Resources */, 4C18F9AB178E122500890BCE /* Test_Password_1234.kdb in Resources */, 4C19E500178E26EF002F2CD0 /* Test_Password_1234.kdbx in Resources */, + 4C305F3E179A1A760082334F /* image.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1661,6 +1683,7 @@ 4C45FB2D178E0BCB0010007D /* MPDatabaseLoading.m in Sources */, 4C45FB30178E0CE20010007D /* MPDatabaseCreation.m in Sources */, 4C19E503178E2871002F2CD0 /* MPDatabasePasswordAndKeyfile.m in Sources */, + 4C305F3C179A19F90082334F /* KPKIconLoading.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1838,6 +1861,7 @@ 4C4510091798C53700219998 /* StringField+Validation.m in Sources */, 4C45100C1798C65C00219998 /* Kdb4Entry+MPAdditions.m in Sources */, 4CFEB36E1799D9CF00AF1868 /* Kdb3Entry+KVOAdditions.m in Sources */, + 4C305F36179A0BD70082334F /* KPKIcon.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/Base.lproj/InspectorView.xib b/MacPass/Base.lproj/InspectorView.xib index 7711222c..d7f5c67f 100644 --- a/MacPass/Base.lproj/InspectorView.xib +++ b/MacPass/Base.lproj/InspectorView.xib @@ -32,6 +32,8 @@ NSTextField NSTextFieldCell NSTextView + NSTokenField + NSTokenFieldCell NSView @@ -202,13 +204,13 @@ {{0, 31}, {293, 399}} - + _NS:9 1 - + 256 @@ -216,6 +218,7 @@ 268 {{17, 365}, {35, 14}} + _NS:1535 YES @@ -248,6 +251,7 @@ 268 {{20, 335}, {253, 22}} + _NS:9 YES @@ -282,6 +286,7 @@ 268 {{17, 313}, {58, 14}} + _NS:1535 YES @@ -302,6 +307,7 @@ 268 {{20, 283}, {253, 22}} + _NS:9 YES @@ -323,6 +329,7 @@ 268 {{20, 231}, {253, 22}} + _NS:9 YES @@ -344,6 +351,7 @@ 268 {{17, 261}, {25, 14}} + _NS:1535 YES @@ -364,6 +372,7 @@ 268 {{17, 209}, {58, 14}} + _NS:1535 YES @@ -384,7 +393,8 @@ 268 {{20, 152}, {253, 19}} - + + _NS:9 {250, 750} YES @@ -413,6 +423,7 @@ 268 {{17, 35}, {259, 11}} + _NS:1535 YES @@ -437,7 +448,8 @@ 268 {{17, 16}, {259, 11}} - + + _NS:1535 YES @@ -457,6 +469,7 @@ 268 {{20, 179}, {214, 22}} + _NS:9 YES @@ -481,6 +494,7 @@ 268 {{242, 177}, {31, 25}} + _NS:22 YES @@ -504,8 +518,58 @@ NO + + + 268 + + NSStringPboardType + + {{20, 73}, {253, 50}} + + + + _NS:9 + YES + + 337641472 + 32768 + + _NS:9 + + + + + 0.0 + 0 + + NO + 2 + + + + 268 + {{17, 131}, {38, 14}} + + + + _NS:1535 + YES + + 68157504 + 272761856 + Tags + + _NS:1535 + + + + + NO + {293, 399} + + _NS:11 @@ -624,7 +688,6 @@ 256 {{236, 1}, {16, 332}} - _NS:83 NO @@ -893,7 +956,7 @@ - + 256 @@ -901,7 +964,6 @@ 268 {{241, 362}, {32, 19}} - _NS:9 YES @@ -927,7 +989,6 @@ 268 {{17, 365}, {80, 14}} - _NS:1535 YES @@ -957,7 +1018,6 @@ {259, 333} - _NS:13 YES @@ -1020,7 +1080,6 @@ {{1, 1}, {259, 333}} - _NS:11 @@ -1032,7 +1091,6 @@ -2147483392 {{224, 17}, {15, 102}} - _NS:58 NO @@ -1045,8 +1103,6 @@ -2147483392 {{1, 119}, {223, 15}} - - _NS:60 NO 1 @@ -1057,7 +1113,6 @@ {{16, 20}, {261, 335}} - _NS:9 133681 @@ -1071,8 +1126,6 @@ {293, 399} - - Fields @@ -1080,13 +1133,13 @@ - + 6 YES YES - + @@ -2279,7 +2332,7 @@ 3 1 - + 4 1 @@ -2355,6 +2408,86 @@ 29 3 + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 4 + 1 + + 8 + + 1000 + + 6 + 24 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + 3 @@ -2751,6 +2884,8 @@ + + @@ -4624,11 +4759,6 @@ - - 2322 - - - 2345 @@ -4874,6 +5004,104 @@ + + 2371 + + + + + + 8 + 0 + + 0 + 1 + + 50 + + 1000 + + 3 + 9 + 1 + + + + + + 2372 + + + + + 2380 + + + + + 2384 + + + + + + 7 + 0 + + 0 + 1 + + 32 + + 1000 + + 3 + 9 + 1 + + + + + + 2385 + + + + + 2388 + + + + + 2389 + + + + + 2391 + + + + + 2397 + + + + + 2398 + + + + + 2400 + + + + + 2401 + + + @@ -4955,6 +5183,11 @@ + + + + + @@ -5253,7 +5486,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin MPCustomFieldTableCellView @@ -5290,6 +5522,26 @@ 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 @@ -5336,7 +5588,7 @@ - 2370 + 2401 diff --git a/MacPassTests/CustomIcon_Password_1234.xml b/MacPassTests/Databases/CustomIcon_Password_1234.xml similarity index 100% rename from MacPassTests/CustomIcon_Password_1234.xml rename to MacPassTests/Databases/CustomIcon_Password_1234.xml diff --git a/MacPassTests/Images/image.png b/MacPassTests/Images/image.png new file mode 100644 index 0000000000000000000000000000000000000000..94f9b0ccfbada0ff079414fabe4a50bf7109ab17 GIT binary patch literal 803 zcmV+;1Kj+HP)$K>A1FLp?+@!I9*8ZJ(ZbWE3YD5g??8;!ektKfu7RPkM-Xsj1vzCnB$o1mZ>D^c@B_# z=HNaqq1R(vDuHoGxM5`w2Zk3a3C(}C>f7h9+-~>9TB#kfH%o6jtr%hi0xm%k1MIgF zr3^HC;fi4x*Y4a8nRjvSR(~pUX?nCcea_NIK0O41-a`=-7z5t!Y*+q#!yu;xwyRO6 zT-rQvmR4SX9}qVB_=B$lmNu zxwYH$bNM|lKYswShXBmxvSVY1$0v^pY2vEOn4(+d-6&#xNL8w>W5o&Io9rK#%gZaf zw%zIaj_uJtU8htEfeX2O=z9tXC{s0GD@3w+= zjW~V>N+F;aHnsWr%MsUfrJ6|?_IykL7aTDZBdNIiy~hk}5h*!^AO+~dyEoTXN}gAr zDW3THY!LzsIV4bpDluauR47Ftp+iy_5keLo-1%4iJ36vY;fbH6@(=A$O0x+~cRIFI hB1S+;K@+5?_8&0*nI;L(_L~3z002ovPDHLkV1mE^XW{?= literal 0 HcmV?d00001 diff --git a/MacPassTests/KPKIconLoading.h b/MacPassTests/KPKIconLoading.h new file mode 100644 index 00000000..49650387 --- /dev/null +++ b/MacPassTests/KPKIconLoading.h @@ -0,0 +1,16 @@ +// +// KPKIconLoading.h +// MacPass +// +// Created by Michael Starke on 20.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import + +@interface KPKIconLoading : SenTestCase { + NSImage *_image; + NSData *_imageData; +} + +@end diff --git a/MacPassTests/KPKIconLoading.m b/MacPassTests/KPKIconLoading.m new file mode 100644 index 00000000..9e84dbb0 --- /dev/null +++ b/MacPassTests/KPKIconLoading.m @@ -0,0 +1,43 @@ +// +// KPKIconLoading.m +// MacPass +// +// Created by Michael Starke on 20.07.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "KPKIconLoading.h" +#import "KPKIcon.h" + +@implementation KPKIconLoading + +- (void)setUp { + NSBundle *myBundle = [NSBundle bundleForClass:[self class]]; + _image = [myBundle imageForResource:@"image.png"]; + _imageData = [[[_image representations] lastObject] representationUsingType:NSPNGFileType properties:nil]; +} + +- (void)tearDown { + _image = nil; + _imageData = nil; +} + +- (void)testLoading { + NSBundle *myBundle = [NSBundle bundleForClass:[self class]]; + NSURL *imageURL = [myBundle URLForImageResource:@"image.png"]; + KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:imageURL]; + STAssertNotNil(icon, @"Icon should have been loaded"); + NSString *iconString = [icon encodedString]; + KPKIcon *iconFromString = [[KPKIcon alloc] initWithUUID:[NSUUID UUID] encodedString:iconString]; + STAssertTrue([iconString isEqualToString:[iconFromString encodedString]], @"Encoding and Decoding should result in the same string"); + Class repClass = [NSBitmapImageRep class]; + NSImageRep *imageRep = [[icon.image representations] lastObject]; + STAssertNotNil(imageRep, @"One image rep shoudl be there"); + STAssertTrue([imageRep isKindOfClass:repClass], @"Representation should be bitmap"); + NSBitmapImageRep *bitmapRep = (NSBitmapImageRep *)imageRep; + NSData *pngData = [bitmapRep representationUsingType:NSPNGFileType properties:nil]; + STAssertTrue([pngData isEqualToData:_imageData], @"Image and PNG data shoudl be identical"); + +} + +@end