2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
23 $Date: 2010/01/19 11:06:53 $
31 #include <sys/types.h>
36 #include "base_settings.h"
37 #include "base_store.h"
38 #include "conffiles.h"
39 #include "user_traff.h"
42 //-----------------------------------------------------------------------------
43 extern "C" BASE_STORE * GetStore();
44 //-----------------------------------------------------------------------------
45 class FILES_STORE_SETTINGS//: public BASE_SETTINGS
48 FILES_STORE_SETTINGS();
49 virtual ~FILES_STORE_SETTINGS();
50 virtual int ParseSettings(const MODULE_SETTINGS & s);
51 virtual const string & GetStrError() const;
53 string GetWorkDir() const;
54 string GetUsersDir() const;
55 string GetAdminsDir() const;
56 string GetTariffsDir() const;
58 mode_t GetStatMode() const;
59 mode_t GetStatModeDir() const;
60 uid_t GetStatUID() const;
61 gid_t GetStatGID() const;
63 mode_t GetConfMode() const;
64 mode_t GetConfModeDir() const;
65 uid_t GetConfUID() const;
66 gid_t GetConfGID() const;
68 mode_t GetLogMode() const;
69 uid_t GetLogUID() const;
70 gid_t GetLogGID() const;
72 bool GetRemoveBak() const;
73 bool GetReadBak() const;
76 const MODULE_SETTINGS * settings;
78 int User2UID(const char * user, uid_t * uid);
79 int Group2GID(const char * gr, gid_t * gid);
80 int Str2Mode(const char * str, mode_t * mode);
81 int ParseOwner(const vector<PARAM_VALUE> & moduleParams, const string & owner, uid_t * uid);
82 int ParseGroup(const vector<PARAM_VALUE> & moduleParams, const string & group, uid_t * uid);
83 int ParseMode(const vector<PARAM_VALUE> & moduleParams, const string & modeStr, mode_t * mode);
84 int ParseYesNo(const string & value, bool * val);
108 //-----------------------------------------------------------------------------
109 class FILES_STORE: public BASE_STORE
113 virtual ~FILES_STORE();
114 virtual const string & GetStrError() const;
117 virtual int GetUsersList(vector<string> * usersList) const;
118 virtual int AddUser(const string & login) const;
119 virtual int DelUser(const string & login) const;
120 virtual int SaveUserStat(const USER_STAT & stat, const string & login) const;
121 virtual int SaveUserConf(const USER_CONF & conf, const string & login) const;
123 virtual int RestoreUserStat(USER_STAT * stat, const string & login) const;
124 virtual int RestoreUserConf(USER_CONF * conf, const string & login) const;
126 virtual int WriteUserChgLog(const string & login,
127 const string & admLogin,
129 const string & paramName,
130 const string & oldValue,
131 const string & newValue,
132 const string & message = "") const;
133 virtual int WriteUserConnect(const string & login, uint32_t ip) const;
134 virtual int WriteUserDisconnect(const string & login,
135 const DIR_TRAFF & up,
136 const DIR_TRAFF & down,
137 const DIR_TRAFF & sessionUp,
138 const DIR_TRAFF & sessionDown,
141 const std::string & reason) const;
143 virtual int WriteDetailedStat(const map<IP_DIR_PAIR, STAT_NODE> & statTree,
145 const string & login) const;
147 virtual int AddMessage(STG_MSG * msg, const string & login) const;
148 virtual int EditMessage(const STG_MSG & msg, const string & login) const;
149 virtual int GetMessage(uint64_t id, STG_MSG * msg, const string & login) const;
150 virtual int DelMessage(uint64_t id, const string & login) const;
151 virtual int GetMessageHdrs(vector<STG_MSG_HDR> * hdrsList, const string & login) const;
152 virtual int ReadMessage(const string & fileName,
154 string * text) const;
156 virtual int SaveMonthStat(const USER_STAT & stat, int month, int year, const string & login) const;
159 virtual int GetAdminsList(vector<string> * adminsList) const;
160 virtual int AddAdmin(const string & login) const;
161 virtual int DelAdmin(const string & login) const;
162 virtual int RestoreAdmin(ADMIN_CONF * ac, const string & login) const;
163 virtual int SaveAdmin(const ADMIN_CONF & ac) const;
166 virtual int GetTariffsList(vector<string> * tariffsList) const;
167 virtual int AddTariff(const string & name) const;
168 virtual int DelTariff(const string & name) const;
169 virtual int SaveTariff(const TARIFF_DATA & td, const string & tariffName) const;
170 virtual int RestoreTariff(TARIFF_DATA * td, const string & tariffName) const;
173 virtual int GetCorpsList(vector<string> *) const {return 0;};
174 virtual int SaveCorp(const CORP_CONF &) const {return 0;};
175 virtual int RestoreCorp(CORP_CONF *, const string &) const {return 0;};
176 virtual int AddCorp(const string &) const {return 0;};
177 virtual int DelCorp(const string &) const {return 0;};
180 virtual int GetServicesList(vector<string> *) const {return 0;};
181 virtual int SaveService(const SERVICE_CONF &) const {return 0;};
182 virtual int RestoreService(SERVICE_CONF *, const string &) const {return 0;};
183 virtual int AddService(const string &) const {return 0;};
184 virtual int DelService(const string &) const {return 0;};
186 //virtual BASE_SETTINGS * GetStoreSettings();
187 virtual void SetSettings(const MODULE_SETTINGS & s);
188 virtual int ParseSettings();
189 virtual const string & GetVersion() const;
192 virtual int RestoreUserStat(USER_STAT * stat, const string & login, const string & fileName) const;
193 virtual int RestoreUserConf(USER_CONF * conf, const string & login, const string & fileName) const;
195 virtual int WriteLogString(const string & str, const string & login) const;
196 virtual int WriteLog2String(const string & str, const string & login) const;
197 int RemoveDir(const char * path) const;
198 int Touch(const std::string & path) const;
200 mutable string errorStr;
202 FILES_STORE_SETTINGS storeSettings;
203 MODULE_SETTINGS settings;
204 mutable pthread_mutex_t mutex;
206 //-----------------------------------------------------------------------------
208 #endif //FILE_STORE_H