Fixed up method docs for updater

This commit is contained in:
James 2017-10-31 15:41:18 +11:00 committed by James Rowe
parent 53a88a0e13
commit b579bf0cc2
3 changed files with 77 additions and 28 deletions

View file

@ -152,15 +152,15 @@ void UpdaterPrivate::StopUpdateCheck(int delay, bool async) {
if (delay > 0) { if (delay > 0) {
main_process->terminate(); main_process->terminate();
if (async) { if (async) {
QTimer *timer = new QTimer(this); QTimer* timer = new QTimer(this);
timer->setSingleShot(true); timer->setSingleShot(true);
connect(timer, &QTimer::timeout, [=]() { connect(timer, &QTimer::timeout, [=]() {
StopUpdateCheck(0, false); StopUpdateCheck(0, false);
timer->deleteLater(); timer->deleteLater();
}); });
timer->start(delay); timer->start(delay);
} else { } else {
if (!main_process->waitForFinished(delay)) { if (!main_process->waitForFinished(delay)) {
main_process->kill(); main_process->kill();

View file

@ -61,58 +61,107 @@ public:
/// The update download size (in Bytes) /// The update download size (in Bytes)
quint64 size = 0; quint64 size = 0;
/// Default Constructor /**
* Default Constructor
*/
UpdateInfo(); UpdateInfo();
/// Copy Constructor
/**
* Copy Constructor
*/
UpdateInfo(const UpdateInfo& other); UpdateInfo(const UpdateInfo& other);
/// Constructor that takes name, version and size
/**
* Constructor that takes name, version and size.
*/
UpdateInfo(QString name, QString version, quint64 size); UpdateInfo(QString name, QString version, quint64 size);
}; };
/// Default constructor /**
* Default constructor
**/
explicit Updater(QObject* parent = nullptr); explicit Updater(QObject* parent = nullptr);
/// Constructor with an explicitly set path
/**
* Constructor with an explicitly set path
**/
explicit Updater(const QString& maintenance_tool_path, QObject* parent = nullptr); explicit Updater(const QString& maintenance_tool_path, QObject* parent = nullptr);
/// Destroys the updater and kills the update check (if running)
/**
* Destroys the updater and kills the update check (if running)
**/
~Updater(); ~Updater();
/// Returns `true`, if the updater exited normally /**
* Returns `true`, if the updater exited normally
**/
bool ExitedNormally() const; bool ExitedNormally() const;
/// Returns the mainetancetools error code of the last update
/**
* Returns the mainetancetools error code from the last update check, if any.
**/
int ErrorCode() const; int ErrorCode() const;
/// returns the error output (stderr) of the last update
/**
* Returns the error output (stderr) of the last update
**/
QByteArray ErrorLog() const; QByteArray ErrorLog() const;
/// readAcFn{Updater::running} /**
* Returns if a update check is running.
**/
bool IsRunning() const; bool IsRunning() const;
/// readAcFn{Updater::updateInfo}
/**
* Returns the latest update information available, if any.
**/
QList<UpdateInfo> LatestUpdateInfo() const; QList<UpdateInfo> LatestUpdateInfo() const;
/// Launches the updater UI formally /**
* Launches the updater UI formally
**/
void LaunchUI(); void LaunchUI();
/// Silently updates the application in the background /**
* Silently updates the application in the background
**/
void SilentlyUpdate(); void SilentlyUpdate();
/// Checks to see if a updater application is available /**
* Checks to see if a updater application is available
**/
bool HasUpdater() const; bool HasUpdater() const;
/// Instead of silently updating, explictly open the UI on shutdown /**
* Instead of silently updating, explictly open the UI on shutdown
**/
void LaunchUIOnExit(); void LaunchUIOnExit();
public slots: public slots:
/// Starts checking for updates /**
* Starts checking for updates
**/
bool CheckForUpdates(); bool CheckForUpdates();
/// Aborts checking for updates
/**
* Aborts checking for updates
**/
void AbortUpdateCheck(int max_delay = 5000, bool async = false); void AbortUpdateCheck(int max_delay = 5000, bool async = false);
signals: signals:
/// Will be emitted as soon as the updater finished checking for updates /**
* Will be emitted as soon as the updater finished checking for updates
**/
void CheckUpdatesDone(bool has_updates, bool has_error); void CheckUpdatesDone(bool has_updates, bool has_error);
/// notifyAcFn{Updater::running} /**
* Emitted when a update check operation changes stage
**/
void RunningChanged(bool running); void RunningChanged(bool running);
/// notifyAcFn{Updater::updateInfo}
/**
* Emitted when new update information has been found
**/
void UpdateInfoChanged(QList<Updater::UpdateInfo> update_info); void UpdateInfoChanged(QList<Updater::UpdateInfo> update_info);
private: private:

View file

@ -29,6 +29,7 @@ public:
bool HasUpdater() const; bool HasUpdater() const;
bool StartUpdateCheck(); bool StartUpdateCheck();
void StopUpdateCheck(int delay, bool async);
void LaunchWithArguments(const QStringList& args); void LaunchWithArguments(const QStringList& args);
void LaunchUI(); void LaunchUI();
@ -37,7 +38,6 @@ public:
void LaunchUIOnExit(); void LaunchUIOnExit();
public slots: public slots:
void StopUpdateCheck(int delay, bool async);
void UpdaterReady(int exit_code, QProcess::ExitStatus exit_status); void UpdaterReady(int exit_code, QProcess::ExitStatus exit_status);
void UpdaterError(QProcess::ProcessError error); void UpdaterError(QProcess::ProcessError error);