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