37 #include <QtCore/QtPlugin>
38 #include <QMainWindow>
39 #include <QMessageBox>
40 #include <QtNetwork/QAbstractSocket>
41 #include <QtNetwork/QTcpSocket>
42 #include <QtNetwork/QUdpSocket>
79 const auto &newHosts = m_config->
hosts();
82 for (
const auto &host : newHosts) {
84 for (
auto dev : devices) {
85 if (static_cast<const IPDevice *>(dev)->host() == host) {
97 dev->setDisplayName(name);
105 for (
int i = 0;
i < devices.length();) {
106 if (!newHosts.contains(static_cast<const IPDevice *>(devices.at(
i))->host())) {
107 devices.at(
i)->deleteLater();
119 auto *dev = qobject_cast<
IPDevice *>(device);
123 const int timeout = 5 * 1000;
126 ipSocket =
new QTcpSocket(
this);
128 ipSocket =
new QUdpSocket(
this);
133 ipSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
138 ipSocket->bind(0, QAbstractSocket::ShareAddress);
141 if (!dev->host().hostname.length() || dev->host().port < 1 || dev->host().port > 65535) {
142 errorMsg = tr(
"Please configure host and port options before opening the connection");
145 ipSocket->connectToHost(dev->host().hostname,
static_cast<quint16
>(dev->host().port));
148 if (ipSocket->waitForConnected(timeout)) {
153 errorMsg = ipSocket->errorString();
158 QMessageBox msgBox(QMessageBox::Critical, tr(
"Connection Failed"), errorMsg,
178 return QString(
"Network telemetry port");
186 IPConnectionPlugin::IPConnectionPlugin()
190 IPConnectionPlugin::~IPConnectionPlugin()
195 void IPConnectionPlugin::extensionsInitialized()
200 bool IPConnectionPlugin::initialize(
const QStringList &arguments, QString *errorString)
203 Q_UNUSED(errorString);
void availableDevChanged(IConnection *)
QVector< Host > & hosts()
void availableDevChanged()
void addObject(QObject *obj)
void onEnumerationChanged()
virtual QIODevice * openDevice(Core::IDevice *deviceName)
virtual QList< Core::IDevice * > availableDevices()
virtual QString shortName()
IPConnectionOptionsPage * optionsPage() const
static ICore * instance()
void removeObject(QObject *obj)
IPConnection * connection
virtual void closeDevice(const QString &deviceName)
void addAutoReleasedObject(QObject *obj)
virtual QString connectionName()