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