git-svn-id: svn://10.65.10.50/branches/R_10_00@22947 c028cbd2-c16b-5b4b-a496-9718f37d4682
98 lines
2.1 KiB
C++
98 lines
2.1 KiB
C++
#include "wxinc.h"
|
|
#include "gtSSA.h"
|
|
|
|
#include "../ssa/h/ssadll.h"
|
|
#include "../ssa/h/ssaerr.h"
|
|
|
|
#include <wx/filename.h>
|
|
|
|
class SSA_dongle : public wxObject
|
|
{
|
|
int m_nSerial;
|
|
wxString m_strUserID;
|
|
wxString m_strProduct, m_strModule;
|
|
|
|
protected:
|
|
const wxString& UserID();
|
|
int Login(const char* product, const char* module);
|
|
|
|
public:
|
|
int Login();
|
|
int Logout();
|
|
SSA_dongle() : m_nSerial(SSA_UTENTE_NON_LOGGATO) {}
|
|
} __SSA;
|
|
|
|
const wxString& SSA_dongle::UserID()
|
|
{
|
|
if (m_strUserID.IsEmpty())
|
|
{
|
|
const unsigned long sess = ::WTSGetActiveConsoleSessionId(); // Unknown modern way!
|
|
const wxString strUser = ::wxGetUserId();
|
|
const wxString strHost = ::wxGetHostName();
|
|
m_strUserID.Printf("%s@%s:%lu", (const char*)strUser, (const char*)strHost, sess);
|
|
}
|
|
return m_strUserID;
|
|
}
|
|
|
|
int SSA_dongle::Login(const char* product, const char* module)
|
|
{
|
|
if (!m_strProduct.IsEmpty())
|
|
Logout();
|
|
|
|
int err = SSA_Login(UserID(), product);
|
|
if (err == 0)
|
|
{
|
|
m_strProduct = product;
|
|
m_nSerial = SSA_NumeroSerie(product);
|
|
}
|
|
|
|
if (err == 0)
|
|
{
|
|
wxString m = module; m.MakeLower();
|
|
err = SSA_ApriModulo(UserID(), m);
|
|
if (err == SSA_MOD_NOTFOUND)
|
|
{
|
|
m.MakeUpper();
|
|
err = SSA_ApriModulo(UserID(), m);
|
|
}
|
|
|
|
if (err == 0)
|
|
m_strModule = m;
|
|
}
|
|
|
|
return err;
|
|
}
|
|
|
|
int SSA_dongle::Login()
|
|
{
|
|
const char* product = "CAMPO";
|
|
const char* module = "pa";
|
|
if (!wxFileName::FileExists("campo.ini"))
|
|
product = "WEBGATE";
|
|
return Login(product, module);
|
|
}
|
|
|
|
int SSA_dongle::Logout()
|
|
{
|
|
int err = 0;
|
|
if (!m_strModule.IsEmpty())
|
|
{
|
|
err = SSA_ChiudiModulo(UserID(), m_strModule);
|
|
if (err == 0)
|
|
m_strModule.Empty();
|
|
}
|
|
if (!m_strProduct.IsEmpty())
|
|
{
|
|
err = SSA_Logout(UserID(), m_strProduct);
|
|
if (err == 0)
|
|
{
|
|
m_nSerial = SSA_UTENTE_NON_LOGGATO;
|
|
m_strProduct.Empty();
|
|
m_strModule.Empty();
|
|
}
|
|
}
|
|
return err;
|
|
}
|
|
|
|
int SSA_Login() { return __SSA.Login(); }
|
|
int SSA_Logout() { return __SSA.Logout(); } |