photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcemds.cpp
branchRCL_3
changeset 17 a60acebbbd9d
parent 15 191387a8b767
child 19 420f6808bf21
equal deleted inserted replaced
15:191387a8b767 17:a60acebbbd9d
   187     iProperty.Subscribe(iStatus);
   187     iProperty.Subscribe(iStatus);
   188     SetActive();
   188     SetActive();
   189     
   189     
   190     // retrieve the value
   190     // retrieve the value
   191     TInt value = 0;
   191     TInt value = 0;
   192     TInt Err = iProperty.Get(value);
   192     TInt err = iProperty.Get(value);
   193     GLX_DEBUG2("CGlxMDSShutdownObserver::RunL(): iProperty.Get(value); returns %d", Err);
   193     GLX_DEBUG2("CGlxMDSShutdownObserver::RunL(): iProperty.Get(value); returns %d", err);
   194     
   194     
   195     User::LeaveIfError(Err);
   195     User::LeaveIfError(err);
   196 
   196 
   197     iObserver.ShutdownNotification(value);
   197     iObserver.ShutdownNotification(value);
   198     
       
   199     }
   198     }
   200 
   199 
   201 // ---------------------------------------------------------------------------
   200 // ---------------------------------------------------------------------------
   202 // CGlxMDSShutdownObserver::DoCancel()
   201 // CGlxMDSShutdownObserver::DoCancel()
   203 // ---------------------------------------------------------------------------
   202 // ---------------------------------------------------------------------------
   343 // ----------------------------------------------------------------------------
   342 // ----------------------------------------------------------------------------
   344 //     
   343 //     
   345 void CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError )    
   344 void CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError )    
   346     {
   345     {
   347     TRACER("CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError)")
   346     TRACER("CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError)")
   348     delete iSession;
   347     GLX_DEBUG2("void CGlxDataSourceMde::HandleSessionError() aError(%d)", aError);
   349     iSession = NULL;
       
   350     
       
   351     GLX_DEBUG2("void CGlxDataSourceMde::HandleSessionError() Session Error = %d", aError);
       
   352 
   348 
   353     iDataSourceReady = EFalse;
   349     iDataSourceReady = EFalse;
   354     iSessionOpen = EFalse;
   350     iSessionOpen = EFalse;
   355 
   351 
   356     // We wait till MDS restarts before starting the session if the current session is locked.
   352     // We wait till MDS restarts before starting the session if the current session is locked.
   359     if ( (KErrLocked != aError) && ( KErrServerTerminated != aError) )
   355     if ( (KErrLocked != aError) && ( KErrServerTerminated != aError) )
   360         {
   356         {
   361         iCreateSessionCallback->CallBack();
   357         iCreateSessionCallback->CallBack();
   362         }
   358         }
   363     }
   359     }
   364 
       
   365 
   360 
   366 // ---------------------------------------------------------------------------
   361 // ---------------------------------------------------------------------------
   367 // CreateTaskL
   362 // CreateTaskL
   368 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   369 //
   364 //
   531 	addCondition->AddObjectConditionL( *iTagDef );
   526 	addCondition->AddObjectConditionL( *iTagDef );
   532 	
   527 	
   533 	iSession->AddObjectObserverL(*this, addCondition );
   528 	iSession->AddObjectObserverL(*this, addCondition );
   534 	iSession->AddObjectPresentObserverL(*this );
   529 	iSession->AddObjectPresentObserverL(*this );
   535 		
   530 		
   536 	CleanupStack::Pop( addCondition ); //This addCondition should only be popped. The destroy part will be done by MDS.
   531 	// This addCondition should only be popped. 
       
   532 	// As the ownership is transferred, the same will be destroyed by MdS.
       
   533 	CleanupStack::Pop( addCondition ); 
   537     }
   534     }
   538 
   535 
   539 // ---------------------------------------------------------------------------
   536 // ---------------------------------------------------------------------------
   540 // CGlxDataSourceMde::HandleObjectNotification
   537 // CGlxDataSourceMde::HandleObjectNotification
   541 // ---------------------------------------------------------------------------
   538 // ---------------------------------------------------------------------------
   709 // ---------------------------------------------------------------------------
   706 // ---------------------------------------------------------------------------
   710 //
   707 //
   711 void CGlxDataSourceMde::CreateSessionL()
   708 void CGlxDataSourceMde::CreateSessionL()
   712     {
   709     {
   713     TRACER("CGlxDataSourceMde::CreateSessionL()");
   710     TRACER("CGlxDataSourceMde::CreateSessionL()");
       
   711     delete iSession;
       
   712     iSession = NULL;
   714 	iSession = CMdESession::NewL( *this );
   713 	iSession = CMdESession::NewL( *this );
   715     }
   714     }
   716             
       
   717 
   715 
   718 // ---------------------------------------------------------------------------
   716 // ---------------------------------------------------------------------------
   719 // ProcessItemUpdate
   717 // ProcessItemUpdate
   720 // ---------------------------------------------------------------------------
   718 // ---------------------------------------------------------------------------
   721 //
   719 //
  1243         default:
  1241         default:
  1244             break;
  1242             break;
  1245         }
  1243         }
  1246     }
  1244     }
  1247 
  1245 
       
  1246 // ---------------------------------------------------------------------------
       
  1247 // ShutdownNotification
       
  1248 // ---------------------------------------------------------------------------
       
  1249 //  
  1248 void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)
  1250 void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)
  1249     {
  1251     {
  1250     TRACER("void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)")
  1252     TRACER("void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)")
  1251     GLX_DEBUG2("CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)  aShutdownState = %d", aShutdownState);
  1253     GLX_DEBUG2("CGlxDataSourceMde::ShutdownNotification(aShutdownState=%d)", 
  1252 
  1254             aShutdownState);
  1253     // iDataSourceReady is set to false if we have lost an MDS session.
  1255 
  1254     // a ShutdownNotification with aaShutdownState == 0 means that MDS has restarted. So this is the time to recreate a session with MDS.  
  1256     if (!iDataSourceReady && 0 == aShutdownState)
  1255     if ( (!iDataSourceReady) && (0 == aShutdownState) )
  1257         {
  1256         {
  1258         GLX_DEBUG1("Photos MdS ShutdownNotification - MdS Server restarted!");
  1257         CreateSession();
  1259         CreateSession();
  1258         }
  1260         }
  1259     }
  1261 
       
  1262     if (iDataSourceReady && 1 == aShutdownState)
       
  1263         {
       
  1264         GLX_DEBUG1("Photos MdS ShutdownNotification - MdS Server Shutdown!");
       
  1265         HandleSessionError(*iSession, KErrServerTerminated);
       
  1266         }
       
  1267     }