forked from koying/SPMC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUIInfoManager.h
356 lines (293 loc) · 11.7 KB
/
GUIInfoManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
/*!
\file GUIInfoManager.h
\brief
*/
#ifndef GUIINFOMANAGER_H_
#define GUIINFOMANAGER_H_
/*
* Copyright (C) 2005-2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "threads/CriticalSection.h"
#include "guilib/IMsgTargetCallback.h"
#include "messaging/IMessageTarget.h"
#include "inttypes.h"
#include "XBDateTime.h"
#include "utils/Observer.h"
#include "utils/Temperature.h"
#include "interfaces/info/InfoBool.h"
#include "interfaces/info/SkinVariable.h"
#include "cores/IPlayer.h"
#include <list>
#include <map>
namespace MUSIC_INFO
{
class CMusicInfoTag;
}
namespace PVR
{
class CPVRRadioRDSInfoTag;
typedef std::shared_ptr<PVR::CPVRRadioRDSInfoTag> CPVRRadioRDSInfoTagPtr;
}
class CVideoInfoTag;
class CFileItem;
class CGUIListItem;
class CDateTime;
namespace INFO
{
class InfoSingle;
}
// forward
class CGUIWindow;
namespace EPG
{
class CEpgInfoTag;
typedef std::shared_ptr<EPG::CEpgInfoTag> CEpgInfoTagPtr;
}
// structure to hold multiple integer data
// for storage referenced from a single integer
class GUIInfo
{
public:
GUIInfo(int info, uint32_t data1 = 0, int data2 = 0, uint32_t flag = 0)
{
m_info = info;
m_data1 = data1;
m_data2 = data2;
if (flag)
SetInfoFlag(flag);
}
bool operator ==(const GUIInfo &right) const
{
return (m_info == right.m_info && m_data1 == right.m_data1 && m_data2 == right.m_data2);
};
uint32_t GetInfoFlag() const;
uint32_t GetData1() const;
int GetData2() const;
int m_info;
private:
void SetInfoFlag(uint32_t flag);
uint32_t m_data1;
int m_data2;
};
/*!
\ingroup strings
\brief
*/
class CGUIInfoManager : public IMsgTargetCallback, public Observable,
public KODI::MESSAGING::IMessageTarget
{
public:
CGUIInfoManager(void);
virtual ~CGUIInfoManager(void);
void Clear();
virtual bool OnMessage(CGUIMessage &message) override;
virtual int GetMessageMask() override;
virtual void OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) override;
/*! \brief Register a boolean condition/expression
This routine allows controls or other clients of the info manager to register
to receive updates of particular expressions, in a particular context (currently windows).
In the future, it will allow clients to receive pushed callbacks when the expression changes.
\param expression the boolean condition or expression
\param context the context window
\return an identifier used to reference this expression
*/
INFO::InfoPtr Register(const std::string &expression, int context = 0);
/*! \brief Evaluate a boolean expression
\param expression the expression to evaluate
\param context the context in which to evaluate the expression (currently windows)
\return the value of the evaluated expression.
\sa Register
*/
bool EvaluateBool(const std::string &expression, int context = 0, const CGUIListItemPtr &item = nullptr);
int TranslateString(const std::string &strCondition);
/*! \brief Get integer value of info.
\param value int reference to pass value of given info
\param info id of info
\param context the context in which to evaluate the expression (currently windows)
\param item optional listitem if want to get listitem related int
\return true if given info was handled
\sa GetItemInt, GetMultiInfoInt
*/
bool GetInt(int &value, int info, int contextWindow = 0, const CGUIListItem *item = NULL) const;
std::string GetLabel(int info, int contextWindow = 0, std::string *fallback = NULL);
std::string GetImage(int info, int contextWindow, std::string *fallback = NULL);
std::string GetTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
std::string GetDate(bool bNumbersOnly = false);
std::string GetDuration(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
void SetCurrentItem(CFileItem &item);
void ResetCurrentItem();
// Current song stuff
/// \brief Retrieves tag info (if necessary) and fills in our current song path.
void SetCurrentSong(CFileItem &item);
void SetCurrentAlbumThumb(const std::string &thumbFileName);
void SetCurrentMovie(CFileItem &item);
void SetCurrentSlide(CFileItem &item);
const CFileItem &GetCurrentSlide() const;
void ResetCurrentSlide();
void SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag &tag);
void SetCurrentVideoTag(const CVideoInfoTag &tag);
const MUSIC_INFO::CMusicInfoTag *GetCurrentSongTag() const;
const PVR::CPVRRadioRDSInfoTagPtr GetCurrentRadioRDSInfoTag() const;
const CVideoInfoTag* GetCurrentMovieTag() const;
std::string GetRadioRDSLabel(int item);
std::string GetMusicLabel(int item);
std::string GetMusicTagLabel(int info, const CFileItem *item);
std::string GetVideoLabel(int item);
std::string GetPlaylistLabel(int item, int playlistid = -1 /* PLAYLIST_NONE */) const;
std::string GetMusicPartyModeLabel(int item);
const std::string GetMusicPlaylistInfo(const GUIInfo& info);
std::string GetPictureLabel(int item);
int64_t GetPlayTime() const; // in ms
std::string GetCurrentPlayTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
std::string GetCurrentSeekTime(TIME_FORMAT format = TIME_FORMAT_GUESS) const;
int GetPlayTimeRemaining() const;
int GetTotalPlayTime() const;
float GetSeekPercent() const;
std::string GetCurrentPlayTimeRemaining(TIME_FORMAT format) const;
bool GetDisplayAfterSeek();
void SetDisplayAfterSeek(unsigned int timeOut = 2500, int seekOffset = 0);
void SetShowTime(bool showtime) { m_playerShowTime = showtime; };
void SetShowCodec(bool showcodec) { m_playerShowCodec = showcodec; };
void SetShowInfo(bool showinfo) { m_playerShowInfo = showinfo; };
bool GetShowInfo() const { return m_playerShowInfo; }
void ToggleShowCodec() { m_playerShowCodec = !m_playerShowCodec; };
bool ToggleShowInfo() { m_playerShowInfo = !m_playerShowInfo; return m_playerShowInfo; };
bool IsPlayerChannelPreviewActive() const;
std::string GetSystemHeatInfo(int info);
CTemperature GetGPUTemperature();
void UpdateFPS();
void UpdateAVInfo();
inline float GetFPS() const { return m_fps; };
void SetNextWindow(int windowID) { m_nextWindowID = windowID; };
void SetPreviousWindow(int windowID) { m_prevWindowID = windowID; };
void ResetCache();
bool GetItemInt(int &value, const CGUIListItem *item, int info) const;
std::string GetItemLabel(const CFileItem *item, int info, std::string *fallback = NULL);
std::string GetItemImage(const CFileItem *item, int info, std::string *fallback = NULL);
/*! \brief containers call here to specify that the focus is changing
\param id control id
\param next true if we're moving to the next item, false if previous
\param scrolling true if the container is scrolling, false if the movement requires no scroll
*/
void SetContainerMoving(int id, bool next, bool scrolling)
{
// magnitude 2 indicates a scroll, sign indicates direction
m_containerMoves[id] = (next ? 1 : -1) * (scrolling ? 2 : 1);
}
void SetLibraryBool(int condition, bool value);
bool GetLibraryBool(int condition);
void ResetLibraryBools();
std::string LocalizeTime(const CDateTime &time, TIME_FORMAT format) const;
int TranslateSingleString(const std::string &strCondition);
int RegisterSkinVariableString(const INFO::CSkinVariableString* info);
int TranslateSkinVariableString(const std::string& name, int context);
std::string GetSkinVariableString(int info, bool preferImage = false, const CGUIListItem *item=NULL);
/// \brief iterates through boolean conditions and compares their stored values to current values. Returns true if any condition changed value.
bool ConditionsChangedValues(const std::map<INFO::InfoPtr, bool>& map);
protected:
friend class INFO::InfoSingle;
bool GetBool(int condition, int contextWindow = 0, const CGUIListItem *item=NULL);
int TranslateSingleString(const std::string &strCondition, bool &listItemDependent);
// routines for window retrieval
bool CheckWindowCondition(CGUIWindow *window, int condition) const;
CGUIWindow *GetWindowWithCondition(int contextWindow, int condition) const;
/*! \brief class for holding information on properties
*/
class Property
{
public:
Property(const std::string &property, const std::string ¶meters);
const std::string ¶m(unsigned int n = 0) const;
unsigned int num_params() const;
std::string name;
private:
std::vector<std::string> params;
};
bool GetMultiInfoBool(const GUIInfo &info, int contextWindow = 0, const CGUIListItem *item = NULL);
bool GetMultiInfoInt(int &value, const GUIInfo &info, int contextWindow = 0) const;
std::string GetMultiInfoLabel(const GUIInfo &info, int contextWindow = 0, std::string *fallback = NULL);
int TranslateListItem(const Property &info);
int TranslateMusicPlayerString(const std::string &info) const;
TIME_FORMAT TranslateTimeFormat(const std::string &format);
bool GetItemBool(const CGUIListItem *item, int condition) const;
/*! \brief Split an info string into it's constituent parts and parameters
Format is:
info1(params1).info2(params2).info3(params3) ...
where the parameters are an optional comma separated parameter list.
\param infoString the original string
\param info the resulting pairs of info and parameters.
*/
void SplitInfoString(const std::string &infoString, std::vector<Property> &info);
// Conditional string parameters for testing are stored in a vector for later retrieval.
// The offset into the string parameters array is returned.
int ConditionalStringParameter(const std::string &strParameter, bool caseSensitive = false);
int AddMultiInfo(const GUIInfo &info);
int AddListItemProp(const std::string &str, int offset=0);
/*!
* @brief Get the EPG tag that is currently active
* @return the currently active tag or NULL if no active tag was found
*/
EPG::CEpgInfoTagPtr GetEpgInfoTag() const;
// Conditional string parameters are stored here
std::vector<std::string> m_stringParameters;
// Array of multiple information mapped to a single integer lookup
std::vector<GUIInfo> m_multiInfo;
std::vector<std::string> m_listitemProperties;
std::string m_currentMovieDuration;
// Current playing stuff
CFileItem* m_currentFile;
std::string m_currentMovieThumb;
CFileItem* m_currentSlide;
// fan stuff
unsigned int m_lastSysHeatInfoTime;
int m_fanSpeed;
CTemperature m_gpuTemp;
CTemperature m_cpuTemp;
//Fullscreen OSD Stuff
unsigned int m_AfterSeekTimeout;
int m_seekOffset;
bool m_playerShowTime;
bool m_playerShowCodec;
bool m_playerShowInfo;
// FPS counters
float m_fps;
unsigned int m_frameCounter;
unsigned int m_lastFPSTime;
std::map<int, int> m_containerMoves; // direction of list moving
int m_nextWindowID;
int m_prevWindowID;
std::vector<INFO::InfoPtr> m_bools;
std::vector<INFO::CSkinVariableString> m_skinVariableStrings;
int m_libraryHasMusic;
int m_libraryHasMovies;
int m_libraryHasTVShows;
int m_libraryHasMusicVideos;
int m_libraryHasMovieSets;
int m_libraryHasSingles;
int m_libraryHasCompilations;
SPlayerVideoStreamInfo m_videoInfo;
SPlayerAudioStreamInfo m_audioInfo;
CCriticalSection m_critInfo;
};
/*!
\ingroup strings
\brief
*/
extern CGUIInfoManager g_infoManager;
#endif