[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / GUIInfoManager.h
blobafc51214e522092ffe7d259b88c72646e1c13bff
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "guilib/guiinfo/GUIInfoProviders.h"
12 #include "interfaces/info/InfoBool.h"
13 #include "interfaces/info/SkinVariable.h"
14 #include "messaging/IMessageTarget.h"
15 #include "threads/CriticalSection.h"
17 #include <map>
18 #include <memory>
19 #include <set>
20 #include <string>
21 #include <vector>
23 class CFileItem;
24 class CVideoInfoTag;
26 class CGUIListItem;
27 typedef std::shared_ptr<CGUIListItem> CGUIListItemPtr;
29 namespace KODI
31 namespace GUILIB
33 namespace GUIINFO
35 class CGUIInfo;
36 class IGUIInfoProvider;
40 namespace INFO
42 class InfoSingle;
44 namespace MUSIC_INFO
46 class CMusicInfoTag;
49 /*!
50 \ingroup strings
51 \brief
53 class CGUIInfoManager : public KODI::MESSAGING::IMessageTarget
55 public:
56 CGUIInfoManager(void);
57 ~CGUIInfoManager(void) override;
59 void Initialize();
61 void Clear();
62 void ResetCache();
64 // KODI::MESSAGING::IMessageTarget implementation
65 int GetMessageMask() override;
66 void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override;
68 /*! \brief Register a boolean condition/expression
69 This routine allows controls or other clients of the info manager to register
70 to receive updates of particular expressions, in a particular context (currently windows).
72 In the future, it will allow clients to receive pushed callbacks when the expression changes.
74 \param expression the boolean condition or expression
75 \param context the context window
76 \return an identifier used to reference this expression
78 INFO::InfoPtr Register(const std::string &expression, int context = 0);
80 /*! \brief Unregister a boolean condition/expression
81 * This routine allows controls or other clients of the info manager to unregister a previously registered
82 * boolean condition/expression
83 \param expression the boolean condition or expression
85 void UnRegister(const INFO::InfoPtr& expression);
87 /// \brief iterates through boolean conditions and compares their stored values to current values. Returns true if any condition changed value.
88 bool ConditionsChangedValues(const std::map<INFO::InfoPtr, bool>& map);
90 /*! \brief Evaluate a boolean expression
91 \param expression the expression to evaluate
92 \param context the context in which to evaluate the expression (currently windows)
93 \return the value of the evaluated expression.
94 \sa Register
96 bool EvaluateBool(const std::string& expression,
97 int context,
98 const CGUIListItemPtr& item = nullptr);
100 int TranslateString(const std::string &strCondition);
101 int TranslateSingleString(const std::string &strCondition, bool &listItemDependent);
103 std::string GetLabel(int info, int contextWindow, std::string* fallback = nullptr) const;
104 std::string GetImage(int info, int contextWindow, std::string *fallback = nullptr);
105 bool GetInt(int& value, int info, int contextWindow, const CGUIListItem* item = nullptr) const;
106 bool GetBool(int condition, int contextWindow, const CGUIListItem* item = nullptr);
108 std::string GetItemLabel(const CFileItem *item, int contextWindow, int info, std::string *fallback = nullptr) const;
109 std::string GetItemImage(const CGUIListItem *item, int contextWindow, int info, std::string *fallback = nullptr) const;
110 /*! \brief Get integer value of info.
111 \param value int reference to pass value of given info
112 \param info id of info
113 \param context the context in which to evaluate the expression (currently windows)
114 \param item optional listitem if want to get listitem related int
115 \return true if given info was handled
116 \sa GetItemInt, GetMultiInfoInt
118 bool GetItemInt(int &value, const CGUIListItem *item, int contextWindow, int info) const;
119 bool GetItemBool(const CGUIListItem *item, int contextWindow, int condition) const;
121 /*! \brief Set currently playing file item
123 void SetCurrentItem(const CFileItem &item);
124 void ResetCurrentItem();
125 void UpdateCurrentItem(const CFileItem &item);
127 // Current song stuff
128 void SetCurrentAlbumThumb(const std::string &thumbFileName);
129 const MUSIC_INFO::CMusicInfoTag *GetCurrentSongTag() const;
131 // Current video stuff
132 const CVideoInfoTag* GetCurrentMovieTag() const;
134 void UpdateAVInfo();
136 int RegisterSkinVariableString(const INFO::CSkinVariableString* info);
137 int TranslateSkinVariableString(const std::string& name, int context);
139 /*! \brief register a guiinfo provider
140 \param the guiinfo provider to register
142 void RegisterInfoProvider(KODI::GUILIB::GUIINFO::IGUIInfoProvider *provider);
144 /*! \brief unregister a guiinfo provider
145 \param the guiinfo provider to unregister
147 void UnregisterInfoProvider(KODI::GUILIB::GUIINFO::IGUIInfoProvider *provider);
149 /*! \brief get access to the registered guiinfo providers
150 \return the guiinfo providers
152 KODI::GUILIB::GUIINFO::CGUIInfoProviders& GetInfoProviders() { return m_infoProviders; }
154 private:
155 /*! \brief class for holding information on properties
157 class Property
159 public:
160 Property(const std::string &property, const std::string &parameters);
162 const std::string &param(unsigned int n = 0) const;
163 unsigned int num_params() const;
165 std::string name;
166 private:
167 std::vector<std::string> params;
170 /*! \brief Split an info string into it's constituent parts and parameters
171 Format is:
173 info1(params1).info2(params2).info3(params3) ...
175 where the parameters are an optional comma separated parameter list.
177 \param infoString the original string
178 \param info the resulting pairs of info and parameters.
180 void SplitInfoString(const std::string &infoString, std::vector<Property> &info);
182 int TranslateSingleString(const std::string &strCondition);
183 int TranslateListItem(const Property& cat, const Property& prop, int id, bool container);
184 int TranslateMusicPlayerString(const std::string &info) const;
185 int TranslateVideoPlayerString(const std::string& info) const;
186 int TranslatePlayerString(const std::string& info) const;
187 static TIME_FORMAT TranslateTimeFormat(const std::string &format);
189 std::string GetMultiInfoLabel(const KODI::GUILIB::GUIINFO::CGUIInfo &info, int contextWindow, std::string *fallback = nullptr) const;
190 bool GetMultiInfoInt(int &value, const KODI::GUILIB::GUIINFO::CGUIInfo &info, int contextWindow, const CGUIListItem *item) const;
191 bool GetMultiInfoBool(const KODI::GUILIB::GUIINFO::CGUIInfo &info, int contextWindow, const CGUIListItem *item);
193 std::string GetMultiInfoItemLabel(const CFileItem *item, int contextWindow, const KODI::GUILIB::GUIINFO::CGUIInfo &info, std::string *fallback = nullptr) const;
194 std::string GetMultiInfoItemImage(const CFileItem *item, int contextWindow, const KODI::GUILIB::GUIINFO::CGUIInfo &info, std::string *fallback = nullptr) const;
196 std::string GetSkinVariableString(int info,
197 int contextWindow,
198 bool preferImage = false,
199 const CGUIListItem* item = nullptr) const;
201 int AddMultiInfo(const KODI::GUILIB::GUIINFO::CGUIInfo &info);
203 int ResolveMultiInfo(int info) const;
204 bool IsListItemInfo(int info) const;
206 void SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag &tag);
207 void SetCurrentVideoTag(const CVideoInfoTag &tag);
209 // Vector of multiple information mapped to a single integer lookup
210 std::vector<KODI::GUILIB::GUIINFO::CGUIInfo> m_multiInfo;
212 // Current playing stuff
213 CFileItem* m_currentFile;
215 typedef std::set<INFO::InfoPtr, bool(*)(const INFO::InfoPtr&, const INFO::InfoPtr&)> INFOBOOLTYPE;
216 INFOBOOLTYPE m_bools;
217 unsigned int m_refreshCounter = 0;
218 std::vector<INFO::CSkinVariableString> m_skinVariableStrings;
220 CCriticalSection m_critInfo;
222 KODI::GUILIB::GUIINFO::CGUIInfoProviders m_infoProviders;