|
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 Group UI extension group view. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPguGroupView.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "Pbk2GroupUi.hrh" |
|
23 #include <CPbk2UIExtensionView.h> |
|
24 #include <CPbk2AppUiBase.h> |
|
25 #include <CPbk2NamesListControl.h> |
|
26 #include <CPbk2ViewState.h> |
|
27 #include <CPbk2ControlContainer.h> |
|
28 #include <MPbk2ViewActivationTransaction.h> |
|
29 #include <MPbk2ViewExplorer.h> |
|
30 #include <CPbk2StoreConfiguration.h> |
|
31 #include <Pbk2GroupUIRes.rsg> |
|
32 #include <Pbk2CommonUi.rsg> |
|
33 #include <Pbk2Commands.rsg> |
|
34 #include <Pbk2UIControls.rsg> |
|
35 #include <csxhelp/phob.hlp.hrh> |
|
36 #include <MPbk2CommandHandler.h> |
|
37 #include <Pbk2UID.h> |
|
38 #include <MPbk2AppUi.h> |
|
39 #include <CPbk2ViewStateTransformer.h> |
|
40 #include <MPbk2StartupMonitor.h> |
|
41 #include <CPbk2StorePropertyArray.h> |
|
42 #include <CPbk2StoreProperty.h> |
|
43 #include <MPbk2ApplicationServices.h> |
|
44 #include <MPbk2ContactViewSupplier.h> |
|
45 |
|
46 // Virtual Phonebook |
|
47 #include <MVPbkContactStoreList.h> |
|
48 #include <CVPbkContactStoreUriArray.h> |
|
49 #include <MVPbkContactStore.h> |
|
50 #include <CVPbkContactManager.h> |
|
51 #include <TVPbkContactStoreUriPtr.h> |
|
52 #include <MVPbkContactStoreProperties.h> |
|
53 #include <VPbkContactStoreUris.h> |
|
54 #include <MVPbkContactViewBase.h> |
|
55 |
|
56 // System includes |
|
57 #include <eikmenup.h> |
|
58 #include <eikbtgpc.h> |
|
59 #include <avkon.rsg> |
|
60 #include <featmgr.h> |
|
61 #include <StringLoader.h> |
|
62 #include <AiwCommon.hrh> |
|
63 #include <eikmenub.h> |
|
64 #include <AknUtils.h> |
|
65 #include <eiklbx.h> |
|
66 #include <eiklbo.h> |
|
67 #include <coecntrl.h> |
|
68 #include <touchfeedback.h> |
|
69 |
|
70 /// Unnamed namespace for local definitions |
|
71 namespace { |
|
72 |
|
73 _LIT( KNewline, "\n" ); |
|
74 |
|
75 /** |
|
76 * Returns ETrue if shift is depressed in given key event. |
|
77 * |
|
78 * @param aKeyEvent Key event |
|
79 * @return ETrue if shift is depressed. |
|
80 */ |
|
81 inline TBool ShiftDown( const TKeyEvent& aKeyEvent ) |
|
82 { |
|
83 return ( aKeyEvent.iModifiers & |
|
84 ( EModifierShift|EModifierLeftShift|EModifierRightShift ) ) != 0; |
|
85 } |
|
86 |
|
87 } /// namespace |
|
88 |
|
89 // -------------------------------------------------------------------------- |
|
90 // CPguGroupView::CPguGroupView |
|
91 // -------------------------------------------------------------------------- |
|
92 // |
|
93 CPguGroupView::CPguGroupView( CPbk2UIExtensionView& aView ) : |
|
94 iView( aView ) |
|
95 { |
|
96 } |
|
97 |
|
98 // -------------------------------------------------------------------------- |
|
99 // CPguGroupView::~CPguGroupView |
|
100 // -------------------------------------------------------------------------- |
|
101 // |
|
102 CPguGroupView::~CPguGroupView() |
|
103 { |
|
104 if ( iStoreConfiguration ) |
|
105 { |
|
106 iStoreConfiguration->RemoveObserver( *this ); |
|
107 } |
|
108 |
|
109 delete iControlState; |
|
110 delete iParamState; |
|
111 |
|
112 if ( iContainer ) |
|
113 { |
|
114 CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer ); |
|
115 delete iContainer; |
|
116 } |
|
117 } |
|
118 |
|
119 // -------------------------------------------------------------------------- |
|
120 // CPguGroupView::NewL |
|
121 // -------------------------------------------------------------------------- |
|
122 // |
|
123 CPguGroupView* CPguGroupView::NewL( CPbk2UIExtensionView& aView ) |
|
124 { |
|
125 CPguGroupView* self = new ( ELeave ) CPguGroupView( aView ); |
|
126 CleanupStack::PushL( self ); |
|
127 self->ConstructL(); |
|
128 CleanupStack::Pop( self ); |
|
129 return self; |
|
130 } |
|
131 |
|
132 // -------------------------------------------------------------------------- |
|
133 // CPguGroupView::ConstructL |
|
134 // -------------------------------------------------------------------------- |
|
135 // |
|
136 inline void CPguGroupView::ConstructL() |
|
137 { |
|
138 iStoreConfiguration = &Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
139 StoreConfiguration(); |
|
140 |
|
141 iStoreConfiguration->AddObserverL( *this ); |
|
142 |
|
143 iCommandHandler = Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
144 CommandHandlerL(); |
|
145 |
|
146 // Attach AIW providers |
|
147 iCommandHandler->RegisterAiwInterestL |
|
148 ( KAiwCmdPoC, R_PHONEBOOK2_GROUPVIEWS_POC_MENU, |
|
149 R_PHONEBOOK2_POCUI_AIW_INTEREST, ETrue ); |
|
150 } |
|
151 |
|
152 // -------------------------------------------------------------------------- |
|
153 // CPguGroupView::HandleStatusPaneSizeChange |
|
154 // -------------------------------------------------------------------------- |
|
155 // |
|
156 void CPguGroupView::HandleStatusPaneSizeChange() |
|
157 { |
|
158 // Resize the container to fill the client rectangle |
|
159 if ( iContainer ) |
|
160 { |
|
161 iContainer->SetRect( iView.ClientRect() ); |
|
162 } |
|
163 } |
|
164 |
|
165 // -------------------------------------------------------------------------- |
|
166 // CPguGroupView::ViewStateLC |
|
167 // -------------------------------------------------------------------------- |
|
168 // |
|
169 CPbk2ViewState* CPguGroupView::ViewStateLC() const |
|
170 { |
|
171 CPbk2ViewState* state = iControl->ControlStateL(); |
|
172 CleanupStack::PushL( state ); |
|
173 return state; |
|
174 } |
|
175 |
|
176 // -------------------------------------------------------------------------- |
|
177 // CPguGroupView::HandleCommandKeyL |
|
178 // -------------------------------------------------------------------------- |
|
179 // |
|
180 TBool CPguGroupView::HandleCommandKeyL |
|
181 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
182 { |
|
183 TBool result = EFalse; |
|
184 TBool itemSpecEnabled = |
|
185 Phonebook2::Pbk2AppUi()->ActiveView()->MenuBar()->ItemSpecificCommandsEnabled(); |
|
186 if ( itemSpecEnabled && (EStdKeyHash == aKeyEvent.iScanCode) ) |
|
187 { |
|
188 //make sure Hash key won't be passed to default keyHandler |
|
189 return ETrue; |
|
190 } |
|
191 if ( aType == EEventKey ) |
|
192 { |
|
193 switch ( aKeyEvent.iCode ) |
|
194 { |
|
195 case EKeyBackspace: |
|
196 { |
|
197 if ( itemSpecEnabled && ( iControl->NumberOfContacts() > 0 ) && |
|
198 ( iControl->FindTextL() == KNullDesC ) ) |
|
199 { |
|
200 HandleCommandL( EPbk2CmdRemoveGroup ); |
|
201 result = ETrue; |
|
202 } |
|
203 break; |
|
204 } |
|
205 case EKeyEnter: // FALLTHROUGH |
|
206 case EKeyOK: |
|
207 { |
|
208 if ( !ShiftDown( aKeyEvent ) // pure OK or ENTER key |
|
209 && iControl->NumberOfContacts() == 0 ) |
|
210 { |
|
211 result = ETrue; |
|
212 } |
|
213 break; |
|
214 } |
|
215 default: |
|
216 { |
|
217 break; |
|
218 } |
|
219 } |
|
220 } |
|
221 return result; |
|
222 } |
|
223 |
|
224 |
|
225 |
|
226 // ---------------------------------------------------------------------------- |
|
227 // CPguGroupView::HandleListBoxEventL |
|
228 // ---------------------------------------------------------------------------- |
|
229 // |
|
230 void CPguGroupView::HandleListBoxEventL(CEikListBox* /*aListBox*/,TListBoxEvent aEventType) |
|
231 { |
|
232 |
|
233 |
|
234 if( AknLayoutUtils::PenEnabled() ) |
|
235 { |
|
236 switch ( aEventType ) |
|
237 { |
|
238 case EEventItemSingleClicked: |
|
239 { |
|
240 ShowContextMenuL(); |
|
241 break; |
|
242 } |
|
243 case EEventItemClicked: //Happens after focus changed |
|
244 break; |
|
245 case EEventEnterKeyPressed: |
|
246 { |
|
247 // Select key is mapped to "Open Group" command |
|
248 HandleCommandL( EPbk2CmdOpenGroup ); |
|
249 break; |
|
250 } |
|
251 default: |
|
252 break; |
|
253 } |
|
254 } |
|
255 |
|
256 |
|
257 |
|
258 } |
|
259 |
|
260 |
|
261 // -------------------------------------------------------------------------- |
|
262 // CPguGroupView::HandlePointerEventL |
|
263 // -------------------------------------------------------------------------- |
|
264 // |
|
265 void CPguGroupView::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
266 { |
|
267 if ( AknLayoutUtils::PenEnabled() ) |
|
268 { |
|
269 if ( iPointerEventInspector->FocusableItemPointed() && iContainer ) |
|
270 { |
|
271 iContainer->LongTapDetectorL().PointerEventL( aPointerEvent ); |
|
272 } |
|
273 if ( iControl->NumberOfContacts()==0) |
|
274 { |
|
275 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
276 { |
|
277 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
278 if ( feedback ) |
|
279 { |
|
280 feedback->InstantFeedback( ETouchFeedbackNone ); |
|
281 } |
|
282 } |
|
283 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
284 { |
|
285 ShowContextMenuL(); |
|
286 } |
|
287 } |
|
288 |
|
289 } |
|
290 } |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 // -------------------------------------------------------------------------- |
|
298 // CPguGroupView::ShowContextMenuL |
|
299 // -------------------------------------------------------------------------- |
|
300 // |
|
301 void CPguGroupView::ShowContextMenuL() |
|
302 { |
|
303 |
|
304 if ( iStylusPopupMenuLaunched ) |
|
305 { |
|
306 // Absorb EButton1Up event if we already launched the stylus |
|
307 // popup menu |
|
308 iStylusPopupMenuLaunched = EFalse; |
|
309 } |
|
310 else if ( !iPointerEventInspector->SearchFieldPointed() ) |
|
311 { |
|
312 if ( iControl->NumberOfContacts() > 0 ) |
|
313 { |
|
314 if ( iPointerEventInspector->FocusedItemPointed() ) |
|
315 { |
|
316 // Open group |
|
317 HandleCommandL(EPbk2CmdOpenGroup); |
|
318 } |
|
319 } |
|
320 } |
|
321 } |
|
322 |
|
323 |
|
324 |
|
325 // -------------------------------------------------------------------------- |
|
326 // CPguGroupView::GetViewSpecificMenuFilteringFlagsL |
|
327 // -------------------------------------------------------------------------- |
|
328 // |
|
329 TInt CPguGroupView::GetViewSpecificMenuFilteringFlagsL() const |
|
330 { |
|
331 TInt flags( 0 ); |
|
332 flags |= CurrentStoreSupportsGroupsL(); |
|
333 if ( iControl ) |
|
334 { |
|
335 flags |= iControl->GetMenuFilteringFlagsL(); |
|
336 } |
|
337 return flags; |
|
338 } |
|
339 |
|
340 // -------------------------------------------------------------------------- |
|
341 // CPguGroupView::DoActivateL |
|
342 // -------------------------------------------------------------------------- |
|
343 // |
|
344 void CPguGroupView::DoActivateL |
|
345 ( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, |
|
346 const TDesC8& aCustomMessage ) |
|
347 { |
|
348 // Add this view to observe menu command events |
|
349 iCommandHandler->AddMenuCommandObserver(*this); |
|
350 |
|
351 HBufC* title = StringLoader::LoadLC( R_QTN_PHOB_TITLE ); |
|
352 |
|
353 MPbk2ViewActivationTransaction* viewActivationTransaction = |
|
354 Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC |
|
355 ( iView.Id(), aPrevViewId, title, NULL, |
|
356 Phonebook2::EUpdateNaviPane | Phonebook2::EUpdateTitlePane | |
|
357 Phonebook2::EUpdateContextPane ); |
|
358 |
|
359 // Check activation parameters |
|
360 delete iParamState; |
|
361 iParamState = NULL; |
|
362 if ( aCustomMessageId == CPbk2ViewState::Uid() ) |
|
363 { |
|
364 iParamState = CPbk2ViewState::NewL( aCustomMessage ); |
|
365 } |
|
366 else if (aCustomMessageId == TUid::Uid(KPbkViewStateUid)) |
|
367 { |
|
368 // Handle legacy view state |
|
369 CPbk2ViewStateTransformer* transformer = CPbk2ViewStateTransformer::NewLC |
|
370 ( Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager() ); |
|
371 iParamState = transformer-> |
|
372 TransformLegacyViewStateToPbk2ViewStateLC( aCustomMessage ); |
|
373 CleanupStack::Pop(); |
|
374 CleanupStack::PopAndDestroy( transformer ); |
|
375 } |
|
376 |
|
377 // Notifies startup monitor of view activation |
|
378 if (Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()) |
|
379 { |
|
380 Phonebook2::Pbk2AppUi()->Pbk2StartupMonitor()-> |
|
381 NotifyViewActivationL( iView.Id(), |
|
382 *Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
383 ViewSupplier().AllGroupsViewL() ); |
|
384 } |
|
385 |
|
386 CreateControlsL(); |
|
387 iContainer->ActivateL(); |
|
388 |
|
389 |
|
390 CCoeControl* ctrl=iControl->ComponentControl(0); |
|
391 CEikListBox* listbox=static_cast <CEikListBox*> (ctrl); |
|
392 listbox->SetListBoxObserver( this ); |
|
393 |
|
394 |
|
395 viewActivationTransaction->Commit(); |
|
396 CleanupStack::PopAndDestroy( 2 ); //title, viewActivationTransaction |
|
397 |
|
398 // Should be here because in NOT READY case view does not become ready |
|
399 // and cbas are not updated without this. |
|
400 UpdateCbasL(); |
|
401 } |
|
402 |
|
403 // -------------------------------------------------------------------------- |
|
404 // CPguGroupView::DoDeactivate |
|
405 // -------------------------------------------------------------------------- |
|
406 // |
|
407 void CPguGroupView::DoDeactivate() |
|
408 { |
|
409 iCommandHandler->RemoveMenuCommandObserver( *this ); |
|
410 // Trash the old states |
|
411 delete iParamState; |
|
412 iParamState = NULL; |
|
413 delete iControlState; |
|
414 iControlState = NULL; |
|
415 |
|
416 if ( iContainer ) |
|
417 { |
|
418 CCoeEnv::Static()->AppUi()->RemoveFromStack( iContainer ); |
|
419 // Store current state, safe to ignore. There's no real harm, |
|
420 // if theres no stored state when activating this view again |
|
421 TRAP_IGNORE( StoreStateL() ); |
|
422 delete iContainer; |
|
423 iContainer = NULL; |
|
424 iControl = NULL; |
|
425 } |
|
426 } |
|
427 |
|
428 // -------------------------------------------------------------------------- |
|
429 // CPguGroupView::HandleCommandL |
|
430 // -------------------------------------------------------------------------- |
|
431 // |
|
432 void CPguGroupView::HandleCommandL( TInt aCommand ) |
|
433 { |
|
434 // this will leave if control is NULL due to e.g. bad view switch |
|
435 CheckUiControlL(); |
|
436 switch( aCommand ) |
|
437 { |
|
438 case EAknCmdExit: |
|
439 case EAknSoftkeyExit: |
|
440 case EPbk2CmdExit: |
|
441 case EAknCmdHideInBackground: |
|
442 { |
|
443 // AppUi will send the application to background. |
|
444 // Because the control is not destroyed it must be reset so that |
|
445 // when the view comes foreground again it will look like a fresh |
|
446 // and brand new control. |
|
447 iControl->Reset(); |
|
448 break; |
|
449 } |
|
450 default: |
|
451 break; |
|
452 } |
|
453 // No command handling in this class, forward to Commands |
|
454 if ( !iCommandHandler->HandleCommandL( aCommand, *iControl, &iView ) ) |
|
455 { |
|
456 iControl->ProcessCommandL( aCommand ); |
|
457 Phonebook2::Pbk2AppUi()->HandleCommandL( aCommand ); |
|
458 UpdateCbasL(); |
|
459 } |
|
460 } |
|
461 |
|
462 // -------------------------------------------------------------------------- |
|
463 // CPguGroupView::DynInitMenuPaneL |
|
464 // -------------------------------------------------------------------------- |
|
465 // |
|
466 void CPguGroupView::DynInitMenuPaneL( |
|
467 TInt aResourceId, |
|
468 CEikMenuPane* aMenuPane ) |
|
469 { |
|
470 |
|
471 // this will leave if control is NULL due to e.g. bad view switch |
|
472 CheckUiControlL(); |
|
473 |
|
474 |
|
475 if ( iControl ) |
|
476 { |
|
477 // Ask the control do control specific filtering |
|
478 // (for example call HandleMarkableListDynInitMenuPane if needed) |
|
479 iControl->DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
480 } |
|
481 |
|
482 switch ( aResourceId ) |
|
483 { |
|
484 case R_PHONEBOOK2_GROUPSLIST_MENU: |
|
485 { |
|
486 if ( !CurrentStoreSupportsGroupsL() ) |
|
487 { |
|
488 aMenuPane->SetItemDimmed( EPbk2CmdCreateNewGroup, ETrue ); |
|
489 } |
|
490 // Weed out commands not meant to be used with empty list |
|
491 if ( iControl->NumberOfContacts() == 0 ) |
|
492 { |
|
493 aMenuPane->SetItemDimmed( EPbk2CmdOpenGroup, ETrue ); |
|
494 aMenuPane->SetItemDimmed( EPbk2CmdWriteGroup, ETrue ); |
|
495 aMenuPane->SetItemDimmed( EPbk2CmdRemoveGroup, ETrue ); |
|
496 aMenuPane->SetItemDimmed( EPbk2CmdRenameGroup, ETrue ); |
|
497 aMenuPane->SetItemDimmed( EPbk2CmdSetToneToGroup, ETrue ); |
|
498 } |
|
499 break; |
|
500 } |
|
501 |
|
502 case R_PHONEBOOK2_GROUPLIST_CONTEXT_MENU: |
|
503 { |
|
504 if( !CurrentStoreSupportsGroupsL() ) |
|
505 { |
|
506 aMenuPane->SetItemDimmed( EPbk2CmdCreateNewGroup, ETrue ); |
|
507 } |
|
508 break; |
|
509 } |
|
510 |
|
511 default: |
|
512 { |
|
513 // Phonebook 2 menu filtering happens in Commands |
|
514 iCommandHandler->DynInitMenuPaneL( |
|
515 aResourceId, aMenuPane, iView, *iControl ); |
|
516 } |
|
517 } |
|
518 } |
|
519 |
|
520 // -------------------------------------------------------------------------- |
|
521 // CPguGroupView::HandleLongTapEventL |
|
522 // -------------------------------------------------------------------------- |
|
523 // |
|
524 void CPguGroupView::HandleLongTapEventL( |
|
525 const TPoint& /*aPenEventLocation*/, |
|
526 const TPoint& aPenEventScreenLocation ) |
|
527 { |
|
528 if( iControl->ContactsMarked() ) |
|
529 { |
|
530 //if there are marked contacts, context menu should not open |
|
531 return; |
|
532 } |
|
533 } |
|
534 |
|
535 // -------------------------------------------------------------------------- |
|
536 // CPguGroupView::HandleControlEventL |
|
537 // -------------------------------------------------------------------------- |
|
538 // |
|
539 void CPguGroupView::HandleControlEventL |
|
540 ( MPbk2ContactUiControl& /*aControl*/, |
|
541 const TPbk2ControlEvent& aEvent ) |
|
542 { |
|
543 switch ( aEvent.iEventType ) |
|
544 { |
|
545 case TPbk2ControlEvent::EReady: |
|
546 { |
|
547 UpdateCbasL(); |
|
548 |
|
549 // Restore control state |
|
550 RestoreStateL(); |
|
551 break; |
|
552 } |
|
553 case TPbk2ControlEvent::EItemAdded: |
|
554 case TPbk2ControlEvent::EItemRemoved: |
|
555 case TPbk2ControlEvent::EContactSetChanged: |
|
556 { |
|
557 UpdateCbasL(); |
|
558 break; |
|
559 } |
|
560 case TPbk2ControlEvent::EControlStateChanged: |
|
561 { |
|
562 UpdateCbasL(); |
|
563 iListControlState = aEvent.iInt; |
|
564 UpdateListEmptyTextL(); |
|
565 iContainer->Control()->DrawDeferred(); |
|
566 break; |
|
567 } |
|
568 default: |
|
569 { |
|
570 // Do nothing |
|
571 break; |
|
572 } |
|
573 } |
|
574 } |
|
575 |
|
576 // -------------------------------------------------------------------------- |
|
577 // CPguGroupView::ConfigurationChanged |
|
578 // -------------------------------------------------------------------------- |
|
579 // |
|
580 void CPguGroupView::ConfigurationChanged() |
|
581 { |
|
582 if ( iContainer ) |
|
583 { |
|
584 iContainer->Control()->Reset(); |
|
585 } |
|
586 } |
|
587 |
|
588 // -------------------------------------------------------------------------- |
|
589 // CPguGroupView::ConfigurationChangedComplete |
|
590 // -------------------------------------------------------------------------- |
|
591 // |
|
592 void CPguGroupView::ConfigurationChangedComplete() |
|
593 { |
|
594 if ( iContainer ) |
|
595 { |
|
596 TRAPD( error, HandleConfigurationChangeL() ); |
|
597 if ( error != KErrNone ) |
|
598 { |
|
599 CCoeEnv::Static()->HandleError( error ); |
|
600 iContainer->Control()->Reset(); |
|
601 } |
|
602 } |
|
603 } |
|
604 |
|
605 // -------------------------------------------------------------------------- |
|
606 // CPguGroupView::PreCommandExecutionL |
|
607 // -------------------------------------------------------------------------- |
|
608 // |
|
609 void CPguGroupView::PreCommandExecutionL |
|
610 ( const MPbk2Command& /*aCommand*/ ) |
|
611 { |
|
612 // Do nothing |
|
613 } |
|
614 |
|
615 // -------------------------------------------------------------------------- |
|
616 // CPguGroupMembersView::PostCommandExecutionL |
|
617 // -------------------------------------------------------------------------- |
|
618 // |
|
619 void CPguGroupView::PostCommandExecutionL |
|
620 ( const MPbk2Command& /*aCommand*/ ) |
|
621 { |
|
622 UpdateCbasL(); |
|
623 } |
|
624 |
|
625 // -------------------------------------------------------------------------- |
|
626 // CPguGroupView::CurrentStoreSupportsGroupsL |
|
627 // -------------------------------------------------------------------------- |
|
628 // |
|
629 TBool CPguGroupView::CurrentStoreSupportsGroupsL() const |
|
630 { |
|
631 TBool ret = EFalse; |
|
632 MVPbkContactStoreList& stores = |
|
633 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
634 ContactManager().ContactStoresL(); |
|
635 CVPbkContactStoreUriArray* uris = |
|
636 iStoreConfiguration->CurrentConfigurationL(); |
|
637 CleanupStack::PushL( uris ); |
|
638 |
|
639 const TInt count = uris->Count(); |
|
640 for ( TInt i = count - 1; i >= 0; --i ) |
|
641 { |
|
642 MVPbkContactStore* store = stores.Find( ( *uris )[i] ); |
|
643 if ( store ) |
|
644 { |
|
645 // If we found atleast one store having groups we |
|
646 // return the flag. |
|
647 if ( store->StoreProperties().SupportsContactGroups() ) |
|
648 { |
|
649 ret = ETrue; |
|
650 break; |
|
651 } |
|
652 } |
|
653 } |
|
654 |
|
655 CleanupStack::PopAndDestroy( uris ); |
|
656 return ret; |
|
657 } |
|
658 |
|
659 // -------------------------------------------------------------------------- |
|
660 // CPguGroupView::CreateControlsL |
|
661 // -------------------------------------------------------------------------- |
|
662 // |
|
663 void CPguGroupView::CreateControlsL() |
|
664 { |
|
665 if ( !iContainer ) |
|
666 { |
|
667 // Create the container and control |
|
668 CContainer* container = CContainer::NewLC( &iView, &iView, iView ); |
|
669 |
|
670 container->SetHelpContext( TCoeHelpContext |
|
671 ( iView.ApplicationUid(), KPHOB_HLP_GROUP_LIST ) ); |
|
672 |
|
673 MPbk2ApplicationServices& appServices = |
|
674 Phonebook2::Pbk2AppUi()->ApplicationServices(); |
|
675 |
|
676 CPbk2NamesListControl* control = CPbk2NamesListControl::NewL |
|
677 ( R_PBK2_GROUPS_LIST_CONTROL, container, |
|
678 appServices.ContactManager(), |
|
679 *appServices.ViewSupplier().AllGroupsViewL(), |
|
680 appServices.NameFormatter(), |
|
681 appServices.StoreProperties() ); |
|
682 CleanupStack::PushL( control ); |
|
683 |
|
684 control->AddObserverL( *this ); |
|
685 // takes ownership |
|
686 container->SetControl( control, iView.ClientRect() ); |
|
687 CleanupStack::Pop( control ); |
|
688 |
|
689 CCoeEnv::Static()->AppUi()->AddToStackL( iView, container ); |
|
690 CleanupStack::Pop( container ); |
|
691 iContainer = container; |
|
692 iControl = control; |
|
693 iPointerEventInspector = control; |
|
694 } |
|
695 } |
|
696 |
|
697 // -------------------------------------------------------------------------- |
|
698 // CPguGroupView::StoreStateL |
|
699 // -------------------------------------------------------------------------- |
|
700 // |
|
701 void CPguGroupView::StoreStateL() |
|
702 { |
|
703 CPbk2ViewState* state = ViewStateLC(); |
|
704 CleanupStack::Pop(state); |
|
705 if ( state ) |
|
706 { |
|
707 delete iControlState; |
|
708 iControlState = state; |
|
709 } |
|
710 } |
|
711 |
|
712 // -------------------------------------------------------------------------- |
|
713 // CPguGroupView::RestoreStateL |
|
714 // -------------------------------------------------------------------------- |
|
715 // |
|
716 void CPguGroupView::RestoreStateL() |
|
717 { |
|
718 iControl->RestoreControlStateL( iControlState ); |
|
719 iControl->RestoreControlStateL( iParamState); |
|
720 delete iControlState; |
|
721 iControlState = NULL; |
|
722 } |
|
723 |
|
724 // -------------------------------------------------------------------------- |
|
725 // CPguGroupView::UpdateCbasL |
|
726 // -------------------------------------------------------------------------- |
|
727 // |
|
728 void CPguGroupView::UpdateCbasL() |
|
729 { |
|
730 if ( iControl ) |
|
731 { |
|
732 if ( iControl->NumberOfContacts() > 0 ) |
|
733 { |
|
734 // Set middle softkey as Open. |
|
735 iView.Cba()->SetCommandSetL( R_PGU_SOFTKEYS_OPTIONS_EXIT_OPEN ); |
|
736 iView.Cba()->DrawDeferred(); |
|
737 } |
|
738 else |
|
739 { |
|
740 // Set middle softkey as Context menu. |
|
741 iView.Cba()->SetCommandSetL( |
|
742 R_PBK2_SOFTKEYS_OPTIONS_EXIT_CONTEXT ); |
|
743 iView.Cba()->DrawDeferred(); |
|
744 // Change context menu when nameslist is empty |
|
745 iView.MenuBar()->SetContextMenuTitleResourceId |
|
746 ( R_PHONEBOOK2_GROUPLIST_CONTEXT_MENUBAR ); |
|
747 } |
|
748 } |
|
749 } |
|
750 |
|
751 |
|
752 // -------------------------------------------------------------------------- |
|
753 // CPguGroupView::UpdateListEmptyTextL |
|
754 // -------------------------------------------------------------------------- |
|
755 // |
|
756 void CPguGroupView::UpdateListEmptyTextL() |
|
757 { |
|
758 HBufC* text = NULL; |
|
759 switch ( iListControlState ) |
|
760 { |
|
761 case CPbk2NamesListControl::EStateEmpty: |
|
762 case CPbk2NamesListControl::EStateNotReady: |
|
763 { |
|
764 text = StringLoader::LoadLC( R_QTN_PHOB_NO_GROUPS ); |
|
765 |
|
766 CVPbkContactStoreUriArray* uris = |
|
767 iStoreConfiguration->CurrentConfigurationL(); |
|
768 CleanupStack::PushL( uris ); |
|
769 |
|
770 HBufC* helpText = NULL; |
|
771 TInt numberOfStores = uris->Count(); |
|
772 if ( CurrentStoreSupportsGroupsL() ) |
|
773 { |
|
774 // At least one memory in use which supports groups |
|
775 helpText = StringLoader::LoadLC( R_QTN_PHOB_NO_GROUPS_LONGER ); |
|
776 } |
|
777 else if ( numberOfStores > 1 ) |
|
778 { |
|
779 // More than one memories in use, but none of them support groups |
|
780 helpText = StringLoader::LoadLC( R_QTN_PHOB_NO_GROUPS_STORES ); |
|
781 } |
|
782 else if ( numberOfStores == 1 ) |
|
783 { |
|
784 // The only used memory does not support groups |
|
785 const CPbk2StoreProperty* props = |
|
786 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
787 StoreProperties().FindProperty( (*uris)[0] ); |
|
788 if ( props ) |
|
789 { |
|
790 helpText = StringLoader::LoadLC( |
|
791 R_QTN_PHOB_NO_GROUPS_STORE, props->StoreName() ); |
|
792 } |
|
793 } |
|
794 |
|
795 if ( !helpText ) |
|
796 { |
|
797 CleanupStack::PopAndDestroy(); // uris |
|
798 } |
|
799 else |
|
800 { |
|
801 TInt newLength = text->Length() |
|
802 + KNewline().Length() |
|
803 + helpText->Length(); |
|
804 |
|
805 text = text->ReAllocL( newLength ); |
|
806 // note: no leaves beyond this point, otherwise |
|
807 text->Des().Append( KNewline ); |
|
808 text->Des().Append( *helpText ); |
|
809 |
|
810 CleanupStack::PopAndDestroy( 2 ); // helpText, uris |
|
811 // update the reallocated 'text' pointer in cleanup stack |
|
812 CleanupStack::Pop(); // text |
|
813 CleanupStack::PushL( text ); |
|
814 } |
|
815 break; |
|
816 } |
|
817 default: |
|
818 { |
|
819 text = KNullDesC().AllocLC(); |
|
820 break; |
|
821 } |
|
822 } |
|
823 if ( text ) |
|
824 { |
|
825 iControl->SetTextL( *text ); |
|
826 CleanupStack::PopAndDestroy(); // text |
|
827 } |
|
828 } |
|
829 |
|
830 // -------------------------------------------------------------------------- |
|
831 // CPguGroupView::HandleConfigurationChangeL |
|
832 // -------------------------------------------------------------------------- |
|
833 // |
|
834 void CPguGroupView::HandleConfigurationChangeL() |
|
835 { |
|
836 // Force empty list text update after configuration change |
|
837 UpdateListEmptyTextL(); |
|
838 |
|
839 UpdateCbasL(); |
|
840 if ( iContainer && iContainer->Control() ) |
|
841 { |
|
842 iContainer->Control()->SetViewL |
|
843 ( *Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
844 ViewSupplier().AllGroupsViewL() ); |
|
845 iContainer->Control()->DrawNow(); |
|
846 } |
|
847 } |
|
848 |
|
849 |
|
850 // -------------------------------------------------------------------------- |
|
851 // CPguGroupView::UiControlL |
|
852 // -------------------------------------------------------------------------- |
|
853 // |
|
854 void CPguGroupView::CheckUiControlL() |
|
855 { |
|
856 |
|
857 // check if we have invalid control |
|
858 if (iControl==NULL) |
|
859 { |
|
860 // leave with bad handle error since iControl is missing |
|
861 User::Leave(KErrBadHandle); |
|
862 } |
|
863 } |
|
864 |
|
865 |
|
866 // End of File |