From c79bb716e9972ea0b6e4da034db91354501be425 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 9 Feb 2010 15:32:59 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : authoriz.exe lurch.exe Ricompilazione Demo : [ ] Commento : Corretta gestione processi in autorun git-svn-id: svn://10.65.10.50/trunk@20092 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- server/authoriz.cpp | 2 +- server/baseserv.cpp | 70 ++++++++++++++++++++++++++------------------- server/baseserv.h | 3 +- server/lurch.cpp | 15 ++++++---- 4 files changed, 52 insertions(+), 38 deletions(-) diff --git a/server/authoriz.cpp b/server/authoriz.cpp index 61158bcc5..0a5819f15 100755 --- a/server/authoriz.cpp +++ b/server/authoriz.cpp @@ -946,7 +946,7 @@ bool TAuthorizationServer::Initialization() if (m_MaxTries < 8) m_MaxTries = 8; - const bool bTestAll = GetOemInt("OEM") == 0; + const bool bTestAll = IsAdvanced(); for (unsigned int i = 0; i < m_MaxTries; i++) { if (m_Dongle.Login(bTestAll)) diff --git a/server/baseserv.cpp b/server/baseserv.cpp index d2b2207ec..d2b8b6382 100755 --- a/server/baseserv.cpp +++ b/server/baseserv.cpp @@ -526,7 +526,7 @@ void TBaseServerApp::OnSocketEvent(wxSocketEvent& e) case wxSOCKET_LOST: if (m_bLogVerbose) WriteLog("--- Socket lost."); - if (GetOemInt("OEM") == 0) + if (IsAdvanced()) sock->Destroy(); break; default: @@ -637,52 +637,62 @@ bool TBaseServerApp::GetConfigBool(const wxChar* key, bool def, const wxChar* ap const wxString str = GetConfigString(key, "*", app); if (str != "*") val = (str[0u] == '1') || (str[0u] == 'X') || (str[0u] == 'Y') || (str.CmpNoCase("On") == 0); - return val; } int TBaseServerApp::GetDefaultPort() const +{ return GetConfigInt("Port", 3883); } + +#define OEM_INI wxT("../setup/oem.ini") + +int TBaseServerApp::GetOemInt(const wxChar* key, int def) const { - return GetConfigInt("Port", 3883); + static int _oem = -1; + +#ifdef __WXMSW__ + if (_oem < 0) + _oem = ::GetPrivateProfileInt("MAIN", "OEM", -1, OEM_INI); + if (_oem >= 0) + { + if (wxStrcmp(key, wxT("OEM")) != 0) + { + wxString str; str.Printf(wxT("OEM_%d"), _oem); + def = ::GetPrivateProfileInt(str, key, def, OEM_INI); + } + else + def = _oem; + } +#endif + + return def; } wxString TBaseServerApp::GetOemString(const wxChar* key, const wxChar* def) const { - static int _oem = -1; - wxString str; -#ifdef __WXMSW__ - if (_oem < 0) - _oem = ::GetPrivateProfileInt("MAIN", "OEM", 0, wxT("../setup/oem.ini")); - if (wxStrcmp(key, "OEM") != 0) + const int oem = GetOemInt("OEM", -1); + wxString str = def; + if (oem >= 0) { - wxChar value[512]; memset(value, 0, sizeof(value)); - str.Printf("OEM_%d", _oem); - ::GetPrivateProfileString(str, key, def, value, sizeof(value)-1, wxT("../setup/oem.ini")); - str = value; - } - else - str.Printf("%d", _oem); + if (wxStrcmp(key, "OEM") != 0) + { +#ifdef __WXMSW__ + wxChar value[512]; memset(value, 0, sizeof(value)); + str.Printf("OEM_%d", oem); + ::GetPrivateProfileString(str, key, def, value, sizeof(value)-1, OEM_INI); + str = value; #endif + } + else + str.Printf("%d", oem); + } return str; } -int TBaseServerApp::GetOemInt(const wxChar* key, int def) const -{ - wxString strDef; - if (def != 0) strDef.Printf("%d", def); - const wxString strVal = GetOemString(key, strDef); - return wxAtoi(strVal); -} - wxString TBaseServerApp::GetLogFileName() const -{ - return GetConfigString("LogFile"); -} +{ return GetConfigString("LogFile"); } wxString TBaseServerApp::GetDocumentRoot() const -{ - return GetConfigString("DocumentRoot", m_strPath); -} +{ return GetConfigString("DocumentRoot", m_strPath); } bool TBaseServerApp::OnInit() { diff --git a/server/baseserv.h b/server/baseserv.h index 1fdfce81f..59c57c452 100755 --- a/server/baseserv.h +++ b/server/baseserv.h @@ -115,7 +115,8 @@ protected: wxString GetOemString(const wxChar* key, const wxChar* def = wxEmptyString) const; int GetOemInt(const wxChar* key, int def = 0) const; - + bool IsAdvanced() const { return GetOemInt(wxT("OEM"), -1) == 0; } + public: // Utilities virtual const wxChar* GetAppName() const = 0; diff --git a/server/lurch.cpp b/server/lurch.cpp index 3cbeebd47..83651ef8b 100755 --- a/server/lurch.cpp +++ b/server/lurch.cpp @@ -296,7 +296,7 @@ void TLurchServer::GenerateFile(wxString& strFilename) wxString strHost; strHost << wxGetHostName() << wxT(":") << GetDefaultPort(); tr1.AddChild("td").AddEnclosedText(strHost); - if (GetOemInt("OEM") == 0) + if (IsAdvanced()) { TXmlItem& tr2 = panel.AddChild("tr"); tr2.AddChild("td").AddEnclosedText("Ping Frequency"); @@ -650,15 +650,18 @@ bool TLurchServer::Initialization() { const wxArrayString& arr = GetAutoRunList(); const size_t nAuto = arr.GetCount(); - if (nAuto > 0 && GetOemInt("OEM") == 0) + if (nAuto > 0) { for (size_t i = 0; i < nAuto; i++) StartProcess(arr[i]); - const int nFreq = GetConfigInt("PingFreq"); - if (nFreq > 0) + if (IsAdvanced()) { - m_PingTimer.Start(nFreq * 1000); // sec to msec - m_Semaphore.Post(); // GREEN! + const int nFreq = GetConfigInt("PingFreq"); + if (nFreq > 0) + { + m_PingTimer.Start(nFreq * 1000); // sec to msec + m_Semaphore.Post(); // GREEN! + } } } return true;