|
1 /* |
|
2 * Copyright (c) 2005-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: Phonebook 2 application server item fetcher. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2ItemFetcher.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "MPbk2UiServiceObserver.h" |
|
23 #include "TPbk2ServerMessageDataRetriever.h" |
|
24 #include "CPbk2ServerAppAppUi.h" |
|
25 #include "TPbk2TitlePaneOperator.h" |
|
26 #include "CPbk2ServerAppStoreManager.h" |
|
27 #include "CPbk2ContactFetchPhase.h" |
|
28 #include "CPbk2AddressSelectPhase.h" |
|
29 #include <CPbk2StoreManager.h> |
|
30 #include <Pbk2UIControls.rsg> |
|
31 #include <TPbk2AddressSelectParams.h> |
|
32 #include <Pbk2IPCPackage.h> |
|
33 #include <MPbk2ApplicationServices.h> |
|
34 #include "CPbk2CommAddressSelectPhase.h" |
|
35 |
|
36 // Virtual Phonebook |
|
37 #include <CVPbkContactManager.h> |
|
38 #include <CVPbkContactStoreUriArray.h> |
|
39 #include <MVPbkContactLink.h> |
|
40 #include <MVPbkStoreContact.h> |
|
41 #include <CVPbkFieldTypeSelector.h> |
|
42 #include <MVPbkContactStore.h> |
|
43 #include <MVPbkStoreContact.h> |
|
44 #include <TVPbkContactStoreUriPtr.h> |
|
45 |
|
46 // System includes |
|
47 #include <avkon.rsg> |
|
48 #include <spsettings.h> |
|
49 #include <spproperty.h> |
|
50 |
|
51 // Debug |
|
52 #include <Pbk2Debug.h> |
|
53 |
|
54 /// Unnamed namespace for local definitions |
|
55 namespace { |
|
56 |
|
57 /** |
|
58 * Sets title pane. |
|
59 * |
|
60 * @param aDataRetriever Server message data retriever. |
|
61 * @param aFlags Fetch flags. |
|
62 * @param aMessage Server message. |
|
63 */ |
|
64 void SetTitlePaneL |
|
65 ( TPbk2ServerMessageDataRetriever& aDataRetriever, TUint aFlags, |
|
66 const RMessage2& aMessage ) |
|
67 { |
|
68 HBufC* titlePaneText = NULL; |
|
69 if ( !( aFlags & ::EUseProviderTitle ) ) |
|
70 { |
|
71 titlePaneText = aDataRetriever.GetTitlePaneTextL( aMessage ); |
|
72 } |
|
73 TPbk2TitlePaneOperator titlePaneOperator; |
|
74 titlePaneOperator.SetTitlePaneL( titlePaneText ); // takes ownership |
|
75 } |
|
76 |
|
77 struct TMap |
|
78 { |
|
79 TAiwCommAddressSelectType aiwType; |
|
80 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector selectorType; |
|
81 }; |
|
82 |
|
83 const TMap KAiwMapTable[] = { |
|
84 { EAiwCommEmpty, VPbkFieldTypeSelectorFactory::EEmptySelector }, |
|
85 { EAiwCommVoiceCall, VPbkFieldTypeSelectorFactory::EVoiceCallSelector }, |
|
86 { EAiwCommUniEditor, VPbkFieldTypeSelectorFactory::EUniEditorSelector }, |
|
87 { EAiwCommEmailEditor, VPbkFieldTypeSelectorFactory::EEmailEditorSelector }, |
|
88 { EAiwCommInstantMessaging, VPbkFieldTypeSelectorFactory::EInstantMessagingSelector }, |
|
89 { EAiwCommVOIPCall, VPbkFieldTypeSelectorFactory::EVOIPCallSelector }, |
|
90 { EAiwCommURL, VPbkFieldTypeSelectorFactory::EURLSelector }, |
|
91 { EAiwCommVideoCall, VPbkFieldTypeSelectorFactory::EVideoCallSelector } |
|
92 }; |
|
93 const TInt KAiwMapTableLength = sizeof( KAiwMapTable ) / sizeof( TMap ); |
|
94 |
|
95 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector |
|
96 MapToCommSelectorType( TAiwCommAddressSelectType aAiwType ) |
|
97 { |
|
98 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector selector = |
|
99 VPbkFieldTypeSelectorFactory::EEmptySelector; |
|
100 for( TInt i = 0; i < KAiwMapTableLength; i++ ) |
|
101 { |
|
102 if( aAiwType == KAiwMapTable[i].aiwType) |
|
103 { |
|
104 selector = KAiwMapTable[i].selectorType; |
|
105 break; |
|
106 } |
|
107 } |
|
108 |
|
109 return selector; |
|
110 } |
|
111 |
|
112 CVPbkFieldTypeSelector* BuildFilterL( |
|
113 TAiwAddressSelectType aType, |
|
114 const MVPbkFieldTypeList& aFieldTypeList ) |
|
115 { |
|
116 CVPbkFieldTypeSelector* selector = NULL; |
|
117 |
|
118 switch( aType ) |
|
119 { |
|
120 case EAiwMMSSelect: |
|
121 { |
|
122 selector = VPbkFieldTypeSelectorFactory:: |
|
123 BuildContactActionTypeSelectorL( |
|
124 VPbkFieldTypeSelectorFactory::EUniEditorSelector, |
|
125 aFieldTypeList ); |
|
126 break; |
|
127 } |
|
128 case EAiwEMailSelect: |
|
129 { |
|
130 selector = VPbkFieldTypeSelectorFactory:: |
|
131 BuildContactActionTypeSelectorL( |
|
132 VPbkFieldTypeSelectorFactory::EEmailEditorSelector, |
|
133 aFieldTypeList ); |
|
134 break; |
|
135 } |
|
136 case EAiwVideoNumberSelect: |
|
137 { |
|
138 selector = VPbkFieldTypeSelectorFactory:: |
|
139 BuildContactActionTypeSelectorL( |
|
140 VPbkFieldTypeSelectorFactory::EVideoCallSelector, |
|
141 aFieldTypeList ); |
|
142 break; |
|
143 } |
|
144 case EAiwVOIPSelect: |
|
145 { |
|
146 selector = VPbkFieldTypeSelectorFactory:: |
|
147 BuildContactActionTypeSelectorL( |
|
148 VPbkFieldTypeSelectorFactory::EVOIPCallSelector, |
|
149 aFieldTypeList ); |
|
150 } |
|
151 break; |
|
152 default: |
|
153 break; |
|
154 } |
|
155 |
|
156 return selector; |
|
157 } |
|
158 |
|
159 #ifdef _DEBUG |
|
160 |
|
161 enum TPanicCode |
|
162 { |
|
163 EPanicLogicPhaseCompletion = 1 |
|
164 }; |
|
165 |
|
166 void Panic( TPanicCode aReason ) |
|
167 { |
|
168 _LIT( KPanicText, "CPbk2ItemFetcher" ); |
|
169 User::Panic( KPanicText, aReason ); |
|
170 } |
|
171 |
|
172 #endif // _DEBUG |
|
173 |
|
174 } /// namespace |
|
175 |
|
176 |
|
177 // -------------------------------------------------------------------------- |
|
178 // CPbk2ItemFetcher::CPbk2ItemFetcher |
|
179 // -------------------------------------------------------------------------- |
|
180 // |
|
181 CPbk2ItemFetcher::CPbk2ItemFetcher |
|
182 ( MPbk2UiServiceObserver& aObserver, |
|
183 TPbk2FetchType aFetchType ) : |
|
184 iObserver( aObserver ), |
|
185 iFetchType( aFetchType ) |
|
186 { |
|
187 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
188 ("CPbk2ItemFetcher::CPbk2ItemFetcher()") ); |
|
189 } |
|
190 |
|
191 // -------------------------------------------------------------------------- |
|
192 // CPbk2ItemFetcher::~CPbk2ItemFetcher |
|
193 // -------------------------------------------------------------------------- |
|
194 // |
|
195 CPbk2ItemFetcher::~CPbk2ItemFetcher() |
|
196 { |
|
197 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
198 ("CPbk2ItemFetcher::~CPbk2ItemFetcher()") ); |
|
199 |
|
200 delete iStoreUris; |
|
201 delete iContactFetchStoreUris; |
|
202 delete iPreselectedContacts; |
|
203 delete iContactViewFilter; |
|
204 iDefaultPriorities.Close(); |
|
205 delete iStoreManager; |
|
206 delete iFetchPhase; |
|
207 delete iAddressSelectPhase; |
|
208 delete iCommAddressSelectPhase; |
|
209 } |
|
210 |
|
211 // -------------------------------------------------------------------------- |
|
212 // CPbk2ItemFetcher::NewL |
|
213 // -------------------------------------------------------------------------- |
|
214 // |
|
215 CPbk2ItemFetcher* CPbk2ItemFetcher::NewL |
|
216 ( const RMessage2& aFetchCompleteMessage, |
|
217 MPbk2UiServiceObserver& aObserver, |
|
218 TPbk2FetchType aFetchType ) |
|
219 { |
|
220 CPbk2ItemFetcher* self = |
|
221 new ( ELeave ) CPbk2ItemFetcher( aObserver, aFetchType ); |
|
222 CleanupStack::PushL( self ); |
|
223 self->ConstructL( aFetchCompleteMessage ); |
|
224 CleanupStack::Pop( self ); |
|
225 return self; |
|
226 } |
|
227 |
|
228 // -------------------------------------------------------------------------- |
|
229 // CPbk2ItemFetcher::ConstructL |
|
230 // -------------------------------------------------------------------------- |
|
231 // |
|
232 inline void CPbk2ItemFetcher::ConstructL( const RMessage2& aMessage ) |
|
233 { |
|
234 // Retrieve data from the client-server message |
|
235 CPbk2ServerAppAppUi& appUi = |
|
236 static_cast<CPbk2ServerAppAppUi&>(*CEikonEnv::Static()->EikAppUi()); |
|
237 |
|
238 TPbk2ServerMessageDataRetriever dataRetriever; |
|
239 TUint flags = dataRetriever.FetchFlagsL( aMessage ); |
|
240 |
|
241 // Set title pane |
|
242 SetTitlePaneL( dataRetriever, flags, aMessage ); |
|
243 |
|
244 iPreselectedContacts = dataRetriever.GetPreselectedContactLinksL |
|
245 ( aMessage, appUi.ApplicationServices().ContactManager() ); |
|
246 iStoreUris = dataRetriever.GetContactStoreUriArrayL |
|
247 ( aMessage, appUi.ApplicationServices().StoreConfiguration(), |
|
248 iPreselectedContacts, iUseDeviceConfig ); |
|
249 |
|
250 // Contact fetch store uris, not including xSP stores |
|
251 iContactFetchStoreUris = CVPbkContactStoreUriArray::NewL(); |
|
252 iContactFetchStoreUris->AppendAllL(*iStoreUris); |
|
253 |
|
254 TAiwCommAddressSelectType selectorType = |
|
255 dataRetriever.GetCommAddressSelectTypeL( aMessage ); |
|
256 iCommAddressSelectType = MapToCommSelectorType( selectorType ); |
|
257 |
|
258 iAddressSelectType = dataRetriever.GetAddressSelectTypeL( aMessage ); |
|
259 |
|
260 // Create contact filters |
|
261 if ( iCommAddressSelectType != VPbkFieldTypeSelectorFactory::EEmptySelector ) |
|
262 { |
|
263 iContactViewFilter = VPbkFieldTypeSelectorFactory:: |
|
264 BuildContactActionTypeSelectorL( iCommAddressSelectType, |
|
265 appUi.ApplicationServices().ContactManager().FieldTypes() ); |
|
266 } |
|
267 // Phonebook specific filters take prefference over the |
|
268 // filter specified by client |
|
269 else |
|
270 { |
|
271 iContactViewFilter = BuildFilterL( iAddressSelectType, |
|
272 appUi.ApplicationServices().ContactManager().FieldTypes() ); |
|
273 |
|
274 // Filter specified by client |
|
275 if ( iContactViewFilter == NULL ) |
|
276 { |
|
277 iContactViewFilter = dataRetriever.GetContactViewFilterL |
|
278 ( aMessage, appUi.ApplicationServices().ContactManager(). |
|
279 FieldTypes() ); |
|
280 } |
|
281 } |
|
282 |
|
283 iFetchResId = dataRetriever.GetFetchDialogResourceL( aMessage ); |
|
284 |
|
285 iStoreManager = CPbk2ServerAppStoreManager::NewL |
|
286 ( appUi.StoreManager(), |
|
287 appUi.ApplicationServices().ContactManager() ); |
|
288 |
|
289 if ( iCommAddressSelectType != VPbkFieldTypeSelectorFactory::EEmptySelector ) |
|
290 { |
|
291 GetDefaultPriorities( flags ); |
|
292 } |
|
293 else |
|
294 { |
|
295 iDefaultPriorities = dataRetriever.FetchDefaultPrioritiesL( aMessage ); |
|
296 } |
|
297 |
|
298 if ( iCommAddressSelectType != VPbkFieldTypeSelectorFactory::EEmptySelector ) |
|
299 { |
|
300 // add also xSP stores to the store list |
|
301 AddXSPStoresL(); |
|
302 } |
|
303 } |
|
304 |
|
305 // -------------------------------------------------------------------------- |
|
306 // CPbk2ItemFetcher::LaunchServiceL |
|
307 // -------------------------------------------------------------------------- |
|
308 // |
|
309 void CPbk2ItemFetcher::LaunchServiceL() |
|
310 { |
|
311 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
312 ("CPbk2ItemFetcher::LaunchServiceL()") ); |
|
313 |
|
314 iStoreManager->LoadAndOpenContactStoresL( *iStoreUris, *this, EFalse ); |
|
315 } |
|
316 |
|
317 // -------------------------------------------------------------------------- |
|
318 // CPbk2ItemFetcher::CancelService |
|
319 // -------------------------------------------------------------------------- |
|
320 // |
|
321 void CPbk2ItemFetcher::CancelService() |
|
322 { |
|
323 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
324 ("CPbk2ItemFetcher::CancelService()") ); |
|
325 |
|
326 if ( iFetchPhase ) |
|
327 { |
|
328 iFetchPhase->CancelServicePhase(); |
|
329 } |
|
330 |
|
331 if ( iAddressSelectPhase ) |
|
332 { |
|
333 iAddressSelectPhase->CancelServicePhase(); |
|
334 } |
|
335 |
|
336 if ( iCommAddressSelectPhase ) |
|
337 { |
|
338 iCommAddressSelectPhase->CancelServicePhase(); |
|
339 } |
|
340 } |
|
341 |
|
342 // -------------------------------------------------------------------------- |
|
343 // CPbk2ItemFetcher::AcceptDelayedContactsL |
|
344 // -------------------------------------------------------------------------- |
|
345 // |
|
346 void CPbk2ItemFetcher::AcceptDelayedContactsL |
|
347 ( const TDesC8& aContactLinkBuffer ) |
|
348 { |
|
349 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
350 ("CPbk2ItemFetcher::AcceptDelayedContactsL()") ); |
|
351 |
|
352 if ( iAddressSelectPhase ) |
|
353 { |
|
354 iAddressSelectPhase->AcceptDelayedL( aContactLinkBuffer ); |
|
355 } |
|
356 |
|
357 if ( iCommAddressSelectPhase ) |
|
358 { |
|
359 iCommAddressSelectPhase->AcceptDelayedL( aContactLinkBuffer ); |
|
360 } |
|
361 |
|
362 if ( iFetchPhase ) |
|
363 { |
|
364 iFetchPhase->AcceptDelayedL( aContactLinkBuffer ); |
|
365 } |
|
366 } |
|
367 |
|
368 // -------------------------------------------------------------------------- |
|
369 // CPbk2ItemFetcher::ExitServiceL |
|
370 // -------------------------------------------------------------------------- |
|
371 // |
|
372 void CPbk2ItemFetcher::ExitServiceL( TInt aExitCommandId ) |
|
373 { |
|
374 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
375 ("CPbk2ItemFetcher::ExitServiceL(%d)"), aExitCommandId ); |
|
376 |
|
377 if ( iAddressSelectPhase ) |
|
378 { |
|
379 iAddressSelectPhase->RequestCancelL( aExitCommandId ); |
|
380 |
|
381 // Report fetch aborting and close application |
|
382 iObserver.ServiceAborted(); |
|
383 } |
|
384 |
|
385 if ( iCommAddressSelectPhase ) |
|
386 { |
|
387 iCommAddressSelectPhase->RequestCancelL( aExitCommandId ); |
|
388 |
|
389 // Report fetch aborting and close application |
|
390 iObserver.ServiceAborted(); |
|
391 } |
|
392 |
|
393 if ( iFetchPhase ) |
|
394 { |
|
395 iFetchPhase->RequestCancelL( aExitCommandId ); |
|
396 } |
|
397 } |
|
398 |
|
399 // -------------------------------------------------------------------------- |
|
400 // CPbk2ItemFetcher::ServiceResults |
|
401 // -------------------------------------------------------------------------- |
|
402 // |
|
403 void CPbk2ItemFetcher::ServiceResults(TServiceResults* aResults) const |
|
404 { |
|
405 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
406 ("CPbk2ItemFetcher::ServiceResults()") ); |
|
407 |
|
408 if ( iAddressSelectPhase ) |
|
409 { |
|
410 aResults->iLinkArray = iAddressSelectPhase->Results(); |
|
411 aResults->iExtraData = iAddressSelectPhase->ExtraResultData(); |
|
412 aResults->iFieldContent = NULL; |
|
413 } |
|
414 |
|
415 if ( iCommAddressSelectPhase ) |
|
416 { |
|
417 aResults->iLinkArray = iCommAddressSelectPhase->Results(); |
|
418 aResults->iExtraData = iCommAddressSelectPhase->ExtraResultData(); |
|
419 aResults->iFieldContent = iCommAddressSelectPhase->FieldContent(); |
|
420 } |
|
421 } |
|
422 |
|
423 // -------------------------------------------------------------------------- |
|
424 // CPbk2ItemFetcher::NextPhase |
|
425 // -------------------------------------------------------------------------- |
|
426 // |
|
427 void CPbk2ItemFetcher::NextPhase( MPbk2ServicePhase& aPhase ) |
|
428 { |
|
429 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
430 ("CPbk2ItemFetcher::NextPhase()") ); |
|
431 |
|
432 if ( &aPhase == iFetchPhase ) |
|
433 { |
|
434 MVPbkContactLinkArray* fetchResult = iFetchPhase->Results(); |
|
435 __ASSERT_DEBUG( fetchResult && fetchResult->Count() > 0, |
|
436 Panic( EPanicLogicPhaseCompletion ) ); |
|
437 |
|
438 TRAPD( err, LaunchAddressSelectPhaseL( *fetchResult ) ); |
|
439 if ( err != KErrNone ) |
|
440 { |
|
441 iObserver.ServiceError( err ); |
|
442 } |
|
443 } |
|
444 else if ( &aPhase == iAddressSelectPhase || |
|
445 &aPhase == iCommAddressSelectPhase ) |
|
446 { |
|
447 // Address select was the last phase |
|
448 iObserver.ServiceComplete(); |
|
449 } |
|
450 else |
|
451 { |
|
452 __ASSERT_DEBUG( EFalse, Panic( EPanicLogicPhaseCompletion ) ); |
|
453 } |
|
454 } |
|
455 |
|
456 // -------------------------------------------------------------------------- |
|
457 // CPbk2ItemFetcher::PreviousPhase |
|
458 // -------------------------------------------------------------------------- |
|
459 // |
|
460 void CPbk2ItemFetcher::PreviousPhase( MPbk2ServicePhase& /*aPhase*/ ) |
|
461 { |
|
462 // Do nothing |
|
463 } |
|
464 |
|
465 // -------------------------------------------------------------------------- |
|
466 // CPbk2ItemFetcher::PhaseCanceled |
|
467 // -------------------------------------------------------------------------- |
|
468 // |
|
469 void CPbk2ItemFetcher::PhaseCanceled( MPbk2ServicePhase& aPhase ) |
|
470 { |
|
471 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
472 ("CPbk2ItemFetcher::PhaseCanceled()") ); |
|
473 |
|
474 // We cannot cancel the phase completely if the cancellation |
|
475 // was done from address phase and fetch phase dialog still exists and |
|
476 // we are dealing with singleitemfetch |
|
477 if ( ( ( &aPhase != iAddressSelectPhase ) && |
|
478 ( &aPhase != iCommAddressSelectPhase ) ) || |
|
479 !iFetchPhase || |
|
480 iFetchType == EMultipleItemFetch ) |
|
481 { |
|
482 iObserver.ServiceCanceled(); |
|
483 } |
|
484 } |
|
485 |
|
486 // -------------------------------------------------------------------------- |
|
487 // CPbk2ItemFetcher::PhaseAborted |
|
488 // -------------------------------------------------------------------------- |
|
489 // |
|
490 void CPbk2ItemFetcher::PhaseAborted( MPbk2ServicePhase& /*aPhase*/ ) |
|
491 { |
|
492 iObserver.ServiceAborted(); |
|
493 } |
|
494 |
|
495 // -------------------------------------------------------------------------- |
|
496 // CPbk2ItemFetcher::PhaseError |
|
497 // -------------------------------------------------------------------------- |
|
498 // |
|
499 void CPbk2ItemFetcher::PhaseError |
|
500 ( MPbk2ServicePhase& /*aPhase*/, TInt aErrorCode ) |
|
501 { |
|
502 iObserver.ServiceError( aErrorCode ); |
|
503 } |
|
504 |
|
505 // -------------------------------------------------------------------------- |
|
506 // CPbk2ItemFetcher::PhaseOkToExit |
|
507 // -------------------------------------------------------------------------- |
|
508 // |
|
509 TBool CPbk2ItemFetcher::PhaseOkToExit |
|
510 ( MPbk2ServicePhase& /*aPhase*/, TInt aCommandId ) |
|
511 { |
|
512 // Deny exit and pass an asynchronous query to the consumer, |
|
513 // which may later approve exit |
|
514 iObserver.CompleteExitMessage( aCommandId ); |
|
515 return EFalse; |
|
516 } |
|
517 |
|
518 // -------------------------------------------------------------------------- |
|
519 // CPbk2ItemFetcher::PhaseAccept |
|
520 // -------------------------------------------------------------------------- |
|
521 // |
|
522 void CPbk2ItemFetcher::PhaseAccept |
|
523 ( MPbk2ServicePhase& /*aPhase*/, const TDesC8& aMarkedEntries, |
|
524 const TDesC8& aLinkData ) |
|
525 { |
|
526 iObserver.CompleteAcceptMsg( aMarkedEntries, aLinkData ); |
|
527 } |
|
528 |
|
529 // -------------------------------------------------------------------------- |
|
530 // CPbk2ItemFetcher::ContactUiReadyL |
|
531 // -------------------------------------------------------------------------- |
|
532 // |
|
533 void CPbk2ItemFetcher::ContactUiReadyL |
|
534 ( MPbk2StartupMonitor& aStartupMonitor ) |
|
535 { |
|
536 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
537 ("CPbk2ItemFetcher::ContactUiReadyL()") ); |
|
538 |
|
539 aStartupMonitor.DeregisterEvents( *this ); |
|
540 |
|
541 if ( !iPreselectedContacts || iPreselectedContacts->Count() == 0 ) |
|
542 { |
|
543 LaunchFetchPhaseL(); |
|
544 } |
|
545 else |
|
546 { |
|
547 if ( iStoreManager->ContactsAvailableL( *iPreselectedContacts ) ) |
|
548 { |
|
549 LaunchAddressSelectPhaseL( *iPreselectedContacts ); |
|
550 } |
|
551 else |
|
552 { |
|
553 iObserver.ServiceError( KErrNotSupported ); |
|
554 } |
|
555 } |
|
556 } |
|
557 |
|
558 // -------------------------------------------------------------------------- |
|
559 // CPbk2ItemFetcher::StartupCanceled |
|
560 // -------------------------------------------------------------------------- |
|
561 // |
|
562 void CPbk2ItemFetcher::StartupCanceled( TInt aErrorCode ) |
|
563 { |
|
564 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
565 ("CPbk2ItemFetcher::StartupCanceled()"), aErrorCode ); |
|
566 |
|
567 if ( aErrorCode == KErrCancel ) |
|
568 { |
|
569 iObserver.ServiceCanceled(); |
|
570 } |
|
571 else |
|
572 { |
|
573 iObserver.ServiceError( aErrorCode ); |
|
574 } |
|
575 } |
|
576 |
|
577 // -------------------------------------------------------------------------- |
|
578 // CPbk2ItemFetcher::LaunchFetchPhaseL |
|
579 // -------------------------------------------------------------------------- |
|
580 // |
|
581 void CPbk2ItemFetcher::LaunchFetchPhaseL() |
|
582 { |
|
583 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
584 ("CPbk2ItemFetcher::LaunchFetchPhaseL()") ); |
|
585 |
|
586 // By default fetch cannot exit |
|
587 TBool fetchOkToExit = EFalse; |
|
588 |
|
589 CPbk2FetchDlg::TParams params; |
|
590 params.iResId = R_PBK2_SINGLE_ENTRY_FETCH_DLG; |
|
591 params.iFlags = CPbk2FetchDlg::EFetchSingle; |
|
592 |
|
593 if ( iFetchType == ECallItemFetch ) |
|
594 { |
|
595 params.iResId = R_PBK2_CALL_ITEM_FETCH_DLG; |
|
596 params.iFlags = CPbk2FetchDlg::EFetchCallItem; |
|
597 } |
|
598 else if ( iFetchType == EMultipleItemFetch ) |
|
599 { |
|
600 params.iResId = R_PBK2_MULTIPLE_ENTRY_FETCH_DLG; |
|
601 params.iFlags = CPbk2FetchDlg::EFetchMultiple; |
|
602 |
|
603 // In multiple entry fetch, fetch can exit |
|
604 fetchOkToExit = ETrue; |
|
605 } |
|
606 |
|
607 delete iFetchPhase; |
|
608 iFetchPhase = NULL; |
|
609 iFetchPhase = CPbk2ContactFetchPhase::NewL |
|
610 ( *this, *iStoreManager, params, fetchOkToExit, |
|
611 MPbk2FetchDlgObserver::EFetchDelayed, iContactViewFilter, |
|
612 iUseDeviceConfig, iContactFetchStoreUris ); |
|
613 |
|
614 CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&> |
|
615 ( *CEikonEnv::Static()->EikAppUi() ); |
|
616 |
|
617 // Change layout to fetch's layout |
|
618 appUi.ChangeStatuspaneLayoutL( |
|
619 CPbk2ServerAppAppUi::EStatusPaneLayoutUsual ); |
|
620 |
|
621 iFetchPhase->LaunchServicePhaseL(); |
|
622 } |
|
623 |
|
624 // -------------------------------------------------------------------------- |
|
625 // CPbk2ItemFetcher::LaunchAddressSelectPhaseL |
|
626 // -------------------------------------------------------------------------- |
|
627 // |
|
628 void CPbk2ItemFetcher::LaunchAddressSelectPhaseL |
|
629 ( MVPbkContactLinkArray& aContactLinks ) |
|
630 { |
|
631 PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING |
|
632 ("CPbk2ItemFetcher::LaunchAddressSelectPhaseL()") ); |
|
633 |
|
634 // By default RSK is 'Back' |
|
635 TBool rskBack = ETrue; |
|
636 |
|
637 // RSK is cancel in case of multiple item fetch |
|
638 // or if there are preselected contacts |
|
639 if ( iFetchType == EMultipleItemFetch ) |
|
640 { |
|
641 rskBack = EFalse; |
|
642 } |
|
643 else if ( iPreselectedContacts && iPreselectedContacts->Count() != 0 ) |
|
644 { |
|
645 rskBack = EFalse; |
|
646 } |
|
647 |
|
648 delete iAddressSelectPhase; |
|
649 iAddressSelectPhase = NULL; |
|
650 delete iCommAddressSelectPhase; |
|
651 iCommAddressSelectPhase = NULL; |
|
652 |
|
653 if ( iCommAddressSelectType != VPbkFieldTypeSelectorFactory::EEmptySelector ) |
|
654 { |
|
655 iCommAddressSelectPhase = CPbk2CommAddressSelectPhase::NewL |
|
656 ( *this, aContactLinks.At( 0 ), iDefaultPriorities, |
|
657 *iContactViewFilter, iCommAddressSelectType, rskBack ); |
|
658 |
|
659 iCommAddressSelectPhase->LaunchServicePhaseL(); |
|
660 } |
|
661 else |
|
662 { |
|
663 iAddressSelectPhase = CPbk2AddressSelectPhase::NewL |
|
664 ( *this, aContactLinks, iDefaultPriorities, |
|
665 iAddressSelectType, rskBack ); |
|
666 |
|
667 iAddressSelectPhase->LaunchServicePhaseL(); |
|
668 } |
|
669 } |
|
670 |
|
671 // -------------------------------------------------------------------------- |
|
672 // CPbk2ItemFetcher::AddXSPStoresL |
|
673 // -------------------------------------------------------------------------- |
|
674 // |
|
675 void CPbk2ItemFetcher::AddXSPStoresL() |
|
676 { |
|
677 RIdArray ids; |
|
678 CleanupClosePushL( ids ); |
|
679 CSPSettings* settings = CSPSettings::NewL(); |
|
680 CleanupStack::PushL( settings ); |
|
681 TInt error = settings->FindServiceIdsL( ids ); |
|
682 const TInt count = ids.Count(); |
|
683 |
|
684 for( TInt i = 0; i < count; i++ ) |
|
685 { |
|
686 CSPProperty* property = CSPProperty::NewLC(); |
|
687 error = settings->FindPropertyL( ids[i], EPropertyContactStoreId, |
|
688 *property ); |
|
689 if( KErrNone == error ) |
|
690 { |
|
691 RBuf uri; |
|
692 uri.Create( KSPMaxDesLength ); |
|
693 CleanupClosePushL( uri ); |
|
694 property->GetValue( uri ); |
|
695 TVPbkContactStoreUriPtr uriPtr( uri ); |
|
696 iStoreUris->AppendL( uriPtr ); |
|
697 CleanupStack::PopAndDestroy(); //uri |
|
698 } |
|
699 CleanupStack::PopAndDestroy(); //property |
|
700 } |
|
701 CleanupStack::PopAndDestroy( 2 ); //settings, ids |
|
702 } |
|
703 |
|
704 // -------------------------------------------------------------------------- |
|
705 // CPbk2ItemFetcher::GetDefaultPriorities |
|
706 // -------------------------------------------------------------------------- |
|
707 // |
|
708 void CPbk2ItemFetcher::GetDefaultPriorities( TUint aFlags ) |
|
709 { |
|
710 if ( !( aFlags & ::EDoNotUseDefaultField ) ) |
|
711 { |
|
712 switch ( iCommAddressSelectType ) |
|
713 { |
|
714 // Errors during Append() operation are ignored, in this case |
|
715 // address select dialog will be shown instead of immediate return |
|
716 // of the default field. |
|
717 case VPbkFieldTypeSelectorFactory::EVoiceCallSelector: |
|
718 { |
|
719 iDefaultPriorities.Append( EVPbkDefaultTypePhoneNumber ); |
|
720 break; |
|
721 } |
|
722 case VPbkFieldTypeSelectorFactory::EUniEditorSelector: |
|
723 { |
|
724 iDefaultPriorities.Append( EVPbkDefaultTypeSms ); |
|
725 iDefaultPriorities.Append( EVPbkDefaultTypeMms ); |
|
726 break; |
|
727 } |
|
728 case VPbkFieldTypeSelectorFactory::EVideoCallSelector: |
|
729 { |
|
730 iDefaultPriorities.Append( EVPbkDefaultTypeVideoNumber ); |
|
731 break; |
|
732 } |
|
733 case VPbkFieldTypeSelectorFactory::EEmailEditorSelector: |
|
734 { |
|
735 iDefaultPriorities.Append( EVPbkDefaultTypeEmail ); |
|
736 break; |
|
737 } |
|
738 case VPbkFieldTypeSelectorFactory::EVOIPCallSelector: |
|
739 { |
|
740 iDefaultPriorities.Append( EVPbkDefaultTypeVoIP ); |
|
741 break; |
|
742 } |
|
743 case VPbkFieldTypeSelectorFactory::EPocSelector: |
|
744 { |
|
745 iDefaultPriorities.Append( EVPbkDefaultTypePOC ); |
|
746 break; |
|
747 } |
|
748 case VPbkFieldTypeSelectorFactory::EURLSelector : |
|
749 { |
|
750 iDefaultPriorities.Append( EVPbkDefaultTypeOpenLink ); |
|
751 break; |
|
752 } |
|
753 case VPbkFieldTypeSelectorFactory::EInstantMessagingSelector : |
|
754 { |
|
755 iDefaultPriorities.Append( EVPbkDefaultTypeChat ); |
|
756 break; |
|
757 } |
|
758 default: |
|
759 { |
|
760 break; |
|
761 } |
|
762 } |
|
763 } |
|
764 } |
|
765 // End of File |