123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- // mod_MobileDial.cpp : Defines the exported functions for the DLL application.
- //
- #include "stdafx2.h"
- #include "mod_MobileDial.h"
- #include "MobileDlg.h"
- CAppModule _Module;
- void CMobileDialServerSession::Handle_Query(SpReqAnsContext<MobileDialService_Query_Req, MobileDialService_Query_Ans>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->Query(ctx);
- }
- void CMobileDialServerSession::Handle_GetDevInfo(SpReqAnsContext<MobileDialService_GetDevInfo_Req, MobileDialService_GetDevInfo_Ans>::Pointer ctx)
- {
- LOG_FUNCTION();
- m_pEntity->GetDevInfo(ctx);
- }
- void CMobileDialServerSession::Handle_ShowDialog(SpOnewayCallContext<MobileDialService_ShowDialog_Info>::Pointer ctx)
- {
- m_pEntity->CreateMobileDialog(ctx);
- }
- unsigned int WINAPI CMobileDialEntity::WndThreadEntry(PVOID param)
- {
- CMobileDialEntity* pEntity = reinterpret_cast<CMobileDialEntity*>(param);
- pEntity->GetFunction()->InitLogCurrentThread();
- pEntity->WndEntry();
- return 0;
- }
- BOOL CMobileDialEntity::UpdateProfileInfo(LPCTSTR lpszInterfaceId)
- {
- return FALSE;
- }
- BOOL CMobileDialEntity::UpdateProfileInfo(int nCurSel)
- {
- return m_fsm.UpdateProfileInfo(nCurSel);
- }
- BOOL CMobileDialEntity::UpdateSubInfo(int nCurSel)
- {
- return m_fsm.UpdateSubInfo(nCurSel);
- }
- ErrorCodeEnum CMobileDialEntity::Connect(
- int nWayToConnect, LPCTSTR lpszInterfaceID, LPCTSTR lpszProfileName)
- {
- LOG_FUNCTION();
- FSMEvent *e = new FSMEvent(USER_EVT_CONNECT_FINISHED);
- if(nWayToConnect == CNT_MBN) {
- //MBN
- if(m_fsm.Dial4GConnectEx(lpszInterfaceID, lpszProfileName) > 0) {
- e->param1 = 4;
- m_fsm.PostEventLIFO(e);
- return Error_Succeed;
- } else {
- e->param1 = -1;
- m_fsm.PostEventLIFO(e);
- return Error_Unexpect;
- }
- } else if(nWayToConnect == CNT_RAS) {
- //RAS
- if(m_fsm.Dial3GConnectEx(lpszInterfaceID, lpszProfileName) > 0) {
- e->param1 = 3;
- m_fsm.PostEventLIFO(e);
- return Error_Succeed;
- } else {
- e->param1 = -1;
- m_fsm.PostEventLIFO(e);
- return Error_Unexpect;
- }
- } else if(nWayToConnect == CNT_MBB) {
- //HuaWei MBB
- //if(m_fsm.SwithMBBConnectStatus(TRUE)) {
- // e->param1 = 5;
- // m_fsm.PostEventLIFO(e);
- // return Error_Succeed;
- //} else {
- // e->param1 = -1;
- // m_fsm.PostEventLIFO(e);
- // return Error_Unexpect;
- //}
- MBBDialupTask* task = new MBBDialupTask(&m_fsm);
- GetFunction()->PostThreadPoolTask(task);
- return Error_Succeed;
- }
- e->DecRef();
- return Error_NoDefine;
- }
- ErrorCodeEnum CMobileDialEntity::Disconnect(int nWayToConnect, LPCTSTR lpszInterfaceID)
- {
- if(nWayToConnect == CNT_MBN) {
- //MBN
- if(m_fsm.Dis4GConnect(lpszInterfaceID)) {
- return Error_Succeed;
- } else {
- return Error_Unexpect;
- }
- } else if(nWayToConnect == CNT_RAS) {
- //RAS
- if(m_fsm.RasHangUpSuffix(FALSE)) {
- return Error_Succeed;
- } else {
- return Error_Unexpect;
- }
- } else if(nWayToConnect == CNT_MBB) {
- //HuaWei MBB
- MBBDialupTask* task = new MBBDialupTask(&m_fsm, FALSE);
- GetFunction()->PostThreadPoolTask(task);
- return Error_Succeed;
- //if(m_fsm.SwithMBBConnectStatus(FALSE)) {
- // return Error_Succeed;
- //} else {
- // return Error_Unexpect;
- //}
- }
- return Error_NoDefine;
- }
- ErrorCodeEnum CMobileDialEntity::AddNewProfile(
- const CSimpleStringA csInterfaceID, const AccessKeyInfo newInfo, bool fApplyNow)
- {
- return m_fsm.AddNewProfile(csInterfaceID, newInfo, fApplyNow);
- }
- ErrorCodeEnum CMobileDialEntity::UpdateProfile(const CSimpleStringA csInterfaceID, LPCTSTR lpszProfileName, const AccessKeyInfo newInfo, bool fApplyNow)
- {
- return m_fsm.UpdateProfile(csInterfaceID, lpszProfileName, newInfo, fApplyNow);
- }
- ErrorCodeEnum CMobileDialEntity::DeleteProfile(int nDongleIdx, int nProfileIdx)
- {
- return m_fsm.DeleteProfile(nDongleIdx, nProfileIdx);
- }
- ErrorCodeEnum CMobileDialEntity::SwitchDefaultSlot(int slotIdx)
- {
- return m_fsm.SwitchDefaultSlot(slotIdx);
- }
- ErrorCodeEnum CMobileDialEntity::ConnectWIFIWithDefault()
- {
- ConnectWlanTask* pTask = new ConnectWlanTask(&m_fsm);
- return GetFunction()->PostEntityTaskFIFO(pTask);
- //return m_fsm.ConnectWithDefault();
- }
- int CMobileDialEntity::WndEntry()
- {
- // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
- ::DefWindowProc(NULL, 0, 0, 0L);
- int nRet = 0;
- {
- CMobileDlg dlgMain(this);
- nRet = dlgMain.DoModal();
- }
- SetEvent(m_hGUIClosedEvent);
- m_hDialogWnd = NULL;
- m_fsm.SetNotifyWnd(NULL);
- m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_DIALOG_OUT));
- return nRet;
- }
- SP_BEGIN_ENTITY_MAP()
- SP_ENTITY(CMobileDialEntity)
- SP_END_ENTITY_MAP()
|