mainwindow.h 2.7 KB

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