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 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
35 // CClientDetailDialog dialog
37 BEGIN_EVENT_TABLE(CClientDetailDialog
,wxDialog
)
38 EVT_BUTTON(ID_CLOSEWND
,CClientDetailDialog::OnBnClose
)
42 CClientDetailDialog::CClientDetailDialog(
44 CUpDownClient
*client
)
52 wxDEFAULT_DIALOG_STYLE
)
55 wxSizer
* content
= clientDetails(this, true);
57 content
->SetSizeHints(this);
58 content
->Show(this, true);
61 CClientDetailDialog::~CClientDetailDialog()
65 void CClientDetailDialog::OnBnClose(wxCommandEvent
& WXUNUSED(evt
))
70 bool CClientDetailDialog::OnInitDialog() {
71 // Username, Userhash and Rating
72 if (!m_client
->GetUserName().IsEmpty()) {
73 CastChild(ID_DNAME
, wxStaticText
)->SetLabel(
74 m_client
->GetUserName());
75 // if we have client name we have userhash
76 wxASSERT(!m_client
->GetUserHash().IsEmpty());
77 CastChild(ID_DHASH
, wxStaticText
)->SetLabel(
78 m_client
->GetUserHash().Encode());
79 CastChild(ID_DRATING
, wxStaticText
)->SetLabel(
80 wxString::Format(wxT("%.1f"), m_client
->GetRating()));
82 CastChild(ID_DNAME
, wxStaticText
)->SetLabel(_("Unknown"));
83 CastChild(ID_DHASH
, wxStaticText
)->SetLabel(_("Unknown"));
84 CastChild(ID_DRATING
, wxStaticText
)->SetLabel(_("Unknown"));;
88 wxString OSInfo
= m_client
->GetClientOSInfo();
89 if (!OSInfo
.IsEmpty()) {
90 CastChild(ID_DSOFT
, wxStaticText
)->SetLabel(
91 m_client
->GetSoftStr()+wxT(" (")+OSInfo
+wxT(")"));
93 CastChild(ID_DSOFT
, wxStaticText
)->SetLabel(
94 m_client
->GetSoftStr());
98 CastChild(ID_DVERSION
, wxStaticText
)->SetLabel(
99 m_client
->GetSoftVerStr());
102 CastChild(ID_DID
, wxStaticText
)->SetLabel(
103 CFormat(wxT("%u (%s)")) % ENDIAN_NTOHL(m_client
->GetIP()) % (m_client
->HasLowID() ? _("LowID") : _("HighID")));
106 CastChild(ID_DIP
, wxStaticText
)->SetLabel(
107 m_client
->GetFullIP() +
108 wxString::Format(wxT(":%i"), m_client
->GetUserPort()));
110 // Server IP/Port/Name
111 if (m_client
->GetServerIP()) {
112 wxString srvaddr
= Uint32toStringIP(m_client
->GetServerIP());
113 CastChild(ID_DSIP
, wxStaticText
)->SetLabel(
115 wxString::Format(wxT(":%i"),m_client
->GetServerPort()));
116 CastChild(ID_DSNAME
, wxStaticText
)->SetLabel(
117 m_client
->GetServerName());
119 CastChild(ID_DSIP
, wxStaticText
)->SetLabel(_("Unknown"));
120 CastChild(ID_DSNAME
, wxStaticText
)->SetLabel(_("Unknown"));
124 const CKnownFile
* file
= m_client
->GetUploadFile();
126 wxString filename
= MakeStringEscaped(
127 TruncateFilename(file
->GetFileName(), 60));
128 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(filename
);
130 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(wxT("-"));
134 CastChild(ID_DDUP
, wxStaticText
)->SetLabel(
135 CastItoXBytes(m_client
->GetTransferredDown()));
138 CastChild(ID_DDOWN
, wxStaticText
)->SetLabel(
139 CastItoXBytes(m_client
->GetTransferredUp()));
141 // Average Upload Rate
142 CastChild(ID_DAVUR
, wxStaticText
)->SetLabel(
143 wxString::Format(_("%.1f kB/s"),
144 m_client
->GetKBpsDown()));
146 // Average Download Rate
147 CastChild(ID_DAVDR
, wxStaticText
)->SetLabel(
148 wxString::Format(_("%.1f kB/s"),
149 m_client
->GetUploadDatarate() / 1024.0f
));
152 CastChild(ID_DUPTOTAL
, wxStaticText
)->SetLabel(
153 CastItoXBytes(m_client
->GetDownloadedTotal()));
156 CastChild(ID_DDOWNTOTAL
, wxStaticText
)->SetLabel(
157 CastItoXBytes(m_client
->GetUploadedTotal()));
160 CastChild(ID_DRATIO
, wxStaticText
)->SetLabel(
161 wxString::Format(wxT("%.1f"),
162 (float)m_client
->GetScoreRatio()));
165 if (theApp
->CryptoAvailable()) {
166 if (m_client
->SUINotSupported()) {
167 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
169 } else if (m_client
->SUIFailed()) {
170 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
172 } else if (m_client
->SUINeeded()) {
173 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
175 } else if (m_client
->IsBadGuy()) {
176 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
178 } else if (m_client
->IsIdentified()) {
179 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
183 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
188 if (m_client
->GetUploadState() != US_NONE
) {
189 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(
190 wxString::Format(_("%u (QR: %u)"),
192 false, m_client
->IsDownloading(), false),
193 theApp
->uploadqueue
->GetWaitingPosition(m_client
)));
195 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(wxT("-"));
201 // File_checked_for_headers