diff -r f8e15b44d440 -r 4843bb5893b6 mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp --- a/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp Fri Feb 19 23:40:44 2010 +0200 +++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp Fri Mar 12 15:46:41 2010 +0200 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "cmtpimagedp.h" @@ -40,6 +41,7 @@ #include "mtpimagedputilits.h" #include "cmtpimagedpmdeobserver.h" #include "cmtpimagedprenameobject.h" +#include "cmtpimagedpnewpicturesnotifier.h" __FLOG_STMT(_LIT8(KComponent,"CMTPImageDataProvider");) @@ -80,6 +82,7 @@ CMTPDataProviderPlugin(aParams), iActiveProcessors(KArrayGranularity), iFormatMappings(&TBuf16Hash, &TBuf16Ident), + iMimeMappings(&TBuf16Hash, &TBuf16Ident), iActiveProcessor(-1), iEnumerated(EFalse), iDeleteObjectsArray(KDeleteObjectGranularity) @@ -94,10 +97,11 @@ __FLOG_OPEN(KMTPSubsystem, KComponent); __FLOG(_L8(">> CMTPImageDataProvider::ConstructL")); - iPropertyMgr = CMTPImageDpObjectPropertyMgr::NewL(Framework()); - iThumbnailManager = CMTPImageDpThumbnailCreator::NewL(); + iPropertyMgr = CMTPImageDpObjectPropertyMgr::NewL(Framework(), *this); + iThumbnailManager = CMTPImageDpThumbnailCreator::NewL(*this); iMdeObserver = CMTPImageDpMdeObserver::NewL(Framework(), *this); iMdeObserver->SubscribeForChangeNotificationL(); + iNewPicNotifier = CMTPImageDpNewPicturesNotifier::NewL(); //Setup central repository connection const TUint32 KUidMTPImageRepositoryValue(0x2001FCA2); @@ -111,6 +115,13 @@ iFormatMappings.Insert(KMTPValidCodeExtensionMappings[i].iExtension, KMTPValidCodeExtensionMappings[i].iFormatCode); } + //Initialize hash map of extension to mime type + count = sizeof(KMTPExtensionMimeTypeMappings) / sizeof(KMTPExtensionMimeTypeMappings[0]); + for(TInt i(0); iClearCacheL(); + __FLOG(_L8("<< SessionClosedL")); } @@ -552,19 +596,10 @@ /** * Get image object count from framework and calculate the new pictures */ - TUint curPictures = QueryImageObjectCountL(); - TInt newPictures = curPictures - iPrePictures; - - __FLOG_2(_L16("CMTPImageDpEnumerator::CompleteEnumeration - Previous Pics:%d, New Pics: %d"), iPrePictures, newPictures); - if (newPictures >= 0) - { - MTPImageDpUtilits::UpdateNewPicturesValue(*this, newPictures, ETrue); - } - else - { - MTPImageDpUtilits::UpdateNewPicturesValue(*this, 0, ETrue); - } - + TUint newPictures = QueryImageObjectCountL(); + RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPictures); + iNewPicNotifier->SetNewPictures(newPictures); + __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - New Pics: %d"), newPictures); iEnumerated = EFalse; } @@ -593,12 +628,39 @@ /** Find format code according to its extension name */ -TMTPFormatCode CMTPImageDataProvider::FindFormatL(const TDesC& aExtension) +TMTPFormatCode CMTPImageDataProvider::FindFormat(const TDesC& aExtension) { TMTPFormatCode* ret = iFormatMappings.Find(aExtension); - User::LeaveIfNull(ret); + if (ret == NULL) + { + return EMTPFormatCodeUndefined; + } + else + { + return *ret; + } + } + +/** + Find mime type according to its extension name +*/ +const TDesC& CMTPImageDataProvider::FindMimeType(const TDesC& aExtension) + { + /** + * copy file extension by insensitive case + */ + TBuf extension; + extension.CopyLC(aExtension); - return *ret; + const TDesC* ret = iMimeMappings.Find(extension); + if (ret == NULL) + { + return KNullDesC; + } + else + { + return *ret; + } } /** @@ -606,8 +668,40 @@ */ TUint CMTPImageDataProvider::QueryImageObjectCountL() { - TMTPObjectMgrQueryParams params(KMTPStorageAll, EMTPFormatCodeEXIFJPEG, KMTPHandleNone); - return Framework().ObjectMgr().CountL(params); + RMTPObjectMgrQueryContext context; + RArray handles; + TMTPObjectMgrQueryParams params(KMTPStorageAll, KMTPFormatsAll, KMTPHandleNone, Framework().DataProviderId()); + CleanupClosePushL(context); + CleanupClosePushL(handles); + + do + { + /* + * Speed up query performance, avoid to duplicated copy object handle between RArrays + */ + Framework().ObjectMgr().GetObjectHandlesL(params, context, handles); + } + while (!context.QueryComplete()); + + CMTPObjectMetaData* objMetadata = CMTPObjectMetaData::NewLC(); + + TUint newPictures = 0; + TInt count = handles.Count(); + for (TInt i(0); i> IncreaseNewPictures New Pictures: %d"), aCount)); + + iNewPicNotifier->IncreaseCount(aCount); + + __FLOG(_L8("<< IncreaseNewPictures ")); + } + +void CMTPImageDataProvider::DecreaseNewPictures(TInt aCount) + { + __FLOG_VA((_L16(">> DecreaseNewPictures New Pictures: %d"), aCount)); + + iNewPicNotifier->DecreaseCount(aCount); + + __FLOG(_L8("<< DecreaseNewPictures ")); + }