Kstars

driverinfo.cpp
1/*
2 SPDX-FileCopyrightText: 2012 Jasem Mutlaq <mutlaqja@ikarustech.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "driverinfo.h"
8
9#include "deviceinfo.h"
10#include "servermanager.h"
11
12#include <basedevice.h>
13
14#include <QDebug>
15
16DriverInfo::DriverInfo(const QString &inName)
17{
18 uniqueLabel.clear();
19 name = inName;
20
21 m_Manufacturer = "Others";
22 hostname = "localhost";
23 port = -1;
24 userPort = -1;
25}
26
27DriverInfo::DriverInfo(DriverInfo *driver)
28{
29 name = driver->getName();
30 label = driver->getLabel();
31 uniqueLabel = driver->getUniqueLabel();
32 exec = driver->getExecutable();
33 version = driver->getVersion();
34 m_Manufacturer = driver->manufacturer();
35 userPort = driver->getUserPort();
36 skelFile = driver->getSkeletonFile();
37 port = driver->getPort();
38 hostname = driver->getHost();
39 remotePort = driver->getRemotePort();
40 remoteHostname = driver->getRemoteHost();
41 type = driver->getType();
42 serverState = driver->getServerState();
43 clientState = driver->getClientState();
44 driverSource = driver->getDriverSource();
45 serverManager = driver->getServerManager();
46 clientManager = driver->getClientManager();
47 auxInfo = driver->getAuxInfo();
48 devices = driver->getDevices();
49}
50
51QSharedPointer<DriverInfo> DriverInfo::clone(bool resetClone)
52{
54 if (resetClone)
55 {
56 clone->reset();
57 clone->resetDevices();
58 }
59 return clone;
60}
61
62DriverInfo::~DriverInfo()
63{
64 qDeleteAll(devices);
65}
66
67void DriverInfo::reset()
68{
69 serverState = false;
70 clientState = false;
71 serverManager = nullptr;
72 clientManager = nullptr;
73}
74
75QString DriverInfo::getServerBuffer() const
76{
77 if (serverManager != nullptr)
78 return serverManager->getLogBuffer();
79
80 return QString();
81}
82
83void DriverInfo::setServerState(bool inState)
84{
85 if (inState == serverState)
86 return;
87
88 serverState = inState;
89
90 if (serverState == false)
91 serverManager = nullptr;
92
93 emit deviceStateChanged();
94}
95
96void DriverInfo::setClientState(bool inState)
97{
98 if (inState == clientState)
99 return;
100
101 clientState = inState;
102
103 if (clientState == false)
104 clientManager = nullptr;
105
106 emit deviceStateChanged();
107}
108
109void DriverInfo::addDevice(DeviceInfo *idv)
110{
111 devices.append(idv);
112}
113
114void DriverInfo::removeDevice(DeviceInfo *idv)
115{
116 devices.removeOne(idv);
117 delete (idv);
118}
119
120DeviceInfo *DriverInfo::getDevice(const QString &deviceName) const
121{
122 foreach (DeviceInfo *idv, devices)
123 {
124 if (idv->getDeviceName() == deviceName)
125 return idv;
126 }
127
128 return nullptr;
129}
130QVariantMap DriverInfo::getAuxInfo() const
131{
132 return auxInfo;
133}
134
135void DriverInfo::setAuxInfo(const QVariantMap &value)
136{
137 auxInfo = value;
138}
139
140void DriverInfo::addAuxInfo(const QString &key, const QVariant &value)
141{
142 auxInfo[key] = value;
143}
144
145QString DriverInfo::manufacturer() const
146{
147 return m_Manufacturer;
148}
149
150void DriverInfo::setManufacturer(const QString &Manufacturer)
151{
152 m_Manufacturer = Manufacturer;
153}
154
155void DriverInfo::setUniqueLabel(const QString &inUniqueLabel)
156{
157 // N.B. We NEVER set unique label for multiple devices per driver "driver"
158 if (auxInfo.value("mdpd", false).toBool() == true || driverSource >= HOST_SOURCE)
159 return;
160
161 uniqueLabel = inUniqueLabel;
162}
163
164QJsonObject DriverInfo::startupRule() const
165{
166 return m_StartupRule;
167}
168
169void DriverInfo::setStartupRule(const QJsonObject &value)
170{
171 m_StartupRule = value;
172}
DeviceInfo is simple class to hold DriverInfo and INDI::BaseDevice associated with a particular devic...
Definition deviceinfo.h:21
DriverInfo holds all metadata associated with a particular INDI driver.
Definition driverinfo.h:46
void append(QList< T > &&value)
bool removeOne(const AT &t)
void clear()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.