64
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-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: common email part object
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "emailtrace.h"
|
|
19 |
#include <apgcli.h>
|
|
20 |
#include <apmrec.h>
|
|
21 |
#include <mmf/common/mmfcontrollerpluginresolver.h> // CleanupResetAndDestroy
|
|
22 |
|
|
23 |
//<cmail>
|
|
24 |
#include "cfsmailmessagepart.h"
|
|
25 |
#include "cfsmailplugin.h"
|
|
26 |
//</cmail>
|
|
27 |
|
|
28 |
#include "cfsmailrequestobserver.h"
|
|
29 |
|
|
30 |
|
|
31 |
// ================= MEMBER FUNCTIONS ==========================================
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
// CFSMailMessagePart::NewLC
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
EXPORT_C CFSMailMessagePart* CFSMailMessagePart::NewLC( TFSMailMsgId aMessageId,
|
|
36 |
TFSMailMsgId aMessagePartId )
|
|
37 |
{
|
|
38 |
FUNC_LOG;
|
|
39 |
CFSMailMessagePart* adr = new (ELeave) CFSMailMessagePart();
|
|
40 |
CleanupStack::PushL(adr);
|
|
41 |
adr->ConstructL( aMessageId, aMessagePartId );
|
|
42 |
return adr;
|
|
43 |
}
|
|
44 |
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
// CFSMailMessagePart::NewL
|
|
47 |
// -----------------------------------------------------------------------------
|
|
48 |
EXPORT_C CFSMailMessagePart* CFSMailMessagePart::NewL( TFSMailMsgId aMessageId,
|
|
49 |
TFSMailMsgId aMessagePartId )
|
|
50 |
{
|
|
51 |
FUNC_LOG;
|
|
52 |
CFSMailMessagePart* adr = CFSMailMessagePart::NewLC( aMessageId, aMessagePartId );
|
|
53 |
CleanupStack::Pop(adr);
|
|
54 |
return adr;
|
|
55 |
}
|
|
56 |
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
// CFSMailMessagePart::ConstructL
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
void CFSMailMessagePart::ConstructL( TFSMailMsgId aMessageId,
|
|
61 |
TFSMailMsgId aMessagePartId )
|
|
62 |
{
|
|
63 |
FUNC_LOG;
|
|
64 |
iMessageId = aMessageId;
|
|
65 |
iMessagePartId = aMessagePartId;
|
|
66 |
iMessagePartsStatus = EFSDefault;
|
|
67 |
|
|
68 |
iContentTypeParams = new (ELeave)CDesCArrayFlat( KArrayGranularity );
|
|
69 |
iContentDispositionParams = new (ELeave)CDesCArrayFlat( KArrayGranularity );
|
|
70 |
|
|
71 |
}
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// CFSMailMessagePart::~CFSMailMessagePart
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
EXPORT_C CFSMailMessagePart::~CFSMailMessagePart()
|
|
77 |
{
|
|
78 |
FUNC_LOG;
|
|
79 |
if(iContentType)
|
|
80 |
{
|
|
81 |
delete iContentType;
|
|
82 |
}
|
|
83 |
iContentType = NULL;
|
|
84 |
|
|
85 |
if(iContentDescription)
|
|
86 |
{
|
|
87 |
delete iContentDescription;
|
|
88 |
}
|
|
89 |
iContentDescription = NULL;
|
|
90 |
|
|
91 |
if(iContentDisposition)
|
|
92 |
{
|
|
93 |
delete iContentDisposition;
|
|
94 |
}
|
|
95 |
iContentDisposition = NULL;
|
|
96 |
|
|
97 |
if(iAttachmentName)
|
|
98 |
{
|
|
99 |
delete iAttachmentName;
|
|
100 |
}
|
|
101 |
iAttachmentName = NULL;
|
|
102 |
|
|
103 |
if(iContentClass)
|
|
104 |
{
|
|
105 |
delete iContentClass;
|
|
106 |
}
|
|
107 |
iContentClass = NULL;
|
|
108 |
|
|
109 |
if(iContentID)
|
|
110 |
{
|
|
111 |
delete iContentID;
|
|
112 |
}
|
|
113 |
iContentID = NULL;
|
|
114 |
|
|
115 |
if(iMeetingRequest)
|
|
116 |
{
|
|
117 |
delete iMeetingRequest;
|
|
118 |
}
|
|
119 |
iMeetingRequest = NULL;
|
|
120 |
|
|
121 |
if(iContentDispositionParams)
|
|
122 |
{
|
|
123 |
iContentDispositionParams->Reset();
|
|
124 |
delete iContentDispositionParams;
|
|
125 |
}
|
|
126 |
if(iContentTypeParams)
|
|
127 |
{
|
|
128 |
iContentTypeParams->Reset();
|
|
129 |
delete iContentTypeParams;
|
|
130 |
}
|
|
131 |
|
|
132 |
iMessageParts.ResetAndDestroy();
|
|
133 |
}
|
|
134 |
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
// CFSMailMessagePart::CFSMailMessagePart
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
CFSMailMessagePart::CFSMailMessagePart() : CFSMailMessageBase()
|
|
139 |
{
|
|
140 |
FUNC_LOG;
|
|
141 |
|
|
142 |
iContentType = HBufC::New(1);
|
|
143 |
iContentType->Des().Copy(KNullDesC());
|
|
144 |
|
|
145 |
iContentDescription = HBufC::New(1);
|
|
146 |
iContentDescription->Des().Copy(KNullDesC());
|
|
147 |
|
|
148 |
iContentDisposition = HBufC::New(1);
|
|
149 |
iContentDisposition->Des().Copy(KNullDesC());
|
|
150 |
|
|
151 |
iContentClass = HBufC::New(1);
|
|
152 |
iContentClass->Des().Copy(KNullDesC());
|
|
153 |
|
|
154 |
iContentID = HBufC::New(1);
|
|
155 |
iContentID->Des().Copy(KNullDesC());
|
|
156 |
|
|
157 |
iAttachmentName = HBufC::New(1);
|
|
158 |
iAttachmentName->Des().Copy(KNullDesC());
|
|
159 |
|
|
160 |
iReadMessageParts = ETrue;
|
|
161 |
}
|
|
162 |
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
// CFSMailMessagePart::GetContentType
|
|
165 |
// -----------------------------------------------------------------------------
|
|
166 |
EXPORT_C const TDesC& CFSMailMessagePart::GetContentType()
|
|
167 |
{
|
|
168 |
FUNC_LOG;
|
|
169 |
return *iContentType;
|
|
170 |
}
|
|
171 |
|
|
172 |
// -----------------------------------------------------------------------------
|
|
173 |
// CFSMailMessagePart::SetContentType
|
|
174 |
// -----------------------------------------------------------------------------
|
|
175 |
EXPORT_C void CFSMailMessagePart::SetContentType(const TDesC& aContentType)
|
|
176 |
{
|
|
177 |
FUNC_LOG;
|
|
178 |
|
|
179 |
HBufC* contentType = HBufC::New(aContentType.Length());
|
|
180 |
|
|
181 |
// store new mailbox name
|
|
182 |
if(contentType)
|
|
183 |
{
|
|
184 |
delete iContentType;
|
|
185 |
iContentType = contentType;
|
|
186 |
iContentType->Des().Copy(aContentType);
|
|
187 |
}
|
|
188 |
}
|
|
189 |
|
|
190 |
// -----------------------------------------------------------------------------
|
|
191 |
// CFSMailMessagePart::GetPartId
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
EXPORT_C TFSMailMsgId CFSMailMessagePart::GetPartId() const
|
|
194 |
{
|
|
195 |
FUNC_LOG;
|
|
196 |
return iMessagePartId;
|
|
197 |
}
|
|
198 |
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
// CFSMailMessagePart::ChildPartsL
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
EXPORT_C void CFSMailMessagePart::ChildPartsL(RPointerArray<CFSMailMessagePart>& aParts)
|
|
203 |
{
|
|
204 |
FUNC_LOG;
|
|
205 |
|
|
206 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
|
|
207 |
{
|
|
208 |
plugin->ChildPartsL(GetMailBoxId(),GetFolderId(),GetMessageId(),GetPartId(),aParts);
|
|
209 |
}
|
|
210 |
}
|
|
211 |
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
// CFSMailMessagePart::ChildPartL
|
|
214 |
// -----------------------------------------------------------------------------
|
|
215 |
EXPORT_C CFSMailMessagePart* CFSMailMessagePart::ChildPartL(TFSMailMsgId aPartId)
|
|
216 |
{
|
|
217 |
FUNC_LOG;
|
|
218 |
|
|
219 |
CFSMailMessagePart* part = NULL;
|
|
220 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
|
|
221 |
{
|
|
222 |
part = plugin->MessagePartL(GetMailBoxId(),
|
|
223 |
GetFolderId(),
|
|
224 |
GetMessageId(),
|
|
225 |
aPartId);
|
|
226 |
}
|
|
227 |
return part;
|
|
228 |
}
|
|
229 |
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
// CFSMailMessagePart::IsMessageL
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
EXPORT_C TBool CFSMailMessagePart::IsMessageL() const
|
|
234 |
{
|
|
235 |
FUNC_LOG;
|
|
236 |
|
|
237 |
TBuf<KMaxDataTypeLength> ptr;
|
|
238 |
if ( iContentType )
|
|
239 |
{
|
|
240 |
ptr.Copy(iContentType->Des());
|
|
241 |
TInt length = ptr.Locate(';');
|
|
242 |
if(length >= 0)
|
|
243 |
{
|
|
244 |
ptr.SetLength(length);
|
|
245 |
}
|
|
246 |
|
|
247 |
if( !ptr.CompareF(KFSMailContentTypeMessage) )
|
|
248 |
{
|
|
249 |
return ETrue;
|
|
250 |
}
|
|
251 |
}
|
|
252 |
return EFalse;
|
|
253 |
}
|
|
254 |
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
// CFSMailMessagePart::NewChildPartL
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
EXPORT_C CFSMailMessagePart* CFSMailMessagePart::NewChildPartL( const TFSMailMsgId aInsertBefore,
|
|
259 |
const TDesC& aContentType )
|
|
260 |
{
|
|
261 |
FUNC_LOG;
|
|
262 |
|
|
263 |
CFSMailMessagePart* part = NULL;
|
|
264 |
|
|
265 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
|
|
266 |
{
|
|
267 |
part = plugin->NewChildPartL( GetMailBoxId(), GetFolderId(), GetMessageId(),
|
|
268 |
GetPartId(), aInsertBefore, aContentType );
|
|
269 |
}
|
|
270 |
return part;
|
|
271 |
}
|
|
272 |
|
|
273 |
// -----------------------------------------------------------------------------
|
|
274 |
// CFSMailMessagePart::RemoveChildPartL
|
|
275 |
// -----------------------------------------------------------------------------
|
|
276 |
EXPORT_C void CFSMailMessagePart::RemoveChildPartL(TFSMailMsgId aPartId)
|
|
277 |
{
|
|
278 |
FUNC_LOG;
|
|
279 |
// get plugin pointer
|
|
280 |
TFSMailMsgId id = GetPartId();
|
|
281 |
if(id.IsNullId())
|
|
282 |
{
|
|
283 |
id = GetMessageId();
|
|
284 |
}
|
|
285 |
CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(id);
|
|
286 |
|
|
287 |
if(plugin)
|
|
288 |
{
|
|
289 |
plugin->RemoveChildPartL( GetMailBoxId(), GetFolderId(), GetMessageId(), GetPartId(), aPartId );
|
|
290 |
}
|
|
291 |
}
|
|
292 |
|
|
293 |
// -----------------------------------------------------------------------------
|
|
294 |
// CFSMailMessagePart::GetContentClass
|
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
EXPORT_C const TDesC& CFSMailMessagePart::GetContentClass()
|
|
297 |
{
|
|
298 |
FUNC_LOG;
|
|
299 |
return *iContentClass;
|
|
300 |
}
|
|
301 |
|
|
302 |
// -----------------------------------------------------------------------------
|
|
303 |
// CFSMailMessagePart::SetContentClass
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
EXPORT_C void CFSMailMessagePart::SetContentClass( const TDesC& aContentClass )
|
|
306 |
{
|
|
307 |
FUNC_LOG;
|
|
308 |
|
|
309 |
//
|
|
310 |
HBufC* contentClass = HBufC::New(aContentClass.Length());
|
|
311 |
|
|
312 |
// store new mailbox name
|
|
313 |
if(contentClass)
|
|
314 |
{
|
|
315 |
delete iContentClass;
|
|
316 |
iContentClass = contentClass;
|
|
317 |
iContentClass->Des().Copy(aContentClass);
|
|
318 |
}
|
|
319 |
iContentClass->ReAlloc(aContentClass.Length());
|
|
320 |
if(iContentClass)
|
|
321 |
{
|
|
322 |
iContentClass->Des().Copy(aContentClass);
|
|
323 |
}
|
|
324 |
}
|
|
325 |
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
// CFSMailMessagePart::ContentSize
|
|
328 |
// -----------------------------------------------------------------------------
|
|
329 |
EXPORT_C TUint CFSMailMessagePart::ContentSize() const
|
|
330 |
{
|
|
331 |
FUNC_LOG;
|
|
332 |
return iContentSize;
|
|
333 |
}
|
|
334 |
|
|
335 |
// -----------------------------------------------------------------------------
|
|
336 |
// CFSMailMessagePart::SetContentSize
|
|
337 |
// -----------------------------------------------------------------------------
|
|
338 |
EXPORT_C void CFSMailMessagePart::SetContentSize( TUint aContentSize )
|
|
339 |
{
|
|
340 |
FUNC_LOG;
|
|
341 |
iContentSize = aContentSize;
|
|
342 |
}
|
|
343 |
|
|
344 |
// -----------------------------------------------------------------------------
|
|
345 |
// CFSMailMessagePart::ContentID
|
|
346 |
// -----------------------------------------------------------------------------
|
|
347 |
EXPORT_C const TDesC& CFSMailMessagePart::ContentID()
|
|
348 |
{
|
|
349 |
FUNC_LOG;
|
|
350 |
return *iContentID;
|
|
351 |
}
|
|
352 |
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
// CFSMailMessagePart::SetContentIDL
|
|
355 |
// -----------------------------------------------------------------------------
|
|
356 |
EXPORT_C void CFSMailMessagePart::SetContentIDL(const TDesC& aContentID)
|
|
357 |
{
|
|
358 |
FUNC_LOG;
|
|
359 |
// init mailbox name
|
|
360 |
HBufC* id = HBufC::New(aContentID.Length());
|
|
361 |
|
|
362 |
// store new mailbox name
|
|
363 |
if(id)
|
|
364 |
{
|
|
365 |
delete iContentID;
|
|
366 |
iContentID = id;
|
|
367 |
iContentID->Des().Copy(aContentID);
|
|
368 |
}
|
|
369 |
}
|
|
370 |
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
// CFSMailMessagePart::CopyMessageAsChildPartL
|
|
373 |
// -----------------------------------------------------------------------------
|
|
374 |
EXPORT_C CFSMailMessagePart* CFSMailMessagePart::CopyMessageAsChildPartL(
|
|
375 |
TFSMailMsgId aInsertBefore,
|
|
376 |
CFSMailMessage* aMessage)
|
|
377 |
{
|
|
378 |
FUNC_LOG;
|
|
379 |
|
|
380 |
CFSMailMessagePart* part = NULL;
|
|
381 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
382 |
{
|
|
383 |
part = plugin->CopyMessageAsChildPartL(GetMailBoxId(),GetFolderId(),GetMessageId(),GetPartId(),
|
|
384 |
aInsertBefore, *aMessage);
|
|
385 |
}
|
|
386 |
return part;
|
|
387 |
}
|
|
388 |
|
|
389 |
// -----------------------------------------------------------------------------
|
|
390 |
// CFSMailMessagePart::RemoveContentL
|
|
391 |
// -----------------------------------------------------------------------------
|
|
392 |
EXPORT_C void CFSMailMessagePart::RemoveContentL()
|
|
393 |
{
|
|
394 |
FUNC_LOG;
|
|
395 |
|
|
396 |
CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId());
|
|
397 |
if(plugin == NULL)
|
|
398 |
{
|
|
399 |
plugin = iRequestHandler->GetPluginByUid(GetMessageId());
|
|
400 |
}
|
|
401 |
|
|
402 |
if(plugin != NULL)
|
|
403 |
{
|
|
404 |
RPointerArray<CFSMailMessagePart> parts;
|
|
405 |
CleanupResetAndDestroyPushL( parts );
|
|
406 |
plugin->ChildPartsL(GetMailBoxId(),GetFolderId(),GetMessageId(),GetPartId(),parts);
|
|
407 |
RArray<TFSMailMsgId> partIds;
|
|
408 |
CleanupClosePushL( partIds );
|
|
409 |
partIds.ReserveL( 1 + parts.Count() );
|
|
410 |
for(TInt i=0;i<parts.Count();i++)
|
|
411 |
{
|
|
412 |
partIds.AppendL( parts[i]->GetMessageId() );
|
|
413 |
}
|
|
414 |
partIds.AppendL( GetPartId() );
|
|
415 |
plugin->RemovePartContentL(GetMailBoxId(), GetFolderId(), GetMessageId(), partIds);
|
|
416 |
CleanupStack::PopAndDestroy( &partIds );
|
|
417 |
CleanupStack::PopAndDestroy( &parts );
|
|
418 |
}
|
|
419 |
}
|
|
420 |
|
|
421 |
// -----------------------------------------------------------------------------
|
|
422 |
// CFSMailMessagePart::RemoveDownLoadedAttachmentsL
|
|
423 |
// -----------------------------------------------------------------------------
|
|
424 |
EXPORT_C void CFSMailMessagePart::RemoveDownLoadedAttachmentsL()
|
|
425 |
{
|
|
426 |
FUNC_LOG;
|
|
427 |
|
|
428 |
CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId());
|
|
429 |
if(plugin == NULL)
|
|
430 |
{
|
|
431 |
plugin = iRequestHandler->GetPluginByUid(GetMessageId());
|
|
432 |
}
|
|
433 |
|
|
434 |
if(plugin != NULL)
|
|
435 |
{
|
|
436 |
// get attachment list
|
|
437 |
RPointerArray<CFSMailMessagePart> attachments;
|
|
438 |
CleanupResetAndDestroyPushL( attachments );
|
|
439 |
DoAttachmentListL(attachments);
|
|
440 |
|
|
441 |
// copy attachment part ids
|
|
442 |
RArray<TFSMailMsgId> ids;
|
|
443 |
CleanupClosePushL( ids );
|
|
444 |
for(TInt i=0;i<attachments.Count();i++)
|
|
445 |
{
|
|
446 |
ids.Append(attachments[i]->GetPartId());
|
|
447 |
}
|
|
448 |
|
|
449 |
// remove attachment fetched contents
|
|
450 |
if(ids.Count())
|
|
451 |
{
|
|
452 |
TRAP_IGNORE(plugin->RemovePartContentL(GetMailBoxId(), GetFolderId(), GetMessageId(), ids));
|
|
453 |
}
|
|
454 |
|
|
455 |
// clean tables
|
|
456 |
CleanupStack::PopAndDestroy( &ids );
|
|
457 |
CleanupStack::PopAndDestroy( &attachments );
|
|
458 |
}
|
|
459 |
}
|
|
460 |
|
|
461 |
// -----------------------------------------------------------------------------
|
|
462 |
// CFSMailMessagePart::GetContentFileL
|
|
463 |
// -----------------------------------------------------------------------------
|
|
464 |
EXPORT_C RFile CFSMailMessagePart::GetContentFileL()
|
|
465 |
{
|
|
466 |
FUNC_LOG;
|
|
467 |
|
|
468 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
469 |
{
|
|
470 |
TInt rcode = plugin->GetMessagePartFileL( GetMailBoxId(), GetFolderId(),
|
|
471 |
GetMessageId(), GetPartId(),
|
|
472 |
iFile );
|
|
473 |
// if content is encrypted, use temp dir files
|
|
474 |
if(rcode == KErrNotSupported)
|
|
475 |
{
|
|
476 |
// temp directory C:\Private\<uid>
|
|
477 |
TFileName fileName;
|
|
478 |
iFile = iRequestHandler->GetTempFileL(GetPartId(),fileName);
|
|
479 |
plugin->CopyMessagePartFileL(GetMailBoxId(), GetFolderId(),
|
|
480 |
GetMessageId(), GetPartId(),
|
|
481 |
fileName);
|
|
482 |
}
|
|
483 |
}
|
|
484 |
|
|
485 |
return iFile;
|
|
486 |
}
|
|
487 |
|
|
488 |
// -----------------------------------------------------------------------------
|
|
489 |
// CFSMailMessagePart::SetContentFromFileL
|
|
490 |
// -----------------------------------------------------------------------------
|
|
491 |
EXPORT_C void CFSMailMessagePart::SetContentFromFileL(const TDesC& aFilePath)
|
|
492 |
{
|
|
493 |
FUNC_LOG;
|
|
494 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
495 |
{
|
|
496 |
plugin->SetPartContentFromFileL(GetMailBoxId(), GetFolderId(),
|
|
497 |
GetMessageId(), GetPartId(), aFilePath );
|
|
498 |
}
|
|
499 |
}
|
|
500 |
|
|
501 |
// -----------------------------------------------------------------------------
|
|
502 |
// CFSMailMessagePart::CopyContentFileL
|
|
503 |
// -----------------------------------------------------------------------------
|
|
504 |
EXPORT_C void CFSMailMessagePart::CopyContentFileL( const TDesC& aFilePath )
|
|
505 |
{
|
|
506 |
FUNC_LOG;
|
|
507 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
508 |
{
|
|
509 |
plugin->CopyMessagePartFileL( GetMailBoxId(), GetFolderId(),
|
|
510 |
GetMessageId(), GetPartId(), aFilePath);
|
|
511 |
}
|
|
512 |
}
|
|
513 |
|
|
514 |
// -----------------------------------------------------------------------------
|
|
515 |
// CFSMailMessagePart::GetContentToBufferL
|
|
516 |
// -----------------------------------------------------------------------------
|
|
517 |
EXPORT_C void CFSMailMessagePart::GetContentToBufferL(TDes16& aBuffer, TUint aStartOffset)
|
|
518 |
{
|
|
519 |
FUNC_LOG;
|
|
520 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
521 |
{
|
|
522 |
plugin->GetContentToBufferL( GetMailBoxId(), GetFolderId(), GetMessageId(),
|
|
523 |
GetPartId(), aBuffer, aStartOffset );
|
|
524 |
}
|
|
525 |
}
|
|
526 |
|
|
527 |
// -----------------------------------------------------------------------------
|
|
528 |
// CFSMailMessagePart::SetContent
|
|
529 |
// -----------------------------------------------------------------------------
|
|
530 |
EXPORT_C void CFSMailMessagePart::SetContent( TDes16& aBuffer )
|
|
531 |
{
|
|
532 |
FUNC_LOG;
|
|
533 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
534 |
{
|
|
535 |
TRAPD(err,plugin->SetContentL( aBuffer, GetMailBoxId(), GetFolderId(),
|
|
536 |
GetMessageId(), GetPartId() ));
|
|
537 |
if(err)
|
|
538 |
{
|
|
539 |
return;
|
|
540 |
}
|
|
541 |
}
|
|
542 |
}
|
|
543 |
|
|
544 |
// -----------------------------------------------------------------------------
|
|
545 |
// CFSMailMessagePart::ContentDescription
|
|
546 |
// -----------------------------------------------------------------------------
|
|
547 |
EXPORT_C const TDesC& CFSMailMessagePart::ContentDescription()
|
|
548 |
{
|
|
549 |
FUNC_LOG;
|
|
550 |
return *iContentDescription;
|
|
551 |
}
|
|
552 |
|
|
553 |
// -----------------------------------------------------------------------------
|
|
554 |
// CFSMailMessagePart::SetContentDescription
|
|
555 |
// -----------------------------------------------------------------------------
|
|
556 |
EXPORT_C void CFSMailMessagePart::SetContentDescription( const TDesC& aContentDescription )
|
|
557 |
{
|
|
558 |
FUNC_LOG;
|
|
559 |
// init mailbox name
|
|
560 |
HBufC* description = HBufC::New(aContentDescription.Length());
|
|
561 |
|
|
562 |
// store new mailbox name
|
|
563 |
if(description)
|
|
564 |
{
|
|
565 |
delete iContentDescription;
|
|
566 |
iContentDescription = description;
|
|
567 |
iContentDescription->Des().Copy(aContentDescription);
|
|
568 |
}
|
|
569 |
}
|
|
570 |
// -----------------------------------------------------------------------------
|
|
571 |
// CFSMailMessagePart::ContentDisposition
|
|
572 |
// -----------------------------------------------------------------------------
|
|
573 |
EXPORT_C const TDesC& CFSMailMessagePart::ContentDisposition()
|
|
574 |
{
|
|
575 |
FUNC_LOG;
|
|
576 |
return *iContentDisposition;
|
|
577 |
}
|
|
578 |
|
|
579 |
// -----------------------------------------------------------------------------
|
|
580 |
// CFSMailMessagePart::SetContentDisposition
|
|
581 |
// -----------------------------------------------------------------------------
|
|
582 |
EXPORT_C void CFSMailMessagePart::SetContentDisposition( const TDesC& aContentDisposition )
|
|
583 |
{
|
|
584 |
FUNC_LOG;
|
|
585 |
// init mailbox name
|
|
586 |
HBufC* disposition = HBufC::New(aContentDisposition.Length());
|
|
587 |
|
|
588 |
// store new mailbox name
|
|
589 |
if(disposition)
|
|
590 |
{
|
|
591 |
delete iContentDisposition;
|
|
592 |
iContentDisposition = disposition;
|
|
593 |
iContentDisposition->Des().Copy(aContentDisposition);
|
|
594 |
}
|
|
595 |
}
|
|
596 |
|
|
597 |
// -----------------------------------------------------------------------------
|
|
598 |
// CFSMailMessagePart::ContentTypeParameters
|
|
599 |
// -----------------------------------------------------------------------------
|
|
600 |
EXPORT_C CDesCArray& CFSMailMessagePart::ContentTypeParameters()
|
|
601 |
{
|
|
602 |
FUNC_LOG;
|
|
603 |
|
|
604 |
if(!iContentType)
|
|
605 |
{
|
|
606 |
return *iContentTypeParams;
|
|
607 |
}
|
|
608 |
|
|
609 |
// clear parameter table
|
|
610 |
iContentTypeParams->Reset();
|
|
611 |
TInt ret = KErrNone;
|
|
612 |
|
|
613 |
// check content type parameters existence
|
|
614 |
TInt index = iContentType->Locate(';');
|
|
615 |
if(index >= 0)
|
|
616 |
{
|
|
617 |
TInt attLength(0);
|
|
618 |
TInt valueLength(0);
|
|
619 |
while(index >= 0)
|
|
620 |
{
|
|
621 |
TPtrC attribute;
|
|
622 |
TPtrC value;
|
|
623 |
HBufC* buf;
|
|
624 |
|
|
625 |
// set pointer to first parameter
|
|
626 |
TPtrC parameter = iContentType->Mid(index+1);
|
|
627 |
attLength = parameter.Locate('=');
|
|
628 |
if(attLength >= 0)
|
|
629 |
{
|
|
630 |
attribute.Set(parameter.Left(attLength));
|
|
631 |
valueLength = parameter.Locate(';');
|
|
632 |
if(valueLength < 0)
|
|
633 |
{
|
|
634 |
value.Set( parameter.Right(parameter.Length()-attLength-1) );
|
|
635 |
index = -1;
|
|
636 |
}
|
|
637 |
else
|
|
638 |
{
|
|
639 |
value.Set(parameter.Mid(attLength+1,(valueLength-attLength-1)));
|
|
640 |
index += valueLength + 1;
|
|
641 |
}
|
|
642 |
}
|
|
643 |
else
|
|
644 |
{
|
|
645 |
attLength = parameter.Locate(';');
|
|
646 |
if(attLength < 0)
|
|
647 |
{
|
|
648 |
attribute.Set(parameter);
|
|
649 |
index = -1;
|
|
650 |
}
|
|
651 |
else
|
|
652 |
{
|
|
653 |
attribute.Set(parameter.Left(attLength));
|
|
654 |
index += attLength + 1;
|
|
655 |
}
|
|
656 |
}
|
|
657 |
|
|
658 |
if(attribute.Length())
|
|
659 |
{
|
|
660 |
buf = HBufC::New(attribute.Length());
|
|
661 |
buf->Des().Copy(attribute);
|
|
662 |
TRAPD(err,iContentTypeParams->AppendL(buf->Des()));
|
|
663 |
if(value.Length() && err == KErrNone)
|
|
664 |
{
|
|
665 |
buf = HBufC::New(value.Length());
|
|
666 |
buf->Des().Copy(value);
|
|
667 |
TRAP(err,iContentTypeParams->AppendL(buf->Des()));
|
|
668 |
ret = err;
|
|
669 |
}
|
|
670 |
else
|
|
671 |
{
|
|
672 |
TBufC<1> empty(KNullDesC);
|
|
673 |
HBufC* buf = HBufC::New(empty.Des().Length());
|
|
674 |
buf->Des().Copy(empty);
|
|
675 |
TRAP(err,iContentTypeParams->AppendL(buf->Des()));
|
|
676 |
ret = err;
|
|
677 |
}
|
|
678 |
}
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
if(ret != KErrNone)
|
|
683 |
{
|
|
684 |
// clear parameter table
|
|
685 |
iContentTypeParams->Reset();
|
|
686 |
}
|
|
687 |
|
|
688 |
return *iContentTypeParams;
|
|
689 |
}
|
|
690 |
|
|
691 |
// -----------------------------------------------------------------------------
|
|
692 |
// CFSMailMessagePart::ContentDispositionParameters
|
|
693 |
// -----------------------------------------------------------------------------
|
|
694 |
EXPORT_C CDesCArray& CFSMailMessagePart::ContentDispositionParameters()
|
|
695 |
{
|
|
696 |
FUNC_LOG;
|
|
697 |
|
|
698 |
if(!iContentDisposition)
|
|
699 |
{
|
|
700 |
return *iContentDispositionParams;
|
|
701 |
}
|
|
702 |
|
|
703 |
// clear parameter array
|
|
704 |
iContentDispositionParams->Reset();
|
|
705 |
TInt ret = KErrNone;
|
|
706 |
|
|
707 |
// check content disposition parameters existence
|
|
708 |
TInt index = iContentDisposition->Locate(';');
|
|
709 |
if( index >= 0 )
|
|
710 |
{
|
|
711 |
TInt attLength(0);
|
|
712 |
TInt valueLength(0);
|
|
713 |
while(index >= 0)
|
|
714 |
{
|
|
715 |
TPtrC attribute;
|
|
716 |
TPtrC value;
|
|
717 |
|
|
718 |
// set pointer to first parameter
|
|
719 |
TPtrC parameter = iContentDisposition->Mid(index+1);
|
|
720 |
attLength = parameter.Locate('=');
|
|
721 |
if( attLength >= 0 )
|
|
722 |
{
|
|
723 |
attribute.Set(parameter.Left(attLength));
|
|
724 |
valueLength = parameter.Locate(';');
|
|
725 |
if( valueLength < 0 )
|
|
726 |
{
|
|
727 |
value.Set( parameter.Right(parameter.Length()-attLength-1) );
|
|
728 |
index = -1;
|
|
729 |
}
|
|
730 |
else
|
|
731 |
{
|
|
732 |
value.Set( parameter.Mid(attLength+1,(valueLength-attLength-1)) );
|
|
733 |
index += valueLength + 1;
|
|
734 |
}
|
|
735 |
}
|
|
736 |
else
|
|
737 |
{
|
|
738 |
attLength = parameter.Locate(';');
|
|
739 |
if(attLength < 0)
|
|
740 |
{
|
|
741 |
attribute.Set(parameter);
|
|
742 |
index = -1;
|
|
743 |
}
|
|
744 |
else
|
|
745 |
{
|
|
746 |
attribute.Set(parameter.Left(attLength));
|
|
747 |
index += attLength + 1;
|
|
748 |
}
|
|
749 |
}
|
|
750 |
|
|
751 |
if(attribute.Length())
|
|
752 |
{
|
|
753 |
HBufC* attBuf = HBufC::New(attribute.Length());
|
|
754 |
attBuf->Des().Copy(attribute);
|
|
755 |
// let's trim the attribute before adding to array
|
|
756 |
TPtr attTrim( attBuf->Des() );
|
|
757 |
attTrim.Trim();
|
|
758 |
|
|
759 |
if ( attTrim.Length() )
|
|
760 |
{
|
|
761 |
// add trimmed attribute to the array
|
|
762 |
TRAPD(err,iContentDispositionParams->AppendL( attTrim ));
|
|
763 |
|
|
764 |
if(value.Length() && err == KErrNone)
|
|
765 |
{
|
|
766 |
HBufC* valueBuf = HBufC::New(value.Length());
|
|
767 |
valueBuf->Des().Copy(value);
|
|
768 |
// let's trim also the value before adding to array
|
|
769 |
TPtr valueTrim( valueBuf->Des() );
|
|
770 |
valueTrim.Trim();
|
|
771 |
|
|
772 |
if ( valueTrim.Length() )
|
|
773 |
{
|
|
774 |
// add trimmed value to the array
|
|
775 |
TRAPD(err,iContentDispositionParams->AppendL( valueTrim ));
|
|
776 |
ret = err;
|
|
777 |
}
|
|
778 |
else
|
|
779 |
{
|
|
780 |
delete valueBuf;
|
|
781 |
valueBuf = NULL;
|
|
782 |
|
|
783 |
TBufC<1> empty(KNullDesC);
|
|
784 |
HBufC* emptyBuf = HBufC::New(empty.Des().Length());
|
|
785 |
emptyBuf->Des().Copy(empty);
|
|
786 |
TRAPD(err,iContentDispositionParams->AppendL(emptyBuf->Des()));
|
|
787 |
ret = err;
|
|
788 |
}
|
|
789 |
}
|
|
790 |
else
|
|
791 |
{
|
|
792 |
TBufC<1> empty(KNullDesC);
|
|
793 |
HBufC* emptyBuf = HBufC::New(empty.Des().Length());
|
|
794 |
emptyBuf->Des().Copy(empty);
|
|
795 |
TRAPD(err,iContentDispositionParams->AppendL(emptyBuf->Des()));
|
|
796 |
ret = err;
|
|
797 |
}
|
|
798 |
}
|
|
799 |
else
|
|
800 |
{
|
|
801 |
delete attBuf;
|
|
802 |
attBuf = NULL;
|
|
803 |
}
|
|
804 |
}
|
|
805 |
} // while
|
|
806 |
}
|
|
807 |
|
|
808 |
if(ret != KErrNone)
|
|
809 |
{
|
|
810 |
// clear parameter table
|
|
811 |
iContentDispositionParams->Reset();
|
|
812 |
}
|
|
813 |
|
|
814 |
return *iContentDispositionParams;
|
|
815 |
}
|
|
816 |
|
|
817 |
// -----------------------------------------------------------------------------
|
|
818 |
// CFSMailMessagePart::GetMRInfo
|
|
819 |
// -----------------------------------------------------------------------------
|
|
820 |
EXPORT_C MMRInfoObject& CFSMailMessagePart::GetMRInfo()
|
|
821 |
{
|
|
822 |
FUNC_LOG;
|
|
823 |
return *iMeetingRequest;
|
|
824 |
}
|
|
825 |
|
|
826 |
// -----------------------------------------------------------------------------
|
|
827 |
// CFSMailMessagePart::IsMRInfoSet
|
|
828 |
// -----------------------------------------------------------------------------
|
|
829 |
EXPORT_C TBool CFSMailMessagePart::IsMRInfoSet()
|
|
830 |
{
|
|
831 |
FUNC_LOG;
|
|
832 |
if(iMeetingRequest)
|
|
833 |
{
|
|
834 |
return ETrue;
|
|
835 |
}
|
|
836 |
else
|
|
837 |
{
|
|
838 |
return EFalse;
|
|
839 |
}
|
|
840 |
}
|
|
841 |
|
|
842 |
// -----------------------------------------------------------------------------
|
|
843 |
// CFSMailMessagePart::SetMRInfo
|
|
844 |
// -----------------------------------------------------------------------------
|
|
845 |
EXPORT_C void CFSMailMessagePart::SetMRInfo(MMRInfoObject* aMeetingRequest)
|
|
846 |
{
|
|
847 |
FUNC_LOG;
|
|
848 |
if(iMeetingRequest)
|
|
849 |
{
|
|
850 |
delete iMeetingRequest;
|
|
851 |
}
|
|
852 |
iMeetingRequest = aMeetingRequest;
|
|
853 |
}
|
|
854 |
|
|
855 |
// -----------------------------------------------------------------------------
|
|
856 |
// CFSMailMessagePart::SaveL
|
|
857 |
// -----------------------------------------------------------------------------
|
|
858 |
EXPORT_C void CFSMailMessagePart::SaveL()
|
|
859 |
{
|
|
860 |
FUNC_LOG;
|
|
861 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
862 |
{
|
|
863 |
plugin->StoreMessagePartL( GetMailBoxId(), GetFolderId(), GetMessageId(), *this );
|
|
864 |
}
|
|
865 |
}
|
|
866 |
|
|
867 |
|
|
868 |
// -----------------------------------------------------------------------------
|
|
869 |
// CFSMailMessagePart::SetAttachmentNameL
|
|
870 |
// -----------------------------------------------------------------------------
|
|
871 |
EXPORT_C void CFSMailMessagePart::SetAttachmentNameL(const TDesC& aFilePath)
|
|
872 |
{
|
|
873 |
FUNC_LOG;
|
|
874 |
// Parse file name in case full path is given
|
|
875 |
TPtrC name;
|
|
876 |
for(TInt i=0;i<aFilePath.Length();)
|
|
877 |
{
|
|
878 |
name.Set(aFilePath.Mid(i,(aFilePath.Length()-i)));
|
|
879 |
TInt skip = name.Locate(KPathDelimiter);
|
|
880 |
if(skip < 0) break;
|
|
881 |
else i += skip + 1;
|
|
882 |
}
|
|
883 |
|
|
884 |
// Set Content-Type param "name" = filename
|
|
885 |
TUint length = KFSMailContentTypeParamName.iTypeLength + name.Length() + 5;
|
|
886 |
if(iContentType)
|
|
887 |
{
|
|
888 |
length += iContentType->Des().Length();
|
|
889 |
}
|
|
890 |
|
|
891 |
HBufC* buffer = HBufC::NewL(length);
|
|
892 |
if(iContentType)
|
|
893 |
{
|
|
894 |
buffer->Des().Append(*iContentType);
|
|
895 |
}
|
|
896 |
buffer->Des().Append(_L("; "));
|
|
897 |
buffer->Des().Append(KFSMailContentTypeParamName);
|
|
898 |
buffer->Des().Append('"');
|
|
899 |
buffer->Des().Append(name);
|
|
900 |
buffer->Des().Append('"');
|
|
901 |
|
|
902 |
// remove old value
|
|
903 |
if(iContentType)
|
|
904 |
{
|
|
905 |
delete iContentType;
|
|
906 |
}
|
|
907 |
iContentType = buffer;
|
|
908 |
|
|
909 |
// Set Content-Disposition as "attachment" and
|
|
910 |
// Content-Disposition param "filename" = filename and
|
|
911 |
// remove old value
|
|
912 |
if(iContentDisposition)
|
|
913 |
{
|
|
914 |
delete iContentDisposition;
|
|
915 |
iContentDisposition = NULL;
|
|
916 |
}
|
|
917 |
length = KFSMailContentDispAttachment.iTypeLength +
|
|
918 |
KFSMailContentDispParamFilename.iTypeLength + name.Length() + 4;
|
|
919 |
iContentDisposition = HBufC::NewL(length);
|
|
920 |
iContentDisposition->Des().Append(KFSMailContentDispAttachment);
|
|
921 |
iContentDisposition->Des().Append(_L("; "));
|
|
922 |
iContentDisposition->Des().Append(KFSMailContentDispParamFilename);
|
|
923 |
iContentDisposition->Des().Append('"');
|
|
924 |
iContentDisposition->Des().Append(name);
|
|
925 |
iContentDisposition->Des().Append('"');
|
|
926 |
|
|
927 |
// set content description
|
|
928 |
// remove old value
|
|
929 |
if(iContentDescription)
|
|
930 |
{
|
|
931 |
delete iContentDescription;
|
|
932 |
iContentDescription = NULL;
|
|
933 |
}
|
|
934 |
iContentDescription = HBufC::NewL(name.Length());
|
|
935 |
iContentDescription->Des().Append(name);
|
|
936 |
|
|
937 |
}
|
|
938 |
|
|
939 |
// -----------------------------------------------------------------------------
|
|
940 |
// CFSMailMessagePart::AttachmentNameL
|
|
941 |
// -----------------------------------------------------------------------------
|
|
942 |
EXPORT_C TDesC& CFSMailMessagePart::AttachmentNameL()
|
|
943 |
{
|
|
944 |
FUNC_LOG;
|
|
945 |
// Look first from Content-Type param "name"
|
|
946 |
TInt ptr = iContentType->Find(KFSMailContentTypeParamName);
|
|
947 |
if(ptr >= 0)
|
|
948 |
{
|
|
949 |
ptr = iContentType->Locate('=');
|
|
950 |
TInt length = iContentType->Length()-ptr-3;
|
|
951 |
TPtrC name = iContentType->Mid((ptr+2),length);
|
|
952 |
if(iAttachmentName)
|
|
953 |
{
|
|
954 |
delete iAttachmentName;
|
|
955 |
iAttachmentName = NULL;
|
|
956 |
}
|
|
957 |
iAttachmentName = HBufC::New(name.Length());
|
|
958 |
iAttachmentName->Des().Copy(name);
|
|
959 |
return *iAttachmentName;
|
|
960 |
}
|
|
961 |
// then if Content-Disposition is "attachment" look from Content-Disposition param "filename" and
|
|
962 |
ptr = iContentDisposition->Find(KFSMailContentDispAttachment);
|
|
963 |
if(ptr >= 0)
|
|
964 |
{
|
|
965 |
ptr = iContentDisposition->Find(KFSMailContentDispParamFilename);
|
|
966 |
if(ptr > 0)
|
|
967 |
{
|
|
968 |
ptr = iContentDisposition->Locate('=');
|
|
969 |
TInt length = iContentDisposition->Length()-ptr-3;
|
|
970 |
TPtrC name = iContentDisposition->Mid(ptr+2,length);
|
|
971 |
if(iAttachmentName)
|
|
972 |
{
|
|
973 |
delete iAttachmentName;
|
|
974 |
iAttachmentName = NULL;
|
|
975 |
}
|
|
976 |
iAttachmentName = HBufC::New(name.Length());
|
|
977 |
iAttachmentName->Des().Copy(name);
|
|
978 |
return *iAttachmentName;
|
|
979 |
}
|
|
980 |
}
|
|
981 |
// finally look if there is Content-Description.
|
|
982 |
return *iContentDescription;
|
|
983 |
}
|
|
984 |
|
|
985 |
// -----------------------------------------------------------------------------
|
|
986 |
// CFSMailMessagePart::FindBodyPartL
|
|
987 |
// -----------------------------------------------------------------------------
|
|
988 |
EXPORT_C CFSMailMessagePart* CFSMailMessagePart::FindBodyPartL(const TDesC& aContentType)
|
|
989 |
{
|
|
990 |
FUNC_LOG;
|
|
991 |
|
|
992 |
TBuf<KMaxDataTypeLength> ptr;
|
|
993 |
if ( iContentType )
|
|
994 |
{
|
|
995 |
ptr.Copy(iContentType->Des());
|
|
996 |
TInt length = ptr.Locate(';');
|
|
997 |
if(length >= 0)
|
|
998 |
{
|
|
999 |
ptr.SetLength(length);
|
|
1000 |
}
|
|
1001 |
|
|
1002 |
if( !ptr.CompareF(aContentType) )
|
|
1003 |
{
|
|
1004 |
return this;
|
|
1005 |
}
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
CFSMailMessagePart* messagePart = NULL;
|
|
1009 |
|
|
1010 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
|
|
1011 |
{
|
|
1012 |
if(iReadMessageParts)
|
|
1013 |
{
|
|
1014 |
plugin->ChildPartsL(GetMailBoxId(),GetFolderId(),GetMessageId(),GetPartId(),iMessageParts);
|
|
1015 |
iReadMessageParts = EFalse;
|
|
1016 |
}
|
|
1017 |
if(iMessageParts.Count())
|
|
1018 |
{
|
|
1019 |
if( !ptr.CompareF(KFSMailContentTypeMultipartAlternative) )
|
|
1020 |
{
|
|
1021 |
// multipart / alternative
|
|
1022 |
for(TInt i=0;i<iMessageParts.Count();i++)
|
|
1023 |
{
|
|
1024 |
ptr.Copy(iMessageParts[i]->GetContentType());
|
|
1025 |
TInt length = ptr.Locate(';');
|
|
1026 |
if(length >= 0)
|
|
1027 |
{
|
|
1028 |
ptr.SetLength(length);
|
|
1029 |
}
|
|
1030 |
if(!ptr.CompareF(aContentType) )
|
|
1031 |
{
|
|
1032 |
messagePart = iMessageParts[i];
|
|
1033 |
// remove part from table
|
|
1034 |
iMessageParts.Remove(i);
|
|
1035 |
break;
|
|
1036 |
}
|
|
1037 |
else if(!ptr.CompareF(KFSMailContentTypeMultipartRelated) ||
|
|
1038 |
!ptr.CompareF(KFSMailContentTypeMultipartMixed) ||
|
|
1039 |
!ptr.CompareF(KFSMailContentTypeMultipartAlternative) ||
|
|
1040 |
!ptr.CompareF(KFSMailContentTypeMultipartDigest) ||
|
|
1041 |
!ptr.CompareF(KFSMailContentTypeMultipartParallel))
|
|
1042 |
{
|
|
1043 |
// multipart, check child parts
|
|
1044 |
messagePart = iMessageParts[i];
|
|
1045 |
// remove part from table
|
|
1046 |
messagePart = messagePart->FindBodyPartL(aContentType);
|
|
1047 |
if(messagePart && messagePart->GetPartId() == iMessageParts[0]->GetPartId())
|
|
1048 |
{
|
|
1049 |
iMessageParts.Remove(i);
|
|
1050 |
}
|
|
1051 |
break;
|
|
1052 |
}
|
|
1053 |
}
|
|
1054 |
}
|
|
1055 |
else
|
|
1056 |
{
|
|
1057 |
// all other cases
|
|
1058 |
messagePart = iMessageParts[0];
|
|
1059 |
// remove part from table
|
|
1060 |
messagePart = messagePart->FindBodyPartL(aContentType);
|
|
1061 |
if(messagePart && messagePart->GetPartId() == iMessageParts[0]->GetPartId())
|
|
1062 |
{
|
|
1063 |
iMessageParts.Remove(0);
|
|
1064 |
}
|
|
1065 |
}
|
|
1066 |
}
|
|
1067 |
}
|
|
1068 |
return messagePart;
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
|
|
1072 |
// -----------------------------------------------------------------------------
|
|
1073 |
// CFSMailMessagePart::ContentTypeMatches
|
|
1074 |
// -----------------------------------------------------------------------------
|
|
1075 |
EXPORT_C TBool CFSMailMessagePart::ContentTypeMatches( const TDesC& aContentType )
|
|
1076 |
{
|
|
1077 |
FUNC_LOG;
|
|
1078 |
|
|
1079 |
TBuf<KMaxDataTypeLength> ptr;
|
|
1080 |
TBool result(EFalse);
|
|
1081 |
if ( iContentType )
|
|
1082 |
{
|
|
1083 |
ptr.Copy(iContentType->Des());
|
|
1084 |
TInt length = ptr.Locate(';');
|
|
1085 |
if(length >= 0)
|
|
1086 |
{
|
|
1087 |
ptr.SetLength(length);
|
|
1088 |
}
|
|
1089 |
|
|
1090 |
if( !ptr.CompareF(aContentType) ) // case-insensitive comparision
|
|
1091 |
{
|
|
1092 |
result = ETrue;
|
|
1093 |
}
|
|
1094 |
}
|
|
1095 |
|
|
1096 |
return result;
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
|
|
1100 |
// -----------------------------------------------------------------------------
|
|
1101 |
// CFSMailMessagePart::AppendAttachmentsL
|
|
1102 |
// -----------------------------------------------------------------------------
|
|
1103 |
EXPORT_C void CFSMailMessagePart::AppendAttachmentsL(
|
|
1104 |
RPointerArray<CFSMailMessagePart>& aParts)
|
|
1105 |
{
|
|
1106 |
FUNC_LOG;
|
|
1107 |
CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetMessageId() );
|
|
1108 |
if ( plugin )
|
|
1109 |
{
|
|
1110 |
RPointerArray<CFSMailMessagePart> messageParts;
|
|
1111 |
CleanupResetAndDestroyPushL( messageParts );
|
|
1112 |
plugin->ChildPartsL( GetMailBoxId(), GetFolderId(),
|
|
1113 |
GetMessageId(), GetPartId(), messageParts );
|
|
1114 |
|
|
1115 |
const TInt messagePartCount = messageParts.Count();
|
|
1116 |
for ( TInt i = 0; i < messagePartCount; i++ )
|
|
1117 |
{
|
|
1118 |
const TDesC& contentType = messageParts[i]->GetContentType();
|
|
1119 |
if (!contentType.CompareF(KFSMailContentTypeMultipartMixed) ||
|
|
1120 |
!contentType.CompareF(KFSMailContentTypeMultipartAlternative) ||
|
|
1121 |
!contentType.CompareF(KFSMailContentTypeMultipartDigest) ||
|
|
1122 |
!contentType.CompareF(KFSMailContentTypeMultipartRelated) ||
|
|
1123 |
!contentType.CompareF(KFSMailContentTypeMultipartParallel))
|
|
1124 |
{
|
|
1125 |
// get multipart message subparts
|
|
1126 |
messageParts[i]->AppendAttachmentsL( aParts );
|
|
1127 |
}
|
|
1128 |
else
|
|
1129 |
{
|
|
1130 |
aParts.AppendL( messageParts[i] );
|
|
1131 |
messageParts[i] = NULL;
|
|
1132 |
}
|
|
1133 |
}
|
|
1134 |
CleanupStack::PopAndDestroy( &messageParts );
|
|
1135 |
}
|
|
1136 |
}
|
|
1137 |
|
|
1138 |
// -----------------------------------------------------------------------------
|
|
1139 |
// CFSMailMessagePart::FetchedContentSize
|
|
1140 |
// -----------------------------------------------------------------------------
|
|
1141 |
EXPORT_C TUint CFSMailMessagePart::FetchedContentSize() const
|
|
1142 |
{
|
|
1143 |
FUNC_LOG;
|
|
1144 |
return iFetchedContentSize;
|
|
1145 |
}
|
|
1146 |
|
|
1147 |
// -----------------------------------------------------------------------------
|
|
1148 |
// CFSMailMessagePart::SetFetchedContentSize
|
|
1149 |
// -----------------------------------------------------------------------------
|
|
1150 |
EXPORT_C void CFSMailMessagePart::SetFetchedContentSize(TUint aContentSize)
|
|
1151 |
{
|
|
1152 |
FUNC_LOG;
|
|
1153 |
iFetchedContentSize = aContentSize;
|
|
1154 |
}
|
|
1155 |
|
|
1156 |
// -----------------------------------------------------------------------------
|
|
1157 |
// CFSMailMessagePart::FetchLoadState
|
|
1158 |
// -----------------------------------------------------------------------------
|
|
1159 |
EXPORT_C TFSPartFetchState CFSMailMessagePart::FetchLoadState() const
|
|
1160 |
{
|
|
1161 |
FUNC_LOG;
|
|
1162 |
|
|
1163 |
if(iMessagePartsStatus != EFSDefault)
|
|
1164 |
{
|
|
1165 |
return iMessagePartsStatus;
|
|
1166 |
}
|
|
1167 |
else if(iContentSize == 0)
|
|
1168 |
{
|
|
1169 |
return EFSFull;
|
|
1170 |
}
|
|
1171 |
else if(iFetchedContentSize == 0)
|
|
1172 |
{
|
|
1173 |
return EFSNone;
|
|
1174 |
}
|
|
1175 |
else if (iFetchedContentSize < iContentSize)
|
|
1176 |
{
|
|
1177 |
return EFSPartial;
|
|
1178 |
}
|
|
1179 |
else
|
|
1180 |
{
|
|
1181 |
return EFSFull;
|
|
1182 |
}
|
|
1183 |
}
|
|
1184 |
|
|
1185 |
// -----------------------------------------------------------------------------
|
|
1186 |
// CFSMailMessagePart::FetchMessagePartL
|
|
1187 |
// -----------------------------------------------------------------------------
|
|
1188 |
EXPORT_C TInt CFSMailMessagePart::FetchMessagePartL( const TFSMailMsgId /*aMessagePartId*/,
|
|
1189 |
MFSMailRequestObserver& aOperationObserver,
|
|
1190 |
const TUint aPreferredByteCount)
|
|
1191 |
{
|
|
1192 |
FUNC_LOG;
|
|
1193 |
|
|
1194 |
TInt requestId(0);
|
|
1195 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
1196 |
{
|
|
1197 |
|
|
1198 |
RArray<TFSMailMsgId> messageList;
|
|
1199 |
messageList.Append(GetPartId());
|
|
1200 |
|
|
1201 |
// init async request
|
|
1202 |
TFSPendingRequest request = iRequestHandler->InitAsyncRequestL( GetPartId().PluginId(),
|
|
1203 |
aOperationObserver);
|
|
1204 |
|
|
1205 |
requestId = request.iRequestId;
|
|
1206 |
MFSMailRequestObserver* observer = request.iObserver;
|
|
1207 |
|
|
1208 |
// fetch message parts
|
|
1209 |
TRAPD(err,plugin->FetchMessagePartsL( GetMailBoxId(),
|
|
1210 |
GetFolderId(),
|
|
1211 |
GetMessageId(),
|
|
1212 |
messageList,
|
|
1213 |
*observer,
|
|
1214 |
requestId,
|
|
1215 |
aPreferredByteCount ));
|
|
1216 |
messageList.Reset();
|
|
1217 |
if(err != KErrNone)
|
|
1218 |
{
|
|
1219 |
iRequestHandler->CompleteRequest(requestId);
|
|
1220 |
User::Leave(err);
|
|
1221 |
}
|
|
1222 |
}
|
|
1223 |
return requestId;
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
// -----------------------------------------------------------------------------
|
|
1227 |
// CFSMailMessagePart::FetchMessagesPartsL
|
|
1228 |
// -----------------------------------------------------------------------------
|
|
1229 |
EXPORT_C TInt CFSMailMessagePart::FetchMessagesPartsL(
|
|
1230 |
const RArray<TFSMailMsgId>& aMessagePartIds,
|
|
1231 |
MFSMailRequestObserver& aOperationObserver,
|
|
1232 |
const TUint aPreferredByteCount)
|
|
1233 |
{
|
|
1234 |
FUNC_LOG;
|
|
1235 |
|
|
1236 |
TInt requestId(0);
|
|
1237 |
|
|
1238 |
if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetPartId()))
|
|
1239 |
{
|
|
1240 |
|
|
1241 |
// get async request id
|
|
1242 |
TFSPendingRequest request =
|
|
1243 |
iRequestHandler->InitAsyncRequestL( GetPartId().PluginId(),
|
|
1244 |
aOperationObserver);
|
|
1245 |
|
|
1246 |
requestId = request.iRequestId;
|
|
1247 |
MFSMailRequestObserver* observer = request.iObserver;
|
|
1248 |
|
|
1249 |
// fetch message parts
|
|
1250 |
TRAPD(err,plugin->FetchMessagePartsL( GetMailBoxId(),
|
|
1251 |
GetFolderId(),
|
|
1252 |
GetMessageId(),
|
|
1253 |
aMessagePartIds,
|
|
1254 |
*observer,
|
|
1255 |
requestId,
|
|
1256 |
aPreferredByteCount ));
|
|
1257 |
|
|
1258 |
if(err != KErrNone)
|
|
1259 |
{
|
|
1260 |
iRequestHandler->CompleteRequest(requestId);
|
|
1261 |
User::Leave(err);
|
|
1262 |
}
|
|
1263 |
}
|
|
1264 |
else
|
|
1265 |
{
|
|
1266 |
User::Leave(KErrArgument);
|
|
1267 |
}
|
|
1268 |
return requestId;
|
|
1269 |
}
|
|
1270 |
|
|
1271 |
// -----------------------------------------------------------------------------
|
|
1272 |
// CFSMailMessagePart::SetMessagePartsStatus
|
|
1273 |
// -----------------------------------------------------------------------------
|
|
1274 |
EXPORT_C void CFSMailMessagePart::SetMessagePartsStatus(TFSPartFetchState aMessagePartStatus)
|
|
1275 |
{
|
|
1276 |
FUNC_LOG;
|
|
1277 |
iMessagePartsStatus = aMessagePartStatus;
|
|
1278 |
}
|
|
1279 |
|
|
1280 |
// -----------------------------------------------------------------------------
|
|
1281 |
// CFSMailMessagePart::AddNewAttachmentL
|
|
1282 |
// -----------------------------------------------------------------------------
|
|
1283 |
EXPORT_C CFSMailMessagePart* CFSMailMessagePart::AddNewAttachmentL( const TDesC& aFilePath,
|
|
1284 |
const TFSMailMsgId /*aInsertBefore*/,
|
|
1285 |
const TDesC& aContentType )
|
|
1286 |
{
|
|
1287 |
FUNC_LOG;
|
|
1288 |
CFSMailMessagePart* newPart = NULL;
|
|
1289 |
|
|
1290 |
CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid( GetMessageId() );
|
|
1291 |
if ( plugin )
|
|
1292 |
{
|
|
1293 |
newPart = plugin->NewChildPartFromFileL( GetMailBoxId(),
|
|
1294 |
GetFolderId(),
|
|
1295 |
GetMessageId(),
|
|
1296 |
GetPartId(),
|
|
1297 |
aContentType, //contentType,
|
|
1298 |
aFilePath );
|
|
1299 |
|
|
1300 |
CleanupStack::PushL( newPart );
|
|
1301 |
|
|
1302 |
// Set attachment name
|
|
1303 |
newPart->SetAttachmentNameL( aFilePath );
|
|
1304 |
|
|
1305 |
// save message part
|
|
1306 |
newPart->SaveL();
|
|
1307 |
|
|
1308 |
CleanupStack::Pop( newPart );
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
return newPart;
|
|
1312 |
}
|
|
1313 |
|
|
1314 |
// -----------------------------------------------------------------------------
|
|
1315 |
// CFSMailMessagePart::ReadOnlyPartSize
|
|
1316 |
// -----------------------------------------------------------------------------
|
|
1317 |
EXPORT_C TUint CFSMailMessagePart::ReadOnlyPartSize() const
|
|
1318 |
{
|
|
1319 |
FUNC_LOG;
|
|
1320 |
return iReadOnlyPartSize;
|
|
1321 |
}
|
|
1322 |
|
|
1323 |
// -----------------------------------------------------------------------------
|
|
1324 |
// CFSMailMessagePart::SetReadOnlyPartSize
|
|
1325 |
// -----------------------------------------------------------------------------
|
|
1326 |
EXPORT_C void CFSMailMessagePart::SetReadOnlyPartSize(const TUint aReadOnlyPartSize)
|
|
1327 |
{
|
|
1328 |
FUNC_LOG;
|
|
1329 |
iReadOnlyPartSize = aReadOnlyPartSize;
|
|
1330 |
}
|
|
1331 |
// -----------------------------------------------------------------------------
|
|
1332 |
// CFSMailMessagePart::DoAttachmentListL
|
|
1333 |
// -----------------------------------------------------------------------------
|
|
1334 |
void CFSMailMessagePart::DoAttachmentListL( RPointerArray<CFSMailMessagePart>& /*aParts*/ )
|
|
1335 |
{
|
|
1336 |
FUNC_LOG;
|
|
1337 |
|
|
1338 |
}
|
|
1339 |
|