mainwindow.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * ZeroTier One - Global Peer to Peer Ethernet
  3. * Copyright (C) 2011-2014 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/Constants.hpp"
  39. #include "../node/Node.hpp"
  40. #include "../node/Utils.hpp"
  41. #include "../control/NodeControlClient.hpp"
  42. namespace Ui {
  43. class MainWindow;
  44. }
  45. // Globally visible instance of local client for communicating with ZT1
  46. // Can be null if not connected, or will point to current
  47. extern ZeroTier::NodeControlClient *zeroTierClient;
  48. // Globally visible pointer to main app window
  49. extern QMainWindow *mainWindow;
  50. class MainWindow : public QMainWindow
  51. {
  52. Q_OBJECT
  53. public:
  54. // Event used to pass messages from the Node::LocalClient thread to the
  55. // main window to update network lists and stats.
  56. class ZTMessageEvent : public QEvent
  57. {
  58. public:
  59. ZTMessageEvent(const std::vector<std::string> &m) :
  60. QEvent(QEvent::User),
  61. ztMessage(m) {}
  62. std::vector<std::string> ztMessage;
  63. };
  64. explicit MainWindow(QWidget *parent = 0);
  65. virtual ~MainWindow();
  66. protected:
  67. virtual void timerEvent(QTimerEvent *event);
  68. virtual void customEvent(QEvent *event);
  69. private slots:
  70. void on_joinNetworkButton_clicked();
  71. void on_actionAbout_triggered();
  72. void on_networkIdLineEdit_textChanged(const QString &text);
  73. void on_addressButton_clicked();
  74. void on_actionQuick_Start_triggered();
  75. private:
  76. Ui::MainWindow *ui;
  77. QString myAddress;
  78. QString myStatus;
  79. QString myVersion;
  80. bool firstTimerTick;
  81. int pollServiceTimerId;
  82. unsigned int numPeers;
  83. unsigned int cyclesSinceResponseFromService;
  84. std::map< std::string,std::vector<std::string> > networks;
  85. };
  86. #endif // MAINWINDOW_H