FreeRDP
Loading...
Searching...
No Matches
SdlConnectionDialogWrapper Class Reference

Public Types

enum  MsgType {
  MSG_NONE , MSG_INFO , MSG_WARN , MSG_ERROR ,
  MSG_DISCARD
}
 

Public Member Functions

 SdlConnectionDialogWrapper (wLog *log)
 
 SdlConnectionDialogWrapper (const SdlConnectionDialogWrapper &other)=delete
 
 SdlConnectionDialogWrapper (SdlConnectionDialogWrapper &&other)=delete
 
SdlConnectionDialogWrapper & operator= (const SdlConnectionDialogWrapper &other)=delete
 
SdlConnectionDialogWrapper & operator= (SdlConnectionDialogWrapper &&other)=delete
 
void create (rdpContext *context)
 
void destroy ()
 
bool isRunning () const
 
bool isVisible () const
 
bool handleEvent (const SDL_Event &event)
 
void setTitle (WINPR_FORMAT_ARG const char *fmt,...)
 
void setTitle (const std::string &title)
 
void showInfo (WINPR_FORMAT_ARG const char *fmt,...)
 
void showInfo (const std::string &info)
 
void showWarn (WINPR_FORMAT_ARG const char *fmt,...)
 
void showWarn (const std::string &info)
 
void showError (WINPR_FORMAT_ARG const char *fmt,...)
 
void showError (const std::string &error)
 
void show (SdlConnectionDialogWrapper::MsgType type, const std::string &msg)
 
void show (bool visible=true)
 
void handleShow ()
 

Detailed Description

Definition at line 36 of file sdl_connection_dialog_wrapper.hpp.

Member Enumeration Documentation

◆ MsgType

enum SdlConnectionDialogWrapper::MsgType

Definition at line 39 of file sdl_connection_dialog_wrapper.hpp.

40 {
41 MSG_NONE,
42 MSG_INFO,
43 MSG_WARN,
44 MSG_ERROR,
45 MSG_DISCARD
46 };

Constructor & Destructor Documentation

◆ SdlConnectionDialogWrapper()

SdlConnectionDialogWrapper::SdlConnectionDialogWrapper ( wLog *  log)
explicit

FreeRDP: A Remote Desktop Protocol Implementation SDL Client helper dialogs

Copyright 2025 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2025 Thincast Technologies GmbH

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 31 of file sdl_connection_dialog_wrapper.cpp.

31 : _log(log)
32{
33}

Member Function Documentation

◆ create()

void SdlConnectionDialogWrapper::create ( rdpContext *  context)

Definition at line 37 of file sdl_connection_dialog_wrapper.cpp.

38{
39 const auto enabled =
40 freerdp_settings_get_bool(context->settings, FreeRDP_UseCommonStdioCallbacks);
41 _connection_dialog.reset();
42#if defined(__EMSCRIPTEN__)
43 /* Every SDL window of an Emscripten build draws on the page's one canvas, so a dialog
44 * window would take over the session's canvas. SDL 3.2 also throws from creating a
45 * window while another one is open (FS.mkdir of its drop directory; SDL 3.4 catches
46 * it), which unwinds the main thread while it holds _mux. The messages go to the log. */
47 WINPR_UNUSED(enabled);
48#else
49 if (!enabled)
50 _connection_dialog = std::make_unique<SDLConnectionDialog>(context);
51#endif
52}
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.

◆ destroy()

void SdlConnectionDialogWrapper::destroy ( )

Definition at line 54 of file sdl_connection_dialog_wrapper.cpp.

55{
56 _connection_dialog.reset();
57}

◆ handleEvent()

bool SdlConnectionDialogWrapper::handleEvent ( const SDL_Event &  event)

Definition at line 80 of file sdl_connection_dialog_wrapper.cpp.

81{
82 std::unique_lock lock(_mux);
83 if (!_connection_dialog)
84 return false;
85 return _connection_dialog->handle(event);
86}

◆ handleShow()

void SdlConnectionDialogWrapper::handleShow ( )

Definition at line 172 of file sdl_connection_dialog_wrapper.cpp.

173{
174 std::unique_lock lock(_mux);
175 while (!_queue.empty())
176 {
177 /* take the message out of the queue: pop() destroys the queued one */
178 auto arg = std::move(_queue.front());
179 _queue.pop();
180
181 if (arg.hasTitle() && _connection_dialog)
182 {
183 std::ignore = _connection_dialog->setTitle(arg.title().c_str());
184 }
185
186 if (arg.hasType() && arg.hasMessage())
187 {
188 switch (arg.type())
189 {
190 case SdlConnectionDialogWrapper::MSG_INFO:
191 if (_connection_dialog)
192 std::ignore = _connection_dialog->showInfo(arg.message().c_str());
193 else
194 WLog_Print(_log, WLOG_INFO, "%s", arg.message().c_str());
195 break;
196 case SdlConnectionDialogWrapper::MSG_WARN:
197 if (_connection_dialog)
198 std::ignore = _connection_dialog->showWarn(arg.message().c_str());
199 else
200 WLog_Print(_log, WLOG_WARN, "%s", arg.message().c_str());
201 break;
202 case SdlConnectionDialogWrapper::MSG_ERROR:
203 if (_connection_dialog)
204 std::ignore = _connection_dialog->showError(arg.message().c_str());
205 else
206 WLog_Print(_log, WLOG_ERROR, "%s", arg.message().c_str());
207 break;
208 default:
209 break;
210 }
211 }
212
213 if (arg.hasVisibility() && _connection_dialog)
214 {
215 if (arg.visible())
216 std::ignore = _connection_dialog->show();
217 else
218 std::ignore = _connection_dialog->hide();
219 }
220 }
221}

◆ isRunning()

bool SdlConnectionDialogWrapper::isRunning ( ) const

Definition at line 59 of file sdl_connection_dialog_wrapper.cpp.

60{
61 std::unique_lock lock(_mux);
62 /* Messages are queued here and handled on the main thread, so the dialog is still busy
63 * while the queue is not empty. Without this the event loop can leave before an error
64 * pushed by the RDP thread was ever shown. */
65 if (!_queue.empty())
66 return true;
67 if (!_connection_dialog)
68 return false;
69 return _connection_dialog->running();
70}

◆ isVisible()

bool SdlConnectionDialogWrapper::isVisible ( ) const

Definition at line 72 of file sdl_connection_dialog_wrapper.cpp.

73{
74 std::unique_lock lock(_mux);
75 if (!_connection_dialog)
76 return false;
77 return _connection_dialog->visible();
78}

◆ setTitle()

void SdlConnectionDialogWrapper::setTitle ( const std::string &  title)

Definition at line 117 of file sdl_connection_dialog_wrapper.cpp.

118{
119 push(EventArg{ title });
120}

◆ show() [1/2]

void SdlConnectionDialogWrapper::show ( bool  visible = true)

Definition at line 167 of file sdl_connection_dialog_wrapper.cpp.

168{
169 push(EventArg{ visible });
170}

◆ show() [2/2]

void SdlConnectionDialogWrapper::show ( SdlConnectionDialogWrapper::MsgType  type,
const std::string &  msg 
)

Definition at line 161 of file sdl_connection_dialog_wrapper.cpp.

163{
164 push({ type, msg, true });
165}

◆ showError()

void SdlConnectionDialogWrapper::showError ( const std::string &  error)

Definition at line 156 of file sdl_connection_dialog_wrapper.cpp.

157{
158 show(MSG_ERROR, error);
159}

◆ showInfo()

void SdlConnectionDialogWrapper::showInfo ( const std::string &  info)

Definition at line 130 of file sdl_connection_dialog_wrapper.cpp.

131{
132 show(MSG_INFO, info);
133}

◆ showWarn()

void SdlConnectionDialogWrapper::showWarn ( const std::string &  info)

Definition at line 143 of file sdl_connection_dialog_wrapper.cpp.

144{
145 show(MSG_WARN, info);
146}

The documentation for this class was generated from the following files: