]> git.vomp.tv Git - jsonserver.git/blob - vdrclient.h
Switch to libmicrohttpd. Rewrite handler.
[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 class cEvent;
11 class cTimer;
12
13 class VDRClient
14 {
15   typedef std::map<std::string, std::string> PFMap;
16
17   public:
18     VDRClient();
19
20     bool process(std::string& request, PFMap& postFields, std::string& returnData);
21
22   private:
23     std::shared_ptr<spd::logger> logger;
24     bool gettime(PFMap& postFields, Json::Value& returnJSON);
25     bool diskstats(PFMap& postFields, Json::Value& returnJSON);
26     bool channellist(PFMap& postFields, Json::Value& returnJSON);
27     bool reclist(PFMap& postFields, Json::Value& returnJSON);
28     bool timerlist(PFMap& postFields, Json::Value& returnJSON);
29     bool epgdownload(PFMap& postFields, Json::Value& returnJSON);
30     bool tunersstatus(PFMap& postFields, Json::Value& returnJSON);
31
32     bool channelschedule(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
33     bool getscheduleevent(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
34     bool epgsearch(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
35     bool epgsearchsame(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
36     bool timerset(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
37     bool recinfo(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
38     bool recstop(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
39     bool recdel(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
40     bool recrename(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
41     bool recmove(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
42     bool timersetactive(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
43     bool timerdel(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
44     bool timerisrecording(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
45     bool recresetresume(PFMap& postFields, Json::Value& returnJSON); // throws BadParamException
46     bool timeredit(PFMap& postFields, Json::Value& returnJSON);
47
48     cTimer* findTimer(const char* rChannelID, const char* rName, const char* rStartTime, const char* rStopTime, const char* rWeekDays);
49     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);
50     const cEvent* getEvent(Json::Value& js, int channelNumber, int eventID, int aroundTime);
51
52     void pathsForRecordingName(const std::string& recordingName,
53                            std::string& dirNameSingleDate,
54                            std::string& dirNameSingleTitle,
55                            std::string& dirNameSingleFolder,
56                            std::string& dirNameFullPathTitle,
57                            std::string& dirNameFullPathDate);  // throws int
58
59     int getVarInt(PFMap& postFields, const char* paramName); // THROWS
60     std::string getVarString(PFMap& postFields, const char* paramName); // THROWS
61
62     class BadParamException : public std::exception
63     {
64     public:
65       const char* param;
66       BadParamException(const char* _param) { param = _param; }
67       /*
68       virtual const char* what() const throw()
69       {
70         return "Mine!!";
71       }
72       */
73     };
74 };
75
76 #endif