3 $Date: 2010/10/07 19:45:52 $
10 #include <mysql/mysql.h>
14 #include "module_settings.h"
16 #include "user_traff.h"
19 //-----------------------------------------------------------------------------
20 extern "C" STORE * GetStore();
21 //-----------------------------------------------------------------------------
22 class MYSQL_STORE_SETTINGS
25 MYSQL_STORE_SETTINGS();
26 virtual ~MYSQL_STORE_SETTINGS();
27 virtual int ParseSettings(const MODULE_SETTINGS & s);
28 virtual const string & GetStrError() const;
30 string GetDBUser() const;
31 string GetDBPassword() const;
32 string GetDBHost() const;
33 string GetDBName() const;
36 const MODULE_SETTINGS * settings;
38 int ParseParam(const vector<PARAM_VALUE> & moduleParams,
39 const string & name, string & result);
48 //-----------------------------------------------------------------------------
49 class MYSQL_STORE: public STORE
53 virtual ~MYSQL_STORE();
54 virtual const string & GetStrError() const;
57 virtual int GetUsersList(vector<string> * usersList) const;
58 virtual int AddUser(const string & login) const;
59 virtual int DelUser(const string & login) const;
60 virtual int SaveUserStat(const USER_STAT & stat, const string & login) const;
61 virtual int SaveUserConf(const USER_CONF & conf, const string & login) const;
62 virtual int RestoreUserStat(USER_STAT * stat, const string & login) const;
63 virtual int RestoreUserConf(USER_CONF * conf, const string & login) const;
64 virtual int WriteUserChgLog(const string & login,
65 const string & admLogin,
67 const string & paramName,
68 const string & oldValue,
69 const string & newValue,
70 const string & message = "") const;
71 virtual int WriteUserConnect(const string & login, uint32_t ip) const;
72 virtual int WriteUserDisconnect(const string & login,
74 const DIR_TRAFF & down,
75 const DIR_TRAFF & sessionUp,
76 const DIR_TRAFF & sessionDown,
79 const std::string & reason) const;
81 virtual int WriteDetailedStat(const map<IP_DIR_PAIR, STAT_NODE> & statTree,
83 const string & login) const;
85 virtual int AddMessage(STG_MSG * msg, const string & login) const;
86 virtual int EditMessage(const STG_MSG & msg, const string & login) const;
87 virtual int GetMessage(uint64_t id, STG_MSG * msg, const string & login) const;
88 virtual int DelMessage(uint64_t id, const string & login) const;
89 virtual int GetMessageHdrs(vector<STG_MSG_HDR> * hdrsList, const string & login) const;
91 virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const;
94 virtual int GetAdminsList(vector<string> * adminsList) const;
95 virtual int AddAdmin(const string & login) const;
96 virtual int DelAdmin(const string & login) const;
97 virtual int RestoreAdmin(ADMIN_CONF * ac, const string & login) const;
98 virtual int SaveAdmin(const ADMIN_CONF & ac) const;
101 virtual int GetTariffsList(vector<string> * tariffsList) const;
102 virtual int AddTariff(const string & name) const;
103 virtual int DelTariff(const string & name) const;
104 virtual int SaveTariff(const TARIFF_DATA & td, const string & tariffName) const;
105 virtual int RestoreTariff(TARIFF_DATA * td, const string & tariffName) const;
108 virtual int GetCorpsList(vector<string> *) const {return 0;};
109 virtual int SaveCorp(const CORP_CONF &) const {return 0;};
110 virtual int RestoreCorp(CORP_CONF *, const string &) const {return 0;};
111 virtual int AddCorp(const string &) const {return 0;};
112 virtual int DelCorp(const string &) const {return 0;};
115 virtual int GetServicesList(vector<string> *) const {return 0;};
116 virtual int SaveService(const SERVICE_CONF &) const {return 0;};
117 virtual int RestoreService(SERVICE_CONF *, const string &) const {return 0;};
118 virtual int AddService(const string &) const {return 0;};
119 virtual int DelService(const string &) const {return 0;};
121 //virtual BASE_SETTINGS * GetStoreSettings();
122 virtual void SetSettings(const MODULE_SETTINGS & s);
123 virtual int ParseSettings();
124 virtual const string & GetVersion() const;
127 virtual int WriteLogString(const string & str, const string & login) const;
128 int GetAllParams(vector<string> * ParamList, const string & table, const string & name) const;
129 int CheckAllTables(MYSQL * sock);
130 bool IsTablePresent(const string & str,MYSQL * sock);
131 mutable string errorStr;
133 int MysqlQuery(const char* sQuery,MYSQL * sock) const;
134 int MysqlGetQuery(const char * Query,MYSQL * & sock) const;
135 int MysqlSetQuery(const char * Query) const;
136 MYSQL * MysqlConnect() const ;
138 MYSQL_STORE_SETTINGS storeSettings;
139 MODULE_SETTINGS settings;
140 //mutable MYSQL mysql;
141 //mutable MYSQL* sock;
143 //-----------------------------------------------------------------------------