Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "appimageupdater.h"
#include <QThread>
#include "appimage/update.h"
AppImageUpdater::AppImageUpdater(const QString &id, const QString &path, QObject *parent)
: QObject(parent), id_(id), path_(path)
{
isFinishedWithNoError_ = false;
errorString_ = "";
}
QString AppImageUpdater::id() const
{
return id_;
}
QString AppImageUpdater::path() const
{
return path_;
}
QString AppImageUpdater::describeAppImage() const
{
std::string description = "";
appimage::update::Updater updater(path_.toStdString());
updater.describeAppImage(description);
return QString::fromStdString(description);
}
bool AppImageUpdater::checkAppImage() const
{
bool updateAvailable = false;
appimage::update::Updater updater(path_.toStdString());
updater.checkForChanges(updateAvailable);
return updateAvailable;
}
void AppImageUpdater::updateAppImage()
{
isFinishedWithNoError_ = false;
errorString_ = "";
appimage::update::Updater updater(path_.toStdString(), false);
if (!updater.start()) {
emit finished(this);
return;
}
while (!updater.isDone()) {
QThread::msleep(100);
double progress;
if (updater.progress(progress)) {
emit updateProgress(id_, progress);
}
}
if (updater.hasError()) {
std::string message;
while (updater.nextStatusMessage(message)) {
errorString_ += QString::fromStdString(message) + "\n";
}
emit finished(this);
return;
}
isFinishedWithNoError_ = true;
emit finished(this);
}
bool AppImageUpdater::isFinishedWithNoError() const
{
return isFinishedWithNoError_;
}
QString AppImageUpdater::errorString() const
{
return errorString_;
}