Debian Codegraph @

src/bnetd/watch.h

raw symbols SCIP
1 /*
2 * Copyright (C) 1999 Ross Combs ([email protected])
3 * Copyright (C) 2005 Dizzy
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) 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
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 #ifndef PVPGN_BNETD_WATCH_H
20 #define PVPGN_BNETD_WATCH_H
21
22 #include <list>
23
24 #include "common/scoped_ptr.h"
25
26 #include "account.h"
27 #include "connection.h"
28 #include "common/tag.h"
29
30 namespace pvpgn
31 {
32
33 namespace bnetd
34 {
35
36 class Watch
37 {
38 public:
39 enum EventType
40 {
41 ET_login = 1,
42 ET_logout = 2,
43 ET_joingame = 4,
44 ET_leavegame = 8
45 };
46
47 Watch(t_connection* owner_, t_account* who_, unsigned what_, t_clienttag ctag_);
48 ~Watch() throw();
49
50 t_connection* getOwner() const;
51 t_account* getAccount() const;
52 unsigned getEventMask() const;
53 t_clienttag getClientTag() const;
54
55 void setEventMask(unsigned what_);
56
57 private:
58 t_connection * owner; /* who to notify */
59 t_account * who; /* when this account */
60 unsigned what; /* does one of these things */
61 t_clienttag ctag; /* while logged in with this clienttag (0 for any) */
62 };
63
64 class WatchComponent
65 {
66 public:
67 WatchComponent();
68 ~WatchComponent() throw();
69
70 void add(t_connection * owner, t_account * who, t_clienttag clienttag, unsigned events);
71 int del(t_connection * owner, t_account * who, t_clienttag clienttag, unsigned events);
72 void del(t_connection * owner);
73 int dispatch(t_account * who, char const * gamename, t_clienttag clienttag, Watch::EventType event) const;
74
75 private:
76 typedef std::list<Watch> WatchList;
77
78 WatchList wlist;
79
80 int dispatch_whisper(t_account *account, char const *gamename, t_clienttag clienttag, Watch::EventType event) const;
81 };
82
83 extern scoped_ptr<WatchComponent> watchlist;
84
85 }
86
87 }
88
89 #endif