aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Op den Kamp <lars@opdenkamp.eu>2014-02-13 01:05:04 +0100
committermontellese <montellese@xbmc.org>2014-02-27 20:01:32 +0100
commita0cedfa26491d131b2e9313efc89458750cc9303 (patch)
tree17ec19882722d598bf6e507cd3924d50e4c4c289
parentfc0d8976f3468f36578ec54c59401685dcd969f0 (diff)
[PVR] added a unique id for each timer, valid as long as xbmc isn't reset
-rw-r--r--xbmc/pvr/timers/PVRTimerInfoTag.cpp6
-rw-r--r--xbmc/pvr/timers/PVRTimerInfoTag.h1
-rw-r--r--xbmc/pvr/timers/PVRTimers.cpp32
-rw-r--r--xbmc/pvr/timers/PVRTimers.h14
4 files changed, 52 insertions, 1 deletions
diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.cpp b/xbmc/pvr/timers/PVRTimerInfoTag.cpp
index 92721c319c..61ff9c3d1b 100644
--- a/xbmc/pvr/timers/PVRTimerInfoTag.cpp
+++ b/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;
}
diff --git a/xbmc/pvr/timers/PVRTimerInfoTag.h b/xbmc/pvr/timers/PVRTimerInfoTag.h
index 576228e680..06e6887390 100644
--- a/xbmc/pvr/timers/PVRTimerInfoTag.h
+++ b/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. */
diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp
index eb8dcfcb76..d8935ec320 100644
--- a/xbmc/pvr/timers/PVRTimers.cpp
+++ b/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;
+}
diff --git a/xbmc/pvr/timers/PVRTimers.h b/xbmc/pvr/timers/PVRTimers.h
index b9a7d429fa..cc9c793301 100644
--- a/xbmc/pvr/timers/PVRTimers.h
+++ b/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;
};
}