photosgallery/gallery/src/glxappui.cpp
branchRCL_3
changeset 64 34937ec34dac
parent 60 5b3385a43d68
child 75 01504893d9cb
equal deleted inserted replaced
60:5b3385a43d68 64:34937ec34dac
    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>
    63 
    67 
    64 //OOM
    68 //OOM
    65 #include <oommonitorplugin.h>
    69 #include <oommonitorplugin.h>
    66 #include <oommonitorsession.h>
    70 #include <oommonitorsession.h>
    67 #include <glxuistd.h>
    71 #include <glxuistd.h>
   117     // Always start in default orientation
   121     // Always start in default orientation
   118     iUiUtility->SetAppOrientationL(EGlxOrientationDefault);
   122     iUiUtility->SetAppOrientationL(EGlxOrientationDefault);
   119     ReserveMemoryL(EEntryTypeStartUp);
   123     ReserveMemoryL(EEntryTypeStartUp);
   120     // publish zoom context, no zoom keys for now
   124     // publish zoom context, no zoom keys for now
   121     NGlxZoomStatePublisher::PublishStateL( EFalse );
   125     NGlxZoomStatePublisher::PublishStateL( EFalse );
   122     iEndKeyPressed = EFalse;
       
   123     iStateChangeRequested = EFalse;
   126     iStateChangeRequested = EFalse;
   124     }
   127     }
   125 
   128 
   126 // -----------------------------------------------------------------------------
   129 // -----------------------------------------------------------------------------
   127 // Destructor
   130 // Destructor
   128 // -----------------------------------------------------------------------------
   131 // -----------------------------------------------------------------------------
   129 //
   132 //
   130 CGlxAppUi::~CGlxAppUi()
   133 CGlxAppUi::~CGlxAppUi()
   131     {
   134     {
   132     TRACER("CGlxAppUi::~CGlxAppUi()");
   135     TRACER("CGlxAppUi::~CGlxAppUi()");
   133 	iEndKeyPressed = EFalse;
       
   134     if ( iNavigationalState )
   136     if ( iNavigationalState )
   135         {
   137         {
   136         iNavigationalState->RemoveObserver(*this);
   138         iNavigationalState->RemoveObserver(*this);
   137         iNavigationalState->Close();
   139         iNavigationalState->Close();
   138         }
   140         }
   241     TRACER("TBool CGlxAppUi::ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail)");
   243     TRACER("TBool CGlxAppUi::ProcessCommandParametersL(TApaCommand aCommand, TFileName& aDocumentName, const TDesC8& aTail)");
   242     
   244     
   243     TRAPD(err, HandleActivationMessageL(aCommand, aDocumentName, aTail));
   245     TRAPD(err, HandleActivationMessageL(aCommand, aDocumentName, aTail));
   244     if ( KErrNone != err )
   246     if ( KErrNone != err )
   245         {
   247         {
   246         // Open navigational state at root level
   248         NavigateToMainListL();
   247         CMPXCollectionPath* newState = CMPXCollectionPath::NewL();
       
   248         CleanupStack::PushL( newState );
       
   249         iNavigationalState->NavigateToL( *newState );
       
   250         iStateChangeRequested = ETrue;
       
   251         CleanupStack::PopAndDestroy( newState );
       
   252         }
   249         }
   253 
   250 
   254     //Start a timer to check for thr IAD update after 60 Secs.
   251     //Start a timer to check for thr IAD update after 60 Secs.
   255     //Only when any view is launched in photos.
   252     //Only when any view is launched in photos.
   256     if(!iPeriodic)
   253     if(!iPeriodic)
   451     delete iActivationParam;
   448     delete iActivationParam;
   452     iActivationParam = NULL;
   449     iActivationParam = NULL;
   453 
   450 
   454     if (aData.Length() == 0 )
   451     if (aData.Length() == 0 )
   455         {
   452         {
   456         // Open navigational state at root level
   453         NavigateToMainListL();
   457         CMPXCollectionPath* newState = CMPXCollectionPath::NewL();
       
   458         CleanupStack::PushL(newState);
       
   459         iNavigationalState->NavigateToL(*newState);
       
   460         iStateChangeRequested = ETrue;
       
   461         CleanupStack::PopAndDestroy(newState);
       
   462         }
   454         }
   463     else
   455     else
   464         {
   456         {
   465         GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL(aData)");        
   457         GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL(aData)");        
   466         HandleActivationMessageL( aData );
   458         HandleActivationMessageL( aData );
   467         }
   459         }
       
   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);
   468     }
   475     }
   469 
   476 
   470 // ---------------------------------------------------------------------------
   477 // ---------------------------------------------------------------------------
   471 // HandleActivationMessageL
   478 // HandleActivationMessageL
   472 // ---------------------------------------------------------------------------
   479 // ---------------------------------------------------------------------------
   483 
   490 
   484     TUid msgUid;
   491     TUid msgUid;
   485     RDesReadStream stream(aData);
   492     RDesReadStream stream(aData);
   486     CleanupClosePushL(stream);
   493     CleanupClosePushL(stream);
   487     stream >> msgUid;
   494     stream >> msgUid;
   488     
   495 
   489     switch ( msgUid.iUid )
   496     switch (msgUid.iUid)
   490         {
   497         {
   491         case KGlxActivationCmdShowLastModified:
   498         case KGlxActivationCmdShowLastModified:
   492         case KGlxActivationCameraAlbum:
   499         case KGlxActivationCameraAlbum:
   493         case KGlxActivationCmdShowAll:
   500         case KGlxActivationCmdShowAll:
   494             {
   501             {
   495             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: Creating Screen Clearer");
   502             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: Creating Screen Clearer");
   496             iUiUtility->DisplayScreenClearerL();
   503             iUiUtility->DisplayScreenClearerL();
       
   504 
   497             HBufC8* activationParam = HBufC8::NewLC(KMaxUidName);
   505             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.
   498             activationParam->Des().AppendNum(KGlxActivationCmdShowAll);
   509             activationParam->Des().AppendNum(KGlxActivationCmdShowAll);
   499             SetActivationParamL(*activationParam);
   510             SetActivationParamL(*activationParam);
   500             CleanupStack::PopAndDestroy(activationParam);
   511             CleanupStack::PopAndDestroy(activationParam);
   501             
   512 
   502             // Go to All grid view
       
   503             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: All Grid View");
       
   504             // Send the command to reset the view
   513             // Send the command to reset the view
   505             ProcessCommandL(EGlxCmdResetView);
   514             ProcessCommandL(EGlxCmdResetView);
   506             iNavigationalState->SetBackExitStatus(ETrue);
   515             iNavigationalState->SetBackExitStatus(ETrue);
   507             path->AppendL(KGlxCollectionPluginAllImplementationUid);
   516             
       
   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                 }
   508             }
   562             }
   509             break;
   563             break;
   510 
   564 
   511         default:
   565         default:
   512             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: unknown command");
   566             GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: unknown command");
   513             User::Leave(KErrNotSupported);
   567             User::Leave(KErrNotSupported);
   514         }
   568         }
   515     CleanupStack::PopAndDestroy(&stream);
   569     CleanupStack::PopAndDestroy(&stream);
   516     iNavigationalState->SetStartingLevel(path->Levels());
   570     iNavigationalState->SetStartingLevel(path->Levels());
   517     iNavigationalState->NavigateToL( *path );
   571     iNavigationalState->NavigateToL(*path);
   518     iStateChangeRequested = ETrue;
   572     iStateChangeRequested = ETrue;
   519     CleanupStack::PopAndDestroy(path);
   573     CleanupStack::PopAndDestroy(path);
   520     
   574 
   521     // Introduced to fix bug EMJN-78GH6N. 
   575     // Introduced to fix bug EMJN-78GH6N. 
   522     if (0 != iEikonEnv->RootWin().OrdinalPosition())
   576     if (0 != iEikonEnv->RootWin().OrdinalPosition())
   523         {
   577         {
   524         iEikonEnv->RootWin().SetOrdinalPosition(0);
   578         iEikonEnv->RootWin().SetOrdinalPosition(0);
   525         }
   579         }
   647 // ---------------------------------------------------------------------------
   701 // ---------------------------------------------------------------------------
   648 // HandleApplicationSpecificEventL
   702 // HandleApplicationSpecificEventL
   649 // Handle OOM events.
   703 // Handle OOM events.
   650 // ---------------------------------------------------------------------------
   704 // ---------------------------------------------------------------------------
   651 //
   705 //
   652 
   706 void CGlxAppUi::HandleApplicationSpecificEventL(TInt aEventType,
   653 void CGlxAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent)
   707         const TWsEvent& aWsEvent)
   654 {
   708     {
   655 TRACER("CGlxAppUi::HandleApplicationSpecificEventL");
   709     TRACER("CGlxAppUi::HandleApplicationSpecificEventL");
   656 CAknViewAppUi::HandleApplicationSpecificEventL(aEventType,aWsEvent);
   710     GLX_LOG_INFO1("CGlxAppUi::HandleApplicationSpecificEventL() aEventType=%d", aEventType);
   657 	if(aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
   711 
   658 		{
   712     CAknViewAppUi::HandleApplicationSpecificEventL(aEventType, aWsEvent);
   659 		/**
   713     if (aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
   660 		* Making the flag etrue ensures that it will not call LaunchMmViewL in handlecommandl while 
   714         {
   661 		* red key is pressed. Otherwise it will launch matrix menu, not idle screen. 
   715         ClosePhotosL();
   662 		*/
   716         }
   663 		iEndKeyPressed = ETrue;
   717 
   664 		ClosePhotosL();
   718     switch (aEventType)
   665 		}
   719         {
   666 switch(aEventType)	
   720         case KAppOomMonitor_FreeRam:
   667 	{
   721             {
   668 	case KAppOomMonitor_FreeRam:
   722             StartCleanupL();
   669 		{
   723             }
   670 		StartCleanupL();				
   724             break;
   671 		}
   725         case KAppOomMonitor_MemoryGood:
   672 		break;
   726             {
   673 	case KAppOomMonitor_MemoryGood:
   727             StopCleanupL();
   674 		{
   728             }
   675 		StopCleanupL();
   729             break;
   676 		}
   730         default:
   677 		break;
   731             break;
   678 	default:
   732         }
   679 		break;
   733     }
   680 	}
       
   681 }
       
   682 
   734 
   683 // ---------------------------------------------------------------------------
   735 // ---------------------------------------------------------------------------
   684 // StartCleanup
   736 // StartCleanup
   685 // Initiate cleanup from cache manager on low memory event
   737 // Initiate cleanup from cache manager on low memory event
   686 // ---------------------------------------------------------------------------
   738 // ---------------------------------------------------------------------------
   687 //
   739 //
   688 void CGlxAppUi::StartCleanupL()
   740 void CGlxAppUi::StartCleanupL()
   689     {
   741     {
       
   742     TRACER("CGlxAppUi::StartCleanupL");
   690     MGlxCache* cacheManager = MGlxCache::InstanceL();
   743     MGlxCache* cacheManager = MGlxCache::InstanceL();
   691     cacheManager->ReleaseRAML();
   744     cacheManager->ReleaseRAML();
   692     cacheManager->Close();
   745     cacheManager->Close();
   693     }
   746     }
   694 
   747 
   697 // Cancel cache cleanup on memory good event
   750 // Cancel cache cleanup on memory good event
   698 // ---------------------------------------------------------------------------
   751 // ---------------------------------------------------------------------------
   699 //
   752 //
   700 void CGlxAppUi::StopCleanupL()
   753 void CGlxAppUi::StopCleanupL()
   701     {
   754     {
       
   755     TRACER("CGlxAppUi::StopCleanupL");
   702     MGlxCache* cacheManager = MGlxCache::InstanceL();
   756     MGlxCache* cacheManager = MGlxCache::InstanceL();
   703     cacheManager->StopRAMReleaseL();
   757     cacheManager->StopRAMReleaseL();
   704     cacheManager->Close();
   758     cacheManager->Close();
   705     }
   759     }
   706 
   760