00001 /* 00002 * 00003 * (C) 2003-2013 Anope Team 00004 * Contact us at team@anope.org 00005 * 00006 * Please read COPYING and README for further details. 00007 * 00008 * Based on the original code of Epona by Lara. 00009 * Based on the original code of Services by Andy Church. 00010 * 00011 */ 00012 00013 #ifndef SERVERS_H 00014 #define SERVERS_H 00015 00016 #include "services.h" 00017 #include "anope.h" 00018 #include "extensible.h" 00019 00020 /* Anope. We are at the top of the server tree, our uplink is 00021 * almost always me->GetLinks()[0]. We never have an uplink. */ 00022 extern CoreExport Server *Me; 00023 00024 namespace Servers 00025 { 00026 /* Retrieves the next free TS6 UID or SID */ 00027 extern CoreExport const Anope::string TS6_UID_Retrieve(); 00028 extern CoreExport const Anope::string TS6_SID_Retrieve(); 00029 00030 /* Gets our uplink. Note we don't actually have an "uplink", this is just 00031 * the only server whose uplink *is* Me that is not a juped server. 00032 * @return Our uplink, or NULL if not uplinked to anything 00033 */ 00034 extern CoreExport Server* GetUplink(); 00035 00036 /* CAPAB/PROTOCTL given by the uplink */ 00037 extern CoreExport std::set<Anope::string> Capab; 00038 } 00039 00042 class CoreExport Server : public Extensible 00043 { 00044 private: 00045 /* Server name */ 00046 Anope::string name; 00047 /* Hops between services and server */ 00048 unsigned int hops; 00049 /* Server description */ 00050 Anope::string description; 00051 /* Server ID */ 00052 Anope::string sid; 00053 /* Links for this server */ 00054 std::vector<Server *> links; 00055 /* Uplink for this server */ 00056 Server *uplink; 00057 /* Server is syncing */ 00058 bool syncing; 00059 /* The server is juped */ 00060 bool juped; 00061 00062 /* Reason this server was quit */ 00063 Anope::string quit_reason; 00064 00065 public: 00074 Server(Server *uplink, const Anope::string &name, unsigned hops, const Anope::string &description, const Anope::string &sid = "", bool jupe = false); 00075 00076 private: 00079 ~Server(); 00080 00081 public: 00082 /* Number of users on the server */ 00083 unsigned users; 00084 00088 void Delete(const Anope::string &reason); 00089 00093 const Anope::string &GetName() const; 00094 00098 unsigned GetHops() const; 00099 00103 void SetDescription(const Anope::string &desc); 00104 00108 const Anope::string &GetDescription() const; 00109 00113 void SetSID(const Anope::string &sid); 00114 00118 const Anope::string &GetSID() const; 00119 00123 const std::vector<Server *> &GetLinks() const; 00124 00128 Server *GetUplink(); 00129 00133 void AddLink(Server *s); 00134 00138 void DelLink(Server *s); 00139 00143 void Sync(bool sync_links); 00144 00148 bool IsSynced() const; 00149 00152 void Unsync(); 00153 00157 bool IsULined() const; 00158 00162 bool IsJuped() const; 00163 00168 void Notice(const BotInfo *source, const Anope::string &message); 00169 00175 static Server *Find(const Anope::string &name, Server *s = NULL); 00176 }; 00177 00178 #endif // SERVERS_H
1.7.1