⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cxx

📁 网络电话(VOIP)软件Pchone 1、按照OpenH323库中readme.txt说明编译OpenH323库 2、再用VC编译PCPhone代码
💻 CXX
📖 第 1 页 / 共 5 页
字号:
  if (type != Normalised)
    return;

  statusWindow->SetDimensions(newSize.Width(), statusWindow->GetDimensions(PixelCoords).Height(), PixelCoords);
  makeCallButton->SetDimensions(newSize.Width(), makeCallButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  answerButton->SetDimensions(newSize.Width()/2, answerButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  refuseButton->SetDimensions(newSize.Width()/2, refuseButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  refuseButton->SetPosition(newSize.Width()/2, refuseButton->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels); 
  hangUpButton->SetDimensions(newSize.Width()/2, hangUpButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  //speakerButton->SetDimensions(newSize.Width()/4, speakerButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  //speakerButton->SetPosition(newSize.Width()/4, speakerButton->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels);
  //transferButton->SetDimensions(newSize.Width()/4, speakerButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  //transferButton->SetPosition(newSize.Width()/2, speakerButton->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels);
  holdButton->SetDimensions(newSize.Width()/2, hangUpButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  holdButton->SetPosition(newSize.Width()/2, refuseButton->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels);
  //intrudeCallButton->SetDimensions(newSize.Width()/2, intrudeCallButton->GetDimensions(PixelCoords).Height(), PixelCoords);
  //intrudeCallButton->SetPosition(newSize.Width()/2, intrudeCallButton->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels); 
  PDIMENSION scrollBarWidth = newSize.Width()/2-speakerEnable->GetDimensions(PixelCoords).Width();
  speakerVolume->SetDimensions(scrollBarWidth, speakerVolume->GetDimensions(PixelCoords).Height(), PixelCoords);
  speakerEnable->SetPosition(scrollBarWidth, speakerEnable->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels);
  speakerVU->SetDimensions(newSize.Width()/2, speakerVU->GetDimensions(PixelCoords).Height(), PixelCoords);
  scrollBarWidth = newSize.Width()/2-microphoneEnable->GetDimensions(PixelCoords).Width();
  microphoneVolume->SetDimensions(scrollBarWidth, microphoneVolume->GetDimensions(PixelCoords).Height(), PixelCoords);
  microphoneVolume->SetPosition(newSize.Width()/2, microphoneVolume->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels);
  microphoneEnable->SetPosition(newSize.Width()/2+scrollBarWidth, microphoneEnable->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels);
  microphoneVU->SetPosition(newSize.Width()/2, microphoneVU->GetPosition(PixelCoords).Y(), TopLeftPixels, TopLeftPixels);
  microphoneVU->SetDimensions(newSize.Width()/2, speakerVU->GetDimensions(PixelCoords).Height(), PixelCoords);

  if (speedDialButtons.IsEmpty())
    return;

  PDim dim = speedDialButtons[0].GetDimensions(PixelCoords);
  PORDINATE top = speedDialButtons[0].GetPosition(PixelCoords).Y();
  PORDINATE x = 0;
  PORDINATE y = top;
  for (PINDEX i = 0; i < speedDialButtons.GetSize(); i++) {
    if ((PDIMENSION)y+dim.Height() > newSize.Height()) {
      y = top;
      x += dim.Width();
      if ((PDIMENSION)x+dim.Width()/2 > newSize.Width())
        break;
    }

    speedDialButtons[i].SetPosition(x, y, TopLeftPixels, TopLeftPixels);
    y += dim.Height();
  }
}


void MainWindow::SetCallMode(CallMode mode)
{
  PWaitAndSignal mutex(callModeMutex);

  if (currentCallMode == ApplicationShuttingDown)
    return;

  currentCallMode = mode;

  if (currentCallMode == ApplicationShuttingDown)
    return;

  makeCallButton->Show(mode == IdleCallMode ||
                       mode == HangingUpMode ||
                       mode == ActiveLineCallMode ||
                       mode == NoGatekeeperMode);
  makeCallButton->Enable(mode == IdleCallMode);

 // intrudeCallButton->Show(mode == IdleCallMode ||
 //                      mode == HangingUpMode ||
 //                      mode == ActiveLineCallMode ||
 //                      mode == NoGatekeeperMode);
 // intrudeCallButton->Enable(mode == IdleCallMode);

  for (PINDEX i = 0; i < speedDialButtons.GetSize(); i++)
    speedDialButtons[i].Show(mode == IdleCallMode);

  answerButton->Show(mode == IncomingCallWait);
  refuseButton->Show(mode == IncomingCallWait);

  BOOL inCall = mode == MakingCallMode ||
                mode == Active323CallMode ||
                mode == ActiveLineCallMode;
  hangUpButton->Show(inCall);
  //speakerButton->Show(inCall);
  //speakerButton->Enable(mode == Active323CallMode &&
  //                      endpoint.lid->IsLineOffHook(endpoint.potsLine));
  //transferButton->Show(inCall);
  //transferButton->Enable(mode == Active323CallMode);
  holdButton->Show(inCall);
  holdButton->Enable(mode == Active323CallMode);
  /*
 myMainMenu->ind1->Enable(inCall);
  myMainMenu->ind2->Enable(inCall);
  myMainMenu->ind3->Enable(inCall);
  myMainMenu->ind4->Enable(inCall);
  myMainMenu->ind5->Enable(inCall);
  myMainMenu->ind6->Enable(inCall);
  myMainMenu->ind7->Enable(inCall);
  myMainMenu->ind8->Enable(inCall);
  myMainMenu->ind9->Enable(inCall);
  myMainMenu->ind0->Enable(inCall);
  myMainMenu->inds->Enable(inCall);
  myMainMenu->indh->Enable(inCall);
*/
  if (!inCall)
    statisticsDialog->Hide();

  speakerEnable->Show(mode == Active323CallMode);
  speakerVolume->Show(mode == Active323CallMode);
  speakerVU->Show(mode == Active323CallMode);
  microphoneEnable->Show(mode == Active323CallMode);
  microphoneVolume->Show(mode == Active323CallMode);
  microphoneVU->Show(mode == Active323CallMode);
  speakerVolume->Enable(endpoint.lid->IsOpen());
  microphoneVolume->Enable(endpoint.lid->IsOpen());
}


void MainWindow::OnCallButton(PTextButton &, INT)
{
  CallCmd();
}


void MainWindow::CallCmd()
{
  if (!CanMakeCall())
    return;

  PConfig config(RecentCallsConfigSection);
  MakeCallDialog dlg(this); // ask the user what address to call

  dlg.recentCalls.SetSize(maxRecentCalls);

  PINDEX i;
  for (i = 0; i < maxRecentCalls; i++) {
    dlg.recentCalls[i] = -1;
    PString fullAddress = config.GetString(psprintf("%u", i+1));
    if (!fullAddress) {
      PINDEX at = fullAddress.Find('@');
      if (at == P_MAX_INDEX)
        dlg.addressBox->AddString(fullAddress);
      else {
        dlg.addressBox->AddString(fullAddress.Left(at));
        dlg.recentCalls[i] = dlg.gatewayBox->AddString(fullAddress.Mid(at+1));
      }
    }
  }

  if (endpoint.lid->IsLinePresent(endpoint.potsLine))
    dlg.gatewayBox->AddString(InternalGatewayName);

  dlg.AddressChanged(*dlg.addressBox, PComboBox::EditChange);

  if (!dlg.RunModal())
    return;

  for (i = 0; i < dlg.gatewayBox->GetCount(); i++) {
    if (dlg.address == dlg.gatewayBox->GetString(i))
      break;
  }

  if (i >= dlg.gatewayBox->GetCount()) {
    PINDEX count = dlg.addressBox->GetCount();
    if (count >= maxRecentCalls-1)
      count = maxRecentCalls-1;

    for (i = count; i > 0; i--)
      config.SetString(psprintf("%u", i+1), config.GetString(psprintf("%u", i)));

    if (dlg.gateway.IsEmpty())
      config.SetString("1", dlg.address);
    else
      config.SetString("1", dlg.address + '@' + dlg.gateway);
  }

  MakeCall(dlg.address, dlg.gateway);
}


BOOL MainWindow::CanMakeCall()
{
  return currentCallMode == IdleCallMode;
}


void MakeCallDialog::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::OnIntrudeButton(PTextButton &, INT)
{
  IntrudeCmd();
}


void MainWindow::IntrudeCmd()
{
  if (!CanIntrudeCall())
    return;
  
  PConfig config(RecentCallsConfigSection);
  IntrudeCallDialog dlg(this); // ask the user what address to call

  dlg.recentCalls.SetSize(maxRecentCalls);

  PINDEX i;
  for (i = 0; i < maxRecentCalls; i++) {
    dlg.recentCalls[i] = -1;
    PString fullAddress = config.GetString(psprintf("%u", i+1));
    if (!fullAddress) {
      PINDEX at = fullAddress.Find('@');
      if (at == P_MAX_INDEX)
        dlg.addressBox->AddString(fullAddress);
      else {
        dlg.addressBox->AddString(fullAddress.Left(at));
        dlg.recentCalls[i] = dlg.gatewayBox->AddString(fullAddress.Mid(at+1));
      }
    }
  }

  if (endpoint.lid->IsLinePresent(endpoint.potsLine))
    dlg.gatewayBox->AddString(InternalGatewayName);

  dlg.AddressChanged(*dlg.addressBox, PComboBox::EditChange);

  dlg.capabilityLevel = config.GetInteger(CallIntrusionCapabilityLevelKey, 1);
  dlg.intrusionType = config.GetInteger(CallIntrusionTypeKey, 1);

  if (!dlg.RunModal())
    return;
  for (i = 0; i < dlg.gatewayBox->GetCount(); i++) {
    if (dlg.address == dlg.gatewayBox->GetString(i))
      break;
  }

  if (i >= dlg.gatewayBox->GetCount()) {
    PINDEX count = dlg.addressBox->GetCount();
    if (count >= maxRecentCalls-1)
      count = maxRecentCalls-1;

    for (i = count; i > 0; i--)
      config.SetString(psprintf("%u", i+1), config.GetString(psprintf("%u", i)));

    if (dlg.gateway.IsEmpty())
      config.SetString("1", dlg.address);
    else
      config.SetString("1", dlg.address + '@' + dlg.gateway);
  }

  config.SetInteger(CallIntrusionCapabilityLevelKey, dlg.capabilityLevel);
  config.SetInteger(CallIntrusionTypeKey, dlg.intrusionType);

  IntrudeCall(dlg.address, dlg.gateway, dlg.capabilityLevel);
}


BOOL MainWindow::CanIntrudeCall()
{
  return currentCallMode == IdleCallMode;
}


void IntrudeCallDialog::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::OnTransferButton(PTextButton &, INT)
{
  TransferCmd();
}


BOOL MainWindow::CanTransferCall()
{
  return currentCallMode == Active323CallMode;
}


void MainWindow::TransferCmd()
{
  if (!CanTransferCall())
    return;

  PConfig config;
  TransferDialog dlg(this); // ask the user what address to transfer to

  dlg.useH450 = config.GetInteger(TransferProtocolConfigKey, 1);

  config.SetDefaultSection(RecentCallsConfigSection);
  dlg.recentCalls.SetSize(maxRecentCalls);

  PINDEX i;
  for (i = 0; i < maxRecentCalls; i++) {
    dlg.recentCalls[i] = -1;
    PString fullAddress = config.GetString(psprintf("%u", i+1));
    if (!fullAddress) {
      PINDEX at = fullAddress.Find('@');
      if (at == P_MAX_INDEX)
        dlg.addressBox->AddString(fullAddress);
      else {
        dlg.addressBox->AddString(fullAddress.Left(at));
        dlg.recentCalls[i] = dlg.gatewayBox->AddString(fullAddress.Mid(at+1));
      }
    }
  }

  if (endpoint.lid->IsLinePresent(endpoint.pstnLine))
    dlg.gatewayBox->AddString(InternalGatewayName);

  dlg.AddressChanged(*dlg.addressBox, PComboBox::EditChange);

  if (!dlg.RunModal())
    return;

  for (i = 0; i < dlg.gatewayBox->GetCount(); i++) {
    if (dlg.address == dlg.gatewayBox->GetString(i))
      break;
  }

  if (i >= dlg.gatewayBox->GetCount()) {
    PINDEX count = dlg.addressBox->GetCount();
    if (count >= maxRecentCalls-1)
      count = maxRecentCalls-1;

    for (i = count; i > 0; i--)
      config.SetString(psprintf("%u", i+1), config.GetString(psprintf("%u", i)));

    if (dlg.gateway.IsEmpty())
      config.SetString("1", dlg.address);
    else
      config.SetString("1", dlg.address + '@' + dlg.gateway);
  }

  PString fullAddress = dlg.address;
  if (!dlg.gateway)
    fullAddress += '@' + dlg.gateway;

  config.SetInteger("Options", TransferProtocolConfigKey, dlg.useH450);

  H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
  if (connection != NULL) {
  if (dlg.useH450 == 1) {
      OutputStatus(IDS_TRANSFERRING, (const char *)fullAddress);
      connection->TransferCall(fullAddress);
  }
  else {
      PTime now;
      PString nowStr = now.AsString("w h:m a");
      OutputStatus(IDS_FORWARDING, (const char *)fullAddress, (const char *)nowStr);
      connection->ForwardCall(fullAddress);
    }
      connection->Unlock();

    SetCallMode(MakingCallMode);
    endpoint.lid->PlayTone(endpoint.potsLine, OpalLineInterfaceDevice::RingTone);
  }
}


void MainWindow::OnHoldButton(PTextButton &, INT)
{
  HoldCmd();
}


BOOL MainWindow::CanHoldCall()
{
  return currentCallMode == Active323CallMode;
}


void MainWindow::HoldCmd()
{
  if (!CanHoldCall())
    return;

  H323Connection * connection = endpoint.FindConnectionWithLock(currentCallToken);
  if (connection != NULL) {
    if (connection->IsLocalHold()) {
      connection->RetrieveCall();
      holdButton->SetName(PResourceString(IDS_HOLD));
    }
    else {
      connection->HoldCall(TRUE);
      holdButton->SetName(PResourceString(IDS_RETRIEVE));
    }
    connection->Unlock();
  }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -