email/mail/PluginSrc/MailHtmlView/CHtmlLoadAttachments.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 message attachments 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CHtmlLoadAttachments.h"
       
    22 #include 	"MailLog.h"
       
    23 #include 	"MailUtils.h"
       
    24 #include 	"CLoadAttachedMessages.h"
       
    25 #include    <MMailAppUiInterface.h>
       
    26 #include    <CMailMessage.h>
       
    27 #include    <MMsvAttachmentManager.h>
       
    28 #include 	<stringloader.h>
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 /// messages
       
    33 // -----------------------------------------------------------------------------
       
    34 // CHtmlLoadAttachments::MessageLoadingL
       
    35 // -----------------------------------------------------------------------------
       
    36 //	
       
    37 void CHtmlLoadAttachments::MessageLoadingL(TInt aStatus, CMailMessage& aMessage)
       
    38 	{
       
    39 	if( aStatus == CMailMessage::EAttachmentsReady ) 
       
    40 		{
       
    41 		//Tell that loading of attachments has started
       
    42 		iAppUI->StartWaitNoteL();
       
    43 
       
    44 	    MMsvAttachmentManager& manager = aMessage.AttachmentManager();		
       
    45         TRAPD( err, AddAttachmentsToAppUiL( manager ) );
       
    46         
       
    47 		//Tell that loading of attachments has ended
       
    48 		iAppUI->StopWaitNote();
       
    49 		
       
    50 		// Complete observer regardless of result
       
    51 		TRequestStatus* observer = iLoadStatus;
       
    52 		User::RequestComplete( observer, err );
       
    53 		
       
    54 		// Then leave this method if error occurred
       
    55 		User::LeaveIfError( err );
       
    56 		}
       
    57 	}
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CHtmlLoadAttachments::CHtmlLoadAttachments
       
    61 // -----------------------------------------------------------------------------
       
    62 //	
       
    63 CHtmlLoadAttachments::CHtmlLoadAttachments( MMailAppUiInterface* aAppUI )
       
    64 	{
       
    65 	iAppUI = aAppUI;
       
    66 	}
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CHtmlLoadAttachments::~CHtmlLoadAttachments
       
    70 // -----------------------------------------------------------------------------
       
    71 //	
       
    72 CHtmlLoadAttachments::~CHtmlLoadAttachments()
       
    73 	{
       
    74 	
       
    75 	}
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CHtmlLoadAttachments::NextStateL
       
    79 // -----------------------------------------------------------------------------
       
    80 //	
       
    81 MLoadState* CHtmlLoadAttachments::NextStateL()
       
    82 	{
       
    83 	return new(ELeave) CLoadAttachedMessages( iAppUI );
       
    84 	}
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CHtmlLoadAttachments::MakeRequestL
       
    88 // -----------------------------------------------------------------------------
       
    89 //		
       
    90 void CHtmlLoadAttachments::MakeRequestL( 
       
    91 	TRequestStatus& aStatus,
       
    92 	CMailMessage& aMessage )
       
    93 	{
       
    94 	iLoadStatus = &aStatus;
       
    95 	aMessage.LoadAttachmentsL( *this );
       
    96 	aStatus = KRequestPending;
       
    97 	}
       
    98 
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CHtmlLoadAttachments::AddAttachmentsToAppUiL
       
   102 // -----------------------------------------------------------------------------
       
   103 //		
       
   104 void CHtmlLoadAttachments::AddAttachmentsToAppUiL(
       
   105     MMsvAttachmentManager& aManager )
       
   106     {
       
   107 	LOG1("CHtmlLoadAttachments::AddAttachmentsToAppUiL attachmentCount:%d", 
       
   108 	     aManager.AttachmentCount());
       
   109 
       
   110 	//It is possible that aManager.AttachmentCount() changes while we are in 
       
   111 	//this loop. That is why latest count is checked every round.
       
   112 	for ( TInt index(0); index < aManager.AttachmentCount(); ++index ) 
       
   113 		{ 
       
   114 		LOG1("CHtmlLoadAttachments::AddAttachmentsToAppUiL iteration: %d",
       
   115 		     index);
       
   116 		CMsvAttachment* info = aManager.GetAttachmentInfoL( index );
       
   117 		CleanupStack::PushL( info );
       
   118 		
       
   119 		LOG("CHtmlLoadAttachments::AddAttachmentsToAppUiL adding atta");
       
   120 		iAppUI->AddAttachmentL( *info, ETrue );
       
   121 		LOG("CHtmlLoadAttachments::AddAttachmentsToAppUiL atta added");
       
   122 		
       
   123 		CleanupStack::PopAndDestroy( info );
       
   124 		}    
       
   125     }
       
   126     
       
   127 //  End of File