void CMobileOpalDlg::OnTimer(UINT_PTR nIDEvent) { if (nIDEvent == TimerID && m_opal != NULL) { OpalMessage * message = OpalGetMessage(m_opal, 0); if (message != NULL) { switch (message->m_type) { case OpalIndRegistration : if (message->m_param.m_registrationStatus.m_error == NULL || message->m_param.m_registrationStatus.m_error[0] == '\0') SetStatusText(IDS_REGISTERED); else { CString text(message->m_param.m_registrationStatus.m_error); m_ctrlStatus.SetWindowText(text); } break; case OpalIndIncomingCall : SetStatusText(IDS_INCOMING_CALL); SetCallButton(true, IDS_ANSWER); m_ctrlAddress.EnableWindow(false); ShowWindow(true); BringWindowToTop(); break; case OpalIndAlerting : SetStatusText(IDS_RINGING); break; case OpalIndEstablished : SetStatusText(IDS_ESTABLISHED); break; case OpalIndUserInput : if (message->m_param.m_userInput.m_userInput != NULL) { CString text(message->m_param.m_callCleared.m_reason); m_ctrlStatus.SetWindowText(text); } break; case OpalIndCallCleared : SetCallButton(true, IDS_CALL); m_ctrlAddress.EnableWindow(true); m_currentCallToken.Empty(); if (message->m_param.m_callCleared.m_reason == NULL) SetStatusText(IDS_READY); else { CString text(message->m_param.m_callCleared.m_reason); m_ctrlStatus.SetWindowText(text); } } OpalFreeMessage(message); } } CDialog::OnTimer(nIDEvent); }
void CMobileOpalDlg::OnCallAnswer() { UpdateData(); OpalMessage * response = NULL; OpalMessage command; memset(&command, 0, sizeof(command)); if (!m_incomingCallToken.IsEmpty()) { SetStatusText(IDS_ANSWERING); SetCallButton(true, IDS_HANGUP); command.m_type = OpalCmdAnswerCall; command.m_param.m_callToken = m_incomingCallToken; response = OpalSendMessage(m_opal, &command); } else if (!m_currentCallToken.IsEmpty()) { SetStatusText(IDS_HANGINGUP); SetCallButton(false, IDS_HANGUP); command.m_type = OpalCmdClearCall; command.m_param.m_callToken = m_currentCallToken; response = OpalSendMessage(m_opal, &command); } else if (!m_callAddress.IsEmpty()) { SetStatusText(IDS_CALLING); SetCallButton(true, IDS_HANGUP); CStringA utfAddress((const TCHAR *)m_callAddress); command.m_type = OpalCmdSetUpCall; command.m_param.m_callSetUp.m_partyB = utfAddress; response = OpalSendMessage(m_opal, &command); } if (response == NULL) ErrorBox(IDS_CALL_START_FAIL); else { if (response->m_type == OpalIndCommandError) { if (response->m_param.m_commandError == NULL || *response->m_param.m_commandError == '\0') ErrorBox(IDS_CALL_START_FAIL); else { CString text(response->m_param.m_commandError); MessageBox(text, NULL, MB_OK|MB_ICONEXCLAMATION); } SetCallButton(true, IDS_CALL); } else if (command.m_type == OpalCmdSetUpCall) m_currentCallToken = response->m_param.m_callSetUp.m_callToken; else if (command.m_type == OpalCmdAnswerCall) { m_currentCallToken = m_incomingCallToken; m_incomingCallToken.Empty(); } OpalFreeMessage(response); } }
void CMobileOpalDlg::OnCallAnswer() { if (!UpdateData()) return; if (m_callAddress.IsEmpty()) return; CStringA utfAddress((const TCHAR *)m_callAddress); OpalMessage command; memset(&command, 0, sizeof(command)); command.m_type = OpalCmdSetUpCall; command.m_param.m_callSetUp.m_partyB = utfAddress; OpalMessage * response = OpalSendMessage(m_opal, &command); if (response != NULL) { if (response->m_type == OpalIndCommandError) ErrorBox(IDS_CALL_START_FAIL); else { m_currentCallToken = response->m_param.m_callSetUp.m_callToken; SetStatusText(IDS_CALLING); SetCallButton(true, IDS_HANGUP); } OpalFreeMessage(response); } }
BOOL CMobileOpalDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon if (!m_dlgCommandBar.Create(this) || !m_dlgCommandBar.InsertMenuBar(IDR_MAINFRAME)) { TRACE0("Failed to create CommandBar\n"); EndDialog(IDCANCEL); return FALSE; // fail to create } SetCallButton(false); InitialiseOPAL(); SetTimer(TimerID, 100, NULL); SetStatusText(IDS_READY); return TRUE; // return TRUE unless you set the focus to a control }
BOOL CMobileOpalDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon if (!m_dlgCommandBar.Create(this) || !m_dlgCommandBar.InsertMenuBar(IDR_MAINFRAME)) { TRACE0("Failed to create CommandBar\n"); EndDialog(IDCANCEL); return FALSE; // fail to create } // Resize to screen width ShowWindow(SW_SHOWMAXIMIZED); // Start background check for OPAL messages SetTimer(TimerID, 100, NULL); // Recent calls list unsigned index = 1; for (;;) { CString key; key.Format(L"%04u", index++); CString uri = AfxGetApp()->GetProfileString(RecentCallsSection, key); if (uri.IsEmpty()) break; m_ctrlCallAddress.AddString(uri); } // Speakerphone state m_speakerphone = false; SetSpeakerMode(m_speakerphone); // Get interfaces CStringArray interfaces; GetNetworkInterfaces(interfaces, false); for (int i = 0; i < interfaces.GetSize(); ++i) { if (!m_localAddress.IsEmpty()) m_localAddress += ", "; m_localAddress += interfaces[i]; } UpdateData(false); SetCallButton(false); return TRUE; // return TRUE unless you set the focus to a control }
void CMobileOpalDlg::OnSelectedAddress() { SetCallButton(true); }
void CMobileOpalDlg::OnChangedAddress() { SetCallButton(m_ctrlCallAddress.GetWindowTextLength() > 0); }
void CMobileOpalDlg::HandleMessage(OpalMessage & message) { switch (message.m_type) { case OpalIndRegistration : switch (message.m_param.m_registrationStatus.m_status) { case OpalRegisterSuccessful : case OpalRegisterRestored : SetStatusText(IDS_REGISTERED); break; case OpalRegisterRemoved : SetStatusText(IDS_UNREGISTERED, message.m_param.m_registrationStatus.m_error); break; case OpalRegisterRetrying : SetStatusText(IDS_REGISTERING); break; case OpalRegisterFailed : SetStatusText(0, message.m_param.m_registrationStatus.m_error); } break; case OpalIndMessageWaiting : if (message.m_param.m_messageWaiting.m_type != NULL && *message.m_param.m_messageWaiting.m_type != '\0') { CStringA msg; msg.Format(IDS_MESSAGE_WAITING, message.m_param.m_messageWaiting.m_type, message.m_param.m_messageWaiting.m_party); SetStatusText(0, msg); } break; case OpalIndIncomingCall : if (m_incomingCallToken.IsEmpty() && m_currentCallToken.IsEmpty()) { m_incomingCallToken = message.m_param.m_incomingCall.m_callToken; SetStatusText(IDS_INCOMING_CALL); SetCallButton(true, IDS_ANSWER); m_ctrlCallAddress.EnableWindow(false); ShowWindow(true); BringWindowToTop(); EnableFullPower(); } else { OpalMessage command; memset(&command, 0, sizeof(command)); command.m_type = OpalCmdClearCall; command.m_param.m_clearCall.m_callToken = message.m_param.m_incomingCall.m_callToken; command.m_param.m_clearCall.m_reason = OpalCallEndedByAnswerDenied; OpalMessage * response = OpalSendMessage(m_opal, &command); if (response != NULL) OpalFreeMessage(response); SetStatusText(IDS_BUSY); } break; case OpalIndAlerting : SetStatusText(IDS_RINGING); break; case OpalIndEstablished : SetSpeakerMode(m_speakerphone); SetStatusText(IDS_ESTABLISHED); break; case OpalIndUserInput : SetStatusText(0, message.m_param.m_userInput.m_userInput); break; case OpalIndCallCleared : if (m_currentCallToken == message.m_param.m_callCleared.m_callToken || m_incomingCallToken == message.m_param.m_callCleared.m_callToken) { m_incomingCallToken.Empty(); m_currentCallToken.Empty(); SetCallButton(true, IDS_CALL); m_ctrlCallAddress.EnableWindow(true); SetStatusText(IDS_READY, message.m_param.m_callCleared.m_reason); if (m_hPowerRequirement != NULL) { ReleasePowerRequirement(m_hPowerRequirement); m_hPowerRequirement = NULL; } PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE); } } }