X-Git-Url: http://git.osdn.net/view?p=mutilities%2FMUtilities.git;a=blobdiff_plain;f=docs%2Fd6%2Fd83%2F_update_checker_8h_source.html;h=9b399c31f843003ddc31d5d462f439893fd4c2dc;hp=d17ed1dba790f9cfbf074aace5ebc5227a477dc2;hb=bb40ce391c680d61168d1835dd8482a7d02766ca;hpb=b6dd06460847626f268e3fe9e39c5a1a4e7c442c diff --git a/docs/d6/d83/_update_checker_8h_source.html b/docs/d6/d83/_update_checker_8h_source.html index d17ed1d..9b399c3 100644 --- a/docs/d6/d83/_update_checker_8h_source.html +++ b/docs/d6/d83/_update_checker_8h_source.html @@ -67,10 +67,10 @@ $(function() {
UpdateChecker.h
-
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
22 #pragma once
23 
24 //MUtils
25 #include <MUtils/Global.h>
26 
27 //Qt
28 #include <QThread>
29 #include <QDate>
30 
32 
33 namespace MUtils
34 {
35  class MUTILS_API UpdateCheckerInfo
36  {
37  friend class UpdateChecker;
38 
39  public:
40  UpdateCheckerInfo(void);
41  void resetInfo(void);
42  bool isComplete(void);
43 
44  const quint32 &getBuildNo(void) const { return m_buildNo; }
45  const QDate &getBuildDate(void) const { return m_buildDate; }
46  const QString &getDownloadSite(void) const { return m_downloadSite; }
47  const QString &getDownloadAddress(void) const { return m_downloadAddress; }
48  const QString &getDownloadFilename(void) const { return m_downloadFilename; }
49  const QString &getDownloadFilecode(void) const { return m_downloadFilecode; }
50  const QString &getDownloadChecksum(void) const { return m_downloadChecksum; }
51 
52  private:
53  quint32 m_buildNo;
54  QDate m_buildDate;
55  QString m_downloadSite;
56  QString m_downloadAddress;
57  QString m_downloadFilename;
58  QString m_downloadFilecode;
59  QString m_downloadChecksum;
60  };
61 
62  // ----------------------------------------------------------------
63 
64  class MUTILS_API UpdateChecker : public QThread
65  {
66  Q_OBJECT
67 
68  public:
69  enum
70  {
71  UpdateStatus_NotStartedYet = 0,
72  UpdateStatus_CheckingConnection = 1,
73  UpdateStatus_FetchingUpdates = 2,
74  UpdateStatus_CompletedUpdateAvailable = 3,
75  UpdateStatus_CompletedNoUpdates = 4,
76  UpdateStatus_CompletedNewVersionOlder = 5,
77  UpdateStatus_ErrorNoConnection = 6,
78  UpdateStatus_ErrorConnectionTestFailed = 7,
79  UpdateStatus_ErrorFetchUpdateInfo = 8,
80  UpdateStatus_CancelledByUser = 9
81  }
82  update_status_t;
83 
84  UpdateChecker(const QString &binWGet, const QString &binMCat, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false);
85  ~UpdateChecker(void);
86 
87  const int getUpdateStatus(void) const { return m_status; }
88  const bool getSuccess(void) const { return m_success; };
89  const int getMaximumProgress(void) const { return m_maxProgress; };
90  const int getCurrentProgress(void) const { return m_progress; };
91  const UpdateCheckerInfo *getUpdateInfo(void) const { return m_updateInfo.data(); }
92 
93  bool cancel(void) { return m_cancelled.ref(); }
94 
95  public slots:
96  void start(Priority = InheritPriority);
97 
98  protected:
99  void run(void);
100  void checkForUpdates(void);
101  void testMirrorsList(void);
102 
103  signals:
104  void statusChanged(const int status);
105  void progressChanged(const int progress);
106  void messageLogged(const QString &text);
107 
108  private:
109  const int m_maxProgress;
110  QScopedPointer<UpdateCheckerInfo> m_updateInfo;
111 
112  const bool m_betaUpdates;
113  const bool m_testMode;
114 
115  const QString m_applicationId;
116  const quint32 m_installedBuildNo;
117 
118  const QString m_binaryWGet;
119  const QString m_binaryMCat;
120  const QString m_binaryGnuPG;
121  const QString m_binaryKeys;
122 
123  QAtomicInt m_success;
124  QAtomicInt m_cancelled;
125 
126  int m_status;
127  int m_progress;
128 
129  inline void setStatus(const int status);
130  inline void setProgress(const int progress);
131  inline void log(const QString &str1, const QString &str2 = QString(), const QString &str3 = QString(), const QString &str4 = QString());
132 
133  bool getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign);
134  bool tryContactHost(const QString &hostname, const int &timeoutMsec, quint32 *const ipAddrOut = NULL);
135  bool parseVersionInfo(const QString &file, UpdateCheckerInfo *updateInfo);
136 
137  bool getFile(const QString &url, const QString &outFile, const unsigned int maxRedir = 5U);
138  bool getFile(const QString &url, const bool forceIp4, const QString &outFile, const unsigned int maxRedir = 5U);
139  bool checkSignature(const QString &file, const QString &signature);
140  bool tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString &url, const bool &quick);
141  };
142 }
This file contains miscellaneous functions that are generally useful for Qt-based applications...
-
Definition: UpdateChecker.h:35
+
1 // MuldeR's Utilities for Qt
3 // Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 // http://www.gnu.org/licenses/lgpl-2.1.txt
21 
22 #pragma once
23 
24 //MUtils
25 #include <MUtils/Global.h>
26 
27 //Qt
28 #include <QThread>
29 #include <QDate>
30 
31 class QUrl;
32 
34 
35 namespace MUtils
36 {
37  class MUTILS_API UpdateCheckerInfo
38  {
39  friend class UpdateChecker;
40 
41  public:
42  UpdateCheckerInfo(void);
43  void resetInfo(void);
44  bool isComplete(void);
45 
46  const quint32 &getBuildNo(void) const { return m_buildNo; }
47  const QDate &getBuildDate(void) const { return m_buildDate; }
48  const QString &getDownloadSite(void) const { return m_downloadSite; }
49  const QString &getDownloadAddress(void) const { return m_downloadAddress; }
50  const QString &getDownloadFilename(void) const { return m_downloadFilename; }
51  const QString &getDownloadFilecode(void) const { return m_downloadFilecode; }
52  const QString &getDownloadChecksum(void) const { return m_downloadChecksum; }
53 
54  private:
55  quint32 m_buildNo;
56  QDate m_buildDate;
57  QString m_downloadSite;
58  QString m_downloadAddress;
59  QString m_downloadFilename;
60  QString m_downloadFilecode;
61  QString m_downloadChecksum;
62  };
63 
64  // ----------------------------------------------------------------
65 
66  class MUTILS_API UpdateChecker : public QThread
67  {
68  Q_OBJECT
69 
70  public:
71  enum
72  {
73  UpdateStatus_NotStartedYet = 0,
74  UpdateStatus_CheckingConnection = 1,
75  UpdateStatus_FetchingUpdates = 2,
76  UpdateStatus_CompletedUpdateAvailable = 3,
77  UpdateStatus_CompletedNoUpdates = 4,
78  UpdateStatus_CompletedNewVersionOlder = 5,
79  UpdateStatus_ErrorNoConnection = 6,
80  UpdateStatus_ErrorConnectionTestFailed = 7,
81  UpdateStatus_ErrorFetchUpdateInfo = 8,
82  UpdateStatus_CancelledByUser = 9
83  }
84  update_status_t;
85 
86  UpdateChecker(const QString &binCurl, const QString &binGnuPG, const QString &binKeys, const QString &applicationId, const quint32 &installedBuildNo, const bool betaUpdates, const bool testMode = false);
87  ~UpdateChecker(void);
88 
89  const int getUpdateStatus(void) const { return m_status; }
90  const bool getSuccess(void) const { return m_success; };
91  const int getMaximumProgress(void) const { return m_maxProgress; };
92  const int getCurrentProgress(void) const { return m_progress; };
93  const UpdateCheckerInfo *getUpdateInfo(void) const { return m_updateInfo.data(); }
94 
95  bool cancel(void) { return m_cancelled.ref(); }
96 
97  public slots:
98  void start(Priority = InheritPriority);
99 
100  protected:
101  void run(void);
102  void checkForUpdates(void);
103  void testMirrorsList(void);
104 
105  signals:
106  void statusChanged(const int status);
107  void progressChanged(const int progress);
108  void messageLogged(const QString &text);
109 
110  private:
111  const int m_maxProgress;
112  QScopedPointer<UpdateCheckerInfo> m_updateInfo;
113 
114  const bool m_betaUpdates;
115  const bool m_testMode;
116 
117  const QString m_applicationId;
118  const quint32 m_installedBuildNo;
119 
120  const QString m_binaryCurl;
121  const QString m_binaryGnuPG;
122  const QString m_binaryKeys;
123 
124  const QScopedPointer<const QHash<QString, QString>> m_environment;
125 
126  QAtomicInt m_success;
127  QAtomicInt m_cancelled;
128 
129  int m_status;
130  int m_progress;
131 
132  inline void setStatus(const int status);
133  inline void setProgress(const int progress);
134  inline void log(const QString &str1, const QString &str2 = QString(), const QString &str3 = QString(), const QString &str4 = QString());
135 
136  bool getUpdateInfo(const QString &url, const QString &outFileVers, const QString &outFileSign);
137  bool tryContactHost(const QString &hostname, const int &timeoutMsec);
138  bool parseVersionInfo(const QString &file, UpdateCheckerInfo *const updateInfo);
139 
140  bool getFile(const QUrl &url, const QString &outFile, const unsigned int maxRedir = 8U);
141  bool checkSignature(const QString &file, const QString &signature);
142  bool tryUpdateMirror(UpdateCheckerInfo *updateInfo, const QString &url, const bool &quick);
143 
144  bool execCurl(const QStringList &args, const QString &workingDir, const int timeout);
145  int execProcess(const QString &programFile, const QStringList &args, const QString &workingDir, const int timeout);
146  };
147 }
This file contains miscellaneous functions that are generally useful for Qt-based applications...
+
Definition: UpdateChecker.h:37
Global MUtils namespace.
Definition: CPUFeatures.h:37
-
Definition: UpdateChecker.h:64
+
Definition: UpdateChecker.h:66