|
1 /* |
|
2 * Copyright (c) 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 #ifndef LAUNCHERXMLPARSER_H_ |
|
19 #define LAUNCHERXMLPARSER_H_ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <xml/contenthandler.h> |
|
23 #include <xml/parser.h> |
|
24 #include "launcherdllelement.h" |
|
25 #include "launcherparserobserver.h" |
|
26 |
|
27 using namespace Xml; |
|
28 |
|
29 const TUint KXMLBufferSize = 1024; |
|
30 |
|
31 class CLauncherDLLElement; |
|
32 |
|
33 /** |
|
34 * Parses DLL data from the given XML-file |
|
35 */ |
|
36 class CLauncherXMLParser : public CActive, public MContentHandler |
|
37 { |
|
38 public: |
|
39 |
|
40 virtual ~CLauncherXMLParser(); |
|
41 static CLauncherXMLParser* NewL(RFs& aFs); |
|
42 static CLauncherXMLParser* NewLC(RFs& aFs); |
|
43 |
|
44 /** |
|
45 * Parses the given XML-file and notifies the observer. |
|
46 * @param aFilePath XML-file's path |
|
47 * @param aObserver Pointer to the observer instance. |
|
48 */ |
|
49 void ParseL(const TDesC& aFilePath, MLauncherParserObserver* aObserver); |
|
50 |
|
51 protected: |
|
52 |
|
53 // from CActive |
|
54 void DoCancel(); |
|
55 void RunL(); |
|
56 |
|
57 private: |
|
58 |
|
59 CLauncherXMLParser(RFs& aFs); |
|
60 void ConstructL(); |
|
61 |
|
62 /** |
|
63 * Tells whether the current XML element is a sub-element of the 'dll'-element. |
|
64 * @return ETrue if the current XML-element is sub-element of the 'dll'-element. |
|
65 */ |
|
66 TBool IsDataElement(); |
|
67 |
|
68 /** |
|
69 * Deletes current data buffer and zeroes the pointer. |
|
70 */ |
|
71 void ClearXMLDataBuffer(); |
|
72 |
|
73 /** |
|
74 * Converts 8-bit descriptor to 32-bit unsigned integer |
|
75 * @return Converted 32-bit unsigned integer value. |
|
76 * @param aStr 8-bit descriptor to be converted. |
|
77 */ |
|
78 TUint32 ConvertDes8ToUint32L(const TDesC8& aStr); |
|
79 |
|
80 public: |
|
81 // From MContentHandler: |
|
82 void OnStartDocumentL(const RDocumentParameters &aDocParam, TInt aErrorCode); |
|
83 void OnEndDocumentL(TInt aErrorCode); |
|
84 void OnStartElementL( const RTagInfo& aElement, |
|
85 const RAttributeArray& aAttributes, |
|
86 TInt aErrorCode); |
|
87 void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); |
|
88 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
89 void OnStartPrefixMappingL( const RString& aPrefix, |
|
90 const RString& aUri, |
|
91 TInt aErrorCode); |
|
92 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
93 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
94 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
95 void OnProcessingInstructionL( const TDesC8& aTarget, |
|
96 const TDesC8& aData, |
|
97 TInt aErrorCode); |
|
98 void OnError(TInt aErrorCode); |
|
99 TAny* GetExtendedInterface(const TInt32 aUid); |
|
100 |
|
101 private: |
|
102 CParser* iParser; // XML parser |
|
103 RFs& iFileSession; |
|
104 RFile iFile; // XML file |
|
105 TBuf8<KXMLBufferSize> iXMLDataBuffer; |
|
106 MLauncherParserObserver* iObserver; |
|
107 CLauncherDLLElement* iCurrentDllElement; |
|
108 TBuf8<KMaxFileName> iCurrentContent; |
|
109 TBuf8<KMaxName> iCurrentElementName; |
|
110 TBool iIgnoreError; |
|
111 TInt iParsedBytes; |
|
112 }; |
|
113 |
|
114 #endif /* LAUNCHERXMLPARSER_H_ */ |