Re: Automatic checking for program updates
Re: Automatic checking for program updates
- Subject: Re: Automatic checking for program updates
- From: Johan Kool <email@hidden>
- Date: Mon, 5 Sep 2005 21:24:30 +0100
This usually just fails for me when there is no network. Don't forget
to change the URL's and names for your specific need.
The file should be of the format:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>peacock</key>
<string>0.0.3</string>
</dict>
</plist>
-(void)checkVersion:(BOOL)quiet {
NSString *currVersionNumber = [[[NSBundle bundleForClass:[self class]]
infoDictionary] objectForKey:@"CFBundleVersion"];
NSDictionary *productVersionDict = [NSDictionary
dictionaryWithContentsOfURL:[NSURL
URLWithString:@"http://www.geo.vu.nl/~jkool/peacock/version.xml"]];
NSString *latestVersionNumber = [productVersionDict valueForKey:@"peacock"];
if([productVersionDict count] > 0 ) { // did we get anything?
if([latestVersionNumber isEqualTo: currVersionNumber] && !quiet)
{
// tell user software is up to date
NSRunAlertPanel(NSLocalizedString(@"Your Software is
up-to-date", @"Title of alert when a the user's software is up to
date."),
NSLocalizedString(@"You have the most recent version
of Peacock.", @"Alert text when the user's software is up to date."),
NSLocalizedString(@"OK", @"OK"), nil, nil);
}
else if( ![latestVersionNumber isEqualTo: currVersionNumber])
{
// tell user to download a new version
int button = NSRunAlertPanel(NSLocalizedString(@"A New
Version is Available", @"Title of alert when a the user's software is
not up to date."),
[NSString stringWithFormat:NSLocalizedString(@"A new
version of Peacock is available (version %@). Would you like to
download the new version now?", @"Alert text when the user's software
is not up to date."), latestVersionNumber],
NSLocalizedString(@"OK", @"OK"),
NSLocalizedString(@"Cancel", @"Cancel"), nil);
if(NSOKButton == button)
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL
URLWithString:@"http://www.geo.vu.nl/~jkool/peacock/"]];
}
}
} else {
if (!quiet) {
// tell user error occured
NSRunAlertPanel(NSLocalizedString(@"Version Check has
Failed", @"Title of alert when the version check has failed."),
NSLocalizedString(@"An error occured whilst trying to
retrieve the current version number from the internet.", @"Alert text
when the when the version check has failed."),
NSLocalizedString(@"OK", @"OK"), nil, nil);
}
}
}
Johan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden