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