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) 2002-2011 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 "muuli_wdr.h" // Needed for ID_CLOSEWND
33 #include "Preferences.h" // Needed for thePrefs
35 // CClientDetailDialog dialog
37 BEGIN_EVENT_TABLE(CClientDetailDialog
,wxDialog
)
38 EVT_BUTTON(ID_CLOSEWND
,CClientDetailDialog::OnBnClose
)
42 CClientDetailDialog::CClientDetailDialog(
44 const CClientRef
& 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() {
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());
80 CastChild(ID_DNAME
, wxStaticText
)->SetLabel(_("Unknown"));
81 CastChild(ID_DHASH
, wxStaticText
)->SetLabel(_("Unknown"));
85 wxString OSInfo
= m_client
.GetClientOSInfo();
86 if (!OSInfo
.IsEmpty()) {
87 CastChild(ID_DSOFT
, wxStaticText
)->SetLabel(
88 m_client
.GetSoftStr()+wxT(" (")+OSInfo
+wxT(")"));
90 CastChild(ID_DSOFT
, wxStaticText
)->SetLabel(
91 m_client
.GetSoftStr());
95 CastChild(ID_DVERSION
, wxStaticText
)->SetLabel(
96 m_client
.GetSoftVerStr());
99 CastChild(ID_DID
, wxStaticText
)->SetLabel(
100 CFormat(wxT("%u (%s)")) % m_client
.GetUserIDHybrid() % (m_client
.HasLowID() ? _("LowID") : _("HighID")));
103 CastChild(ID_DIP
, wxStaticText
)->SetLabel(
104 CFormat(wxT("%s:%i")) % m_client
.GetFullIP() % m_client
.GetUserPort());
106 // Server IP/Port/Name
107 if (m_client
.GetServerIP()) {
108 wxString srvaddr
= Uint32toStringIP(m_client
.GetServerIP());
109 CastChild(ID_DSIP
, wxStaticText
)->SetLabel(
110 CFormat(wxT("%s:%i")) % srvaddr
% m_client
.GetServerPort());
111 CastChild(ID_DSNAME
, wxStaticText
)->SetLabel(
112 m_client
.GetServerName());
114 CastChild(ID_DSIP
, wxStaticText
)->SetLabel(_("Unknown"));
115 CastChild(ID_DSNAME
, wxStaticText
)->SetLabel(_("Unknown"));
120 switch (m_client
.GetObfuscationStatus()) {
121 case OBST_ENABLED
: buffer
= _("Enabled"); break;
122 case OBST_SUPPORTED
: buffer
= _("Supported"); break;
123 case OBST_NOT_SUPPORTED
: buffer
= _("Not supported"); break;
124 case OBST_DISABLED
: buffer
= _("Disabled"); break;
125 default: buffer
= _("Unknown"); break;
127 CastChild(IDT_OBFUSCATION
, wxStaticText
)->SetLabel(buffer
);
130 if (m_client
.GetKadPort()) {
131 CastChild(IDT_KAD
, wxStaticText
)->SetLabel(_("Connected"));
133 CastChild(IDT_KAD
, wxStaticText
)->SetLabel(_("Disconnected"));
137 const CKnownFile
* file
= m_client
.GetUploadFile();
139 wxString filename
= MakeStringEscaped(file
->GetFileName().TruncatePath(60));
140 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(filename
);
142 CastChild(ID_DDOWNLOADING
, wxStaticText
)->SetLabel(wxT("-"));
146 CastChild(ID_DDUP
, wxStaticText
)->SetLabel(
147 CastItoXBytes(m_client
.GetTransferredDown()));
150 CastChild(ID_DDOWN
, wxStaticText
)->SetLabel(
151 CastItoXBytes(m_client
.GetTransferredUp()));
153 // Average Upload Rate
154 CastChild(ID_DAVUR
, wxStaticText
)->SetLabel(
155 CFormat(_("%.1f kB/s")) % m_client
.GetKBpsDown());
157 // Average Download Rate
158 CastChild(ID_DAVDR
, wxStaticText
)->SetLabel(
159 CFormat(_("%.1f kB/s")) % (m_client
.GetUploadDatarate() / 1024.0f
));
162 CastChild(ID_DUPTOTAL
, wxStaticText
)->SetLabel(
163 CastItoXBytes(m_client
.GetDownloadedTotal()));
166 CastChild(ID_DDOWNTOTAL
, wxStaticText
)->SetLabel(
167 CastItoXBytes(m_client
.GetUploadedTotal()));
170 CastChild(ID_DRATIO
, wxStaticText
)->SetLabel(
171 CFormat(wxT("%.1f")) % m_client
.GetScoreRatio());
174 CastChild(IDC_CDIDENT
, wxStaticText
)->SetLabel(
175 m_client
.GetSecureIdentTextStatus());
178 if (m_client
.GetUploadState() != US_NONE
) {
179 CastChild(ID_QUEUERANK
, wxStaticText
)->SetLabel(
180 CFormat(wxT("%u")) % m_client
.GetUploadQueueWaitingPosition());
181 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(
182 CFormat(wxT("%u")) % m_client
.GetScore());
184 CastChild(ID_QUEUERANK
, wxStaticText
)->SetLabel(wxT("-"));
185 CastChild(ID_DSCORE
, wxStaticText
)->SetLabel(wxT("-"));
191 // File_checked_for_headers