📄 mobileassistantview.cpp
字号:
SetMobileParameter ();
SetMobileNOHead ();
if ( !m_MobileControl.Init ( TRUE, TRUE, g_hEvt_TerminateSys, m_nComNo, atoi(CMultiByteString(m_csBaudRate).GetBuffer()) ) )
{
ToolBarEnableButton ( ID_BUTTON_OpenPort, TRUE );
}
else
{
}
}
void CMobileAssistantView::OnBUTTONClear()
{
if ( !GetDlgItem(IDC_EDIT_Log) || !::IsWindow ( GetDlgItem(IDC_EDIT_Log)->GetSafeHwnd() ) )
return;
GetDlgItem(IDC_EDIT_Log)->SetWindowText ( _T("") );
}
void CMobileAssistantView::OnBUTTONExit()
{
AfxGetMainWnd ()-> PostMessage ( WM_CLOSE );
}
LRESULT Proc_SendSMSEnd ( ENUM_ERROR_TYPE eResult, SM_PARAM *psm, WPARAM wParam, LPARAM lParam )
{
CMobileAssistantView *pMobileAssistantView = reinterpret_cast<CMobileAssistantView*> ( wParam );
ASSERT ( pMobileAssistantView );
return pMobileAssistantView->Proc_SendSMSEnd ( eResult, psm, wParam, lParam );
}
BOOL CMobileAssistantView::Proc_SendSMSEnd ( ENUM_ERROR_TYPE eResult, SM_PARAM *psm, WPARAM wParam, LPARAM lParam )
{
ASSERT ( psm );
Log ( L_NORMAL, _T("Send SMS [%s] to [%s] %s"), GetCompatibleString(psm->TP_UD_Byte,FALSE), GetCompatibleString(psm->TPA,FALSE),
(eResult==ENUM_ERROR_TYPE_SUCCESS)?_T("successfully"):g_pErrorTypeDesc[eResult] );
return TRUE;
}
void CMobileAssistantView::OnBUTTONSendSMS()
{
SetMobileParameter ();
if ( m_csReceiverMobileNO.GetLength () < 1|| m_csSMSContent.GetLength () < 1 )
{
AfxMessageBox ( _T("Enter error") );
return;
}
CStringArray StrAry;
PartStringAndAddToStrAry ( m_csReceiverMobileNO, StrAry, _T(';') );
for ( int i=0; i<StrAry.GetSize(); i++ )
{
CString csRecverNO = StrAry.GetAt(i);
Log ( L_VERBOSE, _T("Send SMS to [%s] ..."), csRecverNO );
if ( m_MobileControl.SendSMS ( ENUM_MOBILESMSTYPE_Personal, csRecverNO, CMultiByteString(m_csSMSContent).GetBuffer(),
0, ::Proc_SendSMSEnd, WPARAM(this) ) != ENUM_ERROR_TYPE_SUCCESS )
{
Log ( L_WARNING, _T("Send SMS failed !!!") );
break;
}
}
}
void CMobileAssistantView::OnBUTTONRecvSMS()
{
}
void CMobileAssistantView::OnBUTTONReadSMS()
{
}
void CMobileAssistantView::OnBUTTONReadOnePhoneBook()
{
Log ( L_VERBOSE, _T("Reading phone book ...") );
EnableWindow ( FALSE );
CString csPhoneBook;
GetDlgItemText ( IDC_COMBO_PhoneBook, csPhoneBook );
int nSpacePos = csPhoneBook.Find ( _T(" "), 0 );
if ( nSpacePos < 0 ) nSpacePos = csPhoneBook.GetLength();
csPhoneBook = csPhoneBook.Left (nSpacePos);
t_Ary_PhoneBook Ary_PhoneBook;
Ary_PhoneBook.SetSize ( 0, 10*sizeof(t_PhoneBook) );
if ( !m_MobileControl.gsmReadPhoneBook ( csPhoneBook, &Ary_PhoneBook ) )
{
Log ( L_WARNING, _T("Read phone book [%s] failed"), csPhoneBook );
EnableWindow ( TRUE );
return;
}
for ( int i=0; i<Ary_PhoneBook.GetSize(); i++ )
{
t_PhoneBook &PhoneBook = Ary_PhoneBook.GetAt ( i );
Log ( L_NORMAL, _T("Phone book information :NO.%d - [%s] - %s - %s"), PhoneBook.nIndex,
PhoneBook.szPhoneBookName, PhoneBook.szName, PhoneBook.szPhoneNO );
}
Log ( L_VERBOSE, _T("Read phone book finished. record number : %d"), Ary_PhoneBook.GetSize() );
EnableWindow ( TRUE );
}
void CMobileAssistantView::OnBUTTONReadPhoneBook()
{
EnableWindow ( FALSE );
t_Ary_PhoneBook *pAry_PhoneBook = m_MobileControl.ReadPhoneBook ();
if ( !pAry_PhoneBook )
{
Log ( L_WARNING, _T("Read PhoneBook failed") );
EnableWindow ( TRUE );
return;
}
for ( int i=0; i<pAry_PhoneBook->GetSize(); i++ )
{
t_PhoneBook &PhoneBook = pAry_PhoneBook->GetAt ( i );
Log ( L_NORMAL, _T("电话本信息:NO.%d - [%s] - %s - %s"), PhoneBook.nIndex,
PhoneBook.szPhoneBookName, PhoneBook.szName, PhoneBook.szPhoneNO );
}
HwDbgLog ( L_DEBUG, _T("读取电话本已经全部结束, 共 %d 条纪录"), pAry_PhoneBook->GetSize() );
DELETE_ARRAY ( &pAry_PhoneBook );
EnableWindow ( TRUE );
}
BOOL CMobileAssistantView::Proc_ReceivedSMS ( SM_PARAM *pSMRecv )
{
ASSERT ( pSMRecv );
if ( !pSMRecv ) return FALSE;
char szRecvTime[DATETIME_TYPE_LENGTH+1] = {0};
m_MobileControl.Convert_SCTS2Standard ( pSMRecv->TP_SCTS, szRecvTime, sizeof(szRecvTime) );
Log ( L_NORMAL, _T("\r\nReceived SMS : NO.%d - %s - [%s]\r\n%s\r\n"), pSMRecv->index, GetCompatibleString(pSMRecv->TPA,FALSE),
GetCompatibleString(szRecvTime,FALSE), GetCompatibleString(pSMRecv->TP_UD_Byte,FALSE) );
return TRUE;
}
void CMobileAssistantView::OnBUTTONAddPhoneBook()
{
EnableWindow ( FALSE );
CString csName, csPhoneNO, csPhoneBook;
GetDlgItemText ( IDC_EDIT_Name, csName );
GetDlgItemText ( IDC_EDIT_PhoneNO, csPhoneNO );
GetDlgItemText ( IDC_COMBO_PhoneBook, csPhoneBook );
int nSpacePos = csPhoneBook.Find ( _T(" "), 0 );
if ( nSpacePos < 0 ) nSpacePos = csPhoneBook.GetLength();
csPhoneBook = csPhoneBook.Left (nSpacePos);
if ( csName.GetLength () < 1 || csPhoneNO.GetLength () < 1 || csPhoneBook.GetLength () < 1 )
{
AfxMessageBox ( _T("Enter Phone Datum Error") );
EnableWindow ( TRUE );
return;
}
if ( !m_MobileControl.InsertPhoneBook ( csName, csPhoneNO, csPhoneBook ) )
{
AfxMessageBox ( _T("Insert PhoneBook Failed") );
}
EnableWindow ( TRUE );
}
void CMobileAssistantView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
Align ();
}
BOOL CMobileAssistantView::ToolBarEnableButton(int nID, BOOL bEnable)
{
CToolBarCtrl &ToolBarCtrl = ( (CMainFrame*)AfxGetMainWnd() )->m_wndToolBar.GetToolBarCtrl ();
return ToolBarCtrl.EnableButton ( nID, bEnable );
}
void CMobileAssistantView::OnTimer(UINT nIDEvent)
{
#ifdef _IS_HOWA_MOBILE_MODULE_TOOLS
if ( m_csSMSC.GetLength() <= 0 )
{
CString csSMSC = m_MobileControl.RetrievesSMSC ();
if ( csSMSC.GetLength() > 0 )
{
KillTimer ( nIDEvent );
UpdateData ( TRUE );
m_csSMSC = csSMSC;
UpdateData ( FALSE );
}
}
#endif
CFormView::OnTimer(nIDEvent);
}
void CMobileAssistantView::SetMobileNOHead()
{
t_Ary_MobileNOHead Ary_MobileNOHead;
Ary_MobileNOHead.SetSize ( 0, 10*sizeof(t_MobileNOHead) );
t_MobileNOHead MobileNOHead = {0};
memset ( &MobileNOHead, 0, sizeof(t_MobileNOHead) );
// 大陆全球通
lstrcpy ( MobileNOHead.szCountryCode, _T("0086") ); // 国家代码
lstrcpy ( MobileNOHead.szAreaCode, _T("") ); // 地区代码
lstrcpy ( MobileNOHead.szMobileNoHead, _T("13") ); // 手机字头
lstrcpy ( MobileNOHead.szPrepositiveNO, _T("") ); // 前置号码
MobileNOHead.dwMobileNOFormat = SMS_MobileNO_Format_CountryCode; // 字头格式
lstrcpy ( MobileNOHead.szDesc, _T("大陆全球通") ); // 描述
Ary_MobileNOHead.Add ( MobileNOHead );
memset ( &MobileNOHead, 0, sizeof(t_MobileNOHead) );
// 台湾全球通
lstrcpy ( MobileNOHead.szCountryCode, _T("00886") ); // 国家代码
lstrcpy ( MobileNOHead.szAreaCode, _T("") ); // 地区代码
lstrcpy ( MobileNOHead.szMobileNoHead, _T("09") ); // 手机字头
lstrcpy ( MobileNOHead.szPrepositiveNO, _T("") ); // 前置号码
MobileNOHead.dwMobileNOFormat = SMS_MobileNO_Format_CountryCode; // 字头格式
lstrcpy ( MobileNOHead.szDesc, _T("台湾全球通") ); // 描述
Ary_MobileNOHead.Add ( MobileNOHead );
memset ( &MobileNOHead, 0, sizeof(t_MobileNOHead) );
m_MobileControl.ConfigParameter ( &Ary_MobileNOHead );
}
void CMobileAssistantView::EnableWindow(BOOL bEnable)
{
GetDlgItem(IDC_COMBO_COM)->EnableWindow ( bEnable );
GetDlgItem(IDC_COMBO_BaudRate)->EnableWindow ( bEnable );
GetDlgItem(IDC_EDIT_LocalCountryCode)->EnableWindow ( bEnable );
GetDlgItem(IDC_EDIT_LocalAreaCode)->EnableWindow ( bEnable );
GetDlgItem(IDC_EDIT_ReceiverMobileNO)->EnableWindow ( bEnable );
GetDlgItem(IDC_EDIT_SMSContent)->EnableWindow ( bEnable );
GetDlgItem(IDC_EDIT_Name)->EnableWindow ( bEnable );
GetDlgItem(IDC_EDIT_PhoneNO)->EnableWindow ( bEnable );
GetDlgItem(IDC_COMBO_PhoneBook)->EnableWindow ( bEnable );
GetDlgItem(IDC_BUTTON_ReadOnePhoneBook)->EnableWindow ( bEnable );
GetDlgItem(IDC_BUTTON_AddPhoneBook)->EnableWindow ( bEnable );
}
LRESULT CMobileAssistantView::OnWM_SHOWLOG(WPARAM wParam, LPARAM lParam)
{
::OnWM_SHOWLOG ( (CRichEditCtrl*)GetDlgItem(IDC_EDIT_Log), wParam, lParam );
return 0L;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -