|
1 // Copyright (c) 2000-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 // |
|
15 |
|
16 #ifndef __CMSGPARSER_H |
|
17 #define __CMSGPARSER_H |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <xml/contenthandler.h> |
|
21 #include <xml/parser.h> |
|
22 #include <push/pushmessage.h> |
|
23 |
|
24 class MWAPElementHandler |
|
25 { |
|
26 public: |
|
27 virtual void HandleElementL ( const RString& aTag, const RString& aAttributeName, const RString& aAttributeValue ) = 0; |
|
28 virtual void HandleContentL ( const TDesC8& aBytes ) = 0; |
|
29 }; |
|
30 |
|
31 /** |
|
32 TODO |
|
33 */ |
|
34 //##ModelId=3B659EE90381 |
|
35 class CMessageParser : public CBase, public Xml::MContentHandler |
|
36 /** |
|
37 @internalTechnology |
|
38 @released |
|
39 */ |
|
40 { |
|
41 public: |
|
42 //##ModelId=3B659EEA0032 |
|
43 static CMessageParser* NewL ( CPushMessage& aPushMsg, |
|
44 MWAPElementHandler& aElementHandler, |
|
45 const TStringTable* aTagsTable, |
|
46 const TStringTable* aAttributeTable, |
|
47 const TStringTable* aAttributeValueTable ); |
|
48 /** parses and validates and returns error code */ |
|
49 //##ModelId=3B659EEA0028 |
|
50 TInt ParseMessageL (); |
|
51 |
|
52 //##ModelId=3B659EEA0027 |
|
53 ~CMessageParser (); |
|
54 |
|
55 RStringPool& StringPool (); |
|
56 |
|
57 // Methods from Xml::MContentHandler |
|
58 void OnStartDocumentL ( const Xml::RDocumentParameters &aDocParam, TInt aErrorCode ); |
|
59 void OnEndDocumentL ( TInt aErrorCode ); |
|
60 void OnStartElementL ( const Xml::RTagInfo &aElement, const Xml::RAttributeArray &aAttributes, TInt aErrorCode ); |
|
61 void OnEndElementL ( const Xml::RTagInfo &aElement, TInt aErrorCode ); |
|
62 void OnContentL ( const TDesC8 &aBytes, TInt aErrorCode ); |
|
63 void OnStartPrefixMappingL ( const RString &aPrefix, const RString &aUri, TInt aErrorCode ); |
|
64 void OnEndPrefixMappingL ( const RString &aPrefix, TInt aErrorCode ); |
|
65 void OnIgnorableWhiteSpaceL ( const TDesC8 &aBytes, TInt aErrorCode ); |
|
66 void OnSkippedEntityL ( const RString &aName, TInt aErrorCode ); |
|
67 void OnProcessingInstructionL ( const TDesC8 &aTarget, const TDesC8 &aData, TInt aErrorCode ); |
|
68 void OnError ( TInt aErrorCode ); |
|
69 TAny* GetExtendedInterface ( const TInt32 aUid ); |
|
70 |
|
71 TInt LastError (); |
|
72 private: |
|
73 //##ModelId=3B659EE903D3 |
|
74 CMessageParser( CPushMessage& aPushMsg, |
|
75 MWAPElementHandler& aElementHandler, |
|
76 const TStringTable* aTagsTable, |
|
77 const TStringTable* aAttributeTable, |
|
78 const TStringTable* aAttributeValueTable ); |
|
79 //##ModelId=3B659EE903D2 |
|
80 void ConstructL (); |
|
81 //##ModelId=3B659EE903D1 |
|
82 void LoadPluginL (); |
|
83 |
|
84 void CheckTagInTableL ( const RString& aTag ); |
|
85 void CheckAttributeValuePairL ( const RString& aAttribute, const RString& aAttributeValue ); |
|
86 |
|
87 TInt MapToWapXMLError ( TInt aXmlErrorCode ); |
|
88 |
|
89 private: |
|
90 //##ModelId=3B659EE9038F |
|
91 |
|
92 CPushMessage& iPushMessage; // reference |
|
93 MWAPElementHandler& iElementHandler; |
|
94 |
|
95 Xml::CParser* iParser; |
|
96 |
|
97 // Pointer to the static string pool table for tags, attribute and attribute value |
|
98 // We don't own this |
|
99 const TStringTable* iTagsTable; |
|
100 const TStringTable* iAttributeTable; |
|
101 const TStringTable* iAttributeValueTable; |
|
102 |
|
103 // Tag position in the XML document and the mapping in the tags string table. |
|
104 TInt iTagPosition; |
|
105 |
|
106 TInt iLastError; |
|
107 }; |
|
108 |
|
109 |
|
110 #endif // __CMSGPARSER_H |