adium 2401:017d57eb42f8: Use the account's hostname when looking...

commits at adium.im commits at adium.im
Sat May 30 00:16:33 UTC 2009


details:	http://hg.adium.im/adium/rev/017d57eb42f8
revision:	2401:017d57eb42f8
author:		Zachary West <zacw at adium.im>
date:		Fri May 29 20:16:24 2009 -0400

Use the account's hostname when looking up the proxy information, so we can use the host when looking for a PAC file. Fixes #224.

diffs (61 lines):

diff -r 5b4ffe8b8a28 -r 017d57eb42f8 Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.h
--- a/Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.h	Fri May 29 15:50:44 2009 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.h	Fri May 29 20:16:24 2009 -0400
@@ -35,10 +35,12 @@
 /*!
  * @brief Retrieve systemwide proxy settings for a type of proxy
  *
- * Retrieve systemwide proxy settings for <b>proxyType</b>.
+ * Retrieve systemwide proxy settings for <b>proxyType</b> using optional hostname <b>hostName</b> (for PAC files).
  * @param proxyType The type of proxy for which to retrieve settings.  ProxyType should be one of Proxy_None, Proxy_HTTP, Proxy_HTTPS, Proxy_SOCKS4, Proxy_SOCKS5, Proxy_FTP, Proxy_RTSP, or Proxy_Gopher.
+ * @param hostName An NSString of the hostname to connect to, or nil
  * @result An <tt>NSDictionary</tt> containing the settings for that proxy type, or nil if no proxy is configured for that type.  The dictionary has the host as an NSString in the key @"Host", the port as an NSNumber in the key @"Port", and, if they are present, the username and password as NSStrings in @"Username" and @"Password" respectively.
 */
-+ (NSDictionary *)systemProxySettingsDictionaryForType:(ProxyType)proxyType;
++ (NSDictionary *)systemProxySettingsDictionaryForType:(ProxyType)proxyType
+											 forServer:(NSString *)hostName;
 
 @end
diff -r 5b4ffe8b8a28 -r 017d57eb42f8 Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.m
--- a/Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.m	Fri May 29 15:50:44 2009 -0400
+++ b/Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.m	Fri May 29 20:16:24 2009 -0400
@@ -15,6 +15,7 @@
 @implementation AISystemNetworkDefaults
 
 + (NSDictionary *)systemProxySettingsDictionaryForType:(ProxyType)proxyType
+											 forServer:(NSString *)hostName
 {
 	NSMutableDictionary *systemProxySettingsDictionary = nil;
 	NSDictionary		*proxyDict = nil;
@@ -120,7 +121,7 @@
 				NSString *pacFile = [proxyDict objectForKey:(NSString *)kSCPropNetProxiesProxyAutoConfigURLString];
 				
 				if (pacFile) {
-					CFURLRef url = (CFURLRef)[NSURL URLWithString:@"http://www.google.com"];
+					CFURLRef url = (CFURLRef)[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", hostName ?: @"google.com"]];
 					NSString *scriptStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:pacFile] encoding:NSUTF8StringEncoding error:NULL];
 					
 					if (url && scriptStr) {
@@ -132,7 +133,8 @@
 						CFRelease(CFNetworkCopyProxiesForURL(url, NULL));
 						
 						CFErrorRef error = NULL;
-						proxies = [(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)scriptStr, url, &error) autorelease];						
+						proxies = [(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)scriptStr, url, &error) autorelease];	
+
 						if (error) {
 							CFStringRef description = CFErrorCopyDescription(error);
 							
diff -r 5b4ffe8b8a28 -r 017d57eb42f8 Frameworks/Adium Framework/Source/AIAbstractAccount.m
--- a/Frameworks/Adium Framework/Source/AIAbstractAccount.m	Fri May 29 15:50:44 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIAbstractAccount.m	Fri May 29 20:16:24 2009 -0400
@@ -1556,7 +1556,8 @@
 				systemConfigurationProxyType = Proxy_SOCKS4;
 			}
 			
-			if ((systemProxySettingsDictionary = [AISystemNetworkDefaults systemProxySettingsDictionaryForType:systemConfigurationProxyType])) {
+			if ((systemProxySettingsDictionary = [AISystemNetworkDefaults systemProxySettingsDictionaryForType:systemConfigurationProxyType
+																									 forServer:self.host])) {
 				host = [systemProxySettingsDictionary objectForKey:@"Host"];
 				port = [systemProxySettingsDictionary objectForKey:@"Port"];
 				




More information about the commits mailing list