1 // 2 // UKUpdateChecker.h 3 // NiftyFeatures 4 // 5 // Created by Uli Kusterer on Sun Nov 23 2003. 6 // Copyright (c) 2003 M. Uli Kusterer. All rights reserved. 7 // 8 9 10 /* 11 Directions: Instantiate one of these in your MainMenu.nib. Hook up your 12 "Check for updates..." menu item (should be the second in your 13 <application name> menu, immediately after the "About" item) to 14 the checkForUpdates: action. 15 16 At first startup, this will ask the user whether she wants it 17 to check for updates at each startup. It will remember that 18 choice in the standard user defaults, and if it was yes, it 19 will check at each startup, displaying a message whenever 20 a newer version becomes available. 21 22 Also note that the URL where this expects the version info file 23 to be is in the Localizable.strings file, as are all messages 24 this class displays. 25 */ 26 27 // ----------------------------------------------------------------------------- 28 // Headers: 29 // ----------------------------------------------------------------------------- 30 31 #import <AppKit/AppKit.h> 32 #import <AppKit/AppKit.h> 33 34 // ----------------------------------------------------------------------------- 35 // Constants: 36 // ----------------------------------------------------------------------------- 37 38 // New (MacPad-compatible) Plist keys: 39 #define UKUpdateCheckerURLFilename @"MacPAD" // MacPAD.url file in your bundle's "Resources" folder with URL of .plist file listing the updates. 40 #define UKUpdateCheckerVersionPlistKey @"productVersion" // String holding newest version number. 41 #define UKUpdateCheckerURLPlistKey @"productPageURL" // String with product web page URL. 42 43 // Old Plist keys: (legacy, do not use these, only so you can keep your old 44 // files until you have time to update them) 45 #define UKUpdateCheckerOldVersionPlistKey @"version" // String holding newest version number. 46 #define UKUpdateCheckerOldURLPlistKey @"url" // String with download web page URL. 47 48 // Only check at startup every N days. Since checking every time at startup 49 // can cause huge bandwidth problems, you can use this number to adjust the 50 // frequency. It won't check more often than once per day, anyway. 51 #ifndef DAYS_BETWEEN_CHECKS 52 #define DAYS_BETWEEN_CHECKS 5 // Default: 10, you may change this. 53 #endif 54 55 56 // ----------------------------------------------------------------------------- 57 // UKUpdateChecker class: 58 // ----------------------------------------------------------------------------- 59 60 61 @interface UKUpdateChecker : NSObject 62 { 63 IBOutlet NSButton* prefsButton; // Optional button in the preferences window for turning "check at startup" on/off. 64 } 65 66 // Action for the "check for updates" menu item: 67 -(IBAction) checkForUpdates: (id)sender; 68 69 70 // Use this as the action of any "Preferences" button for setting checkAtStartup you may have: 71 -(IBAction) takeBoolFromObject: (id)sender; 72 73 74 // This object handles it all for you, but if you need to, use this to turn on/off checking at startup: 75 -(void) setCheckAtStartup: (BOOL)shouldCheck; 76 -(BOOL) checkAtStartup; 77 78 79 // Private: 80 -(void) checkForUpdatesAndNotifyIfUnsuccessful: (BOOL)doNotify; 81 82 @end 83