|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // IMCVSEND.H |
|
15 // |
|
16 |
|
17 #if !defined(__IMCVSEND_H__) |
|
18 #define __IMCVSEND_H__ |
|
19 |
|
20 #include <s32mem.h> |
|
21 #include <badesca.h> |
|
22 #include <miutatch.h> |
|
23 #include <miuthdr.h> |
|
24 #include <mentact.h> |
|
25 #include <msvuids.h> |
|
26 #include <msventry.h> |
|
27 #include <smtpset.h> |
|
28 |
|
29 #include <imutdll.h> |
|
30 #include <imcvtext.h> |
|
31 #include <imcvcodc.h> |
|
32 #include <imcvutil.h> |
|
33 |
|
34 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
35 #include "timrfc822datefield.h" |
|
36 #include "cimconvertheader.h" |
|
37 #endif |
|
38 |
|
39 class CImSendEmail; |
|
40 class CImEmailTraverser; |
|
41 class CImSendPlainEmail; |
|
42 class CImSendMimeEmail; |
|
43 class CImSendMimeHeader; |
|
44 class CImSendRfc822Header; |
|
45 class CImSendRichText; |
|
46 class CImSendFile; |
|
47 class CMsvPlainBodyText; |
|
48 |
|
49 /** |
|
50 @internalComponent |
|
51 @released |
|
52 */ |
|
53 enum TMimeHeaderType { EMainMimeHeader, EPartMimeHeader }; |
|
54 |
|
55 |
|
56 const TImHeaderEncodingInfo::TEncodingType |
|
57 KDefaultSendingHeaderEncoding = TImHeaderEncodingInfo::EBase64; |
|
58 const TUint KDefaultSendingCharset = KCharacterSetIdentifierIso88591; |
|
59 const TInt KArrayAllocationNumber =6; |
|
60 |
|
61 /** |
|
62 The number of US ASCII UU Encoded characters per line between the CRLF line |
|
63 terminator and the character count at the beginning of the encoded line when sending |
|
64 UU encoded emails. |
|
65 */ |
|
66 const TInt KMaxUUUnEncodedCharsPerLine = 45; // Historically, UU implmentations use 45. |
|
67 const TInt KMaxUUEncodedCharsPerLine = static_cast<TInt>(KMaxUUUnEncodedCharsPerLine / 0.75); // 60. |
|
68 |
|
69 /** |
|
70 The maximum number of US ASCII characters per line that are before the CRLF line |
|
71 terminator when sending emails. RFC 2822 recommends that each line SHOULD not exceed |
|
72 80 characters including the CRLF terminator, and MUST not exceed 1000. |
|
73 */ |
|
74 const TInt KMaxB64EncodedCharsPerLine = 60; // Could be increased to 75 characters for every encoded line if KDecodeLineLength = 675. 60 was chosen to maintain existing behaviour. |
|
75 |
|
76 /** |
|
77 Size of 8 bit data chunk to extract when encoding using B64 or UU. |
|
78 The size allows for the appending of CRLF every KMaxEncodedCharsPerLine |
|
79 characters after encoding to limit the line length as per RFC 2822. |
|
80 The size also allows for the expansion of every 3 bytes of unencoded data to |
|
81 4 bytes when encoded. |
|
82 */ |
|
83 const TInt KDecodeLineLength = 675; // 675/0.75= 900 = 100 bytes left for CRLF and UU length chars, 900/45 = exactly 20 UU lines per SMTP buffer sent, 900/60 = exactly 15 B64 lines per SMTP buffer sent. |
|
84 |
|
85 |
|
86 // External interface to imcvsend. |
|
87 |
|
88 //---------------------------------------------------------------------------------------- |
|
89 class CImSendMessage : public CBase |
|
90 //---------------------------------------------------------------------------------------- |
|
91 /** |
|
92 @internalAll |
|
93 @released |
|
94 */ |
|
95 { |
|
96 public: |
|
97 IMPORT_C static CImSendMessage* NewL(CMsvServerEntry& aServerEntry); |
|
98 IMPORT_C static CImSendMessage* NewLC(CMsvServerEntry& aServerEntry); |
|
99 |
|
100 IMPORT_C ~CImSendMessage( ); |
|
101 |
|
102 // Returns KImcvFinished when done. |
|
103 IMPORT_C TInt NextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
104 IMPORT_C void InitialiseL(TMsvId aMessageId, const TTime aTimeDate, |
|
105 const TDesC& aDomainName, const TImEmailTransformingInfo& aInfo, |
|
106 const TImSMTPSendCopyToSelf aCopyToSelf); |
|
107 IMPORT_C void InitialiseL(TMsvId aMessageId, TImSendMethod aSendMethod, const TTime aTimeDate, |
|
108 const TDesC& aDomainName, TUint aCharset, const TImSMTPSendCopyToSelf aCopyToSelf); |
|
109 IMPORT_C TInt HeaderSize(); |
|
110 IMPORT_C TInt BodySizeL(); |
|
111 IMPORT_C void Reset(); |
|
112 |
|
113 private: |
|
114 |
|
115 CImSendMessage(CMsvServerEntry& aServerEntry); |
|
116 void ConstructL(); |
|
117 void SetSendMethodL(TImSendMethod aSendMethod); |
|
118 |
|
119 private: |
|
120 CMsvServerEntry& iServerEntry; |
|
121 |
|
122 CImSendEmail* iSendEmail; |
|
123 TMsvId iMessageId; |
|
124 TTime iTimeDate; |
|
125 |
|
126 TBool iLogFileExists; // Logging. |
|
127 RFile iLogFile; |
|
128 }; |
|
129 |
|
130 |
|
131 |
|
132 // This class is a VIRTUAL base class from which email protocol classes are derived. |
|
133 // gives derived classes ability to traverse the entry structure and extract |
|
134 // information from entries. |
|
135 // It determines which entry to set the current context to and which entry will follow, |
|
136 // and knows when the end of the message has been reached. |
|
137 |
|
138 //---------------------------------------------------------------------------------------- |
|
139 class CImSendEmail : public CBase |
|
140 //---------------------------------------------------------------------------------------- |
|
141 /** |
|
142 @internalComponent |
|
143 @released |
|
144 */ |
|
145 { |
|
146 public: |
|
147 CImSendEmail(CMsvServerEntry& aServerEntry); |
|
148 ~CImSendEmail( ); |
|
149 |
|
150 virtual TInt NextLineL(TDes8& rOutputLine, TInt& rPaddingCount) = 0; |
|
151 virtual void Reset(); |
|
152 |
|
153 virtual void InitialiseL( const TTime aTimeDate, const TDesC& aDomainName, |
|
154 const TImSMTPSendCopyToSelf aCopyToSelf, |
|
155 const TImEmailTransformingInfo& aTransformingInfo); |
|
156 virtual TInt HeaderSize(); |
|
157 virtual TInt BodySizeL(); |
|
158 |
|
159 protected: |
|
160 virtual void ConstructL(); // Call base class Construct in the derived function |
|
161 TBool InitBodyObjectL(TMsvEntry& rEntry); |
|
162 TBool InitAttachmentObjectL(TMsvEntry& rEntry); |
|
163 TImFileCodec& Encoder(TImEncodingType aType); |
|
164 |
|
165 protected: |
|
166 CMsvServerEntry& iServerEntry; |
|
167 |
|
168 // Encoding classes including a default. |
|
169 TImCodecNull iNULLEncoder; |
|
170 TImCodecUU iUUEncoder; |
|
171 TImCodecB64WithLineBreaks iB64Encoder; |
|
172 TImCodecQP iQPEncoder; |
|
173 |
|
174 // Objects common to all email types |
|
175 |
|
176 CImSendFile* iSendFile; |
|
177 CImSendRfc822Header* iRfc822Header; |
|
178 CImSendRichText* iSendRichText; |
|
179 |
|
180 CImConvertCharconv* iCharConv; |
|
181 CCnvCharacterSetConverter* iCharacterConverter; |
|
182 CImConvertHeader* iHeaderConverter; |
|
183 |
|
184 TInt iState; |
|
185 CImEmailTraverser* iEmailTraverser; |
|
186 CImHeader* iHeader; |
|
187 |
|
188 TInt iEmbeddedEmail; |
|
189 |
|
190 TTime iTimeDate; |
|
191 TPtrC iDomainName; |
|
192 |
|
193 TUint iAlgorithm; // used for encoding a body/attachment. |
|
194 TImEmailTransformingInfo iDefaultTransformingInfo; |
|
195 }; |
|
196 |
|
197 |
|
198 // Traverses the TMsvEntry structure of email message, used by CImSendEmail. |
|
199 // Complex email messages have a hierarchical structure with more than one LEVEL. |
|
200 |
|
201 //---------------------------------------------------------------------------------------- |
|
202 class CImEmailTraverser : CBase |
|
203 //---------------------------------------------------------------------------------------- |
|
204 /** |
|
205 @internalComponent |
|
206 @released |
|
207 */ |
|
208 { |
|
209 public: |
|
210 static CImEmailTraverser* NewL( CMsvServerEntry& aServerEntry ); |
|
211 ~CImEmailTraverser(); |
|
212 void InitialiseL(TMsvId aId); |
|
213 |
|
214 TBool NextEntryL(TMsvEntry& rEntry); |
|
215 TBool DownLevelL(); |
|
216 TBool UpLevelL(); |
|
217 inline void SetBaseEntry(); |
|
218 |
|
219 inline TBool IsBaseLevel() const; |
|
220 inline CMsvEntrySelection& CurrentList() const; |
|
221 inline const TMsvEntry& ThisEntry() const; |
|
222 |
|
223 private: |
|
224 CImEmailTraverser( CMsvServerEntry& aServerEntry ); |
|
225 void ConstructL(); |
|
226 void Reset(); |
|
227 |
|
228 inline TBool LevelExists() const; |
|
229 inline TBool DeleteCurrentList(); |
|
230 inline void AddList(CMsvEntrySelection& children); |
|
231 inline TInt CurrentEntry(); |
|
232 |
|
233 private: |
|
234 TMsvId iBaseId; // ID of the Top level email entry. |
|
235 CMsvServerEntry& iServerEntry; |
|
236 |
|
237 // Storing the child entries in a hierarchical entry structure. |
|
238 // List and count arrays |
|
239 CArrayFixFlat<CMsvEntrySelection*>* iSelectionList; |
|
240 CArrayFixFlat<TInt> iCurrentEntryList; |
|
241 }; |
|
242 |
|
243 |
|
244 // This class is derived from CImSendEmail and encapsulates the non-MIME protocol. |
|
245 // The class only knows about the entry which is currently in its context, which is |
|
246 // determined by it base class. |
|
247 |
|
248 //---------------------------------------------------------------------------------------- |
|
249 class CImSendPlainEmail : public CImSendEmail |
|
250 //---------------------------------------------------------------------------------------- |
|
251 /** |
|
252 @internalComponent |
|
253 @released |
|
254 */ |
|
255 { |
|
256 private: |
|
257 enum TSendState { |
|
258 ERfc822Header = 0, |
|
259 EBody, |
|
260 EAttachmentFile, |
|
261 }; |
|
262 |
|
263 public: |
|
264 static CImSendPlainEmail* NewL(CMsvServerEntry& aServerEntry ); |
|
265 static CImSendPlainEmail* NewLC(CMsvServerEntry& aServerEntry ); |
|
266 TInt NextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
267 |
|
268 private: |
|
269 CImSendPlainEmail(CMsvServerEntry& aServerEntry); |
|
270 TBool ChangeStateL(); |
|
271 }; |
|
272 |
|
273 |
|
274 |
|
275 // It encapsulates the MIME protocol and controls what needs to be sent for a specific |
|
276 // entry type, this being the type of entry that is currently in context. |
|
277 // Only knows about the entry which is currently in its context, which is determined by |
|
278 // it base class. Creates and looks after the boundary strings. |
|
279 |
|
280 //---------------------------------------------------------------------------------------- |
|
281 class CImSendMimeEmail : public CImSendEmail |
|
282 //---------------------------------------------------------------------------------------- |
|
283 /** |
|
284 @internalComponent |
|
285 @released |
|
286 */ |
|
287 { |
|
288 public: |
|
289 // From RFC 1521, (Boundaries) must be no longer than 70 characters. |
|
290 enum{KBoundaryStringLength = 55}; |
|
291 |
|
292 private: |
|
293 enum TSendState { |
|
294 ERfc822Header = 0, |
|
295 EMimeMainHeader, |
|
296 EMimeText, |
|
297 EBoundary, |
|
298 EMimePartHeader, |
|
299 EBody, |
|
300 EAttachmentFile, |
|
301 EEndBoundary, |
|
302 ELineAfterEndBoundary, |
|
303 }; |
|
304 |
|
305 public: |
|
306 static CImSendMimeEmail* NewL(CMsvServerEntry& aServerEntry ); |
|
307 static CImSendMimeEmail* NewLC(CMsvServerEntry& aServerEntry ); |
|
308 ~CImSendMimeEmail( ); |
|
309 |
|
310 TInt NextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
311 |
|
312 void Reset(); |
|
313 TInt HeaderSize(); |
|
314 TBool InitBodyObjectL(TMsvEntry& rEntry); |
|
315 |
|
316 private: |
|
317 CImSendMimeEmail(CMsvServerEntry& aServerEntry ); |
|
318 void ConstructL(); |
|
319 TBool ChangeStateL(); |
|
320 |
|
321 void CreateBoundaryL(); |
|
322 void DeleteBoundary(); |
|
323 |
|
324 inline void Boundary(TDes8& rOutputLine); |
|
325 inline TPtrC8 Boundary(); |
|
326 inline TPtrC8 SetBoundaryL(TBool aMultipart); |
|
327 inline TInt SendBoundaryLine( TDes8& rOutputLine, TInt& rPaddingCount); |
|
328 inline TBool ValidBoundaryChar( TUint aCharacter ); |
|
329 |
|
330 void InitEmbeddedEmailL(); |
|
331 |
|
332 TBool CreateMimeHeaderL(); |
|
333 void InitMimeHeaderL( TMsvEntry& aEntry, TPtrC8& rBoundary, TPtrC& rFilename); |
|
334 void InitSendMimeHeaderL(TMsvEntry& aEntry, TMimeHeaderType aMimeHeaderType ); |
|
335 |
|
336 inline TBool Next(TMsvEntry& rEntry); |
|
337 inline TBool Down(TMsvEntry& rEntry); |
|
338 inline void GetNextEntryL(TMsvEntry& rEntry); |
|
339 inline TBool CheckForEmbeddedEmailL(const TMsvEntry& aEntry) const; |
|
340 inline TBool CheckForMultipartEmailL( TMsvEntry& rEntry, TImEmailFolderType& aFolder); |
|
341 |
|
342 private: |
|
343 CDesC8ArrayFlat* iBoundaryArray; |
|
344 CImSendMimeHeader* iSendMimeHeader; |
|
345 CImMimeHeader* iMimeHeader; |
|
346 |
|
347 TBool iTextDisplayed; |
|
348 TInt64 iRandSeed; |
|
349 }; |
|
350 |
|
351 |
|
352 |
|
353 // This class creates the main message header lines which conform to the rfc822 specification. |
|
354 // The code is currently implemented in Imcvsend.cpp. |
|
355 |
|
356 //---------------------------------------------------------------------------------------- |
|
357 class CImSendRfc822Header : public CBase |
|
358 //---------------------------------------------------------------------------------------- |
|
359 /** |
|
360 @internalComponent |
|
361 @released |
|
362 */ |
|
363 { |
|
364 private: |
|
365 // Defines the state order of the CImSendRfc822Header object... |
|
366 // !! DO NOT CHANGE THE ORDER !! |
|
367 |
|
368 enum TSendState { |
|
369 EFrom=0, // 0 |
|
370 EReplyTo, |
|
371 ETo, |
|
372 ECc, |
|
373 EBcc, |
|
374 ESubject, |
|
375 EDate, |
|
376 EReturnReceiptTo, |
|
377 EPriority, |
|
378 EImportance, |
|
379 EMessageID, |
|
380 EXMailer, |
|
381 EEndOfRfc822Header |
|
382 }; |
|
383 |
|
384 public: |
|
385 static CImSendRfc822Header* NewLC( RFs& anFs, CImConvertHeader& aConverter ); |
|
386 static CImSendRfc822Header* NewL( RFs& anFs, CImConvertHeader& aConverter ); |
|
387 ~CImSendRfc822Header(); |
|
388 |
|
389 TInt NextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
390 TBool InitialiseL( const TTime aTimeDate , const TDesC& aDomainName, |
|
391 CMsvServerEntry& aServerEntry, const TMsvPriority aPriority, |
|
392 const TImSMTPSendCopyToSelf aCopyToSelf, |
|
393 TImEmailTransformingInfo& rInfo); |
|
394 |
|
395 TInt DoRecipientsL( TDes8& rOutputLine, const TPtrC8& aPrompt, CDesCArray& aList ); |
|
396 void PrepareBufferL( const TPtrC8& aPrompt, const TDesC& aData); |
|
397 void PrepareBufferL( const TPtrC8& aPrompt, const TDesC8& aData); |
|
398 TInt SendOutput( TDes8& rOutputLine ); |
|
399 TInt PriorityL(TDes8& rOutputLine); |
|
400 TInt ImportanceL(TDes8& rOutputLine); |
|
401 |
|
402 TUint HeaderCharset() const; |
|
403 void SetMessageIdL(); |
|
404 void Reset(); |
|
405 TInt Size() const; |
|
406 inline const TImEmailTransformingInfo& TransformingInfo() const; |
|
407 |
|
408 private: |
|
409 CImSendRfc822Header( RFs& anFs, CImConvertHeader& aConverter ); |
|
410 void ConstructL(); |
|
411 |
|
412 inline TInt FromL( TDes8& rOutputLine ); |
|
413 inline TInt ReplyToL( TDes8& rOutputLine ); |
|
414 inline TInt ToL( TDes8& rOutputLine ); |
|
415 inline TInt CcL( TDes8& rOutputLine ); |
|
416 inline TInt BccL( TDes8& rOutputLine ); |
|
417 inline TInt SubjectL( TDes8& rOutputLine ); |
|
418 inline TInt MessageIdL( TDes8& rOutputLine ); |
|
419 inline TInt XMailerL( TDes8& rOutputLine ); |
|
420 inline TInt ReturnReceiptsL(TDes8& rOutputLine); |
|
421 inline TBool FieldIsEmailAddress() const; |
|
422 |
|
423 TBool ValidEmailAddress(const TPtrC8& aData, const TInt aPos, TInt& rStart, TInt& rEnd); |
|
424 void EncodeHeaderFieldL(const TDesC& aBufIn, RBuf8& rBufOut, const TInt aArrayVal); |
|
425 |
|
426 void AddCopyToSelfL(TImSMTPSendCopyToSelf aCopyToSelf, CDesCArray& aList); |
|
427 |
|
428 void HandleSpecialCharacters(TPtr8& aAddressPtr); |
|
429 TBool IsSpecialCharacter(const TUint aChar); |
|
430 void PackRemainingData(TDes8& rOutputLine, TPtrC8& aBuf); |
|
431 |
|
432 private: |
|
433 RFs& iFs; |
|
434 CImHeader* iHeader; |
|
435 TInt iState; |
|
436 |
|
437 HBufC8* iOutputBuffer; |
|
438 const TUint8* ipOutputBuffer; |
|
439 |
|
440 TImRfc822DateField iRfc822Date; |
|
441 TTime iTimeDate; |
|
442 TMsvPriority iPriority; |
|
443 |
|
444 // resource strings |
|
445 HBufC* iProductName; |
|
446 HBufC* iDomainName; |
|
447 |
|
448 CImConvertHeader& iHeaderConverter; |
|
449 CImcvUtils* iImcvUtils; |
|
450 CDesC8Array* iPriorityFields; |
|
451 CDesC8Array* iImportanceFields; |
|
452 CDesC8Array* iReceiptFields; |
|
453 |
|
454 TUint iHeaderCharset; |
|
455 TImEncodingType iHeaderEncoding; |
|
456 |
|
457 TImSMTPSendCopyToSelf iCopyToSelf; |
|
458 TImEmailTransformingInfo iTransformingInfo; |
|
459 TBool iAddSpaceToNewLine; |
|
460 }; |
|
461 |
|
462 |
|
463 // This class encapsulates the MIME header protocol. |
|
464 // The header strings are created from a text resource of standard MIME tokens |
|
465 // Info obtained from cImMimeHeader object. |
|
466 |
|
467 //---------------------------------------------------------------------------------------- |
|
468 class CImSendMimeHeader : public CBase |
|
469 //---------------------------------------------------------------------------------------- |
|
470 /** |
|
471 @internalComponent |
|
472 @released |
|
473 */ |
|
474 { |
|
475 public: |
|
476 enum TMimeHeaderState |
|
477 { |
|
478 EMimeVersion = 0, // Main only |
|
479 EContentLanguage, // Main only |
|
480 EDescription, // Part only |
|
481 EContentType, |
|
482 EBoundaryString, |
|
483 EDisposition, |
|
484 ETransferEncoding, |
|
485 ECRLF, |
|
486 EEndOfMimeHeader |
|
487 }; |
|
488 |
|
489 enum TImSplitLine |
|
490 { |
|
491 EFirstLine = 0, |
|
492 ESecondLine |
|
493 }; |
|
494 public: |
|
495 static CImSendMimeHeader* NewL(CImConvertHeader& aConverter, TMimeHeaderType aType); |
|
496 static CImSendMimeHeader* NewLC(CImConvertHeader& aConverter, TMimeHeaderType aType); |
|
497 ~CImSendMimeHeader(); |
|
498 |
|
499 TInt NextLine( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
500 |
|
501 void InitialiseL( CImMimeHeader& aMimeHeader, const TPtrC aFilename, |
|
502 const TPtrC8& aBoundary, const TBool aEmbedded, |
|
503 const TMsvEntry& aEntry, const TImEmailTransformingInfo& aInfo, |
|
504 TBool aEmbeddedEmail = EFalse); |
|
505 inline TInt BlankLine( TDes8& rOutputLine ) const; |
|
506 inline TInt MimeVersion( TDes8& rOutputLine ) const; |
|
507 inline TBool ContentType( TDes8& rOutputLine) const; |
|
508 inline TBool TransferEncoding(TDes8& rOutputLine) const; |
|
509 inline TInt ContentLanguage( TDes8& rOutputLine ) const; |
|
510 inline TBool Description( TDes8& rOutputLine) const; |
|
511 inline TBool Disposition( TDes8& rOutputLine, TInt& rAdvance); |
|
512 inline const TPtrC8 EncodingType() const; |
|
513 |
|
514 TUint CharsetUid() const; |
|
515 void SetCharsetUidL(const TUint aId); |
|
516 TPtrC8 GetCharsetString() const; |
|
517 |
|
518 inline TInt Boundary(TDes8& rOutputLine) const; |
|
519 void AppendFilenameL( TDes8& rOutputLine ) const; |
|
520 TInt Size() const; |
|
521 |
|
522 private: |
|
523 CImSendMimeHeader( CImConvertHeader& aConverter, TMimeHeaderType aType); |
|
524 |
|
525 private: |
|
526 CImConvertHeader& iConverter; |
|
527 TInt iHeaderState; |
|
528 |
|
529 CImMimeHeader* iMimeHeader; |
|
530 // Info needed when filling in header details |
|
531 TImEncodingType iAlgorithm; |
|
532 HBufC8* iCharsetString; |
|
533 TPtrC8 iBoundaryString; |
|
534 TFileName iFilename; |
|
535 TMsvEntry iEntry; |
|
536 |
|
537 TInt iLine; |
|
538 TBool iIsMultipart; |
|
539 TMimeHeaderType iMimeHeaderType; |
|
540 |
|
541 TUint iHeaderCharset; |
|
542 TImEncodingType iHeaderEncodingType; |
|
543 |
|
544 TUint iCharsetUid; |
|
545 TImEncodingType iEncodingType; |
|
546 |
|
547 TBool iDealingWithAnEmbeddedEmail; |
|
548 }; |
|
549 |
|
550 |
|
551 // This class sends the text from a richtext object. |
|
552 // The text can be encoded using any of the available encoding techniques |
|
553 |
|
554 //---------------------------------------------------------------------------------------- |
|
555 class CImSendRichText : public CBase |
|
556 //---------------------------------------------------------------------------------------- |
|
557 /** |
|
558 @internalComponent |
|
559 @released |
|
560 */ |
|
561 { |
|
562 public: |
|
563 static CImSendRichText* NewL( CImConvertCharconv& aConv ); |
|
564 static CImSendRichText* NewLC( CImConvertCharconv& aConv ); |
|
565 |
|
566 TBool InitialiseL( CMsvServerEntry& aServerEntry, TImCodec& anEncoder, |
|
567 TImEncodingType aType, TUint aCharset); |
|
568 TInt NextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
569 void ExtractLineFromChunkL(TDes16& aOutputLine); |
|
570 ~CImSendRichText(); |
|
571 inline TInt Size() const; |
|
572 |
|
573 private: |
|
574 CImSendRichText(CImConvertCharconv& aConv); |
|
575 void ConstructL(); |
|
576 |
|
577 TInt NoEncodeNextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
578 TInt RemoveControlCharacters( const TDesC& aInputLine, TDes& rOutputLine, TInt& rPaddingCount ); |
|
579 |
|
580 TInt EncodeNextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
581 TInt EncodeQPNextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
582 |
|
583 TInt ConvertNextLineL( const TDesC& aInput, TDes8& rOutput); |
|
584 TBool SmartBreak( TInt written, const TDesC& pSource ); |
|
585 TBool SmartBreak( TInt written, const TUint8* pSource, TInt aMaxLength ); |
|
586 |
|
587 inline TBool IsBreakable( TChar aChar ) const; |
|
588 inline TBool IsEOL(TChar aChar) const; |
|
589 inline TUint8 ReplacementChar(TChar aControlChar) const; |
|
590 inline TBool IsPlain(TChar aChar) const; |
|
591 inline int ConvertLineBreaks( TDes& aSource, TBool aLineBreak) const; |
|
592 |
|
593 private: |
|
594 // The message store class for reteiving chunks of body text from mail store. |
|
595 CMsvPlainBodyText* iPlainBodyText; |
|
596 CImConvertCharconv& iConverter; |
|
597 TBool iPreparedToConvert; |
|
598 TImCodec* iEncoder; |
|
599 |
|
600 TInt iMaxLength; |
|
601 TBool iUseRichText; |
|
602 TInt iBodySize; |
|
603 TInt iPos; |
|
604 TImEncodingType iBodyEncoding; |
|
605 HBufC8* iLeftOver; |
|
606 // Buffer used for extracting line of body text from restored chunk. |
|
607 RBuf iCurrentChunk; |
|
608 // Indicates whether a chunk needs to be restored from Message Store. |
|
609 TBool iIsNewChunk; |
|
610 }; |
|
611 |
|
612 |
|
613 // This class creates lines to send from files, |
|
614 // the files can be encoded using any of the available encoding techniques. |
|
615 |
|
616 //---------------------------------------------------------------------------------------- |
|
617 class CImSendFile : public CBase |
|
618 //---------------------------------------------------------------------------------------- |
|
619 /** |
|
620 @internalComponent |
|
621 @released |
|
622 */ |
|
623 { |
|
624 private: |
|
625 enum TImSplitLine |
|
626 { |
|
627 EFirstLine = 0, |
|
628 ESecondLine |
|
629 }; |
|
630 |
|
631 // Length of source text buffer used when encoding and outputting. |
|
632 // Taking into account that the length may increase. |
|
633 |
|
634 enum TImAttachmentSend |
|
635 { |
|
636 ENextFile = 0, |
|
637 EPrefixLines, |
|
638 EEncodeFile, |
|
639 EPostfixLines, |
|
640 EEndOfAttachments, |
|
641 ECloseDelimiter, |
|
642 ECRLFLine, |
|
643 EEnd |
|
644 }; |
|
645 public: |
|
646 static CImSendFile* NewLC(RFs& anFs, CImConvertCharconv& aCharConv); |
|
647 static CImSendFile* NewL(RFs& anFs, CImConvertCharconv& aCharConv); |
|
648 ~CImSendFile(); |
|
649 |
|
650 void InitialiseL( CMsvServerEntry& aServerEntry, TImFileCodec& anEncoder); |
|
651 |
|
652 TInt NextLineL( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
653 |
|
654 inline TInt BlankLine( TDes8& rOutputLine, TInt& rPaddingCount ); |
|
655 const TFileName& Filename() const; |
|
656 |
|
657 TFileName& Filename( CMsvServerEntry& aEntry, SAttachmentInfo& aInfo); |
|
658 |
|
659 static void EmbeddedEmailFilename(TMsvEntry& aEntry, TFileName& aFileName); |
|
660 inline TInt Size() const; |
|
661 |
|
662 private: |
|
663 CImSendFile(RFs& anFs, CImConvertCharconv& aCharConv); |
|
664 void ConstructL(); |
|
665 |
|
666 private: |
|
667 const RFs& iFs; |
|
668 |
|
669 TImFileCodec* iEncoder; // Either B64 or UU encoder or none |
|
670 CImConvertCharconv& iConverter; |
|
671 |
|
672 SAttachmentInfo iAttachmentInfo; |
|
673 TImAttachmentFile* iAttachmentFile; |
|
674 TBuf8<KDecodeLineLength> iSourceLine; |
|
675 CImMimeHeader* iMimeHeader; // Passed in. |
|
676 |
|
677 TInt iAttachmentState; // so dont change there order |
|
678 TInt iFileIndex; // The following are init'ed in the Ctor list |
|
679 TInt iBodyHeaderState; |
|
680 |
|
681 TInt iPrefixState; |
|
682 TInt iPostfixState; |
|
683 }; |
|
684 |
|
685 |
|
686 //---------------------------------------------------------------------------------------- |
|
687 class CImCalculateMsgSize : public CMsgActive |
|
688 //---------------------------------------------------------------------------------------- |
|
689 /** |
|
690 @internalTechnology |
|
691 @released |
|
692 */ |
|
693 { |
|
694 public: |
|
695 IMPORT_C static CImCalculateMsgSize* NewL(RFs &anFs,CMsvServerEntry& aServerEntry); |
|
696 IMPORT_C ~CImCalculateMsgSize(); |
|
697 IMPORT_C void StartL(TRequestStatus& aStatus,TMsvId aMsvId, |
|
698 TImSendMethod aAlgorithm, TTime& aTimeDate, |
|
699 const TDesC& aDomainName, const TUint aCharset); |
|
700 |
|
701 inline TInt MessageSize() const; // total size of Email - once active object has completed |
|
702 inline void Progress(TInt& aBytes, TInt& aTotal); // current info on size of Email |
|
703 |
|
704 private: |
|
705 void DoRunL(); |
|
706 void DoCancel(); |
|
707 private: |
|
708 CImCalculateMsgSize(RFs &anFs,CMsvServerEntry& aServerEntry); |
|
709 void ConstructL(); |
|
710 void Reset(); |
|
711 private: |
|
712 RFs& iFs; |
|
713 CMsvServerEntry& iServerEntry; |
|
714 TMsvId iMsvId; |
|
715 |
|
716 TInt iSize; |
|
717 TInt iTotal; |
|
718 |
|
719 CImSendMessage* iSendMsg; |
|
720 TBuf8<KImMailMaxBufferSize> iMailString; |
|
721 TBool iFinished; |
|
722 #if defined (_DEBUG) |
|
723 RFile iFile; |
|
724 TBool iFileOpen; |
|
725 #endif |
|
726 }; |
|
727 |
|
728 |
|
729 #include <imcvsend.inl> |
|
730 |
|
731 #endif |