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

0001 /* SPDX-FileCopyrightText: 2020 Casper Meijn <casper@meijn.net>
0002  * SPDX-License-Identifier: GPL-3.0-or-later
0003  *
0004  */
0005 
0006 #include "wsdiscoveryserviceaggregator.h"
0007 #include "wsdiscoveryserviceaggregator_p.h"
0008 
0009 WSDiscoveryServiceAggregator::WSDiscoveryServiceAggregator(QObject *parent)
0010     : QObject(parent)
0011     , d_ptr(new WSDiscoveryServiceAggregatorPrivate())
0012 {
0013 }
0014 
0015 WSDiscoveryServiceAggregator::~WSDiscoveryServiceAggregator()
0016 {
0017     delete d_ptr;
0018 }
0019 
0020 void WSDiscoveryServiceAggregator::updateService(const WSDiscoveryTargetService &receivedService)
0021 {
0022     Q_D(WSDiscoveryServiceAggregator);
0023     auto endpointReference = receivedService.endpointReference();
0024     auto aggregatedService = d->targetServiceMap.value(endpointReference);
0025     if (aggregatedService.isNull()) {
0026         aggregatedService = QSharedPointer<WSDiscoveryTargetService>::create(endpointReference);
0027         d->targetServiceMap.insert(endpointReference, aggregatedService);
0028     }
0029     aggregatedService->setTypeList(receivedService.typeList());
0030     aggregatedService->setScopeList(receivedService.scopeList());
0031     aggregatedService->setXAddrList(receivedService.xAddrList());
0032     aggregatedService->setLastSeen(receivedService.lastSeen());
0033     ;
0034     emit serviceUpdated(aggregatedService);
0035 }