]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/conn.h
Solved some TODOs.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / conn.h
index 902cd39461cbafea74a2c4cc398bc298933adf06..e3cb3f0c6e72a26274929c5dd9b49b598315e50a 100644 (file)
 #ifndef __STG_SGCONFIG_CONN_H__
 #define __STG_SGCONFIG_CONN_H__
 
+#include "parser.h"
+
 #include "stg/os_int.h"
 #include "stg/const.h"
 
 #include <stdexcept>
 #include <string>
-#include <map>
 
 #include <expat.h>
 
@@ -38,6 +39,7 @@ class USERS;
 class TARIFFS;
 class ADMIN;
 class BASE_PARSER;
+class PLUGIN_LOGGER;
 
 namespace STG
 {
@@ -52,11 +54,9 @@ class Conn
             Error(const std::string& message) : runtime_error(message.c_str()) {}
         };
 
-        Conn(const SETTINGS & settings,
-             ADMINS & admins,
-             USERS & users,
-             TARIFFS & tariffs,
-             int sock, const sockaddr_in& addr);
+        Conn(const BASE_PARSER::REGISTRY & registry,
+             ADMINS & admins, int sock, const sockaddr_in& addr,
+             PLUGIN_LOGGER & logger);
         ~Conn();
 
         int Sock() const { return m_sock; }
@@ -79,10 +79,9 @@ class Conn
         static const char OK_LOGINS[5];
         static const char ERR_LOGINS[5];
 
-        const SETTINGS & m_settings;
+        const BASE_PARSER::REGISTRY & m_registry;
+
         ADMINS & m_admins;
-        USERS & m_users;
-        TARIFFS & m_tariffs;
 
         ADMIN * m_admin;
 
@@ -98,13 +97,14 @@ class Conn
 
         void * m_buffer;
         size_t m_bufferSize;
-        char m_header[sizeof(STG_HEADER)];
-        char m_login[ADM_LOGIN_LEN + 1];
-        char m_cryptoLogin[ADM_LOGIN_LEN + 1];
+        char m_header[sizeof(STG_HEADER) - 1]; // Without \0
+        char m_login[ADM_LOGIN_LEN]; // Without \0
+        char m_cryptoLogin[ADM_LOGIN_LEN]; // Without \0
         char m_data[1024];
         STG::DECRYPT_STREAM * m_stream;
+        PLUGIN_LOGGER &  m_logger;
 
-        BASE_PARSER * GetParser(const std::string & tag);
+        BASE_PARSER * GetParser(const std::string & tag) const;
 
         bool HandleBuffer(size_t size);
 
@@ -116,6 +116,8 @@ class Conn
         bool WriteAnswer(const void* buffer, size_t size);
         bool WriteResponse();
 
+        void Log(const char * file, const std::string & message);
+
         struct DataState
         {
             DataState(bool f, Conn & c) : final(f), conn(c) {}