123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- #include "dialphonenum.h"
- #include "SetThreshold.h"
- #include <mmsystem.h>
- #define WAVE_FORMAT_ALAW 0x0006
- #define WAVE_FORMAT_MULAW 0x0007
- #include "phonic_ubox.h"
- #if !defined(AFX_UPhoneBoxDLG_H__62FBB5F5_BADB_4DE5_81C1_7662793DA4E4__INCLUDED_)
- #define AFX_UPhoneBoxDLG_H__62FBB5F5_BADB_4DE5_81C1_7662793DA4E4__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif
- typedef unsigned long UBOX_LINE;
- #define INVALID_UBOX_LINE (UBOX_HANDLE)(-1)
- #define MAX_DEVICE 8
- class CUBoxLine
- {
- UBOX_HANDLE hdl;
- UBOX_LINE lineId_;
- CString dtmfkey;
- bool agc;
- bool bbuzzer;
- bool bmsgswitch;
- public:
-
- bool bplaypause;
- CSetThreshold threshold;
- Cdialphonenum SendDtmfDlg;
- FILE* fpstream;
- bool brecord;
- public:
- CUBoxLine() :hdl(INVALID_UBOX_HANDLE), lineId_(INVALID_UBOX_LINE), agc(false),
- bbuzzer(false), bmsgswitch(false), bplaypause(false), fpstream(NULL), brecord(false)
- {
-
- }
- ~CUBoxLine(){
- ;
- }
- void init_param()
- {
- agc = false;
- bbuzzer = false;
- bmsgswitch = false;
- bplaypause = false;
- brecord = false;
- }
- void handl_plug_in(UBOX_HANDLE ubxHdl, UBOX_LINE lineid){
- hdl = ubxHdl; lineId_ = lineid; init_param();
- }
- void handl_plug_out()
- {
- hdl = INVALID_UBOX_HANDLE;
- lineId_ = INVALID_UBOX_LINE;
- if (fpstream)
- {
- fclose(fpstream);
- fpstream = NULL;
- }
- }
- UBOX_HANDLE line_handel() const {
- return hdl;
- }
- UBOX_LINE line_id() const {
- return lineId_;
- }
- void set_dtmf_key(char key) {
- dtmfkey += key;
- }
- CString get_dtmfky() const {
- return dtmfkey;
- }
- void clear_dtmf_key(){
- dtmfkey = "";
- }
- bool get_agc() const {
- return agc;
- }
- void set_agc(bool bset) {
- agc = bset;
- }
- bool get_buzzerSwitch() const {
- return bbuzzer;
- }
- void set_buzzerSwitch(bool bset) {
- bbuzzer = bset;
- }
- bool get_MessageSwitch() const {
- return bmsgswitch;
- }
- void set_MessageSwitch(bool bset) {
- bmsgswitch = bset;
- }
- };
- #include "ClientTunnel.h"
- #include "TrayIcon.h"
- class CUPhoneBoxDlg : public CDialog
- {
- CTrayIcon m_TrayIcon;
-
- public:
- void RefreshData();
- void ReleaseData();
- void ShowAllWindow();
- void ClientBooking(CString id, CString name1, CString name2);
- void ExitWindow(int lineID, BOOL bSave);
- void ShowClient(int lineid, CString phone);
- CUPhoneBoxDlg(CWnd* pParent = NULL);
- void OnDisconnect();
- BOOL OnConnect();
- DWORD GetConnectionID();
- void SetConnectionID(DWORD dwConnection);
- void ProcessChatMessageRequest2(BYTE code);
- void ProcessChatMessageRequest2(CString sql);
- void ProcessChatMessageRequest2(BYTE *pData, int length);
- BOOL ProcessChatMessageRequest(void *szDataBuf, int nDataLen);
- void ProcessChatMessageResponse(void *pResponse);
- void ProcessLoginResponse(void *pLoginResult);
- BOOL ProcessLoginRequest();
- void ProcessNetEvent(int nEventType, void *pRecvMsg, DWORD dwDataLen);
- CClientTunnel m_tClientTunnel;
- DWORD m_dwConnectionID;
-
-
- enum {
- IDD = IDD_UPhoneBox_DIALOG
- };
- CListCtrl m_list;
- CListBox m_dis;
-
- int m_iClickItemID;
- inline CUBoxLine* get_line_by_ID(size_t lineID);
- inline CUBoxLine* get_line_by_handle(UBOX_HANDLE handle);
- void PopOpt(int index);
- void autoRecordFile(UBOX_HANDLE hdl);
- void handle_event(
- UBOX_HANDLE uboxHnd,
- int eventID,
- unsigned long param1,
- unsigned long param2,
- unsigned long param3,
- unsigned long param4);
-
-
- protected:
- virtual void DoDataExchange(CDataExchange* pDX);
-
-
- protected:
- void OnPLugInPhonicusb(UBOX_HANDLE hdl);
- void OnCallIdPhonicusb(UBOX_HANDLE hdl, char* callid);
- void OnCallOutFinishPhonicusb(UBOX_HANDLE hdl);
- void OnDeviceAlarmPhonicusb(UBOX_HANDLE hdl);
- void OnDeviceErrorPhonicusb(UBOX_HANDLE hdl);
- void OnDtmfKeyPhonicusb(UBOX_HANDLE hdl, char dtmfcode);
- void OnHangIngPhonicusb(UBOX_HANDLE hdl);
- void OnHangUpPhonicusb(UBOX_HANDLE hdl);
- void OnHookOffPhonicusb(UBOX_HANDLE hdl);
- void OnLineIdlePhonicusb(UBOX_HANDLE hdl);
- void OnLineVoltagePhonicusb(UBOX_HANDLE hdl, long voltage);
- void OnPlayEndPhonicusb(UBOX_HANDLE hdl);
- void OnPlayErrorPhonicusb(UBOX_HANDLE hdl);
- void OnPlugOutPhonicusb(UBOX_HANDLE hdl);
- void OnPolarityPhonicusb(UBOX_HANDLE hdl, long param1);
- void OnRingPhonicusb(UBOX_HANDLE hdl);
- void OnRingCancelPhonicusb(UBOX_HANDLE hdl);
- void OnRingStopPhonicusb(UBOX_HANDLE hdl);
- void OnStreamVoicePhonicusb(UBOX_HANDLE hdl, char* pvoice, long len);
- void OnToneBusyPhonicusb(UBOX_HANDLE hdl);
- protected:
- HICON m_hIcon;
- HICON m_hIcon2;
- CUBoxLine ubox_device[MAX_DEVICE];
- CString strPath;
-
-
- virtual BOOL OnInitDialog();
- afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
- afx_msg void OnPaint();
- afx_msg HCURSOR OnQueryDragIcon();
- afx_msg void OnCloseagc();
- afx_msg void OnDialphonenum();
- afx_msg void OnGethangthreshold();
- afx_msg void OnGethardwareversion();
- afx_msg void OnGetproductname();
- afx_msg void OnGetusernum();
- afx_msg void OnOpenbuzzer();
- afx_msg void OnOpenconfiguremode();
- afx_msg void OnOpenmsgswitch();
- afx_msg void OnPauseplay();
- afx_msg void OnPlayfile();
- afx_msg void OnReadeeprom();
- afx_msg void OnReadeepromex();
- afx_msg void OnReadlinevoltage();
- afx_msg void OnRecordfile();
- afx_msg void OnRecordstream();
- afx_msg void OnSethangthreshold();
- afx_msg void OnSethookoffthreshold();
- afx_msg void OnSofthangup();
- afx_msg void OnSofthookoff();
- afx_msg void OnStopplay();
- afx_msg void OnStopreadlinevoltage();
- afx_msg void OnStoprecord();
- afx_msg void OnWriteeeprom();
- afx_msg void OnSetBusyTone();
- afx_msg void OnGethookoffthreshold();
- afx_msg void OnDblclkOpt(NMHDR* pNMHDR, LRESULT* pResult);
- afx_msg void OnDestroy();
- afx_msg void OnRestart();
- afx_msg void OnSetVolume();
- afx_msg void OnTimer(UINT nIDEvent);
- afx_msg void OnClose();
- afx_msg void OnAutorun();
- LRESULT OnTrayNotification(WPARAM wParam, LPARAM lParam);
- LRESULT OnNewClient(WPARAM wParam, LPARAM lParam);
-
- DECLARE_MESSAGE_MAP()
- CFont m_font;
- };
- #pragma pack( push, 1 )
- struct WaveFileHeader //sizeof(WaveFileHeader) = 44
- {
- unsigned long riff_chunk_ID_;
- unsigned long riff_chunk_size_;
- unsigned long wave_id_;
- unsigned long wave_fmt_chunk_id_;
- unsigned long wave_fmt_chunk_size_;
- WAVEFORMATEX wav_fmt_;
- unsigned long fact_chunk_ID_;
- unsigned long fact_chunk_size_;
- unsigned long fact_data_size_;
- unsigned long data_data_ID_;
- unsigned long data_data_size_;
- WaveFileHeader()
- {
- set(0, WAVE_FORMAT_PCM);
- }
- WaveFileHeader(size_t wavesize)
- {
- set(wavesize, WAVE_FORMAT_PCM);
- }
- WaveFileHeader(size_t wavesize, WORD fmt)
- {
- set(wavesize, fmt);
- }
- void set(size_t wavesize, WORD fmt)
- {
- riff_chunk_ID_ = FOURCC_RIFF;
- riff_chunk_size_ = wavesize + sizeof(WaveFileHeader) - 2 * sizeof(unsigned long);
- wave_id_ = mmioFOURCC('W', 'A', 'V', 'E');
- wave_fmt_chunk_id_ = mmioFOURCC('f', 'm', 't', ' ');
- wave_fmt_chunk_size_ = 0x12;
- wav_fmt_.wFormatTag = fmt;
- wav_fmt_.nChannels = 1;
- wav_fmt_.nSamplesPerSec = 8000;
- wav_fmt_.cbSize = 0;
- fact_data_size_ = wavesize;
- switch (fmt)
- {
- case WAVE_FORMAT_PCM:
- wav_fmt_.wBitsPerSample = 16;
- break;
- case WAVE_FORMAT_ALAW:
- case WAVE_FORMAT_MULAW:
- wav_fmt_.wBitsPerSample = 8;
- break;
- }
- wav_fmt_.nAvgBytesPerSec = wav_fmt_.nChannels
- * wav_fmt_.nSamplesPerSec
- * wav_fmt_.wBitsPerSample / 8;
- wav_fmt_.nBlockAlign = wav_fmt_.nChannels * wav_fmt_.wBitsPerSample / 8;
- fact_chunk_ID_ = mmioFOURCC('f', 'a', 'c', 't');
- fact_chunk_size_ = 4;
- data_data_ID_ = mmioFOURCC('d', 'a', 't', 'a');
- data_data_size_ = wavesize;
- }
- };
- #pragma pack( pop, 1 )
- #endif
|