Class AutomaticUpdater
- java.lang.Object
-
- ca.cgjennings.apps.arkham.plugins.catalog.AutomaticUpdater
-
public class AutomaticUpdater extends java.lang.Object
Checks for updates to plug-ins and the application at regular intervals and displays feedback to the user when updates are available.- Since:
- 2.1
- Author:
- Chris Jennings
-
-
Field Summary
Fields Modifier and Type Field Description static int
ACTION_INSTALL
static int
ACTION_INSTALL_IMMEDIATELY
When updates are found, install the plug-ins in the background.static int
ACTION_OPEN_CATALOG
When updates are found, open the plug-in catalog dialog.static int
ACTION_SHOW_CATALOG
static int
ACTION_SHOW_MESSAGE
static int
ACTION_TELL_USER
When updates are found, tell the user about them.static int
AVAILABLE_APP_UPDATE
A bit flag returned byperformUpdate(int, boolean)
when there is an application update available.static int
AVAILABLE_NEW_PLUGIN
A bit flag returned byperformUpdate(int, boolean)
when there are new plug-ins available.static int
AVAILABLE_PLUGIN_UPDATE
A bit flag returned byperformUpdate(int, boolean)
when there is a plug-in update available.static int
FREQUENCY_ALWAYS
static int
FREQUENCY_DAILY
static int
FREQUENCY_MONTHLY
static int
FREQUENCY_NEVER
static int
FREQUENCY_WEEKLY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
getMillisecondsBetweenChecks()
Returns the number of milliseconds that elapse between automatic checks, depending on the update frequency setting.static long
getMillisecondsUntilNextCheck()
Returns the number of milliseconds before the next update check should be performed, orLong.MAX_VALUE
if no update check will be performed.static int
getUpdateAction()
static boolean
getUpdateAllCatalogs()
static int
getUpdateFrequency()
static boolean
isApplicationUpdateAvailable()
Returnstrue
if it can determine with certainty that an application update is available.static boolean
isShowingAppUpdates()
static boolean
isShowingNewPlugins()
static boolean
isUpdateOverdue()
Returnstrue
if, according to current settings, an automatic update check is overdue.static void
markUpdate()
Called when any kind of plug-in check occurs; updates the setting that tracks when the last update took place.static void
performAutomaticUpdate()
Checks if an update is overdue, and if so checks if updates are available in a separate thread.static int
performUpdate(int updateAction, boolean allCatalogs)
Performs an update check immediately, even if an update is not overdue.static void
setShowingAppUpdates(boolean show)
static void
setShowingNewPlugins(boolean show)
static void
setUpdateAction(int action)
static void
setUpdateAllCatalogs(boolean updateAll)
static void
setUpdateFrequency(int freq)
static void
startAutomaticUpdateTimer()
Starts a timer that counts down until the next automatic update is due.static void
writePendingUpdateInformation()
This is called during shutdown to write required information into user settings.
-
-
-
Field Detail
-
AVAILABLE_PLUGIN_UPDATE
public static final int AVAILABLE_PLUGIN_UPDATE
A bit flag returned byperformUpdate(int, boolean)
when there is a plug-in update available.- See Also:
- Constant Field Values
-
AVAILABLE_APP_UPDATE
public static final int AVAILABLE_APP_UPDATE
A bit flag returned byperformUpdate(int, boolean)
when there is an application update available.- See Also:
- Constant Field Values
-
AVAILABLE_NEW_PLUGIN
public static final int AVAILABLE_NEW_PLUGIN
A bit flag returned byperformUpdate(int, boolean)
when there are new plug-ins available.- See Also:
- Constant Field Values
-
ACTION_TELL_USER
public static final int ACTION_TELL_USER
When updates are found, tell the user about them.- See Also:
- Constant Field Values
-
ACTION_OPEN_CATALOG
public static final int ACTION_OPEN_CATALOG
When updates are found, open the plug-in catalog dialog.- See Also:
- Constant Field Values
-
ACTION_INSTALL_IMMEDIATELY
public static final int ACTION_INSTALL_IMMEDIATELY
When updates are found, install the plug-ins in the background.- See Also:
- Constant Field Values
-
FREQUENCY_NEVER
public static final int FREQUENCY_NEVER
- See Also:
- Constant Field Values
-
FREQUENCY_MONTHLY
public static final int FREQUENCY_MONTHLY
- See Also:
- Constant Field Values
-
FREQUENCY_WEEKLY
public static final int FREQUENCY_WEEKLY
- See Also:
- Constant Field Values
-
FREQUENCY_DAILY
public static final int FREQUENCY_DAILY
- See Also:
- Constant Field Values
-
FREQUENCY_ALWAYS
public static final int FREQUENCY_ALWAYS
- See Also:
- Constant Field Values
-
ACTION_SHOW_MESSAGE
public static final int ACTION_SHOW_MESSAGE
- See Also:
- Constant Field Values
-
ACTION_SHOW_CATALOG
public static final int ACTION_SHOW_CATALOG
- See Also:
- Constant Field Values
-
ACTION_INSTALL
public static final int ACTION_INSTALL
- See Also:
- Constant Field Values
-
-
Method Detail
-
markUpdate
public static void markUpdate()
Called when any kind of plug-in check occurs; updates the setting that tracks when the last update took place.
-
getMillisecondsBetweenChecks
public static long getMillisecondsBetweenChecks()
Returns the number of milliseconds that elapse between automatic checks, depending on the update frequency setting.- Returns:
- the ideal number of milliseconds between update checks
-
isUpdateOverdue
public static boolean isUpdateOverdue()
Returnstrue
if, according to current settings, an automatic update check is overdue.- Returns:
true
if the time since the last check is greater than the update check frequency set by the user
-
getMillisecondsUntilNextCheck
public static long getMillisecondsUntilNextCheck()
Returns the number of milliseconds before the next update check should be performed, orLong.MAX_VALUE
if no update check will be performed. Note that this may be less than 0 if an update is overdue.- Returns:
- the number of milliseconds before an update is pending, or
Long.MAX_VALUE
-
performAutomaticUpdate
public static void performAutomaticUpdate()
Checks if an update is overdue, and if so checks if updates are available in a separate thread. If they are, displays feedback to the user.
-
isApplicationUpdateAvailable
public static boolean isApplicationUpdateAvailable()
Returnstrue
if it can determine with certainty that an application update is available. If no update is available, or if any error occurs, it will returnfalse
. This call bypasses the usual update infrastructure; for example, it does not reset the time until the next update check.- Returns:
true
if an application update is available
-
performUpdate
public static int performUpdate(int updateAction, boolean allCatalogs)
Performs an update check immediately, even if an update is not overdue. The value ofupdateAction
must be one of:ACTION_TELL_USER
,ACTION_OPEN_CATALOG
,ACTION_INSTALL_IMMEDIATELY
. IfallCatalogs
istrue
, then all catalogs in the user's catalog URL history will be checked. Otherwise, only the default catalog is checked. Returns a bitwise combination oftrue
if any updates were found, orfalse
otherwise.- Parameters:
updateAction
- the action to take when updates are foundallCatalogs
- update from all catalogs in the catalog URL history, not just the primary catalog- Returns:
true
if any updates were found- Throws:
java.lang.IllegalArgumentException
- if theupdateAction
is not valid
-
writePendingUpdateInformation
public static void writePendingUpdateInformation()
This is called during shutdown to write required information into user settings. It is public only to cross a package boundary and should not be called by plug-ins.
-
getUpdateAllCatalogs
public static boolean getUpdateAllCatalogs()
-
setUpdateAllCatalogs
public static void setUpdateAllCatalogs(boolean updateAll)
-
getUpdateFrequency
public static int getUpdateFrequency()
-
setUpdateFrequency
public static void setUpdateFrequency(int freq)
-
getUpdateAction
public static int getUpdateAction()
-
setUpdateAction
public static void setUpdateAction(int action)
-
isShowingAppUpdates
public static boolean isShowingAppUpdates()
-
setShowingAppUpdates
public static void setShowingAppUpdates(boolean show)
-
isShowingNewPlugins
public static boolean isShowingNewPlugins()
-
setShowingNewPlugins
public static void setShowingNewPlugins(boolean show)
-
startAutomaticUpdateTimer
public static void startAutomaticUpdateTimer()
Starts a timer that counts down until the next automatic update is due. If the timer is already running, it will be reset to match the current update frequency. The timer is normally started during application startup.
-
-