2 // This file is part of the aMule Project.
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 )
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
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 #include "ClientRef.h"
27 #include "amule.h" // Needed fot theApp
30 #include "UpDownClientEC.h" // Needed for CUpDownClient
32 #include "updownclient.h" // Needed for CUpDownClient
35 #ifdef DEBUG_ZOMBIE_CLIENTS
37 #define ASSIGN_MFROM(a) m_from = a
40 #define ASSIGN_MFROM(a)
44 CClientRef::CClientRef(const CClientRef
& ref
)
46 m_client
= ref
.m_client
;
47 ASSIGN_MFROM(wxT("copy ctor of ") + ref
.m_from
);
49 m_client
->Link(MFROM
);
54 CClientRef::CClientRef(CUpDownClient
* client LINKED_FROM
)
59 m_client
->Link(MFROM
);
64 void CClientRef::Link(CUpDownClient
* client LINKED_FROM
)
70 m_client
->Link(MFROM
);
75 void CClientRef::Unlink()
78 m_client
->Unlink(MFROM
);
84 // in amulegui clients are never deleted except when they are marked as removed through EC
87 CUpDownClient
* CClientRef::GetClientChecked()
89 if (m_client
&& m_client
->HasBeenDeleted()) {
90 m_client
->Unlink(MFROM
);
97 CClientRef
& CClientRef::GetRef()
99 if (m_client
&& m_client
->HasBeenDeleted()) {
100 m_client
->Unlink(MFROM
);
107 void CClientRef::Safe_Delete()
109 CUpDownClient
* client
= m_client
;
112 client
->Safe_Delete();
118 #define WRAPC(func) CClientRef::func() const { return m_client->func(); }
121 bool WRAPC(ExtProtocolAvailable
)
122 uint16
WRAPC(GetAvailablePartCount
)
123 const wxString
& WRAPC(GetClientFilename
)
124 const wxString
& WRAPC(GetClientModString
)
125 const wxString
& WRAPC(GetClientOSInfo
)
126 uint8
WRAPC(GetClientSoft
)
127 const wxString
& WRAPC(GetClientVerString
)
128 uint64
WRAPC(GetDownloadedTotal
)
129 uint8
WRAPC(GetDownloadState
)
130 CFriend
* WRAPC(GetFriend
)
131 bool WRAPC(GetFriendSlot
)
132 wxString
WRAPC(GetFullIP
)
134 uint16
WRAPC(GetKadPort
)
135 float WRAPC(GetKBpsDown
)
136 uint16
WRAPC(GetLastDownloadingPart
)
137 uint16
WRAPC(GetNextRequestedPart
)
138 uint8
WRAPC(GetObfuscationStatus
)
139 uint16
WRAPC(GetOldRemoteQueueRank
)
140 const BitVector
& WRAPC(GetPartStatus
)
141 uint16
WRAPC(GetRemoteQueueRank
)
142 CPartFile
* WRAPC(GetRequestFile
)
143 uint32
WRAPC(GetScore
)
144 double WRAPC(GetScoreRatio
)
145 uint32
WRAPC(GetServerIP
)
146 const wxString
WRAPC(GetServerName
)
147 uint16
WRAPC(GetServerPort
)
148 const wxString
& WRAPC(GetSoftStr
)
149 const wxString
& WRAPC(GetSoftVerStr
)
150 int WRAPC(GetSourceFrom
)
151 uint64
WRAPC(GetTransferredDown
)
152 uint64
WRAPC(GetTransferredUp
)
153 uint32
WRAPC(GetUploadDatarate
)
154 uint64
WRAPC(GetUploadedTotal
)
155 const CKnownFile
* WRAPC(GetUploadFile
)
156 uint16
WRAPC(GetUploadQueueWaitingPosition
)
157 uint8
WRAPC(GetUploadState
)
158 size_t WRAPC(GetUpPartCount
)
159 uint32
WRAPC(GetUserIDHybrid
)
160 const wxString
& WRAPC(GetUserName
)
161 uint16_t WRAPC(GetUserPort
)
162 const CMD4Hash
& WRAPC(GetUserHash
)
163 uint32
WRAPC(GetVersion
)
164 bool WRAPC(HasDisabledSharedFiles
)
168 bool WRAPC(IsIdentified
)
169 bool WRAPC(IsRemoteQueueFull
)
170 void WRAPC(RequestSharedFileList
)
172 bool CClientRef::IsUpPartAvailable(uint16 iPart
) const { return m_client
->IsUpPartAvailable(iPart
); }
173 void CClientRef::SetFriend(CFriend
* newfriend
) const { m_client
->SetFriend(newfriend
); }
174 void CClientRef::SetFriendSlot(bool bNV
) const { m_client
->SetFriendSlot(bNV
); }
177 void WRAPC(ClearUploadFileID
)
178 uint16
WRAPC(GetUDPPort
)
179 void CClientRef::SetCommentDirty(bool bDirty
) const { m_client
->SetCommentDirty(bDirty
); }
182 bool CClientRef::SwapToAnotherFile(bool bIgnoreNoNeeded
, bool ignoreSuspensions
, bool bRemoveCompletely
, CPartFile
* toFile
) const
184 return m_client
->SwapToAnotherFile(bIgnoreNoNeeded
, ignoreSuspensions
, bRemoveCompletely
, toFile
);
187 wxString
CClientRef::GetSecureIdentTextStatus() const
190 if (theApp
->CryptoAvailable()) {
191 if (m_client
->SUINotSupported()) {
192 ret
= _("Not supported");
193 } else if (m_client
->SUIFailed()) {
195 } else if (m_client
->SUINeeded()) {
196 ret
= _("Not complete");
197 } else if (m_client
->IsBadGuy()) {
199 } else if (m_client
->IsIdentified()) {
200 ret
= _("Verified - OK");
203 ret
= _("Not Available");