email/mail/PluginSrc/MailHtmlView/CHtmlMailLoadStateMachine.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 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:  internal
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CHtmlMailLoadStateMachine.h"
       
    22 #include    "CLoadAttachedMessages.h"
       
    23 #include	"CLoadHtmlFile.h"
       
    24 #include 	"MailLog.h"
       
    25 #include 	"MailUtils.h"
       
    26 #include    <CMailMessage.h>
       
    27 
       
    28 // ============================= LOCAL FUNCTIONS ===============================
       
    29 
       
    30 /// State machine
       
    31 // -----------------------------------------------------------------------------
       
    32 // CHtmlLoadStateMachine::NewL
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 
       
    36 CHtmlLoadStateMachine* CHtmlLoadStateMachine::NewL( 
       
    37 	MMailAppUiInterface* aAppUI,
       
    38 	CMailMessage& aMessage,
       
    39 	CMailHtmlBodyControl& aHtmlControl )
       
    40 	{
       
    41 	CHtmlLoadStateMachine* self = new(ELeave) CHtmlLoadStateMachine( 
       
    42 		aAppUI, aMessage, aHtmlControl ); 
       
    43 	CleanupStack::PushL(self);
       
    44 	self->ConstructL();
       
    45 	CleanupStack::Pop(self);
       
    46 	return self;
       
    47 	}
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CHtmlLoadStateMachine::ConstructL
       
    51 // -----------------------------------------------------------------------------
       
    52 //	
       
    53 void CHtmlLoadStateMachine::ConstructL()
       
    54 	{
       
    55 	iState = new( ELeave ) CLoadHtmlFile( iAppUI, iHtmlControl );
       
    56    /* if ( iMessage.MessageEntry().Attachment() )
       
    57         {
       
    58         
       
    59         }
       
    60     else
       
    61         {
       
    62       //  iState = new( ELeave ) CLoadHtmlFile( iAppUI, *this );
       
    63         }*/
       
    64 	CActiveScheduler::Add( this );
       
    65 	}
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CHtmlLoadStateMachine::StartL
       
    69 // -----------------------------------------------------------------------------
       
    70 //	
       
    71 void CHtmlLoadStateMachine::StartL()
       
    72 	{
       
    73 	iState->MakeRequestL( iStatus, iMessage );
       
    74 	SetActive();
       
    75 	}
       
    76 	
       
    77 // -----------------------------------------------------------------------------
       
    78 // CHtmlLoadStateMachine::~CHtmlLoadStateMachine
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CHtmlLoadStateMachine::~CHtmlLoadStateMachine()
       
    82 	{
       
    83 	LOG( "CHtmlLoadStateMachine::~CHtmlLoadStateMachine()" );
       
    84 	Cancel();
       
    85 	delete iState;
       
    86 	}
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CHtmlLoadStateMachine::DoCancel
       
    90 // -----------------------------------------------------------------------------
       
    91 //	
       
    92 void CHtmlLoadStateMachine::DoCancel()
       
    93 	{
       
    94 	TRequestStatus* observer = &iStatus;
       
    95 	User::RequestComplete( observer, KErrCancel );
       
    96 		
       
    97 	LOG( "CHtmlLoadStateMachine::DoCancel()" );
       
    98 	iMessage.Cancel();
       
    99 	}
       
   100 	
       
   101 // -----------------------------------------------------------------------------
       
   102 // CHtmlLoadStateMachine::RunL
       
   103 // -----------------------------------------------------------------------------
       
   104 //	
       
   105 void CHtmlLoadStateMachine::RunL()
       
   106 	{
       
   107 	// select next state;
       
   108 	MLoadState* newState = iState->NextStateL();
       
   109 	delete iState;
       
   110 	iState = newState;
       
   111 	if ( iState )
       
   112 		{
       
   113 		iState->MakeRequestL( iStatus, iMessage );
       
   114 		SetActive();
       
   115 		}
       
   116 	else
       
   117 		{
       
   118 		Deque();
       
   119 		}
       
   120 	}
       
   121 	
       
   122 // -----------------------------------------------------------------------------
       
   123 // CHtmlLoadStateMachine::RunError
       
   124 // -----------------------------------------------------------------------------
       
   125 //	
       
   126 TInt CHtmlLoadStateMachine::RunError(TInt /*aError*/)
       
   127 	{
       
   128 	return KErrNone;
       
   129 	}
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CHtmlLoadStateMachine::CHtmlLoadStateMachine
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 CHtmlLoadStateMachine::CHtmlLoadStateMachine( 
       
   136 	MMailAppUiInterface* aAppUI, CMailMessage& aMessage,
       
   137 	CMailHtmlBodyControl& aHtmlControl )
       
   138 	:CActive( CActive::EPriorityStandard ),
       
   139 	iAppUI( aAppUI ), 
       
   140 	iMessage( aMessage ),
       
   141 	iHtmlControl( aHtmlControl )
       
   142 	{
       
   143 	}
       
   144 
       
   145 //  End of File