browserutilities/favouritesengine/ClientServer/inc/FavouritesBuf.h
changeset 0 dd21522fd290
child 36 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2004 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 the License "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 *      Declaration of class RFavouritesBuf.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef FAVOURITES_BUF_H
       
    22 #define FAVOURITES_BUF_H
       
    23 
       
    24 //  INCLUDES
       
    25 
       
    26 #include <e32base.h>
       
    27 #include <s32buf.h>
       
    28 #include <FavouritesHandle.h>
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 /// Stream buffer size.
       
    33 LOCAL_D const TInt KFavouritesStreamBufSize = 512;
       
    34 
       
    35 // FORWARD DECLARATION
       
    36 
       
    37 class RFavouritesSession;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42 * Client side stream buffer data container.
       
    43 */
       
    44 NONSHARABLE_CLASS(TFavouritesBuf)
       
    45     {
       
    46 
       
    47     public:     // Data
       
    48 
       
    49         TInt iLen;                              ///< Data length.
       
    50         TUint8 iData[KFavouritesStreamBufSize]; ///< Data buffer.
       
    51 
       
    52     };
       
    53 
       
    54 /**
       
    55 * Client side stream buffer. Not seekable.
       
    56 */
       
    57 NONSHARABLE_CLASS(RFavouritesBuf): public RFavouritesHandle, public TStreamBuf
       
    58     {
       
    59 
       
    60     public:     // Constructors and destructor
       
    61 
       
    62         /**
       
    63         * Open the object (initially empty).
       
    64         * @param aSess Session to be used.
       
    65         * @return Error code.
       
    66         */
       
    67         TInt Open( RFavouritesSession& aSess );
       
    68 
       
    69         /**
       
    70         * Open this object using other object.
       
    71         * @param aHandle Handle used to open this object.
       
    72         * @param aFunction Function.
       
    73         * @param aArgs Arguments. Arg 3 used here.
       
    74         * @return Error code.
       
    75         */
       
    76         TInt Open
       
    77             ( RFavouritesHandle& aHandle, TInt aFunction, TIpcArgs& aArgs );
       
    78 
       
    79         /**
       
    80         * Close the object.
       
    81         */
       
    82         void Close();
       
    83 
       
    84     private:    // from TStreamBuf
       
    85 
       
    86         /**
       
    87         * Re-fill the intermediate buffer and reset the start and end points
       
    88         * of the read area.
       
    89         * @param aMaxLength The maximum amount of data required.
       
    90         * @return The amount of data available.
       
    91         */
       
    92         TInt UnderflowL( TInt aMaxLength );
       
    93 
       
    94         /**
       
    95         * Empty the intermediate buffer and resets the start and end points
       
    96         * of the write area.
       
    97         */
       
    98         void OverflowL();
       
    99 
       
   100         /**
       
   101         * Synchronise the stream buffer with the stream. In effect, this
       
   102         * ensures that buffered data is delivered to the stream.
       
   103         * Write lag flushed.
       
   104         * Read lag leaves with KErrNotSupported.
       
   105         */
       
   106         void DoSynchL();
       
   107 
       
   108     private:    // New methods
       
   109 
       
   110         /**
       
   111         * Read data from server.
       
   112         * @return The number of bytes read.
       
   113         */
       
   114         TInt IpcReadL();
       
   115 
       
   116         /**
       
   117         * Write data to server.
       
   118         */
       
   119         void IpcWriteL();
       
   120 
       
   121         /**
       
   122         * Get read lag (number of bytes transferred from server side but not
       
   123         * yet read).
       
   124         * @return Read lag.
       
   125         */
       
   126         inline TInt Lag( TRead aArea ) const;
       
   127 
       
   128         /**
       
   129         * Get write lag (number of bytes written but not yet transferred to
       
   130         * server side).
       
   131         * @return Write lag.
       
   132         */
       
   133         inline TInt Lag( TWrite aArea ) const;
       
   134 
       
   135     private:    // Data
       
   136 
       
   137        TFavouritesBuf iBuf; ///< Data buffer.
       
   138     };
       
   139 
       
   140 #include "FavouritesBuf.inl"
       
   141 
       
   142 #endif
       
   143             
       
   144 // End of File