imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp
branchRCL_3
changeset 19 f759b6186ab5
parent 17 ff2fb7658ff7
child 20 2b4b06654caa
equal deleted inserted replaced
17:ff2fb7658ff7 19:f759b6186ab5
   283         }
   283         }
   284 		
   284 		
   285 	iUnmountedDrives.Close();
   285 	iUnmountedDrives.Close();
   286     
   286     
   287     delete iFetchedChecker;
   287     delete iFetchedChecker;
       
   288     iFetchedChecker = NULL;
   288     delete iShutdownObserver;
   289     delete iShutdownObserver;
       
   290     iShutdownObserver = NULL;
   289     delete iProcessor;
   291     delete iProcessor;
       
   292     iProcessor = NULL;
   290     
   293     
   291     if(iReconnect)
   294     if(iReconnect)
   292         {
   295         {
   293         iReconnect->Cancel();
   296         iReconnect->Cancel();
   294         delete iReconnect;
   297         delete iReconnect;
   304     ResetAndDestroyHashMap < TInt, CThumbnailStore > ( iStores );
   307     ResetAndDestroyHashMap < TInt, CThumbnailStore > ( iStores );
   305     ResetAndDestroyHashMap < TInt32, CThumbnailProvider > ( iProviders );
   308     ResetAndDestroyHashMap < TInt32, CThumbnailProvider > ( iProviders );
   306     
   309     
   307     iUnmountObservers.ResetAndDestroy();
   310     iUnmountObservers.ResetAndDestroy();
   308     delete iMMCObserver;
   311     delete iMMCObserver;
       
   312     iMMCObserver = NULL;
   309     delete iFormatObserver;
   313     delete iFormatObserver;
       
   314     iFormatObserver = NULL;
   310     
   315     
   311     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   316     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   312 
   317 
   313     // const pointer to a non-const object
   318     // const pointer to a non-const object
   314     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   319     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   318         delete ref->iBitmap;
   323         delete ref->iBitmap;
   319         ref = bpiter.NextValue();
   324         ref = bpiter.NextValue();
   320         }
   325         }
   321     
   326     
   322     delete iScaler;
   327     delete iScaler;
       
   328     iScaler = NULL;
   323     iBitmapPool.Close();
   329     iBitmapPool.Close();
   324     iFbsSession.Disconnect();
   330     iFbsSession.Disconnect();
   325     iRecognizer.Close();
   331     iRecognizer.Close();
   326     iPluginInfoArray.ResetAndDestroy();
   332     iPluginInfoArray.ResetAndDestroy();
   327     delete iCenrep;
   333     delete iCenrep;
       
   334     iCenrep = NULL;
   328     iFs.Close();
   335     iFs.Close();
   329     REComSession::FinalClose();
   336     REComSession::FinalClose();
   330     }
   337     }
   331 
   338 
   332 // -----------------------------------------------------------------------------
   339 // -----------------------------------------------------------------------------
   437     
   444     
   438     iProcessor->RemoveTasks(aSession);
   445     iProcessor->RemoveTasks(aSession);
   439     
   446     
   440     TN_DEBUG2( "CThumbnailServer::DropSession() aSession = 0x%08x", aSession );        
   447     TN_DEBUG2( "CThumbnailServer::DropSession() aSession = 0x%08x", aSession );        
   441     
   448     
   442     // clean-up bitmap pool
   449     // clean-up bitmap pool    
   443     
       
   444     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   450     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   445 
   451 
   446     // const pointer to a non-const object
   452     // const pointer to a non-const object
   447     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   453     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   448 
   454 
   455             delete ref->iBitmap;            
   461             delete ref->iBitmap;            
   456             bpiter.RemoveCurrent();
   462             bpiter.RemoveCurrent();
   457                         
   463                         
   458             TN_DEBUG2( "CThumbnailServer::DropSession() - deleted bitmap, left=%d", iBitmapPool.Count());
   464             TN_DEBUG2( "CThumbnailServer::DropSession() - deleted bitmap, left=%d", iBitmapPool.Count());
   459             }
   465             }
   460         ref = bpiter.NextValue();
   466         
   461         
   467         ref = bpiter.NextValue();        
   462         }
   468         }
   463 
   469 
   464     if ( iSessionCount <= 0 )
   470     if ( iSessionCount <= 0 )
   465         {
   471         {
   466         // server shutdown
   472         // server shutdown
   794     return res;
   800     return res;
   795     }
   801     }
   796 
   802 
   797 
   803 
   798 // -----------------------------------------------------------------------------
   804 // -----------------------------------------------------------------------------
   799 // CThumbnailServer::GetProviderL()
   805 // CThumbnailServer::PreLoadProviders()
   800 // -----------------------------------------------------------------------------
   806 // -----------------------------------------------------------------------------
   801 //
   807 //
   802 void CThumbnailServer::PreLoadProviders(  )
   808 void CThumbnailServer::PreLoadProviders(  )
   803     {
   809     {
   804     TN_DEBUG1( "CThumbnailServer::PreLoadProvidersL()" );
   810     TN_DEBUG1( "CThumbnailServer::PreLoadProvidersL()" );
   805     TInt err(KErrNone);
   811     TInt err(KErrNone);
   806     
   812     
   807     for(TInt i=0; i< iPluginInfoArray.Count(); i++)
   813     for(TInt i=0; i< iPluginInfoArray.Count(); i++)
   808         {
   814         {
   809             TRAP(err, GetProviderL( iPluginInfoArray[i]->ImplementationUid()));
   815         TRAP(err, GetProviderL( iPluginInfoArray[i]->ImplementationUid()));
   810         }
   816         }
   811     }
   817     }
   812 
   818 
   813 
   819 
   814 // -----------------------------------------------------------------------------
   820 // -----------------------------------------------------------------------------
   827 // CThumbnailServer::DequeTask()
   833 // CThumbnailServer::DequeTask()
   828 // Removes thumbnailtask from processor queue.
   834 // Removes thumbnailtask from processor queue.
   829 // -----------------------------------------------------------------------------
   835 // -----------------------------------------------------------------------------
   830 //
   836 //
   831 TInt CThumbnailServer::DequeTask( const TThumbnailServerRequestId& aRequestId )
   837 TInt CThumbnailServer::DequeTask( const TThumbnailServerRequestId& aRequestId )
   832     {
   838     {   
   833     
       
   834     TInt error = iProcessor->RemoveTask( aRequestId );
   839     TInt error = iProcessor->RemoveTask( aRequestId );
   835         
   840         
   836     // clean-up bitmap pool        
   841     // clean-up bitmap pool               
   837         
       
   838     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   842     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   839 
   843 
   840     // const pointer to a non-const object
   844     // const pointer to a non-const object
   841     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   845     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   842 
   846 
   843     while ( ref )
   847     while ( ref )
   844         {
   848         {       
   845         
       
   846         TN_DEBUG2( "CThumbnailServer::DequeTask() - ref->iRequestId = %d", ref->iRequestId );
   849         TN_DEBUG2( "CThumbnailServer::DequeTask() - ref->iRequestId = %d", ref->iRequestId );
   847 
   850 
   848         if ( ref->iSession == aRequestId.iSession && 
   851         if ( ref->iSession == aRequestId.iSession && 
   849              ref->iRequestId == aRequestId.iRequestId )
   852              ref->iRequestId == aRequestId.iRequestId )
   850             {            
   853             {            
   851             delete ref->iBitmap;            
   854             delete ref->iBitmap;            
   852             bpiter.RemoveCurrent();                        
   855             bpiter.RemoveCurrent();                        
   853                         
   856                         
   854             TN_DEBUG2( "CThumbnailServer::DequeTask() - deleted bitmap, left=%d", 
   857             TN_DEBUG2( "CThumbnailServer::DequeTask() - deleted bitmap, left=%d", 
   855                                 iBitmapPool.Count());
   858                     iBitmapPool.Count());
   856             }
   859             }
   857         ref = bpiter.NextValue();
   860         
   858         
   861         ref = bpiter.NextValue();        
   859         }
   862         }
   860 
   863 
   861     return error;
   864     return error;
   862     }
   865     }
   863 
   866 
  1160                 continue;
  1163                 continue;
  1161                 }
  1164                 }
  1162             
  1165             
  1163             // ignore errors
  1166             // ignore errors
  1164             TRAP_IGNORE( StoreForDriveL( drive ));
  1167             TRAP_IGNORE( StoreForDriveL( drive ));
       
  1168             
       
  1169             TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() update KItemsleft == %d", KErrNotReady);
       
  1170             RProperty::Set(KTAGDPSNotification, KItemsleft, KErrNotReady );
       
  1171 			
  1165             TInt index = iUnmountedDrives.Find( drive );
  1172             TInt index = iUnmountedDrives.Find( drive );
  1166             
  1173             
  1167             if(index >= KErrNone)
  1174             if(index >= KErrNone)
  1168                 {
  1175                 {
  1169                 iUnmountedDrives.Remove( index );
  1176                 iUnmountedDrives.Remove( index );
  1764        __ASSERT_DEBUG(( iUnmount ), ThumbnailPanic( EThumbnailNullPointer ));
  1771        __ASSERT_DEBUG(( iUnmount ), ThumbnailPanic( EThumbnailNullPointer ));
  1765     }
  1772     }
  1766 
  1773 
  1767 
  1774 
  1768 // ---------------------------------------------------------------------------
  1775 // ---------------------------------------------------------------------------
  1769 // CThumbnailServer::ReconnectCallBack()
  1776 // CThumbnailServer::UnmountCallBack()
  1770 // ---------------------------------------------------------------------------
  1777 // ---------------------------------------------------------------------------
  1771 //
  1778 //
  1772 TInt CThumbnailServer::UnmountCallBack(TAny* aAny)
  1779 TInt CThumbnailServer::UnmountCallBack(TAny* aAny)
  1773     {
  1780     {
  1774     TN_DEBUG1( "CThumbnailServer::UnmountCallBack() - unmount finished");
  1781     TN_DEBUG1( "CThumbnailServer::UnmountCallBack() - unmount finished");