Skip to content

Commit

Permalink
Revert "Wallet version control added."
Browse files Browse the repository at this point in the history
This reverts commit 9cff27a.
  • Loading branch information
hardwarewise committed Dec 12, 2020
1 parent 202c47b commit 5dde681
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 129 deletions.
120 changes: 2 additions & 118 deletions src/qt/splashscreen.cpp
Expand Up @@ -27,19 +27,11 @@
#include <QMovie>
#include <QLabel>

#include <univalue/include/univalue.h>
#include <QDebug>
#include <QMessageBox>
#include <QDesktopServices>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QUrl>

SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const NetworkStyle *networkStyle) :
QWidget(0, f), curAlignment(0), m_node(node), networkVersionManager(0), versionRequest(0)
QWidget(0, f), curAlignment(0), m_node(node)
{
setWindowFlags(Qt::FramelessWindowHint);

setWindowFlags(Qt::FramelessWindowHint);

// set sizes
int versionTextHeight = 30;
Expand All @@ -53,109 +45,6 @@ SplashScreen::SplashScreen(interfaces::Node& node, Qt::WindowFlags f, const Netw
float fontFactor = 1.0;
float devicePixelRatio = 1.0;

//++
networkVersionManager = new QNetworkAccessManager();
versionRequest = new QNetworkRequest();

// Get the latest SIN-core release and let the user know if they are using the latest version
// Network request code for the header widget
QObject::connect(networkVersionManager, &QNetworkAccessManager::finished,
this, [=](QNetworkReply *reply) {
if (reply->error()) {
qDebug() << reply->errorString();
return;
}

// Get the data from the network request
QString answer = reply->readAll();

UniValue releases(UniValue::VARR);
releases.read(answer.toStdString());

if (!releases.isArray()) {
return;
}

if (!releases.size()) {
return;
}

// Latest release lives in the first index of the array return from github v3 api
auto latestRelease = releases[0];

auto keys = latestRelease.getKeys();
for (auto key : keys) {
if (key == "tag_name") {
auto latestVersion = latestRelease["tag_name"].get_str();

QRegExp rx("(\\d+).(\\d+).(\\d+).(\\d+)");
rx.indexIn(QString::fromStdString(latestVersion));

// List the found values
QStringList list = rx.capturedTexts();
static const int CLIENT_VERSION_MAJOR_INDEX = 1;
static const int CLIENT_VERSION_MINOR_INDEX = 2;
static const int CLIENT_VERSION_REVISION_INDEX = 3;
static const int CLIENT_VERSION_BUILD_INDEX = 4;
bool fNewSoftwareFound = false;
bool fStopSearch = false;
if (list.size() >= 4) {
if (CLIENT_VERSION_MAJOR < list[CLIENT_VERSION_MAJOR_INDEX].toInt()) {
fNewSoftwareFound = true;
} else {
if (CLIENT_VERSION_MAJOR > list[CLIENT_VERSION_MAJOR_INDEX].toInt()) {
fStopSearch = true;
}
}

if (!fStopSearch) {
if (CLIENT_VERSION_MINOR < list[CLIENT_VERSION_MINOR_INDEX].toInt()) {
fNewSoftwareFound = true;
} else {
if (CLIENT_VERSION_MINOR > list[CLIENT_VERSION_MINOR_INDEX].toInt()) {
fStopSearch = true;
}
}
}

if (!fStopSearch) {
if (CLIENT_VERSION_REVISION < list[CLIENT_VERSION_REVISION_INDEX].toInt()) {
fNewSoftwareFound = true;
}else {
if (CLIENT_VERSION_REVISION > list[CLIENT_VERSION_REVISION_INDEX].toInt()) {
fStopSearch = true;
}
}

}

if (!fStopSearch) {
if (CLIENT_VERSION_BUILD < list[CLIENT_VERSION_BUILD_INDEX].toInt()) {
fNewSoftwareFound = true;
}
}
}

if (fNewSoftwareFound) {


QMessageBox msgBox;
msgBox.setWindowTitle("SIN-CORE");
msgBox.setTextFormat(Qt::RichText);
msgBox.setText("New wallet version found <br> <br> <a href=\"https://github.com/SINOVATEblockchain/SIN-core/releases/\">Please click here to download the latest version.</a>");
msgBox.setWindowModality(Qt::NonModal);
msgBox.exec();

}
}
}
}
);

getLatestVersion();

//--

// define text to place
QString titleText = tr("SIN Core");
QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFullVersion()));
Expand Down Expand Up @@ -328,8 +217,3 @@ void SplashScreen::closeEvent(QCloseEvent *event)
m_node.startShutdown(); // allows an "emergency" shutdown during startup
event->ignore();
}
void SplashScreen::getLatestVersion()
{
versionRequest->setUrl(QUrl("https://api.github.com/repos/SINOVATEblockchain/SIN-core/releases"));
networkVersionManager->get(*versionRequest);
}
11 changes: 0 additions & 11 deletions src/qt/splashscreen.h
Expand Up @@ -12,12 +12,6 @@

class NetworkStyle;


QT_BEGIN_NAMESPACE
class QNetworkAccessManager;
class QNetworkRequest;
QT_END_NAMESPACE

namespace interfaces {
class Handler;
class Node;
Expand Down Expand Up @@ -59,12 +53,7 @@ public Q_SLOTS:
void unsubscribeFromCoreSignals();
/** Connect wallet signals to splash screen */
void ConnectWallet(std::unique_ptr<interfaces::Wallet> wallet);
void getLatestVersion();


QNetworkAccessManager* networkVersionManager;
QNetworkRequest* versionRequest;

QPixmap pixmap;
QString curMessage;
QColor curColor;
Expand Down

0 comments on commit 5dde681

Please sign in to comment.