diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/channels.h | 2 | ||||
-rw-r--r-- | include/membership.h | 25 | ||||
-rw-r--r-- | include/typedefs.h | 4 | ||||
-rw-r--r-- | include/users.h | 13 |
4 files changed, 34 insertions, 10 deletions
diff --git a/include/channels.h b/include/channels.h index 89ac6b86c..7e70fd6c5 100644 --- a/include/channels.h +++ b/include/channels.h @@ -56,7 +56,7 @@ class BanItem : public HostItem * This class represents a channel, and contains its name, modes, topic, topic set time, * etc, and an instance of the BanList type. */ -class CoreExport Channel : public Extensible +class CoreExport Channel : public Extensible, public InviteBase { /** Connect a Channel to a User */ diff --git a/include/membership.h b/include/membership.h index 281d04f70..340f92a12 100644 --- a/include/membership.h +++ b/include/membership.h @@ -35,4 +35,29 @@ class CoreExport Membership : public Extensible unsigned int getRank(); }; +class InviteBase +{ + protected: + InviteList invites; + + public: + void ClearInvites(); + + friend class Invitation; +}; + +class Invitation : public classbase +{ + Invitation(Channel* c, LocalUser* u, time_t timeout) : user(u), chan(c), expiry(timeout) {} + + public: + LocalUser* const user; + Channel* const chan; + time_t expiry; + + ~Invitation(); + static void Create(Channel* c, LocalUser* u, time_t timeout); + static Invitation* Find(Channel* c, LocalUser* u, bool check_expired = true); +}; + #endif diff --git a/include/typedefs.h b/include/typedefs.h index 615af6c9c..7659628d2 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -34,6 +34,8 @@ class DNSRequest; class Extensible; class FakeUser; class InspIRCd; +class Invitation; +class InviteBase; class LocalUser; class Membership; class Module; @@ -72,7 +74,7 @@ typedef std::vector<std::pair<std::string, std::string> > FailedPortList; /** Holds a complete list of all channels to which a user has been invited and has not yet joined, and the time at which they'll expire. */ -typedef std::vector< std::pair<irc::string, time_t> > InvitedList; +typedef std::vector<Invitation*> InviteList; /** Holds a complete list of all allow and deny tags from the configuration file (connection classes) */ diff --git a/include/users.h b/include/users.h index cdc0d8078..66e867ad0 100644 --- a/include/users.h +++ b/include/users.h @@ -29,6 +29,7 @@ #include "inspsocket.h" #include "dns.h" #include "mode.h" +#include "membership.h" /** connect class types */ @@ -740,14 +741,8 @@ class CoreExport UserIOHandler : public StreamSocket typedef unsigned int already_sent_t; -class CoreExport LocalUser : public User +class CoreExport LocalUser : public User, public InviteBase { - /** A list of channels the user has a pending invite to. - * Upon INVITE channels are added, and upon JOIN, the - * channels are removed from this list. - */ - InvitedList invites; - public: LocalUser(int fd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server); CullResult cull(); @@ -835,7 +830,7 @@ class CoreExport LocalUser : public User /** Returns the list of channels this user has been invited to but has not yet joined. * @return A list of channels the user is invited to */ - InvitedList* GetInviteList(); + InviteList& GetInviteList(); /** Returns true if a user is invited to a channel. * @param channel A channel name to look up @@ -856,6 +851,8 @@ class CoreExport LocalUser : public User */ void RemoveInvite(const irc::string &channel); + void RemoveExpiredInvites(); + /** Returns true or false for if a user can execute a privilaged oper command. * This is done by looking up their oper type from User::oper, then referencing * this to their oper classes and checking the commands they can execute. |