williamr@2
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@2
|
4 |
// 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
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@2
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
// BSP.H (Base Script Parser)
|
williamr@2
|
15 |
// Abstract class for different Parsers.
|
williamr@2
|
16 |
//
|
williamr@2
|
17 |
//
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
#if !defined(__BSP_H__)
|
williamr@2
|
21 |
#define __BSP_H__
|
williamr@2
|
22 |
|
williamr@2
|
23 |
#if !defined(__MTCLREG_H__)
|
williamr@2
|
24 |
#include <mtclreg.h>
|
williamr@2
|
25 |
#endif
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#if !defined(__MTCLBASE_H__)
|
williamr@2
|
28 |
#include <mtclbase.h>
|
williamr@2
|
29 |
#endif
|
williamr@2
|
30 |
|
williamr@2
|
31 |
#include <e32base.h>
|
williamr@2
|
32 |
#if !defined(__S32STRM_H__)
|
williamr@2
|
33 |
#include <s32strm.h>
|
williamr@2
|
34 |
#endif
|
williamr@2
|
35 |
|
williamr@2
|
36 |
#include <msvstd.h>
|
williamr@2
|
37 |
// CRichText etc. includes
|
williamr@2
|
38 |
#include <txtrich.h>
|
williamr@2
|
39 |
#include <txtfmlyr.h>
|
williamr@2
|
40 |
|
williamr@2
|
41 |
#include <bif.h>
|
williamr@2
|
42 |
|
williamr@2
|
43 |
|
williamr@2
|
44 |
|
williamr@2
|
45 |
// Symbols:
|
williamr@2
|
46 |
/** Space character. */
|
williamr@2
|
47 |
#define KCharSpace ' '
|
williamr@2
|
48 |
/** Tab character. */
|
williamr@2
|
49 |
#define KCharTab '\t'
|
williamr@2
|
50 |
/** Line feed character. */
|
williamr@2
|
51 |
#define KCharLineFeed '\n'
|
williamr@2
|
52 |
|
williamr@2
|
53 |
|
williamr@2
|
54 |
// Define some generic error codes:
|
williamr@2
|
55 |
/** BIO error code base. */
|
williamr@2
|
56 |
const TInt KBspBaseError = (-500);
|
williamr@2
|
57 |
|
williamr@2
|
58 |
/** Invalid BIO message error code. */
|
williamr@2
|
59 |
const TInt KBspInvalidMessage = (KBspBaseError);
|
williamr@2
|
60 |
/** Invalid smart message token error code. */
|
williamr@2
|
61 |
const TInt KBspSmartMessageInvalidToken = (KBspBaseError-1);
|
williamr@2
|
62 |
/** No smart message parser defined error code. */
|
williamr@2
|
63 |
const TInt KBspSmartMessageNoParserDefined = (KBspBaseError-2);
|
williamr@2
|
64 |
|
williamr@2
|
65 |
// Parsed field class for use by parsers.
|
williamr@2
|
66 |
class CParsedField : public CBase
|
williamr@2
|
67 |
/** Represents a single token-value pair for a given field in a BIO/smart message
|
williamr@2
|
68 |
grammar.
|
williamr@2
|
69 |
@publishedAll
|
williamr@2
|
70 |
@released
|
williamr@2
|
71 |
*/
|
williamr@2
|
72 |
{
|
williamr@2
|
73 |
public:
|
williamr@2
|
74 |
IMPORT_C CParsedField();
|
williamr@2
|
75 |
IMPORT_C ~CParsedField();
|
williamr@2
|
76 |
|
williamr@2
|
77 |
IMPORT_C TPtrC FieldName() const;
|
williamr@2
|
78 |
IMPORT_C void SetFieldNameL( const TDesC& aFieldName);
|
williamr@2
|
79 |
IMPORT_C TPtrC FieldValue() const;
|
williamr@2
|
80 |
IMPORT_C void SetFieldValueL( const TDesC& aFieldValue);
|
williamr@2
|
81 |
IMPORT_C TBool MandatoryField() const;
|
williamr@2
|
82 |
IMPORT_C void SetMandatoryField(TBool aMandatoryField);
|
williamr@2
|
83 |
|
williamr@2
|
84 |
IMPORT_C void InternalizeL(RReadStream& aStream);
|
williamr@2
|
85 |
IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
|
williamr@2
|
86 |
private:
|
williamr@2
|
87 |
void Reset();
|
williamr@2
|
88 |
private:
|
williamr@2
|
89 |
HBufC* iFieldName;
|
williamr@2
|
90 |
HBufC* iFieldValue;
|
williamr@2
|
91 |
TBool iMandatoryField;
|
williamr@2
|
92 |
};
|
williamr@2
|
93 |
|
williamr@2
|
94 |
// Forward declarations:
|
williamr@2
|
95 |
class CMsvServerEntry;
|
williamr@2
|
96 |
class CMsvEntry;
|
williamr@2
|
97 |
class CRegisteredParserDll;
|
williamr@2
|
98 |
class RMsvReadStream;
|
williamr@2
|
99 |
class RMsvWriteStream;
|
williamr@2
|
100 |
class CMsvStore;
|
williamr@2
|
101 |
class CSmsMessage;
|
williamr@2
|
102 |
|
williamr@2
|
103 |
|
williamr@2
|
104 |
|
williamr@2
|
105 |
/** Base class for BIO message parsers V2.
|
williamr@2
|
106 |
|
williamr@2
|
107 |
Concrete derived classes are implemented in parser DLL's to parse particular
|
williamr@2
|
108 |
types of BIO message.
|
williamr@2
|
109 |
|
williamr@2
|
110 |
On receiving an appropriate command (see TBioOperation), the BIO server MTM
|
williamr@2
|
111 |
loads the appropriate parser and passes the message body to it for interpretation.
|
williamr@2
|
112 |
In fact, the parser interface expects the parser to divide its operation into
|
williamr@2
|
113 |
two stages:
|
williamr@2
|
114 |
|
williamr@2
|
115 |
1. parsing: which involves extracting information from the raw message body and
|
williamr@2
|
116 |
storing it in a structured format. The parsing stage can also alter the message
|
williamr@2
|
117 |
body, and create files in the directory associated with the message (e.g.
|
williamr@2
|
118 |
parsing a ring tones message will generate a ring tone file).
|
williamr@2
|
119 |
|
williamr@2
|
120 |
2. processing: which involves using the extracted information to achieve the
|
williamr@2
|
121 |
purpose of the BIO message (e.g. setting some phone configuration setttings).
|
williamr@2
|
122 |
|
williamr@2
|
123 |
This separation allows, for example, a UI to display the parsed information
|
williamr@2
|
124 |
to the user for confirmation, before it is acted upon. For some parsers, however,
|
williamr@2
|
125 |
this two stage division is not sensible, in which case they implement only
|
williamr@2
|
126 |
the first.
|
williamr@2
|
127 |
|
williamr@2
|
128 |
The base class provides a pointer iSettings to reference the raw message data,
|
williamr@2
|
129 |
and an array of token-value pairs, iParsedFieldArray, for storing parsed information
|
williamr@2
|
130 |
(if this is appropriate).
|
williamr@2
|
131 |
@publishedAll
|
williamr@2
|
132 |
@released
|
williamr@2
|
133 |
*/
|
williamr@2
|
134 |
class CBaseScriptParser2: public CActive
|
williamr@2
|
135 |
{
|
williamr@2
|
136 |
public:
|
williamr@2
|
137 |
IMPORT_C CBaseScriptParser2(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs);
|
williamr@2
|
138 |
IMPORT_C ~CBaseScriptParser2();
|
williamr@2
|
139 |
|
williamr@2
|
140 |
/** Called by the BIO server MTM to asynchronously parse message body data.
|
williamr@2
|
141 |
|
williamr@2
|
142 |
When parsing is complete, the function should indicate this by setting the
|
williamr@2
|
143 |
message's index field iMtmData3 to 1.
|
williamr@2
|
144 |
|
williamr@2
|
145 |
The function should leave if the buffer cannot be parsed successfully.
|
williamr@2
|
146 |
|
williamr@2
|
147 |
@param aStatus Asynchronous status word
|
williamr@2
|
148 |
@param aSms Buffer to parse */
|
williamr@2
|
149 |
virtual void ParseL(TRequestStatus& aStatus, const TDesC& aSms)=0; //parses sms data into CParsedField
|
williamr@2
|
150 |
/** Called by the BIO server MTM to asynchronously process the parsed data.
|
williamr@2
|
151 |
|
williamr@2
|
152 |
The function takes appropriate parser-specific action on the results of a
|
williamr@2
|
153 |
previous call to ParseL().
|
williamr@2
|
154 |
|
williamr@2
|
155 |
When processing is complete, the function should indicate this by setting
|
williamr@2
|
156 |
the message's index field iMtmData3 to 2.
|
williamr@2
|
157 |
|
williamr@2
|
158 |
The function should leave if processing is not successful.
|
williamr@2
|
159 |
|
williamr@2
|
160 |
@param aStatus Asynchronous status word */
|
williamr@2
|
161 |
virtual void ProcessL(TRequestStatus& aStatus)=0; //stores parsed data into streams and data base
|
williamr@2
|
162 |
|
williamr@2
|
163 |
IMPORT_C TUid ParserUid();
|
williamr@2
|
164 |
IMPORT_C void RestoreL(CMsvStore& aMessageStore);
|
williamr@2
|
165 |
IMPORT_C void StoreL(CMsvStore& aMsvStore) const;
|
williamr@2
|
166 |
IMPORT_C void RestoreL(const TFileName& aFileName);
|
williamr@2
|
167 |
IMPORT_C void StoreL(const TFileName& aFileName) const;
|
williamr@2
|
168 |
IMPORT_C void ResetL();
|
williamr@2
|
169 |
|
williamr@2
|
170 |
protected:
|
williamr@2
|
171 |
// Parsing:
|
williamr@2
|
172 |
IMPORT_C void UnfoldMessageL();
|
williamr@2
|
173 |
|
williamr@2
|
174 |
// Streaming operations:
|
williamr@2
|
175 |
void InternalizeL(RMsvReadStream& aStream);
|
williamr@2
|
176 |
void ExternalizeL(RMsvWriteStream& aStream) const;
|
williamr@2
|
177 |
|
williamr@2
|
178 |
protected:
|
williamr@2
|
179 |
/** Object that loaded the parser. It contains a reference counter of the use of
|
williamr@2
|
180 |
the parser. */
|
williamr@2
|
181 |
CRegisteredParserDll& iRegisteredParserDll;
|
williamr@2
|
182 |
/** The message entry the parser should parse. */
|
williamr@2
|
183 |
CMsvEntry& iEntry;
|
williamr@2
|
184 |
/** Connected file server handle. */
|
williamr@2
|
185 |
RFs& iFs;
|
williamr@2
|
186 |
|
williamr@2
|
187 |
/** Lexer intended for Smart Message use.
|
williamr@2
|
188 |
|
williamr@2
|
189 |
This is not used by the base class. */
|
williamr@2
|
190 |
TLex iSms;
|
williamr@2
|
191 |
/** Array of token-value pairs.
|
williamr@2
|
192 |
|
williamr@2
|
193 |
Derived classes can use this for storing parsed information (if this is appropriate). */
|
williamr@2
|
194 |
CArrayPtrSeg<CParsedField>* iParsedFieldArray;
|
williamr@2
|
195 |
|
williamr@2
|
196 |
/** Flag intended for Smart Message use.
|
williamr@2
|
197 |
|
williamr@2
|
198 |
This is not used by the base class. */
|
williamr@2
|
199 |
TBool iSmsParsed;
|
williamr@2
|
200 |
/** ID of iEntry. */
|
williamr@2
|
201 |
TMsvId iEntryId;
|
williamr@2
|
202 |
|
williamr@2
|
203 |
/** Pointer to message data.
|
williamr@2
|
204 |
|
williamr@2
|
205 |
This is not set by the base class. */
|
williamr@2
|
206 |
HBufC* iSettings;
|
williamr@2
|
207 |
/** Pointer to SMS data (intended for Smart Message use).
|
williamr@2
|
208 |
|
williamr@2
|
209 |
This is not set by the base class. */
|
williamr@2
|
210 |
HBufC* iSmsBuf; // Local copy of buffer passed to ParseL()
|
williamr@2
|
211 |
/** Temporary pointer used by RestoreL(). */
|
williamr@2
|
212 |
HBufC8* iReadBuffer; // used to restore data from file
|
williamr@2
|
213 |
};
|
williamr@2
|
214 |
|
williamr@2
|
215 |
|
williamr@2
|
216 |
/** BIO data location flag values.
|
williamr@2
|
217 |
|
williamr@2
|
218 |
@see TMsvBIOEntry */
|
williamr@2
|
219 |
enum TMsvBIODataLocation
|
williamr@2
|
220 |
{
|
williamr@2
|
221 |
/** Unknown. */
|
williamr@2
|
222 |
EUnknown,
|
williamr@2
|
223 |
/** Parser wrote data into the body text. */
|
williamr@2
|
224 |
EBodyText, // parser wrote data back into richText
|
williamr@2
|
225 |
/** Parser wrote data into the parsed fields data stream. */
|
williamr@2
|
226 |
EBIODataStream, // parser wrote data into KUIDMsvBioStream
|
williamr@2
|
227 |
/** Parser wrote data into an attachment file. */
|
williamr@2
|
228 |
EFile // parser wrote data into attachment file
|
williamr@2
|
229 |
};
|
williamr@2
|
230 |
|
williamr@2
|
231 |
|
williamr@2
|
232 |
/** Bearer Independent Object entry.
|
williamr@2
|
233 |
Specialises the TMsvEntry message entry class to store additional BIO message-specific
|
williamr@2
|
234 |
information.
|
williamr@2
|
235 |
@internalTechnology
|
williamr@2
|
236 |
@released
|
williamr@2
|
237 |
*/
|
williamr@2
|
238 |
class TMsvBIOEntry : public TMsvEntry
|
williamr@2
|
239 |
{
|
williamr@2
|
240 |
public:
|
williamr@2
|
241 |
/** Constructor. */
|
williamr@2
|
242 |
TMsvBIOEntry() : TMsvEntry() {};
|
williamr@2
|
243 |
void SetBIOParserUid(const TUid aId);
|
williamr@2
|
244 |
const TUid BIOParserUid() const;
|
williamr@2
|
245 |
void SetLocationOfData(const TMsvBIODataLocation aLocation);
|
williamr@2
|
246 |
const TMsvBIODataLocation LocationOfData() const;
|
williamr@2
|
247 |
|
williamr@2
|
248 |
private:
|
williamr@2
|
249 |
TMsvBIODataLocation iLocationOfData;
|
williamr@2
|
250 |
};
|
williamr@2
|
251 |
|
williamr@2
|
252 |
#include <bsp.inl>
|
williamr@2
|
253 |
|
williamr@2
|
254 |
#endif
|