1 /* 2 Copyright (C) 2009-2010 Collabora Ltd <info@collabora.co.uk> 3 @author George Goldberg <george.goldberg@collabora.co.uk> 4 @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk> 5 Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it> 6 7 This program is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public 9 License as published by the Free Software Foundation; either 10 version 2 of the License, or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public License 18 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #ifndef RFBSERVER_H 21 #define RFBSERVER_H 22 23 #include "rfb.h" 24 #include "rfbclient.h" 25 #include <QRect> 26 27 class RfbServer : public QObject 28 { 29 Q_OBJECT 30 public: 31 explicit RfbServer(QObject *parent = nullptr); 32 ~RfbServer() override; 33 34 QByteArray listeningAddress() const; 35 int listeningPort() const; 36 bool passwordRequired() const; 37 38 void setListeningAddress(const QByteArray & address); 39 void setListeningPort(int port); 40 void setPasswordRequired(bool passwordRequired); 41 42 public Q_SLOTS: 43 virtual bool start(); 44 virtual void stop(); 45 46 void updateFrameBuffer(char *fb, int width, int height, int depth); 47 void updateScreen(const QList<QRect> & modifiedTiles); 48 void updateCursorPosition(const QPoint & position); 49 50 private Q_SLOTS: 51 void krfbSendServerCutText(); 52 void onListenSocketActivated(); 53 void pendingClientFinished(RfbClient *client); 54 55 protected: 56 virtual PendingRfbClient *newClient(rfbClientPtr client) = 0; 57 58 private: 59 static rfbNewClientAction newClientHook(rfbClientPtr cl); 60 static void clientGoneHook(rfbClientPtr cl); 61 62 static rfbBool passwordCheck(rfbClientPtr cl, const char *encryptedPassword, int len); 63 static void keyboardHook(rfbBool down, rfbKeySym keySym, rfbClientPtr cl); 64 static void pointerHook(int bm, int x, int y, rfbClientPtr cl); 65 static void clipboardHook(char *str, int len, rfbClientPtr cl); 66 67 Q_DISABLE_COPY(RfbServer) 68 69 struct Private; 70 Private *const d; 71 }; 72 73 #endif // RFBSERVER_H 74