• R/O
  • HTTP
  • SSH
  • HTTPS

MUtilities: 提交

MUtilities development repository


Commit MetaInfo

修订版2eac767ad2e256248223055bbd8d34379b1eab54 (tree)
时间2015-08-16 23:27:43
作者LoRd_MuldeR <mulder2@gmx....>
CommiterLoRd_MuldeR

Log Message

UpdateChecker: Parse and forward the new "DownloadChecksum" entry from update info file.

更改概述

差异

--- a/include/MUtils/UpdateChecker.h
+++ b/include/MUtils/UpdateChecker.h
@@ -39,6 +39,7 @@ namespace MUtils
3939 public:
4040 UpdateCheckerInfo(void);
4141 void resetInfo(void);
42+ bool isComplete(void);
4243
4344 const quint32 &getBuildNo(void) const { return m_buildNo; }
4445 const QDate &getBuildDate(void) const { return m_buildDate; }
@@ -46,6 +47,7 @@ namespace MUtils
4647 const QString &getDownloadAddress(void) const { return m_downloadAddress; }
4748 const QString &getDownloadFilename(void) const { return m_downloadFilename; }
4849 const QString &getDownloadFilecode(void) const { return m_downloadFilecode; }
50+ const QString &getDownloadChecksum(void) const { return m_downloadChecksum; }
4951
5052 private:
5153 quint32 m_buildNo;
@@ -54,6 +56,7 @@ namespace MUtils
5456 QString m_downloadAddress;
5557 QString m_downloadFilename;
5658 QString m_downloadFilecode;
59+ QString m_downloadChecksum;
5760 };
5861
5962 // ----------------------------------------------------------------
@@ -80,11 +83,11 @@ namespace MUtils
8083 UpdateChecker(const QString &binWGet, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false);
8184 ~UpdateChecker(void);
8285
83- const int getUpdateStatus(void) const { return m_status; }
84- const bool getSuccess(void) const { return m_success; };
85- const int getMaximumProgress(void) const { return m_maxProgress; };
86- const int getCurrentProgress(void) const { return m_progress; };
87- const UpdateCheckerInfo *getUpdateInfo(void) const { return m_updateInfo; }
86+ const int getUpdateStatus(void) const { return m_status; }
87+ const bool getSuccess(void) const { return m_success; };
88+ const int getMaximumProgress(void) const { return m_maxProgress; };
89+ const int getCurrentProgress(void) const { return m_progress; };
90+ const UpdateCheckerInfo *getUpdateInfo(void) const { return m_updateInfo.data(); }
8891
8992 protected:
9093 void run(void);
@@ -98,7 +101,7 @@ namespace MUtils
98101
99102 private:
100103 const int m_maxProgress;
101- UpdateCheckerInfo *const m_updateInfo;
104+ QScopedPointer<UpdateCheckerInfo> m_updateInfo;
102105
103106 const bool m_betaUpdates;
104107 const bool m_testMode;
--- a/src/UpdateChecker.cpp
+++ b/src/UpdateChecker.cpp
@@ -207,6 +207,20 @@ void UpdateCheckerInfo::resetInfo(void)
207207 m_downloadAddress.clear();
208208 m_downloadFilename.clear();
209209 m_downloadFilecode.clear();
210+ m_downloadChecksum.clear();
211+}
212+
213+bool UpdateCheckerInfo::isComplete(void)
214+{
215+ if(this->m_buildNo < 1) return false;
216+ if(this->m_buildDate.year() < 2010) return false;
217+ if(this->m_downloadSite.isEmpty()) return false;
218+ if(this->m_downloadAddress.isEmpty()) return false;
219+ if(this->m_downloadFilename.isEmpty()) return false;
220+ if(this->m_downloadFilecode.isEmpty()) return false;
221+ if(this->m_downloadChecksum.isEmpty()) return false;
222+
223+ return true;
210224 }
211225
212226 ////////////////////////////////////////////////////////////
@@ -237,7 +251,6 @@ UpdateChecker::UpdateChecker(const QString &binWGet, const QString &binGnuPG, co
237251
238252 UpdateChecker::~UpdateChecker(void)
239253 {
240- delete m_updateInfo;
241254 }
242255
243256 ////////////////////////////////////////////////////////////
@@ -340,7 +353,7 @@ void UpdateChecker::checkForUpdates(void)
340353 setProgress(m_progress + 1);
341354 if(!m_success)
342355 {
343- if(tryUpdateMirror(m_updateInfo, currentMirror))
356+ if(tryUpdateMirror(m_updateInfo.data(), currentMirror))
344357 {
345358 m_success = true;
346359 }
@@ -669,12 +682,12 @@ bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *upd
669682 if(value.cap(1).compare("BuildNo", Qt::CaseInsensitive) == 0)
670683 {
671684 bool ok = false;
672- unsigned int temp = value.cap(2).toUInt(&ok);
685+ const unsigned int temp = value.cap(2).toUInt(&ok);
673686 if(ok) updateInfo->m_buildNo = temp;
674687 }
675688 else if(value.cap(1).compare("BuildDate", Qt::CaseInsensitive) == 0)
676689 {
677- QDate temp = QDate::fromString(value.cap(2).trimmed(), Qt::ISODate);
690+ const QDate temp = QDate::fromString(value.cap(2).trimmed(), Qt::ISODate);
678691 if(temp.isValid()) updateInfo->m_buildDate = temp;
679692 }
680693 else if(value.cap(1).compare("DownloadSite", Qt::CaseInsensitive) == 0)
@@ -693,6 +706,10 @@ bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *upd
693706 {
694707 updateInfo->m_downloadFilecode = value.cap(2).trimmed();
695708 }
709+ else if(value.cap(1).compare("DownloadChecksum", Qt::CaseInsensitive) == 0)
710+ {
711+ updateInfo->m_downloadChecksum = value.cap(2).trimmed();
712+ }
696713 }
697714 if(inHdr && (value.indexIn(line) >= 0))
698715 {
@@ -724,22 +741,14 @@ bool UpdateChecker::parseVersionInfo(const QString &file, UpdateCheckerInfo *upd
724741 log("Version info is from the future, take care!");
725742 qWarning("Version info is from the future, take care!");
726743 }
727-
728- bool complete = true;
729-
730- if(!(updateInfo->m_buildNo > 0)) complete = false;
731- if(!(updateInfo->m_buildDate.year() >= 2010)) complete = false;
732- if(updateInfo->m_downloadSite.isEmpty()) complete = false;
733- if(updateInfo->m_downloadAddress.isEmpty()) complete = false;
734- if(updateInfo->m_downloadFilename.isEmpty()) complete = false;
735- if(updateInfo->m_downloadFilecode.isEmpty()) complete = false;
736744
737- if(!complete)
745+ if(!updateInfo->isComplete())
738746 {
739747 log("WARNING: Version info is incomplete!");
748+ return false;
740749 }
741750
742- return complete;
751+ return true;
743752 }
744753
745754 ////////////////////////////////////////////////////////////
Show on old repository browser