irda/irdastack/irtranp/comreadwrite.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15  
       
    16 #ifndef COMREADWRITE_H
       
    17 #define COMREADWRITE_H
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <c32comm.h>
       
    21 
       
    22 class RComm;
       
    23 class RCommServ;
       
    24 class IrTranpUtil;
       
    25 
       
    26 class MComReadWriteObserver
       
    27 	{
       
    28 public:
       
    29 	virtual void ReceiveComplete(TDesC8& aBuffer) = 0;
       
    30 	virtual void SendComplete() = 0;
       
    31 	virtual void SendError(TInt aError) = 0;
       
    32 	virtual void ReceiveError(TInt aError) = 0;
       
    33 	virtual void Error(TInt aError) = 0;
       
    34 	};
       
    35 
       
    36 
       
    37 NONSHARABLE_CLASS(CComReadWrite) : public CActive
       
    38 {
       
    39 public:
       
    40 	enum TState {EError, ESend, EReceive, EOpen, EClose, EStop};
       
    41 
       
    42 public:
       
    43 	CComReadWrite();
       
    44 	~CComReadWrite();
       
    45 
       
    46 	static CComReadWrite* NewL(MComReadWriteObserver& iObserver);
       
    47 	void ConstructL();
       
    48 	
       
    49 	void Open();
       
    50 	void Close();
       
    51 	void Send(TDesC8& data);
       
    52 	void Receive();
       
    53 	void Signal(TInt aError);
       
    54 
       
    55 private:
       
    56 	void RunL();
       
    57 	void DoCancel();
       
    58 
       
    59 
       
    60 private:
       
    61 	
       
    62 	CComReadWrite(TInt aPrority, MComReadWriteObserver& aObserver);
       
    63 	RComm iCommPort;
       
    64 	RCommServ iServer;
       
    65 	TState iState;
       
    66 
       
    67 	TBuf8<2048> iRxBuffer;
       
    68 	TBuf8<2048> iSCEPFrame;
       
    69 	TBuf8<2048> iTxBuffer;
       
    70 
       
    71 	MComReadWriteObserver& iObserver;
       
    72 };
       
    73 
       
    74 #endif //COMREADWRITE_H