summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h422
1 files changed, 0 insertions, 422 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h
deleted file mode 100644
index 843bdfa..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h
+++ /dev/null
@@ -1,422 +0,0 @@
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../definitions.h"
12#include "../../AddonBase.h"
13
14namespace kodi
15{
16namespace gui
17{
18namespace dialogs
19{
20
21 //============================================================================
22 ///
23 /// \defgroup cpp_kodi_gui_dialogs_Keyboard Dialog Keyboard
24 /// \ingroup cpp_kodi_gui
25 /// @brief \cpp_namespace{ kodi::gui::dialogs::Keyboard }
26 /// **Keyboard dialogs**
27 ///
28 /// The functions listed below have to be permitted by the user for the
29 /// representation of a keyboard around an input.
30 ///
31 /// The class supports several kinds, from an easy text choice up to the
32 /// passport Word production and their confirmation for add-on.
33 ///
34 /// It has the header \ref Keyboard.h "#include <kodi/gui/dialogs/Keyboard.h>"
35 /// be included to enjoy it.
36 ///
37 namespace Keyboard
38 {
39 //==========================================================================
40 ///
41 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
42 /// @brief Show keyboard with initial value `text` and replace with result
43 /// string.
44 ///
45 /// @param[in,out] text Overwritten with user input if return=true.
46 /// @param[in] heading String shown on dialog title.
47 /// @param[in] allowEmptyResult Whether a blank password is valid or not.
48 /// @param[in] hiddenInput The inserted input is not shown as text.
49 /// @param[in] autoCloseMs To close the dialog after a specified
50 /// time, in milliseconds, default is 0 which
51 /// keeps the dialog open indefinitely.
52 /// @return true if successful display and user input.
53 /// false if unsuccessful display, no user
54 /// input, or canceled editing.
55 ///
56 ///
57 ///-------------------------------------------------------------------------
58 ///
59 /// **Example:**
60 /// ~~~~~~~~~~~~~{.cpp}
61 /// #include <kodi/gui/dialogs/Keyboard.h>
62 ///
63 /// /*
64 /// * The example shows the display of keyboard call dialog at Kodi from the add-on.
65 /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0)
66 /// * to be released if not needed.
67 /// */
68 /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a
69 /// entry text added */
70 /// bool bRet = ::kodi::gui::dialogs::Keyboard::ShowAndGetInput(text,
71 /// "Demonstration text entry",
72 /// true,
73 /// false,
74 /// 0);
75 /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n",
76 /// text.c_str(), bRet ? "OK" : "Canceled");
77 /// ~~~~~~~~~~~~~
78 ///
79 inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text,
80 const std::string& heading,
81 bool allowEmptyResult,
82 bool hiddenInput = false,
83 unsigned int autoCloseMs = 0)
84 {
85 using namespace ::kodi::addon;
86 char* retString = nullptr;
87 bool ret =
88 CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(
89 CAddonBase::m_interface->toKodi->kodiBase, text.c_str(), &retString, heading.c_str(),
90 allowEmptyResult, hiddenInput, autoCloseMs);
91 if (retString != nullptr)
92 {
93 text = retString;
94 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase,
95 retString);
96 }
97 return ret;
98 }
99 //--------------------------------------------------------------------------
100
101 //==========================================================================
102 ///
103 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
104 /// @brief The example shows the display of keyboard call dialog at Kodi
105 /// from the add-on.
106 ///
107 /// @param[out] text Overwritten with user input if return=true.
108 /// @param[in] allowEmptyResult If set to true keyboard can also exited
109 /// without entered text.
110 /// @param[in] autoCloseMs To close the dialog after a specified time,
111 /// in milliseconds, default is 0 which keeps
112 /// the dialog open indefinitely.
113 /// @return true if successful display and user input.
114 /// false if unsuccessful display, no user
115 /// input, or canceled editing.
116 ///
117 inline bool ATTRIBUTE_HIDDEN ShowAndGetInput(std::string& text,
118 bool allowEmptyResult,
119 unsigned int autoCloseMs = 0)
120 {
121 using namespace ::kodi::addon;
122 char* retString = nullptr;
123 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase,
124 text.c_str(), &retString,
125 allowEmptyResult, autoCloseMs);
126 if (retString != nullptr)
127 {
128 text = retString;
129 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
130 }
131 return ret;
132 }
133 //--------------------------------------------------------------------------
134
135 //==========================================================================
136 ///
137 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
138 /// @brief Shows keyboard and prompts for a password. Differs from
139 /// `ShowAndVerifyNewPassword()` in that no second verification
140 ///
141 /// @param[in,out] newPassword Overwritten with user input if return=true.
142 /// @param[in] heading String shown on dialog title.
143 /// @param[in] allowEmptyResult Whether a blank password is valid or not.
144 /// @param[in] autoCloseMs To close the dialog after a specified time,
145 /// in milliseconds, default is 0 which keeps
146 /// the dialog open indefinitely.
147 /// @return true if successful display and user input.
148 /// false if unsuccessful display, no user
149 /// input, or canceled editing.
150 ///
151 inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword,
152 const std::string& heading,
153 bool allowEmptyResult,
154 unsigned int autoCloseMs = 0)
155 {
156 using namespace ::kodi::addon;
157 char* retString = nullptr;
158 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase,
159 newPassword.c_str(), &retString, heading.c_str(),
160 allowEmptyResult, autoCloseMs);
161 if (retString != nullptr)
162 {
163 newPassword = retString;
164 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
165 }
166 return ret;
167 }
168 //--------------------------------------------------------------------------
169
170 //==========================================================================
171 ///
172 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
173 /// @brief Shows keyboard and prompts for a password. Differs from
174 /// `ShowAndVerifyNewPassword()` in that no second verification
175 ///
176 /// @param[in,out] newPassword Overwritten with user input if return=true.
177 /// @param[in] autoCloseMs To close the dialog after a specified time,
178 /// in milliseconds, default is 0 which keeps
179 /// the dialog open indefinitely.
180 /// @return true if successful display and user input.
181 /// false if unsuccessful display, no user
182 /// input, or canceled editing.
183 ///
184 inline bool ATTRIBUTE_HIDDEN ShowAndGetNewPassword(std::string& newPassword,
185 unsigned int autoCloseMs = 0)
186 {
187 using namespace ::kodi::addon;
188 char* retString = nullptr;
189 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase,
190 newPassword.c_str(), &retString, autoCloseMs);
191 if (retString != nullptr)
192 {
193 newPassword = retString;
194 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
195 }
196 return ret;
197 }
198 //--------------------------------------------------------------------------
199
200 //==========================================================================
201 ///
202 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
203 /// @brief Show keyboard twice to get and confirm a user-entered password
204 /// string.
205 ///
206 /// @param[out] newPassword Overwritten with user input if return=true.
207 /// @param[in] heading String shown on dialog title.
208 /// @param[in] allowEmptyResult
209 /// @param[in] autoCloseMs To close the dialog after a specified time,
210 /// in milliseconds, default is 0 which keeps
211 /// the dialog open indefinitely.
212 /// @return true if successful display and user input.
213 /// false if unsuccessful display, no user
214 /// input, or canceled editing.
215 ///
216 ///
217 ///-------------------------------------------------------------------------
218 ///
219 /// **Example:**
220 /// ~~~~~~~~~~~~~{.cpp}
221 /// #include <kodi/General.h>
222 /// #include <kodi/gui/dialogs/Keyboard.h>
223 ///
224 /// /*
225 /// * The example below shows the complete use of keyboard dialog for password
226 /// * check. If only one check from add-on needed can be function with retries
227 /// * set to '0' called alone.
228 /// *
229 /// * The use of MD5 translated password is always required for the check on Kodi!
230 /// */
231 ///
232 /// int maxretries = 3;
233 /// /*
234 /// * Password names need to be send as md5 sum to kodi.
235 /// */
236 /// std::string password;
237 /// kodi::GetMD5("kodi", password);
238 ///
239 /// /*
240 /// * To the loop about password checks.
241 /// */
242 /// int ret;
243 /// for (unsigned int i = 0; i < maxretries; i++)
244 /// {
245 /// /*
246 /// * Ask the user about the password.
247 /// */
248 /// ret = ::kodi::gui::dialogs::Keyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0);
249 /// if (ret == 0)
250 /// {
251 /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1);
252 /// break;
253 /// }
254 /// else if (ret < 0)
255 /// {
256 /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1);
257 /// break;
258 /// }
259 /// else /* if (ret > 0) */
260 /// {
261 /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1);
262 /// }
263 /// }
264 /// ~~~~~~~~~~~~~
265 ///
266 inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword,
267 const std::string& heading,
268 bool allowEmptyResult,
269 unsigned int autoCloseMs = 0)
270 {
271 using namespace ::kodi::addon;
272 char* retString = nullptr;
273 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase,
274 &retString, heading.c_str(), allowEmptyResult,
275 autoCloseMs);
276 if (retString != nullptr)
277 {
278 newPassword = retString;
279 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
280 }
281 return ret;
282 }
283 //--------------------------------------------------------------------------
284
285 //==========================================================================
286 ///
287 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
288 /// @brief Show keyboard twice to get and confirm a user-entered password
289 /// string.
290 ///
291 /// @param[out] newPassword Overwritten with user input if return=true.
292 /// @param[in] autoCloseMs To close the dialog after a specified time,
293 /// in milliseconds, default is 0 which keeps
294 /// the dialog open indefinitely.
295 /// @return true if successful display and user input.
296 /// false if unsuccessful display, no user
297 /// input, or canceled editing.
298 ///
299 inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword,
300 unsigned int autoCloseMs = 0)
301 {
302 using namespace ::kodi::addon;
303 char* retString = nullptr;
304 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase,
305 &retString, autoCloseMs);
306 if (retString != nullptr)
307 {
308 newPassword = retString;
309 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
310 }
311 return ret;
312 }
313 //--------------------------------------------------------------------------
314
315 //==========================================================================
316 ///
317 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
318 /// @brief Show keyboard and verify user input against `password`.
319 ///
320 /// @param[in,out] password Value to compare against user input.
321 /// @param[in] heading String shown on dialog title.
322 /// @param[in] retries If greater than 0, shows "Incorrect
323 /// password, %d retries left" on dialog line 2,
324 /// else line 2 is blank.
325 /// @param[in] autoCloseMs To close the dialog after a specified time,
326 /// in milliseconds, default is 0 which keeps
327 /// the dialog open indefinitely.
328 /// @return 0 if successful display and user input. 1 if
329 /// unsuccessful input. -1 if no user input or
330 /// canceled editing.
331 ///
332 inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(std::string& password,
333 const std::string& heading,
334 int retries,
335 unsigned int autoCloseMs = 0)
336 {
337 using namespace ::kodi::addon;
338 char* retString = nullptr;
339 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase,
340 password.c_str(), &retString, heading.c_str(),
341 retries, autoCloseMs);
342 if (retString != nullptr)
343 {
344 password = retString;
345 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
346 }
347 return ret;
348 }
349 //--------------------------------------------------------------------------
350
351 //==========================================================================
352 ///
353 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
354 /// @brief Shows a filter related keyboard
355 ///
356 /// @param[in,out] text Overwritten with user input if return=true.
357 /// @param[in] searching Use dialog for search and send our search
358 /// message in safe way (only the active window
359 /// needs it)
360 /// - header name if true is "Enter search string"
361 /// - header name if false is "Enter value"
362 /// @param autoCloseMs To close the dialog after a specified time,
363 /// in milliseconds, default is 0 which keeps
364 /// the dialog open indefinitely.
365 /// @return true if successful display and user input.
366 /// false if unsuccessful display, no user
367 /// input, or canceled editing.
368 ///
369 inline bool ATTRIBUTE_HIDDEN ShowAndGetFilter(std::string& text,
370 bool searching,
371 unsigned int autoCloseMs = 0)
372 {
373 using namespace ::kodi::addon;
374 char* retString = nullptr;
375 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase,
376 text.c_str(), &retString, searching, autoCloseMs);
377 if (retString != nullptr)
378 {
379 text = retString;
380 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
381 }
382 return ret;
383 }
384 //--------------------------------------------------------------------------
385
386 //==========================================================================
387 ///
388 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
389 /// @brief Send a text to a visible keyboard
390 ///
391 /// @param[in] text Overwritten with user input if return=true.
392 /// @param[in] closeKeyboard The open dialog is if also closed on 'true'.
393 /// @return true if successful done, false if
394 /// unsuccessful or keyboard not present.
395 ///
396 inline bool ATTRIBUTE_HIDDEN SendTextToActiveKeyboard(const std::string& text,
397 bool closeKeyboard = false)
398 {
399 using namespace ::kodi::addon;
400 return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase,
401 text.c_str(), closeKeyboard);
402 }
403 //--------------------------------------------------------------------------
404
405 //==========================================================================
406 ///
407 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
408 /// @brief Check for visible keyboard on GUI
409 ///
410 /// @return true if keyboard present, false if not present
411 ///
412 inline bool ATTRIBUTE_HIDDEN IsKeyboardActivated()
413 {
414 using namespace ::kodi::addon;
415 return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase);
416 }
417 //--------------------------------------------------------------------------
418 };
419
420} /* namespace dialogs */
421} /* namespace gui */
422} /* namespace kodi */