File indexing completed on 2024-04-21 04:58:35

0001 /*
0002     SPDX-FileCopyrightText: 2002 Arend van Beelen jr. <arend@auton.nl>
0003     SPDX-FileCopyrightText: 2007 Urs Wolfer <uwolfer@kde.org>
0004     SPDX-FileCopyrightText: 2023 Arjen Hiemstra <ahiemstra@heimr.nl>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef RDPVIEW_H
0010 #define RDPVIEW_H
0011 
0012 #include "remoteview.h"
0013 
0014 #include "rdphostpreferences.h"
0015 
0016 // #include <QProcess>
0017 #include <QUrl>
0018 
0019 #define TCP_PORT_RDP 3389
0020 
0021 class RdpSession;
0022 
0023 class RdpView : public RemoteView
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     explicit RdpView(QWidget *parent = nullptr,
0029                      const QUrl &url = QUrl(),
0030                      KConfigGroup configGroup = KConfigGroup(),
0031                      const QString &user = QString(),
0032                      const QString &password = QString());
0033 
0034     ~RdpView() override;
0035 
0036     // functions regarding the window
0037     QSize framebufferSize() override; // returns the size of the remote view
0038     QSize sizeHint() const override; // returns the suggested size
0039 
0040     // functions regarding the connection
0041     void startQuitting() override; // start closing the connection
0042     bool isQuitting() override; // are we currently closing the connection?
0043     bool start() override; // open a connection
0044 
0045     HostPreferences *hostPreferences() override;
0046 
0047     bool supportsScaling() const override;
0048     bool scaling() const override;
0049     void enableScaling(bool scale) override;
0050     void setScaleFactor(float factor) override;
0051 
0052     QPixmap takeScreenshot() override;
0053 
0054     void switchFullscreen(bool on) override;
0055 
0056     void savePassword(const QString &password);
0057 
0058 public Q_SLOTS:
0059     void scaleResize(int w, int h) override;
0060 
0061 protected:
0062     QSize initialSize();
0063 
0064     void paintEvent(QPaintEvent *event) override;
0065 
0066     void keyPressEvent(QKeyEvent *event) override;
0067     void keyReleaseEvent(QKeyEvent *event) override;
0068 
0069     void mousePressEvent(QMouseEvent *event) override;
0070     void mouseReleaseEvent(QMouseEvent *event) override;
0071     void mouseDoubleClickEvent(QMouseEvent *event) override;
0072     void mouseMoveEvent(QMouseEvent *event) override;
0073 
0074     void wheelEvent(QWheelEvent *event) override;
0075 
0076 private:
0077     void onRectangleUpdated(const QRect &rect);
0078 
0079     QString m_name;
0080     QString m_user;
0081     QString m_password;
0082     //
0083     bool m_quitting = false;
0084 
0085     std::unique_ptr<RdpHostPreferences> m_hostPreferences;
0086     std::unique_ptr<RdpSession> m_session;
0087 
0088     QRect m_pendingRectangle;
0089     QImage m_pendingData;
0090 };
0091 
0092 #endif