Sparkle with System Preference Pane

Asked by Trygve

I have a System Preference Pane with has two helper apps. These helper apps (A & B) are in the Resources folder of my PrefPane bundle and are themselves bundles... and may or may not be running.

Of course the System Pref Pane will not normally be open most of the time. I want a way to handle the updates best. Helper A will be running most of the time, so it would be ok if that was the app that polled for updates. The prefs are all controlled via the Pref Pane of course.

How is best to do this and set it up? Should a Make a third helper app (C) that runs whenever the "check for updates" box in my Pref Pane is checked?

Question information

Language:
English Edit question
Status:
Answered
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andy Matuschak (andymatuschak) said :
#1

Helper A should do the checking for updates. But you want to specify that Sparkle should update the prefpane bundle, not Helper A's bundle.

Check out http://sparkle.andymatuschak.org/documentation/pmwiki.php/Documentation/Bundles and make sure to specify that the prefpane be updated.

Revision history for this message
Trygve (sparkle-xericdesign) said :
#2

So, helper A is a background app with no GUI. What happens when the sparkle update window come up... I assume my about box and menu bar will be a bit odd?

Revision history for this message
Andy Matuschak (andymatuschak) said :
#3

It'll be an ownerless floating window. The menu bar will display the features of whatever app was last selected.

Revision history for this message
Trygve (sparkle-xericdesign) said :
#4

Which plist should be controlling this? In my prefpane I have a box for "auto check for updates" this save an "autoUpdate" key to my prefpane.plist. If the sparkle frameowrk and object are in helperA, do the sparkle keys need to be in helperA.plist? Does using [SUUpdater updaterForBundle:(NSBundle *)myBundle] to set the bundle to the prefpane have any affect on this?
If I put a Check for Update Now button in the prefpane, I guess it has to send a notification to the helper app since the updater is not in the prefpane bundle, right?

We really need an example of a prefpane and helper app.

Revision history for this message
Hofman (cmhofman) said :
#5

The bundle you pass to +updaterForBundle: is the bundle that's updated and the bundle that contains the relevant Info.plist keys, so in your case that's always your prefpane. And be aware that you shouldn't use +sharedUpdater: or an updater instance in the NIB, see the docs.

I think when you have user customizable pref settings for Sparkle this setup won't work. Sparkle does not really support it (I've already added a bug report #257001 on this, but it's postponed till after 1.5). Pref setting changes MUST ALWAYS go through Sparkle. Sparkle won't know about user defaults changes if they're made in another process, and the changes Sparkle will make (and it always does) won't be noticed by another process. Perhaps you can send notifications through DO between the processes, but you'll have to setup a DO connection for that. And I'm not sure how defaults synchronization resolves differences.

Moreover, I doubt this setup will work for other reasons as well. The updater will relaunch the app that's running Skim, even though it updates the bundle passed through Sparkle. So in this case the prefpane will be updated, while app A will be relaunched (not the system preferences).

These problems could be overcome, but it's far from trivial and may require changes to the Sparkle code.

Revision history for this message
Trygve (sparkle-xericdesign) said :
#6

So I am passing my prefpane bundle to + updaterForBundle. My prefpane NIB does not coantain any sparkle object.

The only option I give users is a checkbox in the prefpane "[x] Check for updates". This pref setting is stored in the prefpane.plist and is read by the helper App.

The HelperApp contains the SUpdater object and it's init method calls

 SUUpdater * updater = [SUUpdater updaterForBundle:[NSBundle bundleWithPath:[self prefBundlePath]]];
 [updater setAutomaticallyChecksForUpdates:YES];
 [updater resetUpdateCycle];

which seems to work. I can setup a notification so that when the user changes the setting of the checkbox, a notification is sent from the prefpane to the helper app so that the helper app can check or not check for updates... the key SUEnableAutomaticChecks is always set to YES in the prefpane info.plist., but setAutomaticallyChecksForUpdates should be able to override that, right?

What is Skim?

How can I get sparkle to download an updated prefpane and just launch the new prefpane, rather than the helper app (which would be within the prefpane)?

How does this relaunching process work?

Revision history for this message
Trygve (sparkle-xericdesign) said :
#7

My prefpane keeps track of which version was last launched so that if a user manually updates, it will quit the helper apps when a new version of the prefpane is lauched (since old helper apps may still be running).

In a similar way, my HelperApp could just launch the prefpane and quit itself if it sees that it is a new vesion than the last pref pane launch. This way Sparkle would relaunch the helper app (since that is where the updater object is even though the updaterForBundle was set to the prefpane). The helper app would immediately quit and launch the prefpane.

Thoughts?

Why doesn't Sparkle attempt to relaunch the bundle passed into updaterForBundle ???

Does anyone have this working with a prefpane and helper app?

Revision history for this message
Hofman (cmhofman) said :
#8

> which seems to work.

Maybe, but I may just as well not work for some user. If it works (even in all your test) that's just a coincidence, it's not guaranteed to work.

> the key SUEnableAutomaticChecks is always set to YES in the prefpane info.plist.,
> but setAutomaticallyChecksForUpdates should be able to override that, right?

Not exactly, as the names suggest they're not really the same thing. SUEnableAutomaticChecks says that it /may allow/ automatic checks, while automaticallyChecksForUpdates determines whether it will do so. You're right that in the end the latter (when it's set) is the one that's relevant.

> What is Skim?

Sorry, automatism, I meant Sparkle of course.

> How can I get sparkle to download an updated prefpane and just launch the new prefpane,
> rather than the helper app (which would be within the prefpane)?

That requires a rewrite of Sparkle's code, in particular the SUInstaller classes. I can't tell you how.

> In a similar way, my HelperApp could just launch the prefpane and quit itself if it sees that it is a new vesion than the last pref
> pane launch. This way Sparkle would relaunch the helper app (since that is where the updater object is even though the
> updaterForBundle was set to the prefpane). The helper app would immediately quit and launch the prefpane.

I'm not sure even if this is possible. Can you find out which prefpanes are loaded? I'd say that when you launch the prefpane nothing will happen, because the old version was already running in System Preferences.

> Why doesn't Sparkle attempt to relaunch the bundle passed into updaterForBundle ???

Because it doesn't. Moreover, you're not terminating (and relaunching) a /bundle/ but rather a /process/, and it's far from trivial to figure out a process from a bundle (the other way around is much easier, because the process usually knows where its executable is).

> Does anyone have this working with a prefpane and helper app?

You may have a look at my attempt for an updater agent app, I've attached it to bug #257001. Haven't really tested it though, just a proof of concept.

Can you help with this problem?

Provide an answer of your own, or ask Trygve for more information if necessary.

To post a message you must log in.