// NickName.cpp : implementation file // #include "stdafx.h" #include "udpadmintool.h" #include "NickName.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include "login.h" #include "message.h" ///////////////////////////////////////////////////////////////////////////// // CNickName dialog CNickName::CNickName(CWnd* pParent /*=NULL*/) : CDialog(CNickName::IDD, pParent) { //{{AFX_DATA_INIT(CNickName) m_sNewName = _T(""); m_edSelectIP = _T(""); //}}AFX_DATA_INIT } void CNickName::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CNickName) DDX_Text(pDX, IDC_EDIT_NEWNAME, m_sNewName); DDX_Text(pDX, IDC_EDIT_SELECT_IP, m_edSelectIP); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CNickName, CDialog) //{{AFX_MSG_MAP(CNickName) ON_BN_CLICKED(IDC_BUTTON_SETUP, OnButtonSetup) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CNickName message handlers void CNickName::OnButtonSetup() { // TODO: Add your control notification handler code here char newName[64]; UpdateData(TRUE); for(int login = 0; login <= 3; ++login) { // kernel version check char id[1024] = {0,}; char pw_hash[16] = {0,}; char out_mac[1024]; // firmware¹öÁ¯À» ±âÁØÀ¸·Î ·Î±×ÀÎÀÌ ÇÊ¿äÇÑÁö ¿©ºÎ¸¦ ÆÇ´ÜÇÏ°í, // ÇÊ¿äÇÑ °æ¿ì id¿Í md5(md5(id+pw)+mac)°ªÀ» ¾ò¾î¿É´Ï´Ù. - cjy, 07_1203 16:21 int hr = proc_login(theApp.m_info.FirmwareVersion, theApp.m_info.MAC, theApp.GetSelectDeviceName(), theApp.m_info.sIp, id, pw_hash, out_mac); if(hr <= 0) { // cancel return; } sprintf(newName, m_sNewName); hr = CtrlDeviceEx(theApp.m_info.sIp, id, pw_hash, 0x30, (unsigned char *)newName, m_sNewName.GetLength()); if(hr <= 0) { // login °ü·Ã ¿À·ù´Â ´Ù½Ã ½ÃµµÇÕ´Ï´Ù. // -1041: broken packet received // -1042: access level lowwer than request operation // -1043: not match pw // -1061: not exists user id // -167: it's need login process switch(hr) { case -1042: // access level error AfxMessageBox(MSG_LOGIN_ACCESS_LEVEL); theApp.clear_login_info(); continue; case -1043: // not match pw AfxMessageBox(MSG_LOGIN_NOT_MATCH_PW); theApp.clear_login_info(); continue; case -1061: // not exists user id AfxMessageBox(MSG_LOGIN_NOT_EXISTS_USER); theApp.clear_login_info(); continue; } //AfxMessageBox("Failed to change Ip Address", MB_ICONEXCLAMATION); CString msg; msg.Format("Failed to change Network configuration with error[%d]", hr); AfxMessageBox(msg, MB_ICONEXCLAMATION); return; } // success break; } AfxMessageBox("Changing hostname completed"); } BOOL CNickName::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here // device name UpdateData(); m_edSelectIP = theApp.GetSelectDeviceName(); UpdateData(FALSE); // check firmware version int i, flag = 0; char temp[5]; memset(temp, 0x00, sizeof(temp)); // È£½ºÆ® ³×ÀÓÀº Ä¿³Î 326ÀÌ»óºÎÅÍ Áö¿øÇÕ´Ï´Ù. for(i = 0; i < 50; i++) { if(theApp.m_info.FirmwareVersion[i] == '.') { flag++; if(flag == 2) { memcpy(temp, &theApp.m_info.FirmwareVersion[i+1], 3); if(atoi(temp) < 326) { AfxMessageBox("This firmware does not support \"Hostname\" function."); OnOK(); } break; } } } if(i>45) { AfxMessageBox("This firmware does not support \"Hostname\" function."); OnOK(); } // nickname GetDlgItem(IDC_EDIT_OLDNAME)->SetWindowText(theApp.m_info.NickName); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } BOOL CNickName::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if(pMsg->wParam == VK_RETURN) { return TRUE; } return CDialog::PreTranslateMessage(pMsg); }