Debian Codegraph @

xbmc/guilib/guiinfo/GUIControlsGUIInfo.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #include "guilib/guiinfo/GUIControlsGUIInfo.h"
10
11 #include "FileItem.h"
12 #include "ServiceBroker.h"
13 #include "URL.h"
14 #include "dialogs/GUIDialogKeyboardGeneric.h"
15 #include "dialogs/GUIDialogNumeric.h"
16 #include "dialogs/GUIDialogProgress.h"
17 #include "guilib/GUIComponent.h"
18 #include "guilib/GUIControlGroupList.h"
19 #include "guilib/GUITextBox.h"
20 #include "guilib/GUIWindowManager.h"
21 #include "guilib/IGUIContainer.h"
22 #include "guilib/LocalizeStrings.h"
23 #include "guilib/guiinfo/GUIInfo.h"
24 #include "guilib/guiinfo/GUIInfoHelper.h"
25 #include "guilib/guiinfo/GUIInfoLabels.h"
26 #include "music/dialogs/GUIDialogMusicInfo.h"
27 #include "music/dialogs/GUIDialogSongInfo.h"
28 #include "music/tags/MusicInfoTag.h"
29 #include "settings/Settings.h"
30 #include "settings/SettingsComponent.h"
31 #include "utils/StringUtils.h"
32 #include "utils/URIUtils.h"
33 #include "video/VideoInfoTag.h"
34 #include "video/dialogs/GUIDialogVideoInfo.h"
35 #include "view/GUIViewState.h"
36 #include "windows/GUIMediaWindow.h"
37
38 using namespace KODI::GUILIB;
39 using namespace KODI::GUILIB::GUIINFO;
40
41 void CGUIControlsGUIInfo::SetContainerMoving(int id, bool next, bool scrolling)
42 {
43 // magnitude 2 indicates a scroll, sign indicates direction
44 m_containerMoves[id] = (next ? 1 : -1) * (scrolling ? 2 : 1);
45 }
46
47 void CGUIControlsGUIInfo::ResetContainerMovingCache()
48 {
49 m_containerMoves.clear();
50 }
51
52 bool CGUIControlsGUIInfo::InitCurrentItem(CFileItem *item)
53 {
54 return false;
55 }
56
57 bool CGUIControlsGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const
58 {
59 switch (info.m_info)
60 {
61 ///////////////////////////////////////////////////////////////////////////////////////////////
62 // CONTAINER_*
63 ///////////////////////////////////////////////////////////////////////////////////////////////
64 case CONTAINER_FOLDERPATH:
65 case CONTAINER_FOLDERNAME:
66 {
67 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
68 if (window)
69 {
70 if (info.m_info == CONTAINER_FOLDERNAME)
71 value = window->CurrentDirectory().GetLabel();
72 else
73 value = CURL(window->CurrentDirectory().GetPath()).GetWithoutUserDetails();
74 return true;
75 }
76 break;
77 }
78 case CONTAINER_PLUGINNAME:
79 {
80 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
81 if (window)
82 {
83 const CURL url(window->CurrentDirectory().GetPath());
84 if (url.IsProtocol("plugin"))
85 {
86 value = URIUtils::GetFileName(url.GetHostName());
87 return true;
88 }
89 }
90 break;
91 }
92 case CONTAINER_VIEWCOUNT:
93 case CONTAINER_VIEWMODE:
94 {
95 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
96 if (window)
97 {
98 const CGUIControl *control = window->GetControl(window->GetViewContainerID());
99 if (control && control->IsContainer())
100 {
101 if (info.m_info == CONTAINER_VIEWMODE)
102 {
103 value = static_cast<const IGUIContainer*>(control)->GetLabel();
104 return true;
105 }
106 else if (info.m_info == CONTAINER_VIEWCOUNT)
107 {
108 value = std::to_string(window->GetViewCount());
109 return true;
110 }
111 }
112 }
113 break;
114 }
115 case CONTAINER_SORT_METHOD:
116 case CONTAINER_SORT_ORDER:
117 {
118 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
119 if (window)
120 {
121 const CGUIViewState *viewState = window->GetViewState();
122 if (viewState)
123 {
124 if (info.m_info == CONTAINER_SORT_METHOD)
125 {
126 value = g_localizeStrings.Get(viewState->GetSortMethodLabel());
127 return true;
128 }
129 else if (info.m_info == CONTAINER_SORT_ORDER)
130 {
131 value = g_localizeStrings.Get(viewState->GetSortOrderLabel());
132 return true;
133 }
134 }
135 }
136 break;
137 }
138 case CONTAINER_PROPERTY:
139 {
140 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
141 if (window)
142 {
143 value = window->CurrentDirectory().GetProperty(info.GetData3()).asString();
144 return true;
145 }
146 break;
147 }
148 case CONTAINER_ART:
149 {
150 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
151 if (window)
152 {
153 value = window->CurrentDirectory().GetArt(info.GetData3());
154 return true;
155 }
156 break;
157 }
158 case CONTAINER_CONTENT:
159 {
160 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
161 if (window)
162 {
163 value = window->CurrentDirectory().GetContent();
164 return true;
165 }
166 break;
167 }
168 case CONTAINER_SHOWPLOT:
169 {
170 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
171 if (window)
172 {
173 value = window->CurrentDirectory().GetProperty("showplot").asString();
174 return true;
175 }
176 break;
177 }
178 case CONTAINER_SHOWTITLE:
179 {
180 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
181 if (window)
182 {
183 value = window->CurrentDirectory().GetProperty("showtitle").asString();
184 return true;
185 }
186 break;
187 }
188 case CONTAINER_PLUGINCATEGORY:
189 {
190 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
191 if (window)
192 {
193 value = window->CurrentDirectory().GetProperty("plugincategory").asString();
194 return true;
195 }
196 break;
197 }
198 case CONTAINER_TOTALTIME:
199 case CONTAINER_TOTALWATCHED:
200 case CONTAINER_TOTALUNWATCHED:
201 {
202 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
203 if (window)
204 {
205 int count = 0;
206 const CFileItemList& items = window->CurrentDirectory();
207 for (const auto& item : items)
208 {
209 // Iterate through container and count watched, unwatched and total duration.
210 if (info.m_info == CONTAINER_TOTALWATCHED && item->HasVideoInfoTag() && item->GetVideoInfoTag()->GetPlayCount() > 0)
211 count += 1;
212 else if (info.m_info == CONTAINER_TOTALUNWATCHED && item->HasVideoInfoTag() && item->GetVideoInfoTag()->GetPlayCount() == 0)
213 count += 1;
214 else if (info.m_info == CONTAINER_TOTALTIME && item->HasMusicInfoTag())
215 count += item->GetMusicInfoTag()->GetDuration();
216 else if (info.m_info == CONTAINER_TOTALTIME && item->HasVideoInfoTag())
217 count += item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration();
218 }
219 if (info.m_info == CONTAINER_TOTALTIME && count > 0)
220 {
221 value = StringUtils::SecondsToTimeString(count);
222 return true;
223 }
224 else if (info.m_info == CONTAINER_TOTALWATCHED || info.m_info == CONTAINER_TOTALUNWATCHED)
225 {
226 value = std::to_string(count);
227 return true;
228 }
229 }
230 break;
231 }
232 case CONTAINER_NUM_PAGES:
233 case CONTAINER_CURRENT_PAGE:
234 case CONTAINER_NUM_ITEMS:
235 case CONTAINER_POSITION:
236 case CONTAINER_ROW:
237 case CONTAINER_COLUMN:
238 case CONTAINER_CURRENT_ITEM:
239 case CONTAINER_NUM_ALL_ITEMS:
240 case CONTAINER_NUM_NONFOLDER_ITEMS:
241 {
242 const CGUIControl *control = nullptr;
243 if (info.GetData1())
244 { // container specified
245 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
246 if (window)
247 control = window->GetControl(info.GetData1());
248 }
249 else
250 { // no container specified - assume a mediawindow
251 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
252 if (window)
253 control = window->GetControl(window->GetViewContainerID());
254 }
255 if (control)
256 {
257 if (control->IsContainer())
258 value = static_cast<const IGUIContainer*>(control)->GetLabel(info.m_info);
259 else if (control->GetControlType() == CGUIControl::GUICONTROL_GROUPLIST)
260 value = static_cast<const CGUIControlGroupList*>(control)->GetLabel(info.m_info);
261 else if (control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX)
262 value = static_cast<const CGUITextBox*>(control)->GetLabel(info.m_info);
263 return true;
264 }
265 break;
266 }
267
268 ///////////////////////////////////////////////////////////////////////////////////////////////
269 // CONTROL_*
270 ///////////////////////////////////////////////////////////////////////////////////////////////
271 case CONTROL_GET_LABEL:
272 {
273 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
274 if (window)
275 {
276 const CGUIControl *control = window->GetControl(info.GetData1());
277 if (control)
278 {
279 int data2 = info.GetData2();
280 if (data2)
281 value = control->GetDescriptionByIndex(data2);
282 else
283 value = control->GetDescription();
284 return true;
285 }
286 }
287 break;
288 }
289
290 ///////////////////////////////////////////////////////////////////////////////////////////////
291 // WINDOW_*
292 ///////////////////////////////////////////////////////////////////////////////////////////////
293 case WINDOW_PROPERTY:
294 {
295 CGUIWindow *window = nullptr;
296 if (info.GetData1())
297 { // window specified
298 window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(info.GetData1());
299 }
300 else
301 { // no window specified - assume active
302 window = GUIINFO::GetWindow(contextWindow);
303 }
304 if (window)
305 {
306 value = window->GetProperty(info.GetData3()).asString();
307 return true;
308 }
309 break;
310 }
311
312 ///////////////////////////////////////////////////////////////////////////////////////////////
313 // SYSTEM_*
314 ///////////////////////////////////////////////////////////////////////////////////////////////
315 case SYSTEM_CURRENT_WINDOW:
316 value = g_localizeStrings.Get(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindowOrDialog());
317 return true;
318 case SYSTEM_STARTUP_WINDOW:
319 value = std::to_string(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(
320 CSettings::SETTING_LOOKANDFEEL_STARTUPWINDOW));
321 return true;
322 case SYSTEM_CURRENT_CONTROL:
323 case SYSTEM_CURRENT_CONTROL_ID:
324 {
325 CGUIWindow *window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindowOrDialog());
326 if (window)
327 {
328 CGUIControl *control = window->GetFocusedControl();
329 if (control)
330 {
331 if (info.m_info == SYSTEM_CURRENT_CONTROL_ID)
332 value = std::to_string(control->GetID());
333 else if (info.m_info == SYSTEM_CURRENT_CONTROL)
334 value = control->GetDescription();
335 return true;
336 }
337 }
338 break;
339 }
340 case SYSTEM_PROGRESS_BAR:
341 {
342 CGUIDialogProgress *bar = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
343 if (bar && bar->IsDialogRunning())
344 value = std::to_string(bar->GetPercentage());
345 return true;
346 }
347
348 ///////////////////////////////////////////////////////////////////////////////////////////////
349 // FANART_*
350 ///////////////////////////////////////////////////////////////////////////////////////////////
351 case FANART_COLOR1:
352 {
353 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
354 if (window)
355 {
356 value = window->CurrentDirectory().GetProperty("fanart_color1").asString();
357 return true;
358 }
359 break;
360 }
361 case FANART_COLOR2:
362 {
363 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
364 if (window)
365 {
366 value = window->CurrentDirectory().GetProperty("fanart_color2").asString();
367 return true;
368 }
369 break;
370 }
371 case FANART_COLOR3:
372 {
373 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
374 if (window)
375 {
376 value = window->CurrentDirectory().GetProperty("fanart_color3").asString();
377 return true;
378 }
379 break;
380 }
381 case FANART_IMAGE:
382 {
383 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
384 if (window)
385 {
386 value = window->CurrentDirectory().GetArt("fanart");
387 return true;
388 }
389 break;
390 }
391 }
392
393 return false;
394 }
395
396 bool CGUIControlsGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
397 {
398 switch (info.m_info)
399 {
400 ///////////////////////////////////////////////////////////////////////////////////////////////
401 // SYSTEM_*
402 ///////////////////////////////////////////////////////////////////////////////////////////////
403 case SYSTEM_PROGRESS_BAR:
404 {
405 CGUIDialogProgress *bar = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
406 if (bar && bar->IsDialogRunning())
407 value = bar->GetPercentage();
408 return true;
409 }
410 }
411
412 return false;
413 }
414
415 bool CGUIControlsGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
416 {
417 switch (info.m_info)
418 {
419 ///////////////////////////////////////////////////////////////////////////////////////////////
420 // CONTAINER_*
421 ///////////////////////////////////////////////////////////////////////////////////////////////
422 case CONTAINER_HASFILES:
423 case CONTAINER_HASFOLDERS:
424 {
425 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
426 if (window)
427 {
428 const CFileItemList& items = window->CurrentDirectory();
429 for (const auto& item : items)
430 {
431 if ((!item->m_bIsFolder && info.m_info == CONTAINER_HASFILES) ||
432 (item->m_bIsFolder && !item->IsParentFolder() && info.m_info == CONTAINER_HASFOLDERS))
433 {
434 value = true;
435 return true;
436 }
437 }
438 }
439 break;
440 }
441 case CONTAINER_STACKED:
442 {
443 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
444 if (window)
445 {
446 value = window->CurrentDirectory().GetProperty("isstacked").asBoolean();
447 return true;
448 }
449 break;
450 }
451 case CONTAINER_HAS_THUMB:
452 {
453 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
454 if (window)
455 {
456 value = window->CurrentDirectory().HasArt("thumb");
457 return true;
458 }
459 break;
460 }
461 case CONTAINER_CAN_FILTER:
462 {
463 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
464 if (window)
465 {
466 value = !window->CanFilterAdvanced();
467 return true;
468 }
469 break;
470 }
471 case CONTAINER_CAN_FILTERADVANCED:
472 {
473 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
474 if (window)
475 {
476 value = window->CanFilterAdvanced();
477 return true;
478 }
479 break;
480 }
481 case CONTAINER_FILTERED:
482 {
483 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
484 if (window)
485 {
486 value = window->IsFiltered();
487 return true;
488 }
489 break;
490 }
491 case CONTAINER_SORT_METHOD:
492 {
493 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
494 if (window)
495 {
496 const CGUIViewState *viewState = window->GetViewState();
497 if (viewState)
498 {
499 value = (static_cast<int>(viewState->GetSortMethod().sortBy) == info.GetData2());
500 return true;
501 }
502 }
503 break;
504 }
505 case CONTAINER_SORT_DIRECTION:
506 {
507 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
508 if (window)
509 {
510 const CGUIViewState *viewState = window->GetViewState();
511 if (viewState)
512 {
513 value = (static_cast<unsigned int>(viewState->GetSortOrder()) == info.GetData1());
514 return true;
515 }
516 }
517 break;
518 }
519 case CONTAINER_CONTENT:
520 {
521 std::string content;
522 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
523 if (window)
524 {
525 if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
526 content = static_cast<CGUIDialogMusicInfo*>(window)->GetContent();
527 else if (window->GetID() == WINDOW_DIALOG_SONG_INFO)
528 content = static_cast<CGUIDialogSongInfo*>(window)->GetContent();
529 else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
530 content = static_cast<CGUIDialogVideoInfo*>(window)->CurrentDirectory().GetContent();
531 }
532 if (content.empty())
533 {
534 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
535 if (window)
536 content = window->CurrentDirectory().GetContent();
537 }
538 value = StringUtils::EqualsNoCase(info.GetData3(), content);
539 return true;
540 }
541 case CONTAINER_ROW:
542 case CONTAINER_COLUMN:
543 case CONTAINER_POSITION:
544 case CONTAINER_HAS_NEXT:
545 case CONTAINER_HAS_PREVIOUS:
546 case CONTAINER_SCROLLING:
547 case CONTAINER_SUBITEM:
548 case CONTAINER_ISUPDATING:
549 case CONTAINER_HAS_PARENT_ITEM:
550 {
551 if (info.GetData1())
552 {
553 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
554 if (window)
555 {
556 const CGUIControl *control = window->GetControl(info.GetData1());
557 if (control)
558 {
559 value = control->GetCondition(info.m_info, info.GetData2());
560 return true;
561 }
562 }
563 }
564 else
565 {
566 const CGUIControl *activeContainer = GUIINFO::GetActiveContainer(0, contextWindow);
567 if (activeContainer)
568 {
569 value = activeContainer->GetCondition(info.m_info, info.GetData2());
570 return true;
571 }
572 }
573 break;
574 }
575 case CONTAINER_HAS_FOCUS:
576 { // grab our container
577 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
578 if (window)
579 {
580 const CGUIControl *control = window->GetControl(info.GetData1());
581 if (control && control->IsContainer())
582 {
583 const CFileItemPtr item = std::static_pointer_cast<CFileItem>(static_cast<const IGUIContainer*>(control)->GetListItem(0));
584 if (item && item->m_iprogramCount == info.GetData2()) // programcount used to store item id
585 {
586 value = true;
587 return true;
588 }
589 }
590 }
591 break;
592 }
593 case CONTAINER_SCROLL_PREVIOUS:
594 case CONTAINER_MOVE_PREVIOUS:
595 case CONTAINER_MOVE_NEXT:
596 case CONTAINER_SCROLL_NEXT:
597 {
598 int containerId = -1;
599 if (info.GetData1())
600 {
601 containerId = info.GetData1();
602 }
603 else
604 {
605 // no parameters, so we assume it's just requested for a media window. It therefore
606 // can only happen if the list has focus.
607 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
608 if (window)
609 containerId = window->GetViewContainerID();
610 }
611 if (containerId != -1)
612 {
613 const std::map<int,int>::const_iterator it = m_containerMoves.find(containerId);
614 if (it != m_containerMoves.end())
615 {
616 if (info.m_info == CONTAINER_SCROLL_PREVIOUS)
617 value = it->second <= -2;
618 else if (info.m_info == CONTAINER_MOVE_PREVIOUS)
619 value = it->second <= -1;
620 else if (info.m_info == CONTAINER_MOVE_NEXT)
621 value = it->second >= 1;
622 else if (info.m_info == CONTAINER_SCROLL_NEXT)
623 value = it->second >= 2;
624 return true;
625 }
626 }
627 break;
628 }
629
630 ///////////////////////////////////////////////////////////////////////////////////////////////
631 // CONTROL_*
632 ///////////////////////////////////////////////////////////////////////////////////////////////
633 case CONTROL_IS_VISIBLE:
634 {
635 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
636 if (window)
637 {
638 // Note: This'll only work for unique id's
639 const CGUIControl *control = window->GetControl(info.GetData1());
640 if (control)
641 {
642 value = control->IsVisible();
643 return true;
644 }
645 }
646 break;
647 }
648 case CONTROL_IS_ENABLED:
649 {
650 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
651 if (window)
652 {
653 // Note: This'll only work for unique id's
654 const CGUIControl *control = window->GetControl(info.GetData1());
655 if (control)
656 {
657 value = !control->IsDisabled();
658 return true;
659 }
660 }
661 break;
662 }
663 case CONTROL_HAS_FOCUS:
664 {
665 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
666 if (window)
667 {
668 value = (window->GetFocusedControlID() == static_cast<int>(info.GetData1()));
669 return true;
670 }
671 break;
672 }
673 case CONTROL_GROUP_HAS_FOCUS:
674 {
675 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
676 if (window)
677 {
678 value = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
679 return true;
680 }
681 break;
682 }
683
684 ///////////////////////////////////////////////////////////////////////////////////////////////
685 // WINDOW_*
686 ///////////////////////////////////////////////////////////////////////////////////////////////
687 case WINDOW_IS_MEDIA:
688 { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
689 CGUIWindowManager& windowMgr = CServiceBroker::GetGUI()->GetWindowManager();
690 CGUIWindow *window = windowMgr.GetWindow(windowMgr.GetActiveWindow());
691 if (window)
692 {
693 value = window->IsMediaWindow();
694 return true;
695 }
696 break;
697 }
698 case WINDOW_IS:
699 {
700 if (info.GetData1())
701 {
702 CGUIWindowManager& windowMgr = CServiceBroker::GetGUI()->GetWindowManager();
703 CGUIWindow *window = windowMgr.GetWindow(contextWindow);
704 if (!window)
705 {
706 // try topmost dialog
707 window = windowMgr.GetWindow(windowMgr.GetTopmostModalDialog());
708 if (!window)
709 {
710 // try active window
711 window = windowMgr.GetWindow(windowMgr.GetActiveWindow());
712 }
713 }
714 if (window)
715 {
716 value = (window && window->GetID() == static_cast<int>(info.GetData1()));
717 return true;
718 }
719 }
720 break;
721 }
722 case WINDOW_IS_VISIBLE:
723 {
724 if (info.GetData1())
725 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowVisible(info.GetData1());
726 else
727 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowVisible(info.GetData3());
728 return true;
729 }
730 case WINDOW_IS_ACTIVE:
731 {
732 if (info.GetData1())
733 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowActive(info.GetData1());
734 else
735 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowActive(info.GetData3());
736 return true;
737 }
738 case WINDOW_IS_DIALOG_TOPMOST:
739 {
740 if (info.GetData1())
741 value = CServiceBroker::GetGUI()->GetWindowManager().IsDialogTopmost(info.GetData1());
742 else
743 value = CServiceBroker::GetGUI()->GetWindowManager().IsDialogTopmost(info.GetData3());
744 return true;
745 }
746 case WINDOW_IS_MODAL_DIALOG_TOPMOST:
747 {
748 if (info.GetData1())
749 value = CServiceBroker::GetGUI()->GetWindowManager().IsModalDialogTopmost(info.GetData1());
750 else
751 value = CServiceBroker::GetGUI()->GetWindowManager().IsModalDialogTopmost(info.GetData3());
752 return true;
753 }
754 case WINDOW_NEXT:
755 {
756 if (info.GetData1())
757 {
758 value = (static_cast<int>(info.GetData1()) == m_nextWindowID);
759 return true;
760 }
761 else
762 {
763 CGUIWindow *window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(m_nextWindowID);
764 if (window && StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), info.GetData3()))
765 {
766 value = true;
767 return true;
768 }
769 }
770 break;
771 }
772 case WINDOW_PREVIOUS:
773 {
774 if (info.GetData1())
775 {
776 value = (static_cast<int>(info.GetData1()) == m_prevWindowID);
777 return true;
778 }
779 else
780 {
781 CGUIWindow *window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(m_prevWindowID);
782 if (window && StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), info.GetData3()))
783 {
784 value = true;
785 return true;
786 }
787 }
788 break;
789 }
790
791 ///////////////////////////////////////////////////////////////////////////////////////////////
792 // SYSTEM_*
793 ///////////////////////////////////////////////////////////////////////////////////////////////
794 case SYSTEM_HAS_ACTIVE_MODAL_DIALOG:
795 value = CServiceBroker::GetGUI()->GetWindowManager().HasModalDialog(true);
796 return true;
797 case SYSTEM_HAS_VISIBLE_MODAL_DIALOG:
798 value = CServiceBroker::GetGUI()->GetWindowManager().HasVisibleModalDialog();
799 return true;
800 case SYSTEM_HAS_INPUT_HIDDEN:
801 {
802 CGUIDialogNumeric *pNumeric = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogNumeric>(WINDOW_DIALOG_NUMERIC);
803 CGUIDialogKeyboardGeneric *pKeyboard = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogKeyboardGeneric>(WINDOW_DIALOG_KEYBOARD);
804
805 if (pNumeric && pNumeric->IsActive())
806 value = pNumeric->IsInputHidden();
807 else if (pKeyboard && pKeyboard->IsActive())
808 value = pKeyboard->IsInputHidden();
809 return true;
810 }
811 }
812
813 return false;
814 }