|
1 /* |
|
2 * Copyright (c) 2007 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: XML content handler, constructs contacts entrys based upon |
|
15 * callbacks from the Xml parser. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef C_PDCXMLCONTENTHANDLER_H |
|
20 #define C_PDCXMLCONTENTHANDLER_H |
|
21 |
|
22 // System includes |
|
23 #include <e32base.h> // CBase |
|
24 #include <contenthandler.h> // MContentHandler |
|
25 #include <MVPbkContactObserver.h> // MVPbkContactObserver |
|
26 #include <CPbkContactItem.h> // CPbkContactItem |
|
27 |
|
28 // User includes |
|
29 #include "CVPbkContactManager.h" |
|
30 #include "pdcstringconstants.h" |
|
31 #include "pdclogger.h" |
|
32 |
|
33 // Forward declarations |
|
34 class MVPbkStoreContact; |
|
35 class MVPbkContactStore; |
|
36 class Xml::RTagInfo; |
|
37 class CVPbkContactLinkArray; |
|
38 class MVPbkContactFieldData; |
|
39 |
|
40 const TInt phoneNumberCount = 10; |
|
41 /** |
|
42 * This class is an implementation of the Xml:MContentHandler interface, |
|
43 * it is reponsible for creating contact items and and adding them to |
|
44 * the contacts engine based upon the callbacks from the XML parser. |
|
45 */ |
|
46 NONSHARABLE_CLASS( CPdcXmlContentHandler ): public CBase, |
|
47 public Xml::MContentHandler, public MVPbkContactObserver |
|
48 { |
|
49 public: |
|
50 /** |
|
51 * Symbian 1st phase constructor |
|
52 * @return Self pointer to CPdcXmlContentHandler |
|
53 * @param aContactStore contacts store |
|
54 * @param aLinkArray links to the contacts added. |
|
55 * @return a CPdcXmlContentHandler object. |
|
56 */ |
|
57 static CPdcXmlContentHandler* NewL( MVPbkContactStore& aContactStore, |
|
58 CVPbkContactLinkArray& aLinkArray); |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 virtual ~CPdcXmlContentHandler(); |
|
64 |
|
65 /** |
|
66 * Sets the string pool |
|
67 * @param aStringPool parser's string pool |
|
68 */ |
|
69 void SetStringPoolL( RStringPool& aStringPool ); |
|
70 |
|
71 /** |
|
72 * Sets the contactmanager |
|
73 * @param aContactManager engine's contactmanager |
|
74 */ |
|
75 void SetContactManager(CVPbkContactManager* aContactManager); |
|
76 |
|
77 private: // C++ constructor and the Symbian second-phase constructor |
|
78 CPdcXmlContentHandler( MVPbkContactStore& aContactStore, |
|
79 CVPbkContactLinkArray& aLinkArray); |
|
80 void ConstructL(); |
|
81 |
|
82 private: // private member functions |
|
83 TInt GetTagIndexL( const Xml::RTagInfo& aElement ) const; |
|
84 |
|
85 void AddFieldL( TInt aFieldResId, const TDesC8& aBuffer ); |
|
86 void SetTextFieldL( MVPbkContactFieldData& aFieldData, |
|
87 const TDesC8& aBuffer ); |
|
88 void SetBinaryFieldL( MVPbkContactFieldData& aFieldData, |
|
89 const TDesC8& aBuffer ); |
|
90 void SetDateFieldL( MVPbkContactFieldData& aFieldData, |
|
91 const TDesC8& aBuffer ); |
|
92 void AddContactL(); |
|
93 TInt GetSpeeddialAssignedFieldIndexL(CPbkContactItem* aItem); |
|
94 TInt ContactItemFieldIndexL( CPbkContactItem* aItem ); |
|
95 TInt GetDefaultSpeeddialAssignedFieldIndexL(); |
|
96 TBool CheckValidityOfSpeeddialAssignedFieldL( TInt aFieldIndex ); |
|
97 |
|
98 private: // from MContentHandler |
|
99 void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, |
|
100 TInt aErrorCode); |
|
101 void OnEndDocumentL(TInt aErrorCode); |
|
102 void OnStartElementL(const Xml::RTagInfo& aElement, |
|
103 const Xml::RAttributeArray& aAttributes, TInt aErrorCode); |
|
104 void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode); |
|
105 void OnContentL(const TDesC8& aBytes, TInt aErrorCode); |
|
106 void OnStartPrefixMappingL( const RString& aPrefix, |
|
107 const RString& aUri, TInt aErrorCode ); |
|
108 void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); |
|
109 void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); |
|
110 void OnSkippedEntityL(const RString& aName, TInt aErrorCode); |
|
111 void OnProcessingInstructionL( const TDesC8& aTarget, |
|
112 const TDesC8& aData, TInt aErrorCode ); |
|
113 void OnError(TInt aErrorCode); |
|
114 TAny* GetExtendedInterface(const TInt32 aUid); |
|
115 |
|
116 private: // from MVPbkContactObserver |
|
117 void ContactOperationCompleted(TContactOpResult aResult); |
|
118 void ContactOperationFailed |
|
119 (TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); |
|
120 |
|
121 private: // data |
|
122 /// Ref: Contact store |
|
123 MVPbkContactStore& iContactStore; |
|
124 /// Ref: Ids of the contacts that have been added |
|
125 CVPbkContactLinkArray& iLinkArray; |
|
126 /// Ref: String pool |
|
127 RStringPool* iStringPool; |
|
128 /// Own: Content buffer |
|
129 RBuf8 iContentBuffer; |
|
130 /// The current tag can be handled. |
|
131 TBool iKnownTag; |
|
132 /// Own: Contact item being created. |
|
133 MVPbkStoreContact* iContactItem; |
|
134 /// Own |
|
135 CActiveSchedulerWait* iWait; |
|
136 /// Error reported to contact observer |
|
137 TInt iContactObserverError; |
|
138 TInt iSpeeddialValue; |
|
139 CVPbkContactManager* iContactManager; |
|
140 /// The content of speeddial number |
|
141 TInt iSpeeddialIndex; |
|
142 /// Own: Speeddial assigned phone number field |
|
143 TInt iSpeeddialAssignedFieldIndex; |
|
144 RFs iFs; |
|
145 static const |
|
146 TInt iSpeeddailSupportedAssignedFieldsIndexSet[phoneNumberCount]; |
|
147 |
|
148 }; |
|
149 |
|
150 #endif // C_PDCXMLCONTENTHANDLER_H |