filemanager/bkupengine/inc/CMMCScBkupBufferManagers.h
changeset 14 1957042d8c7e
parent 1 d1daf54a55b5
child 16 ada7962b4308
equal deleted inserted replaced
1:d1daf54a55b5 14:1957042d8c7e
     1 /*
       
     2 * Copyright (c) 2005 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: Declaration of CMMCScBkupBufferManagerBase
       
    15 *     
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __CMMCSCBKUPBUFFERMANAGERS_H__
       
    20 #define __CMMCSCBKUPBUFFERMANAGERS_H__
       
    21 
       
    22 // User includes
       
    23 #include <e32std.h>
       
    24 #include <e32cmn.h>
       
    25 #include <f32file.h>
       
    26 #include <ezbufman.h>
       
    27 
       
    28 // User includes
       
    29 #include "TMMCScBkupArchiveVector.h"
       
    30 
       
    31 // Classes referenced
       
    32 class MMMCScBkupArchiveDataInterface;
       
    33 class CMMCScBkupDataStrategy;
       
    34 class MMMCScBkupProgressObserver;
       
    35 
       
    36 // Constants
       
    37 const TInt KScBkupDefaultBufferSize = 0x4000;
       
    38 
       
    39 /**
       
    40 *
       
    41 *
       
    42 * @since 3.0
       
    43 */
       
    44 NONSHARABLE_CLASS(CMMCScBkupBufferManagerBase) : public CBase, public MEZBufferManager 
       
    45     {
       
    46     public: // Enumerations
       
    47 
       
    48         /**
       
    49         *
       
    50         */
       
    51         enum TType
       
    52             {
       
    53             ETypeDescriptorToArchive = 0,
       
    54             ETypeFileToArchive,
       
    55             ETypeArchiveToDescriptor,
       
    56             ETypeArchiveToFile
       
    57             };
       
    58 
       
    59     public: // Construct / destruct
       
    60 
       
    61         /**
       
    62         *
       
    63         */
       
    64         static CMMCScBkupBufferManagerBase* NewByTypeL( TType aType, MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI, TAny* aParam1 = NULL, TAny* aParam2 = NULL );
       
    65 
       
    66         /**
       
    67         *
       
    68         */
       
    69         ~CMMCScBkupBufferManagerBase();
       
    70 
       
    71     protected: // Internal construct
       
    72 
       
    73         /**
       
    74         *
       
    75         */
       
    76         CMMCScBkupBufferManagerBase( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI, TType aType );
       
    77 
       
    78         /**
       
    79         *
       
    80         */
       
    81         virtual void ConstructL( TInt aBufferSize = KScBkupDefaultBufferSize );
       
    82 
       
    83     public: // Framework API
       
    84 
       
    85         /**
       
    86         *
       
    87         */
       
    88         inline TType Type() const { return iType; }
       
    89 
       
    90         /**
       
    91         *
       
    92         */
       
    93         inline const TMMCScBkupArchiveVector& Info() const { return iInfo; }
       
    94 
       
    95         /**
       
    96         *
       
    97         */
       
    98         inline TMMCScBkupArchiveVector& Info() { return iInfo; }
       
    99 
       
   100         /**
       
   101         *
       
   102         */
       
   103         virtual void InitializeL( TAny* aParam1 = NULL, TAny* aParam2 = NULL ) = 0;
       
   104 
       
   105     protected: // Internal methods
       
   106 
       
   107         /**
       
   108         *
       
   109         */
       
   110         inline TPtr8& WriteBuffer() { return iBufferPointer; }
       
   111 
       
   112         /**
       
   113         *
       
   114         */
       
   115         inline const TDesC8& DataView() const { return *iBuffer; }
       
   116 
       
   117         /**
       
   118         *
       
   119         */
       
   120         inline MMMCScBkupProgressObserver& ProgressManager() const { return iProgressManager; }
       
   121 
       
   122         /**
       
   123         *
       
   124         */
       
   125         inline MMMCScBkupArchiveDataInterface& ADI() const { return iADI; }
       
   126 
       
   127         /**
       
   128         *
       
   129         */
       
   130         void WriteToArchiveAndUpdateStatsL( const TDesC8& aData );
       
   131 
       
   132     private:
       
   133 
       
   134         /**
       
   135         *
       
   136         */
       
   137         TType iType;
       
   138 
       
   139         /**
       
   140         *
       
   141         */
       
   142         HBufC8* iBuffer;
       
   143 
       
   144         /**
       
   145         *
       
   146         */
       
   147         TPtr8 iBufferPointer;
       
   148 
       
   149         /**
       
   150         *
       
   151         */
       
   152         MMMCScBkupProgressObserver& iProgressManager;
       
   153 
       
   154         /**
       
   155         *
       
   156         */
       
   157         MMMCScBkupArchiveDataInterface& iADI;
       
   158 
       
   159         /**
       
   160         *
       
   161         */
       
   162         TMMCScBkupArchiveVector iInfo;
       
   163     };
       
   164 
       
   165 
       
   166 
       
   167 /**
       
   168 *
       
   169 *
       
   170 * @since 3.0
       
   171 */
       
   172 NONSHARABLE_CLASS(CMMCScBkupBufferManagerDescriptorToArchive) : public CMMCScBkupBufferManagerBase
       
   173     {
       
   174     private:
       
   175 
       
   176         /**
       
   177         *
       
   178         */
       
   179         CMMCScBkupBufferManagerDescriptorToArchive( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   180 
       
   181         /**
       
   182         *
       
   183         */
       
   184         static CMMCScBkupBufferManagerDescriptorToArchive* NewL( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   185 
       
   186     public: // From CMMCScBkupBufferManagerBase
       
   187         void InitializeL(TAny* aParam1, TAny* aParam2);
       
   188 
       
   189     private: // From MEZBufferManager
       
   190         void InitializeL( CEZZStream& aZStream );
       
   191         void NeedInputL( CEZZStream& aZStream );
       
   192         void NeedOutputL( CEZZStream& aZStream );
       
   193         void FinalizeL( CEZZStream& aZStream );
       
   194 
       
   195     private: // Data members
       
   196 
       
   197         /**
       
   198         *
       
   199         */
       
   200         TPtrC8 iSource;
       
   201 
       
   202         friend class CMMCScBkupBufferManagerBase;
       
   203     };
       
   204 
       
   205 
       
   206 
       
   207 
       
   208 /**
       
   209 *
       
   210 *
       
   211 * @since 3.0
       
   212 */
       
   213 NONSHARABLE_CLASS(CMMCScBkupBufferManagerFileToArchive) : public CMMCScBkupBufferManagerBase 
       
   214     {
       
   215     public:
       
   216 
       
   217         /**
       
   218         *
       
   219         */
       
   220         ~CMMCScBkupBufferManagerFileToArchive();
       
   221 
       
   222     private:
       
   223 
       
   224         /**
       
   225         *
       
   226         */
       
   227         CMMCScBkupBufferManagerFileToArchive( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   228 
       
   229         /**
       
   230         *
       
   231         */
       
   232         void ConstructL(const TDesC& aFileName);
       
   233 
       
   234         /**
       
   235         *
       
   236         */
       
   237         static CMMCScBkupBufferManagerFileToArchive* NewL( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   238 
       
   239     public: // From CMMCScBkupBufferManagerBase
       
   240         void InitializeL(TAny* aParam1, TAny* aParam2);
       
   241 
       
   242     private: // From MEZBufferManager
       
   243         void InitializeL( CEZZStream& aZStream );
       
   244         void NeedInputL( CEZZStream& aZStream );
       
   245         void NeedOutputL( CEZZStream& aZStream );
       
   246         void FinalizeL( CEZZStream& aZStream );
       
   247 
       
   248     private: // Data members
       
   249 
       
   250         /**
       
   251         *
       
   252         */
       
   253         CMMCScBkupDataStrategy* iReadStrategy;
       
   254 
       
   255         /**
       
   256         *
       
   257         */
       
   258         HBufC8* iOutput;
       
   259 
       
   260         /**
       
   261         *
       
   262         */
       
   263         TPtr8 iOutputPointer;
       
   264         
       
   265         /**
       
   266         * Useful for debugging
       
   267         */
       
   268         TPtrC iFileName;
       
   269 
       
   270         friend class CMMCScBkupBufferManagerBase;
       
   271     };
       
   272 
       
   273 
       
   274 
       
   275 
       
   276 
       
   277 
       
   278 /**
       
   279 *
       
   280 *
       
   281 * @since 3.0
       
   282 */
       
   283 NONSHARABLE_CLASS(CMMCScBkupBufferManagerArchiveToDescriptor) : public CMMCScBkupBufferManagerBase
       
   284     {
       
   285     public:
       
   286 
       
   287         /**
       
   288         *
       
   289         */
       
   290         ~CMMCScBkupBufferManagerArchiveToDescriptor();
       
   291 
       
   292     private:
       
   293 
       
   294         /**
       
   295         *
       
   296         */
       
   297         CMMCScBkupBufferManagerArchiveToDescriptor( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   298 
       
   299         /**
       
   300         *
       
   301         */
       
   302         static CMMCScBkupBufferManagerArchiveToDescriptor* NewL( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   303 
       
   304     public: // From CMMCScBkupBufferManagerBase
       
   305         void InitializeL(TAny* aParam1, TAny* aParam2);
       
   306 
       
   307     private: // From MEZBufferManager
       
   308         void InitializeL( CEZZStream& aZStream );
       
   309         void NeedInputL( CEZZStream& aZStream );
       
   310         void NeedOutputL( CEZZStream& aZStream );
       
   311         void FinalizeL( CEZZStream& aZStream );
       
   312 
       
   313     private: // Internal methods
       
   314         
       
   315         /**
       
   316         *
       
   317         */
       
   318         void TryToReadMoreSourceDataL();
       
   319 
       
   320     private: // Data members
       
   321 
       
   322         /**
       
   323         *
       
   324         */
       
   325         TPtr8 iOutputPointer;
       
   326 
       
   327         friend class CMMCScBkupBufferManagerBase;
       
   328     };
       
   329 
       
   330 
       
   331 
       
   332 
       
   333 
       
   334 
       
   335 
       
   336 
       
   337 
       
   338 /**
       
   339 *
       
   340 *
       
   341 * @since 3.0
       
   342 */
       
   343 NONSHARABLE_CLASS(CMMCScBkupBufferManagerArchiveToFile) : public CMMCScBkupBufferManagerBase 
       
   344     {
       
   345     public:
       
   346 
       
   347         /**
       
   348         *
       
   349         */
       
   350         ~CMMCScBkupBufferManagerArchiveToFile();
       
   351 
       
   352     private:
       
   353 
       
   354         /**
       
   355         *
       
   356         */
       
   357         CMMCScBkupBufferManagerArchiveToFile( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   358 
       
   359         /**
       
   360         *
       
   361         */
       
   362         void ConstructL(const TDesC& aFileName);
       
   363 
       
   364         /**
       
   365         *
       
   366         */
       
   367         static CMMCScBkupBufferManagerArchiveToFile* NewL( MMMCScBkupProgressObserver& aProgressManager, MMMCScBkupArchiveDataInterface& aADI );
       
   368 
       
   369     public: // From CMMCScBkupBufferManagerBase
       
   370         void InitializeL(TAny* aParam1, TAny* aParam2);
       
   371 
       
   372     private: // From MEZBufferManager
       
   373         void InitializeL( CEZZStream& aZStream );
       
   374         void NeedInputL( CEZZStream& aZStream );
       
   375         void NeedOutputL( CEZZStream& aZStream );
       
   376         void FinalizeL( CEZZStream& aZStream );
       
   377 
       
   378     private: // Internal methods
       
   379         
       
   380         /**
       
   381         *
       
   382         */
       
   383         void TryToReadMoreSourceDataL();
       
   384 
       
   385     private: // Data members
       
   386 
       
   387         /**
       
   388         *
       
   389         */
       
   390         CMMCScBkupDataStrategy* iWriteStrategy;
       
   391 
       
   392         /**
       
   393         *
       
   394         */
       
   395         HBufC8* iOutput;
       
   396 
       
   397         /**
       
   398         *
       
   399         */
       
   400         TPtr8 iOutputPointer;
       
   401         
       
   402         /**
       
   403         * Needed, since we restore to temporary file
       
   404         * and then delete and rename temp file if
       
   405         * extraction succeeds.
       
   406         */
       
   407         TPtrC iFileName;
       
   408 
       
   409         friend class CMMCScBkupBufferManagerBase;
       
   410     };
       
   411 
       
   412 
       
   413 
       
   414 
       
   415 
       
   416 
       
   417 
       
   418 
       
   419 
       
   420 
       
   421 
       
   422 
       
   423 
       
   424 
       
   425 
       
   426 #endif // __CMMCSCBKUPBUFFERMANAGERS_H__
       
   427 
       
   428 //End of File