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 (!enabled)
43 _connection_dialog = std::make_unique<SDLConnectionDialog>(context);
44}
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 46 of file sdl_connection_dialog_wrapper.cpp.

47{
48 _connection_dialog.reset();
49}

◆ handleEvent()

bool SdlConnectionDialogWrapper::handleEvent ( const SDL_Event &  event)

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->handle(event);
78}

◆ handleShow()

void SdlConnectionDialogWrapper::handleShow ( )

Definition at line 164 of file sdl_connection_dialog_wrapper.cpp.

165{
166 std::unique_lock lock(_mux);
167 while (!_queue.empty())
168 {
169 auto arg = _queue.front();
170 _queue.pop();
171
172 if (arg.hasTitle() && _connection_dialog)
173 {
174 std::ignore = _connection_dialog->setTitle(arg.title().c_str());
175 }
176
177 if (arg.hasType() && arg.hasMessage())
178 {
179 switch (arg.type())
180 {
181 case SdlConnectionDialogWrapper::MSG_INFO:
182 if (_connection_dialog)
183 std::ignore = _connection_dialog->showInfo(arg.message().c_str());
184 else
185 WLog_Print(_log, WLOG_INFO, "%s", arg.message().c_str());
186 break;
187 case SdlConnectionDialogWrapper::MSG_WARN:
188 if (_connection_dialog)
189 std::ignore = _connection_dialog->showWarn(arg.message().c_str());
190 else
191 WLog_Print(_log, WLOG_WARN, "%s", arg.message().c_str());
192 break;
193 case SdlConnectionDialogWrapper::MSG_ERROR:
194 if (_connection_dialog)
195 std::ignore = _connection_dialog->showError(arg.message().c_str());
196 else
197 WLog_Print(_log, WLOG_ERROR, "%s", arg.message().c_str());
198 break;
199 default:
200 break;
201 }
202 }
203
204 if (arg.hasVisibility() && _connection_dialog)
205 {
206 if (arg.visible())
207 std::ignore = _connection_dialog->show();
208 else
209 std::ignore = _connection_dialog->hide();
210 }
211 }
212}

◆ isRunning()

bool SdlConnectionDialogWrapper::isRunning ( ) const

Definition at line 51 of file sdl_connection_dialog_wrapper.cpp.

52{
53 std::unique_lock lock(_mux);
54 /* Messages are queued here and handled on the main thread, so the dialog is still busy
55 * while the queue is not empty. Without this the event loop can leave before an error
56 * pushed by the RDP thread was ever shown. */
57 if (!_queue.empty())
58 return true;
59 if (!_connection_dialog)
60 return false;
61 return _connection_dialog->running();
62}

◆ isVisible()

bool SdlConnectionDialogWrapper::isVisible ( ) const

Definition at line 64 of file sdl_connection_dialog_wrapper.cpp.

65{
66 std::unique_lock lock(_mux);
67 if (!_connection_dialog)
68 return false;
69 return _connection_dialog->visible();
70}

◆ setTitle()

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

Definition at line 109 of file sdl_connection_dialog_wrapper.cpp.

110{
111 push(EventArg{ title });
112}

◆ show() [1/2]

void SdlConnectionDialogWrapper::show ( bool  visible = true)

Definition at line 159 of file sdl_connection_dialog_wrapper.cpp.

160{
161 push(EventArg{ visible });
162}

◆ show() [2/2]

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

Definition at line 153 of file sdl_connection_dialog_wrapper.cpp.

155{
156 push({ type, msg, true });
157}

◆ showError()

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

Definition at line 148 of file sdl_connection_dialog_wrapper.cpp.

149{
150 show(MSG_ERROR, error);
151}

◆ showInfo()

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

Definition at line 122 of file sdl_connection_dialog_wrapper.cpp.

123{
124 show(MSG_INFO, info);
125}

◆ showWarn()

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

Definition at line 135 of file sdl_connection_dialog_wrapper.cpp.

136{
137 show(MSG_WARN, info);
138}

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