summaryrefslogtreecommitdiff
path: root/lib/searchtimer.h
blob: 07e841a0c026cb28b00e681fef409ec19bbd007f (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * searchtimer.h
 *
 * See the README file for copyright information
 *
 */

#ifndef __SEARCHTIMER_H
#define __SEARCHTIMER_H

#include "common.h"
#include "db.h"
#include "epgservice.h"
#include "json.h"

class Python;

//***************************************************************************
// Search Timer
//***************************************************************************

class cSearchTimer
{
   public:

      cSearchTimer();
      ~cSearchTimer();

      int init(const char* confDir);
      int initDb();
      int exitDb();

      int modified();  // check if a search timer is modified by user
      int updateSearchTimers(int force = yes, const char* reason = "");

      int getSearchMatches(cDbRow* searchTimer, json_t* obj);
      int getDoneFor(cDbRow* searchTimer, cDbRow* useevent, json_t* obj);
      // int checkTimerConflicts(std::string& mailBody);
      // int getUsedTransponderAt(time_t lStartTime, time_t lEndTime, std::string& mailBody);

      int prepareDoneSelect(cDbRow* useeventsRow, int repeatfields, cDbStatement*& select);
      cDbStatement* prepareSearchStatement(cDbRow* searchTimer, cDbTable* db);
      int matchCriterias(cDbRow* searchTimer, cDbRow* event);
      cDbTable* getTimersDoneDb() { return timersDoneDb; }

   private:

      int createTimer(int id);
      int modifyCreateTimer(cDbRow* timerRow, int& newid);
      // int rejectTimer(cDbRow* timerRow);

      // data

      Python* ptyRecName;

      cDbConnection* connection;

      cDbTable* searchtimerDb;
      cDbTable* useeventsDb;
      cDbTable* timersDoneDb;
      cDbTable* timerDb;
      cDbTable* mapDb;
      cDbTable* vdrDb;

      cDbStatement* selectChannelFromMap;
      cDbStatement* selectDoneTimer;
      cDbStatement* selectActiveSearchtimers;
      cDbStatement* selectSearchtimerMaxModSp;
      cDbStatement* selectAllTimer;
      cDbStatement* selectTimerByEvent;
      // cDbStatement* selectActiveVdrs;
      // cDbStatement* selectConflictingTimers;

      cDbValue startValue;
      cDbValue endValue;

      time_t lastSearchTimerUpdate;

      static int searchField[];
      static const char* searchFieldName[];
      static int repeadCheckField[];
      static const char* repeadCheckFieldName[];

};

//***************************************************************************
#endif // __SEARCHTIMER_H