]> git.stg.codes - stg.git/blob - include/user.h
Rename BASE_AUTH and BASE_STORE to AUTH and STORE
[stg.git] / include / user.h
1 /*
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.
6  *
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.
11  *
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
15  */
16
17 /*
18  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
19  */
20
21 #ifndef USER_H
22 #define USER_H
23
24 #include <ctime>
25 #include <string>
26
27 #include "os_int.h"
28 #include "notifer.h"
29 #include "base_auth.h"
30 #include "stg_message.h"
31 #include "tariff.h"
32 #include "user_traff.h"
33
34 class USER_PROPERTIES;
35
36 class USER {
37 public:
38     virtual int                 WriteConf() = 0;
39     virtual int                 WriteStat() = 0;
40
41     virtual const std::string & GetLogin() const = 0;
42
43     virtual uint32_t            GetCurrIP() const = 0;
44     virtual time_t              GetCurrIPModificationTime() const = 0;
45
46     virtual void                AddCurrIPBeforeNotifier(PROPERTY_NOTIFIER_BASE<uint32_t> * notifier) = 0;
47     virtual void                DelCurrIPBeforeNotifier(PROPERTY_NOTIFIER_BASE<uint32_t> * notifier) = 0;
48
49     virtual void                AddCurrIPAfterNotifier(PROPERTY_NOTIFIER_BASE<uint32_t> * notifier) = 0;
50     virtual void                DelCurrIPAfterNotifier(PROPERTY_NOTIFIER_BASE<uint32_t> * notifier) = 0;
51
52     virtual int                 GetID() const = 0;
53
54     virtual double              GetPassiveTimePart() const = 0;
55
56     virtual const TARIFF *      GetTariff() const = 0;
57     virtual void                ResetNextTariff() = 0;
58
59     #ifdef TRAFF_STAT_WITH_PORTS
60     virtual void                AddTraffStatU(int dir, uint32_t ip, uint16_t port, uint32_t len) = 0;
61     virtual void                AddTraffStatD(int dir, uint32_t ip, uint16_t port, uint32_t len) = 0;
62     #else
63     virtual void                AddTraffStatU(int dir, uint32_t ip, uint32_t len) = 0;
64     virtual void                AddTraffStatD(int dir, uint32_t ip, uint32_t len) = 0;
65     #endif
66
67     virtual const DIR_TRAFF &   GetSessionUpload() const = 0;
68     virtual const DIR_TRAFF &   GetSessionDownload() const = 0;
69
70     virtual bool                GetConnected() const = 0;
71     virtual time_t              GetConnectedModificationTime() const = 0;
72     virtual int                 GetAuthorized() const = 0;
73     virtual int                 Authorize(uint32_t ip,
74                                           uint32_t enabledDirs,
75                                           const AUTH * auth) = 0;
76     virtual void                Unauthorize(const AUTH * auth) = 0;
77     virtual bool                IsAuthorizedBy(const AUTH * auth) const = 0;
78
79     virtual int                 AddMessage(STG_MSG * msg) = 0;
80
81     virtual void                UpdatePingTime(time_t t = 0) = 0;
82     virtual time_t              GetPingTime() const = 0;
83
84     virtual void                Run() = 0;
85
86     virtual const std::string & GetStrError() const = 0;
87
88     virtual USER_PROPERTIES &   GetProperty() = 0;
89     virtual const USER_PROPERTIES & GetProperty() const = 0;
90
91     virtual bool                GetDeleted() const = 0;
92     virtual void                SetDeleted() = 0;
93
94     virtual time_t              GetLastWriteStatTime() const = 0;
95
96     virtual bool                IsInetable() = 0;
97     virtual std::string         GetEnabledDirs() = 0;
98
99     virtual void                OnAdd() = 0;
100     virtual void                OnDelete() = 0;
101 };
102
103 typedef USER * USER_PTR;
104
105 #endif