/*----------------------------------------------------------------------------- * * Copyright 2001 - 2003 Eicon Networks Corporation * * All Rights Reserved * * This software is the property of Eicon Networks Corporation and/or its * subsidiaries ("Eicon Networks"). This copyright notice may not be removed, * modified or obliterated without the prior written permission of * Eicon Networks. * * No right, title, ownership or other interest in the software is hereby * granted or transferred. The information contained herein is subject * to change without notice and should not be construed as a commitment of * Eicon Networks. * * This application code is not part of any standard Eicon Networks product * and is provided to you solely for the purpose of assisting you in the * development of your applications with Diva Server SDK. The code is provided * "AS IS", without warranty of any kind. Eicon Networks shall not be * liable for any damages arising out of your use of this application, even * if it has been advised of the possibility of such damages. *----------------------------------------------------------------------------- * Sample for receiving a single fax. * * The sample shows how to answer an incoming call and to receive a fax. The * received fax is stored in the file , any existing file will be * overwritten. For each page information is printed. * * The sample application is started from the command line. To terminate the * application press . * * Note that this sample is designed to show very simple how to process a * single call and to receive a fax. Therefore the sample does not do any * error handling. *----------------------------------------------------------------------------*/ #include #ifdef WIN32 #include #endif #include #include "dssdk.h" /* * Some globals */ DivaAppHandle hApp = NULL; DivaCallHandle hSdkCall = NULL; AppCallHandle hMyCall = NULL; char AudioFile[200] = { 0 }; void CallbackHandler ( DivaAppHandle hApp, DivaEvent Event, PVOID Param1, PVOID Param2 ) { DivaCallInfo Info; memset ( &Info, 0x00, sizeof ( Info ) ); Info.Size = sizeof ( Info ); switch (Event) { case DivaEventIncomingCall: if ( hSdkCall == NULL ) { hSdkCall = Param1; DivaAnswer ( hSdkCall, hMyCall, DivaCallTypeFax ); } break; case DivaEventCallConnected: if ( DivaReceiveFax ( hSdkCall, "RxFax.tif", DivaFaxFormatTIFF_ClassF ) == DivaSuccess ) { DivaGetCallInfo ( hSdkCall, &Info ); printf ( "Connected, Speed: %ld\n", Info.RxSpeed ); } else DivaDisconnect ( hSdkCall ); break; case DivaEventFaxPageReceived: DivaGetCallInfo ( hSdkCall, &Info ); printf ( "Page %ld received. Speed: %ld, ECM: %s \n", Info.dwFaxPages, Info.RxSpeed, Info.bECMActive ? "YES" : "NO" ); break; case DivaEventFaxReceived: DivaGetCallInfo ( hSdkCall, &Info ); printf ( "Fax received. Pages: %ld Speed: %ld, ECM: %s \n", Info.dwFaxPages, Info.RxSpeed, Info.bECMActive ? "YES" : "NO" ); DivaDisconnect ( hSdkCall ); break; case DivaEventCallDisconnected: hSdkCall = 0; DivaCloseCall ( Param2 ); printf ( "Disonnected, Server ready now.\n" ); break; default: break; } } int main(int argc, char* argv[]) { int c; printf("Version: %ld.%ld\n", (DivaGetVersion() >> 16) & 0xffff , DivaGetVersion() & 0xffff ); if (DivaInitialize() != DivaSuccess) return -1; hMyCall = (void *) 0x11223344; if ( DivaRegister ( &hApp, DivaEventModeCallback, (void *) CallbackHandler, 0, 1, 7, 2048 ) != DivaSuccess ) { return -1; } if ( DivaListen ( hApp, DivaListenAll, LINEDEV_ALL, "" ) != DivaSuccess ) return -1; printf ( "FaxInSimple running, press to terminate\n" ); while ( 1 ) { #ifdef WIN32 c = _getch ( ); #else c = getc (stdin); #endif if ( c == 'q' ) break; } printf ( "FaxInSimple stopped\n" ); DivaUnregister ( hApp ); return ( 0 ); };