diff --git a/server/authoriz.cpp b/server/authoriz.cpp index 70843afbd..9bac49d6c 100755 --- a/server/authoriz.cpp +++ b/server/authoriz.cpp @@ -36,7 +36,8 @@ public: TUserInfo* AddConnection(wxSocketBase& sock, const wxChar* user, int session); TUserInfo* Find(wxSocketBase& sock, const wxChar* user, int session); void RemoveConnection(wxSocketBase& sock, const wxChar* user, int session); - void Kill(const wxChar* strUserAtHost); + bool Kill(const wxChar* strUserAtHost); + bool Kill(TUserInfo* ui); void KillSession(wxSocketBase& sock, int session); size_t GetCount() const { return size(); } @@ -86,45 +87,54 @@ TUserInfo* TUserTable::Find(wxSocketBase& sock, const wxChar* user, int session) return (*this)[strUserAtHost]; const wxString strHost = strUserAtHost.After('@'); - for( TUsersHashMap::iterator it = begin(); it != end(); ++it ) + for (TUsersHashMap::iterator it = begin(); it != end(); ++it) { TUserInfo* ui = it->second; - if (ui->m_strHost == strHost) + if (ui != NULL && ui->m_strHost == strHost) return ui; } return NULL; } +bool TUserTable::Kill(const wxChar* strUserAtHost) +{ + const int erased = erase(strUserAtHost); + return erased != 0; +} + +bool TUserTable::Kill(TUserInfo* ui) +{ + for (TUsersHashMap::iterator it = begin(); it != end(); ++it) + { + if (it->second == ui) + { + erase(it); + return true; + } + } + return false; +} + + void TUserTable::RemoveConnection(wxSocketBase& sock, const wxChar* user, int session) { TUserInfo* ui = Find(sock, user, session); - if (ui) + if (ui != NULL) { ui->m_nPrograms--; if (ui->m_nPrograms <= 0) - { - const wxString strUserAtHost = BuildKey(sock, user, session); - erase(strUserAtHost); - } + Kill(ui); } } -void TUserTable::Kill(const wxChar* strUserAtHost) -{ - erase(strUserAtHost); -} - void TUserTable::KillSession(wxSocketBase& sock, int session) { while (true) { TUserInfo* ui = Find(sock, NULL, session); if (ui != NULL) - { - const wxString strUserAtHost = BuildKey(sock, ui->m_strName.c_str(), session); - erase(strUserAtHost); - } + Kill(ui); else break; } @@ -343,22 +353,25 @@ void TAuthorizationServer::GenerateIndex(wxString& strFilename) TXmlItem& tr = title.AddChild("table").SetAttr("width", "40%").AddChild("tr"); TXmlItem& td = tr.AddChild("td").SetAttr("width", "30%"); - const bool hard = m_Dongle.hardware() == _dongle_hardlock; TXmlItem& img = td.AddChild("img"); + wxString strModel; switch (m_Dongle.hardware()) { - case _dongle_aladdin: - img.SetAttr("src", "aladdin.gif"); + case _dongle_xsec: + img.SetAttr("src", "xsec.gif"); + strModel = wxT("XSec"); break; case _dongle_hardlock: img.SetAttr("src", "hardlock.gif"); + strModel = wxT("Hardlock"); break; default: img.SetAttr("src", "eutron.gif"); + strModel = wxT("Eutron"); break; } - tr.AddChild("td").SetAttr("align", "center").AddChild("h1") << (hard ? "Hardlock EYE" : "Eutron Smartkey"); + tr.AddChild("td").SetAttr("align", "center").AddChild("h1") << strModel; } else { @@ -494,20 +507,23 @@ void TAuthorizationServer::GenerateUsers(wxString& strFilename) th.AddChild("th").SetAttr("width", "15%") << "Kill"; int nUser = 0; - for( TUsersHashMap::const_iterator it = m_Users.begin(); it != m_Users.end(); ++it ) + for (TUsersHashMap::const_iterator it = m_Users.begin(); it != m_Users.end(); ++it ) { const TUserInfo* ui = it->second; - TXmlItem& tr = table.AddChild("tr"); - tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%d", ++nUser); - tr.AddChild("td").AddChild("b") << ui->m_strName; - tr.AddChild("td") << ui->m_strHost; - tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%u", ui->m_nPrograms); - tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%H:%M:%S"); - tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%d-%m-%Y"); + if (ui != NULL) + { + TXmlItem& tr = table.AddChild("tr"); + tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%d", ++nUser); + tr.AddChild("td").AddChild("b") << ui->m_strName; + tr.AddChild("td") << ui->m_strHost; + tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%u", ui->m_nPrograms); + tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%H:%M:%S"); + tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%d-%m-%Y"); - wxString strKey; strKey << ui->m_strName << wxT("@") << ui->m_strHost; - wxString href = wxString::Format("kill.cgi?%s", strKey.c_str()); - AddLinkButton(tr.AddChild("td"), "Kill", href).SetAttr("width", "100%"); + wxString strKey; strKey << ui->m_strName << wxT("@") << ui->m_strHost; + wxString href = wxString::Format("kill.cgi?%s", strKey.c_str()); + AddLinkButton(tr.AddChild("td"), "Kill", href).SetAttr("width", "100%"); + } } body.AddChild("br"); @@ -986,8 +1002,9 @@ bool TAuthorizationServer::ProcessCommand(wxString cmd, wxSocketBase& outs) if (cmd.StartsWith("UserLogout")) { - bool ok = ProcessUserLogout(cmd, outs); - return ReturnBool(outs, ok); + ReturnBool(outs, true); // ATTENZIONE! Prima rispondo ok ... + ProcessUserLogout(cmd, outs); // ... poi chiudo la connessione + return true; } if (cmd.StartsWith("DongleInfo")) diff --git a/server/dongle.h b/server/dongle.h index 0e87ce380..35a12a4cc 100755 --- a/server/dongle.h +++ b/server/dongle.h @@ -5,8 +5,8 @@ #include #endif -enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_aladdin }; -enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _prassi_dongle, _procom_dongle }; +enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_xsec }; +enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _prassi_dongle }; enum { MAX_DONGLE_ASSIST = 8 }; class TBit_array : public wxObject