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