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.
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"
39 class IGUIInfoProvider
;
56 class CGUIInfoManager
: public KODI::MESSAGING::IMessageTarget
59 CGUIInfoManager(void);
60 ~CGUIInfoManager(void) override
;
67 // KODI::MESSAGING::IMessageTarget implementation
68 int GetMessageMask() override
;
69 void OnApplicationMessage(KODI::MESSAGING::ThreadMessage
* pMsg
) override
;
71 /*! \brief Register a boolean condition/expression
72 This routine allows controls or other clients of the info manager to register
73 to receive updates of particular expressions, in a particular context (currently windows).
75 In the future, it will allow clients to receive pushed callbacks when the expression changes.
77 \param expression the boolean condition or expression
78 \param context the context window
79 \return an identifier used to reference this expression
81 INFO::InfoPtr
Register(const std::string
&expression
, int context
= 0);
83 /*! \brief Unregister a boolean condition/expression
84 * This routine allows controls or other clients of the info manager to unregister a previously registered
85 * boolean condition/expression
86 \param expression the boolean condition or expression
88 void UnRegister(const INFO::InfoPtr
& expression
);
90 /// \brief iterates through boolean conditions and compares their stored values to current values. Returns true if any condition changed value.
91 bool ConditionsChangedValues(const std::map
<INFO::InfoPtr
, bool>& map
);
93 /*! \brief Evaluate a boolean expression
94 \param expression the expression to evaluate
95 \param context the context in which to evaluate the expression (currently windows)
96 \return the value of the evaluated expression.
99 bool EvaluateBool(const std::string
& expression
,
101 const std::shared_ptr
<CGUIListItem
>& item
= nullptr);
103 int TranslateString(const std::string
&strCondition
);
104 int TranslateSingleString(const std::string
&strCondition
, bool &listItemDependent
);
106 std::string
GetLabel(int info
, int contextWindow
, std::string
* fallback
= nullptr) const;
107 std::string
GetImage(int info
, int contextWindow
, std::string
*fallback
= nullptr);
108 bool GetInt(int& value
, int info
, int contextWindow
, const CGUIListItem
* item
= nullptr) const;
109 bool GetBool(int condition
, int contextWindow
, const CGUIListItem
* item
= nullptr);
111 std::string
GetItemLabel(const CFileItem
*item
, int contextWindow
, int info
, std::string
*fallback
= nullptr) const;
112 std::string
GetItemImage(const CGUIListItem
*item
, int contextWindow
, int info
, std::string
*fallback
= nullptr) const;
113 /*! \brief Get integer value of info.
114 \param value int reference to pass value of given info
115 \param info id of info
116 \param context the context in which to evaluate the expression (currently windows)
117 \param item optional listitem if want to get listitem related int
118 \return true if given info was handled
119 \sa GetItemInt, GetMultiInfoInt
121 bool GetItemInt(int &value
, const CGUIListItem
*item
, int contextWindow
, int info
) const;
122 bool GetItemBool(const CGUIListItem
*item
, int contextWindow
, int condition
) const;
124 /*! \brief Set currently playing file item
126 void SetCurrentItem(const CFileItem
&item
);
127 void ResetCurrentItem();
128 void UpdateCurrentItem(const CFileItem
&item
);
130 // Current song stuff
131 void SetCurrentAlbumThumb(const std::string
&thumbFileName
);
132 const MUSIC_INFO::CMusicInfoTag
*GetCurrentSongTag() const;
134 // Current video stuff
135 const CVideoInfoTag
* GetCurrentMovieTag() const;
137 // Current game stuff
138 const KODI::GAME::CGameInfoTag
* GetCurrentGameTag() const;
142 int RegisterSkinVariableString(const INFO::CSkinVariableString
* info
);
143 int TranslateSkinVariableString(const std::string
& name
, int context
);
145 /*! \brief register a guiinfo provider
146 \param the guiinfo provider to register
148 void RegisterInfoProvider(KODI::GUILIB::GUIINFO::IGUIInfoProvider
*provider
);
150 /*! \brief unregister a guiinfo provider
151 \param the guiinfo provider to unregister
153 void UnregisterInfoProvider(KODI::GUILIB::GUIINFO::IGUIInfoProvider
*provider
);
155 /*! \brief get access to the registered guiinfo providers
156 \return the guiinfo providers
158 KODI::GUILIB::GUIINFO::CGUIInfoProviders
& GetInfoProviders() { return m_infoProviders
; }
161 /*! \brief class for holding information on properties
166 Property(const std::string
&property
, const std::string
¶meters
);
168 const std::string
¶m(unsigned int n
= 0) const;
169 unsigned int num_params() const;
173 std::vector
<std::string
> params
;
176 /*! \brief Split an info string into it's constituent parts and parameters
179 info1(params1).info2(params2).info3(params3) ...
181 where the parameters are an optional comma separated parameter list.
183 \param infoString the original string
184 \param info the resulting pairs of info and parameters.
186 void SplitInfoString(const std::string
&infoString
, std::vector
<Property
> &info
);
188 int TranslateSingleString(const std::string
&strCondition
);
189 int TranslateListItem(const Property
& cat
, const Property
& prop
, int id
, bool container
);
190 int TranslateMusicPlayerString(const std::string
&info
) const;
191 int TranslateVideoPlayerString(const std::string
& info
) const;
192 int TranslatePlayerString(const std::string
& info
) const;
193 static TIME_FORMAT
TranslateTimeFormat(const std::string
&format
);
195 std::string
GetMultiInfoLabel(const KODI::GUILIB::GUIINFO::CGUIInfo
&info
, int contextWindow
, std::string
*fallback
= nullptr) const;
196 bool GetMultiInfoInt(int &value
, const KODI::GUILIB::GUIINFO::CGUIInfo
&info
, int contextWindow
, const CGUIListItem
*item
) const;
197 bool GetMultiInfoBool(const KODI::GUILIB::GUIINFO::CGUIInfo
&info
, int contextWindow
, const CGUIListItem
*item
);
199 std::string
GetMultiInfoItemLabel(const CFileItem
*item
, int contextWindow
, const KODI::GUILIB::GUIINFO::CGUIInfo
&info
, std::string
*fallback
= nullptr) const;
200 std::string
GetMultiInfoItemImage(const CFileItem
*item
, int contextWindow
, const KODI::GUILIB::GUIINFO::CGUIInfo
&info
, std::string
*fallback
= nullptr) const;
202 std::string
GetSkinVariableString(int info
,
204 bool preferImage
= false,
205 const CGUIListItem
* item
= nullptr) const;
207 int AddMultiInfo(const KODI::GUILIB::GUIINFO::CGUIInfo
&info
);
209 int ResolveMultiInfo(int info
) const;
210 bool IsListItemInfo(int info
) const;
212 void SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag
&tag
);
213 void SetCurrentVideoTag(const CVideoInfoTag
&tag
);
215 // Vector of multiple information mapped to a single integer lookup
216 std::vector
<KODI::GUILIB::GUIINFO::CGUIInfo
> m_multiInfo
;
218 // Current playing stuff
219 CFileItem
* m_currentFile
;
221 typedef std::set
<INFO::InfoPtr
, bool(*)(const INFO::InfoPtr
&, const INFO::InfoPtr
&)> INFOBOOLTYPE
;
222 INFOBOOLTYPE m_bools
;
223 unsigned int m_refreshCounter
= 0;
224 std::vector
<INFO::CSkinVariableString
> m_skinVariableStrings
;
226 CCriticalSection m_critInfo
;
228 KODI::GUILIB::GUIINFO::CGUIInfoProviders m_infoProviders
;