X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/3886ef930e3fd54894b8798ab17ef4d3bc0b995a..9d093a68b5f3e5a22e243c92ec2e0bd24b10ea38:/projects/stargazer/plugins/configuration/sgconfig-ng/config_thread.h diff --git a/projects/stargazer/plugins/configuration/sgconfig-ng/config_thread.h b/projects/stargazer/plugins/configuration/sgconfig-ng/config_thread.h new file mode 100644 index 00000000..1e6742b3 --- /dev/null +++ b/projects/stargazer/plugins/configuration/sgconfig-ng/config_thread.h @@ -0,0 +1,74 @@ +#ifndef __CONFIG_THREAD_H__ +#define __CONFIG_THREAD_H__ + +#include +#include + +class ADMINS; +class ADMIN; +class TARIFFS; +class USERS; +class SETTINGS; + +namespace boost { + class mutex; +}; + +class CONFIG_THREAD { +public: + CONFIG_THREAD(ADMINS * , TARIFFS * t, USERS * u, const SETTINGS * s); + CONFIG_THREAD(const CONFIG_THREAD & rvalue); + ~CONFIG_THREAD(); + + + void operator() (); + + void SetConnection(int sock, struct sockaddr_in sin); + bool IsDone() const; + + enum {ST_NOOP, ST_OK, ST_ERROR}; + +private: + int sd; + struct sockaddr_in remoteAddr; + bool done; + int state; + uint16_t versionMinor; + uint16_t versionMajor; + std::string message; + std::string login; + std::string password; + std::string xml; + uint32_t respCode; + + BF_KEY key; + unsigned char * iv; + + ADMINS * admins; + TARIFFS * tariffs; + USERS * users; + const SETTINGS * settings; + const ADMIN * currAdmin; + + mutable boost::mutex mutex; + + bool ReadBlock(void * dest, size_t & size, int timeout) const; + bool WriteBlock(const void * source, size_t & size, int timeout) const; + + bool ReadReq(); + void Process(); + void WriteResp() const; + //void MakeErrorXML(); + + bool CheckLogin(const std::string & login, std::string & password); + bool ReceiveData(); + void SendData() const; + + static void TagBegin(void * userData, const char * name, const char ** attr); + static void TagEnd(void * userData, const char * name); + + + CONFIG_THREAD & operator=(const CONFIG_THREAD & rvalue); +}; + +#endif