|
1 /* |
|
2 * Copyright (c) 2006-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: Exporting the contact field from contact to |
|
15 * CParserProperty field |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CVPBKVCARDPROPERTYEXPORTER_H |
|
21 #define CVPBKVCARDPROPERTYEXPORTER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include "TVPbkFieldVersitProperty.h" |
|
25 #include "CVPbkVCardActiveIncremental.h" |
|
26 #include <MVPbkSingleContactOperationObserver.h> |
|
27 #include "CVPbkOwnCardHandler.h" |
|
28 #include "CVPbkGroupCardHandler.h" |
|
29 |
|
30 #include <e32base.h> |
|
31 #include <badesca.h> |
|
32 |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CParserVCard; |
|
36 class MVPbkStoreContact; |
|
37 class CVPbkVCardFieldTypeProperty; |
|
38 class CVPbkVCardIdNameMapping; |
|
39 class MVPbkFieldTypeList; |
|
40 class CParserPropertyValue; |
|
41 class CVPbkVCardParserParamArray; |
|
42 class MVPbkBaseContactField; |
|
43 class TVPbkVCardIndexedProperty; |
|
44 class RWriteStream; |
|
45 class MVPbkContactLink; |
|
46 class CVPbkContactManager; |
|
47 class MVPbkStoreContactField; |
|
48 class CParserVCard; |
|
49 |
|
50 // CLASS DECLARATIONS |
|
51 /** |
|
52 * Class is exporting the contact field from contact to |
|
53 * CParserProperty field |
|
54 */ |
|
55 NONSHARABLE_CLASS(CVPbkVCardPropertyExporter) |
|
56 : public CVPbkVCardActiveIncremental, |
|
57 public MVPbkVCardIncremental, |
|
58 public MVPbkSingleContactOperationObserver |
|
59 { |
|
60 public: |
|
61 /** |
|
62 * Create new instance of this class. |
|
63 */ |
|
64 static CVPbkVCardPropertyExporter* NewLC( |
|
65 CVPbkVCardData& aData, |
|
66 const MVPbkStoreContact* aSourceItem, |
|
67 RWriteStream& aDestStream, |
|
68 MVPbkSingleContactOperationObserver& aObserver, |
|
69 const TBool aBeamed); |
|
70 |
|
71 static CVPbkVCardPropertyExporter* NewLC( |
|
72 CVPbkVCardData& aData, |
|
73 RWriteStream& aDestStream, |
|
74 MVPbkSingleContactOperationObserver& aObserver, |
|
75 const TBool aBeamed); |
|
76 |
|
77 ~CVPbkVCardPropertyExporter(); |
|
78 |
|
79 protected: // From MVPbkVCardIncremental |
|
80 |
|
81 virtual TInt Next(TInt& aRemainingSteps); |
|
82 virtual void CloseL(); |
|
83 virtual void HandleLeave(TInt aError); |
|
84 virtual void HandleCancel(); |
|
85 |
|
86 protected: // From MVPbkContactOperation |
|
87 |
|
88 virtual void StartL(); |
|
89 |
|
90 private: |
|
91 CVPbkVCardPropertyExporter( |
|
92 CVPbkVCardData& aData, |
|
93 const MVPbkStoreContact* aSourceItem, |
|
94 RWriteStream& aDestStream, |
|
95 MVPbkSingleContactOperationObserver& aObserver, |
|
96 const TBool aBeamed); |
|
97 |
|
98 CVPbkVCardPropertyExporter( |
|
99 CVPbkVCardData& aData, |
|
100 RWriteStream& aDestStream, |
|
101 MVPbkSingleContactOperationObserver& aObserver, |
|
102 const TBool aBeamed); |
|
103 |
|
104 void ConstructL(CVPbkVCardData& aData); |
|
105 |
|
106 public: // New functions |
|
107 |
|
108 void InitLinkL( |
|
109 const MVPbkContactLink& aContactLink, |
|
110 CVPbkContactManager& aContactManager ); |
|
111 |
|
112 public: // From MVPbkSingleContactOperationObserver |
|
113 |
|
114 void VPbkSingleContactOperationComplete( |
|
115 MVPbkContactOperationBase& aOperation, |
|
116 MVPbkStoreContact* aContact); |
|
117 |
|
118 void VPbkSingleContactOperationFailed |
|
119 (MVPbkContactOperationBase& aOperation, TInt aError); |
|
120 |
|
121 private: |
|
122 void ExportFieldL( CVPbkVCardFieldTypeProperty& aVCardProperty ); |
|
123 |
|
124 void GetValuesFromIndexedPropertiesL( TBool aSingleItem ); |
|
125 |
|
126 TBool GetSingleValueAndParamsL( |
|
127 const TVPbkVCardIndexedProperty& aIndexedProperty, |
|
128 CVPbkVCardParserParamArray& aParamArray, |
|
129 TInt& aFindIndex ); |
|
130 |
|
131 MVPbkStoreContactField* |
|
132 FindFieldFromContact( |
|
133 const TVPbkVCardIndexedProperty& aIndexedProperty, |
|
134 TInt& aIndex ); |
|
135 |
|
136 CParserPropertyValue* FetchDataFromFieldL( |
|
137 MVPbkStoreContactField&, |
|
138 CVPbkVCardParserParamArray& aParameters ); |
|
139 |
|
140 TBool AddPropertyToParserL( RPointerArray< CParserPropertyValue >& aValues, |
|
141 CVPbkVCardParserParamArray* aParams); |
|
142 |
|
143 TBool HasValues(); |
|
144 |
|
145 CParserPropertyValue* GetExportTextValueL( |
|
146 const MVPbkBaseContactField& aField); |
|
147 |
|
148 CParserPropertyValue* GetExportUriValueL( |
|
149 const MVPbkBaseContactField& aField); |
|
150 |
|
151 CParserPropertyValue* GetExportDateValueL( |
|
152 const MVPbkBaseContactField& aField); |
|
153 |
|
154 CParserPropertyValue* GetExportBinaryValueL( |
|
155 const MVPbkBaseContactField& aField, |
|
156 CVPbkVCardParserParamArray& aParameters ); |
|
157 |
|
158 TBool ContainsValidTextualDataL(const TDesC& aDataText) const; |
|
159 |
|
160 void GetAdditionalParamsL( |
|
161 MVPbkStoreContactField& aField, CVPbkVCardParserParamArray& aParams ); |
|
162 |
|
163 CParserPropertyValue* GetValueL( |
|
164 RPointerArray< CParserPropertyValue >& aValues); |
|
165 |
|
166 void InitDataL(); |
|
167 |
|
168 void DoNextL(); |
|
169 void HandleOwnCardL(); |
|
170 void HandleGroupCardL(); |
|
171 |
|
172 private: |
|
173 CParserVCard* iParser; |
|
174 /// Own: Array of property values |
|
175 RPointerArray< CParserPropertyValue > iValues; |
|
176 /// Ref: Current VCard property |
|
177 CVPbkVCardFieldTypeProperty* iVCardProperty; |
|
178 /// Ref: Source contact |
|
179 const MVPbkStoreContact* iContact; |
|
180 /// Ref: Destination stream |
|
181 RWriteStream& iDestinationStream; |
|
182 /// Own: Internal index for execution loop |
|
183 TInt iCurrentPropertyIndex; |
|
184 /// Own: Maximum property count |
|
185 TInt iMaxPropertyCount; |
|
186 /// Own: The source contact which is owned by exporter |
|
187 MVPbkStoreContact* iOwnedContact; |
|
188 /// Own: The last operation executed |
|
189 MVPbkContactOperationBase* iOperation; |
|
190 /// Own: Internal state of the class |
|
191 enum TVPbkVCardExporterState |
|
192 { |
|
193 ECreatingRetriever, |
|
194 EExporting |
|
195 } iState; |
|
196 |
|
197 // Ref: Array to hold those fields masked during a beamed export |
|
198 const CDesC8ArrayFlat* iMaskedFieldsArray; |
|
199 |
|
200 // ETrue if the current orperation is a beamed export, otherwise EFalse |
|
201 const TBool iBeamed; |
|
202 CVPbkOwnCardHandler* iOwncardHandler; |
|
203 //Own: GroupCard Handler |
|
204 CVPbkGroupCardHandler* iGroupcardHandler; |
|
205 }; |
|
206 |
|
207 #endif // CVPBKVCARDPROPERTYEXPORTER_H |
|
208 |
|
209 // End of file |