]> git.vomp.tv Git - jsonserver.git/blob - vdrclient.h
New include for spdlog 1.3.1
[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 epgsearchotherhalf(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
42     bool timerset(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
43     bool recinfo(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
44     bool recstop(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
45     bool recdel(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
46     bool recrename(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
47     bool recmove(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
48     bool timersetactive(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
49     bool timerdel(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
50     bool timerisrecording(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
51     bool recresetresume(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
52     bool timeredit(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
53     bool epgfilteradd(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
54     bool epgfilterdel(PFMap& postFields, Json::Value& js); // throws BadParamException
55
56     cTimer* findTimer(const char* rChannelID, const char* rName, const char* rStartTime, const char* rStopTime, const char* rWeekDays);
57     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);
58     const cEvent* getEvent(Json::Value& js, int channelNumber, int eventID, int aroundTime);
59
60     void pathsForRecordingName(const std::string& recordingName,
61                            std::string& dirNameSingleDate,
62                            std::string& dirNameSingleTitle,
63                            std::string& dirNameSingleFolder,
64                            std::string& dirNameFullPathTitle,
65                            std::string& dirNameFullPathDate);  // throws int
66
67     int getVarInt(PFMap& postFields, const char* paramName); // THROWS
68     std::string getVarString(PFMap& postFields, const char* paramName); // THROWS
69
70     bool loadEpgFilter(libconfig::Config& epgFilter);
71     bool saveEpgFilter(libconfig::Config& epgFilter);
72
73     class BadParamException : public std::exception
74     {
75     public:
76       const char* param;
77       BadParamException(const char* _param) { param = _param; }
78       /*
79       virtual const char* what() const throw()
80       {
81         return "Mine!!";
82       }
83       */
84     };
85 };
86
87 #endif