1.1 --- a/epoc32/include/bsp.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/bsp.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,254 @@
1.4 -bsp.h
1.5 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +// BSP.H (Base Script Parser)
1.19 +// Abstract class for different Parsers.
1.20 +//
1.21 +//
1.22 +
1.23 +
1.24 +#if !defined(__BSP_H__)
1.25 +#define __BSP_H__
1.26 +
1.27 +#if !defined(__MTCLREG_H__)
1.28 +#include <mtclreg.h>
1.29 +#endif
1.30 +
1.31 +#if !defined(__MTCLBASE_H__)
1.32 +#include <mtclbase.h>
1.33 +#endif
1.34 +
1.35 +#include <e32base.h>
1.36 +#if !defined(__S32STRM_H__)
1.37 +#include <s32strm.h>
1.38 +#endif
1.39 +
1.40 +#include <msvstd.h>
1.41 +// CRichText etc. includes
1.42 +#include <txtrich.h>
1.43 +#include <txtfmlyr.h>
1.44 +
1.45 +#include <bif.h>
1.46 +
1.47 +
1.48 +
1.49 +// Symbols:
1.50 +/** Space character. */
1.51 +#define KCharSpace ' '
1.52 +/** Tab character. */
1.53 +#define KCharTab '\t'
1.54 +/** Line feed character. */
1.55 +#define KCharLineFeed '\n'
1.56 +
1.57 +
1.58 +// Define some generic error codes:
1.59 +/** BIO error code base. */
1.60 +const TInt KBspBaseError = (-500);
1.61 +
1.62 +/** Invalid BIO message error code. */
1.63 +const TInt KBspInvalidMessage = (KBspBaseError);
1.64 +/** Invalid smart message token error code. */
1.65 +const TInt KBspSmartMessageInvalidToken = (KBspBaseError-1);
1.66 +/** No smart message parser defined error code. */
1.67 +const TInt KBspSmartMessageNoParserDefined = (KBspBaseError-2);
1.68 +
1.69 +// Parsed field class for use by parsers.
1.70 +class CParsedField : public CBase
1.71 +/** Represents a single token-value pair for a given field in a BIO/smart message
1.72 +grammar.
1.73 +@publishedAll
1.74 +@released
1.75 +*/
1.76 +{
1.77 +public:
1.78 + IMPORT_C CParsedField();
1.79 + IMPORT_C ~CParsedField();
1.80 +
1.81 + IMPORT_C TPtrC FieldName() const;
1.82 + IMPORT_C void SetFieldNameL( const TDesC& aFieldName);
1.83 + IMPORT_C TPtrC FieldValue() const;
1.84 + IMPORT_C void SetFieldValueL( const TDesC& aFieldValue);
1.85 + IMPORT_C TBool MandatoryField() const;
1.86 + IMPORT_C void SetMandatoryField(TBool aMandatoryField);
1.87 +
1.88 + IMPORT_C void InternalizeL(RReadStream& aStream);
1.89 + IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
1.90 +private:
1.91 + void Reset();
1.92 +private:
1.93 + HBufC* iFieldName;
1.94 + HBufC* iFieldValue;
1.95 + TBool iMandatoryField;
1.96 +};
1.97 +
1.98 +// Forward declarations:
1.99 +class CMsvServerEntry;
1.100 +class CMsvEntry;
1.101 +class CRegisteredParserDll;
1.102 +class RMsvReadStream;
1.103 +class RMsvWriteStream;
1.104 +class CMsvStore;
1.105 +class CSmsMessage;
1.106 +
1.107 +
1.108 +
1.109 +/** Base class for BIO message parsers V2.
1.110 +
1.111 +Concrete derived classes are implemented in parser DLL's to parse particular
1.112 +types of BIO message.
1.113 +
1.114 +On receiving an appropriate command (see TBioOperation), the BIO server MTM
1.115 +loads the appropriate parser and passes the message body to it for interpretation.
1.116 +In fact, the parser interface expects the parser to divide its operation into
1.117 +two stages:
1.118 +
1.119 +1. parsing: which involves extracting information from the raw message body and
1.120 +storing it in a structured format. The parsing stage can also alter the message
1.121 +body, and create files in the directory associated with the message (e.g.
1.122 +parsing a ring tones message will generate a ring tone file).
1.123 +
1.124 +2. processing: which involves using the extracted information to achieve the
1.125 +purpose of the BIO message (e.g. setting some phone configuration setttings).
1.126 +
1.127 +This separation allows, for example, a UI to display the parsed information
1.128 +to the user for confirmation, before it is acted upon. For some parsers, however,
1.129 +this two stage division is not sensible, in which case they implement only
1.130 +the first.
1.131 +
1.132 +The base class provides a pointer iSettings to reference the raw message data,
1.133 +and an array of token-value pairs, iParsedFieldArray, for storing parsed information
1.134 +(if this is appropriate).
1.135 +@publishedAll
1.136 +@released
1.137 +*/
1.138 +class CBaseScriptParser2: public CActive
1.139 + {
1.140 +public:
1.141 + IMPORT_C CBaseScriptParser2(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs);
1.142 + IMPORT_C ~CBaseScriptParser2();
1.143 +
1.144 + /** Called by the BIO server MTM to asynchronously parse message body data.
1.145 +
1.146 + When parsing is complete, the function should indicate this by setting the
1.147 + message's index field iMtmData3 to 1.
1.148 +
1.149 + The function should leave if the buffer cannot be parsed successfully.
1.150 +
1.151 + @param aStatus Asynchronous status word
1.152 + @param aSms Buffer to parse */
1.153 + virtual void ParseL(TRequestStatus& aStatus, const TDesC& aSms)=0; //parses sms data into CParsedField
1.154 + /** Called by the BIO server MTM to asynchronously process the parsed data.
1.155 +
1.156 + The function takes appropriate parser-specific action on the results of a
1.157 + previous call to ParseL().
1.158 +
1.159 + When processing is complete, the function should indicate this by setting
1.160 + the message's index field iMtmData3 to 2.
1.161 +
1.162 + The function should leave if processing is not successful.
1.163 +
1.164 + @param aStatus Asynchronous status word */
1.165 + virtual void ProcessL(TRequestStatus& aStatus)=0; //stores parsed data into streams and data base
1.166 +
1.167 + IMPORT_C TUid ParserUid();
1.168 + IMPORT_C void RestoreL(CMsvStore& aMessageStore);
1.169 + IMPORT_C void StoreL(CMsvStore& aMsvStore) const;
1.170 + IMPORT_C void RestoreL(const TFileName& aFileName);
1.171 + IMPORT_C void StoreL(const TFileName& aFileName) const;
1.172 + IMPORT_C void ResetL();
1.173 +
1.174 +protected:
1.175 +// Parsing:
1.176 + IMPORT_C void UnfoldMessageL();
1.177 +
1.178 +// Streaming operations:
1.179 + void InternalizeL(RMsvReadStream& aStream);
1.180 + void ExternalizeL(RMsvWriteStream& aStream) const;
1.181 +
1.182 +protected:
1.183 + /** Object that loaded the parser. It contains a reference counter of the use of
1.184 + the parser. */
1.185 + CRegisteredParserDll& iRegisteredParserDll;
1.186 + /** The message entry the parser should parse. */
1.187 + CMsvEntry& iEntry;
1.188 + /** Connected file server handle. */
1.189 + RFs& iFs;
1.190 +
1.191 + /** Lexer intended for Smart Message use.
1.192 +
1.193 + This is not used by the base class. */
1.194 + TLex iSms;
1.195 + /** Array of token-value pairs.
1.196 +
1.197 + Derived classes can use this for storing parsed information (if this is appropriate). */
1.198 + CArrayPtrSeg<CParsedField>* iParsedFieldArray;
1.199 +
1.200 + /** Flag intended for Smart Message use.
1.201 +
1.202 + This is not used by the base class. */
1.203 + TBool iSmsParsed;
1.204 + /** ID of iEntry. */
1.205 + TMsvId iEntryId;
1.206 +
1.207 + /** Pointer to message data.
1.208 +
1.209 + This is not set by the base class. */
1.210 + HBufC* iSettings;
1.211 + /** Pointer to SMS data (intended for Smart Message use).
1.212 +
1.213 + This is not set by the base class. */
1.214 + HBufC* iSmsBuf; // Local copy of buffer passed to ParseL()
1.215 + /** Temporary pointer used by RestoreL(). */
1.216 + HBufC8* iReadBuffer; // used to restore data from file
1.217 + };
1.218 +
1.219 +
1.220 +/** BIO data location flag values.
1.221 +
1.222 +@see TMsvBIOEntry */
1.223 +enum TMsvBIODataLocation
1.224 + {
1.225 + /** Unknown. */
1.226 + EUnknown,
1.227 + /** Parser wrote data into the body text. */
1.228 + EBodyText, // parser wrote data back into richText
1.229 + /** Parser wrote data into the parsed fields data stream. */
1.230 + EBIODataStream, // parser wrote data into KUIDMsvBioStream
1.231 + /** Parser wrote data into an attachment file. */
1.232 + EFile // parser wrote data into attachment file
1.233 + };
1.234 +
1.235 +
1.236 +/** Bearer Independent Object entry.
1.237 +Specialises the TMsvEntry message entry class to store additional BIO message-specific
1.238 +information.
1.239 +@internalTechnology
1.240 +@released
1.241 +*/
1.242 +class TMsvBIOEntry : public TMsvEntry
1.243 + {
1.244 +public:
1.245 + /** Constructor. */
1.246 + TMsvBIOEntry() : TMsvEntry() {};
1.247 + void SetBIOParserUid(const TUid aId);
1.248 + const TUid BIOParserUid() const;
1.249 + void SetLocationOfData(const TMsvBIODataLocation aLocation);
1.250 + const TMsvBIODataLocation LocationOfData() const;
1.251 +
1.252 +private:
1.253 + TMsvBIODataLocation iLocationOfData;
1.254 + };
1.255 +
1.256 +#include <bsp.inl>
1.257 +
1.258 +#endif