Skip to content
Snippets Groups Projects
Unverified Commit fc4a7c70 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov Committed by GitHub
Browse files

Merge pull request #12 from cellframe/features-2347-dashboard

Build Dashboard under Windows OS
parents 00e420c4 fee437d5
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
#include "DapServiceClientNativeLinux.h" #include "DapServiceClientNativeLinux.h"
typedef class DapServiceClientNativeLinux DapServiceClientNative; typedef class DapServiceClientNativeLinux DapServiceClientNative;
#elif defined(Q_OS_WIN)
#include "DapServiceClientNativeWin.h"
typedef class DapServiceClientNativeWin DapServiceClientNative;
#endif #endif
typedef QLocalSocket DapUiSocket; typedef QLocalSocket DapUiSocket;
......
#include "DapServiceClientNativeWin.h"
DapServiceClientNativeWin::DapServiceClientNativeWin()
{
}
bool DapServiceClientNativeWin::isServiceRunning()
{
return true;
}
DapServiceError DapServiceClientNativeWin::serviceInstallAndRun() {
return DapServiceError::NO_ERRORS;
}
DapServiceError DapServiceClientNativeWin::serviceStart() {
return DapServiceError::NO_ERRORS;
}
DapServiceError DapServiceClientNativeWin::serviceRestart() {
return DapServiceError::NO_ERRORS;
}
DapServiceError DapServiceClientNativeWin::serviceStop() {
return DapServiceError::NO_ERRORS;
}
DapServiceClientNativeWin::~DapServiceClientNativeWin() {
}
#ifndef DAPSERVICECLIENTNATIVEWIN_H
#define DAPSERVICECLIENTNATIVEWIN_H
#include "DapServiceClientNativeAbstract.h"
class DapServiceClientNativeWin : public DapServiceClientNativeAbstract
{
public:
DapServiceClientNativeWin();
~DapServiceClientNativeWin() override;
bool isServiceRunning() override;
DapServiceError serviceStart() override;
DapServiceError serviceRestart() override;
DapServiceError serviceStop() override;
DapServiceError serviceInstallAndRun() override;
};
#endif // DAPSERVICECLIENTNATIVEWIN_H
...@@ -18,9 +18,11 @@ VER_PAT = 0 ...@@ -18,9 +18,11 @@ VER_PAT = 0
win32 { win32 {
VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT
DEFINES += CLI_PATH=\\\"./kelvin-node-cli.exe\\\"
} }
else { else {
VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT
DEFINES += CLI_PATH=\\\"/opt/kelvin-node/bin/kelvin-node-cli\\\"
} }
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
...@@ -53,6 +55,7 @@ SOURCES += \ ...@@ -53,6 +55,7 @@ SOURCES += \
DapCommandController.cpp \ DapCommandController.cpp \
DapServiceClientNativeAbstract.cpp \ DapServiceClientNativeAbstract.cpp \
DapServiceClientNativeLinux.cpp \ DapServiceClientNativeLinux.cpp \
DapServiceClientNativeWin.cpp \
DapChainWalletsModel.cpp DapChainWalletsModel.cpp
RESOURCES += qml.qrc RESOURCES += qml.qrc
...@@ -84,6 +87,7 @@ HEADERS += \ ...@@ -84,6 +87,7 @@ HEADERS += \
DapCommandController.h \ DapCommandController.h \
DapServiceClientNativeAbstract.h \ DapServiceClientNativeAbstract.h \
DapServiceClientNativeLinux.h \ DapServiceClientNativeLinux.h \
DapServiceClientNativeWin.h \
DapChainWalletsModel.h DapChainWalletsModel.h
include (../libdap/libdap.pri) include (../libdap/libdap.pri)
......
...@@ -26,7 +26,7 @@ QStringList DapChainLogHandler::request(int aiTimeStamp, int aiRowCount) ...@@ -26,7 +26,7 @@ QStringList DapChainLogHandler::request(int aiTimeStamp, int aiRowCount)
{ {
QByteArray result; QByteArray result;
QProcess process; QProcess process;
process.start(QString("%1 print_log ts_after %2 limit %3").arg("/opt/kelvin-node/bin/kelvin-node-cli").arg(aiTimeStamp).arg(aiRowCount)); process.start(QString("%1 print_log ts_after %2 limit %3").arg(CLI_PATH).arg(aiTimeStamp).arg(aiRowCount));
process.waitForFinished(-1); process.waitForFinished(-1);
result = process.readAll(); result = process.readAll();
......
...@@ -17,7 +17,7 @@ QStringList DapChainWalletHandler::createWallet(const QString &asNameWallet) ...@@ -17,7 +17,7 @@ QStringList DapChainWalletHandler::createWallet(const QString &asNameWallet)
{ {
QByteArray result; QByteArray result;
QProcess process; QProcess process;
process.start(QString("%1 wallet new -w %2").arg("/opt/kelvin-node/bin/kelvin-node-cli").arg(asNameWallet)); process.start(QString("%1 wallet new -w %2").arg(CLI_PATH).arg(asNameWallet));
process.waitForFinished(-1); process.waitForFinished(-1);
result = process.readAll(); result = process.readAll();
QStringList list; QStringList list;
...@@ -40,7 +40,7 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets() ...@@ -40,7 +40,7 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets()
{ {
QMap<QString, QVariant> map; QMap<QString, QVariant> map;
QProcess process; QProcess process;
process.start(QString("%1 wallet list").arg("/opt/kelvin-node/bin/kelvin-node-cli")); process.start(QString("%1 wallet list").arg(CLI_PATH));
process.waitForFinished(-1); process.waitForFinished(-1);
QString str = QString::fromLatin1(process.readAll()); QString str = QString::fromLatin1(process.readAll());
qDebug() << "ZDES`" << str; qDebug() << "ZDES`" << str;
...@@ -70,9 +70,40 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets() ...@@ -70,9 +70,40 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets()
QStringList DapChainWalletHandler::getWalletInfo(const QString &asNameWallet) QStringList DapChainWalletHandler::getWalletInfo(const QString &asNameWallet)
{ {
QProcess process; QProcess process;
process.start(QString("%1 wallet info -w %2 -net private").arg("/opt/kelvin-node/bin/kelvin-node-cli").arg(asNameWallet)); process.start(QString("%1 wallet info -w %2 -net kelvin-testnet").arg(CLI_PATH).arg(asNameWallet));
process.waitForFinished(-1); process.waitForFinished(-1);
char* response = process.readAll().data();
//qDebug() << response;
QStringList list; QStringList list;
#ifdef Q_OS_WIN32
char *context = nullptr;
char *data = nullptr;
data = strtok_r(response, ":", &context);
if (strcmp(data, "wallet") != 0) {
data = strtok_r(response, ":", &context);
}
data = strtok_r(context+1, "\r", &context);
list.append(QString(data));
data = strtok_r(context+1, ":", &context);
data = strtok_r(context+1, "\r", &context);
list.append(QString(data));
data = strtok_r(context+1, ":", &context);
list.append(QString(data));
data = strtok_r(context+4, "\r", &context);
char *subctx;
char *subdata;
if (strlen(data) > 2) {
subdata = strtok_r(data+1, " ", &subctx);
} else {
subdata = strtok_r(data, " ", &subctx);
}
list.append(QString(subdata));
subdata = strtok_r(subctx, " ", &subctx);
list.append(QString(subdata));
subdata = strtok_r(subctx, "\r", &subctx);
list.append(QString(subdata));
#else
QString str = QString::fromLatin1(process.readAll()).replace("\\", "\\\\"); QString str = QString::fromLatin1(process.readAll()).replace("\\", "\\\\");
QRegExp rx("[(:\\)\\t]{1,1}([^\\\\\\n\\t]+)[\\\\(|\\n|\\r]{1,1}"); QRegExp rx("[(:\\)\\t]{1,1}([^\\\\\\n\\t]+)[\\\\(|\\n|\\r]{1,1}");
...@@ -84,6 +115,7 @@ QStringList DapChainWalletHandler::getWalletInfo(const QString &asNameWallet) ...@@ -84,6 +115,7 @@ QStringList DapChainWalletHandler::getWalletInfo(const QString &asNameWallet)
list.append(rx.cap(1)); list.append(rx.cap(1));
pos += rx.matchedLength(); pos += rx.matchedLength();
} }
#endif
qDebug() << list; qDebug() << list;
return list; return list;
} }
...@@ -93,8 +125,8 @@ QString DapChainWalletHandler::sendToken(const QString &asSendWallet, const QStr ...@@ -93,8 +125,8 @@ QString DapChainWalletHandler::sendToken(const QString &asSendWallet, const QStr
QString answer; QString answer;
qInfo() << QString("sendTokenTest(%1, %2, %3, %4)").arg(asSendWallet).arg(asAddressReceiver).arg(asToken).arg(aAmount); qInfo() << QString("sendTokenTest(%1, %2, %3, %4)").arg(asSendWallet).arg(asAddressReceiver).arg(asToken).arg(aAmount);
QProcess processCreate; QProcess processCreate;
processCreate.start(QString("%1 tx_create -net private -chain gdb -from_wallet %2 -to_addr %3 -token %4 -value %5") processCreate.start(QString("%1 tx_create -net kelvin-testnet -chain gdb -from_wallet %2 -to_addr %3 -token %4 -value %5")
.arg("/opt/kelvin-node/bin/kelvin-node-cli") .arg(CLI_PATH)
.arg(asSendWallet) .arg(asSendWallet)
.arg(asAddressReceiver) .arg(asAddressReceiver)
.arg(asToken) .arg(asToken)
...@@ -105,7 +137,7 @@ QString DapChainWalletHandler::sendToken(const QString &asSendWallet, const QStr ...@@ -105,7 +137,7 @@ QString DapChainWalletHandler::sendToken(const QString &asSendWallet, const QStr
if(!(resultCreate.isEmpty() || resultCreate.isNull())) if(!(resultCreate.isEmpty() || resultCreate.isNull()))
{ {
QProcess processMempool; QProcess processMempool;
processMempool.start(QString("%1 mempool_proc -net private -chain gdb").arg("/opt/kelvin-node/bin/kelvin-node-cli")); processMempool.start(QString("%1 mempool_proc -net kelvin-testnet -chain gdb").arg(CLI_PATH));
processMempool.waitForFinished(-1); processMempool.waitForFinished(-1);
answer = QString::fromLatin1(processMempool.readAll()); answer = QString::fromLatin1(processMempool.readAll());
qDebug() << answer; qDebug() << answer;
......
...@@ -20,9 +20,11 @@ ICON = icon.ico ...@@ -20,9 +20,11 @@ ICON = icon.ico
win32 { win32 {
VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT
DEFINES += CLI_PATH=\\\"./kelvin-node-cli.exe\\\"
} }
else { else {
VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT
DEFINES += CLI_PATH=\\\"/opt/kelvin-node/bin/kelvin-node-cli\\\"
} }
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
......
...@@ -16,9 +16,9 @@ int main(int argc, char *argv[]) ...@@ -16,9 +16,9 @@ int main(int argc, char *argv[])
{ {
// Creating a semaphore for locking external resources, as well as initializing an external resource-memory // Creating a semaphore for locking external resources, as well as initializing an external resource-memory
QSystemSemaphore systemSemaphore(QString("systemSemaphore for %1").arg("KelvinDashboardService"), 1); QSystemSemaphore systemSemaphore(QString("systemSemaphore for %1").arg("KelvinDashboardService"), 1);
#ifndef Q_OS_WIN
QSharedMemory memmoryAppBagFix(QString("memmory for %1").arg("KelvinDashboardService")); QSharedMemory memmoryAppBagFix(QString("memmory for %1").arg("KelvinDashboardService"));
#endif
QSharedMemory memmoryApp(QString("memmory for %1").arg("KelvinDashboardService")); QSharedMemory memmoryApp(QString("memmory for %1").arg("KelvinDashboardService"));
// Check for the existence of a running instance of the program // Check for the existence of a running instance of the program
bool isRunning = DapHalper::getInstance().checkExistenceRunningInstanceApp(systemSemaphore, memmoryApp, memmoryAppBagFix); bool isRunning = DapHalper::getInstance().checkExistenceRunningInstanceApp(systemSemaphore, memmoryApp, memmoryAppBagFix);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment