Cleanup for wormhole connection
This commit is contained in:
@@ -68,7 +68,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
if (rpc->getConnection() == nullptr)
|
if (rpc->getConnection() == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AppDataServer::connectAppDialog(this);
|
AppDataServer::getInstance()->connectAppDialog(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Address Book
|
// Address Book
|
||||||
@@ -109,7 +109,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createWebsocket() {
|
void MainWindow::createWebsocket() {
|
||||||
new WSServer(8237, true, this);
|
wsserver = new WSServer(8237, false, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::restoreSavedStates() {
|
void MainWindow::restoreSavedStates() {
|
||||||
@@ -1365,4 +1365,6 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
delete loadingMovie;
|
delete loadingMovie;
|
||||||
delete logger;
|
delete logger;
|
||||||
|
|
||||||
|
delete wsserver;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
// Forward declare to break circular dependency.
|
// Forward declare to break circular dependency.
|
||||||
class RPC;
|
class RPC;
|
||||||
class Settings;
|
class Settings;
|
||||||
|
class WSServer;
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
@@ -93,7 +94,6 @@ private:
|
|||||||
void addressBook();
|
void addressBook();
|
||||||
void payZcashURI();
|
void payZcashURI();
|
||||||
void postToZBoard();
|
void postToZBoard();
|
||||||
void connectApp();
|
|
||||||
void importPrivKey();
|
void importPrivKey();
|
||||||
void exportAllKeys();
|
void exportAllKeys();
|
||||||
void exportKeys(QString addr = "");
|
void exportKeys(QString addr = "");
|
||||||
@@ -106,6 +106,8 @@ private:
|
|||||||
|
|
||||||
void createWebsocket();
|
void createWebsocket();
|
||||||
|
|
||||||
|
WSServer* wsserver = nullptr;
|
||||||
|
|
||||||
RPC* rpc = nullptr;
|
RPC* rpc = nullptr;
|
||||||
QCompleter* labelCompleter = nullptr;
|
QCompleter* labelCompleter = nullptr;
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ void WSServer::processTextMessage(QString message)
|
|||||||
qDebug() << "Message received:" << message;
|
qDebug() << "Message received:" << message;
|
||||||
|
|
||||||
if (pClient) {
|
if (pClient) {
|
||||||
AppDataServer::processMessage(message, m_mainWindow, pClient);
|
AppDataServer::getInstance()->processMessage(message, m_mainWindow, pClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,9 +55,7 @@ void WSServer::processBinaryMessage(QByteArray message)
|
|||||||
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
|
QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
qDebug() << "Binary Message received:" << message;
|
qDebug() << "Binary Message received:" << message;
|
||||||
if (pClient) {
|
|
||||||
pClient->sendBinaryMessage(message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSServer::socketDisconnected()
|
void WSServer::socketDisconnected()
|
||||||
@@ -74,6 +72,8 @@ void WSServer::socketDisconnected()
|
|||||||
// ==============================
|
// ==============================
|
||||||
// AppDataServer
|
// AppDataServer
|
||||||
// ==============================
|
// ==============================
|
||||||
|
AppDataServer* AppDataServer::instance = nullptr;
|
||||||
|
|
||||||
QString AppDataServer::getSecretHex() {
|
QString AppDataServer::getSecretHex() {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
|
||||||
@@ -87,9 +87,6 @@ void AppDataServer::saveNewSecret(QString secretHex) {
|
|||||||
s.sync();
|
s.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppDataServer::tempSecret = "";
|
|
||||||
Ui_MobileAppConnector* AppDataServer::ui = nullptr;
|
|
||||||
|
|
||||||
void AppDataServer::connectAppDialog(QWidget* parent) {
|
void AppDataServer::connectAppDialog(QWidget* parent) {
|
||||||
QDialog d(parent);
|
QDialog d(parent);
|
||||||
ui = new Ui_MobileAppConnector();
|
ui = new Ui_MobileAppConnector();
|
||||||
@@ -574,4 +571,4 @@ void AppDataServer::processGetTransactions(MainWindow* mainWindow, QWebSocket* p
|
|||||||
// ==============================
|
// ==============================
|
||||||
// AppDataModel
|
// AppDataModel
|
||||||
// ==============================
|
// ==============================
|
||||||
AppDataModel* AppDataModel::instance = NULL;
|
AppDataModel* AppDataModel::instance = nullptr;
|
||||||
|
|||||||
@@ -40,28 +40,38 @@ enum NonceType {
|
|||||||
|
|
||||||
class AppDataServer {
|
class AppDataServer {
|
||||||
public:
|
public:
|
||||||
static void connectAppDialog(QWidget* parent);
|
static AppDataServer* getInstance() {
|
||||||
static void updateConnectedUI();
|
if (instance == nullptr) {
|
||||||
static void updateUIWithNewQRCode();
|
instance = new AppDataServer();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
static void processSendTx(QJsonObject sendTx, MainWindow* mainwindow, QWebSocket* pClient);
|
void connectAppDialog(QWidget* parent);
|
||||||
static void processMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient);
|
void updateConnectedUI();
|
||||||
static void processDecryptedMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient);
|
void updateUIWithNewQRCode();
|
||||||
static void processGetInfo(QJsonObject jobj, MainWindow* mainWindow, QWebSocket* pClient);
|
|
||||||
static void processGetTransactions(MainWindow* mainWindow, QWebSocket* pClient);
|
|
||||||
|
|
||||||
static QString decryptMessage(QJsonDocument msg, QString secretHex, bool skipNonceCheck = false);
|
void processSendTx(QJsonObject sendTx, MainWindow* mainwindow, QWebSocket* pClient);
|
||||||
static QString encryptOutgoing(QString msg);
|
void processMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient);
|
||||||
|
void processGetInfo(QJsonObject jobj, MainWindow* mainWindow, QWebSocket* pClient);
|
||||||
|
void processDecryptedMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient);
|
||||||
|
void processGetTransactions(MainWindow* mainWindow, QWebSocket* pClient);
|
||||||
|
|
||||||
static QString getSecretHex();
|
QString decryptMessage(QJsonDocument msg, QString secretHex, bool skipNonceCheck = false);
|
||||||
static void saveNewSecret(QString secretHex);
|
QString encryptOutgoing(QString msg);
|
||||||
|
|
||||||
static QString getNonceHex(NonceType nt);
|
QString getSecretHex();
|
||||||
static void saveNonceHex(NonceType nt, QString noncehex);
|
void saveNewSecret(QString secretHex);
|
||||||
|
|
||||||
|
QString getNonceHex(NonceType nt);
|
||||||
|
void saveNonceHex(NonceType nt, QString noncehex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString tempSecret;
|
AppDataServer() = default;
|
||||||
static Ui_MobileAppConnector* ui;
|
|
||||||
|
static AppDataServer* instance;
|
||||||
|
QString tempSecret;
|
||||||
|
Ui_MobileAppConnector* ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppDataModel {
|
class AppDataModel {
|
||||||
|
|||||||
Reference in New Issue
Block a user