mainwindow.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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/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::LocalClient *zeroTierClient;
  47. class MainWindow : public QMainWindow
  48. {
  49. Q_OBJECT
  50. public:
  51. // Event used to pass messages from the Node::LocalClient thread to the
  52. // main window to update network lists and stats.
  53. class ZTMessageEvent : public QEvent
  54. {
  55. public:
  56. ZTMessageEvent(const std::vector<std::string> &m) :
  57. QEvent(QEvent::User),
  58. ztMessage(m) {}
  59. std::vector<std::string> ztMessage;
  60. };
  61. explicit MainWindow(QWidget *parent = 0);
  62. virtual ~MainWindow();
  63. protected:
  64. virtual void timerEvent(QTimerEvent *event);
  65. virtual void customEvent(QEvent *event);
  66. private slots:
  67. void on_joinNetworkButton_clicked();
  68. void on_actionAbout_triggered();
  69. void on_networkIdLineEdit_textChanged(const QString &text);
  70. void on_addressButton_clicked();
  71. private:
  72. Ui::MainWindow *ui;
  73. QString myAddress;
  74. QString myStatus;
  75. QString myVersion;
  76. bool firstTimerTick;
  77. int pollServiceTimerId;
  78. unsigned int numPeers;
  79. unsigned int cyclesSinceResponseFromService;
  80. std::map< std::string,std::vector<std::string> > networks;
  81. };
  82. #endif // MAINWINDOW_H