// MainDlg.cpp : implementation of the CMobileDlg class // ///////////////////////////////////////////////////////////////////////////// #include "stdafx2.h" #include "resource.h" #include "MobileDlg.h" #include #define WND_CHILD_HEIGHT 197 #define WND_CHILD_WIDTH 402 #define WND_LARGE_SIZE_X 432 #define WND_LARGE_SIZE_Y 663 #define WND_CHILD_2_HEIGHT 168 #define WND_SMALL_SIZE_X WND_LARGE_SIZE_X #define WND_SMALL_SIZE_Y (WND_LARGE_SIZE_Y - WND_CHILD_HEIGHT) #define WND_SMALL_2_SIZE_Y (WND_LARGE_SIZE_Y - WND_CHILD_2_HEIGHT) #define MOVE_CHILD_CONTROL(nID) \ do{ \ GetDlgItem(nID).GetWindowRect(&rect); \ ScreenToClient(&rect); \ rect.top += nY; \ rect.bottom += nY; \ GetDlgItem(nID).MoveWindow(&rect); \ }while(false) static UINT statuspanes[] = { ID_STATUSBAR_CONSTATUS, ID_STATUSBAR_MODE, ID_STATUSBAR_SIGNAL }; static HANDLE FindProcessByName(const char *pProcessName) { PROCESSENTRY32 pe32; pe32.dwSize = sizeof(pe32); HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); BOOL bMore = ::Process32First(hProcessSnap, &pe32); while (bMore) { if (_stricmp(pProcessName, pe32.szExeFile) == 0) { return OpenProcess(PROCESS_TERMINATE, FALSE, pe32.th32ProcessID); } bMore = ::Process32Next(hProcessSnap, &pe32); } return NULL; } CMobileDlg::CMobileDlg(CMobileDialEntity* pEntity) : m_pEntity(pEntity), m_bConnected(false),m_nGenType(3),m_nReversedType(3),m_nWhoConnected(0),m_localSIM(TRUE),m_dongleType(0) //,m_cw1(this, 1), m_cw2(this, 1), m_cw3(this, 1), m_cw4(this, 1), m_cw5(this, 1), m_cw6(this, 1) { m_sMBBParam.connectType = 0; m_sReverseMBBParam.connectType = 0; } CMobileDlg::~CMobileDlg() {} HBRUSH CMobileDlg::OnCtlColorStatic(CDCHandle dc, CStatic wndStatic) { if (GetDlgItem(IDC_STATIC_TXT_WARN).m_hWnd == wndStatic.m_hWnd) { dc.SetTextColor(RGB(255, 0, 0)); dc.SetBkColor(RGB(195, 195, 195)); return (HBRUSH)GetStockObject(LTGRAY_BRUSH); } else { SetMsgHandled(FALSE); return 0; } } void CMobileDlg::SetDlgSizeToSmall(void) { SetWindowPos(NULL, 0, 0, WND_SMALL_SIZE_X, WND_SMALL_SIZE_Y, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); ShowProfileCreateCtrl(FALSE); CloseVirtualKeyboard(); m_btnExpand.SetWindowText("管理配置"); } void CMobileDlg::SetDlgSizeToLarge(void) { SetWindowPos(NULL, 0, 0, WND_LARGE_SIZE_X, WND_LARGE_SIZE_Y, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); ShowProfileCreateCtrl(TRUE); m_btnExpand.SetWindowText("▲"); } void CMobileDlg::HideRedundance(void) { SetWindowPos(NULL, 0, 0, WND_LARGE_SIZE_X, WND_SMALL_2_SIZE_Y, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); ////////////////////////////////////////////////////////////////////////// GetDlgItem(IDC_STATIC_CONNECT).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_DONGLE).ShowWindow(FALSE); GetDlgItem(IDC_COMBO_DONGLE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_GTYPE).ShowWindow(FALSE); GetDlgItem(IDC_COMBO_GTYPE).ShowWindow(FALSE); GetDlgItem(IDC_BUTTON_CONNECT).ShowWindow(FALSE); GetDlgItem(IDC_BUTTON_EXPAND).ShowWindow(FALSE); GetDlgItem(IDC_COMBO_PROFILES).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_PROFILE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_CARD).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_PORT).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_PORT).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_IMEI).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_IMEI).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_MANUFACTURER).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_MANUFACTURER).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_HARDWARE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_HARDWARE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_MODEL).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_MODEL).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_DATACLASS).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_DATACLASS).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_FIRMWARE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_FIRMWARE).ShowWindow(FALSE); MoveDlgItems(FALSE); } void CMobileDlg::MoveDlgItems(BOOL bShow) { RECT rect; int nY = bShow ? WND_CHILD_HEIGHT : -WND_CHILD_HEIGHT; #if 1 MOVE_CHILD_CONTROL(IDC_STATIC_CARD); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_PORT); MOVE_CHILD_CONTROL(IDC_STATIC_PORT); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_IMEI); MOVE_CHILD_CONTROL(IDC_STATIC_IMEI); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_MANUFACTURER); MOVE_CHILD_CONTROL(IDC_STATIC_MANUFACTURER); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_HARDWARE); MOVE_CHILD_CONTROL(IDC_STATIC_HARDWARE); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_MODEL); MOVE_CHILD_CONTROL(IDC_STATIC_MODEL); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_DATACLASS); MOVE_CHILD_CONTROL(IDC_STATIC_DATACLASS); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_FIRMWARE); MOVE_CHILD_CONTROL(IDC_STATIC_FIRMWARE); MOVE_CHILD_CONTROL(IDC_STATIC_ADD); MOVE_CHILD_CONTROL(IDC_BUTTON_QUIT); MOVE_CHILD_CONTROL(IDC_BUTTON_DEFAULT_CONNECT); MOVE_CHILD_CONTROL(IDC_STATIC_MBB); MOVE_CHILD_CONTROL(IDC_CHECK_MNTBYRVC); MOVE_CHILD_CONTROL(IDC_STATIC_ADVANCED); MOVE_CHILD_CONTROL(IDC_RADIO_3G); MOVE_CHILD_CONTROL(IDC_RADIO_4G); MOVE_CHILD_CONTROL(IDC_RADIO_DEFAULT); MOVE_CHILD_CONTROL(IDC_RADIO_WEB); MOVE_CHILD_CONTROL(IDC_RADIO_MBB_WIRE); MOVE_CHILD_CONTROL(IDC_RADIO_MBB_WLAN); MOVE_CHILD_CONTROL(IDC_BUTTON_MBB_CONFIG); MOVE_CHILD_CONTROL(IDC_EDIT_PHONENUM); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_PAP); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_CHAP); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_MSCHAPV2); #else if(m_localSIM) { MOVE_CHILD_CONTROL(IDC_STATIC_CARD); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_PORT); MOVE_CHILD_CONTROL(IDC_STATIC_PORT); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_IMEI); MOVE_CHILD_CONTROL(IDC_STATIC_IMEI); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_MANUFACTURER); MOVE_CHILD_CONTROL(IDC_STATIC_MANUFACTURER); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_HARDWARE); MOVE_CHILD_CONTROL(IDC_STATIC_HARDWARE); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_MODEL); MOVE_CHILD_CONTROL(IDC_STATIC_MODEL); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_DATACLASS); MOVE_CHILD_CONTROL(IDC_STATIC_DATACLASS); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_FIRMWARE); MOVE_CHILD_CONTROL(IDC_STATIC_FIRMWARE); MOVE_CHILD_CONTROL(IDC_STATIC_ADD); MOVE_CHILD_CONTROL(IDC_BUTTON_QUIT); MOVE_CHILD_CONTROL(IDC_BUTTON_DEFAULT_CONNECT); MOVE_CHILD_CONTROL(IDC_STATIC_MBB); MOVE_CHILD_CONTROL(IDC_CHECK_MNTBYRVC); MOVE_CHILD_CONTROL(IDC_STATIC_ADVANCED); MOVE_CHILD_CONTROL(IDC_RADIO_3G); MOVE_CHILD_CONTROL(IDC_RADIO_4G); MOVE_CHILD_CONTROL(IDC_RADIO_DEFAULT); MOVE_CHILD_CONTROL(IDC_EDIT_PHONENUM); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_PAP); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_CHAP); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_MSCHAPV2); } else { nY = bShow ? WND_CHILD_2_HEIGHT/2 : -WND_CHILD_2_HEIGHT/2; MOVE_CHILD_CONTROL(IDC_STATIC_LOGIN); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_PROFILENAME); MOVE_CHILD_CONTROL(IDC_EDIT_PROFILE); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_APN); MOVE_CHILD_CONTROL(IDC_EDIT_APN); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_USER); MOVE_CHILD_CONTROL(IDC_EDIT_USER); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_PASSWORD); MOVE_CHILD_CONTROL(IDC_EDIT_PASSWORD); MOVE_CHILD_CONTROL(IDC_CHECK_VIEW_PASSWORD); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_MODE); MOVE_CHILD_CONTROL(IDC_COMBO_CON_MODE); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_IPTYPE); MOVE_CHILD_CONTROL(IDC_COMBO_CON_IPTYPE); MOVE_CHILD_CONTROL(IDC_STATIC_TXT_POINTTYPE); MOVE_CHILD_CONTROL(IDC_COMBO_PONT_TYPE); MOVE_CHILD_CONTROL(IDC_CHECK_APN_APPLY); MOVE_CHILD_CONTROL(IDC_BUTTON_APN_STORE); //MOVE_CHILD_CONTROL(IDC_BUTTON_DROPUP); MOVE_CHILD_CONTROL(IDC_BUTTON_CLEAR); MOVE_CHILD_CONTROL(IDC_BUTTON_DELETE); MOVE_CHILD_CONTROL(IDC_EDIT_PHONENUM); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_PAP); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_CHAP); MOVE_CHILD_CONTROL(IDC_CHECK_RASIO_MSCHAPV2); nY += (bShow ? WND_CHILD_2_HEIGHT/2 : -WND_CHILD_2_HEIGHT/2); MOVE_CHILD_CONTROL(IDC_STATIC_ADD); MOVE_CHILD_CONTROL(IDC_BUTTON_QUIT); MOVE_CHILD_CONTROL(IDC_BUTTON_DEFAULT_CONNECT); MOVE_CHILD_CONTROL(IDC_STATIC_MBB); MOVE_CHILD_CONTROL(IDC_CHECK_MNTBYRVC); MOVE_CHILD_CONTROL(IDC_STATIC_ADVANCED); MOVE_CHILD_CONTROL(IDC_RADIO_3G); MOVE_CHILD_CONTROL(IDC_RADIO_4G); MOVE_CHILD_CONTROL(IDC_RADIO_DEFAULT); MOVE_CHILD_CONTROL(IDC_RADIO_WEB); } #endif } LRESULT CMobileDlg::OnSignalChanged(UINT uMsg, WPARAM wParam, LPARAM lParam) { if(m_bConnected) { CSimpleStringA csStrength("NA"); if(lParam != 0xFFFFFFFF) { if(m_nWhoConnected == CNT_MBN) { csStrength = CSimpleStringA::Format("%2.0lf%%", 100.0*(double)lParam/31.0); } else if(m_nWhoConnected == CNT_MBB) { csStrength = CSimpleStringA::Format("%2.0lf%%", (double)lParam); } } SetDlgItemTextA(IDC_STATIC_PERCENTAGE, (LPCTSTR)csStrength); } return 0; } LRESULT CMobileDlg::OnDeviceChanged(UINT uMsg, WPARAM wParam, LPARAM lParam) { if(uMsg == WM_DONGLE_CHANGE) { Dbg("receive WM_DONGLE_CHANGE message"); UpdateDongles(); } return 0; } LRESULT CMobileDlg::OnFatalMsgChanged(UINT uMsg, WPARAM wParam, LPARAM lParam) { if(WM_FATALMESSAGE_CHANGE == uMsg) { if(wParam != 0 && lParam != 0) { CStatic edit = (CStatic)this->GetDlgItem(IDC_STATIC_TXT_WARN); CDC cdc(edit.GetDC()); SIZE sz; if(cdc.GetTextExtent((LPCTSTR)lParam, strlen((LPCTSTR)lParam), &sz)) { RECT stRect; edit.GetWindowRect(&stRect); int post = stRect.left + (stRect.right - stRect.left) / 2; stRect.left = post - sz.cx / 2; stRect.right = post + sz.cx / 2; //stRect.left = stRect.right - sz.cx; this->ScreenToClient(&stRect); edit.MoveWindow(&stRect); edit.GetWindowRect(&stRect); this->ScreenToClient(&stRect); this->InvalidateRect(&stRect); } SetDlgItemTextA(IDC_STATIC_TXT_WARN, (LPCTSTR)lParam); GetDlgItem(IDC_STATIC_TXT_WARN).ShowWindow(SW_SHOW); } else { SetDlgItemTextA(IDC_STATIC_TXT_WARN, ""); GetDlgItem(IDC_STATIC_TXT_WARN).ShowWindow(SW_HIDE); } } return 0; } LRESULT CMobileDlg::OnWlanConnectResult(UINT uMsg, WPARAM wParam, LPARAM lParam) { if(WM_CONNECT_WLAN_RESULT == uMsg) { auto rc = (ErrorCodeEnum)wParam; LeaveProgressBar(); if (rc != Error_Succeed){ MessageBoxA(CSimpleStringA::Format("连接失败: %s", m_pEntity->GetLastErrMsg())); } else { MessageBoxA("连接成功!"); } } return 0; } LRESULT CMobileDlg::OnProfileResult(UINT uMsg, WPARAM wParam, LPARAM lParam) { auto rc = (ErrorCodeEnum)wParam; LeaveProgressBar(); if (rc != Error_Succeed){ if(lParam == 0) { MessageBoxA(CSimpleStringA::Format("操作失败: %s", m_pEntity->GetLastErrMsg())); } } else { BOOL bApply = m_btnApply.GetCheck(); BOOL bApplyOld = bApply; if(uMsg == WM_DELETE_PROFILE_RESULT) { bApply = FALSE; } if(m_bConnected) { if(/*FALSE && */!IsDlgButtonChecked(IDC_CHECK_MNTBYRVC)) { //停掉连接状态 SendMessageA(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_CONNECT, BN_CLICKED), NULL); } else if(bApply) { bApply = FALSE; Dbg("Because still connected..."); } } CSimpleStringA strDongle; int nIndex = GetInterfaceIdInCombo(strDongle); if(nIndex >= 0 && strDongle.GetLength() > 0) { assert(g_DongleInfos.GetCount() > nIndex); if(m_localSIM) { //assert((m_bConnected && g_DongleInfos[nIndex].subInfo.mbnCntState == MBN_ACTIVATION_STATE_ACTIVATED ) // || (!m_bConnected && g_DongleInfos[nIndex].subInfo.mbnCntState != MBN_ACTIVATION_STATE_ACTIVATED)); } else { /* int nCntType = m_comboCntType.GetCurSel(); for(int i=0; iUpdateProfileInfo(nIndex)) { m_comboProfiles.ResetContent(); const MBNProfileList& info = g_DongleInfos[nIndex].profileList; if(info.GetCount() > 0) { int aim = 0; Dbg("connected: %d", m_bConnected ? 1 : 0); for(int i=0; i 0) { Dbg("profileName: %s", (LPCTSTR)g_DongleInfos[nIndex].subInfo.strProfileName); if(!g_DongleInfos[nIndex].subInfo.strProfileName.Compare(info[i].strProfileName)) { Dbg("selected2: %d", i); aim = i; } } } m_comboProfiles.SetCurSel(aim); //BOOL bEmpty = TRUE; //OnCbnSelchangeComboProfiles(NULL, NULL, NULL, bEmpty); } } else { MessageBoxA("更新配置文件列表失败,请重新打开配置窗口!"); EndDialog(-1); return 0; } } if(uMsg == WM_ADD_PROFILE_RESULT && lParam == 0) { PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_EXPAND, BN_CLICKED), NULL); MessageBoxA("添加配置成功!"); PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_EXPAND, BN_CLICKED), NULL); } else if(uMsg == WM_DELETE_PROFILE_RESULT && lParam == 0) { PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_EXPAND, BN_CLICKED), NULL); MessageBoxA("删除配置成功!"); PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_EXPAND, BN_CLICKED), NULL); } else if(uMsg == WM_UPDATE_PROFILE_RESULT && lParam == 0) { PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_EXPAND, BN_CLICKED), NULL); MessageBoxA("更新配置成功!"); PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_EXPAND, BN_CLICKED), NULL); } } return 0; } LRESULT CMobileDlg::OnConnectResult(UINT uMsg, WPARAM wParam, LPARAM lParam) { Dbg("Receive OnConnectResult msg : %d", lParam); auto rc = (ErrorCodeEnum)wParam; if(uMsg != WM_TIMER_SWITCH) { if(m_bConnected) { return 0; } LeaveProgressBar(WM_TIMER_CONNECT); } if(lParam > 0) { if (rc != Error_Succeed) { if(uMsg != WM_TIMER_SWITCH) { MessageBoxA(CSimpleStringA::Format("拨号失败: %s", m_pEntity->GetLastErrMsg())); } else { MessageBoxA(CSimpleStringA::Format("切换数据卡失败: %s", m_pEntity->GetLastErrMsg())); } } else {//拨号成功或切换数据卡成功 CSimpleStringA strDongle; int nIndex = GetInterfaceIdInCombo(strDongle); if(nIndex >= 0) { ATLASSERT(nIndex >= 0 && strDongle.GetLength() > 0); if(m_pEntity->UpdateSubInfo(nIndex)) { Dbg("%d vs %d", nIndex, g_DongleInfos.GetCount()); ATLASSERT(g_DongleInfos.GetCount() > nIndex); if(uMsg == WM_TIMER_SWITCH) { if(g_DongleInfos[nIndex].priority > 0) { m_btnConnect.SetWindowTextA("已应用"); m_btnConnect.EnableWindow(FALSE); MessageBoxA("切换成功!"); //TODO if(m_nWhoConnected == CNT_INVALID || !m_bConnected) { OnFatalMsgChanged(WM_FATALMESSAGE_CHANGE, Error_Succeed, NULL); } } else { m_btnConnect.SetWindowTextA("应用"); m_btnConnect.EnableWindow(TRUE); MessageBoxA("切换成功,请重新打开窗口!"); EndDialog(-1); } } else {//拨号成功 //BOOL fDefault = FALSE; //OnCbnSelchangeComboDongle(NULL, NULL, NULL, fDefault); if(g_DongleInfos[nIndex].subInfo.mbnCntState == MBN_ACTIVATION_STATE_ACTIVATED) { if(g_DongleInfos[nIndex].usDeviceType & DEVTYPE_ANDROID_UKNOWN) { TriggerConnectState(CNT_ANDROID); } else if(g_DongleInfos[nIndex].usDeviceType == DEVTYPE_MODEM) { TriggerConnectState(CNT_RAS); } else if(g_DongleInfos[nIndex].usDeviceType == DEVTYPE_MBB) { TriggerConnectState(CNT_MBB); } else { TriggerConnectState(CNT_MBN); } } } SetDlgItemTextA(IDC_STATIC_PORT, ConvertStatusToString(g_DongleInfos[nIndex].state)); OnSignalChanged(uMsg, wParam, g_DongleInfos[nIndex].subInfo.ulSingnal); } else { if(uMsg != WM_TIMER_SWITCH) { MessageBoxA("更新连接状态失败,请重新打开配置窗口!"); } else { MessageBoxA("更新状态失败,请重新打开配置窗口!"); } EndDialog(-1); } } } } else { if(rc == Error_Succeed) { UpdateDongles(); } } return 0; } LRESULT CMobileDlg::OnDisConnectResult(UINT uMsg, WPARAM wParam, LPARAM lParam) { Dbg("Receive OnDisConnectResult msg"); auto rc = (ErrorCodeEnum)wParam; if(m_bConnected == false) { Dbg("in disconnect receive the disconnect msg"); return 0; } LeaveProgressBar(WM_TIMER_DISCONNECT); if(rc == Error_Succeed) { CSimpleStringA strDongle; int nIndex = GetInterfaceIdInCombo(strDongle); Dbg("%d vs %d", nIndex, g_DongleInfos.GetCount()); ATLASSERT(nIndex >= 0 && strDongle.GetLength() > 0); ATLASSERT(g_DongleInfos.GetCount() > nIndex); if(m_pEntity->UpdateSubInfo(nIndex)) { //BOOL fDefault = FALSE; //OnCbnSelchangeComboDongle(NULL, NULL, NULL, fDefault); if(g_DongleInfos[nIndex].subInfo.mbnCntState == MBN_ACTIVATION_STATE_DEACTIVATED) { TriggerConnectState(CNT_INVALID); } else { Dbg("index: %d, cnt state: %d", g_DongleInfos[nIndex].subInfo.mbnCntState); } } else { MessageBoxA("更新连接状态失败,请重新打开配置窗口!"); EndDialog(-1); } } else { MessageBoxA(CSimpleStringA::Format("断连失败: %s", m_pEntity->GetLastErrMsg())); } return 0; } LRESULT CMobileDlg::OnCustomTimer(UINT uMsg, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { bHandled = FALSE; if(wParam > WM_TIMER_INVALID && wParam < WM_TIMER_PROCESS_MAX) { LeaveProgressBar(wParam); MessageBoxA("等待操作返回超时,为确保信息准确显示,请重新打开对话框!", "消息", MB_OK | MB_ICONWARNING); EndDialog(wParam); bHandled = TRUE; } return 0; } LRESULT CMobileDlg::OnSelAdvancedChange(WORD wNotifyCode, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if(wNotifyCode == BN_CLICKED) { int store = m_nGenType; m_nGenType = 3; if(IsDlgButtonChecked(IDC_RADIO_3G)) { m_nGenType = 1; } else if(IsDlgButtonChecked(IDC_RADIO_4G)) { m_nGenType = 2; } else if(IsDlgButtonChecked(IDC_RADIO_DEFAULT)) { m_nGenType = 3; } else if(IsDlgButtonChecked(IDC_RADIO_WEB)) { m_nGenType = 4; } if(store != m_nGenType) { m_pEntity->SetAdvancedConfig(m_nGenType); } if(m_nReversedType != m_nGenType) { SetDlgItemTextA(IDC_STATIC_ADVANCED, "终端上网类型-需重启应用:"); } else { SetDlgItemTextA(IDC_STATIC_ADVANCED, "终端上网类型:"); } BOOL checked = IsDlgButtonChecked(IDC_RADIO_WEB); Dbg("IDC_RADIO_WEB checked: %d", checked); GetDlgItem(IDC_RADIO_MBB_WIRE).EnableWindow(checked); GetDlgItem(IDC_RADIO_MBB_WLAN).EnableWindow(checked); if(IsDlgButtonChecked(IDC_RADIO_MBB_WIRE) || IsDlgButtonChecked(IDC_RADIO_MBB_WLAN)) { GetDlgItem(IDC_BUTTON_MBB_CONFIG).EnableWindow(checked); } else { m_pEntity->GetMBBRunConfig(m_sMBBParam, TRUE); CheckRadioButton(IDC_RADIO_MBB_WIRE, IDC_RADIO_MBB_WLAN, IDC_RADIO_MBB_WIRE + m_sMBBParam.connectType - 1); BOOL fDefault = FALSE; OnSelMBBChange(BN_CLICKED, WM_COMMAND, m_hWnd, fDefault); } } return 0; } LRESULT CMobileDlg::OnSelMBBChange(WORD wNotifyCode, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { if(wNotifyCode == BN_CLICKED) { if(IsDlgButtonChecked(IDC_RADIO_MBB_WIRE)) { m_sMBBParam.connectType = MBB_CONNECT_WIRE; GetDlgItem(IDC_BUTTON_MBB_CONFIG).EnableWindow(TRUE); } else if(IsDlgButtonChecked(IDC_RADIO_MBB_WLAN)){ m_sMBBParam.connectType = MBB_CONNECT_WIFI; GetDlgItem(IDC_BUTTON_MBB_CONFIG).EnableWindow(TRUE); } else { ATLASSERT(FALSE); m_sMBBParam.connectType = MBB_CONNECT_UNKONWN; GetDlgItem(IDC_BUTTON_MBB_CONFIG).EnableWindow(FALSE); } if(HasUpdatedMBBParam()) { m_pEntity->SEtMBBRunConfig(m_sMBBParam); m_pEntity->GetMBBRunConfig(m_sReverseMBBParam, FALSE); ATLASSERT(!this->HasUpdatedMBBParam()); } } return 0; } LRESULT CMobileDlg::OnWlanConfigOpen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { Dbg("OnWlanConfigOpen happen!"); CWlanConfigDlg dlg(this); int nRes = dlg.DoModal(m_hWnd); Dbg("CWlanConfigDlg::DoModal returned: %d, error: %d", nRes, GetLastError()); if(nRes != IDOK_EX) { return 0; } if(dlg.HasUpdated(FALSE) || this->HasUpdatedMBBParam()) { m_pEntity->SEtMBBRunConfig(m_sMBBParam); m_pEntity->GetMBBRunConfig(m_sReverseMBBParam, FALSE); ATLASSERT(!this->HasUpdatedMBBParam()); } return 0; } LRESULT CMobileDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // set icons HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON)); SetIcon(hIcon, TRUE); HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)); SetIcon(hIconSmall, FALSE); int cx = GetSystemMetrics(SM_CXSCREEN); RECT rcDlg; ::GetWindowRect(m_hWnd, &rcDlg); ::SetWindowPos(m_hWnd, NULL, (cx + rcDlg.left - rcDlg.right)/2, 20, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); m_pEntity->m_hDialogWnd = m_hWnd; m_pEntity->m_fsm.SetNotifyWnd(m_hWnd); SetEvent(m_pEntity->m_hGUIReadyEvent); m_localSIM = !m_pEntity->IsAndroidControl(); m_ProgressBar.Create(m_hWnd); //m_strPassword = DEFAULT_PASSWORD_CHECK; //m_strUserName = "123@szchinacmb.vpdn.gd"; // 完成相关控件的子类化工作 DoDataExchange(FALSE); InitializeControls(); //GetDlgItem(IDC_RADIO_3G).ShowWindow(FALSE); //GetDlgItem(IDC_RADIO_4G).ShowWindow(FALSE); //GetDlgItem(IDC_RADIO_DEFAULT).ShowWindow(FALSE); //GetDlgItem(IDC_STATIC_ADVANCED).ShowWindow(FALSE); //SetDlgItemTextA(IDC_RADIO_3G, "卡 1"); //SetDlgItemTextA(IDC_RADIO_4G, "卡 2"); //SetDlgItemTextA(IDC_RADIO_DEFAULT, "自动"); //SetDlgItemTextA(IDC_STATIC_ADVANCED, "双卡管理:"); UpdateDongles(); RECT rect; GetWindowRect(&rect); Dbg("%d, %d", rect.right-rect.left, rect.bottom-rect.top); GetDlgItem(IDC_STATIC_LOGIN).GetWindowRect(&rect); Dbg("2: %d, %d", rect.right-rect.left, rect.bottom-rect.top); SetDlgSizeToSmall(); GetWindowRect(&rect); Dbg("3: %d, %d", rect.right-rect.left, rect.bottom-rect.top); GetDlgItem(IDC_STATIC_LOGIN).GetWindowRect(&rect); Dbg("4: %d, %d", rect.right-rect.left, rect.bottom-rect.top); m_wlanClickedTimes = 0; return TRUE; } LRESULT CMobileDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CloseVirtualKeyboard(); EndDialog(wID); return 0; } LRESULT CMobileDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CloseVirtualKeyboard(); BOOL fInvalid = FALSE; if(m_nGenType == 4) { if(m_sMBBParam.connectType == MBB_CONNECT_UNKONWN) { fInvalid = TRUE; } else if(m_sMBBParam.loginParam.strUsername.IsNullOrEmpty()) { fInvalid = TRUE; } else if(m_sMBBParam.loginParam.strPassword.IsNullOrEmpty()) { fInvalid = TRUE; }else if(m_sMBBParam.connectType == MBB_CONNECT_WIFI) { if(m_sMBBParam.wlanConnectParam.strUsername.IsNullOrEmpty()) { fInvalid = TRUE; } else if(m_sMBBParam.wlanConnectParam.strPassword.IsNullOrEmpty()) { fInvalid = TRUE; } } } if(fInvalid) { MessageBox("请填写华为原装未升驱卡托拨号所需的配置信息!", "提示", MB_OK); PostMessageA(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_MBB_CONFIG, BN_CLICKED), NULL); return 0; } EndDialog(wID); return 0; } LRESULT CMobileDlg::OnConnect(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { int nSel = m_comboDongles.GetCurSel(); int nSel2 = m_comboProfiles.GetCurSel(); int nSel3 = m_comboCntType.GetCurSel(); if(nSel3 == 4 || nSel3 == 3) {//android m_btnConnect.EnableWindow(FALSE); int slotID = g_DongleInfos[nSel].usDeviceType - DEVTYPE_ANDROID_UKNOWN; EnterProgressBar(TIMER_TIMTOUT_MAX, WM_TIMER_SWITCH); m_btnConnect.SetWindowTextA("切换中\r\n..."); auto rc = m_pEntity->SwitchDefaultSlot(slotID); LeaveProgressBar(WM_TIMER_SWITCH); if(rc == Error_Succeed) { OnConnectResult(WM_TIMER_SWITCH, Error_Succeed, 1); } else { MessageBoxA(CSimpleStringA::Format("切换数据卡失败: %s", m_pEntity->GetLastErrMsg())); m_btnConnect.SetWindowTextA("应用"); m_btnConnect.EnableWindow(TRUE); } return 0; } if(m_bConnected) { m_btnConnect.EnableWindow(FALSE); auto rc = m_pEntity->Disconnect(nSel3, g_DongleInfos[nSel].csInterfaceId); if(rc == Error_Succeed) { EnterProgressBar(TIMER_TIMTOUT_MAX, WM_TIMER_DISCONNECT); m_btnConnect.SetWindowTextA("断开中\r\n..."); } else { m_btnConnect.EnableWindow(TRUE); MessageBoxA(CSimpleStringA::Format("断开连接失败: %s", m_pEntity->GetLastErrMsg())); } } else { if(nSel == CB_ERR) { MessageBoxA("请选择所需连接的网卡!"); return 0; } if(nSel2 == CB_ERR) { MessageBoxA("请选择拨号配置文件 或 新增拨号配置文件!"); return 0; } if(nSel3 == CB_ERR || nSel3 == CNT_INVALID) { MessageBoxA("请选择合适的拨号方式!"); return 0; } m_btnConnect.EnableWindow(FALSE); auto rc = m_pEntity->Connect(nSel3, g_DongleInfos[nSel].csInterfaceId, g_DongleInfos[nSel].profileList[nSel2].strProfileName); if(rc == Error_Succeed) { EnterProgressBar(TIMER_TIMTOUT_MAX, WM_TIMER_CONNECT); m_btnConnect.SetWindowTextA("连接中\r\n..."); } else { m_btnConnect.EnableWindow(TRUE); MessageBoxA(CSimpleStringA::Format("拨号失败: %s", m_pEntity->GetLastErrMsg())); } } return 0; } bool CMobileDlg::OpenVirtualKeyboard() { HANDLE hKeyboard = FindProcessByName("VirtualKeyboard.exe"); if (hKeyboard == NULL) { HINSTANCE hNewExe = ShellExecuteA(NULL, "open", "VirtualKeyboard.exe", NULL, NULL, SW_SHOWNORMAL); if ((DWORD)hNewExe <= 32) { //MessageBoxA(NULL, "启动触摸键盘失败!", NULL, 0); return false; } } return true; } bool CMobileDlg::CloseVirtualKeyboard() { HANDLE hKeyboard = FindProcessByName("VirtualKeyboard.exe"); if (hKeyboard != NULL) { TerminateProcess(hKeyboard, 0); return true; } return false; } void CMobileDlg::InitializeControls() { m_comboDongles = this->GetDlgItem(IDC_COMBO_DONGLE); //m_comboProfiles = this->GetDlgItem(IDC_COMBO_PROFILES); m_comboCntType.AddString("Auto"); m_comboCntType.AddString("4G-MBN"); //1 m_comboCntType.AddString("3G-RAS"); //2 m_comboCntType.AddString("主卡"); //3 m_comboCntType.AddString("副卡"); //4 m_comboCntType.AddString("HW-MBB"); //5 m_comboCntType.SetCurSel(CNT_INVALID); m_comboModeType.AddString("无"); m_comboModeType.AddString("PAP"); m_comboModeType.AddString("CHAP"); m_comboModeType.AddString("MS-CHAP v2"); m_comboModeType.DeleteString(3); m_comboModeType.AddString("PAP 或 CHAP"); m_comboModeType.SetCurSel(0); m_comboIPType.AddString("默认"); m_comboIPType.AddString("IPv4"); m_comboIPType.AddString("IPv6"); m_comboIPType.AddString("IPv4v6"); m_comboIPType.AddString("IPv4v6XLAT"); m_comboIPType.SetCurSel(0); m_comboPointType.AddString("Internet"); //m_comboPointType.AddString("Internet及连接"); //m_comboPointType.AddString("连接"); m_comboPointType.SetCurSel(0); CheckDlgButton(IDC_CHECK_APN_APPLY, 1); GetDlgItem(IDC_BUTTON_DROPUP).SetWindowTextA("▲"); GetDlgItem(IDC_BUTTON_DROPUP).ShowWindow(FALSE); /* IDC_COMBO_CON_MODE 登录类型选择框 m_comboModeType IDC_STATIC_TXT_MODE 登录类型 IDC_STATIC_TXT_IPTYPE APN 类型 m_comboIPType IDC_COMBO_CON_IPTYPE APN 类型选择框 IDC_STATIC_TXT_POINTTYPE 接入点类型 m_comboPointType IDC_COMBO_PONT_TYPE 接入点类型选择框 */ GetDlgItem(IDC_BUTTON_DEFAULT_CONNECT).ShowWindow(!m_localSIM); if(!m_localSIM) { //m_comboPointType.ShowWindow(FALSE); //SetDlgItemTextA(IDC_STATIC_TXT_PROFILENAME, "配置文件名称:"); //GetDlgItem(IDC_STATIC_TXT_IPTYPE).ShowWindow(FALSE); //SetDlgItemTextA(IDC_STATIC_TXT_IPTYPE, "APN 类型:"); //GetDlgItem(IDC_COMBO_CON_IPTYPE).ShowWindow(FALSE); //GetDlgItem(IDC_STATIC_TXT_POINTTYPE).ShowWindow(FALSE); //GetDlgItem(IDC_COMBO_PONT_TYPE).ShowWindow(FALSE); //SetDlgItemTextA(IDC_STATIC_TXT_MODE, "身份验证类型:"); //SetDlgItemTextA(IDC_STATIC_LOGIN, "拨号配置(接入点)"); //SetDlgItemTextA(IDC_BUTTON_CONNECT, "应用"); } CheckDlgButton(IDC_CHECK_MNTBYRVC, m_pEntity->IsManageByUser() ? FALSE : TRUE); m_nReversedType = m_pEntity->GetCurAdvancedConfig(); m_nGenType = m_pEntity->GetCurAdvancedConfig(true); Dbg("GenType:%d, ReverseType:%d", m_nGenType, m_nReversedType); // 默认程序自动管理 GetDlgItem(IDC_CHECK_MNTBYRVC).ShowWindow(FALSE); if(!m_localSIM) { GetDlgItem(IDC_RADIO_3G).EnableWindow(FALSE); GetDlgItem(IDC_RADIO_4G).EnableWindow(FALSE); GetDlgItem(IDC_RADIO_DEFAULT).EnableWindow(FALSE); GetDlgItem(IDC_RADIO_WEB).EnableWindow(FALSE); } else { CheckRadioButton(IDC_RADIO_3G, IDC_RADIO_WEB, IDC_RADIO_3G + m_nGenType-1); if(m_nReversedType != m_nGenType) { SetDlgItemTextA(IDC_STATIC_ADVANCED, "终端上网类型-需重启应用:"); } else { SetDlgItemTextA(IDC_STATIC_ADVANCED, "终端上网类型:"); } } const BOOL checked = IsDlgButtonChecked(IDC_RADIO_WEB); GetDlgItem(IDC_RADIO_MBB_WIRE).EnableWindow(checked); GetDlgItem(IDC_RADIO_MBB_WLAN).EnableWindow(checked); // 恢复手工配置MIFI登录参数和WIFI连接配置 [6/16/2020 11:23 @Gifur] //GetDlgItem(IDC_BUTTON_MBB_CONFIG).EnableWindow(checked); GetDlgItem(IDC_BUTTON_MBB_CONFIG).ShowWindow(FALSE); m_pEntity->GetMBBRunConfig(m_sReverseMBBParam, FALSE); m_pEntity->GetMBBRunConfig(m_sMBBParam, FALSE); CheckRadioButton(IDC_RADIO_MBB_WIRE, IDC_RADIO_MBB_WLAN, IDC_RADIO_MBB_WIRE + m_sReverseMBBParam.connectType - 1); if(m_sReverseMBBParam.connectType != MBB_CONNECT_UNKONWN && checked) { GetDlgItem(IDC_BUTTON_MBB_CONFIG).EnableWindow(TRUE); } } void CMobileDlg::UpdateDongles() { int cnt = m_pEntity->UpdateDongleInfo(); m_comboDongles.ResetContent(); m_comboProfiles.ResetContent(); this->SetWindowTextA((LPCTSTR)CSimpleStringA::Format("APN 拨号配置(%d) -v%s", cnt, MOD_VERSION)); if(cnt > 0) { int cntType = CNT_INVALID; EnableControls(TRUE); int aim = 0; int activeOne = -1; m_dongleType = 0; for(int i=0; i 0) { activeOne = i; } m_dongleType |= g_DongleInfos[i].usDeviceType; } ATLASSERT(aim == 0 || cntType != CNT_INVALID); m_comboDongles.SetCurSel(aim); if((m_dongleType & DEVTYPE_ANDROID_UKNOWN) && activeOne == -1) { SetDlgItemTextA(IDC_STATIC_TXT_WARN, "当前未能识别到默认移动数据应用卡,请进行选择(应用)!"); } else { GetDlgItem(IDC_STATIC_TXT_WARN).ShowWindow(SW_HIDE); } TriggerConnectState(cntType); if(cntType != CNT_INVALID) { OnSignalChanged(0, NULL, g_DongleInfos[aim].subInfo.ulSingnal); } BOOL bDefault = 0; OnCbnSelchangeComboDongle(0, 0, NULL, bDefault); } else { if(cnt == -2) { SetDlgItemTextA(IDC_STATIC_TXT_WARN, "当前未连接到多合一,请稍后再试!"); } else if(cnt == -1) { SetDlgItemTextA(IDC_STATIC_TXT_WARN, "连接多合一管控实体失败!"); } else if(cnt == 0) { SetDlgItemTextA(IDC_STATIC_TXT_WARN, "未检测到上网卡(或卡槽)相关信息,请检查设备!"); } else if(cnt == -500) { SetDlgItemTextA(IDC_STATIC_TXT_WARN, m_pEntity->GetLastErrMsg()); } //将提示栏显示出来 GetDlgItem(IDC_STATIC_TXT_WARN).ShowWindow(SW_SHOW); TriggerConnectState(CNT_INVALID); EnableControls(FALSE); } } void CMobileDlg::EnableControls(BOOL bEnable /*= TRUE*/) { GetDlgItem(IDC_BUTTON_EXPAND).EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_APN_STORE).EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_CONNECT).EnableWindow(bEnable); GetDlgItem(IDC_COMBO_PROFILES).EnableWindow(bEnable); GetDlgItem(IDC_COMBO_DONGLE).EnableWindow(bEnable); GetDlgItem(IDC_COMBO_CON_MODE).EnableWindow(bEnable); GetDlgItem(IDC_COMBO_CON_IPTYPE).EnableWindow(bEnable); GetDlgItem(IDC_EDIT_USER).EnableWindow(bEnable); GetDlgItem(IDC_EDIT_PASSWORD).EnableWindow(bEnable); GetDlgItem(IDC_CHECK_VIEW_PASSWORD).EnableWindow(bEnable); GetDlgItem(IDC_EDIT_APN).EnableWindow(bEnable); GetDlgItem(IDC_CHECK_APN_APPLY).EnableWindow(bEnable); GetDlgItem(IDC_COMBO_PONT_TYPE).EnableWindow(bEnable); GetDlgItem(IDC_EDIT_PROFILE).EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_CLEAR).EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_DELETE).EnableWindow(bEnable); GetDlgItem(IDC_CHECK_MNTBYRVC).EnableWindow(bEnable); //不让用户更改拨号方式 GetDlgItem(IDC_COMBO_GTYPE).EnableWindow(FALSE); } void CMobileDlg::EnterProgressBar(DWORD dwTimeout, DWORD nTimerID) { EnableWindow(FALSE); m_ProgressBar.ResetStep(); m_ProgressBar.ShowWindow(SW_SHOW); m_ProgressBar.CenterWindow(); if(dwTimeout != INFINITE) { SetTimer(nTimerID, dwTimeout); } } void CMobileDlg::LeaveProgressBar(DWORD nTimerID) { if(nTimerID == WM_TIMER_INVALID || KillTimer(nTimerID)) { m_ProgressBar.ShowWindow(SW_HIDE); EnableWindow(TRUE); if(nTimerID == WM_TIMER_CONNECT && !m_btnConnect.IsWindowEnabled()) { m_btnConnect.EnableWindow(TRUE); m_btnConnect.SetWindowTextA("连接"); Dbg("set connect btn text"); } else if(nTimerID == WM_TIMER_DISCONNECT && !m_btnConnect.IsWindowEnabled()) { m_btnConnect.EnableWindow(TRUE); m_btnConnect.SetWindowTextA("断开连接"); Dbg("set disconnect btn text"); } /*else if(nTimerID == WM_TIMER_SWITCH && !m_btnConnect.IsWindowEnabled()) { m_btnConnect.EnableWindow(TRUE); m_btnConnect.SetWindowTextA("应用"); }*/ } } void CMobileDlg::TriggerConnectState(int nCntState) { Dbg("Enter TriggerConnectState %d", nCntState); if(nCntState == CNT_MBN || nCntState == CNT_RAS || nCntState == CNT_MBB) { Dbg("set disconnect text"); m_btnConnect.SetWindowTextA("断开连接"); m_btnConnect.EnableWindow(TRUE); GetDlgItem(IDC_COMBO_DONGLE).EnableWindow(FALSE); //已连接的情况下,不能选择卡托设备 GetDlgItem(IDC_COMBO_PROFILES).EnableWindow(FALSE); //也不能选择配置文件,所以当前的卡托一定是已连接的 } else if(nCntState == CNT_ANDROID) { GetDlgItem(IDC_COMBO_DONGLE).EnableWindow(TRUE); GetDlgItem(IDC_COMBO_PROFILES).EnableWindow(TRUE); } else if(nCntState == CNT_INVALID) { Dbg("set connet text"); m_btnConnect.SetWindowTextA("连接"); m_btnConnect.EnableWindow(TRUE); } m_bConnected = (nCntState != CNT_INVALID); m_nWhoConnected = nCntState; if(m_bConnected) { SetDlgItemTextA(IDC_STATIC_PERCENTAGE, "0%"); SetDlgItemTextA(IDC_STATIC_SIGNAL, "网络强度:"); SetDlgItemTextA(IDC_STATIC_STATUS, "已连接"); OnFatalMsgChanged(WM_FATALMESSAGE_CHANGE, Error_Succeed, NULL); } else { SetDlgItemTextA(IDC_STATIC_PERCENTAGE, "NA"); SetDlgItemTextA(IDC_STATIC_SIGNAL, ""); SetDlgItemTextA(IDC_STATIC_STATUS, "已断开连接"); GetDlgItem(IDC_COMBO_DONGLE).EnableWindow(TRUE); GetDlgItem(IDC_COMBO_PROFILES).EnableWindow(TRUE); } GetDlgItem(IDC_COMBO_GTYPE).EnableWindow(FALSE); } void CMobileDlg::ShowProfileCreateCtrl(BOOL bShow /*= TRUE*/) { GetDlgItem(IDC_STATIC_LOGIN).ShowWindow(bShow); GetDlgItem(IDC_STATIC_TXT_PROFILENAME).ShowWindow(bShow); GetDlgItem(IDC_EDIT_PROFILE).ShowWindow(bShow); GetDlgItem(IDC_STATIC_TXT_APN).ShowWindow(bShow); GetDlgItem(IDC_EDIT_APN).ShowWindow(bShow); GetDlgItem(IDC_STATIC_TXT_USER).ShowWindow(bShow); GetDlgItem(IDC_EDIT_USER).ShowWindow(bShow); GetDlgItem(IDC_STATIC_TXT_PASSWORD).ShowWindow(bShow); GetDlgItem(IDC_EDIT_PASSWORD).ShowWindow(bShow); GetDlgItem(IDC_CHECK_VIEW_PASSWORD).ShowWindow(bShow); GetDlgItem(IDC_STATIC_TXT_MODE).ShowWindow(bShow); GetDlgItem(IDC_COMBO_CON_MODE).ShowWindow(bShow); const int nSel3 = m_comboCntType.GetCurSel(); if(nSel3 <= CNT_RAS || bShow == FALSE) { GetDlgItem(IDC_STATIC_TXT_IPTYPE).ShowWindow(bShow); GetDlgItem(IDC_COMBO_CON_IPTYPE).ShowWindow(bShow); GetDlgItem(IDC_STATIC_TXT_POINTTYPE).ShowWindow(bShow); GetDlgItem(IDC_COMBO_PONT_TYPE).ShowWindow(bShow); } GetDlgItem(IDC_CHECK_APN_APPLY).ShowWindow(bShow); GetDlgItem(IDC_BUTTON_APN_STORE).ShowWindow(bShow); //GetDlgItem(IDC_BUTTON_DROPUP).ShowWindow(bShow); GetDlgItem(IDC_BUTTON_CLEAR).ShowWindow(bShow); GetDlgItem(IDC_BUTTON_DELETE).ShowWindow(bShow); GetDlgItem(IDC_EDIT_PHONENUM).ShowWindow(bShow); GetDlgItem(IDC_CHECK_RASIO_PAP).ShowWindow(bShow); GetDlgItem(IDC_CHECK_RASIO_CHAP).ShowWindow(bShow); GetDlgItem(IDC_CHECK_RASIO_MSCHAPV2).ShowWindow(bShow); MoveDlgItems(bShow); } void CMobileDlg::_ClearProfileTxt() { SetDlgItemTextA(IDC_EDIT_PROFILE, ""); SetDlgItemTextA(IDC_EDIT_APN, ""); SetDlgItemTextA(IDC_EDIT_USER, ""); SetDlgItemTextA(IDC_EDIT_PASSWORD, ""); SetDlgItemTextA(IDC_EDIT_PHONENUM, ""); CheckDlgButton(IDC_CHECK_RASIO_PAP, FALSE); CheckDlgButton(IDC_CHECK_RASIO_CHAP, FALSE); CheckDlgButton(IDC_CHECK_RASIO_MSCHAPV2, FALSE); m_strPassword = ""; m_strPhoneNum = ""; m_strUserName = ""; m_comboModeType.SetCurSel(0); m_comboIPType.SetCurSel(0); m_comboPointType.SetCurSel(0); const int nCntType = m_comboCntType.GetCurSel(); if(nCntType == CNT_MBB) { m_comboIPType.SetCurSel(1); m_comboIPType.EnableWindow(FALSE); m_comboModeType.SetCurSel(1); } else { m_comboIPType.EnableWindow(TRUE); } } int CMobileDlg::GetInterfaceIdInCombo(CSimpleStringA& strCurDongle, bool bSlient /*= true*/) { int nSel = 0; CString strDongle; { int selected = m_comboDongles.GetCurSel(); if(selected < 0) { return -1; } int nLen = m_comboDongles.GetLBTextLen(selected); m_comboDongles.GetLBText(selected, strDongle.GetBuffer(nLen)); strDongle.ReleaseBuffer(); Dbg("GetInterfaceIdInCombo::selected: %s", (LPCTSTR)strDongle); } for (int i=0; i?")) { MessageBoxA("密码中不能包含(,\":;\\&%+'<>?)等字符!"); return 0; } } /* if(m_strPassword.GetLength() <= 0) { MessageBoxA("请输入密码!"); return 0; } else if(!m_strPassword.Compare(DEFAULT_PASSWORD_CHECK)) { //在修改的情况下表示没有修改密码,//在新建的情况下需要提示为无效密码 m_strPassword = ""; if(bUpdate) { m_strPassword = ""; } else { MessageBoxA("该密码无效,请进行修改!"); return 0; } } */ if(nCntType == CNT_RAS && m_strPhoneNum.GetLength() <= 0) { MessageBoxA(("请输入电话号码!")); return 0; } //是否立即应用 CButton btnCheck = GetDlgItem(IDC_CHECK_APN_APPLY); bool bApplyNow = (btnCheck.GetCheck() != 0); if(bAndroid) { strCurDongle = nCntType == 3 ? "MAIN" : "VICE"; /* for(int i=0; i 3))) { MessageBoxA("不支持的IP类型!"); return 0; } nLen = m_comboIPType.GetLBTextLen(selected); CString strTemp; m_comboIPType.GetLBText(selected, strTemp.GetBuffer(nLen)); strTemp.ReleaseBuffer(); if(nCntType == CNT_MBN) { if(!strTemp.Compare("默认")) { strTemp = "Default"; } else if(!strTemp.Compare("IPv4v6XLAT")) { strTemp = "XLAT"; } } newInfo.strIPType = (LPCTSTR)strTemp; } if(nCntType == CNT_MBN) { int selected = m_comboPointType.GetCurSel(); if(selected < 0) { MessageBoxA("请选择合适的接入点类型!"); return 0; } nLen = m_comboPointType.GetLBTextLen(selected); CString strTemp; m_comboPointType.GetLBText(selected, strTemp.GetBuffer(nLen)); strTemp.ReleaseBuffer(); } } else { { bool fChooseLeastOne = false; if(IsDlgButtonChecked(IDC_CHECK_RASIO_PAP)) { newInfo.usAPType |= AUPR_PAP; fChooseLeastOne = true; } if(IsDlgButtonChecked(IDC_CHECK_RASIO_CHAP)) { newInfo.usAPType |= AUPR_CHAP; fChooseLeastOne = true; } if(IsDlgButtonChecked(IDC_CHECK_RASIO_MSCHAPV2)) { newInfo.usAPType |= AUPR_MSV2; fChooseLeastOne = true; } if(!fChooseLeastOne) { MessageBoxA("请至少选择一个登录类型(密码身份验证协议)!"); return 0; } } newInfo.strPhoneNum = (LPCTSTR)m_strPhoneNum; } EnterProgressBar(TIMER_TIMTOUT_MAX); if(!bUpdate) { auto rc = m_pEntity->AddNewProfile(strCurDongle, newInfo, bApplyNow); if(rc == Error_Pending) { } else { if(rc != Error_Succeed) { LeaveProgressBar(WM_TIMER_PROCESS); MessageBoxA(CSimpleStringA::Format("添加拨号配置失败: %s", m_pEntity->GetLastErrMsg())); } else { Dbg("PostMessage WM_ADD_PROFILE_RESULT"); PostMessage(WM_ADD_PROFILE_RESULT, Error_Succeed, 0); } } } else { auto rc = m_pEntity->UpdateProfile(strCurDongle, g_DongleInfos[nIndex].profileList[aim].strProfileName, newInfo, bApplyNow); if(rc == Error_Pending) { } else { LeaveProgressBar(WM_TIMER_PROCESS); if(rc != Error_Succeed) { MessageBoxA(CSimpleStringA::Format("更新拨号配置失败: %s", m_pEntity->GetLastErrMsg())); } else { Dbg("PostMessage WM_UPDATE_PROFILE_RESULT"); PostMessage(WM_UPDATE_PROFILE_RESULT, Error_Succeed, 0); } } } return 0; } LRESULT CMobileDlg::OnCbnSelchangeComboDongle( WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CSimpleStringA strCurDongle; int nIndex = GetInterfaceIdInCombo(strCurDongle); if(nIndex < 0) { Dbg("GetInterfaceIdInCombo failed: %d", nIndex); return 0; } else if(strCurDongle.GetLength() <= 0) { Dbg("GetInterfaceIdInCombo failed2: %d", nIndex); return 0; } if(g_DongleInfos[nIndex].usDeviceType == DEVTYPE_INTER) { m_comboCntType.SetCurSel(CNT_MBN); } else if(g_DongleInfos[nIndex].usDeviceType == DEVTYPE_MODEM) { m_comboCntType.SetCurSel(CNT_RAS); } else if(g_DongleInfos[nIndex].usDeviceType == DEVTYPE_ANDROID_MAIN) { m_comboCntType.SetCurSel(3); } else if(g_DongleInfos[nIndex].usDeviceType == DEVTYPE_ANDROID_VICE) { m_comboCntType.SetCurSel(4); } else if(g_DongleInfos[nIndex].usDeviceType == DEVTYPE_MBB) { m_comboCntType.SetCurSel(CNT_MBB); } else { m_comboCntType.SetCurSel(0); } if(g_DongleInfos[nIndex].usDeviceType & DEVTYPE_ANDROID_UKNOWN) { if(g_DongleInfos[nIndex].priority > 0) { m_btnConnect.SetWindowTextA("已应用"); m_btnConnect.EnableWindow(FALSE); } else { m_btnConnect.SetWindowTextA("应用"); m_btnConnect.EnableWindow(TRUE); } m_comboPointType.ShowWindow(FALSE); } else { if(g_DongleInfos[nIndex].subInfo.mbnCntState == MBN_ACTIVATION_STATE_ACTIVATED) { m_btnConnect.SetWindowTextA("断开连接"); m_btnConnect.EnableWindow(TRUE); } else { m_btnConnect.SetWindowTextA("连接"); m_btnConnect.EnableWindow(TRUE); } // 在简洁版本中,该字段会出来 [5/12/2020 12:10 @Gifur] { char szBtnTxt[128] = {0}; m_btnExpand.GetWindowTextA(szBtnTxt, 128); if(!!strcmp(szBtnTxt, "管理配置")) { m_comboPointType.ShowWindow(TRUE); } } } m_comboProfiles.ResetContent(); const MBNProfileList& info = g_DongleInfos[nIndex].profileList; Dbg("CbnSelchangeComboDongle: %s", g_DongleInfos[nIndex].subInfo.strProfileName); Dbg("[%d] profile count: %d", nIndex, info.GetCount()); int aim = -1; if(info.GetCount() > 0) { for(int i=0; i 0) { if(!g_DongleInfos[nIndex].subInfo.strProfileName.Compare(info[i].strProfileName)) { Dbg("Here: %d", i); aim = i; } } } if(aim == -1) { aim = 0; } m_comboProfiles.SetCurSel(aim); } BOOL bEmpty = TRUE; OnCbnSelchangeComboProfiles(NULL, NULL, NULL, bEmpty); //第三层固定信息 //制造商 SetDlgItemTextA(IDC_STATIC_MANUFACTURER, g_DongleInfos[nIndex].subInfo.strManufacturer); //型号 SetDlgItemTextA(IDC_STATIC_MODEL, g_DongleInfos[nIndex].subInfo.strMode); //固件 SetDlgItemTextA(IDC_STATIC_FIRMWARE, g_DongleInfos[nIndex].subInfo.strFirmware); //网络类型 SetDlgItemTextA(IDC_STATIC_HARDWARE, g_DongleInfos[nIndex].subInfo.strCellularClass); //IMEI SetDlgItemTextA(IDC_STATIC_IMEI, g_DongleInfos[nIndex].subInfo.strDeviceID); //状态 SetDlgItemTextA(IDC_STATIC_PORT, ConvertStatusToString(g_DongleInfos[nIndex].state)); //数据类 SetDlgItemTextA(IDC_STATIC_DATACLASS, g_DongleInfos[nIndex].subInfo.strDataClass); return 0; } LRESULT CMobileDlg::OnBnClickedButtonExpand(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled) { char szBtnTxt[128] = {0}; m_btnExpand.GetWindowTextA(szBtnTxt, 128); if(!strcmp(szBtnTxt, "管理配置")) { SetDlgSizeToLarge(); OnCbnSelchangeComboProfiles(NULL, NULL, NULL, bHandled); } else { SetDlgSizeToSmall(); } return 0; } LRESULT CMobileDlg::OnBnClickedCheckMntbyrvc(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { m_pEntity->RequireManageByUser(!IsDlgButtonChecked(IDC_CHECK_MNTBYRVC)); return 0; } LRESULT CMobileDlg::OnBnClickedButtonDropup(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { SetDlgSizeToSmall(); return 0; } LRESULT CMobileDlg::OnBnClickedButtonClear(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { char szBtnTxt[128] = {0}; BOOL bClear = FALSE; m_btnClear.GetWindowTextA(szBtnTxt, 128); if(!strcmp(szBtnTxt, "新建")) {//点击了新建 CloseVirtualKeyboard(); GetDlgItem(IDC_BUTTON_DELETE).EnableWindow(FALSE); GetDlgItem(IDC_EDIT_PROFILE).EnableWindow(TRUE); m_btnClear.SetWindowTextA("清除"); bClear = TRUE; CheckDlgButton(IDC_CHECK_APN_APPLY, TRUE); } else if(!strcmp(szBtnTxt, "清除")) { bClear = TRUE; } if(bClear) { _ClearProfileTxt(); } return 0; } LRESULT CMobileDlg::OnBnClickedButtonDefaultConnect(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { UINT_PTR uRes = MessageBoxA("该操作不可撤销!确定要恢复默认密码进行连接?", "确认", MB_OKCANCEL | MB_ICONQUESTION); if(uRes == IDOK) { EnterProgressBar(65 * 1000); auto rc = m_pEntity->ConnectWIFIWithDefault(); if(rc == Error_Succeed) { //MessageBoxA("尝试使用默认密码连接成功!"); } else { LeaveProgressBar(WM_TIMER_PROCESS); MessageBoxA(CSimpleStringA::Format("尝试使用默认密码连接失败: %s", m_pEntity->GetLastErrMsg())); } } return 0; } LRESULT CMobileDlg::OnCbnSelchangeComboProfiles(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { char szBtnTxt[128] = {0}; m_btnExpand.GetWindowTextA(szBtnTxt, 128); if(!!strcmp(szBtnTxt, "管理配置")) { //扩展 GetDlgItem(IDC_EDIT_PROFILE).EnableWindow(FALSE); m_btnClear.SetWindowTextA("新建"); OnCbnSelchangeComboGtype(wNotifyCode, wID, hWndCtl, bHandled); do { const int nSel = m_comboProfiles.GetCurSel(); CSimpleStringA strDongle; const int nIndex = GetInterfaceIdInCombo(strDongle); if(nIndex < 0 || nSel < 0 || strDongle.GetLength() <= 0) { Dbg("nIndex : %d, nSel : %d", nIndex, nSel); GetDlgItem(IDC_BUTTON_DELETE).EnableWindow(FALSE); break; } _ClearProfileTxt(); { const MBNProfileList& info = g_DongleInfos[nIndex].profileList; m_strPassword = (LPCTSTR)info[nSel].AccessInfo.strPassword; if(info[nSel].AccessInfo.strPassword == DEFAULT_PASSWORD_CHECK) { m_strPassword = ""; } m_strUserName = (LPCTSTR)info[nSel].AccessInfo.strUserName; m_edtAPN.SetWindowTextA((LPCTSTR)info[nSel].AccessInfo.strAccessString); GetDlgItem(IDC_EDIT_PROFILE).SetWindowTextA((LPCTSTR)info[nSel].AccessInfo.strProfileDesc); if(info[nSel].AccessInfo.usCntType == CNT_RAS) { assert(m_comboCntType.GetCurSel() == CNT_RAS); Dbg("RAS for %s", (LPCTSTR)info[nSel].AccessInfo.strProfileDesc); //GetDlgItem(IDC_EDIT_PHONENUM).SetWindowTextA((LPCTSTR)info[nSel].AccessInfo.strPhoneNum); m_strPhoneNum = (LPCTSTR)info[nSel].AccessInfo.strPhoneNum; Dbg("Set phone num: %s", (LPCTSTR)info[nSel].AccessInfo.strPhoneNum); Dbg("usAPType: 0x%X", info[nSel].AccessInfo.usAPType); if((info[nSel].AccessInfo.usAPType & AUPR_PAP) == AUPR_PAP) { CheckDlgButton(IDC_CHECK_RASIO_PAP, TRUE); } else { CheckDlgButton(IDC_CHECK_RASIO_PAP, FALSE); } if((info[nSel].AccessInfo.usAPType & AUPR_CHAP) == AUPR_CHAP) { CheckDlgButton(IDC_CHECK_RASIO_CHAP, TRUE); } else { CheckDlgButton(IDC_CHECK_RASIO_CHAP, FALSE); } if((info[nSel].AccessInfo.usAPType & AUPR_MSV2) == AUPR_MSV2) { CheckDlgButton(IDC_CHECK_RASIO_MSCHAPV2, TRUE); } else { CheckDlgButton(IDC_CHECK_RASIO_MSCHAPV2, FALSE); } m_strPhoneNum = (LPCTSTR)info[nSel].AccessInfo.strPhoneNum; } else if(info[nSel].AccessInfo.usCntType == CNT_MBN) { //change test Dbg("@3"); if(m_comboModeType.SelectString(-1, info[nSel].AccessInfo.strAuthProtocol) == CB_ERR) { Dbg("Enter: %s", (LPCTSTR)info[nSel].AccessInfo.strAuthProtocol); if(!strncmp(info[nSel].AccessInfo.strAuthProtocol, "NONE", strlen("NONE"))) { m_comboModeType.SetCurSel(0); Dbg("mode type: set 0"); } else if(!strncmp(info[nSel].AccessInfo.strAuthProtocol, "MsCHAPv2", strlen("MsCHAPv2"))) { m_comboModeType.SetCurSel(3); Dbg("mode type: set 3"); } else { m_comboModeType.SetCurSel(0); Dbg("mode type: set 0"); } } Dbg("@4"); CheckDlgButton(IDC_CHECK_APN_APPLY, info[nSel].AccessInfo.IsDefault); } else if(info[nSel].AccessInfo.usCntType == CNT_ANDROID || info[nSel].AccessInfo.usCntType == CNT_MBB) { //change test Dbg("usAPType: 0x%X", info[nSel].AccessInfo.usAPType); if(info[nSel].AccessInfo.usAPType == AUPR_PAP) { m_comboModeType.SetCurSel(1); } else if(info[nSel].AccessInfo.usAPType == AUPR_CHAP) { m_comboModeType.SetCurSel(2); } else if(info[nSel].AccessInfo.usAPType == AUPR_PAPORCHAP) { m_comboModeType.SetCurSel(3); } else { m_comboModeType.SetCurSel(0); } Dbg("@1"); CheckDlgButton(IDC_CHECK_APN_APPLY, info[nSel].AccessInfo.IsDefault); } else { Dbg("Cannot recognize connect type 0x%X", info[nSel].AccessInfo.usCntType); } if(info[nSel].AccessInfo.usCntType == CNT_MBN || info[nSel].AccessInfo.usCntType == CNT_MBB) { Dbg("@2: %s", (LPCTSTR)info[nSel].AccessInfo.strIPType); if(m_comboIPType.SelectString(-1, info[nSel].AccessInfo.strIPType) == CB_ERR) { Dbg("Enter: %s", (LPCTSTR)info[nSel].AccessInfo.strIPType); if(!strncmp(info[nSel].AccessInfo.strIPType, "Default", strlen("Default"))) { m_comboIPType.SetCurSel(0); Dbg("iptype: set 0"); } else if(!strncmp(info[nSel].AccessInfo.strIPType, "XLAT", strlen("XLAT"))) { m_comboIPType.SetCurSel(4); Dbg("iptype: set 4"); } else { m_comboIPType.SetCurSel(0); Dbg("iptype: set 0"); } } //cannot set ip type to MBB [12/5/2019 14:36 @Gifur] if(info[nSel].AccessInfo.usCntType == CNT_MBB) { m_comboIPType.EnableWindow(FALSE); } } DoDataExchange(FALSE); GetDlgItem(IDC_BUTTON_DELETE).EnableWindow(TRUE); } }while(false); } return 0; } LRESULT CMobileDlg::OnBnClickedButtonDelete(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { const int nSel3 = m_comboCntType.GetCurSel(); int nSel = m_comboProfiles.GetCurSel(); CSimpleStringA strDongle; int nIndex = GetInterfaceIdInCombo(strDongle); Dbg("interface index : %d vs profile sel: %d", nIndex, nSel); if(nIndex >= 0 && strDongle.GetLength() > 0 && nSel >= 0) { if(g_DongleInfos[nIndex].subInfo.mbnCntState == MBN_ACTIVATION_STATE_ACTIVATED && nSel3 <= CNT_RAS) { MessageBox("请先断开连接再执行删除操作!", "提示", MB_OK); return 0; } CloseVirtualKeyboard(); UINT_PTR uRes = MessageBox(CSimpleStringA::Format("确定要删除配置文件 %s ?", (LPCTSTR)g_DongleInfos[nIndex].profileList[nSel].AccessInfo.strProfileDesc), "确认", MB_OKCANCEL | MB_ICONQUESTION); if(uRes == IDOK) { EnterProgressBar(TIMER_TIMTOUT_MAX); auto rc = m_pEntity->DeleteProfile(nIndex, nSel); if(rc == Error_Succeed) { const USHORT cntType = g_DongleInfos[nIndex].profileList[nSel].AccessInfo.usCntType; if(cntType == CNT_RAS || cntType == CNT_ANDROID || cntType == CNT_MBB) { PostMessage(WM_DELETE_PROFILE_RESULT, Error_Succeed); } } else { LeaveProgressBar(WM_TIMER_PROCESS); MessageBoxA(CSimpleStringA::Format("删除失败: %s", m_pEntity->GetLastErrMsg())); } } } return 0; } LRESULT CMobileDlg::OnCbnSelchangeComboGtype(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { char szBtnTxt[128] = {0}; m_btnExpand.GetWindowTextA(szBtnTxt, 128); if(!strcmp(szBtnTxt, "管理配置")) { return 0; } const int nSel = m_comboCntType.GetCurSel(); BOOL bMBNShow = FALSE; if(nSel <= CNT_MBN || nSel == CNT_MBB) {//MBN or MBB bMBNShow = TRUE; SetDlgItemTextA(IDC_STATIC_TXT_MODE, "登录类型:"); SetDlgItemTextA(IDC_STATIC_LOGIN, "拨号配置(接入点)"); SetDlgItemTextA(IDC_STATIC_TXT_IPTYPE, "IP类型:"); SetDlgItemTextA(IDC_STATIC_TXT_PROFILENAME, "配置文件名称:"); } else if(nSel == CNT_RAS) {//RAS bMBNShow = FALSE; SetDlgItemTextA(IDC_STATIC_TXT_MODE, "电话号码:"); SetDlgItemTextA(IDC_STATIC_LOGIN, "拨号配置(电话簿)"); SetDlgItemTextA(IDC_STATIC_TXT_IPTYPE, "登录类型:"); SetDlgItemTextA(IDC_STATIC_TXT_PROFILENAME, "拨号配置名称:"); } else if(nSel == 3 || nSel == 4) {//Android SetDlgItemTextA(IDC_STATIC_TXT_MODE, "身份验证:"); SetDlgItemTextA(IDC_STATIC_LOGIN, "拨号配置(接入点)"); SetDlgItemTextA(IDC_STATIC_TXT_IPTYPE, "APN 类型:"); SetDlgItemTextA(IDC_STATIC_TXT_PROFILENAME, "配置文件名称:"); GetDlgItem(IDC_STATIC_TXT_IPTYPE).ShowWindow(FALSE); GetDlgItem(IDC_COMBO_CON_IPTYPE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_POINTTYPE).ShowWindow(FALSE); GetDlgItem(IDC_COMBO_PONT_TYPE).ShowWindow(FALSE); bMBNShow = TRUE; } else { return 0; } GetDlgItem(IDC_COMBO_CON_MODE).ShowWindow(bMBNShow); GetDlgItem(IDC_EDIT_PHONENUM).ShowWindow(!bMBNShow); GetDlgItem(IDC_CHECK_RASIO_PAP).ShowWindow(!bMBNShow); GetDlgItem(IDC_CHECK_RASIO_CHAP).ShowWindow(!bMBNShow); GetDlgItem(IDC_CHECK_RASIO_MSCHAPV2).ShowWindow(!bMBNShow); if(nSel <= CNT_RAS) { GetDlgItem(IDC_STATIC_TXT_POINTTYPE).ShowWindow(bMBNShow); GetDlgItem(IDC_COMBO_PONT_TYPE).ShowWindow(bMBNShow); GetDlgItem(IDC_COMBO_CON_IPTYPE).ShowWindow(bMBNShow); } if(bMBNShow) { if(nSel <= CNT_MBN || nSel == CNT_MBB) { if(wv == 8 && nSel != CNT_MBB) { GetDlgItem(IDC_COMBO_PONT_TYPE).ShowWindow(FALSE); GetDlgItem(IDC_COMBO_CON_IPTYPE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_IPTYPE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_POINTTYPE).ShowWindow(FALSE); GetDlgItem(IDC_CHECK_APN_APPLY).ShowWindow(FALSE); } else { GetDlgItem(IDC_COMBO_CON_IPTYPE).ShowWindow(TRUE); GetDlgItem(IDC_STATIC_TXT_IPTYPE).ShowWindow(TRUE); if(nSel == CNT_MBB) { GetDlgItem(IDC_COMBO_PONT_TYPE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_POINTTYPE).ShowWindow(FALSE); GetDlgItem(IDC_STATIC_TXT_IPTYPE).EnableWindow(FALSE); } else { GetDlgItem(IDC_COMBO_PONT_TYPE).ShowWindow(TRUE); GetDlgItem(IDC_STATIC_TXT_POINTTYPE).ShowWindow(TRUE); GetDlgItem(IDC_STATIC_TXT_IPTYPE).EnableWindow(TRUE); } GetDlgItem(IDC_CHECK_APN_APPLY).ShowWindow(TRUE); } } else { GetDlgItem(IDC_CHECK_APN_APPLY).ShowWindow(TRUE); } } else { GetDlgItem(IDC_CHECK_APN_APPLY).ShowWindow(FALSE); if(wv == 8) { GetDlgItem(IDC_STATIC_TXT_IPTYPE).ShowWindow(TRUE); } } if(nSel == CNT_MBB) { m_comboModeType.ResetContent(); m_comboModeType.AddString("自动"); m_comboModeType.AddString("PAP"); m_comboModeType.AddString("CHAP"); m_comboModeType.AddString("无"); } else if(nSel == CNT_MBN) { m_comboModeType.ResetContent(); m_comboModeType.AddString("无"); m_comboModeType.AddString("PAP"); m_comboModeType.AddString("CHAP"); m_comboModeType.AddString("MS-CHAP v2"); m_comboModeType.SetCurSel(0); } else if(nSel == 3 || nSel == 4) {//Android m_comboModeType.ResetContent(); m_comboModeType.AddString("无"); m_comboModeType.AddString("PAP"); m_comboModeType.AddString("CHAP"); m_comboModeType.AddString("PAP 或 CHAP"); m_comboModeType.SetCurSel(0); } return 0; } LRESULT CMobileDlg::OnBnClickedCheckViewPassword(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { CEdit edit = (CEdit)this->GetDlgItem(IDC_EDIT_PASSWORD); if(IsDlgButtonChecked(IDC_CHECK_VIEW_PASSWORD)) { edit.SetPasswordChar(0); } else { edit.SetPasswordChar('*'); } edit.RedrawWindow(); return 0; } void CMobileDlg::OnSetFocus(HWND hWnd) { OpenVirtualKeyboard(); SetMsgHandled(FALSE); } void CMobileDlg::OnKillFocus(HWND hWnd) { SetMsgHandled(FALSE); } LRESULT CMobileDlg::OnEnSetfocusEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled) { OpenVirtualKeyboard(); return 0; } LRESULT CMobileDlg::OnEnKillfocusEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled) { return 0; } LRESULT CWlanConfigDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { int cx = GetSystemMetrics(SM_CXSCREEN); RECT rcDlg; ::GetWindowRect(m_hWnd, &rcDlg); ::SetWindowPos(m_hWnd, NULL, (cx + rcDlg.left - rcDlg.right)/2, 40, -1, -1, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); const MBBParams* originalParam = &m_pDlg->m_sMBBParam; GetDlgItem(IDC_EDIT_MBB_LOGIN_USERNAME).SetWindowTextA(originalParam->loginParam.strUsername); GetDlgItem(IDC_EDIT_MBB_LOGIN_PSW).SetWindowTextA(originalParam->loginParam.strPassword); GetDlgItem(IDC_EDIT_MBB_WLAN_SSID).SetWindowTextA(originalParam->wlanConnectParam.strUsername); GetDlgItem(IDC_EDIT_MBB_WLAN_PSW).SetWindowTextA(originalParam->wlanConnectParam.strPassword); CheckDlgButton(IDC_CHECK_WLAN_HIDDEN, originalParam->wlanConnectParam.Flag); if(originalParam->connectType == 1) { GetDlgItem(IDC_EDIT_MBB_WLAN_SSID).EnableWindow(FALSE); GetDlgItem(IDC_EDIT_MBB_WLAN_PSW).EnableWindow(FALSE); GetDlgItem(IDC_CHECK_WLAN_HIDDEN).EnableWindow(FALSE); } CButton btnCheck = GetDlgItem(IDC_CHECK_WLAN_HIDDEN); if(btnCheck.GetCheck() == 0) { GetDlgItem(IDC_STATIC_HIDE_TIP).ShowWindow(SW_SHOW); } else { GetDlgItem(IDC_STATIC_HIDE_TIP).ShowWindow(SW_HIDE); } //CheckDlgButton(IDC_CHECK_WLAN_HIDDEN, FALSE); //GetDlgItem(IDC_CHECK_WLAN_HIDDEN).EnableWindow(FALSE); return TRUE; } BOOL CWlanConfigDlg::HasUpdated(BOOL refresh /*= TRUE*/) { if(refresh) { UpdateValue(); } BOOL changed = FALSE; MBBParams* originalParam = &m_pDlg->m_sMBBParam; if(originalParam->loginParam.strUsername.Compare((LPCTSTR)m_strLoginUsername) != 0) { originalParam->loginParam.strUsername = (LPCTSTR)m_strLoginUsername; changed = TRUE; } if(originalParam->loginParam.strPassword.Compare((LPCTSTR)m_strLoginPassword) != 0) { originalParam->loginParam.strPassword = (LPCTSTR)m_strLoginPassword; changed = TRUE; } if(originalParam->wlanConnectParam.strUsername.Compare((LPCTSTR)m_strWlanSSID) != 0) { originalParam->wlanConnectParam.strUsername = (LPCTSTR)m_strWlanSSID; changed = TRUE; } if(originalParam->wlanConnectParam.strPassword.Compare((LPCTSTR)m_strWlanPassword) != 0) { originalParam->wlanConnectParam.strPassword = (LPCTSTR)m_strWlanPassword; changed = TRUE; } if(originalParam->wlanConnectParam.Flag != m_fHidden) { originalParam->wlanConnectParam.Flag = m_fHidden; changed = TRUE; } return changed; } LRESULT CMobileDlg::OnBnSetfocusRadioMbbWlan(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { m_wlanClickedTimes = 0; Dbg("OnBnSetfocusRadioMbbWlan: %d", m_wlanClickedTimes); return 0; } LRESULT CMobileDlg::OnBnKillfocusRadioMbbWlan(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { m_wlanClickedTimes = 0; Dbg("OnBnKillfocusRadioMbbWlan: %d", m_wlanClickedTimes); return 0; } LRESULT CMobileDlg::OnBnClickedRadioMbbWlan(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { Dbg("OnBnClickedRadioMbbWlan: %d", m_wlanClickedTimes); if(IsDlgButtonChecked(IDC_RADIO_MBB_WLAN) && IsDlgButtonChecked(IDC_RADIO_WEB)) { if(++m_wlanClickedTimes >= 3) { GetDlgItem(IDC_BUTTON_MBB_CONFIG).ShowWindow(TRUE); m_wlanClickedTimes = 0; } } else { m_wlanClickedTimes = 0; } return 0; } LRESULT CMobileDlg::OnBnDoubleclickedRadioMbbWlan(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { Dbg("OnBnDoubleclickedRadioMbbWlan: %d", m_wlanClickedTimes); return 0; }