add more spacing
[personal-kdebase.git] / workspace / libs / solid / control / networkinterface.h
blob9e7f1db7edd2effbd71984d8187910a48488ad2e
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"
32 namespace Solid
34 namespace Control
36 class NetworkInterfacePrivate;
38 /**
39 * This interface represents a generic network interface in the system
41 class SOLIDCONTROL_EXPORT NetworkInterface : public QObject
43 Q_OBJECT
44 Q_ENUMS(ConnectionState Capability Type)
45 Q_FLAGS(Capabilities)
46 Q_DECLARE_PRIVATE(NetworkInterface)
48 public:
49 // == NM ActivationStage
50 /**
51 * Device connection states describe the possible states of a
52 * network connection from the user's point of view. For
53 * simplicity, states from several different layers are present -
54 * this is a high level view
56 enum ConnectionState{ UnknownState, Unmanaged, Unavailable, Disconnected, Preparing,
57 Configuring, NeedAuth, IPConfig, Activated, Failed };
58 /**
59 * Possible Device capabilities
60 * - IsManageable: denotes that the device can be controlled by this API
61 * - SupportsCarrierDetect: the device informs us when it is plugged in to the medium
62 * - SupportsWirelessScan: the device can scan for wireless networks
64 enum Capability { IsManageable = 0x1, SupportsCarrierDetect = 0x2 };
65 /**
66 * Device medium types
67 * - Ieee8023: wired ethernet
68 * - Ieee80211: the popular family of wireless networks
69 * - Gsm: cellular device of the GSM family, used in Europe
70 * - Cdma: cellular device of the CDMA family, used in the USA
72 enum Type { UnknownType, Ieee8023, Ieee80211, Serial, Gsm, Cdma };
74 Q_DECLARE_FLAGS(Capabilities, Capability)
76 /**
77 * Creates a new NetworkInterface object.
79 * @param backendObject the network object provided by the backend
81 explicit NetworkInterface(QObject *backendObject);
83 /**
84 * Constructs a copy of a network.
86 * @param network the network to copy
88 NetworkInterface(const NetworkInterface &network);
90 /**
91 * Destroys a NetworkInterface object.
93 virtual ~NetworkInterface();
95 /**
96 * Retrieves the interface type. This is a virtual function that will return the
97 * proper type of all sub-classes.
99 * @returns the NetworkInterface::Type that corresponds to this device.
101 virtual Type type() const;
104 * Retrieves the Unique Network Identifier (UNI) of the NetworkInterface.
105 * This identifier is unique for each network and network interface in the system.
107 * @returns the Unique Network Identifier of the current network
109 QString uni() const;
112 * The system name for the network interface
114 QString interfaceName() const;
117 * Handle for the system driver controlling this network interface
119 QString driver() const;
121 Solid::Control::IPv4Config ipV4Config() const;
123 * Retrieves the activation status of this network interface.
125 * @return true if this network interface is active, false otherwise
127 bool isActive() const;
130 * Retrieves the current state of the network connection held by this device.
131 * It's a high level view of the connection. It is user oriented, so
132 * actually it provides state coming from different layers.
134 * @return the current connection state
135 * @see Solid::Control::NetworkInterface::ConnectionState
137 ConnectionState connectionState() const;
140 * Retrieves the maximum speed as reported by the device.
141 * Note that this is only a design related piece of information, and that
142 * the device might not reach this maximum.
144 * @return the device's maximum speed
146 int designSpeed() const;
149 * Retrieves the capabilities supported by this device.
151 * @return the capabilities of the device
153 Capabilities capabilities() const;
155 Q_SIGNALS:
157 * This signal is emitted when the settings of this network have changed.
159 void ipDetailsChanged();
162 * This signal is emitted when the device's link status changed. For example, if there
163 * is no carrier anymore.
165 * @param linkActivated true if the carrier got detected, false otherwise
167 void linkUpChanged(bool linkActivated);
170 * This signal is emitted when the device's link status changed. For example, if there
171 * is no carrier anymore.
173 * @param state the new state of the connection
174 * @see Solid::Control::NetworkInterface::ConnectionState
176 void connectionStateChanged(int state);
178 protected:
180 * @internal
182 NetworkInterface(NetworkInterfacePrivate &dd, QObject *backendObject);
185 * @internal
187 NetworkInterface(NetworkInterfacePrivate &dd, const NetworkInterface &network);
189 NetworkInterfacePrivate *d_ptr;
191 private:
192 //HACK: to make NetworkList polymorphic (containing both wired and wireless networks, I used Network * here - Will.
194 typedef QList<NetworkInterface *> NetworkInterfaceList;
197 } //Control
198 } //Solid
200 Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::NetworkInterface::Capabilities)
202 #endif //SOLID_CONTROL_NETWORKINTERFACE_H