///////////////////////////////////////////////////////////////////////////////
// MuldeR's Utilities for Qt
-// Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <QStringList>
#include <QFile>
#include <QFileInfo>
+#include <QDir>
#include <QProcess>
#include <QUrl>
#include <QEventLoop>
#include <QTimer>
+#include <QElapsedTimer>
+#include <QSet>
+#include <QHash>
-using namespace MUtils;
+#include "Mirrors.h"
///////////////////////////////////////////////////////////////////////////////
// CONSTANTS
NULL
};
-static const char *update_mirrors[] =
-{
- "http://muldersoft.com/",
- "http://mulder.bplaced.net/",
- "http://mulder.6te.net/",
- "http://mulder.webuda.com/",
- "http://mulder.pe.hu/",
- "http://muldersoft.square7.ch/",
- "http://muldersoft.co.nf/",
- "http://muldersoft.eu.pn/",
- "http://muldersoft.lima-city.de/",
- "http://www.muldersoft.keepfree.de/",
- "http://lamexp.sourceforge.net/",
- "http://lordmulder.github.io/LameXP/",
- "http://muldersoft.bitbucket.io/", //http://lord_mulder.bitbucket.org/
- "http://www.tricksoft.de/",
- "http://repo.or.cz/LameXP.git/blob_plain/gh-pages:/",
- "http://gitlab.com/lamexp/lamexp/raw/gh-pages/",
- NULL
-};
-
-static const char *known_hosts[] = //Taken form: http://www.alexa.com/topsites !!!
-{
- "www.163.com",
- "www.7-zip.org",
- "www.ac3filter.net",
- "clbianco.altervista.org",
- "status.aws.amazon.com",
- "build.antergos.com",
- "www.aol.com",
- "www.apache.org",
- "www.apple.com",
- "www.adobe.com",
- "archive.org",
- "www.artlebedev.ru",
- "web.audacityteam.org",
- "status.automattic.com",
- "www.avidemux.org",
- "www.babylon.com",
- "www.baidu.com",
- "bandcamp.com",
- "www.bbc.co.uk",
- "www.berlios.de",
- "www.bing.com",
- "www.bingeandgrab.com",
- "www.bucketheadpikes.com",
- "www.buckethead-coop.com",
- "www.buzzfeed.com",
- "www.ccc.de",
- "www.citizeninsomniac.com",
- "www.cnet.com",
- "cnzz.com",
- "www.codeplex.com",
- "www.codeproject.com",
- "www.der-postillon.com",
- "www.ebay.com",
- "www.equation.com",
- "www.farbrausch.de",
- "fc2.com",
- "fedoraproject.org",
- "blog.fefe.de",
- "www.ffmpeg.org",
- "blog.flickr.net",
- "free-codecs.com",
- "git-scm.com",
- "doc.gitlab.com",
- "www.gmx.net",
- "news.gnome.org",
- "www.gnu.org",
- "go.com",
- "code.google.com",
- "haali.su",
- "www.heise.de",
- "www.huffingtonpost.co.uk",
- "www.iana.org",
- "www.imdb.com",
- "www.imgburn.com",
- "imgur.com",
- "www.jd.com",
- "www.jiscdigitalmedia.ac.uk",
- "kannmanumdieuhrzeitschonnbierchentrinken.de",
- "mirrors.kernel.org",
- "komisar.gin.by",
- "lame.sourceforge.net",
- "www.libav.org",
- "blog.linkedin.com",
- "www.linuxmint.com",
- "www.livedoor.com",
- "www.livejournal.com",
- "longplayer.org",
- "go.mail.ru",
- "marknelson.us",
- "www.mediafire.com",
- "www.mod-technologies.com",
- "ftp.mozilla.org",
- "mplayerhq.hu",
- "www.msn.com",
- "wiki.multimedia.cx",
- "www.nch.com.au",
- "mirror.netcologne.de",
- "oss.netfarm.it",
- "blog.netflix.com",
- "netrenderer.de",
- "www.nytimes.com",
- "www.opera.com",
- "www.partha.com",
- "pastebin.com",
- "pastie.org",
- "portableapps.com",
- "www.portablefreeware.com",
- "support.proboards.com",
- "www.qq.com",
- "www.qt.io",
- "www.quakelive.com",
- "rationalqm.us",
- "www.seamonkey-project.org",
- "selfhtml.org",
- "www.sina.com.cn",
- "www.sohu.com",
- "help.sogou.com",
- "sourceforge.net",
- "www.spiegel.de",
- "www.sputnikmusic.com",
- "stackoverflow.com",
- "www.t-online.de",
- "www.tagesschau.de",
- "tdm-gcc.tdragon.net",
- "www.tdrsmusic.com",
- "www.ubuntu.com",
- "www.uol.com.br",
- "www.videohelp.com",
- "www.videolan.org",
- "virtualdub.org",
- "blog.virustotal.com",
- "www.vkgoeswild.com",
- "www.warr.org",
- "www.weibo.com",
- "status.wikimedia.org",
- "www.winamp.com",
- "www.winhoros.de",
- "wpde.org",
- "x265.org",
- "xhmikosr.1f0.de",
- "xiph.org",
- "us.mail.yahoo.com",
- "www.youtube.com",
- "www.zedo.com",
- "ffmpeg.zeranoe.com",
- NULL
-};
-
static const int MIN_CONNSCORE = 5;
+static const int QUICK_MIRRORS = 3;
+static const int MAX_CONN_TIMEOUT = 16000;
+static const int DOWNLOAD_TIMEOUT = 30000;
+
static const int VERSION_INFO_EXPIRES_MONTHS = 6;
-static char *USER_AGENT_STR = "Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0"; /*use something innocuous*/
+static char *USER_AGENT_STR = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0"; /*use something innocuous*/
+
+#define CHECK_CANCELLED() do \
+{ \
+ if(MUTILS_BOOLIFY(m_cancelled)) \
+ { \
+ m_success.fetchAndStoreOrdered(0); \
+ log("", "Update check has been cancelled by user!"); \
+ setProgress(m_maxProgress); \
+ setStatus(UpdateStatus_CancelledByUser); \
+ return; \
+ } \
+} \
+while(0)
////////////////////////////////////////////////////////////
// Helper Functions
static int getMaxProgress(void)
{
- int counter = MIN_CONNSCORE + 2;
- for(int i = 0; update_mirrors[i]; i++) counter++;
- return counter;
+ int counter = 0;
+ while (update_mirrors[counter])
+ {
+ counter++;
+ }
+ counter += MIN_CONNSCORE + QUICK_MIRRORS + 2;
+ return counter; ;
}
static QStringList buildRandomList(const char *const values[])
QStringList list;
for (int index = 0; values[index]; index++)
{
- const int pos = next_rand_u32() % (index + 1);
+ const int pos = MUtils::next_rand_u32() % (index + 1);
list.insert(pos, QString::fromLatin1(values[index]));
}
return list;
}
+static const QHash<QString, QString> *initEnvVars(void)
+{
+ QHash<QString, QString> *const environment = new QHash<QString, QString>();
+ environment->insert(QLatin1String("CURL_HOME"), QDir::toNativeSeparators(MUtils::temp_folder()));
+ return environment;
+}
+
////////////////////////////////////////////////////////////
// Update Info Class
////////////////////////////////////////////////////////////
-UpdateCheckerInfo::UpdateCheckerInfo(void)
+MUtils::UpdateCheckerInfo::UpdateCheckerInfo(void)
{
resetInfo();
}
-void UpdateCheckerInfo::resetInfo(void)
+void MUtils::UpdateCheckerInfo::resetInfo(void)
{
m_buildNo = 0;
m_buildDate.setDate(1900, 1, 1);
m_downloadChecksum.clear();
}
-bool UpdateCheckerInfo::isComplete(void)
+bool MUtils::UpdateCheckerInfo::isComplete(void)
{
if(this->m_buildNo < 1) return false;
if(this->m_buildDate.year() < 2010) return false;
// Constructor & Destructor
////////////////////////////////////////////////////////////
-UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binNC, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode)
+MUtils::UpdateChecker::UpdateChecker(const QString &binCurl, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode)
:
m_updateInfo(new UpdateCheckerInfo()),
- m_binaryWGet(binWGet),
- m_binaryNC(binNC),
+ m_binaryCurl(binCurl),
m_binaryGnuPG(binGnuPG),
m_binaryKeys(binKeys),
m_applicationId(applicationId),
m_installedBuildNo(installedBuildNo),
m_betaUpdates(betaUpdates),
m_testMode(testMode),
- m_maxProgress(getMaxProgress())
+ m_maxProgress(getMaxProgress()),
+ m_environment(initEnvVars())
{
- m_success = false;
m_status = UpdateStatus_NotStartedYet;
m_progress = 0;
- if(m_binaryWGet.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryKeys.isEmpty())
+ if(m_binaryCurl.isEmpty() || m_binaryGnuPG.isEmpty() || m_binaryKeys.isEmpty())
{
MUTILS_THROW("Tools not initialized correctly!");
}
}
-UpdateChecker::~UpdateChecker(void)
+MUtils::UpdateChecker::~UpdateChecker(void)
{
}
////////////////////////////////////////////////////////////
+// Public slots
+////////////////////////////////////////////////////////////
+
+void MUtils::UpdateChecker::start(Priority priority)
+{
+ m_success.fetchAndStoreOrdered(0);
+ m_cancelled.fetchAndStoreOrdered(0);
+ QThread::start(priority);
+}
+
+////////////////////////////////////////////////////////////
// Protected functions
////////////////////////////////////////////////////////////
-void UpdateChecker::run(void)
+void MUtils::UpdateChecker::run(void)
{
qDebug("Update checker thread started!");
- MUTILS_EXCEPTION_HANDLER(m_testMode ? testKnownHosts() : checkForUpdates());
+ MUTILS_EXCEPTION_HANDLER(m_testMode ? testMirrorsList() : checkForUpdates());
qDebug("Update checker thread completed.");
}
-void UpdateChecker::checkForUpdates(void)
+void MUtils::UpdateChecker::checkForUpdates(void)
{
// ----- Initialization ----- //
- m_success = false;
m_updateInfo->resetInfo();
setProgress(0);
// ----- Test Known Hosts Connectivity ----- //
- int connectionScore = 0, connectionRetry = MIN_CONNSCORE;
+ int connectionScore = 0;
+ QStringList mirrorList = buildRandomList(known_hosts);
- QStringList hostList = buildRandomList(known_hosts);
- while((!hostList.isEmpty()) && (connectionScore < MIN_CONNSCORE) && (connectionRetry > 0))
+ for(int connectionTimout = 1000; connectionTimout <= MAX_CONN_TIMEOUT; connectionTimout *= 2)
{
- connectionRetry--;
- if(tryContactHost(hostList.takeFirst()))
+ QElapsedTimer elapsedTimer;
+ elapsedTimer.start();
+ const int globalTimout = 2 * MIN_CONNSCORE * connectionTimout;
+ while (!elapsedTimer.hasExpired(globalTimout))
{
- connectionScore += 1;
- connectionRetry = MIN_CONNSCORE;
+ const QString hostName = mirrorList.takeFirst();
+ if (tryContactHost(hostName, connectionTimout))
+ {
+ connectionScore += 1;
+ setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
+ elapsedTimer.restart();
+ if (connectionScore >= MIN_CONNSCORE)
+ {
+ goto endLoop; /*success*/
+ }
+ }
+ else
+ {
+ mirrorList.append(hostName); /*re-schedule*/
+ }
+ CHECK_CANCELLED();
+ msleep(1);
}
- setProgress(qBound(1, connectionScore + 1, MIN_CONNSCORE + 1));
- msleep(25);
}
+endLoop:
if(connectionScore < MIN_CONNSCORE)
{
log("", "Connectivity test has failed: Internet connection appears to be broken!");
log("----", "", "Checking for updates online...");
setStatus(UpdateStatus_FetchingUpdates);
- QStringList mirrorList = buildRandomList(update_mirrors);
+ int mirrorCount = 0;
+ mirrorList = buildRandomList(update_mirrors);
+
while(!mirrorList.isEmpty())
{
- QString currentMirror = mirrorList.takeFirst();
setProgress(m_progress + 1);
- if(!m_success)
+ const QString currentMirror = mirrorList.takeFirst();
+ const bool isQuick = (mirrorCount++ < QUICK_MIRRORS);
+ if(tryUpdateMirror(m_updateInfo.data(), currentMirror, isQuick))
{
- if(tryUpdateMirror(m_updateInfo.data(), currentMirror))
- {
- m_success = true;
- }
+ m_success.ref(); /*success*/
+ break;
}
- else
+ if (isQuick)
{
- msleep(25);
+ mirrorList.append(currentMirror); /*re-schedule*/
}
+ CHECK_CANCELLED();
+ msleep(1);
}
- setProgress(m_maxProgress);
+ while (m_progress < m_maxProgress)
+ {
+ msleep(16);
+ setProgress(m_progress + 1);
+ CHECK_CANCELLED();
+ }
- if(m_success)
+ // ----- Generate final result ----- //
+
+ if(MUTILS_BOOLIFY(m_success))
{
if(m_updateInfo->m_buildNo > m_installedBuildNo)
{
}
}
-void UpdateChecker::testKnownHosts(void)
+void MUtils::UpdateChecker::testMirrorsList(void)
{
- QStringList hostList;
- for(int i = 0; known_hosts[i]; i++)
+ // ----- Test update mirrors ----- //
+
+ QStringList mirrorList;
+ for(int i = 0; update_mirrors[i]; i++)
+ {
+ mirrorList << QString::fromLatin1(update_mirrors[i]);
+ }
+
+ qDebug("\n[Mirror Sites]");
+ log("Testing all known mirror sites...", "", "---");
+
+ UpdateCheckerInfo updateInfo;
+ while (!mirrorList.isEmpty())
+ {
+ const QString currentMirror = mirrorList.takeFirst();
+ bool success = false;
+ qDebug("Testing: %s", MUTILS_L1STR(currentMirror));
+ log("", "Testing:", currentMirror, "");
+ for (quint8 attempt = 0; attempt < 3; ++attempt)
+ {
+ updateInfo.resetInfo();
+ if (tryUpdateMirror(&updateInfo, currentMirror, (!attempt)))
+ {
+ success = true;
+ break;
+ }
+ }
+ if (!success)
+ {
+ qWarning("\nUpdate mirror seems to be unavailable:\n%s\n", MUTILS_L1STR(currentMirror));
+ }
+ log("", "---");
+ }
+
+ // ----- Test known hosts ----- //
+
+ QStringList knownHostList;
+ for (int i = 0; known_hosts[i]; i++)
{
- hostList << QString::fromLatin1(known_hosts[i]);
+ knownHostList << QString::fromLatin1(known_hosts[i]);
}
qDebug("\n[Known Hosts]");
log("Testing all known hosts...", "", "---");
- int hostCount = hostList.count();
- while(!hostList.isEmpty())
+ while(!knownHostList.isEmpty())
{
- QString currentHost = hostList.takeFirst();
- qDebug("Testing: %s", currentHost.toLatin1().constData());
- log("", "Testing:", currentHost, "");
- if (!tryContactHost(currentHost))
+ const QString currentHost = knownHostList.takeFirst();
+ qDebug("Testing: %s", MUTILS_L1STR(currentHost));
+ log(QLatin1String(""), "Testing:", currentHost, "");
+ if (!tryContactHost(currentHost, DOWNLOAD_TIMEOUT))
{
- qWarning("\nConnectivity test FAILED on the following host:\n%s\n", currentHost.toLatin1().constData());
+ qWarning("\nConnectivity test FAILED on the following host:\n%s\n", MUTILS_L1STR(currentHost));
}
log("", "---");
}
// PRIVATE FUNCTIONS
////////////////////////////////////////////////////////////
-void UpdateChecker::setStatus(const int status)
+void MUtils::UpdateChecker::setStatus(const int status)
{
if(m_status != status)
{
}
}
-void UpdateChecker::setProgress(const int progress)
+void MUtils::UpdateChecker::setProgress(const int progress)
{
if(m_progress != progress)
{
}
}
-void UpdateChecker::log(const QString &str1, const QString &str2, const QString &str3, const QString &str4)
+void MUtils::UpdateChecker::log(const QString &str1, const QString &str2, const QString &str3, const QString &str4)
{
if(!str1.isNull()) emit messageLogged(str1);
if(!str2.isNull()) emit messageLogged(str2);
if(!str4.isNull()) emit messageLogged(str4);
}
-bool UpdateChecker::tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString &url)
+bool MUtils::UpdateChecker::tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString &url, const bool &quick)
{
bool success = false;
- log("", "Trying mirror:", url);
+ log("", "Trying mirror:", url, "");
+
+ if (quick)
+ {
+ if (!tryContactHost(QUrl(url).host(), (MAX_CONN_TIMEOUT / 10)))
+ {
+ log("", "Mirror is too slow, skipping!");
+ return false;
+ }
+ }
const QString randPart = next_rand_str();
const QString outFileVers = QString("%1/%2.ver").arg(temp_folder(), randPart);
const QString outFileSign = QString("%1/%2.sig").arg(temp_folder(), randPart);
- if(getUpdateInfo(url, outFileVers, outFileSign))
+ if (getUpdateInfo(url, outFileVers, outFileSign))
{
log("", "Download okay, checking signature:");
- if(checkSignature(outFileVers, outFileSign))
+ if (checkSignature(outFileVers, outFileSign))
{
- log("", "Signature okay, parsing info:");
+ log("", "Signature okay, parsing info:", "");
success = parseVersionInfo(outFileVers, updateInfo);
}
else
return success;
}
-bool UpdateChecker::getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign)
+bool MUtils::UpdateChecker::getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign)
{
- log("", "Downloading update info:");
- if(!getFile(QString("%1%2" ).arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileVers))
- {
- return false;
- }
-
- log("", "Downloading signature:");
- if(!getFile(QString("%1%2.sig2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileSign))
+ log("Downloading update info:", "");
+ if(getFile(QString("%1%2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileVers))
{
- return false;
+ if (!m_cancelled)
+ {
+ log("", "Downloading signature:", "");
+ if (getFile(QString("%1%2.sig2").arg(url, mirror_url_postfix[m_betaUpdates ? 1 : 0]), outFileSign))
+ {
+ return true;
+ }
+ }
}
-
- return true;
+ return false;
}
-bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *updateInfo)
+bool MUtils::UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *updateInfo)
{
QRegExp value("^(\\w+)=(.+)$");
QRegExp section("^\\[(.+)\\]$");
// EXTERNAL TOOLS
//----------------------------------------------------------
-bool UpdateChecker::getFile(const QString &url, const QString &outFile, const unsigned int maxRedir, bool *httpOk)
-{
- for (int i = 0; i < 2; i++)
- {
- if (getFile(url, (i > 0), outFile, maxRedir, httpOk))
- {
- return true;
- }
- }
- return false;
-}
-
-bool UpdateChecker::getFile(const QString &url, const bool forceIp4, const QString &outFile, const unsigned int maxRedir, bool *httpOk)
+bool MUtils::UpdateChecker::getFile(const QString &url, const QString &outFile, const unsigned int maxRedir)
{
QFileInfo output(outFile);
output.setCaching(false);
- if (httpOk) *httpOk = false;
if (output.exists())
{
}
QProcess process;
- init_process(process, output.absolutePath());
-
- QStringList args;
- if (forceIp4)
- {
- args << "-4";
- }
+ init_process(process, output.absolutePath(), true, NULL, m_environment.data());
- args << "--no-config" << "--no-cache" << "--no-dns-cache" << "--no-check-certificate" << "--no-hsts";
- args << QString().sprintf("--max-redirect=%u", maxRedir) << "--timeout=15";
- args << QString("--referer=%1://%2/").arg(QUrl(url).scheme(), QUrl(url).host()) << "-U" << USER_AGENT_STR;
- args << "-O" << output.fileName() << url;
+ QStringList args(QLatin1String("-vsSqkfL"));
+ args << "-m" << QString::number(DOWNLOAD_TIMEOUT / 1000);
+ args << "--max-redirs" << QString::number(maxRedir);
+ args << "-U" << USER_AGENT_STR;
+ args << "-o" << output.fileName() << url;
QEventLoop loop;
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
timer.setSingleShot(true);
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- const QRegExp httpResponseOK("200 OK$");
-
- process.start(m_binaryWGet, args);
-
+ process.start(m_binaryCurl, args);
if (!process.waitForStarted())
{
return false;
}
- timer.start(25000);
+ timer.start(2 * DOWNLOAD_TIMEOUT);
while (process.state() != QProcess::NotRunning)
{
const bool bTimeOut = (!timer.isActive());
while (process.canReadLine())
{
- QString line = QString::fromLatin1(process.readLine()).simplified();
- if (line.contains(httpResponseOK))
+ const QString line = QString::fromLatin1(process.readLine()).simplified();
+ if (!line.isEmpty())
{
- line.append(" [OK]");
- if (httpOk) *httpOk = true;
+ log(line);
}
- log(line);
}
- if (bTimeOut)
+ if (bTimeOut || MUTILS_BOOLIFY(m_cancelled))
{
- qWarning("WGet process timed out <-- killing!");
+ qWarning("cURL process timed out <-- killing!");
process.kill();
process.waitForFinished();
- log("!!! TIMEOUT !!!");
+ log(bTimeOut ? "PROCESS TIMEOUT !!!" : "CANCELLED BY USER !!!", "");
return false;
}
}
return (process.exitCode() == 0) && output.exists() && output.isFile();
}
-bool UpdateChecker::tryContactHost(const QString &hostname)
+bool MUtils::UpdateChecker::tryContactHost(const QString &hostname, const int &timeoutMsec)
{
- log(QString("Connecting to host: %1").arg(hostname));
+ log(QString("Connecting to host: %1").arg(hostname), "");
QProcess process;
- init_process(process, temp_folder());
-
- QStringList args;
- args << "-z" << hostname << QString::number(80);
+ init_process(process, temp_folder(), true, NULL, m_environment.data());
+ QStringList args(QLatin1String("-vsSqkI"));
+ args << "-m" << QString::number(qMax(timeoutMsec, 1000) / 1000);
+ args << "-U" << USER_AGENT_STR;
+ args << "-o" << OS::null_device() << QString("http://%1/").arg(hostname);
+
QEventLoop loop;
connect(&process, SIGNAL(error(QProcess::ProcessError)), &loop, SLOT(quit()));
connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), &loop, SLOT(quit()));
QTimer timer;
timer.setSingleShot(true);
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
-
- process.start(m_binaryNC, args);
-
+
+ process.start(m_binaryCurl, args);
if (!process.waitForStarted())
{
return false;
}
- timer.start(10000);
+ timer.start(2 * qMax(timeoutMsec, 1000));
while (process.state() != QProcess::NotRunning)
{
const bool bTimeOut = (!timer.isActive());
while (process.canReadLine())
{
- QString line = QString::fromLatin1(process.readLine()).simplified();
- log(line);
+ const QString line = QString::fromLatin1(process.readLine()).simplified();
+ if (!line.isEmpty())
+ {
+ log(line);
+ }
}
- if (bTimeOut)
+ if (bTimeOut || MUTILS_BOOLIFY(m_cancelled))
{
- qWarning("NC process timed out <-- killing!");
+ qWarning("cURL process timed out <-- killing!");
process.kill();
process.waitForFinished();
- log("!!! TIMEOUT !!!");
+ log(bTimeOut ? "PROCESS TIMEOUT !!!" : "CANCELLED BY USER !!!", "");
return false;
}
}
return (process.exitCode() == 0);
}
-bool UpdateChecker::checkSignature(const QString &file, const QString &signature)
+bool MUtils::UpdateChecker::checkSignature(const QString &file, const QString &signature)
{
if (QFileInfo(file).absolutePath().compare(QFileInfo(signature).absolutePath(), Qt::CaseInsensitive) != 0)
{
loop.exec();
while (process.canReadLine())
{
- log(QString::fromLatin1(process.readLine()).simplified());
+ const QString line = QString::fromLatin1(process.readLine()).simplified();
+ if (!line.isEmpty())
+ {
+ log(line);
+ }
}
}