From 11787ea278bc6ff6d5bc797b597df3f26e2ec9b4 Mon Sep 17 00:00:00 2001 From: Daniel Teichmann Date: Tue, 6 Jul 2021 19:55:13 +0200 Subject: Introduce DBusAPI and RWAHost classes --- src/RWAHost.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/RWAHost.cpp (limited to 'src/RWAHost.cpp') diff --git a/src/RWAHost.cpp b/src/RWAHost.cpp new file mode 100644 index 0000000..006ecd9 --- /dev/null +++ b/src/RWAHost.cpp @@ -0,0 +1,71 @@ +/* + * This file is part of Remote Support Desktop + * https://gitlab.das-netzwerkteam.de/RemoteWebApp/rwa.support.desktopapp + * Copyright 2021 Daniel Teichmann + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "RWAHost.h" + +RWAHost::RWAHost(QString uuid, QString alias, QString url) { + assert(uuid != ""); + assert(alias != ""); + assert(url != ""); + + qDebug() << "Created new RWAHost object.\n\t" + << QString("uuid: '%0'").arg(uuid) << "\n\t" + << QString("alias: '%0'").arg(alias) << "\n\t" + << QString("url: '%0'").arg(url); + + _url = url; + _alias = alias; + _uuid = uuid; +} + +QString RWAHost::url() const +{ + return _url; +} + +void RWAHost::setUrl(const QString &url) +{ + _url = url; +} + +QString RWAHost::alias() const +{ + return _alias; +} + +void RWAHost::setAlias(const QString &alias) +{ + _alias = alias; +} + +QString RWAHost::uuid() const +{ + return _uuid; +} + +void RWAHost::setUuid(const QString &uuid) +{ + _uuid = uuid; +} -- cgit v1.2.3 From 9d3405f5e94e21e4401c30808dc3c93f6fbd3283 Mon Sep 17 00:00:00 2001 From: Daniel Teichmann Date: Wed, 7 Jul 2021 15:40:58 +0200 Subject: RWAHost is now an QObject available to QML. --- src/RWAHost.cpp | 33 +++++++++++++++------------------ src/RWAHost.h | 28 +++++++++++++++++----------- 2 files changed, 32 insertions(+), 29 deletions(-) (limited to 'src/RWAHost.cpp') diff --git a/src/RWAHost.cpp b/src/RWAHost.cpp index 006ecd9..cc25b57 100644 --- a/src/RWAHost.cpp +++ b/src/RWAHost.cpp @@ -40,32 +40,29 @@ RWAHost::RWAHost(QString uuid, QString alias, QString url) { _uuid = uuid; } -QString RWAHost::url() const -{ - return _url; +QString RWAHost::uuid() const { + return _uuid; } -void RWAHost::setUrl(const QString &url) -{ - _url = url; +QString RWAHost::alias() const { + return _alias; } -QString RWAHost::alias() const -{ - return _alias; +QString RWAHost::url() const { + return _url; } -void RWAHost::setAlias(const QString &alias) -{ - _alias = alias; +void RWAHost::setUuid(const QString &uuid) { + _uuid = uuid; + emit uuidChanged(uuid); } -QString RWAHost::uuid() const -{ - return _uuid; +void RWAHost::setAlias(const QString &alias) { + _alias = alias; + emit aliasChanged(alias); } -void RWAHost::setUuid(const QString &uuid) -{ - _uuid = uuid; +void RWAHost::setUrl(const QString &url) { + _url = url; + emit urlChanged(url); } diff --git a/src/RWAHost.h b/src/RWAHost.h index c78ef5f..58b6d45 100644 --- a/src/RWAHost.h +++ b/src/RWAHost.h @@ -29,19 +29,14 @@ #include #include -class RWAHost : public QObject -{ +class RWAHost : public QObject { Q_OBJECT -public: - explicit RWAHost(QString uuid = "", QString alias = "", QString url = ""); - - QString uuid() const; - QString alias() const; - QString url() const; + Q_PROPERTY(QString uuid READ uuid WRITE setUuid NOTIFY uuidChanged) + Q_PROPERTY(QString alias READ alias WRITE setAlias NOTIFY aliasChanged) + Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged) - void setUuid(const QString &uuid); - void setAlias(const QString &alias); - void setUrl(const QString &url); +public: + RWAHost(QString uuid = "", QString alias = "", QString url = ""); private: QString _uuid; @@ -49,8 +44,19 @@ private: QString _url; signals: + void uuidChanged(QString uuid); + void aliasChanged(QString alias); + void urlChanged(QString url); public slots: + QString uuid() const; + QString alias() const; + QString url() const; + + void setUuid(const QString &uuid); + void setAlias(const QString &alias); + void setUrl(const QString &url); + }; #endif // RWAHOST_H -- cgit v1.2.3 From afafc8ff96e486e9f903c643945832bee11659a1 Mon Sep 17 00:00:00 2001 From: Daniel Teichmann Date: Mon, 12 Jul 2021 12:51:27 +0200 Subject: Make RWAHost object creation silent again. --- src/RWAHost.cpp | 4 ++-- src/RWAHost.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/RWAHost.cpp') diff --git a/src/RWAHost.cpp b/src/RWAHost.cpp index cc25b57..f31dc60 100644 --- a/src/RWAHost.cpp +++ b/src/RWAHost.cpp @@ -30,10 +30,10 @@ RWAHost::RWAHost(QString uuid, QString alias, QString url) { assert(alias != ""); assert(url != ""); - qDebug() << "Created new RWAHost object.\n\t" + /*qDebug() << "Created new RWAHost object.\n\t" << QString("uuid: '%0'").arg(uuid) << "\n\t" << QString("alias: '%0'").arg(alias) << "\n\t" - << QString("url: '%0'").arg(url); + << QString("url: '%0'").arg(url);*/ _url = url; _alias = alias; diff --git a/src/RWAHost.h b/src/RWAHost.h index 58b6d45..cd3b1ce 100644 --- a/src/RWAHost.h +++ b/src/RWAHost.h @@ -37,6 +37,7 @@ class RWAHost : public QObject { public: RWAHost(QString uuid = "", QString alias = "", QString url = ""); + RWAHost(const RWAHost&); private: QString _uuid; -- cgit v1.2.3