X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmembership.h;h=05d6b3796fb1ac72e44a035117d927077b4878f0;hb=3ef3047681f0813d8f1d06939eaa2ef378d99505;hp=11c142912ee60e6612980416c924bb514d08809c;hpb=84ae29d0eadb5baa7ad4f517c3ce62995205d2f5;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/membership.h b/include/membership.h index 11c142912..05d6b3796 100644 --- a/include/membership.h +++ b/include/membership.h @@ -112,86 +112,3 @@ class CoreExport Membership : public Extensible, public insp::intrusive_list_nod */ const char* GetAllPrefixChars() const; }; - -template -class InviteBase -{ - protected: - /** List of pending Invitations - */ - insp::intrusive_list invites; - - public: - /** Remove and destruct all pending invitations this user or channel has. - * Must be called before the object is destroyed, also called when the TS of the channel is lowered. - */ - void ClearInvites(); - - friend class Invitation; -}; - -/** - * The Invitation class contains all data about a pending invitation. - * Invitation objects are referenced from the user and the channel they belong to. - */ -class CoreExport Invitation : public insp::intrusive_list_node, public insp::intrusive_list_node -{ - /** Constructs an Invitation, only called by Create() - * @param c Channel the user is invited to - * @param u User being invited - * @param timeout Expiration time for this Invitation - */ - Invitation(Channel* c, LocalUser* u, time_t timeout) : user(u), chan(c), expiry(timeout) {} - - public: - /** User the invitation is for - */ - LocalUser* const user; - - /** Channel where the user is invited to - */ - Channel* const chan; - - /** Timestamp when this Invitation expires or 0 if it doesn't expire. - * Invitation::Create() can update this field; see that for more info. - */ - time_t expiry; - - /** Destructor - * Removes references to this Invitation from the associated user and channel. - */ - ~Invitation(); - - /** Create or extend an Invitation. - * When a user is invited to join a channel either a new Invitation object is created or - * or the expiration timestamp is updated if there is already a pending Invitation for - * the given (user, channel) pair and the new expiration time is further than the current. - * @param c Target channel - * @param u Target user - * @param timeout Timestamp when the invite should expire, 0 for no expiration - */ - static void Create(Channel* c, LocalUser* u, time_t timeout); - - /** Finds the Invitation object for the given channel/user pair. - * @param c Target channel, can be NULL to remove expired entries - * @param u Target user, cannot be NULL - * @param check_expired Pass true to remove all expired invites found while searching, false - * to return with an Invitation even if it's expired - * @return Invitation object for the given (channel, user) pair if it exists, NULL otherwise - */ - static Invitation* Find(Channel* c, LocalUser* u, bool check_expired = true); -}; - -typedef insp::intrusive_list InviteList; - -template -inline void InviteBase::ClearInvites() -{ - for (typename insp::intrusive_list::iterator i = invites.begin(); i != invites.end(); ) - { - Invitation* inv = *i; - // Destructing the Invitation invalidates the iterator, so move it now - ++i; - delete inv; - } -}