there always was something that got onto my nerve when I was just trying to set new speed limits via Webserver, Systray Menu or System Menu. They would always be reseted after some time or a reboot of eMule. Well, it would appear that the code responsible for this is within the Scheduler and the code preventing this behaviour from happening was not being applied in any other place but the Connections Preferences page. So see below if you want to add this trivial, yet effective fix:
LRESULT CemuleDlg::OnWMData
theApp.scheduler->SaveOriginals(); // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle return true; } if (clcommand==_T("help") || clcommand==_T("/?")) {
Beginning of WebServer.cpp
#include "UserMsgs.h" #include "Scheduler.h" // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle #ifdef _DEBUG
CString CWebServer::_GetPreferences
if(!_ParseURL(Data.sURL, _T("maxconnectionsperfive")).IsEmpty()) thePrefs.SetMaxConsPerFive(_tstoi(_ParseURL(Data.sURL, _T("maxconnectionsperfive")))); theApp.scheduler->SaveOriginals(); // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle } // Fill form if(thePrefs.GetWebUseGzip()) Out.Replace(_T("[UseGzipVal]"), _T("checked")); else Out.Replace(_T("[UseGzipVal]"), _T(""));
Beginning of MMServer.cpp
#include "Log.h" #include "Scheduler.h" // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle #ifdef _DEBUG
void CMMServer::ProcessChangeLimitRequest
thePrefs.SetMaxUpload(nNewUpload); thePrefs.SetMaxDownload(nNewDownload); theApp.scheduler->SaveOriginals(); // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle CMMPacket* packet = new CMMPacket(MMP_CHANGELIMITANS); packet->WriteShort((uint16)((thePrefs.GetMaxUpload() >= UNLIMITED) ? 0 : thePrefs.GetMaxUpload()));
void CemuleDlg::OnTrayRButtonUp
if (m_pSystrayDlg) { // ==> Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle float fMaxUploadOld = thePrefs.GetMaxUpload(); float fMaxDownloadOld = thePrefs.GetMaxDownload(); // <== Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle UINT nResult = m_pSystrayDlg->DoModal(); delete m_pSystrayDlg; m_pSystrayDlg = NULL; switch (nResult) { case IDC_TOMAX: QuickSpeedOther(MP_QS_UA); // ==> Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle if (uMaxUploadOld != thePrefs.GetMaxUpload() || uMaxDownloadOld != thePrefs.GetMaxDownload()) theApp.scheduler->SaveOriginals(); // <== Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle break; case IDC_TOMIN: QuickSpeedOther(MP_QS_PA); // ==> Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle if (uMaxUploadOld != thePrefs.GetMaxUpload() || uMaxDownloadOld != thePrefs.GetMaxDownload()) theApp.scheduler->SaveOriginals(); // <== Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle break;
void CemuleDlg::QuickSpeedUpload
case MP_QS_U90: thePrefs.SetMaxUpload((UINT)(thePrefs.GetMaxGraphUploadRate(true)*0.9)); break ; case MP_QS_U100: thePrefs.SetMaxUpload((UINT)thePrefs.GetMaxGraphUploadRate(true)); break ; // case MP_QS_UPC: thePrefs.SetMaxUpload(UNLIMITED); break ; case MP_QS_UP10: thePrefs.SetMaxUpload(GetRecMaxUpload()); break ; } theApp.scheduler->SaveOriginals(); // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle }
void CemuleDlg::QuickSpeedDownload
case MP_QS_D90: thePrefs.SetMaxDownload((UINT)(thePrefs.GetMaxGraphDownloadRate()*0.9)); break ; case MP_QS_D100: thePrefs.SetMaxDownload((UINT)thePrefs.GetMaxGraphDownloadRate()); break ; // case MP_QS_DC: thePrefs.SetMaxDownload(UNLIMITED); break ; } theApp.scheduler->SaveOriginals(); // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle }
void CMuleSystrayDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
thePrefs.SetMinUpload(m_nMinUpSpeedTxt); } theApp.scheduler->SaveOriginals(); // Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle CDialog::OnHScroll(nSBCode, nPos, pScrollBar); }
(This has actually already been fixed by SiRoB in the past.)
void CemuleDlg::OnTBBPressed(UINT id)
// Handle pressed thumbbar button void CemuleDlg::OnTBBPressed(UINT id) { // ==> Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle float fMaxUploadOld = thePrefs.GetMaxUpload(); float fMaxDownloadOld = thePrefs.GetMaxDownload(); // <== Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle switch (id) { case TBB_CONNECT: OnBnClickedConnect(); break; [...] case TBB_PREFERENCES: ShowPreferences(); break; } // ==> Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle if (id != IDC_PREFERENCES && (fMaxUploadOld != thePrefs.GetMaxUpload() || fMaxDownloadOld != thePrefs.GetMaxDownload())) theApp.scheduler->SaveOriginals(); // <== Don't reset Connection Settings for Webserver/CML/MM [Stulle] - Stulle }
(for 0.50a and onward)
It is pretty obvious that if the Scheduler is changing the actual values at this particular time we will lose the real originals but the exact same thing I am doing at more places is being done in CPPgConnections:OnApply so IMO it's fine. It is certainly fine for the Webserver because the Webserver allows you to set all values that the Scheduler regards as "originals".
Any comments on the code or reasoning?
Greetings,
Stulle
This post has been edited by Stulle: 17 April 2010 - 06:49 PM