Fixed isse with auto type skipping paste commands

Started implementing AutotypeFixDialog for 0.4.0 and 0.4.1 fix
Autotype candidate selection is shorter using subitems instead of single line
This commit is contained in:
michael starke
2014-03-26 22:29:45 +01:00
parent 478be2b9d9
commit edf4358388
12 changed files with 375 additions and 21 deletions

View File

@@ -16,6 +16,8 @@
4C0728BD17B5B7F7005A7DD9 /* MPPasswordEditWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0728BC17B5B7F7005A7DD9 /* MPPasswordEditWindowController.m */; };
4C0728BF17B68ED0005A7DD9 /* SavePanelAccessoryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0728BE17B68ED0005A7DD9 /* SavePanelAccessoryView.xib */; };
4C08C3AE17B3022400BBBC95 /* KPKLegacyHeaderWriter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C08C3AD17B3022400BBBC95 /* KPKLegacyHeaderWriter.m */; };
4C0B038C18E36DA400B9F9C9 /* MPFixAutotypeWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0B038A18E36DA400B9F9C9 /* MPFixAutotypeWindowController.m */; };
4C0B038D18E36DA400B9F9C9 /* FixAutotypeWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0B038B18E36DA400B9F9C9 /* FixAutotypeWindow.xib */; };
4C0C59F118B17F10009C7B76 /* DDHotKeyUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */; };
4C0DD6C618B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C0DD6C518B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib */; };
4C0F647817B6B65E00D9522A /* MPSheetWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C0F647717B6B65E00D9522A /* MPSheetWindowController.m */; };
@@ -377,6 +379,9 @@
4C08C3AC17B3022400BBBC95 /* KPKLegacyHeaderWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKLegacyHeaderWriter.h; sourceTree = "<group>"; };
4C08C3AD17B3022400BBBC95 /* KPKLegacyHeaderWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKLegacyHeaderWriter.m; sourceTree = "<group>"; };
4C08C3AF17B3036500BBBC95 /* KPKLegacyFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KPKLegacyFormat.h; path = Format/KPKLegacyFormat.h; sourceTree = "<group>"; };
4C0B038918E36DA400B9F9C9 /* MPFixAutotypeWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPFixAutotypeWindowController.h; sourceTree = "<group>"; };
4C0B038A18E36DA400B9F9C9 /* MPFixAutotypeWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPFixAutotypeWindowController.m; sourceTree = "<group>"; };
4C0B038B18E36DA400B9F9C9 /* FixAutotypeWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FixAutotypeWindow.xib; sourceTree = "<group>"; };
4C0C59EF18B17F10009C7B76 /* DDHotKeyUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DDHotKeyUtilities.m; path = DDHotKey/DDHotKeyUtilities.m; sourceTree = "<group>"; };
4C0C59F018B17F10009C7B76 /* DDHotKeyUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = DDHotKeyUtilities.h; path = DDHotKey/DDHotKeyUtilities.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
4C0DD6C518B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AutotypeCandidateSelectionWindow.xib; sourceTree = "<group>"; };
@@ -1879,6 +1884,8 @@
4CD5D704177A5F3300100649 /* MPDatabaseSettingsWindowController.m */,
4C0728BB17B5B7F7005A7DD9 /* MPPasswordEditWindowController.h */,
4C0728BC17B5B7F7005A7DD9 /* MPPasswordEditWindowController.m */,
4C0B038918E36DA400B9F9C9 /* MPFixAutotypeWindowController.h */,
4C0B038A18E36DA400B9F9C9 /* MPFixAutotypeWindowController.m */,
);
name = "Window Controller";
sourceTree = "<group>";
@@ -1895,6 +1902,7 @@
4CE8247216E2E99F00573141 /* Windows */ = {
isa = PBXGroup;
children = (
4C0B038B18E36DA400B9F9C9 /* FixAutotypeWindow.xib */,
4CA0B2EC15BCADAC00654E32 /* SettingsWindow.xib */,
4CD884B615BD47080042BBF8 /* DocumentWindow.xib */,
4C431BCE16E2BAB000700A81 /* OverlayWindow.xib */,
@@ -2153,6 +2161,7 @@
4C7ABA4917BAEC6700FF5799 /* 16_BrowserTemplate.pdf in Resources */,
4C7ABA4A17BAEC6700FF5799 /* 17_CDRomTemplate.pdf in Resources */,
4C7ABA4B17BAEC6700FF5799 /* 19_EmailTemplate.pdf in Resources */,
4C0B038D18E36DA400B9F9C9 /* FixAutotypeWindow.xib in Resources */,
4C0DD6C618B2A44700FCB193 /* AutotypeCandidateSelectionWindow.xib in Resources */,
4C7ABA4C17BAEC6700FF5799 /* 20_MiscTemplate.pdf in Resources */,
4C7ABA4E17BAEC7000FF5799 /* addEntryTemplate.pdf in Resources */,
@@ -2282,6 +2291,7 @@
4C245B7E176E1E3D0086100E /* MultipartMessageHeader.m in Sources */,
4C245B7F176E1E3D0086100E /* MultipartMessageHeaderField.m in Sources */,
4C245B80176E1E3D0086100E /* HTTPAsyncFileResponse.m in Sources */,
4C0B038C18E36DA400B9F9C9 /* MPFixAutotypeWindowController.m in Sources */,
4C245B81176E1E3D0086100E /* HTTPDataResponse.m in Sources */,
4C245B82176E1E3D0086100E /* HTTPDynamicFileResponse.m in Sources */,
4C245B83176E1E3D0086100E /* HTTPErrorResponse.m in Sources */,

View File

@@ -1,20 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPAutotypeDaemon">
<connections>
<outlet property="matchSelectionButton" destination="tAw-72-pSm" id="2a0-3C-UUB"/>
<outlet property="matchSelectionWindow" destination="1" id="ZYa-oC-Nfs"/>
<outlet property="performAutotypeButton" destination="Jlm-i9-jVy" id="Qjk-sL-Yqk"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<window title="Autotype Selection" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" releasedWhenClosed="NO" wantsToBeColor="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
<window title="Autotype Selection" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES"/>
<rect key="contentRect" x="196" y="240" width="370" height="156"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
@@ -33,7 +32,7 @@ Gw
</string>
</buttonCell>
<connections>
<action selector="orderOut:" target="-1" id="dcI-TT-kq3"/>
<action selector="cancelAutotypeSelection:" target="-2" id="nIA-o8-BE1"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Jlm-i9-jVy">
@@ -43,6 +42,9 @@ Gw
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="executeAutotypeWithSelectedMatch:" target="-2" id="icM-Aj-OHO"/>
</connections>
</button>
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="499" translatesAutoresizingMaskIntoConstraints="NO" id="tAw-72-pSm">
<rect key="frame" x="111" y="58" width="242" height="26"/>
@@ -95,4 +97,4 @@ Gw
</view>
</window>
</objects>
</document>
</document>

View File

@@ -112,6 +112,12 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="FVA-Cn-g79"/>
<menuItem title="Fix Autotype…" id="nx7-Vf-LiD">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="fixAutotype:" target="-1" id="eVm-am-dL6"/>
</connections>
</menuItem>
<menuItem title="Quicklook" keyEquivalent="y" id="aVO-9F-Lwc">
<connections>
<action selector="toggleQuicklookPreview:" target="-1" id="LeI-cb-9vg"/>

View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPFixAutotypeWindowController">
<connections>
<outlet property="window" destination="F0z-JX-Cv5" id="2rB-5S-9w4"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<window title="Fix Autotype" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="419" height="490"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="419" height="490"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="y73-eV-Aoo">
<rect key="frame" x="20" y="61" width="379" height="409"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" id="Phq-Ux-7lP">
<rect key="frame" x="1" y="17" width="377" height="391"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" autosaveColumns="NO" typeSelect="NO" headerView="wul-lK-g0n" id="nVa-6i-9j2">
<rect key="frame" x="0.0" y="0.0" width="377" height="391"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="TitleCell" width="116" minWidth="40" maxWidth="1000" id="Khy-1d-ouB">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Title">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="sgb-62-uBZ">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="AutotypeCell" width="144.35546875" minWidth="40" maxWidth="1000" id="zVR-Xo-8oY">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Keystroke Sequence">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="jVx-Lp-99P">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
<tableColumn identifier="IsDefaultCell" width="108" minWidth="10" maxWidth="3.4028234663852886e+38" id="0uz-Re-mk3">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Is default">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="vZ5-p4-TLR">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="9lW-qv-RkM"/>
<outlet property="delegate" destination="-2" id="QRO-Og-o8Q"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="UGM-Rv-JzB">
<rect key="frame" x="1" y="391" width="515" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="37" horizontal="NO" id="W8o-DQ-iiR">
<rect key="frame" x="-15" y="17" width="16" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="wul-lK-g0n">
<rect key="frame" x="0.0" y="0.0" width="377" height="17"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Ui-5h-uFs">
<rect key="frame" x="271" y="13" width="134" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Clear Autotype" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="sGh-Ec-oIL">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iZd-HT-6CT">
<rect key="frame" x="189" y="13" width="82" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="KhL-Mg-BJ7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
</buttonCell>
<connections>
<action selector="orderOut:" target="-1" id="BWI-LN-m2J"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="2Ui-5h-uFs" secondAttribute="trailing" constant="20" id="Enl-NU-6sz"/>
<constraint firstItem="2Ui-5h-uFs" firstAttribute="leading" secondItem="iZd-HT-6CT" secondAttribute="trailing" constant="12" id="K5O-HW-msJ"/>
<constraint firstAttribute="bottom" secondItem="2Ui-5h-uFs" secondAttribute="bottom" constant="20" id="Lfc-Fq-4IC"/>
<constraint firstItem="iZd-HT-6CT" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" symbolic="YES" id="cQL-6C-Wam"/>
<constraint firstAttribute="trailing" secondItem="y73-eV-Aoo" secondAttribute="trailing" constant="20" id="eEP-Dv-Nxs"/>
<constraint firstItem="y73-eV-Aoo" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" id="eTt-c8-ztu"/>
<constraint firstItem="iZd-HT-6CT" firstAttribute="centerY" secondItem="2Ui-5h-uFs" secondAttribute="centerY" id="fi6-45-S3y"/>
<constraint firstItem="y73-eV-Aoo" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="mkc-Fr-gJM"/>
<constraint firstItem="2Ui-5h-uFs" firstAttribute="top" secondItem="y73-eV-Aoo" secondAttribute="bottom" constant="20" id="xpf-JP-jIQ"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
</window>
</objects>
</document>

View File

@@ -35,6 +35,7 @@ FOUNDATION_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings;
- (IBAction)showPasswordCreator:(id)sender;
- (IBAction)createNewDatabase:(id)sender;
- (IBAction)openDatabase:(id)sender;
- (IBAction)fixAutotype:(id)sender;
/**
* Clears the stored key files for any documents.
* @param sender sender of this action

View File

@@ -31,6 +31,7 @@
#import "MPLockDaemon.h"
#import "MPAutotypeDaemon.h"
#import "MPDocumentWindowController.h"
#import "MPFixAutotypeWindowController.h"
#import "MPTemporaryFileStorageCenter.h"
@@ -50,6 +51,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
@property (strong, nonatomic) MPSettingsWindowController *settingsController;
@property (strong, nonatomic) MPPasswordCreatorViewController *passwordCreatorController;
@property (strong) MPFixAutotypeWindowController *fixAutotypeWindowController;
@end
@@ -219,6 +221,14 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kMPSettingsKeyRememeberdKeysForDatabases];
}
- (void)fixAutotype:(id)sender {
if(!self.fixAutotypeWindowController) {
self.fixAutotypeWindowController = [[MPFixAutotypeWindowController alloc] init];
}
[self.fixAutotypeWindowController reset];
[[self.fixAutotypeWindowController window] makeKeyAndOrderFront:sender];
}
#pragma mark -
#pragma mark Private Helper
- (void)_applicationDidFinishRestoringWindows:(NSNotification *)notification {

View File

@@ -13,14 +13,23 @@
/**
* The Autotype command reperesent a capsualted Action that was determined by interpreting
* Autotype field for a given entry. This is a class cluster and schould be considered the sole
* enty point for creating AutotypeCommands.
* enty point for creating AutotypeCommands. You should never need to build a command on your own.
*/
@interface MPAutotypeCommand : NSObject
@property (readonly, strong) MPAutotypeContext *context;
/**
* Creates a command sequence for the given context. The context's keystroke sequence is
* is evaluated (Placholders filled, references resolved) and the commands are created in the
* order of their execution
*
* @param context the context to create the comamnds from.
*
* @return NSArray of MPAutotypeCommand
*/
+ (NSArray *)commandsForContext:(MPAutotypeContext *)context;
/**
* Sends a KeyPress Event with the supplied modifier flags and Keycode
* Any existing modifiers will be disabled for this event. If the user
@@ -37,7 +46,7 @@
- (void)sendPasteKeyCode;
/**
* Exectues the Autotype Command. This will be called by the autotype daemon.
* Exectues the Autotype Command.
*/
- (void)execute;

View File

@@ -124,8 +124,7 @@
}
NSRange pasteRange = NSMakeRange(lastLocation, commandRange.location - lastLocation);
if(pasteRange.length > 0) {
NSString *pasteValue = [context.evaluatedCommand substringWithRange:NSMakeRange(lastLocation, commandRange.location - lastLocation)];
// Determin if it's amodifier key, and collect them!
NSString *pasteValue = [context.evaluatedCommand substringWithRange:pasteRange];
[self appendPasteCommandForContent:pasteValue toCommands:commands];
}
}
@@ -138,6 +137,15 @@
}
lastLocation = commandRange.location + commandRange.length;
}
/* Collect any part that isn't a command or if onyl paste is used */
if(lastLocation < [context.evaluatedCommand length]) {
NSRange pasteRange = NSMakeRange(lastLocation, [context.evaluatedCommand length] - lastLocation);
if(pasteRange.length > 0) {
NSString *pasteValue = [context.evaluatedCommand substringWithRange:pasteRange];
[self appendPasteCommandForContent:pasteValue toCommands:commands];
}
}
return commands;
}

View File

@@ -17,8 +17,8 @@
@property (strong) IBOutlet NSWindow *matchSelectionWindow;
@property (weak) IBOutlet NSPopUpButton *matchSelectionButton;
@property (weak) IBOutlet NSButton *performAutotypeButton;
- (void)exectureAutotypeForEntry:(KPKEntry *)entry withWindowTitle:(NSString *)title;
- (IBAction)executeAutotypeWithSelectedMatch:(id)sender;
- (IBAction)cancelAutotypeSelection:(id)sender;
@end

View File

@@ -66,7 +66,18 @@ NSString *const kMPApplciationNameKey = @"applicationName";
[self _performAutotypeForContext:context];
}
- (void)cancelAutotypeSelection:(id)sender {
[self.matchSelectionWindow orderOut:sender];
if(self.lastFrontMostApplication) {
[MPAutotypeDaemon _orderApplicationToFront:self.lastFrontMostApplication];
}
}
- (void)_didPressHotKey {
/* Reset the applciation on every keypress */
self.lastFrontMostApplication = nil;
NSArray *documents = [NSApp orderedDocuments];
MPDocument *currentDocument = nil;
for(MPDocument *openDocument in documents) {
@@ -105,11 +116,11 @@ NSString *const kMPApplciationNameKey = @"applicationName";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
[MPAutotypeDaemon _orderApplicationToFront:self.lastFrontMostApplication];
usleep(1000*1000);
BOOL lastCommandWasPaste = NO;
for(MPAutotypeCommand *command in commands) {
if(lastCommandWasPaste) {
usleep(500*1000);
NSLog(@"Sleeping for pasting!");
usleep(1000*1000);
}
[command execute];
lastCommandWasPaste = [command isKindOfClass:[MPAutotypePaste class]];
@@ -153,22 +164,26 @@ NSString *const kMPApplciationNameKey = @"applicationName";
- (void)_presentSelectionWindow:(NSArray *)candidates {
if(!self.matchSelectionWindow) {
[[NSBundle mainBundle] loadNibNamed:@"AutotypeCandidateSelectionWindow" owner:self topLevelObjects:nil];
[self.performAutotypeButton setTarget:self];
[self.performAutotypeButton setAction:@selector(executeAutotypeWithSelectedMatch:)];
[self.matchSelectionWindow setLevel:NSFloatingWindowLevel];
}
NSMenu *associationMenu = [[NSMenu alloc] init];
[associationMenu addItemWithTitle:NSLocalizedString(@"SELECT_AUTOTYPE_CANDIDATE", "") action:NULL keyEquivalent:@""];
[associationMenu addItem:[NSMenuItem separatorItem]];
[associationMenu setAutoenablesItems:NO];
NSString *entryMask = NSLocalizedString(@"TITLE_%@_USERNAME_%@_PASSWORD_%@_AUTOTYPE_SEQUENCE_%@", "Mask to create autotype entries for selection by the user. %1 Title %2 Username %3 Password %4 Sequence");
for(MPAutotypeContext *context in candidates) {
NSString *title = [[NSString alloc] initWithFormat:entryMask, context.entry.title, context.entry.username, context.entry.password, context.command];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:0 keyEquivalent:@""];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:context.entry.title action:0 keyEquivalent:@""];
[item setRepresentedObject:context];
[associationMenu addItem:item];
NSArray *attributes = @[ context.entry.username, context.command ];
for(NSString *value in attributes) {
NSMenuItem *valueItem = [[NSMenuItem alloc] initWithTitle:value action:NULL keyEquivalent:@""];
[valueItem setIndentationLevel:1];
[valueItem setEnabled:NO];
[associationMenu addItem:valueItem];
}
}
[self.matchSelectionButton setMenu:associationMenu];
[NSApp activateIgnoringOtherApps:YES];
[self.matchSelectionWindow makeKeyAndOrderFront:self];
/* Setup Items in Popup */
}
@@ -179,7 +194,7 @@ NSString *const kMPApplciationNameKey = @"applicationName";
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:appleScript];
NSDictionary *error;
NSAppleEventDescriptor *descriptor = [script executeAndReturnError:&error];
if(descriptor) {
if(!descriptor) {
NSLog(@"Error trying to execure %@: %@", script, error);
}
}

View File

@@ -0,0 +1,15 @@
//
// MPFixAutotypeWindowController.h
// MacPass
//
// Created by Michael Starke on 26/03/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface MPFixAutotypeWindowController : NSWindowController <NSTableViewDataSource, NSTableViewDelegate>
- (void)reset;
@end

View File

@@ -0,0 +1,139 @@
//
// MPFixAutotypeWindowController.m
// MacPass
//
// Created by Michael Starke on 26/03/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "MPFixAutotypeWindowController.h"
#import "MPDocument.h"
#import "KPKNode.h"
#import "KPKEntry.h"
#import "KPKGroup.h"
#import "KPKAutotype.h"
@interface KPKGroup (Breadcrumb)
- (NSString *)breadcrumb;
@end
@implementation KPKGroup (Breadcrumb)
- (NSString *)breadcrumb {
if(self.parent) {
return [[self.parent breadcrumb] stringByAppendingFormat:@" > %@", self.name];
}
return self.name;
}
@end
@interface MPFixAutotypeWindowController () {
NSMutableArray *_elements;
}
@property (weak) NSTableView *tableView;
@end
@implementation MPFixAutotypeWindowController
- (instancetype)init {
self = [super initWithWindowNibName:@"FixAutotypeWindow"];
return self;
}
- (instancetype)initWithWindow:(NSWindow *)window {
self = [super initWithWindow:window];
if (self) {
}
return self;
}
- (void)windowDidLoad {
[super windowDidLoad];
}
- (void)reset {
_elements = nil;
[self.tableView reloadData];
}
#pragma mark -
#pragma mark NSTableViewDataSource
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
self.tableView = tableView;
return [[self entriesAndGroups] count];
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
self.tableView = tableView;
id node = [self entriesAndGroups][row];
if([[tableColumn identifier] isEqualToString:@"TitleCell"]) {
if( [node respondsToSelector:@selector(title)]) {
return [node title];
}
return [node breadcrumb];
}
else if ([[tableColumn identifier] isEqualToString:@"AutotypeCell"]) {
if([node respondsToSelector:@selector(defaultAutoTypeSequence)]) {
return [node defaultAutoTypeSequence];
}
return [[node autotype] defaultKeystrokeSequence];
}
else if([[tableColumn identifier] isEqualToString:@"IsDefaultCell"]) {
BOOL isDefault = NO;
if([node respondsToSelector:@selector(hasDefaultAutotypeSequence)]) {
isDefault = [node hasDefaultAutotypeSequence];
}
else {
isDefault = [[node autotype] hasDefaultKeystrokeSequence];
}
return isDefault ? @"Yes" : @"No";
}
return nil;
}
#pragma mark -
#pragma mark NSTableViewDelegate
- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row {
id item = [self entriesAndGroups][row];
return [item isKindOfClass:[KPKGroup class]];
}
#pragma mark -
#pragma mark Data accessors
- (NSArray *)entriesAndGroups {
if(nil == _elements) {
NSArray *documents = [[NSDocumentController sharedDocumentController] documents];
_elements = [[NSMutableArray alloc] init];
for(MPDocument *document in documents) {
if(!document.root) {
continue;
}
KPKGroup *group = document.root;
[self flattenGroup:group toArray:_elements];
}
}
return _elements;
}
- (void)flattenGroup:(KPKGroup *)group toArray:(NSMutableArray *)array {
[array addObject:group];
[array addObjectsFromArray:group.entries];
for(KPKGroup *childGroup in group.groups) {
[self flattenGroup:childGroup toArray:array];
}
}
@end