cb21075d |
1 | // ServerQueue.H -*- C++ -*- |
2 | // Copyright (c) 1997, 1998 Etienne BERNARD |
3 | // Copyright (c) 2002 Clinton Ebadi |
4 | |
5 | // This program is free software; you can redistribute it and/or modify |
6 | // it under the terms of the GNU General Public License as published by |
7 | // the Free Software Foundation; either version 2 of the License, or |
8 | // any later version. |
9 | |
10 | // This program is distributed in the hope that it will be useful, |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | // GNU General Public License for more details. |
14 | |
15 | // You should have received a copy of the GNU General Public License |
16 | // along with this program; if not, write to the Free Software |
133eff7a |
17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | // 02110-1301, USA. |
cb21075d |
19 | |
20 | #ifndef SERVERQUEUE_H |
21 | #define SERVERQUEUE_H |
22 | |
23 | #include <list> |
24 | |
cd5342f5 |
25 | #include "BotThreading.H" |
cb21075d |
26 | #include "Queue.H" |
cfa82921 |
27 | #include "String.H" |
28 | |
29 | class ServerQueueItem; |
30 | class Socket; |
cb21075d |
31 | |
32 | enum { |
33 | QUIT_PRIORITY, USERMODE_PRIORITY, CHANNELMODE_PRIORITY, |
34 | KICK_PRIORITY, PONG_PRIORITY, TOPIC_PRIORITY, PART_PRIORITY, |
35 | NICK_PRIORITY, USERHOST_PRIORITY, WHO_PRIORITY, |
36 | JOIN_PRIORITY, PING_PRIORITY, INVITE_PRIORITY, PRIVMSG_PRIORITY, |
37 | NOTICE_PRIORITY |
38 | }; |
39 | |
40 | static const int QUIT_PENALTY = 1; |
41 | static const int USERMODE_PENALTY = 2; |
42 | static const int CHANNELMODE_PENALTY = 2; |
43 | static const int KICK_PENALTY = 2; |
44 | static const int PONG_PENALTY = 1; |
45 | static const int TOPIC_PENALTY = 2; |
46 | static const int PART_PENALTY = 1; |
47 | static const int JOIN_PENALTY = 1; |
48 | static const int USERHOST_PENALTY = 1; |
49 | static const int WHO_PENALTY = 4; |
50 | static const int WHOIS_PENALTY = 1; |
51 | static const int NICK_PENALTY = 1; |
52 | static const int PING_PENALTY = 1; |
53 | static const int INVITE_PENALTY = 1; |
54 | static const int PRIVMSG_PENALTY = 1; |
55 | static const int NOTICE_PENALTY = 1; |
56 | |
57 | |
58 | class ServerQueue : public Queue { |
59 | |
60 | std::list<ServerQueueItem *> serverQueue; |
61 | int penalty; |
cd5342f5 |
62 | BotMutex queue_mutex; |
cb21075d |
63 | |
0b062618 |
64 | static int max_penalty; |
65 | |
cb21075d |
66 | public: |
67 | ServerQueue(Socket *, bool); |
68 | ~ServerQueue(); |
69 | void addItem(ServerQueueItem *); |
70 | void addLine(String, int, int, int); |
71 | bool flush(); |
72 | |
73 | void sendCTCP(String, String, String); |
74 | void sendCTCPReply(String, String, String); |
75 | void sendChannelMode(String); |
76 | void sendChannelMode(String, String, String); |
77 | void sendInvite(String, String); |
78 | void sendJoin(String, String); |
79 | void sendKick(String, String, String); |
80 | void sendNick(String); |
81 | void sendNotice(String, String); |
82 | void sendPart(String); |
83 | void sendPass(String); |
84 | void sendPing(String); |
85 | void sendPong(String); |
86 | void sendPrivmsg(String, String); |
87 | void sendQuit(String); |
88 | void sendTopic(String, String); |
89 | void sendUser(String, String); |
90 | void sendUserMode(String, String); |
91 | void sendUserhost(String); |
92 | void sendWho(String); |
93 | void sendWhois(String); |
94 | }; |
95 | |
96 | #endif |