mainwindow.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * ZeroTier One - Global Peer to Peer Ethernet
  3. * Copyright (C) 2012-2013 ZeroTier Networks LLC
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * --
  19. *
  20. * ZeroTier may be used and distributed under the terms of the GPLv3, which
  21. * are available at: http://www.gnu.org/licenses/gpl-3.0.html
  22. *
  23. * If you would like to embed ZeroTier into a commercial application or
  24. * redistribute it in a modified binary form, please contact ZeroTier Networks
  25. * LLC. Start here: http://www.zerotier.com/
  26. */
  27. #ifndef MAINWINDOW_H
  28. #define MAINWINDOW_H
  29. #include <QMainWindow>
  30. #include <QEvent>
  31. #include <QString>
  32. #include <QShowEvent>
  33. #include <QTimerEvent>
  34. #include <QSettings>
  35. #include <map>
  36. #include <vector>
  37. #include <string>
  38. #include "../node/Node.hpp"
  39. #include "../node/Utils.hpp"
  40. namespace Ui {
  41. class MainWindow;
  42. }
  43. // Globally visible instance of local client for communicating with ZT1
  44. // Can be null if not connected, or will point to current
  45. extern ZeroTier::Node::LocalClient *zeroTierClient;
  46. class MainWindow : public QMainWindow
  47. {
  48. Q_OBJECT
  49. public:
  50. // Event used to pass messages from the Node::LocalClient thread to the
  51. // main window to update network lists and stats.
  52. class ZTMessageEvent : public QEvent
  53. {
  54. public:
  55. ZTMessageEvent(const std::vector<std::string> &m) :
  56. QEvent(QEvent::User),
  57. ztMessage(m) {}
  58. std::vector<std::string> ztMessage;
  59. };
  60. explicit MainWindow(QWidget *parent = 0);
  61. virtual ~MainWindow();
  62. protected:
  63. virtual void timerEvent(QTimerEvent *event);
  64. virtual void customEvent(QEvent *event);
  65. private slots:
  66. void on_joinNetworkButton_clicked();
  67. void on_actionAbout_triggered();
  68. void on_networkIdLineEdit_textChanged(const QString &text);
  69. void on_addressButton_clicked();
  70. private:
  71. Ui::MainWindow *ui;
  72. QString myAddress;
  73. QString myStatus;
  74. QString myVersion;
  75. int pollServiceTimerId;
  76. unsigned int numPeers;
  77. unsigned int cyclesSinceResponseFromService;
  78. std::map< std::string,std::vector<std::string> > networks;
  79. };
  80. #endif // MAINWINDOW_H