Skip to content
Browse files

[PVR] added a unique id for each timer, valid as long as xbmc isn't r…

…eset
  • Loading branch information...
1 parent fc0d897 commit a0cedfa26491d131b2e9313efc89458750cc9303 @opdenkamp opdenkamp committed with Montellese Feb 13, 2014
View
6 xbmc/pvr/timers/PVRTimerInfoTag.cpp
@@ -64,6 +64,7 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(void)
m_StopTime = m_StartTime;
m_state = PVR_TIMER_STATE_SCHEDULED;
m_FirstDay.SetValid(false);
+ m_iTimerId = 0;
}
CPVRTimerInfoTag::CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channel, unsigned int iClientId)
@@ -93,6 +94,7 @@ CPVRTimerInfoTag::CPVRTimerInfoTag(const PVR_TIMER &timer, CPVRChannelPtr channe
m_bIsRadio = channel && channel->IsRadio();
m_state = timer.state;
m_strFileNameAndPath = StringUtils::Format("pvr://client%i/timers/%i", m_iClientId, m_iClientIndex);
+ m_iTimerId = 0;
UpdateSummary();
}
@@ -123,7 +125,8 @@ bool CPVRTimerInfoTag::operator ==(const CPVRTimerInfoTag& right) const
m_iClientId == right.m_iClientId &&
m_iMarginStart == right.m_iMarginStart &&
m_iMarginEnd == right.m_iMarginEnd &&
- m_state == right.m_state);
+ m_state == right.m_state &&
+ m_iTimerId == right.m_iTimerId);
}
CPVRTimerInfoTag &CPVRTimerInfoTag::operator=(const CPVRTimerInfoTag &orig)
@@ -148,6 +151,7 @@ CPVRTimerInfoTag &CPVRTimerInfoTag::operator=(const CPVRTimerInfoTag &orig)
m_iMarginEnd = orig.m_iMarginEnd;
m_state = orig.m_state;
m_iChannelNumber = orig.m_iChannelNumber;
+ m_iTimerId = orig.m_iTimerId;
return *this;
}
View
1 xbmc/pvr/timers/PVRTimerInfoTag.h
@@ -173,6 +173,7 @@ namespace PVR
CStdString m_strFileNameAndPath; /*!< @brief filename is only for reference */
int m_iChannelNumber; /*!< @brief integer value of the channel number */
bool m_bIsRadio; /*!< @brief is radio channel if set */
+ unsigned int m_iTimerId; /*!< @brief id that won't change as long as XBMC is running */
CPVRChannelPtr m_channel;
unsigned int m_iMarginStart; /*!< @brief (optional) if set, the backend starts the recording iMarginStart minutes before startTime. */
View
32 xbmc/pvr/timers/PVRTimers.cpp
@@ -41,6 +41,7 @@ using namespace EPG;
CPVRTimers::CPVRTimers(void)
{
m_bIsUpdating = false;
+ m_iLastId = 0;
}
CPVRTimers::~CPVRTimers(void)
@@ -151,6 +152,7 @@ bool CPVRTimers::UpdateEntries(const CPVRTimers &timers)
addEntry = itr->second;
}
+ newTimer->m_iTimerId = ++m_iLastId;
addEntry->push_back(newTimer);
UpdateEpgEvent(newTimer);
bChanged = true;
@@ -285,6 +287,7 @@ bool CPVRTimers::UpdateFromClient(const CPVRTimerInfoTag &timer)
{
addEntry = itr->second;
}
+ tag->m_iTimerId = ++m_iLastId;
addEntry->push_back(tag);
}
@@ -741,3 +744,32 @@ void CPVRTimers::UpdateChannels(void)
(*timerIt)->UpdateChannel();
}
}
+
+void CPVRTimers::GetAll(CFileItemList& items) const
+{
+ CFileItemPtr item;
+ CSingleLock lock(m_critSection);
+ for (map<CDateTime, vector<CPVRTimerInfoTagPtr>* >::const_iterator it = m_tags.begin(); it != m_tags.end(); it++)
+ {
+ for (vector<CPVRTimerInfoTagPtr>::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); timerIt++)
+ {
+ item.reset(new CFileItem(**timerIt));
+ items.Add(item);
+ }
+ }
+}
+
+CPVRTimerInfoTagPtr CPVRTimers::GetById(unsigned int iTimerId) const
+{
+ CPVRTimerInfoTagPtr item;
+ CSingleLock lock(m_critSection);
+ for (map<CDateTime, vector<CPVRTimerInfoTagPtr>* >::const_iterator it = m_tags.begin(); !item && it != m_tags.end(); it++)
+ {
+ for (vector<CPVRTimerInfoTagPtr>::const_iterator timerIt = it->second->begin(); !item && timerIt != it->second->end(); timerIt++)
+ {
+ if ((*timerIt)->m_iTimerId == iTimerId)
+ item = *timerIt;
+ }
+ }
+ return item;
+}
View
14 xbmc/pvr/timers/PVRTimers.h
@@ -68,6 +68,12 @@ namespace PVR
std::vector<CFileItemPtr> GetActiveTimers(void) const;
/*!
+ * Get all timers
+ * @param items The list to add the timers to
+ */
+ void GetAll(CFileItemList& items) const;
+
+ /*!
* @return True when there is at least one timer that is active (states scheduled or recording), false otherwise.
*/
bool HasActiveTimers(void) const;
@@ -166,6 +172,13 @@ namespace PVR
void Notify(const Observable &obs, const ObservableMessage msg);
+ /*!
+ * Get a timer tag given it's unique ID
+ * @param iTimerId The ID to find
+ * @return The tag, or an empty one when not found
+ */
+ CPVRTimerInfoTagPtr GetById(unsigned int iTimerId) const;
+
private:
void Unload(void);
void UpdateEpgEvent(CPVRTimerInfoTagPtr timer);
@@ -175,5 +188,6 @@ namespace PVR
CCriticalSection m_critSection;
bool m_bIsUpdating;
std::map<CDateTime, std::vector<CPVRTimerInfoTagPtr>* > m_tags;
+ unsigned int m_iLastId;
};
}

0 comments on commit a0cedfa

Please sign in to comment.
Something went wrong with that request. Please try again.