Add very preliminary network-manager backend support

pull/16/head
Timothy Pearson 12 years ago
parent 2d67c1c6b2
commit cfbdd55bb3

@ -831,6 +831,9 @@
/* Defined if compiling without arts */
#cmakedefine WITHOUT_ARTS 1
/* Defined if compiling with the network-manager backend */
#cmakedefine WITH_NETWORK_MANAGER_BACKEND 1
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD

@ -22,7 +22,15 @@ endif( WITH_LIBART )
if( WITH_NETWORK_MANAGER_BACKEND )
add_subdirectory( networkbackends/network-manager/dbus )
set ( TDENM_LIBRARIES tdenm_dbus-static )
set ( TDENM_INCLUDE_DIRECTORIES
${DBUS_TQT_INCLUDE_DIRS}
${NM_UTIL_INCLUDE_DIRS}
"${CMAKE_BINARY_DIR}/tdecore/networkbackends/network-manager/dbus"
)
set ( TDENM_LIBRARIES
tdenm_dbus-static
${DBUS_TQT_LIBRARIES}
)
set ( TDENM_BACKEND_SOURCES networkbackends/network-manager/network-manager.cpp )
endif( WITH_NETWORK_MANAGER_BACKEND )
@ -41,6 +49,7 @@ include_directories(
${LIBART_INCLUDE_DIRS}
${LIBIDN_INCLUDE_DIRS}
${GAMIN_INCLUDEDIR}
${TDENM_INCLUDE_DIRECTORIES}
)
link_directories(

@ -46,14 +46,15 @@ add_dbus_xml( p accesspointproxy AccessPointProxy DBus nm-access-point.xml )
add_dbus_xml( p activeconnectionproxy ActiveConnectionProxy DBus nm-active-connection.xml )
add_dbus_xml( p vpnconnectionproxy VPNConnectionProxy DBus nm-vpn-connection.xml )
add_dbus_xml( p vpnpluginproxy VPNPluginProxy DBus nm-vpn-plugin.xml )
add_dbus_xml( i networkmanagersettings SettingsInterface DBus nm-settings.xml )
add_dbus_xml( i connectionsettings ConnectionSettingsInterface DBus nm-settings-connection.xml )
add_dbus_xml( p networkmanagersettings SettingsInterface DBus nm-settings.xml )
add_dbus_xml( p connectionsettings ConnectionSettingsInterface DBus nm-settings-connection.xml )
# generate moc files
set( MOCHEADERS accesspointproxy.h deviceproxy.h networkmanagerproxy.h networkmanagerpppproxy.h ethernetproxy.h
infinibandproxy.h wifiproxy.h wimaxproxy.h activeconnectionproxy.h vpnconnectionproxy.h vpnpluginproxy.h modemproxy.h )
infinibandproxy.h wifiproxy.h wimaxproxy.h activeconnectionproxy.h vpnconnectionproxy.h vpnpluginproxy.h modemproxy.h
networkmanagersettings.h connectionsettings.h )
foreach( _header_file ${MOCHEADERS} )
get_filename_component( _basename "${_header_file}" NAME_WE )

File diff suppressed because it is too large Load Diff

@ -20,6 +20,90 @@
#include "tdenetworkconnections.h"
//====================================================================================================
// General NetworkManager DBUS service paths
//====================================================================================================
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
#define NM_DBUS_PATH_SETTINGS_CONNECTION "/org/freedesktop/NetworkManager/Settings/Connection"
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
#define NM_DBUS_SETTINGS_SERVICE "org.freedesktop.NetworkManager.Settings"
#define NM_DBUS_SETTINGS_CONNECTION_SERVICE "org.freedesktop.NetworkManager.Settings.Connection"
//====================================================================================================
//====================================================================================================
// These defines MUST be kept in sync with their respective introspection XML files
//====================================================================================================
#define NM_DEVICE_TYPE_UNKNOWN 0
#define NM_DEVICE_TYPE_ETHERNET 1
#define NM_DEVICE_TYPE_WIFI 2
#define NM_DEVICE_TYPE_UNUSED1 3
#define NM_DEVICE_TYPE_UNUSED2 4
#define NM_DEVICE_TYPE_BT 5
#define NM_DEVICE_TYPE_OLPC_MESH 6
#define NM_DEVICE_TYPE_WIMAX 7
#define NM_DEVICE_TYPE_MODEM 8
#define NM_DEVICE_TYPE_INFINIBAND 9
#define NM_DEVICE_TYPE_BOND 10
#define NM_DEVICE_TYPE_VLAN 11
#define NM_DEVICE_TYPE_ADSL 12
//====================================================================================================
#define NM_STATE_UNKNOWN 0
#define NM_STATE_ASLEEP 10
#define NM_STATE_DISCONNECTED 20
#define NM_STATE_DISCONNECTING 30
#define NM_STATE_CONNECTING 40
#define NM_STATE_CONNECTED_LOCAL 50
#define NM_STATE_CONNECTED_SITE 60
#define NM_STATE_CONNECTED_GLOBAL 70
//====================================================================================================
#define NM_DEVICE_STATE_UNKNOWN 0
#define NM_DEVICE_STATE_UNMANAGED 10
#define NM_DEVICE_STATE_UNAVAILABLE 20
#define NM_DEVICE_STATE_DISCONNECTED 30
#define NM_DEVICE_STATE_PREPARE 40
#define NM_DEVICE_STATE_CONFIG 50
#define NM_DEVICE_STATE_NEED_AUTH 60
#define NM_DEVICE_STATE_IP_CONFIG 70
#define NM_DEVICE_STATE_IP_CHECK 80
#define NM_DEVICE_STATE_SECONDARIES 90
#define NM_DEVICE_STATE_ACTIVATED 100
#define NM_DEVICE_STATE_DEACTIVATING 110
#define NM_DEVICE_STATE_FAILED 120
//====================================================================================================
#define NM_DEVICE_CAP_NONE 0
#define NM_DEVICE_CAP_NM_SUPPORTED 1
#define NM_DEVICE_CAP_CARRIER_DETECT 2
//====================================================================================================
#define NM_EAP_FAST_PROVISIONING_DISABLED 0
#define NM_EAP_FAST_PROVISIONING_UNAUTHONLY 1
#define NM_EAP_FAST_PROVISIONING_AUTHONLY 2
#define NM_EAP_FAST_PROVISIONING_BOTH 3
//====================================================================================================
#define NM_PASSWORD_SECRET_NONE 0
#define NM_PASSWORD_SECRET_AGENTOWNED 1
#define NM_PASSWORD_SECRET_NOTSAVED 2
#define NM_PASSWORD_SECRET_NOTREQUIRED 4
//====================================================================================================
#define NM_ACCESS_POINT_CAP_NONE 0x0
#define NM_ACCESS_POINT_CAP_PRIVACY 0x1
//====================================================================================================
#define NM_ACCESS_POINT_SEC_NONE 0x0
#define NM_ACCESS_POINT_SEC_PAIR_WEP40 0x1
#define NM_ACCESS_POINT_SEC_PAIR_WEP104 0x2
#define NM_ACCESS_POINT_SEC_PAIR_TKIP 0x4
#define NM_ACCESS_POINT_SEC_PAIR_CCMP 0x8
#define NM_ACCESS_POINT_SEC_GROUP_WEP40 0x10
#define NM_ACCESS_POINT_SEC_GROUP_WEP104 0x20
#define NM_ACCESS_POINT_SEC_GROUP_TKIP 0x40
#define NM_ACCESS_POINT_SEC_GROUP_CCMP 0x80
#define NM_ACCESS_POINT_SEC_KEY_MGMT_PSK 0x100
#define NM_ACCESS_POINT_SEC_KEY_MGMT_802_1X 0x200
//====================================================================================================
class TDENetworkConnectionManager_BackendNMPrivate;
class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkConnectionManager
{
Q_OBJECT
@ -33,16 +117,32 @@ class TDECORE_EXPORT TDENetworkConnectionManager_BackendNM : public TDENetworkCo
virtual TDENetworkDeviceInformation deviceInformation();
virtual void loadConnectionInformation();
virtual bool saveConnection(TDENetworkConnection connection);
virtual bool loadConnectionSecrets(TQString uuid);
virtual bool saveConnection(TDENetworkConnection* connection);
virtual bool deleteConnection(TQString uuid);
virtual TDENetworkConnectionList* connections();
virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus initiateConnection(TQString uuid);
virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus checkConnectionStatus(TQString uuid);
virtual TDENetworkConnectionStatus::TDENetworkConnectionStatus deactivateConnection(TQString uuid);
virtual TDENetworkHWNeighborList* siteSurvey();
virtual bool networkingEnabled();
virtual bool wiFiHardwareEnabled();
virtual bool enableWiFi(bool enable);
virtual bool wiFiEnabled();
private:
void internalProcessGlobalStateChanged(TQ_UINT32 state);
void internalProcessDeviceStateChanged(TQ_UINT32 newState, TQ_UINT32 oldState, TQ_UINT32 reason);
TDENetworkConnectionType::TDENetworkConnectionType nmDeviceTypeToTDEDeviceType(TQ_UINT32 nmType);
TQString deviceInterfaceString(TQString macAddress);
bool loadConnectionSecretsForGroup(TQString uuid, TQString group);
TDENetworkWiFiAPInfo* getAccessPointDetails(TQString dbusPath);
private:
TDENetworkConnectionManager_BackendNMPrivate* d;
};
#endif // _TDENETWORKBACKEND_NETWORKMANAGER_H

@ -0,0 +1,83 @@
/* This file is part of the TDE libraries
Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _TDENETWORKBACKEND_NETWORKMANAGER_P_H
#define _TDENETWORKBACKEND_NETWORKMANAGER_P_H
/* TQt headers */
#include <tqvaluelist.h>
#include <tqapplication.h>
#include <tqtimer.h>
/* TDE headers */
#include <kdebug.h>
#include <klocale.h>
/* TQDbus headers */
#include <tqdbusconnection.h>
#include <tqdbusobjectpath.h>
#include <tqdbusdata.h>
#include <tqdbuserror.h>
#include <tqdbusdatamap.h>
#include <tqdbusvariant.h>
#include <tqdbusdatalist.h>
/* NM headers */
//#include <NetworkManager.h>
/* Proxy headers */
#include "networkmanagerproxy.h"
#include "networkmanagersettings.h"
#include "connectionsettings.h"
#include "deviceproxy.h"
#include "ethernetproxy.h"
#include "wifiproxy.h"
#include "activeconnectionproxy.h"
#include "accesspointproxy.h"
typedef TQT_DBusDataMap<TQString> TQT_DBusTQStringDataMap;
typedef TQValueList<TQT_DBusData> TQT_DBusDataValueList;
typedef TQMap<uint, bool> NMAsyncCallIDMap;
typedef TQMap<uint, TQT_DBusTQStringDataMap> NMAsyncSettingsResponseMap;
typedef TQMap<uint, TQT_DBusObjectPath> NMAddConnectionAsyncResponseMap;
typedef TQValueList<TQT_DBusObjectPath> TQT_DBusObjectPathList;
class TDENetworkConnectionManager_BackendNMPrivate : public TQObject
{
Q_OBJECT
public:
TDENetworkConnectionManager_BackendNMPrivate() : m_networkManagerProxy(NULL), m_networkManagerSettings(NULL), m_networkDeviceProxy(NULL) {}
public:
DBus::NetworkManagerProxy* m_networkManagerProxy;
DBus::SettingsInterface* m_networkManagerSettings;
DBus::DeviceProxy* m_networkDeviceProxy;
NMAsyncCallIDMap nmConnectionSettingsAsyncCallWaiting;
NMAsyncSettingsResponseMap nmConnectionSettingsAsyncSettingsResponse;
NMAddConnectionAsyncResponseMap nmAddConnectionAsyncResponse;
public slots:
void processConnectionSettingsAsyncReply(int, const TQT_DBusDataMap<TQString>&);
void processConnectionSettingsUpdateAsyncReply(int);
void processAddConnectionAsyncReply(int, const TQT_DBusObjectPath&);
};
#endif // _TDENETWORKBACKEND_NETWORKMANAGER_P_H

@ -16,8 +16,6 @@
Boston, MA 02110-1301, USA.
*/
#define USE_NETWORKMANAGER_NETWORK_BACKEND
#include <tdehardwaredevices.h>
#include <tqfile.h>
@ -61,9 +59,12 @@
// Network connection manager
#include "tdenetworkconnections.h"
#ifdef USE_NETWORKMANAGER_NETWORK_BACKEND
// Compile-time configuration
#include "config.h"
#ifdef WITH_NETWORK_MANAGER_BACKEND
#include "networkbackends/network-manager/network-manager.h"
#endif // USE_NETWORKMANAGER_NETWORK_BACKEND
#endif // WITH_NETWORK_MANAGER_BACKEND
// BEGIN BLOCK
// Copied from include/linux/genhd.h
@ -1458,11 +1459,11 @@ void TDENetworkDevice::internalSetTxPackets(double tx) {
}
TDENetworkConnectionManager* TDENetworkDevice::connectionManager() {
#ifdef USE_NETWORKMANAGER_NETWORK_BACKEND
#ifdef WITH_NETWORK_MANAGER_BACKEND
if (!m_connectionManager) {
m_connectionManager = new TDENetworkConnectionManager_BackendNM(m_macAddress);
}
#endif // USE_NETWORKMANAGER_NETWORK_BACKEND
#endif // WITH_NETWORK_MANAGER_BACKEND
return m_connectionManager;
}

@ -19,13 +19,297 @@
#include "tdehardwaredevices.h"
#include "tdenetworkconnections.h"
#define SET_BIT(x, y) (x |= 1 << y)
#define TEST_BIT(x, y) ((x & (1 << y)) >> y)
/*================================================================================================*/
/* TDENetworkSearchDomain */
/*================================================================================================*/
TDENetworkSearchDomain::TDENetworkSearchDomain() {
m_isIPV6 = false;
}
TDENetworkSearchDomain::TDENetworkSearchDomain(TQString domain, bool ipv6) {
m_isIPV6 = ipv6;
m_domain = domain;
}
TDENetworkSearchDomain::~TDENetworkSearchDomain() {
//
}
TQString TDENetworkSearchDomain::searchDomain() {
return m_domain;
}
void TDENetworkSearchDomain::setSearchDomain(TQString domain, bool ipv6) {
m_isIPV6 = ipv6;
m_domain = domain;
}
bool TDENetworkSearchDomain::isIPv4() {
return !m_isIPV6;
}
bool TDENetworkSearchDomain::isIPv6() {
return m_isIPV6;
}
/*================================================================================================*/
/* TDENetMask */
/*================================================================================================*/
TDENetMask::TDENetMask() {
m_ipv4NetMask = 0;
m_isIPV6 = false;
}
TDENetMask::TDENetMask(TQ_UINT32 netmask) {
m_ipv4NetMask = netmask;
m_isIPV6 = false;
}
TDENetMask::TDENetMask(TQ_UINT8* netmask) {
m_ipv6NetMask = TQHostAddress(netmask);
m_isIPV6 = true;
}
TDENetMask::~TDENetMask() {
//
}
void TDENetMask::fromCIDRMask(unsigned char mask, bool ipv6) {
unsigned int i;
unsigned int j;
if (!ipv6) {
m_ipv4NetMask = 0;
for (i=31;i>=(32-mask);i--) {
SET_BIT(m_ipv4NetMask, i);
}
m_isIPV6 = false;
}
else {
Q_IPV6ADDR maskarray;
j=0;
unsigned int byteno=0;
memset(maskarray.c, 0, 16);
for (i=127;i>=(128-mask);i--) {
SET_BIT(maskarray.c[byteno], (i-((15-byteno)*8)));
j++;
if (j>7) {
j=0;
byteno++;
}
}
m_ipv6NetMask = TQHostAddress(maskarray);
m_isIPV6 = true;
}
}
unsigned char TDENetMask::toCIDRMask() {
unsigned int i;
unsigned int j;
if (!m_isIPV6) {
for (i=0; i<32; i++) {
if (TEST_BIT(m_ipv4NetMask, i)) {
break;
}
}
return 32-i;
}
else {
Q_IPV6ADDR mask = m_ipv6NetMask.toIPv6Address();
bool found = false;
for (j=0; j<16; ++j) {
for (i=0; i<8; i++) {
if (!TEST_BIT(mask.c[j], i)) {
found = true;
break;
}
}
if (found) break;
}
return ((j*8)+i);
}
}
void TDENetMask::fromString(TQString mask) {
if (mask.contains(".")) {
m_isIPV6 = false;
m_ipv4NetMask = 0;
TQStringList pieces = TQStringList::split(".", mask);
TQ_UINT8 chunk;
chunk = pieces[0].toUShort();
m_ipv4NetMask = m_ipv4NetMask | (chunk << 24);
chunk = pieces[1].toUShort();
m_ipv4NetMask = m_ipv4NetMask | (chunk << 16);
chunk = pieces[2].toUShort();
m_ipv4NetMask = m_ipv4NetMask | (chunk << 8);
chunk = pieces[3].toUShort();
m_ipv4NetMask = m_ipv4NetMask | (chunk << 0);
}
else if (mask.contains(":")) {
m_isIPV6 = true;
m_ipv6NetMask.setAddress(mask);
}
}
TQString TDENetMask::toString() {
if (!m_isIPV6) {
return TQString("%1.%2.%3.%4").arg((m_ipv4NetMask & 0xff000000) >> 24).arg((m_ipv4NetMask & 0x00ff0000) >> 16).arg((m_ipv4NetMask & 0x0000ff00) >> 8).arg((m_ipv4NetMask & 0x000000ff) >> 0);
}
else {
return m_ipv6NetMask.toString();
}
}
bool TDENetMask::isIPv4() {
return !m_isIPV6;
}
bool TDENetMask::isIPv6() {
return m_isIPV6;
}
/*================================================================================================*/
/* TDEMACAddress */
/*================================================================================================*/
TDEMACAddress::TDEMACAddress() {
m_macAddress.clear();
m_isValid = false;
}
TDEMACAddress::TDEMACAddress(TDENetworkByteList address) {
m_macAddress = address;
m_isValid = true;
}
TDEMACAddress::~TDEMACAddress() {
//
}
TDENetworkByteList TDEMACAddress::address() {
return m_macAddress;
}
void TDEMACAddress::setAddress(TDENetworkByteList address) {
m_macAddress = address;
m_isValid = true;
}
bool TDEMACAddress::isValid() {
return m_isValid;
}
void TDEMACAddress::fromString(TQString address) {
TQStringList pieces = TQStringList::split(":", address);
m_macAddress.clear();
for (TQStringList::Iterator it = pieces.begin(); it != pieces.end(); ++it) {
m_macAddress.append((*it).toUShort(0, 16));
}
m_isValid = true;
}
TQString TDEMACAddress::toString() {
TQString ret;
TDENetworkByteList::iterator it;
for (it = m_macAddress.begin(); it != m_macAddress.end(); ++it) {
if (ret != "") {
ret.append(":");
}
ret.append(TQString().sprintf("%02x", *it));
}
return ret.lower();
}
bool operator==(const TDEMACAddress &a1, const TDEMACAddress &a2) {
if (a1.m_macAddress.count() != a2.m_macAddress.count()) {
return false;
}
else {
unsigned int i;
for (i=0; i<a1.m_macAddress.count(); i++) {
if (a1.m_macAddress[i] != a2.m_macAddress[i]) {
return false;
}
}
return true;
}
}
/*================================================================================================*/
/* TDENetworkSingleIPConfiguration */
/*================================================================================================*/
TDENetworkSingleIPConfiguration::TDENetworkSingleIPConfiguration() {
valid = false;
}
TDENetworkSingleIPConfiguration::~TDENetworkSingleIPConfiguration() {
//
}
bool TDENetworkSingleIPConfiguration::isIPv4() {
return ipAddress.isIPv4Address() & valid;
}
bool TDENetworkSingleIPConfiguration::isIPv6() {
return ipAddress.isIPv6Address() & valid;
}
/*================================================================================================*/
/* TDENetworkSingleRouteConfiguration */
/*================================================================================================*/
TDENetworkSingleRouteConfiguration::TDENetworkSingleRouteConfiguration() {
valid = false;
}
TDENetworkSingleRouteConfiguration::~TDENetworkSingleRouteConfiguration() {
//
}
bool TDENetworkSingleRouteConfiguration::isIPv4() {
return ipAddress.isIPv4Address() & valid;
}
bool TDENetworkSingleRouteConfiguration::isIPv6() {
return ipAddress.isIPv6Address() & valid;
}
/*================================================================================================*/
/* TDENetworkIEEE8021xConfiguration */
/*================================================================================================*/
TDENetworkIEEE8021xConfiguration::TDENetworkIEEE8021xConfiguration() {
valid = false;
secretsValid = false;
fastProvisioningFlags = TDENetworkIEEE8021xFastFlags::None;
passwordFlags = TDENetworkPasswordHandlingFlags::None;
binaryPasswordFlags = TDENetworkPasswordHandlingFlags::None;
forceSystemCaCertificates = false;
}
TDENetworkIEEE8021xConfiguration::~TDENetworkIEEE8021xConfiguration() {
//
}
/*================================================================================================*/
/* TDENetworkIPConfiguration */
/*================================================================================================*/
TDENetworkIPConfiguration::TDENetworkIPConfiguration() {
valid = false;
connectionFlags = TDENetworkIPConfigurationFlags::Invalid;
connectionFlags = TDENetworkIPConfigurationFlags::IPV4DHCPIP | \
TDENetworkIPConfigurationFlags::IPV4DHCPDNS | \
TDENetworkIPConfigurationFlags::IPV4DHCPRoutes | \
TDENetworkIPConfigurationFlags::IPV4MayUseAsDefaultRoute | \
TDENetworkIPConfigurationFlags::IPV6DHCPIP | \
TDENetworkIPConfigurationFlags::IPV6DHCPDNS | \
TDENetworkIPConfigurationFlags::IPV6DHCPRoutes | \
TDENetworkIPConfigurationFlags::IPV6MayUseAsDefaultRoute;
}
TDENetworkIPConfiguration::~TDENetworkIPConfiguration() {
@ -86,14 +370,30 @@ TDENetworkWiFiAPInfo::~TDENetworkWiFiAPInfo() {
/* TDENetworkConnection */
/*================================================================================================*/
TDENetworkConnection::TDENetworkConnection() : TQObject() {
//
TDENetworkConnection::TDENetworkConnection() {
autoConnect = false;
fullDuplex = true;
requireIPV4 = false;
requireIPV6 = false;
mtu = 0;
}
TDENetworkConnection::~TDENetworkConnection() {
//
}
/*================================================================================================*/
/* TDEWiredEthernetConnection */
/*================================================================================================*/
TDEWiredEthernetConnection::TDEWiredEthernetConnection() : TDENetworkConnection() {
//
}
TDEWiredEthernetConnection::~TDEWiredEthernetConnection() {
//
}
/*================================================================================================*/
/* TDEWiFiConnection */
/*================================================================================================*/
@ -110,7 +410,7 @@ TDEWiFiConnection::~TDEWiFiConnection() {
/* TDENetworkConnectionManager */
/*================================================================================================*/
TDENetworkConnectionManager::TDENetworkConnectionManager(TQString macAddress) : TQObject(), m_connectionList(NULL), m_macAddress(macAddress) {
TDENetworkConnectionManager::TDENetworkConnectionManager(TQString macAddress) : TQObject(), m_connectionList(NULL), m_hwNeighborList(NULL), m_macAddress(macAddress), m_prevConnectionStatus(TDENetworkGlobalManagerFlags::Unknown) {
//
}
@ -122,6 +422,49 @@ TQString TDENetworkConnectionManager::deviceMACAddress() {
return m_macAddress;
}
TDENetworkConnectionList* TDENetworkConnectionManager::connections() {
return m_connectionList;
}
TDENetworkConnection* TDENetworkConnectionManager::findConnectionByUUID(TQString uuid) {
TDENetworkConnection *connection;
for (connection = m_connectionList->first(); connection; connection = m_connectionList->next()) {
if (connection->UUID == uuid) {
return connection;
}
}
return NULL;
}
void TDENetworkConnectionManager::clearTDENetworkConnectionList() {
TDENetworkConnection *connection;
for (connection = m_connectionList->first(); connection; connection = m_connectionList->next()) {
delete connection;
}
m_connectionList->clear();
}
void TDENetworkConnectionManager::clearTDENetworkHWNeighborList() {
TDENetworkHWNeighbor *neighbor;
for (neighbor = m_hwNeighborList->first(); neighbor; neighbor = m_hwNeighborList->next()) {
delete neighbor;
}
m_hwNeighborList->clear();
}
void TDENetworkConnectionManager::internalNetworkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState) {
emit(networkConnectionStateChanged(m_prevConnectionStatus, newState));
m_prevConnectionStatus = newState;
}
void TDENetworkConnectionManager::internalNetworkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TQString hwAddress) {
if (!m_prevDeviceStatus.contains("hwAddress")) {
m_prevDeviceStatus[hwAddress] = TDENetworkConnectionStatus::Invalid;
}
emit(networkDeviceStateChanged(m_prevDeviceStatus[hwAddress], newState, hwAddress));
m_prevDeviceStatus[hwAddress] = newState;
}
/*================================================================================================*/
/* End */
/*================================================================================================*/

@ -23,6 +23,7 @@
#include <tqstring.h>
#include <tqptrlist.h>
#include <tqstringlist.h>
#include <tqhostaddress.h>
#include "kiconloader.h"
#include "tdelibs_export.h"
@ -40,10 +41,26 @@
inline x operator~(x a) \
{ \
return static_cast<x>(~static_cast<int>(a)); \
} \
\
inline x &operator|=(x& a, const x& b) \
{ \
a = static_cast<x>(static_cast<int>(a) | static_cast<int>(b)); \
return a; \
} \
\
inline x &operator&=(x& a, const x& b) \
{ \
a = static_cast<x>(static_cast<int>(a) & static_cast<int>(b)); \
return a; \
}
typedef TQValueList<TQ_UINT8> TDENetworkByteList;
typedef TQValueList<TQHostAddress> TDENetworkAddressList;
namespace TDENetworkConnectionType {
enum TDENetworkConnectionType {
BackendOnly,
WiredEthernet,
WiFi,
Bluetooth,
@ -139,6 +156,50 @@ namespace TDENetworkWiFiConnectionCipher {
};
};
namespace TDENetworkIEEE8021xType {
enum TDENetworkIEEE8021xType {
None,
LEAP,
MD5,
PAP,
CHAP,
MSCHAP,
MSCHAPV2,
Fast,
PSK,
PAX,
SAKE,
GPSK,
TLS,
PEAP,
TTLS,
SIM,
GTC,
OTP
};
};
namespace TDENetworkIEEE8021xFastFlags {
enum TDENetworkIEEE8021xFastFlags {
None = 0x00000000,
AllowUnauthenticated = 0x00000001,
AllowAuthenticated = 0x00000002
};
CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkIEEE8021xFastFlags)
};
namespace TDENetworkPasswordHandlingFlags {
enum TDENetworkPasswordHandlingFlags {
None = 0x00000000,
NoSave = 0x00000001,
NoPrompt = 0x00000002,
ExternalStorage = 0x00000004
};
CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkPasswordHandlingFlags)
};
namespace TDENetworkConnectionStatus {
enum TDENetworkConnectionStatus {
Invalid = 0x00000000,
@ -146,17 +207,18 @@ namespace TDENetworkConnectionStatus {
Connected = 0x00000002,
LinkUnavailable = 0x00000004,
EstablishingLink = 0x00000008,
ConfiguringProtocols = 0x00000010,
Reconnecting = 0x00000020,
LinkLost = 0x00000040,
LinkLocalAccess = 0x00000080,
SiteLocalAccess = 0x00000100,
GlobalAccess = 0x00000200,
UnManaged = 0x00000400,
NeedAuthorization = 0x00000800,
Failed = 0x00001000,
VerifyingProtocols = 0x00002000,
DependencyWait = 0x00004000
DeactivatingLink = 0x00000010,
ConfiguringProtocols = 0x00000020,
Reconnecting = 0x00000040,
LinkLost = 0x00000080,
LinkLocalAccess = 0x00000100,
SiteLocalAccess = 0x00000200,
GlobalAccess = 0x00000400,
UnManaged = 0x00000800,
NeedAuthorization = 0x00001000,
Failed = 0x00002000,
VerifyingProtocols = 0x00004000,
DependencyWait = 0x00008000
};
CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkConnectionStatus)
@ -164,16 +226,168 @@ namespace TDENetworkConnectionStatus {
namespace TDENetworkIPConfigurationFlags {
enum TDENetworkIPConfigurationFlags {
Invalid = 0x00000000,
IPV4 = 0x00000001,
IPV6 = 0x00000002,
DHCP = 0x00000004,
StaticIP = 0x00000008
None = 0x00000000,
IPV4DHCPIP = 0x00000001,
IPV4DHCPDNS = 0x00000002,
IPV4DHCPRoutes = 0x00000004,
IPV4LocalOnly = 0x00000008,
IPV4StartConnectionSharingServer = 0x00000010,
IPV4Disabled = 0x00000020,
IPV4MayUseAsDefaultRoute = 0x00000040,
IPV6DHCPIP = 0x00000080,
IPV6DHCPDNS = 0x00000100,
IPV6DHCPRoutes = 0x00000200,
IPV6LocalOnly = 0x00000400,
IPV6StartConnectionSharingServer = 0x00000800,
IPV6Disabled = 0x00001000,
IPV6MayUseAsDefaultRoute = 0x00002000
};
CREATE_FLAG_BITWISE_MANIPULATION_FUNCTIONS(TDENetworkIPConfigurationFlags)
};
class TDECORE_EXPORT TDENetworkSearchDomain
{
public:
TDENetworkSearchDomain();
TDENetworkSearchDomain(TQString domain, bool ipv6=false);
~TDENetworkSearchDomain();
TQString searchDomain();
void setSearchDomain(TQString domain, bool ipv6=false);
bool isIPv4();
bool isIPv6();
private:
TQString m_domain;
bool m_isIPV6;
};
typedef TQValueList<TDENetworkSearchDomain> TDENetworkSearchDomainList;
class TDECORE_EXPORT TDENetMask
{
public:
TDENetMask();
TDENetMask(TQ_UINT32 netmask);
TDENetMask(TQ_UINT8* netmask);
~TDENetMask();
void fromCIDRMask(unsigned char mask, bool ipv6=false);
unsigned char toCIDRMask();
void fromString(TQString mask);
TQString toString();
bool isIPv4();
bool isIPv6();
private:
TQ_UINT32 m_ipv4NetMask;
TQHostAddress m_ipv6NetMask;
bool m_isIPV6;
};
class TDECORE_EXPORT TDEMACAddress
{
public:
TDEMACAddress();
TDEMACAddress(TDENetworkByteList address);
~TDEMACAddress();
TDENetworkByteList address();
void setAddress(TDENetworkByteList address);
TQString toString();
void fromString(TQString address);
bool isValid();
private:
bool m_isValid;
TDENetworkByteList m_macAddress;
friend bool operator==(const TDEMACAddress &a1, const TDEMACAddress &a2);
};
bool operator==(const TDEMACAddress &a1, const TDEMACAddress &a2);
class TDECORE_EXPORT TDENetworkSingleIPConfiguration
{
public:
TDENetworkSingleIPConfiguration();
~TDENetworkSingleIPConfiguration();
bool isIPv4();
bool isIPv6();
public:
bool valid;
TQHostAddress ipAddress;
TDENetMask networkMask;
TQHostAddress gateway;
};
typedef TQValueList<TDENetworkSingleIPConfiguration> TDENetworkSingleIPConfigurationList;
class TDECORE_EXPORT TDENetworkSingleRouteConfiguration
{
public:
TDENetworkSingleRouteConfiguration();
~TDENetworkSingleRouteConfiguration();
bool isIPv4();
bool isIPv6();
public:
bool valid;
TQHostAddress ipAddress;
TDENetMask networkMask;
TQHostAddress gateway;
TQ_UINT32 metric;
};
typedef TQValueList<TDENetworkSingleRouteConfiguration> TDENetworkSingleRouteConfigurationList;
class TDENetworkIEEE8021xConfiguration
{
public:
TDENetworkIEEE8021xConfiguration();
~TDENetworkIEEE8021xConfiguration();
public:
bool valid;
bool secretsValid;
TDENetworkIEEE8021xType::TDENetworkIEEE8021xType type;
TQString userName;
TQString anonymousUserName;
TQString pacFileName;
TQByteArray caCertificate;
TQString additionalCAFilesPath;
TQString authServerCertSubjectMatch;
TQStringList alternateAuthServerCertSubjectMatch;
TQByteArray clientCertificate;
TQString forcePEAPVersion;
TQString forcePEAPLabel;
TDENetworkIEEE8021xFastFlags::TDENetworkIEEE8021xFastFlags fastProvisioningFlags;
TQString phase2NonEAPAuthMethod;
TQString phase2EAPAuthMethod;
TQByteArray phase2CaCertificate;
TQString phase2CaFilesPath;
TQString phase2AuthServerCertSubjectMatch;
TQStringList phase2AlternateAuthServerCertSubjectMatch;
TQByteArray phase2ClientCertificate;
TQString password;
TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags passwordFlags;
TQByteArray binaryPassword;
TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags binaryPasswordFlags;
TQByteArray privateKey;
TQString privateKeyPassword;
TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags privateKeyPasswordFlags;
TQByteArray phase2PrivateKey;
TQString phase2PrivateKeyPassword;
TDENetworkPasswordHandlingFlags::TDENetworkPasswordHandlingFlags phase2PrivateKeyPasswordFlags;
bool forceSystemCaCertificates;
};
class TDECORE_EXPORT TDENetworkIPConfiguration
{
public:
@ -183,11 +397,13 @@ class TDECORE_EXPORT TDENetworkIPConfiguration
public:
bool valid;
TDENetworkIPConfigurationFlags::TDENetworkIPConfigurationFlags connectionFlags;
TQString ipAddress;
TQString networkMask;
TQString gateway;
TQString broadcast;
TQString destination;
TDENetworkSingleIPConfigurationList ipConfigurations;
TDENetworkSingleRouteConfigurationList routeConfigurations;
TQHostAddress broadcast;
TQHostAddress destination;
TDENetworkAddressList resolvers;
TDENetworkSearchDomainList searchDomains;
TQString dhcpClientIdentifier;
};
class TDECORE_EXPORT TDENetworkWiFiDeviceInfo
@ -198,8 +414,8 @@ class TDECORE_EXPORT TDENetworkWiFiDeviceInfo
public:
bool valid;
TQString hwAddress;
TQString permanentHWAddress;
TDEMACAddress hwAddress;
TDEMACAddress permanentHWAddress;
TDEWiFiMode::TDEWiFiMode operatingMode;
unsigned int bitrate;
TQString activeAccessPointBSSID;
@ -225,7 +441,7 @@ class TDECORE_EXPORT TDENetworkDeviceInformation
bool autoConnect;
bool firmwareMissing;
TDENetworkConnectionType::TDENetworkConnectionType deviceType;
TDENetworkWiFiDeviceInfo wirelessInfo;
TDENetworkWiFiDeviceInfo wiFiInfo;
};
class TDECORE_EXPORT TDENetworkHWNeighbor
@ -245,8 +461,9 @@ class TDECORE_EXPORT TDENetworkWiFiAPInfo : public TDENetworkHWNeighbor
~TDENetworkWiFiAPInfo();
public:
TQString SSID;
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags flags;
TQByteArray SSID;
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags wpaFlags;
TDENetworkWiFiAPFlags::TDENetworkWiFiAPFlags rsnFlags;
unsigned int frequency;
TQString BSSID;
unsigned int maxBitrate;
@ -255,28 +472,38 @@ class TDECORE_EXPORT TDENetworkWiFiAPInfo : public TDENetworkHWNeighbor
typedef TQPtrList< TDENetworkHWNeighbor > TDENetworkHWNeighborList;
class TDECORE_EXPORT TDENetworkConnection : public TQObject
class TDECORE_EXPORT TDENetworkConnection
{
Q_OBJECT
public:
TDENetworkConnection();
~TDENetworkConnection();
virtual ~TDENetworkConnection();
public:
TQString UUID;
TQString friendlyName;
TDENetworkIPConfiguration ipConfig;
TDEMACAddress lockedHWAddress;
TDEMACAddress manualHWAddress;
bool autoConnect;
bool fullDuplex;
bool requireIPV4;
bool requireIPV6;
TQ_UINT32 mtu;
TDENetworkIEEE8021xConfiguration eapConfig;
};
class TDECORE_EXPORT TDEWiFiConnection : public TDENetworkConnection
class TDECORE_EXPORT TDEWiredEthernetConnection : public TDENetworkConnection
{
Q_OBJECT
public:
TDEWiredEthernetConnection();
virtual ~TDEWiredEthernetConnection();
};
class TDECORE_EXPORT TDEWiFiConnection : public TDENetworkConnection
{
public:
TDEWiFiConnection();
~TDEWiFiConnection();
virtual ~TDEWiFiConnection();
public:
TQString SSID;
@ -297,6 +524,8 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
/**
* Constructor.
* @param macAddress The MAC address of the hardware device
* If an empty MAC address is passed, this object will make global networking backend
* methods available exclusively (TDENetworkConnectionType::BackendOnly).
*/
TDENetworkConnectionManager(TQString macAddress);
@ -327,15 +556,25 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
/**
* Loads all connection information from the configuration backend
* Secret information must be loaded separately via a call to
* loadConnectionSecrets(TQString uuid) after this method has been
* executed at least once.
*/
virtual void loadConnectionInformation() = 0;
/**
* @param connection a TDENetworkConnection object containing a
* @param uuid a TQString conntaining the UUID of a connection for which to
* load secrets from the configuration backend.
* @return true on success, false on failure.
*/
virtual bool loadConnectionSecrets(TQString uuid) = 0;
/**
* @param connection a pointer to a TDENetworkConnection object containing a
* connection to save to the configuration backend.
* @return true on success, false on failure.
*/
virtual bool saveConnection(TDENetworkConnection connection) = 0;
virtual bool saveConnection(TDENetworkConnection* connection) = 0;
/**
* @param uuid a TQString conntaining the UUID of a connection to
@ -344,21 +583,6 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/
virtual bool deleteConnection(TQString uuid) = 0;
/**
* @return a TDENetworkConnectionList object containing a list of all
* possible connections this connection manager is aware of, regardless
* of current state or availability.
*
* loadConnectionInformation() should be called at least once before calling
* this method, in order to update internal connection information from the
* configuration backend.
*
* Note that the returned list is internally managed and must not be deleted!
* Also note that pointers in the list may become invalid on subsequent calls to
* loadConnectionInformation(), saveConnection(), deleteConnection(), or connections().
*/
virtual TDENetworkConnectionList* connections() = 0;
/**
* Initiates a connection with UUID @param uuid.
* @return A TDENetworkConnectionStatus enum value with the current connection status
@ -390,9 +614,78 @@ class TDECORE_EXPORT TDENetworkConnectionManager : public TQObject
*/
virtual TDENetworkHWNeighborList* siteSurvey() = 0;
private:
/**
* @return true if networking is enabled, false if not.
*/
virtual bool networkingEnabled() = 0;
/**
* @return true if WiFi hardware is enabled, false if not.
*/
virtual bool wiFiHardwareEnabled() = 0;
/**
* @param enable true to enable WiFi, false to disable it.
* @return true on success, false on failure.
*/
virtual bool enableWiFi(bool enable) = 0;
/**
* @return true if WiFi is enabled, false if not.
*/
virtual bool wiFiEnabled() = 0;
signals:
/**
* Emitted whenever the state of the system's connection changes
* If previous state data was unavailable, @param previousState will contain TDENetworkConnectionStatus::Invalid
*/
void networkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState, TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags previousState);
/**
* Emitted whenever the state of a device changes
* If previous state data was unavailable, @param previousState will contain TDENetworkConnectionStatus::Invalid
* If the global connection state has changed, @param hwAddress will be empty, otherwise it will contain the MAC address
* of the networking hardware that has changed state.
*/
void networkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus previousState, TQString hwAddress);
public:
/**
* @return a TDENetworkConnectionList object containing a list of all
* possible connections this connection manager is aware of, regardless
* of current state or availability.
*
* loadConnectionInformation() should be called at least once before calling
* this method, in order to update internal connection information from the
* configuration backend.
*
* Note that the returned list is internally managed and must not be deleted!
* Also note that pointers in the list may become invalid on subsequent calls to
* loadConnectionInformation(), saveConnection(), deleteConnection(), or connections().
*/
virtual TDENetworkConnectionList* connections();
/**
* @return a pointer to a TDENetworkConnection object with the specified @param uuid,
* or a NULL pointer if no such connection exists.
*
* Note that the returned object is internally managed and must not be deleted!
*/
TDENetworkConnection* findConnectionByUUID(TQString uuid);
protected:
void clearTDENetworkConnectionList();
void clearTDENetworkHWNeighborList();
void internalNetworkConnectionStateChanged(TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags newState);
void internalNetworkDeviceStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TQString hwAddress=TQString::null);
protected:
TDENetworkConnectionList* m_connectionList;
TDENetworkHWNeighborList* m_hwNeighborList;
TQString m_macAddress;
TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags m_prevConnectionStatus;
TQMap<TQString, TDENetworkConnectionStatus::TDENetworkConnectionStatus> m_prevDeviceStatus;
};
#endif // _TDENETWORKCONNECTIONS_H
Loading…
Cancel
Save