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 "emailattachment.h"
|
|
19 |
#include "emailcontent.h"
|
|
20 |
#include "emailclientapi.hrh"
|
|
21 |
|
|
22 |
// -----------------------------------------------------------------------------
|
|
23 |
//
|
|
24 |
// -----------------------------------------------------------------------------/
|
|
25 |
CEmailAttachment::CEmailAttachment( const TDataOwner aOwner ) : iOwner( aOwner )
|
|
26 |
{
|
|
27 |
}
|
|
28 |
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
CEmailAttachment::~CEmailAttachment()
|
|
33 |
{
|
|
34 |
delete iEmailMsgContent;
|
|
35 |
}
|
|
36 |
|
|
37 |
// -----------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
// -----------------------------------------------------------------------------
|
|
40 |
CEmailAttachment* CEmailAttachment::NewLC(
|
|
41 |
CPluginData& aPluginData,
|
|
42 |
const TMessageContentId& aMsgContentId,
|
|
43 |
CFSMailMessagePart *aAtt,
|
|
44 |
const TDataOwner aOwner )
|
|
45 |
{
|
|
46 |
CEmailAttachment* self = new (ELeave) CEmailAttachment( aOwner );
|
|
47 |
CleanupStack::PushL( self );
|
|
48 |
self->ConstructL( aPluginData, aMsgContentId, aAtt );
|
|
49 |
|
|
50 |
return self;
|
|
51 |
}
|
|
52 |
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
CEmailAttachment* CEmailAttachment::NewL(
|
|
57 |
CPluginData& aPluginData,
|
|
58 |
const TMessageContentId& aMsgContentId,
|
|
59 |
CFSMailMessagePart *aAtt,
|
|
60 |
const TDataOwner aOwner )
|
|
61 |
{
|
|
62 |
CEmailAttachment* self = CEmailAttachment::NewLC( aPluginData, aMsgContentId, aAtt, aOwner );
|
|
63 |
CleanupStack::Pop( self );
|
|
64 |
|
|
65 |
return self;
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
void CEmailAttachment::ConstructL(
|
|
72 |
CPluginData& aPluginData,
|
|
73 |
const TMessageContentId& aMsgContentId,
|
|
74 |
CFSMailMessagePart *aAtt)
|
|
75 |
{
|
|
76 |
iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aAtt );
|
|
77 |
}
|
|
78 |
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
TInt CEmailAttachment::AvailableSize() const
|
|
83 |
{
|
|
84 |
return iEmailMsgContent->AvailableSize();
|
|
85 |
}
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
void CEmailAttachment::CancelFetch()
|
|
91 |
{
|
|
92 |
iEmailMsgContent->CancelFetch();
|
|
93 |
}
|
|
94 |
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
TPtrC CEmailAttachment::ContentL() const
|
|
99 |
{
|
|
100 |
User::Leave(KErrNotSupported);
|
|
101 |
return iEmailMsgContent->ContentL();
|
|
102 |
}
|
|
103 |
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
TPtrC CEmailAttachment::ContentClass() const
|
|
108 |
{
|
|
109 |
return iEmailMsgContent->ContentClass();
|
|
110 |
}
|
|
111 |
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
TPtrC CEmailAttachment::ContentDescription() const
|
|
116 |
{
|
|
117 |
return iEmailMsgContent->ContentDescription();
|
|
118 |
}
|
|
119 |
|
|
120 |
// -----------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
// -----------------------------------------------------------------------------
|
|
123 |
TPtrC CEmailAttachment::ContentDisposition() const
|
|
124 |
{
|
|
125 |
return iEmailMsgContent->ContentDisposition();
|
|
126 |
}
|
|
127 |
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
TPtrC CEmailAttachment::ContentId() const
|
|
132 |
{
|
|
133 |
return iEmailMsgContent->ContentId();
|
|
134 |
}
|
|
135 |
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
TPtrC CEmailAttachment::ContentType() const
|
|
140 |
{
|
|
141 |
return iEmailMsgContent->ContentType();
|
|
142 |
}
|
|
143 |
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
void CEmailAttachment::FetchL( MEmailFetchObserver & aObserver )
|
|
148 |
{
|
|
149 |
iEmailMsgContent->FetchL( aObserver );
|
|
150 |
}
|
|
151 |
|
|
152 |
// -----------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
TMessageContentId CEmailAttachment::Id() const
|
|
156 |
{
|
|
157 |
return iEmailMsgContent->Id();
|
|
158 |
}
|
|
159 |
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
TEmailTypeId CEmailAttachment::InterfaceId() const
|
|
164 |
{
|
|
165 |
return KEmailIFUidAttachment;
|
|
166 |
}
|
|
167 |
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
// -----------------------------------------------------------------------------
|
|
171 |
void CEmailAttachment::Release()
|
|
172 |
{
|
|
173 |
if ( iOwner == EClientOwns )
|
|
174 |
{
|
|
175 |
delete this;
|
|
176 |
}
|
|
177 |
}
|
|
178 |
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
// -----------------------------------------------------------------------------
|
|
182 |
void CEmailAttachment::SaveToFileL( const TDesC& aPath )
|
|
183 |
{
|
|
184 |
iEmailMsgContent->SaveToFileL( aPath );
|
|
185 |
}
|
|
186 |
|
|
187 |
// -----------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
void CEmailAttachment::SetContentClass( const TDesC& aContentClass )
|
|
191 |
{
|
|
192 |
iEmailMsgContent->SetContentClass( aContentClass );
|
|
193 |
}
|
|
194 |
|
|
195 |
// -----------------------------------------------------------------------------
|
|
196 |
//
|
|
197 |
// -----------------------------------------------------------------------------
|
|
198 |
void CEmailAttachment::SetContentDescription( const TDesC& aContentDescription )
|
|
199 |
{
|
|
200 |
iEmailMsgContent->SetContentDescription(aContentDescription);
|
|
201 |
}
|
|
202 |
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
// -----------------------------------------------------------------------------
|
|
206 |
void CEmailAttachment::SetContentDisposition( const TDesC& aContentDisposition )
|
|
207 |
{
|
|
208 |
iEmailMsgContent->SetContentDisposition( aContentDisposition );
|
|
209 |
}
|
|
210 |
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
// -----------------------------------------------------------------------------
|
|
214 |
void CEmailAttachment::SetContentId( const TDesC &aContentId )
|
|
215 |
{
|
|
216 |
iEmailMsgContent->SetContentId( aContentId );
|
|
217 |
}
|
|
218 |
|
|
219 |
// -----------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
void CEmailAttachment::SetContentL( const TDesC &aContent )
|
|
223 |
{
|
|
224 |
iEmailMsgContent->SetContentL( aContent );
|
|
225 |
}
|
|
226 |
|
|
227 |
// -----------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
void CEmailAttachment::SetContentType( const TDesC &aContentType )
|
|
231 |
{
|
|
232 |
iEmailMsgContent->SetContentType( aContentType );
|
|
233 |
}
|
|
234 |
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
// -----------------------------------------------------------------------------
|
|
238 |
TInt CEmailAttachment::TotalSize() const
|
|
239 |
{
|
|
240 |
return iEmailMsgContent->TotalSize();
|
|
241 |
}
|
|
242 |
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
//
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
MEmailMultipart* CEmailAttachment::AsMultipartOrNull() const
|
|
247 |
{
|
|
248 |
return NULL;
|
|
249 |
}
|
|
250 |
|
|
251 |
// -----------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
// -----------------------------------------------------------------------------
|
|
254 |
MEmailTextContent* CEmailAttachment::AsTextContentOrNull() const
|
|
255 |
{
|
|
256 |
return NULL;
|
|
257 |
}
|
|
258 |
|
|
259 |
// -----------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
MEmailAttachment* CEmailAttachment::AsAttachmentOrNull() const
|
|
263 |
{
|
|
264 |
const MEmailAttachment* ptr = this;
|
|
265 |
return const_cast<MEmailAttachment *>( ptr );
|
|
266 |
}
|
|
267 |
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
//
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
RFile CEmailAttachment::FileL() const
|
|
272 |
{
|
|
273 |
return iEmailMsgContent->Part().GetContentFileL();
|
|
274 |
}
|
|
275 |
|
|
276 |
// -----------------------------------------------------------------------------
|
|
277 |
//
|
|
278 |
// -----------------------------------------------------------------------------/
|
|
279 |
void CEmailAttachment::SetFileNameL( const TDesC& aFileName )
|
|
280 |
{
|
|
281 |
iEmailMsgContent->Part().SetAttachmentNameL( aFileName );
|
|
282 |
}
|
|
283 |
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
// -----------------------------------------------------------------------------
|
|
287 |
TPtrC CEmailAttachment::FileNameL() const
|
|
288 |
{
|
|
289 |
return iEmailMsgContent->Part().AttachmentNameL();
|
|
290 |
}
|
|
291 |
|
|
292 |
// End of file
|