]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treeserver.h
Remove current time parameter of the Timer constructor
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treeserver.h
index 7792f2191f28e687d25c686fe02930cd5b704086..6bd1a4f7ca1a7da184b7fffec7e037b961094852 100644 (file)
  * TreeServer items, deleting and inserting them as they
  * are created and destroyed.
  */
-class TreeServer : public classbase
+class TreeServer : public Server
 {
        TreeServer* Parent;                     /* Parent entry */
        TreeServer* Route;                      /* Route entry */
        std::vector<TreeServer*> Children;      /* List of child objects */
-       std::string ServerName;                 /* Server's name */
-       std::string ServerDesc;                 /* Server's description */
        std::string VersionString;              /* Version string or empty string */
-       TreeSocket* Socket;                     /* For directly connected servers this points at the socket object */
+
+       /** Full version string including patch version and other info
+        */
+       std::string fullversion;
+
+       TreeSocket* Socket;                     /* Socket used to communicate with this server */
        time_t NextPing;                        /* After this time, the server should be PINGed*/
        bool LastPingWasGood;                   /* True if the server responded to the last PING with a PONG */
        std::string sid;                        /* Server ID */
@@ -56,6 +59,7 @@ class TreeServer : public classbase
        void AddHashEntry();
 
  public:
+       typedef std::vector<TreeServer*> ChildServers;
        FakeUser* const ServerUser;             /* User representing this server */
        const time_t age;
 
@@ -85,18 +89,23 @@ class TreeServer : public classbase
         */
        TreeServer* GetRoute();
 
-       /** Get server name
+       /** Returns true if this server is the tree root (i.e.: us)
         */
-       const std::string& GetName() const { return ServerName; }
+       bool IsRoot() const { return (this->Parent == NULL); }
 
-       /** Get server description (GECOS)
+       /** Returns true if this server is locally connected
         */
-       const std::string& GetDesc();
+       bool IsLocal() const { return (this->Route == this); }
 
        /** Get server version string
         */
        const std::string& GetVersion();
 
+       /** Get the full version string of this server
+        * @return The full version string of this server, including patch version and other info
+        */
+       const std::string& GetFullVersion() const { return fullversion; }
+
        /** Set time we are next due to ping this server
         */
        void SetNextPingTime(time_t t);
@@ -143,13 +152,20 @@ class TreeServer : public classbase
         */
        void SetVersion(const std::string &Version);
 
-       /** Return number of child servers
+       /** Set the full version string
+        * @param verstr The version string to set
         */
-       unsigned int ChildCount();
+       void SetFullVersion(const std::string& verstr) { fullversion = verstr; }
 
-       /** Return a child server indexed 0..n
+       /** Sets the description of this server. Called when the description of a remote server changes
+        * and we are notified about it.
+        * @param descstr The description to set
         */
-       TreeServer* GetChild(unsigned int n);
+       void SetDesc(const std::string& descstr) { description = descstr; }
+
+       /** Return all child servers
+        */
+       const ChildServers& GetChildren() const { return Children; }
 
        /** Add a child server
         */
@@ -163,7 +179,7 @@ class TreeServer : public classbase
         * This is used during netsplits to automatically tidy up the
         * server tree. It is slow, we don't use it for much else.
         */
-       bool Tidy();
+       void Tidy();
 
        /** Get server ID
         */
@@ -175,6 +191,10 @@ class TreeServer : public classbase
        /** Recursive call for child servers */
        void FinishBurstInternal();
 
+       /** (Re)check the uline state of this server
+        */
+       void CheckULine();
+
        CullResult cull();
 
        /** Destructor
@@ -182,4 +202,13 @@ class TreeServer : public classbase
         * hash maps.
         */
        ~TreeServer();
+
+       /** Returns the TreeServer the given user is connected to
+        * @param user The user whose server to return
+        * @return The TreeServer this user is connected to.
+        */
+       static TreeServer* Get(User* user)
+       {
+               return static_cast<TreeServer*>(user->server);
+       }
 };