forked from m-pays/magi
/
updatecheck.h
65 lines (53 loc) · 2.19 KB
/
updatecheck.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2015 The Magi developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef UPDATECHECK_H
#define UPDATECHECK_H
#include <vector>
#include <QObject>
#include <QByteArray>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
/** \def _UPDATE_INTERVAL Frequency of update checks (units: hours)
*/
#define _UPDATE_INTERVAL 24
/** \def _UPDATE_MS_TO_HOURS Conversion factor from milliseconds to hours
*/
#define _UPDATE_MS_TO_HOURS 1000*60*60
/** \def _UPDATE_VERSION_URL The URL that stores the current wallet version string
* \details The newest wallet version string should be the sole contents of the file
* to which this URL points.
* The string is formatted as follows (based on the defines in ../version.h):
* DISPLAY_VERSION_MAJOR.DISPLAY_VERSION_MINOR.DISPLAY_VERSION_REVISION.DISPLAY_VERSION_BUILD
*
* This yields strings of the form: 1.2.1.2
*
* It is necessary to change the value of _UPDATE_URL to reflect the official location
* of the version string file. The file can be hosted be hosted in the official
* repository (using the raw file URL) or the coin's website.
*/
#define _UPDATE_VERSION_URL "http://starflakenights.net/crypto/magiversion/version.txt"
/** \def _UPDATE_DOWNLOAD_URL The URL linked when a new wallet version is available
* \details This URL string should reflect the offical wallet download location, be
* it a web page or directory. This macro contains \ characters before quotation marks
* to escape them for use with QString
*/
#define _UPDATE_DOWNLOAD_URL "http://coinmagi.org/wallets/"
class UpdateCheck : public QObject
{
Q_OBJECT
public:
explicit UpdateCheck(QUrl updateUrl, QObject *parent = 0);
virtual ~UpdateCheck();
QByteArray downloadedData() const;
std::vector<std::string> splitString(std::string input, std::string delimiter);
signals:
void downloaded();
private slots:
void updateDownloaded(QNetworkReply* pReply);
private:
QNetworkAccessManager m_WebCtrl;
QByteArray m_DownloadedData;
};
#endif // UPDATECHECK_H