File: programming/cocoa/NiftyFeatures.zip/NiftyFeatures/UKUpdateChecker.m


//
//  UKUpdateChecker.m
//  NiftyFeatures
//
//  Created by Uli Kusterer on Sun Nov 23 2003.
//  Copyright (c) 2003 M. Uli Kusterer. All rights reserved.
//
 
#import "UKUpdateChecker.h"
// -----------------------------------------------------------------------------
//	awakeFromNib:
//		This object has been created and loaded at startup. If this is first
//		launch, ask user whether we should check for updates periodically at
//		startup and adjust the prefs accurately.
//
//		If the user wants us to check for updates periodically, check whether
//		it is time and if so, initiate the check.
//
//	REVISIONS:
//		2004-03-19	witness	Documented.
// -----------------------------------------------------------------------------
"UKUpdateChecker:CheckAtStartup""UKUpdateChecker:LastCheckDate"// No setting in prefs yet? First launch! Ask!
"CHECK_FOR_UPDATES_TITLE", @"UKUpdateChecker", @"Asking whether to check for updates at startup - dialog title""CHECK_FOR_UPDATES_TEXT", @"UKUpdateChecker", @"Asking whether to check for updates at startup - dialog text""Yes""No"// Save user's preference to prefs file:
"UKUpdateChecker:CheckAtStartup"// Update prefs button, if we have one.
	
	// If user wants us to check for updates at startup, do so:
// Determine how long since last check:
// If there's no date in prefs, use something guaranteed to be past.
// If last check was more than DAYS_BETWEEN_CHECKS days ago, check again now:
"UKUpdateChecker:LastCheckDate"];
		}
	}
}
 
 
// -----------------------------------------------------------------------------
//	checkForUpdates:
//		IBAction to hook up to the "check for updates" menu item.
//
//	REVISIONS:
//		2004-03-19	witness	Documented.
// -----------------------------------------------------------------------------
// YES means we *also* tell the user about failure, since this is in response to a menu item.
}
 
 
// -----------------------------------------------------------------------------
//	latestVersionsDictionary:
//		Load a dictionary containing info on the latest versions of this app.
//
//		This first tries to get MacPAD-compatible version information. If the
//		developer didn't provide that, it will try the old UKUpdateChecker
//		scheme instead.
//
//	REVISIONS:
//		2004-03-19	witness	Documented.
// -----------------------------------------------------------------------------
"url"];
	
	// Do we have a MacPAD.url file?
// MacPAD-compatible!
"\n"// Either this is the only line, or the line following [InternetShortcut]
'/'		// Directory path? Append bundle identifier and .plist to get an actual file path to download.
'=' ) // CGI parameter?
".plist"// Download info from that URL.
// Old-style UKUpdateChecker stuff:
"UPDATE_PLIST_URL", @"URL where the plist with the latest version numbers is."// -----------------------------------------------------------------------------
//	latestVersionsDictionary:
//		This does the actual update checking. This is called in a new thread
//		usually to make sure the user doesn't have to wait to work with their
//		app until this has succeeded or even worse timed out with an error.
//
//	REVISIONS:
//		2004-10-19	witness	Documented, made to run in another thread,
//							extracted actual notification into method
//							notifyAboutUpdateToNewVersion:.
// -----------------------------------------------------------------------------
// Load a .plist of application version info from a web URL:
// We were able to download a dictionary?
	{
		// Extract version number and URL from dictionary:
// Dictionary doesn't contain new MacPAD stuff? Use old UKUpdateChecker stuff instead.
// Is it current? Then tell the user, or just quietly go on, depending on doNotify:
"CFBundleVersion"// If there's an entry for this app:
		{
			// Ask user whether they'd like to open the URL for the new version:
// Otherwise, it's still a success.
        }
    }
	
	// Failed? File not found, no internet, there is no entry for our app?
"isError"// -----------------------------------------------------------------------------
//	notifyAboutUpdateToNewVersion:
//		This actually tells the user about new updates, and is therefore called
//		on the main thread.
//
//	REVISIONS:
//		2004-10-19	witness	Documented, extracted from checkForUpdatesAndNotify:.
// -----------------------------------------------------------------------------
"isError""UP_TO_DATE_TITLE", @"UKUpdateChecker", @"When soft is up-to-date - dialog title""UP_TO_DATE_TEXT", @"UKUpdateChecker", @"When soft is up-to-date - dialog text""OK", @"UKUpdateChecker", @"""NEW_VERSION_TITLE", @"UKUpdateChecker", @"A New Version is Available - dialog title""NEW_VERSION_TEXT", @"UKUpdateChecker", @"A New Version is Available - dialog text""OK", @"UKUpdateChecker", @"""Cancel", @"UKUpdateChecker", @""// Yes?
//Open!
"UPDATE_ERROR_TITLE", @"UKUpdateChecker", @"When update test failed - dialog title""UPDATE_ERROR_TEXT", @"UKUpdateChecker", @"When update test failed - dialog text"),
						 @"OK"// -----------------------------------------------------------------------------
//	takeBoolFromObject:
//		Action for the "check at startup" checkbox in your preferences.
//
//	REVISIONS:
//		2004-10-19	witness	Documented.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
//	setCheckAtStartup:
//		Mutator for startup check (de)activation.
//
//	REVISIONS:
//		2004-10-19	witness	Documented.
// -----------------------------------------------------------------------------
"UKUpdateChecker:CheckAtStartup""UKUpdateChecker:LastCheckDate"];
}
 
 
// -----------------------------------------------------------------------------
//	checkAtStartup:
//		Accessor for finding out whether this will check at startup.
//
//	REVISIONS:
//		2004-10-19	witness	Documented.
// -----------------------------------------------------------------------------
"UKUpdateChecker:CheckAtStartup"

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.