Revisione protezione software only

git-svn-id: svn://10.65.10.50/branches/R_10_00@23129 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2015-07-10 14:58:39 +00:00
parent fc2de58aeb
commit 1d7113ae36
2 changed files with 29 additions and 30 deletions

View File

@ -386,7 +386,7 @@ XVTDLL void xvt_treeview_resume(WINDOW win);
XVTDLL void xvt_treeview_select_node(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN sel);
XVTDLL void xvt_treeview_set_node_bold(WINDOW win, XVT_TREEVIEW_NODE node, BOOLEAN bold);
XVTDLL void xvt_treeview_set_node_images(WINDOW win, XVT_TREEVIEW_NODE node,
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image);
XVT_IMAGE item_image, XVT_IMAGE collapsed_image, XVT_IMAGE expanded_image);
XVTDLL void xvt_treeview_set_node_string(WINDOW win, XVT_TREEVIEW_NODE node, const char* text);
XVTDLL void xvt_treeview_suspend(WINDOW win);

View File

@ -17,6 +17,7 @@ class TSSA_Pinger : public wxTimer
int m_nSerNo;
bool m_bRemote;
wxString m_strModule;
wxString _id, _ini;
protected:
virtual void Notify();
@ -24,13 +25,13 @@ protected:
bool IsRemote() const { return m_bRemote; }
bool IsMenu() const;
bool IsFreeModule(const wxString& mod) const;
int AddRef(const wxString& m, int nDelta = +1);
int DecRef(const wxString& m) { return AddRef(m, -1); }
wxString NormalizedModule(const char* m) const;
bool LoginProduct();
bool LogoutProduct();
const char* UserId() const;
public:
int Login(const char* module);
@ -42,20 +43,6 @@ public:
static TSSA_Pinger* _ssa_timer = NULL;
static const char* const _ssa_product = "CAMPO";
const char* TSSA_Pinger::UserId() const
{
static char id[256] = { 0 };
if (!*id)
{
const int sess = xvt_sys_get_session_id();
char user[64], host[64];
xvt_sys_get_user_name(user, sizeof(user));
xvt_sys_get_host_name(host, sizeof(host));
sprintf_s(id, sizeof(id), "%s@%s:%d", user, host, sess);
}
return id;
}
bool TSSA_Pinger::IsMenu() const
{
const wxFileName argv0 = __argv[0];
@ -63,21 +50,21 @@ bool TSSA_Pinger::IsMenu() const
}
void TSSA_Pinger::Notify()
{ SSA_Ping(UserId()); }
{ SSA_Ping(_id); }
bool TSSA_Pinger::LoginProduct()
{
bool bLoggedIn = IsRemote() && !IsMenu();
if (!bLoggedIn)
{
const int err = SSA_Login(UserId(), _ssa_product);
const int err = SSA_Login(_id, _ssa_product);
bLoggedIn = err == 0;
}
if (bLoggedIn && m_nSerNo < 0)
m_nSerNo = SSA_NumeroSerie(_ssa_product);
if (bLoggedIn && IsRemote() && IsMenu())
::WritePrivateProfileSection(UserId(), "\0\0", "./ssa.ini"); // Azzera tutti i conteggi dei moduli
::WritePrivateProfileSection(_ssa_product, "\0\0", _ini); // Azzera tutti i conteggi dei moduli
return bLoggedIn;
}
@ -87,7 +74,7 @@ bool TSSA_Pinger::LogoutProduct()
m_nSerNo = SSA_UTENTE_NON_LOGGATO;
if (IsRemote() && !IsMenu())
return true;
int err = SSA_Logout(UserId(), _ssa_product);
int err = SSA_Logout(_id, _ssa_product);
return err == 0;
}
@ -106,34 +93,36 @@ wxString TSSA_Pinger::NormalizedModule(const char* m) const
int TSSA_Pinger::AddRef(const wxString& module, int nDelta)
{
int nCount = xvt_sys_get_profile_int("./ssa.ini", UserId(), module, 0);
int nCount = xvt_sys_get_profile_int(_ini, _ssa_product, module, 0);
nCount += nDelta;
if (nCount < 0) nCount = 0;
xvt_sys_set_profile_int("./ssa.ini", UserId(), module, nCount);
xvt_sys_set_profile_int(_ini, _ssa_product, module, nCount);
return nCount;
}
bool TSSA_Pinger::IsFreeModule(const wxString& mod) const
{ return mod.IsEmpty() || mod=="ba" || mod=="pd" || mod=="ps"; }
int TSSA_Pinger::Login(const char* mod)
{
if (mod == NULL || *mod == '\0')
if (mod == NULL || *mod <= ' ')
return LoginProduct() ? Serial() : SSA_UTENTE_NON_LOGGATO;
const wxString module = NormalizedModule(mod);
if (module == "ba" || module == "pd" || module == "ps") // Base o personalizzazione
if (IsFreeModule(module)) // Base o personalizzazione
return 0;
if (IsRemote() && AddRef(module) > 1)
return 0;
const char* uid = UserId();
int err = SSA_ApriModulo(uid, module);
int err = SSA_ApriModulo(_id, module);
if (err == SSA_UTENTE_NON_LOGGATO) // ritenta!
{
LoginProduct();
err = SSA_ApriModulo(uid, module);
err = SSA_ApriModulo(_id, module);
}
if (err != 0 && *module >= 'a')
err = SSA_ApriModulo(uid, module.Upper());
err = SSA_ApriModulo(_id, module.Upper());
if (IsRemote() && err != 0)
DecRef(module);
@ -148,13 +137,13 @@ int TSSA_Pinger::Logout(const char* mod)
{
const wxString module = mod == NULL ? m_strModule : NormalizedModule(mod);
int err= 0;
bool cm = !module.IsEmpty() && module != "ba";
bool cm = !IsFreeModule(module);
if (cm)
{
if (IsRemote())
cm = DecRef(module) <= 0;
if (cm)
err = SSA_ChiudiModulo(UserId(), module);
err = SSA_ChiudiModulo(_id, module);
}
if (err == 0)
LogoutProduct();
@ -163,6 +152,16 @@ int TSSA_Pinger::Logout(const char* mod)
TSSA_Pinger::TSSA_Pinger()
{
wxFileName ini = xvt_fsys_get_campo_ini();
ini.SetName("ssacount"); ini.MakeAbsolute();
_ini = ini.GetFullPath();
const int sess = xvt_sys_get_session_id();
char user[64], host[64];
xvt_sys_get_user_name(user, sizeof(user));
xvt_sys_get_host_name(host, sizeof(host));
_id.Printf("%s@%s:%d", user, host, sess);
char ssaagent[128] = { 0 };
const int len = xvt_sys_get_profile_string("ssa.ini", "", "SSA-PORT", "", ssaagent, sizeof(ssaagent));
m_bRemote = len > 8;