photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcemds.cpp
branchRCL_3
changeset 17 a60acebbbd9d
parent 15 191387a8b767
child 19 420f6808bf21
--- a/photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcemds.cpp	Tue Apr 27 16:37:53 2010 +0300
+++ b/photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcemds.cpp	Tue May 11 16:13:40 2010 +0300
@@ -189,13 +189,12 @@
     
     // retrieve the value
     TInt value = 0;
-    TInt Err = iProperty.Get(value);
-    GLX_DEBUG2("CGlxMDSShutdownObserver::RunL(): iProperty.Get(value); returns %d", Err);
+    TInt err = iProperty.Get(value);
+    GLX_DEBUG2("CGlxMDSShutdownObserver::RunL(): iProperty.Get(value); returns %d", err);
     
-    User::LeaveIfError(Err);
+    User::LeaveIfError(err);
 
     iObserver.ShutdownNotification(value);
-    
     }
 
 // ---------------------------------------------------------------------------
@@ -345,10 +344,7 @@
 void CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError )    
     {
     TRACER("CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError)")
-    delete iSession;
-    iSession = NULL;
-    
-    GLX_DEBUG2("void CGlxDataSourceMde::HandleSessionError() Session Error = %d", aError);
+    GLX_DEBUG2("void CGlxDataSourceMde::HandleSessionError() aError(%d)", aError);
 
     iDataSourceReady = EFalse;
     iSessionOpen = EFalse;
@@ -362,7 +358,6 @@
         }
     }
 
-
 // ---------------------------------------------------------------------------
 // CreateTaskL
 // ---------------------------------------------------------------------------
@@ -533,7 +528,9 @@
 	iSession->AddObjectObserverL(*this, addCondition );
 	iSession->AddObjectPresentObserverL(*this );
 		
-	CleanupStack::Pop( addCondition ); //This addCondition should only be popped. The destroy part will be done by MDS.
+	// This addCondition should only be popped. 
+	// As the ownership is transferred, the same will be destroyed by MdS.
+	CleanupStack::Pop( addCondition ); 
     }
 
 // ---------------------------------------------------------------------------
@@ -711,9 +708,10 @@
 void CGlxDataSourceMde::CreateSessionL()
     {
     TRACER("CGlxDataSourceMde::CreateSessionL()");
+    delete iSession;
+    iSession = NULL;
 	iSession = CMdESession::NewL( *this );
     }
-            
 
 // ---------------------------------------------------------------------------
 // ProcessItemUpdate
@@ -1245,15 +1243,25 @@
         }
     }
 
+// ---------------------------------------------------------------------------
+// ShutdownNotification
+// ---------------------------------------------------------------------------
+//  
 void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)
     {
     TRACER("void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)")
-    GLX_DEBUG2("CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)  aShutdownState = %d", aShutdownState);
+    GLX_DEBUG2("CGlxDataSourceMde::ShutdownNotification(aShutdownState=%d)", 
+            aShutdownState);
 
-    // iDataSourceReady is set to false if we have lost an MDS session.
-    // a ShutdownNotification with aaShutdownState == 0 means that MDS has restarted. So this is the time to recreate a session with MDS.  
-    if ( (!iDataSourceReady) && (0 == aShutdownState) )
+    if (!iDataSourceReady && 0 == aShutdownState)
         {
+        GLX_DEBUG1("Photos MdS ShutdownNotification - MdS Server restarted!");
         CreateSession();
         }
+
+    if (iDataSourceReady && 1 == aShutdownState)
+        {
+        GLX_DEBUG1("Photos MdS ShutdownNotification - MdS Server Shutdown!");
+        HandleSessionError(*iSession, KErrServerTerminated);
+        }
     }