]> git.stg.codes - stg.git/blob - include/stg/user.h
Added const-ness for some params.
[stg.git] / include / stg / 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 "message.h"
30 #include "tariff.h"
31 #include "user_traff.h"
32
33 class USER_PROPERTIES;
34 class AUTH;
35
36 typedef PROPERTY_NOTIFIER_BASE<uint32_t> CURR_IP_NOTIFIER;
37 typedef PROPERTY_NOTIFIER_BASE<bool> CONNECTED_NOTIFIER;
38
39 class USER {
40 public:
41     virtual ~USER() {}
42     virtual int                 WriteConf() = 0;
43     virtual int                 WriteStat() = 0;
44
45     virtual const std::string & GetLogin() const = 0;
46
47     virtual uint32_t            GetCurrIP() const = 0;
48     virtual time_t              GetCurrIPModificationTime() const = 0;
49
50     virtual void                AddCurrIPBeforeNotifier(CURR_IP_NOTIFIER * notifier) = 0;
51     virtual void                DelCurrIPBeforeNotifier(const CURR_IP_NOTIFIER * notifier) = 0;
52
53     virtual void                AddCurrIPAfterNotifier(CURR_IP_NOTIFIER * notifier) = 0;
54     virtual void                DelCurrIPAfterNotifier(const CURR_IP_NOTIFIER * notifier) = 0;
55
56     virtual void                AddConnectedBeforeNotifier(CONNECTED_NOTIFIER * notifier) = 0;
57     virtual void                DelConnectedBeforeNotifier(const CONNECTED_NOTIFIER * notifier) = 0;
58
59     virtual void                AddConnectedAfterNotifier(CONNECTED_NOTIFIER * notifier) = 0;
60     virtual void                DelConnectedAfterNotifier(const CONNECTED_NOTIFIER * notifier) = 0;
61
62     virtual int                 GetID() const = 0;
63
64     virtual double              GetPassiveTimePart() const = 0;
65
66     virtual const TARIFF *      GetTariff() const = 0;
67     virtual void                ResetNextTariff() = 0;
68
69     virtual const DIR_TRAFF &   GetSessionUpload() const = 0;
70     virtual const DIR_TRAFF &   GetSessionDownload() const = 0;
71
72     virtual bool                GetConnected() const = 0;
73     virtual time_t              GetConnectedModificationTime() const = 0;
74     virtual int                 GetAuthorized() const = 0;
75     /*virtual int                 Authorize(uint32_t ip,
76                                           uint32_t enabledDirs,
77                                           const AUTH * auth) = 0;
78     virtual void                Unauthorize(const AUTH * auth) = 0;*/
79     virtual bool                IsAuthorizedBy(const AUTH * auth) const = 0;
80
81     virtual int                 AddMessage(STG_MSG * msg) = 0;
82
83     virtual void                UpdatePingTime(time_t t = 0) = 0;
84     virtual time_t              GetPingTime() const = 0;
85
86     virtual void                Run() = 0;
87
88     virtual const std::string & GetStrError() const = 0;
89
90     virtual USER_PROPERTIES &   GetProperty() = 0;
91     virtual const USER_PROPERTIES & GetProperty() const = 0;
92
93     virtual bool                GetDeleted() const = 0;
94     virtual void                SetDeleted() = 0;
95
96     virtual time_t              GetLastWriteStatTime() const = 0;
97
98     virtual bool                IsInetable() = 0;
99     virtual std::string         GetEnabledDirs() = 0;
100
101     virtual void                OnAdd() = 0;
102     virtual void                OnDelete() = 0;
103 };
104
105 typedef USER * USER_PTR;
106 typedef const USER * CONST_USER_PTR;
107
108 #endif