Adium

Changeset 25577

Show
Ignore:
Timestamp:
11/13/2008 09:52:44 AM (2 months ago)
Author:
evands
Message:

This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.

Needs testing.... I use neither a proxy nor a PAC file and can't test it. :)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.m

    r24807 r25577  
    7575 
    7676        if ((proxyDict = (NSDictionary *)SCDynamicStoreCopyProxies(NULL))) { 
     77                [proxyDict autorelease]; 
     78 
    7779                //Enabled? 
    7880                enable = [[proxyDict objectForKey:(NSString *)enableKey] intValue]; 
     
    119121                                 
    120122                                if (pacFile) { 
    121                                         //XXX can't use pac file 
    122                                         NSString *msg = [NSString stringWithFormat: 
    123                                                 AILocalizedString(@"The system-wide proxy configuration specified via the Network System Preferences depends upon reading a PAC (Proxy Automatic Configuration) file from %@.  This information can not be used at this time; to connect, please obtain proxy information from your network administrator and use it manually.", nil), 
    124                                                 pacFile]; 
    125                                         NSRunCriticalAlertPanel(AILocalizedString(@"Unable to read proxy information", "Title of the alert shown when the system proxy configuration can not be determined"), 
    126                                                                                         msg, 
    127                                                                                         nil, 
    128                                                                                         nil, 
    129                                                                                         nil); 
     123                                        CFURLRef url = (CFURLRef)[NSURL URLWithString:@"http://www.google.com"]; 
     124                                        NSString *scriptStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:pacFile] encoding:NSUTF8StringEncoding error:NULL]; 
     125                                         
     126                                        if (url && scriptStr) { 
     127                                                NSArray *proxies; 
     128                                                // The following note is from Apple's CFProxySupportTool: 
     129                                                // Work around <rdar://problem/5530166>.  This dummy call to  
     130                                                // CFNetworkCopyProxiesForURL initialise some state within CFNetwork  
     131                                                // that is required by CFNetworkCopyProxiesForAutoConfigurationScript. 
     132                                                (void) CFNetworkCopyProxiesForURL(url, NULL); 
     133                                                 
     134                                                proxies = [(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)scriptStr, url, NULL) autorelease]; 
     135                                                if (proxies && proxies.count) { 
     136                                                        proxyDict = [proxies objectAtIndex:0]; 
     137                                                         
     138                                                        systemProxySettingsDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
     139                                                                                                                         [proxyDict objectForKey:(NSString *)kCFProxyHostNameKey], @"Host", 
     140                                                                                                                         [proxyDict objectForKey:(NSString *)kCFProxyPortNumberKey], @"Port", 
     141                                                                                                                         [proxyDict objectForKey:(NSString *)kCFProxyUsernameKey], @"Username", 
     142                                                                                                                         [proxyDict objectForKey:(NSString *)kCFProxyPasswordKey], @"Password", 
     143                                                                                                                         nil]; 
     144                                                } 
     145                                        } 
    130146                                } 
    131147                        } 
    132148                } 
    133149                // Could check and process kSCPropNetProxiesExceptionsList here, which returns: CFArray[CFString] 
    134  
    135                 //Clean up; proxyDict was created by a call with Copy in its name 
    136                 [proxyDict release]; 
    137150        } 
    138151