63
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Phonebook 2 command handler.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "CPbk2CommandHandler.h"
|
|
21 |
|
|
22 |
// Phonebook 2
|
|
23 |
#include "CPbk2CommandFactory.h"
|
|
24 |
#include "CPbk2CommandStore.h"
|
|
25 |
#include "CPbk2AiwInterestArray.h"
|
|
26 |
#include <MPbk2ViewExplorer.h>
|
|
27 |
#include <CPbk2AppViewBase.h>
|
|
28 |
#include <CPbk2AppUiBase.h>
|
|
29 |
#include <CPbk2UIExtensionManager.h>
|
|
30 |
#include <MPbk2Command.h>
|
|
31 |
#include <Pbk2Commands.rsg>
|
|
32 |
#include <Pbk2UIControls.rsg>
|
|
33 |
#include <CPbk2ViewState.h>
|
|
34 |
#include <CPbk2PhonebookInfoDlg.h>
|
|
35 |
#include <TPbk2StoreContactAnalyzer.h>
|
|
36 |
#include <MPbk2ContactNameFormatter.h>
|
|
37 |
#include <CPbk2StoreProperty.h>
|
|
38 |
#include <CPbk2StorePropertyArray.h>
|
|
39 |
#include <CPbk2ContactRelocator.h>
|
|
40 |
#include <MPbk2ContactLinkIterator.h>
|
|
41 |
#include <CPbk2PresentationContact.h>
|
|
42 |
#include <CPbk2PresentationContactFieldCollection.h>
|
|
43 |
#include <CPbk2FieldPropertyArray.h>
|
|
44 |
#include <cpbk2commandactivator.h>
|
|
45 |
#include <CPbk2ApplicationServices.h>
|
|
46 |
#include <MPbk2AppUi.h>
|
|
47 |
|
|
48 |
// Virtual Phonebook
|
|
49 |
#include <CVPbkContactManager.h>
|
|
50 |
#include <MVPbkStoreContactField.h>
|
|
51 |
#include <MVPbkStoreContact.h>
|
|
52 |
#include <MVPbkContactStore.h>
|
|
53 |
#include <MVPbkContactStoreProperties.h>
|
|
54 |
#include <MVPbkContactAttributeManager.h>
|
|
55 |
#include <MVPbkContactLinkArray.h>
|
|
56 |
#include <MVPbkContactLink.h>
|
|
57 |
#include <CVPbkSpeedDialAttribute.h>
|
|
58 |
#include <MVPbkStoreContact.h>
|
|
59 |
#include <VPbkContactStoreUris.h>
|
|
60 |
|
|
61 |
// System includes
|
|
62 |
#include <avkon.hrh>
|
|
63 |
#include <eikmenup.h>
|
|
64 |
#include <featmgr.h>
|
|
65 |
#include <hlplch.h>
|
|
66 |
#include <akntoolbar.h>
|
|
67 |
#include <eikmenub.h>
|
|
68 |
|
|
69 |
|
|
70 |
/// Unnamed namespace for local definitions
|
|
71 |
namespace {
|
|
72 |
|
|
73 |
#ifdef _DEBUG
|
|
74 |
enum TPanicCode
|
|
75 |
{
|
|
76 |
EPanicPreCond_CmdOpenMeViewsL = 1,
|
|
77 |
EPanicPreCond_CmdOpenSettingsViewL,
|
|
78 |
EPanicPreCond_CmdOpenPreviousViewL,
|
|
79 |
EPanicPreCond_CmdOpenHelpL,
|
|
80 |
EPanicLogic_FocusedFieldMatchesFieldTypeL,
|
|
81 |
EPanicLogic_FocusedContactHasFieldTypeL
|
|
82 |
};
|
|
83 |
|
|
84 |
void Panic(TPanicCode aReason)
|
|
85 |
{
|
|
86 |
_LIT(KPanicText, "CPbk2CommandHandler");
|
|
87 |
User::Panic(KPanicText, aReason);
|
|
88 |
}
|
|
89 |
#endif //_DEBUG
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Checks if focused field is of given field type.
|
|
93 |
*
|
|
94 |
* @param aUiControl UI control.
|
|
95 |
* @param aSelectorResId Selector resource id.
|
|
96 |
* @param aContactManager Virtual Phonebook contact manager.
|
|
97 |
* @return ETrue if field type matches with given types.
|
|
98 |
*/
|
|
99 |
TBool FocusedFieldMatchesFieldTypeL(
|
|
100 |
MPbk2ContactUiControl& aUiControl,
|
|
101 |
TInt aSelectorResId,
|
|
102 |
CVPbkContactManager& aContactManager )
|
|
103 |
{
|
|
104 |
const MVPbkStoreContact* contact = aUiControl.FocusedStoreContact();
|
|
105 |
__ASSERT_DEBUG(contact, Panic
|
|
106 |
( EPanicLogic_FocusedFieldMatchesFieldTypeL ) );
|
|
107 |
|
|
108 |
TPbk2StoreContactAnalyzer analyzer( aContactManager, NULL );
|
|
109 |
const MVPbkBaseContactField* field = aUiControl.FocusedField();
|
|
110 |
return field &&
|
|
111 |
analyzer.IsFieldTypeIncludedL( *field, aSelectorResId );
|
|
112 |
}
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Checks if the focused contact have a given field type.
|
|
116 |
*
|
|
117 |
* @param aUiControl UI control
|
|
118 |
* @param aSelectorResId Selector resource id.
|
|
119 |
* @param aContactManager Virtual Phonebook contact manager.
|
|
120 |
* @return Index of the field having the type, KErrNotFound if
|
|
121 |
* the contact does not have the field type.
|
|
122 |
*/
|
|
123 |
TInt FocusedContactHasFieldTypeL(
|
|
124 |
MPbk2ContactUiControl& aUiControl,
|
|
125 |
TInt aSelectorResId,
|
|
126 |
CVPbkContactManager& aContactManager )
|
|
127 |
{
|
|
128 |
TInt ret = KErrNotFound;
|
|
129 |
const MVPbkStoreContact* contact = aUiControl.FocusedStoreContact();
|
|
130 |
__ASSERT_DEBUG( contact,
|
|
131 |
Panic( EPanicLogic_FocusedContactHasFieldTypeL ) );
|
|
132 |
|
|
133 |
TPbk2StoreContactAnalyzer analyzer( aContactManager, contact );
|
|
134 |
ret = analyzer.HasFieldL( aSelectorResId );
|
|
135 |
return ret;
|
|
136 |
}
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Checks if command is 'exit' command.
|
|
140 |
*
|
|
141 |
* @param aCommandId The command to check.
|
|
142 |
* @return ETrue if command is an exit command, EFalse otherwise.
|
|
143 |
*/
|
|
144 |
TBool IsExitCommand( TInt aCommandId )
|
|
145 |
{
|
|
146 |
TBool ret = EFalse;
|
|
147 |
|
|
148 |
if ( EEikCmdExit == aCommandId || EAknSoftkeyExit == aCommandId ||
|
|
149 |
EAknCmdExit == aCommandId || EPbk2CmdExit == aCommandId )
|
|
150 |
{
|
|
151 |
ret = ETrue;
|
|
152 |
}
|
|
153 |
|
|
154 |
return ret;
|
|
155 |
}
|
|
156 |
|
|
157 |
} /// namespace
|
|
158 |
|
|
159 |
|
|
160 |
// --------------------------------------------------------------------------
|
|
161 |
// CPbk2CommandHandler::CPbk2CommandHandler
|
|
162 |
// --------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
inline CPbk2CommandHandler::CPbk2CommandHandler()
|
|
165 |
{
|
|
166 |
}
|
|
167 |
|
|
168 |
// --------------------------------------------------------------------------
|
|
169 |
// CPbk2CommandHandler::~CPbk2CommandHandler
|
|
170 |
// --------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
CPbk2CommandHandler::~CPbk2CommandHandler()
|
|
173 |
{
|
|
174 |
delete iAiwInterestArray;
|
|
175 |
delete iCommandStore;
|
|
176 |
delete iCommandFactory;
|
|
177 |
delete iContactRelocator;
|
|
178 |
Release(iExtensionManager);
|
|
179 |
Release(iAppServices);
|
|
180 |
FeatureManager::UnInitializeLib();
|
|
181 |
}
|
|
182 |
|
|
183 |
// --------------------------------------------------------------------------
|
|
184 |
// CPbk2CommandHandler::NewL
|
|
185 |
// --------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
EXPORT_C CPbk2CommandHandler* CPbk2CommandHandler::NewL()
|
|
188 |
{
|
|
189 |
CPbk2CommandHandler* self = new(ELeave) CPbk2CommandHandler();
|
|
190 |
CleanupStack::PushL(self);
|
|
191 |
self->ConstructL();
|
|
192 |
CleanupStack::Pop(self);
|
|
193 |
return self;
|
|
194 |
}
|
|
195 |
|
|
196 |
// --------------------------------------------------------------------------
|
|
197 |
// CPbk2CommandHandler::ConstructL
|
|
198 |
// --------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
inline void CPbk2CommandHandler::ConstructL()
|
|
201 |
{
|
|
202 |
iCommandFactory = CPbk2CommandFactory::NewL();
|
|
203 |
iCommandStore = CPbk2CommandStore::NewL();
|
|
204 |
iAiwInterestArray = CPbk2AiwInterestArray::NewL();
|
|
205 |
iExtensionManager = CPbk2UIExtensionManager::InstanceL();
|
|
206 |
iContactRelocator = CPbk2ContactRelocator::NewL();
|
|
207 |
iAppServices = CPbk2ApplicationServices::InstanceL();
|
|
208 |
|
|
209 |
// Initialize feature manager
|
|
210 |
FeatureManager::InitializeLibL();
|
|
211 |
}
|
|
212 |
|
|
213 |
// --------------------------------------------------------------------------
|
|
214 |
// CPbk2CommandHandler::HandleCommandL
|
|
215 |
// --------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
TBool CPbk2CommandHandler::HandleCommandL
|
|
218 |
( const TInt aCommandId, MPbk2ContactUiControl& aControl,
|
|
219 |
const CPbk2AppViewBase* aAppView )
|
|
220 |
{
|
|
221 |
TBool ret = ETrue;
|
|
222 |
|
|
223 |
// Exit commands are forwarded right away to appui
|
|
224 |
// Otherwise there is possibility that
|
|
225 |
// 'exit' command is not handled in low memory situations
|
|
226 |
if ( IsExitCommand( aCommandId ) )
|
|
227 |
{
|
|
228 |
ret = EFalse;
|
|
229 |
}
|
|
230 |
|
|
231 |
// Offer the command to AIW unless it is exit command
|
|
232 |
if ( ret && !iAiwInterestArray->HandleCommandL
|
|
233 |
( aCommandId, aControl, KNullHandle ) )
|
|
234 |
{
|
|
235 |
// Try generic command, this can also be a command from an extension
|
|
236 |
ret = CmdGenericCommandL( TPbk2CommandId( aCommandId ), aControl );
|
|
237 |
if ( !ret )
|
|
238 |
{
|
|
239 |
ret = ETrue;
|
|
240 |
switch ( aCommandId )
|
|
241 |
{
|
|
242 |
case EAknSoftkeyBack: // FALLTHROUGH
|
|
243 |
case EPbk2CmdOpenPreviousView:
|
|
244 |
{
|
|
245 |
CmdOpenPreviousViewL( aControl, aAppView );
|
|
246 |
break;
|
|
247 |
}
|
|
248 |
case EPbk2CmdSettings:
|
|
249 |
{
|
|
250 |
CmdOpenSettingsViewL( aControl, aAppView,
|
|
251 |
Phonebook2::KPbk2SettingsViewUid );
|
|
252 |
break;
|
|
253 |
}
|
|
254 |
case EAknCmdHelp:
|
|
255 |
{
|
|
256 |
CmdOpenHelpL( aControl, aAppView );
|
|
257 |
break;
|
|
258 |
}
|
|
259 |
default:
|
|
260 |
{
|
|
261 |
ret = EFalse;
|
|
262 |
break;
|
|
263 |
}
|
|
264 |
}
|
|
265 |
}
|
|
266 |
}
|
|
267 |
return ret;
|
|
268 |
}
|
|
269 |
|
|
270 |
// --------------------------------------------------------------------------
|
|
271 |
// CPbk2CommandHandler::DynInitMenuPaneL
|
|
272 |
// --------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
void CPbk2CommandHandler::DynInitMenuPaneL(
|
|
275 |
TInt aResourceId,
|
|
276 |
CEikMenuPane* aMenuPane,
|
|
277 |
CPbk2AppViewBase& aViewBase,
|
|
278 |
MPbk2ContactUiControl& aControl )
|
|
279 |
{
|
|
280 |
// First, delegate to AIW interests.
|
|
281 |
// If the menu initialization is handled there,
|
|
282 |
// there's no need to continue here
|
|
283 |
if ( !iAiwInterestArray->DynInitMenuPaneL
|
|
284 |
( aResourceId, *aMenuPane, aControl ) )
|
|
285 |
{
|
|
286 |
// Then call extensions
|
|
287 |
iExtensionManager->DynInitMenuPaneL( aResourceId, aMenuPane,
|
|
288 |
aViewBase, aControl );
|
|
289 |
|
|
290 |
// First perform standard menu filtering
|
|
291 |
PerformStandardMenuFilteringL( aResourceId, aMenuPane, aControl );
|
|
292 |
|
|
293 |
// Then perform field type based filtering
|
|
294 |
PerformFieldTypeBasedFilteringL( aResourceId, aMenuPane, aControl );
|
|
295 |
|
|
296 |
// Finally perform store specific filtering
|
|
297 |
PerformStoreSpecificFilteringL( aResourceId, aMenuPane, aControl );
|
|
298 |
}
|
|
299 |
}
|
|
300 |
|
|
301 |
// --------------------------------------------------------------------------
|
|
302 |
// CPbk2CommandHandler::RegisterAiwInterestL
|
|
303 |
// --------------------------------------------------------------------------
|
|
304 |
//
|
|
305 |
void CPbk2CommandHandler::RegisterAiwInterestL(
|
|
306 |
const TInt aInterestId,
|
|
307 |
const TInt aMenuResourceId,
|
|
308 |
const TInt aInterestResourceId,
|
|
309 |
const TBool aAttachBaseService)
|
|
310 |
{
|
|
311 |
iAiwInterestArray->QueueInterestL(aInterestId,
|
|
312 |
aMenuResourceId, aInterestResourceId, aAttachBaseService);
|
|
313 |
}
|
|
314 |
|
|
315 |
// --------------------------------------------------------------------------
|
|
316 |
// CPbk2CommandHandler::ServiceCmdByMenuCmd
|
|
317 |
// --------------------------------------------------------------------------
|
|
318 |
//
|
|
319 |
TInt CPbk2CommandHandler::ServiceCmdByMenuCmd(
|
|
320 |
TInt aMenuCmdId ) const
|
|
321 |
{
|
|
322 |
return iAiwInterestArray->ServiceCmdByMenuCmd( aMenuCmdId );
|
|
323 |
}
|
|
324 |
|
|
325 |
// --------------------------------------------------------------------------
|
|
326 |
// CPbk2CommandHandler::AddAndExecuteCommandL
|
|
327 |
// --------------------------------------------------------------------------
|
|
328 |
//
|
|
329 |
void CPbk2CommandHandler::AddAndExecuteCommandL(
|
|
330 |
MPbk2Command* aCommand)
|
|
331 |
{
|
|
332 |
iCommandStore->AddAndExecuteCommandL(aCommand);
|
|
333 |
}
|
|
334 |
|
|
335 |
// --------------------------------------------------------------------------
|
|
336 |
// CPbk2CommandHandler::AddMenuCommandObserver
|
|
337 |
// --------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
void CPbk2CommandHandler::AddMenuCommandObserver(
|
|
340 |
MPbk2MenuCommandObserver& aObserver)
|
|
341 |
{
|
|
342 |
iCommandStore->AddMenuCommandObserver(aObserver);
|
|
343 |
}
|
|
344 |
|
|
345 |
// --------------------------------------------------------------------------
|
|
346 |
// CPbk2CommandHandler::RemoveMenuCommandObserver
|
|
347 |
// --------------------------------------------------------------------------
|
|
348 |
//
|
|
349 |
void CPbk2CommandHandler::RemoveMenuCommandObserver(
|
|
350 |
MPbk2MenuCommandObserver& aObserver)
|
|
351 |
{
|
|
352 |
iCommandStore->RemoveMenuCommandObserver(aObserver);
|
|
353 |
}
|
|
354 |
|
|
355 |
// --------------------------------------------------------------------------
|
|
356 |
// CPbk2CommandHandler::DynInitToolbarL
|
|
357 |
// --------------------------------------------------------------------------
|
|
358 |
//
|
|
359 |
void CPbk2CommandHandler::DynInitToolbarL
|
|
360 |
( TInt aResourceId, CAknToolbar* aToolbar,
|
|
361 |
const CPbk2AppViewBase& /*aAppView*/,
|
|
362 |
MPbk2ContactUiControl& aControl )
|
|
363 |
{
|
|
364 |
switch ( aResourceId )
|
|
365 |
{
|
|
366 |
case R_PBK2_NAMESLIST_TOOLBAR:
|
|
367 |
{
|
|
368 |
if ( aControl.FocusedContactIndex() == KErrNotFound )
|
|
369 |
{
|
|
370 |
// If there is not focused contact (empty list or otherwise no
|
|
371 |
// focus) then disable calling and message writing
|
|
372 |
aToolbar->SetItemDimmed( EPbk2CmdCall, ETrue, ETrue );
|
|
373 |
aToolbar->SetItemDimmed( EPbk2CmdWriteNoQuery, ETrue, ETrue );
|
|
374 |
}
|
|
375 |
else if ( aControl.ContactsMarked() )
|
|
376 |
{
|
|
377 |
// Disable calling to many contacts
|
|
378 |
aToolbar->SetItemDimmed( EPbk2CmdCall, ETrue, ETrue );
|
|
379 |
}
|
|
380 |
break;
|
|
381 |
}
|
|
382 |
}
|
|
383 |
}
|
|
384 |
|
|
385 |
// --------------------------------------------------------------------------
|
|
386 |
// CPbk2CommandHandler::OfferToolbarEventL
|
|
387 |
// --------------------------------------------------------------------------
|
|
388 |
//
|
|
389 |
void CPbk2CommandHandler::OfferToolbarEventL
|
|
390 |
( TInt aCommand, MPbk2ContactUiControl& aControl,
|
|
391 |
const CPbk2AppViewBase* aAppView )
|
|
392 |
{
|
|
393 |
if ( aAppView )
|
|
394 |
{
|
|
395 |
HandleCommandL( aCommand, aControl, aAppView );
|
|
396 |
}
|
|
397 |
}
|
|
398 |
|
|
399 |
// --------------------------------------------------------------------------
|
|
400 |
// CPbk2CommandHandler::CmdOpenSettingsViewL
|
|
401 |
// --------------------------------------------------------------------------
|
|
402 |
//
|
|
403 |
void CPbk2CommandHandler::CmdOpenSettingsViewL
|
|
404 |
( MPbk2ContactUiControl& aControl,
|
|
405 |
const CPbk2AppViewBase* aAppView, TUid aViewId )
|
|
406 |
{
|
|
407 |
if (aAppView)
|
|
408 |
{
|
|
409 |
// Phonebook 2 view explorer for view switching
|
|
410 |
MPbk2ViewExplorer* viewExplorer = Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer();
|
|
411 |
|
|
412 |
__ASSERT_DEBUG( viewExplorer,
|
|
413 |
Panic( EPanicPreCond_CmdOpenSettingsViewL ) );
|
|
414 |
|
|
415 |
CPbk2ViewState* state = aAppView->ViewStateLC();
|
|
416 |
viewExplorer->ActivatePhonebook2ViewL
|
|
417 |
( aViewId, state );
|
|
418 |
CleanupStack::PopAndDestroy( state );
|
|
419 |
aControl.UpdateAfterCommandExecution();
|
|
420 |
}
|
|
421 |
}
|
|
422 |
|
|
423 |
// --------------------------------------------------------------------------
|
|
424 |
// CPbk2CommandHandler::CmdOpenPreviousViewL
|
|
425 |
// --------------------------------------------------------------------------
|
|
426 |
//
|
|
427 |
void CPbk2CommandHandler::CmdOpenPreviousViewL
|
|
428 |
( MPbk2ContactUiControl& /*aControl*/,
|
|
429 |
const CPbk2AppViewBase* aAppView )
|
|
430 |
{
|
|
431 |
if (aAppView)
|
|
432 |
{
|
|
433 |
// Phonebook 2 view explorer for view switching
|
|
434 |
MPbk2ViewExplorer* viewExplorer = Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer();
|
|
435 |
|
|
436 |
CPbk2ViewState* state = aAppView->ViewStateLC();
|
|
437 |
viewExplorer->ActivatePreviousViewL( state );
|
|
438 |
CleanupStack::PopAndDestroy( state );
|
|
439 |
}
|
|
440 |
}
|
|
441 |
|
|
442 |
// --------------------------------------------------------------------------
|
|
443 |
// CPbk2CommandHandler::CmdOpenHelpL
|
|
444 |
// --------------------------------------------------------------------------
|
|
445 |
//
|
|
446 |
void CPbk2CommandHandler::CmdOpenHelpL
|
|
447 |
( MPbk2ContactUiControl& aControl,
|
|
448 |
const CPbk2AppViewBase* aAppView )
|
|
449 |
{
|
|
450 |
if ( aAppView )
|
|
451 |
{
|
|
452 |
TCoeHelpContext helpContext;
|
|
453 |
if ( iExtensionManager->GetHelpContextL
|
|
454 |
( helpContext, *aAppView, aControl) )
|
|
455 |
{
|
|
456 |
CArrayFix<TCoeHelpContext>* helpContextArray =
|
|
457 |
new (ELeave) CArrayFixFlat<TCoeHelpContext>( 1 );
|
|
458 |
CleanupStack::PushL( helpContextArray );
|
|
459 |
helpContextArray->AppendL( helpContext );
|
|
460 |
|
|
461 |
// HlpLauncher destroys the help context array
|
|
462 |
CleanupStack::Pop( helpContextArray );
|
|
463 |
HlpLauncher::LaunchHelpApplicationL
|
|
464 |
( CCoeEnv::Static()->WsSession(), helpContextArray );
|
|
465 |
}
|
|
466 |
else
|
|
467 |
{
|
|
468 |
HlpLauncher::LaunchHelpApplicationL
|
|
469 |
( CCoeEnv::Static()->WsSession(),
|
|
470 |
CEikonEnv::Static()->EikAppUi()->AppHelpContextL() );
|
|
471 |
}
|
|
472 |
}
|
|
473 |
}
|
|
474 |
|
|
475 |
// --------------------------------------------------------------------------
|
|
476 |
// CPbk2CommandHandler::CmdGenericCommandL
|
|
477 |
// --------------------------------------------------------------------------
|
|
478 |
//
|
|
479 |
TBool CPbk2CommandHandler::CmdGenericCommandL(
|
|
480 |
TPbk2CommandId aCommandId,
|
|
481 |
MPbk2ContactUiControl& aControl)
|
|
482 |
{
|
|
483 |
// Create the command object
|
|
484 |
TBool result = EFalse;
|
|
485 |
MPbk2Command* cmd = iCommandFactory->CreateCommandForIdL(
|
|
486 |
aCommandId, aControl);
|
|
487 |
if (cmd)
|
|
488 |
{
|
|
489 |
// If command factory was able to create the command,
|
|
490 |
// add it to the command store and execute it
|
|
491 |
iCommandStore->AddAndExecuteCommandL(cmd);
|
|
492 |
result = ETrue;
|
|
493 |
}
|
|
494 |
return result;
|
|
495 |
}
|
|
496 |
|
|
497 |
// --------------------------------------------------------------------------
|
|
498 |
// CPbk2CommandHandler::PerformStandardMenuFilteringL
|
|
499 |
// --------------------------------------------------------------------------
|
|
500 |
//
|
|
501 |
inline void CPbk2CommandHandler::PerformStandardMenuFilteringL(
|
|
502 |
TInt aResourceId,
|
|
503 |
CEikMenuPane* aMenuPane,
|
|
504 |
MPbk2ContactUiControl& aControl )
|
|
505 |
{
|
|
506 |
switch (aResourceId)
|
|
507 |
{
|
|
508 |
case R_PHONEBOOK2_NAMESLIST_DELETE_MENU:
|
|
509 |
{
|
|
510 |
if ( aControl.NumberOfContacts() == 0 )
|
|
511 |
{
|
|
512 |
aMenuPane->SetItemDimmed( EPbk2CmdDeleteMe, ETrue );
|
|
513 |
}
|
|
514 |
break;
|
|
515 |
}
|
|
516 |
|
|
517 |
case R_PHONEBOOK2_NAMELIST_CALL_CONTACT_MENU:
|
|
518 |
{
|
|
519 |
// Weed out commands not meant to be used with marked items
|
|
520 |
if ( aControl.ContactsMarked() )
|
|
521 |
{
|
|
522 |
aMenuPane->SetItemDimmed( EPbk2CmdCall, ETrue );
|
|
523 |
}
|
|
524 |
break;
|
|
525 |
}
|
|
526 |
|
|
527 |
case R_PHONEBOOK2_NAMESLIST_CREATE_MENU:
|
|
528 |
{
|
|
529 |
// Weed out commands not meant to be used with marked items
|
|
530 |
if ( aControl.ContactsMarked() )
|
|
531 |
{
|
|
532 |
aMenuPane->SetItemDimmed( EPbk2CmdCreateNew, ETrue );
|
|
533 |
}
|
|
534 |
break;
|
|
535 |
}
|
|
536 |
|
|
537 |
case R_PHONEBOOK2_NAMESLIST_SEND_URL_MENU:
|
|
538 |
{
|
|
539 |
// Weed out commands not meant to be used with empty list
|
|
540 |
if ( aControl.NumberOfContacts() == 0 )
|
|
541 |
{
|
|
542 |
aMenuPane->SetItemDimmed( EPbk2CmdGoToURL, ETrue );
|
|
543 |
}
|
|
544 |
|
|
545 |
if ( aControl.ContactsMarked() )
|
|
546 |
{
|
|
547 |
aMenuPane->SetItemDimmed( EPbk2CmdGoToURL, ETrue );
|
|
548 |
}
|
|
549 |
break;
|
|
550 |
}
|
|
551 |
|
|
552 |
case R_PHONEBOOK2_NAMESLIST_COPY_MENU: // FALLTHROUGH
|
|
553 |
case R_PHONEBOOK2_NAMESLIST_COPY_CONTEXT_MENU:
|
|
554 |
{
|
|
555 |
// The copy menu is not shown if there are no contacts
|
|
556 |
TBool itemSpecCommEnabled = Phonebook2::Pbk2AppUi()->ActiveView()->MenuBar()->ItemSpecificCommandsEnabled();
|
|
557 |
if ( aControl.NumberOfContacts() == 0 ||
|
|
558 |
( !aControl.ContactsMarked() && !itemSpecCommEnabled ) ||
|
|
559 |
( !aControl.FocusedContactL() && itemSpecCommEnabled &&
|
|
560 |
!aControl.ContactsMarked() ) )
|
|
561 |
{
|
|
562 |
aMenuPane->SetItemDimmed( EPbk2CmdCopy, ETrue );
|
|
563 |
}
|
|
564 |
break;
|
|
565 |
}
|
|
566 |
|
|
567 |
case R_PHONEBOOK2_CONTACTINFO_EDIT_MENU:
|
|
568 |
{
|
|
569 |
// Weed out commands not meant to be used with empty contact
|
|
570 |
if ( aControl.NumberOfContactFields() == 0 )
|
|
571 |
{
|
|
572 |
aMenuPane->SetItemDimmed( EPbk2CmdWrite, ETrue );
|
|
573 |
aMenuPane->SetItemDimmed( EPbk2CmdGoToURL, ETrue );
|
|
574 |
aMenuPane->SetItemDimmed( EPbk2CmdDefaultSettings, ETrue );
|
|
575 |
}
|
|
576 |
break;
|
|
577 |
}
|
|
578 |
|
|
579 |
case R_PHONEBOOK2_CONTACTINFO_EXTENDED_MENU:
|
|
580 |
{
|
|
581 |
CVPbkContactManager& manager = iAppServices->ContactManager();
|
|
582 |
|
|
583 |
// Always dim thumbnail if image/text supported or vice versa
|
|
584 |
if ( FeatureManager::FeatureSupported
|
|
585 |
( KFeatureIdCallImagetext ) )
|
|
586 |
{
|
|
587 |
aMenuPane->SetItemDimmed( EPbk2CmdFetchThumbnail, ETrue );
|
|
588 |
aMenuPane->SetItemDimmed( EPbk2CmdRemoveThumbnail, ETrue );
|
|
589 |
}
|
|
590 |
else
|
|
591 |
{
|
|
592 |
aMenuPane->SetItemDimmed( EPbk2CmdAddImage, ETrue );
|
|
593 |
aMenuPane->SetItemDimmed( EPbk2CmdImage, ETrue );
|
|
594 |
}
|
|
595 |
|
|
596 |
// Weed out commands not meant to be used with empty contact
|
|
597 |
if ( aControl.NumberOfContactFields() == 0 )
|
|
598 |
{
|
|
599 |
aMenuPane->SetItemDimmed( EPbk2CmdSend, ETrue );
|
|
600 |
aMenuPane->SetItemDimmed( EPbk2CmdAssignSpeedDial, ETrue);
|
|
601 |
aMenuPane->SetItemDimmed( EPbk2CmdRemoveSpeedDial, ETrue );
|
|
602 |
aMenuPane->SetItemDimmed
|
|
603 |
( EPbk2CmdPersonalRingingTone, ETrue );
|
|
604 |
aMenuPane->SetItemDimmed( EPbk2CmdCopy, ETrue );
|
|
605 |
|
|
606 |
if ( !FeatureManager::FeatureSupported
|
|
607 |
( KFeatureIdCallImagetext ) )
|
|
608 |
{
|
|
609 |
aMenuPane->SetItemDimmed
|
|
610 |
( EPbk2CmdFetchThumbnail, ETrue );
|
|
611 |
aMenuPane->SetItemDimmed
|
|
612 |
( EPbk2CmdRemoveThumbnail, ETrue );
|
|
613 |
}
|
|
614 |
else
|
|
615 |
{
|
|
616 |
aMenuPane->SetItemDimmed( EPbk2CmdAddImage, ETrue );
|
|
617 |
aMenuPane->SetItemDimmed( EPbk2CmdImage, ETrue );
|
|
618 |
}
|
|
619 |
}
|
|
620 |
else
|
|
621 |
{
|
|
622 |
// Utilise attribute manager to find out if
|
|
623 |
// the contact have a speed dial defined
|
|
624 |
TBool hasSpeedDial = HasSpeedDialL( aControl );
|
|
625 |
|
|
626 |
// Filtering is based on the speed dial existence
|
|
627 |
if ( !hasSpeedDial )
|
|
628 |
{
|
|
629 |
aMenuPane->SetItemDimmed
|
|
630 |
( EPbk2CmdRemoveSpeedDial, ETrue );
|
|
631 |
}
|
|
632 |
else
|
|
633 |
{
|
|
634 |
aMenuPane->SetItemDimmed
|
|
635 |
( EPbk2CmdAssignSpeedDial, ETrue );
|
|
636 |
}
|
|
637 |
}
|
|
638 |
break;
|
|
639 |
}
|
|
640 |
|
|
641 |
case R_PHONEBOOK2_CONTACTINFO_CONTEXT_MENU:
|
|
642 |
{
|
|
643 |
// Weed out commands not meant to be used with empty contact
|
|
644 |
if ( aControl.NumberOfContactFields() == 0 )
|
|
645 |
{
|
|
646 |
aMenuPane->SetItemDimmed( EPbk2CmdWrite, ETrue );
|
|
647 |
aMenuPane->SetItemDimmed( EPbk2CmdGoToURL, ETrue );
|
|
648 |
aMenuPane->SetItemDimmed( EPbk2CmdPersonalRingingTone, ETrue );
|
|
649 |
aMenuPane->SetItemDimmed( EPbk2CmdUseNumber, ETrue );
|
|
650 |
aMenuPane->SetItemDimmed( EPbk2CmdImage, ETrue );
|
|
651 |
}
|
|
652 |
break;
|
|
653 |
}
|
|
654 |
|
|
655 |
case R_PHONEBOOK2_INFO_MENU:
|
|
656 |
{
|
|
657 |
// Filter memory info items when list box is empty
|
|
658 |
// or items are marked
|
|
659 |
if ( aControl.NumberOfContacts() == 0 ||
|
|
660 |
aControl.ContactsMarked() )
|
|
661 |
{
|
|
662 |
aMenuPane->SetItemDimmed( EPbk2CmdPhonebook2Info, ETrue );
|
|
663 |
}
|
|
664 |
break;
|
|
665 |
}
|
|
666 |
|
|
667 |
case R_PHONEBOOK2_SYSTEM_MENU:
|
|
668 |
{
|
|
669 |
if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
|
|
670 |
{
|
|
671 |
// Remove non-supported help from menu
|
|
672 |
aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
|
|
673 |
}
|
|
674 |
break;
|
|
675 |
}
|
|
676 |
case R_PHONEBOOK2_MERGE_CONTACTS:
|
|
677 |
{
|
|
678 |
TBool supported = FeatureManager::FeatureSupported( KFeatureIdFfContactsMerge );
|
|
679 |
|
|
680 |
if ( !supported || aControl.ContactsMarked() )
|
|
681 |
{
|
|
682 |
aMenuPane->SetItemDimmed( EPbk2CmdMergeContacts, ETrue );
|
|
683 |
}
|
|
684 |
break;
|
|
685 |
}
|
|
686 |
default:
|
|
687 |
{
|
|
688 |
// Do nothing
|
|
689 |
break;
|
|
690 |
}
|
|
691 |
}
|
|
692 |
}
|
|
693 |
|
|
694 |
// --------------------------------------------------------------------------
|
|
695 |
// CPbk2CommandHandler::PerformStoreSpecificFiltering
|
|
696 |
// --------------------------------------------------------------------------
|
|
697 |
//
|
|
698 |
inline void CPbk2CommandHandler::PerformStoreSpecificFilteringL(
|
|
699 |
TInt aResourceId,
|
|
700 |
CEikMenuPane* aMenuPane,
|
|
701 |
MPbk2ContactUiControl& aControl )
|
|
702 |
{
|
|
703 |
switch (aResourceId)
|
|
704 |
{
|
|
705 |
case R_PHONEBOOK2_NAMESLIST_CONTEXT_MENU_MARKED_ITEMS: // FALLTHROUGH
|
|
706 |
case R_PHONEBOOK2_NAMESLIST_DELETE_MENU:
|
|
707 |
{
|
|
708 |
// Weed out commands not meant to be used with read only stores
|
|
709 |
if (AreSelectedContactsFromReadOnlyStoreL( aControl ))
|
|
710 |
{
|
|
711 |
aMenuPane->SetItemDimmed(EPbk2CmdDeleteMe, ETrue);
|
|
712 |
}
|
|
713 |
break;
|
|
714 |
}
|
|
715 |
|
|
716 |
case R_PHONEBOOK2_CONTACTINFO_EDIT_MENU:
|
|
717 |
{
|
|
718 |
TBool phoneMemoryInConfiguration =
|
|
719 |
iContactRelocator->IsPhoneMemoryInConfigurationL();
|
|
720 |
|
|
721 |
// Weed out commands not meant to be used with read only stores
|
|
722 |
if (AreSelectedContactsFromReadOnlyStoreL( aControl ))
|
|
723 |
{
|
|
724 |
aMenuPane->SetItemDimmed(EPbk2CmdDeleteMe, ETrue);
|
|
725 |
aMenuPane->SetItemDimmed(EPbk2CmdEditMe, ETrue);
|
|
726 |
}
|
|
727 |
|
|
728 |
// Weed out phone memory specific commands, if there is no
|
|
729 |
// phone memory in configuration
|
|
730 |
if (!phoneMemoryInConfiguration)
|
|
731 |
{
|
|
732 |
aMenuPane->SetItemDimmed(EPbk2CmdDefaultSettings, ETrue);
|
|
733 |
}
|
|
734 |
break;
|
|
735 |
}
|
|
736 |
|
|
737 |
case R_PHONEBOOK2_CONTACTINFO_EXTENDED_MENU:
|
|
738 |
{
|
|
739 |
TBool phoneMemoryInConfiguration =
|
|
740 |
iContactRelocator->IsPhoneMemoryInConfigurationL();
|
|
741 |
|
|
742 |
// Weed out phone memory specific commands, if there is no
|
|
743 |
// phone memory in configuration
|
|
744 |
if (!phoneMemoryInConfiguration)
|
|
745 |
{
|
|
746 |
aMenuPane->SetItemDimmed(EPbk2CmdAssignSpeedDial, ETrue);
|
|
747 |
if (!FeatureManager::FeatureSupported(KFeatureIdCallImagetext))
|
|
748 |
{
|
|
749 |
aMenuPane->SetItemDimmed(EPbk2CmdFetchThumbnail, ETrue);
|
|
750 |
}
|
|
751 |
else
|
|
752 |
{
|
|
753 |
aMenuPane->SetItemDimmed(EPbk2CmdAddImage, ETrue);
|
|
754 |
aMenuPane->SetItemDimmed(EPbk2CmdImage, ETrue);
|
|
755 |
}
|
|
756 |
aMenuPane->SetItemDimmed(EPbk2CmdPersonalRingingTone, ETrue);
|
|
757 |
}
|
|
758 |
|
|
759 |
break;
|
|
760 |
}
|
|
761 |
|
|
762 |
case R_PHONEBOOK2_CONTACTINFO_CONTEXT_MENU:
|
|
763 |
{
|
|
764 |
// Weed out commands not meant to be used with read only stores
|
|
765 |
if (AreSelectedContactsFromReadOnlyStoreL( aControl ))
|
|
766 |
{
|
|
767 |
aMenuPane->SetItemDimmed(EPbk2CmdEditMe, ETrue);
|
|
768 |
}
|
|
769 |
break;
|
|
770 |
}
|
|
771 |
case R_PHONEBOOK2_MERGE_CONTACTS:
|
|
772 |
{
|
|
773 |
TBool phoneMemoryInConfiguration =
|
|
774 |
iContactRelocator->IsPhoneMemoryInConfigurationL();
|
|
775 |
|
|
776 |
if( !phoneMemoryInConfiguration )
|
|
777 |
{
|
|
778 |
aMenuPane->SetItemDimmed( EPbk2CmdMergeContacts, ETrue );
|
|
779 |
}
|
|
780 |
break;
|
|
781 |
}
|
|
782 |
default:
|
|
783 |
{
|
|
784 |
// Do nothing
|
|
785 |
break;
|
|
786 |
}
|
|
787 |
}
|
|
788 |
}
|
|
789 |
|
|
790 |
// --------------------------------------------------------------------------
|
|
791 |
// CPbk2CommandHandler::PerformFieldTypeBasedFilteringL
|
|
792 |
// --------------------------------------------------------------------------
|
|
793 |
//
|
|
794 |
inline void CPbk2CommandHandler::PerformFieldTypeBasedFilteringL(
|
|
795 |
TInt aResourceId,
|
|
796 |
CEikMenuPane* aMenuPane,
|
|
797 |
MPbk2ContactUiControl& aControl )
|
|
798 |
{
|
|
799 |
CVPbkContactManager& manager = iAppServices->ContactManager();
|
|
800 |
|
|
801 |
switch (aResourceId)
|
|
802 |
{
|
|
803 |
case R_PHONEBOOK2_CONTACTINFO_EDIT_MENU:
|
|
804 |
{
|
|
805 |
// Weed out commands which are not shown if currently focused field is
|
|
806 |
// not phone number
|
|
807 |
if (!FocusedFieldMatchesFieldTypeL(aControl,
|
|
808 |
R_PHONEBOOK2_PHONENUMBER_SELECTOR, manager))
|
|
809 |
{
|
|
810 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue);
|
|
811 |
}
|
|
812 |
|
|
813 |
// If the contact does not have URL field, there is no
|
|
814 |
// "Go To URL" option available
|
|
815 |
if (FocusedContactHasFieldTypeL(aControl,
|
|
816 |
R_PHONEBOOK2_URL_SELECTOR, manager) < 0)
|
|
817 |
{
|
|
818 |
aMenuPane->SetItemDimmed(EPbk2CmdGoToURL, ETrue);
|
|
819 |
}
|
|
820 |
break;
|
|
821 |
}
|
|
822 |
|
|
823 |
case R_PHONEBOOK2_CONTACTINFO_EXTENDED_MENU:
|
|
824 |
{
|
|
825 |
// Speed dial menus are variated based on VoIP support
|
|
826 |
if( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
|
|
827 |
{
|
|
828 |
// Weed out commands which are not shown if currently focused field is
|
|
829 |
// neither phone number nor VoIP field
|
|
830 |
if( !FocusedFieldMatchesFieldTypeL( aControl,
|
|
831 |
R_PHONEBOOK2_SIP_MSISDN_SELECTOR, manager ) )
|
|
832 |
{
|
|
833 |
aMenuPane->SetItemDimmed( EPbk2CmdAssignSpeedDial, ETrue );
|
|
834 |
aMenuPane->SetItemDimmed( EPbk2CmdRemoveSpeedDial, ETrue );
|
|
835 |
}
|
|
836 |
}
|
|
837 |
else
|
|
838 |
{
|
|
839 |
// Weed out commands which are not shown if currently focused field is
|
|
840 |
// not phone number
|
|
841 |
if( !FocusedFieldMatchesFieldTypeL( aControl,
|
|
842 |
R_PHONEBOOK2_PHONENUMBER_SELECTOR, manager ) )
|
|
843 |
{
|
|
844 |
aMenuPane->SetItemDimmed( EPbk2CmdAssignSpeedDial, ETrue );
|
|
845 |
aMenuPane->SetItemDimmed( EPbk2CmdRemoveSpeedDial, ETrue );
|
|
846 |
}
|
|
847 |
}
|
|
848 |
|
|
849 |
// Alternate Thumbnail/Call object menus based on whether data
|
|
850 |
// has been added or not
|
|
851 |
if (!FeatureManager::FeatureSupported(KFeatureIdCallImagetext))
|
|
852 |
{
|
|
853 |
// Weed out command Remove Thumbnail if contact does not have one
|
|
854 |
if (FocusedContactHasFieldTypeL(aControl,
|
|
855 |
R_PHONEBOOK2_THUMBNAIL_SELECTOR, manager) < 0)
|
|
856 |
{
|
|
857 |
aMenuPane->SetItemDimmed(EPbk2CmdRemoveThumbnail, ETrue);
|
|
858 |
}
|
|
859 |
}
|
|
860 |
else
|
|
861 |
{
|
|
862 |
if ((FocusedContactHasFieldTypeL(aControl,
|
|
863 |
R_PHONEBOOK2_IMAGE_SELECTOR, manager) < 0) &&
|
|
864 |
(FocusedContactHasFieldTypeL(aControl,
|
|
865 |
R_PHONEBOOK2_THUMBNAIL_SELECTOR, manager) < 0))
|
|
866 |
{
|
|
867 |
// Weed out Image submenu if contact does not have image
|
|
868 |
aMenuPane->SetItemDimmed(EPbk2CmdImage, ETrue);
|
|
869 |
}
|
|
870 |
else
|
|
871 |
{
|
|
872 |
// Weed out command Add Image if contact already has one
|
|
873 |
aMenuPane->SetItemDimmed(EPbk2CmdAddImage, ETrue);
|
|
874 |
}
|
|
875 |
}
|
|
876 |
break;
|
|
877 |
}
|
|
878 |
|
|
879 |
case R_PHONEBOOK2_CONTACTINFO_CONTEXT_MENU:
|
|
880 |
{
|
|
881 |
TBool filtered = EFalse;
|
|
882 |
|
|
883 |
// Telephone field
|
|
884 |
if (FocusedFieldMatchesFieldTypeL(aControl,
|
|
885 |
R_PHONEBOOK2_PHONENUMBER_SELECTOR, manager))
|
|
886 |
{
|
|
887 |
aMenuPane->SetItemDimmed(EPbk2CmdGoToURL, ETrue);
|
|
888 |
aMenuPane->SetItemDimmed(EPbk2CmdPersonalRingingTone, ETrue);
|
|
889 |
aMenuPane->SetItemDimmed(EPbk2CmdImage, ETrue);
|
|
890 |
filtered = ETrue;
|
|
891 |
|
|
892 |
// Further filtering of phone number fields
|
|
893 |
// Pager field
|
|
894 |
// Pager returns a match for R_PHONEBOOK2_PHONENUMBER_SELECTOR
|
|
895 |
// too, but it requires further filtering, which is handled here
|
|
896 |
if (FocusedFieldMatchesFieldTypeL(aControl,
|
|
897 |
R_PHONEBOOK2_PAGER_SELECTOR, manager))
|
|
898 |
{
|
|
899 |
aMenuPane->SetItemDimmed(EPbk2CmdWrite, ETrue);
|
|
900 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue );
|
|
901 |
}
|
|
902 |
|
|
903 |
// VoIP
|
|
904 |
// VoIP returns a match for R_PHONEBOOK2_PHONENUMBER_SELECTOR
|
|
905 |
// too, but it requires further filtering, which is handled here
|
|
906 |
if (FocusedFieldMatchesFieldTypeL(aControl,
|
|
907 |
R_PHONEBOOK2_VOIP_SELECTOR, manager))
|
|
908 |
{
|
|
909 |
aMenuPane->SetItemDimmed(EPbk2CmdWrite, ETrue);
|
|
910 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue );
|
|
911 |
}
|
|
912 |
} // further filtering
|
|
913 |
|
|
914 |
// Email field
|
|
915 |
if (FocusedFieldMatchesFieldTypeL(aControl,
|
|
916 |
R_PHONEBOOK2_EMAIL_SELECTOR, manager))
|
|
917 |
{
|
|
918 |
aMenuPane->SetItemDimmed(EPbk2CmdGoToURL, ETrue);
|
|
919 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue );
|
|
920 |
aMenuPane->SetItemDimmed(EPbk2CmdPersonalRingingTone, ETrue);
|
|
921 |
aMenuPane->SetItemDimmed(EPbk2CmdImage, ETrue);
|
|
922 |
filtered = ETrue;
|
|
923 |
}
|
|
924 |
|
|
925 |
// URL field
|
|
926 |
if (FocusedFieldMatchesFieldTypeL(aControl,
|
|
927 |
R_PHONEBOOK2_URL_SELECTOR, manager))
|
|
928 |
{
|
|
929 |
aMenuPane->SetItemDimmed(EPbk2CmdWrite, ETrue);
|
|
930 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue );
|
|
931 |
aMenuPane->SetItemDimmed(EPbk2CmdPersonalRingingTone, ETrue);
|
|
932 |
aMenuPane->SetItemDimmed(EPbk2CmdImage, ETrue);
|
|
933 |
filtered = ETrue;
|
|
934 |
}
|
|
935 |
|
|
936 |
// Ringing tone field
|
|
937 |
if (FocusedFieldMatchesFieldTypeL(aControl,
|
|
938 |
R_PHONEBOOK2_RINGTONE_SELECTOR, manager))
|
|
939 |
{
|
|
940 |
aMenuPane->SetItemDimmed(EPbk2CmdWrite, ETrue);
|
|
941 |
aMenuPane->SetItemDimmed(EPbk2CmdGoToURL, ETrue);
|
|
942 |
aMenuPane->SetItemDimmed(EPbk2CmdEditMe, ETrue);
|
|
943 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue );
|
|
944 |
aMenuPane->SetItemDimmed(EPbk2CmdImage, ETrue);
|
|
945 |
filtered = ETrue;
|
|
946 |
}
|
|
947 |
|
|
948 |
// Image/text context submenus
|
|
949 |
if( FocusedFieldMatchesFieldTypeL(aControl,
|
|
950 |
R_PHONEBOOK2_IMAGE_SELECTOR, manager))
|
|
951 |
{
|
|
952 |
aMenuPane->SetItemDimmed(EPbk2CmdWrite, ETrue);
|
|
953 |
aMenuPane->SetItemDimmed(EPbk2CmdGoToURL, ETrue);
|
|
954 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue );
|
|
955 |
aMenuPane->SetItemDimmed(EPbk2CmdPersonalRingingTone, ETrue);
|
|
956 |
filtered = ETrue;
|
|
957 |
}
|
|
958 |
|
|
959 |
if (!filtered)
|
|
960 |
{
|
|
961 |
// Default filtering leaves only edit option in the menu
|
|
962 |
aMenuPane->SetItemDimmed(EPbk2CmdWrite, ETrue);
|
|
963 |
aMenuPane->SetItemDimmed(EPbk2CmdGoToURL, ETrue);
|
|
964 |
aMenuPane->SetItemDimmed(EPbk2CmdUseNumber, ETrue );
|
|
965 |
aMenuPane->SetItemDimmed(EPbk2CmdPersonalRingingTone, ETrue);
|
|
966 |
aMenuPane->SetItemDimmed(EPbk2CmdImage, ETrue);
|
|
967 |
}
|
|
968 |
break;
|
|
969 |
}
|
|
970 |
|
|
971 |
case R_PHONEBOOK2_IMAGE_SUBMENU:
|
|
972 |
{
|
|
973 |
if (FeatureManager::FeatureSupported(KFeatureIdCallImagetext))
|
|
974 |
{
|
|
975 |
if (FocusedContactHasFieldTypeL(aControl,
|
|
976 |
R_PHONEBOOK2_IMAGE_SELECTOR, manager) < 0)
|
|
977 |
{
|
|
978 |
// Weed out Image View command if contact has no image
|
|
979 |
// (it might have thumbnail from e.g. business card and
|
|
980 |
// and thus other image submenu options)
|
|
981 |
aMenuPane->SetItemDimmed(EPbk2CmdViewImage, ETrue);
|
|
982 |
}
|
|
983 |
}
|
|
984 |
break;
|
|
985 |
}
|
|
986 |
|
|
987 |
default:
|
|
988 |
{
|
|
989 |
// AIW provider menus are filtered in the corresponding
|
|
990 |
// interest item, for example R_PHONEBOOK2_CALL_CONTEXT_MENU
|
|
991 |
// is filtered in CPbk2AiwInterestItemCall
|
|
992 |
break;
|
|
993 |
}
|
|
994 |
}
|
|
995 |
}
|
|
996 |
|
|
997 |
// --------------------------------------------------------------------------
|
|
998 |
// CPbk2CommandHandler::AreSelectedContactsFromReadOnlyStoreL
|
|
999 |
// Returns ETrue if all selected contacts are read-only.
|
|
1000 |
// --------------------------------------------------------------------------
|
|
1001 |
//
|
|
1002 |
inline TBool CPbk2CommandHandler::AreSelectedContactsFromReadOnlyStoreL(
|
|
1003 |
MPbk2ContactUiControl& aControl)
|
|
1004 |
{
|
|
1005 |
// Default behavior is that selection is read-only, e.g
|
|
1006 |
// a link can not be created for folding contact in which case
|
|
1007 |
// the folding contact cannot be destroyed
|
|
1008 |
TBool ret = ETrue;
|
|
1009 |
|
|
1010 |
MPbk2ContactLinkIterator* iterator =
|
|
1011 |
aControl.SelectedContactsIteratorL();
|
|
1012 |
if ( iterator )
|
|
1013 |
{
|
|
1014 |
CleanupDeletePushL( iterator );
|
|
1015 |
|
|
1016 |
while( iterator->HasNext() && ret )
|
|
1017 |
{
|
|
1018 |
MVPbkContactLink* link = iterator->NextL();
|
|
1019 |
|
|
1020 |
if ( link && !IsFromReadOnlyStore( *link ) )
|
|
1021 |
{
|
|
1022 |
ret = EFalse;
|
|
1023 |
}
|
|
1024 |
|
|
1025 |
delete link;
|
|
1026 |
link = NULL;
|
|
1027 |
}
|
|
1028 |
|
|
1029 |
CleanupStack::PopAndDestroy(); // iterator
|
|
1030 |
}
|
|
1031 |
else
|
|
1032 |
{
|
|
1033 |
// There was no iterator so there are no selected contacts,
|
|
1034 |
// this means we are operating with the focused contact
|
|
1035 |
const MVPbkBaseContact* focusedContact =
|
|
1036 |
aControl.FocusedContactL();
|
|
1037 |
if ( focusedContact )
|
|
1038 |
{
|
|
1039 |
MVPbkContactLink* link = focusedContact->CreateLinkLC();
|
|
1040 |
if ( link && !IsFromReadOnlyStore( *link ) )
|
|
1041 |
{
|
|
1042 |
ret = EFalse;
|
|
1043 |
}
|
|
1044 |
CleanupStack::PopAndDestroy(); // link
|
|
1045 |
}
|
|
1046 |
}
|
|
1047 |
|
|
1048 |
return ret;
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
// --------------------------------------------------------------------------
|
|
1052 |
// CPbk2CommandHandler::IsFromReadOnlyStore
|
|
1053 |
// --------------------------------------------------------------------------
|
|
1054 |
//
|
|
1055 |
TBool CPbk2CommandHandler::IsFromReadOnlyStore(
|
|
1056 |
const MVPbkContactLink& aContactLink ) const
|
|
1057 |
{
|
|
1058 |
TBool ret = EFalse;
|
|
1059 |
|
|
1060 |
const MVPbkContactStore& store = aContactLink.ContactStore();
|
|
1061 |
if ( store.StoreProperties().ReadOnly() )
|
|
1062 |
{
|
|
1063 |
ret = ETrue;
|
|
1064 |
}
|
|
1065 |
|
|
1066 |
return ret;
|
|
1067 |
}
|
|
1068 |
|
|
1069 |
// --------------------------------------------------------------------------
|
|
1070 |
// CPbk2CommandHandler::HasSpeedDialL
|
|
1071 |
// --------------------------------------------------------------------------
|
|
1072 |
//
|
|
1073 |
TBool CPbk2CommandHandler::HasSpeedDialL(
|
|
1074 |
MPbk2ContactUiControl& aControl )
|
|
1075 |
{
|
|
1076 |
TBool hasAttribute(EFalse);
|
|
1077 |
|
|
1078 |
const MVPbkStoreContact* storeContact =
|
|
1079 |
aControl.FocusedStoreContact();
|
|
1080 |
|
|
1081 |
// Convert presentation index to store index.
|
|
1082 |
TInt index( ToStoreFieldIndexL(
|
|
1083 |
aControl.FocusedFieldIndex(),
|
|
1084 |
storeContact ) );
|
|
1085 |
|
|
1086 |
if ( index != KErrNotFound )
|
|
1087 |
{
|
|
1088 |
const MVPbkStoreContactField& field =
|
|
1089 |
storeContact->Fields().FieldAt( index );
|
|
1090 |
|
|
1091 |
|
|
1092 |
hasAttribute =
|
|
1093 |
iAppServices->ContactManager().ContactAttributeManagerL().
|
|
1094 |
HasFieldAttributeL(
|
|
1095 |
CVPbkSpeedDialAttribute::Uid(),
|
|
1096 |
field );
|
|
1097 |
}
|
|
1098 |
return hasAttribute;
|
|
1099 |
}
|
|
1100 |
|
|
1101 |
// --------------------------------------------------------------------------
|
|
1102 |
// CPbk2CommandHandler::ToStoreFieldIndexL
|
|
1103 |
// --------------------------------------------------------------------------
|
|
1104 |
//
|
|
1105 |
TInt CPbk2CommandHandler::ToStoreFieldIndexL(
|
|
1106 |
TInt aPresIndex,
|
|
1107 |
const MVPbkStoreContact* aStoreContact )
|
|
1108 |
{
|
|
1109 |
// It is ok to remove const, we don't make any changes
|
|
1110 |
MVPbkStoreContact* storeContact =
|
|
1111 |
const_cast<MVPbkStoreContact*>( aStoreContact );
|
|
1112 |
|
|
1113 |
TInt index( KErrNotFound );
|
|
1114 |
if ( aPresIndex >= 0 )
|
|
1115 |
{
|
|
1116 |
CPbk2PresentationContact* presentationContact =
|
|
1117 |
CPbk2PresentationContact::NewL(
|
|
1118 |
*storeContact,
|
|
1119 |
iAppServices->FieldProperties() );
|
|
1120 |
CleanupStack::PushL( presentationContact );
|
|
1121 |
|
|
1122 |
index = presentationContact->PresentationFields().
|
|
1123 |
StoreIndexOfField( aPresIndex );
|
|
1124 |
|
|
1125 |
CleanupStack::PopAndDestroy( presentationContact );
|
|
1126 |
}
|
|
1127 |
return index;
|
|
1128 |
}
|
|
1129 |
|
|
1130 |
// End of File
|