--- a/photosgallery/gallery/src/glxappui.cpp Wed Sep 01 12:33:26 2010 +0100
+++ b/photosgallery/gallery/src/glxappui.cpp Tue Sep 14 21:19:17 2010 +0300
@@ -60,6 +60,10 @@
#include <hal_data.h>
#include <oommonitorsession.h>
#include <glxtracer.h>
+#include <glxmedialist.h>
+#include <glxmedialistiterator.h>
+#include <glxattributecontext.h>
+#include <glxattributeretriever.h>
//OOM
#include <oommonitorplugin.h>
@@ -119,7 +123,6 @@
ReserveMemoryL(EEntryTypeStartUp);
// publish zoom context, no zoom keys for now
NGlxZoomStatePublisher::PublishStateL( EFalse );
- iEndKeyPressed = EFalse;
iStateChangeRequested = EFalse;
}
@@ -130,7 +133,6 @@
CGlxAppUi::~CGlxAppUi()
{
TRACER("CGlxAppUi::~CGlxAppUi()");
- iEndKeyPressed = EFalse;
if ( iNavigationalState )
{
iNavigationalState->RemoveObserver(*this);
@@ -243,12 +245,7 @@
TRAPD(err, HandleActivationMessageL(aCommand, aDocumentName, aTail));
if ( KErrNone != err )
{
- // Open navigational state at root level
- CMPXCollectionPath* newState = CMPXCollectionPath::NewL();
- CleanupStack::PushL( newState );
- iNavigationalState->NavigateToL( *newState );
- iStateChangeRequested = ETrue;
- CleanupStack::PopAndDestroy( newState );
+ NavigateToMainListL();
}
//Start a timer to check for thr IAD update after 60 Secs.
@@ -453,12 +450,7 @@
if (aData.Length() == 0 )
{
- // Open navigational state at root level
- CMPXCollectionPath* newState = CMPXCollectionPath::NewL();
- CleanupStack::PushL(newState);
- iNavigationalState->NavigateToL(*newState);
- iStateChangeRequested = ETrue;
- CleanupStack::PopAndDestroy(newState);
+ NavigateToMainListL();
}
else
{
@@ -468,6 +460,21 @@
}
// ---------------------------------------------------------------------------
+// NavigateToMainListL
+// ---------------------------------------------------------------------------
+//
+void CGlxAppUi::NavigateToMainListL()
+ {
+ TRACER("void CGlxAppUi::NavigateToMainListL()");
+ // Open navigational state at root level
+ CMPXCollectionPath* collPath = CMPXCollectionPath::NewL();
+ CleanupStack::PushL(collPath);
+ iNavigationalState->NavigateToL(*collPath);
+ iStateChangeRequested = ETrue;
+ CleanupStack::PopAndDestroy(collPath);
+ }
+
+// ---------------------------------------------------------------------------
// HandleActivationMessageL
// ---------------------------------------------------------------------------
//
@@ -485,8 +492,8 @@
RDesReadStream stream(aData);
CleanupClosePushL(stream);
stream >> msgUid;
-
- switch ( msgUid.iUid )
+
+ switch (msgUid.iUid)
{
case KGlxActivationCmdShowLastModified:
case KGlxActivationCameraAlbum:
@@ -494,17 +501,64 @@
{
GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: Creating Screen Clearer");
iUiUtility->DisplayScreenClearerL();
+
HBufC8* activationParam = HBufC8::NewLC(KMaxUidName);
+ // While harvesting is in progress, activate the Camera Album
+ // instead of All grid. However, do not change the activation
+ // parameter as it is used within photos.
activationParam->Des().AppendNum(KGlxActivationCmdShowAll);
SetActivationParamL(*activationParam);
CleanupStack::PopAndDestroy(activationParam);
-
- // Go to All grid view
- GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: All Grid View");
+
// Send the command to reset the view
ProcessCommandL(EGlxCmdResetView);
iNavigationalState->SetBackExitStatus(ETrue);
- path->AppendL(KGlxCollectionPluginAllImplementationUid);
+
+ // 1)While harvesting is going on, TNM publishes itemsleft 'PSkey' value.
+ // After harvesting is over, itemsleft count will be 0.
+ // 2)Tnm sets the value to KErrNotReady until it gets the total count while harvesting.
+ // TNM doesn't update the key value in batches. It updates @ a single shot.
+ // so need to check against KErrNotReady also.
+ if (iUiUtility->GetItemsLeftCount() == KErrNotReady
+ || iUiUtility->GetItemsLeftCount())
+ {
+ // Go to Camera Album grid view
+ GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: Camera Album Grid View");
+ path->AppendL(KGlxCollectionPluginAlbumsImplementationUid);
+ MGlxMediaList* mediaList = MGlxMediaList::InstanceL(*path);
+ CleanupClosePushL(*mediaList);
+
+ TGlxSequentialIterator iter;
+ CGlxAttributeContext* attributeContext =
+ new (ELeave) CGlxAttributeContext(&iter);
+ CleanupStack::PushL(attributeContext);
+ iter.SetRange(1);
+ attributeContext->AddAttributeL(KMPXMediaGeneralTitle);
+ mediaList->AddContextL(attributeContext,
+ KGlxFetchContextPriorityBlocking);
+ TRAPD(err, GlxAttributeRetriever::RetrieveL(
+ *attributeContext, *mediaList, EFalse));
+ if (err != KErrNone)
+ {
+ mediaList->RemoveContext(attributeContext);
+ User::Leave( err);
+ }
+ TInt count = mediaList->Count();
+ GLX_LOG_INFO1("CGlxAppUi::HandleActivationMessageL() count=%d", count);
+ __ASSERT_DEBUG(count != 0, Panic(EGlxPanicRequiredItemNotFound));
+
+ path->AppendL(TMPXItemId(mediaList->Item(0).Id().Value()));
+
+ mediaList->RemoveContext(attributeContext);
+ CleanupStack::PopAndDestroy(attributeContext);
+ CleanupStack::PopAndDestroy(mediaList);
+ }
+ else
+ {
+ // Go to All grid view
+ GLX_LOG_INFO("CGlxAppUi::HandleActivationMessageL: All Grid View");
+ path->AppendL(KGlxCollectionPluginAllImplementationUid);
+ }
}
break;
@@ -514,10 +568,10 @@
}
CleanupStack::PopAndDestroy(&stream);
iNavigationalState->SetStartingLevel(path->Levels());
- iNavigationalState->NavigateToL( *path );
+ iNavigationalState->NavigateToL(*path);
iStateChangeRequested = ETrue;
CleanupStack::PopAndDestroy(path);
-
+
// Introduced to fix bug EMJN-78GH6N.
if (0 != iEikonEnv->RootWin().OrdinalPosition())
{
@@ -649,36 +703,34 @@
// Handle OOM events.
// ---------------------------------------------------------------------------
//
+void CGlxAppUi::HandleApplicationSpecificEventL(TInt aEventType,
+ const TWsEvent& aWsEvent)
+ {
+ TRACER("CGlxAppUi::HandleApplicationSpecificEventL");
+ GLX_LOG_INFO1("CGlxAppUi::HandleApplicationSpecificEventL() aEventType=%d", aEventType);
-void CGlxAppUi::HandleApplicationSpecificEventL(TInt aEventType, const TWsEvent& aWsEvent)
-{
-TRACER("CGlxAppUi::HandleApplicationSpecificEventL");
-CAknViewAppUi::HandleApplicationSpecificEventL(aEventType,aWsEvent);
- if(aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
- {
- /**
- * Making the flag etrue ensures that it will not call LaunchMmViewL in handlecommandl while
- * red key is pressed. Otherwise it will launch matrix menu, not idle screen.
- */
- iEndKeyPressed = ETrue;
- ClosePhotosL();
- }
-switch(aEventType)
- {
- case KAppOomMonitor_FreeRam:
- {
- StartCleanupL();
- }
- break;
- case KAppOomMonitor_MemoryGood:
- {
- StopCleanupL();
- }
- break;
- default:
- break;
- }
-}
+ CAknViewAppUi::HandleApplicationSpecificEventL(aEventType, aWsEvent);
+ if (aWsEvent.Type() == KAknUidValueEndKeyCloseEvent)
+ {
+ ClosePhotosL();
+ }
+
+ switch (aEventType)
+ {
+ case KAppOomMonitor_FreeRam:
+ {
+ StartCleanupL();
+ }
+ break;
+ case KAppOomMonitor_MemoryGood:
+ {
+ StopCleanupL();
+ }
+ break;
+ default:
+ break;
+ }
+ }
// ---------------------------------------------------------------------------
// StartCleanup
@@ -687,6 +739,7 @@
//
void CGlxAppUi::StartCleanupL()
{
+ TRACER("CGlxAppUi::StartCleanupL");
MGlxCache* cacheManager = MGlxCache::InstanceL();
cacheManager->ReleaseRAML();
cacheManager->Close();
@@ -699,6 +752,7 @@
//
void CGlxAppUi::StopCleanupL()
{
+ TRACER("CGlxAppUi::StopCleanupL");
MGlxCache* cacheManager = MGlxCache::InstanceL();
cacheManager->StopRAMReleaseL();
cacheManager->Close();