📄 main.cxx
字号:
void TransferDialog::AddressChanged(PComboBox & box, INT status)
{
if (status != PComboBox::NewSelection)
ok->Enable(box.GetLength() > 0);
else {
PINDEX idx = box.GetCurrent();
if (idx >= recentCalls.GetSize() || recentCalls[idx] < 0)
gatewayBox->SetText("");
else {
gatewayBox->SetCurrent(recentCalls[idx]);
gateway = gatewayBox->GetString(recentCalls[idx]);
}
ok->Enable();
}
}
void MainWindow::HangupCmd()
{
if (!CanHangupCall())
return;
endpoint.lid->StopTone(endpoint.potsLine);
if (currentCallMode == ActiveLineCallMode) {
endpoint.lid->SetLineOnHook(endpoint.pstnLine);
SetCallMode(IdleCallMode);
}
else {
endpoint.ClearCall(currentCallToken);
SetCallMode(HangingUpMode);
}
OutputStatus(IDS_HANGINGUP);
}
BOOL MainWindow::CanHangupCall()
{
return currentCallMode == MakingCallMode ||
currentCallMode == Active323CallMode ||
currentCallMode == ActiveLineCallMode;
}
void MainWindow::OnHangUpButton(PTextButton &, INT)
{
HangupCmd();
}
void MainWindow::OnSpeakerButton(PTextButton &, INT)
{
speakerphoneSwitch = TRUE;
speakerButton->Disable();
OutputStatus(IDS_REPLACEHANDSET);
endpoint.lid->DisableAudio(endpoint.potsLine);
}
void MainWindow::AcceptCallCmd()
{
AnswerCall(TRUE);
}
BOOL MainWindow::CanAcceptCall()
{
return currentCallMode == IncomingCallWait;
}
void MainWindow::OnAnswerButton(PTextButton &, INT)
{
AcceptCallCmd();
}
void MainWindow::RefuseCallCmd()
{
AnswerCall(FALSE);
}
BOOL MainWindow::CanRefuseCall()
{
return currentCallMode == IncomingCallWait;
}
void MainWindow::OnRefuseButton(PTextButton &, INT)
{
RefuseCallCmd();
}
/*
void MainWindow::UserInputCmd(PMenuItem & item, INT)
{
SendUserInput(item.GetString()[0]);
}
*/
void MainWindow::SendUserInput(char tone)
{
H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
if (connection == NULL)
return;
connection->SendUserInput(tone);
connection->Unlock();
OutputStatus(IDS_SENDINGTONE, tone);
}
void MainWindow::ShowStatsCmd()
{
H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
if (connection == NULL)
return;
RTP_Session * session = connection->GetSession(RTP_Session::DefaultAudioSessionID);
if (session != NULL)
endpoint.OnRTPStatistics(*connection, *session);
connection->Unlock();
statisticsDialog->Show();
}
BOOL MainWindow::CanShowStats()
{
return currentCallMode == Active323CallMode;
}
void MainWindow::OnMicrophoneEnable(PCheckBox &, INT)
{
MuteMicrophoneCmd();
}
void MainWindow::MuteMicrophoneCmd()
{
H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
if (connection == NULL)
return;
H323Channel * channel = connection->FindChannel(RTP_Session::DefaultAudioSessionID, FALSE);
if (channel != NULL) {
BOOL newState = !channel->IsPaused();
channel->SetPause(newState);
microphoneEnable->SetValue(!newState);
}
connection->Unlock();
}
BOOL MainWindow::CanMuteMicrophone()
{
return currentCallMode == Active323CallMode;
}
void MainWindow::OnSpeakerEnable(PCheckBox &, INT)
{
MuteSpeakerCmd();
}
void MainWindow::MuteSpeakerCmd()
{
H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
if (connection == NULL)
return;
H323Channel * channel = connection->FindChannel(RTP_Session::DefaultAudioSessionID, TRUE);
if (channel != NULL) {
BOOL newState = !channel->IsPaused();
channel->SetPause(newState);
speakerEnable->SetValue(!newState);
}
connection->Unlock();
}
BOOL MainWindow::CanMuteSpeaker()
{
return currentCallMode == Active323CallMode;
}
void MainWindow::RecordMediaCmd()
{
if (recorder != NULL)
return;
PSaveFileDialog dlg(this);
dlg.SetDefaultFileType(".wav");
if (!dlg.RunModal())
return;
H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
if (connection == NULL)
return;
H323Channel * channel = connection->FindChannel(RTP_Session::DefaultAudioSessionID, TRUE);
if (channel != NULL) {
recorder = new OpalRtpToWavFile(dlg.GetFile());
((H323_RTPChannel *)channel)->AddFilter(recorder->GetReceiveHandler());
}
connection->Unlock();
}
BOOL MainWindow::CanRecordMedia()
{
return currentCallMode == Active323CallMode && recorder == NULL;
}
void MainWindow::StopRecordingCmd()
{
if (recorder == NULL)
return;
H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
if (connection != NULL) {
H323Channel * channel = connection->FindChannel(RTP_Session::DefaultAudioSessionID, TRUE);
if (channel != NULL)
((H323_RTPChannel *)channel)->RemoveFilter(recorder->GetReceiveHandler());
connection->Unlock();
}
delete recorder;
recorder = NULL;
}
BOOL MainWindow::CanStopRecording()
{
return currentCallMode == Active323CallMode && recorder != NULL;
}
void MainWindow::OnSpeakerVolume(PHorizontalScrollBar & bar, INT status)
{
endpoint.lid->SetPlayVolume(endpoint.potsLine, bar.GetValue());
if (status == PScrollBar::EndTrack) {
PConfig config;
config.SetInteger(SpeakerVolumeConfigKey, bar.GetValue());
}
}
void MainWindow::OnMicrophoneVolume(PHorizontalScrollBar & bar, INT status)
{
endpoint.lid->SetRecordVolume(endpoint.potsLine, bar.GetValue());
if (status == PScrollBar::EndTrack) {
PConfig config;
config.SetInteger(MicrophoneVolumeConfigKey, bar.GetValue());
}
}
void MainWindow::ExitCmd()
{
owner->Terminate();
}
void MainWindow::OnSpeedDialButton(PTextButton & button, INT)
{
SpeedDial(button.GetName());
}
void MainWindow::AddSpeedDialButtons()
{
PConfig config(SpeedDialConfigSection);
PINDEX i;
speedDialButtons.RemoveAll();
PStringList aliases = config.GetKeys();
for (i = 0; i < aliases.GetSize(); i++) {
PTextButton * button = new PTextButton(this, aliases[i]);
button->SetNotifier(PCREATE_NOTIFIER(OnSpeedDialButton));
speedDialButtons.Append(button);
}
PDIMENSION maxWidth = 0;
for (i = 0; i < speedDialButtons.GetSize(); i++) {
PDIMENSION width = speedDialButtons[i].GetDimensions(LocalCoords).Width();
if (maxWidth < width)
maxWidth = width;
}
for (i = 0; i < speedDialButtons.GetSize(); i++) {
speedDialButtons[i].SetDimensions(maxWidth, SpeedDialButtonHeight, LocalCoords);
speedDialButtons[i].SetPosition(0, StatusWindowHeight+CallButtonHeight);
speedDialButtons[i].Show();
}
OnResize(GetDimensions(PixelCoords), Normalised);
}
void MainWindow::SpeedDialOptionsCmd()
{
SpeedDialOptionDlg dlg(this);
PConfig config(SpeedDialConfigSection);
PINDEX i;
PStringList aliases = config.GetKeys();
for (i = 0; i < aliases.GetSize(); i++)
dlg.speedDialList->AddString(aliases[i]+'\t'+config.GetString(aliases[i]));
dlg.selectedSpeedDial = P_MAX_INDEX;
if (!dlg.RunModal())
return;
config.DeleteSection();
for (i = 0; i < dlg.speedDialList->GetCount(); i++) {
PString str = dlg.speedDialList->GetString(i);
PINDEX tab = str.Find('\t');
config.SetString(str.Left(tab), str.Mid(tab+1));
}
AddSpeedDialButtons();
}
void SpeedDialOptionDlg::AddButton(PTextButton &, INT)
{
speedDialList->AddString(alias+'\t'+address+'\t'+gateway);
alias = address = gateway;
UpdateControls();
EnableFields();
}
void SpeedDialOptionDlg::RemoveButton(PTextButton &, INT)
{
PString str = speedDialList->GetString(selectedSpeedDial);
PINDEX tab1 = str.Find('\t');
PINDEX tab2 = str.Find('\t', tab1+1);
alias = str.Left(tab1);
address = str(tab1+1, tab2-1);
gateway = str.Mid(tab2+1);
speedDialList->DeleteEntry(selectedSpeedDial);
selectedSpeedDial = P_MAX_INDEX;
UpdateControls();
EnableFields();
}
void SpeedDialOptionDlg::UpButton(PTextButton &, INT)
{
PINDEX selection = selectedSpeedDial;
speedDialList->InsertString(speedDialList->GetString(selection), selection-1, FALSE);
speedDialList->DeleteEntry(selection+1);
speedDialList->SetSelection(selection-1);
}
void SpeedDialOptionDlg::DownButton(PTextButton &, INT)
{
PINDEX selection = selectedSpeedDial;
speedDialList->InsertString(speedDialList->GetString(selection), selection+2, FALSE);
speedDialList->DeleteEntry(selection);
speedDialList->SetSelection(selection+1);
}
void SpeedDialOptionDlg::SpeedDialSelect(PStringListBox &, INT)
{
EnableFields();
}
void SpeedDialOptionDlg::AddressChanged(PEditBox &, INT)
{
EnableFields();
}
void SpeedDialOptionDlg::EnableFields()
{
addButton->Enable(!alias);
PINDEX count = speedDialList->GetCount();
removeButton->Enable(selectedSpeedDial < count);
upButton->Enable(selectedSpeedDial > 0 && selectedSpeedDial < count);
downButton->Enable(selectedSpeedDial < count-1);
}
void MainWindow::GeneralOptionsCmd()
{
PConfig config;
GeneralOptionsDlg dlg(this);
dlg.username = endpoint.GetLocalUserName();
const PStringList & aliases = endpoint.GetAliasNames();
PINDEX i;
for (i = 1; i < aliases.GetSize(); i++)
dlg.aliasList->AddString(aliases[i]);
dlg.addAliasBtn->Disable();
dlg.delAliasBtn->Disable();
dlg.maxRecentCalls = maxRecentCalls;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -