11 changed files with 41 additions and 267 deletions
@ -1,41 +0,0 @@ |
|||||
cmake_policy(SET CMP0015 NEW) |
|
||||
# let cmake autolink dependencies on windows |
|
||||
cmake_policy(SET CMP0020 NEW) |
|
||||
# this policy was introduced in cmake 3.0 |
|
||||
# remove if, once 3.0 will be used on unix |
|
||||
if (${CMAKE_MAJOR_VERSION} GREATER 2) |
|
||||
# old policy do not use MACOSX_RPATH |
|
||||
cmake_policy(SET CMP0042 OLD) |
|
||||
cmake_policy(SET CMP0043 OLD) |
|
||||
endif() |
|
||||
|
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON) |
|
||||
aux_source_directory(. SRC_LIST) |
|
||||
|
|
||||
include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) |
|
||||
include_directories(..) |
|
||||
|
|
||||
set(EXECUTABLE qwebthree) |
|
||||
|
|
||||
file(GLOB HEADERS "*.h") |
|
||||
|
|
||||
if(ETH_STATIC) |
|
||||
add_library(${EXECUTABLE} STATIC ${RESOURCE_ADDED} ${SRC_LIST} ${HEADERS}) |
|
||||
else() |
|
||||
add_library(${EXECUTABLE} SHARED ${RESOURCE_ADDED} ${SRC_LIST} ${HEADERS}) |
|
||||
endif() |
|
||||
|
|
||||
target_link_libraries(${EXECUTABLE} Qt5::Core) |
|
||||
target_link_libraries(${EXECUTABLE} Qt5::Gui) |
|
||||
target_link_libraries(${EXECUTABLE} Qt5::WebKit) |
|
||||
target_link_libraries(${EXECUTABLE} Qt5::WebKitWidgets) |
|
||||
target_link_libraries(${EXECUTABLE} Qt5::Widgets) |
|
||||
target_link_libraries(${EXECUTABLE} Qt5::Network) |
|
||||
target_link_libraries(${EXECUTABLE} Qt5::Quick) |
|
||||
target_link_libraries(${EXECUTABLE} Qt5::Qml) |
|
||||
target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_SERVER_LIBRARIES}) |
|
||||
target_link_libraries(${EXECUTABLE} ethereum) |
|
||||
target_link_libraries(${EXECUTABLE} secp256k1) |
|
||||
|
|
||||
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) |
|
||||
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) |
|
@ -1,107 +0,0 @@ |
|||||
/*
|
|
||||
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 QWebThree.cpp
|
|
||||
* @authors: |
|
||||
* Gav Wood <i@gavwood.com> |
|
||||
* Marek Kotewicz <marek@ethdev.com> |
|
||||
* @date 2014 |
|
||||
*/ |
|
||||
|
|
||||
#include <QtCore/QtCore> |
|
||||
#include "QWebThree.h" |
|
||||
|
|
||||
using namespace std; |
|
||||
|
|
||||
QWebThree::QWebThree(QObject* _p): QObject(_p) |
|
||||
{ |
|
||||
moveToThread(_p->thread()); |
|
||||
} |
|
||||
|
|
||||
QWebThree::~QWebThree() |
|
||||
{ |
|
||||
clientDieing(); |
|
||||
} |
|
||||
|
|
||||
void QWebThree::clientDieing() |
|
||||
{ |
|
||||
this->disconnect(); |
|
||||
} |
|
||||
|
|
||||
QString QWebThree::callMethod(QString _json) |
|
||||
{ |
|
||||
emit processData(_json, ""); // it's synchronous
|
|
||||
return m_response; |
|
||||
} |
|
||||
|
|
||||
void QWebThree::onDataProcessed(QString _json, QString) |
|
||||
{ |
|
||||
QJsonObject f = QJsonDocument::fromJson(_json.toUtf8()).object(); |
|
||||
syncResponse(QString::fromUtf8(QJsonDocument(f).toJson())); |
|
||||
} |
|
||||
|
|
||||
void QWebThree::syncResponse(QString _json) |
|
||||
{ |
|
||||
m_response = _json; |
|
||||
} |
|
||||
|
|
||||
QWebThreeConnector::QWebThreeConnector() |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
QWebThreeConnector::~QWebThreeConnector() |
|
||||
{ |
|
||||
StopListening(); |
|
||||
} |
|
||||
|
|
||||
void QWebThreeConnector::setQWeb(QWebThree* _q) |
|
||||
{ |
|
||||
m_qweb = _q; |
|
||||
if (m_isListening) |
|
||||
{ |
|
||||
StopListening(); |
|
||||
StartListening(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
bool QWebThreeConnector::StartListening() |
|
||||
{ |
|
||||
m_isListening = true; |
|
||||
if (m_qweb) |
|
||||
{ |
|
||||
connect(m_qweb, SIGNAL(processData(QString, QString)), this, SLOT(onProcessData(QString, QString))); |
|
||||
connect(this, SIGNAL(dataProcessed(QString, QString)), m_qweb, SLOT(onDataProcessed(QString, QString))); |
|
||||
} |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
bool QWebThreeConnector::StopListening() |
|
||||
{ |
|
||||
this->disconnect(); |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
bool QWebThreeConnector::SendResponse(std::string const& _response, void* _addInfo) |
|
||||
{ |
|
||||
emit dataProcessed(QString::fromStdString(_response), *(QString*)_addInfo); |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
void QWebThreeConnector::onProcessData(QString const& _json, QString const& _addInfo) |
|
||||
{ |
|
||||
OnRequest(_json.toStdString(), (void*)&_addInfo); |
|
||||
} |
|
||||
|
|
@ -1,89 +0,0 @@ |
|||||
/*
|
|
||||
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 QWebThree.h
|
|
||||
* @authors: |
|
||||
* Gav Wood <i@gavwood.com> |
|
||||
* Marek Kotewicz <marek@ethdev.com> |
|
||||
* @date 2014 |
|
||||
*/ |
|
||||
|
|
||||
#pragma once |
|
||||
|
|
||||
#include <QtCore/QObject> |
|
||||
#include <QtCore/QString> |
|
||||
#include <jsonrpccpp/server.h> |
|
||||
|
|
||||
class QWebThree: public QObject |
|
||||
{ |
|
||||
Q_OBJECT |
|
||||
|
|
||||
public: |
|
||||
QWebThree(QObject* _p); |
|
||||
virtual ~QWebThree(); |
|
||||
void clientDieing(); |
|
||||
|
|
||||
Q_INVOKABLE QString callMethod(QString _json); |
|
||||
void syncResponse(QString _json); |
|
||||
|
|
||||
public slots: |
|
||||
void onDataProcessed(QString _json, QString _addInfo); |
|
||||
|
|
||||
signals: |
|
||||
void processData(QString _json, QString _addInfo); |
|
||||
void response(QString _json); |
|
||||
void onNewId(QString _id); |
|
||||
|
|
||||
private: |
|
||||
QString m_response; |
|
||||
}; |
|
||||
|
|
||||
class QWebThreeConnector: public QObject, public jsonrpc::AbstractServerConnector |
|
||||
{ |
|
||||
Q_OBJECT |
|
||||
|
|
||||
public: |
|
||||
QWebThreeConnector(); |
|
||||
virtual ~QWebThreeConnector(); |
|
||||
|
|
||||
void setQWeb(QWebThree *_q); |
|
||||
|
|
||||
virtual bool StartListening(); |
|
||||
virtual bool StopListening(); |
|
||||
virtual bool SendResponse(std::string const& _response, void* _addInfo = NULL); |
|
||||
|
|
||||
public slots: |
|
||||
void onProcessData(QString const& _json, QString const& _addInfo); |
|
||||
|
|
||||
signals: |
|
||||
void dataProcessed(QString const& _json, QString const& _addInfo); |
|
||||
|
|
||||
private: |
|
||||
QWebThree* m_qweb = nullptr; |
|
||||
bool m_isListening; |
|
||||
}; |
|
||||
|
|
||||
#define QETH_INSTALL_JS_NAMESPACE(_frame, _env, qweb) [_frame, _env, qweb]() \ |
|
||||
{ \ |
|
||||
_frame->disconnect(); \ |
|
||||
_frame->addToJavaScriptWindowObject("_web3", qweb, QWebFrame::ScriptOwnership); \ |
|
||||
_frame->addToJavaScriptWindowObject("env", _env, QWebFrame::QtOwnership); \ |
|
||||
_frame->evaluateJavaScript(contentsOfQResource(":/js/bignumber.min.js")); \ |
|
||||
_frame->evaluateJavaScript(contentsOfQResource(":/js/webthree.js")); \ |
|
||||
_frame->evaluateJavaScript(contentsOfQResource(":/js/setup.js")); \ |
|
||||
} |
|
||||
|
|
||||
|
|
Loading…
Reference in new issue