photosgallery/gallery/src/glxappui.cpp
branchRCL_3
changeset 75 01504893d9cb
parent 64 34937ec34dac
equal deleted inserted replaced
68:5b238bc8ffb6 75:01504893d9cb
    58 #include <AknGlobalNote.h>
    58 #include <AknGlobalNote.h>
    59 #include <hal.h>
    59 #include <hal.h>
    60 #include <hal_data.h>
    60 #include <hal_data.h>
    61 #include <oommonitorsession.h>
    61 #include <oommonitorsession.h>
    62 #include <glxtracer.h>
    62 #include <glxtracer.h>
    63 #include <glxmedialist.h>
       
    64 #include <glxmedialistiterator.h>
       
    65 #include <glxattributecontext.h>
       
    66 #include <glxattributeretriever.h>
       
    67 
    63 
    68 //OOM
    64 //OOM
    69 #include <oommonitorplugin.h>
    65 #include <oommonitorplugin.h>
    70 #include <oommonitorsession.h>
    66 #include <oommonitorsession.h>
    71 #include <glxuistd.h>
    67 #include <glxuistd.h>
   121     // Always start in default orientation
   117     // Always start in default orientation
   122     iUiUtility->SetAppOrientationL(EGlxOrientationDefault);
   118     iUiUtility->SetAppOrientationL(EGlxOrientationDefault);
   123     ReserveMemoryL(EEntryTypeStartUp);
   119     ReserveMemoryL(EEntryTypeStartUp);
   124     // publish zoom context, no zoom keys for now
   120     // publish zoom context, no zoom keys for now
   125     NGlxZoomStatePublisher::PublishStateL( EFalse );
   121     NGlxZoomStatePublisher::PublishStateL( EFalse );
       
   122     iEndKeyPressed = EFalse;
   126     iStateChangeRequested = EFalse;
   123     iStateChangeRequested = EFalse;
   127     }
   124     }
   128 
   125 
   129 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
   130 // Destructor
   127 // Destructor
   131 // -----------------------------------------------------------------------------
   128 // -----------------------------------------------------------------------------
   132 //
   129 //
   133 CGlxAppUi::~CGlxAppUi()
   130 CGlxAppUi::~CGlxAppUi()
   134     {
   131     {
   135     TRACER("CGlxAppUi::~CGlxAppUi()");
   132     TRACER("CGlxAppUi::~CGlxAppUi()");
       
   133 	iEndKeyPressed = EFalse;
   136     if ( iNavigationalState )
   134     if ( iNavigationalState )
   137         {
   135         {
   138         iNavigationalState->RemoveObserver(*this);
   136         iNavigationalState->RemoveObserver(*this);
   139         iNavigationalState->Close();
   137         iNavigationalState->Close();
   140         }
   138         }
   243     TRACER("TBool CGlxAppUi::ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail)");
   241     TRACER("TBool CGlxAppUi::ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail)");
   244     
   242     
   245     TRAPD(err, HandleActivationMessageL(aCommand, aDocumentName, aTail));
   243     TRAPD(err, HandleActivationMessageL(aCommand, aDocumentName, aTail));
   246     if ( KErrNone != err )
   244     if ( KErrNone != err )
   247         {
   245         {
   248         NavigateToMainListL();
   246         // Open navigational state at root level
       
   247         CMPXCollectionPath* newState = CMPXCollectionPath::NewL();
       
   248         CleanupStack::PushL( newState );
       
   249         iNavigationalState->NavigateToL( *newState );
       
   250         iStateChangeRequested = ETrue;
       
   251         CleanupStack::PopAndDestroy( newState );
   249         }
   252         }
   250 
   253 
   251     //Start a timer to check for thr IAD update after 60 Secs.
   254     //Start a timer to check for thr IAD update after 60 Secs.
   252     //Only when any view is launched in photos.
   255     //Only when any view is launched in photos.
   253     if(!iPeriodic)
   256     if(!iPeriodic)
   448     delete iActivationParam;
   451     delete iActivationParam;
   449     iActivationParam = NULL;
   452     iActivationParam = NULL;
   450 
   453 
   451     if (aData.Length() == 0 )
   454     if (aData.Length() == 0 )
   452         {
   455         {
   453         NavigateToMainListL();
   456         // Open navigational state at root level
       
   457         CMPXCollectionPath* newState = CMPXCollectionPath::NewL();
       
   458         CleanupStack::PushL(newState);
       
   459         iNavigationalState->NavigateToL(*newState);
       
   460         iStateChangeRequested = ETrue;
       
   461         CleanupStack::PopAndDestroy(newState);
   454         }
   462         }
   455     else
   463     else
   456         {
   464         {
   457         GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL(aData)");        
   465         GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL(aData)");        
   458         HandleActivationMessageL( aData );
   466         HandleActivationMessageL( aData );
   459         }
   467         }
   460     }
       
   461 
       
   462 // ---------------------------------------------------------------------------
       
   463 // NavigateToMainListL
       
   464 // ---------------------------------------------------------------------------
       
   465 //
       
   466 void CGlxAppUi::NavigateToMainListL()
       
   467     {
       
   468     TRACER("void CGlxAppUi::NavigateToMainListL()");
       
   469     // Open navigational state at root level
       
   470     CMPXCollectionPath* collPath = CMPXCollectionPath::NewL();
       
   471     CleanupStack::PushL(collPath);
       
   472     iNavigationalState->NavigateToL(*collPath);
       
   473     iStateChangeRequested = ETrue;
       
   474     CleanupStack::PopAndDestroy(collPath);
       
   475     }
   468     }
   476 
   469 
   477 // ---------------------------------------------------------------------------
   470 // ---------------------------------------------------------------------------
   478 // HandleActivationMessageL
   471 // HandleActivationMessageL
   479 // ---------------------------------------------------------------------------
   472 // ---------------------------------------------------------------------------
   490 
   483 
   491     TUid msgUid;
   484     TUid msgUid;
   492     RDesReadStream stream(aData);
   485     RDesReadStream stream(aData);
   493     CleanupClosePushL(stream);
   486     CleanupClosePushL(stream);
   494     stream >> msgUid;
   487     stream >> msgUid;
   495 
   488     
   496     switch (msgUid.iUid)
   489     switch ( msgUid.iUid )
   497         {
   490         {
   498         case KGlxActivationCmdShowLastModified:
   491         case KGlxActivationCmdShowLastModified:
   499         case KGlxActivationCameraAlbum:
   492         case KGlxActivationCameraAlbum:
   500         case KGlxActivationCmdShowAll:
   493         case KGlxActivationCmdShowAll:
   501             {
   494             {
   502             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: Creating Screen Clearer");
   495             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: Creating Screen Clearer");
   503             iUiUtility->DisplayScreenClearerL();
   496             iUiUtility->DisplayScreenClearerL();
   504 
       
   505             HBufC8* activationParam = HBufC8::NewLC(KMaxUidName);
   497             HBufC8* activationParam = HBufC8::NewLC(KMaxUidName);
   506             // While harvesting is in progress, activate the Camera Album 
       
   507             // instead of All grid. However, do not change the activation
       
   508             // parameter as it is used within photos.
       
   509             activationParam->Des().AppendNum(KGlxActivationCmdShowAll);
   498             activationParam->Des().AppendNum(KGlxActivationCmdShowAll);
   510             SetActivationParamL(*activationParam);
   499             SetActivationParamL(*activationParam);
   511             CleanupStack::PopAndDestroy(activationParam);
   500             CleanupStack::PopAndDestroy(activationParam);
   512 
   501             
       
   502             // Go to All grid view
       
   503             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: All Grid View");
   513             // Send the command to reset the view
   504             // Send the command to reset the view
   514             ProcessCommandL(EGlxCmdResetView);
   505             ProcessCommandL(EGlxCmdResetView);
   515             iNavigationalState->SetBackExitStatus(ETrue);
   506             iNavigationalState->SetBackExitStatus(ETrue);
   516             
   507             path->AppendL(KGlxCollectionPluginAllImplementationUid);
   517             // 1)While harvesting is going on, TNM publishes itemsleft 'PSkey' value.
       
   518             //      After harvesting is over, itemsleft count will be 0.
       
   519             // 2)Tnm sets the value to KErrNotReady until it gets the total count while harvesting.
       
   520             //      TNM doesn't update the key value in batches. It updates @ a single shot. 
       
   521             //      so need to check against KErrNotReady also.
       
   522             if (iUiUtility->GetItemsLeftCount() == KErrNotReady
       
   523                     || iUiUtility->GetItemsLeftCount())
       
   524                 {
       
   525                 // Go to Camera Album grid view
       
   526                 GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: Camera Album Grid View");
       
   527                 path->AppendL(KGlxCollectionPluginAlbumsImplementationUid);
       
   528                 MGlxMediaList* mediaList = MGlxMediaList::InstanceL(*path);
       
   529                 CleanupClosePushL(*mediaList);
       
   530 
       
   531                 TGlxSequentialIterator iter;
       
   532                 CGlxAttributeContext* attributeContext =
       
   533                         new (ELeave) CGlxAttributeContext(&iter);
       
   534                 CleanupStack::PushL(attributeContext);
       
   535                 iter.SetRange(1);
       
   536                 attributeContext->AddAttributeL(KMPXMediaGeneralTitle);
       
   537                 mediaList->AddContextL(attributeContext,
       
   538                         KGlxFetchContextPriorityBlocking);
       
   539                 TRAPD(err, GlxAttributeRetriever::RetrieveL(
       
   540                         *attributeContext, *mediaList, EFalse));
       
   541                 if (err != KErrNone)
       
   542                     {
       
   543                     mediaList->RemoveContext(attributeContext);
       
   544                     User::Leave( err);
       
   545                     }
       
   546                 TInt count = mediaList->Count();
       
   547                 GLX_LOG_INFO1("CGlxAppUi::HandleActivationMessageL() count=%d", count);
       
   548                 __ASSERT_DEBUG(count != 0, Panic(EGlxPanicRequiredItemNotFound));
       
   549 
       
   550                 path->AppendL(TMPXItemId(mediaList->Item(0).Id().Value()));
       
   551 
       
   552                 mediaList->RemoveContext(attributeContext);
       
   553                 CleanupStack::PopAndDestroy(attributeContext);
       
   554                 CleanupStack::PopAndDestroy(mediaList);
       
   555                 }
       
   556             else
       
   557                 {
       
   558                 // Go to All grid view
       
   559                 GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: All Grid View");
       
   560                 path->AppendL(KGlxCollectionPluginAllImplementationUid);
       
   561                 }
       
   562             }
   508             }
   563             break;
   509             break;
   564 
   510 
   565         default:
   511         default:
   566             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: unknown command");
   512             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: unknown command");
   567             User::Leave(KErrNotSupported);
   513             User::Leave(KErrNotSupported);
   568         }
   514         }
   569     CleanupStack::PopAndDestroy(&stream);
   515     CleanupStack::PopAndDestroy(&stream);
   570     iNavigationalState->SetStartingLevel(path->Levels());
   516     iNavigationalState->SetStartingLevel(path->Levels());
   571     iNavigationalState->NavigateToL(*path);
   517     iNavigationalState->NavigateToL( *path );
   572     iStateChangeRequested = ETrue;
   518     iStateChangeRequested = ETrue;
   573     CleanupStack::PopAndDestroy(path);
   519     CleanupStack::PopAndDestroy(path);
   574 
   520     
   575     // Introduced to fix bug EMJN-78GH6N. 
   521     // Introduced to fix bug EMJN-78GH6N. 
   576     if (0 != iEikonEnv->RootWin().OrdinalPosition())
   522     if (0 != iEikonEnv->RootWin().OrdinalPosition())
   577         {
   523         {
   578         iEikonEnv->RootWin().SetOrdinalPosition(0);
   524         iEikonEnv->RootWin().SetOrdinalPosition(0);
   579         }
   525         }
   701 // ---------------------------------------------------------------------------
   647 // ---------------------------------------------------------------------------
   702 // HandleApplicationSpecificEventL
   648 // HandleApplicationSpecificEventL
   703 // Handle OOM events.
   649 // Handle OOM events.
   704 // ---------------------------------------------------------------------------
   650 // ---------------------------------------------------------------------------
   705 //
   651 //
   706 void CGlxAppUi::HandleApplicationSpecificEventL(TInt aEventType,
   652 
   707         const TWsEvent& aWsEvent)
   653 void CGlxAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent)
   708     {
   654 {
   709     TRACER("CGlxAppUi::HandleApplicationSpecificEventL");
   655 TRACER("CGlxAppUi::HandleApplicationSpecificEventL");
   710     GLX_LOG_INFO1("CGlxAppUi::HandleApplicationSpecificEventL() aEventType=%d", aEventType);
   656 CAknViewAppUi::HandleApplicationSpecificEventL(aEventType,aWsEvent);
   711 
   657 	if(aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
   712     CAknViewAppUi::HandleApplicationSpecificEventL(aEventType, aWsEvent);
   658 		{
   713     if (aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
   659 		/**
   714         {
   660 		* Making the flag etrue ensures that it will not call LaunchMmViewL in handlecommandl while 
   715         ClosePhotosL();
   661 		* red key is pressed. Otherwise it will launch matrix menu, not idle screen. 
   716         }
   662 		*/
   717 
   663 		iEndKeyPressed = ETrue;
   718     switch (aEventType)
   664 		ClosePhotosL();
   719         {
   665 		}
   720         case KAppOomMonitor_FreeRam:
   666 switch(aEventType)	
   721             {
   667 	{
   722             StartCleanupL();
   668 	case KAppOomMonitor_FreeRam:
   723             }
   669 		{
   724             break;
   670 		StartCleanupL();				
   725         case KAppOomMonitor_MemoryGood:
   671 		}
   726             {
   672 		break;
   727             StopCleanupL();
   673 	case KAppOomMonitor_MemoryGood:
   728             }
   674 		{
   729             break;
   675 		StopCleanupL();
   730         default:
   676 		}
   731             break;
   677 		break;
   732         }
   678 	default:
   733     }
   679 		break;
       
   680 	}
       
   681 }
   734 
   682 
   735 // ---------------------------------------------------------------------------
   683 // ---------------------------------------------------------------------------
   736 // StartCleanup
   684 // StartCleanup
   737 // Initiate cleanup from cache manager on low memory event
   685 // Initiate cleanup from cache manager on low memory event
   738 // ---------------------------------------------------------------------------
   686 // ---------------------------------------------------------------------------
   739 //
   687 //
   740 void CGlxAppUi::StartCleanupL()
   688 void CGlxAppUi::StartCleanupL()
   741     {
   689     {
   742     TRACER("CGlxAppUi::StartCleanupL");
       
   743     MGlxCache* cacheManager = MGlxCache::InstanceL();
   690     MGlxCache* cacheManager = MGlxCache::InstanceL();
   744     cacheManager->ReleaseRAML();
   691     cacheManager->ReleaseRAML();
   745     cacheManager->Close();
   692     cacheManager->Close();
   746     }
   693     }
   747 
   694 
   750 // Cancel cache cleanup on memory good event
   697 // Cancel cache cleanup on memory good event
   751 // ---------------------------------------------------------------------------
   698 // ---------------------------------------------------------------------------
   752 //
   699 //
   753 void CGlxAppUi::StopCleanupL()
   700 void CGlxAppUi::StopCleanupL()
   754     {
   701     {
   755     TRACER("CGlxAppUi::StopCleanupL");
       
   756     MGlxCache* cacheManager = MGlxCache::InstanceL();
   702     MGlxCache* cacheManager = MGlxCache::InstanceL();
   757     cacheManager->StopRAMReleaseL();
   703     cacheManager->StopRAMReleaseL();
   758     cacheManager->Close();
   704     cacheManager->Close();
   759     }
   705     }
   760 
   706