messagingfw/biomsgfw/BIUTINC/BSP.H
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // BSP.H (Base Script Parser)
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  * @file 
       
    20  * Abstract class for different Parsers.
       
    21  *
       
    22  * @publishedAll
       
    23  * @released
       
    24  */
       
    25 #if !defined(__BSP_H__)
       
    26 #define __BSP_H__
       
    27 
       
    28 #if !defined(__MTCLREG_H__)
       
    29 #include <mtclreg.h>
       
    30 #endif
       
    31 
       
    32 #if !defined(__MTCLBASE_H__)
       
    33 #include <mtclbase.h>
       
    34 #endif
       
    35 
       
    36 #include <e32base.h>
       
    37 #if !defined(__S32STRM_H__)
       
    38 #include <s32strm.h>
       
    39 #endif
       
    40 
       
    41 #include <msvstd.h>
       
    42 // CRichText etc. includes
       
    43 #include <txtrich.h>
       
    44 #include <txtfmlyr.h>
       
    45 
       
    46 #include <bif.h>
       
    47 
       
    48 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS 
       
    49 #include "tmsvbioinfo.h"
       
    50 #endif
       
    51 
       
    52 // Parsed field class for use by parsers.
       
    53 class CParsedField : public CBase
       
    54 /** Represents a single token-value pair for a given field in a BIO/smart message 
       
    55 grammar. 
       
    56 @publishedAll
       
    57 @released
       
    58 */
       
    59 {
       
    60 public:
       
    61 	IMPORT_C CParsedField();
       
    62 	IMPORT_C ~CParsedField();
       
    63 
       
    64 	IMPORT_C TPtrC FieldName() const;
       
    65 	IMPORT_C void SetFieldNameL( const TDesC& aFieldName);
       
    66 	IMPORT_C TPtrC FieldValue() const;
       
    67 	IMPORT_C void SetFieldValueL( const TDesC& aFieldValue);
       
    68 	IMPORT_C TBool MandatoryField() const;
       
    69 	IMPORT_C void SetMandatoryField(TBool aMandatoryField);
       
    70 
       
    71 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
    72 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
    73 private:
       
    74 	void Reset();
       
    75 private:
       
    76 	HBufC* iFieldName;
       
    77 	HBufC* iFieldValue;
       
    78 	TBool  iMandatoryField;
       
    79 };
       
    80 
       
    81 /**
       
    82  * Forward declarations:
       
    83  * @publishedAll
       
    84  * @released
       
    85  */
       
    86 class CMsvServerEntry;
       
    87 class CMsvEntry;
       
    88 class CRegisteredParserDll;
       
    89 class RMsvReadStream;
       
    90 class RMsvWriteStream;
       
    91 class CMsvStore;
       
    92 class CSmsMessage;
       
    93 
       
    94 /** Base class for BIO message parsers V2.
       
    95 
       
    96 Concrete derived classes are implemented in parser DLL's to parse particular 
       
    97 types of BIO message.
       
    98 
       
    99 On receiving an appropriate command (see TBioOperation), the BIO server MTM 
       
   100 loads the appropriate parser and passes the message body to it for interpretation. 
       
   101 In fact, the parser interface expects the parser to divide its operation into 
       
   102 two stages: 
       
   103 
       
   104 1. parsing: which involves extracting information from the raw message body and 
       
   105 storing it in a structured format. The parsing stage can also alter the message 
       
   106 body, and create files in the directory associated with the message (e.g. 
       
   107 parsing a ring tones message will generate a ring tone file).
       
   108 
       
   109 2. processing: which involves using the extracted information to achieve the 
       
   110 purpose of the BIO message (e.g. setting some phone configuration setttings).
       
   111 
       
   112 This separation allows, for example, a UI to display the parsed information 
       
   113 to the user for confirmation, before it is acted upon. For some parsers, however, 
       
   114 this two stage division is not sensible, in which case they implement only 
       
   115 the first.
       
   116 
       
   117 The base class provides a pointer iSettings to reference the raw message data, 
       
   118 and an array of token-value pairs, iParsedFieldArray, for storing parsed information 
       
   119 (if this is appropriate). 
       
   120 @publishedAll
       
   121 @released
       
   122 */
       
   123 class CBaseScriptParser2: public CActive
       
   124 	{
       
   125 public:
       
   126 	IMPORT_C CBaseScriptParser2(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs);
       
   127 	IMPORT_C ~CBaseScriptParser2();
       
   128 
       
   129 	/** Called by the BIO server MTM to asynchronously parse message body data.
       
   130 	
       
   131 	When parsing is complete, the function should indicate this by setting the 
       
   132 	message's index field iMtmData3 to 1.
       
   133 	
       
   134 	The function should leave if the buffer cannot be parsed successfully.
       
   135 	
       
   136 	@param aStatus Asynchronous status word
       
   137 	@param aSms Buffer to parse */
       
   138 	virtual void ParseL(TRequestStatus& aStatus, const TDesC& aSms)=0; //parses sms data into CParsedField
       
   139 	/** Called by the BIO server MTM to asynchronously process the parsed data.
       
   140 	
       
   141 	The function takes appropriate parser-specific action on the results of a 
       
   142 	previous call to ParseL().
       
   143 	
       
   144 	When processing is complete, the function should indicate this by setting 
       
   145 	the message's index field iMtmData3 to 2.
       
   146 	
       
   147 	The function should leave if processing is not successful.
       
   148 	
       
   149 	@param aStatus Asynchronous status word */
       
   150 	virtual void ProcessL(TRequestStatus& aStatus)=0; //stores parsed data into streams and data base
       
   151 
       
   152 	IMPORT_C TUid ParserUid();
       
   153 	IMPORT_C void RestoreL(CMsvStore& aMessageStore);
       
   154 	IMPORT_C void StoreL(CMsvStore& aMsvStore) const;
       
   155 	IMPORT_C void RestoreL(const TFileName& aFileName);
       
   156 	IMPORT_C void StoreL(const TFileName& aFileName) const;
       
   157 	IMPORT_C void ResetL();
       
   158 	
       
   159 protected:
       
   160 //	Parsing:
       
   161 	IMPORT_C void UnfoldMessageL();
       
   162 
       
   163 //	Streaming operations:
       
   164 	void InternalizeL(RMsvReadStream& aStream);
       
   165 	void ExternalizeL(RMsvWriteStream& aStream) const;
       
   166 
       
   167 protected:
       
   168 	/** Object that loaded the parser. It contains a reference counter of the use of 
       
   169 	the parser. */
       
   170 	CRegisteredParserDll&		iRegisteredParserDll;
       
   171 	/** The message entry the parser should parse. */
       
   172 	CMsvEntry&					iEntry;
       
   173 	/** Connected file server handle. */
       
   174 	RFs&						iFs;
       
   175 
       
   176 	/** Lexer intended for Smart Message use.
       
   177 	
       
   178 	This is not used by the base class. */
       
   179 	TLex						iSms;
       
   180 	/** Array of token-value pairs.
       
   181 	
       
   182 	Derived classes can use this for storing parsed information (if this is appropriate). */
       
   183 	CArrayPtrSeg<CParsedField>* iParsedFieldArray;
       
   184 
       
   185 	/** Flag intended for Smart Message use.
       
   186 	
       
   187 	This is not used by the base class. */
       
   188 	TBool						iSmsParsed;
       
   189 	/** ID of iEntry. */
       
   190 	TMsvId						iEntryId;
       
   191 	
       
   192 	/** Pointer to message data.
       
   193 	
       
   194 	This is not set by the base class. */
       
   195 	HBufC*						iSettings;
       
   196 	/** Pointer to SMS data (intended for Smart Message use).
       
   197 	
       
   198 	This is not set by the base class. */
       
   199     HBufC*						iSmsBuf;                // Local copy of buffer passed to ParseL()
       
   200 	/** Temporary pointer used by RestoreL(). */
       
   201 	HBufC8*						iReadBuffer;			// used to restore data from file
       
   202 	};
       
   203 
       
   204 #endif
       
   205