FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
sdl_connection_dialog_wrapper.hpp
1
21#pragma once
22
23#include <mutex>
24#include <memory>
25#include <string>
26#include <queue>
27
28#include <winpr/platform.h>
29#include <freerdp/types.h>
30
31#include <SDL3/SDL.h>
32
34
36{
37 public:
38 enum MsgType
39 {
40 MSG_NONE,
41 MSG_INFO,
42 MSG_WARN,
43 MSG_ERROR,
44 MSG_DISCARD
45 };
46
49
52
53 SdlConnectionDialogWrapper& operator=(const SdlConnectionDialogWrapper& other) = delete;
54 SdlConnectionDialogWrapper& operator=(SdlConnectionDialogWrapper&& other) = delete;
55
56 void create(rdpContext* context);
57 void destroy();
58
59 bool isRunning() const;
60 bool isVisible() const;
61
62 bool handleEvent(const SDL_Event& event);
63
64 WINPR_ATTR_FORMAT_ARG(2, 3)
65 void setTitle(WINPR_FORMAT_ARG const char* fmt, ...);
66 void setTitle(const std::string& title);
67
68 WINPR_ATTR_FORMAT_ARG(2, 3)
69 void showInfo(WINPR_FORMAT_ARG const char* fmt, ...);
70 void showInfo(const std::string& info);
71
72 WINPR_ATTR_FORMAT_ARG(2, 3)
73 void showWarn(WINPR_FORMAT_ARG const char* fmt, ...);
74 void showWarn(const std::string& info);
75
76 WINPR_ATTR_FORMAT_ARG(2, 3)
77 void showError(WINPR_FORMAT_ARG const char* fmt, ...);
78 void showError(const std::string& error);
79
80 void show(SdlConnectionDialogWrapper::MsgType type, const std::string& msg);
81
82 void show(bool visible = true);
83
84 void handleShow();
85
86 private:
87 class EventArg
88 {
89 public:
90 EventArg(bool visible);
91 EventArg(const std::string& title);
92 EventArg(SdlConnectionDialogWrapper::MsgType type, const std::string& msg, bool visible);
93
94 bool hasTitle() const;
95 const std::string& title() const;
96
97 bool hasMessage() const;
98 const std::string& message() const;
99
100 bool hasType() const;
101 SdlConnectionDialogWrapper::MsgType type() const;
102
103 bool hasVisibility() const;
104 bool visible() const;
105
106 std::string str() const;
107
108 private:
109 std::string _title{};
110 std::string _message{};
111 SdlConnectionDialogWrapper::MsgType _type = MSG_NONE;
112 bool _visible = false;
113 uint32_t _mask = 0;
114 };
115 void push(EventArg&& arg);
116
117 mutable std::mutex _mux;
118 std::unique_ptr<SDLConnectionDialog> _connection_dialog;
119 std::queue<EventArg> _queue;
120};