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