Krita Source Code Documentation
Loading...
Searching...
No Matches
KisAppimageUpdater Class Reference

#include <KisAppimageUpdater.h>

+ Inheritance diagram for KisAppimageUpdater:

Public Member Functions

void checkForUpdate () override
 start the process checking whether there is an update available or not When the check is done, the updater emits sigUpdateCheckStateChange with the check result
 
void doUpdate () override
 if the updater has update capability, start the update process When the update is done, the updater emits sigUpdateCheckStateChange with the check result
 
bool hasUpdateCapability () override
 Returns true if this updater can actually perform an update. If it can only check for new versions, return false.
 
 KisAppimageUpdater ()
 
 KisAppimageUpdater (QString dummyUpdaterPath)
 
- Public Member Functions inherited from KisUpdaterBase
 KisUpdaterBase ()
 

Private Slots

void slotAppendCheckOutput ()
 
void slotAppendUpdateOutput ()
 
void slotUpdateCheckErrorOccurred (QProcess::ProcessError error)
 
void slotUpdateCheckFinished (int result, QProcess::ExitStatus exitStatus)
 
void slotUpdateCheckStarted ()
 
void slotUpdateErrorOccurred (QProcess::ProcessError error)
 
void slotUpdateFinished (int result, QProcess::ExitStatus exitStatus)
 

Private Member Functions

bool findUpdaterBinary ()
 
void initialize (QString &updaterPath)
 

Private Attributes

QString m_appimagePath
 
QString m_checkOutput
 
QScopedPointer< QProcess > m_checkProcess
 
bool m_updateCapability
 
QString m_updateOutput
 
QScopedPointer< QProcess > m_updateProcess
 
QString m_updaterBinary
 
bool m_updaterInProgress {false}
 

Additional Inherited Members

- Signals inherited from KisUpdaterBase
void sigUpdateCheckStateChange (KisUpdaterStatus)
 
- Protected Attributes inherited from KisUpdaterBase
KisUpdaterStatus m_updaterStatus
 

Detailed Description

Definition at line 22 of file KisAppimageUpdater.h.

Constructor & Destructor Documentation

◆ KisAppimageUpdater() [1/2]

KisAppimageUpdater::KisAppimageUpdater ( )

Definition at line 22 of file KisAppimageUpdater.cpp.

23 : m_checkProcess(new QProcess(this))
24 , m_updateProcess(new QProcess(this))
25{
26 QString updaterPath;
27
28#if defined(KRITA_GIT_SHA1_STRING)
29 if (qEnvironmentVariableIsSet("KRITA_APPIMAGEUPDATER_USE_DUMMY")) {
30 updaterPath = QString("%1%2AppImageUpdateDummy")
31 .arg(QCoreApplication::applicationDirPath())
32 .arg(QDir::separator());
33 } else {
34 updaterPath = QString("%1%2AppImageUpdate")
35 .arg(QCoreApplication::applicationDirPath())
36 .arg(QDir::separator());
37 }
38#else
39 updaterPath = QString("%1%2AppImageUpdate")
40 .arg(QCoreApplication::applicationDirPath())
41 .arg(QDir::separator());
42#endif
43
44 initialize(updaterPath);
45}
QScopedPointer< QProcess > m_updateProcess
QScopedPointer< QProcess > m_checkProcess
void initialize(QString &updaterPath)

References initialize().

◆ KisAppimageUpdater() [2/2]

KisAppimageUpdater::KisAppimageUpdater ( QString dummyUpdaterPath)
explicit

Definition at line 47 of file KisAppimageUpdater.cpp.

48 : m_checkProcess(new QProcess(this))
49 , m_updateProcess(new QProcess(this))
50{
51 initialize(dummyUpdaterPath);
52}

References initialize().

Member Function Documentation

◆ checkForUpdate()

void KisAppimageUpdater::checkForUpdate ( )
overridevirtual

start the process checking whether there is an update available or not When the check is done, the updater emits sigUpdateCheckStateChange with the check result

Implements KisUpdaterBase.

Definition at line 54 of file KisAppimageUpdater.cpp.

55{
57 return;
58 }
59
60 if (!m_updateCapability) {
61 return;
62 }
63
64 // reset output for subsequent checks, is this needed?
65 m_checkOutput = QString();
66 m_updateOutput = QString();
68
69 QStringList args = QStringList() << "--check-for-update" << m_appimagePath;
70
71 m_checkProcess->start(m_updaterBinary, args);
73}
QList< QString > QStringList
KisUpdaterStatus m_updaterStatus
void setUpdaterOutput(const QString &updaterOutput)

References m_appimagePath, m_checkOutput, m_checkProcess, m_updateCapability, m_updateOutput, m_updaterBinary, m_updaterInProgress, KisUpdaterBase::m_updaterStatus, and KisUpdaterStatus::setUpdaterOutput().

◆ doUpdate()

void KisAppimageUpdater::doUpdate ( )
overridevirtual

if the updater has update capability, start the update process When the update is done, the updater emits sigUpdateCheckStateChange with the check result

Implements KisUpdaterBase.

Definition at line 80 of file KisAppimageUpdater.cpp.

81{
83 m_updateProcess->start(m_updaterBinary, args);
84}

References m_appimagePath, m_updateProcess, and m_updaterBinary.

◆ findUpdaterBinary()

bool KisAppimageUpdater::findUpdaterBinary ( )
private

Definition at line 243 of file KisAppimageUpdater.cpp.

244{
245 QFileInfo finfo(m_updaterBinary);
246 if (finfo.isExecutable()) {
247 return true;
248 } else {
250 QString("KisAppimageUpdater: AppImageUpdate (%1) was not found within the Krita appimage, or is not executable")
251 .arg(m_updaterBinary)
252 );
253 return false;
254 }
255}
static void log(const QString &message)
Logs with date/time.

References KisUsageLogger::log(), and m_updaterBinary.

◆ hasUpdateCapability()

bool KisAppimageUpdater::hasUpdateCapability ( )
overridevirtual

Returns true if this updater can actually perform an update. If it can only check for new versions, return false.

Returns
bool

Implements KisUpdaterBase.

Definition at line 75 of file KisAppimageUpdater.cpp.

76{
77 return m_updateCapability;
78}

References m_updateCapability.

◆ initialize()

void KisAppimageUpdater::initialize ( QString & updaterPath)
private

Definition at line 216 of file KisAppimageUpdater.cpp.

217{
218 m_appimagePath = qEnvironmentVariable("APPIMAGE");
219 m_updaterBinary = updaterPath;
220
222
223 m_checkProcess->setProcessChannelMode(QProcess::MergedChannels);
224 m_updateProcess->setProcessChannelMode(QProcess::MergedChannels);
225
226 connect(m_checkProcess.data(), SIGNAL(started()), this, SLOT(slotUpdateCheckStarted()));
227 connect(m_checkProcess.data(), SIGNAL(errorOccurred(QProcess::ProcessError)),
228 this, SLOT(slotUpdateCheckErrorOccurred(QProcess::ProcessError)));
229 connect(m_checkProcess.data(), SIGNAL(finished(int, QProcess::ExitStatus)),
230 this, SLOT(slotUpdateCheckFinished(int, QProcess::ExitStatus)));
231 connect(m_checkProcess.data(), SIGNAL(readyReadStandardOutput()),
232 this, SLOT(slotAppendCheckOutput()));
233
234
235 connect(m_updateProcess.data(), SIGNAL(errorOccurred(QProcess::ProcessError)),
236 this, SLOT(slotUpdateErrorOccurred(QProcess::ProcessError)));
237 connect(m_updateProcess.data(), SIGNAL(finished(int, QProcess::ExitStatus)),
238 this, SLOT(slotUpdateFinished(int, QProcess::ExitStatus)));
239 connect(m_updateProcess.data(), SIGNAL(readyReadStandardOutput()),
240 this, SLOT(slotAppendUpdateOutput()));
241}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void slotUpdateErrorOccurred(QProcess::ProcessError error)
void slotUpdateCheckFinished(int result, QProcess::ExitStatus exitStatus)
void slotUpdateCheckErrorOccurred(QProcess::ProcessError error)
void slotUpdateFinished(int result, QProcess::ExitStatus exitStatus)

References connect(), findUpdaterBinary(), m_appimagePath, m_checkProcess, m_updateCapability, m_updateProcess, m_updaterBinary, slotAppendCheckOutput(), slotAppendUpdateOutput(), slotUpdateCheckErrorOccurred(), slotUpdateCheckFinished(), slotUpdateCheckStarted(), slotUpdateErrorOccurred(), and slotUpdateFinished().

◆ slotAppendCheckOutput

void KisAppimageUpdater::slotAppendCheckOutput ( )
privateslot

Definition at line 206 of file KisAppimageUpdater.cpp.

207{
208 m_checkOutput.append(m_checkProcess->readAllStandardOutput());
209}

References m_checkOutput, and m_checkProcess.

◆ slotAppendUpdateOutput

void KisAppimageUpdater::slotAppendUpdateOutput ( )
privateslot

Definition at line 211 of file KisAppimageUpdater.cpp.

212{
213 m_updateOutput.append(m_updateProcess->readAllStandardOutput());
214}

References m_updateOutput, and m_updateProcess.

◆ slotUpdateCheckErrorOccurred

void KisAppimageUpdater::slotUpdateCheckErrorOccurred ( QProcess::ProcessError error)
privateslot

Definition at line 134 of file KisAppimageUpdater.cpp.

135{
137 QString("KisAppimageUpdater: error occurred during update check: %1\npath: %2\noutput: %3")
138 .arg(error)
139 .arg(m_appimagePath)
140 .arg(m_checkOutput)
141 );
142
143 m_updaterInProgress = false;
144
146
148}
void sigUpdateCheckStateChange(KisUpdaterStatus)
void setStatus(const UpdaterStatus::StatusID &status)

References UpdaterStatus::CHECK_ERROR, KisUsageLogger::log(), m_appimagePath, m_checkOutput, m_updaterInProgress, KisUpdaterBase::m_updaterStatus, KisUpdaterStatus::setStatus(), and KisUpdaterBase::sigUpdateCheckStateChange().

◆ slotUpdateCheckFinished

void KisAppimageUpdater::slotUpdateCheckFinished ( int result,
QProcess::ExitStatus exitStatus )
privateslot

Definition at line 86 of file KisAppimageUpdater.cpp.

87{
89 QString("KisAppimageUpdater: update check finished. Result: %1 Exit status: %2\npath: %3\noutput: %4")
90 .arg(result)
91 .arg(exitStatus)
92 .arg(m_appimagePath)
93 .arg(m_updateOutput)
94 );
95
96 UpdaterStatus::StatusID updateStatus;
97
98 if (exitStatus == QProcess::CrashExit) {
100
101 } else {
102 switch (result) {
103 case 0:
105 break;
106 case 1:
108 break;
109 case 2:
111 break;
112 default:
113 // some errors have exit code of 255 (modified by system, when AppImageUpdate returns -1)
114 // one source of 255 is when the AppImage does not contain update information
116 break;
117 }
118 }
119
120 m_updaterInProgress = false;
121
122 m_updaterStatus.setStatus(updateStatus);
124
126}

References UpdaterStatus::CHECK_ERROR, KisUsageLogger::log(), m_appimagePath, m_updateOutput, m_updaterInProgress, KisUpdaterBase::m_updaterStatus, KisUpdaterStatus::setStatus(), KisUpdaterStatus::setUpdaterOutput(), KisUpdaterBase::sigUpdateCheckStateChange(), UpdaterStatus::UPDATE_AVAILABLE, and UpdaterStatus::UPTODATE.

◆ slotUpdateCheckStarted

◆ slotUpdateErrorOccurred

void KisAppimageUpdater::slotUpdateErrorOccurred ( QProcess::ProcessError error)
privateslot

◆ slotUpdateFinished

void KisAppimageUpdater::slotUpdateFinished ( int result,
QProcess::ExitStatus exitStatus )
privateslot

Definition at line 150 of file KisAppimageUpdater.cpp.

151{
153 QString("KisAppimageUpdater: update finished. Result: %1\nExit status: %2\npath: %3\noutput: %4")
154 .arg(result)
155 .arg(exitStatus)
156 .arg(m_appimagePath)
157 .arg(m_updateOutput)
158 );
159
160 UpdaterStatus::StatusID updateStatus;
161 QFileInfo finfoAppImagePath(m_appimagePath);
162 QString statusDetails;
163
164 if (exitStatus == QProcess::CrashExit) {
166
167 } else {
168 switch (result) {
169 case 0:
171 statusDetails = i18n("New AppImage was downloaded to %1. To complete the update, close Krita and run the new AppImage.", finfoAppImagePath.path());
172 break;
173 default:
174 // some errors have exit code of 255 (modified by system, when AppImageUpdate returns -1)
176 break;
177 }
178 }
179
180 m_updaterInProgress = false;
181
182 m_updaterStatus.setStatus(updateStatus);
184 m_updaterStatus.setDetails(statusDetails);
185
187}
void setDetails(const QString &details)

References KisUsageLogger::log(), m_appimagePath, m_updateOutput, m_updaterInProgress, KisUpdaterBase::m_updaterStatus, UpdaterStatus::RESTART_REQUIRED, KisUpdaterStatus::setDetails(), KisUpdaterStatus::setStatus(), KisUpdaterStatus::setUpdaterOutput(), KisUpdaterBase::sigUpdateCheckStateChange(), and UpdaterStatus::UPDATE_ERROR.

Member Data Documentation

◆ m_appimagePath

QString KisAppimageUpdater::m_appimagePath
private

Definition at line 50 of file KisAppimageUpdater.h.

◆ m_checkOutput

QString KisAppimageUpdater::m_checkOutput
private

Definition at line 53 of file KisAppimageUpdater.h.

◆ m_checkProcess

QScopedPointer<QProcess> KisAppimageUpdater::m_checkProcess
private

Definition at line 56 of file KisAppimageUpdater.h.

◆ m_updateCapability

bool KisAppimageUpdater::m_updateCapability
private

Definition at line 51 of file KisAppimageUpdater.h.

◆ m_updateOutput

QString KisAppimageUpdater::m_updateOutput
private

Definition at line 54 of file KisAppimageUpdater.h.

◆ m_updateProcess

QScopedPointer<QProcess> KisAppimageUpdater::m_updateProcess
private

Definition at line 57 of file KisAppimageUpdater.h.

◆ m_updaterBinary

QString KisAppimageUpdater::m_updaterBinary
private

Definition at line 49 of file KisAppimageUpdater.h.

◆ m_updaterInProgress

bool KisAppimageUpdater::m_updaterInProgress {false}
private

Definition at line 52 of file KisAppimageUpdater.h.

52{false};

The documentation for this class was generated from the following files: