Newer
Older
#ifndef DAPSERVICECONTROLLER_H
#define DAPSERVICECONTROLLER_H
#include <QObject>
#include <QQmlEngine>
#include <QJSEngine>
#include <QApplication>
#include <QTimer>
littletux89
committed
#include <QMap>
#include <QPair>
#include "DapCommandController.h"
#include "DapServiceClient.h"
littletux89@gmail.com
committed
#include "DapChainWalletsModel.h"
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class DapServiceController : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(DapServiceController)
/// Brand сompany.
QString m_sBrand {DAP_BRAND};
/// Application version.
QString m_sVersion {DAP_VERSION};
/// Service connection management service.
DapServiceClient *m_pDapServiceClient {nullptr};
/// RPC protocol controller.
DapCommandController *m_pDapCommandController {nullptr};
explicit DapServiceController(QObject *apParent = nullptr);
public:
/// Get an instance of a class.
/// @return Instance of a class.
Q_INVOKABLE static DapServiceController &getInstance();
///********************************************
/// Property
/// *******************************************
/// Brand сompany.
Q_PROPERTY(QString Brand MEMBER m_sBrand READ getBrand NOTIFY brandChanged)
/// Application version.
Q_PROPERTY(QString Version MEMBER m_sVersion READ getVersion NOTIFY versionChanged)
///********************************************
/// Interface
/// *******************************************
void init(DapServiceClient *apDapServiceClient);
/// Get company brand.
/// @return Brand сompany.
QString getBrand() const;
/// Get app version.
/// @return Application version.
QString getVersion() const;
littletux89@gmail.com
committed
/// Get node logs.
/// @param aiTimeStamp Timestamp start reading logging.
/// @param aiRowCount Number of lines displayed.
void getNodeLogs(int aiTimeStamp, int aiRowCount) const;
littletux89
committed
Q_INVOKABLE void getWallets() const;
DapLogModel getLogModel() const;
void setLogModel(const DapLogModel &dapLogModel);
littletux89
committed
Q_INVOKABLE void addWallet(const QString& asWalletName);
Q_INVOKABLE void removeWallet(int index, const QString& asWalletName);
Q_INVOKABLE void sendToken(const QString &asSendWallet, const QString& asAddressReceiver, const QString& asToken, const QString& aAmount);
void getWalletInfo(const QString& asWalletName);
signals:
/// The signal is emitted when the Brand company property changes.
void brandChanged(const QString &brand);
/// The signal is emitted when the Application version property changes.
void versionChanged(const QString &version);
/// The signal is emitted when the main application window is activated.
void activateWindow();
/// The signal is emitted when checking the existence of an already running copy of the application.
void isExistenceClient(bool isExistenceClient);
littletux89@gmail.com
committed
private slots:
/// Handling service response for receiving node logs.
/// @param aNodeLogs List of node logs.
void processGetNodeLogs(const QStringList& aNodeLogs);
littletux89@gmail.com
committed
void processAddWallet(const QString& asWalletName, const QString& asWalletAddress);
littletux89
committed
littletux89@gmail.com
committed
void processSendToken(const QString& asAnswer);
littletux89
committed
void processGetWallets(const QMap<QString, QVariant>& aWallets);
littletux89@gmail.com
committed
void processGetWalletInfo(const QString& asWalletName, const QString& asWalletAddress, const QStringList &aBalance, const QStringList& aTokens);
public slots:
/// Show or hide GUI client by clicking on the tray icon.
/// @param aIsActivated Accepts true - when requesting to
/// display a client, falso - when requesting to hide a client.
void activateClient(bool aIsActivated);
/// Shut down client.
void closeClient();
/// Method that implements the singleton pattern for the qml layer.
/// @param engine QML application.
/// @param scriptEngine The QJSEngine class provides an environment for evaluating JavaScript code.
static QObject *singletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine);
};
#endif // DAPSERVICECONTROLLER_H