email/mail/PluginSrc/icalviewer/uisrc/CICalViewer.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  ICalendar viewer ECOM plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "CICalViewer.h"
       
    22 #include "CICalViewerView.h"
       
    23 #include "MailLog.h"
       
    24 #include "ICalViewer.hrh"
       
    25 #include "icalvieweruid.h"
       
    26 #include <avkon.hrh>
       
    27 #include "cicalattaloader.h"
       
    28 #include <MRCommands.hrh>
       
    29 
       
    30 // SYSTEM INCLUDES
       
    31 #include <stringloader.h>
       
    32 #include <MsgEditorView.h>  // CMsgEditorView
       
    33 #include <FeatMgr.h>
       
    34 #include <icalvieweruires.rsg>
       
    35 #include <MsgMailViewer.rsg>
       
    36 #include <MMSVATTACHMENTMANAGER.H>
       
    37 #include <msgmailviewer.hrh>
       
    38 #include <CMSVATTACHMENT.H>
       
    39 #include <APGCLI.H>
       
    40 #include <calsession.h>
       
    41 #include <CALENTRY.H>	 	//calendar api V2
       
    42 #include <MAgnEntryUi.h> 	//entry ui params
       
    43 #include <MsgMailUIDs.h> 	//mail viewer application uid
       
    44 #include <CMailMessage.h> 	//mail
       
    45 #include <e32des16.h> 		//HBufC
       
    46 #include <caluser.h> 		//CCalAttendee
       
    47 #include <calalarm.h> 		//CCalAlarm
       
    48 #include <calrrule.h> 		//TCalRRule
       
    49 #include <e32std.h> 
       
    50 #include <e32base.h> 
       
    51 #include <CalenImporter.h>	// import/export for ical files
       
    52 #include <SendUiConsts.h>   //MTM uid constants for resolver params
       
    53 
       
    54 
       
    55 // CONSTANTS
       
    56 /// Unnamed namespace for local definitions
       
    57 namespace {
       
    58 
       
    59 _LIT(KICalUiResourceFile, "icalvieweruires.rsc");
       
    60 _LIT8(KDataTypeVCalendar2, "text/x-vCalendar"); // vCalendar v1.0 MIME type
       
    61 _LIT8(KDataTypeVCalendar3, "text/calendar"); // vCalendar v2.0 MIME type
       
    62 
       
    63 enum TStatusFlags
       
    64     {
       
    65     EFlagRecognized = KBit0,
       
    66     EFlagIsUnread = KBit1, // MsgEditor sets unread flag to EFalse too early!
       
    67 	EFlagIsNavigableForward = KBit2,
       
    68 	EFlagIsNavigableBackward = KBit3,
       
    69     }; 
       
    70     
       
    71 }  // namespace
       
    72 
       
    73 
       
    74 // ============================ MEMBER FUNCTIONS ===============================
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CICalViewer::CICalViewer
       
    78 // C++ default constructor can NOT contain any code, that
       
    79 // might leave.
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 CICalViewer::CICalViewer(): iFlags(0)
       
    83     {
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CICalViewer::ConstructL
       
    88 // Symbian 2nd phase constructor can leave.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CICalViewer::ConstructL()
       
    92     {
       
    93     LOG("CICalViewer::ConstructL");    
       
    94     FeatureManager::InitializeLibL();
       
    95     
       
    96     TFileName driveName;
       
    97     DoGetCorrectDllDriveL( driveName );
       
    98     TInt nameLength = driveName.Length() + KICalUiResourceFile().Length();
       
    99     LOG1("CICalViewer::ConstructL: namelength: %d", nameLength);
       
   100     iResourceFile = HBufC::NewL( KMaxFileName );
       
   101     *iResourceFile = driveName;
       
   102     iResourceFile->Des().Append( KICalUiResourceFile );
       
   103       
       
   104     LOG("CICalViewer::ConstructL -> End");
       
   105     }
       
   106 // -----------------------------------------------------------------------------
       
   107 // CICalViewer::NewL
       
   108 // Two-phased constructor.
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 CICalViewer* CICalViewer::NewL()
       
   112 	{
       
   113     CICalViewer* self = new(ELeave) CICalViewer();
       
   114 	CleanupStack::PushL(self);
       
   115 	self->ConstructL();
       
   116 	CleanupStack::Pop(self);
       
   117 	return self;
       
   118 	}
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CICalViewer::~CICalViewer()
       
   122 // Destructor
       
   123 // -----------------------------------------------------------------------------
       
   124 // 
       
   125 CICalViewer::~CICalViewer()
       
   126     {
       
   127     LOG("CICalViewer::~CICalViewer");
       
   128     delete iResourceFile;
       
   129     delete iAttaLoad;
       
   130     delete iICalView;
       
   131     FeatureManager::UnInitializeLib();
       
   132     iEntries.ResetAndDestroy();
       
   133     delete iIdleLauncher;
       
   134     delete iImporter;
       
   135     delete iEntryUiInParams;
       
   136     delete iEntryUiOutParams;
       
   137     delete iSession;
       
   138     LOG("CICalViewer::~CICalViewer -> End");    
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CICalViewer::ViewMessageL
       
   143 // -----------------------------------------------------------------------------
       
   144 // 
       
   145 void CICalViewer::ViewMessageL( RFileReadStream& aReadStream, 
       
   146 	MMailAppUiInterface& aUICallBack)
       
   147     {
       
   148     LOG("CICalViewer::ViewMessageL (BVA)");
       
   149         
       
   150     if (!iAppUi)
       
   151         {
       
   152         iAppUi = &aUICallBack;
       
   153         }
       
   154 	
       
   155 	if ( !iSession )
       
   156 		{			
       
   157 		iSession = CCalSession::NewL();
       
   158 		}
       
   159 	
       
   160 	TRAPD( err, iSession->OpenL( iSession->DefaultFileNameL() ) );
       
   161     if ( err == KErrNotFound )
       
   162         {
       
   163         iSession->CreateCalFileL( iSession->DefaultFileNameL() );
       
   164         iSession->OpenL( iSession->DefaultFileNameL() );
       
   165         }
       
   166     else
       
   167         {
       
   168         User::LeaveIfError( err );
       
   169         }	
       
   170 	
       
   171 	if ( !iImporter )
       
   172 	    {
       
   173 	    iImporter = CCalenImporter::NewL( *iSession );
       
   174 	    }
       
   175 	    
       
   176     LOG("CICalViewer::ViewMessageL, starting iCal importing");
       
   177 	iImporter->ImportICalendarL( aReadStream, iEntries );
       
   178 	
       
   179 	if( iEntries.Count() == 0 )
       
   180 		{
       
   181 		User::Leave( KErrNotFound );
       
   182 		}
       
   183 		
       
   184     LOG("CICalViewer:: ...importing finished");				
       
   185 			
       
   186     LOG("CICalViewer::ViewMessageL, creating AgnEntryUi");
       
   187     iEntryUiInParams = new(ELeave) MAgnEntryUi::TAgnEntryUiInParams(
       
   188     	TUid::Uid( KUidBVAApplication ),
       
   189     	*iSession,
       
   190     	MAgnEntryUi::EViewEntry );
       
   191     	
       
   192     LOG("CICalViewer::ViewMessageL, launching viewer");
       
   193     // In case of BVA we can always launch the default AgnEntryUi
       
   194     // -> this can be achieved by giving SMTP mtm uid
       
   195     DoViewMessageL( KSenduiMtmSmtpUid );
       
   196     LOG("CICalViewer::ViewMessageL -> End");    
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // CICalViewer::ParseMessageToCalEntryL
       
   201 // -----------------------------------------------------------------------------
       
   202 // 
       
   203 void CICalViewer::ParseMessageToCalEntryL( CMailMessage& aMessage )
       
   204 	{
       
   205     LOG("CICalViewer::ParseMessageToCalEntryL");    	
       
   206 	if ( !iSession )
       
   207 		{			
       
   208 		iSession = CCalSession::NewL();
       
   209 		}
       
   210 	
       
   211 	TRAPD( err, iSession->OpenL( iSession->DefaultFileNameL() ) );
       
   212     if ( err == KErrNotFound )
       
   213         {
       
   214         iSession->CreateCalFileL( iSession->DefaultFileNameL() );
       
   215         iSession->OpenL( iSession->DefaultFileNameL() );
       
   216         }
       
   217     else
       
   218         {
       
   219         User::LeaveIfError( err );
       
   220         }	    
       
   221 
       
   222     LOG("CICalViewer::ParseMessageToCalEntryL, checking attachment info");
       
   223 
       
   224 	MMsvAttachmentManager& attachmentManager = 
       
   225 				aMessage.AttachmentManager();			
       
   226 				
       
   227 	TInt attaCount = attachmentManager.AttachmentCount();
       
   228 	
       
   229 	if ( attaCount > 0 )
       
   230 		{
       
   231 		CMsvAttachment* info = attachmentManager.GetAttachmentInfoL(0);
       
   232 		CleanupStack::PushL(info);
       
   233 
       
   234 		const TDesC& filePath = info->FilePath();
       
   235 
       
   236 		RFile attachment = attachmentManager.GetAttachmentFileL( 0 );
       
   237 		CleanupClosePushL( attachment ); // RFile must be closed
       
   238 
       
   239 		RFileReadStream stream( attachment, 0 );
       
   240 		CleanupClosePushL( stream );
       
   241 		
       
   242 		if ( !iImporter )
       
   243 		    {
       
   244 		    iImporter = CCalenImporter::NewL( *iSession );
       
   245 		    }
       
   246 				    
       
   247         LOG("CICalViewer:: starting iCal importing");
       
   248 		iImporter->ImportICalendarL( stream, iEntries );
       
   249 		
       
   250 		if( iEntries.Count() == 0 )
       
   251 			{
       
   252 			User::Leave( KErrNotFound );
       
   253 			}
       
   254 		
       
   255         LOG("CICalViewer:: ...importing finished");		
       
   256 		
       
   257 		//checking of ical entry on rudimentary level
       
   258 		//so that we can make a leave here...
       
   259 		//even so... the ical cant be launched from plain text viewer
       
   260 		//only the alternative description text is shown to user
       
   261 
       
   262 		CCalEntry& entry = *( iEntries[0] );
       
   263 		switch ( entry.MethodL() )
       
   264 			{
       
   265 			case CCalEntry::EMethodNone:
       
   266 			case CCalEntry::EMethodPublish:
       
   267 			case CCalEntry::EMethodAdd:
       
   268 			case CCalEntry::EMethodRefresh:
       
   269 			case CCalEntry::EMethodCounter:
       
   270 			case CCalEntry::EMethodDeclineCounter:
       
   271 				{
       
   272 				User::Leave( KErrNotSupported );
       
   273 				}
       
   274 			}
       
   275 
       
   276 		CleanupStack::PopAndDestroy( 3 );				// CSI: 47 # stream, attachment, info
       
   277 		}
       
   278     LOG("CICalViewer::ParseMessageToCalEntryL -> End");		
       
   279 	}
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CICalViewer::ViewMessageL
       
   283 // -----------------------------------------------------------------------------
       
   284 // 
       
   285 void CICalViewer::ViewMessageL(
       
   286 	CMailMessage& aMessage,
       
   287 	MMailAppUiInterface& aUICallBack, 
       
   288 	TUint& aParam )
       
   289     {
       
   290     LOG("CICalViewer::ViewMessageL (mail)");      
       
   291         
       
   292     aParam |= EMailUseDefaultNaviPane; 
       
   293 	
       
   294 	iMsg = aMessage.MessageEntry();
       
   295 	
       
   296     if (!iAppUi)
       
   297         {
       
   298         iAppUi = &aUICallBack;
       
   299         }
       
   300         
       
   301     LOG("CICalViewer::ViewMessageL, creating AgnEntryUi");
       
   302     iEntryUiInParams = new(ELeave) MAgnEntryUi::TAgnEntryUiInParams(
       
   303     	TUid::Uid( KUidMsgMailViewer ),
       
   304     	*iSession,
       
   305     	MAgnEntryUi::EViewEntry );
       
   306     	
       
   307 	iEntryUiInParams->iMailBoxId = iMsg.iServiceId;
       
   308 	iEntryUiInParams->iMsgSession = aMessage.Session();
       
   309 	iEntryUiInParams->iMessageId = iMsg.Id();
       
   310 
       
   311     // Load attachments, otherwise they won't be visible in the
       
   312     // attachement manager. CICalViewer::MessageLoadL() received
       
   313     // also attachments ready signal, but attachment manager was
       
   314     // resetted after that.
       
   315     if ( !iAttaLoad )
       
   316         {
       
   317         iAttaLoad = CICalAttaLoader::NewL( *iAppUi );
       
   318         }
       
   319     iAttaLoad->StartLoadingL( aMessage );
       
   320 
       
   321     LOG("CICalViewer::ViewMessageL, launching viewer");
       
   322     DoViewMessageL( iMsg.iMtm );
       
   323     LOG("CICalViewer::ViewMessageL -> End");        
       
   324     }
       
   325 
       
   326 // -----------------------------------------------------------------------------
       
   327 // CICalViewer::IdleTimerCallbackL
       
   328 // This method must be leaving so that exiting from viewer
       
   329 // is possible (done using basched.h KLeaveExit)
       
   330 // -----------------------------------------------------------------------------
       
   331 //
       
   332 TInt CICalViewer::IdleTimerCallbackL(TAny* aViewer)	// CSI: 40 # We must return 
       
   333 													// the integer value although this 
       
   334 													// is a leaving method.
       
   335 	{
       
   336 	CICalViewer* thisViewer = static_cast<CICalViewer*>( aViewer );
       
   337 	TRAPD( err, thisViewer->DoOMRViewerLaunchL() );
       
   338 	if ( err != KErrNone )
       
   339 	    {
       
   340         LOG("CIcalViewer::IdleTimerCallback, leave occurred, exiting");	    
       
   341         thisViewer->iAppUi->AppUiHandleCommandL( EAknSoftkeyBack );
       
   342 	    }
       
   343 	return EFalse;
       
   344 	}
       
   345 
       
   346 // -----------------------------------------------------------------------------
       
   347 // CICalViewer::DoOMRViewerLaunchL
       
   348 // -----------------------------------------------------------------------------
       
   349 // 
       
   350 void CICalViewer::DoOMRViewerLaunchL()
       
   351 	{
       
   352     LOG("CICalViewer::DoOMRViewerLaunchL");	
       
   353 	iEntryUiOutParams = new(ELeave) MAgnEntryUi::TAgnEntryUiOutParams();
       
   354 	ASSERT( iSession );
       
   355 	    	
       
   356     LOG("CICalViewer::DoOMRViewerLaunchL, executing viewer");    	
       
   357 	iRetVal = iICalView->ExecuteViewL( iEntries,
       
   358 	                                   *iEntryUiInParams,
       
   359 	                                   *iEntryUiOutParams,
       
   360 	                                   *this );
       
   361 	LOG("CICalViewer::DoOMRViewerLaunchL, viewer finished");
       
   362 	//we need to call back to ui for exiting the mail application
       
   363 	iAppUi->AppUiHandleCommandL( EAknSoftkeyBack );
       
   364 	
       
   365     LOG("CICalViewer::DoOMRViewerLaunchL -> End"); 	
       
   366 	}
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // CICalViewer::DoGetCorrectDllDriveL
       
   370 // -----------------------------------------------------------------------------
       
   371 //    
       
   372 void CICalViewer::DoGetCorrectDllDriveL( TFileName& aDriveName )
       
   373     {
       
   374     TParse parse;
       
   375     Dll::FileName( aDriveName );
       
   376 	User::LeaveIfError( parse.Set( aDriveName, NULL, NULL ) );
       
   377     aDriveName = parse.Drive(); // contains drive, e.g. "c:"
       
   378     }
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CICalViewer::DoViewMessageL
       
   382 // -----------------------------------------------------------------------------
       
   383 // 
       
   384 void CICalViewer::DoViewMessageL( TUid aMtmUid )
       
   385 	{
       
   386 	
       
   387     if ( iAppUi->IsNextMessageAvailableL( ETrue ) )
       
   388         {        
       
   389     	iFlags |= EFlagIsNavigableForward;
       
   390         }
       
   391     
       
   392     if ( iAppUi->IsNextMessageAvailableL( EFalse ) )
       
   393         {        
       
   394     	iFlags |= EFlagIsNavigableBackward;
       
   395         }
       
   396 
       
   397 	
       
   398     LOG("CICalViewer::DoViewMessageL");		
       
   399 	iAppUi->SetTitleTextL(R_QTN_MAIL_TITLE_MTG_REQUEST);
       
   400 
       
   401     iICalView = CICalViewerView::NewL( aMtmUid );
       
   402     
       
   403     LOG("CICalViewer:: adding ical viewer control");    	
       
   404 	iAppUi->AddControlL(*iICalView);
       
   405 		
       
   406 	//idle timer 
       
   407 	iIdleLauncher = CIdle::NewL(CActive::EPriorityIdle);
       
   408     LOG("CICalViewer:: starting idle launcher");	
       
   409  	iIdleLauncher->Start(TCallBack(IdleTimerCallbackL,this));
       
   410     LOG("CICalViewer::DoViewMessageL -> End");	 	
       
   411 	}
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // CICalViewer::DynInitMenuPaneL
       
   415 // -----------------------------------------------------------------------------
       
   416 // 
       
   417 void CICalViewer::DynInitMenuPaneL(TInt /*aResourceId*/,
       
   418 	CEikMenuPane* /*aMenuPane*/)
       
   419     {
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CICalViewer::HandleCommandL
       
   424 // -----------------------------------------------------------------------------
       
   425 // 
       
   426 TBool CICalViewer::HandleCommandL(TInt /*aCommand*/)
       
   427     {
       
   428     return EFalse;
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // CICalViewer::HandleKeyEventL
       
   433 // -----------------------------------------------------------------------------
       
   434 // 
       
   435 TKeyResponse CICalViewer::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/,
       
   436 	TEventCode /*aType*/)
       
   437     {
       
   438     return EKeyWasConsumed;
       
   439     }
       
   440 
       
   441 // -----------------------------------------------------------------------------
       
   442 // CICalViewer::ResourceFile
       
   443 // -----------------------------------------------------------------------------
       
   444 // 
       
   445 const TDesC& CICalViewer::ResourceFile()
       
   446     {
       
   447     return *iResourceFile;
       
   448     }
       
   449 
       
   450 // -----------------------------------------------------------------------------
       
   451 // CICalViewer::MessageLoadL
       
   452 // -----------------------------------------------------------------------------
       
   453 // 
       
   454 void CICalViewer::MessageLoadL( TInt aState, CMailMessage& aMessage )
       
   455 	{
       
   456     LOG("CICalViewer::MessageLoadL");  	
       
   457 	switch (aState)
       
   458 		{
       
   459 		case CMailMessage::EHeaderReady:
       
   460 			{
       
   461             LOG("CICalViewer::aState == EHeaderReady");
       
   462             // This switch case doesn't seem to ever get called
       
   463 			break;
       
   464 			}
       
   465 		case CMailMessage::EAttachmentsReady:
       
   466 			{
       
   467             LOG("CICalViewer::aState == EAttachmentsReady");
       
   468             
       
   469             if ( !aMessage.MessageEntry().ICalendar() )
       
   470                 { // check that the entry is ical message
       
   471                 LOG("TMsvEmailEntry::ICalendar() returned EFalse");
       
   472                 User::Leave( KErrUnknown );
       
   473                 }
       
   474                             
       
   475             RFile attachment;
       
   476             TInt count = aMessage.AttachmentManager().AttachmentCount();
       
   477             
       
   478             if ( count > 0 )
       
   479 				{
       
   480 				attachment = 
       
   481 				    aMessage.AttachmentManager().GetAttachmentFileL( 0 );
       
   482                 CleanupClosePushL( attachment );
       
   483 				
       
   484 				RApaLsSession apaSession;
       
   485 				User::LeaveIfError( apaSession.Connect() );
       
   486 				CleanupClosePushL( apaSession );
       
   487 				TUid appUID( KNullUid );
       
   488 				TDataType dataType;
       
   489 				// Check only first attachment 
       
   490 				User::LeaveIfError( apaSession.AppForDocument( attachment,
       
   491 				                                               appUID,
       
   492 				                                               dataType ) );
       
   493 				CleanupStack::PopAndDestroy( 2 );			// CSI: 47 # apaSession, attachment
       
   494 				
       
   495 				if ( dataType.Des8().FindF( 
       
   496 					 KDataTypeVCalendar2 ) != KErrNotFound ||
       
   497                      dataType.Des8().FindF( 
       
   498 					 KDataTypeVCalendar3 ) != KErrNotFound )
       
   499 					{
       
   500                     LOG("CICalViewer::starting msg parsing");
       
   501 					//we can do attachment parsing only here as
       
   502 					//attachment manager is resetted after this
       
   503 										    		        
       
   504 					ParseMessageToCalEntryL( aMessage );
       
   505 					
       
   506 					iFlags |= EFlagRecognized;
       
   507 					LOG("CICalViewer::recognized!");
       
   508 					}
       
   509 				else
       
   510 					{
       
   511                     LOG("CICalViewer::datatype unknown");
       
   512 					// unknown
       
   513 					User::Leave( KErrUnknown );
       
   514 					}
       
   515 				}
       
   516 			else
       
   517 				{
       
   518 				User::Leave( KErrUnknown );
       
   519 				}
       
   520 			break;	
       
   521 			}
       
   522 		case CMailMessage::ELoadEnd:
       
   523 			{
       
   524             LOG("CICalViewer::aState == ELoadEnd");	
       
   525 			if ( !(iFlags & EFlagRecognized) )
       
   526 				{
       
   527 				// Not valid message
       
   528 				User::Leave( KErrUnknown );
       
   529 				}            
       
   530             if ( aMessage.IsNew() )
       
   531                 {                
       
   532                 iFlags |= EFlagIsUnread;
       
   533                 }
       
   534             break;
       
   535 			}
       
   536 		default:
       
   537 		    {		    
       
   538 		    // do nothing
       
   539 		    break;
       
   540 		    }
       
   541 		}
       
   542     LOG("CICalViewer::MessageLoadL -> End"); 
       
   543 	}
       
   544 
       
   545 // -----------------------------------------------------------------------------
       
   546 // CICalViewer::IsCommandAvailable
       
   547 // -----------------------------------------------------------------------------
       
   548 // 	
       
   549 TBool CICalViewer::IsCommandAvailable( TInt aCommandId )
       
   550     {
       
   551     TBool retVal( EFalse );
       
   552     switch ( aCommandId )
       
   553         {
       
   554         case EMRCommandRetrieve:
       
   555             {
       
   556             retVal = iMsg.PartialDownloaded();
       
   557             break;
       
   558             }
       
   559         case EMRCommandAttachments:
       
   560             {
       
   561             retVal = ( iAttaLoad && iAttaLoad->FinishedWithAttachments() );
       
   562             break;
       
   563             }
       
   564         case EMRCommandUnreadOpeningNote:
       
   565             {
       
   566             retVal = ( ( iFlags & EFlagIsUnread ) != 0 );
       
   567             break;
       
   568             }
       
   569         case EMRCommandNavigateBackward:
       
   570         	{
       
   571         	retVal = ( ( iFlags & EFlagIsNavigableBackward ) != 0 );
       
   572         	}
       
   573         case EMRCommandNavigateForward:
       
   574         	{
       
   575         	retVal = ( ( iFlags & EFlagIsNavigableForward ) != 0 );
       
   576         	break;
       
   577         	}
       
   578         default:
       
   579             {
       
   580             break;
       
   581             }
       
   582         }
       
   583     return retVal;
       
   584     }
       
   585 
       
   586 // -----------------------------------------------------------------------------
       
   587 // CICalViewer::ProcessCommandWithResultL
       
   588 // -----------------------------------------------------------------------------
       
   589 // 	
       
   590 TInt CICalViewer::ProcessCommandWithResultL( TInt aCommandId )	// CSI: 40 # We must return 
       
   591 																// the integer value although this 
       
   592 																// is a leaving method.
       
   593 	{
       
   594 	LOG("CICalViewer::ProcessCommandWithResultL -> End");
       
   595 	TInt retVal( KErrNone );
       
   596 	switch ( aCommandId )
       
   597 	    {
       
   598 	    case EMRCommandForward:
       
   599 	        {
       
   600 	        LOG("Calling AppUiHandleCommandL with forward cmd...");
       
   601 	        iAppUi->AppUiHandleCommandL( EMsgMailViewerCmdForward );
       
   602 	        break;
       
   603 	        }
       
   604 	    case EMRCommandRetrieve:
       
   605 	        {
       
   606 	        iAppUi->AppUiHandleCommandL( EMsgMailViewerCmdRetrieve );
       
   607 	        break;
       
   608 	        }	        
       
   609 	    case EMRCommandAttachments:
       
   610 	        {
       
   611 	        iAppUi->AppUiHandleCommandL( EMsgMailViewerCmdAttachments );
       
   612 	        break;
       
   613 	        }
       
   614 	    case EMRCommandMessageDetails:
       
   615 	        {
       
   616 	        iAppUi->AppUiHandleCommandL( EMsgMailViewerCmdMessageInfo );
       
   617 	        break;
       
   618 	        }
       
   619 	    case EMRCommandNavigateBackward:
       
   620 	    	{
       
   621 	    	iAppUi->NextMessageL( EFalse );
       
   622 	    	break;
       
   623 	    	}
       
   624 	    case EMRCommandNavigateForward:
       
   625 	    	{
       
   626 	    	iAppUi->NextMessageL( ETrue );
       
   627 	    	break;
       
   628 	    	}
       
   629 	    default:
       
   630 	        {
       
   631 	        User::Leave( KErrNotSupported );
       
   632 	        return KErrNotSupported;
       
   633 	        }
       
   634 	    }
       
   635     LOG("CICalViewer::ProcessCommandWithResultL -> End");
       
   636     return retVal;	
       
   637 	}
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CICalViewer::ProcessCommandL
       
   641 // -----------------------------------------------------------------------------
       
   642 // 
       
   643 void CICalViewer::ProcessCommandL( TInt aCommandId )
       
   644 	{
       
   645 	ProcessCommandWithResultL( aCommandId );
       
   646 	}
       
   647 
       
   648 //  End of File
       
   649