// PageSystemMgr.cpp : implementation file // #include "stdafx.h" #include "mgrnve.h" #include "ConnectionManager.h" #include "PageSystemMgr.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPageSystemMgr dialog CPageSystemMgr::CPageSystemMgr(CWnd* pParent, CMgrNVE* pMgrCM, CConnectionManager *pConnMgr) : CParamDlg(CPageSystemMgr::IDD, pParent, pMgrCM, pConnMgr) { //{{AFX_DATA_INIT(CPageSystemMgr) m_strName = _T(""); m_strTime = _T(""); //}}AFX_DATA_INIT m_pNet5Api = NULL; m_pMsgMgr = NULL; } void CPageSystemMgr::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPageSystemMgr) DDX_Control(pDX, IDC_CB_SECURITY, m_cbSecurity); DDX_Control(pDX, IDC_CB_SAVE_MODE, m_cbSaveMode); DDX_Text(pDX, IDC_EDIT_NAME, m_strName); DDX_Text(pDX, IDC_EDIT_TIME, m_strTime); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPageSystemMgr, CDialog) //{{AFX_MSG_MAP(CPageSystemMgr) ON_BN_CLICKED(IDC_BTN_INFO_SET, OnBtnInfoSet) ON_BN_CLICKED(IDC_BTN_RESTART, OnBtnRestart) ON_BN_CLICKED(IDC_BTN_DEFAULT, OnBtnDefault) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPageSystemMgr message handlers BOOL CPageSystemMgr::SaveSetting() { return TRUE; } BOOL CPageSystemMgr::ResetSetting() { return TRUE; } BOOL CPageSystemMgr::UpdateSetting() { return TRUE; } void CPageSystemMgr::GetInfo() { // TODO: Add your control notification handler code here char szName[NVE_MAX_STR_LENGTH]; SYSTEMTIME SysTime; CMN5_BOARD_INFO_DESC Desc; NET5_VERSION_INFO Version; CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_GET_SYSTEM_NAME, (ULONG*)szName, NULL, NULL, NULL), "Cannot get system name"); CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_GET_SYSTEM_TIME, (ULONG*)&SysTime, NULL, NULL, NULL), "Cannot get system time"); Desc.uInfoVersion = 1; Desc.uInfoSize = sizeof(Version); CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_GET_VERSION, (ULONG*)&Desc, (ULONG*)&Version, NULL, NULL), "Cannot get version"); m_strName = szName; m_strTime.Format("%04d-%02d-%02d %02d:%02d:%02d", SysTime.wYear, SysTime.wMonth, SysTime.wDay, SysTime.wHour, SysTime.wMinute, SysTime.wSecond); UpdateData(FALSE); } void CPageSystemMgr::OnBtnInfoSet() { // TODO: Add your control notification handler code here char szName[NVE_MAX_STR_LENGTH]; SYSTEMTIME Time; UpdateData(TRUE); strcpy(szName, (LPSTR)(LPCSTR)m_strName); GetSystemTime(&Time); CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_SET_SYSTEM_NAME, (ULONG*)szName, NULL, NULL, NULL), "Cannot set system name"); CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_SET_SYSTEM_TIME, (ULONG*)&Time, NULL, NULL, NULL), "Cannot set system time"); char szCmd[NVE_MAX_EXT_CMD_LENGTH]; char szSaveMode[NVE_SHORT_STR_LENGTH], szLoginMode[NVE_SHORT_STR_LENGTH]; switch(m_cbSaveMode.GetCurSel()) { case 0: safe_strcpy(szSaveMode, "auto"); break; case 1: safe_strcpy(szSaveMode, "manual"); break; } switch(m_cbSecurity.GetCurSel()) { case 0: safe_strcpy(szLoginMode, "open"); break; case 1: safe_strcpy(szLoginMode, "login_only"); break; case 2: safe_strcpy(szLoginMode, "login_access"); break; } _snprintf(szCmd, sizeof(szCmd), "EXT_CMD %s/ RTSP/1.0\r\n" "CSeq: 1\r\n" "CmdCount: 1\r\n" "SET SYSTEM_MGR save_mode=\"%s\", login_mode=\"%s\"\r\n\r\n", m_pConnection->GetServerAddr(), szSaveMode, szLoginMode); CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_SEND_RTSP_REQUEST, (ULONG*)szCmd, NULL, NULL, NULL), "Cannot set system management info"); CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_RECV_RTSP_RESPONSE, (ULONG*)szCmd, NULL, NULL, NULL), "Cannot receive response(system management)"); } void CPageSystemMgr::OnBtnRestart() { // TODO: Add your control notification handler code here CHECK_AND_RETURN(m_pNet5Api->Net5Command(NET5_NC_RESTART, NULL, NULL, NULL, NULL), "Cannot set restart server"); } BOOL CPageSystemMgr::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_pNet5Api = m_pConnection->GetNet5Api(); m_pMsgMgr = m_pMgrNVE->GetMsgManager(); m_cbSaveMode.AddString("AUTO"); m_cbSaveMode.AddString("MANUAL"); m_cbSecurity.AddString("OPEN"); m_cbSecurity.AddString("LOGIN_ONLY"); m_cbSecurity.AddString("LOGIN_ACCESS"); char szCmd[NVE_MAX_EXT_CMD_LENGTH]; char szValue[NVE_SHORT_STR_LENGTH]; _snprintf(szCmd, sizeof(szCmd), "EXT_CMD %s/ RTSP/1.0\r\n" "CSeq: 1\r\n" "CmdCount: 1\r\n" "GET SYSTEM_MGR save_mode, login_mode\r\n\r\n", m_pConnection->GetServerAddr()); CHECK_AND_RETURN_FALSE(m_pNet5Api->Net5Command(NET5_NC_SEND_RTSP_REQUEST, (ULONG*)szCmd, NULL, NULL, NULL), "Cannot get system management info"); CHECK_AND_RETURN_FALSE(m_pNet5Api->Net5Command(NET5_NC_RECV_RTSP_RESPONSE, (ULONG*)szCmd, NULL, NULL, NULL), "Cannot receive response(system management)"); ParseRTSPResponse(szCmd, m_RtspValue, NVE_MAX_RTSP_VALUE); FindRTSPValue(m_RtspValue, "save_mode", szValue, NVE_RTSP_VALUE_STR); if (strcmp(szValue, "auto") == 0) { m_cbSaveMode.SetCurSel(0); } else if (strcmp(szValue, "manual") == 0) { m_cbSaveMode.SetCurSel(1); } FindRTSPValue(m_RtspValue, "login_mode", szValue, NVE_RTSP_VALUE_STR); if (strcmp(szValue, "open") == 0) { m_cbSecurity.SetCurSel(0); } else if (strcmp(szValue, "login_only") == 0) { m_cbSecurity.SetCurSel(1); } else if (strcmp(szValue, "login_access") == 0) { m_cbSecurity.SetCurSel(2); } GetInfo(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CPageSystemMgr::OnBtnDefault() { // TODO: Add your control notification handler code here ULONG uValue = 1; m_pNet5Api->Net5Command(NET5_NC_FACTORY_DEFAULT, &uValue, NULL, NULL, NULL); }