vdr  1.7.27
svdrp.h
Go to the documentation of this file.
00001 /*
00002  * svdrp.h: Simple Video Disk Recorder Protocol
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: svdrp.h 2.2 2012/02/16 12:37:53 kls Exp $
00008  */
00009 
00010 #ifndef __SVDRP_H
00011 #define __SVDRP_H
00012 
00013 #include "recording.h"
00014 #include "tools.h"
00015 
00016 class cSocket {
00017 private:
00018   int port;
00019   int sock;
00020   int queue;
00021   void Close(void);
00022 public:
00023   cSocket(int Port, int Queue = 1);
00024   ~cSocket();
00025   bool Open(void);
00026   int Accept(void);
00027   };
00028 
00029 class cPUTEhandler {
00030 private:
00031   FILE *f;
00032   int status;
00033   const char *message;
00034 public:
00035   cPUTEhandler(void);
00036   ~cPUTEhandler();
00037   bool Process(const char *s);
00038   int Status(void) { return status; }
00039   const char *Message(void) { return message; }
00040   };
00041 
00042 class cSVDRP {
00043 private:
00044   cSocket socket;
00045   cFile file;
00046   cRecordings Recordings;
00047   cPUTEhandler *PUTEhandler;
00048   int numChars;
00049   int length;
00050   char *cmdLine;
00051   time_t lastActivity;
00052   static char *grabImageDir;
00053   void Close(bool SendReply = false, bool Timeout = false);
00054   bool Send(const char *s, int length = -1);
00055   void Reply(int Code, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
00056   void PrintHelpTopics(const char **hp);
00057   void CmdCHAN(const char *Option);
00058   void CmdCLRE(const char *Option);
00059   void CmdCPYR(const char *Option);
00060   void CmdDELC(const char *Option);
00061   void CmdDELR(const char *Option);
00062   void CmdDELT(const char *Option);
00063   void CmdEDIT(const char *Option);
00064   void CmdGRAB(const char *Option);
00065   void CmdHELP(const char *Option);
00066   void CmdHITK(const char *Option);
00067   void CmdLSTC(const char *Option);
00068   void CmdLSTE(const char *Option);
00069   void CmdLSTR(const char *Option);
00070   void CmdLSTT(const char *Option);
00071   void CmdMESG(const char *Option);
00072   void CmdMODC(const char *Option);
00073   void CmdMODT(const char *Option);
00074   void CmdMOVC(const char *Option);
00075   void CmdMOVR(const char *Option);
00076   void CmdNEWC(const char *Option);
00077   void CmdNEWT(const char *Option);
00078   void CmdNEXT(const char *Option);
00079   void CmdPLAY(const char *Option);
00080   void CmdPLUG(const char *Option);
00081   void CmdPUTE(const char *Option);
00082   void CmdREMO(const char *Option);
00083   void CmdSCAN(const char *Option);
00084   void CmdSTAT(const char *Option);
00085   void CmdUPDT(const char *Option);
00086   void CmdUPDR(const char *Option);
00087   void CmdVOLU(const char *Option);
00088   void Execute(char *Cmd);
00089 public:
00090   cSVDRP(int Port);
00091   ~cSVDRP();
00092   bool HasConnection(void) { return file.IsOpen(); }
00093   bool Process(void);
00094   static void SetGrabImageDir(const char *GrabImageDir);
00095   };
00096 
00097 #endif //__SVDRP_H