|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of the class CfscsaveascontactpluginImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <implementationproxy.h> |
|
21 #include <bautils.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <pbk2rclsaveascontactplugin.rsg> |
|
24 #include <pbk2rclsaveascontactplugin.mbg> |
|
25 #include <AknsConstants.h> |
|
26 #include "mfsccontactset.h" |
|
27 #include "mfscactionutils.h" |
|
28 #include "cfsccontactaction.h" |
|
29 #include "fsccontactactionservicedefines.h" |
|
30 #include <MVPbkStoreContact.h> |
|
31 #include <MVPbkContactObserver.h> |
|
32 #include <CPbk2StoreConfiguration.h> |
|
33 #include <TVPbkContactStoreUriPtr.h> |
|
34 #include <MVPbkContactStoreList.h> |
|
35 #include <e32cmn.h> |
|
36 #include "mfsccontactactionpluginobserver.h" |
|
37 #include <CVPbkContactManager.h> |
|
38 #include <MVPbkContactStore.h> |
|
39 #include <MVPbkStoreContactField.h> |
|
40 #include <MVPbkContactFieldData.h> |
|
41 #include <VPbkContactStoreUris.h> |
|
42 #include <AknWaitDialog.h> |
|
43 |
|
44 #include "fsccontactactionserviceuids.hrh" |
|
45 #include "fscactionpluginactionuids.h" |
|
46 #include "fscactionplugincrkeys.h" |
|
47 #include "cfscsaveascontactpluginimpl.h" |
|
48 #include "FscActionPluginUtils.h" |
|
49 |
|
50 // CONSTANTS DECLARATIONS |
|
51 const TInt KActionCount = 1; |
|
52 const TInt KInvalidReasonId = 0; |
|
53 |
|
54 _LIT( KSaveAsContactPluginIconPath, |
|
55 "\\resource\\apps\\pbk2rclsaveascontactplugin.mif" ); |
|
56 _LIT( KResourceFilePath, "\\resource\\apps\\pbk2rclsaveascontactplugin.rsc" ); |
|
57 |
|
58 const TImplementationProxy ImplementationTable[] = |
|
59 { |
|
60 IMPLEMENTATION_PROXY_ENTRY( |
|
61 KFscSaveAsContactPluginImplImpUid, |
|
62 CFscSaveAsContactPluginImpl::NewL ) |
|
63 }; |
|
64 |
|
65 // ======== MEMBER FUNCTIONS ======== |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CFscSaveAsContactPluginImpl::NewL |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CFscSaveAsContactPluginImpl* CFscSaveAsContactPluginImpl::NewL( |
|
72 TAny* aParams) |
|
73 { |
|
74 FUNC_LOG; |
|
75 |
|
76 TFscContactActionPluginParams* params = |
|
77 reinterpret_cast< TFscContactActionPluginParams* >(aParams ); |
|
78 |
|
79 CFscSaveAsContactPluginImpl* self = new (ELeave) CFscSaveAsContactPluginImpl( *params ); |
|
80 CleanupStack::PushL(self); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop(self); |
|
83 |
|
84 return self; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CFscSaveAsContactPluginImpl::~CFscSaveAsContactPluginImpl |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 CFscSaveAsContactPluginImpl::~CFscSaveAsContactPluginImpl() |
|
92 { |
|
93 FUNC_LOG; |
|
94 DismissWaitNote(); |
|
95 delete iNewStoreContact; |
|
96 delete iContactSaveAsContactAction; |
|
97 delete iActionList; |
|
98 CCoeEnv::Static()->DeleteResourceFile(iResourceHandle); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CFscSaveAsContactPluginImpl::Uid |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 TUid CFscSaveAsContactPluginImpl::Uid() const |
|
106 { |
|
107 FUNC_LOG; |
|
108 TUid uid = |
|
109 { |
|
110 KFscSaveAsContactPluginImplImpUid |
|
111 }; |
|
112 return uid; |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CFscSaveAsContactPluginImpl::ActionList |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 const CArrayFix<TUid>* CFscSaveAsContactPluginImpl::ActionList() const |
|
120 { |
|
121 return iActionList; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CFscSaveAsContactPluginImpl::GetActionL |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 const MFscContactAction& CFscSaveAsContactPluginImpl::GetActionL( |
|
129 TUid aActionUid) const |
|
130 { |
|
131 FUNC_LOG; |
|
132 |
|
133 const MFscContactAction* action= NULL; |
|
134 if (aActionUid == KFscActionUidSaveAsContact) |
|
135 { |
|
136 action = iContactSaveAsContactAction; |
|
137 } |
|
138 else |
|
139 { |
|
140 User::Leave(KErrNotFound); |
|
141 } |
|
142 |
|
143 return *action; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CFscSaveAsContactPluginImpl::PriorityForContactSetL |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CFscSaveAsContactPluginImpl::PriorityForContactSetL( |
|
151 TUid aActionUid, |
|
152 MFscContactSet& aContactSet, |
|
153 TFscContactActionVisibility& aActionMenuVisibility, |
|
154 TFscContactActionVisibility& aOptionsMenuVisibility, |
|
155 MFscContactActionPluginObserver* aObserver) |
|
156 { |
|
157 FUNC_LOG; |
|
158 iActionUid = aActionUid; |
|
159 iContactSet = &aContactSet; |
|
160 iActionMenuVisibility = &aActionMenuVisibility; |
|
161 iOptionsMenuVisibility = &aOptionsMenuVisibility; |
|
162 |
|
163 iIsExecute = EFalse; |
|
164 |
|
165 iContactSet->SetToFirstContact(); |
|
166 |
|
167 iActionPriority = KFscActionPriorityNotAvailable; |
|
168 |
|
169 iCanDisplay = KErrNone; |
|
170 |
|
171 if (iActionUid == KFscActionUidSaveAsContact) |
|
172 { |
|
173 // We save only one contact and no groups: |
|
174 iCanDisplay = (aContactSet.GroupCount() == 0 |
|
175 && aContactSet.ContactCount() == 1 ) ? KErrNone : KErrArgument; |
|
176 |
|
177 //Fix for EJKA-7MFDHU |
|
178 if (iCanDisplay == KErrNone |
|
179 && IsValidStoreL() ) |
|
180 { |
|
181 aActionMenuVisibility.iVisibility |
|
182 = TFscContactActionVisibility::EFscActionVisible; |
|
183 aOptionsMenuVisibility.iVisibility |
|
184 = TFscContactActionVisibility::EFscActionVisible; |
|
185 |
|
186 iActionPriority = iParams.iUtils->ActionPriority( |
|
187 KFscCrUidSaveAsContact, KFscActionPrioritySaveAsContact); |
|
188 if (iActionPriority > 0) |
|
189 { |
|
190 // ignore any leave while updating action icons |
|
191 TRAP_IGNORE( UpdateActionIconL( aActionUid ) ); |
|
192 } |
|
193 } |
|
194 else |
|
195 { |
|
196 iActionPriority = KFscActionPriorityNotAvailable; |
|
197 aActionMenuVisibility.iVisibility |
|
198 = TFscContactActionVisibility::EFscActionHidden; |
|
199 aActionMenuVisibility.iReasonId = KInvalidReasonId; |
|
200 aOptionsMenuVisibility.iVisibility |
|
201 = TFscContactActionVisibility::EFscActionHidden; |
|
202 aOptionsMenuVisibility.iReasonId = KInvalidReasonId; |
|
203 } |
|
204 ResetData(); |
|
205 aObserver->PriorityForContactSetComplete(iActionPriority); |
|
206 } |
|
207 else |
|
208 { |
|
209 ResetData(); |
|
210 aObserver->PriorityForContactSetFailed(KErrArgument); |
|
211 } |
|
212 } |
|
213 // --------------------------------------------------------------------------- |
|
214 // CFscSaveAsContactPluginImpl::CancelPriorityForContactSet |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 void CFscSaveAsContactPluginImpl::CancelPriorityForContactSet() |
|
218 { |
|
219 FUNC_LOG; |
|
220 iLastEvent = EActionEventCanceled; |
|
221 ResetData(); |
|
222 } |
|
223 // --------------------------------------------------------------------------- |
|
224 // CFscSaveAsContactPluginImpl::ExecuteL |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CFscSaveAsContactPluginImpl::ExecuteL( |
|
228 TUid aActionUid, |
|
229 MFscContactSet& aContactSet, |
|
230 MFscContactActionPluginObserver* aObserver) |
|
231 { |
|
232 FUNC_LOG; |
|
233 switch (iLastEvent) |
|
234 { |
|
235 case EActionEventIdle: |
|
236 { |
|
237 |
|
238 iLastEvent = EActionEventCanExecuteLaunched; |
|
239 |
|
240 iActionUid = aActionUid; |
|
241 iContactSet = &aContactSet; |
|
242 iPluginObserver = aObserver; |
|
243 |
|
244 iIsExecute = ETrue; |
|
245 |
|
246 iContactSet->SetToFirstContact(); |
|
247 |
|
248 CanExecuteL(aActionUid, aContactSet); |
|
249 |
|
250 break; |
|
251 } |
|
252 |
|
253 case EActionEventCanExecuteFinished: |
|
254 { |
|
255 |
|
256 iWaitDialog = new(ELeave)CAknWaitDialog( |
|
257 (REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), EFalse); |
|
258 iWaitDialog->ExecuteLD(R_FS_WAIT_NOTE); |
|
259 |
|
260 if (iCanDisplay == KErrNone) |
|
261 { |
|
262 iLastEvent = EActionEventContactRetrieve; |
|
263 iPluginObserver = aObserver; |
|
264 aContactSet.NextContactL(this); |
|
265 } |
|
266 else |
|
267 { |
|
268 ResetData(); |
|
269 iPluginObserver->ExecuteFailed(KErrGeneral); |
|
270 } |
|
271 break; |
|
272 } |
|
273 case EActionEventCanceled: |
|
274 { |
|
275 iLastEvent = EActionEventIdle; |
|
276 break; |
|
277 } |
|
278 default: |
|
279 { |
|
280 ResetData(); |
|
281 break; |
|
282 } |
|
283 } |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CFscSaveAsContactPluginImpl::CancelExecute |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 void CFscSaveAsContactPluginImpl::CancelExecute() |
|
291 { |
|
292 FUNC_LOG; |
|
293 DismissWaitNote(); |
|
294 iLastEvent = EActionEventCanceled; |
|
295 ResetData(); |
|
296 } |
|
297 // --------------------------------------------------------------------------- |
|
298 // CFscSaveAsContactPluginImpl::GetReasonL |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 void CFscSaveAsContactPluginImpl::GetReasonL( |
|
302 TUid /* aActionUid */, |
|
303 TInt /* aReasonId */, |
|
304 HBufC*& /* aReason */) const |
|
305 { |
|
306 FUNC_LOG; |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // CFscSaveAsContactPluginImpl::NextContactComplete |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 void CFscSaveAsContactPluginImpl::NextContactComplete( |
|
314 MVPbkStoreContact* aContact) |
|
315 { |
|
316 FUNC_LOG; |
|
317 TInt err( KErrNone ); |
|
318 switch (iLastEvent) |
|
319 { |
|
320 case EActionEventContactRetrieve: |
|
321 { |
|
322 iRetrievedStoreContact = aContact; |
|
323 iLastEvent = EActionEventExecuteLaunched; |
|
324 TRAP (err, PrepareStoreL() ); |
|
325 break; |
|
326 } |
|
327 case EActionEventCanceled: |
|
328 { |
|
329 iLastEvent = EActionEventIdle; |
|
330 break; |
|
331 } |
|
332 default: |
|
333 { |
|
334 ResetData(); |
|
335 break; |
|
336 } |
|
337 } |
|
338 if ( err != KErrNone ) |
|
339 { |
|
340 CCoeEnv::Static()->HandleError( err ); |
|
341 } |
|
342 } |
|
343 |
|
344 // --------------------------------------------------------------------------- |
|
345 // CFscSaveAsContactPluginImpl::NextContactFailed |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 void CFscSaveAsContactPluginImpl::NextContactFailed( |
|
349 TInt aError) |
|
350 { |
|
351 FUNC_LOG; |
|
352 |
|
353 ResetData(); |
|
354 iPluginObserver->ExecuteFailed(aError); |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // CFscSaveAsContactPluginImpl::NextGroupComplete |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 void CFscSaveAsContactPluginImpl::NextGroupComplete( |
|
362 MVPbkStoreContact* /*aContact*/) |
|
363 { |
|
364 FUNC_LOG; |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CFscSaveAsContactPluginImpl::NextGroupFailed |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CFscSaveAsContactPluginImpl::NextGroupFailed( |
|
372 TInt /*aError*/) |
|
373 { |
|
374 FUNC_LOG; |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // CFscSaveAsContactPluginImpl::GetGroupContactComplete |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 void CFscSaveAsContactPluginImpl::GetGroupContactComplete( |
|
382 MVPbkStoreContact* /*aContact*/) |
|
383 { |
|
384 FUNC_LOG; |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // CFscSaveAsContactPluginImpl::GetGroupContactFailed |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 void CFscSaveAsContactPluginImpl::GetGroupContactFailed( |
|
392 TInt /*aError*/) |
|
393 { |
|
394 FUNC_LOG; |
|
395 } |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // CFscSaveAsContactPluginImpl::IsValidStoreL |
|
399 // --------------------------------------------------------------------------- |
|
400 // |
|
401 TBool CFscSaveAsContactPluginImpl::IsValidStoreL() |
|
402 { |
|
403 FUNC_LOG; |
|
404 TBool isValid = EFalse; |
|
405 |
|
406 //Currently method is checking if saving store is cntdb |
|
407 //if saving store is SIM, contact can't be saved |
|
408 //(SIM store is not supported yet) |
|
409 |
|
410 CPbk2StoreConfiguration* storeCnf = CPbk2StoreConfiguration::NewL(); |
|
411 CleanupStack::PushL(storeCnf); |
|
412 TVPbkContactStoreUriPtr defaultStorePtr = |
|
413 storeCnf->DefaultSavingStoreL(); |
|
414 TVPbkContactStoreUriPtr validStorePtr( |
|
415 VPbkContactStoreUris::DefaultCntDbUri() |
|
416 ); |
|
417 |
|
418 if ( !defaultStorePtr.Compare( |
|
419 validStorePtr.UriDes(), |
|
420 TVPbkContactStoreUriPtr::EContactStoreUriAllComponents ) |
|
421 ) |
|
422 { |
|
423 isValid = ETrue; |
|
424 } |
|
425 |
|
426 CleanupStack::PopAndDestroy(storeCnf); |
|
427 return isValid; |
|
428 } |
|
429 |
|
430 // --------------------------------------------------------------------------- |
|
431 // CFscSaveAsContactPluginImpl::PrepareStoreL |
|
432 // --------------------------------------------------------------------------- |
|
433 // |
|
434 void CFscSaveAsContactPluginImpl::PrepareStoreL() |
|
435 { |
|
436 FUNC_LOG; |
|
437 CPbk2StoreConfiguration* storeCnf = CPbk2StoreConfiguration::NewL(); |
|
438 CleanupStack::PushL(storeCnf); |
|
439 TVPbkContactStoreUriPtr storePtr = storeCnf->DefaultSavingStoreL(); |
|
440 CVPbkContactManager& contactManager = iParams.iUtils->ContactManager(); |
|
441 contactManager.LoadContactStoreL( storePtr ); |
|
442 iTargetStore = contactManager.ContactStoresL(). |
|
443 Find( storePtr ); |
|
444 if ( iTargetStore ) |
|
445 { |
|
446 iTargetStore->OpenL( *this ); |
|
447 } |
|
448 else //store not found |
|
449 { |
|
450 ResetData(); |
|
451 iPluginObserver->ExecuteFailed( KErrNotFound ); |
|
452 } |
|
453 CleanupStack::PopAndDestroy(storeCnf); |
|
454 } |
|
455 |
|
456 // --------------------------------------------------------------------------- |
|
457 // CFscSaveAsContactPluginImpl::SaveToContactDatabaseL |
|
458 // --------------------------------------------------------------------------- |
|
459 // |
|
460 void CFscSaveAsContactPluginImpl::SaveToContactDatabaseL( |
|
461 MVPbkStoreContact* aStoreContact) |
|
462 { |
|
463 FUNC_LOG; |
|
464 |
|
465 iNewStoreContact = iTargetStore->CreateNewContactLC(); |
|
466 CleanupStack::Pop();//iNewStoreContact |
|
467 MVPbkStoreContactFieldCollection& fields = aStoreContact->Fields(); |
|
468 TInt i = 0; |
|
469 TInt a = fields.FieldCount(); |
|
470 // Copy fields to the new store contact. No field matching check |
|
471 for (i = 0; i < fields.FieldCount(); i++) |
|
472 { |
|
473 MVPbkStoreContactField& oldField = fields.FieldAt(i); |
|
474 const MVPbkFieldType* fieldType = |
|
475 oldField.BestMatchingFieldType(); |
|
476 if (fieldType != NULL) |
|
477 { |
|
478 MVPbkStoreContactField* newField = |
|
479 iNewStoreContact->CreateFieldLC(*fieldType); |
|
480 newField->FieldData().CopyL(oldField.FieldData()); |
|
481 iNewStoreContact->AddFieldL(newField); |
|
482 CleanupStack::Pop();//newField |
|
483 } |
|
484 } |
|
485 // This is new contact so we don't need to lock it before commiting |
|
486 iNewStoreContact->CommitL( *this); |
|
487 |
|
488 |
|
489 } |
|
490 |
|
491 // --------------------------------------------------------------------------- |
|
492 // CFscSaveAsContactPluginImpl::StoreReady |
|
493 // --------------------------------------------------------------------------- |
|
494 // |
|
495 void CFscSaveAsContactPluginImpl::StoreReady( |
|
496 MVPbkContactStore& aContactStore ) |
|
497 { |
|
498 FUNC_LOG; |
|
499 iTargetStore = &aContactStore; |
|
500 TRAPD( err, SaveToContactDatabaseL( iRetrievedStoreContact ) ); |
|
501 if ( err != KErrNone ) |
|
502 { |
|
503 ResetData(); |
|
504 iPluginObserver->ExecuteFailed( err ); |
|
505 } |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // CFscSaveAsContactPluginImpl::StoreUnavailable |
|
510 // --------------------------------------------------------------------------- |
|
511 // |
|
512 void CFscSaveAsContactPluginImpl::StoreUnavailable( |
|
513 MVPbkContactStore& /*aContactStore*/, |
|
514 TInt /*aReason*/ ) |
|
515 { |
|
516 FUNC_LOG; |
|
517 ResetData(); |
|
518 iPluginObserver->ExecuteFailed(KErrArgument); |
|
519 } |
|
520 |
|
521 // --------------------------------------------------------------------------- |
|
522 // CFscSaveAsContactPluginImpl::HandleStoreEventL |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 void CFscSaveAsContactPluginImpl::HandleStoreEventL( |
|
526 MVPbkContactStore& /*aContactStore*/, |
|
527 TVPbkContactStoreEvent /*aStoreEvent*/ ) |
|
528 { |
|
529 FUNC_LOG; |
|
530 // Do nothing |
|
531 } |
|
532 |
|
533 // --------------------------------------------------------------------------- |
|
534 // CFscSaveAsContactPluginImpl::CanExecuteL |
|
535 // --------------------------------------------------------------------------- |
|
536 // |
|
537 void CFscSaveAsContactPluginImpl::CanExecuteL( |
|
538 TUid aActionUid, |
|
539 MFscContactSet& aContactSet) |
|
540 { |
|
541 FUNC_LOG; |
|
542 |
|
543 if (aActionUid == KFscActionUidSaveAsContact) |
|
544 { |
|
545 iCanDisplay = (aContactSet.GroupCount() == 0 |
|
546 && aContactSet.ContactCount() == 1 ) |
|
547 ? KErrNone |
|
548 : KErrArgument; |
|
549 iLastEvent = EActionEventCanExecuteFinished; |
|
550 ResumeAsync(aActionUid, aContactSet, iIsExecute); |
|
551 } |
|
552 else |
|
553 { |
|
554 //Just in case |
|
555 ResetData(); |
|
556 iPluginObserver->ExecuteFailed(KErrArgument); |
|
557 } |
|
558 |
|
559 } |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // CFscSaveAsContactPluginImpl::UpdateActionIconL |
|
563 // --------------------------------------------------------------------------- |
|
564 // |
|
565 void CFscSaveAsContactPluginImpl::UpdateActionIconL( |
|
566 TUid aActionUid) |
|
567 { |
|
568 FUNC_LOG; |
|
569 |
|
570 TFileName dllFileName; |
|
571 Dll::FileName(dllFileName); |
|
572 TParse parse; |
|
573 User::LeaveIfError(parse.Set( |
|
574 KSaveAsContactPluginIconPath, &dllFileName, |
|
575 NULL) ); |
|
576 |
|
577 if (aActionUid == KFscActionUidSaveAsContact) |
|
578 { |
|
579 iContactSaveAsContactAction->SetIcon(iParams.iUtils->SkinIconL( |
|
580 KAknsIIDQgnFsRclActionSave, parse.FullName(), |
|
581 EMbmPbk2rclsaveascontactpluginQgn_prop_cmail_action_save, |
|
582 EMbmPbk2rclsaveascontactpluginQgn_prop_cmail_action_save_mask) ); |
|
583 } |
|
584 |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // CFscSaveAsContactPluginImpl::CFscSaveAsContactPluginImpl |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 CFscSaveAsContactPluginImpl::CFscSaveAsContactPluginImpl( |
|
592 const TFscContactActionPluginParams& aParams) : |
|
593 CFscContactActionPlugin(), iParams(aParams), iResourceHandle( 0), |
|
594 iLastEvent(EActionEventIdle), iCanDisplay(KErrNone), |
|
595 iIsExecute(EFalse) |
|
596 { |
|
597 FUNC_LOG; |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // CFscSaveAsContactPluginImpl::ConstructL |
|
602 // --------------------------------------------------------------------------- |
|
603 // |
|
604 void CFscSaveAsContactPluginImpl::ConstructL() |
|
605 { |
|
606 FUNC_LOG; |
|
607 |
|
608 TFileName dllFileName; |
|
609 Dll::FileName(dllFileName); |
|
610 TParse parse; |
|
611 User::LeaveIfError(parse.Set( |
|
612 KResourceFilePath, &dllFileName, NULL) ); |
|
613 TFileName resourceFileName(parse.FullName() ); |
|
614 BaflUtils::NearestLanguageFile( |
|
615 CCoeEnv::Static()->FsSession(), resourceFileName); |
|
616 |
|
617 iResourceHandle = ( CCoeEnv::Static() )->AddResourceFileL(resourceFileName); |
|
618 |
|
619 iActionList = new( ELeave )CArrayFixFlat<TUid>( KActionCount ); |
|
620 iActionList->AppendL(KFscActionUidSaveAsContact); |
|
621 |
|
622 User::LeaveIfError(parse.Set( |
|
623 KSaveAsContactPluginIconPath, &dllFileName, NULL) ); |
|
624 iContactSaveAsContactAction = iParams.iUtils->CreateActionL( |
|
625 *this, KFscActionUidSaveAsContact, KFscAtManSaveAs, |
|
626 R_FS_ACTION_SAVE_AS_CONTACT, iParams.iUtils->SkinIconL( |
|
627 KAknsIIDQgnFsRclActionSave, parse.FullName(), |
|
628 EMbmPbk2rclsaveascontactpluginQgn_prop_cmail_action_save, |
|
629 EMbmPbk2rclsaveascontactpluginQgn_prop_cmail_action_save_mask) ); |
|
630 } |
|
631 |
|
632 // --------------------------------------------------------------------------- |
|
633 // CFscSaveAsContactPluginImpl::ResetData |
|
634 // --------------------------------------------------------------------------- |
|
635 // |
|
636 void CFscSaveAsContactPluginImpl::ResetData() |
|
637 { |
|
638 FUNC_LOG; |
|
639 if (iContactSet) |
|
640 { |
|
641 iContactSet->SetToFirstContact(); |
|
642 iContactSet->SetToFirstGroup(); |
|
643 TRAP_IGNORE( iContactSet->CancelNextContactL() ); |
|
644 TRAP_IGNORE( iContactSet->CancelNextGroupL() ); |
|
645 iContactSet = NULL; |
|
646 } |
|
647 DismissWaitNote(); |
|
648 |
|
649 iLastEvent = EActionEventIdle; |
|
650 iActionMenuVisibility = NULL; |
|
651 iOptionsMenuVisibility = NULL; |
|
652 iCanDisplay = KErrNone; |
|
653 iRetrievedStoreContact = NULL; |
|
654 } |
|
655 |
|
656 // --------------------------------------------------------------------------- |
|
657 // CFscSaveAsContactPluginImpl::ResumeAsync |
|
658 // --------------------------------------------------------------------------- |
|
659 // |
|
660 void CFscSaveAsContactPluginImpl::ResumeAsync( |
|
661 TUid aActionUid, |
|
662 MFscContactSet& aContactSet, |
|
663 TBool aIsExecute ) |
|
664 { |
|
665 FUNC_LOG; |
|
666 TInt err( KErrNone ); |
|
667 if ( aIsExecute ) |
|
668 { |
|
669 TRAP( err, ExecuteL( aActionUid, aContactSet, iPluginObserver ) ); |
|
670 } |
|
671 else |
|
672 { |
|
673 TRAP( err, PriorityForContactSetL(aActionUid, aContactSet, |
|
674 *iActionMenuVisibility, *iOptionsMenuVisibility, |
|
675 iPluginObserver ) ); |
|
676 } |
|
677 |
|
678 if ( err != KErrNone ) |
|
679 { |
|
680 ResetData(); |
|
681 if ( aIsExecute ) |
|
682 { |
|
683 iPluginObserver->ExecuteFailed( err ); |
|
684 } |
|
685 else |
|
686 { |
|
687 iPluginObserver->PriorityForContactSetFailed( err ); |
|
688 } |
|
689 } |
|
690 |
|
691 } |
|
692 |
|
693 // --------------------------------------------------------------------------- |
|
694 // CFscSaveAsContactPluginImpl::ContactOperationCompleted |
|
695 // --------------------------------------------------------------------------- |
|
696 // |
|
697 void CFscSaveAsContactPluginImpl::ContactOperationCompleted( |
|
698 MVPbkContactObserver::TContactOpResult aResult) |
|
699 { |
|
700 FUNC_LOG; |
|
701 TInt err( KErrNone ); |
|
702 switch (aResult.iOpCode) |
|
703 { |
|
704 case EContactLock: |
|
705 { |
|
706 TRAP( err, iNewStoreContact->CommitL( *this ) ); |
|
707 break; |
|
708 } |
|
709 case EContactCommit: |
|
710 { |
|
711 DismissWaitNote(); |
|
712 TRAP( err, iParams.iUtils->ShowCnfNoteL( |
|
713 R_FS_ACTION_SAVED_NOTE ) ); |
|
714 ResetData(); |
|
715 iPluginObserver->ExecuteComplete(); |
|
716 |
|
717 if (iNewStoreContact != NULL) |
|
718 { |
|
719 delete iNewStoreContact; |
|
720 iNewStoreContact = NULL; |
|
721 } |
|
722 break; |
|
723 } |
|
724 case EActionEventCanceled: |
|
725 { |
|
726 iLastEvent = EActionEventIdle; |
|
727 break; |
|
728 } |
|
729 default: |
|
730 { |
|
731 ResetData(); |
|
732 break; |
|
733 } |
|
734 } |
|
735 |
|
736 if ( err != KErrNone ) |
|
737 { |
|
738 ResetData(); |
|
739 if ( iIsExecute ) |
|
740 { |
|
741 iPluginObserver->ExecuteFailed( err ); |
|
742 } |
|
743 else |
|
744 { |
|
745 iPluginObserver->PriorityForContactSetFailed( err ); |
|
746 } |
|
747 } |
|
748 } |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // CFscSaveAsContactPluginImpl::ContactOperationFailed |
|
752 // --------------------------------------------------------------------------- |
|
753 // |
|
754 void CFscSaveAsContactPluginImpl::ContactOperationFailed( |
|
755 MVPbkContactObserver::TContactOp /*aOpCode*/, |
|
756 TInt aErrorCode, |
|
757 TBool /*aErrorNotified*/) |
|
758 { |
|
759 FUNC_LOG; |
|
760 iLastEvent = EActionEventIdle; |
|
761 DismissWaitNote(); |
|
762 ResetData(); |
|
763 iPluginObserver->ExecuteFailed(aErrorCode); |
|
764 } |
|
765 |
|
766 // --------------------------------------------------------------------------- |
|
767 // CFscSaveAsContactPluginImpl::DismissWaitDialog |
|
768 // --------------------------------------------------------------------------- |
|
769 // |
|
770 void CFscSaveAsContactPluginImpl::DismissWaitNote() |
|
771 { |
|
772 FUNC_LOG; |
|
773 if (iWaitDialog != NULL) |
|
774 { |
|
775 TRAPD( err, iWaitDialog->ProcessFinishedL() ); |
|
776 if (err != KErrNone) |
|
777 { |
|
778 delete iWaitDialog; |
|
779 iWaitDialog = NULL; |
|
780 } |
|
781 } |
|
782 } |
|
783 // ======== GLOBAL FUNCTIONS ======== |
|
784 |
|
785 // --------------------------------------------------------------------------- |
|
786 // ImplementationGroupProxy |
|
787 // --------------------------------------------------------------------------- |
|
788 // |
|
789 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
790 TInt& aTableCount ) |
|
791 { |
|
792 aTableCount = |
|
793 sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
794 return ImplementationTable; |
|
795 } |
|
796 |