Discussion:
Reading HTTP Proxy settings from system preferences?
Dan Wood
2001-11-29 17:35:08 UTC
Permalink
Does anybody know how to directly access the HTTP Proxy settings
the the user sets in the System Preferences pane? It seems that
Cocoa classes make use of those settings, but since I'm "rolling
my own" (by using curl), I need to get these preferences and
pass them on to curl. I haven't found anything in core
foundation, cocoa, or just browsing through the various
preferences domains, that would help me....

--
Dan Wood
***@karelia.com
http://www.karelia.com/
http://www.bikealameda.org/
Mac OS X Developer: Online Resume: http://www.karelia.com/resume.html
Andreas Monitzer
2001-11-29 18:10:59 UTC
Permalink
Does anybody know how to directly access the HTTP Proxy settings the
the user sets in the System Preferences pane? It seems that Cocoa
classes make use of those settings, but since I'm "rolling my own" (by
using curl), I need to get these preferences and pass them on to curl.
I haven't found anything in core foundation, cocoa, or just browsing
through the various preferences domains, that would help me....
SystemConfiguration API (CoreFoundation), or Internet Config (Carbon).

andy
Stas Pietrucha
2001-11-29 18:23:15 UTC
Permalink
Dan -

These settings are buried in the Internet Config (see
Developer/Documentation/Carbon/networkcomm/InternetConfig/internetconfig.ht
ml)

I have recently written some code to read the proxy preferences from
Obj-c if you are interested in looking at that; however, i do not know
much about passing that information to curl. In fact, I was wondering if
anyone knows how to get NSURL to use a proxy server?
Message: 10
Date: Thu, 29 Nov 2001 11:33:16 -0800
Subject: Reading HTTP Proxy settings from system preferences?
--Apple-Mail-30-837909542
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Does anybody know how to directly access the HTTP Proxy settings
the the user sets in the System Preferences pane? It seems that
Cocoa classes make use of those settings, but since I'm "rolling
my own" (by using curl), I need to get these preferences and
pass them on to curl. I haven't found anything in core
foundation, cocoa, or just browsing through the various
preferences domains, that would help me....
--
Dan Wood
http://www.karelia.com/
http://www.bikealameda.org/
Mac OS X Developer: Online Resume: http://www.karelia.com/resume.html
--Apple-Mail-30-837909542
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
charset=US-ASCII
Does anybody know how to directly access the HTTP Proxy settings the
the user sets in the System Preferences pane? It seems that Cocoa
classes make use of those settings, but since I'm "rolling my own" (by
using curl), I need to get these preferences and pass them on to curl.
I haven't found anything in core foundation, cocoa, or just browsing
through the various preferences domains, that would help me....
<fontfamily><param>Helvetica</param>
--
<bold>Dan Wood
http://www.karelia.com/
http://www.bikealameda.org/
<color><param>0000,1A1A,FFFF</param>http://www.karelia.com/resume.html</co
lor></fontfamily>
--Apple-Mail-30-837909542--
Stas Pietrucha
Houston, TX

http://homepage.mac.com/wostas
Rick Roe
2001-12-01 16:35:58 UTC
Permalink
Post by Andreas Monitzer
Does anybody know how to directly access the HTTP Proxy settings the
the user sets in the System Preferences pane?
SystemConfiguration API (CoreFoundation), or Internet Config (Carbon).
The former is preferable, is that API makes more allowances for the dynamic
world of OS X networking, where the network interface you use to connect to
a given host may be AirPort with a proxy at one moment and Ethernet without
at another, etc. And it's based on modern data types like CFString, too, so
it's a lot easier to use.
--
Rick Roe
icons.cx / The Omni Group
Max Horn
2001-12-01 18:13:14 UTC
Permalink
Post by Rick Roe
Post by Andreas Monitzer
Does anybody know how to directly access the HTTP Proxy settings the
the user sets in the System Preferences pane?
SystemConfiguration API (CoreFoundation), or Internet Config (Carbon).
The former is preferable, is that API makes more allowances for the dynamic
world of OS X networking, where the network interface you use to connect to
a given host may be AirPort with a proxy at one moment and Ethernet without
at another, etc. And it's based on modern data types like CFString, too, so
it's a lot easier to use.
Sounds very interesting. I am currently using IC, but SC sounds good,
and I would like to transist. But I wonder, is there any example code
available on this? I am not even asking for docs (the headers are
luckily well-documented), but having an example app would be nice to
see how all the pieces should fit together...

E.g. I see a function SCDynamicStoreCopyProxies() which seems to be
exactly what I want, giving me the proxy settings. And I guess the
strings in SCSchemaDefinitions.h are the keys for that, nice... but
then I somehow need to use SCDynamicStoreCreate(). For that I need a
SCDynamicStoreContext it seems. Do I have to malloc() which,
strangely enough, I have to allocate?!? That's a bit weird, IMHO,
since everything else uses CFAllocator's, and this way, the struct
never ever can change... but then, it is not used anywhere else (the
struct), so why do I have to specify it.

Then there is SCDynamicStoreCreateRunLoopSource, I have absolutly no
clue what I should make of this.


So, this all seems nice, but it really needs some more docs.
Trial-and-error can be used to get something to work somehow, but
doing it right requires a bit more information I fear :/




Cheers,

Max
--
-----------------------------------------------
Max Horn
Software Developer

email: <mailto:***@quendi.de>
phone: (+49) 6151-494890
Andreas Monitzer
2001-12-01 20:15:58 UTC
Permalink
Post by Max Horn
Sounds very interesting. I am currently using IC, but SC sounds good,
and I would like to transist. But I wonder, is there any example code
available on this? I am not even asking for docs (the headers are
luckily well-documented), but having an example app would be nice to
see how all the pieces should fit together...
There's an example app called InstallService by Allan Nathanson
(***@apple.com) which was published at the SC-kitchen last August. I
don't know if it's available somewhere, but you could ask him to send
you the latest version.

here are the basics:

#define SCSTR(c) (NSString*)CFSTR(x)
#include <SystemConfiguration/SystemConfiguration.h>

{
SCPreferencesRef prefs=SCPreferencesCreate(NULL,CFSTR("MyApp"),NULL);
NSDictionary *dict=(NSDictionary*)SCPreferencesGetValue(prefs,
(CFStringRef)kSCPrefNetworkServices);

dict now contains all network information in a simple NSDictionary. You
can use [dict objectForKey:constant] to get the specific services (check
out /var/db/SystemConfiguration/preferences.xml for the structure).
InstallService offers some functions that help you with common things
like getting the currently active set (location in Mac OS-terms).

andy

Loading...