3 $Date: 2010/01/19 11:07:57 $
12 #include "base_settings.h"
13 #include "base_store.h"
14 #include "user_traff.h"
15 #include <mysql/mysql.h>
18 //-----------------------------------------------------------------------------
19 extern "C" BASE_STORE * GetStore();
20 //-----------------------------------------------------------------------------
21 class MYSQL_STORE_SETTINGS//: public BASE_SETTINGS
24 MYSQL_STORE_SETTINGS();
25 virtual ~MYSQL_STORE_SETTINGS();
26 virtual int ParseSettings(const MODULE_SETTINGS & s);
27 virtual const string & GetStrError() const;
29 string GetDBUser() const;
30 string GetDBPassword() const;
31 string GetDBHost() const;
32 string GetDBName() const;
35 const MODULE_SETTINGS * settings;
37 int ParseParam(const vector<PARAM_VALUE> & moduleParams,
38 const string & name, string & result);
47 //-----------------------------------------------------------------------------
48 class MYSQL_STORE: public BASE_STORE
52 virtual ~MYSQL_STORE();
53 virtual const string & GetStrError() const;
56 virtual int GetUsersList(vector<string> * usersList) const;
57 virtual int AddUser(const string & login) const;
58 virtual int DelUser(const string & login) const;
59 virtual int SaveUserStat(const USER_STAT & stat, const string & login) const;
60 virtual int SaveUserConf(const USER_CONF & conf, const string & login) const;
61 virtual int RestoreUserStat(USER_STAT * stat, const string & login) const;
62 virtual int RestoreUserConf(USER_CONF * conf, const string & login) const;
63 virtual int WriteUserChgLog(const string & login,
64 const string & admLogin,
66 const string & paramName,
67 const string & oldValue,
68 const string & newValue,
69 const string & message = "") const;
70 virtual int WriteUserConnect(const string & login, uint32_t ip) const;
71 virtual int WriteUserDisconnect(const string & login,
73 const DIR_TRAFF & down,
74 const DIR_TRAFF & sessionUp,
75 const DIR_TRAFF & sessionDown,
78 const std::string & reason) const;
80 virtual int WriteDetailedStat(const map<IP_DIR_PAIR, STAT_NODE> * statTree,
82 const string & login) const;
84 virtual int AddMessage(STG_MSG * msg, const string & login) const;
85 virtual int EditMessage(const STG_MSG & msg, const string & login) const;
86 virtual int GetMessage(uint64_t id, STG_MSG * msg, const string & login) const;
87 virtual int DelMessage(uint64_t id, const string & login) const;
88 virtual int GetMessageHdrs(vector<STG_MSG_HDR> * hdrsList, const string & login) const;
90 virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const;
93 virtual int GetAdminsList(vector<string> * adminsList) const;
94 virtual int AddAdmin(const string & login) const;
95 virtual int DelAdmin(const string & login) const;
96 virtual int RestoreAdmin(ADMIN_CONF * ac, const string & login) const;
97 virtual int SaveAdmin(const ADMIN_CONF & ac) const;
100 virtual int GetTariffsList(vector<string> * tariffsList) const;
101 virtual int AddTariff(const string & name) const;
102 virtual int DelTariff(const string & name) const;
103 virtual int SaveTariff(const TARIFF_DATA & td, const string & tariffName) const;
104 virtual int RestoreTariff(TARIFF_DATA * td, const string & tariffName) const;
107 virtual int GetCorpsList(vector<string> *) const {return 0;};
108 virtual int SaveCorp(const CORP_CONF &) const {return 0;};
109 virtual int RestoreCorp(CORP_CONF *, const string &) const {return 0;};
110 virtual int AddCorp(const string &) const {return 0;};
111 virtual int DelCorp(const string &) const {return 0;};
114 virtual int GetServicesList(vector<string> *) const {return 0;};
115 virtual int SaveService(const SERVICE_CONF &) const {return 0;};
116 virtual int RestoreService(SERVICE_CONF *, const string &) const {return 0;};
117 virtual int AddService(const string &) const {return 0;};
118 virtual int DelService(const string &) const {return 0;};
120 //virtual BASE_SETTINGS * GetStoreSettings();
121 virtual void SetSettings(const MODULE_SETTINGS & s);
122 virtual int ParseSettings();
123 virtual const string & GetVersion() const;
126 virtual int WriteLogString(const string & str, const string & login) const;
127 int GetAllParams(vector<string> * ParamList, const string & table, const string & name) const;
128 int CheckAllTables(MYSQL * sock);
129 bool IsTablePresent(const string & str,MYSQL * sock);
130 mutable string errorStr;
132 int MysqlQuery(const char* sQuery,MYSQL * sock) const;
133 int MysqlGetQuery(const char * Query,MYSQL * & sock) const;
134 int MysqlSetQuery(const char * Query) const;
135 MYSQL * MysqlConnect() const ;
137 MYSQL_STORE_SETTINGS storeSettings;
138 MODULE_SETTINGS settings;
139 //mutable MYSQL mysql;
140 //mutable MYSQL* sock;
142 //-----------------------------------------------------------------------------
144 #endif //FILE_STORE_H