📄 main.cxx
字号:
dlg.ringSoundFile = ringSoundFile;
dlg.playSoundButton->Enable(!ringSoundFile);
dlg.userInputMode = endpoint.GetSendUserInputMode()+1;
dlg.autoAnswer = autoAnswer;
dlg.noFastStart = endpoint.IsFastStartDisabled();
dlg.noTunneling = endpoint.IsH245TunnelingDisabled();
dlg.noH245inSetup = endpoint.IsH245inSetupDisabled();
dlg.intrusionProtectionLevel = endpoint.GetCallIntrusionProtectionLevel()+1;
if (!dlg.RunModal())
return;
endpoint.SetLocalUserName(dlg.username);
config.SetString(UsernameConfigKey, dlg.username);
for (i = 0; i < dlg.aliasList->GetCount(); i++) {
PString alias = dlg.aliasList->GetString(i);
endpoint.AddAliasName(alias);
config.SetString(psprintf(AliasConfigKey, i), alias);
}
config.DeleteKey(psprintf(AliasConfigKey, i));
autoAnswer = dlg.autoAnswer;
config.SetBoolean(AutoAnswerConfigKey, autoAnswer);
endpoint.SetSendUserInputMode((H323Connection::SendUserInputModes)(dlg.userInputMode-1));
config.SetInteger(UserInputModeConfigKey, dlg.userInputMode-1);
endpoint.DisableFastStart(dlg.noFastStart);
config.SetBoolean(NoFastStartConfigKey, dlg.noFastStart);
endpoint.DisableH245Tunneling(dlg.noTunneling);
config.SetBoolean(NoTunnelingConfigKey, dlg.noTunneling);
endpoint.DisableH245inSetup(dlg.noH245inSetup);
config.SetBoolean(NoH245inSetupConfigKey, dlg.noH245inSetup);
maxRecentCalls = dlg.maxRecentCalls;
config.SetInteger(MaxRecentCallsConfigKey, maxRecentCalls);
ringSoundFile = dlg.ringSoundFile;
config.SetString(RingSoundFileConfigKey, ringSoundFile);
endpoint.SetCallIntrusionProtectionLevel(dlg.intrusionProtectionLevel-1);
config.SetInteger(CallIntrusionProtectionLevelKey, endpoint.GetCallIntrusionProtectionLevel());
}
void GeneralOptionsDlg::ChangedUsername(PEditBox & box, INT)
{
ok->Enable(box.GetLength() > 0);
}
void GeneralOptionsDlg::ChangedAlias(PEditBox & box, INT)
{
addAliasBtn->Enable(box.GetLength() > 0);
}
void GeneralOptionsDlg::AddAlias(PTextButton &, INT)
{
aliasList->AddString(alias);
alias = PString();
UpdateControls();
}
void GeneralOptionsDlg::DelAlias(PTextButton &, INT)
{
alias = aliasList->GetSelectedString();
aliasList->DeleteString(aliasList->GetSelection());
UpdateControls();
}
void GeneralOptionsDlg::SelectAlias(PStringListBox & box, INT)
{
delAliasBtn->Enable(box.GetSelection() != P_MAX_INDEX);
}
void GeneralOptionsDlg::ChangedSoundFile(PEditBox & box, INT)
{
playSoundButton->Enable(box.GetLength() > 0);
}
void GeneralOptionsDlg::BrowseSound(PTextButton &, INT)
{
POpenFileDialog dlg(this);
dlg.AddFileType(".wav");
if (dlg.RunModal()) {
ringSoundFile = dlg.GetFile();
UpdateControls();
}
}
void GeneralOptionsDlg::PlaySoundFile(PTextButton &, INT)
{
PSound::PlayFile(ringSoundFile, FALSE);
}
void MainWindow::NetworkingOptionsCmd()
{
PConfig config;
NetworkingOptionsDlg dlg(this);
dlg.bandwidthType = config.GetInteger(BandwidthTypeConfigKey, 5);
dlg.bandwidth = endpoint.GetInitialBandwidth()/20.0;
dlg.bandwidthBox->Enable(dlg.bandwidthType == 6);
dlg.tcpBase = endpoint.GetTCPPortBase();
dlg.tcpMax = endpoint.GetTCPPortMax();
dlg.udpBase = endpoint.GetUDPPortBase();
dlg.udpMax = endpoint.GetUDPPortMax();
dlg.rtpBase = endpoint.GetRtpIpPortBase();
dlg.rtpMax = endpoint.GetRtpIpPortMax();
dlg.ipTOS = endpoint.GetRtpIpTypeofService();
if (!dlg.RunModal())
return;
endpoint.SetInitialBandwidth((unsigned)(dlg.bandwidth*20));
config.SetReal(BandwidthConfigKey, dlg.bandwidth);
config.SetInteger(BandwidthTypeConfigKey, dlg.bandwidthType);
endpoint.SetTCPPorts(dlg.tcpBase, dlg.tcpMax);
endpoint.SetUDPPorts(dlg.udpBase, dlg.udpMax);
endpoint.SetRtpIpPorts(dlg.rtpBase, dlg.rtpMax);
config.SetInteger(TCPPortBaseConfigKey, dlg.tcpBase);
config.SetInteger(TCPPortMaxConfigKey, dlg.tcpMax);
config.SetInteger(UDPPortBaseConfigKey, dlg.udpBase);
config.SetInteger(UDPPortMaxConfigKey, dlg.udpMax);
config.SetInteger(RTPPortBaseConfigKey, dlg.rtpBase);
config.SetInteger(RTPPortMaxConfigKey, dlg.rtpMax);
endpoint.SetRtpIpTypeofService(dlg.ipTOS);
config.SetInteger(IpTosConfigKey, dlg.ipTOS);
}
void NetworkingOptionsDlg::BandwidthChange(PChoiceBox &, INT)
{
bandwidthBox->Enable(bandwidthType == 6);
if (bandwidthType < 6) {
static int const bandwidths[6] = {
14400, 28800, 64000, 128000, 1500000, 10000000
};
bandwidth = bandwidths[bandwidthType]/1000.0;
UpdateControls();
}
}
void MainWindow::ForwardingOptionsCmd()
{
PConfig config;
ForwardingOptionsDlg dlg(this);
dlg.alwaysForwardParty = endpoint.alwaysForwardParty;
dlg.busyForwardParty = endpoint.busyForwardParty;
dlg.noAnswerForwardParty = noAnswerForwardParty;
dlg.noAnswerTime = noAnswerTime.GetSeconds();
if (!dlg.RunModal())
return;
endpoint.alwaysForwardParty = dlg.alwaysForwardParty;
config.SetString(AlwaysForwardPartyConfigKey, endpoint.alwaysForwardParty);
endpoint.busyForwardParty = dlg.busyForwardParty;
config.SetString(BusyForwardPartyConfigKey, endpoint.busyForwardParty);
noAnswerForwardParty = dlg.noAnswerForwardParty;
config.SetString(NoAnswerForwardPartyConfigKey, noAnswerForwardParty);
noAnswerTime = PTimeInterval(0, dlg.noAnswerTime);
config.SetInteger(NoAnswerTimeConfigKey, dlg.noAnswerTime);
}
void MainWindow::GatekeeperOptionsCmd()
{
GatekeeperOptionsDlg dlg(this);
PConfig config;
dlg.useGatekeeper = config.GetBoolean(UseGatekeeperConfigKey, FALSE);
dlg.requireGatekeeper = config.GetBoolean(RequireGatekeeperConfigKey, FALSE);
dlg.gatekeeperHost = config.GetString(GatekeeperHostConfigKey);
dlg.gatekeeperId = config.GetString(GatekeeperIdConfigKey);
if (!dlg.gatekeeperId)
dlg.discover = 3;
else if (!dlg.gatekeeperHost)
dlg.discover = 2;
else
dlg.discover = 1;
dlg.password = config.GetString(GatekeeperPasswordConfigKey);
dlg.timeToLive = config.GetInteger(TimeToLiveConfigKey, 0);
dlg.accessTokenOID = config.GetString(AccessTokenOIDConfigKey);
dlg.EnableFields();
if (!dlg.RunModal())
return;
config.SetBoolean(UseGatekeeperConfigKey, dlg.useGatekeeper);
switch (dlg.discover) {
case 1 :
config.SetString(GatekeeperHostConfigKey, "");
config.SetString(GatekeeperIdConfigKey, "");
break;
case 2 :
config.SetString(GatekeeperHostConfigKey, dlg.gatekeeperHost);
config.SetString(GatekeeperIdConfigKey, "");
break;
case 3 :
config.SetString(GatekeeperHostConfigKey, "");
config.SetString(GatekeeperIdConfigKey, dlg.gatekeeperId);
break;
}
config.SetBoolean(RequireGatekeeperConfigKey, dlg.requireGatekeeper);
config.SetString(GatekeeperPasswordConfigKey, dlg.password);
config.SetInteger(TimeToLiveConfigKey, dlg.timeToLive);
config.SetString(AccessTokenOIDConfigKey, dlg.accessTokenOID);
if (endpoint.FindGatekeeper(config))
SetCallMode(IdleCallMode);
else
SetCallMode(NoGatekeeperMode);
}
BOOL MainWindow::CanSetGatekeeper()
{
return currentCallMode == IdleCallMode ||
currentCallMode == NoGatekeeperMode;
}
void GatekeeperOptionsDlg::UsingGatekeeper(PCheckBox &, INT)
{
EnableFields();
}
void GatekeeperOptionsDlg::CheckDiscover(PRadioButton &, INT)
{
EnableFields();
}
void GatekeeperOptionsDlg::EnableFields()
{
discoverButton->Enable(useGatekeeper);
staticGkButton->Enable(useGatekeeper);
idButton->Enable(useGatekeeper);
gatekeeperHostBox->Enable(useGatekeeper && discover == 2);
gatekeeperIdBox->Enable(useGatekeeper && discover == 3);
requireBox->Enable(useGatekeeper);
}
void MainWindow::AudioDeviceOptionsCmd()
{
PConfig config;
AudioDeviceOptionsDlg dlg(this);
dlg.cardSelection = config.GetInteger(DeviceTypeConfigKey, SoundDeviceTypeCode);
PINDEX i;
PStringArray playDevices = PSoundChannel::GetDeviceNames(PSoundChannel::Player);
for (i = 0; i < playDevices.GetSize(); i++)
dlg.playDeviceBox->AddString(playDevices[i]);
dlg.playSoundDevice = dlg.playDeviceBox->FindString(endpoint.GetSoundChannelPlayDevice());
PStringArray recordDevices = PSoundChannel::GetDeviceNames(PSoundChannel::Recorder);
for (i = 0; i < recordDevices.GetSize(); i++)
dlg.recordDeviceBox->AddString(recordDevices[i]);
dlg.recordSoundDevice = dlg.recordDeviceBox->FindString(endpoint.GetSoundChannelRecordDevice());
dlg.soundBuffers = endpoint.GetSoundChannelBufferDepth();
PStringArray devices = OpalIxJDevice::GetDeviceNames();
dlg.quicknetButton->Enable(!devices.IsEmpty());
for (i = 0; i < devices.GetSize(); i++)
dlg.xJackDeviceBox->AddString(devices[i]);
PINDEX previousDevice = 0;
if (devices.GetSize() > 0) {
previousDevice = dlg.xJackDeviceBox->FindString(config.GetString(DeviceNameConfigKey, devices[0]));
if (previousDevice == P_MAX_INDEX)
previousDevice = 0;
}
dlg.xJackDevice = previousDevice;
dlg.aecLevel = config.GetInteger(AECConfigKey, 2);
dlg.country = config.GetString(CountryConfigKey);
devices = OpalVoipBlasterDevice::GetDeviceNames();
dlg.blasterButton->Enable(!devices.IsEmpty());
for (i = 0; i < devices.GetSize(); i++)
dlg.blasterDeviceBox->AddString(devices[i]);
previousDevice = 0;
if (devices.GetSize() > 0) {
previousDevice = dlg.blasterDeviceBox->FindString(config.GetString(DeviceNameConfigKey, devices[0]));
if (previousDevice == P_MAX_INDEX)
previousDevice = 0;
}
dlg.blasterDevice = previousDevice;
dlg.SelectCard(*(PRadioButton *)NULL, 0);
if (!dlg.RunModal())
return;
config.SetInteger(DeviceTypeConfigKey, dlg.cardSelection);
if (dlg.cardSelection == SoundDeviceTypeCode && endpoint.lid->IsOpen())
endpoint.CloseLID();
PString str = dlg.playDeviceBox->GetString(dlg.playSoundDevice);
config.SetString(SoundPlayConfigKey, str);
endpoint.SetSoundChannelPlayDevice(str);
str = dlg.recordDeviceBox->GetString(dlg.recordSoundDevice);
config.SetString(SoundRecordConfigKey, str);
endpoint.SetSoundChannelRecordDevice(str);
config.SetInteger(SoundBuffersConfigKey, dlg.soundBuffers);
endpoint.SetSoundChannelBufferDepth(dlg.soundBuffers);
config.SetInteger(SoundBuffersConfigKey, dlg.soundBuffers);
config.SetInteger(AECConfigKey, dlg.aecLevel);
config.SetString(CountryConfigKey, dlg.country);
endpoint.lid->SetAEC(endpoint.potsLine, (OpalLineInterfaceDevice::AECLevels)dlg.aecLevel);
PINDEX newDevice = previousDevice;
switch (dlg.cardSelection) {
case QuicknetDeviceTypeCode :
newDevice = dlg.xJackDevice;
str = dlg.xJackDeviceBox->GetString(newDevice);
break;
case BlasterDeviceTypeCode :
newDevice = dlg.blasterDevice;
str = dlg.blasterDeviceBox->GetString(newDevice);
break;
}
if (newDevice != previousDevice)
config.SetString(DeviceNameConfigKey, str);
if (!endpoint.lid->IsOpen() || newDevice != previousDevice)
endpoint.OpenLID(config);
}
void AudioDeviceOptionsDlg::SelectCard(PRadioButton &, INT)
{
playDeviceTitle->Enable(cardSelection == 1);
playDeviceBox->Enable(cardSelection == 1);
recordDeviceTitle->Enable(cardSelection == 1);
recordDeviceBox->Enable(cardSelection == 1);
soundBuffersTitle->Enable(cardSelection == 1);
soundBuffersBox->Enable(cardSelection == 1);
xJackDeviceTitle->Enable(cardSelection == 2);
xJackDeviceBox->Enable(cardSelection == 2);
aecTitle->Enable(cardSelection == 2);
aecBox->Enable(cardSelection == 2);
countryTitle->Enable(cardSelection == 2);
countryBox->Enable(cardSelection == 2);
blasterDeviceBox->Enable(cardSelection == 3);
}
void MainWindow::AudioCodecOptionsCmd()
{
PConfig config;
AudioCodecOptionsDlg dlg(this);
dlg.silenceDetect = endpoint.GetSilenceDetectionMode() != H323AudioCodec::NoSilenceDetection;
dlg.silenceDeadband = (PSCROLLBAR_VALUE)endpoint.silenceDeadband;
dlg.silenceDeadbandMS->SetName(psprintf("%ums", (endpoint.silenceDeadband+7)/8));
dlg.signalDeadband = (PSCROLLBAR_VALUE)endpoint.signalDeadband;
dlg.signalDeadbandMS->SetName(psprintf("%ums", (endpoint.signalDeadband+7)/8));
PINDEX i = 0;
for (;;) {
PString key = psprintf(CodecsConfigKey, ++i);
PString name = config.GetString(CodecsConfigSection, key, "");
if (name.IsEmpty())
break;
dlg.codecList->AddString(name);
}
dlg.SelectCodec(*dlg.codecList, 0);
dlg.enabledCodec->Disable();
dlg.packetSizeBox->Disable();
dlg.jitter = endpoint.GetMaxAudioDelayJitter();
if (!dlg.RunModal())
return;
endpoint.SetSilenceDetectionMode(dlg.silenceDetect ? H323AudioCodec::AdaptiveSilenceDetection
: H323AudioCodec::NoSilenceDetection);
config.SetBoolean(SilenceDetectConfigKey, dlg.silenceDetect);
endpoint.silenceDeadband = dlg.silenceDeadband;
config.SetInteger(SilenceDeadbandConfigKey, dlg.silenceDeadband);
endpoint.signalDeadband = dlg.signalDeadband;
config.SetInteger(SignalDeadbandConfigKey, dlg.signalDeadband);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -