LosaDev source snapshot 2019

This commit is contained in:
LosaDev committed 2026-11-07 13:30:45 +07:00
commit c198676e97
20588 files changed
+8812878

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
[zone1]
name=Beta
main=127.0.0.1:35434
login=127.0.0.1:35434
[zone2]
name=LiveZone
main=127.0.0.1:35434
login=127.0.0.1:35434
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LS_MonitorClient", "LS_MonitorClient\LS_MonitorClient.vcxproj", "{420FC80A-9842-42AE-8999-C7B2633C7E78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{420FC80A-9842-42AE-8999-C7B2633C7E78}.Debug|Win32.ActiveCfg = Debug|Win32
{420FC80A-9842-42AE-8999-C7B2633C7E78}.Debug|Win32.Build.0 = Debug|Win32
{420FC80A-9842-42AE-8999-C7B2633C7E78}.Release|Win32.ActiveCfg = Release|Win32
{420FC80A-9842-42AE-8999-C7B2633C7E78}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,347 @@
// AnnounceDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "AnnounceDlg.h"
#include "afxdialogex.h"
#include "Network/Protocol.h"
// CAnnounceDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CAnnounceDlg, CDialogEx)
CAnnounceDlg::CAnnounceDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CAnnounceDlg::IDD, pParent)
, m_parent(NULL)
, m_count(0)
{
}
CAnnounceDlg::~CAnnounceDlg()
{
}
void CAnnounceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_ANNOUNCE, m_editAnnounce);
DDX_Control(pDX, IDC_EDIT_USERID, m_editUserID);
DDX_Control(pDX, IDC_EDIT_INTERVAL, m_interval);
DDX_Control(pDX, IDC_LIST_KICKUSERID, m_userList);
DDX_Control(pDX, IDC_LIST_ANNOUNCE, m_announceList);
}
BEGIN_MESSAGE_MAP(CAnnounceDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_ANNOUNCE, &CAnnounceDlg::OnBnClickedButtonAnnounce)
ON_BN_CLICKED(IDC_BUTTON_KICK, &CAnnounceDlg::OnBnClickedButtonKickout)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON_COMMONRESET, &CAnnounceDlg::OnBnClickedButtonReset)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_KICKUSERID, &CAnnounceDlg::OnLvnItemchangedListKickuserid)
ON_BN_CLICKED(IDC_BUTTON_PRACTICE, &CAnnounceDlg::OnBnClickedButtonPractice)
END_MESSAGE_MAP()
// CAnnounceDlg 메시지 처리기입니다.
void CAnnounceDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
void CAnnounceDlg::OnBnClickedButtonAnnounce()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
KillTimer(1);
CString count;
m_interval.GetWindowText(count);
m_count = atoi(count);
if(m_count <= 0)
{
m_count = 1;
}
if(m_count > 1)
{
int delay = m_announceList.GetItemCount() * 20000;
SetTimer(1, delay, NULL);
}
else
{
DoAnnounce();
}
MessageBox(_T("Completed"), _T("ANNOUNCE"), MB_OK);
}
void CAnnounceDlg::OnBnClickedButtonKickout()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CString userId;
int count = m_userList.GetItemCount();
for(int i = 0 ; i < count ; i++)
{
userId = m_userList.GetItemText(i, 0);
if(!userId.IsEmpty())
{
m_parent->RequestKickUser(userId);
}
}
MessageBox(_T("Completed"), _T("KICK OUT"), MB_OK);
}
void CAnnounceDlg::OnBnClickedButtonPractice()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CString userId;
int count = m_userList.GetItemCount();
for(int i = 0 ; i < count ; i++)
{
userId = m_userList.GetItemText(i, 0);
if(!userId.IsEmpty())
{
m_parent->RequestPractice(userId);
}
}
MessageBox(_T("Completed"), _T("PRACTICE OUT"), MB_OK);
}
BOOL CAnnounceDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
InitList();
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CAnnounceDlg::InitList()
{
m_userList.DeleteAllItems();
m_userList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_userList.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 120);
m_announceList.DeleteAllItems();
m_announceList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_announceList.InsertColumn(0, _T("Announcement"), LVCFMT_LEFT, 275);
}
void CAnnounceDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
if(1 == nIDEvent)
{
DoAnnounce();
--m_count;
if(m_count <= 0)
{
KillTimer(1);
TRACE("Announce End\n");
}
}
CDialogEx::OnTimer(nIDEvent);
}
void CAnnounceDlg::OnDropUserFiles(CString file)
{
m_userList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertUserID(line);
}
}
}
}
void CAnnounceDlg::OnDropAnnounceFiles(CString file)
{
m_announceList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertAnnounce(line);
}
}
}
}
void CAnnounceDlg::InsertUserID(CString userId)
{
if(userId.GetLength() == 0) return;
m_userList.InsertItem(m_userList.GetItemCount(), userId);
}
void CAnnounceDlg::InsertAnnounce(CString announce)
{
if(announce.GetLength() == 0) return;
m_announceList.InsertItem(m_announceList.GetItemCount(), announce);
}
void CAnnounceDlg::DoAnnounce()
{
CString userId;
CString announce;
m_editUserID.GetWindowText(userId);
int count = m_announceList.GetItemCount();
for(int i = 0 ; i < count ; i++)
{
announce = m_announceList.GetItemText(i, 0);
if(!announce.IsEmpty())
{
int msgType = userId.IsEmpty() ? ANNOUNCE_TYPE_ALL : ANNOUNCE_TYPE_ONE;
m_parent->RequestAnnounce(msgType, userId, announce);
TRACE("[%d]Announce : %s\n", m_count, announce);
}
}
}
BOOL CAnnounceDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(WM_DROPFILES == pMsg->message)
{
if(m_userList.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropUserFiles( file );
}
}
else if(m_announceList.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropAnnounceFiles( file );
}
}
}
else if(WM_KEYDOWN == pMsg->message )
{
if(VK_RETURN == pMsg->wParam)
{
if(m_editUserID.GetSafeHwnd() == pMsg->hwnd)
{
CString userId;
m_editUserID.GetWindowText(userId);
m_editUserID.SetWindowText(_T(""));
InsertUserID(userId);
}
else if(m_editAnnounce.GetSafeHwnd() == pMsg->hwnd)
{
CString itemCode;
m_editAnnounce.GetWindowText(itemCode);
m_editAnnounce.SetWindowText(_T(""));
InsertAnnounce(itemCode);
}
return TRUE;
}
else if(VK_DELETE == pMsg->wParam)
{
if(m_userList.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_userList.GetSelectedCount();
if(count > 0) //kyg 여기에 루프 추가
{
DeleteListItem(m_userList);
}
}
else if(m_announceList.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_announceList.GetSelectedCount();
if(count > 0)
{
DeleteListItem(m_announceList);
}
}
return TRUE;
}
}
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
void CAnnounceDlg::OnBnClickedButtonReset()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
KillTimer(1);
m_userList.DeleteAllItems();
m_announceList.DeleteAllItems();
}
void CAnnounceDlg::OnLvnItemchangedListKickuserid(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
//m_userList.GetItemState()
*pResult = 0;
}
void CAnnounceDlg::DeleteListItem(CListCtrl& m_List)
{
int index = -1;
POSITION pos = m_List.GetFirstSelectedItemPosition();
while(pos)
{
int index = m_List.GetNextSelectedItem(pos);
m_List.DeleteItem(index);
pos = m_List.GetFirstSelectedItemPosition();
}
}
@@ -0,0 +1,58 @@
#pragma once
#include "afxwin.h"
#include "afxcmn.h"
class CZoneDialog;
// CAnnounceDlg 대화 상자입니다.
class CAnnounceDlg : public CDialogEx
{
DECLARE_DYNAMIC(CAnnounceDlg)
public:
CAnnounceDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CAnnounceDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_ANNOUNCE_DIALOG };
public:
void Startup(CZoneDialog* parent);
void InitList();
protected:
void OnDropUserFiles(CString file);
void OnDropAnnounceFiles(CString file);
void InsertUserID(CString userId);
void InsertAnnounce(CString announce);
void DoAnnounce();
protected:
CZoneDialog* m_parent;
int m_count;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonAnnounce();
afx_msg void OnBnClickedButtonKickout();
CEdit m_editAnnounce;
CEdit m_editUserID;
virtual BOOL OnInitDialog();
CEdit m_interval;
afx_msg void OnTimer(UINT_PTR nIDEvent);
CListCtrl m_userList;
CListCtrl m_announceList;
virtual BOOL PreTranslateMessage(MSG* pMsg);
void DeleteListItem(CListCtrl& m_List);
afx_msg void OnBnClickedButtonReset();
afx_msg void OnLvnItemchangedListKickuserid(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedButtonPractice();
};
@@ -0,0 +1,75 @@
// AuthDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "AuthDlg.h"
#include "afxdialogex.h"
// CAuthDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CAuthDlg, CDialogEx)
CAuthDlg::CAuthDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CAuthDlg::IDD, pParent)
{
}
CAuthDlg::~CAuthDlg()
{
}
void CAuthDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_ID, m_editID);
DDX_Control(pDX, IDC_EDIT_PWD, m_editPWD);
}
BEGIN_MESSAGE_MAP(CAuthDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_AUTH, &CAuthDlg::OnBnClickedButtonAuth)
END_MESSAGE_MAP()
// CAuthDlg 메시지 처리기입니다.
void CAuthDlg::OnBnClickedButtonAuth()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_editID.GetWindowText(m_ID);
m_editPWD.GetWindowText(m_PWD);
if(m_ID.IsEmpty() || m_PWD.IsEmpty())
{
EndDialog(IDCANCEL);
}
else
EndDialog(IDOK);
}
void CAuthDlg::GetText(CString& ID, CString& PWD)
{
ID = m_ID;
PWD = m_PWD;
}
BOOL CAuthDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(WM_KEYDOWN == pMsg->message )
{
if(VK_RETURN == pMsg->wParam)
{
OnBnClickedButtonAuth();
return TRUE;
}
}
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
@@ -0,0 +1,33 @@
#pragma once
#include "afxwin.h"
// CAuthDlg 대화 상자입니다.
class CAuthDlg : public CDialogEx
{
DECLARE_DYNAMIC(CAuthDlg)
public:
CAuthDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CAuthDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_AUTH_DIALOG };
public:
void GetText(CString& ID, CString& PWD);
protected:
CString m_ID, m_PWD;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CEdit m_editID;
CEdit m_editPWD;
afx_msg void OnBnClickedButtonAuth();
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
@@ -0,0 +1,521 @@
// BlockDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "BlockDlg.h"
#include "afxdialogex.h"
// CBlockDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CBlockDlg, CDialogEx)
CBlockDlg::CBlockDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CBlockDlg::IDD, pParent)
{
}
CBlockDlg::~CBlockDlg()
{
}
void CBlockDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control( pDX, IDC_LIST_BLOCK_PUBLICID, m_userList );
DDX_Control( pDX, IDC_LIST_BLOCK_NOTE, m_noteList );
DDX_Control( pDX, IDC_EDIT_BLOCK_PUBLICID, m_editPublicID );
DDX_Control( pDX, IDC_EDIT_BLOCK_NOTE, m_editBlockNote );
DDX_Control( pDX, IDC_COMBO_LIMITTIME, m_timeCombo );
DDX_Control( pDX, IDC_COMBO_LEVEL, m_levelCombo );
}
BEGIN_MESSAGE_MAP(CBlockDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_BLOCK_RESET, &CBlockDlg::OnBnClickedButtonBlockReset)
ON_BN_CLICKED(IDC_BUTTON_BLOCK_BLOCK, &CBlockDlg::OnBnClickedButtonBlockBlock)
ON_BN_CLICKED(IDC_BUTTON_BLOCK_UNBLOCK, &CBlockDlg::OnBnClickedButtonBlockUnblock)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_BLOCK_NOTE, &CBlockDlg::OnLvnItemchangedListBlockNote)
ON_CBN_SELCHANGE(IDC_COMBO_LIMITTIME, &CBlockDlg::OnCbnSelchangeComboTime)
ON_CBN_SELCHANGE(IDC_COMBO_LEVEL, &CBlockDlg::OnCbnSelchangeComboLevel)
END_MESSAGE_MAP()
// CBlockDlg 메시지 처리기입니다.
BOOL CBlockDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
InitList();
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CBlockDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
void CBlockDlg::InitList()
{
m_userList.DeleteAllItems();
m_userList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_userList.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 104);
m_noteList.DeleteAllItems();
m_noteList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_noteList.InsertColumn(0, _T("Note"), LVCFMT_LEFT, 194);
// 내용
OnDropNoteFiles(_T("./blockNote.txt"));
// 기간
InsertBlockTime(_T("-- Time --"));
InsertBlockTime(_T("1 Day"));
InsertBlockTime(_T("3 Days"));
InsertBlockTime(_T("5 Days"));
InsertBlockTime(_T("10 Days"));
InsertBlockTime(_T("30 Days"));
InsertBlockTime(_T("90 Days"));
InsertBlockTime(_T("Infinite"));
ResetTimeComboBox();
// 등급
InsertBlockLevel(_T("-- Level --"));
InsertBlockLevel(_T("Caution"));
InsertBlockLevel(_T("Limitation"));
InsertBlockLevel(_T("Block"));
InsertBlockLevel(_T("Unblock"));
ResetLevelComboBox();
}
void CBlockDlg::InsertPublicID(CString PublicID)
{
if( PublicID.GetLength() == 0 ) return ;
m_userList.InsertItem( m_userList.GetItemCount(), PublicID );
}
void CBlockDlg::InsertBlockNote(CString note)
{
if( note.GetLength() == 0 ) return ;
m_noteList.InsertItem( m_noteList.GetItemCount(), note );
}
void CBlockDlg::InsertBlockTime(CString limitTime)
{
if( limitTime.GetLength() == 0 ) return ;
m_timeCombo.InsertString( m_timeCombo.GetCount(), limitTime );
}
void CBlockDlg::InsertBlockLevel(CString level)
{
if( level.GetLength() == 0 ) return ;
m_levelCombo.InsertString( m_levelCombo.GetCount(), level );
}
void CBlockDlg::OnDropUserFiles(CString file)
{
m_userList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertPublicID(line);
}
}
}
}
void CBlockDlg::OnDropNoteFiles(CString file)
{
m_noteList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertBlockNote(line);
}
}
}
}
BlockInfo* CBlockDlg::GetSelectUserInfo(uint index)
{
// 사용 안함
//if( m_userList.GetSelectedCount() <= 0 )
// return NULL;
//POSITION pos = m_userList.GetFirstSelectedItemPosition();
//while( (pos) && (index > 0) )
//{
// m_userList.GetNextSelectedItem( pos );
// index--;
//}
//if( pos )
//{
// int userListindex = m_userList.GetNextSelectedItem(pos);
// if( userListindex != -1 )
// {
// CString userId = m_userList.GetItemText( userListindex, 0 );
// POSITION find = m_blockUserInfo.Find( BlockInfo(userId) );
//
// if( !find )
// return NULL;
// return &m_blockUserInfo.GetAt(find);
// }
//}
return NULL;
}
void CBlockDlg::SelectListItem(CListCtrl& list, CString item)
{
// 사용안함
//LVFINDINFOA find;
//find.flags = LVFI_STRING;
//find.psz = item;
//int index = list.FindItem( &find );
//if( index != -1 )
//{
// list.SetItemState( index,
// LVIS_SELECTED,
// LVIS_SELECTED);
//}
//else
//{
// for(int i = 0 ; i < list.GetItemCount() ; i++)
// {
// list.SetItemState( i, 0, LVIS_SELECTED );
// }
//}
//list.Invalidate(true);
}
void CBlockDlg::SetUserInfoNote(CString note)
{
if( note.GetLength() == 0 ) return ;
m_blockUserInfo.blockNote = note;
}
void CBlockDlg::SetUserInfoTime(CString limitTime)
{
m_blockUserInfo.limitTime = limitTime;
}
void CBlockDlg::SetUserInfoLevel(int level)
{
m_blockUserInfo.level = level;
}
void CBlockDlg::ResetUserInfoNote(CString note)
{
m_blockUserInfo.blockNote == note;
m_blockUserInfo.blockNote.Empty();
}
void CBlockDlg::ResetNoteListCtrl()
{
for( int i = 0 ; i < m_noteList.GetItemCount() ; i++ )
{
if( m_noteList.GetItemState( i, LVIS_SELECTED ) == LVIS_SELECTED )
{
m_noteList.SetItemState( i, 0, LVIS_SELECTED );
m_noteList.SetItemState( i, 0, LVIS_FOCUSED );
break;
}
}
}
BOOL CBlockDlg::PreTranslateMessage(MSG* pMsg)
{
switch( pMsg->message )
{
case WM_DROPFILES:
{
if( m_userList.GetSafeHwnd() == pMsg->hwnd )
{
uint dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropUserFiles( file );
}
}
else if( m_noteList.GetSafeHwnd() == pMsg->hwnd )
{
uint dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropNoteFiles( file );
}
}
}
break;
case WM_KEYDOWN:
{
if( VK_RETURN == pMsg->wParam )
{
if( m_editPublicID.GetSafeHwnd() == pMsg->hwnd )
{
CString publicID;
m_editPublicID.GetWindowText( publicID );
m_editPublicID.SetWindowText( _T("") );
InsertPublicID(publicID);
m_userList.EnsureVisible( m_userList.GetItemCount()-1, FALSE );
}
else if( m_editBlockNote.GetSafeHwnd() == pMsg->hwnd )
{
CString blockNote;
m_editBlockNote.GetWindowText( blockNote );
m_editBlockNote.SetWindowText( _T("") );
InsertBlockNote( blockNote );
m_noteList.EnsureVisible( m_noteList.GetItemCount()-1, FALSE );
}
return TRUE;
}
else if (VK_DELETE == pMsg->wParam )
{
if( m_userList.GetSafeHwnd() == pMsg->hwnd )
{
int index = -1;
POSITION pos = m_userList.GetFirstSelectedItemPosition();
while(pos)
{
index = m_userList.GetNextSelectedItem( pos );
m_userList.DeleteItem( index );
pos = m_userList.GetFirstSelectedItemPosition();
}
m_timeCombo.SelectString( 0, m_blockUserInfo.limitTime );
m_levelCombo.SetCurSel( m_blockUserInfo.level );
}
else if( m_noteList.GetSafeHwnd() == pMsg->hwnd )
{
int index = -1;
POSITION pos = m_noteList.GetFirstSelectedItemPosition();
while(pos)
{
index = m_noteList.GetNextSelectedItem( pos );
CString delstr = m_noteList.GetItemText(index, 0);
ResetUserInfoNote(delstr);
m_noteList.DeleteItem( index );
pos = m_noteList.GetFirstSelectedItemPosition();
}
}
return TRUE;
}
}
break;
}
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
void CBlockDlg::OnBnClickedButtonBlockReset()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_userList.DeleteAllItems();
SelectListItem( m_noteList, _T("") );
m_blockUserInfo.Clear();
ResetNoteListCtrl();
ResetTimeComboBox();
ResetLevelComboBox();
}
void CBlockDlg::OnBnClickedButtonBlockBlock()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if( !m_parent ) return;
if( m_userList.GetItemCount() == 0 )
{
MessageBox(_T("UserList is Empty!!"), _T("BLOCK"), MB_OK);
return ;
}
if( m_blockUserInfo.level == BLOCKTYPE_UNBLOCK )
return OnBnClickedButtonBlockUnblock();
if( !CheckBlockUserInfoList() )
return ;
CString publicID;
int64 limitTime = GetTime( m_blockUserInfo.limitTime ) * 3600;
for(int i = 0 ; i < m_userList.GetItemCount() ; i++)
{
publicID = m_userList.GetItemText( i, 0 );
m_parent->RequestUserBlock( publicID,
m_blockUserInfo.blockNote,
limitTime,
m_blockUserInfo.level );
}
m_parent->WriteLogDlg( _T("[Block] Request UserBlock") );
MessageBox(_T("Completed"), _T("BLOCK"), MB_OK);
}
void CBlockDlg::OnBnClickedButtonBlockUnblock()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if( !m_parent ) return ;
if( m_userList.GetItemCount() == 0 )
{
MessageBox(_T("UserList is Empty!!"), _T("BLOCK"), MB_OK);
return ;
}
CString publicID;
for(int i = 0 ; i < m_userList.GetItemCount() ; i++)
{
publicID = m_userList.GetItemText( i, 0 );
m_parent->RequestUserUnblock( publicID );
}
m_parent->WriteLogDlg( _T("[Block] Request UserUnblock") );
MessageBox(_T("Completed"), _T("UNBLOCK"), MB_OK);
}
void CBlockDlg::OnLvnItemchangedListBlockNote(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
if( !( ( pNMLV->uChanged == LVIF_STATE ) && ( pNMLV->uNewState == (LVIS_SELECTED | LVIS_FOCUSED) ) ) )
return ;
CString note = m_noteList.GetItemText( pNMLV->iItem, 0 );
SetUserInfoNote( note );
}
BOOL CBlockDlg::CheckBlockUserInfoList()
{
if( m_blockUserInfo.blockNote.IsEmpty() )
{
MessageBox(_T("Note is Unselected!!"), _T("BLOCK"), MB_OK);
return FALSE;
}
if( m_blockUserInfo.limitTime.IsEmpty() ||
m_blockUserInfo.limitTime == _T("-- Time --"))
{
MessageBox(_T("Time is Unselected!!"), _T("BLOCK"), MB_OK);
return FALSE;
}
if( m_blockUserInfo.level <= 0 )
{
MessageBox(_T("Level is Unselected!!"), _T("BLOCK"), MB_OK);
return FALSE;
}
return TRUE;
}
int CBlockDlg::GetTime(CString limitTime)
{
CString timeToken;
int findIndex = 0, tokenIndex = 0;
findIndex = limitTime.Find( _T("Hour") );
if( findIndex != -1 )
{
timeToken = limitTime.Tokenize(_T("Hour"), tokenIndex);
return _ttoi(timeToken.GetBuffer( timeToken.GetLength() ));
}
findIndex = 0, tokenIndex = 0;
findIndex = limitTime.Find( _T("Day") );
if( findIndex != -1 )
{
timeToken = limitTime.Tokenize(_T("Day"), tokenIndex);
return _ttoi(timeToken.GetBuffer( timeToken.GetLength() )) * 24;
}
findIndex = 0, tokenIndex = 0;
findIndex = limitTime.Find( _T("Week") );
if( findIndex != -1 )
{
timeToken = limitTime.Tokenize(_T("Week"), tokenIndex);
return _ttoi(timeToken.GetBuffer( timeToken.GetLength() )) * 24 * 7;
}
findIndex = 0, tokenIndex = 0;
findIndex = limitTime.Find( _T("Month") );
if( findIndex != -1 )
{
timeToken = limitTime.Tokenize(_T("Month"), tokenIndex);
return _ttoi(timeToken.GetBuffer( timeToken.GetLength() )) * 24 * 30;
}
findIndex = 0, tokenIndex = 0;
findIndex = limitTime.Find( _T("Year") );
if( findIndex != -1 )
{
timeToken = limitTime.Tokenize(_T("Year"), tokenIndex);
return _ttoi(timeToken.GetBuffer( timeToken.GetLength() )) * 24 * 365;
}
return 50 * 24 * 365;
}
void CBlockDlg::OnCbnSelchangeComboTime()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
int select = m_timeCombo.GetCurSel();
CString limitTime;
m_timeCombo.GetLBText(select, limitTime);
SetUserInfoTime( limitTime );
}
void CBlockDlg::OnCbnSelchangeComboLevel()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
int select = m_levelCombo.GetCurSel();
SetUserInfoLevel( select );
}
@@ -0,0 +1,99 @@
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
class CZoneDialog;
struct BlockInfo
{
CString blockNote;
CString limitTime;
int level;
BlockInfo()
{
Clear();
}
void Clear()
{
blockNote.Empty();
limitTime.Empty();
level = 0;
}
};
// CBlockDlg 대화 상자입니다.
class CBlockDlg : public CDialogEx
{
DECLARE_DYNAMIC(CBlockDlg)
public:
CBlockDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CBlockDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_BLOCK_DIALOG };
public:
void Startup(CZoneDialog* parent);
protected:
void InitList();
void InsertPublicID(CString publicID);
void InsertBlockNote(CString note);
void InsertBlockTime(CString limitTime);
void InsertBlockLevel(CString level);
void OnDropUserFiles(CString file);
void OnDropNoteFiles(CString file);
BlockInfo* GetSelectUserInfo(uint nIndex = 0);
void SelectListItem(CListCtrl& list, CString item);
void SetUserInfoNote(CString note);
void SetUserInfoTime(CString limitTime);
void SetUserInfoLevel(int level);
void ResetUserInfoNote(CString note);
void ResetNoteListCtrl();
void ResetTimeComboBox() { m_timeCombo.SetCurSel( 0 ); }
void ResetLevelComboBox() { m_levelCombo.SetCurSel( 0 ); }
BOOL CheckBlockUserInfoList();
int GetTime(CString limitTime);
protected:
CZoneDialog* m_parent;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CListCtrl m_userList;
CListCtrl m_noteList;
CComboBox m_timeCombo;
CComboBox m_levelCombo;
CEdit m_editPublicID;
CEdit m_editBlockNote;
BlockInfo m_blockUserInfo;
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedButtonBlockReset();
afx_msg void OnBnClickedButtonBlockBlock();
afx_msg void OnBnClickedButtonBlockUnblock();
afx_msg void OnLvnItemchangedListBlockNote(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnCbnSelchangeCombo1();
afx_msg void OnCbnSelchangeComboTime();
afx_msg void OnCbnSelchangeComboLevel();
};
@@ -0,0 +1,104 @@
// CSDialog.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "CSDialog.h"
#include "WinMessage.h"
#include "afxdialogex.h"
// CCSDialog 대화 상자입니다.
IMPLEMENT_DYNAMIC(CCSDialog, CDialogEx)
CCSDialog::CCSDialog(CWnd* pParent /*=NULL*/)
: CDialogEx(CCSDialog::IDD, pParent), m_parent(NULL)
{
}
CCSDialog::~CCSDialog()
{
}
void CCSDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_CSLOG, m_csLog);
DDX_Control(pDX, IDC_EDIT_CHANGEVERSION, m_changeVersion);
DDX_Control(pDX, IDC_EDIT_VERSION, m_version);
}
BEGIN_MESSAGE_MAP(CCSDialog, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_LOADCS, &CCSDialog::OnBnClickedButtonLoadCS)
ON_BN_CLICKED(IDC_BUTTON_SHOWCS, &CCSDialog::OnBnClickedButtonShowCS)
END_MESSAGE_MAP()
// CCSDialog 메시지 처리기입니다.
void CCSDialog::Startup(CZoneDialog* dlg)
{
m_parent = dlg;
ShowWindow(SW_HIDE);
}
void CCSDialog::OnBnClickedButtonLoadCS()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_parent->PostMessage(WM_COMMAND, IDC_SERVICE_LOADCS, NULL);
}
void CCSDialog::OnBnClickedButtonShowCS()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_parent->PostMessage(WM_COMMAND, IDC_SERVICE_SHOWCS, NULL);
}
BOOL CCSDialog::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
m_csLog.ResetContent();
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CCSDialog::Log(const char *format, ...)
{
TCHAR buffer[2048];
va_list marker;
va_start( marker, format );
_vstprintf_s( buffer, _countof(buffer), format, marker );
va_end( marker );
if(m_csLog.GetCount() > 100)
{
m_csLog.DeleteString(0);
}
m_csLog.AddString( buffer );
m_csLog.SetTopIndex( m_csLog.GetCount() - 1 );
}
void CCSDialog::GetVersion(CString& version, CString& change)
{
m_version.GetWindowText(version);
m_changeVersion.GetWindowText(change);
}
BOOL CCSDialog::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
@@ -0,0 +1,41 @@
#pragma once
#include "afxwin.h"
class CZoneDialog;
// CCSDialog 대화 상자입니다.
class CCSDialog : public CDialogEx
{
DECLARE_DYNAMIC(CCSDialog)
public:
CCSDialog(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CCSDialog();
// 대화 상자 데이터입니다.
enum { IDD = IDD_CS_DIALOG };
public:
void Startup(CZoneDialog* dlg);
void Log(const char *format, ...);
void GetVersion(CString& version, CString& change);
protected:
CZoneDialog* m_parent;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CListBox m_csLog;
CEdit m_changeVersion;
CEdit m_version;
afx_msg void OnBnClickedButtonLoadCS();
afx_msg void OnBnClickedButtonShowCS();
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
@@ -0,0 +1,339 @@
// CompensationDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "CompensationDlg.h"
#include "afxdialogex.h"
#include <atltime.h>
#include "ZoneDialog.h"
// CCompensationDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CCompensationDlg, CDialogEx)
CCompensationDlg::CCompensationDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CCompensationDlg::IDD, pParent)
{
}
CCompensationDlg::~CCompensationDlg()
{
}
void CCompensationDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ITEM_COMPENSATION, m_compensationList);
DDX_Control(pDX, IDC_LIST_ENDDATE, m_endDate);
DDX_Control(pDX, IDC_EDIT_COMPENSATION, m_editCompensationCode);
DDX_Control(pDX, IDC_EDIT_ENDDATE, m_editEndDate);
}
BEGIN_MESSAGE_MAP(CCompensationDlg, CDialogEx)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_ITEM_COMPENSATION, &CCompensationDlg::OnLvnItemchangedItemCompensation)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_ENDDATE, &CCompensationDlg::OnLvnItemchangedListEnddate)
ON_BN_CLICKED(IDC_BUTTON_RESET, &CCompensationDlg::OnBnClickedButtonReset)
ON_BN_CLICKED(IDC_INSERT, &CCompensationDlg::OnBnClickedInsert)
END_MESSAGE_MAP()
// CCompensationDlg 메시지 처리기입니다.
void CCompensationDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
void CCompensationDlg::OnLvnItemchangedItemCompensation(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
}
void CCompensationDlg::OnLvnItemchangedListEnddate(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
}
void CCompensationDlg::OnBnClickedButtonReset()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_compensationList.DeleteAllItems();
m_endDate.DeleteAllItems();
}
BOOL CCompensationDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
m_compensationList.DeleteAllItems();
m_compensationList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_compensationList.InsertColumn(0, _T("PresentType"), LVCFMT_LEFT, 60);
m_compensationList.InsertColumn(1, _T("Value1"), LVCFMT_LEFT, 75);
m_compensationList.InsertColumn(2, _T("Value2"), LVCFMT_LEFT, 75);
m_endDate.DeleteAllItems();
m_endDate.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_endDate.InsertColumn(0, _T("EndDate"), LVCFMT_LEFT, 180);
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
BOOL CCompensationDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(WM_DROPFILES == pMsg->message)
{
if(m_compensationList.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropItemFiles( file );
}
}
else if(m_endDate.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropEndDateFiles( file );
}
}
}
else if(WM_KEYDOWN == pMsg->message )
{
if(VK_RETURN == pMsg->wParam)
{
if(m_editCompensationCode.GetSafeHwnd() == pMsg->hwnd)
{
CString itemCode;
m_editCompensationCode.GetWindowText(itemCode);
m_editCompensationCode.SetWindowText(_T(""));
InsertItemCode(itemCode);
}
else if(m_editEndDate.GetSafeHwnd() == pMsg->hwnd)
{
CString itemCount;
m_editEndDate.GetWindowText(itemCount);
m_editEndDate.SetWindowText(_T(""));
InsertEndDate(itemCount);
}
return TRUE;
}
else if(VK_DELETE == pMsg->wParam)
{
if(m_compensationList.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_compensationList.GetSelectedCount();
if(count > 0) //kyg 여기에 루프 추가
{
DeleteListItem(m_compensationList);
}
}
else if(m_endDate.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_endDate.GetSelectedCount();
if(count > 0)
{
DeleteListItem(m_endDate);
}
}
return TRUE;
}
}
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
void CCompensationDlg::InsertItemCode(CString itemCode)
{
if( itemCode.GetLength() == 0 || m_compensationList.GetItemCount() > 0 )
return;
if(itemCode.GetLength() == 0) return;
int index = 0;
CString presentType, value1, value2;
presentType = itemCode.Tokenize(_T("."), index);
if(presentType.IsEmpty()) return;
if( atoi(presentType) != 3 && atoi(presentType) != 6 )
return;
value1 = itemCode.Tokenize(_T("."), index);
if(value1.IsEmpty()) return;
value2 = itemCode.Tokenize(_T("."), index);
if(value2.IsEmpty()) return;
int itemCount = m_compensationList.GetItemCount();
m_compensationList.InsertItem(itemCount, presentType);
m_compensationList.SetItemText(itemCount, 1, value1);
m_compensationList.SetItemText(itemCount, 2, value2);
}
BOOL CCompensationDlg::CheckDateType(CString endDate)
{
if( endDate.GetLength() != 10 )
return FALSE;
DWORD dwEndDate = atoi(endDate);
int iYear = dwEndDate / 1000000;
int iMonth = (dwEndDate % 1000000) / 10000;
int iDay = (dwEndDate % 10000) / 100;
int iHour = (dwEndDate % 10000) % 100;
if( iYear < 2015 )
return FALSE;
if( iMonth < 1 || iMonth > 12 )
return FALSE;
if( iHour < 0 || 24 < iHour )
return FALSE;
int checkDay = 0;
if( 2 == iMonth )
{
checkDay = 28;
if ((iYear % 4 == 0 && iYear % 100 != 0) || (iYear % 100 == 0 && iYear % 400 == 0))
checkDay = 29;
}
else if( (iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11) )
{
checkDay = 30;
}
else
{
checkDay = 31;
}
if( checkDay < iDay )
return FALSE;
//현재보다 이전인지 체크
CTime cCurTime = CTime::GetCurrentTime();
CTime cEndDate( iYear, iMonth, iDay, iHour, 0, 0 );
if( cCurTime > cEndDate )
return FALSE;
return TRUE;
}
void CCompensationDlg::InsertEndDate(CString endDate)
{
if( endDate.GetLength() == 0 || m_endDate.GetItemCount() > 0 )
return;
//check
if( !CheckDateType(endDate) )
return;
m_endDate.InsertItem(m_endDate.GetItemCount(), endDate);
}
void CCompensationDlg::OnDropItemFiles(CString file)
{
m_compensationList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertItemCode(line);
}
}
}
}
void CCompensationDlg::OnDropEndDateFiles(CString file)
{
m_endDate.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertEndDate(line);
}
}
}
}
void CCompensationDlg::DeleteListItem(CListCtrl& m_List)
{
int index = -1;
POSITION pos = m_List.GetFirstSelectedItemPosition();
while(pos)
{
int index = m_List.GetNextSelectedItem(pos);
m_List.DeleteItem(index);
pos = m_List.GetFirstSelectedItemPosition();
}
}
void CCompensationDlg::OnBnClickedInsert()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CString presentType, value1, value2, endDate;
presentType = m_compensationList.GetItemText(0, 0);
value1 = m_compensationList.GetItemText(0, 1);
value2 = m_compensationList.GetItemText(0, 2);
endDate = m_endDate.GetItemText(0, 0);
if( m_compensationList.GetItemCount() <= 0 || m_endDate.GetItemCount() <= 0 )
return;
ReqeustGiveCompensation(atoi(presentType), atoi(value1), atoi(value2), atoi(endDate));
}
void CCompensationDlg::ReqeustGiveCompensation(int type, int code, int value, int endDate)
{
//CTime 값으로 변환
int iYear = endDate / 1000000;
int iMonth = (endDate % 1000000) / 10000;
int iDay = (endDate % 10000) / 100;
int iHour = (endDate % 10000) % 100;
CTime cEndDate( iYear, iMonth, iDay, iHour, 0, 0 );
m_parent->RequestCompensation(type, code, value, cEndDate.GetTime());
}
@@ -0,0 +1,55 @@
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
class CZoneDialog;
// CCompensationDlg 대화 상자입니다.
class CCompensationDlg : public CDialogEx
{
DECLARE_DYNAMIC(CCompensationDlg)
public:
CCompensationDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CCompensationDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_COMPENSATION_DIALOG };
public:
void Startup(CZoneDialog* parent);
protected:
CZoneDialog* m_parent;
protected:
void InsertItemCode(CString itemCode);
void InsertEndDate(CString endDate);
void OnDropItemFiles(CString file);
void OnDropEndDateFiles(CString file);
void DeleteListItem(CListCtrl& m_List);
void ReqeustGiveCompensation(int type, int code, int value, int endDate);
BOOL CheckDateType(CString endDate);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CListCtrl m_compensationList;
CListCtrl m_endDate;
CEdit m_editCompensationCode;
CEdit m_editEndDate;
afx_msg void OnLvnItemchangedItemCompensation(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLvnItemchangedListEnddate(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnBnClickedButtonReset();
afx_msg void OnBnClickedInsert();
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
@@ -0,0 +1,344 @@
#pragma once
#include <Mmsystem.h>
#include <vector>
#include <map>
#include "IOSocket.h"
// define
#define COMPARE(x,min,max) (((x)>=(min))&&((x)<(max)))
#define SAFEDELETE(x) if(x != NULL) { delete x; x = NULL; }
#define SAFEDELETEARRAY(x) if(x != NULL) { delete [] x; x = NULL; }
enum ServerStates
{
SERVERSTATE_OFF=0,
SERVERSTATE_ON,
SERVERSTATE_BUSY,
SERVERSTATE_END,
SERVERSTATE_EMPTY
};
struct BILLINGSERVERINFO
{
BILLINGSERVERINFO()
{
serviceName = "";
serviceIP = "";
servicePort = 0;
billingServerState = 0;
serverType = 0;
serverListIndex = -1;
serverKeyIndex = -1;
connect = 0;
userInfoCount = 0;
reloadStatus = "";
}
CString serviceName;
CString serviceIP;
int servicePort;
int billingServerState;
int serverType;
int serverListIndex;
int serverKeyIndex;
int connect;
WORD userInfoCount;
CIOSocket billingSocket;
CString reloadStatus;
};
typedef std::map<int, BILLINGSERVERINFO*> BILLINGSERVERTABLE;
struct SERVERINFO
{
SERVERINFO()
{
serverIndex = 0;
serverType = 0;
serverState = 0;
serviceName = "";
serviceIP = "";
servicePort = 0;
connect = 0;
// GB_Connect = 0;
// DE_Connect = 0;
// FR_Connect = 0;
// IT_Connect = 0;
// PL_Connect = 0;
// TR_Connect = 0;
// ETC_Connect = 0;
roomCount = 0;
plazaCount = 0;
battleRoomCount = 0;
pingMS = 0;
DBMS = 0;
delay = 0;
relayFlag = 0;
}
int serverIndex;
int serverType;
int serverState;
CString serviceName;
CString serviceIP;
int servicePort;
WORD connect;
// WORD GB_Connect; //영국
// WORD DE_Connect; //독일
// WORD FR_Connect; //프랑스
// WORD IT_Connect; //이탈리아
// WORD PL_Connect; //폴란드
// WORD TR_Connect; //터키
// WORD ETC_Connect; //터키
WORD roomCount;
WORD plazaCount;
WORD battleRoomCount;
WORD pingMS;
WORD DBMS;
WORD delay;
BOOL relayFlag;
};
struct MAINSERVERINFO
{
DWORD dwGlobalTime; //GLOBAL TIME
char szPublicIP[ 32 ]; //Network Info
char szPrivateIP[ 32 ];
int iPort;
int ThreadCount; //Thread Info
int JoinServerCount; //Connect Client Info
int RemainderMemPoolCount; //Remainder MemPool Info
int RecvQueuePacketCount[4];//RECV QUEUE
int RecvQueueRemainderCount[4];//Remainder MemPool Info
char szDBAgentIP[ 32 ]; //DB AGENT SERVER INFO
char szLogDBAgentIP[ 32 ]; //DB AGENT SERVER INFO
int DBAgentPort;
bool bDBAConnected;
int LogDBAgentPort;
bool bLogDBAConnected;
int MaxGuildCount; //GUILD INFO
int MaxUpdateGuild;
char szCampStringHelp[ 128 ];//CAMP INFO
int MaxTradeItemCount; //Trade Info
char szEventShopState[ 32 ]; //Event Shop Info
int EventGoodsSaveDataCount;
int MaxToolConnectCount; //MANAGER TOOL
bool bUseClientVersion; // Client Version
int iClientVersion;
char szMainServerVersion[ 8 ];// Main Server Version
char szMainServerName[ 32 ];
// Log
int usingLogCount; // 현재
int maxUsingLogCount; // 가장 많이 쓸때
int remainLogCount; // remain
int dropLogCount; // 드랍된 갯수.
MAINSERVERINFO() : dwGlobalTime(0), iPort(0), ThreadCount(0), JoinServerCount(0), RemainderMemPoolCount(0)
, DBAgentPort(0), bDBAConnected(false), LogDBAgentPort(0), bLogDBAConnected(false), MaxGuildCount(0)
, MaxUpdateGuild(0), MaxTradeItemCount(0), EventGoodsSaveDataCount(0), MaxToolConnectCount(0)
, bUseClientVersion(false), iClientVersion(0), usingLogCount(0), maxUsingLogCount(0), remainLogCount(0), dropLogCount(0)
{
ZeroMemory( szPublicIP, sizeof( szPublicIP ) );
ZeroMemory( szPrivateIP, sizeof( szPrivateIP ) );
ZeroMemory( RecvQueuePacketCount, sizeof( RecvQueuePacketCount ) );
ZeroMemory( RecvQueueRemainderCount, sizeof( RecvQueueRemainderCount ) );
ZeroMemory( szDBAgentIP, sizeof( szDBAgentIP ) );
ZeroMemory( szLogDBAgentIP, sizeof( szLogDBAgentIP ) );
ZeroMemory( szCampStringHelp, sizeof( szCampStringHelp ) );
ZeroMemory( szEventShopState, sizeof( szEventShopState ) );
ZeroMemory( szMainServerVersion, sizeof( szMainServerVersion ) );
ZeroMemory( szMainServerName, sizeof( szMainServerName ) );
}
};
struct GAMESERVERINFO
{
DWORD dwGlobalTime; //GLOBAL TIME
char szPublicIP[ 32 ]; //Network Info
int csPort;
int SSPort;
int MSPort;
int ThreadCount; //Thread Info
int NodeSize; //Connect Client Info
int CopyNodeSize;
int RemainderNode; //Remainder MemPool Info
int RoomNodeSize; //CREATE ROOM
int PlazaNodeSize;
int HeapQuartersNodeSize;
int CopyRoomNodeSize;
int CopyPlazaNodeSize;
int CopyHeapQuartersNodeSize;
int RommRemainderNode; //Remainder MemPool Info
int BattleRoomNodeSize; //CREATE BATTLEROOM
int BattleRoomCopyNodeSize;
int PartyLevelCheckMinRoom;
int BattleRoomRemainderNode; //Remainder MemPool Info
int LadderTeamNodeSize; //CREATE LADDERTEAM
int LadderTeamCopyNodeSize;
int LadderTeamCampBattlePlay;
int LadderTeamRemainderNode; //Remainder MemPool Info
int RecvQueueNodeSize[ 4 ]; //RECV QUEUE
int BroadCastUDPnRelayNodeSize;
int RecvQueueRemainderNodeSize[4]; //Remainder MemPool Info
int BroadCastUDPnRelayRemainderNodeSize;
int DBClientNodeSize; //DB AGENT SERVER INFO
int DBClientTotalNodeSize; //DB AGENT SERVER INFO
char szSTRFILEVER[ 8 ]; // Game Server Version
char szSTRINTERNALNAME[ 32 ];
char szGameServerID[ 32 ]; // Game Server ID
char szGameServerName[ 32 ]; // Game Server Name
char szLogDBIP[ 32 ]; // LogDB Agent IP / port
int LogDBPort;
bool IsLogDBAActive;
DWORD HackCheckMin; // HackCheck
DWORD HackCheckMax;
int HackCheckLess;
int HackCheckOver;
int HackCheckLessOver;
int HackCheckTotal;
int IsClientVersion; // Client Version
int GetClientVersion;
int ChannelNodeSize; //CREATE Channel
int ChannelRemainderSize;
int ChannelCopyNodeSize;
int MemoNodeSize; //MEMO
DWORD GetServerIndex; //GAME SERVER INFO
int ServerNodeSize;
int ServerRemainderNodeSize;
bool IsMainServerActive; // Main Server Info
char MainServerIP[ 32 ];
int MainServerPort;
__int64 UDPTransferCount; //UDP Transfer Count
__int64 UDPTransferTCPCount;
__int64 UDPTransferTCPSendCount;
bool IsBillingRelayServerActive; //BILLING RELAY SERVER INFO
char BillingIP[ 32 ];
int BillingPort;
char XtrapVersion[ 32 ];
int LicenseDate; // Expiration dates
bool m_bReserveLogout; // Exit
int remainSecond;
int sendBufferUsingCnt; // SendBuffer
int sendBufferRemainCnt;
int sendBufferMaxCnt;
// Log
int usingLogCount; // 현재
int maxUsingLogCount; // 가장 많이 쓸때
int remainLogCount; // remain
int dropLogCount; // 드랍된 갯수.
GAMESERVERINFO() : dwGlobalTime(0), csPort(0), SSPort(0), MSPort(0), ThreadCount(0), NodeSize(0), CopyNodeSize(0)
, RemainderNode(0), RoomNodeSize(0), PlazaNodeSize(0), HeapQuartersNodeSize(0), CopyRoomNodeSize(0), CopyPlazaNodeSize(0)
, CopyHeapQuartersNodeSize(0), RommRemainderNode(0), BattleRoomNodeSize(0), BattleRoomCopyNodeSize(0), PartyLevelCheckMinRoom(0)
, BattleRoomRemainderNode(0), LadderTeamNodeSize(0), LadderTeamCopyNodeSize(0), LadderTeamCampBattlePlay(0), LadderTeamRemainderNode(0)
, BroadCastUDPnRelayNodeSize(0), BroadCastUDPnRelayRemainderNodeSize(0), DBClientNodeSize(0), DBClientTotalNodeSize(0)
, LogDBPort(0), IsLogDBAActive(false), HackCheckMin(0), HackCheckMax(0), HackCheckLess(0), HackCheckOver(0), HackCheckLessOver(0), HackCheckTotal(0), IsClientVersion(0)
, GetClientVersion(0), ChannelNodeSize(0), ChannelRemainderSize(0), ChannelCopyNodeSize(0), MemoNodeSize(0)
, GetServerIndex(0), ServerNodeSize(0), ServerRemainderNodeSize(0), IsMainServerActive(false), MainServerPort(0)
, UDPTransferCount(0), UDPTransferTCPCount(0), UDPTransferTCPSendCount(0), IsBillingRelayServerActive(false), BillingPort(0)
, LicenseDate(0), m_bReserveLogout(false), remainSecond(0), sendBufferUsingCnt(0), sendBufferRemainCnt(0), sendBufferMaxCnt(0)
, usingLogCount(0), maxUsingLogCount(0), remainLogCount(0), dropLogCount(0)
{
ZeroMemory( szPublicIP, sizeof( szPublicIP ) );
ZeroMemory( RecvQueueNodeSize, sizeof( RecvQueueNodeSize ) );
ZeroMemory( RecvQueueRemainderNodeSize, sizeof( RecvQueueRemainderNodeSize ) );
ZeroMemory( szSTRFILEVER, sizeof( szSTRFILEVER ) );
ZeroMemory( szSTRINTERNALNAME, sizeof( szSTRINTERNALNAME ) );
ZeroMemory( szGameServerID, sizeof( szGameServerID ) );
ZeroMemory( szGameServerName, sizeof( szGameServerName ) );
ZeroMemory( szLogDBIP, sizeof( szLogDBIP ) );
ZeroMemory( MainServerIP, sizeof( MainServerIP ) );
ZeroMemory( BillingIP, sizeof( BillingIP ) );
ZeroMemory( XtrapVersion, sizeof( XtrapVersion ) );
}
};
struct LoginServerInfo
{
TCHAR serverIP[64];
int serverPort;
int acceptCountPerSec;
int acceptCount;
int closeCount;
int opPoolCount;
int clientPoolCount;
int userInfoCount;
int serverConnectorPoolCount;
int packetQueueCount;
int serverConnectCount;
};
struct ServerInfo
{
TCHAR serverIP[64];
TCHAR serverName[64];
int serverPort;
int userCount;
int sendCount;
int fullCount;
int blockState;
int serverId;
int serverState;
};
#pragma pack(push,1)
struct SendRelayInfo_
{
TCHAR m_ipAddr[64];
int m_port;
int m_userCount;
int m_roomCount;
int m_serverCount;
int m_64DropCount;
int m_256DropCount;
int m_1024DropCount;
int m_64UsingCount;
int m_256UsingCount;
int m_1024UsingCount;
SendRelayInfo_()
{
ZeroMemory(m_ipAddr,64);
m_port = 0;
m_userCount = 0;
m_roomCount= 0;
m_64DropCount= 0;
m_256DropCount= 0;
m_1024DropCount= 0;
m_64UsingCount= 0;
m_256UsingCount= 0;
m_1024UsingCount= 0;
}
};
#pragma pack(pop)
namespace ESOCKET
{
enum Socket
{
LS_CONNECTED = 0,
LS_DISCONNECTED,
LS_REQSERVERSTATE,
LS_RESPSERVERSTATE,
LS_ZOMBIESERVERSTATE,
LS_BLOCKED,
};
}
namespace EMCONTROLTYPE
{
enum ECONTYPE
{
LS_GETSERVERINFO,
LS_SETALLSERVERBLOCK,
LS_SETSERVERBLOCK,
LS_FILLSERVERINFO,
LS_SETMAXUSER,
LS_FILLINFODRAW,
LS_QUICKEXIT,
};
}
@@ -0,0 +1,102 @@
// DisplayDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "DisplayDlg.h"
#include "afxdialogex.h"
// CDisplayDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CDisplayDlg, CDialogEx)
CDisplayDlg::CDisplayDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CDisplayDlg::IDD, pParent), m_serverType(0), m_index(0), m_parent(NULL)
{
}
CDisplayDlg::~CDisplayDlg()
{
}
void CDisplayDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_SHOWINFO, m_editCtrl);
}
BEGIN_MESSAGE_MAP(CDisplayDlg, CDialogEx)
END_MESSAGE_MAP()
void CDisplayDlg::Startup(CZoneDialog* dlg)
{
m_parent = dlg;
ShowWindow(SW_HIDE);
}
// CDisplayDlg 메시지 처리기입니다.
void CDisplayDlg::Show(int serverType, int index, CString& title, CString& text)
{
SetWindowText(title);
m_serverType = serverType;
m_index = index;
m_editCtrl.SetWindowText(text);
m_editCtrl.SetSel(0, 0);
m_editCtrl.SetFocus();
ShowWindow(SW_SHOW);
}
void CDisplayDlg::Refresh()
{
if(!m_parent->m_billingFlag)
m_parent->RequestInfo(m_serverType, m_index);
else
{
int billingKeyIndex = m_serverType;
m_parent->RequestInfo(SERVER_TYPE_BILLING, billingKeyIndex);
}
}
BOOL CDisplayDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
switch(pMsg->message)
{
case WM_KEYDOWN :
{
if(VK_F5 == pMsg->wParam)
{
Refresh();
return FALSE;
}
}
break;
case WM_SYSKEYDOWN:
{
}
break;
}
return CDialogEx::PreTranslateMessage(pMsg);
}
BOOL CDisplayDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
@@ -0,0 +1,40 @@
#pragma once
#include "afxwin.h"
class CZoneDialog;
// CDisplayDlg 대화 상자입니다.
class CDisplayDlg : public CDialogEx
{
DECLARE_DYNAMIC(CDisplayDlg)
public:
CDisplayDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CDisplayDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_DISPLAY_DIALOG };
public:
void Startup(CZoneDialog* dlg);
void Show(int serverType, int index, CString& title, CString& text);
protected:
void Refresh();
protected:
int m_serverType;
int m_index;
CZoneDialog* m_parent;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CEdit m_editCtrl;
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL OnInitDialog();
};
@@ -0,0 +1,96 @@
/*===================================================*\
| |
| EASY-SIZE Macros |
| |
| Copyright (c) 2001 - Marc Richarme |
| [email protected] |
| http://devix.cjb.net |
| |
| License: |
| |
| You may use this code in any commersial or non- |
| commersial application, and you may redistribute |
| this file (and even modify it if you wish) as |
| long as you keep this notice untouched in any |
| version you redistribute. |
| |
| Usage: |
| |
| - Insert 'DECLARE_EASYSIZE' somewhere in your |
| class declaration |
| - Insert an easysize map in the beginning of your |
| class implementation (see documentation) and |
| outside of any function. |
| - Insert 'INIT_EASYSIZE;' in your |
| OnInitDialog handler. |
| - Insert 'UPDATE_EASYSIZE' in your OnSize handler |
| - Optional: Insert 'EASYSIZE_MINSIZE(mx,my);' in |
| your OnSizing handler if you want to specify |
| a minimum size for your dialog |
| |
| Check http://devix.cjb.net for the |
| docs and new versions |
| |
\*===================================================*/
#ifndef __EASYSIZE_H_
#define __EASYSIZE_H_
#define ES_BORDER 0xffffffff
#define ES_KEEPSIZE 0xfffffffe
#define ES_HCENTER 0x00000001
#define ES_VCENTER 0x00000002
#define DECLARE_EASYSIZE \
void __ES__RepositionControls(BOOL bInit);\
void __ES__CalcBottomRight(CWnd *pThis, BOOL bBottom, int &bottomright, int &topleft, UINT id, UINT br, int es_br, CRect &rect, int clientbottomright);
#define INIT_EASYSIZE __ES__RepositionControls(TRUE); __ES__RepositionControls(FALSE)
#define UPDATE_EASYSIZE if(GetWindow(GW_CHILD)!=NULL) __ES__RepositionControls(FALSE)
#define EASYSIZE_MINSIZE(mx,my,s,r) if(r->right-r->left < mx) { if((s == WMSZ_BOTTOMLEFT)||(s == WMSZ_LEFT)||(s == WMSZ_TOPLEFT)) r->left = r->right-mx; else r->right = r->left+mx; } if(r->bottom-r->top < my) { if((s == WMSZ_TOP)||(s == WMSZ_TOPLEFT)||(s == WMSZ_TOPRIGHT)) r->top = r->bottom-my; else r->bottom = r->top+my; }
#define BEGIN_EASYSIZE_MAP(class) \
void class::__ES__CalcBottomRight(CWnd *pThis, BOOL bBottom, int &bottomright, int &topleft, UINT id, UINT br, int es_br, CRect &rect, int clientbottomright) {\
if(br==ES_BORDER) bottomright = clientbottomright-es_br;\
else if(br==ES_KEEPSIZE) bottomright = topleft+es_br;\
else { CRect rect2;\
pThis->GetDlgItem(br)->GetWindowRect(rect2); pThis->ScreenToClient(rect2);\
bottomright = (bBottom?rect2.top:rect2.left) - es_br;}}\
void class::__ES__RepositionControls(BOOL bInit) { CRect rect,rect2,client; GetClientRect(client);
#define END_EASYSIZE_MAP Invalidate(); UpdateWindow(); }
#define EASYSIZE(id,l,t,r,b,o) \
static int id##_es_l, id##_es_t, id##_es_r, id##_es_b;\
if(bInit) {\
GetDlgItem(id)->GetWindowRect(rect); ScreenToClient(rect);\
if(o & ES_HCENTER) id##_es_l = rect.Width()/2; else {\
if(l==ES_BORDER) id##_es_l = rect.left; else if(l==ES_KEEPSIZE) id##_es_l = rect.Width(); else {\
GetDlgItem(l)->GetWindowRect(rect2); ScreenToClient(rect2);\
id##_es_l = rect.left-rect2.right;}}\
if(o & ES_VCENTER) id##_es_t = rect.Height()/2; else {\
if(t==ES_BORDER) id##_es_t = rect.top; else if(t==ES_KEEPSIZE) id##_es_t = rect.Height(); else {\
GetDlgItem(t)->GetWindowRect(rect2); ScreenToClient(rect2);\
id##_es_t = rect.top-rect2.bottom;}}\
if(o & ES_HCENTER) id##_es_r = rect.Width(); else { if(r==ES_BORDER) id##_es_r = client.right-rect.right; else if(r==ES_KEEPSIZE) id##_es_r = rect.Width(); else {\
GetDlgItem(r)->GetWindowRect(rect2); ScreenToClient(rect2);\
id##_es_r = rect2.left-rect.right;}}\
if(o & ES_VCENTER) id##_es_b = rect.Height(); else { if(b==ES_BORDER) id##_es_b = client.bottom-rect.bottom; else if(b==ES_KEEPSIZE) id##_es_b = rect.Height(); else {\
GetDlgItem(b)->GetWindowRect(rect2); ScreenToClient(rect2);\
id##_es_b = rect2.top-rect.bottom;}}\
} else {\
int left,top,right,bottom; BOOL bR = FALSE,bB = FALSE;\
if(o & ES_HCENTER) { int _a,_b;\
if(l==ES_BORDER) _a = client.left; else { GetDlgItem(l)->GetWindowRect(rect2); ScreenToClient(rect2); _a = rect2.right; }\
if(r==ES_BORDER) _b = client.right; else { GetDlgItem(r)->GetWindowRect(rect2); ScreenToClient(rect2); _b = rect2.left; }\
left = _a+((_b-_a)/2-id##_es_l); right = left + id##_es_r;} else {\
if(l==ES_BORDER) left = id##_es_l;\
else if(l==ES_KEEPSIZE) { __ES__CalcBottomRight(this,FALSE,right,left,id,r,id##_es_r,rect,client.right); left = right-id##_es_l;\
} else { GetDlgItem(l)->GetWindowRect(rect2); ScreenToClient(rect2); left = rect2.right + id##_es_l; }\
if(l != ES_KEEPSIZE) __ES__CalcBottomRight(this,FALSE,right,left,id,r,id##_es_r,rect,client.right);}\
if(o & ES_VCENTER) { int _a,_b;\
if(t==ES_BORDER) _a = client.top; else { GetDlgItem(t)->GetWindowRect(rect2); ScreenToClient(rect2); _a = rect2.bottom; }\
if(b==ES_BORDER) _b = client.bottom; else { GetDlgItem(b)->GetWindowRect(rect2); ScreenToClient(rect2); _b = rect2.top; }\
top = _a+((_b-_a)/2-id##_es_t); bottom = top + id##_es_b;} else {\
if(t==ES_BORDER) top = id##_es_t;\
else if(t==ES_KEEPSIZE) { __ES__CalcBottomRight(this,TRUE,bottom,top,id,b,id##_es_b,rect,client.bottom); top = bottom-id##_es_t;\
} else { GetDlgItem(t)->GetWindowRect(rect2); ScreenToClient(rect2); top = rect2.bottom + id##_es_t; }\
if(t != ES_KEEPSIZE) __ES__CalcBottomRight(this,TRUE,bottom,top,id,b,id##_es_b,rect,client.bottom);}\
GetDlgItem(id)->MoveWindow(left,top,right-left,bottom-top,FALSE);\
}
#endif //__EASYSIZE_H_
@@ -0,0 +1,121 @@
// EventDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "EventDlg.h"
#include "afxdialogex.h"
// CEventDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CEventDlg, CDialogEx)
CEventDlg::CEventDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CEventDlg::IDD, pParent), m_parent(NULL)
{
}
CEventDlg::~CEventDlg()
{
}
void CEventDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_EVENT, m_eventEdit);
}
BEGIN_MESSAGE_MAP(CEventDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_EVENTINSERT, &CEventDlg::OnBnClickedButtonEventApply)
END_MESSAGE_MAP()
// CEventDlg 메시지 처리기입니다.
void CEventDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
void CEventDlg::OnDropEventFiles(CString file)
{
m_eventEdit.SetWindowText(_T(""));
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line, output = "";
while(ff.ReadString(line))
{
output += line;
output += _T("\r\n");
}
ff.Close();
m_eventEdit.SetWindowText(output);
}
}
void CEventDlg::Parse(CString text)
{
ZeroMemory(m_values, sizeof(m_values));
m_valueCount = 0;
int curPos = 0;
CString token= text.Tokenize(_T("\r\n"),curPos);
while (token != _T(""))
{
token.MakeLower();
if(!token.IsEmpty() &&
(token.Find(_T(";"), 0) == -1) &&
(token.Find(_T("["), 0) == -1) &&
(token.Find(_T(";"), 0) == -1) )
{
int index = 0;
CString key = token.Tokenize(_T("="), index);
CString value = token.Tokenize(_T("="), index);
m_values[m_valueCount++] = atoi(value);
}
token = text.Tokenize(_T("\r\n"), curPos);
};
}
void CEventDlg::OnBnClickedButtonEventApply()
{
CString text;
m_eventEdit.GetWindowText(text);
// 텍스트 파싱
Parse(text);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_parent->RequestEventInsert(m_values, m_valueCount);
MessageBox(_T("Completed"), _T("EVENT"), MB_OK);
}
BOOL CEventDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(WM_DROPFILES == pMsg->message)
{
if(m_eventEdit.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropEventFiles( file );
}
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
@@ -0,0 +1,39 @@
#pragma once
#include "afxwin.h"
class CZoneDialog;
// CEventDlg 대화 상자입니다.
class CEventDlg : public CDialogEx
{
DECLARE_DYNAMIC(CEventDlg)
public:
CEventDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CEventDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_EVENT_DIALOG };
public:
void Startup(CZoneDialog* parent);
void OnDropEventFiles(CString file);
void Parse(CString text);
protected:
CZoneDialog* m_parent;
int m_values[64];
int m_valueCount;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CEdit m_eventEdit;
afx_msg void OnBnClickedButtonEventApply();
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
@@ -0,0 +1,621 @@
// GraphDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "GraphDlg.h"
#include "afxdialogex.h"
#include "WinMessage.h"
#include "cFile.h"
#include <iostream>
#include <fstream>
#include "ZoneDialog.h"
using namespace std;
// CGraphDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CGraphDlg, CDialogEx)
CGraphDlg::CGraphDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CGraphDlg::IDD, pParent), m_PCCU(0), m_terms(GRAPH_TERM_3SEC), m_bCountryCode(false)
{
m_bChangeGraph = true;
}
CGraphDlg::~CGraphDlg()
{
}
void CGraphDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_YEAR, m_CbbYear);
DDX_Control(pDX, IDC_DAY, m_CBBDAY);
DDX_Control(pDX, IDC_MONTH, m_CBBMONTH);
}
BEGIN_MESSAGE_MAP(CGraphDlg, CDialogEx)
ON_BN_CLICKED(IDC_TODAY, &CGraphDlg::OnBnClickedToday)
ON_BN_CLICKED(IDC_YESTERDAY, &CGraphDlg::OnBnClickedYesterday)
ON_BN_CLICKED(IDC_SERACH, &CGraphDlg::OnBnClickedSerach)
ON_BN_CLICKED(IDC_1WEEK_AGO, &CGraphDlg::OnBnClicked1weekAgo)
END_MESSAGE_MAP()
// CGraphDlg 메시지 처리기입니다.
void CGraphDlg::CreateGraph()
{
CRect rc;
CDC * pDC = GetDC();
GetClientRect(rc);
HDC m_hMemDC = CreateCompatibleDC(pDC->m_hDC);
GetDlgItem(IDC_OSC_CCU)->GetWindowRect(rc) ;
ScreenToClient(rc) ;
m_graphCCU.DestroyWindow();
m_graphCCU.Create(WS_VISIBLE | WS_CHILD, rc, this) ;
m_graphCCU.SetRange( true, 0, 100, 1) ;
m_graphCCU.SetYUnits(_T("")) ;
GetDlgItem(IDC_OSC_CCU)->ShowWindow(SW_HIDE);
}
BOOL CGraphDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
CreateGraph();
CreateMenu();
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CGraphDlg::Startup(CString title, CZoneDialog* pkZonedlg)
{
m_title = title;
m_pkZonedlg = pkZonedlg;
RefreshTitle();
ShowWindow(SW_HIDE);
m_CbbYear.InsertString(0, ("2018"));
m_CbbYear.InsertString(1, ("2019"));
m_CbbYear.InsertString(2, ("2020"));
m_CbbYear.InsertString(3, ("2021"));
m_CbbYear.InsertString(4, ("2022"));
m_CbbYear.InsertString(5, ("2023"));
m_CBBMONTH.InsertString(0, ("1"));
m_CBBMONTH.InsertString(1, ("2"));
m_CBBMONTH.InsertString(2, ("3"));
m_CBBMONTH.InsertString(3, ("4"));
m_CBBMONTH.InsertString(4, ("5"));
m_CBBMONTH.InsertString(5, ("6"));
m_CBBMONTH.InsertString(6, ("7"));
m_CBBMONTH.InsertString(7, ("8"));
m_CBBMONTH.InsertString(8, ("9"));
m_CBBMONTH.InsertString(9, ("10"));
m_CBBMONTH.InsertString(10, ("11"));
m_CBBMONTH.InsertString(11, ("12"));
m_CBBDAY.InsertString(0, ("1"));
m_CBBDAY.InsertString(1, ("2"));
m_CBBDAY.InsertString(2, ("3"));
m_CBBDAY.InsertString(3, ("4"));
m_CBBDAY.InsertString(4, ("5"));
m_CBBDAY.InsertString(5, ("6"));
m_CBBDAY.InsertString(6, ("7"));
m_CBBDAY.InsertString(7, ("8"));
m_CBBDAY.InsertString(8, ("9"));
m_CBBDAY.InsertString(9, ("10"));
m_CBBDAY.InsertString(10, ("11"));
m_CBBDAY.InsertString(11, ("12"));
m_CBBDAY.InsertString(12, ("13"));
m_CBBDAY.InsertString(13, ("14"));
m_CBBDAY.InsertString(14, ("15"));
m_CBBDAY.InsertString(15, ("16"));
m_CBBDAY.InsertString(16, ("17"));
m_CBBDAY.InsertString(17, ("18"));
m_CBBDAY.InsertString(18, ("19"));
m_CBBDAY.InsertString(19, ("20"));
m_CBBDAY.InsertString(20, ("21"));
m_CBBDAY.InsertString(21, ("22"));
m_CBBDAY.InsertString(22, ("23"));
m_CBBDAY.InsertString(23, ("24"));
m_CBBDAY.InsertString(24, ("25"));
m_CBBDAY.InsertString(25, ("26"));
m_CBBDAY.InsertString(26, ("27"));
m_CBBDAY.InsertString(27, ("28"));
m_CBBDAY.InsertString(28, ("29"));
m_CBBDAY.InsertString(29, ("30"));
m_CBBDAY.InsertString(30, ("31"));
}
void CGraphDlg::CreateMenu()
{
m_menu.DestroyMenu();
m_menu.CreatePopupMenu();
CString menu = _T("3 sec");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_GRAPH3SEC, (LPCTSTR)menu);
menu = _T("1 min");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_GRAPH1MIN, (LPCTSTR)menu);
menu = _T("10 min");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_GRAPH10MIN, (LPCTSTR)menu);
}
void CGraphDlg::RefreshTitle()
{
CString temp;
temp.Format(_T("%s - CCU Graph(PCCU : %d)"), GetTitle(), (int)GetPCCU());
SetWindowText(temp);
}
void CGraphDlg::GraphCCUInit()
{
m_graphCCU.Init();
m_PCCU = 0;
RefreshTitle();
}
void CGraphDlg::InitDate()
{
m_graphCCU.InitDate();
}
void CGraphDlg::SetRange(bool b, double dLower, double dUpper, int nDecimalPlaces)
{
m_graphCCU.SetRange(b, dLower, dUpper, nDecimalPlaces);
}
void CGraphDlg::AppendPoint(bool bCCU, int nPoint)
{
if(m_bChangeGraph == false)
{
return ;
}
m_bCountryCode = bCCU;
m_points.push_back(nPoint); // 11860(200 * 593) max
if(nPoint > m_PCCU)
{
m_PCCU = nPoint;
RefreshTitle();
}
int term = GetTerm(m_terms);
int divide = m_points.size() % term;
if(divide == 0)
{
m_graphCCU.AppendPoint(m_bCountryCode, nPoint);
}
}
void CGraphDlg::SetXUnits(CString string)
{
if(m_bChangeGraph == false)
{
return ;
}
m_graphCCU.SetXUnits(string);
}
void CGraphDlg::SetXSearchUnits(CString string)
{
m_graphCCU.SetXUnits(string);
}
void CGraphDlg::ShowGraph(MSG* pMsg)
{
if(m_graphCCU.GetSafeHwnd() == pMsg->hwnd)
{
//TRACE("Message : %08x\n", pMsg->message);
if(pMsg->message == WM_RBUTTONUP)
{
CPoint pos;
GetCursorPos(&pos);
int term = GetTerm();
for(int i = 1 ; i <= 3 ; i++)
{
if(i == term)
{
m_menu.CheckMenuItem(IDC_SERVICE_GRAPH3SEC+i-1, MF_CHECKED);
}
else
{
m_menu.CheckMenuItem(IDC_SERVICE_GRAPH3SEC+i-1, MF_UNCHECKED);
}
}
m_menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pos.x, pos.y, this);
}
}
}
void CGraphDlg::HideGraph(MSG* pMsg)
{
if(m_graphCCU.GetSafeHwnd() == pMsg->hwnd)
{
//TRACE("Message : %08x\n", pMsg->message);
if(pMsg->message == WM_LBUTTONUP)
{
ShowWindow(SW_HIDE);
}
}
}
void CGraphDlg::ProgressTime(MSG* pMsg)
{
if(m_graphCCU.GetSafeHwnd() == pMsg->hwnd)
{
CString szTime;
int x = GET_X_LPARAM(pMsg->lParam);
int y = GET_Y_LPARAM(pMsg->lParam);
int rightPixel = m_graphCCU.GetRightPixel();
int leftPixel = m_graphCCU.GetLeftPixel();
if( (x < leftPixel) || (x > rightPixel) )
return;
int elapseTime = (rightPixel - x) / 4;
int term = GetTerm(m_terms) * 3;
elapseTime *= term;
CTime nowTime = CTime::GetCurrentTime();
CTime pastTime = nowTime;
pastTime -= elapseTime;
float fPosTerm = (rightPixel - leftPixel)/24.0;
int Diff = x - leftPixel;
int iHour = Diff/fPosTerm;
int iTest = Diff%(int)fPosTerm;
int iMinute = iTest /fPosTerm * 60;
int iNum = iHour*60 + iMinute;
int iCount = 0;
if(iNum < m_points.size())
{
iCount = m_points[iNum];
}
szTime.Format("Time:%02d:%02d\nUser:%05d", iHour, iMinute, iCount);
m_graphCCU.SetToolTip(x, y, szTime );;
}
}
int CGraphDlg::GetTerm(const GraphTerms terms)
{
int term = 1;
switch(terms)
{
case GRAPH_TERM_3SEC :
term = 1;
break;
case GRAPH_TERM_1MIN :
//term = 5;
term = 20;
break;
case GRAPH_TERM_10MIN :
//term = 10;
term = 200;
break;
}
return term;
}
BOOL CGraphDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
ProgressTime(pMsg);
HideGraph(pMsg);
ShowGraph(pMsg);
return CDialogEx::PreTranslateMessage(pMsg);
}
void CGraphDlg::Rearrange(const GraphTerms terms)
{
ShowWindow(SW_HIDE);
m_graphCCU.Reset();
m_terms = terms;
int term = GetTerm(terms);
int width = m_graphCCU.GetWidth();
int offset = (width+1) * term;
int start = 0;
if((int)m_points.size() > offset)
{
start = m_points.size() - offset;
}
TRACE("[Rearrange - %d]\n", term);
for(int i = start ; i < (int)m_points.size() ; i += term)
{
m_graphCCU.AppendPoint(m_bCountryCode, m_points[i]);
TRACE("graph : %d\n", m_points[i]);
}
ShowWindow(SW_SHOW);
}
BOOL CGraphDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
int itemIndex = lParam;
switch(wParam)
{
case IDC_SERVICE_GRAPH3SEC :
{
m_terms = GRAPH_TERM_3SEC;
Rearrange(GRAPH_TERM_3SEC);
}
return TRUE;
case IDC_SERVICE_GRAPH1MIN :
{
m_terms = GRAPH_TERM_1MIN;
Rearrange(GRAPH_TERM_1MIN);
}
return TRUE;
case IDC_SERVICE_GRAPH10MIN :
{
m_terms = GRAPH_TERM_10MIN;
Rearrange(GRAPH_TERM_10MIN);
}
return TRUE;
}
return CDialog::OnCommand(wParam, lParam);
}
void CGraphDlg::AppendCCUPoint( double dNewGB,double dNewDE,double dNewFR,double dNewIT,double dNewPL,double dNewTR, double dNewETC )
{
m_graphCCU.AppendCCUPoint(dNewGB, dNewDE, dNewFR, dNewIT, dNewPL, dNewTR, dNewETC);
}
void CGraphDlg::OnBnClickedToday()
{
// 오늘 내역을 출력한다.
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
m_PCCU = 0;
m_bChangeGraph = true;
m_pkZonedlg->RequestTodayCCU(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
ComboBoxSetting(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
}
void CGraphDlg::OnBnClickedYesterday()
{
__int64 IN_DAY = (__int64)10000000*60*60*24;
// 어제 내역을 출력한다.
SYSTEMTIME sysTime;
FILETIME ftm;
LARGE_INTEGER largeInt;
GetLocalTime(&sysTime);
SystemTimeToFileTime(&sysTime, &ftm);
memcpy(&largeInt, &ftm, sizeof(FILETIME));
largeInt.QuadPart += IN_DAY * (-1);
memcpy(&ftm, &largeInt, sizeof(FILETIME));
FileTimeToSystemTime(&ftm, &sysTime);
m_PCCU = 0;
m_bChangeGraph = false;
m_pkZonedlg->RequestSearchCCU(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
ComboBoxSetting(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
}
void CGraphDlg::OnBnClicked1weekAgo()
{
__int64 IN_DAY = (__int64)10000000*60*60*24;
// 어제 내역을 출력한다.
SYSTEMTIME sysTime;
FILETIME ftm;
LARGE_INTEGER largeInt;
GetLocalTime(&sysTime);
SystemTimeToFileTime(&sysTime, &ftm);
memcpy(&largeInt, &ftm, sizeof(FILETIME));
largeInt.QuadPart += IN_DAY * (-7);
memcpy(&ftm, &largeInt, sizeof(FILETIME));
FileTimeToSystemTime(&ftm, &sysTime);
m_PCCU = 0;
m_bChangeGraph = false;
m_pkZonedlg->RequestSearchCCU(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
ComboBoxSetting(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
}
void CGraphDlg::OnBnClickedSerach()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CString strYear, strMonth, strDay;
m_CbbYear.GetLBText(m_CbbYear.GetCurSel(), strYear);
m_CBBMONTH.GetLBText(m_CBBMONTH.GetCurSel(), strMonth);
m_CBBDAY.GetLBText(m_CBBDAY.GetCurSel(), strDay);
int iYear = atoi(strYear);
int iMonth = atoi(strMonth);
int iDay = atoi(strDay);
// 오늘 내역을 출력한다.
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
m_PCCU = 0;
if(sysTime.wYear == iYear && sysTime.wMonth == iMonth && sysTime.wDay == iDay)
{
m_bChangeGraph = true;
m_pkZonedlg->RequestTodayCCU(sysTime.wYear, sysTime.wMonth, sysTime.wDay);
}
else
{
m_bChangeGraph = false;
m_pkZonedlg->RequestSearchCCU((WORD)iYear, (WORD)iMonth, (WORD)iDay);
}
ComboBoxSetting((WORD)iYear, (WORD)iMonth, (WORD)iDay);
}
void CGraphDlg::GraphSetting(const SYSTEMTIME systime)
{
BOOL billingFlag = FALSE;
TCHAR path[512];
GetCurrentDirectory(sizeof(path), path);
CString fullPath;
fullPath.Format(_T("%s\\%04lu%02lu%02lu.txt"), m_title, systime.wYear, systime.wMonth, systime.wDay);
ifstream ifile;
char line[200]; // 한 줄씩 읽어서 임시로 저장할 공간
CString strTemp;
CString strCount;
int iLastMaxCount = 0;
int imaxValue = 0;
int iMaxCount =0;
ifile.open(fullPath); // 파일 열기
if (ifile.is_open())
{
while (ifile.getline(line, sizeof(line))) // 한 줄씩 읽어 처리를 시작한다.
{
cout << line << endl; // 내용 출력
strTemp = line;
// strTime = strTemp.Right(strTemp.GetLength() - (1));
CString strYear = strTemp.Mid(1, 4);
int iYear = _ttoi(strYear);
CString strMonth = strTemp.Mid(6, 2);
int iMonth = _ttoi(strMonth);
CString strDay = strTemp.Mid(9, 2);
int iDay = _ttoi(strDay);
CString strHour = strTemp.Mid(12, 2);
int iHour = _ttoi(strHour);
CString strMinute = strTemp.Mid(15, 2);
int iMinute = _ttoi(strMinute);
CString strSecond = strTemp.Mid(18, 2);
int iSecond = _ttoi(strSecond);
strCount = strTemp.Left(strTemp.GetLength() - (1));
int iPoint2 = strCount.ReverseFind('[');
strCount = strCount.Right(strCount.GetLength() - (iPoint2 + 1));
int iCount = _ttoi(strCount);
if(iMaxCount < iCount)
{
iMaxCount = iCount;
}
}
if(iLastMaxCount < iMaxCount)
{
if(iMaxCount / 100 == 0) imaxValue = 100;
else if(iMaxCount / 500 == 0) imaxValue = 500;
else if(iMaxCount / 1000 == 0) imaxValue = 1000;
else if(iMaxCount / 2500 == 0) imaxValue = 2500;
else if(iMaxCount / 5000 == 0) imaxValue = 5000;
else if(iMaxCount / 10000 == 0) imaxValue = 10000;
else if(iMaxCount / 20000 == 0) imaxValue = 20000;
else if(iMaxCount / 50000 == 0) imaxValue = 50000;
else if(iMaxCount / 100000 == 0) imaxValue = 100000;
else if(iMaxCount / 500000 == 0) imaxValue = 500000;
else if(iMaxCount / 1000000 == 0) imaxValue = 1000000;
}
if(iLastMaxCount != imaxValue)
{
iLastMaxCount = imaxValue;
}
SetRange(true, 0, imaxValue, 1);
ifile.clear();
ifile.seekg(0, ios::beg);
m_graphCCU.Init();
while (ifile.getline(line, sizeof(line))) // 한 줄씩 읽어 처리를 시작한다.
{
cout << line << endl; // 내용 출력
strTemp = line;
// strTime = strTemp.Right(strTemp.GetLength() - (1));
CString strYear = strTemp.Mid(1, 4);
int iYear = _ttoi(strYear);
CString strMonth = strTemp.Mid(6, 2);
int iMonth = _ttoi(strMonth);
CString strDay = strTemp.Mid(9, 2);
int iDay = _ttoi(strDay);
CString strHour = strTemp.Mid(12, 2);
int iHour = _ttoi(strHour);
CString strMinute = strTemp.Mid(15, 2);
int iMinute = _ttoi(strMinute);
CString strSecond = strTemp.Mid(18, 2);
int iSecond = _ttoi(strSecond);
strCount = strTemp.Left(strTemp.GetLength() - (1));
int iPoint2 = strCount.ReverseFind('[');
strCount = strCount.Right(strCount.GetLength() - (iPoint2 + 1));
int iCount = _ttoi(strCount);
AppendDateTimePoint(iYear, iMonth, iDay, iHour, iMinute, iSecond, iCount);
}
}
else
{
SetRange(true, 0, imaxValue, 1);
CString xunits;
m_graphCCU.Init();
xunits.Format(_T("%04d-%02d-%02d"), systime.wYear, systime.wMonth, systime.wDay);
MessageBox(_T("Not Found File"), xunits, MB_OK);
}
CString xunits;
xunits.Format(_T("%04d-%02d-%02d User(%06d/%06d)"), systime.wYear, systime.wMonth, systime.wDay, iMaxCount, iMaxCount);
m_graphCCU.SetXUnits(xunits);
ifile.close(); // 파일 닫기
}
void CGraphDlg::AppendDateTimePoint(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int nPoint)
{
m_points.push_back(nPoint); // 11860(200 * 593) max
if(nPoint > m_PCCU)
{
m_PCCU = nPoint;
RefreshTitle();
}
int term = GetTerm(m_terms);
int divide = m_points.size() % term;
if(divide == 0)
{
m_graphCCU.AppendDateTimePoint(iYear, iMonth, iDay, iHour, iMinute, iSecond, m_bCountryCode, nPoint);
}
}
void CGraphDlg::ComboBoxSetting(int iYear, int iMonth, int iDay)
{
m_CbbYear.SendMessage(CB_SETCURSEL,iYear - 2018, 0);
m_CBBMONTH.SendMessage(CB_SETCURSEL,iMonth - 1, 0);
m_CBBDAY.SendMessage(CB_SETCURSEL,iDay - 1, 0);
}
@@ -0,0 +1,96 @@
#pragma once
#include "OScopeCtrl.h"
#include "OScopeTimeCtrl.h"
#include <vector>
#include "afxwin.h"
#include "afxcmn.h"
class CZoneDialog;
enum GraphTerms
{
GRAPH_TERM_3SEC = 1,
GRAPH_TERM_1MIN,
GRAPH_TERM_10MIN,
GRAPH_TERM_END
};
// CGraphDlg 대화 상자입니다.
class CGraphDlg : public CDialogEx
{
DECLARE_DYNAMIC(CGraphDlg)
public:
CGraphDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CGraphDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_GRAPH_DIALOG };
public:
void Startup(CString title, CZoneDialog* pkZonedlg);
void CreateMenu();
void RefreshTitle();
void GraphCCUInit();
void InitDate();
void SetRange(bool b, double dLower, double dUpper, int nDecimalPlaces=1);
void AppendPoint(bool bCCU, int nPoint);
void SetXUnits(CString string);
void SetXSearchUnits(CString string);
double GetPCCU() { return m_PCCU; }
CString GetTitle() { return m_title; }
int GetTerm() { return m_terms; }
public:
void Rearrange(const GraphTerms terms);
void SetCountryCode(bool bCCU) { m_bCountryCode = bCCU; };
void AppendCCUPoint(double dNewGB,double dNewDE,double dNewFR,double dNewIT,double dNewPL,double dNewTR, double dNewETC );
void AppendDateTimePoint(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, int nPoint);
void ComboBoxSetting(int iYear, int iMonth, int iDay);
protected:
void CreateGraph();
void ShowGraph(MSG* pMsg);
void HideGraph(MSG* pMsg);
void ProgressTime(MSG* pMsg);
int GetTerm(const GraphTerms terms);
void GraphSetting(const SYSTEMTIME systime);
protected:
typedef std::vector<int> POINTS;
POINTS m_points;
COScopeTimeCtrl m_graphCCU;
CString m_title;
double m_PCCU;
GraphTerms m_terms;
CMenu m_menu;
BOOL m_bChangeGraph;
CZoneDialog* m_pkZonedlg;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
private:
bool m_bCountryCode;
public:
afx_msg void OnBnClickedToday();
afx_msg void OnBnClickedYesterday();
CComboBox m_CbbYear;
CComboBox m_CBBDAY;
CComboBox m_CBBMONTH;
afx_msg void OnBnClickedSerach();
afx_msg void OnBnClicked1weekAgo();
};
@@ -0,0 +1,131 @@
#include "StdAfx.h"
#include "Network/cryption.h"
#include "IOSecurity.h"
CIOSecurity::CIOSecurity(void)
{
Init();
}
CIOSecurity::~CIOSecurity(void)
{
Destroy();
}
void CIOSecurity::Init()
{
InitState();
}
void CIOSecurity::Destroy()
{
}
void CIOSecurity::InitState()
{
m_SndState.InitState();
m_RcvState.InitState();
}
// Packet CheckSum
void CIOSecurity::EncryptMsg(CPacket &rkPacket)
{
// Check Sum
DWORD dwResult = MakeDigest((BYTE*)rkPacket.GetBuffer(), rkPacket.GetBufferSize());
rkPacket.SetCheckSum( dwResult );
// Encryption
BYTE *pSrc;
pSrc = (BYTE*)rkPacket.GetBuffer() + PK_CKSUM_ADDR;
Encrypt( pSrc, rkPacket.GetBufferSize() - PK_CKSUM_ADDR );
}
void CIOSecurity::DecryptMsg( CPacket &rkPacket )
{
// Decryption
BYTE *pSrc;
pSrc = (BYTE*)rkPacket.GetBuffer() + PK_CKSUM_ADDR;
Decrypt( pSrc, rkPacket.GetBufferSize() - PK_CKSUM_ADDR );
}
bool CIOSecurity::IsCheckSum( CPacket &rkPacket )
{
DecryptMsg( rkPacket );
DWORD dwTemp = rkPacket.GetCheckSum(); //Àӽà ÀúÀå.
rkPacket.SetCheckSum( 0 );
DWORD dwResult = MakeDigest( (BYTE*)rkPacket.GetBuffer(), rkPacket.GetBufferSize() );
rkPacket.SetCheckSum( dwTemp );
return (dwResult == rkPacket.GetCheckSum());
}
// Packet Replay
int CIOSecurity::GetSndState()
{
return m_SndState.GetState();
}
void CIOSecurity::UpdateSndState()
{
m_SndState.UpdateState();
}
int CIOSecurity::GetRcvState()
{
return m_RcvState.GetState();
}
void CIOSecurity::UpdateRcvState()
{
m_RcvState.UpdateState();
}
bool CIOSecurity::CheckState( CPacket &rkPacket )
{
if( GetRcvState() == MAGIC_TOKEN_FSM )
{
m_RcvState.SetState( rkPacket.GetState() );
m_SndState.SetState( rkPacket.GetState() );
UpdateSndState();
}
else
{
if( GetRcvState() != rkPacket.GetState() )
return false;
}
UpdateRcvState();
return true;
}
bool CIOSecurity::CheckNS( CPacket &rkPacket )
{
if( !IsCheckSum( rkPacket ) )
{
return false;
}
if( !CheckState( rkPacket ) )
{
return false;
}
return true;
}
void CIOSecurity::PrepareMsg( CPacket &rkPacket )
{
rkPacket.SetState( GetSndState() );
EncryptMsg( rkPacket );
UpdateSndState();
}
void CIOSecurity::CompletionMsg( CPacket &rkPacket )
{
}
@@ -0,0 +1,41 @@
#pragma once
#include "Network/Packet.h"
#include "Network/FSM.h"
class CIOSecurity
{
public:
CIOSecurity(void);
~CIOSecurity(void);
void Init();
void Destroy();
public:
void InitState();
protected:
void EncryptMsg( CPacket &rkPacket );
void DecryptMsg( CPacket &rkPacket );
public:
virtual bool IsCheckSum( CPacket &rkPacket );
public:
virtual int GetSndState();
virtual void UpdateSndState();
virtual int GetRcvState();
virtual void UpdateRcvState();
virtual bool CheckState( CPacket &rkPacket );
virtual bool CheckNS( CPacket &rkPacket );
public:
virtual void PrepareMsg( CPacket &rkPacket );
virtual void CompletionMsg( CPacket &rkPacket );
protected:
FSM m_SndState;
FSM m_RcvState;
};
@@ -0,0 +1,202 @@
#include "StdAfx.h"
#include "resource.h"
#include "ZoneDialog.h"
#include "WinMessage.h"
#include "IOSocket.h"
CIOSocket::CIOSocket(void) : m_connected(FALSE), m_dlg(NULL), m_bytesSent(0), m_bytesBufferSize(0), m_bytesReceived(0)
{
Init();
}
CIOSocket::~CIOSocket(void)
{
Destroy();
}
void CIOSocket::Init()
{
ZeroMemory(m_sendBuffer, sizeof(m_sendBuffer));
m_billingKeyIndex = -1;
}
void CIOSocket::Destroy()
{
}
BOOL CIOSocket::Create()
{
InitState();
if(CAsyncSocket::Create())
{
BOOL flag = 1;
SetSockOpt(TCP_NODELAY, &flag, sizeof(flag), IPPROTO_TCP);
return TRUE;
}
return FALSE;
}
BOOL CIOSocket::Connect(const ServerTypes serverType, CZoneDialog* dlg, const char* IP, const int port)
{
SetType(serverType);
SetDlg(dlg);
return CAsyncSocket::Connect(IP, port);
}
BOOL CIOSocket::BillingServerConnect(const ServerTypes serverType, CZoneDialog* dlg, const char* IP, const int port, const int billingkeyIndex)
{
SetType(serverType);
SetDlg(dlg);
SetBillingIndex(billingkeyIndex);
return CAsyncSocket::Connect(IP, port);
}
void CIOSocket::Disconnect()
{
CAsyncSocket::Close();
}
void CIOSocket::SendPacket(CPacket &rkPacket)
{
if(IsConnected())
{
PrepareMsg( rkPacket );
m_bytesBufferSize = rkPacket.GetBufferSize();
CopyMemory(m_sendBuffer, rkPacket.GetBuffer(), m_bytesBufferSize);
int sentBytes = CAsyncSocket::Send(rkPacket.GetBuffer(), rkPacket.GetBufferSize());
if(sentBytes > 0)
{
if(sentBytes != rkPacket.GetBufferSize())
{
TRACE(_T("Send loop : %d\r\n"), sentBytes);
}
}
else
{
DWORD error = GetLastError();
TRACE(_T("Send failed : %lu\r\n"), error);
}
CompletionMsg( rkPacket );
}
}
void CIOSocket::OnConnect(int nErrorCode)
{
if(0 == nErrorCode)
{
SetConnected(TRUE);
BOOL flag = 1;
SetSockOpt(TCP_NODELAY, &flag, sizeof(flag), IPPROTO_TCP);
}
else
{
SetConnected(FALSE);
}
GetDlg()->OnConnect(GetType(), nErrorCode, GetBillingIndex());
}
void CIOSocket::OnClose(int nErrorCode)
{
SetConnected(FALSE);
GetDlg()->OnClose(GetType(), nErrorCode, GetBillingIndex());
}
void CIOSocket::OnReceive(int nErrorCode)
{
TCHAR buffer[1024 * 16];
int readBytes = Receive(buffer, _countof(buffer));
switch (readBytes)
{
case 0:
{
Close();
}
break;
case SOCKET_ERROR:
{
if (GetLastError() != WSAEWOULDBLOCK)
{
Close();
}
}
break;
default:
{
// 저장된 버퍼에 복사
CopyMemory(m_recvBuffer + m_bytesReceived, buffer, readBytes);
m_bytesReceived += readBytes;
while(m_bytesReceived > 0)
{
CPacket kPacket((char*)m_recvBuffer, m_bytesReceived);
if( kPacket.IsValidPacket() && m_bytesReceived >= kPacket.GetBufferSize() )
{
if(CheckNS( kPacket))
{
GetDlg()->OnReceive(GetType(), (SP2Packet&)kPacket); //타입이랑, 패킷을 PostMessage로 보내도록 수정해야함
TRACE("right recv byte : %lu, packet size %lu\n", m_bytesReceived, kPacket.GetBufferSize());
m_bytesReceived -= kPacket.GetBufferSize();
CopyMemory(m_recvBuffer, m_recvBuffer+kPacket.GetBufferSize(), m_bytesReceived);
}
else
{
break;
}
}
else
{
// 패킷이 적게 들어옴
TRACE("less recv byte : %lu, packet size %lu\n", m_bytesReceived, kPacket.GetBufferSize());
break;
}
}
}
break;
}
}
void CIOSocket::OnSend(int nErrorCode)
{
TRACE(_T("OnSend : %d\r\n"), nErrorCode);
//while (m_bytesSent < m_bytesBufferSize)
//{
// int sentBytes = Send(m_sendBuffer + m_bytesSent, m_bytesBufferSize - m_bytesSent);
// if(sentBytes == SOCKET_ERROR)
// {
// if (GetLastError() == WSAEWOULDBLOCK)
// {
// break;
// }
// else
// {
// Close();
// }
// }
// else
// {
// m_bytesSent += sentBytes;
// }
//}
//
//if (m_bytesSent == m_bytesBufferSize)
//{
// m_bytesSent = 0;
// m_bytesBufferSize = 0;
// ZeroMemory(m_sendBuffer, sizeof(m_sendBuffer));
//}
}
@@ -0,0 +1,65 @@
#pragma once
#include "IOSecurity.h"
#include "ServerTypes.h"
#include "Network/Packet.h"
enum SocketEvents
{
SOCKEVENT_NONE = 0,
SOCKEVENT_CONNECT,
SOCKEVENT_RECEIVE,
SOCKEVENT_SEND,
SOCKEVENT_CLOSE,
SOCKEVENT_END
};
class CZoneDialog;
class CIOSocket : public CAsyncSocket, public CIOSecurity
{
public:
CIOSocket(void);
~CIOSocket(void);
void Init();
void Destroy();
public:
BOOL Create();
BOOL Connect(const ServerTypes serverType, CZoneDialog* dlg, const char* IP, const int port);
BOOL BillingServerConnect(const ServerTypes serverType, CZoneDialog* dlg, const char* IP, const int port, const int billingIndex);
void Disconnect();
void SendPacket(CPacket &rkPacket);
protected:
void SetType(const ServerTypes type) { m_serverType = type; }
void SetConnected(const BOOL b) { m_connected = b; }
void SetDlg(CZoneDialog* dlg) { m_dlg = dlg; }
void SetBillingIndex(const int billingkeyIndex) { m_billingKeyIndex = billingkeyIndex; }
ServerTypes GetType() { return m_serverType; }
BOOL IsConnected() { return m_connected; }
CZoneDialog* GetDlg() { return m_dlg; }
int GetBillingIndex() { return m_billingKeyIndex; }
public:
virtual void OnConnect(int nErrorCode);
virtual void OnClose(int nErrorCode);
virtual void OnReceive(int nErrorCode);
virtual void OnSend(int nErrorCode);
protected:
ServerTypes m_serverType;
CZoneDialog* m_dlg;
int m_billingKeyIndex;
BOOL m_connected;
BYTE m_sendBuffer[1024 * 16];
BYTE m_recvBuffer[1024 * 16];
int m_bytesSent;
int m_bytesBufferSize;
int m_bytesReceived;
};
@@ -0,0 +1,26 @@
#ifndef _FSM_h_
#define _FSM_h_
#define MAGIC_TOKEN_FSM -1
class FSM
{
protected:
int m_iState;
public:
void InitState();
void UpdateState();
public:
bool IsFirst();
int GetState();
void SetState(int iState);
public:
FSM();
};
#endif
@@ -0,0 +1,8 @@
#ifndef _cryption_h_
#define _cryption_h_
void Encrypt(BYTE *szSrc, int len);
void Decrypt(BYTE *szSrc, int len);
#endif
@@ -0,0 +1,22 @@
#ifndef _MD5_H
#define _MD5_H
typedef struct tagMD5Context
{
DWORD buf[4];
DWORD bits[2];
unsigned char in[64];
}MD5Context;
void MD5Init( MD5Context *context );
void MD5Update( MD5Context *context, unsigned char const *buf,
unsigned len );
void MD5Final( unsigned char digest[16], MD5Context *context );
void MD5Transform( DWORD buf[4], DWORD const in[16] );
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
#endif /* !MD5_H */
@@ -0,0 +1,61 @@
#ifndef _CCLINETOBJECT_H_
#define _CCLINETOBJECT_H_
// 서버에서 클라이언트를 관리할때 사용하는 클래스들이 상속해야하는 클래스
// GameServer의 UserNode, 로그인서버의 UserObject, GameServerObject들이 이범주에 속한다.
#define MAX_MSG_COUNT_ONE_SEC 15
class __EX CClientObject
{
public:
void New(SOCKET csocket,DWORD msg_one_sec_count = MAX_MSG_COUNT_ONE_SEC);
void Delete();
protected:
bool m_bExist;
SOCKET m_socket;
SendBuffer m_SendBuffer;
RecvBuffer m_RecvBuffer;
FSM m_sndState;
FSM m_rcvState;
DWORD m_dwTimeCountZero;
DWORD m_dwRcvMsgCount;
DWORD m_max_one_sec_msg_count;
int m_iCurMagicNum;
public:
bool IsExist(){ return m_bExist; }
bool IsValid();
SOCKET GetSocket() const { return m_socket; }
SendBuffer* GetSendBuffer() { return &m_SendBuffer; }
RecvBuffer* GetRecvBuffer() { return &m_RecvBuffer; }
public:
void InitState();
int GetSndServerState();
int GetRcvServerState();
void SetSndServerState(int iState);
void SetRcvServerState(int iState);
void UpdateSndServerState();
void UpdateRcvServerState();
public:
DWORD GetRcvMsgCount();
bool UpdateMsgCount();
public:
inline void AddMagicNum() { m_iCurMagicNum++; }
inline int GetMagicNum() const { return m_iCurMagicNum; }
inline void ClearMagicNum() { m_iCurMagicNum = 0; }
public:
CClientObject();
CClientObject(SOCKET csocket);
virtual ~CClientObject();
};
#endif
@@ -0,0 +1,28 @@
#ifndef _RECVBUFFER_H_
#define _RECVBUFFER_H_
#include "CGenericMessage.h"
class __EX RecvBuffer
{
private:
CGenericRcvMsg m_RcvMsg;
int m_curRcvSize;
int m_curTotalSize;
public:
void InitBuffer();
bool IsAllRecvMsg();
void UpdateRecvData(int curRcvSize);
public:
LPSTR GetBufferPtr(){ return (LPSTR)((char*)&m_RcvMsg + m_curRcvSize); }
int GetCurBufferSize();
int GetCurTotalSize(){ return m_curTotalSize; }
public:
CGenericRcvMsg* GetRcvMsgPtr(){ return &m_RcvMsg; }
};
#endif
@@ -0,0 +1,42 @@
#ifndef _SENDBUFFER_H_
#define _SENDBUFFER_H_
#define MAX_BUFF_SIZE 16384
#define MAX_TEMP_BUFF 16384
//HARDCODE : MAX_TEMP_BUFF 는 Recv와 비슷한 이유에서 필요함
// WSASend시에 m_pStart부터 보내게 되는데 m_pStart가 마지막쪽에 있는경우
// 앞쪽데이터를 이쪽으로 끌고와서 직선형태의 버퍼로 만들어주어야 하기때문임
class __EX SendBuffer
{
private:
char m_pBuffer[MAX_BUFF_SIZE + MAX_TEMP_BUFF];
char *m_pStart;
char *m_pEnd;
int m_iRestCnt;
bool m_bBlock;
public:
void InitBuffer();
void ClearBuffer();
public:
bool EnqueueData(char *pData, int iPacketSize); // return : Can Now Send ?
int DequeueData(int iTransfered);
public:
int GetRestCnt();
char* GetQueuePtr() { return m_pStart; }
public:
void SetBlock(bool bBlock){ m_bBlock = bBlock; }
bool IsBlocked(){ return m_bBlock; }
public:
SendBuffer();
virtual ~SendBuffer();
};
#endif
@@ -0,0 +1,57 @@
// CClientTCPSocket.h
//
#if !defined(CClientTCPSocket_h)
#define CClientTCPSocket_h
#include "RecvBuffer.h"
#include "SendBuffer.h"
class __EX CClientTCPSocket : public CGenericSocket
{
public:
bool InitClientTCP(HWND ishwnd, UINT imsg, char *iip, int iport);
void CloseClientTCP();
public:
bool EvaluateSocket(WPARAM wParam, LPARAM lParam);
virtual bool SendLoop(char* snd, int snd_size);
int BufferSendLoop();
virtual bool ReceiveLoop(SOCKET rsocket);
virtual bool ReceiveProcess(SOCKET csocket);
bool CheckValidMsg( CGenericRcvMsg *pGeneric );
public:
virtual void ConnectProcess() = 0;
virtual void DisconnectProcess() = 0;
virtual void ProcessRcvMsg(CGenericRcvMsg *pGeneric) = 0;
public:
bool IsConnect(){return m_is_connect;};
SOCKET GetSocket(){return m_socket_object; };
public:
void InitClientState();
void SetSndClientState(int iState);
void SetRcvClientState(int iState);
int GetSndClientState();
int GetRcvClientState();
void UpdateSndClientState();
void UpdateRcvClientState();
public:
CClientTCPSocket();
virtual ~CClientTCPSocket();
protected:
bool m_is_connect;
RecvBuffer m_RecvBuffer;
SendBuffer m_SendBuffer;
FSM m_sndState;
FSM m_rcvState;
};
#endif /* CClientTCPSocket_h */
@@ -0,0 +1,48 @@
// CGenericMessage.h
//
#if !defined(CGenericMessage_h)
#define CGenericMessage_h
#define ERROR_CHECK_CODE 0x2B1C
#define MAX_SOCKET_BUFFER 16384
class __EX CGenericMessage
{
protected:
int m_message_size;
DWORD m_dwType;
DWORD m_error_check;
DWORD m_check_sum;
int m_iState;
public:
void EncryptMsg();
bool CheckError();
bool CheckCheckSum();
protected:
DWORD MakeDigest();
public:
void SetState(int iState);
void SetBasicHeader(int isize, DWORD itype);
public:
DWORD GetType();
DWORD GetSize();
int GetState();
public:
CGenericMessage();
};
class __EX CGenericRcvMsg : public CGenericMessage
{
public:
char m_message[MAX_SOCKET_BUFFER];
};
#endif /* CGenericMessage_h */
@@ -0,0 +1,24 @@
// CGenericSocket.h
//
#if !defined(CGenericSocket_h)
#define CGenericSocket_h
#define MAX_SOCKET_DELAY_COUNT 10
#include <winsock.h>
class __EX CGenericSocket
{
public:
bool InitSocket();
void CloseSocket();
int CheckSocketError(LPSTR filename, int linenum);
protected:
SOCKET m_socket_object;
HWND m_socket_hwnd;
UINT m_wnd_message;
};
#endif /* CGenericSocket_h */
@@ -0,0 +1,48 @@
#ifndef _CSERVERTCPSOCKET_H_
#define _CSERVERTCPSOCKET_H_
#include "CGenericSocket.h"
class RecvBuffer;
class CClientObject;
class CGenericRcvMsg;
#define SEM_NOT_VALID_MSG 1001
#define SEM_TOO_MANY_MSG_ONE_SEC 1002
#define MAX_BYPASS_MAGIC_TOKEN 5
class __EX CServerTCPSocket : public CGenericSocket
{
protected:
bool m_bServerClientSocket;
public:
inline void SetServerClientSocket( bool bClient ) { m_bServerClientSocket = bClient; }
inline bool IsServerClientSocket() const { return m_bServerClientSocket; }
public:
bool InitServerTCP (HWND ishwnd, UINT imsg, int iport);
void CloseServerTCP();
public:
bool EvaluateSocket(WPARAM wParam, LPARAM lParam);
bool SendLoop(CClientObject &client_object, char* snd, int snd_size);
bool BufferSendLoop(CClientObject &client_object);
bool ReceiveProcess(SOCKET csocket);
int ReceiveLoop(SOCKET rsocket, RecvBuffer *pBuffer); // return value > 0 : ¸Þ½ÃÁö »çÀÌÁî '=0' grace close, '-1'¿¡·¯, '-2'ºí·°
bool CheckValidMsg( CClientObject *pObject, CGenericRcvMsg *pGeneric );
public:
virtual CClientObject* FindClientObject(SOCKET csocket) = 0;
virtual void ClientAcceptProcess(SOCKET csocket, LPCTSTR cip) = 0;
virtual void ClientDisconnectProcess(SOCKET csocket) = 0;
virtual void ProcessRcvMsg(SOCKET csocket, CGenericRcvMsg *pGeneric) = 0;
virtual void SocketErrorMsg( SOCKET csocket, int iErrorType ) = 0;
public:
CServerTCPSocket();
virtual ~CServerTCPSocket();
};
#endif /* CServerTCPSocket_h */
@@ -0,0 +1,47 @@
// CUDPSocket.h
//
#if !defined(CUDPSocket_h)
#define CUDPSocket_h
#define SEM_UDP_NOT_VALID_MSG 1001
#define SEM_UDP_STATE_SAME 1002
class __EX CUDPSocket : public CGenericSocket
{
public:
bool InitUDP(HWND ishwnd, UINT imsg, int iport);
void CloseUDP();
bool SendLoop(char* ip, int port, char* snd, int snd_size);
bool ReceiveLoop(SOCKET rsocket, CGenericRcvMsg & Generic);
void GetRecentIPPort(char *ip, int & port);
char* GetMyIP();
public:
bool CheckValidMsg(CGenericRcvMsg *pGeneric);
virtual void SocketErrorMsg(int iType);
protected:
void InitState();
bool SetSndStateIfFirst();
void SetRcvState(int iState);
int GetRcvState();
int GetSndState();
void UpdateSndState();
public:
CUDPSocket();
virtual ~CUDPSocket();
protected:
char m_recent_rcv_ip[16];
int m_recent_rcv_port;
int m_main_port;
char m_pre_recent_rcv_ip[16];
int m_pre_recent_rcv_port;
FSM m_rcvState;
FSM m_sndState;
};
#endif /* CUDPSocket_h */
@@ -0,0 +1,60 @@
/********************************************************************
created: 2003/01/22
created: 22:1:2003 10:40
filename: e:\¡á now\workingdll\iosocketdll\iosocket\iosocketdll.h
file path: e:\¡á now\workingdll\iosocketdll\iosocket
file base: iosocketdll
file ext: h
author: ±èÀÎÁß
purpose:
history:
2003/01/22 Edit IOSocketDLL after Generalizing LogDLL.
*********************************************************************/
#ifndef __IOSOCKETDLL_H__
#define __IOSOCKETDLL_H__
#ifndef __DLL_INFO__
#define __DLL_INFO__
#define WIN32_LEAN_AND_MEAN
//#define __WORK__
//#define __MK_DLL__
#ifdef __WORK__
#define __EX
#else
#ifdef __MK_DLL__
#define __EX __declspec(dllexport)
#else
#define __EX __declspec(dllimport)
#endif
#endif
#endif
#include <stdio.h>
#include <windows.h>
#include "IncludeDLL/LogDLL.h"
#pragma comment(lib, "ws2_32.lib")
#ifdef _DEBUG
#pragma comment(lib, "IncludeDLL/LogDDLL.lib")
#else
#pragma comment(lib, "IncludeDLL/LogDLL.lib")
#endif
#pragma warning(disable:4251)
#include "Encrypt/FSM.h"
#include "IOSocket/cgenericsocket.h"
#include "IOSocket/cgenericmessage.h"
#include "IOSocket/RecvBuffer.h"
#include "IOSocket/SendBuffer.h"
#include "IOSocket/cclienttcpsocket.h"
#include "IOSocket/cservertcpsocket.h"
#include "IOSocket/cudpsocket.h"
#include "IOSocket/CClientObject.h"
#endif
@@ -0,0 +1,75 @@
/********************************************************************
created: 2003/01/22
created: 22:1:2003 10:12
filename: e:\■ now\workingdll\logdll\logdll.h
file path: e:\■ now\workingdll\logdll
file base: logdll
file ext: h
author: 김인중
purpose:
history:
2003.1.23 replace wsprintf by sprintf.
2003.1.22 add ASSERT processing
2003.1.22 add log function, CLog:DebugLOG, DebugMBox
for debug infomation (__FILE__, __LINE__)
2003.1.22 edit DEBUGLOG, DEBUGBOX definition for using this function
2003.2.27 add debug level
*********************************************************************/
#ifndef ___LOG_H__
#define ___LOG_H__
#define WIN32_LEAN_AND_MEAN
//#define __EX __declspec(dllexport)
//#define __EX __declspec(dllimport)
#define __IM __declspec(dllimport)
#include <stdio.h>
#include <windows.h>
#include <direct.h>
#include <assert.h>
#include <conio.h>
/**************** Debuging시 사용 ******************
LOG.DebugLog(__FILE__,__LINE__,
DebugMBox(__FILE__,__LINE__,NULL,
****************************************************/
// assert는 Resize class 적용하면서 충돌이 발생하여 주석 처리함.
//#ifdef ASSERT
//#undef ASSERT
//#endif
//#define ASSERT(f) {if(!(f)) {LOG.DebugLog(0, __FILE__,__LINE__,"ASSERT Fail,return"); assert(f);return;}}
//#define ASSERT_minusone(f) {if(!(f)) {LOG.DebugLog(0, __FILE__,__LINE__,"ASSERT Fail,return -1"); assert(f);return -1;}}
//#define ASSERT_false(f) {if(!(f)) {LOG.DebugLog(0, __FILE__,__LINE__,"ASSERT Fail,return false"); assert(f);return false;}}
class __IM CLog
{
public:
char m_file_name[255];
int m_debug_level;
CRITICAL_SECTION m_critical_section;
void OpenLog(int debuglv, char* fName, bool is_append = false); // debug lv : 0 Release version, 0302(3월2일) private debug version
void CloseLog();
void PrintNoEnterLog(int debuglv, LPSTR fmt,...);
void PrintLog(int debuglv, LPSTR fmt,...);
void PrintTimeAndLog(int debuglv, LPSTR fmt,...);
void DebugLog(int debuglv, LPSTR filename, int linenum, LPSTR fmt,...);
void WriteReadyFolderAndFiles(char *fName);
void PrintConsoleLog(int debuglv,LPSTR fmt,...);
void CloseAndRelease();
CLog();
virtual ~CLog();
protected:
FILE* m_pFile;
};
extern __IM CLog LOG;
__IM void MBox(HWND thwnd, LPSTR title, LPSTR szStr,...);
__IM void DebugMBox(LPSTR filename, int linenum, HWND thwnd, LPSTR szStr,...);
#endif
@@ -0,0 +1,296 @@
// ItemDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "ItemDlg.h"
#include "afxdialogex.h"
// CItemDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CItemDlg, CDialogEx)
CItemDlg::CItemDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CItemDlg::IDD, pParent), m_parent(NULL), m_namePropertyRadio(0)
{
m_namePropertyRadio = MONITER_INSERT_ITEM_PUBLIC_ID;
}
CItemDlg::~CItemDlg()
{
}
void CItemDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_OPITEM, m_itemList);
DDX_Control(pDX, IDC_LIST_OPUSERID, m_userList);
DDX_Control(pDX, IDC_EDIT_ITEMUSERID, m_editUserID);
DDX_Control(pDX, IDC_EDIT_ITEMCODE, m_editItemCode);
DDX_Control(pDX, IDC_CHECK_SEAL, m_seal);
DDX_Radio(pDX, IDC_RADIO_NAME_PUBLIC, m_namePropertyRadio);
}
BEGIN_MESSAGE_MAP(CItemDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_ITEMINSERT, &CItemDlg::OnBnClickedButtonItemInsert)
ON_BN_CLICKED(IDC_BUTTON_ITEMRESET, &CItemDlg::OnBnClickedButtonItemReset)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_OPUSERID, &CItemDlg::OnLvnItemchangedListOpuserid)
ON_BN_CLICKED(IDC_STATIC_ISPUBLIC, &CItemDlg::OnBnClickedStaticIspublic)
ON_CONTROL_RANGE(BN_CLICKED, IDC_RADIO_NAME_PUBLIC, IDC_RADIO_NAME_PRIVATE, &CItemDlg::OnNamePropertyRadioCtrl)
END_MESSAGE_MAP()
// CItemDlg 메시지 처리기입니다.
BOOL CItemDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
InitList();
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CItemDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
void CItemDlg::InitList()
{
m_userList.DeleteAllItems();
m_userList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_userList.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 120);
m_itemList.DeleteAllItems();
m_itemList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_itemList.InsertColumn(0, _T("PresentType"), LVCFMT_LEFT, 75);
m_itemList.InsertColumn(1, _T("Value1"), LVCFMT_LEFT, 100);
m_itemList.InsertColumn(2, _T("Value2"), LVCFMT_LEFT, 100);
}
void CItemDlg::OnBnClickedButtonItemInsert()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
int seal = m_seal.GetCheck();
CString userId, presentType, value1, value2;
for(int i = 0 ; i < m_userList.GetItemCount() ; i++)
{
userId = m_userList.GetItemText(i, 0);
for(int j = 0 ; j < m_itemList.GetItemCount() ; j++)
{
presentType = m_itemList.GetItemText(j, 0);
value1 = m_itemList.GetItemText(j, 1);
value2 = m_itemList.GetItemText(j, 2);
// 아이템 추가
if(seal == 0)
{
ReqeustItemInsert(userId, atoi(presentType), atoi(value1), atoi(value2), 1, m_namePropertyRadio);
}
else
{
ReqeustItemInsert(userId, atoi(presentType), atoi(value1), atoi(value2), 40, m_namePropertyRadio);
}
Sleep(10);
}
}
MessageBox(_T("Completed"), _T("ITEM"), MB_OK);
}
void CItemDlg::InsertUserID(CString userId)
{
if(userId.GetLength() == 0) return;
m_userList.InsertItem(m_userList.GetItemCount(), userId);
}
void CItemDlg::InsertItemCode(CString itemCode)
{
if(itemCode.GetLength() == 0) return;
int index = 0;
CString presentType, value1, value2;
presentType = itemCode.Tokenize(_T("."), index);
if(presentType.IsEmpty()) return;
value1 = itemCode.Tokenize(_T("."), index);
if(value1.IsEmpty()) return;
value2 = itemCode.Tokenize(_T("."), index);
if(value2.IsEmpty()) return;
int itemCount = m_itemList.GetItemCount();
m_itemList.InsertItem(itemCount, presentType);
m_itemList.SetItemText(itemCount, 1, value1);
m_itemList.SetItemText(itemCount, 2, value2);
}
void CItemDlg::OnDropUserFiles(CString file)
{
m_userList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertUserID(line);
}
}
}
}
void CItemDlg::OnDropItemFiles(CString file)
{
m_itemList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertItemCode(line);
}
}
}
}
void CItemDlg::ReqeustItemInsert(CString userId, int presentType, int value1, int value2, int ment, int isPublicIDState)
{
m_parent->RequestItemInsert(userId, presentType, value1, value2, ment, isPublicIDState);
}
BOOL CItemDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(WM_DROPFILES == pMsg->message)
{
if(m_userList.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropUserFiles( file );
}
}
else if(m_itemList.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropItemFiles( file );
}
}
}
else if(WM_KEYDOWN == pMsg->message )
{
if(VK_RETURN == pMsg->wParam)
{
if(m_editUserID.GetSafeHwnd() == pMsg->hwnd)
{
CString userId;
m_editUserID.GetWindowText(userId);
m_editUserID.SetWindowText(_T(""));
InsertUserID(userId);
}
else if(m_editItemCode.GetSafeHwnd() == pMsg->hwnd)
{
CString itemCode;
m_editItemCode.GetWindowText(itemCode);
m_editItemCode.SetWindowText(_T(""));
InsertItemCode(itemCode);
}
return TRUE;
}
else if(VK_DELETE == pMsg->wParam)
{
if(m_userList.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_userList.GetSelectedCount();
if(count > 0)
{
DeleteListItem(m_userList);
}
}
else if(m_itemList.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_itemList.GetSelectedCount();
if(count > 0)
{
DeleteListItem(m_userList);
}
}
return TRUE;
}
}
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
void CItemDlg::OnBnClickedButtonItemReset()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_itemList.DeleteAllItems();
m_userList.DeleteAllItems();
}
void CItemDlg::OnLvnItemchangedListOpuserid(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
}
void CItemDlg::DeleteListItem(CListCtrl& m_List)
{
int index = -1;
POSITION pos = m_List.GetFirstSelectedItemPosition();
while(pos)
{
int index = m_List.GetNextSelectedItem(pos);
m_List.DeleteItem(index);
pos = m_List.GetFirstSelectedItemPosition();
}
}
void CItemDlg::OnBnClickedStaticIspublic()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
}
void CItemDlg::OnNamePropertyRadioCtrl( UINT uintID )
{
(uintID == IDC_RADIO_NAME_PUBLIC) ? m_namePropertyRadio = 1 : m_namePropertyRadio = 2;
m_namePropertyRadio;
int a = 0;
}
@@ -0,0 +1,58 @@
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
class CZoneDialog;
// CItemDlg 대화 상자입니다.
class CItemDlg : public CDialogEx
{
DECLARE_DYNAMIC(CItemDlg)
public:
CItemDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CItemDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_ITEM_DIALOG };
public:
void Startup(CZoneDialog* parent);
protected:
void InitList();
void InsertUserID(CString userId);
void InsertItemCode(CString itemCode);
void OnDropUserFiles(CString file);
void OnDropItemFiles(CString file);
void ReqeustItemInsert(CString userId, int presentType, int value1, int value2, int ment = 1, int isPublicIDState =1);
void DeleteListItem(CListCtrl& m_List);
protected:
CZoneDialog* m_parent;
int m_namePropertyRadio;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CListCtrl m_itemList;
CListCtrl m_userList;
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedButtonItemInsert();
CEdit m_editUserID;
CEdit m_editItemCode;
afx_msg void OnBnClickedButtonItemReset();
afx_msg void OnLvnItemchangedListOpuserid(NMHDR *pNMHDR, LRESULT *pResult);
CButton m_seal;
afx_msg void OnBnClickedStaticIspublic();
afx_msg void OnNamePropertyRadioCtrl(UINT uintID);
};
@@ -0,0 +1,95 @@
// LS_MonitorClient.cpp : 응용 프로그램에 대한 클래스 동작을 정의합니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "LS_MonitorClientDlg.h"
#include <crtdbg.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CLS_MonitorApp
BEGIN_MESSAGE_MAP(CLS_MonitorApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CLS_MonitorApp 생성
CLS_MonitorApp::CLS_MonitorApp()
{
// 다시 시작 관리자 지원
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
// TODO: 여기에 생성 코드를 추가합니다.
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
m_pMonitorDlg = NULL;
}
// 유일한 CLS_MonitorApp 개체입니다.
CLS_MonitorApp theApp;
// CLS_MonitorApp 초기화
BOOL CLS_MonitorApp::InitInstance()
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
// 이 항목을 설정하십시오.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화
// 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
CLS_MonitorClientDlg dlg(m_lpCmdLine);
m_pMainWnd = &dlg;
m_pMonitorDlg = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 여기에 [확인]을 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
else if (nResponse == IDCANCEL)
{
// TODO: 여기에 [취소]를 클릭하여 대화 상자가 없어질 때 처리할
// 코드를 배치합니다.
}
// 대화 상자가 닫혔으므로 응용 프로그램의 메시지 펌프를 시작하지 않고 응용 프로그램을 끝낼 수 있도록 FALSE를
// 반환합니다.
return FALSE;
}
@@ -0,0 +1,34 @@
// LS_MonitorClient.h : PROJECT_NAME 응용 프로그램에 대한 주 헤더 파일입니다.
//
#pragma once
#ifndef __AFXWIN_H__
#error "PCH에 대해 이 파일을 포함하기 전에 'stdafx.h'를 포함합니다."
#endif
#include "resource.h" // 주 기호입니다.
// CLS_MonitorApp:
// 이 클래스의 구현에 대해서는 LS_MonitorClient.cpp을 참조하십시오.
//
class CLS_MonitorClientDlg;
class CLS_MonitorApp : public CWinApp
{
public:
CLS_MonitorApp();
// 재정의입니다.
public:
virtual BOOL InitInstance();
// 구현입니다.
DECLARE_MESSAGE_MAP()
private:
CLS_MonitorClientDlg* m_pMonitorDlg;
};
extern CLS_MonitorApp theApp;
@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{420FC80A-9842-42AE-8999-C7B2633C7E78}</ProjectGuid>
<RootNamespace>LS_MonitorClient</RootNamespace>
<Keyword>MFCProj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>D:\LostSaga\Work\Monitoring\MonitoringClient</OutDir>
<TargetName>$(ProjectName)D</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>D:\LostSaga\Work\Monitoring\MonitoringClient</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0412</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../src</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</Midl>
<ResourceCompile>
<Culture>0x0412</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
<None Include="res\bitmap1.bmp" />
<None Include="res\LS_MonitorClient.ico" />
<None Include="res\LS_MonitorClient.rc2" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AnnounceDlg.h" />
<ClInclude Include="AuthDlg.h" />
<ClInclude Include="BlockDlg.h" />
<ClInclude Include="cFile.h" />
<ClInclude Include="CompensationDlg.h" />
<ClInclude Include="CSDialog.h" />
<ClInclude Include="Define.h" />
<ClInclude Include="DisplayDlg.h" />
<ClInclude Include="EventDlg.h" />
<ClInclude Include="GraphDlg.h" />
<ClInclude Include="ioHashString.h" />
<ClInclude Include="IOSecurity.h" />
<ClInclude Include="IOSocket.h" />
<ClInclude Include="ItemDlg.h" />
<ClInclude Include="LogDlg.h" />
<ClInclude Include="LoginDialog.h" />
<ClInclude Include="LS_MonitorClient.h" />
<ClInclude Include="LS_MonitorClientDlg.h" />
<ClInclude Include="MonitorListCtrl.h" />
<ClInclude Include="MonitorTabCtrl.h" />
<ClInclude Include="Network\cryption.h" />
<ClInclude Include="Network\FSM.h" />
<ClInclude Include="Network\md5.h" />
<ClInclude Include="Network\Packet.h" />
<ClInclude Include="Network\SP2Packet.h" />
<ClInclude Include="NoticeDlg.h" />
<ClInclude Include="OperatorDlg.h" />
<ClInclude Include="OScopeCtrl.h" />
<ClInclude Include="OScopeTimeCtrl.h" />
<ClInclude Include="PanelDialog.h" />
<ClInclude Include="ProcessCtrl.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="SecretShopDlg.h" />
<ClInclude Include="ServerTypes.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TownPortal.h" />
<ClInclude Include="ZoneDialog.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AnnounceDlg.cpp" />
<ClCompile Include="AuthDlg.cpp" />
<ClCompile Include="BlockDlg.cpp" />
<ClCompile Include="cFile.cpp" />
<ClCompile Include="CompensationDlg.cpp" />
<ClCompile Include="CSDialog.cpp" />
<ClCompile Include="DisplayDlg.cpp" />
<ClCompile Include="EventDlg.cpp" />
<ClCompile Include="GraphDlg.cpp" />
<ClCompile Include="ioHashString.cpp" />
<ClCompile Include="IOSecurity.cpp" />
<ClCompile Include="IOSocket.cpp" />
<ClCompile Include="ItemDlg.cpp" />
<ClCompile Include="LogDlg.cpp" />
<ClCompile Include="LoginDialog.cpp" />
<ClCompile Include="LS_MonitorClient.cpp" />
<ClCompile Include="LS_MonitorClientDlg.cpp" />
<ClCompile Include="MonitorListCtrl.cpp" />
<ClCompile Include="MonitorTabCtrl.cpp" />
<ClCompile Include="Network\cryption.cpp" />
<ClCompile Include="Network\FSM.cpp" />
<ClCompile Include="Network\md5.cpp" />
<ClCompile Include="Network\Packet.cpp" />
<ClCompile Include="Network\SP2Packet.cpp" />
<ClCompile Include="NoticeDlg.cpp" />
<ClCompile Include="OperatorDlg.cpp" />
<ClCompile Include="OScopeCtrl.cpp" />
<ClCompile Include="OScopeTimeCtrl.cpp" />
<ClCompile Include="PanelDialog.cpp" />
<ClCompile Include="ProcessCtrl.cpp" />
<ClCompile Include="SecretShopDlg.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ZoneDialog.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LS_MonitorClient.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="LS_MonitorClient.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>
@@ -0,0 +1,260 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="리소스 파일">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="File">
<UniqueIdentifier>{e740bc70-7b91-4580-b763-49e462211df2}</UniqueIdentifier>
</Filter>
<Filter Include="Network">
<UniqueIdentifier>{76032e2a-7294-45f3-aad5-3125afb3b89f}</UniqueIdentifier>
</Filter>
<Filter Include="UI">
<UniqueIdentifier>{ed593fe3-7bb1-4a45-9171-cc4fd2bac3dd}</UniqueIdentifier>
</Filter>
<Filter Include="UI\Controls">
<UniqueIdentifier>{56039e51-4b32-4e7a-9ce8-3f646a403e10}</UniqueIdentifier>
</Filter>
<Filter Include="Main">
<UniqueIdentifier>{df82e949-d54a-469c-875a-0c1e82477831}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="res\LS_MonitorClient.rc2">
<Filter>리소스 파일</Filter>
</None>
<None Include="res\LS_MonitorClient.ico">
<Filter>리소스 파일</Filter>
</None>
<None Include="res\bitmap1.bmp">
<Filter>리소스 파일</Filter>
</None>
<None Include="ReadMe.txt">
<Filter>리소스 파일</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cFile.h">
<Filter>File</Filter>
</ClInclude>
<ClInclude Include="Network\FSM.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="Network\cryption.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="Network\SP2Packet.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="Network\md5.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="Network\Packet.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="BlockDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="AnnounceDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="AuthDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="CSDialog.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="CompensationDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="DisplayDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="GraphDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="EventDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="IOSocket.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="ioHashString.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="IOSecurity.h">
<Filter>Network</Filter>
</ClInclude>
<ClInclude Include="LoginDialog.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="ItemDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="LogDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="MonitorTabCtrl.h">
<Filter>UI\Controls</Filter>
</ClInclude>
<ClInclude Include="MonitorListCtrl.h">
<Filter>UI\Controls</Filter>
</ClInclude>
<ClInclude Include="OperatorDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="NoticeDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="OScopeTimeCtrl.h">
<Filter>UI\Controls</Filter>
</ClInclude>
<ClInclude Include="OScopeCtrl.h">
<Filter>UI\Controls</Filter>
</ClInclude>
<ClInclude Include="PanelDialog.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="ProcessCtrl.h">
<Filter>UI\Controls</Filter>
</ClInclude>
<ClInclude Include="ZoneDialog.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="SecretShopDlg.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="LS_MonitorClient.h">
<Filter>Main</Filter>
</ClInclude>
<ClInclude Include="LS_MonitorClientDlg.h">
<Filter>Main</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>리소스 파일</Filter>
</ClInclude>
<ClInclude Include="ServerTypes.h">
<Filter>Main</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>리소스 파일</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>리소스 파일</Filter>
</ClInclude>
<ClInclude Include="Define.h">
<Filter>Main</Filter>
</ClInclude>
<ClInclude Include="TownPortal.h">
<Filter>Main</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="cFile.cpp">
<Filter>File</Filter>
</ClCompile>
<ClCompile Include="Network\cryption.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="Network\FSM.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="Network\md5.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="Network\Packet.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="Network\SP2Packet.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="AnnounceDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="AuthDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="BlockDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="CSDialog.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="CompensationDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="DisplayDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="GraphDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="EventDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="IOSocket.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="ioHashString.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="IOSecurity.cpp">
<Filter>Network</Filter>
</ClCompile>
<ClCompile Include="LoginDialog.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="ItemDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="LogDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="MonitorTabCtrl.cpp">
<Filter>UI\Controls</Filter>
</ClCompile>
<ClCompile Include="MonitorListCtrl.cpp">
<Filter>UI\Controls</Filter>
</ClCompile>
<ClCompile Include="NoticeDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="OperatorDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="OScopeCtrl.cpp">
<Filter>UI\Controls</Filter>
</ClCompile>
<ClCompile Include="OScopeTimeCtrl.cpp">
<Filter>UI\Controls</Filter>
</ClCompile>
<ClCompile Include="PanelDialog.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="ProcessCtrl.cpp">
<Filter>UI\Controls</Filter>
</ClCompile>
<ClCompile Include="ZoneDialog.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="SecretShopDlg.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="LS_MonitorClientDlg.cpp">
<Filter>Main</Filter>
</ClCompile>
<ClCompile Include="LS_MonitorClient.cpp">
<Filter>Main</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>리소스 파일</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="LS_MonitorClient.rc">
<Filter>리소스 파일</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
@@ -0,0 +1,340 @@
// LS_MonitorClientDlg.cpp : 구현 파일
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "LS_MonitorClientDlg.h"
#include "WinMessage.h"
#include "afxdialogex.h"
#include "Define.h"
#include "ServerTypes.h"
#include "IOSocket.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CLS_MonitorClientDlg 대화 상자
CLS_MonitorClientDlg::CLS_MonitorClientDlg(const TCHAR* parameter, CWnd* pParent /*=NULL*/)
: CDialogEx(CLS_MonitorClientDlg::IDD, pParent)
{
m_parameter = parameter;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CLS_MonitorClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB_ZONES, m_zoneTabs);
}
BEGIN_MESSAGE_MAP(CLS_MonitorClientDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
ON_WM_SIZING()
ON_WM_GETMINMAXINFO()
ON_WM_DESTROY()
END_MESSAGE_MAP()
BEGIN_EASYSIZE_MAP(CLS_MonitorClientDlg)
EASYSIZE(IDC_TAB_ZONES,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,ES_HCENTER)
END_EASYSIZE_MAP
// CLS_MonitorClientDlg 메시지 처리기
BOOL CLS_MonitorClientDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
// 프레임워크가 이 작업을 자동으로 수행합니다.
SetIcon(m_hIcon, TRUE); // 큰 아이콘을 설정합니다.
SetIcon(m_hIcon, FALSE); // 작은 아이콘을 설정합니다.
// TODO: Add extra initialization here
CString filePath = m_parameter;
if(filePath.IsEmpty())
{
filePath = _T("config.ini");
}
LoadINI(filePath);
LoadIP();
m_zoneTabs.ShowTab(0);
GetClientRect(m_clientRect);
INIT_EASYSIZE;
return TRUE; // 포커스를 컨트롤에 설정하지 않으면 TRUE를 반환합니다.
}
// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는
// 프레임워크에서 이 작업을 자동으로 수행합니다.
void CLS_MonitorClientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트입니다.
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 아이콘을 그립니다.
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
// 이 함수를 호출합니다.
HCURSOR CLS_MonitorClientDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
BOOL CLS_MonitorClientDlg::LoadBillingFromINI(const TCHAR* file, CString section, BILLINGSERVERTABLE &tempBillingServerTable)
{
BOOL flag = FALSE;
TCHAR buffer[512];
TCHAR path[512];
GetCurrentDirectory(sizeof(path), path);
CString fullPath;
CString defaultStr= "default";
fullPath.Format(_T("%s\\%s"), path, file);
CString name, billing;
if(section == "")
return FALSE;
int i = 1;
while(TRUE)
{
CString strNum;
strNum.Format(_T("billing%d"), i);
// name
DWORD result= GetPrivateProfileString(
section, //zone
strNum, //billing
defaultStr,
buffer,
_countof(buffer),
fullPath);
buffer[result] = 0;
if(defaultStr != buffer)
{
billing = buffer;
i++;
int curPos = 0;
int count = tempBillingServerTable.size(); //count 값이 빌링 구분값
BILLINGSERVERINFO* billingServer = new BILLINGSERVERINFO;
billingServer->serviceIP = billing.Tokenize(_T(":"), curPos);
CString billingPort = billing.Tokenize(_T(":"), curPos);
billingServer->servicePort = atoi(billingPort);
billingServer->billingServerState = SERVERSTATE_OFF;
billingServer->serverType = SERVER_TYPE_BILLING;
billingServer->serverKeyIndex = count;
tempBillingServerTable[count] = billingServer;
}
else
{
break;
}
}
if( tempBillingServerTable.size() > 0 )
{
flag = TRUE;
}
return flag;
}
//. ini 에서 빌링서버옵션 읽을 수 있도록 추가
void CLS_MonitorClientDlg::LoadINI(const TCHAR* file)
{
BOOL billingFlag = FALSE;
TCHAR buffer[512];
TCHAR path[512];
GetCurrentDirectory(sizeof(path), path);
CString fullPath;
fullPath.Format(_T("%s\\%s"), path, file);
CString defaultStr= "default", section;
CString name, main, login, billing;
int nCode = false;
int iReult = 0;
for(int i = 1 ; ; i++)
{
section.Format(_T("zone%d"), i);
billingFlag = FALSE; //초기화
// name
DWORD result= GetPrivateProfileString(
section,
_T("name"),
defaultStr,
buffer,
_countof(buffer),
fullPath);
buffer[result] = 0;
if(defaultStr == buffer)
break;
name = buffer;
// main
result= GetPrivateProfileString(
section,
_T("main"),
defaultStr,
buffer,
_countof(buffer),
fullPath);
buffer[result] = 0;
main = buffer;
// login
result= GetPrivateProfileString(
section,
_T("login"),
defaultStr,
buffer,
_countof(buffer),
fullPath);
buffer[result] = 0;
login = buffer;
nCode = GetPrivateProfileInt(section, _T("countrycode"), 0, fullPath); // EU 국가별 동접 표시
//빌링 추가
BILLINGSERVERTABLE billingServerTable;
billingFlag = LoadBillingFromINI(file, section, billingServerTable);
if(billingFlag == TRUE)
{
int index = m_zoneTabs.GetItemCount();
//m_zoneTabs.AddTab(name, TRUE, billingServerTable);
m_zoneTabs.AddTab(name, main, login, TRUE, billingServerTable, false);
m_zoneTabs.ShowTab(index, FALSE);
}
// 탭추가
if(billingFlag == FALSE)
{
int index = m_zoneTabs.GetItemCount();
m_zoneTabs.AddTab(name, main, login, FALSE, billingServerTable, (bool)nCode);
m_zoneTabs.ShowTab(index, FALSE);
}
}
}
void CLS_MonitorClientDlg::LoadIP()
{
TCHAR hostName[512];
gethostname(hostName, sizeof(hostName));
hostent* host = gethostbyname(hostName);
struct in_addr addr;
int i = 0;
while (host->h_addr_list[i] != 0)
{
addr.s_addr = *(u_long *) host->h_addr_list[i++];
m_IP = inet_ntoa(addr);
if(!m_IP.IsEmpty())
{
CString title;
title.Format(_T("LostSaga Monitor - %s"), m_IP);
SetWindowText(title);
break;
}
}
}
void CLS_MonitorClientDlg::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
UPDATE_EASYSIZE;
}
void CLS_MonitorClientDlg::OnSizing(UINT fwSide, LPRECT pRect)
{
CDialogEx::OnSizing(fwSide, pRect);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
int width = m_clientRect.Width()+16;
pRect->right = pRect->left + width;
EASYSIZE_MINSIZE(m_clientRect.Width()+16, m_clientRect.Height()+38, fwSide, pRect);
}
void CLS_MonitorClientDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
//lpMMI->ptMaxSize.
int width = m_clientRect.Width()+16;
int spacing = lpMMI->ptMaxTrackSize.x - lpMMI->ptMaxSize.x;
lpMMI->ptMaxSize.x = width;
CDialogEx::OnGetMinMaxInfo(lpMMI);
}
BOOL CLS_MonitorClientDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
void CLS_MonitorClientDlg::UpdateTitle(const CString strIP, const int currentUser, const int maxUser)
{
CString title;
title.Format(_T("LostSaga Monitor Client - %s(%d/%d)"), strIP, currentUser, maxUser);
SetWindowText(title);
}
void CLS_MonitorClientDlg::OnDestroy()
{
CDialogEx::OnDestroy();
VERIFY(m_zoneTabs.DeleteAllItems());
}
@@ -0,0 +1,60 @@
// LS_MonitorClientDlg.h : 헤더 파일
//
#pragma once
#include "afxcmn.h"
#include "MonitorTabCtrl.h"
// CLS_MonitorClientDlg 대화 상자
class CLS_MonitorClientDlg : public CDialogEx
{
DECLARE_EASYSIZE
// 생성입니다.
public:
CLS_MonitorClientDlg(const TCHAR* parameter, CWnd* pParent = NULL); // 표준 생성자입니다.
// 대화 상자 데이터입니다.
enum { IDD = IDD_LS_MONITORCLIENT_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
public:
CString GetIP() { return m_IP; }
void UpdateTitle(const CString strIP, const int currentUser, const int maxUser);
protected:
BOOL LoadBillingFromINI(const TCHAR* file, CString section, BILLINGSERVERTABLE &tempBillingServerTable);
void LoadINI(const TCHAR* file);
void LoadIP();
void AddTab(TCHAR* name, TCHAR* IP, const int port);
protected:
CString m_IP;
CRect m_clientRect;
CString m_parameter;
// 구현입니다.
protected:
HICON m_hIcon;
// 생성된 메시지 맵 함수
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
CMonitorTabCtrl m_zoneTabs;
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnDestroy();
};
@@ -0,0 +1,97 @@
// TotalLogDl.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "LogDlg.h"
#include "afxdialogex.h"
// CLogDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CLogDlg, CDialogEx)
CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CLogDlg::IDD, pParent)
{
}
CLogDlg::~CLogDlg()
{
}
void CLogDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control( pDX, IDC_LIST_LOG, m_logList );
}
BEGIN_MESSAGE_MAP(CLogDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_LOG_RESET, &CLogDlg::OnBnClickedButtonLogReset)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_LOG, &CLogDlg::OnLvnItemchangedListLog)
END_MESSAGE_MAP()
// CLogDlg 메시지 처리기입니다.
void CLogDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
void CLogDlg::InitList()
{
m_logList.DeleteAllItems();
m_logList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_logList.InsertColumn(0, _T("Time"), LVCFMT_LEFT, 60);
m_logList.InsertColumn(1, _T("Message"), LVCFMT_LEFT, 375);
}
BOOL CLogDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
InitList();
return TRUE;
}
void CLogDlg::InsertLogText( CString text )
{
if( text.IsEmpty() ) return;
CTime nowTime = CTime::GetCurrentTime();
CString nowTimeText;
nowTimeText.Format( _T(" %02d:%02d:%02d"),
nowTime.GetHour(),
nowTime.GetMinute(),
nowTime.GetSecond() );
int logCount = m_logList.GetItemCount();
m_logList.InsertItem( logCount, nowTimeText );
m_logList.SetItemText( logCount, 1, text );
m_logList.EnsureVisible( m_logList.GetItemCount() - 1, TRUE );
}
void CLogDlg::ResetLogText()
{
m_logList.DeleteAllItems();
}
void CLogDlg::OnBnClickedButtonLogReset()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
ResetLogText();
}
void CLogDlg::OnLvnItemchangedListLog(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
}
@@ -0,0 +1,44 @@
#pragma once
class CZoneDialog;
// CLogDlg 대화 상자입니다.
class CLogDlg : public CDialogEx
{
DECLARE_DYNAMIC(CLogDlg)
public:
CLogDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CLogDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_LOG_DIALOG };
public:
void Startup(CZoneDialog* parent);
protected:
void InitList();
public:
void InsertLogText( CString text );
void ResetLogText();
protected:
CZoneDialog* m_parent;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CListCtrl m_logList;
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedButtonLogReset();
afx_msg void OnLvnItemchangedListLog(NMHDR *pNMHDR, LRESULT *pResult);
};
@@ -0,0 +1,365 @@
// LoginDialog.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "PanelDialog.h"
#include "ZoneDialog.h"
#include "LoginDialog.h"
#include "WinMessage.h"
#include "afxdialogex.h"
#include <algorithm>
enum LoginPanelTimerIDs
{
PANEL_NONE = 0,
PANEL_REFRESH,
PANEL_END
};
// CLoginDialog 대화 상자입니다.
IMPLEMENT_DYNAMIC(CLoginDialog, CDialogEx)
CLoginDialog::CLoginDialog(CWnd* pParent /*=NULL*/)
: CDialogEx(CLoginDialog::IDD, pParent), m_maxUser(0), m_CCU(0), m_maxPanel(0), m_matrix(0), m_curHeight(0), m_scrollPos(0), m_panelWidth(0), m_panelHeight(0)
{
}
CLoginDialog::~CLoginDialog()
{
for(int i = 0 ; i < (int)m_panels.size() ; i++)
{
delete m_panels[i];
m_panels[i] = NULL;
}
//m_panels._Destroy()
}
void CLoginDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CLoginDialog, CDialogEx)
ON_WM_VSCROLL()
ON_WM_SIZE()
ON_WM_MOUSEWHEEL()
ON_WM_SHOWWINDOW()
ON_WM_TIMER()
ON_WM_CLOSE()
ON_WM_SIZING()
END_MESSAGE_MAP()
// CLoginDialog 메시지 처리기입니다.
BOOL CLoginDialog::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
GetClientRect(m_window);
m_scrollPos = 0;
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CLoginDialog::Startup(CString title, const int maxUser, const int maxServer, const int matrix, CZoneDialog* parent)
{
m_title = title;
SetWindowText(title);
m_parent = parent;
m_maxUser = maxUser;
m_maxPanel = maxServer;
m_matrix = matrix;
}
void CLoginDialog::AddPanel(int serverId, CString name, CString IP, int port, int blockState)
{
if(FindPanel(serverId))
return;
int count = m_panels.size();
RECT rcPanel;
CPanelDialog * panelDlg = new CPanelDialog;
panelDlg->Create(IDD_PANEL_DIALOG, this);
panelDlg->Startup(serverId, name, IP, port, blockState, m_maxUser);
panelDlg->ShowWindow(SW_SHOW);
panelDlg->GetClientRect(&rcPanel);
GeneratePos(m_matrix, count, rcPanel);
panelDlg->MoveWindow(&rcPanel);
panelDlg->SetWindowPos(&wndTopMost, 0 , 0 , 0 , 0 , SWP_NOMOVE|SWP_NOSIZE);
panelDlg->ShowWindow(SW_SHOW);
m_panels.push_back(panelDlg);
if(m_panels.size() == 1)
{
m_panelWidth = rcPanel.right - rcPanel.left;
m_panelHeight = rcPanel.bottom - rcPanel.top;
AdjustWindow(rcPanel.right - rcPanel.left, rcPanel.bottom - rcPanel.top);
MoveWindow(m_window);
}
}
void CLoginDialog::UpdateBegin()
{
int count = m_panels.size();
for(int i = 0; i < count ; i++)
{
CPanelDialog * panelDlg = m_panels[i];
if(!panelDlg) continue;
panelDlg->UpdateBegin();
}
}
void CLoginDialog::UpdateEnd(int CCU)
{
int count = m_panels.size();
for(int i = 0; i < count ; i++)
{
CPanelDialog * panelDlg = m_panels[i];
if(!panelDlg) continue;
panelDlg->UpdateEnd();
}
UpdateTitle(CCU);
}
void CLoginDialog::UpdatePanel(int index, int currentUser, int sendCount, int serverState)
{
CPanelDialog* panelDlg = FindPanel(index);
if(panelDlg)
{
panelDlg->Update(currentUser, sendCount, serverState);
}
}
void CLoginDialog::UpdateTitle(int maxUser)
{
if(maxUser != m_CCU)
{
m_CCU = maxUser;
CString title;
title.Format(_T("%s(CCU : %d)"), m_title, m_CCU);
SetWindowText(title);
}
}
CPanelDialog* CLoginDialog::FindPanel(const int serverId)
{
int count = m_panels.size();
for(int i = 0; i < count ; i++)
{
CPanelDialog * panelDlg = m_panels[i];
if(!panelDlg) continue;
if(panelDlg->GetServerID() == serverId)
return panelDlg;
}
return NULL;
}
void CLoginDialog::AdjustWindow(int width, int height)
{
int col = m_maxPanel % m_matrix;
int row = (m_maxPanel / m_matrix) + (col ? 1 : 0);
m_window.right = m_window.left + (width * m_matrix) + 30;
m_window.bottom = m_window.top + (height * row) + 30;
}
void CLoginDialog::GeneratePos(const int matrix, const int index, RECT& rcPanel)
{
int width = rcPanel.right - rcPanel.left;
int height = rcPanel.bottom - rcPanel.top;
int row = index / (matrix);
int col = index % (matrix);
rcPanel.left = (col) * width;
rcPanel.right = rcPanel.left + width;
rcPanel.top = (row) * height;
rcPanel.bottom = rcPanel.top + height;
}
void CLoginDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
int delta;
int maxPos = m_window.Height() - m_curHeight;
switch (nSBCode)
{
case SB_LINEDOWN:
if (m_scrollPos >= maxPos)
return;
delta = min(max(maxPos/20,5),maxPos-m_scrollPos);
break;
case SB_LINEUP:
if (m_scrollPos <= 0)
return;
delta = -min(max(maxPos/20,5),m_scrollPos);
break;
case SB_PAGEDOWN:
if (m_scrollPos >= maxPos)
return;
delta = min(max(maxPos/20,5),maxPos-m_scrollPos);
break;
case SB_THUMBPOSITION:
delta = (int)nPos - m_scrollPos;
break;
case SB_THUMBTRACK:
case SB_PAGEUP:
if (m_scrollPos <= 0)
return;
delta = -min(max(maxPos/20,5),m_scrollPos);
break;
default:
return;
}
m_scrollPos += delta;
SetScrollPos(SB_VERT,m_scrollPos,TRUE);
ScrollWindow(0,-delta);
CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
}
void CLoginDialog::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
m_curHeight = cy;
SCROLLINFO si;
si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
si.nMin = 0;
si.nMax = m_window.Height();
si.nPage = cy;
si.nPos = 0;
SetScrollInfo(SB_VERT, &si, TRUE);
}
BOOL CLoginDialog::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
int maxPos = m_window.Height() - m_curHeight;
if (zDelta<0)
{
if (m_scrollPos < maxPos)
{
zDelta = min(max(maxPos/10,5),maxPos-m_scrollPos);
m_scrollPos += zDelta;
SetScrollPos(SB_VERT,m_scrollPos,TRUE);
ScrollWindow(0,-zDelta);
}
}
else
{
if (m_scrollPos > 0)
{
zDelta = -min(max(maxPos/10,5),m_scrollPos);
m_scrollPos += zDelta;
SetScrollPos(SB_VERT,m_scrollPos,TRUE);
ScrollWindow(0,-zDelta);
}
}
return CDialogEx::OnMouseWheel(nFlags, zDelta, pt);
}
void CLoginDialog::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialogEx::OnShowWindow(bShow, nStatus);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
for(int i = 0; i < (int)m_panels.size() ; i++)
{
CPanelDialog* dlg = m_panels[i];
dlg->ShowWindow(bShow);
}
CRect tmp;
GetClientRect(&tmp);
OnSizing(2, tmp);
ShowScrollBar(SB_VERT, TRUE);
if(bShow)
{
SetTimer(PANEL_REFRESH, 2900, NULL);
}
else
{
KillTimer(PANEL_REFRESH);
}
}
void CLoginDialog::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
CDialogEx::OnTimer(nIDEvent);
}
void CLoginDialog::OnClose()
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
KillTimer(PANEL_REFRESH);
CDialogEx::OnClose();
}
BOOL CLoginDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
return CDialogEx::OnCommand(wParam, lParam);
}
void CLoginDialog::OnSizing(UINT fwSide, LPRECT pRect)
{
CDialogEx::OnSizing(fwSide, pRect);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
pRect->right = pRect->left + m_window.Width();
int height = pRect->bottom - pRect->top;
if(height < (m_panelHeight+32))
{
pRect->bottom = pRect->top + m_panelHeight + 32;
}
}
BOOL CLoginDialog::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
@@ -0,0 +1,72 @@
#pragma once
#include <vector>
class CPanelDialog;
class CZoneDialog;
// CLoginDialog 대화 상자입니다.
class CLoginDialog : public CDialogEx
{
DECLARE_DYNAMIC(CLoginDialog)
public:
CLoginDialog(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CLoginDialog();
// 대화 상자 데이터입니다.
enum { IDD = IDD_LOGIN_DIALOG };
public:
void Startup(CString title, const int maxUser, const int maxServer, const int matrix, CZoneDialog* parent);
void AddPanel(int serverId, CString name, CString IP, int port, int blockState);
void UpdateBegin();
void UpdateEnd(int CCU);
void UpdatePanel(int index, int currentUser, int sendCount, int serverState);
void UpdateTitle(int CCU);
void SetServerIP(CString strServerIP) { m_strServerIP = strServerIP; }
CString GetServerIP() { return m_strServerIP; }
protected:
CPanelDialog* FindPanel(const int serverId);
void AdjustWindow(int width, int height);
void GeneratePos(const int matrix, const int index, RECT& rcPanel);
protected:
int m_maxUser;
int m_CCU;
int m_maxPanel;
int m_matrix;
int m_curHeight;
int m_scrollPos;
int m_panelWidth, m_panelHeight;
CRect m_window;
CString m_strServerIP;
typedef std::vector<CPanelDialog*> PANELS;
PANELS m_panels;
CString m_title;
CZoneDialog* m_parent;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnSize(UINT nType, int cx, int cy);
virtual BOOL OnInitDialog();
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnClose();
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
@@ -0,0 +1,433 @@
// MonitorListCtrl.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "WinMessage.h"
#include "ZoneDialog.h"
#include "MonitorListCtrl.h"
IMPLEMENT_DYNAMIC(CMonitorListCtrl, CListCtrl)
CMonitorListCtrl::CMonitorListCtrl()
: m_bCountryCount(false)
{
InitToolTip();
}
CMonitorListCtrl::~CMonitorListCtrl()
{
}
BEGIN_MESSAGE_MAP(CMonitorListCtrl, CListCtrl)
ON_NOTIFY_REFLECT(NM_CLICK, &CMonitorListCtrl::OnNMLClick)
ON_NOTIFY_REFLECT(NM_RCLICK, &CMonitorListCtrl::OnNMRClick)
ON_NOTIFY_REFLECT(NM_DBLCLK, &CMonitorListCtrl::OnNMDblclk)
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDrawList)
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
// CMonitorListCtrl 메시지 처리기입니다.
void CMonitorListCtrl::Startup(CZoneDialog* parent, const int index)
{
m_parent = parent;
m_ctrlIndex = index;
}
void CMonitorListCtrl::CreatePopup(const ServerTypes serverType)
{
InitToolTip();
switch(serverType)
{
case SERVER_TYPE_MAIN:
{
m_menu.DestroyMenu();
m_menu.CreatePopupMenu();
// 팝업메뉴
CString menu;
if(GetZone()->IsAdministrator())
{
menu = _T("Shutdown immediately");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAINSAFECLOSE, (LPCTSTR)menu);
m_menu.AppendMenu(MF_SEPARATOR);
menu = _T("Shutdown all immediately");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_GAMEQUICKCLOSEALL, (LPCTSTR)menu);
menu = _T("Shutdown all safely");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_GAMESAFECLOSEALL, (LPCTSTR)menu);
m_menu.AppendMenu(MF_SEPARATOR);
menu = _T("Reload gameserver INI");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAINRELOADINI, (LPCTSTR)menu);
menu = _T("Reload gameserver OPTION");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAINRELOADOPTION, (LPCTSTR)menu);
menu = _T("Reload closing INI");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_RELOAD_CLOSEINI, (LPCTSTR)menu);
menu = _T("Reset the quantity of event shop");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAINRESETEVENTSHOP, (LPCTSTR)menu);
menu = _T("Reset the quantity of clover shop");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAINRESETCLOVERSHOP, (LPCTSTR)menu);
menu = _T("Reset the quantity of milege shop");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAINRESETMILEGESHOP, (LPCTSTR)menu);
menu = _T("Reset all record of the purchase");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAINRESETBUYLOG, (LPCTSTR)menu);
menu = _T("Reset old record of the mission");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAIN_RESET_MISSION, (LPCTSTR)menu);
m_menu.AppendMenu(MF_SEPARATOR);
menu = _T("White-list on");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAIN_WHITELISTON, (LPCTSTR)menu);
menu = _T("White-list off");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_MAIN_WHITELISTOFF, (LPCTSTR)menu);
m_menu.AppendMenu(MF_SEPARATOR);
//menu = _T("Tool CS-file");
//m_menu.AppendMenu(MF_STRING, IDC_SERVICE_CSDIALOG, (LPCTSTR)menu);
menu = _T("Operating tool");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_SHOWTOOL, (LPCTSTR)menu);
}
else if(GetZone()->IsOperator())
{
menu = _T("Operating tool");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_SHOWTOOL, (LPCTSTR)menu);
}
else
{
menu = _T("Authenticate");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_AUTHENTICATION, (LPCTSTR)menu);
}
}
break;
case SERVER_TYPE_LOGIN:
{
m_menu.DestroyMenu();
m_menu.CreatePopupMenu();
if(GetZone()->IsAdministrator())
{
// 팝업메뉴
CString menu;
menu = _T("Show panel");
m_menu.AppendMenu(MF_SEPARATOR);
menu = _T("White-list on");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_LOGIN_WHITELISTON, (LPCTSTR)menu);
menu = _T("White-list off");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_LOGIN_WHITELISTOFF, (LPCTSTR)menu);
}
}
break;
case SERVER_TYPE_GAME:
{
m_menu.DestroyMenu();
m_menu.CreatePopupMenu();
if(GetZone()->IsAdministrator())
{
// 팝업메뉴
CString menu;
menu = _T("Shutdown immediately");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_GAMEQUICKCLOSE, (LPCTSTR)menu);
menu = _T("Shutdown safely");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_GAMESAFECLOSE, (LPCTSTR)menu);
UINT flag = GetZone()->GetRelayFlag(GetSelectedIndex()) ? MFS_CHECKED : MFS_UNCHECKED;
menu = _T("Relayserver on/off");
m_menu.AppendMenu(flag,IDC_SERVICE_RELAYSERVERCONTROL,(LPCTSTR)menu);
}
}
break;
case SERVER_TYPE_BILLING:
{
m_menu.DestroyMenu();
m_menu.CreatePopupMenu();
// 팝업메뉴
CString menu;
menu = _T("Reload billingsvr INI");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_BILLINGRELOADINI, (LPCTSTR)menu);
/*
m_menu.AppendMenu(MF_SEPARATOR);
menu = _T("Nexon PCRoom User Logout");
m_menu.AppendMenu(MF_STRING, IDC_SERVICE_BILLINGNEXONLOGOUT, (LPCTSTR)menu);
*/
}
break;
}
}
void CMonitorListCtrl::InitToolTip()
{
if (m_toolTip.m_hWnd == NULL)
{
m_toolTip.Create(this);
m_toolTip.Activate(FALSE);
m_toolTip.SetDelayTime(TTDT_AUTOPOP, 3000);
}
}
void CMonitorListCtrl::SetToolTip(CString text)
{
m_toolTip.DelTool(this, 0);
m_toolTip.AddTool(this, text, NULL, 0);
}
int CMonitorListCtrl::GetSelectedIndex()
{
int index = -1;
for(int i = 0; i < GetItemCount(); i++)
{
if(LVIS_SELECTED == GetItemState(i, LVIS_SELECTED))
{
index = i;
break;
}
}
return index;
}
void CMonitorListCtrl::OnNMLClick(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CPoint pos;
GetCursorPos(&pos);
int index = GetSelectedIndex();
if(index != -1)
{
LVITEM item = {0};
item.iItem = index;
item.mask = LVIF_PARAM;
this->GetItem( &item);
ServerTypes serverType = (ServerTypes)item.lParam;
CZoneDialog* dlg = (CZoneDialog*)GetParent();
if(dlg)
{
if(!dlg->m_billingFlag)
{
CString servernName, serverIP;
int serverPort;
//dlg->GetAddress((ServerTypes)item.lParam, item.iItem, servernName, serverIP, serverPort);
CString toolTip;
// if(m_bCountryCount)
// {
// int strENG, strGER, strFRA, strITA, strPOL, strTUR, strETC;
// dlg->GetCCUINFO((ServerTypes)item.iItem, servernName, serverIP, serverPort, strENG, strGER, strFRA, strITA, strPOL, strTUR, strETC);
// if(servernName.Find("_") != -1)
// return;
// toolTip.Format(_T("%s(%s:%d) | ENG( %d), GER( %d), FRA( %d), ITA( %d), POL( %d), TUR( %d), ETC( %d)"), servernName, serverIP, serverPort,
// strENG, strGER, strFRA, strITA, strPOL, strTUR, strETC);
// }
// else
{
dlg->GetAddress((ServerTypes)item.lParam, item.iItem, servernName, serverIP, serverPort);
toolTip.Format(_T("%s(%s:%d)"), servernName, serverIP, serverPort);
}
SetToolTip(toolTip);
m_toolTip.Activate(TRUE);
}
}
}
*pResult = 0;
}
void CMonitorListCtrl::OnNMRClick(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CPoint pos;
GetCursorPos(&pos);
int index = GetSelectedIndex();
if(index != -1)
{
//모니터링 끄기 기능은 현재 사용안함
if( m_parent->m_billingFlag == TRUE )
{
LVITEM item = {0};
item.iItem = index;
item.mask = LVIF_PARAM;
this->GetItem( &item);
ServerTypes serverType = SERVER_TYPE_BILLING;
BILLINGSERVERINFO* serverInfo = NULL;
serverInfo = m_parent->GetBillingServerInfo( item.lParam ); //m_billingServerTable의 키값으로 서버 정보 찾음
if( serverInfo != NULL && (serverInfo->billingServerState == SERVERSTATE_ON ) )
{
// 마우스 위치에 팝업메뉴를 출력한다.
CreatePopup(serverType);
m_menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pos.x, pos.y, this);
}
}
else
{
LVITEM item = {0};
item.iItem = index;
item.mask = LVIF_PARAM;
this->GetItem( &item);
ServerTypes serverType = (ServerTypes)item.lParam;
// 마우스 위치에 팝업메뉴를 출력한다.
CreatePopup(serverType);
m_menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pos.x, pos.y, this);
}
}
*pResult = 0;
}
BOOL CMonitorListCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
{
int index = GetSelectedIndex();
if(index != -1)
{
GetParent()->PostMessage(WM_COMMAND, wParam, index);
return TRUE;
}
return CListCtrl::OnCommand(wParam, lParam);
}
void CMonitorListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
if(GetZone()->IsAdministrator())
{
int index = GetSelectedIndex();
if(index != -1)
{
LVITEM item = {0};
item.iItem = index;
item.mask = LVIF_PARAM;
this->GetItem( &item);
switch(item.lParam)
{
case SERVER_TYPE_MAIN:
SendMessage(WM_COMMAND, IDC_SERVICE_MAININFO, NULL);
break;
case SERVER_TYPE_GAME:
SendMessage(WM_COMMAND, IDC_SERVICE_GAMEINFO, index);
break;
}
}
}
else
{
int index = GetSelectedIndex();
if(index != -1)
{
LVITEM item = {0};
item.iItem = index;
item.mask = LVIF_PARAM;
this->GetItem( &item);
if( m_parent->m_billingFlag == TRUE )
{
m_parent->RequestBillingServerLOG(item.lParam); //(ServerTypes)변환필요없음
}
}
}
*pResult = 0;
}
BOOL CMonitorListCtrl::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
m_toolTip.RelayEvent(pMsg);
return CListCtrl::PreTranslateMessage(pMsg);
}
void CMonitorListCtrl::OnCustomDrawList( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
int iItemNum = static_cast<int>(pLVCD->iSubItem);
//CString strName = GetItemText(iItemNum, pLVCD->iSubItem);
//CString strName = GetItemText(pLVCD->iSubItem,0); //0번째 텍스트 가져오자!
CString strName = GetItemText(pLVCD->nmcd.dwItemSpec,0); //0번째 텍스트 가져오자!
if( !strName.IsEmpty() && strName.Find("#") != -1 )
{
CFont font;
CRect rc;
CClientDC dc(this);
font.CreateFontA(10,0,0,0,0,FALSE,FALSE,FALSE, DEFAULT_CHARSET,0,0,0,DEFAULT_QUALITY,_T("굴림체"));
dc.SelectObject(font);
GetItemRect(pLVCD->nmcd.dwItemSpec ,&rc ,LVIR_BOUNDS);
rc.left += 7; //위치 조정
CString strNum;
strNum.Format("%d", pLVCD->nmcd.dwItemSpec + 1);
dc.SetBkMode( TRANSPARENT );
DrawText( dc, strNum, 2, rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE );
font.DeleteObject();
}
COLORREF crText = NULL;
if(strName.Find(CCU_ENG) != -1) crText = CCU_RGB_ENG;
else if(strName.Find(CCU_GER) != -1) crText = CCU_RGB_GER;
else if(strName.Find(CCU_FRA) != -1) crText = CCU_RGB_FRA;
else if(strName.Find(CCU_ITA) != -1) crText = CCU_RGB_ITA;
else if(strName.Find(CCU_POL) != -1) crText = CCU_RGB_POL;
else if(strName.Find(CCU_TUR) != -1) crText = CCU_RGB_TUR;
else if(strName.Find(CCU_ETC) != -1) crText = CCU_RGB_ETC;
else crText = RGB(0,0,0);
pLVCD->clrText = crText;
*pResult = CDRF_NOTIFYITEMDRAW;
//*pResult = CDRF_DODEFAULT;
}
@@ -0,0 +1,54 @@
#pragma once
#include "ServerTypes.h"
class CZoneDialog;
// CMonitorListCtrl
class CMonitorListCtrl : public CListCtrl
{
DECLARE_DYNAMIC(CMonitorListCtrl)
public:
CMonitorListCtrl();
virtual ~CMonitorListCtrl();
public:
void Startup(CZoneDialog* parent, const int index);
int GetControlID() { return m_ctrlIndex; }
int GetSelectedIndex();
protected:
void CreatePopup(const ServerTypes serverType);
void InitToolTip();
void SetToolTip(CString text);
CZoneDialog* GetZone() { return m_parent; }
protected:
CMenu m_menu;
CToolTipCtrl m_toolTip;
int m_ctrlIndex;
CZoneDialog* m_parent;
protected:
DECLARE_MESSAGE_MAP()
protected:
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
public:
afx_msg void OnNMLClick(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnNMRClick(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnCustomDrawList(NMHDR* pNMHDR, LRESULT* pResult);
virtual BOOL PreTranslateMessage(MSG* pMsg);
bool m_bCountryCount;
};
@@ -0,0 +1,153 @@
// MonitorTabCtrl.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "LS_MonitorClientDlg.h"
#include "ZoneDialog.h"
#include "MonitorTabCtrl.h"
// CMonitorTabCtrl
IMPLEMENT_DYNAMIC(CMonitorTabCtrl, CTabCtrl)
CMonitorTabCtrl::CMonitorTabCtrl()
{
}
BEGIN_MESSAGE_MAP(CMonitorTabCtrl, CTabCtrl)
ON_WM_LBUTTONUP()
ON_WM_SIZE()
ON_WM_DESTROY()
END_MESSAGE_MAP()
int CMonitorTabCtrl::SetDialogIndex(CZoneDialog* arg)
{
UINT index = GetItemCount();
index -= 1;
m_dialogs[index] = arg;
return index;
}
void CMonitorTabCtrl::AddTab(CString& title, CString& main, CString& login, BOOL billingFlag, BILLINGSERVERTABLE& tempBillingServerMap, bool bCountryCode)
{
this->InsertItem(GetItemCount(), title);
// 다이얼로그 처리
if(GetItemCount() == 1) // 최초 한번만 실행
{
CRect tabRect, itemRect;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
m_x = itemRect.left;
m_y = itemRect.bottom+1;
m_width = tabRect.right - itemRect.left - 1;
m_height = tabRect.bottom - m_y - 1;
}
CZoneDialog* dlg = new CZoneDialog(this);
dlg->Create(IDD_ZONEINFO_DIALOG, this);
dlg->SetWindowPos(&wndTop, m_x, m_y, m_width, m_height, SWP_HIDEWINDOW);
dlg->m_bCountryCode = bCountryCode;
if( billingFlag == FALSE)
dlg->CreateMonitor(title, main, login);
else
dlg->CreateBillingMonitor(title, billingFlag, tempBillingServerMap);
int index = -1;
index = SetDialogIndex(dlg);
// 포커스 초기화 0으로..
SetCurSel(index);
SetFocus(index);
}
void CMonitorTabCtrl::ShowTab(const UINT index, const BOOL show)
{
CZoneDialog* dlg = GetDialog(index);
if(!dlg) return;
if(show)
{
dlg->Show();
SetCurSel(index);
m_tabIndex = index;
}
else
{
dlg->Hide();
}
}
CZoneDialog* CMonitorTabCtrl::GetDialog(const UINT index)
{
SERVER_DIALOGS::iterator it = m_dialogs.find(index);
if(it != m_dialogs.end())
{
return it->second;
}
return NULL;
}
void CMonitorTabCtrl::SetFocus(const UINT index)
{
if(GetTabIndex() != index)
{
ShowTab(GetTabIndex(), FALSE);
ShowTab(GetCurFocus(), TRUE);
}
else
{
ShowTab(GetTabIndex(), TRUE);
}
}
void CMonitorTabCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
SetFocus(GetCurFocus());
CTabCtrl::OnLButtonUp(nFlags, point);
}
void CMonitorTabCtrl::OnSize(UINT nType, int cx, int cy)
{
CTabCtrl::OnSize(nType, cx, cy);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
CRect client;
GetClientRect(client);
for(SERVER_DIALOGS::iterator it = m_dialogs.begin(); it != m_dialogs.end() ; ++it)
{
CZoneDialog* dlg = it->second;
if(!dlg) continue;
CRect rc;
dlg->GetClientRect(rc);
if(dlg->IsShow())
{
dlg->SetWindowPos(NULL, rc.left+2, rc.top+26, m_width, cy - 30, SWP_SHOWWINDOW);
}
else
{
dlg->SetWindowPos(NULL, rc.left+2, rc.top+26, m_width, cy - 30, SWP_HIDEWINDOW);
}
}
}
void CMonitorTabCtrl::OnDestroy()
{
for(int i = 0; i < (int)m_dialogs.size(); i++)
SAFEDELETE(m_dialogs[i]);
}
@@ -0,0 +1,42 @@
#pragma once
#include "Define.h"
#include <map>
// CMonitorTabCtrl
class CZoneDialog;
class CMonitorTabCtrl : public CTabCtrl
{
DECLARE_DYNAMIC(CMonitorTabCtrl)
public:
CMonitorTabCtrl();
public:
int SetDialogIndex(CZoneDialog* arg);
void AddTab(CString& title, CString& main, CString& login, BOOL bBilling, BILLINGSERVERTABLE& tempBillingServerMap, bool bCountryCode);
void ShowTab(const UINT index, const BOOL show = TRUE);
const UINT GetTabIndex() { return m_tabIndex; }
protected:
typedef std::map<UINT, CZoneDialog*> SERVER_DIALOGS;
SERVER_DIALOGS m_dialogs;
CZoneDialog* GetDialog(const UINT index);
void SetFocus(const UINT index);
protected:
int m_x, m_y, m_width, m_height;
UINT m_tabIndex;
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnSize(UINT nType, int cx, int cy);
virtual void OnDestroy();
};
@@ -0,0 +1,44 @@
#include "../stdafx.h"
#include "FSM.h"
FSM::FSM()
{
InitState();
}
void FSM::InitState()
{
m_iState = MAGIC_TOKEN_FSM;
}
bool FSM::IsFirst()
{
if( MAGIC_TOKEN_FSM == m_iState )
return true;
return false;
}
int FSM::GetState()
{
return m_iState;
}
void FSM::SetState(int iState)
{
m_iState = iState;
}
void FSM::UpdateState()
{
if( !IsFirst() )
{
m_iState = ( (~m_iState) + 5371 ) * 31;
m_iState = m_iState ^ ( m_iState >> 16);
if( m_iState < 0 )
m_iState = -m_iState;
}
}
@@ -0,0 +1,23 @@
#pragma once
#define MAGIC_TOKEN_FSM -1
class FSM
{
public:
FSM();
public:
void InitState();
void UpdateState();
public:
bool IsFirst();
int GetState();
void SetState(int iState);
protected:
int m_iState;
};
@@ -0,0 +1,63 @@
#include "../stdafx.h"
#include "FSM.h"
#include "Packet.h"
#include "NetworkSecurity.h"
NetworkSecurity::NetworkSecurity()
{
}
NetworkSecurity::~NetworkSecurity()
{
}
// DoS Attack
bool NetworkSecurity::UpdateReceiveCount()
{
return true;
}
// Packet CheckSum
bool NetworkSecurity::IsCheckSum( CPacket &rkPacket )
{
return true;
}
// Packet Replay
int NetworkSecurity::GetSndState()
{
return MAGIC_TOKEN_FSM;
}
void NetworkSecurity::UpdateSndState()
{
}
int NetworkSecurity::GetRcvState()
{
return MAGIC_TOKEN_FSM;
}
void NetworkSecurity::UpdateRcvState()
{
}
bool NetworkSecurity::CheckState( CPacket &rkPacket )
{
return true;
}
void NetworkSecurity::PrepareMsg( CPacket &rkPacket )
{
}
void NetworkSecurity::CompletionMsg( CPacket &rkPacket )
{
}
@@ -0,0 +1,33 @@
#ifndef _NetworkSecurity_h_
#define _NetworkSecurity_h_
class TOWN_PORTAL_API NetworkSecurity
{
// DoS Attack
public:
virtual bool UpdateReceiveCount();
// Packet CheckSum
public:
virtual bool IsCheckSum( CPacket &rkPacket );
// Packet Replay
public:
virtual int GetSndState();
virtual void UpdateSndState();
virtual int GetRcvState();
virtual void UpdateRcvState();
virtual bool CheckState( CPacket &rkPacket );
// Send
public:
virtual void PrepareMsg( CPacket &rkPacket );
virtual void CompletionMsg( CPacket &rkPacket );
public:
NetworkSecurity();
virtual ~NetworkSecurity();
};
#endif
@@ -0,0 +1,142 @@
// Packet.cpp: implementation of the CPacket class.
//
//////////////////////////////////////////////////////////////////////
#include "../stdafx.h"
#include "Packet.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CPacket::CPacket()
{
Clear();
}
CPacket::CPacket(DWORD ID)
{
Clear();
*m_packet_header.m_ID = ID;
m_currentPos = sizeof(PACKETHEADER);
}
CPacket::CPacket(char *buffer,int size)
{
Clear();
if( size >= sizeof(PACKETHEADER) )
{
memcpy( &m_pBuffer[0] , buffer, sizeof(PACKETHEADER) );
m_currentPos = sizeof(PACKETHEADER);
if( size >= GetBufferSize() )
memcpy( &m_pBuffer[m_currentPos], &buffer[m_currentPos], GetBufferSize() - m_currentPos );
}
}
CPacket::~CPacket()
{
}
void CPacket::Clear()
{
memset(m_pBuffer,0,MAX_PACKET_BUFFER);
m_currentPos = 0;
m_packet_header.m_ID = (DWORD*)&m_pBuffer[PK_ID_ADDR];
m_packet_header.m_Size = (DWORD*)&m_pBuffer[PK_SIZE_ADDR];
m_packet_header.m_CheckSum = (DWORD*)&m_pBuffer[PK_CKSUM_ADDR];
m_packet_header.m_iState = (int*)&m_pBuffer[PK_FSM_ADDR];
*m_packet_header.m_Size = sizeof(PACKETHEADER);
}
void CPacket::SetBufferCopy(char *pBuf,int size)
{
Clear();
memcpy( m_pBuffer, pBuf, size );
m_currentPos = sizeof(PACKETHEADER);
}
void CPacket::SetDataAdd(char *pBuf,int size)
{
memcpy( &m_pBuffer[m_currentPos], pBuf, size );
m_currentPos += size;
*m_packet_header.m_Size = m_currentPos;
}
void CPacket::SetCheckSum( DWORD dwSum )
{
*m_packet_header.m_CheckSum = dwSum;
}
void CPacket::SetState( int iState )
{
*m_packet_header.m_iState = iState;
}
const char* CPacket::GetBuffer() const
{
return &m_pBuffer[0];
}
const char* CPacket::GetData() const
{
return &m_pBuffer[0] + sizeof(PACKETHEADER);
}
int CPacket::GetBufferSize() const
{
return *m_packet_header.m_Size;
}
int CPacket::GetDataSize() const
{
return *m_packet_header.m_Size - sizeof(PACKETHEADER);
}
DWORD CPacket::GetPacketID() const
{
return *m_packet_header.m_ID;
}
DWORD CPacket::GetCheckSum() const
{
return *m_packet_header.m_CheckSum;
}
int CPacket::GetState() const
{
return *m_packet_header.m_iState;
}
bool CPacket::IsValidHeader() const
{
return (GetBufferSize() >= sizeof(PACKETHEADER) );
}
bool CPacket::IsValidPacket() const
{
if(!IsValidHeader()) return false;
return (GetBufferSize() >= m_currentPos);
}
bool CPacket::CheckLeftPacketSize( int iAddSize )
{
if( m_currentPos + iAddSize >= MAX_PACKET_BUFFER )
{
return false;
}
return true;
}
bool CPacket::CheckRightPacketSize( int iAddSize )
{
if( m_currentPos + iAddSize >= MAX_PACKET_BUFFER )
{
return false;
}
return true;
}
@@ -0,0 +1,64 @@
#pragma once
enum
{
PK_ID_ADDR = 0,
PK_SIZE_ADDR = 4,
PK_CKSUM_ADDR = 8,
PK_FSM_ADDR = 12,
PK_HEADER_SIZE = 16,
};
const int MAX_PACKET_BUFFER = 1024 * 16;
class CPacket
{
public:
struct PACKETHEADER
{
DWORD *m_ID;
DWORD *m_Size;
DWORD *m_CheckSum;
int *m_iState;
PACKETHEADER()
{
m_ID = m_Size = m_CheckSum = NULL;
m_iState = NULL;
}
};
protected:
PACKETHEADER m_packet_header;
int m_currentPos;
char m_pBuffer[MAX_PACKET_BUFFER];
bool CheckLeftPacketSize( int iAddSize );
bool CheckRightPacketSize( int iAddSize );
public:
void Clear();
void SetBufferCopy(char *pBuf,int size);
void SetDataAdd(char *pBuf,int size);
void SetCheckSum( DWORD dwSum );
void SetState( int iState );
public:
const char* GetBuffer() const; //패킷 버퍼의 모든 내용(헤더 포함).
const char* GetData() const; //패킷 버퍼의 데이터 내용(헤더 미포함).
int GetBufferSize() const;
int GetDataSize() const;
DWORD GetPacketID() const;
DWORD GetCheckSum() const;
int GetState() const;
bool IsValidHeader() const;
bool IsValidPacket() const;
public:
CPacket();
CPacket( DWORD ID );
CPacket( char *buffer, int size );
virtual ~CPacket();
};
@@ -0,0 +1,177 @@
#ifndef ___PROTOCOL_H__
#define ___PROTOCOL_H__
//CLIENT SEND TCP MONITORING PACKET
#define CTPKM_UPDATE_CLIENT_VERSION 0x8003
#define CTPKM_LOAD_CS3_FILE 0x8004
#define CTPKM_CS3_FILE_VERSION 0x8006
#define CTPKM_SERVER_INFO_REQUEST 0x8007
#define CTPKM_MAINSERVER_RELOADCLOSEINFO 0x8011
#define CTPKM_MAINSERVER_GAMESERVER_OPTION 0x8013
#define CTPKM_MAINSERVER_GAMESERVER_RELOADINI 0x8014
#define CTPKM_MAINSERVER_RESETEVENTSHOP 0x8042
#define CTPKM_LICENSE_REQUEST 0X8047
#define CTPKM_WHITELIST_REQUEST 0X8048
#define CTPKM_MAINSERVER_RESET_OLDMISSIONDATA 0x8051
/* 미사용
#define CTPKM_BILLINGSERVER_FIRST_CONNECT 0x8044
#define CTPKM_BILLINGSERVER_NEXONPCROOM_LOGOUT 0x8046
#define STPKM_SERVER_INFO_COMPLETE_ACK 0x8508
#define STPKM_COUNTRY_CCU_COUNT 0x8512
*/
#define CTPKM_GAMESERVER_QUICK_EXIT 0x8036
#define CTPKM_GAMESERVER_SAFETY_EXIT 0x8037
#define CTPKM_GAMESERVER_CHANGE_RELAYSVR_STATE 0x8041
#define CTPKM_BILLINGSERVER_USER_REQUEST 0x8043
#define CTPKM_BILLINGSERVER_RELOAD_INI 0x8045
//SERVER SEND TCP MONITORING PACKET
#define STPKM_LOAD_CS3_FILE 0x8503
#define STPKM_CS3_FILE_VERSION 0x8504
#define STPKM_ADMIN_RESPONSE 0x8507
//메인
#define STPKM_ANSWER_NUM_CONNECT 0x8501
#define STPKM_SERVER_DISCONNECT 0x8502
#define STPKM_LICENSE_ALERT_CHECK 0x8513
// 빌링
#define STPKM_BILLING_USER 0x8509
#define STPKM_ANSWER_BILLING_CONNECT 0x8510
#define STPKM_BILLINGSERVER_RELOAD_INI 0x8511
//공통
#define STPKM_SERVER_INFO_ACK 0x8506
namespace TOOL_SVR
{
enum PROTOCOL
{
MCTMS_REQUEST_TODAY_CCU = 0x13001,
MSTMC_ANSWER_TODAY_CCU = 0x13003,
MCTMS_REQUEST_NUM_CONNECT = 0x13011,
MSTMC_ANSWER_NUM_CONNECT = 0x13015,
MCTMS_REQUEST_SEARCH_CCU = 0x13017,
MCTMS_ANSWER_SEARCH_CCU = 0x13019,
MSTMC_SERVER_DISCONNECT = 0x13502,
MSTMC_ALL_SERVER_INFO = 0x13505,
MSTMC_M_SERVER_DISCONNECT = 0x13510,
MCTMS_L_CONTROL_SERVER = 0x13586,
MSTMC_L_SERVER_RESPONSE = 0x13590,
MSTMC_L_SERVER_CONNECT = 0x13591,
MSTMC_L_SERVER_DISCONNECT = 0x13593,
MCTMS_C_MAINSERVER_EXIT = 0x14008, // 메인서버 종료
MCTMS_C_MAINSERVER_QUICKALLEXIT = 0x14010, // 게임서버 전체 종료
MCTMS_C_MAINSERVER_SAFETYALLEXIT = 0x14012, // 게임서버 전체 안전종료
MCTMS_C_MAINSERVER_ADMINCOMMAND = 0x14040,
MSTMC_S_ADMIN_RESPONSE = 0x14047,
MCTMS_C_GAMESERVER_PROTOCAL = 0x14050,
MCTMS_C_MAINSERVER_GAMESERVER_RELOADINI = 0x14053,
MCTMS_C_MAINSERVER_GAMESERVER_OPTION = 0x14055,
MCTMS_C_MAINSERVER_RELOADCLOSEINFO = 0x14057,
MCTMS_C_MAINSERVER_RESETEVENTSHOP = 0x14059,
MCTMS_C_MAINSERVER_RESET_OLDMISSIONDATA = 0x14062,
MCTMS_C_WHITELIST_REQUEST = 0x14066,
MCTSC_C_UPDATE_CLIENT_VERSION = 0x14070,
MCTSC_S_UPDATE_CLIENT_VERSION = 0x14072,
};
}
// CTPKM_ANNOUNCE
#define ANNOUNCE_TYPE_ALL 1
#define ANNOUNCE_TYPE_ONE 2
#define ANNOUNCE_TYPE_DISCONNECT 3
// STPKM_LOAD_CS3_FILE
#define LOAD_CS3_FILE_SUCCESS 1
#define LOAD_CS3_FILE_FAIL 2
#define LOAD_CS3_FILE_WRONG_VERSION 3
#define LOAD_CS3_FILE_NOT_FILE 4
#define LOAD_CS3_FILE_CHANGE_WRONG 5
#define LOAD_CS3_FILE_EXIST_VERSION 6
// STPKM_CS3_VERSION
#define CS3_VERSION_SUCCESS 1
#define CS3_VERSION_FAIL 2
// 게임서버 종료 타입
#define ALL_SERVER_QUICK_EXIT 0
#define ALL_SERVER_SAFETY_EXIT 1
enum AdminCommandTypes
{
ADMINCOMMAND_NONE = 0,
ADMINCOMMAND_KICK111,
ADMINCOMMAND_ANNOUNCE1111,
ADMINCOMMAND_ITEMINSERT1111,
ADMINCOMMAND_EVENTINSERT111,
ADMINCOMMAND_AUTH111,
ADMINCOMMAND_USERBLOCK111,
ADMINCOMMAND_USERUNBLOCK11,
ADMINCOMMAND_SECRETSHOP11,
ADMINCOMMAND_COMPENSATION1111,
ADMINCOMMAND_PRACTICE1111,
ADMINCOMMAND_MTOOL_AUTH,
ADMINCOMMAND_MTOOL_KICK,
ADMINCOMMAND_MTOOL_ANNOUNCE,
ADMINCOMMAND_MTOOL_ITEMINSERT,
ADMINCOMMAND_MTOOL_EVENTINSERT,
ADMINCOMMAND_MTOOL_USERBLOCK,
ADMINCOMMAND_MTOOL_USERUNBLOCK,
ADMINCOMMAND_MTOOL_SECRETSHOP,
ADMINCOMMAND_MTOOL_COMPENSATION,
ADMINCOMMAND_MTOOL_PRACTICE,
ADMINCOMMAND_END
};
enum BLOCKTYPE
{
BLOCKTYPE_NONE = 0,
BLOCKTYPE_WARNING, // 주의
BLOCKTYPE_LIMITATION, // 제한
BLOCKTYPE_BLOCK, // 차단
BLOCKTYPE_UNBLOCK, // 해제
BLOCKTYPE_END
};
// DB에 저장되는 값으로 순차적으로 증가하지 않는다.
enum BlockType
{
BKT_NONE = -1,
BKT_NORMAL = 0, // 차단안됨 (정상)
BKT_WARNNING = 10, // 경고 ( 약 )
BKT_LIMITATION = 20, // 제한 ( 중 )
BKT_BLOCK = 100, // 차단 ( 강 )
};
enum AdminLevels
{
ADMIN_LEVEL_NONE = 0,
ADMIN_LEVEL_OPERATOR,
ADMIN_LEVEL_ADMINISTRATOR,
ADMIN_LEVEL_DEVELOPER,
ADMIN_LEVEL_END
};
#endif
@@ -0,0 +1,31 @@
#ifndef _RecvBuffer_h_
#define _RecvBuffer_h_
#include "ioPortalHelp.h"
class RecvBuffer
{
private:
char m_pBuf[MAX_BUFFER];
int m_iCurRcvSize;
char m_pRewindBuf[MAX_BUFFER];
public:
void InitBuffer();
void UpdateRecvSize( int iCurRcvSize );
void RewindBuffer( int iRewindSize );
public:
char* GetStartPtr();
char* GetFreeSpacePtr();
int GetCurRcvSize() const;
int GetFreeSpaceSize() const;
public:
RecvBuffer();
~RecvBuffer();
};
#endif
@@ -0,0 +1,399 @@
#include "../stdafx.h"
#include "SP2Packet.h"
SP2Packet::SP2Packet()
{
}
SP2Packet::SP2Packet(DWORD ID) : CPacket( ID )
{
}
SP2Packet::SP2Packet(char *buffer,int size) : CPacket( buffer, size )
{
}
SP2Packet::~SP2Packet()
{
}
const char* SP2Packet::GetData() const
{
return &m_pBuffer[0] + sizeof(PACKETHEADER);
}
int SP2Packet::GetDataSize() const
{
return *m_packet_header.m_Size - sizeof(PACKETHEADER);
}
void SP2Packet::SetDataAdd( char *buffer, int size )
{
m_currentPos = sizeof(PACKETHEADER);
memcpy( &m_pBuffer[m_currentPos], buffer, size );
m_currentPos += size;
*m_packet_header.m_Size = m_currentPos;
}
void SP2Packet::SetPosBegin()
{
m_currentPos = sizeof(PACKETHEADER);
}
//operator
SP2Packet& SP2Packet::operator = (SP2Packet &packet)
{
Clear();
memcpy(&m_pBuffer[0],packet.GetBuffer(),packet.GetBufferSize());
m_currentPos = sizeof(PACKETHEADER);
return *this;
}
SP2Packet& SP2Packet::operator << (BYTE arg)
{
if( !CheckLeftPacketSize( sizeof(BYTE) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(BYTE));
m_currentPos += sizeof(BYTE);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (bool arg)
{
if( !CheckLeftPacketSize( sizeof(bool) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(bool));
m_currentPos += sizeof(bool);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (int arg)
{
if( !CheckLeftPacketSize( sizeof(int) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(int));
m_currentPos += sizeof(int);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (LONG arg)
{
if( !CheckLeftPacketSize( sizeof(LONG) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(LONG));
m_currentPos += sizeof(LONG);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (WORD arg)
{
if( !CheckLeftPacketSize( sizeof(WORD) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(WORD));
m_currentPos += sizeof(WORD);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (DWORD arg)
{
if( !CheckLeftPacketSize( sizeof(DWORD) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(DWORD));
m_currentPos += sizeof(DWORD);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (__int64 arg)
{
if( !CheckLeftPacketSize( sizeof(__int64) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(__int64));
m_currentPos += sizeof(__int64);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (LPTSTR arg)
{
int nlen = lstrlen(arg) * sizeof( TCHAR ) + sizeof( TCHAR );
if( !CheckLeftPacketSize( nlen ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],arg,nlen);
m_currentPos += nlen;
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (double arg)
{
if( !CheckLeftPacketSize( sizeof(double) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(double));
m_currentPos += sizeof(double);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << (float arg)
{
if( !CheckLeftPacketSize( sizeof(float) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(float));
m_currentPos += sizeof(float);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << ( const ioHashString &arg )
{
int nlen = lstrlen( arg.c_str() ) + 1;
if( !CheckLeftPacketSize( nlen ) ) return *this;
memcpy( &m_pBuffer[m_currentPos], arg.c_str(), nlen );
m_currentPos += nlen;
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << ( const GAMESERVERINFO& arg )
{
if( ! CheckLeftPacketSize( sizeof( GAMESERVERINFO ) ) )
return *this;
memcpy( &m_pBuffer[ m_currentPos ], &arg, sizeof( GAMESERVERINFO ) );
m_currentPos += sizeof( GAMESERVERINFO );
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator << ( const MAINSERVERINFO& arg )
{
if( ! CheckLeftPacketSize( sizeof( MAINSERVERINFO ) ) )
return *this;
memcpy( &m_pBuffer[ m_currentPos ], &arg, sizeof( MAINSERVERINFO ) );
m_currentPos += sizeof( MAINSERVERINFO );
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& SP2Packet::operator >> (BYTE &arg)
{
if( !CheckRightPacketSize( sizeof(BYTE) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(BYTE));
m_currentPos += sizeof(BYTE);
return *this;
}
SP2Packet& SP2Packet::operator >> (bool &arg)
{
if( !CheckRightPacketSize( sizeof(bool) ) )
{
arg = false;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(bool));
m_currentPos += sizeof(bool);
return *this;
}
SP2Packet& SP2Packet::operator >> (int &arg)
{
if( !CheckRightPacketSize( sizeof(int) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(int));
m_currentPos += sizeof(int);
return *this;
}
SP2Packet& SP2Packet::operator >> (LONG &arg)
{
if( !CheckRightPacketSize( sizeof(LONG) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(LONG));
m_currentPos += sizeof(LONG);
return *this;
}
SP2Packet& SP2Packet::operator >> (WORD &arg)
{
if( !CheckRightPacketSize( sizeof(WORD) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(WORD));
m_currentPos += sizeof(WORD);
return *this;
}
SP2Packet& SP2Packet::operator >> (DWORD &arg)
{
if( !CheckRightPacketSize( sizeof(DWORD) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(DWORD));
m_currentPos += sizeof(DWORD);
return *this;
}
SP2Packet& SP2Packet::operator >> (__int64 &arg)
{
if( !CheckRightPacketSize( sizeof(__int64) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(__int64));
m_currentPos += sizeof(__int64);
return *this;
}
SP2Packet& SP2Packet::operator >> (LPTSTR arg)
{
int nlen = lstrlen((LPTSTR)&m_pBuffer[m_currentPos]) * sizeof( TCHAR ) + sizeof( TCHAR );
if( !CheckRightPacketSize( nlen ) )
{
arg[0] = 0;
return *this;
}
memcpy(arg,&m_pBuffer[m_currentPos],nlen);
m_currentPos += nlen;
return *this;
}
SP2Packet& SP2Packet::operator >> (double &arg)
{
if( !CheckRightPacketSize( sizeof(double) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(double));
m_currentPos += sizeof(double);
return *this;
}
SP2Packet& SP2Packet::operator >> (float &arg)
{
if( !CheckRightPacketSize( sizeof(float) ) )
{
arg = 0;
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(float));
m_currentPos += sizeof(float);
return *this;
}
SP2Packet& SP2Packet::operator >> ( ioHashString &arg )
{
int nlen = lstrlen((LPTSTR)&m_pBuffer[m_currentPos]) * sizeof( TCHAR ) + sizeof( TCHAR );
if( !CheckRightPacketSize( nlen ) )
{
arg.Clear();
return *this;
}
arg = &m_pBuffer[m_currentPos];
m_currentPos += nlen;
return *this;
}
SP2Packet& SP2Packet::operator >> ( GAMESERVERINFO& arg )
{
if( ! CheckRightPacketSize( sizeof( GAMESERVERINFO ) ) )
{
ZeroMemory(&arg, sizeof(arg));
return *this;
}
memcpy( &arg, &m_pBuffer[ m_currentPos ], sizeof( GAMESERVERINFO ) );
m_currentPos += sizeof( GAMESERVERINFO );
return *this;
}
SP2Packet& SP2Packet::operator >> ( MAINSERVERINFO& arg )
{
if( ! CheckRightPacketSize( sizeof( MAINSERVERINFO ) ) )
{
ZeroMemory(&arg, sizeof(arg));
return *this;
}
memcpy( &arg, &m_pBuffer[ m_currentPos ], sizeof( MAINSERVERINFO ) );
m_currentPos += sizeof( MAINSERVERINFO );
return *this;
}
SP2Packet& SP2Packet::operator>>( SendRelayInfo_& arg )
{
if( !CheckRightPacketSize( sizeof(SendRelayInfo_) ) )
{
ZeroMemory( &arg, sizeof( SendRelayInfo_ ) );
return *this;
}
memcpy(&arg,&m_pBuffer[m_currentPos],sizeof(SendRelayInfo_));
m_currentPos += sizeof(SendRelayInfo_);
return *this;
}
SP2Packet& SP2Packet::operator<<( SendRelayInfo_& arg )
{
if( !CheckLeftPacketSize( sizeof(SendRelayInfo_) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&arg,sizeof(SendRelayInfo_));
m_currentPos += sizeof(SendRelayInfo_);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
@@ -0,0 +1,70 @@
#pragma once
#include "Packet.h"
#include "../Define.h"
#include "../ioHashString.h"
class SP2Packet : public CPacket
{
public:
SP2Packet();
SP2Packet(DWORD ID);
SP2Packet(char *buffer,int size);
virtual ~SP2Packet();
const char* GetData() const;
int GetDataSize() const;
void SetDataAdd( char *buffer, int size );
void SetPosBegin();
//operator
SP2Packet& operator = (SP2Packet& packet);
SP2Packet& operator << (BYTE arg);
SP2Packet& operator << (bool arg);
SP2Packet& operator << (int arg);
SP2Packet& operator << (LONG arg);
SP2Packet& operator << (WORD arg);
SP2Packet& operator << (DWORD arg);
SP2Packet& operator << (__int64 arg);
SP2Packet& operator << (LPTSTR arg);
SP2Packet& operator << (double arg);
SP2Packet& operator << (float arg);
SP2Packet& operator << ( const ioHashString &arg );
SP2Packet& operator << ( const GAMESERVERINFO& arg );
SP2Packet& operator << ( const MAINSERVERINFO& arg );
SP2Packet& operator >> (BYTE &arg);
SP2Packet& operator >> (bool &arg);
SP2Packet& operator >> (int &arg);
SP2Packet& operator >> (LONG &arg);
SP2Packet& operator >> (WORD &arg);
SP2Packet& operator >> (DWORD &arg);
SP2Packet& operator >> (__int64 &arg);
SP2Packet& operator >> (LPTSTR arg);
SP2Packet& operator >> (double &arg);
SP2Packet& operator >> (float &arg);
SP2Packet& operator >> ( ioHashString &arg );
SP2Packet& operator >> ( GAMESERVERINFO& arg );
SP2Packet& operator >> ( MAINSERVERINFO& arg );
SP2Packet& operator << (LoginServerInfo &data)
{
if( !CheckLeftPacketSize( sizeof(data) ) ) return *this;
memcpy(&m_pBuffer[m_currentPos],&data,sizeof(data));
m_currentPos += sizeof(data);
*m_packet_header.m_Size = m_currentPos;
return *this;
}
SP2Packet& operator >> (LoginServerInfo &data)
{
if( !CheckRightPacketSize( sizeof(data) ) ) return *this;
memcpy(&data,&m_pBuffer[m_currentPos],sizeof(data));
m_currentPos += sizeof(data);
return *this;
}
SP2Packet& operator >> ( SendRelayInfo_& arg);
SP2Packet& operator << ( SendRelayInfo_& arg);
};
@@ -0,0 +1,38 @@
#ifndef _SendBuffer_h_
#define _SendBuffer_h_
class SendBuffer
{
private:
char m_pBuffer[MAX_BUFFER + MAX_TEMP_BUFF];
char *m_pStart;
char *m_pEnd;
int m_iRestCnt;
bool m_bBlock;
public:
void InitBuffer();
void ClearBuffer();
public:
bool EnqueueData( const char *pData, int iPacketSize ); // return : Can Now Send ?
int DequeueData( int iTransfered );
public:
int GetRestCnt();
char* GetQueuePtr() const;
public:
void SetBlock( bool bBlock );
bool IsBlocked() const;
public:
SendBuffer();
~SendBuffer();
};
#endif
@@ -0,0 +1,50 @@
#include "../stdafx.h"
#include "md5.h"
#include "cryption.h"
void Encrypt(BYTE *szSrc, int len)
{
BYTE ch;
BYTE temp;
for( int i=0 ; i<len ; i++ )
{
ch = szSrc[i];
ch ^= 0xff;
temp = (ch & 0xe0) >> 5;
ch <<= 3;
ch |= temp;
szSrc[i] = ch;
}
}
void Decrypt(BYTE *szSrc, int len)
{
BYTE ch;
BYTE temp;
for( int i=0 ; i<len ; i++ )
{
ch = szSrc[i];
temp = (ch & 0x07) << 5;
ch>>=3;
ch |= temp;
ch ^= 0xff;
szSrc[i] = ch;
}
}
DWORD MakeDigest( BYTE *szSrc, int len )
{
MD5Context md5_ctx;
DWORD dwDigest[4];
MD5Init( &md5_ctx );
MD5Update( &md5_ctx, (unsigned char const *)szSrc, len );
MD5Final( (BYTE*)&dwDigest, &md5_ctx );
DWORD dwResult;
dwResult = dwDigest[0] ^ dwDigest[1] ^ dwDigest[2] ^ dwDigest[3];
return dwResult;
}
@@ -0,0 +1,5 @@
#pragma once
void Encrypt(BYTE *szSrc, int len);
void Decrypt(BYTE *szSrc, int len);
DWORD MakeDigest( BYTE *szSrc, int len );
@@ -0,0 +1,217 @@
#include "../stdafx.h"
#include "ioSP2TCPSocket.h"
#include "SP2Packet.h"
#include "Protocol.h"
#include "../LS_MonitorDlg.h"
ioSP2TCPSocket::ioSP2TCPSocket()
{
SetNS( new ioTCPClientSecurity );
}
ioSP2TCPSocket::~ioSP2TCPSocket()
{
SAFEDELETE( m_pNS );
}
void ioSP2TCPSocket::InitState()
{
if( m_pNS )
{
ioTCPClientSecurity *pCS = static_cast<ioTCPClientSecurity *>(m_pNS);
pCS->InitState();
}
}
void ioSP2TCPSocket::ConnectProcess()
{
LOG.PrintTimeAndLog( 0, "Server Connect" );
SP2Packet kPacket(CTPKM_REQUEST_NUM_CONNECT);
SendLoop( kPacket );
if( !AfxGetMainWnd() )
{
LOG.PrintTimeAndLog(0, "ioSP2TCPSocket::ConnectProcess - AfxGetMainWnd == NULL ");
return;
}
CLSMonitorDlg *pDlg = static_cast< CLSMonitorDlg* > ( AfxGetMainWnd() );
if( !pDlg )
{
LOG.PrintTimeAndLog(0, "ioSP2TCPSocket::ConnectProcess - pDlg == NULL ");
return;
}
ioHashString szIP;
pDlg->GetMyIP( szIP );
if( szIP.IsEmpty() )
{
LOG.PrintTimeAndLog(0, "ioSP2TCPSocket::ConnectProcess - IP is Empty. ");
return;
}
SP2Packet kIPPacket( CTPKM_MONITOR_IP );
kIPPacket << szIP;
SendLoop( kIPPacket );
pDlg->OnConnect(m_WndMsg);
}
void ioSP2TCPSocket::DisconnectProcess()
{
LOG.PrintTimeAndLog( 0, "ioSP2TCPSocket::DisconnectProcess - Disconnected Server" );
if(AfxGetApp())
{
CLSMonitorDlg *pWnd = (CLSMonitorDlg*)AfxGetApp()->GetMainWnd();
if(pWnd)
pWnd->Disconnect( m_WndMsg );
}
}
bool ioSP2TCPSocket::CheckNS( CPacket &rkPacket )
{
if( m_pNS == NULL )
{
LOG.PrintTimeAndLog( 0, "ioSP2TCPSocket::CheckNS ( m_pNS == NULL )" );
return true;
}
ioTCPClientSecurity *pCS = (ioTCPClientSecurity*)m_pNS;
if( !pCS->IsCheckSum( rkPacket ) )
{
LOG.PrintTimeAndLog( 0, "ioSP2TCPSocket::CheckNS Check Sum Fail!! [%d : %d]", rkPacket.GetPacketID(), rkPacket.GetCheckSum() );
return false;
}
if( !pCS->CheckState( rkPacket ) )
{
LOG.PrintTimeAndLog( 0, "ioSP2TCPSocket::CheckNSType:%d State Not Same Client:%d, Server:%d",
rkPacket.GetPacketID(), rkPacket.GetState(), pCS->GetRcvState() );
return false;
}
return true;
}
void ioSP2TCPSocket::ProcessPacket( CPacket &rkPacket )
{
if(AfxGetApp())
{
CLSMonitorDlg *pWnd = (CLSMonitorDlg*)AfxGetApp()->GetMainWnd();
if(pWnd)
pWnd->ProcessPacket( m_WndMsg, (SP2Packet&)rkPacket );
}
}
//////////////////////////////////////////////////////////////////////////
ioTCPClientSecurity::ioTCPClientSecurity()
{
InitState();
}
ioTCPClientSecurity::~ioTCPClientSecurity()
{
}
void ioTCPClientSecurity::InitState()
{
m_SndState.InitState();
m_RcvState.InitState();
}
// Packet CheckSum
void ioTCPClientSecurity::EncryptMsg( CPacket &rkPacket )
{
// Check Sum
DWORD dwResult = MakeDigest( (BYTE*)rkPacket.GetBuffer(), rkPacket.GetBufferSize() );
rkPacket.SetCheckSum( dwResult );
// Encryption
BYTE *pSrc;
pSrc = (BYTE*)rkPacket.GetBuffer() + PK_CKSUM_ADDR;
Encrypt( pSrc, rkPacket.GetBufferSize() - PK_CKSUM_ADDR );
}
void ioTCPClientSecurity::DecryptMsg( CPacket &rkPacket )
{
// Decryption
BYTE *pSrc;
pSrc = (BYTE*)rkPacket.GetBuffer() + PK_CKSUM_ADDR;
Decrypt( pSrc, rkPacket.GetBufferSize() - PK_CKSUM_ADDR );
}
bool ioTCPClientSecurity::IsCheckSum( CPacket &rkPacket )
{
//Decrypt
DecryptMsg( rkPacket );
DWORD dwTemp = rkPacket.GetCheckSum(); //Àӽà ÀúÀå.
rkPacket.SetCheckSum( 0 );
DWORD dwResult = MakeDigest( (BYTE*)rkPacket.GetBuffer(), rkPacket.GetBufferSize() );
rkPacket.SetCheckSum( dwTemp );
// Check Sum
return ( dwResult == rkPacket.GetCheckSum() );
}
// Packet Replay
int ioTCPClientSecurity::GetSndState()
{
return m_SndState.GetState();
}
void ioTCPClientSecurity::UpdateSndState()
{
m_SndState.UpdateState();
}
int ioTCPClientSecurity::GetRcvState()
{
return m_RcvState.GetState();
}
void ioTCPClientSecurity::UpdateRcvState()
{
m_RcvState.UpdateState();
}
bool ioTCPClientSecurity::CheckState( CPacket &rkPacket )
{
if( GetRcvState() == MAGIC_TOKEN_FSM )
{
m_RcvState.SetState( rkPacket.GetState() );
m_SndState.SetState( rkPacket.GetState() );
UpdateSndState();
}
else
{
if( GetRcvState() != rkPacket.GetState() )
return false;
}
UpdateRcvState();
return true;
}
void ioTCPClientSecurity::PrepareMsg( CPacket &rkPacket )
{
rkPacket.SetState( GetSndState() );
EncryptMsg( rkPacket );
UpdateSndState();
}
void ioTCPClientSecurity::CompletionMsg( CPacket &rkPacket )
{
}
@@ -0,0 +1,177 @@
#ifndef _ioSP2TCPSocket_h_
#define _ioSP2TCPSocket_h_
#define WM_TCPSOCKET1 (WM_USER + 100)
#define WM_TCPSOCKET2 (WM_USER + 101)
#define WM_TCPSOCKET3 (WM_USER + 102)
#define WM_TCPSOCKET4 (WM_USER + 103)
#define WM_TCPSOCKET5 (WM_USER + 104)
#define WM_TCPSOCKET6 (WM_USER + 105)
#define WM_TCPSOCKET7 (WM_USER + 106)
#define WM_TCPSOCKET8 (WM_USER + 107)
#define WM_TCPSOCKET9 (WM_USER + 108)
#define WM_TCPSOCKET10 (WM_USER + 109)
#define WM_TCPSOCKET11 (WM_USER + 110)
#define WM_TCPSOCKET12 (WM_USER + 111)
#define WM_TCPSOCKET13 (WM_USER + 112)
#define WM_TCPSOCKET14 (WM_USER + 113)
#define WM_TCPSOCKET15 (WM_USER + 114)
#define WM_TCPSOCKET16 (WM_USER + 115)
#define WM_TCPSOCKET17 (WM_USER + 116)
#define WM_TCPSOCKET18 (WM_USER + 117)
#define WM_TCPSOCKET19 (WM_USER + 118)
#define WM_TCPSOCKET20 (WM_USER + 119)
#define WM_TCPSOCKET21 (WM_USER + 120)
#define WM_TCPSOCKET22 (WM_USER + 121)
#define WM_TCPSOCKET23 (WM_USER + 122)
#define WM_TCPSOCKET24 (WM_USER + 123)
#define WM_TCPSOCKET25 (WM_USER + 124)
#define WM_TCPSOCKET26 (WM_USER + 125)
#define WM_TCPSOCKET27 (WM_USER + 126)
#define WM_TCPSOCKET28 (WM_USER + 127)
#define WM_TCPSOCKET29 (WM_USER + 128)
#define WM_TCPSOCKET30 (WM_USER + 129)
#define WM_TCPSOCKET31 (WM_USER + 130)
#define WM_TCPSOCKET32 (WM_USER + 131)
#define WM_TCPSOCKET33 (WM_USER + 132)
#define WM_TCPSOCKET34 (WM_USER + 133)
#define WM_TCPSOCKET35 (WM_USER + 134)
#define WM_TCPSOCKET36 (WM_USER + 135)
#define WM_TCPSOCKET37 (WM_USER + 136)
#define WM_TCPSOCKET38 (WM_USER + 137)
#define WM_TCPSOCKET39 (WM_USER + 138)
#define WM_TCPSOCKET40 (WM_USER + 139)
#define WM_TCPSOCKET41 (WM_USER + 140)
#define WM_TCPSOCKET42 (WM_USER + 141)
#define WM_TCPSOCKET43 (WM_USER + 142)
#define WM_TCPSOCKET44 (WM_USER + 143)
#define WM_TCPSOCKET45 (WM_USER + 144)
#define WM_TCPSOCKET46 (WM_USER + 145)
#define WM_TCPSOCKET47 (WM_USER + 146)
#define WM_TCPSOCKET48 (WM_USER + 147)
#define WM_TCPSOCKET49 (WM_USER + 148)
#define WM_TCPSOCKET50 (WM_USER + 149)
#define WM_TCPSOCKET51 (WM_USER + 150)
#define WM_TCPSOCKET52 (WM_USER + 151)
#define WM_TCPSOCKET53 (WM_USER + 152)
#define WM_TCPSOCKET54 (WM_USER + 153)
#define WM_TCPSOCKET55 (WM_USER + 154)
#define WM_TCPSOCKET56 (WM_USER + 155)
#define WM_TCPSOCKET57 (WM_USER + 156)
#define WM_TCPSOCKET58 (WM_USER + 157)
#define WM_TCPSOCKET59 (WM_USER + 158)
#define WM_TCPSOCKET60 (WM_USER + 159)
#define WM_TCPSOCKET61 (WM_USER + 160)
#define WM_TCPSOCKET62 (WM_USER + 161)
#define WM_TCPSOCKET63 (WM_USER + 162)
#define WM_TCPSOCKET64 (WM_USER + 163)
#define WM_TCPSOCKET65 (WM_USER + 164)
#define WM_TCPSOCKET66 (WM_USER + 165)
#define WM_TCPSOCKET67 (WM_USER + 166)
#define WM_TCPSOCKET68 (WM_USER + 167)
#define WM_TCPSOCKET69 (WM_USER + 168)
#define WM_TCPSOCKET70 (WM_USER + 169)
#define WM_TCPSOCKET71 (WM_USER + 170)
#define WM_TCPSOCKET72 (WM_USER + 171)
#define WM_TCPSOCKET73 (WM_USER + 172)
#define WM_TCPSOCKET74 (WM_USER + 173)
#define WM_TCPSOCKET75 (WM_USER + 174)
#define WM_TCPSOCKET76 (WM_USER + 175)
#define WM_TCPSOCKET77 (WM_USER + 176)
#define WM_TCPSOCKET78 (WM_USER + 177)
#define WM_TCPSOCKET79 (WM_USER + 178)
#define WM_TCPSOCKET80 (WM_USER + 179)
#define WM_TCPSOCKET81 (WM_USER + 180)
#define WM_TCPSOCKET82 (WM_USER + 181)
#define WM_TCPSOCKET83 (WM_USER + 182)
#define WM_TCPSOCKET84 (WM_USER + 183)
#define WM_TCPSOCKET85 (WM_USER + 184)
#define WM_TCPSOCKET86 (WM_USER + 185)
#define WM_TCPSOCKET87 (WM_USER + 186)
#define WM_TCPSOCKET88 (WM_USER + 187)
#define WM_TCPSOCKET89 (WM_USER + 188)
#define WM_TCPSOCKET90 (WM_USER + 189)
#define WM_TCPSOCKET91 (WM_USER + 190)
#define WM_TCPSOCKET92 (WM_USER + 191)
#define WM_TCPSOCKET93 (WM_USER + 192)
#define WM_TCPSOCKET94 (WM_USER + 193)
#define WM_TCPSOCKET95 (WM_USER + 194)
#define WM_TCPSOCKET96 (WM_USER + 195)
#define WM_TCPSOCKET97 (WM_USER + 196)
#define WM_TCPSOCKET98 (WM_USER + 197)
#define WM_TCPSOCKET99 (WM_USER + 198)
#define WM_TCPSOCKET100 (WM_USER + 199)
enum TCPLOGIN
{
WM_TCPLOGIN1 = WM_TCPSOCKET90,
WM_TCPLOGIN2,
WM_TCPLOGIN3,
WM_TCPLOGIN4,
WM_TCPLOGIN5,
WM_TCPLOGIN6,
WM_TCPLOGIN8,
WM_TCPLOGIN9,
WM_TCPLOGIN10,
WM_TCPLOGIN11,
};
#define RIGHT_MSG_CHECK_VALUE "8302kdlso209f&3%#!%&&f"
class ioSP2TCPSocket : public ioClientTCPSocket
{
public:
virtual void ConnectProcess();
virtual void DisconnectProcess();
virtual void ProcessPacket( CPacket &rkPacket );
virtual bool CheckNS( CPacket &rkPacket );
UINT GetWndMsg() {return m_WndMsg;};
public:
void InitState();
public:
ioSP2TCPSocket();
virtual ~ioSP2TCPSocket();
};
//////////////////////////////////////////////////////////////////////////
class FSM;
class ioTCPClientSecurity : public NetworkSecurity
{
FSM m_SndState;
FSM m_RcvState;
public:
void InitState();
// Packet CheckSum
protected:
void EncryptMsg( CPacket &rkPacket );
void DecryptMsg( CPacket &rkPacket );
public:
virtual bool IsCheckSum( CPacket &rkPacket );
// Packet Replay
public:
virtual int GetSndState();
virtual void UpdateSndState();
virtual int GetRcvState();
virtual void UpdateRcvState();
virtual bool CheckState( CPacket &rkPacket );
// Send
public:
virtual void PrepareMsg( CPacket &rkPacket );
virtual void CompletionMsg( CPacket &rkPacket );
public:
ioTCPClientSecurity();
virtual ~ioTCPClientSecurity();
};
#endif
@@ -0,0 +1,254 @@
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
#include "../stdafx.h"
#include "md5.h"
#include <memory.h>
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
#else
void byteReverse(unsigned char *buf, unsigned longs);
#ifndef ASM_MD5
/*
* Note: this code is harmless on little-endian machines.
*/
void byteReverse(unsigned char *buf, unsigned longs)
{
DWORD t;
do {
t = (DWORD) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
((unsigned) buf[1] << 8 | buf[0]);
*(DWORD *) buf = t;
buf += 4;
} while (--longs);
}
#endif
#endif
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void MD5Init(MD5Context *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void MD5Update(MD5Context *ctx, unsigned char const *buf, unsigned len)
{
DWORD t;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = t + ((DWORD) len << 3)) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
if (t) {
unsigned char *p = (unsigned char *) ctx->in + t;
t = 64 - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (DWORD *) ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->in, buf, 64);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (DWORD *) ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void MD5Final(unsigned char digest[16], MD5Context *ctx)
{
unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
byteReverse(ctx->in, 16);
MD5Transform(ctx->buf, (DWORD *) ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count - 8);
}
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
((DWORD *) ctx->in)[14] = ctx->bits[0];
((DWORD *) ctx->in)[15] = ctx->bits[1];
MD5Transform(ctx->buf, (DWORD *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memcpy(digest, ctx->buf, 16);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void MD5Transform(DWORD buf[4], DWORD const in[16])
{
register DWORD a, b, c, d;
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
#endif
@@ -0,0 +1,22 @@
#ifndef _MD5_H
#define _MD5_H
typedef struct tagMD5Context
{
DWORD buf[4];
DWORD bits[2];
unsigned char in[64];
}MD5Context;
void MD5Init( MD5Context *context );
void MD5Update( MD5Context *context, unsigned char const *buf,
unsigned len );
void MD5Final( unsigned char digest[16], MD5Context *context );
void MD5Transform( DWORD buf[4], DWORD const in[16] );
/*
* This is needed to make RSAREF happy on some MS-DOS compilers.
*/
#endif /* !MD5_H */
@@ -0,0 +1,629 @@
// NoticeDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "NoticeDlg.h"
#include "afxdialogex.h"
using namespace std;
// CNoticeDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CNoticeDlg, CDialogEx)
CNoticeDlg::CNoticeDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CNoticeDlg::IDD, pParent)
, m_parent(NULL)
{
m_TimeNoticeMap.clear();
}
CNoticeDlg::~CNoticeDlg()
{
m_TimeNoticeMap.clear();
}
void CNoticeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_START_DATE, m_ListStartDate);
DDX_Control(pDX, IDC_LIST_START_INTERVAL, m_ListInterval);
DDX_Control(pDX, IDC_LIST_END_DATE, m_ListEndDate);
DDX_Control(pDX, IDC_LIST_NOTICE, m_ListNotice);
DDX_Control(pDX, IDC_EDIT_START_DATE, m_EditStartDate);
DDX_Control(pDX, IDC_EDIT_INTERVAL, m_EditInterval);
DDX_Control(pDX, IDC_EDIT_END_DATE, m_EditEndDate);
DDX_Control(pDX, IDC_EDIT_NOTICE, m_EditNotice);
}
BEGIN_MESSAGE_MAP(CNoticeDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_INPUT, &CNoticeDlg::OnBnClickedButtonInput)
ON_BN_CLICKED(IDC_BUTTON_ANNOUNCE_TIME, &CNoticeDlg::OnBnClickedButtonAnnounceTime)
ON_BN_CLICKED(IDC_BUTTON_DELETE, &CNoticeDlg::OnBnClickedButtonDelete)
ON_BN_CLICKED(IDC_BUTTON_CLEAR, &CNoticeDlg::OnBnClickedButtonClear)
ON_WM_TIMER()
END_MESSAGE_MAP()
// CNoticeDlg 메시지 처리기입니다.
void CNoticeDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
BOOL CNoticeDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
InitList();
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CNoticeDlg::InitList()
{
m_ListStartDate.DeleteAllItems();
m_ListStartDate.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_ListStartDate.InsertColumn(0, _T("StartTime"), LVCFMT_LEFT, 80);
m_ListInterval.DeleteAllItems();
m_ListInterval.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_ListInterval.InsertColumn(0, _T("Interval"), LVCFMT_LEFT, 56);
m_ListEndDate.DeleteAllItems();
m_ListEndDate.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_ListEndDate.InsertColumn(0, _T("EndTime"), LVCFMT_LEFT, 80);
m_ListNotice.DeleteAllItems();
m_ListNotice.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_ListNotice.InsertColumn(0, _T("Notice"), LVCFMT_LEFT, 300);
}
void CNoticeDlg::OnBnClickedButtonInput()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CString strStartDate;
m_EditStartDate.GetWindowText( strStartDate );
CString strInterval;
m_EditInterval.GetWindowText( strInterval );
CString strEndDate;
m_EditEndDate.GetWindowText( strEndDate );
CString strNotice;
m_EditNotice.GetWindowText( strNotice );
if( strStartDate.GetLength() == 0 ||
strInterval.GetLength() == 0 ||
strEndDate.GetLength() == 0 ||
strNotice.GetLength() == 0 )
return;
m_EditStartDate.SetWindowText( _T("") );
InsertStartDate( strStartDate );
m_EditInterval.SetWindowText( _T("") );
InsertInterval( strInterval );
m_EditEndDate.SetWindowText( _T("") );
InsertEndDate( strEndDate );
m_EditNotice.SetWindowText( _T("") );
InsertNotice( strNotice );
}
void CNoticeDlg::OnBnClickedButtonAnnounceTime()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
// 앞선 데이터 있으면 날려주고
std::map< int, IntervalData >::iterator it = m_TimeNoticeMap.begin();
for( ; it != m_TimeNoticeMap.end(); ++it )
{
KillTimer( it->first );
}
m_TimeNoticeMap.clear();
TimeCheck();
}
void CNoticeDlg::OnBnClickedButtonDelete()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
std::map< int, IntervalData >::iterator it;
UINT count = m_ListStartDate.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListStartDate );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
count = m_ListInterval.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListInterval );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
count = m_ListEndDate.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListEndDate );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
count = m_ListNotice.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListNotice );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
}
void CNoticeDlg::OnBnClickedButtonClear()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_ListStartDate.DeleteAllItems();
m_ListInterval.DeleteAllItems();
m_ListEndDate.DeleteAllItems();
m_ListNotice.DeleteAllItems();
m_EditStartDate.SetWindowText( _T("") );
m_EditInterval.SetWindowText( _T("") );
m_EditEndDate.SetWindowText( _T("") );
m_EditNotice.SetWindowText( _T("") );
std::map< int, IntervalData >::iterator it = m_TimeNoticeMap.begin();
for( ; it != m_TimeNoticeMap.end(); ++it )
{
KillTimer( it->first );
}
m_TimeNoticeMap.clear();
}
BOOL CNoticeDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if( WM_KEYDOWN == pMsg->message )
{
if( VK_RETURN == pMsg->wParam )
{
if( m_EditStartDate.GetSafeHwnd() == pMsg->hwnd )
{
CString strStartDate;
m_EditStartDate.GetWindowText( strStartDate );
m_EditStartDate.SetWindowText( _T("") );
InsertStartDate( strStartDate );
}
else if( m_EditInterval.GetSafeHwnd() == pMsg->hwnd )
{
CString strInterval;
m_EditInterval.GetWindowText( strInterval );
m_EditInterval.SetWindowText( _T("") );
InsertInterval( strInterval );
}
else if( m_EditEndDate.GetSafeHwnd() == pMsg->hwnd )
{
CString strEndDate;
m_EditEndDate.GetWindowText( strEndDate );
m_EditEndDate.SetWindowText( _T("") );
InsertEndDate( strEndDate );
}
else if( m_EditNotice.GetSafeHwnd() == pMsg->hwnd )
{
CString strNotice;
m_EditNotice.GetWindowText( strNotice );
m_EditNotice.SetWindowText( _T("") );
InsertNotice( strNotice );
}
return TRUE;
}
else if( VK_DELETE == pMsg->wParam )
{
std::map< int, IntervalData >::iterator it;
if( m_ListStartDate.GetSafeHwnd() == pMsg->hwnd )
{
UINT count = m_ListStartDate.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListStartDate );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
}
else if( m_ListInterval.GetSafeHwnd() == pMsg->hwnd )
{
UINT count = m_ListInterval.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListInterval );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
}
else if( m_ListEndDate.GetSafeHwnd() == pMsg->hwnd )
{
UINT count = m_ListEndDate.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListEndDate );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
}
else if( m_ListNotice.GetSafeHwnd() == pMsg->hwnd )
{
UINT count = m_ListNotice.GetSelectedCount();
if(count > 0)
{
DeleteListItem( m_ListNotice );
it = m_TimeNoticeMap.find( count );
if( it != m_TimeNoticeMap.end() )
KillTimer( count );
}
}
return TRUE;
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
void CNoticeDlg::InsertStartDate( CString startDate )
{
if( startDate.GetLength() == 0 )
return;
m_ListStartDate.InsertItem( m_ListStartDate.GetItemCount(), startDate );
}
void CNoticeDlg::InsertInterval( CString interval )
{
if( interval.GetLength() == 0 )
return;
m_ListInterval.InsertItem( m_ListInterval.GetItemCount(), interval );
}
void CNoticeDlg::InsertEndDate( CString endDate )
{
if( endDate.GetLength() == 0 )
return;
m_ListEndDate.InsertItem( m_ListEndDate.GetItemCount(), endDate );
}
void CNoticeDlg::InsertNotice( CString notice )
{
if( notice.GetLength() == 0 )
return;
m_ListNotice.InsertItem( m_ListNotice.GetItemCount(), notice );
}
void CNoticeDlg::DeleteListItem( CListCtrl& AllList )
{
int index = -1;
POSITION pos = AllList.GetFirstSelectedItemPosition();
while( pos )
{
int index = AllList.GetNextSelectedItem( pos );
AllList.DeleteItem( index );
pos = AllList.GetFirstSelectedItemPosition();
}
}
void CNoticeDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
std::map< int, IntervalData >::iterator it;
it = m_TimeNoticeMap.find( nIDEvent );
if( it == m_TimeNoticeMap.end() )
{
KillTimer( nIDEvent );
return;
}
CTime nowTime;
nowTime = CTime::GetCurrentTime();
CString strStartDate, strEndDate, strInterval;
char chStartDate[16] = {0,}, chEndDate[16] = {0,}, chInterval[16] = {0,};
int iStartDate = 0, iEndDate = 0, iInterval = 0;
char chNowDate[16] = {0,};
int iNowDate = 0;
sprintf_s( chNowDate, "%02d%02d%02d%02d", nowTime.GetMonth()
, nowTime.GetDay()
, nowTime.GetHour()
, nowTime.GetMinute() );
iNowDate = atoi( chNowDate );
strEndDate = m_ListEndDate.GetItemText( nIDEvent, 0 );
if( strEndDate.IsEmpty() )
{
KillTimer( nIDEvent );
return;
}
sprintf_s( chEndDate, "%s", strEndDate );
iEndDate = atoi( chEndDate );
strStartDate = m_ListStartDate.GetItemText( nIDEvent, 0 );
if( strStartDate.IsEmpty() )
{
KillTimer( nIDEvent );
return;
}
sprintf_s( chStartDate, "%s", strStartDate );
iStartDate = atoi( chStartDate );
// 공지가 시작 된 타입
if( it->second.eType == NOTICE_START_ON )
{
// 공지 호출
DoAnnounceTime( nIDEvent );
}
// 공지 시작
if( iStartDate == iNowDate )
{
if( it->second.eType == NOTICE_START_BEFORE )
{
it->second.eType = NOTICE_START_ON;
}
// 기존 시작 시점까지의 1분 interval 삭제
KillTimer( nIDEvent );
// 공지 호출
DoAnnounceTime( nIDEvent );
strInterval = m_ListInterval.GetItemText( nIDEvent, 0 );
if( strInterval.IsEmpty() )
return;
// 간격 시간 체크
sprintf_s( chInterval, "%s", strInterval );
iInterval = atoi( chInterval );
iInterval = iInterval * 60 * 1000;
SetTimer( nIDEvent, iInterval, NULL );
}
// 공지 종료
if( iEndDate == iNowDate )
{
m_TimeNoticeMap.erase( it );
// 종료
KillTimer( nIDEvent );
// 마지막 공지 호출
DoAnnounceTime( nIDEvent );
return;
}
// 현재 시각이 공지 시각 보다 뒤인 경우
if( iStartDate < iNowDate )
{
if( it->second.eType == NOTICE_START_AFTER )
{
std::list<int> IntervalTimeList;
IntervalTimeList = it->second.m_IntervalTimeList;
std::list<int>::iterator iter = IntervalTimeList.begin();
for( ; iter != IntervalTimeList.end(); ++iter )
{
// interval 시간값과 동일할 때 시작.
if( iNowDate == *iter )
{
if( it->second.eType == NOTICE_START_BEFORE )
{
it->second.eType = NOTICE_START_ON;
}
// 기존 시작 시점까지의 1분 interval 삭제
KillTimer( nIDEvent );
// 공지 호출
DoAnnounceTime( nIDEvent );
strInterval = m_ListInterval.GetItemText( nIDEvent, 0 );
if( strInterval.IsEmpty() )
return;
// 간격 시간 체크
sprintf_s( chInterval, "%s", strInterval );
iInterval = atoi( chInterval );
iInterval = iInterval * 60 * 1000;
SetTimer( nIDEvent, iInterval, NULL );
return;
}
}
}
}
CDialogEx::OnTimer(nIDEvent);
}
void CNoticeDlg::DoAnnounceTime( int iSelected )
{
CString strNotice;
strNotice = m_ListNotice.GetItemText( iSelected, 0 );
if( !strNotice.IsEmpty() )
{
m_parent->RequestAnnounce( ANNOUNCE_TYPE_ALL, "", strNotice );
}
}
void CNoticeDlg::TimeCheck()
{
CTime nowTime;
nowTime = CTime::GetCurrentTime();
char chNowDate[16] = {0,};
int iNowDate = 0;
CString strStartDate, strEndDate, strInterval;
char chStartDate[16], chEndDate[16], chInterval[16] = {0,};
int iStartDate, iEndDate, iInterval = 0;
sprintf_s( chNowDate, "%02d%02d%02d%02d", nowTime.GetMonth()
, nowTime.GetDay()
, nowTime.GetHour()
, nowTime.GetMinute() );
iNowDate = atoi( chNowDate );
// 종료시간을 보고 Timer 돌지 않을 항목 체크
int iCount = m_ListEndDate.GetItemCount();
for( int i = 0; i < iCount; ++i )
{
strEndDate = m_ListEndDate.GetItemText( i, 0 );
if( strEndDate.IsEmpty() )
continue;
sprintf_s( chEndDate, "%s", strEndDate );
iEndDate = atoi( chEndDate );
// 종료시간 지난 공지
if( iNowDate > iEndDate )
continue;
strStartDate = m_ListStartDate.GetItemText( i, 0 );
if( strStartDate.IsEmpty() )
continue;
sprintf_s( chStartDate, "%s", strStartDate );
iStartDate = atoi( chStartDate );
strInterval = m_ListInterval.GetItemText( i, 0 );
if( strInterval.IsEmpty() )
continue;
// 간격 시간 체크
sprintf_s( chInterval, "%s", strInterval );
iInterval = atoi( chInterval );
// 공지 시작
if( iStartDate == iNowDate )
{
iInterval = iInterval * 60 * 1000;
SetTimer( i, iInterval, NULL );
// 공지 호출
DoAnnounceTime( i );
IntervalData data;
data.eType = NOTICE_START_ON;
m_TimeNoticeMap.insert( pair< int, IntervalData > ( i, data ) );
}
else
{
IntervalData data;
// 시작 시각 전
// 1분마다 interval 을 주면서 해당 시각이 되었을 때 세팅된 interval 을 줌
if( iStartDate > iNowDate )
{
data.eType = NOTICE_START_BEFORE;
m_TimeNoticeMap.insert( pair< int, IntervalData > ( i, data ) );
}
// 시작 시각 후
// 1분마다 interval 을 주면서 iNowDate 가 몇 번의 interval 만큼 더 해졌을때 값이 같을지 세팅
else
{
int iIntervalTime = iStartDate;
data.eType = NOTICE_START_AFTER;
int iTemp = 0;
char chTemp[16] = {0,};
SYSTEMTIME sysTime;
GetLocalTime( &sysTime );
iTemp = iIntervalTime / 1000000;
sysTime.wMonth = iTemp;
iTemp = iIntervalTime / 10000 % 100;
sysTime.wDay = iTemp;
iTemp = iIntervalTime / 100 % 100;
sysTime.wHour = iTemp;
iTemp = iIntervalTime % 100;
sysTime.wMinute = iTemp;
CTime cTime( sysTime );
// Interval 시간 증가 된 값들 리스트로 삽입
while( iIntervalTime < iEndDate )
{
data.m_IntervalTimeList.push_back( iIntervalTime );
cTime += CTimeSpan( iInterval * 60 );
sprintf_s( chTemp, "%02d%02d%02d%02d", cTime.GetMonth()
, cTime.GetDay(), cTime.GetHour(), cTime.GetMinute() );
iIntervalTime = atoi( chTemp );
}
m_TimeNoticeMap.insert( pair< int, IntervalData > ( i, data ) );
}
// 구분자는 i. OnTimer 에서 event ID 로 들어간다.
SetTimer( i, 1000, NULL );
}
}
}
@@ -0,0 +1,93 @@
#pragma once
#include "afxwin.h"
#include "afxcmn.h"
#include <iostream>
#include <map>
#include <algorithm>
#include <list>
class CZoneDialog;
// CNoticeDlg 대화 상자입니다.
class CNoticeDlg : public CDialogEx
{
DECLARE_DYNAMIC(CNoticeDlg)
public:
CNoticeDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CNoticeDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_NOTICEDLG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CListCtrl m_ListStartDate;
CListCtrl m_ListInterval;
CListCtrl m_ListEndDate;
CListCtrl m_ListNotice;
CEdit m_EditStartDate;
CEdit m_EditInterval;
CEdit m_EditEndDate;
CEdit m_EditNotice;
protected:
CZoneDialog* m_parent;
enum eNoticeType
{
NOTICE_NONE,
NOTICE_START_ON,
NOTICE_START_BEFORE,
NOTICE_START_AFTER,
NOTICE_END,
NOTICE_MAX
};
struct IntervalData
{
eNoticeType eType;
std::list<int> m_IntervalTimeList;
IntervalData()
{
Init();
}
void Init()
{
eType = NOTICE_NONE;
m_IntervalTimeList.clear();
}
};
std::map< int, IntervalData > m_TimeNoticeMap;
protected:
void InsertStartDate( CString startDate );
void InsertInterval( CString interval);
void InsertEndDate( CString endDate );
void InsertNotice( CString notice );
void TimeCheck();
void DoAnnounceTime( int iSelected );
public:
void Startup( CZoneDialog* parent );
void InitList();
void DeleteListItem( CListCtrl& AllList );
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedButtonInput();
afx_msg void OnBnClickedButtonAnnounceTime();
afx_msg void OnBnClickedButtonDelete();
afx_msg void OnBnClickedButtonClear();
virtual BOOL PreTranslateMessage( MSG* pMsg );
afx_msg void OnTimer(UINT_PTR nIDEvent);
};
@@ -0,0 +1,816 @@
// OScopeCtrl.cpp : implementation file//
#include "stdafx.h"
#include "math.h"
#include "OScopeCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COScopeCtrl
COScopeCtrl::COScopeCtrl()
: m_bCountryCode(false)
{
// since plotting is based on a LineTo for each new point
// we need a starting point (i.e. a "previous" point)
// use 0.0 as the default first point.
// these are public member variables, and can be changed outside
// (after construction). Therefore m_perviousPosition could be set to
// a more appropriate value prior to the first call to SetPosition.
m_dPreviousPosition = 0.0;
// public variable for the number of decimal places on the y axis
m_nYDecimals = 3;
// set some initial values for the scaling until "SetRange" is called.
// these are protected varaibles and must be set with SetRange
// in order to ensure that m_dRange is updated accordingly
m_dLowerLimit = -10.0;
m_dUpperLimit = 10.0;
m_dLowerXLimit = 0.0;
m_dUpperYLimit = 24.0;
m_dRange = m_dUpperLimit - m_dLowerLimit; // protected member variable
// m_nShiftPixels determines how much the plot shifts (in terms of pixels)
// with the addition of a new data point
m_nShiftPixels = 4;
m_nHalfShiftPixels = m_nShiftPixels/2; // protected
m_nPlotShiftPixels = m_nShiftPixels + m_nHalfShiftPixels; // protected
// background, grid and data colors
// these are public variables and can be set directly
m_crBackColor = RGB( 0, 0, 0); // see also SetBackgroundColor
m_crGridColor = RGB( 0, 255, 255); // see also SetGridColor
m_crPlotColor = RGB(255, 255, 255); // see also SetPlotColor
//set country count color
m_crCCUColor[CI_EG] = CCU_RGB_ENG;
m_crCCUColor[CI_GE] = CCU_RGB_GER;
m_crCCUColor[CI_FR] = CCU_RGB_FRA;
m_crCCUColor[CI_IT] = CCU_RGB_ITA;
m_crCCUColor[CI_PL] = CCU_RGB_POL;
m_crCCUColor[CI_TR] = CCU_RGB_TUR;
m_crCCUColor[CI_ETC] = CCU_RGB_ETC;
// protected variables
m_penPlot.CreatePen(PS_SOLID, 0, m_crPlotColor);
m_brushBack.CreateSolidBrush(m_crBackColor);
//crate ccu pen & CCUArray
for(int i = 0 ; i < CI_MAX ; ++i)
{
m_CCUpen[i].CreatePen(PS_SOLID, 2, m_crCCUColor[i]);
m_dCurCCUPosition[i] = 0;
m_dPreCCUPosition[i] = 0;
}
// public member variables, can be set directly
m_strXUnitsString.Format(_T("Concurrent User(%06d/%06d)"), 0, 0); // can also be set with SetXUnits
m_strYUnitsString.Format(_T("Y units")); // can also be set with SetYUnits
// protected bitmaps to restore the memory DC's
m_pbitmapOldGrid = NULL;
m_pbitmapOldPlot = NULL;
InitToolTip();
} // COScopeCtrl
/////////////////////////////////////////////////////////////////////////////
COScopeCtrl::~COScopeCtrl()
{
// just to be picky restore the bitmaps for the two memory dc's
// (these dc's are being destroyed so there shouldn't be any leaks)
if (m_pbitmapOldGrid != NULL)
m_dcGrid.SelectObject(m_pbitmapOldGrid);
if (m_pbitmapOldPlot != NULL)
m_dcPlot.SelectObject(m_pbitmapOldPlot);
if (m_pbitmapCCUOldPlot[0] != NULL) //CCU
{
for(int i = 0 ; i < CI_MAX ; ++i)
m_dcCCUPlot[i].SelectObject(m_pbitmapCCUOldPlot[i]);
}
} // ~COScopeCtrl
BEGIN_MESSAGE_MAP(COScopeCtrl, CWnd)
//{{AFX_MSG_MAP(COScopeCtrl)
ON_WM_PAINT()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COScopeCtrl message handlers
/////////////////////////////////////////////////////////////////////////////
BOOL COScopeCtrl::Create(DWORD dwStyle, const RECT& rect,
CWnd* pParentWnd, UINT nID)
{
BOOL result;
static CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);
result = CWnd::CreateEx(
WS_EX_CLIENTEDGE | WS_EX_STATICEDGE,
className, NULL, dwStyle,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
pParentWnd->GetSafeHwnd(), (HMENU)nID);
if (result != 0)
InvalidateCtrl();
return result;
} // Create
void COScopeCtrl::SetToolTip(CString text)
{
m_toolTip.AddTool(this, text, NULL, 0);
m_toolTip.Activate(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::SetRange( bool b, double dLower, double dUpper, int nDecimalPlaces)
{
ASSERT(dUpper > dLower);
m_dLowerLimit = dLower;
m_dUpperLimit = dUpper;
m_nYDecimals = nDecimalPlaces;
m_dRange = m_dUpperLimit - m_dLowerLimit;
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
// clear out the existing garbage, re-start with a clean plot
if( b )
InvalidateCtrl();
else
RefreshRange();
} // SetRange
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::SetXUnits(CString string)
{
m_strXUnitsString = string;
// clear out the existing garbage, re-start with a clean plot
//InvalidateCtrl();
InvalidateXUnits();
} // SetXUnits
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::SetYUnits(CString string)
{
m_strYUnitsString = string;
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetYUnits
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::SetGridColor(COLORREF color)
{
m_crGridColor = color;
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetGridColor
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::SetPlotColor(COLORREF color)
{
m_crPlotColor = color;
m_penPlot.DeleteObject();
m_penPlot.CreatePen(PS_SOLID, 0, m_crPlotColor);
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetPlotColor
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::SetBackgroundColor(COLORREF color)
{
m_crBackColor = color;
m_brushBack.DeleteObject();
m_brushBack.CreateSolidBrush(m_crBackColor);
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetBackgroundColor
void COScopeCtrl::InitToolTip()
{
if (m_toolTip.m_hWnd == NULL)
{
m_toolTip.Create(this);
m_toolTip.Activate(FALSE);
m_toolTip.SetDelayTime(TTDT_AUTOPOP, 800);
}
}
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::RefreshRange()
{
// There is a lot of drawing going on here - particularly in terms of
// drawing the grid. Don't panic, this is all being drawn (only once)
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
int i = 0;
int nCharacters = 0;
int nTopGridPix = 0, nMidGridPix = 0, nBottomGridPix = 0;
CPen *oldPen = NULL;
CPen solidPen(PS_SOLID, 0, m_crGridColor);
CFont axisFont, yUnitFont, *oldFont;
CString strTemp;
// in case we haven't established the memory dc's
CClientDC dc(this);
// if we don't have one yet, set up a memory dc for the grid
if (m_dcGrid.GetSafeHdc() == NULL)
{
m_dcGrid.CreateCompatibleDC(&dc);
m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
}
m_dcGrid.SetBkColor (m_crBackColor);
// fill the grid background
m_dcGrid.FillRect(m_rectClient, &m_brushBack);
// draw the plot rectangle:
// determine how wide the y axis scaling values are
nCharacters = abs((int)log10(fabs(m_dUpperLimit)));
nCharacters = max(nCharacters, abs((int)log10(fabs(m_dLowerLimit))));
//nCharacters = 3;
// add the units digit, decimal point and a minus sign, and an extra space
// as well as the number of decimal places to display
nCharacters = nCharacters + 4 + m_nYDecimals;
// adjust the plot rectangle dimensions
// assume 6 pixels per character (this may need to be adjusted)
m_rectPlot.left = m_rectClient.left + 4*(nCharacters);
m_nPlotWidth = m_rectPlot.Width();
// draw the plot rectangle
oldPen = m_dcGrid.SelectObject (&solidPen);
m_dcGrid.MoveTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.SelectObject (oldPen);
// draw the dotted lines,
// use SetPixel instead of a dotted pen - this allows for a
// finer dotted line and a more "technical" look
nMidGridPix = (m_rectPlot.top + m_rectPlot.bottom)/2;
nTopGridPix = nMidGridPix - m_nPlotHeight/4;
nBottomGridPix = nMidGridPix + m_nPlotHeight/4;
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=4)
{
m_dcGrid.SetPixel (i, nTopGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nMidGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nBottomGridPix, m_crGridColor);
}
// create some fonts (horizontal and vertical)
// use a height of 14 pixels and 300 weight
// (these may need to be adjusted depending on the display)
axisFont.CreateFont (14, 0, 0, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
yUnitFont.CreateFont (14, 0, 900, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
// grab the horizontal font
oldFont = m_dcGrid.SelectObject(&axisFont);
// y max
m_dcGrid.SetTextColor (m_crGridColor);
m_dcGrid.SetTextAlign (TA_RIGHT|TA_TOP);
//strTemp.Format (_T("%.*lf"), m_nYDecimals, m_dUpperLimit);
strTemp.Format (_T("%d"), (int)m_dUpperLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.top, strTemp);
// y min
m_dcGrid.SetTextAlign (TA_RIGHT|TA_BASELINE);
//strTemp.Format (_T("%.*lf"), m_nYDecimals, m_dLowerLimit);
strTemp.Format (_T("%d"), (int)m_dLowerLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.bottom, strTemp);
//// x min
//m_dcGrid.SetTextAlign (TA_LEFT|TA_TOP);
//m_dcGrid.TextOut (m_rectPlot.left, m_rectPlot.bottom+4, _T("0"));
//// x max
//m_dcGrid.SetTextAlign (TA_RIGHT|TA_TOP);
//strTemp.Format (_T("%d"), m_nPlotWidth/m_nShiftPixels);
//m_dcGrid.TextOut (m_rectPlot.right, m_rectPlot.bottom+4, strTemp);
// x units
m_dcGrid.SetTextAlign (TA_CENTER|TA_TOP);
m_dcGrid.TextOut ((m_rectPlot.left+m_rectPlot.right)/2,
m_rectPlot.bottom+20, m_strXUnitsString);
// restore the font
m_dcGrid.SelectObject(oldFont);
// y units
oldFont = m_dcGrid.SelectObject(&yUnitFont);
m_dcGrid.SetTextAlign (TA_CENTER|TA_BASELINE);
m_dcGrid.TextOut ((m_rectClient.left+m_rectPlot.left)/2,
(m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString);
m_dcGrid.SelectObject(oldFont);
// at this point we are done filling the the grid bitmap,
// no more drawing to this bitmap is needed until the setting are changed
// if we don't have one yet, set up a memory dc for the plot
if (m_dcPlot.GetSafeHdc() == NULL)
{
m_dcPlot.CreateCompatibleDC(&dc);
m_bitmapPlot.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldPlot = m_dcPlot.SelectObject(&m_bitmapPlot);
for(int i = 0 ; i < CI_MAX ; ++i)
{
m_dcCCUPlot[i].CreateCompatibleDC(&dc);
m_bitmapCCUPlot[i].CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapCCUOldPlot[i] = m_dcCCUPlot[i].SelectObject(&m_bitmapCCUPlot[i]);
}
}
/*
// make sure the plot bitmap is cleared
m_dcPlot.SetBkColor (m_crBackColor);
m_dcPlot.FillRect(m_rectClient, &m_brushBack);
*/
// finally, force the plot area to redraw
InvalidateRect(m_rectClient);
}
void COScopeCtrl::InvalidateCtrl()
{
// There is a lot of drawing going on here - particularly in terms of
// drawing the grid. Don't panic, this is all being drawn (only once)
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
int i;
int nCharacters;
int nTopGridPix, nMidGridPix, nBottomGridPix;
CPen *oldPen;
CPen solidPen(PS_SOLID, 0, m_crGridColor);
CFont axisFont, yUnitFont, *oldFont;
CString strTemp;
// in case we haven't established the memory dc's
CClientDC dc(this);
// if we don't have one yet, set up a memory dc for the grid
if (m_dcGrid.GetSafeHdc() == NULL)
{
m_dcGrid.CreateCompatibleDC(&dc);
m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
}
m_dcGrid.SetBkColor (m_crBackColor);
// fill the grid background
m_dcGrid.FillRect(m_rectClient, &m_brushBack);
// draw the plot rectangle:
// determine how wide the y axis scaling values are
nCharacters = abs((int)log10(fabs(m_dUpperLimit)));
nCharacters = max(nCharacters, abs((int)log10(fabs(m_dLowerLimit))));
// add the units digit, decimal point and a minus sign, and an extra space
// as well as the number of decimal places to display
nCharacters = nCharacters + 4 + m_nYDecimals;
// adjust the plot rectangle dimensions
// assume 6 pixels per character (this may need to be adjusted)
m_rectPlot.left = m_rectClient.left + 4*(nCharacters);
m_nPlotWidth = m_rectPlot.Width();
// draw the plot rectangle
oldPen = m_dcGrid.SelectObject (&solidPen);
m_dcGrid.MoveTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.SelectObject (oldPen);
// draw the dotted lines,
// use SetPixel instead of a dotted pen - this allows for a
// finer dotted line and a more "technical" look
nMidGridPix = (m_rectPlot.top + m_rectPlot.bottom)/2;
nTopGridPix = nMidGridPix - m_nPlotHeight/4;
nBottomGridPix = nMidGridPix + m_nPlotHeight/4;
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=4)
{
m_dcGrid.SetPixel (i, nTopGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nMidGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nBottomGridPix, m_crGridColor);
}
// create some fonts (horizontal and vertical)
// use a height of 14 pixels and 300 weight
// (these may need to be adjusted depending on the display)
axisFont.CreateFont (14, 0, 0, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
yUnitFont.CreateFont (14, 0, 900, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
// grab the horizontal font
oldFont = m_dcGrid.SelectObject(&axisFont);
// y max
m_dcGrid.SetTextColor (m_crGridColor);
m_dcGrid.SetTextAlign (TA_RIGHT|TA_TOP);
//strTemp.Format ("%.*lf", m_nYDecimals, m_dUpperLimit);
strTemp.Format (_T("%d"), (int)m_dUpperLimit);
m_dcGrid.TextOut (m_rectPlot.left, m_rectPlot.top, strTemp);
// y min
m_dcGrid.SetTextAlign (TA_RIGHT|TA_BASELINE);
//strTemp.Format ("%.*lf", m_nYDecimals, m_dLowerLimit);
strTemp.Format (_T("%d"), (int)m_dLowerLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.bottom, strTemp);
// x min
m_dcGrid.SetTextAlign (TA_RIGHT|TA_BOTTOM);
strTemp.Format (_T("%d"), (int)m_dUpperYLimit);
m_dcGrid.TextOut (m_rectPlot.right, m_rectPlot.bottom+10, strTemp);
// x max
m_dcGrid.SetTextAlign (TA_RIGHT|TA_BOTTOM);
strTemp.Format ("%d", (int)m_dLowerXLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.bottom+10, strTemp);
if( strTemp == "102" )
{
TRACE( "%s\n", strTemp );
}
// x units
m_dcGrid.SetTextAlign (TA_CENTER|TA_TOP);
m_dcGrid.TextOut ((m_rectPlot.left+m_rectPlot.right)/2,
m_rectPlot.bottom+20, m_strXUnitsString);
// restore the font
m_dcGrid.SelectObject(oldFont);
// y units
oldFont = m_dcGrid.SelectObject(&yUnitFont);
m_dcGrid.SetTextAlign (TA_CENTER|TA_BASELINE);
m_dcGrid.TextOut ((m_rectClient.left+m_rectPlot.left)/2, (m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString);
m_dcGrid.SelectObject(oldFont);
// at this point we are done filling the the grid bitmap,
// no more drawing to this bitmap is needed until the setting are changed
// if we don't have one yet, set up a memory dc for the plot
if (m_dcPlot.GetSafeHdc() == NULL)
{
m_dcPlot.CreateCompatibleDC(&dc);
m_bitmapPlot.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldPlot = m_dcPlot.SelectObject(&m_bitmapPlot);
}
for(int i = 0 ; i < CI_MAX ; ++i)
{
if(m_dcCCUPlot[i].GetSafeHdc() == NULL)
{
m_dcCCUPlot[i].CreateCompatibleDC(&dc);
m_bitmapCCUPlot[i].CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapCCUOldPlot[i] = m_dcCCUPlot[i].SelectObject(&m_bitmapCCUPlot[i]);
}
}
// make sure the plot bitmap is cleared
m_dcPlot.SetBkColor (m_crBackColor);
m_dcPlot.FillRect(m_rectClient, &m_brushBack);
// finally, force the plot area to redraw
InvalidateRect(m_rectClient);
} // InvalidateCtrl
void COScopeCtrl::InvalidateXUnits()
{
// There is a lot of drawing going on here - particularly in terms of
// drawing the grid. Don't panic, this is all being drawn (only once)
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
CFont axisFont, *oldFont;
// in case we haven't established the memory dc's
CClientDC dc(this);
// if we don't have one yet, set up a memory dc for the grid
if (m_dcGrid.GetSafeHdc() == NULL)
{
m_dcGrid.CreateCompatibleDC(&dc);
m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
}
// create some fonts (horizontal and vertical)
// use a height of 14 pixels and 300 weight
// (these may need to be adjusted depending on the display)
axisFont.CreateFont (14, 0, 0, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
// grab the horizontal font
oldFont = m_dcGrid.SelectObject(&axisFont);
// x units
m_dcGrid.SetTextAlign (TA_CENTER|TA_TOP);
m_dcGrid.TextOut ((m_rectPlot.left+m_rectPlot.right)/2, m_rectPlot.bottom+20, m_strXUnitsString);
// restore the font
m_dcGrid.SelectObject(oldFont);
// finally, force the plot area to redraw
InvalidateRect(m_rectClient);
}
/////////////////////////////////////////////////////////////////////////////
double COScopeCtrl::AppendPoint(bool bCCU, double dNewPoint)
{
// append a data point to the plot
// return the previous point
m_bCountryCode = bCCU;
double dPrevious;
dPrevious = m_dCurrentPosition;
m_dCurrentPosition = dNewPoint;
DrawPoint();
Invalidate();
return dPrevious;
} // AppendPoint
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::AppendCCUPoint(double dNewGB,double dNewDE,double dNewFR,double dNewIT,double dNewPL,double dNewTR, double dNewETC )
{
m_dCurCCUPosition[CI_EG] = dNewGB;
m_dCurCCUPosition[CI_GE] = dNewDE;
m_dCurCCUPosition[CI_FR] = dNewFR;
m_dCurCCUPosition[CI_IT] = dNewIT;
m_dCurCCUPosition[CI_PL] = dNewPL;
m_dCurCCUPosition[CI_TR] = dNewTR;
m_dCurCCUPosition[CI_ETC] = dNewETC;
} //AppendCCUPoint
////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC memDC;
CBitmap memBitmap;
CBitmap* oldBitmap; // bitmap originally found in CMemDC
// no real plotting work is performed here,
// just putting the existing bitmaps on the client
// to avoid flicker, establish a memory dc, draw to it
// and then BitBlt it to the client
memDC.CreateCompatibleDC(&dc);
memBitmap.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap);
if (memDC.GetSafeHdc() != NULL)
{
// first drop the grid on the memory dc
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &m_dcGrid, 0, 0, SRCCOPY);
// now add the plot on top as a "pattern" via SRCPAINT.
// works well with dark background and a light plot
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &m_dcPlot, 0, 0, SRCPAINT); //SRCPAINT
//CCU
if(m_bCountryCode)
{
for(int i = 0 ; i < CI_MAX ; ++i)
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &m_dcCCUPlot[i], 0, 0, SRCPAINT);
}
// finally send the result to the display
dc.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(oldBitmap);
} // OnPaint
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::DrawPoint()
{
// this does the work of "scrolling" the plot to the left
// and appending a new data point all of the plotting is
// directed to the memory based bitmap associated with m_dcPlot
// the will subsequently be BitBlt'd to the client in OnPaint
int currX, prevX, currY, prevY;
int currCCUX[CI_MAX], prevCCUX[CI_MAX], currCCUY[CI_MAX], prevCCUY[CI_MAX];
CPen *oldPen;
CPen *oldCCUPen[CI_MAX];
CRect rectCleanUp;
if (m_dcPlot.GetSafeHdc() != NULL)
{
// shift the plot by BitBlt'ing it to itself
// note: the m_dcPlot covers the entire client
// but we only shift bitmap that is the size
// of the plot rectangle
// grab the right side of the plot (exluding m_nShiftPixels on the left)
// move this grabbed bitmap to the left by m_nShiftPixels
m_dcPlot.BitBlt(m_rectPlot.left, m_rectPlot.top+1, m_nPlotWidth, m_nPlotHeight, &m_dcPlot, m_rectPlot.left+m_nShiftPixels, m_rectPlot.top+1, SRCCOPY);
// establish a rectangle over the right side of plot
// which now needs to be cleaned up proir to adding the new point
rectCleanUp = m_rectPlot;
rectCleanUp.left = rectCleanUp.right - m_nShiftPixels;
// fill the cleanup area with the background
m_dcPlot.FillRect(rectCleanUp, &m_brushBack);
// draw the next line segement
// grab the plotting pen
oldPen = m_dcPlot.SelectObject(&m_penPlot);
// move to the previous point
prevX = m_rectPlot.right - m_nPlotShiftPixels;
prevY = m_rectPlot.bottom - (long)((m_dPreviousPosition - m_dLowerLimit) * m_dVerticalFactor);
m_dcPlot.MoveTo (prevX, prevY);
// draw to the current point
currX = m_rectPlot.right-m_nHalfShiftPixels;
currY = m_rectPlot.bottom - (long)((m_dCurrentPosition - m_dLowerLimit) * m_dVerticalFactor);
m_dcPlot.LineTo (currX, currY);
// restore the pen
m_dcPlot.SelectObject(oldPen);
// if the data leaks over the upper or lower plot boundaries
// fill the upper and lower leakage with the background
// this will facilitate clipping on an as needed basis
// as opposed to always calling IntersectClipRect
if ((prevY <= m_rectPlot.top) || (currY <= m_rectPlot.top))
m_dcPlot.FillRect(CRect(prevX, m_rectClient.top, currX+1, m_rectPlot.top+1), &m_brushBack);
if ((prevY >= m_rectPlot.bottom) || (currY >= m_rectPlot.bottom))
m_dcPlot.FillRect(CRect(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1), &m_brushBack);
// store the current point for connection to the next point
m_dPreviousPosition = m_dCurrentPosition;
if(m_bCountryCode)
{
for(int i = 0 ; i < CI_MAX ; ++i)
{
m_dcCCUPlot[i].BitBlt(m_rectPlot.left, m_rectPlot.top+1, m_nPlotWidth, m_nPlotHeight, &m_dcCCUPlot[i], m_rectPlot.left+m_nShiftPixels, m_rectPlot.top+1, SRCCOPY);
if(m_dcCCUPlot[i].GetSafeHdc() != NULL)
{
//grab the plotting pen
oldCCUPen[i] = m_dcCCUPlot[i].SelectObject(&m_CCUpen[i]);
//previous point
prevCCUX[i] = m_rectPlot.right - m_nPlotShiftPixels;
prevCCUY[i] = m_rectPlot.bottom - (long)((m_dPreCCUPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
m_dcCCUPlot[i].MoveTo(prevCCUX[i], prevCCUY[i]);
//current point
currCCUX[i] = m_rectPlot.right-m_nHalfShiftPixels;
currCCUY[i] = m_rectPlot.bottom - (long)((m_dCurCCUPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
m_dcCCUPlot[i].LineTo (currCCUX[i], currCCUY[i]);
//restore the pen
m_dcCCUPlot[i].SelectObject(oldCCUPen[i]);
if ((prevCCUY[i] <= m_rectPlot.top) || (currCCUY[i] <= m_rectPlot.top))
m_dcCCUPlot[i].FillRect(CRect(prevCCUX[i], m_rectClient.top, currCCUX[i]+1, m_rectPlot.top+1), &m_brushBack);
if ((prevCCUY[i] >= m_rectPlot.bottom) || (currCCUY[i] >= m_rectPlot.bottom))
m_dcCCUPlot[i].FillRect(CRect(prevCCUX[i], m_rectPlot.bottom+1, currCCUX[i]+1, m_rectClient.bottom+1), &m_brushBack);
// store the current point for connection to the next point
m_dPreCCUPosition[i] = m_dCurCCUPosition[i];
}
}
}
}
} // end DrawPoint
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
// NOTE: OnSize automatically gets called during the setup of the control
GetClientRect(m_rectClient);
// set some member variables to avoid multiple function calls
m_nClientHeight = m_rectClient.Height();
m_nClientWidth = m_rectClient.Width();
// the "left" coordinate and "width" will be modified in
// InvalidateCtrl to be based on the width of the y axis scaling
m_rectPlot.left = 5;
m_rectPlot.top = 5;
m_rectPlot.right = m_rectClient.right-10;
m_rectPlot.bottom = m_rectClient.bottom-20;
// set some member variables to avoid multiple function calls
m_nPlotHeight = m_rectPlot.Height();
m_nPlotWidth = m_rectPlot.Width();
// set the scaling factor for now, this can be adjusted
// in the SetRange functions
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
} // OnSize
/////////////////////////////////////////////////////////////////////////////
void COScopeCtrl::Reset()
{
m_dPreviousPosition = 0;
m_dCurrentPosition = 0;
InvalidateCtrl();
}
int COScopeCtrl::GetWidth()
{
int nWidth = m_rectPlot.right - m_rectPlot.left;
return nWidth;
}
BOOL COScopeCtrl::PreTranslateMessage(MSG* pMsg)
{
m_toolTip.RelayEvent(pMsg);
return CWnd::PreTranslateMessage(pMsg);
}
int COScopeCtrl::GetRightPixel()
{
return m_rectPlot.right;
}
int COScopeCtrl::GetLeftPixel()
{
return m_rectPlot.left;
}
@@ -0,0 +1,113 @@
// OScopeCtrl.h : header file
//
#pragma once
/////////////////////////////////////////////////////////////////////////////
// COScopeCtrl window
class COScopeCtrl : public CWnd
{
// Construction
public:
// COScopeCtrl(int iLine = 1);
COScopeCtrl();
virtual ~COScopeCtrl();
// Attributes
public:
double AppendPoint(bool bCCU, double dNewPoint);
void AppendCCUPoint( double dNewGB,double dNewDE,double dNewFR,double dNewIT,double dNewPL,double dNewTR, double dNewETC);
void SetToolTip(CString string);
void SetRange(bool b, double dLower, double dUpper, int nDecimalPlaces=1);
void SetXUnits(CString string);
void SetYUnits(CString string);
void SetGridColor(COLORREF color);
void SetPlotColor(COLORREF color);
void SetBackgroundColor(COLORREF color);
void InitToolTip();
void RefreshRange();
void InvalidateCtrl();
void InvalidateXUnits();
void DrawPoint();
void Reset();
// Operations
public:
int GetWidth();
int GetRightPixel();
int GetLeftPixel();
BOOL PreTranslateMessage(MSG* pMsg);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(COScopeCtrl)
public:
virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID=NULL);
//}}AFX_VIRTUAL
// Implementation
public:
int m_nShiftPixels; // amount to shift with each new point
int m_nYDecimals;
CString m_strXUnitsString;
CString m_strYUnitsString;
COLORREF m_crBackColor; // background color
COLORREF m_crGridColor; // grid color
COLORREF m_crPlotColor; // data color
COLORREF m_crCCUColor[CI_MAX];
double m_dCurrentPosition; // current position
double m_dPreviousPosition; // previous position
//CCU Point
double m_dCurCCUPosition[CI_MAX]; // current position
double m_dPreCCUPosition[CI_MAX]; // previous position
bool m_bCountryCode;
// Generated message map functions
protected:
//{{AFX_MSG(COScopeCtrl)
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
int m_nHalfShiftPixels;
int m_nPlotShiftPixels;
int m_nClientHeight;
int m_nClientWidth;
int m_nPlotHeight;
int m_nPlotWidth;
double m_dLowerLimit; // lower bounds
double m_dUpperLimit; // upper bounds
double m_dLowerXLimit; // lower bounds
double m_dUpperYLimit; // upper bounds
double m_dRange;
double m_dVerticalFactor;
CRect m_rectClient;
CRect m_rectPlot;
CPen m_penPlot;
CPen m_CCUpen[CI_MAX];
CBrush m_brushBack;
CDC m_dcGrid;
CDC m_dcPlot;
CDC m_dcCCUPlot[CI_MAX];
CBitmap *m_pbitmapOldGrid;
CBitmap *m_pbitmapOldPlot;
CBitmap *m_pbitmapCCUOldPlot[CI_MAX];
CBitmap m_bitmapGrid;
CBitmap m_bitmapPlot;
CBitmap m_bitmapCCUPlot[CI_MAX];
CToolTipCtrl m_toolTip;
};
@@ -0,0 +1,942 @@
// OScopeTimeCtrl.cpp : implementation file//
#include "stdafx.h"
#include "math.h"
#include "OScopeTimeCtrl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COScopeTimeCtrl
COScopeTimeCtrl::COScopeTimeCtrl()
: m_bCountryCode(false)
{
InitDate();
m_nYDecimals = 3;
m_dLowerLimit = -10.0;
m_dUpperLimit = 10.0;
m_dLowerXLimit = 0.0;
m_dUpperYLimit = 24.0;
m_dRange = m_dUpperLimit - m_dLowerLimit; // protected member variable
m_nShiftPixels = 0;
m_nHalfShiftPixels = m_nShiftPixels/2; // protected
m_nPlotShiftPixels = m_nShiftPixels + m_nHalfShiftPixels; // protected
m_crBackColor = RGB( 0, 0, 0); // see also SetBackgroundColor
m_crGridColor = RGB( 0, 255, 255); // see also SetGridColor
m_crPlotColor = RGB(255, 255, 255); // see also SetPlotColor
//set country count color
m_crCCUColor[CI_EG] = CCU_RGB_ENG;
m_crCCUColor[CI_GE] = CCU_RGB_GER;
m_crCCUColor[CI_FR] = CCU_RGB_FRA;
m_crCCUColor[CI_IT] = CCU_RGB_ITA;
m_crCCUColor[CI_PL] = CCU_RGB_POL;
m_crCCUColor[CI_TR] = CCU_RGB_TUR;
m_crCCUColor[CI_ETC] = CCU_RGB_ETC;
// protected variables
m_penPlot.CreatePen(PS_SOLID, 1, m_crPlotColor);
m_brushBack.CreateSolidBrush(m_crBackColor);
//crate ccu pen & CCUArray
for(int i = 0 ; i < CI_MAX ; ++i)
{
m_CCUpen[i].CreatePen(PS_SOLID, 2, m_crCCUColor[i]);
m_dCurCCUPosition[i] = 0;
m_dPreCCUPosition[i] = 0;
}
// public member variables, can be set directly
m_strXUnitsString.Format(_T("Concurrent User(%06d/%06d)"), 0, 0); // can also be set with SetXUnits
m_strYUnitsString.Format(_T("Y units")); // can also be set with SetYUnits
// protected bitmaps to restore the memory DC's
m_pbitmapOldGrid = NULL;
m_pbitmapOldPlot = NULL;
InitToolTip();
} // COScopeTimeCtrl
/////////////////////////////////////////////////////////////////////////////
COScopeTimeCtrl::~COScopeTimeCtrl()
{
if (m_pbitmapOldGrid != NULL)
m_dcGrid.SelectObject(m_pbitmapOldGrid);
if (m_pbitmapOldPlot != NULL)
m_dcPlot.SelectObject(m_pbitmapOldPlot);
if (m_pbitmapCCUOldPlot[0] != NULL) //CCU
{
for(int i = 0 ; i < CI_MAX ; ++i)
{
m_dcCCUPlot[i].SelectObject(m_pbitmapCCUOldPlot[i]);
}
}
} // ~COScopeTimeCtrl
BEGIN_MESSAGE_MAP(COScopeTimeCtrl, CWnd)
ON_WM_PAINT()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COScopeTimeCtrl message handlers
/////////////////////////////////////////////////////////////////////////////
BOOL COScopeTimeCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
BOOL result;
static CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW);
result = CWnd::CreateEx(
WS_EX_CLIENTEDGE | WS_EX_STATICEDGE,
className, NULL, dwStyle,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
pParentWnd->GetSafeHwnd(), (HMENU)nID);
if (result != 0)
InvalidateCtrl();
return result;
} // Create
void COScopeTimeCtrl::InitDate()
{
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
m_stPrevDateTime = sysTime;
m_stPrevDateTime.wHour = 0;
m_stPrevDateTime.wMinute = 0;
m_stPrevDateTime.wSecond = 0;
m_stPrevDateTime.wMilliseconds = 0;
m_dPreviousPosition = 0.0;
m_bGraph = false;
}
void COScopeTimeCtrl::DateSetting(int iYear, int iMonth, int iDay, int iDayOfWeek, int iHour, int iMinute, int iSecond, int iMilliseconds)
{
m_stPrevDateTime.wYear = iYear;
m_stPrevDateTime.wMonth = iMonth;
m_stPrevDateTime.wDay = iDay;
m_stPrevDateTime.wDayOfWeek = iDayOfWeek;
m_stPrevDateTime.wHour = iHour;
m_stPrevDateTime.wMinute = iMinute;
m_stPrevDateTime.wSecond = iSecond;
m_stPrevDateTime.wMilliseconds = iMilliseconds;
}
void COScopeTimeCtrl::SetToolTip(int x, int y, CString text)
{
m_toolTip.SetMaxTipWidth(10);
m_toolTip.AddTool(this, text, NULL, 0);
m_toolTip.Activate(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::SetRange( bool b, double dLower, double dUpper, int nDecimalPlaces)
{
ASSERT(dUpper >= dLower);
m_dLowerLimit = dLower;
m_dUpperLimit = dUpper;
m_nYDecimals = nDecimalPlaces;
m_dRange = m_dUpperLimit - m_dLowerLimit;
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
// clear out the existing garbage, re-start with a clean plot
if( b )
InvalidateCtrl();
else
RefreshRange();
} // SetRange
void COScopeTimeCtrl::SetDay(int iDay)
{
m_day = iDay;
} // SetXUnits
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::SetXUnits(CString string)
{
m_strXUnitsString = string;
// clear out the existing garbage, re-start with a clean plot
//InvalidateCtrl();
InvalidateXUnits();
} // SetXUnits
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::SetYUnits(CString string)
{
m_strYUnitsString = string;
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetYUnits
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::SetGridColor(COLORREF color)
{
m_crGridColor = color;
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetGridColor
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::SetPlotColor(COLORREF color)
{
m_crPlotColor = color;
m_penPlot.DeleteObject();
m_penPlot.CreatePen(PS_SOLID, 0, m_crPlotColor);
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetPlotColor
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::SetBackgroundColor(COLORREF color)
{
m_crBackColor = color;
m_brushBack.DeleteObject();
m_brushBack.CreateSolidBrush(m_crBackColor);
// clear out the existing garbage, re-start with a clean plot
InvalidateCtrl();
} // SetBackgroundColor
void COScopeTimeCtrl::InitToolTip()
{
if (m_toolTip.m_hWnd == NULL)
{
m_toolTip.Create(this);
m_toolTip.Activate(FALSE);
m_toolTip.SetDelayTime(TTDT_AUTOPOP, 800);
}
}
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::RefreshRange()
{
// There is a lot of drawing going on here - particularly in terms of
// drawing the grid. Don't panic, this is all being drawn (only once)
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
int i = 0;
int nCharacters = 0;
int nTopGridPix = 0, nMidGridPix = 0, nBottomGridPix = 0;
CPen *oldPen = NULL;
CPen solidPen(PS_SOLID, 0, m_crGridColor);
CFont axisFont, yUnitFont, *oldFont;
CString strTemp;
// in case we haven't established the memory dc's
CClientDC dc(this);
// if we don't have one yet, set up a memory dc for the grid
if (m_dcGrid.GetSafeHdc() == NULL)
{
m_dcGrid.CreateCompatibleDC(&dc);
m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
}
m_dcGrid.SetBkColor (m_crBackColor);
// fill the grid background
m_dcGrid.FillRect(m_rectClient, &m_brushBack);
// draw the plot rectangle:
// determine how wide the y axis scaling values are
nCharacters = abs((int)log10(fabs(m_dUpperLimit)));
nCharacters = max(nCharacters, abs((int)log10(fabs(m_dLowerLimit))));
//nCharacters = 3;
// add the units digit, decimal point and a minus sign, and an extra space
// as well as the number of decimal places to display
nCharacters = nCharacters + 4 + m_nYDecimals;
// adjust the plot rectangle dimensions
// assume 6 pixels per character (this may need to be adjusted)
m_rectPlot.left = m_rectClient.left + 4*(nCharacters);
m_nPlotWidth = m_rectPlot.Width();
// draw the plot rectangle
oldPen = m_dcGrid.SelectObject (&solidPen);
m_dcGrid.MoveTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.SelectObject (oldPen);
// draw the dotted lines,
// use SetPixel instead of a dotted pen - this allows for a
// finer dotted line and a more "technical" look
nMidGridPix = (m_rectPlot.top + m_rectPlot.bottom)/2;
nTopGridPix = nMidGridPix - m_nPlotHeight/4;
nBottomGridPix = nMidGridPix + m_nPlotHeight/4;
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=4)
{
m_dcGrid.SetPixel (i, nTopGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nMidGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nBottomGridPix, m_crGridColor);
}
// create some fonts (horizontal and vertical)
// use a height of 14 pixels and 300 weight
// (these may need to be adjusted depending on the display)
axisFont.CreateFont (14, 0, 0, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
yUnitFont.CreateFont (14, 0, 900, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
// grab the horizontal font
oldFont = m_dcGrid.SelectObject(&axisFont);
// y max
m_dcGrid.SetTextColor (m_crGridColor);
m_dcGrid.SetTextAlign (TA_RIGHT|TA_TOP);
//strTemp.Format (_T("%.*lf"), m_nYDecimals, m_dUpperLimit);
strTemp.Format (_T("%d"), (int)m_dUpperLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.top, strTemp);
// y min
m_dcGrid.SetTextAlign (TA_RIGHT|TA_BASELINE);
//strTemp.Format (_T("%.*lf"), m_nYDecimals, m_dLowerLimit);
strTemp.Format (_T("%d"), (int)m_dLowerLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.bottom, strTemp);
//// x min
//m_dcGrid.SetTextAlign (TA_LEFT|TA_TOP);
//m_dcGrid.TextOut (m_rectPlot.left, m_rectPlot.bottom+4, _T("0"));
//// x max
//m_dcGrid.SetTextAlign (TA_RIGHT|TA_TOP);
//strTemp.Format (_T("%d"), m_nPlotWidth/m_nShiftPixels);
//m_dcGrid.TextOut (m_rectPlot.right, m_rectPlot.bottom+4, strTemp);
// x units
m_dcGrid.SetTextAlign (TA_CENTER|TA_TOP);
m_dcGrid.TextOut ((m_rectPlot.left+m_rectPlot.right)/2,
m_rectPlot.bottom+20, m_strXUnitsString);
// restore the font
m_dcGrid.SelectObject(oldFont);
// y units
oldFont = m_dcGrid.SelectObject(&yUnitFont);
m_dcGrid.SetTextAlign (TA_CENTER|TA_BASELINE);
m_dcGrid.TextOut ((m_rectClient.left+m_rectPlot.left)/2,
(m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString);
m_dcGrid.SelectObject(oldFont);
// at this point we are done filling the the grid bitmap,
// no more drawing to this bitmap is needed until the setting are changed
// if we don't have one yet, set up a memory dc for the plot
if (m_dcPlot.GetSafeHdc() == NULL)
{
m_dcPlot.CreateCompatibleDC(&dc);
m_bitmapPlot.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldPlot = m_dcPlot.SelectObject(&m_bitmapPlot);
for(int i = 0 ; i < CI_MAX ; ++i)
{
m_dcCCUPlot[i].CreateCompatibleDC(&dc);
m_bitmapCCUPlot[i].CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapCCUOldPlot[i] = m_dcCCUPlot[i].SelectObject(&m_bitmapCCUPlot[i]);
}
}
// finally, force the plot area to redraw
InvalidateRect(m_rectClient);
}
void COScopeTimeCtrl::InvalidateCtrl()
{
// There is a lot of drawing going on here - particularly in terms of
// drawing the grid. Don't panic, this is all being drawn (only once)
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
int i;
int nCharacters;
int nTopGridPix, nMidGridPix, nBottomGridPix;
CPen *oldPen;
CPen solidPen(PS_SOLID, 0, m_crGridColor);
CFont axisFont, yUnitFont, *oldFont;
CString strTemp;
// in case we haven't established the memory dc's
CClientDC dc(this);
// if we don't have one yet, set up a memory dc for the grid
if (m_dcGrid.GetSafeHdc() == NULL)
{
m_dcGrid.CreateCompatibleDC(&dc);
m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
}
m_dcGrid.SetBkColor (m_crBackColor);
// fill the grid background
m_dcGrid.FillRect(m_rectClient, &m_brushBack);
// draw the plot rectangle:
// determine how wide the y axis scaling values are
nCharacters = abs((int)log10(fabs(m_dUpperLimit)));
nCharacters = max(nCharacters, abs((int)log10(fabs(m_dLowerLimit))));
// add the units digit, decimal point and a minus sign, and an extra space
// as well as the number of decimal places to display
nCharacters = nCharacters + 4 + m_nYDecimals;
// adjust the plot rectangle dimensions
// assume 6 pixels per character (this may need to be adjusted)
m_rectPlot.left = m_rectClient.left + 4*(10);
m_rectPlot.right = (m_rectClient.right - m_rectPlot.left)/ 24*24+m_rectPlot.left;
m_rectPlot.bottom = m_rectClient.bottom - 40;
m_nPlotHeight = m_rectPlot.Height();
m_nPlotWidth = m_rectPlot.Width();
// draw the plot rectangle
oldPen = m_dcGrid.SelectObject (&solidPen);
m_dcGrid.MoveTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left-1, m_rectPlot.top);
m_dcGrid.SelectObject (oldPen);
// draw the dotted lines,
// use SetPixel instead of a dotted pen - this allows for a
// finer dotted line and a more "technical" look
nMidGridPix = (m_rectPlot.top + m_rectPlot.bottom)/2;
nTopGridPix = nMidGridPix - m_nPlotHeight/4;
nBottomGridPix = nMidGridPix + m_nPlotHeight/4;
for (i=m_rectPlot.left; i<m_rectPlot.right; i+=4)
{
m_dcGrid.SetPixel (i, nTopGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nMidGridPix, m_crGridColor);
m_dcGrid.SetPixel (i, nBottomGridPix, m_crGridColor);
}
// create some fonts (horizontal and vertical)
// use a height of 14 pixels and 300 weight
// (these may need to be adjusted depending on the display)
axisFont.CreateFont (14, 0, 0, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
yUnitFont.CreateFont (14, 0, 900, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
// grab the horizontal font
oldFont = m_dcGrid.SelectObject(&axisFont);
CountSetting();
TimeSetting();
if( strTemp == "102" )
{
TRACE( "%s\n", strTemp );
}
// x units
m_dcGrid.SetTextAlign (TA_CENTER|TA_TOP);
m_dcGrid.TextOut ((m_rectPlot.left+m_rectPlot.right)/2,
m_rectPlot.bottom+20, m_strXUnitsString);
// restore the font
m_dcGrid.SelectObject(oldFont);
// y units
oldFont = m_dcGrid.SelectObject(&yUnitFont);
m_dcGrid.SetTextAlign (TA_CENTER|TA_BASELINE);
m_dcGrid.TextOut ((m_rectClient.left+m_rectPlot.left)/2, (m_rectPlot.bottom+m_rectPlot.top)/2, m_strYUnitsString);
m_dcGrid.SelectObject(oldFont);
// at this point we are done filling the the grid bitmap,
// no more drawing to this bitmap is needed until the setting are changed
// if we don't have one yet, set up a memory dc for the plot
if (m_dcPlot.GetSafeHdc() == NULL)
{
m_dcPlot.CreateCompatibleDC(&dc);
m_bitmapPlot.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldPlot = m_dcPlot.SelectObject(&m_bitmapPlot);
}
for(int i = 0 ; i < CI_MAX ; ++i)
{
if(m_dcCCUPlot[i].GetSafeHdc() == NULL)
{
m_dcCCUPlot[i].CreateCompatibleDC(&dc);
m_bitmapCCUPlot[i].CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapCCUOldPlot[i] = m_dcCCUPlot[i].SelectObject(&m_bitmapCCUPlot[i]);
}
}
// make sure the plot bitmap is cleared
m_dcPlot.SetBkColor (m_crBackColor);
m_dcPlot.FillRect(m_rectClient, &m_brushBack);
// finally, force the plot area to redraw
InvalidateRect(m_rectClient);
} // InvalidateCtrl
void COScopeTimeCtrl::InvalidateXUnits()
{
// There is a lot of drawing going on here - particularly in terms of
// drawing the grid. Don't panic, this is all being drawn (only once)
// to a bitmap. The result is then BitBlt'd to the control whenever needed.
CFont axisFont, *oldFont;
// in case we haven't established the memory dc's
CClientDC dc(this);
// if we don't have one yet, set up a memory dc for the grid
if (m_dcGrid.GetSafeHdc() == NULL)
{
m_dcGrid.CreateCompatibleDC(&dc);
m_bitmapGrid.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
}
// create some fonts (horizontal and vertical)
// use a height of 14 pixels and 300 weight
// (these may need to be adjusted depending on the display)
axisFont.CreateFont (14, 0, 0, 0, 300,
FALSE, FALSE, 0, ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, _T("Arial"));
// grab the horizontal font
oldFont = m_dcGrid.SelectObject(&axisFont);
// x units
m_dcGrid.SetTextAlign (TA_CENTER|TA_TOP);
m_dcGrid.TextOut ((m_rectPlot.left+m_rectPlot.right)/2, m_rectPlot.bottom+20, m_strXUnitsString);
// restore the font
m_dcGrid.SelectObject(oldFont);
// finally, force the plot area to redraw
InvalidateRect(m_rectClient);
}
/////////////////////////////////////////////////////////////////////////////
double COScopeTimeCtrl::AppendPoint(bool bCCU, double dNewPoint)
{
// append a data point to the plot
// return the previous point
m_bCountryCode = bCCU;
double dPrevious;
dPrevious = m_dCurrentPosition;
m_dCurrentPosition = dNewPoint;
DrawPoint();
Invalidate();
return dPrevious;
} // AppendPoint
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::AppendDateTimePoint(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, bool bCCU, double dNewPoint)
{
m_bCountryCode = bCCU;
double dPrevious;
dPrevious = m_dCurrentPosition;
m_dCurrentPosition = dNewPoint;
DrawPoint(iYear, iMonth, iDay, iHour, iMinute, iSecond, bCCU, dNewPoint);
m_day = iDay;
Invalidate();
}
void COScopeTimeCtrl::AppendCCUPoint(double dNewGB,double dNewDE,double dNewFR,double dNewIT,double dNewPL,double dNewTR, double dNewETC )
{
m_dCurCCUPosition[CI_EG] = dNewGB;
m_dCurCCUPosition[CI_GE] = dNewDE;
m_dCurCCUPosition[CI_FR] = dNewFR;
m_dCurCCUPosition[CI_IT] = dNewIT;
m_dCurCCUPosition[CI_PL] = dNewPL;
m_dCurCCUPosition[CI_TR] = dNewTR;
m_dCurCCUPosition[CI_ETC] = dNewETC;
} //AppendCCUPoint
////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC memDC;
CBitmap memBitmap;
CBitmap* oldBitmap; // bitmap originally found in CMemDC
// no real plotting work is performed here,
// just putting the existing bitmaps on the client
// to avoid flicker, establish a memory dc, draw to it
// and then BitBlt it to the client
memDC.CreateCompatibleDC(&dc);
memBitmap.CreateCompatibleBitmap(&dc, m_nClientWidth, m_nClientHeight);
oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap);
if (memDC.GetSafeHdc() != NULL)
{
// first drop the grid on the memory dc
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &m_dcGrid, 0, 0, SRCCOPY);
// now add the plot on top as a "pattern" via SRCPAINT.
// works well with dark background and a light plot
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &m_dcPlot, 0, 0, SRCPAINT); //SRCPAINT
//CCU
if(m_bCountryCode)
{
for(int i = 0 ; i < CI_MAX ; ++i)
memDC.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &m_dcCCUPlot[i], 0, 0, SRCPAINT);
}
// finally send the result to the display
dc.BitBlt(0, 0, m_nClientWidth, m_nClientHeight, &memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(oldBitmap);
} // OnPaint
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::DrawPoint()
{
TimeCountDraw();
return ;
// this does the work of "scrolling" the plot to the left
// and appending a new data point all of the plotting is
// directed to the memory based bitmap associated with m_dcPlot
// the will subsequently be BitBlt'd to the client in OnPaint
int currX, prevX, currY, prevY;
int currCCUX[CI_MAX], prevCCUX[CI_MAX], currCCUY[CI_MAX], prevCCUY[CI_MAX];
CPen *oldPen;
CPen *oldCCUPen[CI_MAX];
CRect rectCleanUp;
if (m_dcPlot.GetSafeHdc() != NULL)
{
m_dcPlot.BitBlt(m_rectPlot.left, m_rectPlot.top+1, m_nPlotWidth, m_nPlotHeight, &m_dcPlot, m_rectPlot.left+m_nShiftPixels, m_rectPlot.top+1, SRCCOPY);
rectCleanUp = m_rectPlot;
rectCleanUp.left = rectCleanUp.right - m_nShiftPixels;
m_dcPlot.FillRect(rectCleanUp, &m_brushBack);
// draw the next line segement
// grab the plotting pen
// oldPen = m_dcPlot.SelectObject(&m_penPlot);
// move to the previous point
prevX = m_rectPlot.right - m_nPlotShiftPixels;
prevY = m_rectPlot.bottom - (long)((m_dPreviousPosition - m_dLowerLimit) * m_dVerticalFactor);
m_dcPlot.MoveTo (prevX, prevY);
// draw to the current point
currX = m_rectPlot.right-m_nHalfShiftPixels;
currY = m_rectPlot.bottom - (long)((m_dCurrentPosition - m_dLowerLimit) * m_dVerticalFactor);
m_dcPlot.LineTo (currX, currY);
// restore the pen
m_dcPlot.SelectObject(oldPen);
// if the data leaks over the upper or lower plot boundaries
// fill the upper and lower leakage with the background
// this will facilitate clipping on an as needed basis
// as opposed to always calling IntersectClipRect
if ((prevY <= m_rectPlot.top) || (currY <= m_rectPlot.top))
m_dcPlot.FillRect(CRect(prevX, m_rectClient.top, currX+1, m_rectPlot.top+1), &m_brushBack);
if ((prevY >= m_rectPlot.bottom) || (currY >= m_rectPlot.bottom))
m_dcPlot.FillRect(CRect(prevX, m_rectPlot.bottom+1, currX+1, m_rectClient.bottom+1), &m_brushBack);
// store the current point for connection to the next point
m_dPreviousPosition = m_dCurrentPosition;
if(m_bCountryCode)
{
for(int i = 0 ; i < CI_MAX ; ++i)
{
m_dcCCUPlot[i].BitBlt(m_rectPlot.left, m_rectPlot.top+1, m_nPlotWidth, m_nPlotHeight, &m_dcCCUPlot[i], m_rectPlot.left+m_nShiftPixels, m_rectPlot.top+1, SRCCOPY);
if(m_dcCCUPlot[i].GetSafeHdc() != NULL)
{
//grab the plotting pen
oldCCUPen[i] = m_dcCCUPlot[i].SelectObject(&m_CCUpen[i]);
//previous point
prevCCUX[i] = m_rectPlot.right - m_nPlotShiftPixels;
prevCCUY[i] = m_rectPlot.bottom - (long)((m_dPreCCUPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
m_dcCCUPlot[i].MoveTo(prevCCUX[i], prevCCUY[i]);
//current point
currCCUX[i] = m_rectPlot.right-m_nHalfShiftPixels;
currCCUY[i] = m_rectPlot.bottom - (long)((m_dCurCCUPosition[i] - m_dLowerLimit) * m_dVerticalFactor);
m_dcCCUPlot[i].LineTo (currCCUX[i], currCCUY[i]);
//restore the pen
m_dcCCUPlot[i].SelectObject(oldCCUPen[i]);
if ((prevCCUY[i] <= m_rectPlot.top) || (currCCUY[i] <= m_rectPlot.top))
m_dcCCUPlot[i].FillRect(CRect(prevCCUX[i], m_rectClient.top, currCCUX[i]+1, m_rectPlot.top+1), &m_brushBack);
if ((prevCCUY[i] >= m_rectPlot.bottom) || (currCCUY[i] >= m_rectPlot.bottom))
m_dcCCUPlot[i].FillRect(CRect(prevCCUX[i], m_rectPlot.bottom+1, currCCUX[i]+1, m_rectClient.bottom+1), &m_brushBack);
// store the current point for connection to the next point
m_dPreCCUPosition[i] = m_dCurCCUPosition[i];
}
}
}
}
} // end DrawPoint
void COScopeTimeCtrl::DrawPoint(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecound, bool bCCU, double dNewPoint)
{
if (m_dcPlot.GetSafeHdc() != NULL)
{
CRect rectCleanUp = m_rectPlot;
//시간에 따른 포인트 위치 수정
float fPosTerm = (m_rectPlot.right - m_rectPlot.left)/24.0;
rectCleanUp.left = m_rectPlot.left + (fPosTerm*m_stPrevDateTime.wHour + (fPosTerm * m_stPrevDateTime.wMinute /60));
rectCleanUp.right = m_rectPlot.left + (fPosTerm*iHour + (fPosTerm * iMinute /60));
rectCleanUp.top = m_rectPlot.bottom - (long)((m_dPreviousPosition - m_dLowerLimit) * m_dVerticalFactor);
rectCleanUp.bottom = m_rectPlot.bottom - (long)((m_dCurrentPosition - m_dLowerLimit) * m_dVerticalFactor);
if(false ==((rectCleanUp.left == rectCleanUp.right) && (rectCleanUp.top == rectCleanUp.bottom)))
{
// m_dcPlot.FillRect(rectCleanUp, &m_brushBack);
// grab the plotting pen
CPen *oldPen = m_dcPlot.SelectObject(&m_penPlot);
m_dcPlot.MoveTo (rectCleanUp.left, rectCleanUp.top);
m_dcPlot.LineTo (rectCleanUp.right, rectCleanUp.bottom);
DateSetting(iYear, iMonth, iDay, m_stPrevDateTime.wDayOfWeek, iHour, iMinute, iSecound, m_stPrevDateTime.wMilliseconds);
m_dPreviousPosition = m_dCurrentPosition;
m_dcPlot.SelectObject(oldPen);
}
}
m_bGraph = true;
}
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
// NOTE: OnSize automatically gets called during the setup of the control
GetClientRect(m_rectClient);
// set some member variables to avoid multiple function calls
m_nClientHeight = m_rectClient.Height();
m_nClientWidth = m_rectClient.Width();
// the "left" coordinate and "width" will be modified in
// InvalidateCtrl to be based on the width of the y axis scaling
m_rectPlot.left = 5;
m_rectPlot.top = 5;
m_rectPlot.right = m_rectClient.right-10;
m_rectPlot.bottom = m_rectClient.bottom-20;
// set some member variables to avoid multiple function calls
m_nPlotHeight = m_rectPlot.Height();
m_nPlotWidth = m_rectPlot.Width();
// set the scaling factor for now, this can be adjusted
// in the SetRange functions
m_dVerticalFactor = (double)m_nPlotHeight / m_dRange;
} // OnSize
/////////////////////////////////////////////////////////////////////////////
void COScopeTimeCtrl::Reset()
{
m_dPreviousPosition = 0;
m_dCurrentPosition = 0;
InvalidateCtrl();
}
int COScopeTimeCtrl::GetWidth()
{
int nWidth = m_rectPlot.right - m_rectPlot.left;
return nWidth;
}
BOOL COScopeTimeCtrl::PreTranslateMessage(MSG* pMsg)
{
m_toolTip.RelayEvent(pMsg);
return CWnd::PreTranslateMessage(pMsg);
}
int COScopeTimeCtrl::GetRightPixel()
{
return m_rectPlot.right;
}
int COScopeTimeCtrl::GetLeftPixel()
{
return m_rectPlot.left;
}
// 초기화
void COScopeTimeCtrl::Init()
{
m_dPreviousPosition = 0;
m_dCurrentPosition = 0;
InvalidateCtrl();
}
// 인원수
void COScopeTimeCtrl::CountSetting()
{
CString strTemp;
// y max
m_dcGrid.SetTextColor (m_crGridColor);
m_dcGrid.SetTextAlign (TA_RIGHT|TA_TOP);
strTemp.Format (_T("%d"), (int)m_dUpperLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.top, strTemp);
// y min
m_dcGrid.SetTextAlign (TA_RIGHT|TA_BASELINE);
strTemp.Format (_T("%d"), (int)m_dLowerLimit);
m_dcGrid.TextOut (m_rectPlot.left-4, m_rectPlot.bottom, strTemp);
}
// 밑에 시간
void COScopeTimeCtrl::TimeSetting()
{
float fPosTerm = (m_rectPlot.right - m_rectPlot.left)/24.0;
CString strTemp;
for(int iHour = m_dLowerXLimit; iHour <= m_dUpperYLimit; iHour+=2)
{
strTemp.Format (_T("%d"), (int)iHour);
m_dcGrid.TextOut (m_rectPlot.left + 4 + (fPosTerm*iHour), m_rectPlot.bottom+17, strTemp);
}
}
void COScopeTimeCtrl::TimeCountDraw()
{
if(false == m_bGraph)
{
return ;
}
if (m_dcPlot.GetSafeHdc() != NULL)
{
//시간에 따른 포인트 위치 수정
SYSTEMTIME sysTime;
GetLocalTime(&sysTime);
if(m_day != sysTime.wDay)
{
// 그래프를 초기화한다. 초기화 루틴을 시작한다.
Init();
}
CRect rectCleanUp = m_rectPlot;
float fPosTerm = (m_rectPlot.right - m_rectPlot.left)/24.0;
rectCleanUp.left = m_rectPlot.left + (fPosTerm*m_stPrevDateTime.wHour + (fPosTerm * m_stPrevDateTime.wMinute /60));
rectCleanUp.right = m_rectPlot.left + (fPosTerm*sysTime.wHour + (fPosTerm * sysTime.wMinute /60));
rectCleanUp.top = m_rectPlot.bottom - (long)((m_dPreviousPosition - m_dLowerLimit) * m_dVerticalFactor);
rectCleanUp.bottom = m_rectPlot.bottom - (long)((m_dCurrentPosition - m_dLowerLimit) * m_dVerticalFactor);
if(false ==((rectCleanUp.left == rectCleanUp.right) && (rectCleanUp.top == rectCleanUp.bottom)))
{
// m_dcPlot.BitBlt(m_rectPlot.left, m_rectPlot.top+1, m_nPlotWidth, m_nPlotHeight, &m_dcPlot, m_rectPlot.left+m_nShiftPixels, m_rectPlot.top+1, SRCCOPY);
// m_dcPlot.FillRect(rectCleanUp, &m_brushBack);
// grab the plotting pen
CPen *oldPen = m_dcPlot.SelectObject(&m_penPlot);
m_dcPlot.MoveTo (rectCleanUp.left, rectCleanUp.top);
m_dcPlot.LineTo (rectCleanUp.right, rectCleanUp.bottom);
DateSetting(sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wDayOfWeek, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds);
m_dPreviousPosition = m_dCurrentPosition;
m_dcPlot.SelectObject(oldPen);
}
m_day = sysTime.wDay;
}
}
@@ -0,0 +1,129 @@
// OScopeTimeCtrl.h : header file
//
#pragma once
/////////////////////////////////////////////////////////////////////////////
// COScopeTimeCtrl window
class COScopeTimeCtrl : public CWnd
{
public:
COScopeTimeCtrl();
virtual ~COScopeTimeCtrl();
// Attributes
public:
void InitDate();
void DateSetting(int iYear, int iMonth, int iDay, int iDayOfWeek, int iHour, int iMinute, int iSecond, int iMilliseconds);
double AppendPoint(bool bCCU, double dNewPoint);
void AppendDateTimePoint(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, bool bCCU, double dNewPoint);
void AppendCCUPoint( double dNewGB,double dNewDE,double dNewFR,double dNewIT,double dNewPL,double dNewTR, double dNewETC);
void SetToolTip(int x, int y, CString text);
void SetRange(bool b, double dLower, double dUpper, int nDecimalPlaces=1);
void SetDay(int iDay);
void SetXUnits(CString string);
void SetYUnits(CString string);
void SetGridColor(COLORREF color);
void SetPlotColor(COLORREF color);
void SetBackgroundColor(COLORREF color);
void InitToolTip();
void RefreshRange();
void InvalidateCtrl();
void InvalidateXUnits();
void DrawPoint();
void DrawPoint(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond, bool bCCU, double dNewPoint);
void Reset();
void Init();
// Operations
public:
int GetWidth();
int GetRightPixel();
int GetLeftPixel();
BOOL PreTranslateMessage(MSG* pMsg);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(COScopeTimeCtrl)
public:
virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID=NULL);
//}}AFX_VIRTUAL
// Implementation
public:
int m_nShiftPixels; // amount to shift with each new point
int m_nYDecimals;
CString m_strXUnitsString;
CString m_strYUnitsString;
COLORREF m_crBackColor; // background color
COLORREF m_crGridColor; // grid color
COLORREF m_crPlotColor; // data color
COLORREF m_crCCUColor[CI_MAX];
double m_dCurrentPosition; // current position
double m_dPreviousPosition; // previous position
//CCU Point
double m_dCurCCUPosition[CI_MAX]; // current position
double m_dPreCCUPosition[CI_MAX]; // previous position
bool m_bGraph;
SYSTEMTIME m_stPrevDateTime;
bool m_bCountryCode;
private:
void CountSetting();
void TimeSetting();
void TimeCountDraw();
// Generated message map functions
protected:
//{{AFX_MSG(COScopeTimeCtrl)
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
int m_nHalfShiftPixels;
int m_nPlotShiftPixels;
int m_nClientHeight;
int m_nClientWidth;
int m_nPlotHeight;
int m_nPlotWidth;
double m_dLowerLimit; // lower bounds
double m_dUpperLimit; // upper bounds
double m_dLowerXLimit; // lower bounds
double m_dUpperYLimit; // upper bounds
double m_dRange;
double m_dVerticalFactor;
int m_day;
CRect m_rectClient;
CRect m_rectPlot;
CPen m_penPlot;
CPen m_CCUpen[CI_MAX];
CBrush m_brushBack;
CDC m_dcGrid;
CDC m_dcPlot;
CDC m_dcCCUPlot[CI_MAX];
CBitmap *m_pbitmapOldGrid;
CBitmap *m_pbitmapOldPlot;
CBitmap *m_pbitmapCCUOldPlot[CI_MAX];
CBitmap m_bitmapGrid;
CBitmap m_bitmapPlot;
CBitmap m_bitmapCCUPlot[CI_MAX];
CToolTipCtrl m_toolTip;
};
@@ -0,0 +1,361 @@
// OperatorDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "ZoneDialog.h"
#include "AnnounceDlg.h"
#include "ItemDlg.h"
#include "EventDlg.h"
#include "CSDialog.h"
#include "BlockDlg.h"
#include "LogDlg.h"
#include "OperatorDlg.h"
#include "NoticeDlg.h"
#include "SecretShopDlg.h"
#include "CompensationDlg.h"
#include "afxdialogex.h"
// COperatorDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(COperatorDlg, CDialogEx)
COperatorDlg::COperatorDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(COperatorDlg::IDD, pParent)
, m_parent(NULL)
, m_announceDlg(NULL)
, m_itemDlg(NULL)
, m_eventDlg(NULL)
, m_csDlg(NULL)
, m_blockDlg(NULL)
, m_logDlg(NULL)
, m_tablIndex(0)
, m_NoticeDlg( NULL )
, m_SecretShopDlg(NULL)
, m_CompensationDlg(NULL)
{
}
COperatorDlg::~COperatorDlg()
{
delete m_announceDlg;
delete m_itemDlg;
delete m_eventDlg;
delete m_csDlg;
delete m_blockDlg;
delete m_logDlg;
delete m_NoticeDlg;
delete m_SecretShopDlg;
delete m_CompensationDlg;
}
void COperatorDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB_OPERATOR, m_operatorTab);
}
BEGIN_MESSAGE_MAP(COperatorDlg, CDialogEx)
ON_WM_SHOWWINDOW()
END_MESSAGE_MAP()
// COperatorDlg 메시지 처리기입니다.
void COperatorDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
CWnd* pWnd = GetDesktopWindow();
CenterWindow(pWnd);
CreatePanel();
m_announceDlg->ShowWindow(SW_SHOW);
}
void COperatorDlg::CreatePanel()
{
CRect rc;
m_operatorTab.GetClientRect(rc);
TC_ITEM item;
item.mask = TCIF_TEXT;
item.pszText = _T("Common");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Item");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Event");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("CS");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Block");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Notice");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("SecretShop");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Compensation");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
m_announceDlg = new CAnnounceDlg;
m_announceDlg->Create(IDD_ANNOUNCE_DIALOG, &m_operatorTab);
m_announceDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_announceDlg->Startup(m_parent);
m_itemDlg = new CItemDlg;
m_itemDlg->Create(IDD_ITEM_DIALOG, &m_operatorTab);
m_itemDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_itemDlg->Startup(m_parent);
m_eventDlg = new CEventDlg;
m_eventDlg->Create(IDD_EVENT_DIALOG, &m_operatorTab);
m_eventDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_eventDlg->Startup(m_parent);
m_csDlg = new CCSDialog;
m_csDlg->Create(IDD_CS_DIALOG, &m_operatorTab);
m_csDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_csDlg->Startup(m_parent);
m_blockDlg = new CBlockDlg;
m_blockDlg->Create( IDD_BLOCK_DIALOG, &m_operatorTab );
m_blockDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_blockDlg->Startup(m_parent);
m_logDlg = new CLogDlg;
m_logDlg->Create( IDD_LOG_DIALOG, &m_operatorTab );
m_logDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_logDlg->Startup(m_parent);
m_NoticeDlg = new CNoticeDlg;
m_NoticeDlg->Create( IDD_NOTICEDLG, &m_operatorTab );
m_NoticeDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_NoticeDlg->Startup(m_parent);
m_SecretShopDlg = new CSecretShopDlg;
m_SecretShopDlg->Create(IDD_DIALOG_SECRETSHOP, &m_operatorTab);
m_SecretShopDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_SecretShopDlg->Startup(m_parent);
m_CompensationDlg = new CCompensationDlg;
m_CompensationDlg->Create(IDD_COMPENSATION_DIALOG, &m_operatorTab);
m_CompensationDlg->MoveWindow(rc.left+10, rc.top+30, rc.Width()-30, rc.Height()-35);
m_CompensationDlg->Startup(m_parent);
}
void COperatorDlg::ShowTab(int index)
{
if( GetZone()->IsAdministrator() )
{
switch(index)
{
case 0:
m_announceDlg->ShowWindow(SW_SHOW);
break;
case 1:
m_itemDlg->ShowWindow(SW_SHOW);
break;
case 2:
m_eventDlg->ShowWindow(SW_SHOW);
break;
case 3:
m_csDlg->ShowWindow(SW_SHOW);
break;
case 4:
m_blockDlg->ShowWindow(SW_SHOW);
break;
case 5:
m_logDlg->ShowWindow(SW_SHOW);
break;
case 6:
m_NoticeDlg->ShowWindow(SW_SHOW);
break;
case 7:
m_SecretShopDlg->ShowWindow(SW_SHOW);
break;
case 8:
m_CompensationDlg->ShowWindow(SW_SHOW);
break;
}
}
else if( GetZone()->IsOperator() )
{
switch(index)
{
case 0:
m_announceDlg->ShowWindow(SW_SHOW);
break;
case 1:
m_blockDlg->ShowWindow(SW_SHOW);
break;
case 2:
m_logDlg->ShowWindow(SW_SHOW);
break;
case 3:
m_NoticeDlg->ShowWindow(SW_SHOW);
break;
}
}
}
void COperatorDlg::HideTab(int index)
{
if( GetZone()->IsAdministrator() )
{
switch(index)
{
case 0:
m_announceDlg->ShowWindow(SW_HIDE);
break;
case 1:
m_itemDlg->ShowWindow(SW_HIDE);
break;
case 2:
m_eventDlg->ShowWindow(SW_HIDE);
break;
case 3:
m_csDlg->ShowWindow(SW_HIDE);
break;
case 4:
m_blockDlg->ShowWindow(SW_HIDE);
break;
case 5:
m_logDlg->ShowWindow(SW_HIDE);
break;
case 6:
m_NoticeDlg->ShowWindow(SW_HIDE);
break;
case 7:
m_SecretShopDlg->ShowWindow(SW_HIDE);
break;
case 8:
m_CompensationDlg->ShowWindow(SW_HIDE);
break;
}
}
else if( GetZone()->IsOperator() )
{
switch(index)
{
case 0:
m_announceDlg->ShowWindow(SW_HIDE);
break;
case 1:
m_blockDlg->ShowWindow(SW_HIDE);
break;
case 2:
m_logDlg->ShowWindow(SW_HIDE);
break;
case 3:
m_NoticeDlg->ShowWindow(SW_HIDE);
break;
}
}
}
void COperatorDlg::ShowLogTab()
{
// logDlog는 무조건 제일 뒤에 있도록 설정한다
HideTab( m_tablIndex );
m_tablIndex = m_operatorTab.GetItemCount() - 1;
ShowTab( m_tablIndex );
m_operatorTab.SetCurSel( m_tablIndex );
m_logDlg->SetFocus();
}
void COperatorDlg::WriteLogDlg( CString text )
{
if( !m_logDlg ) return;
m_logDlg->InsertLogText( text );
}
BOOL COperatorDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
LPNMHDR lpnmhdr = (LPNMHDR) lParam;
if(lpnmhdr->code==TCN_SELCHANGE)
{
HideTab(m_tablIndex);
m_tablIndex = m_operatorTab.GetCurSel();
ShowTab(m_tablIndex);
}
return CDialogEx::OnNotify(wParam, lParam, pResult);
}
void COperatorDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
if(bShow)
{
m_operatorTab.DeleteAllItems();
if(GetZone()->IsAdministrator())
{
TC_ITEM item;
item.mask = TCIF_TEXT;
item.pszText = _T("Common");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Item");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Event");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("CS");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Block");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Log");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Notice");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("SecretShop");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Compensation");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
}
else if(GetZone()->IsOperator())
{
TC_ITEM item;
item.mask = TCIF_TEXT;
item.pszText = _T("Common");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Block");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Log");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
item.pszText = _T("Notice");
m_operatorTab.InsertItem(m_operatorTab.GetItemCount(), &item);
}
}
CDialogEx::OnShowWindow(bShow, nStatus);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
}
@@ -0,0 +1,72 @@
#pragma once
#include "afxcmn.h"
class CZoneDialog;
class CAnnounceDlg;
class CItemDlg;
class CEventDlg;
class CCSDlg;
class CBlockDlg;
class CLogDlg;
class CNoticeDlg;
class CSecretShopDlg;
class CCompensationDlg;
// COperatorDlg 대화 상자입니다.
class COperatorDlg : public CDialogEx
{
DECLARE_DYNAMIC(COperatorDlg)
public:
COperatorDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~COperatorDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_OPERATOR_DIALOG };
public:
void Startup(CZoneDialog* parent);
void CreatePanel();
CCSDialog* GetCSDlg() { return m_csDlg; }
protected:
void ShowTab(int index);
void HideTab(int index);
CZoneDialog* GetZone() { return m_parent; }
public:
void ShowLogTab();
void WriteLogDlg( CString text );
protected:
CZoneDialog* m_parent;
CAnnounceDlg* m_announceDlg;
CItemDlg* m_itemDlg;
CEventDlg* m_eventDlg;
CCSDialog* m_csDlg;
CBlockDlg* m_blockDlg;
CLogDlg* m_logDlg;
CNoticeDlg * m_NoticeDlg;
CSecretShopDlg* m_SecretShopDlg;
CCompensationDlg* m_CompensationDlg;
int m_tablIndex;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CTabCtrl m_operatorTab;
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnTcnSelchangeTabOperator(NMHDR *pNMHDR, LRESULT *pResult);
};
@@ -0,0 +1,160 @@
// PanelDialog.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "PanelDialog.h"
#include "WinMessage.h"
#include "Define.h"
#include "afxdialogex.h"
// CPanelDialog 대화 상자입니다.
IMPLEMENT_DYNAMIC(CPanelDialog, CDialogEx)
CPanelDialog::CPanelDialog(CWnd* pParent /*=NULL*/)
: CDialogEx(CPanelDialog::IDD, pParent), m_maxValue(0), m_current(0), m_serverId(0), m_serverPort(0), m_blockState(0), m_serverState(0)
{
}
CPanelDialog::~CPanelDialog()
{
}
void CPanelDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TITLE_STATIC, m_title);
}
BEGIN_MESSAGE_MAP(CPanelDialog, CDialogEx)
ON_WM_RBUTTONUP()
END_MESSAGE_MAP()
// CPanelDialog 메시지 처리기입니다.
BOOL CPanelDialog::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
CreatePopup();
CRect rc;
GetDlgItem(IDC_STATIC_MBAR)->GetWindowRect(rc);
ScreenToClient(rc);
m_graph.Create(WS_VISIBLE | WS_CHILD, rc, this);
m_graph.SetRange( 0, 100 );
m_graph.SetPlotColor(RGB(128, 128, 128), FALSE);
m_graph.SetBackgroundColor(RGB(128, 128, 128), TRUE);
m_graph.InitToolTip();
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CPanelDialog::Startup(int serverId, CString title, CString serverIP, int serverPort, int blockState, int maxUser)
{
m_title.SetWindowText(title);
m_graph.SetRange(0, maxUser);
m_graph.DrawGraph(0);
m_serverId = serverId;
m_serverName = title;
m_serverIP = serverIP;
m_serverPort = serverPort;
m_blockState = blockState;
CString tooltip;
tooltip.Format(_T("%s(%s:%d) - %d/%d"), m_serverName, m_serverIP, m_serverPort, m_current, m_maxValue);
m_graph.SetToolTip(tooltip);
UpdatePopup(m_blockState);
}
void CPanelDialog::UpdateBegin()
{
m_serverState = ESOCKET::LS_REQSERVERSTATE;
}
void CPanelDialog::UpdateEnd()
{
switch(m_serverState)
{
case ESOCKET::LS_DISCONNECTED :
break;
case ESOCKET::LS_RESPSERVERSTATE :
m_blockState = 0;
m_graph.SetPlotColor(RGB(128, 255, 128), FALSE);
m_graph.SetBackgroundColor(RGB(0, 0, 0), TRUE);
break;
case ESOCKET::LS_ZOMBIESERVERSTATE :
m_blockState = 0;
m_graph.SetPlotColor(RGB(255, 0, 0), FALSE);
m_graph.SetBackgroundColor(RGB(0, 0, 0), TRUE);
break;
case ESOCKET::LS_BLOCKED :
m_blockState = 1;
m_graph.SetPlotColor(RGB(128, 128, 128), FALSE);
m_graph.SetBackgroundColor(RGB(0, 0, 0), TRUE);
break;
}
}
void CPanelDialog::Update(int currentUser, int sendCount, int serverState)
{
m_current = currentUser;
m_serverState = serverState;
if(m_maxValue < m_current)
{
m_maxValue = m_current;
}
CString tooltip;
tooltip.Format(_T("%s(%s:%d) - %d/%d"), m_serverName, m_serverIP, m_serverPort, m_current, m_maxValue);
m_graph.SetToolTip(tooltip);
m_graph.DrawGraph(currentUser);
}
void CPanelDialog::CreatePopup()
{
}
void CPanelDialog::UpdatePopup(int blockState)
{
}
void CPanelDialog::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
CPoint pos;
GetCursorPos(&pos);
m_menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pos.x, pos.y, this);
CDialogEx::OnRButtonDown(nFlags, point);
}
BOOL CPanelDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
return CDialogEx::OnCommand(wParam, lParam);
}
BOOL CPanelDialog::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
@@ -0,0 +1,55 @@
#pragma once
#include "afxwin.h"
#include "afxcmn.h"
#include "ProcessCtrl.h"
// CPanelDialog 대화 상자입니다.
class CPanelDialog : public CDialogEx
{
DECLARE_DYNAMIC(CPanelDialog)
public:
CPanelDialog(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CPanelDialog();
// 대화 상자 데이터입니다.
enum { IDD = IDD_PANEL_DIALOG };
public:
void Startup(int serverId, CString title, CString serverIP, int serverPort, int blockState, int maxUser);
void UpdateBegin();
void UpdateEnd();
void Update(int currentUser, int sendCount, int serverState);
void CreatePopup();
void UpdatePopup(int blockState);
int GetServerID() { return m_serverId; }
protected:
int m_maxValue;
int m_current;
CString m_serverName;
CString m_serverIP;
int m_serverId;
int m_serverPort;
int m_blockState;
int m_serverState;
CProcessCtrl m_graph;
CMenu m_menu;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CStatic m_title;
virtual BOOL OnInitDialog();
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
virtual BOOL PreTranslateMessage(MSG* pMsg);
};
@@ -0,0 +1,274 @@
// CProcessCtrl.cpp: implementation of the CProcessCtrl class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ProcessCtrl.h"
CProcessCtrl::CProcessCtrl() : m_vertical(TRUE)
{
SetRange( 0, 100 );
SetBackgroundColor(RGB(0, 0, 0));
//SetPlotColor(RGB(255, 255, 0));
SetPlotColor(RGB(128, 255, 128));
SetGridColor(RGB(128, 255, 128));
SetAlertColor(RGB(255, 64, 64));
m_pbitmapOldGrid = NULL;
m_pbitmapOldPlot = NULL;
}
CProcessCtrl::~CProcessCtrl()
{
}
BEGIN_MESSAGE_MAP(CProcessCtrl, CWnd)
//{{AFX_MSG_MAP(CProcessCtrl)
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CProcessCtrl::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
BOOL result;
static CString className = AfxRegisterWndClass( CS_HREDRAW | CS_VREDRAW );
result = CWnd::CreateEx(
WS_EX_CLIENTEDGE | WS_EX_STATICEDGE,
className, NULL, dwStyle,
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
pParentWnd->GetSafeHwnd(),
(HMENU)nID );
if( result != 0 ) InvalidateCtrl();
return result;
}
void CProcessCtrl::SetRange( UINT low, UINT high )
{
m_lowLevel = low;
m_highLevel = high;
m_level = low;
}
void CProcessCtrl::SetGridColor(COLORREF color, BOOL redraw)
{
m_crGridColor = color;
m_penGrid.DeleteObject();
m_penGrid.CreatePen(PS_SOLID, 0, m_crGridColor);
if(redraw)
InvalidateCtrl();
}
void CProcessCtrl::SetAlertColor(COLORREF color, BOOL redraw)
{
m_crAlertColor = color;
m_penAlert.DeleteObject();
m_penAlert.CreatePen(PS_SOLID, 0, m_crGridColor);
if(redraw)
InvalidateCtrl();
}
void CProcessCtrl::SetPlotColor(COLORREF color, BOOL redraw)
{
m_crPlotColor = color;
m_penPlot.DeleteObject();
m_penPlot.CreatePen(PS_SOLID, 0, m_crPlotColor);
if(redraw)
InvalidateCtrl();
}
void CProcessCtrl::SetBackgroundColor(COLORREF color, BOOL redraw)
{
m_crBackColor = color;
m_brushBack.DeleteObject();
m_brushBack.CreateSolidBrush(m_crBackColor);
if(redraw)
InvalidateCtrl();
}
void CProcessCtrl::GetRange(UINT& low, UINT& high)
{
low = m_lowLevel;
high = m_highLevel;
}
void CProcessCtrl::DrawGraph( UINT level )
{
m_level = (UINT)(level * 100.0 / m_highLevel);
if(m_level > 100)
m_level = 100;
InvalidateCtrl();
}
void CProcessCtrl::InvalidateCtrl()
{
CClientDC dc(this);
if (m_dcGrid.GetSafeHdc() == NULL)
{
m_dcGrid.CreateCompatibleDC(&dc);
m_bitmapGrid.CreateCompatibleBitmap(&dc, m_clientWidth, m_clientHeight);
m_pbitmapOldGrid = m_dcGrid.SelectObject(&m_bitmapGrid);
}
m_dcGrid.SetBkColor(m_crBackColor);
m_dcGrid.FillRect(m_rectClient, &m_brushBack);
m_plotHeight = m_rectPlot.Height();
m_plotWidth = m_rectPlot.Width();
// draw the plot rectangle
CPen *oldPen = m_dcGrid.SelectObject (&m_penPlot);
// 테두리
m_dcGrid.MoveTo (m_rectPlot.left, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right+1, m_rectPlot.top);
m_dcGrid.LineTo (m_rectPlot.right+1, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left, m_rectPlot.bottom+1);
m_dcGrid.LineTo (m_rectPlot.left, m_rectPlot.top);
int middle, range;
if(IsVertical())
{
middle = (m_rectPlot.right + m_rectPlot.left) / 2;
range = (m_rectPlot.bottom - m_rectPlot.top - 1) * m_level / 100;
}
else
{
middle = (m_rectPlot.top + m_rectPlot.bottom) / 2 + 1;
range = (m_rectPlot.right - m_rectPlot.left - 1) * m_level / 100;
}
m_dcGrid.SelectObject (oldPen);
// 그리드
if( m_level >= 90)
{
oldPen = m_dcGrid.SelectObject (&m_penAlert);
}
else
{
oldPen = m_dcGrid.SelectObject (&m_penGrid);
}
for( int i = 0; i < range; i+=2 )
{
if(IsVertical())
{
int height = m_rectPlot.bottom - i - 1;
m_dcGrid.MoveTo( m_rectPlot.left+2, height );
m_dcGrid.LineTo( middle, height );
m_dcGrid.MoveTo( middle+1, height );
m_dcGrid.LineTo( m_rectPlot.right, height );
}
else
{
int width = m_rectPlot.left + i + 2;
m_dcGrid.MoveTo( width, m_rectPlot.top +1 );
m_dcGrid.LineTo( width, m_rectPlot.bottom +1 );
}
}
m_dcGrid.SelectObject (oldPen);
//if (m_dcPlot.GetSafeHdc() == NULL)
//{
// m_dcPlot.CreateCompatibleDC(&dc);
// m_bitmapPlot.CreateCompatibleBitmap(&dc, m_clientWidth, m_clientHeight);
// m_pbitmapOldPlot = m_dcPlot.SelectObject(&m_bitmapPlot);
//}
//m_dcPlot.SetBkColor (m_crBackColor);
//m_dcPlot.FillRect(m_rectClient, &m_brushBack);
InvalidateRect(m_rectClient);
}
void CProcessCtrl::OnPaint()
{
CPaintDC dc(this);
CDC memDC;
CBitmap memBitmap;
CBitmap* oldBitmap;
memDC.CreateCompatibleDC(&dc);
memBitmap.CreateCompatibleBitmap(&dc, m_clientWidth, m_clientHeight);
oldBitmap = (CBitmap *)memDC.SelectObject(&memBitmap);
if (memDC.GetSafeHdc() != NULL)
{
memDC.BitBlt(0, 0, m_clientWidth, m_clientHeight, &m_dcGrid, 0, 0, SRCCOPY);
memDC.BitBlt(0, 0, m_clientWidth, m_clientHeight, &m_dcPlot, 0, 0, SRCPAINT);
dc.BitBlt(0, 0, m_clientWidth, m_clientHeight, &memDC, 0, 0, SRCCOPY);
}
memDC.SelectObject(oldBitmap);
}
void CProcessCtrl::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
GetClientRect(m_rectClient);
m_clientHeight = m_rectClient.Height();
m_clientWidth = m_rectClient.Width();
m_rectPlot.left = 2;
m_rectPlot.top = 2;
m_rectPlot.right = m_rectClient.right - 5;
m_rectPlot.bottom = m_rectClient.bottom - 3;
m_plotHeight = m_rectPlot.Height();
m_plotWidth = m_rectPlot.Width();
}
void CProcessCtrl::InitToolTip()
{
if (m_toolTip.m_hWnd == NULL)
{
m_toolTip.Create(this);
m_toolTip.Activate(FALSE);
m_toolTip.SetDelayTime(TTDT_AUTOPOP, 3000);
}
}
void CProcessCtrl::SetToolTip(CString text)
{
m_toolTip.DelTool(this, 0);
m_toolTip.AddTool(this, text, NULL, 0);
}
BOOL CProcessCtrl::PreTranslateMessage(MSG* pMsg)
{
m_toolTip.RelayEvent(pMsg);
return CWnd::PreTranslateMessage(pMsg);
}
void CProcessCtrl::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
m_toolTip.Activate(TRUE);
CWnd::OnMouseMove(nFlags, point);
}
@@ -0,0 +1,73 @@
#pragma once
class CProcessCtrl : public CWnd
{
public:
CProcessCtrl();
virtual ~CProcessCtrl();
public:
virtual BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID=NULL);
void SetRange(UINT unLow, UINT unHigh);
void SetGridColor(COLORREF color, BOOL redraw = FALSE);
void SetAlertColor(COLORREF color, BOOL redraw = FALSE);
void SetPlotColor(COLORREF color, BOOL redraw = FALSE);
void SetBackgroundColor(COLORREF color, BOOL redraw = FALSE);
void SetVertical(BOOL b) { m_vertical = b; }
void GetRange(UINT& low, UINT& high);
BOOL IsVertical() { return m_vertical; }
void InvalidateCtrl();
void DrawGraph( UINT unLevel );
void InitToolTip();
void SetToolTip(CString text);
// Generated message map functions
protected:
//{{AFX_MSG(COScopeCtrl)
afx_msg void OnPaint();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
BOOL PreTranslateMessage(MSG* pMsg);
private:
BOOL m_vertical;
CRect m_rectClient;
CRect m_rectPlot;
CDC m_dcGrid;
CDC m_dcPlot;
CBitmap *m_pbitmapOldGrid;
CBitmap *m_pbitmapOldPlot;
CBitmap m_bitmapGrid;
CBitmap m_bitmapPlot;
COLORREF m_crBackColor; // background color
COLORREF m_crGridColor; // grid color
COLORREF m_crAlertColor; // alert color
COLORREF m_crPlotColor; // data color
CPen m_penPlot;
CPen m_penGrid;
CPen m_penAlert;
CBrush m_brushBack;
CToolTipCtrl m_toolTip;
int m_clientHeight;
int m_clientWidth;
int m_plotHeight;
int m_plotWidth;
UINT m_lowLevel;
UINT m_highLevel;
UINT m_level;
};
@@ -0,0 +1,100 @@
================================================================================
MFC 라이브러리 : LS_MonitorClient 프로젝트 개요
================================================================================
응용 프로그램 마법사에서 이 LS_MonitorClient 응용 프로그램을
만들었습니다. 이 응용 프로그램은 MFC의 기본 사용법을 보여 줄 뿐만 아니라 응용
프로그램작성을 위한 기본 구조를 제공합니다.
이 파일에는 LS_MonitorClient 응용 프로그램을 구성하는 각 파일에 대한
요약 설명이 포함되어 있습니다.
LS_MonitorClient.vcxproj
응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 주 프로젝트 파일입니다.
파일을 생성한 Visual C++ 버전에 대한 정보와 응용 프로그램 마법사를 사용하여 선택한
플랫폼, 구성 및 프로젝트 기능에 대한 정보가 들어 있습니다.
LS_MonitorClient.vcxproj.filters
응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 필터 파일입니다.
이 파일에는 프로젝트의 파일과 필터 간의 연결 정보가 들어 있습니다. 이러한
연결은 특정 노드에서 유사한 확장명으로 그룹화된 파일을 표시하기 위해
IDE에서 사용됩니다. 예를 들어 ".cpp" 파일은 "소스 파일" 필터와 연결되어
있습니다.
LS_MonitorClient.h
응용 프로그램의 기본 헤더 파일입니다. 여기에는 다른 프로젝트 관련
헤더(Resource.h 포함)가 들어 있고 CLS_MonitorClientApp 응용 프로그램
클래스를 선언합니다.
LS_MonitorClient.cpp
응용 프로그램 클래스 CLS_MonitorClientApp이(가) 들어 있는 기본 응용 프로그램
소스 파일입니다.
LS_MonitorClient.rc
프로그램에서 사용하는 모든 Microsoft Windows 리소스의 목록입니다.
여기에는 RES 하위 디렉터리에 저장된 아이콘, 비트맵 및 커서가
포함됩니다. 이 파일은 Microsoft Visual C++에서 직접
편집할 수 있습니다. 프로젝트 리소스는 1042에 있습니다.
res\LS_MonitorClient.ico
응용 프로그램의 아이콘으로 사용되는 아이콘 파일입니다. 이 아이콘은
주 리소스 파일인 LS_MonitorClient.rc에 의해 포함됩니다.
res\LS_MonitorClient.rc2
이 파일에는 Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스가
들어 있습니다. 리소스 편집기로 편집할 수 없는 모든 리소스는
이 파일에 넣어야 합니다.
/////////////////////////////////////////////////////////////////////////////
응용 프로그램 마법사에서 하나의 대화 상자 클래스가 만들어집니다.
LS_MonitorClientDlg.h, LS_MonitorClientDlg.cpp - 대화 상자
이 파일에는 CLS_MonitorClientDlg 클래스가 들어 있습니다. 이 클래스는
응용 프로그램의 주 대화 상자 동작을 정의합니다. 대화 상자의 템플릿은
Microsoft Visual C++에서 편집할 수 있는 LS_MonitorClient.rc에 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 기능:
ActiveX 컨트롤
응용 프로그램에서 ActiveX 컨트롤을 사용할 수 있도록 지원합니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일:
StdAfx.h, StdAfx.cpp
이 파일은 미리 컴파일된 헤더 파일(PCH)인 LS_MonitorClient.pch와
미리 컴파일된 형식 파일인 StdAfx.obj를 빌드하는 데 사용됩니다.
Resource.h
새 리소스 ID를 정의하는 표준 헤더 파일입니다.
Microsoft Visual C++에서 이 파일을 읽고 업데이트합니다.
LS_MonitorClient.manifest
응용 프로그램 매니페스트 파일은 Windows XP에서 특정 버전의 Side-by-Side
어셈블리에 대한 응용 프로그램 종속성을 설명하는 데 사용됩니다. 로더는 이 정보를
사용하여 어셈블리 캐시에서 적절한 어셈블리를 로드하거나 응용 프로그램에서 전용
어셈블리를 로드합니다. 응용 프로그램 매니페스트는 응용 프로그램 실행 파일과 같은
폴더에 설치된 외부 .manifest 파일로 재배포를 위해 포함되거나 리소스의 형태로
실행 파일에 포함될 수 있습니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사는 "TODO:"를 사용하여 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
응용 프로그램이 공유 DLL에서 MFC를 사용하는 경우 해당 MFC DLL을
재배포해야 합니다. 그리고 응용 프로그램이 운영 체제의 로캘과
다른 언어를 사용하는 경우 해당 지역화된 리소스인 MFC100XXX.DLL을
재배포해야 합니다. 이 두가지 항목에 대한 자세한 내용은
MSDN 설명서의 Visual C++ 응용 프로그램 재배포 항목을
참조하십시오.
/////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,282 @@
// SecretShopDlg.cpp : 구현 파일입니다.
//
#include "stdafx.h"
#include "LS_MonitorClient.h"
#include "SecretShopDlg.h"
#include "ZoneDialog.h"
#include "afxdialogex.h"
// CSecretShopDlg 대화 상자입니다.
IMPLEMENT_DYNAMIC(CSecretShopDlg, CDialogEx)
CSecretShopDlg::CSecretShopDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CSecretShopDlg::IDD, pParent)
{
}
CSecretShopDlg::~CSecretShopDlg()
{
}
void CSecretShopDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST_ITEMCODE, m_itemList);
DDX_Control(pDX, IDC_LIST_ITEMCOUNT, m_itemCount);
DDX_Control(pDX, IDC_EDIT_ITEMCODE, m_editItemCode);
DDX_Control(pDX, IDC_EDIT_ITEMCOUNT, m_editItemCount);
}
BEGIN_MESSAGE_MAP(CSecretShopDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_INFORESET, &CSecretShopDlg::OnBnClickedButtonInforeset)
ON_EN_CHANGE(IDC_EDIT_ITEMCODE, &CSecretShopDlg::OnEnChangeEditItemcode)
ON_EN_CHANGE(IDC_EDIT_ITEMCOUNT, &CSecretShopDlg::OnEnChangeEditItemcount)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_ITEMCODE, &CSecretShopDlg::OnLvnItemchangedListItemcode)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_ITEMCOUNT, &CSecretShopDlg::OnLvnItemchangedListItemcount)
ON_BN_CLICKED(IDC_BUTTON_INSERT, &CSecretShopDlg::OnBnClickedButtonInsert)
END_MESSAGE_MAP()
// CSecretShopDlg 메시지 처리기입니다.
void CSecretShopDlg::Startup(CZoneDialog* parent)
{
m_parent = parent;
ShowWindow(SW_HIDE);
}
void CSecretShopDlg::OnBnClickedButtonInforeset()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
m_itemList.DeleteAllItems();
m_itemCount.DeleteAllItems();
}
void CSecretShopDlg::OnEnChangeEditItemcode()
{
// TODO: RICHEDIT 컨트롤인 경우, 이 컨트롤은
// CDialogEx::OnInitDialog() 함수를 재지정
//하고 마스크에 OR 연산하여 설정된 ENM_CHANGE 플래그를 지정하여 CRichEditCtrl().SetEventMask()를 호출하지 않으면
// 이 알림 메시지를 보내지 않습니다.
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
}
void CSecretShopDlg::OnEnChangeEditItemcount()
{
// TODO: RICHEDIT 컨트롤인 경우, 이 컨트롤은
// CDialogEx::OnInitDialog() 함수를 재지정
//하고 마스크에 OR 연산하여 설정된 ENM_CHANGE 플래그를 지정하여 CRichEditCtrl().SetEventMask()를 호출하지 않으면
// 이 알림 메시지를 보내지 않습니다.
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
}
void CSecretShopDlg::OnLvnItemchangedListItemcode(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
}
void CSecretShopDlg::OnLvnItemchangedListItemcount(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
}
BOOL CSecretShopDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 여기에 추가 초기화 작업을 추가합니다.
m_itemList.DeleteAllItems();
m_itemList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_itemList.InsertColumn(0, _T("Code"), LVCFMT_LEFT, 120);
m_itemCount.DeleteAllItems();
m_itemCount.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT);
m_itemCount.InsertColumn(0, _T("ResetCount"), LVCFMT_LEFT, 180);
return TRUE; // return TRUE unless you set the focus to a control
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
}
void CSecretShopDlg::InsertItemCode(CString itemCode)
{
if( itemCode.GetLength() == 0 )
return;
m_itemList.InsertItem(m_itemList.GetItemCount(), itemCode);
}
void CSecretShopDlg::InsertItemCount(CString itemCount)
{
if( itemCount.GetLength() == 0 )
return;
m_itemCount.InsertItem(m_itemCount.GetItemCount(), itemCount);
}
void CSecretShopDlg::OnDropItemFiles(CString file)
{
m_itemList.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertItemCode(line);
}
}
}
}
void CSecretShopDlg::OnDropItemCountFiles(CString file)
{
m_itemCount.DeleteAllItems();
CStdioFile ff;
if(ff.Open(file, CFile::modeRead))
{
CString line;
while(ff.ReadString(line))
{
if(line.GetLength() > 0)
{
InsertItemCount(line);
}
}
}
}
void CSecretShopDlg::DeleteListItem(CListCtrl& m_List)
{
int index = -1;
POSITION pos = m_List.GetFirstSelectedItemPosition();
while(pos)
{
int index = m_List.GetNextSelectedItem(pos);
m_List.DeleteItem(index);
pos = m_List.GetFirstSelectedItemPosition();
}
}
BOOL CSecretShopDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if(WM_DROPFILES == pMsg->message)
{
if(m_itemList.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropItemFiles( file );
}
}
else if(m_itemCount.GetSafeHwnd() == pMsg->hwnd)
{
UINT dragCount = DragQueryFile((HDROP)pMsg->wParam, 0xFFFFFFFF, NULL, 0);
char file[MAX_PATH];
if( dragCount > 0 )
{
DragQueryFile( (HDROP)pMsg->wParam, 0, file, MAX_PATH );
OnDropItemCountFiles( file );
}
}
}
else if(WM_KEYDOWN == pMsg->message )
{
if(VK_RETURN == pMsg->wParam)
{
if(m_editItemCode.GetSafeHwnd() == pMsg->hwnd)
{
CString itemCode;
m_editItemCode.GetWindowText(itemCode);
m_editItemCode.SetWindowText(_T(""));
InsertItemCode(itemCode);
}
else if(m_editItemCount.GetSafeHwnd() == pMsg->hwnd)
{
CString itemCount;
m_editItemCount.GetWindowText(itemCount);
m_editItemCount.SetWindowText(_T(""));
InsertItemCount(itemCount);
}
return TRUE;
}
else if(VK_DELETE == pMsg->wParam)
{
if(m_itemList.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_itemList.GetSelectedCount();
if(count > 0) //kyg 여기에 루프 추가
{
DeleteListItem(m_itemList);
}
}
else if(m_itemCount.GetSafeHwnd() == pMsg->hwnd)
{
UINT count = m_itemCount.GetSelectedCount();
if(count > 0)
{
DeleteListItem(m_itemCount);
}
}
return TRUE;
}
}
if(RestrictMessage(pMsg))
return FALSE;
return CDialogEx::PreTranslateMessage(pMsg);
}
void CSecretShopDlg::ReqeustCountChange(int itemCode, int itemCount)
{
m_parent->RequestSecretShopCountChange(itemCode, itemCount);
}
void CSecretShopDlg::OnBnClickedButtonInsert()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CString itemCode, itemCount;
for(int i = 0 ; i < m_itemList.GetItemCount() ; i++)
{
itemCode = m_itemList.GetItemText(i, 0);
if( m_itemCount.GetItemCount() <= i )
break;
itemCount = m_itemCount.GetItemText(i, 0);
ReqeustCountChange(atoi(itemCode), atoi(itemCount));
}
}
@@ -0,0 +1,55 @@
#pragma once
#include "afxcmn.h"
#include "afxwin.h"
class CZoneDialog;
// CSecretShopDlg 대화 상자입니다.
class CSecretShopDlg : public CDialogEx
{
DECLARE_DYNAMIC(CSecretShopDlg)
public:
CSecretShopDlg(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CSecretShopDlg();
// 대화 상자 데이터입니다.
enum { IDD = IDD_DIALOG_SECRETSHOP };
public:
void Startup(CZoneDialog* parent);
protected:
CZoneDialog* m_parent;
protected:
void InsertItemCode(CString itemCode);
void InsertItemCount(CString itemCount);
void OnDropItemFiles(CString file);
void OnDropItemCountFiles(CString file);
void DeleteListItem(CListCtrl& m_List);
void ReqeustCountChange(int itemCode, int itemCount);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CListCtrl m_itemList;
CListCtrl m_itemCount;
afx_msg void OnBnClickedButtonInforeset();
afx_msg void OnEnChangeEditItemcode();
afx_msg void OnEnChangeEditItemcount();
afx_msg void OnLvnItemchangedListItemcode(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLvnItemchangedListItemcount(NMHDR *pNMHDR, LRESULT *pResult);
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
CEdit m_editItemCode;
CEdit m_editItemCount;
afx_msg void OnBnClickedButtonInsert();
};
@@ -0,0 +1,11 @@
#pragma once
enum ServerTypes
{
SERVER_TYPE_NONE = 0,
SERVER_TYPE_MAIN,
SERVER_TYPE_LOGIN,
SERVER_TYPE_GAME,
SERVER_TYPE_BILLING,
SERVER_TYPE_MONITOR,
SERVER_TYPE_END
};
@@ -0,0 +1,28 @@
#ifndef _TownPortal_h_
#define _TownPortal_h_
#ifdef STATIC_TOWN_PORTAL_API
#define TOWN_PORTAL_API
#else
#ifdef EXPORT_TOWN_PORTAL
#define TOWN_PORTAL_API __declspec(dllexport)
#else
#define TOWN_PORTAL_API __declspec(dllimport)
#endif
#endif
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#include "ioPortalHelp.h"
#include "Packet.h"
#include "ioClientTCPSocket.h"
#include "ioUDPSocket.h"
#include "NetworkSecurity.h"
#include "FSM.h"
#include "cryption.h"
#endif
@@ -0,0 +1,44 @@
#pragma once
#define IDC_SOCKET_CONNECT (WM_USER+1)
#define IDC_SOCKET_CLOSE (WM_USER+2)
#define IDC_SOCKET_RECEIVE (WM_USER+3)
#define IDC_SOCKET_SEND (WM_USER+4)
#define IDC_SERVICE_GAMEINFO (WM_USER+100)
#define IDC_SERVICE_GAMEQUICKCLOSE (WM_USER+110)
#define IDC_SERVICE_GAMESAFECLOSE (WM_USER+111)
#define IDC_SERVICE_LOGINSHOWPANEL (WM_USER+121)
#define IDC_SERVICE_MAININFO (WM_USER+150)
#define IDC_SERVICE_MAINSAFECLOSE (WM_USER+151)
#define IDC_SERVICE_MAINRELOADINI (WM_USER+152)
#define IDC_SERVICE_GAMEQUICKCLOSEALL (WM_USER+153)
#define IDC_SERVICE_GAMESAFECLOSEALL (WM_USER+154)
#define IDC_SERVICE_RELOAD_CLOSEINI (WM_USER+155)
#define IDC_SERVICE_RELOAD_GSINI (WM_USER+156)
#define IDC_SERVICE_RELAYSERVERCONTROL (WM_USER+158)
#define IDC_SERVICE_MAINRESETEVENTSHOP (WM_USER+159)
#define IDC_SERVICE_MAINRESETCLOVERSHOP (WM_USER+160)
#define IDC_SERVICE_MAINRESETMILEGESHOP (WM_USER+161)
#define IDC_SERVICE_MAINRESETBUYLOG (WM_USER+162)
#define IDC_SERVICE_BILLINGRELOADINI (WM_USER+163)
#define IDC_SERVICE_MAIN_WHITELISTON (WM_USER+164)
#define IDC_SERVICE_MAIN_WHITELISTOFF (WM_USER+165)
#define IDC_SERVICE_LOGIN_WHITELISTON (WM_USER+166)
#define IDC_SERVICE_LOGIN_WHITELISTOFF (WM_USER+167)
#define IDC_SERVICE_MAINRELOADOPTION (WM_USER+168)
#define IDC_SERVICE_MAIN_RESET_MISSION (WM_USER+169)
//#define IDC_SERVICE_BILLINGNEXONLOGOUT (WM_USER+163) 130912 Àӽà »ç¿ë
#define IDC_SERVICE_CSDIALOG (WM_USER+198)
#define IDC_SERVICE_SHOWCS (WM_USER+199)
#define IDC_SERVICE_LOADCS (WM_USER+200)
#define IDC_SERVICE_SHOWTOOL (WM_USER+201)
#define IDC_SERVICE_AUTHENTICATION (WM_USER+202)
#define IDC_SERVICE_GRAPH3SEC (WM_USER+300)
#define IDC_SERVICE_GRAPH1MIN (WM_USER+301)
#define IDC_SERVICE_GRAPH10MIN (WM_USER+302)
#define IDC_SERVICE_REPORT (WM_USER+500)
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,289 @@
#pragma once
#include "afxcmn.h"
#include "IOSocket.h"
#include "OScopeCtrl.h"
#include "OScopeTimeCtrl.h"
#include "ServerTypes.h"
#include "MonitorListCtrl.h"
#include "Network/Protocol.h"
#include "Network/SP2Packet.h"
#include <map>
const int CCU_PORT = 9999;
// 변수명에 userId로 쓰인것은
// publicId와 privateId중 어느 것인지 헤깔리는 부분이 있어
// 추후에 변경해야함
class CDisplayDlg;
class CCSDialog;
class CLoginDialog;
class COperatorDlg;
class CGraphDlg;
class cFileWriter;
typedef std::map<int,SERVERINFO*> SERVERTABLE;
#define BILLING_ANSWER 3
//
// CZoneDialog 대화 상자입니다.
class CZoneDialog : public CDialogEx
{
DECLARE_EASYSIZE
DECLARE_DYNAMIC(CZoneDialog)
public:
CZoneDialog(CWnd* pParent = NULL); // 표준 생성자입니다.
virtual ~CZoneDialog();
// 대화 상자 데이터입니다.
enum { IDD = IDD_ZONEINFO_DIALOG };
public:
void Show();
void Hide();
void CreateMonitor(CString& title, CString& main, CString& login);
void CreateBillingMonitor(CString& title, BOOL billingFlag, BILLINGSERVERTABLE& tempBilling);
void SetBillingFlag(bool bBillingFlag) { m_billingFlag = bBillingFlag; }
void SetBillingTable(BILLINGSERVERTABLE& tempBilling) { m_billingServerTable = tempBilling; }
void SetBillingViewList();
void SetBillingConnTimerFlag(bool bTimer) { m_billingConnTimerFlag = bTimer; }
BOOL GetBillingConnTimerFlag() { return m_billingConnTimerFlag; }
void SetBillingTimerFlag(bool bTimer) { m_billingTimerFlag = bTimer; }
BOOL GetBilingTimerFlag() { return m_billingTimerFlag; }
void AddBillingConnectCount() { ++m_billingConnCount; }
void MinusBillingConnectCount() { --m_billingConnCount; }
int GetBillingConnectCount() { return m_billingConnCount; }
void OnConnect(const ServerTypes serverType, const int errCode, const int billingIndex);
void OnClose(const ServerTypes serverType, const int errCode, const int billingKeyIndex);
void OnReceive(const ServerTypes serverType, SP2Packet& rkPacket);
void ReceiveInfo( SP2Packet& rkPacket );
void RequestInfo(int serverType, int index);
void GetAddress(const ServerTypes serverType, const int item, CString& name, CString& IP, int& port);
void GetBillingAddress(const int serverType, const int item, CString& name, CString& IP, int& port);
BOOL GetRelayFlag(int index);
BOOL IsShow() { return m_show; }
BOOL IsAdministrator() { return (ADMIN_LEVEL_ADMINISTRATOR == m_level) ? TRUE : FALSE; }
BOOL IsOperator() { return (ADMIN_LEVEL_OPERATOR == m_level) ? TRUE : FALSE; }
protected:
void CreateSocket();
void CreateGraph();
void CreateList();
void CreateChild();
void CreateLog();
void CreateTimer();
void KillcheckTimer();
void DestroyTimer();
void CreatePanel();
void CreatePopup();
void CreateServerDownLog(SERVERINFO *serverInfo);
void InsertServer(SERVERINFO* serverInfo, const ServerStates state);
void UpdateServer(SERVERINFO* serverInfo, const ServerStates state);
void UpdateGameInfo(const int item, SERVERINFO& serverInfo);
void UpdateBillingReloadStatus(const int item, BOOL status);
void UpdateBillingUserCountInfo(const int item, BILLINGSERVERINFO& serverInfo, int billingKeyIndex);
void UpdateGraph(const int userCount);
void SortBillingList();
void InsertBillingServer(BILLINGSERVERINFO* serverInfo, const ServerStates state, int billingKeyIndex);
void UpdateBillingServer(BILLINGSERVERINFO* serverInfo, const ServerStates state, int billingKeyIndex);
void UpdateBillingGraph();
void SetTitle(CString& title) { m_title = title; }
CString GetTitle() { return m_title; }
protected:
int GetGameServerCount() { return m_gameServerTable.size(); }
SERVERINFO* GetGameServerInfo(const int index);
SERVERINFO* GetGameServerInfo(ioHashString& serverName);
SERVERINFO* GetGameServerInfo(ioHashString& serverIP, int serverPort);
SERVERINFO* GetOtherServerInfo(const int index);
SERVERINFO* GetOtherServerInfo(const ServerTypes serverType);
public :
BILLINGSERVERINFO* GetBillingServerInfo(const int index);
BILLINGSERVERINFO* GetBillingServerListInfo(const int index);
protected :
void AddGameServerInfo(SERVERINFO* serverInfo);
void AddOtherServerInfo(SERVERINFO* serverInfo);
void RequestBillingUserInfoCount(); //접속되어 있는 빌링서버에 유저 카운트 요청함
void ShowInfo(int serverType, int index, CString& title, CString& text);
void ShowGraph(MSG* pMsg);
void WriteLog(int currentUser);
public:
void RequestKickUser(CString publicID);
void RequestPractice(CString publicID);
void RequestAnnounce(int msgType, CString publicID, CString announce);
void RequestItemInsert(CString publicID, int presentType, int value1, int value2, int ment, int isPublicID);
void RequestEventInsert(int values[], int valueCount);
void RequestUserBlock(CString publicID, CString note, int64 limitTime, int level);
void RequestUserUnblock(CString publicID);
void RequestBillingServerLOG(int index);
void RequestWhiteList(BOOL bWhiteList, ServerTypes eServerType);
void RequestSecretShopCountChange(int iCode, int iCount);
void RequestCompensation(int iType, int iCode, int iValue, __int64 iEndDate);
void WriteLogDlg( const TCHAR* format, ...);
void WriteLogDlg( CString text );
void RequestTodayCCU(WORD wYear, WORD wMonth, WORD wDay);
void RequestSearchCCU(WORD wYear, WORD wMonth, WORD wDay);
protected:
BOOL GetIP(CString& localIP);
void UpdateBegin();
void UpdateEnd();
void RequestConnect();
void RequestMainInfo();
void RequestGameServerInfo(int index);
void RequestMainClose();
void RequestGameSafeyClose(int index);
void RequestGameQuicklyClose(int index);
void RequestGameSafeyCloseAll();
void RequestGameQuicklyCloseAll();
void RequestShowCSFile();
void RequestLoadCSFile();
void RequestUpdateRivision(int version);
void RequestReloadGSINI();
void RequestReloadOption();
void RequestReloadCloseINI();
void RequestBillingReloadINI( int billingKeyIndex );
//void RequestBillingReloadINI_ALL();
//void RequestBillingNexonPCRoomLogout( int billingKeyIndex );
void ResetEventShopCount();
void ResetCloverShopCount();
void ResetMilegeShopCount();
void ReserPurchaseLog();
void ReserOldMissionData();
void RequestAuth(CString ID, CString PWD);
void RequestChangeRelayServerState(int index);
void RequestExportReports();
void OnAnswerTodayCCU(SP2Packet &rkPacket);
void OnAnswerSearchCCU(SP2Packet &rkPacket);
void OnAnswerNumConnect(SP2Packet &rkPacket);
void OnAnswerBillingConnect(SP2Packet &rkPacket);
void OnBillingUserInfo(SP2Packet &rkPacket);
void OnServerDisconnect(SP2Packet &rkPacket);
void OnLoadCS3File(SP2Packet &rkPacket);
void OnCS3FileVersion(SP2Packet &rkPacket);
void OnUpdateClientVersion(SP2Packet &rkPacket);
void OnServerInfoAck(SP2Packet &rkPacket);
void OnAdminResponse(SP2Packet &rkPacket);
void OnLoginInfoAck(SP2Packet &rkPacket);
void OnLoginServerInfo(SP2Packet& rkPacket);
void OnLoginServerRefresh(SP2Packet& rkPacket);
void OnLoginServerBlock(SP2Packet& rkPacket);
void OnLSResponse(SP2Packet &rkPacket);
void OnAnswerBillingRequest(SP2Packet &rkPacket);
void OnBillingReloadINIStatus(SP2Packet &rkPacket);
void OnConnectState(SP2Packet &rkPacket);
void OnReceiveLicenseCheck(SP2Packet &rkPacket);
protected:
BOOL m_show;
CImageList m_imageList;
//COScopeCtrl m_countGraph;
COScopeTimeCtrl m_countGraph;
CString m_title;
WORD m_wLogYear;
WORD m_wLogMonth;
WORD m_wLogDay;
CString m_MNTClientIP;
int m_MNTClientPort;
CIOSocket m_sockMNTClient;
SERVERTABLE m_gameServerTable;
SERVERTABLE m_otherServerTable;
BILLINGSERVERTABLE m_billingServerTable; //INI에서 읽어온 빌링서버 정보
std::vector<BILLINGSERVERINFO*> m_billingServerList; //리스트 출력 순대로 저장됨 -> index 를 통해 클릭된 빌링서버 정보 구할 수 있음
int m_maxBillingUser, m_CurrentBillingUser;
int m_lastBillingMax;
int m_billingLOGReceiveCount, m_billingConnCount;
int m_level;
int m_maxUser, m_currentUser;
int m_lastMax;
int m_selectedItem;
CDisplayDlg* m_displayDlg;
CLoginDialog* m_loginDlg;
COperatorDlg* m_operatorDlg;
CGraphDlg* m_graphDlg;
cFileWriter* m_file;
CMenu m_menu;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
CMonitorListCtrl m_services[2];
BOOL m_billingFlag;
BOOL m_billingTimerFlag;
BOOL m_billingConnTimerFlag;
BOOL m_bCountryCode;
ioHashString m_szID;
ioHashString m_szPwd;
virtual BOOL OnInitDialog();
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnLvnItemchangedListGamedemons(NMHDR *pNMHDR, LRESULT *pResult);
private:
//EU국가별 접속자수 카운팅 함수 및 변수입니다.
void SetUserEachOfCountry(int iSvrType, int iNum, char* cName, SERVERINFO* svrInfo, const ServerStates iSvrState);
//문자열 붙이는 함수입니다.
void CStringAddINT(int iData, CString* TStr);
void SetCloseCCU(CString* Tstr);
void MoveToItemData(int iSvrNum, int iSour, int iDest);
SERVERINFO OtherSvrInfo[CI_MAX]; //국가별 카운트용
DWORD m_wdENG, m_wdGER, m_wdFRA, m_wdITA, m_wdPOL, m_wdTUR, m_wdETC;
public:
// afx_msg void OnNMClickListGamedemons(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnLvnKeydownListGamedemons(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnNMDblclkListGamedemons(NMHDR *pNMHDR, LRESULT *pResult);
void GetCCUINFO(const int item, CString& strName, CString& IP, int& port, int& ENGcnt, int& GERcnt, int& FRAcnt, int& ITAcnt, int& POLcnt, int& TURcnt, int& ETCcnt);
};
@@ -0,0 +1,271 @@
// cFile.cpp: implementation of the cFile class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "cFile.h"
#include <stdio.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
cFile::cFile() : m_hFile(INVALID_HANDLE_VALUE), m_dwSizeLow(0), m_dwSizeHigh(0)
{
}
cFile::cFile(LPCTSTR fileName, DWORD dwMode, DWORD dwShareMode, DWORD dwCreationDisposition) : m_hFile(INVALID_HANDLE_VALUE), m_dwSizeLow(0), m_dwSizeHigh(0)
{
Open(fileName, dwMode, dwShareMode, dwCreationDisposition);
}
cFile::~cFile()
{
Close();
}
//////////////////////////////////////////////////////////////////////
// operation
//////////////////////////////////////////////////////////////////////
BOOL cFile::Open(const TCHAR* fileName, DWORD dwMode, DWORD dwShareMode, DWORD dwCreationDisposition)
{
Close();
m_hFile = CreateFile( reinterpret_cast<LPCTSTR>(fileName),
dwMode,
dwShareMode,
NULL,
dwCreationDisposition,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(m_hFile == INVALID_HANDLE_VALUE) return FALSE;
return (m_hFile == INVALID_HANDLE_VALUE) ? FALSE : TRUE;
}
void cFile::Close()
{
if(m_hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(m_hFile);
m_hFile = NULL;
}
m_dwSizeLow = 0;
m_dwSizeHigh = 0;
}
BOOL cFile::Move(DWORD dwOrigin, LONG lOffset)
{
if(m_hFile != INVALID_HANDLE_VALUE)
{
DWORD dwResult = SetFilePointer( m_hFile,
lOffset,
NULL,
dwOrigin);
return (dwResult == 0xFFFFFFFF) ? FALSE : TRUE;
}
return FALSE;
}
DWORD cFile::GetFileSize()
{
if(m_dwSizeLow != 0)
return m_dwSizeLow;
DWORD dwError = 0;
if(m_hFile != INVALID_HANDLE_VALUE)
{
m_dwSizeLow = ::GetFileSize(m_hFile, &m_dwSizeHigh);
if((INVALID_FILE_SIZE == m_dwSizeLow) &&
((dwError = GetLastError()) != NO_ERROR))
return 0;
}
return m_dwSizeLow;
}
//////////////////////////////////////////////////////////////////////
// cFileReader class
//////////////////////////////////////////////////////////////////////
cFileReader::cFileReader(const TCHAR* fileName) : m_nReadType(-1)
{
if(fileName != NULL)
{
Open(fileName);
}
}
BOOL cFileReader::Open(const TCHAR* fileName)
{
if(cFile::Open(fileName, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING))
{
return (GetBOM() > 0) ? TRUE : FALSE;
}
return FALSE;
}
BOOL cFileReader::Read(BYTE* buffer, const DWORD dwLength)
{
DWORD dwWritten = 0;
if(m_hFile == INVALID_HANDLE_VALUE) return FALSE;
if(ReadFile( m_hFile,
buffer,
dwLength,
&dwWritten,
NULL))
{
if(dwLength == dwWritten) return TRUE;
}
return FALSE;
}
BOOL cFileReader::Convert(const BYTE* bufferA, const int lengthA, BYTE* bufferB, const int lengthB)
{
switch(m_nReadType)
{
case FILEFORMAT_ANSI :
CopyMemory(bufferB, bufferA, (lengthA > lengthB) ? lengthB : lengthA);
return TRUE;
case FILEFORMAT_UNICODE_UTF8 :
CopyMemory(bufferB, bufferA, (lengthA > lengthB) ? lengthB : lengthA);
return TRUE;
case FILEFORMAT_UNICODE_LE :
WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)bufferA, lengthA, (LPSTR)bufferB, lengthB, NULL, NULL);
return TRUE;
case FILEFORMAT_UNICODE_BE :
return TRUE;
}
return FALSE;
}
int cFileReader::GetBOM()
{
if((-1) == m_nReadType)
{
Move(FILE_BEGIN, 0);
WORD BOM = 0;
if(Read(reinterpret_cast<BYTE*>(&BOM), sizeof(WORD)))
{
switch(BOM)
{
case 0xFEFF :
m_nReadType = FILEFORMAT_UNICODE_LE;
Move(FILE_BEGIN, 2);
break;
case 0xFFFE :
m_nReadType = 0; //FILEFORMAT_UNICODE_BE; not supported
Move(FILE_BEGIN, 2);
break;
case 0xBBEF :
m_nReadType = FILEFORMAT_UNICODE_UTF8;
Move(FILE_BEGIN, 3);
break;
default:
m_nReadType = FILEFORMAT_ANSI;
Move(FILE_BEGIN, 0);
break;
}
return m_nReadType;
}
return 0;
}
return m_nReadType;
}
DWORD cFileReader::GetFileSize()
{
if(0 == m_dwSizeLow)
{
cFile::GetFileSize();
switch(m_nReadType)
{
case FILEFORMAT_UNICODE_LE :
case FILEFORMAT_UNICODE_BE :
m_dwSizeLow -= (2);
break;
case FILEFORMAT_UNICODE_UTF8 :
m_dwSizeLow -= (3);
break;
default:
break;
}
}
return m_dwSizeLow;
}
//////////////////////////////////////////////////////////////////////
// cFileWriter class
//////////////////////////////////////////////////////////////////////
cFileWriter::cFileWriter(const TCHAR* fileName)
{
if(fileName != NULL)
{
Open(fileName);
}
}
BOOL cFileWriter::Open(const TCHAR* fileName)
{
if(cFile::Open(fileName, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_ALWAYS))
{
WriteHeader();
return TRUE;
}
return FALSE;
}
BOOL cFileWriter::Write(const BYTE* buffer, const DWORD dwLength)
{
if(dwLength == 0)
return TRUE;
DWORD dwBytes = 0;
if(WriteFile( m_hFile,
buffer,
dwLength,
&dwBytes,
NULL))
{
return (dwBytes == dwLength) ? TRUE : FALSE;
}
return FALSE;
}
BOOL cFileWriter::WriteFormat(const TCHAR* format, ...)
{
TCHAR buffer[4096];
va_list marker;
va_start(marker, format);
_vstprintf_s(buffer, _countof(buffer), format, marker);
va_end(marker);
return Write(reinterpret_cast<BYTE*>(buffer), (_tcslen(buffer) * sizeof(TCHAR)));
}
void cFileWriter::WriteHeader()
{
#ifdef _UNICODE
Move(FILE_BEGIN, 0);
WORD BOM = 0xFEFF;
Write(reinterpret_cast<BYTE*>(&BOM), sizeof(BOM));
#endif
}
@@ -0,0 +1,68 @@
#pragma once
// cFile
class cFile
{
public:
cFile();
cFile(LPCTSTR fileName, DWORD dwMode, DWORD dwShareMode, DWORD dwCreationDisposition);
virtual ~cFile();
public:
BOOL Open(const TCHAR* fileName, DWORD dwMode, DWORD dwShareMode, DWORD dwCreationDisposition);
void Close();
BOOL Move(DWORD dwOrigin, LONG lOffset);
virtual DWORD GetFileSize();
enum SaveFileFormat
{
FILEFORMAT_ANSI = 1,
FILEFORMAT_UNICODE_UTF8,
FILEFORMAT_UNICODE_LE,
FILEFORMAT_UNICODE_BE,
};
protected:
HANDLE m_hFile;
DWORD m_dwSizeLow, m_dwSizeHigh;
};
// cFileReader
class cFileReader : public cFile
{
public:
cFileReader(const TCHAR* fileName=NULL);
public:
BOOL Open(const TCHAR* fileName);
BOOL Read(BYTE* buffer, const DWORD dwLength);
BOOL Convert(const BYTE* bufferA, const int lengthA, BYTE* bufferB, const int lengthB);
int GetBOM();
virtual DWORD GetFileSize();
private:
int m_nReadType;
};
// cFileWriter
class cFileWriter : public cFile
{
public:
cFileWriter(const TCHAR* fileName=NULL);
public:
BOOL Open(const TCHAR* fileName);
BOOL Write(const BYTE* buffer, const DWORD dwLength);
BOOL WriteFormat(const TCHAR* format, ...);
void WriteHeader();
};
@@ -0,0 +1,40 @@
[zone1]
name=Latin_live
main=127.0.0.1:40001
login=127.0.0.1:40005
[zone2]
name=USA
main=127.0.0.1:40001
login=127.0.0.1:40005
[zone3]
name=INDONESIA
main=10.6.8.101:40001
login=10.6.8.120:40005
countrycode=2
[zone4]
name=EU
main=127.0.0.1:40001
login=127.0.0.1:40005
countrycode=0
[zone5]
name=Latin_Dev
main=172.20.20.246:40001
login=172.20.20.246:40005
[zone6]
name=Thailand
main=127.0.0.1:40001
login=127.0.0.1:40005
[zone7]
name=EU_BETA
main=127.0.0.1:40001
login=127.0.0.1:40005
countrycode=1
@@ -0,0 +1,171 @@
#include "stdafx.h"
#include "Define.h"
#include "ioHashString.h"
ioHashString::ioHashString()
{
m_iCapacity = DEFAULT_CAPACITY;
m_pString = new char[ m_iCapacity ];
Clear();
m_dwHashCode = CalcHashCode( m_pString );
}
ioHashString::ioHashString( const char* str ) : m_pString(NULL)
{
m_iLength = (int)strlen( str );
int iCapacity = max( m_iLength + 1, DEFAULT_CAPACITY );
ReAllocCapacity( iCapacity );
strcpy( m_pString, str );
m_dwHashCode = CalcHashCode( str );
}
ioHashString::ioHashString( const ioHashString &rhs ) : m_pString(NULL)
{
m_iLength = rhs.Length();
ReAllocCapacity( rhs.m_iCapacity );
strcpy( m_pString, rhs.m_pString );
m_dwHashCode = rhs.m_dwHashCode;
}
ioHashString::~ioHashString()
{
SAFEDELETEARRAY( m_pString );
}
bool ioHashString::IsEmpty() const
{
return ( m_iLength == 0 );
}
int ioHashString::Length() const
{
return m_iLength;
}
void ioHashString::Clear()
{
memset( m_pString, 0, m_iCapacity );
m_iLength = 0;
}
const char* ioHashString::c_str() const
{
return m_pString;
}
void ioHashString::ReAllocCapacity( int iNewCapacity )
{
SAFEDELETEARRAY( m_pString );
m_iCapacity = iNewCapacity;
m_pString = new char[iNewCapacity];
}
DWORD ioHashString::CalcHashCode( const char *str )
{
DWORD dwLen, dwCh, dwResult;
dwLen = (DWORD)strlen( str );
dwResult = HASH_CONST;
for( DWORD i=0; i<dwLen ; i++ )
{
dwCh = (DWORD)str[i];
dwResult = ((dwResult<< 5) + dwResult) + dwCh; // hash * 33 + ch
}
return dwResult;
}
DWORD ioHashString::GetHashCode() const
{
return m_dwHashCode;
}
bool ioHashString::operator<( const ioHashString &rhs ) const
{
if( m_dwHashCode != rhs.m_dwHashCode )
return ( m_dwHashCode < rhs.m_dwHashCode );
return ( strcmp( m_pString, rhs.m_pString ) < 0 );
}
char ioHashString::At( int i ) const
{
if( m_iLength < i || !m_pString )
{
ASSERT( false );
return 0;
}
return m_pString[i];
}
ioHashString& ioHashString::operator=( const ioHashString &rhs )
{
m_iLength = rhs.Length();
if( m_iCapacity < m_iLength + 1 )
{
ReAllocCapacity( m_iLength + 1 );
}
strcpy(m_pString, rhs.m_pString );
m_dwHashCode = rhs.m_dwHashCode;
return *this;
}
ioHashString& ioHashString::operator=( const char *szText )
{
m_iLength = (int)strlen( szText );
if( m_iCapacity < m_iLength + 1 )
{
ReAllocCapacity( m_iLength + 1 );
}
strcpy( m_pString, szText );
m_dwHashCode = CalcHashCode( szText );
return *this;
}
bool ioHashString::operator==( const ioHashString &rhs ) const
{
if( m_dwHashCode != rhs.m_dwHashCode )
return false;
if( strcmp( m_pString, rhs.m_pString ) != 0 )
return false;
return true;
}
bool ioHashString::operator==( const char *szText ) const
{
if( strcmp( m_pString, szText ) != 0 )
return false;
return true;
}
bool ioHashString::operator!=( const ioHashString &rhs ) const
{
if( *this == rhs )
return false;
return true;
}
bool ioHashString::operator!=( const char *szText ) const
{
if( *this == szText )
return false;
return true;
}
@@ -0,0 +1,53 @@
#ifndef _ioHashString_h_
#define _ioHashString_h_
#define HASH_CONST 5381
#define DEFAULT_CAPACITY 32
// Original version is www.gamza.net
class ioHashString
{
private:
char *m_pString;
DWORD m_dwHashCode;
int m_iLength;
int m_iCapacity;
private:
void ReAllocCapacity( int iNewCapacity );
public:
void Clear();
bool IsEmpty() const;
int Length() const;
char At( int i ) const;
DWORD GetHashCode() const;
const char* c_str() const;
public:
static DWORD CalcHashCode( const char *str );
public:
bool operator < ( const ioHashString &rhs ) const;
ioHashString& operator=( const ioHashString &rhs );
ioHashString& operator=( const char *szText );
bool operator==( const ioHashString &rhs ) const;
bool operator==( const char *szText ) const;
bool operator!=( const ioHashString &rhs ) const;
bool operator!=( const char *szText ) const;
public:
ioHashString();
ioHashString( const char *str );
ioHashString( const ioHashString &rhs );
~ioHashString();
};
#endif
Loaded 100 of 20588 files, more files were not shown because too many files have changed in this diff. Show more