Old fashion design for PC-104
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

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: PhoneEditDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PhoneEditDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // PhoneEditDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "PhoneEditDlg.h"
  19. #include "..\DLIB\SensorArray.h"
  20. #include "..\..\lglib\Modem\LgModem.h"
  21. #include "..\..\LgLib\Version.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. CPhoneEditDlg::CPhoneEditDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CPhoneEditDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CPhoneEditDlg)
  31. //}}AFX_DATA_INIT
  32. m_pPhoneCommand = NULL;
  33. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::CPhoneEditDlg") );
  34. }
  35. CPhoneEditDlg::~CPhoneEditDlg()
  36. {
  37. m_WavePlayer.ResetWave();
  38. m_WaveFile.Destroy();
  39. m_SpeechPlayer.ResetSpeech();
  40. ::PlaySound( NULL, NULL, SND_PURGE );
  41. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::~CPhoneEditDlg") );
  42. }
  43. void CPhoneEditDlg::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. //{{AFX_DATA_MAP(CPhoneEditDlg)
  47. DDX_Control(pDX, IDC_EDIT_REPEAT, m_EditMessageRepeat);
  48. DDX_Control(pDX, IDC_SLIDER_WELCOME_VOLUME, m_SliderWelcomeVolume);
  49. DDX_Control(pDX, IDC_SLIDER_WELCOME_RATE, m_SliderWelcomeRate);
  50. DDX_Control(pDX, IDC_SLIDER_MESSAGE_VOLUME, m_SliderMessageVolume);
  51. DDX_Control(pDX, IDC_SLIDER_MESSAGE_RATE, m_SliderMessageRate);
  52. DDX_Control(pDX, IDC_COMBO_WELCOME_VOICE, m_ComboWelcomeVoice);
  53. DDX_Control(pDX, IDC_COMBO_MESSAGE_VOICE, m_ComboMessageVoice);
  54. DDX_Control(pDX, IDC_EDIT_NUMBER, m_EditNumber);
  55. DDX_Control(pDX, IDC_EDIT_MESSAGE_WAVE, m_EditMessageWave);
  56. DDX_Control(pDX, IDC_EDIT_MESSAGE_TEXT2SPEECH, m_EditMessageText2Speech);
  57. DDX_Control(pDX, IDC_EDIT_WELCOME_TEXT2SPEECH, m_EditWelcomeText2Speech);
  58. DDX_Control(pDX, IDC_EDIT_WELCOME_WAVE, m_EditWelcomeWave);
  59. DDX_Control(pDX, IDC_BUTTON_MESSAGE_TEST, m_ButtonMessageTest);
  60. DDX_Control(pDX, IDC_BUTTON_MESSAGE_FILE, m_ButtonMessageFile);
  61. DDX_Control(pDX, IDC_BUTTON_WELCOME_TEST, m_ButtonWelcomeTest);
  62. DDX_Control(pDX, IDC_BUTTON_WELCOME_FILE, m_ButtonWelcomeFile);
  63. DDX_Control(pDX, IDC_LIST_SRC, m_ListSrc);
  64. DDX_Control(pDX, IDC_LIST_DST, m_ListDst);
  65. //}}AFX_DATA_MAP
  66. }
  67. BEGIN_MESSAGE_MAP(CPhoneEditDlg, CDialog)
  68. //{{AFX_MSG_MAP(CPhoneEditDlg)
  69. ON_BN_CLICKED(IDC_RADIO_MESSAGE_NONE, OnRadioMessage)
  70. ON_BN_CLICKED(IDC_RADIO_WELCOME_NONE, OnRadioWelcome)
  71. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  72. ON_BN_CLICKED(IDC_BUTTON_ADD_ALL, OnButtonAddAll)
  73. ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
  74. ON_BN_CLICKED(IDC_BUTTON_DELETE_ALL, OnButtonDeleteAll)
  75. ON_BN_CLICKED(IDC_BUTTON_MESSAGE_FILE, OnButtonMessageFile)
  76. ON_BN_CLICKED(IDC_BUTTON_WELCOME_FILE, OnButtonWelcomeFile)
  77. ON_BN_CLICKED(IDC_BUTTON_MESSAGE_TEST, OnButtonMessageTest)
  78. ON_BN_CLICKED(IDC_BUTTON_WELCOME_TEST, OnButtonWelcomeTest)
  79. ON_BN_CLICKED(IDC_RADIO_MESSAGE_TEXT2SPEECH, OnRadioMessage)
  80. ON_BN_CLICKED(IDC_RADIO_MESSAGE_WAVE, OnRadioMessage)
  81. ON_BN_CLICKED(IDC_RADIO_WELCOME_TEXT2SPEECH, OnRadioWelcome)
  82. ON_BN_CLICKED(IDC_RADIO_WELCOME_WAVE, OnRadioWelcome)
  83. ON_WM_DESTROY()
  84. //}}AFX_MSG_MAP
  85. END_MESSAGE_MAP()
  86. BOOL CPhoneEditDlg::OnInitDialog()
  87. {
  88. CDialog::OnInitDialog();
  89. // initialize combo box with availible modem names
  90. CLgModem modem;
  91. if( modem.Create() )
  92. {
  93. for( DWORD i = 0; i < modem.GetDeviceCount(); i++ )
  94. {
  95. TCHAR pModemName[MAX_PATH];
  96. modem.GetDeviceName( i, pModemName, MAX_PATH );
  97. SendDlgItemMessage( IDC_COMBO_MODEM, CB_ADDSTRING, 0, (LPARAM)pModemName );
  98. }
  99. modem.Destroy();
  100. }
  101. SendDlgItemMessage( IDC_COMBO_MODEM, CB_SETCURSEL, m_pPhoneCommand->nModem, 0 );
  102. // set phone number
  103. m_EditNumber.SetWindowText( m_pPhoneCommand->command.pPhoneNumber );
  104. // set redial
  105. SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
  106. SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneRedialCount, 0 ) );
  107. // set dial time
  108. SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
  109. SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDialTime / 1000UL, 0 ) );
  110. // set drop time
  111. SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
  112. SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDropTime / 1000UL, 0 ) );
  113. // initialize voices
  114. CLgSpeechPlayer::EnumVoice( EnumVoiceProc, this );
  115. // set welcome data
  116. m_SliderWelcomeVolume.SetRange( 0, 100, TRUE );
  117. m_SliderWelcomeRate.SetRange( -10, 10, TRUE );
  118. switch( m_pPhoneCommand->command.ePhoneWelcomeType )
  119. {
  120. case CLgVoiceModemCallCenter::VOICE_TYPE_NONE:
  121. CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_NONE );
  122. break;
  123. case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE:
  124. CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_WAVE );
  125. m_EditWelcomeWave.SetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData );
  126. break;
  127. case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH:
  128. CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_TEXT2SPEECH );
  129. m_EditWelcomeText2Speech.SetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData );
  130. m_SliderWelcomeVolume.SetPos( m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume );
  131. m_SliderWelcomeRate.SetPos( m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate );
  132. break;
  133. }
  134. // set message data
  135. m_SliderMessageVolume.SetRange( 0, 100, TRUE );
  136. m_SliderMessageRate.SetRange( -10, 10, TRUE );
  137. switch( m_pPhoneCommand->command.ePhoneMessageType )
  138. {
  139. case CLgVoiceModemCallCenter::VOICE_TYPE_NONE:
  140. CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_NONE );
  141. break;
  142. case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE:
  143. CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_WAVE );
  144. m_EditMessageWave.SetWindowText( m_pPhoneCommand->command.pPhoneMessageData );
  145. break;
  146. case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH:
  147. CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_TEXT2SPEECH );
  148. m_EditMessageText2Speech.SetWindowText( m_pPhoneCommand->command.pPhoneMessageData );
  149. m_SliderMessageVolume.SetPos( m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume );
  150. m_SliderMessageRate.SetPos( m_pPhoneCommand->command.nPhoneMessageText2SpeechRate );
  151. break;
  152. }
  153. SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETRANGE, 0, MAKELONG( 10, 0 ) );
  154. SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneMessageRepeatCount, 0 ) );
  155. // initialize lists
  156. for( INT i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  157. {
  158. CSensor *pSensor = m_pSensorArray->GetSensor(i);
  159. INT nIndex = m_ListSrc.AddString( pSensor->GetName() );
  160. m_ListSrc.SetItemData( nIndex, (LPARAM)pSensor );
  161. }
  162. for( i = 0; i < m_pPhoneCommand->nSensorCount; i++ )
  163. {
  164. CSensor *pSensor = m_pSensorArray->GetSensor( m_pPhoneCommand->pSensor[i] );
  165. if( pSensor )
  166. {
  167. for( INT j = 0; j < m_ListSrc.GetCount(); j++ )
  168. {
  169. if( m_ListSrc.GetItemData( j ) == (LPARAM)pSensor )
  170. {
  171. m_ListSrc.SetSel( j, TRUE );
  172. break;
  173. }
  174. }
  175. }
  176. }
  177. OnButtonAdd();
  178. // update dynamic
  179. OnRadioWelcome();
  180. OnRadioMessage();
  181. return TRUE; // return TRUE unless you set the focus to a control
  182. // EXCEPTION: OCX Property Pages should return FALSE
  183. }
  184. void CPhoneEditDlg::OnRadioWelcome()
  185. {
  186. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
  187. {
  188. m_EditWelcomeWave.EnableWindow( FALSE );
  189. m_ButtonWelcomeFile.EnableWindow( FALSE );
  190. m_ButtonWelcomeTest.EnableWindow( FALSE );
  191. m_EditWelcomeText2Speech.EnableWindow( FALSE );
  192. m_SliderWelcomeVolume.EnableWindow( FALSE );
  193. m_SliderWelcomeRate.EnableWindow( FALSE );
  194. m_ComboWelcomeVoice.EnableWindow( FALSE );
  195. }
  196. else
  197. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
  198. {
  199. m_EditWelcomeWave.EnableWindow( TRUE );
  200. m_ButtonWelcomeFile.EnableWindow( TRUE );
  201. m_ButtonWelcomeTest.EnableWindow( TRUE );
  202. m_EditWelcomeText2Speech.EnableWindow( FALSE );
  203. m_SliderWelcomeVolume.EnableWindow( FALSE );
  204. m_SliderWelcomeRate.EnableWindow( FALSE );
  205. m_ComboWelcomeVoice.EnableWindow( FALSE );
  206. }
  207. else
  208. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
  209. {
  210. m_EditWelcomeWave.EnableWindow( FALSE );
  211. m_ButtonWelcomeFile.EnableWindow( FALSE );
  212. m_ButtonWelcomeTest.EnableWindow( TRUE );
  213. m_EditWelcomeText2Speech.EnableWindow( TRUE );
  214. m_SliderWelcomeVolume.EnableWindow( TRUE );
  215. m_SliderWelcomeRate.EnableWindow( TRUE );
  216. m_ComboWelcomeVoice.EnableWindow( TRUE );
  217. }
  218. }
  219. void CPhoneEditDlg::OnRadioMessage()
  220. {
  221. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
  222. {
  223. m_EditMessageWave.EnableWindow( FALSE );
  224. m_ButtonMessageFile.EnableWindow( FALSE );
  225. m_ButtonMessageTest.EnableWindow( FALSE );
  226. m_EditMessageText2Speech.EnableWindow( FALSE );
  227. m_SliderMessageVolume.EnableWindow( FALSE );
  228. m_SliderMessageRate.EnableWindow( FALSE );
  229. m_ComboMessageVoice.EnableWindow( FALSE );
  230. m_EditMessageRepeat.EnableWindow( FALSE );
  231. }
  232. else
  233. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
  234. {
  235. m_EditMessageWave.EnableWindow( TRUE );
  236. m_ButtonMessageFile.EnableWindow( TRUE );
  237. m_ButtonMessageTest.EnableWindow( TRUE );
  238. m_EditMessageText2Speech.EnableWindow( FALSE );
  239. m_SliderMessageVolume.EnableWindow( FALSE );
  240. m_SliderMessageRate.EnableWindow( FALSE );
  241. m_ComboMessageVoice.EnableWindow( FALSE );
  242. m_EditMessageRepeat.EnableWindow( TRUE );
  243. }
  244. else
  245. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
  246. {
  247. m_EditMessageWave.EnableWindow( FALSE );
  248. m_ButtonMessageFile.EnableWindow( FALSE );
  249. m_ButtonMessageTest.EnableWindow( TRUE );
  250. m_EditMessageText2Speech.EnableWindow( TRUE );
  251. m_SliderMessageVolume.EnableWindow( TRUE );
  252. m_SliderMessageRate.EnableWindow( TRUE );
  253. m_ComboMessageVoice.EnableWindow( TRUE );
  254. m_EditMessageRepeat.EnableWindow( TRUE );
  255. }
  256. }
  257. void CPhoneEditDlg::OnOK()
  258. {
  259. // initialize combo box with availible modem names
  260. m_pPhoneCommand->nModem = SendDlgItemMessage( IDC_COMBO_MODEM, CB_GETCURSEL, 0, 0 );
  261. // get phone number
  262. m_EditNumber.GetWindowText( m_pPhoneCommand->command.pPhoneNumber, sizeof(m_pPhoneCommand->command.pPhoneNumber) );
  263. // get redial
  264. m_pPhoneCommand->command.nPhoneRedialCount = SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_GETPOS, 0, 0 );
  265. // get dial time
  266. m_pPhoneCommand->command.dwPhoneDialTime = SendDlgItemMessage( IDC_SPIN_TIME, UDM_GETPOS, 0, 0 ) * 1000UL;
  267. // get drop time
  268. m_pPhoneCommand->command.dwPhoneDropTime = SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_GETPOS, 0, 0 ) * 1000UL;
  269. // get welcome data
  270. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
  271. m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE;
  272. else
  273. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
  274. {
  275. m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE;
  276. m_EditWelcomeWave.GetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) );
  277. }
  278. else
  279. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
  280. {
  281. m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH;
  282. m_EditWelcomeText2Speech.GetWindowText( m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) );
  283. INT nIndex = m_ComboWelcomeVoice.GetCurSel();
  284. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboWelcomeVoice.GetItemData( nIndex );
  285. wcscpy( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pVoice );
  286. m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume = m_SliderWelcomeVolume.GetPos();
  287. m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate = m_SliderWelcomeRate.GetPos();
  288. }
  289. // set message data
  290. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
  291. m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE;
  292. else
  293. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
  294. {
  295. m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE;
  296. m_EditMessageWave.GetWindowText( m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) );
  297. }
  298. else
  299. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
  300. {
  301. m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH;
  302. m_EditMessageText2Speech.GetWindowText( m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) );
  303. INT nIndex = m_ComboMessageVoice.GetCurSel();
  304. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboMessageVoice.GetItemData( nIndex );
  305. if( pVoice )wcscpy( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pVoice );
  306. else wcscpy( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, L"" );
  307. m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume = m_SliderMessageVolume.GetPos();
  308. m_pPhoneCommand->command.nPhoneMessageText2SpeechRate = m_SliderMessageRate.GetPos();
  309. }
  310. m_pPhoneCommand->command.nPhoneMessageRepeatCount = SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_GETPOS, 0, 0 );
  311. // set sensor list
  312. 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() );
  313. if( m_pPhoneCommand )
  314. {
  315. m_pPhoneCommand->nSensorCount = m_ListDst.GetCount();
  316. for( INT i = 0; i < m_pPhoneCommand->nSensorCount; i++ )
  317. {
  318. CSensor *pSensor = (CSensor*)m_ListDst.GetItemData( i );
  319. m_pPhoneCommand->pSensor[i] = pSensor->GetArrayIndex();
  320. }
  321. }
  322. CDialog::OnOK();
  323. }
  324. INT CPhoneEditDlg::DoModal( CSensorArray *pSensorArray, CPhoneCallCenter::PPHONE_COMMAND_EX& pPhoneCommand )
  325. {
  326. m_pSensorArray = pSensorArray;
  327. m_pPhoneCommand = pPhoneCommand;
  328. INT nResult = CDialog::DoModal();
  329. if( nResult == IDOK )
  330. pPhoneCommand = m_pPhoneCommand;
  331. return nResult;
  332. }
  333. void CPhoneEditDlg::OnButtonAdd()
  334. {
  335. INT nCount = m_ListSrc.GetSelCount();
  336. if( !nCount )
  337. return;
  338. LPINT pItem = (LPINT)malloc( sizeof(INT) * nCount );
  339. if( !pItem )
  340. return;
  341. m_ListSrc.GetSelItems( nCount, pItem );
  342. for( INT i = nCount - 1; i >= 0; i -- )
  343. {
  344. INT nIndex = pItem[i];
  345. CSensor *pSensor = (CSensor*)m_ListSrc.GetItemData( nIndex );
  346. m_ListSrc.DeleteString( nIndex );
  347. nIndex = m_ListDst.AddString( pSensor->GetName() );
  348. m_ListDst.SetItemData( nIndex, (LPARAM)pSensor );
  349. }
  350. free( pItem );
  351. }
  352. void CPhoneEditDlg::OnButtonAddAll()
  353. {
  354. switch( m_ListSrc.GetCount() )
  355. {
  356. case 0:
  357. break;
  358. case 1:
  359. m_ListSrc.SetSel( 0, TRUE );
  360. OnButtonAdd();
  361. break;
  362. default:
  363. m_ListSrc.SelItemRange( TRUE, 0, m_ListSrc.GetCount() - 1 );
  364. OnButtonAdd();
  365. break;
  366. }
  367. }
  368. void CPhoneEditDlg::OnButtonDelete()
  369. {
  370. INT nCount = m_ListDst.GetSelCount();
  371. if( !nCount )
  372. return;
  373. LPINT pItem = (LPINT)malloc( sizeof(INT) * nCount );
  374. if( !pItem )
  375. return;
  376. m_ListDst.GetSelItems( nCount, pItem );
  377. for( INT i = nCount - 1; i >= 0; i -- )
  378. {
  379. INT nIndex = pItem[i];
  380. CSensor *pSensor = (CSensor*)m_ListDst.GetItemData( nIndex );
  381. m_ListDst.DeleteString( nIndex );
  382. nIndex = m_ListSrc.AddString( pSensor->GetName() );
  383. m_ListSrc.SetItemData( nIndex, (LPARAM)pSensor );
  384. }
  385. free( pItem );
  386. }
  387. void CPhoneEditDlg::OnButtonDeleteAll()
  388. {
  389. switch( m_ListDst.GetCount() )
  390. {
  391. case 0:
  392. break;
  393. case 1:
  394. m_ListDst.SetSel( 0, TRUE );
  395. OnButtonDelete();
  396. break;
  397. default:
  398. m_ListDst.SelItemRange( TRUE, 0, m_ListDst.GetCount() - 1 );
  399. OnButtonDelete();
  400. break;
  401. }
  402. }
  403. void CPhoneEditDlg::OnButtonWelcomeFile()
  404. {
  405. TCHAR pFileName[MAX_PATH] = {0};
  406. TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0");
  407. OPENFILENAME OpenFileName;
  408. memset( &OpenFileName, 0, sizeof(OpenFileName) );
  409. OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400;
  410. OpenFileName.hwndOwner = GetSafeHwnd();
  411. OpenFileName.hInstance = NULL;
  412. OpenFileName.lpstrFilter = pFilter;
  413. OpenFileName.lpstrCustomFilter = NULL;
  414. OpenFileName.nMaxCustFilter = 0;
  415. OpenFileName.nFilterIndex = 1;
  416. OpenFileName.lpstrFile = pFileName;
  417. OpenFileName.nMaxFile = MAX_PATH;
  418. OpenFileName.lpstrFileTitle = NULL;
  419. OpenFileName.nMaxFileTitle = 0;
  420. OpenFileName.lpstrInitialDir = NULL;
  421. OpenFileName.lpstrTitle = NULL;
  422. OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
  423. if( ::GetOpenFileName( &OpenFileName ) )
  424. {
  425. m_EditWelcomeWave.SetWindowText( OpenFileName.lpstrFile );
  426. }
  427. }
  428. void CPhoneEditDlg::OnButtonMessageFile()
  429. {
  430. TCHAR pFileName[MAX_PATH] = {0};
  431. TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0");
  432. OPENFILENAME OpenFileName;
  433. memset( &OpenFileName, 0, sizeof(OpenFileName) );
  434. OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400;
  435. OpenFileName.hwndOwner = GetSafeHwnd();
  436. OpenFileName.hInstance = NULL;
  437. OpenFileName.lpstrFilter = pFilter;
  438. OpenFileName.lpstrCustomFilter = NULL;
  439. OpenFileName.nMaxCustFilter = 0;
  440. OpenFileName.nFilterIndex = 1;
  441. OpenFileName.lpstrFile = pFileName;
  442. OpenFileName.nMaxFile = MAX_PATH;
  443. OpenFileName.lpstrFileTitle = NULL;
  444. OpenFileName.nMaxFileTitle = 0;
  445. OpenFileName.lpstrInitialDir = NULL;
  446. OpenFileName.lpstrTitle = NULL;
  447. OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
  448. if( ::GetOpenFileName( &OpenFileName ) )
  449. {
  450. m_EditMessageWave.SetWindowText( OpenFileName.lpstrFile );
  451. }
  452. }
  453. void CPhoneEditDlg::OnButtonWelcomeTest()
  454. {
  455. // get welcome data
  456. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
  457. {
  458. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonWelcomeTest"), _T("Unexpected situation (state=NONE)") );
  459. }
  460. else
  461. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
  462. {
  463. // get file name
  464. TCHAR pFileName[MAX_PATH] = {0};
  465. m_EditWelcomeWave.GetWindowText( pFileName, MAX_PATH );
  466. // stop previous wave
  467. // m_WavePlayer.ResetWave();
  468. ::PlaySound( NULL, NULL, SND_PURGE );
  469. // stop previous speech
  470. m_SpeechPlayer.ResetSpeech();
  471. // // load file
  472. // if( m_WaveFile.Load( pFileName ) )
  473. // {
  474. // // play file
  475. // m_WavePlayer.PlayWave( &m_WaveFile, WAVE_MAPPER );
  476. // }
  477. ::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC );
  478. }
  479. else
  480. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
  481. {
  482. // get file name
  483. TCHAR pText[MAX_PATH] = {0};
  484. m_EditWelcomeText2Speech.GetWindowText( pText, MAX_PATH );
  485. // stop previous wave
  486. // m_WavePlayer.ResetWave();
  487. ::PlaySound( NULL, NULL, SND_PURGE );
  488. // stop previous speech
  489. m_SpeechPlayer.ResetSpeech();
  490. INT nIndex = m_ComboWelcomeVoice.GetCurSel();
  491. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboWelcomeVoice.GetItemData( nIndex );
  492. // play text
  493. m_SpeechPlayer.PlaySpeech( pText, WAVE_MAPPER, m_SliderWelcomeVolume.GetPos(), m_SliderWelcomeRate.GetPos(), pVoice );
  494. }
  495. }
  496. void CPhoneEditDlg::OnButtonMessageTest()
  497. {
  498. // get welcome data
  499. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
  500. {
  501. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonMessageTest"), _T("Unexpected situation (state=NONE)") );
  502. }
  503. else
  504. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
  505. {
  506. // get file name
  507. TCHAR pFileName[MAX_PATH] = {0};
  508. m_EditMessageWave.GetWindowText( pFileName, MAX_PATH );
  509. // stop previous wave
  510. // m_WavePlayer.ResetWave();
  511. ::PlaySound( NULL, NULL, SND_PURGE );
  512. // stop previous speech
  513. m_SpeechPlayer.ResetSpeech();
  514. // // load file
  515. // if( m_WaveFile.Load( pFileName ) )
  516. // {
  517. // // play file
  518. // m_WavePlayer.PlayWave( &m_WaveFile, WAVE_MAPPER );
  519. // }
  520. ::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC );
  521. }
  522. else
  523. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
  524. {
  525. // get file name
  526. TCHAR pText[MAX_PATH] = {0};
  527. m_EditMessageText2Speech.GetWindowText( pText, MAX_PATH );
  528. // stop previous wave
  529. // m_WavePlayer.ResetWave();
  530. ::PlaySound( NULL, NULL, SND_PURGE );
  531. // stop previous speech
  532. m_SpeechPlayer.ResetSpeech();
  533. INT nIndex = m_ComboMessageVoice.GetCurSel();
  534. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)m_ComboMessageVoice.GetItemData( nIndex );
  535. // play text
  536. m_SpeechPlayer.PlaySpeech( pText, WAVE_MAPPER, m_SliderMessageVolume.GetPos(), m_SliderMessageRate.GetPos(), pVoice );
  537. }
  538. }
  539. BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId, void* pParam )
  540. {
  541. CPhoneEditDlg *pThis = (CPhoneEditDlg*) pParam;
  542. return pThis->EnumVoiceProc( pDescription, pId );
  543. }
  544. BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId )
  545. {
  546. INT nIndex = m_ComboWelcomeVoice.AddString( pDescription );
  547. LPWSTR pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) );
  548. if( pCopyId ) wcscpy( pCopyId, pId );
  549. m_ComboWelcomeVoice.SetItemData( nIndex, (DWORD)pCopyId );
  550. if( !wcscmp( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pCopyId ) )
  551. m_ComboWelcomeVoice.SetCurSel( nIndex );
  552. nIndex = m_ComboMessageVoice.AddString( pDescription );
  553. pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) );
  554. if( pCopyId ) wcscpy( pCopyId, pId );
  555. m_ComboMessageVoice.SetItemData( nIndex, (DWORD)pCopyId );
  556. if( !wcscmp( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pCopyId ) )
  557. m_ComboMessageVoice.SetCurSel( nIndex );
  558. return TRUE;
  559. }
  560. void CPhoneEditDlg::OnDestroy()
  561. {
  562. while( m_ComboWelcomeVoice.GetCount() )
  563. {
  564. LPWSTR pVoice = (LPWSTR)m_ComboWelcomeVoice.GetItemData(0);
  565. if( pVoice )
  566. ::CoTaskMemFree( pVoice );
  567. m_ComboWelcomeVoice.DeleteString(0);
  568. }
  569. while( m_ComboMessageVoice.GetCount() )
  570. {
  571. LPWSTR pVoice = (LPWSTR)m_ComboMessageVoice.GetItemData(0);
  572. if( pVoice )
  573. ::CoTaskMemFree( pVoice );
  574. m_ComboMessageVoice.DeleteString(0);
  575. }
  576. CDialog::OnDestroy();
  577. }