mod_MobileDial.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // mod_MobileDial.cpp : Defines the exported functions for the DLL application.
  2. //
  3. #include "stdafx2.h"
  4. #include "mod_MobileDial.h"
  5. #include "MobileDlg.h"
  6. CAppModule _Module;
  7. void CMobileDialServerSession::Handle_Query(SpReqAnsContext<MobileDialService_Query_Req, MobileDialService_Query_Ans>::Pointer ctx)
  8. {
  9. LOG_FUNCTION();
  10. m_pEntity->Query(ctx);
  11. }
  12. void CMobileDialServerSession::Handle_GetDevInfo(SpReqAnsContext<MobileDialService_GetDevInfo_Req, MobileDialService_GetDevInfo_Ans>::Pointer ctx)
  13. {
  14. LOG_FUNCTION();
  15. m_pEntity->GetDevInfo(ctx);
  16. }
  17. void CMobileDialServerSession::Handle_ShowDialog(SpOnewayCallContext<MobileDialService_ShowDialog_Info>::Pointer ctx)
  18. {
  19. m_pEntity->CreateMobileDialog(ctx);
  20. }
  21. unsigned int WINAPI CMobileDialEntity::WndThreadEntry(PVOID param)
  22. {
  23. CMobileDialEntity* pEntity = reinterpret_cast<CMobileDialEntity*>(param);
  24. pEntity->GetFunction()->InitLogCurrentThread();
  25. pEntity->WndEntry();
  26. return 0;
  27. }
  28. BOOL CMobileDialEntity::UpdateProfileInfo(LPCTSTR lpszInterfaceId)
  29. {
  30. return FALSE;
  31. }
  32. BOOL CMobileDialEntity::UpdateProfileInfo(int nCurSel)
  33. {
  34. return m_fsm.UpdateProfileInfo(nCurSel);
  35. }
  36. BOOL CMobileDialEntity::UpdateSubInfo(int nCurSel)
  37. {
  38. return m_fsm.UpdateSubInfo(nCurSel);
  39. }
  40. ErrorCodeEnum CMobileDialEntity::Connect(
  41. int nWayToConnect, LPCTSTR lpszInterfaceID, LPCTSTR lpszProfileName)
  42. {
  43. LOG_FUNCTION();
  44. FSMEvent *e = new FSMEvent(USER_EVT_CONNECT_FINISHED);
  45. if(nWayToConnect == CNT_MBN) {
  46. //MBN
  47. if(m_fsm.Dial4GConnectEx(lpszInterfaceID, lpszProfileName) > 0) {
  48. e->param1 = 4;
  49. m_fsm.PostEventLIFO(e);
  50. return Error_Succeed;
  51. } else {
  52. e->param1 = -1;
  53. m_fsm.PostEventLIFO(e);
  54. return Error_Unexpect;
  55. }
  56. } else if(nWayToConnect == CNT_RAS) {
  57. //RAS
  58. if(m_fsm.Dial3GConnectEx(lpszInterfaceID, lpszProfileName) > 0) {
  59. e->param1 = 3;
  60. m_fsm.PostEventLIFO(e);
  61. return Error_Succeed;
  62. } else {
  63. e->param1 = -1;
  64. m_fsm.PostEventLIFO(e);
  65. return Error_Unexpect;
  66. }
  67. } else if(nWayToConnect == CNT_MBB) {
  68. //HuaWei MBB
  69. //if(m_fsm.SwithMBBConnectStatus(TRUE)) {
  70. // e->param1 = 5;
  71. // m_fsm.PostEventLIFO(e);
  72. // return Error_Succeed;
  73. //} else {
  74. // e->param1 = -1;
  75. // m_fsm.PostEventLIFO(e);
  76. // return Error_Unexpect;
  77. //}
  78. MBBDialupTask* task = new MBBDialupTask(&m_fsm);
  79. GetFunction()->PostThreadPoolTask(task);
  80. return Error_Succeed;
  81. }
  82. e->DecRef();
  83. return Error_NoDefine;
  84. }
  85. ErrorCodeEnum CMobileDialEntity::Disconnect(int nWayToConnect, LPCTSTR lpszInterfaceID)
  86. {
  87. if(nWayToConnect == CNT_MBN) {
  88. //MBN
  89. if(m_fsm.Dis4GConnect(lpszInterfaceID)) {
  90. return Error_Succeed;
  91. } else {
  92. return Error_Unexpect;
  93. }
  94. } else if(nWayToConnect == CNT_RAS) {
  95. //RAS
  96. if(m_fsm.RasHangUpSuffix(FALSE)) {
  97. return Error_Succeed;
  98. } else {
  99. return Error_Unexpect;
  100. }
  101. } else if(nWayToConnect == CNT_MBB) {
  102. //HuaWei MBB
  103. MBBDialupTask* task = new MBBDialupTask(&m_fsm, FALSE);
  104. GetFunction()->PostThreadPoolTask(task);
  105. return Error_Succeed;
  106. //if(m_fsm.SwithMBBConnectStatus(FALSE)) {
  107. // return Error_Succeed;
  108. //} else {
  109. // return Error_Unexpect;
  110. //}
  111. }
  112. return Error_NoDefine;
  113. }
  114. ErrorCodeEnum CMobileDialEntity::AddNewProfile(
  115. const CSimpleStringA csInterfaceID, const AccessKeyInfo newInfo, bool fApplyNow)
  116. {
  117. return m_fsm.AddNewProfile(csInterfaceID, newInfo, fApplyNow);
  118. }
  119. ErrorCodeEnum CMobileDialEntity::UpdateProfile(const CSimpleStringA csInterfaceID, LPCTSTR lpszProfileName, const AccessKeyInfo newInfo, bool fApplyNow)
  120. {
  121. return m_fsm.UpdateProfile(csInterfaceID, lpszProfileName, newInfo, fApplyNow);
  122. }
  123. ErrorCodeEnum CMobileDialEntity::DeleteProfile(int nDongleIdx, int nProfileIdx)
  124. {
  125. return m_fsm.DeleteProfile(nDongleIdx, nProfileIdx);
  126. }
  127. ErrorCodeEnum CMobileDialEntity::SwitchDefaultSlot(int slotIdx)
  128. {
  129. return m_fsm.SwitchDefaultSlot(slotIdx);
  130. }
  131. ErrorCodeEnum CMobileDialEntity::ConnectWIFIWithDefault()
  132. {
  133. ConnectWlanTask* pTask = new ConnectWlanTask(&m_fsm);
  134. return GetFunction()->PostEntityTaskFIFO(pTask);
  135. //return m_fsm.ConnectWithDefault();
  136. }
  137. int CMobileDialEntity::WndEntry()
  138. {
  139. // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
  140. ::DefWindowProc(NULL, 0, 0, 0L);
  141. int nRet = 0;
  142. {
  143. CMobileDlg dlgMain(this);
  144. nRet = dlgMain.DoModal();
  145. }
  146. SetEvent(m_hGUIClosedEvent);
  147. m_hDialogWnd = NULL;
  148. m_fsm.SetNotifyWnd(NULL);
  149. m_fsm.PostEventFIFO(new FSMEvent(USER_EVT_DIALOG_OUT));
  150. return nRet;
  151. }
  152. SP_BEGIN_ENTITY_MAP()
  153. SP_ENTITY(CMobileDialEntity)
  154. SP_END_ENTITY_MAP()