webservices/wsstar/wsstarplugin/inc/wsstardictionary.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2006-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 declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 #ifndef WSSTAR_DICTIONARY_H
       
    29 #define WSSTAR_DICTIONARY_H
       
    30 
       
    31 // INCLUDES
       
    32 #include <e32std.h>
       
    33 #include <flogger.h>
       
    34 #include "sensessionhandler.h"
       
    35 #include "wsstarservicesession.h"
       
    36 
       
    37 #include "seninternalserviceconsumer.h"
       
    38 #include "SenXmlElement.h"
       
    39 #include "sentransportbase.h"
       
    40 
       
    41 
       
    42 class CWSStarDictHttpClient;
       
    43 class CZlibDictionary;
       
    44 class CDictXml;
       
    45 
       
    46 #if !defined( EKA2 ) && !defined( RD_SECURE_PRIV_DATA )
       
    47     _LIT(KPrivateFolder,        "C:\\system\\data\\");
       
    48 #endif
       
    49 
       
    50 /**
       
    51  * Class:       
       
    52  *
       
    53  */
       
    54 class CWSStarDictionary : public CBase
       
    55     {
       
    56 
       
    57     public:
       
    58 
       
    59 
       
    60        /**
       
    61         * Function:    NewL
       
    62         *
       
    63         * Description: Create instance of concrete implementation. Note that ECOM
       
    64         * Returns:    Instance of this class.
       
    65         */
       
    66         static CWSStarDictionary* NewL(CSIF& aSIF, RFileLogger& aLogger);
       
    67 
       
    68         /**
       
    69         */
       
    70         TInt InvokeL(MSenHandlerContext* iHndlrCtx, CSenWSDescription* aSD);
       
    71         TInt LoadDictionariesL();
       
    72 //        TInt LoadDictionariesL(CSenElement*  aPolicy);
       
    73   		void DataTrafficDetails( TSenDataTrafficDetails& aDetails); 		      
       
    74         ~CWSStarDictionary();
       
    75         RFileLogger* Log() const;
       
    76             
       
    77     protected:
       
    78         /**
       
    79          * Function:   CWSStarDictionary
       
    80          *
       
    81          * Discussion: Perform the first phase of two phase construction
       
    82          */
       
    83         CWSStarDictionary(CSIF& aSIF, RFileLogger& aLogger);
       
    84         
       
    85         /**
       
    86          * Function:   ConstructL
       
    87          *
       
    88          * Discussion: Perform the second phase construction of a
       
    89          *             CImplementationClassPlus object.
       
    90          */
       
    91         void ConstructL();
       
    92 
       
    93     private:
       
    94         void CreateZlibL(const TDesC8* name, CSenElement* aDict);
       
    95         TInt GetHttpDictionaryL(const TDesC8& aEndpoint, MSenHandlerContext* iHndlrCtx);
       
    96         void SaveFileL(const TDesC8& aUri, const TDesC8& aContents);
       
    97         TInt SaveL(TFileName aFileName, const TDesC8& aContents);
       
    98         TInt LoadDictionariesL(CSenElement*  aPolicy);
       
    99         void LoadFileL(CZlibDictionary* aDict);
       
   100         TInt SaveConfigurationL();
       
   101         TBool IfDictionaryExist(CZlibDictionary* aDict);
       
   102         void CreateMSZlibL(const TDesC8* name, CSenElement* aDict);
       
   103         CZlibDictionary* Dictionary(const TDesC8& aName);
       
   104         
       
   105         TPtrC8 WriteToBufL(CBufBase& aBuf);
       
   106         HBufC8* WriteAllAsXMlL();
       
   107         TInt WriteL(RWriteStream& aWriteStream);
       
   108         
       
   109 
       
   110 
       
   111         RPointerArray<CZlibDictionary> iDictionaires;
       
   112         CSIF* iSIF;
       
   113         HBufC* iSavePath;
       
   114         TUint32 iIapId;
       
   115         RFileLogger& iLog;                      //not owned
       
   116 	    TSenDataTrafficDetails iDictDetails;    
       
   117     };
       
   118     
       
   119 class CZlibDictionary : public CBase
       
   120 {
       
   121     public:
       
   122     static CZlibDictionary* NewL( const TDesC8& aDictUri, 
       
   123                                   const TDesC8* aDictName, 
       
   124                                   const TDesC8* aDictType, 
       
   125                                   const TDesC8* aDictCheckSum );
       
   126                                 
       
   127      static CZlibDictionary* NewLC( const TDesC8& aDictUri, 
       
   128                                     const TDesC8* aDictName, 
       
   129                                     const TDesC8* aDictType, 
       
   130                                     const TDesC8* aDictCheckSum );
       
   131     
       
   132     virtual ~CZlibDictionary();
       
   133     
       
   134     TBool  Verified();
       
   135     TPtrC8  DictUri();
       
   136     TPtrC8  DictName();
       
   137     TPtrC8  DictType();
       
   138     TPtrC8  DictContents();    
       
   139     TUint32 DictCheckSum();
       
   140     TPtrC8 DictCheckSumPtr();
       
   141     
       
   142     TInt ResetL(CZlibDictionary* aDict);
       
   143     
       
   144     TInt SetDictContentsL(const TDesC8& aDictContents);
       
   145     TInt DeleteDictContents();
       
   146     
       
   147 private:
       
   148     TInt VerifyContentsL(const TDesC8& aDictContents);
       
   149     CZlibDictionary();
       
   150     void ConstructL( const TDesC8& aDictUri, 
       
   151                      const TDesC8* aDictName, 
       
   152                      const TDesC8* aDictType, 
       
   153                      const TDesC8* aDictCheckSum );
       
   154 private:
       
   155     
       
   156     HBufC8* iDictUri; //uri to download
       
   157     HBufC8* iDictName; //name or mws:Id tag
       
   158     HBufC8* iDictType; //zlib or mws:type
       
   159     HBufC8* iDictContents; //contents
       
   160     HBufC8* iDictCheckSum; //provided checksum
       
   161     TUint32 iChkSum; //chksum in integer form
       
   162     
       
   163     TBool iVerfied;
       
   164 }; 
       
   165 
       
   166 class CDictXml :public CSenDomFragment
       
   167 {
       
   168 public:    
       
   169     static CDictXml* NewL();
       
   170     static CDictXml* NewLC();
       
   171     ~CDictXml();
       
   172     
       
   173     TInt ReadFileL(TFileName aPath);
       
   174     CSenElement* XMLDocL();
       
   175 private:
       
   176 
       
   177     CDictXml();
       
   178     void ConstructL();
       
   179     TInt count;
       
   180     TBool iParsed;
       
   181 };   
       
   182 #endif // WSSTAR_DICTIONARY_H
       
   183 
       
   184 
       
   185