summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/AddonCallbacksGUI.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2015-03-04 00:23:39 +0100
committermanuel <manuel@mausz.at>2015-03-04 00:23:39 +0100
commit9d11b08ad61b1f0d6d7023ce403285d8662efaed (patch)
tree5bc0c947d9e10d3e8c9dc1e6b26f3d6599f0cea1 /xbmc/addons/AddonCallbacksGUI.cpp
parentc159d9f91f1573901868100a9464527a5a71575b (diff)
downloadkodi-pvr-build-9d11b08ad61b1f0d6d7023ce403285d8662efaed.tar.gz
kodi-pvr-build-9d11b08ad61b1f0d6d7023ce403285d8662efaed.tar.bz2
kodi-pvr-build-9d11b08ad61b1f0d6d7023ce403285d8662efaed.zip
sync with upstream
Diffstat (limited to 'xbmc/addons/AddonCallbacksGUI.cpp')
-rw-r--r--xbmc/addons/AddonCallbacksGUI.cpp2281
1 files changed, 0 insertions, 2281 deletions
diff --git a/xbmc/addons/AddonCallbacksGUI.cpp b/xbmc/addons/AddonCallbacksGUI.cpp
deleted file mode 100644
index 3069039..0000000
--- a/xbmc/addons/AddonCallbacksGUI.cpp
+++ /dev/null
@@ -1,2281 +0,0 @@
1/*
2 * Copyright (C) 2012-2013 Team XBMC
3 * http://xbmc.org
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include "Application.h"
22#include "ApplicationMessenger.h"
23#include "Addon.h"
24#include "AddonCallbacksGUI.h"
25#include "utils/log.h"
26#include "Skin.h"
27#include "FileItem.h"
28#include "filesystem/File.h"
29#include "utils/URIUtils.h"
30#include "utils/TimeUtils.h"
31#include "utils/StringUtils.h"
32#include "guilib/GUIWindowManager.h"
33#include "input/Key.h"
34#include "guilib/TextureManager.h"
35#include "guilib/GUISpinControlEx.h"
36#include "guilib/GUIRadioButtonControl.h"
37#include "guilib/GUISettingsSliderControl.h"
38#include "guilib/GUIEditControl.h"
39#include "guilib/GUIProgressControl.h"
40#include "guilib/GUIRenderingControl.h"
41#include "guilib/GUIKeyboardFactory.h"
42#include "dialogs/GUIDialogNumeric.h"
43#include "dialogs/GUIDialogOK.h"
44#include "dialogs/GUIDialogYesNo.h"
45#include "dialogs/GUIDialogFileBrowser.h"
46#include "dialogs/GUIDialogTextViewer.h"
47#include "dialogs/GUIDialogSelect.h"
48
49#define CONTROL_BTNVIEWASICONS 2
50#define CONTROL_BTNSORTBY 3
51#define CONTROL_BTNSORTASC 4
52#define CONTROL_LABELFILES 12
53
54using namespace std;
55
56namespace ADDON
57{
58
59static int iXBMCGUILockRef = 0;
60
61CAddonCallbacksGUI::CAddonCallbacksGUI(CAddon* addon)
62{
63 m_addon = addon;
64 m_callbacks = new CB_GUILib;
65
66 /* GUI Helper functions */
67 m_callbacks->Lock = CAddonCallbacksGUI::Lock;
68 m_callbacks->Unlock = CAddonCallbacksGUI::Unlock;
69 m_callbacks->GetScreenHeight = CAddonCallbacksGUI::GetScreenHeight;
70 m_callbacks->GetScreenWidth = CAddonCallbacksGUI::GetScreenWidth;
71 m_callbacks->GetVideoResolution = CAddonCallbacksGUI::GetVideoResolution;
72 m_callbacks->Window_New = CAddonCallbacksGUI::Window_New;
73 m_callbacks->Window_Delete = CAddonCallbacksGUI::Window_Delete;
74 m_callbacks->Window_SetCallbacks = CAddonCallbacksGUI::Window_SetCallbacks;
75 m_callbacks->Window_Show = CAddonCallbacksGUI::Window_Show;
76 m_callbacks->Window_Close = CAddonCallbacksGUI::Window_Close;
77 m_callbacks->Window_DoModal = CAddonCallbacksGUI::Window_DoModal;
78 m_callbacks->Window_SetFocusId = CAddonCallbacksGUI::Window_SetFocusId;
79 m_callbacks->Window_GetFocusId = CAddonCallbacksGUI::Window_GetFocusId;
80 m_callbacks->Window_SetCoordinateResolution = CAddonCallbacksGUI::Window_SetCoordinateResolution;
81 m_callbacks->Window_SetProperty = CAddonCallbacksGUI::Window_SetProperty;
82 m_callbacks->Window_SetPropertyInt = CAddonCallbacksGUI::Window_SetPropertyInt;
83 m_callbacks->Window_SetPropertyBool = CAddonCallbacksGUI::Window_SetPropertyBool;
84 m_callbacks->Window_SetPropertyDouble = CAddonCallbacksGUI::Window_SetPropertyDouble;
85 m_callbacks->Window_GetProperty = CAddonCallbacksGUI::Window_GetProperty;
86 m_callbacks->Window_GetPropertyInt = CAddonCallbacksGUI::Window_GetPropertyInt;
87 m_callbacks->Window_GetPropertyBool = CAddonCallbacksGUI::Window_GetPropertyBool;
88 m_callbacks->Window_GetPropertyDouble = CAddonCallbacksGUI::Window_GetPropertyDouble;
89 m_callbacks->Window_ClearProperties = CAddonCallbacksGUI::Window_ClearProperties;
90
91 m_callbacks->Window_GetListSize = CAddonCallbacksGUI::Window_GetListSize;
92 m_callbacks->Window_ClearList = CAddonCallbacksGUI::Window_ClearList;
93 m_callbacks->Window_AddItem = CAddonCallbacksGUI::Window_AddItem;
94 m_callbacks->Window_AddStringItem = CAddonCallbacksGUI::Window_AddStringItem;
95 m_callbacks->Window_RemoveItem = CAddonCallbacksGUI::Window_RemoveItem;
96 m_callbacks->Window_GetListItem = CAddonCallbacksGUI::Window_GetListItem;
97 m_callbacks->Window_SetCurrentListPosition = CAddonCallbacksGUI::Window_SetCurrentListPosition;
98 m_callbacks->Window_GetCurrentListPosition = CAddonCallbacksGUI::Window_GetCurrentListPosition;
99
100 m_callbacks->Window_GetControl_Spin = CAddonCallbacksGUI::Window_GetControl_Spin;
101 m_callbacks->Window_GetControl_Button = CAddonCallbacksGUI::Window_GetControl_Button;
102 m_callbacks->Window_GetControl_RadioButton = CAddonCallbacksGUI::Window_GetControl_RadioButton;
103 m_callbacks->Window_GetControl_Edit = CAddonCallbacksGUI::Window_GetControl_Edit;
104 m_callbacks->Window_GetControl_Progress = CAddonCallbacksGUI::Window_GetControl_Progress;
105 m_callbacks->Window_GetControl_RenderAddon = CAddonCallbacksGUI::Window_GetControl_RenderAddon;
106 m_callbacks->Window_GetControl_Slider = CAddonCallbacksGUI::Window_GetControl_Slider;
107 m_callbacks->Window_GetControl_SettingsSlider= CAddonCallbacksGUI::Window_GetControl_SettingsSlider;
108
109 m_callbacks->Window_SetControlLabel = CAddonCallbacksGUI::Window_SetControlLabel;
110 m_callbacks->Window_MarkDirtyRegion = CAddonCallbacksGUI::Window_MarkDirtyRegion;
111
112 m_callbacks->Control_Spin_SetVisible = CAddonCallbacksGUI::Control_Spin_SetVisible;
113 m_callbacks->Control_Spin_SetText = CAddonCallbacksGUI::Control_Spin_SetText;
114 m_callbacks->Control_Spin_Clear = CAddonCallbacksGUI::Control_Spin_Clear;
115 m_callbacks->Control_Spin_AddLabel = CAddonCallbacksGUI::Control_Spin_AddLabel;
116 m_callbacks->Control_Spin_GetValue = CAddonCallbacksGUI::Control_Spin_GetValue;
117 m_callbacks->Control_Spin_SetValue = CAddonCallbacksGUI::Control_Spin_SetValue;
118
119 m_callbacks->Control_RadioButton_SetVisible = CAddonCallbacksGUI::Control_RadioButton_SetVisible;
120 m_callbacks->Control_RadioButton_SetText = CAddonCallbacksGUI::Control_RadioButton_SetText;
121 m_callbacks->Control_RadioButton_SetSelected= CAddonCallbacksGUI::Control_RadioButton_SetSelected;
122 m_callbacks->Control_RadioButton_IsSelected = CAddonCallbacksGUI::Control_RadioButton_IsSelected;
123
124 m_callbacks->Control_Progress_SetPercentage = CAddonCallbacksGUI::Control_Progress_SetPercentage;
125 m_callbacks->Control_Progress_GetPercentage = CAddonCallbacksGUI::Control_Progress_GetPercentage;
126 m_callbacks->Control_Progress_SetInfo = CAddonCallbacksGUI::Control_Progress_SetInfo;
127 m_callbacks->Control_Progress_GetInfo = CAddonCallbacksGUI::Control_Progress_GetInfo;
128 m_callbacks->Control_Progress_GetDescription= CAddonCallbacksGUI::Control_Progress_GetDescription;
129
130 m_callbacks->ListItem_Create = CAddonCallbacksGUI::ListItem_Create;
131 m_callbacks->ListItem_GetLabel = CAddonCallbacksGUI::ListItem_GetLabel;
132 m_callbacks->ListItem_SetLabel = CAddonCallbacksGUI::ListItem_SetLabel;
133 m_callbacks->ListItem_GetLabel2 = CAddonCallbacksGUI::ListItem_GetLabel2;
134 m_callbacks->ListItem_SetLabel2 = CAddonCallbacksGUI::ListItem_SetLabel2;
135 m_callbacks->ListItem_SetIconImage = CAddonCallbacksGUI::ListItem_SetIconImage;
136 m_callbacks->ListItem_SetThumbnailImage = CAddonCallbacksGUI::ListItem_SetThumbnailImage;
137 m_callbacks->ListItem_SetInfo = CAddonCallbacksGUI::ListItem_SetInfo;
138 m_callbacks->ListItem_SetProperty = CAddonCallbacksGUI::ListItem_SetProperty;
139 m_callbacks->ListItem_GetProperty = CAddonCallbacksGUI::ListItem_GetProperty;
140 m_callbacks->ListItem_SetPath = CAddonCallbacksGUI::ListItem_SetPath;
141
142 m_callbacks->RenderAddon_SetCallbacks = CAddonCallbacksGUI::RenderAddon_SetCallbacks;
143 m_callbacks->RenderAddon_Delete = CAddonCallbacksGUI::RenderAddon_Delete;
144
145 m_callbacks->Control_Slider_SetVisible = CAddonCallbacksGUI::Control_Slider_SetVisible;
146 m_callbacks->Control_Slider_GetDescription = CAddonCallbacksGUI::Control_Slider_GetDescription;
147 m_callbacks->Control_Slider_SetIntRange = CAddonCallbacksGUI::Control_Slider_SetIntRange;
148 m_callbacks->Control_Slider_SetIntValue = CAddonCallbacksGUI::Control_Slider_SetIntValue;
149 m_callbacks->Control_Slider_GetIntValue = CAddonCallbacksGUI::Control_Slider_GetIntValue;
150 m_callbacks->Control_Slider_SetIntInterval = CAddonCallbacksGUI::Control_Slider_SetIntInterval;
151 m_callbacks->Control_Slider_SetPercentage = CAddonCallbacksGUI::Control_Slider_SetPercentage;
152 m_callbacks->Control_Slider_GetPercentage = CAddonCallbacksGUI::Control_Slider_GetPercentage;
153 m_callbacks->Control_Slider_SetFloatRange = CAddonCallbacksGUI::Control_Slider_SetFloatRange;
154 m_callbacks->Control_Slider_SetFloatValue = CAddonCallbacksGUI::Control_Slider_SetFloatValue;
155 m_callbacks->Control_Slider_GetFloatValue = CAddonCallbacksGUI::Control_Slider_GetFloatValue;
156 m_callbacks->Control_Slider_SetFloatInterval = CAddonCallbacksGUI::Control_Slider_SetFloatInterval;
157
158 m_callbacks->Control_SettingsSlider_SetVisible = CAddonCallbacksGUI::Control_SettingsSlider_SetVisible;
159 m_callbacks->Control_SettingsSlider_SetText = CAddonCallbacksGUI::Control_SettingsSlider_SetText;
160 m_callbacks->Control_SettingsSlider_GetDescription = CAddonCallbacksGUI::Control_SettingsSlider_GetDescription;
161 m_callbacks->Control_SettingsSlider_SetIntRange = CAddonCallbacksGUI::Control_SettingsSlider_SetIntRange;
162 m_callbacks->Control_SettingsSlider_SetIntValue = CAddonCallbacksGUI::Control_SettingsSlider_SetIntValue;
163 m_callbacks->Control_SettingsSlider_GetIntValue = CAddonCallbacksGUI::Control_SettingsSlider_GetIntValue;
164 m_callbacks->Control_SettingsSlider_SetIntInterval = CAddonCallbacksGUI::Control_SettingsSlider_SetIntInterval;
165 m_callbacks->Control_SettingsSlider_SetPercentage = CAddonCallbacksGUI::Control_SettingsSlider_SetPercentage;
166 m_callbacks->Control_SettingsSlider_GetPercentage = CAddonCallbacksGUI::Control_SettingsSlider_GetPercentage;
167 m_callbacks->Control_SettingsSlider_SetFloatRange = CAddonCallbacksGUI::Control_SettingsSlider_SetFloatRange;
168 m_callbacks->Control_SettingsSlider_SetFloatValue = CAddonCallbacksGUI::Control_SettingsSlider_SetFloatValue;
169 m_callbacks->Control_SettingsSlider_GetFloatValue = CAddonCallbacksGUI::Control_SettingsSlider_GetFloatValue;
170 m_callbacks->Control_SettingsSlider_SetFloatInterval = CAddonCallbacksGUI::Control_SettingsSlider_SetFloatInterval;
171
172 m_callbacks->Dialog_Keyboard_ShowAndGetInputWithHead = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetInputWithHead;
173 m_callbacks->Dialog_Keyboard_ShowAndGetInput = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetInput;
174 m_callbacks->Dialog_Keyboard_ShowAndGetNewPasswordWithHead = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetNewPasswordWithHead;
175 m_callbacks->Dialog_Keyboard_ShowAndGetNewPassword = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetNewPassword;
176 m_callbacks->Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead;
177 m_callbacks->Dialog_Keyboard_ShowAndVerifyNewPassword = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndVerifyNewPassword;
178 m_callbacks->Dialog_Keyboard_ShowAndVerifyPassword = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndVerifyPassword;
179 m_callbacks->Dialog_Keyboard_ShowAndGetFilter = CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetFilter;
180 m_callbacks->Dialog_Keyboard_SendTextToActiveKeyboard = CAddonCallbacksGUI::Dialog_Keyboard_SendTextToActiveKeyboard;
181 m_callbacks->Dialog_Keyboard_isKeyboardActivated = CAddonCallbacksGUI::Dialog_Keyboard_isKeyboardActivated;
182
183 m_callbacks->Dialog_Numeric_ShowAndVerifyNewPassword = CAddonCallbacksGUI::Dialog_Numeric_ShowAndVerifyNewPassword;
184 m_callbacks->Dialog_Numeric_ShowAndVerifyPassword = CAddonCallbacksGUI::Dialog_Numeric_ShowAndVerifyPassword;
185 m_callbacks->Dialog_Numeric_ShowAndVerifyInput = CAddonCallbacksGUI::Dialog_Numeric_ShowAndVerifyInput;
186 m_callbacks->Dialog_Numeric_ShowAndGetTime = CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetTime;
187 m_callbacks->Dialog_Numeric_ShowAndGetDate = CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetDate;
188 m_callbacks->Dialog_Numeric_ShowAndGetIPAddress = CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetIPAddress;
189 m_callbacks->Dialog_Numeric_ShowAndGetNumber = CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetNumber;
190 m_callbacks->Dialog_Numeric_ShowAndGetSeconds = CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetSeconds;
191
192 m_callbacks->Dialog_FileBrowser_ShowAndGetFile = CAddonCallbacksGUI::Dialog_FileBrowser_ShowAndGetFile;
193
194 m_callbacks->Dialog_OK_ShowAndGetInputSingleText = CAddonCallbacksGUI::Dialog_OK_ShowAndGetInputSingleText;
195 m_callbacks->Dialog_OK_ShowAndGetInputLineText = CAddonCallbacksGUI::Dialog_OK_ShowAndGetInputLineText;
196
197 m_callbacks->Dialog_YesNo_ShowAndGetInputSingleText = CAddonCallbacksGUI::Dialog_YesNo_ShowAndGetInputSingleText;
198 m_callbacks->Dialog_YesNo_ShowAndGetInputLineText = CAddonCallbacksGUI::Dialog_YesNo_ShowAndGetInputLineText;
199 m_callbacks->Dialog_YesNo_ShowAndGetInputLineButtonText = CAddonCallbacksGUI::Dialog_YesNo_ShowAndGetInputLineButtonText;
200
201 m_callbacks->Dialog_TextViewer = CAddonCallbacksGUI::Dialog_TextViewer;
202
203 m_callbacks->Dialog_Select = CAddonCallbacksGUI::Dialog_Select;
204}
205
206CAddonCallbacksGUI::~CAddonCallbacksGUI()
207{
208 delete m_callbacks;
209}
210
211void CAddonCallbacksGUI::Lock()
212{
213 if (iXBMCGUILockRef == 0) g_graphicsContext.Lock();
214 iXBMCGUILockRef++;
215}
216
217void CAddonCallbacksGUI::Unlock()
218{
219 if (iXBMCGUILockRef > 0)
220 {
221 iXBMCGUILockRef--;
222 if (iXBMCGUILockRef == 0) g_graphicsContext.Unlock();
223 }
224}
225
226int CAddonCallbacksGUI::GetScreenHeight()
227{
228 return g_graphicsContext.GetHeight();
229}
230
231int CAddonCallbacksGUI::GetScreenWidth()
232{
233 return g_graphicsContext.GetWidth();
234}
235
236int CAddonCallbacksGUI::GetVideoResolution()
237{
238 return (int)g_graphicsContext.GetVideoResolution();
239}
240
241GUIHANDLE CAddonCallbacksGUI::Window_New(void *addonData, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog)
242{
243 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
244 if (!helper)
245 return NULL;
246
247 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
248
249 RESOLUTION_INFO res;
250 std::string strSkinPath;
251 if (!forceFallback)
252 {
253 /* Check to see if the XML file exists in current skin. If not use
254 fallback path to find a skin for the addon */
255 strSkinPath = g_SkinInfo->GetSkinPath(xmlFilename, &res);
256
257 if (!XFILE::CFile::Exists(strSkinPath))
258 {
259 /* Check for the matching folder for the skin in the fallback skins folder */
260 std::string basePath = URIUtils::AddFileToFolder(guiHelper->m_addon->Path(), "resources");
261 basePath = URIUtils::AddFileToFolder(basePath, "skins");
262 basePath = URIUtils::AddFileToFolder(basePath, URIUtils::GetFileName(g_SkinInfo->Path()));
263 strSkinPath = g_SkinInfo->GetSkinPath(xmlFilename, &res, basePath);
264 if (!XFILE::CFile::Exists(strSkinPath))
265 {
266 /* Finally fallback to the DefaultSkin as it didn't exist in either the
267 XBMC Skin folder or the fallback skin folder */
268 forceFallback = true;
269 }
270 }
271 }
272
273 if (forceFallback)
274 {
275 //FIXME make this static method of current skin?
276 std::string str("none");
277 AddonProps props(str, ADDON_SKIN, str, str);
278 std::string basePath = URIUtils::AddFileToFolder(guiHelper->m_addon->Path(), "resources");
279 basePath = URIUtils::AddFileToFolder(basePath, "skins");
280 basePath = URIUtils::AddFileToFolder(basePath, defaultSkin);
281 props.path = basePath;
282
283 CSkinInfo skinInfo(props);
284 skinInfo.Start();
285 strSkinPath = skinInfo.GetSkinPath(xmlFilename, &res, basePath);
286
287 if (!XFILE::CFile::Exists(strSkinPath))
288 {
289 CLog::Log(LOGERROR, "Window_New: %s/%s - XML File '%s' for Window is missing, contact Developer '%s' of this AddOn", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str(), strSkinPath.c_str(), guiHelper->m_addon->Author().c_str());
290 return NULL;
291 }
292 }
293 // window id's 14000 - 14100 are reserved for addons
294 // get first window id that is not in use
295 int id = WINDOW_ADDON_START;
296 // if window 14099 is in use it means addon can't create more windows
297 Lock();
298 if (g_windowManager.GetWindow(WINDOW_ADDON_END))
299 {
300 Unlock();
301 CLog::Log(LOGERROR, "Window_New: %s/%s - maximum number of windows reached", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
302 return NULL;
303 }
304 while(id < WINDOW_ADDON_END && g_windowManager.GetWindow(id) != NULL) id++;
305 Unlock();
306
307 CGUIWindow *window;
308 if (!asDialog)
309 window = new CGUIAddonWindow(id, strSkinPath, guiHelper->m_addon);
310 else
311 window = new CGUIAddonWindowDialog(id, strSkinPath, guiHelper->m_addon);
312
313 Lock();
314 g_windowManager.Add(window);
315 Unlock();
316
317 window->SetCoordsRes(res);
318
319 return window;
320}
321
322void CAddonCallbacksGUI::Window_Delete(void *addonData, GUIHANDLE handle)
323{
324 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
325 if (!helper)
326 return;
327
328 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
329
330 if (!handle)
331 {
332 CLog::Log(LOGERROR, "Window_Show: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
333 return;
334 }
335
336 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
337 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
338 if (!pWindow)
339 return;
340
341 Lock();
342 // first change to an existing window
343 if (g_windowManager.GetActiveWindow() == pAddonWindow->m_iWindowId && !g_application.m_bStop)
344 {
345 if(g_windowManager.GetWindow(pAddonWindow->m_iOldWindowId))
346 g_windowManager.ActivateWindow(pAddonWindow->m_iOldWindowId);
347 else // old window does not exist anymore, switch to home
348 g_windowManager.ActivateWindow(WINDOW_HOME);
349 }
350 // Free any window properties
351 pAddonWindow->ClearProperties();
352 // free the window's resources and unload it (free all guicontrols)
353 pAddonWindow->FreeResources(true);
354
355 g_windowManager.Remove(pAddonWindow->GetID());
356 delete pAddonWindow;
357 Unlock();
358}
359
360void CAddonCallbacksGUI::Window_SetCallbacks(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*initCB)(GUIHANDLE), bool (*clickCB)(GUIHANDLE, int), bool (*focusCB)(GUIHANDLE, int), bool (*onActionCB)(GUIHANDLE handle, int))
361{
362 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
363 if (!helper || !handle)
364 return;
365
366 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
367
368 Lock();
369 pAddonWindow->m_clientHandle = clienthandle;
370 pAddonWindow->CBOnInit = initCB;
371 pAddonWindow->CBOnClick = clickCB;
372 pAddonWindow->CBOnFocus = focusCB;
373 pAddonWindow->CBOnAction = onActionCB;
374 Unlock();
375}
376
377bool CAddonCallbacksGUI::Window_Show(void *addonData, GUIHANDLE handle)
378{
379 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
380 if (!helper)
381 return false;
382
383 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
384
385 if (!handle)
386 {
387 CLog::Log(LOGERROR, "Window_Show: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
388 return false;
389 }
390
391 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
392 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
393 if (!pWindow)
394 return false;
395
396 if (pAddonWindow->m_iOldWindowId != pAddonWindow->m_iWindowId && pAddonWindow->m_iWindowId != g_windowManager.GetActiveWindow())
397 pAddonWindow->m_iOldWindowId = g_windowManager.GetActiveWindow();
398
399 Lock();
400 if (pAddonWindow->IsDialog())
401 ((CGUIAddonWindowDialog*)pAddonWindow)->Show();
402 else
403 g_windowManager.ActivateWindow(pAddonWindow->m_iWindowId);
404 Unlock();
405
406 return true;
407}
408
409bool CAddonCallbacksGUI::Window_Close(void *addonData, GUIHANDLE handle)
410{
411 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
412 if (!helper)
413 return false;
414
415 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
416
417 if (!handle)
418 {
419 CLog::Log(LOGERROR, "Window_Close: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
420 return false;
421 }
422
423 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
424 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
425 if (!pWindow)
426 return false;
427
428 pAddonWindow->m_bModal = false;
429 if (pAddonWindow->IsDialog())
430 ((CGUIAddonWindowDialog*)pAddonWindow)->PulseActionEvent();
431 else
432 ((CGUIAddonWindow*)pAddonWindow)->PulseActionEvent();
433
434 Lock();
435 // if it's a dialog, we have to close it a bit different
436 if (pAddonWindow->IsDialog())
437 ((CGUIAddonWindowDialog*)pAddonWindow)->Show(false);
438 else
439 g_windowManager.ActivateWindow(pAddonWindow->m_iOldWindowId);
440 pAddonWindow->m_iOldWindowId = 0;
441
442 Unlock();
443
444 return true;
445}
446
447bool CAddonCallbacksGUI::Window_DoModal(void *addonData, GUIHANDLE handle)
448{
449 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
450 if (!helper)
451 return false;
452
453 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
454
455 if (!handle)
456 {
457 CLog::Log(LOGERROR, "Window_DoModal: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
458 return false;
459 }
460
461 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
462 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
463 if (!pWindow)
464 return false;
465
466 pAddonWindow->m_bModal = true;
467
468 if (pAddonWindow->m_iWindowId != g_windowManager.GetActiveWindow())
469 Window_Show(addonData, handle);
470
471 return true;
472}
473
474bool CAddonCallbacksGUI::Window_SetFocusId(void *addonData, GUIHANDLE handle, int iControlId)
475{
476 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
477 if (!helper)
478 return false;
479
480 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
481
482 if (!handle)
483 {
484 CLog::Log(LOGERROR, "Window_SetFocusId: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
485 return false;
486 }
487
488 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
489 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
490 if (!pWindow)
491 return false;
492
493 if(!pWindow->GetControl(iControlId))
494 {
495 CLog::Log(LOGERROR, "Window_SetFocusId: %s/%s - Control does not exist in window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
496 return false;
497 }
498
499 Lock();
500 CGUIMessage msg = CGUIMessage(GUI_MSG_SETFOCUS, pAddonWindow->m_iWindowId, iControlId);
501 pWindow->OnMessage(msg);
502 Unlock();
503
504 return true;
505}
506
507int CAddonCallbacksGUI::Window_GetFocusId(void *addonData, GUIHANDLE handle)
508{
509 int iControlId = -1;
510
511 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
512 if (!helper)
513 return iControlId;
514
515 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
516
517 if (!handle)
518 {
519 CLog::Log(LOGERROR, "Window_GetFocusId: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
520 return iControlId;
521 }
522
523 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
524 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
525 if (!pWindow)
526 return iControlId;
527
528 Lock();
529 iControlId = pWindow->GetFocusedControlID();
530 Unlock();
531
532 if (iControlId == -1)
533 {
534 CLog::Log(LOGERROR, "Window_GetFocusId: %s/%s - No control in this window has focus", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
535 return iControlId;
536 }
537
538 return iControlId;
539}
540
541bool CAddonCallbacksGUI::Window_SetCoordinateResolution(void *addonData, GUIHANDLE handle, int res)
542{
543 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
544 if (!helper)
545 return false;
546
547 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
548
549 if (!handle)
550 {
551 CLog::Log(LOGERROR, "SetCoordinateResolution: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
552 return false;
553 }
554
555 if (res < RES_HDTV_1080i || res > RES_AUTORES)
556 {
557 CLog::Log(LOGERROR, "SetCoordinateResolution: %s/%s - Invalid resolution", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
558 return false;
559 }
560
561 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
562 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
563 if (!pWindow)
564 return false;
565
566 pWindow->SetCoordsRes((RESOLUTION)res);
567
568 return true;
569}
570
571void CAddonCallbacksGUI::Window_SetProperty(void *addonData, GUIHANDLE handle, const char *key, const char *value)
572{
573 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
574 if (!helper)
575 return;
576
577 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
578
579 if (!handle || !key || !value)
580 {
581 CLog::Log(LOGERROR, "Window_SetProperty: %s/%s - No Window or NULL key or value", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
582 return;
583 }
584
585 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
586 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
587 if (!pWindow)
588 return;
589
590 std::string lowerKey = key;
591 StringUtils::ToLower(lowerKey);
592
593 Lock();
594 pWindow->SetProperty(lowerKey, value);
595 Unlock();
596}
597
598void CAddonCallbacksGUI::Window_SetPropertyInt(void *addonData, GUIHANDLE handle, const char *key, int value)
599{
600 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
601 if (!helper)
602 return;
603
604 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
605
606 if (!handle || !key)
607 {
608 CLog::Log(LOGERROR, "Window_SetPropertyInt: %s/%s - No Window or NULL key", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
609 return;
610 }
611
612 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
613 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
614 if (!pWindow)
615 return;
616
617 std::string lowerKey = key;
618 StringUtils::ToLower(lowerKey);
619
620 Lock();
621 pWindow->SetProperty(lowerKey, value);
622 Unlock();
623}
624
625void CAddonCallbacksGUI::Window_SetPropertyBool(void *addonData, GUIHANDLE handle, const char *key, bool value)
626{
627 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
628 if (!helper)
629 return;
630
631 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
632
633 if (!handle || !key)
634 {
635 CLog::Log(LOGERROR, "Window_SetPropertyBool: %s/%s - No Window or NULL key", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
636 return;
637 }
638
639 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
640 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
641 if (!pWindow)
642 return;
643
644 std::string lowerKey = key;
645 StringUtils::ToLower(lowerKey);
646
647 Lock();
648 pWindow->SetProperty(lowerKey, value);
649 Unlock();
650}
651
652void CAddonCallbacksGUI::Window_SetPropertyDouble(void *addonData, GUIHANDLE handle, const char *key, double value)
653{
654 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
655 if (!helper)
656 return;
657
658 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
659
660 if (!handle || !key)
661 {
662 CLog::Log(LOGERROR, "Window_SetPropertyDouble: %s/%s - No Window or NULL key", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
663 return;
664 }
665
666 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
667 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
668 if (!pWindow)
669 return;
670
671 std::string lowerKey = key;
672 StringUtils::ToLower(lowerKey);
673
674 Lock();
675 pWindow->SetProperty(lowerKey, value);
676 Unlock();
677}
678
679const char* CAddonCallbacksGUI::Window_GetProperty(void *addonData, GUIHANDLE handle, const char *key)
680{
681 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
682 if (!helper)
683 return NULL;
684
685 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
686
687 if (!handle || !key)
688 {
689 CLog::Log(LOGERROR, "Window_GetProperty: %s/%s - No Window or NULL key", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
690 return NULL;
691 }
692
693 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
694 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
695 if (!pWindow)
696 return NULL;
697
698 std::string lowerKey = key;
699 StringUtils::ToLower(lowerKey);
700
701 Lock();
702 string value = pWindow->GetProperty(lowerKey).asString();
703 Unlock();
704
705 return strdup(value.c_str());
706}
707
708int CAddonCallbacksGUI::Window_GetPropertyInt(void *addonData, GUIHANDLE handle, const char *key)
709{
710 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
711 if (!helper)
712 return -1;
713
714 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
715
716 if (!handle || !key)
717 {
718 CLog::Log(LOGERROR, "Window_GetPropertyInt: %s/%s - No Window or NULL key", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
719 return -1;
720 }
721
722 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
723 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
724 if (!pWindow)
725 return -1;
726
727 std::string lowerKey = key;
728 StringUtils::ToLower(lowerKey);
729
730 Lock();
731 int value = (int)pWindow->GetProperty(lowerKey).asInteger();
732 Unlock();
733
734 return value;
735}
736
737bool CAddonCallbacksGUI::Window_GetPropertyBool(void *addonData, GUIHANDLE handle, const char *key)
738{
739 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
740 if (!helper)
741 return false;
742
743 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
744
745 if (!handle || !key)
746 {
747 CLog::Log(LOGERROR, "Window_GetPropertyBool: %s/%s - No Window or NULL key", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
748 return false;
749 }
750
751 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
752 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
753 if (!pWindow)
754 return false;
755
756 std::string lowerKey = key;
757 StringUtils::ToLower(lowerKey);
758
759 Lock();
760 bool value = pWindow->GetProperty(lowerKey).asBoolean();
761 Unlock();
762
763 return value;
764}
765
766double CAddonCallbacksGUI::Window_GetPropertyDouble(void *addonData, GUIHANDLE handle, const char *key)
767{
768 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
769 if (!helper)
770 return 0.0;
771
772 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
773
774 if (!handle || !key)
775 {
776 CLog::Log(LOGERROR, "Window_GetPropertyDouble: %s/%s - No Window or NULL key", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
777 return 0.0;
778 }
779
780 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
781 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
782 if (!pWindow)
783 return 0.0;
784
785 std::string lowerKey = key;
786 StringUtils::ToLower(lowerKey);
787
788 Lock();
789 double value = pWindow->GetProperty(lowerKey).asDouble();
790 Unlock();
791
792 return value;
793}
794
795void CAddonCallbacksGUI::Window_ClearProperties(void *addonData, GUIHANDLE handle)
796{
797 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
798 if (!helper)
799 return;
800
801 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
802
803 if (!handle)
804 {
805 CLog::Log(LOGERROR, "Window_ClearProperties: %s/%s - No Window", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
806 return;
807 }
808
809 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
810 CGUIWindow *pWindow = (CGUIWindow*)g_windowManager.GetWindow(pAddonWindow->m_iWindowId);
811 if (!pWindow)
812 return;
813
814 Lock();
815 pWindow->ClearProperties();
816 Unlock();
817}
818
819int CAddonCallbacksGUI::Window_GetListSize(void *addonData, GUIHANDLE handle)
820{
821 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
822 if (!helper || !handle)
823 return -1;
824
825 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
826
827 Lock();
828 int listSize = pAddonWindow->GetListSize();
829 Unlock();
830
831 return listSize;
832}
833
834void CAddonCallbacksGUI::Window_ClearList(void *addonData, GUIHANDLE handle)
835{
836 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
837 if (!helper || !handle)
838 return;
839
840 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
841
842 Lock();
843 pAddonWindow->ClearList();
844 Unlock();
845
846 return;
847}
848
849GUIHANDLE CAddonCallbacksGUI::Window_AddItem(void *addonData, GUIHANDLE handle, GUIHANDLE item, int itemPosition)
850{
851 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
852 if (!helper || !handle || !item)
853 return NULL;
854
855 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
856 CFileItemPtr pItem((CFileItem*)item);
857 Lock();
858 pAddonWindow->AddItem(pItem, itemPosition);
859 Unlock();
860
861 return item;
862}
863
864GUIHANDLE CAddonCallbacksGUI::Window_AddStringItem(void *addonData, GUIHANDLE handle, const char *itemName, int itemPosition)
865{
866 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
867 if (!helper || !handle || !itemName)
868 return NULL;
869
870 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
871 CFileItemPtr item(new CFileItem(itemName));
872 Lock();
873 pAddonWindow->AddItem(item, itemPosition);
874 Unlock();
875
876 return item.get();
877}
878
879void CAddonCallbacksGUI::Window_RemoveItem(void *addonData, GUIHANDLE handle, int itemPosition)
880{
881 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
882 if (!helper || !handle)
883 return;
884
885 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
886
887 Lock();
888 pAddonWindow->RemoveItem(itemPosition);
889 Unlock();
890
891 return;
892}
893
894GUIHANDLE CAddonCallbacksGUI::Window_GetListItem(void *addonData, GUIHANDLE handle, int listPos)
895{
896 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
897 if (!helper || !handle)
898 return NULL;
899
900 CAddonCallbacksGUI* guiHelper = helper->GetHelperGUI();
901 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
902
903 Lock();
904 CFileItemPtr fi = pAddonWindow->GetListItem(listPos);
905 if (fi == NULL)
906 {
907 Unlock();
908 CLog::Log(LOGERROR, "Window_GetListItem: %s/%s - Index out of range", TranslateType(guiHelper->m_addon->Type()).c_str(), guiHelper->m_addon->Name().c_str());
909 return NULL;
910 }
911 Unlock();
912
913 return fi.get();
914}
915
916void CAddonCallbacksGUI::Window_SetCurrentListPosition(void *addonData, GUIHANDLE handle, int listPos)
917{
918 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
919 if (!helper || !handle)
920 return;
921
922 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
923
924 Lock();
925 pAddonWindow->SetCurrentListPosition(listPos);
926 Unlock();
927
928 return;
929}
930
931int CAddonCallbacksGUI::Window_GetCurrentListPosition(void *addonData, GUIHANDLE handle)
932{
933 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
934 if (!helper || !handle)
935 return -1;
936
937 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
938
939 Lock();
940 int listPos = pAddonWindow->GetCurrentListPosition();
941 Unlock();
942
943 return listPos;
944}
945
946GUIHANDLE CAddonCallbacksGUI::Window_GetControl_Spin(void *addonData, GUIHANDLE handle, int controlId)
947{
948 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
949 if (!helper || !handle)
950 return NULL;
951
952 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
953 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
954 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_SPINEX)
955 return NULL;
956
957 return pGUIControl;
958}
959
960GUIHANDLE CAddonCallbacksGUI::Window_GetControl_Button(void *addonData, GUIHANDLE handle, int controlId)
961{
962 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
963 if (!helper || !handle)
964 return NULL;
965
966 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
967 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
968 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_BUTTON)
969 return NULL;
970
971 return pGUIControl;
972}
973
974GUIHANDLE CAddonCallbacksGUI::Window_GetControl_RadioButton(void *addonData, GUIHANDLE handle, int controlId)
975{
976 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
977 if (!helper || !handle)
978 return NULL;
979
980 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
981 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
982 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_RADIO)
983 return NULL;
984
985 return pGUIControl;
986}
987
988GUIHANDLE CAddonCallbacksGUI::Window_GetControl_Edit(void *addonData, GUIHANDLE handle, int controlId)
989{
990 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
991 if (!helper || !handle)
992 return NULL;
993
994 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
995 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
996 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_EDIT)
997 return NULL;
998
999 return pGUIControl;
1000}
1001
1002GUIHANDLE CAddonCallbacksGUI::Window_GetControl_Progress(void *addonData, GUIHANDLE handle, int controlId)
1003{
1004 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1005 if (!helper || !handle)
1006 return NULL;
1007
1008 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
1009 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
1010 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_PROGRESS)
1011 return NULL;
1012
1013 return pGUIControl;
1014}
1015
1016GUIHANDLE CAddonCallbacksGUI::Window_GetControl_RenderAddon(void *addonData, GUIHANDLE handle, int controlId)
1017{
1018 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1019 if (!helper || !handle)
1020 return NULL;
1021
1022 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
1023 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
1024 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_RENDERADDON)
1025 return NULL;
1026
1027 CGUIAddonRenderingControl *pProxyControl;
1028 pProxyControl = new CGUIAddonRenderingControl((CGUIRenderingControl*)pGUIControl);
1029 return pProxyControl;
1030}
1031
1032void CAddonCallbacksGUI::Window_SetControlLabel(void *addonData, GUIHANDLE handle, int controlId, const char *label)
1033{
1034 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1035 if (!helper || !handle)
1036 return;
1037
1038 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
1039
1040 CGUIMessage msg(GUI_MSG_LABEL_SET, pAddonWindow->m_iWindowId, controlId);
1041 msg.SetLabel(label);
1042 pAddonWindow->OnMessage(msg);
1043}
1044
1045void CAddonCallbacksGUI::Window_MarkDirtyRegion(void *addonData, GUIHANDLE handle)
1046{
1047 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1048 if (!helper || !handle)
1049 return;
1050
1051 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
1052
1053 pAddonWindow->MarkDirtyRegion();
1054}
1055
1056void CAddonCallbacksGUI::Control_Spin_SetVisible(void *addonData, GUIHANDLE spinhandle, bool yesNo)
1057{
1058 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1059 if (!helper || !spinhandle)
1060 return;
1061
1062 CGUISpinControlEx *pSpin = (CGUISpinControlEx*)spinhandle;
1063 pSpin->SetVisible(yesNo);
1064}
1065
1066void CAddonCallbacksGUI::Control_Spin_SetText(void *addonData, GUIHANDLE spinhandle, const char *label)
1067{
1068 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1069 if (!helper || !spinhandle)
1070 return;
1071
1072 CGUISpinControlEx *pSpin = (CGUISpinControlEx*)spinhandle;
1073 pSpin->SetText(label);
1074}
1075
1076void CAddonCallbacksGUI::Control_Spin_Clear(void *addonData, GUIHANDLE spinhandle)
1077{
1078 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1079 if (!helper || !spinhandle)
1080 return;
1081
1082 CGUISpinControlEx *pSpin = (CGUISpinControlEx*)spinhandle;
1083 pSpin->Clear();
1084}
1085
1086void CAddonCallbacksGUI::Control_Spin_AddLabel(void *addonData, GUIHANDLE spinhandle, const char *label, int iValue)
1087{
1088 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1089 if (!helper || !spinhandle)
1090 return;
1091
1092 CGUISpinControlEx *pSpin = (CGUISpinControlEx*)spinhandle;
1093 pSpin->AddLabel(label, iValue);
1094}
1095
1096int CAddonCallbacksGUI::Control_Spin_GetValue(void *addonData, GUIHANDLE spinhandle)
1097{
1098 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1099 if (!helper || !spinhandle)
1100 return -1;
1101
1102 CGUISpinControlEx *pSpin = (CGUISpinControlEx*)spinhandle;
1103 return pSpin->GetValue();
1104}
1105
1106void CAddonCallbacksGUI::Control_Spin_SetValue(void *addonData, GUIHANDLE spinhandle, int iValue)
1107{
1108 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1109 if (!helper || !spinhandle)
1110 return;
1111
1112 CGUISpinControlEx *pSpin = (CGUISpinControlEx*)spinhandle;
1113 pSpin->SetValue(iValue);
1114}
1115
1116void CAddonCallbacksGUI::Control_RadioButton_SetVisible(void *addonData, GUIHANDLE handle, bool yesNo)
1117{
1118 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1119 if (!helper || !handle)
1120 return;
1121
1122 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl*)handle;
1123 pRadioButton->SetVisible(yesNo);
1124}
1125
1126void CAddonCallbacksGUI::Control_RadioButton_SetText(void *addonData, GUIHANDLE handle, const char *label)
1127{
1128 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1129 if (!helper || !handle)
1130 return;
1131
1132 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl*)handle;
1133 pRadioButton->SetLabel(label);
1134}
1135
1136void CAddonCallbacksGUI::Control_RadioButton_SetSelected(void *addonData, GUIHANDLE handle, bool yesNo)
1137{
1138 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1139 if (!helper || !handle)
1140 return;
1141
1142 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl*)handle;
1143 pRadioButton->SetSelected(yesNo);
1144}
1145
1146bool CAddonCallbacksGUI::Control_RadioButton_IsSelected(void *addonData, GUIHANDLE handle)
1147{
1148 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1149 if (!helper || !handle)
1150 return false;
1151
1152 CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl*)handle;
1153 return pRadioButton->IsSelected();
1154}
1155
1156void CAddonCallbacksGUI::Control_Progress_SetPercentage(void *addonData, GUIHANDLE handle, float fPercent)
1157{
1158 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1159 if (!helper || !handle)
1160 return;
1161
1162 CGUIProgressControl *pControl = (CGUIProgressControl*)handle;
1163 pControl->SetPercentage(fPercent);
1164}
1165
1166float CAddonCallbacksGUI::Control_Progress_GetPercentage(void *addonData, GUIHANDLE handle)
1167{
1168 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1169 if (!helper || !handle)
1170 return 0.0;
1171
1172 CGUIProgressControl *pControl = (CGUIProgressControl*)handle;
1173 return pControl->GetPercentage();
1174}
1175
1176void CAddonCallbacksGUI::Control_Progress_SetInfo(void *addonData, GUIHANDLE handle, int iInfo)
1177{
1178 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1179 if (!helper || !handle)
1180 return;
1181
1182 CGUIProgressControl *pControl = (CGUIProgressControl*)handle;
1183 pControl->SetInfo(iInfo);
1184}
1185
1186int CAddonCallbacksGUI::Control_Progress_GetInfo(void *addonData, GUIHANDLE handle)
1187{
1188 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1189 if (!helper || !handle)
1190 return -1;
1191
1192 CGUIProgressControl *pControl = (CGUIProgressControl*)handle;
1193 return pControl->GetInfo();
1194}
1195
1196const char* CAddonCallbacksGUI::Control_Progress_GetDescription(void *addonData, GUIHANDLE handle)
1197{
1198 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1199 if (!helper || !handle)
1200 return NULL;
1201
1202 CGUIProgressControl *pControl = (CGUIProgressControl*)handle;
1203 std::string string = pControl->GetDescription();
1204
1205 char *buffer = (char*) malloc (string.length()+1);
1206 strcpy(buffer, string.c_str());
1207 return buffer;
1208}
1209
1210/*
1211 * GUI slider control callback functions
1212 */
1213GUIHANDLE CAddonCallbacksGUI::Window_GetControl_Slider(void *addonData, GUIHANDLE handle, int controlId)
1214{
1215 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1216 if (!helper || !handle)
1217 return NULL;
1218
1219 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
1220 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
1221 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_SLIDER)
1222 return NULL;
1223
1224 return pGUIControl;
1225}
1226
1227void CAddonCallbacksGUI::Control_Slider_SetVisible(void *addonData, GUIHANDLE handle, bool yesNo)
1228{
1229 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1230 if (!helper || !handle)
1231 return;
1232
1233 CGUIControl *pControl = (CGUIControl*)handle;
1234 pControl->SetVisible(yesNo);
1235}
1236
1237const char* CAddonCallbacksGUI::Control_Slider_GetDescription(void *addonData, GUIHANDLE handle)
1238{
1239 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1240 if (!helper || !handle)
1241 return NULL;
1242
1243 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1244 std::string string = pControl->GetDescription();
1245
1246 char *buffer = (char*) malloc (string.length()+1);
1247 strcpy(buffer, string.c_str());
1248 return buffer;
1249}
1250
1251void CAddonCallbacksGUI::Control_Slider_SetIntRange(void *addonData, GUIHANDLE handle, int iStart, int iEnd)
1252{
1253 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1254 if (!helper || !handle)
1255 return;
1256
1257 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1258 pControl->SetRange(iStart, iEnd);
1259}
1260
1261void CAddonCallbacksGUI::Control_Slider_SetIntValue(void *addonData, GUIHANDLE handle, int iValue)
1262{
1263 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1264 if (!helper || !handle)
1265 return;
1266
1267 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1268 pControl->SetType(SPIN_CONTROL_TYPE_INT);
1269 pControl->SetIntValue(iValue);
1270}
1271
1272int CAddonCallbacksGUI::Control_Slider_GetIntValue(void *addonData, GUIHANDLE handle)
1273{
1274 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1275 if (!helper || !handle)
1276 return 0;
1277
1278 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1279 return pControl->GetIntValue();
1280}
1281
1282void CAddonCallbacksGUI::Control_Slider_SetIntInterval(void *addonData, GUIHANDLE handle, int iInterval)
1283{
1284 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1285 if (!helper || !handle)
1286 return;
1287
1288 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1289 pControl->SetIntInterval(iInterval);
1290}
1291
1292void CAddonCallbacksGUI::Control_Slider_SetPercentage(void *addonData, GUIHANDLE handle, float fPercent)
1293{
1294 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1295 if (!helper || !handle)
1296 return;
1297
1298 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1299 pControl->SetType(SPIN_CONTROL_TYPE_FLOAT);
1300 pControl->SetPercentage(fPercent);
1301}
1302
1303float CAddonCallbacksGUI::Control_Slider_GetPercentage(void *addonData, GUIHANDLE handle)
1304{
1305 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1306 if (!helper || !handle)
1307 return 0.0f;
1308
1309 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1310 return pControl->GetPercentage();
1311}
1312
1313void CAddonCallbacksGUI::Control_Slider_SetFloatRange(void *addonData, GUIHANDLE handle, float fStart, float fEnd)
1314{
1315 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1316 if (!helper || !handle)
1317 return;
1318
1319 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1320 pControl->SetFloatRange(fStart, fEnd);
1321}
1322
1323void CAddonCallbacksGUI::Control_Slider_SetFloatValue(void *addonData, GUIHANDLE handle, float iValue)
1324{
1325 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1326 if (!helper || !handle)
1327 return;
1328
1329 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1330 pControl->SetType(SPIN_CONTROL_TYPE_FLOAT);
1331 pControl->SetFloatValue(iValue);
1332}
1333
1334float CAddonCallbacksGUI::Control_Slider_GetFloatValue(void *addonData, GUIHANDLE handle)
1335{
1336 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1337 if (!helper || !handle)
1338 return 0.0f;
1339
1340 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1341 return pControl->GetFloatValue();
1342}
1343
1344void CAddonCallbacksGUI::Control_Slider_SetFloatInterval(void *addonData, GUIHANDLE handle, float fInterval)
1345{
1346 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1347 if (!helper || !handle)
1348 return;
1349
1350 CGUISliderControl *pControl = (CGUISliderControl*)handle;
1351 pControl->SetFloatInterval(fInterval);
1352}
1353
1354/*
1355 * GUI settings slider control callback functions
1356 */
1357GUIHANDLE CAddonCallbacksGUI::Window_GetControl_SettingsSlider(void *addonData, GUIHANDLE handle, int controlId)
1358{
1359 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1360 if (!helper || !handle)
1361 return NULL;
1362
1363 CGUIAddonWindow *pAddonWindow = (CGUIAddonWindow*)handle;
1364 CGUIControl* pGUIControl = (CGUIControl*)pAddonWindow->GetControl(controlId);
1365 if (pGUIControl && pGUIControl->GetControlType() != CGUIControl::GUICONTROL_SETTINGS_SLIDER)
1366 return NULL;
1367
1368 return pGUIControl;
1369}
1370
1371void CAddonCallbacksGUI::Control_SettingsSlider_SetVisible(void *addonData, GUIHANDLE handle, bool yesNo)
1372{
1373 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1374 if (!helper || !handle)
1375 return;
1376
1377 CGUIControl *pControl = (CGUIControl*)handle;
1378 pControl->SetVisible(yesNo);
1379}
1380
1381void CAddonCallbacksGUI::Control_SettingsSlider_SetText(void *addonData, GUIHANDLE handle, const char *label)
1382{
1383 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1384 if (!helper || !handle)
1385 return;
1386
1387 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1388 pControl->SetText(label);
1389}
1390
1391const char* CAddonCallbacksGUI::Control_SettingsSlider_GetDescription(void *addonData, GUIHANDLE handle)
1392{
1393 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1394 if (!helper || !handle)
1395 return NULL;
1396
1397 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1398 std::string string = pControl->GetDescription();
1399
1400 char *buffer = (char*) malloc (string.length()+1);
1401 strcpy(buffer, string.c_str());
1402 return buffer;
1403}
1404
1405void CAddonCallbacksGUI::Control_SettingsSlider_SetIntRange(void *addonData, GUIHANDLE handle, int iStart, int iEnd)
1406{
1407 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1408 if (!helper || !handle)
1409 return;
1410
1411 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1412 pControl->SetRange(iStart, iEnd);
1413}
1414
1415void CAddonCallbacksGUI::Control_SettingsSlider_SetIntValue(void *addonData, GUIHANDLE handle, int iValue)
1416{
1417 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1418 if (!helper || !handle)
1419 return;
1420
1421 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1422 pControl->SetType(SPIN_CONTROL_TYPE_INT);
1423 pControl->SetIntValue(iValue);
1424}
1425
1426int CAddonCallbacksGUI::Control_SettingsSlider_GetIntValue(void *addonData, GUIHANDLE handle)
1427{
1428 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1429 if (!helper || !handle)
1430 return 0;
1431
1432 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1433 return pControl->GetIntValue();
1434}
1435
1436void CAddonCallbacksGUI::Control_SettingsSlider_SetIntInterval(void *addonData, GUIHANDLE handle, int iInterval)
1437{
1438 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1439 if (!helper || !handle)
1440 return;
1441
1442 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1443 pControl->SetIntInterval(iInterval);
1444}
1445
1446void CAddonCallbacksGUI::Control_SettingsSlider_SetPercentage(void *addonData, GUIHANDLE handle, float fPercent)
1447{
1448 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1449 if (!helper || !handle)
1450 return;
1451
1452 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1453 pControl->SetType(SPIN_CONTROL_TYPE_FLOAT);
1454 pControl->SetPercentage(fPercent);
1455}
1456
1457float CAddonCallbacksGUI::Control_SettingsSlider_GetPercentage(void *addonData, GUIHANDLE handle)
1458{
1459 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1460 if (!helper || !handle)
1461 return 0.0f;
1462
1463 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1464 return pControl->GetPercentage();
1465}
1466
1467void CAddonCallbacksGUI::Control_SettingsSlider_SetFloatRange(void *addonData, GUIHANDLE handle, float fStart, float fEnd)
1468{
1469 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1470 if (!helper || !handle)
1471 return;
1472
1473 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1474 pControl->SetFloatRange(fStart, fEnd);
1475}
1476
1477void CAddonCallbacksGUI::Control_SettingsSlider_SetFloatValue(void *addonData, GUIHANDLE handle, float fValue)
1478{
1479 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1480 if (!helper || !handle)
1481 return;
1482
1483 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1484 pControl->SetType(SPIN_CONTROL_TYPE_FLOAT);
1485 pControl->SetFloatValue(fValue);
1486}
1487
1488float CAddonCallbacksGUI::Control_SettingsSlider_GetFloatValue(void *addonData, GUIHANDLE handle)
1489{
1490 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1491 if (!helper || !handle)
1492 return 0.0f;
1493
1494 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1495 return pControl->GetFloatValue();
1496}
1497
1498void CAddonCallbacksGUI::Control_SettingsSlider_SetFloatInterval(void *addonData, GUIHANDLE handle, float fInterval)
1499{
1500 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1501 if (!helper || !handle)
1502 return;
1503
1504 CGUISettingsSliderControl *pControl = (CGUISettingsSliderControl*)handle;
1505 pControl->SetFloatInterval(fInterval);
1506}
1507
1508/*
1509 * GUI list item control callback functions
1510 */
1511GUIHANDLE CAddonCallbacksGUI::ListItem_Create(void *addonData, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path)
1512{
1513 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1514 if (!helper)
1515 return NULL;
1516
1517 // create CFileItem
1518 CFileItem *pItem = new CFileItem();
1519 if (!pItem)
1520 return NULL;
1521
1522 if (label)
1523 pItem->SetLabel(label);
1524 if (label2)
1525 pItem->SetLabel2(label2);
1526 if (iconImage)
1527 pItem->SetIconImage(iconImage);
1528 if (thumbnailImage)
1529 pItem->SetArt("thumb", thumbnailImage);
1530 if (path)
1531 pItem->SetPath(path);
1532
1533 return pItem;
1534}
1535
1536const char* CAddonCallbacksGUI::ListItem_GetLabel(void *addonData, GUIHANDLE handle)
1537{
1538 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1539 if (!helper || !handle)
1540 return NULL;
1541
1542 std::string string = ((CFileItem*)handle)->GetLabel();
1543 char *buffer = (char*) malloc (string.length()+1);
1544 strcpy(buffer, string.c_str());
1545 return buffer;
1546}
1547
1548void CAddonCallbacksGUI::ListItem_SetLabel(void *addonData, GUIHANDLE handle, const char *label)
1549{
1550 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1551 if (!helper || !handle)
1552 return;
1553
1554 ((CFileItem*)handle)->SetLabel(label);
1555}
1556
1557const char* CAddonCallbacksGUI::ListItem_GetLabel2(void *addonData, GUIHANDLE handle)
1558{
1559 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1560 if (!helper || !handle)
1561 return NULL;
1562
1563 std::string string = ((CFileItem*)handle)->GetLabel2();
1564
1565 char *buffer = (char*) malloc (string.length()+1);
1566 strcpy(buffer, string.c_str());
1567 return buffer;
1568}
1569
1570void CAddonCallbacksGUI::ListItem_SetLabel2(void *addonData, GUIHANDLE handle, const char *label)
1571{
1572 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1573 if (!helper || !handle)
1574 return;
1575
1576 ((CFileItem*)handle)->SetLabel2(label);
1577}
1578
1579void CAddonCallbacksGUI::ListItem_SetIconImage(void *addonData, GUIHANDLE handle, const char *image)
1580{
1581 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1582 if (!helper || !handle)
1583 return;
1584
1585 ((CFileItem*)handle)->SetIconImage(image);
1586}
1587
1588void CAddonCallbacksGUI::ListItem_SetThumbnailImage(void *addonData, GUIHANDLE handle, const char *image)
1589{
1590 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1591 if (!helper || !handle)
1592 return;
1593
1594 ((CFileItem*)handle)->SetArt("thumb", image);
1595}
1596
1597void CAddonCallbacksGUI::ListItem_SetInfo(void *addonData, GUIHANDLE handle, const char *info)
1598{
1599 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1600 if (!helper || !handle)
1601 return;
1602
1603}
1604
1605void CAddonCallbacksGUI::ListItem_SetProperty(void *addonData, GUIHANDLE handle, const char *key, const char *value)
1606{
1607 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1608 if (!helper || !handle)
1609 return;
1610
1611 ((CFileItem*)handle)->SetProperty(key, value);
1612}
1613
1614const char* CAddonCallbacksGUI::ListItem_GetProperty(void *addonData, GUIHANDLE handle, const char *key)
1615{
1616 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1617 if (!helper || !handle)
1618 return NULL;
1619
1620 string string = ((CFileItem*)handle)->GetProperty(key).asString();
1621 char *buffer = (char*) malloc (string.length()+1);
1622 strcpy(buffer, string.c_str());
1623 return buffer;
1624}
1625
1626void CAddonCallbacksGUI::ListItem_SetPath(void *addonData, GUIHANDLE handle, const char *path)
1627{
1628 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1629 if (!helper || !handle)
1630 return;
1631
1632 ((CFileItem*)handle)->SetPath(path);
1633}
1634
1635void CAddonCallbacksGUI::RenderAddon_SetCallbacks(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*createCB)(GUIHANDLE,int,int,int,int,void*), void (*renderCB)(GUIHANDLE), void (*stopCB)(GUIHANDLE), bool (*dirtyCB)(GUIHANDLE))
1636{
1637 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1638 if (!helper || !handle)
1639 return;
1640
1641 CGUIAddonRenderingControl *pAddonControl = (CGUIAddonRenderingControl*)handle;
1642
1643 Lock();
1644 pAddonControl->m_clientHandle = clienthandle;
1645 pAddonControl->CBCreate = createCB;
1646 pAddonControl->CBRender = renderCB;
1647 pAddonControl->CBStop = stopCB;
1648 pAddonControl->CBDirty = dirtyCB;
1649 Unlock();
1650
1651 pAddonControl->m_pControl->InitCallback(pAddonControl);
1652}
1653
1654void CAddonCallbacksGUI::RenderAddon_Delete(void *addonData, GUIHANDLE handle)
1655{
1656 CAddonCallbacks* helper = (CAddonCallbacks*) addonData;
1657 if (!helper || !handle)
1658 return;
1659
1660 CGUIAddonRenderingControl *pAddonControl = (CGUIAddonRenderingControl*)handle;
1661
1662 Lock();
1663 pAddonControl->Delete();
1664 Unlock();
1665}
1666
1667/*! @name GUI Keyboard functions */
1668//@{
1669bool CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetInputWithHead(char &aTextString, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs)
1670{
1671 std::string str = &aTextString;
1672 bool bRet = CGUIKeyboardFactory::ShowAndGetInput(str, strHeading, allowEmptyResult, hiddenInput, autoCloseMs);
1673 if (bRet)
1674 strncpy(&aTextString, str.c_str(), iMaxStringSize);
1675 return bRet;
1676}
1677
1678bool CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetInput(char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs)
1679{
1680 std::string str = &aTextString;
1681 bool bRet = CGUIKeyboardFactory::ShowAndGetInput(str, allowEmptyResult, autoCloseMs);
1682 if (bRet)
1683 strncpy(&aTextString, str.c_str(), iMaxStringSize);
1684 return bRet;
1685}
1686
1687bool CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetNewPasswordWithHead(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs)
1688{
1689 std::string str = &strNewPassword;
1690 bool bRet = CGUIKeyboardFactory::ShowAndGetNewPassword(str, strHeading, allowEmptyResult, autoCloseMs);
1691 if (bRet)
1692 strncpy(&strNewPassword, str.c_str(), iMaxStringSize);
1693 return bRet;
1694}
1695
1696bool CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)
1697{
1698 std::string str = &strNewPassword;
1699 bool bRet = CGUIKeyboardFactory::ShowAndGetNewPassword(str, autoCloseMs);
1700 if (bRet)
1701 strncpy(&strNewPassword, str.c_str(), iMaxStringSize);
1702 return bRet;
1703}
1704
1705bool CAddonCallbacksGUI::Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs)
1706{
1707 std::string str = &strNewPassword;
1708 bool bRet = CGUIKeyboardFactory::ShowAndVerifyNewPassword(str, strHeading, allowEmptyResult, autoCloseMs);
1709 if (bRet)
1710 strncpy(&strNewPassword, str.c_str(), iMaxStringSize);
1711 return bRet;
1712}
1713
1714bool CAddonCallbacksGUI::Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs)
1715{
1716 std::string str = &strNewPassword;
1717 bool bRet = CGUIKeyboardFactory::ShowAndVerifyNewPassword(str, autoCloseMs);
1718 if (bRet)
1719 strncpy(&strNewPassword, str.c_str(), iMaxStringSize);
1720 return bRet;
1721}
1722
1723int CAddonCallbacksGUI::Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs)
1724{
1725 std::string str = &strPassword;
1726 int iRet = CGUIKeyboardFactory::ShowAndVerifyPassword(str, strHeading, iRetries, autoCloseMs);
1727 if (iRet)
1728 strncpy(&strPassword, str.c_str(), iMaxStringSize);
1729 return iRet;
1730}
1731
1732bool CAddonCallbacksGUI::Dialog_Keyboard_ShowAndGetFilter(char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs)
1733{
1734 std::string strText = &aTextString;
1735 bool bRet = CGUIKeyboardFactory::ShowAndGetFilter(strText, searching, autoCloseMs);
1736 if (bRet)
1737 strncpy(&aTextString, strText.c_str(), iMaxStringSize);
1738 return bRet;
1739}
1740
1741bool CAddonCallbacksGUI::Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard)
1742{
1743 return CGUIKeyboardFactory::SendTextToActiveKeyboard(aTextString, closeKeyboard);
1744}
1745
1746bool CAddonCallbacksGUI::Dialog_Keyboard_isKeyboardActivated()
1747{
1748 return CGUIKeyboardFactory::isKeyboardActivated();
1749}
1750//@}
1751
1752/*! @name GUI Numeric functions */
1753//@{
1754bool CAddonCallbacksGUI::Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize)
1755{
1756 std::string str = &strNewPassword;
1757 bool bRet = CGUIDialogNumeric::ShowAndVerifyNewPassword(str);
1758 if (bRet)
1759 strncpy(&strNewPassword, str.c_str(), iMaxStringSize);
1760 return bRet;
1761}
1762
1763int CAddonCallbacksGUI::Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries)
1764{
1765 std::string str = &strPassword;
1766 int bRet = CGUIDialogNumeric::ShowAndVerifyPassword(str, strHeading, iRetries);
1767 if (bRet)
1768 strncpy(&strPassword, str.c_str(), iMaxStringSize);
1769 return bRet;
1770}
1771
1772bool CAddonCallbacksGUI::Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput)
1773{
1774 std::string str = &strPassword;
1775 bool bRet = CGUIDialogNumeric::ShowAndVerifyInput(str, strHeading, bGetUserInput);
1776 if (bRet)
1777 strncpy(&strPassword, str.c_str(), iMaxStringSize);
1778 return bRet;
1779}
1780
1781bool CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading)
1782{
1783 SYSTEMTIME systemTime;
1784 CDateTime dateTime(time);
1785 dateTime.GetAsSystemTime(systemTime);
1786 if (CGUIDialogNumeric::ShowAndGetTime(systemTime, strHeading))
1787 {
1788 dateTime = systemTime;
1789 dateTime.GetAsTm(time);
1790 return true;
1791 }
1792 return false;
1793}
1794
1795bool CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading)
1796{
1797 SYSTEMTIME systemTime;
1798 CDateTime dateTime(date);
1799 dateTime.GetAsSystemTime(systemTime);
1800 if (CGUIDialogNumeric::ShowAndGetDate(systemTime, strHeading))
1801 {
1802 dateTime = systemTime;
1803 dateTime.GetAsTm(date);
1804 return true;
1805 }
1806 return false;
1807}
1808
1809bool CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading)
1810{
1811 std::string strIP = &strIPAddress;
1812 bool bRet = CGUIDialogNumeric::ShowAndGetIPAddress(strIP, strHeading);
1813 if (bRet)
1814 strncpy(&strIPAddress, strIP.c_str(), iMaxStringSize);
1815 return bRet;
1816}
1817
1818bool CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs)
1819{
1820 std::string str = &strInput;
1821 bool bRet = CGUIDialogNumeric::ShowAndGetNumber(str, strHeading, iAutoCloseTimeoutMs);
1822 if (bRet)
1823 strncpy(&strInput, str.c_str(), iMaxStringSize);
1824 return bRet;
1825}
1826
1827bool CAddonCallbacksGUI::Dialog_Numeric_ShowAndGetSeconds(char &timeString, unsigned int iMaxStringSize, const char *strHeading)
1828{
1829 std::string str = &timeString;
1830 bool bRet = CGUIDialogNumeric::ShowAndGetSeconds(str, strHeading);
1831 if (bRet)
1832 strncpy(&timeString, str.c_str(), iMaxStringSize);
1833 return bRet;
1834}
1835//@}
1836
1837/*! @name GUI File browser functions */
1838//@{
1839bool CAddonCallbacksGUI::Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList)
1840{
1841 std::string strPath = &path;
1842 bool bRet = CGUIDialogFileBrowser::ShowAndGetFile(directory, mask, heading, strPath, useThumbs, useFileDirectories, singleList);
1843 if (bRet)
1844 strncpy(&path, strPath.c_str(), iMaxStringSize);
1845 return bRet;
1846}
1847//@}
1848
1849/*! @name GUI OK Dialog */
1850//@{
1851void CAddonCallbacksGUI::Dialog_OK_ShowAndGetInputSingleText(const char *heading, const char *text)
1852{
1853 CGUIDialogOK::ShowAndGetInput(heading, text);
1854}
1855
1856void CAddonCallbacksGUI::Dialog_OK_ShowAndGetInputLineText(const char *heading, const char *line0, const char *line1, const char *line2)
1857{
1858 CGUIDialogOK::ShowAndGetInput(heading, line0, line1, line2);
1859}
1860//@}
1861
1862/*! @name GUI Yes No Dialog */
1863//@{
1864bool CAddonCallbacksGUI::Dialog_YesNo_ShowAndGetInputSingleText(const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel)
1865{
1866 return CGUIDialogYesNo::ShowAndGetInput(heading, text, bCanceled, noLabel, yesLabel);
1867}
1868
1869bool CAddonCallbacksGUI::Dialog_YesNo_ShowAndGetInputLineText(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel)
1870{
1871 return CGUIDialogYesNo::ShowAndGetInput(heading, line0, line1, line2, noLabel, yesLabel);
1872}
1873
1874bool CAddonCallbacksGUI::Dialog_YesNo_ShowAndGetInputLineButtonText(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel)
1875{
1876 return CGUIDialogYesNo::ShowAndGetInput(heading, line0, line1, line2, bCanceled, noLabel, yesLabel);
1877}
1878//@}
1879
1880/*! @name GUI Text viewer Dialog */
1881//@{
1882void CAddonCallbacksGUI::Dialog_TextViewer(const char *heading, const char *text)
1883{
1884 CGUIDialogTextViewer* pDialog = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER);
1885 pDialog->SetHeading(heading);
1886 pDialog->SetText(text);
1887 pDialog->DoModal();
1888}
1889//@}
1890
1891/*! @name GUI select Dialog */
1892//@{
1893int CAddonCallbacksGUI::Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected)
1894{
1895 CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
1896 pDialog->Reset();
1897 pDialog->SetHeading(heading);
1898
1899 for (unsigned int i = 0; i < size; i++)
1900 pDialog->Add(entries[i]);
1901
1902 if (selected > 0)
1903 pDialog->SetSelected(selected);
1904
1905 pDialog->DoModal();
1906 return pDialog->GetSelectedLabel();
1907}
1908//@}
1909
1910CGUIAddonWindow::CGUIAddonWindow(int id, const std::string& strXML, CAddon* addon)
1911 : CGUIMediaWindow(id, strXML.c_str())
1912 , m_iWindowId(id)
1913 , m_iOldWindowId(0)
1914 , m_bModal(false)
1915 , m_bIsDialog(false)
1916 , m_actionEvent(true)
1917 , m_addon(addon)
1918{
1919 m_loadType = LOAD_ON_GUI_INIT;
1920 CBOnInit = NULL;
1921 CBOnFocus = NULL;
1922 CBOnClick = NULL;
1923 CBOnAction = NULL;
1924}
1925
1926CGUIAddonWindow::~CGUIAddonWindow(void)
1927{
1928}
1929
1930bool CGUIAddonWindow::OnAction(const CAction &action)
1931{
1932 // Let addon decide whether it wants to hande action first
1933 if (CBOnAction && CBOnAction(m_clientHandle, action.GetID()))
1934 return true;
1935
1936 return CGUIWindow::OnAction(action);
1937}
1938
1939bool CGUIAddonWindow::OnMessage(CGUIMessage& message)
1940{
1941 // TODO: We shouldn't be dropping down to CGUIWindow in any of this ideally.
1942 // We have to make up our minds about what python should be doing and
1943 // what this side of things should be doing
1944 switch (message.GetMessage())
1945 {
1946 case GUI_MSG_WINDOW_DEINIT:
1947 {
1948 return CGUIMediaWindow::OnMessage(message);
1949 }
1950 break;
1951
1952 case GUI_MSG_WINDOW_INIT:
1953 {
1954 CGUIMediaWindow::OnMessage(message);
1955 if (CBOnInit)
1956 CBOnInit(m_clientHandle);
1957
1958 return true;
1959 }
1960 break;
1961
1962 case GUI_MSG_SETFOCUS:
1963 {
1964 if (m_viewControl.HasControl(message.GetControlId()) && m_viewControl.GetCurrentControl() != (int)message.GetControlId())
1965 {
1966 m_viewControl.SetFocused();
1967 return true;
1968 }
1969 // check if our focused control is one of our category buttons
1970 int iControl = message.GetControlId();
1971 if (CBOnFocus)
1972 {
1973 CBOnFocus(m_clientHandle, iControl);
1974 }
1975 }
1976 break;
1977
1978 case GUI_MSG_FOCUSED:
1979 {
1980 if (HasID(message.GetSenderId()) && CBOnFocus)
1981 {
1982 CBOnFocus(m_clientHandle, message.GetControlId());
1983 }
1984 }
1985 break;
1986
1987 case GUI_MSG_CLICKED:
1988 {
1989 int iControl=message.GetSenderId();
1990 // Handle Sort/View internally. Scripters shouldn't use ID 2, 3 or 4.
1991 if (iControl == CONTROL_BTNSORTASC) // sort asc
1992 {
1993 CLog::Log(LOGINFO, "WindowXML: Internal asc/dsc button not implemented");
1994 /*if (m_guiState.get())
1995 m_guiState->SetNextSortOrder();
1996 UpdateFileList();*/
1997 return true;
1998 }
1999 else if (iControl == CONTROL_BTNSORTBY) // sort by
2000 {
2001 CLog::Log(LOGINFO, "WindowXML: Internal sort button not implemented");
2002 /*if (m_guiState.get())
2003 m_guiState->SetNextSortMethod();
2004 UpdateFileList();*/
2005 return true;
2006 }
2007
2008 if (CBOnClick && iControl && iControl != (int)this->GetID())
2009 {
2010 CGUIControl* controlClicked = (CGUIControl*)this->GetControl(iControl);
2011
2012 // The old python way used to check list AND SELECITEM method or if its a button, checkmark.
2013 // Its done this way for now to allow other controls without a python version like togglebutton to still raise a onAction event
2014 if (controlClicked) // Will get problems if we the id is not on the window and we try to do GetControlType on it. So check to make sure it exists
2015 {
2016 if ((controlClicked->IsContainer() && (message.GetParam1() == ACTION_SELECT_ITEM ||
2017 message.GetParam1() == ACTION_MOUSE_LEFT_CLICK)) ||
2018 !controlClicked->IsContainer())
2019 {
2020 if (CBOnClick(m_clientHandle, iControl))
2021 return true;
2022 }
2023 else if (controlClicked->IsContainer() && message.GetParam1() == ACTION_MOUSE_RIGHT_CLICK)
2024 {
2025// PyXBMCAction* inf = new PyXBMCAction;
2026// inf->pObject = Action_FromAction(CAction(ACTION_CONTEXT_MENU));
2027// inf->pCallbackWindow = pCallbackWindow;
2028//
2029// // aquire lock?
2030// PyXBMC_AddPendingCall(Py_XBMC_Event_OnAction, inf);
2031// PulseActionEvent();
2032 }
2033 }
2034 }
2035 }
2036 break;
2037 }
2038
2039 return CGUIMediaWindow::OnMessage(message);
2040}
2041
2042void CGUIAddonWindow::AllocResources(bool forceLoad /*= FALSE */)
2043{
2044 std::string tmpDir = URIUtils::GetDirectory(GetProperty("xmlfile").asString());
2045 std::string fallbackMediaPath;
2046 URIUtils::GetParentPath(tmpDir, fallbackMediaPath);
2047 URIUtils::RemoveSlashAtEnd(fallbackMediaPath);
2048 m_mediaDir = fallbackMediaPath;
2049
2050 //CLog::Log(LOGDEBUG, "CGUIPythonWindowXML::AllocResources called: %s", fallbackMediaPath.c_str());
2051 g_TextureManager.AddTexturePath(m_mediaDir);
2052 CGUIMediaWindow::AllocResources(forceLoad);
2053 g_TextureManager.RemoveTexturePath(m_mediaDir);
2054}
2055
2056void CGUIAddonWindow::FreeResources(bool forceUnLoad /*= FALSE */)
2057{
2058 CGUIMediaWindow::FreeResources(forceUnLoad);
2059}
2060
2061void CGUIAddonWindow::Render()
2062{
2063 g_TextureManager.AddTexturePath(m_mediaDir);
2064 CGUIMediaWindow::Render();
2065 g_TextureManager.RemoveTexturePath(m_mediaDir);
2066}
2067
2068void CGUIAddonWindow::Update()
2069{
2070}
2071
2072void CGUIAddonWindow::AddItem(CFileItemPtr fileItem, int itemPosition)
2073{
2074 if (itemPosition == -1 || itemPosition > m_vecItems->Size())
2075 {
2076 m_vecItems->Add(fileItem);
2077 }
2078 else if (itemPosition < -1 && !(itemPosition-1 < m_vecItems->Size()))
2079 {
2080 m_vecItems->AddFront(fileItem,0);
2081 }
2082 else
2083 {
2084 m_vecItems->AddFront(fileItem,itemPosition);
2085 }
2086 m_viewControl.SetItems(*m_vecItems);
2087 UpdateButtons();
2088}
2089
2090void CGUIAddonWindow::RemoveItem(int itemPosition)
2091{
2092 m_vecItems->Remove(itemPosition);
2093 m_viewControl.SetItems(*m_vecItems);
2094 UpdateButtons();
2095}
2096
2097int CGUIAddonWindow::GetCurrentListPosition()
2098{
2099 return m_viewControl.GetSelectedItem();
2100}
2101
2102void CGUIAddonWindow::SetCurrentListPosition(int item)
2103{
2104 m_viewControl.SetSelectedItem(item);
2105}
2106
2107int CGUIAddonWindow::GetListSize()
2108{
2109 return m_vecItems->Size();
2110}
2111
2112CFileItemPtr CGUIAddonWindow::GetListItem(int position)
2113{
2114 if (position < 0 || position >= m_vecItems->Size()) return CFileItemPtr();
2115 return m_vecItems->Get(position);
2116}
2117
2118void CGUIAddonWindow::ClearList()
2119{
2120 ClearFileItems();
2121
2122 m_viewControl.SetItems(*m_vecItems);
2123 UpdateButtons();
2124}
2125
2126void CGUIAddonWindow::GetContextButtons(int itemNumber, CContextButtons &buttons)
2127{
2128 // maybe on day we can make an easy way to do this context menu
2129 // with out this method overriding the MediaWindow version, it will display 'Add to Favorites'
2130}
2131
2132void CGUIAddonWindow::WaitForActionEvent(unsigned int timeout)
2133{
2134 m_actionEvent.WaitMSec(timeout);
2135 m_actionEvent.Reset();
2136}
2137
2138void CGUIAddonWindow::PulseActionEvent()
2139{
2140 m_actionEvent.Set();
2141}
2142
2143bool CGUIAddonWindow::OnClick(int iItem)
2144{
2145 // Hook Over calling CGUIMediaWindow::OnClick(iItem) results in it trying to PLAY the file item
2146 // which if its not media is BAD and 99 out of 100 times undesireable.
2147 return false;
2148}
2149
2150// SetupShares();
2151/*
2152 CGUIMediaWindow::OnWindowLoaded() calls SetupShares() so override it
2153and just call UpdateButtons();
2154*/
2155void CGUIAddonWindow::SetupShares()
2156{
2157 UpdateButtons();
2158}
2159
2160
2161CGUIAddonWindowDialog::CGUIAddonWindowDialog(int id, const std::string& strXML, CAddon* addon)
2162: CGUIAddonWindow(id,strXML,addon)
2163{
2164 m_bRunning = false;
2165 m_bIsDialog = true;
2166}
2167
2168CGUIAddonWindowDialog::~CGUIAddonWindowDialog(void)
2169{
2170}
2171
2172bool CGUIAddonWindowDialog::OnMessage(CGUIMessage &message)
2173{
2174 if (message.GetMessage() == GUI_MSG_WINDOW_DEINIT)
2175 {
2176 CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
2177 if (pWindow)
2178 g_windowManager.ShowOverlay(pWindow->GetOverlayState());
2179 return CGUIWindow::OnMessage(message);
2180 }
2181 return CGUIAddonWindow::OnMessage(message);
2182}
2183
2184void CGUIAddonWindowDialog::Show(bool show /* = true */)
2185{
2186 unsigned int iCount = g_graphicsContext.exit();
2187 ThreadMessage tMsg = {TMSG_GUI_ADDON_DIALOG, 1, show ? 1 : 0};
2188 tMsg.lpVoid = this;
2189 CApplicationMessenger::Get().SendMessage(tMsg, true);
2190 g_graphicsContext.restore(iCount);
2191}
2192
2193void CGUIAddonWindowDialog::Show_Internal(bool show /* = true */)
2194{
2195 if (show)
2196 {
2197 m_bModal = true;
2198 m_bRunning = true;
2199 g_windowManager.RouteToWindow(this);
2200
2201 // active this window...
2202 CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, m_iWindowId);
2203 OnMessage(msg);
2204
2205 // this dialog is derived from GUiMediaWindow
2206 // make sure it is rendered last
2207 m_renderOrder = 1;
2208 while (m_bRunning && !g_application.m_bStop)
2209 {
2210 g_windowManager.ProcessRenderLoop();
2211 }
2212 }
2213 else // hide
2214 {
2215 m_bRunning = false;
2216
2217 CGUIMessage msg(GUI_MSG_WINDOW_DEINIT,0,0);
2218 OnMessage(msg);
2219
2220 g_windowManager.RemoveDialog(GetID());
2221 }
2222}
2223
2224CGUIAddonRenderingControl::CGUIAddonRenderingControl(CGUIRenderingControl *pControl)
2225{
2226 m_pControl = pControl;
2227 m_refCount = 1;
2228}
2229
2230bool CGUIAddonRenderingControl::Create(int x, int y, int w, int h, void *device)
2231{
2232 if (CBCreate)
2233 {
2234 if (CBCreate(m_clientHandle, x, y, w, h, device))
2235 {
2236 m_refCount++;
2237 return true;
2238 }
2239 }
2240 return false;
2241}
2242
2243void CGUIAddonRenderingControl::Render()
2244{
2245 if (CBRender)
2246 {
2247 g_graphicsContext.BeginPaint();
2248 CBRender(m_clientHandle);
2249 g_graphicsContext.EndPaint();
2250 }
2251}
2252
2253void CGUIAddonRenderingControl::Stop()
2254{
2255 if (CBStop)
2256 {
2257 CBStop(m_clientHandle);
2258 }
2259 m_refCount--;
2260 if (m_refCount <= 0)
2261 delete this;
2262}
2263
2264void CGUIAddonRenderingControl::Delete()
2265{
2266 m_refCount--;
2267 if (m_refCount <= 0)
2268 delete this;
2269}
2270
2271bool CGUIAddonRenderingControl::IsDirty()
2272{
2273 bool ret = true;
2274 if (CBDirty)
2275 {
2276 ret = CBDirty(m_clientHandle);
2277 }
2278 return ret;
2279}
2280
2281}; /* namespace ADDON */