Update contrib.
1 // Copyright (c) 2001-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #ifndef __MMFFILEPRIV_H_
18 #define __MMFFILEPRIV_H_
22 #include <mmf/server/mmfclip.h>
23 #include <mmf/server/mmfdatabuffer.h>
30 * Represents a copy of a KUidMmfTransferBuffer used for reading/writting to the file server
33 class CTransferBufferCopy : public CBase
36 static CTransferBufferCopy* NewL(TInt aMaxLength);
38 virtual ~CTransferBufferCopy()
42 TDes8& Des() {return iBufferDes;}
44 TInt MaxLength() {return iBufferDes.MaxLength();}
46 void ReUse(TInt aMaxLength) {iBufferDes.Set(iBuffer,0, Min(aMaxLength, iMaxLength));}
48 TBool InUse() {return iInUse;}
50 void SetInUse(TBool aInUse) {iInUse=aInUse;}
53 CTransferBufferCopy(TInt aMaxLength) : CBase(), iMaxLength(aMaxLength), iBufferDes(0,0,0), iInUse(EFalse){}
60 //Holds the original MaxLength when class constructed.
61 //May be larger than MaxLength of iBufferDes
75 * A request is created when an external object requests or supplies data. Calls to the File Server are
76 * made asynchronously and a CReadWriteRequest created to notify the caller on completion.
78 * CReadWriteRequest is an abstract class. Concrete instances are of CReadRequest & CWriteRequest.
79 * Concrete instances need to know whether to call MDataSink::BufferFilledL() or MDataSource::BufferEmptiedL()
81 class CReadWriteRequest : public CActive
84 CReadWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, MAsyncEventHandler* aEventHandler)
85 : CActive(EPriorityStandard),
86 iSinkOrSource(aSinkOrSource),
88 iEventHandler(aEventHandler)
90 CActiveScheduler::Add( this );
93 CReadWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, CTransferBufferCopy* aOptionalDataBuffer, MAsyncEventHandler* aEventHandler)
94 : CActive(EPriorityStandard),
95 iSinkOrSource(aSinkOrSource),
97 iTransferBufferCopy(aOptionalDataBuffer),
98 iEventHandler(aEventHandler)
100 CActiveScheduler::Add( this );
101 iTransferBufferCopy->SetInUse(ETrue);
104 CReadWriteRequest(CReadWriteRequest& aRequest)
105 : CActive(EPriorityStandard),
106 iSinkOrSource(aRequest.iSinkOrSource),
107 iBuffer(aRequest.iBuffer),
108 iTransferBufferCopy(aRequest.iTransferBufferCopy),
109 iEventHandler(aRequest.iEventHandler)
111 CActiveScheduler::Add( this );
112 iTransferBufferCopy->SetInUse(ETrue);
118 const TDesC8& BufferDesC() ;
120 ~CReadWriteRequest() ;
123 // CActive functions.
127 virtual void RunL() = 0 ;
128 virtual TInt RunError( TInt aError ) ;
134 CTransferBufferCopy* iTransferBufferCopy;
136 MAsyncEventHandler* iEventHandler;
140 TBool iUseTransferBuffer ;
141 void SetTransferBuffer (TBool aTBuffer) ;
142 TBool CanUseTransferBuffer () ;
148 class CReadRequest : public CReadWriteRequest
151 CReadRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, TUint aPosition, TUint aFileSize, MAsyncEventHandler* aEventHandler)
152 : CReadWriteRequest(aSinkOrSource, aBuffer, aEventHandler),
153 iPosition(aPosition), iFileSize(aFileSize)
156 CReadRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, CTransferBufferCopy* aOptionalDataBuffer, TUint aPosition, TUint aFileSize, MAsyncEventHandler* aEventHandler)
157 : CReadWriteRequest(aSinkOrSource, aBuffer, aOptionalDataBuffer, aEventHandler),
158 iPosition(aPosition), iFileSize(aFileSize)
170 class CWriteRequest : public CReadWriteRequest
173 CWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, MAsyncEventHandler* aEventHandler)
174 : CReadWriteRequest(aSinkOrSource, aBuffer, aEventHandler)
177 CWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, CTransferBufferCopy* aOptionalDataBuffer, MAsyncEventHandler* aEventHandler)
178 : CReadWriteRequest(aSinkOrSource, aBuffer, aOptionalDataBuffer, aEventHandler)