wpagui.h 4.4 KB

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