diff --git a/.gitignore b/.gitignore index cfb0b8c5c0afe114827c357c07675d9c148113c4..a6662736bf3c7e3b6afc76ab3db11ffd158596f2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ CTestTestfile.cmake *.o *.obj moc_* +.DS_Store diff --git a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro index df6428da40ec3ce56eec9ab3e7164f466f99e019..7c2c1bf0a9fe6fc988e52d41c649ea14d7956ef9 100755 --- a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro +++ b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro @@ -34,7 +34,13 @@ DEFINES += DAP_BRAND=\\\"$$BRAND\\\" DEFINES += DAP_SERVICE_NAME=\\\"CellFrameDashboardService\\\" DEFINES += DAP_VERSION=\\\"$$VERSION\\\" DEFINES += DAP_SETTINGS_FILE=\\\"settings.json\\\" -ICON = icon.ico +macx { +ICON = Resources/Icons/dashboard.icns +} +else { +ICON = Resources/Icons/icon.ico +} + # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. @@ -66,6 +72,7 @@ SOURCES += \ DapServiceClientNativeAbstract.cpp \ DapServiceClientNativeLinux.cpp \ DapServiceClientNativeWin.cpp \ + DapServiceClientNativeMacOS.cpp \ DapChainWalletsModel.cpp RESOURCES += qml.qrc @@ -111,6 +118,7 @@ HEADERS += \ include (../libdap/libdap.pri) include (../libdap-crypto/libdap-crypto.pri) include (../libdap-qt/libdap-qt.pri) +include (../libdap-qt-ui-qml/libdap-qt-ui-qml.pri) include (../libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri) include (../DapRPCProtocol/DapRPCProtocol.pri) diff --git a/CellFrameDashboardGUI/DapServiceClient.h b/CellFrameDashboardGUI/DapServiceClient.h index 3e21f0c3b3bd6c13000ca8996113a71ef14bbb8f..b1f9a32441170b6f5e21977374101387e5a28db5 100644 --- a/CellFrameDashboardGUI/DapServiceClient.h +++ b/CellFrameDashboardGUI/DapServiceClient.h @@ -13,6 +13,9 @@ typedef class DapServiceClientNativeLinux DapServiceClientNative; #elif defined(Q_OS_WIN) #include "DapServiceClientNativeWin.h" typedef class DapServiceClientNativeWin DapServiceClientNative; +#elif defined(Q_OS_MAC) +#include "DapServiceClientNativeMacOS.h" +typedef class DapServiceClientNativeMacOS DapServiceClientNative; #endif typedef QLocalSocket DapUiSocket; diff --git a/CellFrameDashboardGUI/DapServiceClientNativeMacOS.cpp b/CellFrameDashboardGUI/DapServiceClientNativeMacOS.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d58f43a5a0821d45d65a79ae1979bf04a1deaf66 --- /dev/null +++ b/CellFrameDashboardGUI/DapServiceClientNativeMacOS.cpp @@ -0,0 +1,75 @@ +#include "DapServiceClientNativeMacOS.h" + +#include <QtDebug> +#include <QMessageBox> + +DapServiceClientNativeMacOS::DapServiceClientNativeMacOS() +{ + QString dapServiceNameToLower = QString(DAP_SERVICE_NAME).toLower(); + QString cmd = QString("ps -C %1 > /dev/null").arg(DAP_SERVICE_NAME); + m_checkIsServiceRunningCommand = strdup(cmd.toLatin1().data()); + + m_cmdTemplate = QString("service " + dapServiceNameToLower) + " %1"; + + qDebug() << "command for check is service running: " << m_checkIsServiceRunningCommand; +} + +DapServiceClientNativeMacOS::~DapServiceClientNativeMacOS() +{ + delete m_checkIsServiceRunningCommand; +} + +bool DapServiceClientNativeMacOS::isServiceRunning() +{ + m_isServiceRunning =true;// (::system(m_checkIsServiceRunningCommand) == 0); + return m_isServiceRunning; +} + +DapServiceError DapServiceClientNativeMacOS::serviceRestart() +{ + qDebug() << "Restart service name" << m_cmdTemplate.arg("restart").toLatin1().data(); + + int retCode = ::system(m_cmdTemplate.arg("restart").toLatin1().data()); + qDebug() << "Restart result code:" << retCode; + if(retCode != 0) { + return DapServiceError::USER_COMMAND_ABORT; + } + + return DapServiceError::NO_ERRORS; +} + +/** + * @brief SapNetworkClientNativeMacOS::serviceStart + */ +DapServiceError DapServiceClientNativeMacOS::serviceStart() +{ + // yes better use restart + int ret = ::system(m_cmdTemplate.arg("restart").toLatin1().data()); + qDebug() << "serviceStart Result: " << ret; + + if(ret != 0) { + return DapServiceError::USER_COMMAND_ABORT; + } + + return DapServiceError::NO_ERRORS; +} + +/** + * @brief SapServiceClientNativeMacOS::serviceStop + */ +DapServiceError DapServiceClientNativeMacOS::serviceStop() +{ + int ret = ::system(m_cmdTemplate.arg("stop").toLatin1().data()); + qDebug() << "serviceStop result:" << ret; + if(ret != 0) { + return DapServiceError::USER_COMMAND_ABORT; + } + return DapServiceError::NO_ERRORS; +} +/** + * @brief SapServiceClientNativeMacOS::serviceInstallAndRun + */ +DapServiceError DapServiceClientNativeMacOS::serviceInstallAndRun() +{ + return serviceStart(); +} diff --git a/CellFrameDashboardGUI/DapServiceClientNativeMacOS.h b/CellFrameDashboardGUI/DapServiceClientNativeMacOS.h new file mode 100644 index 0000000000000000000000000000000000000000..6d9f31dcc82915d23377696c3dbbcf4bc14a758e --- /dev/null +++ b/CellFrameDashboardGUI/DapServiceClientNativeMacOS.h @@ -0,0 +1,21 @@ +#ifndef DAPSERVICECLIENTNATIVEMACOS_H +#define DAPSERVICECLIENTNATIVEMACOS_H + +#include "DapServiceClientNativeAbstract.h" + +class DapServiceClientNativeMacOS : public DapServiceClientNativeAbstract +{ + const char* m_checkIsServiceRunningCommand; + QString m_cmdTemplate; +public: + DapServiceClientNativeMacOS(); + ~DapServiceClientNativeMacOS() override; + bool isServiceRunning() override; + DapServiceError serviceStart() override; + DapServiceError serviceRestart() override; + + DapServiceError serviceStop() override; + DapServiceError serviceInstallAndRun() override; +}; + +#endif // DAPSERVICECLIENTNATIVEMACOS_H diff --git a/CellFrameDashboardGUI/Resources/Icons/dashboard.icns b/CellFrameDashboardGUI/Resources/Icons/dashboard.icns new file mode 100644 index 0000000000000000000000000000000000000000..265114500a6b03a98de52cadde5bebfba184e660 Binary files /dev/null and b/CellFrameDashboardGUI/Resources/Icons/dashboard.icns differ diff --git a/CellFrameDashboardGUI/Resources/Icons/icon.ico b/CellFrameDashboardGUI/Resources/Icons/icon.ico index 41230db92cb8101b8f24cf6f861082c6dfb827e1..f5d98ff6020a1a5fa6922262be41cf6a245effb5 100644 Binary files a/CellFrameDashboardGUI/Resources/Icons/icon.ico and b/CellFrameDashboardGUI/Resources/Icons/icon.ico differ diff --git a/CellFrameDashboardGUI/Resources/Icons/icon.png b/CellFrameDashboardGUI/Resources/Icons/icon.png index 52525ef9e99b9d42242dcddc0f5f5a25eaeee901..f5d98ff6020a1a5fa6922262be41cf6a245effb5 100644 Binary files a/CellFrameDashboardGUI/Resources/Icons/icon.png and b/CellFrameDashboardGUI/Resources/Icons/icon.png differ diff --git a/CellFrameDashboardGUI/main.cpp b/CellFrameDashboardGUI/main.cpp index b6e10bb71ede8e7088f6a340cc8f1ee636bb0934..00ce401b807641e3bcae56344e1acd9b79916fc7 100755 --- a/CellFrameDashboardGUI/main.cpp +++ b/CellFrameDashboardGUI/main.cpp @@ -33,6 +33,8 @@ #include <QRegExp> +#include <sys/stat.h> + int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -46,12 +48,13 @@ int main(int argc, char *argv[]) DapLogger dapLogger; /// TODO: The code is commented out at the time of developing the logging strategy in the project //#ifndef QT_DEBUG -#ifdef Q_OS_LINUX - dapLogger.setLogFile(QString("/opt/cellframe-dashboard/log/%1Gui.log").arg(DAP_BRAND)); -#elif defined Q_OS_WIN - dapLogger.setLogFile(QString("%1Gui.log").arg(DAP_BRAND)); - dapLogger.setLogLevel(L_DEBUG); -#endif + #ifdef Q_OS_LINUX + dapLogger.setLogFile(QString("/opt/cellframe-dashboard/log/%1Gui.log").arg(DAP_BRAND)); + #elif defined Q_OS_MACOS + mkdir("/tmp/cellframe-dashboard_log",0777); + dapLogger.setLogFile(QString("/tmp/cellframe-dashboard_log/%1Gui.log").arg(DAP_BRAND)); + #elif defined Q_OS_WIN + #endif //#endif /// Local client. diff --git a/CellFrameDashboardService/CellFrameDashboardService.pro b/CellFrameDashboardService/CellFrameDashboardService.pro index a836654430b3b3c9adc7eff1a7624d0c64afb34f..9832f5ebd69cdde397ddf8f0bca22289b0838c93 100755 --- a/CellFrameDashboardService/CellFrameDashboardService.pro +++ b/CellFrameDashboardService/CellFrameDashboardService.pro @@ -69,6 +69,8 @@ HEADERS += \ include (../libdap/libdap.pri) include (../libdap-crypto/libdap-crypto.pri) include (../libdap-qt/libdap-qt.pri) +include (../libdap-qt-ui-qml/libdap-qt-ui-qml.pri) + include (../libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri) include (../DapRPCProtocol/DapRPCProtocol.pri) diff --git a/CellFrameDashboardService/main.cpp b/CellFrameDashboardService/main.cpp index 12226354205c71ba36e0bdf3e66b0f50cffb10f6..057ae38933aaad6c0c7cd8b0f5e96088e6d25d5d 100755 --- a/CellFrameDashboardService/main.cpp +++ b/CellFrameDashboardService/main.cpp @@ -11,6 +11,8 @@ #include "DapChainLogHandler.h" #include "DapSettings.h" +#include <sys/stat.h> + void processArgs(); int main(int argc, char *argv[]) @@ -42,6 +44,9 @@ int main(int argc, char *argv[]) #elif defined Q_OS_WIN dapLogger.setLogFile(QString("%1Service.log").arg(DAP_BRAND)); dapLogger.setLogLevel(L_INFO); + #elif defined Q_OS_MAC + mkdir("tmp/cellframe-dashboard_log",0777); + dapLogger.setLogFile(QString("/tmp/cellframe-dashboard_log/%1Service.log").arg(DAP_BRAND)); #endif //#endif // Creating the main application object @@ -58,7 +63,7 @@ int main(int argc, char *argv[]) void processArgs() { -#ifdef Q_OS_LINUX +#if defined(Q_OS_LINUX) || defined(Q_OS_MAC) QCommandLineParser clParser; clParser.parse(QCoreApplication::arguments()); auto options = clParser.unknownOptionNames();