--- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp Fri Feb 19 23:07:36 2010 +0200
+++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/src/thumbnailserver.cpp Fri Mar 12 15:43:57 2010 +0200
@@ -17,10 +17,10 @@
#include <e32svr.h>
-#include <mihlscaler.h>
+#include <MIHLScaler.h>
#include <driveinfo.h>
#include <caf/data.h>
-#include <oma2agent.h>
+#include <Oma2Agent.h>
#include <bautils.h>
#include <mdesession.h>
@@ -54,7 +54,7 @@
// ----------------------------------------------------------------------------------------
// Total number of ranges
// ----------------------------------------------------------------------------------------
-const TUint KThumbnailServerRangeCount = 17;
+const TUint KThumbnailServerRangeCount = 16;
// ----------------------------------------------------------------------------------------
// Definition of the ranges
@@ -66,7 +66,6 @@
EReleaseBitmap,
ECancelRequest,
EChangePriority,
- ECreateThumbnails,
EDeleteThumbnails,
EGetMimeTypeBufferSize,
EGetMimeTypeList,
@@ -90,7 +89,6 @@
CPolicyServer::ECustomCheck, // EReleaseBitmap
CPolicyServer::ECustomCheck, // ECancelRequest
CPolicyServer::ECustomCheck, // EChangePriority
- CPolicyServer::ECustomCheck, // ECreateThumbnails
CPolicyServer::ECustomCheck, // EDeleteThumbnails
CPolicyServer::ECustomCheck, // EGetMimeTypeBufferSize
CPolicyServer::ECustomCheck, // EGetMimeTypeList
@@ -139,7 +137,6 @@
case EReleaseBitmap:
case ECancelRequest:
case EChangePriority:
- case ECreateThumbnails:
case EDeleteThumbnails:
case EGetMimeTypeBufferSize:
case EGetMimeTypeList:
@@ -251,9 +248,11 @@
iFormatting = EFalse;
- OpenStoresL();
+ //OpenStoresL();
AddUnmountObserversL();
+
+ iReconnect = CPeriodic::NewL(CActive::EPriorityIdle);
}
@@ -270,9 +269,17 @@
delete iShutdownObserver;
delete iProcessor;
+ if(iReconnect)
+ {
+ iReconnect->Cancel();
+ delete iReconnect;
+ iReconnect = NULL;
+ }
+
if (iMdESession)
{
delete iMdESession;
+ iMdESession = NULL;
}
ResetAndDestroyHashMap < TInt, CThumbnailStore > ( iStores );
@@ -318,10 +325,17 @@
//
void CThumbnailServer::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
{
- if (aError != KErrNone)
+ TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError );
+ if (aError != KErrNone && !iShutdown)
{
- TN_DEBUG2( "CThumbnailServer::HandleSessionError == %d", aError );
- }
+ if (!iReconnect->IsActive())
+ {
+ iReconnect->Start( KMdEReconnect, KMdEReconnect,
+ TCallBack(ReconnectCallBack, this));
+
+ TN_DEBUG1( "CThumbnailServer::HandleSessionError() - reconnect timer started" );
+ }
+ }
}
// -----------------------------------------------------------------------------
@@ -499,7 +513,7 @@
//
void CThumbnailServer::StoreThumbnailL( const TDesC& aPath, CFbsBitmap* aBitmap,
const TSize& aOriginalSize, const TBool aCropped, const TThumbnailSize aThumbnailSize,
- const TThumbnailId aThumbnailId, const TBool aThumbFromPath, const TBool aCheckExist )
+ const TInt64 aModified, const TBool aThumbFromPath, const TBool aCheckExist )
{
TN_DEBUG6(
"CThumbnailServer::StoreBitmapL(aPath=%S, aBitmap=0x%08x, aOriginalSize=%dx%d, aCropped=%d)", &aPath, aBitmap, aOriginalSize.iWidth, aOriginalSize.iHeight, aCropped );
@@ -510,12 +524,12 @@
if (!aCheckExist)
{
StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
- aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath );
+ aCropped, aThumbnailSize, aModified, aThumbFromPath );
}
else if(BaflUtils::FileExists( iFs, aPath))
{
StoreForPathL( aPath )->StoreThumbnailL( aPath, aBitmap, aOriginalSize,
- aCropped, aThumbnailSize, aThumbnailId, aThumbFromPath );
+ aCropped, aThumbnailSize, aModified, aThumbFromPath );
}
else
{
@@ -569,7 +583,7 @@
}
else
{
- __ASSERT_DEBUG(( EFalse ), ThumbnailPanic( EThumbnailBitmapNotReleased ));
+ //__ASSERT_DEBUG(( EFalse ), ThumbnailPanic( EThumbnailBitmapNotReleased ));
TN_DEBUG2( "CThumbnailServer::DeleteBitmapFromPool(%d) -- not found!",
aHandle );
}
@@ -587,41 +601,6 @@
StoreForPathL( aPath )->DeleteThumbnailsL( aPath );
}
-
-// -----------------------------------------------------------------------------
-// Delete thumbnails by Id
-// -----------------------------------------------------------------------------
-//
-void CThumbnailServer::DeleteThumbnailsByIdL( const TThumbnailId aItemId )
- {
- TN_DEBUG2( "CThumbnailServer::DeleteThumbnailsByIdL(%d)", aItemId);
-
-#ifdef _DEBUG
- TTime aStart, aStop;
- aStart.UniversalTime();
-#endif
-
- // no path available, can be any store
- THashMapIter<TInt, CThumbnailStore*> iter( iStores );
- CThumbnailStore* const *store = iter.NextValue();
-
- while ( store )
- {
- TInt err = KErrNone;
- TRAP(err, ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId) );
- if (err == KErrNone)
- {
-#ifdef _DEBUG
- aStop.UniversalTime();
- TN_DEBUG2( "CThumbnailStore::DeleteThumbnailsByIdL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
-#endif
- return;
- }
- store = iter.NextValue();
- }
- }
-
-
// -----------------------------------------------------------------------------
// CThumbnailServer::ResolveMimeTypeL()
// -----------------------------------------------------------------------------
@@ -909,67 +888,6 @@
return res;
}
-
-// -----------------------------------------------------------------------------
-// CThumbnailServer::FetchThumbnailL()
-// -----------------------------------------------------------------------------
-//
-void CThumbnailServer::FetchThumbnailL( TThumbnailId aThumbnailId, CFbsBitmap* &
- aThumbnail, TDesC8* & aData, TThumbnailSize aThumbnailSize, TSize &aOriginalSize )
- {
- TN_DEBUG3( "CThumbnailServer::FetchThumbnailL(aThumbnailId=%d aThumbnailSize=%d)", aThumbnailId, aThumbnailSize );
-
-#ifdef _DEBUG
- TTime aStart, aStop;
- aStart.UniversalTime();
- TInt roundCount = 1;
-#endif
-
- THashMapIter<TInt, CThumbnailStore*> storeIter(iStores);
-
- TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() store iteration - begin");
- for (CThumbnailStore* const* pStore = storeIter.NextValue();
- pStore && aThumbnail == NULL ;
- pStore = storeIter.NextValue())
- {
- TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() store iteration - round == %d ", roundCount++);
- CThumbnailStore* const store = (CThumbnailStore*)(*pStore);
-
- TRAPD(err, store->FetchThumbnailL( aThumbnailId, aThumbnail, aData, aThumbnailSize, aOriginalSize ));
-
- if( err == KErrCompletion )
- {
- // If thumbnail of requested size is blacklisted, fetching is left with KErrCompletion
- TN_DEBUG1(
- "CThumbnailServer::FetchThumbnailL() - thumbnail blacklisted" );
- User::Leave( err );
- }
- else if ( aThumbnail || aData)
- { // thumbnail found from DB
- TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() found" );
- break;
- }
-/*
-#ifdef _DEBUG
- aStop.UniversalTime();
- TN_DEBUG3( "CThumbnailServer::FetchThumbnailL() iteration round %d took %d ms", roundCount, (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
-#endif
-*/
- }
-
-#ifdef _DEBUG
- aStop.UniversalTime();
- TN_DEBUG2( "CThumbnailServer::FetchThumbnailL() took %d ms", (TInt)aStop.MicroSecondsFrom(aStart).Int64()/1000);
-#endif
-
- if ( !aThumbnail && !aData)
- { // thumbnail not found from DB
- TN_DEBUG1( "CThumbnailServer::FetchThumbnailL() not found" );
- User::Leave( KErrNotFound );
- }
- }
-
-
// -----------------------------------------------------------------------------
// Get the thumbnail store instance, which is responsible for the drive
// identified by given path
@@ -1030,9 +948,6 @@
// ignore errors
TRAP_IGNORE( StoreForDriveL( i ));
- // start also placeholder task
- //AddPlaceholderTaskL(i);
-
driveCountInt--;
}
}
@@ -1066,10 +981,10 @@
return iPersistentSizes;
}
-void CThumbnailServer::GetMissingSizesAndIDsL( const TDesC& aPath, TInt aSourceType, RArray <
- TThumbnailPersistentSize > & aMissingSizes, TBool& aMissingIDs )
+void CThumbnailServer::GetMissingSizesL( const TDesC& aPath, TInt aSourceType, RArray <
+ TThumbnailPersistentSize > & aMissingSizes, TBool aCheckGridSizeOnly )
{
- StoreForPathL( aPath )->GetMissingSizesAndIDsL( aPath, aSourceType, aMissingSizes, aMissingIDs );
+ StoreForPathL( aPath )->GetMissingSizesL( aPath, aSourceType, aMissingSizes, aCheckGridSizeOnly );
}
// ---------------------------------------------------------------------------
@@ -1148,8 +1063,7 @@
if (!err && !err_drive && driveInfo.iDriveAtt& KDriveAttRemovable)
{
// ignore errors
- TRAP_IGNORE( StoreForDriveL( drive ));
-
+ //TRAP_IGNORE( StoreForDriveL( drive ));
}
//dismount -- if removable drive, close store
@@ -1214,7 +1128,7 @@
// Updates thumbnails by given Id.
// -----------------------------------------------------------------------------
//
-TBool CThumbnailServer::UpdateThumbnailsL( const TThumbnailId aItemId, const TDesC& aPath,
+TBool CThumbnailServer::UpdateThumbnailsL( const TDesC& aPath,
const TInt /*aOrientation*/, const TInt64 aModified )
{
TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL()");
@@ -1222,94 +1136,55 @@
// 1. check path change
// 2. check orientation change
// 3. check timestamp change
- TBool pathChanged = EFalse;
+
TBool orientationChanged = EFalse;
TBool modifiedChanged = EFalse;
- CThumbnailStore* newstore = StoreForPathL( aPath );
- TInt err(KErrNone);
-
- // no path available, can be any store
- THashMapIter<TInt, CThumbnailStore*> iter( iStores );
- CThumbnailStore* const *store = iter.NextValue();
-
- while ( store )
- {
- err = KErrNone;
+ CThumbnailStore* store = StoreForPathL( aPath );
+
+ // placeholder for orientation check
+ orientationChanged = EFalse;
+
+ if (orientationChanged)
+ {
+ TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated");
- TRAP(err, ((CThumbnailStore*)(*store))->FindStoreL( aItemId ) );
-
- // no need to move thumbs to different store
- if (err == KErrNone && *store == newstore)
+ // orientation updated, no need to check further
+ return ETrue;
+ }
+ else
+ {
+ TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exist");
+
+ TBool exists = store->CheckModifiedByPathL(aPath, aModified, modifiedChanged);
+
+ if(!exists)
{
- pathChanged = ((CThumbnailStore*)(*store))->UpdateStoreL(aItemId, aPath);
+ TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - exists NO");
+ //not found, needs to be generated
+ return EFalse;
+ }
+
+ TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?");
+
+ if (modifiedChanged)
+ {
+ TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES");
- if (pathChanged)
- {
- TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - path updated");
-
- // path updated, no need to check further
- return ETrue;
- }
- else
- {
- // placeholder for orientation check
- orientationChanged = EFalse;
-
- if (orientationChanged)
- {
- TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - orientation updated");
-
- // orientation updated, no need to check further
- return ETrue;
- }
- else
- {
- TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified ?");
- modifiedChanged = ((CThumbnailStore*)(*store))->CheckModifiedL(aItemId, aModified);
-
- if (modifiedChanged)
- {
- TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified YES");
-
- // delete old thumbs
- ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId);
-
- // need to create new thumbs
- return EFalse;
- }
- else
- {
- TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO");
-
- // not modified
- return ETrue;
- }
- }
- }
+ // delete old thumbs
+ store->DeleteThumbnailsL(aPath, ETrue);
- }
- // move to new store
- else if (err == KErrNone && *store != newstore)
+ // need to create new thumbs
+ }
+ else
{
- RArray < TThumbnailDatabaseData* >* thumbnails = NULL;
- thumbnails = new (ELeave) RArray < TThumbnailDatabaseData* >;
- CleanupClosePushL( *thumbnails );
- ((CThumbnailStore*)(*store))->FetchThumbnailsL(aItemId, *thumbnails);
- newstore->StoreThumbnailsL(aPath, *thumbnails);
- ((CThumbnailStore*)(*store))->DeleteThumbnailsL(aItemId);
- CleanupStack::PopAndDestroy( thumbnails);
- delete thumbnails;
- thumbnails = NULL;
+ TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - modified NO");
- TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - moved to different store");
-
- // no need to check further
+ // not modified
return ETrue;
}
-
- store = iter.NextValue();
- }
+ }
+
TN_DEBUG1( "CThumbnailServer::UpdateThumbnailsL() - no thumbs found, create new");
@@ -1580,19 +1455,6 @@
}
// -----------------------------------------------------------------------------
-// Updates ID for thumbnails with given Path
-// -----------------------------------------------------------------------------
-//
-void CThumbnailServer::UpdateIDL( const TDesC& aPath, const TThumbnailId aNewId )
- {
- TN_DEBUG3( "CThumbnailServer::UpdateIDL() aPath = %S aId = %d", &aPath, aNewId);
-
- CThumbnailStore* store = StoreForPathL( aPath );
- User::LeaveIfNull( store );
- store->UpdateStoreL( aPath, aNewId );
- }
-
-// -----------------------------------------------------------------------------
// Closes stores for removable drives
// -----------------------------------------------------------------------------
//
@@ -1687,3 +1549,29 @@
}
}
+// ---------------------------------------------------------------------------
+// CThumbnailServer::ReconnectCallBack()
+// ---------------------------------------------------------------------------
+//
+TInt CThumbnailServer::ReconnectCallBack(TAny* aAny)
+ {
+ TN_DEBUG1( "CThumbnailServer::ReconnectCallBack() - reconnect");
+
+ CThumbnailServer* self = static_cast<CThumbnailServer*>( aAny );
+
+ self->iReconnect->Cancel();
+
+ if (self->iMdESession)
+ {
+ delete self->iMdESession;
+ self->iMdESession = NULL;
+ }
+
+ // reconnect to MDS
+ TRAP_IGNORE( self->iMdESession = CMdESession::NewL( *self ) );
+
+ TN_DEBUG1( "CThumbAGDaemon::ReconnectCallBack() - done");
+
+ return KErrNone;
+ }
+