Patch level : 10.0

Files correlati     : lurch authoriz
Ricompilazione Demo : [ ]
Commento            :
Corretta visualizzazione versione e patch


git-svn-id: svn://10.65.10.50/trunk@20140 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-02-18 09:09:13 +00:00
parent 0b70cb0150
commit f0f8949357
3 changed files with 95 additions and 58 deletions

View File

@ -15,7 +15,7 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// headers // headers
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include <wx/wxprec.h> #include <wx/wx.h>
#include "baseserv.h" #include "baseserv.h"
#include <wx/config.h> #include <wx/config.h>
@ -128,7 +128,7 @@ void TTaskBarIcon::Init()
{ {
wxInitAllImageHandlers(); wxInitAllImageHandlers();
wxImage img(strIcon); wxImage img(strIcon);
img.Rescale(32,32); img.Rescale(32,32/*,wxIMAGE_QUALITY_HIGH*/);
const wxBitmap bmp(img); const wxBitmap bmp(img);
icon.CopyFromBitmap(bmp); icon.CopyFromBitmap(bmp);
} }
@ -587,23 +587,60 @@ const wxString& TBaseServerApp::GetConfigName() const
return m_strIni; return m_strIni;
} }
void TBaseServerApp::SetConfigString(const wxChar* key, const wxChar* val, const wxChar* app) const wxString TBaseServerApp::GetConfigFileString(const wxChar* file, const wxChar* paragraph, const wxChar* key, const wxChar* def) const
{ {
wxString str;
if (file == NULL || *file <= ' ')
file = GetConfigName();
if (paragraph == NULL || *paragraph <= ' ')
paragraph = GetAppName();
#ifdef __WXMSW__ #ifdef __WXMSW__
if (app == NULL || *app == '\0') wxChar value[512]; memset(value, 0, sizeof(value));
app = GetAppName(); const int len = ::GetPrivateProfileString(paragraph, key, def, value, sizeof(value)-1, file);
::WritePrivateProfileString(app, key, val, GetConfigName()); str = len <= 0 ? def : value;
#else #else
wxFileConfig ini("", "", GetConfigName(), "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
str << '/' << paragraph;
ini.SetPath(str);
ini.Read(key, &str, def);
#endif
return str;
}
long TBaseServerApp::GetConfigFileInt(const wxChar* file, const wxChar* paragraph, const wxChar* key, long val) const
{
const wxString str = GetConfigFileString(file, paragraph, key, "*");
if (str != "*")
str.ToLong(&val);
return val;
}
void TBaseServerApp::SetConfigFileString(const wxChar* file, const wxChar* paragraph, const wxChar* key, const wxChar* val) const
{
if (file == NULL || *file <= ' ')
file = GetConfigName();
if (paragraph == NULL || *paragraph <= ' ')
paragraph = GetAppName();
#ifdef __WXMSW__
::WritePrivateProfileString(paragraph, key, val, file);
#else
wxFileConfig ini("", "", file, "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
wxString str; wxString str;
if (app == NULL || *app == '\0') str << '/' << paragraph;
app = GetAppName();
str << '/' << app;
ini.SetPath(str); ini.SetPath(str);
ini.Write(key, val); ini.Write(key, val);
#endif #endif
} }
void TBaseServerApp::SetConfigString(const wxChar* key, const wxChar* val, const wxChar* app) const
{
return SetConfigFileString(NULL, app, key, val);
}
void TBaseServerApp::SetConfigInt(const wxChar* key, int val, const wxChar* app) const void TBaseServerApp::SetConfigInt(const wxChar* key, int val, const wxChar* app) const
{ {
wxString str; str.Printf("%d", val); wxString str; str.Printf("%d", val);
@ -612,26 +649,12 @@ void TBaseServerApp::SetConfigInt(const wxChar* key, int val, const wxChar* app)
wxString TBaseServerApp::GetConfigString(const wxChar* key, const wxChar* def, const wxChar* app) const wxString TBaseServerApp::GetConfigString(const wxChar* key, const wxChar* def, const wxChar* app) const
{ {
wxString str; return GetConfigFileString(NULL, app, key, def);
if (app == NULL || *app == '\0')
app = GetAppName();
#ifdef __WXMSW__
wxChar value[512]; memset(value, 0, sizeof(value));
const int len = ::GetPrivateProfileString(app, key, def, value, sizeof(value)-1, GetConfigName());
str = len <= 0 ? def : value;
#else
wxFileConfig ini("", "", GetConfigName(), "", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH);
str << '/' << app;
ini.SetPath(str);
ini.Read(key, &str, def);
#endif
return str;
} }
int TBaseServerApp::GetConfigInt(const wxChar* key, int def, const wxChar* app) const int TBaseServerApp::GetConfigInt(const wxChar* key, int def, const wxChar* app) const
{ {
const wxString str = GetConfigString(key, "*", app); return GetConfigFileInt(NULL, app, key, def);
return str != "*" ? atoi(str) : def;
} }
bool TBaseServerApp::GetConfigBool(const wxChar* key, bool def, const wxChar* app) const bool TBaseServerApp::GetConfigBool(const wxChar* key, bool def, const wxChar* app) const
@ -650,22 +673,17 @@ int TBaseServerApp::GetDefaultPort() const
int TBaseServerApp::GetOemInt(const wxChar* key, int def) const int TBaseServerApp::GetOemInt(const wxChar* key, int def) const
{ {
static int _oem = -883; static int _oem = GetConfigFileInt(OEM_INI, "MAIN", "OEM", -1);
#ifdef __WXMSW__
if (_oem == -883)
_oem = ::GetPrivateProfileInt("MAIN", "OEM", -1, OEM_INI);
if (_oem >= 0) if (_oem >= 0)
{ {
if (wxStrcmp(key, wxT("OEM")) != 0) if (wxStrcmp(key, wxT("OEM")) != 0)
{ {
wxString str; str.Printf(wxT("OEM_%d"), _oem); wxString str; str.Printf(wxT("OEM_%d"), _oem);
def = ::GetPrivateProfileInt(str, key, def, OEM_INI); def = GetConfigFileInt(OEM_INI, str, key, def);
} }
else else
def = _oem; def = _oem;
} }
#endif
return def; return def;
} }
@ -678,12 +696,8 @@ wxString TBaseServerApp::GetOemString(const wxChar* key, const wxChar* def) cons
{ {
if (wxStrcmp(key, "OEM") != 0) if (wxStrcmp(key, "OEM") != 0)
{ {
#ifdef __WXMSW__
wxChar value[512]; memset(value, 0, sizeof(value));
str.Printf("OEM_%d", oem); str.Printf("OEM_%d", oem);
::GetPrivateProfileString(str, key, def, value, sizeof(value)-1, OEM_INI); str = GetConfigFileString(OEM_INI, str, key, def);
str = value;
#endif
} }
else else
str.Printf("%d", oem); str.Printf("%d", oem);
@ -691,10 +705,18 @@ wxString TBaseServerApp::GetOemString(const wxChar* key, const wxChar* def) cons
return str; return str;
} }
wxString TBaseServerApp::GetInstallString(const wxChar* key, const wxChar* module) const
{
if (module == NULL || *module <= ' ')
module = wxT("sr");
return GetConfigFileString(wxT("../install.ini"), module, key, wxEmptyString);
}
bool TBaseServerApp::IsAdvanced() const bool TBaseServerApp::IsAdvanced() const
{ {
const int nOEM = GetOemInt(wxT("OEM"), -1); const int nOEM = GetOemInt(wxT("OEM"), -1);
return nOEM==0 || nOEM>2; } return nOEM==0 || nOEM>2;
}
wxString TBaseServerApp::GetLogFileName() const wxString TBaseServerApp::GetLogFileName() const
{ return GetConfigString("LogFile"); } { return GetConfigString("LogFile"); }

View File

@ -92,7 +92,11 @@ private:
#ifdef wxHAS_TASK_BAR_ICON #ifdef wxHAS_TASK_BAR_ICON
TTaskBarIcon* m_Tray; TTaskBarIcon* m_Tray;
#endif #endif
wxString GetConfigFileString(const wxChar* file, const wxChar* paragraph, const wxChar* key, const wxChar* def) const;
void SetConfigFileString(const wxChar* file, const wxChar* paragraph, const wxChar* key, const wxChar* value) const;
long GetConfigFileInt(const wxChar* file, const wxChar* paragraph, const wxChar* key, long val) const;
protected: protected:
wxSingleInstanceChecker* m_SingleInstance; wxSingleInstanceChecker* m_SingleInstance;
@ -115,6 +119,8 @@ protected:
wxString GetOemString(const wxChar* key, const wxChar* def = wxEmptyString) const; wxString GetOemString(const wxChar* key, const wxChar* def = wxEmptyString) const;
int GetOemInt(const wxChar* key, int def = 0) const; int GetOemInt(const wxChar* key, int def = 0) const;
wxString GetInstallString(const wxChar* key, const wxChar* module = wxEmptyString) const;
bool IsAdvanced() const; bool IsAdvanced() const;
public: public:

View File

@ -31,14 +31,16 @@ protected:
TXmlItem& AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const; TXmlItem& AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const;
void EnumerateVariables(const wxString& strApp, wxArrayString& arr) const; void EnumerateVariables(const wxString& strApp, wxArrayString& arr) const;
const wxArrayString& GetServersList(); const wxArrayString& GetServersList() const ;
const wxArrayString& GetAutoRunList(); const wxArrayString& GetAutoRunList() const;
const TProcessHashMap& GetRunningServers() const { return m_hmProcMap; } const TProcessHashMap& GetRunningServers() const { return m_hmProcMap; }
bool PingProcess(const wxString& strApp); bool PingProcess(const wxString& strApp);
void StopProcess(const wxString& strApp); void StopProcess(const wxString& strApp);
wxString StartProcess(const wxString& strApp); wxString StartProcess(const wxString& strApp);
TXmlItem& AddTableRow(TXmlItem& table, const wxChar* prompt, const wxString& value) const;
public: public:
void GenerateFile(wxString& strFilename); void GenerateFile(wxString& strFilename);
bool IsMagicName(wxString& strFilename) const; bool IsMagicName(wxString& strFilename) const;
@ -163,7 +165,7 @@ void TLurchServer::OnEndProcess(wxProcessEvent& evt)
const wxChar* TLurchServer::GetAppName() const const wxChar* TLurchServer::GetAppName() const
{ return wxT("Lurch"); } { return wxT("Lurch"); }
const wxArrayString& TLurchServer::GetServersList() const wxArrayString& TLurchServer::GetServersList() const
{ {
if (m_aServers.IsEmpty()) if (m_aServers.IsEmpty())
{ {
@ -171,7 +173,7 @@ const wxArrayString& TLurchServer::GetServersList()
const size_t size = ini.GetSize(); const size_t size = ini.GetSize();
wxChar* buff = new wxChar[size]; wxChar* buff = new wxChar[size];
ini.Read(buff, size); ini.Read(buff, size);
const char* aperta = strchr(buff, '['); const char* aperta = strchr(buff, '[');
while (aperta != NULL) while (aperta != NULL)
{ {
@ -180,7 +182,7 @@ const wxArrayString& TLurchServer::GetServersList()
{ {
*chiusa = '\0'; *chiusa = '\0';
wxString str = aperta+1; wxString str = aperta+1;
m_aServers.Add(str); ((wxArrayString&)m_aServers).Add(str);
aperta = strchr(chiusa+1, '['); aperta = strchr(chiusa+1, '[');
} }
else else
@ -190,7 +192,7 @@ const wxArrayString& TLurchServer::GetServersList()
return m_aServers; return m_aServers;
} }
const wxArrayString& TLurchServer::GetAutoRunList() const wxArrayString& TLurchServer::GetAutoRunList() const
{ {
if (m_aAutoRun.IsEmpty()) if (m_aAutoRun.IsEmpty())
{ {
@ -199,13 +201,12 @@ const wxArrayString& TLurchServer::GetAutoRunList()
{ {
const bool bAutorun = GetConfigBool("Autorun", false, as[i]); const bool bAutorun = GetConfigBool("Autorun", false, as[i]);
if (bAutorun) if (bAutorun)
m_aAutoRun.Add(as[i]); ((wxArrayString&)m_aAutoRun).Add(as[i]);
} }
} }
return m_aAutoRun; return m_aAutoRun;
} }
TXmlItem& TLurchServer::AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const TXmlItem& TLurchServer::AddMiniForm(TXmlItem& tr, const wxChar* action, const wxChar* app, const wxChar* prompt) const
{ {
TXmlItem& td = tr.AddChild("td").SetAttr("width", "10%"); TXmlItem& td = tr.AddChild("td").SetAttr("width", "10%");
@ -225,6 +226,14 @@ TXmlItem& TLurchServer::AddMiniForm(TXmlItem& tr, const wxChar* action, const wx
return submit; return submit;
} }
TXmlItem& TLurchServer::AddTableRow(TXmlItem& table, const wxChar* prompt, const wxString& value) const
{
TXmlItem& tr = table.AddChild("tr");
tr.AddChild("td").AddEnclosedText(prompt);
tr.AddChild("td").AddEnclosedText(value);
return tr;
}
void TLurchServer::GenerateFile(wxString& strFilename) void TLurchServer::GenerateFile(wxString& strFilename)
{ {
TXmlItem html; TXmlItem html;
@ -288,21 +297,21 @@ void TLurchServer::GenerateFile(wxString& strFilename)
panel.SetAttr("border", "1"); panel.SetAttr("width", "100%"); panel.SetAttr("border", "1"); panel.SetAttr("width", "100%");
panel.AddChild("caption").AddEnclosedText("Options"); panel.AddChild("caption").AddEnclosedText("Options");
TXmlItem& tr0 = panel.AddChild("tr"); AddTableRow(panel, wxT("Working directory"), wxGetCwd());
tr0.AddChild("td").AddEnclosedText("Working directory");
tr0.AddChild("td").AddEnclosedText(wxGetCwd());
TXmlItem& tr1 = panel.AddChild("tr");
tr1.AddChild("td").AddEnclosedText("Host Name");
wxString strHost; strHost << wxGetHostName() << wxT(":") << GetDefaultPort(); wxString strHost; strHost << wxGetHostName() << wxT(":") << GetDefaultPort();
tr1.AddChild("td").AddEnclosedText(strHost); AddTableRow(panel, wxT("Host Name"), strHost);
const wxString strVersion = GetInstallString(wxT("Versione"));
wxString str; str.Printf(wxT("%04d / %5.2lf"), wxAtoi(strVersion.Left(4)), wxAtoi(strVersion.Mid(4))/100.0);
AddTableRow(panel, wxT("Version"), str);
AddTableRow(panel, wxT("Patch"), GetInstallString(wxT("Patch")));
AddTableRow(panel, wxT("Date"), GetInstallString(wxT("Data")));
if (IsAdvanced()) if (IsAdvanced())
{ {
TXmlItem& tr2 = panel.AddChild("tr");
tr2.AddChild("td").AddEnclosedText("Ping Frequency");
wxString strFreq; strFreq << m_PingTimer.GetInterval()/1000; wxString strFreq; strFreq << m_PingTimer.GetInterval()/1000;
tr2.AddChild("td").AddEnclosedText(strFreq); AddTableRow(panel, wxT("Ping Frequency"), strFreq);
} }
html.Save(strFilename); html.Save(strFilename);