|
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 CFscSendPluginImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <ecom/implementationproxy.h> |
|
21 #include <bautils.h> |
|
22 #include <CMessageData.h> |
|
23 #include <sendui.h> |
|
24 #include <sysutil.h> |
|
25 #include <SenduiMtmUids.h> |
|
26 #include <TSendingCapabilities.h> |
|
27 #include <AknQueryDialog.h> |
|
28 #include <AknsConstants.h> |
|
29 #include <RPbkViewResourceFile.h> |
|
30 //<cmail> |
|
31 #include "mfsccontactset.h" |
|
32 #include "mfscactionutils.h" |
|
33 #include <FscActionUtils.rsg> |
|
34 #include <fscsendplugin.rsg> |
|
35 #include <fscsendplugin.mbg> |
|
36 #include "cfsccontactaction.h" |
|
37 #include <StringLoader.h> |
|
38 #include <featmgr.h> |
|
39 #include "fsccontactactionserviceuids.hrh" |
|
40 #include "mfsccontactactionpluginobserver.h" |
|
41 //</cmail> |
|
42 #include <MVPbkStoreContact.h> |
|
43 #include <MVPbkContactStore.h> |
|
44 #include <MVPbkContactGroup.h> |
|
45 #include <MVPbkContactLinkArray.h> |
|
46 #include <CVPbkContactManager.h> |
|
47 #include <CVPbkContactIdConverter.h> |
|
48 |
|
49 #include "fscactionpluginactionuids.h" |
|
50 #include "cfscsendpluginimpl.h" |
|
51 #include "cfscattachmentfile.h" |
|
52 #include "fscactionplugincrkeys.h" |
|
53 |
|
54 // CONSTANTS DECLARATIONS |
|
55 |
|
56 |
|
57 // <cmail> flag not needed here |
|
58 |
|
59 const TInt KMaxContactIdStringLength = 10; |
|
60 const TInt KMsgSpaceEstimationBytes = 10240; |
|
61 const TInt KMaxLenghtOfAddressData = 255; |
|
62 |
|
63 const TUid KCRUidUniEditor = {0x102072E5}; |
|
64 const TUint32 KUniEditorMaxRecipientCount = 0x00000002; |
|
65 const TUint32 KUniEditorSoftLimitRecipientCount = 0x00000003; |
|
66 |
|
67 const TInt KDefaultSmsRecipients = 20; |
|
68 const TInt KDefaultMmsRecipients = 100; |
|
69 const TInt KDefaultEmailRecipients = KMaxTInt; |
|
70 |
|
71 const TInt KActionCount = 4; |
|
72 const TInt KInvalidReasonId = 0; |
|
73 //const TInt KContactListGranularity = 2; |
|
74 |
|
75 _LIT( KSendPluginIconPath, "\\resource\\apps\\fscsendplugin.mif" ); |
|
76 _LIT( KResourceFilePath, "\\resource\\apps\\fscsendplugin.rsc"); |
|
77 |
|
78 // typedef declarations |
|
79 typedef TBuf<KMaxLenghtOfAddressData> TAddressData; |
|
80 |
|
81 |
|
82 const TImplementationProxy ImplementationTable[] = |
|
83 { |
|
84 IMPLEMENTATION_PROXY_ENTRY( |
|
85 KFscSendPluginImplImpUid, |
|
86 CFscSendPluginImpl::NewL ) |
|
87 }; |
|
88 |
|
89 // ======== MEMBER FUNCTIONS ======== |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CFscSendPluginImpl::NewL |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CFscSendPluginImpl* CFscSendPluginImpl::NewL( TAny* aParams ) |
|
96 { |
|
97 FUNC_LOG; |
|
98 |
|
99 TFscContactActionPluginParams* params = |
|
100 reinterpret_cast< TFscContactActionPluginParams* >( aParams ); |
|
101 |
|
102 CFscSendPluginImpl* self = new( ELeave ) CFscSendPluginImpl( *params ); |
|
103 CleanupStack::PushL( self ); |
|
104 self->ConstructL(); |
|
105 CleanupStack::Pop( self ); |
|
106 return self; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CFscSendPluginImpl::~CFscSendPluginImpl |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 CFscSendPluginImpl::~CFscSendPluginImpl() |
|
114 { |
|
115 FUNC_LOG; |
|
116 delete iContactMsgAction; |
|
117 delete iContactAudioMsgAction; |
|
118 // <cmail> flag not needed here |
|
119 delete iContactPostcardAction; |
|
120 |
|
121 delete iContactEmailAction; |
|
122 delete iActionList; |
|
123 delete iAttachmentFile; |
|
124 CCoeEnv::Static()->DeleteResourceFile( iResourceHandle ); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // CFscSendPluginImpl::Uid |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 TUid CFscSendPluginImpl::Uid() const |
|
132 { |
|
133 FUNC_LOG; |
|
134 TUid uid = { KFscSendPluginImplImpUid }; |
|
135 return uid; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CFscSendPluginImpl::ActionList |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 const CArrayFix<TUid>* CFscSendPluginImpl::ActionList() const |
|
143 { |
|
144 FUNC_LOG; |
|
145 return iActionList; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CFscSendPluginImpl::GetActionL |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 const MFscContactAction& CFscSendPluginImpl::GetActionL( |
|
153 TUid aActionUid ) const |
|
154 { |
|
155 FUNC_LOG; |
|
156 |
|
157 const MFscContactAction* action = NULL; |
|
158 |
|
159 if ( aActionUid == KFscActionUidCreateMsg ) |
|
160 { |
|
161 action = iContactMsgAction; |
|
162 } |
|
163 else if ( aActionUid == KFscActionUidCreateAudMsg ) |
|
164 { |
|
165 action = iContactAudioMsgAction; |
|
166 } |
|
167 // <cmail> flag not needed here |
|
168 else if ( aActionUid == KFscActionUidPostcard && |
|
169 iContactPostcardAction != NULL ) |
|
170 { |
|
171 action = iContactPostcardAction; |
|
172 } |
|
173 else if ( aActionUid == KFscActionUidEmail ) |
|
174 { |
|
175 action = iContactEmailAction; |
|
176 } |
|
177 else |
|
178 { |
|
179 User::Leave( KErrNotFound ); |
|
180 } |
|
181 |
|
182 return *action; |
|
183 } |
|
184 |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // CFscSendPluginImpl::PriorityForContactSetL |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CFscSendPluginImpl::PriorityForContactSetL( |
|
191 TUid aActionUid, |
|
192 MFscContactSet& aContactSet, |
|
193 TFscContactActionVisibility& aActionMenuVisibility, |
|
194 TFscContactActionVisibility& aOptionsMenuVisibility, |
|
195 MFscContactActionPluginObserver* aObserver ) |
|
196 { |
|
197 FUNC_LOG; |
|
198 |
|
199 switch(iLastEvent) |
|
200 { |
|
201 case EActionEventIdle: |
|
202 { |
|
203 iActionUid = aActionUid; |
|
204 iContactSet = &aContactSet; |
|
205 iActionMenuVisibility = &aActionMenuVisibility; |
|
206 iOptionsMenuVisibility = &aOptionsMenuVisibility; |
|
207 iPluginObserver = aObserver; |
|
208 |
|
209 iIsExecute = EFalse; |
|
210 iActionPriority = KFscActionPriorityNotAvailable; |
|
211 |
|
212 iContactSet->SetToFirstContact(); |
|
213 iContactSet->SetToFirstGroup(); |
|
214 |
|
215 iLastEvent = EActionEventCanExecuteLaunched; |
|
216 CanExecuteL( aActionUid, aContactSet ); |
|
217 |
|
218 break; |
|
219 } |
|
220 case EActionEventCanExecuteFinished: |
|
221 { |
|
222 |
|
223 if ( iCanDisplay == KErrNone ) |
|
224 { |
|
225 aActionMenuVisibility.iVisibility = |
|
226 TFscContactActionVisibility::EFscActionVisible; |
|
227 aOptionsMenuVisibility.iVisibility = |
|
228 TFscContactActionVisibility::EFscActionVisible; |
|
229 |
|
230 if ( aActionUid == KFscActionUidCreateMsg ) |
|
231 { |
|
232 iActionPriority = iParams.iUtils->ActionPriority( |
|
233 KFscCrUidCreateMsg, |
|
234 KFscActionPrioritySendMsg ); |
|
235 } |
|
236 else if ( aActionUid == KFscActionUidCreateAudMsg ) |
|
237 { |
|
238 iActionPriority = iParams.iUtils->ActionPriority( |
|
239 KFscCrUidCreateAudMsg, |
|
240 KFscActionPrioritySendAudio ); |
|
241 } |
|
242 else if ( aActionUid == KFscActionUidPostcard ) |
|
243 { |
|
244 //</cmail> |
|
245 if ( FeatureManager::FeatureSupported( KFeatureIdMmsPostcard ) ) |
|
246 { |
|
247 iActionPriority = iParams.iUtils->ActionPriority( |
|
248 KFscCrUidPostcard, KFscActionPrioritySendPostcard ); |
|
249 } |
|
250 } |
|
251 //</cmail> |
|
252 else if ( aActionUid == KFscActionUidEmail ) |
|
253 { |
|
254 iActionPriority = iParams.iUtils->ActionPriority( |
|
255 KFscCrUidEmail, |
|
256 KFscActionPrioritySendEmail ); |
|
257 } |
|
258 // no else. already checked in CanExecuteL() |
|
259 |
|
260 CheckPriority( aActionUid ); |
|
261 |
|
262 } |
|
263 else |
|
264 { |
|
265 iLastEvent = EActionEventContactAvailableLaunched; |
|
266 ContactAvailableL( aContactSet ); |
|
267 } |
|
268 break; |
|
269 } |
|
270 case EActionEventContactAvailableFinished: |
|
271 { |
|
272 // Message is Visible in Options menu even if phone number isn't available |
|
273 if ( aActionUid == KFscActionUidCreateMsg && |
|
274 iIsContactAvailable ) |
|
275 { |
|
276 aOptionsMenuVisibility.iVisibility = |
|
277 TFscContactActionVisibility::EFscActionVisible; |
|
278 aActionMenuVisibility.iVisibility = |
|
279 TFscContactActionVisibility::EFscActionHidden; |
|
280 aActionMenuVisibility.iReasonId = KInvalidReasonId; |
|
281 |
|
282 iActionPriority = iParams.iUtils->ActionPriority( |
|
283 KFscCrUidCreateMsg, |
|
284 KFscActionPrioritySendMsg ); |
|
285 } |
|
286 else |
|
287 { |
|
288 iActionPriority = KFscActionPriorityNotAvailable; |
|
289 aActionMenuVisibility.iVisibility = |
|
290 TFscContactActionVisibility::EFscActionHidden; |
|
291 aActionMenuVisibility.iReasonId = KInvalidReasonId; |
|
292 aOptionsMenuVisibility.iVisibility = |
|
293 TFscContactActionVisibility::EFscActionHidden; |
|
294 aOptionsMenuVisibility.iReasonId = KInvalidReasonId; |
|
295 } |
|
296 |
|
297 CheckPriority( aActionUid ); |
|
298 break; |
|
299 } |
|
300 case EActionEventCanceled: |
|
301 { |
|
302 iLastEvent = EActionEventIdle; |
|
303 break; |
|
304 } |
|
305 default: |
|
306 { |
|
307 ResetData(); |
|
308 break; // <cmail> |
|
309 } |
|
310 } |
|
311 } |
|
312 |
|
313 // --------------------------------------------------------------------------- |
|
314 // CFscSendPluginImpl::ExecuteL |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 void CFscSendPluginImpl::ExecuteL( |
|
318 TUid aActionUid, |
|
319 MFscContactSet& aContactSet, |
|
320 MFscContactActionPluginObserver* aObserver ) |
|
321 { |
|
322 FUNC_LOG; |
|
323 |
|
324 switch ( iLastEvent ) |
|
325 { |
|
326 case EActionEventIdle: |
|
327 { |
|
328 |
|
329 iActionUid = aActionUid; |
|
330 iContactSet = &aContactSet; |
|
331 iPluginObserver = aObserver; |
|
332 |
|
333 iIsExecute = ETrue; |
|
334 |
|
335 iContactSet->SetToFirstContact(); |
|
336 iContactSet->SetToFirstGroup(); |
|
337 |
|
338 iGroupIteratorPosition = 1; |
|
339 iGroupMembersCount = 0; |
|
340 iGroupMemberIndex = 0; |
|
341 |
|
342 iMaxRecipients = MaxMsgRecipientsL(); |
|
343 |
|
344 iAddressList = CMessageData::NewL(); |
|
345 |
|
346 if( aContactSet.HasNextContact() ) |
|
347 { |
|
348 iLastEvent = EActionEventExecuteContactRetrieve; |
|
349 aContactSet.NextContactL( this ); |
|
350 } |
|
351 else |
|
352 { |
|
353 if ( aContactSet.HasNextGroup() ) |
|
354 { |
|
355 iLastEvent = EActionEventExecuteGroupRetrieve; |
|
356 aContactSet.NextGroupL( this ); |
|
357 } |
|
358 else |
|
359 { |
|
360 iLastEvent = EActionEventExecuteFinished; |
|
361 ExecuteL( aActionUid, aContactSet, aObserver ); |
|
362 } |
|
363 } |
|
364 |
|
365 break; |
|
366 } |
|
367 case EActionEventExecuteProcessContact: |
|
368 { |
|
369 |
|
370 MVPbkContactLinkArray* linkArray = |
|
371 iRetrievedStoreContact->GroupsJoinedLC(); |
|
372 |
|
373 TBool found = EFalse; |
|
374 |
|
375 if ( aContactSet.GroupCount() > 0 |
|
376 && linkArray->Count() > 0 ) |
|
377 { |
|
378 |
|
379 while ( aContactSet.HasNextGroup() |
|
380 && !found ) |
|
381 { |
|
382 if ( linkArray->Find( *aContactSet.NextGroupLinkL() ) |
|
383 != KErrNotFound ) |
|
384 { |
|
385 found = ETrue; |
|
386 } |
|
387 } |
|
388 |
|
389 aContactSet.SetToFirstGroup(); |
|
390 } |
|
391 |
|
392 CleanupStack::PopAndDestroy(); //linkArray |
|
393 |
|
394 if ( !found ) |
|
395 { |
|
396 if ( aActionUid == KFscActionUidPostcard ) |
|
397 { |
|
398 //</cmail> |
|
399 if ( FeatureManager::FeatureSupported( KFeatureIdMmsPostcard ) ) |
|
400 { |
|
401 AddPostcardContactL( |
|
402 *iAddressList, |
|
403 *iRetrievedStoreContact ); |
|
404 } |
|
405 //</cmail> |
|
406 } |
|
407 else |
|
408 { |
|
409 TInt result = AddContactL( |
|
410 aActionUid, |
|
411 *iAddressList, |
|
412 *iRetrievedStoreContact ); |
|
413 |
|
414 if ( result == KErrCancel ) |
|
415 { |
|
416 // Cancel whole operation |
|
417 ResetData(); |
|
418 aObserver->ExecuteComplete(); |
|
419 break; |
|
420 } |
|
421 else if ( result != KErrNone ) |
|
422 { |
|
423 ++iMissingCount; |
|
424 } |
|
425 } |
|
426 } |
|
427 |
|
428 |
|
429 if ( aContactSet.HasNextContact() ) |
|
430 { |
|
431 iLastEvent = EActionEventExecuteContactRetrieve; |
|
432 aContactSet.NextContactL( this ); |
|
433 } |
|
434 else if ( aContactSet.HasNextGroup() ) |
|
435 { |
|
436 iLastEvent = EActionEventExecuteGroupRetrieve; |
|
437 aContactSet.NextGroupL( this ); |
|
438 } |
|
439 else |
|
440 { |
|
441 iLastEvent = EActionEventExecuteFinished; |
|
442 ExecuteL( aActionUid, aContactSet, aObserver ); |
|
443 } |
|
444 |
|
445 break; |
|
446 } |
|
447 case EActionEventExecuteProcessGroup: |
|
448 { |
|
449 iGroupMembersCount = aContactSet.GroupContactCountL( |
|
450 *iRetrievedStoreGroup ); |
|
451 |
|
452 if ( iGroupMembersCount > 0 ) |
|
453 { |
|
454 iLastEvent = EActionEventExecuteContactRetrieve; |
|
455 aContactSet.GetGroupContactL( *iRetrievedStoreGroup, iGroupMemberIndex++, this ); |
|
456 } |
|
457 else |
|
458 { |
|
459 if ( aContactSet.HasNextGroup() ) |
|
460 { |
|
461 iGroupIteratorPosition++; |
|
462 iLastEvent = EActionEventExecuteGroupRetrieve; |
|
463 aContactSet.NextGroupL( this ); |
|
464 } |
|
465 else |
|
466 { |
|
467 iLastEvent = EActionEventExecuteFinished; |
|
468 ExecuteL( aActionUid, aContactSet, aObserver ); |
|
469 } |
|
470 } |
|
471 |
|
472 break; |
|
473 } |
|
474 case EActionEventExecuteProcessGroupMember: |
|
475 { |
|
476 |
|
477 if ( !IsAnyGroupMemberL( *iRetrievedGroupMember ) ) |
|
478 { |
|
479 TInt result = AddContactL( |
|
480 aActionUid, |
|
481 *iAddressList, |
|
482 *iRetrievedGroupMember ); |
|
483 |
|
484 if ( result == KErrCancel ) |
|
485 { |
|
486 // Cancel whole operation |
|
487 ResetData(); |
|
488 aObserver->ExecuteComplete(); |
|
489 break; |
|
490 } |
|
491 else if ( result != KErrNone ) |
|
492 { |
|
493 ++iMissingCount; |
|
494 } |
|
495 } |
|
496 |
|
497 delete iRetrievedGroupMember; |
|
498 iRetrievedGroupMember = NULL; |
|
499 |
|
500 if ( iGroupMemberIndex < iGroupMembersCount ) |
|
501 { |
|
502 iLastEvent = EActionEventExecuteContactRetrieve; |
|
503 aContactSet.GetGroupContactL( *iRetrievedStoreGroup, iGroupMemberIndex++, this ); |
|
504 } |
|
505 else if ( aContactSet.HasNextGroup() ) |
|
506 { |
|
507 iGroupMemberIndex = 0; |
|
508 iGroupMembersCount = 0; |
|
509 iGroupIteratorPosition++; |
|
510 iLastEvent = EActionEventExecuteGroupRetrieve; |
|
511 aContactSet.NextGroupL( this ); |
|
512 } |
|
513 else |
|
514 { |
|
515 iLastEvent = EActionEventExecuteFinished; |
|
516 ExecuteL( aActionUid, aContactSet, aObserver ); |
|
517 } |
|
518 |
|
519 break; |
|
520 } |
|
521 case EActionEventExecuteFinished: |
|
522 { |
|
523 |
|
524 if ( aContactSet.ContactCount() == 1 |
|
525 && aContactSet.GroupCount() == 0 |
|
526 && iMissingCount == 1 ) |
|
527 { |
|
528 //if only one contact available and without |
|
529 //proper contact information |
|
530 HBufC* contactName = iParams.iUtils->GetContactNameL( *iRetrievedStoreContact ); |
|
531 CleanupStack::PushL(contactName); |
|
532 |
|
533 TInt note = R_QTN_FS_NOTE_NO_MSG_TO_NAME; |
|
534 |
|
535 iParams.iUtils->ShowInfoNoteL( |
|
536 note, |
|
537 contactName ); |
|
538 |
|
539 CleanupStack::PopAndDestroy( contactName ); |
|
540 } |
|
541 else if ( iMissingCount > 0 |
|
542 && !iParams.iUtils->ShowNumberMissingNoteL( |
|
543 iMissingCount, |
|
544 ( iAddressList->ToAddressArray().Count() + iMissingCount ), |
|
545 R_FS_NOTE_NUMBER_MISSING, |
|
546 R_FS_NUMBER_MISSING_QUERY_DIALOG ) ) |
|
547 { |
|
548 //Fix for: EJKA-7KAEVA |
|
549 ResetData(); |
|
550 aObserver->ExecuteFailed( KErrCancel ); |
|
551 break; |
|
552 } |
|
553 else |
|
554 { |
|
555 if ( iRecipientsCounter <= iMaxRecipients ) |
|
556 { |
|
557 SendToSelectedMembersL( aActionUid, iAddressList ); |
|
558 } |
|
559 else if ( iRecipientsCounter == iMaxRecipients + 1 ) |
|
560 { |
|
561 TInt note = R_QTN_MAX_RECIPIENTS_EXCEEDED_1; |
|
562 HBufC *emptyBuf = NULL; |
|
563 iParams.iUtils->ShowInfoNoteL( |
|
564 note, |
|
565 emptyBuf ); |
|
566 } |
|
567 else |
|
568 { |
|
569 TInt note = R_QTN_MAX_RECIPIENTS_EXCEEDED_MANY; |
|
570 iParams.iUtils->ShowInfoNoteL( |
|
571 note, |
|
572 iRecipientsCounter - iMaxRecipients ); |
|
573 } |
|
574 } |
|
575 |
|
576 ResetData(); |
|
577 aObserver->ExecuteComplete(); |
|
578 break; |
|
579 } |
|
580 case EActionEventCanceled: |
|
581 { |
|
582 iLastEvent = EActionEventIdle; |
|
583 break; |
|
584 } |
|
585 default: |
|
586 { |
|
587 ResetData(); |
|
588 break; // <cmail> |
|
589 } |
|
590 } |
|
591 |
|
592 } |
|
593 |
|
594 |
|
595 // --------------------------------------------------------------------------- |
|
596 // CFscSendPluginImpl::GetReasonL |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 void CFscSendPluginImpl::GetReasonL( |
|
600 TUid /* aActionUid */, |
|
601 TInt /* aReasonId */, |
|
602 HBufC*& /* aReason */) const |
|
603 { |
|
604 FUNC_LOG; |
|
605 } |
|
606 |
|
607 // --------------------------------------------------------------------------- |
|
608 // CFscSendPluginImpl::SendToSelectedMembersL |
|
609 // --------------------------------------------------------------------------- |
|
610 // |
|
611 void CFscSendPluginImpl::SendToSelectedMembersL( |
|
612 TUid aActionUid, |
|
613 const CMessageData* aAddressList ) |
|
614 { |
|
615 FUNC_LOG; |
|
616 // Check from sys utils that the flash drive |
|
617 // is not on critical level before creating a message. |
|
618 TBool flashOnCL = |
|
619 SysUtil::FFSSpaceBelowCriticalLevelL( |
|
620 &CCoeEnv::Static()->FsSession(), |
|
621 KMsgSpaceEstimationBytes ); |
|
622 if ( flashOnCL ) |
|
623 { |
|
624 User::Leave( KErrNoMemory ); |
|
625 } |
|
626 |
|
627 CSendUi* sendUi = CSendUi::NewLC(); |
|
628 TUid messageType = KSenduiMtmUniMessageUid; |
|
629 if ( aActionUid == KFscActionUidCreateMsg ) |
|
630 { |
|
631 messageType = KSenduiMtmUniMessageUid; |
|
632 } |
|
633 else if ( aActionUid == KFscActionUidCreateAudMsg ) |
|
634 { |
|
635 messageType = KSenduiMtmAudioMessageUid; |
|
636 } |
|
637 // <cmail> flag not needed here |
|
638 else if ( aActionUid == KFscActionUidPostcard && |
|
639 iContactPostcardAction != NULL ) |
|
640 { |
|
641 messageType = KSenduiMtmPostcardUid; |
|
642 } |
|
643 else if ( aActionUid == KFscActionUidEmail ) |
|
644 { |
|
645 messageType = KSenduiMtmSmtpUid; |
|
646 } |
|
647 else |
|
648 { |
|
649 User::Leave( KErrArgument ); |
|
650 } |
|
651 |
|
652 sendUi->CreateAndSendMessageL( |
|
653 messageType, |
|
654 aAddressList, KNullUid, EFalse ); |
|
655 |
|
656 CleanupStack::PopAndDestroy( sendUi ); |
|
657 } |
|
658 |
|
659 // --------------------------------------------------------------------------- |
|
660 // CFscSendPluginImpl::ContactAvailableL |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 void CFscSendPluginImpl::ContactAvailableL( MFscContactSet& aContactSet ) |
|
664 { |
|
665 FUNC_LOG; |
|
666 |
|
667 switch ( iLastEvent ) |
|
668 { |
|
669 case EActionEventContactAvailableLaunched: |
|
670 { |
|
671 if ( aContactSet.ContactCount() > 0 ) |
|
672 { |
|
673 iIsContactAvailable = ETrue; |
|
674 iLastEvent = EActionEventContactAvailableFinished; |
|
675 PriorityForContactSetL( |
|
676 iActionUid, |
|
677 aContactSet, |
|
678 *iActionMenuVisibility, |
|
679 *iOptionsMenuVisibility, |
|
680 iPluginObserver ); |
|
681 } |
|
682 else |
|
683 { |
|
684 aContactSet.SetToFirstContact(); |
|
685 aContactSet.SetToFirstGroup(); |
|
686 |
|
687 if ( aContactSet.HasNextGroup() |
|
688 && iIsContactAvailable == EFalse ) |
|
689 { |
|
690 iLastEvent = EActionEventContactAvailableContactRetrieve; |
|
691 aContactSet.NextGroupL( this ); |
|
692 } |
|
693 else |
|
694 { |
|
695 iLastEvent = EActionEventContactAvailableFinished; |
|
696 PriorityForContactSetL( |
|
697 iActionUid, |
|
698 aContactSet, |
|
699 *iActionMenuVisibility, |
|
700 *iOptionsMenuVisibility, |
|
701 iPluginObserver ); |
|
702 } |
|
703 } |
|
704 break; |
|
705 } |
|
706 case EActionEventContactAvailableProcess: |
|
707 { |
|
708 if ( aContactSet.GroupContactCountL( *iRetrievedStoreGroup ) > 0 ) |
|
709 { |
|
710 iIsContactAvailable = ETrue; |
|
711 iLastEvent = EActionEventContactAvailableFinished; |
|
712 PriorityForContactSetL( |
|
713 iActionUid, |
|
714 aContactSet, |
|
715 *iActionMenuVisibility, |
|
716 *iOptionsMenuVisibility, |
|
717 iPluginObserver ); |
|
718 } |
|
719 else |
|
720 { |
|
721 if ( aContactSet.HasNextGroup() |
|
722 && iIsContactAvailable == EFalse ) |
|
723 { |
|
724 iLastEvent = EActionEventContactAvailableContactRetrieve; |
|
725 aContactSet.NextGroupL( this ); |
|
726 } |
|
727 else |
|
728 { |
|
729 iLastEvent = EActionEventContactAvailableFinished; |
|
730 PriorityForContactSetL( |
|
731 iActionUid, |
|
732 aContactSet, |
|
733 *iActionMenuVisibility, |
|
734 *iOptionsMenuVisibility, |
|
735 iPluginObserver ); |
|
736 } |
|
737 } |
|
738 break; |
|
739 } |
|
740 case EActionEventCanceled: |
|
741 { |
|
742 iLastEvent = EActionEventIdle; |
|
743 break; |
|
744 } |
|
745 default: |
|
746 { |
|
747 ResetData(); |
|
748 break; // <cmail> |
|
749 } |
|
750 } |
|
751 } |
|
752 |
|
753 // --------------------------------------------------------------------------- |
|
754 // CFscSendPluginImpl::CanExecuteL |
|
755 // --------------------------------------------------------------------------- |
|
756 // |
|
757 void CFscSendPluginImpl::CanExecuteL( |
|
758 TUid aActionUid, |
|
759 MFscContactSet& aContactSet ) |
|
760 { |
|
761 FUNC_LOG; |
|
762 |
|
763 switch( iLastEvent ) |
|
764 { |
|
765 case EActionEventCanExecuteLaunched: |
|
766 { |
|
767 |
|
768 iCanDisplay = KErrArgument; |
|
769 iNumberType = ETypeInvalid; |
|
770 if ( ( aActionUid == KFscActionUidCreateMsg ) || |
|
771 ( aActionUid == KFscActionUidCreateAudMsg ) ) |
|
772 { |
|
773 iNumberType = ETypeMsgAddress; |
|
774 } |
|
775 // <cmail> flag not needed here |
|
776 else if ( aActionUid == KFscActionUidPostcard && |
|
777 iContactPostcardAction ) |
|
778 { |
|
779 iNumberType = ETypeInvalid; |
|
780 } |
|
781 else if ( aActionUid == KFscActionUidEmail ) |
|
782 { |
|
783 iNumberType = ETypeEmailAddress; |
|
784 } |
|
785 else |
|
786 { |
|
787 User::Leave( KErrArgument ); |
|
788 } |
|
789 |
|
790 if ( aContactSet.HasNextContact() |
|
791 && iCanDisplay != KErrNone ) |
|
792 { |
|
793 iLastEvent = EActionEventCanExecuteContactRetrieve; |
|
794 aContactSet.NextContactL( this ); |
|
795 } |
|
796 else |
|
797 { |
|
798 if ( aContactSet.HasNextGroup() |
|
799 && iCanDisplay != KErrNone ) |
|
800 { |
|
801 iLastEvent = EActionEventCanExecuteGroupRetrieve; |
|
802 aContactSet.NextGroupL( this ); |
|
803 } |
|
804 else |
|
805 { |
|
806 iLastEvent = EActionEventCanExecuteFinished; |
|
807 CanExecuteL( aActionUid, aContactSet ); |
|
808 } |
|
809 } |
|
810 |
|
811 break; |
|
812 } |
|
813 case EActionEventCanExecuteProcessContact: |
|
814 { |
|
815 if ( aActionUid == KFscActionUidPostcard && |
|
816 aContactSet.ContactCount() == 1 && |
|
817 aContactSet.GroupCount() == 0 ) |
|
818 { |
|
819 //</cmail> |
|
820 if ( FeatureManager::FeatureSupported( KFeatureIdMmsPostcard ) ) |
|
821 { |
|
822 //verify if contact has valid store - needed for attachement |
|
823 MVPbkContactStore* contactStore = &iRetrievedStoreContact->ContactStore(); |
|
824 if ( contactStore ) |
|
825 { |
|
826 iLastEvent = EActionEventCanExecuteFinished; |
|
827 iCanDisplay = KErrNone; |
|
828 CanExecuteL( aActionUid, aContactSet ); |
|
829 } |
|
830 } |
|
831 } |
|
832 //</cmail> |
|
833 if ( iParams.iUtils->IsContactNumberAvailableL( |
|
834 *iRetrievedStoreContact, iNumberType )) |
|
835 { |
|
836 iLastEvent = EActionEventCanExecuteFinished; |
|
837 iCanDisplay = KErrNone; |
|
838 CanExecuteL( aActionUid, aContactSet ); |
|
839 } |
|
840 else if ( aContactSet.HasNextContact() |
|
841 && iCanDisplay != KErrNone ) |
|
842 { |
|
843 iLastEvent = EActionEventCanExecuteContactRetrieve; |
|
844 aContactSet.NextContactL( this ); |
|
845 } |
|
846 else if (aContactSet.HasNextGroup() ) |
|
847 { |
|
848 iLastEvent = EActionEventCanExecuteGroupRetrieve; |
|
849 aContactSet.NextGroupL( this); |
|
850 } |
|
851 else |
|
852 { |
|
853 iLastEvent = EActionEventCanExecuteFinished; |
|
854 CanExecuteL( aActionUid, aContactSet ); |
|
855 } |
|
856 break; |
|
857 } |
|
858 case EActionEventCanExecuteProcessGroup: |
|
859 { |
|
860 MVPbkContactGroup* group = iRetrievedStoreGroup->Group(); |
|
861 if ( group |
|
862 && aContactSet.GroupContactCountL( |
|
863 *iRetrievedStoreGroup )>0 ) |
|
864 { |
|
865 iGroupMembersCount = |
|
866 aContactSet.GroupContactCountL( *iRetrievedStoreGroup ); |
|
867 iLastEvent = EActionEventCanExecuteContactRetrieve; |
|
868 aContactSet.GetGroupContactL( |
|
869 *iRetrievedStoreGroup, iGroupMemberIndex++, this ); |
|
870 } |
|
871 else |
|
872 { |
|
873 iLastEvent = EActionEventCanExecuteFinished; |
|
874 CanExecuteL( aActionUid, aContactSet ); |
|
875 } |
|
876 break; |
|
877 } |
|
878 case EActionEventCanExecuteProcessGroupMember: |
|
879 { |
|
880 |
|
881 if ( iParams.iUtils->IsContactNumberAvailableL( |
|
882 *iRetrievedGroupMember, iNumberType ) |
|
883 && aActionUid != KFscActionUidPostcard ) |
|
884 { |
|
885 iLastEvent = EActionEventCanExecuteFinished; |
|
886 iCanDisplay = KErrNone; // atleast one number avaialble |
|
887 delete iRetrievedGroupMember; |
|
888 iRetrievedGroupMember = NULL; |
|
889 CanExecuteL( aActionUid, aContactSet ); |
|
890 } |
|
891 else |
|
892 { |
|
893 delete iRetrievedGroupMember; |
|
894 iRetrievedGroupMember = NULL; |
|
895 if ( iGroupMemberIndex < iGroupMembersCount ) |
|
896 { |
|
897 iLastEvent = EActionEventCanExecuteContactRetrieve; |
|
898 aContactSet.GetGroupContactL( *iRetrievedStoreGroup, |
|
899 iGroupMemberIndex++, this ); |
|
900 } |
|
901 else |
|
902 { |
|
903 if ( aContactSet.HasNextGroup() |
|
904 && iCanDisplay != KErrNone ) |
|
905 { |
|
906 iGroupMemberIndex = 0; |
|
907 iGroupMembersCount = 0; |
|
908 iLastEvent = EActionEventCanExecuteGroupRetrieve; |
|
909 aContactSet.NextGroupL(this); |
|
910 } |
|
911 else |
|
912 { |
|
913 iLastEvent = EActionEventCanExecuteFinished; |
|
914 CanExecuteL( aActionUid, aContactSet ); |
|
915 } |
|
916 } |
|
917 } |
|
918 |
|
919 break; |
|
920 } |
|
921 case EActionEventCanExecuteFinished: |
|
922 { |
|
923 PriorityForContactSetL( |
|
924 iActionUid, |
|
925 aContactSet, |
|
926 *iActionMenuVisibility, |
|
927 *iOptionsMenuVisibility, |
|
928 iPluginObserver ); |
|
929 break; |
|
930 } |
|
931 case EActionEventCanceled: |
|
932 { |
|
933 iLastEvent = EActionEventIdle; |
|
934 break; |
|
935 } |
|
936 default: |
|
937 { |
|
938 ResetData(); |
|
939 break; // <cmail> |
|
940 } |
|
941 } |
|
942 |
|
943 } |
|
944 |
|
945 // --------------------------------------------------------------------------- |
|
946 // CFscSendPluginImpl::UpdateActionIconL |
|
947 // --------------------------------------------------------------------------- |
|
948 // |
|
949 void CFscSendPluginImpl::UpdateActionIconL( TUid aActionUid ) |
|
950 { |
|
951 FUNC_LOG; |
|
952 |
|
953 TFileName dllFileName; |
|
954 Dll::FileName( dllFileName ); |
|
955 TParse parse; |
|
956 User::LeaveIfError( |
|
957 parse.Set( KSendPluginIconPath, &dllFileName, NULL ) ); |
|
958 |
|
959 // <cmail> icons changed |
|
960 if ( aActionUid == KFscActionUidCreateMsg ) |
|
961 { |
|
962 iContactMsgAction->SetIcon( iParams.iUtils->SkinIconL( |
|
963 KAknsIIDQgnFsActionMsg, |
|
964 parse.FullName(), |
|
965 EMbmFscsendpluginQgn_prop_cmail_action_msg, |
|
966 EMbmFscsendpluginQgn_prop_cmail_action_msg_mask ) ); |
|
967 } |
|
968 |
|
969 else if ( aActionUid == KFscActionUidCreateAudMsg ) |
|
970 { |
|
971 iContactAudioMsgAction->SetIcon( iParams.iUtils->SkinIconL( |
|
972 KAknsIIDQgnFsActionAudio, |
|
973 parse.FullName(), |
|
974 EMbmFscsendpluginQgn_prop_cmail_action_audio, |
|
975 EMbmFscsendpluginQgn_prop_cmail_action_audio_mask ) ); |
|
976 } |
|
977 else if ( aActionUid == KFscActionUidPostcard ) |
|
978 { |
|
979 //</cmail> |
|
980 if ( FeatureManager::FeatureSupported( KFeatureIdMmsPostcard ) ) |
|
981 { |
|
982 iContactPostcardAction->SetIcon( iParams.iUtils->SkinIconL( |
|
983 KAknsIIDQgnFsActionPostcard, |
|
984 parse.FullName(), |
|
985 EMbmFscsendpluginQgn_prop_cmail_action_postcard, |
|
986 EMbmFscsendpluginQgn_prop_cmail_action_postcard_mask ) ); |
|
987 } |
|
988 } |
|
989 //</cmail> |
|
990 else if ( aActionUid == KFscActionUidEmail ) |
|
991 { |
|
992 iContactEmailAction->SetIcon( iParams.iUtils->SkinIconL( |
|
993 KAknsIIDQgnFsActionEmail, |
|
994 parse.FullName(), |
|
995 EMbmFscsendpluginQgn_prop_cmail_action_email, |
|
996 EMbmFscsendpluginQgn_prop_cmail_action_email_mask ) ); |
|
997 } |
|
998 // </cmail> |
|
999 } |
|
1000 |
|
1001 |
|
1002 // --------------------------------------------------------------------------- |
|
1003 // CFscSendPluginImpl::AddContactL |
|
1004 // --------------------------------------------------------------------------- |
|
1005 // |
|
1006 TInt CFscSendPluginImpl::AddContactL( |
|
1007 TUid aActionUid, |
|
1008 CMessageData& aAddressList, |
|
1009 MVPbkStoreContact& aContact ) |
|
1010 { |
|
1011 FUNC_LOG; |
|
1012 |
|
1013 TAddressData addressData; |
|
1014 TInt ret = KErrNotFound; |
|
1015 |
|
1016 if ( aActionUid == KFscActionUidEmail ) |
|
1017 { |
|
1018 ret = iParams.iUtils->GetEmailAddressL( |
|
1019 aContact, addressData ); |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 ret = iParams.iUtils->GetMessageAddressL( |
|
1024 aContact, addressData ); |
|
1025 } |
|
1026 |
|
1027 if ( ret == KErrNone && addressData.Length() > 0 ) |
|
1028 { |
|
1029 // no need to check for duplicate addresses |
|
1030 HBufC* contactName = iParams.iUtils->GetContactNameL( |
|
1031 aContact ); |
|
1032 CleanupStack::PushL( contactName ); |
|
1033 aAddressList.AppendToAddressL( |
|
1034 addressData, *contactName ); |
|
1035 CleanupStack::PopAndDestroy( contactName ); |
|
1036 iRecipientsCounter++; |
|
1037 } |
|
1038 |
|
1039 return ret; |
|
1040 } |
|
1041 |
|
1042 // <cmail> ENABLE_POSTCARD_ACTION flag not needed |
|
1043 // --------------------------------------------------------------------------- |
|
1044 // CFscSendPluginImpl::AddPostcardContactL |
|
1045 // --------------------------------------------------------------------------- |
|
1046 // |
|
1047 void CFscSendPluginImpl::AddPostcardContactL( |
|
1048 CMessageData& aMessageData, |
|
1049 const MVPbkStoreContact& aContact ) |
|
1050 { |
|
1051 FUNC_LOG; |
|
1052 MVPbkContactStore* store = &aContact.ContactStore(); |
|
1053 if ( store ) |
|
1054 { |
|
1055 // Create attachment file object |
|
1056 delete iAttachmentFile; |
|
1057 iAttachmentFile = NULL; |
|
1058 HBufC* attFileName = |
|
1059 StringLoader::LoadLC( R_FS_POSTCARD_WRITE_ATTACHMENT_TAG ); |
|
1060 iAttachmentFile = CFscAttachmentFile::NewL( |
|
1061 *attFileName, |
|
1062 iParams.iUtils->ContactManager().FsSession(), |
|
1063 EFileWrite | EFileShareAny ); |
|
1064 CleanupStack::PopAndDestroy( attFileName ); |
|
1065 WritePostcardAttachmentContentL( aContact, *iAttachmentFile ); |
|
1066 aMessageData.AppendAttachmentL( |
|
1067 iAttachmentFile->FileName() ); |
|
1068 iAttachmentFile->Release(); |
|
1069 } |
|
1070 |
|
1071 } |
|
1072 |
|
1073 // --------------------------------------------------------------------------- |
|
1074 // CFscSendPluginImpl::WritePostcardAttachmentContentL |
|
1075 // --------------------------------------------------------------------------- |
|
1076 // |
|
1077 void CFscSendPluginImpl::WritePostcardAttachmentContentL( |
|
1078 const MVPbkStoreContact& aContact, |
|
1079 CFscAttachmentFile& aAttachmentFile ) |
|
1080 { |
|
1081 FUNC_LOG; |
|
1082 HBufC* contactId = HBufC::NewLC( KMaxContactIdStringLength ); |
|
1083 MVPbkContactLink* contactLink = aContact.CreateLinkLC(); |
|
1084 |
|
1085 CVPbkContactIdConverter* cntIdCnv = |
|
1086 CVPbkContactIdConverter::NewL( aContact.ContactStore() ); |
|
1087 TContactItemId cntId = cntIdCnv->LinkToIdentifier( *contactLink ); |
|
1088 |
|
1089 delete cntIdCnv; |
|
1090 CleanupStack::PopAndDestroy(); //contactLink |
|
1091 |
|
1092 contactId->Des().Num( cntId ); |
|
1093 HBufC8* string8 = HBufC8::NewLC( KMaxContactIdStringLength ); |
|
1094 string8->Des().Append( *contactId ); |
|
1095 aAttachmentFile.File().Write( *string8 ); |
|
1096 CleanupStack::PopAndDestroy( 2, contactId ); |
|
1097 } |
|
1098 // </cmail> |
|
1099 |
|
1100 // --------------------------------------------------------------------------- |
|
1101 // CFscSendPluginImpl::CFscSendPluginImpl |
|
1102 // --------------------------------------------------------------------------- |
|
1103 // |
|
1104 CFscSendPluginImpl::CFscSendPluginImpl( |
|
1105 const TFscContactActionPluginParams& aParams ) |
|
1106 : CFscContactActionPlugin(), |
|
1107 iParams( aParams ), |
|
1108 iResourceHandle( 0 ) |
|
1109 { |
|
1110 FUNC_LOG; |
|
1111 } |
|
1112 |
|
1113 // --------------------------------------------------------------------------- |
|
1114 // CFscSendPluginImpl::ConstructL |
|
1115 // --------------------------------------------------------------------------- |
|
1116 // |
|
1117 void CFscSendPluginImpl::ConstructL() |
|
1118 { |
|
1119 FUNC_LOG; |
|
1120 TFileName dllFileName; |
|
1121 Dll::FileName( dllFileName ); |
|
1122 TParse parse; |
|
1123 User::LeaveIfError( parse.Set( KResourceFilePath, &dllFileName, NULL ) ); |
|
1124 TFileName resourceFileName( parse.FullName() ); |
|
1125 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), |
|
1126 resourceFileName ); |
|
1127 |
|
1128 iResourceHandle = |
|
1129 ( CCoeEnv::Static() )->AddResourceFileL( resourceFileName ); |
|
1130 |
|
1131 iActionList = new( ELeave ) CArrayFixFlat<TUid>( KActionCount ); |
|
1132 |
|
1133 User::LeaveIfError( |
|
1134 parse.Set( KSendPluginIconPath, &dllFileName, NULL ) ); |
|
1135 |
|
1136 // <cmail> icons changed |
|
1137 iActionList->AppendL( KFscActionUidCreateMsg ); |
|
1138 iContactMsgAction = iParams.iUtils->CreateActionL( |
|
1139 *this, |
|
1140 KFscActionUidCreateMsg, |
|
1141 KFscAtComSendMsg, |
|
1142 R_FS_ACTION_MESSAGE, |
|
1143 iParams.iUtils->SkinIconL( |
|
1144 KAknsIIDQgnFsActionMsg, |
|
1145 parse.FullName(), |
|
1146 EMbmFscsendpluginQgn_prop_cmail_action_msg, |
|
1147 EMbmFscsendpluginQgn_prop_cmail_action_msg_mask ) ); |
|
1148 |
|
1149 iActionList->AppendL( KFscActionUidCreateAudMsg ); |
|
1150 iContactAudioMsgAction = iParams.iUtils->CreateActionL( |
|
1151 *this, |
|
1152 KFscActionUidCreateAudMsg, |
|
1153 KFscAtComSendAudio, |
|
1154 R_FS_ACTION_AUDIO, |
|
1155 iParams.iUtils->SkinIconL( |
|
1156 KAknsIIDQgnFsActionAudio, |
|
1157 parse.FullName(), |
|
1158 EMbmFscsendpluginQgn_prop_cmail_action_audio, |
|
1159 EMbmFscsendpluginQgn_prop_cmail_action_audio_mask ) ); |
|
1160 |
|
1161 // <cmail> flag not needed here |
|
1162 if ( FeatureManager::FeatureSupported( KFeatureIdMmsPostcard ) ) |
|
1163 { |
|
1164 iActionList->AppendL( KFscActionUidPostcard ); |
|
1165 iContactPostcardAction = iParams.iUtils->CreateActionL( |
|
1166 *this, |
|
1167 KFscActionUidPostcard, |
|
1168 KFscAtComSendPostcard, |
|
1169 R_FS_ACTION_POSTCARD, |
|
1170 iParams.iUtils->SkinIconL( |
|
1171 KAknsIIDQgnFsActionPostcard, |
|
1172 parse.FullName(), |
|
1173 EMbmFscsendpluginQgn_prop_cmail_action_postcard, |
|
1174 EMbmFscsendpluginQgn_prop_cmail_action_postcard_mask ) ); |
|
1175 } |
|
1176 // </cmail> |
|
1177 iActionList->AppendL( KFscActionUidEmail ); |
|
1178 iContactEmailAction = iParams.iUtils->CreateActionL( |
|
1179 *this, |
|
1180 KFscActionUidEmail, |
|
1181 KFscAtComSendEmail, |
|
1182 R_FS_ACTION_EMAIL, |
|
1183 iParams.iUtils->SkinIconL( |
|
1184 KAknsIIDQgnFsActionEmail, |
|
1185 parse.FullName(), |
|
1186 EMbmFscsendpluginQgn_prop_cmail_action_email, |
|
1187 EMbmFscsendpluginQgn_prop_cmail_action_email_mask ) ); |
|
1188 // </cmail> |
|
1189 } |
|
1190 |
|
1191 |
|
1192 // --------------------------------------------------------------------------- |
|
1193 // CFscSendPluginImpl::ResetData |
|
1194 // --------------------------------------------------------------------------- |
|
1195 // |
|
1196 void CFscSendPluginImpl::ResetData() |
|
1197 { |
|
1198 FUNC_LOG; |
|
1199 if ( iContactSet ) |
|
1200 { |
|
1201 // <cmail> |
|
1202 TRAP_IGNORE( iContactSet->CancelNextContactL() ); |
|
1203 TRAP_IGNORE( iContactSet->CancelNextGroupL() ); |
|
1204 // </cmail> |
|
1205 iContactSet->SetToFirstContact(); |
|
1206 iContactSet->SetToFirstGroup(); |
|
1207 iContactSet = NULL; |
|
1208 } |
|
1209 |
|
1210 if ( iAddressList ) |
|
1211 { |
|
1212 delete iAddressList; |
|
1213 iAddressList = NULL; |
|
1214 } |
|
1215 |
|
1216 if ( iRetrievedGroupMember ) |
|
1217 { |
|
1218 delete iRetrievedGroupMember; |
|
1219 iRetrievedGroupMember = NULL; |
|
1220 } |
|
1221 |
|
1222 iLastEvent = EActionEventIdle; |
|
1223 iActionMenuVisibility = NULL; |
|
1224 iOptionsMenuVisibility = NULL; |
|
1225 iCanDisplay = KErrNone; |
|
1226 iRetrievedStoreContact = NULL; |
|
1227 iRetrievedStoreGroup = NULL; |
|
1228 iNumberType = ETypeInvalid; |
|
1229 iGroupMembersCount = 0; |
|
1230 iGroupMemberIndex = 0; |
|
1231 iIsContactAvailable = EFalse; |
|
1232 iGroupIteratorPosition = 0; |
|
1233 iMissingCount = 0; |
|
1234 iMaxRecipients = 0; |
|
1235 iRecipientsCounter = 0; |
|
1236 } |
|
1237 |
|
1238 // --------------------------------------------------------------------------- |
|
1239 // CFscSendPluginImpl::CheckPriority |
|
1240 // --------------------------------------------------------------------------- |
|
1241 // |
|
1242 void CFscSendPluginImpl::CheckPriority(TUid aActionUid) |
|
1243 { |
|
1244 FUNC_LOG; |
|
1245 if ( iActionPriority > 0 ) |
|
1246 { |
|
1247 // ignore any leave while updating action icons |
|
1248 TRAP_IGNORE( UpdateActionIconL( aActionUid ) ); |
|
1249 } |
|
1250 ResetData(); |
|
1251 iPluginObserver->PriorityForContactSetComplete(iActionPriority); |
|
1252 } |
|
1253 |
|
1254 // --------------------------------------------------------------------------- |
|
1255 // CFscSendPluginImpl::MoveGroupToIndexL |
|
1256 // --------------------------------------------------------------------------- |
|
1257 // |
|
1258 void CFscSendPluginImpl::MoveGroupToIndexL(MFscContactSet& aContactSet, |
|
1259 TInt aIndex, TInt& aError) |
|
1260 { |
|
1261 FUNC_LOG; |
|
1262 aError = KErrNone; |
|
1263 aContactSet.SetToFirstGroup(); |
|
1264 |
|
1265 if ( aIndex > aContactSet.GroupCount() ) |
|
1266 { |
|
1267 aError = KErrArgument; |
|
1268 } |
|
1269 |
|
1270 //move iterator to specified index |
|
1271 while ( aContactSet.HasNextGroup() |
|
1272 && aIndex-- > 0 ) |
|
1273 { |
|
1274 aContactSet.NextGroupLinkL(); |
|
1275 } |
|
1276 |
|
1277 } |
|
1278 |
|
1279 // --------------------------------------------------------------------------- |
|
1280 // CFscSendPluginImpl::IsAnyGroupMember |
|
1281 // --------------------------------------------------------------------------- |
|
1282 // |
|
1283 TBool CFscSendPluginImpl::IsAnyGroupMemberL( MVPbkStoreContact& aContact ) |
|
1284 { |
|
1285 FUNC_LOG; |
|
1286 MVPbkContactLinkArray* linkArray = aContact.GroupsJoinedLC(); |
|
1287 |
|
1288 TBool found = EFalse; |
|
1289 TInt error = KErrNone; |
|
1290 TBool isChanged = EFalse; |
|
1291 |
|
1292 if ( linkArray->Count() > 1 |
|
1293 && iContactSet->HasNextGroup() ) |
|
1294 { |
|
1295 |
|
1296 while ( iContactSet->HasNextGroup() |
|
1297 && !found ) |
|
1298 { |
|
1299 isChanged = ETrue; |
|
1300 if ( linkArray->Find( *iContactSet->NextGroupLinkL() ) |
|
1301 != KErrNotFound ) |
|
1302 { |
|
1303 found = ETrue; |
|
1304 } |
|
1305 } |
|
1306 |
|
1307 if ( isChanged ) |
|
1308 { |
|
1309 //if iterator moved |
|
1310 MoveGroupToIndexL( *iContactSet, iGroupIteratorPosition , error ); |
|
1311 } |
|
1312 |
|
1313 User::LeaveIfError( error ); |
|
1314 } |
|
1315 |
|
1316 CleanupStack::PopAndDestroy(); //linkArray |
|
1317 return found; |
|
1318 } |
|
1319 |
|
1320 // --------------------------------------------------------------------------- |
|
1321 // CFscSendPluginImpl::NextContactComplete |
|
1322 // --------------------------------------------------------------------------- |
|
1323 // |
|
1324 void CFscSendPluginImpl::NextContactComplete( MVPbkStoreContact* aContact ) |
|
1325 { |
|
1326 FUNC_LOG; |
|
1327 TInt err = KErrNone; |
|
1328 |
|
1329 switch( iLastEvent ) |
|
1330 { |
|
1331 case EActionEventCanExecuteContactRetrieve: |
|
1332 { |
|
1333 iRetrievedStoreContact = aContact; |
|
1334 iLastEvent = EActionEventCanExecuteProcessContact; |
|
1335 TRAP( err, CanExecuteL( iActionUid, *iContactSet ) ); |
|
1336 break; |
|
1337 } |
|
1338 case EActionEventExecuteContactRetrieve: |
|
1339 { |
|
1340 iRetrievedStoreContact = aContact; |
|
1341 iLastEvent = EActionEventExecuteProcessContact; |
|
1342 TRAP( err, ExecuteL( iActionUid, *iContactSet, iPluginObserver ) ); |
|
1343 break; |
|
1344 } |
|
1345 case EActionEventCanceled: |
|
1346 { |
|
1347 iLastEvent = EActionEventIdle; |
|
1348 break; |
|
1349 } |
|
1350 default: |
|
1351 { |
|
1352 ResetData(); |
|
1353 break; // <cmail> |
|
1354 } |
|
1355 } |
|
1356 |
|
1357 if ( err != KErrNone ) |
|
1358 { |
|
1359 ResetData(); |
|
1360 if ( iIsExecute ) |
|
1361 { |
|
1362 iPluginObserver->ExecuteFailed( err ); |
|
1363 } |
|
1364 else |
|
1365 { |
|
1366 iPluginObserver->PriorityForContactSetFailed( err ); |
|
1367 } |
|
1368 } |
|
1369 } |
|
1370 |
|
1371 // --------------------------------------------------------------------------- |
|
1372 // CFscSendPluginImpl::NextContactFailed |
|
1373 // --------------------------------------------------------------------------- |
|
1374 // |
|
1375 void CFscSendPluginImpl::NextContactFailed( TInt aError ) |
|
1376 { |
|
1377 FUNC_LOG; |
|
1378 ResetData(); |
|
1379 if (iIsExecute) |
|
1380 { |
|
1381 iPluginObserver->ExecuteFailed(aError); |
|
1382 } |
|
1383 else |
|
1384 { |
|
1385 iPluginObserver->PriorityForContactSetFailed(aError); |
|
1386 } |
|
1387 } |
|
1388 |
|
1389 // --------------------------------------------------------------------------- |
|
1390 // CFscSendPluginImpl::NextGroupComplete |
|
1391 // --------------------------------------------------------------------------- |
|
1392 // |
|
1393 void CFscSendPluginImpl::NextGroupComplete( MVPbkStoreContact* aContact ) |
|
1394 { |
|
1395 FUNC_LOG; |
|
1396 TInt err = KErrNone; |
|
1397 |
|
1398 switch( iLastEvent ) |
|
1399 { |
|
1400 case EActionEventCanExecuteGroupRetrieve: |
|
1401 { |
|
1402 iLastEvent = EActionEventCanExecuteProcessGroup; |
|
1403 iRetrievedStoreGroup = aContact; |
|
1404 TRAP( err, CanExecuteL( iActionUid, *iContactSet ) ); |
|
1405 break; |
|
1406 } |
|
1407 case EActionEventContactAvailableContactRetrieve: |
|
1408 { |
|
1409 iLastEvent = EActionEventContactAvailableProcess; |
|
1410 iRetrievedStoreGroup = aContact; |
|
1411 TRAP( err, ContactAvailableL( *iContactSet ) ); |
|
1412 break; |
|
1413 } |
|
1414 case EActionEventExecuteGroupRetrieve: |
|
1415 { |
|
1416 iLastEvent = EActionEventExecuteProcessGroup; |
|
1417 iRetrievedStoreGroup = aContact; |
|
1418 TRAP( err, ExecuteL( iActionUid, *iContactSet, iPluginObserver ) ); |
|
1419 break; |
|
1420 } |
|
1421 case EActionEventCanceled: |
|
1422 { |
|
1423 iLastEvent = EActionEventIdle; |
|
1424 break; |
|
1425 } |
|
1426 default: |
|
1427 { |
|
1428 ResetData(); |
|
1429 break; // <cmail> |
|
1430 } |
|
1431 } |
|
1432 |
|
1433 if ( err != KErrNone ) |
|
1434 { |
|
1435 if ( iIsExecute ) |
|
1436 { |
|
1437 iPluginObserver->ExecuteFailed( err ); |
|
1438 } |
|
1439 else |
|
1440 { |
|
1441 iPluginObserver->PriorityForContactSetFailed( err ); |
|
1442 } |
|
1443 } |
|
1444 } |
|
1445 |
|
1446 // --------------------------------------------------------------------------- |
|
1447 // CFscSendPluginImpl::NextGroupFailed |
|
1448 // --------------------------------------------------------------------------- |
|
1449 // |
|
1450 void CFscSendPluginImpl::NextGroupFailed( TInt aError ) |
|
1451 { |
|
1452 FUNC_LOG; |
|
1453 ResetData(); |
|
1454 if ( iIsExecute ) |
|
1455 { |
|
1456 iPluginObserver->ExecuteFailed(aError); |
|
1457 } |
|
1458 else |
|
1459 { |
|
1460 iPluginObserver->PriorityForContactSetFailed(aError); |
|
1461 } |
|
1462 } |
|
1463 |
|
1464 // --------------------------------------------------------------------------- |
|
1465 // CFscSendPluginImpl::GetGroupContactComplete |
|
1466 // --------------------------------------------------------------------------- |
|
1467 // |
|
1468 void CFscSendPluginImpl::GetGroupContactComplete( MVPbkStoreContact* aContact ) |
|
1469 { |
|
1470 FUNC_LOG; |
|
1471 TInt err = KErrNone; |
|
1472 |
|
1473 switch( iLastEvent ) |
|
1474 { |
|
1475 case EActionEventCanExecuteContactRetrieve: |
|
1476 { |
|
1477 iLastEvent = EActionEventCanExecuteProcessGroupMember; |
|
1478 iRetrievedGroupMember = aContact; |
|
1479 TRAP( err, CanExecuteL( iActionUid, *iContactSet ) ); |
|
1480 break; |
|
1481 } |
|
1482 case EActionEventExecuteContactRetrieve: |
|
1483 { |
|
1484 iRetrievedGroupMember = aContact; |
|
1485 iLastEvent = EActionEventExecuteProcessGroupMember; |
|
1486 TRAP( err, ExecuteL( iActionUid, *iContactSet, iPluginObserver ) ); |
|
1487 break; |
|
1488 } |
|
1489 case EActionEventCanceled: |
|
1490 { |
|
1491 iLastEvent = EActionEventIdle; |
|
1492 break; |
|
1493 } |
|
1494 default: |
|
1495 { |
|
1496 ResetData(); |
|
1497 break; // <cmail> |
|
1498 } |
|
1499 } |
|
1500 |
|
1501 if ( err != KErrNone ) |
|
1502 { |
|
1503 if ( iIsExecute ) |
|
1504 { |
|
1505 iPluginObserver->ExecuteFailed( err ); |
|
1506 } |
|
1507 else |
|
1508 { |
|
1509 iPluginObserver->PriorityForContactSetFailed( err ); |
|
1510 } |
|
1511 } |
|
1512 } |
|
1513 |
|
1514 // --------------------------------------------------------------------------- |
|
1515 // CFscSendPluginImpl::GetGroupContactComplete |
|
1516 // --------------------------------------------------------------------------- |
|
1517 // |
|
1518 void CFscSendPluginImpl::GetGroupContactFailed( TInt aError ) |
|
1519 { |
|
1520 FUNC_LOG; |
|
1521 ResetData(); |
|
1522 if ( iIsExecute ) |
|
1523 { |
|
1524 iPluginObserver->ExecuteFailed(aError); |
|
1525 } |
|
1526 else |
|
1527 { |
|
1528 iPluginObserver->PriorityForContactSetFailed(aError); |
|
1529 } |
|
1530 } |
|
1531 |
|
1532 // --------------------------------------------------------------------------- |
|
1533 // CFscSendPluginImpl::CancelPriorityForContactSet |
|
1534 // --------------------------------------------------------------------------- |
|
1535 // |
|
1536 void CFscSendPluginImpl::CancelPriorityForContactSet() |
|
1537 { |
|
1538 FUNC_LOG; |
|
1539 iLastEvent = EActionEventCanceled; |
|
1540 ResetData(); |
|
1541 } |
|
1542 |
|
1543 // --------------------------------------------------------------------------- |
|
1544 // CFscSendPluginImpl::CancelExecute |
|
1545 // --------------------------------------------------------------------------- |
|
1546 // |
|
1547 void CFscSendPluginImpl::CancelExecute() |
|
1548 { |
|
1549 FUNC_LOG; |
|
1550 // close popup window for selecting number if opened |
|
1551 TRAPD( err, iParams.iUtils->CloseSelectDialogL() ); |
|
1552 |
|
1553 if ( err != KErrNone ) |
|
1554 { |
|
1555 CCoeEnv::Static()->HandleError( err ); |
|
1556 } |
|
1557 |
|
1558 // set action |
|
1559 iLastEvent = EActionEventCanceled; |
|
1560 ResetData(); |
|
1561 } |
|
1562 |
|
1563 // --------------------------------------------------------------------------- |
|
1564 // CFscSendPluginImpl::MaxMsgRecipients |
|
1565 // --------------------------------------------------------------------------- |
|
1566 // |
|
1567 TInt CFscSendPluginImpl::MaxMsgRecipientsL() |
|
1568 { |
|
1569 FUNC_LOG; |
|
1570 TInt maxRecipients = 0; |
|
1571 TInt smsRecipients = 0; |
|
1572 TInt mmsRecipients = 0; |
|
1573 |
|
1574 if ( iActionUid == KFscActionUidEmail ) |
|
1575 { |
|
1576 // There should be no limit for the amount of allowed contacts when sending email |
|
1577 maxRecipients = KDefaultEmailRecipients; |
|
1578 } |
|
1579 else |
|
1580 { |
|
1581 CRepository* repository = CRepository::NewL( KCRUidUniEditor ); |
|
1582 CleanupStack::PushL( repository ); |
|
1583 |
|
1584 if ( repository->Get( KUniEditorSoftLimitRecipientCount, smsRecipients ) != KErrNone || |
|
1585 smsRecipients < 1 ) |
|
1586 { |
|
1587 // Unreasonable count, change it back to default value |
|
1588 smsRecipients = KDefaultSmsRecipients; |
|
1589 } |
|
1590 |
|
1591 if ( repository->Get( KUniEditorMaxRecipientCount, mmsRecipients ) != KErrNone || |
|
1592 mmsRecipients < 1 ) |
|
1593 { |
|
1594 // Unreasonable count, change it back to default value |
|
1595 mmsRecipients = KDefaultMmsRecipients; |
|
1596 } |
|
1597 |
|
1598 CleanupStack::PopAndDestroy( repository ); |
|
1599 |
|
1600 if ( smsRecipients > mmsRecipients ) |
|
1601 { |
|
1602 maxRecipients = smsRecipients; |
|
1603 } |
|
1604 else |
|
1605 { |
|
1606 maxRecipients = mmsRecipients; |
|
1607 } |
|
1608 } |
|
1609 |
|
1610 return maxRecipients; |
|
1611 } |
|
1612 |
|
1613 |
|
1614 // ======== GLOBAL FUNCTIONS ======== |
|
1615 |
|
1616 // --------------------------------------------------------------------------- |
|
1617 // ImplementationGroupProxy |
|
1618 // --------------------------------------------------------------------------- |
|
1619 // |
|
1620 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
1621 TInt& aTableCount ) |
|
1622 { |
|
1623 aTableCount = |
|
1624 sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
1625 return ImplementationTable; |
|
1626 } |
|
1627 |