diff --git a/KeePassKit b/KeePassKit index 07349e3b..cad68d0f 160000 --- a/KeePassKit +++ b/KeePassKit @@ -1 +1 @@ -Subproject commit 07349e3bcbce3c3c16fcd3143d5c06efdedd40ce +Subproject commit cad68d0f6bf914b394551827ab8e4b2fc3f2fa25 diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index a74b28ac..87ae9645 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -259,6 +259,7 @@ 4CECB31717AC326D00EAFB0F /* KPKLegacyWritingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CECB31617AC326D00EAFB0F /* KPKLegacyWritingTest.m */; }; 4CF1F0CA1786B37900CD920E /* NSData+Gzip.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF1F0C81786B37900CD920E /* NSData+Gzip.m */; }; 4CF29BF417879D0000851B60 /* 26_FileSaveTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */; }; + 4CF4FEE017AEA4A400712774 /* UUID+Pasterboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF4FEDF17AEA4A400712774 /* UUID+Pasterboard.m */; }; 4CF62B86179385D700B660B6 /* KPKAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF62B85179385D700B660B6 /* KPKAttribute.m */; }; 4CF6C711176F4533007A811D /* MPStringLengthValueTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */; }; 4CF6C718176F5234007A811D /* MPAssociateRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF6C717176F5234007A811D /* MPAssociateRequestHandler.m */; }; @@ -756,6 +757,8 @@ 4CF1F0C81786B37900CD920E /* NSData+Gzip.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Gzip.m"; sourceTree = ""; }; 4CF1F0C91786B37900CD920E /* NSData+Gzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Gzip.h"; sourceTree = ""; }; 4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 26_FileSaveTemplate.pdf; sourceTree = ""; }; + 4CF4FEDE17AEA4A400712774 /* UUID+Pasterboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UUID+Pasterboard.h"; sourceTree = ""; }; + 4CF4FEDF17AEA4A400712774 /* UUID+Pasterboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UUID+Pasterboard.m"; sourceTree = ""; }; 4CF62B84179385D700B660B6 /* KPKAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKAttribute.h; sourceTree = ""; }; 4CF62B85179385D700B660B6 /* KPKAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKAttribute.m; sourceTree = ""; }; 4CF6C70F176F4533007A811D /* MPStringLengthValueTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPStringLengthValueTransformer.h; sourceTree = ""; }; @@ -1090,6 +1093,8 @@ 4C45100B1798C65C00219998 /* Kdb4Entry+MPAdditions.m */, 4CFB5E9D17AAD20200D9B10C /* Kdb4Group+Undo.h */, 4CFB5E9E17AAD20200D9B10C /* Kdb4Group+Undo.m */, + 4CF4FEDE17AEA4A400712774 /* UUID+Pasterboard.h */, + 4CF4FEDF17AEA4A400712774 /* UUID+Pasterboard.m */, ); name = "KeePassLib Categories"; sourceTree = ""; @@ -2094,6 +2099,7 @@ 4C79E80317A9187400AC6CD2 /* KPKXmlHeaderWriter.m in Sources */, 4CFB5E9F17AAD20200D9B10C /* Kdb4Group+Undo.m in Sources */, 4CE3E62617AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m in Sources */, + 4CF4FEE017AEA4A400712774 /* UUID+Pasterboard.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacPass/MPConstants.h b/MacPass/MPConstants.h index 76b59e62..9383a904 100644 --- a/MacPass/MPConstants.h +++ b/MacPass/MPConstants.h @@ -14,6 +14,7 @@ FOUNDATION_EXPORT NSString *const MPPasteBoardType; FOUNDATION_EXPORT NSString *const MPEntryUTI; FOUNDATION_EXPORT NSString *const MPGroupUTI; +FOUNDATION_EXTERN NSString *const MPUUIDUTI; FOUNDATION_EXPORT NSString *const MPErrorDomain; #endif diff --git a/MacPass/MPConstants.m b/MacPass/MPConstants.m index 6fb5e239..7a41b620 100644 --- a/MacPass/MPConstants.m +++ b/MacPass/MPConstants.m @@ -11,4 +11,5 @@ NSString *const MPPasteBoardType = @"com.hicknhack.macpass.pasteboard"; NSString *const MPErrorDomain = @"com.hicknhack.macpass.error"; NSString *const MPEntryUTI = @"com.hicknhack.macpass.entry"; -NSString *const MPGroupUTI = @"com.hicknhack.macpass.group"; \ No newline at end of file +NSString *const MPGroupUTI = @"com.hicknhack.macpass.group"; +NSString *const MPUUIDUTI = @"com.hicknhack.macpass.UUID"; \ No newline at end of file diff --git a/MacPass/MPEntryTableDataSource.m b/MacPass/MPEntryTableDataSource.m index 7efab818..15efca88 100644 --- a/MacPass/MPEntryTableDataSource.m +++ b/MacPass/MPEntryTableDataSource.m @@ -8,7 +8,10 @@ #import "MPEntryTableDataSource.h" #import "MPEntryViewController.h" -#import "UUID.h" + +#import "Kdb.h" +#import "UUID+Pasterboard.h" + #import "MPConstants.h" @interface MPEntryTableDataSource () @@ -23,19 +26,13 @@ return NO; // No valid drag } - id entry = [self.viewController.entryArrayController arrangedObjects][[rowIndexes firstIndex]]; - - if(![entry respondsToSelector:@selector(uuid)]) { - return NO; // Invalid item for dragging + id item = [self.viewController.entryArrayController arrangedObjects][[rowIndexes firstIndex]]; + if(![item isKindOfClass:[KdbEntry class]]) { + return NO; } - UUID *uuid = (UUID *)[entry uuid]; - NSPasteboardItem *pBoardItem = [[NSPasteboardItem alloc] init]; - [pBoardItem setString:[uuid description] forType:MPPasteBoardType]; - [pboard writeObjects:@[pBoardItem]]; - + KdbEntry *entry = (KdbEntry *)item; + [pboard writeObjects:@[entry.uuid]]; return YES; } -//TODO: Validation and adding - @end diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index ec266956..7adcfe5b 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -138,7 +138,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername"; [self.entryTable setDoubleAction:@selector(_columnDoubleClick:)]; [self.entryTable setTarget:self]; [self.entryTable setFloatsGroupRows:NO]; - //[self.entryTable registerForDraggedTypes:@[MPPasteBoardType]]; + [self.entryTable registerForDraggedTypes:@[MPEntryUTI]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didBecomFirstResponder:) name:MPDidActivateViewNotification diff --git a/MacPass/MPOutlineDataSource.h b/MacPass/MPOutlineDataSource.h index abd4252e..efcb3082 100644 --- a/MacPass/MPOutlineDataSource.h +++ b/MacPass/MPOutlineDataSource.h @@ -8,9 +8,6 @@ #import -@class KdbGroup; +@interface MPOutlineDataSource : NSObject -@interface MPOutlineDataSource : NSObject { - KdbGroup *_draggedItem; -} @end diff --git a/MacPass/MPOutlineDataSource.m b/MacPass/MPOutlineDataSource.m index 9660c9a9..4440fe89 100644 --- a/MacPass/MPOutlineDataSource.m +++ b/MacPass/MPOutlineDataSource.m @@ -17,25 +17,30 @@ #import "KdbGroup+MPTreeTools.h" #import "KdbEntry+MPTreeTools.h" - #import "UUID.h" +#import "UUID+Pasterboard.h" + +@interface MPOutlineDataSource () + +@property (weak) KdbGroup *draggedGroup; + +@end + @implementation MPOutlineDataSource - - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pasteboard { - _draggedItem = nil; - [pasteboard setString:@"Weee" forType:MPPasteBoardType]; + self.draggedGroup = nil; if([items count] == 1) { - _draggedItem = [[items lastObject] representedObject]; - return (nil != _draggedItem.parent); + [pasteboard setString:self.draggedGroup.name forType:MPGroupUTI]; + self.draggedGroup = [[items lastObject] representedObject]; + return (nil != self.draggedGroup.parent); } - return YES; + return NO; } - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id)info proposedItem:(id)item proposedChildIndex:(NSInteger)index { - if(_draggedItem) { - info.animatesToDestination = YES; + /* info.animatesToDestination = YES; NSDragOperation oprationMask = NSDragOperationMove; if([info draggingSourceOperationMask] == NSDragOperationCopy) { oprationMask = NSDragOperationCopy; @@ -50,9 +55,9 @@ } KdbGroup *targetGroup = targetItem; BOOL validTarget = YES; - if( _draggedItem.parent == targetGroup ) { + if( self.draggedGroup.parent == targetGroup ) { validTarget &= index != NSOutlineViewDropOnItemIndex; - validTarget &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem]; + validTarget &= index != [self.draggedGroup.parent.groups indexOfObject:self.draggedGroup]; } if( validTarget ) { return oprationMask; @@ -65,23 +70,27 @@ [outlineView setDropItem:item dropChildIndex:NSOutlineViewDropOnItemIndex]; } return NSDragOperationMove; - } + }*/ + self.draggedGroup = nil; return NSDragOperationNone; } - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id)info item:(id)item childIndex:(NSInteger)index { - KdbGroup *target = [item representedObject]; - if(_draggedItem) { + self.draggedGroup = nil; + /* + KdbGroup *target = [item representedObject]; + if(self.draggedGroup) { BOOL accepted = YES; - if( _draggedItem.parent == target ) { + if( self.draggedGroup.parent == target ) { accepted &= index != NSOutlineViewDropOnItemIndex; - accepted &= index != [_draggedItem.parent.groups indexOfObject:_draggedItem]; + accepted &= index != [self.draggedGroup.parent.groups indexOfObject:self.draggedGroup]; } - accepted = ![_draggedItem isAnchestorOfGroup:target]; + accepted = ![self.draggedGroup isAnchestorOfGroup:target]; if( accepted ) { - [_draggedItem moveToGroupUndoable:target atIndex:index]; + [self.draggedGroup moveToGroupUndoable:target atIndex:index]; } info.animatesToDestination = !accepted; + self.draggedGroup = nil; return accepted; } NSPasteboard *pasteBoard = [info draggingPasteboard]; @@ -99,6 +108,7 @@ } } } + */ return NO; } @end diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 815ac450..152c9fe1 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -72,7 +72,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; [_outlineView setMenu:[self _contextMenu]]; [_outlineView setAllowsEmptySelection:YES]; [_outlineView setFloatsGroupRows:NO]; - //[_outlineView registerForDraggedTypes:@[ MPPasteBoardType ]]; + [_outlineView registerForDraggedTypes:@[ MPGroupUTI, MPEntryUTI, MPUUIDUTI ]]; [_outlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; [_bottomBar setBorderType:HNHBorderTop]; [_addGroupButton setAction:[MPActionHelper actionOfType:MPActionAddGroup]]; diff --git a/MacPass/UUID+Pasterboard.h b/MacPass/UUID+Pasterboard.h new file mode 100644 index 00000000..3b7d161f --- /dev/null +++ b/MacPass/UUID+Pasterboard.h @@ -0,0 +1,13 @@ +// +// UUID+Pasterboard.h +// MacPass +// +// Created by Michael Starke on 04.08.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "UUID.h" + +@interface UUID (Pasterboard) + +@end diff --git a/MacPass/UUID+Pasterboard.m b/MacPass/UUID+Pasterboard.m new file mode 100644 index 00000000..0949d1ab --- /dev/null +++ b/MacPass/UUID+Pasterboard.m @@ -0,0 +1,49 @@ +// +// UUID+Pasterboard.m +// MacPass +// +// Created by Michael Starke on 04.08.13. +// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved. +// + +#import "UUID+Pasterboard.h" +#import "MPConstants.h" + +@implementation UUID (Pasterboard) + +#pragma mark NSCoding + +- (id)initWithCoder:(NSCoder *)aDecoder { + NSData *data = [aDecoder decodeObjectForKey:@"data"]; + self = [self initWithData:data]; + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:[self getData] forKey:@"data"]; +} + +#pragma mark - +#pragma mark NSPasteboardReading + ++ (NSArray *)readableTypesForPasteboard:(NSPasteboard *)pasteboard { + return @[ MPUUIDUTI ]; +} + ++ (NSPasteboardReadingOptions)readingOptionsForType:(NSString *)type pasteboard:(NSPasteboard *)pasteboard { + NSAssert([type isEqualToString:MPUUIDUTI], @"Only MPUUID type is supported"); + return NSPasteboardReadingAsKeyedArchive; +} +#pragma mark - +#pragma mark NSPasteboardWriting + +- (id)pasteboardPropertyListForType:(NSString *)type { + NSAssert([type isEqualToString:MPUUIDUTI], @"Only MPUUID type is supported"); + return [NSKeyedArchiver archivedDataWithRootObject:self]; +} + +- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard { + return @[ MPUUIDUTI ]; +} + +@end diff --git a/MiniKeePassLib b/MiniKeePassLib index 692f6fbf..f8829af2 160000 --- a/MiniKeePassLib +++ b/MiniKeePassLib @@ -1 +1 @@ -Subproject commit 692f6fbf1188ad50899c9fc9084a5e1d1e9c09f5 +Subproject commit f8829af211aa784a298dca28d67f3a0c2c7d7438