summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h98
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h247
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h296
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h419
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h369
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h107
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h252
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h105
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h118
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h190
10 files changed, 2201 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
new file mode 100644
index 0000000..47afc23
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
@@ -0,0 +1,98 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_namespace{ kodi::gui::dialogs::ContextMenu }
37 /// **Context menu dialog**
38 ///
39 /// The function listed below permits the call of a dialogue as context menu to
40 /// select of an entry as a key
41 ///
42 /// It has the header \ref ContextMenu.h "#include <kodi/gui/dialogs/ContextMenu.h>"
43 /// be included to enjoy it.
44 ///
45 ///
46 namespace ContextMenu
47 {
48 //==========================================================================
49 ///
50 /// \ingroup cpp_kodi_gui_dialogs_ContextMenu
51 /// @brief Show a context menu dialog about given parts.
52 ///
53 /// @param[in] heading Dialog heading name
54 /// @param[in] entries String list about entries
55 /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled
56 ///
57 ///
58 ///-------------------------------------------------------------------------
59 ///
60 /// **Example:**
61 /// ~~~~~~~~~~~~~{.cpp}
62 /// #include <kodi/gui/dialogs/ContextMenu.h>
63 ///
64 /// const std::vector<std::string> entries
65 /// {
66 /// "Test 1",
67 /// "Test 2",
68 /// "Test 3",
69 /// "Test 4",
70 /// "Test 5"
71 /// };
72 ///
73 /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries);
74 /// if (selected < 0)
75 /// fprintf(stderr, "Item selection canceled\n");
76 /// else
77 /// fprintf(stderr, "Selected item is: %i\n", selected);
78 /// ~~~~~~~~~~~~~
79 ///
80 inline int Show(const std::string& heading, const std::vector<std::string>& entries)
81 {
82 using namespace ::kodi::addon;
83 unsigned int size = entries.size();
84 const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**)));
85 for (unsigned int i = 0; i < size; ++i)
86 {
87 cEntries[i] = entries[i].c_str();
88 }
89 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
90 free(cEntries);
91 return ret;
92 }
93 //--------------------------------------------------------------------------
94 };
95
96} /* namespace dialogs */
97} /* namespace gui */
98} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
new file mode 100644
index 0000000..e9c5a9d
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ExtendedProgress.h
@@ -0,0 +1,247 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_CExtendedProgress Dialog Extended Progress
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_class{ kodi::gui::dialogs::ExtendedProgress }
37 /// **Progress dialog shown for background work**
38 ///
39 /// The with \ref ExtendedProgress.h "#include <kodi/gui/dialogs/ExtendedProgress.h>"
40 /// given class are basically used to create Kodi's extended progress.
41 ///
42 ///
43 /// --------------------------------------------------------------------------
44 ///
45 /// **Example:**
46 /// ~~~~~~~~~~~~~{.cpp}
47 /// #include <kodi/gui/dialogs/ExtendedProgress.h>
48 ///
49 /// kodi::gui::dialogs::CExtendedProgress *ext_progress = new kodi::gui::dialogs::CExtendedProgress("Test Extended progress");
50 /// ext_progress->SetText("Test progress");
51 /// for (unsigned int i = 0; i < 50; i += 10)
52 /// {
53 /// ext_progress->SetProgress(i, 100);
54 /// sleep(1);
55 /// }
56 ///
57 /// ext_progress->SetTitle("Test Extended progress - Second round");
58 /// ext_progress->SetText("Test progress - Step 2");
59 ///
60 /// for (unsigned int i = 50; i < 100; i += 10)
61 /// {
62 /// ext_progress->SetProgress(i, 100);
63 /// sleep(1);
64 /// }
65 /// delete ext_progress;
66 /// ~~~~~~~~~~~~~
67 ///
68 class CExtendedProgress
69 {
70 public:
71 //==========================================================================
72 ///
73 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
74 /// Construct a new dialog
75 ///
76 /// @param[in] title Title string
77 ///
78 CExtendedProgress(const std::string& title = "")
79 {
80 using namespace ::kodi::addon;
81 m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str());
82 if (!m_DialogHandle)
83 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!");
84 }
85 //--------------------------------------------------------------------------
86
87 //==========================================================================
88 ///
89 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
90 /// Destructor
91 ///
92 ~CExtendedProgress()
93 {
94 using namespace ::kodi::addon;
95 if (m_DialogHandle)
96 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
97 }
98 //--------------------------------------------------------------------------
99
100 //==========================================================================
101 ///
102 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
103 /// @brief Get the used title
104 ///
105 /// @return Title string
106 ///
107 std::string Title() const
108 {
109 using namespace ::kodi::addon;
110 std::string text;
111 char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
112 if (strMsg != nullptr)
113 {
114 if (std::strlen(strMsg))
115 text = strMsg;
116 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg);
117 }
118 return text;
119 }
120 //--------------------------------------------------------------------------
121
122 //==========================================================================
123 ///
124 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
125 /// @brief To set the title of dialog
126 ///
127 /// @param[in] title Title string
128 ///
129 void SetTitle(const std::string& title)
130 {
131 using namespace ::kodi::addon;
132 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str());
133 }
134 //--------------------------------------------------------------------------
135
136 //==========================================================================
137 ///
138 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
139 /// @brief Get the used text information string
140 ///
141 /// @return Text string
142 ///
143 std::string Text() const
144 {
145 using namespace ::kodi::addon;
146 std::string text;
147 char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
148 if (strMsg != nullptr)
149 {
150 if (std::strlen(strMsg))
151 text = strMsg;
152 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg);
153 }
154 return text;
155 }
156 //--------------------------------------------------------------------------
157
158 //==========================================================================
159 ///
160 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
161 /// @brief To set the used text information string
162 ///
163 /// @param[in] text information text to set
164 ///
165 void SetText(const std::string& text)
166 {
167 using namespace ::kodi::addon;
168 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str());
169 }
170 //--------------------------------------------------------------------------
171
172 //==========================================================================
173 ///
174 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
175 /// @brief To ask dialog is finished
176 ///
177 /// @return True if on end
178 ///
179 bool IsFinished() const
180 {
181 using namespace ::kodi::addon;
182 return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
183 }
184 //--------------------------------------------------------------------------
185
186 //==========================================================================
187 ///
188 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
189 /// @brief Mark progress finished
190 ///
191 void MarkFinished()
192 {
193 using namespace ::kodi::addon;
194 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
195 }
196 //--------------------------------------------------------------------------
197
198 //==========================================================================
199 ///
200 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
201 /// @brief Get the current progress position as percent
202 ///
203 /// @return Position
204 ///
205 float Percentage() const
206 {
207 using namespace ::kodi::addon;
208 return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
209 }
210 //--------------------------------------------------------------------------
211
212 //==========================================================================
213 ///
214 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
215 /// @brief To set the current progress position as percent
216 ///
217 /// @param[in] percentage Position to use from 0.0 to 100.0
218 ///
219 void SetPercentage(float percentage)
220 {
221 using namespace ::kodi::addon;
222 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage);
223 }
224 //--------------------------------------------------------------------------
225
226 //==========================================================================
227 ///
228 /// \ingroup cpp_kodi_gui_dialogs_CExtendedProgress
229 /// @brief To set progress position with predefined places
230 ///
231 /// @param[in] currentItem Place position to use
232 /// @param[in] itemCount Amount of used places
233 ///
234 void SetProgress(int currentItem, int itemCount)
235 {
236 using namespace ::kodi::addon;
237 CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount);
238 }
239 //--------------------------------------------------------------------------
240
241 private:
242 void* m_DialogHandle;
243 };
244
245} /* namespace dialogs */
246} /* namespace gui */
247} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h
new file mode 100644
index 0000000..401a78d
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/FileBrowser.h
@@ -0,0 +1,296 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_FileBrowser Dialog File Browser
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_namespace{ kodi::gui::dialogs::FileBrowser }
37 /// **File browser dialog**
38 ///
39 /// The functions listed below of the class "FileBrowser" offer
40 /// the possibility to select to a file by the user of the add-on.
41 ///
42 /// It allows all the options that are possible in Kodi itself and offers all
43 /// support file types.
44 ///
45 /// It has the header \ref FileBrowser.h "#include <kodi/gui/dialogs/FileBrowser.h>"
46 /// be included to enjoy it.
47 ///
48 namespace FileBrowser
49 {
50 //==========================================================================
51 ///
52 /// \ingroup cpp_kodi_gui_dialogs_FileBrowser
53 /// @brief Directory selection dialog
54 ///
55 /// @param[in] shares With Shares becomes the available start folders
56 /// be set.
57 /// @param[in] heading Dialog header name
58 /// @param[in,out] path As in the path to start and return value about
59 /// selected directory
60 /// @param[in] writeOnly If set only writeable folders are shown.
61 /// @return False if selection becomes canceled.
62 ///
63 /// **Example:**
64 /// ~~~~~~~~~~~~~{.cpp}
65 /// #include <kodi/gui/dialogs/FileBrowser.h>
66 ///
67 /// /*
68 /// * Example show directory selection dialog with on 'share' (first value)
69 /// * defined directory types.
70 /// *
71 /// * If this becomes leaved empty and 'directory' is empty goes it to the
72 /// * base path of the hard disk.
73 /// *
74 /// * Also can be with path written to 'directory' before the dialog forced
75 /// * to a start place.
76 /// */
77 /// std::string directory;
78 /// bool ret = kodi::gui::dialogs::FileBrowser::ShowAndGetDirectory("local|network|removable",
79 /// "Test directory selection",
80 /// directory,
81 /// false);
82 /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled");
83 /// ~~~~~~~~~~~~~
84 ///
85 inline bool ShowAndGetDirectory(const std::string& shares, const std::string& heading, std::string& path, bool writeOnly = false)
86 {
87 using namespace ::kodi::addon;
88 char* retString = nullptr;
89 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(CAddonBase::m_interface->toKodi->kodiBase,
90 shares.c_str(), heading.c_str(), path.c_str(), &retString, writeOnly);
91 if (retString != nullptr)
92 {
93 if (std::strlen(retString))
94 path = retString;
95 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
96 }
97 return ret;
98 }
99 //--------------------------------------------------------------------------
100
101 //==========================================================================
102 ///
103 /// \ingroup cpp_kodi_gui_dialogs_FileBrowser
104 /// @brief File selection dialog
105 ///
106 /// @param[in] shares With Shares becomes the available start
107 /// folders be set.
108 /// @param[in] mask The mask to filter visible files, e.g.
109 /// ".m3u|.pls|.b4s|.wpl".
110 /// @param[in] heading Dialog header name
111 /// @param[in,out] path As in the path to start and Return value
112 /// about selected file
113 /// @param[in] useThumbs If set show thumbs if possible on dialog.
114 /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are
115 /// handled as directories.
116 /// @return False if selection becomes canceled.
117 ///
118 inline bool ShowAndGetFile(const std::string& shares, const std::string& mask, const std::string& heading,
119 std::string& path, bool useThumbs = false, bool useFileDirectories = false)
120 {
121 using namespace ::kodi::addon;
122 char* retString = nullptr;
123 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase,
124 shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString,
125 useThumbs, useFileDirectories);
126 if (retString != nullptr)
127 {
128 if (std::strlen(retString))
129 path = retString;
130 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
131 }
132 return ret;
133 }
134 //--------------------------------------------------------------------------
135
136 //==========================================================================
137 ///
138 /// \ingroup cpp_kodi_gui_dialogs_FileBrowser
139 /// @brief File selection from a directory
140 ///
141 /// @param[in] directory The directory name where the dialog
142 /// start, possible are normal names and
143 /// kodi's special names.
144 /// @param[in] mask The mask to filter visible files, e.g.
145 /// ".m3u|.pls|.b4s|.wpl".
146 /// @param[in] heading Dialog header name
147 /// @param[in,out] path As in the path to start and Return value
148 /// about selected file
149 /// @param[in] useThumbs If set show thumbs if possible on dialog.
150 /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are
151 /// handled as directories.
152 /// @param[in] singleList
153 /// @return False if selection becomes canceled.
154 ///
155 inline bool ShowAndGetFileFromDir(const std::string& directory, const std::string& mask, const std::string& heading, std::string& path,
156 bool useThumbs = false, bool useFileDirectories = false, bool singleList = false)
157 {
158 using namespace ::kodi::addon;
159 char* retString = nullptr;
160 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase,
161 directory.c_str(), mask.c_str(), heading.c_str(),
162 path.c_str(), &retString, useThumbs,
163 useFileDirectories, singleList);
164 if (retString != nullptr)
165 {
166 if (std::strlen(retString))
167 path = retString;
168 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
169 }
170 return ret;
171 }
172 //--------------------------------------------------------------------------
173
174 //==========================================================================
175 ///
176 /// \ingroup cpp_kodi_gui_dialogs_FileBrowser
177 /// @brief File selection dialog to get several in to a list
178 ///
179 /// @param[in] shares With Shares becomes the available start
180 /// folders be set.
181 /// @param[in] mask The mask to filter visible files, e.g.
182 /// ".m3u|.pls|.b4s|.wpl".
183 /// @param[in] heading Dialog header name
184 /// @param[out] fileList Return value about selected files
185 /// @param[in] useThumbs If set show thumbs if possible on dialog.
186 /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are
187 /// handled as directories.
188 /// @return False if selection becomes canceled.
189 ///
190 inline bool ShowAndGetFileList(const std::string& shares, const std::string& mask, const std::string& heading,
191 std::vector<std::string>& fileList, bool useThumbs = false, bool useFileDirectories = false)
192 {
193 using namespace ::kodi::addon;
194 char** list = nullptr;
195 unsigned int listSize = 0;
196 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase,
197 shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize,
198 useThumbs, useFileDirectories);
199 if (ret)
200 {
201 for (unsigned int i = 0; i < listSize; ++i)
202 fileList.push_back(list[i]);
203 CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize);
204 }
205 return ret;
206 }
207 //--------------------------------------------------------------------------
208
209 //==========================================================================
210 ///
211 /// \ingroup cpp_kodi_gui_dialogs_FileBrowser
212 /// @brief Source selection dialog
213 ///
214 /// @param[in,out] path As in the path to start and Return value
215 /// about selected source
216 /// @param[in] allowNetworkShares Allow also access to network
217 /// @param[in] additionalShare With additionalShare becomes the available
218 /// start folders be set (optional).
219 /// @param[in] type
220 /// @return False if selection becomes canceled.
221 ///
222 inline bool ShowAndGetSource(std::string& path, bool allowNetworkShares, const std::string& additionalShare = "", const std::string& type = "")
223 {
224 using namespace ::kodi::addon;
225 char* retString = nullptr;
226 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString,
227 allowNetworkShares, additionalShare.c_str(), type.c_str());
228 if (retString != nullptr)
229 {
230 if (std::strlen(retString))
231 path = retString;
232 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
233 }
234 return ret;
235 }
236 //--------------------------------------------------------------------------
237
238 //==========================================================================
239 ///
240 /// \ingroup cpp_kodi_gui_dialogs_FileBrowser
241 /// @brief Image selection dialog
242 ///
243 /// @param[in] shares With Shares becomes the available start folders be
244 /// set.
245 /// @param[in] heading Dialog header name
246 /// @param[out] path Return value about selected image
247 /// @return False if selection becomes canceled.
248 ///
249 inline bool ShowAndGetImage(const std::string& shares, const std::string& heading, std::string& path)
250 {
251 using namespace ::kodi::addon;
252 char* retString = nullptr;
253 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase,
254 shares.c_str(), heading.c_str(), path.c_str(), &retString);
255 if (retString != nullptr)
256 {
257 if (std::strlen(retString))
258 path = retString;
259 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
260 }
261 return ret;
262 }
263 //--------------------------------------------------------------------------
264
265 //==========================================================================
266 ///
267 /// \ingroup cpp_kodi_gui_dialogs_FileBrowser
268 /// @brief Image selection dialog to get several in to a list
269 ///
270 /// @param[in] shares With Shares becomes the available start folders
271 /// be set.
272 /// @param[in] heading Dialog header name
273 /// @param[out] file_list Return value about selected images
274 /// @return False if selection becomes canceled.
275 ///
276 inline bool ShowAndGetImageList(const std::string& shares, const std::string& heading, std::vector<std::string>& file_list)
277 {
278 using namespace ::kodi::addon;
279 char** list = nullptr;
280 unsigned int listSize = 0;
281 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase,
282 shares.c_str(), heading.c_str(), &list, &listSize);
283 if (ret)
284 {
285 for (unsigned int i = 0; i < listSize; ++i)
286 file_list.push_back(list[i]);
287 CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize);
288 }
289 return ret;
290 }
291 //--------------------------------------------------------------------------
292 };
293
294} /* namespace dialogs */
295} /* namespace gui */
296} /* namespace kodi */
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
new file mode 100644
index 0000000..cff30d8
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Keyboard.h
@@ -0,0 +1,419 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_Keyboard Dialog Keyboard
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_namespace{ kodi::gui::dialogs::Keyboard }
37 /// **Keyboard dialogs**
38 ///
39 /// The functions listed below have to be permitted by the user for the
40 /// representation of a keyboard around an input.
41 ///
42 /// The class supports several kinds, from an easy text choice up to the
43 /// passport Word production and their confirmation for add-on.
44 ///
45 /// It has the header \ref Keyboard.h "#include <kodi/gui/dialogs/Keyboard.h>"
46 /// be included to enjoy it.
47 ///
48 namespace Keyboard
49 {
50 //==========================================================================
51 ///
52 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
53 /// @brief Show keyboard with initial value `text` and replace with result
54 /// string.
55 ///
56 /// @param[in,out] text Overwritten with user input if return=true.
57 /// @param[in] heading String shown on dialog title.
58 /// @param[in] allowEmptyResult Whether a blank password is valid or not.
59 /// @param[in] hiddenInput The inserted input is not shown as text.
60 /// @param[in] autoCloseMs To close the dialog after a specified
61 /// time, in milliseconds, default is 0 which
62 /// keeps the dialog open indefinitely.
63 /// @return true if successful display and user input.
64 /// false if unsuccessful display, no user
65 /// input, or canceled editing.
66 ///
67 ///
68 ///-------------------------------------------------------------------------
69 ///
70 /// **Example:**
71 /// ~~~~~~~~~~~~~{.cpp}
72 /// #include <kodi/gui/dialogs/Keyboard.h>
73 ///
74 /// /*
75 /// * The example shows the display of keyboard call dialog at Kodi from the add-on.
76 /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0)
77 /// * to be released if not needed.
78 /// */
79 /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a
80 /// entry text added */
81 /// bool bRet = ::kodi::gui::dialogs::Keyboard::ShowAndGetInput(text,
82 /// "Demonstration text entry",
83 /// true,
84 /// false,
85 /// 0);
86 /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n",
87 /// text.c_str(), bRet ? "OK" : "Canceled");
88 /// ~~~~~~~~~~~~~
89 ///
90 inline bool ShowAndGetInput(std::string& text, const std::string& heading, bool allowEmptyResult, bool hiddenInput = false, unsigned int autoCloseMs = 0)
91 {
92 using namespace ::kodi::addon;
93 char* retString = nullptr;
94 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(CAddonBase::m_interface->toKodi->kodiBase,
95 text.c_str(), &retString, heading.c_str(), allowEmptyResult,
96 hiddenInput, autoCloseMs);
97 if (retString != nullptr)
98 {
99 if (std::strlen(retString))
100 text = retString;
101 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
102 }
103 return ret;
104 }
105 //--------------------------------------------------------------------------
106
107 //==========================================================================
108 ///
109 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
110 /// @brief The example shows the display of keyboard call dialog at Kodi
111 /// from the add-on.
112 ///
113 /// @param[out] text Overwritten with user input if return=true.
114 /// @param[in] allowEmptyResult If set to true keyboard can also exited
115 /// without entered text.
116 /// @param[in] autoCloseMs To close the dialog after a specified time,
117 /// in milliseconds, default is 0 which keeps
118 /// the dialog open indefinitely.
119 /// @return true if successful display and user input.
120 /// false if unsuccessful display, no user
121 /// input, or canceled editing.
122 ///
123 inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0)
124 {
125 using namespace ::kodi::addon;
126 char* retString = nullptr;
127 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase,
128 text.c_str(), &retString,
129 allowEmptyResult, autoCloseMs);
130 if (retString != nullptr)
131 {
132 if (std::strlen(retString))
133 text = retString;
134 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
135 }
136 return ret;
137 }
138 //--------------------------------------------------------------------------
139
140 //==========================================================================
141 ///
142 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
143 /// @brief Shows keyboard and prompts for a password. Differs from
144 /// `ShowAndVerifyNewPassword()` in that no second verification
145 ///
146 /// @param[in,out] newPassword Overwritten with user input if return=true.
147 /// @param[in] heading String shown on dialog title.
148 /// @param[in] allowEmptyResult Whether a blank password is valid or not.
149 /// @param[in] autoCloseMs To close the dialog after a specified time,
150 /// in milliseconds, default is 0 which keeps
151 /// the dialog open indefinitely.
152 /// @return true if successful display and user input.
153 /// false if unsuccessful display, no user
154 /// input, or canceled editing.
155 ///
156 inline bool ShowAndGetNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0)
157 {
158 using namespace ::kodi::addon;
159 char* retString = nullptr;
160 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase,
161 newPassword.c_str(), &retString, heading.c_str(),
162 allowEmptyResult, autoCloseMs);
163 if (retString != nullptr)
164 {
165 if (std::strlen(retString))
166 newPassword = retString;
167 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
168 }
169 return ret;
170 }
171 //--------------------------------------------------------------------------
172
173 //==========================================================================
174 ///
175 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
176 /// @brief Shows keyboard and prompts for a password. Differs from
177 /// `ShowAndVerifyNewPassword()` in that no second verification
178 ///
179 /// @param[in,out] newPassword Overwritten with user input if return=true.
180 /// @param[in] autoCloseMs To close the dialog after a specified time,
181 /// in milliseconds, default is 0 which keeps
182 /// the dialog open indefinitely.
183 /// @return true if successful display and user input.
184 /// false if unsuccessful display, no user
185 /// input, or canceled editing.
186 ///
187 inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0)
188 {
189 using namespace ::kodi::addon;
190 char* retString = nullptr;
191 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase,
192 newPassword.c_str(), &retString, autoCloseMs);
193 if (retString != nullptr)
194 {
195 if (std::strlen(retString))
196 newPassword = retString;
197 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
198 }
199 return ret;
200 }
201 //--------------------------------------------------------------------------
202
203 //==========================================================================
204 ///
205 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
206 /// @brief Show keyboard twice to get and confirm a user-entered password
207 /// string.
208 ///
209 /// @param[out] newPassword Overwritten with user input if return=true.
210 /// @param[in] heading String shown on dialog title.
211 /// @param[in] allowEmptyResult
212 /// @param[in] autoCloseMs To close the dialog after a specified time,
213 /// in milliseconds, default is 0 which keeps
214 /// the dialog open indefinitely.
215 /// @return true if successful display and user input.
216 /// false if unsuccessful display, no user
217 /// input, or canceled editing.
218 ///
219 ///
220 ///-------------------------------------------------------------------------
221 ///
222 /// **Example:**
223 /// ~~~~~~~~~~~~~{.cpp}
224 /// #include <kodi/General.h>
225 /// #include <kodi/gui/dialogs/Keyboard.h>
226 ///
227 /// /*
228 /// * The example below shows the complete use of keyboard dialog for password
229 /// * check. If only one check from add-on needed can be function with retries
230 /// * set to '0' called alone.
231 /// *
232 /// * The use of MD5 translated password is always required for the check on Kodi!
233 /// */
234 ///
235 /// int maxretries = 3;
236 /// /*
237 /// * Password names need to be send as md5 sum to kodi.
238 /// */
239 /// std::string password;
240 /// kodi::GetMD5("kodi", password);
241 ///
242 /// /*
243 /// * To the loop about password checks.
244 /// */
245 /// int ret;
246 /// for (unsigned int i = 0; i < maxretries; i++)
247 /// {
248 /// /*
249 /// * Ask the user about the password.
250 /// */
251 /// ret = ::kodi::gui::dialogs::Keyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0);
252 /// if (ret == 0)
253 /// {
254 /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1);
255 /// break;
256 /// }
257 /// else if (ret < 0)
258 /// {
259 /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1);
260 /// break;
261 /// }
262 /// else /* if (ret > 0) */
263 /// {
264 /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1);
265 /// }
266 /// }
267 /// ~~~~~~~~~~~~~
268 ///
269 inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, 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 if (std::strlen(retString))
279 newPassword = retString;
280 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
281 }
282 return ret;
283 }
284 //--------------------------------------------------------------------------
285
286 //==========================================================================
287 ///
288 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
289 /// @brief Show keyboard twice to get and confirm a user-entered password
290 /// string.
291 ///
292 /// @param[out] newPassword Overwritten with user input if return=true.
293 /// @param[in] autoCloseMs To close the dialog after a specified time,
294 /// in milliseconds, default is 0 which keeps
295 /// the dialog open indefinitely.
296 /// @return true if successful display and user input.
297 /// false if unsuccessful display, no user
298 /// input, or canceled editing.
299 ///
300 inline bool ShowAndVerifyNewPassword(std::string& newPassword, 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 if (std::strlen(retString))
309 newPassword = retString;
310 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
311 }
312 return ret;
313 }
314 //--------------------------------------------------------------------------
315
316 //==========================================================================
317 ///
318 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
319 /// @brief Show keyboard and verify user input against `password`.
320 ///
321 /// @param[in,out] password Value to compare against user input.
322 /// @param[in] heading String shown on dialog title.
323 /// @param[in] retries If greater than 0, shows "Incorrect
324 /// password, %d retries left" on dialog line 2,
325 /// else line 2 is blank.
326 /// @param[in] autoCloseMs To close the dialog after a specified time,
327 /// in milliseconds, default is 0 which keeps
328 /// the dialog open indefinitely.
329 /// @return 0 if successful display and user input. 1 if
330 /// unsuccessful input. -1 if no user input or
331 /// canceled editing.
332 ///
333 inline int ShowAndVerifyPassword(std::string& password, const std::string& heading, int retries, unsigned int autoCloseMs = 0)
334 {
335 using namespace ::kodi::addon;
336 char* retString = nullptr;
337 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase,
338 password.c_str(), &retString, heading.c_str(),
339 retries, autoCloseMs);
340 if (retString != nullptr)
341 {
342 if (std::strlen(retString))
343 password = retString;
344 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
345 }
346 return ret;
347 }
348 //--------------------------------------------------------------------------
349
350 //==========================================================================
351 ///
352 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
353 /// @brief Shows a filter related keyboard
354 ///
355 /// @param[in,out] text Overwritten with user input if return=true.
356 /// @param[in] searching Use dialog for search and send our search
357 /// message in safe way (only the active window
358 /// needs it)
359 /// - header name if true is "Enter search string"
360 /// - header name if false is "Enter value"
361 /// @param autoCloseMs To close the dialog after a specified time,
362 /// in milliseconds, default is 0 which keeps
363 /// the dialog open indefinitely.
364 /// @return true if successful display and user input.
365 /// false if unsuccessful display, no user
366 /// input, or canceled editing.
367 ///
368 inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0)
369 {
370 using namespace ::kodi::addon;
371 char* retString = nullptr;
372 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase,
373 text.c_str(), &retString, searching, autoCloseMs);
374 if (retString != nullptr)
375 {
376 if (std::strlen(retString))
377 text = retString;
378 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
379 }
380 return ret;
381 }
382 //--------------------------------------------------------------------------
383
384 //==========================================================================
385 ///
386 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
387 /// @brief Send a text to a visible keyboard
388 ///
389 /// @param[in] text Overwritten with user input if return=true.
390 /// @param[in] closeKeyboard The open dialog is if also closed on 'true'.
391 /// @return true if successful done, false if
392 /// unsuccessful or keyboard not present.
393 ///
394 inline bool SendTextToActiveKeyboard(const std::string& text, bool closeKeyboard = false)
395 {
396 using namespace ::kodi::addon;
397 return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase,
398 text.c_str(), closeKeyboard);
399 }
400 //--------------------------------------------------------------------------
401
402 //==========================================================================
403 ///
404 /// \ingroup cpp_kodi_gui_dialogs_Keyboard
405 /// @brief Check for visible keyboard on GUI
406 ///
407 /// @return true if keyboard present, false if not present
408 ///
409 inline bool IsKeyboardActivated()
410 {
411 using namespace ::kodi::addon;
412 return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase);
413 }
414 //--------------------------------------------------------------------------
415 };
416
417} /* namespace dialogs */
418} /* namespace gui */
419} /* namespace kodi */
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
new file mode 100644
index 0000000..dddbf7e
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Numeric.h
@@ -0,0 +1,369 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_Numeric Dialog Numeric
35 /// \ingroup cpp_kodi_gui
36 /// @{
37 /// @brief \cpp_namespace{ kodi::gui::dialogs::Numeric }
38 /// **Numeric dialogs**
39 ///
40 /// The functions listed below have to be permitted by the user for the
41 /// representation of a numeric keyboard around an input.
42 ///
43 /// The class supports several kinds, from an easy number choice up to the
44 /// passport Word production and their confirmation for add-on.
45 ///
46 /// It has the header \ref Numeric.h "#include <kodi/gui/dialogs/Numeric.h>"
47 /// be included to enjoy it.
48 ///
49 namespace Numeric
50 {
51 //==========================================================================
52 ///
53 /// \ingroup cpp_kodi_gui_dialogs_Numeric
54 /// @brief Use dialog to get numeric new password
55 ///
56 /// @param[out] newPassword String to preload into the keyboard
57 /// accumulator. Overwritten with user input
58 /// if return=true. Returned in MD5 format.
59 /// @return true if successful display and user
60 /// input entry/re-entry.
61 /// false if unsuccessful display, no user
62 /// input, or canceled editing.
63 ///
64 inline bool ShowAndVerifyNewPassword(std::string& newPassword)
65 {
66 using namespace ::kodi::addon;
67 char* pw = nullptr;
68 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, &pw);
69 if (pw != nullptr)
70 {
71 if (std::strlen(pw))
72 newPassword = pw;
73 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw);
74 }
75 return ret;
76 }
77 //--------------------------------------------------------------------------
78
79 //==========================================================================
80 ///
81 /// \ingroup cpp_kodi_gui_dialogs_Numeric
82 /// @brief Use dialog to verify numeric password.
83 ///
84 /// @param[in] password Password to compare with user input, need
85 /// in MD5 format.
86 /// @param[in] heading Heading to display
87 /// @param[in] retries If greater than 0, shows "Incorrect
88 /// password, %d retries left" on dialog
89 /// line 2, else line 2 is blank.
90 /// @return Possible values:
91 /// - 0 if successful display and user input.
92 /// - 1 if unsuccessful input.
93 /// - -1 if no user input or canceled editing.
94 ///
95 ///
96 ///-------------------------------------------------------------------------
97 ///
98 /// **Example:**
99 /// ~~~~~~~~~~~~~{.cpp}
100 /// #include <stdio.h> /* fprintf */
101 /// #include <kodi/General.h>
102 /// #include <kodi/gui/dialogs/Numeric.h>
103 ///
104 /// /*
105 /// * The example below shows the complete use of keyboard dialog for password
106 /// * check. If only one check from add-on needed can be function with retries
107 /// * set to '0' called alone.
108 /// *
109 /// * The use of MD5 translated password is always required for the check on Kodi!
110 /// */
111 ///
112 /// int maxretries = 3;
113 ///
114 /// /*
115 /// * Password names need to be send as md5 sum to kodi.
116 /// */
117 /// std::string password = kodi::GetMD5("1234");
118 ///
119 /// /*
120 /// * To the loop about password checks.
121 /// */
122 /// int ret;
123 /// for (unsigned int i = 0; i < maxretries; i++)
124 /// {
125 /// /*
126 /// * Ask the user about the password.
127 /// */
128 /// ret = kodi::gui::dialogs::Numeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i);
129 /// if (ret == 0)
130 /// {
131 /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1);
132 /// break;
133 /// }
134 /// else if (ret < 0)
135 /// {
136 /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1);
137 /// break;
138 /// }
139 /// else /* if (ret > 0) */
140 /// {
141 /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1);
142 /// }
143 /// }
144 /// ~~~~~~~~~~~~~
145 ///
146 inline int ShowAndVerifyPassword(const std::string& password, const std::string& heading, int retries)
147 {
148 using namespace ::kodi::addon;
149 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase,
150 password.c_str(), heading.c_str(), retries);
151 }
152 //--------------------------------------------------------------------------
153
154 //==========================================================================
155 ///
156 /// \ingroup cpp_kodi_gui_dialogs_Numeric
157 /// @brief Use dialog to verify numeric password
158 ///
159 /// @param[in,out] toVerify Value to compare against user input.
160 /// @param[in] heading Heading to display
161 /// @param[in] verifyInput If set as true we verify the users input
162 /// versus toVerify.
163 /// @return true if successful display and user
164 /// input. false if unsuccessful display, no
165 /// user input, or canceled editing.
166 ///
167 inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput)
168 {
169 using namespace ::kodi::addon;
170 char* retString = nullptr;
171 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase,
172 toVerify.c_str(), &retString, heading.c_str(), verifyInput);
173 if (retString != nullptr)
174 {
175 if (std::strlen(retString))
176 toVerify = retString;
177 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
178 }
179 return ret;
180 }
181 //--------------------------------------------------------------------------
182
183 //==========================================================================
184 ///
185 /// \ingroup cpp_kodi_gui_dialogs_Numeric
186 /// @brief Use dialog to get time value.
187 ///
188 /// @param[out] time Overwritten with user input if
189 /// return=true and time inserted.
190 /// @param[in] heading Heading to display.
191 /// @return true if successful display and user
192 /// input. false if unsuccessful display, no
193 /// user input, or canceled editing.
194 ///
195 ///
196 ///-------------------------------------------------------------------------
197 ///
198 /// **Example:**
199 /// ~~~~~~~~~~~~~{.cpp}
200 /// #include <stdio.h> /* printf */
201 /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */
202 /// #include <kodi/gui/dialogs/Numeric.h>
203 ///
204 /// time_t rawtime;
205 /// struct tm * timeinfo;
206 /// char buffer [10];
207 ///
208 /// time (&rawtime);
209 /// timeinfo = localtime(&rawtime);
210 /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetTime(*timeinfo, "Selected time test call");
211 /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo);
212 /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled");
213 /// ~~~~~~~~~~~~~
214 ///
215 inline bool ShowAndGetTime(tm& time, const std::string& heading)
216 {
217 using namespace ::kodi::addon;
218 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str());
219 }
220 //--------------------------------------------------------------------------
221
222 //==========================================================================
223 ///
224 /// \ingroup cpp_kodi_gui_dialogs_Numeric
225 /// @brief Use dialog to get date value.
226 ///
227 /// @param[in,out] date Overwritten with user input if
228 /// return=true and date inserted.
229 /// @param[in] heading Heading to display
230 /// @return true if successful display and user
231 /// input. false if unsuccessful display, no
232 /// user input, or canceled editing.
233 ///
234 ///
235 ///-------------------------------------------------------------------------
236 ///
237 /// **Example:**
238 /// ~~~~~~~~~~~~~{.cpp}
239 /// #include <stdio.h> /* printf */
240 /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */
241 /// #include <kodi/gui/dialogs/Numeric.h>
242 ///
243 /// time_t rawtime;
244 /// struct tm * timeinfo;
245 /// char buffer [20];
246 ///
247 /// time (&rawtime);
248 /// timeinfo = localtime(&rawtime);
249 /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetDate(*timeinfo, "Selected date test call");
250 /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo);
251 /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled");
252 /// ~~~~~~~~~~~~~
253 ///
254 inline bool ShowAndGetDate(tm& date, const std::string& heading)
255 {
256 using namespace ::kodi::addon;
257 return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str());
258 }
259 //--------------------------------------------------------------------------
260
261 //==========================================================================
262 ///
263 /// \ingroup cpp_kodi_gui_dialogs_Numeric
264 /// @brief Use dialog to get a IP
265 ///
266 /// @param[in,out] ipAddress Overwritten with user input if
267 /// return=true and IP address inserted.
268 /// @param[in] heading Heading to display.
269 /// @return true if successful display and
270 /// user input. false if unsuccessful
271 /// display, no user input, or canceled
272 /// editing.
273 ///
274 inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading)
275 {
276 using namespace ::kodi::addon;
277 char* retString = nullptr;
278 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase,
279 ipAddress.c_str(), &retString, heading.c_str());
280 if (retString != nullptr)
281 {
282 if (std::strlen(retString))
283 ipAddress = retString;
284 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
285 }
286 return ret;
287 }
288 //--------------------------------------------------------------------------
289
290 //==========================================================================
291 ///
292 /// \ingroup cpp_kodi_gui_dialogs_Numeric
293 /// @brief Use dialog to get normal number.
294 ///
295 /// @param[in,out] input Overwritten with user input if
296 /// return=true and time in seconds inserted
297 /// @param[in] heading Heading to display
298 /// @param[in] autoCloseTimeoutMs To close the dialog after a specified
299 /// time, in milliseconds, default is 0
300 /// which keeps the dialog open
301 /// indefinitely.
302 /// @return true if successful display and user
303 /// input. false if unsuccessful display, no
304 /// user input, or canceled editing.
305 ///
306 ///
307 ///-------------------------------------------------------------------------
308 ///
309 /// **Example:**
310 /// ~~~~~~~~~~~~~{.cpp}
311 /// #include <stdio.h> /* printf */
312 /// #include <stdlib.h> /* strtoull (C++11) */
313 /// #include <kodi/gui/dialogs/Numeric.h>
314 ///
315 /// std::string number;
316 /// bool bRet = kodi::gui::dialogs::Numeric::ShowAndGetNumber(number, "Number test call");
317 /// printf("Written number input is : %llu and was %s\n",
318 /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled");
319 /// ~~~~~~~~~~~~~
320 ///
321 inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0)
322 {
323 using namespace ::kodi::addon;
324 char* retString = nullptr;
325 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase,
326 input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs);
327 if (retString != nullptr)
328 {
329 if (std::strlen(retString))
330 input = retString;
331 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
332 }
333 return ret;
334 }
335 //--------------------------------------------------------------------------
336
337 //==========================================================================
338 ///
339 /// \ingroup cpp_kodi_gui_dialogs_Numeric
340 /// @brief Show numeric keypad to get seconds.
341 ///
342 /// @param[in,out] time Overwritten with user input if return=true and
343 /// time in seconds inserted.
344 /// @param[in] heading Heading to display
345 /// @return true if successful display and user input. false
346 /// if unsuccessful display, no user input, or
347 /// canceled editing.
348 ///
349 inline bool ShowAndGetSeconds(std::string& time, const std::string& heading)
350 {
351 using namespace ::kodi::addon;
352 char* retString = nullptr;
353 bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase,
354 time.c_str(), &retString, heading.c_str());
355 if (retString != nullptr)
356 {
357 if (std::strlen(retString))
358 time = retString;
359 CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString);
360 }
361 return ret;
362 }
363 //--------------------------------------------------------------------------
364 };
365 /// @}
366
367} /* namespace dialogs */
368} /* namespace gui */
369} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h
new file mode 100644
index 0000000..12799b7
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/OK.h
@@ -0,0 +1,107 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../../AddonBase.h"
23#include "../definitions.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_OK Dialog OK
35 /// \ingroup cpp_kodi_gui
36 /// @{
37 /// @brief \cpp_namespace{ kodi::gui::dialogs::OK }
38 /// **OK dialog**
39 ///
40 /// The functions listed below permit the call of a dialogue of information, a
41 /// confirmation of the user by press from OK required.
42 ///
43 /// It has the header \ref OK.h "#include <kodi/gui/dialogs/OK.h>"
44 /// be included to enjoy it.
45 ///
46 namespace OK
47 {
48 //==========================================================================
49 ///
50 /// \ingroup cpp_kodi_gui_dialogs_OK
51 /// @brief Use dialog to inform user with text and confirmation with OK with continued string.
52 ///
53 /// @param[in] heading Dialog heading.
54 /// @param[in] text Multi-line text.
55 ///
56 ///
57 ///-------------------------------------------------------------------------
58 ///
59 /// **Example:**
60 /// ~~~~~~~~~~~~~{.cpp}
61 /// #include <kodi/gui/dialogs/OK.h>
62 /// ...
63 /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D");
64 /// ~~~~~~~~~~~~~
65 ///
66 inline void ShowAndGetInput(const std::string& heading, const std::string& text)
67 {
68 using namespace ::kodi::addon;
69 CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase,
70 heading.c_str(), text.c_str());
71 }
72 //--------------------------------------------------------------------------
73
74 //==========================================================================
75 ///
76 /// \ingroup cpp_kodi_gui_dialogs_OK
77 /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines.
78 ///
79 /// @param[in] heading Dialog heading.
80 /// @param[in] line0 Line #1 text.
81 /// @param[in] line1 Line #2 text.
82 /// @param[in] line2 Line #3 text.
83 ///
84 ///
85 ///-------------------------------------------------------------------------
86 ///
87 /// **Example:**
88 /// ~~~~~~~~~~~~~{.cpp}
89 /// #include <kodi/gui/dialogs/OK.h>
90 /// ...
91 /// kodi::gui::dialogs::OK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D");
92 /// ~~~~~~~~~~~~~
93 ///
94 inline void ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2)
95 {
96 using namespace ::kodi::addon;
97 CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase,
98 heading.c_str(), line0.c_str(), line1.c_str(),
99 line2.c_str());
100 }
101 //--------------------------------------------------------------------------
102 }
103 /// @}
104
105} /* namespace dialogs */
106} /* namespace gui */
107} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h
new file mode 100644
index 0000000..3f18499
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Progress.h
@@ -0,0 +1,252 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_CProgress Dialog Progress
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_class{ kodi::gui::dialogs::CProgress }
37 /// **Progress dialog shown in center**
38 ///
39 /// The with \ref DialogProgress.h "#include <kodi/gui/dialogs/Progress.h>"
40 /// given class are basically used to create Kodi's progress dialog with named
41 /// text fields.
42 ///
43 /// **Example:**
44 /// ~~~~~~~~~~~~~{.cpp}
45 /// #include <kodi/gui/dialogs/Progress.h>
46 ///
47 /// kodi::gui::dialogs::CProgress *progress = new kodi::gui::dialogs::CProgress;
48 /// progress->SetHeading("Test progress");
49 /// progress->SetLine(1, "line 1");
50 /// progress->SetLine(2, "line 2");
51 /// progress->SetLine(3, "line 3");
52 /// progress->SetCanCancel(true);
53 /// progress->ShowProgressBar(true);
54 /// progress->Open();
55 /// for (unsigned int i = 0; i < 100; i += 10)
56 /// {
57 /// progress->SetPercentage(i);
58 /// sleep(1);
59 /// }
60 /// delete progress;
61 /// ~~~~~~~~~~~~~
62 ///
63 class CProgress
64 {
65 public:
66 //==========================================================================
67 ///
68 /// \ingroup cpp_kodi_gui_dialogs_CProgress
69 /// @brief Construct a new dialog
70 ///
71 CProgress()
72 {
73 using namespace ::kodi::addon;
74 m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase);
75 if (!m_DialogHandle)
76 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::dialogs::CProgress can't create window class from Kodi !!!");
77 }
78 //--------------------------------------------------------------------------
79
80 //==========================================================================
81 ///
82 /// \ingroup cpp_kodi_gui_dialogs_CProgress
83 /// @brief Destructor
84 ///
85 ~CProgress()
86 {
87 using namespace ::kodi::addon;
88 if (m_DialogHandle)
89 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
90 }
91 //--------------------------------------------------------------------------
92
93 //==========================================================================
94 ///
95 /// \ingroup cpp_kodi_gui_dialogs_CProgress
96 /// @brief To open the dialog
97 ///
98 void Open()
99 {
100 using namespace ::kodi::addon;
101 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
102 }
103 //--------------------------------------------------------------------------
104
105 //==========================================================================
106 ///
107 /// \ingroup cpp_kodi_gui_dialogs_CProgress
108 /// @brief Set the heading title of dialog
109 ///
110 /// @param[in] heading Title string to use
111 ///
112 void SetHeading(const std::string& heading)
113 {
114 using namespace ::kodi::addon;
115 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str());
116 }
117 //--------------------------------------------------------------------------
118
119 //==========================================================================
120 ///
121 /// \ingroup cpp_kodi_gui_dialogs_CProgress
122 /// @brief To set the line text field on dialog from 0 - 2
123 ///
124 /// @param[in] iLine Line number
125 /// @param[in] line Text string
126 ///
127 void SetLine(unsigned int iLine, const std::string& line)
128 {
129 using namespace ::kodi::addon;
130 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str());
131 }
132 //--------------------------------------------------------------------------
133
134 //==========================================================================
135 ///
136 /// \ingroup cpp_kodi_gui_dialogs_CProgress
137 /// @brief To enable and show cancel button on dialog
138 ///
139 /// @param[in] canCancel if true becomes it shown
140 ///
141 void SetCanCancel(bool canCancel)
142 {
143 using namespace ::kodi::addon;
144 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel);
145 }
146 //--------------------------------------------------------------------------
147
148 //==========================================================================
149 ///
150 /// \ingroup cpp_kodi_gui_dialogs_CProgress
151 /// @brief To check dialog for clicked cancel button
152 ///
153 /// @return True if canceled
154 ///
155 bool IsCanceled() const
156 {
157 using namespace ::kodi::addon;
158 return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
159 }
160 //--------------------------------------------------------------------------
161
162 //==========================================================================
163 ///
164 /// \ingroup cpp_kodi_gui_dialogs_CProgress
165 /// @brief Get the current progress position as percent
166 ///
167 /// @param[in] percentage Position to use from 0 to 100
168 ///
169 void SetPercentage(int percentage)
170 {
171 using namespace ::kodi::addon;
172 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage);
173 }
174 //--------------------------------------------------------------------------
175
176 //==========================================================================
177 ///
178 /// \ingroup cpp_kodi_gui_dialogs_CProgress
179 /// @brief To set the current progress position as percent
180 ///
181 /// @return Current Position used from 0 to 100
182 ///
183 int GetPercentage() const
184 {
185 using namespace ::kodi::addon;
186 return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
187 }
188 //--------------------------------------------------------------------------
189
190 //==========================================================================
191 ///
192 /// \ingroup cpp_kodi_gui_dialogs_CProgress
193 /// @brief To show or hide progress bar dialog
194 ///
195 /// @param[in] onOff If true becomes it shown
196 ///
197 void ShowProgressBar(bool onOff)
198 {
199 using namespace ::kodi::addon;
200 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff);
201 }
202 //--------------------------------------------------------------------------
203
204 //==========================================================================
205 ///
206 /// \ingroup cpp_kodi_gui_dialogs_CProgress
207 /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used
208 ///
209 /// @param[in] max Biggest usable position to use
210 ///
211 void SetProgressMax(int max)
212 {
213 using namespace ::kodi::addon;
214 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max);
215 }
216 //--------------------------------------------------------------------------
217
218 //==========================================================================
219 ///
220 /// \ingroup cpp_kodi_gui_dialogs_CProgress
221 /// @brief To increase progress bar by defined step size until reach of maximum position
222 ///
223 /// @param[in] steps Step size to increase, default is 1
224 ///
225 void SetProgressAdvance(int steps=1)
226 {
227 using namespace ::kodi::addon;
228 CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps);
229 }
230 //--------------------------------------------------------------------------
231
232 //==========================================================================
233 ///
234 /// \ingroup cpp_kodi_gui_dialogs_CProgress
235 /// @brief To check progress was canceled on work
236 ///
237 /// @return True if aborted
238 ///
239 bool Abort()
240 {
241 using namespace ::kodi::addon;
242 return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle);
243 }
244 //--------------------------------------------------------------------------
245
246 private:
247 void* m_DialogHandle;
248 };
249
250} /* namespace dialogs */
251} /* namespace gui */
252} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h
new file mode 100644
index 0000000..963c84c
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h
@@ -0,0 +1,105 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_Select Dialog Select
35 /// \ingroup cpp_kodi_gui
36 /// @{
37 /// @brief \cpp_namespace{ kodi::gui::dialogs::Select }
38 /// **Selection dialog**
39 ///
40 /// The function listed below permits the call of a dialogue to select of an
41 /// entry as a key
42 ///
43 /// It has the header \ref Select.h "#include <kodi/gui/dialogs/Select.h>"
44 /// be included to enjoy it.
45 ///
46 ///
47 namespace Select
48 {
49 //==========================================================================
50 ///
51 /// \ingroup cpp_kodi_gui_dialogs_Select
52 /// @brief Show a selection dialog about given parts.
53 ///
54 /// @param[in] heading Dialog heading name
55 /// @param[in] entries String list about entries
56 /// @param[in] selected [opt] Predefined selection (default is
57 /// <tt>-1</tt> for the first)
58 /// @param[in] autoclose [opt] To close dialog automatic after the given
59 /// time in ms. As '0' it stays open.
60 /// @return The selected entry, if return <tt>-1</tt> was
61 /// nothing selected or canceled
62 ///
63 ///
64 ///-------------------------------------------------------------------------
65 ///
66 /// **Example:**
67 /// ~~~~~~~~~~~~~{.cpp}
68 /// #include <kodi/gui/dialogs/Select.h>
69 ///
70 /// const std::vector<std::string> entries
71 /// {
72 /// "Test 1",
73 /// "Test 2",
74 /// "Test 3",
75 /// "Test 4",
76 /// "Test 5"
77 /// };
78 ///
79 /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1);
80 /// if (selected < 0)
81 /// fprintf(stderr, "Item selection canceled\n");
82 /// else
83 /// fprintf(stderr, "Selected item is: %i\n", selected);
84 /// ~~~~~~~~~~~~~
85 ///
86 inline int Show(const std::string& heading, const std::vector<std::string>& entries, int selected = -1, unsigned int autoclose = 0)
87 {
88 using namespace ::kodi::addon;
89 unsigned int size = entries.size();
90 const char** cEntries = (const char**)malloc(size*sizeof(const char**));
91 for (unsigned int i = 0; i < size; ++i)
92 {
93 cEntries[i] = entries[i].c_str();
94 }
95 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, autoclose);
96 free(cEntries);
97 return ret;
98 }
99 //--------------------------------------------------------------------------
100 };
101 /// @}
102
103} /* namespace dialogs */
104} /* namespace gui */
105} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h
new file mode 100644
index 0000000..c64bc1e
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/TextViewer.h
@@ -0,0 +1,118 @@
1#pragma once
2/*
3 * Copyright (C) 2015-2016 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_TextViewer Dialog Text Viewer
35 /// \ingroup cpp_kodi_gui
36 /// @{
37 /// @brief \cpp_namespace{ kodi::gui::dialogs::TextViewer }
38 /// **Text viewer dialog**
39 ///
40 /// The text viewer dialog can be used to display descriptions, help texts or
41 /// other larger texts.
42 ///
43 /// In order to achieve a line break is a <b>\\n</b> directly in the text or
44 /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em>
45 /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>.
46 ///
47 /// It has the header \ref TextViewer.h "#include <kodi/gui/dialogs/TextViewer.h>"
48 /// be included to enjoy it.
49 ///
50 namespace TextViewer
51 {
52 //==========================================================================
53 ///
54 /// \ingroup cpp_kodi_gui_dialogs_TextViewer
55 /// @brief Show info text dialog
56 ///
57 /// @param[in] heading Small heading text
58 /// @param[in] text Showed text on dialog
59 ///
60 ///
61 ///-------------------------------------------------------------------------
62 ///
63 /// **Example:**
64 /// ~~~~~~~~~~~~~{.cpp}
65 /// #include <kodi/gui/dialogs/TextViewer.h>
66 ///
67 /// kodi::gui::dialogs::TextViewer::Show("The Wizard of Oz (1939 film)",
68 /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film "
69 /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially "
70 /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz "
71 /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film"
72 /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, "
73 /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and "
74 /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n"
75 /// "\n"
76 /// "Notable for its use of Technicolor, fantasy storytelling, musical score and "
77 /// "unusual characters, over the years it has become an icon of American popular "
78 /// "culture. It was nominated for six Academy Awards, including Best Picture but "
79 /// "lost to Gone with the Wind. It did win in two other categories including Best "
80 /// "Original Song for \"Over the Rainbow\". However, the film was a box office "
81 /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 "
82 /// "budget, despite receiving largely positive reviews. It was MGM's most "
83 /// "expensive production at that time, and did not completely recoup the studio's "
84 /// "investment and turn a profit until theatrical re-releases starting in 1949.\n"
85 /// "\n"
86 /// "The 1956 broadcast television premiere of the film on CBS re-introduced the "
87 /// "film to the wider public and eventually made the presentation an annual "
88 /// "tradition, making it one of the most known films in cinema history. The "
89 /// "film was named the most-viewed motion picture on television syndication by "
90 /// "the Library of Congress who also included the film in its National Film "
91 /// "Registry in its inaugural year in 1989. Designation on the registry calls "
92 /// "for efforts to preserve it for being \"culturally, historically, and "
93 /// "aesthetically significant\". It is also one of the few films on UNESCO's "
94 /// "Memory of the World Register.\n"
95 /// "\n"
96 /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public "
97 /// "polls. It is the source of many quotes referenced in modern popular culture. "
98 /// "It was directed primarily by Victor Fleming (who left production to take "
99 /// "over direction on the troubled Gone with the Wind production). Noel Langley, "
100 /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, "
101 /// "but there were uncredited contributions by others. The songs were written "
102 /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental "
103 /// "music, based largely on the songs, was composed by Herbert Stothart, with "
104 /// "interspersed renderings from classical composers.\n");
105 /// ~~~~~~~~~~~~~
106 ///
107 inline void Show(const std::string& heading, const std::string& text)
108 {
109 using namespace ::kodi::addon;
110 CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str());
111 }
112 //--------------------------------------------------------------------------
113 };
114 /// @}
115
116} /* namespace dialogs */
117} /* namespace gui */
118} /* namespace kodi */
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h
new file mode 100644
index 0000000..d9c34ff
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h
@@ -0,0 +1,190 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_YesNo Dialog Yes/No
35 /// \ingroup cpp_kodi_gui
36 /// @{
37 /// @brief \cpp_namespace{ kodi::gui::dialogs::YesNo }
38 /// **Yes / No dialog**
39 ///
40 /// The Yes / No dialog can be used to inform the user about questions and get
41 /// the answer.
42 ///
43 /// In order to achieve a line break is a <b>\\n</b> directly in the text or
44 /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em>
45 /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>.
46 ///
47 /// It has the header \ref YesNo.h "#include <kodi/gui/dialogs/YesNo.h>"
48 /// be included to enjoy it.
49 ///
50 ///
51 namespace YesNo
52 {
53 //==========================================================================
54 ///
55 /// \ingroup cpp_kodi_gui_dialogs_YesNo
56 /// @brief Use dialog to get numeric new password with one text string shown
57 /// everywhere and cancel return field
58 ///
59 /// @param[in] heading Dialog heading
60 /// @param[in] text Multi-line text
61 /// @param[out] canceled Return value about cancel button
62 /// @param[in] noLabel [opt] label to put on the no button
63 /// @param[in] yesLabel [opt] label to put on the yes button
64 /// @return Returns True if 'Yes' was pressed, else False
65 ///
66 /// @note It is preferred to only use this as it is actually a multi-line text.
67 ///
68 ///
69 ///-------------------------------------------------------------------------
70 ///
71 /// **Example:**
72 /// ~~~~~~~~~~~~~{.cpp}
73 /// #include <kodi/gui/dialogs/YesNo.h>
74 ///
75 /// bool canceled;
76 /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput(
77 /// "Yes / No test call", /* The Header */
78 /// "You has opened Yes / No dialog for test\n\nIs this OK for you?",
79 /// canceled, /* return value about cancel button */
80 /// "Not really", /* No label, is optional and if empty "No" */
81 /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */
82 /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n",
83 /// ret ? "yes" : "no",
84 /// canceled ? "canceled" : "not canceled");
85 /// ~~~~~~~~~~~~~
86 ///
87 inline bool ShowAndGetInput(const std::string& heading, const std::string& text,
88 bool& canceled, const std::string& noLabel = "",
89 const std::string& yesLabel = "")
90 {
91 using namespace ::kodi::addon;
92 return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase,
93 heading.c_str(), text.c_str(), &canceled,
94 noLabel.c_str(), yesLabel.c_str());
95 }
96 //--------------------------------------------------------------------------
97
98 //==========================================================================
99 ///
100 /// \ingroup cpp_kodi_gui_dialogs_YesNo
101 /// @brief Use dialog to get numeric new password with separated line strings
102 ///
103 /// @param[in] heading Dialog heading
104 /// @param[in] line0 Line #0 text
105 /// @param[in] line1 Line #1 text
106 /// @param[in] line2 Line #2 text
107 /// @param[in] noLabel [opt] label to put on the no button.
108 /// @param[in] yesLabel [opt] label to put on the yes button.
109 /// @return Returns True if 'Yes' was pressed, else False.
110 ///
111 ///
112 ///-------------------------------------------------------------------------
113 ///
114 /// **Example:**
115 /// ~~~~~~~~~~~~~{.cpp}
116 /// #include <kodi/gui/dialogs/YesNo.h>
117 ///
118 /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput(
119 /// "Yes / No test call", // The Header
120 /// "You has opened Yes / No dialog for test",
121 /// "",
122 /// "Is this OK for you?",
123 /// "Not really", // No label, is optional and if empty "No"
124 /// "Ohhh yes"); // Yes label, also optional and if empty "Yes"
125 /// fprintf(stderr, "You has called Yes/No, returned '%s'\n",
126 /// ret ? "yes" : "no");
127 /// ~~~~~~~~~~~~~
128 ///
129 inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1,
130 const std::string& line2, const std::string& noLabel = "",
131 const std::string& yesLabel = "")
132 {
133 using namespace ::kodi::addon;
134 return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase,
135 heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(),
136 noLabel.c_str(), yesLabel.c_str());
137 }
138 //--------------------------------------------------------------------------
139
140 //==========================================================================
141 ///
142 /// \ingroup cpp_kodi_gui_dialogs_YesNo
143 /// @brief Use dialog to get numeric new password with separated line strings and cancel return field
144 ///
145 /// @param[in] heading Dialog heading
146 /// @param[in] line0 Line #0 text
147 /// @param[in] line1 Line #1 text
148 /// @param[in] line2 Line #2 text
149 /// @param[out] canceled Return value about cancel button
150 /// @param[in] noLabel [opt] label to put on the no button
151 /// @param[in] yesLabel [opt] label to put on the yes button
152 /// @return Returns True if 'Yes' was pressed, else False
153 ///
154 ///
155 ///-------------------------------------------------------------------------
156 ///
157 /// **Example:**
158 /// ~~~~~~~~~~~~~{.cpp}
159 /// #include <kodi/gui/dialogs/YesNo.h>
160 ///
161 /// bool canceled;
162 /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput(
163 /// "Yes / No test call", // The Header
164 /// "You has opened Yes / No dialog for test",
165 /// "",
166 /// "Is this OK for you?",
167 /// canceled, // return value about cancel button
168 /// "Not really", // No label, is optional and if empty "No"
169 /// "Ohhh yes"); // Yes label, also optional and if empty "Yes"
170 /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n",
171 /// ret ? "yes" : "no",
172 /// canceled ? "canceled" : "not canceled");
173 /// ~~~~~~~~~~~~~
174 ///
175 inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1,
176 const std::string& line2, bool& canceled, const std::string& noLabel = "",
177 const std::string& yesLabel = "")
178 {
179 using namespace ::kodi::addon;
180 return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase,
181 heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(),
182 &canceled, noLabel.c_str(), yesLabel.c_str());
183 }
184 //--------------------------------------------------------------------------
185 };
186 /// @}
187
188} /* namespace dialogs */
189} /* namespace gui */
190} /* namespace kodi */