wpagui.h 4.1 KB

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