diff --git a/qt-openzwave/include/qt-openzwave/qtopenzwave.h b/qt-openzwave/include/qt-openzwave/qtopenzwave.h index 9bcea66..2e84c78 100644 --- a/qt-openzwave/include/qt-openzwave/qtopenzwave.h +++ b/qt-openzwave/include/qt-openzwave/qtopenzwave.h @@ -10,7 +10,7 @@ class QTOPENZWAVESHARED_EXPORT QTOpenZwave : public QObject { Q_OBJECT public: - QTOpenZwave(QObject *parent = nullptr); + QTOpenZwave(QObject *parent = nullptr, QDir DBPath = QDir("./config/"), QDir UserPath = QDir("./config/")); QTOZWManager *GetManager(); private Q_SLOT: @@ -18,6 +18,8 @@ private Q_SLOT: private: QTOZWManager *m_manager; + QDir m_ozwdbpath; + QDir m_ozwuserpath; }; #endif // QTOPENZWAVE_H diff --git a/qt-openzwave/include/qt-openzwave/qtozwmanager.h b/qt-openzwave/include/qt-openzwave/qtozwmanager.h index 832afcc..2552625 100644 --- a/qt-openzwave/include/qt-openzwave/qtozwmanager.h +++ b/qt-openzwave/include/qt-openzwave/qtozwmanager.h @@ -16,6 +16,7 @@ enum QTOZW_UserRoles { class QTOZWManager_Internal; class QTOZWManagerReplica; +class QTOZWOptionsReplica; class QTOZWManager : public QObject { Q_OBJECT @@ -26,6 +27,9 @@ public: Invalid }; Q_ENUM(connectionType) + Q_PROPERTY(QDir OZWDatabasePath READ OZWDatabasePath WRITE setOZWDatabasePath) + Q_PROPERTY(QDir OZWUserPath READ OZWUserPath WRITE setOZWUserPath) + QTOZWManager(QObject *parent = nullptr); bool initilizeBase(); @@ -79,6 +83,12 @@ public: bool downloadLatestConfigFileRevision(quint8 const _node); bool downloadLatestMFSRevision(); +/* Property Methods */ + QDir OZWDatabasePath() { return this->m_ozwdatabasepath; } + QDir OZWUserPath() { return this->m_ozwuserpath; } + void setOZWDatabasePath(QDir path); + void setOZWUserPath(QDir path); + Q_SIGNALS: void ready(); @@ -117,6 +127,8 @@ private Q_SLOTS: void onReplicaError(QRemoteObjectNode::ErrorCode); void onSourceError(QRemoteObjectHost::ErrorCode); void onManagerStateChange(QRemoteObjectReplica::State); + void onOptionsStateChange(QRemoteObjectReplica::State); + void onNodeInitialized(); void onValueInitialized(); void onAssociationInitialized(); @@ -131,7 +143,9 @@ private: QRemoteObjectHost *m_sourceNode; QTOZWManager_Internal *d_ptr_internal; QTOZWManagerReplica *d_ptr_replica; + QTOZWOptionsReplica *d_options_replica; QRemoteObjectReplica::State m_managerState; + QRemoteObjectReplica::State m_optionsState; bool m_nodeState; bool m_valuesState; bool m_associationsState; @@ -141,6 +155,8 @@ private: QAbstractItemModel *m_associationModel; bool m_running; + QDir m_ozwdatabasepath; + QDir m_ozwuserpath; }; diff --git a/qt-openzwave/include/qt-openzwave/qtozwmanager.rep b/qt-openzwave/include/qt-openzwave/qtozwmanager.rep index ad94c6b..3c9fd1f 100644 --- a/qt-openzwave/include/qt-openzwave/qtozwmanager.rep +++ b/qt-openzwave/include/qt-openzwave/qtozwmanager.rep @@ -3,7 +3,7 @@ #include "qt-openzwave/qtozw_pods.h" class QTOZWManager { - ENUM QTOZWErrorCodes { + ENUM QTOZWManagerErrorCodes { homeId_Invalid, nodeId_Invalid, valueIDKey_Invalid, @@ -62,7 +62,7 @@ class QTOZWManager { SIGNAL(starting()); SIGNAL(started(quint32 homeID)) SIGNAL(stopped(quint32 homeID)) - SIGNAL(error(QTOZWErrorCodes errorcode)) + SIGNAL(error(QTOZWManagerErrorCodes errorcode)) SLOT(bool open(QString serialPort)) SLOT(bool refreshNodeInfo(quint8 _node)) diff --git a/qt-openzwave/include/qt-openzwave/qtozwoptions.h b/qt-openzwave/include/qt-openzwave/qtozwoptions.h new file mode 100644 index 0000000..0a57066 --- /dev/null +++ b/qt-openzwave/include/qt-openzwave/qtozwoptions.h @@ -0,0 +1,191 @@ +#ifndef QTOZWOPTIONS_H +#define QTOZWOPTIONS_H + +#include +#include + + +class QTOZWOptions_Internal; +class QTOZWOptionsReplica; + + +class QTOZWOptions : public QObject { + Q_OBJECT + +public: + enum connectionType { + Local, + Remote, + Invalid + }; + Q_ENUM(connectionType) + + QTOZWOptions(QObject *parent = nullptr); + + Q_PROPERTY(QString ConfigPath READ ConfigPath WRITE setConfigPath NOTIFY ConfigPathChanged) + Q_PROPERTY(QString UserPath READ UserPath WRITE setUserPath NOTIFY UserPathChanged) + Q_PROPERTY(bool Logging READ Logging WRITE setLogging NOTIFY LoggingChanged) + Q_PROPERTY(QString LogFileName READ LogFileName WRITE setLogFileName NOTIFY LogFileNameChanged) + Q_PROPERTY(bool AppendLogFile READ AppendLogFile WRITE setAppendLogFile NOTIFY AppendLogFileChanged) + Q_PROPERTY(bool ConsoleOutput READ ConsoleOutput WRITE setConsoleOutput NOTIFY ConsoleOutputChanged) + Q_PROPERTY(qint32 SaveLogLevel READ SaveLogLevel WRITE setSaveLogLevel NOTIFY SaveLogLevelChanged) + Q_PROPERTY(qint32 QueueLogLevel READ QueueLogLevel WRITE setQueueLogLevel NOTIFY QueueLogLevelChanged) + Q_PROPERTY(qint32 DumpTriggerLevel READ DumpTriggerLevel WRITE setDumpTriggerLevel NOTIFY DumpTriggerLevelChanged) + Q_PROPERTY(bool Associate READ Associate WRITE setAssociate NOTIFY AssociateChanged) + Q_PROPERTY(QString Exclude READ Exclude WRITE setExclude NOTIFY ExcludeChanged) + Q_PROPERTY(QString Include READ Include WRITE setInclude NOTIFY IncludeChanged) + Q_PROPERTY(bool NotifyTransactions READ NotifyTransactions WRITE setNotifyTransactions NOTIFY NotifyTransactionsChanged) + Q_PROPERTY(QString Interface READ Interface WRITE setInterface NOTIFY InterfaceChanged) + Q_PROPERTY(bool SaveConfiguration READ SaveConfiguration WRITE setSaveConfiguration NOTIFY SaveConfigurationChanged) + Q_PROPERTY(qint32 DriverMaxAttempts READ DriverMaxAttempts WRITE setDriverMaxAttempts NOTIFY DriverMaxAttemptsChanged) + Q_PROPERTY(qint32 PollInterval READ PollInterval WRITE setPollInterval NOTIFY PollIntervalChanged) + Q_PROPERTY(bool IntervalBetweenPolls READ IntervalBetweenPolls WRITE setIntervalBetweenPolls NOTIFY IntervalBetweenPollsChanged) + Q_PROPERTY(bool SuppressValueRefresh READ SuppressValueRefresh WRITE setSuppressValueRefresh NOTIFY SuppressValueRefreshChanged) + Q_PROPERTY(bool PerformReturnRoutes READ PerformReturnRoutes WRITE setPerformReturnRoutes NOTIFY PerformReturnRoutesChanged) + Q_PROPERTY(QString NetworkKey READ NetworkKey WRITE setNetworkKey NOTIFY NetworkKeyChanged) + Q_PROPERTY(bool RefreshAllUserCodes READ RefreshAllUserCodes WRITE setRefreshAllUserCodes NOTIFY RefreshAllUserCodesChanged) + Q_PROPERTY(qint32 RetryTimeout READ RetryTimeout WRITE setRetryTimeout NOTIFY RetryTimeoutChanged) + Q_PROPERTY(bool EnableSIS READ EnableSIS WRITE setEnableSIS NOTIFY EnableSISChanged) + Q_PROPERTY(bool AssumeAwake READ AssumeAwake WRITE setAssumeAwake NOTIFY AssumeAwakeChanged) + Q_PROPERTY(bool NotifyOnDriverUnload READ NotifyOnDriverUnload WRITE setNotifyOnDriverUnload NOTIFY NotifyOnDriverUnloadChanged) + Q_PROPERTY(QString SecurityStrategy READ SecurityStrategy WRITE setSecurityStrategy NOTIFY SecurityStrategyChanged) + Q_PROPERTY(QString CustomSecuredCC READ CustomSecuredCC WRITE setCustomSecuredCC NOTIFY CustomSecuredCCChanged) + Q_PROPERTY(bool EnforceSecureReception READ EnforceSecureReception WRITE setEnforceSecureReception NOTIFY EnforceSecureReceptionChanged) + Q_PROPERTY(bool AutoUpdateConfigFile READ AutoUpdateConfigFile WRITE setAutoUpdateConfigFile NOTIFY AutoUpdateConfigFileChanged) + Q_PROPERTY(QString ReloadAfterUpdate READ ReloadAfterUpdate WRITE setReloadAfterUpdate NOTIFY ReloadAfterUpdateChanged) + Q_PROPERTY(QString Language READ Language WRITE setLanguage NOTIFY LanguageChanged) + Q_PROPERTY(bool IncludeInstanceLabels READ IncludeInstanceLabels WRITE setIncludeInstanceLabels NOTIFY IncludeInstanceLabelsChanged) + + QString ConfigPath() const; + QString UserPath() const; + bool Logging() const; + QString LogFileName() const; + bool AppendLogFile() const; + bool ConsoleOutput() const; + qint32 SaveLogLevel() const; + qint32 QueueLogLevel() const; + qint32 DumpTriggerLevel() const; + bool Associate() const; + QString Exclude() const; + QString Include() const; + bool NotifyTransactions() const; + QString Interface() const; + bool SaveConfiguration() const; + qint32 DriverMaxAttempts() const; + qint32 PollInterval() const; + bool SuppressValueRefresh() const; + bool IntervalBetweenPolls() const; + bool PerformReturnRoutes() const ; + QString NetworkKey() const; + bool RefreshAllUserCodes() const; + qint32 RetryTimeout() const; + bool EnableSIS() const; + bool AssumeAwake() const; + bool NotifyOnDriverUnload() const; + QString SecurityStrategy() const; + QString CustomSecuredCC() const; + bool EnforceSecureReception() const; + bool AutoUpdateConfigFile() const; + QString ReloadAfterUpdate() const; + QString Language() const; + bool IncludeInstanceLabels() const; + + void setConfigPath(QString ConfigPath); + void setUserPath(QString UserPath); + void setLogging(bool Logging); + void setLogFileName(QString LogFileName); + void setAppendLogFile(bool AppendLogFile); + void setConsoleOutput(bool ConsoleOutput); + void setSaveLogLevel(qint32 SaveLogLevel); + void setQueueLogLevel(qint32 QueueLogLevel); + void setDumpTriggerLevel(qint32 DumpTriggerLevel); + void setAssociate(bool Associate); + void setExclude(QString Exclude); + void setInclude(QString Include); + void setNotifyTransactions(bool NotifyTransactions); + void setInterface(QString Interface); + void setSaveConfiguration(bool SaveConfiguration); + void setDriverMaxAttempts(qint32 DriverMaxAttempts); + void setPollInterval(qint32 PollInterval); + void setIntervalBetweenPolls(bool IntervalBetweenPolls); + void setSuppressValueRefresh(bool SuppressValueRefresh); + void setPerformReturnRoutes(bool PerformReturnRoutes); + void setNetworkKey(QString NetworkKey); + void setRefreshAllUserCodes(bool RefreshAllUserCodes); + void setRetryTimeout(qint32 RetryTimeout); + void setEnableSIS(bool EnableSIS); + void setAssumeAwake(bool AssumeAwake); + void setNotifyOnDriverUnload(bool NotifyOnDriverUnload); + void setSecurityStrategy(QString SecurityStrategy); + void setCustomSecuredCC(QString CustomSecuredCC); + void setEnforceSecureReception(bool EnforceSecureReception); + void setAutoUpdateConfigFile(bool AutoUpdateConfigFile); + void setReloadAfterUpdate(QString ReloadAfterUpdate); + void setLanguage(QString Language); + void setIncludeInstanceLabels(bool IncludeInstanceLabels); + + bool initilizeBase(); + bool initilizeSource(QRemoteObjectHost *m_sourceNode); + bool initilizeReplica(QRemoteObjectNode *m_replicaNode); + + bool AddOptionBool(QString option, bool value); + bool AddOptionInt(QString option, qint32 value); + bool AddOptionString(QString option, QString value); + bool GetOptionAsBool(QString option); + qint32 GetOptionAsInt(QString option); + QString GetOptionAsString(QString option); + + + +Q_SIGNALS: + void ConfigPathChanged(QString ConfigPath); + void UserPathChanged(QString UserPath); + void LoggingChanged(bool Logging); + void LogFileNameChanged(QString LogFileName); + void AppendLogFileChanged(bool AppendLogFile); + void ConsoleOutputChanged(bool ConsoleOutput); + void SaveLogLevelChanged(qint32 SaveLogLevel); + void QueueLogLevelChanged(qint32 QueueLogLevel); + void DumpTriggerLevelChanged(qint32 DumpTriggerLevel); + void AssociateChanged(bool Associate); + void ExcludeChanged(QString Exclude); + void IncludeChanged(QString Include); + void NotifyTransactionsChanged(bool NotifyTransactions); + void InterfaceChanged(QString Interface); + void SaveConfigurationChanged(bool SaveConfiguration); + void DriverMaxAttemptsChanged(qint32 DriverMaxAttempts); + void PollIntervalChanged(qint32 PollInterval); + void IntervalBetweenPollsChanged(bool IntervalBetweenPolls); + void SuppressValueRefreshChanged(bool SuppressValueRefresh); + void PerformReturnRoutesChanged(bool PerformReturnRoutes); + void NetworkKeyChanged(QString NetworkKey); + void RefreshAllUserCodesChanged(bool RefreshAllUserCodes); + void RetryTimeoutChanged(qint32 RetryTimeout); + void EnableSISChanged(bool EnableSIS); + void AssumeAwakeChanged(bool AssumeAwake); + void NotifyOnDriverUnloadChanged(bool NotifyOnDriverUnload); + void SecurityStrategyChanged(QString SecurityStrategy); + void CustomSecuredCCChanged(QString CustomSecuredCC); + void EnforceSecureReceptionChanged(bool EnforceSecureReception); + void AutoUpdateConfigFileChanged(bool AutoUpdateConfigFile); + void ReloadAfterUpdateChanged(QString ReloadAfterUpdate); + void LanguageChanged(QString Language); + void IncludeInstanceLabelsChanged(bool IncludeInstanceLabels); + //void error(QTOZWOptionsReplica::QTOZWOptionsErrorCodes errorcode); + +private Q_SLOTS: + void onOptionStateChange(QRemoteObjectReplica::State); + +private: + void connectSignals(); + + + QTOZWOptions_Internal *d_ptr_internal; + QTOZWOptionsReplica *d_ptr_replica; + connectionType m_connectionType; + QRemoteObjectReplica::State m_optionState; +}; + + + +#endif // QTOZWOPTIONS_H diff --git a/qt-openzwave/include/qt-openzwave/qtozwoptions.rep b/qt-openzwave/include/qt-openzwave/qtozwoptions.rep new file mode 100644 index 0000000..71d356a --- /dev/null +++ b/qt-openzwave/include/qt-openzwave/qtozwoptions.rep @@ -0,0 +1,54 @@ +#include +#include +#include "qt-openzwave/qtozw_pods.h" + +class QTOZWOptions { + ENUM QTOZWOptionsErrorCodes { + InvalidOption, + NoOptionClass, + NoError + }; + + PROP(QString ConfigPath READWRITE) + PROP(QString UserPath READWRITE) + PROP(bool Logging READWRITE) + PROP(QString LogFileName READWRITE) + PROP(bool AppendLogFile READWRITE) + PROP(bool ConsoleOutput READWRITE) + PROP(qint32 SaveLogLevel READWRITE) + PROP(qint32 QueueLogLevel READWRITE) + PROP(qint32 DumpTriggerLevel READWRITE) + PROP(bool Associate READWRITE) + PROP(QString Exclude READWRITE) + PROP(QString Include READWRITE) + PROP(bool NotifyTransactions READWRITE) + PROP(QString Interface READWRITE) + PROP(bool SaveConfiguration READWRITE) + PROP(qint32 DriverMaxAttempts READWRITE) + PROP(qint32 PollInterval READWRITE) + PROP(bool IntervalBetweenPolls READWRITE) + PROP(bool SuppressValueRefresh READWRITE) + PROP(bool PerformReturnRoutes READWRITE) + PROP(QString NetworkKey READWRITE) + PROP(bool RefreshAllUserCodes READWRITE) + PROP(qint32 RetryTimeout READWRITE) + PROP(bool EnableSIS READWRITE) + PROP(bool AssumeAwake READWRITE) + PROP(bool NotifyOnDriverUnload READWRITE) + PROP(QString SecurityStrategy READWRITE) + PROP(QString CustomSecuredCC READWRITE) + PROP(bool EnforceSecureReception READWRITE) + PROP(bool AutoUpdateConfigFile READWRITE) + PROP(QString ReloadAfterUpdate READWRITE) + PROP(QString Language READWRITE) + PROP(bool IncludeInstanceLabels READWRITE) + + SIGNAL(error(QTOZWOptionsErrorCodes errorcode)) + + SLOT(bool AddOptionBool(QString option, bool value)) + SLOT(bool AddOptionInt(QString option, qint32 value)) + SLOT(bool AddOptionString(QString option, QString value)) + SLOT(bool GetOptionAsBool(QString option)) + SLOT(qint32 GetOptionAsInt(QString option)) + SLOT(QString GetOptionAsString(QString option)) +} diff --git a/qt-openzwave/include/qtozwmanager_p.h b/qt-openzwave/include/qtozwmanager_p.h index 5d86b8a..c781591 100644 --- a/qt-openzwave/include/qtozwmanager_p.h +++ b/qt-openzwave/include/qtozwmanager_p.h @@ -8,13 +8,13 @@ #include "rep_qtozwmanager_replica.h" #include "qtozwnotification.h" #include "qt-openzwave/qtozwmanager.h" +#include "qtozwoptions_p.h" #include "qtozwnodemodel_p.h" #include "qtozwvalueidmodel_p.h" #include "qtozwassociationmodel_p.h" /* OZW Includes */ #include "Manager.h" -#include "Options.h" #include "Notification.h" #include "platform/Log.h" #include "OZWException.h" @@ -30,6 +30,7 @@ public: QTOZW_Nodes *getNodeModel(); QTOZW_ValueIds *getValueModel(); QTOZW_Associations *getAssociationModel(); + QTOZWOptions_Internal *getOptions(); public Q_SLOTS: bool open(QString serialPort); @@ -114,7 +115,7 @@ private: bool convertValueID(quint64 vidKey); - OpenZWave::Options *m_options; + QTOZWOptions_Internal *m_options; OpenZWave::Manager *m_manager; QTOZW_Nodes_internal *m_nodeModel; QTOZW_ValueIds_internal *m_valueModel; diff --git a/qt-openzwave/include/qtozwoptions_p.h b/qt-openzwave/include/qtozwoptions_p.h new file mode 100644 index 0000000..2626762 --- /dev/null +++ b/qt-openzwave/include/qtozwoptions_p.h @@ -0,0 +1,67 @@ +#ifndef QTOZWOPTIONS_P_H +#define QTOZWOPTIONS_P_H + +#include +#include +#include +#include "qtozw_logging.h" +#include "rep_qtozwoptions_source.h" +#include "rep_qtozwoptions_replica.h" + + +class QTOZWOptions_Internal : public QTOZWOptionsSimpleSource +{ + Q_OBJECT +public: + QTOZWOptions_Internal(QObject *parent = nullptr); + +public Q_SLOTS: + bool AddOptionBool(QString option, bool value); + bool AddOptionInt(QString option, qint32 value); + bool AddOptionString(QString option, QString value); + bool GetOptionAsBool(QString option); + qint32 GetOptionAsInt(QString option); + QString GetOptionAsString(QString option); + +private Q_SLOTS: + void pvt_ConfigPathChanged(QString value); + void pvt_UserPathChanged(QString value); + void pvt_LoggingChanged(bool value); + void pvt_LogFileNameChanged(QString value); + void pvt_AppendLogFileChanged(bool value); + void pvt_ConsoleOutputChanged(bool value); + void pvt_SaveLogLevelChanged(qint32 value); + void pvt_QueueLogLevelChanged(qint32 value); + void pvt_DumpTriggerLevelChanged(qint32 value); + void pvt_AssociateChanged(bool value); + void pvt_ExcludeChanged(QString value); + void pvt_IncludeChanged(QString value); + void pvt_NotifyTransactionChanged(bool value); + void pvt_InterfaceChanged(QString value); + void pvt_SaveConfigurationChanged(bool value); + void pvt_DriverMaxAttemptsChanged(qint32 value); + void pvt_PollIntervalChanged(qint32 value); + void pvt_IntervalBetweenPollsChanged(bool value); + void pvt_SuppressValueRefreshChanged(bool value); + void pvt_PerformReturnRoutesChanged(bool value); + void pvt_NetworkKeyChanged(QString value); + void pvt_RefreshAllUserCodesChanged(bool value); + void pvt_RetryTimeoutChanged(qint32 value); + void pvt_EnableSISChanged(bool value); + void pvt_AssumeAwakeChanged(bool value); + void pvt_NotifyOnDriverUnloadChanged(bool value); + void pvt_SecurityStrategyChanged(QString value); + void pvt_CustomSecuredCCChanged(QString value); + void pvt_EnforceSecureReceptionChanged(bool value); + void pvt_AutoUpdateConfigFileChanged(bool value); + void pvt_ReloadAfterUpdateChanged(QString value); + void pvt_LanguageChanged(QString value); + void pvt_IncludeInstanceLabelsChanged(bool value); + +private: + bool populateProperties(); + bool m_updating; + OpenZWave::Options *m_options; +}; + +#endif // QTOZWOPTIONS_P_H diff --git a/qt-openzwave/qt-openzwave.pro b/qt-openzwave/qt-openzwave.pro index b80f654..073e38e 100644 --- a/qt-openzwave/qt-openzwave.pro +++ b/qt-openzwave/qt-openzwave.pro @@ -6,7 +6,7 @@ QT -= gui -QT += remoteobjects +QT += remoteobjects testlib #QT += websockets TEMPLATE = lib @@ -39,6 +39,8 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += source/qtopenzwave.cpp \ + source/qtozwoptions.cpp \ + source/qtozwoptions_p.cpp \ source/qt_pods.cpp \ source/qtozwassociationmodel.cpp \ source/qtozwassociationmodel_p.cpp \ @@ -53,6 +55,8 @@ SOURCES += source/qtopenzwave.cpp \ HEADERS += include/qt-openzwave/qtopenzwave.h \ include/qt-openzwave/qtozw_pods.h \ + include/qt-openzwave/qtozwoptions.h \ + include/qtozwoptions_p.h \ include/qt-openzwave_global.h \ \ include/qtozw_logging.h \ include/qt-openzwave/qtozwassociationmodel.h \ @@ -68,12 +72,13 @@ HEADERS += include/qt-openzwave/qtopenzwave.h \ INCLUDEPATH += include/ -REPC_SOURCE = include/qt-openzwave/qtozwmanager.rep -REPC_REPLICA = include/qt-openzwave/qtozwmanager.rep +REPC_SOURCE = include/qt-openzwave/qtozwmanager.rep include/qt-openzwave/qtozwoptions.rep + +REPC_REPLICA = include/qt-openzwave/qtozwmanager.rep include/qt-openzwave/qtozwoptions.rep copyrepheaders.path = include/qt-openzwave/ -copyrepheaders.files = rep_qtozwmanager_replica.h rep_qtozwmanager_source.h -copyrepheaders.depends = rep_qtozwmanager_replica.h rep_qtozwmanager_source.h +copyrepheaders.files = rep_qtozwmanager_replica.h rep_qtozwmanager_source.h rep_qtozwoptions_replica.h rep_qtozwoptions_source.h +copyrepheaders.depends = rep_qtozwmanager_replica.h rep_qtozwmanager_source.h rep_qtozwoptions_replica.h rep_qtozwoptions_source.h COPIES += copyrepheaders unix { @@ -92,7 +97,6 @@ macx { FRAMEWORK_HEADERS.path = Headers QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS - QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/ CONFIG +=lib_bundle } diff --git a/qt-openzwave/source/qtopenzwave.cpp b/qt-openzwave/source/qtopenzwave.cpp index d32c0f0..8ef6d43 100644 --- a/qt-openzwave/source/qtopenzwave.cpp +++ b/qt-openzwave/source/qtopenzwave.cpp @@ -12,10 +12,14 @@ Q_LOGGING_CATEGORY(notifications, "ozw.notifications"); QTOpenZwave::QTOpenZwave ( - QObject *parent + QObject *parent, + QDir DBPath, + QDir UserPath ) : QObject (parent), - m_manager(nullptr) + m_manager(nullptr), + m_ozwdbpath(DBPath), + m_ozwuserpath(UserPath) { //qRegisterMetaType("uint32_t"); qRegisterMetaType("QTOZW_ValueIDList"); @@ -34,6 +38,8 @@ QTOZWManager *QTOpenZwave::GetManager { if (m_manager == nullptr) { this->m_manager = new QTOZWManager(this); + this->m_manager->setOZWDatabasePath(m_ozwdbpath); + this->m_manager->setOZWUserPath(m_ozwuserpath); } return this->m_manager; } diff --git a/qt-openzwave/source/qtozwmanager.cpp b/qt-openzwave/source/qtozwmanager.cpp index 0328b02..d7c0134 100644 --- a/qt-openzwave/source/qtozwmanager.cpp +++ b/qt-openzwave/source/qtozwmanager.cpp @@ -9,8 +9,9 @@ QTOZWManager::QTOZWManager(QObject *parent) : QObject(parent), - m_running(false) - + m_running(false), + m_ozwdatabasepath(""), + m_ozwuserpath("") { } @@ -21,12 +22,22 @@ bool QTOZWManager::initilizeBase() { bool QTOZWManager::initilizeSource(bool enableServer) { initilizeBase(); this->m_connectionType = connectionType::Local; + if (!this->m_ozwdatabasepath.exists()) { + qCWarning(manager) << "Database Path Does Not Exist: " << this->m_ozwdatabasepath; + return false; + } + if (!this->m_ozwuserpath.exists()) { + qCWarning(manager) << "User Path Does Not Exist: " << this->m_ozwuserpath; + return false; + } + OpenZWave::Options::Create(this->m_ozwdatabasepath.path().toStdString(), this->m_ozwuserpath.path().toStdString(), ""); this->d_ptr_internal = new QTOZWManager_Internal(this); if (enableServer) { this->m_sourceNode = new QRemoteObjectHost(QUrl(QStringLiteral("tcp://0.0.0.0:1983")), this); QObject::connect(this->m_sourceNode, &QRemoteObjectHost::error, this, &QTOZWManager::onSourceError); //this->m_sourceNode->setHeartbeatInterval(1000); this->m_sourceNode->enableRemoting(this->d_ptr_internal); + this->m_sourceNode->enableRemoting(this->d_ptr_internal->getOptions()); QVector roles; roles << Qt::DisplayRole << Qt::EditRole << Qt::ToolTipRole; this->m_sourceNode->enableRemoting(this->d_ptr_internal->getNodeModel(), "QTOZW_nodeModel", roles); @@ -46,6 +57,8 @@ bool QTOZWManager::initilizeReplica(QUrl remote) { if (this->m_replicaNode->connectToNode(remote)) { this->d_ptr_replica = this->m_replicaNode->acquire("QTOZWManager"); QObject::connect(this->d_ptr_replica, &QTOZWManagerReplica::stateChanged, this, &QTOZWManager::onManagerStateChange); + this->d_options_replica = this->m_replicaNode->acquire("QTOZWOptions"); + QObject::connect(this->d_options_replica, &QTOZWOptionsReplica::stateChanged, this, &QTOZWManager::onOptionsStateChange); this->m_nodeModel = this->m_replicaNode->acquireModel("QTOZW_nodeModel", QtRemoteObjects::InitialAction::PrefetchData); QObject::connect(qobject_cast(this->m_nodeModel), &QAbstractItemModelReplica::initialized, this, &QTOZWManager::onNodeInitialized); this->m_valueModel= this->m_replicaNode->acquireModel("QTOZW_valueModel", QtRemoteObjects::InitialAction::PrefetchData); @@ -70,6 +83,12 @@ void QTOZWManager::onManagerStateChange(QRemoteObjectReplica::State state) { this->m_managerState = state; this->checkReplicaReady(); } + +void QTOZWManager::onOptionsStateChange(QRemoteObjectReplica::State state) { + this->m_optionsState = state; + this->checkReplicaReady(); +} + void QTOZWManager::onNodeInitialized() { this->m_nodeState = true; this->checkReplicaReady(); @@ -85,9 +104,10 @@ void QTOZWManager::onAssociationInitialized() { void QTOZWManager::checkReplicaReady() { if ((this->m_managerState == QRemoteObjectReplica::State::Valid) && - (this->m_nodeState == true) && - (this->m_valuesState == true) && - (this->m_associationsState == true)) { + (this->m_optionsState == QRemoteObjectReplica::State::Valid) && + (this->m_nodeState == true) && + (this->m_valuesState == true) && + (this->m_associationsState == true)) { /* have to connect all the d_ptr SIGNALS to our SIGNALS now */ connectSignals(); emit this->ready(); @@ -299,3 +319,18 @@ bool QTOZWManager::downloadLatestConfigFileRevision(quint8 const _node) { bool QTOZWManager::downloadLatestMFSRevision() { CALL_DPTR_RTN(downloadLatestMFSRevision(), bool); } + +void QTOZWManager::setOZWDatabasePath(QDir path) { + if (path.exists()) + this->m_ozwdatabasepath = path; + else + qCWarning(manager) << "Database Path " << path << " doesn't exist"; + +} +void QTOZWManager::setOZWUserPath(QDir path) { + if (path.exists()) + this->m_ozwuserpath = path; + else + qCWarning(manager) << "User Path " << path << " doesn't exist"; +} + diff --git a/qt-openzwave/source/qtozwmanager_p.cpp b/qt-openzwave/source/qtozwmanager_p.cpp index 96d8b19..8fcf651 100644 --- a/qt-openzwave/source/qtozwmanager_p.cpp +++ b/qt-openzwave/source/qtozwmanager_p.cpp @@ -23,22 +23,13 @@ QTOZWManager_Internal::QTOZWManager_Internal(QObject *parent) { this->setObjectName("QTOZW_Manager"); try { - this->m_options = OpenZWave::Options::Create( "", "", "" ); + qCDebug(manager) << "OpenZWave Options Class Creating"; + this->m_options = new QTOZWOptions_Internal(this); + qCDebug(manager) << "OpenZWave Options Class Set"; } catch (OpenZWave::OZWException &e) { qCWarning(manager) << "Failed to Load Options Class" << QString(e.GetMsg().c_str()); return; } - qCDebug(manager) << "OpenZWave Options Class Created"; - this->m_options->AddOptionInt( "SaveLogLevel", OpenZWave::LogLevel_Detail ); - this->m_options->AddOptionInt( "QueueLogLevel", OpenZWave::LogLevel_Debug ); - this->m_options->AddOptionInt( "DumpTrigger", OpenZWave::LogLevel_Error ); - this->m_options->AddOptionBool("ConsoleOutput", false); - this->m_options->AddOptionInt( "PollInterval", 500 ); - this->m_options->AddOptionBool( "IntervalBetweenPolls", true ); - this->m_options->AddOptionBool( "ValidateValueChanges", true); - qCDebug(manager) << "OpenZWave Options Set"; - - this->m_nodeModel = new QTOZW_Nodes_internal(this); QObject::connect(this->m_nodeModel, &QTOZW_Nodes_internal::dataChanged, this, &QTOZWManager_Internal::pvt_nodeModelDataChanged); this->m_valueModel = new QTOZW_ValueIds_internal(this); @@ -56,7 +47,7 @@ bool QTOZWManager_Internal::open(QString SerialPort) try { this->m_manager = OpenZWave::Manager::Create(); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); qCWarning(manager) << "Failed to Load Manager Class" << QString(e.GetMsg().c_str()); return false; @@ -64,13 +55,13 @@ bool QTOZWManager_Internal::open(QString SerialPort) qCDebug(manager) << "OpenZWave Manager Instance Created"; try { if (this->m_manager->AddWatcher( OZWNotification::processNotification, this ) != true) { - emit this->error(QTOZWErrorCodes::setupFailed); + emit this->error(QTOZWManagerErrorCodes::setupFailed); this->setErrorString("Failed to Add Notification Callback"); qCWarning(manager) << "Failed to Add Notification Callback"; return false; } } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); qCWarning(manager) << "Failed to Add Notification Callback " << QString(e.GetMsg().c_str()); return false; @@ -113,13 +104,13 @@ bool QTOZWManager_Internal::open(QString SerialPort) try { if (this->m_manager->AddDriver( SerialPort.toStdString()) != true) { - emit this->error(QTOZWErrorCodes::setupFailed); + emit this->error(QTOZWManagerErrorCodes::setupFailed); this->setErrorString("Failed to Add Serial Port"); qCWarning(manager) << "Failed to Add Serial Port"; return false; } } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); qCWarning(manager) << "Failed to Add Serial Port: " << QString(e.GetMsg().c_str()); return false; @@ -135,7 +126,7 @@ bool QTOZWManager_Internal::refreshNodeInfo(quint8 _node) { try { return this->m_manager->RefreshNodeInfo(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -147,7 +138,7 @@ bool QTOZWManager_Internal::requestNodeState(quint8 _node) { try { return this->m_manager->RequestNodeState(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -159,7 +150,7 @@ bool QTOZWManager_Internal::requestNodeDynamic(quint8 _node) { try { return this->m_manager->RequestNodeDynamic(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -171,7 +162,7 @@ bool QTOZWManager_Internal::setConfigParam(quint8 _node, quint8 _param, qint32 _ try { return this->m_manager->SetConfigParam(this->homeId(), _node, _param, _value, _size); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -183,7 +174,7 @@ void QTOZWManager_Internal::requestConfigParam(quint8 _node, quint8 _param) { try { this->m_manager->RequestConfigParam(this->homeId(), _node, _param); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -195,7 +186,7 @@ void QTOZWManager_Internal::requestAllConfigParam(quint8 _node) { try { this->m_manager->RequestAllConfigParams(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -207,7 +198,7 @@ void QTOZWManager_Internal::softResetController() { try { this->m_manager->SoftReset(this->homeId()); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -220,7 +211,7 @@ void QTOZWManager_Internal::hardResetController() { try { this->m_manager->ResetController(this->homeId()); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -233,7 +224,7 @@ bool QTOZWManager_Internal::cancelControllerCommand() { try { return this->m_manager->CancelControllerCommand(this->homeId()); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -245,7 +236,7 @@ void QTOZWManager_Internal::testNetworkNode(quint8 _node, quint32 const _count) try { this->m_manager->TestNetworkNode(this->homeId(), _node, _count); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -256,7 +247,7 @@ void QTOZWManager_Internal::testNetwork(quint32 const _count) { try { this->m_manager->TestNetwork(this->homeId(), _count); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -267,7 +258,7 @@ void QTOZWManager_Internal::healNetworkNode(quint8 _node, bool _doRR) { try { this->m_manager->HealNetworkNode(this->homeId(), _node, _doRR); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -278,7 +269,7 @@ void QTOZWManager_Internal::healNetwork(bool _doRR) { try { this->m_manager->HealNetwork(this->homeId(), _doRR); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return; @@ -289,7 +280,7 @@ bool QTOZWManager_Internal::addNode(bool _doSecure) { try { return this->m_manager->AddNode(this->homeId(), _doSecure); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -300,7 +291,7 @@ bool QTOZWManager_Internal::removeNode() { try { return this->m_manager->RemoveNode(this->homeId()); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -311,7 +302,7 @@ bool QTOZWManager_Internal::removeFailedNode(quint8 _node) { try { return this->m_manager->RemoveFailedNode(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -322,7 +313,7 @@ bool QTOZWManager_Internal::hasNodeFailed(quint8 _node) { try { return this->m_manager->HasNodeFailed(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -333,7 +324,7 @@ bool QTOZWManager_Internal::requestNodeNeighborUpdate(quint8 _node) { try { return this->m_manager->RequestNodeNeighborUpdate(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -344,7 +335,7 @@ bool QTOZWManager_Internal::assignReturnRoute(quint8 _node) { try { return this->m_manager->AssignReturnRoute(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -355,7 +346,7 @@ bool QTOZWManager_Internal::deleteAllReturnRoute(quint8 _node) { try { return this->m_manager->DeleteAllReturnRoutes(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -366,7 +357,7 @@ bool QTOZWManager_Internal::sendNodeInfomation(quint8 _node) { try { return this->m_manager->SendNodeInformation(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -377,7 +368,7 @@ bool QTOZWManager_Internal::replaceFailedNode(quint8 _node) { try { return this->m_manager->ReplaceFailedNode(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -388,7 +379,7 @@ bool QTOZWManager_Internal::requestNetworkUpdate(quint8 _node) { try { return this->m_manager->RequestNetworkUpdate(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -400,7 +391,7 @@ QString QTOZWManager_Internal::GetMetaData(quint8 _node, QTOZWMetaDataField _fie try { return QString::fromStdString(this->m_manager->GetMetaData(this->homeId(), _node, static_cast(_field))); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return QString(); @@ -418,7 +409,7 @@ QByteArray QTOZWManager_Internal::GetMetaDataProductPic(quint8 _node) { if (!file.open(QIODevice::ReadOnly)) return QByteArray(); return file.readAll(); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return QByteArray(); @@ -432,7 +423,7 @@ QString QTOZWManager_Internal::GetNodeQueryStage(quint8 const _node) { try { return this->m_manager->GetNodeQueryStage(this->homeId(), _node).c_str(); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return QString(); @@ -482,7 +473,7 @@ NodeStatistics QTOZWManager_Internal::GetNodeStatistics(quint8 const _node) { ns.lastReceivedTimeStamp = nd.m_receivedTS.c_str(); return ns; } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return NodeStatistics(); @@ -495,7 +486,7 @@ bool QTOZWManager_Internal::IsNodeFailed(quint8 const _node) { try { return this->m_manager->IsNodeFailed(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -508,7 +499,7 @@ bool QTOZWManager_Internal::checkLatestConfigFileRevision(quint8 const _node) { try { return this->m_manager->checkLatestConfigFileRevision(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -520,7 +511,7 @@ bool QTOZWManager_Internal::checkLatestMFSRevision() { try { return this->m_manager->checkLatestMFSRevision(this->homeId()); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -532,7 +523,7 @@ bool QTOZWManager_Internal::downloadLatestConfigFileRevision(quint8 const _node) try { return this->m_manager->downloadLatestConfigFileRevision(this->homeId(), _node); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -544,7 +535,7 @@ bool QTOZWManager_Internal::downloadLatestMFSRevision() { try { return this->m_manager->downloadLatestMFSRevision(this->homeId()); } catch (OpenZWave::OZWException &e) { - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } return false; @@ -562,14 +553,20 @@ QTOZW_Associations *QTOZWManager_Internal::getAssociationModel() { return static_cast(this->m_associationsModel); } +QTOZWOptions_Internal *QTOZWManager_Internal::getOptions() { + return this->m_options; +} + + + bool QTOZWManager_Internal::checkHomeId() { if (this->m_manager == nullptr) { - emit this->error(QTOZWErrorCodes::Manager_Not_Started); + emit this->error(QTOZWManagerErrorCodes::Manager_Not_Started); this->setErrorString("Manager Not Started"); return false; } if (this->homeId() == 0) { - emit this->error(QTOZWErrorCodes::homeId_Invalid); + emit this->error(QTOZWManagerErrorCodes::homeId_Invalid); this->setErrorString("Invalid homeID"); return false; } @@ -577,7 +574,7 @@ bool QTOZWManager_Internal::checkHomeId() { } bool QTOZWManager_Internal::checkNodeId(quint8 _node) { if (!this->m_validNodes.contains(_node)) { - emit this->error(QTOZWErrorCodes::nodeId_Invalid); + emit this->error(QTOZWManagerErrorCodes::nodeId_Invalid); this->setErrorString("Invalid nodeID"); return false; } @@ -586,7 +583,7 @@ bool QTOZWManager_Internal::checkNodeId(quint8 _node) { bool QTOZWManager_Internal::checkValueKey(quint64 _vidKey) { if (!this->m_validValues.contains(_vidKey)) { - emit this->error(QTOZWErrorCodes::valueIDKey_Invalid); + emit this->error(QTOZWManagerErrorCodes::valueIDKey_Invalid); this->setErrorString("Invalid ValueID Key"); return false; } @@ -746,7 +743,7 @@ void QTOZWManager_Internal::pvt_valueAdded(quint64 vidKey) this->convertValueID(vidKey); } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } emit this->valueAdded(vidKey); @@ -839,7 +836,7 @@ void QTOZWManager_Internal::pvt_nodeNew(quint8 node) this->m_nodeModel->setNodeFlags(node, QTOZW_Nodes::isFailed, this->m_manager->IsNodeFailed(this->homeId(), node)); } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } @@ -863,7 +860,7 @@ void QTOZWManager_Internal::pvt_nodeAdded(quint8 node) this->m_nodeModel->setNodeFlags(node, QTOZW_Nodes::isFailed, this->m_manager->IsNodeFailed(this->homeId(), node)); } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } emit this->nodeAdded(node); @@ -913,7 +910,7 @@ void QTOZWManager_Internal::pvt_nodeNaming(quint8 node) this->m_nodeModel->setNodeFlags(node, QTOZW_Nodes::isFailed, this->m_manager->IsNodeFailed(this->homeId(), node)); } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } emit this->nodeNaming(node); @@ -930,7 +927,7 @@ void QTOZWManager_Internal::pvt_nodeEvent(quint8 node, quint8 event) this->m_nodeModel->setNodeFlags(node, QTOZW_Nodes::isFailed, this->m_manager->IsNodeFailed(this->homeId(), node)); } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } emit this->nodeEvent(node, event); @@ -1004,7 +1001,7 @@ void QTOZWManager_Internal::pvt_nodeProtocolInfo(quint8 node) this->m_nodeModel->setNodeFlags(node, QTOZW_Nodes::isFailed, this->m_manager->IsNodeFailed(this->homeId(), node)); } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } emit this->nodeProtocolInfo(node); @@ -1081,7 +1078,7 @@ void QTOZWManager_Internal::pvt_nodeEssentialNodeQueriesComplete(quint8 node) } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } emit this->nodeEssentialNodeQueriesComplete(node); @@ -1170,7 +1167,7 @@ void QTOZWManager_Internal::pvt_nodeQueriesComplete(quint8 node) } catch (OpenZWave::OZWException &e) { qCWarning(notifications) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } emit this->nodeQueriesComplete(node); @@ -1272,7 +1269,7 @@ void QTOZWManager_Internal::pvt_nodeModelDataChanged(const QModelIndex &topLeft, } } catch (OpenZWave::OZWException &e) { qCWarning(nodeModel) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } @@ -1363,7 +1360,7 @@ void QTOZWManager_Internal::pvt_valueModelDataChanged(const QModelIndex &topLeft } } catch (OpenZWave::OZWException &e) { qCWarning(valueModel) << "OZW Exception: " << e.GetMsg().c_str() << " at " << e.GetFile().c_str() <<":" << e.GetLine(); - emit this->error(QTOZWErrorCodes::OZWException); + emit this->error(QTOZWManagerErrorCodes::OZWException); this->setErrorString(e.GetMsg().c_str()); } } diff --git a/qt-openzwave/source/qtozwoptions.cpp b/qt-openzwave/source/qtozwoptions.cpp new file mode 100644 index 0000000..a64591d --- /dev/null +++ b/qt-openzwave/source/qtozwoptions.cpp @@ -0,0 +1,329 @@ +#include +#include + +#include "qt-openzwave/qtozwoptions.h" +#include "qtozwoptions_p.h" +#include "qtozw_logging.h" + +#define CONNECT_DPTR(x) if (this->m_connectionType == connectionType::Local) { \ + QObject::connect(this->d_ptr_internal, &QTOZWOptions_Internal::x, this, &QTOZWOptions::x);\ + } else { \ + QObject::connect(this->d_ptr_replica, &QTOZWOptionsReplica::x, this, &QTOZWOptions::x); \ + }; + +#define CONNECT_DPTR1(x, y) if (this->m_connectionType == connectionType::Local) { \ + QObject::connect(this->d_ptr_internal, &QTOZWOptions_Internal::x, this, &QTOZWOptions::y);\ + } else { \ + QObject::connect(this->d_ptr_replica, &QTOZWOptionsReplica::x, this, &QTOZWOptions::y); \ + }; + +#define CALL_DPTR(x) if (this->m_connectionType == QTOZWOptions::connectionType::Local) this->d_ptr_internal->x; else this->d_ptr_replica->x; +#define CALL_DPTR_PROP(x) if (this->m_connectionType == QTOZWOptions::connectionType::Local) return this->d_ptr_internal->x; else return this->d_ptr_replica->x; +#define CALL_DPTR_PROP_SET(x) if (this->m_connectionType == QTOZWOptions::connectionType::Local) { \ + this->d_ptr_internal->setProperty("x", x); \ + } else { \ + QSignalSpy spy(this, SIGNAL(xChanged)); \ + this->d_ptr_replica->setProperty("x", x); \ + spy.wait(); \ + } +#define CALL_DPTR_METHOD_RTN(x, y) if (this->m_connectionType == QTOZWOptions::connectionType::Local) \ + return this->d_ptr_internal->x; \ + else { \ + QRemoteObjectPendingReply res = this->d_ptr_replica->x; \ + res.waitForFinished(); \ + return res.returnValue(); \ + } + + + + +QTOZWOptions::QTOZWOptions(QObject *parent) + : QObject(parent) +{ + +} + +bool QTOZWOptions::initilizeBase() { + return true; +} + +bool QTOZWOptions::initilizeSource(QRemoteObjectHost *m_sourceNode) { + initilizeBase(); + this->m_connectionType = connectionType::Local; + this->d_ptr_internal = new QTOZWOptions_Internal(this); + if (m_sourceNode) { + m_sourceNode->enableRemoting(this->d_ptr_internal); + } + return true; +} + +bool QTOZWOptions::initilizeReplica(QRemoteObjectNode *m_replicaNode) { + initilizeBase(); + this->m_connectionType = connectionType::Remote; + this->d_ptr_replica = m_replicaNode->acquire("QTOZW_Options"); + QObject::connect(this->d_ptr_replica, &QTOZWOptionsReplica::stateChanged, this, &QTOZWOptions::onOptionStateChange); + + return true; +} + +void QTOZWOptions::onOptionStateChange(QRemoteObjectReplica::State state) { + if (state == QRemoteObjectReplica::State::Valid) { + connectSignals(); + } +} + +void QTOZWOptions::connectSignals() { + CONNECT_DPTR(ConfigPathChanged); + CONNECT_DPTR(UserPathChanged); + CONNECT_DPTR(LoggingChanged); + CONNECT_DPTR(LogFileNameChanged); + CONNECT_DPTR(AppendLogFileChanged); + CONNECT_DPTR(ConsoleOutputChanged); + CONNECT_DPTR(SaveLogLevelChanged); + CONNECT_DPTR(QueueLogLevelChanged); + CONNECT_DPTR(DumpTriggerLevelChanged); + CONNECT_DPTR(AssociateChanged); + CONNECT_DPTR(ExcludeChanged); + CONNECT_DPTR(IncludeChanged); + CONNECT_DPTR(NotifyTransactionsChanged); + CONNECT_DPTR(InterfaceChanged); + CONNECT_DPTR(SaveConfigurationChanged); + CONNECT_DPTR(DriverMaxAttemptsChanged); + CONNECT_DPTR(PollIntervalChanged); + CONNECT_DPTR(IntervalBetweenPollsChanged); + CONNECT_DPTR(SuppressValueRefreshChanged); + CONNECT_DPTR(PerformReturnRoutesChanged); + CONNECT_DPTR(NetworkKeyChanged); + CONNECT_DPTR(RefreshAllUserCodesChanged); + CONNECT_DPTR(RetryTimeoutChanged); + CONNECT_DPTR(EnableSISChanged); + CONNECT_DPTR(AssumeAwakeChanged); + CONNECT_DPTR(NotifyOnDriverUnloadChanged); + CONNECT_DPTR(SecurityStrategyChanged); + CONNECT_DPTR(CustomSecuredCCChanged); + CONNECT_DPTR(EnforceSecureReceptionChanged); + CONNECT_DPTR(AutoUpdateConfigFileChanged); + CONNECT_DPTR(ReloadAfterUpdateChanged); + CONNECT_DPTR(LanguageChanged); + CONNECT_DPTR(IncludeInstanceLabelsChanged); +// CONNECT_DPTR(error); +} + +QString QTOZWOptions::ConfigPath() const { + CALL_DPTR_PROP(ConfigPath()); +} +QString QTOZWOptions::UserPath() const { + CALL_DPTR_PROP(UserPath()); +} +bool QTOZWOptions::Logging() const { + CALL_DPTR_PROP(Logging()); +} +QString QTOZWOptions::LogFileName() const { + CALL_DPTR_PROP(LogFileName()); +} +bool QTOZWOptions::AppendLogFile() const { + CALL_DPTR_PROP(AppendLogFile()); +} +bool QTOZWOptions::ConsoleOutput() const { + CALL_DPTR_PROP(ConsoleOutput()); +} +qint32 QTOZWOptions::SaveLogLevel() const { + CALL_DPTR_PROP(SaveLogLevel()); +} +qint32 QTOZWOptions::QueueLogLevel() const { + CALL_DPTR_PROP(QueueLogLevel()); +} +qint32 QTOZWOptions::DumpTriggerLevel() const { + CALL_DPTR_PROP(DumpTriggerLevel()); +} +bool QTOZWOptions::Associate() const { + CALL_DPTR_PROP(Associate()); +} +QString QTOZWOptions::Exclude() const { + CALL_DPTR_PROP(Exclude()); +} +QString QTOZWOptions::Include() const { + CALL_DPTR_PROP(Include()); +} +bool QTOZWOptions::NotifyTransactions() const { + CALL_DPTR_PROP(NotifyTransactions()); +} +QString QTOZWOptions::Interface() const { + CALL_DPTR_PROP(Interface()); +} +bool QTOZWOptions::SaveConfiguration() const { + CALL_DPTR_PROP(SaveConfiguration()); +} +qint32 QTOZWOptions::DriverMaxAttempts() const { + CALL_DPTR_PROP(DriverMaxAttempts()); +} +qint32 QTOZWOptions::PollInterval() const { + CALL_DPTR_PROP(PollInterval()); +} +bool QTOZWOptions::SuppressValueRefresh() const { + CALL_DPTR_PROP(SuppressValueRefresh()); +} +bool QTOZWOptions::IntervalBetweenPolls() const { + CALL_DPTR_PROP(IntervalBetweenPolls()); +} +bool QTOZWOptions::PerformReturnRoutes() const { + CALL_DPTR_PROP(PerformReturnRoutes()); +} +QString QTOZWOptions::NetworkKey() const { + CALL_DPTR_PROP(NetworkKey()); +} +bool QTOZWOptions::RefreshAllUserCodes() const { + CALL_DPTR_PROP(RefreshAllUserCodes()); +} +qint32 QTOZWOptions::RetryTimeout() const { + CALL_DPTR_PROP(RetryTimeout()); +} +bool QTOZWOptions::EnableSIS() const { + CALL_DPTR_PROP(EnableSIS()); +} +bool QTOZWOptions::AssumeAwake() const { + CALL_DPTR_PROP(AssumeAwake()); +} +bool QTOZWOptions::NotifyOnDriverUnload() const { + CALL_DPTR_PROP(NotifyTransactions()); +} +QString QTOZWOptions::SecurityStrategy() const { + CALL_DPTR_PROP(SecurityStrategy()); +} +QString QTOZWOptions::CustomSecuredCC() const { + CALL_DPTR_PROP(CustomSecuredCC()); +} +bool QTOZWOptions::EnforceSecureReception() const { + CALL_DPTR_PROP(EnforceSecureReception()); +} +bool QTOZWOptions::AutoUpdateConfigFile() const { + CALL_DPTR_PROP(AutoUpdateConfigFile()); +} +QString QTOZWOptions::ReloadAfterUpdate() const { + CALL_DPTR_PROP(ReloadAfterUpdate()); +} +QString QTOZWOptions::Language() const { + CALL_DPTR_PROP(Language()); +} +bool QTOZWOptions::IncludeInstanceLabels() const { + CALL_DPTR_PROP(IncludeInstanceLabels()); +} + +void QTOZWOptions::setConfigPath(QString ConfigPath) { + CALL_DPTR_PROP_SET(ConfigPath); +} +void QTOZWOptions::setUserPath(QString UserPath) { + CALL_DPTR_PROP_SET(UserPath); +} +void QTOZWOptions::setLogging(bool Logging) { + CALL_DPTR_PROP_SET(Logging); +} +void QTOZWOptions::setLogFileName(QString LogFileName) { + CALL_DPTR_PROP_SET(LogFileName); +} +void QTOZWOptions::setAppendLogFile(bool AppendLogFile) { + CALL_DPTR_PROP_SET(AppendLogFile); +} +void QTOZWOptions::setConsoleOutput(bool ConsoleOutput) { + CALL_DPTR_PROP_SET(ConsoleOutput); +} +void QTOZWOptions::setSaveLogLevel(qint32 SaveLogLevel) { + CALL_DPTR_PROP_SET(SaveLogLevel); +} +void QTOZWOptions::setQueueLogLevel(qint32 QueueLogLevel) { + CALL_DPTR_PROP_SET(QueueLogLevel); +} +void QTOZWOptions::setDumpTriggerLevel(qint32 DumpTriggerLevel) { + CALL_DPTR_PROP_SET(DumpTriggerLevel); +} +void QTOZWOptions::setAssociate(bool Associate) { + CALL_DPTR_PROP_SET(Associate); +} +void QTOZWOptions::setExclude(QString Exclude) { + CALL_DPTR_PROP_SET(Exclude); +} +void QTOZWOptions::setInclude(QString Include) { + CALL_DPTR_PROP_SET(Include); +} +void QTOZWOptions::setNotifyTransactions(bool NotifyTransactions) { + CALL_DPTR_PROP_SET(NotifyTransactions); +} +void QTOZWOptions::setInterface(QString Interface) { + CALL_DPTR_PROP_SET(Interface); +} +void QTOZWOptions::setSaveConfiguration(bool SaveConfiguration) { + CALL_DPTR_PROP_SET(SaveConfiguration); +} +void QTOZWOptions::setDriverMaxAttempts(qint32 DriverMaxAttempts) { + CALL_DPTR_PROP_SET(DriverMaxAttempts); +} +void QTOZWOptions::setPollInterval(qint32 PollInterval) { + CALL_DPTR_PROP_SET(PollInterval); +} +void QTOZWOptions::setIntervalBetweenPolls(bool IntervalBetweenPolls) { + CALL_DPTR_PROP_SET(IntervalBetweenPolls); +} +void QTOZWOptions::setSuppressValueRefresh(bool SuppressValueRefresh) { + CALL_DPTR_PROP_SET(SuppressValueRefresh); +} +void QTOZWOptions::setPerformReturnRoutes(bool PerformReturnRoutes) { + CALL_DPTR_PROP_SET(PerformReturnRoutes); +} +void QTOZWOptions::setNetworkKey(QString NetworkKey) { + CALL_DPTR_PROP_SET(NetworkKey); +} +void QTOZWOptions::setRefreshAllUserCodes(bool RefreshAllUserCodes) { + CALL_DPTR_PROP_SET(RefreshAllUserCodes); +} +void QTOZWOptions::setRetryTimeout(qint32 RetryTimeout) { + CALL_DPTR_PROP_SET(RetryTimeout); +} +void QTOZWOptions::setEnableSIS(bool EnableSIS) { + CALL_DPTR_PROP_SET(EnableSIS); +} +void QTOZWOptions::setAssumeAwake(bool AssumeAwake) { + CALL_DPTR_PROP_SET(AssumeAwake); +} +void QTOZWOptions::setNotifyOnDriverUnload(bool NotifyOnDriverUnload) { + CALL_DPTR_PROP_SET(NotifyOnDriverUnload); +} +void QTOZWOptions::setSecurityStrategy(QString SecurityStrategy) { + CALL_DPTR_PROP_SET(SecurityStrategy); +} +void QTOZWOptions::setCustomSecuredCC(QString CustomSecuredCC) { + CALL_DPTR_PROP_SET(CustomSecuredCC); +} +void QTOZWOptions::setEnforceSecureReception(bool EnforceSecureReception) { + CALL_DPTR_PROP_SET(EnforceSecureReception); +} +void QTOZWOptions::setAutoUpdateConfigFile(bool AutoUpdateConfigFile) { + CALL_DPTR_PROP_SET(AutoUpdateConfigFile); +} +void QTOZWOptions::setReloadAfterUpdate(QString ReloadAfterUpdate) { + CALL_DPTR_PROP_SET(ReloadAfterUpdate); +} +void QTOZWOptions::setLanguage(QString Language) { + CALL_DPTR_PROP_SET(Language); +} +void QTOZWOptions::setIncludeInstanceLabels(bool IncludeInstanceLabels) { + CALL_DPTR_PROP_SET(IncludeInstanceLabels); +} + +bool QTOZWOptions::AddOptionBool(QString option, bool value) { + CALL_DPTR_METHOD_RTN(AddOptionBool(option, value), bool); +} +bool QTOZWOptions::AddOptionInt(QString option, qint32 value) { + CALL_DPTR_METHOD_RTN(AddOptionInt(option, value), bool) +} +bool QTOZWOptions::AddOptionString(QString option, QString value) { + CALL_DPTR_METHOD_RTN(AddOptionString(option, value), bool) +} +bool QTOZWOptions::GetOptionAsBool(QString option) { + CALL_DPTR_METHOD_RTN(GetOptionAsBool(option), bool); +} +qint32 QTOZWOptions::GetOptionAsInt(QString option) { + CALL_DPTR_METHOD_RTN(GetOptionAsInt(option), qint32); +} +QString QTOZWOptions::GetOptionAsString(QString option) { + CALL_DPTR_METHOD_RTN(GetOptionAsString(option), QString); +} diff --git a/qt-openzwave/source/qtozwoptions_p.cpp b/qt-openzwave/source/qtozwoptions_p.cpp new file mode 100644 index 0000000..5bcd65a --- /dev/null +++ b/qt-openzwave/source/qtozwoptions_p.cpp @@ -0,0 +1,292 @@ +#include "qtozwoptions_p.h" + + +QTOZWOptions_Internal::QTOZWOptions_Internal(QObject *parent) + : QTOZWOptionsSimpleSource (parent), + m_updating(false) +{ + this->setObjectName("QTOZW_Options"); + + this->m_options = OpenZWave::Options::Get(); + if (!this->m_options) { + /* Not Created...Bail Out*/ + emit this->error(QTOZWOptionsErrorCodes::NoOptionClass); + return; + } + + this->populateProperties(); + + connect(this, &QTOZWOptionsSimpleSource::ConfigPathChanged, this, &QTOZWOptions_Internal::pvt_ConfigPathChanged); + connect(this, &QTOZWOptionsSimpleSource::UserPathChanged, this, &QTOZWOptions_Internal::pvt_UserPathChanged); + connect(this, &QTOZWOptionsSimpleSource::LoggingChanged, this, &QTOZWOptions_Internal::pvt_LoggingChanged); + connect(this, &QTOZWOptionsSimpleSource::LogFileNameChanged, this, &QTOZWOptions_Internal::pvt_LogFileNameChanged); + connect(this, &QTOZWOptionsSimpleSource::AppendLogFileChanged, this, &QTOZWOptions_Internal::pvt_AppendLogFileChanged); + connect(this, &QTOZWOptionsSimpleSource::ConsoleOutputChanged, this, &QTOZWOptions_Internal::pvt_ConsoleOutputChanged); + connect(this, &QTOZWOptionsSimpleSource::SaveLogLevelChanged, this, &QTOZWOptions_Internal::pvt_SaveLogLevelChanged); + connect(this, &QTOZWOptionsSimpleSource::QueueLogLevelChanged, this, &QTOZWOptions_Internal::pvt_QueueLogLevelChanged); + connect(this, &QTOZWOptionsSimpleSource::DumpTriggerLevelChanged, this, &QTOZWOptions_Internal::pvt_DumpTriggerLevelChanged); + connect(this, &QTOZWOptionsSimpleSource::AssociateChanged, this, &QTOZWOptions_Internal::pvt_AssociateChanged); + connect(this, &QTOZWOptionsSimpleSource::ExcludeChanged, this, &QTOZWOptions_Internal::pvt_ExcludeChanged); + connect(this, &QTOZWOptionsSimpleSource::IncludeChanged, this, &QTOZWOptions_Internal::pvt_IncludeChanged); + connect(this, &QTOZWOptionsSimpleSource::NotifyTransactionsChanged, this, &QTOZWOptions_Internal::pvt_NotifyTransactionChanged); + connect(this, &QTOZWOptionsSimpleSource::InterfaceChanged, this, &QTOZWOptions_Internal::pvt_InterfaceChanged); + connect(this, &QTOZWOptionsSimpleSource::SaveConfigurationChanged, this, &QTOZWOptions_Internal::pvt_SaveConfigurationChanged); + connect(this, &QTOZWOptionsSimpleSource::DriverMaxAttemptsChanged, this, &QTOZWOptions_Internal::pvt_DriverMaxAttemptsChanged); + connect(this, &QTOZWOptionsSimpleSource::PollIntervalChanged, this, &QTOZWOptions_Internal::pvt_PollIntervalChanged); + connect(this, &QTOZWOptionsSimpleSource::IntervalBetweenPollsChanged, this, &QTOZWOptions_Internal::pvt_IntervalBetweenPollsChanged); + connect(this, &QTOZWOptionsSimpleSource::SuppressValueRefreshChanged, this, &QTOZWOptions_Internal::pvt_SuppressValueRefreshChanged); + connect(this, &QTOZWOptionsSimpleSource::PerformReturnRoutesChanged, this, &QTOZWOptions_Internal::pvt_PerformReturnRoutesChanged); + connect(this, &QTOZWOptionsSimpleSource::NetworkKeyChanged, this, &QTOZWOptions_Internal::pvt_NetworkKeyChanged); + connect(this, &QTOZWOptionsSimpleSource::RefreshAllUserCodesChanged, this, &QTOZWOptions_Internal::pvt_RefreshAllUserCodesChanged); + connect(this, &QTOZWOptionsSimpleSource::RetryTimeoutChanged, this, &QTOZWOptions_Internal::pvt_RetryTimeoutChanged); + connect(this, &QTOZWOptionsSimpleSource::EnableSISChanged, this, &QTOZWOptions_Internal::pvt_EnableSISChanged); + connect(this, &QTOZWOptionsSimpleSource::AssumeAwakeChanged, this, &QTOZWOptions_Internal::pvt_AssumeAwakeChanged); + connect(this, &QTOZWOptionsSimpleSource::NotifyOnDriverUnloadChanged, this, &QTOZWOptions_Internal::pvt_NotifyOnDriverUnloadChanged); + connect(this, &QTOZWOptionsSimpleSource::SecurityStrategyChanged, this, &QTOZWOptions_Internal::pvt_SecurityStrategyChanged); + connect(this, &QTOZWOptionsSimpleSource::CustomSecuredCCChanged, this, &QTOZWOptions_Internal::pvt_CustomSecuredCCChanged); + connect(this, &QTOZWOptionsSimpleSource::EnforceSecureReceptionChanged, this, &QTOZWOptions_Internal::pvt_EnforceSecureReceptionChanged); + connect(this, &QTOZWOptionsSimpleSource::AutoUpdateConfigFileChanged, this, &QTOZWOptions_Internal::pvt_AutoUpdateConfigFileChanged); + connect(this, &QTOZWOptionsSimpleSource::ReloadAfterUpdateChanged, this, &QTOZWOptions_Internal::pvt_ReloadAfterUpdateChanged); + connect(this, &QTOZWOptionsSimpleSource::LanguageChanged, this, &QTOZWOptions_Internal::pvt_LanguageChanged); + connect(this, &QTOZWOptionsSimpleSource::IncludeInstanceLabelsChanged, this, &QTOZWOptions_Internal::pvt_IncludeInstanceLabelsChanged); + +} +bool QTOZWOptions_Internal::AddOptionBool(QString option, bool value) { + return this->m_options->AddOptionBool(option.toStdString(), value); +} +bool QTOZWOptions_Internal::AddOptionInt(QString option, qint32 value) { + return this->m_options->AddOptionInt(option.toStdString(), value); +} +bool QTOZWOptions_Internal::AddOptionString(QString option, QString value) { + return this->m_options->AddOptionString(option.toStdString(), value.toStdString(), false); +} +bool QTOZWOptions_Internal::GetOptionAsBool(QString option) { + bool value; + if (this->m_options->GetOptionAsBool(option.toStdString(), &value)) { + return value; + } + emit this->error(QTOZWOptionsErrorCodes::InvalidOption); + return false; +} +qint32 QTOZWOptions_Internal::GetOptionAsInt(QString option) { + qint32 value; + if (this->m_options->GetOptionAsInt(option.toStdString(), &value)) { + return value; + } + emit this->error(QTOZWOptionsErrorCodes::InvalidOption); + return -1; +} +QString QTOZWOptions_Internal::GetOptionAsString(QString option) { + std::string value; + if (this->m_options->GetOptionAsString(option.toStdString(), &value)) { + return QString::fromStdString(value); + } + emit this->error(QTOZWOptionsErrorCodes::InvalidOption); + return QString(); +} + +bool QTOZWOptions_Internal::populateProperties() { + this->m_updating = true; + this->setConfigPath(this->GetOptionAsString("ConfigPath")); + this->setUserPath(this->GetOptionAsString("UserPath")); + this->setLogging(this->GetOptionAsBool("Logging")); + this->setLogFileName(this->GetOptionAsString("LogFileName")); + this->setAppendLogFile(this->GetOptionAsBool("AppendLogFile")); + this->setConsoleOutput(this->GetOptionAsBool("ConsoleOutput")); + this->setSaveLogLevel(this->GetOptionAsInt("SaveLogLevel")); + this->setQueueLogLevel(this->GetOptionAsInt("QueueLogLevel")); + this->setDumpTriggerLevel(this->GetOptionAsInt("DumpTriggerLevel")); + this->setAssociate(this->GetOptionAsBool("Associate")); + this->setExclude(this->GetOptionAsString("Exclude")); + this->setInclude(this->GetOptionAsString("Include")); + this->setNotifyTransactions(this->GetOptionAsBool("NotifyTransactions")); + this->setInterface(this->GetOptionAsString("Interface")); + this->setSaveConfiguration(this->GetOptionAsBool("SaveConfiguration")); + this->setDriverMaxAttempts(this->GetOptionAsInt("DriverMaxAttempts")); + this->setPollInterval(this->GetOptionAsInt("PollInterval")); + this->setIntervalBetweenPolls(this->GetOptionAsBool("IntervalBetweenPolls")); + this->setSuppressValueRefresh(this->GetOptionAsBool("SuppressValueRefresh")); + this->setPerformReturnRoutes(this->GetOptionAsBool("PerformReturnRoutes")); + this->setNetworkKey(this->GetOptionAsString("NetworkKey")); + this->setRefreshAllUserCodes(this->GetOptionAsBool("RefreshAllUserCodes")); + this->setRetryTimeout(this->GetOptionAsInt("RetryTimeout")); + this->setEnableSIS(this->GetOptionAsBool("EnableSIS")); + this->setAssumeAwake(this->GetOptionAsBool("AssumeAwake")); + this->setNotifyOnDriverUnload(this->GetOptionAsBool("NotifyOnDriverUnload")); + this->setSecurityStrategy(this->GetOptionAsString("SecurityStrategy")); + this->setCustomSecuredCC(this->GetOptionAsString("CustomSecuredCC")); + this->setEnforceSecureReception(this->GetOptionAsBool("EnforceSecureReception")); + this->setAutoUpdateConfigFile(this->GetOptionAsBool("AutoUpdateConfigFile")); + this->setReloadAfterUpdate(this->GetOptionAsString("ReloadAfterUpdate")); + this->setLanguage(this->GetOptionAsString("Language")); + this->setIncludeInstanceLabels(this->GetOptionAsBool("IncludeInstanceLabels")); + this->m_updating = false; + return true; +} + +void QTOZWOptions_Internal::pvt_ConfigPathChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("ConfigPath", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_UserPathChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("UserPath", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_LoggingChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("Logging", value); +} +void QTOZWOptions_Internal::pvt_LogFileNameChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("LogFileName", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_AppendLogFileChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("AppendLogFile", value); +} +void QTOZWOptions_Internal::pvt_ConsoleOutputChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("ConsoleOutput", value); +} +void QTOZWOptions_Internal::pvt_SaveLogLevelChanged(qint32 value) { + if (this->m_updating) + return; + this->m_options->AddOptionInt("SaveLogLevel", value); +} +void QTOZWOptions_Internal::pvt_QueueLogLevelChanged(qint32 value) { + if (this->m_updating) + return; + this->m_options->AddOptionInt("QueueLogLevel", value); +} +void QTOZWOptions_Internal::pvt_DumpTriggerLevelChanged(qint32 value) { + if (this->m_updating) + return; + this->m_options->AddOptionInt("DumpTriggerLevel", value); +} +void QTOZWOptions_Internal::pvt_AssociateChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("Associate", value); +} +void QTOZWOptions_Internal::pvt_ExcludeChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("Exclude", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_IncludeChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("Include", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_NotifyTransactionChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("NotifyTransaction", value); +} +void QTOZWOptions_Internal::pvt_InterfaceChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("Interface", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_SaveConfigurationChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("SaveConfiguration", value); +} +void QTOZWOptions_Internal::pvt_DriverMaxAttemptsChanged(qint32 value) { + if (this->m_updating) + return; + this->m_options->AddOptionInt("DriverMaxAttempts", value); +} +void QTOZWOptions_Internal::pvt_PollIntervalChanged(qint32 value) { + if (this->m_updating) + return; + this->m_options->AddOptionInt("PollInterval", value); +} +void QTOZWOptions_Internal::pvt_IntervalBetweenPollsChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("IntervalBetweenPolls", value); +} +void QTOZWOptions_Internal::pvt_SuppressValueRefreshChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("SuppressValueRefresh", value); +} +void QTOZWOptions_Internal::pvt_PerformReturnRoutesChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("PerformReturnRoutes", value); +} +void QTOZWOptions_Internal::pvt_NetworkKeyChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("NetworkKey", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_RefreshAllUserCodesChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("RefreshAllUserCodes", value); +} +void QTOZWOptions_Internal::pvt_RetryTimeoutChanged(qint32 value) { + if (this->m_updating) + return; + this->m_options->AddOptionInt("RetryTimeout", value); +} +void QTOZWOptions_Internal::pvt_EnableSISChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("EnableSIS", value); +} +void QTOZWOptions_Internal::pvt_AssumeAwakeChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("AssumeAwake", value); +} +void QTOZWOptions_Internal::pvt_NotifyOnDriverUnloadChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("NotifyOnDriverUnload", value); +} +void QTOZWOptions_Internal::pvt_SecurityStrategyChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("SecurityStrategy", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_CustomSecuredCCChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("CustomSecuredCC", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_EnforceSecureReceptionChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("EnforceSecureReception", value); +} +void QTOZWOptions_Internal::pvt_AutoUpdateConfigFileChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("AutoUpdateConfigFile", value); +} +void QTOZWOptions_Internal::pvt_ReloadAfterUpdateChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("ReloadAfterUpdate", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_LanguageChanged(QString value) { + if (this->m_updating) + return; + this->m_options->AddOptionString("Language", value.toStdString(), false); +} +void QTOZWOptions_Internal::pvt_IncludeInstanceLabelsChanged(bool value) { + if (this->m_updating) + return; + this->m_options->AddOptionBool("IncludeInstanceLabels", value); +} + diff --git a/simpleclient/main.cpp b/simpleclient/main.cpp index 6b8670e..221ee38 100644 --- a/simpleclient/main.cpp +++ b/simpleclient/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char **argv) { -#if 1 +#if 0 QLoggingCategory::setFilterRules("qt.remoteobjects.debug=true\n" "qt.remoteobjects.warning=true\n" "qt.remoteobjects.models.debug=true\n" diff --git a/simpleclient/mainwindow.cpp b/simpleclient/mainwindow.cpp index 6090585..517333f 100644 --- a/simpleclient/mainwindow.cpp +++ b/simpleclient/mainwindow.cpp @@ -14,7 +14,7 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); qDebug() << "Starting MainWindow"; - this->m_openzwave = new QTOpenZwave(this); + this->m_openzwave = new QTOpenZwave(this, QDir("./config/")); this->m_qtozwmanager = this->m_openzwave->GetManager(); qDebug() << "QTOpenZWave Managers Created"; QObject::connect(this->m_qtozwmanager, &QTOZWManager::ready, this, &MainWindow::QTOZW_Ready); diff --git a/simpleclient/simpleclient.pro b/simpleclient/simpleclient.pro index 4b4b67e..d036729 100644 --- a/simpleclient/simpleclient.pro +++ b/simpleclient/simpleclient.pro @@ -33,8 +33,6 @@ HEADERS += \ qtozw_itemdelegate.h \ startup.h -DISTFILES += - RESOURCES += \ simpleclient.qrc @@ -43,6 +41,12 @@ macx { QMAKE_CXXFLAGS += -F../qt-openzwave/ LIBS += -F../qt-openzwave/ -framework qt-openzwave ICON = res/ozw_logo.icns + BUNDLE.files = ../qt-openzwave/qt-openzwave.framework/ + BUNDLE.path = Contents/Frameworks/qt-openzwave.framework/ + LIBOZW.files = ../../open-zwave/libopenzwave-1.6.dylib + LIBOZW.path = Contents/Frameworks/ + QMAKE_BUNDLE_DATA += BUNDLE LIBOZW + } else { LIBS += -L../qt-openzwave/ -lqt-openzwave INCLUDEPATH += ../qt-openzwave/qt-openzwave/include/