InfoWindowController.m from redshed at Krugle
Show InfoWindowController.m syntax highlighted
#import "InfoWindowController.h"
@implementation InfoWindowController
- (void)awakeFromNib;
{
NSString *readmePath = [[NSBundle mainBundle] pathForResource: @"README" ofType: @"html"];
NSData *htmlData = [NSData dataWithContentsOfFile: readmePath];
NSMutableAttributedString *htmlString = [[NSMutableAttributedString alloc] initWithHTML:htmlData documentAttributes:nil];
[[readmeTextView textStorage] setAttributedString: htmlString];
[readmeTextView scrollPoint: NSMakePoint(0,0)];
[readmeTextView setNeedsDisplay: YES];
[htmlString release];
[mainWindow makeKeyAndOrderFront: nil];
}
- (void)windowWillClose:(NSNotification *)notification;
{
[[NSApplication sharedApplication] terminate:self];
}
- (NSString *) pluginDirPath
{
return [[NSBundle mainBundle] pathForResource: @"Project Builder Plug-ins" ofType: nil];
}
- (CFPropertyListRef) cleanseAndAddPluginPath: (CFPropertyListRef) plistRef
{
if (plistRef == NULL)
return (CFPropertyListRef) [NSArray arrayWithObject: [self pluginDirPath]];
else {
NSEnumerator *oE = [(NSArray *) plistRef objectEnumerator];
NSString *nP;
NSMutableArray *returnArray = [NSMutableArray array];
[returnArray addObject: [self pluginDirPath]];
while (nP = [oE nextObject]) {
if ([nP rangeOfString: @"SSHPassKey.app"].location != NSNotFound)
continue;
[returnArray addObject: nP];
}
return (CFPropertyListRef) returnArray;
}
}
- (IBAction) configurePBXSSHPassKeyPluginAction: sender;
{
NSBundle *pbxBundle = [NSBundle bundleWithPath: @"/Developer/Applications/Project Builder.app"];
CFStringRef pbxIdentifier = (CFStringRef) [pbxBundle bundleIdentifier];
CFStringRef pbxOtherPluginPref = (CFStringRef) @"PBXExtraPlugInFolders";
//! CFPropertyListRef otherPluginLocations;
// ensure latest stuff from PBX
CFPreferencesAppSynchronize(pbxIdentifier);
// other bundle search path
//! otherPluginLocations = CFPreferencesCopyAppValue(pbxOtherPluginPref, pbxIdentifier);
#warning BADNESS! This is how it should work, but doesn't due to a bug in PBX that will be fixed in the next release.
//! CFPreferencesSetAppValue(pbxOtherPluginPref, (CFStringRef) [self cleanseAndAddPluginPath: otherPluginLocations], pbxIdentifier);
CFPreferencesSetAppValue(pbxOtherPluginPref, (CFStringRef) [self pluginDirPath], pbxIdentifier);
// bundle configuration
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppEnabled", kCFBooleanTrue, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyForceCVSToUseSSH", kCFBooleanTrue, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppPath", (CFStringRef) [[NSBundle mainBundle] bundlePath], pbxIdentifier);
// write back to PBX
CFPreferencesAppSynchronize(pbxIdentifier);
}
- (IBAction) unconfigurePBXSSHPassKeyPluginAction: sender;
{
NSBundle *pbxBundle = [NSBundle bundleWithPath: @"/Developer/Applications/Project Builder.app"];
CFStringRef pbxIdentifier = (CFStringRef) [pbxBundle bundleIdentifier];
CFStringRef pbxOtherPluginPref = (CFStringRef) @"PBXExtraPlugInFolders";
CFPreferencesAppSynchronize(pbxIdentifier);
CFPreferencesSetAppValue(pbxOtherPluginPref, NULL, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppEnabled", NULL, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyForceCVSToUseSSH", NULL, pbxIdentifier);
CFPreferencesSetAppValue((CFStringRef) @"SSHPassKeyAppPath", NULL, pbxIdentifier);
CFPreferencesAppSynchronize(pbxIdentifier);
}
- (NSMutableDictionary *) mutableReadEnvironment: (NSString *) aPath
{
NSDictionary *contents = [NSDictionary dictionaryWithContentsOfFile: aPath];
if (!contents) contents = [NSDictionary dictionary];
return [[contents mutableCopy] autorelease];
}
+ (NSString *) mosxEnvironmentPath
{
static NSString *mosxEnvironmentPath = nil;
if (mosxEnvironmentPath == nil)
mosxEnvironmentPath = [[@"~/.MacOSX/environment.plist" stringByStandardizingPath] retain];
return mosxEnvironmentPath;
}
- (IBAction) configureSSHPassKeyLoginEnvironment: sender;
{
NSFileManager *defaultManager = [NSFileManager defaultManager];
NSString *mosxEnvironmentPath = [[self class] mosxEnvironmentPath];
NSString *mosxDirectory = [mosxEnvironmentPath stringByDeletingLastPathComponent];
NSMutableDictionary *environment;
BOOL isDirectory;
if (![defaultManager fileExistsAtPath: mosxDirectory isDirectory: &isDirectory]) {
if (![defaultManager createDirectoryAtPath:mosxDirectory attributes:nil])
[NSException raise: NSInternalInconsistencyException
format: @"Failed to create directory at %@", mosxDirectory];
}
environment = [self mutableReadEnvironment: mosxEnvironmentPath];
[environment setObject: @"ssh" forKey: @"CVS_RSH"];
[environment setObject: @"localhost" forKey: @"DISPLAY"];
[environment setObject: [[NSBundle mainBundle] executablePath] forKey: @"SSH_ASKPASS"];
if (![environment writeToFile:mosxEnvironmentPath atomically:YES])
[NSException raise: NSInternalInconsistencyException
format: @"Failed to write environment file at %@", mosxEnvironmentPath];
}
- (IBAction) unconfigureSSHPassKeyLoginEnvironment: sender;
{
NSString *mosxEnvironmentPath = [[self class] mosxEnvironmentPath];
NSMutableDictionary *environment;
if (![[NSFileManager defaultManager] fileExistsAtPath: mosxEnvironmentPath isDirectory: NULL]) return; // nothing to do
environment = [self mutableReadEnvironment: mosxEnvironmentPath];
[environment removeObjectForKey: @"CVS_RSH"];
[environment removeObjectForKey: @"DISPLAY"];
[environment removeObjectForKey: @"SSH_ASKPASS"];
if ([environment count]) {
if (![environment writeToFile:mosxEnvironmentPath atomically:YES])
[NSException raise: NSInternalInconsistencyException
format: @"Failed to write environment file at %@", mosxEnvironmentPath];
} else {
if (![[NSFileManager defaultManager] removeFileAtPath: mosxEnvironmentPath handler: nil])
[NSException raise: NSInternalInconsistencyException
format: @"Failed to remove otherwise empty environment file at %@", mosxEnvironmentPath];
}
}
@end
/*
Copyright (c) 2002 CodeFab, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
See more files for this project here