// UserFileUpdate.cpp : implementation file // #include "stdafx.h" #include "udpadmintool.h" #include "UserFileUpdate.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include "util.hpp" #include "util_path.hpp" #include "util_local.h" ///////////////////////////////////////////////////////////////////////////// // CUserFileUpdate dialog CUserFileUpdate::CUserFileUpdate(CWnd* pParent /*=NULL*/) : CDialog(CUserFileUpdate::IDD, pParent) { //{{AFX_DATA_INIT(CUserFileUpdate) m_edSelectIP = _T(""); m_sedBrowse = _T(""); //}}AFX_DATA_INIT } void CUserFileUpdate::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CUserFileUpdate) DDX_Text(pDX, IDC_EDIT_SELECT_IP, m_edSelectIP); DDX_Text(pDX, IDC_EDIT_BROWSE, m_sedBrowse); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CUserFileUpdate, CDialog) //{{AFX_MSG_MAP(CUserFileUpdate) ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse) ON_BN_CLICKED(IDC_BUTTON_UPDATE, OnButtonUpdate) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CUserFileUpdate message handlers void CUserFileUpdate::OnButtonBrowse() { // TODO: Add your control notification handler code here char szFilter[30]; sprintf(szFilter, "IMAGE File|*.*||"); UpdateData(); CString path; //GetDlgItem(IDC_EDIT_BROWSE)->GetWindowText(path); path = m_sedBrowse; CFileDialog dlgOpen(TRUE, NULL, path, OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST, szFilter,this); // Open dialog dlgOpen.m_ofn.lpstrTitle = _T("Select files to burn"); // Select and add files if(IDOK == dlgOpen.DoModal()) { // m_bFile=true; CString dlg_path = dlgOpen.GetPathName(); // m_sFilePath = dlg_path; // m_sFileName = dlg_path; // GetDlgItem(IDC_EDIT_BROWSE)->SetWindowText(m_sFilePath); UpdateData(); m_sedBrowse = dlg_path; UpdateData(FALSE); theApp.set_userfile_path(dlg_path); // registry } } void CUserFileUpdate::OnButtonUpdate() { // TODO: Add your control notification handler code here char savePath[50]; UpdateData(); if(m_sedBrowse != "") { GetDlgItem(IDC_EDIT_SAVEFILEPATH)->GetWindowText(savePath, 50); if(strlen(savePath) < 5) { AfxMessageBox("Save Path Error!"); return; } GetDlgItem(IDC_BUTTON_BROWSE)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_UPDATE)->EnableWindow(FALSE); GetDlgItem(IDOK)->EnableWindow(FALSE); // send CString filename = path_name(m_sedBrowse); // get file name if(SingleFileUpdate(theApp.m_info.sIp, TO_STR(m_sedBrowse), TO_STR(filename), savePath, 0x20)) AfxMessageBox("User File Update complete"); else AfxMessageBox("User File Update fail"); } else AfxMessageBox("Not File Select ", MB_ICONEXCLAMATION); GetDlgItem(IDC_BUTTON_BROWSE)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_UPDATE)->EnableWindow(TRUE); GetDlgItem(IDOK)->EnableWindow(TRUE); } BOOL CUserFileUpdate::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); } BOOL CUserFileUpdate::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here UpdateData(); m_edSelectIP = theApp.GetSelectDeviceName(); UpdateData(FALSE); int i, flag=0; char temp[5]; memset(temp, 0x00, sizeof(temp)); 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)<=369) { AfxMessageBox("This firmware does not support \"ActiveX upload\" function."); OnOK(); } break; } } } if(i>45) { AfxMessageBox("This firmware does not support \"ActiveX upload\" function."); OnOK(); } CString path = theApp.get_userfile_path(); // registry UpdateData(); m_sedBrowse = path; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }