Skip to content

Commit

Permalink
Added droplet ssh users support
Browse files Browse the repository at this point in the history
  • Loading branch information
deivuh committed May 7, 2014
1 parent 825bf5d commit f732459
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 19 deletions.
30 changes: 29 additions & 1 deletion DODropletManager/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ @implementation AppDelegate {
BOOL firstRun;

DropletManager *dropletManager;

NSUserDefaults *userdefaults;
NSMutableDictionary *sshUserDictionary;


}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
Expand All @@ -56,6 +61,17 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
name:@"dropletsFailed"
object:nil];


userdefaults = [NSUserDefaults standardUserDefaults];


// If dictionary exists, load it from userDefaults;
if ([userdefaults objectForKey:@"sshUserDictionary"] == nil) {
sshUserDictionary = [[NSMutableDictionary alloc] init];
} else {
sshUserDictionary = [[userdefaults objectForKey:@"sshUserDictionary"] mutableCopy];
}

}

- (BOOL)loadKeys {
Expand Down Expand Up @@ -312,8 +328,20 @@ - (void)viewDropletOnBrowser:(id)sender {
}

- (void)establishSSHConnectionToDroplet:(id)sender {




Droplet *currentDroplet = ((NSMenuItem*)sender).representedObject;
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"ssh://root@%@", currentDroplet.ip]]];


if ([sshUserDictionary objectForKey:currentDroplet.name] == nil) {
[sshUserDictionary setObject:@"root" forKey:currentDroplet.name];
}

NSString *dropletSSHUsername = [sshUserDictionary objectForKey:currentDroplet.name];

[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"ssh://%@@%@", dropletSSHUsername, currentDroplet.ip]]];
}

- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
Expand Down
4 changes: 2 additions & 2 deletions DODropletManager/DODropletManager-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<string>0.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>4</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>LSUIElement</key>
Expand Down
Loading

0 comments on commit f732459

Please sign in to comment.