+ /** Create a G-Line.
+ * @param s_time The set time
+ * @param d The duration of the xline
+ * @param src The sender of the xline
+ * @param re The reason of the xline
+ * @param nickname Nickname to match
+ */
+ QLine(time_t s_time, long d, std::string src, std::string re, std::string nickname)
+ : XLine(s_time, d, src, re, "Q"), nick(nickname)
+ {
+ }
+
+ /** Destructor
+ */
+ ~QLine()
+ {
+ }
+ virtual bool Matches(User *u);
+
+ virtual bool Matches(const std::string &str);
+
+ virtual void Apply(User* u);
+
+ virtual const std::string& Displayable();
+
+ /** Nickname mask
+ */
+ std::string nick;
+};
+
+/** XLineFactory is used to generate an XLine pointer, given just the
+ * pattern, timing information and type of line to create. This is used
+ * for example in the spanningtree module which will call an XLineFactory
+ * to create a new XLine when it is inbound on a server link, so that it
+ * does not have to know the specifics of the internals of an XLine class
+ * and/or how to call its constructor.
+ */
+class CoreExport XLineFactory
+{
+ protected:
+
+ std::string type;
+
+ public:
+
+ /** Create an XLine factory
+ * @param t Type of XLine this factory generates
+ */
+ XLineFactory(const std::string &t) : type(t) { }
+
+ /** Return the type of XLine this factory generates
+ * @return The type of XLine this factory generates
+ */
+ virtual const std::string& GetType() { return type; }
+
+ /** Generate a specialized XLine*.
+ * @param set_time Time this line was created
+ * @param duration Duration of the line
+ * @param source The sender of the line, nickname or server
+ * @param reason The reason for the line
+ * @param xline_specific_mask The mask string for the line, specific to the XLine type being created.
+ * @return A specialized XLine class of the given type for this factory.
+ */
+ virtual XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask) = 0;
+
+ virtual bool AutoApplyToUserList(XLine* x) { return true; }
+
+ /** Destructor
+ */
+ virtual ~XLineFactory() { }
+};
+
+/** XLineManager is a class used to manage glines, klines, elines, zlines and qlines,
+ * or any other line created by a module. It also manages XLineFactory classes which
+ * can generate a specialized XLine for use by another module.
+ */
+class CoreExport XLineManager
+{
+ protected:
+ /** Used to hold XLines which have not yet been applied.
+ */
+ std::vector<XLine *> pending_lines;
+
+ /** Current xline factories
+ */
+ XLineFactMap line_factory;
+
+ /** Container of all lines, this is a map of maps which
+ * allows for fast lookup for add/remove of a line, and
+ * the shortest possible timed O(n) for checking a user
+ * against a line.
+ */
+ XLineContainer lookup_lines;
+
+ public:
+
+ /** Constructor
+ */
+ XLineManager();
+
+ /** Destructor
+ */
+ ~XLineManager();
+
+ /** Split an ident and host into two seperate strings.
+ * This allows for faster matching.
+ */
+ IdentHostPair IdentSplit(const std::string &ident_and_host);
+
+ /** Checks what users match e:lines and sets their ban exempt flag accordingly.
+ */
+ void CheckELines();
+
+ /** Get all lines of a certain type to an XLineLookup (std::map<std::string, XLine*>).
+ * NOTE: When this function runs any expired items are removed from the list before it
+ * is returned to the caller.
+ * @param type The type to look up
+ * @return A list of all XLines of the given type.
+ */
+ XLineLookup* GetAll(const std::string &type);
+
+ /** Remove all lines of a certain type.
+ */
+ void DelAll(const std::string &type);
+
+ /** Return all known types of line currently stored by the XLineManager.
+ * @return A vector containing all known line types currently stored in the main list.
+ */
+ std::vector<std::string> GetAllTypes();
+
+ /** Add a new XLine
+ * @param line The line to be added
+ * @param user The user adding the line or NULL for the local server
+ * @return True if the line was added successfully