photosgallery/imgvwr/src/glxivwrappui.cpp
branchRCL_3
changeset 23 b023a8d2866a
parent 15 191387a8b767
equal deleted inserted replaced
21:f9e827349359 23:b023a8d2866a
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description:    AppUi class 
    14  * Description: Image Viewer AppUi class 
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 
    18 
    19 
    19 
    20 
    20 
    21 #include "glxivwrappui.h"
    21 #include "glxivwrappui.h"
    22 
    22 #include "glxivwrdocument.h"
    23 #include <avkon.hrh>
    23 
    24 #include <StringLoader.h>    
    24 #include <apgcli.h>
    25 #include <aknnotewrappers.h>
    25 #include <hal.h>
    26 #include <AknUtils.h>
    26 #include <oommonitorsession.h>
    27 #include <mpxviewutility.h>
    27 #include <mpxviewutility.h>
    28 #include <mpxcollectionutility.h>
       
    29 #include <mpxcollectionmessage.h>
       
    30 #include <mpxmessagegeneraldefs.h>
       
    31 #include <mpxcollectionpath.h>
    28 #include <mpxcollectionpath.h>
    32 
    29 
    33 #include <alf/alfenv.h>
    30 #include <glxmedialist.h>
    34 #include <akntoolbar.h>
       
    35 #include <glxgallery.hrh>
       
    36 
       
    37 #include <glxcollectionpluginimageviewer.hrh>
    31 #include <glxcollectionpluginimageviewer.hrh>
    38 #include <glxfiltergeneraldefs.h>
       
    39 #include <glxpanic.h>
       
    40 #include <glxuistd.h>
       
    41 #include <glxviewpluginuids.hrh>
    32 #include <glxviewpluginuids.hrh>
    42 #include <glxlog.h>
       
    43 #include <glxuiutility.h>
    33 #include <glxuiutility.h>
    44 #include <glxsettingsmodel.h>
       
    45 #include <glxcommandhandlers.hrh>
       
    46 #include <glxzoomstatepublisher.h>
    34 #include <glxzoomstatepublisher.h>
    47 #include <glxnavigationalstate.h>
    35 #include <glxnavigationalstate.h>
    48 #include <glxnavigationalstatedefs.h>
    36 #include <glxnavigationalstatedefs.h>
    49 #include <glxfullscreenviewplugin.hrh>
    37 #include <glxtracer.h>
       
    38 #include <glxlog.h>
    50 #include <glxivwr.rsg>
    39 #include <glxivwr.rsg>
    51 #include <AknGlobalNote.h>
    40 
    52 #include <hal.h>
    41 
    53 #include <hal_data.h>
       
    54 #include <oommonitorsession.h>
       
    55 #include <glxtracer.h>
       
    56 #include <glxuistd.h>
       
    57 #include <apgcli.h>
       
    58 
    42 
    59 //constants
    43 //constants
    60 const TInt KGlxFullThumbnailCount         = 1 ;       // 1 visible thumnail
    44 const TInt KGlxFullThumbnailCount         = 1 ;       // 1 visible thumnail
    61 #ifdef __MARM
    45 #ifdef __MARM
    62 const TInt KGlxMaxMegaPixelsSupportedByCamera = 5242880 ; // 5 MB
    46 const TInt KGlxMaxMegaPixelsSupportedByCamera = 5242880 ; // 5 MB
    65 #endif
    49 #endif
    66 const TInt KGlxMaxMemoryToDecodeCapturedPicture = 2 * KGlxMaxMegaPixelsSupportedByCamera ;
    50 const TInt KGlxMaxMemoryToDecodeCapturedPicture = 2 * KGlxMaxMegaPixelsSupportedByCamera ;
    67 const TInt KGlxMemoryForOOMFwk          = 1048576 ; // 1 MB
    51 const TInt KGlxMemoryForOOMFwk          = 1048576 ; // 1 MB
    68 const TInt KGlxThumbNailRepresentation    = 4;         // Thumbnail Representation; Could be 3 also 
    52 const TInt KGlxThumbNailRepresentation    = 4;         // Thumbnail Representation; Could be 3 also 
    69 
    53 
       
    54 // UID for the application, 
       
    55 // this should correspond to the uid defined in the mmp file
       
    56 static const TUid KUidGlxIvwrApp = {0x200104E7};
       
    57 
    70 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    71 // Constructor
    59 // Constructor
    72 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    73 //
    61 //
    74 CGlxIVwrAppUi::CGlxIVwrAppUi()
    62 CGlxIVwrAppUi::CGlxIVwrAppUi()
    83     {
    71     {
    84     TRACER("void CGlxIVwrAppUi::ConstructL()");
    72     TRACER("void CGlxIVwrAppUi::ConstructL()");
    85 
    73 
    86     // Enable Avkon skins.
    74     // Enable Avkon skins.
    87     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
    75     BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible );
       
    76 
    88     // Create navigational state 
    77     // Create navigational state 
    89     iNavigationalState = CGlxNavigationalState::InstanceL();
    78     iNavigationalState = CGlxNavigationalState::InstanceL();
    90 
       
    91     iNavigationalState->AddObserverL( *this );
    79     iNavigationalState->AddObserverL( *this );
    92 
       
    93     iNavigationalState->SetBackExitStatus(EFalse);
    80     iNavigationalState->SetBackExitStatus(EFalse);
    94 
    81 
    95     // Get an instance of view utility
    82     // Get an instance of view utility
    96     iViewUtility = MMPXViewUtility::UtilityL();
    83     iViewUtility = MMPXViewUtility::UtilityL();
    97 
    84 
    98     iUiUtility = CGlxUiUtility::UtilityL();
    85     iUiUtility = CGlxUiUtility::UtilityL();
    99     // Always start in default orientation
    86     // Always start in default orientation
   100     iUiUtility->SetAppOrientationL(EGlxOrientationDefault);
    87     iUiUtility->SetAppOrientationL(EGlxOrientationDefault);
       
    88 
   101     ReserveMemoryL(EEntryTypeStartUp);
    89     ReserveMemoryL(EEntryTypeStartUp);
       
    90     
   102     // publish zoom context, no zoom keys for now
    91     // publish zoom context, no zoom keys for now
   103     NGlxZoomStatePublisher::PublishStateL( EFalse );
    92     NGlxZoomStatePublisher::PublishStateL( EFalse );
   104     }
    93     }
   105 
    94 
   106 // -----------------------------------------------------------------------------
    95 // -----------------------------------------------------------------------------
   132 // -----------------------------------------------------------------------------
   121 // -----------------------------------------------------------------------------
   133 //
   122 //
   134 void CGlxIVwrAppUi::HandleCommandL(TInt aCommand)
   123 void CGlxIVwrAppUi::HandleCommandL(TInt aCommand)
   135     {
   124     {
   136     TRACER("void CGlxIVwrAppUi::HandleCommandL(TInt aCommand)");
   125     TRACER("void CGlxIVwrAppUi::HandleCommandL(TInt aCommand)");
   137     GLX_LOG_INFO1("PHOTOS LOGS: void CGlxIVwrAppUi::HandleCommandL(TInt aCommand = %d)",aCommand );
   126     GLX_LOG_INFO1("void CGlxIVwrAppUi::HandleCommandL(aCommand=%d)", aCommand );
   138     switch(aCommand)
   127     switch (aCommand)
   139         {
   128         {
   140         case EEikCmdExit:
   129         case EEikCmdExit:
   141             {
   130             {
   142             Exit();
   131             Exit();
   143             }
   132             }
   149             Exit();
   138             Exit();
   150             }
   139             }
   151             break;
   140             break;
   152 
   141 
   153         case EAknSoftkeyBack:
   142         case EAknSoftkeyBack:
       
   143             {
   154             iNavigationalState->ActivatePreviousViewL();
   144             iNavigationalState->ActivatePreviousViewL();
       
   145             }
   155             break;
   146             break;
   156 
   147 
   157         default:
   148         default:
   158             break;
   149             break;
   159         }
   150         }
   164 // ---------------------------------------------------------------------------
   155 // ---------------------------------------------------------------------------
   165 //
   156 //
   166 TBool CGlxIVwrAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,
   157 TBool CGlxIVwrAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,
   167         TFileName& /*aDocumentName*/, const TDesC8& /*aTail*/)
   158         TFileName& /*aDocumentName*/, const TDesC8& /*aTail*/)
   168     {
   159     {
   169     TRACER("TBool CGlxIVwrAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,TFileName& /*aDocumentName*/, const TDesC8& aTail)");
   160     TRACER("TBool CGlxIVwrAppUi::ProcessCommandParametersL()");
   170 
   161 
   171     // Bring the application to foreground, if not already
   162     // Bring the application to foreground, if not already
   172     if (0 != iEikonEnv->RootWin().OrdinalPosition())
   163     if (0 != iEikonEnv->RootWin().OrdinalPosition())
   173         {
   164         {
   174         iEikonEnv->RootWin().SetOrdinalPosition(0);
   165         iEikonEnv->RootWin().SetOrdinalPosition(0);
   187     TRACER("void CGlxIVwrAppUi::HandleNavigationalStateChangedL()");
   178     TRACER("void CGlxIVwrAppUi::HandleNavigationalStateChangedL()");
   188     // get current navigational state
   179     // get current navigational state
   189     CMPXCollectionPath* naviState = iNavigationalState->StateLC();
   180     CMPXCollectionPath* naviState = iNavigationalState->StateLC();
   190 
   181 
   191     // Case: Open photos in grid, go to filemanager via menu and open any image
   182     // Case: Open photos in grid, go to filemanager via menu and open any image
   192     if (naviState->Id() != TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid))
   183     if (naviState->Id() != TMPXItemId(
       
   184             KGlxCollectionPluginImageViewerImplementationUid))
   193         {
   185         {
   194         /*
   186         /*
   195          * This thread chk is added for EDDG-7UUC53. In this scenario we get EPathChanged from MPX.
   187          * This thread chk is added for EDDG-7UUC53. In this scenario we get EPathChanged from MPX.
   196          * That initiates a viewnavigational change from CGlxNavigationalStateImp  HandleCollectionMessageL()
   188          * That initiates a viewnavigational change from CGlxNavigationalStateImp  HandleCollectionMessageL()
   197          * In these types of scenarios we don't want a view switch. So ignoring the event. 
   189          * In these types of scenarios we don't want a view switch. So ignoring the event. 
   198          */
   190          */
   199         TApaTaskList taskList( iCoeEnv->WsSession() );
   191         TApaTaskList taskList(iCoeEnv->WsSession());
   200         TApaTask task = taskList.FindApp( TUid::Uid( KGlxGalleryApplicationUid ) );
   192         TApaTask task = taskList.FindApp(KUidGlxIvwrApp);
   201         TApaTask taskForeGround = taskList.FindByPos(0); // get fopreground app
   193         TApaTask taskForeGround = taskList.FindByPos(0); // get fopreground app
   202         if ( task.Exists() && task.ThreadId() != taskForeGround.ThreadId() )
   194         if (task.Exists() && task.ThreadId() != taskForeGround.ThreadId())
   203             {
   195             {
   204             GLX_LOG_INFO("CGlxIVwrAppUi ::HandleNavigationalStateChanged: Return ");
   196             GLX_LOG_INFO("CGlxIVwrAppUi ::HandleNavigationalStateChanged: Return ");
   205             return;
   197             return;
   206             }
   198             }
   207         }
   199         }
   208 
   200 
   209     CleanupStack::PopAndDestroy( naviState );
   201     CleanupStack::PopAndDestroy(naviState);
   210 
   202 
   211     if ( TUid::Null() != iStartupViewUid )
   203     if (TUid::Null() != iStartupViewUid)
   212         {
   204         {
   213         GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating startup view");
   205         GLX_LOG_INFO("CGlxIVwrAppUi::HandleNavigationalStateChanged:Activating startup view");
   214         // Activate startup view
   206         // Activate startup view
   215         iViewUtility->ActivateViewL( iStartupViewUid, NULL );
   207         iViewUtility->ActivateViewL(iStartupViewUid, NULL);
   216         iStartupViewUid = TUid::Null();
   208         iStartupViewUid = TUid::Null();
   217         }
   209         }
   218     else
   210     else
   219         {
   211         {
   220         GLX_LOG_INFO("CGlxAppUi::HandleNavigationalStateChanged: Activating view");
   212         GLX_LOG_INFO("CGlxIVwrAppUi::HandleNavigationalStateChanged:Activating view");
   221 
   213 
   222         // get ids for scoring a view
   214         // get ids for scoring a view
   223         RArray< TUid > scoringIds;
   215         RArray<TUid> scoringIds;
   224         CleanupClosePushL( scoringIds );
   216         CleanupClosePushL(scoringIds);
   225         GetViewScoringIdsL( scoringIds );
   217         GetViewScoringIdsL(scoringIds);
   226 
   218 
   227         GLX_LOG_INFO1( "CGlxIVwrAppUi::HandleNavigationalStateChanged: Uid count %d", scoringIds.Count());
   219         GLX_LOG_INFO1("CGlxIVwrAppUi::HandleNavigationalStateChanged:Uid count %d", scoringIds.Count());
   228         // let view utility to select the best view based on scoring ids
   220         // let view utility to select the best view based on scoring ids
   229         iViewUtility->ActivateViewL( scoringIds, NULL );
   221         iViewUtility->ActivateViewL(scoringIds, NULL);
   230 
   222 
   231         CleanupStack::PopAndDestroy( &scoringIds );
   223         CleanupStack::PopAndDestroy(&scoringIds);
   232         }
   224         }
   233     }
   225     }
   234 
   226 
   235 // ---------------------------------------------------------------------------
   227 // ---------------------------------------------------------------------------
   236 // Populate array with view scoring ids
   228 // Populate array with view scoring ids
   237 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   238 //
   230 //
   239 void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const
   231 void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const
   240 {
   232     {
   241 TRACER("void CGlxIVwrAppUi::GetViewScoringIdsL( RArray<TUid>& aIds ) const");
   233     TRACER("void CGlxIVwrAppUi::GetViewScoringIdsL()");
   242     CleanupClosePushL(aIds);
   234     CleanupClosePushL(aIds);
   243 aIds.Reset(); // For maintenance safety
   235     aIds.Reset(); // For maintenance safety
   244 
   236 
   245 // get current navigational state
   237     // get current navigational state
   246 CMPXCollectionPath* naviState = iNavigationalState->StateLC();
   238     CMPXCollectionPath* naviState = iNavigationalState->StateLC();
   247 
   239 
   248 // no if check in needed here ,it makes the aapui aware of the list view depth
   240     // no if check in needed here ,it makes the aapui aware of the list view depth
   249 // to be removed.added by gopa   
   241     // to be removed.added by gopa   
   250 if ( naviState->Levels() >= 1)
   242     if (naviState->Levels() >= 1)
   251     {
   243         {
   252         if (iNavigationalState->ViewingMode()
   244         if (iNavigationalState->ViewingMode()
   253                 == NGlxNavigationalState::EBrowse)
   245                 == NGlxNavigationalState::EBrowse)
   254         {
   246             {
   255         // For image viewer collection, goto view mode
   247             // For image viewer collection, goto view mode
   256             if (naviState->Id() == TMPXItemId(
   248             if (naviState->Id() == TMPXItemId(
   257                     KGlxCollectionPluginImageViewerImplementationUid))
   249                     KGlxCollectionPluginImageViewerImplementationUid))
   258             {
   250                 {
   259             aIds.AppendL( TUid::Uid(  KGlxViewingModeView ) );
   251                 aIds.AppendL(TUid::Uid(KGlxViewingModeView));
       
   252                 }
       
   253             else
       
   254                 {
       
   255                 aIds.AppendL(TUid::Uid(KGlxViewingModeBrowse));
       
   256                 }
   260             }
   257             }
   261         else
   258         else
   262             {
   259             {
   263             aIds.AppendL( TUid::Uid(  KGlxViewingModeBrowse ) );
   260             aIds.AppendL(TUid::Uid(KGlxViewingModeView));
   264             }
   261             }
   265         } 
   262         }
   266     else 
   263 
   267         {
   264     if (TUid::Null() != GetViewScoringIdForCollectionPlugin(*naviState))
   268         aIds.AppendL( TUid::Uid(  KGlxViewingModeView ) );
   265         {
   269         }                 
   266         // add scoring id for collection plugin
   270     }
   267         aIds.AppendL(GetViewScoringIdForCollectionPlugin(*naviState));
   271 
   268         }
   272 if( TUid::Null() != GetViewScoringIdForCollectionPlugin( *naviState ) )
   269 
   273     {
   270     if (TUid::Null() != ViewScoringIdForNaviStateDepth(*naviState))
   274     // add scoring id for collection plugin
   271         {
   275     aIds.AppendL( GetViewScoringIdForCollectionPlugin( *naviState ) );
   272         // add scoring id for depth in the ui hierarchy
   276     }
   273         aIds.AppendL(ViewScoringIdForNaviStateDepth(*naviState));
   277 
   274         }
   278 if( TUid::Null() != ViewScoringIdForNaviStateDepth( *naviState ) )
   275 
   279     {
   276     CleanupStack::PopAndDestroy(naviState);
   280     // add scoring id for depth in the ui hierarchy
       
   281     aIds.AppendL( ViewScoringIdForNaviStateDepth( *naviState ) );
       
   282     }
       
   283 
       
   284 CleanupStack::PopAndDestroy( naviState );
       
   285     CleanupStack::Pop(&aIds);
   277     CleanupStack::Pop(&aIds);
   286 }
   278     }
   287 // ---------------------------------------------------------------------------
   279 
   288 // Handles the foreground events
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 void CGlxIVwrAppUi::HandleForegroundEventL( TBool aForeground )
       
   292     {
       
   293     TRACER("void CGlxIVwrAppUi::HandleForegroundEventL( TBool aForeground )");
       
   294 
       
   295     // first let base class handle it so that we dont break anything
       
   296     CAknViewAppUi::HandleForegroundEventL( aForeground );
       
   297 
       
   298     }
       
   299 // ---------------------------------------------------------------------------
   280 // ---------------------------------------------------------------------------
   300 // Return scoring id for collection plugin
   281 // Return scoring id for collection plugin
   301 // ---------------------------------------------------------------------------
   282 // ---------------------------------------------------------------------------
   302 //
   283 //
   303 TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPlugin( const CMPXCollectionPath& aNaviState ) const
   284 TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPlugin(
   304 {
   285         const CMPXCollectionPath& aNaviState) const
   305 TRACER("TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL( const CMPXCollectionPath& aNaviState ) const");
   286     {
   306 
   287     TRACER("TUid CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL()");
   307 GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL: Depth %d", aNaviState.Levels() );
   288 
   308 // score view based on collection plugin if not on root level
   289     GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForCollectionPluginL:Depth %d", aNaviState.Levels() );
   309 if ( aNaviState.Levels() )
   290     // score view based on collection plugin if not on root level
   310     {
   291     if (aNaviState.Levels())
   311     return TUid::Uid( aNaviState.Id( 0 ) );
   292         {
   312     }
   293         return TUid::Uid(aNaviState.Id(0));
   313 // return null as id to be ignored in scoring
   294         }
   314 return TUid::Null(); 
   295     // return null as id to be ignored in scoring
   315 }
   296     return TUid::Null();
       
   297     }
   316 
   298 
   317 // ---------------------------------------------------------------------------
   299 // ---------------------------------------------------------------------------
   318 // Return scoring id for depth
   300 // Return scoring id for depth
   319 // ---------------------------------------------------------------------------
   301 // ---------------------------------------------------------------------------
   320 //
   302 //
   321 TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepth( const CMPXCollectionPath& aNaviState ) const
   303 TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepth(
   322 {
   304         const CMPXCollectionPath& aNaviState) const
   323 TRACER("TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL( const CMPXCollectionPath& aNaviState ) const");
   305     {
   324 GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: Level %d", aNaviState.Levels() );
   306     TRACER("TUid CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL()");
   325 
   307     GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: Level %d",aNaviState.Levels() );
   326 switch ( aNaviState.Levels() )
   308 
   327     {
   309     switch (aNaviState.Levels())
   328     case 0:
   310         {
   329 
   311         case 0:
   330         GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: \
   312 
   331                 Depth  case 0 %x", TUid::Uid( KGlxDepthOne ) );
   313             GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL:Depth  case 0 %x", TUid::Uid( KGlxDepthOne ) );
   332         return TUid::Uid( KGlxDepthOne );
   314             return TUid::Uid(KGlxDepthOne);
   333 
   315 
   334     case 1:
   316         case 1:
   335 
   317 
   336         GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL: \
   318             GLX_LOG_INFO1( "CGlxIVwrAppUi::ViewScoringIdForNaviStateDepthL:Depth case 1 %x", TUid::Uid( KGlxDepthTwo ) );
   337                 Depth case 1 %x", TUid::Uid( KGlxDepthTwo ) );
   319             return TUid::Uid(KGlxDepthTwo);
   338         return TUid::Uid( KGlxDepthTwo );
   320 
   339 
   321         case 2:
   340 
   322 
   341     case 2:
   323             GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForUiHieararchyDepthL:Depth case 2 %x", TUid::Uid( KGlxDepthThree ) );
   342 
   324             return TUid::Uid(KGlxDepthThree);
   343         GLX_LOG_INFO1( "CGlxIVwrAppUi::GetViewScoringIdForUiHieararchyDepthL: \
   325 
   344                 Depth case 2 %x", TUid::Uid( KGlxDepthThree ) );
   326         default:
   345         return TUid::Uid( KGlxDepthThree );
   327             GLX_LOG_WARNING( "CGlxIVwrAppUi::GetViewScoringIdsL:Navigational state deeper than supported" );
   346 
   328             // return null as an id to be ignored in scoring
   347     default:
   329             return TUid::Null();
   348         GLX_LOG_WARNING( "CGlxIVwrAppUi::GetViewScoringIdsL: Navigational state deeper than supported" );
   330         }
   349         // return null as an id to be ignored in scoring
   331     }
   350         return TUid::Null(); 
       
   351     }
       
   352 }
       
   353 
   332 
   354 // ---------------------------------------------------------------------------
   333 // ---------------------------------------------------------------------------
   355 // HandleOpenFileL
   334 // HandleOpenFileL
   356 // ---------------------------------------------------------------------------
   335 // ---------------------------------------------------------------------------
   357 //
   336 //
   367 
   346 
   368 // ---------------------------------------------------------------------------
   347 // ---------------------------------------------------------------------------
   369 // OOMRequestFreeMemoryL
   348 // OOMRequestFreeMemoryL
   370 // ---------------------------------------------------------------------------
   349 // ---------------------------------------------------------------------------
   371 //
   350 //
   372 TInt CGlxIVwrAppUi::OOMRequestFreeMemoryL( TInt aBytesRequested)
   351 TInt CGlxIVwrAppUi::OOMRequestFreeMemoryL(TInt aBytesRequested)
   373     {
   352     {
   374     TRACER("TInt CGlxIVwrAppUi::OOMRequestFreeMemoryL( TInt aBytesRequested)");
   353     TRACER("TInt CGlxIVwrAppUi::OOMRequestFreeMemoryL(TInt aBytesRequested)");
   375     GLX_LOG_INFO1("CGlxIVwrAppUi::OOMRequestFreeMemoryL() aBytesRequested=%d",
   354     GLX_LOG_INFO1("CGlxIVwrAppUi::OOMRequestFreeMemoryL() aBytesRequested=%d",aBytesRequested);
   376                                                         aBytesRequested);
       
   377 
   355 
   378     ROomMonitorSession oomMonitor;
   356     ROomMonitorSession oomMonitor;
   379     User::LeaveIfError( oomMonitor.Connect() );
   357     User::LeaveIfError( oomMonitor.Connect() );
   380     // No leaving code after this point, so no need to use cleanup stack
   358     // No leaving code after this point, so no need to use cleanup stack
   381     // for oomMonitor
   359     // for oomMonitor
   400     TRACER("void CGlxIVwrAppUi::ReserveMemoryL(TInt aCriticalMemoryRequired)");
   378     TRACER("void CGlxIVwrAppUi::ReserveMemoryL(TInt aCriticalMemoryRequired)");
   401 
   379 
   402     TInt memoryLeft = 0;
   380     TInt memoryLeft = 0;
   403     TInt error = KErrNone ; 
   381     TInt error = KErrNone ; 
   404     HAL::Get( HALData::EMemoryRAMFree, memoryLeft );
   382     HAL::Get( HALData::EMemoryRAMFree, memoryLeft );
   405     GLX_LOG_INFO2("CGlxIVwrAppUi::ReserveMemoryL() - aCriticalMemoryRequired=%d, memoryLeft=%d",
   383     GLX_LOG_INFO2("CGlxIVwrAppUi::ReserveMemoryL() - aCriticalMemoryRequired=%d, memoryLeft=%d", aCriticalMemoryRequired, memoryLeft);
   406                                        aCriticalMemoryRequired, memoryLeft);
       
   407     if ( aCriticalMemoryRequired > memoryLeft )
   384     if ( aCriticalMemoryRequired > memoryLeft )
   408         {
   385         {
   409         // Request for critical memory required 
   386         // Request for critical memory required 
   410         error = OOMRequestFreeMemoryL( aCriticalMemoryRequired);
   387         error = OOMRequestFreeMemoryL( aCriticalMemoryRequired);
   411         GLX_LOG_INFO1("CGlxIVwrAppUi::ReserveMemoryL() - OOMRequestFreeMemoryL() error=%d", error);
   388         GLX_LOG_INFO1("CGlxIVwrAppUi::ReserveMemoryL() - OOMRequestFreeMemoryL() error=%d", error);
   426         {
   403         {
   427         // This is Bare Minimum Required Memory for Photos to start 
   404         // This is Bare Minimum Required Memory for Photos to start 
   428         // For Framework to work and to do the on-the-fly decoding 
   405         // For Framework to work and to do the on-the-fly decoding 
   429         // for the just captured picture = KGlxMemoryForOOMFwk + KGlxMaxMemoryToDecodeCapturedPicture
   406         // for the just captured picture = KGlxMemoryForOOMFwk + KGlxMaxMemoryToDecodeCapturedPicture
   430         // For FullScreen to Work Number of Thumbnail(s) * Width * Height * Representation
   407         // For FullScreen to Work Number of Thumbnail(s) * Width * Height * Representation
   431         criticalRamMemory =  KGlxMemoryForOOMFwk + KGlxMaxMemoryToDecodeCapturedPicture + 
   408         criticalRamMemory = KGlxMemoryForOOMFwk
   432                                              (KGlxFullThumbnailCount *
   409                 + KGlxMaxMemoryToDecodeCapturedPicture
   433                                               displaySize.iWidth * displaySize.iHeight * 
   410                 + (KGlxFullThumbnailCount * displaySize.iWidth
   434                                               KGlxThumbNailRepresentation );
   411                         * displaySize.iHeight * KGlxThumbNailRepresentation);
   435         
   412 
   436         GLX_LOG_INFO1("CGlxIVwrAppUi::RamRequiredInBytesL(EEntryTypeStartUp): criticalRamMemory=%d",
   413         GLX_LOG_INFO1("CGlxIVwrAppUi::RamRequiredInBytesL(EEntryTypeStartUp):criticalRamMemory=%d", criticalRamMemory);
   437                                                                             criticalRamMemory);
       
   438         }
   414         }
   439     else
   415     else
   440         {
   416         {
   441         GLX_LOG_INFO("CGlxIVwrAppUi::RamRequiredInBytesL(): Photos Already Running");
   417         GLX_LOG_INFO("CGlxIVwrAppUi::RamRequiredInBytesL():Viewer Already Running");
   442         }
   418         }
   443  
   419  
   444     return criticalRamMemory;
   420     return criticalRamMemory;
   445     }
   421     }
   446 
   422 
   455     TInt error = ReserveMemoryL(RamRequiredInBytesL(aType));
   431     TInt error = ReserveMemoryL(RamRequiredInBytesL(aType));
   456     GLX_LOG_INFO1("CGlxIVwrAppUi::ReserveMemoryL() error=%d", error);
   432     GLX_LOG_INFO1("CGlxIVwrAppUi::ReserveMemoryL() error=%d", error);
   457     
   433     
   458     if (KErrNoMemory == error)
   434     if (KErrNoMemory == error)
   459         {
   435         {
   460         GLX_LOG_INFO("CGlxIVwrAppUi::ReserveMemoryL(): LEAVE with KErrNoMemory ");
   436         GLX_LOG_INFO("CGlxIVwrAppUi::ReserveMemoryL():LEAVE with KErrNoMemory");
   461         User::Leave(KErrNoMemory);
   437         User::Leave(KErrNoMemory);
   462         }
   438         }
   463     }
   439     }
   464 
   440 
   465 // ---------------------------------------------------------------------------
   441 // ---------------------------------------------------------------------------
   466 // HandleApplicationSpecificEventL
   442 // HandleApplicationSpecificEventL
   467 // 
   443 // 
   468 // ---------------------------------------------------------------------------
   444 // ---------------------------------------------------------------------------
   469 //
   445 //
   470 
   446 void CGlxIVwrAppUi::HandleApplicationSpecificEventL(TInt aEventType, 
   471 void CGlxIVwrAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent)
   447         const TWsEvent& aWsEvent)
   472     {
   448     {
   473     TRACER("CGlxIVwrAppUi::HandleApplicationSpecificEventL");
   449     TRACER("CGlxIVwrAppUi::HandleApplicationSpecificEventL");
   474     CAknViewAppUi::HandleApplicationSpecificEventL(aEventType,aWsEvent);
   450     CAknViewAppUi::HandleApplicationSpecificEventL(aEventType,aWsEvent);
   475     if(aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
   451     if(aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
   476         {
   452         {
   482 // CloseImgVwr
   458 // CloseImgVwr
   483 // -----------------------------------------------------------------------------
   459 // -----------------------------------------------------------------------------
   484 //
   460 //
   485 void CGlxIVwrAppUi::CloseImgVwr()
   461 void CGlxIVwrAppUi::CloseImgVwr()
   486     {
   462     {
   487     TRACER("CGlxNsAppUi::CloseImgVwr()");
   463     TRACER("CGlxIVwrAppUi::CloseImgVwr()");
   488     iUiUtility->SetViewNavigationDirection(EGlxNavigationBackwards);
   464     iUiUtility->SetViewNavigationDirection(EGlxNavigationBackwards);
   489     iUiUtility->SetExitingState(ETrue);         
   465     iUiUtility->SetExitingState(ETrue);         
   490     }
   466     }
   491 
   467 
       
   468 // ----------------------------------------------------------------------------
       
   469 // CGlxIVwrAppUi::OpenFileL
       
   470 // This is called by framework when application is already open in background
       
   471 // and user open other file in eg. File Browse.
       
   472 // New file to been shown is passed via aFileName.
       
   473 // ----------------------------------------------------------------------------
       
   474 //
       
   475 void CGlxIVwrAppUi::OpenFileL(const TDesC& aFileName)
       
   476     {
       
   477     TRACER("CGlxIVwrAppUi::OpenFileL()");
       
   478     GLX_LOG_URI("CGlxIVwrAppUi::OpenFileL(%S)", &aFileName);
       
   479 
       
   480     // File changed. Open new file with documents OpenFileL method.
       
   481     Document()->OpenFileL(EFalse, aFileName, iEikonEnv->FsSession());
       
   482 
       
   483     GLX_DEBUG1("CGlxIVwrAppUi::OpenFileL() *** File Changed *** ");
       
   484     MGlxCache* cacheManager = MGlxCache::InstanceL();
       
   485     CleanupClosePushL(*cacheManager);
       
   486 
       
   487     CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   488     CleanupStack::PushL(path);
       
   489     path->AppendL(KGlxCollectionPluginImageViewerImplementationUid);
       
   490 
       
   491     MGlxMediaList* mediaList = MGlxMediaList::InstanceL(*path);
       
   492     CleanupClosePushL(*mediaList);
       
   493 
       
   494     if (mediaList->Count() > 0)
       
   495         {
       
   496         GLX_DEBUG1("CGlxIVwrAppUi::OpenFileL() - Cleanup & Refresh Media!");
       
   497         cacheManager->ForceCleanupMedia(mediaList->IdSpaceId(0),
       
   498                 mediaList->Item(0).Id());
       
   499         cacheManager->RefreshL();
       
   500         }
       
   501 
       
   502     CleanupStack::PopAndDestroy(mediaList);
       
   503     CleanupStack::PopAndDestroy(path);
       
   504     CleanupStack::PopAndDestroy(cacheManager);
       
   505     }