File indexing completed on 2024-05-19 04:43:11

0001 /* SPDX-FileCopyrightText: 2019 Casper Meijn <casper@meijn.net>
0002  * SPDX-License-Identifier: GPL-3.0-or-later
0003  *
0004  */
0005 #include "wsdiscoverytargetservice.h"
0006 
0007 class WSDiscoveryTargetServiceData : public QSharedData
0008 {
0009 public:
0010     QString endpointReference;
0011     QList<KDQName> typeList;
0012     QList<QUrl> scopeList;
0013     QList<QUrl> xAddrList;
0014     QDateTime lastSeen;
0015 };
0016 
0017 WSDiscoveryTargetService::WSDiscoveryTargetService()
0018 {
0019     d = new WSDiscoveryTargetServiceData();
0020 }
0021 
0022 WSDiscoveryTargetService::WSDiscoveryTargetService(const QString &endpointReference)
0023 {
0024     d = new WSDiscoveryTargetServiceData();
0025     d->endpointReference = endpointReference;
0026 }
0027 
0028 WSDiscoveryTargetService::WSDiscoveryTargetService(const WSDiscoveryTargetService &other) = default;
0029 WSDiscoveryTargetService::~WSDiscoveryTargetService() = default;
0030 
0031 QDateTime WSDiscoveryTargetService::lastSeen() const
0032 {
0033     return d->lastSeen;
0034 }
0035 
0036 void WSDiscoveryTargetService::setLastSeen(const QDateTime &lastSeen)
0037 {
0038     d->lastSeen = lastSeen;
0039 }
0040 
0041 void WSDiscoveryTargetService::updateLastSeen()
0042 {
0043     setLastSeen(QDateTime::currentDateTime());
0044 }
0045 
0046 bool WSDiscoveryTargetService::isMatchingType(const KDQName &matchingType) const
0047 {
0048     for (const KDQName &type : d->typeList) {
0049         if (matchingType.nameSpace() == type.nameSpace() && matchingType.localName() == type.localName()) {
0050             return true;
0051         }
0052     }
0053     return false;
0054 }
0055 
0056 bool WSDiscoveryTargetService::isMatchingScope(const QUrl &matchingScope) const
0057 {
0058     for (const QUrl &scope : d->scopeList) {
0059         if (matchingScope == scope) {
0060             return true;
0061         }
0062     }
0063     return false;
0064 }
0065 
0066 QList<QUrl> WSDiscoveryTargetService::xAddrList() const
0067 {
0068     return d->xAddrList;
0069 }
0070 
0071 void WSDiscoveryTargetService::setXAddrList(const QList<QUrl> &xAddrList)
0072 {
0073     d->xAddrList = xAddrList;
0074 }
0075 
0076 QList<QUrl> WSDiscoveryTargetService::scopeList() const
0077 {
0078     return d->scopeList;
0079 }
0080 
0081 void WSDiscoveryTargetService::setScopeList(const QList<QUrl> &scopeList)
0082 {
0083     d->scopeList = scopeList;
0084 }
0085 
0086 QList<KDQName> WSDiscoveryTargetService::typeList() const
0087 {
0088     return d->typeList;
0089 }
0090 
0091 void WSDiscoveryTargetService::setTypeList(const QList<KDQName> &typeList)
0092 {
0093     d->typeList = typeList;
0094 }
0095 
0096 QString WSDiscoveryTargetService::endpointReference() const
0097 {
0098     return d->endpointReference;
0099 }
0100 
0101 void WSDiscoveryTargetService::setEndpointReference(const QString &endpointReference)
0102 {
0103     d->endpointReference = endpointReference;
0104 }