email/mail/PluginSrc/MailHtmlView/CLoadHtmlFile.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Loads html content 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include 	"MailLog.h"
       
    22 #include 	"MailUtils.h"
       
    23 #include    "CLoadHtmlFile.h"
       
    24 #include 	"CHtmlLoadAttachments.h"
       
    25 #include    "CMailHtmlBodyControl.h"
       
    26 #include    <MMailAppUiInterface.h>
       
    27 #include    <CMailMessage.h>
       
    28 #include 	<stringloader.h>
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // load html file
       
    33 // -----------------------------------------------------------------------------
       
    34 // CLoadHtmlFile::MessageLoadingL
       
    35 // -----------------------------------------------------------------------------
       
    36 //	
       
    37 void CLoadHtmlFile::MessageLoadingL( TInt aStatus, CMailMessage& aMessage )
       
    38 	{
       
    39 	if( aStatus == CMailMessage::EBodyTextReady ) 
       
    40 		{
       
    41 		LOG("CLoadHtmlFile::MessageLoadingL - EBodyTextReady");
       
    42 
       
    43         TRAPD( err, LoadHtmlFileL( aMessage ) );
       
    44         
       
    45         // Complete observer regardless of result	
       
    46 		TRequestStatus* observer = iLoadStatus;
       
    47 		User::RequestComplete( observer, err );
       
    48 		
       
    49 		// Then leave this method if error occurred
       
    50 		User::LeaveIfError( err );
       
    51 		}
       
    52 	}
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CLoadHtmlFile::CLoadHtmlFile
       
    56 // -----------------------------------------------------------------------------
       
    57 //	
       
    58 CLoadHtmlFile::CLoadHtmlFile( 
       
    59 	MMailAppUiInterface* aAppUI,
       
    60 	CMailHtmlBodyControl& aHtmlControl ):
       
    61 	iHtmlControl( aHtmlControl )
       
    62 	{
       
    63 	iAppUI = aAppUI;
       
    64 	}
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CLoadHtmlFile::~CLoadHtmlFile
       
    68 // -----------------------------------------------------------------------------
       
    69 //	
       
    70 CLoadHtmlFile::~CLoadHtmlFile()
       
    71 	{
       
    72 	
       
    73 	}
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CLoadHtmlFile::NextStateL
       
    77 // -----------------------------------------------------------------------------
       
    78 //		
       
    79 MLoadState* CLoadHtmlFile::NextStateL()
       
    80 	{
       
    81 	return new( ELeave ) CHtmlLoadAttachments( iAppUI );
       
    82 	}
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CLoadHtmlFile::MakeRequestL
       
    86 // -----------------------------------------------------------------------------
       
    87 //	
       
    88 void CLoadHtmlFile::MakeRequestL( 
       
    89 	TRequestStatus& aStatus,
       
    90 	CMailMessage& aMessage )
       
    91 	{
       
    92 	iLoadStatus = &aStatus;
       
    93 	aMessage.LoadHtmlContentL( *this );
       
    94 	aStatus = KRequestPending;
       
    95 	}
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CLoadHtmlFile::LoadHtmlFileL
       
    99 // -----------------------------------------------------------------------------
       
   100 //	
       
   101 void CLoadHtmlFile::LoadHtmlFileL( CMailMessage& aMessage )
       
   102     {
       
   103 	RFile handle = aMessage.HtmlContent();
       
   104 	CleanupClosePushL( handle );
       
   105 	if ( handle.SubSessionHandle() != 0 )
       
   106 		{
       
   107         // load content to br control
       
   108 	    TInt fileSize;
       
   109 	    TInt error = handle.Size( fileSize );
       
   110 	    if ( error == KErrNone )
       
   111 	    	{
       
   112 	    	iHtmlControl.BrowserControl().LoadFileL( handle );
       
   113 	    	}
       
   114 	    else
       
   115 	        {
       
   116 	        LOG1( "CLoadHtmlFile::LoadHtmlFileL error:%d", error );
       
   117 	        User::Leave( error );
       
   118 	        }       
       
   119 		}
       
   120 	else
       
   121 		{
       
   122 		// corrupted html file?
       
   123 		User::Leave( KErrCorrupt );
       
   124 		}    
       
   125     CleanupStack::PopAndDestroy(); // handle		
       
   126     }
       
   127 
       
   128 //  End of File