mmfenh/enhancedmediaclient/Plugins/ProgDLSource/src/MmffilePriv.h
changeset 16 43d09473c595
parent 14 80975da52420
child 22 128eb6a32b84
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
     1 /*
       
     2 * Copyright (c) 2006 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:  Header of TransferBuffer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __MMFFILEPRIV_H_
       
    20 #define __MMFFILEPRIV_H_
       
    21 
       
    22 #include <f32file.h>
       
    23 
       
    24 #include <mmf/server/mmfclip.h>
       
    25 #include <mmf/server/mmfdatabuffer.h>
       
    26 
       
    27 /**
       
    28 *  @publishedAll
       
    29 *
       
    30 *  Represents a copy of a KUidMmfTransferBuffer used for reading/writting to the file server
       
    31 */
       
    32 
       
    33 class CTransferBufferCopy : public CBase
       
    34     {
       
    35     public:
       
    36         static CTransferBufferCopy* NewL(TInt aMaxLength);
       
    37         
       
    38         virtual ~CTransferBufferCopy()
       
    39             {delete iBuffer;}
       
    40         
       
    41         
       
    42         TDes8& Des() {return iBufferDes;}
       
    43         
       
    44         TInt MaxLength() {return iBufferDes.MaxLength();}
       
    45         
       
    46         void ReUse(TInt aMaxLength) {iBufferDes.Set(iBuffer,0, Min(aMaxLength, iMaxLength));}
       
    47         
       
    48         TBool InUse() {return iInUse;}
       
    49         
       
    50         void SetInUse(TBool aInUse) {iInUse=aInUse;}
       
    51         
       
    52     private:
       
    53         CTransferBufferCopy(TInt aMaxLength) : CBase(), iMaxLength(aMaxLength), iBufferDes(0,0,0), iInUse(EFalse){}
       
    54         
       
    55         void ConstructL();
       
    56         
       
    57     private:
       
    58         TUint8*	iBuffer;
       
    59         
       
    60         //Holds the original MaxLength when class constructed. 
       
    61         //May be larger than MaxLength of iBufferDes
       
    62         TInt	iMaxLength;
       
    63         
       
    64         TPtr8	iBufferDes;
       
    65         
       
    66         TBool	iInUse;
       
    67     };
       
    68 
       
    69 
       
    70 
       
    71 
       
    72     /**
       
    73     * @internalComponent
       
    74     *
       
    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.
       
    77     *
       
    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()
       
    80 */
       
    81 class CReadWriteRequest : public CActive
       
    82     {
       
    83     public:
       
    84         CReadWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer,TBool aSourceType)
       
    85             : CActive(EPriorityStandard),
       
    86             iSinkOrSource(aSinkOrSource), 
       
    87             iBuffer(aBuffer),
       
    88             iSourceType(aSourceType)
       
    89             {
       
    90             CActiveScheduler::Add( this );
       
    91             }
       
    92         
       
    93         CReadWriteRequest(TAny* aSinkOrSource, CMMFBuffer* aBuffer, CTransferBufferCopy* aOptionalDataBuffer,TBool aSourceType)
       
    94             : CActive(EPriorityStandard),
       
    95             iSinkOrSource(aSinkOrSource), 
       
    96             iBuffer(aBuffer),
       
    97             iSourceType(aSourceType),
       
    98             iTransferBufferCopy(aOptionalDataBuffer)
       
    99             {
       
   100             CActiveScheduler::Add( this );
       
   101             iTransferBufferCopy->SetInUse(ETrue);
       
   102             }
       
   103         
       
   104         CReadWriteRequest(CReadWriteRequest& aRequest)
       
   105             : CActive(EPriorityStandard),
       
   106             iSinkOrSource(aRequest.iSinkOrSource),
       
   107             iBuffer(aRequest.iBuffer),
       
   108             iSourceType(aRequest.iSourceType),
       
   109             iTransferBufferCopy(aRequest.iTransferBufferCopy)
       
   110             {
       
   111             CActiveScheduler::Add( this );
       
   112             iTransferBufferCopy->SetInUse(ETrue);
       
   113             }
       
   114         
       
   115         
       
   116         TBool Completed() ;
       
   117         TInt SetStatus(TBool aStatus);
       
   118         TDes8& BufferDes() ;
       
   119         TBool SourceType();
       
   120         const TDesC8& BufferDesC() ;
       
   121         CMMFBuffer* Buffer();
       
   122         TAny* GetSinkOrSource();
       
   123         ~CReadWriteRequest() ;
       
   124         
       
   125         
       
   126         // CActive functions.
       
   127         // 
       
   128         void SetActive() ;
       
   129         void DoCancel() ;
       
   130         virtual void RunL() = 0 ;
       
   131         virtual TInt RunError( TInt aError ) ;
       
   132         
       
   133         
       
   134     protected :
       
   135         TAny* iSinkOrSource;
       
   136         CMMFBuffer* iBuffer;
       
   137         TBool iSourceType;
       
   138         CTransferBufferCopy* iTransferBufferCopy;
       
   139         
       
   140         TBool iCompleted ;
       
   141         TDes8* iBufferDes ;
       
   142         TInt iError ;
       
   143         TBool iUseTransferBuffer ;
       
   144         void SetTransferBuffer (TBool aTBuffer) ;
       
   145         TBool CanUseTransferBuffer () ;
       
   146     } ;
       
   147 
       
   148     /**
       
   149     * @internalComponent
       
   150 */
       
   151 class CReadRequest : public CReadWriteRequest
       
   152     {
       
   153     public :
       
   154         CReadRequest(TAny* aParent,TAny* aSinkOrSource, CMMFBuffer* aBuffer, TUint aPosition, TUint aFileSize,TBool aSourceType)
       
   155             : CReadWriteRequest(aSinkOrSource, aBuffer,aSourceType),
       
   156             iPosition(aPosition), iFileSize(aFileSize),iParent(aParent)
       
   157             { } 
       
   158         
       
   159         CReadRequest(TAny* aParent,TAny* aSinkOrSource, CMMFBuffer* aBuffer, CTransferBufferCopy* aOptionalDataBuffer, TUint aPosition, TUint aFileSize,TBool aSourceType)
       
   160             : CReadWriteRequest(aSinkOrSource, aBuffer, aOptionalDataBuffer,aSourceType),
       
   161             iPosition(aPosition), iFileSize(aFileSize),iParent(aParent)
       
   162             { } 
       
   163         
       
   164         void RunL();
       
   165     private:
       
   166         TUint iPosition;
       
   167         TUint iFileSize;
       
   168         TAny* iParent;
       
   169     };
       
   170 
       
   171 #endif
       
   172