netprotocols_plat/http_cache_mgr_api/inc/httpcachemanager.h
changeset 0 b16258d2340f
child 19 c0c2f28ace9c
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     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:   Definition of CHttpCacheManager
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CHTTPCACHEMANAGER_H
       
    19 #define CHTTPCACHEMANAGER_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <e32base.h>
       
    23 #include <cenrepnotifyhandler.h>
       
    24 #include <brctldefs.h>
       
    25 #include <http/rhttpsession.h>
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // MACROS
       
    30 
       
    31 // DATA TYPES
       
    32 
       
    33 // FUNCTION PROTOTYPES
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CHttpCacheEntry;
       
    37 class CHttpCacheHandler;
       
    38 class CCenRepNotifyHandler;
       
    39 class CRepository;
       
    40 class RHTTPTransaction;
       
    41 class MHTTPDataSupplier;
       
    42 class CHttpCacheFileWriteHandler;
       
    43 class CHttpCacheFileHash;
       
    44 class THttpCachePostponeParameters;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 *
       
    50 *  @lib
       
    51 *  @since 3.1
       
    52 */
       
    53 class THttpCacheEntry
       
    54     {
       
    55     public:
       
    56 
       
    57         //
       
    58         CHttpCacheHandler*  iCacheHandler;
       
    59 
       
    60         //
       
    61         CHttpCacheEntry*    iCacheEntry;
       
    62     };
       
    63 
       
    64 /**
       
    65 *
       
    66 *  @lib
       
    67 *  @since 3.1
       
    68 */
       
    69 class CHttpCacheManager : public CBase, public MCenRepNotifyHandlerCallback
       
    70     {
       
    71     public:  // Constructors and destructor
       
    72 
       
    73         /**
       
    74         * Two-phased constructor.
       
    75         * @since 3.1
       
    76         * @param
       
    77         * @param
       
    78         * @return CacheHandler object.
       
    79         */
       
    80         IMPORT_C static CHttpCacheManager* NewL();
       
    81 
       
    82         /**
       
    83         * Destructor.
       
    84         */
       
    85         virtual ~CHttpCacheManager();
       
    86 
       
    87     public: // new functions
       
    88 
       
    89         /**
       
    90         *
       
    91         * @since 3.1
       
    92         * @param
       
    93         * @return
       
    94         */
       
    95         IMPORT_C TInt RequestL( RHTTPTransaction& aTrans, TBrCtlDefs::TBrCtlCacheMode aCacheMode,
       
    96             THttpCacheEntry& aCacheEntry );
       
    97 
       
    98         /**
       
    99         *
       
   100         * @since 3.1
       
   101         * @param
       
   102         * @return
       
   103         */
       
   104         IMPORT_C TInt RequestHeadersL( RHTTPTransaction& aTrans, THttpCacheEntry& aCacheEntry );
       
   105 
       
   106         /**
       
   107         *
       
   108         * @since 3.1
       
   109         * @param
       
   110         * @return
       
   111         */
       
   112         IMPORT_C HBufC8* RequestNextChunkL( RHTTPTransaction& aTrans, TBool& aLastChunk, THttpCacheEntry& aCacheEntry );
       
   113 
       
   114         /**
       
   115         *
       
   116         * @since 3.1
       
   117         * @param
       
   118         * @return
       
   119         */
       
   120         IMPORT_C void ReceivedResponseHeadersL( RHTTPTransaction& aTrans, THttpCacheEntry& aCacheEntry );
       
   121 
       
   122         /**
       
   123         *
       
   124         * @since 3.1
       
   125         * @param
       
   126         * @return
       
   127         */
       
   128     IMPORT_C void ReceivedResponseBodyDataL( RHTTPTransaction& aTrans, MHTTPDataSupplier& aBodyDataSupplier, THttpCacheEntry& aCacheEntry );
       
   129 
       
   130         /**
       
   131         *
       
   132         * @since 3.1
       
   133         * @param
       
   134         * @return
       
   135         */
       
   136     IMPORT_C void ResponseComplete( RHTTPTransaction& aTrans, THttpCacheEntry& aCacheEntry );
       
   137 
       
   138         /**
       
   139         *
       
   140         * @since 3.1
       
   141         * @param
       
   142         * @return
       
   143         */
       
   144     IMPORT_C void RequestClosed( RHTTPTransaction* aTrans, THttpCacheEntry& aCacheEntry );
       
   145 
       
   146         /**
       
   147         *
       
   148         * @since 3.1
       
   149         * @param
       
   150         * @return
       
   151         */
       
   152         IMPORT_C TInt RemoveAllL();
       
   153 
       
   154         /**
       
   155         *
       
   156         * @since 3.1
       
   157         * @param
       
   158         * @return
       
   159         */
       
   160         IMPORT_C TInt RemoveL( const TDesC8& aUrl );
       
   161 
       
   162         /**
       
   163         *
       
   164         * @since 3.1
       
   165         * @param
       
   166         * @return
       
   167         */
       
   168         IMPORT_C TBool Find( const TDesC8& aUrl );
       
   169 
       
   170         /**
       
   171         *
       
   172         * @since 3.1
       
   173         * @param
       
   174         * @return
       
   175         */
       
   176         IMPORT_C TBool SaveL( const TDesC8& aUrl, const TDesC8& aHeader,
       
   177                      const TDesC8& aContent, const TDesC8&  aHttpHeaderString );
       
   178 
       
   179         /**
       
   180         *
       
   181         * @since 3.1
       
   182         * @param
       
   183         * @return
       
   184         */
       
   185         IMPORT_C TInt AddHeaderL( const TDesC8& aUrl, const TDesC8& aName, const TDesC8& aValue );
       
   186 
       
   187     public: // from MCenRepNotifyHandlerCallback
       
   188 
       
   189         /**
       
   190         *
       
   191         * @since 3.1
       
   192         * @param
       
   193         * @return
       
   194         */
       
   195         void HandleNotifyString( const TUint32 aKeyId, const TDesC& aValue );
       
   196 
       
   197     private:
       
   198 
       
   199         /**
       
   200         * Construct.
       
   201         * @since 3.1
       
   202         * @param
       
   203         * @param
       
   204         * @return CacheHandler object.
       
   205         */
       
   206         CHttpCacheManager();
       
   207 
       
   208         /**
       
   209         * By default Symbian 2nd phase constructor is private.
       
   210         */
       
   211         void ConstructL();
       
   212 
       
   213     private:
       
   214 
       
   215         /**
       
   216         *
       
   217         * @since 3.1
       
   218         * @param
       
   219         * @return
       
   220         */
       
   221         void CreateCacheHandlersL();
       
   222 
       
   223         /**
       
   224         *
       
   225         * @since 7.1
       
   226         * @param
       
   227         * @return
       
   228         */
       
   229         void RemoveOrphanedFilesL();    // remove all orphan files.
       
   230         /**
       
   231         *
       
   232         * @since 7.1
       
   233         * @param
       
   234         * @return
       
   235         */
       
   236         // perform phase 2 of orphan file removal. Mark any files 
       
   237         void MarkAllCacheContentAsNoDelete( CHttpCacheFileHash* aOnDiskFilesMap );
       
   238         /**
       
   239         *
       
   240         * @since 7.1
       
   241         * @param
       
   242         * @return
       
   243         */
       
   244         // perform phase 3 of orphan file removal.
       
   245         // Write an 'empty cache' index file over the top of any unknown index files to let any running clients
       
   246         // prepare for their data to disappear.
       
   247         void WipeAllOtherIndexFilesL( CHttpCacheFileHash* aOnDiskFilesMap, RFs& aRfs );
       
   248         /**
       
   249         *
       
   250         * @since 7.1
       
   251         * @param
       
   252         * @return
       
   253         */
       
   254         // perform phase 4 of orphan file removal. Remove any files not referenced in the loaded caches.
       
   255         void DeleteMarkedFilesL( CHttpCacheFileHash* aOnDiskFilesMap, RFs& aRfs );
       
   256         /**
       
   257         *
       
   258         * @since 7.1
       
   259         * @param
       
   260         * @return
       
   261         */
       
   262         // utility fn for phase 3 of orphan file removal.
       
   263         void GenerateEmptyIndexFileL(const TDesC& aIndexFile, RFs& aRfs );
       
   264 
       
   265         /**
       
   266          * @since 7.1
       
   267          * override cache parameters according to application using DLL and any config in Centrep
       
   268          */
       
   269         void ApplyCacheOverridesL(CRepository& aRepository, const TUint32& aSecIdInt, TBool& aCacheEnabled, TInt& aCacheSize, TBool& aOpCacheEnabled, TBool& aVssCacheEnabled, TDes& aPath, const TDesC& aDefaultDrive);
       
   270 
       
   271         /**
       
   272         *
       
   273         * @since 3.1
       
   274         * @param
       
   275         * @return
       
   276         */
       
   277         CHttpCacheHandler* CacheHandler( const TDesC8& aUrl,  TDes8* aHttpHeaderString ) const;
       
   278 
       
   279 
       
   280     /**
       
   281         *
       
   282         * @since 3.1
       
   283         * @param
       
   284         * @return
       
   285         */
       
   286         TBool VSSRequestCheckL( const RHTTPTransaction& aTrans,
       
   287                                 const RHTTPHeaders& aHttpHeader, const TDesC8& aUrl );
       
   288     /**
       
   289         *
       
   290         * @since 3.1
       
   291         * @param
       
   292         * @return
       
   293         */
       
   294 
       
   295         TBool VSSHeaderCheck(  TDes8*  aHttpHeaderString ) const ;
       
   296 
       
   297         /**
       
   298          * @since 7.1
       
   299          * 
       
   300          */
       
   301         void GetPostponeParamsL( TBool& aNewCentrepPresent, THttpCachePostponeParameters& aParams, CRepository* aRepo );
       
   302 
       
   303         /**
       
   304          * @since 7.1
       
   305          * 
       
   306          */
       
   307         void GetHttpCacheConfigL( CRepository& aRepository, TBool& aCacheEnabled, TInt& aCacheSize, TDes& aCacheFolder );
       
   308 
       
   309         /**
       
   310          * @since 7.1
       
   311          * 
       
   312          */
       
   313         void GetOperatorCacheConfigL( CRepository& aRepository, TBool& aOpCacheEnabled, TInt& aOpCacheSize, TDes& aOpCacheFolder );
       
   314 
       
   315         /**
       
   316          * @since 7.1
       
   317          * 
       
   318          */
       
   319         void GetVSSCacheConfigL( CRepository& aRepository, TBool& aVSSCacheEnabled, TInt& aVssCacheSize, TDes& aVssCacheFolder );
       
   320         
       
   321         /**
       
   322          * @since 7.1
       
   323          * 
       
   324          */
       
   325         void GetCriticalDriveLevelsL( CRepository& aRepository, const TDesC& aCacheFolder, TInt& aCriticalLevel );
       
   326 
       
   327         /**
       
   328          * @since 7.1
       
   329          * 
       
   330          */
       
   331         void CreateHttpCacheL( const TInt& aSecIdInt, const TInt& aCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone );
       
   332 
       
   333         /**
       
   334          * @since 7.1
       
   335          * 
       
   336          */
       
   337         void CreateOperatorCacheL( CRepository& aRepository, const TDesC& aOpCacheFolder, const TInt& aOpCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone );
       
   338 
       
   339         /**
       
   340          * @since 7.1
       
   341          * 
       
   342          */
       
   343         void CreateVssCacheL( CRepository& aRepository, const TDesC& aVssCacheFolder, const TInt& aVssCacheSize, const TInt& aCriticalLevel, const THttpCachePostponeParameters& aPostpone );
       
   344 
       
   345         /**
       
   346          * @since 7.1
       
   347          * 
       
   348          */
       
   349         void CrashCheckL( const TInt& aSecIdInt );
       
   350 
       
   351 
       
   352     private:    // Data
       
   353 
       
   354         CHttpCacheHandler*                         iCache;      // owned
       
   355 
       
   356         TPath                                      iCacheFolder;
       
   357 
       
   358         CHttpCacheHandler*                         iOperatorCache;      // owned
       
   359         //
       
   360         CHttpCacheHandler*                         iphoneSpecificCache;      // owned
       
   361         //
       
   362         CHttpCacheFileWriteHandler*                iFileWriteHandler; // owned
       
   363 
       
   364         HBufC8*                                    iOpDomain;       // owned
       
   365         //
       
   366         CCenRepNotifyHandler*                      iOfflineNotifyHandler; // owned
       
   367         //
       
   368         CRepository*                               iOfflineRepository; // owned
       
   369         //
       
   370         TBool                                      iOfflineMode;
       
   371         //
       
   372         TBool                                      iCacheEnabled;
       
   373         //
       
   374         HBufC8*                                    iVSSWhiteList;       // owned
       
   375         //
       
   376         TBool                                      iVSSCacheEnabled;
       
   377         TBool                                      iVSSTransaction;
       
   378     };
       
   379 
       
   380 #endif      // CHttpCacheManager_H
       
   381 
       
   382 // End of File