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