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 #pragma once 10 11 #include "threads/CriticalSection.h" 12 #include "threads/SystemClock.h" 13 #include "windows/GUIMediaWindow.h" 14 15 #include <atomic> 16 #include <memory> 17 #include <string> 18 19 #define CONTROL_BTNVIEWASICONS 2 20 #define CONTROL_BTNSORTBY 3 21 #define CONTROL_BTNSORTASC 4 22 #define CONTROL_BTNGROUPITEMS 5 23 #define CONTROL_BTNSHOWHIDDEN 6 24 #define CONTROL_BTNSHOWDELETED 7 25 #define CONTROL_BTNHIDEDISABLEDTIMERS 8 26 #define CONTROL_BTNSHOWMODE 10 27 #define CONTROL_LSTCHANNELGROUPS 11 28 29 #define CONTROL_BTNCHANNELGROUPS 28 30 #define CONTROL_BTNFILTERCHANNELS 31 31 32 #define CONTROL_LABEL_HEADER1 29 33 #define CONTROL_LABEL_HEADER2 30 34 35 class CGUIDialogProgressBarHandle; 36 37 namespace PVR 38 { 39 enum class PVREvent; 40 41 enum EPGSelectAction 42 { 43 EPG_SELECT_ACTION_CONTEXT_MENU = 0, 44 EPG_SELECT_ACTION_SWITCH = 1, 45 EPG_SELECT_ACTION_INFO = 2, 46 EPG_SELECT_ACTION_RECORD = 3, 47 EPG_SELECT_ACTION_PLAY_RECORDING = 4, 48 EPG_SELECT_ACTION_SMART_SELECT = 5 49 }; 50 51 class CPVRChannelGroup; 52 class CGUIPVRChannelGroupsSelector; 53 54 class CGUIWindowPVRBase : public CGUIMediaWindow 55 { 56 public: 57 ~CGUIWindowPVRBase() override; 58 59 void OnInitWindow() override; 60 void OnDeinitWindow(int nextWindowID) override; 61 bool OnMessage(CGUIMessage& message) override; 62 bool Update(const std::string& strDirectory, bool updateFilterPath = true) override; 63 void UpdateButtons() override; 64 bool OnAction(const CAction& action) override; 65 bool OnBack(int actionID) override; 66 void SetInvalid() override; 67 bool CanBeActivated() const override; 68 69 /*! 70 * @brief CEventStream callback for PVR events. 71 * @param event The event. 72 */ 73 void Notify(const PVREvent& event); 74 virtual void NotifyEvent(const PVREvent& event); 75 76 /*! 77 * @brief Refresh window content. 78 * @return true, if refresh succeeded, false otherwise. 79 */ DoRefresh()80 bool DoRefresh() { return Refresh(true); } 81 82 bool ActivatePreviousChannelGroup(); 83 bool ActivateNextChannelGroup(); 84 bool OpenChannelGroupSelectionDialog(); 85 86 protected: 87 CGUIWindowPVRBase(bool bRadio, int id, const std::string& xmlFile); 88 89 virtual std::string GetDirectoryPath() = 0; 90 91 virtual void ClearData(); 92 93 /*! 94 * @brief Init this window's channel group with the currently active (the "playing") channel group. 95 * @return true if group could be set, false otherwise. 96 */ 97 bool InitChannelGroup(); 98 99 /*! 100 * @brief Get the channel group for this window. 101 * @return the group or null, if no group set. 102 */ 103 std::shared_ptr<CPVRChannelGroup> GetChannelGroup(); 104 105 /*! 106 * @brief Set a new channel group, start listening to this group, optionally update window content. 107 * @param group The new group. 108 * @param bUpdate if true, window content will be updated. 109 */ 110 void SetChannelGroup(std::shared_ptr<CPVRChannelGroup> &&group, bool bUpdate = true); 111 112 virtual void UpdateSelectedItemPath(); 113 114 void RegisterObservers(); 115 void UnregisterObservers(); 116 117 CCriticalSection m_critSection; 118 std::string m_channelGroupPath; 119 bool m_bRadio; 120 std::atomic_bool m_bUpdating = {false}; 121 122 private: 123 /*! 124 * @brief Show or update the progress dialog. 125 * @param strText The current status. 126 * @param iProgress The current progress in %. 127 */ 128 void ShowProgressDialog(const std::string& strText, int iProgress); 129 130 /*! 131 * @brief Hide the progress dialog if it's visible. 132 */ 133 void HideProgressDialog(); 134 135 std::unique_ptr<CGUIPVRChannelGroupsSelector> m_channelGroupsSelector; 136 std::shared_ptr<CPVRChannelGroup> m_channelGroup; 137 XbmcThreads::EndTime m_refreshTimeout; 138 CGUIDialogProgressBarHandle* m_progressHandle; /*!< progress dialog that is displayed while the pvr manager is loading */ 139 }; 140 } 141