From 64acc3c9e626c3f133e4f310e7b2ac534d59439d Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 23 Oct 2014 12:17:38 +0200 Subject: [PATCH] changes populated to third --- alethzero/MainWin.h | 1 - libwebthree/WebThree.h | 1 - third/CMakeLists.txt | 1 + third/MainWin.cpp | 35 +++++++++++++++-------------------- third/MainWin.h | 8 +++----- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index db7c490ce..d1ddeebb9 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -76,7 +76,6 @@ public: dev::WebThreeDirect* web3() const { return m_webThree.get(); } dev::eth::Client* ethereum() const { return m_webThree->ethereum(); } - dev::p2p::Host* peer2peer() const { return m_webThree->peer2peer(); } std::shared_ptr whisper() const { return m_webThree->whisper(); } QList const& owned() const { return m_myKeys; } diff --git a/libwebthree/WebThree.h b/libwebthree/WebThree.h index b42b9775a..a135f77ff 100644 --- a/libwebthree/WebThree.h +++ b/libwebthree/WebThree.h @@ -76,7 +76,6 @@ public: eth::Client* ethereum() const { if (!m_ethereum) BOOST_THROW_EXCEPTION(InterfaceNotSupported("eth")); return m_ethereum.get(); } std::shared_ptr whisper() const { auto w = m_whisper.lock(); if (!w) BOOST_THROW_EXCEPTION(InterfaceNotSupported("shh")); return w; } bzz::Interface* swarm() const { BOOST_THROW_EXCEPTION(InterfaceNotSupported("bzz")); } - p2p::Host* peer2peer() { return &m_net; }; // Misc stuff: diff --git a/third/CMakeLists.txt b/third/CMakeLists.txt index 9221ad045..f92d19c1f 100644 --- a/third/CMakeLists.txt +++ b/third/CMakeLists.txt @@ -54,6 +54,7 @@ endif () qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets) target_link_libraries(${EXECUTEABLE} webthree qethereum ethereum evm ethcore secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface devcore) +target_link_libraries(${EXECUTEABLE} ethrpc) if (APPLE) # First have qt5 install plugins and frameworks diff --git a/third/MainWin.cpp b/third/MainWin.cpp index 4fe58a9a9..73fb5bee7 100644 --- a/third/MainWin.cpp +++ b/third/MainWin.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "BuildInfo.h" #include "MainWin.h" #include "ui_Main.h" @@ -105,23 +106,22 @@ Main::Main(QWidget *parent) : connect(ui->webView, &QWebView::loadStarted, [this]() { // NOTE: no need to delete as QETH_INSTALL_JS_NAMESPACE adopts it. - m_dev = new QDev(this); - m_ethereum = new QEthereum(this, ethereum(), owned()); - m_whisper = new QWhisper(this, whisper()); - m_p2p = new QPeer2Peer(this, peer2peer()); + m_qweb = new QWebThree(this); + auto qweb = m_qweb; QWebFrame* f = ui->webView->page()->mainFrame(); f->disconnect(SIGNAL(javaScriptWindowObjectCleared())); - auto qdev = m_dev; - auto qeth = m_ethereum; - auto qshh = m_whisper; - auto qp2p = m_p2p; - connect(f, &QWebFrame::javaScriptWindowObjectCleared, QETH_INSTALL_JS_NAMESPACE(f, this, qdev, qeth, qshh, qp2p)); + + auto list = owned().toStdList(); + m_server = auto_ptr(new WebThreeStubServer(new QWebThreeConnector(qweb), *web3(), {std::begin(list), std::end(list)})); + m_server->StartListening(); + + connect(f, &QWebFrame::javaScriptWindowObjectCleared, QETH_INSTALL_JS_NAMESPACE(f, this, qweb)); }); connect(ui->webView, &QWebView::loadFinished, [=]() { - m_ethereum->poll(); +// m_ethereum->poll(); }); connect(ui->webView, &QWebView::titleChanged, [=]() @@ -149,7 +149,7 @@ Main::~Main() { // Must do this here since otherwise m_ethereum'll be deleted (and therefore clearWatches() called by the destructor) // *after* the client is dead. - m_ethereum->clientDieing(); +// m_ethereum->clientDieing(); writeSettings(); } @@ -159,11 +159,6 @@ eth::Client* Main::ethereum() const return m_web3->ethereum(); } -dev::p2p::Host* Main::peer2peer() const -{ - return web3()->peer2peer(); -} - std::shared_ptr Main::whisper() const { return m_web3->whisper(); @@ -527,8 +522,8 @@ void Main::timerEvent(QTimerEvent*) else interval += 100; - if (m_ethereum) - m_ethereum->poll(); +// if (m_ethereum) +// m_ethereum->poll(); for (auto const& i: m_handlers) if (ethereum()->checkWatch(i.first)) @@ -547,8 +542,8 @@ void Main::ourAccountsRowsMoved() myKeys.push_back(i); } m_myKeys = myKeys; - if (m_ethereum) - m_ethereum->setAccounts(myKeys); +// if (m_ethereum) +// m_ethereum->setAccounts(myKeys); } void Main::on_ourAccounts_doubleClicked() diff --git a/third/MainWin.h b/third/MainWin.h index 5d6577d42..b74b72d7f 100644 --- a/third/MainWin.h +++ b/third/MainWin.h @@ -48,6 +48,7 @@ class WhisperHost; } class QQuickView; +class WebThreeStubServer; class Main : public QMainWindow { @@ -59,7 +60,6 @@ public: dev::WebThreeDirect* web3() const { return m_web3.get(); } dev::eth::Client* ethereum() const; - dev::p2p::Host* peer2peer() const; std::shared_ptr whisper() const; QList const& owned() const { return m_myKeys; } @@ -133,8 +133,6 @@ private: QNetworkAccessManager m_webCtrl; - QDev* m_dev = nullptr; - QEthereum* m_ethereum = nullptr; - QWhisper* m_whisper = nullptr; - QPeer2Peer* m_p2p = nullptr; + std::auto_ptr m_server; + QWebThree* m_qweb = nullptr; };