email/mail/PluginSrc/icalviewer/uisrc/cicalattaloader.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:  Mail icalviewer attachment loader
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "cicalattaloader.h"
       
    22 #include  <MMailAppUiInterface.h>
       
    23 #include  <CMailMessage.h>
       
    24 #include  <MMsvAttachmentManager.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CICalAttaLoader::CICalAttaLoader
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CICalAttaLoader::CICalAttaLoader( MMailAppUiInterface& aAppUI )
       
    37     : iAppUI( aAppUI ),
       
    38     iFinishedWithAttachments( EFalse )
       
    39     {
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CICalAttaLoader::NewL
       
    44 // Two-phased constructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CICalAttaLoader* CICalAttaLoader::NewL( MMailAppUiInterface& aAppUI )
       
    48 	{
       
    49 	return new( ELeave ) CICalAttaLoader( aAppUI );
       
    50 	}
       
    51 	
       
    52 // -----------------------------------------------------------------------------
       
    53 // CICalAttaLoader::~CICalAttaLoader
       
    54 // Destructor
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CICalAttaLoader::~CICalAttaLoader()
       
    58     {
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CICalAttaLoader::StartLoadingL
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CICalAttaLoader::StartLoadingL( CMailMessage& aMessage )
       
    66     {
       
    67     iFinishedWithAttachments = EFalse;
       
    68     aMessage.LoadAttachmentsL( *this );
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CICalAttaLoader::FinishedWithAttachments
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 TBool CICalAttaLoader::FinishedWithAttachments()
       
    76     {
       
    77     return iFinishedWithAttachments;
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CICalAttaLoader::MessageLoadingL
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CICalAttaLoader::MessageLoadingL( TInt aStatus, CMailMessage& aMessage )
       
    85     {
       
    86 	if ( aStatus == CMailMessage::EAttachmentsReady ) 
       
    87 		{
       
    88 	    MMsvAttachmentManager& manager = aMessage.AttachmentManager();
       
    89 		TInt count = manager.AttachmentCount();
       
    90 			
       
    91         // current implementation (also in the ical viewer) assumes that .ics
       
    92         // attachment is the first attachment in the array, if it isn't
       
    93         // then e-mail is not viewed with ical viewer. We will hide that
       
    94         // first .ics attachment from the user -> start from index 1        
       
    95         for ( TInt i( 1 ); i < count; ++i ) 
       
    96             {
       
    97             iFinishedWithAttachments = ETrue; 
       
    98             CMsvAttachment* info = manager.GetAttachmentInfoL( i );
       
    99             CleanupStack::PushL( info );			
       
   100             iAppUI.AddAttachmentL( *info, ETrue );			
       
   101             CleanupStack::PopAndDestroy( info );
       
   102             }
       
   103 		}    
       
   104     }
       
   105 
       
   106 //  End of File
       
   107