29 #include <winpr/wtypes.h>
30 #include <freerdp/freerdp.h>
31 #include <freerdp/client/client_cliprdr_file.h>
34 #include "sdl_types.hpp"
35 #include "sdl_utils.hpp"
41 ClipRequest(UINT32 format,
const std::string& mime);
49 [[nodiscard]] uint32_t format()
const;
50 [[nodiscard]] std::string formatstr()
const;
51 [[nodiscard]] std::string mime()
const;
52 [[nodiscard]]
bool success()
const;
53 void setSuccess(
bool status);
64 CliprdrFormat(uint32_t formatID,
const char* formatName) : _formatID(formatID)
67 _formatName = formatName;
70 [[nodiscard]] uint32_t formatId()
const
75 [[nodiscard]]
const char* formatName()
const
77 if (_formatName.empty())
79 return _formatName.c_str();
84 std::string _formatName;
94 BOOL init(CliprdrClientContext* clip);
95 BOOL uninit(CliprdrClientContext* clip);
97 bool handle_update(
const SDL_ClipboardEvent& ev);
100 UINT SendClientCapabilities();
101 void clearServerFormats();
102 UINT SendFormatListResponse(BOOL status);
103 UINT SendDataResponse(
const BYTE* data,
size_t size);
104 UINT SendDataRequest(uint32_t formatID,
const std::string& mime);
106 std::string getServerFormat(uint32_t
id);
107 uint32_t serverIdForMime(
const std::string& mime);
109 static UINT MonitorReady(CliprdrClientContext* context,
112 static UINT ReceiveServerCapabilities(CliprdrClientContext* context,
114 static UINT ReceiveServerFormatList(CliprdrClientContext* context,
116 static UINT ReceiveFormatListResponse(CliprdrClientContext* context,
118 static std::shared_ptr<BYTE> ReceiveFormatDataRequestHandle(
120 static UINT ReceiveFormatDataRequest(CliprdrClientContext* context,
122 static UINT ReceiveFormatDataResponse(CliprdrClientContext* context,
125 static const void* SDLCALL ClipDataCb(
void* userdata,
const char* mime_type,
size_t* size);
126 static void SDLCALL ClipCleanCb(
void* userdata);
128 static bool mime_is_file(
const std::string& mime);
129 static bool mime_is_text(
const std::string& mime);
130 static bool mime_is_image(
const std::string& mime);
131 static bool mime_is_html(
const std::string& mime);
134 CliprdrFileContext* _file =
nullptr;
135 CliprdrClientContext* _ctx =
nullptr;
136 wLog* _log =
nullptr;
137 wClipboard* _system =
nullptr;
138 std::atomic<bool> _sync =
false;
141 std::vector<CliprdrFormat> _serverFormats;
144 std::queue<ClipRequest> _request_queue;
148 cache_entry(
size_t len, std::shared_ptr<void> p) : size(len), ptr(std::move(p))
153 std::shared_ptr<void> ptr;
155 std::map<std::string, cache_entry> _cache_data;
a clipboard format request
object that handles clipboard context for the SDL3 client