]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/membership.h
Remove the Kiwi links from the readme.
[user/henk/code/inspircd.git] / include / membership.h
index 11c142912ee60e6612980416c924bb514d08809c..1bac0cf95e90563825e89d998a7f1284d7b53625 100644 (file)
@@ -1,7 +1,10 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2012-2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013-2014, 2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013, 2017-2018 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
@@ -20,7 +23,7 @@
 
 #pragma once
 
-uint64_t ConvToUInt64(const std::string& in);
+#include "convto.h"
 
 /**
  * Represents a member of a channel.
@@ -60,7 +63,7 @@ class CoreExport Membership : public Extensible, public insp::intrusive_list_nod
         */
        static Id IdFromString(const std::string& str)
        {
-               return ConvToUInt64(str);
+               return ConvToNum<Id>(str);
        }
 
        /** Constructor, sets the user and chan fields to the parameters, does NOT update any bookkeeping
@@ -70,13 +73,13 @@ class CoreExport Membership : public Extensible, public insp::intrusive_list_nod
         */
        Membership(User* u, Channel* c) : user(u), chan(c) {}
 
-       /** Returns true if this member has a given prefix mode set
-        * @param m The prefix mode letter to check
+       /** Check if this member has a given prefix mode set
+        * @param pm Prefix mode to check
         * @return True if the member has the prefix mode set, false otherwise
         */
-       inline bool hasMode(char m) const
+       bool HasMode(const PrefixMode* pm) const
        {
-               return modes.find(m) != std::string::npos;
+               return (modes.find(pm->GetModeChar()) != std::string::npos);
        }
 
        /** Returns the rank of this member.
@@ -110,88 +113,10 @@ class CoreExport Membership : public Extensible, public insp::intrusive_list_nod
         * be in rank order, greatest first, as certain IRC clients require
         * this when multiple prefixes are used names lists.
         */
-       const char* GetAllPrefixChars() const;
-};
-
-template <typename T>
-class InviteBase
-{
- protected:
-       /** List of pending Invitations
-        */
-       insp::intrusive_list<Invitation, T> invites;
+       std::string GetAllPrefixChars() const;
 
- 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.
+       /** Sends a server notice to this user in the context of this channel.
+        * @param text The contents of the message to send.
         */
-       void ClearInvites();
-
-       friend class Invitation;
+       void WriteNotice(const std::string& text) const;
 };
-
-/**
- * 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<Invitation, Channel>, public insp::intrusive_list_node<Invitation, LocalUser>
-{
-       /** 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<Invitation, LocalUser> InviteList;
-
-template<typename T>
-inline void InviteBase<T>::ClearInvites()
-{
-       for (typename insp::intrusive_list<Invitation, T>::iterator i = invites.begin(); i != invites.end(); )
-       {
-               Invitation* inv = *i;
-               // Destructing the Invitation invalidates the iterator, so move it now
-               ++i;
-               delete inv;
-       }
-}