Patch level : 05.054
Files correlati : Ricompilazione Demo : [ ] Commento : Corretto frontend che sbagliava a leggere i moduli attivi dalla chiave hardlock. Ora stampa anche i codici dei moduli attivati. git-svn-id: svn://10.65.10.50/trunk@7446 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
062476b25d
commit
6e30f9c6dd
@ -6,8 +6,8 @@
|
|||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TPrassiConnection
|
// TPrassiConnection
|
||||||
|
|
||||||
TPrassiConnection::TPrassiConnection(TLanManager* lm, DWORD id)
|
TPrassiConnection::TPrassiConnection(TLanManager* lm, DWORD id, const char* name)
|
||||||
: TConnection(lm, id), m_nFirm(0)
|
: TConnection(lm, id), m_strPeer(name), m_nFirm(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ BOOL TPrassiConnection::Trace(int level, const char* str) const
|
|||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
user = "";
|
user = "GUEST";
|
||||||
}
|
}
|
||||||
CString trc;
|
CString trc;
|
||||||
trc.Format("%-8s %s", user, str);
|
trc.Format("%-8s %s", user, str);
|
||||||
|
@ -12,6 +12,7 @@ class TPrassiConnection : public TConnection
|
|||||||
{
|
{
|
||||||
CString m_strUser;
|
CString m_strUser;
|
||||||
CString m_strApp;
|
CString m_strApp;
|
||||||
|
CString m_strPeer;
|
||||||
int m_nFirm;
|
int m_nFirm;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -32,8 +33,10 @@ public:
|
|||||||
BOOL SetFirm(int nFirm);
|
BOOL SetFirm(int nFirm);
|
||||||
|
|
||||||
const CString& User() const { return m_strUser; }
|
const CString& User() const { return m_strUser; }
|
||||||
|
const CString& Application() const { return m_strApp; }
|
||||||
|
const CString& PeerName() const { return m_strPeer; }
|
||||||
|
|
||||||
TPrassiConnection(TLanManager* lm, DWORD id);
|
TPrassiConnection(TLanManager* lm, DWORD id, const char* name);
|
||||||
virtual ~TPrassiConnection();
|
virtual ~TPrassiConnection();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,11 +3,20 @@
|
|||||||
#include "connect.h"
|
#include "connect.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
int CountUser(TConnection& conn, void* pJolly)
|
int CountPeerUser(TConnection& conn, void* pJolly)
|
||||||
{
|
{
|
||||||
const CString& user = *(CString*)pJolly;
|
const CString& strPeerUser = *(CString*)pJolly;
|
||||||
|
const int at = strPeerUser.Find('@');
|
||||||
|
const CString strUser = strPeerUser.Left(at);
|
||||||
|
|
||||||
const TPrassiConnection& c = (TPrassiConnection&)conn;
|
const TPrassiConnection& c = (TPrassiConnection&)conn;
|
||||||
return user.CompareNoCase(c.User()) == 0;
|
CString pu = c.User();
|
||||||
|
if (pu != strUser)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pu += "@";
|
||||||
|
pu += c.PeerName();
|
||||||
|
return strPeerUser != pu;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TPrassiConnection::DoUserLogin(const CString& user,
|
BOOL TPrassiConnection::DoUserLogin(const CString& user,
|
||||||
@ -18,24 +27,25 @@ BOOL TPrassiConnection::DoUserLogin(const CString& user,
|
|||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
m_strUser = "";
|
if (user != "******" && user != "GUEST")
|
||||||
int total = Server().ForEachConnection(CountUser, (void *)&user);
|
{
|
||||||
if (app == "ba0100")
|
CString security = GetIniString("Server", "Security", "0");
|
||||||
{
|
if (atoi(security) > 0)
|
||||||
if (user == "******")
|
{
|
||||||
ok = !pwd.IsEmpty();
|
CString strPeerUser = user; strPeerUser.MakeUpper();
|
||||||
else
|
strPeerUser += "@";
|
||||||
ok = total == 0 && !pwd.IsEmpty();
|
strPeerUser += PeerName();
|
||||||
}
|
|
||||||
else
|
int total = Server().ForEachConnection(CountPeerUser,
|
||||||
{
|
(void*)&strPeerUser);
|
||||||
ok = total == 1;
|
ok = total == 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
m_strUser = user; m_strUser.MakeUpper();
|
m_strUser = user; m_strUser.MakeUpper();
|
||||||
m_strApp = app;
|
m_strApp = app; m_strApp.MakeUpper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReturnBool(ok);
|
return ReturnBool(ok);
|
||||||
|
Binary file not shown.
@ -17,9 +17,9 @@ Class4=CMainFrame
|
|||||||
ResourceCount=3
|
ResourceCount=3
|
||||||
Resource1=IDR_MAINFRAME
|
Resource1=IDR_MAINFRAME
|
||||||
Class5=CAboutDlg
|
Class5=CAboutDlg
|
||||||
Resource2=IDD_ABOUTBOX
|
Resource2=IDD_STATUS
|
||||||
Class6=CStatusDlg
|
Class6=CStatusDlg
|
||||||
Resource3=IDD_STATUS
|
Resource3=IDD_ABOUTBOX
|
||||||
|
|
||||||
[CLS:CFrontEndApp]
|
[CLS:CFrontEndApp]
|
||||||
Type=0
|
Type=0
|
||||||
@ -124,12 +124,14 @@ CommandCount=6
|
|||||||
[DLG:IDD_STATUS]
|
[DLG:IDD_STATUS]
|
||||||
Type=1
|
Type=1
|
||||||
Class=CStatusDlg
|
Class=CStatusDlg
|
||||||
ControlCount=5
|
ControlCount=7
|
||||||
Control1=IDOK,button,1342242817
|
Control1=IDOK,button,1342242817
|
||||||
Control2=IDC_STATIC,static,1342308352
|
Control2=IDC_STATIC,static,1342308352
|
||||||
Control3=IDC_USERS,static,1342308352
|
Control3=IDC_USERS,static,1342312448
|
||||||
Control4=IDC_STATIC,static,1342308352
|
Control4=IDC_STATIC,static,1342308352
|
||||||
Control5=IDC_CONNECTIONS,static,1342308352
|
Control5=IDC_CONNECTIONS,static,1342312448
|
||||||
|
Control6=IDC_STATIC,static,1342308352
|
||||||
|
Control7=IDC_PEERS,static,1342312448
|
||||||
|
|
||||||
[CLS:CStatusDlg]
|
[CLS:CStatusDlg]
|
||||||
Type=0
|
Type=0
|
||||||
|
@ -96,6 +96,9 @@ BOOL CFrontEndApp::InitInstance()
|
|||||||
{
|
{
|
||||||
AfxMessageBox("Non e' possibile attivare due server contemporaneamente!",
|
AfxMessageBox("Non e' possibile attivare due server contemporaneamente!",
|
||||||
MB_ICONEXCLAMATION);
|
MB_ICONEXCLAMATION);
|
||||||
|
#ifndef NDEBUG
|
||||||
|
ok = StartServer();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
@ -160,7 +160,7 @@ CAPTION "Server PRASSI"
|
|||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
BEGIN
|
BEGIN
|
||||||
ICON IDR_MAINFRAME,IDC_STATIC,7,7,20,20
|
ICON IDR_MAINFRAME,IDC_STATIC,7,7,20,20
|
||||||
LTEXT "Server Versione 1.0",IDC_STATIC,49,7,119,10,SS_NOPREFIX |
|
LTEXT "Server Versione 1.5",IDC_STATIC,49,7,119,10,SS_NOPREFIX |
|
||||||
SS_SUNKEN
|
SS_SUNKEN
|
||||||
LTEXT "Disk space",IDC_DISK_SPACE,84,54,84,9,SS_SUNKEN
|
LTEXT "Disk space",IDC_DISK_SPACE,84,54,84,9,SS_SUNKEN
|
||||||
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
|
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
|
||||||
@ -170,16 +170,18 @@ BEGIN
|
|||||||
LTEXT "Disco",IDC_STATIC,50,55,19,8
|
LTEXT "Disco",IDC_STATIC,50,55,19,8
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_STATUS DIALOGEX 0, 0, 152, 71
|
IDD_STATUS DIALOGEX 0, 0, 152, 78
|
||||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
CAPTION "Utenti del sistema"
|
CAPTION "Utenti del sistema"
|
||||||
FONT 8, "MS Sans Serif"
|
FONT 8, "MS Sans Serif"
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "OK",IDOK,50,45,50,14
|
DEFPUSHBUTTON "OK",IDOK,50,55,50,14
|
||||||
LTEXT "Numero connessioni",IDC_STATIC,7,23,84,8
|
LTEXT "Numero connessioni",IDC_STATIC,7,40,84,8
|
||||||
LTEXT "0",IDC_USERS,111,7,34,10,0,WS_EX_RIGHT
|
LTEXT "0",IDC_USERS,111,23,34,10,SS_SUNKEN,WS_EX_RIGHT
|
||||||
LTEXT "Numero utenti",IDC_STATIC,7,7,84,8
|
LTEXT "Numero utenti",IDC_STATIC,7,25,84,8
|
||||||
LTEXT "0",IDC_CONNECTIONS,111,20,34,10,0,WS_EX_RIGHT
|
LTEXT "0",IDC_CONNECTIONS,111,38,34,10,SS_SUNKEN,WS_EX_RIGHT
|
||||||
|
LTEXT "Numero stazioni di lavoro",IDC_STATIC,7,9,84,8
|
||||||
|
LTEXT "0",IDC_PEERS,111,7,34,10,SS_SUNKEN,WS_EX_RIGHT
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
@ -190,8 +192,8 @@ END
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1998,1,3,75
|
FILEVERSION 1998,1,5,75
|
||||||
PRODUCTVERSION 1998,1,3,0
|
PRODUCTVERSION 1998,1,5,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@ -208,12 +210,12 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "AGA\0"
|
VALUE "CompanyName", "AGA\0"
|
||||||
VALUE "FileDescription", "Network Dongle Server \0"
|
VALUE "FileDescription", "Network Dongle Server \0"
|
||||||
VALUE "FileVersion", "1998, 1, 3, 75\0"
|
VALUE "FileVersion", "1998, 1, 5, 75\0"
|
||||||
VALUE "InternalName", "FRONTEND\0"
|
VALUE "InternalName", "FRONTEND\0"
|
||||||
VALUE "LegalCopyright", "Copyright © 1998\0"
|
VALUE "LegalCopyright", "Copyright © 1998\0"
|
||||||
VALUE "OriginalFilename", "FRONTEND.EXE\0"
|
VALUE "OriginalFilename", "FRONTEND.EXE\0"
|
||||||
VALUE "ProductName", "FRONTEND Applicazione\0"
|
VALUE "ProductName", "FRONTEND Applicazione\0"
|
||||||
VALUE "ProductVersion", "1998, 1, 3, 0\0"
|
VALUE "ProductVersion", "1998, 1, 5, 0\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
@ -246,7 +248,7 @@ BEGIN
|
|||||||
LEFTMARGIN, 7
|
LEFTMARGIN, 7
|
||||||
RIGHTMARGIN, 145
|
RIGHTMARGIN, 145
|
||||||
TOPMARGIN, 7
|
TOPMARGIN, 7
|
||||||
BOTTOMMARGIN, 59
|
BOTTOMMARGIN, 69
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
#endif // APSTUDIO_INVOKED
|
#endif // APSTUDIO_INVOKED
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#define IDC_USERS 1008
|
#define IDC_USERS 1008
|
||||||
#define IDC_GRID 1009
|
#define IDC_GRID 1009
|
||||||
#define IDC_CONNECTIONS 1009
|
#define IDC_CONNECTIONS 1009
|
||||||
|
#define IDC_PEERS 1010
|
||||||
#define stc32 0x045f
|
#define stc32 0x045f
|
||||||
#define ID_BUTTON32772 32772
|
#define ID_BUTTON32772 32772
|
||||||
#define ID_VIEW_TRACE 32773
|
#define ID_VIEW_TRACE 32773
|
||||||
|
@ -38,9 +38,9 @@ static char THIS_FILE[] = __FILE__;
|
|||||||
// @rdesc Ritorna il valore corrispondente alla chiave appartenente
|
// @rdesc Ritorna il valore corrispondente alla chiave appartenente
|
||||||
// ad una sezione del file di configurazione
|
// ad una sezione del file di configurazione
|
||||||
|
|
||||||
static CString GetIniString(LPCSTR sec, // @parm Sezione
|
CString GetIniString(LPCSTR sec, // @parm Sezione
|
||||||
LPCSTR key, // @parm Chiave
|
LPCSTR key, // @parm Chiave
|
||||||
LPCSTR def) // @parm Valore di default
|
LPCSTR def) // @parm Valore di default
|
||||||
{
|
{
|
||||||
// Nome del file .ini
|
// Nome del file .ini
|
||||||
static CString m_strIniFile;
|
static CString m_strIniFile;
|
||||||
@ -111,6 +111,7 @@ BOOL TDongleServer::ReadHardlockWords(unsigned short reg,
|
|||||||
{
|
{
|
||||||
for (unsigned short n = 0; n < num; n++)
|
for (unsigned short n = 0; n < num; n++)
|
||||||
HL_READ(reg+n, EYECAST &data[n]);
|
HL_READ(reg+n, EYECAST &data[n]);
|
||||||
|
HL_CODE(EYECAST data, 1);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@ -124,17 +125,16 @@ BOOL TDongleServer::HardlockLogin()
|
|||||||
unsigned char ref[9]; strcpy((char*)ref, REFKEY);
|
unsigned char ref[9]; strcpy((char*)ref, REFKEY);
|
||||||
unsigned char ver[9]; strcpy((char*)ver, VERKEY);
|
unsigned char ver[9]; strcpy((char*)ver, VERKEY);
|
||||||
|
|
||||||
const int status = HL_LOGIN(26952, LOCAL_DEVICE, ref, ver);
|
const int status = HL_LOGIN(26952, LOCAL_DEVICE, ref, ver);
|
||||||
|
|
||||||
Trace(-1, "Login Hardlock %s: %d",
|
Trace(-1, "Login Hardlock %s: %d",
|
||||||
status == STATUS_OK ? "OK" : "FALLITO", status);
|
status == STATUS_OK ? "OK" : "FALLITO", status);
|
||||||
|
|
||||||
_SerNo = 0xFFFF;
|
_SerNo = 0xFFFF;
|
||||||
if (status == STATUS_OK)
|
if (status == STATUS_OK)
|
||||||
{
|
{
|
||||||
Word Val[4] = { 0, 0, 0, 0 };
|
Word Val[4] = { 0, 0, 0, 0 };
|
||||||
ReadHardlockWords(0, 4, Val);
|
ReadHardlockWords(0, 4, Val);
|
||||||
HL_CODE(EYECAST Val, 1);
|
|
||||||
if (Val[0] == 0xFAE8)
|
if (Val[0] == 0xFAE8)
|
||||||
_SerNo = Val[1];
|
_SerNo = Val[1];
|
||||||
else
|
else
|
||||||
@ -143,7 +143,6 @@ BOOL TDongleServer::HardlockLogin()
|
|||||||
if (_SerNo != 0)
|
if (_SerNo != 0)
|
||||||
{
|
{
|
||||||
ReadHardlockWords(60, 4, Val);
|
ReadHardlockWords(60, 4, Val);
|
||||||
HL_CODE(EYECAST Val, 1);
|
|
||||||
_AssistanceYear = Val[0];
|
_AssistanceYear = Val[0];
|
||||||
_MaxUsers = Val[1];
|
_MaxUsers = Val[1];
|
||||||
|
|
||||||
@ -151,14 +150,16 @@ BOOL TDongleServer::HardlockLogin()
|
|||||||
for (unsigned short reg = 48; reg < 60; reg += 4)
|
for (unsigned short reg = 48; reg < 60; reg += 4)
|
||||||
{
|
{
|
||||||
ReadHardlockWords(reg, 4, Val);
|
ReadHardlockWords(reg, 4, Val);
|
||||||
HL_CODE(EYECAST Val, 1);
|
Val[0] ^= _SerNo;
|
||||||
|
Val[1] ^= _SerNo;
|
||||||
|
Val[2] ^= _SerNo;
|
||||||
memcpy(&_int_tab[index], Val, 3);
|
memcpy(&_int_tab[index], Val, 3);
|
||||||
index += 3;
|
index += 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return status == STATUS_OK;
|
return status == STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TDongleServer::EutronLogin()
|
BOOL TDongleServer::EutronLogin()
|
||||||
@ -167,45 +168,44 @@ BOOL TDongleServer::EutronLogin()
|
|||||||
memset(&_Eutron, 0, sizeof(_Eutron));
|
memset(&_Eutron, 0, sizeof(_Eutron));
|
||||||
_Eutron.net_command = NET_KEY_OPEN;
|
_Eutron.net_command = NET_KEY_OPEN;
|
||||||
|
|
||||||
const char* labels[2] = { "AGA.CAMPO", "2699DP" };
|
const char* labels[2] = { "AGA.CAMPO", "25EBAI" };
|
||||||
for (int k = 0; k < 2; k++)
|
for (int k = 0; k < 2; k++)
|
||||||
{
|
{
|
||||||
memset(_Eutron.label, 0, LABEL_LENGTH);
|
memset(_Eutron.label, 0, LABEL_LENGTH);
|
||||||
memcpy(_Eutron.label, labels[k], strlen(labels[k]));
|
memcpy(_Eutron.label, labels[k], strlen(labels[k]));
|
||||||
memset(_Eutron.password, 0, PASSWORD_LENGTH);
|
memset(_Eutron.password, 0, PASSWORD_LENGTH);
|
||||||
if (k == 0)
|
if (k == 0)
|
||||||
{
|
{
|
||||||
char pwd[PASSWORD_LENGTH];
|
char pwd[PASSWORD_LENGTH];
|
||||||
Encode(labels[k], pwd);
|
Encode(labels[k], pwd);
|
||||||
memcpy(_Eutron.password, pwd, strlen(pwd));
|
memcpy(_Eutron.password, pwd, strlen(pwd));
|
||||||
}
|
}
|
||||||
smartlink(&_Eutron);
|
smartlink(&_Eutron);
|
||||||
ok = _Eutron.status == ST_OK;
|
ok = _Eutron.status == ST_OK;
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
if (k == 1)
|
if (k == 1)
|
||||||
_SerNo = 0;
|
_SerNo = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Trace(-1, "Login Eutron %s: %d",
|
Trace(-1, "Login Eutron %s: %d", ok ? "OK" : "FALLITO", _Eutron.status);
|
||||||
ok ? "OK" : "FALLITO", _Eutron.status);
|
|
||||||
|
|
||||||
if (ok && _SerNo != 0)
|
if (ok && _SerNo != 0)
|
||||||
{
|
{
|
||||||
TEutronHeader eh;
|
TEutronHeader eh;
|
||||||
if (ReadEutronWords(0, sizeof(TEutronHeader)/2, (unsigned short*)&eh))
|
if (ReadEutronWords(0, sizeof(TEutronHeader)/2, (unsigned short*)&eh))
|
||||||
{
|
{
|
||||||
char serno[16];
|
char serno[16];
|
||||||
strncpy(serno, eh._serno, 8);
|
strncpy(serno, eh._serno, 8);
|
||||||
serno[8] = '\0';
|
serno[8] = '\0';
|
||||||
_SerNo = (unsigned long)atol(serno);
|
_SerNo = (unsigned long)atol(serno);
|
||||||
if (eh._max_users > 0)
|
if (eh._max_users > 0)
|
||||||
{
|
{
|
||||||
_MaxUsers = eh._max_users;
|
_MaxUsers = eh._max_users;
|
||||||
_AssistanceYear = eh._year_assist;
|
_AssistanceYear = eh._year_assist;
|
||||||
ReadEutronWords(16, 16, _int_tab);
|
ReadEutronWords(16, 16, _int_tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +237,32 @@ BOOL TDongleServer::Login()
|
|||||||
Trace(-1, "Numero di serie %u", _SerNo);
|
Trace(-1, "Numero di serie %u", _SerNo);
|
||||||
Trace(-1, "Anno assistenza %u", _AssistanceYear);
|
Trace(-1, "Anno assistenza %u", _AssistanceYear);
|
||||||
Trace(-1, "Numero utenti %u", _MaxUsers);
|
Trace(-1, "Numero utenti %u", _MaxUsers);
|
||||||
|
|
||||||
|
CString modules = "Moduli attivi: ";
|
||||||
|
if (_SerNo > 0 && _SerNo != 0xFFFF)
|
||||||
|
{
|
||||||
|
for (int n = 0; n < MAX_MODULES; n++)
|
||||||
|
{
|
||||||
|
const unsigned short index = n / 16;
|
||||||
|
if (index < 4)
|
||||||
|
{
|
||||||
|
if ((_int_tab[index] >> (n % 16)) & 0x1)
|
||||||
|
{
|
||||||
|
char buff[24];
|
||||||
|
sprintf(buff, "%d ", n+1);
|
||||||
|
modules += buff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_SerNo == 0)
|
||||||
|
modules += "Tutti";
|
||||||
|
else
|
||||||
|
modules += "Nessuno";
|
||||||
|
}
|
||||||
|
Trace(-1, modules);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@ -270,23 +296,30 @@ BOOL TDongleServer::OnConnect(const CString& topic)
|
|||||||
TConnection* TDongleServer::OnCreateConnection(DWORD id)
|
TConnection* TDongleServer::OnCreateConnection(DWORD id)
|
||||||
{
|
{
|
||||||
TConnection* c = NULL;
|
TConnection* c = NULL;
|
||||||
if (Users() < MaxUsers())
|
|
||||||
|
CString strPeer;
|
||||||
|
GetPeerName(id, strPeer);
|
||||||
|
|
||||||
|
const int n = GetPeerConnections(strPeer);
|
||||||
|
if (n > 0 || Peers() < MaxUsers())
|
||||||
{
|
{
|
||||||
Trace(0, "Connecting %lu", id);
|
Trace(0, "Connecting %lu from %s", id, strPeer);
|
||||||
c = new TPrassiConnection(this, id);
|
c = new TPrassiConnection(this, id, strPeer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Trace(0, "Refusing Connection %lu", id);
|
Trace(0, "Refusing Connection %lu from %s", id, strPeer);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL TDongleServer::OnRemoveConnection(DWORD id)
|
BOOL TDongleServer::OnRemoveConnection(DWORD id)
|
||||||
{
|
{
|
||||||
Trace(0, "Disconnecting %lu", id);
|
CString strPeer;
|
||||||
|
GetPeerName(id, strPeer);
|
||||||
|
Trace(0, "Disconnecting %lu from %s", id, strPeer);
|
||||||
return BASE_SERVER::OnRemoveConnection(id);
|
return BASE_SERVER::OnRemoveConnection(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CountUsers(TConnection& conn, void* pJolly)
|
static int CountUsers(TConnection& conn, void* pJolly)
|
||||||
{
|
{
|
||||||
CMapStringToOb& users = *(CMapStringToOb*)pJolly;
|
CMapStringToOb& users = *(CMapStringToOb*)pJolly;
|
||||||
const TPrassiConnection& c = (TPrassiConnection&)conn;
|
const TPrassiConnection& c = (TPrassiConnection&)conn;
|
||||||
@ -297,7 +330,6 @@ int CountUsers(TConnection& conn, void* pJolly)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned short TDongleServer::Users() const
|
unsigned short TDongleServer::Users() const
|
||||||
{
|
{
|
||||||
CMapStringToOb u;
|
CMapStringToOb u;
|
||||||
@ -306,6 +338,37 @@ unsigned short TDongleServer::Users() const
|
|||||||
return nTotal;
|
return nTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int CountPeerConnections(TConnection& conn, void* pJolly)
|
||||||
|
{
|
||||||
|
const CString& name = *(const CString*)pJolly;
|
||||||
|
const TPrassiConnection& c = (TPrassiConnection&)conn;
|
||||||
|
return c.PeerName() == name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TDongleServer::GetPeerConnections(const CString& strPeer) const
|
||||||
|
{
|
||||||
|
int nTotal = ((TDongleServer*)this)->ForEachConnection(CountPeerConnections, (void*)&strPeer);
|
||||||
|
return nTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int CountPeers(TConnection& conn, void* pJolly)
|
||||||
|
{
|
||||||
|
CMapStringToOb& users = *(CMapStringToOb*)pJolly;
|
||||||
|
const TPrassiConnection& c = (TPrassiConnection&)conn;
|
||||||
|
const CString& name = c.PeerName();
|
||||||
|
users.SetAt(name, NULL);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short TDongleServer::Peers() const
|
||||||
|
{
|
||||||
|
CMapStringToOb u;
|
||||||
|
((TDongleServer*)this)->ForEachConnection(CountPeers, &u);
|
||||||
|
unsigned short nTotal = (unsigned short)u.GetCount();
|
||||||
|
return nTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TDongleServer::TDongleServer()
|
TDongleServer::TDongleServer()
|
||||||
: BASE_SERVER("DONGLE")
|
: BASE_SERVER("DONGLE")
|
||||||
{
|
{
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
#ifndef __NETSOCK_H__
|
#ifndef __NETSOCK_H__
|
||||||
#include "NetSock.h"
|
#include "NetSock.h"
|
||||||
#define BASE_SERVER TSocketServer
|
|
||||||
#endif
|
#endif
|
||||||
|
#define BASE_SERVER TSocketServer
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// TDongleServer
|
// TDongleServer
|
||||||
@ -36,6 +36,8 @@ protected:
|
|||||||
BOOL ReadHardlockWords(unsigned short reg, unsigned short num, unsigned short* data);
|
BOOL ReadHardlockWords(unsigned short reg, unsigned short num, unsigned short* data);
|
||||||
BOOL ReadEutronWords(unsigned short reg, unsigned short num, unsigned short* data);
|
BOOL ReadEutronWords(unsigned short reg, unsigned short num, unsigned short* data);
|
||||||
|
|
||||||
|
int GetPeerConnections(const CString& strPeer) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned short SerialNumber() const
|
unsigned short SerialNumber() const
|
||||||
{ return _SerNo; }
|
{ return _SerNo; }
|
||||||
@ -50,11 +52,14 @@ public:
|
|||||||
{ return _MaxUsers; }
|
{ return _MaxUsers; }
|
||||||
|
|
||||||
unsigned short Users() const;
|
unsigned short Users() const;
|
||||||
|
unsigned short Peers() const;
|
||||||
|
|
||||||
TDongleServer();
|
TDongleServer();
|
||||||
virtual ~TDongleServer();
|
virtual ~TDongleServer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CString GetIniString(LPCSTR sec, LPCSTR key, LPCSTR def);
|
||||||
|
|
||||||
BOOL StartServer();
|
BOOL StartServer();
|
||||||
TDongleServer& GetServer();
|
TDongleServer& GetServer();
|
||||||
BOOL StopServer();
|
BOOL StopServer();
|
||||||
|
@ -47,8 +47,10 @@ BOOL CStatusDlg::OnInitDialog()
|
|||||||
CDialog::OnInitDialog();
|
CDialog::OnInitDialog();
|
||||||
|
|
||||||
TDongleServer& srv = GetServer();
|
TDongleServer& srv = GetServer();
|
||||||
|
const int nPeers = srv.Peers();
|
||||||
const int nUsers = srv.Users();
|
const int nUsers = srv.Users();
|
||||||
const int nConns = srv.Connections();
|
const int nConns = srv.Connections();
|
||||||
|
SetDlgItemInt(IDC_PEERS, nPeers);
|
||||||
SetDlgItemInt(IDC_USERS, nUsers);
|
SetDlgItemInt(IDC_USERS, nUsers);
|
||||||
SetDlgItemInt(IDC_CONNECTIONS, nConns);
|
SetDlgItemInt(IDC_CONNECTIONS, nConns);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user