7#include "needupdatecheckexistingnewversionjob.h"
8#include "needupdateparsehtmljob.h"
9#include "needupdateparsehtmlutil.h"
10#include "pimcommon_debug.h"
13NeedUpdateCheckExistingNewVersionJob::NeedUpdateCheckExistingNewVersionJob(
QObject *parent)
18NeedUpdateCheckExistingNewVersionJob::~NeedUpdateCheckExistingNewVersionJob() =
default;
20void NeedUpdateCheckExistingNewVersionJob::start()
23 qCWarning(PIMCOMMON_LOG) <<
"Impossible to start NeedUpdateCheckExistingNewVersionJob";
24 Q_EMIT foundNewVersion(
false);
28 auto job =
new NeedUpdateParseHtmlJob(
this);
30 connect(job, &NeedUpdateParseHtmlJob::downLoadDone,
this, &NeedUpdateCheckExistingNewVersionJob::slotDownloadDone);
34void NeedUpdateCheckExistingNewVersionJob::slotDownloadDone(
const QString &str)
36 const QString compileDateStr = NeedUpdateParseHtmlUtil::extractDate(str);
38 Q_EMIT foundNewVersion(
false);
43 qCDebug(PIMCOMMON_LOG) <<
" currentCompiledDate " << mCompileDate;
45 const QDate dateFromUrl =
QDate::fromString(compileDateStr, QStringLiteral(
"yyyy-MM-dd"));
46 qCDebug(PIMCOMMON_LOG) <<
" dateFromUrl " << dateFromUrl <<
" original " << compileDateStr;
48 if (dateFromUrl > mCompileDate) {
49 Q_EMIT foundNewVersion(
true);
51 Q_EMIT foundNewVersion(
false);
56QUrl NeedUpdateCheckExistingNewVersionJob::url()
const
61void NeedUpdateCheckExistingNewVersionJob::setUrl(
const QUrl &newUrl)
66bool NeedUpdateCheckExistingNewVersionJob::canStart()
const
68 return !mUrl.
isEmpty() && mCompileDate.isValid();
71QDate NeedUpdateCheckExistingNewVersionJob::compileDate()
const
76void NeedUpdateCheckExistingNewVersionJob::setCompileDate(
const QDate &newCompileDate)
78 mCompileDate = newCompileDate;
81#include "moc_needupdatecheckexistingnewversionjob.cpp"
QDate fromString(QStringView string, QStringView format, QCalendar cal)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const
bool isEmpty() const const