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