void LanLinkProvider::onNetworkConfigurationChanged(const QNetworkConfiguration &config) { if (m_lastConfig != config && config.state() == QNetworkConfiguration::Active) { m_lastConfig = config; onNetworkChange(); } }
void LanLinkProvider::onStart() { mUdpServer->bind(QHostAddress::Any, port, QUdpSocket::ShareAddress); mTcpPort = port; while (!mTcpServer->listen(QHostAddress::Any, mTcpPort)) { mTcpPort++; if (mTcpPort > 1764) { //No ports available? qCritical(KDECONNECT_CORE) << "Error opening a port in range 1714-1764"; mTcpPort = 0; return; } } onNetworkChange(); }
LanLinkProvider::LanLinkProvider() { mTcpPort = 0; mUdpServer = new QUdpSocket(this); connect(mUdpServer, SIGNAL(readyRead()), this, SLOT(newUdpConnection())); mTcpServer = new QTcpServer(this); connect(mTcpServer,SIGNAL(newConnection()),this, SLOT(newConnection())); //Detect when a network interface changes status, so we announce ourelves in the new network QNetworkConfigurationManager* networkManager; networkManager = new QNetworkConfigurationManager(this); connect(networkManager, &QNetworkConfigurationManager::configurationChanged, [this, networkManager](QNetworkConfiguration config) { Q_UNUSED(config); //qCDebug(KDECONNECT_CORE) << config.name() << " state changed to " << config.state(); //qCDebug(KDECONNECT_CORE) << "Online status: " << (networkManager->isOnline()? "online":"offline"); onNetworkChange(); }); }
void LanLinkProvider::onStart() { const QHostAddress bindAddress = mTestMode? QHostAddress::LocalHost : QHostAddress::Any; bool success = mUdpSocket.bind(bindAddress, port, QUdpSocket::ShareAddress); Q_ASSERT(success); qCDebug(KDECONNECT_CORE) << "onStart"; mTcpPort = port; while (!mServer->listen(bindAddress, mTcpPort)) { mTcpPort++; if (mTcpPort > 1764) { //No ports available? qCritical(KDECONNECT_CORE) << "Error opening a port in range 1714-1764"; mTcpPort = 0; return; } } onNetworkChange(); }
void LoopbackLinkProvider::onStart() { onNetworkChange(); }