summaryrefslogtreecommitdiff
path: root/timers.cpp
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-05 20:31:33 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-05 20:31:33 +0000
commit07aebf937a6a196114e7136f77eb5adefa2eeeb1 (patch)
tree64fe06420e825f80e02ec9e9f3198306b79d42ab /timers.cpp
parent8d278564f8350647964b5b9ccf3a6183ac7e2f0e (diff)
downloadvdr-plugin-live-07aebf937a6a196114e7136f77eb5adefa2eeeb1.tar.gz
vdr-plugin-live-07aebf937a6a196114e7136f77eb5adefa2eeeb1.tar.bz2
- incorporated all code into one shared object
- added several functions for timer identification
Diffstat (limited to 'timers.cpp')
-rw-r--r--timers.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/timers.cpp b/timers.cpp
index e1689ce..de072dc 100644
--- a/timers.cpp
+++ b/timers.cpp
@@ -1,5 +1,7 @@
#include <sstream>
+#include <vector>
#include "timers.h"
+#include "tools.h"
static bool operator<( cTimer const& left, cTimer const& right )
{
@@ -9,6 +11,7 @@ static bool operator<( cTimer const& left, cTimer const& right )
namespace vdrlive {
using namespace std;
+using namespace vdrlive;
SortedTimers::SortedTimers():
m_state( 0 )
@@ -24,6 +27,38 @@ string SortedTimers::GetTimerId( cTimer const& timer )
return builder.str();
}
+cTimer* SortedTimers::GetByTimerId( string const& timerid )
+{
+ vector< string > parts = StringSplit( timerid, ':' );
+ if ( parts.size() < 5 ) {
+ esyslog("GetByTimerId: invalid format %s", timerid.c_str() );
+ return 0;
+ }
+
+ cChannel* channel = Channels.GetByChannelID( tChannelID::FromString( parts[0].c_str() ) );
+ if ( channel == 0 ) {
+ esyslog("GetByTimerId: no channel %s", parts[0].c_str() );
+ return 0;
+ }
+
+ try {
+ int weekdays = lexical_cast< int >( parts[1] );
+ time_t day = lexical_cast< time_t >( parts[2] );
+ int start = lexical_cast< int >( parts[3] );
+ int stop = lexical_cast< int >( parts[4] );
+
+ for ( SortedTimers::iterator timer = begin(); timer != end(); ++timer ) {
+ if ( timer->Channel() == channel &&
+ ( ( weekdays != 0 && timer->WeekDays() == weekdays ) || ( weekdays == 0 && timer->Day() == day ) ) &&
+ timer->Start() == start && timer->Stop() == stop )
+ return &*timer;
+ }
+ } catch ( bad_lexical_cast const& ex ) {
+ esyslog("GetByTimer: bad cast");
+ }
+ return 0;
+}
+
void SortedTimers::ReloadTimers( bool initial )
{
if ( !Timers.Modified( m_state ) && !initial )
@@ -48,4 +83,10 @@ void TimerManager::DoPendingWork()
m_timers.ReloadTimers();
}
+TimerManager& LiveTimerManager()
+{
+ static TimerManager instance;
+ return instance;
+}
+
} // namespace vdrlive