PageRenderTime 80ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/srchybrid/StatisticsDlg.cpp

https://github.com/acat/emule
C++ | 3498 lines | 2949 code | 277 blank | 272 comment | 646 complexity | d574d37a32225f8da8c164e512d36778 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-3.0, BSD-3-Clause
  1. //this file is part of eMule
  2. //Copyright (C)2002-2008 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net )
  3. //
  4. //This program is free software; you can redistribute it and/or
  5. //modify it under the terms of the GNU General Public License
  6. //as published by the Free Software Foundation; either
  7. //version 2 of the License, or (at your option) any later version.
  8. //
  9. //This program is distributed in the hope that it will be useful,
  10. //but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. //GNU General Public License for more details.
  13. //
  14. //You should have received a copy of the GNU General Public License
  15. //along with this program; if not, write to the Free Software
  16. //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. #include "stdafx.h"
  18. #include "emule.h"
  19. #include "StatisticsDlg.h"
  20. #include "UploadQueue.h"
  21. #include "Statistics.h"
  22. #include "emuledlg.h"
  23. #include "OtherFunctions.h"
  24. #include "WebServer.h"
  25. #include "DownloadQueue.h"
  26. #include "ClientList.h"
  27. #include "Preferences.h"
  28. #include "ListenSocket.h"
  29. #include "ServerList.h"
  30. #include "SharedFileList.h"
  31. #include "UpDownClient.h"
  32. #include "UserMsgs.h"
  33. #include "HelpIDs.h"
  34. #include "Kademlia/Kademlia/kademlia.h"
  35. #include "Kademlia/Kademlia/Prefs.h"
  36. #include "kademlia/kademlia/UDPFirewallTester.h"
  37. #ifdef _DEBUG
  38. #define new DEBUG_NEW
  39. #undef THIS_FILE
  40. static char THIS_FILE[] = __FILE__;
  41. #endif
  42. #ifdef _DEBUG
  43. extern _CRT_ALLOC_HOOK g_pfnPrevCrtAllocHook;
  44. #endif
  45. // CStatisticsDlg dialog
  46. IMPLEMENT_DYNAMIC(CStatisticsDlg, CDialog)
  47. BEGIN_MESSAGE_MAP(CStatisticsDlg, CResizableDialog)
  48. ON_WM_SHOWWINDOW()
  49. ON_WM_SIZE()
  50. ON_BN_CLICKED(IDC_BNMENU, OnMenuButtonClicked)
  51. ON_WM_SYSCOLORCHANGE()
  52. ON_WM_CTLCOLOR()
  53. ON_STN_DBLCLK(IDC_SCOPE_D, OnStnDblclickScopeD)
  54. ON_STN_DBLCLK(IDC_SCOPE_U, OnStnDblclickScopeU)
  55. ON_STN_DBLCLK(IDC_STATSSCOPE, OnStnDblclickStatsscope)
  56. ON_MESSAGE(UM_OSCOPEPOSITION, OnOscopePositionMsg)
  57. ON_WM_HELPINFO()
  58. END_MESSAGE_MAP()
  59. CStatisticsDlg::CStatisticsDlg(CWnd* pParent /*=NULL*/)
  60. : CResizableDialog(CStatisticsDlg::IDD, pParent)
  61. , m_DownloadOMeter(3)
  62. , m_Statistics(4)
  63. , m_UploadOMeter(5)
  64. {
  65. m_oldcx=0;
  66. m_oldcy=0;
  67. m_TimeToolTips = NULL;
  68. }
  69. CStatisticsDlg::~CStatisticsDlg()
  70. {
  71. delete m_TimeToolTips;
  72. #ifdef _DEBUG
  73. POSITION pos = blockFiles.GetStartPosition();
  74. while (pos != NULL)
  75. {
  76. const unsigned char* fileName;
  77. HTREEITEM* pTag;
  78. blockFiles.GetNextAssoc(pos, fileName, pTag);
  79. delete pTag;
  80. }
  81. #endif
  82. }
  83. void CStatisticsDlg::DoDataExchange(CDataExchange* pDX)
  84. {
  85. CResizableDialog::DoDataExchange(pDX);
  86. DDX_Control(pDX, IDC_STATTREE, stattree);
  87. }
  88. void CStatisticsDlg::OnSysColorChange()
  89. {
  90. CResizableDialog::OnSysColorChange();
  91. SetAllIcons();
  92. }
  93. void CStatisticsDlg::SetAllIcons()
  94. {
  95. InitWindowStyles(this);
  96. CImageList iml;
  97. iml.Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1);
  98. iml.Add(CTempIconLoader(_T("StatsGeneric"))); // Dots & Arrow (Default icon for stats)
  99. iml.Add(CTempIconLoader(_T("TransferUpDown"))); // Transfer
  100. iml.Add(CTempIconLoader(_T("Connection"))); // Connection
  101. iml.Add(CTempIconLoader(_T("StatsClients"))); // Clients
  102. iml.Add(CTempIconLoader(_T("Server"))); // Server
  103. iml.Add(CTempIconLoader(_T("SharedFiles"))); // Shared Files
  104. iml.Add(CTempIconLoader(_T("Upload"))); // Transfer > Upload
  105. iml.Add(CTempIconLoader(_T("Download"))); // Transfer > Download
  106. iml.Add(CTempIconLoader(_T("StatsDetail"))); // Session Sections
  107. iml.Add(CTempIconLoader(_T("StatsCumulative"))); // Cumulative Sections
  108. iml.Add(CTempIconLoader(_T("StatsRecords"))); // Records
  109. iml.Add(CTempIconLoader(_T("TransferUpDown"))); // Connection > General
  110. iml.Add(CTempIconLoader(_T("StatsTime"))); // Time Section
  111. iml.Add(CTempIconLoader(_T("StatsProjected"))); // Time > Averages and Projections
  112. iml.Add(CTempIconLoader(_T("StatsDay"))); // Time > Averages and Projections > Daily
  113. iml.Add(CTempIconLoader(_T("StatsMonth"))); // Time > Averages and Projections > Monthly
  114. iml.Add(CTempIconLoader(_T("StatsYear"))); // Time > Averages and Projections > Yearly
  115. iml.Add(CTempIconLoader(_T("HardDisk"))); // Diskspace
  116. stattree.SetImageList(&iml, TVSIL_NORMAL);
  117. imagelistStatTree.DeleteImageList();
  118. imagelistStatTree.Attach(iml.Detach());
  119. COLORREF crBk = GetSysColor(COLOR_WINDOW);
  120. COLORREF crFg = GetSysColor(COLOR_WINDOWTEXT);
  121. theApp.LoadSkinColorAlt(_T("StatisticsTvBk"), _T("DefLvBk"), crBk);
  122. theApp.LoadSkinColorAlt(_T("StatisticsTvFg"), _T("DefLvFg"), crFg);
  123. stattree.SetBkColor(crBk);
  124. stattree.SetTextColor(crFg);
  125. // can't use 'TVM_SETLINECOLOR' because the color may not match that one used in "StatsGeneric" item image.
  126. //stattree.SendMessage(TVM_SETLINECOLOR, 0, (LPARAM)crFg);
  127. }
  128. BOOL CStatisticsDlg::OnInitDialog()
  129. {
  130. CResizableDialog::OnInitDialog();
  131. EnableWindow(FALSE);
  132. SetAllIcons();
  133. m_bTreepaneHidden=false;
  134. if (theApp.m_fontSymbol.m_hObject)
  135. {
  136. GetDlgItem(IDC_BNMENU)->SetFont(&theApp.m_fontSymbol);
  137. GetDlgItem(IDC_BNMENU)->SetWindowText(_T("6")); // show a down-arrow
  138. }
  139. // Win98: Explicitly set to Unicode to receive Unicode notifications.
  140. stattree.SendMessage(CCM_SETUNICODEFORMAT, TRUE);
  141. if (thePrefs.GetUseSystemFontForMainControls())
  142. stattree.SendMessage(WM_SETFONT, NULL, FALSE);
  143. CreateMyTree();
  144. // Setup download-scope
  145. CRect rcDown;
  146. GetDlgItem(IDC_SCOPE_D)->GetWindowRect(rcDown);
  147. GetDlgItem(IDC_SCOPE_D)->DestroyWindow();
  148. ScreenToClient(rcDown);
  149. m_DownloadOMeter.Create(WS_VISIBLE | WS_CHILD, rcDown, this, IDC_SCOPE_D);
  150. SetARange(true, thePrefs.GetMaxGraphDownloadRate());
  151. m_DownloadOMeter.SetYUnits(GetResString(IDS_KBYTESPERSEC));
  152. // Setup upload-scope
  153. CRect rcUp;
  154. GetDlgItem(IDC_SCOPE_U)->GetWindowRect(rcUp);
  155. GetDlgItem(IDC_SCOPE_U)->DestroyWindow();
  156. ScreenToClient(rcUp);
  157. // compensate rounding errors due to dialog units, make each of the 3 panes with same height
  158. rcUp.top = rcDown.bottom + 4;
  159. rcUp.bottom = rcUp.top + rcDown.Height();
  160. m_UploadOMeter.Create(WS_VISIBLE | WS_CHILD, rcUp, this, IDC_SCOPE_U);
  161. SetARange(false, thePrefs.GetMaxGraphUploadRate(true));
  162. m_UploadOMeter.SetYUnits(GetResString(IDS_KBYTESPERSEC));
  163. // Setup additional graph-scope
  164. CRect rcConn;
  165. GetDlgItem(IDC_STATSSCOPE)->GetWindowRect(rcConn);
  166. GetDlgItem(IDC_STATSSCOPE)->DestroyWindow();
  167. ScreenToClient(rcConn);
  168. // compensate rounding errors due to dialog units, make each of the 3 panes with same height
  169. rcConn.top = rcUp.bottom + 4;
  170. rcConn.bottom = rcConn.top + rcDown.Height();
  171. m_Statistics.Create(WS_VISIBLE | WS_CHILD, rcConn, this, IDC_STATSSCOPE);
  172. m_Statistics.SetRanges(0, thePrefs.GetStatsMax());
  173. m_Statistics.autofitYscale = false;
  174. // Set the trend ratio of the Active Connections trend in the Connection Statistics scope.
  175. m_Statistics.SetTrendRatio(0, thePrefs.GetStatsConnectionsGraphRatio());
  176. m_Statistics.SetYUnits(_T(""));
  177. m_Statistics.SetXUnits(GetResString(IDS_TIME));
  178. RepaintMeters();
  179. m_Statistics.SetBackgroundColor(thePrefs.GetStatsColor(0)) ;
  180. m_Statistics.SetGridColor(thePrefs.GetStatsColor(1)) ;
  181. m_DownloadOMeter.InvalidateCtrl();
  182. m_UploadOMeter.InvalidateCtrl();
  183. m_Statistics.InvalidateCtrl();
  184. if (thePrefs.GetStatsInterval()==0)
  185. GetDlgItem(IDC_STATTREE)->EnableWindow(false);
  186. UpdateData(FALSE);
  187. EnableWindow( TRUE );
  188. m_ilastMaxConnReached = 0;
  189. CRect rcW,rcSpl,rcTree,rcStat;
  190. GetWindowRect(rcW);
  191. ScreenToClient(rcW);
  192. GetDlgItem(IDC_STATTREE)->GetWindowRect(rcTree);
  193. ScreenToClient(rcTree);
  194. m_DownloadOMeter.GetWindowRect(rcDown);
  195. ScreenToClient(rcDown);
  196. m_UploadOMeter.GetWindowRect(rcUp);
  197. ScreenToClient(rcUp);
  198. m_Statistics.GetWindowRect(rcStat);
  199. ScreenToClient(rcStat);
  200. //vertical splitter
  201. rcSpl.left = rcTree.right;
  202. rcSpl.right = rcSpl.left + 4;
  203. rcSpl.top = rcW.top + 2;
  204. rcSpl.bottom = rcW.bottom - 5;
  205. m_wndSplitterstat.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT);
  206. int PosStatVinitX = rcSpl.left;
  207. int PosStatVnewX = thePrefs.GetSplitterbarPositionStat()*rcW.Width()/100;
  208. int maxX = rcW.right-13;
  209. int minX = rcW.left+8;
  210. if (thePrefs.GetSplitterbarPositionStat() > 90)
  211. PosStatVnewX = maxX;
  212. else if (thePrefs.GetSplitterbarPositionStat() < 10)
  213. PosStatVnewX = minX;
  214. rcSpl.left = PosStatVnewX;
  215. rcSpl.right = PosStatVnewX + 4;
  216. m_wndSplitterstat.MoveWindow(rcSpl);
  217. //HR splitter
  218. rcSpl.left = rcDown.left;
  219. rcSpl.right = rcDown.right;
  220. rcSpl.top = rcDown.bottom;
  221. rcSpl.bottom = rcSpl.top + 4;
  222. m_wndSplitterstat_HR.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT_HR);
  223. int PosStatVinitZ = rcSpl.top;
  224. int PosStatVnewZ = thePrefs.GetSplitterbarPositionStat_HR()*rcW.Height()/100;
  225. int maxZ = rcW.bottom-14;
  226. int minZ = 0;
  227. if (thePrefs.GetSplitterbarPositionStat_HR() > 90)
  228. PosStatVnewZ = maxZ;
  229. else if (thePrefs.GetSplitterbarPositionStat_HR() < 10)
  230. PosStatVnewZ = minZ;
  231. rcSpl.top = PosStatVnewZ;
  232. rcSpl.bottom = PosStatVnewZ+4;
  233. m_wndSplitterstat_HR.MoveWindow(rcSpl);
  234. //HL splitter
  235. rcSpl.left = rcUp.left;
  236. rcSpl.right = rcUp.right;
  237. rcSpl.top = rcUp.bottom;
  238. rcSpl.bottom = rcSpl.top + 4;
  239. m_wndSplitterstat_HL.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_STAT_HL);
  240. int PosStatVinitY = rcSpl.top;
  241. int PosStatVnewY = thePrefs.GetSplitterbarPositionStat_HL()*rcW.Height()/100;
  242. int maxY = rcW.bottom-9;
  243. int minY = 10;
  244. if (thePrefs.GetSplitterbarPositionStat_HL() > 90)
  245. PosStatVnewY = maxY;
  246. else if (thePrefs.GetSplitterbarPositionStat_HL() < 10)
  247. PosStatVnewY = minY;
  248. rcSpl.top = PosStatVnewY;
  249. rcSpl.bottom = PosStatVnewY+4;
  250. m_wndSplitterstat_HL.MoveWindow(rcSpl);
  251. DoResize_V(PosStatVnewX - PosStatVinitX);
  252. DoResize_HL(PosStatVnewY - PosStatVinitY);
  253. DoResize_HR(PosStatVnewZ - PosStatVinitZ);
  254. Localize();
  255. ShowStatistics(true);
  256. m_TimeToolTips = new CToolTipCtrl();
  257. m_TimeToolTips->Create(this);
  258. m_TimeToolTips->AddTool(GetDlgItem(IDC_SCOPE_D), _T(""), NULL, 0);
  259. m_TimeToolTips->AddTool(GetDlgItem(IDC_SCOPE_U), _T(""), NULL, 0);
  260. m_TimeToolTips->AddTool(GetDlgItem(IDC_STATSSCOPE), _T(""), NULL, 0);
  261. // Any Autopop-Time which is specified higher than ~30 sec. will get reset to 5 sec.
  262. m_TimeToolTips->SetDelayTime(TTDT_AUTOPOP, 30000);
  263. m_TimeToolTips->SetDelayTime(TTDT_INITIAL, 30000);
  264. m_TimeToolTips->SetDelayTime(TTDT_RESHOW, 30000);
  265. EnableToolTips(TRUE);
  266. return true;
  267. }
  268. void CStatisticsDlg::initCSize()
  269. {
  270. UINT x = thePrefs.GetSplitterbarPositionStat();
  271. UINT y = thePrefs.GetSplitterbarPositionStat_HL();
  272. UINT z = thePrefs.GetSplitterbarPositionStat_HR();
  273. if (x > 90)
  274. x = 100;
  275. else if (x < 10)
  276. x = 0;
  277. if (y > 90)
  278. y = 100;
  279. else if (y < 10)
  280. y = 0;
  281. if (z > 90)
  282. z = 100;
  283. else if (z < 10)
  284. z = 0;
  285. RemoveAnchor(IDC_BNMENU);
  286. AddAnchor(IDC_BNMENU,CSize(0,0));
  287. //StatTitle
  288. RemoveAnchor(IDC_STATIC_LASTRESET);
  289. AddAnchor(IDC_STATIC_LASTRESET,CSize(0,0),CSize(x,0));
  290. //stattree
  291. RemoveAnchor(stattree);
  292. AddAnchor(stattree,CSize(0,0),CSize(x,100));
  293. //graph
  294. RemoveAnchor(m_DownloadOMeter);
  295. AddAnchor(m_DownloadOMeter,CSize(x,0),CSize(100,z));
  296. RemoveAnchor(m_UploadOMeter);
  297. AddAnchor(m_UploadOMeter,CSize(x,z),CSize(100,y));
  298. RemoveAnchor(m_Statistics);
  299. AddAnchor(m_Statistics,CSize(x,y),CSize(100,100));
  300. //set range
  301. CRect rcW;
  302. GetWindowRect(rcW);
  303. ScreenToClient(rcW);
  304. CRect rcHR,rcHL;
  305. m_wndSplitterstat_HR.GetWindowRect(rcHR);
  306. m_wndSplitterstat_HL.GetWindowRect(rcHL);
  307. ScreenToClient(rcHR);
  308. ScreenToClient(rcHL);
  309. m_wndSplitterstat.SetRange(rcW.left+11, rcW.right-11);
  310. m_wndSplitterstat_HL.SetRange(rcHR.bottom+5, rcW.bottom-7);
  311. m_wndSplitterstat_HR.SetRange(rcW.top+3, rcHL.top-5);
  312. }
  313. void CStatisticsDlg::DoResize_HL(int delta)
  314. {
  315. if(!delta)
  316. return;
  317. m_DownloadOMeter.InvalidateCtrl(true);
  318. CSplitterControl::ChangeHeight(&m_UploadOMeter, delta , CW_TOPALIGN);
  319. CSplitterControl::ChangeHeight(&m_Statistics, -delta, CW_BOTTOMALIGN);
  320. CRect rcW;
  321. GetWindowRect(rcW);
  322. ScreenToClient(rcW);
  323. CRect rcspl;
  324. m_UploadOMeter.GetWindowRect(rcspl);
  325. ScreenToClient(rcspl);
  326. thePrefs.SetSplitterbarPositionStat_HL(rcspl.bottom*100/rcW.Height());
  327. initCSize();
  328. ShowInterval();
  329. Invalidate();
  330. UpdateWindow();
  331. }
  332. void CStatisticsDlg::DoResize_HR(int delta)
  333. {
  334. if(!delta)
  335. return;
  336. CSplitterControl::ChangeHeight(&m_DownloadOMeter, delta , CW_TOPALIGN);
  337. CSplitterControl::ChangeHeight(&m_UploadOMeter, -delta, CW_BOTTOMALIGN);
  338. m_Statistics.InvalidateCtrl(true);
  339. CRect rcW;
  340. GetWindowRect(rcW);
  341. ScreenToClient(rcW);
  342. CRect rcspl;
  343. m_DownloadOMeter.GetWindowRect(rcspl);
  344. ScreenToClient(rcspl);
  345. thePrefs.SetSplitterbarPositionStat_HR(rcspl.bottom*100/rcW.Height());
  346. initCSize();
  347. ShowInterval();
  348. Invalidate();
  349. UpdateWindow();
  350. }
  351. void CStatisticsDlg::DoResize_V(int delta)
  352. {
  353. if(!delta)
  354. return;
  355. CSplitterControl::ChangeWidth(GetDlgItem(IDC_STATIC_LASTRESET), delta);
  356. CSplitterControl::ChangeWidth(&stattree, delta);
  357. CSplitterControl::ChangeWidth(&m_DownloadOMeter, -delta, CW_RIGHTALIGN);
  358. CSplitterControl::ChangeWidth(&m_UploadOMeter, -delta, CW_RIGHTALIGN);
  359. CSplitterControl::ChangeWidth(&m_Statistics, -delta, CW_RIGHTALIGN);
  360. CRect rcW;
  361. GetWindowRect(rcW);
  362. ScreenToClient(rcW);
  363. CRect rcspl;
  364. GetDlgItem(IDC_STATTREE)->GetWindowRect(rcspl);
  365. ScreenToClient(rcspl);
  366. thePrefs.SetSplitterbarPositionStat(rcspl.right*100/rcW.Width());
  367. if (rcspl.left==rcspl.right) {
  368. GetDlgItem(IDC_STATTREE)->ShowWindow(SW_HIDE);
  369. GetDlgItem(IDC_BNMENU)->ShowWindow(SW_HIDE);
  370. GetDlgItem(IDC_STATIC_LASTRESET)->ShowWindow(SW_HIDE);
  371. m_bTreepaneHidden=true;
  372. } else if (m_bTreepaneHidden) {
  373. m_bTreepaneHidden=false;
  374. GetDlgItem(IDC_STATTREE)->ShowWindow(SW_SHOW);
  375. GetDlgItem(IDC_BNMENU)->ShowWindow(SW_SHOW);
  376. GetDlgItem(IDC_STATIC_LASTRESET)->ShowWindow(SW_SHOW);
  377. }
  378. initCSize();
  379. ShowInterval();
  380. Invalidate();
  381. UpdateWindow();
  382. }
  383. LRESULT CStatisticsDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  384. {
  385. switch (message)
  386. {
  387. case WM_PAINT:
  388. if (m_wndSplitterstat)
  389. {
  390. CRect rctree,rcSpl,rcW;
  391. GetWindowRect(rcW);
  392. ScreenToClient(rcW);
  393. GetDlgItem(IDC_STATTREE)->GetWindowRect(rctree);
  394. ScreenToClient(rctree);
  395. if (rcW.Width()>0)
  396. {
  397. rcSpl.left = rctree.right;
  398. rcSpl.right = rcSpl.left + 4;
  399. rcSpl.top = rcW.top + 2;
  400. rcSpl.bottom = rcW.bottom - 5;
  401. m_wndSplitterstat.MoveWindow(rcSpl,true);
  402. }
  403. }
  404. if (m_wndSplitterstat_HL)
  405. {
  406. CRect rcUp,rcSpl,rcW;
  407. CWnd* pWnd;
  408. GetWindowRect(rcW);
  409. ScreenToClient(rcW);
  410. pWnd = &m_UploadOMeter;
  411. pWnd->GetWindowRect(rcUp);
  412. ScreenToClient(rcUp);
  413. if (rcW.Height()>0)
  414. {
  415. rcSpl.left = rcUp.left;
  416. rcSpl.right = rcUp.right;
  417. rcSpl.top = rcUp.bottom;
  418. rcSpl.bottom = rcUp.bottom + 4;
  419. m_wndSplitterstat_HL.MoveWindow(rcSpl,true);
  420. }
  421. }
  422. if (m_wndSplitterstat_HR)
  423. {
  424. CRect rcDown,rcSpl,rcW;
  425. CWnd* pWnd;
  426. GetWindowRect(rcW);
  427. ScreenToClient(rcW);
  428. pWnd = &m_DownloadOMeter;
  429. pWnd->GetWindowRect(rcDown);
  430. ScreenToClient(rcDown);
  431. if (rcW.Height()>0)
  432. {
  433. rcSpl.left = rcDown.left;
  434. rcSpl.right = rcDown.right;
  435. rcSpl.top = rcDown.bottom;
  436. rcSpl.bottom = rcDown.bottom + 4;
  437. m_wndSplitterstat_HR.MoveWindow(rcSpl,true);
  438. }
  439. }
  440. break;
  441. case WM_NOTIFY:
  442. if (wParam == IDC_SPLITTER_STAT)
  443. {
  444. SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
  445. DoResize_V(pHdr->delta);
  446. }
  447. else if (wParam == IDC_SPLITTER_STAT_HL)
  448. {
  449. SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
  450. DoResize_HL(pHdr->delta);
  451. }
  452. else if (wParam == IDC_SPLITTER_STAT_HR)
  453. {
  454. SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;
  455. DoResize_HR(pHdr->delta);
  456. }
  457. break;
  458. case WM_WINDOWPOSCHANGED:
  459. {
  460. CRect rcW;
  461. GetWindowRect(rcW);
  462. ScreenToClient(rcW);
  463. if (m_wndSplitterstat && rcW.Width()>0) Invalidate();
  464. if (m_wndSplitterstat_HL && rcW.Height()>0) Invalidate();
  465. if (m_wndSplitterstat_HR && rcW.Height()>0) Invalidate();
  466. break;
  467. }
  468. case WM_SIZE:
  469. {
  470. //set range
  471. if (m_wndSplitterstat)
  472. {
  473. CRect rcW;
  474. GetWindowRect(rcW);
  475. ScreenToClient(rcW);
  476. if (rcW.Width()>0)
  477. {
  478. CRect rcSpl;
  479. CRect rcTree,rcDown;
  480. stattree.GetWindowRect(rcTree);
  481. m_DownloadOMeter.GetWindowRect(rcDown);
  482. ScreenToClient(rcTree);
  483. ScreenToClient(rcDown);
  484. long splitposstat=thePrefs.GetSplitterbarPositionStat()*rcW.Width()/100;
  485. rcSpl.left = splitposstat;
  486. rcSpl.right = rcSpl.left + 4;
  487. rcSpl.top = rcW.top + 2;
  488. rcSpl.bottom = rcW.bottom - 5;
  489. m_wndSplitterstat.MoveWindow(rcSpl,true);
  490. m_wndSplitterstat.SetRange(rcW.left+11, rcW.right-11);
  491. }
  492. }
  493. if (m_wndSplitterstat_HR)
  494. {
  495. CRect rcW;
  496. GetWindowRect(rcW);
  497. ScreenToClient(rcW);
  498. if (rcW.Width()>0)
  499. {
  500. CRect rcSpl;
  501. CRect rcDown;
  502. m_DownloadOMeter.GetWindowRect(rcDown);
  503. ScreenToClient(rcDown);
  504. long splitposstat=thePrefs.GetSplitterbarPositionStat()*rcW.Width()/100;
  505. long splitposstat_HR=thePrefs.GetSplitterbarPositionStat_HR()*rcW.Height()/100;
  506. long splitposstat_HL=thePrefs.GetSplitterbarPositionStat_HL()*rcW.Height()/100;
  507. rcSpl.left = splitposstat + 7;
  508. rcSpl.right = rcW.right - 14;
  509. rcSpl.top = splitposstat_HR;
  510. rcSpl.bottom = rcSpl.top + 4;
  511. m_wndSplitterstat_HR.MoveWindow(rcSpl,true);
  512. m_wndSplitterstat_HR.SetRange(rcW.top+3, splitposstat_HL-4);
  513. }
  514. }
  515. if (m_wndSplitterstat_HL)
  516. {
  517. CRect rcW;
  518. GetWindowRect(rcW);
  519. ScreenToClient(rcW);
  520. if (rcW.Width()>0)
  521. {
  522. CRect rcSpl;
  523. CRect rcStat;
  524. m_Statistics.GetWindowRect(rcStat);
  525. ScreenToClient(rcStat);
  526. long splitposstat=thePrefs.GetSplitterbarPositionStat()*rcW.Width()/100;
  527. long splitposstat_HR=thePrefs.GetSplitterbarPositionStat_HR()*rcW.Height()/100;
  528. long splitposstat_HL=thePrefs.GetSplitterbarPositionStat_HL()*rcW.Height()/100;
  529. rcSpl.left = splitposstat + 7;
  530. rcSpl.right = rcW.right - 14;
  531. rcSpl.top = splitposstat_HL;
  532. rcSpl.bottom = rcSpl.top + 4;
  533. m_wndSplitterstat_HL.MoveWindow(rcSpl,true);
  534. m_wndSplitterstat_HL.SetRange(splitposstat_HR+14, rcW.bottom-7);
  535. }
  536. }
  537. break;
  538. }
  539. }
  540. return CResizableDialog::DefWindowProc(message, wParam, lParam);
  541. }
  542. void CStatisticsDlg::RepaintMeters()
  543. {
  544. CString Buffer;
  545. m_DownloadOMeter.SetBackgroundColor(thePrefs.GetStatsColor(0)); // Background
  546. m_DownloadOMeter.SetGridColor(thePrefs.GetStatsColor(1)); // Grid
  547. m_DownloadOMeter.SetPlotColor(thePrefs.GetStatsColor(4), 0); // Download session
  548. m_DownloadOMeter.SetPlotColor(thePrefs.GetStatsColor(3), 1); // Download average
  549. m_DownloadOMeter.SetPlotColor(thePrefs.GetStatsColor(2), 2); // Download current
  550. m_DownloadOMeter.SetBarsPlot(thePrefs.GetFillGraphs(), 2);
  551. m_UploadOMeter.SetBackgroundColor(thePrefs.GetStatsColor(0));
  552. m_UploadOMeter.SetGridColor(thePrefs.GetStatsColor(1)); // Grid
  553. m_UploadOMeter.SetPlotColor(thePrefs.GetStatsColor(7), 0); // Upload session
  554. m_UploadOMeter.SetPlotColor(thePrefs.GetStatsColor(6), 1); // Upload average
  555. m_UploadOMeter.SetPlotColor(thePrefs.GetStatsColor(5), 2); // Upload current
  556. m_UploadOMeter.SetPlotColor(thePrefs.GetStatsColor(14), 3); // Upload current (excl. overhead)
  557. m_UploadOMeter.SetPlotColor(thePrefs.GetStatsColor(13), 4); // Upload friend slots
  558. m_UploadOMeter.SetBarsPlot(thePrefs.GetFillGraphs(), 2);
  559. m_Statistics.SetBackgroundColor(thePrefs.GetStatsColor(0));
  560. m_Statistics.SetGridColor(thePrefs.GetStatsColor(1));
  561. m_Statistics.SetPlotColor(thePrefs.GetStatsColor(8), 0); // Active Connections
  562. m_Statistics.SetPlotColor(thePrefs.GetStatsColor(10), 1); // Active Uploads
  563. m_Statistics.SetPlotColor(thePrefs.GetStatsColor(9), 2); // Total Uploads
  564. m_Statistics.SetPlotColor(thePrefs.GetStatsColor(12), 3); // Active Downloads
  565. m_Statistics.SetBarsPlot(thePrefs.GetFillGraphs(), 0);
  566. m_DownloadOMeter.SetYUnits(GetResString(IDS_ST_DOWNLOAD));
  567. m_DownloadOMeter.SetLegendLabel(GetResString(IDS_ST_SESSION), 0); // Download session
  568. Buffer.Format(_T(" (%u %s)"), thePrefs.GetStatsAverageMinutes(), GetResString(IDS_MINS));
  569. m_DownloadOMeter.SetLegendLabel(GetResString(IDS_AVG) + Buffer, 1); // Download average
  570. m_DownloadOMeter.SetLegendLabel(GetResString(IDS_ST_CURRENT), 2); // Download current
  571. m_UploadOMeter.SetYUnits(GetResString(IDS_ST_UPLOAD));
  572. m_UploadOMeter.SetLegendLabel(GetResString(IDS_ST_SESSION), 0); // Upload session
  573. Buffer.Format(_T(" (%u %s)"), thePrefs.GetStatsAverageMinutes(), GetResString(IDS_MINS));
  574. m_UploadOMeter.SetLegendLabel(GetResString(IDS_AVG) + Buffer, 1); // Upload average
  575. m_UploadOMeter.SetLegendLabel(GetResString(IDS_ST_ULCURRENT), 2); // Upload current
  576. m_UploadOMeter.SetLegendLabel(GetResString(IDS_ST_ULSLOTSNOOVERHEAD), 3); // Upload current (excl. overhead)
  577. m_UploadOMeter.SetLegendLabel(GetResString(IDS_ST_ULFRIEND), 4); // Upload friend slots
  578. m_Statistics.SetYUnits(GetResString(IDS_FSTAT_CONNECTION));
  579. Buffer.Format(_T("%s (1:%u)"), GetResString(IDS_ST_ACTIVEC), thePrefs.GetStatsConnectionsGraphRatio());
  580. m_Statistics.SetLegendLabel(Buffer, 0); // Active Connections
  581. m_Statistics.SetLegendLabel(GetResString(IDS_ST_ACTIVEU_ZZ), 1); // Active Uploads
  582. m_Statistics.SetLegendLabel(GetResString(IDS_SP_TOTALUL), 2); // Total Uploads
  583. m_Statistics.SetLegendLabel(GetResString(IDS_ST_ACTIVED), 3); // Active Downloads
  584. }
  585. void CStatisticsDlg::SetCurrentRate(float uploadrate, float downloadrate)
  586. {
  587. if (!theApp.emuledlg->IsRunning())
  588. return;
  589. // Download
  590. double m_dPlotDataDown[3];
  591. m_dPlotDataDown[0] = theStats.GetAvgDownloadRate(AVG_SESSION);
  592. m_dPlotDataDown[1] = theStats.GetAvgDownloadRate(AVG_TIME);
  593. m_dPlotDataDown[2] = downloadrate;
  594. m_DownloadOMeter.AppendPoints(m_dPlotDataDown);
  595. // Upload
  596. double m_dPlotDataUp[5];
  597. m_dPlotDataUp[0] = theStats.GetAvgUploadRate(AVG_SESSION);
  598. m_dPlotDataUp[1] = theStats.GetAvgUploadRate(AVG_TIME);
  599. // current rate to network (standardPackets + controlPackets)
  600. m_dPlotDataUp[2] = uploadrate;
  601. // current rate (excl. overhead)
  602. m_dPlotDataUp[3] = uploadrate - (float)theStats.GetUpDatarateOverhead() / 1024;
  603. // current rate to friends
  604. m_dPlotDataUp[4] = uploadrate - (float)theApp.uploadqueue->GetToNetworkDatarate() / 1024;
  605. m_UploadOMeter.AppendPoints(m_dPlotDataUp);
  606. // Connections
  607. CDownloadQueue::SDownloadStats myStats;
  608. theApp.downloadqueue->GetDownloadSourcesStats(myStats);
  609. m_dPlotDataMore[0] = theApp.listensocket->GetActiveConnections();
  610. m_dPlotDataMore[1] = theApp.uploadqueue->GetActiveUploadsCount();
  611. m_dPlotDataMore[2] = theApp.uploadqueue->GetUploadQueueLength();
  612. m_dPlotDataMore[3] = myStats.a[1];
  613. m_Statistics.AppendPoints(m_dPlotDataMore);
  614. // Websever
  615. UpDown updown;
  616. updown.upload = uploadrate;
  617. updown.download = downloadrate;
  618. updown.connections = theApp.listensocket->GetActiveConnections();
  619. theApp.webserver->AddStatsLine(updown);
  620. }
  621. void CStatisticsDlg::ShowStatistics(bool forceUpdate)
  622. {
  623. stattree.SetRedraw(false);
  624. CString cbuffer;
  625. // Set Tree Values
  626. // TRANSFER SECTION
  627. // If a section is not expanded, don't waste CPU cycles updating it.
  628. if (forceUpdate || stattree.IsExpanded(h_transfer))
  629. {
  630. uint32 statGoodSessions = 0;
  631. uint32 statBadSessions = 0;
  632. double percentSessions = 0;
  633. // Transfer Ratios
  634. if ( theStats.sessionReceivedBytes>0 && theStats.sessionSentBytes>0 )
  635. {
  636. // Session
  637. if (theStats.sessionReceivedBytes<theStats.sessionSentBytes)
  638. {
  639. cbuffer.Format(_T("%s %.2f : 1"),GetResString(IDS_STATS_SRATIO),(float)theStats.sessionSentBytes/theStats.sessionReceivedBytes);
  640. stattree.SetItemText(trans[0], cbuffer);
  641. }
  642. else
  643. {
  644. cbuffer.Format(_T("%s 1 : %.2f"),GetResString(IDS_STATS_SRATIO),(float)theStats.sessionReceivedBytes/theStats.sessionSentBytes);
  645. stattree.SetItemText(trans[0], cbuffer);
  646. }
  647. }
  648. else
  649. {
  650. cbuffer.Format(_T("%s %s"), GetResString(IDS_STATS_SRATIO), GetResString(IDS_FSTAT_WAITING)); // Localize
  651. stattree.SetItemText(trans[0], cbuffer);
  652. }
  653. if ( theStats.sessionReceivedBytes>0 && theStats.sessionSentBytes>0)
  654. {
  655. // Session
  656. if (theStats.sessionSentBytes > theStats.sessionSentBytesToFriend && theStats.sessionReceivedBytes<theStats.sessionSentBytes-theStats.sessionSentBytesToFriend)
  657. {
  658. cbuffer.Format(_T("%s %.2f : 1"),GetResString(IDS_STATS_FRATIO),(float)(theStats.sessionSentBytes-theStats.sessionSentBytesToFriend)/theStats.sessionReceivedBytes);
  659. stattree.SetItemText(trans[1], cbuffer);
  660. }
  661. else
  662. {
  663. cbuffer.Format(_T("%s 1 : %.2f"),GetResString(IDS_STATS_FRATIO),(float)theStats.sessionReceivedBytes/(theStats.sessionSentBytes-theStats.sessionSentBytesToFriend));
  664. stattree.SetItemText(trans[1], cbuffer);
  665. }
  666. }
  667. else
  668. {
  669. cbuffer.Format(_T("%s %s"), GetResString(IDS_STATS_FRATIO), GetResString(IDS_FSTAT_WAITING)); // Localize
  670. stattree.SetItemText(trans[1], cbuffer);
  671. }
  672. if ( (thePrefs.GetTotalDownloaded()>0 && thePrefs.GetTotalUploaded()>0) || (theStats.sessionReceivedBytes>0 && theStats.sessionSentBytes>0) )
  673. {
  674. // Cumulative
  675. if ((theStats.sessionReceivedBytes+thePrefs.GetTotalDownloaded())<(theStats.sessionSentBytes+thePrefs.GetTotalUploaded()))
  676. {
  677. cbuffer.Format(_T("%s %.2f : 1"),GetResString(IDS_STATS_CRATIO),(float)(theStats.sessionSentBytes+thePrefs.GetTotalUploaded())/(theStats.sessionReceivedBytes+thePrefs.GetTotalDownloaded()));
  678. stattree.SetItemText(trans[2], cbuffer);
  679. }
  680. else
  681. {
  682. cbuffer.Format(_T("%s 1 : %.2f"),GetResString(IDS_STATS_CRATIO),(float)(theStats.sessionReceivedBytes+thePrefs.GetTotalDownloaded())/(theStats.sessionSentBytes+thePrefs.GetTotalUploaded()));
  683. stattree.SetItemText(trans[2], cbuffer);
  684. }
  685. }
  686. else
  687. {
  688. cbuffer.Format(_T("%s %s"), GetResString(IDS_STATS_CRATIO), GetResString(IDS_FSTAT_WAITING)); // Localize
  689. stattree.SetItemText(trans[2], cbuffer);
  690. }
  691. // TRANSFER -> DOWNLOADS SECTION
  692. if (forceUpdate || stattree.IsExpanded(h_download))
  693. {
  694. uint64 DownOHTotal = 0;
  695. uint64 DownOHTotalPackets = 0;
  696. CDownloadQueue::SDownloadStats myStats;
  697. theApp.downloadqueue->GetDownloadSourcesStats(myStats);
  698. // TRANSFER -> DOWNLOADS -> SESSION SECTION
  699. if (forceUpdate || stattree.IsExpanded(h_down_session))
  700. {
  701. // Downloaded Data
  702. cbuffer.Format( GetResString( IDS_STATS_DDATA ) , CastItoXBytes( theStats.sessionReceivedBytes, false, false ) );
  703. stattree.SetItemText( down_S[0] , cbuffer );
  704. if (forceUpdate || stattree.IsExpanded(down_S[0]))
  705. {
  706. // Downloaded Data By Client
  707. if (forceUpdate || stattree.IsExpanded(hdown_scb))
  708. {
  709. int i = 0;
  710. uint64 DownDataTotal = thePrefs.GetDownSessionClientData();
  711. uint64 DownDataClient = thePrefs.GetDownData_EMULE();
  712. double percentClientTransferred = 0;
  713. if ( DownDataTotal!=0 && DownDataClient!=0 )
  714. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  715. cbuffer.Format( _T("eMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ) , percentClientTransferred);
  716. stattree.SetItemText( down_scb[i] , cbuffer );
  717. i++;
  718. DownDataClient = thePrefs.GetDownData_EDONKEYHYBRID();
  719. if ( DownDataTotal!=0 && DownDataClient!=0 )
  720. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  721. else
  722. percentClientTransferred = 0;
  723. cbuffer.Format( _T("eD Hybrid: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ) , percentClientTransferred );
  724. stattree.SetItemText( down_scb[i] , cbuffer );
  725. i++;
  726. DownDataClient = thePrefs.GetDownData_EDONKEY();
  727. if ( DownDataTotal!=0 && DownDataClient!=0 )
  728. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  729. else
  730. percentClientTransferred = 0;
  731. cbuffer.Format( _T("eDonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  732. stattree.SetItemText( down_scb[i] , cbuffer );
  733. i++;
  734. DownDataClient = thePrefs.GetDownData_AMULE();
  735. if ( DownDataTotal!=0 && DownDataClient!=0 )
  736. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  737. else
  738. percentClientTransferred = 0;
  739. cbuffer.Format( _T("aMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  740. stattree.SetItemText( down_scb[i] , cbuffer );
  741. i++;
  742. DownDataClient = thePrefs.GetDownData_MLDONKEY();
  743. if ( DownDataTotal!=0 && DownDataClient!=0 )
  744. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  745. else
  746. percentClientTransferred = 0;
  747. cbuffer.Format( _T("MLdonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  748. stattree.SetItemText( down_scb[i] , cbuffer );
  749. i++;
  750. DownDataClient = thePrefs.GetDownData_SHAREAZA();
  751. if ( DownDataTotal!=0 && DownDataClient!=0 )
  752. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  753. else
  754. percentClientTransferred = 0;
  755. cbuffer.Format( _T("Shareaza: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  756. stattree.SetItemText( down_scb[i] , cbuffer );
  757. i++;
  758. DownDataClient = thePrefs.GetDownData_EMULECOMPAT();
  759. if ( DownDataTotal!=0 && DownDataClient!=0 )
  760. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  761. else
  762. percentClientTransferred = 0;
  763. cbuffer.Format( _T("eM Compat: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  764. stattree.SetItemText( down_scb[i] , cbuffer );
  765. i++;
  766. DownDataClient = thePrefs.GetDownData_URL();
  767. if ( DownDataTotal!=0 && DownDataClient!=0 )
  768. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  769. else
  770. percentClientTransferred = 0;
  771. cbuffer.Format( _T("URL: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  772. stattree.SetItemText( down_scb[i] , cbuffer );
  773. i++;
  774. }
  775. // Downloaded Data By Port
  776. if (forceUpdate || stattree.IsExpanded(hdown_spb))
  777. {
  778. int i = 0;
  779. uint64 PortDataDefault = thePrefs.GetDownDataPort_4662();
  780. uint64 PortDataOther = thePrefs.GetDownDataPort_OTHER();
  781. uint64 PortDataPeerCache = thePrefs.GetDownDataPort_PeerCache();
  782. uint64 PortDataTotal = thePrefs.GetDownSessionDataPort();
  783. double percentPortTransferred = 0;
  784. if ( PortDataTotal!=0 && PortDataDefault!=0 )
  785. percentPortTransferred = (double) 100 * PortDataDefault / PortDataTotal;
  786. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTDEF) , CastItoXBytes( PortDataDefault, false, false ) , percentPortTransferred);
  787. stattree.SetItemText( down_spb[i] , cbuffer );
  788. i++;
  789. if ( PortDataTotal!=0 && PortDataOther!=0 )
  790. percentPortTransferred = (double) 100 * PortDataOther / PortDataTotal;
  791. else
  792. percentPortTransferred = 0;
  793. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataOther, false, false ) , percentPortTransferred);
  794. stattree.SetItemText( down_spb[i] , cbuffer );
  795. i++;
  796. if ( PortDataTotal!=0 && PortDataPeerCache!=0 )
  797. percentPortTransferred = (double) 100 * PortDataPeerCache / PortDataTotal;
  798. else
  799. percentPortTransferred = 0;
  800. cbuffer.Format( _T("%s: %s (%1.1f%%)") , thePrefs.GetPeerCacheShow() ? _T("PeerCache") : GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataPeerCache, false, false ) , percentPortTransferred);
  801. stattree.SetItemText( down_spb[i] , cbuffer );
  802. i++;
  803. }
  804. }
  805. // Completed Downloads
  806. cbuffer.Format( _T("%s: %u") , GetResString( IDS_STATS_COMPDL ) , thePrefs.GetDownSessionCompletedFiles() );
  807. stattree.SetItemText( down_S[1] , cbuffer );
  808. // Active Downloads
  809. cbuffer.Format( GetResString( IDS_STATS_ACTDL ) , myStats.a[1] );
  810. stattree.SetItemText( down_S[2] , cbuffer );
  811. // Found Sources
  812. cbuffer.Format( GetResString( IDS_STATS_FOUNDSRC ) , myStats.a[0] );
  813. stattree.SetItemText( down_S[3] , cbuffer );
  814. if (forceUpdate || stattree.IsExpanded(down_S[3]))
  815. {
  816. int i = 0;
  817. // Sources By Status
  818. cbuffer.Format( _T("%s: %u") , GetResString( IDS_ONQUEUE ) , myStats.a[2] );
  819. stattree.SetItemText( down_sources[i] , cbuffer );
  820. i++;
  821. cbuffer.Format( _T("%s: %u") , GetResString( IDS_QUEUEFULL ) , myStats.a[3] );
  822. stattree.SetItemText( down_sources[i] , cbuffer );
  823. i++;
  824. cbuffer.Format( _T("%s: %u") , GetResString( IDS_NONEEDEDPARTS ) , myStats.a[4] );
  825. stattree.SetItemText( down_sources[i] , cbuffer );
  826. i++;
  827. cbuffer.Format( _T("%s: %u") , GetResString( IDS_ASKING ) , myStats.a[5] );
  828. stattree.SetItemText( down_sources[i] , cbuffer );
  829. i++;
  830. cbuffer.Format( _T("%s: %u") , GetResString( IDS_RECHASHSET ) , myStats.a[6] );
  831. stattree.SetItemText( down_sources[i] , cbuffer );
  832. i++;
  833. cbuffer.Format( _T("%s: %u") , GetResString( IDS_CONNECTING ) , myStats.a[7] );
  834. stattree.SetItemText( down_sources[i] , cbuffer );
  835. i++;
  836. cbuffer.Format( _T("%s: %u") , GetResString(IDS_CONNVIASERVER) , myStats.a[8] );
  837. stattree.SetItemText( down_sources[i] , cbuffer );
  838. i++;
  839. cbuffer.Format( _T("%s: %u") , GetResString(IDS_TOOMANYCONNS) , myStats.a[9] );
  840. stattree.SetItemText( down_sources[i] , cbuffer );
  841. i++;
  842. cbuffer.Format( _T("%s: %u") , GetResString(IDS_NOCONNECTLOW2LOW) , myStats.a[10] );
  843. stattree.SetItemText( down_sources[i] , cbuffer );
  844. i++;
  845. cbuffer.Format( _T("%s: %u") , GetResString(IDS_STATS_PROBLEMATIC) , myStats.a[12] );
  846. stattree.SetItemText( down_sources[i] , cbuffer );
  847. i++;
  848. cbuffer.Format( _T("%s: %u") , GetResString(IDS_BANNED) , myStats.a[13] );
  849. stattree.SetItemText( down_sources[i] , cbuffer );
  850. i++;
  851. cbuffer.Format( _T("%s: %u") , GetResString(IDS_ASKED4ANOTHERFILE) , myStats.a[15] );
  852. stattree.SetItemText( down_sources[i] , cbuffer );
  853. i++;
  854. cbuffer.Format( _T("%s: %u") , GetResString(IDS_UNKNOWN) , myStats.a[11] );
  855. stattree.SetItemText( down_sources[i] , cbuffer );
  856. i++;
  857. // where from? (3)
  858. cbuffer.Format( _T("%s: %u") , GetResString( IDS_VIAED2KSQ ) , myStats.a[16] );
  859. stattree.SetItemText( down_sources[i] , cbuffer );
  860. i++;
  861. cbuffer.Format( _T("%s: %u") , GetResString( IDS_VIAKAD ) , myStats.a[17] );
  862. stattree.SetItemText( down_sources[i] , cbuffer );
  863. i++;
  864. cbuffer.Format( _T("%s: %u") , GetResString( IDS_VIASE ) , myStats.a[18] );
  865. stattree.SetItemText( down_sources[i] , cbuffer );
  866. i++;
  867. cbuffer.Format( _T("%s: %u") , GetResString( IDS_VIAPASSIVE ) , myStats.a[14] );
  868. stattree.SetItemText( down_sources[i] , cbuffer );
  869. i++;
  870. cbuffer.Format( _T("eD2K: %u (%.1f%%)") , myStats.a[19], myStats.a[0] ? (myStats.a[19] * 100.0 / myStats.a[0]) : 0.0 );
  871. stattree.SetItemText( down_sources[i] , cbuffer );
  872. i++;
  873. cbuffer.Format( _T("Kad: %u (%.1f%%)") , myStats.a[20], myStats.a[0] ? (myStats.a[20] * 100.0 / myStats.a[0]) : 0.0 );
  874. stattree.SetItemText( down_sources[i] , cbuffer );
  875. i++;
  876. cbuffer.Format( _T("eD2K/Kad: %u (%.1f%%)") , myStats.a[21], myStats.a[0] ? (myStats.a[21] * 100.0 / myStats.a[0]) : 0.0 );
  877. stattree.SetItemText( down_sources[i] , cbuffer );
  878. i++;
  879. cbuffer.Format(_T("%s: %s, %s: %s (%.1f%%)"), GetResString(IDS_UDPREASKS), CastItoIShort(theApp.downloadqueue->GetUDPFileReasks()), GetResString(IDS_UFAILED), CastItoIShort(theApp.downloadqueue->GetFailedUDPFileReasks()), theApp.downloadqueue->GetUDPFileReasks() ? (theApp.downloadqueue->GetFailedUDPFileReasks() * 100.0 / theApp.downloadqueue->GetUDPFileReasks()) : 0.0 );
  880. stattree.SetItemText( down_sources[i] , cbuffer );
  881. i++;
  882. cbuffer.Format(_T("%s: %s (%s + %s)"), GetResString(IDS_DEADSOURCES), CastItoIShort(theApp.clientlist->m_globDeadSourceList.GetDeadSourcesCount() + myStats.a[22]), CastItoIShort(theApp.clientlist->m_globDeadSourceList.GetDeadSourcesCount()), CastItoIShort((UINT)myStats.a[22]));
  883. stattree.SetItemText( down_sources[i] , cbuffer );
  884. i++;
  885. }
  886. // Set Download Sessions
  887. statGoodSessions = thePrefs.GetDownS_SuccessfulSessions() + myStats.a[1]; // Add Active Downloads
  888. statBadSessions = thePrefs.GetDownS_FailedSessions();
  889. cbuffer.Format( _T("%s: %u") , GetResString(IDS_STATS_DLSES) , statGoodSessions + statBadSessions );
  890. stattree.SetItemText( down_S[4] , cbuffer );
  891. if (forceUpdate || stattree.IsExpanded(down_S[4]))
  892. {
  893. // Set Successful Download Sessions and Average Downloaded Per Session
  894. percentSessions = 0;
  895. if (statGoodSessions > 0)
  896. {
  897. percentSessions = (double) 100 * statGoodSessions / (statGoodSessions + statBadSessions);
  898. cbuffer.Format( _T("%s: %s") , GetResString(IDS_STATS_AVGDATADLSES) , CastItoXBytes( theStats.sessionReceivedBytes / statGoodSessions, false, false ) );
  899. }
  900. else
  901. cbuffer.Format( _T("%s: %s") , GetResString(IDS_STATS_AVGDATADLSES) , CastItoXBytes((uint32)0, false, false) );
  902. stattree.SetItemText( down_ssessions[2] , cbuffer ); // Set Avg DL/Session
  903. cbuffer.Format( _T("%s: %u (%1.1f%%)") , GetResString(IDS_STATS_SDLSES) , statGoodSessions , percentSessions );
  904. stattree.SetItemText( down_ssessions[0] , cbuffer ); // Set Succ Sessions
  905. // Set Failed Download Sessions (Avoid Division)
  906. if (percentSessions != 0 && statBadSessions > 0)
  907. percentSessions = 100 - percentSessions; // There were some good sessions and bad ones...
  908. else if (percentSessions == 0 && statBadSessions > 0)
  909. percentSessions = 100; // There were bad sessions and no good ones, must be 100%
  910. else
  911. percentSessions = 0; // No sessions at all, or no bad ones.
  912. cbuffer.Format( _T("%s: %u (%1.1f%%)") , GetResString(IDS_STATS_FDLSES) , statBadSessions , percentSessions );
  913. stattree.SetItemText( down_ssessions[1] , cbuffer );
  914. // Set Average Download Time
  915. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_AVGDLTIME), CastSecondsToLngHM(thePrefs.GetDownS_AvgTime()));
  916. stattree.SetItemText( down_ssessions[3] , cbuffer );
  917. }
  918. // Set Gain Due To Compression
  919. cbuffer.Format(GetResString(IDS_STATS_GAINCOMP) + _T(" (%.1f%%)"), CastItoXBytes(thePrefs.GetSesSavedFromCompression(), false, false), theStats.sessionReceivedBytes!=0 ? (thePrefs.GetSesSavedFromCompression() * 100.0 / theStats.sessionReceivedBytes) : 0.0);
  920. stattree.SetItemText( down_S[5] , cbuffer );
  921. // Set Lost Due To Corruption
  922. cbuffer.Format(GetResString(IDS_STATS_LOSTCORRUPT) + _T(" (%.1f%%)"), CastItoXBytes(thePrefs.GetSesLostFromCorruption(), false, false), theStats.sessionReceivedBytes!=0 ? (thePrefs.GetSesLostFromCorruption() * 100.0 / theStats.sessionReceivedBytes) : 0.0);
  923. stattree.SetItemText( down_S[6] , cbuffer );
  924. // Set Parts Saved Due To ICH
  925. cbuffer.Format(GetResString(IDS_STATS_ICHSAVED), thePrefs.GetSesPartsSavedByICH());
  926. stattree.SetItemText( down_S[7] , cbuffer );
  927. // Calculate downline OH totals
  928. DownOHTotal = theStats.GetDownDataOverheadFileRequest() +
  929. theStats.GetDownDataOverheadSourceExchange() +
  930. theStats.GetDownDataOverheadServer() +
  931. theStats.GetDownDataOverheadKad() +
  932. theStats.GetDownDataOverheadOther();
  933. DownOHTotalPackets =
  934. theStats.GetDownDataOverheadFileRequestPackets() +
  935. theStats.GetDownDataOverheadSourceExchangePackets() +
  936. theStats.GetDownDataOverheadServerPackets() +
  937. theStats.GetDownDataOverheadKadPackets() +
  938. theStats.GetDownDataOverheadOtherPackets();
  939. // Downline Overhead
  940. cbuffer.Format( GetResString( IDS_TOVERHEAD ) , CastItoXBytes( DownOHTotal, false, false ) , CastItoIShort( DownOHTotalPackets ) );
  941. stattree.SetItemText( hdown_soh , cbuffer );
  942. if (forceUpdate || stattree.IsExpanded(hdown_soh))
  943. {
  944. int i = 0;
  945. // Set down session file req OH
  946. cbuffer.Format( GetResString( IDS_FROVERHEAD ) , CastItoXBytes( theStats.GetDownDataOverheadFileRequest(), false, false ) , CastItoIShort( theStats.GetDownDataOverheadFileRequestPackets() ) );
  947. stattree.SetItemText( down_soh[i] , cbuffer );
  948. i++;
  949. // Set down session source exch OH
  950. cbuffer.Format( GetResString( IDS_SSOVERHEAD ) , CastItoXBytes( theStats.GetDownDataOverheadSourceExchange(), false, false ), CastItoIShort( theStats.GetDownDataOverheadSourceExchangePackets() ) );
  951. stattree.SetItemText( down_soh[i] , cbuffer );
  952. i++;
  953. // Set down session server OH
  954. cbuffer.Format(GetResString(IDS_SOVERHEAD),
  955. CastItoXBytes(theStats.GetDownDataOverheadServer(), false, false),
  956. CastItoIShort(theStats.GetDownDataOverheadServerPackets()));
  957. stattree.SetItemText( down_soh[i] , cbuffer );
  958. i++;
  959. // Set down session Kad OH
  960. cbuffer.Format(GetResString(IDS_KADOVERHEAD),
  961. CastItoXBytes(theStats.GetDownDataOverheadKad(), false, false),
  962. CastItoIShort(theStats.GetDownDataOverheadKadPackets()));
  963. stattree.SetItemText( down_soh[i] , cbuffer );
  964. i++;
  965. }
  966. }
  967. // TRANSFER -> DOWNLOADS -> CUMULATIVE SECTION
  968. if (forceUpdate || stattree.IsExpanded(h_down_total))
  969. {
  970. // Downloaded Data
  971. uint64 ullCumReceived = theStats.sessionReceivedBytes + thePrefs.GetTotalDownloaded();
  972. cbuffer.Format(GetResString(IDS_STATS_DDATA), CastItoXBytes(ullCumReceived, false, false));
  973. stattree.SetItemText(down_T[0], cbuffer);
  974. if (forceUpdate || stattree.IsExpanded(down_T[0]))
  975. {
  976. // Downloaded Data By Client
  977. if (forceUpdate || stattree.IsExpanded(hdown_tcb))
  978. {
  979. int i = 0;
  980. uint64 DownDataTotal = thePrefs.GetDownTotalClientData();
  981. uint64 DownDataClient = thePrefs.GetCumDownData_EMULE();
  982. double percentClientTransferred = 0;
  983. if ( DownDataTotal!=0 && DownDataClient!=0 )
  984. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  985. cbuffer.Format( _T("eMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ) , percentClientTransferred);
  986. stattree.SetItemText( down_tcb[i] , cbuffer );
  987. i++;
  988. DownDataClient = thePrefs.GetCumDownData_EDONKEYHYBRID();
  989. if ( DownDataTotal!=0 && DownDataClient!=0 )
  990. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  991. else
  992. percentClientTransferred = 0;
  993. cbuffer.Format( _T("eD Hybrid: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ) , percentClientTransferred );
  994. stattree.SetItemText( down_tcb[i] , cbuffer );
  995. i++;
  996. DownDataClient = thePrefs.GetCumDownData_EDONKEY();
  997. if ( DownDataTotal!=0 && DownDataClient!=0 )
  998. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  999. else
  1000. percentClientTransferred = 0;
  1001. cbuffer.Format( _T("eDonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  1002. stattree.SetItemText( down_tcb[i] , cbuffer );
  1003. i++;
  1004. DownDataClient = thePrefs.GetCumDownData_AMULE();
  1005. if ( DownDataTotal!=0 && DownDataClient!=0 )
  1006. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  1007. else
  1008. percentClientTransferred = 0;
  1009. cbuffer.Format( _T("aMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  1010. stattree.SetItemText( down_tcb[i] , cbuffer );
  1011. i++;
  1012. DownDataClient = thePrefs.GetCumDownData_MLDONKEY();
  1013. if ( DownDataTotal!=0 && DownDataClient!=0 )
  1014. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  1015. else
  1016. percentClientTransferred = 0;
  1017. cbuffer.Format( _T("MLdonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  1018. stattree.SetItemText( down_tcb[i] , cbuffer );
  1019. i++;
  1020. DownDataClient = thePrefs.GetCumDownData_SHAREAZA();
  1021. if ( DownDataTotal!=0 && DownDataClient!=0 )
  1022. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  1023. else
  1024. percentClientTransferred = 0;
  1025. cbuffer.Format( _T("Shareaza: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  1026. stattree.SetItemText( down_tcb[i] , cbuffer );
  1027. i++;
  1028. DownDataClient = thePrefs.GetCumDownData_EMULECOMPAT();
  1029. if ( DownDataTotal!=0 && DownDataClient!=0 )
  1030. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  1031. else
  1032. percentClientTransferred = 0;
  1033. cbuffer.Format( _T("eM Compat: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  1034. stattree.SetItemText( down_tcb[i] , cbuffer );
  1035. i++;
  1036. DownDataClient = thePrefs.GetCumDownData_URL();
  1037. if ( DownDataTotal!=0 && DownDataClient!=0 )
  1038. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  1039. else
  1040. percentClientTransferred = 0;
  1041. cbuffer.Format( _T("URL: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  1042. stattree.SetItemText( down_tcb[i] , cbuffer );
  1043. i++;
  1044. }
  1045. // Downloaded Data By Port
  1046. if (forceUpdate || stattree.IsExpanded(hdown_tpb))
  1047. {
  1048. int i = 0;
  1049. uint64 PortDataDefault = thePrefs.GetCumDownDataPort_4662();
  1050. uint64 PortDataOther = thePrefs.GetCumDownDataPort_OTHER();
  1051. uint64 PortDataPeerCache = thePrefs.GetCumDownDataPort_PeerCache();
  1052. uint64 PortDataTotal = thePrefs.GetDownTotalPortData();
  1053. double percentPortTransferred = 0;
  1054. if ( PortDataTotal!=0 && PortDataDefault!=0 )
  1055. percentPortTransferred = (double) 100 * PortDataDefault / PortDataTotal;
  1056. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTDEF) , CastItoXBytes( PortDataDefault, false, false ) , percentPortTransferred);
  1057. stattree.SetItemText( down_tpb[i] , cbuffer );
  1058. i++;
  1059. if ( PortDataTotal!=0 && PortDataOther!=0 )
  1060. percentPortTransferred = (double) 100 * PortDataOther / PortDataTotal;
  1061. else
  1062. percentPortTransferred = 0;
  1063. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataOther, false, false ) , percentPortTransferred);
  1064. stattree.SetItemText( down_tpb[i] , cbuffer );
  1065. i++;
  1066. if ( PortDataTotal!=0 && PortDataPeerCache!=0 )
  1067. percentPortTransferred = (double) 100 * PortDataPeerCache / PortDataTotal;
  1068. else
  1069. percentPortTransferred = 0;
  1070. cbuffer.Format( _T("%s: %s (%1.1f%%)") , thePrefs.GetPeerCacheShow() ? _T("PeerCache") : GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataPeerCache, false, false ) , percentPortTransferred);
  1071. stattree.SetItemText( down_tpb[i] , cbuffer );
  1072. i++;
  1073. }
  1074. }
  1075. // Set Cum Completed Downloads
  1076. cbuffer.Format(_T("%s: %u"), GetResString(IDS_STATS_COMPDL), thePrefs.GetDownCompletedFiles() );
  1077. stattree.SetItemText(down_T[1], cbuffer);
  1078. // Set Cum Download Sessions
  1079. statGoodSessions = thePrefs.GetDownC_SuccessfulSessions() + myStats.a[1]; // Need to reset these from the session section. Declared up there.
  1080. statBadSessions = thePrefs.GetDownC_FailedSessions(); // ^^^^^^^^^^^^^^
  1081. cbuffer.Format(_T("%s: %u"), GetResString(IDS_STATS_DLSES), statGoodSessions+statBadSessions );
  1082. stattree.SetItemText(down_T[2], cbuffer);
  1083. if (forceUpdate || stattree.IsExpanded(down_T[2]))
  1084. {
  1085. // Set Cum Successful Download Sessions & Cum Average Download Per Sessions (Save an if-else statement)
  1086. if (statGoodSessions > 0)
  1087. {
  1088. percentSessions = (double) 100 * statGoodSessions / (statGoodSessions + statBadSessions);
  1089. cbuffer.Format( _T("%s: %s") , GetResString(IDS_STATS_AVGDATADLSES), CastItoXBytes(ullCumReceived / statGoodSessions, false, false));
  1090. }
  1091. else
  1092. {
  1093. percentSessions = 0;
  1094. cbuffer.Format( _T("%s: %s") , GetResString(IDS_STATS_AVGDATADLSES) , CastItoXBytes((uint32)0, false, false) );
  1095. }
  1096. stattree.SetItemText( down_tsessions[2] , cbuffer ); // Set Avg DL/Session
  1097. cbuffer.Format( _T("%s: %u (%1.1f%%)"), GetResString(IDS_STATS_SDLSES) , statGoodSessions , percentSessions );
  1098. stattree.SetItemText( down_tsessions[0] , cbuffer ); // Set Successful Sessions
  1099. // Set Cum Failed Download Sessions
  1100. if (percentSessions != 0 && statBadSessions > 0)
  1101. percentSessions = 100 - percentSessions; // There were some good sessions and bad ones...
  1102. else if (percentSessions == 0 && statBadSessions > 0)
  1103. percentSessions = 100; // There were bad sessions and no good ones, must be 100%
  1104. else
  1105. percentSessions = 0; // No sessions at all, or no bad ones.
  1106. cbuffer.Format( _T("%s: %u (%1.1f%%)") , GetResString(IDS_STATS_FDLSES) , statBadSessions , percentSessions);
  1107. stattree.SetItemText( down_tsessions[1] , cbuffer );
  1108. // Set Cumulative Average Download Time
  1109. uint32 avgDownTime = thePrefs.GetDownS_AvgTime();
  1110. if (thePrefs.GetDownC_AvgTime()<=0)
  1111. thePrefs.SetDownCAvgTime(avgDownTime);
  1112. avgDownTime = (uint32) (avgDownTime+thePrefs.GetDownC_AvgTime())/2;
  1113. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_AVGDLTIME), CastSecondsToLngHM(avgDownTime));
  1114. stattree.SetItemText(down_tsessions[3], cbuffer);
  1115. }
  1116. // Set Cumulative Gained Due To Compression
  1117. uint64 ullCumCompressed = thePrefs.GetSesSavedFromCompression() + thePrefs.GetCumSavedFromCompression();
  1118. cbuffer.Format(GetResString(IDS_STATS_GAINCOMP) + _T(" (%.1f%%)"), CastItoXBytes(ullCumCompressed, false, false), ullCumReceived!=0 ? (ullCumCompressed * 100.0 / ullCumReceived) : 0.0);
  1119. stattree.SetItemText( down_T[3] , cbuffer );
  1120. // Set Cumulative Lost Due To Corruption
  1121. uint64 ullCumCorrupted = thePrefs.GetSesLostFromCorruption() + thePrefs.GetCumLostFromCorruption();
  1122. cbuffer.Format(GetResString(IDS_STATS_LOSTCORRUPT) + _T(" (%.1f%%)"), CastItoXBytes(ullCumCorrupted, false, false), ullCumReceived!=0 ? (ullCumCorrupted * 100.0 / ullCumReceived) : 0.0);
  1123. stattree.SetItemText( down_T[4] , cbuffer );
  1124. // Set Cumulative Saved Due To ICH
  1125. cbuffer.Format(GetResString(IDS_STATS_ICHSAVED), thePrefs.GetSesPartsSavedByICH() + thePrefs.GetCumPartsSavedByICH());
  1126. stattree.SetItemText( down_T[5] , cbuffer );
  1127. if (DownOHTotal == 0 || DownOHTotalPackets == 0)
  1128. {
  1129. DownOHTotal = theStats.GetDownDataOverheadFileRequest() +
  1130. theStats.GetDownDataOverheadSourceExchange() +
  1131. theStats.GetDownDataOverheadServer() +
  1132. theStats.GetDownDataOverheadKad() +
  1133. theStats.GetDownDataOverheadOther();
  1134. DownOHTotalPackets =
  1135. theStats.GetDownDataOverheadFileRequestPackets() +
  1136. theStats.GetDownDataOverheadSourceExchangePackets() +
  1137. theStats.GetDownDataOverheadServerPackets() +
  1138. theStats.GetDownDataOverheadKadPackets() +
  1139. theStats.GetDownDataOverheadOtherPackets();
  1140. }
  1141. // Total Overhead
  1142. cbuffer.Format(GetResString(IDS_TOVERHEAD),CastItoXBytes(DownOHTotal + thePrefs.GetDownOverheadTotal(), false, false), CastItoIShort(DownOHTotalPackets + thePrefs.GetDownOverheadTotalPackets()));
  1143. stattree.SetItemText(hdown_toh, cbuffer);
  1144. if (forceUpdate || stattree.IsExpanded(hdown_toh))
  1145. {
  1146. int i = 0;
  1147. // File Request Overhead
  1148. cbuffer.Format(GetResString(IDS_FROVERHEAD), CastItoXBytes( theStats.GetDownDataOverheadFileRequest() + thePrefs.GetDownOverheadFileReq(), false, false), CastItoIShort(theStats.GetDownDataOverheadFileRequestPackets() + thePrefs.GetDownOverheadFileReqPackets()));
  1149. stattree.SetItemText(down_toh[i], cbuffer);
  1150. i++;
  1151. // Source Exchange Overhead
  1152. cbuffer.Format(GetResString(IDS_SSOVERHEAD), CastItoXBytes( theStats.GetDownDataOverheadSourceExchange()+thePrefs.GetDownOverheadSrcEx(), false, false), CastItoIShort(theStats.GetDownDataOverheadSourceExchangePackets()+thePrefs.GetDownOverheadSrcExPackets()));
  1153. stattree.SetItemText(down_toh[i], cbuffer);
  1154. i++;
  1155. // Server Overhead
  1156. cbuffer.Format(GetResString(IDS_SOVERHEAD),
  1157. CastItoXBytes(theStats.GetDownDataOverheadServer() +
  1158. thePrefs.GetDownOverheadServer(), false, false),
  1159. CastItoIShort(theStats.GetDownDataOverheadServerPackets() +
  1160. thePrefs.GetDownOverheadServerPackets()));
  1161. stattree.SetItemText(down_toh[i], cbuffer);
  1162. i++;
  1163. // Kad Overhead
  1164. cbuffer.Format(GetResString(IDS_KADOVERHEAD),
  1165. CastItoXBytes(theStats.GetDownDataOverheadKad() +
  1166. thePrefs.GetDownOverheadKad(), false, false),
  1167. CastItoIShort(theStats.GetDownDataOverheadKadPackets() +
  1168. thePrefs.GetDownOverheadKadPackets()));
  1169. stattree.SetItemText(down_toh[i], cbuffer);
  1170. i++;
  1171. }
  1172. } // - End Transfer -> Downloads -> Cumulative Section
  1173. } // - End Transfer -> Downloads Section
  1174. // TRANSFER-> UPLOADS SECTION
  1175. if (forceUpdate || stattree.IsExpanded(h_upload))
  1176. {
  1177. uint64 UpOHTotal = 0;
  1178. uint64 UpOHTotalPackets = 0;
  1179. // TRANSFER -> UPLOADS -> SESSION SECTION
  1180. if (forceUpdate || stattree.IsExpanded(h_up_session))
  1181. {
  1182. // Uploaded Data
  1183. cbuffer.Format(GetResString(IDS_STATS_UDATA),CastItoXBytes(theStats.sessionSentBytes, false, false));
  1184. stattree.SetItemText(up_S[0], cbuffer);
  1185. if (forceUpdate || stattree.IsExpanded(up_S[0]))
  1186. {
  1187. // Uploaded Data By Client
  1188. if (forceUpdate || stattree.IsExpanded(hup_scb))
  1189. {
  1190. int i = 0;
  1191. uint64 UpDataTotal = thePrefs.GetUpSessionClientData();
  1192. uint64 UpDataClient = thePrefs.GetUpData_EMULE();
  1193. double percentClientTransferred = 0;
  1194. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1195. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1196. cbuffer.Format( _T("eMule: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ) , percentClientTransferred);
  1197. stattree.SetItemText( up_scb[i] , cbuffer );
  1198. i++;
  1199. UpDataClient = thePrefs.GetUpData_EDONKEYHYBRID();
  1200. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1201. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1202. else
  1203. percentClientTransferred = 0;
  1204. cbuffer.Format( _T("eD Hybrid: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ) , percentClientTransferred );
  1205. stattree.SetItemText( up_scb[i] , cbuffer );
  1206. i++;
  1207. UpDataClient = thePrefs.GetUpData_EDONKEY();
  1208. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1209. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1210. else
  1211. percentClientTransferred = 0;
  1212. cbuffer.Format( _T("eDonkey: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1213. stattree.SetItemText( up_scb[i] , cbuffer );
  1214. i++;
  1215. UpDataClient = thePrefs.GetUpData_AMULE();
  1216. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1217. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1218. else
  1219. percentClientTransferred = 0;
  1220. cbuffer.Format( _T("aMule: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1221. stattree.SetItemText( up_scb[i] , cbuffer );
  1222. i++;
  1223. UpDataClient = thePrefs.GetUpData_MLDONKEY();
  1224. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1225. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1226. else
  1227. percentClientTransferred = 0;
  1228. cbuffer.Format( _T("MLdonkey: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1229. stattree.SetItemText( up_scb[i] , cbuffer );
  1230. i++;
  1231. UpDataClient = thePrefs.GetUpData_SHAREAZA();
  1232. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1233. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1234. else
  1235. percentClientTransferred = 0;
  1236. cbuffer.Format( _T("Shareaza: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1237. stattree.SetItemText( up_scb[i] , cbuffer );
  1238. i++;
  1239. UpDataClient = thePrefs.GetUpData_EMULECOMPAT();
  1240. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1241. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1242. else
  1243. percentClientTransferred = 0;
  1244. cbuffer.Format( _T("eM Compat: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1245. stattree.SetItemText( up_scb[i] , cbuffer );
  1246. i++;
  1247. }
  1248. // Uploaded Data By Port
  1249. if (forceUpdate || stattree.IsExpanded(hup_spb))
  1250. {
  1251. int i = 0;
  1252. uint64 PortDataDefault = thePrefs.GetUpDataPort_4662();
  1253. uint64 PortDataOther = thePrefs.GetUpDataPort_OTHER();
  1254. uint64 PortDataPeerCache = thePrefs.GetUpDataPort_PeerCache();
  1255. uint64 PortDataTotal = thePrefs.GetUpSessionPortData();
  1256. double percentPortTransferred = 0;
  1257. if ( PortDataTotal!=0 && PortDataDefault!=0 )
  1258. percentPortTransferred = (double) 100 * PortDataDefault / PortDataTotal;
  1259. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTDEF) , CastItoXBytes( PortDataDefault, false, false ) , percentPortTransferred);
  1260. stattree.SetItemText( up_spb[i] , cbuffer );
  1261. i++;
  1262. if ( PortDataTotal!=0 && PortDataOther!=0 )
  1263. percentPortTransferred = (double) 100 * PortDataOther / PortDataTotal;
  1264. else
  1265. percentPortTransferred = 0;
  1266. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataOther, false, false ) , percentPortTransferred);
  1267. stattree.SetItemText( up_spb[i] , cbuffer );
  1268. i++;
  1269. if ( PortDataTotal!=0 && PortDataPeerCache!=0 )
  1270. percentPortTransferred = (double) 100 * PortDataPeerCache / PortDataTotal;
  1271. else
  1272. percentPortTransferred = 0;
  1273. cbuffer.Format( _T("%s: %s (%1.1f%%)") , thePrefs.GetPeerCacheShow() ? _T("PeerCache") : GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataPeerCache, false, false ) , percentPortTransferred);
  1274. stattree.SetItemText( up_spb[i] , cbuffer );
  1275. i++;
  1276. }
  1277. // Uploaded Data By Source
  1278. if (forceUpdate || stattree.IsExpanded(hup_ssb))
  1279. {
  1280. int i = 0;
  1281. uint64 DataSourceFile = thePrefs.GetUpData_File();
  1282. uint64 DataSourcePF = thePrefs.GetUpData_Partfile();
  1283. uint64 DataSourceTotal = thePrefs.GetUpSessionDataFile();
  1284. double percentFileTransferred = 0;
  1285. if ( DataSourceTotal!=0 && DataSourceFile!=0 )
  1286. percentFileTransferred = (double) 100 * DataSourceFile / DataSourceTotal;
  1287. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_DSFILE) , CastItoXBytes( DataSourceFile, false, false ) , percentFileTransferred);
  1288. stattree.SetItemText( up_ssb[i] , cbuffer );
  1289. i++;
  1290. if ( DataSourceTotal!=0 && DataSourcePF!=0 )
  1291. percentFileTransferred = (double) 100 * DataSourcePF / DataSourceTotal;
  1292. else
  1293. percentFileTransferred = 0;
  1294. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_DSPF) , CastItoXBytes( DataSourcePF, false, false ) , percentFileTransferred);
  1295. stattree.SetItemText( up_ssb[i] , cbuffer );
  1296. i++;
  1297. }
  1298. }
  1299. // Amount of data uploaded to friends
  1300. cbuffer.Format(GetResString(IDS_STATS_UDATA_FRIENDS),CastItoXBytes(theStats.sessionSentBytesToFriend, false, false));
  1301. stattree.SetItemText(up_S[1], cbuffer);
  1302. // Set fully Active Uploads
  1303. cbuffer.Format(GetResString(IDS_STATS_ACTUL_ZZ),theApp.uploadqueue->GetActiveUploadsCount()); //theApp.uploadqueue->GetUploadQueueLength()
  1304. stattree.SetItemText(up_S[2], cbuffer);
  1305. // Set Set Total Uploads
  1306. cbuffer.Format(GetResString(IDS_STATS_TOTALUL),theApp.uploadqueue->GetUploadQueueLength());
  1307. stattree.SetItemText(up_S[3], cbuffer);
  1308. // Set Queue Length
  1309. cbuffer.Format(GetResString(IDS_STATS_WAITINGUSERS),theApp.uploadqueue->GetWaitingUserCount());
  1310. stattree.SetItemText(up_S[4], cbuffer);
  1311. // Set Upload Sessions
  1312. statGoodSessions = theApp.uploadqueue->GetSuccessfullUpCount() + theApp.uploadqueue->GetUploadQueueLength();
  1313. statBadSessions = theApp.uploadqueue->GetFailedUpCount();
  1314. cbuffer.Format(_T("%s: %u"), GetResString(IDS_STATS_ULSES), statGoodSessions + statBadSessions);
  1315. stattree.SetItemText(up_S[5], cbuffer);
  1316. if (forceUpdate || stattree.IsExpanded(up_S[5]))
  1317. {
  1318. // Set Successful Upload Sessions & Average Uploaded Per Session
  1319. if (statGoodSessions>0)
  1320. { // Blackholes are when God divided by 0
  1321. percentSessions = (double) 100*statGoodSessions/(statGoodSessions+statBadSessions);
  1322. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_AVGDATAULSES), CastItoXBytes( theStats.sessionSentBytes / statGoodSessions, false, false) );
  1323. }
  1324. else
  1325. {
  1326. percentSessions = 0;
  1327. cbuffer.Format( _T("%s: %s") , GetResString(IDS_STATS_AVGDATAULSES) , GetResString(IDS_FSTAT_WAITING) );
  1328. }
  1329. stattree.SetItemText(up_ssessions[2], cbuffer);
  1330. cbuffer.Format(GetResString(IDS_STATS_SUCCUPCOUNT),statGoodSessions,percentSessions);
  1331. stattree.SetItemText(up_ssessions[0], cbuffer);
  1332. // Set Failed Upload Sessions
  1333. if (percentSessions != 0 && statBadSessions > 0)
  1334. percentSessions = 100 - percentSessions; // There were some good sessions and bad ones...
  1335. else if (percentSessions == 0 && statBadSessions > 0)
  1336. percentSessions = 100; // There were bad sessions and no good ones, must be 100%
  1337. else
  1338. percentSessions = 0; // No sessions at all, or no bad ones.
  1339. cbuffer.Format(GetResString(IDS_STATS_FAILUPCOUNT),statBadSessions,percentSessions);
  1340. stattree.SetItemText(up_ssessions[1], cbuffer);
  1341. // Set Avg Upload time
  1342. //DWORD running=theApp.uploadqueue->GetAverageUpTime();
  1343. cbuffer.Format(GetResString(IDS_STATS_AVEUPTIME),CastSecondsToLngHM(theApp.uploadqueue->GetAverageUpTime()));
  1344. stattree.SetItemText(up_ssessions[3], cbuffer);
  1345. }
  1346. // Calculate Upline OH Totals
  1347. UpOHTotal = theStats.GetUpDataOverheadFileRequest() +
  1348. theStats.GetUpDataOverheadSourceExchange() +
  1349. theStats.GetUpDataOverheadServer() +
  1350. theStats.GetUpDataOverheadKad() +
  1351. theStats.GetUpDataOverheadOther();
  1352. UpOHTotalPackets = theStats.GetUpDataOverheadFileRequestPackets() +
  1353. theStats.GetUpDataOverheadSourceExchangePackets() +
  1354. theStats.GetUpDataOverheadServerPackets() +
  1355. theStats.GetUpDataOverheadKadPackets() +
  1356. theStats.GetUpDataOverheadOtherPackets();
  1357. // Total Upline Overhead
  1358. cbuffer.Format(GetResString(IDS_TOVERHEAD), CastItoXBytes( UpOHTotal, false, false ), CastItoIShort(UpOHTotalPackets));
  1359. stattree.SetItemText(hup_soh, cbuffer);
  1360. if (forceUpdate || stattree.IsExpanded(hup_soh))
  1361. {
  1362. int i = 0;
  1363. // File Request Overhead
  1364. cbuffer.Format(GetResString(IDS_FROVERHEAD), CastItoXBytes( theStats.GetUpDataOverheadFileRequest(), false, false ), CastItoIShort(theStats.GetUpDataOverheadFileRequestPackets()));
  1365. stattree.SetItemText(up_soh[i], cbuffer);
  1366. i++;
  1367. // Source Exchanged Overhead
  1368. cbuffer.Format(GetResString(IDS_SSOVERHEAD), CastItoXBytes( theStats.GetUpDataOverheadSourceExchange(), false, false ), CastItoIShort(theStats.GetUpDataOverheadSourceExchangePackets()));
  1369. stattree.SetItemText(up_soh[i], cbuffer);
  1370. i++;
  1371. // Server Overhead
  1372. cbuffer.Format(GetResString(IDS_SOVERHEAD),
  1373. CastItoXBytes(theStats.GetUpDataOverheadServer(), false, false),
  1374. CastItoIShort(theStats.GetUpDataOverheadServerPackets()));
  1375. stattree.SetItemText(up_soh[i], cbuffer);
  1376. i++;
  1377. // Kad Overhead
  1378. cbuffer.Format(GetResString(IDS_KADOVERHEAD),
  1379. CastItoXBytes(theStats.GetUpDataOverheadKad(), false, false),
  1380. CastItoIShort(theStats.GetUpDataOverheadKadPackets()));
  1381. stattree.SetItemText(up_soh[i], cbuffer);
  1382. i++;
  1383. }
  1384. } // - End Transfer -> Uploads -> Session Section
  1385. // TRANSFER -> UPLOADS -> CUMULATIVE SECTION
  1386. if (forceUpdate || stattree.IsExpanded(h_up_total))
  1387. {
  1388. // Uploaded Data
  1389. cbuffer.Format(GetResString(IDS_STATS_UDATA),CastItoXBytes( theStats.sessionSentBytes+thePrefs.GetTotalUploaded(), false, false));
  1390. stattree.SetItemText(up_T[0],cbuffer);
  1391. if (forceUpdate || stattree.IsExpanded(up_T[0]))
  1392. {
  1393. // Uploaded Data By Client
  1394. if (forceUpdate || stattree.IsExpanded(hup_tcb))
  1395. {
  1396. int i = 0;
  1397. uint64 UpDataTotal = thePrefs.GetUpTotalClientData();
  1398. uint64 UpDataClient = thePrefs.GetCumUpData_EMULE();
  1399. double percentClientTransferred = 0;
  1400. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1401. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1402. cbuffer.Format( _T("eMule: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ) , percentClientTransferred);
  1403. stattree.SetItemText( up_tcb[i] , cbuffer );
  1404. i++;
  1405. UpDataClient = thePrefs.GetCumUpData_EDONKEYHYBRID();
  1406. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1407. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1408. else
  1409. percentClientTransferred = 0;
  1410. cbuffer.Format( _T("eD Hybrid: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ) , percentClientTransferred );
  1411. stattree.SetItemText( up_tcb[i] , cbuffer );
  1412. i++;
  1413. UpDataClient = thePrefs.GetCumUpData_EDONKEY();
  1414. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1415. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1416. else
  1417. percentClientTransferred = 0;
  1418. cbuffer.Format( _T("eDonkey: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1419. stattree.SetItemText( up_tcb[i] , cbuffer );
  1420. i++;
  1421. UpDataClient = thePrefs.GetCumUpData_AMULE();
  1422. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1423. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1424. else
  1425. percentClientTransferred = 0;
  1426. cbuffer.Format( _T("aMule: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1427. stattree.SetItemText( up_tcb[i] , cbuffer );
  1428. i++;
  1429. UpDataClient = thePrefs.GetCumUpData_MLDONKEY();
  1430. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1431. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1432. else
  1433. percentClientTransferred = 0;
  1434. cbuffer.Format( _T("MLdonkey: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1435. stattree.SetItemText( up_tcb[i] , cbuffer );
  1436. i++;
  1437. UpDataClient = thePrefs.GetCumUpData_SHAREAZA();
  1438. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1439. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1440. else
  1441. percentClientTransferred = 0;
  1442. cbuffer.Format( _T("Shareaza: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1443. stattree.SetItemText( up_tcb[i] , cbuffer );
  1444. i++;
  1445. UpDataClient = thePrefs.GetCumUpData_EMULECOMPAT();
  1446. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1447. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1448. else
  1449. percentClientTransferred = 0;
  1450. cbuffer.Format( _T("eM Compat: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1451. stattree.SetItemText( up_tcb[i] , cbuffer );
  1452. i++;
  1453. }
  1454. // Uploaded Data By Port
  1455. if (forceUpdate || stattree.IsExpanded(hup_tpb))
  1456. {
  1457. int i = 0;
  1458. uint64 PortDataDefault = thePrefs.GetCumUpDataPort_4662();
  1459. uint64 PortDataOther = thePrefs.GetCumUpDataPort_OTHER();
  1460. uint64 PortDataPeerCache = thePrefs.GetCumUpDataPort_PeerCache();
  1461. uint64 PortDataTotal = thePrefs.GetUpTotalPortData();
  1462. double percentPortTransferred = 0;
  1463. if ( PortDataTotal!=0 && PortDataDefault!=0 )
  1464. percentPortTransferred = (double) 100 * PortDataDefault / PortDataTotal;
  1465. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTDEF) , CastItoXBytes( PortDataDefault, false, false ) , percentPortTransferred);
  1466. stattree.SetItemText( up_tpb[i] , cbuffer );
  1467. i++;
  1468. if ( PortDataTotal!=0 && PortDataOther!=0 )
  1469. percentPortTransferred = (double) 100 * PortDataOther / PortDataTotal;
  1470. else
  1471. percentPortTransferred = 0;
  1472. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataOther, false, false ) , percentPortTransferred);
  1473. stattree.SetItemText( up_tpb[i] , cbuffer );
  1474. i++;
  1475. if ( PortDataTotal!=0 && PortDataPeerCache!=0 )
  1476. percentPortTransferred = (double) 100 * PortDataPeerCache / PortDataTotal;
  1477. else
  1478. percentPortTransferred = 0;
  1479. cbuffer.Format( _T("%s: %s (%1.1f%%)") , thePrefs.GetPeerCacheShow() ? _T("PeerCache") : GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataPeerCache, false, false ) , percentPortTransferred);
  1480. stattree.SetItemText( up_tpb[i] , cbuffer );
  1481. i++;
  1482. }
  1483. // Uploaded Data By Source
  1484. if (forceUpdate || stattree.IsExpanded(hup_tsb))
  1485. {
  1486. int i = 0;
  1487. uint64 DataSourceFile = thePrefs.GetCumUpData_File();
  1488. uint64 DataSourcePF = thePrefs.GetCumUpData_Partfile();
  1489. uint64 DataSourceTotal = thePrefs.GetUpTotalDataFile();
  1490. double percentFileTransferred = 0;
  1491. if ( DataSourceTotal!=0 && DataSourceFile!=0 )
  1492. percentFileTransferred = (double) 100 * DataSourceFile / DataSourceTotal;
  1493. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_DSFILE) , CastItoXBytes( DataSourceFile, false, false ) , percentFileTransferred);
  1494. stattree.SetItemText( up_tsb[i] , cbuffer );
  1495. i++;
  1496. if ( DataSourceTotal!=0 && DataSourcePF!=0 )
  1497. percentFileTransferred = (double) 100 * DataSourcePF / DataSourceTotal;
  1498. else
  1499. percentFileTransferred = 0;
  1500. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_DSPF) , CastItoXBytes( DataSourcePF, false, false ) , percentFileTransferred);
  1501. stattree.SetItemText( up_tsb[i] , cbuffer );
  1502. i++;
  1503. }
  1504. }
  1505. // Upload Sessions
  1506. statGoodSessions = theApp.uploadqueue->GetSuccessfullUpCount() + thePrefs.GetUpSuccessfulSessions() + theApp.uploadqueue->GetUploadQueueLength();
  1507. statBadSessions = theApp.uploadqueue->GetFailedUpCount() + thePrefs.GetUpFailedSessions();
  1508. cbuffer.Format(_T("%s: %u"), GetResString(IDS_STATS_ULSES), statGoodSessions + statBadSessions);
  1509. stattree.SetItemText(up_T[1], cbuffer);
  1510. if (forceUpdate || stattree.IsExpanded(up_T[1]))
  1511. {
  1512. // Set Successful Upload Sessions & Average Uploaded Per Session
  1513. if (statGoodSessions>0)
  1514. { // Blackholes are when God divided by 0
  1515. percentSessions = (double) 100*statGoodSessions/(statGoodSessions+statBadSessions);
  1516. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_AVGDATAULSES), CastItoXBytes((theStats.sessionSentBytes + thePrefs.GetTotalUploaded()) / statGoodSessions, false, false) );
  1517. }
  1518. else
  1519. {
  1520. percentSessions = 0;
  1521. cbuffer.Format( _T("%s: %s") , GetResString(IDS_STATS_AVGDATAULSES) , GetResString(IDS_FSTAT_WAITING) );
  1522. }
  1523. stattree.SetItemText(up_tsessions[2], cbuffer);
  1524. cbuffer.Format(GetResString(IDS_STATS_SUCCUPCOUNT),statGoodSessions,percentSessions);
  1525. stattree.SetItemText(up_tsessions[0], cbuffer);
  1526. // Set Failed Upload Sessions
  1527. if (percentSessions != 0 && statBadSessions > 0)
  1528. percentSessions = 100 - percentSessions; // There were some good sessions and bad ones...
  1529. else if (percentSessions == 0 && statBadSessions > 0)
  1530. percentSessions = 100; // There were bad sessions and no good ones, must be 100%
  1531. else
  1532. percentSessions = 0; // No sessions at all, or no bad ones.
  1533. cbuffer.Format(GetResString(IDS_STATS_FAILUPCOUNT),statBadSessions,percentSessions);
  1534. stattree.SetItemText(up_tsessions[1], cbuffer);
  1535. // Set Avg Upload time
  1536. uint32 avguptime = theApp.uploadqueue->GetAverageUpTime();
  1537. if (thePrefs.GetUpAvgTime()<=0)
  1538. thePrefs.SetUpAvgTime(avguptime);
  1539. avguptime = (uint32) (avguptime+thePrefs.GetUpAvgTime())/2;
  1540. cbuffer.Format(GetResString(IDS_STATS_AVEUPTIME),CastSecondsToLngHM(avguptime));
  1541. stattree.SetItemText(up_tsessions[3], cbuffer);
  1542. }
  1543. if (UpOHTotal == 0 || UpOHTotalPackets == 0)
  1544. {
  1545. // Calculate Upline OH Totals
  1546. UpOHTotal = theStats.GetUpDataOverheadFileRequest() +
  1547. theStats.GetUpDataOverheadSourceExchange() +
  1548. theStats.GetUpDataOverheadServer() +
  1549. theStats.GetUpDataOverheadKad() +
  1550. theStats.GetUpDataOverheadOther();
  1551. UpOHTotalPackets = theStats.GetUpDataOverheadFileRequestPackets() +
  1552. theStats.GetUpDataOverheadSourceExchangePackets() +
  1553. theStats.GetUpDataOverheadServerPackets() +
  1554. theStats.GetUpDataOverheadKadPackets() +
  1555. theStats.GetUpDataOverheadOtherPackets();
  1556. }
  1557. // Set Cumulative Total Overhead
  1558. cbuffer.Format(GetResString(IDS_TOVERHEAD),CastItoXBytes(UpOHTotal + thePrefs.GetUpOverheadTotal(), false, false), CastItoIShort(UpOHTotalPackets + thePrefs.GetUpOverheadTotalPackets()));
  1559. stattree.SetItemText(hup_toh, cbuffer);
  1560. if (forceUpdate || stattree.IsExpanded(hup_toh))
  1561. {
  1562. int i = 0;
  1563. // Set up total file req OH
  1564. cbuffer.Format(GetResString(IDS_FROVERHEAD), CastItoXBytes( theStats.GetUpDataOverheadFileRequest() + thePrefs.GetUpOverheadFileReq(), false, false), CastItoIShort(theStats.GetUpDataOverheadFileRequestPackets() + thePrefs.GetUpOverheadFileReqPackets()));
  1565. stattree.SetItemText(up_toh[i], cbuffer);
  1566. i++;
  1567. // Set up total source exch OH
  1568. cbuffer.Format(GetResString(IDS_SSOVERHEAD), CastItoXBytes( theStats.GetUpDataOverheadSourceExchange()+thePrefs.GetUpOverheadSrcEx(), false, false), CastItoIShort(theStats.GetUpDataOverheadSourceExchangePackets()+thePrefs.GetUpOverheadSrcExPackets()));
  1569. stattree.SetItemText(up_toh[i], cbuffer);
  1570. i++;
  1571. // Set up total server OH
  1572. cbuffer.Format(GetResString(IDS_SOVERHEAD),
  1573. CastItoXBytes(theStats.GetUpDataOverheadServer()
  1574. + thePrefs.GetUpOverheadServer(), false, false),
  1575. CastItoIShort(theStats.GetUpDataOverheadServerPackets()
  1576. + thePrefs.GetUpOverheadServerPackets()));
  1577. stattree.SetItemText(up_toh[i], cbuffer);
  1578. i++;
  1579. // Set up total Kad OH
  1580. cbuffer.Format(GetResString(IDS_KADOVERHEAD),
  1581. CastItoXBytes(theStats.GetUpDataOverheadKad() +
  1582. thePrefs.GetUpOverheadKad(), false, false),
  1583. CastItoIShort(theStats.GetUpDataOverheadKadPackets() +
  1584. thePrefs.GetUpOverheadKadPackets()));
  1585. stattree.SetItemText(up_toh[i], cbuffer);
  1586. i++;
  1587. }
  1588. } // - End Transfer -> Uploads -> Cumulative Section
  1589. } // - End Transfer -> Uploads Section
  1590. } // - END TRANSFER SECTION
  1591. // CONNECTION SECTION
  1592. if (forceUpdate || stattree.IsExpanded(h_connection))
  1593. {
  1594. // CONNECTION -> SESSION SECTION
  1595. if (forceUpdate || stattree.IsExpanded(h_conn_session))
  1596. {
  1597. // CONNECTION -> SESSION -> GENERAL SECTION
  1598. if (forceUpdate || stattree.IsExpanded(hconn_sg))
  1599. {
  1600. int i = 0;
  1601. // Server Reconnects
  1602. if (theStats.reconnects>0)
  1603. cbuffer.Format(GetResString(IDS_STATS_RECONNECTS),theStats.reconnects-1);
  1604. else
  1605. cbuffer.Format(GetResString(IDS_STATS_RECONNECTS),0);
  1606. stattree.SetItemText(conn_sg[i], cbuffer);
  1607. i++;
  1608. // Active Connections
  1609. cbuffer.Format(_T("%s: %i (%s:%u | %s:%u | %s:%u)"),GetResString(IDS_SF_ACTIVECON),theApp.listensocket->GetActiveConnections(), GetResString(IDS_HALF), theApp.listensocket->GetTotalHalfCon(), GetResString(IDS_CONCOMPL) ,theApp.listensocket->GetTotalComp(), GetResString(IDS_STATS_PRTOTHER) ,theApp.listensocket->GetActiveConnections() - theApp.listensocket->GetTotalHalfCon() - theApp.listensocket->GetTotalComp());
  1610. stattree.SetItemText(conn_sg[i], cbuffer);
  1611. i++;
  1612. // Average Connections
  1613. cbuffer.Format(_T("%s: %i"),GetResString(IDS_SF_AVGCON),(int)theApp.listensocket->GetAverageConnections());
  1614. stattree.SetItemText(conn_sg[i], cbuffer);
  1615. i++;
  1616. // Peak Connections
  1617. cbuffer.Format(_T("%s: %i"),GetResString(IDS_SF_PEAKCON),theApp.listensocket->GetPeakConnections());
  1618. stattree.SetItemText(conn_sg[i], cbuffer);
  1619. i++;
  1620. // Connect Limit Reached
  1621. uint32 m_itemp = theApp.listensocket->GetMaxConnectionReached();
  1622. if( m_itemp != m_ilastMaxConnReached )
  1623. {
  1624. cbuffer.Format(_T("%s: %i : %s"), GetResString(IDS_SF_MAXCONLIMITREACHED), m_itemp, CTime::GetCurrentTime().Format(_T("%c")));
  1625. stattree.SetItemText(conn_sg[i], cbuffer);
  1626. m_ilastMaxConnReached = m_itemp;
  1627. }
  1628. else if( m_itemp == 0 )
  1629. {
  1630. cbuffer.Format(_T("%s: %i"),GetResString(IDS_SF_MAXCONLIMITREACHED),m_itemp);
  1631. stattree.SetItemText(conn_sg[i], cbuffer);
  1632. }
  1633. i++;
  1634. } // - End Connection -> Session -> General Section
  1635. // CONNECTION -> SESSION -> UPLOADS SECTION
  1636. if (forceUpdate || stattree.IsExpanded(hconn_su))
  1637. {
  1638. int i = 0;
  1639. // Upload Rate
  1640. cbuffer.Format(_T("%s: %s"), GetResString(IDS_ST_UPLOAD),CastItoXBytes(theStats.rateUp, true, true));
  1641. stattree.SetItemText(conn_su[i], cbuffer);
  1642. i++;
  1643. // Average Upload Rate
  1644. cbuffer.Format(GetResString(IDS_STATS_AVGUL),CastItoXBytes(theStats.GetAvgUploadRate(AVG_SESSION), true, true));
  1645. stattree.SetItemText(conn_su[i], cbuffer);
  1646. i++;
  1647. // Max Upload Rate
  1648. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_MAXUL), CastItoXBytes(theStats.maxUp, true, true));
  1649. stattree.SetItemText(conn_su[i], cbuffer);
  1650. i++;
  1651. // Max Average Upload Rate
  1652. float myAverageUpRate = theStats.GetAvgUploadRate(AVG_SESSION);
  1653. if (myAverageUpRate>theStats.maxUpavg)
  1654. theStats.maxUpavg = myAverageUpRate;
  1655. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_MAXAVGUL), CastItoXBytes(theStats.maxUpavg, true, true));
  1656. stattree.SetItemText(conn_su[i], cbuffer);
  1657. i++;
  1658. } // - End Connection -> Session -> Uploads Section
  1659. // CONNECTION -> SESSION -> DOWNLOADShead SECTION
  1660. if (forceUpdate || stattree.IsExpanded(hconn_sd))
  1661. {
  1662. int i = 0;
  1663. // Download Rate
  1664. cbuffer.Format(_T("%s: %s"), GetResString(IDS_ST_DOWNLOAD), CastItoXBytes(theStats.rateDown, true, true));
  1665. stattree.SetItemText(conn_sd[i], cbuffer);
  1666. i++;
  1667. // Average Download Rate
  1668. cbuffer.Format(GetResString(IDS_STATS_AVGDL),CastItoXBytes(theStats.GetAvgDownloadRate(AVG_SESSION), true, true));
  1669. stattree.SetItemText(conn_sd[i], cbuffer);
  1670. i++;
  1671. // Max Download Rate
  1672. cbuffer.Format(GetResString(IDS_STATS_MAXDL),CastItoXBytes(theStats.maxDown, true, true));
  1673. stattree.SetItemText(conn_sd[i], cbuffer);
  1674. i++;
  1675. // Max Average Download Rate
  1676. float myAverageDownRate = theStats.GetAvgDownloadRate(AVG_SESSION);
  1677. if (myAverageDownRate>theStats.maxDownavg)
  1678. theStats.maxDownavg = myAverageDownRate;
  1679. cbuffer.Format(GetResString(IDS_STATS_MAXAVGDL), CastItoXBytes(theStats.maxDownavg, true, true));
  1680. stattree.SetItemText(conn_sd[i], cbuffer);
  1681. i++;
  1682. } // - End Connection -> Session -> Downloads Section
  1683. } // - End Connection -> Session Section
  1684. // CONNECTION -> CUMULATIVE SECTION
  1685. if (forceUpdate || stattree.IsExpanded(h_conn_total))
  1686. {
  1687. // CONNECTION -> CUMULATIVE -> GENERAL SECTION
  1688. if (forceUpdate || stattree.IsExpanded(hconn_tg))
  1689. {
  1690. int i = 0;
  1691. // Server Reconnects
  1692. if(theStats.reconnects>0)
  1693. cbuffer.Format(GetResString(IDS_STATS_RECONNECTS),theStats.reconnects - 1 + thePrefs.GetConnNumReconnects());
  1694. else
  1695. cbuffer.Format(GetResString(IDS_STATS_RECONNECTS),thePrefs.GetConnNumReconnects());
  1696. stattree.SetItemText(conn_tg[i], cbuffer);
  1697. i++;
  1698. // Average Connections
  1699. cbuffer.Format(_T("%s: %i"), GetResString(IDS_SF_AVGCON), (int) (theApp.listensocket->GetActiveConnections() + thePrefs.GetConnAvgConnections()) / 2 );
  1700. stattree.SetItemText(conn_tg[i], cbuffer);
  1701. i++;
  1702. // Peak Connections
  1703. cbuffer.Format(_T("%s: %i"), GetResString(IDS_SF_PEAKCON), thePrefs.GetConnPeakConnections());
  1704. stattree.SetItemText(conn_tg[i], cbuffer);
  1705. i++;
  1706. // Connection Limit Reached
  1707. cbuffer.Format(_T("%s: %i"), GetResString(IDS_SF_MAXCONLIMITREACHED), theApp.listensocket->GetMaxConnectionReached() + thePrefs.GetConnMaxConnLimitReached());
  1708. stattree.SetItemText(conn_tg[i], cbuffer);
  1709. i++;
  1710. } // - End Connection -> Cumulative -> General Section
  1711. // CONNECTION -> CUMULATIVE -> UPLOADS SECTION
  1712. if (forceUpdate || stattree.IsExpanded(hconn_tu))
  1713. {
  1714. int i = 0;
  1715. // Average Upload Rate
  1716. cbuffer.Format(GetResString(IDS_STATS_AVGUL),CastItoXBytes(theStats.cumUpavg, true, true));
  1717. stattree.SetItemText(conn_tu[i], cbuffer);
  1718. i++;
  1719. // Max Upload Rate
  1720. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_MAXUL), CastItoXBytes(theStats.maxcumUp, true, true));
  1721. stattree.SetItemText(conn_tu[i], cbuffer);
  1722. i++;
  1723. // Max Average Upload Rate
  1724. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_MAXAVGUL), CastItoXBytes(theStats.maxcumUpavg, true, true));
  1725. stattree.SetItemText(conn_tu[i], cbuffer);
  1726. i++;
  1727. } // - End Connection -> Cumulative -> Uploads Section
  1728. // CONNECTION -> CUMULATIVE -> DOWNLOADS SECTION
  1729. if (forceUpdate || stattree.IsExpanded(hconn_td))
  1730. {
  1731. int i = 0;
  1732. // Average Download Rate
  1733. cbuffer.Format(GetResString(IDS_STATS_AVGDL), CastItoXBytes(theStats.cumDownavg, true, true));
  1734. stattree.SetItemText(conn_td[i], cbuffer);
  1735. i++;
  1736. // Max Download Rate
  1737. cbuffer.Format(GetResString(IDS_STATS_MAXDL), CastItoXBytes(theStats.maxcumDown, true, true));
  1738. stattree.SetItemText(conn_td[i], cbuffer);
  1739. i++;
  1740. // Max Average Download Rate
  1741. cbuffer.Format(GetResString(IDS_STATS_MAXAVGDL), CastItoXBytes(theStats.maxcumDownavg, true, true));
  1742. stattree.SetItemText(conn_td[i], cbuffer);
  1743. i++;
  1744. } // - End Connection -> Cumulative -> Downloads Section
  1745. } // - End Connection -> Cumulative Section
  1746. } // - END CONNECTION SECTION
  1747. // TIME STATISTICS SECTION
  1748. if (forceUpdate || stattree.IsExpanded(h_time))
  1749. {
  1750. // Statistics Last Reset
  1751. cbuffer.Format(GetResString(IDS_STATS_LASTRESETSTATIC), thePrefs.GetStatsLastResetStr(false));
  1752. stattree.SetItemText(tvitime[0], cbuffer);
  1753. // Time Since Last Reset
  1754. time_t timeDiff;
  1755. if (thePrefs.GetStatsLastResetLng())
  1756. {
  1757. time_t timeNow;
  1758. time(&timeNow);
  1759. timeDiff = timeNow - thePrefs.GetStatsLastResetLng(); // In seconds
  1760. cbuffer.Format(GetResString(IDS_STATS_TIMESINCERESET), CastSecondsToLngHM(timeDiff));
  1761. }
  1762. else
  1763. {
  1764. timeDiff = 0;
  1765. cbuffer.Format(GetResString(IDS_STATS_TIMESINCERESET), GetResString(IDS_UNKNOWN));
  1766. }
  1767. stattree.SetItemText(tvitime[1], cbuffer);
  1768. // TIME STATISTICS -> SESSION SECTION
  1769. if (forceUpdate || stattree.IsExpanded(htime_s))
  1770. {
  1771. int i = 0;
  1772. // Run Time
  1773. time_t sessionRunTime = (GetTickCount() - theStats.starttime) / 1000;
  1774. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_RUNTIME), CastSecondsToLngHM(sessionRunTime));
  1775. stattree.SetItemText(tvitime_s[i], cbuffer);
  1776. i++;
  1777. if (!sessionRunTime)
  1778. sessionRunTime = 1;
  1779. // Transfer Time
  1780. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_TRANSTIME), CastSecondsToLngHM(theStats.GetTransferTime()), (double) (100 * theStats.GetTransferTime() ) / sessionRunTime);
  1781. stattree.SetItemText(tvitime_s[i], cbuffer);
  1782. if (forceUpdate || stattree.IsExpanded(tvitime_s[i]))
  1783. {
  1784. int x = 0;
  1785. // Upload Time
  1786. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_UPTIME), CastSecondsToLngHM(theStats.GetUploadTime()), (double) (100 * theStats.GetUploadTime()) / sessionRunTime);
  1787. stattree.SetItemText(tvitime_st[x], cbuffer);
  1788. x++;
  1789. // Download Time
  1790. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_DOWNTIME), CastSecondsToLngHM(theStats.GetDownloadTime()), (double) (100 * theStats.GetDownloadTime()) / sessionRunTime);
  1791. stattree.SetItemText(tvitime_st[x], cbuffer);
  1792. x++;
  1793. }
  1794. i++;
  1795. // Current Server Duration
  1796. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_CURRSRVDUR), CastSecondsToLngHM(theStats.time_thisServerDuration), (double) (100 * theStats.time_thisServerDuration) / sessionRunTime);
  1797. stattree.SetItemText(tvitime_s[i], cbuffer);
  1798. i++;
  1799. // Total Server Duration
  1800. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_TOTALSRVDUR), CastSecondsToLngHM(theStats.GetServerDuration()), (double) (100 * theStats.GetServerDuration()) / sessionRunTime);
  1801. stattree.SetItemText(tvitime_s[i], cbuffer);
  1802. i++;
  1803. }
  1804. // TIME STATISTICS -> CUMULATIVE SECTION
  1805. if (forceUpdate || stattree.IsExpanded(htime_t))
  1806. {
  1807. int i = 0;
  1808. // Run Time
  1809. time_t totalRunTime = ((GetTickCount() - theStats.starttime)/1000) + thePrefs.GetConnRunTime();
  1810. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_RUNTIME), CastSecondsToLngHM(totalRunTime));
  1811. stattree.SetItemText(tvitime_t[i], cbuffer);
  1812. i++;
  1813. if (!totalRunTime)
  1814. totalRunTime = 1;
  1815. // Transfer Time
  1816. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_TRANSTIME), CastSecondsToLngHM(theStats.GetTransferTime() + thePrefs.GetConnTransferTime()), (double) (100 * (theStats.GetTransferTime() + thePrefs.GetConnTransferTime())) / totalRunTime);
  1817. stattree.SetItemText(tvitime_t[i], cbuffer);
  1818. if (forceUpdate || stattree.IsExpanded(tvitime_t[i]))
  1819. {
  1820. int x = 0;
  1821. // Upload Time
  1822. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_UPTIME), CastSecondsToLngHM(theStats.GetUploadTime() + thePrefs.GetConnUploadTime()), (double) (100 * (theStats.GetUploadTime() + thePrefs.GetConnUploadTime())) / totalRunTime);
  1823. stattree.SetItemText(tvitime_tt[x], cbuffer);
  1824. x++;;
  1825. // Download Time
  1826. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_DOWNTIME), CastSecondsToLngHM(theStats.GetDownloadTime() + thePrefs.GetConnDownloadTime()), (double) (100 * (theStats.GetDownloadTime() + thePrefs.GetConnDownloadTime())) / totalRunTime);
  1827. stattree.SetItemText(tvitime_tt[x], cbuffer);
  1828. x++;
  1829. }
  1830. i++;
  1831. // Total Server Duration
  1832. cbuffer.Format(_T("%s: %s (%1.1f%%)"), GetResString(IDS_STATS_TOTALSRVDUR), CastSecondsToLngHM(theStats.GetServerDuration() + thePrefs.GetConnServerDuration()), (double) (100 * (theStats.GetServerDuration() + thePrefs.GetConnServerDuration())) / totalRunTime);
  1833. stattree.SetItemText(tvitime_t[i], cbuffer);
  1834. i++;
  1835. }
  1836. // TIME STATISTICS -> PROJECTED AVERAGES SECTION
  1837. if ( (forceUpdate || stattree.IsExpanded(htime_aap)) && timeDiff > 0 )
  1838. {
  1839. double avgModifier[3];
  1840. avgModifier[0] = (double) 86400 / timeDiff; // Days
  1841. avgModifier[1] = (double) 2628000 / timeDiff; // Months
  1842. avgModifier[2] = (double) 31536000 / timeDiff; // Years
  1843. // TIME STATISTICS -> PROJECTED AVERAGES -> TIME PERIODS
  1844. // This section is completely scalable. Might add "Week" to it in the future.
  1845. // For each time period that we are calculating a projected average for...
  1846. for (int mx = 0; mx<3; mx++)
  1847. {
  1848. if (forceUpdate || stattree.IsExpanded(time_aaph[mx]))
  1849. {
  1850. // TIME STATISTICS -> PROJECTED AVERAGES -> TIME PERIOD -> UPLOADS SECTION
  1851. if (forceUpdate || stattree.IsExpanded(time_aap_hup[mx]))
  1852. {
  1853. // Uploaded Data
  1854. cbuffer.Format(GetResString(IDS_STATS_UDATA),CastItoXBytes( ((double)(theStats.sessionSentBytes+thePrefs.GetTotalUploaded()))*avgModifier[mx], false, false));
  1855. stattree.SetItemText(time_aap_up[mx][0],cbuffer);
  1856. if (forceUpdate || stattree.IsExpanded(time_aap_up[mx][0]))
  1857. {
  1858. // Uploaded Data By Client
  1859. if (forceUpdate || stattree.IsExpanded(time_aap_up_hd[mx][0]))
  1860. {
  1861. int i = 0;
  1862. uint64 UpDataTotal = (uint64)(thePrefs.GetUpTotalClientData() * avgModifier[mx]);
  1863. uint64 UpDataClient = (uint64)(thePrefs.GetCumUpData_EMULE() * avgModifier[mx]);
  1864. double percentClientTransferred = 0;
  1865. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1866. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1867. cbuffer.Format( _T("eMule: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ) , percentClientTransferred);
  1868. stattree.SetItemText( time_aap_up_dc[mx][i] , cbuffer );
  1869. i++;
  1870. UpDataClient = (uint64)(thePrefs.GetCumUpData_EDONKEYHYBRID() * avgModifier[mx]);
  1871. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1872. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1873. else
  1874. percentClientTransferred = 0;
  1875. cbuffer.Format( _T("eD Hybrid: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ) , percentClientTransferred );
  1876. stattree.SetItemText( time_aap_up_dc[mx][i] , cbuffer );
  1877. i++;
  1878. UpDataClient = (uint64)(thePrefs.GetCumUpData_EDONKEY() * avgModifier[mx]);
  1879. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1880. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1881. else
  1882. percentClientTransferred = 0;
  1883. cbuffer.Format( _T("eDonkey: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1884. stattree.SetItemText( time_aap_up_dc[mx][i] , cbuffer );
  1885. i++;
  1886. UpDataClient = (uint64)(thePrefs.GetCumUpData_AMULE() * avgModifier[mx]);
  1887. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1888. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1889. else
  1890. percentClientTransferred = 0;
  1891. cbuffer.Format( _T("aMule: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1892. stattree.SetItemText( time_aap_up_dc[mx][i] , cbuffer );
  1893. i++;
  1894. UpDataClient = (uint64)(thePrefs.GetCumUpData_MLDONKEY() * avgModifier[mx]);
  1895. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1896. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1897. else
  1898. percentClientTransferred = 0;
  1899. cbuffer.Format( _T("MLdonkey: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1900. stattree.SetItemText( time_aap_up_dc[mx][i] , cbuffer );
  1901. i++;
  1902. UpDataClient = (uint64)(thePrefs.GetCumUpData_SHAREAZA() * avgModifier[mx]);
  1903. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1904. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1905. else
  1906. percentClientTransferred = 0;
  1907. cbuffer.Format( _T("Shareaza: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1908. stattree.SetItemText( time_aap_up_dc[mx][i] , cbuffer );
  1909. i++;
  1910. UpDataClient = (uint64)(thePrefs.GetCumUpData_EMULECOMPAT() * avgModifier[mx]);
  1911. if ( UpDataTotal!=0 && UpDataClient!=0 )
  1912. percentClientTransferred = (double) 100 * UpDataClient / UpDataTotal;
  1913. else
  1914. percentClientTransferred = 0;
  1915. cbuffer.Format( _T("eM Compat: %s (%1.1f%%)") , CastItoXBytes( UpDataClient, false, false ), percentClientTransferred );
  1916. stattree.SetItemText( time_aap_up_dc[mx][i] , cbuffer );
  1917. i++;
  1918. }
  1919. // Uploaded Data By Port
  1920. if (forceUpdate || stattree.IsExpanded(time_aap_up_hd[mx][1]))
  1921. {
  1922. int i = 0;
  1923. uint64 PortDataDefault = (uint64)(thePrefs.GetCumUpDataPort_4662() * avgModifier[mx]);
  1924. uint64 PortDataOther = (uint64)(thePrefs.GetCumUpDataPort_OTHER() * avgModifier[mx]);
  1925. uint64 PortDataPeerCache = (uint64)(thePrefs.GetCumUpDataPort_PeerCache() * avgModifier[mx]);
  1926. uint64 PortDataTotal = (uint64)( thePrefs.GetUpTotalPortData() * avgModifier[mx]);
  1927. double percentPortTransferred = 0;
  1928. if ( PortDataTotal!=0 && PortDataDefault!=0 )
  1929. percentPortTransferred = (double) 100 * PortDataDefault / PortDataTotal;
  1930. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTDEF) , CastItoXBytes( PortDataDefault, false, false ) , percentPortTransferred);
  1931. stattree.SetItemText( time_aap_up_dp[mx][i] , cbuffer );
  1932. i++;
  1933. if ( PortDataTotal!=0 && PortDataOther!=0 )
  1934. percentPortTransferred = (double) 100 * PortDataOther / PortDataTotal;
  1935. else
  1936. percentPortTransferred = 0;
  1937. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataOther, false, false ) , percentPortTransferred);
  1938. stattree.SetItemText( time_aap_up_dp[mx][i] , cbuffer );
  1939. i++;
  1940. if ( PortDataTotal!=0 && PortDataPeerCache!=0 )
  1941. percentPortTransferred = (double) 100 * PortDataPeerCache / PortDataTotal;
  1942. else
  1943. percentPortTransferred = 0;
  1944. cbuffer.Format( _T("%s: %s (%1.1f%%)") , thePrefs.GetPeerCacheShow() ? _T("PeerCache") : GetResString(IDS_STATS_PRTOTHER) , CastItoXBytes( PortDataPeerCache, false, false ) , percentPortTransferred);
  1945. stattree.SetItemText( time_aap_up_dp[mx][i] , cbuffer );
  1946. i++;
  1947. }
  1948. // Uploaded Data By Source
  1949. if (forceUpdate || stattree.IsExpanded(time_aap_up_hd[mx][2]))
  1950. {
  1951. int i = 0;
  1952. uint64 DataSourceFile = (uint64)(thePrefs.GetCumUpData_File() * avgModifier[mx]);
  1953. uint64 DataSourcePF = (uint64)(thePrefs.GetCumUpData_Partfile() * avgModifier[mx]);
  1954. uint64 DataSourceTotal = (uint64)(thePrefs.GetUpTotalDataFile() * avgModifier[mx]);
  1955. double percentFileTransferred = 0;
  1956. if ( DataSourceTotal!=0 && DataSourceFile!=0 )
  1957. percentFileTransferred = (double) 100 * DataSourceFile / DataSourceTotal;
  1958. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_DSFILE) , CastItoXBytes( DataSourceFile, false, false ) , percentFileTransferred);
  1959. stattree.SetItemText( time_aap_up_ds[mx][i] , cbuffer );
  1960. i++;
  1961. if ( DataSourceTotal!=0 && DataSourcePF!=0 )
  1962. percentFileTransferred = (double) 100 * DataSourcePF / DataSourceTotal;
  1963. else
  1964. percentFileTransferred = 0;
  1965. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_DSPF) , CastItoXBytes( DataSourcePF, false, false ) , percentFileTransferred);
  1966. stattree.SetItemText( time_aap_up_ds[mx][i] , cbuffer );
  1967. i++;
  1968. }
  1969. }
  1970. // Upload Sessions
  1971. uint32 statGoodSessions = (uint32)((theApp.uploadqueue->GetSuccessfullUpCount() + thePrefs.GetUpSuccessfulSessions() + theApp.uploadqueue->GetUploadQueueLength()) * avgModifier[mx]);
  1972. uint32 statBadSessions = (uint32)((theApp.uploadqueue->GetFailedUpCount() + thePrefs.GetUpFailedSessions()) * avgModifier[mx]);
  1973. double percentSessions;
  1974. cbuffer.Format(_T("%s: %u"), GetResString(IDS_STATS_ULSES), statGoodSessions + statBadSessions);
  1975. stattree.SetItemText(time_aap_up[mx][1], cbuffer);
  1976. if (forceUpdate || stattree.IsExpanded(time_aap_up[mx][1]))
  1977. {
  1978. // Set Successful Upload Sessions
  1979. if (statGoodSessions>0)
  1980. percentSessions = (double) 100*statGoodSessions/(statGoodSessions+statBadSessions);
  1981. else
  1982. percentSessions = 0;
  1983. cbuffer.Format(GetResString(IDS_STATS_SUCCUPCOUNT),statGoodSessions,percentSessions);
  1984. stattree.SetItemText(time_aap_up_s[mx][0], cbuffer);
  1985. // Set Failed Upload Sessions
  1986. if (percentSessions != 0 && statBadSessions > 0)
  1987. percentSessions = 100 - percentSessions; // There were some good sessions and bad ones...
  1988. else if (percentSessions == 0 && statBadSessions > 0)
  1989. percentSessions = 100; // There were bad sessions and no good ones, must be 100%
  1990. else
  1991. percentSessions = 0; // No sessions at all, or no bad ones.
  1992. cbuffer.Format(GetResString(IDS_STATS_FAILUPCOUNT),statBadSessions,percentSessions);
  1993. stattree.SetItemText(time_aap_up_s[mx][1], cbuffer);
  1994. }
  1995. // Calculate Upline OH Totals
  1996. uint64 UpOHTotal = (uint64)((theStats.GetUpDataOverheadFileRequest() +
  1997. theStats.GetUpDataOverheadSourceExchange() +
  1998. theStats.GetUpDataOverheadServer() +
  1999. theStats.GetUpDataOverheadKad() +
  2000. theStats.GetUpDataOverheadOther()
  2001. ) * avgModifier[mx]);
  2002. uint64 UpOHTotalPackets = (uint64)((theStats.GetUpDataOverheadFileRequestPackets() +
  2003. theStats.GetUpDataOverheadSourceExchangePackets() +
  2004. theStats.GetUpDataOverheadServerPackets() +
  2005. theStats.GetUpDataOverheadKadPackets() +
  2006. theStats.GetUpDataOverheadOtherPackets()
  2007. ) * avgModifier[mx]);
  2008. // Set Cumulative Total Overhead
  2009. cbuffer.Format(GetResString(IDS_TOVERHEAD),CastItoXBytes(UpOHTotal + ((uint64)thePrefs.GetUpOverheadTotal() * avgModifier[mx]), false, false), CastItoIShort((uint64)(UpOHTotalPackets + ((uint64)thePrefs.GetUpOverheadTotalPackets() * avgModifier[mx]))));
  2010. stattree.SetItemText(time_aap_up[mx][2], cbuffer);
  2011. if (forceUpdate || stattree.IsExpanded(time_aap_up[mx][2]))
  2012. {
  2013. int i = 0;
  2014. // Set up total file req OH
  2015. cbuffer.Format(GetResString(IDS_FROVERHEAD), CastItoXBytes( (uint64)(theStats.GetUpDataOverheadFileRequest() + thePrefs.GetUpOverheadFileReq()) * avgModifier[mx], false, false), CastItoIShort( (uint64)(theStats.GetUpDataOverheadFileRequestPackets() + thePrefs.GetUpOverheadFileReqPackets()) * avgModifier[mx]));
  2016. stattree.SetItemText(time_aap_up_oh[mx][i], cbuffer);
  2017. i++;
  2018. // Set up total source exch OH
  2019. cbuffer.Format(GetResString(IDS_SSOVERHEAD), CastItoXBytes( (uint64)(theStats.GetUpDataOverheadSourceExchange()+thePrefs.GetUpOverheadSrcEx()) * avgModifier[mx], false, false), CastItoIShort( (uint64)(theStats.GetUpDataOverheadSourceExchangePackets()+thePrefs.GetUpOverheadSrcExPackets()) * avgModifier[mx]));
  2020. stattree.SetItemText(time_aap_up_oh[mx][i], cbuffer);
  2021. i++;
  2022. // Set up total server OH
  2023. cbuffer.Format(GetResString(IDS_SOVERHEAD),
  2024. CastItoXBytes((theStats.GetUpDataOverheadServer() +
  2025. thePrefs.GetUpOverheadServer()
  2026. ) * avgModifier[mx], false, false),
  2027. CastItoIShort((uint64)(theStats.GetUpDataOverheadServerPackets() +
  2028. thePrefs.GetUpOverheadServerPackets()
  2029. ) * avgModifier[mx]));
  2030. stattree.SetItemText(time_aap_up_oh[mx][i], cbuffer);
  2031. i++;
  2032. // Set up total Kad OH
  2033. cbuffer.Format(GetResString(IDS_KADOVERHEAD),
  2034. CastItoXBytes((uint64)(theStats.GetUpDataOverheadKad() +
  2035. thePrefs.GetUpOverheadKad()
  2036. ) * avgModifier[mx], false, false),
  2037. CastItoIShort((uint64)(theStats.GetUpDataOverheadKadPackets() +
  2038. thePrefs.GetUpOverheadKadPackets()
  2039. ) * avgModifier[mx]));
  2040. stattree.SetItemText(time_aap_up_oh[mx][i], cbuffer);
  2041. i++;
  2042. }
  2043. } // - End Time Statistics -> Projected Averages -> Time Period -> Uploads Section
  2044. // TIME STATISTICS -> PROJECTED AVERAGES -> TIME PERIOD -> DOWNLOADS SECTION
  2045. if (forceUpdate || stattree.IsExpanded(time_aap_hdown[mx]))
  2046. {
  2047. CDownloadQueue::SDownloadStats myStats;
  2048. theApp.downloadqueue->GetDownloadSourcesStats(myStats);
  2049. // Downloaded Data
  2050. cbuffer.Format(GetResString(IDS_STATS_DDATA),CastItoXBytes( (uint64)(theStats.sessionReceivedBytes+thePrefs.GetTotalDownloaded()) * avgModifier[mx], false, false ));
  2051. stattree.SetItemText(time_aap_down[mx][0], cbuffer);
  2052. if (forceUpdate || stattree.IsExpanded(time_aap_down[mx][0]))
  2053. {
  2054. // Downloaded Data By Client
  2055. if (forceUpdate || stattree.IsExpanded(time_aap_down_hd[mx][0]))
  2056. {
  2057. int i = 0;
  2058. uint64 DownDataTotal = (uint64)(thePrefs.GetDownTotalClientData() * avgModifier[mx]);
  2059. uint64 DownDataClient = (uint64)(thePrefs.GetCumDownData_EMULE() * avgModifier[mx]);
  2060. double percentClientTransferred = 0;
  2061. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2062. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2063. cbuffer.Format( _T("eMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ) , percentClientTransferred);
  2064. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2065. i++;
  2066. DownDataClient = (uint64)(thePrefs.GetCumDownData_EDONKEYHYBRID() * avgModifier[mx]);
  2067. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2068. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2069. else
  2070. percentClientTransferred = 0;
  2071. cbuffer.Format( _T("eD Hybrid: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ) , percentClientTransferred );
  2072. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2073. i++;
  2074. DownDataClient = (uint64)(thePrefs.GetCumDownData_EDONKEY() * avgModifier[mx]);
  2075. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2076. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2077. else
  2078. percentClientTransferred = 0;
  2079. cbuffer.Format( _T("eDonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  2080. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2081. i++;
  2082. DownDataClient = (uint64)(thePrefs.GetCumDownData_AMULE() * avgModifier[mx]);
  2083. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2084. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2085. else
  2086. percentClientTransferred = 0;
  2087. cbuffer.Format( _T("aMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  2088. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2089. i++;
  2090. DownDataClient = (uint64)(thePrefs.GetCumDownData_MLDONKEY() * avgModifier[mx]);
  2091. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2092. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2093. else
  2094. percentClientTransferred = 0;
  2095. cbuffer.Format( _T("MLdonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  2096. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2097. i++;
  2098. DownDataClient = (uint64)(thePrefs.GetCumDownData_SHAREAZA() * avgModifier[mx]);
  2099. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2100. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2101. else
  2102. percentClientTransferred = 0;
  2103. cbuffer.Format( _T("Shareaza: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  2104. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2105. i++;
  2106. DownDataClient = (uint64)(thePrefs.GetCumDownData_EMULECOMPAT() * avgModifier[mx]);
  2107. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2108. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2109. else
  2110. percentClientTransferred = 0;
  2111. cbuffer.Format( _T("eM Compat: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  2112. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2113. i++;
  2114. DownDataClient = (uint64)(thePrefs.GetCumDownData_URL() * avgModifier[mx]);
  2115. if ( DownDataTotal!=0 && DownDataClient!=0 )
  2116. percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
  2117. else
  2118. percentClientTransferred = 0;
  2119. cbuffer.Format( _T("URL: %s (%1.1f%%)") , CastItoXBytes( DownDataClient, false, false ), percentClientTransferred );
  2120. stattree.SetItemText( time_aap_down_dc[mx][i] , cbuffer );
  2121. i++;
  2122. }
  2123. // Downloaded Data By Port
  2124. if (forceUpdate || stattree.IsExpanded(time_aap_down_hd[mx][1]))
  2125. {
  2126. int i = 0;
  2127. uint64 PortDataDefault = (uint64)(thePrefs.GetCumDownDataPort_4662() * avgModifier[mx]);
  2128. uint64 PortDataOther = (uint64)(thePrefs.GetCumDownDataPort_OTHER() * avgModifier[mx]);
  2129. uint64 PortDataPeerCache = (uint64)(thePrefs.GetCumDownDataPort_PeerCache() * avgModifier[mx]);
  2130. uint64 PortDataTotal = (uint64)(thePrefs.GetDownTotalPortData() * avgModifier[mx]);
  2131. double percentPortTransferred = 0;
  2132. if ( PortDataTotal!=0 && PortDataDefault!=0 )
  2133. percentPortTransferred = (double) 100 * PortDataDefault / PortDataTotal;
  2134. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTDEF) , CastItoXBytes( PortDataDefault, false, false ) , percentPortTransferred);
  2135. stattree.SetItemText( time_aap_down_dp[mx][i] , cbuffer );
  2136. i++;
  2137. if ( PortDataTotal!=0 && PortDataOther!=0 )
  2138. percentPortTransferred = (double) 100 * PortDataOther / PortDataTotal;
  2139. else
  2140. percentPortTransferred = 0;
  2141. cbuffer.Format( _T("%s: %s (%1.1f%%)") , GetResString(IDS_STATS_PRTOTHER), CastItoXBytes( PortDataOther, false, false ) , percentPortTransferred);
  2142. stattree.SetItemText( time_aap_down_dp[mx][i] , cbuffer );
  2143. i++;
  2144. if ( PortDataTotal!=0 && PortDataPeerCache!=0 )
  2145. percentPortTransferred = (double) 100 * PortDataPeerCache / PortDataTotal;
  2146. else
  2147. percentPortTransferred = 0;
  2148. cbuffer.Format( _T("%s: %s (%1.1f%%)") , thePrefs.GetPeerCacheShow() ? _T("PeerCache") : GetResString(IDS_STATS_PRTOTHER), CastItoXBytes( PortDataPeerCache, false, false ) , percentPortTransferred);
  2149. stattree.SetItemText( time_aap_down_dp[mx][i] , cbuffer );
  2150. i++;
  2151. }
  2152. }
  2153. // Set Cum Completed Downloads
  2154. cbuffer.Format(_T("%s: %I64u"), GetResString(IDS_STATS_COMPDL), (uint64) (thePrefs.GetDownCompletedFiles() * avgModifier[mx]) );
  2155. stattree.SetItemText(time_aap_down[mx][1], cbuffer);
  2156. // Set Cum Download Sessions
  2157. uint32 statGoodSessions = (uint32)((thePrefs.GetDownC_SuccessfulSessions() + myStats.a[1]) * avgModifier[mx]);
  2158. uint32 statBadSessions = (uint32)(thePrefs.GetDownC_FailedSessions() * avgModifier[mx]);
  2159. double percentSessions;
  2160. cbuffer.Format(_T("%s: %u"), GetResString(IDS_STATS_DLSES), statGoodSessions+statBadSessions );
  2161. stattree.SetItemText(time_aap_down[mx][2], cbuffer);
  2162. if (forceUpdate || stattree.IsExpanded(time_aap_down[mx][2]))
  2163. {
  2164. // Set Cum Successful Download Sessions
  2165. if (statGoodSessions > 0)
  2166. percentSessions = (double) 100 * statGoodSessions / (statGoodSessions + statBadSessions);
  2167. else
  2168. percentSessions = 0;
  2169. cbuffer.Format( _T("%s: %u (%1.1f%%)"), GetResString(IDS_STATS_SDLSES) , statGoodSessions , percentSessions );
  2170. stattree.SetItemText( time_aap_down_s[mx][0] , cbuffer ); // Set Successful Sessions
  2171. // Set Cum Failed Download Sessions
  2172. if (percentSessions != 0 && statBadSessions > 0)
  2173. percentSessions = 100 - percentSessions; // There were some good sessions and bad ones...
  2174. else if (percentSessions == 0 && statBadSessions > 0)
  2175. percentSessions = 100; // There were bad sessions and no good ones, must be 100%
  2176. else
  2177. percentSessions = 0; // No sessions at all, or no bad ones.
  2178. cbuffer.Format( _T("%s: %u (%1.1f%%)") , GetResString(IDS_STATS_FDLSES) , statBadSessions , percentSessions);
  2179. stattree.SetItemText( time_aap_down_s[mx][1] , cbuffer );
  2180. }
  2181. // Set Cumulative Gained Due To Compression
  2182. cbuffer.Format( GetResString( IDS_STATS_GAINCOMP ) , CastItoXBytes( (uint64)(thePrefs.GetSesSavedFromCompression()+ thePrefs.GetCumSavedFromCompression()) * avgModifier[mx], false, false ) );
  2183. stattree.SetItemText( time_aap_down[mx][3] , cbuffer );
  2184. // Set Cumulative Lost Due To Corruption
  2185. cbuffer.Format( GetResString( IDS_STATS_LOSTCORRUPT ) , CastItoXBytes( (uint64)(thePrefs.GetSesLostFromCorruption() + thePrefs.GetCumLostFromCorruption()) * avgModifier[mx], false, false ) );
  2186. stattree.SetItemText( time_aap_down[mx][4] , cbuffer );
  2187. // Set Cumulative Saved Due To ICH
  2188. cbuffer.Format(GetResString(IDS_STATS_ICHSAVED), (uint32)((thePrefs.GetSesPartsSavedByICH() + thePrefs.GetCumPartsSavedByICH()) * avgModifier[mx]));
  2189. stattree.SetItemText( time_aap_down[mx][5] , cbuffer );
  2190. uint64 DownOHTotal = theStats.GetDownDataOverheadFileRequest() +
  2191. theStats.GetDownDataOverheadSourceExchange() +
  2192. theStats.GetDownDataOverheadServer() +
  2193. theStats.GetDownDataOverheadKad() +
  2194. theStats.GetDownDataOverheadOther();
  2195. uint64 DownOHTotalPackets =
  2196. theStats.GetDownDataOverheadFileRequestPackets() +
  2197. theStats.GetDownDataOverheadSourceExchangePackets() +
  2198. theStats.GetDownDataOverheadServerPackets() +
  2199. theStats.GetDownDataOverheadKadPackets() +
  2200. theStats.GetDownDataOverheadOtherPackets();
  2201. // Total Overhead
  2202. cbuffer.Format(GetResString(IDS_TOVERHEAD),CastItoXBytes( (uint64)(DownOHTotal + thePrefs.GetDownOverheadTotal()) * avgModifier[mx], false, false), CastItoIShort((uint64)(DownOHTotalPackets + thePrefs.GetDownOverheadTotalPackets()) * avgModifier[mx]));
  2203. stattree.SetItemText(time_aap_down[mx][6], cbuffer);
  2204. if (forceUpdate || stattree.IsExpanded(time_aap_down[mx][6]))
  2205. {
  2206. int i = 0;
  2207. // File Request Overhead
  2208. cbuffer.Format(GetResString(IDS_FROVERHEAD), CastItoXBytes( (uint64)(theStats.GetDownDataOverheadFileRequest() + thePrefs.GetDownOverheadFileReq()) * avgModifier[mx], false, false), CastItoIShort((uint64)(theStats.GetDownDataOverheadFileRequestPackets() + thePrefs.GetDownOverheadFileReqPackets()) * avgModifier[mx]));
  2209. stattree.SetItemText(time_aap_down_oh[mx][i], cbuffer);
  2210. i++;
  2211. // Source Exchange Overhead
  2212. cbuffer.Format(GetResString(IDS_SSOVERHEAD), CastItoXBytes( (uint64)(theStats.GetDownDataOverheadSourceExchange()+thePrefs.GetDownOverheadSrcEx()) * avgModifier[mx], false, false), CastItoIShort((uint64)(theStats.GetDownDataOverheadSourceExchangePackets()+thePrefs.GetDownOverheadSrcExPackets()) * avgModifier[mx]));
  2213. stattree.SetItemText(time_aap_down_oh[mx][i], cbuffer);
  2214. i++;
  2215. // Server Overhead
  2216. cbuffer.Format(GetResString(IDS_SOVERHEAD),
  2217. CastItoXBytes((uint64)(theStats.GetDownDataOverheadServer() +
  2218. thePrefs.GetDownOverheadServer()) * avgModifier[mx], false, false),
  2219. CastItoIShort((uint64)(theStats.GetDownDataOverheadServerPackets() +
  2220. thePrefs.GetDownOverheadServerPackets()) * avgModifier[mx]));
  2221. stattree.SetItemText(time_aap_down_oh[mx][i], cbuffer);
  2222. i++;
  2223. // Kad Overhead
  2224. cbuffer.Format(GetResString(IDS_KADOVERHEAD),
  2225. CastItoXBytes((uint64)(theStats.GetDownDataOverheadKad() +
  2226. thePrefs.GetDownOverheadKad()
  2227. ) * avgModifier[mx], false, false),
  2228. CastItoIShort((uint64)(theStats.GetDownDataOverheadKadPackets() +
  2229. thePrefs.GetDownOverheadKadPackets()
  2230. ) * avgModifier[mx]));
  2231. stattree.SetItemText(time_aap_down_oh[mx][i], cbuffer);
  2232. i++;
  2233. }
  2234. } // - End Time Statistics -> Projected Averages -> Time Period -> Downloads Section
  2235. } // - End Time Statistics -> Projected Averages -> Time Period Sections
  2236. } // - End Time Statistics -> Projected Averages Section
  2237. } // - End Time Statistics -> Projected Averages Section Loop
  2238. } // - END TIME STATISTICS SECTION
  2239. // CLIENTS SECTION
  2240. // Note: This section now has dynamic tree items. This technique
  2241. // may appear in other areas, however, there is usually an
  2242. // advantage to displaying 0 datems. Here, with the ver-
  2243. // sions being displayed the way they are, it makes sense.
  2244. // Who wants to stare at totally blank tree items? ;)
  2245. if (forceUpdate || stattree.IsExpanded(h_clients))
  2246. {
  2247. CMap<uint32, uint32, uint32, uint32> clientVersionEDonkey;
  2248. CMap<uint32, uint32, uint32, uint32> clientVersionEDonkeyHybrid;
  2249. CMap<uint32, uint32, uint32, uint32> clientVersionEMule;
  2250. CMap<uint32, uint32, uint32, uint32> clientVersionAMule;
  2251. uint32 totalclient;
  2252. int myStats[NUM_CLIENTLIST_STATS];
  2253. theApp.clientlist->GetStatistics(totalclient, myStats,
  2254. clientVersionEDonkey,
  2255. clientVersionEDonkeyHybrid,
  2256. clientVersionEMule,
  2257. clientVersionAMule);
  2258. cbuffer.Format(_T("%s: %u "), GetResString(IDS_CLIENTLIST), totalclient);
  2259. stattree.SetItemText(cligen[5], cbuffer);
  2260. int SIclients=myStats[12]+myStats[13];
  2261. cbuffer.Format(_T("%s: %u (%.1f%%) : %u (%.1f%%)"), GetResString(IDS_STATS_SECUREIDENT), myStats[12] , (SIclients>0)?((double)100*myStats[12] / SIclients):0, myStats[13] , (SIclients>0)?((double)100*myStats[13] / SIclients ):0);
  2262. stattree.SetItemText(cligen[3], cbuffer);
  2263. cbuffer.Format(_T("%s: %u (%.1f%%)"), GetResString(IDS_IDLOW), myStats[14] , (totalclient>0)?((double)100*myStats[14] / totalclient):0);
  2264. stattree.SetItemText(cligen[4], cbuffer);
  2265. if( !totalclient )
  2266. totalclient = 1;
  2267. // CLIENTS -> CLIENT SOFTWARE SECTION
  2268. if (forceUpdate || stattree.IsExpanded(hclisoft))
  2269. {
  2270. cbuffer.Format(_T("eMule: %i (%1.1f%%)"), myStats[ 2],(double)100*myStats[ 2]/totalclient);stattree.SetItemText(clisoft[0], cbuffer);
  2271. cbuffer.Format(_T("eD Hybrid: %i (%1.1f%%)"), myStats[ 4],(double)100*myStats[ 4]/totalclient);stattree.SetItemText(clisoft[1], cbuffer);
  2272. cbuffer.Format(_T("eDonkey: %i (%1.1f%%)"), myStats[ 1],(double)100*myStats[ 1]/totalclient);stattree.SetItemText(clisoft[2], cbuffer);
  2273. cbuffer.Format(_T("aMule: %i (%1.1f%%)"), myStats[10],(double)100*myStats[10]/totalclient);stattree.SetItemText(clisoft[3], cbuffer);
  2274. cbuffer.Format(_T("MLdonkey: %i (%1.1f%%)"), myStats[ 3],(double)100*myStats[ 3]/totalclient);stattree.SetItemText(clisoft[4], cbuffer);
  2275. cbuffer.Format(_T("Shareaza: %i (%1.1f%%)"), myStats[11],(double)100*myStats[11]/totalclient);stattree.SetItemText(clisoft[5], cbuffer);
  2276. cbuffer.Format(_T("eM Compat: %i (%1.1f%%)"), myStats[ 5],(double)100*myStats[ 5]/totalclient);stattree.SetItemText(clisoft[6], cbuffer);
  2277. cbuffer.Format(GetResString(IDS_STATS_UNKNOWNCLIENT)+_T(" (%1.1f%%)"),myStats[0] , (double)100*myStats[0]/totalclient);stattree.SetItemText(clisoft[7], cbuffer);
  2278. // CLIENTS -> CLIENT SOFTWARE -> EMULE SECTION
  2279. if (forceUpdate || stattree.IsExpanded(clisoft[0]) || cli_lastCount[0] == 0)
  2280. {
  2281. uint32 verCount = 0;
  2282. //--- find top 4 eMule client versions ---
  2283. uint32 currtopcnt = 0;
  2284. uint32 currtopver = 0;
  2285. uint32 totalOther = 0;
  2286. for (uint32 i = 0; i < MAX_SUB_CLIENT_VERSIONS; i++)
  2287. {
  2288. POSITION pos = clientVersionEMule.GetStartPosition();
  2289. uint32 topver = 0;
  2290. uint32 topcnt = 0;
  2291. double topper = 0.0;
  2292. while (pos)
  2293. {
  2294. uint32 ver;
  2295. uint32 cnt;
  2296. clientVersionEMule.GetNextAssoc(pos, ver, cnt);
  2297. if (currtopcnt < cnt)
  2298. {
  2299. topper = (double)cnt/myStats[2];
  2300. topver = ver;
  2301. topcnt = cnt;
  2302. currtopcnt = cnt;
  2303. currtopver = ver;
  2304. }
  2305. else if (currtopcnt == cnt && currtopver < ver)
  2306. {
  2307. topver = ver;
  2308. currtopver = ver;
  2309. }
  2310. }
  2311. currtopcnt = 0;
  2312. currtopver = 0;
  2313. clientVersionEMule.RemoveKey(topver);
  2314. if (topcnt)
  2315. {
  2316. UINT verMaj = topver/(100*10*100);
  2317. UINT verMin = (topver - (verMaj*100*10*100))/(100*10);
  2318. UINT verUp = (topver - (verMaj*100*10*100) - (verMin*100*10))/(100);
  2319. if (topver >= MAKE_CLIENT_VERSION(0,40,0) || verUp != 0)
  2320. {
  2321. if (verUp < 26)
  2322. cbuffer.Format(_T("v%u.%u%c: %i (%1.1f%%)"), verMaj, verMin, _T('a') + verUp, topcnt, topper*100);
  2323. else
  2324. cbuffer.Format(_T("v%u.%u.%u: %i (%1.1f%%)"), verMaj, verMin, verUp, topcnt, topper*100);
  2325. }
  2326. else
  2327. cbuffer.Format(_T("v%u.%u: %i (%1.1f%%)"), verMaj, verMin, topcnt, topper*100);
  2328. }
  2329. else
  2330. continue;
  2331. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2332. totalOther += topcnt;
  2333. if (i >= cli_lastCount[0])
  2334. {
  2335. if (i == MAX_SUB_CLIENT_VERSIONS/2)
  2336. cli_other[0] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), clisoft[0]);
  2337. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2338. cli_versions[MAX_SUB_CLIENT_VERSIONS*0+i] = stattree.InsertItem(cbuffer, cli_other[0]);
  2339. else
  2340. cli_versions[MAX_SUB_CLIENT_VERSIONS*0+i] = stattree.InsertItem(cbuffer, clisoft[0]);
  2341. }
  2342. else
  2343. stattree.SetItemText(cli_versions[MAX_SUB_CLIENT_VERSIONS*0+i], cbuffer);
  2344. verCount++;
  2345. }
  2346. if (verCount > MAX_SUB_CLIENT_VERSIONS/2)
  2347. {
  2348. cbuffer.Format(_T("%s: %i (%1.1f%%)"), GetResString(IDS_STATS_MINORCLIENTS), totalOther, (double)100 * totalOther / myStats[2]);
  2349. stattree.SetItemText(cli_other[0], cbuffer);
  2350. }
  2351. if (verCount < cli_lastCount[0])
  2352. {
  2353. for (uint32 i = 0; i < cli_lastCount[0] - verCount; i++)
  2354. {
  2355. stattree.DeleteItem(cli_versions[cli_lastCount[0] + (MAX_SUB_CLIENT_VERSIONS*0-1) - i]);
  2356. if (cli_lastCount[0] + (MAX_SUB_CLIENT_VERSIONS*0-1) - i == MAX_SUB_CLIENT_VERSIONS/2)
  2357. stattree.DeleteItem(cli_other[0]);
  2358. }
  2359. }
  2360. cli_lastCount[0] = verCount;
  2361. } // End Clients -> Client Software -> eMule Section
  2362. // CLIENTS -> CLIENT SOFTWARE -> eD HYBRID SECTION
  2363. if (forceUpdate || stattree.IsExpanded(clisoft[1]) || cli_lastCount[1] == 0)
  2364. {
  2365. uint32 verCount = 0;
  2366. //--- find top 4 eD Hybrid client versions ---
  2367. uint32 currtopcnt = 0;
  2368. uint32 currtopver = 0;
  2369. uint32 totalOther = 0;
  2370. for (uint32 i = 0; i < MAX_SUB_CLIENT_VERSIONS; i++)
  2371. {
  2372. POSITION pos = clientVersionEDonkeyHybrid.GetStartPosition();
  2373. uint32 topver = 0;
  2374. uint32 topcnt = 0;
  2375. double topper = 0.0;
  2376. while (pos)
  2377. {
  2378. uint32 ver;
  2379. uint32 cnt;
  2380. clientVersionEDonkeyHybrid.GetNextAssoc(pos, ver, cnt);
  2381. if (currtopcnt < cnt)
  2382. {
  2383. topper = (double)cnt/myStats[4];
  2384. topver = ver;
  2385. topcnt = cnt;
  2386. currtopcnt = cnt;
  2387. currtopver = ver;
  2388. }
  2389. else if (currtopcnt == cnt && currtopver < ver)
  2390. {
  2391. topver = ver;
  2392. currtopver = ver;
  2393. }
  2394. }
  2395. currtopcnt = 0;
  2396. currtopver = 0;
  2397. clientVersionEDonkeyHybrid.RemoveKey(topver);
  2398. if (topcnt)
  2399. {
  2400. UINT verMaj = topver/(100*10*100);
  2401. UINT verMin = (topver - (verMaj*100*10*100))/(100*10);
  2402. UINT verUp = (topver - (verMaj*100*10*100) - (verMin*100*10))/(100);
  2403. cbuffer.Format(_T("v%u.%u.%u: %i (%1.1f%%)"), verMaj, verMin, verUp, topcnt, topper*100);
  2404. }
  2405. else
  2406. continue;
  2407. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2408. totalOther += topcnt;
  2409. if (i >= cli_lastCount[1])
  2410. {
  2411. if (i == MAX_SUB_CLIENT_VERSIONS/2)
  2412. cli_other[1] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), clisoft[1]);
  2413. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2414. cli_versions[MAX_SUB_CLIENT_VERSIONS*1+i] = stattree.InsertItem(cbuffer, cli_other[1]);
  2415. else
  2416. cli_versions[MAX_SUB_CLIENT_VERSIONS*1+i] = stattree.InsertItem(cbuffer, clisoft[1]);
  2417. }
  2418. else
  2419. stattree.SetItemText(cli_versions[MAX_SUB_CLIENT_VERSIONS*1+i], cbuffer);
  2420. verCount++;
  2421. }
  2422. if (verCount > MAX_SUB_CLIENT_VERSIONS/2)
  2423. {
  2424. cbuffer.Format(_T("%s: %i (%1.1f%%)"), GetResString(IDS_STATS_MINORCLIENTS), totalOther, (double)100 * totalOther / myStats[4]);
  2425. stattree.SetItemText(cli_other[1], cbuffer);
  2426. }
  2427. if (verCount < cli_lastCount[1])
  2428. {
  2429. for (uint32 i = 0; i < cli_lastCount[1] - verCount; i++)
  2430. {
  2431. stattree.DeleteItem(cli_versions[cli_lastCount[1] + (MAX_SUB_CLIENT_VERSIONS*1-1) - i]);
  2432. if (cli_lastCount[1] + (MAX_SUB_CLIENT_VERSIONS*1-1) - i == MAX_SUB_CLIENT_VERSIONS/2)
  2433. stattree.DeleteItem(cli_other[1]);
  2434. }
  2435. }
  2436. cli_lastCount[1] = verCount;
  2437. } // End Clients -> Client Software -> eD Hybrid Section
  2438. // CLIENTS -> CLIENT SOFTWARE -> EDONKEY SECTION
  2439. if (forceUpdate || stattree.IsExpanded(clisoft[2]) || cli_lastCount[2] == 0)
  2440. {
  2441. uint32 verCount = 0;
  2442. //--- find top 4 eDonkey client versions ---
  2443. uint32 currtopcnt = 0;
  2444. uint32 currtopver = 0;
  2445. uint32 totalOther = 0;
  2446. for (uint32 i = 0; i < MAX_SUB_CLIENT_VERSIONS; i++)
  2447. {
  2448. POSITION pos = clientVersionEDonkey.GetStartPosition();
  2449. uint32 topver = 0;
  2450. uint32 topcnt = 0;
  2451. double topper = 0.0;
  2452. while (pos)
  2453. {
  2454. uint32 ver;
  2455. uint32 cnt;
  2456. clientVersionEDonkey.GetNextAssoc(pos, ver, cnt);
  2457. if (currtopcnt < cnt)
  2458. {
  2459. topper = (double)cnt/myStats[1];
  2460. topver = ver;
  2461. topcnt = cnt;
  2462. currtopcnt = cnt;
  2463. currtopver = ver;
  2464. }
  2465. else if (currtopcnt == cnt && currtopver < ver)
  2466. {
  2467. topver = ver;
  2468. currtopver = ver;
  2469. }
  2470. }
  2471. currtopcnt = 0;
  2472. currtopver = 0;
  2473. clientVersionEDonkey.RemoveKey(topver);
  2474. if (topcnt)
  2475. {
  2476. UINT verMaj = topver/(100*10*100);
  2477. UINT verMin = (topver - (verMaj*100*10*100))/(100*10);
  2478. UINT verUp = (topver - (verMaj*100*10*100) - (verMin*100*10))/(100);
  2479. cbuffer.Format(_T("v%u.%u.%u: %i (%1.1f%%)"), verMaj, verMin, verUp, topcnt, topper*100);
  2480. }
  2481. else
  2482. continue;
  2483. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2484. totalOther += topcnt;
  2485. if (i >= cli_lastCount[2])
  2486. {
  2487. if (i == MAX_SUB_CLIENT_VERSIONS/2)
  2488. cli_other[2] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), clisoft[2]);
  2489. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2490. cli_versions[MAX_SUB_CLIENT_VERSIONS*2+i] = stattree.InsertItem(cbuffer, cli_other[2]);
  2491. else
  2492. cli_versions[MAX_SUB_CLIENT_VERSIONS*2+i] = stattree.InsertItem(cbuffer, clisoft[2]);
  2493. }
  2494. else
  2495. stattree.SetItemText(cli_versions[MAX_SUB_CLIENT_VERSIONS*2+i], cbuffer);
  2496. verCount++;
  2497. }
  2498. if (verCount > MAX_SUB_CLIENT_VERSIONS/2)
  2499. {
  2500. cbuffer.Format(_T("%s: %i (%1.1f%%)"), GetResString(IDS_STATS_MINORCLIENTS), totalOther, (double)100 * totalOther / myStats[1]);
  2501. stattree.SetItemText(cli_other[2], cbuffer);
  2502. }
  2503. if (verCount < cli_lastCount[2])
  2504. {
  2505. for (uint32 i = 0; i < cli_lastCount[2] - verCount; i++)
  2506. {
  2507. stattree.DeleteItem(cli_versions[cli_lastCount[2] + (MAX_SUB_CLIENT_VERSIONS*2-1) - i]);
  2508. if (cli_lastCount[2] + (MAX_SUB_CLIENT_VERSIONS*2-1) - i == MAX_SUB_CLIENT_VERSIONS/2)
  2509. stattree.DeleteItem(cli_other[2]);
  2510. }
  2511. }
  2512. cli_lastCount[2] = verCount;
  2513. } // End Clients -> Client Software -> eDonkey Section
  2514. // CLIENTS -> CLIENT SOFTWARE -> AMULE SECTION
  2515. if (forceUpdate || stattree.IsExpanded(clisoft[3]) || cli_lastCount[3] == 0)
  2516. {
  2517. uint32 verCount = 0;
  2518. //--- find top 4 client versions ---
  2519. uint32 currtopcnt = 0;
  2520. uint32 currtopver = 0;
  2521. uint32 totalOther = 0;
  2522. for (uint32 i = 0; i < MAX_SUB_CLIENT_VERSIONS; i++)
  2523. {
  2524. POSITION pos = clientVersionAMule.GetStartPosition();
  2525. uint32 topver = 0;
  2526. uint32 topcnt = 0;
  2527. double topper = 0.0;
  2528. while (pos)
  2529. {
  2530. uint32 ver;
  2531. uint32 cnt;
  2532. clientVersionAMule.GetNextAssoc(pos, ver, cnt);
  2533. if (currtopcnt < cnt)
  2534. {
  2535. topper = (double)cnt/myStats[10];
  2536. topver = ver;
  2537. topcnt = cnt;
  2538. currtopcnt = cnt;
  2539. currtopver = ver;
  2540. }
  2541. else if (currtopcnt == cnt && currtopver < ver)
  2542. {
  2543. topver = ver;
  2544. currtopver = ver;
  2545. }
  2546. }
  2547. currtopcnt = 0;
  2548. currtopver = 0;
  2549. clientVersionAMule.RemoveKey(topver);
  2550. if (topcnt)
  2551. {
  2552. UINT verMaj = topver/(100*10*100);
  2553. UINT verMin = (topver - (verMaj*100*10*100))/(100*10);
  2554. UINT verUp = (topver - (verMaj*100*10*100) - (verMin*100*10))/(100);
  2555. if (topver >= MAKE_CLIENT_VERSION(0,40,0) || verUp != 0)
  2556. cbuffer.Format(_T("v%u.%u.%u: %i (%1.1f%%)"), verMaj, verMin, verUp, topcnt, topper*100);
  2557. else
  2558. cbuffer.Format(_T("v%u.%u: %i (%1.1f%%)"), verMaj, verMin, topcnt, topper*100);
  2559. }
  2560. else
  2561. continue;
  2562. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2563. totalOther += topcnt;
  2564. if (i >= cli_lastCount[3])
  2565. {
  2566. if (i == MAX_SUB_CLIENT_VERSIONS/2)
  2567. cli_other[3] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), clisoft[3]);
  2568. if (i >= MAX_SUB_CLIENT_VERSIONS/2)
  2569. cli_versions[MAX_SUB_CLIENT_VERSIONS*3+i] = stattree.InsertItem(cbuffer, cli_other[3]);
  2570. else
  2571. cli_versions[MAX_SUB_CLIENT_VERSIONS*3+i] = stattree.InsertItem(cbuffer, clisoft[3]);
  2572. }
  2573. else
  2574. stattree.SetItemText(cli_versions[MAX_SUB_CLIENT_VERSIONS*3+i], cbuffer);
  2575. verCount++;
  2576. }
  2577. if (verCount > MAX_SUB_CLIENT_VERSIONS/2)
  2578. {
  2579. cbuffer.Format(_T("%s: %i (%1.1f%%)"), GetResString(IDS_STATS_MINORCLIENTS), totalOther, (double)100 * totalOther / myStats[10]);
  2580. stattree.SetItemText(cli_other[3], cbuffer);
  2581. }
  2582. if (verCount < cli_lastCount[3])
  2583. {
  2584. for (uint32 i = 0; i < cli_lastCount[3] - verCount; i++)
  2585. {
  2586. stattree.DeleteItem(cli_versions[cli_lastCount[3] + (MAX_SUB_CLIENT_VERSIONS*3-1) - i]);
  2587. if (cli_lastCount[3] + (MAX_SUB_CLIENT_VERSIONS*3-1) - i == MAX_SUB_CLIENT_VERSIONS/2)
  2588. stattree.DeleteItem(cli_other[3]);
  2589. }
  2590. }
  2591. cli_lastCount[3] = verCount;
  2592. } // End Clients -> Client Software -> aMule Section
  2593. } // - End Clients -> Client Software Section
  2594. // CLIENTS -> NETWORK SECTION
  2595. if (forceUpdate || stattree.IsExpanded(hclinet))
  2596. {
  2597. cbuffer.Format( _T("eD2K: %u (%.1f%%)") , myStats[15], totalclient ? (myStats[15] * 100.0 / totalclient) : 0.0 );
  2598. stattree.SetItemText( clinet[0] , cbuffer );
  2599. cbuffer.Format( _T("Kad: %u (%.1f%%)") , myStats[16], totalclient ? (myStats[16] * 100.0 / totalclient) : 0.0 );
  2600. stattree.SetItemText( clinet[1] , cbuffer );
  2601. cbuffer.Format( _T("eD2K/Kad: %u (%.1f%%)") , myStats[17], totalclient ? (myStats[17] * 100.0 / totalclient) : 0.0 );
  2602. stattree.SetItemText( clinet[2] , cbuffer );
  2603. cbuffer.Format( _T("%s: %u (%.1f%%)") , GetResString(IDS_UNKNOWN), myStats[18], totalclient ? (myStats[18] * 100.0 / totalclient) : 0.0 );
  2604. stattree.SetItemText( clinet[3] , cbuffer );
  2605. }
  2606. // End Clients -> Network Section
  2607. // CLIENTS -> PORT SECTION
  2608. if (forceUpdate || stattree.IsExpanded(hcliport))
  2609. {
  2610. cbuffer.Format(_T("%s: %u (%1.1f%%)"), GetResString(IDS_STATS_PRTDEF), myStats[8], myStats[8]>0?((double)100*myStats[8]/(myStats[8]+myStats[9])):0);
  2611. stattree.SetItemText(cliport[0], cbuffer);
  2612. cbuffer.Format(_T("%s: %u (%1.1f%%)"), GetResString(IDS_STATS_PRTOTHER), myStats[9], myStats[9]>0?((double)100*myStats[9]/(myStats[8]+myStats[9])):0);
  2613. stattree.SetItemText(cliport[1], cbuffer);
  2614. } // - End Clients -> Port Section
  2615. // CLIENTS -> FIREWALLED (KAD) SECTION
  2616. if (forceUpdate || stattree.IsExpanded(hclifirewalled))
  2617. {
  2618. if (!Kademlia::CKademlia::IsRunning() || Kademlia::CUDPFirewallTester::IsFirewalledUDP(true)) {
  2619. cbuffer.Format(_T("UDP: %s"), GetResString(IDS_KAD_UNKNOWN));
  2620. stattree.SetItemText(clifirewalled[0], cbuffer);
  2621. cbuffer.Format(_T("TCP: %s"), GetResString(IDS_KAD_UNKNOWN));
  2622. stattree.SetItemText(clifirewalled[1], cbuffer);
  2623. }
  2624. else {
  2625. if (Kademlia::CKademlia::GetPrefs()->StatsGetFirewalledRatio(true) > 0)
  2626. cbuffer.Format(_T("UDP: %1.1f%%"), Kademlia::CKademlia::GetPrefs()->StatsGetFirewalledRatio(true) * 100);
  2627. else
  2628. cbuffer.Format(_T("UDP: %s"), GetResString(IDS_FSTAT_WAITING));
  2629. stattree.SetItemText(clifirewalled[0], cbuffer);
  2630. if (Kademlia::CKademlia::GetPrefs()->StatsGetFirewalledRatio(false) > 0)
  2631. cbuffer.Format(_T("TCP: %1.1f%%"), Kademlia::CKademlia::GetPrefs()->StatsGetFirewalledRatio(false) * 100);
  2632. else
  2633. cbuffer.Format(_T("TCP: %s"), GetResString(IDS_FSTAT_WAITING));
  2634. stattree.SetItemText(clifirewalled[1], cbuffer);
  2635. }
  2636. } // - End Clients -> Firewalled (Kad) Section
  2637. // General Client Statistics
  2638. cbuffer.Format(_T("%s: %u (%1.1f%%)"), GetResString(IDS_STATS_PROBLEMATIC), myStats[6], (double)100*myStats[6]/totalclient);
  2639. stattree.SetItemText(cligen[0], cbuffer);
  2640. cbuffer.Format(_T("%s: %u"), GetResString(IDS_BANNED), theApp.clientlist->GetBannedCount());
  2641. stattree.SetItemText(cligen[1], cbuffer);
  2642. cbuffer.Format(GetResString(IDS_STATS_FILTEREDCLIENTS), theStats.filteredclients);
  2643. stattree.SetItemText(cligen[2], cbuffer);
  2644. } // - END CLIENTS SECTION
  2645. // UPDATE RECORDS FOR SERVERS AND SHARED FILES
  2646. thePrefs.SetRecordStructMembers();
  2647. // SERVERS SECTION
  2648. if (forceUpdate || stattree.IsExpanded(h_servers))
  2649. {
  2650. // Get stat values
  2651. uint32 servtotal, servfail, servuser, servfile, servlowiduser, servtuser, servtfile;
  2652. float servocc;
  2653. theApp.serverlist->GetStatus( servtotal, servfail, servuser, servfile, servlowiduser, servtuser, servtfile, servocc);
  2654. // Set working servers value
  2655. cbuffer.Format(_T("%s: %s"),GetResString(IDS_SF_WORKING),CastItoIShort(servtotal-servfail));stattree.SetItemText(srv[0], cbuffer);
  2656. if (forceUpdate || stattree.IsExpanded(srv[0]))
  2657. {
  2658. // Set users on working servers value
  2659. cbuffer.Format(_T("%s: %s; %s: %s (%.1f%%)"),GetResString(IDS_SF_WUSER),CastItoIShort(servuser),GetResString(IDS_IDLOW),CastItoIShort(servlowiduser),servuser ? (servlowiduser * 100.0 / servuser) : 0.0);stattree.SetItemText(srv_w[0], cbuffer);
  2660. // Set files on working servers value
  2661. cbuffer.Format(_T("%s: %s"),GetResString(IDS_SF_WFILE),CastItoIShort(servfile));stattree.SetItemText(srv_w[1], cbuffer);
  2662. // Set server occ value
  2663. cbuffer.Format(GetResString(IDS_SF_SRVOCC),servocc);stattree.SetItemText(srv_w[2], cbuffer);
  2664. }
  2665. // Set failed servers value
  2666. cbuffer.Format(_T("%s: %s"),GetResString(IDS_SF_FAIL),CastItoIShort(servfail));stattree.SetItemText(srv[1], cbuffer);
  2667. // Set deleted servers value
  2668. cbuffer.Format(_T("%s: %s"),GetResString(IDS_SF_DELCOUNT),CastItoIShort(theApp.serverlist->GetDeletedServerCount()));stattree.SetItemText(srv[2], cbuffer);
  2669. // Set total servers value
  2670. cbuffer.Format(_T("%s: %s"),GetResString(IDS_SF_TOTAL),CastItoIShort(servtotal));stattree.SetItemText(srv[3], cbuffer);
  2671. // Set total users value
  2672. cbuffer.Format(_T("%s: %s"),GetResString(IDS_SF_USER),CastItoIShort(servtuser));stattree.SetItemText(srv[4], cbuffer);
  2673. // Set total files value
  2674. cbuffer.Format(_T("%s: %s"),GetResString(IDS_SF_FILE),CastItoIShort(servtfile));stattree.SetItemText(srv[5], cbuffer);
  2675. // SERVERS -> RECORDS SECTION
  2676. if (forceUpdate || stattree.IsExpanded(hsrv_records))
  2677. {
  2678. // Set most working servers
  2679. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_SVRECWORKING), CastItoIShort(thePrefs.GetSrvrsMostWorkingServers()));
  2680. stattree.SetItemText(srv_r[0], cbuffer);
  2681. // Set most users online
  2682. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_SVRECUSERS), CastItoIShort(thePrefs.GetSrvrsMostUsersOnline()));
  2683. stattree.SetItemText(srv_r[1], cbuffer);
  2684. // Set most files avail
  2685. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_SVRECFILES), CastItoIShort(thePrefs.GetSrvrsMostFilesAvail()));
  2686. stattree.SetItemText(srv_r[2], cbuffer);
  2687. } // - End Servers -> Records Section
  2688. } // - END SERVERS SECTION
  2689. // SHARED FILES SECTION
  2690. if (forceUpdate || stattree.IsExpanded(h_shared))
  2691. {
  2692. // Set Number of Shared Files
  2693. cbuffer.Format(GetResString(IDS_SHAREDFILESCOUNT),theApp.sharedfiles->GetCount());
  2694. // SLUGFILLER: SafeHash - extra statistics
  2695. if (theApp.sharedfiles->GetHashingCount())
  2696. {
  2697. CString tempbuffer;
  2698. tempbuffer.Format(GetResString(IDS_HASHINGFILESCOUNT),theApp.sharedfiles->GetHashingCount());
  2699. cbuffer += tempbuffer;
  2700. }
  2701. // SLUGFILLER: SafeHash
  2702. stattree.SetItemText(shar[0], cbuffer);
  2703. // Set Average File Size
  2704. uint64 bytesLargestFile = 0;
  2705. uint64 allsize=theApp.sharedfiles->GetDatasize(bytesLargestFile); // Func returns total share size and sets pointeredd uint64 to largest single filesize
  2706. CString cbuffer2;
  2707. if(theApp.sharedfiles->GetCount() != 0)
  2708. cbuffer2.Format( _T("%s"), CastItoXBytes(allsize/(uint64)theApp.sharedfiles->GetCount(), false, false));
  2709. else
  2710. cbuffer2.Format( _T("%s"), CastItoXBytes((uint32)0, false, false) );
  2711. cbuffer.Format(GetResString(IDS_SF_AVERAGESIZE),cbuffer2);
  2712. stattree.SetItemText(shar[1], cbuffer);
  2713. // Set Largest File Size
  2714. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_LARGESTFILE), CastItoXBytes(bytesLargestFile, false, false) );
  2715. stattree.SetItemText(shar[2], cbuffer);
  2716. // Set Total Share Size
  2717. cbuffer.Format(GetResString(IDS_SF_SIZE),CastItoXBytes(allsize, false, false));
  2718. stattree.SetItemText(shar[3], cbuffer);
  2719. // SHARED FILES -> RECORDS SECTION
  2720. if (forceUpdate || stattree.IsExpanded(hshar_records))
  2721. {
  2722. // Set Most Files Shared
  2723. cbuffer.Format(_T("%s: %u"), GetResString(IDS_STATS_SHRECNUM), thePrefs.GetSharedMostFilesShared() );
  2724. stattree.SetItemText(shar_r[0], cbuffer);
  2725. // Set largest avg file size
  2726. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_SHRECASIZE), CastItoXBytes(thePrefs.GetSharedLargestAvgFileSize(), false, false) );
  2727. stattree.SetItemText(shar_r[1], cbuffer);
  2728. // Set largest file size
  2729. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_LARGESTFILE), CastItoXBytes(thePrefs.GetSharedLargestFileSize(), false, false) );
  2730. stattree.SetItemText(shar_r[2], cbuffer);
  2731. // Set largest share size
  2732. cbuffer.Format(_T("%s: %s"), GetResString(IDS_STATS_SHRECSIZE), CastItoXBytes(thePrefs.GetSharedLargestShareSize(), false, false) );
  2733. stattree.SetItemText(shar_r[3], cbuffer);
  2734. } // - End Shared Files -> Records Section
  2735. } // - END SHARED FILES SECTION
  2736. if (forceUpdate || stattree.IsExpanded(h_total_downloads))
  2737. {
  2738. uint64 ui64TotalFileSize = 0;
  2739. uint64 ui64TotalLeftToTransfer = 0;
  2740. uint64 ui64TotalAdditionalNeededSpace = 0;
  2741. int iActiveFiles = theApp.downloadqueue->GetDownloadFilesStats(ui64TotalFileSize, ui64TotalLeftToTransfer, ui64TotalAdditionalNeededSpace);
  2742. cbuffer.Format(GetResString(IDS_DWTOT_NR), iActiveFiles);
  2743. stattree.SetItemText(h_total_num_of_dls, cbuffer);
  2744. cbuffer.Format(GetResString(IDS_DWTOT_TSD), CastItoXBytes(ui64TotalFileSize, false, false));
  2745. stattree.SetItemText(h_total_size_of_dls, cbuffer);
  2746. uint64 ui64TotalTransferred = ui64TotalFileSize - ui64TotalLeftToTransfer;
  2747. double fPercent = 0.0;
  2748. if (ui64TotalFileSize != 0)
  2749. fPercent = (ui64TotalTransferred * 100.0) / ui64TotalFileSize;
  2750. cbuffer.Format(GetResString(IDS_DWTOT_TCS), CastItoXBytes(ui64TotalTransferred, false, false), fPercent);
  2751. stattree.SetItemText(h_total_size_dld, cbuffer);
  2752. cbuffer.Format(GetResString(IDS_DWTOT_TSL), CastItoXBytes(ui64TotalLeftToTransfer, false, false));
  2753. stattree.SetItemText(h_total_size_left_to_dl, cbuffer);
  2754. cbuffer.Format(GetResString(IDS_DWTOT_TSN), CastItoXBytes(ui64TotalAdditionalNeededSpace, false, false));
  2755. stattree.SetItemText(h_total_size_needed, cbuffer);
  2756. CString buffer2;
  2757. uint64 ui64TotalFreeSpace = GetFreeTempSpace(-1);
  2758. buffer2.Format(GetResString(IDS_DWTOT_FS), CastItoXBytes(ui64TotalFreeSpace, false, false));
  2759. if (ui64TotalAdditionalNeededSpace > ui64TotalFreeSpace)
  2760. cbuffer.Format(GetResString(IDS_NEEDFREEDISKSPACE), buffer2, CastItoXBytes(ui64TotalAdditionalNeededSpace - ui64TotalFreeSpace, false, false));
  2761. else
  2762. cbuffer = buffer2;
  2763. stattree.SetItemText(h_total_size_left_on_drive, cbuffer);
  2764. }
  2765. // - End Set Tree Values
  2766. #ifdef _DEBUG
  2767. if (g_pfnPrevCrtAllocHook)
  2768. {
  2769. _CrtMemState memState;
  2770. _CrtMemCheckpoint(&memState);
  2771. cbuffer.Format(_T("%s: %u bytes in %u blocks"),_T("Free"),memState.lSizes[ 0 ],memState.lCounts[ 0 ] );
  2772. stattree.SetItemText(debug1, cbuffer);
  2773. cbuffer.Format(_T("%s: %u bytes in %u blocks"),_T("Normal"),memState.lSizes[ 1 ],memState.lCounts[ 1 ] );
  2774. stattree.SetItemText(debug2, cbuffer);
  2775. cbuffer.Format(_T("%s: %u bytes in %u blocks"),_T("CRT"),memState.lSizes[ 2 ],memState.lCounts[ 2 ] );
  2776. stattree.SetItemText(debug3, cbuffer);
  2777. cbuffer.Format(_T("%s: %u bytes in %u blocks"),_T("Ignore"),memState.lSizes[ 3 ],memState.lCounts[ 3 ] );
  2778. stattree.SetItemText(debug4, cbuffer);
  2779. cbuffer.Format(_T("%s: %u bytes in %u blocks"),_T("Client"),memState.lSizes[ 4 ],memState.lCounts[ 4 ] );
  2780. stattree.SetItemText(debug5, cbuffer);
  2781. extern CMap<const unsigned char*, const unsigned char*, UINT, UINT> g_allocations;
  2782. POSITION pos = blockFiles.GetStartPosition();
  2783. while (pos != NULL)
  2784. {
  2785. const unsigned char* pszFileName;
  2786. HTREEITEM* pTag;
  2787. blockFiles.GetNextAssoc(pos, pszFileName, pTag);
  2788. stattree.SetItemText(*pTag, _T(""));
  2789. }
  2790. pos = g_allocations.GetStartPosition();
  2791. while (pos != NULL)
  2792. {
  2793. const unsigned char* pszFileName;
  2794. UINT count;
  2795. g_allocations.GetNextAssoc(pos, pszFileName, count);
  2796. HTREEITEM* pTag;
  2797. if (blockFiles.Lookup(pszFileName, pTag) == 0)
  2798. {
  2799. pTag = new HTREEITEM;
  2800. *pTag = stattree.InsertItem(_T("0"), debug2);
  2801. stattree.SetItemData(*pTag, 1);
  2802. blockFiles.SetAt(pszFileName, pTag);
  2803. }
  2804. cbuffer.Format(_T("%s : %u blocks"), pszFileName, count);
  2805. stattree.SetItemText(*pTag, cbuffer);
  2806. }
  2807. }
  2808. #endif
  2809. #ifdef USE_MEM_STATS
  2810. if (forceUpdate || stattree.IsExpanded(h_allocs))
  2811. {
  2812. ULONGLONG ullTotalAllocs = 0;
  2813. for (int i = 0; i < ALLOC_SLOTS; i++)
  2814. ullTotalAllocs += g_aAllocStats[i];
  2815. for (int i = 0; i < ALLOC_SLOTS; i++)
  2816. {
  2817. unsigned uStart, uEnd;
  2818. if (i <= 1)
  2819. uStart = uEnd = i;
  2820. else {
  2821. uStart = 1 << (i - 1);
  2822. uEnd = (i == ALLOC_SLOTS - 1) ? (unsigned)-1 : (uStart << 1) - 1;
  2823. }
  2824. CString strLabel;
  2825. strLabel.Format(_T("Block size %08X-%08X: %s (%1.1f%%)"), uStart, uEnd, CastItoIShort(g_aAllocStats[i], false, 2), ullTotalAllocs != 0 ? g_aAllocStats[i] * 100.0 / ullTotalAllocs : 0.0);
  2826. stattree.SetItemText(h_allocSizes[i], strLabel);
  2827. }
  2828. }
  2829. #endif
  2830. stattree.SetRedraw(true);
  2831. } // ShowStatistics(bool forceRedraw = false){}
  2832. void CStatisticsDlg::UpdateConnectionsGraph()
  2833. {
  2834. // This updates the Y-Axis scale of the Connections Statistics graph...
  2835. // And it updates the trend ratio for the active connections trend.
  2836. m_Statistics.SetRanges(0, thePrefs.GetStatsMax());
  2837. m_Statistics.SetTrendRatio(0, thePrefs.GetStatsConnectionsGraphRatio());
  2838. }
  2839. void CStatisticsDlg::OnShowWindow(BOOL /*bShow*/, UINT /*nStatus*/)
  2840. {
  2841. }
  2842. void CStatisticsDlg::OnSize(UINT nType, int cx, int cy)
  2843. {
  2844. CResizableDialog::OnSize(nType, cx, cy);
  2845. if (cx > 0 && cy > 0 && (cx != m_oldcx || cy != m_oldcy))
  2846. {
  2847. m_oldcx=cx;
  2848. m_oldcy=cy;
  2849. ShowInterval();
  2850. }
  2851. }
  2852. void CStatisticsDlg::ShowInterval()
  2853. {
  2854. if (!theApp.emuledlg->IsRunning())
  2855. return;
  2856. // Check if OScope already initialized
  2857. if (m_DownloadOMeter.GetSafeHwnd() != NULL && m_UploadOMeter.GetSafeHwnd() != NULL)
  2858. {
  2859. // Retrieve the size (in pixel) of the OScope
  2860. CRect plotRect;
  2861. m_UploadOMeter.GetPlotRect(plotRect);
  2862. // Dynamic update of time scale [Maella]
  2863. int shownSecs = plotRect.Width() * thePrefs.GetTrafficOMeterInterval();
  2864. // CB Mod ---> Make Setters
  2865. m_Statistics.m_nXPartial = m_DownloadOMeter.m_nXPartial = m_UploadOMeter.m_nXPartial = shownSecs % 3600;
  2866. m_Statistics.m_nXGrids = m_DownloadOMeter.m_nXGrids = m_UploadOMeter.m_nXGrids = shownSecs / 3600;
  2867. if(shownSecs <= 0)
  2868. {
  2869. m_DownloadOMeter.SetXUnits(GetResString(IDS_STOPPED));
  2870. m_UploadOMeter.SetXUnits(GetResString(IDS_STOPPED));
  2871. m_Statistics.SetXUnits(GetResString(IDS_STOPPED));
  2872. }
  2873. else
  2874. {
  2875. const CString buffer = CastSecondsToHM(shownSecs);
  2876. m_UploadOMeter.SetXUnits(buffer);
  2877. m_DownloadOMeter.SetXUnits(buffer);
  2878. m_Statistics.SetXUnits(buffer);
  2879. }
  2880. UpdateData(FALSE);
  2881. }
  2882. }
  2883. void CStatisticsDlg::SetARange(bool SetDownload, int maxValue)
  2884. {
  2885. if (SetDownload)
  2886. {
  2887. m_DownloadOMeter.SetRange(0, maxValue, 0);
  2888. m_DownloadOMeter.SetRange(0, maxValue, 1);
  2889. m_DownloadOMeter.SetRange(0, maxValue, 2);
  2890. }
  2891. else
  2892. {
  2893. m_UploadOMeter.SetRange(0, maxValue, 0) ;
  2894. m_UploadOMeter.SetRange(0, maxValue, 1);
  2895. m_UploadOMeter.SetRange(0, maxValue, 2);
  2896. m_UploadOMeter.SetRange(0, maxValue, 3);
  2897. m_UploadOMeter.SetRange(0, maxValue, 4);
  2898. }
  2899. }
  2900. // Various changes in Localize() and a new button event...
  2901. void CStatisticsDlg::Localize()
  2902. {
  2903. RepaintMeters();
  2904. CString myBuffer;
  2905. myBuffer.Format(GetResString(IDS_STATS_LASTRESETSTATIC), thePrefs.GetStatsLastResetStr(false));
  2906. GetDlgItem(IDC_STATIC_LASTRESET)->SetWindowText(myBuffer);
  2907. }
  2908. // End Localize
  2909. // Menu Button: Displays the menu of stat tree commands.
  2910. void CStatisticsDlg::OnMenuButtonClicked()
  2911. {
  2912. CRect rectBn;
  2913. CPoint thePoint;
  2914. GetDlgItem(IDC_BNMENU)->GetWindowRect(&rectBn);
  2915. thePoint = rectBn.BottomRight();
  2916. stattree.DoMenu(thePoint);
  2917. }
  2918. void CStatisticsDlg::CreateMyTree()
  2919. {
  2920. stattree.DeleteAllItems();
  2921. // Setup Tree
  2922. h_transfer = stattree.InsertItem(GetResString(IDS_FSTAT_TRANSFER),1,1); // Transfers Section
  2923. CString buffer;
  2924. buffer.Format(_T("%s %s"),GetResString(IDS_STATS_SRATIO),GetResString(IDS_FSTAT_WAITING));// Make It Pretty
  2925. trans[0]= stattree.InsertItem(buffer, h_transfer); // Session Ratio
  2926. buffer.Format(_T("%s %s"),GetResString(IDS_STATS_FRATIO),GetResString(IDS_FSTAT_WAITING));// Make It Pretty
  2927. trans[1]= stattree.InsertItem(buffer, h_transfer); // Friend Session Ratio
  2928. buffer.Format(_T("%s %s"),GetResString(IDS_STATS_CRATIO),GetResString(IDS_FSTAT_WAITING));// Make It Pretty
  2929. trans[2]= stattree.InsertItem(buffer, h_transfer); // Cumulative Ratio
  2930. h_upload = stattree.InsertItem(GetResString(IDS_TW_UPLOADS), 6,6,h_transfer); // Uploads Section
  2931. h_up_session= stattree.InsertItem(GetResString(IDS_STATS_SESSION), 8,8,h_upload); // Session Section (Uploads)
  2932. for(int i = 0; i<6; i++)
  2933. up_S[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_up_session); //MORPH - Added by Yun.SF3, ZZ Upload System
  2934. hup_scb= stattree.InsertItem(GetResString(IDS_CLIENTS),up_S[0]); // Clients Section
  2935. for(int i = 0; i<_countof(up_scb); i++)
  2936. up_scb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_scb);
  2937. hup_spb= stattree.InsertItem(GetResString(IDS_PORT),up_S[0]); // Ports Section
  2938. for(int i = 0; i<_countof(up_spb); i++)
  2939. up_spb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_spb);
  2940. hup_ssb= stattree.InsertItem(GetResString(IDS_STATS_DATASOURCE),up_S[0]); // Data Source Section
  2941. for(int i = 0; i<2; i++)
  2942. up_ssb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_ssb);
  2943. for(int i = 0; i<4; i++)
  2944. up_ssessions[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), up_S[5]); //MORPH - Added by Yun.SF3, ZZ Upload System
  2945. hup_soh= stattree.InsertItem(GetResString(IDS_STATS_OVRHD),h_up_session); // Upline Overhead (Session)
  2946. for(int i = 0; i<_countof(up_soh); i++)
  2947. up_soh[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_soh);
  2948. h_up_total= stattree.InsertItem(GetResString(IDS_STATS_CUMULATIVE),9,9, h_upload); // Cumulative Section (Uploads)
  2949. up_T[0]= stattree.InsertItem(GetResString(IDS_FSTAT_WAITING),h_up_total); // Uploaded Data (Total)
  2950. hup_tcb= stattree.InsertItem(GetResString(IDS_CLIENTS),up_T[0]); // Clients Section
  2951. for(int i = 0; i<_countof(up_tcb); i++)
  2952. up_tcb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_tcb);
  2953. hup_tpb= stattree.InsertItem(GetResString(IDS_PORT),up_T[0]); // Ports Section
  2954. for(int i = 0; i<_countof(up_tpb); i++)
  2955. up_tpb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_tpb);
  2956. hup_tsb= stattree.InsertItem(GetResString(IDS_STATS_DATASOURCE),up_T[0]); // Data Source Section
  2957. for(int i = 0; i<2; i++)
  2958. up_tsb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_tsb);
  2959. up_T[1]= stattree.InsertItem(GetResString(IDS_FSTAT_WAITING),h_up_total); // Upload Sessions (Total)
  2960. for(int i = 0; i<4; i++)
  2961. up_tsessions[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), up_T[1]);
  2962. hup_toh= stattree.InsertItem(GetResString(IDS_STATS_OVRHD),h_up_total); // Upline Overhead (Total)
  2963. for(int i = 0; i<_countof(up_toh); i++)
  2964. up_toh[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hup_toh);
  2965. h_download = stattree.InsertItem(GetResString(IDS_TW_DOWNLOADS), 7,7,h_transfer); // Downloads Section
  2966. h_down_session= stattree.InsertItem(GetResString(IDS_STATS_SESSION),8,8, h_download); // Session Section (Downloads)
  2967. for(int i = 0; i<8; i++)
  2968. down_S[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_down_session);
  2969. hdown_scb= stattree.InsertItem(GetResString(IDS_CLIENTS),down_S[0]); // Clients Section
  2970. for(int i = 0; i<_countof(down_scb); i++)
  2971. down_scb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hdown_scb);
  2972. hdown_spb= stattree.InsertItem(GetResString(IDS_PORT),down_S[0]); // Ports Section
  2973. for(int i = 0; i<_countof(down_spb); i++)
  2974. down_spb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hdown_spb);
  2975. for(int i = 0; i<_countof(down_sources); i++)
  2976. down_sources[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), down_S[3]);
  2977. for(int i = 0; i<4; i++)
  2978. down_ssessions[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), down_S[4]);
  2979. hdown_soh= stattree.InsertItem(GetResString(IDS_STATS_OVRHD),h_down_session); // Downline Overhead (Session)
  2980. for(int i = 0; i<_countof(down_soh); i++)
  2981. down_soh[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hdown_soh);
  2982. h_down_total= stattree.InsertItem(GetResString(IDS_STATS_CUMULATIVE),9,9, h_download); // Cumulative Section (Downloads)
  2983. for(int i = 0; i<6; i++)
  2984. down_T[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_down_total);
  2985. hdown_tcb= stattree.InsertItem(GetResString(IDS_CLIENTS),down_T[0]); // Clients Section
  2986. for(int i = 0; i<_countof(down_tcb); i++)
  2987. down_tcb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hdown_tcb);
  2988. hdown_tpb= stattree.InsertItem(GetResString(IDS_PORT),down_T[0]); // Ports Section
  2989. for(int i = 0; i<_countof(down_tpb); i++)
  2990. down_tpb[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hdown_tpb);
  2991. for(int i = 0; i<4; i++)
  2992. down_tsessions[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), down_T[2]);
  2993. hdown_toh= stattree.InsertItem(GetResString(IDS_STATS_OVRHD),h_down_total); // Downline Overhead (Total)
  2994. for(int i = 0; i<_countof(down_toh); i++)
  2995. down_toh[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hdown_toh);
  2996. h_connection = stattree.InsertItem(GetResString(IDS_FSTAT_CONNECTION),2,2); // Connection Section
  2997. h_conn_session= stattree.InsertItem(GetResString(IDS_STATS_SESSION),8,8,h_connection); // Session Section (Connection)
  2998. hconn_sg= stattree.InsertItem(GetResString(IDS_STATS_GENERAL),11,11,h_conn_session); // General Section (Session)
  2999. for(int i = 0; i<5; i++)
  3000. conn_sg[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hconn_sg);
  3001. hconn_su= stattree.InsertItem(GetResString(IDS_PW_CON_UPLBL),6,6,h_conn_session); // Uploads Section (Session)
  3002. for(int i = 0; i<4; i++)
  3003. conn_su[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hconn_su);
  3004. hconn_sd= stattree.InsertItem(GetResString(IDS_PW_CON_DOWNLBL),7,7,h_conn_session); // Downloads Section (Session)
  3005. for(int i = 0; i<4; i++)
  3006. conn_sd[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hconn_sd);
  3007. h_conn_total= stattree.InsertItem(GetResString(IDS_STATS_CUMULATIVE),9,9,h_connection); // Cumulative Section (Connection)
  3008. hconn_tg= stattree.InsertItem(GetResString(IDS_STATS_GENERAL),11,11,h_conn_total); // General (Total)
  3009. for(int i = 0; i<4; i++)
  3010. conn_tg[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hconn_tg);
  3011. hconn_tu= stattree.InsertItem(GetResString(IDS_PW_CON_UPLBL),6,6,h_conn_total); // Uploads (Total)
  3012. for(int i = 0; i<3; i++)
  3013. conn_tu[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hconn_tu);
  3014. hconn_td= stattree.InsertItem(GetResString(IDS_PW_CON_DOWNLBL),7,7,h_conn_total); // Downloads (Total)
  3015. for(int i = 0; i<3; i++)
  3016. conn_td[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hconn_td);
  3017. h_time = stattree.InsertItem(GetResString(IDS_STATS_TIMESTATS),12,12); // Time Statistics Section
  3018. for(int i = 0; i<2; i++)
  3019. tvitime[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_time);
  3020. htime_s = stattree.InsertItem(GetResString(IDS_STATS_SESSION),8,8,h_time); // Session Section (Time)
  3021. for(int i = 0; i<4; i++)
  3022. tvitime_s[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), htime_s);
  3023. for(int i = 0; i<2; i++)
  3024. tvitime_st[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), tvitime_s[1]);
  3025. htime_t = stattree.InsertItem(GetResString(IDS_STATS_CUMULATIVE),9,9,h_time); // Cumulative Section (Time)
  3026. for(int i = 0; i<3; i++)
  3027. tvitime_t[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), htime_t);
  3028. for(int i = 0; i<2; i++)
  3029. tvitime_tt[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), tvitime_t[1]);
  3030. htime_aap = stattree.InsertItem(GetResString(IDS_STATS_AVGANDPROJ),13,13,h_time); // Projected Averages Section
  3031. time_aaph[0] = stattree.InsertItem(GetResString(IDS_DAYLY),14,14,htime_aap); // Daily Section
  3032. time_aaph[1] = stattree.InsertItem(GetResString(IDS_STATS_MONTHLY),15,15,htime_aap); // Monthly Section
  3033. time_aaph[2] = stattree.InsertItem(GetResString(IDS_STATS_YEARLY),16,16,htime_aap); // Yearly Section
  3034. for(int x = 0; x<3; x++)
  3035. {
  3036. time_aap_hup[x] = stattree.InsertItem(GetResString(IDS_TW_UPLOADS),6,6,time_aaph[x]); // Upload Section
  3037. for(int i = 0; i<3; i++)
  3038. time_aap_up[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING),time_aap_hup[x]);
  3039. time_aap_up_hd[x][0] = stattree.InsertItem(GetResString(IDS_CLIENTS),time_aap_up[x][0]); // Clients Section
  3040. for(int i = 0; i<7; i++)
  3041. time_aap_up_dc[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_up_hd[x][0]);
  3042. time_aap_up_hd[x][1] = stattree.InsertItem(GetResString(IDS_PORT),time_aap_up[x][0]); // Ports Section
  3043. for(int i = 0; i<_countof(time_aap_up_dp[0]); i++)
  3044. time_aap_up_dp[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_up_hd[x][1]);
  3045. time_aap_up_hd[x][2] = stattree.InsertItem(GetResString(IDS_STATS_DATASOURCE),time_aap_up[x][0]); // Data Source Section
  3046. for(int i = 0; i<2; i++)
  3047. time_aap_up_ds[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_up_hd[x][2]);
  3048. for(int i = 0; i<2; i++)
  3049. time_aap_up_s[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_up[x][1]);
  3050. for(int i = 0; i<4; i++)
  3051. time_aap_up_oh[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_up[x][2]);
  3052. time_aap_hdown[x] = stattree.InsertItem(GetResString(IDS_TW_DOWNLOADS),7,7,time_aaph[x]);// Download Section
  3053. for(int i = 0; i<7; i++)
  3054. time_aap_down[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING),time_aap_hdown[x]);
  3055. time_aap_down_hd[x][0] = stattree.InsertItem(GetResString(IDS_CLIENTS),time_aap_down[x][0]); // Clients Section
  3056. for(int i = 0; i<8; i++)
  3057. time_aap_down_dc[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_down_hd[x][0]);
  3058. time_aap_down_hd[x][1] = stattree.InsertItem(GetResString(IDS_PORT),time_aap_down[x][0]); // Ports Section
  3059. for(int i = 0; i<_countof(time_aap_down_dp[0]); i++)
  3060. time_aap_down_dp[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_down_hd[x][1]);
  3061. for(int i = 0; i<2; i++)
  3062. time_aap_down_s[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_down[x][2]);
  3063. for(int i = 0; i<4; i++)
  3064. time_aap_down_oh[x][i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), time_aap_down[x][6]);
  3065. }
  3066. h_clients = stattree.InsertItem(GetResString(IDS_CLIENTS),3,3); // Clients Section
  3067. cligen[5] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_clients);
  3068. hclisoft = stattree.InsertItem(GetResString(IDS_CD_CSOFT),h_clients); // Client Software Section
  3069. for(int i = 0; i<8; i++)
  3070. clisoft[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hclisoft);
  3071. hclinet = stattree.InsertItem(GetResString(IDS_NETWORK),h_clients); // Client Network Section
  3072. for(int i = 0; i<4; i++)
  3073. clinet[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hclinet);
  3074. hcliport = stattree.InsertItem(GetResString(IDS_PORT),h_clients); // Client Port Section
  3075. for(int i = 0; i<2; i++)
  3076. cliport[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hcliport);
  3077. hclifirewalled = stattree.InsertItem(GetResString(IDS_FIREWALLED) + _T(" (") + GetResString(IDS_KADEMLIA) + _T(")"),h_clients);
  3078. for (int i = 0; i < 2; i++)
  3079. clifirewalled[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hclifirewalled);
  3080. cligen[4] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_clients);
  3081. cligen[3] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_clients);
  3082. for(int i = 0; i<3; i++)
  3083. cligen[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_clients);
  3084. h_servers = stattree.InsertItem(GetResString(IDS_FSTAT_SERVERS),4,4); // Servers section
  3085. for(int i = 0; i<6; i++)
  3086. srv[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_servers); // Servers Items
  3087. for(int i = 0; i<3; i++)
  3088. srv_w[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), srv[0]); // Working Servers Items
  3089. hsrv_records = stattree.InsertItem(GetResString(IDS_STATS_RECORDS),10,10,h_servers); // Servers Records Section
  3090. for(int i = 0; i<3; i++)
  3091. srv_r[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hsrv_records); // Record Items
  3092. h_shared = stattree.InsertItem( GetResString(IDS_SHAREDFILES),5,5 ); // Shared Files Section
  3093. for(int i = 0; i<4; i++)
  3094. shar[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), h_shared);
  3095. hshar_records= stattree.InsertItem(GetResString(IDS_STATS_RECORDS),10,10,h_shared); // Shared Records Section
  3096. for(int i = 0; i<4; i++)
  3097. shar_r[i] = stattree.InsertItem(GetResString(IDS_FSTAT_WAITING), hshar_records);
  3098. h_total_downloads=stattree.InsertItem(GetResString(IDS_DWTOT),17,17);
  3099. h_total_num_of_dls=stattree.InsertItem(GetResString(IDS_DWTOT_NR),h_total_downloads);
  3100. h_total_size_of_dls=stattree.InsertItem(GetResString(IDS_DWTOT_TSD),h_total_downloads);
  3101. h_total_size_dld=stattree.InsertItem(GetResString(IDS_DWTOT_TCS),h_total_downloads);
  3102. h_total_size_left_to_dl=stattree.InsertItem(GetResString(IDS_DWTOT_TSL),h_total_downloads);
  3103. h_total_size_left_on_drive=stattree.InsertItem(GetResString(IDS_DWTOT_FS),h_total_downloads);
  3104. h_total_size_needed=stattree.InsertItem(GetResString(IDS_DWTOT_TSN),h_total_downloads);
  3105. #ifdef _DEBUG
  3106. if (g_pfnPrevCrtAllocHook)
  3107. {
  3108. h_debug = stattree.InsertItem( _T("Debug info") );stattree.SetItemData(h_debug,0);
  3109. h_blocks = stattree.InsertItem(_T("Blocks"),h_debug);stattree.SetItemData(h_blocks,1);
  3110. debug1 = stattree.InsertItem(_T("Free"),h_blocks);stattree.SetItemData(debug1,1);
  3111. debug2 = stattree.InsertItem(_T("Normal"),h_blocks);stattree.SetItemData(debug2,1);
  3112. debug3 = stattree.InsertItem(_T("CRT"),h_blocks);stattree.SetItemData(debug3,1);
  3113. debug4 = stattree.InsertItem(_T("Ignore"),h_blocks);stattree.SetItemData(debug4,1);
  3114. debug5 = stattree.InsertItem(_T("Client"),h_blocks);stattree.SetItemData(debug5,1);
  3115. stattree.Expand(h_debug,TVE_EXPAND);
  3116. stattree.Expand(h_blocks,TVE_EXPAND);
  3117. }
  3118. #endif
  3119. #ifdef USE_MEM_STATS
  3120. h_allocs = stattree.InsertItem(_T("Allocations"));
  3121. for (int i = 0; i < ALLOC_SLOTS; i++)
  3122. {
  3123. unsigned uStart, uEnd;
  3124. if (i <= 1)
  3125. uStart = uEnd = i;
  3126. else {
  3127. uStart = 1 << (i - 1);
  3128. uEnd = (i == ALLOC_SLOTS - 1) ? (unsigned)-1 : (uStart << 1) - 1;
  3129. }
  3130. CString strLabel;
  3131. strLabel.Format(_T("Block size %08X-%08X: %s (%1.1f%%)"), uStart, uEnd, CastItoIShort(g_aAllocStats[i], false, 2), 0.0);
  3132. h_allocSizes[i] = stattree.InsertItem(strLabel, h_allocs);
  3133. }
  3134. #endif
  3135. // Make section headers bold in order to make the tree easier to view at a glance.
  3136. stattree.SetItemState(h_transfer, TVIS_BOLD, TVIS_BOLD);
  3137. stattree.SetItemState(h_connection, TVIS_BOLD, TVIS_BOLD);
  3138. stattree.SetItemState(h_time, TVIS_BOLD, TVIS_BOLD);
  3139. stattree.SetItemState(htime_s, TVIS_BOLD, TVIS_BOLD);
  3140. stattree.SetItemState(htime_t, TVIS_BOLD, TVIS_BOLD);
  3141. stattree.SetItemState(htime_aap, TVIS_BOLD, TVIS_BOLD);
  3142. stattree.SetItemState(h_total_downloads, TVIS_BOLD, TVIS_BOLD);
  3143. for(int i = 0; i<3; i++)
  3144. {
  3145. stattree.SetItemState(time_aaph[i], TVIS_BOLD, TVIS_BOLD);
  3146. stattree.SetItemState(time_aap_hup[i], TVIS_BOLD, TVIS_BOLD);
  3147. stattree.SetItemState(time_aap_hdown[i], TVIS_BOLD, TVIS_BOLD);
  3148. }
  3149. stattree.SetItemState(h_clients, TVIS_BOLD, TVIS_BOLD);
  3150. stattree.SetItemState(h_servers, TVIS_BOLD, TVIS_BOLD);
  3151. stattree.SetItemState(h_shared, TVIS_BOLD, TVIS_BOLD);
  3152. stattree.SetItemState(h_upload, TVIS_BOLD, TVIS_BOLD);
  3153. stattree.SetItemState(h_download, TVIS_BOLD, TVIS_BOLD);
  3154. stattree.SetItemState(h_up_session, TVIS_BOLD, TVIS_BOLD);
  3155. stattree.SetItemState(h_up_total, TVIS_BOLD, TVIS_BOLD);
  3156. stattree.SetItemState(h_down_session, TVIS_BOLD, TVIS_BOLD);
  3157. stattree.SetItemState(h_down_total, TVIS_BOLD, TVIS_BOLD);
  3158. stattree.SetItemState(h_conn_session, TVIS_BOLD, TVIS_BOLD);
  3159. stattree.SetItemState(h_conn_total, TVIS_BOLD, TVIS_BOLD);
  3160. stattree.SetItemState(hsrv_records, TVIS_BOLD, TVIS_BOLD);
  3161. stattree.SetItemState(hshar_records, TVIS_BOLD, TVIS_BOLD);
  3162. stattree.SetItemState(hconn_sg, TVIS_BOLD, TVIS_BOLD);
  3163. stattree.SetItemState(hconn_su, TVIS_BOLD, TVIS_BOLD);
  3164. stattree.SetItemState(hconn_sd, TVIS_BOLD, TVIS_BOLD);
  3165. stattree.SetItemState(hconn_tg, TVIS_BOLD, TVIS_BOLD);
  3166. stattree.SetItemState(hconn_tu, TVIS_BOLD, TVIS_BOLD);
  3167. stattree.SetItemState(hconn_td, TVIS_BOLD, TVIS_BOLD);
  3168. // Expand our purdy new tree...
  3169. stattree.ApplyExpandedMask(thePrefs.GetExpandedTreeItems());
  3170. // Select the top item so that the tree is not scrolled to the bottom when first viewed.
  3171. stattree.SelectItem(h_transfer);
  3172. stattree.Init();
  3173. // Initialize our client version counts
  3174. for (int i = 0; i < _countof(cli_lastCount); i++)
  3175. cli_lastCount[i] = 0;
  3176. // End Tree Setup
  3177. }
  3178. void CStatisticsDlg::OnStnDblclickScopeD()
  3179. {
  3180. theApp.emuledlg->ShowPreferences(IDD_PPG_STATS);
  3181. }
  3182. void CStatisticsDlg::OnStnDblclickScopeU()
  3183. {
  3184. theApp.emuledlg->ShowPreferences(IDD_PPG_STATS);
  3185. }
  3186. void CStatisticsDlg::OnStnDblclickStatsscope()
  3187. {
  3188. theApp.emuledlg->ShowPreferences(IDD_PPG_STATS);
  3189. }
  3190. LRESULT CStatisticsDlg::OnOscopePositionMsg(WPARAM /*wParam*/, LPARAM lParam)
  3191. {
  3192. LPCTSTR pszInfo = (LPCTSTR)lParam;
  3193. m_TimeToolTips->UpdateTipText(pszInfo, GetDlgItem(IDC_SCOPE_D));
  3194. m_TimeToolTips->UpdateTipText(pszInfo, GetDlgItem(IDC_SCOPE_U));
  3195. m_TimeToolTips->UpdateTipText(pszInfo, GetDlgItem(IDC_STATSSCOPE));
  3196. m_TimeToolTips->Update();
  3197. return 0;
  3198. }
  3199. BOOL CStatisticsDlg::PreTranslateMessage(MSG* pMsg)
  3200. {
  3201. m_TimeToolTips->RelayEvent(pMsg);
  3202. if (pMsg->message == WM_KEYDOWN)
  3203. {
  3204. // Don't handle Ctrl+Tab in this window. It will be handled by main window.
  3205. if (pMsg->wParam == VK_TAB && GetAsyncKeyState(VK_CONTROL) < 0)
  3206. return FALSE;
  3207. }
  3208. return CDialog::PreTranslateMessage(pMsg);
  3209. }
  3210. BOOL CStatisticsDlg::OnHelpInfo(HELPINFO* /*pHelpInfo*/)
  3211. {
  3212. theApp.ShowHelp(eMule_FAQ_GUI_Statistics);
  3213. return TRUE;
  3214. }
  3215. HBRUSH CStatisticsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  3216. {
  3217. HBRUSH hbr = theApp.emuledlg->GetCtlColor(pDC, pWnd, nCtlColor);
  3218. if (hbr)
  3219. return hbr;
  3220. return __super::OnCtlColor(pDC, pWnd, nCtlColor);
  3221. }