diff --git a/gostcoin-qt.pro b/gostcoin-qt.pro index 6a9fe5b..0b19cfb 100644 --- a/gostcoin-qt.pro +++ b/gostcoin-qt.pro @@ -211,7 +211,8 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/macnotificationhandler.h \ src/qt/splashscreen.h \ src/qt/showi2paddresses.h \ - src/qt/i2poptionswidget.h + src/qt/i2poptionswidget.h \ + src/qt/setupdarknet.h SOURCES += src/qt/gostcoin.cpp \ src/qt/bitcoingui.cpp \ @@ -286,6 +287,7 @@ SOURCES += src/qt/gostcoin.cpp \ src/qt/splashscreen.cpp \ src/qt/showi2paddresses.cpp \ src/qt/i2poptionswidget.cpp \ + src/qt/setupdarknet.cpp \ i2psam/i2psam.cpp RESOURCES += src/qt/bitcoin.qrc diff --git a/src/qt/gostcoin.cpp b/src/qt/gostcoin.cpp index b85d1fa..041bd8e 100644 --- a/src/qt/gostcoin.cpp +++ b/src/qt/gostcoin.cpp @@ -23,6 +23,7 @@ #include "ui_interface.h" #include "paymentserver.h" #include "splashscreen.h" +#include "setupdarknet.h" #include #if QT_VERSION < 0x050000 @@ -194,7 +195,8 @@ int main(int argc, char *argv[]) // Gostcoin if (!boost::filesystem::exists(GetConfigFile().string())) { - writeFirstConfig(); // create default config + // Run wizard + runFirstRunWizard(); } // Read config after it's potentional written by the wizard. ReadConfigFile(mapArgs, mapMultiArgs); diff --git a/src/qt/setupdarknet.cpp b/src/qt/setupdarknet.cpp new file mode 100644 index 0000000..2546c5c --- /dev/null +++ b/src/qt/setupdarknet.cpp @@ -0,0 +1,63 @@ +// Copyright 2013 The Anoncoin Developers +// Copyright 2017 The Gostcoin Developers + +#include +#include +#include + +#include "setupdarknet.h" +#include "bitcoingui.h" +#include "util.h" + + +void runFirstRunWizard() +{ + QString strMessage = BitcoinGUI::tr("Do you run I2P on your computer?\n" + "If so, press yes to let Gostcoin configure it's " + "connection to the I2P"); + QMessageBox::StandardButton isRunningDarknet = QMessageBox::question(NULL, + BitcoinGUI::tr("Gostcoin Wizard - Step #1"), strMessage, + QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); + if (isRunningDarknet == QMessageBox::No) + { + // Tell user to download + strMessage = BitcoinGUI::tr("Do you want to install I2P, and " + "continue I2P setup?\nIf you select yes Gostcoin will quit, " + "so you can continue the wizard after installing I2P.\n" + "If you select no, Gostcoin will write a default clearnet " + "(regular internet) config file for you. (unsafe mode)\n"); + QMessageBox::StandardButton wantDownloadDarknet = QMessageBox::question(NULL, + BitcoinGUI::tr("Gostcoin Wizard - Step #2"), strMessage, + QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes); + if (wantDownloadDarknet == QMessageBox::No) + { + writeFirstConfig(false, false); + return; + } + QApplication::quit(); + exit(7); // Exit code 7 = awaiting darknet + } + // Step #2 passed. Use I2P + FinishWizard(); +} + +void FinishWizard() +{ + QMessageBox msgBox; + QPushButton *sharedButton = msgBox.addButton(BitcoinGUI::tr("Shared"), QMessageBox::ActionRole); + QPushButton * i2pOnlyButton = msgBox.addButton(BitcoinGUI::tr("I2P only"), QMessageBox::ActionRole); + msgBox.setText(BitcoinGUI::tr("Ok, last question!\nDo you want to run shared " + "(which means you work as a bridge between the " + "I2P and internet) or only I2P?")); + msgBox.exec(); + if (msgBox.clickedButton() == i2pOnlyButton) + writeFirstConfig (true, true); + else if (msgBox.clickedButton() == sharedButton) + writeFirstConfig (false, true); + QMessageBox msgBoxThanks; + msgBoxThanks.setText(BitcoinGUI::tr("Thanks! That was all. Enjoy your wallet :)")); + msgBoxThanks.exec(); + return; +} + + diff --git a/src/qt/setupdarknet.h b/src/qt/setupdarknet.h new file mode 100644 index 0000000..e5fbad1 --- /dev/null +++ b/src/qt/setupdarknet.h @@ -0,0 +1,7 @@ +#ifndef SETUPDARKNET_H +#define SETUPDARKNET_H + +void runFirstRunWizard(); +void FinishWizard(); + +#endif diff --git a/src/util.cpp b/src/util.cpp index 6c16493..13c1199 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -996,13 +996,15 @@ bool writeConfig(boost::filesystem::path configFile, boost::property_tree::ptree } // call upon first run -bool writeFirstConfig() +bool writeFirstConfig(bool i2pOnlyEnabled, bool i2pEnabled) { using boost::property_tree::ptree; ptree pt; - pt.put("onlynet", "i2p"); - pt.put("i2p", 1); + if (i2pOnlyEnabled) + pt.put("onlynet", "i2p"); + if (i2pEnabled) + pt.put("i2p", 1); unsigned char rand_pwd[32]; RAND_bytes(rand_pwd, 32); pt.put("rpcuser", "gostcoinrpc"); diff --git a/src/util.h b/src/util.h index a880d0d..c534095 100644 --- a/src/util.h +++ b/src/util.h @@ -133,7 +133,7 @@ inline void MilliSleep(int64 n) // Gostcoin bool WriteConfig(boost::filesystem::path configFile, boost::property_tree::ptree data); -bool writeFirstConfig(); // always I2P +bool writeFirstConfig(bool i2pOnlyEnabled, bool i2pEnabled);