Skip to content

Commit f8d638a

Browse files
committed
completed backend doc
1 parent 185609b commit f8d638a

File tree

4 files changed

+190
-8
lines changed

4 files changed

+190
-8
lines changed

doc/backends.dox

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
This page lists the different backends that are available, together with their features and how to use them. Refer
77
to this page if you want to know details about a particular plugin.
88

9+
@note In all "Arguments for QtAutoUpdater::UpdateInfo::data" sections, the data that is used as the
10+
QtAutoUpdater::UpdaterBackend::secondaryInfo arguments is highlighted by beeing marked **bold**.
11+
912
@tableofcontents
1013

1114
@section qtautoupdater_backends_types Special Types
@@ -48,6 +51,11 @@ QtAutoUpdater::AdminAuthoriser::needsAdminPermission(path). The path here is the
4851
settings. While this may work for most systems, it is recommended to always explicitly set this parameter to avoid
4952
problems.
5053

54+
@subsection qtautoupdater_backends_qtifw_info_extras Arguments for QtAutoUpdater::UpdateInfo::data
55+
Parameter | Type | JSON-Type | Description
56+
----------------|---------------|-----------|-------
57+
<b>size</b> | quint64 | number | The size of the update to be downloaded
58+
5159
@section qtautoupdater_backends_pkgkit PackageKit
5260
The plugin based on [PackageKit](https://www.freedesktop.org/software/PackageKit/) is a general plugin that can work
5361
with any package managing system that supports PackageKit. This includes most popular linux distros like Arch,
@@ -98,6 +106,11 @@ list of all the packages that make your application, which is typically just a s
98106
for updates, only updates for the packages listed here are considered by the plugin. You must always enter the
99107
packages by the full name. Wildcards are not possible for now.
100108

109+
@subsection qtautoupdater_backends_choco_info_extras Arguments for QtAutoUpdater::UpdateInfo::data
110+
Parameter | Type | JSON-Type | Description
111+
--------------------|-------------------|-----------|-------
112+
<b>oldVersion</b> | QVersionNumber | string | The currently installed version that will be replaced by the new one
113+
101114
@section qtautoupdater_backends_brew Homebrew
102115
The plugin uses the [Homebrew](https://brew.sh/) package manager for macOs to check for updates and install them.
103116
It can install updates in parallel, but also supports launching [Cakebrew](https://www.cakebrew.com/) as external
@@ -128,6 +141,12 @@ list of all the packages that make your application, which is typically just a s
128141
for updates, only updates for the packages listed here are considered by the plugin. You must always enter the
129142
packages by the full name. Wildcards are not possible for now. If your package is a cask, set the variable.
130143

144+
@subsection qtautoupdater_backends_brew_info_extras Arguments for QtAutoUpdater::UpdateInfo::data
145+
Parameter | Type | JSON-Type | Cask | Description
146+
--------------------|-------------------|-----------|-------|-------------
147+
<b>oldVersions</b> | QVariantList | array | no | The currently installed versions that will be replaced by the new one. Is a list of QVersionNumber. Not available for casks
148+
<b>oldVersion</b> | QVersionNumber | string | yes | The currently installed version that will be replaced by the new one. Only available for casks
149+
131150
@section qtautoupdater_backends_play Google Playstore
132151
When deploying your app via the [Google Playstore](https://play.google.com/store) for Android, you can use this
133152
plugin to check for updates and even install them. This works fine for most phones, but be aware that some might
@@ -154,4 +173,159 @@ This backend can be used if none of the other backends fit your distribution met
154173
create a custom plugin for such cases, for many variants this plugin suffices. It can query a webserver for
155174
JSON-encoded information about available updates, download a binary or update package of any kind and execute a
156175
selected binary to perform the update installation.
176+
177+
@subsection qtautoupdater_backends_webquery_features Features
178+
- QtAutoUpdater::UpdaterBackend::Feature::CheckUpdates
179+
- QtAutoUpdater::UpdaterBackend::Feature::CheckProgress
180+
- For downloadable installations:
181+
- QtAutoUpdater::UpdaterBackend::Feature::PerformInstall
182+
- For supported installation
183+
- QtAutoUpdater::UpdaterBackend::Feature::TriggerInstall
184+
- QtAutoUpdater::UpdaterBackend::Feature::ParallelTrigger (can be optionally enabled)
185+
186+
@subsection qtautoupdater_backends_webquery_config Configuration
187+
Parameter | Type | Default Value | Description
188+
----------------------------|---------------------------------------------------------------|-----------------------------------------------|-------------
189+
check/url | QUrl | _required_ | The URL to query to check for updates. Must be a URL unterstood and supported by QNetworkAccessManager
190+
check/autoQuery | bool | `true` | If enabled, additional information is added as query to the URL. See @ref qtautoupdater_backends_webquery_config_query for more details
191+
check/spdy | bool | `false` | Enables the use of the SPDY-Protocol
192+
check/http2 | bool | `false` | Enables the use of the HTTP2-Protocol
193+
check/hsts | bool | `false` | Enables the use of HSTS for TLS-based requests (e.g. HTTPS)
194+
check/sslConfiguration | QSslConfiguration | `QSslConfiguration::defaultConfiguration()` | The SSL configuration to use for TLS-based requests (e.g. HTTPS)
195+
check/headers | @ref qtautoupdater_backends_webquery_config_headers "Headers" | _empty_ | Additional HTTP-Headers to be added to the request. See @ref qtautoupdater_backends_webquery_config_headers for how to specify headers
196+
check/verb | QByteArray | `"GET"` | The HTTP-Verb to use for HTTP or HTTPS requests
197+
check/body | QByteArray / QIODevice / QHttpMultiPart | _empty_ | The body to send to the server with the request. By default, no body is sent (empty request)
198+
check/parser | QString | `"auto"` | The parser to use to parse the received data. Can be `"auto"`, `"json"` or `"version"`. See @ref qtautoupdater_backends_webquery_formats for more details
199+
install/download | bool | `false` | Specifies if the installation requires the previous download of a file (typically the installer itself)
200+
install/tool | QString | _empty_ | The binary to execute as installer. Can be left empty if the installer is downloaded or `url` is used
201+
install/parallel | bool | `false` | Specifies if the installer can be run in parallel to the running application
202+
install/url | QUrl | _empty_ | The URL to invoke to start the installer. Typically an app-specific URL to for example trigger an app store. Can be used instead of `tool`
203+
install/path | @ref qtautoupdater_backends_types "pathList" | _system-path_ | A list of paths where to search for the `tool` executable. If not specified, the `PATH` environment variable is used
204+
install/arguments | @ref qtautoupdater_backends_types "argList" | _empty_ | Additional arguments to be passed to `tool` when running the installer
205+
install/pwd | QString | _empty_ | The working directory to be used by `tool`. If unset, the calling processes current working directory is used
206+
install/runAsAdmin | bool | _special_ | Specifies, if the `tool` should be executed with elevated rights
207+
install/addDataArgs | bool | `false` | Specify if additional arguments of the downloaded JSON file are allowed to be added to the installer invokation. See @ref qtautoupdater_backends_webquery_info_extras for the syntax
208+
install/downloadUrl | QUrl | _empty_ | The URL to download the installer from. Can contain @ref qtautoupdater_backends_webquery_config_placeholders "placeholders"
209+
install/useInfoDownload | bool | `false` | Specify if additional arguments of the downloaded JSON file are allowed to be used as download URL. See @ref qtautoupdater_backends_webquery_info_extras for the syntax. Relative URLs are resolve to the `downloadUrl`
210+
install/headers | @ref qtautoupdater_backends_webquery_config_headers "Headers" | _empty_ | The headers to be added to the installer download request. See @ref qtautoupdater_backends_webquery_config_headers for how to specify headers
211+
install/execDownload | bool | `false` | Specify if the downloaded installer data should be used as executable and executed or if instead the path should be passed to the installer tool
212+
213+
All parameter that start with `check/` are used when checking for updates. They are used to construct a web request
214+
(typically HTTP or HTTPS) to download some kind of information about new updates. This information must be in a
215+
predefined format (See @ref qtautoupdater_backends_webquery_formats) and is parsed to provide the update
216+
information.
217+
218+
Optionally, one can specify installer information to allow the user to install updates. All parameters that start
219+
with `install/` are used for that. There are three ways to launch an installer:
220+
221+
1. **As URL:** Specify a URL as `install/url` when the user triggers the installation, the plugin will use the
222+
QDesktopServices::openUrl to open that url and launch the corresponding app. You can use this to invoke a certain
223+
local application (like steam) or open a website in the browser. If `addDataArgs` is set to true, additional
224+
query parameters can be added to the URL.
225+
2. **As local tool:** If the installer or updater is a locally available tool (i.e. executable), you can use the
226+
`install/tool` parameter to specify the binary and the `path`, `arguments`, `pwd` and `runAsAdmin` to customize
227+
how that tool is executed. If `addDataArgs` is set to true, additional arguments can be added from the JSON to the
228+
arguments.
229+
3. **As downloaded tool:** Basically the same as 2, but you use the `install/downloadUrl` to download some file
230+
before running the installer. If `tool` is set, then this tool is executed and the downloaded file is simply
231+
passed as argument to that tool. Use the `%{downloadPath}` placeholder somewhere as an argument (even multiple
232+
times, if required), and this string will be replaced with the temporary path to the downloaded file. If however
233+
the `tool` is unset, and `execDownload` is set to true, the downloaded file will be made executable and executed
234+
as the tool (with arguments, path, etc. all just like for a normal tool). But be careful to only use HTTPS for the
235+
update info and always add a hashsum to the update info to prevent malicious code from beeing downloaded and
236+
executed!
237+
238+
The default value of the `runAsAdmin` depends of the result of
239+
QtAutoUpdater::AdminAuthoriser::needsAdminPermission(path). The path here is the maintenancetool as specified in the
240+
settings. While this may work for most systems, it is recommended to always explicitly set this parameter to avoid
241+
problems.
242+
243+
@subsubsection qtautoupdater_backends_webquery_config_headers The Headers type
244+
The headers type is basically just a simple QSettings array. It has a size and various elements. Each element has
245+
a `key` and a `value` member, defining the header pair. The following example should be helpful to understand it:
246+
247+
@code
248+
# The config values:
249+
header/size=2
250+
header/0/key=Content-Type
251+
header/0/value=text/plain
252+
header/1/key=Authorization
253+
header/1/value=my-secret-passphrase
254+
255+
# The corresponding HTTP-headers
256+
Content-Type: text/plain
257+
Authorization: my-secret-passphrase
258+
@endcode
259+
260+
@subsubsection qtautoupdater_backends_webquery_config_query Additional Query Parameters
261+
If the `check/autoQuery` is set to true, then the following arguments are added to the URL-query autmatically
262+
(Only for the check request, not the download request).
263+
264+
Parameter | Value
265+
----------------|-------
266+
name | QCoreApplication::applicationName()
267+
version | QCoreApplication::applicationVersion()
268+
domain | QCoreApplication::organizationDomain()
269+
abi | QSysInfo::buildAbi()
270+
kernel-type | QSysInfo::kernelType()
271+
kernel-version | QSysInfo::kernelVersion()
272+
os-type | QSysInfo::productType()
273+
os-version | QSysInfo::productVersion()
274+
275+
@note Those are always added to the URL, even for
276+
POST-requests. If you want the query in the POST-body , create it yourself and use the `check/body` parameter to
277+
add it.
278+
279+
@subsubsection qtautoupdater_backends_webquery_config_placeholders Download URL placeholders
280+
The following placeholders can be part of the download URL. the will be automatically replaced by the corresponding
281+
value before invoking the download. The values are taken from the QtAutoUpdater::UpdateInfo that initiated the
282+
download.
283+
284+
Placeholder | Value
285+
----------------|-------
286+
`%{id}` | QtAutoUpdater::UpdateInfo::identifier()
287+
`%{name}` | QtAutoUpdater::UpdateInfo::name()
288+
`%{version}` | QtAutoUpdater::UpdateInfo::version()
289+
290+
@subsection qtautoupdater_backends_webquery_formats Check Request Formats
291+
The reply to the check for upates request can have one of two formats: `json` or `version`. There is also `auto`,
292+
which will guess the format based on the returned `Content-Type` header.
293+
294+
If the `version` format is used, the returned data should be a single, undecorated version string (e.g. `1.1.5`).
295+
This version is then combined with QCoreApplication::applicationName and QGuiApplication::applicationDisplayName
296+
to create an QtAutoUpdater::UpdateInfo representing the update to the application. You cannot specify additional
297+
data via this format.
298+
299+
The second and recommended format is `json`. This format allows you to specify multiple update infos and to add
300+
extra data. The following shows the JSON scheme:
301+
302+
@code
303+
[
304+
{
305+
"identifier": any,
306+
"name": string,
307+
"version": string,
308+
"data": object
309+
},
310+
...
311+
]
312+
@endcode
313+
314+
The json members are mapped directly to the equally named properties of QtAutoUpdater::UpdateInfo. The `data` is
315+
converted using QJsonValue::toVariant. To see what arguments can be passed via `data`, see
316+
@ref qtautoupdater_backends_webquery_info_extras
317+
318+
@subsection qtautoupdater_backends_webquery_info_extras Arguments for QtAutoUpdater::UpdateInfo::data
319+
Unlike for most other backends, many of the data arguments are process internally and thus are used to control
320+
the plugins behaviour. The following table shows all arguments with special meaning for the plugin and how they
321+
are processed by it. Of course, you can add whatever data you want in addition to those and they will be simply
322+
parsed and added to the UpdateInfo, so you can process them in your application code how you like.
323+
324+
Parameter | Type | JSON-Type | Usage
325+
------------|---------------|-----------|-------
326+
query | QVariantMap | object | A map of keys and values, that are added as URL query parameters to the `install/url` that is used to invoke an installer. The values will be automatically escaped. Is only processed, if `install/addDataArgs` is set to true
327+
arguments | QStringList | array | A list of extra arguments to be added to `install/arguments` that are used to run `install/tool`. Is only processed, if `install/addDataArgs` is set to true
328+
eulas | QVariantList | array | A list of EULAs to be show via the installer before downloading an installer. Are only shown if a download is done. Each element can either be a simple QString (for a required EULA) or a QVariantMap, with `text` beeing the EULA text and `required` a boolean to specify if the EULA must be accepted or not
329+
download | QUrl | string | A URL to be used as download URL for a downloaded installer. If the URL is relative, it is resolved via `install/downloadUrl`. Is only used if `install/useInfoDownload` is set to true.
330+
exec | bool | bool | Specifies if the downloaded data of this info can be executed. Both this and `install/execDownload` must be true in order for this to be allowed.
157331
*/

src/plugins/updater/qhomebrew/qhomebrewupdaterbackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void QHomebrewUpdaterBackend::onCaskOutdated(int exitCode, QIODevice *processDev
224224
UpdateInfo info;
225225
info.setName(match.captured(1));
226226
info.setVersion(QVersionNumber::fromString(match.captured(3)));
227-
info.setData(QStringLiteral("oldVersions"), QVariant::fromValue(QVersionNumber::fromString(match.captured(2))));
227+
info.setData(QStringLiteral("oldVersion"), QVariant::fromValue(QVersionNumber::fromString(match.captured(2))));
228228
info.setIdentifier(info.name());
229229
updates.append(info);
230230
}

0 commit comments

Comments
 (0)