2
Copyright 2008,2009 Will Stephenson <wstephenson@kde.org>
3
Copyright 2008, 2009 Sebastian Kügler <sebas@kde.org>
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License or (at your option) version 3 or any later version
9
accepted by the membership of KDE e.V. (or its successor approved
10
by the membership of KDE e.V.), which shall act as a proxy
11
defined in Section 14 of version 3 of the license.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#ifndef APPLET_INTERFACEITEM_H
23
#define APPLET_INTERFACEITEM_H
25
#include <QDBusObjectPath>
26
#include <QGraphicsWidget>
28
#include <solid/control/networkinterface.h>
30
#include "interfaceconnection.h"
31
#include "remoteactivatable.h"
34
#include <Plasma/Frame>
35
#include <Plasma/IconWidget>
36
#include <Plasma/Label>
37
#include <Plasma/Meter>
38
#include <Plasma/CheckBox>
39
#include <Plasma/PushButton>
41
class QGraphicsGridLayout;
42
class QGraphicsLinearLayout;
47
class NetworkInterface;
51
class RemoteInterfaceConnection;
52
class RemoteActivatableList;
56
* Represents a single network interface
57
* Displays status, updates itself
58
* Allows deactivating any active connection
60
class InterfaceItem : public Plasma::IconWidget
64
enum NameDisplayMode {InterfaceName, HardwareName};
65
InterfaceItem(Solid::Control::NetworkInterfaceNm09* iface, RemoteActivatableList* activatables, NameDisplayMode mode = InterfaceName, QGraphicsWidget* parent = 0);
66
virtual ~InterfaceItem();
68
void setNameDisplayMode(NameDisplayMode);
69
NameDisplayMode nameDisplayMode() const;
70
Solid::Control::NetworkInterfaceNm09* interface();
71
virtual QString connectionName();
73
virtual void setActivatableList(RemoteActivatableList* activatables);
74
virtual QString currentIpAddress();
78
void activeConnectionsChanged();
79
virtual void connectionStateChanged(Solid::Control::NetworkInterfaceNm09::ConnectionState, bool updateConnection = true);
80
virtual void setEnabled(bool enable);
81
// also updates the connection info
82
virtual void setActive(bool active);
85
void disappearAnimationFinished();
89
* Remove any connections that were provided by this service
90
* from our active connection list
92
void handleConnectionStateChange(int new_state);
93
void handleConnectionStateChange(int new_state, int old_state, int reason);
94
void handleHasDefaultRouteChanged(bool);
95
void pppStats(uint in, uint out);
97
virtual void setConnectionInfo();
101
void disconnectInterfaceRequested(const QString& deviceUni);
102
void clicked(Solid::Control::NetworkInterfaceNm09*);
103
void hoverEnter(const QString& uni = QString());
104
void hoverLeave(const QString& uni = QString());
108
* Fill in interface type connection info
111
* Give us a pixmap for an icon
113
virtual QPixmap interfacePixmap(const QString &icon = QString());
116
* The current IP address when the connection is active.
118
//----- virtual QString currentIpAddress();
119
virtual RemoteInterfaceConnection* currentConnection();
120
void showItem(QGraphicsWidget* widget, bool show = true);
122
RemoteInterfaceConnection* m_currentConnection;
124
QWeakPointer<Solid::Control::NetworkInterfaceNm09> m_iface;
125
RemoteActivatableList* m_activatables;
127
QGraphicsGridLayout* m_layout;
128
QGraphicsLinearLayout* m_infoLayout;
129
Plasma::Label* m_icon;
131
Plasma::PushButton* m_disconnectButton;
132
Plasma::Label* m_ifaceNameLabel;
133
Plasma::Label* m_connectionNameLabel;
134
QGraphicsLinearLayout* m_connectionInfoLayout;
135
Plasma::Label* m_connectionInfoLabel;
136
Plasma::Label* m_connectionInfoStrengthLabel;
137
Plasma::Label* m_connectionInfoIcon;
138
NameDisplayMode m_nameMode;
140
Solid::Control::NetworkInterfaceNm09::ConnectionState m_state;
141
QString m_interfaceName;
143
bool m_hasDefaultRoute;
147
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
148
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
151
virtual void currentConnectionChanged();
154
void emitDisconnectInterfaceRequest();
155
void serviceDisappeared();
156
void activatableAdded(RemoteActivatable*);
157
void activatableRemoved(RemoteActivatable*);
158
void updateCurrentConnection(RemoteInterfaceConnection *);
160
#endif // APPLET_INTERFACEWIDGET_H