summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h362
1 files changed, 0 insertions, 362 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h
deleted file mode 100644
index bff7683..0000000
--- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h
+++ /dev/null
@@ -1,362 +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_Numeric Dialog Numeric
24 /// \ingroup cpp_kodi_gui
25 /// @{
26 /// @brief \cpp_namespace{ kodi::gui::dialogs::Numeric }
27 /// **Numeric dialogs**
28 ///
29 /// The functions listed below have to be permitted by the user for the
30 /// representation of a numeric keyboard around an input.
31 ///
32 /// The class supports several kinds, from an easy number choice up to the
33 /// passport Word production and their confirmation for add-on.
34 ///
35 /// It has the header \ref Numeric.h "#include <kodi/gui/dialogs/Numeric.h>"
36 /// be included to enjoy it.
37 ///
38 namespace Numeric
39 {
40 //==========================================================================
41 ///
42 /// \ingroup cpp_kodi_gui_dialogs_Numeric
43 /// @brief Use dialog to get numeric new password
44 ///
45 /// @param[out] newPassword String to preload into the keyboard
46 /// accumulator. Overwritten with user input
47 /// if return=true. Returned in MD5 format.
48 /// @return true if successful display and user
49 /// input entry/re-entry.
50 /// false if unsuccessful display, no user
51 /// input, or canceled editing.
52 ///
53 inline bool ATTRIBUTE_HIDDEN ShowAndVerifyNewPassword(std::string& newPassword)
54 {
55 using namespace ::kodi::addon;
56 char* pw = nullptr;
57 bool ret =
58 CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(
59 CAddonBase::m_interface->toKodi->kodiBase, &pw);
60 if (pw != nullptr)
61 {
62 newPassword = pw;
63 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw);
64 }
65 return ret;
66 }
67 //--------------------------------------------------------------------------
68
69 //==========================================================================
70 ///
71 /// \ingroup cpp_kodi_gui_dialogs_Numeric
72 /// @brief Use dialog to verify numeric password.
73 ///
74 /// @param[in] password Password to compare with user input, need
75 /// in MD5 format.
76 /// @param[in] heading Heading to display
77 /// @param[in] retries If greater than 0, shows "Incorrect
78 /// password, %d retries left" on dialog
79 /// line 2, else line 2 is blank.
80 /// @return Possible values:
81 /// - 0 if successful display and user input.
82 /// - 1 if unsuccessful input.
83 /// - -1 if no user input or canceled editing.
84 ///
85 ///
86 ///-------------------------------------------------------------------------
87 ///
88 /// **Example:**
89 /// ~~~~~~~~~~~~~{.cpp}
90 /// #include <stdio.h> /* fprintf */
91 /// #include <kodi/General.h>
92 /// #include <kodi/gui/dialogs/Numeric.h>
93 ///
94 /// /*
95 /// * The example below shows the complete use of keyboard dialog for password
96 /// * check. If only one check from add-on needed can be function with retries
97 /// * set to '0' called alone.
98 /// *
99 /// * The use of MD5 translated password is always required for the check on Kodi!
100 /// */
101 ///
102 /// int maxretries = 3;
103 ///
104 /// /*
105 /// * Password names need to be send as md5 sum to kodi.
106 /// */
107 /// std::string password = kodi::GetMD5("1234");
108 ///
109 /// /*
110 /// * To the loop about password checks.
111 /// */
112 /// int ret;
113 /// for (unsigned int i = 0; i < maxretries; i++)
114 /// {
115 /// /*
116 /// * Ask the user about the password.
117 /// */
118 /// ret = kodi::gui::dialogs::Numeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i);
119 /// if (ret == 0)
120 /// {
121 /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1);
122 /// break;
123 /// }
124 /// else if (ret < 0)
125 /// {
126 /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1);
127 /// break;
128 /// }
129 /// else /* if (ret > 0) */
130 /// {
131 /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1);
132 /// }
133 /// }
134 /// ~~~~~~~~~~~~~
135 ///
136 inline int ATTRIBUTE_HIDDEN ShowAndVerifyPassword(const std::string& password,
137 const std::string& heading,
138 int retries)
139 {
140 using namespace ::kodi::addon;
141 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase,
142 password.c_str(), heading.c_str(), retries);
143 }
144 //--------------------------------------------------------------------------
145
146 //==========================================================================
147 ///
148 /// \ingroup cpp_kodi_gui_dialogs_Numeric
149 /// @brief Use dialog to verify numeric password
150 ///
151 /// @param[in,out] toVerify Value to compare against user input.
152 /// @param[in] heading Heading to display
153 /// @param[in] verifyInput If set as true we verify the users input
154 /// versus toVerify.
155 /// @return true if successful display and user
156 /// input. false if unsuccessful display, no
157 /// user input, or canceled editing.
158 ///
159 inline bool ATTRIBUTE_HIDDEN ShowAndVerifyInput(std::string& toVerify,
160 const std::string& heading,
161 bool verifyInput)
162 {
163 using namespace ::kodi::addon;
164 char* retString = nullptr;
165 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase,
166 toVerify.c_str(), &retString, heading.c_str(), verifyInput);
167 if (retString != nullptr)
168 {
169 toVerify = retString;
170 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
171 }
172 return ret;
173 }
174 //--------------------------------------------------------------------------
175
176 //==========================================================================
177 ///
178 /// \ingroup cpp_kodi_gui_dialogs_Numeric
179 /// @brief Use dialog to get time value.
180 ///
181 /// @param[out] time Overwritten with user input if
182 /// return=true and time inserted.
183 /// @param[in] heading Heading to display.
184 /// @return true if successful display and user
185 /// input. false if unsuccessful display, no
186 /// user input, or canceled editing.
187 ///
188 ///
189 ///-------------------------------------------------------------------------
190 ///
191 /// **Example:**
192 /// ~~~~~~~~~~~~~{.cpp}
193 /// #include <stdio.h> /* printf */
194 /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */
195 /// #include <kodi/gui/dialogs/Numeric.h>
196 ///
197 /// time_t rawtime;
198 /// struct tm * timeinfo;
199 /// char buffer [10];
200 ///
201 /// time (&rawtime);
202 /// timeinfo = localtime(&rawtime);
203 /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetTime(*timeinfo, "Selected time test call");
204 /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo);
205 /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled");
206 /// ~~~~~~~~~~~~~
207 ///
208 inline bool ATTRIBUTE_HIDDEN ShowAndGetTime(tm& time, const std::string& heading)
209 {
210 using namespace ::kodi::addon;
211 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str());
212 }
213 //--------------------------------------------------------------------------
214
215 //==========================================================================
216 ///
217 /// \ingroup cpp_kodi_gui_dialogs_Numeric
218 /// @brief Use dialog to get date value.
219 ///
220 /// @param[in,out] date Overwritten with user input if
221 /// return=true and date inserted.
222 /// @param[in] heading Heading to display
223 /// @return true if successful display and user
224 /// input. false if unsuccessful display, no
225 /// user input, or canceled editing.
226 ///
227 ///
228 ///-------------------------------------------------------------------------
229 ///
230 /// **Example:**
231 /// ~~~~~~~~~~~~~{.cpp}
232 /// #include <stdio.h> /* printf */
233 /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */
234 /// #include <kodi/gui/dialogs/Numeric.h>
235 ///
236 /// time_t rawtime;
237 /// struct tm * timeinfo;
238 /// char buffer [20];
239 ///
240 /// time (&rawtime);
241 /// timeinfo = localtime(&rawtime);
242 /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetDate(*timeinfo, "Selected date test call");
243 /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo);
244 /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled");
245 /// ~~~~~~~~~~~~~
246 ///
247 inline bool ATTRIBUTE_HIDDEN ShowAndGetDate(tm& date, const std::string& heading)
248 {
249 using namespace ::kodi::addon;
250 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str());
251 }
252 //--------------------------------------------------------------------------
253
254 //==========================================================================
255 ///
256 /// \ingroup cpp_kodi_gui_dialogs_Numeric
257 /// @brief Use dialog to get a IP
258 ///
259 /// @param[in,out] ipAddress Overwritten with user input if
260 /// return=true and IP address inserted.
261 /// @param[in] heading Heading to display.
262 /// @return true if successful display and
263 /// user input. false if unsuccessful
264 /// display, no user input, or canceled
265 /// editing.
266 ///
267 inline bool ATTRIBUTE_HIDDEN ShowAndGetIPAddress(std::string& ipAddress,
268 const std::string& heading)
269 {
270 using namespace ::kodi::addon;
271 char* retString = nullptr;
272 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase,
273 ipAddress.c_str(), &retString, heading.c_str());
274 if (retString != nullptr)
275 {
276 ipAddress = retString;
277 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
278 }
279 return ret;
280 }
281 //--------------------------------------------------------------------------
282
283 //==========================================================================
284 ///
285 /// \ingroup cpp_kodi_gui_dialogs_Numeric
286 /// @brief Use dialog to get normal number.
287 ///
288 /// @param[in,out] input Overwritten with user input if
289 /// return=true and time in seconds inserted
290 /// @param[in] heading Heading to display
291 /// @param[in] autoCloseTimeoutMs To close the dialog after a specified
292 /// time, in milliseconds, default is 0
293 /// which keeps the dialog open
294 /// indefinitely.
295 /// @return true if successful display and user
296 /// input. false if unsuccessful display, no
297 /// user input, or canceled editing.
298 ///
299 ///
300 ///-------------------------------------------------------------------------
301 ///
302 /// **Example:**
303 /// ~~~~~~~~~~~~~{.cpp}
304 /// #include <stdio.h> /* printf */
305 /// #include <stdlib.h> /* strtoull (C++11) */
306 /// #include <kodi/gui/dialogs/Numeric.h>
307 ///
308 /// std::string number;
309 /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetNumber(number, "Number test call");
310 /// printf("Written number input is : %llu and was %s\n",
311 /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled");
312 /// ~~~~~~~~~~~~~
313 ///
314 inline bool ATTRIBUTE_HIDDEN ShowAndGetNumber(std::string& input,
315 const std::string& heading,
316 unsigned int autoCloseTimeoutMs = 0)
317 {
318 using namespace ::kodi::addon;
319 char* retString = nullptr;
320 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase,
321 input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs);
322 if (retString != nullptr)
323 {
324 input = retString;
325 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
326 }
327 return ret;
328 }
329 //--------------------------------------------------------------------------
330
331 //==========================================================================
332 ///
333 /// \ingroup cpp_kodi_gui_dialogs_Numeric
334 /// @brief Show numeric keypad to get seconds.
335 ///
336 /// @param[in,out] time Overwritten with user input if return=true and
337 /// time in seconds inserted.
338 /// @param[in] heading Heading to display
339 /// @return true if successful display and user input. false
340 /// if unsuccessful display, no user input, or
341 /// canceled editing.
342 ///
343 inline bool ATTRIBUTE_HIDDEN ShowAndGetSeconds(std::string& time, const std::string& heading)
344 {
345 using namespace ::kodi::addon;
346 char* retString = nullptr;
347 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase,
348 time.c_str(), &retString, heading.c_str());
349 if (retString != nullptr)
350 {
351 time = retString;
352 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
353 }
354 return ret;
355 }
356 //--------------------------------------------------------------------------
357 };
358 /// @}
359
360} /* namespace dialogs */
361} /* namespace gui */
362} /* namespace kodi */