fix standby
[enigma2.git] / lib / network / httpd.h
index 791d49c..aa8c528 100644 (file)
@@ -4,9 +4,10 @@
 #include <asm/types.h>
 #include <map>
 
+#include <lib/base/object.h>
 #include <lib/base/eptrlist.h>
 #include <lib/base/ebase.h>
-#include <lib/base/estring.h>
+#include <string>
 #include <lib/base/eerror.h>
 #include <lib/network/socket.h>
 #include <lib/network/serversocket.h>
@@ -15,14 +16,17 @@ class eHTTPConnection;
 class eHTTPDataSource;
 class eHTTPD;
 
-class eHTTPPathResolver
+class eHTTPDataSource;
+typedef ePtr<eHTTPDataSource> eHTTPDataSourcePtr;
+
+class iHTTPPathResolver: public iObject
 {
 public:
-       virtual ~eHTTPPathResolver() {}; 
-       virtual eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn)=0;
+       virtual ~iHTTPPathResolver() {}; 
+       virtual RESULT getDataSource(eHTTPDataSourcePtr &source, std::string request, std::string path, eHTTPConnection *conn)=0;
 };
 
-class eHTTPDataSource
+class eHTTPDataSource: public iObject
 {
 protected:
        eHTTPConnection *connection;
@@ -33,8 +37,12 @@ public:
        virtual int doWrite(int bytes); // number of written bytes, -1 for "no more"
 };
 
+typedef ePtr<eHTTPDataSource> eHTTPDataSourcePtr;
+
 class eHTTPError: public eHTTPDataSource
 {
+       DECLARE_REF(eHTTPError);
+private:
        int errcode;
 public:
        eHTTPError(eHTTPConnection *c, int errcode);
@@ -47,13 +55,13 @@ class eHTTPConnection: public eSocket
 {
        void doError(int error);
        
-       int getLine(eString &line);
+       int getLine(std::string &line);
        
        int processLocalState();
        int processRemoteState();
        void writeString(const char *data);
        
-       eHTTPDataSource *data;
+       eHTTPDataSourcePtr data;
        eHTTPD *parent;
        
        int buffersize;
@@ -93,13 +101,13 @@ public:
        ~eHTTPConnection();
        
                // stateRequest
-       eString request, requestpath, httpversion;
+       std::string request, requestpath, httpversion;
        int is09;
        
                // stateResponse
        
        int code;
-       eString code_descr;
+       std::string code_descr;
        
        std::map<std::string,std::string> remote_header, local_header;
        
@@ -110,14 +118,14 @@ public:
 class eHTTPD: public eServerSocket
 {
        friend class eHTTPConnection;
-       ePtrList<eHTTPPathResolver> resolver;
+       eSmartPtrList<iHTTPPathResolver> resolver;
        eMainloop *ml;
 public:
        eHTTPD(int port, eMainloop *ml);
        void newConnection(int socket);
 
-       void addResolver(eHTTPPathResolver *r) { resolver.push_back(r); }
-       void removeResolver(eHTTPPathResolver *r) { resolver.remove(r); }
+       void addResolver(iHTTPPathResolver *r) { resolver.push_back(r); }
+       void removeResolver(iHTTPPathResolver *r) { resolver.remove(r); }
 };
 
 #endif