]> jfr.im git - irc/evilnet/mod.chanfix.git/blob - sqlChannel.h
Fixed missing include, corebug fix was already applied here.
[irc/evilnet/mod.chanfix.git] / sqlChannel.h
1 /**
2 * sqlChannel.h
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 *
19 * $Id$
20 */
21
22 #ifndef __SQLCHANNEL_H
23 #define __SQLCHANNEL_H "$Id$"
24
25 #include <string>
26 #include <ctime>
27 #include "client.h"
28 #include "dbHandle.h"
29
30 namespace gnuworld
31 {
32
33 namespace cf
34 {
35
36 class sqlcfUser;
37 class sqlManager;
38
39 class sqlChannel
40 {
41 public:
42 sqlChannel(sqlManager*);
43 virtual ~sqlChannel();
44
45 typedef unsigned int flagType ;
46
47 static const flagType F_BLOCKED;
48 static const flagType F_ALERT;
49
50 /*
51 * Channel 'Event' Flags, used in the channelog table.
52 * These flags are used to filter channel log records.
53 * in reports.
54 */
55
56 static const int EV_MISC; /* Uncategorised event */
57 static const int EV_NOTE; /* Miscellaneous notes */
58 static const int EV_CHANFIX; /* Manual chanfixes */
59 static const int EV_SIMULATE; /* Fix simulation */
60 static const int EV_BLOCK; /* Channel block */
61 static const int EV_TEMPBLOCK; /* Temp channel block */
62 static const int EV_UNTEMPBLOCK; /* Temp channel block */
63 static const int EV_UNBLOCK; /* Channel unblock */
64 static const int EV_ALERT; /* Channel alert */
65 static const int EV_UNALERT; /* Channel unalert */
66 static const int EV_REQUESTOP; /* Requestops */
67
68 /*
69 * Methods to get data atrributes.
70 */
71
72
73 inline const unsigned int& getID() const
74 { return id ; }
75
76 inline const std::string& getChannel() const
77 { return channel ; }
78
79 inline const flagType& getFlags() const
80 { return flags ; }
81
82 inline bool getFlag( const flagType& whichFlag ) const
83 { return (flags & whichFlag) ; }
84
85 inline time_t getLastAttempt() const
86 { return last ; }
87
88 inline time_t getLastSimAttempt() const
89 { return simlast ; }
90
91 inline time_t getFixStart() const
92 { return start ; }
93
94 inline time_t getSimStart() const
95 { return simstart ; }
96
97 inline int getMaxScore() const
98 { return maxScore ; }
99
100 inline int getAmountSimOpped() const
101 { return amtopped ; }
102
103 inline int getTMaxScore() const
104 { return tmaxScore ; }
105
106 inline bool getModesRemoved() const
107 { return modesRemoved ; }
108
109 inline bool getSimModesRemoved() const
110 { return simModesRemoved ; }
111
112 inline bool useSQL() const
113 { return inSQL ; }
114
115 /*
116 * Methods to set data atrributes.
117 */
118
119 // 'ID' is a primary key and cannot be altered.
120
121 inline void setID( const unsigned int& _id )
122 { id = _id; }
123
124 inline void setChannel(const std::string& _channel)
125 { channel = _channel; }
126
127 inline void setFlag( const flagType& whichFlag )
128 { flags |= whichFlag; }
129
130 inline void removeFlag( const flagType& whichFlag )
131 { flags &= ~whichFlag; }
132
133 inline void clearFlags()
134 { flags = 0; }
135
136 inline void setLastAttempt (time_t _last)
137 { last = _last; }
138
139 inline void setLastSimAttempt (time_t _simlast)
140 { simlast = _simlast; }
141
142 inline void setFixStart(time_t _start)
143 { start = _start; }
144
145 inline void setSimStart(time_t _simstart)
146 { simstart = _simstart; }
147
148 inline void setAmountSimOpped(unsigned int _amtopped)
149 { amtopped = _amtopped; }
150
151 inline void setMaxScore(unsigned int _maxScore)
152 { maxScore = _maxScore; }
153
154 inline void setTMaxScore(unsigned int _tmaxScore)
155 { tmaxScore = _tmaxScore; }
156
157 inline void setModesRemoved(bool _modesRemoved)
158 { modesRemoved = _modesRemoved; }
159
160 inline void setSimModesRemoved(bool _simModesRemoved)
161 { simModesRemoved = _simModesRemoved; }
162
163 inline void setUseSQL(bool _inSQL)
164 { inSQL = _inSQL; }
165
166 bool Insert(dbHandle*);
167 bool Delete(dbHandle*);
168 bool commit(dbHandle*);
169 void setAllMembers(dbHandle*, int);
170
171 /** Static member for keeping track of max user id */
172 static unsigned long int maxUserId;
173
174 void addNote(dbHandle*, unsigned short, iClient*, const std::string&);
175 bool deleteNote(dbHandle*, unsigned int);
176 bool deleteOldestNote(dbHandle*);
177 bool deleteAllNotes(dbHandle*);
178 size_t countNotes(dbHandle*, unsigned short);
179 const std::string getLastNote(dbHandle*, unsigned short, time_t&);
180
181 protected:
182
183 unsigned int id;
184 std::string channel;
185 std::string user_name;
186 time_t last;
187 time_t simlast;
188 time_t start;
189 time_t simstart;
190 unsigned int amtopped;
191 unsigned int maxScore;
192 unsigned int tmaxScore;
193 bool modesRemoved;
194 bool simModesRemoved;
195 flagType flags;
196 bool inSQL;
197
198 sqlManager* myManager;
199 }; // class sqlChannel
200
201 } // namespace cf
202
203 } // namespace gnuworld
204
205 #endif // __SQLCHANNEL_H