]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd_config.cpp
Update Event and Request APIs
[user/henk/code/inspircd.git] / src / modules / m_httpd_config.cpp
index 27b494421b3f796b0170e23672e31b264e1beb34..988ba397790cf3d30cc3f3506f18386203bef678 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *         the file COPYING for details.
@@ -28,16 +28,15 @@ class ModuleHttpStats : public Module
 
        void ReadConfig()
        {
-               ConfigReader c(ServerInstance);
+               ConfigReader c;
                this->stylesheet = c.ReadValue("httpstats", "stylesheet", 0);
        }
 
-       ModuleHttpStats(InspIRCd* Me) : Module(Me)
-       {
+       ModuleHttpStats()       {
                ReadConfig();
                this->changed = true;
-               Implementation eventlist[] = { I_OnEvent, I_OnRequest };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               Implementation eventlist[] = { I_OnEvent };
+               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
        std::string Sanitize(const std::string &str)
@@ -74,14 +73,14 @@ class ModuleHttpStats : public Module
                return ret;
        }
 
-       void OnEvent(Event* event)
+       void OnEvent(Event& event)
        {
                std::stringstream data("");
 
-               if (event->GetEventID() == "httpd_url")
+               if (event.id == "httpd_url")
                {
                        ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
-                       HTTPRequest* http = (HTTPRequest*)event->GetData();
+                       HTTPRequest* http = (HTTPRequest*)&event;
 
                        if ((http->GetURI() == "/config") || (http->GetURI() == "/config/"))
                        {
@@ -100,28 +99,21 @@ class ModuleHttpStats : public Module
 
                                data << "</body></html>";
                                /* Send the document back to m_httpd */
-                               HTTPDocument response(http->sock, &data, 200);
+                               HTTPDocumentResponse response(this, *http, &data, 200);
                                response.headers.SetHeader("X-Powered-By", "m_httpd_config.so");
                                response.headers.SetHeader("Content-Type", "text/html");
-                               Request req((char*)&response, (Module*)this, event->GetSource());
-                               req.Send();
+                               response.Send();
                        }
                }
        }
 
-       const char* OnRequest(Request* request)
-       {
-               return NULL;
-       }
-
-
        virtual ~ModuleHttpStats()
        {
        }
 
        virtual Version GetVersion()
        {
-               return Version("$Id$", VF_VENDOR, API_VERSION);
+               return Version("Provides statistics over HTTP via m_httpd.so", VF_VENDOR, API_VERSION);
        }
 };