imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp
branchRCL_3
changeset 21 6257223ede8a
parent 20 2b4b06654caa
child 22 9d4d3445ce6e
equal deleted inserted replaced
20:2b4b06654caa 21:6257223ede8a
    35 #include "thumbnailpanic.h"
    35 #include "thumbnailpanic.h"
    36 #include "thumbnailcenrep.h"
    36 #include "thumbnailcenrep.h"
    37 #include "thumbnailmemorycardobserver.h"
    37 #include "thumbnailmemorycardobserver.h"
    38 #include "tmgetimei.h"
    38 #include "tmgetimei.h"
    39 #include "thumbnailfetchedchecker.h"
    39 #include "thumbnailfetchedchecker.h"
       
    40 #include "OstTraceDefinitions.h"
       
    41 #ifdef OST_TRACE_COMPILER_IN_USE
       
    42 #include "thumbnailserverTraces.h"
       
    43 #endif
       
    44 
    40 
    45 
    41 
    46 
    42 _LIT8( KThumbnailMimeWildCard, "*" );
    47 _LIT8( KThumbnailMimeWildCard, "*" );
    43 _LIT8( KThumbnailMimeImage, "image" );
    48 _LIT8( KThumbnailMimeImage, "image" );
    44 _LIT8( KThumbnailMimeVideo, "video" );
    49 _LIT8( KThumbnailMimeVideo, "video" );
   209 // ---------------------------------------------------------------------------
   214 // ---------------------------------------------------------------------------
   210 //
   215 //
   211 void CThumbnailServer::ConstructL()
   216 void CThumbnailServer::ConstructL()
   212     {
   217     {
   213     TN_DEBUG1( "CThumbnailServer::ConstructL()" );
   218     TN_DEBUG1( "CThumbnailServer::ConstructL()" );
       
   219     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_CONSTRUCTL, "CThumbnailServer::ConstructL" );
   214     
   220     
   215 #ifdef _DEBUG
   221 #ifdef _DEBUG
   216     iPlaceholderCounter = 0;
   222     iPlaceholderCounter = 0;
   217 #endif
   223 #endif
   218     
   224     
   271 // ---------------------------------------------------------------------------
   277 // ---------------------------------------------------------------------------
   272 //
   278 //
   273 CThumbnailServer::~CThumbnailServer()
   279 CThumbnailServer::~CThumbnailServer()
   274     {
   280     {
   275     TN_DEBUG1( "CThumbnailServer::~CThumbnailServer()" );
   281     TN_DEBUG1( "CThumbnailServer::~CThumbnailServer()" );
       
   282     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_CTHUMBNAILSERVER, "CThumbnailServer::~CThumbnailServer" );
   276 
   283 
   277     iShutdown = ETrue;
   284     iShutdown = ETrue;
   278     
   285     
   279     if(iUnmount)
   286     if(iUnmount)
   280         {
   287         {
   345 void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt aError )
   352 void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt aError )
   346 #else
   353 #else
   347 void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt /*aError*/ )
   354 void CThumbnailServer::HandleSessionOpened( CMdESession& /* aSession */, TInt /*aError*/ )
   348 #endif
   355 #endif
   349     {
   356     {
       
   357 #ifdef _DEBUG
   350     TN_DEBUG2( "CThumbnailServer::HandleSessionOpened error == %d", aError );
   358     TN_DEBUG2( "CThumbnailServer::HandleSessionOpened error == %d", aError );
       
   359     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_HANDLESESSIONOPENED, "CThumbnailServer::HandleSessionOpened;aError=%d", aError );
       
   360 #endif    
   351     }
   361     }
   352 
   362 
   353 // -----------------------------------------------------------------------------
   363 // -----------------------------------------------------------------------------
   354 // CThumbnailServer::HandleSessionError
   364 // CThumbnailServer::HandleSessionError
   355 // -----------------------------------------------------------------------------
   365 // -----------------------------------------------------------------------------
   356 //
   366 //
   357 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
   367 void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
   358     {
   368     {
   359     TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError );
   369     TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError );
       
   370     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_HANDLESESSIONERROR, "CThumbnailServer::HandleSessionError;aError=%d", aError );
   360     if (aError != KErrNone && !iShutdown && !iSessionError)
   371     if (aError != KErrNone && !iShutdown && !iSessionError)
   361         {
   372         {
   362         iSessionError = ETrue;
   373         iSessionError = ETrue;
   363     
   374     
   364         if (!iReconnect->IsActive())
   375         if (!iReconnect->IsActive())
   365             {
   376             {
   366             iReconnect->Start( KMdEReconnect, KMdEReconnect, 
   377             iReconnect->Start( KMdEReconnect, KMdEReconnect, 
   367                                TCallBack(ReconnectCallBack, this));
   378                                TCallBack(ReconnectCallBack, this));
   368             
   379             
   369             TN_DEBUG1( "CThumbnailServer::HandleSessionError() - reconnect timer started" );
   380             TN_DEBUG1( "CThumbnailServer::HandleSessionError() - reconnect timer started" );
       
   381             OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_HANDLESESSIONERROR, "CThumbnailServer::HandleSessionError - reconnect timer started" );
   370             }
   382             }
   371         } 
   383         } 
   372     }
   384     }
   373 
   385 
   374 // -----------------------------------------------------------------------------
   386 // -----------------------------------------------------------------------------
   409         server = CThumbnailServer::NewL(); // Adds server in scheduler
   421         server = CThumbnailServer::NewL(); // Adds server in scheduler
   410         // No need to CleanupStack::PushL(server) since no leaves can happen
   422         // No need to CleanupStack::PushL(server) since no leaves can happen
   411         RProcess::Rendezvous( KErrNone );
   423         RProcess::Rendezvous( KErrNone );
   412         TN_DEBUG1( 
   424         TN_DEBUG1( 
   413             "CThumbnailServer::ThreadFunctionL() -- CActiveScheduler::Start() in" );
   425             "CThumbnailServer::ThreadFunctionL() -- CActiveScheduler::Start() in" );
       
   426         OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_THREADFUNCTIONL, "CThumbnailServer::ThreadFunctionL -- CActiveScheduler::Start() in" );
   414         CActiveScheduler::Start();
   427         CActiveScheduler::Start();
   415         TN_DEBUG1( 
   428         TN_DEBUG1( 
   416             "CThumbnailServer::ThreadFunctionL() -- CActiveScheduler::Start() out" );
   429             "CThumbnailServer::ThreadFunctionL() -- CActiveScheduler::Start() out" );
       
   430         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_THREADFUNCTIONL, "CThumbnailServer::ThreadFunctionL - out" );
   417         // Comes here if server gets shut down
   431         // Comes here if server gets shut down
   418         delete server;
   432         delete server;
   419         server = NULL;
   433         server = NULL;
   420         CleanupStack::PopAndDestroy( scheduler );
   434         CleanupStack::PopAndDestroy( scheduler );
   421         }
   435         }
   428 //
   442 //
   429 void CThumbnailServer::AddSession()
   443 void CThumbnailServer::AddSession()
   430     {
   444     {
   431     TN_DEBUG2( "CThumbnailServer::AddSession() iSessionCount was %d",
   445     TN_DEBUG2( "CThumbnailServer::AddSession() iSessionCount was %d",
   432         iSessionCount );
   446         iSessionCount );
       
   447     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_ADDSESSION, "CThumbnailServer::AddSession;iSessionCount=%d", iSessionCount );
   433     iSessionCount++;
   448     iSessionCount++;
   434     }
   449     }
   435 
   450 
   436 
   451 
   437 // -----------------------------------------------------------------------------
   452 // -----------------------------------------------------------------------------
   440 //
   455 //
   441 void CThumbnailServer::DropSession(CThumbnailServerSession* aSession)
   456 void CThumbnailServer::DropSession(CThumbnailServerSession* aSession)
   442     {
   457     {
   443     TN_DEBUG2( "CThumbnailServer::DropSession() iSessionCount was %d",
   458     TN_DEBUG2( "CThumbnailServer::DropSession() iSessionCount was %d",
   444         iSessionCount );
   459         iSessionCount );
       
   460     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_DROPSESSION, "CThumbnailServer::DropSession;iSessionCount=%d", iSessionCount );
   445     iSessionCount--;
   461     iSessionCount--;
   446     
   462     
   447     if(iProcessor)
   463     if(iProcessor)
   448         {
   464         {
   449         iProcessor->RemoveTasks(aSession);
   465         iProcessor->RemoveTasks(aSession);
   450         }
   466         }
   451     
   467     
   452     TN_DEBUG2( "CThumbnailServer::DropSession() aSession = 0x%08x", aSession );        
   468     TN_DEBUG2( "CThumbnailServer::DropSession() aSession = 0x%08x", aSession );        
       
   469     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_DROPSESSION, "CThumbnailServer::DropSession;aSession=%o", aSession );
   453     
   470     
   454     // clean-up bitmap pool    
   471     // clean-up bitmap pool    
   455     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   472     THashMapIter < TInt, TThumbnailBitmapRef > bpiter( iBitmapPool );
   456 
   473 
   457     // const pointer to a non-const object
   474     // const pointer to a non-const object
   460     while ( ref )
   477     while ( ref )
   461         {        
   478         {        
   462         if ( ref->iSession == aSession )
   479         if ( ref->iSession == aSession )
   463             {
   480             {
   464             TN_DEBUG2( "CThumbnailServer::DropSession() - ref->iSession = 0x%08x", ref->iSession );
   481             TN_DEBUG2( "CThumbnailServer::DropSession() - ref->iSession = 0x%08x", ref->iSession );
       
   482             OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_DROPSESSION, "CThumbnailServer::DropSession;ref->iSession=%o", ref->iSession );
   465         
   483         
   466             delete ref->iBitmap;
   484             delete ref->iBitmap;
   467             bpiter.RemoveCurrent();
   485             bpiter.RemoveCurrent();
   468                         
   486                         
   469             TN_DEBUG2( "CThumbnailServer::DropSession() - deleted bitmap, left=%d", iBitmapPool.Count());
   487             TN_DEBUG2( "CThumbnailServer::DropSession() - deleted bitmap, left=%d", iBitmapPool.Count());
       
   488             OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSERVER_DROPSESSION, "CThumbnailServer::DropSession;iBitmapPool.Count()=%d", iBitmapPool.Count() );
   470             }
   489             }
   471         
   490         
   472         ref = bpiter.NextValue();        
   491         ref = bpiter.NextValue();        
   473         }
   492         }
   474 
   493 
   491 // -----------------------------------------------------------------------------
   510 // -----------------------------------------------------------------------------
   492 //
   511 //
   493 void CThumbnailServer::ShutdownNotification()
   512 void CThumbnailServer::ShutdownNotification()
   494     {
   513     {
   495     TN_DEBUG1( "CThumbnailServer::ShutdownNotification()");
   514     TN_DEBUG1( "CThumbnailServer::ShutdownNotification()");
       
   515     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_SHUTDOWNNOTIFICATION, "CThumbnailServer::ShutdownNotification" );
   496     if (!iShutdown)
   516     if (!iShutdown)
   497         {
   517         {
   498         TN_DEBUG1( "CThumbnailServer::ShutdownNotification() shutdown");
   518         TN_DEBUG1( "CThumbnailServer::ShutdownNotification() shutdown");
       
   519         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_SHUTDOWNNOTIFICATION, "CThumbnailServer::ShutdownNotification - shutdown" );
   499         CActiveScheduler::Stop();
   520         CActiveScheduler::Stop();
   500         iShutdown = ETrue;
   521         iShutdown = ETrue;
   501         }
   522         }
   502     }
   523     }
   503 
   524 
   511     CFbsBitmap* aBitmap, TThumbnailServerRequestId aRequestId )
   532     CFbsBitmap* aBitmap, TThumbnailServerRequestId aRequestId )
   512     {
   533     {
   513     if( !aBitmap )
   534     if( !aBitmap )
   514         {
   535         {
   515         TN_DEBUG1( "CThumbnailServer::AddBitmapToPoolL() - KErrArgument");
   536         TN_DEBUG1( "CThumbnailServer::AddBitmapToPoolL() - KErrArgument");
       
   537         OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_ADDBITMAPTOPOOLL, "CThumbnailServer::AddBitmapToPoolL - KErrArgument" );
   516         User::Leave( KErrArgument );
   538         User::Leave( KErrArgument );
   517         }
   539         }
   518     TN_DEBUG4( 
   540     TN_DEBUG4( 
   519         "CThumbnailServer::AddBitmapToPoolL(aSession=0x%08x, aBitmap=0x%08x), handle=%d", aSession, aBitmap, aBitmap->Handle());
   541         "CThumbnailServer::AddBitmapToPoolL(aSession=0x%08x, aBitmap=0x%08x), handle=%d", aSession, aBitmap, aBitmap->Handle());
   520 
   542 
   521     TThumbnailBitmapRef* ptr = iBitmapPool.Find( aBitmap->Handle());
   543     TThumbnailBitmapRef* ptr = iBitmapPool.Find( aBitmap->Handle());
   522 
   544 
   523     TN_DEBUG2( "CThumbnailServer::AddBitmapToPoolL() - req id = %d", aRequestId.iRequestId );
   545     TN_DEBUG2( "CThumbnailServer::AddBitmapToPoolL() - req id = %d", aRequestId.iRequestId );
       
   546     OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_ADDBITMAPTOPOOLL, "CThumbnailServer::AddBitmapToPoolL;aRequestId.iRequestId=%u", aRequestId.iRequestId );
   524     
   547     
   525     if ( ptr )
   548     if ( ptr )
   526         {
   549         {
   527         ptr->iRefCount++;
   550         ptr->iRefCount++;
   528         }
   551         }
   537         iBitmapPool.InsertL( aBitmap->Handle(), ref );
   560         iBitmapPool.InsertL( aBitmap->Handle(), ref );
   538         }
   561         }
   539     
   562     
   540 #ifdef _DEBUG
   563 #ifdef _DEBUG
   541     TN_DEBUG2( "CThumbnailServer::BITMAP-POOL-COUNTER----------, Bitmaps = %d", iBitmapPool.Count() );
   564     TN_DEBUG2( "CThumbnailServer::BITMAP-POOL-COUNTER----------, Bitmaps = %d", iBitmapPool.Count() );
       
   565     OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_ADDBITMAPTOPOOLL, "CThumbnailServer::AddBitmapToPoolL;iBitmapPool.Count()=%d", iBitmapPool.Count() );
   542 #endif
   566 #endif
   543     }
   567     }
   544 
   568 
   545 
   569 
   546 // -----------------------------------------------------------------------------
   570 // -----------------------------------------------------------------------------
   551     const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize,
   575     const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize,
   552     const TInt64 aModified, const TBool aThumbFromPath, const TBool aCheckExist )
   576     const TInt64 aModified, const TBool aThumbFromPath, const TBool aCheckExist )
   553     {
   577     {
   554     TN_DEBUG6( 
   578     TN_DEBUG6( 
   555         "CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped );
   579         "CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped );
       
   580     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_STORETHUMBNAILL, "CThumbnailServer::StoreThumbnailL;aBitmap=%o", aBitmap );
       
   581     OstTraceExt1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_STORETHUMBNAILL, "CThumbnailServer::StoreThumbnailL;aPath=%S", aPath );
       
   582     OstTraceExt3( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_STORETHUMBNAILL, "CThumbnailServer::StoreThumbnailL;aOriginalSize.iWidth=%d;aOriginalSize.iHeight=%d;aCropped=%u", aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped );
       
   583     
   556 #ifdef _DEBUG
   584 #ifdef _DEBUG
   557     TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode());
   585     TN_DEBUG2( "CThumbnailServer::StoreThumbnailL() - iScaledBitmap displaymode is %d", aBitmap->DisplayMode());
       
   586     OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSERVER_STORETHUMBNAILL, "CThumbnailServer::StoreThumbnailL;aBitmap->DisplayMode()=%u", aBitmap->DisplayMode() );
   558 #endif
   587 #endif
   559     
   588     
   560     if (!aCheckExist)
   589     if (!aCheckExist)
   561         {
   590         {
   562         StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
   591         StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
   568                        aCropped, aThumbnailSize, aModified, aThumbFromPath, EFalse );
   597                        aCropped, aThumbnailSize, aModified, aThumbFromPath, EFalse );
   569         }
   598         }
   570     else
   599     else
   571         {
   600         {
   572         TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!");
   601         TN_DEBUG1( "CThumbnailServer::StoreThumbnailL() - file doesn't exists anymore, skip store!");
       
   602         OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSERVER_STORETHUMBNAILL, "CThumbnailServer::StoreThumbnailL - file doesn't exists anymore, skip store!" );
   573         }
   603         }
   574     
   604     
   575     if( iFetchedChecker )    
   605     if( iFetchedChecker )    
   576         {
   606         {
   577         iFetchedChecker->SetFetchResult( aPath, aThumbnailSize, KErrNone );
   607         iFetchedChecker->SetFetchResult( aPath, aThumbnailSize, KErrNone );
   585 //
   615 //
   586 void CThumbnailServer::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* &
   616 void CThumbnailServer::FetchThumbnailL( const TDesC& aPath, CFbsBitmap* &
   587     aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize )
   617     aThumbnail, TDesC8* & aData, const TThumbnailSize aThumbnailSize, TSize &aOriginalSize )
   588     {
   618     {
   589     TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aPath=%S aThumbnailSize=%d)", &aPath, aThumbnailSize );
   619     TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aPath=%S aThumbnailSize=%d)", &aPath, aThumbnailSize );
       
   620     OstTraceExt2( TRACE_NORMAL, CTHUMBNAILSERVER_FETCHTHUMBNAILL, "CThumbnailServer::FetchThumbnailL;aPath=%S;aThumbnailSize=%hu", aPath, aThumbnailSize );
   590     if( iFetchedChecker )
   621     if( iFetchedChecker )
   591         {
   622         {
   592         TInt err( iFetchedChecker->LastFetchResult( aPath, aThumbnailSize ) );
   623         TInt err( iFetchedChecker->LastFetchResult( aPath, aThumbnailSize ) );
   593         if ( err == KErrNone ) // To avoid useless sql gets that fails for sure
   624         if ( err == KErrNone ) // To avoid useless sql gets that fails for sure
   594             {
   625             {
   626 // -----------------------------------------------------------------------------
   657 // -----------------------------------------------------------------------------
   627 //
   658 //
   628 void CThumbnailServer::DeleteBitmapFromPool( TInt aHandle )
   659 void CThumbnailServer::DeleteBitmapFromPool( TInt aHandle )
   629     {
   660     {
   630     TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d)", aHandle );
   661     TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d)", aHandle );
       
   662     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_DELETEBITMAPFROMPOOL, "CThumbnailServer::DeleteBitmapFromPool;aHandle=%d", aHandle );
   631 
   663 
   632     TThumbnailBitmapRef* ptr = iBitmapPool.Find( aHandle );
   664     TThumbnailBitmapRef* ptr = iBitmapPool.Find( aHandle );
   633     if ( ptr )
   665     if ( ptr )
   634         {
   666         {
   635         ptr->iRefCount--;
   667         ptr->iRefCount--;
   636         if ( !ptr->iRefCount )
   668         if ( !ptr->iRefCount )
   637             {
   669             {
   638             TN_DEBUG3( 
   670             TN_DEBUG3( 
   639                 "CThumbnailServer::DeleteBitmapFromPool(%d) -- deleting 0x%08x)", aHandle, ptr );
   671                 "CThumbnailServer::DeleteBitmapFromPool(%d) -- deleting 0x%08x)", aHandle, ptr );
       
   672             OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_DELETEBITMAPFROMPOOL, "CThumbnailServer::DeleteBitmapFromPool -- deleting;ptr=%o", ptr );
   640             delete ptr->iBitmap;
   673             delete ptr->iBitmap;
   641             ptr->iBitmap = NULL;
   674             ptr->iBitmap = NULL;
   642             iBitmapPool.Remove( aHandle );
   675             iBitmapPool.Remove( aHandle );
   643             TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool -- items left %d", iBitmapPool.Count() );
   676             TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool -- items left %d", iBitmapPool.Count() );
       
   677             OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_DELETEBITMAPFROMPOOL, "CThumbnailServer::DeleteBitmapFromPool  -- items left;iBitmapPool.Count()=%d", iBitmapPool.Count() );
   644             }
   678             }
   645         else
   679         else
   646             {
   680             {
   647             TN_DEBUG3( 
   681             TN_DEBUG3( 
   648                 "CThumbnailServer::DeleteBitmapFromPool(%d) -- refcount now %d",
   682                 "CThumbnailServer::DeleteBitmapFromPool(%d) -- refcount now %d",
   649                 aHandle, ptr->iRefCount );
   683                 aHandle, ptr->iRefCount );
       
   684             OstTraceExt2( TRACE_NORMAL, DUP3_CTHUMBNAILSERVER_DELETEBITMAPFROMPOOL, "CThumbnailServer::DeleteBitmapFromPool) -- refcount now;aHandle=%d;ptr->iRefCount=%d", aHandle, ptr->iRefCount );
   650             }
   685             }
   651         }
   686         }
   652     else
   687     else
   653         {
   688         {
   654         //__ASSERT_DEBUG(( EFalse ), ThumbnailPanic( EThumbnailBitmapNotReleased ));
   689         //__ASSERT_DEBUG(( EFalse ), ThumbnailPanic( EThumbnailBitmapNotReleased ));
   655         TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!",
   690         TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!",
   656             aHandle );
   691             aHandle );
       
   692         OstTrace1( TRACE_NORMAL, DUP4_CTHUMBNAILSERVER_DELETEBITMAPFROMPOOL, "CThumbnailServer::DeleteBitmapFromPool  -- not found!;aHandle=%d", aHandle );
   657         }
   693         }
   658     }
   694     }
   659 
   695 
   660 
   696 
   661 // -----------------------------------------------------------------------------
   697 // -----------------------------------------------------------------------------
   663 // -----------------------------------------------------------------------------
   699 // -----------------------------------------------------------------------------
   664 //
   700 //
   665 void CThumbnailServer::DeleteThumbnailsL( const TDesC& aPath )
   701 void CThumbnailServer::DeleteThumbnailsL( const TDesC& aPath )
   666     {
   702     {
   667     TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath);
   703     TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsL(%S)", &aPath);
       
   704     OstTraceExt1( TRACE_NORMAL, CTHUMBNAILSERVER_DELETETHUMBNAILSL, "CThumbnailServer::DeleteThumbnailsL;aPath=%S", aPath );
   668     
   705     
   669     StoreForPathL( aPath )->DeleteThumbnailsL( aPath );
   706     StoreForPathL( aPath )->DeleteThumbnailsL( aPath );
   670     
   707     
   671     if( iFetchedChecker ) 
   708     if( iFetchedChecker ) 
   672         {
   709         {
   698     
   735     
   699     if ( drm && filetype != ContentAccess::EOma1Dcf )
   736     if ( drm && filetype != ContentAccess::EOma1Dcf )
   700         {
   737         {
   701         // cannot handle other than Oma DRM 1.x files
   738         // cannot handle other than Oma DRM 1.x files
   702         TN_DEBUG1( "CThumbnailStore::ResolveMimeTypeL()- only OMA DRM 1.0 supported");
   739         TN_DEBUG1( "CThumbnailStore::ResolveMimeTypeL()- only OMA DRM 1.0 supported");
       
   740         OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_RESOLVEMIMETYPEL, "CThumbnailServer::ResolveMimeTypeL - only OMA DRM 1.0 supported" );
   703         User::Leave(KErrNotSupported);
   741         User::Leave(KErrNotSupported);
   704         }    
   742         }    
   705     
   743     
   706     TDataRecognitionResult res;
   744     TDataRecognitionResult res;
   707     if ( iRecognizer.Handle() == KNullHandle )
   745     if ( iRecognizer.Handle() == KNullHandle )
   732     {
   770     {
   733 #ifdef _DEBUG
   771 #ifdef _DEBUG
   734     TBuf < KMaxDataTypeLength > buf; // 16-bit descriptor for debug prints
   772     TBuf < KMaxDataTypeLength > buf; // 16-bit descriptor for debug prints
   735     buf.Copy( aMimeType );
   773     buf.Copy( aMimeType );
   736     TN_DEBUG2( "CThumbnailServer::ResolveProviderL(%S)", &buf );
   774     TN_DEBUG2( "CThumbnailServer::ResolveProviderL(%S)", &buf );
       
   775     OstTraceExt1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_RESOLVEMIMETYPEL, "CThumbnailServer::ResolveMimeTypeL;buf=%S", buf );
   737 #endif 
   776 #endif 
   738 
   777 
   739     CThumbnailProvider* ret = NULL;
   778     CThumbnailProvider* ret = NULL;
   740 
   779 
   741     TInt separatorPos = aMimeType.Locate( KThumbnailMimeSeparatorChar );
   780     TInt separatorPos = aMimeType.Locate( KThumbnailMimeSeparatorChar );
   756                 !pSubType.CompareF( subType ))
   795                 !pSubType.CompareF( subType ))
   757                 {
   796                 {
   758 #ifdef _DEBUG
   797 #ifdef _DEBUG
   759                 TN_DEBUG3( 
   798                 TN_DEBUG3( 
   760                     "CThumbnailServer::ResolveProviderL(%S) -- using provider 0x%08x", &buf, iPluginInfoArray[i]->ImplementationUid().iUid );
   799                     "CThumbnailServer::ResolveProviderL(%S) -- using provider 0x%08x", &buf, iPluginInfoArray[i]->ImplementationUid().iUid );
       
   800                 OstTraceExt1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_RESOLVEPROVIDERL, "CThumbnailServer::ResolveProviderL;buf=%S", buf );
       
   801                 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_RESOLVEPROVIDERL, "CThumbnailServer::ResolveProviderL;iPluginInfoArray[i]->ImplementationUid().iUid=%o", iPluginInfoArray[i]->ImplementationUid().iUid );
   761 #endif 
   802 #endif 
   762                 ret = GetProviderL( iPluginInfoArray[i]->ImplementationUid());
   803                 ret = GetProviderL( iPluginInfoArray[i]->ImplementationUid());
   763                 }
   804                 }
   764             }
   805             }
   765         }
   806         }
   767         {
   808         {
   768 #ifdef _DEBUG
   809 #ifdef _DEBUG
   769         TN_DEBUG2( 
   810         TN_DEBUG2( 
   770             "CThumbnailServer::ResolveProviderL(%S) -- provider not found",
   811             "CThumbnailServer::ResolveProviderL(%S) -- provider not found",
   771             &buf );
   812             &buf );
       
   813         OstTraceExt1( TRACE_NORMAL, CTHUMBNAILSERVER_RESOLVEPROVIDERL, "CThumbnailServer::ResolveProviderL;buf=%S", buf );
   772 #endif 
   814 #endif 
   773         User::Leave( KErrNotSupported );
   815         User::Leave( KErrNotSupported );
   774         }
   816         }
   775     return ret;
   817     return ret;
   776     }
   818     }
   795         TN_DEBUG2( 
   837         TN_DEBUG2( 
   796             "CThumbnailServer::GetProviderL() -- loading plug-in, UID 0x%08x",
   838             "CThumbnailServer::GetProviderL() -- loading plug-in, UID 0x%08x",
   797             aImplUid );
   839             aImplUid );
   798         res = CThumbnailProvider::NewL( aImplUid );
   840         res = CThumbnailProvider::NewL( aImplUid );
   799         TN_DEBUG1( "CThumbnailServer::GetProviderL() -- loading complete" );
   841         TN_DEBUG1( "CThumbnailServer::GetProviderL() -- loading complete" );
       
   842         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_GETPROVIDERL, "CThumbnailServer::GetProviderL -- loading complete" );
   800         CleanupStack::PushL( res );
   843         CleanupStack::PushL( res );
   801         iProviders.InsertL( aImplUid.iUid, res );
   844         iProviders.InsertL( aImplUid.iUid, res );
   802         CleanupStack::Pop( res );
   845         CleanupStack::Pop( res );
   803         }
   846         }
   804 
   847 
   811 // -----------------------------------------------------------------------------
   854 // -----------------------------------------------------------------------------
   812 //
   855 //
   813 void CThumbnailServer::PreLoadProviders(  )
   856 void CThumbnailServer::PreLoadProviders(  )
   814     {
   857     {
   815     TN_DEBUG1( "CThumbnailServer::PreLoadProvidersL()" );
   858     TN_DEBUG1( "CThumbnailServer::PreLoadProvidersL()" );
       
   859     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_PRELOADPROVIDERS, "CThumbnailServer::PreLoadProviders" );
   816     TInt err(KErrNone);
   860     TInt err(KErrNone);
   817     
   861     
   818     for(TInt i=0; i< iPluginInfoArray.Count(); i++)
   862     for(TInt i=0; i< iPluginInfoArray.Count(); i++)
   819         {
   863         {
   820         TRAP(err, GetProviderL( iPluginInfoArray[i]->ImplementationUid()));
   864         TRAP(err, GetProviderL( iPluginInfoArray[i]->ImplementationUid()));
   850     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   894     const TThumbnailBitmapRef* ref = bpiter.NextValue();
   851 
   895 
   852     while ( ref )
   896     while ( ref )
   853         {       
   897         {       
   854         TN_DEBUG2( "CThumbnailServer::DequeTask() - ref->iRequestId = %d", ref->iRequestId );
   898         TN_DEBUG2( "CThumbnailServer::DequeTask() - ref->iRequestId = %d", ref->iRequestId );
       
   899         OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_DEQUETASK, "CThumbnailServer::DequeTask;ref->iRequestId=%u", ref->iRequestId );
   855 
   900 
   856         if ( ref->iSession == aRequestId.iSession && 
   901         if ( ref->iSession == aRequestId.iSession && 
   857              ref->iRequestId == aRequestId.iRequestId )
   902              ref->iRequestId == aRequestId.iRequestId )
   858             {            
   903             {            
   859             delete ref->iBitmap;
   904             delete ref->iBitmap;
   860             bpiter.RemoveCurrent();                        
   905             bpiter.RemoveCurrent();                        
   861                         
   906                         
   862             TN_DEBUG2( "CThumbnailServer::DequeTask() - deleted bitmap, left=%d", 
   907             TN_DEBUG2( "CThumbnailServer::DequeTask() - deleted bitmap, left=%d", 
   863                     iBitmapPool.Count());
   908                     iBitmapPool.Count());
       
   909             OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_DEQUETASK, "CThumbnailServer::DequeTask;iBitmapPool.Count()=%d", iBitmapPool.Count() );
   864             }
   910             }
   865         
   911         
   866         ref = bpiter.NextValue();        
   912         ref = bpiter.NextValue();        
   867         }
   913         }
   868 
   914 
   930 // -----------------------------------------------------------------------------
   976 // -----------------------------------------------------------------------------
   931 //
   977 //
   932 CThumbnailStore* CThumbnailServer::StoreForDriveL( const TInt aDrive )
   978 CThumbnailStore* CThumbnailServer::StoreForDriveL( const TInt aDrive )
   933     {
   979     {
   934     TN_DEBUG2( "CThumbnailServer::StoreForDriveL() drive=%d", aDrive );
   980     TN_DEBUG2( "CThumbnailServer::StoreForDriveL() drive=%d", aDrive );
       
   981     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_STOREFORDRIVEL, "CThumbnailServer::StoreForDriveL;aDrive=%d", aDrive );
   935     
   982     
   936     if(iUnmountedDrives.Find( aDrive ) >= KErrNone)
   983     if(iUnmountedDrives.Find( aDrive ) >= KErrNone)
   937         {
   984         {
   938         TN_DEBUG1( "CThumbnailServer::StoreForDriveL() unmount in progress, skip!");
   985         TN_DEBUG1( "CThumbnailServer::StoreForDriveL() unmount in progress, skip!");
       
   986         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_STOREFORDRIVEL, "CThumbnailServer::StoreForDriveL - unmount in progress, skip!" );
   939         User::Leave( KErrDisMounted );
   987         User::Leave( KErrDisMounted );
   940         }
   988         }
   941     
   989     
   942     CThumbnailStore** resPtr = iStores.Find( aDrive );
   990     CThumbnailStore** resPtr = iStores.Find( aDrive );
   943     CThumbnailStore* res = NULL;
   991     CThumbnailStore* res = NULL;
   949     else
   997     else
   950         {
   998         {
   951         if( iFormatting )
   999         if( iFormatting )
   952            {
  1000            {
   953            TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - FORMATTING! - ABORT");
  1001            TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - FORMATTING! - ABORT");
       
  1002            OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_STOREFORDRIVEL, "CThumbnailServer::StoreForDriveL - FORMATTING! - ABORT" );
   954            User::Leave( KErrNotSupported );
  1003            User::Leave( KErrNotSupported );
   955            } 
  1004            } 
   956         
  1005         
   957         TVolumeInfo volumeInfo;
  1006         TVolumeInfo volumeInfo;
   958         TInt err = iFs.Volume( volumeInfo, aDrive );
  1007         TInt err = iFs.Volume( volumeInfo, aDrive );
   959         
  1008         
   960         if ( err )
  1009         if ( err )
   961             {
  1010             {
   962             // Locked
  1011             // Locked
   963             TN_DEBUG2( "CThumbnailServer::StoreForDriveL() - err %d", err);
  1012             TN_DEBUG2( "CThumbnailServer::StoreForDriveL() - err %d", err);
       
  1013             OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSERVER_STOREFORDRIVEL, "CThumbnailServer::StoreForDriveL;err=%d", err );
   964             User::Leave( err);
  1014             User::Leave( err);
   965             }
  1015             }
   966         else if( volumeInfo.iDrive.iMediaAtt& KMediaAttLocked )
  1016         else if( volumeInfo.iDrive.iMediaAtt& KMediaAttLocked )
   967             {
  1017             {
   968             TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - locked");
  1018             TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - locked");
       
  1019             OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSERVER_STOREFORDRIVEL, "CThumbnailServer::StoreForDriveL - locked" );
   969             User::Leave( KErrAccessDenied );
  1020             User::Leave( KErrAccessDenied );
   970             }
  1021             }
   971 		else if ( volumeInfo.iDrive.iDriveAtt& KDriveAttRom ||
  1022 		else if ( volumeInfo.iDrive.iDriveAtt& KDriveAttRom ||
   972             volumeInfo.iDrive.iDriveAtt& KDriveAttRemote ||
  1023             volumeInfo.iDrive.iDriveAtt& KDriveAttRemote ||
   973             volumeInfo.iDrive.iMediaAtt& KMediaAttWriteProtected )
  1024             volumeInfo.iDrive.iMediaAtt& KMediaAttWriteProtected )
   974             {
  1025             {
   975             // We support ROM disks and remote disks in read only mode.
  1026             // We support ROM disks and remote disks in read only mode.
   976             TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - rom/remote/write protected");
  1027             TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - rom/remote/write protected");
       
  1028             OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSERVER_STOREFORDRIVEL, "CThumbnailServer::StoreForDriveL - rom/remote/write protected" );
   977             res = CThumbnailStore::NewL( iFs, aDrive, iImei, this, ETrue );
  1029             res = CThumbnailStore::NewL( iFs, aDrive, iImei, this, ETrue );
   978             }
  1030             }
   979         else
  1031         else
   980             {
  1032             {
   981             TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - normal");
  1033             TN_DEBUG1( "CThumbnailServer::StoreForDriveL() - normal");
       
  1034             OstTrace0( TRACE_NORMAL, DUP6_CTHUMBNAILSERVER_STOREFORDRIVEL, "CThumbnailServer::StoreForDriveL - normal" );
   982             res = CThumbnailStore::NewL( iFs, aDrive, iImei, this, EFalse );
  1035             res = CThumbnailStore::NewL( iFs, aDrive, iImei, this, EFalse );
   983             }
  1036             }
   984 			
  1037 			
   985         CleanupStack::PushL( res );
  1038         CleanupStack::PushL( res );
   986         iStores.InsertL( aDrive, res );
  1039         iStores.InsertL( aDrive, res );
  1004 CThumbnailStore* CThumbnailServer::StoreForPathL( const TDesC& aPath )
  1057 CThumbnailStore* CThumbnailServer::StoreForPathL( const TDesC& aPath )
  1005     {
  1058     {
  1006     if(aPath.Length() < 3 || aPath.Length() > KMaxPath)
  1059     if(aPath.Length() < 3 || aPath.Length() > KMaxPath)
  1007         {
  1060         {
  1008         TN_DEBUG1( "CThumbnailServer::StoreForPathL() - KErrArgument");
  1061         TN_DEBUG1( "CThumbnailServer::StoreForPathL() - KErrArgument");
       
  1062         OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_STOREFORPATHL, "CThumbnailServer::StoreForPathL - KErrArgument" );
  1009         User::Leave(KErrArgument);
  1063         User::Leave(KErrArgument);
  1010         }
  1064         }
  1011     TInt drive = 0;
  1065     TInt drive = 0;
  1012     User::LeaveIfError( RFs::CharToDrive( aPath[0], drive ));
  1066     User::LeaveIfError( RFs::CharToDrive( aPath[0], drive ));
  1013     return StoreForDriveL( drive );
  1067     return StoreForDriveL( drive );
  1048             TInt err = iFs.Volume( volumeInfo, i );
  1102             TInt err = iFs.Volume( volumeInfo, i );
  1049             
  1103             
  1050             if (!err)
  1104             if (!err)
  1051                 {
  1105                 {
  1052                 TN_DEBUG2( "CThumbnailServer::OpenStoresL() StoreForDriveL %d", i);
  1106                 TN_DEBUG2( "CThumbnailServer::OpenStoresL() StoreForDriveL %d", i);
       
  1107                 OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_OPENSTORESL, "CThumbnailServer::OpenStoresL;i=%d", i );
  1053                 
  1108                 
  1054                 // ignore errors
  1109                 // ignore errors
  1055                 TRAP_IGNORE( StoreForDriveL( i ));
  1110                 TRAP_IGNORE( StoreForDriveL( i ));
  1056                 
  1111                 
  1057                 driveCountInt--;
  1112                 driveCountInt--;
  1066 // -----------------------------------------------------------------------------
  1121 // -----------------------------------------------------------------------------
  1067 //
  1122 //
  1068 void CThumbnailServer::CloseStoreForDriveL( const TInt aDrive )
  1123 void CThumbnailServer::CloseStoreForDriveL( const TInt aDrive )
  1069     {
  1124     {
  1070     TN_DEBUG2( "CThumbnailServer::CloseStoreForDriveL drive=%d", aDrive);
  1125     TN_DEBUG2( "CThumbnailServer::CloseStoreForDriveL drive=%d", aDrive);
       
  1126     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_CLOSESTOREFORDRIVEL, "CThumbnailServer::CloseStoreForDriveL;aDrive=%d", aDrive );
  1071     CThumbnailStore** store = iStores.Find( aDrive );
  1127     CThumbnailStore** store = iStores.Find( aDrive );
  1072     
  1128     
  1073     StartUnmountTimeout( aDrive);
  1129     StartUnmountTimeout( aDrive);
  1074     
  1130     
  1075     if (store)
  1131     if (store)
  1132         
  1188         
  1133         // if removable drive, add observer
  1189         // if removable drive, add observer
  1134         if (!err && driveInfo.iDriveAtt& KDriveAttRemovable)
  1190         if (!err && driveInfo.iDriveAtt& KDriveAttRemovable)
  1135             {
  1191             {
  1136             TN_DEBUG2( "CThumbnailServer::AddOnMountObserver drive=%d", drive);
  1192             TN_DEBUG2( "CThumbnailServer::AddOnMountObserver drive=%d", drive);
       
  1193             OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_ADDUNMOUNTOBSERVERSL, "CThumbnailServer::AddUnmountObserversL;drive=%d", drive );
  1137             CThumbnailDiskUnmountObserver* obs = CThumbnailDiskUnmountObserver::NewL( iFs, drive, this );
  1194             CThumbnailDiskUnmountObserver* obs = CThumbnailDiskUnmountObserver::NewL( iFs, drive, this );
  1138             CleanupStack::PushL( obs );
  1195             CleanupStack::PushL( obs );
  1139             iUnmountObservers.AppendL( obs );
  1196             iUnmountObservers.AppendL( obs );
  1140             CleanupStack::Pop( obs );
  1197             CleanupStack::Pop( obs );
  1141             }
  1198             }
  1147 // ---------------------------------------------------------------------------
  1204 // ---------------------------------------------------------------------------
  1148 //
  1205 //
  1149 void CThumbnailServer::MemoryCardStatusChangedL()
  1206 void CThumbnailServer::MemoryCardStatusChangedL()
  1150     {
  1207     {
  1151     TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL in()" );
  1208     TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL in()" );
       
  1209     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_MEMORYCARDSTATUSCHANGEDL, "CThumbnailServer::MemoryCardStatusChangedL - in" );
  1152     TDriveList driveList;
  1210     TDriveList driveList;
  1153     TInt drive; 
  1211     TInt drive; 
  1154     TVolumeInfo volumeInfo;
  1212     TVolumeInfo volumeInfo;
  1155     TDriveInfo driveInfo;
  1213     TDriveInfo driveInfo;
  1156         
  1214         
  1172         if (!err && !err_drive 
  1230         if (!err && !err_drive 
  1173                 && driveInfo.iType != EMediaNotPresent
  1231                 && driveInfo.iType != EMediaNotPresent
  1174                 && driveInfo.iDriveAtt& KDriveAttRemovable )
  1232                 && driveInfo.iDriveAtt& KDriveAttRemovable )
  1175             {
  1233             {
  1176             TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL mount drive==%d", drive);
  1234             TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL mount drive==%d", drive);
       
  1235             OstTrace1( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_MEMORYCARDSTATUSCHANGEDL, "CThumbnailServer::MemoryCardStatusChangedL;drive=%d", drive );
  1177             
  1236             
  1178             CThumbnailStore** resPtr = iStores.Find( drive );
  1237             CThumbnailStore** resPtr = iStores.Find( drive );
  1179 
  1238 
  1180             if ( resPtr )
  1239             if ( resPtr )
  1181                 {
  1240                 {
  1182                 TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() already mounted, skip %d", drive);
  1241                 TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() already mounted, skip %d", drive);
       
  1242                 OstTrace1( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_MEMORYCARDSTATUSCHANGEDL, "CThumbnailServer::MemoryCardStatusChangedL;drive=%d", drive );
  1183                 continue;
  1243                 continue;
  1184                 }
  1244                 }
  1185             
  1245             
  1186             // ignore errors
  1246             // ignore errors
  1187             TRAP_IGNORE( StoreForDriveL( drive ));
  1247             TRAP_IGNORE( StoreForDriveL( drive ));
  1191             TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() driveStatus = %d", driveStatus);
  1251             TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() driveStatus = %d", driveStatus);
  1192             if (!(driveStatus & DriveInfo::EDriveUsbMemory) && 
  1252             if (!(driveStatus & DriveInfo::EDriveUsbMemory) && 
  1193 			    !(driveStatus & DriveInfo::EDriveRemote))
  1253 			    !(driveStatus & DriveInfo::EDriveRemote))
  1194                 {
  1254                 {
  1195                 TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() update KItemsleft = %d", KErrNotReady);
  1255                 TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() update KItemsleft = %d", KErrNotReady);
       
  1256                 OstTrace1( TRACE_NORMAL, DUP3_CTHUMBNAILSERVER_MEMORYCARDSTATUSCHANGEDL, "CThumbnailServer::MemoryCardStatusChangedL;KErrNotReady=%d - update KItemsleft", KErrNotReady );
  1196                 RProperty::Set(KTAGDPSNotification, KItemsleft, KErrNotReady );
  1257                 RProperty::Set(KTAGDPSNotification, KItemsleft, KErrNotReady );
  1197                 }
  1258                 }
  1198 			
  1259 			
  1199             TInt index = iUnmountedDrives.Find( drive );
  1260             TInt index = iUnmountedDrives.Find( drive );
  1200             
  1261             
  1204                 }
  1265                 }
  1205             
  1266             
  1206             if(!iUnmountedDrives.Count()&& iUnmount && iUnmount->IsActive())
  1267             if(!iUnmountedDrives.Count()&& iUnmount && iUnmount->IsActive())
  1207                 {
  1268                 {
  1208                 TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL() cancel unmount timer");
  1269                 TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL() cancel unmount timer");
       
  1270                 OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSERVER_MEMORYCARDSTATUSCHANGEDL, "CThumbnailServer::MemoryCardStatusChangedL - cancel unmount timer" );
  1209                 iUnmount->Cancel();
  1271                 iUnmount->Cancel();
  1210                 }
  1272                 }
  1211             }
  1273             }
  1212         
  1274         
  1213         //dismount -- if removable drive, close store
  1275         //dismount -- if removable drive, close store
  1214         else if(err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable )
  1276         else if(err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable )
  1215             {
  1277             {
  1216             TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() unmount drive==%d", drive);
  1278             TN_DEBUG2( "CThumbnailServer::MemoryCardStatusChangedL() unmount drive==%d", drive);
       
  1279             OstTrace1( TRACE_NORMAL, DUP5_CTHUMBNAILSERVER_MEMORYCARDSTATUSCHANGEDL, "CThumbnailServer::MemoryCardStatusChangedL - unmount drive;drive=%d", drive );
  1217             CloseStoreForDriveL( drive);
  1280             CloseStoreForDriveL( drive);
  1218             }
  1281             }
  1219         }
  1282         }
  1220 
  1283 
  1221     TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL out()" );
  1284     TN_DEBUG1( "CThumbnailServer::MemoryCardStatusChangedL out()" );
       
  1285     OstTrace0( TRACE_NORMAL, DUP6_CTHUMBNAILSERVER_MEMORYCARDSTATUSCHANGEDL, "CThumbnailServer::MemoryCardStatusChangedL - out" );
  1222     }
  1286     }
  1223 
  1287 
  1224 
  1288 
  1225 // -----------------------------------------------------------------------------
  1289 // -----------------------------------------------------------------------------
  1226 // Get the required size (in characters) for a buffer that contains the
  1290 // Get the required size (in characters) for a buffer that contains the
  1275 //
  1339 //
  1276 TBool CThumbnailServer::UpdateThumbnailsL( const TDesC& aPath,
  1340 TBool CThumbnailServer::UpdateThumbnailsL( const TDesC& aPath,
  1277                                            const TInt /*aOrientation*/, const TInt64 aModified )
  1341                                            const TInt /*aOrientation*/, const TInt64 aModified )
  1278     {
  1342     {
  1279     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()");
  1343     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()");
       
  1344     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_UPDATETHUMBNAILSL, "CThumbnailServer::UpdateThumbnailsL" );
  1280     
  1345     
  1281     // 1. check path change
  1346     // 1. check path change
  1282     // 2. check timestamp change
  1347     // 2. check timestamp change
  1283     TBool modifiedChanged = EFalse;
  1348     TBool modifiedChanged = EFalse;
  1284     
  1349     
  1285     CThumbnailStore* store = StoreForPathL( aPath );
  1350     CThumbnailStore* store = StoreForPathL( aPath );
  1286    
  1351    
  1287     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist");
  1352     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist");
       
  1353     OstTrace0( TRACE_NORMAL, DUP2_CTHUMBNAILSERVER_UPDATETHUMBNAILSL, "CThumbnailServer::UpdateThumbnailsL - exist" );
  1288         
  1354         
  1289     TBool exists = store->CheckModifiedByPathL(aPath, aModified, modifiedChanged);
  1355     TBool exists = store->CheckModifiedByPathL(aPath, aModified, modifiedChanged);
  1290        
  1356        
  1291     if(!exists)
  1357     if(!exists)
  1292         {
  1358         {
  1293         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exists NO");
  1359         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exists NO");
       
  1360     	OstTrace0( TRACE_NORMAL, DUP3_CTHUMBNAILSERVER_UPDATETHUMBNAILSL, "CThumbnailServer::UpdateThumbnailsL - exists NO" );
  1294         //not found, needs to be generated
  1361         //not found, needs to be generated
  1295         return EFalse;
  1362         return EFalse;
  1296         }
  1363         }
  1297     
  1364     
  1298     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?");
  1365     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?");
       
  1366     OstTrace0( TRACE_NORMAL, DUP4_CTHUMBNAILSERVER_UPDATETHUMBNAILSL, "CThumbnailServer::UpdateThumbnailsL - modified ?" );
  1299     
  1367     
  1300     if (modifiedChanged)
  1368     if (modifiedChanged)
  1301         {
  1369         {
  1302         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES");
  1370         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES");
       
  1371         OstTrace0( TRACE_NORMAL, DUP5_CTHUMBNAILSERVER_UPDATETHUMBNAILSL, "CThumbnailServer::UpdateThumbnailsL - modified YES" );
  1303             
  1372             
  1304         // delete old thumbs
  1373         // delete old thumbs
  1305         store->DeleteThumbnailsL(aPath, ETrue);
  1374         store->DeleteThumbnailsL(aPath, ETrue);
  1306             
  1375             
  1307         if( iFetchedChecker ) 
  1376         if( iFetchedChecker ) 
  1312         // need to create new thumbs
  1381         // need to create new thumbs
  1313         }
  1382         }
  1314     else
  1383     else
  1315         {
  1384         {
  1316         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO");
  1385         TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO");
       
  1386         OstTrace0( TRACE_NORMAL, DUP6_CTHUMBNAILSERVER_UPDATETHUMBNAILSL, "CThumbnailServer::UpdateThumbnailsL - modified NO" );
  1317         
  1387         
  1318         // not modified
  1388         // not modified
  1319         return ETrue;
  1389         return ETrue;
  1320         }
  1390         }
  1321     
  1391     
  1322     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new");
  1392     TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new");
       
  1393     OstTrace0( TRACE_NORMAL, DUP7_CTHUMBNAILSERVER_UPDATETHUMBNAILSL, "CThumbnailServer::UpdateThumbnailsL - no thumbs found, create new" );
  1323     
  1394     
  1324     return EFalse;
  1395     return EFalse;
  1325     }
  1396     }
  1326 
  1397 
  1327 // -----------------------------------------------------------------------------
  1398 // -----------------------------------------------------------------------------
  1329 // -----------------------------------------------------------------------------
  1400 // -----------------------------------------------------------------------------
  1330 //
  1401 //
  1331 void CThumbnailServer::RenameThumbnailsL( const TDesC& aCurrentPath, const TDesC& aNewPath )
  1402 void CThumbnailServer::RenameThumbnailsL( const TDesC& aCurrentPath, const TDesC& aNewPath )
  1332     {
  1403     {
  1333     TN_DEBUG2( "CThumbnailServer::RenameThumbnailsL(%S)", &aCurrentPath);
  1404     TN_DEBUG2( "CThumbnailServer::RenameThumbnailsL(%S)", &aCurrentPath);
       
  1405     OstTraceExt1( TRACE_NORMAL, CTHUMBNAILSERVER_RENAMETHUMBNAILSL, "CThumbnailServer::RenameThumbnailsL;aCurrentPath=%S", aCurrentPath );
  1334     
  1406     
  1335     StoreForPathL( aCurrentPath )->RenameThumbnailsL( aCurrentPath, aNewPath );
  1407     StoreForPathL( aCurrentPath )->RenameThumbnailsL( aCurrentPath, aNewPath );
  1336     
  1408     
  1337     if( iFetchedChecker ) 
  1409     if( iFetchedChecker ) 
  1338         {
  1410         {
  1406         aMimeType = TDataType( KBmpMime );
  1478         aMimeType = TDataType( KBmpMime );
  1407         }
  1479         }
  1408     else if ( ext.CompareF( K3gpExt ) == 0 )
  1480     else if ( ext.CompareF( K3gpExt ) == 0 )
  1409         {
  1481         {
  1410         aMimeType = TDataType( KVideo3gppMime );
  1482         aMimeType = TDataType( KVideo3gppMime );
       
  1483         return KErrNotFound; 
       
  1484         // 3gp can contain video or audio, should go to recognizer
  1411         } 
  1485         } 
  1412     else if ( ext.CompareF( K3gppExt ) == 0 )
  1486     else if ( ext.CompareF( K3gppExt ) == 0 )
  1413         {
  1487         {
  1414         aMimeType = TDataType( KVideo3gppMime );
  1488         aMimeType = TDataType( KVideo3gppMime );
       
  1489         return KErrNotFound; 
       
  1490         // 3gp can contain video or audio, should go to recognizer
  1415         }
  1491         }
  1416     else if ( ext.CompareF( KAmrExt ) == 0 )
  1492     else if ( ext.CompareF( KAmrExt ) == 0 )
  1417         {
  1493         {
  1418         aMimeType = TDataType( KAudioAmrMime );
  1494         aMimeType = TDataType( KAudioAmrMime );
  1419         }
  1495         }
  1613         {
  1689         {
  1614         TRAP( result, CThumbnailServer::ThreadFunctionL());
  1690         TRAP( result, CThumbnailServer::ThreadFunctionL());
  1615         TN_DEBUG2( 
  1691         TN_DEBUG2( 
  1616             "CThumbnailServer::E32Main() -- thread function out, result=%d",
  1692             "CThumbnailServer::E32Main() -- thread function out, result=%d",
  1617             result );
  1693             result );
       
  1694         OstTrace1( TRACE_NORMAL, _E32MAIN, "::E32Main;result=%d - thread function out", result );
  1618         delete cleanup;
  1695         delete cleanup;
  1619         cleanup = NULL;
  1696         cleanup = NULL;
  1620         }
  1697         }
  1621     if ( result != KErrNone )
  1698     if ( result != KErrNone )
  1622         {
  1699         {
  1623         // Signal the client that server creation failed
  1700         // Signal the client that server creation failed
  1624         TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() in" );
  1701         TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() in" );
       
  1702         OstTrace0( TRACE_NORMAL, DUP2__E32MAIN, "::E32Main - in" );
  1625         RProcess::Rendezvous( result );
  1703         RProcess::Rendezvous( result );
  1626         TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() out" );
  1704         TN_DEBUG1( "CThumbnailServer::E32Main() -- Rendezvous() out" );
       
  1705         OstTrace0( TRACE_NORMAL, DUP1__E32MAIN, "::E32Main - out" );
  1627         }
  1706         }
  1628 
  1707 
  1629     __UHEAP_MARKEND;
  1708     __UHEAP_MARKEND;
  1630     return result;
  1709     return result;
  1631     }
  1710     }
  1656             
  1735             
  1657         // if removable drive, close store
  1736         // if removable drive, close store
  1658         if (!err && driveInfo.iDriveAtt& KDriveAttRemovable)
  1737         if (!err && driveInfo.iDriveAtt& KDriveAttRemovable)
  1659             {
  1738             {
  1660             TN_DEBUG2( "CThumbnailServer::CloseRemovableDrive drive=%d", drive);
  1739             TN_DEBUG2( "CThumbnailServer::CloseRemovableDrive drive=%d", drive);
       
  1740             OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_CLOSEREMOVABLEDRIVESL, "CThumbnailServer::CloseRemovableDrivesL;drive=%d", drive );
  1661             CloseStoreForDriveL(drive);
  1741             CloseStoreForDriveL(drive);
  1662             }
  1742             }
  1663         }
  1743         }
  1664     iProcessor->RemoveAllTasks();
  1744     iProcessor->RemoveAllTasks();
  1665     }
  1745     }
  1690             
  1770             
  1691         // if removable drive, open store
  1771         // if removable drive, open store
  1692         if (!err && driveInfo.iDriveAtt& KDriveAttRemovable)
  1772         if (!err && driveInfo.iDriveAtt& KDriveAttRemovable)
  1693             {
  1773             {
  1694             TN_DEBUG2( "CThumbnailServer::OpenRemovableDrive drive=%d", drive);
  1774             TN_DEBUG2( "CThumbnailServer::OpenRemovableDrive drive=%d", drive);
       
  1775             OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_OPENREMOVABLEDRIVESL, "CThumbnailServer::OpenRemovableDrivesL;drive=%d", drive );
  1695             StoreForDriveL(drive);
  1776             StoreForDriveL(drive);
  1696             }
  1777             }
  1697         }
  1778         }
  1698     }
  1779     }
  1699 
  1780 
  1712 // ---------------------------------------------------------------------------
  1793 // ---------------------------------------------------------------------------
  1713 //
  1794 //
  1714 void CThumbnailServer::FormatNotification( TBool aFormat )
  1795 void CThumbnailServer::FormatNotification( TBool aFormat )
  1715     {
  1796     {
  1716     TN_DEBUG2( "CThumbnailServer::FormatNotification(%d)", aFormat );
  1797     TN_DEBUG2( "CThumbnailServer::FormatNotification(%d)", aFormat );
       
  1798     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_FORMATNOTIFICATION, "CThumbnailServer::FormatNotification;aFormat=%d", aFormat );
  1717     
  1799     
  1718     if(aFormat)
  1800     if(aFormat)
  1719         {
  1801         {
  1720         TRAP_IGNORE( CloseRemovableDrivesL() );
  1802         TRAP_IGNORE( CloseRemovableDrivesL() );
  1721         }
  1803         }
  1730 // ---------------------------------------------------------------------------
  1812 // ---------------------------------------------------------------------------
  1731 //
  1813 //
  1732 TInt CThumbnailServer::ReconnectCallBack(TAny* aAny)
  1814 TInt CThumbnailServer::ReconnectCallBack(TAny* aAny)
  1733     {
  1815     {
  1734     TN_DEBUG1( "CThumbnailServer::ReconnectCallBack() - reconnect");
  1816     TN_DEBUG1( "CThumbnailServer::ReconnectCallBack() - reconnect");
       
  1817     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_RECONNECTCALLBACK, "CThumbnailServer::ReconnectCallBack - reconnect" );
  1735     
  1818     
  1736     CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny );
  1819     CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny );
  1737     
  1820     
  1738     self->iReconnect->Cancel();
  1821     self->iReconnect->Cancel();
  1739     
  1822     
  1746     // reconnect to MDS
  1829     // reconnect to MDS
  1747     TRAP_IGNORE( self->iMdESession = CMdESession::NewL( *self ) );
  1830     TRAP_IGNORE( self->iMdESession = CMdESession::NewL( *self ) );
  1748     self->iSessionError = EFalse;
  1831     self->iSessionError = EFalse;
  1749     
  1832     
  1750     TN_DEBUG1( "CThumbAGDaemon::ReconnectCallBack() - done");
  1833     TN_DEBUG1( "CThumbAGDaemon::ReconnectCallBack() - done");
       
  1834     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_RECONNECTCALLBACK, "CThumbnailServer::ReconnectCallBack - done" );
  1751     
  1835     
  1752     return KErrNone;
  1836     return KErrNone;
  1753     }
  1837     }
  1754 
  1838 
  1755 // -----------------------------------------------------------------------------
  1839 // -----------------------------------------------------------------------------
  1762     TInt pos = aPath.FindF(KPrivateFolder);
  1846     TInt pos = aPath.FindF(KPrivateFolder);
  1763     
  1847     
  1764     if ( pos == 1 )
  1848     if ( pos == 1 )
  1765         {
  1849         {
  1766         TN_DEBUG1( "CThumbnailServer::IsPublicPath() NO");
  1850         TN_DEBUG1( "CThumbnailServer::IsPublicPath() NO");
       
  1851         OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_ISPUBLICPATH, "CThumbnailServer::IsPublicPath - NO" );
  1767         return EFalse;
  1852         return EFalse;
  1768         }
  1853         }
  1769     
  1854     
  1770     pos = aPath.FindF(KSysFolder);
  1855     pos = aPath.FindF(KSysFolder);
  1771     if ( pos == 1 )
  1856     if ( pos == 1 )
  1772         {
  1857         {
  1773         TN_DEBUG1( "CThumbnailServer::IsPublicPath() NO");
  1858         TN_DEBUG1( "CThumbnailServer::IsPublicPath() NO");
       
  1859         OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_ISPUBLICPATH, "CThumbnailServer::IsPublicPath - NO" );
  1774         return EFalse;
  1860         return EFalse;
  1775         }
  1861         }
  1776     
  1862     
  1777     return ETrue;
  1863     return ETrue;
  1778     }
  1864     }
  1782 // ---------------------------------------------------------------------------
  1868 // ---------------------------------------------------------------------------
  1783 //
  1869 //
  1784 void CThumbnailServer::StartUnmountTimeout( const TInt aDrive)
  1870 void CThumbnailServer::StartUnmountTimeout( const TInt aDrive)
  1785     {
  1871     {
  1786     TN_DEBUG2( "CThumbnailServer::StartUnmountTimeout(%d)", aDrive);
  1872     TN_DEBUG2( "CThumbnailServer::StartUnmountTimeout(%d)", aDrive);
       
  1873     OstTrace1( TRACE_NORMAL, CTHUMBNAILSERVER_STARTUNMOUNTTIMEOUT, "CThumbnailServer::StartUnmountTimeout;aDrive=%d", aDrive );
  1787     
  1874     
  1788     if(iUnmount )
  1875     if(iUnmount )
  1789         {
  1876         {
  1790         if(iUnmountedDrives.Find( aDrive ) == KErrNotFound)
  1877         if(iUnmountedDrives.Find( aDrive ) == KErrNotFound)
  1791             {
  1878             {
  1796            {
  1883            {
  1797            iUnmount->Cancel();
  1884            iUnmount->Cancel();
  1798            }
  1885            }
  1799        
  1886        
  1800        TN_DEBUG1( "CThumbnailServer::StartUnmountTimeout() start unmount timer");
  1887        TN_DEBUG1( "CThumbnailServer::StartUnmountTimeout() start unmount timer");
       
  1888        OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_STARTUNMOUNTTIMEOUT, "CThumbnailServer::StartUnmountTimeout - start unmount timer" );
  1801        iUnmount->Start( KUnmountTimerTimeout, KUnmountTimerTimeout, TCallBack(UnmountCallBack, this));
  1889        iUnmount->Start( KUnmountTimerTimeout, KUnmountTimerTimeout, TCallBack(UnmountCallBack, this));
  1802        }
  1890        }
  1803        __ASSERT_DEBUG(( iUnmount ), ThumbnailPanic( EThumbnailNullPointer ));
  1891        __ASSERT_DEBUG(( iUnmount ), ThumbnailPanic( EThumbnailNullPointer ));
  1804     }
  1892     }
  1805 
  1893 
  1809 // ---------------------------------------------------------------------------
  1897 // ---------------------------------------------------------------------------
  1810 //
  1898 //
  1811 TInt CThumbnailServer::UnmountCallBack(TAny* aAny)
  1899 TInt CThumbnailServer::UnmountCallBack(TAny* aAny)
  1812     {
  1900     {
  1813     TN_DEBUG1( "CThumbnailServer::UnmountCallBack() - unmount finished");
  1901     TN_DEBUG1( "CThumbnailServer::UnmountCallBack() - unmount finished");
       
  1902     OstTrace0( TRACE_NORMAL, CTHUMBNAILSERVER_UNMOUNTCALLBACK, "CThumbnailServer::UnmountCallBack - unmount finished" );
  1814     
  1903     
  1815     CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny );
  1904     CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny );
  1816     
  1905     
  1817     self->iUnmount->Cancel();
  1906     self->iUnmount->Cancel();
  1818     
  1907     
  1819     self->iUnmountedDrives.Reset();
  1908     self->iUnmountedDrives.Reset();
  1820     
  1909     
  1821     TN_DEBUG1( "CThumbAGDaemon::UnmountCallBack() - done");
  1910     TN_DEBUG1( "CThumbAGDaemon::UnmountCallBack() - done");
       
  1911     OstTrace0( TRACE_NORMAL, DUP1_CTHUMBNAILSERVER_UNMOUNTCALLBACK, "CThumbnailServer::UnmountCallBack - done" );
  1822     
  1912     
  1823     return KErrNone;
  1913     return KErrNone;
  1824     }
  1914     }