From b6ebbd4df6a6a588692bd0e5e1bbd1d920aad3e1 Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Wed, 17 Jan 2007 01:15:59 +0000 Subject: - Moved cRecordings locking infrastructure to RecordingsManager. - Take care to have at any time maximum one instance of RecordingsManager alive. This is done with a combination of boost::shared_ptr and boost::weak_ptr. See LiveRecordingsManager() function. - RecordingsTree now uses RecordingsManager to calculate a MD5 Hash for each 'real' cRecording item. - The MD5 Hash is used in the Ajax-Request to start play back of a recording. (Server side needs implementation of this.) - Id's are also used in the DOM for the identification of the tooltips. - New code dependency on openssl libraries (for md5 function). - Changed style (not yet complete) to have 'action' items also in the recording description popup. --- recordings.h | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'recordings.h') diff --git a/recordings.h b/recordings.h index a8ea907..bf016a4 100644 --- a/recordings.h +++ b/recordings.h @@ -12,6 +12,27 @@ namespace vdrlive { using namespace boost; using namespace std; + class RecordingsManager; + typedef shared_ptr RecordingsManagerPtr; + + class RecordingsManager + { + friend RecordingsManagerPtr LiveRecordingsManager(); + + public: + /** + * generates a Md5 hash from a cRecording entry. It can be used + * to reidentify a recording. + */ + string Md5Hash(const cRecording* recording) const; + + private: + RecordingsManager(); + + cThreadLock m_recordingsLock; + }; + + class RecordingsTree { public: @@ -54,7 +75,7 @@ namespace vdrlive { virtual time_t StartTime() const { return 0; } virtual bool IsDir() const { return true; } - virtual const string Id() const { return ""; } + virtual const string Id() const { string e; return e; } private: int m_level; @@ -79,7 +100,7 @@ namespace vdrlive { string m_id; }; - RecordingsTree(); + RecordingsTree(RecordingsManagerPtr recManPtr); virtual ~RecordingsTree(); @@ -91,11 +112,20 @@ namespace vdrlive { private: int m_maxLevel; RecordingsItemPtr m_root; - cThreadLock m_recordingsLock; + RecordingsManagerPtr m_recManPtr; Map::iterator findDir(RecordingsItemPtr& dir, const string& dirname); }; + /** + * return singleton instance of RecordingsManager as a shared Pointer. + * This ensures that after last use of the RecordingsManager it is + * deleted. After deletion of the original RecordingsManager a repeated + * call to this function creates a new RecordingsManager which is again + * kept alive as long references to it exist. + */ + RecordingsManagerPtr LiveRecordingsManager(); + } // namespace vdrlive #endif // VDR_LIVE_RECORDINGS_H -- cgit v1.2.3