FaxAPI.h
上传用户:glass0516
上传日期:2010-01-11
资源大小:104k
文件大小:7k
- /*****************************************************************************
- * RelayFax Open Source Project
- * Copyright 1996-2004 Alt-N Technologies, Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the RelayFax Open
- * Source License. A copy of this license is available in file LICENSE
- * in the top-level directory of the distribution.
- *
- * RelayFax is a registered trademark of Alt-N Technologies, Ltd.
- *
- * Individual files and/or contributed packages may be copyright by
- * other parties and subject to additional restrictions.
- *****************************************************************************/
- #ifndef FAXAPI_H
- #define FAXAPI_H
- #define FAXAPI_CALL WINAPI
- // For FaxApiCreateModem: Note that class 1.0 and class 2.1 are not functional.
- #define FAXAPI_DETECT 0
- #define FAXAPI_CLASS_1 1
- #define FAXAPI_CLASS_1_0 2
- #define FAXAPI_CLASS_2 3
- #define FAXAPI_CLASS_2_0 4
- #define FAXAPI_CLASS_2_1 5
- // Speaker volume parameter for FaxApiSetSpkrParams
- #define FAXAPI_SPKRVOL_LOW 0
- #define FAXAPI_SPKRVOL_MED 1
- #define FAXAPI_SPKRVOL_HIGH 2
- // Speaker mode parameter for FaxApiSetSpkrParams
- #define FAXAPI_SPKRMODE_OFF 0
- #define FAXAPI_SPKRMODE_DIAL 1
- #define FAXAPI_SPKRMODE_ON 2
- // For FaxApiSetSendEncoding -- don't use uncompressed!
- #define FAXAPI_ENC_CCITT_1D 0
- #define FAXAPI_ENC_CCITT_2D 1
- #define FAXAPI_ENC_CCITT_UNC 2
- #define FAXAPI_ENC_CCITT_T6 3
- // FaxApiSetSendBaud and FaxApiSetRecvBaud
- #define FAXAPI_BAUD_2400 1
- #define FAXAPI_BAUD_4800 2
- #define FAXAPI_BAUD_7200 3
- #define FAXAPI_BAUD_9600 4
- #define FAXAPI_BAUD_12000 5
- #define FAXAPI_BAUD_14400 6
- #define FAXAPI_BAUD_16800 7
- #define FAXAPI_BAUD_19200 8
- #define FAXAPI_BAUD_21600 9
- #define FAXAPI_BAUD_24000 10
- #define FAXAPI_BAUD_26400 11
- #define FAXAPI_BAUD_28800 12
- #define FAXAPI_BAUD_31200 13
- #define FAXAPI_BAUD_33600 14
- // Events - identified by lParam of FAXAPI_MESSAGE
- #define FAXAPI_EVENT_ERROR 0
- #define FAXAPI_EVENT_IDLE 1
- #define FAXAPI_EVENT_RING 2
- #define FAXAPI_EVENT_START_RECV 3
- #define FAXAPI_EVENT_START_SEND 4
- #define FAXAPI_EVENT_RECV_DIS 5
- #define FAXAPI_EVENT_SENT_DIS 6
- #define FAXAPI_EVENT_RECV_DCS 7
- #define FAXAPI_EVENT_SENT_DCS 8
- #define FAXAPI_EVENT_START_TRAINING 9
- #define FAXAPI_EVENT_START_PAGE 10
- #define FAXAPI_EVENT_PAGE_DATA 11
- #define FAXAPI_EVENT_GOT_REMOTEID 12
- #define FAXAPI_EVENT_TERMINATE 13
- #define FAXAPI_EVENT_DISCONNECT 14
- #define FAXAPI_EVENT_CALLERID 15
- #define FAXAPI_EVENT_INFO 16
- #define FAXAPI_EVENT_DETECT_FINISHED 17
- #define FAXAPI_SUCCESS 0
- #define FAXAPI_ERROR_BAD_MSG 1
- #define FAXAPI_ERROR_BAD_MODEM 2
- #define FAXAPI_ERROR_THREAD_STARTED 3
- #define FAXAPI_MESSAGE WM_USER+423
- // FAXAPI_MESSAGEs have lParam = FAXAPI_EVENT and wParam is *FaxApiModemMsg
- // if lParam == FAXAPI_EVENT_DETECT_FINISHED then wParam is *FaxApiModemDetectMsg
- // Free either one by calling FaxApiDeleteMessage()
- #define FAXAPI_MAXPARAMVALUE 7
- #define FAXAPI_MAXPARAMETERS 8
- #define FAXAPI_MODEMMSG_IDLEN 32
- #define FAXAPI_MODEMMSG_INFOLEN 256
- #define FAXAPI_DETECTMSG_INFOLEN 256
- extern "C" {
- // See class 2/2.0 spec for definition of these parameters
- typedef struct
- {
- int VertRes;
- int BitRate;
- int PageWidth;
- int PageLength;
- int DataFormat;
- int ECM;
- int BFT;
- int ScanTime;
- } FaxApiParameters;
- typedef struct
- {
- int nSuccessful; // 1 = true, 0 = false
- int nPages; // total pages sent/recvd
- } FaxApiTerminate;
- typedef struct _FaxApiModemMsg // for all events except FAXAPI_EVENT_DETECT_FINISHED
- {
- unsigned int m_cbSize;
- FaxApiParameters p; // for DIS/DCS events only
- FaxApiTerminate t; // for FAXAPI_EVENT_TERMINATE only
- char szID[FAXAPI_MODEMMSG_IDLEN]; // Modem port
- char sz[FAXAPI_MODEMMSG_INFOLEN]; // information string
- } FaxApiModemMsg;
- typedef struct _FaxApiModemDetectMsg // for FAXAPI_EVENT_DETECT_FINISHED only
- {
- unsigned int m_cbSize;
- bool m_bSuccessful;
- bool m_bClass1;
- bool m_bClass1_0;
- bool m_bClass2;
- bool m_bClass2_0;
- bool m_bClass2_1;
- bool m_Class2Matrix[FAXAPI_MAXPARAMETERS][FAXAPI_MAXPARAMVALUE];
- bool m_Class20Matrix[FAXAPI_MAXPARAMETERS][FAXAPI_MAXPARAMVALUE];
- int m_nSendBaudRate;
- int m_nRecvBaudRate;
- char m_szClasses[FAXAPI_DETECTMSG_INFOLEN];
- char m_szProductCode[FAXAPI_DETECTMSG_INFOLEN];
- char m_szIDCode[FAXAPI_DETECTMSG_INFOLEN];
- char m_szManufacturer[FAXAPI_DETECTMSG_INFOLEN];
- char m_szModel[FAXAPI_DETECTMSG_INFOLEN];
- char szID[FAXAPI_MODEMMSG_IDLEN];
- } FaxApiModemDetectMsg;
- typedef void* FaxApiModem;
- // call this first
- FaxApiModem FAXAPI_CALL FaxApiCreateModem( int nClass );
- // called these FaxApiStartThread
- int FAXAPI_CALL FaxApiSetCommParam( FaxApiModem pModem, DWORD BaudRate, BYTE ByteSize, BYTE Parity, BYTE StopBits );
- int FAXAPI_CALL FaxApiSetFlowControl( FaxApiModem pModem, bool bDSRFlowControl, bool bCTSFlowControl, bool bSoftFlowControl );
- int FAXAPI_CALL FaxApiSetPort( FaxApiModem pModem, char* szPort );
- int FAXAPI_CALL FaxApiSetSpkrParams( FaxApiModem pModem, int nSpkrVol, int nSpkrMode );
- int FAXAPI_CALL FaxApiSetDistinctiveRing( FaxApiModem pModem, LPCSTR szRingCodes );
- int FAXAPI_CALL FaxApiSetInitString( FaxApiModem pModem, LPCSTR szString );
- int FAXAPI_CALL FaxApiSetSendEncoding( FaxApiModem pModem, int nEncoding );
- int FAXAPI_CALL FaxApiSetSendECM( FaxApiModem pModem, bool bECMSupported );
- int FAXAPI_CALL FaxApiSetSendFine( FaxApiModem pModem, bool bFineSupported );
- int FAXAPI_CALL FaxApiSetSendUnlimited( FaxApiModem pModem, bool bUnlimitedSupported );
- int FAXAPI_CALL FaxApiSetPulseDialing( FaxApiModem pModem, bool bPulseDialing );
- int FAXAPI_CALL FaxApiSetSendBaud( FaxApiModem pModem, int nBaud );
- int FAXAPI_CALL FaxApiSetRecvBaud( FaxApiModem pModem, int nBaud );
- int FAXAPI_CALL FaxApiEnableDebugLog( FaxApiModem pModem, bool bEnable, char* LogDirectory );
- int FAXAPI_CALL FaxApiSetMaxPageRetries( FaxApiModem pModem, int nRetries );
- // this can be called before or after FaxApiStartThread
- int FAXAPI_CALL FaxApiSetCSID( FaxApiModem pModem, LPCSTR szString );
- // start the modem thread
- int FAXAPI_CALL FaxApiStartThread( FaxApiModem pModem, HANDLE hStop, DWORD faxThreadID );
- // these can only be called after FaxApiStartThread
- void FAXAPI_CALL FaxApiReceiveFax( FaxApiModem pModem, char* szFaxFile );
- void FAXAPI_CALL FaxApiAbortFax( FaxApiModem pModem );
- void FAXAPI_CALL FaxApiDisconnect( FaxApiModem pModem );
- bool FAXAPI_CALL FaxApiSendFax( FaxApiModem pModem, char* szNumberToDial, char* szFaxFile );
- void FAXAPI_CALL FaxApiClearRingCount( FaxApiModem pModem );
- int FAXAPI_CALL FaxApiWaitForModemToExit( FaxApiModem pModem );
- // call this when processing modem messages
- int FAXAPI_CALL FaxApiDeleteMessage( MSG* pMsg );
- }
- #endif // FAXAPI_H