|
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 contact editor dialog implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2ContactEditorDlgImpl.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "Pbk2UIControls.hrh" |
|
24 #include "MPbk2ContactEditorStrategy.h" |
|
25 #include "CPbk2ContactEditorFieldArray.h" |
|
26 #include "MPbk2ContactEditorField.h" |
|
27 #include <MPbk2ContactEditorField2.h> |
|
28 #include "CPbk2AddItemManager.h" |
|
29 #include "Pbk2TitlePanePictureFactory.h" |
|
30 #include "TPbk2DeleteItemManager.h" |
|
31 #include <MPbk2StoreObservationRegister.h> |
|
32 #include <MPbk2ApplicationServices.h> |
|
33 #include <CPbk2PresentationContact.h> |
|
34 #include <CPbk2PresentationContactField.h> |
|
35 #include <CPbk2PresentationContactFieldCollection.h> |
|
36 #include <MPbk2FieldProperty.h> |
|
37 #include <MPbk2FieldProperty2.h> |
|
38 #include <CPbk2FieldPropertyArray.h> |
|
39 #include <Pbk2UIControls.rsg> |
|
40 #include <MPbk2ContactNameFormatter.h> |
|
41 #include <MPbk2ContactEditorExtension.h> |
|
42 #include <CPbk2StoreConfiguration.h> |
|
43 #include <CPbk2ContactRelocator.h> |
|
44 #include <MPbk2ContactEditorEventObserver.h> |
|
45 #include <MPbk2EditedContactObserver.h> |
|
46 #include <CPbk2UIExtensionManager.h> |
|
47 #include <MPbk2UIExtensionFactory.h> |
|
48 #include <MPbk2ContactEditorContactRelocator.h> |
|
49 #include <CPbk2AppUiBase.h> |
|
50 #include <CPbk2StorePropertyArray.h> |
|
51 #include <CPbk2StoreProperty.h> |
|
52 #include <MPbk2ExitCallback.h> |
|
53 #include <CPbk2IconInfoContainer.h> |
|
54 #include <CPbk2IconFactory.h> |
|
55 #include "Pbk2RingtoneCommands.h" |
|
56 #include "Pbk2ImageCommands.h" |
|
57 #include "CPbk2ContactEditorUIAddressField.h" |
|
58 #include "MPbk2ContactEditorUIField.h" |
|
59 #include "Pbk2ContactEditorFieldFactory.h" |
|
60 #include "Pbk2AddressTools.h" |
|
61 #include "MPbk2UIField.h" |
|
62 #include "CPbk2ContactEditorRingtoneField.h" |
|
63 #include "CPbk2ContactEditorImageField.h" |
|
64 #include "CPbk2ContactEditorReadonlyField.h" |
|
65 #include "Pbk2EditorLineIds.hrh" |
|
66 #include <Pbk2Config.hrh> |
|
67 #include <Pbk2Commands.hrh> |
|
68 #include "Pbk2FieldProperty.hrh" |
|
69 #include "Pbk2IconId.hrh" |
|
70 #include <Pbk2UID.h> |
|
71 #include <pbk2mapcommands.hrh> |
|
72 #include <MPbk2StartupMonitor.h> |
|
73 |
|
74 // Virtual Phonebook |
|
75 #include <CVPbkContactManager.h> |
|
76 #include <MVPbkStoreContact.h> |
|
77 #include <MVPbkContactStore.h> |
|
78 #include <MVPbkContactFieldTextData.h> |
|
79 #include <MVPbkContactStoreProperties.h> |
|
80 #include <MVPbkContactFieldData.h> |
|
81 #include <MVPbkFieldType.h> |
|
82 #include <TVPbkFieldVersitProperty.h> |
|
83 |
|
84 #include <VPbkEng.rsg> |
|
85 #include <VPbkFieldType.hrh> |
|
86 #include <VPbkContactStoreUris.h> |
|
87 |
|
88 // System includes |
|
89 #include <akntitle.h> |
|
90 #include <aknnavi.h> |
|
91 #include <StringLoader.h> |
|
92 #include <eikcapc.h> |
|
93 #include <barsread.h> |
|
94 #include <aknnotewrappers.h> |
|
95 #include <hlplch.h> |
|
96 #include <aknnavide.h> |
|
97 #include <akninputblock.h> |
|
98 #include <charconv.h> |
|
99 |
|
100 /// Unnamed namespace for local definitions |
|
101 namespace { |
|
102 |
|
103 const TInt KEditorNameFormatFlags = MPbk2ContactNameFormatter::EUseSeparator; |
|
104 const TInt KTwoBytes = 2; |
|
105 const TInt KExtraByte = 1; |
|
106 |
|
107 #ifdef _DEBUG |
|
108 enum TPanicCode |
|
109 { |
|
110 EHandleControlStateChangeL_NullField = 1, |
|
111 EPanic_IsControlEmptyL_OOB, |
|
112 EPanic_EditorField_OOB |
|
113 }; |
|
114 |
|
115 void Panic(TInt aReason) |
|
116 { |
|
117 _LIT(KPanicText, "CPbk2ContactEditorDlgImpl"); |
|
118 User::Panic(KPanicText, aReason); |
|
119 } |
|
120 #endif // _DEBUG |
|
121 |
|
122 /** |
|
123 * Displays a store not available note. |
|
124 * |
|
125 * @param aName Store name. |
|
126 */ |
|
127 void ShowStoreNotAvailableNoteL( const TDesC& aName ) |
|
128 { |
|
129 if ( aName.Length() > 0 ) |
|
130 { |
|
131 HBufC* text = StringLoader::LoadLC( R_QTN_PHOB_STORE_NOT_AVAILABLE, |
|
132 aName ); |
|
133 CAknInformationNote* note = new ( ELeave ) CAknInformationNote; |
|
134 note->ExecuteLD( *text ); |
|
135 CleanupStack::PopAndDestroy( text ); |
|
136 } |
|
137 } |
|
138 |
|
139 /** |
|
140 * Decides whether to leave or not in case of an error. |
|
141 * Performs some filtering of errors. |
|
142 * |
|
143 * @param aError Error code. |
|
144 */ |
|
145 void DecideToLeaveL( TInt aError ) |
|
146 { |
|
147 if ( aError != KErrInUse && aError != KErrNone ) |
|
148 { |
|
149 User::Leave( aError ); |
|
150 } |
|
151 } |
|
152 |
|
153 } /// namespace |
|
154 |
|
155 |
|
156 // -------------------------------------------------------------------------- |
|
157 // CPbk2ContactEditorDlgImpl::CPbk2ContactEditorDlgImpl |
|
158 // -------------------------------------------------------------------------- |
|
159 // |
|
160 CPbk2ContactEditorDlgImpl::CPbk2ContactEditorDlgImpl |
|
161 ( TPbk2ContactEditorParams& aParams, |
|
162 CPbk2PresentationContact& aContact, |
|
163 CPbk2FieldPropertyArray& aFieldProperties, |
|
164 MPbk2EditedContactObserver& aContactObserver, |
|
165 MPbk2ContactEditorStrategy& aEditorStrategy, |
|
166 MPbk2ContactEditorContactRelocator& aRelocator, |
|
167 MPbk2ApplicationServices* aAppServices, |
|
168 HBufC* aTitleText ) : |
|
169 iParams( aParams ), |
|
170 iEditorStrategy( aEditorStrategy ), |
|
171 iFieldProperties( aFieldProperties ), |
|
172 iContact( aContact ), |
|
173 iContactObserver( aContactObserver ), |
|
174 iRelocator( aRelocator ), |
|
175 iEndKeyWasPressed( EFalse ), |
|
176 iAddressViewStandalone( EFalse ), |
|
177 iAppServices( aAppServices ), |
|
178 iTitleText( aTitleText ) |
|
179 { |
|
180 // Exit is approved by default |
|
181 iExitRecord.Set( EExitApproved ); |
|
182 } |
|
183 |
|
184 // -------------------------------------------------------------------------- |
|
185 // CPbk2ContactEditorDlgImpl::~CPbk2ContactEditorDlgImpl |
|
186 // -------------------------------------------------------------------------- |
|
187 // |
|
188 CPbk2ContactEditorDlgImpl::~CPbk2ContactEditorDlgImpl() |
|
189 { |
|
190 iCoeEnv->RemoveForegroundObserver( *this ); |
|
191 |
|
192 if ( iWaitFinish && iWaitFinish->IsStarted() ) |
|
193 { |
|
194 iWaitFinish->AsyncStop(); |
|
195 } |
|
196 delete iWaitFinish; |
|
197 delete iInputBlock; |
|
198 |
|
199 if ( iSelfPtr ) |
|
200 { |
|
201 *iSelfPtr = NULL; |
|
202 } |
|
203 // Make the variable in CloseDialog() to ETrue. |
|
204 if ( iDestroyedPtr ) |
|
205 { |
|
206 *iDestroyedPtr = ETrue; |
|
207 } |
|
208 |
|
209 if( iAppServices ) |
|
210 { |
|
211 iAppServices->StoreObservationRegister().DeregisterStoreEvents( *this ); |
|
212 } |
|
213 else |
|
214 { |
|
215 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
216 StoreObservationRegister().DeregisterStoreEvents( *this ); |
|
217 } |
|
218 |
|
219 if ( iEikonEnv && iContextMenuBar ) |
|
220 { |
|
221 iEikonEnv->EikAppUi()->RemoveFromStack( iContextMenuBar ); |
|
222 delete iContextMenuBar; |
|
223 } |
|
224 |
|
225 TRAP_IGNORE ( RestoreStatusPaneL() ); |
|
226 |
|
227 // Remove empty status pane |
|
228 if (iNaviContainer) |
|
229 { |
|
230 iNaviContainer->Pop(); |
|
231 TRAP_IGNORE(RestorePrevNaviDecoratorL()); |
|
232 } |
|
233 |
|
234 delete iStoreContact; |
|
235 delete iFieldFactory; |
|
236 delete iPbk2BaseCommand; |
|
237 delete iEditorExtension; |
|
238 delete iUiFieldArray; |
|
239 Release(iExtensionManager); |
|
240 delete iTitleText; |
|
241 iTitleText = NULL; |
|
242 delete iStoredTitlePaneText; |
|
243 iStoredTitlePaneText = NULL; |
|
244 |
|
245 delete iConverter; |
|
246 delete iDelayDelete; |
|
247 } |
|
248 |
|
249 // -------------------------------------------------------------------------- |
|
250 // CPbk2ContactEditorDlgImpl::NewL |
|
251 // -------------------------------------------------------------------------- |
|
252 // |
|
253 CPbk2ContactEditorDlgImpl* CPbk2ContactEditorDlgImpl::NewL( |
|
254 TPbk2ContactEditorParams& aParams, |
|
255 CPbk2PresentationContact& aContact, |
|
256 CPbk2FieldPropertyArray& aFieldProperties, |
|
257 MPbk2EditedContactObserver& aContactObserver, |
|
258 MPbk2ContactEditorStrategy& aEditorStrategy, |
|
259 MPbk2ContactEditorContactRelocator& aRelocator) |
|
260 { |
|
261 CPbk2ContactEditorDlgImpl* self = |
|
262 new ( ELeave ) CPbk2ContactEditorDlgImpl(aParams, aContact, |
|
263 aFieldProperties, aContactObserver, |
|
264 aEditorStrategy, aRelocator); |
|
265 CleanupStack::PushL(self); |
|
266 self->ConstructL(); |
|
267 CleanupStack::Pop(self); |
|
268 return self; |
|
269 } |
|
270 |
|
271 // -------------------------------------------------------------------------- |
|
272 // CPbk2ContactEditorDlgImpl::NewL |
|
273 // -------------------------------------------------------------------------- |
|
274 // |
|
275 CPbk2ContactEditorDlgImpl* CPbk2ContactEditorDlgImpl::NewL( |
|
276 TPbk2ContactEditorParams& aParams, |
|
277 CPbk2PresentationContact& aContact, |
|
278 CPbk2FieldPropertyArray& aFieldProperties, |
|
279 MPbk2EditedContactObserver& aContactObserver, |
|
280 MPbk2ContactEditorStrategy& aEditorStrategy, |
|
281 MPbk2ContactEditorContactRelocator& aRelocator, |
|
282 MPbk2ApplicationServices* aAppServices, |
|
283 HBufC* aTitleText ) |
|
284 { |
|
285 CPbk2ContactEditorDlgImpl* self = |
|
286 new ( ELeave ) CPbk2ContactEditorDlgImpl(aParams, aContact, |
|
287 aFieldProperties, aContactObserver, |
|
288 aEditorStrategy, aRelocator, aAppServices, aTitleText ); |
|
289 CleanupStack::PushL(self); |
|
290 self->ConstructL(); |
|
291 CleanupStack::Pop(self); |
|
292 return self; |
|
293 } |
|
294 |
|
295 // -------------------------------------------------------------------------- |
|
296 // CPbk2ContactEditorDlgImpl::ConstructL |
|
297 // -------------------------------------------------------------------------- |
|
298 // |
|
299 void CPbk2ContactEditorDlgImpl::ConstructL() |
|
300 { |
|
301 CAknDialog::ConstructL(R_PBK2_CONTACTEDITOR_MENUBAR); |
|
302 iCoeEnv->AddForegroundObserverL( *this ); |
|
303 |
|
304 if(iParams.iActiveView != TPbk2ContactEditorParams::EEditorView) |
|
305 { |
|
306 iParams.iFocusedContactField = NULL; |
|
307 } |
|
308 if(iParams.iFocusedContactField) |
|
309 { |
|
310 const MVPbkFieldType* type = iParams.iFocusedContactField->BestMatchingFieldType(); |
|
311 const TArray<TVPbkFieldVersitProperty> propArr = type->VersitProperties(); |
|
312 if(propArr.Count()) |
|
313 { |
|
314 const TVPbkFieldVersitProperty prop = propArr[0]; |
|
315 if(prop.Name() == EVPbkVersitNameADR) |
|
316 { |
|
317 if(prop.Parameters().Contains(EVPbkVersitParamHOME)) |
|
318 { |
|
319 iParams.iActiveView = TPbk2ContactEditorParams::EEditorAddressHomeView; |
|
320 } |
|
321 else if(prop.Parameters().Contains(EVPbkVersitParamWORK)) |
|
322 { |
|
323 iParams.iActiveView = TPbk2ContactEditorParams::EEditorAddressOfficeView; |
|
324 } |
|
325 else |
|
326 { |
|
327 iParams.iActiveView = TPbk2ContactEditorParams::EEditorAddressView; |
|
328 } |
|
329 iAddressViewStandalone = ETrue; |
|
330 iParams.iFocusedContactField = NULL; |
|
331 } |
|
332 } |
|
333 } |
|
334 |
|
335 // Register to listen store events, so that we can close editor if |
|
336 // iContact's store becomes unavailable. |
|
337 |
|
338 /* |
|
339 * Use iAppServices if provided. This is to enable editor use outside from pbk2 context |
|
340 */ |
|
341 if( iAppServices ) |
|
342 { |
|
343 iAppServices->StoreObservationRegister().RegisterStoreEventsL( *this ); |
|
344 iNameFormatter = &iAppServices->NameFormatter(); |
|
345 } |
|
346 else |
|
347 { |
|
348 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
349 StoreObservationRegister().RegisterStoreEventsL( *this ); |
|
350 iNameFormatter = |
|
351 &Phonebook2::Pbk2AppUi()->ApplicationServices().NameFormatter(); |
|
352 } |
|
353 |
|
354 |
|
355 StoreTitlePaneTextL(); |
|
356 ConstructContextMenuL(); |
|
357 |
|
358 iExtensionManager = CPbk2UIExtensionManager::InstanceL(); |
|
359 |
|
360 /* |
|
361 * Use iAppServices if provided. This is to enable editor use outside from pbk2 context |
|
362 */ |
|
363 CVPbkContactManager* manager = NULL; |
|
364 if( iAppServices ) |
|
365 { |
|
366 manager = &iAppServices->ContactManager(); |
|
367 } |
|
368 else |
|
369 { |
|
370 manager = &Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager(); |
|
371 } |
|
372 |
|
373 iEditorExtension = iExtensionManager->FactoryL()-> |
|
374 CreatePbk2ContactEditorExtensionL( *manager, iContact, *this ); |
|
375 |
|
376 iFieldFactory = CPbk2ContactEditorFieldFactory::NewL(*this, *iEditorExtension); |
|
377 iUiFieldArray = CPbk2ContactEditorFieldArray::NewL( |
|
378 *manager, iContact, *this, *iFieldFactory, iAppServices ); |
|
379 |
|
380 iUseState = EUseReady; |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------------- |
|
384 // CPbk2ContactEditorDlgImpl::ExecuteLD |
|
385 // -------------------------------------------------------------------------- |
|
386 // |
|
387 void CPbk2ContactEditorDlgImpl::ExecuteLD() |
|
388 { |
|
389 CAknForm::ExecuteLD(R_PBK2_EDIT_MEMORY_ENTRY_DIALOG); |
|
390 } |
|
391 |
|
392 // -------------------------------------------------------------------------- |
|
393 // CPbk2ContactEditorDlgImpl::CreateCustomControlL |
|
394 // -------------------------------------------------------------------------- |
|
395 // |
|
396 SEikControlInfo CPbk2ContactEditorDlgImpl::CreateCustomControlL( |
|
397 TInt /*aControlType*/ ) |
|
398 { |
|
399 iLastCreatedCustomControl = NULL; |
|
400 SEikControlInfo control = {NULL, 0, 0}; |
|
401 iLastCreatedCustomControl = new (ELeave) CPbk2ContactEditorReadonlyField(); |
|
402 control.iControl = iLastCreatedCustomControl; |
|
403 control.iTrailerTextId = 0; |
|
404 control.iFlags = 0; |
|
405 return control; |
|
406 } |
|
407 |
|
408 // -------------------------------------------------------------------------- |
|
409 // CPbk2ContactEditorDlgImpl::ContactEditorUiBuilderExtension |
|
410 // -------------------------------------------------------------------------- |
|
411 // |
|
412 TAny* CPbk2ContactEditorDlgImpl::ContactEditorUiBuilderExtension( |
|
413 TUid /*aExtensionUid*/ ) |
|
414 { |
|
415 //return extension point of MPbk2ContactEditorUiBuilderExtension |
|
416 return static_cast<MPbk2ContactEditorUiBuilderExtension*>(this); |
|
417 } |
|
418 |
|
419 // -------------------------------------------------------------------------- |
|
420 // CPbk2ContactEditorDlgImpl::AddCustomFieldToFormL |
|
421 // -------------------------------------------------------------------------- |
|
422 // |
|
423 CCoeControl* CPbk2ContactEditorDlgImpl::AddCustomFieldToFormL( |
|
424 TInt aIndex,TInt aResourceId) |
|
425 { |
|
426 InsertLineL(aIndex, aResourceId); |
|
427 // Return value is updated in CreateCustomControlL() |
|
428 return iLastCreatedCustomControl; |
|
429 } |
|
430 |
|
431 // -------------------------------------------------------------------------- |
|
432 // CPbk2ContactEditorDlgImpl::HandleCustomFieldCommandL |
|
433 // -------------------------------------------------------------------------- |
|
434 // |
|
435 TBool CPbk2ContactEditorDlgImpl::HandleCustomFieldCommandL(TInt aCommand ) |
|
436 { |
|
437 ProcessCommandL( aCommand ); |
|
438 return ETrue; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CPbk2ContactEditorDlgImpl::ConvertCustomControlTypeToBaseControlType() |
|
443 // Provide correct base type for custom contols |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 MEikDialogPageObserver::TFormControlTypes CPbk2ContactEditorDlgImpl:: |
|
447 ConvertCustomControlTypeToBaseControlType(TInt aControlType) const |
|
448 { |
|
449 MEikDialogPageObserver::TFormControlTypes ret = |
|
450 MEikDialogPageObserver::EUnknownType; |
|
451 |
|
452 switch(aControlType) |
|
453 { |
|
454 case EPbk2FieldCtrlTypeImageEditor: |
|
455 case EPbk2FieldCtrlTypeRingtoneEditor: |
|
456 case EPbk2FieldCtrlTypeExtAddressEditor: |
|
457 case EPbk2FieldCtrlTypeExtAddressHomeEditor: |
|
458 case EPbk2FieldCtrlTypeExtAddressOfficeEditor: |
|
459 case EPbk2FieldCtrlTypeExtAssignFromMapsEditor: |
|
460 { |
|
461 ret = MEikDialogPageObserver::EEdwinDerived; |
|
462 } |
|
463 break; |
|
464 default: |
|
465 { |
|
466 ret = MEikDialogPageObserver::EUnknownType; |
|
467 } |
|
468 break; |
|
469 } |
|
470 return ret; |
|
471 } |
|
472 |
|
473 // -------------------------------------------------------------------------- |
|
474 // CPbk2ContactEditorDlgImpl::HandlePointerEventL |
|
475 // -------------------------------------------------------------------------- |
|
476 // |
|
477 void CPbk2ContactEditorDlgImpl::HandlePointerEventL( |
|
478 const TPointerEvent& aPointerEvent ) |
|
479 { |
|
480 //Here we can prevent recursive execution of ExecuteBaseCommandL if needed |
|
481 //as touch events are handled in it too. So it may case multiple callbacks to here if |
|
482 //user repeats the same pointer event very quickly using options menu. |
|
483 // This check is needed, otherwise, when touch quickly on Address field and |
|
484 // quickly on Image field in the Editor Dialog, the address editor will be |
|
485 // opened, but touch input can not open in any of its editors. |
|
486 if(!iCommandPending) |
|
487 { |
|
488 CAknForm::HandlePointerEventL( aPointerEvent ); |
|
489 } |
|
490 } |
|
491 |
|
492 // -------------------------------------------------------------------------- |
|
493 // CPbk2ContactEditorDlgImpl::HandleResourceChange |
|
494 // -------------------------------------------------------------------------- |
|
495 // |
|
496 void CPbk2ContactEditorDlgImpl::HandleResourceChange( TInt aType ) |
|
497 { |
|
498 // Handle change in layout orientation |
|
499 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
500 { |
|
501 // Set status pane layout to the Phonebook 2 one |
|
502 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
503 if ( statusPane ) |
|
504 { |
|
505 iCurrentstatuspane = statusPane->CurrentLayoutResId(); |
|
506 if( iCurrentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
507 { |
|
508 TRAP_IGNORE( statusPane->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL) ); |
|
509 } |
|
510 } |
|
511 } |
|
512 |
|
513 CAknForm::HandleResourceChange( aType ); |
|
514 } |
|
515 |
|
516 // -------------------------------------------------------------------------- |
|
517 // CPbk2ContactEditorDlgImpl::AddItemToContactL |
|
518 // -------------------------------------------------------------------------- |
|
519 // |
|
520 void CPbk2ContactEditorDlgImpl::AddItemToContactL |
|
521 ( TInt aFieldTypeResourceId, |
|
522 const TDesC& aFieldTypeXspName, |
|
523 TBool aSetFocus ) |
|
524 { |
|
525 // Store the original parameter value, since it is |
|
526 // changed by AddFieldsL |
|
527 TInt origParam = aFieldTypeResourceId; |
|
528 TPtrC xSpName = aFieldTypeXspName; |
|
529 |
|
530 CPbk2AddItemManager* addItemManager = CPbk2AddItemManager::NewL |
|
531 (iContact, *iUiFieldArray, iParams, iAppServices ); |
|
532 CleanupStack::PushL(addItemManager); |
|
533 CPbk2AddItemManager::TReturnValue ret = addItemManager->AddFieldsL( |
|
534 aFieldTypeResourceId, xSpName); |
|
535 |
|
536 if (ret.iControlId == KErrAlreadyExists) |
|
537 { |
|
538 // cannot add more than one of this field type |
|
539 // find and focus that |
|
540 TInt fieldArrayCount( iUiFieldArray->Count() ); |
|
541 for (TInt i(0); i < fieldArrayCount && ret.iControlId |
|
542 == KErrAlreadyExists; ++i) |
|
543 { |
|
544 if (!iUiFieldArray->At(i).ContactEditorField()) |
|
545 { |
|
546 continue; |
|
547 } |
|
548 const MVPbkFieldType* fieldType = |
|
549 iUiFieldArray->At(i).ContactEditorField()->ContactField(). |
|
550 BestMatchingFieldType(); |
|
551 if(fieldType && fieldType->FieldTypeResId() == aFieldTypeResourceId) |
|
552 { |
|
553 ret.iControlId = iUiFieldArray->At(i).ControlId(); |
|
554 } |
|
555 } |
|
556 } |
|
557 |
|
558 if (ret.iControlId > 0) |
|
559 { |
|
560 if (aSetFocus) |
|
561 { |
|
562 TryChangeFocusL(ret.iControlId); |
|
563 MPbk2ContactEditorField* editorField = iUiFieldArray->Find( ret.iControlId )->ContactEditorField(); |
|
564 MVPbkStoreContactField& storeContactField = editorField->ContactField(); |
|
565 iParams.iFocusedContactField = &storeContactField; |
|
566 // Call this after adding or deleting lines |
|
567 UpdatePageL( ETrue ); |
|
568 // Must be DrawNow and not DrawDeferred otherwise field label |
|
569 // and content of the following field will be incorrect |
|
570 DrawNow(); |
|
571 } |
|
572 } |
|
573 else if (ret.iControlId == KErrNotSupported && origParam == KErrNotFound) |
|
574 { |
|
575 iUiFieldArray->SaveFieldsL(); |
|
576 iRelocator.RelocateContactL(aFieldTypeResourceId, xSpName, |
|
577 Pbk2ContactRelocator::EPbk2DisplayStoreDoesNotSupportQuery); |
|
578 } |
|
579 else if ( iParams.iActiveView == TPbk2ContactEditorParams::EEditorView ) |
|
580 { |
|
581 switch( ret.iGruopId ) |
|
582 { |
|
583 case EPbk2FieldGroupIdPostalAddress: |
|
584 if(iUiFieldArray->Count()) |
|
585 { |
|
586 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
|
587 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressView ); |
|
588 } |
|
589 break; |
|
590 case EPbk2FieldGroupIdHomeAddress: |
|
591 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
|
592 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressHomeView ); |
|
593 break; |
|
594 case EPbk2FieldGroupIdCompanyAddress: |
|
595 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
|
596 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressOfficeView ); |
|
597 break; |
|
598 } |
|
599 } |
|
600 CleanupStack::PopAndDestroy(addItemManager); |
|
601 } |
|
602 |
|
603 // -------------------------------------------------------------------------- |
|
604 // CPbk2ContactEditorDlgImpl::CloseWithoutSaving |
|
605 // -------------------------------------------------------------------------- |
|
606 // |
|
607 void CPbk2ContactEditorDlgImpl::CloseWithoutSaving( TBool aInformObserver ) |
|
608 { |
|
609 CloseDialog( |
|
610 MVPbkContactObserver::EContactOperationUnknown, |
|
611 aInformObserver ); |
|
612 } |
|
613 |
|
614 // -------------------------------------------------------------------------- |
|
615 // CPbk2ContactEditorDlgImpl::TryChangeFocusWithTypeIdL |
|
616 // -------------------------------------------------------------------------- |
|
617 // |
|
618 void CPbk2ContactEditorDlgImpl::TryChangeFocusWithTypeIdL |
|
619 ( TInt aFieldTypeResId, const TDesC& aFieldTypeXSpName ) |
|
620 { |
|
621 const TInt count( iUiFieldArray->Count() ); |
|
622 for ( TInt i = 0; i < count; ++i ) |
|
623 { |
|
624 if (!iUiFieldArray->At(i).ContactEditorField()) |
|
625 { |
|
626 continue; |
|
627 } |
|
628 MPbk2ContactEditorField& uiEditorField = |
|
629 *(iUiFieldArray->At(i).ContactEditorField()); |
|
630 const MVPbkFieldType* fieldType = |
|
631 uiEditorField.ContactField().BestMatchingFieldType(); |
|
632 TInt candidate( KErrNotFound ); |
|
633 if ( fieldType ) |
|
634 { |
|
635 candidate = fieldType->FieldTypeResId(); |
|
636 } |
|
637 |
|
638 MPbk2FieldProperty2* fieldPropertyExtension = |
|
639 reinterpret_cast<MPbk2FieldProperty2*>( |
|
640 const_cast<MPbk2FieldProperty&>( uiEditorField.FieldProperty() ). |
|
641 FieldPropertyExtension( |
|
642 KMPbk2FieldPropertyExtension2Uid ) ); |
|
643 |
|
644 if ( fieldPropertyExtension != NULL ) |
|
645 { |
|
646 if ( (aFieldTypeResId == candidate ) && |
|
647 !fieldPropertyExtension->XSpName().CompareF( |
|
648 aFieldTypeXSpName) ) |
|
649 { |
|
650 TryChangeFocusL( uiEditorField.ControlId() ); |
|
651 MVPbkStoreContactField& storeContactField = uiEditorField.ContactField(); |
|
652 iParams.iFocusedContactField = &storeContactField; |
|
653 // Must be DrawNow and not DrawDeferred otherwise field label |
|
654 // and content of the following field will be incorrect |
|
655 DrawNow(); |
|
656 break; |
|
657 } |
|
658 } |
|
659 } |
|
660 } |
|
661 |
|
662 // -------------------------------------------------------------------------- |
|
663 // CPbk2ContactEditorDlgImpl::OfferKeyEventL |
|
664 // -------------------------------------------------------------------------- |
|
665 // |
|
666 TKeyResponse CPbk2ContactEditorDlgImpl::OfferKeyEventL |
|
667 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
668 { |
|
669 TKeyResponse ret(EKeyWasNotConsumed); |
|
670 |
|
671 if(iAddressView) |
|
672 { |
|
673 return ret; |
|
674 } |
|
675 |
|
676 /* Uncomment this code if it is necessary to enable navigation hardware keys |
|
677 * on devices which have these keys (its Map Extension feature) |
|
678 if( aKeyEvent.iScanCode == EStdKeyApplicationD && aType == EEventKeyUp ) |
|
679 { |
|
680 HandleCustomFieldCommandL(EPbk2ExtensionAssignFromMap); |
|
681 return EKeyWasConsumed; |
|
682 } |
|
683 |
|
684 if( aKeyEvent.iScanCode == EStdKeyApplicationE && aType == EEventKeyUp ) |
|
685 { |
|
686 HandleCustomFieldCommandL(EPbk2ExtensionShowOnMap); |
|
687 return EKeyWasConsumed; |
|
688 }*/ |
|
689 |
|
690 // Display menu bar if the focused control doesnt consume selection keys |
|
691 CPbk2ContactEditorArrayItem* currentField = iUiFieldArray->Find( |
|
692 IdOfFocusControl()); |
|
693 |
|
694 if (currentField) |
|
695 { |
|
696 CheckCurrentFieldTextL( currentField, aKeyEvent, aType ); |
|
697 |
|
698 if (currentField->ContactEditorField() |
|
699 && currentField->ContactEditorField()->ConsumesKeyEvent( |
|
700 aKeyEvent, aType)) |
|
701 { |
|
702 ret = CAknForm::OfferKeyEventL(aKeyEvent, aType); |
|
703 } |
|
704 else if (currentField->ContactEditorUIField() |
|
705 && currentField->ContactEditorUIField()->ConsumesKeyEvent( |
|
706 aKeyEvent, aType)) |
|
707 { |
|
708 ret = CAknForm::OfferKeyEventL(aKeyEvent, aType); |
|
709 } |
|
710 } |
|
711 |
|
712 if (ret != EKeyWasConsumed && aType == EEventKey && aKeyEvent.iCode |
|
713 == EKeyOK) |
|
714 { |
|
715 iContextMenuBar->TryDisplayMenuBarL(); |
|
716 ret = EKeyWasConsumed; |
|
717 } |
|
718 |
|
719 if ( ret != EKeyWasConsumed && !iEndKeyWasPressed ) |
|
720 { |
|
721 if ( aKeyEvent.iCode == EKeyEscape ) |
|
722 { |
|
723 iEditorStrategy.StopQuery(); |
|
724 iEndKeyWasPressed = ETrue; |
|
725 } |
|
726 ret = CAknForm::OfferKeyEventL( aKeyEvent, aType ); |
|
727 if ( ret == EKeyWasConsumed && |
|
728 aKeyEvent.iCode != EKeyPhoneEnd && aKeyEvent.iCode != EKeyEscape ) |
|
729 { |
|
730 UpdateCbasL(); |
|
731 } |
|
732 } |
|
733 |
|
734 return ret; |
|
735 } |
|
736 |
|
737 // -------------------------------------------------------------------------- |
|
738 // CPbk2ContactEditorDlgImpl::GetHelpContext |
|
739 // -------------------------------------------------------------------------- |
|
740 // |
|
741 void CPbk2ContactEditorDlgImpl::GetHelpContext |
|
742 ( TCoeHelpContext& aContext ) const |
|
743 { |
|
744 if (iParams.iHelpContext) |
|
745 { |
|
746 // If external help context has been set, return it.. |
|
747 aContext = *iParams.iHelpContext; |
|
748 } |
|
749 else |
|
750 { |
|
751 // ..otherwise go with the default context |
|
752 iEditorStrategy.GetHelpContext(aContext); |
|
753 } |
|
754 } |
|
755 |
|
756 // -------------------------------------------------------------------------- |
|
757 // CPbk2ContactEditorDlgImpl::PreLayoutDynInitL |
|
758 // -------------------------------------------------------------------------- |
|
759 // |
|
760 void CPbk2ContactEditorDlgImpl::PreLayoutDynInitL() |
|
761 { |
|
762 SetEditableL(ETrue); |
|
763 |
|
764 if (!ContactHasAddress(EPbk2FieldGroupIdPostalAddress) |
|
765 && !ContactHasAddress(EPbk2FieldGroupIdHomeAddress) |
|
766 && !ContactHasAddress(EPbk2FieldGroupIdCompanyAddress)) |
|
767 { |
|
768 AddGroupFieldsL(EPbk2FieldGroupIdPostalAddress); |
|
769 } |
|
770 |
|
771 if(iAddressViewStandalone) |
|
772 { |
|
773 AddGroupFieldsL(Pbk2AddressTools::MapViewTypeToAddress(iParams.iActiveView)); |
|
774 } |
|
775 |
|
776 iUiFieldArray->CreateFieldsFromContactL(iParams); |
|
777 SetAddressValidationIconsL(); |
|
778 |
|
779 // Offer button group container to extensions. |
|
780 // This is needed here because previous settings might override extension's |
|
781 // buttons. |
|
782 iEditorExtension->ModifyButtonGroupContainerL(ButtonGroupContainer()); |
|
783 |
|
784 ConstructNaviPaneL(); |
|
785 UpdateTitleL(); |
|
786 UpdateTitlePictureL(); |
|
787 } |
|
788 |
|
789 // -------------------------------------------------------------------------- |
|
790 // CPbk2ContactEditorDlgImpl::PostLayoutDynInitL |
|
791 // -------------------------------------------------------------------------- |
|
792 // |
|
793 void CPbk2ContactEditorDlgImpl::PostLayoutDynInitL() |
|
794 { |
|
795 |
|
796 if(iParams.iFocusedContactField) |
|
797 { |
|
798 const TInt count = iUiFieldArray->Count(); |
|
799 for (TInt i = 0; i < count; ++i) |
|
800 { |
|
801 if(iUiFieldArray->At(i).ContactEditorField()) |
|
802 { |
|
803 MVPbkBaseContactField & field = |
|
804 iUiFieldArray->At(i).ContactEditorField()->ContactField(); |
|
805 if (field.IsSame(*iParams.iFocusedContactField)) |
|
806 { |
|
807 UpdateCbasL(&(iUiFieldArray->At(i))); |
|
808 break; |
|
809 } |
|
810 } |
|
811 } |
|
812 } |
|
813 else if(iUiFieldArray->Count()) |
|
814 { |
|
815 UpdateCbasL(&(iUiFieldArray->At(0))); |
|
816 } |
|
817 |
|
818 // Notify relocator, that editor is ready |
|
819 iRelocator.EditorReadyL(); |
|
820 } |
|
821 |
|
822 // -------------------------------------------------------------------------- |
|
823 // CPbk2ContactEditorDlgImpl::SetInitialCurrentLine |
|
824 // -------------------------------------------------------------------------- |
|
825 // |
|
826 void CPbk2ContactEditorDlgImpl::SetInitialCurrentLine() |
|
827 { |
|
828 TInt focusedIndex = 0; |
|
829 if ( iParams.iFocusedContactField ) |
|
830 { |
|
831 const TInt count = iUiFieldArray->Count(); |
|
832 for (TInt i = 0; i < count; ++i) |
|
833 { |
|
834 if (iUiFieldArray->At(i).ContactEditorField()) |
|
835 { |
|
836 MVPbkBaseContactField & field = |
|
837 iUiFieldArray->At(i).ContactEditorField()->ContactField(); |
|
838 if (field.IsSame(*iParams.iFocusedContactField)) |
|
839 { |
|
840 focusedIndex = i; |
|
841 break; |
|
842 } |
|
843 } |
|
844 } |
|
845 CAknForm::SetInitialCurrentLine(); |
|
846 iUiFieldArray->SetFocus(focusedIndex); |
|
847 } |
|
848 else |
|
849 { |
|
850 CAknForm::SetInitialCurrentLine(); |
|
851 iUiFieldArray->SetFocus(focusedIndex); |
|
852 } |
|
853 } |
|
854 |
|
855 // -------------------------------------------------------------------------- |
|
856 // CPbk2ContactEditorDlgImpl::ProcessCommandL |
|
857 // -------------------------------------------------------------------------- |
|
858 // |
|
859 void CPbk2ContactEditorDlgImpl::ProcessCommandL(TInt aCommandId) |
|
860 { |
|
861 HideMenu(); |
|
862 |
|
863 iContextMenuBar->StopDisplayingMenuBar(); |
|
864 |
|
865 // Extensions get the command first |
|
866 // If decide to exit already, do not handle new commands until this exit cmd clear |
|
867 if (!iEditorExtension->ProcessCommandL(aCommandId) && |
|
868 !CheckBaseCommandL(aCommandId) && |
|
869 !CheckFieldSpecificCommandL(aCommandId) && |
|
870 iExitRecord.IsClear( EExitOrdered ) ) |
|
871 { |
|
872 switch (aCommandId) |
|
873 { |
|
874 case EPbk2CmdAddItem: |
|
875 { |
|
876 CmdAddItemL(); |
|
877 break; |
|
878 } |
|
879 |
|
880 case EPbk2CmdDeleteItem: |
|
881 { |
|
882 CmdDeleteItemL(); |
|
883 break; |
|
884 } |
|
885 |
|
886 case EPbk2CmdEditItemLabel: |
|
887 { |
|
888 CmdEditItemLabelL(); |
|
889 break; |
|
890 } |
|
891 #ifdef ECE_DISABLE_CONTEXT_MENU |
|
892 case EPbk2CmdEditorContextMenu: |
|
893 { |
|
894 iContextMenuBar->TryDisplayMenuBarL(); |
|
895 break; |
|
896 } |
|
897 #endif |
|
898 case EEikCmdExit: |
|
899 case EAknCmdExit: |
|
900 { |
|
901 // Exit Phonebook and if existing save |
|
902 // contact (happens later on in OkToExit..) |
|
903 |
|
904 // Escape or end key pressed. |
|
905 // We must save changes and exit the application |
|
906 |
|
907 if( iParams.iActiveView == TPbk2ContactEditorParams::EEditorView || iAddressViewStandalone ) |
|
908 { |
|
909 if (!iExitRecord.IsSet(EOkToExitWithoutHandlingIt)) |
|
910 { |
|
911 if( OkToExitApplicationL( EAknCmdExit ) ) |
|
912 { |
|
913 iExitRecord.Set(EExitOrdered); |
|
914 // Remove empty status pane |
|
915 if (iNaviContainer) |
|
916 { |
|
917 iNaviContainer->Pop(); |
|
918 RestorePrevNaviDecoratorL(); |
|
919 iNaviContainer = NULL; |
|
920 } |
|
921 |
|
922 MPbk2ContactEditorEventObserver::TParams params; |
|
923 params.iFlags = EPbk2EditorCommandId; |
|
924 params.iKeyCode = EKeyEscape; |
|
925 params.iCommandId = EAknCmdExit; |
|
926 |
|
927 CmdDoneL(params); |
|
928 if ( iUseState == EUseOperatingContact ) |
|
929 { |
|
930 WaitFinishL(); |
|
931 } |
|
932 } |
|
933 } |
|
934 break; |
|
935 } |
|
936 else |
|
937 { |
|
938 if (!iExitRecord.IsSet(EOkToExitWithoutHandlingIt)) |
|
939 { |
|
940 iExitRecord.Set(EOkToExitWithoutHandlingIt); |
|
941 OkToExitApplicationL(EAknCmdExit); |
|
942 { |
|
943 // Remove empty status pane |
|
944 if (iNaviContainer) |
|
945 { |
|
946 iNaviContainer->Pop(); |
|
947 RestorePrevNaviDecoratorL(); |
|
948 iNaviContainer = NULL; |
|
949 } |
|
950 |
|
951 MPbk2ContactEditorEventObserver::TParams params; |
|
952 params.iFlags = EPbk2EditorKeyCode; |
|
953 params.iKeyCode = EKeyEscape; |
|
954 params.iCommandId = EAknCmdExit; |
|
955 |
|
956 CmdDoneL(params); |
|
957 if ( iUseState == EUseOperatingContact ) |
|
958 { |
|
959 WaitFinishL(); |
|
960 } |
|
961 } |
|
962 } |
|
963 } |
|
964 |
|
965 break; |
|
966 } |
|
967 case EAknCmdHelp: |
|
968 { |
|
969 HlpLauncher::LaunchHelpApplicationL( |
|
970 CCoeEnv::Static()->WsSession(), |
|
971 iEikonEnv->EikAppUi()->AppHelpContextL()); |
|
972 break; |
|
973 } |
|
974 default: |
|
975 { |
|
976 // Command not handled here, forward it to the app ui. |
|
977 iEikonEnv->EikAppUi()->HandleCommandL(aCommandId); |
|
978 break; |
|
979 } |
|
980 } |
|
981 } |
|
982 } |
|
983 |
|
984 // -------------------------------------------------------------------------- |
|
985 // CPbk2ContactEditorDlgImpl::CheckBaseCommandL |
|
986 // Check whether there is a base command to execute |
|
987 // -------------------------------------------------------------------------- |
|
988 // |
|
989 TBool CPbk2ContactEditorDlgImpl::CheckBaseCommandL(TInt aCommandId) |
|
990 { |
|
991 TBool ret(ETrue); |
|
992 if (!iCommandPending) |
|
993 { |
|
994 //Prevent recursive execution of ExecuteBaseCommandL as touch events are |
|
995 //handled in it too. So it causes multiple callback to here if |
|
996 //user repeats the same pointer event very quickly. |
|
997 iCommandPending = ETrue; |
|
998 |
|
999 if (iPbk2BaseCommand) |
|
1000 { |
|
1001 //Cancel and delete previous possible pending command. |
|
1002 delete iPbk2BaseCommand; |
|
1003 iPbk2BaseCommand = NULL; |
|
1004 } |
|
1005 TRAPD(err, ret = ExecuteBaseCommandL(aCommandId)); |
|
1006 iCommandPending = EFalse; |
|
1007 User::LeaveIfError(err); |
|
1008 } |
|
1009 |
|
1010 return ret; |
|
1011 } |
|
1012 |
|
1013 // -------------------------------------------------------------------------- |
|
1014 // CPbk2ContactEditorDlgImpl::ExecuteBaseCommandL |
|
1015 // -------------------------------------------------------------------------- |
|
1016 // |
|
1017 TBool CPbk2ContactEditorDlgImpl::ExecuteBaseCommandL(TInt aCommandId) |
|
1018 { |
|
1019 TBool executingCommand(ETrue); |
|
1020 |
|
1021 switch (aCommandId) |
|
1022 { |
|
1023 case EPbk2CmdEditorChangeRingtone: |
|
1024 { |
|
1025 iPbk2BaseCommand = Pbk2RingtoneCommands::SetRingtoneL( |
|
1026 &iContact.StoreContact()); |
|
1027 break; |
|
1028 } |
|
1029 |
|
1030 case EPbk2CmdEditorRemoveRingtone: |
|
1031 { |
|
1032 iPbk2BaseCommand = Pbk2RingtoneCommands::RemoveRingtoneL( |
|
1033 &iContact.StoreContact()); |
|
1034 break; |
|
1035 } |
|
1036 |
|
1037 case EPbk2CmdEditorSelectAddress: |
|
1038 { |
|
1039 ExecuteAddressDlgL(TPbk2ContactEditorParams::EEditorAddressView); |
|
1040 return executingCommand; |
|
1041 } |
|
1042 |
|
1043 case EPbk2CmdEditorSelectAddressHome: |
|
1044 { |
|
1045 ExecuteAddressDlgL(TPbk2ContactEditorParams::EEditorAddressHomeView); |
|
1046 return executingCommand; |
|
1047 } |
|
1048 |
|
1049 case EPbk2CmdEditorSelectAddressOffice: |
|
1050 { |
|
1051 ExecuteAddressDlgL( |
|
1052 TPbk2ContactEditorParams::EEditorAddressOfficeView); |
|
1053 return executingCommand; |
|
1054 } |
|
1055 |
|
1056 case EPbk2CmdEditorOpen: |
|
1057 { |
|
1058 CPbk2ContactEditorArrayItem* currentField = iUiFieldArray->Find( |
|
1059 IdOfFocusControl()); |
|
1060 |
|
1061 if (currentField->ContactEditorUIField()) |
|
1062 { |
|
1063 TPbk2ContactEditorParams::TActiveView |
|
1064 viewType = |
|
1065 Pbk2AddressTools::MapCtrlTypeToViewType( |
|
1066 currentField->ContactEditorUIField()->UIField()->CtrlType()); |
|
1067 if (viewType != TPbk2ContactEditorParams::EEditorUndefinied) |
|
1068 { |
|
1069 ExecuteAddressDlgL(viewType); |
|
1070 return executingCommand; |
|
1071 } |
|
1072 } |
|
1073 break; |
|
1074 } |
|
1075 case EPbk2CmdEditorSelectAssignFromMaps: |
|
1076 { |
|
1077 HandleCustomFieldCommandL(EPbk2ExtensionAssignFromMap); |
|
1078 break; |
|
1079 } |
|
1080 |
|
1081 case EPbk2CmdEditorAddImage: |
|
1082 case EPbk2CmdEditorChangeImage: |
|
1083 { |
|
1084 iPbk2BaseCommand = Pbk2ImageCommands::SetImageL( |
|
1085 &iContact,this); |
|
1086 break; |
|
1087 } |
|
1088 |
|
1089 case EPbk2CmdEditorViewImage: |
|
1090 { |
|
1091 iPbk2BaseCommand = Pbk2ImageCommands::ViewImageL( |
|
1092 &iContact.StoreContact()); |
|
1093 break; |
|
1094 } |
|
1095 |
|
1096 case EPbk2CmdEditorRemoveImage: |
|
1097 { |
|
1098 iPbk2BaseCommand = Pbk2ImageCommands::RemoveImageL(&iContact); |
|
1099 break; |
|
1100 } |
|
1101 |
|
1102 default: |
|
1103 { |
|
1104 executingCommand = EFalse; |
|
1105 break; |
|
1106 } |
|
1107 } |
|
1108 |
|
1109 if (executingCommand) |
|
1110 { |
|
1111 CPbk2ContactEditorArrayItem* currentField = iUiFieldArray->Find( |
|
1112 IdOfFocusControl()); |
|
1113 |
|
1114 if (currentField && currentField->ContactEditorField()) |
|
1115 { |
|
1116 TInt id = currentField->ControlId(); |
|
1117 TAny |
|
1118 * ext = |
|
1119 currentField->ContactEditorField()->ContactEditorFieldExtension( |
|
1120 TUid::Uid(NULL)); |
|
1121 if (id == EPbk2EditorLineRingtone) |
|
1122 { |
|
1123 CPbk2ContactEditorRingtoneField* fld = |
|
1124 static_cast<CPbk2ContactEditorRingtoneField*> (ext); |
|
1125 fld->SetTextL(); |
|
1126 } |
|
1127 else if( id == EPbk2EditorLineImage && |
|
1128 aCommandId == EPbk2CmdEditorRemoveImage) |
|
1129 { |
|
1130 //If image removed, no callback to ImageLoadingComplete() so do it here |
|
1131 DoImageLoadingCompleteL(); |
|
1132 } |
|
1133 } |
|
1134 } |
|
1135 |
|
1136 return executingCommand; |
|
1137 } |
|
1138 |
|
1139 // -------------------------------------------------------------------------- |
|
1140 // CPbk2ContactEditorDlgImpl::SwitchView |
|
1141 // -------------------------------------------------------------------------- |
|
1142 // |
|
1143 void CPbk2ContactEditorDlgImpl::ExecuteAddressDlgL( |
|
1144 TPbk2ContactEditorParams::TActiveView aActiveView) |
|
1145 { |
|
1146 if (iParams.iActiveView == TPbk2ContactEditorParams::EEditorView) |
|
1147 { |
|
1148 AddGroupFieldsL(Pbk2AddressTools::MapViewTypeToAddress(aActiveView)); |
|
1149 } |
|
1150 |
|
1151 iParams.iActiveView = aActiveView; |
|
1152 |
|
1153 CPbk2ContactEditorDlgImpl* adressDlg = CPbk2ContactEditorDlgImpl::NewL( |
|
1154 iParams, iContact, iFieldProperties, iContactObserver, |
|
1155 iEditorStrategy, iRelocator, iAppServices ); |
|
1156 |
|
1157 iAddressView = adressDlg; |
|
1158 adressDlg->ExecuteLD(); |
|
1159 iAddressView = NULL; |
|
1160 iParams.iActiveView = TPbk2ContactEditorParams::EEditorView; |
|
1161 UpdateControlsL(); |
|
1162 |
|
1163 // The if-expression refers to the situation that need to |
|
1164 // delete editor dialog after address dialog exit completely, |
|
1165 // such as the store-unavailable situation |
|
1166 if ( iDelayDelete ) |
|
1167 { |
|
1168 iDelayDelete->Start( TCallBack( &DelayDlgDeleteCallBack, this ) ); |
|
1169 } |
|
1170 } |
|
1171 |
|
1172 // -------------------------------------------------------------------------- |
|
1173 // CPbk2ContactEditorDlgImpl::DelayDlgDeleteCallBack |
|
1174 // -------------------------------------------------------------------------- |
|
1175 // |
|
1176 TInt CPbk2ContactEditorDlgImpl::DelayDlgDeleteCallBack( TAny* aCallBack ) |
|
1177 { |
|
1178 static_cast<CPbk2ContactEditorDlgImpl*>( aCallBack )->DelayDlgDelete(); |
|
1179 return EFalse; |
|
1180 } |
|
1181 |
|
1182 // -------------------------------------------------------------------------- |
|
1183 // CPbk2ContactEditorDlgImpl::DelayDlgDelete |
|
1184 // -------------------------------------------------------------------------- |
|
1185 // |
|
1186 void CPbk2ContactEditorDlgImpl::DelayDlgDelete() |
|
1187 { |
|
1188 // Need to inform editor-observer that contact editing is |
|
1189 // aborted, at the same time, exit editor dialog directly |
|
1190 // without saving the changes. |
|
1191 iContactObserver.ContactEditingAborted(); |
|
1192 delete this; |
|
1193 } |
|
1194 |
|
1195 // -------------------------------------------------------------------------- |
|
1196 // CPbk2ContactEditorDlgImpl::AddAddressFields |
|
1197 // -------------------------------------------------------------------------- |
|
1198 // |
|
1199 void CPbk2ContactEditorDlgImpl::AddGroupFieldsL(TPbk2FieldGroupId aGroupId) |
|
1200 { |
|
1201 if (aGroupId == EPbk2FieldGroupIdNone) |
|
1202 return; |
|
1203 |
|
1204 TInt count = iFieldProperties.Count(); |
|
1205 for (TInt idx = 0; idx < count; idx++) |
|
1206 { |
|
1207 const MPbk2FieldProperty& fieldProp = iFieldProperties.At(idx); |
|
1208 if (fieldProp.GroupId() == aGroupId) |
|
1209 { |
|
1210 AddItemToContactL(fieldProp.FieldType().FieldTypeResId(), |
|
1211 KNullDesC(), EFalse); |
|
1212 } |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 // -------------------------------------------------------------------------- |
|
1217 // CPbk2ContactEditorDlgImpl::AreAllFieldsEmpty |
|
1218 // -------------------------------------------------------------------------- |
|
1219 // |
|
1220 TBool CPbk2ContactEditorDlgImpl::AreAllFieldsEmpty() |
|
1221 { |
|
1222 TBool result(ETrue); |
|
1223 TInt countAll = iContact.PresentationFields().FieldCount(); |
|
1224 for (TInt idx = 0; idx < countAll; idx++) |
|
1225 { |
|
1226 CPbk2PresentationContactField& field = |
|
1227 iContact.PresentationFields().At(idx); |
|
1228 |
|
1229 MVPbkContactFieldData& data = field.FieldData(); |
|
1230 TInt fld = field.FieldProperty().FieldType().FieldTypeResId(); |
|
1231 if(fld != R_VPBK_FIELD_TYPE_RINGTONE && |
|
1232 fld != R_VPBK_FIELD_TYPE_THUMBNAILPIC && |
|
1233 fld != R_VPBK_FIELD_TYPE_CALLEROBJIMG && |
|
1234 fld != R_VPBK_FIELD_TYPE_SYNCCLASS && |
|
1235 fld != R_VPBK_FIELD_TYPE_TOPCONTACT) |
|
1236 { |
|
1237 if(!data.IsEmpty()) |
|
1238 { |
|
1239 if(data.DataType() == EVPbkFieldStorageTypeText) |
|
1240 { |
|
1241 HBufC* fieldText = MVPbkContactFieldTextData::Cast(data).Text().AllocL(); |
|
1242 fieldText->Des().TrimAll(); |
|
1243 if(fieldText->Length() > 0) |
|
1244 { |
|
1245 result = EFalse; |
|
1246 } |
|
1247 delete fieldText; |
|
1248 } |
|
1249 else |
|
1250 { |
|
1251 result = EFalse; |
|
1252 } |
|
1253 } |
|
1254 } |
|
1255 } |
|
1256 return result; |
|
1257 } |
|
1258 |
|
1259 // -------------------------------------------------------------------------- |
|
1260 // CPbk2ContactEditorDlgImpl::ContactHasAddress |
|
1261 // -------------------------------------------------------------------------- |
|
1262 // |
|
1263 TBool CPbk2ContactEditorDlgImpl::ContactHasAddress( |
|
1264 TPbk2FieldGroupId aAddressGroup) |
|
1265 { |
|
1266 TInt countAll = iContact.PresentationFields().FieldCount(); |
|
1267 for (TInt idx = 0; idx < countAll; idx++) |
|
1268 { |
|
1269 CPbk2PresentationContactField& field = |
|
1270 iContact.PresentationFields().At(idx); |
|
1271 if (field.FieldProperty().GroupId() == aAddressGroup) |
|
1272 { |
|
1273 return ETrue; |
|
1274 } |
|
1275 } |
|
1276 return EFalse; |
|
1277 } |
|
1278 |
|
1279 // -------------------------------------------------------------------------- |
|
1280 // CPbk2ContactEditorDlgImpl::ClearControls |
|
1281 // -------------------------------------------------------------------------- |
|
1282 // |
|
1283 void CPbk2ContactEditorDlgImpl::ClearControls() |
|
1284 { |
|
1285 TInt count = iUiFieldArray->Count(); |
|
1286 for (TInt idx = count - 1; idx >= 0; idx--) |
|
1287 { |
|
1288 iUiFieldArray->RemoveFieldFromUI(idx); |
|
1289 } |
|
1290 } |
|
1291 |
|
1292 // -------------------------------------------------------------------------- |
|
1293 // CPbk2ContactEditorDlgImpl::ContactEditorControlExtension |
|
1294 // -------------------------------------------------------------------------- |
|
1295 // |
|
1296 TAny* CPbk2ContactEditorDlgImpl::ContactEditorControlExtension(TUid /*aExtensionUid*/) |
|
1297 { |
|
1298 return static_cast<MPbk2ContactEditorControlExtension*> (this); |
|
1299 } |
|
1300 |
|
1301 // -------------------------------------------------------------------------- |
|
1302 // CPbk2ContactEditorDlgImpl::UpdateControlsL |
|
1303 // -------------------------------------------------------------------------- |
|
1304 // |
|
1305 void CPbk2ContactEditorDlgImpl::UpdateControlsL() |
|
1306 { |
|
1307 iUiFieldArray->UpdateControlsL(); |
|
1308 SetAddressValidationIconsL(); |
|
1309 UpdatePageL(ETrue); |
|
1310 } |
|
1311 |
|
1312 // -------------------------------------------------------------------------- |
|
1313 // CPbk2ContactEditorDlgImpl::CheckFieldSpecificCommandL |
|
1314 // -------------------------------------------------------------------------- |
|
1315 // |
|
1316 TBool CPbk2ContactEditorDlgImpl::CheckFieldSpecificCommandL(TInt aCommandId) |
|
1317 { |
|
1318 TBool ret(EFalse); |
|
1319 CPbk2ContactEditorArrayItem* currentField = iUiFieldArray->Find( |
|
1320 IdOfFocusControl()); |
|
1321 |
|
1322 if (currentField) |
|
1323 { |
|
1324 if (currentField->ContactEditorUIField()) |
|
1325 { |
|
1326 ret = currentField->ContactEditorUIField()->HandleCustomFieldCommandL( |
|
1327 aCommandId); |
|
1328 } |
|
1329 else |
|
1330 { |
|
1331 MPbk2ContactEditorField2* tempCurrentField = |
|
1332 reinterpret_cast<MPbk2ContactEditorField2*> |
|
1333 (currentField->ContactEditorField()->ContactEditorFieldExtension( |
|
1334 KMPbk2ContactEditorFieldExtension2Uid)); |
|
1335 if (tempCurrentField) |
|
1336 { |
|
1337 ret = tempCurrentField->HandleCustomFieldCommandL(aCommandId); |
|
1338 } |
|
1339 } |
|
1340 } |
|
1341 |
|
1342 return ret; |
|
1343 } |
|
1344 |
|
1345 // -------------------------------------------------------------------------- |
|
1346 // CPbk2ContactEditorDlgImpl::DynInitMenuPaneL |
|
1347 // -------------------------------------------------------------------------- |
|
1348 // |
|
1349 void CPbk2ContactEditorDlgImpl::DynInitMenuPaneL(TInt aResourceId, |
|
1350 CEikMenuPane* aMenuPane) |
|
1351 { |
|
1352 iEditorExtension->DynInitMenuPaneL(aResourceId, aMenuPane); |
|
1353 |
|
1354 if (aResourceId == R_PBK2_CONTACTEDITOR_MENUPANE || |
|
1355 aResourceId == R_PBK2_CONTACTEDITOR_CONTEXT_MENUPANE) |
|
1356 { |
|
1357 //Label editing not anymore supported. Remove later all code |
|
1358 //related to editing labels |
|
1359 DimItem( aMenuPane, EPbk2CmdEditItemLabel); |
|
1360 // Filter delete item away from menu for first and last name fields |
|
1361 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
1362 IdOfFocusControl()); |
|
1363 MPbk2ContactEditorField* currentField = current->ContactEditorField(); |
|
1364 if (currentField) |
|
1365 { |
|
1366 if (currentField->FieldProperty().Flags() |
|
1367 & KPbk2FieldFlagCanNotBeRemoved) |
|
1368 { |
|
1369 DimItem(aMenuPane, EPbk2CmdDeleteItem); |
|
1370 } |
|
1371 //Label editing not anymore supported. Remove later all code |
|
1372 //related to editing labels |
|
1373 //MVPbkStoreContactField& field = currentField->ContactField(); |
|
1374 //if (!field.SupportsLabel()) |
|
1375 // { |
|
1376 // DimItem( aMenuPane, EPbk2CmdEditItemLabel); |
|
1377 // } |
|
1378 //else |
|
1379 // { |
|
1380 // TVPbkFieldVersitProperty prop; |
|
1381 // prop.SetName(EVPbkVersitNameIMPP); |
|
1382 // if (field.BestMatchingFieldType()->Matches(prop, 0)) |
|
1383 // { |
|
1384 // DimItem( aMenuPane, EPbk2CmdEditItemLabel); |
|
1385 // } |
|
1386 // } |
|
1387 DynInitRingtoneL(aResourceId, aMenuPane, *currentField); |
|
1388 DynInitImageL(aResourceId, aMenuPane, *currentField); |
|
1389 DynInitSyncL(aResourceId, aMenuPane, *currentField); |
|
1390 } |
|
1391 else |
|
1392 { |
|
1393 DimItem(aMenuPane, EPbk2CmdDeleteItem); |
|
1394 DimItem(aMenuPane, EPbk2CmdEditorChangeRingtone); |
|
1395 DimItem(aMenuPane, EPbk2CmdEditorRemoveRingtone); |
|
1396 DimItem(aMenuPane, EPbk2CmdEditorAddImage); |
|
1397 DimItem(aMenuPane, EPbk2CmdEditorViewImage); |
|
1398 DimItem(aMenuPane, EPbk2CmdEditorChangeImage); |
|
1399 DimItem(aMenuPane, EPbk2CmdEditorRemoveImage); |
|
1400 DimItem(aMenuPane, EPbk2CmdEditorChangeSync); |
|
1401 } |
|
1402 |
|
1403 DynInitAddressL(aResourceId, aMenuPane); |
|
1404 // If there are no available fields to add, do not show |
|
1405 // the add item dialog. If phone memory is in configuration |
|
1406 // this check is not needed. |
|
1407 if (!iRelocator.IsPhoneMemoryInConfigurationL()) |
|
1408 { |
|
1409 CArrayPtr<const MPbk2FieldProperty>* availableFields = |
|
1410 iContact.AvailableFieldsToAddL(); |
|
1411 if (!availableFields || availableFields->Count() == 0) |
|
1412 { |
|
1413 DimItem(aMenuPane, EPbk2CmdAddItem); |
|
1414 } |
|
1415 delete availableFields; |
|
1416 } |
|
1417 |
|
1418 if (aResourceId == R_PBK2_CONTACTEDITOR_MENUPANE) |
|
1419 { |
|
1420 // Hide exit, if wanted. Exit command is available only in |
|
1421 // main menu. |
|
1422 if (iParams.iFlags & TPbk2ContactEditorParams::EHideExit) |
|
1423 { |
|
1424 DimItem(aMenuPane, EAknCmdExit); |
|
1425 } |
|
1426 } |
|
1427 } |
|
1428 } |
|
1429 |
|
1430 // -------------------------------------------------------------------------- |
|
1431 // CPbk2ContactEditorDlgImpl::DynInitRingtoneL |
|
1432 // -------------------------------------------------------------------------- |
|
1433 // |
|
1434 void CPbk2ContactEditorDlgImpl::DynInitRingtoneL( |
|
1435 TInt /*aResourceId*/, |
|
1436 CEikMenuPane* aMenuPane, |
|
1437 MPbk2ContactEditorField& aCurrentField ) |
|
1438 { |
|
1439 TInt id = aCurrentField.FieldProperty().FieldType().FieldTypeResId(); |
|
1440 |
|
1441 if(id != R_VPBK_FIELD_TYPE_RINGTONE) |
|
1442 { |
|
1443 DimItem( aMenuPane, EPbk2CmdEditorChangeRingtone); |
|
1444 DimItem( aMenuPane, EPbk2CmdEditorRemoveRingtone); |
|
1445 } |
|
1446 else |
|
1447 { |
|
1448 if( aCurrentField.ContactField().FieldData().DataType() != |
|
1449 EVPbkFieldStorageTypeText || |
|
1450 aCurrentField.ContactField().FieldData().IsEmpty() ) |
|
1451 { |
|
1452 DimItem( aMenuPane, EPbk2CmdEditorRemoveRingtone); |
|
1453 } |
|
1454 //Label editing not anymore supported (is dimmed in DynInitMenuPaneL) |
|
1455 //DimItem( aMenuPane, EPbk2CmdEditItemLabel); |
|
1456 DimItem( aMenuPane, EPbk2CmdDeleteItem); |
|
1457 } |
|
1458 } |
|
1459 |
|
1460 // -------------------------------------------------------------------------- |
|
1461 // CPbk2ContactEditorDlgImpl::DynInitImageL |
|
1462 // -------------------------------------------------------------------------- |
|
1463 // |
|
1464 void CPbk2ContactEditorDlgImpl::DynInitImageL( |
|
1465 TInt /*aResourceId*/, |
|
1466 CEikMenuPane* aMenuPane, |
|
1467 MPbk2ContactEditorField& aCurrentField ) |
|
1468 { |
|
1469 TInt id = aCurrentField.FieldProperty().FieldType().FieldTypeResId(); |
|
1470 |
|
1471 if( id != R_VPBK_FIELD_TYPE_CALLEROBJIMG ) |
|
1472 { |
|
1473 DimItem( aMenuPane, EPbk2CmdEditorAddImage ); |
|
1474 DimItem( aMenuPane, EPbk2CmdEditorViewImage); |
|
1475 DimItem( aMenuPane, EPbk2CmdEditorChangeImage); |
|
1476 DimItem( aMenuPane, EPbk2CmdEditorRemoveImage); |
|
1477 } |
|
1478 else |
|
1479 { |
|
1480 if( aCurrentField.ContactField().FieldData().DataType() == |
|
1481 EVPbkFieldStorageTypeText && |
|
1482 !aCurrentField.ContactField().FieldData().IsEmpty() ) |
|
1483 { |
|
1484 DimItem( aMenuPane, EPbk2CmdEditorAddImage ); |
|
1485 |
|
1486 //Dim 'View image' if currently cold file name, e.g mem card not there. |
|
1487 TBool dimView(ETrue); |
|
1488 TPbk2FieldCtrlType type = aCurrentField.FieldProperty().CtrlType(); |
|
1489 TAny* ext = aCurrentField.ContactEditorFieldExtension(TUid::Uid(NULL)); |
|
1490 if (type == EPbk2FieldCtrlTypeImageEditor && ext) |
|
1491 { |
|
1492 CPbk2ContactEditorImageField* fld = |
|
1493 static_cast<CPbk2ContactEditorImageField*> (ext); |
|
1494 TPtrC dataPtr(MVPbkContactFieldTextData::Cast( |
|
1495 fld->ContactField().FieldData()).Text()); |
|
1496 TEntry entry; |
|
1497 RFs& fs( iCoeEnv->FsSession() ); |
|
1498 dimView = fs.Entry( dataPtr, entry ) == 0 ? EFalse : ETrue; |
|
1499 } |
|
1500 if( dimView ) |
|
1501 { |
|
1502 DimItem( aMenuPane, EPbk2CmdEditorViewImage); |
|
1503 } |
|
1504 } |
|
1505 else |
|
1506 { |
|
1507 DimItem( aMenuPane, EPbk2CmdEditorViewImage); |
|
1508 DimItem( aMenuPane, EPbk2CmdEditorChangeImage); |
|
1509 DimItem( aMenuPane, EPbk2CmdEditorRemoveImage); |
|
1510 } |
|
1511 |
|
1512 //Label editing not anymore supported (is dimmed in DynInitMenuPaneL) |
|
1513 //DimItem( aMenuPane, EPbk2CmdEditItemLabel); |
|
1514 DimItem( aMenuPane, EPbk2CmdDeleteItem); |
|
1515 } |
|
1516 } |
|
1517 |
|
1518 // -------------------------------------------------------------------------- |
|
1519 // CPbk2ContactEditorDlgImpl::DynInitSyncL |
|
1520 // -------------------------------------------------------------------------- |
|
1521 // |
|
1522 void CPbk2ContactEditorDlgImpl::DynInitSyncL( |
|
1523 TInt /*aResourceId*/, |
|
1524 CEikMenuPane* aMenuPane, |
|
1525 MPbk2ContactEditorField& aCurrentField ) |
|
1526 { |
|
1527 TInt id = aCurrentField.FieldProperty().FieldType().FieldTypeResId(); |
|
1528 |
|
1529 // If the selection popup is open, hide menu option "Change" |
|
1530 if( id == R_VPBK_FIELD_TYPE_SYNCCLASS ) |
|
1531 { |
|
1532 CEikCaptionedControl* line=CurrentLine(); |
|
1533 if ( line && (line->iControlType == EAknCtPopupField || line->iControlType == EAknCtPopupFieldText ) ) |
|
1534 { |
|
1535 CAknPopupField* ctrl = static_cast<CAknPopupField*>( line->iControl ); |
|
1536 if ( ctrl && ctrl->NumLines() > 1 ) |
|
1537 { |
|
1538 DimItem( aMenuPane, EPbk2CmdEditorChangeSync); |
|
1539 } |
|
1540 } |
|
1541 } |
|
1542 else // id != R_VPBK_FIELD_TYPE_SYNCCLASS |
|
1543 { |
|
1544 DimItem( aMenuPane, EPbk2CmdEditorChangeSync); |
|
1545 } |
|
1546 |
|
1547 } |
|
1548 // CPbk2ContactEditorDlgImpl::DynInitAddressL |
|
1549 // -------------------------------------------------------------------------- |
|
1550 // |
|
1551 void CPbk2ContactEditorDlgImpl::DynInitAddressL(TInt /*aResourceId*/, |
|
1552 CEikMenuPane* aMenuPane) |
|
1553 { |
|
1554 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
1555 IdOfFocusControl()); |
|
1556 if (iParams.iActiveView == TPbk2ContactEditorParams::EEditorView) |
|
1557 { |
|
1558 DimItem(aMenuPane, EPbk2ExtensionAssignFromMap); |
|
1559 if (current && current->ContactEditorUIField() |
|
1560 && Pbk2AddressTools::MapCtrlTypeToAddress( |
|
1561 current->ContactEditorUIField()->UIField()->CtrlType()) |
|
1562 != EPbk2FieldGroupIdNone) |
|
1563 { |
|
1564 UnDimItem(aMenuPane, EPbk2CmdEditorOpen); |
|
1565 UnDimItem(aMenuPane, EPbk2CmdDeleteItem); |
|
1566 } |
|
1567 else |
|
1568 { |
|
1569 DimItem(aMenuPane, EPbk2CmdEditorOpen); |
|
1570 } |
|
1571 } |
|
1572 else |
|
1573 { |
|
1574 DimItem(aMenuPane, EPbk2CmdAddItem); |
|
1575 DimItem(aMenuPane, EPbk2CmdEditorOpen); |
|
1576 DimItem(aMenuPane, EPbk2CmdDeleteItem); |
|
1577 } |
|
1578 } |
|
1579 |
|
1580 // -------------------------------------------------------------------------- |
|
1581 // CPbk2ContactEditorDlgImpl::DimItem |
|
1582 // -------------------------------------------------------------------------- |
|
1583 // |
|
1584 void CPbk2ContactEditorDlgImpl::DimItem(CEikMenuPane* aMenuPane, TInt aCmd) |
|
1585 { |
|
1586 TInt pos; |
|
1587 if (aMenuPane->MenuItemExists(aCmd, pos)) |
|
1588 { |
|
1589 aMenuPane->SetItemDimmed(aCmd, ETrue); |
|
1590 } |
|
1591 } |
|
1592 |
|
1593 // -------------------------------------------------------------------------- |
|
1594 // CPbk2ContactEditorDlgImpl::UnDimItem |
|
1595 // -------------------------------------------------------------------------- |
|
1596 // |
|
1597 void CPbk2ContactEditorDlgImpl::UnDimItem(CEikMenuPane* aMenuPane, TInt aCmd) |
|
1598 { |
|
1599 TInt pos; |
|
1600 if (aMenuPane->MenuItemExists(aCmd, pos)) |
|
1601 { |
|
1602 aMenuPane->SetItemDimmed(aCmd, EFalse); |
|
1603 } |
|
1604 } |
|
1605 |
|
1606 // -------------------------------------------------------------------------- |
|
1607 // CPbk2ContactEditorDlgImpl::OkToExitL |
|
1608 // -------------------------------------------------------------------------- |
|
1609 // |
|
1610 TBool CPbk2ContactEditorDlgImpl::OkToExitL(TInt aKeycode) |
|
1611 { |
|
1612 TBool ret = EFalse; |
|
1613 if( iCommandPending ) |
|
1614 { |
|
1615 //When command in process prevent further processing |
|
1616 ret = EFalse; |
|
1617 } |
|
1618 else if ( iExitRecord.IsSet( EOkToExitWithoutHandlingIt ) ) |
|
1619 { |
|
1620 ret = ETrue; |
|
1621 } |
|
1622 else if ( aKeycode == EAknSoftkeyDone ) |
|
1623 { |
|
1624 // Done key pressed |
|
1625 MPbk2ContactEditorEventObserver::TParams params; |
|
1626 params.iFlags = EPbk2EditorKeyCode; |
|
1627 params.iKeyCode = aKeycode; |
|
1628 CmdDoneL( params ); |
|
1629 } |
|
1630 else if (aKeycode == EKeyEscape || aKeycode == EEikBidCancel) |
|
1631 { |
|
1632 // this happens when service is canceled, so in this case, |
|
1633 // do nothing but give ret ETrue, so that this object |
|
1634 // is able to be deleted later. |
|
1635 if( iServiceCanceled ) |
|
1636 { |
|
1637 ret = ETrue; |
|
1638 } |
|
1639 // Escape or end key pressed. |
|
1640 // We must save changes and exit the applicatio |
|
1641 else if( !iExitRecord.IsSet( EExitOrdered ) ) |
|
1642 { |
|
1643 // Remove empty status pane |
|
1644 if (iNaviContainer) |
|
1645 { |
|
1646 iNaviContainer->Pop(); |
|
1647 RestorePrevNaviDecoratorL(); |
|
1648 iNaviContainer = NULL; |
|
1649 } |
|
1650 MakeVisible( EFalse ); |
|
1651 MPbk2ContactEditorEventObserver::TParams params; |
|
1652 params.iFlags = EPbk2EditorKeyCode; |
|
1653 params.iKeyCode = aKeycode; |
|
1654 |
|
1655 // If the application is not allowed to hide itself in the |
|
1656 // background, end of the dialog is also end of the |
|
1657 // application. |
|
1658 if ( !iAvkonAppUi->ExitHidesInBackground() ) |
|
1659 { |
|
1660 iExitRecord.Set( EExitOrdered ); |
|
1661 |
|
1662 if( OkToExitApplicationL( EAknCmdExit ) ) |
|
1663 { |
|
1664 params.iCommandId = EAknCmdExit; |
|
1665 } |
|
1666 } |
|
1667 |
|
1668 CmdDoneL( params ); |
|
1669 } |
|
1670 } |
|
1671 else if (aKeycode == EAknSoftkeyContextOptions) |
|
1672 { |
|
1673 // Launch context menu if the control is not popup control |
|
1674 CEikCaptionedControl* line = CurrentLine(); |
|
1675 TInt type = line->iControlType; |
|
1676 TBool isPopUp = ( type == EAknCtPopupFieldText ) || |
|
1677 ( type == EAknCtPopupField ); |
|
1678 if (isPopUp) |
|
1679 { |
|
1680 CAknPopupField* ctrl = |
|
1681 static_cast<CAknPopupField*>( line->iControl ); |
|
1682 ctrl->ActivateSelectionListL(); |
|
1683 } |
|
1684 else |
|
1685 { |
|
1686 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
1687 IdOfFocusControl()); |
|
1688 if (current && current->ContactEditorUIField()) |
|
1689 { |
|
1690 TPbk2ContactEditorParams::TActiveView |
|
1691 viewType = |
|
1692 Pbk2AddressTools::MapCtrlTypeToViewType( |
|
1693 current->ContactEditorUIField()->UIField()->CtrlType()); |
|
1694 if (viewType != TPbk2ContactEditorParams::EEditorUndefinied) |
|
1695 { |
|
1696 ExecuteAddressDlgL(viewType); |
|
1697 return ret; |
|
1698 } |
|
1699 else if (current->ContactEditorUIField()->UIField()->CtrlType() |
|
1700 == EPbk2FieldCtrlTypeExtAssignFromMapsEditor) |
|
1701 { |
|
1702 HandleCustomFieldCommandL(EPbk2ExtensionAssignFromMap); |
|
1703 return ret; |
|
1704 } |
|
1705 } |
|
1706 |
|
1707 iContextMenuBar->SetMenuTitleResourceId( |
|
1708 R_PBK2_CONTACTEDITOR_CONTEXT_MENUBAR); |
|
1709 iContextMenuBar->SetMenuType(CEikMenuBar::EMenuContext); |
|
1710 iContextMenuBar->StopDisplayingMenuBar(); |
|
1711 iContextMenuBar->TryDisplayMenuBarL(); |
|
1712 iContextMenuBar->SetMenuTitleResourceId |
|
1713 ( R_PBK2_CONTACTEDITOR_MENUBAR ); |
|
1714 iContextMenuBar->SetMenuType( CEikMenuBar::EMenuOptions ); |
|
1715 } |
|
1716 } |
|
1717 else if( aKeycode == EAknSoftkeyChange ) |
|
1718 { |
|
1719 //For custom controls (ringtone, image) msk middle key press need to be |
|
1720 //caught here |
|
1721 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
1722 IdOfFocusControl()); |
|
1723 MPbk2ContactEditorField* currentField = NULL; |
|
1724 if (current) |
|
1725 { |
|
1726 currentField = current->ContactEditorField(); |
|
1727 } |
|
1728 |
|
1729 if (currentField) |
|
1730 { |
|
1731 TInt id = currentField->ControlId(); |
|
1732 if (id == EPbk2EditorLineRingtone || id == EPbk2EditorLineImage) |
|
1733 { |
|
1734 MPbk2ContactEditorField2 |
|
1735 * tempCurrentField = |
|
1736 reinterpret_cast<MPbk2ContactEditorField2*> (currentField->ContactEditorFieldExtension( |
|
1737 KMPbk2ContactEditorFieldExtension2Uid)); |
|
1738 if (tempCurrentField) |
|
1739 { |
|
1740 tempCurrentField->HandleCustomFieldCommandL( |
|
1741 EPbk2CmdEditorHandleCustomSelect); |
|
1742 } |
|
1743 } |
|
1744 else |
|
1745 { |
|
1746 //For non-custom fields (sync...) forward to framework |
|
1747 ForwardOkToExitL( aKeycode ); |
|
1748 } |
|
1749 } |
|
1750 } |
|
1751 else |
|
1752 { |
|
1753 ForwardOkToExitL( aKeycode ); |
|
1754 } |
|
1755 |
|
1756 // Clear the exit state after usage. |
|
1757 iExitRecord.Clear( EOkToExitWithoutHandlingIt ); |
|
1758 return ret; |
|
1759 } |
|
1760 |
|
1761 // -------------------------------------------------------------------------- |
|
1762 // CPbk2ContactEditorDlgImpl::ForwardOkToExitL |
|
1763 // -------------------------------------------------------------------------- |
|
1764 // |
|
1765 void CPbk2ContactEditorDlgImpl::ForwardOkToExitL( TInt aKeycode ) |
|
1766 { |
|
1767 //Prevent further execution of menu commands while a command is running. |
|
1768 //In touch tapping RSK very quickly for ringtone gets otherwise through |
|
1769 //when ringtone fetch command is running. |
|
1770 TBool okToSkip = iCommandPending && aKeycode != EAknSoftkeyDone && |
|
1771 aKeycode != EAknCmdExit && aKeycode != EAknCmdExit; |
|
1772 if(!okToSkip) |
|
1773 { |
|
1774 CAknForm::OkToExitL( aKeycode ); |
|
1775 } |
|
1776 } |
|
1777 |
|
1778 // -------------------------------------------------------------------------- |
|
1779 // CPbk2ContactEditorDlgImpl::HandleControlStateChangeL |
|
1780 // -------------------------------------------------------------------------- |
|
1781 // |
|
1782 void CPbk2ContactEditorDlgImpl::HandleControlStateChangeL(TInt aControlId) |
|
1783 { |
|
1784 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
1785 aControlId); |
|
1786 MPbk2ContactEditorField* changedField = current->ContactEditorField(); |
|
1787 __ASSERT_DEBUG(changedField, Panic(EHandleControlStateChangeL_NullField)); |
|
1788 if (changedField && iNameFormatter->IsTitleField( |
|
1789 changedField->ContactField())) |
|
1790 { |
|
1791 UpdateTitleL(); |
|
1792 } |
|
1793 } |
|
1794 |
|
1795 // -------------------------------------------------------------------------- |
|
1796 // CPbk2ContactEditorDlgImpl::CreateLineL |
|
1797 // -------------------------------------------------------------------------- |
|
1798 // |
|
1799 CCoeControl* CPbk2ContactEditorDlgImpl::CreateLineL |
|
1800 ( const TDesC& aCaption, TInt aControlId, TInt aControlType ) |
|
1801 { |
|
1802 return CreateLineByTypeL( aCaption, aControlId, aControlType, NULL ); |
|
1803 } |
|
1804 |
|
1805 // -------------------------------------------------------------------------- |
|
1806 // CPbk2ContactEditorDlgImpl::LineControl |
|
1807 // -------------------------------------------------------------------------- |
|
1808 // |
|
1809 CEikCaptionedControl* CPbk2ContactEditorDlgImpl::LineControl |
|
1810 ( TInt aControlId ) const |
|
1811 { |
|
1812 return Line( aControlId ); |
|
1813 } |
|
1814 |
|
1815 // -------------------------------------------------------------------------- |
|
1816 // CPbk2ContactEditorDlgImpl::DeleteControl |
|
1817 // -------------------------------------------------------------------------- |
|
1818 // |
|
1819 void CPbk2ContactEditorDlgImpl::DeleteControl(TInt aControlId) |
|
1820 { |
|
1821 DeleteLine( aControlId ); |
|
1822 TRAP_IGNORE( UpdateTitleL() ); |
|
1823 } |
|
1824 |
|
1825 // -------------------------------------------------------------------------- |
|
1826 // CPbk2ContactEditorDlgImpl::TryChangeFocusL |
|
1827 // -------------------------------------------------------------------------- |
|
1828 // |
|
1829 void CPbk2ContactEditorDlgImpl::TryChangeFocusL(TInt aControlId) |
|
1830 { |
|
1831 //Ensure current line is set before trying to change focus |
|
1832 if(!CurrentLine()) |
|
1833 { |
|
1834 SetInitialCurrentLine(); |
|
1835 } |
|
1836 |
|
1837 //Attempt setting the focus |
|
1838 if ( ControlOrNull( aControlId ) ) |
|
1839 { |
|
1840 TryChangeFocusToL( aControlId ); |
|
1841 } |
|
1842 } |
|
1843 |
|
1844 // -------------------------------------------------------------------------- |
|
1845 // CPbk2ContactEditorDlgImpl::SetCurrentLineCaptionL |
|
1846 // -------------------------------------------------------------------------- |
|
1847 // |
|
1848 void CPbk2ContactEditorDlgImpl::SetCurrentLineCaptionL(const TDesC& aText) |
|
1849 { |
|
1850 SetControlCaptionL(IdOfFocusControl(), aText); |
|
1851 } |
|
1852 |
|
1853 // -------------------------------------------------------------------------- |
|
1854 // CPbk2ContactEditorDlgImpl::Control |
|
1855 // -------------------------------------------------------------------------- |
|
1856 // |
|
1857 CCoeControl* CPbk2ContactEditorDlgImpl::Control(TInt aControlId) const |
|
1858 { |
|
1859 return ControlOrNull(aControlId); |
|
1860 } |
|
1861 |
|
1862 // -------------------------------------------------------------------------- |
|
1863 // CPbk2ContactEditorDlgImpl::SetEditableL |
|
1864 // -------------------------------------------------------------------------- |
|
1865 // |
|
1866 void CPbk2ContactEditorDlgImpl::SetEditableL( TBool aState ) |
|
1867 { |
|
1868 CAknForm::SetEditableL( aState ); |
|
1869 } |
|
1870 |
|
1871 // -------------------------------------------------------------------------- |
|
1872 // CPbk2ContactEditorDlgImpl::LoadBitmapToFieldL |
|
1873 // -------------------------------------------------------------------------- |
|
1874 // |
|
1875 void CPbk2ContactEditorDlgImpl::LoadBitmapToFieldL |
|
1876 ( const MPbk2FieldProperty& aFieldProperty, |
|
1877 const CPbk2IconInfoContainer& aIconInfoContainer, |
|
1878 TInt aControlId ) |
|
1879 { |
|
1880 CPbk2IconFactory* factory = CPbk2IconFactory::NewLC( aIconInfoContainer ); |
|
1881 CEikImage* image = factory->CreateImageLC( aFieldProperty.IconId() ); |
|
1882 |
|
1883 if ( image ) |
|
1884 { |
|
1885 CEikCaptionedControl* line = LineControl( aControlId ); |
|
1886 if( line ) |
|
1887 { |
|
1888 line->SetIconL( |
|
1889 const_cast<CFbsBitmap*>( image->Bitmap() ), |
|
1890 const_cast<CFbsBitmap*>( image->Mask() ) ); |
|
1891 line->iBitmap->SetPictureOwnedExternally( EFalse ); |
|
1892 image->SetPictureOwnedExternally( ETrue ); |
|
1893 line->iBitmap->SetNonFocusing(); |
|
1894 line->iBitmap->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
1895 line->iBitmap->SetContainerWindowL( *line ); |
|
1896 } |
|
1897 |
|
1898 CleanupStack::PopAndDestroy( image ); |
|
1899 } |
|
1900 |
|
1901 CleanupStack::PopAndDestroy( factory ); |
|
1902 } |
|
1903 |
|
1904 // -------------------------------------------------------------------------- |
|
1905 // CPbk2ContactEditorDlgImpl::ContactEditorOperationCompleted |
|
1906 // -------------------------------------------------------------------------- |
|
1907 // |
|
1908 void CPbk2ContactEditorDlgImpl::ContactEditorOperationCompleted |
|
1909 ( MVPbkContactObserver::TContactOpResult aResult, |
|
1910 MPbk2ContactEditorEventObserver::TParams aParams ) |
|
1911 { |
|
1912 iUseState = EUseFinished; |
|
1913 |
|
1914 // Notify extensions |
|
1915 iEditorExtension->ContactEditorOperationCompleted |
|
1916 ( aResult, aParams ); |
|
1917 |
|
1918 switch ( aResult.iOpCode ) |
|
1919 { |
|
1920 case MVPbkContactObserver::EContactOperationUnknown: // FALLTHROUGH |
|
1921 { |
|
1922 CloseDialog( aResult.iOpCode, ETrue ); |
|
1923 break; |
|
1924 } |
|
1925 case MVPbkContactObserver::EContactCommit: // FALLTHROUGH |
|
1926 case MVPbkContactObserver::EContactDelete: |
|
1927 { |
|
1928 if ( aParams.iFlags & EPbk2EditorKeyCode && |
|
1929 aParams.iKeyCode == EAknSoftkeyDone ) |
|
1930 { |
|
1931 CloseDialog( aResult.iOpCode, ETrue ); |
|
1932 } |
|
1933 else if ( ( aParams.iFlags & EPbk2EditorKeyCode && |
|
1934 aParams.iKeyCode == EEikBidCancel ) || |
|
1935 ( aParams.iFlags & EPbk2EditorCommandId && |
|
1936 aParams.iCommandId == EEikBidCancel ) ) |
|
1937 { |
|
1938 if( iExitRecord.IsSet( EExitOrdered ) ) |
|
1939 { |
|
1940 ExitApplication( aResult.iOpCode, EAknCmdExit ); |
|
1941 } |
|
1942 else |
|
1943 { |
|
1944 CloseDialog( aResult.iOpCode, ETrue ); |
|
1945 } |
|
1946 } |
|
1947 else if ( ( aParams.iFlags & EPbk2EditorCommandId ) && |
|
1948 ( ( aParams.iCommandId == EEikCmdExit ) || |
|
1949 ( aParams.iCommandId == EAknCmdExit ) ) ) |
|
1950 { |
|
1951 ExitApplication( aResult.iOpCode, aParams.iCommandId ); |
|
1952 } |
|
1953 break; |
|
1954 } |
|
1955 default: |
|
1956 { |
|
1957 // Do nothing |
|
1958 break; |
|
1959 } |
|
1960 } |
|
1961 } |
|
1962 |
|
1963 // -------------------------------------------------------------------------- |
|
1964 // CPbk2ContactEditorDlgImpl::CloseDialog |
|
1965 // -------------------------------------------------------------------------- |
|
1966 // |
|
1967 void CPbk2ContactEditorDlgImpl::CloseDialog() |
|
1968 { |
|
1969 // Ignore error and close editor without further user interaction |
|
1970 MVPbkContactObserver::TContactOpResult exitResult; |
|
1971 exitResult.iExtension = NULL; |
|
1972 exitResult.iStoreContact = NULL; |
|
1973 exitResult.iOpCode = MVPbkContactObserver::EContactDelete; |
|
1974 MPbk2ContactEditorEventObserver::TParams exitParams; |
|
1975 if ( iAvkonAppUi->ExitHidesInBackground() ) |
|
1976 { |
|
1977 exitParams.iCommandId = 0; |
|
1978 exitParams.iFlags = EPbk2EditorKeyCode; |
|
1979 exitParams.iKeyCode = EAknSoftkeyDone; |
|
1980 } |
|
1981 else |
|
1982 { |
|
1983 exitParams.iCommandId = EAknCmdExit; |
|
1984 exitParams.iFlags = EPbk2EditorCommandId; |
|
1985 exitParams.iKeyCode = 0; |
|
1986 |
|
1987 iExitRecord.Set( EExitApproved ); |
|
1988 iExitRecord.Set( EExitOrdered ); |
|
1989 } |
|
1990 |
|
1991 ContactEditorOperationCompleted(exitResult, exitParams); |
|
1992 } |
|
1993 |
|
1994 // -------------------------------------------------------------------------- |
|
1995 // CPbk2ContactEditorDlgImpl::ContactEditorOperationFailed |
|
1996 // -------------------------------------------------------------------------- |
|
1997 // |
|
1998 void CPbk2ContactEditorDlgImpl::ContactEditorOperationFailed |
|
1999 ( MVPbkContactObserver::TContactOp aOpCode, |
|
2000 TInt aErrorCode, MPbk2ContactEditorEventObserver::TParams aParams, |
|
2001 MPbk2ContactEditorEventObserver::TFailParams& aFailParams ) |
|
2002 { |
|
2003 iUseState = EUseReady; |
|
2004 |
|
2005 if( iEndKeyWasPressed ) |
|
2006 { |
|
2007 CloseDialog(); |
|
2008 } |
|
2009 else |
|
2010 { |
|
2011 // Offer the failure to the extensions first |
|
2012 iEditorExtension->ContactEditorOperationFailed(aOpCode, |
|
2013 aErrorCode, aParams, aFailParams ); |
|
2014 |
|
2015 // If extensions did not handle the error, handle it here |
|
2016 if ( !aFailParams.iErrorNotified ) |
|
2017 { |
|
2018 CCoeEnv::Static()->HandleError( aErrorCode ); |
|
2019 } |
|
2020 |
|
2021 if ( aFailParams.iErrorCode != KErrNone ) |
|
2022 { |
|
2023 TPbk2RelocationQyeryPolicy policy( |
|
2024 Pbk2ContactRelocator::EPbk2DisplayNoQueries ); |
|
2025 |
|
2026 if ( aFailParams.iErrorCode == KErrNotSupported ) |
|
2027 { |
|
2028 policy = Pbk2ContactRelocator::EPbk2DisplayStoreDoesNotSupportQuery; |
|
2029 } |
|
2030 else if ( aFailParams.iErrorCode == KErrGeneral ) |
|
2031 { |
|
2032 policy = Pbk2ContactRelocator::EPbk2DisplayBasicQuery; |
|
2033 } |
|
2034 |
|
2035 TBool result( EFalse ); |
|
2036 TRAPD( err, result = iRelocator.RelocateContactL( policy ) ); |
|
2037 |
|
2038 if ( result ) |
|
2039 { |
|
2040 // Do not close editor if contact need to relocate the first. |
|
2041 aFailParams.iCloseEditor = EFalse; |
|
2042 } |
|
2043 |
|
2044 if ( err != KErrNone ) |
|
2045 { |
|
2046 CCoeEnv::Static()->HandleError( err ); |
|
2047 } |
|
2048 } |
|
2049 // Clear EExitOrdered to let next exit cmd available |
|
2050 iExitRecord.Clear(EExitOrdered); |
|
2051 if ( aFailParams.iCloseEditor ) |
|
2052 { |
|
2053 CloseDialog( MVPbkContactObserver::EContactOperationUnknown, ETrue ); |
|
2054 } |
|
2055 } |
|
2056 } |
|
2057 |
|
2058 // -------------------------------------------------------------------------- |
|
2059 // CPbk2ContactEditorDlgImpl::RequestExitL |
|
2060 // -------------------------------------------------------------------------- |
|
2061 // |
|
2062 void CPbk2ContactEditorDlgImpl::RequestExitL(TInt aCommandId) |
|
2063 { |
|
2064 if (iAddressView) |
|
2065 { |
|
2066 iAddressView->RequestExitL(aCommandId); |
|
2067 } |
|
2068 |
|
2069 if ( iUseState == EUseFinished ) |
|
2070 { |
|
2071 ForceExit(); |
|
2072 } |
|
2073 else if ( iUseState == EUseOperatingContact ) |
|
2074 { |
|
2075 iEditorStrategy.StopQuery(); |
|
2076 iExitRecord.Set( EExitApproved ); |
|
2077 iExitRecord.Set( EExitOrdered ); |
|
2078 } |
|
2079 else |
|
2080 { |
|
2081 if ( aCommandId == EKeyEscape ) |
|
2082 { |
|
2083 iEndKeyWasPressed = ETrue; |
|
2084 OkToExitL( EAknSoftkeyDone ); |
|
2085 // If iUseState is set EUseOperatingContact by above function |
|
2086 if ( iUseState == EUseOperatingContact ) |
|
2087 { |
|
2088 WaitFinishL(); |
|
2089 } |
|
2090 } |
|
2091 else |
|
2092 { |
|
2093 iExitRecord.Set( EExitApproved ); |
|
2094 iExitRecord.Set( EExitOrdered ); |
|
2095 MPbk2ContactEditorEventObserver::TParams params; |
|
2096 params.iFlags = EPbk2EditorCommandId; |
|
2097 params.iCommandId = aCommandId; |
|
2098 CmdDoneL( params ); |
|
2099 } |
|
2100 } |
|
2101 } |
|
2102 |
|
2103 // -------------------------------------------------------------------------- |
|
2104 // CPbk2ContactEditorDlgImpl::ForceExit |
|
2105 // -------------------------------------------------------------------------- |
|
2106 // |
|
2107 void CPbk2ContactEditorDlgImpl::ForceExit() |
|
2108 { |
|
2109 iServiceCanceled = ETrue; |
|
2110 |
|
2111 if (iAddressView) |
|
2112 { |
|
2113 iAddressView->ForceExit(); |
|
2114 } |
|
2115 |
|
2116 if ( iUseState == EUseOperatingContact ) |
|
2117 { |
|
2118 iEditorStrategy.StopQuery(); |
|
2119 iExitRecord.Set( EExitApproved ); |
|
2120 iExitRecord.Set( EExitOrdered ); |
|
2121 // It is ignored for dlg would exit |
|
2122 // Leave is not valuable |
|
2123 TRAP_IGNORE( WaitFinishL() ); |
|
2124 } |
|
2125 else |
|
2126 { |
|
2127 iExitRecord.Set( EOkToExitWithoutHandlingIt ); |
|
2128 |
|
2129 TRAPD( err, TryExitL( EAknSoftkeyBack ) ); |
|
2130 if ( err != KErrNone ) |
|
2131 { |
|
2132 // If not nicely then use the force |
|
2133 delete this; |
|
2134 } |
|
2135 } |
|
2136 } |
|
2137 |
|
2138 // -------------------------------------------------------------------------- |
|
2139 // CPbk2ContactEditorDlgImpl::ResetWhenDestroyed |
|
2140 // -------------------------------------------------------------------------- |
|
2141 // |
|
2142 void CPbk2ContactEditorDlgImpl::ResetWhenDestroyed |
|
2143 ( MPbk2DialogEliminator** aSelfPtr ) |
|
2144 { |
|
2145 iSelfPtr = aSelfPtr; |
|
2146 } |
|
2147 |
|
2148 // -------------------------------------------------------------------------- |
|
2149 // CPbk2ContactEditorDlgImpl::SetFocus |
|
2150 // -------------------------------------------------------------------------- |
|
2151 // |
|
2152 void CPbk2ContactEditorDlgImpl::SetFocus(TInt aIndex) |
|
2153 { |
|
2154 TBool found = EFalse; |
|
2155 TInt count = 0; |
|
2156 TInt idx; |
|
2157 for (idx = 0; idx < iUiFieldArray->Count(); idx++) |
|
2158 { |
|
2159 if (iUiFieldArray->At(idx).ContactEditorField()) |
|
2160 { |
|
2161 if (count == aIndex) |
|
2162 { |
|
2163 found = ETrue; |
|
2164 break; |
|
2165 } |
|
2166 count++; |
|
2167 } |
|
2168 } |
|
2169 if (found) |
|
2170 { |
|
2171 iUiFieldArray->SetFocus(idx); |
|
2172 } |
|
2173 } |
|
2174 |
|
2175 // -------------------------------------------------------------------------- |
|
2176 // CPbk2ContactEditorDlgImpl::NumberOfControls |
|
2177 // -------------------------------------------------------------------------- |
|
2178 // |
|
2179 TInt CPbk2ContactEditorDlgImpl::NumberOfControls() const |
|
2180 { |
|
2181 TInt count = 0; |
|
2182 for (TInt idx = 0; idx < iUiFieldArray->Count(); idx++) |
|
2183 { |
|
2184 if (iUiFieldArray->At(idx).ContactEditorField()) |
|
2185 { |
|
2186 count++; |
|
2187 } |
|
2188 } |
|
2189 return count; |
|
2190 } |
|
2191 |
|
2192 // -------------------------------------------------------------------------- |
|
2193 // CPbk2ContactEditorDlgImpl::IndexOfCtrlType |
|
2194 // -------------------------------------------------------------------------- |
|
2195 // |
|
2196 TInt CPbk2ContactEditorDlgImpl::IndexOfCtrlType(TPbk2FieldCtrlType aType, |
|
2197 TInt& aIndex) const |
|
2198 { |
|
2199 TInt ret = KErrNotFound; |
|
2200 const TInt fieldCount = iUiFieldArray->Count(); |
|
2201 for (TInt i = Max(aIndex, 0); i < fieldCount; ++i) |
|
2202 { |
|
2203 if (iUiFieldArray->At(i).ContactEditorField()) |
|
2204 { |
|
2205 const MPbk2FieldProperty & property = |
|
2206 iUiFieldArray->At(i).ContactEditorField()->FieldProperty(); |
|
2207 if (property.CtrlType() == aType) |
|
2208 { |
|
2209 ret = i; |
|
2210 break; |
|
2211 } |
|
2212 } |
|
2213 } |
|
2214 return ret; |
|
2215 } |
|
2216 |
|
2217 // -------------------------------------------------------------------------- |
|
2218 // CPbk2ContactEditorDlgImpl::AreAllControlsEmpty |
|
2219 // -------------------------------------------------------------------------- |
|
2220 // |
|
2221 TBool CPbk2ContactEditorDlgImpl::AreAllControlsEmpty() const |
|
2222 { |
|
2223 return iUiFieldArray->AreAllUiFieldsEmpty(); |
|
2224 } |
|
2225 |
|
2226 // -------------------------------------------------------------------------- |
|
2227 // CPbk2ContactEditorDlgImpl::IsControlEmptyL |
|
2228 // -------------------------------------------------------------------------- |
|
2229 // |
|
2230 TBool CPbk2ContactEditorDlgImpl::IsControlEmptyL(TInt aIndex) const |
|
2231 { |
|
2232 __ASSERT_DEBUG( iUiFieldArray->Count()> aIndex, |
|
2233 Panic( EPanic_IsControlEmptyL_OOB ) ); |
|
2234 TBool ret = EFalse; |
|
2235 |
|
2236 // There are two types field controls in the edit dialog, one is the editor |
|
2237 // field control and the other is editor ui field control. The editor field |
|
2238 // control are concreted field mapping to one field, it also can be divided |
|
2239 // into two types, custom control and normal control. The editor ui field |
|
2240 // control are more like a container, currently only be used as the address |
|
2241 // container which can contain several editor field controls. |
|
2242 if ( iUiFieldArray->At(aIndex).ContactEditorField() ) |
|
2243 { |
|
2244 // The custom control are special controls, like image, ring tone or date, |
|
2245 // they need use special way to judge if empty. |
|
2246 TBool empty = ETrue; |
|
2247 if( IsCustomControlEmptyL(aIndex, empty ) ) |
|
2248 { |
|
2249 ret = empty; |
|
2250 } |
|
2251 // The control is normal editor field control. |
|
2252 else |
|
2253 { |
|
2254 ret = iUiFieldArray->IsEditorFieldControlEmpty( aIndex ); |
|
2255 } |
|
2256 } |
|
2257 // If it's not an editor field control, judge if it's an editor ui field control. |
|
2258 else |
|
2259 { |
|
2260 // Check if contact editor ui field like address field is empty. |
|
2261 if ( iUiFieldArray->At( aIndex ).ContactEditorUIField() ) |
|
2262 { |
|
2263 ret = iUiFieldArray->IsEditorUiFieldControlEmpty( aIndex ); |
|
2264 } |
|
2265 } |
|
2266 |
|
2267 |
|
2268 return ret; |
|
2269 } |
|
2270 |
|
2271 // -------------------------------------------------------------------------- |
|
2272 // CPbk2ContactEditorDlgImpl::IsCustomControlEmptyL |
|
2273 // |
|
2274 // Check emptiness of those fields that technically may contain data although |
|
2275 // in view of user and ui are considered as empty (e.g. "Add image" text) |
|
2276 // -------------------------------------------------------------------------- |
|
2277 // |
|
2278 TBool CPbk2ContactEditorDlgImpl::IsCustomControlEmptyL(TInt aIndex, TBool& aRet) const |
|
2279 { |
|
2280 __ASSERT_DEBUG( iUiFieldArray->Count()> aIndex, |
|
2281 Panic( EPanic_IsControlEmptyL_OOB ) ); |
|
2282 TBool isCustom(EFalse); |
|
2283 if (!iUiFieldArray->At(aIndex).ContactEditorField()) |
|
2284 { |
|
2285 return isCustom; |
|
2286 } |
|
2287 MPbk2ContactEditorField& currentField = |
|
2288 *(iUiFieldArray->At(aIndex).ContactEditorField()); |
|
2289 TPbk2FieldCtrlType type = currentField.FieldProperty().CtrlType(); |
|
2290 TAny* ext = currentField.ContactEditorFieldExtension(TUid::Uid(NULL)); |
|
2291 |
|
2292 if (type == EPbk2FieldCtrlTypeImageEditor && ext) |
|
2293 { |
|
2294 CPbk2ContactEditorImageField* fld = |
|
2295 static_cast<CPbk2ContactEditorImageField*> (ext); |
|
2296 aRet = fld->TextState() == CPbk2ContactEditorImageField::ENoData; |
|
2297 isCustom = ETrue; |
|
2298 } |
|
2299 else if (type == EPbk2FieldCtrlTypeRingtoneEditor && ext) |
|
2300 { |
|
2301 CPbk2ContactEditorRingtoneField* fld = |
|
2302 static_cast<CPbk2ContactEditorRingtoneField*> (ext); |
|
2303 aRet = fld->TextState() == CPbk2ContactEditorRingtoneField::ENoData; |
|
2304 isCustom = ETrue; |
|
2305 } |
|
2306 else if (type == EPbk2FieldCtrlTypeDateEditor) |
|
2307 { |
|
2308 // If contact has a date field, for index counting |
|
2309 // date editor field is considered as a custom control |
|
2310 // and it is not empty. |
|
2311 isCustom = ETrue; |
|
2312 aRet = EFalse; |
|
2313 } |
|
2314 |
|
2315 return isCustom; |
|
2316 } |
|
2317 // CPbk2ContactEditorDlgImpl::EditorField |
|
2318 // -------------------------------------------------------------------------- |
|
2319 // |
|
2320 MPbk2ContactEditorField& CPbk2ContactEditorDlgImpl::EditorField(TInt aIndex) const |
|
2321 { |
|
2322 __ASSERT_DEBUG( iUiFieldArray->Count()> aIndex, |
|
2323 Panic( EPanic_EditorField_OOB ) ); |
|
2324 |
|
2325 TBool found = EFalse; |
|
2326 TInt count = 0; |
|
2327 TInt idx; |
|
2328 for (idx = 0; idx < iUiFieldArray->Count(); idx++) |
|
2329 { |
|
2330 if (iUiFieldArray->At(idx).ContactEditorField()) |
|
2331 { |
|
2332 if (count == aIndex) |
|
2333 { |
|
2334 found = ETrue; |
|
2335 break; |
|
2336 } |
|
2337 count++; |
|
2338 } |
|
2339 } |
|
2340 |
|
2341 __ASSERT_DEBUG( found, |
|
2342 Panic( EPanic_EditorField_OOB ) ); |
|
2343 return *(iUiFieldArray->At(idx).ContactEditorField()); |
|
2344 } |
|
2345 |
|
2346 // -------------------------------------------------------------------------- |
|
2347 // CPbk2ContactEditorDlgImpl::StoreReady |
|
2348 // -------------------------------------------------------------------------- |
|
2349 // |
|
2350 void CPbk2ContactEditorDlgImpl::StoreReady(MVPbkContactStore& /*aContactStore*/) |
|
2351 { |
|
2352 // Do nothing |
|
2353 } |
|
2354 |
|
2355 // -------------------------------------------------------------------------- |
|
2356 // CPbk2ContactEditorDlgImpl::StoreUnavailable |
|
2357 // -------------------------------------------------------------------------- |
|
2358 // |
|
2359 void CPbk2ContactEditorDlgImpl::StoreUnavailable |
|
2360 ( MVPbkContactStore& aContactStore, TInt /*aReason*/ ) |
|
2361 { |
|
2362 if ( &aContactStore == &iContact.ParentStore() ) |
|
2363 { |
|
2364 // Use iAppServices if provided. This is to enable editor use outside from pbk2 context |
|
2365 const CPbk2StoreProperty* property = NULL; |
|
2366 if( iAppServices ) |
|
2367 { |
|
2368 property = |
|
2369 iAppServices->StoreProperties().FindProperty |
|
2370 ( aContactStore.StoreProperties().Uri() ); |
|
2371 } |
|
2372 else |
|
2373 { |
|
2374 property = |
|
2375 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
2376 StoreProperties().FindProperty |
|
2377 ( aContactStore.StoreProperties().Uri() ); |
|
2378 } |
|
2379 |
|
2380 |
|
2381 TPtrC storeName; |
|
2382 if ( property ) |
|
2383 { |
|
2384 storeName.Set( property->StoreName() ); |
|
2385 } |
|
2386 |
|
2387 // If this leaves the note is not shown. |
|
2388 // Cannot do anything about that |
|
2389 TRAP_IGNORE( ShowStoreNotAvailableNoteL( storeName ) ); |
|
2390 |
|
2391 // If the address dialog is opened, delete address dialog first, |
|
2392 // then after address dialog exit completely, delete the editor dialog |
|
2393 // via DelayDlgDeleteCallBack; if there isn't the address dialog, |
|
2394 // delete editor dialog directly. |
|
2395 if (iAddressView ) |
|
2396 { |
|
2397 // Create the CIdle object to delete editor dialog later. |
|
2398 if ( !iDelayDelete ) |
|
2399 { |
|
2400 iDelayDelete = CIdle::NewL( CActive::EPriorityStandard ); |
|
2401 } |
|
2402 delete iAddressView; |
|
2403 } |
|
2404 else |
|
2405 { |
|
2406 // At the store unavailable situation, informs editor observer |
|
2407 // that contact editing is aborted without saving the changes. |
|
2408 iContactObserver.ContactEditingAborted(); |
|
2409 delete this; |
|
2410 } |
|
2411 } |
|
2412 } |
|
2413 |
|
2414 // -------------------------------------------------------------------------- |
|
2415 // CPbk2ContactEditorDlgImpl::HandleStoreEventL |
|
2416 // -------------------------------------------------------------------------- |
|
2417 // |
|
2418 void CPbk2ContactEditorDlgImpl::HandleStoreEventL( |
|
2419 MVPbkContactStore& /*aContactStore*/, |
|
2420 TVPbkContactStoreEvent /*aStoreEvent*/ ) |
|
2421 { |
|
2422 // Do nothing |
|
2423 } |
|
2424 |
|
2425 // -------------------------------------------------------------------------- |
|
2426 // CPbk2ContactEditorDlgImpl::LineChangedL |
|
2427 // -------------------------------------------------------------------------- |
|
2428 // |
|
2429 void CPbk2ContactEditorDlgImpl::LineChangedL( TInt /*aControlId*/ ) |
|
2430 { |
|
2431 SetCbaButtonsL(); |
|
2432 } |
|
2433 |
|
2434 // -------------------------------------------------------------------------- |
|
2435 // CPbk2ContactEditorDlgImpl::StoreTitlePaneTextL |
|
2436 // -------------------------------------------------------------------------- |
|
2437 // |
|
2438 inline void CPbk2ContactEditorDlgImpl::StoreTitlePaneTextL() |
|
2439 { |
|
2440 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
2441 if (statusPane && statusPane->PaneCapabilities( |
|
2442 TUid::Uid(EEikStatusPaneUidTitle)).IsPresent()) |
|
2443 { |
|
2444 iTitlePane = static_cast<CAknTitlePane*> |
|
2445 (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle))); |
|
2446 if (iTitlePane->Text()) |
|
2447 { |
|
2448 iStoredTitlePaneText = iTitlePane->Text()->AllocL(); |
|
2449 } |
|
2450 } |
|
2451 } |
|
2452 |
|
2453 // -------------------------------------------------------------------------- |
|
2454 // CPbk2ContactEditorDlgImpl::FocusedControlType |
|
2455 // -------------------------------------------------------------------------- |
|
2456 // |
|
2457 TInt CPbk2ContactEditorDlgImpl::FocusedControlType() |
|
2458 { |
|
2459 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
2460 IdOfFocusControl()); |
|
2461 if (current && current->ContactEditorField()) |
|
2462 { |
|
2463 return current->ContactEditorField()->FieldProperty().CtrlType(); |
|
2464 } |
|
2465 else if (current && current->ContactEditorUIField()) |
|
2466 { |
|
2467 return current->ContactEditorUIField()->UIField()->CtrlType(); |
|
2468 } |
|
2469 |
|
2470 return EPbk2FieldCtrlTypeNone; |
|
2471 } |
|
2472 |
|
2473 // -------------------------------------------------------------------------- |
|
2474 // CPbk2ContactEditorDlgImpl::ConstructContextMenuL |
|
2475 // -------------------------------------------------------------------------- |
|
2476 // |
|
2477 inline void CPbk2ContactEditorDlgImpl::ConstructContextMenuL() |
|
2478 { |
|
2479 CEikMenuBar* newMenuBar = new ( ELeave ) CEikMenuBar(); |
|
2480 CleanupStack::PushL( newMenuBar ); |
|
2481 newMenuBar->ConstructL |
|
2482 ( this, NULL, R_PBK2_CONTACTEDITOR_CONTEXT_MENUBAR ); |
|
2483 iEikonEnv->EikAppUi()->AddToStackL( newMenuBar, ECoeStackPriorityMenu, |
|
2484 ECoeStackFlagRefusesFocus ); |
|
2485 iContextMenuBar = newMenuBar; |
|
2486 CleanupStack::Pop( newMenuBar ); |
|
2487 iContextMenuBar->SetMenuType( CEikMenuBar::EMenuContext ); |
|
2488 } |
|
2489 |
|
2490 // -------------------------------------------------------------------------- |
|
2491 // CPbk2ContactEditorDlgImpl::ConstructNaviPaneL |
|
2492 // -------------------------------------------------------------------------- |
|
2493 // |
|
2494 inline void CPbk2ContactEditorDlgImpl::ConstructNaviPaneL() |
|
2495 { |
|
2496 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
2497 if (statusPane && statusPane->PaneCapabilities(TUid::Uid( |
|
2498 EEikStatusPaneUidNavi)).IsPresent()) |
|
2499 { |
|
2500 // Create a default empty status pane, otherwise sync field will show |
|
2501 iNaviContainer |
|
2502 = static_cast<CAknNavigationControlContainer *> (statusPane->ControlL( |
|
2503 TUid::Uid(EEikStatusPaneUidNavi))); |
|
2504 |
|
2505 iPrevNaviDecorator = iNaviContainer->Top(); |
|
2506 |
|
2507 iNaviContainer->PushDefaultL(ETrue); |
|
2508 } |
|
2509 } |
|
2510 |
|
2511 // -------------------------------------------------------------------------- |
|
2512 // CPbk2ContactEditorDlgImpl::UpdateTitleL |
|
2513 // -------------------------------------------------------------------------- |
|
2514 // |
|
2515 void CPbk2ContactEditorDlgImpl::UpdateTitleL() |
|
2516 { |
|
2517 if (iTitlePane) |
|
2518 { |
|
2519 HBufC* title = NULL; |
|
2520 switch (iParams.iActiveView) |
|
2521 { |
|
2522 case TPbk2ContactEditorParams::EEditorAddressView: |
|
2523 if( !iTitleText ) |
|
2524 { |
|
2525 title = StringLoader::LoadL(R_QTN_PHOB_HEADER_ADDRESS); |
|
2526 } |
|
2527 break; |
|
2528 case TPbk2ContactEditorParams::EEditorAddressHomeView: |
|
2529 if( !iTitleText ) |
|
2530 { |
|
2531 title = StringLoader::LoadL( |
|
2532 R_QTN_PHOB_HEADER_ADDRESS_HOME); |
|
2533 } |
|
2534 break; |
|
2535 case TPbk2ContactEditorParams::EEditorAddressOfficeView: |
|
2536 if( !iTitleText ) |
|
2537 { |
|
2538 title = StringLoader::LoadL( |
|
2539 R_QTN_PHOB_HEADER_ADDRESS_WORK); |
|
2540 } |
|
2541 break; |
|
2542 case TPbk2ContactEditorParams::EEditorView: |
|
2543 { |
|
2544 if ( !iStoreContact ) |
|
2545 { |
|
2546 // Create the contact once |
|
2547 iStoreContact = iContact.StoreContact().ParentStore().CreateNewContactLC(); |
|
2548 CleanupStack::Pop(); |
|
2549 } |
|
2550 |
|
2551 // Remove all fields before re-add |
|
2552 iStoreContact->RemoveAllFields(); |
|
2553 |
|
2554 const TInt fieldCount = iUiFieldArray->Count(); |
|
2555 for (TInt i = 0; i < fieldCount; ++i) |
|
2556 { |
|
2557 CPbk2ContactEditorArrayItem& item = iUiFieldArray->At(i); |
|
2558 MPbk2ContactEditorField* uiField = item.ContactEditorField(); |
|
2559 if (uiField && iNameFormatter->IsTitleField(uiField->ContactField())) |
|
2560 { |
|
2561 HBufC* uiData = uiField->ControlTextL(); |
|
2562 if (uiData) |
|
2563 { |
|
2564 CleanupStack::PushL(uiData); |
|
2565 const MVPbkFieldType& type = |
|
2566 uiField->FieldProperty().FieldType(); |
|
2567 MVPbkStoreContactField* field = iStoreContact->CreateFieldLC(type); |
|
2568 MVPbkContactFieldTextData::Cast( |
|
2569 field->FieldData()).SetTextL(*uiData); |
|
2570 iStoreContact->AddFieldL(field); |
|
2571 CleanupStack::Pop(); // field |
|
2572 CleanupStack::PopAndDestroy(uiData); |
|
2573 } |
|
2574 } |
|
2575 } |
|
2576 if( !iTitleText ) |
|
2577 { |
|
2578 title = iNameFormatter->GetContactTitleOrNullL(iStoreContact->Fields(), |
|
2579 KEditorNameFormatFlags); |
|
2580 } |
|
2581 break; |
|
2582 } |
|
2583 default: |
|
2584 break; |
|
2585 } |
|
2586 |
|
2587 // if custom title text is provided |
|
2588 if( iTitleText ) |
|
2589 { |
|
2590 iTitlePane->SetTextL( iTitleText->Des() ); |
|
2591 } |
|
2592 else |
|
2593 { |
|
2594 if (title) |
|
2595 { |
|
2596 iTitlePane->SetText(title); |
|
2597 } |
|
2598 else |
|
2599 { |
|
2600 iTitlePane->SetTextL(iEditorStrategy.DefaultTitle()); |
|
2601 } |
|
2602 } |
|
2603 } |
|
2604 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
2605 |
|
2606 if (statusPane) |
|
2607 { |
|
2608 iCurrentstatuspane = statusPane->CurrentLayoutResId(); |
|
2609 if( iCurrentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
2610 { |
|
2611 statusPane->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL); |
|
2612 } |
|
2613 } |
|
2614 |
|
2615 } |
|
2616 |
|
2617 // -------------------------------------------------------------------------- |
|
2618 // CPbk2ContactEditorDlgImpl::UpdateTitlePictureL |
|
2619 // -------------------------------------------------------------------------- |
|
2620 // |
|
2621 void CPbk2ContactEditorDlgImpl::UpdateTitlePictureL() |
|
2622 { |
|
2623 if (iTitlePane) |
|
2624 { |
|
2625 // Update picture in title pane |
|
2626 |
|
2627 /* |
|
2628 * Use iAppServices if provided. This is to enable editor use outside from pbk2 context |
|
2629 */ |
|
2630 CEikImage* image = NULL; |
|
2631 if( iAppServices ) |
|
2632 { |
|
2633 image = |
|
2634 Pbk2TitlePanePictureFactory::CreateTitlePanePictureLC |
|
2635 ( &iContact.StoreContact(), |
|
2636 iAppServices->StoreProperties() ); |
|
2637 } |
|
2638 else |
|
2639 { |
|
2640 image = |
|
2641 Pbk2TitlePanePictureFactory::CreateTitlePanePictureLC |
|
2642 ( &iContact.StoreContact(), |
|
2643 Phonebook2::Pbk2AppUi()->ApplicationServices(). |
|
2644 StoreProperties() ); |
|
2645 } |
|
2646 |
|
2647 |
|
2648 // ownership of the picture is transfered to title pane |
|
2649 image->SetPictureOwnedExternally( ETrue ); |
|
2650 iTitlePane->SetSmallPicture( |
|
2651 image->Bitmap(), image->Mask(), image->Bitmap() != NULL ); |
|
2652 // bitmap and mask from image were transfered to title pane, |
|
2653 // so image can be destroyed now |
|
2654 CleanupStack::PopAndDestroy( image ); |
|
2655 } |
|
2656 } |
|
2657 |
|
2658 // -------------------------------------------------------------------------- |
|
2659 // CPbk2ContactEditorDlgImpl::CloseDialog |
|
2660 // -------------------------------------------------------------------------- |
|
2661 // |
|
2662 void CPbk2ContactEditorDlgImpl::CloseDialog( |
|
2663 MVPbkContactObserver::TContactOp aOpCode, TBool aInformObserver) |
|
2664 { |
|
2665 // For knowing if the destructor has been called |
|
2666 TBool destroyed = EFalse; |
|
2667 iDestroyedPtr = &destroyed; |
|
2668 |
|
2669 if (aInformObserver && iParams.iActiveView |
|
2670 == TPbk2ContactEditorParams::EEditorView || iAddressViewStandalone) |
|
2671 { |
|
2672 switch (aOpCode) |
|
2673 { |
|
2674 case MVPbkContactObserver::EContactOperationUnknown: // FALLTHROUGH |
|
2675 case MVPbkContactObserver::EContactCommit: |
|
2676 { |
|
2677 iContactObserver.ContactEditingComplete( |
|
2678 &iContact.StoreContact()); |
|
2679 break; |
|
2680 } |
|
2681 case MVPbkContactObserver::EContactDelete: |
|
2682 { |
|
2683 iContactObserver.ContactEditingDeletedContact( |
|
2684 &iContact.StoreContact()); |
|
2685 break; |
|
2686 } |
|
2687 default: |
|
2688 { |
|
2689 // Either end key was pressed or some uncommon scenario took place, |
|
2690 // abort |
|
2691 iContactObserver.ContactEditingAborted(); |
|
2692 break; |
|
2693 } |
|
2694 }; |
|
2695 } |
|
2696 |
|
2697 // In VOIP/new contacts/exit case, this object will be destructed by |
|
2698 // iContactObserver.ContactEditingComplete() above. |
|
2699 // If this object is destructed, don't excute the following anymore |
|
2700 if ( destroyed ) |
|
2701 { |
|
2702 return; |
|
2703 } |
|
2704 |
|
2705 // Don't save any contact data (already saved) |
|
2706 iExitRecord.Set(EOkToExitWithoutHandlingIt); |
|
2707 iExitRecord.Clear(EExitOrdered); |
|
2708 |
|
2709 // Close dialog using TryExitL and returning ETrue from OkToExit |
|
2710 TInt err = KErrNone; |
|
2711 TRAP( err, TryExitL( EAknSoftkeyBack ) ); |
|
2712 if (err != KErrNone) |
|
2713 { |
|
2714 // If not nicely then use the force. |
|
2715 delete this; |
|
2716 } |
|
2717 } |
|
2718 |
|
2719 // -------------------------------------------------------------------------- |
|
2720 // CPbk2ContactEditorDlgImpl::ExitApplication |
|
2721 // -------------------------------------------------------------------------- |
|
2722 // |
|
2723 void CPbk2ContactEditorDlgImpl::ExitApplication( |
|
2724 MVPbkContactObserver::TContactOp aOpCode, |
|
2725 TInt aCommandId ) |
|
2726 { |
|
2727 if ( iExitRecord.IsSet( EExitOrdered ) && |
|
2728 iExitRecord.IsSet( EExitApproved ) ) |
|
2729 { |
|
2730 |
|
2731 CloseDialog( aOpCode, ETrue ); |
|
2732 |
|
2733 // Dialog is closed so there is nothing to do if |
|
2734 // HandleCommandL leaves. |
|
2735 TRAP_IGNORE(CEikonEnv::Static()->EikAppUi()->HandleCommandL(aCommandId)); |
|
2736 } |
|
2737 } |
|
2738 |
|
2739 // -------------------------------------------------------------------------- |
|
2740 // CPbk2ContactEditorDlgImpl::CmdAddItemL |
|
2741 // -------------------------------------------------------------------------- |
|
2742 // |
|
2743 void CPbk2ContactEditorDlgImpl::CmdAddItemL() |
|
2744 { |
|
2745 AddItemToContactL(KErrNotFound, KNullDesC); |
|
2746 } |
|
2747 |
|
2748 // -------------------------------------------------------------------------- |
|
2749 // CPbk2ContactEditorDlgImpl::CmdDeleteItemL |
|
2750 // -------------------------------------------------------------------------- |
|
2751 // |
|
2752 void CPbk2ContactEditorDlgImpl::CmdDeleteItemL() |
|
2753 { |
|
2754 TPbk2DeleteItemManager deleteItem( iContact, *iUiFieldArray, iAppServices ); |
|
2755 if (deleteItem.DeleteFieldL(IdOfFocusControl())) |
|
2756 { |
|
2757 // Redraw using DrawNow, DrawDeferred does not get the job done |
|
2758 DrawNow(); |
|
2759 } |
|
2760 } |
|
2761 |
|
2762 // -------------------------------------------------------------------------- |
|
2763 // CPbk2ContactEditorDlgImpl::CmdEditItemLabelL |
|
2764 // -------------------------------------------------------------------------- |
|
2765 // |
|
2766 void CPbk2ContactEditorDlgImpl::CmdEditItemLabelL() |
|
2767 { |
|
2768 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
2769 IdOfFocusControl()); |
|
2770 MPbk2ContactEditorField* field = current->ContactEditorField(); |
|
2771 if (field && field->ContactField().SupportsLabel()) |
|
2772 { |
|
2773 // Find out the presentation contact index and then label length |
|
2774 TInt fieldIndx = iContact.PresentationFields().FindFieldIndex( |
|
2775 field->ContactField() ); |
|
2776 TInt maxLabelLength = iContact.PresentationFields(). |
|
2777 FieldAt( fieldIndx ).MaxLabelLength(); |
|
2778 |
|
2779 HBufC* textBuf = HBufC::NewLC(maxLabelLength); |
|
2780 TPtr text = textBuf->Des(); |
|
2781 text.Copy(field->FieldLabel().Left(text.MaxLength())); |
|
2782 HBufC* prompt = StringLoader::LoadLC(R_QTN_FORM_PRMPT_FIELD_LABEL); |
|
2783 |
|
2784 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(text); |
|
2785 dlg->SetMaxLength(maxLabelLength); |
|
2786 if (dlg->ExecuteLD(R_PBK2_EDIT_FIELD_LABEL_QUERY, *prompt)) |
|
2787 { |
|
2788 if (text != field->FieldLabel()) |
|
2789 { |
|
2790 field->SetFieldLabelL(text); |
|
2791 } |
|
2792 } |
|
2793 CleanupStack::PopAndDestroy(2); // prompt, textBuf |
|
2794 } |
|
2795 } |
|
2796 |
|
2797 // -------------------------------------------------------------------------- |
|
2798 // CPbk2ContactEditorDlgImpl::IsUIDataChanged |
|
2799 // -------------------------------------------------------------------------- |
|
2800 // |
|
2801 TBool CPbk2ContactEditorDlgImpl::IsUIDataChanged() |
|
2802 { |
|
2803 TInt count = iUiFieldArray->Count(); |
|
2804 for(TInt idx1 = 0; idx1 < count; idx1++) |
|
2805 { |
|
2806 CPbk2ContactEditorArrayItem& item = iUiFieldArray->At(idx1); |
|
2807 if(item.ContactEditorField() && item.ContactEditorField()->FieldDataChanged()) |
|
2808 { |
|
2809 return ETrue; |
|
2810 } |
|
2811 } |
|
2812 return EFalse; |
|
2813 } |
|
2814 |
|
2815 // -------------------------------------------------------------------------- |
|
2816 // CPbk2ContactEditorDlgImpl::IsAddressValidated |
|
2817 // -------------------------------------------------------------------------- |
|
2818 // |
|
2819 TBool CPbk2ContactEditorDlgImpl::IsAddressValidated(TPbk2FieldGroupId aGroupId) |
|
2820 { |
|
2821 CPbk2PresentationContactFieldCollection& fields = iContact.PresentationFields(); |
|
2822 for(TInt idx = 0; idx < fields.FieldCount(); idx++) |
|
2823 { |
|
2824 MVPbkStoreContactField& field = fields.FieldAt(idx); |
|
2825 TInt countProps = |
|
2826 field.BestMatchingFieldType()->VersitProperties().Count(); |
|
2827 TArray<TVPbkFieldVersitProperty> props = |
|
2828 field.BestMatchingFieldType()->VersitProperties(); |
|
2829 for ( TInt idx2 = 0; idx2 < countProps; idx2++ ) |
|
2830 { |
|
2831 if ( props[ idx2 ].Name() == EVPbkVersitNameGEO && |
|
2832 ( ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) && |
|
2833 aGroupId == EPbk2FieldGroupIdHomeAddress ) || |
|
2834 ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) && |
|
2835 aGroupId == EPbk2FieldGroupIdCompanyAddress ) || |
|
2836 ( !props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) && |
|
2837 !props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) && |
|
2838 aGroupId == EPbk2FieldGroupIdPostalAddress ) ) ) |
|
2839 { |
|
2840 return ETrue; |
|
2841 } |
|
2842 } |
|
2843 } |
|
2844 return EFalse; |
|
2845 } |
|
2846 |
|
2847 // -------------------------------------------------------------------------- |
|
2848 // CPbk2ContactEditorDlgImpl::SetAddressValidationIconsL |
|
2849 // -------------------------------------------------------------------------- |
|
2850 // |
|
2851 void CPbk2ContactEditorDlgImpl::SetAddressValidationIconsL() |
|
2852 { |
|
2853 TInt count = iUiFieldArray->Count(); |
|
2854 for(TInt idx = 0; idx < count; idx++) |
|
2855 { |
|
2856 CPbk2ContactEditorArrayItem& uiItem = iUiFieldArray->At(idx); |
|
2857 MPbk2ContactEditorUIField* uiField = uiItem.ContactEditorUIField(); |
|
2858 if(uiField) |
|
2859 { |
|
2860 switch(uiField->UIField()->CtrlType()) |
|
2861 { |
|
2862 case EPbk2FieldCtrlTypeExtAddressEditor: |
|
2863 case EPbk2FieldCtrlTypeExtAddressHomeEditor: |
|
2864 case EPbk2FieldCtrlTypeExtAddressOfficeEditor: |
|
2865 if(IsAddressValidated(Pbk2AddressTools::MapCtrlTypeToAddress( |
|
2866 uiField->UIField()->CtrlType()))) |
|
2867 { |
|
2868 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map); |
|
2869 uiField->LoadBitmapToFieldL(iconID); |
|
2870 } |
|
2871 else |
|
2872 { |
|
2873 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm); |
|
2874 uiField->LoadBitmapToFieldL(iconID); |
|
2875 } |
|
2876 break; |
|
2877 case EPbk2FieldCtrlTypeExtAssignFromMapsEditor: |
|
2878 if(IsAddressValidated( Pbk2AddressTools::MapViewTypeToAddress(iParams.iActiveView))) |
|
2879 { |
|
2880 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map); |
|
2881 uiField->LoadBitmapToFieldL(iconID); |
|
2882 } |
|
2883 else |
|
2884 { |
|
2885 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm); |
|
2886 uiField->LoadBitmapToFieldL(iconID); |
|
2887 } |
|
2888 break; |
|
2889 default: |
|
2890 return; |
|
2891 } |
|
2892 } |
|
2893 } |
|
2894 } |
|
2895 |
|
2896 // -------------------------------------------------------------------------- |
|
2897 // CPbk2ContactEditorDlgImpl::DeleteActiveAddressGeoCoords |
|
2898 // -------------------------------------------------------------------------- |
|
2899 // |
|
2900 void CPbk2ContactEditorDlgImpl::DeleteActiveAddressGeoCoords() |
|
2901 { |
|
2902 CPbk2PresentationContactFieldCollection& fields = iContact.PresentationFields(); |
|
2903 for(TInt idx = 0; idx < fields.FieldCount(); idx++) |
|
2904 { |
|
2905 MVPbkStoreContactField& field = fields.FieldAt(idx); |
|
2906 TInt countProps = |
|
2907 field.BestMatchingFieldType()->VersitProperties().Count(); |
|
2908 TArray<TVPbkFieldVersitProperty> props = |
|
2909 field.BestMatchingFieldType()->VersitProperties(); |
|
2910 for ( TInt idx2 = 0; idx2 < countProps; idx2++ ) |
|
2911 { |
|
2912 if ( props[ idx2 ].Name() == EVPbkVersitNameGEO && |
|
2913 ( ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) && |
|
2914 iParams.iActiveView == |
|
2915 TPbk2ContactEditorParams::EEditorAddressHomeView ) || |
|
2916 ( props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) && |
|
2917 iParams.iActiveView == |
|
2918 TPbk2ContactEditorParams::EEditorAddressOfficeView ) || |
|
2919 ( !props[ idx2 ].Parameters().Contains( EVPbkVersitParamHOME ) && |
|
2920 !props[ idx2 ].Parameters().Contains( EVPbkVersitParamWORK ) && |
|
2921 iParams.iActiveView == |
|
2922 TPbk2ContactEditorParams::EEditorAddressView ) ) ) |
|
2923 { |
|
2924 iContact.RemoveField(idx); |
|
2925 return; |
|
2926 } |
|
2927 } |
|
2928 } |
|
2929 } |
|
2930 |
|
2931 // -------------------------------------------------------------------------- |
|
2932 // CPbk2ContactEditorDlgImpl::CmdDoneL |
|
2933 // -------------------------------------------------------------------------- |
|
2934 // |
|
2935 void CPbk2ContactEditorDlgImpl::CmdDoneL( |
|
2936 MPbk2ContactEditorEventObserver::TParams& aParams) |
|
2937 { |
|
2938 // The event that "end" key is pressed is informed into |
|
2939 // CPsu2ContactEditorExtension to do some process |
|
2940 if( iEndKeyWasPressed ) |
|
2941 { |
|
2942 iEditorExtension->ProcessCommandL( EAknCmdHideInBackground ); |
|
2943 } |
|
2944 |
|
2945 // Saving/deleting is asynchronic so it is never to ok exit rightaway |
|
2946 // No need to save fields when all field are empty. |
|
2947 // To estimate dialog is a contact editor or a address dialog. |
|
2948 // If it is address dialog, then save all field. |
|
2949 if (iUseState != EUseOperatingContact) |
|
2950 { |
|
2951 if ( !iUiFieldArray->AreAllUiFieldsEmpty() |
|
2952 || iParams.iActiveView == TPbk2ContactEditorParams::EEditorAddressView |
|
2953 || iParams.iActiveView == TPbk2ContactEditorParams::EEditorAddressHomeView |
|
2954 || iParams.iActiveView == TPbk2ContactEditorParams::EEditorAddressOfficeView ) |
|
2955 { |
|
2956 iUiFieldArray->SaveFieldsL(); |
|
2957 } |
|
2958 |
|
2959 if(iParams.iActiveView != TPbk2ContactEditorParams::EEditorView && IsUIDataChanged() && |
|
2960 IsAddressValidated(Pbk2AddressTools::MapViewTypeToAddress(iParams.iActiveView))) |
|
2961 { |
|
2962 if(iUiFieldArray->AreAllUiFieldsEmpty()) |
|
2963 { |
|
2964 DeleteActiveAddressGeoCoords(); |
|
2965 } |
|
2966 else |
|
2967 { |
|
2968 HBufC* prompt = StringLoader::LoadLC(R_QTN_PHOB_CONFIRM_KEEP_COORDINATES); |
|
2969 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
2970 if(!dlg->ExecuteLD(R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt)) |
|
2971 { |
|
2972 DeleteActiveAddressGeoCoords(); |
|
2973 } |
|
2974 CleanupStack::PopAndDestroy( prompt ); |
|
2975 } |
|
2976 } |
|
2977 |
|
2978 TInt error(KErrNone); |
|
2979 if (iParams.iActiveView == TPbk2ContactEditorParams::EEditorView || |
|
2980 iAddressViewStandalone) |
|
2981 { |
|
2982 // Estimate all field are empty by UI field. |
|
2983 if (( AreAllControlsEmpty() && !iAddressViewStandalone )|| |
|
2984 (iAddressViewStandalone && AreAllFieldsEmpty())) |
|
2985 { |
|
2986 if (iEditorExtension->OkToDeleteContactL(aParams)) |
|
2987 { |
|
2988 // iUseState must be set before DeleteContactL() because |
|
2989 // during deletion ForceExit() might be entered and needs to |
|
2990 // check the state to make sure operation finished. |
|
2991 iUseState = EUseOperatingContact; |
|
2992 |
|
2993 // If Endkey is pressed, no need of query dialog in DeleteContactL() |
|
2994 if ( iEndKeyWasPressed ) |
|
2995 { |
|
2996 aParams.iCommandId = EEikBidCancel; |
|
2997 } |
|
2998 |
|
2999 TRAP( error, iEditorStrategy.DeleteContactL( *this, aParams ) ); |
|
3000 |
|
3001 DecideToLeaveL( error ); |
|
3002 } |
|
3003 } |
|
3004 else |
|
3005 { |
|
3006 iParams.iFocusedIndex = FocusedFieldIndexL(); |
|
3007 if (iEditorExtension->OkToSaveContactL(aParams)) |
|
3008 { |
|
3009 iUseState = EUseOperatingContact; |
|
3010 |
|
3011 TRAP( error, iEditorStrategy.SaveContactL( *this, aParams ) ); |
|
3012 |
|
3013 // Close the dialog if save contact fail caused by the |
|
3014 // memory full |
|
3015 if ( error == KErrDiskFull ) |
|
3016 { |
|
3017 CloseDialog( MVPbkContactObserver::EContactCommit, ETrue ); |
|
3018 } |
|
3019 |
|
3020 DecideToLeaveL(error); |
|
3021 } |
|
3022 else |
|
3023 { |
|
3024 if ( iEndKeyWasPressed ) |
|
3025 { |
|
3026 CloseDialog(); |
|
3027 } |
|
3028 else |
|
3029 { |
|
3030 iExitRecord.Clear( EExitOrdered ); |
|
3031 } |
|
3032 } |
|
3033 } |
|
3034 } |
|
3035 else |
|
3036 { |
|
3037 CloseWithoutSaving(EFalse); |
|
3038 } |
|
3039 } |
|
3040 } |
|
3041 |
|
3042 // -------------------------------------------------------------------------- |
|
3043 // CPbk2ContactEditorDlgImpl::FocusedFieldIndexL |
|
3044 // -------------------------------------------------------------------------- |
|
3045 // |
|
3046 TInt CPbk2ContactEditorDlgImpl::FocusedFieldIndexL() |
|
3047 { |
|
3048 if( iAddressViewStandalone ) |
|
3049 { |
|
3050 return KErrNotFound; |
|
3051 } |
|
3052 |
|
3053 const TInt idOfFocusedControl(IdOfFocusControl()); |
|
3054 TInt fieldIndex(0); |
|
3055 const TInt count(iUiFieldArray->Count()); |
|
3056 |
|
3057 for (TInt i(0); i < count; ++i) |
|
3058 { |
|
3059 CPbk2ContactEditorArrayItem& uiField = iUiFieldArray->At(i); |
|
3060 |
|
3061 if(uiField.ControlId() == idOfFocusedControl) |
|
3062 { |
|
3063 if( IsControlEmptyL(i) ) |
|
3064 { |
|
3065 break; |
|
3066 } |
|
3067 return fieldIndex; |
|
3068 } |
|
3069 else |
|
3070 { |
|
3071 if( !IsControlEmptyL(i) ) |
|
3072 { |
|
3073 fieldIndex++; |
|
3074 } |
|
3075 } |
|
3076 } |
|
3077 return KErrNotFound; |
|
3078 } |
|
3079 |
|
3080 // -------------------------------------------------------------------------- |
|
3081 // CPbk2ContactEditorDlgImpl::SetCbaButtonsL |
|
3082 // -------------------------------------------------------------------------- |
|
3083 // |
|
3084 void CPbk2ContactEditorDlgImpl::SetCbaButtonsL() |
|
3085 { |
|
3086 if ( AknLayoutUtils::MSKEnabled() ) |
|
3087 { |
|
3088 TBool hideMsk(EFalse); |
|
3089 |
|
3090 if ( !iRelocator.IsPhoneMemoryInConfigurationL() ) |
|
3091 { |
|
3092 if ( EmptyContextMenuL() ) |
|
3093 { |
|
3094 hideMsk = ETrue; |
|
3095 } |
|
3096 } |
|
3097 |
|
3098 ButtonGroupContainer().DimCommandByPosition( |
|
3099 CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
3100 hideMsk ); |
|
3101 |
|
3102 ButtonGroupContainer().MakeCommandVisibleByPosition( |
|
3103 CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
3104 !hideMsk ); |
|
3105 |
|
3106 ButtonGroupContainer().DrawDeferred(); |
|
3107 } |
|
3108 } |
|
3109 |
|
3110 // -------------------------------------------------------------------------- |
|
3111 // CPbk2ContactEditorDlgImpl::EmptyContextMenuL |
|
3112 // -------------------------------------------------------------------------- |
|
3113 // |
|
3114 TBool CPbk2ContactEditorDlgImpl::EmptyContextMenuL() |
|
3115 { |
|
3116 TBool empty(EFalse); |
|
3117 |
|
3118 CPbk2ContactEditorArrayItem* current = iUiFieldArray->Find( |
|
3119 IdOfFocusControl()); |
|
3120 |
|
3121 if( current ) |
|
3122 { |
|
3123 MPbk2ContactEditorField* currentField = current->ContactEditorField(); |
|
3124 |
|
3125 CArrayPtr<const MPbk2FieldProperty>* availableFields = |
|
3126 iContact.AvailableFieldsToAddL(); |
|
3127 |
|
3128 if ( ( !currentField || |
|
3129 ( currentField->FieldProperty().Flags() |
|
3130 & KPbk2FieldFlagCanNotBeRemoved ) ) && |
|
3131 ( !currentField || |
|
3132 !currentField->ContactField().SupportsLabel() ) && |
|
3133 ( !availableFields || availableFields->Count() == 0 ) ) |
|
3134 { |
|
3135 empty = ETrue; |
|
3136 } |
|
3137 delete availableFields; |
|
3138 } |
|
3139 else |
|
3140 { |
|
3141 empty = EFalse; |
|
3142 } |
|
3143 |
|
3144 return empty; |
|
3145 } |
|
3146 |
|
3147 // -------------------------------------------------------------------------- |
|
3148 // CPbk2ContactEditorDlgImpl::OkToExitApplicationL |
|
3149 // -------------------------------------------------------------------------- |
|
3150 // |
|
3151 TBool CPbk2ContactEditorDlgImpl::OkToExitApplicationL |
|
3152 ( TInt aCommandId ) |
|
3153 { |
|
3154 TBool okToExit = ETrue; |
|
3155 |
|
3156 // If exit callback returned EFalse, the exit is cancelled |
|
3157 if ( iParams.iExitCallback && |
|
3158 !iParams.iExitCallback->OkToExitL( aCommandId ) ) |
|
3159 { |
|
3160 okToExit = EFalse; |
|
3161 } |
|
3162 |
|
3163 if ( !okToExit ) |
|
3164 { |
|
3165 iExitRecord.Clear( EExitApproved ); |
|
3166 } |
|
3167 |
|
3168 return okToExit; |
|
3169 } |
|
3170 |
|
3171 // -------------------------------------------------------------------------- |
|
3172 // CPbk2ContactEditorDlgImpl::SetCbaCommandSetL |
|
3173 // -------------------------------------------------------------------------- |
|
3174 // |
|
3175 void CPbk2ContactEditorDlgImpl::SetCbaCommandSetL( TInt aResourceId ) |
|
3176 { |
|
3177 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
3178 cba.SetCommandSetL( aResourceId ); |
|
3179 iCbaCommandSet = aResourceId; |
|
3180 cba.DrawDeferred(); |
|
3181 } |
|
3182 |
|
3183 // -------------------------------------------------------------------------- |
|
3184 // CPbk2ContactEditorDlgImpl::UpdateCbasL |
|
3185 // -------------------------------------------------------------------------- |
|
3186 // |
|
3187 void CPbk2ContactEditorDlgImpl::UpdateCbasL(CPbk2ContactEditorArrayItem* aItemToUpdate) |
|
3188 { |
|
3189 CPbk2ContactEditorArrayItem* current = aItemToUpdate; |
|
3190 if(!current) |
|
3191 { |
|
3192 current = iUiFieldArray->Find(IdOfFocusControl()); |
|
3193 } |
|
3194 |
|
3195 MPbk2ContactEditorField* currentField = current->ContactEditorField(); |
|
3196 MPbk2ContactEditorUIField* currentUIField = current->ContactEditorUIField(); |
|
3197 if ( currentField ) |
|
3198 { |
|
3199 TPbk2FieldCtrlType type = |
|
3200 currentField->FieldProperty().CtrlType(); |
|
3201 if (type == EPbk2FieldCtrlTypeImageEditor ) |
|
3202 { |
|
3203 TInt id = currentField->ControlId(); |
|
3204 TAny* ext = currentField->ContactEditorFieldExtension(TUid::Uid(NULL)); |
|
3205 CPbk2ContactEditorImageField* fld = |
|
3206 static_cast<CPbk2ContactEditorImageField*>(ext); |
|
3207 if(fld->TextState() == CPbk2ContactEditorImageField::ENoData) |
|
3208 { |
|
3209 if ( iCbaCommandSet != R_PBK2_SOFTKEYS_OPTIONS_DONE_ADD ) |
|
3210 { |
|
3211 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_DONE_ADD ); |
|
3212 } |
|
3213 } |
|
3214 else |
|
3215 { |
|
3216 if ( iCbaCommandSet != R_PBK2_SOFTKEYS_OPTIONS_DONE_CHANGE ) |
|
3217 { |
|
3218 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_DONE_CHANGE ); |
|
3219 } |
|
3220 } |
|
3221 } |
|
3222 else if ( type == EPbk2FieldCtrlTypeChoiceItems || |
|
3223 type == EPbk2FieldCtrlTypeRingtoneEditor ) |
|
3224 { |
|
3225 if ( iCbaCommandSet != R_PBK2_SOFTKEYS_OPTIONS_DONE_CHANGE ) |
|
3226 { |
|
3227 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_DONE_CHANGE ); |
|
3228 } |
|
3229 } |
|
3230 else |
|
3231 { |
|
3232 #ifndef ECE_DISABLE_CONTEXT_MENU |
|
3233 if ( iCbaCommandSet != R_PBK2_SOFTKEYS_OPTIONS_DONE_CONTEXT ) |
|
3234 { |
|
3235 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_DONE_CONTEXT ); |
|
3236 } |
|
3237 #else |
|
3238 if ( iCbaCommandSet != R_PBK2_SOFTKEYS_OPTIONS_DONE_EMPTY ) |
|
3239 { |
|
3240 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_DONE_EMPTY ); |
|
3241 } |
|
3242 #endif |
|
3243 } |
|
3244 } |
|
3245 |
|
3246 if(currentUIField) |
|
3247 { |
|
3248 TPbk2FieldCtrlTypeExt type = |
|
3249 currentUIField->UIField()->CtrlType(); |
|
3250 switch(type) |
|
3251 { |
|
3252 case EPbk2FieldCtrlTypeExtAddressEditor: |
|
3253 case EPbk2FieldCtrlTypeExtAddressHomeEditor: |
|
3254 case EPbk2FieldCtrlTypeExtAddressOfficeEditor: |
|
3255 if ( iCbaCommandSet != R_PBK2_SOFTKEYS_OPTIONS_DONE_CHANGE ) |
|
3256 { |
|
3257 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_DONE_CHANGE ); |
|
3258 } |
|
3259 break; |
|
3260 case EPbk2FieldCtrlTypeExtAssignFromMapsEditor: |
|
3261 if ( iCbaCommandSet != R_PBK2_SOFTKEYS_OPTIONS_DONE_SELECT ) |
|
3262 { |
|
3263 SetCbaCommandSetL( R_PBK2_SOFTKEYS_OPTIONS_DONE_SELECT ); |
|
3264 } |
|
3265 break; |
|
3266 } |
|
3267 } |
|
3268 |
|
3269 // Offer button group container to extensions. |
|
3270 // This is needed here because previous settings might override extension's |
|
3271 // buttons. |
|
3272 iEditorExtension->ModifyButtonGroupContainerL(ButtonGroupContainer()); |
|
3273 } |
|
3274 |
|
3275 // -------------------------------------------------------------------------- |
|
3276 // CPbk2ContactEditorDlgImpl::ImageLoadingComplete |
|
3277 // -------------------------------------------------------------------------- |
|
3278 // |
|
3279 TInt CPbk2ContactEditorDlgImpl::ImageLoadingComplete() |
|
3280 { |
|
3281 TRAPD(err,DoImageLoadingCompleteL()) |
|
3282 return err; |
|
3283 } |
|
3284 |
|
3285 // -------------------------------------------------------------------------- |
|
3286 // CPbk2ContactEditorDlgImpl::DoImageLoadingCompleteL |
|
3287 // -------------------------------------------------------------------------- |
|
3288 // |
|
3289 void CPbk2ContactEditorDlgImpl::DoImageLoadingCompleteL() |
|
3290 { |
|
3291 CPbk2ContactEditorArrayItem* currentField = |
|
3292 iUiFieldArray->Find(IdOfFocusControl()); |
|
3293 if (currentField && currentField->ContactEditorField()) |
|
3294 { |
|
3295 TInt id = currentField->ContactEditorField()->ControlId(); |
|
3296 TAny* ext = currentField->ContactEditorField()->ContactEditorFieldExtension(TUid::Uid(NULL)); |
|
3297 if( id == EPbk2EditorLineImage ) |
|
3298 { |
|
3299 CPbk2ContactEditorImageField* fld = |
|
3300 static_cast<CPbk2ContactEditorImageField*>(ext); |
|
3301 fld->SetTextL(); |
|
3302 } |
|
3303 } |
|
3304 } |
|
3305 |
|
3306 // -------------------------------------------------------------------------- |
|
3307 // CPbk2ContactEditorDlgImpl::ImageLoadingFailed |
|
3308 // -------------------------------------------------------------------------- |
|
3309 // |
|
3310 TInt CPbk2ContactEditorDlgImpl::ImageLoadingFailed() |
|
3311 { |
|
3312 return KErrNone; |
|
3313 } |
|
3314 // -------------------------------------------------------------------------- |
|
3315 // CPbk2ContactEditorDlgImpl::ImageLoadingCancelled |
|
3316 // -------------------------------------------------------------------------- |
|
3317 // |
|
3318 TInt CPbk2ContactEditorDlgImpl::ImageLoadingCancelled() |
|
3319 { |
|
3320 return KErrNone; |
|
3321 } |
|
3322 |
|
3323 // -------------------------------------------------------------------------- |
|
3324 // CPbk2ContactEditorDlgImpl::WaitFinish |
|
3325 // -------------------------------------------------------------------------- |
|
3326 // |
|
3327 void CPbk2ContactEditorDlgImpl::WaitFinishL() |
|
3328 { |
|
3329 if ( !iWaitFinish && *iSelfPtr ) |
|
3330 { |
|
3331 iInputBlock = CAknInputBlock::NewLC(); |
|
3332 CleanupStack::Pop( iInputBlock ); |
|
3333 |
|
3334 iWaitFinish = new (ELeave) CActiveSchedulerWait(); |
|
3335 iWaitFinish->Start(); |
|
3336 } |
|
3337 } |
|
3338 |
|
3339 // -------------------------------------------------------------------------- |
|
3340 // CPbk2ContactEditorDlgImpl::IsUnicodeL |
|
3341 // -------------------------------------------------------------------------- |
|
3342 // |
|
3343 TBool CPbk2ContactEditorDlgImpl::IsUnicodeL( const TDesC& aText ) |
|
3344 { |
|
3345 if ( !iConverter ) |
|
3346 { |
|
3347 iConverter = CCnvCharacterSetConverter::NewLC(); |
|
3348 CleanupStack::Pop(); |
|
3349 RFs& fs = Phonebook2::Pbk2AppUi()-> |
|
3350 ApplicationServices().ContactManager().FsSession(); |
|
3351 iConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierSms7Bit, fs ); |
|
3352 } |
|
3353 |
|
3354 TBool isUnicode( EFalse ); |
|
3355 TInt unconvertedCount(0); |
|
3356 HBufC8* convertedText = HBufC8::NewLC( aText.Length()*KTwoBytes ); |
|
3357 TPtr8 convertedTextPtr = convertedText->Des(); |
|
3358 |
|
3359 iConverter->ConvertFromUnicode( convertedTextPtr, aText, unconvertedCount ); |
|
3360 |
|
3361 // If any characters were not converted or if the converted text is longer |
|
3362 // than the original the text must be unicode |
|
3363 if( unconvertedCount > 0 || |
|
3364 aText.Length() < convertedText->Length() ) |
|
3365 { |
|
3366 isUnicode = ETrue; |
|
3367 } |
|
3368 |
|
3369 CleanupStack::PopAndDestroy( convertedText ); |
|
3370 return isUnicode; |
|
3371 } |
|
3372 |
|
3373 // -------------------------------------------------------------------------- |
|
3374 // CPbk2ContactEditorDlgImpl::IsCheckPointEvent |
|
3375 // -------------------------------------------------------------------------- |
|
3376 // |
|
3377 TBool CPbk2ContactEditorDlgImpl::IsCheckPointEvent( |
|
3378 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
3379 { |
|
3380 TBool check = EFalse; |
|
3381 if ( EEventKeyDown == aType ) |
|
3382 { |
|
3383 // Don't handle 'EStdKeyBackspace', 'EStdKeyHash' and those between |
|
3384 // 'EStdKeyPrintScreen' and 'EStdKeyScrollLock'. |
|
3385 // If the definition of standard scancode is changed, the scope here needs to |
|
3386 // be examined again. |
|
3387 if ( ( EStdKeyPrintScreen > aKeyEvent.iScanCode || EStdKeyScrollLock < aKeyEvent.iScanCode ) && |
|
3388 EStdKeyBackspace != aKeyEvent.iScanCode && |
|
3389 EStdKeyHash != aKeyEvent.iScanCode ) |
|
3390 { |
|
3391 check = ETrue; |
|
3392 } |
|
3393 } |
|
3394 else if ( EEventKey == aType && EStdKeyNull == aKeyEvent.iScanCode ) |
|
3395 { |
|
3396 check = ETrue; |
|
3397 } |
|
3398 |
|
3399 return check; |
|
3400 } |
|
3401 |
|
3402 // -------------------------------------------------------------------------- |
|
3403 // CPbk2ContactEditorDlgImpl::CheckCurrentFieldTextL |
|
3404 // -------------------------------------------------------------------------- |
|
3405 // |
|
3406 void CPbk2ContactEditorDlgImpl::CheckCurrentFieldTextL( |
|
3407 CPbk2ContactEditorArrayItem* aCurrentField, |
|
3408 const TKeyEvent& aKeyEvent, |
|
3409 TEventCode aType ) |
|
3410 { |
|
3411 MPbk2ContactEditorField* editorField = aCurrentField->ContactEditorField(); |
|
3412 if ( editorField ) |
|
3413 { |
|
3414 MVPbkStoreContactField& contactField = editorField->ContactField(); |
|
3415 TVPbkFieldStorageType dataType = contactField.FieldData().DataType(); |
|
3416 |
|
3417 if ( EVPbkFieldStorageTypeText == dataType ) |
|
3418 { |
|
3419 const MVPbkContactFieldTextData& textData = |
|
3420 MVPbkContactFieldTextData::Cast(contactField.FieldData()); |
|
3421 TInt maxSize = textData.MaxLength(); |
|
3422 |
|
3423 if ( KVPbkUnlimitedFieldLength != maxSize && |
|
3424 IsCheckPointEvent( aKeyEvent, aType ) ) |
|
3425 { |
|
3426 CEikEdwin* ctrl = editorField->Control(); |
|
3427 HBufC* textBuf = ctrl->GetTextInHBufL(); |
|
3428 |
|
3429 if ( textBuf ) |
|
3430 { |
|
3431 CleanupStack::PushL( textBuf ); |
|
3432 TInt maxLen = maxSize; |
|
3433 if ( IsUnicodeL( *textBuf ) ) |
|
3434 { |
|
3435 maxLen = maxSize / KTwoBytes - KExtraByte; |
|
3436 } |
|
3437 if ( ctrl->MaxLength() != maxLen && textBuf->Length() <= maxLen ) |
|
3438 { |
|
3439 ctrl->SetMaxLength( maxLen ); |
|
3440 } |
|
3441 CleanupStack::PopAndDestroy( textBuf ); |
|
3442 } |
|
3443 } |
|
3444 } |
|
3445 } |
|
3446 } |
|
3447 |
|
3448 // -------------------------------------------------------------------------- |
|
3449 // CPbk2ContactEditorDlgImpl::HandleLosingForeground |
|
3450 // -------------------------------------------------------------------------- |
|
3451 // |
|
3452 void CPbk2ContactEditorDlgImpl::HandleLosingForeground() |
|
3453 { |
|
3454 //Fix for ou1cimx1#308012 |
|
3455 iEditorStrategy.StopQuery(); |
|
3456 } |
|
3457 |
|
3458 // -------------------------------------------------------------------------- |
|
3459 // CPbk2ContactEditorDlgImpl::HandleGainingForeground |
|
3460 // -------------------------------------------------------------------------- |
|
3461 // |
|
3462 void CPbk2ContactEditorDlgImpl::HandleGainingForeground() |
|
3463 { |
|
3464 /* |
|
3465 * iAppServices is provided to enable editor use outside from pbk2 context |
|
3466 * no need to disable startup monitor in that case |
|
3467 */ |
|
3468 if( !iAppServices ) |
|
3469 { |
|
3470 MPbk2AppUi* pbk2AppUI = NULL; |
|
3471 pbk2AppUI = Phonebook2::Pbk2AppUi(); |
|
3472 |
|
3473 if ( pbk2AppUI && pbk2AppUI->Pbk2StartupMonitor() ) |
|
3474 { |
|
3475 TAny* extension = pbk2AppUI->Pbk2StartupMonitor() |
|
3476 ->StartupMonitorExtension( KPbk2StartupMonitorExtensionUid ); |
|
3477 |
|
3478 if( extension ) |
|
3479 { |
|
3480 MPbk2StartupMonitorExtension* startupMonitorExtension = |
|
3481 static_cast<MPbk2StartupMonitorExtension*>( extension ); |
|
3482 |
|
3483 if( startupMonitorExtension ) |
|
3484 { |
|
3485 startupMonitorExtension->DisableMonitoring(); |
|
3486 } |
|
3487 } |
|
3488 } |
|
3489 } |
|
3490 } |
|
3491 |
|
3492 // -------------------------------------------------------------------------- |
|
3493 // CPbk2ContactEditorDlgImpl::RestorePrevNaviDecoratorL |
|
3494 // -------------------------------------------------------------------------- |
|
3495 // |
|
3496 void CPbk2ContactEditorDlgImpl::RestorePrevNaviDecoratorL() |
|
3497 { |
|
3498 if ( iNaviContainer && iPrevNaviDecorator ) |
|
3499 { |
|
3500 iNaviContainer->PushL(*iPrevNaviDecorator); |
|
3501 } |
|
3502 } |
|
3503 |
|
3504 // -------------------------------------------------------------------------- |
|
3505 // CPbk2ContactEditorDlgImpl::RestoreStatusPaneL |
|
3506 // -------------------------------------------------------------------------- |
|
3507 // |
|
3508 void CPbk2ContactEditorDlgImpl::RestoreStatusPaneL() |
|
3509 { |
|
3510 //Restore StatusPane & Title |
|
3511 if ( iCurrentstatuspane ) |
|
3512 { |
|
3513 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
3514 |
|
3515 if (statusPane) |
|
3516 { |
|
3517 statusPane->SwitchLayoutL( iCurrentstatuspane ); |
|
3518 } |
|
3519 } |
|
3520 // Restore the titlepane text |
|
3521 if (iTitlePane && iStoredTitlePaneText) |
|
3522 { |
|
3523 iTitlePane->SetTextL(*iStoredTitlePaneText); |
|
3524 } |
|
3525 |
|
3526 // Reset title pane picture |
|
3527 if( iTitlePane ) |
|
3528 { |
|
3529 iTitlePane->SetSmallPicture( NULL, NULL, EFalse ); |
|
3530 } |
|
3531 } |
|
3532 |
|
3533 |
|
3534 // End of File |