basic networkmanager functionality
This commit is contained in:
parent
661e0a5116
commit
642b5c8331
2
debian/control
vendored
2
debian/control
vendored
@ -19,6 +19,7 @@ Build-Depends: debhelper (>= 9.0.0),
|
|||||||
libqt5websockets5-dev,
|
libqt5websockets5-dev,
|
||||||
libqt5bluetooth5,
|
libqt5bluetooth5,
|
||||||
libqt5sql5-sqlite,
|
libqt5sql5-sqlite,
|
||||||
|
libqt5dbus5,
|
||||||
libavahi-client-dev,
|
libavahi-client-dev,
|
||||||
libavahi-common-dev
|
libavahi-common-dev
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ Depends: libqt5network5,
|
|||||||
libqt5gui5,
|
libqt5gui5,
|
||||||
libqt5sql5,
|
libqt5sql5,
|
||||||
libqt5xml5,
|
libqt5xml5,
|
||||||
|
libqt5dbus5,
|
||||||
libqt5websockets5,
|
libqt5websockets5,
|
||||||
libqt5bluetooth5,
|
libqt5bluetooth5,
|
||||||
logrotate,
|
logrotate,
|
||||||
|
|||||||
2
guh.pri
2
guh.pri
@ -9,7 +9,7 @@ DEFINES += GUH_VERSION_STRING=\\\"$${GUH_VERSION_STRING}\\\" \
|
|||||||
JSON_PROTOCOL_VERSION=\\\"$${JSON_PROTOCOL_VERSION}\\\" \
|
JSON_PROTOCOL_VERSION=\\\"$${JSON_PROTOCOL_VERSION}\\\" \
|
||||||
REST_API_VERSION=\\\"$${REST_API_VERSION}\\\"
|
REST_API_VERSION=\\\"$${REST_API_VERSION}\\\"
|
||||||
|
|
||||||
QT+= network websockets bluetooth
|
QT *= network websockets bluetooth dbus
|
||||||
|
|
||||||
QMAKE_CXXFLAGS *= -Werror -std=c++11 -g
|
QMAKE_CXXFLAGS *= -Werror -std=c++11 -g
|
||||||
QMAKE_LFLAGS *= -std=c++11
|
QMAKE_LFLAGS *= -std=c++11
|
||||||
|
|||||||
4
guh.pro
4
guh.pro
@ -35,8 +35,8 @@ test.commands = LD_LIBRARY_PATH=$$top_builddir/libguh:$$top_builddir/tests/libgu
|
|||||||
QMAKE_EXTRA_TARGETS += licensecheck doc test
|
QMAKE_EXTRA_TARGETS += licensecheck doc test
|
||||||
|
|
||||||
# Inform about guh build
|
# Inform about guh build
|
||||||
message("--------------------------------------")
|
message(============================================)
|
||||||
message(Qt version: $$[QT_VERSION])
|
message("Qt version:" $$[QT_VERSION])
|
||||||
message("Building guh version $${GUH_VERSION_STRING}")
|
message("Building guh version $${GUH_VERSION_STRING}")
|
||||||
message("JSON-RPC API version $${JSON_PROTOCOL_VERSION}")
|
message("JSON-RPC API version $${JSON_PROTOCOL_VERSION}")
|
||||||
message("REST API version $${REST_API_VERSION}")
|
message("REST API version $${REST_API_VERSION}")
|
||||||
|
|||||||
@ -209,8 +209,9 @@ DeviceManager::DeviceManager(const QLocale &locale, QObject *parent) :
|
|||||||
m_radio433 = new Radio433(this);
|
m_radio433 = new Radio433(this);
|
||||||
m_radio433->enable();
|
m_radio433->enable();
|
||||||
|
|
||||||
m_networkManager = new NetworkManager(this);
|
// Network manager
|
||||||
connect(m_networkManager, &NetworkManager::replyReady, this, &DeviceManager::replyReady);
|
m_networkManager = new NetworkAccessManager(this);
|
||||||
|
connect(m_networkManager, &NetworkAccessManager::replyReady, this, &DeviceManager::replyReady);
|
||||||
|
|
||||||
// UPnP discovery
|
// UPnP discovery
|
||||||
m_upnpDiscovery = new UpnpDiscovery(this);
|
m_upnpDiscovery = new UpnpDiscovery(this);
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
#include "types/action.h"
|
#include "types/action.h"
|
||||||
#include "types/vendor.h"
|
#include "types/vendor.h"
|
||||||
|
|
||||||
#include "network/networkmanager.h"
|
#include "network/networkaccessmanager.h"
|
||||||
#include "network/upnp/upnpdiscovery.h"
|
#include "network/upnp/upnpdiscovery.h"
|
||||||
#include "network/upnp/upnpdevicedescriptor.h"
|
#include "network/upnp/upnpdevicedescriptor.h"
|
||||||
#include "network/avahi/qtavahiservicebrowser.h"
|
#include "network/avahi/qtavahiservicebrowser.h"
|
||||||
@ -206,7 +206,7 @@ private:
|
|||||||
Radio433* m_radio433;
|
Radio433* m_radio433;
|
||||||
QTimer m_pluginTimer;
|
QTimer m_pluginTimer;
|
||||||
QList<DevicePlugin *> m_pluginTimerUsers;
|
QList<DevicePlugin *> m_pluginTimerUsers;
|
||||||
NetworkManager *m_networkManager;
|
NetworkAccessManager *m_networkManager;
|
||||||
UpnpDiscovery* m_upnpDiscovery;
|
UpnpDiscovery* m_upnpDiscovery;
|
||||||
QtAvahiServiceBrowser *m_avahiBrowser;
|
QtAvahiServiceBrowser *m_avahiBrowser;
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ HEADERS += devicemanager.h \
|
|||||||
network/upnp/upnpdevice.h \
|
network/upnp/upnpdevice.h \
|
||||||
network/upnp/upnpdevicedescriptor.h \
|
network/upnp/upnpdevicedescriptor.h \
|
||||||
network/upnp/upnpdiscoveryrequest.h \
|
network/upnp/upnpdiscoveryrequest.h \
|
||||||
network/networkmanager.h \
|
network/networkaccessmanager.h \
|
||||||
network/oauth2.h \
|
network/oauth2.h \
|
||||||
network/avahi/qt-watch.h \
|
network/avahi/qt-watch.h \
|
||||||
network/avahi/avahiserviceentry.h \
|
network/avahi/avahiserviceentry.h \
|
||||||
@ -95,7 +95,7 @@ SOURCES += devicemanager.cpp \
|
|||||||
network/upnp/upnpdevice.cpp \
|
network/upnp/upnpdevice.cpp \
|
||||||
network/upnp/upnpdevicedescriptor.cpp \
|
network/upnp/upnpdevicedescriptor.cpp \
|
||||||
network/upnp/upnpdiscoveryrequest.cpp \
|
network/upnp/upnpdiscoveryrequest.cpp \
|
||||||
network/networkmanager.cpp \
|
network/networkaccessmanager.cpp \
|
||||||
network/oauth2.cpp \
|
network/oauth2.cpp \
|
||||||
network/avahi/qt-watch.cpp \
|
network/avahi/qt-watch.cpp \
|
||||||
network/avahi/avahiserviceentry.cpp \
|
network/avahi/avahiserviceentry.cpp \
|
||||||
|
|||||||
@ -35,3 +35,4 @@ Q_LOGGING_CATEGORY(dcRest, "Rest")
|
|||||||
Q_LOGGING_CATEGORY(dcOAuth2, "OAuth2")
|
Q_LOGGING_CATEGORY(dcOAuth2, "OAuth2")
|
||||||
Q_LOGGING_CATEGORY(dcAvahi, "Avahi")
|
Q_LOGGING_CATEGORY(dcAvahi, "Avahi")
|
||||||
Q_LOGGING_CATEGORY(dcCloud, "Cloud")
|
Q_LOGGING_CATEGORY(dcCloud, "Cloud")
|
||||||
|
Q_LOGGING_CATEGORY(dcNetworkManager, "NetworkManager")
|
||||||
|
|||||||
@ -43,5 +43,6 @@ Q_DECLARE_LOGGING_CATEGORY(dcRest)
|
|||||||
Q_DECLARE_LOGGING_CATEGORY(dcOAuth2)
|
Q_DECLARE_LOGGING_CATEGORY(dcOAuth2)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(dcAvahi)
|
Q_DECLARE_LOGGING_CATEGORY(dcAvahi)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(dcCloud)
|
Q_DECLARE_LOGGING_CATEGORY(dcCloud)
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(dcNetworkManager)
|
||||||
|
|
||||||
#endif // LOGGINGCATEGORYS_H
|
#endif // LOGGINGCATEGORYS_H
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class NetworkManager
|
\class NetworkAccessManager
|
||||||
\brief Allows to send network requests and receive replies.
|
\brief Allows to send network requests and receive replies.
|
||||||
|
|
||||||
\ingroup hardware
|
\ingroup hardware
|
||||||
@ -30,21 +30,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \fn NetworkManager::replyReady(const PluginId &pluginId, QNetworkReply *reply)
|
* \fn NetworkAccessManager::replyReady(const PluginId &pluginId, QNetworkReply *reply)
|
||||||
* This signal will be emitted whenever a pending network \a reply for the plugin with the given \a pluginId is finished.
|
* This signal will be emitted whenever a pending network \a reply for the plugin with the given \a pluginId is finished.
|
||||||
*
|
*
|
||||||
* \sa DevicePlugin::networkManagerReplyReady()
|
* \sa DevicePlugin::networkManagerReplyReady()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "networkmanager.h"
|
#include "networkaccessmanager.h"
|
||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
/*! Construct the hardware resource NetworkManager with the given \a parent. */
|
/*! Construct the hardware resource NetworkAccessManager with the given \a parent. */
|
||||||
NetworkManager::NetworkManager(QObject *parent) :
|
NetworkAccessManager::NetworkAccessManager(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
m_manager = new QNetworkAccessManager(this);
|
m_manager = new QNetworkAccessManager(this);
|
||||||
connect(m_manager, &QNetworkAccessManager::finished, this, &NetworkManager::replyFinished);
|
connect(m_manager, &QNetworkAccessManager::finished, this, &NetworkAccessManager::replyFinished);
|
||||||
|
|
||||||
qCDebug(dcDeviceManager) << "--> Network manager created successfully.";
|
qCDebug(dcDeviceManager) << "--> Network manager created successfully.";
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ NetworkManager::NetworkManager(QObject *parent) :
|
|||||||
*
|
*
|
||||||
* \sa DevicePlugin::networkManagerGet()
|
* \sa DevicePlugin::networkManagerGet()
|
||||||
*/
|
*/
|
||||||
QNetworkReply *NetworkManager::get(const PluginId &pluginId, const QNetworkRequest &request)
|
QNetworkReply *NetworkAccessManager::get(const PluginId &pluginId, const QNetworkRequest &request)
|
||||||
{
|
{
|
||||||
QNetworkReply *reply = m_manager->get(request);
|
QNetworkReply *reply = m_manager->get(request);
|
||||||
m_replies.insert(reply, pluginId);
|
m_replies.insert(reply, pluginId);
|
||||||
@ -73,7 +73,7 @@ QNetworkReply *NetworkManager::get(const PluginId &pluginId, const QNetworkReque
|
|||||||
*
|
*
|
||||||
* \sa DevicePlugin::networkManagerPost()
|
* \sa DevicePlugin::networkManagerPost()
|
||||||
*/
|
*/
|
||||||
QNetworkReply *NetworkManager::post(const PluginId &pluginId, const QNetworkRequest &request, const QByteArray &data)
|
QNetworkReply *NetworkAccessManager::post(const PluginId &pluginId, const QNetworkRequest &request, const QByteArray &data)
|
||||||
{
|
{
|
||||||
QNetworkReply *reply = m_manager->post(request, data);
|
QNetworkReply *reply = m_manager->post(request, data);
|
||||||
m_replies.insert(reply, pluginId);
|
m_replies.insert(reply, pluginId);
|
||||||
@ -87,14 +87,14 @@ QNetworkReply *NetworkManager::post(const PluginId &pluginId, const QNetworkRequ
|
|||||||
*
|
*
|
||||||
* \sa DevicePlugin::networkManagerPut()
|
* \sa DevicePlugin::networkManagerPut()
|
||||||
*/
|
*/
|
||||||
QNetworkReply *NetworkManager::put(const PluginId &pluginId, const QNetworkRequest &request, const QByteArray &data)
|
QNetworkReply *NetworkAccessManager::put(const PluginId &pluginId, const QNetworkRequest &request, const QByteArray &data)
|
||||||
{
|
{
|
||||||
QNetworkReply *reply = m_manager->put(request, data);
|
QNetworkReply *reply = m_manager->put(request, data);
|
||||||
m_replies.insert(reply, pluginId);
|
m_replies.insert(reply, pluginId);
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkManager::replyFinished(QNetworkReply *reply)
|
void NetworkAccessManager::replyFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
// NOTE: Each plugin has to delete his own replys with deleteLater()!!
|
// NOTE: Each plugin has to delete his own replys with deleteLater()!!
|
||||||
// NOTE: also the reply->error() has to be handled in each plugin!!
|
// NOTE: also the reply->error() has to be handled in each plugin!!
|
||||||
@ -18,8 +18,8 @@
|
|||||||
* *
|
* *
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#ifndef NETWORKMANAGER_H
|
#ifndef NETWORKACCESSMANAGER_H
|
||||||
#define NETWORKMANAGER_H
|
#define NETWORKACCESSMANAGER_H
|
||||||
|
|
||||||
#include "libguh.h"
|
#include "libguh.h"
|
||||||
#include "typeutils.h"
|
#include "typeutils.h"
|
||||||
@ -31,11 +31,11 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
class LIBGUH_EXPORT NetworkManager : public QObject
|
class LIBGUH_EXPORT NetworkAccessManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NetworkManager(QObject *parent = 0);
|
explicit NetworkAccessManager(QObject *parent = 0);
|
||||||
|
|
||||||
QNetworkReply *get(const PluginId &pluginId, const QNetworkRequest &request);
|
QNetworkReply *get(const PluginId &pluginId, const QNetworkRequest &request);
|
||||||
QNetworkReply *post(const PluginId &pluginId, const QNetworkRequest &request, const QByteArray &data);
|
QNetworkReply *post(const PluginId &pluginId, const QNetworkRequest &request, const QByteArray &data);
|
||||||
@ -53,4 +53,4 @@ private slots:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NETWORKMANAGER_H
|
#endif // NETWORKACCESSMANAGER_H
|
||||||
@ -77,7 +77,7 @@
|
|||||||
\note Only if if the plugin has requested the \l{DeviceManager::HardwareResourceNetworkManager}
|
\note Only if if the plugin has requested the \l{DeviceManager::HardwareResourceNetworkManager}
|
||||||
resource using \l{DevicePlugin::requiredHardware()}, this slot will be called.
|
resource using \l{DevicePlugin::requiredHardware()}, this slot will be called.
|
||||||
|
|
||||||
\sa NetworkManager::replyReady()
|
\sa NetworkAccessManager::replyReady()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -818,7 +818,7 @@ bool DevicePlugin::transmitData(int delay, QList<int> rawData, int repetitions)
|
|||||||
*
|
*
|
||||||
* \note The plugin has to delete the QNetworkReply with the function deleteLater().
|
* \note The plugin has to delete the QNetworkReply with the function deleteLater().
|
||||||
*
|
*
|
||||||
* \sa NetworkManager::get()
|
* \sa NetworkAccessManager::get()
|
||||||
*/
|
*/
|
||||||
QNetworkReply *DevicePlugin::networkManagerGet(const QNetworkRequest &request)
|
QNetworkReply *DevicePlugin::networkManagerGet(const QNetworkRequest &request)
|
||||||
{
|
{
|
||||||
@ -835,7 +835,7 @@ QNetworkReply *DevicePlugin::networkManagerGet(const QNetworkRequest &request)
|
|||||||
*
|
*
|
||||||
* \note The plugin has to delete the QNetworkReply with the function deleteLater().
|
* \note The plugin has to delete the QNetworkReply with the function deleteLater().
|
||||||
*
|
*
|
||||||
* \sa NetworkManager::post()
|
* \sa NetworkAccessManager::post()
|
||||||
*/
|
*/
|
||||||
QNetworkReply *DevicePlugin::networkManagerPost(const QNetworkRequest &request, const QByteArray &data)
|
QNetworkReply *DevicePlugin::networkManagerPost(const QNetworkRequest &request, const QByteArray &data)
|
||||||
{
|
{
|
||||||
@ -851,7 +851,7 @@ QNetworkReply *DevicePlugin::networkManagerPost(const QNetworkRequest &request,
|
|||||||
*
|
*
|
||||||
* \note The plugin has to delete the QNetworkReply with the function deleteLater().
|
* \note The plugin has to delete the QNetworkReply with the function deleteLater().
|
||||||
*
|
*
|
||||||
* \sa NetworkManager::put()
|
* \sa NetworkAccessManager::put()
|
||||||
*/
|
*/
|
||||||
QNetworkReply *DevicePlugin::networkManagerPut(const QNetworkRequest &request, const QByteArray &data)
|
QNetworkReply *DevicePlugin::networkManagerPut(const QNetworkRequest &request, const QByteArray &data)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,7 +48,7 @@ DevicePluginOrderButton::DevicePluginOrderButton()
|
|||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginOrderButton::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginOrderButton::requiredHardware() const
|
||||||
{
|
{
|
||||||
// We need the NetworkManager for node discovery and the timer for ping requests
|
// We need the NetworkAccessManager for node discovery and the timer for ping requests
|
||||||
return DeviceManager::HardwareResourceNetworkManager | DeviceManager::HardwareResourceTimer;
|
return DeviceManager::HardwareResourceNetworkManager | DeviceManager::HardwareResourceTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ DevicePluginPlantCare::DevicePluginPlantCare()
|
|||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginPlantCare::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginPlantCare::requiredHardware() const
|
||||||
{
|
{
|
||||||
// We need the NetworkManager for node discovery and the timer for ping requests
|
// We need the NetworkAccessManager for node discovery and the timer for ping requests
|
||||||
return DeviceManager::HardwareResourceNetworkManager | DeviceManager::HardwareResourceTimer;
|
return DeviceManager::HardwareResourceNetworkManager | DeviceManager::HardwareResourceTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ DevicePluginWs2812::DevicePluginWs2812()
|
|||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginWs2812::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginWs2812::requiredHardware() const
|
||||||
{
|
{
|
||||||
// We need the NetworkManager for node discovery and the timer for ping requests
|
// We need the NetworkAccessManager for node discovery and the timer for ping requests
|
||||||
return DeviceManager::HardwareResourceNetworkManager | DeviceManager::HardwareResourceTimer;
|
return DeviceManager::HardwareResourceNetworkManager | DeviceManager::HardwareResourceTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,6 +99,7 @@
|
|||||||
#include "loggingcategories.h"
|
#include "loggingcategories.h"
|
||||||
#include "jsonrpcserver.h"
|
#include "jsonrpcserver.h"
|
||||||
#include "ruleengine.h"
|
#include "ruleengine.h"
|
||||||
|
#include "networkmanager/networkmanager.h"
|
||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "plugin/device.h"
|
#include "plugin/device.h"
|
||||||
@ -450,6 +451,7 @@ GuhCore::GuhCore(QObject *parent) :
|
|||||||
m_webServer = new WebServer(m_configuration->webServerAddress(), m_configuration->webServerPort(), m_configuration->webServerPublicFolder(), this);
|
m_webServer = new WebServer(m_configuration->webServerAddress(), m_configuration->webServerPort(), m_configuration->webServerPublicFolder(), this);
|
||||||
m_serverManager->restServer()->registerWebserver(m_webServer);
|
m_serverManager->restServer()->registerWebserver(m_webServer);
|
||||||
|
|
||||||
|
m_networkManager = new NetworkManager(this);
|
||||||
|
|
||||||
// Connect the configuration changes
|
// Connect the configuration changes
|
||||||
connect(m_configuration, &GuhConfiguration::cloudEnabledChanged, m_cloudManager, &CloudManager::onCloudEnabledChanged);
|
connect(m_configuration, &GuhConfiguration::cloudEnabledChanged, m_cloudManager, &CloudManager::onCloudEnabledChanged);
|
||||||
|
|||||||
@ -53,6 +53,7 @@ namespace guhserver {
|
|||||||
|
|
||||||
class JsonRPCServer;
|
class JsonRPCServer;
|
||||||
class LogEngine;
|
class LogEngine;
|
||||||
|
class NetworkManager;
|
||||||
|
|
||||||
class GuhCore : public QObject
|
class GuhCore : public QObject
|
||||||
{
|
{
|
||||||
@ -122,6 +123,9 @@ private:
|
|||||||
RuleEngine *m_ruleEngine;
|
RuleEngine *m_ruleEngine;
|
||||||
LogEngine *m_logger;
|
LogEngine *m_logger;
|
||||||
TimeManager *m_timeManager;
|
TimeManager *m_timeManager;
|
||||||
|
|
||||||
|
NetworkManager *m_networkManager;
|
||||||
|
|
||||||
#ifdef TESTING_ENABLED
|
#ifdef TESTING_ENABLED
|
||||||
MockTcpServer *m_tcpServer;
|
MockTcpServer *m_tcpServer;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@ -129,6 +129,7 @@ int main(int argc, char *argv[])
|
|||||||
s_loggingFilters.insert("Coap", false);
|
s_loggingFilters.insert("Coap", false);
|
||||||
s_loggingFilters.insert("Avahi", false);
|
s_loggingFilters.insert("Avahi", false);
|
||||||
s_loggingFilters.insert("Cloud", true);
|
s_loggingFilters.insert("Cloud", true);
|
||||||
|
s_loggingFilters.insert("NetworkManager", true);
|
||||||
|
|
||||||
QHash<QString, bool> loggingFiltersPlugins;
|
QHash<QString, bool> loggingFiltersPlugins;
|
||||||
foreach (const QJsonObject &pluginMetadata, DeviceManager::pluginsMetadata()) {
|
foreach (const QJsonObject &pluginMetadata, DeviceManager::pluginsMetadata()) {
|
||||||
|
|||||||
40
server/networkmanager/dbus-interfaces.h
Normal file
40
server/networkmanager/dbus-interfaces.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#ifndef DBUSINTERFACES_H
|
||||||
|
#define DBUSINTERFACES_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
static const QString serviceString("org.freedesktop.NetworkManager");
|
||||||
|
|
||||||
|
static const QString pathString("/org/freedesktop/NetworkManager");
|
||||||
|
static const QString settingsPathString("/org/freedesktop/NetworkManager/Settings");
|
||||||
|
|
||||||
|
static const QString deviceInterfaceString("org.freedesktop.NetworkManager.Device");
|
||||||
|
static const QString wirelessInterfaceString("org.freedesktop.NetworkManager.Device.Wireless");
|
||||||
|
static const QString accessPointInterfaceString("org.freedesktop.NetworkManager.AccessPoint");
|
||||||
|
static const QString settingsInterfaceString("org.freedesktop.NetworkManager.Settings");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // DBUSINTERFACES_H
|
||||||
6
server/networkmanager/networkconnection.cpp
Normal file
6
server/networkmanager/networkconnection.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "networkconnection.h"
|
||||||
|
|
||||||
|
NetworkConnection::NetworkConnection(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
17
server/networkmanager/networkconnection.h
Normal file
17
server/networkmanager/networkconnection.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef NETWORKCONNECTION_H
|
||||||
|
#define NETWORKCONNECTION_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class NetworkConnection : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit NetworkConnection(QObject *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NETWORKCONNECTION_H
|
||||||
186
server/networkmanager/networkdevice.cpp
Normal file
186
server/networkmanager/networkdevice.cpp
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#include "networkdevice.h"
|
||||||
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
NetworkDevice::NetworkDevice(const QDBusObjectPath &objectPath, QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_objectPath(objectPath),
|
||||||
|
m_mtu(0),
|
||||||
|
m_metered(0),
|
||||||
|
m_deviceState(DeviceStateUnknown),
|
||||||
|
m_deviceStateReason(DeviceStateReasonUnknown)
|
||||||
|
{
|
||||||
|
|
||||||
|
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||||
|
if (!systemBus.isConnected()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "NetworkDevice: System DBus not connected";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusInterface networkDeviceInterface(serviceString, m_objectPath.path(), deviceInterfaceString, QDBusConnection::systemBus());
|
||||||
|
if(!networkDeviceInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "NetworkDevice: Invalid DBus device interface" << m_objectPath.path();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_udi = networkDeviceInterface.property("Udi").toString();
|
||||||
|
m_interface = networkDeviceInterface.property("Interface").toString();
|
||||||
|
m_ipInterface = networkDeviceInterface.property("IpInterface").toString();
|
||||||
|
m_driver = networkDeviceInterface.property("Driver").toString();
|
||||||
|
m_driverVersion = networkDeviceInterface.property("DriverVersion").toString();
|
||||||
|
m_firmwareVersion = networkDeviceInterface.property("FirmwareVersion").toString();
|
||||||
|
m_physicalPortId = networkDeviceInterface.property("PhysicalPortId").toString();
|
||||||
|
m_mtu = networkDeviceInterface.property("Mtu").toUInt();
|
||||||
|
m_metered = networkDeviceInterface.property("Metered").toUInt();
|
||||||
|
|
||||||
|
m_deviceState = DeviceState(networkDeviceInterface.property("State").toUInt());
|
||||||
|
m_deviceType = DeviceType(networkDeviceInterface.property("DeviceType").toUInt());
|
||||||
|
|
||||||
|
m_activeConnection = qdbus_cast<QDBusObjectPath>(networkDeviceInterface.property("ActiveConnection"));
|
||||||
|
m_ip4Config = qdbus_cast<QDBusObjectPath>(networkDeviceInterface.property("Ip4Config"));
|
||||||
|
m_ip6Config = qdbus_cast<QDBusObjectPath>(networkDeviceInterface.property("Ip6Config"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusObjectPath NetworkDevice::objectPath() const
|
||||||
|
{
|
||||||
|
return m_objectPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::udi() const
|
||||||
|
{
|
||||||
|
return m_udi;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::interface() const
|
||||||
|
{
|
||||||
|
return m_interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::ipInterface() const
|
||||||
|
{
|
||||||
|
return m_ipInterface;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::driver() const
|
||||||
|
{
|
||||||
|
return m_driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::driverVersion() const
|
||||||
|
{
|
||||||
|
return m_driverVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::firmwareVersion() const
|
||||||
|
{
|
||||||
|
return m_firmwareVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::physicalPortId() const
|
||||||
|
{
|
||||||
|
return m_physicalPortId;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint NetworkDevice::mtu() const
|
||||||
|
{
|
||||||
|
return m_mtu;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint NetworkDevice::metered() const
|
||||||
|
{
|
||||||
|
return m_metered;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkDevice::DeviceState NetworkDevice::deviceState() const
|
||||||
|
{
|
||||||
|
return m_deviceState;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkDevice::DeviceStateReason NetworkDevice::deviceStateReason() const
|
||||||
|
{
|
||||||
|
return m_deviceStateReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkDevice::DeviceType NetworkDevice::deviceType() const
|
||||||
|
{
|
||||||
|
return m_deviceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusObjectPath NetworkDevice::activeConnection() const
|
||||||
|
{
|
||||||
|
return m_activeConnection;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusObjectPath NetworkDevice::ip4Config() const
|
||||||
|
{
|
||||||
|
return m_ip4Config;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QDBusObjectPath> NetworkDevice::availableConnections() const
|
||||||
|
{
|
||||||
|
return m_availableConnections;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::deviceTypeToString(const NetworkDevice::DeviceType &deviceType)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = NetworkDevice::staticMetaObject;
|
||||||
|
int enumIndex = metaObject.indexOfEnumerator(QString("DeviceType").toLatin1().data());
|
||||||
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
|
return QString(metaEnum.valueToKey(deviceType)).remove("DeviceType");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::deviceStateToString(const NetworkDevice::DeviceState &deviceState)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = NetworkDevice::staticMetaObject;
|
||||||
|
int enumIndex = metaObject.indexOfEnumerator(QString("DeviceState").toLatin1().data());
|
||||||
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
|
return QString(metaEnum.valueToKey(deviceState)).remove("DeviceState");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkDevice::deviceStateReasonToString(const NetworkDevice::DeviceStateReason &deviceStateReason)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = NetworkDevice::staticMetaObject;
|
||||||
|
int enumIndex = metaObject.indexOfEnumerator(QString("DeviceStateReason").toLatin1().data());
|
||||||
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
|
return QString(metaEnum.valueToKey(deviceStateReason)).remove("DeviceStateReason");
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkDevice::onStateChanged(uint newState, uint oldState, uint reason)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << m_interface << deviceStateToString(DeviceState(oldState)) << "-->" << deviceStateToString(DeviceState(newState)) << ":" << deviceStateReasonToString(DeviceStateReason(reason));
|
||||||
|
|
||||||
|
m_deviceState = DeviceState(newState);
|
||||||
|
emit deviceStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, NetworkDevice *device)
|
||||||
|
{
|
||||||
|
debug.nospace() << "NetworkDevice(" << device->interface() << " - " << NetworkDevice::deviceTypeToString(device->deviceType()) << ")";
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
208
server/networkmanager/networkdevice.h
Normal file
208
server/networkmanager/networkdevice.h
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#ifndef NETWORKDEVICE_H
|
||||||
|
#define NETWORKDEVICE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QDBusContext>
|
||||||
|
#include <QDBusArgument>
|
||||||
|
|
||||||
|
#include "dbus-interfaces.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
class NetworkDevice : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_ENUMS(DeviceType)
|
||||||
|
Q_ENUMS(DeviceState)
|
||||||
|
Q_ENUMS(DeviceStateReason)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DeviceState {
|
||||||
|
DeviceStateUnknown = 0,
|
||||||
|
DeviceStateUnmanaged = 10,
|
||||||
|
DeviceStateUnavailable = 20,
|
||||||
|
DeviceStateDisconnected = 30,
|
||||||
|
DeviceStatePrepare = 40,
|
||||||
|
DeviceStateConfig = 50,
|
||||||
|
DeviceStateNeedAuth = 60,
|
||||||
|
DeviceStateIpConfig = 70,
|
||||||
|
DeviceStateIpCheck = 80,
|
||||||
|
DeviceStateSecondaries = 90,
|
||||||
|
DeviceStateActivated = 100,
|
||||||
|
DeviceStateDeactivating = 110,
|
||||||
|
DeviceStateFailed = 120
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DeviceStateReason {
|
||||||
|
DeviceStateReasonNone = 0,
|
||||||
|
DeviceStateReasonUnknown = 1,
|
||||||
|
DeviceStateReasonNowManaged = 2,
|
||||||
|
DeviceStateReasonNowUnmanaged = 3,
|
||||||
|
DeviceStateReasonConfigFailed = 4,
|
||||||
|
DeviceStateReasonIpConfigUnavailable = 5,
|
||||||
|
DeviceStateReasonIpConfigExpired = 6,
|
||||||
|
DeviceStateReasonNoSecrets = 7,
|
||||||
|
DeviceStateReasonSupplicantDisconnected = 8,
|
||||||
|
DeviceStateReasonSupplicantConfigFailed = 9,
|
||||||
|
DeviceStateReasonSupplicantFailed = 10,
|
||||||
|
DeviceStateReasonSupplicantTimeout = 11,
|
||||||
|
DeviceStateReasonPppStartFailed = 12,
|
||||||
|
DeviceStateReasonPppDisconnected = 13,
|
||||||
|
DeviceStateReasonPppFailed = 14,
|
||||||
|
DeviceStateReasonDhcpStartFailed = 15,
|
||||||
|
DeviceStateReasonDhcpError = 16,
|
||||||
|
DeviceStateReasonDhcpFailed = 17,
|
||||||
|
DeviceStateReasonSharedStartFailed = 18,
|
||||||
|
DeviceStateReasonSharedFailed = 19,
|
||||||
|
DeviceStateReasonAutoIpStartFailed = 20,
|
||||||
|
DeviceStateReasonAutoIpError = 21,
|
||||||
|
DeviceStateReasonAutoIpFailed = 22,
|
||||||
|
DeviceStateReasonModemBusy = 23,
|
||||||
|
DeviceStateReasonModemNoDialTone = 24,
|
||||||
|
DeviceStateReasonModemNoCarrier = 25,
|
||||||
|
DeviceStateReasonModemDialTimeout = 26,
|
||||||
|
DeviceStateReasonModemDialFailed = 27,
|
||||||
|
DeviceStateReasonModemInitFailed = 28,
|
||||||
|
DeviceStateReasonGsmApnFailed = 29,
|
||||||
|
DeviceStateReasonGsmRegistrationNotSearching = 30,
|
||||||
|
DeviceStateReasonGsmRegistrationDenied = 31,
|
||||||
|
DeviceStateReasonGsmRegistrationTimeout = 32,
|
||||||
|
DeviceStateReasonGsmRegistrationFailed = 33,
|
||||||
|
DeviceStateReasonGsmPinCheckFailed = 34,
|
||||||
|
DeviceStateReasonFirmwareMissing = 35,
|
||||||
|
DeviceStateReasonRemoved = 36,
|
||||||
|
DeviceStateReasonSleeping = 37,
|
||||||
|
DeviceStateReasonConnectionRemoved = 38,
|
||||||
|
DeviceStateReasonUserRequest = 39,
|
||||||
|
DeviceStateReasonCarrier = 40,
|
||||||
|
DeviceStateReasonConnectionAssumed = 41,
|
||||||
|
DeviceStateReasonSupplicantAvailable = 42,
|
||||||
|
DeviceStateReasonModemNotFound = 43,
|
||||||
|
DeviceStateReasonBtFailed = 44,
|
||||||
|
DeviceStateReasonGsmSimNotInserted = 45,
|
||||||
|
DeviceStateReasonGsmSimPinRequired = 46,
|
||||||
|
DeviceStateReasonGsmSimPukRequired = 47,
|
||||||
|
DeviceStateReasonGsmSimWrong = 48,
|
||||||
|
DeviceStateReasonInfinibandMode = 49,
|
||||||
|
DeviceStateReasonDependencyFailed = 50,
|
||||||
|
DeviceStateReasonBR2684Failed = 51,
|
||||||
|
DeviceStateReasonModemManagerUnavailable = 52,
|
||||||
|
DeviceStateReasonSsidNotFound = 53,
|
||||||
|
DeviceStateReasonSecondaryConnectionFailed = 54,
|
||||||
|
DeviceStateReasonDcbFoecFailed = 55,
|
||||||
|
DeviceStateReasonTeamdControlFailed = 56,
|
||||||
|
DeviceStateReasonModemFailed = 57,
|
||||||
|
DeviceStateReasonModemAvailable = 58,
|
||||||
|
DeviceStateReasonSimPinIncorrect = 59,
|
||||||
|
DeviceStateReasonNewActivision = 60,
|
||||||
|
DeviceStateReasonParentChanged = 61,
|
||||||
|
DeviceStateReasonParentManagedChanged = 62
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DeviceType {
|
||||||
|
DeviceTypeUnknown = 0,
|
||||||
|
DeviceTypeEthernet = 1,
|
||||||
|
DeviceTypeWifi = 2,
|
||||||
|
DeviceTypeBluetooth = 5,
|
||||||
|
DeviceTypeOlpcMesh = 6,
|
||||||
|
DeviceTypeWiMax = 7,
|
||||||
|
DeviceTypeModem = 8,
|
||||||
|
DeviceTypeInfiniBand = 9,
|
||||||
|
DeviceTypeBond = 10,
|
||||||
|
DeviceTypeVLan = 11,
|
||||||
|
DeviceTypeAdsl = 12,
|
||||||
|
DeviceTypeBridge = 13,
|
||||||
|
DeviceTypeGeneric = 14,
|
||||||
|
DeviceTypeTeam = 15,
|
||||||
|
DeviceTypeTun = 16,
|
||||||
|
DeviceTypeIpTunnel = 17,
|
||||||
|
DeviceTypeMacVLan = 18,
|
||||||
|
DeviceTypeVXLan = 19,
|
||||||
|
DeviceTypeVEth = 20,
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit NetworkDevice(const QDBusObjectPath &objectPath, QObject *parent = 0);
|
||||||
|
|
||||||
|
QDBusObjectPath objectPath() const;
|
||||||
|
|
||||||
|
QString udi() const;
|
||||||
|
QString interface() const;
|
||||||
|
QString ipInterface() const;
|
||||||
|
QString driver() const;
|
||||||
|
QString driverVersion() const;
|
||||||
|
QString firmwareVersion() const;
|
||||||
|
QString physicalPortId() const;
|
||||||
|
uint mtu() const;
|
||||||
|
uint metered() const;
|
||||||
|
DeviceState deviceState() const;
|
||||||
|
DeviceStateReason deviceStateReason() const;
|
||||||
|
DeviceType deviceType() const;
|
||||||
|
|
||||||
|
QDBusObjectPath activeConnection() const;
|
||||||
|
QDBusObjectPath ip4Config() const;
|
||||||
|
QList<QDBusObjectPath> availableConnections() const;
|
||||||
|
|
||||||
|
static QString deviceTypeToString(const DeviceType &deviceType);
|
||||||
|
static QString deviceStateToString(const DeviceState &deviceState);
|
||||||
|
static QString deviceStateReasonToString(const DeviceStateReason &deviceStateReason);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDBusObjectPath m_objectPath;
|
||||||
|
|
||||||
|
// Device properties
|
||||||
|
QString m_udi;
|
||||||
|
QString m_interface;
|
||||||
|
QString m_ipInterface;
|
||||||
|
QString m_driver;
|
||||||
|
QString m_driverVersion;
|
||||||
|
QString m_firmwareVersion;
|
||||||
|
QString m_physicalPortId;
|
||||||
|
uint m_mtu;
|
||||||
|
uint m_metered;
|
||||||
|
DeviceState m_deviceState;
|
||||||
|
DeviceStateReason m_deviceStateReason;
|
||||||
|
DeviceType m_deviceType;
|
||||||
|
|
||||||
|
QDBusObjectPath m_activeConnection;
|
||||||
|
QDBusObjectPath m_ip4Config;
|
||||||
|
QDBusObjectPath m_ip6Config;
|
||||||
|
|
||||||
|
QList<QDBusObjectPath> m_availableConnections;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onStateChanged(uint newState, uint oldState, uint reason);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void deviceStateChanged();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, NetworkDevice *device);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NETWORKDEVICE_H
|
||||||
253
server/networkmanager/networkmanager.cpp
Normal file
253
server/networkmanager/networkmanager.cpp
Normal file
@ -0,0 +1,253 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#include "networkmanager.h"
|
||||||
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
NetworkManager::NetworkManager(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_wirelessNetworkManager(0)
|
||||||
|
{
|
||||||
|
// Create interface
|
||||||
|
m_networkManagerInterface = new QDBusInterface(serviceString, pathString, serviceString, QDBusConnection::systemBus(), this);
|
||||||
|
if(!m_networkManagerInterface->isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "Invalid DBus network manager interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read properties
|
||||||
|
m_version = m_networkManagerInterface->property("Version").toString();
|
||||||
|
m_state = NetworkManagerState(m_networkManagerInterface->property("State").toUInt());
|
||||||
|
m_connectivityState = NetworkManagerConnectivityState(m_networkManagerInterface->property("Connectivity").toUInt());
|
||||||
|
m_networkingEnabled = m_networkManagerInterface->property("NetworkingEnabled").toBool();
|
||||||
|
m_wirelessEnabled = m_networkManagerInterface->property("WirelessEnabled").toBool();
|
||||||
|
|
||||||
|
qCDebug(dcNetworkManager()) << "Networkmanager version" << m_version;
|
||||||
|
|
||||||
|
// Get network devices
|
||||||
|
QDBusMessage query = m_networkManagerInterface->call("GetDevices");
|
||||||
|
if(query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDBusArgument &argument = query.arguments().at(0).value<QDBusArgument>();
|
||||||
|
argument.beginArray();
|
||||||
|
while(!argument.atEnd()) {
|
||||||
|
QDBusObjectPath deviceObjectPath = qdbus_cast<QDBusObjectPath>(argument);
|
||||||
|
onDeviceAdded(deviceObjectPath);
|
||||||
|
}
|
||||||
|
argument.endArray();
|
||||||
|
|
||||||
|
// Connect signals
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, pathString, serviceString, "StateChanged", this, SLOT(onStateChanged(uint)));
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, pathString, serviceString, "DeviceAdded", this, SLOT(onDeviceAdded(QDBusObjectPath)));
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, pathString, serviceString, "DeviceRemoved", this, SLOT(onDeviceRemoved(QDBusObjectPath)));
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, pathString, serviceString, "PropertiesChanged", this, SLOT(onPropertiesChanged(QVariantMap)));
|
||||||
|
|
||||||
|
m_networkSettings = new NetworkSettings(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkManager::available()
|
||||||
|
{
|
||||||
|
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||||
|
if (!systemBus.isConnected()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "System DBus not connected";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusInterface networkInterface(serviceString, pathString, serviceString, QDBusConnection::systemBus());
|
||||||
|
if(!networkInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "Invalid DBus network manager interface";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkManager::networkManagerStateToString(const NetworkManager::NetworkManagerState &state)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = NetworkManager::staticMetaObject;
|
||||||
|
int enumIndex = metaObject.indexOfEnumerator(QString("NetworkManagerState").toLatin1().data());
|
||||||
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
|
return QString(metaEnum.valueToKey(state)).remove("NetworkManagerState");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkManager::networkManagerConnectivityStateToString(const NetworkManager::NetworkManagerConnectivityState &state)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = NetworkManager::staticMetaObject;
|
||||||
|
int enumIndex = metaObject.indexOfEnumerator(QString("NetworkManagerConnectivityState").toLatin1().data());
|
||||||
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
|
return QString(metaEnum.valueToKey(state)).remove("NetworkManagerConnectivityState");
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<NetworkDevice *> NetworkManager::networkDevices() const
|
||||||
|
{
|
||||||
|
return m_networkDevices.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString NetworkManager::version() const
|
||||||
|
{
|
||||||
|
return m_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkManager::NetworkManagerState NetworkManager::state() const
|
||||||
|
{
|
||||||
|
return m_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkManager::NetworkManagerConnectivityState NetworkManager::connectivityState() const
|
||||||
|
{
|
||||||
|
return m_connectivityState;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkManager::networkingEnabled() const
|
||||||
|
{
|
||||||
|
return m_networkingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkManager::enableNetworking()
|
||||||
|
{
|
||||||
|
if (m_networkingEnabled)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
QDBusMessage query = m_networkManagerInterface->call("Enable", true);
|
||||||
|
if(query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkManager::disableNetworking()
|
||||||
|
{
|
||||||
|
if (!m_networkingEnabled)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
QDBusMessage query = m_networkManagerInterface->call("Enable", false);
|
||||||
|
if(query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::setNetworkingEnabled(const bool &enabled)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Networking" << (enabled ? "enabled" : "disabled");
|
||||||
|
m_networkingEnabled = enabled;
|
||||||
|
emit networkingEnabledChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkManager::wirelessEnabled() const
|
||||||
|
{
|
||||||
|
return m_wirelessEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetworkManager::enableWireless()
|
||||||
|
{
|
||||||
|
if (m_wirelessEnabled)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return m_networkManagerInterface->setProperty("WirelessEnabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::setVersion(const QString &version)
|
||||||
|
{
|
||||||
|
m_version = version;
|
||||||
|
emit versionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::setWirelessEnabled(const bool &enabled)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Wireless networking" << (enabled ? "enabled" : "disabled");
|
||||||
|
m_wirelessEnabled = enabled;
|
||||||
|
emit wirelessEnabledChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::setConnectivityState(const NetworkManager::NetworkManagerConnectivityState &connectivityState)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Connectivity state changed:" << networkManagerConnectivityStateToString(connectivityState);
|
||||||
|
m_connectivityState = connectivityState;
|
||||||
|
emit connectivityStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::setState(const NetworkManager::NetworkManagerState &state)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "State changed:" << networkManagerStateToString(state);
|
||||||
|
m_state = state;
|
||||||
|
emit stateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::onDeviceAdded(const QDBusObjectPath &deviceObjectPath)
|
||||||
|
{
|
||||||
|
if (m_networkDevices.keys().contains(deviceObjectPath)) {
|
||||||
|
qCWarning(dcNetworkManager()) << "Device" << deviceObjectPath.path() << "already added.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkDevice *networkDevice = new NetworkDevice(deviceObjectPath, this);
|
||||||
|
qCDebug(dcNetworkManager()) << "[+]" << networkDevice;
|
||||||
|
|
||||||
|
if (!m_wirelessNetworkManager && networkDevice->deviceType() == NetworkDevice::DeviceTypeWifi)
|
||||||
|
m_wirelessNetworkManager = new WirelessNetworkManager(networkDevice->objectPath(), this);
|
||||||
|
|
||||||
|
m_networkDevices.insert(deviceObjectPath, networkDevice);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::onDeviceRemoved(const QDBusObjectPath &deviceObjectPath)
|
||||||
|
{
|
||||||
|
if (!m_networkDevices.keys().contains(deviceObjectPath)) {
|
||||||
|
qCWarning(dcNetworkManager()) << "Unknown network device removed:" << deviceObjectPath.path();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkDevice *networkDevice = m_networkDevices.take(deviceObjectPath);
|
||||||
|
qCDebug(dcNetworkManager()) << "[-]" << networkDevice;
|
||||||
|
networkDevice->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkManager::onPropertiesChanged(const QVariantMap &properties)
|
||||||
|
{
|
||||||
|
//qCDebug(dcNetworkManager()) << "Network manager properties changed" << properties;
|
||||||
|
|
||||||
|
if (properties.contains("Version"))
|
||||||
|
setVersion(properties.value("Version").toString());
|
||||||
|
|
||||||
|
if (properties.contains("State"))
|
||||||
|
setState(NetworkManagerState(properties.value("State").toUInt()));
|
||||||
|
|
||||||
|
if (properties.contains("Connectivity"))
|
||||||
|
setConnectivityState(NetworkManagerConnectivityState(properties.value("Connectivity").toUInt()));
|
||||||
|
|
||||||
|
if (properties.contains("NetworkingEnabled"))
|
||||||
|
setNetworkingEnabled(properties.value("NetworkingEnabled").toBool());
|
||||||
|
|
||||||
|
if (properties.contains("WirelessEnabled"))
|
||||||
|
setWirelessEnabled(properties.value("WirelessEnabled").toBool());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
123
server/networkmanager/networkmanager.h
Normal file
123
server/networkmanager/networkmanager.h
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#ifndef NETWORKMANAGER_H
|
||||||
|
#define NETWORKMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QDBusContext>
|
||||||
|
#include <QDBusArgument>
|
||||||
|
|
||||||
|
#include "wirelessnetworkmanager.h"
|
||||||
|
#include "dbus-interfaces.h"
|
||||||
|
#include "networkdevice.h"
|
||||||
|
#include "networksettings.h"
|
||||||
|
|
||||||
|
// Note: https://developer.gnome.org/NetworkManager/unstable/spec.html
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
class NetworkManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_ENUMS(NetworkManagerState)
|
||||||
|
Q_ENUMS(NetworkManagerConnectivityState)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum NetworkManagerState {
|
||||||
|
NetworkManagerStateUnknown = 0,
|
||||||
|
NetworkManagerStateAsleep = 10,
|
||||||
|
NetworkManagerStateDisconnected = 20,
|
||||||
|
NetworkManagerStateDisconnecting = 30,
|
||||||
|
NetworkManagerStateConnecting = 40,
|
||||||
|
NetworkManagerStateConnectedLocal = 50,
|
||||||
|
NetworkManagerStateConnectedSite = 60,
|
||||||
|
NetworkManagerStateConnectedGlobal = 70
|
||||||
|
};
|
||||||
|
|
||||||
|
enum NetworkManagerConnectivityState {
|
||||||
|
NetworkManagerConnectivityStateUnknown = 1,
|
||||||
|
NetworkManagerConnectivityStateNone = 2,
|
||||||
|
NetworkManagerConnectivityStatePortal = 3,
|
||||||
|
NetworkManagerConnectivityStateLimited = 4,
|
||||||
|
NetworkManagerConnectivityStateFull = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit NetworkManager(QObject *parent = 0);
|
||||||
|
|
||||||
|
static bool available();
|
||||||
|
static QString networkManagerStateToString(const NetworkManagerState &state);
|
||||||
|
static QString networkManagerConnectivityStateToString(const NetworkManagerConnectivityState &state);
|
||||||
|
|
||||||
|
QList<NetworkDevice *> networkDevices() const;
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
QString version() const;
|
||||||
|
NetworkManagerState state() const;
|
||||||
|
NetworkManagerConnectivityState connectivityState() const;
|
||||||
|
|
||||||
|
bool networkingEnabled() const;
|
||||||
|
bool enableNetworking();
|
||||||
|
bool disableNetworking();
|
||||||
|
|
||||||
|
bool wirelessEnabled() const;
|
||||||
|
bool enableWireless();
|
||||||
|
bool disableWireless();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDBusInterface *m_networkManagerInterface;
|
||||||
|
QHash<QDBusObjectPath, NetworkDevice *> m_networkDevices;
|
||||||
|
|
||||||
|
NetworkSettings *m_networkSettings;
|
||||||
|
WirelessNetworkManager *m_wirelessNetworkManager;
|
||||||
|
|
||||||
|
QString m_version;
|
||||||
|
|
||||||
|
NetworkManagerState m_state;
|
||||||
|
NetworkManagerConnectivityState m_connectivityState;
|
||||||
|
bool m_networkingEnabled;
|
||||||
|
bool m_wirelessEnabled;
|
||||||
|
|
||||||
|
void setVersion(const QString &version);
|
||||||
|
void setNetworkingEnabled(const bool &enabled);
|
||||||
|
void setWirelessEnabled(const bool &enabled);
|
||||||
|
void setConnectivityState(const NetworkManagerConnectivityState &connectivityState);
|
||||||
|
void setState(const NetworkManagerState &state);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void versionChanged();
|
||||||
|
void networkingEnabledChanged();
|
||||||
|
void wirelessEnabledChanged();
|
||||||
|
void stateChanged();
|
||||||
|
void connectivityStateChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDeviceAdded(const QDBusObjectPath &deviceObjectPath);
|
||||||
|
void onDeviceRemoved(const QDBusObjectPath &deviceObjectPath);
|
||||||
|
void onPropertiesChanged(const QVariantMap &properties);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NETWORKMANAGER_H
|
||||||
83
server/networkmanager/networksettings.cpp
Normal file
83
server/networkmanager/networksettings.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#include "networksettings.h"
|
||||||
|
#include "dbus-interfaces.h"
|
||||||
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
NetworkSettings::NetworkSettings(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||||
|
if (!systemBus.isConnected()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "System DBus not connected";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_settingsInterface = new QDBusInterface(serviceString, settingsPathString, settingsInterfaceString, QDBusConnection::systemBus(), this);
|
||||||
|
if(!m_settingsInterface->isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "Invalid DBus network settings interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, settingsPathString, settingsInterfaceString, "NewConnection", this, SLOT(connectionAdded(QDBusObjectPath)));
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, settingsPathString, settingsInterfaceString, "ConnectionRemoved", this, SLOT(connectionRemoved(QDBusObjectPath)));
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, settingsPathString, settingsInterfaceString, "PropertiesChanged", this, SLOT(propertiesChanged(QVariantMap)));
|
||||||
|
|
||||||
|
loadConnections();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettings::loadConnections()
|
||||||
|
{
|
||||||
|
// Get
|
||||||
|
QDBusMessage query = m_settingsInterface->call("ListConnections");
|
||||||
|
if(query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDBusArgument &argument = query.arguments().at(0).value<QDBusArgument>();
|
||||||
|
argument.beginArray();
|
||||||
|
while(!argument.atEnd()) {
|
||||||
|
QDBusObjectPath objectPath = qdbus_cast<QDBusObjectPath>(argument);
|
||||||
|
connectionAdded(objectPath);
|
||||||
|
}
|
||||||
|
argument.endArray();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettings::connectionAdded(const QDBusObjectPath &objectPath)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Settings: [+]" << objectPath.path();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettings::connectionRemoved(const QDBusObjectPath &objectPath)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Settings: [-]" << objectPath.path();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkSettings::propertiesChanged(const QVariantMap &properties)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "Settins: properties changed" << properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
54
server/networkmanager/networksettings.h
Normal file
54
server/networkmanager/networksettings.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#ifndef NETWORKSETTINGS_H
|
||||||
|
#define NETWORKSETTINGS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDBusObjectPath>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusArgument>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
class NetworkSettings : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit NetworkSettings(QObject *parent = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDBusInterface *m_settingsInterface;
|
||||||
|
|
||||||
|
void loadConnections();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void connectionAdded(const QDBusObjectPath &objectPath);
|
||||||
|
void connectionRemoved(const QDBusObjectPath &objectPath);
|
||||||
|
void propertiesChanged(const QVariantMap &properties);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NETWORKSETTINGS_H
|
||||||
116
server/networkmanager/wirelessaccesspoint.cpp
Normal file
116
server/networkmanager/wirelessaccesspoint.cpp
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#include "wirelessaccesspoint.h"
|
||||||
|
#include "loggingcategories.h"
|
||||||
|
#include "dbus-interfaces.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
WirelessAccessPoint::WirelessAccessPoint(const QDBusObjectPath &objectPath, QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_objectPath(objectPath)
|
||||||
|
{
|
||||||
|
QDBusInterface accessPointInterface(serviceString, m_objectPath.path(), accessPointInterfaceString, QDBusConnection::systemBus());
|
||||||
|
if(!accessPointInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "Invalid access point dbus interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init properties
|
||||||
|
setSsid(accessPointInterface.property("Ssid").toString());
|
||||||
|
setMacAddress(accessPointInterface.property("HwAddress").toString());
|
||||||
|
setFrequency(accessPointInterface.property("Frequency").toDouble() / 1000);
|
||||||
|
setSignalStrength(accessPointInterface.property("Strength").toUInt());
|
||||||
|
setSecurityFlags(WirelessAccessPoint::ApSecurityModes(accessPointInterface.property("WpaFlags").toUInt()));
|
||||||
|
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, objectPath.path(), accessPointInterfaceString, "PropertiesChanged", this, SLOT(onPropertiesChanged(QVariantMap)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusObjectPath WirelessAccessPoint::objectPath() const
|
||||||
|
{
|
||||||
|
return m_objectPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessAccessPoint::ssid() const
|
||||||
|
{
|
||||||
|
return m_ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessAccessPoint::setSsid(const QString &ssid)
|
||||||
|
{
|
||||||
|
m_ssid = ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessAccessPoint::macAddress() const
|
||||||
|
{
|
||||||
|
return m_macAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessAccessPoint::setMacAddress(const QString &macAddress)
|
||||||
|
{
|
||||||
|
m_macAddress = macAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
double WirelessAccessPoint::frequency() const
|
||||||
|
{
|
||||||
|
return m_frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessAccessPoint::setFrequency(const double &frequency)
|
||||||
|
{
|
||||||
|
m_frequency = frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WirelessAccessPoint::signalStrength() const
|
||||||
|
{
|
||||||
|
return m_signalStrength;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessAccessPoint::setSignalStrength(const int &signalStrength)
|
||||||
|
{
|
||||||
|
m_signalStrength = signalStrength;
|
||||||
|
emit signalStrengthChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessAccessPoint::ApSecurityModes WirelessAccessPoint::securityFlags() const
|
||||||
|
{
|
||||||
|
return m_securityFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessAccessPoint::setSecurityFlags(const WirelessAccessPoint::ApSecurityModes &securityFlags)
|
||||||
|
{
|
||||||
|
m_securityFlags = securityFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessAccessPoint::onPropertiesChanged(const QVariantMap &properties)
|
||||||
|
{
|
||||||
|
//qCDebug(dcNetworkManager()) << "AccessPoint" << ssid() << ": Properties changed" << properties;
|
||||||
|
if (properties.contains("Strength"))
|
||||||
|
setSignalStrength(properties.value("Strength").toUInt());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, WirelessAccessPoint *accessPoint)
|
||||||
|
{
|
||||||
|
return debug.nospace() << "AccessPoint(" << accessPoint->signalStrength() << "%, " << accessPoint->frequency()<< " GHz, " << accessPoint->ssid() << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
98
server/networkmanager/wirelessaccesspoint.h
Normal file
98
server/networkmanager/wirelessaccesspoint.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#ifndef WIRELESSACCESSPOINT_H
|
||||||
|
#define WIRELESSACCESSPOINT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFlags>
|
||||||
|
#include <QDBusObjectPath>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusArgument>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
class WirelessAccessPoint : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_FLAGS(ApSecurityModes)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum ApSecurityMode{
|
||||||
|
ApSecurityModeNone = 0x000,
|
||||||
|
ApSecurityModePairWep40 = 0x001,
|
||||||
|
ApSecurityModePairWep104 = 0x002,
|
||||||
|
ApSecurityModePairTkip = 0x004,
|
||||||
|
ApSecurityModePairCcmp = 0x008,
|
||||||
|
ApSecurityModeGroupWep40 = 0x010,
|
||||||
|
ApSecurityModeGroupWep104 = 0x020,
|
||||||
|
ApSecurityModeGroupTkip = 0x040,
|
||||||
|
ApSecurityModeGroupCcmp = 0x080,
|
||||||
|
ApSecurityModeKeyMgmtPsk = 0x100,
|
||||||
|
ApSecurityModeKeyMgmt8021X = 0x200,
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(ApSecurityModes, ApSecurityMode)
|
||||||
|
|
||||||
|
|
||||||
|
explicit WirelessAccessPoint(const QDBusObjectPath &objectPath, QObject *parent = 0);
|
||||||
|
|
||||||
|
QDBusObjectPath objectPath() const;
|
||||||
|
|
||||||
|
QString ssid() const;
|
||||||
|
void setSsid(const QString &ssid);
|
||||||
|
|
||||||
|
QString macAddress() const;
|
||||||
|
void setMacAddress(const QString &macAddress);
|
||||||
|
|
||||||
|
double frequency() const;
|
||||||
|
void setFrequency(const double &frequency);
|
||||||
|
|
||||||
|
int signalStrength() const;
|
||||||
|
void setSignalStrength(const int &signalStrength);
|
||||||
|
|
||||||
|
WirelessAccessPoint::ApSecurityModes securityFlags() const;
|
||||||
|
void setSecurityFlags(const WirelessAccessPoint::ApSecurityModes &securityFlags);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QDBusObjectPath m_objectPath;
|
||||||
|
QString m_ssid;
|
||||||
|
QString m_macAddress;
|
||||||
|
double m_frequency;
|
||||||
|
int m_signalStrength;
|
||||||
|
WirelessAccessPoint::ApSecurityModes m_securityFlags;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void signalStrengthChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onPropertiesChanged(const QVariantMap &properties);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, WirelessAccessPoint *accessPoint);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(guhserver::WirelessAccessPoint::ApSecurityModes)
|
||||||
|
Q_DECLARE_METATYPE(guhserver::WirelessAccessPoint::ApSecurityMode)
|
||||||
|
|
||||||
|
#endif // WIRELESSACCESSPOINT_H
|
||||||
295
server/networkmanager/wirelessnetworkmanager.cpp
Normal file
295
server/networkmanager/wirelessnetworkmanager.cpp
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#include "wirelessnetworkmanager.h"
|
||||||
|
|
||||||
|
#include "dbus-interfaces.h"
|
||||||
|
#include "loggingcategories.h"
|
||||||
|
|
||||||
|
#include <QMetaEnum>
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
WirelessNetworkManager::WirelessNetworkManager(const QDBusObjectPath &devicePath, QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_path(devicePath.path()),
|
||||||
|
m_connected(false),
|
||||||
|
m_managed(false),
|
||||||
|
m_state(DeviceStateUnknown),
|
||||||
|
m_stateReason(DeviceStateReasonUnknown)
|
||||||
|
{
|
||||||
|
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||||
|
if (!systemBus.isConnected()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "System DBus not connected";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, m_path, wirelessInterfaceString, "AccessPointAdded", this, SLOT(accessPointAdded(QDBusObjectPath)));
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, m_path, wirelessInterfaceString, "AccessPointRemoved", this, SLOT(accessPointRemoved(QDBusObjectPath)));
|
||||||
|
QDBusConnection::systemBus().connect(serviceString, m_path, deviceInterfaceString, "StateChanged", this, SLOT(deviceStateChanged(quint32,quint32,quint32)));
|
||||||
|
|
||||||
|
readWirelessDeviceProperties();
|
||||||
|
|
||||||
|
qCDebug(dcNetworkManager()) << this;
|
||||||
|
|
||||||
|
readAccessPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessNetworkManager::udi() const
|
||||||
|
{
|
||||||
|
return m_udi;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessNetworkManager::macAddress() const
|
||||||
|
{
|
||||||
|
return m_macAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessNetworkManager::interfaceName() const
|
||||||
|
{
|
||||||
|
return m_interfaceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessNetworkManager::driver() const
|
||||||
|
{
|
||||||
|
return m_driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessNetworkManager::driverVersion() const
|
||||||
|
{
|
||||||
|
return m_driverVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WirelessNetworkManager::connected() const
|
||||||
|
{
|
||||||
|
return m_connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WirelessNetworkManager::managed() const
|
||||||
|
{
|
||||||
|
return m_managed;
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessNetworkManager::DeviceState WirelessNetworkManager::state() const
|
||||||
|
{
|
||||||
|
return m_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessNetworkManager::DeviceStateReason WirelessNetworkManager::stateReason() const
|
||||||
|
{
|
||||||
|
return m_stateReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::scanWirelessNetworks()
|
||||||
|
{
|
||||||
|
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||||
|
if (!systemBus.isConnected()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: System DBus not connected";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusInterface wirelessInterface(serviceString, m_path, wirelessInterfaceString, systemBus);
|
||||||
|
if(!wirelessInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: Could not scan wireless networks: Invalid wireless dbus interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusMessage query= wirelessInterface.call("RequestScan", QVariantMap());
|
||||||
|
if(query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << "Scan error:" << query.errorName() << query.errorMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<WirelessAccessPoint *> WirelessNetworkManager::accessPoints()
|
||||||
|
{
|
||||||
|
return m_accessPointsTable.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessAccessPoint *WirelessNetworkManager::getAccessPoint(const QString &ssid)
|
||||||
|
{
|
||||||
|
foreach (WirelessAccessPoint *accessPoint, m_accessPointsTable.values()) {
|
||||||
|
if (accessPoint->ssid() == ssid)
|
||||||
|
return accessPoint;
|
||||||
|
}
|
||||||
|
return Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessAccessPoint *WirelessNetworkManager::getAccessPoint(const QDBusObjectPath &objectPath)
|
||||||
|
{
|
||||||
|
return m_accessPointsTable.value(objectPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessNetworkManager::deviceStateToString(const WirelessNetworkManager::DeviceState &state)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = WirelessNetworkManager::staticMetaObject;
|
||||||
|
int enumIndex = metaObject.indexOfEnumerator(QString("DeviceState").toLatin1().data());
|
||||||
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
|
return QString(metaEnum.valueToKey(state)).remove("DeviceState");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WirelessNetworkManager::deviceStateReasonToString(const WirelessNetworkManager::DeviceStateReason &stateReason)
|
||||||
|
{
|
||||||
|
QMetaObject metaObject = WirelessNetworkManager::staticMetaObject;
|
||||||
|
int enumIndex = metaObject.indexOfEnumerator(QString("DeviceStateReason").toLatin1().data());
|
||||||
|
QMetaEnum metaEnum = metaObject.enumerator(enumIndex);
|
||||||
|
return QString(metaEnum.valueToKey(stateReason)).remove("DeviceStateReason");
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::readAccessPoints()
|
||||||
|
{
|
||||||
|
QDBusInterface wirelessInterface(serviceString, m_path, wirelessInterfaceString, QDBusConnection::systemBus());
|
||||||
|
if(!wirelessInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: Could not read access points: Invalid wireless dbus interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusMessage query= wirelessInterface.call("GetAccessPoints");
|
||||||
|
if(query.type() != QDBusMessage::ReplyMessage) {
|
||||||
|
qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDBusArgument &argument = query.arguments().at(0).value<QDBusArgument>();
|
||||||
|
argument.beginArray();
|
||||||
|
while(!argument.atEnd()) {
|
||||||
|
QDBusObjectPath accessPointObjectPath = qdbus_cast<QDBusObjectPath>(argument);
|
||||||
|
accessPointAdded(accessPointObjectPath);
|
||||||
|
}
|
||||||
|
argument.endArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::readWirelessDeviceProperties()
|
||||||
|
{
|
||||||
|
QDBusInterface wirelessInterface(serviceString, m_path, wirelessInterfaceString, QDBusConnection::systemBus());
|
||||||
|
if(!wirelessInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: Could not read access points: Invalid wireless dbus interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDBusInterface driverInterface(serviceString, m_path, deviceInterfaceString, QDBusConnection::systemBus());
|
||||||
|
if(!driverInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: Could not read driver information: Invalid driver dbus interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_udi = driverInterface.property("Udi").toString();
|
||||||
|
m_macAddress = wirelessInterface.property("HwAddress").toString();
|
||||||
|
m_interfaceName = driverInterface.property("Interface").toString();
|
||||||
|
m_driver = driverInterface.property("Driver").toString();
|
||||||
|
m_driverVersion = driverInterface.property("DriverVersion").toString();
|
||||||
|
|
||||||
|
qCDebug(dcNetworkManager()) << qdbus_cast<QDBusObjectPath>(driverInterface.property("ActiveConnection")).path();
|
||||||
|
|
||||||
|
setManaged(driverInterface.property("Managed").toBool());
|
||||||
|
setState(DeviceState(driverInterface.property("State").toUInt()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::setConnected(const bool &connected)
|
||||||
|
{
|
||||||
|
if (m_connected != connected) {
|
||||||
|
m_connected = connected;
|
||||||
|
emit connectedChanged(m_connected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::setState(const DeviceState &state)
|
||||||
|
{
|
||||||
|
m_state = state;
|
||||||
|
emit stateChanged(m_state);
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case DeviceStateActivated:
|
||||||
|
setConnected(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setConnected(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::setStateReason(const WirelessNetworkManager::DeviceStateReason &stateReason)
|
||||||
|
{
|
||||||
|
m_stateReason = stateReason;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::setManaged(const bool &managed)
|
||||||
|
{
|
||||||
|
m_managed = managed;
|
||||||
|
emit managedChanged(m_managed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::deviceStateChanged(uint newState, uint oldState, uint reason)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "WirelessManager: state changed" << deviceStateToString(DeviceState(oldState)) << "-->" << deviceStateToString(DeviceState(newState)) << ":" << deviceStateReasonToString(DeviceStateReason(reason));
|
||||||
|
|
||||||
|
setState(DeviceState(newState));
|
||||||
|
setStateReason(DeviceStateReason(reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::accessPointAdded(const QDBusObjectPath &objectPath)
|
||||||
|
{
|
||||||
|
QDBusInterface accessPointInterface(serviceString, objectPath.path(), accessPointInterfaceString, QDBusConnection::systemBus());
|
||||||
|
if(!accessPointInterface.isValid()) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: Invalid access point dbus interface";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_accessPointsTable.keys().contains(objectPath)) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: Access point already added" << objectPath.path();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WirelessAccessPoint *accessPoint = new WirelessAccessPoint(objectPath, this);
|
||||||
|
|
||||||
|
// Add access point
|
||||||
|
qCDebug(dcNetworkManager()) << "WirelessNetworkManager: [+]" << accessPoint;
|
||||||
|
m_accessPointsTable.insert(objectPath, accessPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::accessPointRemoved(const QDBusObjectPath &objectPath)
|
||||||
|
{
|
||||||
|
if (!m_accessPointsTable.keys().contains(objectPath)) {
|
||||||
|
qCWarning(dcNetworkManager()) << "WirelessNetworkManager: Unknown access point removed" << objectPath.path();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove access point
|
||||||
|
WirelessAccessPoint *accessPoint = m_accessPointsTable.take(objectPath);
|
||||||
|
qCDebug(dcNetworkManager()) << "WirelessNetworkManager: [-]" << accessPoint;
|
||||||
|
accessPoint->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WirelessNetworkManager::propertiesChanged(const QVariantMap &properties)
|
||||||
|
{
|
||||||
|
qCDebug(dcNetworkManager()) << "WirelessNetworkManager: Property changed" << properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, WirelessNetworkManager *manager)
|
||||||
|
{
|
||||||
|
debug.nospace() << "WirelessManager(" << manager->interfaceName() << ", ";
|
||||||
|
debug.nospace() << manager->macAddress() << ", ";
|
||||||
|
debug.nospace() << manager->udi() << ", ";
|
||||||
|
debug.nospace() << manager->driver() << ": " << manager->driverVersion() << ", ";
|
||||||
|
debug.nospace() << WirelessNetworkManager::deviceStateToString(manager->state()) << ") ";
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
188
server/networkmanager/wirelessnetworkmanager.h
Normal file
188
server/networkmanager/wirelessnetworkmanager.h
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.io> *
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
#ifndef WIRELESSNETWORKMANAGER_H
|
||||||
|
#define WIRELESSNETWORKMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QDBusContext>
|
||||||
|
#include <QDBusArgument>
|
||||||
|
|
||||||
|
#include "wirelessaccesspoint.h"
|
||||||
|
|
||||||
|
namespace guhserver {
|
||||||
|
|
||||||
|
class WirelessNetworkManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_ENUMS(DeviceState)
|
||||||
|
Q_ENUMS(DeviceStateReason)
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DeviceState {
|
||||||
|
DeviceStateUnknown = 0,
|
||||||
|
DeviceStateUnmanaged = 10,
|
||||||
|
DeviceStateUnavailable = 20,
|
||||||
|
DeviceStateDisconnected = 30,
|
||||||
|
DeviceStatePrepare = 40,
|
||||||
|
DeviceStateConfig = 50,
|
||||||
|
DeviceStateNeedAuth = 60,
|
||||||
|
DeviceStateIpConfig = 70,
|
||||||
|
DeviceStateIpCheck = 80,
|
||||||
|
DeviceStateSecondaries = 90,
|
||||||
|
DeviceStateActivated = 100,
|
||||||
|
DeviceStateDeactivating = 110,
|
||||||
|
DeviceStateFailed = 120
|
||||||
|
};
|
||||||
|
|
||||||
|
enum DeviceStateReason {
|
||||||
|
DeviceStateReasonNone = 0,
|
||||||
|
DeviceStateReasonUnknown = 1,
|
||||||
|
DeviceStateReasonNowManaged = 2,
|
||||||
|
DeviceStateReasonNowUnmanaged = 3,
|
||||||
|
DeviceStateReasonConfigFailed = 4,
|
||||||
|
DeviceStateReasonIpConfigUnavailable = 5,
|
||||||
|
DeviceStateReasonIpConfigExpired = 6,
|
||||||
|
DeviceStateReasonNoSecrets = 7,
|
||||||
|
DeviceStateReasonSupplicantDisconnected = 8,
|
||||||
|
DeviceStateReasonSupplicantConfigFailed = 9,
|
||||||
|
DeviceStateReasonSupplicantFailed = 10,
|
||||||
|
DeviceStateReasonSupplicantTimeout = 11,
|
||||||
|
DeviceStateReasonPppStartFailed = 12,
|
||||||
|
DeviceStateReasonPppDisconnected = 13,
|
||||||
|
DeviceStateReasonPppFailed = 14,
|
||||||
|
DeviceStateReasonDhcpStartFailed = 15,
|
||||||
|
DeviceStateReasonDhcpError = 16,
|
||||||
|
DeviceStateReasonDhcpFailed = 17,
|
||||||
|
DeviceStateReasonSharedStartFailed = 18,
|
||||||
|
DeviceStateReasonSharedFailed = 19,
|
||||||
|
DeviceStateReasonAutoIpStartFailed = 20,
|
||||||
|
DeviceStateReasonAutoIpError = 21,
|
||||||
|
DeviceStateReasonAutoIpFailed = 22,
|
||||||
|
DeviceStateReasonModemBusy = 23,
|
||||||
|
DeviceStateReasonModemNoDialTone = 24,
|
||||||
|
DeviceStateReasonModemNoCarrier = 25,
|
||||||
|
DeviceStateReasonModemDialTimeout = 26,
|
||||||
|
DeviceStateReasonModemDialFailed = 27,
|
||||||
|
DeviceStateReasonModemInitFailed = 28,
|
||||||
|
DeviceStateReasonGsmApnFailed = 29,
|
||||||
|
DeviceStateReasonGsmRegistrationNotSearching = 30,
|
||||||
|
DeviceStateReasonGsmRegistrationDenied = 31,
|
||||||
|
DeviceStateReasonGsmRegistrationTimeout = 32,
|
||||||
|
DeviceStateReasonGsmRegistrationFailed = 33,
|
||||||
|
DeviceStateReasonGsmPinCheckFailed = 34,
|
||||||
|
DeviceStateReasonFirmwareMissing = 35,
|
||||||
|
DeviceStateReasonRemoved = 36,
|
||||||
|
DeviceStateReasonSleeping = 37,
|
||||||
|
DeviceStateReasonConnectionRemoved = 38,
|
||||||
|
DeviceStateReasonUserRequest = 39,
|
||||||
|
DeviceStateReasonCarrier = 40,
|
||||||
|
DeviceStateReasonConnectionAssumed = 41,
|
||||||
|
DeviceStateReasonSupplicantAvailable = 42,
|
||||||
|
DeviceStateReasonModemNotFound = 43,
|
||||||
|
DeviceStateReasonBtFailed = 44,
|
||||||
|
DeviceStateReasonGsmSimNotInserted = 45,
|
||||||
|
DeviceStateReasonGsmSimPinRequired = 46,
|
||||||
|
DeviceStateReasonGsmSimPukRequired = 47,
|
||||||
|
DeviceStateReasonGsmSimWrong = 48,
|
||||||
|
DeviceStateReasonInfinibandMode = 49,
|
||||||
|
DeviceStateReasonDependencyFailed = 50,
|
||||||
|
DeviceStateReasonBR2684Failed = 51,
|
||||||
|
DeviceStateReasonModemManagerUnavailable = 52,
|
||||||
|
DeviceStateReasonSsidNotFound = 53,
|
||||||
|
DeviceStateReasonSecondaryConnectionFailed = 54,
|
||||||
|
DeviceStateReasonDcbFoecFailed = 55,
|
||||||
|
DeviceStateReasonTeamdControlFailed = 56,
|
||||||
|
DeviceStateReasonModemFailed = 57,
|
||||||
|
DeviceStateReasonModemAvailable = 58,
|
||||||
|
DeviceStateReasonSimPinIncorrect = 59,
|
||||||
|
DeviceStateReasonNewActivision = 60,
|
||||||
|
DeviceStateReasonParentChanged = 61,
|
||||||
|
DeviceStateReasonParentManagedChanged = 62
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit WirelessNetworkManager(const QDBusObjectPath &devicePath, QObject *parent = 0);
|
||||||
|
|
||||||
|
QString udi() const;
|
||||||
|
QString macAddress() const;
|
||||||
|
QString interfaceName() const;
|
||||||
|
QString driver() const;
|
||||||
|
QString driverVersion() const;
|
||||||
|
|
||||||
|
bool connected() const;
|
||||||
|
bool managed() const;
|
||||||
|
DeviceState state() const;
|
||||||
|
DeviceStateReason stateReason() const;
|
||||||
|
|
||||||
|
void scanWirelessNetworks();
|
||||||
|
|
||||||
|
QList<WirelessAccessPoint *> accessPoints();
|
||||||
|
WirelessAccessPoint * getAccessPoint(const QString &ssid);
|
||||||
|
WirelessAccessPoint * getAccessPoint(const QDBusObjectPath &objectPath);
|
||||||
|
|
||||||
|
static QString deviceStateToString(const DeviceState &state);
|
||||||
|
static QString deviceStateReasonToString(const DeviceStateReason &stateReason);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_path;
|
||||||
|
|
||||||
|
QString m_udi;
|
||||||
|
QString m_macAddress;
|
||||||
|
QString m_interfaceName;
|
||||||
|
QString m_driver;
|
||||||
|
QString m_driverVersion;
|
||||||
|
|
||||||
|
// Can change
|
||||||
|
bool m_connected;
|
||||||
|
bool m_managed;
|
||||||
|
DeviceState m_state;
|
||||||
|
DeviceStateReason m_stateReason;
|
||||||
|
|
||||||
|
QHash<QDBusObjectPath, WirelessAccessPoint *> m_accessPointsTable;
|
||||||
|
|
||||||
|
void readAccessPoints();
|
||||||
|
void readWirelessDeviceProperties();
|
||||||
|
|
||||||
|
void setConnected(const bool &connected);
|
||||||
|
void setState(const DeviceState &state);
|
||||||
|
void setStateReason(const DeviceStateReason &stateReason);
|
||||||
|
void setManaged(const bool &managed);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void deviceStateChanged(uint newState, uint oldState, uint reason);
|
||||||
|
void accessPointAdded(const QDBusObjectPath &objectPath);
|
||||||
|
void accessPointRemoved(const QDBusObjectPath &objectPath);
|
||||||
|
void propertiesChanged(const QVariantMap &properties);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void connectedChanged(const bool &connected);
|
||||||
|
void managedChanged(const bool &managed);
|
||||||
|
void stateChanged(const DeviceState &state);
|
||||||
|
};
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug debug, WirelessNetworkManager *manager);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // WIRELESSNETWORKMANAGER_H
|
||||||
@ -56,6 +56,14 @@ HEADERS += $$top_srcdir/server/guhcore.h \
|
|||||||
$$top_srcdir/server/cloud/cloudconnectionhandler.h \
|
$$top_srcdir/server/cloud/cloudconnectionhandler.h \
|
||||||
$$top_srcdir/server/cloud/cloudjsonhandler.h \
|
$$top_srcdir/server/cloud/cloudjsonhandler.h \
|
||||||
$$top_srcdir/server/cloud/cloudmanager.h \
|
$$top_srcdir/server/cloud/cloudmanager.h \
|
||||||
|
$$top_srcdir/server/cloud/cloud.h \
|
||||||
|
$$top_srcdir/server/networkmanager/dbus-interfaces.h \
|
||||||
|
$$top_srcdir/server/networkmanager/networkmanager.h \
|
||||||
|
$$top_srcdir/server/networkmanager/networkdevice.h \
|
||||||
|
$$top_srcdir/server/networkmanager/wirelessaccesspoint.h \
|
||||||
|
$$top_srcdir/server/networkmanager/wirelessnetworkmanager.h \
|
||||||
|
$$top_srcdir/server/networkmanager/networksettings.h \
|
||||||
|
$$top_srcdir/server/networkmanager/networkconnection.h \
|
||||||
|
|
||||||
|
|
||||||
SOURCES += $$top_srcdir/server/guhcore.cpp \
|
SOURCES += $$top_srcdir/server/guhcore.cpp \
|
||||||
@ -112,3 +120,10 @@ SOURCES += $$top_srcdir/server/guhcore.cpp \
|
|||||||
$$top_srcdir/server/cloud/cloudconnectionhandler.cpp \
|
$$top_srcdir/server/cloud/cloudconnectionhandler.cpp \
|
||||||
$$top_srcdir/server/cloud/cloudjsonhandler.cpp \
|
$$top_srcdir/server/cloud/cloudjsonhandler.cpp \
|
||||||
$$top_srcdir/server/cloud/cloudmanager.cpp \
|
$$top_srcdir/server/cloud/cloudmanager.cpp \
|
||||||
|
$$top_srcdir/server/networkmanager/networkmanager.cpp \
|
||||||
|
$$top_srcdir/server/networkmanager/networkdevice.cpp \
|
||||||
|
$$top_srcdir/server/networkmanager/wirelessaccesspoint.cpp \
|
||||||
|
$$top_srcdir/server/networkmanager/wirelessnetworkmanager.cpp \
|
||||||
|
$$top_srcdir/server/networkmanager/networksettings.cpp \
|
||||||
|
$$top_srcdir/server/networkmanager/networkconnection.cpp \
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ INCLUDEPATH += ../libguh jsonrpc
|
|||||||
target.path = /usr/bin
|
target.path = /usr/bin
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
||||||
QT += sql xml websockets bluetooth
|
QT *= sql xml websockets bluetooth dbus
|
||||||
|
|
||||||
LIBS += -L$$top_builddir/libguh/ -lguh
|
LIBS += -L$$top_builddir/libguh/ -lguh
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>main</name>
|
<name>main</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="152"/>
|
<location filename="../server/main.cpp" line="153"/>
|
||||||
<source>
|
<source>
|
||||||
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
||||||
which allows to control a lot of different devices from many different
|
which allows to control a lot of different devices from many different
|
||||||
@ -23,12 +23,12 @@ Szenen undVerhaltensweisen des Systems festzulegen.
|
|||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="164"/>
|
<location filename="../server/main.cpp" line="165"/>
|
||||||
<source>Run guhd in the foreground, not as daemon.</source>
|
<source>Run guhd in the foreground, not as daemon.</source>
|
||||||
<translation>Starte guhd im Vordergrund, nicht als Service.</translation>
|
<translation>Starte guhd im Vordergrund, nicht als Service.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="167"/>
|
<location filename="../server/main.cpp" line="168"/>
|
||||||
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
||||||
|
|
||||||
Categories are:</source>
|
Categories are:</source>
|
||||||
@ -36,12 +36,12 @@ Categories are:</source>
|
|||||||
Es gibt folgende Kategorien:</translation>
|
Es gibt folgende Kategorien:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="184"/>
|
<location filename="../server/main.cpp" line="185"/>
|
||||||
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
||||||
<translation>Aktiviere alle Debug-Kategorien. Dieser Parameter überschreibt alle anderen Debug-Kategorien Parameter.</translation>
|
<translation>Aktiviere alle Debug-Kategorien. Dieser Parameter überschreibt alle anderen Debug-Kategorien Parameter.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="203"/>
|
<location filename="../server/main.cpp" line="204"/>
|
||||||
<source>No such debug category:</source>
|
<source>No such debug category:</source>
|
||||||
<translation>Diese Debug-Kategorie existiert nicht:</translation>
|
<translation>Diese Debug-Kategorie existiert nicht:</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>main</name>
|
<name>main</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="152"/>
|
<location filename="../server/main.cpp" line="153"/>
|
||||||
<source>
|
<source>
|
||||||
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
guh ( /[guːh]/ ) is an open source IoT (Internet of Things) server,
|
||||||
which allows to control a lot of different devices from many different
|
which allows to control a lot of different devices from many different
|
||||||
@ -23,12 +23,12 @@ for your environment.
|
|||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="164"/>
|
<location filename="../server/main.cpp" line="165"/>
|
||||||
<source>Run guhd in the foreground, not as daemon.</source>
|
<source>Run guhd in the foreground, not as daemon.</source>
|
||||||
<translation>Run guhd in the foreground, not as daemon.</translation>
|
<translation>Run guhd in the foreground, not as daemon.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="167"/>
|
<location filename="../server/main.cpp" line="168"/>
|
||||||
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
<source>Debug categories to enable. Prefix with "No" to disable. Warnings from all categories will be printed unless explicitly muted with "NoWarnings".
|
||||||
|
|
||||||
Categories are:</source>
|
Categories are:</source>
|
||||||
@ -37,12 +37,12 @@ Categories are:</source>
|
|||||||
Categories are:</translation>
|
Categories are:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="184"/>
|
<location filename="../server/main.cpp" line="185"/>
|
||||||
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
<source>Enables all debug categories. This parameter overrides all debug category parameters.</source>
|
||||||
<translation>Enables all debug categories. This parameter overrides all debug category parameters.</translation>
|
<translation>Enables all debug categories. This parameter overrides all debug category parameters.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../server/main.cpp" line="203"/>
|
<location filename="../server/main.cpp" line="204"/>
|
||||||
<source>No such debug category:</source>
|
<source>No such debug category:</source>
|
||||||
<translation>No such debug category:</translation>
|
<translation>No such debug category:</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|||||||
Reference in New Issue
Block a user