vupdate.h Header

Platform Contract

#include <vortex/vupdate.h>

Types

struct UpdateOptions Settings for update checks, which update_options() reads from the app's environment.
struct UpdateResult Result of one update check, read from the app's latest.json manifest.

Type Aliases

using UpdateCallback Callback that receives the UpdateResult of check_for_updates().

Functions

int compare_versions(const std::string & a, const std::string & b)
bool parse_update_manifest(const std::string & body, const std::string & platform_key, UpdateResult & out)
UpdateOptions update_options(const VApp & app)
void check_for_updates(VApp & app, const UpdateOptions & options, UpdateCallback callback)

Type Alias Documentation

using UpdateCallback = std::function<void (const UpdateResult &)>

Callback that receives the UpdateResult of check_for_updates().

Function Documentation

int compare_versions(const std::string & a, const std::string & b)

Compares two versions, like "2.0.0" and "2.1.0-beta.1".

Returns a negative number when a is older than b, 0 when they're the same, and a positive number when a is newer. Versions compare by the Semantic Versioning rules, with a few allowances:

  • a missing number counts as 0, so "2.1" equals "2.1.0"
  • a leading "v", like in "v2.1.0", is ignored
  • build metadata, like "+abc123", is ignored

A release is newer than its own pre-releases, so "2.0.0" is newer than "2.0.0-alpha.1".

bool parse_update_manifest(const std::string & body, const std::string & platform_key, UpdateResult & out)

Reads the manifest text in body into out, with the download for platform_key (see UpdateResult).

Fills out's manifest members only, and leaves ok and update_available for the caller. Returns false, with out.error set, when body isn't a JSON object or has no version.

UpdateOptions update_options(const VApp & app)

Returns the UpdateOptions that the desktop runner set in app's environment.

An empty manifestUrl means that the app has update checks off.

void check_for_updates(VApp & app, const UpdateOptions & options, UpdateCallback callback)

Downloads the manifest with VApp::http(), then calls callback on the UI thread with the result.

The check compares the manifest's version to VApp::app_version(). It fails without a download when options has no manifestUrl or the app has no version. Every download attempt stores its time under kUpdateLastCheckKey, even a failed one.

A version that the user skipped still shows as an update here, so a manual check can show it. The update prompt hides skipped versions itself.

› Documentation
Appearance
Theme
—