Remove do-nothing command and add warning about it
[amule.git] / src / ClientDetailDialog.cpp
blobe2062fc93695134477a11f47f3ece5d37f7a8273
1 //
2 // This file is part of the aMule Project.
3 //
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 )
6 //
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
9 // respective authors.
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)
39 END_EVENT_TABLE()
42 CClientDetailDialog::CClientDetailDialog(
43 wxWindow *parent,
44 const CClientRef& client)
46 wxDialog(
47 parent,
48 9997,
49 _("Client Details"),
50 wxDefaultPosition,
51 wxDefaultSize,
52 wxDEFAULT_DIALOG_STYLE)
54 m_client = client;
55 wxSizer* content = clientDetails(this, true);
56 OnInitDialog();
57 content->SetSizeHints(this);
58 content->Show(this, true);
61 CClientDetailDialog::~CClientDetailDialog()
65 void CClientDetailDialog::OnBnClose(wxCommandEvent& WXUNUSED(evt))
67 EndModal(0);
70 bool CClientDetailDialog::OnInitDialog() {
71 // Username, Userhash
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 } else {
80 CastChild(ID_DNAME, wxStaticText)->SetLabel(_("Unknown"));
81 CastChild(ID_DHASH, wxStaticText)->SetLabel(_("Unknown"));
84 // Client Software
85 wxString OSInfo = m_client.GetClientOSInfo();
86 if (!OSInfo.IsEmpty()) {
87 CastChild(ID_DSOFT, wxStaticText)->SetLabel(
88 m_client.GetSoftStr()+wxT(" (")+OSInfo+wxT(")"));
89 } else {
90 CastChild(ID_DSOFT, wxStaticText)->SetLabel(
91 m_client.GetSoftStr());
94 // Client Version
95 CastChild(ID_DVERSION, wxStaticText)->SetLabel(
96 m_client.GetSoftVerStr());
98 // User ID
99 CastChild(ID_DID, wxStaticText)->SetLabel(
100 CFormat(wxT("%u (%s)")) % m_client.GetUserIDHybrid() % (m_client.HasLowID() ? _("LowID") : _("HighID")));
102 // Client IP/Port
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());
113 } else {
114 CastChild(ID_DSIP, wxStaticText)->SetLabel(_("Unknown"));
115 CastChild(ID_DSNAME, wxStaticText)->SetLabel(_("Unknown"));
118 // Obfuscation
119 wxString buffer;
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);
129 // Kad
130 if (m_client.GetKadPort()) {
131 CastChild(IDT_KAD, wxStaticText)->SetLabel(_("Connected"));
132 } else {
133 CastChild(IDT_KAD, wxStaticText)->SetLabel(_("Disconnected"));
136 // File Name
137 const CKnownFile* file = m_client.GetUploadFile();
138 if (file) {
139 wxString filename = MakeStringEscaped(file->GetFileName().TruncatePath(60));
140 CastChild(ID_DDOWNLOADING, wxStaticText)->SetLabel(filename);
141 } else {
142 CastChild(ID_DDOWNLOADING, wxStaticText)->SetLabel(wxT("-"));
145 // Upload
146 CastChild(ID_DDUP, wxStaticText)->SetLabel(
147 CastItoXBytes(m_client.GetTransferredDown()));
149 // Download
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));
161 // Total Upload
162 CastChild(ID_DUPTOTAL, wxStaticText)->SetLabel(
163 CastItoXBytes(m_client.GetDownloadedTotal()));
165 // Total Download
166 CastChild(ID_DDOWNTOTAL, wxStaticText)->SetLabel(
167 CastItoXBytes(m_client.GetUploadedTotal()));
169 // DL/UP Modifier
170 CastChild(ID_DRATIO, wxStaticText)->SetLabel(
171 CFormat(wxT("%.1f")) % m_client.GetScoreRatio());
173 // Secure Ident
174 CastChild(IDC_CDIDENT, wxStaticText)->SetLabel(
175 m_client.GetSecureIdentTextStatus());
177 // Queue Score
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());
183 } else {
184 CastChild(ID_QUEUERANK, wxStaticText)->SetLabel(wxT("-"));
185 CastChild(ID_DSCORE, wxStaticText)->SetLabel(wxT("-"));
187 Layout();
189 return true;
191 // File_checked_for_headers