File: timers.h

package info (click to toggle)
vdr-plugin-live 3.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,128 kB
  • sloc: cpp: 12,995; javascript: 3,234; makefile: 241; sh: 40
file content (73 lines) | stat: -rw-r--r-- 2,472 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef VDR_LIVE_TIMERS_H
#define VDR_LIVE_TIMERS_H

// STL headers need to be before VDR tools.h (included by <vdr/timers.h>)
#include <list>
#include <string>

#if TNTVERSION >= 30000
  #include <cxxtools/log.h>  // must be loaded before any VDR include because of duplicate macros (LOG_ERROR, LOG_DEBUG, LOG_INFO)
#endif

#include <vdr/timers.h>
#include "stringhelpers.h"

namespace vdrlive {

  class SortedTimers
  {
    public:
      static std::string GetTimerId(cTimer const& timer);
      static const cTimer* GetByTimerId(cSv timerid, const cTimers* Timers);

      // en- or decodes a timer into an id usable for DOM Ids.
      static std::string EncodeDomId(cSv timerid);
      static std::string DecodeDomId(cSv timerDomId);

      static std::string GetTimerDays(cTimer const *timer);
      static std::string GetTimerInfo(cTimer const& timer);
template<std::size_t N>
      static cSv SearchTimerInfo(cTimer const& timer, const char (&value)[N] ) {
        return partInXmlTag(partInXmlTag(timer.Aux(), "epgsearch"), value);
      }
      static std::string TvScraperTimerInfo(cTimer const& timer, std::string &recID, std::string &recName);
  };

  class TimerManager
  {
    public:
      void UpdateTimer(int timerId, const char* remote, const char* oldRemote, const tChannelID& channel, cStr builder);
      void DelTimer(int timerId, const char* remote);
      void ToggleTimerActive(int timerId, const char* remote);
      static const cTimer* GetTimer(tEventID eventid, tChannelID channelid, const cTimers* Timers);
      static const cTimer* GetTimer(const cEvent *event, const cChannel *channel, const cTimers* Timers);

    private:
      typedef struct
      {
        int id;
        const char* remote;
        const char* oldRemote;
        std::string builder;
      } timerStruct;

      typedef std::pair<timerStruct, std::string> ErrorPair;
      typedef std::list<timerStruct> TimerList;
      typedef std::list<ErrorPair> ErrorList;

      TimerList m_updateTimers;
      ErrorList m_failedUpdates;

      void DoUpdateTimers();
      void DoInsertTimer( timerStruct& timerData );
      void DoUpdateTimer( timerStruct& timerData );
      void DoDeleteTimer( timerStruct& timerData );
      void DoToggleTimer( timerStruct& timerData );

      void StoreError( timerStruct const& timerData, std::string const& error );
      std::string GetError( timerStruct const& timerData );
  };

} // namespace vdrlive

#endif // VDR_LIVE_TIMERS_H