remotemgmt_plat/fota_engine_api/inc/FotaEngStream.h
branchRCL_3
changeset 25 b183ec05bd8c
parent 24 13d7c31c74e0
child 26 19bba8228ff0
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
     1 /*
       
     2 * Copyright (c) 2005-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:  Stream to memorybased chunk
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __FOTAENGSTREAM_H__
       
    21 #define __FOTAENGSTREAM_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <s32strm.h>
       
    25 #include <s32buf.h>
       
    26 #include <e32svr.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class RFotaEngineSession;
       
    30 class RFotaWriteStream;
       
    31 
       
    32 
       
    33 const TInt  KDefaultWriteLimit( 5000000 );
       
    34 
       
    35 // CLASS DECLARATION
       
    36 /**
       
    37 * Memory buffer
       
    38 *
       
    39 * Saves streams data to chunk.
       
    40 *
       
    41 * @lib    fotaengine.lib
       
    42 * @since  Series 60 v3.1
       
    43 */
       
    44 class TDP2StreamBuf : public TStreamBuf
       
    45 {
       
    46     friend class RFotaWriteStream;
       
    47 
       
    48 public: 
       
    49 
       
    50     TDP2StreamBuf ();
       
    51 
       
    52     /** Resets write area
       
    53     *
       
    54     * @param    None
       
    55     * @return   None
       
    56     */
       
    57     void            ResetL();
       
    58 
       
    59 private:
       
    60 
       
    61     /** Handles overflow of write area
       
    62     *
       
    63     * @param    None
       
    64     * @return   None
       
    65     */
       
    66     virtual void    OverflowL();
       
    67 
       
    68 	
       
    69     /** Handles underflow of write area
       
    70     *
       
    71     * @param    aMaxLength
       
    72     * @return   Error code
       
    73     */
       
    74     virtual TInt    UnderflowL(TInt aMaxLength);
       
    75 
       
    76     
       
    77     /** Handles releasing of stream/buffer
       
    78     *
       
    79     * @param    None
       
    80     * @return   None
       
    81     */
       
    82     virtual void    DoRelease();
       
    83 
       
    84 
       
    85     /**
       
    86     * Bytes written to stream
       
    87     */
       
    88     TInt            iBytesWritten;
       
    89 
       
    90 
       
    91     /**
       
    92     * Chunks sent to server
       
    93     */
       
    94     TInt            iSentChunks;
       
    95     
       
    96 
       
    97     /**
       
    98     * Reference to parent stream
       
    99     */
       
   100     RFotaWriteStream* iMyWriteStream;
       
   101 
       
   102 };
       
   103 
       
   104 
       
   105 /**
       
   106  *  RFotaWriteStream saves swupd to memory chunk
       
   107  *
       
   108  *  Saves written content via TDP2StreamBuf to 
       
   109  *  the chunk.
       
   110  *
       
   111  *  @lib fotaengine.lib
       
   112  *  @since S60 3.1
       
   113  */
       
   114 class RFotaWriteStream : public RWriteStream
       
   115     {
       
   116     friend class RFotaEngineSession;
       
   117 
       
   118     friend class TDP2StreamBuf;
       
   119 
       
   120 public:
       
   121 
       
   122     RFotaWriteStream ();
       
   123 
       
   124     /** Opens stream
       
   125     *
       
   126     * @param    aPkgId  package id
       
   127     * @return   Error code
       
   128     */
       
   129     TInt OpenL (const TInt aPkgId);
       
   130 
       
   131 private:
       
   132 
       
   133     /**
       
   134      * Memory buffer
       
   135      */
       
   136     TDP2StreamBuf            iBuf;
       
   137 
       
   138     /**
       
   139      * Reference to parent session
       
   140      */
       
   141     RFotaEngineSession*     iFotaEngineSession;
       
   142 
       
   143     /**
       
   144      * Max package size. If exceeded, must throw error in this class.
       
   145      */
       
   146     TInt  iWriteLimit;
       
   147     };
       
   148 
       
   149 
       
   150 #endif // __FOTAENGSTREAM_H__