www.pudn.com > H323BeaconClient-v1.4_win_src.zip > BeaconClientDlg.cpp, change:2004-07-28,size:65709b


/* 
 * BeaconClientDlg.cxx 
 * 
 * Implementation file 
 * 
 * Copyright (c) ITEC-Ohio, 2002. 
 * 
 * The contents of this file are subject to the Mozilla Public License 
 * Version 1.2 (the "License"); you may not use this file except in 
 * compliance with the License. You may obtain a copy of the License at 
 * http://www.mozilla.org/MPL/ 
 * 
 * Software distributed under the License is distributed on an "AS IS" 
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 
 * the License for the specific language governing rights and limitations 
 * under the License. 
 * 
 * The Original Code is Open H323 Library available at http://www.openh323.org 
 * The Initial Developer of the Original Code is Equivalence Pty. Ltd. 
 * 
 */ 
 
#pragma warning(disable: 4786) 
 
#include "stdafx.h" 
#include "excel9.h" 
 
#include <iostream> 
#include <fstream> 
#include <vector> 
 
#include <ptlib.h> 
#include <string.h> 
#include <stdio.h> 
 
#include <windows.h> 
#include <tlhelp32.h> 
 
 
 
#include "main.h" 
 
#include "gsmcodec.h" 
#include "lpc10codec.h" 
 
#include "mscodecs.h" 
#include "h261codec.h" 
 
#include "videoio.h" 
#include "h323pdu.h" 
 
 
#include "BeaconClient.h" 
#include "DlgMain.h" 
#include "DlgStatistics.h" 
#include "DlgAudioVideo.h" 
#include "MyTabCtrl.h" 
#include "BeaconClientDlg.h" 
#include "DlgPlots.h" 
 
 
CDlgAudioVideo m_audioVideo; 
CString ipHolder; 
CString currentTestFolder; 
extern char exeFolderPath[MAX_PATH]; 
 
//CString consoleText; 
 
extern UINT    TimerVal; 
extern PString TokenCurrentCall; 
extern char testsFolderPath[MAX_PATH]; 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
using namespace std; 
 
BeaconClient* globalInstance; 
CString ipglobal = ""; 
extern const char* globalEndReason; 
extern int FlagEndPoint; 
 
extern MyH323EndPoint &ep11;  
 
UINT ConnectionTimer; 
extern UINT StatisticTimer; 
int constat; 
extern UINT TimerVal; 
int is_MsgBox_Display; // 0 means globalendReason has NOT been displayed 
int CurrentDrive_tmp; 
char CurrentDrive_tmp1[MAX_PATH]; 
char tmpCurrDrvStr[MAX_PATH]; 
extern BOOLEAN GenerateStatistic; 
extern CString consoleStr; 
extern CString ReportStr; 
extern CString AudioCodec; 
extern CString SaveResult; 
 
//IndexBandwidth added to make a call with particular bandwidth 
extern int indexbandwidth; 
bool bCalling = false; 
 
 
 
//Report Variables 
 
extern CString localmachine;		//client IP 
extern const char* globalEndReason; 
char startTimeStr[100]; 
extern CString sessionStartTime; 
extern CString sessionEndTime; 
extern CString sessionDate; 
//extern PStringStream DurationTimeGlobal; 
extern int DurationHour; 
extern int DurationMinute; 
extern int DurationSecond; 
extern PString PayloadTypeGlobal; 
extern DWORD PacketSentGlobal; 
extern DWORD OctetSendGlobal; 
extern DWORD PacketsReceivedGlobal; 
extern DWORD OctetsReceivedGlobal; 
 
 
//Ping Report Variables 
extern CString avgPingLatency; 
extern CString medianPingLatency; 
extern CString sdPingLatency; 
extern CString minPingLatency; 
extern CString maxPingLatency; 
extern CString P50PingLatency; 
extern CString P90PingLatency; 
 
//Codec Latency Report Variables 
extern CString avgCodecLatency; 
extern CString medianCodecLatency; 
extern CString sdCodecLatency; 
extern CString minCodecLatency; 
extern CString maxCodecLatency; 
extern CString P50CodecLatency; 
extern CString P90CodecLatency; 
 
//Jitter Report Variables 
extern CString avgJitterLatency; 
extern CString medianJitterLatency; 
extern CString sdJitterLatency; 
extern CString minJitterLatency; 
extern CString maxJitterLatency; 
extern CString P50JitterLatency; 
extern CString P90JitterLatency; 
 
//PacketLoss Report Variables 
extern CString avgPacketLossLatency; 
extern CString medianPacketLossLatency; 
extern CString sdPacketLossLatency; 
extern CString minPacketLossLatency; 
extern CString maxPacketLossLatency; 
extern CString P50PacketLossLatency; 
extern CString P90PacketLossLatency; 
 
char TraceRT[2048]; 
 
//End Report Variables 
 
extern CString SaveResult; 
 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CBeaconClientDlg dialog 
 
CBeaconClientDlg::CBeaconClientDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CBeaconClientDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CBeaconClientDlg) 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1); 
} 
 
void CBeaconClientDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CBeaconClientDlg) 
	DDX_Control(pDX, IDC_TRAFFICLIGHT, m_trafficlight); 
	DDX_Control(pDX, IDC_COMBO1, m_call); 
	DDX_Control(pDX, IDC_BEACON_PICTURE, m_beaconPicture); 
	DDX_Control(pDX, IDC_TABPAGES, m_tab1); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CBeaconClientDlg, CDialog) 
	//{{AFX_MSG_MAP(CBeaconClientDlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_DESTROY() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_BN_CLICKED(IDC_BUTTON_CALL, OnButtonCall) 
	ON_NOTIFY(TCN_SELCHANGE, IDC_TABPAGES, OnSelchangeTabpages) 
	ON_WM_TIMER() 
	ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditchangeCombo1) 
	ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear) 
	ON_BN_CLICKED(IDC_ABOUT, OnAbout) 
	ON_WM_CTLCOLOR() 
	ON_BN_CLICKED(IDC_STATISTICSPLOTS, OnStatisticsplots) 
	ON_BN_CLICKED(IDC_REPORT, OnReport) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CBeaconClientDlg message handlers 
 
BOOL CBeaconClientDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
	// TODO: Add extra initialization here 
 
	m_tab1.InsertItem(0, _T("Main")); 
	m_tab1.InsertItem(1,_T("Settings")); 
	//m_tab1.InsertItem(2,_T("Statistics")); 
	//m_tab1.InsertItem(3,_T("Audio / Video")); 
	 
	m_tab1.Init(); 
 
	HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP3), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
	m_trafficlight.SetBitmap(hTrafficLightBmp); 
	SetDlgItemText(IDC_EDIT_CALLSTATUS, "Normal Close"); 
	//Disable Statistics And Report Buttons. 
	GetDlgItem(IDC_STATISTICS)->EnableWindow(FALSE); 
	GetDlgItem(IDC_REPORT)->EnableWindow(FALSE); 
	 
	//Prepare Combo Box  
	m_call.InsertString(0,"56K"); 
	m_call.InsertString(1,"128K"); 
	m_call.InsertString(2,"256K"); 
	m_call.InsertString(3,"384K"); 
	m_call.InsertString(4,"512K"); 
	m_call.InsertString(5,"768K"); 
	m_call.LimitText(0); 
 
	 
	GenerateStatistic = FALSE; 
 
	//Create a "Tests" directory if it does not exist 
	HANDLE		fFile;					// File Handle 
	WIN32_FIND_DATA fileinfo;			// File Information Structure 
	CString dd;							//To hold the directory name 
	 
	//dd = strcat(testsFolderPath,"Tests"); 
	dd = testsFolderPath; 
	//MessageBox(dd); 
	fFile = FindFirstFile(dd,&fileinfo); 
	// if the file exists and it is a directory 
	if(fileinfo.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY) 
	{ 
		//  Directory Exists close file and return 
		FindClose(fFile); 
	} 
	else{ 
		 //Create a new directory 
		if( _mkdir( dd ) != 0 ){ 
						consoleStr+= "\r\nWARNING2: Problem creating 'Tests' directory!"; 
		} 
	} 
	sprintf(CurrentDrive_tmp1,"%s\\%s",testsFolderPath, "\\Temp"); 
		 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CBeaconClientDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX){ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
void CBeaconClientDlg::OnDestroy(){ 
 
	WinHelp(0L, HELP_QUIT); 
	CDialog::OnDestroy(); 
} 
 
void CBeaconClientDlg::RemoveFile(){ 
 
	//Excel sheet related files 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"timestamp.txt"); 
	remove(tmpCurrDrvStr); 
				 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"ploadtype.txt");		 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"pktloss.txt");		 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"audjitter.txt"); 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"rtd.txt"); 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"pktsent.txt"); 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"octsent.txt"); 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"pktrecvd.txt"); 
	remove(tmpCurrDrvStr);  
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"octrecvd.txt"); 
	remove(tmpCurrDrvStr); 
 
	//GNUPlot related files 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"pktloss_gplot.txt"); 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"audjitter_gplot.txt"); 
	remove(tmpCurrDrvStr); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"rtd_gplot.txt"); 
	remove(tmpCurrDrvStr); 
	 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CBeaconClientDlg::OnPaint()  
{ 
 
	if (IsIconic()){ 
		CPaintDC dc(this); // device context for painting 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		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; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else{ 
		CDialog::OnPaint(); 
	} 
 
	HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP1), 
                                        IMAGE_BITMAP,  
                                        80,80,  
                                        LR_DEFAULTCOLOR); 
	m_beaconPicture.SetBitmap(hBmp); 
 
	/*HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP3), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
	m_trafficlight.SetBitmap(hTrafficLightBmp);*/ 
	 
	m_call.SetCurSel(3); 
	GetDlgItem( IDC_IPADDRESS1)->SetFocus(); 
	//GetDlgItem( IDC_STATISTICS)->EnableWindow(FALSE); 
	//GetDlgItem( IDC_SIGNALING)->EnableWindow(FALSE); 
	//GetDlgItem( IDC_REPORT)->EnableWindow(FALSE); 
	//GetDlgItem( IDC_TRACE)->EnableWindow(FALSE); 
	 
	//SetDlgItemText(IDC_EDIT_CALLSTATUS, "Normal Close"); 
		 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CBeaconClientDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
void CBeaconClientDlg::OnButtonCall()  
{ 
	// TODO: Add your control notification handler code here 
 
	CWnd* pIP = (CWnd*)GetDlgItem(IDC_IPADDRESS1); 
	pIP->GetWindowText(ipHolder); 
	ipglobal = ipHolder; 
	pIP->GetWindowText(ipglobal); 
	 
	if (ipglobal == "0.0.0.0"){ 
		MessageBox("Please enter a destination IP Address before placing a call...","H.323 Beacon Client",MB_OK); 
	    CIPAddressCtrl *pIPReset = (CIPAddressCtrl *)GetDlgItem(IDC_IPADDRESS1); 
		pIPReset->SetFocus(); 
	} 
	else{ 
	 
	if(FlagEndPoint == 0) 
		 
 
	FlagEndPoint = 1; 
 
 
	CString strtext; 
	int checktimeconn; 
	int value; 
	int value_a; 
 
 
	value = 0; 
 
	CButton *pButton = (CButton *)GetDlgItem(IDC_BUTTON_CALL); 
	pButton->GetWindowText(strtext); 
 
 
	if ( strtext == "&Call" ){ 
		consoleStr+="\r\nInitiating the test session to H.323 Beacon Server IP : "+ipglobal; 
 
		inCall = true; 
		pButton->SetWindowText("&Hang Up"); 
		GetDlgItem(IDC_STATISTICS)->EnableWindow(FALSE); 
		GetDlgItem(IDC_REPORT)->EnableWindow(FALSE); 
	 
 
		//Create directory in the "Tests" directory, to hold test output for current session 
		char ddOutput[100];							//To hold the directory name 
		CString baseName;							//To generate folder name based on time and date 
 
		baseName = GetTestSessionFolderName();  
		sprintf(ddOutput,"%s\\%s\\",testsFolderPath, baseName); 
		currentTestFolder = ddOutput; 
		 
		//Create a new directory 
		//if(atoi(SaveResult)==1){ 
			if( _mkdir( currentTestFolder ) != 0 ) 
				consoleStr+= "\r\nWARNING: Problem creating directory for test session!"; 
		//} 
 
		m_tab1.InsertItem(2,_T("Statistics")); 
		m_tab1.InsertItem(3,_T("Audio / Video")); 
		 
		if (ipglobal == ""){ 
			SetDlgItemText(IDC_EDIT_CALLSTATUS, " "); 
		} 
		else{ 
		SetDlgItemText(IDC_EDIT_CALLSTATUS, "Waiting for Answer");  
		} 
		bCalling = true; 
	} 
	else{ 
 
	  TRY{ 
 
		value_a = MessageBox("Do you want to Hang-Up ?","H.323 Beacon Client", MB_YESNO + MB_ICONINFORMATION); 
 
		if (value_a == 6){ 
			// if yes value = 6  
			// if no value = 7 
			consoleStr+="\r\nTerminating the test session..."; 
			//Send DTMF message 4 to server 
			H323Connection * connection = globalInstance->endpoint->FindConnectionWithLock(TokenCurrentCall); 
			 
			if (connection == NULL) 
			  return; 
		 
			 
 
			//do other things 
 
			connection->SendUserInput(4); 
			connection->Unlock(); 
 
			inCall = false; 
 
			 
			pButton->SetWindowText("&Call"); 
			SetDlgItemText(IDC_EDIT_CALLSTATUS, "Normal Close"); 
			HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP6), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
			m_trafficlight.SetBitmap(hTrafficLightBmp); 
			bCalling = false; 
			globalInstance->Quit(); 
			delete(globalInstance); 
 
			SetDlgItemText(IDC_EDIT_CALLSTATUS, "Clearing Call....");  
 
			 
			CBeaconClientDlg::UpdateWindow(); 
			FlagEndPoint = 1; 
 
			m_tab1.m_tabPages[3]->GetDlgItem( IDC_BUTTON_STOP )->EnableWindow(FALSE); 
			m_tab1.m_tabPages[3]->GetDlgItem( IDC_BUTTON_RECORD )->EnableWindow(TRUE); 
			m_tab1.m_tabPages[3]->GetDlgItem( IDC_BUTTON_PLAY )->EnableWindow(FALSE); 
			m_tab1.SetCurSel(0); 
 
			m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
			m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
			 
			m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
			m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[0]->UpdateWindow(); 
			GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
			 
			SetDlgItemText(IDC_EDIT_CALLSTATUS, "Normal Close"); 
			hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP6), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
			m_trafficlight.SetBitmap(hTrafficLightBmp); 
			CBeaconClientDlg::UpdateWindow(); 
 
			KillTimer(TimerVal); 
			 
			//GNUPlot related processing to create plots 
			globalInstance->PrepareGnuPlot(); 
			 
			globalInstance->PrepareGnuPlotLatency(); 
			 
			globalInstance->ConvertPngToBmp(currentTestFolder); 
 
			//CAll finished. 
			//start socket server to get the reverse trace route from server 
			//Asynchronous communication preferable. 
			//MessageBox("Opening Socket for getting the traceRT"); 
			 
			//consoleStr+="\r\nStarting the trace route Server..."; 
			//if(GetTraceRouteFromServer()==0){ 
				//MessageBox("Problem with server ports, Couldnt get trace route from server"); 
			//} 
 
			//MessageBox("Socket Open to get traceRT"); 
			 
			//Enable Statistics And Report Buttons. 
			GetDlgItem(IDC_STATISTICS)->EnableWindow(TRUE); 
			//GetDlgItem( IDC_SIGNALING)->EnableWindow(FALSE); 
			GetDlgItem(IDC_REPORT)->EnableWindow(TRUE); 
			//GetDlgItem( IDC_TRACE)->EnableWindow(FALSE); 
 
			if (GenerateStatistic == TRUE){ 
 
				value = MessageBox("Generate File Containing Statistics?","H.323 Beacon Client", MB_YESNO + MB_ICONINFORMATION); 
 
				// if yes value = 6  
				// if no value = 7 
 
				if (value == 6){ 
					consoleStr+="\r\nGenerating Excel file containing test session statistics collected..."; 
					consoleStr+="\r\nWaiting to initiate test session..."; 
 
					m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
					m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
					 
					m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
					m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[0]->UpdateWindow(); 
					GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
					CBeaconClientDlg::UpdateWindow(); 
					StoreStatistics(); 
					RemoveFile(); 
					//CDialog::OnCancel(); 
				} 
				else{ 
					consoleStr+="\r\nCancelling generation of Excel file containing test session statistics collected..."; 
					consoleStr+="\r\nWaiting to initiate test session..."; 
 
					m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
					m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
					 
					m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
					m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[0]->UpdateWindow(); 
					GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
					CBeaconClientDlg::UpdateWindow(); 
					RemoveFile(); 
					//CDialog::OnCancel(); 
				} 
			} 
 
			GenerateStatistic = FALSE; 
 
			// Remove All Temporary Files 
			RemoveFile();    
			 
			//Removes the Statistics and Audio/Video tabs 
			m_tab1.DeleteItem(3); 
			m_tab1.DeleteItem(2); 
 
			m_tab1.m_tabPages[0]->UpdateWindow(); 
 
			//closing the socket opened for the getting the traceRT from server 
			//SockServer.Close(); 
			//MessageBox("Socket Closed"); 
 
 
		} // end of if(value == 6) 
			 
 
			if (value != 0) 
			{ 
				FlagEndPoint = 1; 
			} 
			else 
			{ 
				FlagEndPoint = 0; // still in the call 
			} 
 
 
 
		 
	  } 
 
	  CATCH_ALL(e){ 
		// Put some delay here		 
	  } 
	  END_CATCH_ALL 
	} 
 
	if (FlagEndPoint == 0){ 
		// Already in Call 
	} 
	else{ 
		if( bCalling ){		 
			globalInstance = new BeaconClient(); 
			globalInstance->ipAddress = (LPCTSTR)ipglobal; 
			if (ipglobal == ""){ 
				pButton->SetWindowText("&Call"); 
				MessageBox("Please enter a destination IP Address and press apply before placing a call...","H.323 Beacon Client", MB_OK); 
				SetDlgItemText(IDC_EDIT_CALLSTATUS, "Normal Close"); 
				HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP6), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
				m_trafficlight.SetBitmap(hTrafficLightBmp); 
			} 
			else{ 
				// need to trap return value 
				// Get bandwidth  
				indexbandwidth = m_call.GetCurSel(); 
 
				// Delete Contents of file 
				SetDlgItemText(IDC_EDIT_CALLSTATUS, "Connecting..."); 
				m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
				m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
				m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
				m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
				 
				m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
				m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
				m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
				m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
				m_tab1.m_tabPages[0]->UpdateWindow(); 
				GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
				CBeaconClientDlg::UpdateWindow(); 
 
			   if( _chdir( CurrentDrive_tmp1) == 0){ 
				// Success to do change directory to <TestsFolderPath>\Temp 
			   } 
			   else{ 
					if ( _mkdir( CurrentDrive_tmp1 ) == 0 ){ 
					} 
					else{ 
					  MessageBox ("Could not make the 'Temp' directory in <TestsFolderPath>"); 
					} 
			   } 
 
			    RemoveFile(); 
 
				globalInstance->Main();  
				FlagEndPoint = 0 ; 
				m_call.SetCurSel(indexbandwidth); 
				is_MsgBox_Display = 0; //MsgBox has not been displayed 
 
				// For statistic part, we are using WM_TIMER to collect 
				// statistic for every second by command SetTimer(1,1000,0)  
				// where 1000 = 1000 mile second 
 
				CWnd::KillTimer(ConnectionTimer); 
				if (globalInstance != NULL){ 
					if (globalInstance->endpoint != NULL){ 
 
						ConnectionTimer = CWnd::SetTimer(10,5000,0);   
 
						// Keep pooling to check for connection for 10 seconds 
						checktimeconn = 0; 
						while (checktimeconn < 20){ 
							if (globalInstance->endpoint->IsConnectionEstablished(globalInstance->endpoint->currentCallToken) == TRUE){ 
									SetDlgItemText(IDC_EDIT_CALLSTATUS, "In Session"); 
									HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP4), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
									m_trafficlight.SetBitmap(hTrafficLightBmp); 
									FlagEndPoint = 0; 
									checktimeconn = 11000; 
									m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
									m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
									m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
									m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
									m_tab1.m_tabPages[2]->UpdateWindow(); 
									m_tab1.m_tabPages[2]->SetFocus(); 
									m_tab1.SetCurSel(2); 
							} 
							else{ 
									FlagEndPoint = 1; // suppose to be 1 
							} 
												 
							checktimeconn = checktimeconn + 1; // increase every 1 sec 
							if (checktimeconn < 20){ 
								Sleep(300); 
							} 
												 
						} // end of while 
					} 
					else{ 
						CWnd::KillTimer(ConnectionTimer); 
					} 
				} 
 
			}//end of else 
				 
				  
		}  // if (bcalling) 
	} // else if (FlagEndPoint == 0) 
  } 
} 
 
void CBeaconClientDlg::OnCancel()  
{ 
 
	int value; 
	//const char* myendreasoncode = (LPCTSTR)globalEndReason; 
 
	if (FlagEndPoint == 0){ 
		value = MessageBox("Do you want to Hang-Up?","H.323 Beacon Client", MB_YESNO + MB_ICONINFORMATION); 
 
		if (value == 6){ 
 
				globalInstance->Quit(); 
 
				m_tab1.m_tabPages[3]->GetDlgItem(IDC_BUTTON_STOP )->EnableWindow(FALSE); 
				m_tab1.m_tabPages[3]->GetDlgItem(IDC_BUTTON_RECORD )->EnableWindow(TRUE); 
				m_tab1.m_tabPages[3]->GetDlgItem(IDC_BUTTON_PLAY)->EnableWindow(FALSE); 
  
				delete(globalInstance); 
				FlagEndPoint = 1; 
 
				m_tab1.SetCurSel(0); 
 
				if (GenerateStatistic == TRUE){ 
 
					if (strcmp(globalEndReason, "") == 0){ 
 
						//MessageBox("Call Ended Successfully!"); 
					} 
					else{ 
						MessageBox(globalEndReason,"H.323 Beacon Client", MB_OK | MB_SYSTEMMODAL); 
						m_tab1.DeleteItem(3); 
						m_tab1.DeleteItem(2); 
						m_tab1.m_tabPages[0]->UpdateWindow(); 
					} 
 
					value = MessageBox("Generate File Containing Statistics?","H.323 Beacon Client", MB_YESNO + MB_ICONINFORMATION); 
 
					// if yes value = 6  
					// if no value = 7 
 
					if (value == 6){ 
						StoreStatistics(); 
						RemoveFile(); 
						CDialog::OnCancel(); 
						 
					} 
					else{ 
						RemoveFile(); 
						CDialog::OnCancel(); 
					} 
				} 
 
		} // value == 6; 
	} 
	else{ 
	 
		if (GenerateStatistic == TRUE){ 
			value = MessageBox("Generate File Containing Statistics?","H.323 Beacon Client", MB_YESNO + MB_ICONINFORMATION); 
 
			// if yes value = 6  
			// if no value = 7 
 
			if (value == 6){ 
				StoreStatistics(); 
				RemoveFile(); 
				CDialog::OnCancel(); 
			} 
			else{ 
				RemoveFile(); 
				CDialog::OnCancel(); 
				 
			} 
		} 
		else{ 
				RemoveFile(); 
				CDialog::OnCancel(); 
			} 
				 
	} 
	 
} 
 
 
void CBeaconClientDlg::FillSafeArray(OLECHAR FAR* sz, int iRow, int iCol, 
                         COleSafeArray* sa) 
{ 
  TRY { 
 
 
	VARIANT v; 
	long index[2]; 
 
	index[0] = iRow; 
	index[1] = iCol; 
 
	VariantInit(&v); 
	v.vt = VT_BSTR; 
	v.bstrVal = SysAllocString(sz); 
	sa->PutElement(index, v.bstrVal); 
	SysFreeString(v.bstrVal); 
	VariantClear(&v); 
  } 
  CATCH_ALL(e){ 
	// Put some delay here		 
  } 
  END_CATCH_ALL 
 
} 
 
void CBeaconClientDlg::StoreStatistics() 
{ 
	// Commonly used OLE variants. 
 
	COleVariant 
    covTrue((short)TRUE), 
    covFalse((short)FALSE), 
    covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR); 
 
 
	_Application app; 
	Workbooks books; 
	_Workbook book; 
 
	Worksheets sheets; 
	_Worksheet sheet; 
	Range range; 
	Font font; 
	Range cols; 
 
	int num_cols; 
	int iRes; 
	char buffer1[200]; 
	//char buffer2[200]; 
	int row_num; 
	char buf1[200]; 
 
 
	// Kill Background Excel Program 
	TRY{ 
 
		iRes = KillProcessByName("EXCEL.EXE"); 
		_itoa(iRes,buf1,10); 
    } 
	CATCH_ALL(e){ 
	} 
	END_CATCH_ALL 
 
	// Start Excel and get Application object. 
	TRY{ 
		if(!app.CreateDispatch("Excel.Application")) 
		{ 
		  AfxMessageBox("Couldn't start Excel and get Application object."); 
		  return; 
		} 
	} 
	CATCH_ALL(e){ 
	} 
	END_CATCH_ALL 
 
	TRY{ 
 
	//Get a new workbook. 
	books = app.GetWorkbooks(); 
	book = books.Add (covOptional); 
 
	//Get the first sheet. 
	sheets =book.GetSheets(); 
	sheet = sheets.GetItem(COleVariant((short)1)); 
 
	//Fill cells A1, B1, C1, and D1 one cell at a time with "headers". 
	range = sheet.GetRange(COleVariant("A1"),COleVariant("A1")); 
	range.SetValue(COleVariant("Time Stamp")); 
	range.SetColumnWidth(COleVariant("20")); 
 
 
	range = sheet.GetRange(COleVariant("B1"),COleVariant("B1")); 
	range.SetValue(COleVariant("Payload Type")); 
	range.SetColumnWidth(COleVariant("15")); 
 
	range = sheet.GetRange(COleVariant("C1"),COleVariant("C1")); 
	range.SetValue(COleVariant("Packet Lost")); 
	range.SetColumnWidth(COleVariant("12")); 
 
 
	range = sheet.GetRange(COleVariant("D1"),COleVariant("D1")); 
	range.SetValue(COleVariant("Audio Jitter")); 
	range.SetColumnWidth(COleVariant("12")); 
 
 
	range = sheet.GetRange(COleVariant("E1"),COleVariant("E1")); 
	range.SetValue(COleVariant("Round Trip Delay")); 
	range.SetColumnWidth(COleVariant("15")); 
 
 
	range = sheet.GetRange(COleVariant("F1"),COleVariant("F1")); 
	range.SetValue(COleVariant("Packet Sent")); 
	range.SetColumnWidth(COleVariant("15")); 
 
 
	range = sheet.GetRange(COleVariant("G1"),COleVariant("G1")); 
	range.SetValue(COleVariant("Octet Sent")); 
	range.SetColumnWidth(COleVariant("15")); 
 
 
	range = sheet.GetRange(COleVariant("H1"),COleVariant("H1")); 
	range.SetValue(COleVariant("Packet Received")); 
	range.SetColumnWidth(COleVariant("15")); 
 
 
	range = sheet.GetRange(COleVariant("I1"),COleVariant("I1")); 
	range.SetValue(COleVariant("Octet Received")); 
	range.SetColumnWidth(COleVariant("15")); 
	} 
	CATCH_ALL(e){ 
	} 
	END_CATCH_ALL 
 
	//read from each file and store in vector 
 
	num_cols = 1; 
	char buf[1000]; 
	//char buf2[1000]; 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"timestamp.txt"); 
	fstream fs1( tmpCurrDrvStr, ios::in ); 
	vector<string> v1; 
	while( fs1.peek() != EOF ){ 
		fs1.getline(buf, 1000); 
		string st(buf); 
		v1.push_back(st); 
		 
    } 
	fs1.close(); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"ploadtype.txt"); 
	fstream fs2( tmpCurrDrvStr, ios::in ); 
	vector<string> v2; 
	while( fs2.peek() != EOF ){ 
		fs2.getline(buf, 1000); 
		string st(buf); 
		v2.push_back(st); 
    } 
	fs2.close(); 
	 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"pktloss.txt"); 
	fstream fs3( tmpCurrDrvStr, ios::in ); 
	vector<string> v3; 
	while( fs3.peek() != EOF ){ 
		fs3.getline(buf, 1000); 
		string st(buf); 
		v3.push_back(st); 
    } 
 
	fs3.close(); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"audjitter.txt"); 
	fstream fs4( tmpCurrDrvStr, ios::in ); 
	vector<string> v4; 
	while( fs4.peek() != EOF ){ 
		fs4.getline(buf, 1000); 
		string st(buf); 
		v4.push_back(st); 
    } 
 
	fs4.close(); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"rtd.txt"); 
	fstream fs5( tmpCurrDrvStr, ios::in ); 
	vector<string> v5; 
	while( fs5.peek() != EOF ){ 
		fs5.getline(buf, 1000); 
		string st(buf); 
		v5.push_back(st); 
    } 
 
	fs5.close(); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"pktsent.txt"); 
	fstream fs6( tmpCurrDrvStr, ios::in ); 
	vector<string> v6; 
	while( fs6.peek() != EOF ){ 
		fs6.getline(buf, 1000); 
		string st(buf); 
		v6.push_back(st); 
		num_cols++; //Number of packet sent, Try to get number of rows need to be generated 
    } 
 
	fs6.close(); 
 
	_itoa(num_cols,buf1,10); 
 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"octsent.txt"); 
	fstream fs7( tmpCurrDrvStr, ios::in ); 
	vector<string> v7; 
	while( fs7.peek() != EOF ){ 
		fs7.getline(buf, 1000); 
		string st(buf); 
		v7.push_back(st); 
    } 
	fs7.close(); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"pktrecvd.txt"); 
	fstream fs8( tmpCurrDrvStr, ios::in ); 
	vector<string> v8; 
	while( fs8.peek() != EOF ){ 
		fs8.getline(buf, 1000); 
		string st(buf); 
		v8.push_back(st); 
    } 
 
	fs8.close(); 
 
	sprintf(tmpCurrDrvStr,"%s\\\\%s",CurrentDrive_tmp1,"octrecvd.txt"); 
	fstream fs9( tmpCurrDrvStr, ios::in ); 
	vector<string> v9; 
	while( fs9.peek() != EOF ){ 
		fs9.getline(buf, 1000); 
		string st(buf); 
		v9.push_back(st); 
    } 
 
	fs9.close(); 
 
 
	//Fill A2:B6 with an array of values (First & Last Names). 
	int num = v1.size(); 
 
 
	COleSafeArray saRet; 
	//DWORD numElements[]={num,2};   //5x2 element array 
	//DWORD numElements[]={num,5}; 
	DWORD numElements[] = {num,num_cols}; 
	 
	// 2 is the num of dimensions 
	//saRet.Create(VT_BSTR, 2, numElements); 
	saRet.Create(VT_BSTR, 2, numElements); 
 
 
	row_num = 0; 
 
	TRY { 
		_itoa(num,buf1,10); 
		 
 
		 
    for( int i = 0; i < num; i++ ){ 
	    if (i > 0){ 
			if (strcmp(v6[i].c_str(), v6[i-1].c_str()) != 0){ 
				if (atoi(v6[i].c_str()) > atoi(v6[i-1].c_str())){ 
				   CString st1( v1[i].c_str() ); 
				   BSTR bst1= st1.AllocSysString(); 
 
				   CString st2( v2[i].c_str() ); 
				   BSTR bst2 = st2.AllocSysString(); 
 
				   CString st3( v3[i].c_str() ); 
				   BSTR bst3 = st3.AllocSysString(); 
 
				   CString st4( v4[i].c_str() ); 
				   BSTR bst4 = st4.AllocSysString(); 
 
				   CString st5( v5[i].c_str() ); 
				   BSTR bst5 = st5.AllocSysString(); 
        
		   		   CString st6( v6[i].c_str() ); 
				   BSTR bst6 = st6.AllocSysString(); 
 
				    
				   CString st7( v7[i].c_str() ); 
				   BSTR bst7 = st7.AllocSysString(); 
 
				    
				   CString st8( v8[i].c_str() ); 
				   BSTR bst8 = st8.AllocSysString(); 
 
				    
				   CString st9( v9[i].c_str() ); 
				   BSTR bst9 = st9.AllocSysString(); 
 
			  		//FillSafeArray(bst17, row_num, 0, &saRet);  // Time Duration 
					FillSafeArray(bst1, row_num, 0, &saRet); 
					FillSafeArray(bst2, row_num, 1, &saRet); 
					FillSafeArray(bst3, row_num, 2, &saRet); 
					FillSafeArray(bst4, row_num, 3, &saRet); 
					FillSafeArray(bst5, row_num, 4, &saRet); 
					FillSafeArray(bst6, row_num, 5, &saRet); 
					FillSafeArray(bst7, row_num, 6, &saRet); 
					FillSafeArray(bst8, row_num, 7, &saRet); 
					FillSafeArray(bst9, row_num, 8, &saRet); 
				 
					row_num++; 
					_itoa(row_num,buf1,10); 
			 
				} // end of atoi 
			} 
		} 
		else{ 
			// To Prevent repetition on Report for first couple row 
 
			if (atoi(v6[i].c_str()) < atoi(v6[i+1].c_str())){ 
 
			   CString st1( v1[i].c_str() ); 
			   BSTR bst1= st1.AllocSysString(); 
			   CString st2( v2[i].c_str() ); 
			    
 
			   BSTR bst2 = st2.AllocSysString(); 
			   CString st3( v3[i].c_str() ); 
			   BSTR bst3 = st3.AllocSysString(); 
			   CString st4( v4[i].c_str() ); 
			   BSTR bst4 = st4.AllocSysString(); 
			   CString st5( v5[i].c_str() ); 
			   BSTR bst5 = st5.AllocSysString(); 
        
			    
			   CString st6( v6[i].c_str() ); 
			   BSTR bst6 = st6.AllocSysString(); 
 
			    
			   CString st7( v7[i].c_str() ); 
			   BSTR bst7 = st7.AllocSysString(); 
 
			    
			   CString st8( v8[i].c_str() ); 
			   BSTR bst8 = st8.AllocSysString(); 
 
			    
			   CString st9( v9[i].c_str() ); 
			   BSTR bst9 = st9.AllocSysString(); 
 
			    
			   FillSafeArray(bst1, row_num, 0, &saRet); 
			   FillSafeArray(bst2, row_num, 1, &saRet); 
			   FillSafeArray(bst3, row_num, 2, &saRet); 
			   FillSafeArray(bst4, row_num, 3, &saRet); 
			   FillSafeArray(bst5, row_num, 4, &saRet); 
			   FillSafeArray(bst6, row_num, 5, &saRet); 
			   FillSafeArray(bst7, row_num, 6, &saRet); 
			   FillSafeArray(bst8, row_num, 7, &saRet); 
			   FillSafeArray(bst9, row_num, 8, &saRet); 
 
			   row_num++; 
			   _itoa(row_num,buf1,10); 
			   
			} // end if atoi 
		}	 
	}  // end for 
 
	} 
	CATCH_ALL(e){ 
	} 
	END_CATCH_ALL 
 
	TRY{ 
		_itoa(num_cols,buffer1,10); 
		CString temp=""; 
	 
 
		_ltoa(num_cols,buffer1,10); 
		temp = CString("I") + CString(buffer1); 
		range = sheet.GetRange(COleVariant("A2"), COleVariant(temp)); 
		 
		 range.SetValue(COleVariant(saRet)); 
	 
		 saRet.Detach(); 
		 RemoveFile(); 
 
		app.SetVisible(TRUE); 
		app.SetUserControl(TRUE); 
	} 
	CATCH_ALL(e){ 
	} 
	END_CATCH_ALL 
} 
 
void CBeaconClientDlg::OnSelchangeTabpages(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here 
 
	int m_tabCurrent1; 
	int m_cursel1; 
 
 
	m_tabCurrent1 = m_tab1.GetCurFocus(); 
	m_cursel1 = m_tab1.GetCurSel(); 
 
	TRY{ 
			 
	  if (FlagEndPoint == 0){ 
		if (globalInstance->endpoint->HasConnection(globalInstance->endpoint->currentCallToken) == TRUE){ 
			 
				SetDlgItemText(IDC_EDIT_CALLSTATUS, "In Session");  
				HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP4), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
				m_trafficlight.SetBitmap(hTrafficLightBmp); 
 
				if (m_tabCurrent1 == 2){ 
						m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
						m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[2]->UpdateWindow(); 
						m_tab1.m_tabPages[2]->SetFocus(); 
						m_tab1.SetCurSel(2); 
					} 
					if (m_tabCurrent1 == 3){ 
						m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[3]->ShowWindow(SW_SHOW); 
						m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[3]->UpdateWindow(); 
						m_tab1.m_tabPages[3]->SetFocus(); 
						m_tab1.SetCurSel(3); 
					} 
 
 
					if (m_tabCurrent1 == 0){ 
						m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
						m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[0]->UpdateWindow(); 
						//m_tab1.m_tabPages[0]->SetFocus();  
						m_tab1.SetCurSel(0); 
						GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
					} 
 
					if (m_tabCurrent1 == 1){ 
						m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[1]->ShowWindow(SW_SHOW); 
						m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
						m_tab1.m_tabPages[1]->UpdateWindow(); 
						//m_tab1.m_tabPages[0]->SetFocus();  
						m_tab1.SetCurSel(1); 
						GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
					} 
 
					 
			}	 
			else{ 
				 
			} 
	  } 
 
	  else{ 
			if (m_tab1.GetCurSel() == 0 ){ 
				m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
				m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
				m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
				m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
 
				m_tab1.m_tabPages[0]->UpdateWindow(); 
					//m_tab1.m_tabPages[0]->SetFocus();  
				m_tab1.SetCurSel(0); 
					GetDlgItem( IDC_IPADDRESS1)->SetFocus(); 
				 
				} 
			else if (m_tab1.GetCurSel() == 1 ){ 
					m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[1]->ShowWindow(SW_SHOW); 
					m_tab1.m_tabPages[1]->UpdateWindow(); 
			}	 
			else{ 
					m_tab1.m_tabPages[m_tabCurrent1]->ShowWindow(SW_HIDE); 
 
					m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
					m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
 
					m_tab1.m_tabPages[0]->UpdateWindow(); 
					//m_tab1.m_tabPages[0]->SetFocus();  
					m_tab1.SetCurSel(0); 
					GetDlgItem( IDC_IPADDRESS1)->SetFocus(); 
 
					MessageBox("     Please place a call...","H.323 Beacon Client",MB_OK); 
				 
					FlagEndPoint = 1; 
				} 
	  } 
	 
   	  *pResult = 0; 
	} 
	CATCH_ALL(e){ 
		// Put some delay here		 
	} 
	END_CATCH_ALL 
 
} 
 
 
void CBeaconClientDlg::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
 
	 
	if (FlagEndPoint == 1){ 
		if (strcmp(globalEndReason,"")  != 0){ 
			CButton *pButton = (CButton *)GetDlgItem(IDC_BUTTON_CALL); 
			pButton->SetWindowText("&Call"); 
			SetDlgItemText(IDC_EDIT_CALLSTATUS, "Exception Close");  
			 
			 
 
			HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP5), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
			m_trafficlight.SetBitmap(hTrafficLightBmp); 
 
			m_tab1.m_tabPages[3]->GetDlgItem(IDC_BUTTON_STOP )->EnableWindow(FALSE); 
			m_tab1.m_tabPages[3]->GetDlgItem( IDC_BUTTON_RECORD )->EnableWindow(TRUE); 
			m_tab1.m_tabPages[3]->GetDlgItem( IDC_BUTTON_PLAY)->EnableWindow(FALSE); 
 
			m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
			m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[0]->UpdateWindow(); 
			GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
			//m_tab1.m_tabPages[0]->SetFocus();  
 
		  
			if (is_MsgBox_Display == 1){ 
				// Message Box globalEndReason has been displayed 
			} 
			else{ 
				is_MsgBox_Display = 1; 
				MessageBox(globalEndReason,"H.323 Beacon Client",MB_OK |MB_SYSTEMMODAL); 
				consoleStr+="\r\nAlarm generated in the test session!!!"; 
				consoleStr+="\r\nTerminating the test session due to exception..."; 
				consoleStr+="\r\nWaiting to initiate test session..."; 
 
				//Removes the Statistics and Audio/Video tabs 
				m_tab1.DeleteItem(3); 
				m_tab1.DeleteItem(2); 
				m_tab1.m_tabPages[0]->UpdateWindow(); 
			} 
			CWnd::KillTimer(ConnectionTimer); 
			bCalling = false; 
 
			m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
			m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
						 
			m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
			m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
			m_tab1.m_tabPages[0]->UpdateWindow(); 
			GetDlgItem( IDC_IPADDRESS1)->SetFocus(); 
			CBeaconClientDlg::UpdateWindow(); 
		} 
	} 
	else{ 
 
		//CEdit *p_Timer1= (CEdit *)GetDlgItem(IDC_BeaconTimer1); 
		if (globalInstance->endpoint != NULL){ 
 			constat = globalInstance->GetStatistics(); 
 
			if (constat == 0){ 
				SetDlgItemText(IDC_EDIT_CALLSTATUS, "In Session"); 	 
				HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP4), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
				m_trafficlight.SetBitmap(hTrafficLightBmp); 
			} 
			else{ 
				 CWnd::KillTimer(ConnectionTimer); 
				 if (strcmp(globalEndReason,"") == 0){ 
					  ConnectionTimer = CWnd::SetTimer(10,2000,0);					   
				 } 
				 else{ 
					  if (is_MsgBox_Display == 1){ 
						// Message Box globalEndReason has been displayed 
					  } 
					  else{ 
						is_MsgBox_Display = 1; 
						MessageBox(globalEndReason,"H.323 Beacon Client",MB_OK | MB_SYSTEMMODAL);						 
						consoleStr+="\r\nAlarm generated in the test session!!!"; 
					    consoleStr+="\r\nTerminating the test session due to exception..."; 
					  } 
 
					  CWnd::KillTimer(ConnectionTimer);				  
				      FlagEndPoint = 1; 
					  m_tab1.m_tabPages[0]->ShowWindow(SW_HIDE); 
					  m_tab1.m_tabPages[2]->ShowWindow(SW_SHOW); 
					  m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					  m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
							 
					  m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
					  m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
					  m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
					  m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
					  m_tab1.m_tabPages[0]->UpdateWindow(); 
					  GetDlgItem( IDC_IPADDRESS1)->SetFocus(); 
					  CBeaconClientDlg::UpdateWindow(); 
				 } 
				 
				 inCall = false; 
				 CButton *pButton = (CButton *)GetDlgItem(IDC_BUTTON_CALL); 
				 pButton->SetWindowText("&Call"); 
				 SetDlgItemText(IDC_EDIT_CALLSTATUS, "Exception Close");  
				  
 
				 HBITMAP hTrafficLightBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),  
                                        MAKEINTRESOURCE(IDB_BITMAP5), 
                                        IMAGE_BITMAP,  
                                        23,29,  
                                        LR_DEFAULTCOLOR); 
				 m_trafficlight.SetBitmap(hTrafficLightBmp); 
 
				 m_tab1.m_tabPages[3]->GetDlgItem(IDC_BUTTON_STOP )->EnableWindow(FALSE); 
				 m_tab1.m_tabPages[3]->GetDlgItem(IDC_BUTTON_RECORD )->EnableWindow(TRUE); 
				 m_tab1.m_tabPages[3]->GetDlgItem(IDC_BUTTON_PLAY)->EnableWindow(FALSE); 
 
				 m_tab1.m_tabPages[0]->ShowWindow(SW_SHOW); 
				 m_tab1.m_tabPages[2]->ShowWindow(SW_HIDE); 
				 m_tab1.m_tabPages[3]->ShowWindow(SW_HIDE); 
				 m_tab1.m_tabPages[1]->ShowWindow(SW_HIDE); 
				 m_tab1.m_tabPages[0]->UpdateWindow(); 
				 GetDlgItem( IDC_BUTTON_CALL)->SetFocus(); 
				 //m_tab1.m_tabPages[0]->SetFocus();  
	  
				 bCalling = false; 
				 
				 //Removes the Statistics and Audio/Video tabs 
				 m_tab1.DeleteItem(3); 
				 m_tab1.DeleteItem(2); 
				 m_tab1.m_tabPages[0]->UpdateWindow(); 
			} 
		} 
 
		//p_Timer1->SetWindowText(""); 
		//p_Timer1->UpdateWindow(); 
	 
		CDialog::OnTimer(nIDEvent); 
	} 
} 
 
int CBeaconClientDlg::KillProcessByName(const char * szToTerminate) 
 
// This function retrieved from  
// http://www.geocities.com/omeryesil/programming/visualcpp/killprocessbyname.htm 
// Created: 6/23/2000  (RK) 
// Last modified: 3/10/2002  (RK) 
// Please report any problems or bugs to kochhar@physiology.wisc.edu 
// The latest version of this routine can be found at: 
//     http://www.neurophys.wisc.edu/ravi/software/killproc/ 
// Terminate the process "szToTerminate" if it is currently running 
// This works for Win/95/98/ME and also Win/NT/2000/XP 
// The process name is case-insensitive, i.e. "notepad.exe" and "NOTEPAD.EXE" 
// will both work (for szToTerminate) 
// Return codes are as follows: 
//   0   = Process was successfully terminated 
//   603 = Process was not currently running 
//   604 = No permission to terminate process 
//   605 = Unable to load PSAPI.DLL 
//   602 = Unable to terminate process for some other reason 
//   606 = Unable to identify system type 
//   607 = Unsupported OS 
//   632 = Invalid process name 
//   700 = Unable to get procedure address from PSAPI.DLL 
//   701 = Unable to get process list, EnumProcesses failed 
//   702 = Unable to load KERNEL32.DLL 
//   703 = Unable to get procedure address from KERNEL32.DLL 
//   704 = CreateToolhelp32Snapshot failed 
 
{ 
	BOOL bResult,bResultm; 
	DWORD aiPID[1000],iCb=1000,iNumProc,iV2000=0; 
	DWORD iCbneeded,i,iFound=0; 
	char szName[MAX_PATH],szToTermUpper[MAX_PATH]; 
	HANDLE hProc,hSnapShot,hSnapShotm; 
	OSVERSIONINFO osvi; 
    HINSTANCE hInstLib; 
	int iLen,iLenP,indx; 
    HMODULE hMod; 
	PROCESSENTRY32 procentry;       
	MODULEENTRY32 modentry; 
 
	// Transfer Process name into "szToTermUpper" and 
	// convert it to upper case 
	iLenP=strlen(szToTerminate); 
	if(iLenP<1 || iLenP>MAX_PATH) return 632; 
	for(indx=0;indx<iLenP;indx++) 
		szToTermUpper[indx]=toupper(szToTerminate[indx]); 
	szToTermUpper[iLenP]=0; 
 
     // PSAPI Function Pointers. 
     BOOL (WINAPI *lpfEnumProcesses)( DWORD *, DWORD cb, DWORD * ); 
     BOOL (WINAPI *lpfEnumProcessModules)( HANDLE, HMODULE *, 
        DWORD, LPDWORD ); 
     DWORD (WINAPI *lpfGetModuleBaseName)( HANDLE, HMODULE, 
        LPTSTR, DWORD ); 
 
	  // ToolHelp Function Pointers. 
	  HANDLE (WINAPI *lpfCreateToolhelp32Snapshot)(DWORD,DWORD) ; 
	  BOOL (WINAPI *lpfProcess32First)(HANDLE,LPPROCESSENTRY32) ; 
	  BOOL (WINAPI *lpfProcess32Next)(HANDLE,LPPROCESSENTRY32) ; 
	  BOOL (WINAPI *lpfModule32First)(HANDLE,LPMODULEENTRY32) ; 
	  BOOL (WINAPI *lpfModule32Next)(HANDLE,LPMODULEENTRY32) ; 
 
	// First check what version of Windows we're in 
	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
    bResult=GetVersionEx(&osvi); 
	if(!bResult)     // Unable to identify system version 
	    return 606; 
 
	// At Present we only support Win/NT/2000/XP or Win/9x/ME 
	if((osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) && 
		(osvi.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)) 
		return 607; 
 
    if(osvi.dwPlatformId==VER_PLATFORM_WIN32_NT){ 
		// Win/NT or 2000 or XP 
 
         // Load library and get the procedures explicitly. We do 
         // this so that we don't have to worry about modules using 
         // this code failing to load under Windows 9x, because 
         // it can't resolve references to the PSAPI.DLL. 
         hInstLib = LoadLibraryA("PSAPI.DLL"); 
         if(hInstLib == NULL) 
            return 605; 
 
         // Get procedure addresses. 
         lpfEnumProcesses = (BOOL(WINAPI *)(DWORD *,DWORD,DWORD*)) 
            GetProcAddress( hInstLib, "EnumProcesses" ) ; 
         lpfEnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, 
            DWORD, LPDWORD)) GetProcAddress( hInstLib, 
            "EnumProcessModules" ) ; 
         lpfGetModuleBaseName =(DWORD (WINAPI *)(HANDLE, HMODULE, 
            LPTSTR, DWORD )) GetProcAddress( hInstLib, 
            "GetModuleBaseNameA" ) ; 
 
         if(lpfEnumProcesses == NULL || 
            lpfEnumProcessModules == NULL || 
            lpfGetModuleBaseName == NULL){ 
               FreeLibrary(hInstLib); 
               return 700; 
            } 
		  
		bResult=lpfEnumProcesses(aiPID,iCb,&iCbneeded); 
		if(!bResult){ 
			// Unable to get process list, EnumProcesses failed 
            FreeLibrary(hInstLib); 
			return 701; 
		} 
 
		// How many processes are there? 
		iNumProc=iCbneeded/sizeof(DWORD); 
 
		// Get and match the name of each process 
		for(i=0;i<iNumProc;i++){ 
			// Get the (module) name for this process 
 
	        strcpy(szName,"Unknown"); 
			// First, get a handle to the process 
	        hProc=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,FALSE, 
				aiPID[i]); 
	        // Now, get the process name 
	        if(hProc){ 
               if(lpfEnumProcessModules(hProc,&hMod,sizeof(hMod),&iCbneeded) ){ 
                  iLen=lpfGetModuleBaseName(hProc,hMod,szName,MAX_PATH); 
			   } 
			} 
	        CloseHandle(hProc); 
			// We will match regardless of lower or upper case 
#ifdef BORLANDC 
            if(strcmp(strupr(szName),szToTermUpper)==0) 
#else 
			if(strcmp(_strupr(szName),szToTermUpper)==0) 
#endif 
			{ 
				// Process found, now terminate it 
				iFound=1; 
				// First open for termination 
				hProc=OpenProcess(PROCESS_TERMINATE,FALSE,aiPID[i]); 
				if(hProc){ 
					if(TerminateProcess(hProc,0)){ 
						// process terminated 
						CloseHandle(hProc); 
                        FreeLibrary(hInstLib); 
						return 0; 
					} 
					else{ 
						// Unable to terminate process 
						CloseHandle(hProc); 
                        FreeLibrary(hInstLib); 
						return 602; 
					} 
				} 
				else{ 
					// Unable to open process for termination 
                    FreeLibrary(hInstLib); 
					return 604; 
				} 
			} 
		} 
	} 
 
	if(osvi.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS){ 
		// Win/95 or 98 or ME 
			 
		hInstLib = LoadLibraryA("Kernel32.DLL"); 
		if( hInstLib == NULL ) 
			return 702; 
 
		// Get procedure addresses. 
		// We are linking to these functions of Kernel32 
		// explicitly, because otherwise a module using 
		// this code would fail to load under Windows NT, 
		// which does not have the Toolhelp32 
		// functions in the Kernel 32. 
		lpfCreateToolhelp32Snapshot= 
			(HANDLE(WINAPI *)(DWORD,DWORD)) 
			GetProcAddress( hInstLib, 
			"CreateToolhelp32Snapshot" ) ; 
		lpfProcess32First= 
			(BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) 
			GetProcAddress( hInstLib, "Process32First" ) ; 
		lpfProcess32Next= 
			(BOOL(WINAPI *)(HANDLE,LPPROCESSENTRY32)) 
			GetProcAddress( hInstLib, "Process32Next" ) ; 
		lpfModule32First= 
			(BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) 
			GetProcAddress( hInstLib, "Module32First" ) ; 
		lpfModule32Next= 
			(BOOL(WINAPI *)(HANDLE,LPMODULEENTRY32)) 
			GetProcAddress( hInstLib, "Module32Next" ) ; 
		if( lpfProcess32Next == NULL || 
			lpfProcess32First == NULL || 
		    lpfModule32Next == NULL || 
			lpfModule32First == NULL || 
			lpfCreateToolhelp32Snapshot == NULL ){ 
			FreeLibrary(hInstLib); 
			return 703; 
		} 
			 
		// The Process32.. and Module32.. routines return names in all uppercase 
 
		// Get a handle to a Toolhelp snapshot of all the systems processes. 
 
		hSnapShot = lpfCreateToolhelp32Snapshot( 
			TH32CS_SNAPPROCESS, 0 ) ; 
		if( hSnapShot == INVALID_HANDLE_VALUE ){ 
			FreeLibrary(hInstLib); 
			return 704; 
		} 
		 
        // Get the first process' information. 
        procentry.dwSize = sizeof(PROCESSENTRY32); 
        bResult=lpfProcess32First(hSnapShot,&procentry); 
 
        // While there are processes, keep looping and checking. 
        while(bResult){ 
		    // Get a handle to a Toolhelp snapshot of this process. 
		    hSnapShotm = lpfCreateToolhelp32Snapshot( 
			    TH32CS_SNAPMODULE, procentry.th32ProcessID) ; 
		    if( hSnapShotm == INVALID_HANDLE_VALUE ){ 
				CloseHandle(hSnapShot); 
			    FreeLibrary(hInstLib); 
			    return 704; 
			} 
			// Get the module list for this process 
			modentry.dwSize=sizeof(MODULEENTRY32); 
			bResultm=lpfModule32First(hSnapShotm,&modentry); 
 
			// While there are modules, keep looping and checking 
			while(bResultm){ 
		        if(strcmp(modentry.szModule,szToTermUpper)==0){ 
				    // Process found, now terminate it 
				    iFound=1; 
				    // First open for termination 
				    hProc=OpenProcess(PROCESS_TERMINATE,FALSE,procentry.th32ProcessID); 
				    if(hProc){ 
					    if(TerminateProcess(hProc,0)){ 
						    // process terminated 
							CloseHandle(hSnapShotm); 
							CloseHandle(hSnapShot); 
							CloseHandle(hProc); 
			                FreeLibrary(hInstLib); 
						    return 0; 
						} 
					    else{ 
						    // Unable to terminate process 
							CloseHandle(hSnapShotm); 
							CloseHandle(hSnapShot); 
							CloseHandle(hProc); 
			                FreeLibrary(hInstLib); 
						    return 602; 
						} 
					} 
				    else{ 
					    // Unable to open process for termination 
						CloseHandle(hSnapShotm); 
						CloseHandle(hSnapShot); 
			            FreeLibrary(hInstLib); 
					    return 604; 
					} 
				} 
				else{ 
					// Look for next modules for this process 
					modentry.dwSize=sizeof(MODULEENTRY32); 
					bResultm=lpfModule32Next(hSnapShotm,&modentry); 
				} 
			} 
 
			//Keep looking 
			CloseHandle(hSnapShotm); 
            procentry.dwSize = sizeof(PROCESSENTRY32); 
            bResult = lpfProcess32Next(hSnapShot,&procentry); 
        } 
		CloseHandle(hSnapShot); 
	} 
	if(iFound==0){ 
		FreeLibrary(hInstLib); 
		return 603; 
	} 
	FreeLibrary(hInstLib); 
	return 0; 
} 
 
 
void CBeaconClientDlg::OnEditchangeCombo1() { 
	// TODO: Add your control notification handler code here 
	MessageBox("You cannot edit this field!","H.323 Beacon Client",MB_OK); 
	m_call.SetCurSel(0); 
} 
 
void CBeaconClientDlg::OnButtonClear()  
{ 
	// TODO: Add your control notification handler code here 
	CIPAddressCtrl *pIP = (CIPAddressCtrl *)GetDlgItem(IDC_IPADDRESS1); 
	pIP->ClearAddress(); 
 
	ipglobal = ""; 
} 
 
void CBeaconClientDlg::OnAbout()  
{ 
	// TODO: Add your control notification handler code here 
	CAboutDlg dlgAbout; 
	dlgAbout.DoModal(); 
} 
 
HBRUSH CBeaconClientDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)  
{ 
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); 
	 
	// TODO: Change any attributes of the DC here 
	 
 
	 
	// TODO: Return a different brush if the default is not desired 
	return hbr; 
} 
 
 
CString CBeaconClientDlg::GetTestSessionFolderName() 
{ 
 
	char tmpBuffer[100]; 
 
	CTime startTimeYMDHMS = CTime::GetCurrentTime(); 
	CString startTimeYear; 
	CString startTimeMonth; 
	CString startTimeDay; 
	CString startTimeHour; 
	CString startTimeMinute; 
	CString startTimeSecond; 
 
	startTimeYear = _itoa(startTimeYMDHMS.GetYear(), tmpBuffer, 10); 
	startTimeMonth = _itoa(startTimeYMDHMS.GetMonth(), tmpBuffer, 10); 
	startTimeDay = _itoa(startTimeYMDHMS.GetDay(), tmpBuffer, 10); 
	startTimeHour = _itoa(startTimeYMDHMS.GetHour(), tmpBuffer, 10); 
	startTimeMinute = _itoa(startTimeYMDHMS.GetMinute(), tmpBuffer, 10); 
	startTimeSecond = _itoa(startTimeYMDHMS.GetSecond(), tmpBuffer, 10); 
 
 
	sprintf(startTimeStr,"\\%04s%02s%02s_%02s%02s%02s",startTimeYear,startTimeMonth,startTimeDay, 
                          startTimeHour, startTimeMinute, startTimeSecond); 
 
	return startTimeStr; 
} 
 
void CBeaconClientDlg::OnStatisticsplots()  
{ 
	CDialog* pDlg = new DlgPlots(); 
	//CDialog* pDlg = new CDialog(); 
    pDlg->Create( IDD_STATISTICSPLOT , NULL ); 
    pDlg->ModifyStyleEx( 0 , WS_EX_APPWINDOW ); 
    pDlg->ShowWindow( SW_SHOW ); 
		 
} 
 
void CBeaconClientDlg::OnReport()  
{ 
	// TODO: Add your control notification handler code here 
 
	FILE * fp; 
	CString file; 
 
	if(atoi(SaveResult)==1){ 
		file=  currentTestFolder+"\\TestSummary.txt"; 
	} 
	else { 
		file= "TestSummary.txt"; 
	} 
 
	fp = fopen(file, "w"); 
	//fprintf(fp, "Report File\n"); 
	char *id= new char[260]; 
	CString id1; 
	id1=GetTestSessionFolderName(); 
	strcpy(id,(LPCSTR)id1); 
	id=&id[1]; 
	fprintf(fp,"Test Results Summary for Test ID: %s \n",id); 
	fprintf(fp,"======================================================\n"); 
	fprintf(fp,"\n<<Test Session Information>>\n"); 
	fprintf(fp,"H.323 Beacon Client IP: %s\n",localmachine); 
	fprintf(fp,"H.323 Beacon Server IP: %s\n",ipglobal); 
	fprintf(fp,"Test Session Date: %s\n",sessionDate); 
	fprintf(fp,"Test Session Start Time: %s\n",sessionStartTime); 
	fprintf(fp,"Test Session End Time: %s\n",sessionEndTime); 
	fprintf(fp,"Duration of Test Session: %d:%d:%d\n",DurationHour,DurationMinute,DurationSecond); 
	fprintf(fp,"Codec used during Test Session: %s\n", AudioCodec); 
	fprintf(fp,"Packets Sent during Test Session: %d\n",PacketSentGlobal); 
	fprintf(fp,"Packets Received during Test Session: %d\n",PacketsReceivedGlobal); 
	fprintf(fp,"Octets Send during Test Session: %d\n",OctetSendGlobal); 
	fprintf(fp,"Octets Received during Test Session: %d\n",OctetsReceivedGlobal); 
	fprintf(fp,"Test Session Results Folder Path: %s\n",testsFolderPath); 
	 
	/* 
	Need to think about the logic to include this in Report 
	fprintf(fp,"\n<<Exception Information>>\n"); 
	if(globalEndReason!='\0'){ 
		fprintf(fp,"%s\n",globalEndReason); 
	}else{ 
		fprintf(fp,"Normal Close: Session Terminated by user\n"); 
	}*/ 
 
	//Generate Traceroute to Server 
 
    /*char cmmd[1024]; 
	//strcpy(cmmd,exeFolderPath); 
	//strcat(cmmd, "ftrace -t 15 "); 
	strcpy(cmmd, "tracert -d -h 15 "); 
	//strcpy(cmmd, "-d -h 15 "); 
	strcat(cmmd, ipglobal); 
	strcat(cmmd," > "); 
	//strcat(cmmd,currentTestFolder); 
	strcat(cmmd,"ft_result"); 
	char localTraceRT[2048] = ""; 
 
	//CString cmmd; 
	 
	//cmmd = cmmd +  "ftrace " + ipglobal + " > ft_result"; 
	//cout<< "Trace cmd: "<<cmd<<"\n"; 
	//MessageBox(cmmd); 
	//WinExec (cmmd, SW_HIDE); 
 
	STARTUPINFO         siStartInfo;  
	PROCESS_INFORMATION piProcInfo; 
	// CRS: initialize the STARTUPINFO and call CreateProcess().   
	siStartInfo.cb = sizeof(STARTUPINFO);  
	siStartInfo.lpReserved = NULL;  
	siStartInfo.lpReserved2 = NULL;  
	siStartInfo.cbReserved2 = 0;  
	siStartInfo.lpDesktop = NULL;  
	siStartInfo.dwFlags = STARTF_USESHOWWINDOW; 
	siStartInfo.wShowWindow = SW_SHOWMINIMIZED; 
 
	int bSuccess = CreateProcess(  
		    "tracert",                   // pointer to name of executable module    
			cmmd,                   // pointer to command line string          
			NULL,                   // pointer to process security attributes  
			NULL,                   // pointer to thread security attributes   
			FALSE,                  // handle inheritance flag                 
			0,                      // creation flags                          
			NULL,                   // pointer to new environment block        
			NULL,                   // pointer to current directory name       
			&siStartInfo,           // pointer to STARTUPINFO                  
			&piProcInfo             // pointer to PROCESS_INFORMATION          
			); 
 
 
	 
	// if CreateProcess() failed, print a warning and exit.  
	if ( ! bSuccess ) { 
		MessageBox("Couldnot run tracert command"); 
		//exit(EXIT_FAILURE); 
	}*/ 
 
	//system(cmmd); 
 
	/*char filename[1024]=""; 
	//strcpy(filename,currentTestFolder); 
	strcat(filename,"ft_result"); 
	CFile trp(filename,CFile::modeRead); 
	trp.Read(localTraceRT,2048);*/ 
	 
	 
	fprintf(fp,"\n<<Session Network Statistics Summary>>\n"); 
	fprintf(fp,"Ping Latency\n"); 
	fprintf(fp,"============\n"); 
	fprintf(fp,"Average: N/A\n"); 
	fprintf(fp,"Median: N/A\n"); 
	fprintf(fp,"Standard Deviation: N/A\n"); 
	fprintf(fp,"Min: N/A\n"); 
	fprintf(fp,"Max: N/A\n"); 
	fprintf(fp,"50th Percentile: N/A\n"); 
	fprintf(fp,"90th Percentile: N/A\n"); 
 
	 
	fprintf(fp,"\nCodec Latency\n"); 
	fprintf(fp,"=============\n"); 
	fprintf(fp,"Average: N/A\n"); 
	fprintf(fp,"Median: N/A\n"); 
	fprintf(fp,"Standard Deviation: N/A\n"); 
	fprintf(fp,"Min: N/A\n"); 
	fprintf(fp,"Max: N/A\n"); 
	fprintf(fp,"50th Percentile: N/A\n"); 
	fprintf(fp,"90th Percentile: N/A\n"); 
	 
	fprintf(fp,"\nJitter \n"); 
	fprintf(fp,"======\n"); 
	fprintf(fp,"Average: N/A\n"); 
	fprintf(fp,"Median: N/A\n"); 
	fprintf(fp,"Standard Deviation: N/A\n"); 
	fprintf(fp,"Min: N/A\n"); 
	fprintf(fp,"Max: N/A\n"); 
	fprintf(fp,"50th Percentile: N/A\n"); 
	fprintf(fp,"90th Percentile: N/A\n"); 
 
	 
	fprintf(fp,"\nPacket Loss\n"); 
	fprintf(fp,"===========\n"); 
	fprintf(fp,"Average: N/A\n"); 
	fprintf(fp,"Median: N/A\n"); 
	fprintf(fp,"Standard Deviation: N/A\n"); 
	fprintf(fp,"Min: N/A\n"); 
	fprintf(fp,"Max: N/A\n"); 
	fprintf(fp,"50th Percentile: N/A\n"); 
	fprintf(fp,"90th Percentile: N/A\n"); 
 
	fprintf(fp,"\n<<Other Information>>\n"); 
	fprintf(fp,"Packets Out of Order: N/A\n"); 
	fprintf(fp,"Packets too Late: N/A\n"); 
		 
	/*fprintf(fp,"\nTrace Route from H.323 BeaconClient to H.323 BeaconServer\n"); 
	fprintf(fp,"=========================================================\n"); 
	fprintf(fp,"%s\n",localTraceRT); 
 
	fprintf(fp,"\nTrace Route from H.323 BeaconServer to H.323 BeaconClient\n"); 
	fprintf(fp,"=========================================================\n"); 
	fprintf(fp,"%s\n",TraceRT);*/ 
 
	fclose(fp); 
 
	CString cmd; 
	if(atoi(SaveResult)==1){ 
		cmd= "notepad "+ currentTestFolder+"\\TestSummary.txt"; 
	}else { 
		cmd= "notepad TestSummary.txt"; 
	} 
	WinExec(cmd, SW_SHOW);	 
 
} 
 
/*int CBeaconClientDlg::GetTraceRouteFromServer() 
{ 
	//UINT nport=2000; 
//	char msg[1024]; 
		//CSocketServer SockServer; 
	//SockServer.Create(nPort); 
	//SockServer.Listen(); 
	//SockServer.Receive(msg,20,0); 
 
	  //---------------------- 
  // Initialize Winsock 
  WSADATA wsaData; 
  int iResult = WSAStartup(MAKEWORD(2,2), &wsaData); 
  if (iResult != NO_ERROR) 
    printf("Error at WSAStartup()\n"); 
 
  //---------------------- 
 
   //---------------------- 
  // Create a SOCKET for listening for 
  // incoming connection requests. 
  SOCKET ListenSocket; 
  ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 
  if (ListenSocket == INVALID_SOCKET) { 
    printf("Error at socket(): %ld\n", WSAGetLastError()); 
    WSACleanup(); 
    //return 1; 
  } 
 
  //---------------------- 
 
  //---------------------- 
  // The sockaddr_in structure specifies the address family, 
  // IP address, and port for the socket that is being bound. 
  sockaddr_in service; 
  service.sin_family = AF_INET; 
  service.sin_addr.s_addr = inet_addr("0.0.0.0"); 
  service.sin_port = htons(5051); 
 
  if (bind( ListenSocket, 
    (SOCKADDR*) &service, 
    sizeof(service)) == SOCKET_ERROR) { 
    printf("bind() failed.\n"); 
    closesocket(ListenSocket); 
    //return 1; 
  } 
 
 
  //---------------------- 
  // Listen for incoming connection requests 
  // on the created socket 
  if (listen( ListenSocket, 1 ) == SOCKET_ERROR) 
    consoleStr += "\r\n The TRACEROUTE: Error listening on socket"; 
 
  //---------------------- 
  // Create a SOCKET for accepting incoming requests. 
  SOCKET AcceptSocket; 
  consoleStr += "\r\n The TRACEROUTE: Waiting for client to connect..."; 
 
 
 
  //int nLen = sizeof(SOCKADDR); 
 // char buf[1024]; 
  //int line = 1; 
  
  //FILE *log; 
  //---------------------- 
  // Accept the connection. 
 
  //while(1) { 
	FILE *fp; 
	int flag=0; 
	//int maxDescriptor; 
	fd_set sockSet; 
	//long timeout; 
	struct timeval selTimeout; 
	FD_ZERO(&sockSet); 
	FD_SET(ListenSocket,&sockSet); 
	selTimeout.tv_sec = 10; 
	selTimeout.tv_usec = 0; 
 
	fp= fopen("TRT.report","w"); 
	int ret; 
 
	//AcceptSocket = SOCKET_ERROR; 
	//MessageBox("Before select"); 
	if((ret=select(ListenSocket+1,&sockSet,NULL,NULL,&selTimeout))==SOCKET_ERROR){ 
		//MessageBox("socket Error"); 
		 
	}else if(ret==0){ 
		//MessageBox("Problem getting trace route file from server"); 
		strcpy(TraceRT,"Problem Getting TraceRoute From Server, check if port 5050 is open in your firewall\n"); 
	}else{ 
		if(FD_ISSET(ListenSocket, &sockSet)){ 
			//MessageBox("Connecting to socket"); 
			AcceptSocket = accept( ListenSocket, NULL, NULL ); 
		 
//			consoleStr += "\r\n The TRACEROUTE: Client connected..."; 
			fprintf(fp,"The TRACEROUTE: Client connected...\n"); 
			//Sleep(3000); 
			int recvMsgSize; 
			for (int i=0; i<4;i++){ 
				if((recvMsgSize = recv(AcceptSocket,TraceRT,2048,0))<0){ 
//					consoleStr += "\r\n The TRACEROUTE: Recv failed"; 
					fprintf(fp,"The TRACEROUTE: Recv failed\n"); 
				} 
				else { 
//					consoleStr += "\r\n The TRACEROUTE: REVC Success: "+  *TraceRT ; 
					fprintf(fp,"The TRACEROUTE: REVC Success: %s\n", TraceRT); 
					flag=1; 
					break; 
				} 
			} 
	 
			if(flag==1){ 
//				consoleStr += "\r\n The TRACEROUTE: REVC msg 2 Success: "+  *TraceRT ; 
				fprintf(fp,"The TRACEROUTE: REVC msg 2 Success: %s\n", TraceRT); 
			} 
		 
		} 
		else { 
			//MessageBox("No:socket"); 
			//fprintf(fp,"Problem Getting TraceRoute From Server, check if port 5050 is on your side\n"); 
		} 
	} 
 
	closesocket (AcceptSocket); 
	closesocket (ListenSocket); 
	fclose (fp); 
	WSACleanup(); 
	return flag; 
} 
*/