// CFAX32.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

/********************************************************************/

// Contents :  fax s/r header file

/********************************************************************/

#ifndef __cfax32_h
#define __cfax32_h

/********************************************************************/

/********************************************************************/

// These are the other include files used when sending and receiving
// faxes.  The order of inclusion should not be changed.  Unfortunately,
// the design of the engine means that there's a very close coupling
// between the various classes involved, and while each class doesn't
// need to know how the other work, they all need to know what the others
// have to offer.  The fax settings need to be accessible from modem for
// autodetection to work, and since the modem handles the session log
// and progress reporting, the the cfaxtransfersource and
// cfaxmodemdriver classes need to be able know about that.  The inline
// functions at the end of this faxtrans.h file clearly won't compile if
// they don't know about cfaxtransfersource either. Ah well. So much for
// neat modular encapsulation.

#include <e32std.h>
#include <e32base.h>
#include <f32file.h>

#include <c32comm.h>
#include <s32file.h>
#include <s32mem.h>

#include <CommDB.h>
#include <CDBLen.h> 
#include <Commdb.h>
#include <faxstore.h>
#include <faxdefn.h>

#include "etel.h"
#include "faxset.h"
#include "faxtsrc.h"
#include "FaxStd.h"

/********************************************************************/

// now the CFaxTransfer class

class CFaxTransfer : public CBase
   {
 public:
   IMPORT_C static CFaxTransfer * NewL (const TFaxSettings &);
   IMPORT_C static CFaxTransfer * NewLC (const TFaxSettings &);

   IMPORT_C TInt Start (TRequestStatus &);
   IMPORT_C TInt Progress ();
   IMPORT_C void SetPhoneNumberL (TDesC8 &);
   IMPORT_C void Cancel ();
   IMPORT_C void Stop ();

   ~CFaxTransfer ();
   void GetPhoneModuleNameL(TDes& aModuleName) const;

   IMPORT_C void AddSourceL (const TFileName &);
   IMPORT_C void AddSourceL (const TFileName &, TInt);
   IMPORT_C void AddSourceL (const TFileName &, TInt, TInt);
   IMPORT_C void RemoveAllSources ();

   inline void SetMode (TFaxMode);
   inline void SetPhoneNumber (TDesC8 &);
   inline void SetReceiveFileName (const TFileName &);

   void FaxReceiveL ();
   void FaxTransmitL ();
   TInt GetPhoneInfoForTsy(const TDes& aTsyName, RTelServer::TPhoneInfo& aPhoneInfo) const;

   RTelServer iTelServer;
   RLine iLine ;
   RCall iCall ;
   RPhone iPhone ;
   RFax iFax ;
   CFaxTransferSource * iSource;
   TFaxSettings iFaxSettings;
   TFaxMode iMode;
   RCall::TFaxSessionSettings iFaxSessionSettings;
   RFax::TProgress iProgress ;
   TRequestStatus iTransferStatus ;
   TRequestStatus iClientCancel;
   TBuf8 < KMaxFaxBuf > iDataBuf;
   TBool iFaxStarted;

   TFileName iReceiveFileName ;		// only used when receiving
   TBuf8<KMaxDialString> iPhoneNumber ; 		// only used when dialling
 protected:
   RThread iDriverThread;
   CFaxTransfer();
   void ConstructL (const TFaxSettings &);
   void CancelFaxServerSession ();
   void SetFaxSettingsL();
   };

/********************************************************************/

#include "cfax32.inl"

#endif
