diff options
author | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2015-07-07 20:11:39 +0200 |
---|---|---|
committer | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2015-07-07 20:11:39 +0200 |
commit | 73bfc9508f7f1d36bd6b7f1b7c2cbbbdcb4acf47 (patch) | |
tree | 67506ecd36f2109efafa1bd8f655ca6dc233a237 | |
parent | 5143b8853f13e9000dc548b25aabed00577f7ce8 (diff) | |
parent | 1bcdc418d4bc25fa2f96ac85b9633ffb78a506fe (diff) |
Merge pull request #7439 from ksooo/pr7079-followup
[PVR] Series Recordings - Coverity / Code Cleanup
-rw-r--r-- | xbmc/GUIInfoManager.cpp | 2 | ||||
-rw-r--r-- | xbmc/addons/include/xbmc_pvr_types.h | 25 | ||||
-rw-r--r-- | xbmc/epg/EpgInfoTag.cpp | 2 | ||||
-rw-r--r-- | xbmc/pvr/addons/PVRClient.cpp | 3 | ||||
-rw-r--r-- | xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp | 277 | ||||
-rw-r--r-- | xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h | 2 | ||||
-rw-r--r-- | xbmc/pvr/timers/PVRTimerInfoTag.cpp | 39 | ||||
-rw-r--r-- | xbmc/pvr/timers/PVRTimerInfoTag.h | 23 | ||||
-rw-r--r-- | xbmc/pvr/timers/PVRTimerType.cpp | 6 | ||||
-rw-r--r-- | xbmc/pvr/timers/PVRTimers.cpp | 4 | ||||
-rw-r--r-- | xbmc/pvr/windows/GUIWindowPVRBase.cpp | 3 |
11 files changed, 191 insertions, 195 deletions
diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 05eb0548fa..6b3100cb2b 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -5459,7 +5459,7 @@ bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const { CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem); if (timer && timer->HasPVRTimerInfoTag()) - return timer->GetPVRTimerInfoTag()->IsRepeating(); + return timer->GetPVRTimerInfoTag()->GetTimerScheduleId() > 0; } } else if (condition == LISTITEM_HASRECORDING) diff --git a/xbmc/addons/include/xbmc_pvr_types.h b/xbmc/addons/include/xbmc_pvr_types.h index ace01954c8..7d51fc292f 100644 --- a/xbmc/addons/include/xbmc_pvr_types.h +++ b/xbmc/addons/include/xbmc_pvr_types.h @@ -71,7 +71,7 @@ struct DemuxPacket; #define PVR_ADDON_INPUT_FORMAT_STRING_LENGTH 32 #define PVR_ADDON_EDL_LENGTH 32 #define PVR_ADDON_TIMERTYPE_ARRAY_SIZE 32 -#define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE 512 +#define PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE 64 #define PVR_ADDON_TIMERTYPE_STRING_LENGTH 64 /* using the default avformat's MAX_STREAMS value to be safe */ @@ -93,6 +93,16 @@ extern "C" { const unsigned int PVR_TIMER_TYPE_NONE = 0; /*!< @brief "Null" value for a numeric timer type. */ /*! + * @brief special PVR_TIMER.iParentClientIndex value to indicate that a timer has no parent. + */ + const unsigned int PVR_TIMER_NO_PARENT = 0; /*!< @brief timer has no parent; it was not scheduled by a repeating timer. */ + + /*! + * @brief special PVR_TIMER.iClientChannelUid value to indicate "any channel". Useful for some repeating timer types. + */ + const int PVR_TIMER_ANY_CHANNEL = -1; /*!< @brief denotes "any channel", not a specific one. */ + + /*! * @brief PVR timer type attributes (PVR_TIMER_TYPE.iAttributes values) */ const unsigned int PVR_TIMER_TYPE_ATTRIBUTE_NONE = 0x00000000; @@ -350,11 +360,11 @@ extern "C" { unsigned int iPreventDuplicateEpisodesDefault; /*!< @brief (optional) The default value for PVR_TMER.iPreventDuplicateEpisodesSize. Must be filled if iPreventDuplicateEpisodesSize > 0 */ /* recording folder list value definitions */ - unsigned int iRecordingGroupSize; /*< @brief (required) Count of possible values of PVR_TIMER.iRecordingGroup. 0 means folder lists are not supported by this timer type */ + unsigned int iRecordingGroupSize; /*!< @brief (required) Count of possible values of PVR_TIMER.iRecordingGroup. 0 means folder lists are not supported by this timer type */ PVR_TIMER_TYPE_ATTRIBUTE_INT_VALUE recordingGroup[PVR_ADDON_TIMERTYPE_VALUES_ARRAY_SIZE]; /*!< @brief (optional) Array containing the possible values of PVR_TMER.iRecordingGroup. Must be filled if iRecordingGroupSize > 0 */ - unsigned int iRecordingGroupDefault; /*! @brief (optional) The default value for PVR_TIMER.iRecordingGroup. Must be filled in if PVR_TIMER.iRecordingGroupSize > 0 */ + unsigned int iRecordingGroupDefault; /*!< @brief (optional) The default value for PVR_TIMER.iRecordingGroup. Must be filled in if PVR_TIMER.iRecordingGroupSize > 0 */ } ATTRIBUTE_PACKED PVR_TIMER_TYPE; @@ -363,12 +373,15 @@ extern "C" { */ typedef struct PVR_TIMER { unsigned int iClientIndex; /*!< @brief (required) the index of this timer given by the client */ - unsigned int iParentClientIndex; /*!< @brief (optional) for timers scheduled by a repeating timer, the index of the repeating that scheduled this timer. 0 indicates "no parent". */ - int iClientChannelUid; /*!< @brief (optional) unique identifier of the channel to record on. For repeating timers, -1 will indicate "any" channel. */ + unsigned int iParentClientIndex; /*!< @brief (optional) for timers scheduled by a repeating timer, the index of the repeating timer that scheduled this timer (it's PVR_TIMER.iClientIndex value). Use PVR_TIMER_NO_PARENT + to indicate that this timer was no scheduled by a repeating timer. */ + int iClientChannelUid; /*!< @brief (optional) unique identifier of the channel to record on. PVR_TIMER_ANY_CHANNEL will denote "any channel", not a specifoc one. */ time_t startTime; /*!< @brief (optional) start time of the recording in UTC. Instant timers that are sent to the add-on by Kodi will have this value set to 0. For repeatimg timers, 0 will indicate "any" time. */ time_t endTime; /*!< @brief (optional) end time of the recording in UTC. For repeating timers, 0 will indicate "any" time. */ PVR_TIMER_STATE state; /*!< @brief (required) the state of this timer */ - unsigned int iTimerType; /*!< @brief (required) the type of this timer */ + unsigned int iTimerType; /*!< @brief (required) the type of this timer. It is private to the addon and can be freely defined by the addon. The value must be greater than PVR_TIMER_TYPE_NONE. + Kodi does not interpret this value (except for checking for PVR_TIMER_TYPE_NONE), but will pass the right id to the addon with every PVR_TIMER instance, thus the addon easily can determine + the timer type. */ char strTitle[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (required) a title for this timer */ char strEpgSearchString[PVR_ADDON_NAME_STRING_LENGTH]; /*!< @brief (optional) a string used to search epg data for repeating epg-based timers. Format is backend-dependent, for example regexp */ bool bFullTextEpgSearch; /*!< @brief (optional) indicates, whether strEpgSearchString is to match against the epg episode title only or also against "other" epg data (backend-dependent) */ diff --git a/xbmc/epg/EpgInfoTag.cpp b/xbmc/epg/EpgInfoTag.cpp index 596265d44b..dc2886e823 100644 --- a/xbmc/epg/EpgInfoTag.cpp +++ b/xbmc/epg/EpgInfoTag.cpp @@ -524,7 +524,7 @@ bool CEpgInfoTag::HasTimer(void) const bool CEpgInfoTag::HasTimerSchedule(void) const { CSingleLock lock(m_critSection); - return m_timer && (m_timer->m_iParentClientIndex > 0); + return m_timer && (m_timer->GetTimerScheduleId() != PVR_TIMER_NO_PARENT); } CPVRTimerInfoTagPtr CEpgInfoTag::Timer(void) const diff --git a/xbmc/pvr/addons/PVRClient.cpp b/xbmc/pvr/addons/PVRClient.cpp index 15421905d9..6c0a22d33c 100644 --- a/xbmc/pvr/addons/PVRClient.cpp +++ b/xbmc/pvr/addons/PVRClient.cpp @@ -1286,6 +1286,9 @@ PVR_ERROR CPVRClient::UpdateTimer(const CPVRTimerInfoTag &timer) PVR_ERROR CPVRClient::GetTimerTypes(CPVRTimerTypes& results) const { + if (!m_bReadyToUse) + return PVR_ERROR_REJECTED; + results = m_timertypes; return PVR_ERROR_NO_ERROR; } diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp index beaaeafc7f..486e2ab103 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.cpp @@ -86,7 +86,6 @@ CGUIDialogPVRTimerSettings::CGUIDialogPVRTimerSettings() : m_loadType = LOAD_EVERY_TIME; } -// virtual CGUIDialogPVRTimerSettings::~CGUIDialogPVRTimerSettings() { } @@ -202,14 +201,12 @@ void CGUIDialogPVRTimerSettings::SetTimer(CFileItem *item) CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::SetTimer - No timer type!"); } -// virtual void CGUIDialogPVRTimerSettings::SetupView() { CGUIDialogSettingsManualBase::SetupView(); SetButtonLabels(); } -// virtual void CGUIDialogPVRTimerSettings::InitializeSettings() { CGUIDialogSettingsManualBase::InitializeSettings(); @@ -348,7 +345,6 @@ void CGUIDialogPVRTimerSettings::InitializeSettings() AddTypeDependentEnableCondition(setting, SETTING_TMR_REC_GROUP); } -// virtual void CGUIDialogPVRTimerSettings::OnSettingChanged(const CSetting *setting) { if (setting == NULL) @@ -363,7 +359,7 @@ void CGUIDialogPVRTimerSettings::OnSettingChanged(const CSetting *setting) if (settingId == SETTING_TMR_TYPE) { - int idx = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + int idx = static_cast<const CSettingInt*>(setting)->GetValue(); const auto it = m_typeEntries.find(idx); if (it != m_typeEntries.end()) { @@ -379,23 +375,23 @@ void CGUIDialogPVRTimerSettings::OnSettingChanged(const CSetting *setting) } else if (settingId == SETTING_TMR_ACTIVE) { - m_bTimerActive = dynamic_cast<const CSettingBool*>(setting)->GetValue(); + m_bTimerActive = static_cast<const CSettingBool*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_NAME) { - m_strTitle = dynamic_cast<const CSettingString*>(setting)->GetValue(); + m_strTitle = static_cast<const CSettingString*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_EPGSEARCH) { - m_strEpgSearchString = dynamic_cast<const CSettingString*>(setting)->GetValue(); + m_strEpgSearchString = static_cast<const CSettingString*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_FULLTEXT) { - m_bFullTextEpgSearch = dynamic_cast<const CSettingBool*>(setting)->GetValue(); + m_bFullTextEpgSearch = static_cast<const CSettingBool*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_CHANNEL) { - int idx = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + int idx = static_cast<const CSettingInt*>(setting)->GetValue(); const auto it = m_channelEntries.find(idx); if (it != m_channelEntries.end()) { @@ -408,7 +404,7 @@ void CGUIDialogPVRTimerSettings::OnSettingChanged(const CSetting *setting) } else if (settingId == SETTING_TMR_WEEKDAYS) { - const CSettingList *settingList = dynamic_cast<const CSettingList*>(setting); + const CSettingList *settingList = static_cast<const CSettingList*>(setting); if (settingList->GetElementType() != SettingTypeInteger) { CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::OnSettingChanged - wrong weekdays element type"); @@ -429,51 +425,50 @@ void CGUIDialogPVRTimerSettings::OnSettingChanged(const CSetting *setting) } else if (settingId == SETTING_TMR_ANYTIME) { - m_bStartAnytime = m_bEndAnytime = dynamic_cast<const CSettingBool*>(setting)->GetValue(); + m_bStartAnytime = m_bEndAnytime = static_cast<const CSettingBool*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_START_DAY) { - SetDateFromInt(m_startLocalTime, dynamic_cast<const CSettingInt*>(setting)->GetValue()); + SetDateFromInt(m_startLocalTime, static_cast<const CSettingInt*>(setting)->GetValue()); } else if (settingId == SETTING_TMR_END_DAY) { - SetDateFromInt(m_endLocalTime, dynamic_cast<const CSettingInt*>(setting)->GetValue()); + SetDateFromInt(m_endLocalTime, static_cast<const CSettingInt*>(setting)->GetValue()); } else if (settingId == SETTING_TMR_FIRST_DAY) { - SetDateFromInt(m_firstDayLocalTime, dynamic_cast<const CSettingInt*>(setting)->GetValue()); + SetDateFromInt(m_firstDayLocalTime, static_cast<const CSettingInt*>(setting)->GetValue()); } else if (settingId == SETTING_TMR_NEW_EPISODES) { - m_iPreventDupEpisodes = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + m_iPreventDupEpisodes = static_cast<const CSettingInt*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_BEGIN_PRE) { - m_iMarginStart = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + m_iMarginStart = static_cast<const CSettingInt*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_END_POST) { - m_iMarginEnd = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + m_iMarginEnd = static_cast<const CSettingInt*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_PRIORITY) { - m_iPriority = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + m_iPriority = static_cast<const CSettingInt*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_LIFETIME) { - m_iLifetime = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + m_iLifetime = static_cast<const CSettingInt*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_DIR) { - m_strDirectory = dynamic_cast<const CSettingString*>(setting)->GetValue(); + m_strDirectory = static_cast<const CSettingString*>(setting)->GetValue(); } else if (settingId == SETTING_TMR_REC_GROUP) { - m_iRecordingGroup = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + m_iRecordingGroup = static_cast<const CSettingInt*>(setting)->GetValue(); } } -// virtual void CGUIDialogPVRTimerSettings::OnSettingAction(const CSetting *setting) { if (setting == NULL) @@ -509,7 +504,6 @@ void CGUIDialogPVRTimerSettings::OnSettingAction(const CSetting *setting) } } -// virtual void CGUIDialogPVRTimerSettings::Save() { // Timer type @@ -552,16 +546,14 @@ void CGUIDialogPVRTimerSettings::Save() bool bEndSet(false); if ((m_bStartAnytime || m_bEndAnytime) && m_timerType->IsRepeatingEpgBased()) { - time_t time = 0; - CDateTime datetime(time); if (m_bStartAnytime) { - m_timerInfoTag->SetStartFromUTC(datetime); + m_timerInfoTag->SetStartAtAnyTime(); bStartSet = true; } if (m_bEndAnytime) { - m_timerInfoTag->SetEndFromUTC(datetime); + m_timerInfoTag->SetEndAtAnyTime(); bEndSet = true; } } @@ -668,7 +660,6 @@ void CGUIDialogPVRTimerSettings::AddCondition( setting->SetDependencies(deps); } -// static int CGUIDialogPVRTimerSettings::GetDateAsInt(const CDateTime &datetime) { const CDateTime date(datetime.GetYear(), datetime.GetMonth(), datetime.GetDay(), 0, 0, 0); @@ -677,7 +668,6 @@ int CGUIDialogPVRTimerSettings::GetDateAsInt(const CDateTime &datetime) return static_cast<int>(t); } -// static void CGUIDialogPVRTimerSettings::SetDateFromInt(CDateTime &datetime, int date) { const CDateTime newDate(static_cast<time_t>(date)); @@ -686,7 +676,6 @@ void CGUIDialogPVRTimerSettings::SetDateFromInt(CDateTime &datetime, int date) datetime.GetHour(), datetime.GetMinute(), datetime.GetSecond()); } -// static void CGUIDialogPVRTimerSettings::SetTimeFromSystemTime(CDateTime &datetime, const SYSTEMTIME &time) { const CDateTime newTime(time); @@ -695,7 +684,6 @@ void CGUIDialogPVRTimerSettings::SetTimeFromSystemTime(CDateTime &datetime, cons newTime.GetHour(), newTime.GetMinute(), newTime.GetSecond()); } -// static CDateTime CGUIDialogPVRTimerSettings::InitializeDateTime(const CDateTime &datetime) { const CDateTime now(CDateTime::GetCurrentDateTime()); @@ -757,194 +745,176 @@ void CGUIDialogPVRTimerSettings::InitializeChannelsList() ENTRY_ANY_CHANNEL, ChannelDescriptor(PVR_INVALID_CHANNEL_UID, 0, g_localizeStrings.Get(809)))); } -// static void CGUIDialogPVRTimerSettings::TypesFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) - { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::TypesFiller - No dialog"); - return; - } - - list.clear(); - current = 0; - - bool foundCurrent(false); - for (const auto &typeEntry : pThis->m_typeEntries) + if (pThis) { - list.push_back(std::make_pair(typeEntry.second->GetDescription(), typeEntry.first)); + list.clear(); + current = 0; - if (!foundCurrent && (*(pThis->m_timerType) == *(typeEntry.second))) + bool foundCurrent(false); + for (const auto &typeEntry : pThis->m_typeEntries) { - current = typeEntry.first; - foundCurrent = true; + list.push_back(std::make_pair(typeEntry.second->GetDescription(), typeEntry.first)); + + if (!foundCurrent && (*(pThis->m_timerType) == *(typeEntry.second))) + { + current = typeEntry.first; + foundCurrent = true; + } } } + else + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::TypesFiller - No dialog"); } -// static void CGUIDialogPVRTimerSettings::ChannelsFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) + if (pThis) { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::ChannelsFiller - No dialog"); - return; - } - - list.clear(); - current = 0; + list.clear(); + current = 0; - bool foundCurrent(false); - for (const auto &channelEntry : pThis->m_channelEntries) - { - if (channelEntry.first == ENTRY_ANY_CHANNEL) + bool foundCurrent(false); + for (const auto &channelEntry : pThis->m_channelEntries) { - // For repeating epg-based timers only, add an "any channel" entry. - if (pThis->m_timerType->IsRepeatingEpgBased()) - list.push_back(std::make_pair(channelEntry.second.description, channelEntry.first)); + if (channelEntry.first == ENTRY_ANY_CHANNEL) + { + // For repeating epg-based timers only, add an "any channel" entry. + if (pThis->m_timerType->IsRepeatingEpgBased()) + list.push_back(std::make_pair(channelEntry.second.description, channelEntry.first)); + else + continue; + } else - continue; - } - else - { - // Only include channels supplied by the currently active PVR client. - if (channelEntry.second.clientId == pThis->m_timerType->GetClientId()) - list.push_back(std::make_pair(channelEntry.second.description, channelEntry.first)); - } + { + // Only include channels supplied by the currently active PVR client. + if (channelEntry.second.clientId == pThis->m_timerType->GetClientId()) + list.push_back(std::make_pair(channelEntry.second.description, channelEntry.first)); + } - if (!foundCurrent && (pThis->m_channel == channelEntry.second)) - { - current = channelEntry.first; - foundCurrent = true; + if (!foundCurrent && (pThis->m_channel == channelEntry.second)) + { + current = channelEntry.first; + foundCurrent = true; + } } } + else + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::ChannelsFiller - No dialog"); } -// static void CGUIDialogPVRTimerSettings::DaysFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) + if (pThis) { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::DaysFiller - No dialog"); - return; - } + list.clear(); + current = 0; - list.clear(); - current = 0; + // Data range: "today" until "yesterday next year" + const CDateTime now(CDateTime::GetCurrentDateTime()); + CDateTime time(now.GetYear(), now.GetMonth(), now.GetDay(), 0, 0, 0); + const CDateTime yesterdayPlusOneYear( + time.GetYear() + 1, time.GetMonth(), time.GetDay() - 1, time.GetHour(), time.GetMinute(), time.GetSecond()); - // Data range: "today" until "yesterday next year" - const CDateTime now(CDateTime::GetCurrentDateTime()); - CDateTime time(now.GetYear(), now.GetMonth(), now.GetDay(), 0, 0, 0); - const CDateTime yesterdayPlusOneYear( - time.GetYear() + 1, time.GetMonth(), time.GetDay() - 1, time.GetHour(), time.GetMinute(), time.GetSecond()); + while (time <= yesterdayPlusOneYear) + { + list.push_back(std::make_pair(time.GetAsLocalizedDate(), GetDateAsInt(time))); + time += CDateTimeSpan(1, 0, 0, 0); + } - time_t t(0); - while (time <= yesterdayPlusOneYear) - { - time.GetAsTime(t); - list.push_back(std::make_pair(time.GetAsLocalizedDate(), static_cast< int >(t))); - time += CDateTimeSpan(1, 0, 0, 0); + if (setting->GetId() == SETTING_TMR_FIRST_DAY) + current = GetDateAsInt(pThis->m_firstDayLocalTime); + else if (setting->GetId() == SETTING_TMR_START_DAY) + current = GetDateAsInt(pThis->m_startLocalTime); + else + current = GetDateAsInt(pThis->m_endLocalTime); } - - if (setting->GetId() == SETTING_TMR_FIRST_DAY) - current = GetDateAsInt(pThis->m_firstDayLocalTime); - else if (setting->GetId() == SETTING_TMR_START_DAY) - current = GetDateAsInt(pThis->m_startLocalTime); else - current = GetDateAsInt(pThis->m_endLocalTime); + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::DaysFiller - No dialog"); } -// static void CGUIDialogPVRTimerSettings::DupEpisodesFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) + if (pThis) { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::DupEpisodesFiller - No dialog"); - return; + list.clear(); + pThis->m_timerType->GetPreventDuplicateEpisodesValues(list); + current = pThis->m_iPreventDupEpisodes; } - - list.clear(); - pThis->m_timerType->GetPreventDuplicateEpisodesValues(list); - current = pThis->m_iPreventDupEpisodes; + else + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::DupEpisodesFiller - No dialog"); } -// static void CGUIDialogPVRTimerSettings::WeekdaysFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) + if (pThis) { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::WeekdaysFiller - No dialog"); - return; + list.clear(); + list.push_back(std::make_pair(g_localizeStrings.Get(831), PVR_WEEKDAY_MONDAY)); // "Mondays" + list.push_back(std::make_pair(g_localizeStrings.Get(832), PVR_WEEKDAY_TUESDAY)); // "Tuesdays" + list.push_back(std::make_pair(g_localizeStrings.Get(833), PVR_WEEKDAY_WEDNESDAY)); // "Wednesdays" + list.push_back(std::make_pair(g_localizeStrings.Get(834), PVR_WEEKDAY_THURSDAY)); // "Thursdays" + list.push_back(std::make_pair(g_localizeStrings.Get(835), PVR_WEEKDAY_FRIDAY)); // "Fridays" + list.push_back(std::make_pair(g_localizeStrings.Get(836), PVR_WEEKDAY_SATURDAY)); // "Saturdays" + list.push_back(std::make_pair(g_localizeStrings.Get(837), PVR_WEEKDAY_SUNDAY)); // "Sundays" + + current = pThis->m_iWeekdays; } - - list.clear(); - list.push_back(std::make_pair(g_localizeStrings.Get(831), PVR_WEEKDAY_MONDAY)); // "Mondays" - list.push_back(std::make_pair(g_localizeStrings.Get(832), PVR_WEEKDAY_TUESDAY)); // "Tuesdays" - list.push_back(std::make_pair(g_localizeStrings.Get(833), PVR_WEEKDAY_WEDNESDAY)); // "Wednesdays" - list.push_back(std::make_pair(g_localizeStrings.Get(834), PVR_WEEKDAY_THURSDAY)); // "Thursdays" - list.push_back(std::make_pair(g_localizeStrings.Get(835), PVR_WEEKDAY_FRIDAY)); // "Fridays" - list.push_back(std::make_pair(g_localizeStrings.Get(836), PVR_WEEKDAY_SATURDAY)); // "Saturdays" - list.push_back(std::make_pair(g_localizeStrings.Get(837), PVR_WEEKDAY_SUNDAY)); // "Sundays" - - current = pThis->m_iWeekdays; + else + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::WeekdaysFiller - No dialog"); } -// static void CGUIDialogPVRTimerSettings::PrioritiesFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) + if (pThis) { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::PrioritiesFiller - No dialog"); - return; + list.clear(); + pThis->m_timerType->GetPriorityValues(list); + current = pThis->m_iPriority; } - - list.clear(); - pThis->m_timerType->GetPriorityValues(list); - current = pThis->m_iPriority; + else + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::PrioritiesFiller - No dialog"); } -// static void CGUIDialogPVRTimerSettings::LifetimesFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) + if (pThis) { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::LifetimesFiller - No dialog"); - return; + list.clear(); + pThis->m_timerType->GetLifetimeValues(list); + current = pThis->m_iLifetime; } - - list.clear(); - pThis->m_timerType->GetLifetimeValues(list); - current = pThis->m_iLifetime; + else + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::LifetimesFiller - No dialog"); } -// static void CGUIDialogPVRTimerSettings::RecordingGroupFiller( const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { CGUIDialogPVRTimerSettings *pThis = static_cast<CGUIDialogPVRTimerSettings*>(data); - if (pThis == NULL) + if (pThis) { - CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::RecordingGroupFiller - No dialog"); - return; + list.clear(); + pThis->m_timerType->GetRecordingGroupValues(list); + current = pThis->m_iRecordingGroup; } - - list.clear(); - pThis->m_timerType->GetRecordingGroupValues(list); - current = pThis->m_iRecordingGroup; + else + CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::RecordingGroupFiller - No dialog"); } void CGUIDialogPVRTimerSettings::AddTypeDependentEnableCondition(CSetting *setting, const std::string &identifier) @@ -955,9 +925,9 @@ void CGUIDialogPVRTimerSettings::AddTypeDependentEnableCondition(CSetting *setti AddCondition(setting, id, TypeReadOnlyCondition, SettingDependencyTypeEnable, SETTING_TMR_TYPE); } -// static bool CGUIDialogPVRTimerSettings::TypeReadOnlyCondition(const std::string &condition, const std::string &value, const CSetting *setting, void *data) { + bool bRet(true); if (setting == NULL) return false; @@ -1001,16 +971,13 @@ bool CGUIDialogPVRTimerSettings::TypeReadOnlyCondition(const std::string &condit } // Let the PVR client decide... - int idx = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + int idx = static_cast<const CSettingInt*>(setting)->GetValue(); const auto entry = pThis->m_typeEntries.find(idx); if (entry != pThis->m_typeEntries.end()) - { return !entry->second->IsReadOnly(); - } else - { CLog::Log(LOGERROR, "CGUIDialogPVRTimerSettings::TypeReadOnlyCondition - No type entry"); - } + return false; } @@ -1022,7 +989,6 @@ void CGUIDialogPVRTimerSettings::AddTypeDependentVisibilityCondition(CSetting *s AddCondition(setting, id, TypeSupportsCondition, SettingDependencyTypeVisible, SETTING_TMR_TYPE); } -// static bool CGUIDialogPVRTimerSettings::TypeSupportsCondition(const std::string &condition, const std::string &value, const CSetting *setting, void *data) { if (setting == NULL) @@ -1038,7 +1004,7 @@ bool CGUIDialogPVRTimerSettings::TypeSupportsCondition(const std::string &condit if (!StringUtils::EqualsNoCase(value, "true")) return false; - int idx = dynamic_cast<const CSettingInt*>(setting)->GetValue(); + int idx = static_cast<const CSettingInt*>(setting)->GetValue(); const auto entry = pThis->m_typeEntries.find(idx); if (entry != pThis->m_typeEntries.end()) { @@ -1096,7 +1062,6 @@ void CGUIDialogPVRTimerSettings::AddAnytimeDependentVisibilityCondition(CSetting AddCondition(setting, id, AnytimeSetCondition, SettingDependencyTypeVisible, SETTING_TMR_ANYTIME); } -// static bool CGUIDialogPVRTimerSettings::AnytimeSetCondition(const std::string &condition, const std::string &value, const CSetting *setting, void *data) { if (setting == NULL) @@ -1124,7 +1089,7 @@ bool CGUIDialogPVRTimerSettings::AnytimeSetCondition(const std::string &conditio (cond == SETTING_TMR_BEGIN) || (cond == SETTING_TMR_END)) { - bool bAnytime = dynamic_cast<const CSettingBool*>(setting)->GetValue(); + bool bAnytime = static_cast<const CSettingBool*>(setting)->GetValue(); return !bAnytime; } return false; diff --git a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h index 8c769e55bd..6021a61978 100644 --- a/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h +++ b/xbmc/pvr/dialogs/GUIDialogPVRTimerSettings.h @@ -48,7 +48,7 @@ namespace PVR protected: // implementation of ISettingCallback virtual void OnSettingChanged(const CSetting *setting); - virtual void OnSettingAction (const CSetting *setting); + virtual void OnSettingAction(const CSetting *setting); // specialization of CGUIDialogSettingsBase virtual bool AllowResettingSettings() const { return false; } diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp index 999b330670..4fe92a094d 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp +++ b/xbmc/pvr/timers/PVRTimerInfoTag.cpp @@ -43,7 +43,7 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(bool bRadio /* = false */) : { m_iClientId = g_PVRClients->GetFirstConnectedClientID(); m_iClientIndex = -1; - m_iParentClientIndex = 0; + m_iParentClientIndex = PVR_TIMER_NO_PARENT; m_iClientChannelUid = PVR_INVALID_CHANNEL_UID; m_iPriority = CSettings::Get().GetInt("pvrrecord.defaultpriority"); m_iLifetime = CSettings::Get().GetInt("pvrrecord.defaultlifetime"); @@ -171,7 +171,7 @@ bool CPVRTimerInfoTag::operator ==(const CPVRTimerInfoTag& right) const m_iClientChannelUid == right.m_iClientChannelUid && m_bIsRadio == right.m_bIsRadio && m_iPreventDupEpisodes == right.m_iPreventDupEpisodes && - m_iRecordingGroup == m_iRecordingGroup && + m_iRecordingGroup == right.m_iRecordingGroup && m_StartTime == right.m_StartTime && m_StopTime == right.m_StopTime && m_FirstDay == right.m_FirstDay && @@ -398,7 +398,7 @@ std::string CPVRTimerInfoTag::GetStatus() const std::string CPVRTimerInfoTag::GetTypeAsString() const { CSingleLock lock(m_critSection); - return m_timerType ? m_timerType->GetDescription() : std::string(); + return m_timerType ? m_timerType->GetDescription() : ""; } namespace @@ -415,7 +415,6 @@ void AppendDay(std::string &strReturn, unsigned int iId) } } // unnamed namespace -// static std::string CPVRTimerInfoTag::GetWeekdaysString(unsigned int iWeekdays, bool bEpgBased, bool bLongMultiDaysFormat) { std::string strReturn; @@ -677,7 +676,7 @@ CPVRTimerInfoTagPtr CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTagPtr &tag, b CDateTime newStart = tag->StartAsUTC(); CDateTime newEnd = tag->EndAsUTC(); newTag->m_iClientIndex = -1; - newTag->m_iParentClientIndex = 0; + newTag->m_iParentClientIndex = PVR_TIMER_NO_PARENT; newTag->m_strTitle = tag->Title().empty() ? channel->ChannelName() : tag->Title(); newTag->m_iChannelNumber = channel->ChannelNumber(); newTag->m_iClientChannelUid = channel->UniqueID(); @@ -750,6 +749,13 @@ bool CPVRTimerInfoTag::IsStartAtAnyTime(void) const return time == 0; } +void CPVRTimerInfoTag::SetStartAtAnyTime(void) +{ + time_t time = 0; + CDateTime start(time); + SetStartFromUTC(start); +} + CDateTime CPVRTimerInfoTag::EndAsUTC(void) const { CDateTime retVal = m_StopTime; @@ -771,6 +777,13 @@ bool CPVRTimerInfoTag::IsEndAtAnyTime(void) const return time == 0; } +void CPVRTimerInfoTag::SetEndAtAnyTime(void) +{ + time_t time = 0; + CDateTime stop(time); + SetEndFromUTC(stop); +} + CDateTime CPVRTimerInfoTag::FirstDayAsUTC(void) const { CDateTime retVal = m_FirstDay; @@ -791,29 +804,29 @@ void CPVRTimerInfoTag::GetNotificationText(std::string &strText) const { case PVR_TIMER_STATE_ABORTED: case PVR_TIMER_STATE_CANCELLED: - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19224).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19224).c_str(), m_strTitle.c_str()); // Recording aborted break; case PVR_TIMER_STATE_SCHEDULED: if (IsRepeating()) - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(826).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(826).c_str(), m_strTitle.c_str()); // Timer activated else - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19225).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19225).c_str(), m_strTitle.c_str()); // Recording scheduled break; case PVR_TIMER_STATE_RECORDING: - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19226).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19226).c_str(), m_strTitle.c_str()); // Recording started break; case PVR_TIMER_STATE_COMPLETED: - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19227).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19227).c_str(), m_strTitle.c_str()); // Recording completed break; case PVR_TIMER_STATE_CONFLICT_OK: case PVR_TIMER_STATE_CONFLICT_NOK: - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19277).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19277).c_str(), m_strTitle.c_str()); // Recording conflict break; case PVR_TIMER_STATE_ERROR: - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19278).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(19278).c_str(), m_strTitle.c_str()); // Recording error break; case PVR_TIMER_STATE_DISABLED: - strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(827).c_str(), m_strTitle.c_str()); + strText = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(827).c_str(), m_strTitle.c_str()); // Timer deactivated break; default: break; diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.h b/xbmc/pvr/timers/PVRTimerInfoTag.h index 15e55cd186..479b115e23 100644 --- a/xbmc/pvr/timers/PVRTimerInfoTag.h +++ b/xbmc/pvr/timers/PVRTimerInfoTag.h @@ -123,15 +123,14 @@ namespace PVR bool IsRecording(void) const { return m_state == PVR_TIMER_STATE_RECORDING; } /*! - * @brief Checks whether is timer has a timer type. Can be false if - * no PVR client supporting timers is enabled. + * @brief Checks whether this timer has a timer type. * @return True if this timer has a timer type, false otherwise */ bool HasTimerType(void) const { return m_timerType.get() != NULL; } /*! * @brief Gets the type of this timer. - * @return the timer type. + * @return the timer type or NULL if this tag has no timer type. */ const CPVRTimerTypePtr GetTimerType() const { return m_timerType; } @@ -155,16 +154,20 @@ namespace PVR CDateTime StartAsUTC(void) const; CDateTime StartAsLocalTime(void) const; - bool IsStartAtAnyTime(void) const; void SetStartFromUTC(CDateTime &start) { m_StartTime = start; } void SetStartFromLocalTime(CDateTime &start) { m_StartTime = start.GetAsUTCDateTime(); } + bool IsStartAtAnyTime(void) const; + void SetStartAtAnyTime(void); + CDateTime EndAsUTC(void) const; CDateTime EndAsLocalTime(void) const; - bool IsEndAtAnyTime(void) const; void SetEndFromUTC(CDateTime &end) { m_StopTime = end; } void SetEndFromLocalTime(CDateTime &end) { m_StopTime = end.GetAsUTCDateTime(); } + bool IsEndAtAnyTime(void) const; + void SetEndAtAnyTime(void); + CDateTime FirstDayAsUTC(void) const; CDateTime FirstDayAsLocalTime(void) const; void SetFirstDayFromUTC(CDateTime &firstDay) { m_FirstDay = firstDay; } @@ -216,6 +219,12 @@ namespace PVR */ static std::string GetWeekdaysString(unsigned int iWeekdays, bool bEpgBased, bool bLongMultiDaysFormat); + /*! + * @brief For timers scheduled by repeated timers, return the id of the parent. + * @return the id of the timer schedule or 0 in case the timer was not scheduled by a repeating timer. + */ + unsigned int GetTimerScheduleId() const { return m_iParentClientIndex; } + std::string m_strTitle; /*!< @brief name of this timer */ std::string m_strEpgSearchString; /*!< @brief a epg data match string for repeating epg-based timers. Format is backend-dependent, for example regexp */ bool m_bFullTextEpgSearch; /*!< @brief indicates whether only epg episode title can be matched by the pvr backend or "more" (backend-dependent") data. */ @@ -223,8 +232,8 @@ namespace PVR std::string m_strSummary; /*!< @brief summary string with the time to show inside a GUI list */ PVR_TIMER_STATE m_state; /*!< @brief the state of this timer */ int m_iClientId; /*!< @brief ID of the backend */ - unsigned int m_iClientIndex; /*!< @brief index number of the tag, given by the backend, -1 for new */ - unsigned int m_iParentClientIndex; /*!< @brief for timers scheduled by repeated timers, the index number of the parent, given by the backend, 0 for no parent */ + int m_iClientIndex; /*!< @brief index number of the tag, given by the backend, -1 for new */ + unsigned int m_iParentClientIndex; /*!< @brief for timers scheduled by repeated timers, the index number of the parent, given by the backend, PVR_TIMER_NO_PARENT for no parent */ int m_iClientChannelUid; /*!< @brief channel uid */ int m_iPriority; /*!< @brief priority of the timer */ int m_iLifetime; /*!< @brief lifetime of the timer in days */ diff --git a/xbmc/pvr/timers/PVRTimerType.cpp b/xbmc/pvr/timers/PVRTimerType.cpp index a31833217b..d2a47695b2 100644 --- a/xbmc/pvr/timers/PVRTimerType.cpp +++ b/xbmc/pvr/timers/PVRTimerType.cpp @@ -29,7 +29,6 @@ using namespace PVR; -// static const std::vector<CPVRTimerTypePtr> CPVRTimerType::GetAllTypes() { std::vector<CPVRTimerTypePtr> allTypes; @@ -37,14 +36,12 @@ const std::vector<CPVRTimerTypePtr> CPVRTimerType::GetAllTypes() return allTypes; } -// static const CPVRTimerTypePtr CPVRTimerType::GetFirstAvailableType() { std::vector<CPVRTimerTypePtr> allTypes(GetAllTypes()); return allTypes.empty() ? CPVRTimerTypePtr() : *(allTypes.begin()); } -// static CPVRTimerTypePtr CPVRTimerType::CreateFromIds(unsigned int iTypeId, int iClientId) { std::vector<CPVRTimerTypePtr> types; @@ -62,7 +59,6 @@ CPVRTimerTypePtr CPVRTimerType::CreateFromIds(unsigned int iTypeId, int iClientI return CPVRTimerTypePtr(); } -// static CPVRTimerTypePtr CPVRTimerType::CreateFromAttributes( unsigned int iMustHaveAttr, unsigned int iMustNotHaveAttr, int iClientId) { @@ -102,7 +98,6 @@ CPVRTimerType::CPVRTimerType(const PVR_TIMER_TYPE &type, int iClientId) : InitAttributeValues(type); } -// virtual CPVRTimerType::~CPVRTimerType() { } @@ -277,4 +272,3 @@ void CPVRTimerType::GetRecordingGroupValues(std::vector< std::pair<std::string, for (const auto &recordingGroup : m_recordingGroupValues) list.push_back(recordingGroup); } - diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 61c9c9dce0..aaedc3c443 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -413,7 +413,7 @@ bool CPVRTimers::GetRootDirectory(const CPVRTimersPath &path, CFileItemList &ite for (const auto &timer : *tagsEntry.second) { if ((bRadio == timer->m_bIsRadio) && - (!bGrouped || (timer->m_iParentClientIndex == 0))) + (!bGrouped || (timer->m_iParentClientIndex == PVR_TIMER_NO_PARENT))) { item.reset(new CFileItem(timer)); std::string strItemPath( @@ -440,7 +440,7 @@ bool CPVRTimers::GetSubDirectory(const CPVRTimersPath &path, CFileItemList &item for (const auto &timer : *tagsEntry.second) { if ((timer->m_bIsRadio == bRadio) && - (timer->m_iParentClientIndex > 0) && + (timer->m_iParentClientIndex != PVR_TIMER_NO_PARENT) && (timer->m_iClientId == iClientId) && (timer->m_iParentClientIndex == iParentId)) { diff --git a/xbmc/pvr/windows/GUIWindowPVRBase.cpp b/xbmc/pvr/windows/GUIWindowPVRBase.cpp index 41f6d24a56..28b4976947 100644 --- a/xbmc/pvr/windows/GUIWindowPVRBase.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRBase.cpp @@ -402,7 +402,7 @@ bool CGUIWindowPVRBase::StartRecordFile(CFileItem *item, bool bAdvanced) { // ask for confirmation before starting a timer if (!CGUIDialogYesNo::ShowAndGetInput( - 264 /* "Stop Rec." */, tag->PVRChannelName(), "", tag->Title())) + 264 /* "Record" */, tag->PVRChannelName(), "", tag->Title())) return false; CPVRTimerInfoTagPtr newTimer = CPVRTimerInfoTag::CreateFromEpg(tag); @@ -743,7 +743,6 @@ void CGUIWindowPVRBase::UpdateSelectedItemPath() m_selectedItemPaths.at(m_bRadio) = m_viewControl.GetSelectedItemPath(); } -// static bool CGUIWindowPVRBase::ConfirmDeleteTimer(CFileItem *item, bool &bDeleteSchedule) { bool bConfirmed(false); |