• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Launching Network System Preferences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Launching Network System Preferences


  • Subject: Re: Launching Network System Preferences
  • From: Quinn <email@hidden>
  • Date: Fri, 27 Feb 2004 10:29:06 +0000

At 22:23 -0800 26/2/04, Daniel Zimmerman wrote:
I'm trying to do what Safari does when it launches the Network System Preferences for the user to change their proxy settings but It's not working.
I found that on Panther I could use the following code and it would correctly launch the System preferences and switch to the Network panel:

ICInstance myInst;
OSStatus err1 = ICStart(&myInst, kAdobeLMControlSignature);
if (err1 == noErr) {
OSStatus err2 = ICEditPreferences(myInst, kICUseHTTPProxy);
ICStop(myInst);
}

If this code works on 10.3, this is what I'd recommend you use on 10.3 and later systems.

But this code fails on Jaguar with an error 1015 being returned by ICEditPreferences. there is no documentation on what a 1015 error is.

AFAIK it's an internal Launch Services error code that's not supposed to escape. That'd be a bug (which it looks like we fixed on 10.3).

Also on panther, even though I'm passing in the kICUseHTTPProxy key, it's not going to the proxies tab of the network panel.

I'd probably classify that as a bug as well, although it's not trivial to fix (as is made clear by the following).

So my questions are:

1) Is this the right way to bring up the Network Panel

Yes, for 10.3 and later. For earlier systems, see the discussion below.

2) The documentation for IC says that the ICEditPreferences call must have a configuration setup before calling it. However, all of the configuration calls are not available on OS X. Is this why it's failing on Jaguar (fixed on Panther)

No. The whole notion of configuration setup is eliminated in IC in Carbon, so you just don't have to worry about that requirement (all instances are automatically configured to use the default prefs).

3) I looked into Launch Services, but could not find an appropriate solution.

You can do it with Launch Services, but I don't really recommend it as a solution because you have to hard code more stuff that I'd like. Hence my recommendation that you use IC if it works.

In the past I have used the following code to launch the Network preference pane. The hard-coded things that I don't like include the assumption that kSystemPreferencesFolderType returns /System/Library/PreferencesPanes (which is not what that selector was originally intended for) and the name of the preferences pane itself.

static OSStatus OpenPreferencesPanel(CFStringRef paneNameStr)
{
OSStatus err;
HFSUniStr255 paneNameUnicode;
FSRef prefPaneFolder;
FSRef prefPane;

paneNameUnicode.length = CFStringGetLength(paneNameStr);
CFStringGetCharacters(
paneNameStr,
CFRangeMake(0, paneNameUnicode.length),
paneNameUnicode.unicode
);
err = FSFindFolder(
kSystemDomain,
kSystemPreferencesFolderType,
false,
&prefPaneFolder
);
if (err == noErr) {
err = FSMakeFSRefUnicode(
&prefPaneFolder,
paneNameUnicode.length,
paneNameUnicode.unicode,
kTextEncodingUnknown,
&prefPane
);
}
if (err == noErr) {
err = LSOpenFSRef(&prefPane, nil);
}
return err;
}

err = OpenPreferencesPanel(CFSTR("Network.prefPane"));

ICEditPreferences contains code like that shown above. Of course, it doesn't have to worry about the hard coded stuff because if we change it we can change ICEditPreferences as well.

Also, once you understand this code you'll understand why it's non-trivial to get to the Proxies tab. This code just acts as if you'd double clicked the .prefPane file. There's no side band communication that allows you to switch to the appropriate tab. Still, it's something worth investigating, so I'd appreciate it if you could file a bug.

<http://developer.apple.com/bugreporter/>

Mail me the bug number and I'll keep an eye on it.

S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.


References: 
 >Launching Network System Preferences (From: Daniel Zimmerman <email@hidden>)

  • Prev by Date: Launching Network System Preferences
  • Next by Date: AbsoluteTime question...
  • Previous by thread: Launching Network System Preferences
  • Next by thread: AbsoluteTime question...
  • Index(es):
    • Date
    • Thread