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