2 // This file is part of the aMule Project.
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 )
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 "ClientDetailDialog.h" // Interface declarations
27 #include "PartFile.h" // Needed for CPartFile
28 #include "UploadQueue.h" // Needed for CUploadQueue
29 #include "ServerList.h" // Needed for CServerList
30 #include "amule.h" // Needed for theApp
31 #include "Server.h" // Needed for CServer
32 #include "updownclient.h" // Needed for CUpDownClient
33 #include "muuli_wdr.h" // Needed for ID_CLOSEWND
34 #include "Preferences.h" // Needed for thePrefs
36 // CClientDetailDialog dialog
38 BEGIN_EVENT_TABLE(CClientDetailDialog
,wxDialog
)
39 EVT_BUTTON(ID_CLOSEWND
,CClientDetailDialog::OnBnClose
)
43 CClientDetailDialog::CClientDetailDialog(
45 CUpDownClient
*client
)
53 wxDEFAULT_DIALOG_STYLE
)
56 wxSizer
* content
= clientDetails(this, true);
58 content
->SetSizeHints(this);
59 content
->Show(this, true);
62 CClientDetailDialog::~CClientDetailDialog()
66 void CClientDetailDialog::OnBnClose(wxCommandEvent
& WXUNUSED(evt
))
71 bool CClientDetailDialog::OnInitDialog() {
72 // Username, Userhash and Rating
73 if (!m_client
->GetUserName().IsEmpty()) {
74 CastChild(ID_DNAME
, wxStaticText
)->SetLabel(
75 m_client
->GetUserName());
76 // if we have client name we have userhash
77 wxASSERT(!m_client
->GetUserHash().IsEmpty());
78 CastChild(ID_DHASH
, wxStaticText
)->SetLabel(
79 m_client
->GetUserHash().Encode());
80 CastChild(ID_DRATING
, wxStaticText
)->SetLabel(
81 wxString::Format(wxT("%.1f"), m_client
->GetRating()));
83 CastChild(ID_DNAME
, wxStaticText
)->SetLabel(_("Unknown"));
84 CastChild(ID_DHASH
, wxStaticText
)->SetLabel(_("Unknown"));
85 CastChild(ID_DRATING
, wxStaticText
)->SetLabel(_("Unknown"));;
89 wxString OSInfo
= m_client
->GetClientOSInfo();
90 if (!OSInfo
.IsEmpty()) {
91 CastChild(ID_DSOFT
, wxStaticText
)->SetLabel(
92 m_client
->GetSoftStr()+wxT(" (")+OSInfo
+wxT(")"));
94 CastChild(ID_DSOFT
, wxStaticText
)->SetLabel(
95 m_client
->GetSoftStr());
99 CastChild(ID_DVERSION
, wxStaticText
)->SetLabel(
100 m_client
->GetSoftVerStr());
103 CastChild(ID_DID
, wxStaticText
)->SetLabel(
104 CFormat(wxT("%u (%s)")) % ENDIAN_NTOHL(m_client
->GetIP()) % (m_client
->HasLowID() ? _("LowID") : _("HighID")));
107 CastChild(ID_DIP
, wxStaticText
)->SetLabel(
108 m_client
->GetFullIP() +
109 wxString::Format(wxT(":%i"), m_client
->GetUserPort()));
111 // Server IP/Port/Name
112 if (m_client
->GetServerIP()) {
113 wxString srvaddr
= Uint32toStringIP(m_client
->GetServerIP());
114 CastChild(ID_DSIP
, wxStaticText
)->SetLabel(
116 wxString::Format(wxT(":%i"),m_client
->GetServerPort()));
117 CastChild(ID_DSNAME
, wxStaticText
)->SetLabel(
118 m_client
->GetServerName());
120 CastChild(ID_DSIP
, wxStaticText
)->SetLabel(_("Unknown"));
121 CastChild(ID_DSNAME
, wxStaticText
)->SetLabel(_("Unknown"));
126 if (thePrefs::IsClientCryptLayerSupported()) {
127 if (m_client
->SupportsCryptLayer()) {
128 if ((m_client
->RequestsCryptLayer() || thePrefs::IsClientCryptLayerRequested()) && m_client
->HasObfuscatedConnectionBeenEstablished()) {
129 buffer
= _("Enabled");
131 buffer
= _("Supported");
134 buffer
= _("Not supported");
137 buffer
= _("Disabled");
139 CastChild(IDT_OBFUSCATION
, wxStaticText
)->SetLabel(buffer
);
142 if (m_client
->GetKadPort()) {
143 CastChild(IDT_KAD
, wxStaticText
)->SetLabel(_("Connected"));
145 CastChild(IDT_KAD
, wxStaticText
)->SetLabel(_("Disconnected"));
149 const CKnownFile
* file
= m_client
->GetUploadFile();
151 wxString filename
= MakeStringEscaped(
152 TruncateFilename(file
->GetFileName(), 60));
153 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(filename
);
155 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(wxT("-"));
159 CastChild(ID_DDUP
, wxStaticText
)->SetLabel(
160 CastItoXBytes(m_client
->GetTransferredDown()));
163 CastChild(ID_DDOWN
, wxStaticText
)->SetLabel(
164 CastItoXBytes(m_client
->GetTransferredUp()));
166 // Average Upload Rate
167 CastChild(ID_DAVUR
, wxStaticText
)->SetLabel(
168 wxString::Format(_("%.1f kB/s"),
169 m_client
->GetKBpsDown()));
171 // Average Download Rate
172 CastChild(ID_DAVDR
, wxStaticText
)->SetLabel(
173 wxString::Format(_("%.1f kB/s"),
174 m_client
->GetUploadDatarate() / 1024.0f
));
177 CastChild(ID_DUPTOTAL
, wxStaticText
)->SetLabel(
178 CastItoXBytes(m_client
->GetDownloadedTotal()));
181 CastChild(ID_DDOWNTOTAL
, wxStaticText
)->SetLabel(
182 CastItoXBytes(m_client
->GetUploadedTotal()));
185 CastChild(ID_DRATIO
, wxStaticText
)->SetLabel(
186 wxString::Format(wxT("%.1f"),
187 (float)m_client
->GetScoreRatio()));
190 if (theApp
->CryptoAvailable()) {
191 if (m_client
->SUINotSupported()) {
192 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
194 } else if (m_client
->SUIFailed()) {
195 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
197 } else if (m_client
->SUINeeded()) {
198 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
200 } else if (m_client
->IsBadGuy()) {
201 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
203 } else if (m_client
->IsIdentified()) {
204 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
208 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
213 if (m_client
->GetUploadState() != US_NONE
) {
214 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(
215 wxString::Format(_("%u (QR: %u)"),
217 false, m_client
->IsDownloading(), false),
218 theApp
->uploadqueue
->GetWaitingPosition(m_client
)));
220 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(wxT("-"));
226 // File_checked_for_headers