// DlgInputMac.cpp : implementation file // #include "stdafx.h" #include "udpadmintool.h" #include "DlgInputMac.h" #include "./util_source/util.hpp" #include "util_param.h" #include "DlgWebLogin.h" /* #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif */ ///////////////////////////////////////////////////////////////////////////// // CDlgInputMac dialog CDlgInputMac::CDlgInputMac(CWnd* pParent /*=NULL*/) : CDialog(CDlgInputMac::IDD, pParent) { //{{AFX_DATA_INIT(CDlgInputMac) m_sEdMac = _T(""); m_sEdSelectIP = _T(""); //}}AFX_DATA_INIT } void CDlgInputMac::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgInputMac) DDX_Text(pDX, IDC_EDIT_MAC, m_sEdMac); DDV_MaxChars(pDX, m_sEdMac, 17); DDX_Text(pDX, IDC_EDIT_SELECT_IP, m_sEdSelectIP); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDlgInputMac, CDialog) //{{AFX_MSG_MAP(CDlgInputMac) ON_BN_CLICKED(IDC_BUTTON_QUERY_MAC, OnButtonQueryMac) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDlgInputMac message handlers void CDlgInputMac::OnOK() { // TODO: Add extra validation here // ÀԷ¹ÞÀº MACÀÌ Á¤»óÀûÀÎ MACÀΰ¡? UpdateData(); if(m_sEdMac.GetLength() != 17) { warn("Invalid Mac address"); return; } if(m_sEdMac[2] != ':' || m_sEdMac[5] != ':' || m_sEdMac[8] != ':' || m_sEdMac[11] != ':' || m_sEdMac[14] != ':' ) { warn("Invalid Mac address"); return; } //strcpy(m_out_mac, m_sEdMac); CDialog::OnOK(); } void CDlgInputMac::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel(); } void CDlgInputMac::OnButtonQueryMac() { // TODO: Add your control notification handler code here // cgi call char id[1024]; char pw[1024]; char mac[1024]; int web_port; // input login info CDlgWebLogin dlg; dlg.m_nWebPort = atoi(theApp.m_info.HTTP); if(dlg.DoModal() != IDOK) { return; } //strcpy(id, "root"); //strcpy(pw, "pass"); strcpy(id, dlg.m_sEdID); strcpy(pw, dlg.m_sEdPW); web_port = dlg.m_nWebPort; // query // param.cgi¿¡¼­ ¾òÀº Äõ¸®¿¡¼­ keyword¿¡ ÇØ´çÇÏ´Â °ªÀ» ¾ò¾î¿Â´Ù. ´ÜÀÏ Äõ¸®¸¸ »ç¿ë°¡´É //int get_param_one(IN const char* url, IN const char* id, IN const char* pw, // IN const char* keyword, OUT char* out_buf, IN int out_buf_size); char url[1024]; sprintf(url, "%s:%d", theApp.m_info.sIp, web_port); // int hr = get_param_one(theApp.m_info.sIp, id, pw, "Network.eth0.MACAddress", // mac, sizeof(mac)); int hr = get_param_one(url, id, pw, "Network.eth0.MACAddress", mac, sizeof(mac)); if(hr <= 0) { warn("Failed to query mac address with error(%d)", hr); return; } m_sEdMac = mac; UpdateData(FALSE); // OnOK(); } BOOL CDlgInputMac::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here // device ip address UpdateData(); m_sEdSelectIP = theApp.GetSelectDeviceName(); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }