Browse Source

common style changes

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
a51e49381d
  1. 8
      alethzero/MainWin.cpp
  2. 34
      libqethereum/QEthereum.cpp
  3. 35
      libqethereum/QEthereum.h

8
alethzero/MainWin.cpp

@ -136,16 +136,12 @@ Main::Main(QWidget *parent) :
connect(ui->webView, &QWebView::loadStarted, [this]()
{
// NOTE: no need to delete as QETH_INSTALL_JS_NAMESPACE adopts it.
m_qweb = new QWebThree(this);
auto qweb = m_qweb;
QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
QWebFrame* f = ui->webView->page()->mainFrame();
f->disconnect(SIGNAL(javaScriptWindowObjectCleared()));
m_qweb = new QWebThree(this);
auto qweb = m_qweb;
auto list = owned().toStdList();
m_server = auto_ptr<WebThreeStubServer>(new WebThreeStubServer(new QWebThreeConnector(qweb), *web3(), {std::begin(list), std::end(list)}));

34
libqethereum/QEthereum.cpp

@ -1,17 +1,30 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QEthereum.cpp
* @authors:
* Gav Wood <i@gavwood.com>
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
#include <QtCore/QtCore>
#include <QtWebKitWidgets/QWebFrame>
#include <libdevcrypto/FileSystem.h>
#include <libevmface/Instruction.h>
#include <liblll/Compiler.h>
#include <libethereum/Client.h>
#include <libethereum/EthereumHost.h>
#include <libp2p/Host.h>
#include "QEthereum.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
QWebThree::QWebThree(QObject* _p): QObject(_p)
{
@ -66,6 +79,7 @@ bool QWebThreeConnector::StopListening()
bool QWebThreeConnector::SendResponse(std::string const& _response, void* _addInfo)
{
Q_UNUSED(_addInfo);
emit m_qweb->send(QString::fromStdString(_response));
return true;
}

35
libqethereum/QEthereum.h

@ -1,10 +1,30 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file QEthereum.h
* @authors:
* Gav Wood <i@gavwood.com>
* Marek Kotewicz <marek@ethdev.com>
* @date 2014
*/
#pragma once
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QList>
#include <libdevcore/CommonIO.h>
#include <libethcore/CommonEth.h>
#include <QtCore/QString>
#include <jsonrpc/rpc.h>
class QWebThree: public QObject
@ -33,8 +53,7 @@ public:
virtual bool StartListening();
virtual bool StopListening();
bool virtual SendResponse(std::string const& _response,
void* _addInfo = NULL);
bool virtual SendResponse(std::string const& _response, void* _addInfo = NULL);
public slots:
void onMessage(QString const& _json);
@ -43,8 +62,6 @@ private:
QWebThree* m_qweb;
};
// TODO: p2p object condition
#define QETH_INSTALL_JS_NAMESPACE(_frame, _env, qweb) [_frame, _env, qweb]() \
{ \
_frame->disconnect(); \
@ -61,7 +78,7 @@ private:
_frame->evaluateJavaScript("navigator.qt.send.connect(function (res) {" \
"navigator.qt.handlers.forEach(function (handler) {" \
" handler(res);" \
"})" \
"})" \
"})"); \
}

Loading…
Cancel
Save