Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

now we store a dictionary instead of just the netservice

  • Loading branch information...
commit 2a5999920dd2456f944523327a2395d11575492c 1 parent e9d78be
Jérôme Lebel authored
View
10 iProxyMacSetup/Classes/PMUIController.m
@@ -77,11 +77,13 @@ - (void)updateStartButton
- (void)updateProxyPopUpButton
{
[proxyPopUpButton removeAllItems];
- for (NSNetService *service in appDelegate.proxyServiceList) {
+ for (NSDictionary *proxy in appDelegate.proxyServiceList) {
NSString *title;
+ NSNetService *proxyService;
- title = [[NSString alloc] initWithFormat:@"%@.%@", [service name], [service domain]];
- if ([service port] != -1) {
+ proxyService = [proxy objectForKey:PROXY_SERVICE_KEY];
+ title = [[NSString alloc] initWithFormat:@"%@.%@", [proxyService name], [proxyService domain]];
+ if ([proxyService port] != -1 || [proxyService port] != 0) {
[proxyPopUpButton addItemWithTitle:title];
} else {
[proxyPopUpButton addItemWithTitle:[NSString stringWithFormat:@"%@ (disabled)", title]];
@@ -114,7 +116,7 @@ - (void)updateInterfacePopUpButton
- (IBAction)startButtonAction:(id)sender
{
NSDictionary *interfaceInfo;
- NSNetService *proxy;
+ NSDictionary *proxy;
[self updateProxyPopUpButton];
[self updateInterfacePopUpButton];
View
4 iProxyMacSetup/Classes/iProxyMacSetupAppDelegate.h
@@ -11,6 +11,8 @@
#define INTERFACE_NAME @"name"
#define INTERFACE_ENABLED @"enabled"
+#define PROXY_SERVICE_KEY @"service"
+
@interface iProxyMacSetupAppDelegate : NSObject <NSApplicationDelegate, NSNetServiceBrowserDelegate, NSNetServiceDelegate>
{
NSMutableArray *proxyServiceList;
@@ -34,7 +36,7 @@
@property(retain, nonatomic) NSString *defaultInterface;
- (void)startBrowsingServices;
-- (void)enableForInterface:(NSString *)interfaceName withProxy:(NSNetService *)proxy;
+- (void)enableForInterface:(NSString *)interfaceName withProxy:(NSDictionary *)proxy;
- (void)disableProxyForInterface:(NSString *)interface;
@end
View
21 iProxyMacSetup/Classes/iProxyMacSetupAppDelegate.m
@@ -45,12 +45,15 @@ - (void)applicationWillTerminate:(NSNotification *)notification
- (void)_updateAutomatic
{
if (automatic) {
- NSNetService *proxy = nil;
+ NSDictionary *proxy = nil;
NSDictionary *currentInterface = nil;
NSUInteger ii, count = [proxyServiceList count];
for (ii = 0; ii < count; ii++) {
- if ([(NSNetService *)[proxyServiceList objectAtIndex:ii] port] != -1 && [(NSNetService *)[proxyServiceList objectAtIndex:ii] port] != 0) {
+ NSNetService *proxyService;
+
+ proxyService = [[proxyServiceList objectAtIndex:ii] objectForKey:PROXY_SERVICE_KEY];
+ if ([proxyService port] != -1 && [proxyService port] != 0) {
proxy = [proxyServiceList objectAtIndex:ii];
break;
}
@@ -222,7 +225,10 @@ - (NSInteger)indexForDomain:(NSString *)domain name:(NSString *)name type:(NSStr
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing
{
[self willChangeValueForKey:@"proxyServiceList"];
- [proxyServiceList addObject:aNetService];
+ NSMutableDictionary *proxy = [[NSMutableDictionary alloc] init];
+ [proxy setObject:aNetService forKey:PROXY_SERVICE_KEY];
+ [proxyServiceList addObject:proxy];
+ [proxy release];
[self didChangeValueForKey:@"proxyServiceList"];
[aNetService setDelegate:self];
[aNetService resolveWithTimeout:20.0];
@@ -286,12 +292,15 @@ - (void)_enableProxyForInterface:(NSString *)interface server:(NSString *)server
[task waitUntilExit];
}
-- (void)enableForInterface:(NSString *)interfaceName withProxy:(NSNetService *)proxy
+- (void)enableForInterface:(NSString *)interfaceName withProxy:(NSDictionary *)proxy
{
if (!proxyEnabled) {
+ NSNetService *proxyService;
+
[self willChangeValueForKey:@"proxyEnabled"];
- if ([proxy port] != -1) {
- [self _enableProxyForInterface:interfaceName server:[NSString stringWithFormat:@"%@.%@", [proxy name], [proxy domain]] port:[proxy port]];
+ proxyService = [proxy objectForKey:PROXY_SERVICE_KEY];
+ if ([proxyService port] != -1) {
+ [self _enableProxyForInterface:interfaceName server:[NSString stringWithFormat:@"%@.%@", [proxyService name], [proxyService domain]] port:[proxyService port]];
proxyEnabled = YES;
proxyEnabledInterfaceName = [interfaceName retain];
}
Please sign in to comment.
Something went wrong with that request. Please try again.