File indexing completed on 2024-10-06 07:35:27

0001 /*
0002     Copyright (C) 2009-2010 Collabora Ltd <info@collabora.co.uk>
0003       @author George Goldberg <george.goldberg@collabora.co.uk>
0004       @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
0005     Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
0006 
0007     This program is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This program is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015     GNU General Public License for more details.
0016 
0017     You should have received a copy of the GNU Lesser General Public License
0018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 #ifndef RFBSERVER_H
0021 #define RFBSERVER_H
0022 
0023 #include "rfb.h"
0024 #include "rfbclient.h"
0025 #include <QRect>
0026 
0027 class RfbServer : public QObject
0028 {
0029     Q_OBJECT
0030 public:
0031     explicit RfbServer(QObject *parent = nullptr);
0032     ~RfbServer() override;
0033 
0034     QByteArray listeningAddress() const;
0035     int listeningPort() const;
0036     bool passwordRequired() const;
0037 
0038     void setListeningAddress(const QByteArray & address);
0039     void setListeningPort(int port);
0040     void setPasswordRequired(bool passwordRequired);
0041 
0042 public Q_SLOTS:
0043     virtual bool start();
0044     virtual void stop();
0045 
0046     void updateFrameBuffer(char *fb, int width, int height, int depth);
0047     void updateScreen(const QList<QRect> & modifiedTiles);
0048     void updateCursorPosition(const QPoint & position);
0049 
0050 private Q_SLOTS:
0051     void krfbSendServerCutText();
0052     void onListenSocketActivated();
0053     void pendingClientFinished(RfbClient *client);
0054 
0055 protected:
0056     virtual PendingRfbClient *newClient(rfbClientPtr client) = 0;
0057 
0058 private:
0059     static rfbNewClientAction newClientHook(rfbClientPtr cl);
0060     static void clientGoneHook(rfbClientPtr cl);
0061 
0062     static rfbBool passwordCheck(rfbClientPtr cl, const char *encryptedPassword, int len);
0063     static void keyboardHook(rfbBool down, rfbKeySym keySym, rfbClientPtr cl);
0064     static void pointerHook(int bm, int x, int y, rfbClientPtr cl);
0065     static void clipboardHook(char *str, int len, rfbClientPtr cl);
0066 
0067     Q_DISABLE_COPY(RfbServer)
0068 
0069     struct Private;
0070     Private *const d;
0071 };
0072 
0073 #endif // RFBSERVER_H