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("%u"), m_client
->GetScore(false, true)));
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)")) % m_client
->GetUserIDHybrid() % (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 switch (m_client
->GetObfuscationStatus()) {
127 case OBST_ENABLED
: buffer
= _("Enabled"); break;
128 case OBST_SUPPORTED
: buffer
= _("Supported"); break;
129 case OBST_NOT_SUPPORTED
: buffer
= _("Not supported"); break;
130 case OBST_DISABLED
: buffer
= _("Disabled"); break;
131 default: buffer
= _("Unknown"); break;
133 CastChild(IDT_OBFUSCATION
, wxStaticText
)->SetLabel(buffer
);
136 if (m_client
->GetKadPort()) {
137 CastChild(IDT_KAD
, wxStaticText
)->SetLabel(_("Connected"));
139 CastChild(IDT_KAD
, wxStaticText
)->SetLabel(_("Disconnected"));
143 const CKnownFile
* file
= m_client
->GetUploadFile();
145 wxString filename
= MakeStringEscaped(file
->GetFileName().TruncatePath(60));
146 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(filename
);
148 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(wxT("-"));
152 CastChild(ID_DDUP
, wxStaticText
)->SetLabel(
153 CastItoXBytes(m_client
->GetTransferredDown()));
156 CastChild(ID_DDOWN
, wxStaticText
)->SetLabel(
157 CastItoXBytes(m_client
->GetTransferredUp()));
159 // Average Upload Rate
160 CastChild(ID_DAVUR
, wxStaticText
)->SetLabel(
161 wxString::Format(_("%.1f kB/s"),
162 m_client
->GetKBpsDown()));
164 // Average Download Rate
165 CastChild(ID_DAVDR
, wxStaticText
)->SetLabel(
166 wxString::Format(_("%.1f kB/s"),
167 m_client
->GetUploadDatarate() / 1024.0f
));
170 CastChild(ID_DUPTOTAL
, wxStaticText
)->SetLabel(
171 CastItoXBytes(m_client
->GetDownloadedTotal()));
174 CastChild(ID_DDOWNTOTAL
, wxStaticText
)->SetLabel(
175 CastItoXBytes(m_client
->GetUploadedTotal()));
178 CastChild(ID_DRATIO
, wxStaticText
)->SetLabel(
179 wxString::Format(wxT("%.1f"),
180 (float)m_client
->GetScoreRatio()));
183 if (theApp
->CryptoAvailable()) {
184 if (m_client
->SUINotSupported()) {
185 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
187 } else if (m_client
->SUIFailed()) {
188 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
190 } else if (m_client
->SUINeeded()) {
191 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
193 } else if (m_client
->IsBadGuy()) {
194 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
196 } else if (m_client
->IsIdentified()) {
197 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
201 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
206 if (m_client
->GetUploadState() != US_NONE
) {
207 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(
208 wxString::Format(_("%u (QR: %u)"),
209 m_client
->GetScore(),
210 m_client
->GetUploadQueueWaitingPosition()));
212 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(wxT("-"));
218 // File_checked_for_headers