📄 cpfwindow.cpp
字号:
/*____________________________________________________________________________
Copyright (C) 1996-1999 Network Associates, Inc.
All rights reserved.
$Id: CPFWindow.cpp,v 1.14 1999/03/10 02:36:22 heller Exp $
____________________________________________________________________________*/
#include "CPFWindow.h"
#include "CXferWindow.h"
#include "CPGPFone.h"
#include "CPGPFoneFrame.h"
#include "PGPFoneUtils.h"
#include "CSoundInput.h"
#include "CSoundOutput.h"
#include "CMessageQueue.h"
#include "CControlThread.h"
#include "CEncryptionStream.h"
#include "CPhoneDialog.h"
#include "CModemDialog.h"
#include "CEncryptionDialog.h"
#include "CFileTransferDialog.h"
#include "CPFTransport.h"
#include "CStatusPane.h"
#include "fastpool.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const POINT sLogoLeftTop = {14,8};
const POINT sGainIconLeftTop = {211,12};
const POINT sVolIconLeftTop = {123,12};
const POINT sLevelMeterLeftTop = {303,11};
const RECT sCallComboBoxRect = {13,44,217,164};
const RECT sVolumeSliderRect = {138,10,198,28};
const RECT sGainSliderRect = {228,10,288,28};
const RECT sLocalIPTitleRect = {230,69,295,84};
const RECT sLocalIPRect = {296,67,388,85};
const RECT sConnectButtonRect = {13,67,85,87};
const RECT sTalkButtonRect = {86,67,217,87};
const RECT sCoderComboBoxRect = {73,97,217,217};
const RECT sDecoderComboBoxRect = {73,122,217,242};
const RECT sCoderTitleRect = {13,99,72,114};
const RECT sDecoderTitleRect = {13,124,72,139};
const RECT sRemoteIDTitleRect = {13,49,66,64};
const RECT sRemoteIDRect = {67,47,217,65};
const RECT sCryptorTitleRect = {230,99,295,114};
const RECT sCryptorRect = {296,97,388,115};
const RECT sPrimeTitleRect = {230,124,295,139};
const RECT sPrimeRect = {296,122,388,142};
const RECT sStatusPaneRect = {13,220,388,280}; //{13,155,388,215};
const RECT sTitles1Rect = {13,155,100,210}; //{13,220,100,275};
const RECT sTitles2Rect = {230,155,330,210}; //{200,220,300,275};
const RECT sInfo1Rect = {101,155,195,210}; //{101,220,195,275};
const RECT sInfo2Rect = {331,155,400,210}; //{301,220,388,275};
const RECT sDividerRect = {13,149,388,151}; //{13,155,388,215};
const RECT sStatusPaneRect2 = {13,162,388,222}; //{13,97,388,157}
const RECT sTitles1Rect2 = {13,97,100,152}; //{13,162,100,217}
const RECT sTitles2Rect2 = {230,97,330,152}; //{200,162,300,217}
const RECT sInfo1Rect2 = {101,97,195,152}; //{101,162,195,217}
const RECT sInfo2Rect2 = {331,97,400,152}; //{301,162,388,217}
const RECT sDividerRect2 = {13,92,388,94}; //{13,155,388,215};
const int sAuthWindowWidth = 153;
const int sAuthWindowHeight = 148;
const int sFTPWindowWidth = 363;
const int sFTPWindowHeight = 284;
#define IDI_TALKBUTTON 2000
#define IDI_CONNECTBUTTON 2001
#define IDI_LOCALIPTITLESTATIC 2002
#define IDI_DECODERCOMBOBOX 2003
#define IDI_CODERCOMBOBOX 2004
#define IDI_CALLCOMBOBOX 2005
#define IDI_CRYPTORTITLESTATIC 2006
#define IDI_REMOTEIDTITLESTATIC 2007
#define IDI_PRIMETITLESTATIC 2008
#define IDI_CODERTITLESTATIC 2009
#define IDI_DECODERTITLESTATIC 2010
#define IDI_LEVELMETER 2011
#define IDI_TRITHRESHOLD 2012
#define IDI_SOUNDLIGHT 2013
#define IDI_TITLES1 2014
#define IDI_TITLES2 2015
#define IDI_INFO1 2016
#define IDI_INFO2 2017
#define IDI_DIVIDER 2018
#define IDI_VOLUMESLIDER 2019
#define IDI_GAINSLIDER 2020
#define RANDOM_DATA_TIMER 1000
#define DEBUG_TIMER 1001
#define UPDATE_TIMER 1002
void DrawMaskedBitmap(CDC* pDC, UINT bitmapID, UINT maskID, POINT leftTop);
CPFWindow *gPacketWatch;
IMPLEMENT_DYNCREATE(CPFWindow, CView)
CPFWindow::CPFWindow()
{
gPacketWatch = this;
mGoodPackets = 0;
mBadPackets = 0;
mAvgHPP = 0;
mMaxQueueSize = 0;
mEntryPos = 0;
mPacketsSent = 0;
mOutputUnderflows = 0;
mOverflows = 0;
mGSMfull = 0;
mGSMlite = 0;
mGSMfullDec = 0;
mGSMliteDec = 0;
mJitter = 0;
mBandwidth = 0;
mDirty = 0;
mRTTms = 0;
mLastSampleTime = 0;
mHPPOutQueue = NULL;
mSoundOutQueue = NULL;
mSoundOutput = NULL;
mDead = FALSE;
mTalkFlag = FALSE;
mSending = FALSE;
mControlThread = NULL;
mPFoneFrame = NULL;
mViewStatusInfo = gPGFOpts.sysopt.viewStatusInfo;
mViewEncodingDetails = gPGFOpts.sysopt.viewEncodingDetails;
}
CPFWindow::~CPFWindow()
{
}
void
CPFWindow::ShowCaller()
{
StMutex mutex(*this);
char s[64];
if(mDead)
return;
mControlThread->GetRemoteName(s);
mRemoteIDTitleStatic.ShowWindow(SW_SHOW);
mRemoteIDStatic.ShowWindow(SW_SHOW);
mRemoteIDStatic.SetWindowText(s);
}
void
CPFWindow::SetState(enum CSTypes newState)
{
StMutex mutex(*this);
if(mDead)
return;
mState = newState;
ShowStatus();
}
void
CPFWindow::SetLocalAddress(char *addr)
{
mLocalIPStatic.SetWindowText(addr);
}
void
CPFWindow::SetSpeaker(Boolean speaker, Boolean fullDuplex)
{
StMutex mutex(*this);
if(mDead)
return;
mTalkFlag = (BOOLEAN)speaker;
if(fullDuplex)
mTalkButton.SetWindowText(speaker ? "Mute" : "Unmute");
else
mTalkButton.SetWindowText(speaker ? "Push to Listen":"Push to Talk");
}
void
CPFWindow::ShowAuthParams(char *params)
{
StMutex mutex(*this);
RECT frame;
if(mDead)
return;
GetParent()->GetWindowRect(&frame);
mAuthWindow.MoveWindow(frame.right+2,frame.top,
sAuthWindowWidth,
sAuthWindowHeight);
mAuthWindow.SetAuthWords(params);
mAuthWindow.ShowWindow(SW_SHOW);
}
void
CPFWindow::HideAuthParams(void)
{
StMutex mutex(*this);
if(mDead)
return;
mAuthWindow.ShowWindow(SW_HIDE);
}
void
CPFWindow::ShowStatus(void)
{
StMutex mutex(*this);
static int ID;
if(mDead || !mPFoneFrame)
return;
switch(mState)
{
case _cs_none:
case _cs_uninitialized:
case _cs_listening:
mRemoteIDStatic.ShowWindow(SW_HIDE);
mRemoteIDTitleStatic.ShowWindow(SW_HIDE);
if( gHardwareIsFullDuplex )
{
mTalkButton.SetWindowText("Test");
mTalkButton.ShowWindow(SW_SHOW);
}
mCallComboBox.ShowWindow(SW_SHOW);
mConnectButton.ShowWindow(SW_SHOW);
if(gPGFOpts.popt.connection == _cme_Serial)
{
mConnectButton.SetWindowText("Dial");
mLocalIPStatic.ShowWindow(SW_HIDE);
mLocalIPTitleStatic.ShowWindow(SW_HIDE);
}
else
{
mConnectButton.SetWindowText("Connect");
mLocalIPStatic.ShowWindow(SW_SHOW);
mLocalIPTitleStatic.ShowWindow(SW_SHOW);
}
mDecoderComboBox.EnableWindow(FALSE);
mCoderComboBox.EnableWindow(FALSE);
//SetDefID(IDC_DIAL);
break;
case _cs_connected:
mConnectButton.SetWindowText("Hangup");
mConnectButton.ShowWindow(SW_SHOW);
if(mControlThread->GetControlState() == _con_Phone)
{
SetSpeaker(mTalkFlag, mFullDuplex);
mTalkButton.ShowWindow(SW_SHOW);
mDecoderComboBox.EnableWindow(TRUE);
mCoderComboBox.EnableWindow(TRUE);
//SetDefID(IDC_TALK_LISTEN);
}
else
{
if( !gHardwareIsFullDuplex )
mTalkButton.ShowWindow(SW_HIDE);
mDecoderComboBox.EnableWindow(FALSE);
mCoderComboBox.EnableWindow(FALSE);
//SetDefID(IDC_DIAL);
}
ShowCaller();
break;
case _cs_calldetected:
mCallComboBox.ShowWindow(SW_HIDE);
mConnectButton.SetWindowText("Answer");
ShowCaller();
//SetDefID(IDC_DIAL);
break;
case _cs_connecting:
case _cs_disconnecting:
mCallComboBox.ShowWindow(SW_HIDE);
mConnectButton.ShowWindow(SW_SHOW);
if( !gHardwareIsFullDuplex )
mTalkButton.ShowWindow(SW_HIDE);
mConnectButton.SetWindowText("Hangup");
mDecoderComboBox.EnableWindow(FALSE);
mCoderComboBox.EnableWindow(FALSE);
//SetDefID(IDC_DIAL);
break;
case _cs_initializing:
mCallComboBox.ShowWindow(SW_HIDE);
mConnectButton.ShowWindow(SW_SHOW);
if( !gHardwareIsFullDuplex )
mTalkButton.ShowWindow(SW_HIDE);
mConnectButton.SetWindowText("Cancel");
mDecoderComboBox.EnableWindow(FALSE);
mCoderComboBox.EnableWindow(FALSE);
//SetDefID(IDC_DIAL);
break;
}
switch(mState)
{
case _cs_listening:
mStatusBar = "Waiting for call";
mPFoneFrame->setStatusPhoneIconID(IDR_WAITING);
break;
case _cs_none:
case _cs_uninitialized:
mStatusBar = "None";
mPFoneFrame->setStatusPhoneIconID(0);
break;
case _cs_connected:
switch(mControlThread->GetControlState())
{
default:
case _con_Configuring:
mStatusBar = "Configuring";
break;
case _con_Phone:
if(!memcmp(&mCryptor, "NONE", 4))
mPFoneFrame->setStatusSecureIconID(IDR_INSECURE);
else
mPFoneFrame->setStatusSecureIconID(IDR_SECURE);
break;
case _con_Disconnecting:
mStatusBar = "Confirming Hangup";
break;
}
mPFoneFrame->setStatusPhoneIconID(IDR_CONNECTED);
break;
case _cs_calldetected:
mStatusBar = "Ring";
break;
case _cs_connecting:
mStatusBar = "Connecting";
mPFoneFrame->setStatusPhoneIconID(IDR_CONNECTED);
break;
case _cs_disconnecting:
mStatusBar = "Disconnecting";
mPFoneFrame->setStatusPhoneIconID(IDR_CONNECTED);
break;
case _cs_initializing:
mStatusBar = "Initializing modem";
break;
default:
pgp_errstring("unknown status");
}
if(mState != _cs_connected)
mPFoneFrame->setStatusSecureIconID(ID);
}
void
CPFWindow::SetDecoder(ulong coder)
{
StMutex mutex(*this);
short index = 0;
char *name;
if(mDead)
return;
if(coder && mControlThread &&
(name = mControlThread->GetCoderName(coder)))
index = mDecoderComboBox.FindStringExact(-1, name);
if(index == CB_ERR)
index = 0;
mDecoderComboBox.SetCurSel(index);
}
void
CPFWindow::SetEncoder(ulong coder)
{
StMutex mutex(*this);
short index = 0;
char *name;
if(mDead)
return;
if(coder && mControlThread &&
(name = mControlThread->GetCoderName(coder)))
index = mCoderComboBox.FindStringExact(-1, name);
if(index == CB_ERR)
index = 0;
mCoderComboBox.SetCurSel(index);
}
void
CPFWindow::SetEncryption(ulong firstCryptor, ulong secondCryptor)
{
StMutex mutex(*this);
char str[64], *p = str;
if(mDead)
return;
LONG_TO_BUFFER(firstCryptor, &mCryptor);
if(!memcmp(&mCryptor, sCryptorHash[_enc_none], 4))
p += sprintf(p, "None");
else if(!memcmp(&mCryptor, sCryptorHash[_enc_tripleDES], 4))
p += sprintf(p, "TripleDES");
else if(!memcmp(&mCryptor, sCryptorHash[_enc_blowfish], 4))
p += sprintf(p, "Blowfish");
else if(!memcmp(&mCryptor, sCryptorHash[_enc_cast], 4))
p += sprintf(p, "CAST");
else
p += sprintf(p, "");
mCryptorStatic.SetWindowText(str);
}
void
CPFWindow::SetDecoderList(uchar *decoders, short numDecoders)
{
StMutex mutex(*this);
ulong coder;
char *name;
if(mDead)
return;
if(decoders && numDecoders && mControlThread)
{
while (mDecoderComboBox.DeleteString(0) != CB_ERR);
while (numDecoders--)
{
BUFFER_TO_LONG(decoders, coder);
if(name = mControlThread->GetCoderName(coder))
mDecoderComboBox.AddString(name);
decoders += 4;
}
}
mDecoderComboBox.SetCurSel(0);
}
void
CPFWindow::SetEncoderList(uchar *encoders, short numEncoders)
{
StMutex mutex(*this);
ulong coder;
char *name;
if(mDead)
return;
if(encoders && numEncoders && mControlThread)
{
while(mCoderComboBox.DeleteString(0) != CB_ERR);
while(numEncoders--)
{
BUFFER_TO_LONG(encoders, coder);
if(name = mControlThread->GetCoderName(coder))
mCoderComboBox.AddString(name);
encoders += 4;
}
}
}
void
CPFWindow::ClearDecoderList(void)
{
StMutex mutex(*this);
if(mDead)
return;
while(mDecoderComboBox.DeleteString(0) != CB_ERR);
mDecoderComboBox.Clear();
}
void
CPFWindow::ClearEncoderList(void)
{
StMutex mutex(*this);
if(mDead)
return;
while(mCoderComboBox.DeleteString(0) != CB_ERR);
mCoderComboBox.Clear();
}
void
CPFWindow::AllowXfers(Boolean allow)
{
}
void
CPFWindow::SetSoundInStatus(Boolean sending)
{
if(sending != mSending)
{
if(sending)
{
mSoundLight.Switch(TRUE);
mSending = TRUE;
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -