|
1 /** |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file XmlParsing.h |
|
22 */ |
|
23 |
|
24 #ifndef _XMLPARSING_H_ |
|
25 #define _XMLPARSING_H_ |
|
26 |
|
27 #include <xml/contenthandler.h> |
|
28 #include <xml/documentparameters.h> |
|
29 #include <xml/taginfo.h> |
|
30 #include <xml/attribute.h> |
|
31 |
|
32 #include <elements/sd_mintercept.h> |
|
33 |
|
34 |
|
35 |
|
36 static const TUint KXmlParsingBufferMaxLength = 128; |
|
37 typedef TBuf8<KXmlParsingBufferMaxLength> TXmlTempBuf8; |
|
38 _LIT8(KXmlMimeType, "text/xml"); |
|
39 |
|
40 class TLookupTableEntry8 |
|
41 { |
|
42 public: |
|
43 TPtrC8 iIdentifier; |
|
44 TUint iValue; |
|
45 }; |
|
46 |
|
47 class CExpressionXmlHandler : public Xml::MContentHandler |
|
48 { |
|
49 // MContentHandler |
|
50 protected: |
|
51 void OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt /*aErrorCode*/) {} |
|
52 void OnEndDocumentL(TInt /*aErrorCode*/) {} |
|
53 void OnStartElementL(const Xml::RTagInfo& /*aElement*/, const Xml::RAttributeArray& /*aAttributes*/, TInt /*aErrorCode*/) {} |
|
54 void OnEndElementL(const Xml::RTagInfo& /*aElement*/, TInt /*aErrorCode*/) {} |
|
55 void OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/){} |
|
56 void OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, TInt /*aErrorCode*/){} |
|
57 void OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/){} |
|
58 void OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/){} |
|
59 void OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/) {} |
|
60 void OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/){} |
|
61 void OnExtensionL(const RString& /*aData*/, TInt /*aToken*/, TInt /*aErrorCode*/){} |
|
62 void OnError(TInt /*aErrorCode*/){} |
|
63 TAny* GetExtendedInterface(const TInt32 /*aUid*/){return NULL;} |
|
64 void FetchAttributeValueByNameL( |
|
65 const Xml::RAttributeArray& aAttributes, |
|
66 const TDesC8& aAttributeTag, |
|
67 TDes8& aAttributeValue); |
|
68 |
|
69 enum TLookupTableType {EUidTable, EMessageIdTable, ETierIdTable, EAccessPointIdTable, EErrorCodeTable, EActionTypeTable, ERealmIdTable}; |
|
70 |
|
71 void ParseIdentifierValueL(const TDesC8& aBuffer, TDes8& aIdentifier); |
|
72 void ParseHexValueL(const TDesC8& aBuffer, TUint& aHexValue); |
|
73 void LookupValueByNameL(TLookupTableType aLookupType, const TDesC8& aName, TUint& aValue); |
|
74 void FetchValueOrNamedValueL(TLookupTableType aType, const TDesC8& aBuffer, TUint& aValue); |
|
75 }; |
|
76 |
|
77 class CActionXmlHandler : public CExpressionXmlHandler |
|
78 { |
|
79 public: |
|
80 CActionXmlHandler(); |
|
81 CActionXmlHandler(Den::TAction& aParsedAction) : iAction(aParsedAction) {} |
|
82 virtual ~CActionXmlHandler() {} |
|
83 |
|
84 private: |
|
85 // From MContentHandler |
|
86 void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode); |
|
87 |
|
88 void ParseActionTypeAttributeL(const Xml::RAttributeArray& aAttributes, Den::TAction::TActionType& aActionType); |
|
89 void ParseActionErrorCodeAttributeL(const Xml::RAttributeArray& aAttributes, TInt& aError); |
|
90 |
|
91 Den::TAction& iAction; |
|
92 }; |
|
93 |
|
94 class CEventExpressionXmlHandler : public CExpressionXmlHandler |
|
95 { |
|
96 |
|
97 public: |
|
98 CEventExpressionXmlHandler(); |
|
99 CEventExpressionXmlHandler(Den::TEventExpression& aEventExpression) : |
|
100 iEventExpression(aEventExpression), |
|
101 iParseState(EEventElement) {} |
|
102 virtual ~CEventExpressionXmlHandler() {} |
|
103 |
|
104 private: |
|
105 // From MContentHandler |
|
106 void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode); |
|
107 void OnEndElementL(const Xml::RTagInfo& /*aElement*/, TInt /*aErrorCode*/); |
|
108 |
|
109 void ParseProviderInfoAttributeL(const Xml::RAttributeArray& aAttributes, TUid& aTierId, TUint& aAPId); |
|
110 void ParseUidAttributeL(const Xml::RAttributeArray& aAttributes, TUid& aUid); |
|
111 void ParseNodeTagAttributeL(const Xml::RAttributeArray& aAttributes, TDes8& aTagToApply); |
|
112 void ParseNodeTagToApplyAttributeL(const Xml::RAttributeArray& aAttributes, TDes8& aTagToApply); |
|
113 |
|
114 void ParseNodeExpressionElementL( |
|
115 const Xml::RTagInfo& aElementName, |
|
116 const Xml::RAttributeArray& aAttributes, |
|
117 Den::TNodeExpression& aNodeExpression); |
|
118 |
|
119 void ParseMessageElementL( |
|
120 const Xml::RTagInfo& aElementName, |
|
121 const Xml::RAttributeArray& aAttributes, |
|
122 Den::TMsgExpression& aMessage); |
|
123 |
|
124 void ParseNamedNumericAttributeL( |
|
125 const TDesC8& aAttribName, |
|
126 const Xml::RAttributeArray& aAttributes, |
|
127 TLookupTableType aTableId, |
|
128 TUint& aParsedValue); |
|
129 |
|
130 Den::TNodeExpression iSender; |
|
131 Den::TMsgExpression iMessage; |
|
132 Den::TNodeExpression iReceiver; |
|
133 Den::TEventExpression& iEventExpression; |
|
134 |
|
135 enum TParseState {EEventElement, ESenderNodeElement, EMsgElement, EReceiverNodeElement, EDone}; |
|
136 TParseState iParseState; |
|
137 }; |
|
138 |
|
139 #endif // _XMLPARSING_H_ |
|
140 |