Skip to content

Commit a1d2685

Browse files
committed
updated core doc
1 parent 6fac7fc commit a1d2685

File tree

7 files changed

+74
-156
lines changed

7 files changed

+74
-156
lines changed

doc/adminauthoriser.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
@class QtAutoUpdater::AdminAuthoriser
33

4-
The AdminAuthorisers task is to run a program with elevated rigths. Since the way to archive this is different
4+
The AdminAuthoriser's task is to run a program with elevated rigths. Since the way to archive this is different
55
on every platform, the authoriser is an interface. Because the "default" way to gain elevated privilegs is doing so
66
by using a GUI, the default implementation is done in the AutoUpdaterWidgets library. If you intend to use the
77
core library only, you will have to implement admin-authorisation yourself (if you require it)
@@ -24,7 +24,7 @@ instead.
2424

2525
@param program The path to the executable. This will be an absolute path
2626
@param arguments A list of arguments to be passed to the executable. Can be empty
27-
@returns `true`, if the program could be started with <b>elevated rights</b>, `false` if not
27+
@returns `true`, if the program could be started with **elevated rights**, `false` if not
2828

2929
The actual elevation and execution should be done using this function. Please note that it's possible that this function
3030
is called while the QCoreApplication is shutting down. If `false` is returned, no error will be shown to the user. If you want

doc/autoupdater.dox

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*!
2+
@namespace QtAutoUpdater
3+
4+
@brief The QtAutoUpdater namespace holds all classes that are related with the updater
5+
6+
This namespace includes both, the core library and the widgets library. Please note that
7+
the two are seperate libraries, that only share the namespace. The Core-Library is
8+
independet of the Widgets-Library and won't need a gui. The Widgets-Library requires both,
9+
a gui and the Core-Library.
10+
11+
## Core-Library:
12+
- Updater
13+
- AdminAuthoriser
14+
15+
## Widgets-Libray:
16+
- UpdateController
17+
- UpdateButton
18+
*/

doc/updater.dox

Lines changed: 27 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
/*!
2-
@namespace QtAutoUpdater
3-
4-
@brief The QtAutoUpdater namespace holds all classes that are related with the updater
5-
6-
This namespace includes both, the core library and the widgets library. Please note that
7-
the two are seperate libraries, that only share the namespace. The Core-Library is
8-
independet of the Widgets-Library and won't need a gui. The Widgets-Library requires both,
9-
a gui and the Core-Library.
10-
11-
## Core-Library:
12-
- Updater
13-
- AdminAuthoriser
14-
15-
## Widgets-Libray:
16-
- UpdateController
17-
- UpdateButton
18-
*/
19-
201
/*!
212
@class QtAutoUpdater::Updater
223

@@ -25,50 +6,7 @@ evalute the results of the tool and generate update information of it. In additi
256
it can schedule the maintenancetool to run in updater mode as soon as the application
267
finishes. (This requires the Updater instance to exist until QCoreApplication::quit is called).
278

28-
## Example
29-
The following example shows the basic usage of the updater. Only the core library is
30-
required for this example. It creates a new updater instance that is connected to the
31-
maintenancetool located at "C:/Qt/MaintenanceTool". As soon as the application starts, it will
32-
check for updates and print the update result. If updates are available, their details will
33-
be printed and the maintenancetool is scheduled to start on exit. In both cases, the
34-
application will quit afterwards.
35-
36-
@attention Since this library requires the maintenancetool that is deployed with every
37-
Qt Installer Framework installation, the examples cannot be tested without a
38-
maintenancetool! If you intend to use this library, the maintenancetool will be
39-
available for your final application. For testing purpose or the examples, I set the
40-
path to the `MaintenanceTool` that is deployed with the installation of Qt (or any
41-
other maintenancetool). So make shure to adjust the path if you try to run the examples.
42-
43-
@code{.cpp}
44-
#include <QCoreApplication>
45-
#include <QDebug>
46-
#include <updater.h>
47-
48-
int main(int argc, char *argv[])
49-
{
50-
QCoreApplication a(argc, argv);
51-
//create the updater with the application as parent -> will live long enough start the tool on exit
52-
QtAutoUpdater::Updater *updater = new QtAutoUpdater::Updater("C:/Qt/MaintenanceTool", &a);//.exe is automatically added
53-
54-
QObject::connect(updater, &QtAutoUpdater::Updater::checkUpdatesDone, [updater](bool hasUpdate, bool hasError) {
55-
qDebug() << "Has updates:" << hasUpdate << "\nHas errors:" << hasError;
56-
if(hasUpdate) {
57-
//As soon as the application quits, the maintenancetool will be started in update mode
58-
updater->runUpdaterOnExit();
59-
qDebug() << "Update info:" << updater->updateInfo();
60-
}
61-
//Quit the application
62-
qApp->quit();
63-
});
64-
65-
//start the update check
66-
updater->checkForUpdates();
67-
return a.exec();
68-
}
69-
@endcode
70-
71-
@sa QtAutoUpdater::UpdateController
9+
@sa @ref index REAMDE.md, QtAutoUpdater::UpdateController
7210
*/
7311

7412
/*!
@@ -77,8 +15,8 @@ int main(int argc, char *argv[])
7715
@default{`./maintenancetool` on Windows/X11, `../../maintenancetool` on mac}
7816

7917
The path of the maintenancetool has to be set inside of the constructor and cannot be
80-
changed later.<br>
81-
The path will be assumed relative to QCoreApplication::applicationDirPath(), the location
18+
changed later.<br/>
19+
The path will be resolved relative to QCoreApplication::applicationDirPath(), the location
8220
of the currently running application.
8321

8422
The updater will check whether or not the given path has a file-extension. If not, it
@@ -136,36 +74,19 @@ property is the result of the last update check (if one happend).
13674
/*!
13775
@fn QtAutoUpdater::Updater::Updater(QObject *)
13876

139-
@overload
14077
@param parent The object parent for QObject
14178

14279
The maintenancetool path will be set to the default one (and cannot be changed).
14380
See Updater::maintenanceToolPath for more details.
14481

145-
@overloads{
146-
@ovElem{Updater(QObject *)}
147-
@ovElem{Updater(const QString &, QObject *)}
148-
}
149-
15082
@sa Updater::maintenanceToolPath
15183
*/
15284

15385
/*!
15486
@fn QtAutoUpdater::Updater::Updater(const QString &, QObject *)
15587

156-
@overload
15788
@param maintenanceToolPath The path to the maintenancetool
158-
@param parent The object parent for QObject
159-
160-
The maintenancetool path will be set to the given one (and cannot be changed).
161-
See Updater::maintenanceToolPath for more details.
162-
163-
@overloads{
164-
@ovElem{Updater(QObject *)}
165-
@ovElem{Updater(const QString &, QObject *)}
166-
}
167-
168-
@sa Updater::maintenanceToolPath
89+
@copydetails Updater::Updater(QObject *)
16990
*/
17091

17192
/*!
@@ -184,14 +105,14 @@ Updater::abortUpdateCheck to gracefully shut down the maintenancetool
184105
@returns `true`, if the maintenancetool finished normally, `false` if not
185106

186107
Exiting normally does **not** mean the the update was successfull, only that the
187-
maintenancetool exited itself and was not killed or crashed.<br>
108+
maintenancetool exited itself and was not killed or crashed.<br/>
188109
If `false` is returned, in most cases the process either crashed or was never even
189110
able to start. Use Updater::errorCode to get the code. If the tool failed to start,
190111
it's most certanly because of an invalid path to the maintenancetool.
191112

192113
While the updater is running, this function will always return `true`.
193114

194-
@note Depending on the return of this function, the meaning of Updater::errorCode
115+
@attention Depending on the return of this function, the meaning of Updater::errorCode
195116
and Updater::errorLog will change!
196117

197118
@sa Updater::running, Updater::errorCode, Updater::errorLog
@@ -202,14 +123,15 @@ and Updater::errorLog will change!
202123

203124
@returns The exit-code of the maintenancetool or an error code
204125

205-
@note The meaning of this functions return value depends on what Updater::exitedNormally
126+
@attention The meaning of this functions return value depends on what Updater::exitedNormally
206127
returns
207128

208129
If the maintenancetool exited normally, this function will return the actual exit code
209130
of the maintenancetool. Please note that `EXIT_SUCCESS (0)` means that there are updates
210-
available and `EXIT_FAILURE (1)` can mean either no updates or some other kind of error.
211-
Please check the <a href="https://doc.qt.io/qtinstallerframework/" target="_blank">Qt Installer Framework</a>
212-
documentation for more details about the tool itself.
131+
available and `EXIT_FAILURE (1)` can mean either no updates or some other kind of error. Thus, the
132+
exit code is no indicator for success or failure. Please check the
133+
[Qt Installer Framework](https://doc.qt.io/qtinstallerframework/) documentation for more details
134+
about the tool itself.
213135

214136
If the maintenancetool did not exit normally, the returned error-code will be one of
215137
QProcess::ProcessError.
@@ -224,14 +146,14 @@ While the updater is running, this function will always return 0.
224146

225147
@returns The error log of the last run of the maintenancetool
226148

227-
@note The meaning of this functions return value depends on what Updater::exitedNormally
149+
@attention The meaning of this functions return value depends on what Updater::exitedNormally
228150
returns
229151

230-
If the maintenancetool exited normally, this function will return the cerr (standard error)
152+
If the maintenancetool exited normally, this function will return the stderr (standard error)
231153
output generated by the maintenancetool. If the maintenancetool actually fails, you
232154
can use this to find out why.
233155

234-
If the maintenancetool did not exit normally, the returned error-code will be the error
156+
If the maintenancetool did not exit normally, the returned log will be the error
235157
string of the last devide error of the process, i.e. QProcess::errorString
236158

237159
While the updater is running, this function will always return an empty QByteArray.
@@ -286,17 +208,17 @@ If `async` is `false`, this function will block and not return until the process
286208
terminated (or killed). If it's `true`, the function will return immediately. You can
287209
use Updater::running. To find out when the process actually finishes.
288210

289-
@warning In most cases there will be no side-effects of a abort. However, if the tool has to be killed,
290-
this may cause unwanted effects. As an example, you may not be able to start the tool until you restart
291-
your system. If possible, do not abort the check, but instead just wait for it to finish.
211+
@warning In most cases there will be no side-effects of an abort. However, if the tool has to be killed,
212+
because of no delay or a timeout, this may cause unwanted effects. As an example, you may not be able to
213+
start the tool until you restart your system, or worst case scenario, break the installation.
214+
If possible, do not abort the check, but instead just wait for it to finish.
292215

293216
@sa Updater::checkForUpdates, Updater::running, Updater::exitedNormally
294217
*/
295218

296219
/*!
297220
@fn QtAutoUpdater::Updater::scheduleUpdate(int , bool)
298221

299-
@overload
300222
@param delaySeconds The time (in seconds) to wait until the update is started
301223
@param repeated Specifies, whether the updater should be started every `delaySeconds`
302224
or only once
@@ -311,18 +233,12 @@ If the updater is already running while the task is triggered, nothing will happ
311233
The scheduled update will only work if this same instance of the updater is still alive
312234
at that time.
313235

314-
@overloads{
315-
@ovElem{scheduleUpdate(int , bool)}
316-
@ovElem{scheduleUpdate(const QDateTime &)}
317-
}
318-
319236
@sa Updater::cancelScheduledUpdate, Updater::checkForUpdates
320237
*/
321238

322239
/*!
323240
@fn QtAutoUpdater::Updater::scheduleUpdate(const QDateTime &)
324241

325-
@overload
326242
@param when The timepoint where the update should be started
327243
@returns The internal ID of this update task. Can be used to cancel the task
328244

@@ -335,11 +251,6 @@ If the updater is already running while the task is triggered, nothing will happ
335251
The scheduled update will only work if this same instance of the updater is still alive
336252
at that time.
337253

338-
@overloads{
339-
@ovElem{scheduleUpdate(int , bool)}
340-
@ovElem{scheduleUpdate(const QDateTime &)}
341-
}
342-
343254
@sa Updater::cancelScheduledUpdate, Updater::checkForUpdates
344255
*/
345256

@@ -360,11 +271,10 @@ Updater::abortUpdateCheck
360271
/*!
361272
@fn QtAutoUpdater::Updater::runUpdaterOnExit(AdminAuthoriser *)
362273

363-
@overload
364274
@param authoriser An optional admin authoriser instance to execture the updater as admin
365275

366276
Schedules the maintenancetool to be run on exit. This means that as soon as the
367-
application exits, the updater will run the maintenancetool (with the paramter `--updater`)
277+
application exits, the updater will run the maintenancetool (with the default parameter `--updater`)
368278
detached. This way you can let the user do the actual update if you found that there
369279
are new updates.
370280

@@ -382,30 +292,14 @@ arguments and admin authorisation, i.e. the last call to this function will dete
382292
how the updater starts. To cancel this (stop the maintenancetool from beeing started),
383293
you cann use Updater::cancelExitRun.
384294

385-
@overloads{
386-
@povElem{runUpdaterOnExit(AdminAuthoriser *)}
387-
@ovElem{runUpdaterOnExit(const QStringList &, AdminAuthoriser *)}
388-
}
389-
390295
@sa Updater::willRunOnExit, Updater::cancelExitRun, AdminAuthoriser
391296
*/
392297

393298
/*!
394299
@fn QtAutoUpdater::Updater::runUpdaterOnExit(const QStringList &, AdminAuthoriser *)
395300

396-
@overload
397-
@param arguments The arguments to be passed to to the maintenancetool
398-
@param authoriser An optional admin authoriser to execture the updater as admin
399-
400-
This overload will use custom arguments for the invokation of the maintenancetool
401-
instead of using `--updater`
402-
403-
@overloads{
404-
@povElem{runUpdaterOnExit(AdminAuthoriser *)}
405-
@ovElem{runUpdaterOnExit(const QStringList &, AdminAuthoriser *)}
406-
}
407-
408-
@sa Updater::willRunOnExit, Updater::cancelExitRun, AdminAuthoriser
301+
@param arguments The custom arguments to be passed to to the maintenancetool
302+
@copydetails Updater::runUpdaterOnExit(AdminAuthoriser *)
409303
*/
410304

411305
/*!
@@ -421,19 +315,18 @@ function will cancel that and nothing will happend on exit.
421315
@fn QtAutoUpdater::Updater::checkUpdatesDone
422316

423317
@param hasUpdates Specifies whether or not the new updates could be found
424-
@param hasError `true`, if the updater did not exit normally or returned something other
425-
than `EXIT_SUCCESS (0)`, `false` if everything is ok
318+
@param hasError `true`, if the updater did not exit normally or provided invalid data, `false` if everything is ok
426319

427320
`hasUpdates` can be used to determine if there are updates. If it is set to true, you
428321
can assume that Updater::updateInfo contains at least one value (but it's not guaranteed).
429322

430323
`hasError` basically summarises the error state. If it is `false`, everything is ok. If
431-
it is `true`, the maintenancetool either did not finish normally or returned an error code
432-
different from success. You can use the error functions to find out if and what went wrong.
324+
it is `true`, the maintenancetool did not work properly. You can use the error functions
325+
to find out if and what went wrong.
433326

434-
@note If `hasError` is true, it does not neccesarily mean that something went wrong. Since
435-
the maintenancetool returns `EXIT_FAILURE (1)` if no new updates are available, you will have
436-
to use the other functions provided to get the actual error.
327+
@note If `hasError` is false, it does not neccesarily mean that everything went fine. Since
328+
the maintenancetool returns `EXIT_FAILURE (1)` if no new updates are available, it cannot be
329+
used as an error indicator, you will have to use the other functions provided to get the actual error.
437330

438331
@sa Updater::checkForUpdates, Updater::running, Updater::updateInfo, Updater::exitedNormally,
439332
Updater::errorCode, Updater::errorLog

src/autoupdatercore/adminauthoriser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace QtAutoUpdater
1313
class Q_AUTOUPDATERCORE_EXPORT AdminAuthoriser
1414
{
1515
public:
16-
//! Destructor
16+
//! Virtual destructor
1717
virtual inline ~AdminAuthoriser() {}
18-
//! Specifies whether this program already has elevated rights or not
18+
//! Tests whether this program already has elevated rights or not
1919
virtual bool hasAdminRights() = 0;
2020
//! Runs a program with the given arguments with elevated rights
2121
virtual bool executeAsAdmin(const QString &program, const QStringList &arguments) = 0;

src/autoupdatercore/updater.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ void Updater::cancelScheduledUpdate(int taskId)
8888
d->scheduler->cancelSchedule(taskId);
8989
}
9090

91+
void Updater::runUpdaterOnExit(AdminAuthoriser *authoriser)
92+
{
93+
runUpdaterOnExit({QStringLiteral("--updater")}, authoriser);
94+
}
95+
9196
void Updater::runUpdaterOnExit(const QStringList &arguments, AdminAuthoriser *authoriser)
9297
{
9398
d->runOnExit = true;

0 commit comments

Comments
 (0)