epoc32/include/imcvsend.inl
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 //----------------------------------------------------------------------------------------
       
    17 inline LOCAL_C void AppendCRLF( TDes8& rOutputLine, TInt& rPaddingCount )
       
    18 //----------------------------------------------------------------------------------------
       
    19 	{
       
    20 	rOutputLine.Append( TPtrC8(KImcvCRLF) );
       
    21 	rPaddingCount += KImcvCRLF().Length();
       
    22 	}
       
    23 
       
    24 
       
    25 //----------------------------------------------------------------------------------------
       
    26 inline LOCAL_C TInt AddCRLF(TDes8& rOutputLine)
       
    27 //----------------------------------------------------------------------------------------
       
    28 	{
       
    29 	rOutputLine = KImcvCRLF;
       
    30 	return 1;
       
    31 	}
       
    32 
       
    33 //----------------------------------------------------------------------------------------
       
    34 inline LOCAL_C void AddCRLF( TDes8& rOutputLine, TInt& rPaddingCount )
       
    35 //----------------------------------------------------------------------------------------
       
    36 	{
       
    37 	rOutputLine=TPtrC8(KImcvCRLF);
       
    38 	rPaddingCount = KImcvCRLF().Length();
       
    39 	}
       
    40 
       
    41 //----------------------------------------------------------------------------------------
       
    42 inline LOCAL_C void AddCRLFAtEndOfLine( TDes8& rOutputLine, TInt& rPaddingCount)
       
    43 //----------------------------------------------------------------------------------------
       
    44 	{
       
    45 	TInt length = rOutputLine.Length();
       
    46 	if ( length < 2 || (rOutputLine[length-2] != KImcvCR || rOutputLine[length-1] != KImcvLF) )
       
    47 		{
       
    48 		rOutputLine.Append( KImcvCRLF );
       
    49 		rPaddingCount += 2;
       
    50 		}
       
    51 	}
       
    52 
       
    53 //----------------------------------------------------------------------------------------
       
    54 inline TBool IsLineCRLF( TDesC8& aOutputLine )
       
    55 //----------------------------------------------------------------------------------------
       
    56 	{
       
    57 	TInt length = aOutputLine.Length();
       
    58 	if ( length < 2 || (aOutputLine[length-2] != KImcvCR || aOutputLine[length-1] != KImcvLF) )
       
    59 		return EFalse;
       
    60 	return ETrue;
       
    61 	}
       
    62 
       
    63 
       
    64 //****************************************************************************************
       
    65 //              Class CImEmailTraverser Functions
       
    66 //****************************************************************************************
       
    67 
       
    68 
       
    69 //----------------------------------------------------------------------------------------
       
    70 inline TInt CImEmailTraverser::CurrentEntry()
       
    71 //----------------------------------------------------------------------------------------
       
    72 	{
       
    73 	return iCurrentEntryList[0];
       
    74 	}
       
    75 
       
    76 //----------------------------------------------------------------------------------------
       
    77 inline CMsvEntrySelection& CImEmailTraverser::CurrentList() const
       
    78 //----------------------------------------------------------------------------------------
       
    79 	{
       
    80 	return *(*iSelectionList)[0];
       
    81 	}
       
    82 
       
    83 //----------------------------------------------------------------------------------------
       
    84 inline TBool CImEmailTraverser::DeleteCurrentList()
       
    85 //----------------------------------------------------------------------------------------
       
    86 	{
       
    87 	if (!LevelExists())
       
    88 		return EFalse;
       
    89 
       
    90 	delete &CurrentList();
       
    91 	iSelectionList->Delete(0);
       
    92 	iCurrentEntryList.Delete(0);
       
    93 	return ETrue;
       
    94 	}
       
    95 
       
    96 //----------------------------------------------------------------------------------------
       
    97 inline void CImEmailTraverser::AddList(CMsvEntrySelection& children)
       
    98 //----------------------------------------------------------------------------------------
       
    99 	{
       
   100 	iSelectionList->InsertL(0, &children);
       
   101 	iCurrentEntryList.InsertL(0, 0);
       
   102 	}
       
   103 
       
   104 //----------------------------------------------------------------------------------------
       
   105 inline TBool CImEmailTraverser::LevelExists() const
       
   106 //----------------------------------------------------------------------------------------
       
   107 	{
       
   108 	return iSelectionList->Count();
       
   109 	}
       
   110 
       
   111 //----------------------------------------------------------------------------------------
       
   112 inline TBool CImEmailTraverser::IsBaseLevel() const
       
   113 //----------------------------------------------------------------------------------------
       
   114 	{
       
   115 	return ThisEntry().Id()==iBaseId ? ETrue: EFalse;;
       
   116 	}
       
   117 
       
   118 //----------------------------------------------------------------------------------------
       
   119 inline void CImEmailTraverser::SetBaseEntry()
       
   120 //----------------------------------------------------------------------------------------
       
   121 	{
       
   122 	iServerEntry.SetEntry(iBaseId);
       
   123 	}
       
   124 
       
   125 //----------------------------------------------------------------------------------------
       
   126 inline const TMsvEntry& CImEmailTraverser::ThisEntry() const
       
   127 //----------------------------------------------------------------------------------------
       
   128 	{	
       
   129 	return iServerEntry.Entry();
       
   130 	}
       
   131 
       
   132 
       
   133 //****************************************************************************************
       
   134 //              Class CImSendMimeEmail Functions
       
   135 //****************************************************************************************
       
   136 
       
   137 //----------------------------------------------------------------------------------------
       
   138 inline void CImSendMimeEmail::Boundary(TDes8& rOutputLine) 
       
   139 //----------------------------------------------------------------------------------------
       
   140 	{
       
   141 	rOutputLine.Append( (*iBoundaryArray)[0] );
       
   142 	}
       
   143 
       
   144 //----------------------------------------------------------------------------------------
       
   145 inline TPtrC8 CImSendMimeEmail::Boundary()
       
   146 //----------------------------------------------------------------------------------------
       
   147 	{
       
   148 	return (*iBoundaryArray)[0];
       
   149 	}
       
   150 
       
   151 //----------------------------------------------------------------------------------------
       
   152 inline TInt CImSendMimeEmail::SendBoundaryLine(TDes8& rOutputLine, TInt& rPaddingCount)
       
   153 //----------------------------------------------------------------------------------------
       
   154 	{
       
   155 	rOutputLine.Append(KImcvMimeBoundaryStartEnd);
       
   156 	Boundary( rOutputLine );
       
   157 	rPaddingCount += (*iBoundaryArray)[0].Length() + 2;
       
   158 	return 1;
       
   159 	}
       
   160 
       
   161 
       
   162 // Sets iState to EEndBoundary or EEndOfEmail
       
   163 // returns true if entry found
       
   164 //----------------------------------------------------------------------------------------
       
   165 inline TBool CImSendMimeEmail::Down(TMsvEntry& rEntry)
       
   166 //----------------------------------------------------------------------------------------
       
   167 	{
       
   168 	TInt ret = iEmailTraverser->DownLevelL() ? ETrue:EFalse;
       
   169 
       
   170 	if (ret)
       
   171 		rEntry = iEmailTraverser->ThisEntry();
       
   172 	return ret;
       
   173 	}
       
   174 
       
   175 //----------------------------------------------------------------------------------------
       
   176 inline void CImSendMimeEmail::GetNextEntryL(TMsvEntry& rEntry)
       
   177 //----------------------------------------------------------------------------------------
       
   178 	{
       
   179 	if ( (iState!=EEndBoundary && iState!=ELineAfterEndBoundary) && Down(rEntry) )
       
   180 		iState=EBoundary;
       
   181 	else if ( iEmailTraverser->NextEntryL(rEntry) )
       
   182 		iState=EBoundary;
       
   183 	else if (iEmailTraverser->UpLevelL() )
       
   184 		{
       
   185 		if (iServerEntry.Entry().iType==KUidMsvMessageEntry && !(iEmailTraverser->IsBaseLevel()))
       
   186 			{
       
   187 			// Embedded non-mime message
       
   188 			iState=EEndBoundary;
       
   189 			GetNextEntryL(rEntry);
       
   190 			}
       
   191 		else
       
   192 			iState=EEndBoundary;
       
   193 		}
       
   194 	else
       
   195 		iState=KImCvFinished;
       
   196 	}
       
   197 
       
   198 
       
   199 //----------------------------------------------------------------------------------------
       
   200 inline TPtrC8 CImSendMimeEmail::SetBoundaryL(TBool aMultipart)
       
   201 //----------------------------------------------------------------------------------------
       
   202 	{
       
   203 	if (!aMultipart)
       
   204 		return TPtrC8();
       
   205 
       
   206 	CreateBoundaryL();
       
   207 	return (*iBoundaryArray)[0];
       
   208 	}
       
   209 
       
   210 //----------------------------------------------------------------------------------------
       
   211 inline TBool CImSendMimeEmail::CheckForEmbeddedEmailL(const TMsvEntry& aEntry) const
       
   212 //----------------------------------------------------------------------------------------
       
   213 	{
       
   214 	return (aEntry.iType==KUidMsvMessageEntry);
       
   215 	}
       
   216 
       
   217 //----------------------------------------------------------------------------------------
       
   218 inline TBool CImSendMimeEmail::CheckForMultipartEmailL(TMsvEntry& rEntry, TImEmailFolderType& aFolder)
       
   219 //----------------------------------------------------------------------------------------
       
   220 	{
       
   221 	TMsvEmailEntry emailEntry = (TMsvEmailEntry)rEntry;
       
   222 
       
   223 	aFolder = emailEntry.MessageFolderType();
       
   224 	if (aFolder==EFolderTypeMixed || aFolder==EFolderTypeDigest || 
       
   225 		aFolder==EFolderTypeAlternative || aFolder==EFolderTypeRelated ) 
       
   226 		return ETrue;
       
   227 		
       
   228 	if ( ! Down(emailEntry) )
       
   229 		return EFalse;
       
   230 
       
   231 	if ( iEmailTraverser->CurrentList().Count()==1 && 
       
   232 				iEmailTraverser->ThisEntry().iType==KUidMsvFolderEntry )
       
   233 		{
       
   234 		aFolder = ((TMsvEmailEntry&)iEmailTraverser->ThisEntry()).MessageFolderType();
       
   235 		iEmailTraverser->UpLevelL();
       
   236 		return ETrue;
       
   237 		}
       
   238 	
       
   239 	iEmailTraverser->UpLevelL();
       
   240 	return EFalse;
       
   241 	}
       
   242 
       
   243 //****************************************************************************************
       
   244 //              Class CImSendRfc822Header Functions
       
   245 //****************************************************************************************
       
   246 
       
   247 //----------------------------------------------------------------------------------------
       
   248 inline TInt CImSendRfc822Header::XMailerL(TDes8& rOutputLine)
       
   249 //----------------------------------------------------------------------------------------
       
   250 	{
       
   251 	rOutputLine = KImcvXMailer;
       
   252 	rOutputLine.Append(*iProductName);
       
   253 	return 1;
       
   254 	}
       
   255 
       
   256 //----------------------------------------------------------------------------------------
       
   257 inline TInt CImSendRfc822Header::MessageIdL( TDes8& rOutputLine )
       
   258 //----------------------------------------------------------------------------------------
       
   259 	{
       
   260 	if ( !iHeader->ImMsgId().Length() )
       
   261 		return 1;
       
   262 
       
   263 	PrepareBufferL( TPtrC8(KImcvMessageIdPrompt), iHeader->ImMsgId());
       
   264 	return SendOutput( rOutputLine );
       
   265 	}
       
   266 
       
   267 //----------------------------------------------------------------------------------------
       
   268 inline TInt CImSendRfc822Header::ToL(TDes8& rOutputLine)
       
   269 //----------------------------------------------------------------------------------------
       
   270 	{
       
   271 	return DoRecipientsL(rOutputLine, TPtrC8(KImcvToPrompt), iHeader->ToRecipients());
       
   272 	}
       
   273 
       
   274 //----------------------------------------------------------------------------------------
       
   275 inline TInt CImSendRfc822Header::CcL(TDes8& rOutputLine)
       
   276 //----------------------------------------------------------------------------------------
       
   277 	{
       
   278 	return DoRecipientsL(rOutputLine, TPtrC8(KImcvCcPrompt), iHeader->CcRecipients());
       
   279 	}
       
   280 
       
   281 //----------------------------------------------------------------------------------------
       
   282 inline TInt CImSendRfc822Header::BccL(TDes8& rOutputLine)
       
   283 //----------------------------------------------------------------------------------------
       
   284 	{
       
   285 	return DoRecipientsL(rOutputLine, TPtrC8(KImcvBccPrompt), iHeader->BccRecipients());
       
   286 	}
       
   287 
       
   288 //----------------------------------------------------------------------------------------
       
   289 inline TInt CImSendRfc822Header::FromL( TDes8& rOutputLine )
       
   290 //----------------------------------------------------------------------------------------
       
   291 	{
       
   292 	PrepareBufferL( TPtrC8(KImcvFromPrompt), iHeader->From());
       
   293 	return SendOutput( rOutputLine );
       
   294 	}
       
   295 
       
   296 //----------------------------------------------------------------------------------------
       
   297 inline TInt CImSendRfc822Header::ReplyToL( TDes8& rOutputLine )
       
   298 //----------------------------------------------------------------------------------------
       
   299 	{
       
   300 	if ( !iHeader->ReplyTo().Length() )
       
   301 		return 1;
       
   302 
       
   303 	PrepareBufferL( TPtrC8(KImcvReplyToPrompt), iHeader->ReplyTo() );
       
   304 	return SendOutput( rOutputLine );
       
   305 	}
       
   306 
       
   307 //----------------------------------------------------------------------------------------
       
   308 inline TInt CImSendRfc822Header::SubjectL( TDes8& rOutputLine )
       
   309 //----------------------------------------------------------------------------------------
       
   310 	{
       
   311 	// If the subject field has already been encoded and stored in iOutputBuffer
       
   312 	// then there is no need to encode again.
       
   313 	if (!iOutputBuffer)
       
   314 		{
       
   315 		PrepareBufferL( TPtrC8(KImcvSubjectPrompt), iHeader->Subject() );
       
   316 		}
       
   317 	return SendOutput( rOutputLine );	
       
   318 	}
       
   319 
       
   320 
       
   321 //----------------------------------------------------------------------------------------
       
   322 inline TInt CImSendRfc822Header::ReturnReceiptsL(TDes8& rOutputLine)
       
   323 //----------------------------------------------------------------------------------------
       
   324 	{
       
   325 	// SendReturnReceiptFieldsL() will always return one choice. 
       
   326 	// In future it can be changed to add more fields 
       
   327 
       
   328 	TPtrC address;
       
   329 	if ( iHeader->ReceiptAddress().Length() )
       
   330 		address.Set(iHeader->ReceiptAddress());
       
   331 	else if ( iHeader->ReplyTo().Length() )
       
   332 		address.Set(iHeader->ReplyTo());
       
   333 	else
       
   334 		return 1; // No valid a address
       
   335 
       
   336 	CDesC8Array* receiptsFields=new (ELeave)CDesC8ArrayFlat(KArrayAllocationNumber);
       
   337 	CleanupStack::PushL(receiptsFields);
       
   338 	CImcvUtils::SendReturnReceiptFieldsL(*receiptsFields);
       
   339 	TInt count=receiptsFields->Count();
       
   340 	for (TInt i=0;i<count;i++)
       
   341 		PrepareBufferL((*receiptsFields)[i], address);
       
   342 
       
   343 	CleanupStack::PopAndDestroy(); //receiptsFields
       
   344 	return SendOutput( rOutputLine );
       
   345 	}
       
   346 
       
   347 //----------------------------------------------------------------------------------------
       
   348 inline TBool CImSendRfc822Header::FieldIsEmailAddress() const
       
   349 //----------------------------------------------------------------------------------------
       
   350 	{
       
   351 	return (iState != ESubject);
       
   352 	}
       
   353 
       
   354 //----------------------------------------------------------------------------------------
       
   355 inline const TImEmailTransformingInfo& CImSendRfc822Header::TransformingInfo() const
       
   356 //----------------------------------------------------------------------------------------
       
   357 	{
       
   358 	return iTransformingInfo;
       
   359 	}
       
   360 
       
   361 
       
   362 
       
   363 //****************************************************************************************
       
   364 //              Class CImSendMimeHeader Functions
       
   365 //****************************************************************************************
       
   366 
       
   367 
       
   368 //----------------------------------------------------------------------------------------
       
   369 inline TInt CImSendMimeHeader::BlankLine(TDes8& rOutputLine) const
       
   370 //----------------------------------------------------------------------------------------
       
   371 	{
       
   372 	rOutputLine = KNullDesC8;
       
   373 	return 1;
       
   374 	}
       
   375 
       
   376 //----------------------------------------------------------------------------------------
       
   377 inline TInt CImSendMimeHeader::MimeVersion(TDes8& rOutputLine) const
       
   378 //----------------------------------------------------------------------------------------
       
   379 	{
       
   380 	rOutputLine = KImcvMimePrompt;
       
   381 	rOutputLine.Append(KImcvSpMimeVersion);
       
   382 	return 1;
       
   383 	}
       
   384 
       
   385 //----------------------------------------------------------------------------------------
       
   386 inline TBool CImSendMimeHeader::ContentType(TDes8& rOutputLine) const
       
   387 //----------------------------------------------------------------------------------------
       
   388 	{
       
   389 	TBool isText = EFalse;
       
   390 	rOutputLine = KImcvContentType;
       
   391 	rOutputLine.Append(KImcvSpace);
       
   392 
       
   393 	if (((TMsvEmailEntry&)iEntry).VCard())
       
   394 		{
       
   395 		rOutputLine.Append(KImcvText);
       
   396 		rOutputLine.Append( KImcvForwardSlash );
       
   397 		rOutputLine.Append(KImcvDirectory);
       
   398 		rOutputLine.Append( KImcvSemiColon );
       
   399 		rOutputLine.Append( KImcvSpace );
       
   400 		rOutputLine.Append( KImcvProfile );
       
   401 		rOutputLine.Append( KImcvEquals );
       
   402 		rOutputLine.Append( KImcvVCard );
       
   403 		isText=ETrue;
       
   404 		}
       
   405 	else if (((TMsvEmailEntry&)iEntry).VCalendar())
       
   406 		{
       
   407 		rOutputLine.Append(KImcvText);
       
   408 		rOutputLine.Append( KImcvForwardSlash );
       
   409 		rOutputLine.Append(KImcvVCalender);
       
   410 		isText=ETrue;
       
   411 		}
       
   412 	else if (iEntry.iType == KUidMsvEmailHtmlEntry)
       
   413 		{
       
   414 		rOutputLine.Append(KImcvText);
       
   415 		rOutputLine.Append( KImcvForwardSlash );
       
   416 		rOutputLine.Append(KImcvHtml);
       
   417 		isText=ETrue;
       
   418 		}
       
   419 	else if ( iMimeHeader->ContentType().Length() )
       
   420 		{
       
   421 		TPtrC8 contentType = iMimeHeader->ContentType();
       
   422 		rOutputLine.Append( contentType );	
       
   423 
       
   424 		TPtrC8 contentSubType = iMimeHeader->ContentSubType();
       
   425 		if ( contentSubType.Length() )
       
   426 			{
       
   427 			rOutputLine.Append( KImcvForwardSlash );
       
   428 			rOutputLine.Append( iMimeHeader->ContentSubType() );
       
   429 			}
       
   430 
       
   431 		isText = contentType.CompareF(KImcvText) ? EFalse : ETrue;
       
   432 		
       
   433 		
       
   434 		// If the content-Type is text/calendar we need to add two
       
   435 		// parameters: "method" and "component"
       
   436 // GS : do we need extra parameters for vCal??
       
   437 		TPtrC8 parameter;
       
   438 
       
   439 		if ( contentType.Length() && contentSubType.Length() )
       
   440 		if ( isText && !(contentSubType.CompareF(KImcvICalendar)) )
       
   441 			{
       
   442 			// METHOD parameter
       
   443 			parameter.Set(iMimeHeader->GetContentTypeValue(KImcvICalendarMethod));
       
   444 			if ( parameter.Length() )
       
   445 				{
       
   446 				rOutputLine.Append( KImcvSemiColon );
       
   447 				rOutputLine.Append( KImcvSpace );
       
   448 				rOutputLine.Append( KImcvICalendarMethod );
       
   449 				rOutputLine.Append( KImcvEquals );
       
   450 				rOutputLine.Append( parameter );
       
   451 				}
       
   452 
       
   453 			// COMPONENT parameter
       
   454 			parameter.Set(iMimeHeader->GetContentTypeValue(KImcvICalendarComponent));
       
   455 			if ( parameter.Length() )
       
   456 				{
       
   457 				rOutputLine.Append( KImcvSemiColon );
       
   458 				rOutputLine.Append( KImcvSpace );
       
   459 				rOutputLine.Append( KImcvICalendarComponent );
       
   460 				rOutputLine.Append( KImcvEquals );
       
   461 				rOutputLine.Append( parameter );
       
   462 				}	
       
   463 			}
       
   464 		
       
   465 		}
       
   466 	else if (iEntry.iType == KUidMsvAttachmentEntry)
       
   467 		rOutputLine.Append( KImcvApplOctet );	
       
   468 	else if (iEntry.iType==KUidMsvEmailTextEntry || (!iIsMultipart && !iEntry.Attachment()))
       
   469 		{
       
   470 		rOutputLine.Append(KImcvText);
       
   471 		rOutputLine.Append( KImcvForwardSlash );
       
   472 		rOutputLine.Append(KImcvPlain);
       
   473 		isText=ETrue;
       
   474 		}
       
   475 	else
       
   476 		{
       
   477 		rOutputLine.SetLength(0);
       
   478 		return EFalse;
       
   479 		}
       
   480 
       
   481 	if (isText)
       
   482 		{
       
   483 		rOutputLine.Append( KImcvSemiColon );
       
   484 		rOutputLine.Append( KImcvSpace );
       
   485 		rOutputLine.Append( KImcvCharset );
       
   486 		rOutputLine.Append( KImcvEquals );
       
   487 		rOutputLine.Append( GetCharsetString() );
       
   488 		}
       
   489 	else if ( iBoundaryString.Length() )
       
   490 		rOutputLine.Append(KImcvSemiColon); // boundary to follow
       
   491 
       
   492 	return ETrue;
       
   493 	}
       
   494 
       
   495 //----------------------------------------------------------------------------------------
       
   496 inline TBool CImSendMimeHeader::TransferEncoding(TDes8& rOutputLine) const
       
   497 //----------------------------------------------------------------------------------------
       
   498 	{
       
   499 	TPtrC8 encodingType = EncodingType();
       
   500 
       
   501 	if (iEntry.iType!=KUidMsvFolderEntry && encodingType.Length())
       
   502 		{
       
   503 		rOutputLine = KImcvContentTransferEncoding;
       
   504 		rOutputLine.Append(encodingType);
       
   505 		return ETrue;
       
   506 		}
       
   507 
       
   508 	return EFalse;
       
   509 	}
       
   510 
       
   511 //----------------------------------------------------------------------------------------
       
   512 inline TInt CImSendMimeHeader::ContentLanguage(TDes8& rOutputLine) const
       
   513 //----------------------------------------------------------------------------------------
       
   514 	{
       
   515 	rOutputLine = KImcvContentLanguage;
       
   516 	rOutputLine.Append(KImcvDefaultLanguage);
       
   517 	return 1;
       
   518 	}
       
   519 
       
   520 //----------------------------------------------------------------------------------------
       
   521 inline TBool CImSendMimeHeader::Description( TDes8& rOutputLine ) const
       
   522 //----------------------------------------------------------------------------------------
       
   523 	{
       
   524 	TPtrC8 description = iMimeHeader->ContentDescription();
       
   525 
       
   526 	if ( !description.Length() )
       
   527 		return EFalse;
       
   528 
       
   529 	rOutputLine = KImcvContentDescription;
       
   530 	rOutputLine.Append(KImcvSpace);
       
   531 	rOutputLine.Append( description );
       
   532 	return ETrue;
       
   533 	}
       
   534 
       
   535 
       
   536 //----------------------------------------------------------------------------------------
       
   537 inline TInt CImSendMimeHeader::Boundary(TDes8& rOutputLine) const
       
   538 //----------------------------------------------------------------------------------------
       
   539 	{
       
   540 	rOutputLine.Append(KImcvSpace);
       
   541 	rOutputLine.Append(KImcvSpace);
       
   542 	rOutputLine.Append(KImcvBoundary);
       
   543 	rOutputLine.Append(KImcvEquals);
       
   544 	rOutputLine.Append(KImcvQuote);
       
   545 	rOutputLine.Append(iBoundaryString);
       
   546 	rOutputLine.Append(KImcvQuote);
       
   547 	return 1;
       
   548 	}
       
   549 
       
   550 //----------------------------------------------------------------------------------------
       
   551 inline TBool CImSendMimeHeader::Disposition( TDes8& rOutputLine, TInt& rAdvance)
       
   552 //----------------------------------------------------------------------------------------
       
   553 	{
       
   554 	rAdvance++;
       
   555 	if (iEntry.iType == KUidMsvFolderEntry)
       
   556 		return EFalse;
       
   557 
       
   558 	if(iLine==EFirstLine)
       
   559 		{
       
   560 		TPtrC8 disposition = iMimeHeader->ContentDisposition();
       
   561 		
       
   562 		// Four cases : (2)disposition explicitly attachment,
       
   563 		// (3) Non Multipart message with attachment flag set.
       
   564 		// (4) Embedded email
       
   565 
       
   566 		if ( iEntry.iType==KUidMsvAttachmentEntry || 
       
   567 			 disposition==KImcvAttachment ||
       
   568 			 (!iIsMultipart && iEntry.iType!=KUidMsvMessageEntry && iEntry.Attachment()) )
       
   569 			{
       
   570 			rOutputLine = KImcvContentDisposition;
       
   571 			rOutputLine.Append(KImcvSpace);
       
   572 			rOutputLine.Append(KImcvAttachment);
       
   573 			rOutputLine.Append(KImcvSemiColon);
       
   574 			iLine++;
       
   575 			rAdvance--;
       
   576 			return ETrue;
       
   577 			}
       
   578 		else if (iEntry.iType==KUidMsvEmailTextEntry )
       
   579 			{
       
   580 			rOutputLine = KImcvContentDisposition;
       
   581 			rOutputLine.Append(KImcvSpace);
       
   582 			rOutputLine.Append(KImcvInline);
       
   583 			return ETrue;
       
   584 			}
       
   585 		 		else if (iEntry.iType==KUidMsvMessageEntry && iDealingWithAnEmbeddedEmail)
       
   586  			{
       
   587  			rOutputLine = KImcvContentDisposition;
       
   588  			rOutputLine.Append(KImcvSpace);
       
   589  			rOutputLine.Append(KImcvAttachment);
       
   590 			rOutputLine.Append(KImcvSemiColon);
       
   591  			iLine++;
       
   592  			rAdvance--;
       
   593  			return ETrue;
       
   594  			}
       
   595 		}
       
   596 	else if (iFilename.Length())
       
   597 		{
       
   598 		rOutputLine.Append(KImcvTab);
       
   599 		rOutputLine.Append(KImcvMimeDispositionFilename);
       
   600 		AppendFilenameL( rOutputLine );
       
   601 		iDealingWithAnEmbeddedEmail = EFalse;
       
   602 		return ETrue;
       
   603 		}
       
   604 
       
   605 	iLine=0;
       
   606 	return EFalse;
       
   607 	}
       
   608 
       
   609 //----------------------------------------------------------------------------------------
       
   610 inline const TPtrC8 CImSendMimeHeader::EncodingType() const
       
   611 //----------------------------------------------------------------------------------------
       
   612 	{
       
   613 	switch (iEncodingType)
       
   614 		{
       
   615 		case EEncodingTypeBASE64:
       
   616 			return TPtrC8(KImcvBase64);
       
   617 		case EEncodingTypeQP:
       
   618 			return TPtrC8(KImcvQuotedPrintable);
       
   619 		case EEncodingTypeUU:
       
   620 			return TPtrC8(KImcvXUUString);
       
   621 		default:
       
   622 			return TPtrC8(KImcv7Bit);
       
   623 		}
       
   624 	}
       
   625 
       
   626 //----------------------------------------------------------------------------------------
       
   627 inline TUint CImSendMimeHeader::CharsetUid() const
       
   628 //----------------------------------------------------------------------------------------
       
   629 	{
       
   630 	return iCharsetUid;
       
   631 	}
       
   632 
       
   633 
       
   634 //****************************************************************************************
       
   635 //              Class CImSendRichText Functions
       
   636 //****************************************************************************************
       
   637 
       
   638 //----------------------------------------------------------------------------------------
       
   639 inline TBool CImSendRichText::IsBreakable( TChar ch ) const
       
   640 //----------------------------------------------------------------------------------------
       
   641 	{
       
   642 	return (ch==' '|| ch=='\t' || ch==CEditableText::EParagraphDelimiter 
       
   643 				   || ch==CEditableText::ENonBreakingSpace );
       
   644 	}
       
   645 
       
   646 //----------------------------------------------------------------------------------------
       
   647 inline TInt CImSendRichText::Size() const
       
   648 //----------------------------------------------------------------------------------------
       
   649 	{
       
   650 	return iBodySize;
       
   651 	}
       
   652 
       
   653 //----------------------------------------------------------------------------------------
       
   654 inline TBool CImSendRichText::IsEOL( TChar ch ) const
       
   655 //----------------------------------------------------------------------------------------
       
   656 	{
       
   657 	return (ch==CEditableText::EParagraphDelimiter
       
   658 		 || ch==CEditableText::ELineBreak
       
   659 		 || ch==CEditableText::EPageBreak);
       
   660 	}
       
   661 
       
   662 //----------------------------------------------------------------------------------------
       
   663 inline TBool CImSendRichText::IsPlain( TChar aChar ) const
       
   664 //----------------------------------------------------------------------------------------
       
   665 	{
       
   666 	return (((aChar >= '!') && (aChar <= KImcvSemiColon)) 
       
   667 					|| ((aChar >= KImcvRightChevron) && (aChar <= KImcvTilde)));
       
   668 	};
       
   669 
       
   670 //----------------------------------------------------------------------------------------
       
   671 inline TUint8 CImSendRichText::ReplacementChar( TChar aControlChar ) const
       
   672 //----------------------------------------------------------------------------------------
       
   673 	{
       
   674 	if (aControlChar==CEditableText::ETabCharacter)
       
   675 		return KImcvTab;
       
   676 
       
   677 	if (aControlChar==CEditableText::ENonBreakingHyphen)
       
   678 		return KImcvHyphen;
       
   679 
       
   680 	if (aControlChar==CEditableText::ENonBreakingSpace)
       
   681 		return KImcvSP;
       
   682 
       
   683 	return 0;
       
   684 	}
       
   685 
       
   686 //----------------------------------------------------------------------------------------
       
   687 inline int CImSendRichText::ConvertLineBreaks( TDes& aSource, TBool aLineBreak) const
       
   688 //----------------------------------------------------------------------------------------
       
   689 	{ 		
       
   690 	// Need to get rid of 16 bit richtext control characters before moving to 8bit buffer
       
   691 	// Therefore convert to the old para delimiter, convert to CRLF later in EncodeRichText.
       
   692 	// Its horrible, but what can you do.
       
   693 
       
   694 	TInt padding=0;
       
   695 	TInt len=aSource.Length();
       
   696 	TUint8 repChar;
       
   697 	for (TInt i=0; i<len; i++)
       
   698 		{
       
   699 		repChar=ReplacementChar(aSource[i]);
       
   700 		if (repChar)
       
   701 			aSource[i]=repChar;
       
   702 		else if ( IsEOL(aSource[i]) )
       
   703 			{
       
   704 			aSource[i]=KImcvCR;
       
   705 			aSource.SetLength(i+2);
       
   706 			aSource[i+1]=KImcvLF;
       
   707 			padding+=1;
       
   708 			if (aLineBreak)
       
   709 				break;
       
   710 			}
       
   711 		} 
       
   712 	return padding;
       
   713 	};
       
   714 
       
   715 //****************************************************************************************
       
   716 //              Class CImSendFile Functions
       
   717 //****************************************************************************************
       
   718 
       
   719 
       
   720 //----------------------------------------------------------------------------------------
       
   721 inline TInt CImSendFile::Size() const
       
   722 //----------------------------------------------------------------------------------------
       
   723 	{
       
   724 	return iAttachmentInfo.iSize;
       
   725 	}
       
   726 
       
   727 //****************************************************************************************
       
   728 //              Class CImCalculateMsgSize Functions
       
   729 //****************************************************************************************
       
   730 
       
   731 //----------------------------------------------------------------------------------------
       
   732 inline TInt CImCalculateMsgSize::MessageSize() const
       
   733 //----------------------------------------------------------------------------------------
       
   734 	{
       
   735 	return iSize;
       
   736 	}
       
   737 
       
   738 //----------------------------------------------------------------------------------------
       
   739 inline void CImCalculateMsgSize::Progress(TInt& rCurrentSize, TInt& rTotalSize)
       
   740 //----------------------------------------------------------------------------------------
       
   741 	{
       
   742 	rCurrentSize=iSize;
       
   743 	rTotalSize=iTotal;
       
   744 	}