ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QSimpleUpdater.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
10 
11 static QList<QString> URLS;
12 static QList<Updater *> UPDATERS;
13 
15 {
16  URLS.clear();
17 
18  foreach (Updater *updater, UPDATERS)
19  updater->deleteLater();
20 
21  UPDATERS.clear();
22 }
23 
28 {
29  static QSimpleUpdater updater;
30  return &updater;
31 }
32 
41 bool QSimpleUpdater::usesCustomAppcast(const QString &url) const
42 {
43  return getUpdater(url)->customAppcast();
44 }
45 
53 bool QSimpleUpdater::getNotifyOnUpdate(const QString &url) const
54 {
55  return getUpdater(url)->notifyOnUpdate();
56 }
57 
65 bool QSimpleUpdater::getNotifyOnFinish(const QString &url) const
66 {
67  return getUpdater(url)->notifyOnFinish();
68 }
69 
78 bool QSimpleUpdater::getUpdateAvailable(const QString &url) const
79 {
80  return getUpdater(url)->updateAvailable();
81 }
82 
90 bool QSimpleUpdater::getDownloaderEnabled(const QString &url) const
91 {
92  return getUpdater(url)->downloaderEnabled();
93 }
94 
106 bool QSimpleUpdater::usesCustomInstallProcedures(const QString &url) const
107 {
108  return getUpdater(url)->useCustomInstallProcedures();
109 }
110 
120 QString QSimpleUpdater::getOpenUrl(const QString &url) const
121 {
122  return getUpdater(url)->openUrl();
123 }
124 
133 QString QSimpleUpdater::getChangelog(const QString &url) const
134 {
135  return getUpdater(url)->changelog();
136 }
137 
147 QString QSimpleUpdater::getModuleName(const QString &url) const
148 {
149  return getUpdater(url)->moduleName();
150 }
151 
160 QString QSimpleUpdater::getDownloadUrl(const QString &url) const
161 {
162  return getUpdater(url)->downloadUrl();
163 }
164 
178 QString QSimpleUpdater::getPlatformKey(const QString &url) const
179 {
180  return getUpdater(url)->platformKey();
181 }
182 
191 QString QSimpleUpdater::getLatestVersion(const QString &url) const
192 {
193  return getUpdater(url)->latestVersion();
194 }
195 
205 QString QSimpleUpdater::getModuleVersion(const QString &url) const
206 {
207  return getUpdater(url)->moduleVersion();
208 }
209 
217 QString QSimpleUpdater::getUserAgentString(const QString &url) const
218 {
219  return getUpdater(url)->userAgentString();
220 }
221 
229 void QSimpleUpdater::checkForUpdates(const QString &url)
230 {
231  getUpdater(url)->checkForUpdates();
232 }
233 
243 void QSimpleUpdater::setModuleName(const QString &url, const QString &name)
244 {
245  getUpdater(url)->setModuleName(name);
246 }
247 
255 void QSimpleUpdater::setNotifyOnUpdate(const QString &url, const bool notify)
256 {
257  getUpdater(url)->setNotifyOnUpdate(notify);
258 }
259 
268 void QSimpleUpdater::setNotifyOnFinish(const QString &url, const bool notify)
269 {
270  getUpdater(url)->setNotifyOnFinish(notify);
271 }
272 
287 void QSimpleUpdater::setPlatformKey(const QString &url, const QString &platform)
288 {
289  getUpdater(url)->setPlatformKey(platform);
290 }
291 
300 void QSimpleUpdater::setModuleVersion(const QString &url, const QString &version)
301 {
302  getUpdater(url)->setModuleVersion(version);
303 }
304 
313 void QSimpleUpdater::setDownloaderEnabled(const QString &url, const bool enabled)
314 {
315  getUpdater(url)->setDownloaderEnabled(enabled);
316 }
317 
325 void QSimpleUpdater::setUserAgentString(const QString &url, const QString &agent)
326 {
327  getUpdater(url)->setUserAgentString(agent);
328 }
329 
339 void QSimpleUpdater::setUseCustomAppcast(const QString &url, const bool customAppcast)
340 {
341  getUpdater(url)->setUseCustomAppcast(customAppcast);
342 }
343 
355 void QSimpleUpdater::setUseCustomInstallProcedures(const QString &url, const bool custom)
356 {
357  getUpdater(url)->setUseCustomInstallProcedures(custom);
358 }
359 
360 void QSimpleUpdater::setMandatoryUpdate(const QString &url, const bool mandatory_update)
361 {
362  getUpdater(url)->setMandatoryUpdate(mandatory_update);
363 }
364 
371 Updater *QSimpleUpdater::getUpdater(const QString &url) const
372 {
373  if (!URLS.contains(url))
374  {
375  Updater *updater = new Updater;
376  updater->setUrl(url);
377 
378  URLS.append(url);
379  UPDATERS.append(updater);
380 
381  connect(updater, SIGNAL(checkingFinished(QString)), this, SIGNAL(checkingFinished(QString)));
382  connect(updater, SIGNAL(downloadFinished(QString, QString)), this, SIGNAL(downloadFinished(QString, QString)));
383  connect(updater, SIGNAL(appcastDownloaded(QString, QByteArray)), this,
384  SIGNAL(appcastDownloaded(QString, QByteArray)));
385  }
386 
387  return UPDATERS.at(URLS.indexOf(url));
388 }
std::string version
std::string name
static QList< Updater * > UPDATERS
static QList< QString > URLS
Manages the updater instances.
void appcastDownloaded(const QString &url, const QByteArray &data)
void setModuleVersion(const QString &url, const QString &version)
QString getOpenUrl(const QString &url) const
void setNotifyOnUpdate(const QString &url, const bool notify)
void setNotifyOnFinish(const QString &url, const bool notify)
void setModuleName(const QString &url, const QString &name)
void checkingFinished(const QString &url)
QString getPlatformKey(const QString &url) const
QString getUserAgentString(const QString &url) const
QString getChangelog(const QString &url) const
void checkForUpdates(const QString &url)
bool getUpdateAvailable(const QString &url) const
bool getNotifyOnFinish(const QString &url) const
QString getLatestVersion(const QString &url) const
QString getDownloadUrl(const QString &url) const
bool usesCustomInstallProcedures(const QString &url) const
void setMandatoryUpdate(const QString &url, const bool mandatory_update)
void downloadFinished(const QString &url, const QString &filepath)
void setDownloaderEnabled(const QString &url, const bool enabled)
void setUseCustomAppcast(const QString &url, const bool customAppcast)
QString getModuleName(const QString &url) const
void setUseCustomInstallProcedures(const QString &url, const bool custom)
bool getNotifyOnUpdate(const QString &url) const
QString getModuleVersion(const QString &url) const
void setUserAgentString(const QString &url, const QString &agent)
static QSimpleUpdater * getInstance()
bool getDownloaderEnabled(const QString &url) const
void setPlatformKey(const QString &url, const QString &platform)
bool usesCustomAppcast(const QString &url) const
Downloads and interprests the update definition file.
Definition: Updater.h:23
QString changelog() const
Definition: Updater.cpp:85
void setNotifyOnFinish(const bool notify)
Definition: Updater.cpp:262
void setUrl(const QString &url)
Definition: Updater.cpp:234
QString openUrl() const
Definition: Updater.cpp:76
void setDownloaderEnabled(const bool enabled)
Definition: Updater.cpp:294
bool useCustomInstallProcedures() const
Definition: Updater.cpp:212
bool notifyOnFinish() const
Definition: Updater.cpp:174
void setUseCustomInstallProcedures(const bool custom)
Definition: Updater.cpp:329
QString moduleName() const
Definition: Updater.cpp:93
QString latestVersion() const
Definition: Updater.cpp:126
void checkForUpdates()
Definition: Updater.cpp:221
void setModuleName(const QString &name)
Definition: Updater.cpp:244
QString downloadUrl() const
Definition: Updater.cpp:117
void setPlatformKey(const QString &platformKey)
Definition: Updater.cpp:308
bool customAppcast() const
Definition: Updater.cpp:153
void setModuleVersion(const QString &version)
Definition: Updater.cpp:285
void setMandatoryUpdate(const bool mandatory_update)
Definition: Updater.cpp:338
bool downloaderEnabled() const
Definition: Updater.cpp:202
bool notifyOnUpdate() const
Definition: Updater.cpp:162
QString platformKey() const
Definition: Updater.cpp:108
void setUseCustomAppcast(const bool customAppcast)
Definition: Updater.cpp:319
bool updateAvailable() const
Definition: Updater.cpp:192
void setNotifyOnUpdate(const bool notify)
Definition: Updater.cpp:253
QString userAgentString() const
Definition: Updater.cpp:135
QString moduleVersion() const
Definition: Updater.cpp:143
void setUserAgentString(const QString &agent)
Definition: Updater.cpp:273