From 23562a42a5a5d776330b42823fe844493b574830 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Thu, 10 Feb 2011 13:14:03 +0200 Subject: Added support for renaming/moving recordings and for deleting multiple recordings at once. --- recman.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'recman.h') diff --git a/recman.h b/recman.h index e04c16b..dc766ed 100644 --- a/recman.h +++ b/recman.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "stdext.h" @@ -21,6 +22,8 @@ namespace vdrlive { class RecordingsTreePtr; class RecordingsList; class RecordingsListPtr; + class DirectoryList; + class DirectoryListPtr; class RecordingsItem; typedef std::tr1::shared_ptr< RecordingsManager > RecordingsManagerPtr; @@ -56,6 +59,12 @@ namespace vdrlive { RecordingsListPtr GetRecordingsList(bool ascending = true) const; RecordingsListPtr GetRecordingsList(time_t begin, time_t end, bool ascending = true) const; + /** + * Returns a shared pointer to a fully populated + * directory list. + */ + DirectoryListPtr GetDirectoryList() const; + /** * generates a Md5 hash from a cRecording entry. It can be used * to reidentify a recording. @@ -68,6 +77,24 @@ namespace vdrlive { */ cRecording const* GetByMd5Hash(std::string const & hash) const; + /** + * Rename a recording with the given hash according to + * VDRs recording mechanisms. + */ + bool RenameRecording(cRecording const * recording, std::string const & name) const; + + /** + * Delete recording resume with the given hash according to + * VDRs recording mechanisms. + */ + void DeleteResume(cRecording const * recording) const; + + /** + * Delete recording marks with the given hash according to + * VDRs recording mechanisms. + */ + void DeleteMarks(cRecording const * recording) const; + /** * Delete a recording with the given hash according to * VDRs recording deletion mechanisms. @@ -97,6 +124,7 @@ namespace vdrlive { static std::tr1::weak_ptr< RecordingsManager > m_recMan; static std::tr1::shared_ptr< RecordingsTree > m_recTree; static std::tr1::shared_ptr< RecordingsList > m_recList; + static std::tr1::shared_ptr< DirectoryList > m_recDirs; static int m_recordingsState; cThreadLock m_recordingsLock; @@ -309,6 +337,51 @@ namespace vdrlive { }; + /** + * The recording directory list contains all real directory entries. + */ + class DirectoryList + { + friend class RecordingsManager; + + private: + DirectoryList(RecordingsManagerPtr recManPtr); +#if APIVERSNUM >= 10712 + void InjectFoldersConf(cNestedItem * folder, std::string parent = ""); +#endif + public: + typedef std::list< std::string > DirVecType; + + virtual ~DirectoryList(); + + DirVecType::const_iterator begin() const { return m_pDirVec->begin(); } + DirVecType::const_iterator end() const { return m_pDirVec->end(); } + DirVecType::size_type size() const { return m_pDirVec->size(); } + + private: + DirVecType *m_pDirVec; + }; + + + /** + * A smart pointer to a directory list. As long as an instance of this + * exists the recordings are locked in the vdr. + */ + class DirectoryListPtr : public std::tr1::shared_ptr< DirectoryList > + { + friend class RecordingsManager; + + private: + DirectoryListPtr(RecordingsManagerPtr recManPtr, std::tr1::shared_ptr< DirectoryList > recDirs); + + public: + virtual ~DirectoryListPtr(); + + private: + RecordingsManagerPtr m_recManPtr; + }; + + /** * return singleton instance of RecordingsManager as a shared Pointer. * This ensures that after last use of the RecordingsManager it is -- cgit v1.2.3