emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
changeset 1 12c456ceeff2
parent 0 8466d47a6819
child 2 5253a20d2a1e
equal deleted inserted replaced
0:8466d47a6819 1:12c456ceeff2
   127     BaseConstructL( R_FSEMAILUI_HTML_VIEW );
   127     BaseConstructL( R_FSEMAILUI_HTML_VIEW );
   128     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
   128     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityLow );
   129     iOpenMessages = new (ELeave) CStack<CFSMailMessage, ETrue>();
   129     iOpenMessages = new (ELeave) CStack<CFSMailMessage, ETrue>();
   130     iEmbeddedMessages = new (ELeave) CStack<CFSMailMessage, EFalse>();
   130     iEmbeddedMessages = new (ELeave) CStack<CFSMailMessage, EFalse>();
   131     iNextOrPrevMessageSelected = EFalse; 
   131     iNextOrPrevMessageSelected = EFalse; 
       
   132     iForwardingMessage = EFalse;
   132     }
   133     }
   133 
   134 
   134 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   135 // CFsEmailUiHtmlViewerView::Id()
   136 // CFsEmailUiHtmlViewerView::Id()
   136 // Returns View's ID.
   137 // Returns View's ID.
   288                         {
   289                         {
   289                         HideContainer();
   290                         HideContainer();
   290                         iContainer->ResetContent();
   291                         iContainer->ResetContent();
   291                         }
   292                         }
   292 
   293 
       
   294                     iForwardingMessage = ETrue;
   293                     iAppUi.LaunchEditorL( KEditorCmdForward, params );
   295                     iAppUi.LaunchEditorL( KEditorCmdForward, params );
   294                     }
   296                     }
   295                 }
   297                 }
   296             break;
   298             break;
   297             case EFsEmailUiCmdActionsDelete:
   299             case EFsEmailUiCmdActionsDelete:
   645                                 
   647                                 
   646                 }
   648                 }
   647             else{
   649             else{
   648                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );         
   650                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );         
   649                 }                
   651                 }                
   650                 
   652             
   651     
   653     
   652             TRAPD( error, LoadContentFromMailMessageL( iOpenMessages->Head() ) );
   654             TRAPD( error, LoadContentFromMailMessageL( iOpenMessages->Head() ) );
   653             if ( error == KErrNotFound || error == KErrInUse || error == KErrLocked )
   655             if ( error == KErrNotFound || error == KErrInUse || error == KErrLocked )
   654                 {
   656                 {
   655                 bodypartNotFound = ETrue;
   657                 bodypartNotFound = ETrue;
   701                 {
   703                 {
   702                 HBufC* emailAddress = address->GetEmailAddress().AllocLC();
   704                 HBufC* emailAddress = address->GetEmailAddress().AllocLC();
   703                 iAppUi.SetTitlePaneTextL(*emailAddress);
   705                 iAppUi.SetTitlePaneTextL(*emailAddress);
   704                 CleanupStack::PopAndDestroy(emailAddress);
   706                 CleanupStack::PopAndDestroy(emailAddress);
   705                 }
   707                 }
   706             CleanupStack::PopAndDestroy( displayName );      
   708         CleanupStack::PopAndDestroy( displayName );
   707             }
   709             }
   708         }
   710         }
   709     
   711     
   710     if ( !openedInMrViewer )
   712     if ( !openedInMrViewer )
   711         {
   713         {
   734                 StartFetchingMessagePartL( *iMessage, type );
   736                 StartFetchingMessagePartL( *iMessage, type );
   735                 }
   737                 }
   736             }
   738             }
   737        }
   739        }
   738     iNextOrPrevMessageSelected = EFalse;
   740     iNextOrPrevMessageSelected = EFalse;
       
   741     iForwardingMessage = EFalse;
   739     }
   742     }
   740 
   743 
   741 // -----------------------------------------------------------------------------
   744 // -----------------------------------------------------------------------------
   742 // CFsEmailUiHtmlViewerView::OfferToolbarEventL
   745 // CFsEmailUiHtmlViewerView::OfferToolbarEventL
   743 // -----------------------------------------------------------------------------
   746 // -----------------------------------------------------------------------------
   812 // -----------------------------------------------------------------------------
   815 // -----------------------------------------------------------------------------
   813 //
   816 //
   814 void CFsEmailUiHtmlViewerView::ChildDoDeactivate()
   817 void CFsEmailUiHtmlViewerView::ChildDoDeactivate()
   815     {
   818     {
   816     FUNC_LOG;
   819     FUNC_LOG;
   817     CancelFetchings();
   820     // Don't cancel fetching the message parts when forwarding the message:
   818    
   821     // it would also cancel the fetchings initiated by the forwarding,
       
   822     // causing the forwarding to abort.
       
   823     if ( !iForwardingMessage )
       
   824         {
       
   825         CancelFetchings();
       
   826         }
       
   827 
   819     if ( iContainer )
   828     if ( iContainer )
   820         {
   829         {
   821         HideContainer();
   830         HideContainer();
   822         iContainer->ResetContent();
   831         iContainer->ResetContent();
   823         iAppUi.RemoveFromStack(iContainer);
   832         iAppUi.RemoveFromStack(iContainer);
  1034             respondStatus, *iMessage, *this );
  1043             respondStatus, *iMessage, *this );
  1035         }
  1044         }
  1036     }
  1045     }
  1037 
  1046 
  1038 
  1047 
  1039 void CFsEmailUiHtmlViewerView::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ )
  1048 void CFsEmailUiHtmlViewerView::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType )
  1040     {
  1049     {
  1041     FUNC_LOG;
  1050     FUNC_LOG;
  1042 
  1051     
  1043     if ( iContainer )
  1052     if ( iContainer )
  1044         {
  1053         {
  1045         iContainer->SetRect( ClientRect() );
  1054         iContainer->HandleResourceChange( aType );
  1046         }
  1055         }
  1047     }
  1056     }
  1048 
  1057 
  1049 void CFsEmailUiHtmlViewerView::LoadContentFromFileL( const TDesC& aFileName )
  1058 void CFsEmailUiHtmlViewerView::LoadContentFromFileL( const TDesC& aFileName )
  1050     {
  1059     {
  1110         if ( iContainer )
  1119         if ( iContainer )
  1111             {
  1120             {
  1112             HideContainer();
  1121             HideContainer();
  1113             iContainer->ResetContent();
  1122             iContainer->ResetContent();
  1114             }
  1123             }
  1115 
  1124         
  1116         RArray<TFSMailMsgId> msgIds;
  1125         RArray<TFSMailMsgId> msgIds;
  1117         CleanupClosePushL( msgIds );
  1126         CleanupClosePushL( msgIds );
  1118         msgIds.Append( iMessage->GetMessageId() );
  1127         TFSMailMsgId currentMsgId = iMessage->GetMessageId();    
       
  1128         msgIds.Append( currentMsgId );
  1119         TFSMailMsgId mailBox = iMessage->GetMailBoxId();
  1129         TFSMailMsgId mailBox = iMessage->GetMailBoxId();
  1120         TFSMailMsgId folderId = iMessage->GetFolderId();
  1130         TFSMailMsgId folderId = iMessage->GetFolderId();        
       
  1131  
       
  1132 		//Get the id and check if there is a previous message available 
       
  1133 		TFSMailMsgId prevMsgId;
       
  1134 		TFSMailMsgId prevMsgFolderId;  
       
  1135 		
       
  1136 		//Get the previous message if it exists
       
  1137 		TBool available = iAppUi.IsPreviousMsgAvailable( currentMsgId, 
       
  1138 												   prevMsgId, 
       
  1139                         		                   prevMsgFolderId );
       
  1140         
       
  1141         //Delete the message
  1121         iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  1142         iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  1122         CleanupStack::PopAndDestroy( &msgIds );
  1143         CleanupStack::PopAndDestroy( &msgIds );
  1123 
  1144 
  1124         // Notify appui of deleted mail item
  1145         // Notify appui of deleted mail item
  1125         SendEventToAppUiL( TFSEventMailDeleted );
  1146         SendEventToAppUiL( TFSEventMailDeleted ); 
  1126 
  1147         
  1127         if ( iAppUi.CurrentActiveView()->Id() == HtmlViewerId )
  1148         if ( iAppUi.CurrentActiveView()->Id() == HtmlViewerId )
  1128             {
  1149 			{	
  1129             NavigateBackL();
  1150 			//Open the previous message or navigate back to list viewer
  1130             }
  1151 			if ( available )
       
  1152 				{
       
  1153 				iAppUi.MoveToPreviousMsgAfterDeleteL( prevMsgId );				
       
  1154 				}	
       
  1155 			else
       
  1156 				{
       
  1157 				ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
       
  1158 				NavigateBackL();
       
  1159 				}
       
  1160 			//inform user that mail is deleted	
       
  1161 			TFsEmailUiUtility::ShowGlobalInfoNoteL( R_FREESTYLE_EMAIL_MAIL_DELETED );
       
  1162 			}        
  1131         }
  1163         }
  1132     }
  1164     }
  1133 
  1165 
  1134 // ---------------------------------------------------------------------------
  1166 // ---------------------------------------------------------------------------
  1135 // HandleMailBoxEventL
  1167 // HandleMailBoxEventL
  1138 //
  1170 //
  1139 void CFsEmailUiHtmlViewerView::HandleMailBoxEventL( TFSMailEvent aEvent,
  1171 void CFsEmailUiHtmlViewerView::HandleMailBoxEventL( TFSMailEvent aEvent,
  1140         TFSMailMsgId aMailbox, TAny* aParam1, TAny* /*aParam2*/, TAny* /*aParam3*/ )
  1172         TFSMailMsgId aMailbox, TAny* aParam1, TAny* /*aParam2*/, TAny* /*aParam3*/ )
  1141     {
  1173     {
  1142     FUNC_LOG;
  1174     FUNC_LOG;
  1143 
       
  1144     if ( /*iFirstStartCompleted &&*/ iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() &&
  1175     if ( /*iFirstStartCompleted &&*/ iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() &&
  1145                                      aEvent == TFSEventMailDeleted && aParam1 ) // Safety, in list events that only concern active mailbox are handled
  1176                                      aEvent == TFSEventMailDeleted && aParam1 ) // Safety, in list events that only concern active mailbox are handled
  1146         {
  1177         {
  1147         TFSMailMsgId curMsgId = iMessage->GetMessageId();
  1178         TFSMailMsgId curMsgId = iMessage->GetMessageId();       
  1148         RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>( aParam1 );
  1179         RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>( aParam1 );
  1149         // <cmail> break-keyword should be used only in switch-clauses
  1180         // <cmail> break-keyword should be used only in switch-clauses
  1150         TBool cont = ETrue;
  1181         TBool cont = ETrue;
  1151 
  1182 
  1152         for ( TInt i = 0 ; i < removedEntries->Count() && cont; i++ )
  1183         for ( TInt i = 0 ; i < removedEntries->Count() && cont; i++ )
  1153             {
  1184             {
  1154             if ( curMsgId == ( *removedEntries )[i] )
  1185             if ( curMsgId == ( *removedEntries )[i] )
  1155                 {
  1186                 {                
  1156                 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
       
  1157                 NavigateBackL();
       
  1158                 cont = EFalse;
  1187                 cont = EFalse;
  1159                 }
  1188                 }            
  1160             }
  1189             } 
  1161         }
  1190         }
       
  1191      
  1162     if (iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() && aEvent == TFSEventNewMail)
  1192     if (iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() && aEvent == TFSEventNewMail)
  1163         {
  1193         {
  1164         UpdateNaviPaneL();
  1194         UpdateNaviPaneL();
  1165         }
  1195         }
  1166     // </cmail>
  1196     // </cmail>
  1387     {
  1417     {
  1388     // this method assumes that remote lookup is available with current plugin.
  1418     // this method assumes that remote lookup is available with current plugin.
  1389     HBufC* textData = aEmailAddress.AllocLC();
  1419     HBufC* textData = aEmailAddress.AllocLC();
  1390     CFSMailBox* mailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( iMessage->GetMailBoxId() );
  1420     CFSMailBox* mailBox = iAppUi.GetMailClient()->GetMailBoxByUidL( iMessage->GetMailBoxId() );
  1391     CleanupStack::PushL( mailBox );
  1421     CleanupStack::PushL( mailBox );
       
  1422   
       
  1423     //UI options Delete and Actions dimmed in Remote Lookup.
       
  1424     const TInt resourceId(ToolbarResourceId());
       
  1425     RArray<TInt> dimmedItems;
       
  1426     CleanupClosePushL(dimmedItems);
       
  1427     GetInitiallyDimmedItemsL(resourceId, dimmedItems); // get the currently dimmed buttons
       
  1428     
       
  1429     SetToolbarItemDimmed( EFsEmailUiTbCmdActions, ETrue);
       
  1430     SetToolbarItemDimmed( EFsEmailUiTbCmdDelete, ETrue);
       
  1431         
  1392     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupWithQueryL( *mailBox, *textData );
  1432     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupWithQueryL( *mailBox, *textData );
       
  1433     
       
  1434     SetToolbarItemDimmed( EFsEmailUiTbCmdActions, EFalse);
       
  1435     SetToolbarItemDimmed( EFsEmailUiTbCmdDelete, EFalse);
       
  1436    
       
  1437     for (TInt i = 0; i < dimmedItems.Count(); i++) // restore the buttons
       
  1438         {
       
  1439         SetToolbarItemDimmed(dimmedItems[i], ETrue);
       
  1440         }
       
  1441     CleanupStack::PopAndDestroy(); // dimmedItems.Close()
  1393     CleanupStack::PopAndDestroy( mailBox );
  1442     CleanupStack::PopAndDestroy( mailBox );
  1394     CleanupStack::PopAndDestroy( textData );
  1443     CleanupStack::PopAndDestroy( textData );
  1395     }
  1444     }
  1396 
  1445 
  1397 // -----------------------------------------------------------------------------
  1446 // -----------------------------------------------------------------------------
  2457             }
  2506             }
  2458             break;
  2507             break;
  2459         case EESMRCmdDownloadAttachment:
  2508         case EESMRCmdDownloadAttachment:
  2460         case EESMRCmdDownloadAllAttachments:
  2509         case EESMRCmdDownloadAllAttachments:
  2461             {
  2510             {
       
  2511             if(iAttachmentsListModel == NULL)
       
  2512                 {
       
  2513                 iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
       
  2514                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
       
  2515                 }
  2462             // Check that message has attachments to display
  2516             // Check that message has attachments to display
  2463             if ( messagePtr->IsFlagSet( EFSMsgFlag_Attachments ) )
  2517             if ( messagePtr->IsFlagSet( EFSMsgFlag_Attachments ) )
  2464                 {
  2518                 {
  2465                 iOpResult.iResultCode = KErrNone;
  2519                 iOpResult.iResultCode = KErrNone;
  2466                 //StartDowloadingAttachmentsL();
  2520                 DownloadAllAttachmentsL();
  2467                 CompletePendingMrCommand();
  2521                 CompletePendingMrCommand();
  2468                 }
  2522                 }
  2469             }
  2523             }
  2470             break;
  2524             break;
  2471         case EESMRCmdSaveAttachment:
  2525         case EESMRCmdSaveAttachment:
  2472         case EESMRCmdSaveAllAttachments:
  2526         case EESMRCmdSaveAllAttachments:
  2473             {
  2527             {
       
  2528             if(iAttachmentsListModel == NULL)
       
  2529                 {
       
  2530                 iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
       
  2531                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
       
  2532                 }
  2474             // Check that message has attachments to display
  2533             // Check that message has attachments to display
  2475             if ( messagePtr->IsFlagSet( EFSMsgFlag_Attachments ) )
  2534             if ( messagePtr->IsFlagSet( EFSMsgFlag_Attachments ) )
  2476                 {
  2535                 {
  2477                 iOpResult.iResultCode = KErrNone;
  2536                 iOpResult.iResultCode = KErrNone;
  2478                 SaveAllAttachmentsL();
  2537                 SaveAllAttachmentsL();
  2775         // Check if there's next and previous message available, and set
  2834         // Check if there's next and previous message available, and set
  2776         // the navipane arrows accordingly
  2835         // the navipane arrows accordingly
  2777         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  2836         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  2778         TFSMailMsgId tmpMsgId;
  2837         TFSMailMsgId tmpMsgId;
  2779         TFSMailMsgId tmpMsgFolderId;
  2838         TFSMailMsgId tmpMsgFolderId;
       
  2839         CAknNavigationDecorator::TScrollButton nextButton = CAknNavigationDecorator::ERightButton;
       
  2840         CAknNavigationDecorator::TScrollButton prevButton = CAknNavigationDecorator::ELeftButton;
       
  2841         if (AknLayoutUtils::LayoutMirrored())
       
  2842             {
       
  2843             nextButton = CAknNavigationDecorator::ELeftButton;
       
  2844             prevButton = CAknNavigationDecorator::ERightButton;
       
  2845             }
  2780         if ( iAppUi.IsNextMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ) )
  2846         if ( iAppUi.IsNextMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ) )
  2781             {
  2847             {
  2782             naviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, EFalse );
  2848             naviDecorator->SetScrollButtonDimmed( nextButton, EFalse );
  2783             }
  2849             }
  2784         else
  2850         else
  2785             {
  2851             {
  2786             naviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ERightButton, ETrue );
  2852             naviDecorator->SetScrollButtonDimmed( nextButton, ETrue );
  2787             }
  2853             }
  2788         if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ) )
  2854         if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ) )
  2789             {
  2855             {
  2790             naviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, EFalse );
  2856             naviDecorator->SetScrollButtonDimmed( prevButton, EFalse );
  2791             }
  2857             }
  2792         else
  2858         else
  2793             {
  2859             {
  2794             naviDecorator->SetScrollButtonDimmed( CAknNavigationDecorator::ELeftButton, ETrue );
  2860             naviDecorator->SetScrollButtonDimmed( prevButton, ETrue );
  2795             }
  2861             }
  2796 
  2862 
  2797         // Set this view's navipane to the top of the navipane control stack
  2863         // Set this view's navipane to the top of the navipane control stack
  2798         CAknNavigationControlContainer* naviPaneContainer =
  2864         CAknNavigationControlContainer* naviPaneContainer =
  2799             static_cast<CAknNavigationControlContainer*>(
  2865             static_cast<CAknNavigationControlContainer*>(
  2845     CAknNavigationDecorator* naviDecorator = iAppUi.NaviDecoratorL( MailViewerId );
  2911     CAknNavigationDecorator* naviDecorator = iAppUi.NaviDecoratorL( MailViewerId );
  2846     if ( naviDecorator )
  2912     if ( naviDecorator )
  2847         {
  2913         {
  2848         naviDecorator->SetNaviDecoratorObserver( NULL );
  2914         naviDecorator->SetNaviDecoratorObserver( NULL );
  2849         }
  2915         }
  2850     if( aEventID == MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow )
  2916     MAknNaviDecoratorObserver::TAknNaviDecoratorEvents nextButton = MAknNaviDecoratorObserver::EAknNaviDecoratorEventRightTabArrow;
       
  2917     if (AknLayoutUtils::LayoutMirrored())
       
  2918         {
       
  2919         nextButton = MAknNaviDecoratorObserver::EAknNaviDecoratorEventLeftTabArrow;
       
  2920         }
       
  2921     if( aEventID == nextButton )
  2851         {
  2922         {
  2852         ShowNextMessageL();
  2923         ShowNextMessageL();
  2853         }
  2924         }
  2854     else
  2925     else
  2855         {
  2926         {