3 $Date: 2007/11/17 18:28:39 $
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,
79 virtual int WriteDetailedStat(const map<IP_DIR_PAIR, STAT_NODE> * statTree,
81 const string & login) const;
83 virtual int AddMessage(STG_MSG * msg, const string & login) const;
84 virtual int EditMessage(const STG_MSG & msg, const string & login) const;
85 virtual int GetMessage(uint64_t id, STG_MSG * msg, const string & login) const;
86 virtual int DelMessage(uint64_t id, const string & login) const;
87 virtual int GetMessageHdrs(vector<STG_MSG_HDR> * hdrsList, const string & login) const;
89 virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const;
92 virtual int GetAdminsList(vector<string> * adminsList) const;
93 virtual int AddAdmin(const string & login) const;
94 virtual int DelAdmin(const string & login) const;
95 virtual int RestoreAdmin(ADMIN_CONF * ac, const string & login) const;
96 virtual int SaveAdmin(const ADMIN_CONF & ac) const;
99 virtual int GetTariffsList(vector<string> * tariffsList) const;
100 virtual int AddTariff(const string & name) const;
101 virtual int DelTariff(const string & name) const;
102 virtual int SaveTariff(const TARIFF_DATA & td, const string & tariffName) const;
103 virtual int RestoreTariff(TARIFF_DATA * td, const string & tariffName) const;
106 virtual int GetCorpsList(vector<string> * corpsList) const {return 0;};
107 virtual int SaveCorp(const CORP_CONF & cc) const {return 0;};
108 virtual int RestoreCorp(CORP_CONF * cc, const string & name) const {return 0;};
109 virtual int AddCorp(const string & name) const {return 0;};
110 virtual int DelCorp(const string & name) const {return 0;};
113 virtual int GetServicesList(vector<string> * corpsList) const {return 0;};
114 virtual int SaveService(const SERVICE_CONF & sc) const {return 0;};
115 virtual int RestoreService(SERVICE_CONF * sc, const string & name) const {return 0;};
116 virtual int AddService(const string & name) const {return 0;};
117 virtual int DelService(const string & name) const {return 0;};
119 //virtual BASE_SETTINGS * GetStoreSettings();
120 virtual void SetSettings(const MODULE_SETTINGS & s);
121 virtual int ParseSettings();
122 virtual const string & GetVersion() const;
125 virtual int WriteLogString(const string & str, const string & login) const;
126 int GetAllParams(vector<string> * ParamList, const string & table, const string & name) const;
127 int CheckAllTables(MYSQL * sock);
128 bool IsTablePresent(const string & str,MYSQL * sock);
129 mutable string errorStr;
131 int MysqlQuery(const char* sQuery,MYSQL * sock) const;
132 int MysqlGetQuery(const char * Query,MYSQL * & sock) const;
133 int MysqlSetQuery(const char * Query) const;
134 MYSQL * MysqlConnect() const ;
136 MYSQL_STORE_SETTINGS storeSettings;
137 MODULE_SETTINGS settings;
138 //mutable MYSQL mysql;
139 //mutable MYSQL* sock;
141 //-----------------------------------------------------------------------------
143 #endif //FILE_STORE_H