1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945 |
- // MainDlg.cpp : implementation of the CMobileDlg class
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx2.h"
- #include "resource.h"
- #include "MobileDlg.h"
- #include <TlHelp32.h>
- #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; i<g_DongleInfos.GetCount(); ++i) {
- if(g_DongleInfos[i].usDeviceType == DEVTYPE_ANDROID_MAIN && nCntType == 3) {
- nIndex = i;
- break;
- } else if(g_DongleInfos[i].usDeviceType == DEVTYPE_ANDROID_VICE && nCntType == 4) {
- nIndex = i;
- break;
- }
- }
- */
- }
- if(m_pEntity->UpdateProfileInfo(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<info.GetCount(); ++i) {
- m_comboProfiles.AddString(info[i].AccessInfo.strProfileDesc);
- Dbg("mProfileDesc:%s vs %s", (LPCTSTR)m_strProfileDesc, (LPCTSTR)info[i].AccessInfo.strProfileDesc);
- if(bApply && !info[i].AccessInfo.strProfileDesc.Compare((LPCTSTR)m_strProfileDesc)) {
- Dbg("selected: %d", i);
- aim = i;
- } else if(/*m_bConnected && */g_DongleInfos[nIndex].subInfo.strProfileName.GetLength() > 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);
- 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)
- {
- MessageBox("启动触摸键盘失败!", 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);
- //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)", cnt));
- if(cnt > 0) {
- int cntType = CNT_INVALID;
- EnableControls(TRUE);
- int aim = 0;
- int activeOne = -1;
- m_dongleType = 0;
- for(int i=0; i<cnt; ++i) {
- m_comboDongles.AddString(g_DongleInfos[i].subInfo.strProviderName);
- if(g_DongleInfos[i].subInfo.mbnCntState == MBN_ACTIVATION_STATE_ACTIVATED) {
- aim = i;
- if(g_DongleInfos[aim].usDeviceType & DEVTYPE_ANDROID_UKNOWN) {
- cntType = CNT_ANDROID;
- } else if(g_DongleInfos[aim].usDeviceType == DEVTYPE_MODEM) {
- cntType = CNT_RAS;
- } else if(g_DongleInfos[aim].usDeviceType == DEVTYPE_MBB) {
- cntType = CNT_MBB;
- } else if(g_DongleInfos[aim].usDeviceType == DEVTYPE_INTER){
- cntType = CNT_MBN;
- }
- }
- if(g_DongleInfos[i].priority > 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<g_DongleInfos.GetCount(); ++i)
- {
- Dbg("GetInterfaceIdInCombo::idx[%d] %s", i, (LPCTSTR)g_DongleInfos[i].subInfo.strProviderName);
- if(!strDongle.Compare((LPCTSTR)g_DongleInfos[i].subInfo.strProviderName)) {
- strCurDongle = g_DongleInfos[i].csInterfaceId;
- nSel = i;
- Dbg("break");
- break;
- }
- }
- return nSel;
- }
- BOOL CMobileDlg::HasUpdatedMBBParam()
- {
- if(m_nGenType != 4) {
- return FALSE;
- }
- if(m_sMBBParam.connectType != m_sReverseMBBParam.connectType) {
- Dbg("@1@");
- return TRUE;
- }
- if(m_sMBBParam.loginParam.strUsername.Compare(
- (LPCTSTR)m_sReverseMBBParam.loginParam.strUsername) != 0) {
- Dbg("@2@");
- return TRUE;
- }
- if(m_sMBBParam.loginParam.strPassword.Compare(
- (LPCTSTR)m_sReverseMBBParam.loginParam.strPassword) != 0) {
- Dbg("@3@");
- return TRUE;
- }
- if(m_sMBBParam.wlanConnectParam.strUsername.Compare(
- (LPCTSTR)m_sReverseMBBParam.wlanConnectParam.strUsername) != 0) {
- Dbg("@4@");
- return TRUE;
- }
- if(m_sMBBParam.wlanConnectParam.strPassword.Compare(
- (LPCTSTR)m_sReverseMBBParam.wlanConnectParam.strPassword) != 0) {
- Dbg("@5@");
- return TRUE;
- }
- if(m_sMBBParam.wlanConnectParam.Flag != m_sReverseMBBParam.wlanConnectParam.Flag) {
- Dbg("@6@");
- return TRUE;
- }
- return FALSE;
- }
- LRESULT CMobileDlg::OnBnClickedButtonApnStore(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
- {
- CloseVirtualKeyboard();
- DoDataExchange(TRUE);
- const int nCntType = m_comboCntType.GetCurSel();
- int nSel = m_comboProfiles.GetCurSel();
- CSimpleStringA strCurDongle;
- int nIndex = GetInterfaceIdInCombo(strCurDongle);
- Dbg("nIndex : %d vs nSel: %d", nIndex, nSel);
- if(nCntType <= 0) {
- //TODO:在之前应该设为该选择框不可用
- MessageBoxA("意料之外的拨号类型!");
- return 0;
- }
- BOOL bAndroid = (nCntType == 4 || nCntType == 3) ? TRUE : FALSE;
- if(nIndex < 0) {
- MessageBoxA(bAndroid ? "请选择要为其添加配置的卡槽!" : "请选择要为其添加配置的网卡!");
- return 0;
- } else if(strCurDongle.GetLength() <= 0) {
- MessageBoxA(bAndroid ? "数据卡不存在,请关闭后重新打开当前配置窗口!" : "无线网卡不存在,请关闭后重新打开当前配置窗口!");
- return 0;
- }
- BOOL bUpdate = FALSE;
- if(GetDlgItem(IDC_BUTTON_DELETE).IsWindowEnabled()) {
- bUpdate = TRUE;
- if(bAndroid || nCntType == CNT_MBB) {
- //let it empty.
- } else if(g_DongleInfos[nIndex].subInfo.mbnCntState == MBN_ACTIVATION_STATE_ACTIVATED) {
- MessageBox("请先断开连接再进行更新保存!", "提示", MB_OK);
- return 0;
- }
- }
- //Profile description.
- CEdit edit = GetDlgItem(IDC_EDIT_PROFILE);
- int nLen = edit.GetWindowTextLength();
- if(nLen <= 0) {
- MessageBoxA("请输入配置文件名称!");
- return 0;
- }
- edit.GetWindowText(m_strProfileDesc.GetBuffer(nLen), nLen + 1);
- m_strProfileDesc.ReleaseBuffer();
- CString strApn;
- nLen = m_edtAPN.GetWindowTextLength();
- if((nCntType == CNT_MBN || nCntType == CNT_MBB) && nLen <= 0) {
- MessageBoxA("请输入接入点(APN)名称!");
- return 0;
- }
- m_edtAPN.GetWindowText(strApn.GetBuffer(nLen + 1), nLen + 1);
- strApn.ReleaseBuffer(nLen);
- strApn.TrimLeft();
- strApn.TrimRight();
- m_strUserName.TrimLeft();
- m_strUserName.TrimRight();
- if(m_strUserName.GetLength() <= 0) {
- MessageBoxA("请输入用户名!");
- return 0;
- }
- m_strPassword.TrimLeft();
- m_strPassword.TrimRight();
- if(m_strPassword.GetLength() <= 0) {
- MessageBoxA("请输入密码!");
- return 0;
- } else if(nCntType == CNT_MBB) {
- std::string password((LPCTSTR)m_strPassword);
- if(std::string::npos != password.find_first_of(",\":;\\&%+'<>?")) {
- 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<g_DongleInfos.GetCount(); ++i) {
- if(g_DongleInfos[i].usDeviceType == DEVTYPE_ANDROID_MAIN && nCntType == 3) {
- nIndex = i;
- break;
- } else if(g_DongleInfos[i].usDeviceType == DEVTYPE_ANDROID_VICE && nCntType == 4) {
- nIndex = i;
- break;
- }
- }
- */
- }
- int aim = -1;
- for(int i=0; i<g_DongleInfos[nIndex].profileList.GetCount(); ++i) {
- if(!g_DongleInfos[nIndex].profileList[i].AccessInfo.strProfileDesc.Compare((LPCTSTR)m_strProfileDesc)) {
- if(!bUpdate) {
- MessageBoxA("该配置文件名称已存在,请尝试更换名称!");
- return 0;
- } else {
- aim = i;
- break;
- }
- }
- }
- if(bUpdate && aim == -1) {
- assert(FALSE);
- }
- AccessKeyInfo newInfo;
- memset(&newInfo, 0, sizeof(newInfo));
- newInfo.strProfileDesc = (LPCTSTR)m_strProfileDesc;
- newInfo.strAccessString = (LPCTSTR)strApn;
- newInfo.strUserName = (LPCTSTR)m_strUserName;
- newInfo.strPassword = (LPCTSTR)m_strPassword;
- if(bAndroid) {
- newInfo.usCntType = CNT_ANDROID;
- } else {
- newInfo.usCntType = nCntType;
- }
- newInfo.usAPType = 0;
- if(nCntType == CNT_MBN || bAndroid || nCntType == CNT_MBB) {
- {
- int selected = m_comboModeType.GetCurSel();
- if(selected < 0) {
- MessageBoxA(bAndroid ? "请选择合适的身份验证类型!" : "请选择合适的登录类型!");
- return 0;
- }
- nLen = m_comboModeType.GetLBTextLen(selected);
- if(nCntType == CNT_MBN) {
- CString strTemp;
- m_comboModeType.GetLBText(selected, strTemp.GetBuffer(nLen));
- strTemp.ReleaseBuffer();
- if(!strTemp.Compare("无")) {
- strTemp = "NONE";
- } else if(!strTemp.Compare("MS-CHAP v2")) {
- strTemp = "MsCHAPv2";
- }
- newInfo.strAuthProtocol = strTemp;
- } else {//CNT_MBB
- if(selected == 1) {
- newInfo.usAPType = AUPR_PAP;
- } else if(selected == 2) {
- newInfo.usAPType = AUPR_CHAP;
- } else if(selected == 3) {
- newInfo.usAPType = AUPR_PAPORCHAP;
- }
- }
- }
- if(nCntType == CNT_MBN || nCntType == CNT_MBB)
- {
- const int selected = m_comboIPType.GetCurSel();
- if(selected < 0) {
- MessageBoxA("请选择合适的IP类型!");
- return 0;
- } else if((nCntType == CNT_MBB && (selected < 0 || selected > 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);
- }
- 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<info.GetCount(); ++i) {
- m_comboProfiles.AddString(info[i].AccessInfo.strProfileDesc);
- Dbg("%s - %s", (LPCTSTR)info[i].strProfileName, (LPCTSTR)info[i].AccessInfo.strProfileDesc);
- // m_bConnected && ?? [12/4/2019 19:18 @Gifur]
- if(aim == -1 &&/*m_bConnected && */g_DongleInfos[nIndex].subInfo.strProfileName.GetLength() > 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);
- }
- //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;
- }
|