diff options
author | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2018-03-14 22:40:20 +0100 |
---|---|---|
committer | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2018-03-15 15:50:40 +0100 |
commit | b03ddd0f5306c69dc79dce27cbd6e4d82166e6c5 (patch) | |
tree | 5fa53e5624330501fb7b2d75cfac96a66161dc58 | |
parent | 33e75dcf6608b18abc7cbcfc833ce2f1ba8904a6 (diff) |
[PVR][guiinfo] PVRGUIInfo: PVR.EpgEventDuration, PVREpgEvent(Elapsed|Remaining|Finish|Seek)Time, PVR.Timeshift(Start|Cur|End|Offset) now support time format strings.
-rw-r--r-- | xbmc/GUIInfoManager.cpp | 320 | ||||
-rw-r--r-- | xbmc/GUIInfoManager.h | 28 | ||||
-rw-r--r-- | xbmc/guiinfo/CMakeLists.txt | 3 | ||||
-rw-r--r-- | xbmc/guiinfo/GUIInfo.h | 47 | ||||
-rw-r--r-- | xbmc/pvr/PVRGUIInfo.cpp | 149 | ||||
-rw-r--r-- | xbmc/pvr/PVRGUIInfo.h | 35 | ||||
-rw-r--r-- | xbmc/pvr/PVRManager.cpp | 9 | ||||
-rw-r--r-- | xbmc/pvr/PVRManager.h | 13 |
8 files changed, 375 insertions, 229 deletions
diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index ea6afdc75d..cbd3014c73 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -4252,46 +4252,6 @@ const infomap playlist[] = {{ "length", PLAYLIST_LENGTH }, /// _boolean_, /// Returns true if there are timers present who currently not do recording /// } -/// \table_row3{ <b>`PVR.NowRecordingTitle`</b>, -/// \anchor PVR_NowRecordingTitle -/// _string_, -/// Title of the programme being recorded -/// } -/// \table_row3{ <b>`PVR.NowRecordingDateTime`</b>, -/// \anchor PVR_NowRecordingDateTime -/// _Date/Time string_, -/// Start date and time of the current recording -/// } -/// \table_row3{ <b>`PVR.NowRecordingChannel`</b>, -/// \anchor PVR_NowRecordingChannel -/// _string_, -/// Channel name of the current recording -/// } -/// \table_row3{ <b>`PVR.NowRecordingChannelIcon`</b>, -/// \anchor PVR_NowRecordingChannelIcon -/// _string_, -/// Icon of the current recording channel -/// } -/// \table_row3{ <b>`PVR.NextRecordingTitle`</b>, -/// \anchor PVR_NextRecordingTitle -/// _string_, -/// Title of the next programme that will be recorded -/// } -/// \table_row3{ <b>`PVR.NextRecordingDateTime`</b>, -/// \anchor PVR_NextRecordingDateTime -/// _Date/Time string_, -/// Start date and time of the next recording -/// } -/// \table_row3{ <b>`PVR.NextRecordingChannel`</b>, -/// \anchor PVR_NextRecordingChannel -/// _string_, -/// Channel name of the next recording -/// } -/// \table_row3{ <b>`PVR.NextRecordingChannelIcon`</b>, -/// \anchor PVR_NextRecordingChannelIcon -/// _string_, -/// Icon of the next recording channel -/// } /// \table_row3{ <b>`PVR.BackendName`</b>, /// \anchor PVR_BackendName /// _string_, @@ -4372,31 +4332,6 @@ const infomap playlist[] = {{ "length", PLAYLIST_LENGTH }, /// _boolean_, /// Returns true when an epg tag is being watched. /// } -/// \table_row3{ <b>`PVR.EpgEventDuration`</b>, -/// \anchor PVR_EpgEventDuration -/// _string_, -/// Returns the duration of the currently playing epg event -/// } -/// \table_row3{ <b>`PVR.EpgEventElapsedTime`</b>, -/// \anchor PVR_EpgEventElapsedTime -/// _string_, -/// Returns the time of the current position of the currently playing epg event -/// } -/// \table_row3{ <b>`PVR.EpgEventRemainingTime`</b>, -/// \anchor PVR_EpgEventRemainingTime -/// _string_, -/// Returns the remaining time for currently playing epg event -/// } -/// \table_row3{ <b>`PVR.EpgEventSeekTime`</b>, -/// \anchor PVR_EpgEventSeekTime -/// _string_, -/// Returns the time the user is seeking within the currently playing epg event -/// } -/// \table_row3{ <b>`PVR.EpgEventFinishTime`</b>, -/// \anchor PVR_EpgEventFinishTime -/// _string_, -/// Returns the time the currently playing epg event will end -/// } /// \table_row3{ <b>`PVR.EpgEventProgress`</b>, /// \anchor PVR_EpgEventProgress /// _integer_, @@ -4477,30 +4412,50 @@ const infomap playlist[] = {{ "length", PLAYLIST_LENGTH }, /// _boolean_, /// Returns true when for channel is timeshift available /// } -/// \table_row3{ <b>`PVR.TimeShiftStart`</b>, -/// \anchor PVR_TimeShiftStart -/// _time string_, -/// Start position of the timeshift -/// } -/// \table_row3{ <b>`PVR.TimeShiftEnd`</b>, -/// \anchor PVR_TimeShiftEnd -/// _time string_, -/// End position of the timeshift -/// } -/// \table_row3{ <b>`PVR.TimeShiftCur`</b>, -/// \anchor PVR_TimeShiftCur -/// _time string_, -/// Current position of the timeshift -/// } /// \table_row3{ <b>`PVR.TimeShiftProgress`</b>, /// \anchor PVR_TimeShiftProgress /// _integer_, /// Returns the position of currently timeshifted title on TV as integer /// } -/// \table_row3{ <b>`PVR.TimeShiftOffset`</b>, -/// \anchor PVR_TimeShiftOffset -/// _integer_, -/// Returns the delta of timeshifted time to actual time +/// \table_row3{ <b>`PVR.NowRecordingTitle`</b>, +/// \anchor PVR_NowRecordingTitle +/// _string_, +/// Title of the programme being recorded +/// } +/// \table_row3{ <b>`PVR.NowRecordingDateTime`</b>, +/// \anchor PVR_NowRecordingDateTime +/// _Date/Time string_, +/// Start date and time of the current recording +/// } +/// \table_row3{ <b>`PVR.NowRecordingChannel`</b>, +/// \anchor PVR_NowRecordingChannel +/// _string_, +/// Channel name of the current recording +/// } +/// \table_row3{ <b>`PVR.NowRecordingChannelIcon`</b>, +/// \anchor PVR_NowRecordingChannelIcon +/// _string_, +/// Icon of the current recording channel +/// } +/// \table_row3{ <b>`PVR.NextRecordingTitle`</b>, +/// \anchor PVR_NextRecordingTitle +/// _string_, +/// Title of the next programme that will be recorded +/// } +/// \table_row3{ <b>`PVR.NextRecordingDateTime`</b>, +/// \anchor PVR_NextRecordingDateTime +/// _Date/Time string_, +/// Start date and time of the next recording +/// } +/// \table_row3{ <b>`PVR.NextRecordingChannel`</b>, +/// \anchor PVR_NextRecordingChannel +/// _string_, +/// Channel name of the next recording +/// } +/// \table_row3{ <b>`PVR.NextRecordingChannelIcon`</b>, +/// \anchor PVR_NextRecordingChannelIcon +/// _string_, +/// Icon of the next recording channel /// } /// \table_row3{ <b>`PVR.TVNowRecordingTitle`</b>, /// \anchor PVR_TVNowRecordingTitle @@ -4636,14 +4591,6 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "hastvchannels", PVR_HAS_TV_CHANNELS }, { "hasradiochannels", PVR_HAS_RADIO_CHANNELS }, { "hasnonrecordingtimer", PVR_HAS_NONRECORDING_TIMER }, - { "nowrecordingtitle", PVR_NOW_RECORDING_TITLE }, - { "nowrecordingdatetime", PVR_NOW_RECORDING_DATETIME }, - { "nowrecordingchannel", PVR_NOW_RECORDING_CHANNEL }, - { "nowrecordingchannelicon", PVR_NOW_RECORDING_CHAN_ICO }, - { "nextrecordingtitle", PVR_NEXT_RECORDING_TITLE }, - { "nextrecordingdatetime", PVR_NEXT_RECORDING_DATETIME }, - { "nextrecordingchannel", PVR_NEXT_RECORDING_CHANNEL }, - { "nextrecordingchannelicon", PVR_NEXT_RECORDING_CHAN_ICO }, { "backendname", PVR_BACKEND_NAME }, { "backendversion", PVR_BACKEND_VERSION }, { "backendhost", PVR_BACKEND_HOST }, @@ -4660,11 +4607,6 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "isplayingradio", PVR_IS_PLAYING_RADIO }, { "isplayingrecording", PVR_IS_PLAYING_RECORDING }, { "isplayingepgtag", PVR_IS_PLAYING_EPGTAG }, - { "epgeventduration", PVR_EPG_EVENT_DURATION }, - { "epgeventelapsedtime", PVR_EPG_EVENT_ELAPSED_TIME }, - { "epgeventremainingtime", PVR_EPG_EVENT_REMAINING_TIME }, - { "epgeventfinishtime", PVR_EPG_EVENT_FINISH_TIME }, - { "epgeventseektime", PVR_EPG_EVENT_SEEK_TIME }, { "epgeventprogress", PVR_EPG_EVENT_PROGRESS }, { "actstreamclient", PVR_ACTUAL_STREAM_CLIENT }, { "actstreamdevice", PVR_ACTUAL_STREAM_DEVICE }, @@ -4681,11 +4623,7 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "actstreammux", PVR_ACTUAL_STREAM_MUX }, { "actstreamprovidername", PVR_ACTUAL_STREAM_PROVIDER }, { "istimeshift", PVR_IS_TIMESHIFTING }, - { "timeshiftstart", PVR_TIMESHIFT_START_TIME }, - { "timeshiftend", PVR_TIMESHIFT_END_TIME }, - { "timeshiftcur", PVR_TIMESHIFT_PLAY_TIME }, { "timeshiftprogress", PVR_TIMESHIFT_PROGRESS }, - { "timeshiftoffset", PVR_TIMESHIFT_OFFSET }, { "nowrecordingtitle", PVR_NOW_RECORDING_TITLE }, { "nowrecordingdatetime", PVR_NOW_RECORDING_DATETIME }, { "nowrecordingchannel", PVR_NOW_RECORDING_CHANNEL }, @@ -4721,6 +4659,142 @@ const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING { "isrecordingplayingchannel", PVR_IS_RECORDING_PLAYING_CHANNEL }}; /// \page modules__General__List_of_gui_access +/// \section modules__General__List_of_gui_access_PvrTimes PvrTimes +/// @{ +/// \table_start +/// \table_h3{ Labels, Type, Description } +/// \table_row3{ <b>`PVR.EpgEventDuration`</b>, +/// \anchor PVR_EpgEventDuration +/// _string_, +/// Returns the duration of the currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.EpgEventDuration(format)`</b>, +/// \anchor PVR_EpgEventDuration_format +/// _string_, +/// Returns the duration of the currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.EpgEventElapsedTime`</b>, +/// \anchor PVR_EpgEventElapsedTime +/// _string_, +/// Returns the time of the current position of the currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.EpgEventElapsedTime(format)`</b>, +/// \anchor PVR_EpgEventElapsedTime_format +/// _string_, +/// Returns the time of the current position of the currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.EpgEventRemainingTime`</b>, +/// \anchor PVR_EpgEventRemainingTime +/// _string_, +/// Returns the remaining time for currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.EpgEventRemainingTime(format)`</b>, +/// \anchor PVR_EpgEventRemainingTime_format +/// _string_, +/// Returns the remaining time for currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.EpgEventSeekTime`</b>, +/// \anchor PVR_EpgEventSeekTime +/// _string_, +/// Returns the time the user is seeking within the currently playing epg event in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.EpgEventSeekTime(format)`</b>, +/// \anchor PVR_EpgEventSeekTime_format +/// _string_, +/// Returns the time the user is seeking within the currently playing epg event in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.EpgEventFinishTime`</b>, +/// \anchor PVR_EpgEventFinishTime +/// _string_, +/// Returns the time the currently playing epg event will end in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.EpgEventFinishTime(format)`</b>, +/// \anchor PVR_EpgEventFinishTime_format +/// _string_, +/// Returns the time the currently playing epg event will end in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.TimeShiftStart`</b>, +/// \anchor PVR_TimeShiftStart +/// _string_, +/// Returns the start time of the timeshift buffer in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.TimeShiftStart(format)`</b>, +/// \anchor PVR_TimeShiftStart_format +/// _string_, +/// Returns the start time of the timeshift buffer in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.TimeShiftEnd`</b>, +/// \anchor PVR_TimeShiftEnd +/// _string_, +/// Returns the end time of the timeshift buffer in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.TimeShiftEnd(format)`</b>, +/// \anchor PVR_TimeShiftEnd_format +/// _string_, +/// Returns the end time of the timeshift buffer in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.TimeShiftCur`</b>, +/// \anchor PVR_TimeShiftCur +/// _string_, +/// Returns the current playback time within the timeshift buffer in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.TimeShiftCur(format)`</b>, +/// \anchor PVR_TimeShiftCur_format +/// _string_, +/// Returns the current playback time within the timeshift buffer in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_row3{ <b>`PVR.TimeShiftOffset`</b>, +/// \anchor PVR_TimeShiftOffset +/// _string_, +/// Returns the delta of timeshifted time to actual time in the +/// format hh:mm:ss. hh: will be omitted if hours value is zero. +/// } +/// \table_row3{ <b>`PVR.TimeShiftOffset(format)`</b>, +/// \anchor PVR_TimeShiftOffset_format +/// _string_, +/// Returns the delta of timeshifted time to actual time in different formats: +/// Hours (hh)\, minutes (mm) or seconds (ss). When 12 hour clock is used (xx) will +/// return AM/PM. Also supported: (hh:mm)\, (mm:ss)\, (hh:mm:ss)\, (hh:mm:ss). +/// } +/// \table_end +/// +/// ----------------------------------------------------------------------------- +/// @} +const infomap pvr_times[] = {{ "epgeventduration", PVR_EPG_EVENT_DURATION }, + { "epgeventelapsedtime", PVR_EPG_EVENT_ELAPSED_TIME }, + { "epgeventremainingtime", PVR_EPG_EVENT_REMAINING_TIME }, + { "epgeventfinishtime", PVR_EPG_EVENT_FINISH_TIME }, + { "epgeventseektime", PVR_EPG_EVENT_SEEK_TIME }, + { "timeshiftstart", PVR_TIMESHIFT_START_TIME }, + { "timeshiftend", PVR_TIMESHIFT_END_TIME }, + { "timeshiftcur", PVR_TIMESHIFT_PLAY_TIME }, + { "timeshiftoffset", PVR_TIMESHIFT_OFFSET }}; + +/// \page modules__General__List_of_gui_access /// \section modules__General__List_of_gui_access_ADSP ADSP /// @{ /// \table_start @@ -5791,6 +5865,11 @@ int CGUIInfoManager::TranslateSingleString(const std::string &strCondition, bool if (prop.name == pvr[i].str) return pvr[i].val; } + for (size_t i = 0; i < sizeof(pvr_times) / sizeof(infomap); i++) + { + if (prop.name == pvr_times[i].str) + return AddMultiInfo(GUIInfo(pvr_times[i].val, TranslateTimeFormat(prop.param()))); + } } else if (cat.name == "adsp") { @@ -6000,14 +6079,6 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * switch (info) { - case PVR_NEXT_RECORDING_CHANNEL: - case PVR_NEXT_RECORDING_CHAN_ICO: - case PVR_NEXT_RECORDING_DATETIME: - case PVR_NEXT_RECORDING_TITLE: - case PVR_NOW_RECORDING_CHANNEL: - case PVR_NOW_RECORDING_CHAN_ICO: - case PVR_NOW_RECORDING_DATETIME: - case PVR_NOW_RECORDING_TITLE: case PVR_BACKEND_NAME: case PVR_BACKEND_VERSION: case PVR_BACKEND_HOST: @@ -6019,10 +6090,6 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * case PVR_BACKEND_NUMBER: case PVR_TOTAL_DISKSPACE: case PVR_NEXT_TIMER: - case PVR_EPG_EVENT_DURATION: - case PVR_EPG_EVENT_ELAPSED_TIME: - case PVR_EPG_EVENT_REMAINING_TIME: - case PVR_EPG_EVENT_FINISH_TIME: case PVR_EPG_EVENT_PROGRESS: case PVR_ACTUAL_STREAM_CLIENT: case PVR_ACTUAL_STREAM_DEVICE: @@ -6037,10 +6104,14 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * case PVR_ACTUAL_STREAM_SERVICE: case PVR_ACTUAL_STREAM_MUX: case PVR_ACTUAL_STREAM_PROVIDER: - case PVR_TIMESHIFT_START_TIME: - case PVR_TIMESHIFT_END_TIME: - case PVR_TIMESHIFT_PLAY_TIME: - case PVR_TIMESHIFT_OFFSET: + case PVR_NOW_RECORDING_TITLE: + case PVR_NOW_RECORDING_CHANNEL: + case PVR_NOW_RECORDING_CHAN_ICO: + case PVR_NOW_RECORDING_DATETIME: + case PVR_NEXT_RECORDING_TITLE: + case PVR_NEXT_RECORDING_CHANNEL: + case PVR_NEXT_RECORDING_CHAN_ICO: + case PVR_NEXT_RECORDING_DATETIME: case PVR_TV_NOW_RECORDING_TITLE: case PVR_TV_NOW_RECORDING_CHANNEL: case PVR_TV_NOW_RECORDING_CHAN_ICO: @@ -6059,9 +6130,6 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string * case PVR_RADIO_NEXT_RECORDING_DATETIME: CServiceBroker::GetPVRManager().TranslateCharInfo(m_currentFile, info, strLabel); break; - case PVR_EPG_EVENT_SEEK_TIME: - CServiceBroker::GetPVRManager().GetSeekTimeLabel(g_application.GetAppPlayer().GetSeekHandler().GetSeekSize(), strLabel); - break; case PVR_CHANNEL_NUMBER_INPUT: strLabel = CServiceBroker::GetPVRManager().GUIActions()->GetChannelNumberInputHandler().GetChannelNumberAsString(); break; @@ -8025,6 +8093,10 @@ CGUIControl* CGUIInfoManager::GetActiveContainer(int containerId, int contextWin /// \brief Examines the multi information sent and returns the string as appropriate std::string CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, std::string *fallback) { + std::string strValue; + if (CServiceBroker::GetPVRManager().GetMultiInfoLabel(m_currentFile, info, strValue)) + return strValue; + if (info.m_info == SKIN_STRING) { return CSkinSettings::GetInstance().GetString(info.GetData1()); @@ -8087,6 +8159,14 @@ std::string CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextW { return GetCurrentSeekTime((TIME_FORMAT)info.GetData1()); } + else if (info.m_info == PVR_EPG_EVENT_SEEK_TIME) + { + std::string strLabel; + CServiceBroker::GetPVRManager().GetSeekTimeLabel(g_application.GetAppPlayer().GetSeekHandler().GetSeekSize(), + static_cast<TIME_FORMAT>(info.GetData1()), + strLabel); + return strLabel; + } else if (info.m_info == PLAYER_SEEKOFFSET) { std::string seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset / 1000), (TIME_FORMAT)info.GetData1()); diff --git a/xbmc/GUIInfoManager.h b/xbmc/GUIInfoManager.h index 0656d26742..444fab331c 100644 --- a/xbmc/GUIInfoManager.h +++ b/xbmc/GUIInfoManager.h @@ -20,6 +20,7 @@ #pragma once #include "threads/CriticalSection.h" +#include "guiinfo/GUIInfo.h" #include "guilib/IMsgTargetCallback.h" #include "guilib/GUIControl.h" #include "messaging/IMessageTarget.h" @@ -54,33 +55,6 @@ namespace INFO // forward class CGUIWindow; -// 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 diff --git a/xbmc/guiinfo/CMakeLists.txt b/xbmc/guiinfo/CMakeLists.txt index 4c01446be3..b52dbe9f71 100644 --- a/xbmc/guiinfo/CMakeLists.txt +++ b/xbmc/guiinfo/CMakeLists.txt @@ -1,4 +1,5 @@ -set(HEADERS GUIInfoLabels.h) +set(HEADERS GUIInfo.h + GUIInfoLabels.h) if(NOT ENABLE_STATIC_LIBS) core_add_library(guiinfo) diff --git a/xbmc/guiinfo/GUIInfo.h b/xbmc/guiinfo/GUIInfo.h new file mode 100644 index 0000000000..d7d0ac8a28 --- /dev/null +++ b/xbmc/guiinfo/GUIInfo.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * 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/>. + * + */ +#pragma once + +// 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; +}; diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index 8cca15d8e7..eacb089e4f 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -26,6 +26,7 @@ #include "Application.h" #include "ServiceBroker.h" #include "cores/DataCacheCore.h" +#include "guiinfo/GUIInfo.h" #include "guiinfo/GUIInfoLabels.h" #include "guilib/LocalizeStrings.h" #include "settings/AdvancedSettings.h" @@ -90,9 +91,6 @@ void CPVRGUIInfo::ResetProperties(void) m_iTimeshiftEndTime = time_t(0); m_iTimeshiftPlayTime = time_t(0); m_iTimeshiftOffset = 0; - m_strTimeshiftStartTime.clear(); - m_strTimeshiftEndTime.clear(); - m_strTimeshiftPlayTime.clear(); ResetPlayingTag(); ClearQualityInfo(m_qualityInfo); @@ -264,9 +262,6 @@ void CPVRGUIInfo::UpdateTimeshift(void) m_iTimeshiftPlayTime = 0; m_iLastTimeshiftUpdate = 0; m_iTimeshiftOffset = 0; - m_strTimeshiftStartTime.clear(); - m_strTimeshiftEndTime.clear(); - m_strTimeshiftPlayTime.clear(); } return; } @@ -309,16 +304,6 @@ void CPVRGUIInfo::UpdateTimeshift(void) m_iTimeshiftOffset = now - m_iTimeshiftPlayTime; - CDateTime tmp; - tmp.SetFromUTCDateTime(m_iTimeshiftStartTime); - m_strTimeshiftStartTime = tmp.GetAsLocalizedTime("", false); - - tmp.SetFromUTCDateTime(m_iTimeshiftEndTime); - m_strTimeshiftEndTime = tmp.GetAsLocalizedTime("", false); - - tmp.SetFromUTCDateTime(m_iTimeshiftPlayTime); - m_strTimeshiftPlayTime = tmp.GetAsLocalizedTime("", true); - m_bHasTimeshiftData = true; } @@ -401,18 +386,6 @@ bool CPVRGUIInfo::TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::st case PVR_RADIO_NEXT_RECORDING_DATETIME: m_radioTimersInfo.CharInfoNextTimerDateTime(strValue); break; - case PVR_EPG_EVENT_DURATION: - CharInfoEpgEventDuration(item, strValue); - break; - case PVR_EPG_EVENT_ELAPSED_TIME: - CharInfoEpgEventElapsedTime(item, strValue); - break; - case PVR_EPG_EVENT_REMAINING_TIME: - CharInfoEpgEventRemainingTime(item, strValue); - break; - case PVR_EPG_EVENT_FINISH_TIME: - CharInfoEpgEventFinishTime(item, strValue); - break; case PVR_NEXT_TIMER: m_anyTimersInfo.CharInfoNextTimer(strValue); break; @@ -479,18 +452,6 @@ bool CPVRGUIInfo::TranslateCharInfo(const CFileItem *item, DWORD dwInfo, std::st case PVR_TOTAL_DISKSPACE: CharInfoTotalDiskSpace(strValue); break; - case PVR_TIMESHIFT_START_TIME: - CharInfoTimeshiftStartTime(strValue); - break; - case PVR_TIMESHIFT_END_TIME: - CharInfoTimeshiftEndTime(strValue); - break; - case PVR_TIMESHIFT_PLAY_TIME: - CharInfoTimeshiftPlayTime(strValue); - break; - case PVR_TIMESHIFT_OFFSET: - CharInfoTimeshiftOffset(strValue); - break; default: strValue.clear(); bReturn = false; @@ -648,6 +609,7 @@ bool CPVRGUIInfo::GetVideoLabel(const CFileItem *item, int iLabel, std::string & } case VIDEOPLAYER_CHANNEL_GROUP: { + CSingleLock lock(m_critSection); strValue = recording->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup; return true; } @@ -821,6 +783,7 @@ bool CPVRGUIInfo::GetVideoLabel(const CFileItem *item, int iLabel, std::string & } case VIDEOPLAYER_CHANNEL_GROUP: { + CSingleLock lock(m_critSection); strValue = channel->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup; return true; } @@ -847,33 +810,86 @@ bool CPVRGUIInfo::GetVideoLabel(const CFileItem *item, int iLabel, std::string & return false; } -bool CPVRGUIInfo::GetSeekTimeLabel(int iSeekSize, std::string &strValue) const +bool CPVRGUIInfo::GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const { - strValue = StringUtils::SecondsToTimeString(GetElapsedTime() + iSeekSize, TIME_FORMAT_GUESS).c_str(); + CSingleLock lock(m_critSection); + + switch (info.m_info) + { + case PVR_EPG_EVENT_DURATION: + CharInfoEpgEventDuration(item, static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + case PVR_EPG_EVENT_ELAPSED_TIME: + CharInfoEpgEventElapsedTime(item, static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + case PVR_EPG_EVENT_REMAINING_TIME: + CharInfoEpgEventRemainingTime(item, static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + case PVR_EPG_EVENT_FINISH_TIME: + CharInfoEpgEventFinishTime(item, static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_START_TIME: + CharInfoTimeshiftStartTime(static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_END_TIME: + CharInfoTimeshiftEndTime(static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_PLAY_TIME: + CharInfoTimeshiftPlayTime(static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + case PVR_TIMESHIFT_OFFSET: + CharInfoTimeshiftOffset(static_cast<TIME_FORMAT>(info.GetData1()), strValue); + break; + default: + return false; + } + return true; +} + +bool CPVRGUIInfo::GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const +{ + CSingleLock lock(m_critSection); + strValue = StringUtils::SecondsToTimeString(GetElapsedTime() + iSeekSize, format).c_str(); return true; } -void CPVRGUIInfo::CharInfoTimeshiftStartTime(std::string &strValue) const +namespace +{ + int TimeFromDateTime(time_t datetime) + { + CDateTime time; + time.SetFromUTCDateTime(datetime); + return time.GetHour() * 60 * 60 + time.GetMinute() * 60 + time.GetSecond(); + } +} // unnamed namespace + +void CPVRGUIInfo::CharInfoTimeshiftStartTime(TIME_FORMAT format, std::string &strValue) const { - strValue = m_strTimeshiftStartTime; + if (format == TIME_FORMAT_GUESS) + format = TIME_FORMAT_HH_MM; + + strValue = StringUtils::SecondsToTimeString(TimeFromDateTime(m_iTimeshiftStartTime), format).c_str(); } -void CPVRGUIInfo::CharInfoTimeshiftEndTime(std::string &strValue) const +void CPVRGUIInfo::CharInfoTimeshiftEndTime(TIME_FORMAT format, std::string &strValue) const { - strValue = m_strTimeshiftEndTime; + if (format == TIME_FORMAT_GUESS) + format = TIME_FORMAT_HH_MM; + + strValue = StringUtils::SecondsToTimeString(TimeFromDateTime(m_iTimeshiftEndTime), format).c_str(); } -void CPVRGUIInfo::CharInfoTimeshiftPlayTime(std::string &strValue) const +void CPVRGUIInfo::CharInfoTimeshiftPlayTime(TIME_FORMAT format, std::string &strValue) const { - strValue = m_strTimeshiftPlayTime; + strValue = StringUtils::SecondsToTimeString(TimeFromDateTime(m_iTimeshiftPlayTime), format).c_str(); } -void CPVRGUIInfo::CharInfoTimeshiftOffset(std::string &strValue) const +void CPVRGUIInfo::CharInfoTimeshiftOffset(TIME_FORMAT format, std::string &strValue) const { - strValue = StringUtils::SecondsToTimeString(m_iTimeshiftOffset, TIME_FORMAT_GUESS).c_str(); + strValue = StringUtils::SecondsToTimeString(m_iTimeshiftOffset, format).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventDuration(const CFileItem *item, std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventDuration(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const { int iDuration = 0; CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); @@ -882,10 +898,10 @@ void CPVRGUIInfo::CharInfoEpgEventDuration(const CFileItem *item, std::string &s else iDuration = m_iDuration; - strValue = StringUtils::SecondsToTimeString(iDuration, TIME_FORMAT_GUESS).c_str(); + strValue = StringUtils::SecondsToTimeString(iDuration, format).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventElapsedTime(const CFileItem *item, std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventElapsedTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const { int iElapsed = 0; CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); @@ -894,10 +910,10 @@ void CPVRGUIInfo::CharInfoEpgEventElapsedTime(const CFileItem *item, std::string else iElapsed = GetElapsedTime(); - strValue = StringUtils::SecondsToTimeString(iElapsed, TIME_FORMAT_GUESS).c_str(); + strValue = StringUtils::SecondsToTimeString(iElapsed, format).c_str(); } -void CPVRGUIInfo::CharInfoEpgEventRemainingTime(const CFileItem *item, std::string &strValue) const +int CPVRGUIInfo::GetRemainingTime(const CFileItem *item) const { int iRemaining = 0; CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); @@ -906,21 +922,22 @@ void CPVRGUIInfo::CharInfoEpgEventRemainingTime(const CFileItem *item, std::stri else iRemaining = m_iDuration - GetElapsedTime(); - strValue = StringUtils::SecondsToTimeString(iRemaining, TIME_FORMAT_GUESS).c_str(); + return iRemaining; } -void CPVRGUIInfo::CharInfoEpgEventFinishTime(const CFileItem *item, std::string &strValue) const +void CPVRGUIInfo::CharInfoEpgEventRemainingTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const { - int iFinish = 0; - CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); - if (epgTag && epgTag != m_playingEpgTag) - iFinish = epgTag->GetDuration() - epgTag->Progress(); - else - iFinish = m_iDuration - GetElapsedTime(); + strValue = StringUtils::SecondsToTimeString(GetRemainingTime(item), format).c_str(); +} + +void CPVRGUIInfo::CharInfoEpgEventFinishTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const +{ + if (format == TIME_FORMAT_GUESS) + format = TIME_FORMAT_HH_MM; - CDateTime finishTime = CDateTime::GetCurrentDateTime(); - finishTime += CDateTimeSpan(0, 0, 0, iFinish); - strValue = finishTime.GetAsLocalizedTime("", false); + CDateTime finish = CDateTime::GetCurrentDateTime(); + finish += CDateTimeSpan(0, 0, 0, GetRemainingTime(item)); + strValue = StringUtils::SecondsToTimeString(finish.GetHour() * 60 * 60 + finish.GetMinute() * 60 + finish.GetSecond(), format).c_str(); } void CPVRGUIInfo::CharInfoBackendNumber(std::string &strValue) const diff --git a/xbmc/pvr/PVRGUIInfo.h b/xbmc/pvr/PVRGUIInfo.h index 76fe21e99f..2f6213346c 100644 --- a/xbmc/pvr/PVRGUIInfo.h +++ b/xbmc/pvr/PVRGUIInfo.h @@ -31,6 +31,8 @@ #include "pvr/PVRTypes.h" #include "pvr/addons/PVRClients.h" +class GUIInfo; + namespace PVR { class CPVRGUIInfo : private CThread, @@ -59,12 +61,22 @@ namespace PVR bool GetVideoLabel(const CFileItem *item, int iLabel, std::string &strValue) const; /*! + * @brief Get a GUIInfoManager multi info label. + * @param item The item to get the label for. + * @param info The GUI info (label id + additional data). + * @param strValue Will be filled with the requested label value. + * @return True if the requested label value was set, false otherwise. + */ + bool GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const; + + /*! * @brief Get a GUIInfoManager seek time label for the currently playing epg tag. * @param iSeekSize The seconds to be seeked from the current playback position. + * @param format The time format for the label. * @param strValue Will be filled with the requested label value. * @return True if the label value was set, false otherwise. */ - bool GetSeekTimeLabel(int iSeekSize, std::string &strValue) const; + bool GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const; /*! * @brief Get the total duration of the currently playing epg event or if no epg is @@ -198,10 +210,10 @@ namespace PVR void UpdateTimersToggle(void); - void CharInfoEpgEventDuration(const CFileItem *item, std::string &strValue) const; - void CharInfoEpgEventElapsedTime(const CFileItem *item, std::string &strValue) const; - void CharInfoEpgEventRemainingTime(const CFileItem *item, std::string &strValue) const; - void CharInfoEpgEventFinishTime(const CFileItem *item, std::string &strValue) const; + void CharInfoEpgEventDuration(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; + void CharInfoEpgEventElapsedTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; + void CharInfoEpgEventRemainingTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; + void CharInfoEpgEventFinishTime(const CFileItem *item, TIME_FORMAT format, std::string &strValue) const; void CharInfoBackendNumber(std::string &strValue) const; void CharInfoTotalDiskSpace(std::string &strValue) const; void CharInfoSignal(std::string &strValue) const; @@ -223,10 +235,12 @@ namespace PVR void CharInfoService(std::string &strValue) const; void CharInfoMux(std::string &strValue) const; void CharInfoProvider(std::string &strValue) const; - void CharInfoTimeshiftStartTime(std::string &strValue) const; - void CharInfoTimeshiftEndTime(std::string &strValue) const; - void CharInfoTimeshiftPlayTime(std::string &strValue) const; - void CharInfoTimeshiftOffset(std::string &strValue) const; + void CharInfoTimeshiftStartTime(TIME_FORMAT format, std::string &strValue) const; + void CharInfoTimeshiftEndTime(TIME_FORMAT format, std::string &strValue) const; + void CharInfoTimeshiftPlayTime(TIME_FORMAT format, std::string &strValue) const; + void CharInfoTimeshiftOffset(TIME_FORMAT format, std::string &strValue) const; + + int GetRemainingTime(const CFileItem *item) const; /** @name GUIInfoManager data */ //@{ @@ -275,9 +289,6 @@ namespace PVR time_t m_iTimeshiftEndTime; time_t m_iTimeshiftPlayTime; unsigned int m_iTimeshiftOffset; - std::string m_strTimeshiftStartTime; - std::string m_strTimeshiftEndTime; - std::string m_strTimeshiftPlayTime; CCriticalSection m_critSection; diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 9a1abd811e..32f13df9d7 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -829,9 +829,14 @@ bool CPVRManager::GetVideoLabel(const CFileItem *item, int iLabel, std::string & return IsStarted() && m_guiInfo ? m_guiInfo->GetVideoLabel(item, iLabel, strValue) : false; } -bool CPVRManager::GetSeekTimeLabel(int iSeekSize, std::string &strValue) const +bool CPVRManager::GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const { - return IsStarted() && m_guiInfo ? m_guiInfo->GetSeekTimeLabel(iSeekSize, strValue) : false; + return IsStarted() && m_guiInfo ? m_guiInfo->GetMultiInfoLabel(item, info, strValue) : false; +} + +bool CPVRManager::GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const +{ + return IsStarted() && m_guiInfo ? m_guiInfo->GetSeekTimeLabel(iSeekSize, format, strValue) : false; } bool CPVRManager::IsRecording(void) const diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 1344f0cd84..3b24923d62 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -42,6 +42,7 @@ class CStopWatch; class CVariant; +class GUIInfo; namespace PVR { @@ -194,12 +195,22 @@ namespace PVR bool GetVideoLabel(const CFileItem *item, int iLabel, std::string &strValue) const; /*! + * @brief Get a GUIInfoManager multi info label. + * @param item The item to get the label for. + * @param info The GUI info (label id + additional data). + * @param strValue Will be filled with the requested label value. + * @return True if the requested label value was set, false otherwise. + */ + bool GetMultiInfoLabel(const CFileItem *item, const GUIInfo &info, std::string &strValue) const; + + /*! * @brief Get a GUIInfoManager seek time label for the currently playing epg tag. * @param iSeekSize The seconds to be seeked from the current playback position. + * @param format The time format for the label. * @param strValue Will be filled with the requested label value. * @return True if the label value was set, false otherwise. */ - bool GetSeekTimeLabel(int iSeekSize, std::string &strValue) const; + bool GetSeekTimeLabel(int iSeekSize, TIME_FORMAT format, std::string &strValue) const; /*! * @brief Check if a TV channel, radio channel or recording is playing. |