1 /* 2 * Stellarium Remote Sync plugin 3 * Copyright (C) 2015 Florian Schaukowitsch 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (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, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. 18 */ 19 20 #ifndef SYNCCLIENTHANDLERS_HPP 21 #define SYNCCLIENTHANDLERS_HPP 22 23 #include "SyncProtocol.hpp" 24 25 #include <QRegularExpression> 26 27 class SyncClient; 28 class StelCore; 29 30 class ClientHandler : public QObject, public SyncMessageHandler 31 { 32 Q_OBJECT 33 Q_INTERFACES(SyncMessageHandler) 34 35 public: 36 ClientHandler(); 37 ClientHandler(SyncClient *client); 38 protected: 39 SyncClient* client; 40 StelCore* core; 41 }; 42 43 class ClientErrorHandler : public ClientHandler 44 { 45 Q_OBJECT 46 public: 47 ClientErrorHandler(SyncClient* client); 48 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 49 }; 50 51 //! Reacts to Server challenge and challenge OK on the client 52 class ClientAuthHandler : public ClientHandler 53 { 54 Q_OBJECT 55 public: 56 ClientAuthHandler(SyncClient* client); 57 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 58 signals: 59 void authenticated(); 60 }; 61 62 class ClientAliveHandler : public SyncMessageHandler 63 { 64 public: 65 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 66 }; 67 68 class ClientTimeHandler : public ClientHandler 69 { 70 public: 71 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 72 }; 73 74 class ClientLocationHandler : public ClientHandler 75 { 76 public: 77 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 78 }; 79 80 class StelObjectMgr; 81 class ClientSelectionHandler : public ClientHandler 82 { 83 public: 84 ClientSelectionHandler(); 85 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 86 private: 87 StelObjectMgr* objMgr; 88 }; 89 90 class StelPropertyMgr; 91 class ClientStelPropertyUpdateHandler : public ClientHandler 92 { 93 public: 94 ClientStelPropertyUpdateHandler(bool skipGuiProps, const QStringList& excludeProps); 95 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 96 private: 97 StelPropertyMgr* propMgr; 98 QRegularExpression filter; 99 }; 100 101 class StelMovementMgr; 102 class ClientViewHandler : public ClientHandler 103 { 104 public: 105 ClientViewHandler(); 106 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 107 private: 108 StelMovementMgr* mvMgr; 109 }; 110 111 class ClientFovHandler : public ClientHandler 112 { 113 public: 114 ClientFovHandler(); 115 bool handleMessage(QDataStream &stream, SyncProtocol::tPayloadSize dataSize, SyncRemotePeer &peer) Q_DECL_OVERRIDE; 116 private: 117 StelMovementMgr* mvMgr; 118 }; 119 120 #endif 121