UPhoneBoxDlg.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. // UPhoneBoxDlg.h : heade r file
  2. //
  3. //{{AFX_INCLUDES()
  4. //}}AFX_INCLUDES
  5. #include "dialphonenum.h"
  6. #include "SetThreshold.h"
  7. #include <mmsystem.h>
  8. #define WAVE_FORMAT_ALAW 0x0006
  9. #define WAVE_FORMAT_MULAW 0x0007
  10. #include "phonic_ubox.h"
  11. #if !defined(AFX_UPhoneBoxDLG_H__62FBB5F5_BADB_4DE5_81C1_7662793DA4E4__INCLUDED_)
  12. #define AFX_UPhoneBoxDLG_H__62FBB5F5_BADB_4DE5_81C1_7662793DA4E4__INCLUDED_
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif // _MSC_VER > 1000
  16. typedef unsigned long UBOX_LINE;
  17. #define INVALID_UBOX_LINE (UBOX_HANDLE)(-1)
  18. #define MAX_DEVICE 8
  19. class CUBoxLine
  20. {
  21. UBOX_HANDLE hdl;
  22. UBOX_LINE lineId_;
  23. CString dtmfkey;
  24. bool agc;
  25. bool bbuzzer;
  26. bool bmsgswitch;
  27. public:
  28. // CString phonenum;
  29. bool bplaypause;
  30. CSetThreshold threshold;
  31. Cdialphonenum SendDtmfDlg;
  32. FILE* fpstream;
  33. bool brecord;
  34. public:
  35. CUBoxLine() :hdl(INVALID_UBOX_HANDLE), lineId_(INVALID_UBOX_LINE), agc(false),
  36. bbuzzer(false), bmsgswitch(false), bplaypause(false), fpstream(NULL), brecord(false)
  37. {
  38. // phonenum = _T("9876543210");
  39. }
  40. ~CUBoxLine(){
  41. ;
  42. }
  43. void init_param()
  44. {
  45. agc = false;
  46. bbuzzer = false;
  47. bmsgswitch = false;
  48. bplaypause = false;
  49. brecord = false;
  50. }
  51. void handl_plug_in(UBOX_HANDLE ubxHdl, UBOX_LINE lineid){
  52. hdl = ubxHdl; lineId_ = lineid; init_param();
  53. }
  54. void handl_plug_out()
  55. {
  56. hdl = INVALID_UBOX_HANDLE;
  57. lineId_ = INVALID_UBOX_LINE;
  58. if (fpstream)
  59. {
  60. fclose(fpstream);
  61. fpstream = NULL;
  62. }
  63. }
  64. UBOX_HANDLE line_handel() const {
  65. return hdl;
  66. }
  67. UBOX_LINE line_id() const {
  68. return lineId_;
  69. }
  70. void set_dtmf_key(char key) {
  71. dtmfkey += key;
  72. }
  73. CString get_dtmfky() const {
  74. return dtmfkey;
  75. }
  76. void clear_dtmf_key(){
  77. dtmfkey = "";
  78. }
  79. bool get_agc() const {
  80. return agc;
  81. }
  82. void set_agc(bool bset) {
  83. agc = bset;
  84. }
  85. bool get_buzzerSwitch() const {
  86. return bbuzzer;
  87. }
  88. void set_buzzerSwitch(bool bset) {
  89. bbuzzer = bset;
  90. }
  91. bool get_MessageSwitch() const {
  92. return bmsgswitch;
  93. }
  94. void set_MessageSwitch(bool bset) {
  95. bmsgswitch = bset;
  96. }
  97. };
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CUPhoneBoxDlg dialog
  100. #include "ClientTunnel.h"
  101. #include "TrayIcon.h"
  102. class CUPhoneBoxDlg : public CDialog
  103. {
  104. CTrayIcon m_TrayIcon;
  105. // Construction
  106. public:
  107. void RefreshData();
  108. void ReleaseData();
  109. void ShowAllWindow();
  110. void ClientBooking(CString id, CString name1, CString name2);
  111. void ExitWindow(int lineID, BOOL bSave);
  112. void ShowClient(int lineid, CString phone);
  113. CUPhoneBoxDlg(CWnd* pParent = NULL); // standard constructor
  114. void OnDisconnect();
  115. BOOL OnConnect();
  116. DWORD GetConnectionID();
  117. void SetConnectionID(DWORD dwConnection);
  118. void ProcessChatMessageRequest2(BYTE code);
  119. void ProcessChatMessageRequest2(CString sql);
  120. void ProcessChatMessageRequest2(BYTE *pData, int length);
  121. BOOL ProcessChatMessageRequest(void *szDataBuf, int nDataLen);
  122. void ProcessChatMessageResponse(void *pResponse);
  123. void ProcessLoginResponse(void *pLoginResult);
  124. BOOL ProcessLoginRequest();
  125. void ProcessNetEvent(int nEventType, void *pRecvMsg, DWORD dwDataLen);
  126. CClientTunnel m_tClientTunnel;
  127. DWORD m_dwConnectionID;
  128. // Dialog Data
  129. //{{AFX_DATA(CUPhoneBoxDlg)
  130. enum {
  131. IDD = IDD_UPhoneBox_DIALOG
  132. };
  133. CListCtrl m_list;
  134. CListBox m_dis;
  135. //}}AFX_DATA
  136. int m_iClickItemID;
  137. inline CUBoxLine* get_line_by_ID(size_t lineID);
  138. inline CUBoxLine* get_line_by_handle(UBOX_HANDLE handle);
  139. void PopOpt(int index);
  140. void autoRecordFile(UBOX_HANDLE hdl);
  141. void handle_event(
  142. UBOX_HANDLE uboxHnd,
  143. int eventID, //事件,参考UBOX_EVENT的定义
  144. unsigned long param1, //下面几个参数不同的事件,其含义不同
  145. unsigned long param2,
  146. unsigned long param3,
  147. unsigned long param4);
  148. // ClassWizard generated virtual function overrides
  149. //{{AFX_VIRTUAL(CUPhoneBoxDlg)
  150. protected:
  151. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  152. //}}AFX_VIRTUAL
  153. // Implementation
  154. protected:
  155. void OnPLugInPhonicusb(UBOX_HANDLE hdl);
  156. void OnCallIdPhonicusb(UBOX_HANDLE hdl, char* callid);
  157. void OnCallOutFinishPhonicusb(UBOX_HANDLE hdl);
  158. void OnDeviceAlarmPhonicusb(UBOX_HANDLE hdl);
  159. void OnDeviceErrorPhonicusb(UBOX_HANDLE hdl);
  160. void OnDtmfKeyPhonicusb(UBOX_HANDLE hdl, char dtmfcode);
  161. void OnHangIngPhonicusb(UBOX_HANDLE hdl);
  162. void OnHangUpPhonicusb(UBOX_HANDLE hdl);
  163. void OnHookOffPhonicusb(UBOX_HANDLE hdl);
  164. void OnLineIdlePhonicusb(UBOX_HANDLE hdl);
  165. void OnLineVoltagePhonicusb(UBOX_HANDLE hdl, long voltage);
  166. void OnPlayEndPhonicusb(UBOX_HANDLE hdl);
  167. void OnPlayErrorPhonicusb(UBOX_HANDLE hdl);
  168. void OnPlugOutPhonicusb(UBOX_HANDLE hdl);
  169. void OnPolarityPhonicusb(UBOX_HANDLE hdl, long param1);
  170. void OnRingPhonicusb(UBOX_HANDLE hdl);
  171. void OnRingCancelPhonicusb(UBOX_HANDLE hdl);
  172. void OnRingStopPhonicusb(UBOX_HANDLE hdl);
  173. void OnStreamVoicePhonicusb(UBOX_HANDLE hdl, char* pvoice, long len);
  174. void OnToneBusyPhonicusb(UBOX_HANDLE hdl);
  175. protected:
  176. HICON m_hIcon;
  177. HICON m_hIcon2;
  178. CUBoxLine ubox_device[MAX_DEVICE];
  179. CString strPath;
  180. // Generated message map functions
  181. //{{AFX_MSG(CUPhoneBoxDlg)
  182. virtual BOOL OnInitDialog();
  183. afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  184. afx_msg void OnPaint();
  185. afx_msg HCURSOR OnQueryDragIcon();
  186. afx_msg void OnCloseagc();
  187. afx_msg void OnDialphonenum();
  188. afx_msg void OnGethangthreshold();
  189. afx_msg void OnGethardwareversion();
  190. afx_msg void OnGetproductname();
  191. afx_msg void OnGetusernum();
  192. afx_msg void OnOpenbuzzer();
  193. afx_msg void OnOpenconfiguremode();
  194. afx_msg void OnOpenmsgswitch();
  195. afx_msg void OnPauseplay();
  196. afx_msg void OnPlayfile();
  197. afx_msg void OnReadeeprom();
  198. afx_msg void OnReadeepromex();
  199. afx_msg void OnReadlinevoltage();
  200. afx_msg void OnRecordfile();
  201. afx_msg void OnRecordstream();
  202. afx_msg void OnSethangthreshold();
  203. afx_msg void OnSethookoffthreshold();
  204. afx_msg void OnSofthangup();
  205. afx_msg void OnSofthookoff();
  206. afx_msg void OnStopplay();
  207. afx_msg void OnStopreadlinevoltage();
  208. afx_msg void OnStoprecord();
  209. afx_msg void OnWriteeeprom();
  210. afx_msg void OnSetBusyTone();
  211. afx_msg void OnGethookoffthreshold();
  212. afx_msg void OnDblclkOpt(NMHDR* pNMHDR, LRESULT* pResult);
  213. afx_msg void OnDestroy();
  214. afx_msg void OnRestart();
  215. afx_msg void OnSetVolume();
  216. afx_msg void OnTimer(UINT nIDEvent);
  217. afx_msg void OnClose();
  218. afx_msg void OnAutorun();
  219. LRESULT OnTrayNotification(WPARAM wParam, LPARAM lParam);
  220. LRESULT OnNewClient(WPARAM wParam, LPARAM lParam);
  221. //}}AFX_MSG
  222. DECLARE_MESSAGE_MAP()
  223. CFont m_font;
  224. };
  225. #pragma pack( push, 1 )
  226. struct WaveFileHeader //sizeof(WaveFileHeader) = 44
  227. {
  228. unsigned long riff_chunk_ID_; //"RIFF"
  229. unsigned long riff_chunk_size_; //riff_chunk_size_ = filesize-8
  230. unsigned long wave_id_; //"WAVE"
  231. unsigned long wave_fmt_chunk_id_; //"fmt "
  232. unsigned long wave_fmt_chunk_size_; //=sizeof(wav_fmt_)
  233. WAVEFORMATEX wav_fmt_;
  234. unsigned long fact_chunk_ID_; //"fact"
  235. unsigned long fact_chunk_size_; //4
  236. unsigned long fact_data_size_; //fact_data_size_=riff_chunk_size_-50
  237. unsigned long data_data_ID_; //"data"
  238. unsigned long data_data_size_; //data_data_size_=riff_chunk_size_-50
  239. WaveFileHeader()
  240. {
  241. set(0, WAVE_FORMAT_PCM);
  242. }
  243. WaveFileHeader(size_t wavesize)
  244. {
  245. set(wavesize, WAVE_FORMAT_PCM);
  246. }
  247. WaveFileHeader(size_t wavesize, WORD fmt)
  248. {
  249. set(wavesize, fmt);
  250. }
  251. void set(size_t wavesize, WORD fmt)
  252. {
  253. riff_chunk_ID_ = FOURCC_RIFF;
  254. riff_chunk_size_ = wavesize + sizeof(WaveFileHeader) - 2 * sizeof(unsigned long);
  255. wave_id_ = mmioFOURCC('W', 'A', 'V', 'E');
  256. wave_fmt_chunk_id_ = mmioFOURCC('f', 'm', 't', ' ');
  257. wave_fmt_chunk_size_ = 0x12;
  258. wav_fmt_.wFormatTag = /*(WORD)*/fmt;
  259. wav_fmt_.nChannels = 1; // 1 for mono
  260. wav_fmt_.nSamplesPerSec = 8000;
  261. wav_fmt_.cbSize = 0;
  262. fact_data_size_ = wavesize;
  263. switch (fmt)
  264. {
  265. case WAVE_FORMAT_PCM:
  266. wav_fmt_.wBitsPerSample = 16;
  267. break;
  268. case WAVE_FORMAT_ALAW:
  269. case WAVE_FORMAT_MULAW:
  270. wav_fmt_.wBitsPerSample = 8;
  271. break;
  272. }
  273. wav_fmt_.nAvgBytesPerSec = wav_fmt_.nChannels
  274. * wav_fmt_.nSamplesPerSec
  275. * wav_fmt_.wBitsPerSample / 8;
  276. wav_fmt_.nBlockAlign = wav_fmt_.nChannels * wav_fmt_.wBitsPerSample / 8;
  277. fact_chunk_ID_ = mmioFOURCC('f', 'a', 'c', 't');
  278. fact_chunk_size_ = 4;
  279. data_data_ID_ = mmioFOURCC('d', 'a', 't', 'a');
  280. data_data_size_ = wavesize;
  281. }
  282. };
  283. #pragma pack( pop, 1 )
  284. //{{AFX_INSERT_LOCATION}}
  285. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  286. #endif // !defined(AFX_UPhoneBoxDLG_H__62FBB5F5_BADB_4DE5_81C1_7662793DA4E4__INCLUDED_)