Official eMule-Board: Don't Reset Connection Settings Fix - Official eMule-Board

Jump to content


Page 1 of 1

Don't Reset Connection Settings Fix for setting limits via Webserver, commandline, MobileMule & more

#1 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 14 September 2009 - 10:55 PM

Hey guys,

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

I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

#2 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 10 October 2009 - 10:03 AM

added code to fix the same issue for System Menu and System Tray Menu.
I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

#3 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 28 March 2010 - 08:15 PM

added a fix for the tray icon menu (MuleSystrayDlg) and 0.50a windows 7 features.
I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

#4 User is offline   Stulle 

  • [Enter Mod] Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5738
  • Joined: 07-April 04

Posted 17 April 2010 - 06:51 PM

the fix for void CemuleDlg::OnTrayRButtonUp might have caused errors under some circumstances. it's now fixed to prevent crash on exit via tray icon.
I am an emule-web.de member and fan! Hate me or people will get suspicious about you! Ever wondered if it's all worth the trouble?

Posted Image

No, there will not be a new version of my mods. No, I do not want your PM. No, I am certain, use the board and quit sending PMs. No, I am not kidding, there will not be a new version of my mods just because of YOU asking for it!
0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users