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