]> git.vomp.tv Git - jsonserver.git/blob - vdrclient.h
Implement loading and saving EPG filters
[jsonserver.git] / vdrclient.h
1 #ifndef VDRCLIENT_H
2 #define VDRCLIENT_H
3
4 #include <jsoncpp/json/json.h>
5
6 // Log docs: https://github.com/gabime/spdlog
7 #include <spdlog/spdlog.h>
8 namespace spd = spdlog;
9
10 // Config docs: http://www.hyperrealm.com/libconfig/libconfig_manual.html#The-C_002b_002b-API
11 #include <libconfig.h++>
12
13 class cEvent;
14 class cTimer;
15
16 class VDRClient
17 {
18   typedef std::map<std::string, std::string> PFMap;
19
20   public:
21     VDRClient();
22     ~VDRClient();
23
24     bool process(std::string& request, PFMap& postFields, std::string& returnData);
25
26   private:
27     std::shared_ptr<spd::logger> logger;
28     bool gettime(PFMap& postFields, Json::Value& returnJSON);
29     bool diskstats(PFMap& postFields, Json::Value& returnJSON);
30     bool channellist(PFMap& postFields, Json::Value& returnJSON);
31     bool reclist(PFMap& postFields, Json::Value& returnJSON);
32     bool timerlist(PFMap& postFields, Json::Value& returnJSON);
33     bool epgdownload(PFMap& postFields, Json::Value& returnJSON);
34     bool tunersstatus(PFMap& postFields, Json::Value& returnJSON);
35     bool epgfilterget(PFMap& postFields, Json::Value& js);
36
37     bool channelschedule(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
38     bool getscheduleevent(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
39     bool epgsearch(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
40     bool epgsearchsame(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
41     bool timerset(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
42     bool recinfo(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
43     bool recstop(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
44     bool recdel(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
45     bool recrename(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
46     bool recmove(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
47     bool timersetactive(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
48     bool timerdel(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
49     bool timerisrecording(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
50     bool recresetresume(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
51     bool timeredit(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
52     bool epgfilteradd(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
53     bool epgfilterdel(PFMap& postFields, Json::Value& js); // throws BadParamException
54
55     cTimer* findTimer(const char* rChannelID, const char* rName, const char* rStartTime, const char* rStopTime, const char* rWeekDays);
56     cTimer* findTimer2(const char* rName, const char* rActive, const char* rChannelID, const char* rDay, const char* rWeekDays, const char* rStartTime, const char* rStopTime, const char* rPriority, const char* rLifetime);
57     const cEvent* getEvent(Json::Value& js, int channelNumber, int eventID, int aroundTime);
58
59     void pathsForRecordingName(const std::string& recordingName,
60                            std::string& dirNameSingleDate,
61                            std::string& dirNameSingleTitle,
62                            std::string& dirNameSingleFolder,
63                            std::string& dirNameFullPathTitle,
64                            std::string& dirNameFullPathDate);  // throws int
65
66     int getVarInt(PFMap& postFields, const char* paramName); // THROWS
67     std::string getVarString(PFMap& postFields, const char* paramName); // THROWS
68
69     libconfig::Config epgFilter;
70     bool epgFilterLoaded = false;
71     bool loadEpgFilter();
72     void saveEpgFilter();
73
74     class BadParamException : public std::exception
75     {
76     public:
77       const char* param;
78       BadParamException(const char* _param) { param = _param; }
79       /*
80       virtual const char* what() const throw()
81       {
82         return "Mine!!";
83       }
84       */
85     };
86 };
87
88 #endif