|
1 /* |
|
2 * Copyright (c) 2009 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 names list extension view. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "Pbk2NamesListExView.h" |
|
21 #include "CPbk2CmdItemAddTop.h" |
|
22 #include "CPbk2CmdItemRemoteContactLookup.h" |
|
23 #include <cpbk2remotecontactlookupaccounts.h> |
|
24 #include <Pbk2ExNamesListRes.rsg> |
|
25 #include "Pbk2NlxMenuFiltering.h" |
|
26 #include "cpbk2cmditemmycard.h" |
|
27 #include "cpbk2mycard.h" |
|
28 #include "Pbk2NamesListEx.hrh" |
|
29 #include "cpbk2contextlaunch.h" |
|
30 |
|
31 #include <spbcontentprovider.h> |
|
32 |
|
33 // Phonebook 2 |
|
34 #include <CPbk2UIExtensionView.h> |
|
35 #include <MPbk2AppUi.h> |
|
36 #include <MPbk2ViewExplorer.h> |
|
37 #include "CPbk2ViewState.h" |
|
38 #include <MPbk2StartupMonitor.h> |
|
39 #include <Phonebook2.rsg> |
|
40 #include <Pbk2Commands.rsg> |
|
41 #include <Pbk2UIControls.rsg> |
|
42 #include <Pbk2CommonUi.rsg> |
|
43 #include <CPbk2ControlContainer.h> |
|
44 #include <CPbk2NamesListControl.h> |
|
45 #include <MPbk2CommandHandler.h> |
|
46 #include <Pbk2Commands.hrh> |
|
47 #include <MPbk2ViewActivationTransaction.h> |
|
48 #include <CPbk2ViewStateTransformer.h> |
|
49 #include <csxhelp/phob.hlp.hrh> |
|
50 #include <Pbk2UID.h> |
|
51 #include <MPbk2PointerEventInspector.h> |
|
52 #include <Phonebook2PrivateCRKeys.h> |
|
53 #include <CPbk2IconFactory.h> |
|
54 #include <TPbk2IconId.h> |
|
55 #include <CPbk2IconInfoContainer.h> |
|
56 #include <MPbk2ApplicationServices.h> |
|
57 #include <MPbk2ContactViewSupplier.h> |
|
58 #include <CPbk2StoreConfiguration.h> |
|
59 #include <Pbk2IconId.hrh> |
|
60 #include "Pbk2ContactUiControlProxy.h" |
|
61 #include <MPbk2UiControlCmdItem.h> |
|
62 #include <pbk2mapcommands.hrh> |
|
63 #include "Pbk2InternalCommands.hrh" |
|
64 #include "CPbk2ContactViewListBox.h" |
|
65 #include <pbk2doublelistboxcmditemextension.h> |
|
66 |
|
67 #include "CVPbkContactManager.h" |
|
68 #include "MVPbkContactStoreList.h" |
|
69 #include "VPbkContactStoreUris.h" |
|
70 #include "TVPbkContactStoreUriPtr.h" |
|
71 |
|
72 //Cca |
|
73 #ifdef RD_PBK2_USE_CCA |
|
74 #include <MVPbkBaseContact.h> |
|
75 #include <mccaparameter.h> |
|
76 #include <mccaconnection.h> |
|
77 #include <ccafactory.h> |
|
78 // #include <ccaerrors.h> |
|
79 #endif |
|
80 #include <ccafactory.h> |
|
81 #include <mccaconnection.h> |
|
82 |
|
83 // System includes |
|
84 #include <StringLoader.h> |
|
85 #include <centralrepository.h> |
|
86 #include <AiwCommon.hrh> |
|
87 #include <eikbtgpc.h> |
|
88 #include <avkon.rsg> |
|
89 #include <eikmenub.h> |
|
90 #include <AknUtils.h> |
|
91 #include <akntoolbar.h> |
|
92 #include <akntouchpane.h> |
|
93 #include <gulicon.h> |
|
94 #include <AknsUtils.h> |
|
95 #include <aknbutton.h> |
|
96 #include <eikcolib.h> |
|
97 #include <eiklbx.h> |
|
98 #include <touchfeedback.h> |
|
99 #include <aknstyluspopupmenu.h> |
|
100 #include <Pbk2Config.hrh> |
|
101 #include <layoutmetadata.cdl.h> |
|
102 #include <featmgr.h> |
|
103 #include <ecom.h> |
|
104 |
|
105 // Debugging headers |
|
106 #include <Pbk2Debug.h> |
|
107 #include <Pbk2Profile.h> |
|
108 |
|
109 //Phone memory checking |
|
110 #include <CPbk2ApplicationServices.h> |
|
111 #include <CVPbkContactStoreUriArray.h> |
|
112 #include <CPbk2StoreConfiguration.h> |
|
113 #include <VPbkContactStoreUris.h> |
|
114 #include <TVPbkContactStoreUriPtr.h> |
|
115 #include <Pbk2InternalUID.h> |
|
116 |
|
117 /// Unnamed namespace for local definitions |
|
118 namespace { |
|
119 |
|
120 #ifdef _DEBUG |
|
121 enum TPanicCode |
|
122 { |
|
123 EPanicPreCond_ConstructL = 1, |
|
124 EPanicPostCond_ConstructL, |
|
125 EPanicPostCond_DoActivateL, |
|
126 EPanicPreCond_HandleCommandL, |
|
127 EPanicLogic_DoTransformLegacyViewStateToPbk2ViewStateLC |
|
128 }; |
|
129 |
|
130 void Panic(TPanicCode aReason) |
|
131 { |
|
132 _LIT( KPanicText, "CPbk2NamesListExView" ); |
|
133 User::Panic( KPanicText, aReason ); |
|
134 } |
|
135 #endif // _DEBUG |
|
136 |
|
137 |
|
138 /** |
|
139 * Returns ETrue if shift is depressed in aKeyEvent. |
|
140 * |
|
141 * @param aKeyEvent Key event. |
|
142 * @return ETrue if shift is down. |
|
143 */ |
|
144 inline TBool ShiftDown |
|
145 ( const TKeyEvent& aKeyEvent ) |
|
146 { |
|
147 return ( aKeyEvent.iModifiers & |
|
148 ( EModifierShift | EModifierLeftShift | EModifierRightShift ) ) != 0; |
|
149 } |
|
150 |
|
151 /** |
|
152 * Returns ETrue if either Shift or Control key is depressed. |
|
153 * |
|
154 * @param aKeyEvent Key event. |
|
155 * @return ETrue if shift or control is down. |
|
156 */ |
|
157 inline TBool IsShiftOrControlDown( const TKeyEvent& aKeyEvent ) |
|
158 { |
|
159 return ( aKeyEvent.iModifiers & |
|
160 ( EModifierShift | EModifierLeftShift | EModifierRightShift | |
|
161 EModifierCtrl | EModifierLeftCtrl | EModifierRightCtrl ) ) != 0; |
|
162 } |
|
163 |
|
164 /** |
|
165 * Creates a toolbar button with a skinnable icon |
|
166 * |
|
167 * @param aIconFactory Icon factory that must contain the toolbar |
|
168 * button icon. |
|
169 * @param aPbk2IconId Id for Phonebook2 icon for all button states. |
|
170 * @return CAknButton instance. |
|
171 */ |
|
172 CAknButton* CreateToolbarButtonLC |
|
173 ( CPbk2IconFactory& aIconFactory, TInt aPbk2IconId, TInt aHelpTextResId ) |
|
174 { |
|
175 TPbk2IconId iconId( TUid::Uid(KPbk2UID3), aPbk2IconId ); |
|
176 CGulIcon* icon = aIconFactory.CreateIconLC( iconId ); |
|
177 |
|
178 HBufC* helpText = CCoeEnv::Static()->AllocReadResourceLC( aHelpTextResId ); |
|
179 |
|
180 CAknButton* button = CAknButton::NewL( icon, NULL, NULL, NULL, |
|
181 KNullDesC, *helpText, KAknButtonSizeFitText, 0 ); |
|
182 |
|
183 CleanupStack::PopAndDestroy();//helpText |
|
184 |
|
185 CleanupStack::Pop( icon ); |
|
186 CleanupStack::PushL( button ); |
|
187 return button; |
|
188 } |
|
189 |
|
190 } /// namespace |
|
191 |
|
192 // -------------------------------------------------------------------------- |
|
193 // CPbk2NamesListExView::CPbk2NamesListExView |
|
194 // -------------------------------------------------------------------------- |
|
195 // |
|
196 CPbk2NamesListExView::CPbk2NamesListExView |
|
197 ( CPbk2UIExtensionView& aView, |
|
198 CSpbContentProvider& aStatusProvider, |
|
199 MCCAConnection*& aCCAConnection ) : |
|
200 iView( aView ), |
|
201 iCommandState( ETrue ), |
|
202 iCurrentCommandId( KErrNotFound ), |
|
203 iCtrlVisibleStateBeforeLosingForground( ETrue ), |
|
204 iFirstTimeActivated( ETrue ), |
|
205 iContentProvider( aStatusProvider ), |
|
206 iCCAConnection( aCCAConnection ), |
|
207 iMarkingModeOn( EFalse ) |
|
208 { |
|
209 } |
|
210 |
|
211 // -------------------------------------------------------------------------- |
|
212 // CPbk2NamesListAppView::~CPbk2NamesListAppView |
|
213 // -------------------------------------------------------------------------- |
|
214 // |
|
215 CPbk2NamesListExView::~CPbk2NamesListExView() |
|
216 { |
|
217 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
218 ("CPbk2NamesListExView(%x)::~CPbk2NamesListExView()"), this); |
|
219 |
|
220 if ( iStoreConfiguration ) |
|
221 { |
|
222 iStoreConfiguration->RemoveObserver( *this ); |
|
223 } |
|
224 |
|
225 delete iControlState; |
|
226 delete iIdleToolbarWarden; |
|
227 delete iToolbarIcons; |
|
228 if ( iToolbar ) |
|
229 { |
|
230 iToolbar->SetToolbarObserver( NULL ); |
|
231 } |
|
232 |
|
233 if (iContainer) |
|
234 { |
|
235 iContainer->RemoveForegroundObserver(); |
|
236 CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer); |
|
237 delete iContainer; |
|
238 } |
|
239 |
|
240 delete iIdleTexter; |
|
241 delete iControlProxy; |
|
242 |
|
243 delete iMyCard; |
|
244 CCoeEnv::Static()->RemoveForegroundObserver( *this ); |
|
245 |
|
246 delete iContextLauncher; |
|
247 FeatureManager::UnInitializeLib(); |
|
248 } |
|
249 |
|
250 // -------------------------------------------------------------------------- |
|
251 // CPbk2NamesListExView::NewL |
|
252 // -------------------------------------------------------------------------- |
|
253 // |
|
254 CPbk2NamesListExView* CPbk2NamesListExView::NewL |
|
255 ( CPbk2UIExtensionView& aView, |
|
256 CSpbContentProvider& aStatusProvider, |
|
257 MCCAConnection*& aCCAConnection ) |
|
258 { |
|
259 CPbk2NamesListExView* self = new ( ELeave ) CPbk2NamesListExView |
|
260 ( aView, aStatusProvider, aCCAConnection ); |
|
261 CleanupStack::PushL( self ); |
|
262 self->ConstructL(); |
|
263 CleanupStack::Pop( self ); |
|
264 return self; |
|
265 } |
|
266 |
|
267 // -------------------------------------------------------------------------- |
|
268 // CPbk2NamesListExView::ConstructL |
|
269 // -------------------------------------------------------------------------- |
|
270 // |
|
271 inline void CPbk2NamesListExView::ConstructL() |
|
272 { |
|
273 FeatureManager::InitializeLibL(); |
|
274 |
|
275 // PreCond |
|
276 __ASSERT_DEBUG(!iContainer, Panic(EPanicPreCond_ConstructL)); |
|
277 PBK2_PROFILE_START(Pbk2Profile::ENamesListExViewConstruction); |
|
278 CCoeEnv::Static()->AddForegroundObserverL(*this); |
|
279 |
|
280 iContactManager = &(Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager()); |
|
281 iNameFormatter = &(Phonebook2::Pbk2AppUi()->ApplicationServices().NameFormatter()); |
|
282 |
|
283 PBK2_PROFILE_START(Pbk2Profile::ENamesListGetCommandHandler); |
|
284 iCommandHandler = Phonebook2::Pbk2AppUi()->ApplicationServices().CommandHandlerL(); |
|
285 PBK2_PROFILE_END(Pbk2Profile::ENamesListGetCommandHandler); |
|
286 |
|
287 // Register this view as a store configuration observer |
|
288 PBK2_PROFILE_START(Pbk2Profile::ENamesListRegisterStoreConfiguration); |
|
289 iStoreConfiguration = &Phonebook2::Pbk2AppUi()->ApplicationServices().StoreConfiguration(); |
|
290 iStoreConfiguration->AddObserverL( *this ); |
|
291 PBK2_PROFILE_END(Pbk2Profile::ENamesListRegisterStoreConfiguration); |
|
292 |
|
293 iControlProxy = new( ELeave )CPbk2ContactUiControlProxy; |
|
294 |
|
295 iContextLauncher = new(ELeave) CPbk2ContextLaunch( iCCAConnection ); |
|
296 |
|
297 PBK2_PROFILE_END(Pbk2Profile::ENamesListPenSupportConstruction); |
|
298 |
|
299 if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) ) |
|
300 { |
|
301 // Get the phoneStore for MyCard |
|
302 MVPbkContactStore* phoneStore = iContactManager->ContactStoresL() |
|
303 .Find(VPbkContactStoreUris::DefaultCntDbUri()); |
|
304 |
|
305 if(phoneStore) |
|
306 { |
|
307 iMyCard = CPbk2MyCard::NewL( *phoneStore ); |
|
308 } |
|
309 } |
|
310 |
|
311 // Attach AIW providers |
|
312 AttachAIWProvidersL(); |
|
313 |
|
314 // Do not create the container control here: defer creation to first |
|
315 // activation of the view (first DoActivateL call). This saves a lot |
|
316 // of memory and application starting time, because all the application |
|
317 // views (classes like this) must be created at startup. Controls will |
|
318 // be created on-demand as the views are accessed. |
|
319 |
|
320 PBK2_PROFILE_END(Pbk2Profile::ENamesListExViewConstruction); |
|
321 // PostCond |
|
322 __ASSERT_DEBUG(!iContainer, Panic(EPanicPostCond_ConstructL)); |
|
323 } |
|
324 |
|
325 // -------------------------------------------------------------------------- |
|
326 // CPbk2NamesListExView::ConstructToolbarL |
|
327 // -------------------------------------------------------------------------- |
|
328 // |
|
329 void CPbk2NamesListExView::ConstructToolbarL() |
|
330 { |
|
331 if ( AknLayoutUtils::PenEnabled() ) |
|
332 { |
|
333 iToolbar = iView.Toolbar(); |
|
334 if ( iToolbar ) |
|
335 { |
|
336 // Take toolbar control event handling from touch pane. |
|
337 // Events need to be forwarded to touch pane manually. |
|
338 iToolbar->SetObserver( this ); |
|
339 iToolbar->SetToolbarObserver( this ); |
|
340 |
|
341 // Add toolbar buttons with skinnable icons |
|
342 iToolbarIcons = CPbk2IconInfoContainer::NewL( |
|
343 R_PBK2_NAMESLIST_TOOLBAR_ICON_INFO_ARRAY ); |
|
344 CPbk2IconFactory* factory = |
|
345 CPbk2IconFactory::NewLC( *iToolbarIcons ); |
|
346 |
|
347 // Button 1: Call |
|
348 CAknButton* button = CreateToolbarButtonLC( |
|
349 *factory, EPbk2qgn_indi_tb_call, R_PHOB_TB_CALL ); |
|
350 iToolbar->AddItemL( |
|
351 button, EAknCtButton, EPbk2CmdCall, 0, 0 ); |
|
352 CleanupStack::Pop( button ); |
|
353 |
|
354 // Button 2: Write message |
|
355 button = CreateToolbarButtonLC( |
|
356 *factory, EPbk2qgn_indi_tb_mce, R_PHOB_TB_CREATE_MSG ); |
|
357 iToolbar->AddItemL( |
|
358 button, EAknCtButton, EPbk2CmdWriteNoQuery, 0, 1 ); |
|
359 CleanupStack::Pop( button ); |
|
360 |
|
361 // Button 3: Create new contact |
|
362 button = CreateToolbarButtonLC( |
|
363 *factory, EPbk2qgn_indi_tb_avail_contacts, R_PHOB_TB_NEW_CONTACT ); |
|
364 iToolbar->AddItemL( |
|
365 button, EAknCtButton, EPbk2CmdCreateNew, 0, 2 ); |
|
366 CleanupStack::Pop( button ); |
|
367 |
|
368 CleanupStack::PopAndDestroy( factory ); |
|
369 |
|
370 // Load the previously saved toolbar state |
|
371 CRepository* cenrep = |
|
372 CRepository::NewLC( TUid::Uid( KCRUidPhonebook ) ); |
|
373 User::LeaveIfError( |
|
374 cenrep->Get( KPhonebookNamesListToolbarVisibility, |
|
375 iToolbarVisible ) ); |
|
376 CleanupStack::PopAndDestroy( cenrep ); |
|
377 |
|
378 // FIXME: toolbar is now always on after fixed toolbar is taken to use. |
|
379 // so the toolbar visibility storing and handling code including the cenrep key |
|
380 // could probably be removed now |
|
381 iToolbar->SetToolbarVisibility(ETrue, EFalse); |
|
382 } |
|
383 } |
|
384 } |
|
385 |
|
386 // -------------------------------------------------------------------------- |
|
387 // CPbk2NamesListExView::HandleCommandL |
|
388 // -------------------------------------------------------------------------- |
|
389 // |
|
390 void CPbk2NamesListExView::HandleCommandL(TInt aCommandId) |
|
391 { |
|
392 // If this view has already been deactivated, just return. |
|
393 if ( Phonebook2::Pbk2AppUi()->ActiveView()->Id() != Phonebook2::KPbk2NamesListViewUid ) |
|
394 { |
|
395 return; |
|
396 } |
|
397 |
|
398 // In case "open" is chosen and a command item is highlighted, need to remap |
|
399 // cmd ID from openCca to the correct cmd ID. For command items "select" is used. |
|
400 // Not very elegant. Another way would be to dynamically change the OK cmd assignment |
|
401 // all the time as UI state changes. |
|
402 if ( iControl->FocusedCommandItem() && |
|
403 !iControl->ContactsMarked() && |
|
404 (aCommandId == EPbk2CmdOpenCca || aCommandId == EAknSoftkeySelect ) ) |
|
405 { |
|
406 aCommandId = iControl->FocusedCommandItem()->CommandId(); |
|
407 } |
|
408 |
|
409 if ( iControl->FocusedCommandItem() && |
|
410 !iControl->ContactsMarked() && |
|
411 aCommandId == EPbk2CmdSelectRclCmdItem ) |
|
412 { |
|
413 aCommandId = EPbk2CmdRcl; |
|
414 } |
|
415 |
|
416 if ( EAknCmdHideInBackground != aCommandId ) |
|
417 { |
|
418 iCurrentCommandId = aCommandId; |
|
419 } |
|
420 |
|
421 if ( EPbk2CmdOpenCca == aCommandId ) |
|
422 { |
|
423 iControl->SetOpeningCca( ETrue ); |
|
424 } |
|
425 |
|
426 // Set focus, keep current focus on the area of the client screen |
|
427 // when scoll to the bottom of Names list view. |
|
428 CPbk2ContactViewListBox* listbox = static_cast<CPbk2ContactViewListBox*>(iControl->ComponentControl(0)); |
|
429 if ( EPbk2CmdCreateNew == aCommandId && |
|
430 listbox->CurrentItemIndex() < listbox->TopItemIndex() && |
|
431 listbox->BottomItemIndex() == listbox->Model()->NumberOfItems()-1 ) |
|
432 { |
|
433 listbox->SetCurrentItemIndex( listbox->TopItemIndex() ); |
|
434 } |
|
435 |
|
436 // No command handling in this class, forward to Commands |
|
437 if (!iCommandHandler->HandleCommandL( aCommandId, *iControlProxy, &iView )) |
|
438 { |
|
439 iControl->ProcessCommandL(aCommandId); |
|
440 // Command was not handled in Pbk2Commands, forward it to AppUi |
|
441 Phonebook2::Pbk2AppUi()->HandleCommandL(aCommandId); |
|
442 |
|
443 // Update CBAs, if command handler is consuming the command |
|
444 // postcommandexecution is updating CBAs |
|
445 UpdateCbasL(); |
|
446 } |
|
447 } |
|
448 |
|
449 // -------------------------------------------------------------------------- |
|
450 // CPbk2NamesListExView::Id |
|
451 // -------------------------------------------------------------------------- |
|
452 // |
|
453 TUid CPbk2NamesListExView::Id() const |
|
454 { |
|
455 return Phonebook2::KPbk2NamesListViewUid; |
|
456 } |
|
457 |
|
458 // -------------------------------------------------------------------------- |
|
459 // CPbk2NamesListExView::HandleStatusPaneSizeChange |
|
460 // -------------------------------------------------------------------------- |
|
461 // |
|
462 void CPbk2NamesListExView::HandleStatusPaneSizeChange() |
|
463 { |
|
464 // Resize the container to fill the client rectangle |
|
465 if (iContainer) |
|
466 { |
|
467 iContainer->SetRect(iView.ClientRect()); |
|
468 } |
|
469 if ( iToolbar && NeedToHideToolbar(iCurrentCommandId) ) |
|
470 { |
|
471 // If Command is is executing (iCommandState:0) |
|
472 // Ordinal priority of iToolbar is set to ECoeWinPriorityLow. |
|
473 iToolbar->DrawableWindow()->SetOrdinalPosition |
|
474 ( 0, iCommandState ? ECoeWinPriorityNormal : ECoeWinPriorityLow ); |
|
475 } |
|
476 } |
|
477 |
|
478 // -------------------------------------------------------------------------- |
|
479 // CPbk2NamesListExView::DoActivateL |
|
480 // -------------------------------------------------------------------------- |
|
481 // |
|
482 void CPbk2NamesListExView::DoActivateL |
|
483 ( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, |
|
484 const TDesC8& aCustomMessage ) |
|
485 { |
|
486 /// Notice that when "always on" feature is used this is called second |
|
487 /// time without calling DoDeactivate, when exit is done. |
|
488 /// This function must not do any duplicate resource allocation. |
|
489 |
|
490 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
491 ("CPbk2NamesListExView(%x)::DoActivateL()"), this); |
|
492 |
|
493 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewDoActivateL); |
|
494 |
|
495 PBK2_PROFILE_START |
|
496 ( Pbk2Profile::ENamesListViewDoActivateAddMenuCommandObserver ); |
|
497 // Do not add duplicate if DoActivateL is called due to Exit in |
|
498 // always on mode. |
|
499 iCommandHandler->RemoveMenuCommandObserver( *this ); |
|
500 // Add this view to observ command events |
|
501 iCommandHandler->AddMenuCommandObserver(*this); |
|
502 PBK2_PROFILE_END |
|
503 ( Pbk2Profile::ENamesListViewDoActivateAddMenuCommandObserver ); |
|
504 |
|
505 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewDoActivateLoadTitle); |
|
506 HBufC* title = StringLoader::LoadLC(R_QTN_PHOB_TITLE); |
|
507 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewDoActivateLoadTitle); |
|
508 |
|
509 PBK2_PROFILE_START |
|
510 ( Pbk2Profile::ENamesListViewDoActivateHandleViewActivation ); |
|
511 MPbk2ViewActivationTransaction* viewActivationTransaction = |
|
512 Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC |
|
513 ( Id(), aPrevViewId, title, NULL, |
|
514 Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane | |
|
515 Phonebook2::EUpdateContextPane ); |
|
516 PBK2_PROFILE_END |
|
517 ( Pbk2Profile::ENamesListViewDoActivateHandleViewActivation ); |
|
518 |
|
519 // Create control and activate it. |
|
520 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewDoActivateActivateControl); |
|
521 CreateControlsL(); |
|
522 iContainer->ActivateL(); |
|
523 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewDoActivateActivateControl); |
|
524 |
|
525 // Check activation parameters |
|
526 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewDoActivateParamHandling); |
|
527 delete iParamState; |
|
528 iParamState = NULL; |
|
529 if( aCustomMessageId == CPbk2ContextLaunch::Uid() ) |
|
530 { |
|
531 // Close up any open CCA instances |
|
532 if( iCCAConnection ) |
|
533 { |
|
534 iCCAConnection->Close(); |
|
535 iCCAConnection = NULL; |
|
536 } |
|
537 |
|
538 // Handle context launch request |
|
539 if( iContextLauncher ) |
|
540 { |
|
541 iContextLauncher->HandleMessageL( aCustomMessage ); |
|
542 } |
|
543 } |
|
544 else if (aCustomMessageId == CPbk2ViewState::Uid()) |
|
545 { |
|
546 // Restore state when TPbk2ControlEvent::EReady comes. |
|
547 iParamState = CPbk2ViewState::NewL(aCustomMessage); |
|
548 } |
|
549 else if (aCustomMessageId == TUid::Uid(KPbkViewStateUid)) |
|
550 { |
|
551 // Handle legacy view state |
|
552 CPbk2ViewStateTransformer* transformer = |
|
553 CPbk2ViewStateTransformer::NewLC( *iContactManager ); |
|
554 // Restore state when TPbk2ControlEvent::EReady comes. |
|
555 iParamState = transformer-> |
|
556 TransformLegacyViewStateToPbk2ViewStateLC |
|
557 ( aCustomMessage ); |
|
558 CleanupStack::Pop(iParamState); |
|
559 CleanupStack::PopAndDestroy(transformer); |
|
560 } |
|
561 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewDoActivateParamHandling); |
|
562 |
|
563 viewActivationTransaction->Commit(); |
|
564 CleanupStack::PopAndDestroy(2,title); // viewActivationTransaction, title |
|
565 |
|
566 // The application is set here to background if application exit occurs |
|
567 PBK2_PROFILE_START |
|
568 ( Pbk2Profile::ENamesListViewDoActivateNotifyViewActivatation ); |
|
569 |
|
570 // The application is set here to background if application exit occurs |
|
571 // When the device is powered on, Phonebook will start up automatically and |
|
572 // hide itself in the background. At the first time of names list view activation, |
|
573 // event is generated, the notification needs to be sent to Startup Monitor |
|
574 // so that making UI controls displaying properly. |
|
575 // At the first time of the activation, since all controls are brand new so |
|
576 // the iControl->Reset() needn’t to be called. |
|
577 if ( iParamState && iParamState->Flags() & |
|
578 CPbk2ViewState::ESendToBackground && !iFirstTimeActivated) |
|
579 { |
|
580 // AppUi will send the application to background. |
|
581 |
|
582 // Because the control is not destroyed it must be reset so that |
|
583 // when the view comes foreground again it will look like a fresh |
|
584 // and brand new control. |
|
585 iControl->Reset(); |
|
586 } |
|
587 else if (Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()) |
|
588 { |
|
589 // We are not going to background. Notify the start-up monitor that |
|
590 // will need to know the when the first view is activated. |
|
591 Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()->NotifyViewActivationL(Id()); |
|
592 |
|
593 // Reset flag |
|
594 iFirstTimeActivated = EFalse; |
|
595 } |
|
596 PBK2_PROFILE_END |
|
597 ( Pbk2Profile::ENamesListViewDoActivateNotifyViewActivatation ); |
|
598 |
|
599 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewDoActivateL); |
|
600 |
|
601 // It will return the listbox by calling iControl->ComponentControl(0), |
|
602 // which is defined in CPbk2NamesListControl::ComponentControl(TInt aIndex). |
|
603 CCoeControl* ctrl=iControl->ComponentControl(0); |
|
604 CEikListBox* listbox=static_cast <CEikListBox*> (ctrl); |
|
605 listbox->SetListBoxObserver( this ); |
|
606 listbox->SetMarkingModeObserver( this ); |
|
607 |
|
608 // iCtrlVisibleStateBeforeLosingForground records the names list control states before |
|
609 // losing foreground during a command execution. Set the iCtrlVisibleStateBeforeLosingForground |
|
610 // flag as ETrue as the control should be visible when active a view. |
|
611 iCtrlVisibleStateBeforeLosingForground = ETrue; |
|
612 |
|
613 // PostCond: |
|
614 __ASSERT_DEBUG(iContainer, Panic(EPanicPostCond_DoActivateL)); |
|
615 } |
|
616 |
|
617 // -------------------------------------------------------------------------- |
|
618 // CPbk2NamesListExView::AddCommandItemsToContainerL |
|
619 // -------------------------------------------------------------------------- |
|
620 // |
|
621 void CPbk2NamesListExView::AddCommandItemsToContainerL() |
|
622 { |
|
623 // get command item count |
|
624 TInt commandCount = iControl->CommandItemCount(); |
|
625 |
|
626 // Check if there is need to create MyCard |
|
627 if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) && |
|
628 ( !iMyCard && IsPhoneMemoryUsedL() ) ) |
|
629 { |
|
630 // Get the phoneStore for MyCard |
|
631 MVPbkContactStore* phoneStore = iContactManager->ContactStoresL() |
|
632 .Find(VPbkContactStoreUris::DefaultCntDbUri() ); |
|
633 |
|
634 if( phoneStore ) |
|
635 { |
|
636 // Create MyCard if not already exist and the phone memory selected |
|
637 iMyCard = CPbk2MyCard::NewL( *phoneStore ); |
|
638 } |
|
639 } |
|
640 |
|
641 // Add the MyCard item to the top of the list |
|
642 if( iMyCard && IsPhoneMemoryUsedL() ) |
|
643 { |
|
644 CPbk2CmdItemMyCard* cmd = |
|
645 CPbk2CmdItemMyCard::NewLC( *iMyCard, iContentProvider ); |
|
646 iControl->AddCommandItemL( cmd, commandCount ); // ownership transferred |
|
647 CleanupStack::Pop( cmd ); |
|
648 commandCount++; |
|
649 } |
|
650 |
|
651 CPbk2CmdItemAddTop* listCmd = CPbk2CmdItemAddTop::NewLC(); |
|
652 // Add the command item to the bottom of the command list |
|
653 iControl->AddCommandItemL( listCmd, commandCount ); // ownership transferred |
|
654 CleanupStack::Pop( listCmd ); |
|
655 commandCount++; |
|
656 |
|
657 |
|
658 // promotion item disabled until we can support command items at the bottom of the list |
|
659 // if ( IsRclOnL() ) |
|
660 if( 0 ) |
|
661 { |
|
662 CPbk2CmdItemRemoteContactLookup* rclCmd = CPbk2CmdItemRemoteContactLookup::NewLC(); |
|
663 // Add the command item to the bottom of the command list |
|
664 iControl->AddCommandItemL( rclCmd, commandCount ); // ownership transferred |
|
665 CleanupStack::Pop( rclCmd ); |
|
666 commandCount++; |
|
667 } |
|
668 } |
|
669 |
|
670 // -------------------------------------------------------------------------- |
|
671 // CPbk2NamesListExView::IsRclOnL |
|
672 // -------------------------------------------------------------------------- |
|
673 // |
|
674 TBool CPbk2NamesListExView::IsRclOnL() |
|
675 { |
|
676 TBool ret(EFalse); |
|
677 |
|
678 if( FeatureManager::FeatureSupported( KFeatureIdFfContactsRemoteLookup )) |
|
679 { |
|
680 //1. Get default protocol account |
|
681 TPbkxRemoteContactLookupProtocolAccountId accountID = |
|
682 CPbk2RemoteContactLookupAccounts::DefaultAccountIdL(); |
|
683 |
|
684 //2. Check that there really are implementation and account corresponding to |
|
685 //repository's value |
|
686 // If the iProtocolUid is NULL, then a default account has not been set. |
|
687 if ( accountID.iProtocolUid.iUid ) |
|
688 { |
|
689 CPbkxRemoteContactLookupProtocolAccount* account = NULL; |
|
690 // Returns NULL if account or plugin doesn't exist |
|
691 account = CPbk2RemoteContactLookupAccounts::GetAccountL( accountID ); |
|
692 if ( account ) |
|
693 { |
|
694 ret = ETrue; |
|
695 delete account; |
|
696 } |
|
697 } |
|
698 } |
|
699 return ret; |
|
700 } |
|
701 |
|
702 // -------------------------------------------------------------------------- |
|
703 // CPbk2NamesListExView::MyCard |
|
704 // -------------------------------------------------------------------------- |
|
705 // |
|
706 CPbk2MyCard* CPbk2NamesListExView::MyCard() const |
|
707 { |
|
708 TBool phoneMemory = EFalse; |
|
709 |
|
710 TRAP_IGNORE( phoneMemory = IsPhoneMemoryUsedL() ); |
|
711 |
|
712 if( phoneMemory ) |
|
713 { |
|
714 return iMyCard; |
|
715 } |
|
716 |
|
717 return NULL; |
|
718 } |
|
719 |
|
720 // -------------------------------------------------------------------------- |
|
721 // CPbk2NamesListExView::DoDeactivate |
|
722 // -------------------------------------------------------------------------- |
|
723 // |
|
724 void CPbk2NamesListExView::DoDeactivate() |
|
725 { |
|
726 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
727 ("CPbk2NamesListExView(%x)::DoDeactivate()"), this); |
|
728 |
|
729 // CCA Connection should be closed when Name List View deactivated |
|
730 if( iCCAConnection ) |
|
731 { |
|
732 iCCAConnection->Close(); |
|
733 iCCAConnection = NULL; |
|
734 } |
|
735 |
|
736 if ( iCommandHandler ) |
|
737 { |
|
738 iCommandHandler->RemoveMenuCommandObserver( *this ); |
|
739 } |
|
740 |
|
741 // Cancel toolbar warden to prevent further state saving |
|
742 if( iIdleToolbarWarden ) |
|
743 { |
|
744 iIdleToolbarWarden->Cancel(); |
|
745 } |
|
746 |
|
747 // Disable focus of toobar, so that it can't steal it from other views |
|
748 if( iToolbar ) |
|
749 { |
|
750 iToolbar->SetFocusing( EFalse ); |
|
751 } |
|
752 |
|
753 if( iIdleTexter ) |
|
754 { |
|
755 iIdleTexter->Cancel(); |
|
756 } |
|
757 |
|
758 // Trash the old states |
|
759 delete iParamState; |
|
760 iParamState = NULL; |
|
761 delete iControlState; |
|
762 iControlState = NULL; |
|
763 |
|
764 if (iContainer) |
|
765 { |
|
766 CCoeEnv::Static()->AppUi()->RemoveFromStack(iContainer); |
|
767 if( iMarkingModeOn ) |
|
768 { |
|
769 // It will return the listbox by calling |
|
770 // iControl->ComponentControl(0), which is defined |
|
771 // in CPbk2NamesListControl::ComponentControl(TInt aIndex). |
|
772 CCoeControl* ctrl=iControl->ComponentControl(0); |
|
773 CEikListBox* listbox=static_cast <CEikListBox*> (ctrl); |
|
774 listbox->SetMarkingMode(EFalse); |
|
775 } |
|
776 // Store current state, safe to ignore. There's no real harm, |
|
777 // if theres no stored state when activating this view again |
|
778 TRAP_IGNORE(StoreStateL()); |
|
779 iControl->SetObserver(NULL); |
|
780 delete iContainer; |
|
781 iContainer = NULL; |
|
782 // Reset also the reference to the control |
|
783 iControl = NULL; |
|
784 iControlProxy->SetControl( NULL ); |
|
785 } |
|
786 } |
|
787 |
|
788 // -------------------------------------------------------------------------- |
|
789 // CPbk2NamesListExView::DynInitMenuPaneL |
|
790 // -------------------------------------------------------------------------- |
|
791 // |
|
792 void CPbk2NamesListExView::DynInitMenuPaneL |
|
793 ( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
794 { |
|
795 // Ask the control to do control specific filtering |
|
796 // (for example call HandleMarkableListDynInitMenuPane if needed) |
|
797 iControl->DynInitMenuPaneL(aResourceId, aMenuPane); |
|
798 |
|
799 // Phonebook 2 menu filtering happens in Commands |
|
800 iCommandHandler->DynInitMenuPaneL( |
|
801 aResourceId, aMenuPane, iView, *iControl); |
|
802 |
|
803 //This is called after CPbk2CommandHandler::PerformStandardMenuFilteringL |
|
804 //so we can safely remove here anything that may already also be removed |
|
805 //there. |
|
806 switch (aResourceId) |
|
807 { |
|
808 case R_AVKON_MENUPANE_MARK_MULTIPLE: |
|
809 { |
|
810 TInt pos; |
|
811 if ( aMenuPane->MenuItemExists( EAknCmdMarkingModeEnter, pos ) && |
|
812 iControl->NumberOfContacts() <= 0 ) |
|
813 { |
|
814 aMenuPane->SetItemDimmed( EAknCmdMarkingModeEnter, ETrue ); |
|
815 } |
|
816 break; |
|
817 } |
|
818 case R_PHONEBOOK2_NAMESLIST_SEND_URL_MENU: |
|
819 { |
|
820 DimItem( aMenuPane, EPbk2CmdGoToURL ); |
|
821 if ( iControl->ContactsMarked() && iMarkingModeOn ) |
|
822 { |
|
823 aMenuPane->SetItemDimmed( EPbk2CmdSend, EFalse ); |
|
824 } |
|
825 break; |
|
826 } |
|
827 case R_PHONEBOOK2_NAMESLIST_COPY_MENU: |
|
828 { |
|
829 TInt pos; |
|
830 if ( aMenuPane->MenuItemExists( EPbk2CmdCopy, pos ) && iMarkingModeOn |
|
831 && iControl->NumberOfContacts() > 0 ) |
|
832 { |
|
833 // Show Copy item both in pop up menu and Options |
|
834 // when Marking mode is active. |
|
835 aMenuPane->SetItemSpecific( EPbk2CmdCopy, ETrue ); |
|
836 aMenuPane->SetItemDimmed( EPbk2CmdCopy, EFalse ); |
|
837 } |
|
838 break; |
|
839 } |
|
840 default: |
|
841 { |
|
842 break; |
|
843 } |
|
844 } |
|
845 } |
|
846 |
|
847 // -------------------------------------------------------------------------- |
|
848 // CPbk2NamesListAppView::DimItem |
|
849 // -------------------------------------------------------------------------- |
|
850 // |
|
851 void CPbk2NamesListExView::DimItem( CEikMenuPane* aMenuPane, TInt aCmd ) |
|
852 { |
|
853 TInt pos; |
|
854 if ( aMenuPane->MenuItemExists( aCmd, pos ) ) |
|
855 { |
|
856 aMenuPane->SetItemDimmed( aCmd, ETrue ); |
|
857 } |
|
858 } |
|
859 |
|
860 // -------------------------------------------------------------------------- |
|
861 // CPbk2NamesListExView::ViewStateLC |
|
862 // -------------------------------------------------------------------------- |
|
863 // |
|
864 CPbk2ViewState* CPbk2NamesListExView::ViewStateLC() const |
|
865 { |
|
866 CPbk2ViewState* state = NULL; |
|
867 if (iControl) |
|
868 { |
|
869 state = iControl->ControlStateL(); |
|
870 } |
|
871 CleanupStack::PushL(state); |
|
872 return state; |
|
873 } |
|
874 |
|
875 // -------------------------------------------------------------------------- |
|
876 // CPbk2NamesListExView::HandleCommandKeyL |
|
877 // -------------------------------------------------------------------------- |
|
878 // |
|
879 TBool CPbk2NamesListExView::HandleCommandKeyL |
|
880 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
881 { |
|
882 // re-initialized the findbox focus if the application is back in the |
|
883 // foreground. |
|
884 if ( iNeedSetFocus && iView.IsForeground() ) |
|
885 { |
|
886 iNeedSetFocus = EFalse; |
|
887 iControl->FocusChanged( EDrawNow ); |
|
888 } |
|
889 |
|
890 /* Uncomment this code if it is necessary to enable navigation hardware keys |
|
891 * on devices which have these keys (its Map Extension feature) |
|
892 if( aKeyEvent.iScanCode == EStdKeyApplicationD && aType == EEventKeyUp ) |
|
893 { |
|
894 HandleCommandL( EPbk2ExtensionAssignFromMap ); |
|
895 return ETrue; |
|
896 } |
|
897 |
|
898 if( aKeyEvent.iScanCode == EStdKeyApplicationE && aType == EEventKeyUp ) |
|
899 { |
|
900 HandleCommandL( EPbk2ExtensionShowOnMap ); |
|
901 return ETrue; |
|
902 }*/ |
|
903 TBool itemSpecEnabled = iView.MenuBar()->ItemSpecificCommandsEnabled(); |
|
904 |
|
905 TBool result = EFalse; |
|
906 if (aType == EEventKey) |
|
907 { |
|
908 switch (aKeyEvent.iCode) |
|
909 { |
|
910 case EKeyPhoneSend: |
|
911 { |
|
912 if ( itemSpecEnabled && iControl->NumberOfContacts() > 0 && |
|
913 !iControl->ContactsMarked() ) |
|
914 { |
|
915 // Do not handle the call command if there is a dialog displayed |
|
916 if ( !(CEikonEnv::Static()->EikAppUi()->IsDisplayingDialog()) ) |
|
917 { |
|
918 // Use the EPbk2CmdCall id to identify that |
|
919 // call is being launched with send key |
|
920 HandleCommandL(EPbk2CmdCall); |
|
921 } |
|
922 result = ETrue; |
|
923 } |
|
924 break; |
|
925 } |
|
926 case EKeyPoC: |
|
927 { |
|
928 // Use the EPbk2CmdPoC id to identify that |
|
929 // call is being launched with PoC key |
|
930 HandleCommandL( EPbk2CmdPoC ); |
|
931 result = ETrue; |
|
932 break; |
|
933 } |
|
934 case EKeyBackspace: |
|
935 { |
|
936 if ( itemSpecEnabled && ( iControl->FindTextL() == KNullDesC ) ) |
|
937 { |
|
938 TBool contactsMarked( iControl->ContactsMarked() ); |
|
939 |
|
940 MPbk2UiControlCmdItem* cmdItem = const_cast<MPbk2UiControlCmdItem*> ( iControl->FocusedCommandItem() ); |
|
941 |
|
942 TBool onMyCard = cmdItem && ( EPbk2CmdOpenMyCard == cmdItem->CommandId() ); |
|
943 |
|
944 if ( !contactsMarked && onMyCard ) |
|
945 { |
|
946 //Check to see whether the current focus is on MyCard or not |
|
947 //When none of the contacts are marked and with focus on MyCard, |
|
948 // pressing BackSpace/Del key leads to deletion of MyCard |
|
949 |
|
950 // get extension point and my card link |
|
951 TAny* object = cmdItem->ControlCmdItemExtension( TUid::Uid( KPbk2ControlCmdItemExtensionUID ) ); |
|
952 if( object ) |
|
953 { |
|
954 MPbk2DoubleListboxCmdItemExtension* extension = |
|
955 static_cast<MPbk2DoubleListboxCmdItemExtension*>( object ); |
|
956 // if extension exists |
|
957 if( extension ) |
|
958 { |
|
959 const MVPbkContactLink* link = extension->Link(); |
|
960 // if link exists, then MyCard has been Assigned |
|
961 if( link ) |
|
962 { |
|
963 HandleCommandL( EPbk2CmdDeleteMyCard ); |
|
964 result = ETrue; |
|
965 } |
|
966 } |
|
967 } |
|
968 } |
|
969 else if( ( contactsMarked ) || (iControl->NumberOfContacts() > 0) ) |
|
970 { |
|
971 HandleCommandL(EPbk2CmdDeleteMe); |
|
972 result = ETrue; |
|
973 } |
|
974 } |
|
975 break; |
|
976 } |
|
977 |
|
978 case EKeyEnter: // FALLTHROUGH |
|
979 case EKeyOK: |
|
980 { |
|
981 if ( !ShiftDown(aKeyEvent) ) // pure OK key |
|
982 { |
|
983 if ( iControl->ContactsMarked() && itemSpecEnabled ) |
|
984 { |
|
985 result = EFalse; |
|
986 } |
|
987 } |
|
988 break; |
|
989 } |
|
990 default: |
|
991 { |
|
992 break; |
|
993 } |
|
994 } |
|
995 } |
|
996 |
|
997 // Update selection modifier key state |
|
998 iSelectionModifierUsed = IsShiftOrControlDown( aKeyEvent ) || |
|
999 ( (aType == EEventKeyDown) && (aKeyEvent.iCode == EStdKeyHash) ); |
|
1000 |
|
1001 return result; |
|
1002 } |
|
1003 |
|
1004 |
|
1005 // ---------------------------------------------------------------------------- |
|
1006 // CLogsBaseView::HandleListBoxEventL |
|
1007 // ---------------------------------------------------------------------------- |
|
1008 // |
|
1009 void CPbk2NamesListExView::HandleListBoxEventL( |
|
1010 CEikListBox* aListBox, |
|
1011 TListBoxEvent aEventType) |
|
1012 { |
|
1013 if( AknLayoutUtils::PenEnabled() ) |
|
1014 { |
|
1015 switch ( aEventType ) |
|
1016 { |
|
1017 case EEventItemSingleClicked: |
|
1018 { |
|
1019 ShowContextMenuL(); |
|
1020 break; |
|
1021 } |
|
1022 #if 0 |
|
1023 case EEventEmptyAreaClicked: //An empty area of non-empty listbox was clicked |
|
1024 case EEventEmptyListClicked: //An empty listbox was clicked |
|
1025 { |
|
1026 ProcessEmptyAreaClickL(); |
|
1027 break; |
|
1028 } |
|
1029 #endif |
|
1030 |
|
1031 case EEventItemClicked: //Happens after focus changed |
|
1032 break; |
|
1033 |
|
1034 case EEventPanningStarted: |
|
1035 case EEventFlickStarted: |
|
1036 case EEventPanningStopped: |
|
1037 case EEventFlickStopped: |
|
1038 { |
|
1039 iControl->HandleListBoxEventL( aListBox, aEventType ); |
|
1040 break; |
|
1041 } |
|
1042 case EEventEnterKeyPressed: |
|
1043 { |
|
1044 if ( iControl->FocusedCommandItem() && |
|
1045 !iControl->ContactsMarked() ) |
|
1046 { |
|
1047 HandleCommandL(iControl->FocusedCommandItem()->CommandId() ); |
|
1048 } |
|
1049 else if (iControl->NumberOfContacts() > 0 && |
|
1050 !iControl->ContactsMarked()) |
|
1051 { |
|
1052 // Select key is mapped to "Open Contact" command |
|
1053 HandleCommandL(EPbk2CmdOpenCca); |
|
1054 } |
|
1055 break; |
|
1056 } |
|
1057 default: |
|
1058 break; |
|
1059 } |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 // -------------------------------------------------------------------------- |
|
1064 // CPbk2NamesListExView::HandlePointerEventL |
|
1065 // -------------------------------------------------------------------------- |
|
1066 // |
|
1067 void CPbk2NamesListExView::HandlePointerEventL( |
|
1068 const TPointerEvent& aPointerEvent ) |
|
1069 { |
|
1070 // re-initialized the findbox focus when the application is back in the |
|
1071 // foreground. |
|
1072 if ( iNeedSetFocus ) |
|
1073 { |
|
1074 iNeedSetFocus = EFalse; |
|
1075 iControl->FocusChanged( EDrawNow ); |
|
1076 } |
|
1077 |
|
1078 if ( AknLayoutUtils::PenEnabled() ) |
|
1079 { |
|
1080 // Longtap detection is currently not needed here |
|
1081 #if 0 |
|
1082 // If at some point we need to enable longtap detection here, then need |
|
1083 // to implement a way to prevent passing the event to longtap detector |
|
1084 // when a command item is tapped. Because command items should not have the |
|
1085 // longtap animation. |
|
1086 if ( iContainer |
|
1087 && <tapped item is not a command item> // <-- implement this logic by any means |
|
1088 && !iControl->ContactsMarked() && iPointerEventInspector->FocusableItemPointed() ) |
|
1089 { |
|
1090 iContainer->LongTapDetectorL().PointerEventL( aPointerEvent ); |
|
1091 } |
|
1092 #endif |
|
1093 |
|
1094 // ece has stylus menu for empty state, no need to initiate touch feedback |
|
1095 // context menu disabled as well |
|
1096 #if 0 |
|
1097 if ( iControl->NumberOfContacts()==0) |
|
1098 { |
|
1099 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1100 { |
|
1101 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1102 if ( feedback ) |
|
1103 { |
|
1104 feedback->InstantFeedback( ETouchFeedbackBasic ); |
|
1105 } |
|
1106 } |
|
1107 else if ( ( aPointerEvent.iType == TPointerEvent::EButton1Up ) && iCommandState) |
|
1108 { |
|
1109 ShowContextMenuL(); |
|
1110 } |
|
1111 } |
|
1112 #endif |
|
1113 } |
|
1114 |
|
1115 } |
|
1116 |
|
1117 // -------------------------------------------------------------------------- |
|
1118 // CPbk2NamesListExView::ShowContextMenuL |
|
1119 // -------------------------------------------------------------------------- |
|
1120 // |
|
1121 void CPbk2NamesListExView::ShowContextMenuL() |
|
1122 { |
|
1123 |
|
1124 if ( iStylusPopupMenuLaunched ) |
|
1125 { |
|
1126 // Absorb EButton1Up event if we already launched the stylus |
|
1127 // popup menu |
|
1128 iStylusPopupMenuLaunched = EFalse; |
|
1129 } |
|
1130 else if ( !iPointerEventInspector->SearchFieldPointed() && |
|
1131 !iSelectionModifierUsed ) |
|
1132 { |
|
1133 if ( iControl->NumberOfContacts() > 0 || iControl->CommandItemCount() > 0) |
|
1134 { |
|
1135 if ( iPointerEventInspector->FocusedItemPointed() ) |
|
1136 { |
|
1137 if ( !iControl->ContactsMarked() ) |
|
1138 { |
|
1139 // cancel the long tap animation with pointer up event |
|
1140 TPointerEvent event; |
|
1141 event.iType = TPointerEvent::EButton1Up; |
|
1142 iContainer->LongTapDetectorL().PointerEventL( event ); |
|
1143 |
|
1144 // Open contact |
|
1145 HandleCommandL( EPbk2CmdOpenCca ); |
|
1146 } |
|
1147 } |
|
1148 } |
|
1149 else |
|
1150 { |
|
1151 #ifndef ECE_DISABLE_CONTEXT_MENU |
|
1152 // Display regular context menu |
|
1153 iView.LaunchPopupMenuL |
|
1154 ( R_PHONEBOOK2_NAMESLIST_CONTEXT_MENUBAR ); |
|
1155 #endif |
|
1156 } |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 #if 0 |
|
1161 // -------------------------------------------------------------------------- |
|
1162 // CPbk2NamesListExView::ProcessEmptyAreaClickL |
|
1163 // -------------------------------------------------------------------------- |
|
1164 // |
|
1165 void CPbk2NamesListExView::ProcessEmptyAreaClickL() |
|
1166 { |
|
1167 if ( iStylusPopupMenuLaunched ) |
|
1168 { |
|
1169 // Absorb EButton1Up event if we already launched the stylus |
|
1170 // popup menu |
|
1171 iStylusPopupMenuLaunched = EFalse; |
|
1172 } |
|
1173 else if ( !iPointerEventInspector->SearchFieldPointed() && |
|
1174 !iSelectionModifierUsed ) |
|
1175 { |
|
1176 if ( iControl->NumberOfContacts() == 0 ) |
|
1177 { |
|
1178 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1179 if ( feedback ) |
|
1180 { |
|
1181 feedback->InstantFeedback( ETouchFeedbackBasic ); |
|
1182 } |
|
1183 HandleCommandL( EPbk2CmdCreateNew ); |
|
1184 } |
|
1185 } |
|
1186 } |
|
1187 #endif |
|
1188 |
|
1189 // -------------------------------------------------------------------------- |
|
1190 // CPbk2NamesListExView::GetViewSpecificMenuFilteringFlagsL |
|
1191 // -------------------------------------------------------------------------- |
|
1192 // |
|
1193 TInt CPbk2NamesListExView::GetViewSpecificMenuFilteringFlagsL() const |
|
1194 { |
|
1195 TInt flags(0); |
|
1196 |
|
1197 flags |= iControl->GetMenuFilteringFlagsL(); |
|
1198 |
|
1199 return flags; |
|
1200 } |
|
1201 |
|
1202 // -------------------------------------------------------------------------- |
|
1203 // CPbk2NamesListExView::HandleControlEventL |
|
1204 // -------------------------------------------------------------------------- |
|
1205 // |
|
1206 void CPbk2NamesListExView::HandleControlEventL |
|
1207 ( MPbk2ContactUiControl& /*aControl*/, |
|
1208 const TPbk2ControlEvent& aEvent ) |
|
1209 { |
|
1210 switch (aEvent.iEventType) |
|
1211 { |
|
1212 case TPbk2ControlEvent::EUnavailable: // FALLTHROUGH |
|
1213 case TPbk2ControlEvent::EReady: |
|
1214 { |
|
1215 DynInitToolbarL( R_PBK2_NAMESLIST_TOOLBAR, iToolbar ); |
|
1216 |
|
1217 // Restore control state |
|
1218 RestoreStateL(); |
|
1219 if ( iControl ) |
|
1220 { |
|
1221 iControl->ShowThumbnail(); |
|
1222 iControl->DrawDeferred(); |
|
1223 } |
|
1224 // Restore control's state before updating cbas to get right state. |
|
1225 UpdateCbasL(); |
|
1226 PBK2_PROFILE_END(Pbk2Profile::EFullStartup); |
|
1227 break; |
|
1228 } |
|
1229 |
|
1230 case TPbk2ControlEvent::EContactSetChanged: |
|
1231 { |
|
1232 UpdateCbasL(); |
|
1233 DynInitToolbarL( R_PBK2_NAMESLIST_TOOLBAR, iToolbar ); |
|
1234 iControl->ShowThumbnail(); |
|
1235 break; |
|
1236 } |
|
1237 |
|
1238 case TPbk2ControlEvent::EContactSelected: // FALLTHROUGH |
|
1239 case TPbk2ControlEvent::EContactUnselected: // FALLTHROUGH |
|
1240 case TPbk2ControlEvent::EContactUnselectedAll: |
|
1241 { |
|
1242 // Do not UpdateCbasL here because control handles itself |
|
1243 // the MSK when it goes to selection mode. |
|
1244 DynInitToolbarL( R_PBK2_NAMESLIST_TOOLBAR, iToolbar ); |
|
1245 UpdateCbasL(); |
|
1246 break; |
|
1247 } |
|
1248 case TPbk2ControlEvent::EControlLeavesSelectionMode: |
|
1249 { |
|
1250 // Update CBAs because the control doesn't know should |
|
1251 // the MSK be Open or Context menu when control leaves |
|
1252 // the selection mode. |
|
1253 UpdateCbasL(); |
|
1254 break; |
|
1255 } |
|
1256 |
|
1257 case TPbk2ControlEvent::EControlStateChanged: |
|
1258 { |
|
1259 UpdateCbasL(); |
|
1260 DynInitToolbarL( R_PBK2_NAMESLIST_TOOLBAR, iToolbar ); |
|
1261 UpdateListEmptyTextL( aEvent.iInt ); |
|
1262 iControl->DrawDeferred(); |
|
1263 break; |
|
1264 } |
|
1265 |
|
1266 case TPbk2ControlEvent::EControlFocusChanged: |
|
1267 { |
|
1268 DynInitToolbarL( R_PBK2_NAMESLIST_TOOLBAR, iToolbar ); |
|
1269 UpdateCbasL(); |
|
1270 break; |
|
1271 } |
|
1272 |
|
1273 default: |
|
1274 { |
|
1275 // Do nothing |
|
1276 break; |
|
1277 } |
|
1278 } |
|
1279 } |
|
1280 |
|
1281 // -------------------------------------------------------------------------- |
|
1282 // CPbk2NamesListExView::ConfigurationChanged |
|
1283 // -------------------------------------------------------------------------- |
|
1284 // |
|
1285 void CPbk2NamesListExView::ConfigurationChanged() |
|
1286 { |
|
1287 MVPbkContactStore* phoneStore = NULL; |
|
1288 |
|
1289 Reset(); |
|
1290 |
|
1291 if( iMyCard ) |
|
1292 { |
|
1293 return; |
|
1294 } |
|
1295 |
|
1296 if( FeatureManager::FeatureSupported( KFeatureIdffContactsMycard ) ) |
|
1297 { |
|
1298 // Get the phoneStore for MyCard |
|
1299 TRAP_IGNORE( phoneStore = iContactManager->ContactStoresL(). |
|
1300 Find( VPbkContactStoreUris::DefaultCntDbUri() ) ); |
|
1301 } |
|
1302 |
|
1303 if( !phoneStore ) |
|
1304 { |
|
1305 TRAP_IGNORE( iContactManager->LoadContactStoreL( |
|
1306 VPbkContactStoreUris::DefaultCntDbUri() ) ); |
|
1307 } |
|
1308 } |
|
1309 |
|
1310 // -------------------------------------------------------------------------- |
|
1311 // CPbk2NamesListExView::ConfigurationChangedComplete |
|
1312 // -------------------------------------------------------------------------- |
|
1313 // |
|
1314 void CPbk2NamesListExView::ConfigurationChangedComplete() |
|
1315 { |
|
1316 if ( iControl ) |
|
1317 { |
|
1318 MVPbkContactViewBase* allContactsView = NULL; |
|
1319 |
|
1320 TRAPD( res, allContactsView = Phonebook2::Pbk2AppUi()-> |
|
1321 ApplicationServices().ViewSupplier().AllContactsViewL() ); |
|
1322 |
|
1323 if ( res == KErrNone ) |
|
1324 { |
|
1325 TRAP( res, iControl->SetViewL( *allContactsView ) ); |
|
1326 iControl->DrawNow(); |
|
1327 } |
|
1328 |
|
1329 if ( res != KErrNone ) |
|
1330 { |
|
1331 CCoeEnv::Static()->HandleError( res ); |
|
1332 iControl->Reset(); |
|
1333 } |
|
1334 } |
|
1335 } |
|
1336 |
|
1337 // -------------------------------------------------------------------------- |
|
1338 // CPbk2NamesListExView::PreCommandExecutionL |
|
1339 // -------------------------------------------------------------------------- |
|
1340 // |
|
1341 void CPbk2NamesListExView::PreCommandExecutionL |
|
1342 ( const MPbk2Command& /*aCommand*/ ) |
|
1343 { |
|
1344 iControl->AllowPointerEvents( EFalse ); |
|
1345 iCommandState = EFalse; |
|
1346 |
|
1347 if ( iControl ) |
|
1348 { |
|
1349 // Note: PostCommandExecutionL() must match this if() |
|
1350 if ( iToolbar && NeedToHideToolbar(iCurrentCommandId) ) |
|
1351 { |
|
1352 iToolbarVisible = iToolbar->IsShown(); |
|
1353 |
|
1354 // First hide the other components (FindBox etc.) |
|
1355 // No need to hide listbox and findbox for EPbk2CmdWriteNoQuery as |
|
1356 // it will go to Message view |
|
1357 if ( iCurrentCommandId != EPbk2CmdWriteNoQuery ) |
|
1358 { |
|
1359 iControl->MakeVisible( EFalse ); |
|
1360 } |
|
1361 // Now hide toolbar items during the command execution... |
|
1362 iToolbar->HideItemsAndDrawOnlyBackground( ETrue ); |
|
1363 |
|
1364 // ..but don't save the state change |
|
1365 iIdleToolbarWarden->Cancel(); |
|
1366 } |
|
1367 |
|
1368 iControl->HideThumbnail(); |
|
1369 iControl->MassUpdateSkipProgressNote( ETrue ); |
|
1370 } |
|
1371 } |
|
1372 |
|
1373 // -------------------------------------------------------------------------- |
|
1374 // CPbk2NamesListExView::PostCommandExecutionL |
|
1375 // -------------------------------------------------------------------------- |
|
1376 // |
|
1377 void CPbk2NamesListExView::PostCommandExecutionL |
|
1378 ( const MPbk2Command& /*aCommand*/ ) |
|
1379 { |
|
1380 iCommandState = ETrue; |
|
1381 |
|
1382 if ( iControl ) |
|
1383 { |
|
1384 iControl->MassUpdateSkipProgressNote( EFalse ); |
|
1385 |
|
1386 // There are some special cases that the names list view would be hide in backgroud |
|
1387 // before one command is executing, and then get foreground later after the command |
|
1388 // finished, which would cause the control to be set invisible. So reset the flag |
|
1389 // after a command is finished. |
|
1390 iCtrlVisibleStateBeforeLosingForground = ETrue; |
|
1391 |
|
1392 if( EPbk2CmdOpenCca == iCurrentCommandId ) |
|
1393 { |
|
1394 iControl->SetOpeningCca( EFalse ); |
|
1395 } |
|
1396 |
|
1397 iControl->AllowPointerEvents( ETrue ); |
|
1398 iControl->ShowThumbnail(); |
|
1399 |
|
1400 TBool drawToolbar( EFalse ); |
|
1401 // Check the orientation of the screen. |
|
1402 const TBool isPortrait( Layout_Meta_Data::IsLandscapeOrientation() ? EFalse : ETrue ); |
|
1403 if ( isPortrait ) |
|
1404 { |
|
1405 // If there is a menu shown do not draw the tool bar. It will be drawn |
|
1406 // once the dialog or menu disappears and an event is received from |
|
1407 // the control environment |
|
1408 CCoeAppUi* appUi = CCoeEnv::Static()->AppUi(); |
|
1409 |
|
1410 if ( NeedToHideToolbar(iCurrentCommandId) && |
|
1411 appUi && !appUi->IsDisplayingMenuOrDialog() ) |
|
1412 { |
|
1413 drawToolbar = ETrue; |
|
1414 } |
|
1415 } |
|
1416 else |
|
1417 { |
|
1418 // The orientation is landscape |
|
1419 drawToolbar = ETrue; |
|
1420 } |
|
1421 if ( iToolbar && drawToolbar ) |
|
1422 { |
|
1423 // First show toolbar items |
|
1424 iToolbar->HideItemsAndDrawOnlyBackground( EFalse ); |
|
1425 |
|
1426 // Now show the other components (FindBox etc.) |
|
1427 // No need set the flag as it is not hidden. |
|
1428 if ( iCurrentCommandId != EPbk2CmdWriteNoQuery ) |
|
1429 { |
|
1430 iControl->MakeVisible( ETrue ); |
|
1431 } |
|
1432 // Without the below lines the Toolbar is drawn |
|
1433 // above the Find box |
|
1434 iContainer->SetRect(iView.ClientRect()); |
|
1435 iControl->DrawNow(); |
|
1436 } |
|
1437 if ( EPbk2CmdCreateNew == iCurrentCommandId ) |
|
1438 { |
|
1439 iControl->DrawDeferred(); |
|
1440 } |
|
1441 } |
|
1442 iCurrentCommandId = KErrNotFound; |
|
1443 UpdateCbasL(); |
|
1444 } |
|
1445 |
|
1446 // -------------------------------------------------------------------------- |
|
1447 // CPbk2NamesListExView::DynInitToolbarL |
|
1448 // -------------------------------------------------------------------------- |
|
1449 // |
|
1450 void CPbk2NamesListExView::DynInitToolbarL |
|
1451 ( TInt aResourceId, CAknToolbar* aToolbar ) |
|
1452 { |
|
1453 if ( aToolbar ) |
|
1454 { |
|
1455 if ( iControl ) |
|
1456 { |
|
1457 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1458 ("CPbk2NamesListExView::DynInitToolbarL(0x%x) enable everything"), this); |
|
1459 // By default enable everything |
|
1460 aToolbar->SetItemDimmed( EPbk2CmdCall, EFalse, ETrue ); |
|
1461 aToolbar->SetItemDimmed( EPbk2CmdWriteNoQuery, EFalse, ETrue ); |
|
1462 aToolbar->SetItemDimmed( EPbk2CmdCreateNew, EFalse, ETrue ); |
|
1463 |
|
1464 // Forward to command handler |
|
1465 iCommandHandler->DynInitToolbarL |
|
1466 ( aResourceId, aToolbar, iView, *iControl ); |
|
1467 } |
|
1468 else |
|
1469 { |
|
1470 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1471 ("CPbk2NamesListExView::DynInitToolbarL(0x%x) Disable all buttons"), this); |
|
1472 |
|
1473 // Disable all buttons if control has not yet been created |
|
1474 aToolbar->SetItemDimmed( EPbk2CmdCall, ETrue, ETrue ); |
|
1475 aToolbar->SetItemDimmed( EPbk2CmdWriteNoQuery, ETrue, ETrue ); |
|
1476 aToolbar->SetItemDimmed( EPbk2CmdCreateNew, ETrue, ETrue ); |
|
1477 } |
|
1478 } |
|
1479 } |
|
1480 |
|
1481 // -------------------------------------------------------------------------- |
|
1482 // CPbk2NamesListExView::OfferToolbarEventL |
|
1483 // -------------------------------------------------------------------------- |
|
1484 // |
|
1485 void CPbk2NamesListExView::OfferToolbarEventL |
|
1486 ( TInt aCommand ) |
|
1487 { |
|
1488 iCurrentCommandId = aCommand; |
|
1489 |
|
1490 if ( iControl ) |
|
1491 { |
|
1492 // Forward to command handler |
|
1493 iCommandHandler->HandleCommandL( aCommand, *iControl, &iView ); |
|
1494 } |
|
1495 } |
|
1496 |
|
1497 // -------------------------------------------------------------------------- |
|
1498 // CPbk2NamesListExView::HandleControlEventL |
|
1499 // -------------------------------------------------------------------------- |
|
1500 // |
|
1501 void CPbk2NamesListExView::HandleControlEventL( |
|
1502 CCoeControl* aControl, |
|
1503 TCoeEvent aEventType ) |
|
1504 { |
|
1505 if ( aControl == iToolbar ) |
|
1506 { |
|
1507 // Forward control event to touch pane |
|
1508 CEikAppUiFactory* factory = new(ELeave) CEikAppUiFactory; |
|
1509 CleanupStack::PushL(factory); |
|
1510 CAknTouchPane* pane = factory->TouchPane(); |
|
1511 CleanupStack::PopAndDestroy(factory); |
|
1512 |
|
1513 if ( pane ) |
|
1514 { |
|
1515 pane->HandleControlEventL( aControl, aEventType ); |
|
1516 if (!aControl->IsVisible() && iControl ) |
|
1517 { |
|
1518 iControl->DrawDeferred(); |
|
1519 } |
|
1520 } |
|
1521 |
|
1522 if ( iControl ) |
|
1523 { |
|
1524 // Forward event to view's control |
|
1525 iControl->HandleControlEventL( aControl, aEventType ); |
|
1526 } |
|
1527 |
|
1528 if ( aEventType == EEventStateChanged ) |
|
1529 { |
|
1530 // Save state from idle callback. This gives possibility |
|
1531 // to prevent save if we are e.g. existing the view or just |
|
1532 // disabling the toolbar temporarily. |
|
1533 iIdleToolbarWarden->Cancel(); |
|
1534 iIdleToolbarWarden->Start( TCallBack( |
|
1535 ( &CPbk2NamesListExView::IdleSaveToolbarStateL ), this ) ); |
|
1536 } |
|
1537 } |
|
1538 if ( aControl ==iControl && |
|
1539 aEventType == MCoeControlObserver::EEventStateChanged && |
|
1540 iCommandState ) |
|
1541 { |
|
1542 // If the toolbar is not drawn for some reason, draw it here once |
|
1543 // view's control sends an event after updating itself |
|
1544 if ( iToolbar && !iToolbar->IsShown() ) |
|
1545 { |
|
1546 // First show toolbar items |
|
1547 iToolbar->HideItemsAndDrawOnlyBackground( EFalse ); |
|
1548 |
|
1549 // Now show the other components (FindBox etc.) |
|
1550 // No need set the flag as it is not hide. |
|
1551 if ( iCurrentCommandId != EPbk2CmdWriteNoQuery ) |
|
1552 { |
|
1553 iControl->MakeVisible( ETrue ); |
|
1554 } |
|
1555 |
|
1556 // Without the below lines the Toolbar is drawn |
|
1557 // above the Find box |
|
1558 iContainer->SetRect(iView.ClientRect()); |
|
1559 iControl->DrawNow(); |
|
1560 } |
|
1561 } |
|
1562 } |
|
1563 |
|
1564 // ----------------------------------------------------------------------------- |
|
1565 // CPbk2NamesListExView::MarkingModeStatusChanged |
|
1566 // ----------------------------------------------------------------------------- |
|
1567 // |
|
1568 void CPbk2NamesListExView::MarkingModeStatusChanged( TBool aActivated ) |
|
1569 { |
|
1570 iMarkingModeOn = aActivated; |
|
1571 |
|
1572 // It will return the control findbox by calling |
|
1573 // iControl->ComponentControl(1), which is defined |
|
1574 // in CPbk2NamesListControl::ComponentControl(TInt aIndex). |
|
1575 if ( !iMarkingModeOn && iControl->ComponentControl(1)->IsVisible() ) |
|
1576 { |
|
1577 // Clear the text of the FindBox, when canceling from Marking mode. |
|
1578 TRAP_IGNORE( iControl->ResetFindL() ); |
|
1579 } |
|
1580 iControl->SetMarkingMode( aActivated ); |
|
1581 |
|
1582 // It will return the control listbox by calling |
|
1583 // iControl->ComponentControl(0), which is defined |
|
1584 // in CPbk2NamesListControl::ComponentControl(TInt aIndex). |
|
1585 CPbk2ContactViewListBox* listbox = |
|
1586 static_cast<CPbk2ContactViewListBox*>(iControl->ComponentControl(0)); |
|
1587 listbox->SetMarkingModeState( aActivated ); |
|
1588 } |
|
1589 |
|
1590 // ----------------------------------------------------------------------------- |
|
1591 // CPbk2NamesListExView::ExitMarkingMode |
|
1592 // Called by avkon, if the return value is ETrue, |
|
1593 // the Marking mode will be canceled after any operation, |
|
1594 // otherwise the Marking mode keep active. |
|
1595 // ----------------------------------------------------------------------------- |
|
1596 // |
|
1597 TBool CPbk2NamesListExView::ExitMarkingMode() const |
|
1598 { |
|
1599 return EFalse; |
|
1600 } |
|
1601 |
|
1602 //--------------------------------------------------------------------------- |
|
1603 // CPbk2NamesListExView::CreateControlsL |
|
1604 // -------------------------------------------------------------------------- |
|
1605 // |
|
1606 inline void CPbk2NamesListExView::CreateControlsL() |
|
1607 { |
|
1608 |
|
1609 if (!iContainer) |
|
1610 { |
|
1611 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewCreateControls); |
|
1612 // Create the container and control |
|
1613 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewCreateContainer); |
|
1614 CContainer* container = CContainer::NewLC( &iView, &iView, iView ); |
|
1615 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewCreateContainer); |
|
1616 |
|
1617 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewSetHelpContext); |
|
1618 container->SetHelpContext( TCoeHelpContext( iView.ApplicationUid(), |
|
1619 KPHOB_HLP_NAME_LIST )); |
|
1620 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewSetHelpContext); |
|
1621 |
|
1622 PBK2_PROFILE_START |
|
1623 ( Pbk2Profile::ENamesListViewCreateNamesListControl ); |
|
1624 CPbk2NamesListControl* control = CPbk2NamesListControl::NewL( |
|
1625 R_PBK2_SPB_NAMES_LIST_EXTENSION_CONTROL, |
|
1626 container, |
|
1627 *iContactManager, |
|
1628 *Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
1629 ViewSupplier().AllContactsViewL(), |
|
1630 *iNameFormatter, |
|
1631 Phonebook2::Pbk2AppUi()->ApplicationServices().StoreProperties() ); |
|
1632 |
|
1633 PBK2_PROFILE_END |
|
1634 ( Pbk2Profile::ENamesListViewCreateNamesListControl ); |
|
1635 |
|
1636 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewSetControl); |
|
1637 container->SetControl(control, iView.ClientRect()); // takes ownership |
|
1638 container->AddForegroundObserver( control ); |
|
1639 control->AddObserverL(*this); |
|
1640 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewSetControl); |
|
1641 |
|
1642 PBK2_PROFILE_START(Pbk2Profile::ENamesListViewAddToStack); |
|
1643 CCoeEnv::Static()->AppUi()->AddToStackL(iView, container); |
|
1644 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewAddToStack); |
|
1645 CleanupStack::Pop(container); |
|
1646 iContainer = container; |
|
1647 iControl = control; |
|
1648 iControl->SetObserver(this); |
|
1649 iControlProxy->SetControl( iControl ); |
|
1650 iPointerEventInspector = control; |
|
1651 |
|
1652 // Add command item to container |
|
1653 AddCommandItemsToContainerL(); |
|
1654 PBK2_PROFILE_END(Pbk2Profile::ENamesListViewCreateControls); |
|
1655 } |
|
1656 } |
|
1657 |
|
1658 // -------------------------------------------------------------------------- |
|
1659 // CPbk2NamesListExView::StoreStateL |
|
1660 // -------------------------------------------------------------------------- |
|
1661 // |
|
1662 void CPbk2NamesListExView::StoreStateL() |
|
1663 { |
|
1664 CPbk2ViewState* state = ViewStateLC(); |
|
1665 CleanupStack::Pop(state); |
|
1666 delete iControlState; |
|
1667 iControlState = state; |
|
1668 } |
|
1669 |
|
1670 // -------------------------------------------------------------------------- |
|
1671 // CPbk2NamesListExView::RestoreStateL |
|
1672 // -------------------------------------------------------------------------- |
|
1673 // |
|
1674 void CPbk2NamesListExView::RestoreStateL() |
|
1675 { |
|
1676 iControl->RestoreControlStateL(iControlState); |
|
1677 // Parameter state overrides stored state |
|
1678 iControl->RestoreControlStateL(iParamState); |
|
1679 delete iControlState; |
|
1680 iControlState = NULL; |
|
1681 delete iParamState; |
|
1682 iParamState = NULL; |
|
1683 } |
|
1684 |
|
1685 // -------------------------------------------------------------------------- |
|
1686 // CPbk2NamesListExView::UpdateCbasL |
|
1687 // -------------------------------------------------------------------------- |
|
1688 // |
|
1689 void CPbk2NamesListExView::UpdateCbasL() |
|
1690 { |
|
1691 if ( iControl ) |
|
1692 { |
|
1693 TBool listContainsContacts = ( iControl->NumberOfContacts() > 0 ); |
|
1694 listContainsContacts = listContainsContacts || (iControl->CommandItemCount() > 0); |
|
1695 TBool contactsMarked = iControl->ContactsMarked(); |
|
1696 |
|
1697 if ( listContainsContacts && !contactsMarked ) |
|
1698 { |
|
1699 //For command items msk is select |
|
1700 if( iControl->FocusedContactIndex() == KErrNotFound ) |
|
1701 { |
|
1702 // Set middle softkey as select. |
|
1703 iView.Cba()->SetCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_EXIT_SELECT ); |
|
1704 } |
|
1705 else |
|
1706 { |
|
1707 // Set middle softkey as open cca. |
|
1708 iView.Cba()->SetCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_EXIT_CONNECT ); |
|
1709 } |
|
1710 } |
|
1711 else if ( listContainsContacts && contactsMarked ) |
|
1712 { |
|
1713 // Set middle softkey as Context Icon |
|
1714 iView.Cba()->SetCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_EXIT_CONTEXT ); |
|
1715 } |
|
1716 else // not listContainsContacts && not contactsMarked |
|
1717 { |
|
1718 #ifndef ECE_DISABLE_CONTEXT_MENU |
|
1719 // Set middle softkey as Context Icon. |
|
1720 iView.Cba()->SetCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_EXIT_CONTEXT ); |
|
1721 // Change context menu when nameslist is empty |
|
1722 iView.MenuBar()->SetContextMenuTitleResourceId |
|
1723 ( R_PHONEBOOK2_NAMESLIST_CONTEXT_MENUBAR ); |
|
1724 #else |
|
1725 iView.Cba()->SetCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_EXIT_EMPTY ); |
|
1726 #endif |
|
1727 } |
|
1728 iView.Cba()->DrawDeferred(); |
|
1729 } |
|
1730 |
|
1731 } |
|
1732 |
|
1733 // -------------------------------------------------------------------------- |
|
1734 // CPbk2NamesListExView::IdleSaveToolbarState |
|
1735 // -------------------------------------------------------------------------- |
|
1736 // |
|
1737 TInt CPbk2NamesListExView::IdleSaveToolbarStateL( TAny* aSelf ) |
|
1738 { |
|
1739 CPbk2NamesListExView* self = |
|
1740 static_cast<CPbk2NamesListExView*>( aSelf ); |
|
1741 if ( AknLayoutUtils::PenEnabled() && self && self->iToolbar ) |
|
1742 { |
|
1743 TBool shown = self->iToolbar->IsShown(); |
|
1744 self->ShowToolbarOnViewActivation( shown ); |
|
1745 |
|
1746 // Save state to central repository |
|
1747 CRepository* cenrep = |
|
1748 CRepository::NewLC( TUid::Uid( KCRUidPhonebook ) ); |
|
1749 User::LeaveIfError( |
|
1750 cenrep->Set( KPhonebookNamesListToolbarVisibility, shown ) ); |
|
1751 CleanupStack::PopAndDestroy( cenrep ); |
|
1752 } |
|
1753 return EFalse; // don't call again |
|
1754 } |
|
1755 |
|
1756 void CPbk2NamesListExView::ShowToolbarOnViewActivation(TBool aShown) |
|
1757 { |
|
1758 iView.ShowToolbarOnViewActivation(aShown); |
|
1759 } |
|
1760 // -------------------------------------------------------------------------- |
|
1761 // CPbk2NamesListExView::AttachAIWProvidersL |
|
1762 // -------------------------------------------------------------------------- |
|
1763 // |
|
1764 inline void CPbk2NamesListExView::AttachAIWProvidersL() |
|
1765 { |
|
1766 PBK2_PROFILE_START( Pbk2Profile::ENamesListAIWRegisterInterestCall ); |
|
1767 iCommandHandler->RegisterAiwInterestL |
|
1768 ( KAiwCmdCall, R_PHONEBOOK2_CALL_MENU, |
|
1769 R_PHONEBOOK2_CALLUI_AIW_INTEREST, ETrue ); |
|
1770 PBK2_PROFILE_END( Pbk2Profile::ENamesListAIWRegisterInterestCall ); |
|
1771 |
|
1772 iCommandHandler->RegisterAiwInterestL |
|
1773 ( KAiwCmdCall, R_PHONEBOOK2_STYLUS_CALL_MENU, |
|
1774 R_PHONEBOOK2_CALLUI_AIW_INTEREST, EFalse ); |
|
1775 |
|
1776 PBK2_PROFILE_START( Pbk2Profile::ENamesListAIWRegisterInterestPOC ); |
|
1777 iCommandHandler->RegisterAiwInterestL |
|
1778 ( KAiwCmdPoC, R_PHONEBOOK2_POC_MENU, |
|
1779 R_PHONEBOOK2_POCUI_AIW_INTEREST, ETrue ); |
|
1780 PBK2_PROFILE_END( Pbk2Profile::ENamesListAIWRegisterInterestPOC ); |
|
1781 |
|
1782 PBK2_PROFILE_START( Pbk2Profile::ENamesListAIWRegisterInterestSyncML ); |
|
1783 iCommandHandler->RegisterAiwInterestL |
|
1784 ( KAiwCmdSynchronize, R_PHONEBOOK2_SYNCML_MENU, |
|
1785 R_PHONEBOOK2_SYNCML_AIW_INTEREST, EFalse ); |
|
1786 PBK2_PROFILE_END( Pbk2Profile::ENamesListAIWRegisterInterestSyncML ); |
|
1787 iCommandHandler->RegisterAiwInterestL |
|
1788 ( KOtasAiwCmdSynchronize, R_PHONEBOOK2_OVISYNC_MENU, |
|
1789 R_PHONEBOOK2_OVISYNC_AIW_INTEREST, ETrue ); |
|
1790 } |
|
1791 |
|
1792 // -------------------------------------------------------------------------- |
|
1793 // CPbk2NamesListExView::UpdateListEmptyTextL |
|
1794 // -------------------------------------------------------------------------- |
|
1795 // |
|
1796 void CPbk2NamesListExView::UpdateListEmptyTextL( |
|
1797 TInt aListState ) |
|
1798 { |
|
1799 iListState = aListState; |
|
1800 |
|
1801 if ( !iIdleTexter ) |
|
1802 { |
|
1803 iIdleTexter = CIdle::NewL( CActive::EPriorityStandard ); |
|
1804 } |
|
1805 |
|
1806 iIdleTexter->Cancel(); |
|
1807 iIdleTexter->Start( TCallBack( |
|
1808 ( &CPbk2NamesListExView::IdleSetEmptyTextL ), this ) ); |
|
1809 } |
|
1810 |
|
1811 // -------------------------------------------------------------------------- |
|
1812 // CPbk2NamesListExView::HandleLongTapEventL |
|
1813 // -------------------------------------------------------------------------- |
|
1814 // |
|
1815 void CPbk2NamesListExView::HandleLongTapEventL( |
|
1816 const TPoint& /*aPenEventLocation*/, |
|
1817 const TPoint& /*aPenEventScreenLocation*/ ) |
|
1818 { |
|
1819 //no implementation needed currently |
|
1820 } |
|
1821 |
|
1822 // -------------------------------------------------------------------------- |
|
1823 // CPbk2NamesListExView::Reset |
|
1824 // -------------------------------------------------------------------------- |
|
1825 // |
|
1826 void CPbk2NamesListExView::Reset() |
|
1827 { |
|
1828 if ( iControl ) |
|
1829 { |
|
1830 iControl->Reset(); |
|
1831 } |
|
1832 |
|
1833 delete iControlState; |
|
1834 iControlState = NULL; |
|
1835 delete iParamState; |
|
1836 iParamState = NULL; |
|
1837 } |
|
1838 |
|
1839 // -------------------------------------------------------------------------- |
|
1840 // CPbk2NamesListExView::IdleSetEmptyTextL |
|
1841 // -------------------------------------------------------------------------- |
|
1842 // |
|
1843 TInt CPbk2NamesListExView::IdleSetEmptyTextL( TAny* aSelf ) |
|
1844 { |
|
1845 CPbk2NamesListExView* self = |
|
1846 static_cast<CPbk2NamesListExView*>( aSelf ); |
|
1847 |
|
1848 HBufC* text = NULL; |
|
1849 switch ( self->iListState ) |
|
1850 { |
|
1851 case CPbk2NamesListControl::EStateEmpty: |
|
1852 case CPbk2NamesListControl::EStateNotReady: |
|
1853 { |
|
1854 text = StringLoader::LoadLC( R_QTN_PHOB_NO_ENTRIES_LONG ); |
|
1855 |
|
1856 // Append secondary text |
|
1857 TInt secondaryTextId = R_QTN_PHOB_NO_ENTRIES_LONGER; |
|
1858 if ( self->iListState == CPbk2NamesListControl::EStateNotReady ) |
|
1859 { |
|
1860 secondaryTextId = R_QTN_PHOB_STORES_NA; |
|
1861 } |
|
1862 _LIT( KNewline, "\n" ); |
|
1863 HBufC* secondaryText = StringLoader::LoadLC( secondaryTextId ); |
|
1864 TInt newLength = text->Length() |
|
1865 + KNewline().Length() |
|
1866 + secondaryText->Length(); |
|
1867 text = text->ReAllocL( newLength ); |
|
1868 TPtr ptr = text->Des(); |
|
1869 ptr.Append( KNewline ); |
|
1870 ptr.Append( *secondaryText ); |
|
1871 CleanupStack::PopAndDestroy( secondaryText ); |
|
1872 |
|
1873 // Fix text ptr in cleanup stack, see ReAllocL above |
|
1874 CleanupStack::Pop(); // text |
|
1875 CleanupStack::PushL( text ); |
|
1876 break; |
|
1877 } |
|
1878 case CPbk2NamesListControl::EStateReady: // FALLTHROUGH |
|
1879 case CPbk2NamesListControl::EStateFiltered: |
|
1880 { |
|
1881 text = StringLoader::LoadLC( R_PBK2_FIND_NO_MATCHES ); |
|
1882 |
|
1883 if (self->iListState == CPbk2NamesListControl::EStateFiltered && |
|
1884 self->iControl->NumberOfContacts() == 0 && |
|
1885 self->iStylusPopupMenuLaunched |
|
1886 ) |
|
1887 { |
|
1888 self->iPopupMenu->RemoveMenuItem(EPbk2CmdAddToTopContacts); |
|
1889 self->iPopupMenu->RemoveMenuItem(EPbk2CmdRemoveFromTopContacts); |
|
1890 self->iPopupMenu->RemoveMenuItem(EPbk2CmdEditMe); |
|
1891 self->iPopupMenu->RemoveMenuItem(EPbk2CmdSend); |
|
1892 } |
|
1893 break; |
|
1894 } |
|
1895 default: |
|
1896 { |
|
1897 text = KNullDesC().AllocLC(); |
|
1898 break; |
|
1899 } |
|
1900 } |
|
1901 if ( text ) |
|
1902 { |
|
1903 self->iControl->SetTextL( *text ); |
|
1904 CleanupStack::PopAndDestroy( text ); |
|
1905 self->iControl->DrawDeferred(); |
|
1906 } |
|
1907 |
|
1908 return EFalse; // don't call again |
|
1909 } |
|
1910 |
|
1911 // -------------------------------------------------------------------------- |
|
1912 // CPbk2NamesListExView::NeedToHideToolbar |
|
1913 // -------------------------------------------------------------------------- |
|
1914 // |
|
1915 TBool CPbk2NamesListExView::NeedToHideToolbar(TInt aCurrentCommand) |
|
1916 { |
|
1917 // before show new dialog or pop-up list, etc for the below commands, it is |
|
1918 // required to hide the toolbar, and retrieve it after command complete |
|
1919 if ( aCurrentCommand == EPbk2CmdCreateNew || |
|
1920 aCurrentCommand == EPbk2CmdWrite || |
|
1921 aCurrentCommand == EPbk2CmdAddFavourites || |
|
1922 aCurrentCommand == EPbk2CmdRcl || |
|
1923 aCurrentCommand == EPbk2CmdMoveInTopContactsList || |
|
1924 aCurrentCommand == EPbk2CmdEditMe || |
|
1925 aCurrentCommand == EPbk2CmdWriteNoQuery ) |
|
1926 { |
|
1927 return ETrue; |
|
1928 } |
|
1929 else |
|
1930 { |
|
1931 return EFalse; |
|
1932 } |
|
1933 } |
|
1934 |
|
1935 // -------------------------------------------------------------------------- |
|
1936 // CPbk2NamesListExView::IsPhoneMemoryUsedL |
|
1937 // -------------------------------------------------------------------------- |
|
1938 // |
|
1939 TBool CPbk2NamesListExView::IsPhoneMemoryUsedL() const |
|
1940 { |
|
1941 CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceL(); |
|
1942 |
|
1943 // Get current configuration |
|
1944 CPbk2StoreConfiguration& storeConfig = appServices->StoreConfiguration(); |
|
1945 |
|
1946 CVPbkContactStoreUriArray* uriArray = storeConfig.CurrentConfigurationL(); |
|
1947 |
|
1948 TVPbkContactStoreUriPtr contactUri( VPbkContactStoreUris::DefaultCntDbUri() ); |
|
1949 |
|
1950 // Check is phone memory included |
|
1951 TBool phoneMemory = uriArray->IsIncluded( contactUri ); |
|
1952 |
|
1953 delete uriArray; |
|
1954 Release( appServices ); |
|
1955 |
|
1956 return phoneMemory; |
|
1957 } |
|
1958 |
|
1959 // -------------------------------------------------------------------------- |
|
1960 // CPbk2NamesListExView::HandleGainingForeground |
|
1961 // -------------------------------------------------------------------------- |
|
1962 // |
|
1963 void CPbk2NamesListExView::HandleGainingForeground() |
|
1964 { |
|
1965 // If the control state is not the same as the state before losing forground |
|
1966 // set it back to the state before losing forground. |
|
1967 if( iControl && ( ( iControl->IsVisible() && !iCtrlVisibleStateBeforeLosingForground ) || |
|
1968 ( !iControl->IsVisible() && iCtrlVisibleStateBeforeLosingForground ) ) ) |
|
1969 { |
|
1970 iControl->MakeVisible( iCtrlVisibleStateBeforeLosingForground ); |
|
1971 } |
|
1972 |
|
1973 // This flag is used to force the find box to be re-initialized when the application |
|
1974 // is back in the foreground. |
|
1975 iNeedSetFocus = ETrue; |
|
1976 } |
|
1977 |
|
1978 // -------------------------------------------------------------------------- |
|
1979 // CPbk2NamesListExView::HandleLosingForeground |
|
1980 // -------------------------------------------------------------------------- |
|
1981 // |
|
1982 void CPbk2NamesListExView::HandleLosingForeground() |
|
1983 { |
|
1984 // If some command is executing now and control state is invisible. Set the control |
|
1985 // visible before it hide in background. |
|
1986 // To do this is because some special states, like creating new contact or |
|
1987 // creating new message, the iControl will be set invisible (In the function the control |
|
1988 // set invisible in the function PreCommandExecutionL which is to avoid displaying two |
|
1989 // find boxes after press the create new contact button). And during the command |
|
1990 // executing, set the control visible before it is hided into background.This is make |
|
1991 // sure that the control should be updated after it set foreground again. |
|
1992 if( iControl ) |
|
1993 { |
|
1994 iCtrlVisibleStateBeforeLosingForground = iControl->IsVisible(); |
|
1995 if( !iCommandState && !iCtrlVisibleStateBeforeLosingForground ) |
|
1996 { |
|
1997 iControl->MakeVisible( ETrue ); |
|
1998 } |
|
1999 } |
|
2000 |
|
2001 // This flag is used to force the find box to be re-initialized when the application |
|
2002 // is back in the foreground. |
|
2003 iNeedSetFocus = EFalse; |
|
2004 } |
|
2005 |
|
2006 // -------------------------------------------------------------------------- |
|
2007 // CPbk2NamesListExView::UIExtensionViewExtension |
|
2008 // -------------------------------------------------------------------------- |
|
2009 // |
|
2010 TAny* CPbk2NamesListExView::UIExtensionViewExtension( |
|
2011 TUid aExtensionUid ) |
|
2012 { |
|
2013 if( aExtensionUid == KMPbk2UIExtensionView2Uid ) |
|
2014 { |
|
2015 return static_cast<MPbk2UIExtensionView2*>( this ); |
|
2016 } |
|
2017 |
|
2018 return NULL; |
|
2019 } |
|
2020 |
|
2021 // -------------------------------------------------------------------------- |
|
2022 // CPbk2NamesListExView::HandleForegroundEventL |
|
2023 // -------------------------------------------------------------------------- |
|
2024 // |
|
2025 void CPbk2NamesListExView::HandleForegroundEventL(TBool aForeground) |
|
2026 { |
|
2027 if ( iControl ) |
|
2028 { |
|
2029 iControl->HandleViewForegroundEventL( aForeground ); |
|
2030 } |
|
2031 } |
|
2032 |
|
2033 // End of File |