mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
First stab at an executable that can be put into the SSH_ASKPASS environment variable to make GitX ask for passwords.
Set the environment variables for our tool. We have a rudimentary but working password panel now. Prettification later. Label on password window so it's less cryptic.
This commit is contained in:
committed by
Nathan Kinsinger
parent
de7d74cac8
commit
a6b5705a5f
@@ -67,6 +67,11 @@
|
||||
- (void)applicationDidFinishLaunching:(NSNotification*)notification
|
||||
{
|
||||
[[SUUpdater sharedUpdater] setSendsSystemProfile:YES];
|
||||
|
||||
// Make sure Git's SSH password requests get forwarded to our little UI tool:
|
||||
setenv( "SSH_ASKPASS", [[[NSBundle mainBundle] pathForResource: @"gitx_askpasswd" ofType: @""] UTF8String], 1 );
|
||||
setenv( "DISPLAY", "localhost:0", 1 );
|
||||
|
||||
[self registerServices];
|
||||
|
||||
BOOL hasOpenedDocuments = NO;
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
47DBDB6A0E94EF6500671A1E /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 47DBDB680E94EF6500671A1E /* Preferences.xib */; };
|
||||
47DBDBB10E94F6CA00671A1E /* Updates.png in Resources */ = {isa = PBXBuildFile; fileRef = 47DBDBB00E94F6CA00671A1E /* Updates.png */; };
|
||||
47DBDBCA0E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDBC90E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m */; };
|
||||
551BF11E112F376C00265053 /* gitx_askpasswd_main.m in Sources */ = {isa = PBXBuildFile; fileRef = 551BF11D112F376C00265053 /* gitx_askpasswd_main.m */; };
|
||||
551BF176112F3F4B00265053 /* gitx_askpasswd in Resources */ = {isa = PBXBuildFile; fileRef = 551BF111112F371800265053 /* gitx_askpasswd */; };
|
||||
770B37ED0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */; };
|
||||
77C8280E06725ACE000B614F /* ApplicationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C8280C06725ACE000B614F /* ApplicationController.m */; };
|
||||
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||
@@ -182,6 +184,13 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
551BF174112F3F3500265053 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 551BF110112F371800265053;
|
||||
remoteInfo = gitx_askpasswd;
|
||||
};
|
||||
913D5E590E5564F400CECEA2 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
@@ -236,6 +245,8 @@
|
||||
47DBDBB00E94F6CA00671A1E /* Updates.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Updates.png; path = Images/Preferences/Updates.png; sourceTree = "<group>"; };
|
||||
47DBDBC80E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBNSURLPathUserDefaultsTransfomer.h; sourceTree = "<group>"; };
|
||||
47DBDBC90E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBNSURLPathUserDefaultsTransfomer.m; sourceTree = "<group>"; };
|
||||
551BF111112F371800265053 /* gitx_askpasswd */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = gitx_askpasswd; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
551BF11D112F376C00265053 /* gitx_askpasswd_main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = gitx_askpasswd_main.m; sourceTree = "<group>"; };
|
||||
770B37EC0679A11B001EADE2 /* GitTest_DataModel.xcdatamodel */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.xcdatamodel; path = GitTest_DataModel.xcdatamodel; sourceTree = "<group>"; };
|
||||
77C82804067257F0000B614F /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
|
||||
77C8280B06725ACE000B614F /* ApplicationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationController.h; sourceTree = "<group>"; };
|
||||
@@ -434,6 +445,13 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
551BF10F112F371800265053 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
8D11072E0486CEB800E47090 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -512,6 +530,7 @@
|
||||
913D5E490E55644600CECEA2 /* gitx */,
|
||||
F5886A100ED5D33D0066E74C /* SpeedTest.app */,
|
||||
F567CC39106E6B910059BB9D /* GitXTesting.framework */,
|
||||
551BF111112F371800265053 /* gitx_askpasswd */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -528,6 +547,7 @@
|
||||
7756732906782D8800D1FEB8 /* Models */,
|
||||
080E96DDFE201D6D7F000001 /* Classes */,
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||
551BF118112F373E00265053 /* gitx_asskpasswd */,
|
||||
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||
@@ -612,6 +632,14 @@
|
||||
name = "Preference Icons";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
551BF118112F373E00265053 /* gitx_asskpasswd */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
551BF11D112F376C00265053 /* gitx_askpasswd_main.m */,
|
||||
);
|
||||
name = gitx_asskpasswd;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7756732906782D8800D1FEB8 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -931,6 +959,22 @@
|
||||
/* End PBXLegacyTarget section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
551BF110112F371800265053 /* gitx_askpasswd */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 551BF119112F373E00265053 /* Build configuration list for PBXNativeTarget "gitx_askpasswd" */;
|
||||
buildPhases = (
|
||||
551BF10E112F371800265053 /* Sources */,
|
||||
551BF10F112F371800265053 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = gitx_askpasswd;
|
||||
productName = gitx_askpasswd;
|
||||
productReference = 551BF111112F371800265053 /* gitx_askpasswd */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
8D1107260486CEB800E47090 /* GitX */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 26FC0A840875C7B200E6366F /* Build configuration list for PBXNativeTarget "GitX" */;
|
||||
@@ -944,6 +988,7 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
551BF175112F3F3500265053 /* PBXTargetDependency */,
|
||||
913D5E5A0E5564F400CECEA2 /* PBXTargetDependency */,
|
||||
F5643A020F792B4900A579C2 /* PBXTargetDependency */,
|
||||
D8022C1A11DFE8ED003C21F6 /* PBXTargetDependency */,
|
||||
@@ -1022,6 +1067,7 @@
|
||||
F56439F70F792B2100A579C2 /* Generate PList Prefix */,
|
||||
F567CC38106E6B910059BB9D /* GitXTesting */,
|
||||
D8022B1411DFCE7F003C21F6 /* libgit2 */,
|
||||
551BF110112F371800265053 /* gitx_askpasswd */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@@ -1033,6 +1079,7 @@
|
||||
files = (
|
||||
F5E92A1B0E88550E00056E75 /* empty_file.png in Resources */,
|
||||
913D5E500E55645900CECEA2 /* gitx in Resources */,
|
||||
551BF176112F3F4B00265053 /* gitx_askpasswd in Resources */,
|
||||
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
|
||||
F5B721C40E05CF7E00AF29DC /* MainMenu.xib in Resources */,
|
||||
911111E20E58BD5A00BF76B4 /* RepositoryWindow.xib in Resources */,
|
||||
@@ -1116,6 +1163,14 @@
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
551BF10E112F371800265053 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
551BF11E112F376C00265053 /* gitx_askpasswd_main.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
8D11072C0486CEB800E47090 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -1248,6 +1303,11 @@
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
551BF175112F3F3500265053 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 551BF110112F371800265053 /* gitx_askpasswd */;
|
||||
targetProxy = 551BF174112F3F3500265053 /* PBXContainerItemProxy */;
|
||||
};
|
||||
913D5E5A0E5564F400CECEA2 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 913D5E480E55644600CECEA2 /* cli tool */;
|
||||
@@ -1434,6 +1494,72 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
551BF113112F371800265053 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = gitx_askpasswd;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
551BF114112F371800265053 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = gitx_askpasswd;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
551BF115112F371800265053 /* Install */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
|
||||
INSTALL_PATH = /usr/local/bin;
|
||||
OTHER_LDFLAGS = (
|
||||
"-framework",
|
||||
Foundation,
|
||||
"-framework",
|
||||
AppKit,
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = gitx_askpasswd;
|
||||
};
|
||||
name = Install;
|
||||
};
|
||||
913D5E4B0E55644600CECEA2 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@@ -1666,6 +1792,16 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
551BF119112F373E00265053 /* Build configuration list for PBXNativeTarget "gitx_askpasswd" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
551BF113112F371800265053 /* Debug */,
|
||||
551BF114112F371800265053 /* Release */,
|
||||
551BF115112F371800265053 /* Install */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
913D5E570E55646100CECEA2 /* Build configuration list for PBXNativeTarget "cli tool" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* gitx_askpasswd_main.m
|
||||
* GitX
|
||||
*
|
||||
* Created by Uli Kusterer on 19.02.10.
|
||||
* Copyright 2010 The Void Software. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#define OKBUTTONWIDTH 100.0
|
||||
#define OKBUTTONHEIGHT 24.0
|
||||
#define CANCELBUTTONWIDTH 100.0
|
||||
#define CANCELBUTTONHEIGHT 24.0
|
||||
#define PASSHEIGHT 22.0
|
||||
#define PASSLABELHEIGHT 16.0
|
||||
|
||||
|
||||
@interface GAPAppDelegate : NSObject <NSApplicationDelegate>
|
||||
{
|
||||
NSPanel* mPasswordPanel;
|
||||
NSSecureTextField* mPasswordField;
|
||||
}
|
||||
|
||||
-(NSPanel*) passwordPanel;
|
||||
|
||||
-(IBAction) doOKButton: (id)sender;
|
||||
-(IBAction) doCancelButton: (id)sender;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation GAPAppDelegate
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
[mPasswordPanel release];
|
||||
mPasswordPanel = nil;
|
||||
|
||||
[mPasswordField release];
|
||||
mPasswordField = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(NSPanel*) passwordPanel
|
||||
{
|
||||
if( !mPasswordPanel )
|
||||
{
|
||||
NSRect box = NSMakeRect( 100, 100, 250, 100 );
|
||||
mPasswordPanel = [[NSPanel alloc] initWithContentRect: box
|
||||
styleMask: NSTitledWindowMask
|
||||
backing: NSBackingStoreBuffered defer: NO];
|
||||
[mPasswordPanel setHidesOnDeactivate: NO];
|
||||
[mPasswordPanel setLevel: NSFloatingWindowLevel];
|
||||
[mPasswordPanel center];
|
||||
|
||||
box.origin = NSZeroPoint; // Only need local coords from now on.
|
||||
|
||||
// OK:
|
||||
NSRect okBox = box;
|
||||
okBox.origin.x = NSMaxX( box ) -OKBUTTONWIDTH -10;
|
||||
okBox.size.width = OKBUTTONWIDTH;
|
||||
okBox.origin.y += 10;
|
||||
okBox.size.height = OKBUTTONHEIGHT;
|
||||
NSButton* okButton = [[[NSButton alloc] initWithFrame: okBox] autorelease];
|
||||
[okButton setTarget: self];
|
||||
[okButton setAction: @selector(doOKButton:)];
|
||||
[okButton setTitle: @"OK"]; // +++ Localize.
|
||||
[okButton setKeyEquivalent: @"\r"];
|
||||
[okButton setBordered: YES];
|
||||
[okButton setBezelStyle: NSRoundedBezelStyle];
|
||||
[[mPasswordPanel contentView] addSubview: okButton];
|
||||
|
||||
// Cancel:
|
||||
NSRect cancelBox = box;
|
||||
cancelBox.origin.x = NSMinX( okBox ) -CANCELBUTTONWIDTH -6;
|
||||
cancelBox.size.width = CANCELBUTTONWIDTH;
|
||||
cancelBox.origin.y += 10;
|
||||
cancelBox.size.height = CANCELBUTTONHEIGHT;
|
||||
okButton = [[[NSButton alloc] initWithFrame: cancelBox] autorelease];
|
||||
[okButton setTarget: self];
|
||||
[okButton setAction: @selector(doCancelButton:)];
|
||||
[okButton setTitle: @"Cancel"]; // +++ Localize.
|
||||
[okButton setBordered: YES];
|
||||
[okButton setBezelStyle: NSRoundedBezelStyle];
|
||||
[[mPasswordPanel contentView] addSubview: okButton];
|
||||
|
||||
// Password field:
|
||||
NSRect passBox = box;
|
||||
passBox.origin.y = NSMaxY(okBox) + 12;
|
||||
passBox.size.height = PASSHEIGHT;
|
||||
passBox.origin.x += 12;
|
||||
passBox.size.width -= 12 * 2;
|
||||
mPasswordField = [[NSSecureTextField alloc] initWithFrame: passBox];
|
||||
[mPasswordField setSelectable: YES];
|
||||
[mPasswordField setEditable: YES];
|
||||
[mPasswordField setBordered: YES];
|
||||
[mPasswordField setBezeled: YES];
|
||||
[mPasswordField setBezelStyle: NSTextFieldSquareBezel];
|
||||
[mPasswordField selectText: self];
|
||||
[[mPasswordPanel contentView] addSubview: mPasswordField];
|
||||
|
||||
// Password label:
|
||||
NSRect passLabelBox = box;
|
||||
passLabelBox.origin.y = NSMaxY(passBox) + 6;
|
||||
passLabelBox.size.height = PASSLABELHEIGHT;
|
||||
passLabelBox.origin.x += 12;
|
||||
passLabelBox.size.width -= 12 * 2;
|
||||
NSTextField* passwordLabel = [[[NSTextField alloc] initWithFrame: passLabelBox] autorelease];
|
||||
[passwordLabel setSelectable: YES];
|
||||
[passwordLabel setEditable: NO];
|
||||
[passwordLabel setBordered: NO];
|
||||
[passwordLabel setBezeled: NO];
|
||||
[passwordLabel setDrawsBackground: NO];
|
||||
[passwordLabel setStringValue: @"Please enter your password:"]; // +++ Localize.
|
||||
[[mPasswordPanel contentView] addSubview: passwordLabel];
|
||||
}
|
||||
|
||||
return mPasswordPanel;
|
||||
}
|
||||
|
||||
|
||||
-(IBAction) doOKButton: (id)sender
|
||||
{
|
||||
printf( "%s\n", [[mPasswordField stringValue] UTF8String] );
|
||||
[[NSApplication sharedApplication] terminate: self];
|
||||
}
|
||||
|
||||
|
||||
-(IBAction) doCancelButton: (id)sender
|
||||
{
|
||||
printf("\n");
|
||||
[[NSApplication sharedApplication] terminate: self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
{
|
||||
ProcessSerialNumber myPSN = { 0, kCurrentProcess };
|
||||
TransformProcessType( &myPSN, kProcessTransformToForegroundApplication );
|
||||
|
||||
NSApplication * app = [NSApplication sharedApplication];
|
||||
GAPAppDelegate * appDel = [[GAPAppDelegate alloc] init];
|
||||
[app setDelegate: appDel];
|
||||
NSWindow* passPanel = [appDel passwordPanel];
|
||||
|
||||
[app activateIgnoringOtherApps: YES];
|
||||
[passPanel makeKeyAndOrderFront: nil];
|
||||
[app runModalForWindow: passPanel];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user