Header file Velopack.h
enum vpkc_update_check_t
: int8_t;
struct vpkc_update_options_t;
struct vpkc_locator_config_t;
using vpkc_update_manager_t = void;
struct vpkc_asset_t;
struct vpkc_update_info_t;
using vpkc_progress_callback_t = void(*)(void*, size_t);
using vpkc_hook_callback_t = void(*)(void*, char const*);
using vpkc_log_callback_t = void(*)(void*, char const*, char const*);
extern "C"
{
bool vpkc_new_update_manager(char const* psz_url_or_path, vpkc_update_options_t* p_options, vpkc_locator_config_t* p_locator, vpkc_update_manager_t** p_manager);
size_t vpkc_get_current_version(vpkc_update_manager_t* p_manager, char* psz_version, size_t c_version);
size_t vpkc_get_app_id(vpkc_update_manager_t* p_manager, char* psz_id, size_t c_id);
bool vpkc_is_portable(vpkc_update_manager_t* p_manager);
bool vpkc_update_pending_restart(vpkc_update_manager_t* p_manager, vpkc_asset_t* p_asset);
vpkc_update_check_t vpkc_check_for_updates(vpkc_update_manager_t* p_manager, vpkc_update_info_t* p_update);
bool vpkc_download_updates(vpkc_update_manager_t* p_manager, vpkc_update_info_t* p_update, vpkc_progress_callback_t cb_progress, void* p_user_data);
bool vpkc_wait_exit_then_apply_update(vpkc_update_manager_t* p_manager, vpkc_asset_t* p_asset, bool b_silent, bool b_restart, char** p_restart_args, size_t c_restart_args);
void vpkc_free_update_manager(vpkc_update_manager_t* p_manager);
void vpkc_free_update_info(vpkc_update_info_t* p_update_info);
void vpkc_free_asset(vpkc_asset_t* p_asset);
void vpkc_app_run(void* p_user_data);
void vpkc_app_set_auto_apply_on_startup(bool b_auto_apply);
void vpkc_app_set_args(char** p_args, size_t c_args);
void vpkc_app_set_locator(vpkc_locator_config_t* p_locator);
void vpkc_app_set_hook_after_install(vpkc_hook_callback_t cb_after_install);
void vpkc_app_set_hook_before_uninstall(vpkc_hook_callback_t cb_before_uninstall);
void vpkc_app_set_hook_before_update(vpkc_hook_callback_t cb_before_update);
void vpkc_app_set_hook_after_update(vpkc_hook_callback_t cb_after_update);
void vpkc_app_set_hook_first_run(vpkc_hook_callback_t cb_first_run);
void vpkc_app_set_hook_restarted(vpkc_hook_callback_t cb_restarted);
size_t vpkc_get_last_error(char* psz_error, size_t c_error);
void vpkc_set_logger(vpkc_log_callback_t cb_log, void* p_user_data);
}
Enumeration vpkc_update_check_t
enum vpkc_update_check_t
: int8_t
{
UPDATE_ERROR = -1,
UPDATE_AVAILABLE = 0,
NO_UPDATE_AVAILABLE = 1,
REMOTE_IS_EMPTY = 2
};
The result of a call to check for updates. This can indicate that an update is available, or that an error occurred.
Struct vpkc_update_options_t
struct vpkc_update_options_t
{
bool AllowVersionDowngrade;
char* ExplicitChannel;
};
Options to customise the behaviour of UpdateManager.
Variable vpkc_update_options_t::AllowVersionDowngrade
bool AllowVersionDowngrade;
Allows UpdateManager to update to a version that’s lower than the current version (i.e. downgrading).
This could happen if a release has bugs and was retracted from the release feed, or if you’re using ExplicitChannel to switch channels to another channel where the latest version on that channel is lower than the current version.
Variable vpkc_update_options_t::ExplicitChannel
char* ExplicitChannel;
This option should usually be left None. <br/> Overrides the default channel used to fetch updates.
The default channel will be whatever channel was specified on the command line when building this release. For example, if the current release was packaged with ‘–channel beta’, then the default channel will be ‘beta’. This allows users to automatically receive updates from the same channel they installed from. This options allows you to explicitly switch channels, for example if the user wished to switch back to the ‘stable’ channel without having to reinstall the application.
Struct vpkc_locator_config_t
struct vpkc_locator_config_t
{
char* RootAppDir;
char* UpdateExePath;
char* PackagesDir;
char* ManifestPath;
char* CurrentBinaryDir;
bool IsPortable;
};
VelopackLocator provides some utility functions for locating the current app important paths (eg. path to packages, update binary, and so forth).
Member variables
RootAppDir
— The root directory of the current app.UpdateExePath
— The path to the Update.exe binary.PackagesDir
— The path to the packages’ directory.ManifestPath
— The current app manifest.CurrentBinaryDir
— The directory containing the application’s user binaries.IsPortable
— Whether the current application is portable or installed.
Type alias vpkc_update_manager_t
using vpkc_update_manager_t = void;
Opaque type for the Velopack UpdateManager. Must be freed with vpkc_free_update_manager
.
Struct vpkc_asset_t
struct vpkc_asset_t
{
char* PackageId;
char* Version;
char* Type;
char* FileName;
char* SHA1;
char* SHA256;
uint64_t Size;
char* NotesMarkdown;
char* NotesHtml;
};
An individual Velopack asset, could refer to an asset on-disk or in a remote package feed.
Member variables
PackageId
— The name or Id of the package containing this release.Version
— The version of this release.Type
— The type of asset (eg. “Full” or “Delta”).FileName
— The filename of the update package containing this release.SHA1
— The SHA1 checksum of the update package containing this release.SHA256
— The SHA256 checksum of the update package containing this release.Size
— The size in bytes of the update package containing this release.NotesMarkdown
— The release notes in markdown format, as passed to Velopack when packaging the release. This may be an empty string.NotesHtml
— The release notes in HTML format, transformed from Markdown when packaging the release. This may be an empty string.
Struct vpkc_update_info_t
struct vpkc_update_info_t
{
vpkc_asset_t TargetFullRelease;
bool IsDowngrade;
};
Holds information about the current version and pending updates, such as how many there are, and access to release notes.
Member variables
TargetFullRelease
— The available version that we are updating to.
Variable vpkc_update_info_t::IsDowngrade
bool IsDowngrade;
True if the update is a version downgrade or lateral move (such as when switching channels to the same version number).
In this case, only full updates are allowed, and any local packages on disk newer than the downloaded version will be deleted.
Type alias vpkc_progress_callback_t
using vpkc_progress_callback_t = void(*)(void*, size_t);
Progress callback function.
Type alias vpkc_hook_callback_t
using vpkc_hook_callback_t = void(*)(void*, char const*);
VelopackApp startup hook callback function.
Type alias vpkc_log_callback_t
using vpkc_log_callback_t = void(*)(void*, char const*, char const*);
Log callback function.
Function vpkc_new_update_manager
bool vpkc_new_update_manager(char const* psz_url_or_path, vpkc_update_options_t* p_options, vpkc_locator_config_t* p_locator, vpkc_update_manager_t** p_manager);
Create a new UpdateManager instance.
@param urlOrPath Location of the update server or path to the local update directory. @param options Optional extra configuration for update manager. @param locator Override the default locator configuration (usually used for testing / mocks).
Function vpkc_get_current_version
size_t vpkc_get_current_version(vpkc_update_manager_t* p_manager, char* psz_version, size_t c_version);
Returns the currently installed version of the app.
Function vpkc_get_app_id
size_t vpkc_get_app_id(vpkc_update_manager_t* p_manager, char* psz_id, size_t c_id);
Returns the currently installed app id.
Function vpkc_is_portable
bool vpkc_is_portable(vpkc_update_manager_t* p_manager);
Returns whether the app is in portable mode. On Windows this can be true or false.
On MacOS and Linux this will always be true.
Function vpkc_update_pending_restart
bool vpkc_update_pending_restart(vpkc_update_manager_t* p_manager, vpkc_asset_t* p_asset);
Returns an UpdateInfo object if there is an update downloaded which still needs to be applied.
You can pass the UpdateInfo object to waitExitThenApplyUpdate to apply the update.
Function vpkc_check_for_updates
vpkc_update_check_t vpkc_check_for_updates(vpkc_update_manager_t* p_manager, vpkc_update_info_t* p_update);
Checks for updates, returning None if there are none available. If there are updates available, this method will return an UpdateInfo object containing the latest available release, and any delta updates that can be applied if they are available.
Function vpkc_download_updates
bool vpkc_download_updates(vpkc_update_manager_t* p_manager, vpkc_update_info_t* p_update, vpkc_progress_callback_t cb_progress, void* p_user_data);
Downloads the specified updates to the local app packages directory. Progress is reported back to the caller via an optional callback.
This function will acquire a global update lock so may fail if there is already another update operation in progress.
-
If the update contains delta packages and the delta feature is enabled this method will attempt to unpack and prepare them.
-
If there is no delta update available, or there is an error preparing delta packages, this method will fall back to downloading the full version of the update.
Function vpkc_wait_exit_then_apply_update
bool vpkc_wait_exit_then_apply_update(vpkc_update_manager_t* p_manager, vpkc_asset_t* p_asset, bool b_silent, bool b_restart, char** p_restart_args, size_t c_restart_args);
This will launch the Velopack updater and tell it to wait for this program to exit gracefully.
You should then clean up any state and exit your app. The updater will apply updates and then optionally restart your app. The updater will only wait for 60 seconds before giving up.
Function vpkc_free_update_manager
void vpkc_free_update_manager(vpkc_update_manager_t* p_manager);
Frees a vpkc_update_manager_t instance.
Function vpkc_free_update_info
void vpkc_free_update_info(vpkc_update_info_t* p_update_info);
Frees a vpkc_update_info_t instance.
Function vpkc_free_asset
void vpkc_free_asset(vpkc_asset_t* p_asset);
Frees a vpkc_asset_t instance.
Function vpkc_app_run
void vpkc_app_run(void* p_user_data);
VelopackApp helps you to handle app activation events correctly.
This should be used as early as possible in your application startup code. (eg. the beginning of main() or wherever your entry point is)
Function vpkc_app_set_auto_apply_on_startup
void vpkc_app_set_auto_apply_on_startup(bool b_auto_apply);
Set whether to automatically apply downloaded updates on startup. This is ON by default.
Function vpkc_app_set_args
void vpkc_app_set_args(char** p_args, size_t c_args);
Override the command line arguments used by VelopackApp. (by default this is env::args().skip(1))
Function vpkc_app_set_locator
void vpkc_app_set_locator(vpkc_locator_config_t* p_locator);
VelopackLocator provides some utility functions for locating the current app important paths (eg. path to packages, update binary, and so forth).
Function vpkc_app_set_hook_after_install
void vpkc_app_set_hook_after_install(vpkc_hook_callback_t cb_after_install);
WARNING: FastCallback hooks are run during critical stages of Velopack operations.
Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
Function vpkc_app_set_hook_before_uninstall
void vpkc_app_set_hook_before_uninstall(vpkc_hook_callback_t cb_before_uninstall);
WARNING: FastCallback hooks are run during critical stages of Velopack operations.
Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
Function vpkc_app_set_hook_before_update
void vpkc_app_set_hook_before_update(vpkc_hook_callback_t cb_before_update);
WARNING: FastCallback hooks are run during critical stages of Velopack operations.
Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
Function vpkc_app_set_hook_after_update
void vpkc_app_set_hook_after_update(vpkc_hook_callback_t cb_after_update);
WARNING: FastCallback hooks are run during critical stages of Velopack operations.
Your code will be run and then the process will exit. If your code has not completed within 30 seconds, it will be terminated. Only supported on windows; On other operating systems, this will never be called.
Function vpkc_app_set_hook_first_run
void vpkc_app_set_hook_first_run(vpkc_hook_callback_t cb_first_run);
This hook is triggered when the application is started for the first time after installation.
Function vpkc_app_set_hook_restarted
void vpkc_app_set_hook_restarted(vpkc_hook_callback_t cb_restarted);
This hook is triggered when the application is restarted by Velopack after installing updates.
Function vpkc_get_last_error
size_t vpkc_get_last_error(char* psz_error, size_t c_error);
Get the last error message that occurred in the Velopack library.
Function vpkc_set_logger
void vpkc_set_logger(vpkc_log_callback_t cb_log, void* p_user_data);
Set a custom log callback. This will be called for all log messages generated by the Velopack library.