~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/solid/control/networkinterface.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
4
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
 
 
19
*/
 
20
 
 
21
#ifndef SOLID_CONTROL_NETWORKINTERFACE_H
 
22
#define SOLID_CONTROL_NETWORKINTERFACE_H
 
23
 
 
24
#include <QtCore/QObject>
 
25
#include <QtCore/QStringList>
 
26
#include <QtNetwork/QNetworkAddressEntry>
 
27
 
 
28
#include "solid_control_export.h"
 
29
 
 
30
#include "networkipv4config.h"
 
31
 
 
32
namespace Solid
 
33
{
 
34
namespace Control
 
35
{
 
36
    class NetworkInterfacePrivate;
 
37
 
 
38
    /**
 
39
     * This interface represents a generic network interface in the system
 
40
     */
 
41
    class SOLIDCONTROL_EXPORT NetworkInterface : public QObject
 
42
    {
 
43
    Q_OBJECT
 
44
    Q_ENUMS(ConnectionState Capability Type)
 
45
    Q_FLAGS(Capabilities)
 
46
    Q_FLAGS(Types)
 
47
    Q_DECLARE_PRIVATE(NetworkInterface)
 
48
 
 
49
    public:
 
50
        // == NM ActivationStage
 
51
        /**
 
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
 
56
         */
 
57
        enum ConnectionState{ UnknownState, Unmanaged, Unavailable, Disconnected, Preparing,
 
58
                              Configuring, NeedAuth, IPConfig, Activated, Failed };
 
59
        /**
 
60
         * Enums describing the reason for a connection state change
 
61
         */
 
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,
 
76
                                    Reserved = 65536 };
 
77
        /**
 
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
 
82
         */
 
83
        enum Capability { IsManageable = 0x1, SupportsCarrierDetect = 0x2 };
 
84
        /**
 
85
         * Device medium types
 
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)
 
92
         */
 
93
        enum Type { UnknownType = 0x0, Ieee8023 = 0x1, Ieee80211 = 0x2, Serial = 0x4, Gsm = 0x8, Cdma = 0x10, Bluetooth = 0x20 };
 
94
 
 
95
        Q_DECLARE_FLAGS(Capabilities, Capability)
 
96
        Q_DECLARE_FLAGS(Types, Type)
 
97
 
 
98
        /**
 
99
         * Creates a new NetworkInterface object.
 
100
         *
 
101
         * @param backendObject the network object provided by the backend
 
102
         */
 
103
        explicit NetworkInterface(QObject *backendObject);
 
104
 
 
105
        /**
 
106
         * Constructs a copy of a network.
 
107
         *
 
108
         * @param network the network to copy
 
109
         */
 
110
        NetworkInterface(const NetworkInterface &network);
 
111
 
 
112
        /**
 
113
         * Destroys a NetworkInterface object.
 
114
         */
 
115
        virtual ~NetworkInterface();
 
116
 
 
117
        /**
 
118
         * Retrieves the interface type.  This is a virtual function that will return the
 
119
         * proper type of all sub-classes.
 
120
         *
 
121
         * @returns the NetworkInterface::Type that corresponds to this device.
 
122
         */
 
123
        virtual Type type() const;
 
124
 
 
125
        /**
 
126
         * Retrieves the Unique Network Identifier (UNI) of the NetworkInterface.
 
127
         * This identifier is unique for each network and network interface in the system.
 
128
         *
 
129
         * @returns the Unique Network Identifier of the current network
 
130
         */
 
131
        QString uni() const;
 
132
 
 
133
        /**
 
134
         * Retrieves the Unique Device Identifier (UDI).
 
135
         * This is needed for ModemManager support.
 
136
         *
 
137
         * @returns the Unique Device Identifier of the current device
 
138
         */
 
139
        QString udi() const;
 
140
 
 
141
        /**
 
142
         * The system name for the network interface
 
143
         */
 
144
        QString interfaceName() const;
 
145
 
 
146
        /**
 
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.
 
151
         */
 
152
        QString ipInterfaceName() const;
 
153
 
 
154
        /**
 
155
         * If TRUE, indicates the device is likely missing firmware necessary for
 
156
         * its operation.
 
157
         */
 
158
        bool firmwareMissing() const;
 
159
 
 
160
        /**
 
161
         * Handle for the system driver controlling this network interface
 
162
         */
 
163
        QString driver() const;
 
164
 
 
165
        /**
 
166
         * Disconnects a device and prevents the device from automatically
 
167
         * activating further connections without user intervention.
 
168
         */
 
169
        void disconnectInterface() const;
 
170
 
 
171
        Solid::Control::IPv4Config ipV4Config() const;
 
172
        /**
 
173
         * Retrieves the activation status of this network interface.
 
174
         *
 
175
         * @return true if this network interface is active, false otherwise
 
176
         */
 
177
        bool isActive() const;
 
178
 
 
179
        /**
 
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.
 
183
         *
 
184
         * @return the current connection state
 
185
         * @see Solid::Control::NetworkInterface::ConnectionState
 
186
         */
 
187
        ConnectionState connectionState() const;
 
188
 
 
189
        /**
 
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.
 
193
         *
 
194
         * @return the device's maximum speed
 
195
         */
 
196
        int designSpeed() const;
 
197
 
 
198
        /**
 
199
         * Retrieves the capabilities supported by this device.
 
200
         *
 
201
         * @return the capabilities of the device
 
202
         */
 
203
        Capabilities capabilities() const;
 
204
 
 
205
    Q_SIGNALS:
 
206
        /**
 
207
         * This signal is emitted when the settings of this network have changed.
 
208
         */
 
209
        void ipDetailsChanged();
 
210
 
 
211
        /**
 
212
         * This signal is emitted when the device's link status changed. For example, if there
 
213
         * is no carrier anymore.
 
214
         *
 
215
         * @param linkActivated true if the carrier got detected, false otherwise
 
216
         */
 
217
        void linkUpChanged(bool linkActivated);
 
218
 
 
219
        /**
 
220
         * This signal is emitted when the device's link status changed. For example, if there
 
221
         * is no carrier anymore.
 
222
         *
 
223
         * @param state the new state of the connection
 
224
         * @see Solid::Control::NetworkInterface::ConnectionState
 
225
         */
 
226
        void connectionStateChanged(int state);
 
227
 
 
228
        /**
 
229
         * This signal is emitted when the device's link status changed.
 
230
         * 
 
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
 
236
         */
 
237
        void connectionStateChanged(int new_state, int old_state, int reason );
 
238
 
 
239
    protected:
 
240
        /**
 
241
         * @internal
 
242
         */
 
243
        NetworkInterface(NetworkInterfacePrivate &dd, QObject *backendObject);
 
244
 
 
245
        /**
 
246
         * @internal
 
247
         */
 
248
        NetworkInterface(NetworkInterfacePrivate &dd, const NetworkInterface &network);
 
249
 
 
250
        NetworkInterfacePrivate *d_ptr;
 
251
 
 
252
    private:
 
253
    //HACK: to make NetworkList polymorphic (containing both wired and wireless networks, I used Network * here - Will.
 
254
    };
 
255
    typedef QList<NetworkInterface *> NetworkInterfaceList;
 
256
 
 
257
 
 
258
} //Control
 
259
} //Solid
 
260
 
 
261
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::NetworkInterface::Capabilities)
 
262
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::NetworkInterface::Types)
 
263
 
 
264
#endif //SOLID_CONTROL_NETWORKINTERFACE_H
 
265