summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epgsearch.cpp97
-rw-r--r--epgsearch.h135
2 files changed, 232 insertions, 0 deletions
diff --git a/epgsearch.cpp b/epgsearch.cpp
new file mode 100644
index 0000000..1816574
--- /dev/null
+++ b/epgsearch.cpp
@@ -0,0 +1,97 @@
+#include <vector>
+#include <vdr/plugin.h>
+#include "epgsearch/services.h"
+#include "epgsearch.h"
+#include "exception.h"
+#include "tools.h"
+
+namespace vdrlive {
+
+using namespace std;
+
+bool operator<( SearchTimer const& left, SearchTimer const& right )
+{
+ return left.m_id < right.m_id;
+}
+
+SearchTimer::SearchTimer( string const& data ):
+ m_id( 0 ),
+ m_useTime( false ),
+ m_startTime( 0 ),
+ m_stopTime( 0 ),
+ m_useChannel( NoChannel ),
+ m_useCase( false ),
+ m_mode( 0 ),
+ m_useTitle( false ),
+ m_useSubtitle( false ),
+ m_useDescription( false ),
+ m_useDuration( false ),
+ m_minDuration( 0 ),
+ m_maxDuration( 0 ),
+ m_useAsSearchTimer( false ),
+ m_useDayOfWeek( false ),
+ m_dayOfWeek( 0 ),
+ m_useEpisode( false ),
+ m_priority( 0 ),
+ m_lifetime( 0 )
+{
+ vector< string > parts = StringSplit( data, ':' );
+ try {
+ vector< string >::const_iterator part = parts.begin();
+ for ( int i = 0; part != parts.end(); ++i, ++part ) {
+ switch ( i ) {
+ case 0: m_id = lexical_cast< int >( *part ); break;
+ case 1: m_search = StringReplace( StringReplace( *part, "|", ":" ), "!^pipe^!", "|" ); break;
+ case 2: m_useTime = lexical_cast< bool >( *part ); break;
+ case 3: if ( m_useTime ) m_startTime = lexical_cast< int >( *part ); break;
+ case 4: if ( m_useTime ) m_stopTime = lexical_cast< int >( *part ); break;
+ case 5: m_useChannel = lexical_cast< int >( *part ); break;
+ case 6: ParseChannel( *part ); break;
+ case 7: m_useCase = lexical_cast< int >( *part ); break;
+ case 8: m_mode = lexical_cast< int >( *part ); break;
+ case 9: m_useTitle = lexical_cast< bool >( *part ); break;
+ case 10: m_useSubtitle = lexical_cast< bool >( *part ); break;
+ case 11: m_useDescription = lexical_cast< bool >( *part ); break;
+ case 12: m_useDuration = lexical_cast< bool >( *part ); break;
+ case 13: if ( m_useDuration ) m_minDuration = lexical_cast< int >( *part ); break;
+ case 14: if ( m_useDuration ) m_maxDuration = lexical_cast< int >( *part ); break;
+ case 15: m_useAsSearchTimer = lexical_cast< bool >( *part ); break;
+ case 16: m_useDayOfWeek = lexical_cast< bool >( *part ); break;
+ case 17: m_dayOfWeek = lexical_cast< int >( *part ); break;
+ case 18: m_useEpisode = lexical_cast< bool >( *part ); break;
+ case 19: m_directory = *part; break;
+ case 20: m_priority = lexical_cast< int >( *part ); break;
+ case 21: m_lifetime = lexical_cast< int >( *part ); break;
+ }
+ }
+ } catch ( bad_lexical_cast const& ex ) {
+ }
+}
+
+void SearchTimer::ParseChannel( string const& data )
+{
+ switch ( m_useChannel ) {
+ case Interval: ParseChannelIDs( data ); break;
+ case Group: m_channelGroup = data; break;
+ }
+}
+
+void SearchTimer::ParseChannelIDs( string const& data )
+{
+ vector< string > parts = StringSplit( data, '|' );
+ m_channelMin = lexical_cast< tChannelID >( parts[ 0 ] );
+ if ( parts.size() == 2 )
+ m_channelMax = lexical_cast< tChannelID >( parts[ 1 ] );
+}
+
+SearchTimers::SearchTimers()
+{
+ Epgsearch_services_v1_0 service;
+ if ( cPluginManager::CallFirstService("Epgsearch-services-v1.0", &service) == 0 )
+ throw HtmlError( tr("No searchtimers available") );
+
+ list< string > timers = service.handler->SearchTimerList();
+ m_timers.assign( timers.begin(), timers.end() );
+}
+
+} // namespace vdrlive
diff --git a/epgsearch.h b/epgsearch.h
new file mode 100644
index 0000000..1ce7698
--- /dev/null
+++ b/epgsearch.h
@@ -0,0 +1,135 @@
+#ifndef VDR_LIVE_EPGSEARCH_H
+#define VDR_LIVE_EPGSEARCH_H
+
+#include <list>
+#include <string>
+#include <vdr/channels.h>
+
+namespace vdrlive {
+
+class SearchTimer;
+
+bool operator<( SearchTimer const& left, SearchTimer const& right );
+
+class SearchTimer
+{
+public:
+ enum UseChannel
+ {
+ NoChannel = 0,
+ Interval = 1,
+ Group = 2,
+ FTAOnly = 3
+ };
+
+ SearchTimer( std::string const& data );
+
+ int Id() const { return m_id; }
+ std::string const& Search() const { return m_search; }
+ bool UseTime() const { return m_useTime; }
+ int StartTime() const { return m_startTime; }
+ int StopTime() const { return m_stopTime; }
+ bool UseChannel() const { return m_useChannel; }
+ tChannelID const& ChannelMin() const { return m_channelMin; }
+ tChannelID const& ChannelMax() const { return m_channelMax; }
+ bool UseAsSearchTimer() const { return m_useAsSearchTimer; }
+
+ friend bool operator<( SearchTimer const& left, SearchTimer const& right );
+
+private:
+ int m_id;
+ std::string m_search;
+ bool m_useTime;
+ int m_startTime;
+ int m_stopTime;
+ int m_useChannel;
+ tChannelID m_channelMin;
+ tChannelID m_channelMax;
+ std::string m_channelGroup;
+ bool m_useCase;
+ int m_mode;
+ bool m_useTitle;
+ bool m_useSubtitle;
+ bool m_useDescription;
+ bool m_useDuration;
+ int m_minDuration;
+ int m_maxDuration;
+ bool m_useAsSearchTimer;
+ bool m_useDayOfWeek;
+ int m_dayOfWeek;
+ bool m_useEpisode;
+ std::string m_directory;
+ int m_priority;
+ int m_lifetime;
+
+ void ParseChannel( std::string const& data );
+ void ParseChannelIDs( std::string const& data );
+/*
+ int useChannel;
+ int useCase;
+ int mode;
+ int useTitle;
+ int useSubtitle;
+ int useDescription;
+ int useDuration;
+ int minDuration;
+ int maxDuration;
+ int useAsSearchTimer;
+ int useDayOfWeek;
+ int DayOfWeek;
+ int useEpisode;
+ char directory[MaxFileName];
+ int Priority;
+ int Lifetime;
+ int MarginStart;
+ int MarginStop;
+ int useVPS;
+ int action;
+ int useExtEPGInfo;
+ char** catvalues;
+ cChannel *channelMin;
+ cChannel *channelMax;
+ char* channelGroup;
+ int avoidRepeats;
+ int compareTitle;
+ int compareSubtitle;
+ int compareSummary;
+ int allowedRepeats;
+ unsigned long catvaluesAvoidRepeat;
+ int repeatsWithinDays;
+ int delAfterDays;
+ int recordingsKeep;
+ int switchMinsBefore;
+ int pauseOnNrRecordings;
+ int blacklistMode;
+ cList<cBlacklistObject> blacklists;
+ int fuzzyTolerance;
+ int useInFavorites;
+ int menuTemplate;*/
+};
+
+class SearchTimers
+{
+public:
+ typedef std::list< SearchTimer > TimerList;
+ typedef TimerList::size_type size_type;
+ typedef TimerList::iterator iterator;
+ typedef TimerList::const_iterator const_iterator;
+
+ SearchTimers();
+
+ size_type size() const { return m_timers.size(); }
+
+ iterator begin() { return m_timers.begin(); }
+ const_iterator begin() const { return m_timers.begin(); }
+ iterator end() { return m_timers.end(); }
+ const_iterator end() const { return m_timers.end(); }
+
+private:
+ TimerList m_timers;
+};
+
+
+} // namespace vdrlive
+
+#endif // VDR_LIVE_EPGSEARCH_H