usbmgmt/usbmgr/device/classdrivers/acm/classimplementation/ecacm/inc/CdcDataInterface.h
changeset 0 c9bc50fca66e
child 6 96e575696901
equal deleted inserted replaced
-1:000000000000 0:c9bc50fca66e
       
     1 /*
       
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CDCDATAINTERFACE_H__
       
    19 #define __CDCDATAINTERFACE_H__
       
    20 
       
    21 #include "CdcInterfaceBase.h"
       
    22 #include "WriteObserver.h"
       
    23 #include "ReadObserver.h"
       
    24 #include "ReadOneOrMoreObserver.h"
       
    25 #include "linkstatenotifier.h"
       
    26 #include "NotifyDataAvailableObserver.h"
       
    27 
       
    28 
       
    29 
       
    30 class CActiveReadOneOrMoreReader;
       
    31 class CActiveReader;
       
    32 class CActiveDataAvailableNotifier;
       
    33 class CActiveWriter;
       
    34 class CIniFile;
       
    35 
       
    36 NONSHARABLE_CLASS(CCdcDataInterface) :	public CCdcInterfaceBase,
       
    37 							public MReadObserver,
       
    38 							public MReadOneOrMoreObserver,
       
    39 							public MWriteObserver,
       
    40 							public MLinkStateObserver,
       
    41 							public MNotifyDataAvailableObserver
       
    42 /**
       
    43  * ACM data interface subclass.
       
    44  */
       
    45 	{
       
    46 public:
       
    47 	static CCdcDataInterface* NewL(const TDesC16& aIfcName);
       
    48 	~CCdcDataInterface();
       
    49 
       
    50 public:
       
    51 	void Write(MWriteObserver& aObserver, const TDesC8& aDes, TInt aLen);
       
    52 	void CancelWrite();
       
    53 	void Read(MReadObserver& aObserver, TDes8& aDes, TInt aMaxLen);
       
    54 	void ReadOneOrMore(MReadOneOrMoreObserver& aObserver, 
       
    55 		TDes8 &aDes, 
       
    56 		TInt aMaxLen);
       
    57 	void CancelRead();
       
    58 	void NotifyDataAvailable(MNotifyDataAvailableObserver& aObserver);
       
    59 	void CancelNotifyDataAvailable();
       
    60 
       
    61 private:
       
    62 	CCdcDataInterface();
       
    63 	CCdcDataInterface(const TDesC16& aIfcName);
       
    64 	void ConstructL();
       
    65 
       
    66 private: // from MReadOneOrMoreObserver
       
    67 	void ReadOneOrMoreCompleted(TInt aError);
       
    68 
       
    69 private: // from MReadObserver
       
    70 	void ReadCompleted(TInt aError);
       
    71 
       
    72 private: // from MWriteObserver
       
    73 	void WriteCompleted(TInt aError);
       
    74 
       
    75 private: // from CCdcClassBase
       
    76 	TInt SetUpInterface();
       
    77 
       
    78 private: // from MLinkStateObserver
       
    79 	void MLSOStateChange(TInt aPacketSize);
       
    80 
       
    81 private: // from MNotifyDataAvailableObserver
       
    82 	void NotifyDataAvailableCompleted(TInt aError);
       
    83 
       
    84 private: 
       
    85 	void GetHostZLPHandlingFromFile();
       
    86 
       
    87 private: // owned
       
    88 	CActiveReadOneOrMoreReader* iReadOneOrMoreReader;
       
    89 	CActiveReader* iReader;
       
    90 	CActiveWriter* iWriter;
       
    91 	CActiveDataAvailableNotifier* iDataAvailableNotifier;
       
    92 	CLinkStateNotifier* iLinkState;
       
    93 	TBool iHostCanHandleZLPs;  ///< Host USB Device Driver can cope with Zero Length Packets
       
    94 	TInt iPacketSize;
       
    95 
       
    96 private: // unowned
       
    97 	MReadObserver* iReadObserver;
       
    98 	MReadOneOrMoreObserver* iReadOneOrMoreObserver;
       
    99 	MWriteObserver* iWriteObserver;
       
   100 	MNotifyDataAvailableObserver* iNotifyDataAvailableObserver;
       
   101 
       
   102 #ifdef __HEADLESS_ACM_TEST_CODE__
       
   103 	// This code is for testing the performance of the stack at the 
       
   104 	// RDevUsbcClient level. Issue a Read or ReadOneOrMore at the RComm level, 
       
   105 	// and it will be passed to the LDD. When it completes, it will Write the 
       
   106 	// data back. When that completes, it will again Read/ROOM. It basically 
       
   107 	// enters an infinite loop, doing loopback. Drive this from the PC end 
       
   108 	// using serial.exe.
       
   109 private: // owned
       
   110 	// The buffer to do repeated Read/ReadOneOrMore into and Writes from.
       
   111 	TBuf8<4096> iHeadlessAcmBuffer;
       
   112 	// The length of the initial Read/ROOM request- we continue to use this 
       
   113 	// value in subsequent Read/ROOM requests.
       
   114 	TUint iHeadlessReadLength;
       
   115 	// Whether we're currently using Read or ROOM. 
       
   116 	enum THeadlessReadType
       
   117 		{
       
   118 		EUnknown,
       
   119 		ERead,
       
   120 		EReadOneOrMore
       
   121 		};
       
   122 	THeadlessReadType iHeadlessReadType;
       
   123 #endif // __HEADLESS_ACM_TEST_CODE__
       
   124 	};
       
   125 
       
   126 #endif // __CDCDATAINTERFACE_H__