📄 netprodlg.cpp
字号:
// if a controller still holds on to one of its objects. These
// message handlers make sure that if the proxy is still in use,
// then the UI is hidden but the dialog remains around if it
// is dismissed.
void CNetproDlg::OnClose()
{
OnOK();
WritePhonebook("Phonebook.dat","[PHONEBOOK]");
WriteCallLog("Call.log","[CALLLOG]");
CDialog::OnClose();
}
void CNetproDlg::EndDialAndJMP()
{
if((SystemStatus.bOnJMP==TRUE)&&(SystemStatus.bDialWinOnCancel==FALSE))
{
if(RasConfirmHangupAll()==FALSE)
{
TRACE0("RasConfirmHangupAll() return FALSE");
goto if_2;
}
Sleep(2000);
strcpy(m_tapiObj.m_szPhoneNumber,SystemStatus.m_EndCFBL);
m_tapiObj.Create(m_tapiObj.m_szPhoneNumber);
if (!m_tapiObj.DialCall(m_tapiObj.m_szPhoneNumber))
{
m_tapiObj.HangupCall();
AfxMessageBox(IDS_SIGN_DIVERTLINE_FAIL);
OutputDebugString("Dial call failed.\n");
}else{
m_tapiObj.HangupCall();
}
return;
}
if_2:
/*
if(((SystemStatus.bOnDial==TRUE)||(SystemStatus.bOnJMP==TRUE))&&(SystemStatus.bDialWinOnCancel==FALSE))
{
Sleep(1000);
if(RasHangupAll()==FALSE)
AfxMessageBox("fff");
}*/
return;
}
void CNetproDlg::OnOK()
{
if (CanExit())
{
if(pConf!=NULL)
{
delete pConf;
pConf=NULL;
}
EnableWindow(FALSE);
if(m_ModemTestTimer)
{
KillTimer(m_ModemTestTimer);
m_ModemTestTimer=0;
}
if(m_bOnLine)
{
m_oDN = "0";
ModemTest();
}
//m_cMsgwnd.m_cDialUp ="正在退出软件";
//m_cMsgwnd.m_cStatus = "欢迎使用 FFCS IP 电话";
//m_cMsgwnd.PaintFlame();
m_pMsgWndOwner->SetMsgWndStatus(IDS_EXITING_PROGRAM,3);
m_pMsgWndOwner->SetMsgWndStatus(IDS_WELCOME_USE_IPHONE,0);
m_TrayIcon.HideIcon();
EndDialAndJMP();
ShowWindow(SW_HIDE);
if(WaitForSingleObject(m_hEventConnectThread,1000)!=WAIT_OBJECT_0)
{
}
CDialog::OnOK();
}
}
void CNetproDlg::OnCancel()
{
if (CanExit())
{
if(pConf!=NULL)
{
delete pConf;
pConf=NULL;
}
CDialog::OnCancel();
}
}
BOOL CNetproDlg::CanExit()
{
// If the proxy object is still around, then the automation
// controller is still holding on to this application. Leave
// the dialog around, but hide its UI.
/* if (m_pAutoProxy != NULL)
{
ShowWindow(SW_HIDE);
return FALSE;
}
*/
return TRUE;
}
LRESULT CNetproDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
switch (message)
{
case WM_CONNECTING:
//::SetDlgItemText(GetSafeHwnd(),IDC_CALLHANGUP,"挂断");
DisableButtons(FALSE,TRUE);
m_CallName=pConf->m_sRemoteUsername;
m_cStatus.Format(IDS_CALLING_TO_SB,m_CallName);
m_pMsgWndOwner->SetMsgWndStatus(m_cStatus,0);
/*
m_cMsgwnd.m_cStatus = m_cStatus;
if(m_cMsgwnd.IsWindowVisible( ))
{
m_cMsgwnd.PaintFlame();
}
*/
m_bSCInUse = TRUE;
OnAnimate();
return TRUE;
case WM_CONNECTED:
// Message from Conf object that a user is connected
DisableButtons(TRUE,FALSE);
// ::SetDlgItemText(this->m_hWnd,IDC_CALLHANGUP,"挂断");
m_CallName=pConf->m_sRemoteUsername;
m_cStatus.Format(IDS_TALKING_WITH_SB,m_CallName);
m_bSCInUse = TRUE;
/*m_cMsgwnd.m_cStatus = m_cStatus;
if(m_cMsgwnd.IsWindowVisible( ))
{
m_cMsgwnd.PaintFlame();
}
*/
m_pMsgWndOwner->SetMsgWndStatus(m_cStatus,0);
return TRUE;
case WM_DISCONNECTED:
// Message from Conf object that a user disconnected or rejected call
//::SetDlgItemText(GetSafeHwnd(),IDC_CALLHANGUP,"呼叫");
DisableButtons(FALSE,FALSE);
m_cStatus.LoadString(IDS_WELCOME_USE_IPHONE);
/*
m_cMsgwnd.m_cStatus = m_cStatus;
if(m_cMsgwnd.IsWindowVisible( ))
{
m_cMsgwnd.PaintFlame();
}
*/
m_pMsgWndOwner->SetMsgWndStatus(m_cStatus,0);
m_bSCInUse = FALSE;
return TRUE;
}
return CDialog::WindowProc(message, wParam, lParam);
}
BOOL CNetproDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
CString szNameTemp;
// TODO: Add your specialized code here and/or call the base class
switch (LOWORD(wParam))
{
case IDC_CALLHANGUP:
// If not in a call, then call szMachineName, otherwise hang up.
if (!pConf->InConnection())
{
/*char szMachineName[MAX_SZ];
::GetDlgItemText(GetSafeHwnd(),IDC_MACHINENAME,szMachineName,MAX_SZ);
szNameTemp=szMachineName;
if(szNameTemp.IsEmpty())
{
MessageBox("电话号码未填","Receive",MB_ICONSTOP);
return TRUE;
}
else
{
pConf->Call(szMachineName);
return TRUE;
}
*/
return TRUE;
}
else
{
pConf->HangUp();
return TRUE;
}
break;
case 2://press ESC
return TRUE;
case 1://press Return
return TRUE;
/* case ID_FILE_EXIT:
CDialog::OnCancel();
return TRUE;
*/ }
return CDialog::OnCommand(wParam, lParam);
}
/*void CNetproDlg::OnConnectButton()
{
// TODO: Add your control notification handler code here
CString cValue;
CString cAdr;
UINT LocalPort;
CString cSend;
int i;
if(UnConnectFlg)
{
UpdateData(TRUE);
if(m_oDN != m_origDN)
{
m_origDN = m_oDN;
CMyRegKey regKey;
long lResult = regKey.Open(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\FFCS\\VSL IPHONE\\Config"));
if(lResult==ERROR_SUCCESS)
{
//UpdateData(TRUE);
regKey.Write(_T("TELEPHONENUMBER"),m_oDN);
}
}
for( i=m_CiShu; i >0; --i )
{
CClientSocket* m_ClientSocket;
m_ClientSocket = new CClientSocket(this);
cSend.Format("%d",i);
cSend=m_oDN;
m_DNTemp=cSend;
//((CComboBox*)GetDlgItem(IDC_CMBSERVER))->GetLBText(m_cComboServer,cAdr);
cAdr = m_ServerArray[m_cVslServername.GetCurSel()];
if(!m_ClientSocket->Create())
{
MessageBox("ReceiveSocket create failed!","Receive",MB_ICONSTOP);
return;
}
else
{
UINT h=7777;
if(m_ClientSocket->Connect(cAdr,h))
{
m_ClientSocket->GetSockName(LocalSockAddr,(UINT &)LocalPort);
//m_cStatus.Format("发送 OK! \n Value="+cSend);
m_ClientSocket->Send(cSend,16);
// m_ClientSocket->Close();
}
else
{
m_cStatus.Format("连接不成功");
m_ClientSocket->Close();
}
}
}
m_Send.SetWindowText("初始化");
UnConnectFlg=FALSE;
}
else
{
m_CiShu=1;
m_oDN="";
UnConnectFlg=TRUE;
m_cStatus.Format(" ");//发送初始化 OK!
m_Send.SetWindowText("发送信息");
//MessageBox("ReceiveSocket has been create!","Receive",MB_ICONSTOP);
}
UpdateData(FALSE);
// cValue.Format("Send ok");
}
void CNetproDlg::OnPopupOption1()
{
//MessageBox(_T("You chose Option 1"));
ShowWindow(SW_NORMAL);
}
void CNetproDlg::OnUpdatePopupOption1(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_Option1Enabled);
}
void CNetproDlg::OnPopupOption2()
{
m_Option1Enabled = !m_Option1Enabled;
CString str;
str.Format(_T("You chose option 2. Option 1 is now %s"),
m_Option1Enabled? _T("Enabled") : _T("Disabled"));
MessageBox(str);
}
*/
void CNetproDlg::OnAnimate()
{
m_TrayIcon.SetIconList(IDI_ICON1, IDI_ICON4);
m_TrayIcon.Animate(200,5);
}
void CNetproDlg::OnSize(UINT nType, int cx, int cy)
{
if(nType == SIZE_MINIMIZED)
ShowWindow(SW_HIDE);
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
}
void CNetproDlg::ProcessOnReceive(CClientSocket *m_pClient)
{
int datasize;
char buf[128];
CString temp;
CString cValue;
if(!(datasize=m_pClient->Receive(buf,128)))
{
delete m_pClient;
return;
}
temp=buf;
temp=temp.Left(datasize);
// iValue = atoi(temp);
// ShowWindow(SW_NORMAL);
// if(iValue ==0)
// iValue = 9999999;
if(temp=="FFIT")
{
m_cStatus.LoadString(IDS_CONNECT_TO_VSL_OK);
m_origDN=m_oDN;
m_origIP=m_oIP;
OneHourCounter = 0;
//m_cMsgwnd.m_bOnline = TRUE;
m_pMsgWndOwner->SetOnline(TRUE);
KillTimer(m_ModemTestTimer);
m_ModemTestTimer = SetTimer(MODEM_TIMER_ID,2000,NULL);
}
if(temp=="FAIL")
{
m_cStatus.LoadString(IDS_SINGIN_FAILED);
}
//m_cMsgwnd.m_cStatus = m_cStatus;
//m_cMsgwnd.PaintFlame();
m_pMsgWndOwner->SetMsgWndStatus(m_cStatus,0);
m_pClient->Close();
delete m_pClient;
}
void CNetproDlg::OnPhoneGetStart()
{
unsigned short port=8888;
CString TestSock;UINT TestPort;
m_ServerSocket = new CClientSocket(this);
if(m_ServerSocket->Create(port,SOCK_STREAM,(LPCTSTR)m_oIP))
{
m_ServerSocket->GetSockName(TestSock,(UINT &)TestPort);
//m_cStatus=TestSock;
//UpdateData(FALSE);
if(m_ServerSocket->Listen(5))
{
bListenFlg=FALSE;
}
else
{
MessageBox("Listen Failed");
}
}
else
{
MessageBox("Creat Failed!");
delete m_ServerSocket;
}
}
void CNetproDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
// MessageBox("time out!","time out",MB_ICONSTOP);
if(nIDEvent==m_uTimer)
;//OnIPCompare();
else if(nIDEvent==m_ModemTestTimer)
ModemTest();
else if(nIDEvent==m_CallTimer)
{
m_CallTimerCounter++;
// ::ShowWindow(::AfxGetApp()->m_pMainWnd->m_hWnd,SW_NORMAL);
//::ShowWindow(::AfxGetApp()->m_pMainWnd->m_hWnd,SW_NORMAL);
//::SetForegroundWindow(::AfxGetApp()->m_pMainWnd->m_hWnd);
PlayCallSound();
if (m_CallTimerCounter == 6)
{
KillTimer(m_CallTimer);
m_CallTimer=0;
pConf->m_pCallNotify->RejectCall();
DisableButtons(FALSE,FALSE);
m_cStatus.LoadString(IDS_WELCOME_USE_IPHONE);
/*m_cMsgwnd.m_cStatus = m_cStatus;
if(m_cMsgwnd.IsWindowVisible( ))
{
m_cMsgwnd.PaintFlame();
}
*/
m_pMsgWndOwner->SetMsgWndStatus(m_cStatus,0);
}
}
CDialog::OnTimer(nIDEvent);
}
/*void CNetproDlg::ModemTestbak()
{
RASCONN ras[20];
DWORD dSize, dNumber,dwRet;
char szBuf[256];
RASCONNSTATUS rasconnstatus;
if(m_ModemNormal==TRUE)
{
ras[0].dwSize = sizeof( RASCONN );
dSize = sizeof( ras ); // Get active RAS - Connection
dwRet = RasEnumConnections( ras, &dSize, &dNumber );
if ( dwRet != 0 )
{
if ( RasGetErrorString( (UINT)dwRet, (LPSTR)szBuf, 256 ) != 0 )
wsprintf( (LPSTR)szBuf, "Undefined RAS Enum Connections error (%ld).", dwRet );
//m_cMsgwnd.m_cDialUp =szBuf;
//m_cMsgwnd.PaintFlame();
m_pMsgWndOwner->SetMsgWndStatus(szBuf,3);
m_ModemNormal=FALSE;
}
else
{
if(dNumber==0)
{
m_ModemNormal=FALSE;
m_cMsgwnd.m_cDialUp ="尚未拨号上网";
// m_cStatus.Format("欢迎使用 FFCS IP 电话");
// m_cMsgwnd.m_cStatus = m_cStatus;
m_cMsgwnd.PaintFlame();
}
else
{ rasconnstatus.dwSize=sizeof(rasconnstatus);
RasGetConnectStatus(ras[0].hrasconn,&rasconnstatus);
if(rasconnstatus.rasconnstate==RASCS_Connected)
{
m_cMsgwnd.m_cDialUp ="已经拨号上网";
}
}
}
}
else
{
ras[0].dwSize = sizeof( RASCONN );
dSize = sizeof( ras ); // Get active RAS - Connection
dwRet = RasEnumConnections( ras, &dSize, &dNumber );
if ( dwRet == 0 )
{
if(dNumber!=0)
{
rasconnstatus.dwSize=sizeof(rasconnstatus);
RasGetConnectStatus(ras[0].hrasconn,&rasconnstatus);
if(rasconnstatus.rasconnstate==RASCS_Connected)
{
m_cMsgwnd.m_cDialUp ="已经拨号上网";
}
else
{
m_cMsgwnd.m_cDialUp ="正在拨号上网";
}
m_ModemNormal=TRUE;
m_cMsgwnd.PaintFlame();
}
}
}
}*/
void CNetproDlg::ModemTest()
{
CDC *pDC;
RASCONN ras[20];
DWORD dSize, dNumber,dwRet;
char szBuf[256];
RASCONNSTATUS rasconnstatus;
RASPROJECTION rasprojection;
RASPPPIP raspppip;
DWORD cb;
ras[0].dwSize = sizeof( RASCONN );
dSize = sizeof( ras ); // Get active RAS - Connection
dwRet = RasEnumConnections( ras, &dSize, &dNumber );
if ( dwRet != 0 )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -