47
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 CEmailAttachment.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "emailcontent.h"
|
|
19 |
#include "emailtextcontent.h"
|
|
20 |
#include "emailattachment.h"
|
|
21 |
#include "emailmultipart.h"
|
|
22 |
#include "emailmessage.h"
|
|
23 |
#include "emailclientapi.hrh"
|
|
24 |
|
|
25 |
// -----------------------------------------------------------------------------
|
|
26 |
//
|
|
27 |
// -----------------------------------------------------------------------------
|
|
28 |
CEmailMultipart* CEmailMultipart::NewL(
|
|
29 |
CPluginData& aPluginData,
|
|
30 |
const TMessageContentId& aMsgContentId,
|
|
31 |
CFSMailMessagePart* aPart,
|
|
32 |
const TDataOwner aOwner )
|
|
33 |
{
|
|
34 |
CEmailMultipart* self = new ( ELeave ) CEmailMultipart( aOwner );
|
|
35 |
CleanupStack::PushL( self );
|
|
36 |
self->ConstructL( aPluginData, aMsgContentId, aPart );
|
|
37 |
CleanupStack::Pop( self );
|
|
38 |
return self;
|
|
39 |
}
|
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
void CEmailMultipart::ConstructL(
|
|
45 |
CPluginData& aPluginData,
|
|
46 |
const TMessageContentId& aMsgContentId,
|
|
47 |
CFSMailMessagePart* aPart )
|
|
48 |
{
|
|
49 |
iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aPart );
|
|
50 |
}
|
|
51 |
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
CEmailMultipart::~CEmailMultipart()
|
|
56 |
{
|
|
57 |
delete iEmailMsgContent;
|
|
58 |
iChildParts.Reset();
|
|
59 |
}
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
CEmailMultipart::CEmailMultipart( const TDataOwner aOwner ) : iOwner( aOwner )
|
|
65 |
{
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
TInt CEmailMultipart::PartCountL()
|
|
72 |
{
|
|
73 |
iChildParts.Reset();
|
|
74 |
RPointerArray<CFSMailMessagePart> childParts;
|
|
75 |
CleanupResetAndDestroyPushL( childParts );
|
|
76 |
iEmailMsgContent->Part().ChildPartsL( childParts );
|
|
77 |
iChildPartCount = childParts.Count();
|
|
78 |
|
|
79 |
for ( TInt i = 0; i < iChildPartCount; i++ )
|
|
80 |
{
|
|
81 |
TFSMailMsgId id = childParts[i]->GetPartId();
|
|
82 |
iChildParts.AppendL( id );
|
|
83 |
}
|
|
84 |
CleanupStack::PopAndDestroy( &childParts );
|
|
85 |
return iChildPartCount;
|
|
86 |
}
|
|
87 |
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
MEmailMessageContent* CEmailMultipart::PartByIndexL( const TUint aIndex ) const
|
|
92 |
{
|
|
93 |
if ( aIndex >= iChildPartCount )
|
|
94 |
{
|
|
95 |
User::Leave( KErrArgument );
|
|
96 |
}
|
|
97 |
MEmailMessageContent* content = NULL;
|
|
98 |
TFSMailMsgId partId = iChildParts[aIndex];
|
|
99 |
CFSMailMessagePart* copy = iEmailMsgContent->Part().ChildPartL( partId );
|
|
100 |
if ( !copy )
|
|
101 |
return content;
|
|
102 |
|
|
103 |
TContentType contentType( copy->GetContentType() );
|
|
104 |
TMessageContentId msgContentId = TMessageContentId(
|
|
105 |
copy->GetPartId().Id(),
|
|
106 |
Id().iMessageId.iId,
|
|
107 |
Id().iMessageId.iFolderId.iId,
|
|
108 |
Id().iMessageId.iFolderId.iMailboxId );
|
|
109 |
|
|
110 |
if ( contentType.Equals( KFSMailContentTypeTextPlain ) ||
|
|
111 |
contentType.Equals( KFSMailContentTypeTextHtml ) )
|
|
112 |
{
|
|
113 |
content = CEmailTextContent::NewL(
|
|
114 |
iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
|
|
115 |
}
|
|
116 |
else if ( contentType.Equals( KFSMailContentTypeMultipartMixed ) ||
|
|
117 |
contentType.Equals( KFSMailContentTypeMultipartAlternative ) ||
|
|
118 |
contentType.Equals( KFSMailContentTypeMultipartDigest ) ||
|
|
119 |
contentType.Equals( KFSMailContentTypeMultipartRelated ) ||
|
|
120 |
contentType.Equals( KFSMailContentTypeMultipartParallel ) )
|
|
121 |
{
|
|
122 |
content = CEmailMultipart::NewL(
|
|
123 |
iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
|
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
|
127 |
content = CEmailAttachment::NewL(
|
|
128 |
iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
|
|
129 |
}
|
|
130 |
return content;
|
|
131 |
}
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
//
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
void CEmailMultipart::DeletePartL( const TUint aIndex )
|
|
137 |
{
|
|
138 |
if ( aIndex >= iChildPartCount )
|
|
139 |
{
|
|
140 |
User::Leave( KErrArgument );
|
|
141 |
}
|
|
142 |
|
|
143 |
TFSMailMsgId partId = iChildParts[aIndex];
|
|
144 |
iEmailMsgContent->Part().RemoveChildPartL( partId );
|
|
145 |
iChildParts.Remove( aIndex );
|
|
146 |
iChildPartCount--;
|
|
147 |
}
|
|
148 |
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
//
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
void CEmailMultipart::AddPartL(
|
|
153 |
const MEmailMessageContent& aPart,
|
|
154 |
const TUint aPos )
|
|
155 |
{
|
|
156 |
if ( aPos > iChildPartCount )
|
|
157 |
{
|
|
158 |
User::Leave( KErrArgument );
|
|
159 |
}
|
|
160 |
|
|
161 |
TFSMailMsgId insertBefore = TFSMailMsgId();
|
|
162 |
if ( aPos < iChildPartCount )
|
|
163 |
{
|
|
164 |
insertBefore = iChildParts[aPos];
|
|
165 |
}
|
|
166 |
const TDesC& contentType = aPart.ContentType();
|
|
167 |
|
|
168 |
CFSMailMessagePart* newPart =
|
|
169 |
iEmailMsgContent->Part().NewChildPartL( insertBefore, contentType );
|
|
170 |
CleanupStack::PushL( newPart );
|
|
171 |
TFSMailMsgId newPartId = newPart->GetPartId();
|
|
172 |
iChildParts.InsertL( newPartId, aPos );
|
|
173 |
iChildPartCount = iChildParts.Count();
|
|
174 |
CleanupStack::Pop( newPart );
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
return;
|
|
179 |
}
|
|
180 |
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
TEmailTypeId CEmailMultipart::InterfaceId() const
|
|
185 |
{
|
|
186 |
return KEmailIFUidMultipart;
|
|
187 |
}
|
|
188 |
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
void CEmailMultipart::Release()
|
|
193 |
{
|
|
194 |
if ( iOwner == EClientOwns )
|
|
195 |
{
|
|
196 |
delete this;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
|
|
200 |
// -----------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
// -----------------------------------------------------------------------------
|
|
203 |
TMessageContentId CEmailMultipart::Id() const
|
|
204 |
{
|
|
205 |
return iEmailMsgContent->Id();
|
|
206 |
}
|
|
207 |
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
TPtrC CEmailMultipart::ContentType() const
|
|
212 |
{
|
|
213 |
return iEmailMsgContent->ContentType();
|
|
214 |
}
|
|
215 |
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
//
|
|
218 |
// -----------------------------------------------------------------------------
|
|
219 |
void CEmailMultipart::SetContentType( const TDesC& aContentType )
|
|
220 |
{
|
|
221 |
iEmailMsgContent->SetContentType( aContentType );
|
|
222 |
}
|
|
223 |
|
|
224 |
// -----------------------------------------------------------------------------
|
|
225 |
//
|
|
226 |
// -----------------------------------------------------------------------------
|
|
227 |
TPtrC CEmailMultipart::ContentId() const
|
|
228 |
{
|
|
229 |
return iEmailMsgContent->ContentId();
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
void CEmailMultipart::SetContentId( const TDesC& aContentId )
|
|
236 |
{
|
|
237 |
iEmailMsgContent->SetContentId( aContentId );
|
|
238 |
}
|
|
239 |
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
// -----------------------------------------------------------------------------
|
|
243 |
TPtrC CEmailMultipart::ContentDescription() const
|
|
244 |
{
|
|
245 |
return iEmailMsgContent->ContentDescription();
|
|
246 |
}
|
|
247 |
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
// -----------------------------------------------------------------------------
|
|
251 |
void CEmailMultipart::SetContentDescription( const TDesC& aContentDescription )
|
|
252 |
{
|
|
253 |
iEmailMsgContent->SetContentDescription( aContentDescription );
|
|
254 |
}
|
|
255 |
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
//
|
|
258 |
// -----------------------------------------------------------------------------
|
|
259 |
TPtrC CEmailMultipart::ContentDisposition() const
|
|
260 |
{
|
|
261 |
return iEmailMsgContent->ContentDisposition();
|
|
262 |
}
|
|
263 |
|
|
264 |
// -----------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
// -----------------------------------------------------------------------------
|
|
267 |
void CEmailMultipart::SetContentDisposition( const TDesC& aContentDisposition )
|
|
268 |
{
|
|
269 |
iEmailMsgContent->SetContentDisposition( aContentDisposition );
|
|
270 |
}
|
|
271 |
|
|
272 |
// -----------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
TPtrC CEmailMultipart::ContentClass() const
|
|
276 |
{
|
|
277 |
return iEmailMsgContent->ContentClass();
|
|
278 |
}
|
|
279 |
|
|
280 |
// -----------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
void CEmailMultipart::SetContentClass( const TDesC& aContentClass )
|
|
284 |
{
|
|
285 |
iEmailMsgContent->SetContentClass( aContentClass );
|
|
286 |
}
|
|
287 |
|
|
288 |
// -----------------------------------------------------------------------------
|
|
289 |
//
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
TInt CEmailMultipart::AvailableSize() const
|
|
292 |
{
|
|
293 |
return iEmailMsgContent->AvailableSize();
|
|
294 |
}
|
|
295 |
|
|
296 |
// -----------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
TInt CEmailMultipart::TotalSize() const
|
|
300 |
{
|
|
301 |
return iEmailMsgContent->TotalSize();
|
|
302 |
}
|
|
303 |
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
//
|
|
306 |
// -----------------------------------------------------------------------------
|
|
307 |
TPtrC CEmailMultipart::ContentL() const
|
|
308 |
{
|
|
309 |
User::Leave(KErrNotSupported);
|
|
310 |
return iEmailMsgContent->ContentL();
|
|
311 |
}
|
|
312 |
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
// -----------------------------------------------------------------------------
|
|
316 |
void CEmailMultipart::SetContentL( const TDesC& aContent )
|
|
317 |
{
|
|
318 |
iEmailMsgContent->SetContentL( aContent );
|
|
319 |
}
|
|
320 |
|
|
321 |
// -----------------------------------------------------------------------------
|
|
322 |
//
|
|
323 |
// -----------------------------------------------------------------------------
|
|
324 |
void CEmailMultipart::FetchL( MEmailFetchObserver& aObserver )
|
|
325 |
{
|
|
326 |
iEmailMsgContent->FetchL( aObserver );
|
|
327 |
}
|
|
328 |
|
|
329 |
// -----------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
// -----------------------------------------------------------------------------
|
|
332 |
void CEmailMultipart::CancelFetch()
|
|
333 |
{
|
|
334 |
iEmailMsgContent->CancelFetch();
|
|
335 |
}
|
|
336 |
|
|
337 |
// -----------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
// -----------------------------------------------------------------------------
|
|
340 |
void CEmailMultipart::SaveToFileL( const TDesC& aPath )
|
|
341 |
{
|
|
342 |
iEmailMsgContent->SaveToFileL( aPath );
|
|
343 |
}
|
|
344 |
|
|
345 |
// -----------------------------------------------------------------------------
|
|
346 |
//
|
|
347 |
// -----------------------------------------------------------------------------
|
|
348 |
MEmailMultipart* CEmailMultipart::AsMultipartOrNull() const
|
|
349 |
{
|
|
350 |
const MEmailMultipart* ptr = this;
|
|
351 |
return const_cast<MEmailMultipart*>( ptr );
|
|
352 |
}
|
|
353 |
|
|
354 |
// -----------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
// -----------------------------------------------------------------------------
|
|
357 |
MEmailTextContent* CEmailMultipart::AsTextContentOrNull() const
|
|
358 |
{
|
|
359 |
return NULL;
|
|
360 |
}
|
|
361 |
|
|
362 |
// -----------------------------------------------------------------------------
|
|
363 |
//
|
|
364 |
// -----------------------------------------------------------------------------
|
|
365 |
MEmailAttachment* CEmailMultipart::AsAttachmentOrNull() const
|
|
366 |
{
|
|
367 |
return NULL;
|
|
368 |
}
|
|
369 |
|
|
370 |
// -----------------------------------------------------------------------------
|
|
371 |
//
|
|
372 |
// -----------------------------------------------------------------------------
|
|
373 |
void CEmailMultipart::SetOwner( const TDataOwner aOwner )
|
|
374 |
{
|
|
375 |
iOwner = aOwner;
|
|
376 |
}
|
|
377 |
|
|
378 |
// End of file
|