blob: ee441ef2b925871a4ba57a8c2a4c5141b582d8de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
59
|
// Copyright (C) 2017 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qremoteobjectregistrysource_p.h"
#include <QtCore/qdatastream.h>
QT_BEGIN_NAMESPACE
QRegistrySource::QRegistrySource(QObject *parent)
: QObject(parent)
{
}
QRegistrySource::~QRegistrySource()
{
}
QRemoteObjectSourceLocations QRegistrySource::sourceLocations() const
{
qCDebug(QT_REMOTEOBJECT) << "sourceLocations property requested on RegistrySource" << m_sourceLocations;
return m_sourceLocations;
}
void QRegistrySource::removeServer(const QUrl &url)
{
for (auto it = m_sourceLocations.begin(), end = m_sourceLocations.end(); it != end; /* erasing */) {
if (it.value().hostUrl == url)
it = m_sourceLocations.erase(it);
else
++it;
}
}
void QRegistrySource::addSource(const QRemoteObjectSourceLocation &entry)
{
qCDebug(QT_REMOTEOBJECT) << "An entry was added to the RegistrySource" << entry;
if (m_sourceLocations.contains(entry.first)) {
if (m_sourceLocations[entry.first].hostUrl == entry.second.hostUrl)
qCWarning(QT_REMOTEOBJECT) << "Node warning: Ignoring Source" << entry.first
<< "as this Node already has a Source by that name.";
else
qCWarning(QT_REMOTEOBJECT) << "Node warning: Ignoring Source" << entry.first
<< "as another source (" << m_sourceLocations[entry.first]
<< ") has already registered that name.";
return;
}
m_sourceLocations[entry.first] = entry.second;
emit remoteObjectAdded(entry);
}
void QRegistrySource::removeSource(const QRemoteObjectSourceLocation &entry)
{
if (m_sourceLocations.contains(entry.first) && m_sourceLocations[entry.first].hostUrl == entry.second.hostUrl) {
m_sourceLocations.remove(entry.first);
emit remoteObjectRemoved(entry);
}
}
QT_END_NAMESPACE
|