Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GothicChess.Com

macrumors regular
Original poster
Apr 6, 2007
126
0
Philadelphia, PA
I am writing an application that will require a fair number of large external files, but every user might not want all of them. Just as I was thinking how the best way to distribute the app without making a complex installer (large download anyway) or stripping down the app too much, I received a "Software Update" notification.

Then, the little light bulb went off :)

I can make the installer build all of the essential support files, and then allow the user the option to do a "Software Update" and pull down the files at their leisure.

Does anyone know of a link that shows some sample source code that demonstrates how Apple does their own "Software Update"?

I would need "two flavors" of it:

1. User Initiates -- If they want more of the support files, then can use a menu option to make a request.

2. Server Side Initiates -- If a "necessary support file changes", it would be great if I could notify everyone that is connected, the way Apple does.

I know there is probably a mountain of code to handle this request, but if I could just find out the core API files I would be able to handle all of the tedium required to make this work.

Thanks in advance to all who share their ideas!
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
First off, there is no "API" for this. Generally, one develops a library/framework for handling this, and reuses it over and over in each app, since it's so common of a feature (see Sparkle).

Second, what are you coding in? Cocoa, Java, etc?

Generally how software updates are done, is you have a master list (XML) on your server that lists every possible update (with details such as name, description, version, etc). Then you have the local files all cataloged somehow, each file with its version number associated with it (in the case of Cocoa, each bundle has its own version string already). If you're not developing in Cocoa, you will have to figure out a way to associate version numbers with a file or folder.

Then you periodically (on launch, every X minutes, etc) load the XML on the server, and compare what you have on the local machine, and finally, present a dialog to the user with the new updates.
 

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
2. Server Side Initiates -- If a "necessary support file changes", it would be great if I could notify everyone that is connected, the way Apple does.

It doesn't work this way. Both scenarios work the same way. Apple can't "push" code, it's just that Software Update automatically checks Apple's servers for updates every so often and notifies you if there are any available that you don't have installed. Software update doesn't care if they're new or not, so the exact same paradigm could just as easily be used to install/update optional components.

All that said, you may want to look closely at Sparkle because it might be easier to modify it to suit your needs than to roll your own solution from scratch. Sparkle is free and open source and licensed under the BSD license so you're welcome to use it in closed source/commercial apps.
 

GothicChess.Com

macrumors regular
Original poster
Apr 6, 2007
126
0
Philadelphia, PA
Second, what are you coding in? Cocoa, Java, etc?

I am writing it in C with the Carbon API using XCode.

Then you periodically (on launch, every X minutes, etc) load the XML on the server, and compare what you have on the local machine, and finally, present a dialog to the user with the new updates.

I understand conceptually how to do this, but how does one "locate" all of the users of the software that are online at a given moment in time?

That has to be rather difficult!

And where can one get this "Sparkle" code, or should I just try googling it?
 

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
15
Grand Rapids, MI, USA
First off, there is no "API" for this. Generally, one develops a library/framework for handling this, and reuses it over and over in each app, since it's so common of a feature (see Sparkle).

This is a really nice product. And I've taken advantage of it, I guess, because Adium updates this way. It does an okay job of managing security. On the plus side, it makes the user provide authorization to update things in the /applications folder if the user does not own rights (it still drives me crazy that Firefox somehow subverts this... it really shouldn't be able to do so! :mad: ). The downside is that, at least in what I've seen with Adium, if the user accidentally mistypes their password or admin account and hits the button, not only will it fail, but it will terminate the updating procedure. This means that the user will have to download the update file AGAIN! :rolleyes:

But still, it's a great project overall. :)

http://sparkle.andymatuschak.org/
 

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
I understand conceptually how to do this, but how does one "locate" all of the users of the software that are online at a given moment in time?

That has to be rather difficult!

Like I explained, that's not how it's done at all. Nevermind the technical issues (which are huge) there are some pretty big ethical problems with the idea. It's the software on the user's computer that checks for updates. There is no central "pushing" of updates going on. The server doesn't know about the users out there needing to be updated, it merely provides a way for the software to check if it needs to update itself. Does that make sense?

EDIT: Ahh, I see that you've edited your post with a note that you realize this. Nevermind...
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
And where can one get this "Sparkle" code, or should I just try googling it?

Sparkle is a Cocoa framework.

However, check out Nano. It is a C++ wrapper for much of Carbon and provides several nice features that are similar to what Cocoa has. It comes with a software updating feature - you might be able to use that code in your app (looks like it works very similarly to Sparkle).
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
The downside is that, at least in what I've seen with Adium, if the user accidentally mistypes their password or admin account and hits the button, not only will it fail, but it will terminate the updating procedure. This means that the user will have to download the update file AGAIN!

If some enthusiastic new Cocoa programmer felt like fixing this I'd certainly be willing to answer questions about the code, since I've worked on it before...

< looks around at the forum hopefully ;) >
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.