emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
branchRCL_3
changeset 16 b5fbb9b25d57
parent 14 b13141f05c3d
child 17 67369d1b217f
equal deleted inserted replaced
14:b13141f05c3d 16:b5fbb9b25d57
    62 #include "FreestyleEmailUiMailViewerConstants.h"
    62 #include "FreestyleEmailUiMailViewerConstants.h"
    63 #include "FSDelayedLoader.h"
    63 #include "FSDelayedLoader.h"
    64 #include "FreestyleMessageHeaderURL.h"
    64 #include "FreestyleMessageHeaderURL.h"
    65 #include "FreestyleEmailUiAknStatusIndicator.h"
    65 #include "FreestyleEmailUiAknStatusIndicator.h"
    66 #include <akntoolbar.h>
    66 #include <akntoolbar.h>
    67 // CONSTANTS
       
    68 // Zoom levels available on the UI
       
    69 const TInt KZoomLevels[] = { 75, 100, 125, 150 };
       
    70 const TInt KZoomLevelCount = sizeof( KZoomLevels ) / sizeof( TInt );
       
    71 
    67 
    72 CFsEmailUiHtmlViewerView* CFsEmailUiHtmlViewerView::NewL( 
    68 CFsEmailUiHtmlViewerView* CFsEmailUiHtmlViewerView::NewL( 
    73     CAlfEnv& aEnv,
    69     CAlfEnv& aEnv,
    74     CFreestyleEmailUiAppUi& aAppUi, 
    70     CFreestyleEmailUiAppUi& aAppUi, 
    75     CAlfControlGroup& aControlGroup )
    71     CAlfControlGroup& aControlGroup )
   290                 DeleteMailL();
   286                 DeleteMailL();
   291                 }
   287                 }
   292             break;
   288             break;
   293             case EFsEmailUiCmdZoomIn:
   289             case EFsEmailUiCmdZoomIn:
   294                 {
   290                 {
   295                 TUint zoomLevelIdx = ZoomLevelIndexL();
   291                 iContainer->ZoomInL();
   296                 SetZoomLevelIndexL( zoomLevelIdx + 1 );
       
   297                 }
   292                 }
   298             break;
   293             break;
   299             case EFsEmailUiCmdZoomOut:
   294             case EFsEmailUiCmdZoomOut:
   300                 {
   295                 {
   301                 TUint zoomLevelIdx = ZoomLevelIndexL();
   296                 iContainer->ZoomOutL();
   302                 SetZoomLevelIndexL( zoomLevelIdx - 1 );
       
   303                 }
   297                 }
   304             break;
   298             break;
   305             case EFsEmailUiCmdHelp:
   299             case EFsEmailUiCmdHelp:
   306                 {
   300                 {
   307                 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
   301                 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
   386                      }
   380                      }
   387                  }
   381                  }
   388                  break;
   382                  break;
   389             default:
   383             default:
   390                 {
   384                 {
       
   385                 /* -- pinch zoom only --
   391                 if ( aCommand >= EFsEmailUiCmdZoomSmall )
   386                 if ( aCommand >= EFsEmailUiCmdZoomSmall )
   392                     {
   387                     {
   393                     TUint zoomLevelIndex = aCommand - EFsEmailUiCmdZoomSmall;
   388                     iContainer->SetZoomLevelL( aCommand - EFsEmailUiCmdZoomSmall );
   394                     SetZoomLevelIndexL( zoomLevelIndex );
       
   395                     }
   389                     }
       
   390                 */
   396                 }
   391                 }
   397             break;
   392             break;
   398             }
   393             }
   399         }
   394         }
   400     TIMESTAMP( "Html viewer selected operation done" );    
   395     TIMESTAMP( "Html viewer selected operation done" );    
   951     {
   946     {
   952     FUNC_LOG;
   947     FUNC_LOG;
   953 
   948 
   954     if ( aResourceId == R_FSEMAILUI_HTMLVIEWER_MENUPANE )
   949     if ( aResourceId == R_FSEMAILUI_HTMLVIEWER_MENUPANE )
   955         {
   950         {
   956         
   951         // Pinch zoom only
       
   952         aMenuPane->SetItemDimmed( EFsEmailUiCmdZoomLevel, ETrue );
       
   953     
   957         if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
   954         if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
   958             {
   955             {
   959             // remove help support in pf5250
   956             // remove help support in pf5250
   960             aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
   957             aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
   961             }   
   958             }   
  1192     if ( !iMessage || iActivationData.iEmbeddedMessageMode )
  1189     if ( !iMessage || iActivationData.iEmbeddedMessageMode )
  1193         {
  1190         {
  1194         return;
  1191         return;
  1195         }
  1192         }
  1196 
  1193 
       
  1194     TFSMailMsgId currentMsgId = iMessage->GetMessageId();
       
  1195     if ( iLastDeletedMessageID == currentMsgId )
       
  1196         {
       
  1197         return;
       
  1198         }
       
  1199 
  1197     TInt reallyDelete( ETrue );
  1200     TInt reallyDelete( ETrue );
  1198 
  1201 
  1199     if ( iAppUi.GetCRHandler()->WarnBeforeDelete() && 
  1202     if ( iAppUi.GetCRHandler()->WarnBeforeDelete() && 
  1200          !aSilentDelete )
  1203          !aSilentDelete )
  1201         {
  1204         {
  1214             iContainer->ResetContent();
  1217             iContainer->ResetContent();
  1215             }
  1218             }
  1216         
  1219         
  1217         RArray<TFSMailMsgId> msgIds;
  1220         RArray<TFSMailMsgId> msgIds;
  1218         CleanupClosePushL( msgIds );
  1221         CleanupClosePushL( msgIds );
  1219         TFSMailMsgId currentMsgId = iMessage->GetMessageId();    
  1222             
  1220         msgIds.Append( currentMsgId );
  1223         msgIds.Append( currentMsgId );
  1221         TFSMailMsgId mailBox = iMessage->GetMailBoxId();
  1224         TFSMailMsgId mailBox = iMessage->GetMailBoxId();
  1222         TFSMailMsgId folderId = iMessage->GetFolderId();        
  1225         TFSMailMsgId folderId = iMessage->GetFolderId();        
  1223  
  1226  
  1224         //Get the id and check if there is a previous message available 
  1227         //Get the id and check if there is a previous message available 
  1229         TBool available = iAppUi.IsPreviousMsgAvailable( currentMsgId, 
  1232         TBool available = iAppUi.IsPreviousMsgAvailable( currentMsgId, 
  1230                                                    prevMsgId, 
  1233                                                    prevMsgId, 
  1231                                                    prevMsgFolderId );
  1234                                                    prevMsgFolderId );
  1232         
  1235         
  1233         //Delete the message
  1236         //Delete the message
       
  1237         iLastDeletedMessageID = iMessage->GetMessageId(); 
  1234         iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  1238         iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds );
  1235         CleanupStack::PopAndDestroy( &msgIds );
  1239         CleanupStack::PopAndDestroy( &msgIds );
  1236 
  1240 
  1237         // Notify appui of deleted mail item
  1241         // Notify appui of deleted mail item
  1238         SendEventToAppUiL( TFSEventMailDeletedFromViewer ); 
  1242         SendEventToAppUiL( TFSEventMailDeletedFromViewer ); 
  1239         
  1243         
  1240        
  1244        
  1241         
       
  1242         if ( iAppUi.CurrentActiveView()->Id() == HtmlViewerId )
  1245         if ( iAppUi.CurrentActiveView()->Id() == HtmlViewerId )
  1243             {   
  1246             {   
  1244             //Open the previous message or navigate back to list viewer
  1247             //Open the previous message or navigate back to list viewer
  1245             if ( available )
  1248             if ( available )
  1246                 {
  1249                 {
  1320         }
  1323         }
  1321     }
  1324     }
  1322 
  1325 
  1323 void CFsEmailUiHtmlViewerView::DynInitZoomMenuL( CEikMenuPane* aMenuPane )
  1326 void CFsEmailUiHtmlViewerView::DynInitZoomMenuL( CEikMenuPane* aMenuPane )
  1324     {
  1327     {
  1325     FUNC_LOG;
  1328     FUNC_LOG; 
  1326     TInt zoomLevelIdx = ZoomLevelIndexL();
  1329     /* -- Pinch zoom only --
       
  1330     TInt zoomLevelIdx = iContainer->ZoomLevelL();
  1327 
  1331 
  1328     // Set the radio button state to match current zoom level
  1332     // Set the radio button state to match current zoom level
  1329     if ( zoomLevelIdx >= 0 && zoomLevelIdx < KZoomLevelCount )
  1333     if ( zoomLevelIdx >= 0 && zoomLevelIdx < iContainer->MaxZoomLevel() )
  1330         {
  1334         {
  1331         TInt curZoomLevel = zoomLevelIdx + EFsEmailUiCmdZoomSmall;
  1335         TInt curZoomLevel = zoomLevelIdx + EFsEmailUiCmdZoomSmall;
  1332         aMenuPane->SetItemButtonState( curZoomLevel, EEikMenuItemSymbolOn );
  1336         aMenuPane->SetItemButtonState( curZoomLevel, EEikMenuItemSymbolOn );
  1333         }
  1337         }
  1334     }
  1338      */
  1335 
  1339     aMenuPane->SetItemDimmed( EFsEmailUiCmdZoomSmall, ETrue );
  1336 TInt CFsEmailUiHtmlViewerView::ZoomLevelIndexL()
  1340     aMenuPane->SetItemDimmed( EFsEmailUiCmdZoomNormal, ETrue );
  1337     {
  1341     aMenuPane->SetItemDimmed( EFsEmailUiCmdZoomLarge, ETrue );
  1338     FUNC_LOG;
  1342     aMenuPane->SetItemDimmed( EFsEmailUiCmdZoom150Percent, ETrue );
  1339     TInt zoomLevelIdx = iContainer->BrowserControlIf()->BrowserSettingL(
       
  1340                             TBrCtlDefs::ESettingsCurrentZoomLevelIndex );
       
  1341 
       
  1342     // Behaviour of zooming in Browser Control Interface is different in version 7.1
       
  1343     // than in previous versions and we need to support both. In older versions there
       
  1344     // are 4 preset zoom levels while version 7.1 can zoom to any percent.
       
  1345     RArray<TUint>* zoomLevels = iContainer->BrowserControlIf()->ZoomLevels();
       
  1346 
       
  1347     if ( !zoomLevels || !zoomLevels->Count() || ( *zoomLevels )[0] != KZoomLevels[0] )
       
  1348         {
       
  1349         // new browser:
       
  1350         // BrowserControlIf gives zoom level percentage insted of index to array
       
  1351         TBool found = EFalse;
       
  1352 
       
  1353         for ( TInt i = 0 ; i < KZoomLevelCount && !found ; ++i )
       
  1354             {
       
  1355             if ( zoomLevelIdx == KZoomLevels[i] )
       
  1356                 {
       
  1357                 zoomLevelIdx = i;
       
  1358                 found = ETrue;
       
  1359                 }
       
  1360             }
       
  1361 
       
  1362         if ( !found )
       
  1363             {
       
  1364             zoomLevelIdx = KErrNotFound;
       
  1365             }
       
  1366         }
       
  1367 
       
  1368     return zoomLevelIdx;
       
  1369     }
       
  1370 
       
  1371 void CFsEmailUiHtmlViewerView::SetZoomLevelIndexL( TInt aIndex )
       
  1372     {
       
  1373     FUNC_LOG;
       
  1374     TInt newValue = KMinTInt;
       
  1375 
       
  1376     // Behaviour of zooming in Browser Control Interface is different in version 7.1
       
  1377     // than in previous versions and we need to support both. In older versions there
       
  1378     // are 4 preset zoom levels while version 7.1 can zoom to any percent.
       
  1379     RArray<TUint>* zoomLevels = iContainer->BrowserControlIf()->ZoomLevels();
       
  1380 
       
  1381     if ( !zoomLevels || !zoomLevels->Count() || ( *zoomLevels )[0] != KZoomLevels[0] )
       
  1382         {
       
  1383         // new browser:
       
  1384         // BrowserControlIf takes zoom level percentage insted of index to array
       
  1385         if ( aIndex >= 0 && aIndex < KZoomLevelCount )
       
  1386             {
       
  1387             newValue = KZoomLevels[aIndex];
       
  1388             }
       
  1389         }
       
  1390     else
       
  1391         {
       
  1392         // old browser
       
  1393         newValue = aIndex;
       
  1394         }
       
  1395 
       
  1396     if ( newValue > KMinTInt )
       
  1397         {
       
  1398         iContainer->BrowserControlIf()->SetBrowserSettingL(
       
  1399             TBrCtlDefs::ESettingsCurrentZoomLevelIndex, newValue );
       
  1400         }
       
  1401     }
       
  1402 
       
  1403 // -----------------------------------------------------------------------------
       
  1404 // CFsEmailUiHtmlViewerView::RestoreZoomLevelL()
       
  1405 // -----------------------------------------------------------------------------
       
  1406 //
       
  1407 void CFsEmailUiHtmlViewerView::RestoreZoomLevelL()
       
  1408     {
       
  1409     FUNC_LOG;
       
  1410     SetZoomLevelIndexL( ZoomLevelIndexL() );
       
  1411     }
  1343     }
  1412 
  1344 
  1413 // -----------------------------------------------------------------------------
  1345 // -----------------------------------------------------------------------------
  1414 // CFsEmailUiHtmlViewerView::HandleEmailAddressCommandL()
  1346 // CFsEmailUiHtmlViewerView::HandleEmailAddressCommandL()
  1415 // -----------------------------------------------------------------------------
  1347 // -----------------------------------------------------------------------------
  1643     {
  1575     {
  1644     }
  1576     }
  1645 
  1577 
  1646 void CFsEmailUiHtmlViewerView::DownloadAttachmentL( const TAttachmentData& aAttachment )
  1578 void CFsEmailUiHtmlViewerView::DownloadAttachmentL( const TAttachmentData& aAttachment )
  1647     {
  1579     {
  1648     iAppUi.DownloadInfoMediator()->AddObserver( this, aAttachment.partData.iMessageId );
       
  1649     iAttachmentsListModel->StartDownloadL(aAttachment);
  1580     iAttachmentsListModel->StartDownloadL(aAttachment);
  1650     }
  1581     }
  1651 
  1582 
  1652 void CFsEmailUiHtmlViewerView::DownloadAllAttachmentsL()
  1583 void CFsEmailUiHtmlViewerView::DownloadAllAttachmentsL()
  1653     {
  1584     {
  1792                 break;
  1723                 break;
  1793             }
  1724             }
  1794         
  1725         
  1795         iContainer->ShowAttachmentDownloadStatusL( aEvent.iProgressStatus, *attachment );
  1726         iContainer->ShowAttachmentDownloadStatusL( aEvent.iProgressStatus, *attachment );
  1796         }
  1727         }
  1797     
       
  1798     if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete || 
       
  1799             aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled)
       
  1800         {
       
  1801         iAppUi.DownloadInfoMediator()->StopObserving( this, aPart.iMessageId );
       
  1802         }
       
  1803     }
  1728     }
  1804 
  1729 
  1805 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1730 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1806     {
  1731     {
  1807     FUNC_LOG;
  1732     FUNC_LOG;
  1979             // Change empty msk when moving to next
  1904             // Change empty msk when moving to next
  1980             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1905             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1981 
  1906 
  1982             iAppUi.MoveToNextMsgL( currentMsgId, nextMsgId );
  1907             iAppUi.MoveToNextMsgL( currentMsgId, nextMsgId );
  1983             // Next message is displayed in this view through doactivate, because view is re-activate by mail list
  1908             // Next message is displayed in this view through doactivate, because view is re-activate by mail list
  1984 
       
  1985             if ( iContainer )
       
  1986                 {
       
  1987 			    RestoreZoomLevelL();
       
  1988                 }
       
  1989             }
  1909             }
  1990         }
  1910         }
  1991     }
  1911     }
  1992 // -----------------------------------------------------------------------------
  1912 // -----------------------------------------------------------------------------
  1993 // CFsEmailUiHtmlViewerView::ShowPreviousMessageMenuInOptions
  1913 // CFsEmailUiHtmlViewerView::ShowPreviousMessageMenuInOptions
  2031             // Change empty msk when moving to previous
  1951             // Change empty msk when moving to previous
  2032             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1952             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  2033 
  1953 
  2034             iAppUi.MoveToPreviousMsgL( currentMsgId, prevMsgId );
  1954             iAppUi.MoveToPreviousMsgL( currentMsgId, prevMsgId );
  2035             // Previous message is displayed in this view through doactivate, because view is re-activate by mail list
  1955             // Previous message is displayed in this view through doactivate, because view is re-activate by mail list
  2036 
       
  2037             if ( iContainer )
       
  2038                 {
       
  2039                 RestoreZoomLevelL();
       
  2040                 }
       
  2041             }
  1956             }
  2042         }
  1957         }
  2043     }
  1958     }
  2044 
  1959 
  2045 
  1960