aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/wpa_gui-qt4/wpagui.h
blob: f0a34c97ebe8ec7a6d5bea670424a80d668f8de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
 * wpa_gui - WpaGui class
 * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
 *
 * This software may be distributed under the terms of the BSD license.
 * See README for more details.
 */

#ifndef WPAGUI_H
#define WPAGUI_H

#include <QSystemTrayIcon>
#include <QObject>
#include "ui_wpagui.h"
#include "addinterface.h"

class UserDataRequest;

class WpaGuiApp : public QApplication
{
	Q_OBJECT
public:
	WpaGuiApp(int &argc, char **argv);

#if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
	virtual void saveState(QSessionManager &manager);
#endif

	WpaGui *w;
	int argc;
	char **argv;
};

class WpaGui : public QMainWindow, public Ui::WpaGui
{
	Q_OBJECT

public:

	enum TrayIconType {
		TrayIconOffline = 0,
		TrayIconAcquiring,
		TrayIconConnected,
		TrayIconSignalNone,
		TrayIconSignalWeak,
		TrayIconSignalOk,
		TrayIconSignalGood,
		TrayIconSignalExcellent,
	};

	WpaGui(QApplication *app, QWidget *parent = 0, const char *name = 0,
	       Qt::WindowFlags fl = 0);
	~WpaGui();

	virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
	virtual void triggerUpdate();
	virtual void editNetwork(const QString &sel);
	virtual void removeNetwork(const QString &sel);
	virtual void enableNetwork(const QString &sel);
	virtual void disableNetwork(const QString &sel);
	virtual int getNetworkDisabled(const QString &sel);
	void setBssFromScan(const QString &bssid);
#ifndef QT_NO_SESSIONMANAGER
	void saveState();
#endif

public slots:
	virtual void parse_argv();
	virtual void updateStatus();
	virtual void updateNetworks();
	virtual void helpIndex();
	virtual void helpContents();
	virtual void helpAbout();
	virtual void disconnect();
	virtual void scan();
	virtual void eventHistory();
	virtual void ping();
	virtual void signalMeterUpdate();
	virtual void processMsg(char *msg);
	virtual void processCtrlReq(const char *req);
	virtual void receiveMsgs();
	virtual void connectB();
	virtual void selectNetwork(const QString &sel);
	virtual void editSelectedNetwork();
	virtual void editListedNetwork();
	virtual void removeSelectedNetwork();
	virtual void removeListedNetwork();
	virtual void addNetwork();
	virtual void enableAllNetworks();
	virtual void disableAllNetworks();
	virtual void removeAllNetworks();
	virtual void saveConfig();
	virtual void selectAdapter(const QString &sel);
	virtual void updateNetworkDisabledStatus();
	virtual void enableListedNetwork(bool);
	virtual void disableListedNetwork(bool);
	virtual void showTrayMessage(QSystemTrayIcon::MessageIcon type,
				     int sec, const QString &msg);
	virtual void showTrayStatus();
	virtual void updateTrayIcon(TrayIconType type);
	virtual void updateTrayToolTip(const QString &msg);
	virtual QIcon loadThemedIcon(const QStringList &names,
				     const QIcon &fallback);
	virtual void wpsDialog();
	virtual void peersDialog();
	virtual void tabChanged(int index);
	virtual void wpsPbc();
	virtual void wpsGeneratePin();
	virtual void wpsApPinChanged(const QString &text);
	virtual void wpsApPin();
#ifdef CONFIG_NATIVE_WINDOWS
	virtual void startService();
	virtual void stopService();
#endif /* CONFIG_NATIVE_WINDOWS */
	virtual void addInterface();

protected slots:
	virtual void languageChange();
	virtual void trayActivated(QSystemTrayIcon::ActivationReason how);
	virtual void closeEvent(QCloseEvent *event);

private:
	ScanResults *scanres;
	Peers *peers;
	bool networkMayHaveChanged;
	char *ctrl_iface;
	EventHistory *eh;
	struct wpa_ctrl *ctrl_conn;
	QSocketNotifier *msgNotifier;
	QTimer *timer;
	int pingsToStatusUpdate;
	WpaMsgList msgs;
	char *ctrl_iface_dir;
	struct wpa_ctrl *monitor_conn;
	UserDataRequest *udr;
	QAction *disconnectAction;
	QAction *reconnectAction;
	QAction *eventAction;
	QAction *scanAction;
	QAction *statAction;
	QAction *showAction;
	QAction *hideAction;
	QAction *quitAction;
	QMenu *tray_menu;
	QSystemTrayIcon *tray_icon;
	TrayIconType currentIconType;
	QString wpaStateTranslate(char *state);
	void createTrayIcon(bool);
	bool ackTrayIcon;
	bool startInTray;
	bool quietMode;

	int openCtrlConnection(const char *ifname);

	bool wpsRunning;

	QString bssFromScan;

	void stopWpsRun(bool success);

	QTimer *signalMeterTimer;
	int signalMeterInterval;

#ifdef CONFIG_NATIVE_WINDOWS
	QAction *fileStartServiceAction;
	QAction *fileStopServiceAction;

	bool serviceRunning();
#endif /* CONFIG_NATIVE_WINDOWS */

	QAction *addInterfaceAction;
	AddInterface *add_iface;

	bool connectedToService;

	QApplication *app;
	bool inTray;
};

#endif /* WPAGUI_H */