sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: // WARNING: This file contains some APIs which are internal and are subject sl@0: // to change without notice. Such APIs should therefore not be used sl@0: // outside the Kernel and Hardware Services package. sl@0: // sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: #ifndef __RPIPE_H__ sl@0: #define __RPIPE_H__ sl@0: sl@0: #include sl@0: #include sl@0: #ifndef __KERNEL_MODE__ sl@0: #include sl@0: #endif sl@0: sl@0: #if defined(DATAPAGING_TEST_ON) sl@0: #define DATAPAGING_TEST(s) s sl@0: #else sl@0: #define DATAPAGING_TEST(s) sl@0: #endif sl@0: sl@0: sl@0: class RPipe: public RBusLogicalChannel sl@0: /** sl@0: RPipe class object represent the user side handle. It is derived from RBusLogicalChannel sl@0: which is the base class for handle to the kernel side device driver instance. It encapsulates sl@0: both named and unnamed pipe methods. sl@0: @internalTechnology sl@0: */ sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Structure for holding driver capabilities information sl@0: (Just a version number.) sl@0: */ sl@0: class TCaps sl@0: { sl@0: public: sl@0: TVersion iVersion; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: Enumeration for the modes of opening a pipe. sl@0: */ sl@0: enum TMode sl@0: { sl@0: EOpenToRead, sl@0: EOpenToWrite, sl@0: EOpenToWriteNamedPipeButFailOnNoReaders sl@0: }; sl@0: sl@0: enum TChannelType sl@0: { sl@0: EChannelUnset = 0x0, sl@0: EReadChannel = 0x1, sl@0: EWriteChannel = 0x2 sl@0: }; sl@0: sl@0: class TPipeInfo sl@0: { sl@0: public: sl@0: TInt isize; sl@0: TBuf8 iName; sl@0: sl@0: }; sl@0: typedef TPckgBuf TPipeInfoBuf; sl@0: sl@0: sl@0: public: sl@0: sl@0: /** sl@0: Returns the version information of the DPipe Factory object sl@0: */ sl@0: inline static TVersion VersionRequired(); sl@0: sl@0: /** sl@0: Returns the name of the DPipe factory object sl@0: */ sl@0: inline static const TDesC& Name(); sl@0: sl@0: sl@0: /** sl@0: Support for un-named pipe sl@0: */ sl@0: IMPORT_C static TInt Create( TInt aSize, RPipe& aReader, RPipe& aWriter, TOwnerType aTypeR = EOwnerProcess, TOwnerType aTypeW = EOwnerProcess); sl@0: sl@0: TInt Create(const TInt sSize, TOwnerType aType = EOwnerProcess); sl@0: sl@0: TInt Open(const RPipe& aWriter, TOwnerType aType = EOwnerProcess); sl@0: sl@0: sl@0: /** sl@0: Support for named pipe sl@0: */ sl@0: sl@0: IMPORT_C static TInt Define( const TDesC& aName, TInt aSize); sl@0: sl@0: IMPORT_C static TInt Define( const TDesC& aName, TInt aSize, const TSecurityPolicy& aPolicy); sl@0: sl@0: sl@0: IMPORT_C static TInt Destroy(const TDesC& aName); sl@0: sl@0: IMPORT_C TInt Open(const TDesC& aName, TMode aMode); sl@0: sl@0: IMPORT_C TInt Open(TInt aArgumentIndex, TOwnerType aType=EOwnerProcess); sl@0: sl@0: IMPORT_C TInt Open(RMessagePtr2 aMessage, TInt aParam, TOwnerType aType=EOwnerProcess); sl@0: sl@0: IMPORT_C static TInt Init(); sl@0: sl@0: /** sl@0: Non-blocking read/write operations sl@0: */ sl@0: IMPORT_C TInt Read ( TDes8& aData, TInt aSize); sl@0: sl@0: IMPORT_C TInt Write( const TDesC8& aBuf, TInt aSize); sl@0: sl@0: /** sl@0: Blocking read/write operations sl@0: */ sl@0: IMPORT_C TInt ReadBlocking(TDes8& aData, TInt aSize); sl@0: sl@0: IMPORT_C TInt WriteBlocking (const TDesC8& aBuf, TInt aSize); sl@0: sl@0: IMPORT_C TInt Size(); sl@0: sl@0: IMPORT_C void NotifySpaceAvailable( TInt aSize, TRequestStatus&); sl@0: sl@0: IMPORT_C void NotifyDataAvailable( TRequestStatus&); sl@0: sl@0: IMPORT_C void Wait(const TDesC& aName, TRequestStatus& aStatus); sl@0: sl@0: IMPORT_C TInt MaxSize(); sl@0: sl@0: sl@0: IMPORT_C TInt CancelSpaceAvailable(); sl@0: sl@0: IMPORT_C TInt CancelDataAvailable(); sl@0: sl@0: IMPORT_C void CancelWait(); sl@0: sl@0: IMPORT_C void Flush(); sl@0: sl@0: IMPORT_C void Close(); sl@0: sl@0: IMPORT_C TInt HandleType()const; sl@0: sl@0: TInt PipeHandle()const; sl@0: sl@0: IMPORT_C void WaitForReader(const TDesC& aName, TRequestStatus& aStatus); sl@0: sl@0: IMPORT_C void WaitForWriter(const TDesC& aName, TRequestStatus& aStatus); sl@0: sl@0: /* sl@0: Enumeration of Request messages. sl@0: */ sl@0: enum TRequest sl@0: { sl@0: EDefineNamedPipe, sl@0: EOpenToReadNamedPipe, sl@0: EOpenToWriteNamedPipe, sl@0: EOpenToWriteButFailOnNoReaderNamedPipe, sl@0: EDestroyNamedPipe, sl@0: ECreateUnNamedPipe, sl@0: EOpenUnNamedPipe, sl@0: ERead, sl@0: EWrite, sl@0: ESize, sl@0: EReadBlocking, sl@0: EWriteBlocking, sl@0: EDataAvailable, sl@0: EDataAvailableCount, sl@0: ESpaceAvailable, sl@0: EWaitNotification, sl@0: EWaitNotificationCheck, sl@0: ECancelSpaceAvailable, sl@0: ECancelDataAvailable, sl@0: ECancelWaitNotification, sl@0: EFlushPipe, sl@0: EClosePipe, sl@0: EGetPipeInfo sl@0: }; sl@0: /* sl@0: Enumeration of Wait Request. sl@0: */ sl@0: enum TWaitRequest sl@0: { sl@0: EWaitForReader, sl@0: EWaitForWriter sl@0: }; sl@0: sl@0: private: sl@0: sl@0: void Wait(const TDesC& aName, TRequestStatus& aStatus, TInt aChoice); sl@0: sl@0: void ReqComplete(TRequestStatus& aState, TInt aval); sl@0: TInt iHandleType; sl@0: TInt iSize; sl@0: TInt iPipeHandle; sl@0: }; sl@0: sl@0: sl@0: sl@0: inline TVersion RPipe::VersionRequired() sl@0: { sl@0: // Just a number sl@0: const TInt KMajorVersionNumber=1; sl@0: const TInt KMinorVersionNumber=0; sl@0: const TInt KBuildVersionNumber=1; sl@0: return sl@0: TVersion (KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber); sl@0: } sl@0: sl@0: inline const TDesC& RPipe::Name() sl@0: { sl@0: _LIT(KRpipeDevice, "SymbianPipe"); sl@0: return KRpipeDevice; sl@0: } sl@0: sl@0: sl@0: #endif // __RPIPE_H__