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
SetContainerMoving(int id,bool next,bool scrolling)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
ResetContainerMovingCache()47 void CGUIControlsGUIInfo::ResetContainerMovingCache()
48 {
49 m_containerMoves.clear();
50 }
51
InitCurrentItem(CFileItem * item)52 bool CGUIControlsGUIInfo::InitCurrentItem(CFileItem *item)
53 {
54 return false;
55 }
56
GetLabel(std::string & value,const CFileItem * item,int contextWindow,const CGUIInfo & info,std::string * fallback) const57 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 = StringUtils::Format("%i", 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 = StringUtils::Format("%i", 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 = StringUtils::Format("%i", CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_LOOKANDFEEL_STARTUPWINDOW));
320 return true;
321 case SYSTEM_CURRENT_CONTROL:
322 case SYSTEM_CURRENT_CONTROL_ID:
323 {
324 CGUIWindow *window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindowOrDialog());
325 if (window)
326 {
327 CGUIControl *control = window->GetFocusedControl();
328 if (control)
329 {
330 if (info.m_info == SYSTEM_CURRENT_CONTROL_ID)
331 value = StringUtils::Format("%i", control->GetID());
332 else if (info.m_info == SYSTEM_CURRENT_CONTROL)
333 value = control->GetDescription();
334 return true;
335 }
336 }
337 break;
338 }
339 case SYSTEM_PROGRESS_BAR:
340 {
341 CGUIDialogProgress *bar = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
342 if (bar && bar->IsDialogRunning())
343 value = StringUtils::Format("%i", bar->GetPercentage());
344 return true;
345 }
346
347 ///////////////////////////////////////////////////////////////////////////////////////////////
348 // FANART_*
349 ///////////////////////////////////////////////////////////////////////////////////////////////
350 case FANART_COLOR1:
351 {
352 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
353 if (window)
354 {
355 value = window->CurrentDirectory().GetProperty("fanart_color1").asString();
356 return true;
357 }
358 break;
359 }
360 case FANART_COLOR2:
361 {
362 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
363 if (window)
364 {
365 value = window->CurrentDirectory().GetProperty("fanart_color2").asString();
366 return true;
367 }
368 break;
369 }
370 case FANART_COLOR3:
371 {
372 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
373 if (window)
374 {
375 value = window->CurrentDirectory().GetProperty("fanart_color3").asString();
376 return true;
377 }
378 break;
379 }
380 case FANART_IMAGE:
381 {
382 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
383 if (window)
384 {
385 value = window->CurrentDirectory().GetArt("fanart");
386 return true;
387 }
388 break;
389 }
390 }
391
392 return false;
393 }
394
GetInt(int & value,const CGUIListItem * gitem,int contextWindow,const CGUIInfo & info) const395 bool CGUIControlsGUIInfo::GetInt(int& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
396 {
397 switch (info.m_info)
398 {
399 ///////////////////////////////////////////////////////////////////////////////////////////////
400 // SYSTEM_*
401 ///////////////////////////////////////////////////////////////////////////////////////////////
402 case SYSTEM_PROGRESS_BAR:
403 {
404 CGUIDialogProgress *bar = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
405 if (bar && bar->IsDialogRunning())
406 value = bar->GetPercentage();
407 return true;
408 }
409 }
410
411 return false;
412 }
413
GetBool(bool & value,const CGUIListItem * gitem,int contextWindow,const CGUIInfo & info) const414 bool CGUIControlsGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const
415 {
416 switch (info.m_info)
417 {
418 ///////////////////////////////////////////////////////////////////////////////////////////////
419 // CONTAINER_*
420 ///////////////////////////////////////////////////////////////////////////////////////////////
421 case CONTAINER_HASFILES:
422 case CONTAINER_HASFOLDERS:
423 {
424 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
425 if (window)
426 {
427 const CFileItemList& items = window->CurrentDirectory();
428 for (const auto& item : items)
429 {
430 if ((!item->m_bIsFolder && info.m_info == CONTAINER_HASFILES) ||
431 (item->m_bIsFolder && !item->IsParentFolder() && info.m_info == CONTAINER_HASFOLDERS))
432 {
433 value = true;
434 return true;
435 }
436 }
437 }
438 break;
439 }
440 case CONTAINER_STACKED:
441 {
442 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
443 if (window)
444 {
445 value = window->CurrentDirectory().GetProperty("isstacked").asBoolean();
446 return true;
447 }
448 break;
449 }
450 case CONTAINER_HAS_THUMB:
451 {
452 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
453 if (window)
454 {
455 value = window->CurrentDirectory().HasArt("thumb");
456 return true;
457 }
458 break;
459 }
460 case CONTAINER_CAN_FILTER:
461 {
462 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
463 if (window)
464 {
465 value = !window->CanFilterAdvanced();
466 return true;
467 }
468 break;
469 }
470 case CONTAINER_CAN_FILTERADVANCED:
471 {
472 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
473 if (window)
474 {
475 value = window->CanFilterAdvanced();
476 return true;
477 }
478 break;
479 }
480 case CONTAINER_FILTERED:
481 {
482 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
483 if (window)
484 {
485 value = window->IsFiltered();
486 return true;
487 }
488 break;
489 }
490 case CONTAINER_SORT_METHOD:
491 {
492 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
493 if (window)
494 {
495 const CGUIViewState *viewState = window->GetViewState();
496 if (viewState)
497 {
498 value = (static_cast<int>(viewState->GetSortMethod().sortBy) == info.GetData2());
499 return true;
500 }
501 }
502 break;
503 }
504 case CONTAINER_SORT_DIRECTION:
505 {
506 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
507 if (window)
508 {
509 const CGUIViewState *viewState = window->GetViewState();
510 if (viewState)
511 {
512 value = (static_cast<unsigned int>(viewState->GetSortOrder()) == info.GetData1());
513 return true;
514 }
515 }
516 break;
517 }
518 case CONTAINER_CONTENT:
519 {
520 std::string content;
521 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
522 if (window)
523 {
524 if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
525 content = static_cast<CGUIDialogMusicInfo*>(window)->GetContent();
526 else if (window->GetID() == WINDOW_DIALOG_SONG_INFO)
527 content = static_cast<CGUIDialogSongInfo*>(window)->GetContent();
528 else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
529 content = static_cast<CGUIDialogVideoInfo*>(window)->CurrentDirectory().GetContent();
530 }
531 if (content.empty())
532 {
533 CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow);
534 if (window)
535 content = window->CurrentDirectory().GetContent();
536 }
537 value = StringUtils::EqualsNoCase(info.GetData3(), content);
538 return true;
539 }
540 case CONTAINER_ROW:
541 case CONTAINER_COLUMN:
542 case CONTAINER_POSITION:
543 case CONTAINER_HAS_NEXT:
544 case CONTAINER_HAS_PREVIOUS:
545 case CONTAINER_SCROLLING:
546 case CONTAINER_SUBITEM:
547 case CONTAINER_ISUPDATING:
548 case CONTAINER_HAS_PARENT_ITEM:
549 {
550 if (info.GetData1())
551 {
552 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
553 if (window)
554 {
555 const CGUIControl *control = window->GetControl(info.GetData1());
556 if (control)
557 {
558 value = control->GetCondition(info.m_info, info.GetData2());
559 return true;
560 }
561 }
562 }
563 else
564 {
565 const CGUIControl *activeContainer = GUIINFO::GetActiveContainer(0, contextWindow);
566 if (activeContainer)
567 {
568 value = activeContainer->GetCondition(info.m_info, info.GetData2());
569 return true;
570 }
571 }
572 break;
573 }
574 case CONTAINER_HAS_FOCUS:
575 { // grab our container
576 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
577 if (window)
578 {
579 const CGUIControl *control = window->GetControl(info.GetData1());
580 if (control && control->IsContainer())
581 {
582 const CFileItemPtr item = std::static_pointer_cast<CFileItem>(static_cast<const IGUIContainer*>(control)->GetListItem(0));
583 if (item && item->m_iprogramCount == info.GetData2()) // programcount used to store item id
584 {
585 value = true;
586 return true;
587 }
588 }
589 }
590 break;
591 }
592 case CONTAINER_SCROLL_PREVIOUS:
593 case CONTAINER_MOVE_PREVIOUS:
594 case CONTAINER_MOVE_NEXT:
595 case CONTAINER_SCROLL_NEXT:
596 {
597 int containerId = -1;
598 if (info.GetData1())
599 {
600 containerId = info.GetData1();
601 }
602 else
603 {
604 // no parameters, so we assume it's just requested for a media window. It therefore
605 // can only happen if the list has focus.
606 CGUIMediaWindow *window = GUIINFO::GetMediaWindow(contextWindow);
607 if (window)
608 containerId = window->GetViewContainerID();
609 }
610 if (containerId != -1)
611 {
612 const std::map<int,int>::const_iterator it = m_containerMoves.find(containerId);
613 if (it != m_containerMoves.end())
614 {
615 if (info.m_info == CONTAINER_SCROLL_PREVIOUS)
616 value = it->second <= -2;
617 else if (info.m_info == CONTAINER_MOVE_PREVIOUS)
618 value = it->second <= -1;
619 else if (info.m_info == CONTAINER_MOVE_NEXT)
620 value = it->second >= 1;
621 else if (info.m_info == CONTAINER_SCROLL_NEXT)
622 value = it->second >= 2;
623 return true;
624 }
625 }
626 break;
627 }
628
629 ///////////////////////////////////////////////////////////////////////////////////////////////
630 // CONTROL_*
631 ///////////////////////////////////////////////////////////////////////////////////////////////
632 case CONTROL_IS_VISIBLE:
633 {
634 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
635 if (window)
636 {
637 // Note: This'll only work for unique id's
638 const CGUIControl *control = window->GetControl(info.GetData1());
639 if (control)
640 {
641 value = control->IsVisible();
642 return true;
643 }
644 }
645 break;
646 }
647 case CONTROL_IS_ENABLED:
648 {
649 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
650 if (window)
651 {
652 // Note: This'll only work for unique id's
653 const CGUIControl *control = window->GetControl(info.GetData1());
654 if (control)
655 {
656 value = !control->IsDisabled();
657 return true;
658 }
659 }
660 break;
661 }
662 case CONTROL_HAS_FOCUS:
663 {
664 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
665 if (window)
666 {
667 value = (window->GetFocusedControlID() == static_cast<int>(info.GetData1()));
668 return true;
669 }
670 break;
671 }
672 case CONTROL_GROUP_HAS_FOCUS:
673 {
674 CGUIWindow *window = GUIINFO::GetWindow(contextWindow);
675 if (window)
676 {
677 value = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
678 return true;
679 }
680 break;
681 }
682
683 ///////////////////////////////////////////////////////////////////////////////////////////////
684 // WINDOW_*
685 ///////////////////////////////////////////////////////////////////////////////////////////////
686 case WINDOW_IS_MEDIA:
687 { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
688 CGUIWindowManager& windowMgr = CServiceBroker::GetGUI()->GetWindowManager();
689 CGUIWindow *window = windowMgr.GetWindow(windowMgr.GetActiveWindow());
690 if (window)
691 {
692 value = window->IsMediaWindow();
693 return true;
694 }
695 break;
696 }
697 case WINDOW_IS:
698 {
699 if (info.GetData1())
700 {
701 CGUIWindowManager& windowMgr = CServiceBroker::GetGUI()->GetWindowManager();
702 CGUIWindow *window = windowMgr.GetWindow(contextWindow);
703 if (!window)
704 {
705 // try topmost dialog
706 window = windowMgr.GetWindow(windowMgr.GetTopmostModalDialog());
707 if (!window)
708 {
709 // try active window
710 window = windowMgr.GetWindow(windowMgr.GetActiveWindow());
711 }
712 }
713 if (window)
714 {
715 value = (window && window->GetID() == static_cast<int>(info.GetData1()));
716 return true;
717 }
718 }
719 break;
720 }
721 case WINDOW_IS_VISIBLE:
722 {
723 if (info.GetData1())
724 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowVisible(info.GetData1());
725 else
726 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowVisible(info.GetData3());
727 return true;
728 }
729 case WINDOW_IS_ACTIVE:
730 {
731 if (info.GetData1())
732 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowActive(info.GetData1());
733 else
734 value = CServiceBroker::GetGUI()->GetWindowManager().IsWindowActive(info.GetData3());
735 return true;
736 }
737 case WINDOW_IS_DIALOG_TOPMOST:
738 {
739 if (info.GetData1())
740 value = CServiceBroker::GetGUI()->GetWindowManager().IsDialogTopmost(info.GetData1());
741 else
742 value = CServiceBroker::GetGUI()->GetWindowManager().IsDialogTopmost(info.GetData3());
743 return true;
744 }
745 case WINDOW_IS_MODAL_DIALOG_TOPMOST:
746 {
747 if (info.GetData1())
748 value = CServiceBroker::GetGUI()->GetWindowManager().IsModalDialogTopmost(info.GetData1());
749 else
750 value = CServiceBroker::GetGUI()->GetWindowManager().IsModalDialogTopmost(info.GetData3());
751 return true;
752 }
753 case WINDOW_NEXT:
754 {
755 if (info.GetData1())
756 {
757 value = (static_cast<int>(info.GetData1()) == m_nextWindowID);
758 return true;
759 }
760 else
761 {
762 CGUIWindow *window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(m_nextWindowID);
763 if (window && StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), info.GetData3()))
764 {
765 value = true;
766 return true;
767 }
768 }
769 break;
770 }
771 case WINDOW_PREVIOUS:
772 {
773 if (info.GetData1())
774 {
775 value = (static_cast<int>(info.GetData1()) == m_prevWindowID);
776 return true;
777 }
778 else
779 {
780 CGUIWindow *window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(m_prevWindowID);
781 if (window && StringUtils::EqualsNoCase(URIUtils::GetFileName(window->GetProperty("xmlfile").asString()), info.GetData3()))
782 {
783 value = true;
784 return true;
785 }
786 }
787 break;
788 }
789
790 ///////////////////////////////////////////////////////////////////////////////////////////////
791 // SYSTEM_*
792 ///////////////////////////////////////////////////////////////////////////////////////////////
793 case SYSTEM_HAS_ACTIVE_MODAL_DIALOG:
794 value = CServiceBroker::GetGUI()->GetWindowManager().HasModalDialog(true);
795 return true;
796 case SYSTEM_HAS_VISIBLE_MODAL_DIALOG:
797 value = CServiceBroker::GetGUI()->GetWindowManager().HasVisibleModalDialog();
798 return true;
799 case SYSTEM_HAS_INPUT_HIDDEN:
800 {
801 CGUIDialogNumeric *pNumeric = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogNumeric>(WINDOW_DIALOG_NUMERIC);
802 CGUIDialogKeyboardGeneric *pKeyboard = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogKeyboardGeneric>(WINDOW_DIALOG_KEYBOARD);
803
804 if (pNumeric && pNumeric->IsActive())
805 value = pNumeric->IsInputHidden();
806 else if (pKeyboard && pKeyboard->IsActive())
807 value = pKeyboard->IsInputHidden();
808 return true;
809 }
810 }
811
812 return false;
813 }
814