Changeset 29
- Timestamp:
- 12/08/04 21:00:51 (4 years ago)
- Files:
-
- trunk/NSMenu_Additions.h (added)
- trunk/NSMenu_Additions.m (added)
- trunk/PreferenceController.m (modified) (3 diffs)
- trunk/PreferenceViews/TunnelsView.m (modified) (7 diffs)
- trunk/SSHKeychain.xcode/project.pbxproj (modified) (6 diffs)
- trunk/TODO (modified) (1 diff)
- trunk/TunnelController.h (modified) (1 diff)
- trunk/TunnelController.m (modified) (24 diffs)
- trunk/Utilities.h (added)
- trunk/Utilities.m (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/PreferenceController.m
r28 r29 7 7 - (id)init 8 8 { 9 if(!(self = [super init])) 10 { 11 return nil; 12 } 13 14 sharedPreferenceController = self; 15 16 [NSBundle loadNibNamed:@"Preferences" owner:sharedPreferenceController]; 17 18 blankView = [[NSView alloc] init]; 9 if(self = [super init]) 10 { 11 sharedPreferenceController = self; 12 13 blankView = [[NSView alloc] init]; 14 15 [NSBundle loadNibNamed:@"Preferences" owner:sharedPreferenceController]; 16 } 19 17 20 18 return self; … … 23 21 - (void)dealloc 24 22 { 25 [blankView dealloc];23 [blankView release]; 26 24 [super dealloc]; 27 25 } … … 145 143 { 146 144 if(([array objectAtIndex:1]) && (currentController != [array objectAtIndex:1])) 147 {145 { 148 146 [currentController closePreferences]; 149 147 trunk/PreferenceViews/TunnelsView.m
r28 r29 3 3 #import "PreferenceController.h" 4 4 #import "TunnelController.h" 5 #import "Utilities.h" 5 6 6 7 @implementation TunnelsView 7 8 8 - (void) awakeFromNib { 9 if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_2) { 9 - (void) awakeFromNib 10 { 11 if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_2) 12 { 10 13 // Ack, we gotta disable the dynamic ports tab 11 14 int dynamicTabIndex = [tunnelDetailsTabView indexOfTabViewItemWithIdentifier:@"dynamicPorts"]; … … 20 23 { 21 24 /* Get all tunnels. */ 22 tunnels = [[NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:tunnelsString]] retain]; 25 [[NSUserDefaults standardUserDefaults] synchronize]; 26 tunnels = [[NSMutableArray alloc] initWithArray: 27 [[NSUserDefaults standardUserDefaults] arrayForKey:tunnelsString]]; 23 28 24 29 if(!tunnels) { … … 53 58 - (IBAction)addTunnel:(id)sender 54 59 { 55 int i;56 60 BOOL match = NO; 57 61 58 for(i=0; i < [tunnels count]; i++) { 59 if([[[tunnels objectAtIndex:i] objectForKey:@"TunnelName"] isEqualToString:@"New Tunnel"]) { 62 NSEnumerator *e = [tunnels objectEnumerator]; 63 NSDictionary *aTunnel; 64 while (aTunnel = [e nextObject]) 65 { 66 if ([[aTunnel objectForKey:@"TunnelName"] isEqualToString:@"New Tunnel"]) 67 { 60 68 match = YES; 61 69 } 62 70 } 63 71 64 if (!match)72 if (!match) 65 73 { 66 74 NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; 67 75 [dict setObject:@"New Tunnel" forKey:@"TunnelName"]; 76 [dict setObject:CreateUUID() forKey:@"TunnelUUID"]; 68 77 69 78 [tunnels addObject:dict]; … … 89 98 [self hideTunnelDetails]; 90 99 91 [[TunnelController sharedController] removeTunnelWith Name:[[tunnels objectAtIndex:index] objectForKey:@"TunnelName"]];100 [[TunnelController sharedController] removeTunnelWithUUID:[[tunnels objectAtIndex:index] objectForKey:@"TunnelUUID"]]; 92 101 [tunnels removeObjectAtIndex:index]; 93 102 … … 362 371 - (void)saveTunnelDetails 363 372 { 364 NSMutableDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];365 366 373 if(tunnelIndex < 0) 367 374 { … … 369 376 } 370 377 378 NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:[tunnels objectAtIndex:tunnelIndex]]; 371 379 372 380 if([[tunnelName stringValue] isEqualToString:@""]) { [tunnelName setStringValue:@"Some Tunnel"]; } … … 377 385 if(![[[tunnels objectAtIndex:tunnelIndex] objectForKey:@"TunnelName"] isEqualToString:[tunnelName stringValue]]) 378 386 { 379 [[TunnelController sharedController] changeTunnel Name:[[tunnels objectAtIndex:tunnelIndex] objectForKey:@"TunnelName"]380 toName:[tunnelName stringValue]];387 [[TunnelController sharedController] changeTunnel:[[tunnels objectAtIndex:tunnelIndex] objectForKey:@"TunnelUUID"] 388 setName:[tunnelName stringValue]]; 381 389 } 382 390 trunk/SSHKeychain.xcode/project.pbxproj
r25 r29 57 57 shellScript = "echo \"Cleaning up unneeded files...\"\nfind $BUILD_ROOT/$WRAPPER_NAME '(' -name '.svn' -or -name '.DS_Store' ')' -prune -exec rm -rf '{}' ';'"; 58 58 }; 59 0A7F548E07676EB500E1C1E4 = { 60 fileEncoding = 4; 61 isa = PBXFileReference; 62 lastKnownFileType = sourcecode.c.h; 63 path = Utilities.h; 64 refType = 4; 65 sourceTree = "<group>"; 66 }; 67 0A7F548F07676EB500E1C1E4 = { 68 fileEncoding = 4; 69 isa = PBXFileReference; 70 lastKnownFileType = sourcecode.c.objc; 71 path = Utilities.m; 72 refType = 4; 73 sourceTree = "<group>"; 74 }; 75 0A7F549007676EB500E1C1E4 = { 76 fileRef = 0A7F548E07676EB500E1C1E4; 77 isa = PBXBuildFile; 78 settings = { 79 }; 80 }; 81 0A7F549107676EB500E1C1E4 = { 82 fileRef = 0A7F548F07676EB500E1C1E4; 83 isa = PBXBuildFile; 84 settings = { 85 }; 86 }; 87 0A7F549A07676F2400E1C1E4 = { 88 isa = PBXFileReference; 89 lastKnownFileType = wrapper.framework; 90 name = Carbon.framework; 91 path = /System/Library/Frameworks/Carbon.framework; 92 refType = 0; 93 sourceTree = "<absolute>"; 94 }; 95 0A7F549B07676F2400E1C1E4 = { 96 fileRef = 0A7F549A07676F2400E1C1E4; 97 isa = PBXBuildFile; 98 settings = { 99 }; 100 }; 101 0A7F554E07677DCC00E1C1E4 = { 102 fileEncoding = 4; 103 isa = PBXFileReference; 104 lastKnownFileType = sourcecode.c.h; 105 path = NSMenu_Additions.h; 106 refType = 4; 107 sourceTree = "<group>"; 108 }; 109 0A7F554F07677DCC00E1C1E4 = { 110 fileEncoding = 4; 111 isa = PBXFileReference; 112 lastKnownFileType = sourcecode.c.objc; 113 path = NSMenu_Additions.m; 114 refType = 4; 115 sourceTree = "<group>"; 116 }; 117 0A7F555007677DCC00E1C1E4 = { 118 fileRef = 0A7F554E07677DCC00E1C1E4; 119 isa = PBXBuildFile; 120 settings = { 121 }; 122 }; 123 0A7F555107677DCC00E1C1E4 = { 124 fileRef = 0A7F554F07677DCC00E1C1E4; 125 isa = PBXBuildFile; 126 settings = { 127 }; 128 }; 59 129 0A925562075F22B800B98A2B = { 60 130 isa = PBXFileReference; … … 86 156 CCC9E42906A6763E00422E9E, 87 157 1058C7A1FEA54F0111CA2CBB, 158 0A7F549A07676F2400E1C1E4, 88 159 ); 89 160 isa = PBXGroup; … … 182 253 29B97315FDCFA39411CA2CEA = { 183 254 children = ( 255 0A7F554E07677DCC00E1C1E4, 256 0A7F554F07677DCC00E1C1E4, 257 0A7F548E07676EB500E1C1E4, 258 0A7F548F07676EB500E1C1E4, 184 259 32CA4F630368D1EE00C91783, 185 260 CCCDD4A706A576CF00B68ED1, … … 377 452 CC586C5106C3D56A00D73261, 378 453 CC6C191507421C8700CB0A18, 454 0A7F549007676EB500E1C1E4, 455 0A7F555007677DCC00E1C1E4, 379 456 ); 380 457 isa = PBXHeadersBuildPhase; … … 433 510 CC586C5206C3D56A00D73261, 434 511 CC6C191607421C8700CB0A18, 512 0A7F549107676EB500E1C1E4, 513 0A7F555107677DCC00E1C1E4, 435 514 ); 436 515 isa = PBXSourcesBuildPhase; … … 451 530 CCC9E42A06A6763E00422E9E, 452 531 CCC9E42B06A6763F00422E9E, 532 0A7F549B07676F2400E1C1E4, 453 533 ); 454 534 isa = PBXFrameworksBuildPhase; trunk/TODO
r28 r29 8 8 - The option to not display messages regarding tunnels (Nov 05 - Marc Liyanage - Feature suggestion for SSHKeychain) 9 9 - Listen to local forwarded ports and start up the tunnel on demand (that's going to require some hacking with random ports to have ssh listening on) 10 - Give tunnels UUIDs for identification instead of using their names (<http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFPlugIns/Tasks/GeneratingUUID.html>)11 10 12 11 1.0 TODO: trunk/TunnelController.h
r17 r29 21 21 22 22 - (void)sync; 23 - (void)changeTunnel Name:(NSString *)oldName toName:(NSString *)newName;24 - (void)removeTunnelWith Name:(NSString *)name;23 - (void)changeTunnel:(NSString *)uuid setName:(NSString *)newName; 24 - (void)removeTunnelWithUUID:(NSString *)uuid; 25 25 26 26 - (void)setToolTipForActiveTunnels; trunk/TunnelController.m
r28 r29 4 4 #import "PreferenceController.h" 5 5 #import "Libs/SSHTunnel.h" 6 #import "Utilities.h" 7 #import "NSMenu_Additions.h" 6 8 7 9 #include "SSHKeychain_Prefix.pch" … … 16 18 - (id)init 17 19 { 18 if(!(self = [super init])) 19 { 20 return nil; 21 } 22 23 [[NSNotificationCenter defaultCenter] addObserver:self 24 selector:@selector(applicationDidFinishLaunching:) 25 name:@"NSApplicationDidFinishLaunchingNotification" object:NSApp]; 26 27 [[NSNotificationCenter defaultCenter] addObserver:self 28 selector:@selector(applicationWillTerminate:) 29 name:@"NSApplicationWillTerminateNotification" object:NSApp]; 30 31 [[NSNotificationCenter defaultCenter] addObserver:self 32 selector:@selector(agentFilledNotification:) name:@"AgentFilled" object:nil]; 33 34 [[NSNotificationCenter defaultCenter] addObserver:self 35 selector:@selector(agentEmptiedNotification:) name:@"AgentEmptied" object:nil]; 36 37 sharedTunnelController = self; 38 39 notificationQueue = [[NSMutableArray alloc] init]; 40 notificationLock = [[NSLock alloc] init]; 41 notificationThread = [[NSThread currentThread] retain]; 42 notificationPort = [[NSMachPort alloc] init]; 43 44 [notificationPort setDelegate:self]; 45 46 [[NSRunLoop currentRunLoop] addPort:notificationPort forMode:(NSString *)kCFRunLoopCommonModes]; 20 if(self = [super init]) 21 { 22 [[NSNotificationCenter defaultCenter] addObserver:self 23 selector:@selector(applicationDidFinishLaunching:) 24 name:@"NSApplicationDidFinishLaunchingNotification" object:NSApp]; 25 26 [[NSNotificationCenter defaultCenter] addObserver:self 27 selector:@selector(applicationWillTerminate:) 28 name:@"NSApplicationWillTerminateNotification" object:NSApp]; 29 30 [[NSNotificationCenter defaultCenter] addObserver:self 31 selector:@selector(agentFilledNotification:) name:@"AgentFilled" object:nil]; 32 33 [[NSNotificationCenter defaultCenter] addObserver:self 34 selector:@selector(agentEmptiedNotification:) name:@"AgentEmptied" object:nil]; 35 36 sharedTunnelController = self; 37 38 notificationQueue = [[NSMutableArray alloc] init]; 39 notificationLock = [[NSLock alloc] init]; 40 notificationThread = [[NSThread currentThread] retain]; 41 notificationPort = [[NSMachPort alloc] init]; 42 43 [notificationPort setDelegate:self]; 44 45 [[NSRunLoop currentRunLoop] addPort:notificationPort forMode:(NSString *)kCFRunLoopCommonModes]; 46 } 47 47 48 48 return self; … … 76 76 NSArray *newTunnels; 77 77 NSMutableDictionary *dict; 78 int i , j;78 int i; 79 79 BOOL match; 80 80 81 81 if(!tunnels) { return; } 82 82 83 newTunnels = [NSArray arrayWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:tunnelsString]]; 84 85 for(i=0; i < [newTunnels count]; i++) 86 { 83 [[NSUserDefaults standardUserDefaults] synchronize]; 84 newTunnels = [[NSUserDefaults standardUserDefaults] arrayForKey:tunnelsString]; 85 86 // Because we're adding UUIDs, we should give them to all tunnels that don't yet have them 87 BOOL setUUID = NO; 88 NSEnumerator *e = [newTunnels objectEnumerator]; 89 NSDictionary *aTunnel; 90 NSMutableArray *modifiedTunnels = [NSMutableArray array]; 91 while (aTunnel = [e nextObject]) { 92 if ([aTunnel objectForKey:@"TunnelUUID"] == nil) 93 { 94 NSMutableDictionary *modifiedTunnel = [NSMutableDictionary dictionaryWithDictionary:aTunnel]; 95 [modifiedTunnel setObject:CreateUUID() forKey:@"TunnelUUID"]; 96 [modifiedTunnels addObject:modifiedTunnel]; 97 setUUID = YES; 98 } else { 99 [modifiedTunnels addObject:aTunnel]; 100 } 101 } 102 if (setUUID) { 103 newTunnels = [NSArray arrayWithArray:modifiedTunnels]; 104 [[NSUserDefaults standardUserDefaults] setObject:newTunnels forKey:tunnelsString]; 105 } 106 107 e = [newTunnels objectEnumerator]; 108 while (aTunnel = [e nextObject]) { 87 109 match = NO; 88 110 89 for(j=0; j < [tunnels count]; j++) 90 { 91 if([[[newTunnels objectAtIndex:i] objectForKey:@"TunnelName"] isEqualToString: 92 [[tunnels objectAtIndex:j] objectForKey:@"TunnelName"]]) 111 for(i=0; i < [tunnels count]; i++) 112 { 113 NSDictionary *oldTunnel = [tunnels objectAtIndex:i]; 114 if([[aTunnel objectForKey:@"TunnelUUID"] isEqualToString: 115 [oldTunnel objectForKey:@"TunnelUUID"]]) 93 116 { 94 dict = [NSMutableDictionary dictionaryWithDictionary: [newTunnels objectAtIndex:i]];95 96 if([ [tunnels objectAtIndex:j]objectForKey:@"TunnelObject"])97 { 98 [dict setObject:[ [tunnels objectAtIndex:j]objectForKey:@"TunnelObject"] forKey:@"TunnelObject"];99 } 100 101 [tunnels replaceObjectAtIndex: jwithObject:dict];117 dict = [NSMutableDictionary dictionaryWithDictionary:aTunnel]; 118 119 if([oldTunnel objectForKey:@"TunnelObject"]) 120 { 121 [dict setObject:[oldTunnel objectForKey:@"TunnelObject"] forKey:@"TunnelObject"]; 122 } 123 124 [tunnels replaceObjectAtIndex:i withObject:dict]; 102 125 103 126 match = YES; … … 107 130 if(!match) 108 131 { 109 dict = [NSMutableDictionary dictionaryWithDictionary:[newTunnels objectAtIndex:i]]; 110 111 [[mainMenuTunnelsItem addItemWithTitle:[dict objectForKey:@"TunnelName"] 112 action:@selector(toggleTunnel:) keyEquivalent:@""] setTarget:self]; 113 114 [[dockMenuTunnelsItem addItemWithTitle:[dict objectForKey:@"TunnelName"] 115 action:@selector(toggleTunnel:) keyEquivalent:@""] setTarget:self]; 116 117 [[statusbarMenuTunnelsItem addItemWithTitle:[dict objectForKey:@"TunnelName"] 118 action:@selector(toggleTunnel:) keyEquivalent:@""] setTarget:self]; 132 dict = [NSMutableDictionary dictionaryWithDictionary:aTunnel]; 133 134 id <NSMenuItem> mItem; 135 mItem = [mainMenuTunnelsItem addItemWithTitle:[dict objectForKey:@"TunnelName"] 136 action:@selector(toggleTunnel:) 137 keyEquivalent:@""]; 138 [mItem setTarget:self]; 139 [mItem setRepresentedObject:[dict objectForKey:@"TunnelUUID"]]; 140 141 mItem = [dockMenuTunnelsItem addItemWithTitle:[dict objectForKey:@"TunnelName"] 142 action:@selector(toggleTunnel:) 143 keyEquivalent:@""]; 144 [mItem setTarget:self]; 145 [mItem setRepresentedObject:[dict objectForKey:@"TunnelUUID"]]; 146 147 mItem = [statusbarMenuTunnelsItem addItemWithTitle:[dict objectForKey:@"TunnelName"] 148 action:@selector(toggleTunnel:) keyEquivalent:@""]; 149 [mItem setTarget:self]; 150 [mItem setRepresentedObject:[dict objectForKey:@"TunnelUUID"]]; 119 151 120 152 [tunnels addObject:[NSMutableDictionary dictionaryWithDictionary:dict]]; … … 123 155 } 124 156 125 - (void)changeTunnel Name:(NSString *)oldName toName:(NSString *)newName126 { 127 i nt i;128 129 if(!tunnels) { return; }130 131 for(i=0; i < [tunnels count]; i++)132 { 133 if([[ [tunnels objectAtIndex:i] objectForKey:@"TunnelName"] isEqualToString:oldName])134 { 135 [ [tunnels objectAtIndex:i]setObject:newName forKey:@"TunnelName"];136 137 [[mainMenuTunnelsItem itemWith Title:oldName] setTitle:newName];138 [[statusbarMenuTunnelsItem itemWith Title:oldName] setTitle:newName];139 [[dockMenuTunnelsItem itemWith Title:oldName] setTitle:newName];157 - (void)changeTunnel:(NSString *)uuid setName:(NSString *)newName 158 { 159 if(!tunnels) { return; } 160 161 NSEnumerator *e = [tunnels objectEnumerator]; 162 NSMutableDictionary *aTunnel; 163 while (aTunnel = [e nextObject]) 164 { 165 if([[aTunnel objectForKey:@"TunnelUUID"] isEqualToString:uuid]) 166 { 167 [aTunnel setObject:newName forKey:@"TunnelName"]; 168 169 [[mainMenuTunnelsItem itemWithRepresentation:uuid] setTitle:newName]; 170 [[statusbarMenuTunnelsItem itemWithRepresentation:uuid] setTitle:newName]; 171 [[dockMenuTunnelsItem itemWithRepresentation:uuid] setTitle:newName]; 140 172 141 173 return; … … 147 179 { 148 180 Controller *controller = [Controller sharedController]; 149 int i;150 181 int active = 0; 151 182 … … 155 186 } 156 187 157 for(i=0; i < [tunnels count]; i++) 158 { 159 if([[tunnels objectAtIndex:i] objectForKey:@"TunnelObject"]) 188 NSEnumerator *e = [tunnels objectEnumerator]; 189 NSDictionary *aTunnel; 190 while (aTunnel = [e nextObject]) 191 { 192 if([aTunnel objectForKey:@"TunnelObject"]) 160 193 { 161 194 active++; … … 172 205 } 173 206 174 - (void)removeTunnelWith Name:(NSString *)name207 - (void)removeTunnelWithUUID:(NSString *)uuid 175 208 { 176 209 SSHTunnel *tunnel; 177 int i; 178 179 if(!tunnels) { return; } 180 181 for(i=0; i < [tunnels count]; i++) 182 { 183 if([[[tunnels objectAtIndex:i] objectForKey:@"TunnelName"] isEqualToString:name]) 184 { 185 tunnel = [[tunnels objectAtIndex:i] objectForKey:@"TunnelObject"]; 186 187 if(tunnel) 210 211 if(!tunnels) { return; } 212 213 NSEnumerator *e = [tunnels objectEnumerator]; 214 NSDictionary *aTunnel; 215 while (aTunnel = [e nextObject]) 216 { 217 if([[aTunnel objectForKey:@"TunnelUUID"] isEqualToString:uuid]) 218 { 219 tunnel = [aTunnel objectForKey:@"TunnelObject"]; 220 221 if (tunnel) 188 222 { 189 223 [tunnel closeTunnel]; 190 224 } 191 225 192 [tunnels removeObject AtIndex:i];193 194 [mainMenuTunnelsItem removeItem:[mainMenuTunnelsItem itemWith Title:name]];195 [dockMenuTunnelsItem removeItem:[dockMenuTunnelsItem itemWith Title:name]];196 [statusbarMenuTunnelsItem removeItem:[statusbarMenuTunnelsItem itemWith Title:name]];226 [tunnels removeObjectIdenticalTo:aTunnel]; 227 228 [mainMenuTunnelsItem removeItem:[mainMenuTunnelsItem itemWithRepresentation:uuid]]; 229 [dockMenuTunnelsItem removeItem:[dockMenuTunnelsItem itemWithRepresentation:uuid]]; 230 [statusbarMenuTunnelsItem removeItem:[statusbarMenuTunnelsItem itemWithRepresentation:uuid]]; 197 231 } 198 232 } … … 200 234 201 235 - (void)closeAllTunnels 202 { 203 i nt i;204 205 if(!tunnels) { return; }206 207 for(i=0; i < [tunnels count]; i++)208 { 209 if([ [tunnels objectAtIndex:i]objectForKey:@"TunnelObject"])210 { 211 SSHTunnel *tunnel = [ [tunnels objectAtIndex:i]objectForKey:@"TunnelObject"];212 NSString * name = [[tunnels objectAtIndex:i] objectForKey:@"TunnelName"];236 { 237 if(!tunnels) { return; } 238 239 NSEnumerator *e = [tunnels objectEnumerator]; 240 NSMutableDictionary *aTunnel; 241 while (aTunnel = [e nextObject]) 242 { 243 if([aTunnel objectForKey:@"TunnelObject"]) 244 { 245 SSHTunnel *tunnel = [aTunnel objectForKey:@"TunnelObject"]; 246 NSString *uuid = [aTunnel objectForKey:@"TunnelUUID"]; 213 247 214 248 [tunnel closeTunnel]; 215 [ [tunnels objectAtIndex:i]removeObjectForKey:@"TunnelObject"];216 217 [[mainMenuTunnelsItem itemWith Title:name] setState:NO];218 [[statusbarMenuTunnelsItem itemWith Title:name] setState:NO];219 [[dockMenuTunnelsItem itemWith Title:name] setState:NO];249 [aTunnel removeObjectForKey:@"TunnelObject"]; 250 251 [[mainMenuTunnelsItem itemWithRepresentation:uuid] setState:NO]; 252 [[statusbarMenuTunnelsItem itemWithRepresentation:uuid] setState:NO]; 253 [[dockMenuTunnelsItem itemWithRepresentation:uuid] setState:NO]; 220 254 } 221 255 } … … 227 261 { 228 262 SSHTunnel *tunnel; 229 NSString * name;230 231 i nt i;232 233 if(!tunnels) { return; }234 235 for(i=0; i < [tunnels count]; i++)236 { 237 if([ [tunnels objectAtIndex:i]objectForKey:@"LaunchAfterSleep"])263 NSString *uuid; 264 265 if(!tunnels) { return; } 266 267 NSEnumerator *e = [tunnels objectEnumerator]; 268 NSMutableDictionary *aTunnel; 269 while (aTunnel = [e nextObject]) 270 { 271 if([aTunnel objectForKey:@"LaunchAfterSleep"]) 238 272 { 239 273 /* First kill the tunnel, if it's still open. */ 240 if([ [tunnels objectAtIndex:i]objectForKey:@"TunnelObject"])274 if([aTunnel objectForKey:@"TunnelObject"]) 241 275 { 242 tunnel = [ [tunnels objectAtIndex:i]objectForKey:@"TunnelObject"];243 name = [[tunnels objectAtIndex:i] objectForKey:@"TunnelName"];276 tunnel = [aTunnel objectForKey:@"TunnelObject"]; 277 uuid = [aTunnel objectForKey:@"TunnelUUID"]; 244 278 245 279 [tunnel closeTunnel]; 246 [ [tunnels objectAtIndex:i]removeObjectForKey:@"TunnelObject"];247 248 [[mainMenuTunnelsItem itemWith Title:name] setState:NO];249 [[statusbarMenuTunnelsItem itemWith Title:name] setState:NO];250 [[dockMenuTunnelsItem itemWith Title:name] setState:NO];280 [aTunnel removeObjectForKey:@"TunnelObject"]; 281 282 [[mainMenuTunnelsItem itemWithRepresentation:uuid] setState:NO]; 283 [[statusbarMenuTunnelsItem itemWithRepresentation:uuid] setState:NO]; 284 [[dockMenuTunnelsItem itemWithRepresentation:uuid] setState:NO]; 251 285 } 252 286 253 [self openTunnelWithDict: [tunnels objectAtIndex:i]];287 [self openTunnelWithDict:aTunnel]; 254 288 } 255 289 } … … 261 295 { 262 296 NSMutableDictionary *dict; 263 int i;264 297 SSHTunnel *tunnel; 265 298 … … 268 301 if(!tunnels) { return; } 269 302 270 for(i=0; i < [tunnels count]; i++) 271 { 272 if([[[tunnels objectAtIndex:i] objectForKey:@"TunnelName"] isEqualToString:[sender title]]) 273 { 274 dict = [tunnels objectAtIndex:i]; 303 NSEnumerator *e = [tunnels objectEnumerator]; 304 NSMutableDictionary *aTunnel; 305 while (aTunnel = [e nextObject]) 306 { 307 if([[aTunnel objectForKey:@"TunnelUUID"] isEqualToString:[sender representedObject]]) 308 { 309 dict = aTunnel; 310 break; 275 311 } 276 312 } … … 301 337 - (void)handleClosedTunnels:(NSString *)contextInfo 302 338 { 303 int i,last_terminated;339 int last_terminated; 304 340 NSString *output; 305 341 BOOL fails_exceeded = NO; … … 309 345 } 310 346 311 [[mainMenuTunnelsItem itemWithTitle:contextInfo] setState:NO]; 312 [[statusbarMenuTunnelsItem itemWithTitle:contextInfo] setState:NO]; 313 [[dockMenuTunnelsItem itemWithTitle:contextInfo] setState:NO]; 314 315 if(!tunnels) { return; } 316 317 for(i=0; i < [tunnels count]; i++) 318 { 319 if([[[tunnels objectAtIndex:i] objectForKey:@"TunnelName"] isEqualToString:contextInfo]) 320 { 321 SSHTunnel *tunnel = [[tunnels objectAtIndex:i] objectForKey:@"TunnelObject"]; 322 347 [[mainMenuTunnelsItem itemWithRepresentation:contextInfo] setState:NO]; 348 [[statusbarMenuTunnelsItem itemWithRepresentation:contextInfo] setState:NO]; 349 [[dockMenuTunnelsItem itemWithRepresentation:contextInfo] setState:NO]; 350 351 if(!tunnels) { return; } 352 353 NSEnumerator *e = [tunnels objectEnumerator]; 354 NSMutableDictionary *aTunnel; 355 while (aTunnel = [e nextObject]) 356 { 357 if([[aTunnel objectForKey:@"TunnelUUID"] isEqualToString:contextInfo]) 358 { 359 SSHTunnel *tunnel = [aTunnel objectForKey:@"TunnelObject"]; 360 323 361 if(tunnel) 324 362 { … … 328 366 output = [tunnel getOutput]; 329 367 330 [ [tunnels objectAtIndex:i]removeObjectForKey:@"TunnelObject"];331 332 if([ [tunnels objectAtIndex:i]objectForKey:@"LastTerminated"])333 { 334 last_terminated = [[ [tunnels objectAtIndex:i]objectForKey:@"LastTerminated"] intValue];368 [aTunnel removeObjectForKey:@"TunnelObject"]; 369 370 if([aTunnel objectForKey:@"LastTerminated"]) 371 { 372 last_terminated = [[aTunnel objectForKey:@"LastTerminated"] intValue]; 335 373 } 336 374 … … 338 376 { 339 377 fails_exceeded = YES; 340 [ [tunnels objectAtIndex:i]removeObjectForKey:@"LastTerminated"];378 [aTunnel removeObjectForKey:@"LastTerminated"]; 341 379 } 342 380 343 381 else if((allKeysOnAgent) && ([output length] < 1)) 344 382 { 345 [ [tunnels objectAtIndex:i]setObject:[NSNumber numberWithInt:time(nil)] forKey:@"LastTerminated"];346 [self openTunnelWithDict: [tunnels objectAtIndex:i]];383 [aTunnel setObject:[NSNumber numberWithInt:time(nil)] forKey:@"LastTerminated"]; 384 [self openTunnelWithDict:aTunnel]; 347 385 } 348 386 … … 351 389 [self warningPanelWithTitle:local(@"TunnelTerminated") 352 390 andMessage:[NSString stringWithFormat:@"(%@) %@", 353 [ [tunnels objectAtIndex:i]objectForKey:@"TunnelName"],391 [aTunnel objectForKey:@"TunnelName"], 354 392 local(@"TunnelTerminatedAndCouldNotBeRestarted")]]; 355 393 } … … 358 396 [self warningPanelWithTitle:local(@"TunnelTerminated") 359 397 andMessage:[NSString stringWithFormat:@"(%@) %@", 360 [ [tunnels objectAtIndex:i]objectForKey:@"TunnelName"],398 [aTunnel objectForKey:@"TunnelName"], 361 399 local(@"TunnelTerminatedAndCouldNotBeRestarted")]]; 362 400 } … … 366 404 [self warningPanelWithTitle:local(@"TunnelForwardingFailed") 367 405 andMessage:[NSString stringWithFormat:@"(%@) %@", 368 [ [tunnels objectAtIndex:i]objectForKey:@"TunnelName"],406 [aTunnel objectForKey:@"TunnelName"], 369 407 local(@"ForwardingFailedDuringInitialization")]]; 370 408 } … … 374 412 [self warningPanelWithTitle:local(@"TunnelSetupFailed") 375 413 andMessage:[NSString stringWithFormat:@"(%@) Error:\n%@", 376 [ [tunnels objectAtIndex:i]objectForKey:@"TunnelName"],414 [aTunnel objectForKey:@"TunnelName"], 377 415 output]]; 378 416 } … … 382 420 [self warningPanelWithTitle:local(@"TunnelTerminated") 383 421 andMessage:[NSString stringWithFormat:@"(%@) %@", 384 &nb
