|
1 /* |
|
2 * Copyright (c) 2009 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: This file implements class CEmailMessage. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
19 #include <viewclipartner.h> |
|
20 #include <vwsdefpartner.h> |
|
21 #else |
|
22 #include <viewcli.h> |
|
23 #include <vwsdef.h> |
|
24 #endif // SYMBIAN_ENABLE_SPLIT_HEADERS |
|
25 |
|
26 #include "emailmessage.h" |
|
27 #include "emailaddress.h" |
|
28 #include "emailapiutils.h" |
|
29 #include "emailclientapi.hrh" |
|
30 #include "emailapiutils.h" |
|
31 #include "emailinterfacefactoryimpl.h" |
|
32 #include "emailcontent.h" |
|
33 #include "emailtextcontent.h" |
|
34 #include "emailmultipart.h" |
|
35 #include "emailattachment.h" |
|
36 #include "CFSMailPlugin.h" |
|
37 #include "FreestyleEmailUiConstants.h" |
|
38 #include "CFSMailClient.h" |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 // ----------------------------------------------------------------------------- |
|
43 CEmailMessage* CEmailMessage::NewL( CPluginData& aPluginData, |
|
44 CFSMailMessage* aFsMessage, |
|
45 const TDataOwner aOwner ) |
|
46 { |
|
47 CEmailMessage* message = new ( ELeave ) CEmailMessage( aPluginData, aFsMessage, aOwner ); |
|
48 CleanupStack::PushL( message ); |
|
49 message->ConstructL(); |
|
50 CleanupStack::Pop(); |
|
51 return message; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 CEmailMessage::CEmailMessage( |
|
58 CPluginData& aPluginData, |
|
59 CFSMailMessage *aFsMessage, |
|
60 const TDataOwner aOwner) |
|
61 : iPluginData( aPluginData ), iPluginMessage( aFsMessage ), iOwner( aOwner ) |
|
62 { |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 // ----------------------------------------------------------------------------- |
|
68 void CEmailMessage::ConstructL() |
|
69 { |
|
70 iPlugin = iPluginData.ClaimInstanceL(); |
|
71 if ( iPluginMessage ) |
|
72 { |
|
73 iMessageId = TMessageId( |
|
74 iPluginMessage->GetMessageId().Id(), |
|
75 iPluginMessage->GetFolderId().Id(), |
|
76 iPluginMessage->GetMailBoxId().Id() ); |
|
77 } |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 // ----------------------------------------------------------------------------- |
|
83 CEmailMessage::~CEmailMessage() |
|
84 { |
|
85 delete iPluginMessage; |
|
86 delete iSender; |
|
87 delete iReplyTo; |
|
88 delete iTextContent; |
|
89 delete iContent; |
|
90 iPluginData.ReleaseInstance(); |
|
91 iAttachments.ResetAndDestroy(); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 // ----------------------------------------------------------------------------- |
|
97 TEmailTypeId CEmailMessage::InterfaceId() const |
|
98 { |
|
99 return KEmailIFUidMessage; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 // ----------------------------------------------------------------------------- |
|
105 void CEmailMessage::Release() |
|
106 { |
|
107 if ( iOwner == EClientOwns ) |
|
108 { |
|
109 delete this; |
|
110 } |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 // ----------------------------------------------------------------------------- |
|
116 const TMessageId& CEmailMessage::MessageId() const |
|
117 { |
|
118 return iMessageId; |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 // ----------------------------------------------------------------------------- |
|
124 MEmailAddress* CEmailMessage::SenderAddressL() const |
|
125 { |
|
126 CFSMailAddress* fsAddress = iPluginMessage->GetSender(); |
|
127 if (fsAddress) |
|
128 { |
|
129 if (!iSender) |
|
130 { |
|
131 iSender = CEmailAddress::NewL( MEmailAddress::ESender, EAPIOwns ); |
|
132 } |
|
133 iSender->SetAddressL(fsAddress->GetEmailAddress()); |
|
134 iSender->SetDisplayNameL(fsAddress->GetDisplayName()); |
|
135 } |
|
136 else |
|
137 { |
|
138 // Sender address not defined. Delete client object as well |
|
139 delete iSender; |
|
140 iSender = NULL; |
|
141 } |
|
142 return iSender; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 // ----------------------------------------------------------------------------- |
|
148 MEmailAddress* CEmailMessage::ReplyToAddressL() const |
|
149 { |
|
150 const CFSMailAddress& fsAddress = iPluginMessage->GetReplyToAddress(); |
|
151 if ( &fsAddress ) |
|
152 { |
|
153 if (!iReplyTo) |
|
154 { |
|
155 iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns ); |
|
156 } |
|
157 iReplyTo->SetAddressL( fsAddress.GetEmailAddress() ); |
|
158 iReplyTo->SetDisplayNameL( fsAddress.GetDisplayName() ); |
|
159 } |
|
160 else |
|
161 { |
|
162 delete iReplyTo; |
|
163 iReplyTo = NULL; |
|
164 } |
|
165 return iReplyTo; |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 // ----------------------------------------------------------------------------- |
|
171 void CEmailMessage::SetReplyToAddressL( const MEmailAddress& aSender ) |
|
172 { |
|
173 CFSMailAddress *fsAddress = CFSMailAddress::NewLC(); |
|
174 if (!iReplyTo) |
|
175 { |
|
176 iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns); |
|
177 } |
|
178 fsAddress->SetDisplayName( aSender.DisplayName() ); |
|
179 fsAddress->SetEmailAddress( aSender.Address() ); |
|
180 iPluginMessage->SetReplyToAddress( fsAddress ); |
|
181 iReplyTo->SetAddressL( fsAddress->GetEmailAddress() ); |
|
182 iReplyTo->SetDisplayNameL( fsAddress->GetDisplayName() ); |
|
183 CleanupStack::Pop(); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 // ----------------------------------------------------------------------------- |
|
189 TInt CEmailMessage::GetRecipientsL( const MEmailAddress::TRole aRole, |
|
190 REmailAddressArray& aRecipients ) const |
|
191 { |
|
192 if( aRole == MEmailAddress::EReplyTo || |
|
193 aRole == MEmailAddress::ESender ) |
|
194 { |
|
195 User::Leave( KErrArgument ); |
|
196 } |
|
197 else |
|
198 { |
|
199 if( aRole == MEmailAddress::ETo || |
|
200 aRole == MEmailAddress::EUndefined ) |
|
201 { |
|
202 RPointerArray<CFSMailAddress>& toRecipients = |
|
203 iPluginMessage->GetToRecipients(); |
|
204 ConvertAddressArrayL( |
|
205 MEmailAddress::ETo, |
|
206 toRecipients, aRecipients ); |
|
207 } |
|
208 if( aRole == MEmailAddress::ECc || |
|
209 aRole == MEmailAddress::EUndefined ) |
|
210 { |
|
211 RPointerArray<CFSMailAddress>& ccRecipients = |
|
212 iPluginMessage->GetCCRecipients(); |
|
213 ConvertAddressArrayL( |
|
214 MEmailAddress::ECc, |
|
215 ccRecipients, aRecipients ); |
|
216 } |
|
217 if( aRole == MEmailAddress::EBcc || |
|
218 aRole == MEmailAddress::EUndefined ) |
|
219 { |
|
220 RPointerArray<CFSMailAddress>& bccRecipients = |
|
221 iPluginMessage->GetBCCRecipients(); |
|
222 ConvertAddressArrayL( |
|
223 MEmailAddress::EBcc, |
|
224 bccRecipients, aRecipients ); |
|
225 } |
|
226 } |
|
227 return aRecipients.Count(); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 // ----------------------------------------------------------------------------- |
|
233 void CEmailMessage::SetRecipientsL( const MEmailAddress::TRole aRole, |
|
234 REmailAddressArray& aRecipients ) |
|
235 { |
|
236 TInt count( aRecipients.Count() ); |
|
237 |
|
238 for( TInt i=0;i<count;i++ ) |
|
239 { |
|
240 const MEmailAddress* address = aRecipients[i]; |
|
241 CFSMailAddress* fsAddress = CFSMailAddress::NewLC(); |
|
242 fsAddress->SetEmailAddress( address->Address() ); |
|
243 fsAddress->SetDisplayName( address->DisplayName() ); |
|
244 |
|
245 if( aRole == MEmailAddress::ETo ) |
|
246 { |
|
247 iPluginMessage->AppendToRecipient( fsAddress ); |
|
248 } |
|
249 else if( aRole == MEmailAddress::ECc ) |
|
250 { |
|
251 iPluginMessage->AppendCCRecipient( fsAddress ); |
|
252 } |
|
253 else if( aRole == MEmailAddress::EBcc ) |
|
254 { |
|
255 iPluginMessage->AppendBCCRecipient( fsAddress ); |
|
256 } |
|
257 else |
|
258 { |
|
259 User::Leave( KErrArgument ); |
|
260 } |
|
261 CleanupStack::Pop( fsAddress ); |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 // ----------------------------------------------------------------------------- |
|
268 void CEmailMessage::RemoveRecipientL( const MEmailAddress& aRecipient ) |
|
269 { |
|
270 TInt err( KErrNotFound ); |
|
271 RPointerArray<CFSMailAddress>* recipients = NULL; |
|
272 |
|
273 switch (aRecipient.Role()) |
|
274 { |
|
275 case MEmailAddress::ETo: |
|
276 recipients = &iPluginMessage->GetToRecipients(); |
|
277 break; |
|
278 case MEmailAddress::ECc: |
|
279 recipients = &iPluginMessage->GetCCRecipients(); |
|
280 break; |
|
281 case MEmailAddress::EBcc: |
|
282 recipients = &iPluginMessage->GetBCCRecipients(); |
|
283 break; |
|
284 default: |
|
285 User::Leave( KErrArgument ); |
|
286 break; |
|
287 } |
|
288 |
|
289 for( TInt i = 0; i < recipients->Count(); i++ ) |
|
290 { |
|
291 if ( !aRecipient.Address().Compare( (*recipients)[i]->GetEmailAddress() ) ) |
|
292 { |
|
293 recipients->Remove(i); |
|
294 err = KErrNone; |
|
295 // We could break now. But let's loop if there are several entries |
|
296 } |
|
297 } |
|
298 User::LeaveIfError( err ); |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 // ----------------------------------------------------------------------------- |
|
304 TPtrC CEmailMessage::Subject() const |
|
305 { |
|
306 return iPluginMessage->GetSubject(); |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 // ----------------------------------------------------------------------------- |
|
312 void CEmailMessage::SetSubjectL( const TPtrC& aSubject) |
|
313 { |
|
314 iPluginMessage->SetSubject( aSubject ); |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 // ----------------------------------------------------------------------------- |
|
320 TTime CEmailMessage::Date() const |
|
321 { |
|
322 return iPluginMessage->GetDate(); |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 // ----------------------------------------------------------------------------- |
|
328 TInt CEmailMessage::Flags() const |
|
329 { |
|
330 return iFlags; |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 // ----------------------------------------------------------------------------- |
|
336 void CEmailMessage::SetFlag( const TUint aFlag ) |
|
337 { |
|
338 iFlags |= aFlag; |
|
339 TUint flag = MapFlags( aFlag ); |
|
340 iPluginMessage->SetFlag( flag ); |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 // ----------------------------------------------------------------------------- |
|
346 void CEmailMessage::ResetFlag( const TUint aFlag ) |
|
347 { |
|
348 iFlags &= ~aFlag; |
|
349 TUint flag = MapFlags( aFlag ); |
|
350 iPluginMessage->ResetFlag( flag ); |
|
351 } |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 // ----------------------------------------------------------------------------- |
|
356 MEmailMessageContent* CEmailMessage::ContentL() const |
|
357 { |
|
358 if (iTextContent) |
|
359 { |
|
360 return iTextContent; |
|
361 } |
|
362 if (iContent) |
|
363 { |
|
364 return iContent; |
|
365 } |
|
366 |
|
367 RPointerArray<CFSMailMessagePart> parts; |
|
368 CleanupResetAndDestroyPushL( parts ); |
|
369 iPluginMessage->ChildPartsL(parts); |
|
370 TInt count( parts.Count() ); |
|
371 if( count == 0 ) |
|
372 { |
|
373 /* No content, return NULL */ |
|
374 return NULL; |
|
375 } |
|
376 CFSMailMessagePart* part = parts[0]; |
|
377 const TDesC& contentType = part->GetContentType(); |
|
378 TMessageContentId msgContentId = TMessageContentId( |
|
379 part->GetPartId().Id(), |
|
380 iMessageId.iId, |
|
381 iMessageId.iFolderId.iId, |
|
382 iMessageId.iFolderId.iMailboxId ); |
|
383 |
|
384 if (!contentType.Compare(KFSMailContentTypeTextPlain) || |
|
385 !contentType.Compare(KFSMailContentTypeTextHtml)) |
|
386 { |
|
387 iTextContent = CEmailTextContent::NewL(iPluginData, msgContentId, part, EAPIOwns ); |
|
388 } |
|
389 else if (!contentType.Compare(KFSMailContentTypeMultipartMixed) || |
|
390 !contentType.Compare(KFSMailContentTypeMultipartAlternative) || |
|
391 !contentType.Compare(KFSMailContentTypeMultipartDigest) || |
|
392 !contentType.Compare(KFSMailContentTypeMultipartRelated) || |
|
393 !contentType.Compare(KFSMailContentTypeMultipartParallel)) |
|
394 { |
|
395 iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns); |
|
396 } |
|
397 if (count == 2 ) |
|
398 { |
|
399 CFSMailMessagePart* part = parts[1]; |
|
400 const TDesC& contentType = part->GetContentType(); |
|
401 } |
|
402 CleanupStack::Pop(); // parts |
|
403 |
|
404 if (iTextContent) |
|
405 { |
|
406 return iTextContent; |
|
407 } |
|
408 return iContent; |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 // ----------------------------------------------------------------------------- |
|
414 void CEmailMessage::SetContentL( const MEmailMessageContent* aContent ) |
|
415 { |
|
416 MEmailTextContent* textContent = aContent->AsTextContentOrNull(); |
|
417 if (textContent) |
|
418 { |
|
419 if (iTextContent) |
|
420 { |
|
421 delete iTextContent; // Destroy old content |
|
422 } |
|
423 iTextContent = dynamic_cast<CEmailTextContent*>(textContent); |
|
424 iTextContent->SetOwner( EAPIOwns ); |
|
425 return; |
|
426 } |
|
427 MEmailMultipart* mPart = aContent->AsMultipartOrNull(); |
|
428 if (mPart) |
|
429 { |
|
430 if (iContent) |
|
431 { |
|
432 delete iContent; |
|
433 } |
|
434 iContent = dynamic_cast<CEmailMultipart*>(mPart); |
|
435 iContent->SetOwner( EAPIOwns ); |
|
436 } |
|
437 } |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 // ----------------------------------------------------------------------------- |
|
442 void CEmailMessage::SetPlainTextBodyL( const TDesC& aPlainText ) |
|
443 { |
|
444 if (iTextContent) |
|
445 { |
|
446 iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText ); |
|
447 return; |
|
448 } |
|
449 CFSMailMessagePart* msgTextPart = iPluginMessage->PlainTextBodyPartL(); |
|
450 |
|
451 if( !msgTextPart ) |
|
452 { |
|
453 msgTextPart = iPluginMessage->NewChildPartL( TFSMailMsgId(), KFSMailContentTypeTextPlain ); |
|
454 } |
|
455 CleanupStack::PushL( msgTextPart ); |
|
456 |
|
457 TMessageContentId msgContentId = TMessageContentId( |
|
458 msgTextPart->GetPartId().Id(), |
|
459 iMessageId.iId, |
|
460 iMessageId.iFolderId.iId, |
|
461 iMessageId.iFolderId.iMailboxId ); |
|
462 |
|
463 msgTextPart->SetContentType( KFSMailContentTypeTextPlain ); |
|
464 iTextContent = CEmailTextContent::NewL( iPluginData, msgContentId, msgTextPart, EAPIOwns ); |
|
465 if (iTextContent) |
|
466 { |
|
467 iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText ); |
|
468 } |
|
469 CleanupStack::Pop(); // msgTextPart |
|
470 |
|
471 return; |
|
472 |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 // ----------------------------------------------------------------------------- |
|
478 MEmailAttachment* CEmailMessage::AddAttachmentL( const TDesC& aFullPath ) |
|
479 { |
|
480 CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL(aFullPath, TFSMailMsgId()); |
|
481 CleanupStack::PushL( part ); |
|
482 CEmailAttachment* att = CEmailAttachment::NewLC(iPluginData, iMsgContentId, part, EAPIOwns); |
|
483 iAttachments.AppendL( att ); |
|
484 CleanupStack::Pop(2); // part, att |
|
485 |
|
486 return att; |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 // ----------------------------------------------------------------------------- |
|
492 |
|
493 MEmailAttachment* CEmailMessage::AddAttachmentL( RFile& aFile ) |
|
494 { |
|
495 TBufC8 <1> mime; |
|
496 CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL(aFile, mime); |
|
497 CleanupStack::PushL( part ); |
|
498 CEmailAttachment* att = CEmailAttachment::NewLC(iPluginData, iMsgContentId, part, EAPIOwns); |
|
499 iAttachments.AppendL( att ); |
|
500 |
|
501 CleanupStack::Pop(); // part, att |
|
502 |
|
503 return att; |
|
504 } |
|
505 |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 // ----------------------------------------------------------------------------- |
|
509 TInt CEmailMessage::GetAttachmentsL( REmailAttachmentArray& aAttachments ) |
|
510 { |
|
511 RPointerArray<CFSMailMessagePart> attachments; |
|
512 CleanupResetAndDestroyPushL( attachments ); |
|
513 iPluginMessage->AttachmentListL(attachments); |
|
514 const TInt count( attachments.Count() ); |
|
515 for (TInt i = 0; i < count; i++) |
|
516 { |
|
517 TMessageContentId msgContentId = TMessageContentId( |
|
518 attachments[i]->GetPartId().Id(), |
|
519 iMessageId.iId, |
|
520 iMessageId.iFolderId.iId, |
|
521 iMessageId.iFolderId.iMailboxId ); |
|
522 |
|
523 CEmailAttachment* att = CEmailAttachment::NewL(iPluginData, msgContentId, attachments[i], EClientOwns); |
|
524 |
|
525 aAttachments.AppendL(att); |
|
526 } |
|
527 CleanupStack::Pop(); // attachments |
|
528 return count; |
|
529 } |
|
530 |
|
531 // ----------------------------------------------------------------------------- |
|
532 // |
|
533 // ----------------------------------------------------------------------------- |
|
534 void CEmailMessage::RemoveAttachmentL( const MEmailAttachment& aAttachment ) |
|
535 { |
|
536 iPluginMessage->RemoveChildPartL(FsMsgId( iPluginData, aAttachment.Id())); |
|
537 } |
|
538 |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 // ----------------------------------------------------------------------------- |
|
542 const TFolderId& CEmailMessage::ParentFolderId() const |
|
543 { |
|
544 return iMessageId.iFolderId; |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // |
|
549 // ----------------------------------------------------------------------------- |
|
550 void CEmailMessage::SaveChangesL() |
|
551 { |
|
552 TFSMailMsgId mailboxId( |
|
553 FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId ) ); |
|
554 |
|
555 iPlugin->StoreMessageL( mailboxId, *iPluginMessage ); |
|
556 } |
|
557 |
|
558 // ----------------------------------------------------------------------------- |
|
559 // |
|
560 // ----------------------------------------------------------------------------- |
|
561 void CEmailMessage::SendL() |
|
562 { |
|
563 SaveChangesL(); |
|
564 iPlugin->SendMessageL( *iPluginMessage ); |
|
565 } |
|
566 |
|
567 // ----------------------------------------------------------------------------- |
|
568 // |
|
569 // ----------------------------------------------------------------------------- |
|
570 void CEmailMessage::ConvertAddressArrayL( |
|
571 const MEmailAddress::TRole aRole, |
|
572 RPointerArray<CFSMailAddress>& aSrc, |
|
573 REmailAddressArray& aDst ) const |
|
574 { |
|
575 for ( TInt i=0; i<aSrc.Count(); i++ ) |
|
576 { |
|
577 CEmailAddress* recipient = CreateAddressLC( aRole, *aSrc[i] ); |
|
578 aDst.AppendL( recipient ); |
|
579 CleanupStack::Pop( recipient ); |
|
580 } |
|
581 } |
|
582 |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 CEmailAddress* CEmailMessage::CreateAddressLC( |
|
588 const MEmailAddress::TRole aRole, |
|
589 CFSMailAddress& aFsAddress ) const |
|
590 { |
|
591 CEmailAddress* address = CEmailAddress::NewLC( aRole, EClientOwns ); |
|
592 TDesC& temp1 = aFsAddress.GetEmailAddress(); |
|
593 if ( &temp1 ) |
|
594 { |
|
595 address->SetAddressL( temp1 ); |
|
596 } |
|
597 TDesC& temp2 = aFsAddress.GetDisplayName(); |
|
598 if ( &temp2 ) |
|
599 { |
|
600 address->SetDisplayNameL( temp2 ); |
|
601 } |
|
602 return address; |
|
603 } |
|
604 |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 // ----------------------------------------------------------------------------- |
|
608 // |
|
609 TUint CEmailMessage::MapFlags( const TUint& aFlag ) |
|
610 { |
|
611 TUint flag = 0; |
|
612 switch( aFlag ) |
|
613 { |
|
614 case EFlag_Read: |
|
615 flag = EFSMsgFlag_Read; |
|
616 break; |
|
617 case EFlag_Read_Locally: |
|
618 flag = EFSMsgFlag_Read_Locally; |
|
619 break; |
|
620 case EFlag_Low: |
|
621 flag = EFSMsgFlag_Low; |
|
622 break; |
|
623 case EFlag_Important: |
|
624 flag = EFSMsgFlag_Important; |
|
625 break; |
|
626 case EFlag_FollowUpComplete: |
|
627 flag = EFSMsgFlag_FollowUpComplete; |
|
628 break; |
|
629 case EFlag_FollowUp: |
|
630 flag = EFSMsgFlag_FollowUp; |
|
631 break; |
|
632 case EFlag_Attachments: |
|
633 flag = EFSMsgFlag_Attachments; |
|
634 break; |
|
635 case EFlag_Multiple: |
|
636 flag = EFSMsgFlag_Multiple; |
|
637 break; |
|
638 case EFlag_CalendarMsg: |
|
639 flag = EFSMsgFlag_CalendarMsg; |
|
640 break; |
|
641 case EFlag_Answered: |
|
642 flag = EFSMsgFlag_Answered; |
|
643 break; |
|
644 case EFlag_Forwarded: |
|
645 flag = EFSMsgFlag_Forwarded; |
|
646 break; |
|
647 case EFlag_OnlyToMe: |
|
648 flag = EFSMsgFlag_OnlyToMe; |
|
649 break; |
|
650 case EFlag_RemoteDeleted: |
|
651 flag = EFSMsgFlag_RemoteDeleted; |
|
652 break; |
|
653 case EFlag_HasMsgSender: |
|
654 flag = EFSMsgFlag_HasMsgSender; |
|
655 break; |
|
656 default: |
|
657 break; |
|
658 } |
|
659 return flag; |
|
660 } |
|
661 |
|
662 void CEmailMessage::ShowMessageViewerL( ) |
|
663 { |
|
664 THtmlViewerActivationData htmlData; |
|
665 htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage; |
|
666 htmlData.iMailBoxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId); |
|
667 htmlData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId); |
|
668 htmlData.iMessageId = FsMsgId(iPluginData, iMessageId); |
|
669 TPckgBuf<THtmlViewerActivationData> pckgData( htmlData ); |
|
670 CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC(); |
|
671 viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, HtmlViewerId), KHtmlViewerOpenNew, pckgData); |
|
672 CleanupStack::PopAndDestroy(); |
|
673 } |
|
674 |
|
675 /** |
|
676 * Launches Email application and new reply message in editor. |
|
677 * The method follows "fire and forget" pattern, returns immediately. |
|
678 */ |
|
679 void CEmailMessage::ReplyToMessageL( const TBool aReplyToAll ) |
|
680 { |
|
681 TEditorLaunchParams editorLaunchData; |
|
682 editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId); |
|
683 editorLaunchData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId); |
|
684 editorLaunchData.iMsgId = FsMsgId(iPluginData, iMessageId); |
|
685 editorLaunchData.iActivatedExternally = ETrue; |
|
686 |
|
687 TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData ); |
|
688 CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC(); |
|
689 TUid command = TUid::Uid(KEditorCmdReplyAll); |
|
690 if ( !aReplyToAll ) |
|
691 { |
|
692 command = TUid::Uid(KEditorCmdReply); |
|
693 } |
|
694 viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData); |
|
695 CleanupStack::PopAndDestroy(); |
|
696 } |
|
697 |
|
698 void CEmailMessage::ForwardMessageL() |
|
699 { |
|
700 TEditorLaunchParams editorLaunchData; |
|
701 editorLaunchData.iMailboxId = FsMsgId(iPluginData, iMessageId.iFolderId.iMailboxId); |
|
702 editorLaunchData.iFolderId = FsMsgId(iPluginData, iMessageId.iFolderId); |
|
703 editorLaunchData.iMsgId = FsMsgId(iPluginData, iMessageId); |
|
704 editorLaunchData.iActivatedExternally = ETrue; |
|
705 |
|
706 TPckgBuf<TEditorLaunchParams> pckgData( editorLaunchData ); |
|
707 CVwsSessionWrapper* viewSrvSession = CVwsSessionWrapper::NewLC(); |
|
708 TUid command = TUid::Uid(KEditorCmdForward); |
|
709 viewSrvSession->ActivateView(TVwsViewId(KFSEmailUiUid, MailEditorId), command, pckgData); |
|
710 CleanupStack::PopAndDestroy(); |
|
711 } |
|
712 // End of file. |