20
|
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: Phonebook2 contact editor dialog.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <CPbk2ContactEditorDlg.h>
|
|
21 |
|
|
22 |
// Phonebook 2
|
|
23 |
#include "CPbk2ContactEditorDlgImpl.h"
|
|
24 |
#include "Pbk2ContactEditorStrategyFactory.h"
|
|
25 |
#include "MPbk2ContactEditorStrategy.h"
|
|
26 |
#include <CPbk2ContactRelocator.h>
|
|
27 |
#include <CPbk2FieldPropertyArray.h>
|
|
28 |
#include <MPbk2ContactEditorEventObserver.h>
|
|
29 |
#include <MPbk2EditedContactObserver.h>
|
|
30 |
#include <CPbk2PresentationContact.h>
|
|
31 |
#include <CPbk2StoreSpecificFieldPropertyArray.h>
|
|
32 |
#include <CPbk2PresentationContactFieldCollection.h>
|
|
33 |
#include <MPbk2FieldProperty.h>
|
|
34 |
#include <MPbk2ApplicationServices.h>
|
|
35 |
#include <MPbk2AppUi.h>
|
|
36 |
|
|
37 |
// Virtual Phonebook
|
|
38 |
#include <CVPbkContactManager.h>
|
|
39 |
#include <MVPbkStoreContact.h>
|
|
40 |
#include <MVPbkContactStore.h>
|
|
41 |
#include <MVPbkContactFieldTextData.h>
|
|
42 |
#include <MVPbkContactStoreProperties.h>
|
|
43 |
#include <MVPbkFieldType.h>
|
|
44 |
#include <barsread.h>
|
|
45 |
|
|
46 |
|
|
47 |
// System includes
|
|
48 |
#include <coemain.h>
|
|
49 |
|
|
50 |
/// Unnamed namespace for local definitions
|
|
51 |
namespace {
|
|
52 |
|
|
53 |
#ifdef _DEBUG
|
|
54 |
enum TPanicCode
|
|
55 |
{
|
|
56 |
ENullPointer,
|
|
57 |
EPanicPreCond_ResetWhenDestroyed
|
|
58 |
};
|
|
59 |
|
|
60 |
void Panic(TPanicCode aReason)
|
|
61 |
{
|
|
62 |
_LIT(KPanicText, "CPbk2ContactEditorDlg");
|
|
63 |
User::Panic(KPanicText,aReason);
|
|
64 |
}
|
|
65 |
#endif // _DEBUG
|
|
66 |
|
|
67 |
} /// namespace
|
|
68 |
|
|
69 |
// --------------------------------------------------------------------------
|
|
70 |
// CPbk2ContactEditorDlg::CPbk2ContactEditorDlg
|
|
71 |
// --------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CPbk2ContactEditorDlg::CPbk2ContactEditorDlg
|
|
74 |
( TPbk2ContactEditorParams& aParams,
|
|
75 |
MPbk2EditedContactObserver& aContactObserver,
|
|
76 |
MPbk2ApplicationServices* aAppServices,
|
|
77 |
TInt aEditorFieldsId ) :
|
|
78 |
iParams( aParams ),
|
|
79 |
iContactObserver( aContactObserver ),
|
|
80 |
iAddItemFieldTypeResourceId( KErrNotFound ),
|
|
81 |
iAppServices( aAppServices ),
|
|
82 |
iEditorFieldsId( aEditorFieldsId )
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
// --------------------------------------------------------------------------
|
|
87 |
// CPbk2ContactEditorDlg::~CPbk2ContactEditorDlg
|
|
88 |
// --------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
CPbk2ContactEditorDlg::~CPbk2ContactEditorDlg()
|
|
91 |
{
|
|
92 |
ForceExit();
|
|
93 |
|
|
94 |
delete iTitleText;
|
|
95 |
if ( iSelfPtr )
|
|
96 |
{
|
|
97 |
*iSelfPtr = NULL;
|
|
98 |
}
|
|
99 |
if ( iDestroyedPtr )
|
|
100 |
{
|
|
101 |
*iDestroyedPtr = ETrue;
|
|
102 |
}
|
|
103 |
delete iContact;
|
|
104 |
delete iSpecificFieldProperties;
|
|
105 |
delete iFieldProperties;
|
|
106 |
delete iEditorStrategy;
|
|
107 |
delete iContactRelocator;
|
|
108 |
delete iStoreContact;
|
|
109 |
delete iAddItemFieldTypeXspName;
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
// --------------------------------------------------------------------------
|
|
114 |
// CPbk2ContactEditorDlg::NewL
|
|
115 |
// --------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
EXPORT_C CPbk2ContactEditorDlg* CPbk2ContactEditorDlg::NewL(
|
|
118 |
TPbk2ContactEditorParams& aParams, MVPbkStoreContact* aContact,
|
|
119 |
MPbk2EditedContactObserver& aContactObserver)
|
|
120 |
{
|
|
121 |
CPbk2ContactEditorDlg* self =
|
|
122 |
new(ELeave) CPbk2ContactEditorDlg(aParams, aContactObserver);
|
|
123 |
CleanupStack::PushL(self);
|
|
124 |
self->ConstructL( aContact );
|
|
125 |
CleanupStack::Pop(self);
|
|
126 |
return self;
|
|
127 |
}
|
|
128 |
|
|
129 |
|
|
130 |
// --------------------------------------------------------------------------
|
|
131 |
// CPbk2ContactEditorDlg::NewL
|
|
132 |
// --------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
EXPORT_C CPbk2ContactEditorDlg* CPbk2ContactEditorDlg::NewL(
|
|
135 |
TPbk2ContactEditorParams& aParams,
|
|
136 |
MVPbkStoreContact* aContact,
|
|
137 |
MPbk2EditedContactObserver& aContactObserver,
|
|
138 |
MPbk2ApplicationServices* aAppServices,
|
|
139 |
HBufC* aTitleText,
|
|
140 |
TInt aEditorFieldsId )
|
|
141 |
{
|
|
142 |
CPbk2ContactEditorDlg* self =
|
|
143 |
new(ELeave) CPbk2ContactEditorDlg(aParams, aContactObserver,aAppServices,aEditorFieldsId );
|
|
144 |
CleanupStack::PushL(self);
|
|
145 |
self->ConstructL( aContact );
|
|
146 |
self->iTitleText = aTitleText;
|
|
147 |
CleanupStack::Pop(self);
|
|
148 |
return self;
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
// --------------------------------------------------------------------------
|
|
153 |
// CPbk2ContactEditorDlg::ConstructL
|
|
154 |
// --------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CPbk2ContactEditorDlg::ConstructL( MVPbkStoreContact* aStoreContact )
|
|
157 |
{
|
|
158 |
CreatePresentationContactL( *aStoreContact );
|
|
159 |
|
|
160 |
iEditorStrategy =
|
|
161 |
Pbk2ContactEditorStrategyFactory::CreateL
|
|
162 |
(iParams, iContact);
|
|
163 |
|
|
164 |
// Take ownership of the contact after all leaving initialization has
|
|
165 |
// been done.
|
|
166 |
iStoreContact = aStoreContact;
|
|
167 |
}
|
|
168 |
|
|
169 |
// --------------------------------------------------------------------------
|
|
170 |
// CPbk2ContactEditorDlg::ExecuteLD
|
|
171 |
// --------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
EXPORT_C void CPbk2ContactEditorDlg::ExecuteLD()
|
|
174 |
{
|
|
175 |
CleanupStack::PushL( this );
|
|
176 |
|
|
177 |
TBool destroyed = EFalse;
|
|
178 |
iDestroyedPtr = &destroyed;
|
|
179 |
|
|
180 |
// Implementation dialog must be run again e.g when relocation
|
|
181 |
// is done due to item addition.
|
|
182 |
do
|
|
183 |
{
|
|
184 |
// Reset state
|
|
185 |
iRelocationState.ClearAll();
|
|
186 |
|
|
187 |
iImplementation = CPbk2ContactEditorDlgImpl::NewL
|
|
188 |
( iParams, *iContact, *iFieldProperties, *this,
|
|
189 |
*iEditorStrategy, *this, iAppServices, iTitleText );
|
|
190 |
// ownership is passed
|
|
191 |
iTitleText = NULL;
|
|
192 |
iEliminator = iImplementation;
|
|
193 |
iImplementation->ResetWhenDestroyed( &iEliminator );
|
|
194 |
iImplementation->ExecuteLD();
|
|
195 |
} while ( ContinueAfterRelocation() );
|
|
196 |
|
|
197 |
if ( destroyed )
|
|
198 |
{
|
|
199 |
CleanupStack::Pop( this );
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
CleanupStack::PopAndDestroy( this );
|
|
204 |
}
|
|
205 |
}
|
|
206 |
|
|
207 |
// --------------------------------------------------------------------------
|
|
208 |
// CPbk2ContactEditorDlg::RequestExitL
|
|
209 |
// --------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
void CPbk2ContactEditorDlg::RequestExitL( TInt aCommandId )
|
|
212 |
{
|
|
213 |
__ASSERT_DEBUG( iEliminator, Panic( ENullPointer ) );
|
|
214 |
iEliminator->RequestExitL( aCommandId );
|
|
215 |
}
|
|
216 |
|
|
217 |
// --------------------------------------------------------------------------
|
|
218 |
// CPbk2ContactEditorDlg::ForceExit
|
|
219 |
// --------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
void CPbk2ContactEditorDlg::ForceExit()
|
|
222 |
{
|
|
223 |
if ( iEliminator )
|
|
224 |
{
|
|
225 |
iEliminator->ForceExit();
|
|
226 |
}
|
|
227 |
// The contact relocator should be destructed
|
|
228 |
// if the edit dialog has been destructed
|
|
229 |
if ( iContactRelocator )
|
|
230 |
{
|
|
231 |
iRelocationState.ClearAll();
|
|
232 |
delete iContactRelocator;
|
|
233 |
iContactRelocator = NULL;
|
|
234 |
}
|
|
235 |
}
|
|
236 |
|
|
237 |
// --------------------------------------------------------------------------
|
|
238 |
// CPbk2ContactEditorDlg::ResetWhenDestroyed
|
|
239 |
// --------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
void CPbk2ContactEditorDlg::ResetWhenDestroyed(
|
|
242 |
MPbk2DialogEliminator** aSelfPtr )
|
|
243 |
{
|
|
244 |
__ASSERT_DEBUG(!aSelfPtr || *aSelfPtr == this,
|
|
245 |
Panic(EPanicPreCond_ResetWhenDestroyed));
|
|
246 |
iSelfPtr = aSelfPtr;
|
|
247 |
}
|
|
248 |
|
|
249 |
// --------------------------------------------------------------------------
|
|
250 |
// CPbk2ContactEditorDlg::ContactRelocatedL
|
|
251 |
// --------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
void CPbk2ContactEditorDlg::ContactRelocatedL
|
|
254 |
(MVPbkStoreContact* aRelocatedContact)
|
|
255 |
{
|
|
256 |
iStoreContact = aRelocatedContact; // take ownership
|
|
257 |
}
|
|
258 |
|
|
259 |
// --------------------------------------------------------------------------
|
|
260 |
// CPbk2ContactEditorDlg::ContactRelocationFailed
|
|
261 |
// --------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void CPbk2ContactEditorDlg::ContactRelocationFailed
|
|
264 |
( TInt aReason, MVPbkStoreContact* aContact )
|
|
265 |
{
|
|
266 |
// Take the contact back
|
|
267 |
iStoreContact = aContact;
|
|
268 |
iAddItemFieldTypeResourceId = KErrNotFound;
|
|
269 |
iAddItemFieldTypeXspName = NULL;
|
|
270 |
|
|
271 |
if ( aReason != KErrCancel )
|
|
272 |
{
|
|
273 |
// Reset state
|
|
274 |
iRelocationState.Set( ERelocationFailed );
|
|
275 |
// No error note is to be shown to the user when she
|
|
276 |
// manually cancels the relocation process, therefore
|
|
277 |
// the error code must be converted
|
|
278 |
CCoeEnv::Static()->HandleError( aReason );
|
|
279 |
}
|
|
280 |
else
|
|
281 |
{
|
|
282 |
// Relocation cancelled
|
|
283 |
iRelocationState.Set( ERelocationCancelled );
|
|
284 |
}
|
|
285 |
}
|
|
286 |
|
|
287 |
// --------------------------------------------------------------------------
|
|
288 |
// CPbk2ContactEditorDlg::ContactsRelocationFailed
|
|
289 |
// --------------------------------------------------------------------------
|
|
290 |
//
|
|
291 |
void CPbk2ContactEditorDlg::ContactsRelocationFailed
|
|
292 |
( TInt /*aReason*/, CVPbkContactLinkArray* /*aContacts*/ )
|
|
293 |
{
|
|
294 |
// Not called in editor case
|
|
295 |
}
|
|
296 |
|
|
297 |
// --------------------------------------------------------------------------
|
|
298 |
// CPbk2ContactEditorDlg::RelocationProcessComplete
|
|
299 |
// --------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
void CPbk2ContactEditorDlg::RelocationProcessComplete()
|
|
302 |
{
|
|
303 |
TRAPD( res, HandleRelocationProcessCompleteL() );
|
|
304 |
if ( res != KErrNone )
|
|
305 |
{
|
|
306 |
// Shows system messages
|
|
307 |
CCoeEnv::Static()->HandleError( res );
|
|
308 |
// If application is not closed then at least destroy
|
|
309 |
// the dialog
|
|
310 |
iRelocationState.ClearAll();
|
|
311 |
iRelocationState.Set( ERelocationFailed );
|
|
312 |
delete iImplementation;
|
|
313 |
iImplementation = NULL;
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
// --------------------------------------------------------------------------
|
|
318 |
// CPbk2ContactEditorDlg::RelocateContactL
|
|
319 |
// --------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
TBool CPbk2ContactEditorDlg::RelocateContactL(
|
|
322 |
TPbk2RelocationQyeryPolicy aQueryPolicy )
|
|
323 |
{
|
|
324 |
TBool result = RelocateContactL( KErrNotFound, KNullDesC, aQueryPolicy );
|
|
325 |
// Clear the add item state because this is called in other cases than
|
|
326 |
// relocation due to add item.
|
|
327 |
iRelocationState.Clear( ERelocationDueToItemAddition );
|
|
328 |
|
|
329 |
return result;
|
|
330 |
}
|
|
331 |
|
|
332 |
// --------------------------------------------------------------------------
|
|
333 |
// CPbk2ContactEditorDlg::RelocateContactL
|
|
334 |
// --------------------------------------------------------------------------
|
|
335 |
//
|
|
336 |
TBool CPbk2ContactEditorDlg::RelocateContactL(
|
|
337 |
TInt aAddItemFieldTypeResourceId,
|
|
338 |
const TDesC& aAddItemXspName,
|
|
339 |
TPbk2RelocationQyeryPolicy aQueryPolicy )
|
|
340 |
{
|
|
341 |
iRelocationState.ClearAll();
|
|
342 |
delete iContactRelocator;
|
|
343 |
iContactRelocator = NULL;
|
|
344 |
iContactRelocator = CPbk2ContactRelocator::NewL();
|
|
345 |
|
|
346 |
TBool result = EFalse;
|
|
347 |
if (iContactRelocator->IsPhoneMemoryInConfigurationL())
|
|
348 |
{
|
|
349 |
CPbk2ContactRelocator::TFlags flags =
|
|
350 |
CPbk2ContactRelocator::EPbk2RelocatorExistingContact;
|
|
351 |
if ( iParams.iFlags & TPbk2ContactEditorParams::ENewContact )
|
|
352 |
{
|
|
353 |
flags = CPbk2ContactRelocator::EPbk2RelocatorNewContact;
|
|
354 |
}
|
|
355 |
|
|
356 |
result = iContactRelocator->RelocateAndLockContactL(
|
|
357 |
iStoreContact, *this,
|
|
358 |
aQueryPolicy,
|
|
359 |
flags );
|
|
360 |
iStoreContact = NULL; // relocator took away ownership
|
|
361 |
iAddItemFieldTypeResourceId = aAddItemFieldTypeResourceId;
|
|
362 |
if (aAddItemXspName != KNullDesC())
|
|
363 |
{
|
|
364 |
delete iAddItemFieldTypeXspName;
|
|
365 |
iAddItemFieldTypeXspName = NULL;
|
|
366 |
iAddItemFieldTypeXspName = aAddItemXspName.AllocL();
|
|
367 |
}
|
|
368 |
// else not needed because iAddItemFieldTypeXspName is NULL
|
|
369 |
|
|
370 |
/// Dialog must be started again if relocation is done due to
|
|
371 |
/// item addition.
|
|
372 |
if ( iContactRelocator )
|
|
373 |
{
|
|
374 |
iRelocationState.Set( ERelocationDueToItemAddition );
|
|
375 |
}
|
|
376 |
}
|
|
377 |
return result;
|
|
378 |
}
|
|
379 |
|
|
380 |
// --------------------------------------------------------------------------
|
|
381 |
// CPbk2ContactEditorDlg::IsPhoneMemoryInConfigurationL
|
|
382 |
// --------------------------------------------------------------------------
|
|
383 |
//
|
|
384 |
TBool CPbk2ContactEditorDlg::IsPhoneMemoryInConfigurationL()
|
|
385 |
{
|
|
386 |
CPbk2ContactRelocator* contactRelocator = CPbk2ContactRelocator::NewL();
|
|
387 |
CleanupStack::PushL( contactRelocator );
|
|
388 |
TBool ret = contactRelocator->IsPhoneMemoryInConfigurationL();
|
|
389 |
CleanupStack::PopAndDestroy( contactRelocator );
|
|
390 |
return ret;
|
|
391 |
}
|
|
392 |
|
|
393 |
// --------------------------------------------------------------------------
|
|
394 |
// CPbk2ContactEditorDlg::IsTemplateFieldL
|
|
395 |
// --------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
TBool CPbk2ContactEditorDlg::IsTemplateFieldL( TInt aResId,
|
|
398 |
const TDesC& aXSpName )
|
|
399 |
{
|
|
400 |
TBool result( EFalse );
|
|
401 |
const MVPbkFieldType* fieldType =
|
|
402 |
Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager().
|
|
403 |
FieldTypes().Find( aResId );
|
|
404 |
if ( fieldType )
|
|
405 |
{
|
|
406 |
const MPbk2FieldProperty* fieldProp =
|
|
407 |
iFieldProperties->FindProperty( *fieldType, aXSpName );
|
|
408 |
if ( fieldProp
|
|
409 |
&& ( fieldProp->Flags() & KPbk2FieldFlagTemplateField ) )
|
|
410 |
{
|
|
411 |
result = ETrue;
|
|
412 |
}
|
|
413 |
}
|
|
414 |
return result;
|
|
415 |
}
|
|
416 |
|
|
417 |
// --------------------------------------------------------------------------
|
|
418 |
// CPbk2ContactEditorDlg::EditorReadyL
|
|
419 |
// --------------------------------------------------------------------------
|
|
420 |
//
|
|
421 |
void CPbk2ContactEditorDlg::EditorReadyL()
|
|
422 |
{
|
|
423 |
// Editor is ready
|
|
424 |
if (iAddItemFieldTypeResourceId != KErrNotFound)
|
|
425 |
{
|
|
426 |
TPtrC xSpName = iAddItemFieldTypeXspName ? *iAddItemFieldTypeXspName :
|
|
427 |
KNullDesC();
|
|
428 |
// If new field is template field in relocated contact,
|
|
429 |
// do not add new field. Just focus the field in contact.
|
|
430 |
if ( IsTemplateFieldL( iAddItemFieldTypeResourceId, xSpName ) )
|
|
431 |
{
|
|
432 |
iImplementation->TryChangeFocusWithTypeIdL
|
|
433 |
( iAddItemFieldTypeResourceId, xSpName );
|
|
434 |
}
|
|
435 |
else
|
|
436 |
{
|
|
437 |
// Lets run the add item dialog silently
|
|
438 |
iImplementation->AddItemToContactL
|
|
439 |
( iAddItemFieldTypeResourceId, xSpName );
|
|
440 |
}
|
|
441 |
}
|
|
442 |
}
|
|
443 |
|
|
444 |
// --------------------------------------------------------------------------
|
|
445 |
// CPbk2ContactEditorDlg::ContactEditingComplete
|
|
446 |
//
|
|
447 |
// aEditedContact is commented because it is called from the
|
|
448 |
// CPbk2ContactEditorDlgImpl who actually don't own it. So against
|
|
449 |
// observer documentation ownership is not changed. This is
|
|
450 |
// an implementation detail of
|
|
451 |
// CPbk2ContactEditorDlg <-> CPbk2ContactEditorDlgImpl
|
|
452 |
// --------------------------------------------------------------------------
|
|
453 |
//
|
|
454 |
void CPbk2ContactEditorDlg::ContactEditingComplete(
|
|
455 |
MVPbkStoreContact* /*aEditedContact*/ )
|
|
456 |
{
|
|
457 |
// Don't inform observer if the dialog need to be run again
|
|
458 |
if ( !ContinueAfterRelocation() )
|
|
459 |
{
|
|
460 |
// Give ownership of the iStoreContact to the observer
|
|
461 |
MVPbkStoreContact* contact = iStoreContact;
|
|
462 |
iStoreContact = NULL;
|
|
463 |
iContactObserver.ContactEditingComplete( contact );
|
|
464 |
}
|
|
465 |
}
|
|
466 |
|
|
467 |
// --------------------------------------------------------------------------
|
|
468 |
// CPbk2ContactEditorDlg::ContactEditingDeletedContact
|
|
469 |
//
|
|
470 |
// aEditedContact is commented because it is called from the
|
|
471 |
// CPbk2ContactEditorDlgImpl who actually don't own it. So against
|
|
472 |
// observer documentation ownership is not changed. This is
|
|
473 |
// an implementation detail of
|
|
474 |
// CPbk2ContactEditorDlg <-> CPbk2ContactEditorDlgImpl
|
|
475 |
// --------------------------------------------------------------------------
|
|
476 |
//
|
|
477 |
void CPbk2ContactEditorDlg::ContactEditingDeletedContact(
|
|
478 |
MVPbkStoreContact* /*aEditedContact*/ )
|
|
479 |
{
|
|
480 |
// Don't inform observer if the dialog need to be run again
|
|
481 |
if ( !ContinueAfterRelocation() )
|
|
482 |
{
|
|
483 |
// Give ownership of the iStoreContact to the observer
|
|
484 |
MVPbkStoreContact* contact = iStoreContact;
|
|
485 |
iStoreContact = NULL;
|
|
486 |
iContactObserver.ContactEditingDeletedContact( contact );
|
|
487 |
}
|
|
488 |
}
|
|
489 |
|
|
490 |
// --------------------------------------------------------------------------
|
|
491 |
// CPbk2ContactEditorDlg::ContactEditingAborted
|
|
492 |
// --------------------------------------------------------------------------
|
|
493 |
//
|
|
494 |
void CPbk2ContactEditorDlg::ContactEditingAborted()
|
|
495 |
{
|
|
496 |
// Forward from implementation dialog to the actual client
|
|
497 |
iContactObserver.ContactEditingAborted();
|
|
498 |
}
|
|
499 |
|
|
500 |
// --------------------------------------------------------------------------
|
|
501 |
// CPbk2ContactEditorDlg::HandleRelocationProcessCompleteL
|
|
502 |
// --------------------------------------------------------------------------
|
|
503 |
//
|
|
504 |
void CPbk2ContactEditorDlg::HandleRelocationProcessCompleteL()
|
|
505 |
{
|
|
506 |
if ( !iRelocationState.IsSet( ERelocationCancelled ) &&
|
|
507 |
!iRelocationState.IsSet( ERelocationFailed ) )
|
|
508 |
{
|
|
509 |
// Update contact
|
|
510 |
CreatePresentationContactL();
|
|
511 |
|
|
512 |
// Contact has been relocated which means that the state changes
|
|
513 |
// from creating a new contact to editing an relocated contact.
|
|
514 |
|
|
515 |
// Remove the new contact flag...
|
|
516 |
iParams.iFlags &= ~TPbk2ContactEditorParams::ENewContact;
|
|
517 |
// ... and set the editing flag
|
|
518 |
iParams.iFlags |= TPbk2ContactEditorParams::EModified;
|
|
519 |
// Update strategy
|
|
520 |
delete iEditorStrategy;
|
|
521 |
iEditorStrategy = NULL;
|
|
522 |
iEditorStrategy = Pbk2ContactEditorStrategyFactory::CreateL
|
|
523 |
( iParams, iContact );
|
|
524 |
|
|
525 |
// Set iFocusedContactField to NULL so that
|
|
526 |
// the right field (new field) will be focused
|
|
527 |
iParams.iFocusedContactField = NULL;
|
|
528 |
|
|
529 |
TBool informObserver = EFalse;
|
|
530 |
if ( !iRelocationState.IsSet( ERelocationDueToItemAddition ) )
|
|
531 |
{
|
|
532 |
informObserver = ETrue;
|
|
533 |
}
|
|
534 |
// Delete current implementation dialog nicely and create
|
|
535 |
// a new dialog in ExecuteLD if needed.
|
|
536 |
iImplementation->CloseWithoutSaving( informObserver );
|
|
537 |
}
|
|
538 |
else
|
|
539 |
{
|
|
540 |
// Reset state if dialog is not closed -> continued with old contact
|
|
541 |
iRelocationState.ClearAll();
|
|
542 |
}
|
|
543 |
}
|
|
544 |
|
|
545 |
// --------------------------------------------------------------------------
|
|
546 |
// CPbk2ContactEditorDlg::CreatePresentationContactL
|
|
547 |
// --------------------------------------------------------------------------
|
|
548 |
//
|
|
549 |
void CPbk2ContactEditorDlg::CreatePresentationContactL()
|
|
550 |
{
|
|
551 |
CreatePresentationContactL( *iStoreContact );
|
|
552 |
}
|
|
553 |
|
|
554 |
// --------------------------------------------------------------------------
|
|
555 |
// CPbk2ContactEditorDlg::CreatePresentationContactL
|
|
556 |
// --------------------------------------------------------------------------
|
|
557 |
//
|
|
558 |
void CPbk2ContactEditorDlg::CreatePresentationContactL(
|
|
559 |
MVPbkStoreContact& aStoreContact)
|
|
560 |
{
|
|
561 |
delete iSpecificFieldProperties;
|
|
562 |
iSpecificFieldProperties = NULL;
|
|
563 |
delete iFieldProperties;
|
|
564 |
iFieldProperties = NULL;
|
|
565 |
|
|
566 |
const MVPbkFieldTypeList& supportedFieldTypes =
|
|
567 |
aStoreContact.ParentStore().StoreProperties().SupportedFields();
|
|
568 |
|
|
569 |
//If custom fields are provided (social phonebook)
|
|
570 |
if( iEditorFieldsId != KErrNotFound )
|
|
571 |
{
|
|
572 |
HBufC8* res = CCoeEnv::Static()->AllocReadResourceAsDes8L( iEditorFieldsId );
|
|
573 |
CleanupStack::PushL( res );
|
|
574 |
TResourceReader reader;
|
|
575 |
reader.SetBuffer( res );
|
|
576 |
// Create a field property list of the provided fields on reader
|
|
577 |
iFieldProperties = CPbk2FieldPropertyArray::NewL
|
|
578 |
( supportedFieldTypes, reader, CCoeEnv::Static()->FsSession() );
|
|
579 |
CleanupStack::PopAndDestroy( res );
|
|
580 |
}
|
|
581 |
else
|
|
582 |
{
|
|
583 |
// Create a field property list of the supported
|
|
584 |
// field types of the used store
|
|
585 |
iFieldProperties = CPbk2FieldPropertyArray::NewL
|
|
586 |
( supportedFieldTypes, CCoeEnv::Static()->FsSession() );
|
|
587 |
}
|
|
588 |
|
|
589 |
// if iAppServices is set. This is used if EditorDlg is used outside of Pbk2 context
|
|
590 |
if( iAppServices )
|
|
591 |
{
|
|
592 |
iSpecificFieldProperties = CPbk2StoreSpecificFieldPropertyArray::NewL
|
|
593 |
( *iFieldProperties,
|
|
594 |
iAppServices->StoreProperties(),
|
|
595 |
supportedFieldTypes, aStoreContact.ParentStore() );
|
|
596 |
}
|
|
597 |
else
|
|
598 |
{
|
|
599 |
iSpecificFieldProperties = CPbk2StoreSpecificFieldPropertyArray::NewL
|
|
600 |
( *iFieldProperties,
|
|
601 |
Phonebook2::Pbk2AppUi()->ApplicationServices().StoreProperties(),
|
|
602 |
supportedFieldTypes, aStoreContact.ParentStore() );
|
|
603 |
}
|
|
604 |
|
|
605 |
delete iContact;
|
|
606 |
iContact = NULL;
|
|
607 |
iContact = CPbk2PresentationContact::NewL
|
|
608 |
( aStoreContact, *iSpecificFieldProperties );
|
|
609 |
}
|
|
610 |
|
|
611 |
// --------------------------------------------------------------------------
|
|
612 |
// CPbk2ContactEditorDlg::ContinueAfterRelocation
|
|
613 |
// --------------------------------------------------------------------------
|
|
614 |
//
|
|
615 |
TBool CPbk2ContactEditorDlg::ContinueAfterRelocation()
|
|
616 |
{
|
|
617 |
TBool ret = EFalse;
|
|
618 |
|
|
619 |
// Currently 4 ways to continue after relocation:
|
|
620 |
// 1) User cancels relocation -> editor stays open with the OLD contact.
|
|
621 |
// 2) Relocation done due to add item and user approves
|
|
622 |
// relocation -> editor stays open with the NEW contact
|
|
623 |
// 3) Relocation done due to other reason than add item.
|
|
624 |
// User approves relocation -> editor is closed.
|
|
625 |
// 4) Error case
|
|
626 |
|
|
627 |
if ( iRelocationState.IsSet( ERelocationDueToItemAddition ) &&
|
|
628 |
!iRelocationState.IsSet( ERelocationCancelled ) &&
|
|
629 |
!iRelocationState.IsSet( ERelocationFailed ) )
|
|
630 |
{
|
|
631 |
// Continue only in case 2
|
|
632 |
ret = ETrue;
|
|
633 |
}
|
|
634 |
|
|
635 |
return ret;
|
|
636 |
}
|
|
637 |
|
|
638 |
// End of File
|