|
1 /* |
|
2 * Copyright (c) 2004 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: Shared basic implementation for client plug-ins. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 |
|
21 #include <CPEngAttributeStore2.h> |
|
22 #include <CPEngAttributeTransaction2.h> |
|
23 #include <CPEngAttributeListStore2.h> |
|
24 #include <CPEngAttributeListTransaction2.h> |
|
25 #include <CPEngContactListStore2.h> |
|
26 #include <CPEngContactListTransaction2.h> |
|
27 #include <CPEngNWSessionSlotID2.h> |
|
28 #include <CPEngNWSessionSlot2.h> |
|
29 #include <PEngPresenceEngineConsts2.h> |
|
30 #include <MPEngTransactionStatus2.h> |
|
31 #include <PEngWVPresenceErrors2.h> |
|
32 #include <PEngWVServices2.h> |
|
33 |
|
34 #include "CCnUiClientPluginBase.h" |
|
35 #include "IMPSPublishLevelPolicy.h" |
|
36 #include "impscommonuibuilddefinitions.h" |
|
37 |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ======================= |
|
40 |
|
41 // Destructor |
|
42 CCnUiClientPluginBase::~CCnUiClientPluginBase() |
|
43 { |
|
44 CancelAllProcessingAndCompleteIfNeeded(); |
|
45 |
|
46 delete iPEngAttributeStore; |
|
47 delete iPEngAttributeListStore; |
|
48 |
|
49 delete iPEngAttributePublisher; |
|
50 delete iPEngAttributeListPublisher; |
|
51 |
|
52 delete iPEngCntListStore; |
|
53 delete iPEngCntListPublisher; |
|
54 |
|
55 delete iNWSessionSlotID; |
|
56 } |
|
57 |
|
58 |
|
59 // C++ default constructor can NOT contain any code, that |
|
60 // might leave. |
|
61 // |
|
62 CCnUiClientPluginBase::CCnUiClientPluginBase( TIMPSConnectionClient aClientID ) |
|
63 : iClientID( aClientID ), |
|
64 iExplicitSyncNeeded( EFalse ), |
|
65 iStepProcessingActive( EFalse ) |
|
66 { |
|
67 } |
|
68 |
|
69 |
|
70 // Symbian OS default constructor can leave. |
|
71 void CCnUiClientPluginBase::ConstructL( CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
72 { |
|
73 |
|
74 // Create contact-list store & publisher |
|
75 iPEngCntListStore = CPEngContactListStore2::NewL( aNWSessionSlotID ); |
|
76 iPEngCntListPublisher = CPEngContactListTransaction2::NewL( aNWSessionSlotID ); |
|
77 |
|
78 // Create attribute-list store & publisher |
|
79 iPEngAttributeListStore = CPEngAttributeListStore2::NewL( aNWSessionSlotID ); |
|
80 iPEngAttributeListPublisher = CPEngAttributeListTransaction2::NewL( aNWSessionSlotID ); |
|
81 |
|
82 // Create attribute store & publisher |
|
83 iPEngAttributeStore = CPEngAttributeStore2::NewL( aNWSessionSlotID ); |
|
84 iPEngAttributePublisher = CPEngAttributeTransaction2::NewL( aNWSessionSlotID ); |
|
85 |
|
86 iNWSessionSlotID = aNWSessionSlotID.CloneL(); |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CCnUiClientPluginBase::ClientID() |
|
92 // From MCnUiClientPlugin API |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 TIMPSConnectionClient CCnUiClientPluginBase::ClientID() |
|
96 { |
|
97 return iClientID; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CCnUiClientPluginBase::ReleaseDynamicResources() |
|
103 // From MCnUiClientPlugin API |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CCnUiClientPluginBase::ReleaseDynamicResources() |
|
107 { |
|
108 //Cancel first possibly running processing stuffs |
|
109 CancelAllPEngPublishers(); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CCnUiClientPluginBase::ConnectionOpenInitL() |
|
115 // From MCnUiClientPlugin API |
|
116 // Connection open |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CCnUiClientPluginBase::ConnectionOpenInitL( TBool /*aSapConnectionOpen*/, |
|
120 const CIMPSSAPSettings& /*aSap*/ ) |
|
121 { |
|
122 iExplicitSyncNeeded = ETrue; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CCnUiClientPluginBase::VerifySapCapabilitiesL() |
|
127 // From MCnUiClientPlugin API |
|
128 // Connection open |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 TBool CCnUiClientPluginBase::VerifySapCapabilitiesL() |
|
132 { |
|
133 CPEngNWSessionSlot2* slot = CPEngNWSessionSlot2::NewLC( *iNWSessionSlotID ); |
|
134 TPEngWVCspServicesTree2 cspTree; |
|
135 TPckg<TPEngWVCspServicesTree2> cspTreePtr( cspTree ); |
|
136 User::LeaveIfError( slot->GetOption( KPEngWVCspServicesTree2, |
|
137 KPEngNWSessionSlotTransportQuery, |
|
138 cspTreePtr ) ); |
|
139 |
|
140 CleanupStack::PopAndDestroy( slot ); |
|
141 //let the real client to do the verification |
|
142 return DoVerifySapCapabilities( cspTree ); |
|
143 } |
|
144 |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CCnUiClientPluginBase::DoPostLoginProsessingL() |
|
148 // From MCnUiClientPlugin API |
|
149 // Connection open |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CCnUiClientPluginBase::DoPostLoginProsessingL( TRequestStatus& aStatus ) |
|
153 { |
|
154 if ( iExplicitSyncNeeded ) |
|
155 { |
|
156 //let the real client to start the processing if needed |
|
157 DoStartExplicitPostLoginSyncL(); |
|
158 if ( iStepProcessingActive ) |
|
159 { |
|
160 //processing started |
|
161 iRequest = &aStatus; |
|
162 *iRequest = KRequestPending; |
|
163 iStepProcessType = EExplicitPostLoginSync; |
|
164 } |
|
165 } |
|
166 } |
|
167 |
|
168 |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CCnUiClientPluginBase::CancelPostLoginProsessing() |
|
172 // From MCnUiClientPlugin API |
|
173 // Connection open |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CCnUiClientPluginBase::CancelPostLoginProsessing() |
|
177 { |
|
178 CancelAllProcessingAndCompleteIfNeeded(); |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CCnUiClientPluginBase::ConnectionCloseInitL() |
|
184 // From MCnUiClientPlugin API |
|
185 // Connection close |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CCnUiClientPluginBase::ConnectionCloseInitL( const CIMPSSAPSettings& /*aSap*/ ) |
|
189 { |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CCnUiClientPluginBase::DoPreLogoutProsessingL() |
|
195 // From MCnUiClientPlugin API |
|
196 // Connection close |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CCnUiClientPluginBase::DoPreLogoutProsessingL( TRequestStatus& aStatus ) |
|
200 { |
|
201 //let the real client to start the processing if needed |
|
202 DoStartPreLogoutPublishL(); |
|
203 if ( iStepProcessingActive ) |
|
204 { |
|
205 //processing started |
|
206 iRequest = &aStatus; |
|
207 *iRequest = KRequestPending; |
|
208 iStepProcessType = EPreLogoutPublish; |
|
209 } |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CCnUiClientPluginBase::CancelPreLogoutProsessing() |
|
215 // From MCnUiClientPlugin API |
|
216 // Connection close |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 void CCnUiClientPluginBase::CancelPreLogoutProsessing() |
|
220 { |
|
221 CancelAllProcessingAndCompleteIfNeeded(); |
|
222 } |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 // Callback methods for PENG publishers |
|
230 // |
|
231 // ----------------------------------------------------------------------------- |
|
232 |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CCnUiClientPluginBase::HandleContactListTransactionError() |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CCnUiClientPluginBase::HandleContactListTransactionError( |
|
239 TInt aError, |
|
240 CPEngContactListTransaction2& /*aAttributeTransaction*/, |
|
241 TInt aTransactionOperation ) |
|
242 { |
|
243 if ( aTransactionOperation == EPEngTransOpCntListBaseSync ) |
|
244 { |
|
245 HandleStepComplete( EBaseCntListSynch, aError ); |
|
246 } |
|
247 else |
|
248 { |
|
249 HandleStepComplete( ECntListPublish, aError ); |
|
250 } |
|
251 } |
|
252 |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CCnUiClientPluginBase::HandleContactListTransactionCompleteL() |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void CCnUiClientPluginBase::HandleContactListTransactionCompleteL( |
|
259 MPEngTransactionStatus2& aStatus , |
|
260 CPEngContactListTransaction2& /* aContactListTransaction */, |
|
261 TInt aTransactionOperation ) |
|
262 { |
|
263 TInt error( aStatus.Status() ); |
|
264 if ( error == KPEngNwErrPartiallySuccessful ) |
|
265 { |
|
266 // ignore partial successfull |
|
267 error = KErrNone; |
|
268 } |
|
269 User::LeaveIfError( error ); |
|
270 if ( aTransactionOperation == EPEngTransOpCntListBaseSync ) |
|
271 { |
|
272 HandleStepComplete( EBaseCntListSynch, KErrNone ); |
|
273 } |
|
274 else |
|
275 { |
|
276 HandleStepComplete( ECntListPublish, KErrNone ); |
|
277 } |
|
278 } |
|
279 |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CCnUiClientPluginBase::HandleAttributeListTransactionError() |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 void CCnUiClientPluginBase::HandleAttributeListTransactionError( |
|
286 TInt aError, |
|
287 CPEngAttributeListTransaction2& /* aAttributeTransaction */, |
|
288 TInt /* aTransactionOperation */ ) |
|
289 { |
|
290 HandleStepComplete( EAttribListPublish, aError ); |
|
291 } |
|
292 |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CCnUiClientPluginBase::HandleAttributeListTransactionCompleteL() |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CCnUiClientPluginBase::HandleAttributeListTransactionCompleteL( |
|
299 MPEngTransactionStatus2& aStatus, |
|
300 CPEngAttributeListTransaction2& /* aAttributeListTransaction */, |
|
301 TInt /* aTransactionOperation */ ) |
|
302 { |
|
303 TInt error( aStatus.Status() ); |
|
304 if ( error == KPEngNwErrPartiallySuccessful ) |
|
305 { |
|
306 // ignore partial successfull |
|
307 error = KErrNone; |
|
308 } |
|
309 User::LeaveIfError( error ); |
|
310 HandleStepComplete( EAttribListPublish, KErrNone ); |
|
311 } |
|
312 |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CCnUiClientPluginBase::HandleAttributeTransactionError() |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 void CCnUiClientPluginBase::HandleAttributeTransactionError( |
|
319 TInt aError, |
|
320 CPEngAttributeTransaction2& /* aAttributeTransaction */, |
|
321 TInt /* aTransactionOperation */ ) |
|
322 { |
|
323 HandleStepComplete( EAttributePublish, aError ); |
|
324 } |
|
325 |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CCnUiClientPluginBase::HandleAttributeTransactionCompleteL() |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 void CCnUiClientPluginBase::HandleAttributeTransactionCompleteL( |
|
332 MPEngTransactionStatus2& aStatus , |
|
333 CPEngAttributeTransaction2& /* aAttributeTransaction */, |
|
334 TInt /* aTransactionOperation */ ) |
|
335 { |
|
336 TInt error( aStatus.Status() ); |
|
337 if ( error == KPEngNwErrPartiallySuccessful ) |
|
338 { |
|
339 // ignore partial successfull |
|
340 error = KErrNone; |
|
341 } |
|
342 User::LeaveIfError( error ); |
|
343 HandleStepComplete( EAttributePublish, KErrNone ); |
|
344 } |
|
345 |
|
346 |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 // Local helpers |
|
351 // |
|
352 // ----------------------------------------------------------------------------- |
|
353 |
|
354 |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CCnUiClientPluginBase::SetActive() |
|
358 // Signalling method for derived clients |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 void CCnUiClientPluginBase::SetStepProcessingActive() |
|
362 { |
|
363 iStepProcessingActive = ETrue; |
|
364 } |
|
365 |
|
366 |
|
367 // ----------------------------------------------------------------------------- |
|
368 // CCnUiClientPluginBase::HandleStepComplete() |
|
369 // Private helper |
|
370 // Handles the step completion and lets the client continue processing if needed |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 void CCnUiClientPluginBase::HandleStepComplete( TStepId aStepId, TInt aStepStatus ) |
|
374 { |
|
375 if ( !iStepProcessingActive ) |
|
376 { |
|
377 //Error coming from some publisher cancel, e.g. |
|
378 //explicit cancel round running |
|
379 //==> nothing to do (direct return protects agains cancel nesting.) |
|
380 return; |
|
381 } |
|
382 |
|
383 |
|
384 //not active anymore |
|
385 iStepProcessingActive = EFalse; |
|
386 |
|
387 //let the derived class to handle the step completion |
|
388 TInt err = KErrNone; |
|
389 if ( iStepProcessType == EExplicitPostLoginSync ) |
|
390 { |
|
391 TRAP( err, DoHandleExplicitPostLoginSyncStepCompleteL( aStepId, aStepStatus ) ); |
|
392 } |
|
393 |
|
394 else |
|
395 { |
|
396 //EPreLogoutPublish |
|
397 TRAP( err, DoHandlePreLogoutPublishStepCompleteL( aStepId, aStepStatus ) ); |
|
398 } |
|
399 |
|
400 if ( err != KErrNone ) |
|
401 { |
|
402 //if starting failed, complete away with catched error.. |
|
403 iStepProcessingActive = EFalse; |
|
404 aStepStatus = err; |
|
405 } |
|
406 |
|
407 |
|
408 if ( !iStepProcessingActive ) |
|
409 { |
|
410 //No active processing anymore |
|
411 |
|
412 //cancel still possibly existing processing |
|
413 CancelAllPEngPublishers(); |
|
414 |
|
415 //and complete the original request |
|
416 User::RequestComplete( iRequest, aStepStatus ); |
|
417 } |
|
418 } |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CCnUiClientPluginBase::CancelAllProcessingAndCompleteIfNeeded() |
|
425 // |
|
426 // ----------------------------------------------------------------------------- |
|
427 // |
|
428 void CCnUiClientPluginBase::CancelAllProcessingAndCompleteIfNeeded() |
|
429 { |
|
430 //not definitely active anymore |
|
431 iStepProcessingActive = EFalse; |
|
432 |
|
433 //cancel all sub precessing parts |
|
434 CancelAllPEngPublishers(); |
|
435 |
|
436 //and complete the original request if still having one |
|
437 if ( iRequest ) |
|
438 { |
|
439 User::RequestComplete( iRequest, KErrCancel ); |
|
440 } |
|
441 } |
|
442 |
|
443 |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CCnUiClientPluginBase::CancelAllPEngPublishers() |
|
447 // Private helper |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 void CCnUiClientPluginBase::CancelAllPEngPublishers() |
|
451 { |
|
452 // nothing done here at the moment |
|
453 } |
|
454 |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CCnUiClientPluginBase::LoginCancelledL() |
|
458 // Private helper |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 void CCnUiClientPluginBase::LoginCancelledL() |
|
462 { |
|
463 // empty implementation |
|
464 } |
|
465 |
|
466 |
|
467 // End of File |
|
468 |