Replace dynamically built filter list with a static one
[amule.git] / src / UpDownClientEC.h
blob9ee7df42917774fdfb1903e269cf23627b7bfbdc
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2003-2011 Stu Redman ( sturedman@amule.org / http://www.amule.org )
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.
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 UPDOWNCLIENTEC_H
27 #define UPDOWNCLIENTEC_H
29 #include <ec/cpp/ECID.h> // Needed for CECID
30 #include "BitVector.h" // Needed for BitVector
31 #include "ClientRef.h" // Needed for debug defines
33 class CKnownFile;
34 class CPartFile;
35 class CFriend;
38 class CUpDownClient : public CECID
40 friend class CUpDownClientListRem;
41 friend class CClientRef;
42 private:
43 /**
44 * Please note that only the ClientList is allowed to delete the clients.
46 ~CUpDownClient();
48 /**
49 * Reference count which is increased whenever client is linked to a clientref.
50 * Clients are to be stored only by ClientRefs, CUpDownClient * are for temporary
51 * use only.
52 * Linking is done only by CClientRef which is friend, so methods are private.
54 uint16 m_linked;
55 #ifdef DEBUG_ZOMBIE_CLIENTS
56 bool m_linkedDebug;
57 std::multiset<wxString> m_linkedFrom;
58 void Link(const wxString& from) { m_linked++; m_linkedFrom.insert(from); }
59 void Unlink(const wxString& from);
60 wxString GetLinkedFrom() {
61 wxString ret;
62 for (std::multiset<wxString>::iterator it = m_linkedFrom.begin(); it != m_linkedFrom.end(); it++) {
63 ret += *it + wxT(", ");
65 return ret;
67 #else
68 void Link() { m_linked++; }
69 void Unlink();
70 #endif
72 public:
73 CUpDownClient(const class CEC_UpDownClient_Tag *);
75 void RequestSharedFileList();
78 // Wrapped by CClientRef
79 bool ExtProtocolAvailable() const { return m_bEmuleProtocol; }
80 uint16 GetAvailablePartCount() const { return m_AvailPartCount; }
81 const wxString& GetClientFilename() const { return m_clientFilename; }
82 const wxString& GetClientModString() const { return m_strModVersion; }
83 const wxString& GetClientOSInfo() const { return m_sClientOSInfo; }
84 uint8 GetClientSoft() const { return m_clientSoft; }
85 const wxString& GetClientVerString() const { return m_fullClientVerString; }
86 uint64 GetDownloadedTotal() const;
87 uint8 GetDownloadState() const { return m_nDownloadState; }
88 CFriend* GetFriend() const { return m_Friend; }
89 bool GetFriendSlot() const { return m_bFriendSlot; }
90 wxString GetFullIP() const { return Uint32toStringIP(m_dwUserIP); }
91 uint16 GetKadPort() const { return m_nKadPort; }
92 float GetKBpsDown() const { return m_kBpsDown; }
93 uint32 GetIP() const { return m_dwUserIP; }
94 uint16 GetLastDownloadingPart() const { return m_lastDownloadingPart; }
95 uint16 GetNextRequestedPart() const { return m_nextRequestedPart; }
96 uint8 GetObfuscationStatus() const { return m_obfuscationStatus; }
97 uint16 GetOldRemoteQueueRank() const { return m_nOldRemoteQueueRank; }
98 const BitVector& GetPartStatus() const { return m_downPartStatus; }
99 uint16 GetRemoteQueueRank() const { return m_nRemoteQueueRank; }
100 CPartFile* GetRequestFile() const { return m_reqfile; }
101 uint32 GetScore() const { return m_score; }
102 double GetScoreRatio() const;
103 uint32 GetServerIP() const { return m_dwServerIP; }
104 const wxString GetServerName() const { return m_ServerName; }
105 uint16 GetServerPort() const { return m_nServerPort; }
106 const wxString& GetSoftStr() const { return m_clientSoftString; }
107 const wxString& GetSoftVerStr() const { return m_clientVerString; }
108 ESourceFrom GetSourceFrom() const { return m_nSourceFrom; }
109 uint64 GetTransferredDown() const { return m_nTransferredDown; }
110 uint64 GetTransferredUp() const { return m_nTransferredUp; }
111 uint32 GetUploadDatarate() const { return m_nUpDatarate; }
112 uint64 GetUploadedTotal() const;
113 const CKnownFile* GetUploadFile() const { return m_uploadingfile; }
114 uint16 GetUploadQueueWaitingPosition() const { return m_waitingPosition; }
115 uint8 GetUploadState() const { return m_nUploadState; }
116 size_t GetUpPartCount() const { return m_upPartStatus.size(); }
117 const CMD4Hash& GetUserHash() const { return m_UserHash; }
118 uint32 GetUserIDHybrid() const { return m_nUserIDHybrid; }
119 const wxString& GetUserName() const { return m_Username; }
120 uint16 GetUserPort() const { return m_nUserPort; }
121 uint32 GetVersion() const { return m_nClientVersion; }
122 bool HasDisabledSharedFiles() const { return m_fNoViewSharedFiles; }
123 bool HasLowID() const { return IsLowID(m_nUserIDHybrid); }
124 bool IsBadGuy() const { return m_identState == IS_IDBADGUY; }
125 bool IsFriend() const { return m_Friend != NULL; }
126 bool IsIdentified() const { return m_identState == IS_IDENTIFIED; }
127 bool IsRemoteQueueFull() const { return m_bRemoteQueueFull; }
128 bool IsUpPartAvailable(uint16 iPart) const { return ( iPart < m_upPartStatus.size() ) ? m_upPartStatus.get(iPart) : 0; }
129 void RequestSharedFileList() const;
130 void SetFriend(CFriend* newfriend) { m_Friend = newfriend; }
131 void SetFriendSlot(bool bNV) { m_bFriendSlot = bNV; }
132 bool SUIFailed() const { return m_identState == IS_IDFAILED; }
133 bool SUINeeded() const { return m_identState == IS_IDNEEDED; }
134 bool SUINotSupported() const { return m_identState == IS_NOTAVAILABLE; }
135 bool SwapToAnotherFile(bool bIgnoreNoNeeded, bool ignoreSuspensions, bool bRemoveCompletely, CPartFile* toFile = NULL);
138 private:
139 bool m_bEmuleProtocol;
140 uint16 m_AvailPartCount;
141 wxString m_clientFilename;
142 wxString m_strModVersion;
143 wxString m_sClientOSInfo;
144 uint8 m_clientSoft;
145 wxString m_fullClientVerString;
146 uint8 m_nDownloadState;
147 CFriend* m_Friend;
148 bool m_bFriendSlot;
149 uint16 m_nKadPort;
150 float m_kBpsDown;
151 uint32 m_dwUserIP;
152 uint16 m_lastDownloadingPart;
153 uint16 m_nextRequestedPart;
154 uint8 m_obfuscationStatus;
155 uint16 m_nOldRemoteQueueRank;
156 BitVector m_downPartStatus;
157 uint16 m_nRemoteQueueRank;
158 CPartFile* m_reqfile;
159 uint32 m_score;
160 uint32 m_dwServerIP;
161 wxString m_ServerName;
162 uint16 m_nServerPort;
163 wxString m_clientSoftString;
164 wxString m_clientVerString;
165 ESourceFrom m_nSourceFrom;
166 uint64 m_nTransferredDown;
167 uint64 m_nTransferredUp;
168 uint32 m_nUpDatarate;
169 CKnownFile* m_uploadingfile;
170 uint16 m_waitingPosition;
171 uint8 m_nUploadState;
172 BitVector m_upPartStatus;
173 CMD4Hash m_UserHash;
174 uint32 m_nUserIDHybrid;
175 wxString m_Username;
176 uint16 m_nUserPort;
177 uint32 m_nClientVersion;
178 bool m_fNoViewSharedFiles;
179 EIdentState m_identState;
180 bool m_bRemoteQueueFull;
182 // other stuff
183 CClientCredits *credits;
187 #endif