Home | History | Annotate | Download | only in wpa_gui-qt4
      1 /*
      2  * wpa_gui - WpaGui class
      3  * Copyright (c) 2005-2006, Jouni Malinen <j (at) w1.fi>
      4  *
      5  * This software may be distributed under the terms of the BSD license.
      6  * See README for more details.
      7  */
      8 
      9 #ifndef WPAGUI_H
     10 #define WPAGUI_H
     11 
     12 #include <QSystemTrayIcon>
     13 #include <QObject>
     14 #include "ui_wpagui.h"
     15 #include "addinterface.h"
     16 
     17 class UserDataRequest;
     18 
     19 class WpaGuiApp : public QApplication
     20 {
     21 	Q_OBJECT
     22 public:
     23 	WpaGuiApp(int &argc, char **argv);
     24 
     25 #if !defined(QT_NO_SESSIONMANAGER) && QT_VERSION < 0x050000
     26 	virtual void saveState(QSessionManager &manager);
     27 #endif
     28 
     29 	WpaGui *w;
     30 	int argc;
     31 	char **argv;
     32 };
     33 
     34 class WpaGui : public QMainWindow, public Ui::WpaGui
     35 {
     36 	Q_OBJECT
     37 
     38 public:
     39 
     40 	enum TrayIconType {
     41 		TrayIconOffline = 0,
     42 		TrayIconAcquiring,
     43 		TrayIconConnected,
     44 		TrayIconSignalNone,
     45 		TrayIconSignalWeak,
     46 		TrayIconSignalOk,
     47 		TrayIconSignalGood,
     48 		TrayIconSignalExcellent,
     49 	};
     50 
     51 	WpaGui(QApplication *app, QWidget *parent = 0, const char *name = 0,
     52 	       Qt::WindowFlags fl = 0);
     53 	~WpaGui();
     54 
     55 	virtual int ctrlRequest(const char *cmd, char *buf, size_t *buflen);
     56 	virtual void triggerUpdate();
     57 	virtual void editNetwork(const QString &sel);
     58 	virtual void removeNetwork(const QString &sel);
     59 	virtual void enableNetwork(const QString &sel);
     60 	virtual void disableNetwork(const QString &sel);
     61 	virtual int getNetworkDisabled(const QString &sel);
     62 	void setBssFromScan(const QString &bssid);
     63 #ifndef QT_NO_SESSIONMANAGER
     64 	void saveState();
     65 #endif
     66 
     67 public slots:
     68 	virtual void parse_argv();
     69 	virtual void updateStatus();
     70 	virtual void updateNetworks();
     71 	virtual void helpIndex();
     72 	virtual void helpContents();
     73 	virtual void helpAbout();
     74 	virtual void disconnect();
     75 	virtual void scan();
     76 	virtual void eventHistory();
     77 	virtual void ping();
     78 	virtual void signalMeterUpdate();
     79 	virtual void processMsg(char *msg);
     80 	virtual void processCtrlReq(const char *req);
     81 	virtual void receiveMsgs();
     82 	virtual void connectB();
     83 	virtual void selectNetwork(const QString &sel);
     84 	virtual void editSelectedNetwork();
     85 	virtual void editListedNetwork();
     86 	virtual void removeSelectedNetwork();
     87 	virtual void removeListedNetwork();
     88 	virtual void addNetwork();
     89 	virtual void enableAllNetworks();
     90 	virtual void disableAllNetworks();
     91 	virtual void removeAllNetworks();
     92 	virtual void saveConfig();
     93 	virtual void selectAdapter(const QString &sel);
     94 	virtual void updateNetworkDisabledStatus();
     95 	virtual void enableListedNetwork(bool);
     96 	virtual void disableListedNetwork(bool);
     97 	virtual void showTrayMessage(QSystemTrayIcon::MessageIcon type,
     98 				     int sec, const QString &msg);
     99 	virtual void showTrayStatus();
    100 	virtual void updateTrayIcon(TrayIconType type);
    101 	virtual void updateTrayToolTip(const QString &msg);
    102 	virtual QIcon loadThemedIcon(const QStringList &names,
    103 				     const QIcon &fallback);
    104 	virtual void wpsDialog();
    105 	virtual void peersDialog();
    106 	virtual void tabChanged(int index);
    107 	virtual void wpsPbc();
    108 	virtual void wpsGeneratePin();
    109 	virtual void wpsApPinChanged(const QString &text);
    110 	virtual void wpsApPin();
    111 #ifdef CONFIG_NATIVE_WINDOWS
    112 	virtual void startService();
    113 	virtual void stopService();
    114 #endif /* CONFIG_NATIVE_WINDOWS */
    115 	virtual void addInterface();
    116 
    117 protected slots:
    118 	virtual void languageChange();
    119 	virtual void trayActivated(QSystemTrayIcon::ActivationReason how);
    120 	virtual void closeEvent(QCloseEvent *event);
    121 
    122 private:
    123 	ScanResults *scanres;
    124 	Peers *peers;
    125 	bool networkMayHaveChanged;
    126 	char *ctrl_iface;
    127 	EventHistory *eh;
    128 	struct wpa_ctrl *ctrl_conn;
    129 	QSocketNotifier *msgNotifier;
    130 	QTimer *timer;
    131 	int pingsToStatusUpdate;
    132 	WpaMsgList msgs;
    133 	char *ctrl_iface_dir;
    134 	struct wpa_ctrl *monitor_conn;
    135 	UserDataRequest *udr;
    136 	QAction *disconnectAction;
    137 	QAction *reconnectAction;
    138 	QAction *eventAction;
    139 	QAction *scanAction;
    140 	QAction *statAction;
    141 	QAction *showAction;
    142 	QAction *hideAction;
    143 	QAction *quitAction;
    144 	QMenu *tray_menu;
    145 	QSystemTrayIcon *tray_icon;
    146 	TrayIconType currentIconType;
    147 	QString wpaStateTranslate(char *state);
    148 	void createTrayIcon(bool);
    149 	bool ackTrayIcon;
    150 	bool startInTray;
    151 	bool quietMode;
    152 
    153 	int openCtrlConnection(const char *ifname);
    154 
    155 	bool wpsRunning;
    156 
    157 	QString bssFromScan;
    158 
    159 	void stopWpsRun(bool success);
    160 
    161 	QTimer *signalMeterTimer;
    162 	int signalMeterInterval;
    163 
    164 #ifdef CONFIG_NATIVE_WINDOWS
    165 	QAction *fileStartServiceAction;
    166 	QAction *fileStopServiceAction;
    167 
    168 	bool serviceRunning();
    169 #endif /* CONFIG_NATIVE_WINDOWS */
    170 
    171 	QAction *addInterfaceAction;
    172 	AddInterface *add_iface;
    173 
    174 	bool connectedToService;
    175 
    176 	QApplication *app;
    177 	bool inTray;
    178 };
    179 
    180 #endif /* WPAGUI_H */
    181