You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
681 lines
22 KiB
681 lines
22 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: PhoneEditDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of PhoneEditDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
// PhoneEditDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "chicago.h"
|
|
#include "PhoneEditDlg.h"
|
|
#include "..\DLIB\SensorArray.h"
|
|
#include "..\..\lglib\Modem\LgModem.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
CPhoneEditDlg::CPhoneEditDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CPhoneEditDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CPhoneEditDlg)
|
|
//}}AFX_DATA_INIT
|
|
|
|
m_pPhoneCommand = NULL;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::CPhoneEditDlg") );
|
|
}
|
|
|
|
CPhoneEditDlg::~CPhoneEditDlg()
|
|
{
|
|
m_WavePlayer.ResetWave();
|
|
m_WaveFile.Destroy();
|
|
m_SpeechPlayer.ResetSpeech();
|
|
::PlaySound( NULL, NULL, SND_PURGE );
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::~CPhoneEditDlg") );
|
|
}
|
|
|
|
void CPhoneEditDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CPhoneEditDlg)
|
|
DDX_Control(pDX, IDC_EDIT_REPEAT, m_EditMessageRepeat);
|
|
DDX_Control(pDX, IDC_SLIDER_WELCOME_VOLUME, m_SliderWelcomeVolume);
|
|
DDX_Control(pDX, IDC_SLIDER_WELCOME_RATE, m_SliderWelcomeRate);
|
|
DDX_Control(pDX, IDC_SLIDER_MESSAGE_VOLUME, m_SliderMessageVolume);
|
|
DDX_Control(pDX, IDC_SLIDER_MESSAGE_RATE, m_SliderMessageRate);
|
|
DDX_Control(pDX, IDC_COMBO_WELCOME_VOICE, m_ComboWelcomeVoice);
|
|
DDX_Control(pDX, IDC_COMBO_MESSAGE_VOICE, m_ComboMessageVoice);
|
|
DDX_Control(pDX, IDC_EDIT_NUMBER, m_EditNumber);
|
|
DDX_Control(pDX, IDC_EDIT_MESSAGE_WAVE, m_EditMessageWave);
|
|
DDX_Control(pDX, IDC_EDIT_MESSAGE_TEXT2SPEECH, m_EditMessageText2Speech);
|
|
DDX_Control(pDX, IDC_EDIT_WELCOME_TEXT2SPEECH, m_EditWelcomeText2Speech);
|
|
DDX_Control(pDX, IDC_EDIT_WELCOME_WAVE, m_EditWelcomeWave);
|
|
DDX_Control(pDX, IDC_BUTTON_MESSAGE_TEST, m_ButtonMessageTest);
|
|
DDX_Control(pDX, IDC_BUTTON_MESSAGE_FILE, m_ButtonMessageFile);
|
|
DDX_Control(pDX, IDC_BUTTON_WELCOME_TEST, m_ButtonWelcomeTest);
|
|
DDX_Control(pDX, IDC_BUTTON_WELCOME_FILE, m_ButtonWelcomeFile);
|
|
DDX_Control(pDX, IDC_LIST_SRC, m_ListSrc);
|
|
DDX_Control(pDX, IDC_LIST_DST, m_ListDst);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CPhoneEditDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CPhoneEditDlg)
|
|
ON_BN_CLICKED(IDC_RADIO_MESSAGE_NONE, OnRadioMessage)
|
|
ON_BN_CLICKED(IDC_RADIO_WELCOME_NONE, OnRadioWelcome)
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD_ALL, OnButtonAddAll)
|
|
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
|
|
ON_BN_CLICKED(IDC_BUTTON_DELETE_ALL, OnButtonDeleteAll)
|
|
ON_BN_CLICKED(IDC_BUTTON_MESSAGE_FILE, OnButtonMessageFile)
|
|
ON_BN_CLICKED(IDC_BUTTON_WELCOME_FILE, OnButtonWelcomeFile)
|
|
ON_BN_CLICKED(IDC_BUTTON_MESSAGE_TEST, OnButtonMessageTest)
|
|
ON_BN_CLICKED(IDC_BUTTON_WELCOME_TEST, OnButtonWelcomeTest)
|
|
ON_BN_CLICKED(IDC_RADIO_MESSAGE_TEXT2SPEECH, OnRadioMessage)
|
|
ON_BN_CLICKED(IDC_RADIO_MESSAGE_WAVE, OnRadioMessage)
|
|
ON_BN_CLICKED(IDC_RADIO_WELCOME_TEXT2SPEECH, OnRadioWelcome)
|
|
ON_BN_CLICKED(IDC_RADIO_WELCOME_WAVE, OnRadioWelcome)
|
|
ON_WM_DESTROY()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CPhoneEditDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// initialize combo box with availible modem names
|
|
CLgModem modem;
|
|
if( modem.Create() )
|
|
{
|
|
for( DWORD i = 0; i < modem.GetDeviceCount(); i++ )
|
|
{
|
|
TCHAR pModemName[MAX_PATH];
|
|
modem.GetDeviceName( i, pModemName, MAX_PATH );
|
|
SendDlgItemMessage( IDC_COMBO_MODEM, CB_ADDSTRING, 0, (LPARAM)pModemName );
|
|
}
|
|
modem.Destroy();
|
|
}
|
|
SendDlgItemMessage( IDC_COMBO_MODEM, CB_SETCURSEL, m_pPhoneCommand->nModem, 0 );
|
|
|
|
// set phone number
|
|
m_EditNumber.SetWindowText( m_pPhoneCommand->command.pPhoneNumber );
|
|
|
|
// set redial
|
|
SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
|
|
SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneRedialCount, 0 ) );
|
|
|
|
// set dial time
|
|
SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
|
|
SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDialTime / 1000UL, 0 ) );
|
|
|
|
// set drop time
|
|
SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
|
|
SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDropTime / 1000UL, 0 ) );
|
|
|
|
// initialize voices
|
|
CLgSpeechPlayer::EnumVoice( EnumVoiceProc, this );
|
|
|
|
// set welcome data
|
|
m_SliderWelcomeVolume.SetRange( 0, 100, TRUE );
|
|
m_SliderWelcomeRate.SetRange( -10, 10, TRUE );
|
|
switch( m_pPhoneCommand->command.ePhoneWelcomeType )
|
|
{
|
|
case CLgVoiceModemCallCenter::VOICE_TYPE_NONE:
|
|
CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_NONE );
|
|
break;
|
|
case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE:
|
|
CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_WAVE );
|
|
m_EditWelcomeWave.SetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData );
|
|
break;
|
|
case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH:
|
|
CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_TEXT2SPEECH );
|
|
m_EditWelcomeText2Speech.SetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData );
|
|
m_SliderWelcomeVolume.SetPos( m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume );
|
|
m_SliderWelcomeRate.SetPos( m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate );
|
|
break;
|
|
}
|
|
|
|
// set message data
|
|
m_SliderMessageVolume.SetRange( 0, 100, TRUE );
|
|
m_SliderMessageRate.SetRange( -10, 10, TRUE );
|
|
switch( m_pPhoneCommand->command.ePhoneMessageType )
|
|
{
|
|
case CLgVoiceModemCallCenter::VOICE_TYPE_NONE:
|
|
CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_NONE );
|
|
break;
|
|
case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE:
|
|
CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_WAVE );
|
|
m_EditMessageWave.SetWindowText( m_pPhoneCommand->command.pPhoneMessageData );
|
|
break;
|
|
case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH:
|
|
CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_TEXT2SPEECH );
|
|
m_EditMessageText2Speech.SetWindowText( m_pPhoneCommand->command.pPhoneMessageData );
|
|
m_SliderMessageVolume.SetPos( m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume );
|
|
m_SliderMessageRate.SetPos( m_pPhoneCommand->command.nPhoneMessageText2SpeechRate );
|
|
break;
|
|
}
|
|
SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETRANGE, 0, MAKELONG( 10, 0 ) );
|
|
SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneMessageRepeatCount, 0 ) );
|
|
|
|
// initialize lists
|
|
for( INT i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
|
|
{
|
|
CSensor *pSensor = m_pSensorArray->GetSensor(i);
|
|
INT nIndex = m_ListSrc.AddString( pSensor->GetName() );
|
|
m_ListSrc.SetItemData( nIndex, (LPARAM)pSensor );
|
|
}
|
|
for( i = 0; i < m_pPhoneCommand->nSensorCount; i++ )
|
|
{
|
|
CSensor *pSensor = m_pSensorArray->GetSensor( m_pPhoneCommand->pSensor[i] );
|
|
if( pSensor )
|
|
{
|
|
for( INT j = 0; j < m_ListSrc.GetCount(); j++ )
|
|
{
|
|
if( m_ListSrc.GetItemData( j ) == (LPARAM)pSensor )
|
|
{
|
|
m_ListSrc.SetSel( j, TRUE );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
OnButtonAdd();
|
|
|
|
// update dynamic
|
|
OnRadioWelcome();
|
|
OnRadioMessage();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CPhoneEditDlg::OnRadioWelcome()
|
|
{
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
|
|
{
|
|
m_EditWelcomeWave.EnableWindow( FALSE );
|
|
m_ButtonWelcomeFile.EnableWindow( FALSE );
|
|
|
|
m_ButtonWelcomeTest.EnableWindow( FALSE );
|
|
|
|
m_EditWelcomeText2Speech.EnableWindow( FALSE );
|
|
m_SliderWelcomeVolume.EnableWindow( FALSE );
|
|
m_SliderWelcomeRate.EnableWindow( FALSE );
|
|
m_ComboWelcomeVoice.EnableWindow( FALSE );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
|
|
{
|
|
m_EditWelcomeWave.EnableWindow( TRUE );
|
|
m_ButtonWelcomeFile.EnableWindow( TRUE );
|
|
|
|
m_ButtonWelcomeTest.EnableWindow( TRUE );
|
|
|
|
m_EditWelcomeText2Speech.EnableWindow( FALSE );
|
|
m_SliderWelcomeVolume.EnableWindow( FALSE );
|
|
m_SliderWelcomeRate.EnableWindow( FALSE );
|
|
m_ComboWelcomeVoice.EnableWindow( FALSE );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
|
|
{
|
|
m_EditWelcomeWave.EnableWindow( FALSE );
|
|
m_ButtonWelcomeFile.EnableWindow( FALSE );
|
|
|
|
m_ButtonWelcomeTest.EnableWindow( TRUE );
|
|
|
|
m_EditWelcomeText2Speech.EnableWindow( TRUE );
|
|
m_SliderWelcomeVolume.EnableWindow( TRUE );
|
|
m_SliderWelcomeRate.EnableWindow( TRUE );
|
|
m_ComboWelcomeVoice.EnableWindow( TRUE );
|
|
}
|
|
}
|
|
|
|
void CPhoneEditDlg::OnRadioMessage()
|
|
{
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
|
|
{
|
|
m_EditMessageWave.EnableWindow( FALSE );
|
|
m_ButtonMessageFile.EnableWindow( FALSE );
|
|
|
|
m_ButtonMessageTest.EnableWindow( FALSE );
|
|
|
|
m_EditMessageText2Speech.EnableWindow( FALSE );
|
|
m_SliderMessageVolume.EnableWindow( FALSE );
|
|
m_SliderMessageRate.EnableWindow( FALSE );
|
|
m_ComboMessageVoice.EnableWindow( FALSE );
|
|
m_EditMessageRepeat.EnableWindow( FALSE );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
|
|
{
|
|
m_EditMessageWave.EnableWindow( TRUE );
|
|
m_ButtonMessageFile.EnableWindow( TRUE );
|
|
|
|
m_ButtonMessageTest.EnableWindow( TRUE );
|
|
|
|
m_EditMessageText2Speech.EnableWindow( FALSE );
|
|
m_SliderMessageVolume.EnableWindow( FALSE );
|
|
m_SliderMessageRate.EnableWindow( FALSE );
|
|
m_ComboMessageVoice.EnableWindow( FALSE );
|
|
m_EditMessageRepeat.EnableWindow( TRUE );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
|
|
{
|
|
m_EditMessageWave.EnableWindow( FALSE );
|
|
m_ButtonMessageFile.EnableWindow( FALSE );
|
|
|
|
m_ButtonMessageTest.EnableWindow( TRUE );
|
|
|
|
m_EditMessageText2Speech.EnableWindow( TRUE );
|
|
m_SliderMessageVolume.EnableWindow( TRUE );
|
|
m_SliderMessageRate.EnableWindow( TRUE );
|
|
m_ComboMessageVoice.EnableWindow( TRUE );
|
|
m_EditMessageRepeat.EnableWindow( TRUE );
|
|
}
|
|
}
|
|
|
|
void CPhoneEditDlg::OnOK()
|
|
{
|
|
// initialize combo box with availible modem names
|
|
m_pPhoneCommand->nModem = SendDlgItemMessage( IDC_COMBO_MODEM, CB_GETCURSEL, 0, 0 );
|
|
|
|
// get phone number
|
|
m_EditNumber.GetWindowText( m_pPhoneCommand->command.pPhoneNumber, sizeof(m_pPhoneCommand->command.pPhoneNumber) );
|
|
|
|
// get redial
|
|
m_pPhoneCommand->command.nPhoneRedialCount = SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_GETPOS, 0, 0 );
|
|
|
|
// get dial time
|
|
m_pPhoneCommand->command.dwPhoneDialTime = SendDlgItemMessage( IDC_SPIN_TIME, UDM_GETPOS, 0, 0 ) * 1000UL;
|
|
|
|
// get drop time
|
|
m_pPhoneCommand->command.dwPhoneDropTime = SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_GETPOS, 0, 0 ) * 1000UL;
|
|
|
|
// get welcome data
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
|
|
m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE;
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
|
|
{
|
|
m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE;
|
|
m_EditWelcomeWave.GetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
|
|
{
|
|
m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH;
|
|
m_EditWelcomeText2Speech.GetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) );
|
|
INT nIndex = m_ComboWelcomeVoice.GetCurSel();
|
|
LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboWelcomeVoice.GetItemData( nIndex );
|
|
wcscpy( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pVoice );
|
|
m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume = m_SliderWelcomeVolume.GetPos();
|
|
m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate = m_SliderWelcomeRate.GetPos();
|
|
}
|
|
|
|
// set message data
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
|
|
m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE;
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
|
|
{
|
|
m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE;
|
|
m_EditMessageWave.GetWindowText( m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
|
|
{
|
|
m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH;
|
|
m_EditMessageText2Speech.GetWindowText( m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) );
|
|
INT nIndex = m_ComboMessageVoice.GetCurSel();
|
|
LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboMessageVoice.GetItemData( nIndex );
|
|
if( pVoice )wcscpy( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pVoice );
|
|
else wcscpy( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, L"" );
|
|
m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume = m_SliderMessageVolume.GetPos();
|
|
m_pPhoneCommand->command.nPhoneMessageText2SpeechRate = m_SliderMessageRate.GetPos();
|
|
}
|
|
m_pPhoneCommand->command.nPhoneMessageRepeatCount = SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_GETPOS, 0, 0 );
|
|
|
|
// set sensor list
|
|
m_pPhoneCommand = (CPhoneCallCenter::PPHONE_COMMAND_EX)realloc( m_pPhoneCommand, sizeof(CPhoneCallCenter::PHONE_COMMAND) + (sizeof(CPhoneCallCenter::PHONE_COMMAND_EX) - sizeof(CPhoneCallCenter::PHONE_COMMAND)) * m_ListDst.GetCount() );
|
|
if( m_pPhoneCommand )
|
|
{
|
|
m_pPhoneCommand->nSensorCount = m_ListDst.GetCount();
|
|
|
|
for( INT i = 0; i < m_pPhoneCommand->nSensorCount; i++ )
|
|
{
|
|
CSensor *pSensor = (CSensor*)m_ListDst.GetItemData( i );
|
|
|
|
m_pPhoneCommand->pSensor[i] = pSensor->GetArrayIndex();
|
|
}
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
INT CPhoneEditDlg::DoModal( CSensorArray *pSensorArray, CPhoneCallCenter::PPHONE_COMMAND_EX& pPhoneCommand )
|
|
{
|
|
m_pSensorArray = pSensorArray;
|
|
m_pPhoneCommand = pPhoneCommand;
|
|
|
|
INT nResult = CDialog::DoModal();
|
|
|
|
if( nResult == IDOK )
|
|
pPhoneCommand = m_pPhoneCommand;
|
|
|
|
return nResult;
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonAdd()
|
|
{
|
|
INT nCount = m_ListSrc.GetSelCount();
|
|
if( !nCount )
|
|
return;
|
|
|
|
LPINT pItem = (LPINT)malloc( sizeof(INT) * nCount );
|
|
if( !pItem )
|
|
return;
|
|
|
|
m_ListSrc.GetSelItems( nCount, pItem );
|
|
|
|
for( INT i = nCount - 1; i >= 0; i -- )
|
|
{
|
|
INT nIndex = pItem[i];
|
|
|
|
CSensor *pSensor = (CSensor*)m_ListSrc.GetItemData( nIndex );
|
|
|
|
m_ListSrc.DeleteString( nIndex );
|
|
|
|
nIndex = m_ListDst.AddString( pSensor->GetName() );
|
|
|
|
m_ListDst.SetItemData( nIndex, (LPARAM)pSensor );
|
|
}
|
|
|
|
free( pItem );
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonAddAll()
|
|
{
|
|
switch( m_ListSrc.GetCount() )
|
|
{
|
|
case 0:
|
|
break;
|
|
|
|
case 1:
|
|
m_ListSrc.SetSel( 0, TRUE );
|
|
OnButtonAdd();
|
|
break;
|
|
|
|
default:
|
|
m_ListSrc.SelItemRange( TRUE, 0, m_ListSrc.GetCount() - 1 );
|
|
OnButtonAdd();
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonDelete()
|
|
{
|
|
INT nCount = m_ListDst.GetSelCount();
|
|
if( !nCount )
|
|
return;
|
|
|
|
LPINT pItem = (LPINT)malloc( sizeof(INT) * nCount );
|
|
if( !pItem )
|
|
return;
|
|
|
|
m_ListDst.GetSelItems( nCount, pItem );
|
|
|
|
for( INT i = nCount - 1; i >= 0; i -- )
|
|
{
|
|
INT nIndex = pItem[i];
|
|
|
|
CSensor *pSensor = (CSensor*)m_ListDst.GetItemData( nIndex );
|
|
|
|
m_ListDst.DeleteString( nIndex );
|
|
|
|
nIndex = m_ListSrc.AddString( pSensor->GetName() );
|
|
|
|
m_ListSrc.SetItemData( nIndex, (LPARAM)pSensor );
|
|
}
|
|
|
|
free( pItem );
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonDeleteAll()
|
|
{
|
|
switch( m_ListDst.GetCount() )
|
|
{
|
|
case 0:
|
|
break;
|
|
|
|
case 1:
|
|
m_ListDst.SetSel( 0, TRUE );
|
|
OnButtonDelete();
|
|
break;
|
|
|
|
default:
|
|
m_ListDst.SelItemRange( TRUE, 0, m_ListDst.GetCount() - 1 );
|
|
OnButtonDelete();
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonWelcomeFile()
|
|
{
|
|
TCHAR pFileName[MAX_PATH] = {0};
|
|
|
|
TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0");
|
|
|
|
OPENFILENAME OpenFileName;
|
|
memset( &OpenFileName, 0, sizeof(OpenFileName) );
|
|
OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400;
|
|
OpenFileName.hwndOwner = GetSafeHwnd();
|
|
OpenFileName.hInstance = NULL;
|
|
OpenFileName.lpstrFilter = pFilter;
|
|
OpenFileName.lpstrCustomFilter = NULL;
|
|
OpenFileName.nMaxCustFilter = 0;
|
|
OpenFileName.nFilterIndex = 1;
|
|
OpenFileName.lpstrFile = pFileName;
|
|
OpenFileName.nMaxFile = MAX_PATH;
|
|
OpenFileName.lpstrFileTitle = NULL;
|
|
OpenFileName.nMaxFileTitle = 0;
|
|
OpenFileName.lpstrInitialDir = NULL;
|
|
OpenFileName.lpstrTitle = NULL;
|
|
OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
|
|
if( ::GetOpenFileName( &OpenFileName ) )
|
|
{
|
|
m_EditWelcomeWave.SetWindowText( OpenFileName.lpstrFile );
|
|
}
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonMessageFile()
|
|
{
|
|
TCHAR pFileName[MAX_PATH] = {0};
|
|
|
|
TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0");
|
|
|
|
OPENFILENAME OpenFileName;
|
|
memset( &OpenFileName, 0, sizeof(OpenFileName) );
|
|
OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400;
|
|
OpenFileName.hwndOwner = GetSafeHwnd();
|
|
OpenFileName.hInstance = NULL;
|
|
OpenFileName.lpstrFilter = pFilter;
|
|
OpenFileName.lpstrCustomFilter = NULL;
|
|
OpenFileName.nMaxCustFilter = 0;
|
|
OpenFileName.nFilterIndex = 1;
|
|
OpenFileName.lpstrFile = pFileName;
|
|
OpenFileName.nMaxFile = MAX_PATH;
|
|
OpenFileName.lpstrFileTitle = NULL;
|
|
OpenFileName.nMaxFileTitle = 0;
|
|
OpenFileName.lpstrInitialDir = NULL;
|
|
OpenFileName.lpstrTitle = NULL;
|
|
OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
|
|
if( ::GetOpenFileName( &OpenFileName ) )
|
|
{
|
|
m_EditMessageWave.SetWindowText( OpenFileName.lpstrFile );
|
|
}
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonWelcomeTest()
|
|
{
|
|
// get welcome data
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonWelcomeTest"), _T("Unexpected situation (state=NONE)") );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
|
|
{
|
|
// get file name
|
|
TCHAR pFileName[MAX_PATH] = {0};
|
|
m_EditWelcomeWave.GetWindowText( pFileName, MAX_PATH );
|
|
|
|
// stop previous wave
|
|
// m_WavePlayer.ResetWave();
|
|
::PlaySound( NULL, NULL, SND_PURGE );
|
|
|
|
// stop previous speech
|
|
m_SpeechPlayer.ResetSpeech();
|
|
|
|
// // load file
|
|
// if( m_WaveFile.Load( pFileName ) )
|
|
// {
|
|
// // play file
|
|
// m_WavePlayer.PlayWave( &m_WaveFile, WAVE_MAPPER );
|
|
// }
|
|
::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
|
|
{
|
|
// get file name
|
|
TCHAR pText[MAX_PATH] = {0};
|
|
m_EditWelcomeText2Speech.GetWindowText( pText, MAX_PATH );
|
|
|
|
// stop previous wave
|
|
// m_WavePlayer.ResetWave();
|
|
::PlaySound( NULL, NULL, SND_PURGE );
|
|
|
|
// stop previous speech
|
|
m_SpeechPlayer.ResetSpeech();
|
|
|
|
INT nIndex = m_ComboWelcomeVoice.GetCurSel();
|
|
LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboWelcomeVoice.GetItemData( nIndex );
|
|
|
|
// play text
|
|
m_SpeechPlayer.PlaySpeech( pText, WAVE_MAPPER, m_SliderWelcomeVolume.GetPos(), m_SliderWelcomeRate.GetPos(), pVoice );
|
|
}
|
|
}
|
|
|
|
void CPhoneEditDlg::OnButtonMessageTest()
|
|
{
|
|
// get welcome data
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
|
|
{
|
|
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonMessageTest"), _T("Unexpected situation (state=NONE)") );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
|
|
{
|
|
// get file name
|
|
TCHAR pFileName[MAX_PATH] = {0};
|
|
m_EditMessageWave.GetWindowText( pFileName, MAX_PATH );
|
|
|
|
// stop previous wave
|
|
// m_WavePlayer.ResetWave();
|
|
::PlaySound( NULL, NULL, SND_PURGE );
|
|
|
|
// stop previous speech
|
|
m_SpeechPlayer.ResetSpeech();
|
|
|
|
// // load file
|
|
// if( m_WaveFile.Load( pFileName ) )
|
|
// {
|
|
// // play file
|
|
// m_WavePlayer.PlayWave( &m_WaveFile, WAVE_MAPPER );
|
|
// }
|
|
::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC );
|
|
}
|
|
else
|
|
if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
|
|
{
|
|
// get file name
|
|
TCHAR pText[MAX_PATH] = {0};
|
|
m_EditMessageText2Speech.GetWindowText( pText, MAX_PATH );
|
|
|
|
// stop previous wave
|
|
// m_WavePlayer.ResetWave();
|
|
::PlaySound( NULL, NULL, SND_PURGE );
|
|
|
|
// stop previous speech
|
|
m_SpeechPlayer.ResetSpeech();
|
|
|
|
INT nIndex = m_ComboMessageVoice.GetCurSel();
|
|
LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboMessageVoice.GetItemData( nIndex );
|
|
|
|
// play text
|
|
m_SpeechPlayer.PlaySpeech( pText, WAVE_MAPPER, m_SliderMessageVolume.GetPos(), m_SliderMessageRate.GetPos(), pVoice );
|
|
}
|
|
}
|
|
|
|
BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId, void* pParam )
|
|
{
|
|
CPhoneEditDlg *pThis = (CPhoneEditDlg*) pParam;
|
|
return pThis->EnumVoiceProc( pDescription, pId );
|
|
}
|
|
|
|
BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId )
|
|
{
|
|
INT nIndex = m_ComboWelcomeVoice.AddString( pDescription );
|
|
LPWSTR pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) );
|
|
if( pCopyId ) wcscpy( pCopyId, pId );
|
|
m_ComboWelcomeVoice.SetItemData( nIndex, (DWORD)pCopyId );
|
|
if( !wcscmp( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pCopyId ) )
|
|
m_ComboWelcomeVoice.SetCurSel( nIndex );
|
|
|
|
nIndex = m_ComboMessageVoice.AddString( pDescription );
|
|
pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) );
|
|
if( pCopyId ) wcscpy( pCopyId, pId );
|
|
m_ComboMessageVoice.SetItemData( nIndex, (DWORD)pCopyId );
|
|
if( !wcscmp( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pCopyId ) )
|
|
m_ComboMessageVoice.SetCurSel( nIndex );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void CPhoneEditDlg::OnDestroy()
|
|
{
|
|
while( m_ComboWelcomeVoice.GetCount() )
|
|
{
|
|
LPWSTR pVoice = (LPWSTR)m_ComboWelcomeVoice.GetItemData(0);
|
|
if( pVoice )
|
|
::CoTaskMemFree( pVoice );
|
|
m_ComboWelcomeVoice.DeleteString(0);
|
|
}
|
|
while( m_ComboMessageVoice.GetCount() )
|
|
{
|
|
LPWSTR pVoice = (LPWSTR)m_ComboMessageVoice.GetItemData(0);
|
|
if( pVoice )
|
|
::CoTaskMemFree( pVoice );
|
|
m_ComboMessageVoice.DeleteString(0);
|
|
}
|
|
|
|
CDialog::OnDestroy();
|
|
}
|