|
1 /* |
|
2 * Copyright (c) 2005 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: Handler to create contact list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPEngContactListTransCreate.h" |
|
21 |
|
22 #include "CPEngContactListModItemContainer.h" |
|
23 #include "CPEngContactListSettings.h" |
|
24 #include "MPEngContactListTransactionManager.h" |
|
25 |
|
26 #include "PEngListLibTools.h" |
|
27 #include "MPEngXMLSerializer.h" |
|
28 #include "MPEngXMLParser.h" |
|
29 |
|
30 #include "CPEngTransactionStatus.h" |
|
31 #include "PEngWVPresenceErrors2.h" |
|
32 #include "PresenceDebugPrint.h" |
|
33 |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CPEngContactListTransCreate::CPEngContactListTransCreate() |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CPEngContactListTransCreate::CPEngContactListTransCreate( |
|
42 CPEngContactListModBase& aContactList, |
|
43 CPEngSessionSlotId& aSessionSlotId, |
|
44 MPEngContactListTransactionManager& aManager, |
|
45 TPEngWVCspVersion& aCSPVersion, |
|
46 TInt aOperationId ) |
|
47 : CPEngContactListTransBase( aContactList, |
|
48 aSessionSlotId, |
|
49 aManager, |
|
50 aCSPVersion, |
|
51 aOperationId ) |
|
52 { |
|
53 PENG_DP( D_PENG_LIT( "PEngContactListTransCreate::CPEngContactListTransCreate() [%S]" ), |
|
54 &( iContactList.ListProperties().Name() ) ); |
|
55 } |
|
56 |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CPEngContactListTransCreate::ConstructL() |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void CPEngContactListTransCreate::ConstructL( ) |
|
63 { |
|
64 CPEngContactListTransBase::ConstructL( ); |
|
65 iContactListSyncState = EPEngCntListCreate; |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CPEngStartSyncTransaction::NewLC() |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CPEngContactListTransCreate* CPEngContactListTransCreate::NewLC( |
|
74 CPEngContactListModBase& aContactList, |
|
75 CPEngSessionSlotId& aSessionSlotId, |
|
76 MPEngContactListTransactionManager& aManager, |
|
77 TPEngWVCspVersion& aCSPVersion, |
|
78 TInt aOperationId ) |
|
79 { |
|
80 CPEngContactListTransCreate* self = |
|
81 new ( ELeave ) CPEngContactListTransCreate( aContactList, |
|
82 aSessionSlotId, |
|
83 aManager, |
|
84 aCSPVersion, |
|
85 aOperationId ); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 return self; |
|
89 } |
|
90 |
|
91 |
|
92 // Destructor |
|
93 CPEngContactListTransCreate::~CPEngContactListTransCreate() |
|
94 { |
|
95 } |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CPEngContactListTransCreate::DoGetXMLCreateCntListL() |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CPEngContactListTransCreate::DoGetXMLCreateCntListL( |
|
103 MPEngXMLSerializer& aXmlSerializer ) |
|
104 { |
|
105 // <CreateList-Request> |
|
106 aXmlSerializer.StartTagL( KCreateList ); |
|
107 |
|
108 NListLibTools::AppendContactListNameXmlL( aXmlSerializer, |
|
109 iContactList.Settings() ); |
|
110 |
|
111 TInt count( iContactList.Count() ); |
|
112 if ( count != 0 ) |
|
113 { |
|
114 // <NickList> |
|
115 aXmlSerializer.StartTagL( KNickList ); |
|
116 |
|
117 for ( TInt x( 0 ); x < count ; x++ ) |
|
118 { |
|
119 MPEngContactItem& contactItem = iContactList.ContactItem( x ); |
|
120 |
|
121 // <NickName> |
|
122 // <Name> |
|
123 aXmlSerializer.StartTagL( KNickName |
|
124 ).StartTagL( KName ); |
|
125 |
|
126 // Nick name |
|
127 // </Name> |
|
128 aXmlSerializer.UnicodeTextL( contactItem.NickName() |
|
129 ).EndTagL( KName ); |
|
130 |
|
131 // <UserID> |
|
132 // contact Id |
|
133 // </UserID> |
|
134 // </NickName> |
|
135 aXmlSerializer.StartTagL( KUserIDXMLTag |
|
136 ).WvAddressL( contactItem.Id() |
|
137 ).EndTagL( KUserIDXMLTag |
|
138 ).EndTagL( KNickName ); |
|
139 } |
|
140 // </NickList> |
|
141 aXmlSerializer.EndTagL( KNickList ); |
|
142 } |
|
143 |
|
144 // add properties of the contact list |
|
145 NListLibTools::AppendContactListPropertiesXmlL( aXmlSerializer, |
|
146 iContactList.Settings() ); |
|
147 |
|
148 // </CreateList-Request> |
|
149 aXmlSerializer.EndTagL( KCreateList ); |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CPEngContactListTransCreate::DoParseCreateCntListResponseL() |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CPEngContactListTransCreate::DoParseCreateCntListResponseL( |
|
158 const TDesC8& aResponse, |
|
159 MPEngXMLParser& aXMLparser ) |
|
160 { |
|
161 PENG_DP( D_PENG_LIT( "PEngContactListTransCreate::DoParseCreateCntListResponseL() [%S]" ), |
|
162 &( iContactList.ListProperties().Name() ) ); |
|
163 |
|
164 CPEngTransactionStatus* transactionStatus = CPEngTransactionStatus::NewL(); |
|
165 |
|
166 CleanupClosePushL( *transactionStatus ); |
|
167 TInt err ( aXMLparser.ParseContactListResultL( aResponse, |
|
168 iOperationId, |
|
169 iContactList.StorageId(), |
|
170 *transactionStatus ) ); |
|
171 |
|
172 switch ( err ) |
|
173 { |
|
174 // parse KErrNone and partial success in same way |
|
175 case KErrNone: |
|
176 case KPEngNwErrPartiallySuccessful: |
|
177 { |
|
178 MPEngXMLParser* secondXMLparser = CreateXMLParserLC(); |
|
179 |
|
180 RReffArray<CPEngContactListModItemContainer> newContacts; |
|
181 CleanupClosePushL( newContacts ); |
|
182 |
|
183 if ( NListLibTools::ParseContactListNickListL( aResponse, |
|
184 newContacts, |
|
185 iContactList, |
|
186 aXMLparser, |
|
187 *secondXMLparser, |
|
188 ETrue ) ) |
|
189 { |
|
190 iContactList.AdoptNewContactsL( newContacts ); |
|
191 } |
|
192 else |
|
193 { |
|
194 // nick list was not there, consume result manually |
|
195 // commit changes and parse wrong IDs if any |
|
196 iContactList.CommitRemoveContactsL(); |
|
197 iContactList.CommitAddContactsL(); |
|
198 NListLibTools::RemoveBadContactsL( *transactionStatus, iContactList ); |
|
199 } |
|
200 |
|
201 CleanupStack::PopAndDestroy( ); // newContacts |
|
202 NListLibTools::ParseContactListPropertiesL( aResponse, |
|
203 iContactList.Settings(), |
|
204 aXMLparser, |
|
205 *secondXMLparser ); |
|
206 CleanupStack::PopAndDestroy(); // secondXMLparser |
|
207 |
|
208 |
|
209 // update behavior |
|
210 iContactList.Settings().SetPropertyL( KPEngListExistsOnServer, |
|
211 KPEngCntLstPropertyNativeCached, |
|
212 ETrue ); |
|
213 |
|
214 // if this was to be new default contact list, do update |
|
215 NListLibTools::HarmonizeDefaultContactListSettingsL( iContactList.Settings(), |
|
216 iManager ); |
|
217 |
|
218 |
|
219 // resolve next step - do we need to subscribe this lists |
|
220 if ( iContactList.Settings().Property( KPEngCntLstSubscribe, |
|
221 KPEngCntLstPropertyNativePermanent ) ) |
|
222 { |
|
223 iContactListSyncState = EPEngSubscribeCntList; |
|
224 } |
|
225 else |
|
226 { |
|
227 CompleteCntListTransactionL(); |
|
228 } |
|
229 break; |
|
230 } |
|
231 |
|
232 |
|
233 case KPEngNwErrUnknownUser: |
|
234 { |
|
235 // remove all contact ids and repeat creation of the contact list |
|
236 TInt count ( iContactList.Count() - 1 ); |
|
237 for ( ; count >= 0 ; --count ) |
|
238 { |
|
239 // add bad contact it to the transaction status |
|
240 TPtrC badContactId( iContactList.ContactItem( count ).Id() ); |
|
241 |
|
242 iTransactionStatus->AddDetailedResultL( iOperationId, |
|
243 KPEngNwErrUnknownUser, |
|
244 NULL, |
|
245 &badContactId, |
|
246 &( iContactList.StorageId() ), |
|
247 NULL ); |
|
248 iContactList.RemoveBadContactL( badContactId ); |
|
249 } |
|
250 break; |
|
251 } |
|
252 |
|
253 |
|
254 default: |
|
255 { |
|
256 iManager.CompleteCntListDeletionL( iContactList.Settings().Name() ); |
|
257 iContactListSyncState = EPEngTransactionCompleted; |
|
258 break; |
|
259 } |
|
260 } |
|
261 |
|
262 // update transaction status |
|
263 iTransactionStatus->ImportStatusFrom( *transactionStatus ); |
|
264 CleanupStack::Pop(); // transactionStatus |
|
265 } |
|
266 |
|
267 |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CPEngContactListTransCreate::DoGetXMLFetchCntListL() |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CPEngContactListTransCreate::DoGetXMLFetchCntListL( |
|
274 MPEngXMLSerializer& /*aXmlSerializer*/ ) |
|
275 { |
|
276 } |
|
277 |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CPEngContactListTransCreate::DoParseFetchCntListResponseL() |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CPEngContactListTransCreate::DoParseFetchCntListResponseL( |
|
284 const TDesC8& /*aResponse*/, |
|
285 MPEngXMLParser& /*aXMLparser*/ ) |
|
286 { |
|
287 } |
|
288 |
|
289 |
|
290 // End of File |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |