Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ClipboardMimeData.h
1// Author: Kang Lin <kl222@126.com>
2
3#ifndef CMIMEDATA_H
4#define CMIMEDATA_H
5
6#include <QMimeData>
7#include <QMultiMap>
8#include <QVector>
9#include <QFile>
10#include <QSharedPointer>
11#include <QAtomicInteger>
12
13#include "freerdp/client/cliprdr.h"
14#include "winpr/clipboard.h"
15
16#define MIME_TYPE_RABBITREMOTECONTROL_PLUGINS_FREERDP "rabbit/remotecontrol/plugins/freerdp"
18class CClipboardMimeData : public QMimeData
19{
20 Q_OBJECT
21public:
22 explicit CClipboardMimeData(CliprdrClientContext* pContext);
23 virtual ~CClipboardMimeData();
24
25 const qint32 GetId() const;
26 struct _FORMAT {
27 UINT32 id;
28 QString name;
29 UINT32 localId;
30 };
31
32 int SetFormat(const CLIPRDR_FORMAT_LIST* pList);
33
34Q_SIGNALS:
35 void sigSendDataRequest(CliprdrClientContext* context,
36 UINT32 formatId) const;
37 void sigContinue();
38
39public:
40 virtual bool hasFormat(const QString &mimetype) const override;
41 virtual QStringList formats() const override;
42
43public Q_SLOTS:
44 void slotServerFormatData(const BYTE* pData, UINT32 nLen,
45 UINT32 id);
46 void slotServerFileContentsRespose(UINT32 streamId, QByteArray& data);
47
48protected:
49#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
50 virtual QVariant retrieveData(const QString &mimeType, QMetaType preferredType) const override;
51#else
52 virtual QVariant retrieveData(const QString &mimeType, QVariant::Type preferredType) const override;
53#endif
54
55private:
56 int AddFormat(UINT32 id, const char *name);
57
58 bool isText(QString mimeType, bool bRegular = true) const;
59 bool isHtml(QString mimeType, bool bRegular = true) const;
60 bool isImage(QString mimeType, bool bRegular = true) const;
61 bool isUrls(QString mimeType, bool bRegular = true) const;
62
63Q_SIGNALS:
64 void sigRequestFileFromServer(const QString& mimetype, const QString& valueName,
65 const void* pData, const UINT32 nLen) const;
66private Q_SLOTS:
67 void slotRequestFileFromServer(const QString& mimeType, const QString& valueName,
68 const void* pData, const UINT32 nLen);
69private:
70 UINT sendRequestFilecontents(UINT32 listIndex,
71 UINT32 dwFlags,
72 DWORD nPositionHigh,
73 DWORD nPositionLow,
74 UINT32 cbRequested);
75private:
76 friend CClipboardFreeRDP;
77
78 static QAtomicInteger<qint32> m_nId;
79 qint32 m_Id;
80
81 CliprdrClientContext* m_pContext;
82 wClipboard* m_pClipboard; // Clipboard interface provided by winpr library
83
84 QVector<_FORMAT> m_Formats; // Save server format
85 QMultiMap<QString, _FORMAT> m_indexString;
86 QMap<UINT32, _FORMAT> m_indexId;
87 QStringList m_lstFormats; // Clipboard return farmat
88
89 QVariant m_Variant;
90 QVariant m_gnomeFiles;
91 QVariant m_uriFiles;
92 bool m_bExit;
93
95 {
96 QFile m_File;
97 QByteArray m_Data;
98 bool m_Success;
99 };
100 QMap<UINT32, QSharedPointer<_CliprdrFileStream> > m_Stream;
101};
102
103#endif // CMIMEDATA_H
void slotServerFormatData(const BYTE *pData, UINT32 nLen, UINT32 id)
if(pData == nullptr && nLen == 0) is Notify clipboard program has exited