fix seeking in filepush
[enigma2.git] / lib / network / xmlrpc.h
1 #ifndef DISABLE_NETWORK
2
3 #ifndef __xmlrpc_h_
4 #define __xmlrpc_h_
5
6 #include <asm/types.h>
7 #include <map>
8 #include <vector>
9 #include <xmltree.h>
10
11 #include <string>
12 #include <lib/base/eptrlist.h>
13 #include <lib/network/httpd.h>
14
15 #define INSERT(KEY,VALUE) insert(std::pair<std::string, eXMLRPCVariant*>(KEY,VALUE))
16
17 class eXMLRPCVariant
18 {
19         std::map<std::string,eXMLRPCVariant*> *_struct;
20         std::vector<eXMLRPCVariant> *_array;
21         __s32 *_i4;
22         bool *_boolean;
23         std::string *_string;
24         double *_double;
25 //      QDateTime *_datetime;
26 //      QByteArray *_base64;
27         void zero();
28 public:
29         eXMLRPCVariant(std::map<std::string,eXMLRPCVariant*> *_struct);
30         eXMLRPCVariant(std::vector<eXMLRPCVariant> *_array);
31         eXMLRPCVariant(__s32 *_i4);
32         eXMLRPCVariant(bool *_boolean);
33         eXMLRPCVariant(std::string *_string);
34         eXMLRPCVariant(double *_double);
35 //      eXMLRPCVariant(QDateTime *_datetime);
36 //      eXMLRPCVariant(QByteArray *_base64);
37         eXMLRPCVariant(const eXMLRPCVariant &c);
38         ~eXMLRPCVariant();
39         
40         std::map<std::string,eXMLRPCVariant*> *getStruct();
41         std::vector<eXMLRPCVariant> *getArray();
42         __s32 *getI4();
43         bool *getBoolean();
44         std::string *getString();
45         double *getDouble();
46 //      QDateTime *getDatetime();
47 //      QByteArray *getBase64();
48         
49         void toXML(std::string &);
50 };
51
52 class eXMLRPCResponse: public eHTTPDataSource
53 {
54         XMLTreeParser parser;
55         std::string result;
56         int size;
57         int wptr;
58         int doCall();
59 public:
60         eXMLRPCResponse(eHTTPConnection *c);
61         ~eXMLRPCResponse();
62         
63         int doWrite(int);
64         void haveData(void *data, int len);
65 };
66
67 void xmlrpc_initialize(eHTTPD *httpd);
68 void xmlrpc_addMethod(std::string methodName, int (*)(std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant>&));
69 void xmlrpc_fault(ePtrList<eXMLRPCVariant> &res, int faultCode, std::string faultString);
70 int xmlrpc_checkArgs(std::string args, std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant> &res);
71
72 class eHTTPXMLRPCResolver: public iHTTPPathResolver
73 {
74         DECLARE_REF(eHTTPXMLRPCResolver);
75 public:
76         eHTTPXMLRPCResolver();
77         eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn);
78 };
79
80 #endif
81
82 #endif //DISABLE_NETWORK