Improve speed of category tab title updates
[amule.git] / src / Server.h
blob08b034f017b805baac856048be7c6d76fb40d3a0
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef SERVER_H
27 #define SERVER_H
29 #include "Tag.h"
30 #include "OtherStructs.h"
31 #include <ec/cpp/ECID.h> // Needed for CECID
33 #include <protocol/ed2k/Client2Server/TCP.h>
34 #include <protocol/ed2k/Client2Server/UDP.h>
36 class CFileDataIO;
38 // Server priority
39 #define SRV_PR_LOW 2
40 #define SRV_PR_NORMAL 0
41 #define SRV_PR_HIGH 1
42 // Server priority max and min values
43 #define SRV_PR_MAX 2
44 #define SRV_PR_MID 1
45 #define SRV_PR_MIN 0
47 class CServer : public CECID
49 friend class CServerListRem;
50 public:
51 CServer(ServerMet_Struct* in_data);
52 CServer(uint16 in_port, const wxString i_addr);
53 CServer(CServer* pOld);
54 CServer(class CEC_Server_Tag *);
56 ~CServer();
57 void AddTag(CTag* in_tag) {m_taglist.push_back(in_tag);}
58 const wxString &GetListName() const {return listname;}
59 const wxString &GetFullIP() const {return ipfull;}
61 const wxString &GetAddress() const {
62 if (!dynip.IsEmpty()) {
63 return dynip;
64 } else {
65 return ipfull;
69 // the official port
70 uint16 GetPort() const {return realport ? realport : port;}
71 // the connection port
72 uint16 GetConnPort() const {return port;}
73 void SetPort(uint32 val) {realport = val;}
74 bool AddTagFromFile(CFileDataIO* servermet);
75 void SetListName(const wxString& newname);
76 void SetDescription(const wxString& newdescription);
77 uint32 GetIP() const {return ip;}
78 uint32 GetFiles() const {return files;}
79 uint32 GetUsers() const {return users;}
80 const wxString &GetDescription() const {return description;}
81 uint32 GetPing() const {return ping;}
82 uint32 GetPreferences() const {return preferences;}
83 uint32 GetMaxUsers() const {return maxusers;}
84 void SetMaxUsers(uint32 in_maxusers) {maxusers = in_maxusers;}
85 void SetUserCount(uint32 in_users) {users = in_users;}
86 void SetFileCount(uint32 in_files) {files = in_files;}
87 void ResetFailedCount() {failedcount = 0;}
88 void AddFailedCount() {failedcount++;}
89 uint32 GetFailedCount() const {return failedcount;}
90 void SetID(uint32 newip);
91 const wxString &GetDynIP() const {return dynip;}
92 bool HasDynIP() const {return !dynip.IsEmpty() ;}
93 void SetDynIP(const wxString& newdynip);
95 uint32 GetLastPingedTime() const {return lastpingedtime;}
96 void SetLastPingedTime(uint32 in_lastpingedtime) {lastpingedtime = in_lastpingedtime;}
98 uint32 GetRealLastPingedTime() const {return m_dwRealLastPingedTime;} // last pinged time without any random modificator
99 void SetRealLastPingedTime(uint32 in_lastpingedtime) {m_dwRealLastPingedTime = in_lastpingedtime;}
101 uint32 GetLastPinged() const {return lastpinged;}
102 void SetLastPinged(uint32 in_lastpinged) {lastpinged = in_lastpinged;}
104 void SetPing(uint32 in_ping) {ping = in_ping;}
105 void SetPreference(uint32 in_preferences) {preferences = in_preferences;}
106 void SetIsStaticMember(bool in) {staticservermember=in;}
107 bool IsStaticMember() const {return staticservermember;}
108 uint32 GetChallenge() const {return challenge;}
109 void SetChallenge(uint32 in_challenge) {challenge = in_challenge;}
110 uint32 GetSoftFiles() const {return softfiles;}
111 void SetSoftFiles(uint32 in_softfiles) {softfiles = in_softfiles;}
112 uint32 GetHardFiles() const {return hardfiles;}
113 void SetHardFiles(uint32 in_hardfiles) {hardfiles = in_hardfiles;}
114 const wxString &GetVersion() const {return m_strVersion;}
115 void SetVersion(const wxString &pszVersion) {m_strVersion = pszVersion;}
116 void SetTCPFlags(uint32 uFlags) {m_uTCPFlags = uFlags;}
117 uint32 GetTCPFlags() const {return m_uTCPFlags;}
118 void SetUDPFlags(uint32 uFlags) {m_uUDPFlags = uFlags;}
119 uint32 GetUDPFlags() const {return m_uUDPFlags;}
120 uint32 GetLowIDUsers() const {return m_uLowIDUsers;}
121 void SetLowIDUsers(uint32 uLowIDUsers) {m_uLowIDUsers = uLowIDUsers;}
122 uint32 GetDescReqChallenge() const {return m_uDescReqChallenge;}
123 void SetDescReqChallenge(uint32 uDescReqChallenge) {m_uDescReqChallenge = uDescReqChallenge;}
124 uint8 GetLastDescPingedCount() const {return lastdescpingedcout;}
125 void SetLastDescPingedCount(bool reset);
127 uint16 GetObfuscationPortTCP() const {return m_nObfuscationPortTCP;}
128 void SetObfuscationPortTCP(uint16 nPort) {m_nObfuscationPortTCP = nPort;}
130 uint16 GetObfuscationPortUDP() const {return m_nObfuscationPortUDP;}
131 void SetObfuscationPortUDP(uint16 nPort) {m_nObfuscationPortUDP = nPort;}
133 uint32 GetServerKeyUDP(bool bForce = false) const;
134 void SetServerKeyUDP(uint32 dwServerKeyUDP);
136 bool GetCryptPingReplyPending() const {return m_bCryptPingReplyPending;}
137 void SetCryptPingReplyPending(bool bVal) {m_bCryptPingReplyPending = bVal;}
139 uint32 GetServerKeyUDPIP() const {return m_dwIPServerKeyUDP;}
141 bool GetUnicodeSupport() const {return (GetTCPFlags() & SRV_TCPFLG_UNICODE) != 0;}
142 bool GetRelatedSearchSupport() const {return (GetTCPFlags() & SRV_TCPFLG_RELATEDSEARCH) != 0;}
143 bool SupportsLargeFilesTCP() const {return (GetTCPFlags() & SRV_TCPFLG_LARGEFILES) != 0;}
144 bool SupportsLargeFilesUDP() const {return (GetUDPFlags() & SRV_UDPFLG_LARGEFILES) != 0;}
145 bool SupportsObfuscationUDP() const {return (GetUDPFlags() & SRV_UDPFLG_UDPOBFUSCATION) != 0;}
146 bool SupportsObfuscationTCP() const {return (GetObfuscationPortTCP() != 0) && (((GetUDPFlags() & SRV_UDPFLG_TCPOBFUSCATION) != 0) || ((GetTCPFlags() & SRV_TCPFLG_TCPOBFUSCATION) != 0));}
147 bool SupportsGetSourcesObfuscation() const {return (GetTCPFlags() & SRV_TCPFLG_TCPOBFUSCATION) != 0;} // mapped to TCPFLAG_TCPOBFU
149 const wxString& GetAuxPortsList() const {return m_auxPorts;}
150 void SetAuxPortsList(const wxString& val) {m_auxPorts = val;}
152 uint64 GetLastDNSSolve() const { return m_lastdnssolve; }
153 void SetLastDNSSolve(uint64 value) { m_lastdnssolve = value; }
155 bool GetDNSError() const { return m_dnsfailure; }
156 void SetDNSError(bool value) { m_dnsfailure = value; }
158 private:
159 uint32 challenge;
160 uint32 lastpinged; //This is to get the ping delay.
161 uint32 lastpingedtime; //This is to decided when we retry the ping.
162 uint32 files;
163 uint32 users;
164 uint32 maxusers;
165 uint32 softfiles;
166 uint32 hardfiles;
167 uint32 preferences;
168 uint32 ping;
169 wxString description;
170 wxString listname;
171 wxString dynip;
172 uint32 tagcount;
173 wxString ipfull;
174 uint32 ip;
175 uint16 port;
176 uint16 realport;
177 uint32 failedcount;
178 uint32 m_uDescReqChallenge;
179 uint8 lastdescpingedcout;
180 TagPtrList m_taglist;
181 bool staticservermember;
182 wxString m_strVersion;
183 uint32 m_uTCPFlags;
184 uint32 m_uUDPFlags;
185 uint32 m_uLowIDUsers;
186 wxString m_auxPorts;
188 uint64 m_lastdnssolve;
189 bool m_dnsfailure;
191 bool m_bCryptPingReplyPending;
192 uint32 m_dwServerKeyUDP;
193 uint32 m_dwIPServerKeyUDP;
194 uint16 m_nObfuscationPortTCP;
195 uint16 m_nObfuscationPortUDP;
197 uint32 m_dwRealLastPingedTime;
199 void Init();
202 #endif // SERVER_H
203 // File_checked_for_headers