Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : Migliorie varie sul frontend git-svn-id: svn://10.65.10.50/trunk@7679 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
4f99172ae0
commit
82ff5d5694
@ -49,7 +49,7 @@ static TFunctionName ftable[MAX_FUNC] =
|
||||
{ "DongleModules", f_DongleModules, 1 },
|
||||
{ "DongleNumber", f_DongleNumber, 1 },
|
||||
{ "DongleYear", f_DongleYear, 1 },
|
||||
{ "UserLogin", f_UserLogin, 0 },
|
||||
{ "UserLogin", f_UserLogin, 0 },
|
||||
{ "UserLogout", f_UserLogout, 0 },
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "connect.h"
|
||||
#include "server.h"
|
||||
|
||||
int CountPeerUser(TConnection& conn, void* pJolly)
|
||||
static int CountPeerUser(TConnection& conn, void* pJolly)
|
||||
{
|
||||
const CString& strPeerUser = *(CString*)pJolly;
|
||||
const int at = strPeerUser.Find('@');
|
||||
|
@ -43,7 +43,7 @@ BOOL CFrontEndDoc::OnNewDocument()
|
||||
return FALSE;
|
||||
|
||||
SetTitle("PRASSI");
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual BOOL DoSave(LPCTSTR lpszPathName, BOOL bReplace);
|
||||
virtual BOOL DoSave(LPCTSTR lpszPathName, BOOL bReplace);
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
|
Binary file not shown.
@ -2,24 +2,25 @@
|
||||
|
||||
[General Info]
|
||||
Version=1
|
||||
LastClass=CStatusDlg
|
||||
LastClass=CMainFrame
|
||||
LastTemplate=CDialog
|
||||
NewFileInclude1=#include "stdafx.h"
|
||||
NewFileInclude2=#include "FrontEnd.h"
|
||||
LastPage=0
|
||||
|
||||
ClassCount=6
|
||||
ClassCount=7
|
||||
Class1=CFrontEndApp
|
||||
Class2=CFrontEndDoc
|
||||
Class3=CFrontEndView
|
||||
Class4=CMainFrame
|
||||
|
||||
ResourceCount=3
|
||||
Resource1=IDR_MAINFRAME
|
||||
Resource1=IDD_ABOUTBOX
|
||||
Class5=CAboutDlg
|
||||
Resource2=IDD_STATUS
|
||||
Class6=CStatusDlg
|
||||
Resource3=IDD_ABOUTBOX
|
||||
Class7=TConnectionsDlg
|
||||
Resource3=IDR_MAINFRAME
|
||||
|
||||
[CLS:CFrontEndApp]
|
||||
Type=0
|
||||
@ -52,7 +53,7 @@ ImplementationFile=MainFrm.cpp
|
||||
Filter=T
|
||||
BaseClass=CFrameWnd
|
||||
VirtualFilter=fWC
|
||||
LastObject=ID_NOTEPAD
|
||||
LastObject=CMainFrame
|
||||
|
||||
|
||||
|
||||
@ -87,10 +88,11 @@ Command3=ID_EDIT_CLEAR_ALL
|
||||
Command4=ID_NOTEPAD
|
||||
Command5=ID_VIEW_TRACE
|
||||
Command6=ID_VIEW_STATUS
|
||||
Command7=ID_VIEW_TOOLBAR
|
||||
Command8=ID_VIEW_STATUS_BAR
|
||||
Command9=ID_APP_ABOUT
|
||||
CommandCount=9
|
||||
Command7=ID_VIEW_TREE
|
||||
Command8=ID_VIEW_TOOLBAR
|
||||
Command9=ID_VIEW_STATUS_BAR
|
||||
Command10=ID_APP_ABOUT
|
||||
CommandCount=10
|
||||
|
||||
[ACL:IDR_MAINFRAME]
|
||||
Type=1
|
||||
@ -112,7 +114,7 @@ CommandCount=13
|
||||
|
||||
[TB:IDR_MAINFRAME]
|
||||
Type=1
|
||||
Class=?
|
||||
Class=CMainFrame
|
||||
Command1=ID_FILE_SAVE_AS
|
||||
Command2=ID_VIEW_TRACE
|
||||
Command3=ID_EDIT_CLEAR_ALL
|
||||
@ -121,18 +123,6 @@ Command5=ID_APP_EXIT
|
||||
Command6=ID_APP_ABOUT
|
||||
CommandCount=6
|
||||
|
||||
[DLG:IDD_STATUS]
|
||||
Type=1
|
||||
Class=CStatusDlg
|
||||
ControlCount=7
|
||||
Control1=IDOK,button,1342242817
|
||||
Control2=IDC_STATIC,static,1342308352
|
||||
Control3=IDC_USERS,static,1342312448
|
||||
Control4=IDC_STATIC,static,1342308352
|
||||
Control5=IDC_CONNECTIONS,static,1342312448
|
||||
Control6=IDC_STATIC,static,1342308352
|
||||
Control7=IDC_PEERS,static,1342312448
|
||||
|
||||
[CLS:CStatusDlg]
|
||||
Type=0
|
||||
HeaderFile=StatDlg.h
|
||||
@ -142,3 +132,26 @@ Filter=D
|
||||
LastObject=CStatusDlg
|
||||
VirtualFilter=dWC
|
||||
|
||||
[CLS:TConnectionsDlg]
|
||||
Type=0
|
||||
HeaderFile=ConnDlg.h
|
||||
ImplementationFile=ConnDlg.cpp
|
||||
BaseClass=CDialog
|
||||
Filter=D
|
||||
LastObject=IDC_USERS
|
||||
VirtualFilter=dWC
|
||||
|
||||
[DLG:IDD_STATUS]
|
||||
Type=1
|
||||
Class=TConnectionsDlg
|
||||
ControlCount=9
|
||||
Control1=IDCANCEL,button,1342242816
|
||||
Control2=IDC_TREE,SysTreeView32,1350631424
|
||||
Control3=IDC_UPDATE,button,1342242816
|
||||
Control4=IDC_STATIC,static,1342308352
|
||||
Control5=IDC_USERS,static,1342312448
|
||||
Control6=IDC_STATIC,static,1342308352
|
||||
Control7=IDC_CONNECTIONS,static,1342312448
|
||||
Control8=IDC_STATIC,static,1342308352
|
||||
Control9=IDC_PEERS,static,1342312448
|
||||
|
||||
|
@ -172,21 +172,6 @@ int CFrontEndApp::ExitInstance()
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
|
||||
void CFrontEndApp::OnAppExit()
|
||||
{
|
||||
BOOL bCanExit = !GetServer().HasConnections();
|
||||
if (!bCanExit)
|
||||
{
|
||||
int nCode = AfxMessageBox("Ci sono ancora degli utenti collegati:\n"
|
||||
"Si desidera uscire ugualmete?",
|
||||
MB_YESNO | MB_ICONQUESTION);
|
||||
if (nCode == IDYES)
|
||||
bCanExit = TRUE;
|
||||
}
|
||||
if (bCanExit)
|
||||
CWinApp::OnAppExit();
|
||||
}
|
||||
|
||||
BOOL CAboutDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
@ -29,7 +29,6 @@ public:
|
||||
|
||||
//{{AFX_MSG(CFrontEndApp)
|
||||
afx_msg void OnAppAbout();
|
||||
afx_msg void OnAppExit();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
@ -114,7 +114,8 @@ BEGIN
|
||||
POPUP "&Visualizza"
|
||||
BEGIN
|
||||
MENUITEM "&Trace", ID_VIEW_TRACE
|
||||
MENUITEM "Stato del sistema...", ID_VIEW_STATUS
|
||||
MENUITEM "Numero utenti...", ID_VIEW_STATUS
|
||||
MENUITEM "Stato del sistema...", ID_VIEW_TREE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Barra degli st&rumenti", ID_VIEW_TOOLBAR
|
||||
MENUITEM "Barra di st&ato", ID_VIEW_STATUS_BAR
|
||||
@ -170,18 +171,21 @@ BEGIN
|
||||
LTEXT "Disco",IDC_STATIC,50,55,19,8
|
||||
END
|
||||
|
||||
IDD_STATUS DIALOGEX 0, 0, 152, 78
|
||||
IDD_STATUS DIALOGEX 0, 0, 267, 174
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Utenti del sistema"
|
||||
CAPTION "Connections"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,50,55,50,14
|
||||
LTEXT "Numero connessioni",IDC_STATIC,7,40,84,8
|
||||
LTEXT "0",IDC_USERS,111,23,34,10,SS_SUNKEN,WS_EX_RIGHT
|
||||
LTEXT "Numero utenti",IDC_STATIC,7,25,84,8
|
||||
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
|
||||
PUSHBUTTON "Close",IDCANCEL,210,153,50,14
|
||||
CONTROL "Tree1",IDC_TREE,"SysTreeView32",WS_BORDER | WS_TABSTOP,
|
||||
7,7,195,160
|
||||
PUSHBUTTON "Update Now",IDC_UPDATE,210,7,50,14
|
||||
LTEXT "Connessioni",IDC_STATIC,207,102,53,8
|
||||
LTEXT "0",IDC_USERS,207,76,53,10,SS_SUNKEN,WS_EX_RIGHT
|
||||
LTEXT "Numero utenti",IDC_STATIC,207,66,50,8
|
||||
LTEXT "0",IDC_CONNECTIONS,207,114,53,10,SS_SUNKEN,WS_EX_RIGHT
|
||||
LTEXT "Stazioni",IDC_STATIC,209,31,51,8
|
||||
LTEXT "0",IDC_PEERS,207,42,53,10,SS_SUNKEN,WS_EX_RIGHT
|
||||
END
|
||||
|
||||
|
||||
@ -246,9 +250,9 @@ BEGIN
|
||||
IDD_STATUS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 145
|
||||
RIGHTMARGIN, 260
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 69
|
||||
BOTTOMMARGIN, 167
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
@ -368,6 +372,7 @@ STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
ID_VIEW_TRACE "Logging degli eventi"
|
||||
ID_VIEW_STATUS "Mostra lo stato del sistema\nStato del sistema..."
|
||||
ID_VIEW_TREE "Mostra le connessioni al sistema\nConnessioni..."
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "FrontEnd.h"
|
||||
#include "FrontDoc.h"
|
||||
#include "FrontVw.h"
|
||||
#include "StatDlg.h"
|
||||
#include "Server.h"
|
||||
#include "Tracing.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
@ -27,8 +27,6 @@ BEGIN_MESSAGE_MAP(CFrontEndView, CTreeView)
|
||||
ON_UPDATE_COMMAND_UI(ID_EDIT_CLEAR_ALL, OnUpdateEditClearAll)
|
||||
ON_COMMAND(ID_VIEW_TRACE, OnViewTrace)
|
||||
ON_UPDATE_COMMAND_UI(ID_VIEW_TRACE, OnUpdateViewTrace)
|
||||
ON_COMMAND(ID_VIEW_STATUS, OnViewStatus)
|
||||
ON_UPDATE_COMMAND_UI(ID_VIEW_STATUS, OnUpdateViewStatus)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
@ -90,15 +88,15 @@ CFrontEndDoc* CFrontEndView::GetDocument() // non-debug version is inline
|
||||
|
||||
void CFrontEndView::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
|
||||
{
|
||||
CTreeCtrl& pTreeCtrl = GetTreeCtrl();
|
||||
pCmdUI->Enable(pTreeCtrl.GetCount() > 0);
|
||||
CTreeCtrl& rTreeCtrl = GetTreeCtrl();
|
||||
pCmdUI->Enable(rTreeCtrl.GetCount() > 0);
|
||||
}
|
||||
|
||||
void CFrontEndView::OnEditClearAll()
|
||||
{
|
||||
CWaitCursor HourGlass;
|
||||
CTreeCtrl& pTreeCtrl = GetTreeCtrl();
|
||||
pTreeCtrl.DeleteAllItems();
|
||||
CTreeCtrl& rTreeCtrl = GetTreeCtrl();
|
||||
rTreeCtrl.DeleteAllItems();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
@ -117,13 +115,3 @@ void CFrontEndView::OnUpdateViewTrace(CCmdUI* pCmdUI)
|
||||
pCmdUI->SetCheck(TracingEnabled());
|
||||
}
|
||||
|
||||
void CFrontEndView::OnViewStatus()
|
||||
{
|
||||
CStatusDlg dlg(this);
|
||||
dlg.DoModal();
|
||||
}
|
||||
|
||||
void CFrontEndView::OnUpdateViewStatus(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable();
|
||||
}
|
||||
|
@ -41,8 +41,6 @@ protected:
|
||||
afx_msg void OnUpdateEditClearAll(CCmdUI* pCmdUI);
|
||||
afx_msg void OnViewTrace();
|
||||
afx_msg void OnUpdateViewTrace(CCmdUI* pCmdUI);
|
||||
afx_msg void OnViewStatus();
|
||||
afx_msg void OnUpdateViewStatus(CCmdUI* pCmdUI);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "FrontEnd.h"
|
||||
#include "Server.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
#include "StatDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
@ -22,6 +24,9 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
ON_WM_CREATE()
|
||||
ON_UPDATE_COMMAND_UI(ID_NOTEPAD, OnUpdateNotepad)
|
||||
ON_COMMAND(ID_NOTEPAD, OnNotepad)
|
||||
ON_COMMAND(ID_VIEW_STATUS, OnViewStatus)
|
||||
ON_UPDATE_COMMAND_UI(ID_VIEW_STATUS, OnUpdateViewStatus)
|
||||
ON_WM_CLOSE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
@ -117,3 +122,25 @@ void CMainFrame::OnNotepad()
|
||||
CString cmd = "notepad";
|
||||
WinExec(cmd, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
void CMainFrame::OnViewStatus()
|
||||
{
|
||||
TConnectionsDlg dlg;
|
||||
dlg.DoModal();
|
||||
}
|
||||
|
||||
void CMainFrame::OnUpdateViewStatus(CCmdUI* pCmdUI)
|
||||
{
|
||||
pCmdUI->Enable();
|
||||
}
|
||||
|
||||
BOOL CMainFrame::OnQueryEndSession()
|
||||
{
|
||||
return GetServer().CanClose();
|
||||
}
|
||||
|
||||
void CMainFrame::OnClose()
|
||||
{
|
||||
if (GetServer().CanClose())
|
||||
CFrameWnd::OnClose();
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
public:
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
@ -38,7 +39,12 @@ protected:
|
||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
||||
afx_msg void OnUpdateNotepad(CCmdUI* pCmdUI);
|
||||
afx_msg void OnNotepad();
|
||||
afx_msg void OnViewStatus();
|
||||
afx_msg void OnUpdateViewStatus(CCmdUI* pCmdUI);
|
||||
afx_msg void OnClose();
|
||||
afx_msg BOOL OnQueryEndSession();
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
|
@ -16,19 +16,22 @@
|
||||
#define IDC_GRID 1009
|
||||
#define IDC_CONNECTIONS 1009
|
||||
#define IDC_PEERS 1010
|
||||
#define IDC_TREE 1011
|
||||
#define IDC_UPDATE 1012
|
||||
#define stc32 0x045f
|
||||
#define ID_BUTTON32772 32772
|
||||
#define ID_VIEW_TRACE 32773
|
||||
#define ID_NOTEPAD 32775
|
||||
#define ID_VIEW_STATUS 32776
|
||||
#define ID_VIEW_TREE 32778
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 134
|
||||
#define _APS_NEXT_COMMAND_VALUE 32778
|
||||
#define _APS_NEXT_CONTROL_VALUE 1010
|
||||
#define _APS_NEXT_RESOURCE_VALUE 135
|
||||
#define _APS_NEXT_COMMAND_VALUE 32779
|
||||
#define _APS_NEXT_CONTROL_VALUE 1013
|
||||
#define _APS_NEXT_SYMED_VALUE 105
|
||||
#endif
|
||||
#endif
|
||||
|
@ -292,7 +292,6 @@ BOOL TDongleServer::OnConnect(const CString& topic)
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
TConnection* TDongleServer::OnCreateConnection(DWORD id)
|
||||
{
|
||||
TConnection* c = NULL;
|
||||
@ -316,7 +315,8 @@ BOOL TDongleServer::OnRemoveConnection(DWORD id)
|
||||
CString strPeer;
|
||||
GetPeerName(id, strPeer);
|
||||
Trace(0, "Disconnecting %lu from %s", id, strPeer);
|
||||
return BASE_SERVER::OnRemoveConnection(id);
|
||||
BOOL ok = TSocketServer::OnRemoveConnection(id);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int CountUsers(TConnection& conn, void* pJolly)
|
||||
@ -368,9 +368,21 @@ unsigned short TDongleServer::Peers() const
|
||||
return nTotal;
|
||||
}
|
||||
|
||||
BOOL TDongleServer::CanClose() const
|
||||
{
|
||||
BOOL bCanExit = !HasConnections();
|
||||
if (!bCanExit)
|
||||
{
|
||||
int nCode = AfxMessageBox("Ci sono ancora degli utenti collegati:\n"
|
||||
"Si desidera uscire ugualmente?",
|
||||
MB_YESNO | MB_ICONQUESTION);
|
||||
bCanExit = nCode == IDYES;
|
||||
}
|
||||
return bCanExit;
|
||||
}
|
||||
|
||||
TDongleServer::TDongleServer()
|
||||
: BASE_SERVER("DONGLE")
|
||||
: TSocketServer("DONGLE")
|
||||
{
|
||||
_SerNo = 0xFFFF;
|
||||
_MaxUsers = 0;
|
||||
|
@ -1,22 +1,14 @@
|
||||
#ifndef __SERVER_H__
|
||||
#define __SERVER_H__
|
||||
|
||||
/*
|
||||
#ifndef __NETDDE_H__
|
||||
#include "netdde.h"
|
||||
#define BASE_SERVER TDDEServer
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifndef __NETSOCK_H__
|
||||
#include "NetSock.h"
|
||||
#endif
|
||||
#define BASE_SERVER TSocketServer
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// TDongleServer
|
||||
|
||||
class TDongleServer : public BASE_SERVER
|
||||
class TDongleServer : public TSocketServer
|
||||
{
|
||||
enum { MAX_MODULES = 256 };
|
||||
|
||||
@ -54,6 +46,8 @@ public:
|
||||
unsigned short Users() const;
|
||||
unsigned short Peers() const;
|
||||
|
||||
BOOL CanClose() const;
|
||||
|
||||
TDongleServer();
|
||||
virtual ~TDongleServer();
|
||||
};
|
||||
|
@ -1,9 +1,10 @@
|
||||
// StatDlg.cpp : implementation file
|
||||
// ConnDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Connect.h"
|
||||
#include "FrontEnd.h"
|
||||
|
||||
#include "Connect.h"
|
||||
#include "StatDlg.h"
|
||||
#include "Server.h"
|
||||
|
||||
@ -14,46 +15,141 @@ static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CStatusDlg dialog
|
||||
// TConnectionsDlg dialog
|
||||
|
||||
|
||||
CStatusDlg::CStatusDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CStatusDlg::IDD, pParent)
|
||||
TConnectionsDlg::TConnectionsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(TConnectionsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CStatusDlg)
|
||||
//{{AFX_DATA_INIT(TConnectionsDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CStatusDlg::DoDataExchange(CDataExchange* pDX)
|
||||
void TConnectionsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CStatusDlg)
|
||||
//{{AFX_DATA_MAP(TConnectionsDlg)
|
||||
DDX_Control(pDX, IDC_TREE, m_tree);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CStatusDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CStatusDlg)
|
||||
BEGIN_MESSAGE_MAP(TConnectionsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(TConnectionsDlg)
|
||||
ON_WM_CLOSE()
|
||||
ON_WM_TIMER()
|
||||
ON_BN_CLICKED(IDC_UPDATE, OnUpdateNow)
|
||||
ON_NOTIFY(TVN_KEYDOWN, IDC_TREE, OnKeydownUsers)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CStatusDlg message handlers
|
||||
// TConnectionsDlg message handlers
|
||||
|
||||
|
||||
BOOL CStatusDlg::OnInitDialog()
|
||||
static int add_to_tree(TConnection& rConnection, void* pJolly)
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
TDongleServer& srv = GetServer();
|
||||
const TPrassiConnection& conn = (const TPrassiConnection&)rConnection;
|
||||
CTreeCtrl& tree = *(CTreeCtrl*)pJolly;
|
||||
|
||||
for (HTREEITEM hPeer = tree.GetRootItem(); hPeer;
|
||||
hPeer = tree.GetNextSiblingItem(hPeer))
|
||||
{
|
||||
if (tree.GetItemText(hPeer) == conn.PeerName())
|
||||
break;
|
||||
}
|
||||
if (!hPeer)
|
||||
hPeer = tree.InsertItem(conn.PeerName());
|
||||
|
||||
for (HTREEITEM hUser = tree.GetChildItem(hPeer); hUser;
|
||||
hUser = tree.GetNextSiblingItem(hUser))
|
||||
{
|
||||
if (tree.GetItemText(hUser) == conn.User())
|
||||
break;
|
||||
}
|
||||
if (!hUser)
|
||||
{
|
||||
BOOL bNewPeer = !tree.ItemHasChildren(hPeer);
|
||||
hUser = tree.InsertItem(conn.User(), hPeer);
|
||||
if (bNewPeer)
|
||||
tree.Expand(hPeer, TVE_EXPAND);
|
||||
}
|
||||
|
||||
BOOL bNewUser = !tree.ItemHasChildren(hUser);
|
||||
HTREEITEM hApp = tree.InsertItem(conn.Application(), hUser);
|
||||
if (hApp) tree.SetItemData(hApp, conn.Id());
|
||||
|
||||
if (bNewUser)
|
||||
tree.Expand(hUser, TVE_EXPAND);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void TConnectionsDlg::UpdateStatus()
|
||||
{
|
||||
TDongleServer& srv = GetServer();
|
||||
const int nPeers = srv.Peers();
|
||||
const int nUsers = srv.Users();
|
||||
const int nConns = srv.Connections();
|
||||
const int nConnections = srv.Connections();
|
||||
SetDlgItemInt(IDC_PEERS, nPeers);
|
||||
SetDlgItemInt(IDC_USERS, nUsers);
|
||||
SetDlgItemInt(IDC_CONNECTIONS, nConns);
|
||||
SetDlgItemInt(IDC_CONNECTIONS, nConnections);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
m_tree.DeleteAllItems();
|
||||
srv.ForEachConnection(add_to_tree, &m_tree);
|
||||
}
|
||||
|
||||
BOOL TConnectionsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
UpdateStatus();
|
||||
m_nTimerId = SetTimer(1, 10000, NULL); // Ogni dieci secondi
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void TConnectionsDlg::OnClose()
|
||||
{
|
||||
KillTimer(m_nTimerId);
|
||||
CDialog::OnClose();
|
||||
}
|
||||
|
||||
void TConnectionsDlg::OnTimer(UINT nIDEvent)
|
||||
{
|
||||
if (m_nTimerId == nIDEvent)
|
||||
{
|
||||
UpdateStatus();
|
||||
}
|
||||
CDialog::OnTimer(nIDEvent);
|
||||
}
|
||||
|
||||
void TConnectionsDlg::OnUpdateNow()
|
||||
{
|
||||
UpdateStatus();
|
||||
}
|
||||
|
||||
void TConnectionsDlg::OnKeydownUsers(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*)pNMHDR;
|
||||
|
||||
if (pTVKeyDown->wVKey == VK_DELETE)
|
||||
{
|
||||
HTREEITEM hCurrent = m_tree.GetSelectedItem();
|
||||
if (hCurrent && !m_tree.ItemHasChildren(hCurrent))
|
||||
{
|
||||
DWORD nId = m_tree.GetItemData(hCurrent);
|
||||
int nCode = AfxMessageBox("Confermate la chiusura della connessione?",
|
||||
MB_YESNO | MB_ICONQUESTION);
|
||||
if (nCode == IDYES)
|
||||
{
|
||||
GetServer().RemoveConnection(nId);
|
||||
UpdateStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
@ -1,24 +1,32 @@
|
||||
// StatDlg.h : header file
|
||||
#ifndef __CONNDLG_H
|
||||
#define __CONNDLG_H
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
// ConnDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CStatusDlg dialog
|
||||
// TConnectionsDlg dialog
|
||||
|
||||
class CStatusDlg : public CDialog
|
||||
class TConnectionsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CStatusDlg(CWnd* pParent = NULL); // standard constructor
|
||||
TConnectionsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
void UpdateStatus();
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CStatusDlg)
|
||||
//{{AFX_DATA(TConnectionsDlg)
|
||||
enum { IDD = IDD_STATUS };
|
||||
CTreeCtrl m_tree;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CStatusDlg)
|
||||
//{{AFX_VIRTUAL(TConnectionsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
@ -27,8 +35,20 @@ public:
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CStatusDlg)
|
||||
//{{AFX_MSG(TConnectionsDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnClose();
|
||||
afx_msg void OnTimer(UINT nIDEvent);
|
||||
afx_msg void OnUpdateNow();
|
||||
afx_msg void OnKeydownUsers(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
UINT m_nTimerId;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CONNDLG_H__F6F3B1E2_90D7_11D2_B123_00A0C91DD6F1__INCLUDED_)
|
||||
|
@ -28,7 +28,7 @@ BOOL Trace(int level, const char* fmt, ...)
|
||||
ASSERT(pFrame);
|
||||
CTreeView* pTreeView = (CTreeView*)pFrame->GetActiveView();
|
||||
ASSERT(pTreeView);
|
||||
CTreeCtrl& pTreeCtrl = pTreeView->GetTreeCtrl();
|
||||
CTreeCtrl& rTreeCtrl = pTreeView->GetTreeCtrl();
|
||||
|
||||
char msg[256];
|
||||
va_list argptr;
|
||||
@ -36,8 +36,8 @@ BOOL Trace(int level, const char* fmt, ...)
|
||||
vsprintf(msg,fmt,argptr);
|
||||
va_end(argptr);
|
||||
|
||||
HTREEITEM hItem = pTreeCtrl.InsertItem(msg, 0, 0);
|
||||
HTREEITEM hItem = rTreeCtrl.InsertItem(msg);
|
||||
BOOL ok = hItem != NULL;
|
||||
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user