1
/* This file is part of the KDE project
2
Copyright (C) 2006 Will Stephenson <wstephenson@kde.org>
3
Copyright (C) 2007 Kevin Ottens <ervin@kde.org>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License version 2 as published by the Free Software Foundation.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
21
#ifndef SOLID_CONTROL_NETWORKINTERFACE_H
22
#define SOLID_CONTROL_NETWORKINTERFACE_H
24
#include <QtCore/QObject>
25
#include <QtCore/QStringList>
26
#include <QtNetwork/QNetworkAddressEntry>
28
#include "solid_control_export.h"
30
#include "networkipv4config.h"
36
class NetworkInterfacePrivate;
39
* This interface represents a generic network interface in the system
41
class SOLIDCONTROL_EXPORT NetworkInterface : public QObject
44
Q_ENUMS(ConnectionState Capability Type)
47
Q_DECLARE_PRIVATE(NetworkInterface)
50
// == NM ActivationStage
52
* Device connection states describe the possible states of a
53
* network connection from the user's point of view. For
54
* simplicity, states from several different layers are present -
55
* this is a high level view
57
enum ConnectionState{ UnknownState, Unmanaged, Unavailable, Disconnected, Preparing,
58
Configuring, NeedAuth, IPConfig, Activated, Failed };
60
* Enums describing the reason for a connection state change
62
enum ConnectionStateChangeReason{ NoReason=0, UnknownReason, NowManagedReason, NowUnmanagedReason,
63
ConfigFailedReason, ConfigUnavailableReason,
64
ConfigExpiredReason, NoSecretsReason, AuthSupplicantDisconnectReason,
65
AuthSupplicantConfigFailedReason, AuthSupplicantFailedReason,
66
AuthSupplicantTimeoutReason, PppStartFailedReason, PppDisconnectReason,
67
PppFailedReason, DhcpStartFailedReason, DhcpErrorReason, DhcpFailedReason,
68
SharedStartFailedReason, SharedFailedReason,
69
AutoIpStartFailedReason, AutoIpErrorReason, AutoIpFailedReason,
70
ModemBusyReason, ModemNoDialToneReason, ModemNoCarrierReason, ModemDialTimeoutReason,
71
ModemDialFailedReason, ModemInitFailedReason,
72
GsmApnSelectFailedReason, GsmNotSearchingReason, GsmRegistrationDeniedReason,
73
GsmRegistrationTimeoutReason, GsmRegistrationFailedReason,
74
GsmPinCheckFailedReason, FirmwareMissingReason, DeviceRemovedReason,
75
SleepingReason, ConnectionRemovedReason, UserRequestedReason, CarrierReason,
78
* Possible Device capabilities
79
* - IsManageable: denotes that the device can be controlled by this API
80
* - SupportsCarrierDetect: the device informs us when it is plugged in to the medium
81
* - SupportsWirelessScan: the device can scan for wireless networks
83
enum Capability { IsManageable = 0x1, SupportsCarrierDetect = 0x2 };
86
* - Ieee8023: wired ethernet
87
* - Ieee80211: the popular family of wireless networks
88
* - Serial: generic serial type for non-cellular ppp connections
89
* - Gsm: cellular device of the GSM family, used in Europe
90
* - Cdma: cellular device of the CDMA family, used in the USA
91
* - Bluetooth: network bluetooth device (usually a cell phone)
93
enum Type { UnknownType = 0x0, Ieee8023 = 0x1, Ieee80211 = 0x2, Serial = 0x4, Gsm = 0x8, Cdma = 0x10, Bluetooth = 0x20 };
95
Q_DECLARE_FLAGS(Capabilities, Capability)
96
Q_DECLARE_FLAGS(Types, Type)
99
* Creates a new NetworkInterface object.
101
* @param backendObject the network object provided by the backend
103
explicit NetworkInterface(QObject *backendObject);
106
* Constructs a copy of a network.
108
* @param network the network to copy
110
NetworkInterface(const NetworkInterface &network);
113
* Destroys a NetworkInterface object.
115
virtual ~NetworkInterface();
118
* Retrieves the interface type. This is a virtual function that will return the
119
* proper type of all sub-classes.
121
* @returns the NetworkInterface::Type that corresponds to this device.
123
virtual Type type() const;
126
* Retrieves the Unique Network Identifier (UNI) of the NetworkInterface.
127
* This identifier is unique for each network and network interface in the system.
129
* @returns the Unique Network Identifier of the current network
134
* Retrieves the Unique Device Identifier (UDI).
135
* This is needed for ModemManager support.
137
* @returns the Unique Device Identifier of the current device
142
* The system name for the network interface
144
QString interfaceName() const;
147
* The name of the device's data interface when available. This property
148
* may not refer to the actual data interface until the device has
149
* successfully established a data connection, indicated by the device's
150
* State becoming ACTIVATED.
152
QString ipInterfaceName() const;
155
* If TRUE, indicates the device is likely missing firmware necessary for
158
bool firmwareMissing() const;
161
* Handle for the system driver controlling this network interface
163
QString driver() const;
166
* Disconnects a device and prevents the device from automatically
167
* activating further connections without user intervention.
169
void disconnectInterface() const;
171
Solid::Control::IPv4Config ipV4Config() const;
173
* Retrieves the activation status of this network interface.
175
* @return true if this network interface is active, false otherwise
177
bool isActive() const;
180
* Retrieves the current state of the network connection held by this device.
181
* It's a high level view of the connection. It is user oriented, so
182
* actually it provides state coming from different layers.
184
* @return the current connection state
185
* @see Solid::Control::NetworkInterface::ConnectionState
187
ConnectionState connectionState() const;
190
* Retrieves the maximum speed as reported by the device.
191
* Note that this is only a design related piece of information, and that
192
* the device might not reach this maximum.
194
* @return the device's maximum speed
196
int designSpeed() const;
199
* Retrieves the capabilities supported by this device.
201
* @return the capabilities of the device
203
Capabilities capabilities() const;
207
* This signal is emitted when the settings of this network have changed.
209
void ipDetailsChanged();
212
* This signal is emitted when the device's link status changed. For example, if there
213
* is no carrier anymore.
215
* @param linkActivated true if the carrier got detected, false otherwise
217
void linkUpChanged(bool linkActivated);
220
* This signal is emitted when the device's link status changed. For example, if there
221
* is no carrier anymore.
223
* @param state the new state of the connection
224
* @see Solid::Control::NetworkInterface::ConnectionState
226
void connectionStateChanged(int state);
229
* This signal is emitted when the device's link status changed.
231
* @param new_state the new state of the connection
232
* @param old_state the previous state of the connection
233
* @param reason the reason for the state change, if any. ReasonNone where the backend
234
* provides no reason.
235
* @see Solid::Control::NetworkInterface::ConnectionState
237
void connectionStateChanged(int new_state, int old_state, int reason );
243
NetworkInterface(NetworkInterfacePrivate &dd, QObject *backendObject);
248
NetworkInterface(NetworkInterfacePrivate &dd, const NetworkInterface &network);
250
NetworkInterfacePrivate *d_ptr;
253
//HACK: to make NetworkList polymorphic (containing both wired and wireless networks, I used Network * here - Will.
255
typedef QList<NetworkInterface *> NetworkInterfaceList;
261
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::NetworkInterface::Capabilities)
262
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::NetworkInterface::Types)
264
#endif //SOLID_CONTROL_NETWORKINTERFACE_H