Frameworks/AIUtilities Framework/Source/AISystemNetworkDefaults.m
author Evan Schoenberg
Thu, 14 Nov 2019 16:22:42 -0500
branchadium-1.5.10.5
changeset 5997 d88e6711d0e0
parent 4071 da5bbdab941f
permissions -rw-r--r--
Fixed a triple handful of warnings
3679
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     1
/* 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     2
 * Adium is the legal property of its developers, whose names are listed in the copyright file included
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     3
 * with this source distribution.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     4
 * 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     6
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     7
 * or (at your option) any later version.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     8
 * 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
    10
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
    11
 * Public License for more details.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
    12
 * 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
    13
 * You should have received a copy of the GNU General Public License along with this program; if not,
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
    14
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 3409
diff changeset
    15
 */
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    16
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    17
#import <CoreServices/CoreServices.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    18
#import <CoreFoundation/CoreFoundation.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    19
#import <SystemConfiguration/SystemConfiguration.h>
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    20
#import "AISystemNetworkDefaults.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    21
#import "AIKeychain.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    22
#import "AIApplicationAdditions.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    23
#import "AIStringUtilities.h"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    24
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    25
@implementation AISystemNetworkDefaults
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    26
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    27
+ (NSDictionary *)systemProxySettingsDictionaryForType:(ProxyType)proxyType
2401
017d57eb42f8 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.
Zachary West <zacw@adium.im>
parents: 2350
diff changeset
    28
											 forServer:(NSString *)hostName
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    29
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    30
	NSMutableDictionary *systemProxySettingsDictionary = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    31
	NSDictionary		*proxyDict = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    32
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    33
	CFStringRef			enableKey;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    34
	int                 enable;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    35
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    36
	CFStringRef			portKey;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    37
	NSNumber			*portNum = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    38
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    39
	CFStringRef			proxyKey;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    40
	NSString			*hostString;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    41
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    42
	SecProtocolType		protocolType;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    43
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    44
	switch (proxyType) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    45
		case Proxy_HTTP: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    46
			enableKey = kSCPropNetProxiesHTTPEnable;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    47
			portKey   = kSCPropNetProxiesHTTPPort;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    48
			proxyKey  = kSCPropNetProxiesHTTPProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    49
			protocolType = kSecProtocolTypeHTTPProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    50
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    51
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    52
		case Proxy_SOCKS4:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    53
		case Proxy_SOCKS5: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    54
			enableKey = kSCPropNetProxiesSOCKSEnable;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    55
			portKey   = kSCPropNetProxiesSOCKSPort;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    56
			proxyKey  = kSCPropNetProxiesSOCKSProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    57
			protocolType = kSecProtocolTypeSOCKS;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    58
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    59
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    60
		case Proxy_HTTPS: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    61
			enableKey = kSCPropNetProxiesHTTPSEnable;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    62
			portKey   = kSCPropNetProxiesHTTPSPort;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    63
			proxyKey  = kSCPropNetProxiesHTTPSProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    64
			protocolType = kSecProtocolTypeHTTPSProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    65
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    66
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    67
		case Proxy_FTP: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    68
			enableKey = kSCPropNetProxiesFTPEnable;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    69
			portKey   = kSCPropNetProxiesFTPPort;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    70
			proxyKey  = kSCPropNetProxiesFTPProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    71
			protocolType = kSecProtocolTypeFTPProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    72
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    73
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    74
		case Proxy_RTSP: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    75
			enableKey = kSCPropNetProxiesRTSPEnable;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    76
			portKey   = kSCPropNetProxiesRTSPPort;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    77
			proxyKey  = kSCPropNetProxiesRTSPProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    78
			protocolType = kSecProtocolTypeRTSPProxy;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    79
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    80
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    81
		default: {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    82
			return nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    83
			break;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    84
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    85
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    86
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    87
	if ((proxyDict = (NSDictionary *)SCDynamicStoreCopyProxies(NULL))) {
540
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
    88
		[proxyDict autorelease];
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
    89
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    90
		//Enabled?
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    91
		enable = [[proxyDict objectForKey:(NSString *)enableKey] intValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    92
		if (enable) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    93
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    94
			//Host
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    95
			hostString = [proxyDict objectForKey:(NSString *)proxyKey];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    96
			if (hostString) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    97
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    98
				//Port
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    99
				portNum = [proxyDict objectForKey:(NSString *)portKey];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   100
				if (portNum) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   101
					NSDictionary	*authDict;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   102
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   103
					systemProxySettingsDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   104
						hostString, @"Host",
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   105
						portNum,    @"Port",
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   106
						nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   107
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   108
					//User name & password if applicable
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   109
					NSError *error = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   110
					authDict = [[AIKeychain defaultKeychain_error:&error] dictionaryFromKeychainForServer:hostString 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   111
																								 protocol:protocolType
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   112
																									error:&error];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   113
					if (authDict) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   114
						[systemProxySettingsDictionary addEntriesFromDictionary:authDict];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   115
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   116
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   117
					if (error) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   118
						NSDictionary *userInfo = [error userInfo];
3409
b4d44fcc32fb Fix a few warnings, I'm trusting clang here.
Frank Dowsett <wixardy@adium.im>
parents: 2401
diff changeset
   119
						NSLog(@"Could not get username and password for proxy: %@ returned %ld (%@)",
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   120
							  [userInfo objectForKey:AIKEYCHAIN_ERROR_USERINFO_SECURITYFUNCTIONNAME],
4071
da5bbdab941f Fixed some conversion-warnings.
Patrick Steinhardt <steinhardt.p@me.com>
parents: 3679
diff changeset
   121
							  (long)[error code],
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   122
							  [userInfo objectForKey:AIKEYCHAIN_ERROR_USERINFO_ERRORDESCRIPTION]);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   123
					}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   124
				}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   125
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   126
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   127
		} else {
73
fc3311a3ea1a Remove Tiger-specific stuff from AIUtils
David Smith
parents: 0
diff changeset
   128
			//Check for a PAC configuration
fc3311a3ea1a Remove Tiger-specific stuff from AIUtils
David Smith
parents: 0
diff changeset
   129
			enable = [[proxyDict objectForKey:(NSString *)kSCPropNetProxiesProxyAutoConfigEnable] boolValue];
fc3311a3ea1a Remove Tiger-specific stuff from AIUtils
David Smith
parents: 0
diff changeset
   130
			if (enable) {
fc3311a3ea1a Remove Tiger-specific stuff from AIUtils
David Smith
parents: 0
diff changeset
   131
				NSString *pacFile = [proxyDict objectForKey:(NSString *)kSCPropNetProxiesProxyAutoConfigURLString];
fc3311a3ea1a Remove Tiger-specific stuff from AIUtils
David Smith
parents: 0
diff changeset
   132
				
fc3311a3ea1a Remove Tiger-specific stuff from AIUtils
David Smith
parents: 0
diff changeset
   133
				if (pacFile) {
2401
017d57eb42f8 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.
Zachary West <zacw@adium.im>
parents: 2350
diff changeset
   134
					CFURLRef url = (CFURLRef)[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", hostName ?: @"google.com"]];
540
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   135
					NSString *scriptStr = [NSString stringWithContentsOfURL:[NSURL URLWithString:pacFile] encoding:NSUTF8StringEncoding error:NULL];
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   136
					
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   137
					if (url && scriptStr) {
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   138
						NSArray *proxies;
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   139
						// The following note is from Apple's CFProxySupportTool:
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   140
						// Work around <rdar://problem/5530166>.  This dummy call to 
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   141
						// CFNetworkCopyProxiesForURL initialise some state within CFNetwork 
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   142
						// that is required by CFNetworkCopyProxiesForAutoConfigurationScript.
5997
d88e6711d0e0 Fixed a triple handful of warnings
Evan Schoenberg
parents: 4071
diff changeset
   143
                        CFRelease(CFNetworkCopyProxiesForURL(url, (CFDictionaryRef)@{}));
d88e6711d0e0 Fixed a triple handful of warnings
Evan Schoenberg
parents: 4071
diff changeset
   144
2350
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   145
						CFErrorRef error = NULL;
2401
017d57eb42f8 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.
Zachary West <zacw@adium.im>
parents: 2350
diff changeset
   146
						proxies = [(NSArray *)CFNetworkCopyProxiesForAutoConfigurationScript((CFStringRef)scriptStr, url, &error) autorelease];	
017d57eb42f8 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.
Zachary West <zacw@adium.im>
parents: 2350
diff changeset
   147
2350
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   148
						if (error) {
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   149
							CFStringRef description = CFErrorCopyDescription(error);
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   150
							
3409
b4d44fcc32fb Fix a few warnings, I'm trusting clang here.
Frank Dowsett <wixardy@adium.im>
parents: 2401
diff changeset
   151
							NSLog(@"Tried to get PAC, but got error: %@ %ld %@",
2350
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   152
								  CFErrorGetDomain(error),
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   153
								  CFErrorGetCode(error),
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   154
								  description);
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   155
							
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   156
							CFRelease(description);
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   157
							CFRelease(error);
07b7b2f9f71c Fix trying to grab the proxy auto-config file. Fixes #12199.
Zachary West <zacw@adium.im>
parents: 1661
diff changeset
   158
						} else if (proxies && proxies.count) {
540
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   159
							proxyDict = [proxies objectAtIndex:0];
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   160
							
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   161
							systemProxySettingsDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   162
															 [proxyDict objectForKey:(NSString *)kCFProxyHostNameKey], @"Host",
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   163
															 [proxyDict objectForKey:(NSString *)kCFProxyPortNumberKey], @"Port",
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   164
															 [proxyDict objectForKey:(NSString *)kCFProxyUsernameKey], @"Username",
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   165
															 [proxyDict objectForKey:(NSString *)kCFProxyPasswordKey], @"Password",
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   166
															 nil];
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   167
						}
4d3f482806b8 This might implement PAC support for proxy configuration. Fixes #224 if so. Fixes #11364 if so.
Evan Schoenberg
parents: 104
diff changeset
   168
					}
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   169
				}
73
fc3311a3ea1a Remove Tiger-specific stuff from AIUtils
David Smith
parents: 0
diff changeset
   170
			}
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   171
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   172
		// Could check and process kSCPropNetProxiesExceptionsList here, which returns: CFArray[CFString]
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   173
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   174
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   175
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   176
	return systemProxySettingsDictionary;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   177
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   178
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   179
@end