scrsaver/scrsaverplugins/SlideshowPlugin/src/SlideshowPlugin.cpp
branchRCL_3
changeset 31 8f536f98e1f8
parent 27 fc25e03508fd
equal deleted inserted replaced
29:65be1d84df1f 31:8f536f98e1f8
   132     delete iScreensaverName;
   132     delete iScreensaverName;
   133     delete iSettings;
   133     delete iSettings;
   134     delete iDrmHelper;
   134     delete iDrmHelper;
   135     delete iModel;
   135     delete iModel;
   136 
   136 
   137     // Close and delete mds query
   137     // First model, then engine, otherwise bad things happen
   138     if ( iQuery )
   138     delete iMdESession;
   139         {
       
   140         iQuery->Cancel();
       
   141         delete iQuery;
       
   142         iQuery = NULL;
       
   143         }
       
   144 
       
   145 	if ( iMdESession )
       
   146         {
       
   147         delete iMdESession;
       
   148         iMdESession = NULL;
       
   149         }
       
   150     
   139     
   151     // Logging done
   140     // Logging done
   152     SSPLOGGER_DELETE;
   141     SSPLOGGER_DELETE;
   153     }
   142     }
   154 
   143 
   798 
   787 
   799 // Load filenames from CLF
   788 // Load filenames from CLF
   800 void CSlideshowPlugin::LoadRandomSlidesL()
   789 void CSlideshowPlugin::LoadRandomSlidesL()
   801     {
   790     {
   802     SSPLOGGER_ENTERFN("LoadRandomSlidesL()");
   791     SSPLOGGER_ENTERFN("LoadRandomSlidesL()");
       
   792 
   803     // Start by getting rid of possibly loaded slides
   793     // Start by getting rid of possibly loaded slides
   804     iModel->DeleteAll();
   794     iModel->DeleteAll();
   805     // connect to MDS, load data or not
   795 
       
   796     // connect to MDS
   806     ConnectToMDSSessionL();
   797     ConnectToMDSSessionL();
       
   798 
       
   799     // Wait for query of MDS to complete before continuing
       
   800     WaitForMDS();
   807 
   801 
   808     SSPLOGGER_LEAVEFN("LoadRandomSlidesL()");
   802     SSPLOGGER_LEAVEFN("LoadRandomSlidesL()");
   809     }
   803     }
   810 
   804 
   811 
   805 
   944 void CSlideshowPlugin::ConnectToMDSSessionL()
   938 void CSlideshowPlugin::ConnectToMDSSessionL()
   945     {
   939     {
   946     if (!iMdESession)
   940     if (!iMdESession)
   947         {
   941         {
   948         iMdESession = CMdESession::NewL( *this );
   942         iMdESession = CMdESession::NewL( *this );
   949         // Wait for query of MDS to complete before continuing
       
   950         WaitForMDS();
       
   951         }
   943         }
   952     }
   944     }
   953 
   945 
   954 // -----------------------------------------------------------------------------
   946 // -----------------------------------------------------------------------------
   955 // CSlideshowPlugin::WaitForMDS
   947 // CSlideshowPlugin::WaitForMDS
  1010     {
  1002     {
  1011     CMdENamespaceDef& defaultNamespaceDef = iMdESession->GetDefaultNamespaceDefL();
  1003     CMdENamespaceDef& defaultNamespaceDef = iMdESession->GetDefaultNamespaceDefL();
  1012     CMdEObjectDef& imageObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Image::KImageObject );
  1004     CMdEObjectDef& imageObjDef = defaultNamespaceDef.GetObjectDefL( MdeConstants::Image::KImageObject );
  1013 
  1005 
  1014     // query objects with object definition "Image"
  1006     // query objects with object definition "Image"
  1015     iQuery = iMdESession->NewObjectQueryL( defaultNamespaceDef, imageObjDef, this );
  1007     CMdEObjectQuery* query = iMdESession->NewObjectQueryL( defaultNamespaceDef, imageObjDef, this );
  1016 
  1008 
  1017     iQuery->FindL( KDefaultRandomLoadingNumber );
  1009     query->FindL( KDefaultRandomLoadingNumber );
  1018     }
  1010     }
  1019 
  1011 
  1020 // -----------------------------------------------------------------------------
  1012 // -----------------------------------------------------------------------------
  1021 // CSlideshowPlugin::HandleSessionError
  1013 // CSlideshowPlugin::HandleSessionError
  1022 // error happened when open the session, close session and end the waiting
  1014 // error happened when open the session, close session and end the waiting