| 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 | } |
|---|