connectivitymodules/SeCon/wbxml/conmlhandler/inc/sconconmlgenerator.h
branchRCL_3
changeset 20 4a793f564d72
parent 0 d0791faffa3f
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  ConML parser/generator
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __SCONCONMLGENERATOR_H__
       
    20 #define __SCONCONMLGENERATOR_H__
       
    21 
       
    22 // -----------------------------------------------------------------------------
       
    23 // Includes
       
    24 // -----------------------------------------------------------------------------
       
    25 #include "sconxmlelement.h"
       
    26 #include "sconconmldtd.h"
       
    27 #include "sconconmltags.h"
       
    28 #include "sconwbxmldefs.h"
       
    29 #include "sconxmlworkspace.h"
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // MWBXMLConMLCallback - Call back for parsed data
       
    33 // -----------------------------------------------------------------------------
       
    34 class MWBXMLConMLCallback
       
    35     {
       
    36 public:
       
    37      /**
       
    38     * Call back function for delivering the parsed data
       
    39     * @param aContent contains the parsed data
       
    40     * @return none
       
    41     */
       
    42 
       
    43     virtual void ConMLL( ConML_ConMLPtr_t aContent ) = 0;
       
    44     };
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // TWBXMLContentFormat
       
    48 // -----------------------------------------------------------------------------
       
    49 enum TWBXMLContentFormat
       
    50     {
       
    51     EWBXMLContentFormatOpaque,
       
    52     EWBXMLContentFormatInlineString
       
    53     };
       
    54     
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSConConMLGenerator - Generates XBXML and XML documents
       
    57 // -----------------------------------------------------------------------------
       
    58 NONSHARABLE_CLASS( CSConConMLGenerator ) : public CBase
       
    59     {
       
    60 public:
       
    61 
       
    62     static CSConConMLGenerator* NewL();
       
    63     ~CSConConMLGenerator();
       
    64         
       
    65     /**
       
    66     * Returns the generated WBXML document
       
    67     * @param none 
       
    68     * @return the document as TPtrC8
       
    69     */
       
    70     TPtrC8 WBXMLDocument();
       
    71 
       
    72     /**
       
    73     * Returns the generated XML document
       
    74     * @param none 
       
    75     * @return the document as TPtrC8
       
    76     */
       
    77     TPtrC8 XMLDocument();
       
    78     
       
    79     
       
    80     // WBXML Parser
       
    81     
       
    82     /**
       
    83     * Sets the callback function to call after parsing
       
    84     * @param aCallback callback function to call when parsing finished
       
    85     * @return none
       
    86     */
       
    87     void SetCallback ( MWBXMLConMLCallback* aCallbakc );
       
    88     
       
    89     /**
       
    90     * Starts the document after header has been parsed 
       
    91     * @param aVersion - version of WBXML document
       
    92     * @param aPublicId - public ID of WBXML document as known public ID
       
    93     * @param aCharset - Character set of WBXML document
       
    94     * @return none
       
    95     */
       
    96     void StartDocument( TUint8 aVersion, TInt32 aPublicId, TUint32 aCharset );
       
    97 
       
    98     /**
       
    99     * Starts the document after header has been parsed 
       
   100     * @param aVersion - version of WBXML document
       
   101     * @param aPublicIdStr - public ID of WBXML document as a inline string 
       
   102     * @param aCharset - Character set of WBXML document
       
   103     * @return none
       
   104     */
       
   105     void StartDocument( 
       
   106         TUint8 aVersion, const TDesC8& aPublicIdStr, TUint32 aCharset );
       
   107     
       
   108     /**
       
   109     * Starts a new element in the document
       
   110     * @param aTag - Tag of the element
       
   111     * @return none
       
   112     */
       
   113     void StartElementL( TWBXMLTag aTag );
       
   114 
       
   115     /**
       
   116     * Starts a character data in the document
       
   117     * @param aBuffer - Character data
       
   118     * @return none
       
   119     */
       
   120     void CharactersL( const TDesC8& aBuffer );
       
   121 
       
   122     /**
       
   123     * Document has been parsed - the end of document
       
   124     * @param none
       
   125     * @return none
       
   126     */
       
   127     void EndDocument();
       
   128         
       
   129     /**
       
   130     * End tag of an element has been found
       
   131     * @param aTag - tag of the element to be closed 
       
   132     * @return none
       
   133     */
       
   134     void EndElementL( TWBXMLTag aTag );
       
   135     
       
   136     // Generator
       
   137     
       
   138     /**
       
   139     * Starts the generation of a document
       
   140     * @param aContent - data for the document
       
   141     * @return none
       
   142     */
       
   143     TInt GenerateConMLDocument ( ConML_ConMLPtr_t aContent );
       
   144 
       
   145 private:
       
   146 
       
   147     // WBXML Generator
       
   148     void WriteMUint32L( TUint32 aValue );
       
   149     void WriteOpaqueDataL( const TDesC8& aData );
       
   150     void WriteInlineStringL( const TDesC8& aData );
       
   151     
       
   152     // XML Generator
       
   153     void IndentL();
       
   154     TPtrC8 TranslateElement( TUint8 aElement );
       
   155 
       
   156     // WBXML / XML Generator
       
   157     void BeginDocumentL( TUint8 aVersion, TInt32 aPublicId, TUint32 aCharset, 
       
   158         const TDesC8& aStringTbl = TPtrC8() );
       
   159     void BeginElementL( TUint8 aElement, TBool aHasContent = EFalse, 
       
   160         TBool aHasAttributes = EFalse );
       
   161     void EndElementL();
       
   162     void AddElementL( 
       
   163         TUint8 aElement, const TDesC8& aContent, 
       
   164         const TWBXMLContentFormat aFormat = EWBXMLContentFormatOpaque );
       
   165     void AppendPCDataL( TUint8 aElement, pcdataPtr_t aContent );
       
   166     void AppendConMLL( ConML_ConMLPtr_t aContent );
       
   167     void AppendExecuteL( ConML_ExecutePtr_t aContent );
       
   168     void AppendSupplyDataL( ConML_SupplyDataPtr_t aContent );
       
   169     void AppendInstallL( ConML_InstallPtr_t aContent );
       
   170     void AppendCancelL ( ConML_CancelPtr_t aContent );
       
   171     void AppendStatusL ( ConML_StatusPtr_t aContent );
       
   172     void AppendGetStatusL( ConML_GetStatusPtr_t aContent );
       
   173     void AppendRebootL( ConML_RebootPtr_t aContent );
       
   174     void AppendTaskL( ConML_TaskPtr_t aContent );
       
   175     void AppendTaskListL( ConML_TaskListPtr_t aContent );
       
   176     void AppendUnInstallL( ConML_UnInstallPtr_t aContent );
       
   177     void AppendListInstalledAppsL ( ConML_ListInstalledAppsPtr_t aContent );
       
   178     void AppendListDataOwnersL ( ConML_ListDataOwnersPtr_t aContent );
       
   179     void AppendBUROptionsL( ConML_BUROptionsPtr_t aContent );
       
   180     void AppendSetBURModeL( ConML_SetBURModePtr_t aContent );
       
   181     void AppendGetDataSizeL( ConML_GetDataSizePtr_t aContent );
       
   182     void AppendRequestDataL( ConML_RequestDataPtr_t aContent );
       
   183     void AppendUpdateDeviceInfoL( ConML_UpdateDeviceInfoPtr_t aContent );
       
   184     void AppendListPublicFilesL( ConML_ListPublicFilesPtr_t aContent );
       
   185     void AppendApplicationL( ConML_ApplicationPtr_t aContent );
       
   186     void AppendApplicationListL( ConML_ApplicationListPtr_t aContent );
       
   187     void AppendApplicationsL( ConML_ApplicationsPtr_t aContent );
       
   188     void AppendParamL( ConML_ParamPtr_t aContent );
       
   189     void AppendParamListL( ConML_ParamListPtr_t aContent );
       
   190     void AppendInstParamsL( ConML_InstParamsPtr_t aContent );
       
   191     void AppendProgressL( ConML_ProgressPtr_t aContent );
       
   192     void AppendResultsL( ConML_ResultsPtr_t aContent );
       
   193     void AppendDriveL( ConML_DrivePtr_t aContent );
       
   194     void AppendDriveListL( ConML_DriveListPtr_t aContent );
       
   195     void AppendDrivesL( ConML_DrivesPtr_t aContent );
       
   196     void AppendDataOwnersL( ConML_DataOwnersPtr_t aContent );
       
   197     void AppendPackageInfoL ( ConML_PackageInfoPtr_t aContent );
       
   198     void AppendSIDL( ConML_SIDPtr_t aContent );
       
   199     void AppendSIDListL( ConML_SIDListPtr_t aContent );
       
   200     void AppendDeviceInfoL( ConML_DeviceInfoPtr_t aContent );
       
   201     void AppendFilesL( ConML_FilesPtr_t aContent );
       
   202     void AppendSupportedMethodsL( ConML_SupportedMethodsPtr_t aContent );
       
   203     void AppendFileListL( ConML_FileListPtr_t  aContent );
       
   204     void AppendFileL( ConML_FilePtr_t aContent );
       
   205     void AppendGetDataOwnerStatusL( ConML_GetDataOwnerStatusPtr_t aContent );
       
   206     void AppendGetMetadataL( ConML_GetMetadataPtr_t aContent );
       
   207     
       
   208     TInt HandleResult( TInt aResult, TInt aTreshold = 0 );
       
   209     
       
   210 private:
       
   211     void ConstructL();
       
   212     CSConConMLGenerator();
       
   213     void AddElement( CXMLElement* aElement );
       
   214 
       
   215 private:
       
   216     // Parser
       
   217     CXMLStack<CXMLElement>* iCmdStack;
       
   218     CXMLStack<CXMLElement>* iCleanupStack;
       
   219     MWBXMLConMLCallback* iCallback;
       
   220 
       
   221     // Generator workspaces 
       
   222     CXMLWorkspace* iWBXMLWorkspace;
       
   223     CXMLWorkspace* iXMLWorkspace;
       
   224 
       
   225     // XML
       
   226     RArray<TUint8> iElemStack;
       
   227     TInt iInitialIndentLevel;
       
   228     TBool iDontNewLine;
       
   229     TBool iDontIndent;
       
   230     }; 
       
   231 
       
   232 #endif // __SCONCONMLGENERATOR_H__