Chromium Updater
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.9 KiB

13 years ago
  1. //
  2. // SUUpdater.h
  3. // Sparkle
  4. //
  5. // Created by Andy Matuschak on 1/4/06.
  6. // Copyright 2006 Andy Matuschak. All rights reserved.
  7. //
  8. #ifndef SUUPDATER_H
  9. #define SUUPDATER_H
  10. #import <Sparkle/SUVersionComparisonProtocol.h>
  11. @class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
  12. @interface SUUpdater : NSObject
  13. {
  14. @private
  15. NSTimer *checkTimer;
  16. SUUpdateDriver *driver;
  17. NSString *customUserAgentString;
  18. SUHost *host;
  19. IBOutlet id delegate;
  20. }
  21. + (SUUpdater *)sharedUpdater;
  22. + (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
  23. - initForBundle:(NSBundle *)bundle;
  24. - (NSBundle *)hostBundle;
  25. - (void)setDelegate:(id)delegate;
  26. - delegate;
  27. - (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecks;
  28. - (BOOL)automaticallyChecksForUpdates;
  29. - (void)setUpdateCheckInterval:(NSTimeInterval)interval;
  30. - (NSTimeInterval)updateCheckInterval;
  31. - (void)setFeedURL:(NSURL *)feedURL;
  32. - (NSURL *)feedURL;
  33. - (void)setUserAgentString:(NSString *)userAgent;
  34. - (NSString *)userAgentString;
  35. - (void)setSendsSystemProfile:(BOOL)sendsSystemProfile;
  36. - (BOOL)sendsSystemProfile;
  37. - (void)setAutomaticallyDownloadsUpdates:(BOOL)automaticallyDownloadsUpdates;
  38. - (BOOL)automaticallyDownloadsUpdates;
  39. // This IBAction is meant for a main menu item. Hook up any menu item to this action,
  40. // and Sparkle will check for updates and report back its findings verbosely.
  41. - (IBAction)checkForUpdates:sender;
  42. // This kicks off an update meant to be programmatically initiated. That is, it will display no UI unless it actually finds an update,
  43. // in which case it proceeds as usual. If the fully automated updating is turned on, however, this will invoke that behavior, and if an
  44. // update is found, it will be downloaded and prepped for installation.
  45. - (void)checkForUpdatesInBackground;
  46. // Date of last update check. Returns null if no check has been performed.
  47. - (NSDate*)lastUpdateCheckDate;
  48. // This begins a "probing" check for updates which will not actually offer to update to that version. The delegate methods, though,
  49. // (up to updater:didFindValidUpdate: and updaterDidNotFindUpdate:), are called, so you can use that information in your UI.
  50. - (void)checkForUpdateInformation;
  51. // Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. This call does not change the date of the next check, but only the internal NSTimer.
  52. - (void)resetUpdateCycle;
  53. - (BOOL)updateInProgress;
  54. @end
  55. @interface NSObject (SUUpdaterDelegateInformalProtocol)
  56. // This method allows you to add extra parameters to the appcast URL, potentially based on whether or not Sparkle will also be sending along the system profile. This method should return an array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
  57. - (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
  58. // Use this to override the default behavior for Sparkle prompting the user about automatic update checks.
  59. - (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)bundle;
  60. // Implement this if you want to do some special handling with the appcast once it finishes loading.
  61. - (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
  62. // If you're using special logic or extensions in your appcast, implement this to use your own logic for finding
  63. // a valid update, if any, in the given appcast.
  64. - (SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)bundle;
  65. // Sent when a valid update is found by the update driver.
  66. - (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)update;
  67. // Sent when a valid update is not found.
  68. - (void)updaterDidNotFindUpdate:(SUUpdater *)update;
  69. // Sent immediately before installing the specified update.
  70. - (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update;
  71. // Return YES to delay the relaunch until you do some processing; invoke the given NSInvocation to continue.
  72. - (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update untilInvoking:(NSInvocation *)invocation;
  73. // Called immediately before relaunching.
  74. - (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
  75. // This method allows you to provide a custom version comparator.
  76. // If you don't implement this method or return nil, the standard version comparator will be used.
  77. - (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
  78. // Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
  79. - (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
  80. @end
  81. // Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
  82. #ifdef DEBUG
  83. #define SU_MIN_CHECK_INTERVAL 60
  84. #else
  85. #define SU_MIN_CHECK_INTERVAL 60*60
  86. #endif
  87. #ifdef DEBUG
  88. #define SU_DEFAULT_CHECK_INTERVAL 60
  89. #else
  90. #define SU_DEFAULT_CHECK_INTERVAL 60*60*24
  91. #endif
  92. #endif