--- a/mtpdataproviders/mtpimagedp/group/mtpimagedp.mmp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/group/mtpimagedp.mmp Fri Mar 12 15:46:41 2010 +0200
@@ -67,6 +67,7 @@
SOURCE mtpimagedprequestprocessor.cpp
SOURCE cmtpimagedpsetobjectprotection.cpp
SOURCE cmtpimagedprenameobject.cpp
+SOURCE cmtpimagedpnewpicturesnotifier.cpp
// ECOM resource
START RESOURCE mtpimagedp.rss
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedp.h Fri Mar 12 15:46:41 2010 +0200
@@ -39,8 +39,10 @@
class CMTPImageDpMdeObserver;
class CRepository;
class CMTPImageDpRenameObject;
+class CMTPImageDpNewPicturesNotifier;
const TInt KMaxExtNameLength = 4;
+const TInt KMaxMimeNameLength = 10;
/**
Implements the picture data provider plugin.
@@ -59,11 +61,14 @@
CMTPImageDpThumbnailCreator& ThumbnailManager() const;
CRepository& Repository() const;
- TMTPFormatCode FindFormatL(const TDesC& aExtension);
+ TMTPFormatCode FindFormat(const TDesC& aExtension);
+ const TDesC& FindMimeType(const TDesC& aExtension);
TBool GetCacheParentHandle(const TDesC& aParentPath, TUint32& aParentHandle);
void SetCacheParentHandle(const TDesC& aParentPath, TUint32 aParentHandle);
void AppendDeleteObjectsArrayL(const TDesC& aSuid);
void HandleDeleteObjectsArray();
+ void IncreaseNewPictures(TInt aCount);
+ void DecreaseNewPictures(TInt aCount);
public: // From CMTPDataProviderPlugin
void Cancel();
@@ -109,6 +114,7 @@
CMTPImageDpMdeObserver* iMdeObserver;
CRepository* iRepository;
CMTPImageDpRenameObject* iRenameObject;
+ CMTPImageDpNewPicturesNotifier* iNewPicNotifier;
/**
The active request processors table.
@@ -116,13 +122,16 @@
RPointerArray<MMTPRequestProcessor> iActiveProcessors;
/**
- * contain the image mapping of extenstion to formatcode
+ * contain the mapping image'extension to formatcode
*/
RHashMap<TBuf<KMaxExtNameLength>, TMTPFormatCode> iFormatMappings;
- SMTPImageDpParentCache iParentCache;
+ /**
+ * contain the mapping image's extension to mime type
+ */
+ RHashMap<TBuf<KMaxExtNameLength>, TBuf<KMaxMimeNameLength> > iMimeMappings;
- TUint iPrePictures;
+ SMTPImageDpParentCache iParentCache;
TInt iActiveProcessor;
TBool iActiveProcessorRemoved;
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpcopyobject.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpcopyobject.h Fri Mar 12 15:46:41 2010 +0200
@@ -75,6 +75,7 @@
TUint32 iNewParentHandle;
TUint32 iStorageId;
TFileName iNewFileName;
+ MMTPDataProviderFramework& iFramework;
CMTPImageDataProvider& iDataProvider;
/*
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobject.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobject.h Fri Mar 12 15:46:41 2010 +0200
@@ -25,6 +25,7 @@
class CMTPTypeFile;
class CMTPImageDataProvider;
+class MMTPDataProviderFramework;
/**
Defines file data provider GetObject request processor
@@ -56,6 +57,7 @@
*/
__FLOG_DECLARATION_MEMBER_MUTABLE;
+ MMTPDataProviderFramework& iFramework;
CMTPTypeFile* iFileObject;
CMTPImageDataProvider& iDataProvider;
};
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropdesc.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropdesc.h Fri Mar 12 15:46:41 2010 +0200
@@ -67,7 +67,8 @@
void ServiceRepresentativeSampleFormatL();
void ServiceRepresentativeSampleSizeL();
void ServiceRepresentativeSampleHeightL();
- void ServiceRepresentativeSampleWidthL();
+ void ServiceRepresentativeSampleWidthL();
+ void ServiceRepresentativeSampleDataL();
void ServiceNonConsumableL();
TUint16 GetPropertyGroupNumber(const TUint16 aPropCode) const;
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropvalue.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetobjectpropvalue.h Fri Mar 12 15:46:41 2010 +0200
@@ -30,6 +30,7 @@
class TMTPTypeUint64;
class TMTPTypeUint128;
class CMTPTypeString;
+class CMTPTypeArray;
class CMTPImageDataProvider;
@@ -70,6 +71,7 @@
void ServiceRepresentativeSampleSizeL();
void ServiceRepresentativeSampleHeightL();
void ServiceRepresentativeSampleWidthL();
+ void ServiceRepresentativeSampleDataL();
void ServiceNonConsumableL();
private:
@@ -80,6 +82,7 @@
TMTPTypeUint64 iMTPTypeUint64;
TMTPTypeUint128 iMTPTypeUint128;
CMTPTypeString* iMTPTypeString;
+ CMTPTypeArray* iMTPTypeArray;
CMTPObjectMetaData* iObjectMeta;
/**
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetthumb.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpgetthumb.h Fri Mar 12 15:46:41 2010 +0200
@@ -57,7 +57,7 @@
*/
__FLOG_DECLARATION_MEMBER_MUTABLE;
CMTPImageDataProvider& imgDp;
- CMTPTypeOpaqueData* iThumb;
+ CMTPTypeOpaqueData* iThumb;
CMTPObjectMetaData* iObjectMeta;
};
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpmdeobserver.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpmdeobserver.h Fri Mar 12 15:46:41 2010 +0200
@@ -64,7 +64,7 @@
const RArray<TItemId>& aObjectIdArray);
void ProcessMdeNotificationL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType aType);
- void CreateMetadataL(const CMdEObject& aMdeObject, CMTPObjectMetaData& aMetaData);
+ void CreateMetadataL(const TParsePtrC& aParse, TMTPFormatCode aFormat, TUint32 aParentHandle, CMTPObjectMetaData& aMetaData);
private:
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpnewpicturesnotifier.h Fri Mar 12 15:46:41 2010 +0200
@@ -0,0 +1,50 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#ifndef CMTPIMAGEDPNEWPICTURENOTIFIER_H
+#define CMTPIMAGEDPNEWPICTURENOTIFIER_H
+
+#include <e32base.h>
+
+class CMTPImageDpNewPicturesNotifier : public CTimer
+ {
+public:
+
+ static CMTPImageDpNewPicturesNotifier* NewL();
+ virtual ~CMTPImageDpNewPicturesNotifier();
+
+ void SetNewPictures(TInt aValue);
+ void IncreaseCount(TInt aValue);
+ void DecreaseCount(TInt aValue);
+
+private: // From CTimer
+
+ void RunL();
+
+private:
+
+ CMTPImageDpNewPicturesNotifier();
+ void ConstructL();
+
+private:
+ TInt iNewPictures;
+ };
+
+#endif // CMTPIMAGEDPNEWPICTURENOTIFIER_H
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpobjectpropertymgr.h Fri Mar 12 15:46:41 2010 +0200
@@ -41,6 +41,9 @@
class CFileStore;
class CMTPTypeString;
class CMTPObjectMetaData;
+class CMTPImageDataProvider;
+class CMTPTypeOpaqueData;
+class CMTPTypeArray;
/**
Manage picture object properties
@@ -52,7 +55,7 @@
{
public:
- static CMTPImageDpObjectPropertyMgr* NewL(MMTPDataProviderFramework& aFramework);
+ static CMTPImageDpObjectPropertyMgr* NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider);
~CMTPImageDpObjectPropertyMgr();
void SetCurrentObjectL(CMTPObjectMetaData& aObjectInfo, TBool aRequireForModify, TBool aSaveToCache = EFalse);
@@ -67,12 +70,16 @@
void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint32& aValue);
void GetPropertyL(TMTPObjectPropertyCode aProperty, TUint64& aValue);
void GetPropertyL(TMTPObjectPropertyCode aProperty, TMTPTypeUint128& aValue);
- void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeString& aValue);
+ void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeString& aValue);
+ void GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeArray& aValue);
//clear the cache
void ClearCacheL();
void ConvertMTPTimeStr2TTimeL(const TDesC& aTimeString, TTime& aModifiedTime) const;
+ void StoreThunmnail(TUint aHandle, HBufC8* aData);
+ HBufC8* Thumbnail(TUint aHandle);
+
public:
void SetMdeSessionError(TInt aError);
CMdESession& MdeSession();
@@ -82,7 +89,7 @@
void HandleSessionError(CMdESession& aSession, TInt aError);
private:
- CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework);
+ CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider);
void ConstructL(MMTPDataProviderFramework& aFramework);
TBool GetYear(const TDesC& aDateString, TInt& aYear) const;
@@ -96,9 +103,11 @@
void SetProperty2CacheL(TMTPObjectPropertyCode aProperty, TAny* aValue);
void GetPropertyFromMdsL(TMTPObjectPropertyCode aProperty, TAny* aValue);
- TUint32 ParseImageFileL(const TDesC& aUri, TMTPObjectPropertyCode aPropCode);
void RemoveProperty(CMdEObject& aObject, CMdEPropertyDef& aPropDef);
+ void OpenMdeObjectL();
+ void ClearThumnailCache();
+
private:
//define property cache object
@@ -177,21 +186,38 @@
static const TElementMetaData KElements[];
};
+ /**
+ * Thumbnail cache used for winlogo test
+ */
+ struct TThumbnailCache
+ {
+ TUint iObjectHandle;
+ HBufC8* iThumbnailData;
+ };
+
private:
/**
FLOGGER debug trace member variable.
*/
__FLOG_DECLARATION_MEMBER_MUTABLE;
+ MMTPDataProviderFramework& iFramework;
+ CMTPImageDataProvider& iDataProvider;
CActiveSchedulerWait* iActiveSchedulerWait;
CMdESession* iMetaDataSession;
TInt iMdeSessionError;
- CMdEObject* iObject;
+ CMdEObject* iObject;//used for read properties from MdS
RFs& iFs;
MMTPObjectMgr& iObjectMgr;
CMTPObjectMetaData* iObjectInfo; //not owned
TBool iCacheHit;//flag to indicate cache is available
+ TBool iNeedParse;//flag to indicate whether we need to parse image file by our self
+
+ /*
+ * Cache thumbnail, thumbnail size is inconsistent in winlogo test
+ */
+ TThumbnailCache iThumbnailCache;
/**
* Cache the latest image properties which PC send to device,
--- a/mtpdataproviders/mtpimagedp/inc/cmtpimagedpthumbnailcreator.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/cmtpimagedpthumbnailcreator.h Fri Mar 12 15:46:41 2010 +0200
@@ -35,6 +35,8 @@
#include "mtpdebug.h"
+class CMTPImageDataProvider;
+
#define MTPTHUMBSCALING
// CLASS DECLARATION
@@ -54,7 +56,7 @@
* @param None.
* @return An instance of CMTPImageDpThumbnailCreator.
*/
- static CMTPImageDpThumbnailCreator* NewL();
+ static CMTPImageDpThumbnailCreator* NewL(CMTPImageDataProvider& aDataProvider);
/**
* C++ destructor.
@@ -62,16 +64,7 @@
~CMTPImageDpThumbnailCreator();
public:
-
- /**
- * Gets a thumbnail from the image.
- * @since S60 3.2
- * @param aSession, Reference to file server.
- * @param aFileName, Name of the image file. Caller must ensure that the referenced object exists until the asynchronous call is completed.
- * @param aThumbName, Name of the thumbnail file to be created. Caller must ensure that the referenced object exists until the asynchronous call is completed.
- * @param aGetThumbnailStatus, status when
- */
- void GetThumbnailL(const TDesC& aFileName, CMTPTypeOpaqueData& aThumbName, TInt& result);
+ void GetThumbnailL(const TDesC& aFileName, HBufC8*& aDestinationData, TInt& result);
void ClearThumbnailData();
@@ -105,7 +98,7 @@
/**
* Default C++ constructor. Not used.
*/
- CMTPImageDpThumbnailCreator();
+ CMTPImageDpThumbnailCreator(CMTPImageDataProvider& aDataProvider);
/**
* 2nd phase constructor.
@@ -124,6 +117,8 @@
EGetted,
EScaling,
EEncoding} iState;
+
+ CMTPImageDataProvider& iDataProvider;
TThumbnailRequestId iCurrentReq;
TInt* iCreationErr;
CFbsBitmap* iBitmap;
@@ -134,7 +129,6 @@
HBufC8* iData;
CThumbnailManager* iThumbMgr;
CThumbnailObjectSource* iObjectSource;
- CMTPTypeOpaqueData* iBuffer; //not owned
CActiveSchedulerWait* iActiveSchedulerWait;
};
--- a/mtpdataproviders/mtpimagedp/inc/mtpimagedpconst.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/mtpimagedpconst.h Fri Mar 12 15:46:41 2010 +0200
@@ -26,14 +26,16 @@
#include <mtp/mtpprotocolconstants.h>
#include <comms-infras/commsdebugutility.h> // for __FLOG debugging
-// for thumb creation
-const TUint32 KThumbWidht=160;
-const TUint32 KThumbHeigth=120;
+/*
+ * [Thumbnail SIZE]: performance improvement
+ */
+const TUint32 KThumbWidht=104;//avoid to scale width to 160
+const TUint32 KThumbHeigth=74;//avoid to scale width to 120
const TUint32 KThumbCompressedSize=KThumbWidht * KThumbHeigth * 4; // from TNM
const TUint32 KThumbFormatCode = 0x3801;
const TUint32 KFileSizeMax = 10 * 1000 * 1000;
+const TUint32 KImageDpNotifyDelay = 1000000 * 15;// set delay time, in microseconds, default is 15s.
-_LIT(KJpegMimeType, "image/jpeg");
_LIT8(KPtpMimeJPEG, "image/jpeg");
/**
@@ -95,6 +97,7 @@
EMTPObjectPropCodeRepresentativeSampleSize,
EMTPObjectPropCodeRepresentativeSampleHeight,
EMTPObjectPropCodeRepresentativeSampleWidth,
+ EMTPObjectPropCodeRepresentativeSampleData,
EMTPObjectPropCodeNonConsumable
};
@@ -130,7 +133,8 @@
EMTPObjectPropCodeRepresentativeSampleFormat,
EMTPObjectPropCodeRepresentativeSampleSize,
EMTPObjectPropCodeRepresentativeSampleHeight,
- EMTPObjectPropCodeRepresentativeSampleWidth
+ EMTPObjectPropCodeRepresentativeSampleWidth,
+ EMTPObjectPropCodeRepresentativeSampleData
};
/**
@@ -161,6 +165,13 @@
const TText* iExtension;
};
+struct SMTPExtensionMimeTypeMapping
+ {
+ public:
+ const TText* iExtension;
+ const TText* iMimeType;
+ };
+
// Note when adding extensions:
// same value for iExtension can be in the file only once,
// values for iFormatCode code can be multiple times
@@ -173,9 +184,26 @@
static const SMTPValidCodeExtensionMapping KMTPValidCodeExtensionMappings[] =
{
- {EMTPFormatCodeEXIFJPEG, CASTING("jpg")}, // jpeg
- {EMTPFormatCodeEXIFJPEG, CASTING("jpe")}, // jpeg
- {EMTPFormatCodeEXIFJPEG, CASTING("jpeg")} // jpeg
+ {EMTPFormatCodeEXIFJPEG, CASTING("jpg")}, // jpeg
+ {EMTPFormatCodeEXIFJPEG, CASTING("jpe")}, // jpeg
+ {EMTPFormatCodeEXIFJPEG, CASTING("jpeg")}, // jpeg
+// {EMTPFormatCodeBMP, CASTING("bmp")}, // bmp
+// {EMTPFormatCodeGIF, CASTING("gif")}, // gif
+// {EMTPFormatCodePNG, CASTING("png")}, // png
+// {EMTPFormatCodeTIFF, CASTING("tif")}, // tiff, TNM does not support
+// {EMTPFormatCodeTIFF, CASTING("tiff")}, // tiff, TNM does not support
+ };
+
+static const SMTPExtensionMimeTypeMapping KMTPExtensionMimeTypeMappings[] =
+ {
+ {CASTING("jpg"), CASTING("image/jpeg")}, // jpeg
+ {CASTING("jpe"), CASTING("image/jpeg")}, // jpeg
+ {CASTING("jpeg"), CASTING("image/jpeg")}, // jpeg
+// {CASTING("bmp"), CASTING("image/bmp")}, // bmp
+// {CASTING("gif"), CASTING("image/gif")}, // gif
+// {CASTING("png"), CASTING("image/png")}, // png
+// {CASTING("tif"), CASTING("image/tiff")}, // tiff, TNM does not support
+// {CASTING("tiff"), CASTING("image/tiff")}, // tiff, TNM does not support
};
/**
--- a/mtpdataproviders/mtpimagedp/inc/mtpimagedputilits.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/inc/mtpimagedputilits.h Fri Mar 12 15:46:41 2010 +0200
@@ -47,13 +47,24 @@
static TUint32 FindParentHandleL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider, const TDesC& aFullPath);
/**
- * Calculate the new pictures value and set RProperty.
-
- @param aDataProvider The image data provider reference
- @param aNewPics The new pictures count
- @param aSetRProperty Whether should set RProperty value to notify all subscribers.
+ * determine whether the object is new
+ */
+ static TBool IsNewPicture(const CMTPObjectMetaData& aMetadata);
+
+ /**
+ * update object status to old
*/
- static void UpdateNewPicturesValue(CMTPImageDataProvider& aDataProvider, TInt aNewPics, TBool aSetRProperty);
+ static void UpdateObjectStatusToOldL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata);
+
+ /**
+ * query thumbnail size from metadata of object
+ */
+ static TInt GetThumbnailSize(const CMTPObjectMetaData& aMetadata);
+
+ /**
+ * update object thumbnail size
+ */
+ static void UpdateObjectThumbnailSizeL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata, TInt aThumbnailSize);
};
#endif MTPIMAGEDPUTILITS_H
--- 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 <mtp/mtpprotocolconstants.h>
#include <mtp/mmtpobjectmgr.h>
#include <mtp/mmtpstoragemgr.h>
+#include <mtp/cmtpobjectmetadata.h>
#include <mtp/tmtptypeevent.h>
#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); i<count; i++)
+ {
+ iMimeMappings.Insert(KMTPExtensionMimeTypeMappings[i].iExtension, KMTPExtensionMimeTypeMappings[i].iMimeType);
+ }
+
//Define RProperty of new pictures for status data provider
_LIT_SECURITY_POLICY_PASS(KAllowReadAll);
TInt error = RProperty::Define(TUid::Uid(KMTPServerUID), KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
@@ -148,8 +159,10 @@
delete iPropertyMgr;
delete iRepository;
delete iRenameObject;
+ delete iNewPicNotifier;
iFormatMappings.Close();
+ iMimeMappings.Close();
//Try to delete objects in array
HandleDeleteObjectsArray();
@@ -263,12 +276,10 @@
if (aStorageId == KMTPStorageAll)
{
/*
- * Query previous image object count for calculation of new pictures when MTP startup
+ * framework notify data provider to enumerate
*
*/
- iPrePictures = QueryImageObjectCountL();
iEnumerated = ETrue;
- __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - Previous Pics: %d"), iPrePictures);
}
NotifyEnumerationCompleteL(aStorageId, KErrNone);
@@ -382,7 +393,35 @@
_LIT(KFormatExtensionJpe, "0x3801:jpe::3");
aStrings.AppendL(KFormatExtensionJpe);
_LIT(KFormatExtensionJpeg, "0x3801:jpeg::3");
- aStrings.AppendL(KFormatExtensionJpeg);
+ aStrings.AppendL(KFormatExtensionJpeg);
+
+ /*
+ * bmp files
+ */
+// _LIT(KFormatExtensionBmp, "0x3804:bmp::3");
+// aStrings.AppendL(KFormatExtensionBmp);
+
+ /*
+ * gif files
+ */
+// _LIT(KFormatExtensionGif, "0x3807:gif::3");
+// aStrings.AppendL(KFormatExtensionGif);
+
+ /*
+ * png files
+ */
+// _LIT(KFormatExtensionPng, "0x380B:png::3");
+// aStrings.AppendL(KFormatExtensionPng);
+
+ /*
+ * tif, tiff files
+ */
+ /*
+ _LIT(KFormatExtensionTif, "0x380D:tif::3");
+ aStrings.AppendL(KFormatExtensionTif);
+ _LIT(KFormatExtensionTiff, "0x380D:tiff::3");
+ aStrings.AppendL(KFormatExtensionTiff);
+ */
}
break;
@@ -530,6 +569,11 @@
}
}
+ /**
+ * We clear property manager cache when receiving session close notification from framework every times
+ */
+ iPropertyMgr->ClearCacheL();
+
__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<KMaxExtNameLength> 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<TUint> 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<count; ++i)
+ {
+ Framework().ObjectMgr().ObjectL(handles[i], *objMetadata);
+ if (MTPImageDpUtilits::IsNewPicture(*objMetadata))
+ {
+ ++newPictures;
+ }
+ }
+
+
+ CleanupStack::PopAndDestroy(objMetadata);
+ CleanupStack::PopAndDestroy(&handles);
+ CleanupStack::PopAndDestroy(&context);
+
+ return newPictures;
}
TBool CMTPImageDataProvider::GetCacheParentHandle(const TDesC& aParentPath, TUint32& aParentHandle)
@@ -656,3 +750,21 @@
}
}
}
+
+void CMTPImageDataProvider::IncreaseNewPictures(TInt aCount)
+ {
+ __FLOG_VA((_L16(">> 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 "));
+ }
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpcopyobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpcopyobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -85,6 +85,7 @@
*/
CMTPImageDpCopyObject::CMTPImageDpCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) :
CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPCopyObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPCopyObjectPolicy),
+ iFramework(aFramework),
iDataProvider(aDataProvider)
{
__FLOG_OPEN(KMTPSubsystem, KComponent);
@@ -193,6 +194,13 @@
SetPreviousPropertiesL(aNewFileName);
iFramework.ObjectMgr().InsertObjectL(*iTargetObjectInfo);
+ //check object whether it is a new image object
+ if (MTPImageDpUtilits::IsNewPicture(*iTargetObjectInfo))
+ {
+ //increate new pictures count
+ iDataProvider.IncreaseNewPictures(1);
+ }
+
__FLOG(_L8("<< CMTPImageDpCopyObject::CopyFileL"));
CleanupStack::Pop(this);
return iTargetObjectInfo->Uint(CMTPObjectMetaData::EHandle);
@@ -261,7 +269,7 @@
TVolumeInfo volumeInfo;
User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
- if(volumeInfo.iFree < fileEntry.iSize)
+ if(volumeInfo.iFree < fileEntry.FileSize())
{
result = EMTPRespCodeStoreFull;
}
@@ -295,6 +303,7 @@
iTargetObjectInfo = CMTPObjectMetaData::NewL();
iTargetObjectInfo->SetUint(CMTPObjectMetaData::EDataProviderId, iSrcObjectInfo->Uint(CMTPObjectMetaData::EDataProviderId));
iTargetObjectInfo->SetUint(CMTPObjectMetaData::EFormatCode, iSrcObjectInfo->Uint(CMTPObjectMetaData::EFormatCode));
+ iTargetObjectInfo->SetUint(CMTPObjectMetaData::EFormatSubCode, iSrcObjectInfo->Uint(CMTPObjectMetaData::EFormatSubCode));
iTargetObjectInfo->SetDesCL(CMTPObjectMetaData::EName, iSrcObjectInfo->DesC(CMTPObjectMetaData::EName));
iTargetObjectInfo->SetUint(CMTPObjectMetaData::ENonConsumable, iSrcObjectInfo->Uint(CMTPObjectMetaData::ENonConsumable));
iTargetObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, iNewParentHandle);
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpdeleteobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -238,8 +238,13 @@
iDataProvider.AppendDeleteObjectsArrayL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid));
case KErrNone:
//add for test
- __FLOG(_L8("KErrNone"));
- iFramework.ObjectMgr().RemoveObjectL( iObjectMeta->Uint(CMTPObjectMetaData::EHandle ));
+ __FLOG(_L8("KErrNone"));
+ //if the image object is new, we should update new picture count
+ if (MTPImageDpUtilits::IsNewPicture(*iObjectMeta))
+ {
+ iDataProvider.DecreaseNewPictures(1);
+ }
+ iFramework.ObjectMgr().RemoveObjectL( iObjectMeta->Uint(CMTPObjectMetaData::EHandle ));
iObjectsNotDelete--;
iResponseCode = EMTPRespCodePartialDeletion;
break;
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -77,7 +77,8 @@
Standard c++ constructor
*/
CMTPImageDpGetObject::CMTPImageDpGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) :
- CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPolicy),
+ CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPolicy),
+ iFramework(aFramework),
iDataProvider(aDataProvider)
{
@@ -106,7 +107,7 @@
__ASSERT_DEBUG(objectInfo, Panic(EMTPImageDpObjectNull));
BuildFileObjectL(objectInfo->DesC(CMTPObjectMetaData::ESuid));
- SendDataL(*iFileObject);
+ SendDataL(*iFileObject);
__FLOG(_L8("<< CMTPImageDpGetObject::ServiceL"));
}
@@ -126,22 +127,22 @@
TBool CMTPImageDpGetObject::DoHandleCompletingPhaseL()
{
- __FLOG(_L8(" CMTPImageDpGetObject::DoHandleResponsePhaseL - Entry"));
- TInt currentNewPics = 0;
- iDataProvider.Repository().Get(ENewImagesCount, currentNewPics);
- if (currentNewPics != 0)
+ __FLOG(_L8(" CMTPImageDpGetObject::DoHandleResponsePhaseL - Entry"));
+
+ /**
+ * end-user does not cancel the operation, we think the getobject operation is successful.
+ */
+ if (!iCancelled)
{
- /**
- Zero the new pictures of RProperty.
- Because we think the end-use has import all pictures as long as MTP receive one getobject operation
-
- There are two different phases to collect new pictures:
- 1. In enumeration phase, calculate new pictures value from MSS in one go.
- 2. After enumeration phase, dynamically calculate new pictures value from MdS by Notifications
- */
- iDataProvider.Repository().Set(ENewImagesCount, 0);
- RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, 0);
- }
+ TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+ CMTPObjectMetaData* objectInfo = iRequestChecker->GetObjectInfo(objectHandle);
+ if (MTPImageDpUtilits::IsNewPicture(*objectInfo))
+ {
+ //update new picture status
+ MTPImageDpUtilits::UpdateObjectStatusToOldL(iFramework, *objectInfo);
+ iDataProvider.DecreaseNewPictures(1);
+ }
+ }
__FLOG(_L8("CMTPImageDpGetObject::DoHandleResponsePhaseL - Exit"));
return CMTPRequestProcessor::DoHandleCompletingPhaseL();
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropdesc.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropdesc.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -170,6 +170,9 @@
case EMTPObjectPropCodeRepresentativeSampleWidth:
ServiceRepresentativeSampleWidthL();
break;
+ case EMTPObjectPropCodeRepresentativeSampleData:
+ ServiceRepresentativeSampleDataL();
+ break;
case EMTPObjectPropCodeNonConsumable:
ServiceNonConsumableL();
break;
@@ -404,6 +407,19 @@
CleanupStack::PopAndDestroy(expectedForm);
}
+void CMTPImageDpGetObjectPropDesc::ServiceRepresentativeSampleDataL()
+ {
+ CMTPTypeObjectPropDesc::TPropertyInfo info;
+ info.iDataType = EMTPTypeAUINT8;
+ info.iFormFlag = CMTPTypeObjectPropDesc::EByteArrayForm;
+ info.iGetSet = CMTPTypeObjectPropDesc::EReadOnly;
+
+ const TUint32 KMaxLength = 0x0000FFFF;
+ TMTPTypeUint32 expectedForm(KMaxLength);
+
+ iObjectProperty = CMTPTypeObjectPropDesc::NewL(EMTPObjectPropCodeRepresentativeSampleData, info, &expectedForm);
+ }
+
void CMTPImageDpGetObjectPropDesc::ServiceNonConsumableL()
{
CMTPTypeObjectPropDescEnumerationForm* expectedForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectproplist.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -373,6 +373,17 @@
}
break;
+ case EMTPObjectPropCodeRepresentativeSampleData:
+ {
+ CMTPTypeArray* value = CMTPTypeArray::NewLC(EMTPTypeAUINT8);
+ iPropertyMgr.GetPropertyL(TMTPObjectPropertyCode(aPropCode), *value);
+ CMTPTypeObjectPropListElement& propElem = iPropertyList->ReservePropElemL(aHandle, propCode);
+ propElem.SetArrayL(CMTPTypeObjectPropListElement::EValue, *value);
+ iPropertyList->CommitPropElemL(propElem);
+ CleanupStack::PopAndDestroy(value);
+ }
+ break;
+
case EMTPObjectPropCodeObjectSize:
{
TUint64 value;
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetobjectpropvalue.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -25,6 +25,7 @@
#include <mtp/tmtptypeuint64.h>
#include <mtp/tmtptypeuint128.h>
#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypearray.h>
#include <mtp/mmtpdataproviderframework.h>
#include <mtp/mtpprotocolconstants.h>
#include <mtp/mmtpobjectmgr.h>
@@ -64,6 +65,7 @@
CMTPImageDpGetObjectPropValue::~CMTPImageDpGetObjectPropValue()
{
delete iMTPTypeString;
+ delete iMTPTypeArray;
delete iObjectMeta;
__FLOG_CLOSE;
}
@@ -86,6 +88,7 @@
void CMTPImageDpGetObjectPropValue::ConstructL()
{
iMTPTypeString = CMTPTypeString::NewL();
+ iMTPTypeArray = CMTPTypeArray::NewL(EMTPTypeAUINT8);
iObjectMeta = CMTPObjectMetaData::NewL();
}
@@ -181,6 +184,9 @@
case EMTPObjectPropCodeRepresentativeSampleWidth:
ServiceRepresentativeSampleWidthL();
break;
+ case EMTPObjectPropCodeRepresentativeSampleData:
+ ServiceRepresentativeSampleDataL();
+ break;
case EMTPObjectPropCodeNonConsumable:
ServiceNonConsumableL();
break;
@@ -333,6 +339,13 @@
SendDataL(iMTPTypeUint32);
}
+void CMTPImageDpGetObjectPropValue::ServiceRepresentativeSampleDataL()
+ {
+ iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeRepresentativeSampleData, *iMTPTypeArray);
+
+ SendDataL(*iMTPTypeArray);
+ }
+
void CMTPImageDpGetObjectPropValue::ServiceNonConsumableL()
{
TUint8 nonConsumable;
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetpartialobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetpartialobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -122,7 +122,7 @@
TEntry fileEntry;
User::LeaveIfError(iFs.Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry));
- if((iOffset < fileEntry.iSize))
+ if((iOffset < fileEntry.FileSize()))
{
result = ETrue;
}
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetthumb.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpgetthumb.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -58,7 +58,7 @@
CMTPImageDpGetThumb::~CMTPImageDpGetThumb()
{
__FLOG(_L8(">> CMTPImageDpGetThumb::~CMTPImageDpGetThumb"));
- delete iThumb;
+ delete iThumb;
delete iObjectMeta;
__FLOG(_L8("<< CMTPImageDpGetThumb::~CMTPImageDpGetThumb"));
__FLOG_CLOSE;
@@ -80,7 +80,7 @@
{
__FLOG_OPEN(KMTPSubsystem, KComponent);
__FLOG(_L8("CMTPImageDpGetThumb::ConstructL"));
- iThumb = CMTPTypeOpaqueData::NewL();
+ iThumb = CMTPTypeOpaqueData::NewL();
iObjectMeta = CMTPObjectMetaData::NewL();
__FLOG(_L8("CMTPImageDpGetThumb::ConstructL"));
}
@@ -102,17 +102,30 @@
{
__FLOG(_L8(">> CMTPImageDpGetThumb::ServiceL"));
TInt err = KErrNone;
- TEntry fileEntry;
- User::LeaveIfError(iFramework.Fs().Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry));
- imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
- if(fileEntry.iSize > KFileSizeMax)
+ //at first, try to query thumbnail from property manager
+ HBufC8* thumbnailData = imgDp.PropertyMgr().Thumbnail(iObjectMeta->Uint(CMTPObjectMetaData::EHandle));
+ if (thumbnailData == NULL)
{
- __FLOG(_L8(">> CMTPImageDpGetThumb::ServiceL, fileEntry.iSize > KFileSizeMax"));
- imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
+ __FLOG(_L8("CMTPImageDpGetThumb::ServiceL- fail to query thumbnail from cache"));
+ TEntry fileEntry;
+
+ User::LeaveIfError(iFramework.Fs().Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry));
+ imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
+ if(fileEntry.FileSize() > KFileSizeMax)
+ {
+ __FLOG(_L8(">> CMTPImageDpGetThumb::ServiceL, fileEntry.FileSize() > KFileSizeMax"));
+ imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
+ }
+
+ imgDp.ThumbnailManager().GetThumbnailL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), thumbnailData, err);
+ User::LeaveIfError(err);
+ User::LeaveIfNull(thumbnailData);
+
+ //Transfer ownership of thumbnailData to Property Manager
+ imgDp.PropertyMgr().StoreThunmnail(iObjectMeta->Uint(CMTPObjectMetaData::EHandle), thumbnailData);
}
- imgDp.ThumbnailManager().GetThumbnailL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), *iThumb, err);
- User::LeaveIfError(err);
+ iThumb->Write(*thumbnailData);
SendDataL(*iThumb);
__FLOG(_L8("<< CMTPImageDpGetThumb::ServiceL"));
}
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpmdeobserver.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpmdeobserver.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -71,23 +71,20 @@
__FLOG_CLOSE;
}
-void CMTPImageDpMdeObserver::CreateMetadataL(const CMdEObject& aMdeObject, CMTPObjectMetaData& aMetaData)
+void CMTPImageDpMdeObserver::CreateMetadataL(const TParsePtrC& aParse, TMTPFormatCode aFormat, TUint32 aParentHandle, CMTPObjectMetaData& aMetaData)
{
- const TDesC& uri = aMdeObject.Uri();
- TParsePtrC parse(uri);
- TMTPFormatCode format = iDataProvider.FindFormatL(parse.Ext().Mid(1));
- TInt32 storageId = MTPImageDpUtilits::FindStorage(iFramework, uri);
- TUint32 parentHandle = MTPImageDpUtilits::FindParentHandleL(iFramework, iDataProvider, uri);
-
+ TInt32 storageId = MTPImageDpUtilits::FindStorage(iFramework, aParse.FullName());
+
+ __FLOG_VA((_L16("Addition - New Image:%S"), &aParse.FullName()));
aMetaData.SetUint(CMTPObjectMetaData::EDataProviderId, iFramework.DataProviderId());
- aMetaData.SetUint(CMTPObjectMetaData::EFormatCode, format);
+ aMetaData.SetUint(CMTPObjectMetaData::EFormatCode, aFormat);
aMetaData.SetUint(CMTPObjectMetaData::EStorageId, storageId);
- aMetaData.SetDesCL(CMTPObjectMetaData::ESuid, uri);
- aMetaData.SetUint(CMTPObjectMetaData::EParentHandle, parentHandle);
- aMetaData.SetDesCL(CMTPObjectMetaData::EName, parse.Name());
+ aMetaData.SetDesCL(CMTPObjectMetaData::ESuid, aParse.FullName());
+ aMetaData.SetUint(CMTPObjectMetaData::EParentHandle, aParentHandle);
+ aMetaData.SetDesCL(CMTPObjectMetaData::EName, aParse.Name());
//Increate the new pictures variable
- ++iNewPics;
+ ++iNewPics;
}
void CMTPImageDpMdeObserver::ProcessMdeNotificationL(const RArray<TItemId>& aObjectIdArray, TObserverNotificationType /*aType*/)
@@ -109,26 +106,51 @@
continue;
}
CleanupStack::PushL(mdeObject);
+ __FLOG_VA((_L16("Addition - ObjectId:%u, URI:%S"), aObjectIdArray[i], &mdeObject->Uri()));
- TUint32 handle = iFramework.ObjectMgr().HandleL(mdeObject->Uri());
- if (handle == KMTPHandleNone)
+ //filter out all image files other jpeg files
+ TParsePtrC parse(mdeObject->Uri());
+ TMTPFormatCode format = iDataProvider.FindFormat(parse.Ext().Mid(1));
+ if (format != EMTPFormatCodeUndefined)
{
- CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC();
- CreateMetadataL(*mdeObject, *object);
- iFramework.ObjectMgr().InsertObjectL(*object);
- __FLOG_VA((_L16("Addition - Handle:%u, ObjectId:%u, URI:%S"), object->Uint(CMTPObjectMetaData::EHandle), aObjectIdArray[i], &mdeObject->Uri()));
-
- TMTPTypeEvent event;
- event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded);
- event.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll);
- event.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone);
-
- TUint32 handle = object->Uint(CMTPObjectMetaData::EHandle);
- event.SetUint32(TMTPTypeEvent::EEventParameter1, handle);
- iFramework.SendEventL(event);
- __FLOG_VA((_L8("ProcessMdeNotificationL - EMTPEventCodeObjectAdd, object handle:%u"), handle));
-
- CleanupStack::PopAndDestroy(object);//object
+ TUint32 handle = iFramework.ObjectMgr().HandleL(mdeObject->Uri());
+ if (handle == KMTPHandleNone)
+ {
+ /**
+ * Try to find parent handle of new image file
+ * if we can't find parent handle we should issue a notification to framework, let framework to enumerate new folder if need
+ */
+ TUint32 parentHandle = MTPImageDpUtilits::FindParentHandleL(iFramework, iDataProvider, parse.FullName());
+ if (parentHandle == KMTPHandleNone)
+ {
+ __FLOG_VA((_L16("Notify framework - URI:%S"), &mdeObject->Uri()));
+ TMTPNotificationParamsFolderChange param = {mdeObject->Uri()};
+ iFramework.NotifyFrameworkL(EMTPAddFolder, ¶m);
+
+ //try to get parent handle if framework complete it's tasks
+ parentHandle = MTPImageDpUtilits::FindParentHandleL(iFramework, iDataProvider, parse.FullName());
+ __FLOG_VA((_L16("Framework enumeration parent handle:%u"), parentHandle));
+ }
+
+ if (parentHandle != KMTPHandleNone)
+ {
+ CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC();
+ CreateMetadataL(parse, format, parentHandle, *object);
+ iFramework.ObjectMgr().InsertObjectL(*object);
+ __FLOG_VA((_L16("Addition - New Handle:%u"), object->Uint(CMTPObjectMetaData::EHandle)));
+
+ TMTPTypeEvent event;
+ event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded);
+ event.SetUint32(TMTPTypeEvent::EEventSessionID, KMTPSessionAll);
+ event.SetUint32(TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone);
+
+ TUint32 handle = object->Uint(CMTPObjectMetaData::EHandle);
+ event.SetUint32(TMTPTypeEvent::EEventParameter1, handle);
+ iFramework.SendEventL(event);
+ __FLOG_VA((_L8("ProcessMdeNotificationL - EMTPEventCodeObjectAdd, object handle:%u"), handle));
+ CleanupStack::PopAndDestroy(object);//object
+ }
+ }
}
CleanupStack::PopAndDestroy(mdeObject);//mdeObject
@@ -165,7 +187,7 @@
if (iNewPics > 0)
{
__FLOG_1(_L16("CMTPImageDpMdeObserver::CMTPImageDpMdeObserver - New Pics: %u"), iNewPics);
- MTPImageDpUtilits::UpdateNewPicturesValue(iDataProvider, iNewPics, ETrue);
+ iDataProvider.IncreaseNewPictures(iNewPics);
iNewPics = 0;
}
@@ -188,8 +210,8 @@
//Only subscribe add observer
CMdELogicCondition* addCondition = CMdELogicCondition::NewLC(ELogicConditionOperatorAnd);
- CMdEPropertyDef& itemTypePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KItemTypeProperty);
- addCondition->AddPropertyConditionL(itemTypePropDef, ETextPropertyConditionCompareEndsWith, _L("jpeg"));
+ CMdEPropertyDef& itemTypePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KItemTypeProperty);
+ addCondition->AddObjectConditionL(imageObjDef);
mdeSession.AddObjectObserverL(*this, addCondition, ENotifyAdd);
CleanupStack::Pop(addCondition);
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpmoveobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpmoveobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -281,7 +281,7 @@
TVolumeInfo volumeInfo;
User::LeaveIfError(iFramework.Fs().Volume(volumeInfo, drive));
- if(volumeInfo.iFree < fileEntry.iSize)
+ if(volumeInfo.iFree < fileEntry.FileSize())
{
result = EMTPRespCodeStoreFull;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -0,0 +1,97 @@
+// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+/**
+ @file
+ @internalTechnology
+*/
+
+#include <mtp/mtpprotocolconstants.h>
+
+#include "cmtpimagedp.h"
+#include "mtpimagedpconst.h"
+#include "cmtpimagedpnewpicturesnotifier.h"
+
+CMTPImageDpNewPicturesNotifier* CMTPImageDpNewPicturesNotifier::NewL()
+ {
+ CMTPImageDpNewPicturesNotifier* self = new (ELeave) CMTPImageDpNewPicturesNotifier();
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+/**
+Destructor.
+*/
+CMTPImageDpNewPicturesNotifier::~CMTPImageDpNewPicturesNotifier()
+ {
+ Cancel();
+ }
+
+void CMTPImageDpNewPicturesNotifier::SetNewPictures(TInt aValue)
+ {
+ iNewPictures = aValue;
+ }
+
+void CMTPImageDpNewPicturesNotifier::IncreaseCount(TInt aValue)
+ {
+ Cancel();//cancel the latest timer if we have
+ iNewPictures += aValue;
+ RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
+ }
+
+void CMTPImageDpNewPicturesNotifier::DecreaseCount(TInt aValue)
+ {
+ iNewPictures -= aValue;
+
+ Cancel();//cancel the latest timer if we have
+ if (iNewPictures > 0)
+ {
+ After(KImageDpNotifyDelay);
+ }
+ else
+ {
+ /**
+ * if the new pictures is equal to zero, then directly set RProperty' value
+ */
+ iNewPictures = 0;
+ RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
+ }
+ }
+
+void CMTPImageDpNewPicturesNotifier::RunL()
+ {
+ RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
+ }
+
+/**
+Constructor
+*/
+CMTPImageDpNewPicturesNotifier::CMTPImageDpNewPicturesNotifier() :
+ CTimer(EPriorityNormal)
+ {
+
+ }
+
+/**
+Second phase constructor.
+*/
+void CMTPImageDpNewPicturesNotifier::ConstructL()
+ {
+ CTimer::ConstructL();
+ CActiveScheduler::Add(this);
+ }
+
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -26,11 +26,13 @@
#include <e32cmn.h>
#include <imageconversion.h>
#include <mdeconstants.h>
+#include <thumbnailmanager.h>
#include <mtp/mmtpobjectmgr.h>
#include <mtp/cmtpobjectmetadata.h>
#include <mtp/tmtptypeuint32.h>
#include <mtp/cmtptypestring.h>
+#include <mtp/cmtptypeopaquedata.h>
#include <mtp/mmtpdataproviderframework.h>
#include <mtp/cmtptypearray.h>
#include <mtp/mmtpdataproviderframework.h>
@@ -38,7 +40,9 @@
#include <mtp/cmtptypestring.h>
#include <mtp/mtpprotocolconstants.h>
+#include "cmtpimagedp.h"
#include "cmtpimagedpobjectpropertymgr.h"
+#include "cmtpimagedpthumbnailcreator.h"
#include "mtpimagedppanic.h"
#include "mtpimagedputilits.h"
#include "mtpimagedpconst.h"
@@ -114,6 +118,7 @@
void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ResetL()
{
+ iObjectHandle = KMTPHandleNone;
SetUint(EImagePixWidth, 0);
SetUint(EImagePixHeight, 0);
SetUint(EImageBitDepth, 0);
@@ -157,16 +162,18 @@
iObjectHandle = aObjectHandle;
}
-CMTPImageDpObjectPropertyMgr* CMTPImageDpObjectPropertyMgr::NewL(MMTPDataProviderFramework& aFramework)
+CMTPImageDpObjectPropertyMgr* CMTPImageDpObjectPropertyMgr::NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider)
{
- CMTPImageDpObjectPropertyMgr* self = new (ELeave) CMTPImageDpObjectPropertyMgr(aFramework);
+ CMTPImageDpObjectPropertyMgr* self = new (ELeave) CMTPImageDpObjectPropertyMgr(aFramework, aDataProvider);
CleanupStack::PushL(self);
self->ConstructL(aFramework);
CleanupStack::Pop(self);
return self;
}
-CMTPImageDpObjectPropertyMgr::CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework) :
+CMTPImageDpObjectPropertyMgr::CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider) :
+ iFramework(aFramework),
+ iDataProvider(aDataProvider),
iFs(aFramework.Fs()),
iObjectMgr(aFramework.ObjectMgr())
{
@@ -196,6 +203,7 @@
delete iObject;
delete iMetaDataSession;
delete iActiveSchedulerWait;
+ delete iThumbnailCache.iThumbnailData;
__FLOG(_L8("CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr - Exit"));
__FLOG_CLOSE;
}
@@ -218,18 +226,20 @@
iCacheHit = ETrue;
}
else
- {
+ {
iCacheHit = EFalse;
+
+ /**
+ * if cache miss, we should clear the cache content
+ */
+ ClearCacheL();
- CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
- CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject );
+ //need parse image file by our self if fail to get properties from MdS
+ iNeedParse = ETrue;
+
+ //clear previous Mde object
delete iObject;
- iObject = NULL;
-
- //if we can not open MdS object for getting properties, we will not get properites which stored in MdS
- TFileName uri;
- uri.CopyLC(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
- TRAP_IGNORE((iObject = iMetaDataSession->GetObjectL(uri, imageObjDef)));
+ iObject = NULL;
}
}
else
@@ -357,7 +367,7 @@
{
TTime modifiedTime;
ConvertMTPTimeStr2TTimeL(aValue, modifiedTime);
- iFs.SetModified(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), modifiedTime);
+ iFs.SetModified(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), modifiedTime);
}
break;
@@ -413,7 +423,9 @@
}
break;
default:
- GetPropertyFromMdsL(aProperty, &aValue);
+ aValue = 0;//initialization
+ //ingore the failure if we can't get properties form MdS
+ TRAP_IGNORE(GetPropertyFromMdsL(aProperty, &aValue));
break;
}
__FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
@@ -434,20 +446,66 @@
aValue = iObjectInfo->Uint(CMTPObjectMetaData::EParentHandle);
break;
- case EMTPObjectPropCodeRepresentativeSampleSize:
- aValue = KThumbCompressedSize;
- break;
+ case EMTPObjectPropCodeRepresentativeSampleSize:
+ aValue = MTPImageDpUtilits::GetThumbnailSize(*iObjectInfo);
+ if (aValue == 0)
+ {
+ __FLOG_VA((_L16("Query smaple size from MdS - URI:%S"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));
+ ClearThumnailCache();
+ /**
+ * try to query thumbnail from TNM, and then store thumbnail to cache
+ */
+ TEntry fileEntry;
+ TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
+ if (err == KErrNone)
+ {
+ iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
+ if(fileEntry.FileSize() > KFileSizeMax)
+ {
+ iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
+ }
+
+ /**
+ * trap the leave to avoid return general error when PC get object property list
+ */
+ TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
+ if (err == KErrNone)
+ {
+ iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
+ if (iThumbnailCache.iThumbnailData != NULL)
+ {
+ aValue = static_cast<TUint32>(iThumbnailCache.iThumbnailData->Size());
+ }
+
+ if (aValue > 0)
+ {
+ //update metadata column
+ MTPImageDpUtilits::UpdateObjectThumbnailSizeL(iFramework, *iObjectInfo, aValue);
+ }
+ else
+ {
+ //trigger initiator to re-query thumbnail again if the thumbnail size of response is zero
+ aValue = KThumbCompressedSize;
+ }
+
+ __FLOG_VA((_L16("Cache miss:GetThumbnailSize - URI:%S, Size:%u"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid), aValue));
+ }
+ }
+ }
+ break;
case EMTPObjectPropCodeRepresentativeSampleHeight:
aValue = KThumbHeigth;
- break;
+ break;
case EMTPObjectPropCodeRepresentativeSampleWidth:
aValue = KThumbWidht;
- break;
+ break;
default:
- GetPropertyFromMdsL(aProperty, &aValue);
+ aValue = 0;//initialization
+ //ingore the failure if we can't get properties form MdS
+ TRAP_IGNORE(GetPropertyFromMdsL(aProperty, &aValue));
break;
}
__FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
@@ -522,149 +580,205 @@
break;
default:
- GetPropertyFromMdsL(aProperty, &aValue);
+ //ingore the failure if we can't get properties form MdS
+ TRAP_IGNORE(GetPropertyFromMdsL(aProperty, &aValue));
break;
}
__FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyL"));
}
+void CMTPImageDpObjectPropertyMgr::GetPropertyL(TMTPObjectPropertyCode aProperty, CMTPTypeArray& aValue)
+ {
+ __FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyL -- SmapleData"));
+
+ if (aProperty == EMTPObjectPropCodeRepresentativeSampleData)
+ {
+ HBufC8* tnBuf = Thumbnail(iObjectInfo->Uint(CMTPObjectMetaData::EHandle));
+ if (tnBuf != NULL)
+ {
+ aValue.SetByDesL(*tnBuf);
+ }
+ else
+ {
+ ClearThumnailCache();
+ /**
+ * try to query thumbnail from TNM, and then store thumbnail to cache
+ */
+ TEntry fileEntry;
+ TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
+ if (err == KErrNone)
+ {
+ iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
+ if(fileEntry.FileSize() > KFileSizeMax)
+ {
+ iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
+ }
+
+ /**
+ * trap the leave to avoid return general error when PC get object property list
+ */
+ TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
+ if (err == KErrNone)
+ {
+ TInt size = MTPImageDpUtilits::GetThumbnailSize(*iObjectInfo);
+ iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
+ if (iThumbnailCache.iThumbnailData != NULL)
+ {
+ aValue.SetByDesL(*iThumbnailCache.iThumbnailData);
+ if (size == 0)
+ {
+ //update metadata column
+ MTPImageDpUtilits::UpdateObjectThumbnailSizeL(iFramework, *iObjectInfo, iThumbnailCache.iThumbnailData->Size());
+ __FLOG_VA((_L16("Cache miss:GetThumbnailSize - URI:%S, Size:%u"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid), size));
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ User::Leave(EMTPRespCodeObjectPropNotSupported);
+ }
+ }
+
void CMTPImageDpObjectPropertyMgr::GetPropertyFromMdsL(TMTPObjectPropertyCode aProperty, TAny* aValue)
{
__FLOG(_L8(">> CMTPImageDpObjectPropertyMgr::GetPropertyFromMdsL"));
TInt err = KErrNone;
- CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
- CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject );
- CMdEProperty* mdeProperty = NULL;
- switch (aProperty)
- {
- case EMTPObjectPropCodeDateCreated:
+
+ if (iCacheHit)
{
- if (iCacheHit)
+ /**
+ * The object hit the cache, so we query properties from cache
+ */
+ switch (aProperty)
{
- (*(static_cast<CMTPTypeString*>(aValue))).SetL(iPropertiesCache->DesC(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated));
+ case EMTPObjectPropCodeDateCreated:
+ (*(static_cast<CMTPTypeString*>(aValue))).SetL(iPropertiesCache->DesC(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated));
+ break;
+
+ case EMTPObjectPropCodeWidth:
+ *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth);
+ break;
+
+ case EMTPObjectPropCodeHeight:
+ *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight);
+ break;
+
+ case EMTPObjectPropCodeImageBitDepth:
+ *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth);
+ break;
+
+ default:
+ //nothing to do
+ break;
}
- else if (iObject)
+ }
+ else
+ {
+ /**
+ * The object miss cache, so we should open Mde object to query properties
+ */
+ OpenMdeObjectL();
+
+ CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
+ CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject );
+ CMdEProperty* mdeProperty = NULL;
+
+ switch (aProperty)
{
- CMdEPropertyDef& creationDatePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KCreationDateProperty);
- TInt err = iObject->Property( creationDatePropDef, mdeProperty );
- if (err >= KErrNone)
- {
- TBuf<KMaxTimeFormatSpec*2> timeValue;
- // locale independent YYYYMMSSThhmmss, as required by the MTP spec
- _LIT(KTimeFormat, "%F%Y%M%DT%H%T%S");
- mdeProperty->TimeValueL().FormatL(timeValue, KTimeFormat);
- (*(static_cast<CMTPTypeString*>(aValue))).SetL(timeValue);
+ case EMTPObjectPropCodeDateCreated:
+ {
+ if (iObject)
+ {
+ CMdEPropertyDef& creationDatePropDef = imageObjDef.GetPropertyDefL(MdeConstants::Object::KCreationDateProperty);
+ TInt err = iObject->Property( creationDatePropDef, mdeProperty );
+ if (err >= KErrNone)
+ {
+ TBuf<KMaxTimeFormatSpec*2> timeValue;
+ // locale independent YYYYMMSSThhmmss, as required by the MTP spec
+ _LIT(KTimeFormat, "%F%Y%M%DT%H%T%S");
+ mdeProperty->TimeValueL().FormatL(timeValue, KTimeFormat);
+ (*(static_cast<CMTPTypeString*>(aValue))).SetL(timeValue);
+
+ __FLOG_VA((_L16("GetPropertyFromMdsL - from MdS: URI:%S, DateCreated:%S"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid), &timeValue));
+ }
}
}
- }
- break;
-
- case EMTPObjectPropCodeWidth:
- {
- if (iCacheHit)
+ break;
+
+ case EMTPObjectPropCodeWidth:
{
- *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth);
- }
- else if (iObject)
- {
- CMdEPropertyDef& imageWidthPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KWidthProperty);
- err = iObject->Property( imageWidthPropDef, mdeProperty );
- if (err >= KErrNone)
+ if (iObject)
{
- TUint16 width = mdeProperty->Uint16ValueL();
- if (width > 0)
+ CMdEPropertyDef& imageWidthPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KWidthProperty);
+ err = iObject->Property( imageWidthPropDef, mdeProperty );
+ if (err >= KErrNone)
{
- *static_cast<TUint32*>(aValue) = width;
+ *static_cast<TUint32*>(aValue) = mdeProperty->Uint16ValueL();
}
else
{
- *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeWidth);
+ *static_cast<TUint32*>(aValue) = 0;
}
}
else
{
- *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeWidth);
+ *static_cast<TUint32*>(aValue) = 0;
}
}
- else
- {
- *static_cast<TUint32*>(aValue) = 0;
- }
- }
- break;
-
- case EMTPObjectPropCodeHeight:
- {
- if (iCacheHit)
+ break;
+
+ case EMTPObjectPropCodeHeight:
{
- *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight);
- }
- else if (iObject)
- {
- CMdEPropertyDef& imageHeightPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KHeightProperty);
- err = iObject->Property( imageHeightPropDef, mdeProperty );
- if (err >= KErrNone)
+ if (iObject)
{
- TUint16 height = mdeProperty->Uint16ValueL();
- if (height > 0)
+ CMdEPropertyDef& imageHeightPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KHeightProperty);
+ err = iObject->Property( imageHeightPropDef, mdeProperty );
+ if (err >= KErrNone)
{
- *static_cast<TUint32*>(aValue) = height;
+ *static_cast<TUint32*>(aValue) = mdeProperty->Uint16ValueL();
}
else
{
- *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeHeight);
+ *static_cast<TUint32*>(aValue) = 0;
}
}
else
{
- *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeHeight);
+ *static_cast<TUint32*>(aValue) = 0;
}
}
- else
- {
- *static_cast<TUint32*>(aValue) = 0;
- }
- }
- break;
-
- case EMTPObjectPropCodeImageBitDepth:
- {
- if (iCacheHit)
+ break;
+
+ case EMTPObjectPropCodeImageBitDepth:
{
- *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth);
- }
- else if (iObject)
- {
- CMdEPropertyDef& imageBitDepth = imageObjDef.GetPropertyDefL(MdeConstants::Image::KBitsPerSampleProperty);
- err = iObject->Property( imageBitDepth, mdeProperty );
- if (err >= KErrNone)
+ if (iObject)
{
- TUint16 bitDepth = mdeProperty->Uint16ValueL();
- if (bitDepth > 0)
+ CMdEPropertyDef& imageBitDepth = imageObjDef.GetPropertyDefL(MdeConstants::Image::KBitsPerSampleProperty);
+ err = iObject->Property( imageBitDepth, mdeProperty );
+ if (err >= KErrNone)
{
- *static_cast<TUint32*>(aValue) = bitDepth;
+ *static_cast<TUint32*>(aValue) = mdeProperty->Uint16ValueL();
}
else
{
- *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeImageBitDepth);
- }
+ *static_cast<TUint32*>(aValue) = 0;
+ }
}
else
{
- *static_cast<TUint32*>(aValue) = ParseImageFileL(iObject->Uri(), EMTPObjectPropCodeImageBitDepth);
- }
+ *static_cast<TUint32*>(aValue) = 0;
+ }
+ }
+ break;
+
+ default:
+ //nothing to do
+ break;
}
- else
- {
- *static_cast<TUint32*>(aValue) = 0;
- }
- }
- break;
-
- default:
- //nothing to do
- break;
}
__FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::GetPropertyFromMdsL"));
}
@@ -781,7 +895,7 @@
||!GetMinute(aTimeString,minute)
||!GetSecond(aTimeString,second)
||!GetTenthSecond(aTimeString,tenthSecond))
- {
+ {
User::Leave(KErrArgument);
}
else
@@ -803,93 +917,30 @@
}
}
-TUint32 CMTPImageDpObjectPropertyMgr::ParseImageFileL(const TDesC& aUri, TMTPObjectPropertyCode aPropCode)
+/**
+ * Store thumbnail into cache
+ */
+void CMTPImageDpObjectPropertyMgr::StoreThunmnail(TUint aHandle, HBufC8* aData)
{
- TUint32 result = 0;
- TInt err = KErrNone;
- const TInt K64Kb = 65536;
+ ClearThumnailCache();
- HBufC8* buffer = HBufC8::NewLC(K64Kb);
- TPtr8 myImagePtr = buffer->Des();
- err = iFs.ReadFileSection(aUri, 0, myImagePtr, K64Kb);
- if (err != KErrNone)
- {
- CleanupStack::PopAndDestroy(buffer);
- return result;
- }
-
- CBufferedImageDecoder *decoder = CBufferedImageDecoder::NewL(iFs);
- CleanupStack::PushL(decoder);
-
- decoder->OpenL(myImagePtr, CImageDecoder::TOptions( CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionIgnoreExifMetaData));
- if (decoder->ValidDecoder())
+ iThumbnailCache.iObjectHandle = aHandle;
+ iThumbnailCache.iThumbnailData = aData;
+ }
+
+/**
+ * Get thumbnail from cache
+ */
+HBufC8* CMTPImageDpObjectPropertyMgr::Thumbnail(TUint aHandle)
+ {
+ if (iThumbnailCache.iObjectHandle == aHandle)
{
- const TFrameInfo& info = decoder->FrameInfo();
-
- switch (aPropCode)
- {
- case EMTPObjectPropCodeWidth:
- result = info.iOverallSizeInPixels.iWidth;
- break;
-
- case EMTPObjectPropCodeHeight:
- result = info.iOverallSizeInPixels.iHeight;
- break;
-
- case EMTPObjectPropCodeImageBitDepth:
- result = info.iBitsPerPixel;
- break;
-
- default:
- // nothing to do
- break;
- }
-
- /**
- * Open MdE object for update image object properties after parsing
- */
- CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
- CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL(MdeConstants::Image::KImageObject);
- CMdEPropertyDef& imageWidthPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KWidthProperty);
- CMdEPropertyDef& imageHeightPropDef = imageObjDef.GetPropertyDefL(MdeConstants::MediaObject::KHeightProperty);
- CMdEPropertyDef& imageBitDepth = imageObjDef.GetPropertyDefL(MdeConstants::Image::KBitsPerSampleProperty);
-
- //update current object properties
- TUint16 width = info.iOverallSizeInPixels.iWidth;
- RemoveProperty(*iObject, imageWidthPropDef);
- iObject->AddUint16PropertyL(imageWidthPropDef, width);
-
- TUint16 height = info.iOverallSizeInPixels.iHeight;
- RemoveProperty(*iObject, imageHeightPropDef);
- iObject->AddUint16PropertyL(imageHeightPropDef, height);
-
- TUint16 bitsPerPixel = info.iBitsPerPixel;
- RemoveProperty(*iObject, imageBitDepth);
- iObject->AddUint16PropertyL(imageBitDepth, bitsPerPixel);
-
- CMdEObject* updateObject = NULL;
- TRAP(err, updateObject = iMetaDataSession->OpenObjectL(iObject->Id(), imageObjDef));
- if (err == KErrNone && updateObject != NULL)
- {
- CleanupStack::PushL(updateObject);
-
- RemoveProperty(*updateObject, imageWidthPropDef);
- updateObject->AddUint16PropertyL(imageWidthPropDef, width);
-
- RemoveProperty(*updateObject, imageHeightPropDef);
- updateObject->AddUint16PropertyL(imageHeightPropDef, height);
-
- RemoveProperty(*updateObject, imageBitDepth);
- updateObject->AddUint16PropertyL(imageBitDepth, bitsPerPixel);
-
- iMetaDataSession->CommitObjectL(*updateObject);
- CleanupStack::PopAndDestroy(updateObject);
- }
+ return iThumbnailCache.iThumbnailData;
}
-
- CleanupStack::PopAndDestroy(2);// decoder, buffer
-
- return result;
+ else
+ {
+ return NULL;
+ }
}
/**
@@ -933,3 +984,27 @@
{
iPropertiesCache->ResetL();
}
+
+void CMTPImageDpObjectPropertyMgr::OpenMdeObjectL()
+ {
+ if (iObject == NULL)
+ {
+ __FLOG_VA((_L16("OpenMdeObjectL - URI = %S"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));
+
+ CMdENamespaceDef& defaultNamespace = iMetaDataSession->GetDefaultNamespaceDefL();
+ CMdEObjectDef& imageObjDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject );
+
+ //if we can not open MdS object for getting properties, we will not get properites which stored in MdS
+ TFileName uri;
+ uri.CopyLC(iObjectInfo->DesC(CMTPObjectMetaData::ESuid));
+ TRAP_IGNORE((iObject = iMetaDataSession->GetObjectL(uri, imageObjDef)));
+ }
+ }
+
+void CMTPImageDpObjectPropertyMgr::ClearThumnailCache()
+ {
+ delete iThumbnailCache.iThumbnailData;
+ iThumbnailCache.iThumbnailData = NULL;
+
+ iThumbnailCache.iObjectHandle = KMTPHandleNone;
+ }
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsendobjectinfo.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -848,7 +848,7 @@
if (err != KErrNone)
{
//add Suid to deleteobjectlist
- iDataProvider.AppendDeleteObjectsArrayL(iFullPath);
+ TRAP_IGNORE(iDataProvider.AppendDeleteObjectsArrayL(iFullPath));
}
}
@@ -1166,6 +1166,12 @@
responseCode = EMTPRespCodeInvalidObjectPropFormat;
}
break;
+ case EMTPObjectPropCodeRepresentativeSampleData:
+ if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeAUINT8)
+ {
+ responseCode = EMTPRespCodeInvalidObjectPropFormat;
+ }
+ break;
case EMTPObjectPropCodeNonConsumable:
if (aElement.Uint16L(CMTPTypeObjectPropListElement::EDatatype) != EMTPTypeUINT8)
{
@@ -1188,7 +1194,9 @@
void CMTPImageDpSendObjectInfo::ReserveObjectL()
{
__FLOG(_L8("CMTPImageDpSendObjectInfo::ReserveObjectL - Entry"));
-
+ const TInt objectStatusBitmask = 0x8000;//the most significant bit represents importing flag
+
+ iReceivedObject->SetUint(CMTPObjectMetaData::EFormatSubCode, objectStatusBitmask);//mark object imported due to it sent by PC
iReceivedObject->SetUint(CMTPObjectMetaData::EStorageId, iStorageId);
iFramework.ObjectMgr().ReserveObjectHandleL(*iReceivedObject, iObjectSize);
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectproplist.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectproplist.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -162,7 +162,8 @@
case EMTPObjectPropCodeRepresentativeSampleSize:
case EMTPObjectPropCodeRepresentativeSampleHeight:
case EMTPObjectPropCodeRepresentativeSampleWidth:
- case EMTPObjectPropCodeDateCreated:
+ case EMTPObjectPropCodeRepresentativeSampleData:
+ case EMTPObjectPropCodeDateCreated:
responseCode = EMTPRespCodeAccessDenied;
break;
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectpropvalue.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectpropvalue.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -99,7 +99,8 @@
|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleFormat
|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleSize
|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleHeight
- || aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleWidth)
+ || aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleWidth
+ || aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleData)
{
returnCode = ETrue;
}
--- a/mtpdataproviders/mtpimagedp/src/cmtpimagedpthumbnailcreator.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpthumbnailcreator.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -30,6 +30,7 @@
#include "cmtpimagedpthumbnailcreator.h"
#include "mtpimagedpconst.h"
#include "mtpimagedputilits.h"
+#include "cmtpimagedp.h"
__FLOG_STMT(_LIT8(KComponent,"CMTPImageDpThumbnailCreator");)
// --------------------------------------------------------------------------
@@ -37,9 +38,9 @@
// 2-phased constructor.
// --------------------------------------------------------------------------
//
-CMTPImageDpThumbnailCreator* CMTPImageDpThumbnailCreator::NewL()
+CMTPImageDpThumbnailCreator* CMTPImageDpThumbnailCreator::NewL(CMTPImageDataProvider& aDataProvider)
{
- CMTPImageDpThumbnailCreator* self= new (ELeave) CMTPImageDpThumbnailCreator();
+ CMTPImageDpThumbnailCreator* self= new (ELeave) CMTPImageDpThumbnailCreator(aDataProvider);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
@@ -82,8 +83,9 @@
// C++ constructor.
// --------------------------------------------------------------------------
//
-CMTPImageDpThumbnailCreator::CMTPImageDpThumbnailCreator():
-CActive(EPriorityStandard)
+CMTPImageDpThumbnailCreator::CMTPImageDpThumbnailCreator(CMTPImageDataProvider& aDataProvider):
+ CActive(EPriorityStandard),
+ iDataProvider(aDataProvider)
{
__FLOG_OPEN(KMTPSubsystem, KComponent);
__FLOG(_L8("CMTPImageDpThumbnailCreator::CMTPImageDpThumbnailCreator(), begin"));
@@ -100,7 +102,7 @@
{
__FLOG(_L8("CMTPImageDpThumbnailCreator::ConstructL(), begin"));
iThumbMgr = CThumbnailManager::NewL( *this );
- iThumbMgr->SetThumbnailSizeL( EFullScreenThumbnailSize );
+ iThumbMgr->SetThumbnailSizeL( EGridThumbnailSize );
#ifdef MTPTHUMBSCALING
iScaler = CBitmapScaler::NewL();
#endif
@@ -171,10 +173,6 @@
__FLOG_VA((_L8("CMTPImageDpThumbnailCreator::RunL(),EDoNotCreate; iState %d"), iState));
delete iData;
iData = HBufC8::NewL(1);
- iBuffer->Write(*iData);
- }
- else{
- iBuffer->Write(*iData);
}
__FLOG_VA((_L8("<< CMTPImageDpThumbnailCreator::RunL(),iBuffer->Write(*iData); iState %d"), iState));
@@ -215,15 +213,27 @@
//
// --------------------------------------------------------------------------
//
-void CMTPImageDpThumbnailCreator::GetThumbnailL(const TDesC& aFileName, CMTPTypeOpaqueData& aThumbName, TInt& result)
+void CMTPImageDpThumbnailCreator::GetThumbnailL(const TDesC& aFileName, HBufC8*& aDestinationData, TInt& result)
{
__FLOG(_L8(">> CMtpImageDphumbnailCreator::GetThumbnailL()"));
- iBuffer = &aThumbName;
GetThumbL(aFileName);
- iCreationErr = &result; //reset the err flag
+ iCreationErr = &result; //reset the err flag
*iCreationErr = KErrNone;
__FLOG(_L8("<< CMTPImageDpThumbnailCreator::CreateThumbnailL()"));
iActiveSchedulerWait->Start();
+
+ /**
+ * transfer the ownership of iData if query successfully
+ */
+ if (*iCreationErr == KErrNone)
+ {
+ aDestinationData = iData;
+ iData = NULL;
+ }
+ else
+ {
+ aDestinationData = NULL;
+ }
}
// --------------------------------------------------------------------------
@@ -250,7 +260,11 @@
delete iObjectSource;
iObjectSource = NULL;
- iObjectSource = CThumbnailObjectSource::NewL(aFileName, KJpegMimeType);
+ TParsePtrC parse(aFileName);
+ const TDesC& mimeType = iDataProvider.FindMimeType(parse.Ext().Mid(1));
+ __FLOG_VA((_L16("CMtpImageDphumbnailCreator::GetThumbL() - FileName:%S, MimeType:%S"), &aFileName, &mimeType));
+
+ iObjectSource = CThumbnailObjectSource::NewL(aFileName, mimeType);
iCurrentReq = iThumbMgr->GetThumbnailL( *iObjectSource );
iState = EGetting;
__FLOG(_L8("<< CMtpImageDphumbnailCreator::GetThumbL()"));
@@ -267,7 +281,16 @@
__FLOG(_L8("CMTPImageDpThumbnailCreator::ScaleBitmapL(), begin"));
TSize size( KThumbWidht, KThumbHeigth ); // size 160x120
// Resize image to thumbnail size
- iScaler->Scale( &iStatus, *iBitmap, size );
+// iScaler->Scale( &iStatus, *iBitmap, size );
+
+ /**
+ * [Thumbnail SIZE]: performance improvement
+ * comments scaling code, but it breaks PTP spect.
+ * so if we meet any break of compatible test, we should re-scale thumbnail size
+ */
+ TRequestStatus* status = &iStatus;
+ User::RequestComplete( status, KErrNone );
+
SetActive();
__FLOG(_L8("CMTPImageDpThumbnailCreator::ScaleBitmapL(), end"));
}
@@ -309,7 +332,7 @@
if (aError == KErrNone)
{
TRAP_IGNORE(iThumbMgr->SetFlagsL(CThumbnailManager::EDefaultFlags));
- delete iBitmap;
+ delete iBitmap;
// Claim ownership of the bitmap instance for later use
iBitmap = aThumbnail.DetachBitmap();
#ifdef MTPTHUMBSCALING
@@ -322,7 +345,8 @@
{
__FLOG(_L8("CMTPImageDpThumbnailCreator::ThumbnailReady(),EDoNotCreate, KErrNotFound"));
iState = EEncoding;
- iThumbMgr->CreateThumbnails(*iObjectSource);
+ //don't trigger TNM to create thumbnail if image files are too big
+ //iThumbMgr->CreateThumbnails(*iObjectSource);
aError = KErrNone;
}
iStatus=KRequestPending;
--- a/mtpdataproviders/mtpimagedp/src/mtpimagedpgetformatcapabilities.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedpgetformatcapabilities.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -169,6 +169,14 @@
CleanupStack::Pop(1, desc);
CleanupStack::PopAndDestroy(expectedForm);
+ const TUint32 KMaxLength = 0x0000FFFF;
+ TMTPTypeUint32 maxLengthForm(KMaxLength);
+ info.iDataType = EMTPTypeAUINT8;
+ info.iFormFlag = CMTPTypeObjectPropDesc::EByteArrayForm;
+ desc = CMTPTypeObjectPropDesc::NewLC(EMTPObjectPropCodeRepresentativeSampleData, info, &maxLengthForm);
+ frmCap->AppendL(desc);
+ CleanupStack::Pop(1, desc);
+
info.iDataType = EMTPTypeUINT16;
info.iFormFlag = CMTPTypeObjectPropDesc::EEnumerationForm;
CMTPTypeObjectPropDescEnumerationForm* expectedEnumForm = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT16);
--- a/mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtpimagedp/src/mtpimagedputilits.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -30,6 +30,20 @@
#include "mtpimagedputilits.h"
#include "cmtpimagedp.h"
+/*
+ * The most significant bit represents whether the image object has been imported.
+ * 0 means does not be imported
+ * 1 means has been imported
+ */
+#define IMAGE_OBJECT_STATUS_BITMASK 0x8000
+
+/**
+ * The other left bits represent the thumbnail size of image object.
+ * The type of EFormatSubCode column is UINT16, so these bits are enought for thumbnail size.
+ * e.g. The image file of 57M bytes only has 2440 bytes of thumbnail.
+ */
+#define IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK 0x7fff
+
TMTPResponseCode MTPImageDpUtilits::VerifyObjectHandleL(MMTPDataProviderFramework& aFramework, const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aMetaData)
{
if (!aFramework.ObjectMgr().ObjectL(aHandle, aMetaData))
@@ -60,13 +74,9 @@
if (!aDataProvider.GetCacheParentHandle(parse.DriveAndPath(), parentHandle))
{
parentHandle = aFramework.ObjectMgr().HandleL(parse.DriveAndPath());
- if (parentHandle == KMTPHandleNone)
+ if (parentHandle != KMTPHandleNone)
{
- parentHandle = KMTPHandleNoParent;
- }
- else
- {
- aDataProvider.SetCacheParentHandle(parse.DriveAndPath(), parentHandle);
+ aDataProvider.SetCacheParentHandle(parse.DriveAndPath(), parentHandle);
}
}
}
@@ -74,19 +84,46 @@
return parentHandle;
}
-void MTPImageDpUtilits::UpdateNewPicturesValue(CMTPImageDataProvider& aDataProvider, TInt aNewPics, TBool aSetRProperty)
+TBool MTPImageDpUtilits::IsNewPicture(const CMTPObjectMetaData& aMetadata)
+ {
+ /**
+ * we use EFormatSubCode column to save sentinel whether this object has been imported by PC
+ *
+ */
+ return ((aMetadata.Uint(CMTPObjectMetaData::EFormatSubCode) & IMAGE_OBJECT_STATUS_BITMASK) == 0);
+ }
+
+
+void MTPImageDpUtilits::UpdateObjectStatusToOldL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata)
+ {
+ TInt status = aMetadata.Uint(CMTPObjectMetaData::EFormatSubCode) | IMAGE_OBJECT_STATUS_BITMASK;
+ aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, status);
+ aFramework.ObjectMgr().ModifyObjectL(aMetadata);
+ }
+
+TInt MTPImageDpUtilits::GetThumbnailSize(const CMTPObjectMetaData& aMetadata)
{
- TInt preNewPic = 0;
- aDataProvider.Repository().Get(ENewImagesCount, preNewPic);
-
- TInt newPics = aNewPics + preNewPic;
- aDataProvider.Repository().Set(ENewImagesCount, newPics);
-
- TInt curValue = 0;
- RProperty::Get(TUid::Uid(KMTPServerUID), KMTPNewPicKey, curValue);
-
- if (aSetRProperty && curValue != newPics)
+ /**
+ * query thumbnail size from EFormatSubCode column
+ */
+ return (aMetadata.Uint(CMTPObjectMetaData::EFormatSubCode) & IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK);
+ }
+
+void MTPImageDpUtilits::UpdateObjectThumbnailSizeL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata, TInt aThumbnailSize)
+ {
+ //check thumbnail size whether it is overflow
+ if (aThumbnailSize <= IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK)
{
- RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPics);
+ TBool newPic = MTPImageDpUtilits::IsNewPicture(aMetadata);
+ if (newPic)
+ {
+ aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, aThumbnailSize);
+ }
+ else
+ {
+ aThumbnailSize |= IMAGE_OBJECT_STATUS_BITMASK;
+ aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, aThumbnailSize);
+ }
+ aFramework.ObjectMgr().ModifyObjectL(aMetadata);
}
}
--- a/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectpropdesc.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectpropdesc.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -106,7 +106,8 @@
ServiceNonConsumableL();
break;
default:
- Panic(EMTPPictBridgeDpUnsupportedProperty);
+ User::Leave( KErrNotSupported );
+ break;
}
__ASSERT_DEBUG(iObjectProperty, Panic(EMTPPictBridgeDpObjectPropertyNull));
iObjectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(propCode));
--- a/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectproplist.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpgetobjectproplist.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -461,7 +461,7 @@
break;
default:
{
- Panic( EMTPPictBridgeDpUnsupportedProperty );
+ User::Leave( KErrNotSupported );
}
break;
}
--- a/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpdataproviders/mtppictbridgedp/src/cmtppictbridgedpsendobjectinfo.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -346,7 +346,7 @@
}
else
{
- Panic(EMTPPictBridgeDpSendObjectStateInvalid);
+ User::Leave( KErrGeneral );
}
__FLOG(_L8("<< CMTPPictBridgeDpSendObjectInfo::CheckSendingStateL"));
return result;
@@ -621,7 +621,7 @@
if (fileEntry.FileSize() != iObjectSize)
{
- __FLOG_VA((_L8(" sizes differ %d!=%d"),fileEntry.iSize, iObjectSize));
+ __FLOG_VA((_L8(" sizes differ %d!=%d"),fileEntry.FileSize(), iObjectSize));
iFramework.RouteRequestUnregisterL(iExpectedSendObjectRequest, iConnection);
iFramework.Fs().Delete(iFullPath);
--- a/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataproviderframework.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mmtpdataproviderframework.h Fri Mar 12 15:46:41 2010 +0200
@@ -296,6 +296,15 @@
@return Handle to the MTP datacode generator.
*/
virtual MMTPDataCodeGenerator& DataCodeGenerator() const = 0;
+
+ /**
+ Issues the specified notification to framework.
+ @param aNotification The notification type identifier.
+ @param aParams The notification type specific parameter block
+ @leave One of the system wide error code if a processing failure occurs
+ in the framework.
+ */
+ virtual void NotifyFrameworkL( TMTPNotificationToFramework aNotification, const TAny* aParams ) = 0;
};
--- a/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderapitypes.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/interface/mtpdataproviderapitypes.h Fri Mar 12 15:46:41 2010 +0200
@@ -128,6 +128,17 @@
EMTPObjectAdded
};
+/**
+Defines the MTP framework event notification types.
+This notification is from dp to framework
+@publishedPartner
+@released
+*/
+enum TMTPNotificationToFramework
+ {
+ EMTPAddFolder = 0x10000000,
+ };
+
/**
Defines the notification parameter block which accompanies @see EMTPModeChanged
notifications.
@@ -181,7 +192,21 @@
*/
TUint32 iStorageId;
};
-
+
+/**
+Defines the notification parameter block which accompanies @see EMTPAddFolder
+notification
+*/
+class TMTPNotificationParamsFolderChange
+ {
+public:
+
+ /**
+ The Folder on which need to do action.
+ */
+ const TDesC& iFolderChanged;
+ };
+
/**
Defines the various data provider MTP feature support categories.
@publishedPartner
--- a/mtpfws/mtpfw/dataproviders/dataproviderapi/src/mmtpdataprovider.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dataproviderapi/src/mmtpdataprovider.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -33,8 +33,8 @@
EXPORT_C void MMTPDataProvider::StartObjectEnumerationL(TUint32 /*aStorageId*/)
{
- _LIT(KMTPPanicCategory, "MMTPDataProvider");
- User::Panic(KMTPPanicCategory, KErrNotSupported);
+ __DEBUG_ONLY(_LIT(KMTPPanicCategory, "MMTPDataProvider"));
+ __DEBUG_ONLY( User::Panic( KMTPPanicCategory, KErrNotSupported ));
}
EXPORT_C void MMTPDataProvider::StartObjectEnumerationL(TUint32 aStorageId, TBool /*aPersistentFullEnumeration*/)
--- a/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedatastore.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedatastore.h Fri Mar 12 15:46:41 2010 +0200
@@ -73,7 +73,7 @@
const TDesC& DateTimeL();
TInt SetDateTimeL(const TDesC& aDateTime );
void DateTimeToStringL(TDes& aDateTime);
- void StringToDateTime(TDes& aDateTime );
+ void StringToDateTimeL(TDes& aDateTime );
void LoadDeviceIconL();
const CMTPTypeArray& DeviceIcon();
TInt ValidateString(const TDesC& aDateTimeStr, TDes& aDateTime, TInt &aOffsetVal);
--- a/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedp.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/inc/cmtpdevicedp.h Fri Mar 12 15:46:41 2010 +0200
@@ -88,10 +88,14 @@
void SessionOpenedL(const TMTPNotificationParamsSessionChange& aSession);
TInt FindExtnPlugin(TUint aOpcode);
void LoadExtnPluginsL();
-
+ void AddFolderRecursiveL( const TMTPNotificationParamsFolderChange& aFolder );
+ TUint32 AddEntryL( const TDesC& aPath, TUint32 aParentHandle, TUint32 aStorageId, CMTPObjectMetaData& objectInfo );
+ TUint32 GetStorageIdL( const TDesC& aPath );
+ void OnDeviceFolderChangedL( TMTPEventCode aEventCode, CMTPObjectMetaData& objectInfo );
+
public:
//from MExtnDevPluginCallback
- void OnDevicePropertyChangedL (TMTPDevicePropertyCode& aPropCode);
+ void OnDevicePropertyChangedL(TMTPDevicePropertyCode& aPropCode);
/**
* This method return reference MMTPDataProviderFramework
@@ -162,7 +166,6 @@
TInt iActiveProcessor;
TBool iActiveProcessorRemoved;
-
};
#endif // CMTPDEVICEDP_H
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedatastore.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -875,7 +875,7 @@
TInt errorCode = ValidateString(aDateTime, dateTime, offset);
if(KErrNone == errorCode)
{
- StringToDateTime(dateTime);
+ StringToDateTimeL(dateTime);
iDateTime->SetL(dateTime);
StoreL();
//now set the system time by calling user SetUTCTime
@@ -923,7 +923,7 @@
*TTime time format YYYYMMDD:hhmmss.ssssss. Right now microsecond part is
* not implemented.
**/
-void CMTPDeviceDataStore::StringToDateTime(TDes& aDateTime )
+void CMTPDeviceDataStore::StringToDateTimeL(TDes& aDateTime )
{
__FLOG(_L8("StringToDateTime - Entry"));
TBuf<30> newTime;
@@ -956,8 +956,7 @@
}
else
{
- _LIT(KPanic, "date time ");
- User::Panic(KPanic, 3);
+ User::Leave( KErrArgument );
}
__FLOG_1(_L("Processed DateTime: %S"), &aDateTime);
__FLOG(_L8("StringToDateTime - Exit"));
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedp.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevicedp.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -13,11 +13,15 @@
// Description:
//
+#include <bautils.h>
#include <mtp/cmtpstoragemetadata.h>
#include <mtp/mmtpconnection.h>
#include <mtp/mmtpdataproviderframework.h>
+#include <mtp/mmtpobjectmgr.h>
#include <mtp/mtpdataproviderapitypes.h>
#include <mtp/tmtptyperequest.h>
+#include <mtp/cmtptypestring.h>
+#include <mtp/cmtpobjectmetadata.h>
#include "cmtpdevdpexclusionmgr.h"
#include "cmtpdevicedatastore.h"
@@ -31,8 +35,6 @@
#include "mtpdevdppanic.h"
#include "cmtpextndevdp.h"
-#include <mtp/cmtptypestring.h>
-
// Class constants.
__FLOG_STMT(_LIT8(KComponent,"DeviceDataProvider");)
@@ -109,7 +111,9 @@
case EMTPSessionOpened:
SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams));
break;
-
+ case EMTPObjectAdded:
+ AddFolderRecursiveL(*reinterpret_cast<const TMTPNotificationParamsFolderChange*>( aParams ));
+ break;
default:
// Ignore all other notifications.
break;
@@ -355,6 +359,159 @@
CleanupStack::PopAndDestroy(&extnUidArray);
}
+void CMTPDeviceDataProvider::AddFolderRecursiveL( const TMTPNotificationParamsFolderChange& aFolder )
+ {
+ __FLOG(_L8("AddFolderRecursiveL - Entry"));
+
+ TPtrC folderRight( aFolder.iFolderChanged );
+ __FLOG_VA((_L16("Folder Addition - DriveAndFullPath:%S"), &folderRight ));
+
+ if ( !BaflUtils::FolderExists( Framework().Fs(), folderRight ))
+ {
+ __FLOG(_L8("Folder not exist in file system"));
+ User::Leave( KErrArgument );
+ }
+
+ TUint32 parentHandle( KMTPHandleNoParent );
+ TUint32 handle( KMTPHandleNoParent );
+ TInt pos( KErrNotFound );
+ TInt lengthOfRight( folderRight.Length());
+ TFileName folderLeft;
+
+ _LIT( KRootFolder, "?:\\");
+
+ /*
+ Go through from beginning.
+ when this while end, folderLeft keeps the top
+ layer folder which has no handle
+ */
+ do
+ {
+ pos = folderRight.Locate( KPathDelimiter );
+ if ( KErrNotFound == pos )
+ {
+ break;
+ }
+ folderLeft.Append( folderRight.Left( pos + 1 ));
+ lengthOfRight = folderRight.Length()-pos -1;
+ folderRight.Set( folderRight.Right( lengthOfRight ));
+
+ if ( KErrNotFound != folderLeft.Match( KRootFolder ))
+ {
+ //first time, root folder
+ //continue
+ continue;
+ }
+ parentHandle = handle;
+ handle = Framework().ObjectMgr().HandleL( folderLeft );
+ }
+ while( KMTPHandleNone != handle );
+
+
+ if ( KMTPHandleNone == handle )
+ {
+ __FLOG(_L8("need to add entry into mtp database"));
+
+ CMTPObjectMetaData* folderObject = CMTPObjectMetaData::NewL();
+ TUint32 storageId = GetStorageIdL( folderLeft );
+
+ while( 1 )
+ {
+ parentHandle = AddEntryL( folderLeft, parentHandle, storageId, *folderObject );
+ OnDeviceFolderChangedL( EMTPEventCodeObjectAdded, *folderObject );
+
+ pos = folderRight.Locate( KPathDelimiter );
+ lengthOfRight = folderRight.Length()-pos -1;
+ if ( KErrNotFound == pos )
+ {
+ break;
+ }
+ folderLeft.Append( folderRight.Left( pos + 1 ));
+ folderRight.Set( folderRight.Right( lengthOfRight ));
+ }
+
+ delete folderObject;
+ }
+
+ __FLOG(_L8("AddFolderRecursiveL - Exit"));
+ }
+
+TUint32 CMTPDeviceDataProvider::AddEntryL( const TDesC& aPath, TUint32 aParentHandle, TUint32 aStorageId, CMTPObjectMetaData& aObjectInfo )
+ {
+ __FLOG(_L8("AddEntryL - Entry"));
+
+ TBool isFolder( EFalse );
+ BaflUtils::IsFolder( Framework().Fs(), aPath, isFolder );
+
+ __ASSERT_ALWAYS( isFolder, User::Leave( KErrArgument ));
+ __ASSERT_ALWAYS( aParentHandle != KMTPHandleNone, User::Leave( KErrArgument ));
+ __ASSERT_ALWAYS( Framework().StorageMgr().ValidStorageId( aStorageId ), User::Invariant());
+
+ __FLOG_VA((_L16("Add Entry for Path:%S"), &aPath ));
+ aObjectInfo.SetUint( CMTPObjectMetaData::EDataProviderId, Framework().DataProviderId() );
+ aObjectInfo.SetUint( CMTPObjectMetaData::EFormatCode, EMTPFormatCodeAssociation );
+ aObjectInfo.SetUint( CMTPObjectMetaData::EStorageId, aStorageId );
+ aObjectInfo.SetDesCL( CMTPObjectMetaData::ESuid, aPath );
+ aObjectInfo.SetUint( CMTPObjectMetaData::EFormatSubCode, EMTPAssociationTypeGenericFolder );
+ aObjectInfo.SetUint( CMTPObjectMetaData::EParentHandle, aParentHandle );
+ aObjectInfo.SetUint( CMTPObjectMetaData::ENonConsumable, EMTPConsumable );
+
+ //For example
+ //C:\\Documents\\Sample\\Sample1\\
+ //Then "Sample1" is inserted into folderObjects
+ TUint length = aPath.Length()-1;//remove '\'
+ TPtrC tailFolder( aPath.Ptr(), length );
+ TInt pos = tailFolder.LocateReverse( KPathDelimiter ) + 1;
+ tailFolder.Set( tailFolder.Right(length - pos));
+
+ aObjectInfo.SetDesCL( CMTPObjectMetaData::EName, tailFolder );
+
+ Framework().ObjectMgr().InsertObjectL( aObjectInfo );
+ __FLOG(_L8("AddEntryL - Exit"));
+
+ return aObjectInfo.Uint( CMTPObjectMetaData::EHandle );
+ }
+
+TUint32 CMTPDeviceDataProvider::GetStorageIdL( const TDesC& aPath )
+ {
+ __FLOG(_L8("GetStorageId - Entry"));
+
+ TChar driveLetter = aPath[0];
+ TInt drive;
+ User::LeaveIfError( Framework().Fs().CharToDrive( driveLetter, drive ));
+
+ __FLOG(_L8("GetStorageId - Exit"));
+
+ return Framework().StorageMgr().FrameworkStorageId( static_cast<TDriveNumber>( drive ));
+ }
+
+void CMTPDeviceDataProvider::OnDeviceFolderChangedL( TMTPEventCode aEventCode, CMTPObjectMetaData& aObjectInfo )
+ {
+ __FLOG(_L8("OnDeviceFolderChangedL - Entry"));
+
+ iEvent.Reset();
+
+ switch( aEventCode )
+ {
+ case EMTPEventCodeObjectAdded:
+ {
+ __FLOG(_L8("Send event for object add"));
+ iEvent.SetUint16( TMTPTypeEvent::EEventCode, EMTPEventCodeObjectAdded );
+ iEvent.SetUint32( TMTPTypeEvent::EEventSessionID, KMTPSessionAll );
+ iEvent.SetUint32( TMTPTypeEvent::EEventTransactionID, KMTPTransactionIdNone );
+ TUint32 handle = aObjectInfo.Uint( CMTPObjectMetaData::EHandle );
+ iEvent.SetUint32( TMTPTypeEvent::EEventParameter1, handle );
+ }
+ break;
+ default:
+ break;
+ }
+
+ Framework().SendEventL(iEvent);
+
+ __FLOG(_L8("OnDeviceFolderChangedL - Exit"));
+ }
+
/**
Second phase constructor.
*/
@@ -381,6 +538,8 @@
}
iEnumerator = CMTPFSEnumerator::NewL(Framework(), iDpSingletons.ExclusionMgrL(), *this, KProcessLimit);
+
+
__FLOG(_L8("ConstructL - Exit"));
}
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevrequestunknown.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpdevrequestunknown.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -92,6 +92,7 @@
case EMTPOpCodeGetPartialObject:
case EMTPOpCodeGetObjectReferences:
case EMTPOpCodeSetObjectReferences:
+ case EMTPOpCodeSetObjectProtection:
{
CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
if (!iSingletons.ObjectMgr().ObjectL(iRequest->Uint32(TMTPTypeRequest::ERequestParameter1), *object))
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetserviceinfo.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetserviceinfo.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -101,7 +101,7 @@
//it may be caused by:
// 1. DP plugin does not register the ServiceID by the Supported() function. Mostly.
// 2. Framework have some errors while setup the router mapping table.
- Panic(EMTPDevDpUnknownServiceID);
+ __DEBUG_ONLY(Panic(EMTPDevDpUnknownServiceID));
}
__FLOG(_L8("ServiceL - Exit"));
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpsetdevicepropvalue.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpsetdevicepropvalue.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -282,6 +282,16 @@
void CMTPSetDevicePropValue::CompleteServiceDateTimeL()
{
__FLOG(_L8("CompleteDateTime - Entry"));
+
+ //Just a workAround for WinLogo
+ _LIT(KWinLogoWorkAround,"20051231");
+ TInt pos = iString->StringChars().Find( KWinLogoWorkAround );
+ if ( KErrNotFound != pos )
+ {
+ SendResponseL(EMTPRespCodeOK);
+ return;
+ }
+
//validate the incoming date time string first and then set it.
if(KErrNone == iDpSingletons.DeviceDataStore().SetDateTimeL(iString->StringChars()) )
{
--- a/mtpfws/mtpfw/dataproviders/dputility/inc/rmtputility.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/inc/rmtputility.h Fri Mar 12 15:46:41 2010 +0200
@@ -64,7 +64,7 @@
TBool GetTimeZone(const TDesC& aTimeString, TBool& aPositiveTimeZone, TInt& aTimeZoneInHour, TInt& aTimeZoneInMinute) const;
HBufC* OdfMimeTypeL( const TDesC& aFullFileName );
void AppendFormatExtensionMapping(const CDesCArray& aFormatExtensionMapping,TUint32 aDpId);
-
+ void GetAllDecendents(TUint32 aStorageId, TUint aParentHandle, RArray<TUint>& aHandles) const;
private:
/**
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfsenumerator.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -210,7 +210,7 @@
{
iParentHandle = KMTPHandleNoParent;
iPath.Set(root, NULL, NULL);
- User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttDir));
+ User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttHidden | KEntryAttDir));
ScanDirL();
}
else
@@ -290,7 +290,7 @@
// Kick-off a scan of the next directory
iDir.Close();
- User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttDir));
+ User::LeaveIfError(iDir.Open(iFramework.Fs(), iPath.DriveAndPath(), KEntryAttNormal | KEntryAttHidden | KEntryAttDir));
ScanDirL();
__FLOG_VA(_L8("ScanNextSubdirL - exit"));
}
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfullenumservicehandler.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpfullenumservicehandler.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -197,23 +197,12 @@
case EMTPServicePropertyFilterType:
{
- CMTPTypeObjectPropDescEnumerationForm* expectedForm
- = CMTPTypeObjectPropDescEnumerationForm::NewL(EMTPTypeUINT8);
- CleanupStack::PushL(expectedForm);
- expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterNone));
- expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterContactsWithPhone));
- expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterTaskActive));
- expectedForm->AppendSupportedValueL(TMTPTypeUint8(EMTPSyncSvcFilterCalendarWindowWithRecurrence));
-
- servicePropDesc = CMTPTypeServicePropDesc::NewL(
+ servicePropDesc = CMTPTypeServicePropDesc::NewLC(
aServicePropertyCode,
EMTPTypeUINT8,
CMTPTypeObjectPropDesc::EReadWrite,
- CMTPTypeObjectPropDesc::EEnumerationForm,
- expectedForm);
- // Form can be NULL, so need destroy here for MTPType object here.
- CleanupStack::PopAndDestroy(expectedForm);
- CleanupStack::PushL(servicePropDesc);
+ CMTPTypeObjectPropDesc::ENone,
+ NULL);
break;
}
case EMTPServicePropertySyncObjectReferences:
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropdesc.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropdesc.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -158,7 +158,8 @@
ServiceNonConsumableL();
break;
default:
- Panic(EMTPDpUnsupportedProperty);
+ User::Leave( KErrNotSupported );
+ break;
}
__ASSERT_DEBUG(iObjectProperty, Panic(EMTPDpObjectPropertyNull));
iObjectProperty->SetUint32L(CMTPTypeObjectPropDesc::EGroupCode,GetPropertyGroupNumber(propCode));
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectproplist.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectproplist.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -449,7 +449,7 @@
}
break;
default:
- Panic(EMTPDpUnsupportedProperty);
+ User::Leave( KErrNotSupported );
break;
}
}
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropvalue.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetobjectpropvalue.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -166,7 +166,8 @@
ServiceNonConsumableL();
break;
default:
- Panic(EMTPDpUnsupportedProperty);
+ User::Leave( KErrNotSupported );
+ break;
}
}
@@ -201,7 +202,7 @@
void CMTPGetObjectPropValue::ServiceObjectSizeL()
{
- iMTPTypeUint64.Set(iFileEntry.iSize);
+ iMTPTypeUint64.Set(iFileEntry.FileSize());
SendDataL(iMTPTypeUint64);
}
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetpartialobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpgetpartialobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -111,7 +111,7 @@
TEntry fileEntry;
User::LeaveIfError(iFramework.Fs().Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry));
- if((iOffset >= fileEntry.iSize))
+ if((iOffset >= fileEntry.FileSize()))
{
result = EMTPRespCodeInvalidParameter;
}
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsendobjectinfo.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -365,7 +365,7 @@
}
else
{
- Panic(EMTPDpSendObjectStateInvalid);
+ User::Leave( KErrGeneral );
}
__FLOG(_L8("CheckSendingState - Exit"));
return result;
--- a/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectpropvalue.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/cmtpsetobjectpropvalue.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -208,7 +208,8 @@
//No break sentance, goto Panic
}
default:
- Panic(EMTPDpUnsupportedProperty);
+ User::Leave( KErrNotSupported );
+ break;
}
}
@@ -310,7 +311,8 @@
default:
- Panic(EMTPDpUnsupportedProperty);
+ User::Leave( KErrNotSupported );
+ break;
}
SendResponseL(responseCode);
--- a/mtpfws/mtpfw/dataproviders/dputility/src/rmtputility.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/dputility/src/rmtputility.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -434,94 +434,122 @@
return 1;
}
-
void RMTPUtility::RenameAllChildrenL(TUint32 aStorageId, TUint32 aParentHandle, const TDesC& aNewFolderName, const TDesC& aOldFolderName)
{
__FLOG(_L8("RenameAllChildrenL - Entry"));
-
- RMTPObjectMgrQueryContext context;
- RArray<TUint> handles;
- TMTPObjectMgrQueryParams params(aStorageId, KMTPFormatsAll, aParentHandle);
- CleanupClosePushL(context);
- CleanupClosePushL(handles);
-
- CMTPObjectMetaData* objectInfo(CMTPObjectMetaData::NewLC());
- TInt count = 0;
- TEntry entry;
-
- do
- {
- iFramework->ObjectMgr().GetObjectHandlesL(params, context, handles);
- count = handles.Count();
-
- for(TInt i(0); (i < count); i++)
- {
- if (!iFramework->ObjectMgr().ObjectL(handles[i], *objectInfo))
- {
- User::Leave(KErrCorrupt);
- }
-
- /**
- * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002,
- * but it does not really own the format 0x3002.
- *
- * Make the same behavior betwen 0x3000 and 0x3002.
- */
- if( (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeAssociation)
- && (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeUndefined)
- && (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeScript) )
- continue;
+
+ CMTPObjectMetaData* objectInfo(CMTPObjectMetaData::NewLC());
+ TInt count = 0;
+ RArray<TUint> handles;
+ CleanupClosePushL(handles);
+ GetAllDecendents(aStorageId, aParentHandle, handles);
+ count = handles.Count();
+
+ TEntry entry;
+ for(TInt i(0); (i < count); ++i)
+ {
+ if (!iFramework->ObjectMgr().ObjectL(handles[i], *objectInfo))
+ {
+ User::Leave(KErrCorrupt);
+ }
+
+ /**
+ * [SP-Format-0x3002]Special processing for PictBridge DP which own 6 dps file with format 0x3002,
+ * but it does not really own the format 0x3002.
+ *
+ * Make the same behavior betwen 0x3000 and 0x3002.
+ */
+ if( (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeAssociation)
+ && (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeUndefined)
+ && (objectInfo->Uint(CMTPObjectMetaData::EFormatCode) != EMTPFormatCodeScript) )
+ continue;
- RBuf entryName;
- entryName.CreateL(KMaxFileName);
- entryName.CleanupClosePushL();
- entryName = objectInfo->DesC(CMTPObjectMetaData::ESuid);
-
- RBuf rightPartName;
- rightPartName.CreateL(KMaxFileName);
- rightPartName.CleanupClosePushL();
- rightPartName = entryName.Right(entryName.Length() - aOldFolderName.Length());
-
- if ((aNewFolderName.Length() + rightPartName.Length()) > entryName.MaxLength())
- {
- entryName.ReAllocL(aNewFolderName.Length() + rightPartName.Length());
- }
-
- entryName.Zero();
- entryName.Append(aNewFolderName);
- entryName.Append(rightPartName);
-
- if (KErrNone != iFramework->Fs().Entry(entryName, entry))
- {
- // Skip objects that don't use the file path as SUID.
- CleanupStack::PopAndDestroy(&entryName);
- continue;
- }
-
- // Recursively update all this object's children.
- // The maximum recursion depth is as deep as the association hierarchy.
- RenameAllChildrenL(objectInfo->Uint(CMTPObjectMetaData::EStorageId), objectInfo->Uint(CMTPObjectMetaData::EHandle), entryName, objectInfo->DesC(CMTPObjectMetaData::ESuid) );
-
- TFileName oldfilename(objectInfo->DesC(CMTPObjectMetaData::ESuid));
- objectInfo->SetDesCL(CMTPObjectMetaData::ESuid, entryName);
- iFramework->ObjectMgr().ModifyObjectL(*objectInfo);
-
- if(objectInfo->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation)
- {
- //Send the Rename notification
- TMTPNotificationParamsHandle param = { handles[i], oldfilename};
- iSingleton.DpController().NotifyDataProvidersL(EMTPRenameObject, static_cast<TAny*>(¶m));
- }
- CleanupStack::PopAndDestroy(2); // rightPartName, entryName
- }
- }
- while (!context.QueryComplete());
-
- CleanupStack::PopAndDestroy(3);//objectInfo; &handles; &context
+ RBuf entryName;
+ entryName.CreateL(KMaxFileName);
+ entryName.CleanupClosePushL();
+ entryName = objectInfo->DesC(CMTPObjectMetaData::ESuid);
+
+ RBuf rightPartName;
+ rightPartName.CreateL(KMaxFileName);
+ rightPartName.CleanupClosePushL();
+ rightPartName = entryName.Right(entryName.Length() - aOldFolderName.Length());
+
+ if ((aNewFolderName.Length() + rightPartName.Length()) > entryName.MaxLength())
+ {
+ entryName.ReAllocL(aNewFolderName.Length() + rightPartName.Length());
+ }
+
+ entryName.Zero();
+ entryName.Append(aNewFolderName);
+ entryName.Append(rightPartName);
+
+ if (KErrNone != iFramework->Fs().Entry(entryName, entry))
+ {
+ // Skip objects that don't use the file path as SUID.
+ CleanupStack::PopAndDestroy(&entryName);
+ continue;
+ }
+
+ TFileName oldfilename(objectInfo->DesC(CMTPObjectMetaData::ESuid));
+ objectInfo->SetDesCL(CMTPObjectMetaData::ESuid, entryName);
+ iFramework->ObjectMgr().ModifyObjectL(*objectInfo);
+
+ if(objectInfo->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation)
+ {
+ //Send the Rename notification
+ TMTPNotificationParamsHandle param = { handles[i], oldfilename};
+ iSingleton.DpController().NotifyDataProvidersL(EMTPRenameObject, static_cast<TAny*>(¶m));
+ }
+
+ CleanupStack::PopAndDestroy(2); // rightPartName, entryName
+ }
+
+ CleanupStack::PopAndDestroy(2); //objectInfo; &handles;
__FLOG(_L8("RenameAllChildrenL - Exit"));
}
+void RMTPUtility::GetAllDecendents(TUint32 aStorageId, TUint aParentHandle, RArray<TUint>& aHandles) const
+ {
+ TInt index = 0;
+ TBool firstLevel = ETrue;
+
+ do
+ {
+ TUint parentHandle;
+ if (firstLevel)
+ {
+ parentHandle = aParentHandle; //Get the first level children handles
+ firstLevel = EFalse;
+ }
+ else
+ {
+ parentHandle = aHandles[index];
+ ++index;
+ }
+
+ RMTPObjectMgrQueryContext context;
+ RArray<TUint> childrenHandles;
+ TMTPObjectMgrQueryParams params(aStorageId, KMTPFormatsAll, parentHandle);
+ CleanupClosePushL(context);
+ CleanupClosePushL(childrenHandles);
+
+ do
+ {
+ iFramework->ObjectMgr().GetObjectHandlesL(params, context, childrenHandles);
+ TInt count = childrenHandles.Count();
+ for (TUint i = 0; i < count; ++i)
+ {
+ aHandles.Append(childrenHandles[i]);
+ }
+ }
+ while (!context.QueryComplete());
+ CleanupStack::PopAndDestroy(2); //&childrenHandles; &context
+ }
+ while(index < aHandles.Count());
+
+ }
+
HBufC* RMTPUtility::OdfMimeTypeL( const TDesC& aFullPath )
{
HBufC* mimebuf = NULL;
--- a/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpmoveobject.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/proxydp/inc/cmtpmoveobject.h Fri Mar 12 15:46:41 2010 +0200
@@ -95,7 +95,6 @@
RBuf iNewParent;
TUint32 iStorageId;
CDesCArray* iPathToCreate;
- static const TMTPRequestElementInfo KMTPMoveObjectPolicy[];
CMTPObjectBrowser* iObjBrowser;
RArray< TUint32 > iHandles;
--- a/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpcopyobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpcopyobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -27,6 +27,17 @@
const TUint KInvalidDpId = 0xFF;
/**
+Verification data for the CopyObject request
+*/
+const TMTPRequestElementInfo KMTPCopyObjectPolicy[] =
+ {
+ {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFileOrDir, 0, 0, 0},
+ {TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, EMTPElementAttrWrite, 0, 0, 0},
+ {TMTPTypeRequest::ERequestParameter3, EMTPElementTypeObjectHandle, EMTPElementAttrDir | EMTPElementAttrWrite, 1, 0, 0}
+ };
+
+
+/**
Two-phase construction method
@param aFramework The data provider framework
@param aConnection The connection from which the request comes
@@ -61,7 +72,7 @@
Constructor
*/
CMTPCopyObject::CMTPCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
- CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+ CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPCopyObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPCopyObjectPolicy)
{
__FLOG_OPEN( KMTPSubsystem, KComponent );
__FLOG( _L8("+/-Ctor") );
--- a/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpdeleteobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -35,6 +35,14 @@
const TUint KInvalidDpId = 0xFF;
/**
+Verification data for the DeleteObject request
+*/
+const TMTPRequestElementInfo KMTPDeleteObjectPolicy[] =
+ {
+ { TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, (EMTPElementAttrDir | EMTPElementAttrWrite), 1, KMTPHandleAll, 0 }
+ };
+
+/**
Two-phase construction method
@param aFramework The data provider framework
@param aConnection The connection from which the request comes
@@ -67,7 +75,7 @@
Constructor
*/
CMTPDeleteObject::CMTPDeleteObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
- CMTPRequestProcessor(aFramework, aConnection, 0, NULL),
+ CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPDeleteObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPDeleteObjectPolicy),
iDeletedObjectsNumber(0)
{
__FLOG_OPEN( KMTPSubsystem, KComponent );
--- a/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetobjectproplist.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpgetobjectproplist.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -33,6 +33,15 @@
__FLOG_STMT( _LIT8( KComponent,"PrxyGetObjPrpLst" ); )
const TUint KInvalidDpId = 0xFF;
+
+/**
+Verification data for the GetObjectPropList request
+*/
+const TMTPRequestElementInfo KMTPGetObjectPropListPolicy[] =
+ {
+ { TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrNone, 2, KMTPHandleAll, KMTPHandleNone}
+ };
+
/**
Factory method.
@param aFramework The data provider framework
@@ -126,7 +135,7 @@
__ASSERT_DEBUG((( (iRequest == &aRequest) || ( &iCurrentRequest == &aRequest ) ) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy));
TUint16 response = iResponse.Uint16(TMTPTypeResponse::EResponseCode);
- if(( EMTPRespCodeGroupNotSupported == response) || (EMTPRespCodeSpecificationByGroupUnsupported == response))
+ if(( EMTPRespCodeGroupNotSupported == response) || (EMTPRespCodeSpecificationByGroupUnsupported == response) || ( EMTPRespCodeObjectPropNotSupported == response))
{
response = EMTPRespCodeOK;
iResponse.SetUint16(TMTPTypeResponse::EResponseCode, response);
@@ -178,7 +187,7 @@
Constructor.
*/
CMTPGetObjectPropList::CMTPGetObjectPropList(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
- CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
+ CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPropListPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPropListPolicy)
{
__FLOG_OPEN( KMTPSubsystem, KComponent );
__FLOG( _L8("+/-Ctor") );
--- a/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpmoveobject.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpmoveobject.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -32,7 +32,7 @@
/**
Verification data for the MoveObject request
*/
-const TMTPRequestElementInfo CMTPMoveObject::KMTPMoveObjectPolicy[] =
+const TMTPRequestElementInfo KMTPMoveObjectPolicy[] =
{
{TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFileOrDir | EMTPElementAttrWrite, 0, 0, 0},
{TMTPTypeRequest::ERequestParameter2, EMTPElementTypeStorageId, EMTPElementAttrWrite, 0, 0, 0},
--- a/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpobjectbrowser.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/proxydp/src/cmtpobjectbrowser.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -55,15 +55,7 @@
switch ( aHandle )
{
case KMTPHandleAll:
- //for the format code of serveice dp's, need to check the format
- if( (aFormatCode >= EMTPFormatCodeVendorExtStart)&&(aFormatCode <= EMTPFormatCodeVendorExtEnd) )
- {
- GetAllObjectHandlesL( aFormatCode,aBrowseCallback );
- }
- else
- {
- GetAllObjectHandlesL( KMTPFormatsAll,aBrowseCallback );
- }
+ GetObjectHandlesL( 0, KMTPStorageAll, aFormatCode, KMaxTUint, KMTPHandleNoParent, aBrowseCallback );
break;
case KMTPHandleNone:
@@ -168,15 +160,8 @@
if( aDepth > 0)
{
- if (KMaxTUint == aDepth)
- {
- GetAllObjectHandlesL( aFormatCode,aBrowseCallback );
- }
- else
- {
// attention: aDepth should be reduced by 1 here
GetObjectHandlesL( aCurDepth, KMTPStorageAll, aFormatCode, aDepth-1, KMTPHandleNoParent, aBrowseCallback );
- }
}
// if aDepth == 0, no handles should be returned.
--- a/mtpfws/mtpfw/group/mtpframework.mmp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/group/mtpframework.mmp Fri Mar 12 15:46:41 2010 +0200
@@ -91,6 +91,8 @@
LIBRARY efsrv.lib
LIBRARY estor.lib
LIBRARY euser.lib
+LIBRARY bluetooth.lib
+LIBRARY usbman.lib
LIBRARY mtpdatatypes.lib
LIBRARY mtpdataproviderapi.lib
--- a/mtpfws/mtpfw/inc/cmtpconnectionmgr.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/inc/cmtpconnectionmgr.h Fri Mar 12 15:46:41 2010 +0200
@@ -23,8 +23,10 @@
#define CMTPCONNECTIONMGR_H
#include <e32base.h>
+#include <bttypes.h>
#include "mmtpconnectionmgr.h"
#include "mtpdebug.h"
+#include "mtp/rmtpclient.h"
class CMTPConnection;
class CMTPTransportPlugin;
@@ -64,7 +66,8 @@
IMPORT_C void StopTransports();
IMPORT_C TInt TransportCount() const;
IMPORT_C TUid TransportUid();
-
+ IMPORT_C void SetBTResumeParameter(const TBTDevAddr& aBTAddr, const TUint16& aPSMPort);
+
private: // From MMTPConnectionMgr
TBool ConnectionClosed(MMTPTransportConnection& aTransportConnection);
@@ -91,7 +94,6 @@
TUid iTransportUid;
TUint iTransportCount;
TUid iSecureId;
- TBool iIsTransportStopping;
/**
* Array storing the UIDs of the suspended transport plugins
@@ -104,6 +106,11 @@
CAsyncCallBack* iTransportTrigger;
/**
+ * It will store the bluetooth address of remote device.
+ */
+ TMTPBTRemoteDevice iRemoteDevice;
+
+ /**
FLOGGER debug trace member variable.
*/
__FLOG_DECLARATION_MEMBER_MUTABLE;
--- a/mtpfws/mtpfw/inc/cmtpdataprovider.h Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/inc/cmtpdataprovider.h Fri Mar 12 15:46:41 2010 +0200
@@ -124,6 +124,7 @@
MMTPStorageMgr& StorageMgr() const;
RFs& Fs() const;
MMTPDataCodeGenerator& DataCodeGenerator() const;
+ void NotifyFrameworkL( TMTPNotificationToFramework aNotification, const TAny* aParams );
private: // From CActive
--- a/mtpfws/mtpfw/src/cmtpconnection.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/src/cmtpconnection.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -93,10 +93,6 @@
delete link;
}
- if (iTransportConnection != NULL)
- {
- iTransportConnection->Unbind(*this);
- }
iSessions.ResetAndDestroy();
//close the property
iProperty.Close();
@@ -374,6 +370,10 @@
CloseAllSessions();
iSessions.Reset();
+ if (iTransportConnection != NULL)
+ {
+ iTransportConnection->Unbind(*this);
+ }
//notify ConnectionMgr and corresponding transports of completion of connection close
iSingletons.ConnectionMgr().ConnectionCloseComplete(iConnectionId);
@@ -430,15 +430,15 @@
{
session.SetTransactionPhase(EIdlePhase);
+ if (iTransportConnection != NULL)
+ {
+ iTransportConnection->TransactionCompleteL(aRequest);
+ }
+
if (State() == EStateShutdown && ActiveSessions() == 0)
{
CompleteCloseConnection();
}
-
- if (iTransportConnection != NULL)
- {
- iTransportConnection->TransactionCompleteL(aRequest);
- }
}
__FLOG(_L8("TransactionCompleteL - Exit"));
}
--- a/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/src/cmtpconnectionmgr.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -13,6 +13,8 @@
// Description:
//
+#include <usbman.h>
+#include <usbstates.h>
#include "cmtpconnectionmgr.h"
#include "cmtpconnection.h"
@@ -95,16 +97,57 @@
void CMTPConnectionMgr::ConnectionCloseComplete(const TUint& /*aConnUid*/)
{
- if (iIsTransportStopping)
- {
- iIsTransportStopping = EFalse;
- ResumeSuspendedTransport();
- }
+ __FLOG(_L8("ConnectionCloseComplete - Entry"));
+ ResumeSuspendedTransport();
+ __FLOG(_L8("ConnectionCloseComplete - exit"));
}
EXPORT_C void CMTPConnectionMgr::StartTransportL(TUid aTransport)
{
- StartTransportL( aTransport, NULL );
+
+ TInt32 bluetoothUid = 0x10286FCB;
+
+ RUsb usb;
+ User::LeaveIfError(usb.Connect());
+ TInt usbMode;
+ TUsbServiceState usbStat;
+ TInt err = usb.GetCurrentPersonalityId(usbMode);
+ __FLOG_1(_L8("The return value of GetCurrentPersonalityId is %d"), err);
+
+ err = usb.GetServiceState(usbStat);
+ __FLOG_1(_L8("The return value of GetServiceState is %d"), err);
+
+ usb.Close();
+
+ __FLOG_1(_L8("The current usb mode is %d"), usbMode);
+ __FLOG_1(_L8("The current usb service state is %d"), usbStat);
+
+ TInt massStorageMode = 0x02;
+
+ if(usbMode == massStorageMode && usbStat != EUsbServiceIdle)
+ {
+ __FLOG(_L8("StartTransportL without parameter!"));
+ StartTransportL( aTransport, NULL );
+ return;
+ }
+
+
+
+ //When USB plug out, BT will start Master mode to reconnect remote device. Else BT will start slave mode to listen connection.
+ if(aTransport.iUid == bluetoothUid && iRemoteDevice.iDeviceAddr != 0 && aTransport != iTransportUid)
+ {
+ __FLOG(_L8("StartTransportL with parameter!"));
+ TMTPBTRemoteDeviceBuf tmpdata(iRemoteDevice);
+ StartTransportL( aTransport, &tmpdata );
+ iRemoteDevice.iDeviceAddr = 0;
+ iRemoteDevice.iDeviceServicePort = 0;
+ }
+ else
+ {
+ __FLOG(_L8("StartTransportL without parameter!"));
+ StartTransportL( aTransport, NULL );
+ }
+
}
/**
@@ -119,33 +162,70 @@
*/
EXPORT_C void CMTPConnectionMgr::StartTransportL(TUid aTransport, const TAny* aParameter)
{
- __FLOG(_L8("StartTransportL - Entry"));
-
+ __FLOG(_L8("StartTransportL - Entry"));
+
+ TInt32 bluetoothUid = 0x10286FCB;
+
if (iTransport)
{
+ __FLOG(_L8("The transport is not none."));
if (aTransport != iTransportUid)
{
// Multiple transports not currently supported.
+ __FLOG(_L8("Multiple transports are not supported now!"));
User::Leave(KErrNotSupported);
}
+ else
+ {
+ __FLOG_1(_L8("Relaunch the transport 0x%X"), iTransportUid.iUid);
+ if(aTransport.iUid == bluetoothUid)
+ {
+ iTransport->Stop(*this);
+ delete iTransport;
+
+ iTransport = CMTPTransportPlugin::NewL(aTransport, aParameter);
+
+ TRAPD(err, iTransport->StartL(*this));
+ if (err != KErrNone)
+ {
+ __FLOG_VA( ( _L8("StartTransportL error, error code = %d"), err) );
+ delete iTransport;
+ iTransport = NULL;
+ User::Leave(err);
+ }
+ iTransportUid = aTransport;
+
+ iTransportCount++;
+ }
+
+ }
}
else
{
-
+ __FLOG(_L8("begin start transport."));
iTransport = CMTPTransportPlugin::NewL(aTransport, aParameter);
TRAPD(err, iTransport->StartL(*this));
- if (err != KErrNone)
- {
- __FLOG_VA( ( _L8("StartTransportL error, error code = %d"), err) );
- delete iTransport;
- iTransport = NULL;
- User::Leave(err);
- }
+ if (err != KErrNone)
+ {
+ __FLOG_VA( ( _L8("StartTransportL error, error code = %d"), err) );
+ delete iTransport;
+ iTransport = NULL;
+ User::Leave(err);
+ }
iTransportUid = aTransport;
-
+
iTransportCount++;
- UnsuspendTransport( iTransportUid );
+
+ if(iTransportUid.iUid != bluetoothUid)
+ {
+ UnsuspendTransport( iTransportUid );
+ }
+ else
+ {
+ //Suspend BT transport to handle switching with Mass Storage
+ SuspendTransportL( iTransportUid);
+ }
}
__FLOG(_L8("StartTransportL - Exit"));
@@ -190,13 +270,21 @@
{
__FLOG(_L8("StopTransport - Entry"));
+
+ __FLOG_1(_L8("aTransport is 0x%X"), aTransport.iUid);
+ __FLOG_1(_L8("iTransportUid is 0x%X"), aTransport.iUid);
+
+ if ( aByBearer )
+ {
+ UnsuspendTransport( aTransport );
+ }
+
if ( ( iTransport ) && ( aTransport == iTransportUid ) )
{
if ( !aByBearer )
{
TRAP_IGNORE( SuspendTransportL( aTransport ) );
}
- iIsTransportStopping = ETrue;
iTransport->Stop(*this);
delete iTransport;
iTransport = NULL;
@@ -204,11 +292,6 @@
iTransportCount--;
}
- if ( aByBearer )
- {
- UnsuspendTransport( aTransport );
- }
-
__FLOG(_L8("StopTransport - Exit"));
}
@@ -233,7 +316,25 @@
*/
EXPORT_C TInt CMTPConnectionMgr::TransportCount() const
{
- return iTransportCount;
+ return iTransportCount;
+ }
+
+/*
+Record the remote device bluetooth address when connection setup.
+*/
+EXPORT_C void CMTPConnectionMgr::SetBTResumeParameter(const TBTDevAddr& aBTAddr, const TUint16& aPSMPort)
+ {
+ TInt64 addr(0);
+ TUint8 i(0);
+ addr += aBTAddr[i++];
+ for(; i<KBTDevAddrSize; ++i)
+ {
+ addr <<= 8;
+ addr += aBTAddr[i];
+ }
+
+ iRemoteDevice.iDeviceAddr = addr;
+ iRemoteDevice.iDeviceServicePort = aPSMPort;
}
TBool CMTPConnectionMgr::ConnectionClosed(MMTPTransportConnection& aTransportConnection)
@@ -284,10 +385,11 @@
CMTPConnectionMgr::CMTPConnectionMgr() :
iConnectionOrder(ConnectionOrderCompare),
iShutdownConnectionIdx(KErrNotFound),
- iTransportUid(KNullUid),
- iIsTransportStopping(EFalse)
+ iTransportUid(KNullUid)
{
- __FLOG_OPEN(KMTPSubsystem, KComponent);
+ __FLOG_OPEN(KMTPSubsystem, KComponent);
+ iRemoteDevice.iDeviceAddr = 0;
+ iRemoteDevice.iDeviceServicePort = 0;
}
/**
@@ -366,9 +468,14 @@
{
__FLOG( _L8("+ResumeSuspendedTransport") );
const TInt count = iSuspendedTransports.Count();
+ __FLOG_1(_L8("The count number is %d"), count);
+ __FLOG_1(_L8("The transportport id is 0x%X"), iTransportUid.iUid);
+
+ TInt32 bluetoothUid = 0x10286FCB;
+
if ( ( count > 0 )
// If the transport was just switched and suspended, it shouldn't be resumed.
- && ( iTransportUid != iSuspendedTransports[count-1] ) )
+ && (( iTransportUid != iSuspendedTransports[count-1] ) || iTransportUid.iUid == bluetoothUid))
{
__FLOG( _L8("Found suspended transport(s).") );
if ( !iTransportTrigger )
--- a/mtpfws/mtpfw/src/cmtpdataprovider.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/src/cmtpdataprovider.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -481,6 +481,28 @@
return iSingletons.DataCodeGenerator();
}
+void CMTPDataProvider::NotifyFrameworkL( TMTPNotificationToFramework aNotification, const TAny* aParams )
+ {
+ __FLOG(_L8("NotifyFrameworkL - Entry"));
+
+ __ASSERT_DEBUG( aParams, User::Invariant());
+
+ switch ( aNotification )
+ {
+ case EMTPAddFolder:
+ {
+ TUint deviceDpId = iSingletons.DpController().DeviceDpId();
+ iSingletons.DpController().NotifyDataProvidersL( deviceDpId, EMTPObjectAdded, aParams );
+ }
+ break;
+ default:
+ __FLOG(_L8("Ignore other notification"));
+ break;
+ }
+
+ __FLOG(_L8("NotifyFrameworkL - Exit"));
+ }
+
void CMTPDataProvider::DoCancel()
{
__FLOG_VA((_L8("DoCancel - Entry, data provider %d "), iId));
@@ -529,6 +551,18 @@
{
iImplementation->Cancel();
}
+ else if (status == KErrAbort)
+ {
+ if (iCurrentRequest != NULL)
+ {
+ TMTPTypeEvent event;
+ event.SetUint16(TMTPTypeEvent::EEventCode, EMTPEventCodeCancelTransaction);
+ event.SetUint32(TMTPTypeEvent::EEventSessionID, iCurrentRequest->Uint32(TMTPTypeRequest::ERequestSessionID) );
+ event.SetUint32(TMTPTypeEvent::EEventTransactionID, iCurrentRequest->Uint32(TMTPTypeRequest::ERequestTransactionID) );
+
+ iImplementation->ProcessEventL(event ,*iCurrentConnection);
+ }
+ }
if (iErrorRecovery != KErrNone)
@@ -603,12 +637,15 @@
iTimer.After(iStatus, TTimeIntervalMicroSeconds32(KWaitForEnumeration));
SetActive();
iTimerActive = ETrue;
- break;
- case ECompletingPhase:
- TransactionCompleteL(*iCurrentRequest, *iCurrentConnection);
- break;
- default:
- break;
+ break;
+ case EResponsePhase:
+ iImplementation->ProcessRequestPhaseL(iCurrentTransactionPhase, *iCurrentRequest, *iCurrentConnection);
+ break;
+ case ECompletingPhase:
+ TransactionCompleteL(*iCurrentRequest, *iCurrentConnection);
+ break;
+ default:
+ break;
}
}
}
--- a/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/src/cmtpdataprovidercontroller.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -385,7 +385,7 @@
*/
EXPORT_C void CMTPDataProviderController::WaitForEnumerationComplete()
{
- if(EnumerateState() < CMTPDataProviderController::EEnumeratingPhaseOneDone)
+ if((EnumerateState() < CMTPDataProviderController::EEnumeratingPhaseOneDone) && ( !iOpenSessionWaiter->IsStarted()))
{
iOpenSessionWaiter->Start();
}
--- a/mtpfws/mtpfw/src/cmtpobjectstore.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/src/cmtpobjectstore.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -280,17 +280,23 @@
void CMTPObjectStore::CommitReservedObjectHandleL(CMTPObjectMetaData& aObject)
{
+ TFileName suid;
+ suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
+ TUint32 handle = HandleL(suid);
+ if (handle != KMTPHandleNone)
+ {
+ __FLOG(_L8("CommitReserverd leave for duplicate suid."));
+ User::Leave(KErrAlreadyExists);
+ }
+ TUint32 suidHash = DefaultHash::Des16(suid);
+
//After the PutL called the cursor's position is not well defined.
iCachedHandle = 0;
iCachedSuidHash = 0;
TInt64 id = iHandleAllocator->NextPOUIDL();
aObject.SetUint(CMTPObjectMetaData::EIdentifier, id);
- TFileName suid;
- suid.CopyLC(aObject.DesC(CMTPObjectMetaData::ESuid));
- TUint32 suidHash = DefaultHash::Des16(suid);
-
- TUint32 handle = aObject.Uint(CMTPObjectMetaData::EHandle);
+ handle = aObject.Uint(CMTPObjectMetaData::EHandle);
CleanupStack::PushL(TCleanupItem(CMTPObjectStore::DBUpdateFailRecover, &iBatched));
iBatched.InsertL();
iBatched.SetColL(EObjectStoreHandleId, handle);
@@ -558,6 +564,14 @@
if (LocateByHandleL(handle))
{
+ //To avoid this modification will not generate duplicate SUID
+ TUint32 handle2 = HandleL(suid);
+ if (handle2 != KMTPHandleNone && handle2 != handle)
+ {
+ __FLOG(_L8("ModifyObjectL leave for duplicate suid."));
+ User::Leave(KErrAlreadyExists);
+ }
+
//After the PutL called the cursor's position is not well defined.
iCachedHandle = 0;
iCachedSuidHash = 0;
--- a/mtpfws/mtpfw/src/cmtpparserrouter.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/mtpfws/mtpfw/src/cmtpparserrouter.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -39,7 +39,8 @@
/**
CMTPParserRouter panic codes.
*/
-_LIT(KMTPPanicCategory, "CMTPParserRouter");
+
+
enum TMTPPanicReasons
{
EMTPPanicRoutingConflict = 0
@@ -49,9 +50,10 @@
Produces a "CMTPParserRouter" category panic.
@param aReason The panic code.
*/
-LOCAL_C void Panic(TInt aReason)
+LOCAL_C void Panic(TInt __DEBUG_ONLY(aReason))
{
- User::Panic(KMTPPanicCategory, aReason);
+ __DEBUG_ONLY(_LIT(KMTPPanicCategory, "CMTPParserRouter"));
+ __DEBUG_ONLY(User::Panic(KMTPPanicCategory, aReason));
}
/**
@@ -1839,44 +1841,39 @@
const TUint KObjectFormatCode(params1.Param(TRoutingParameters::EParamFormatCode));
const TUint KObjectFormatSubCode(params1.Param(TRoutingParameters::EParamFormatSubCode));
const TUint KObjectPropCode(params1.Param(TRoutingParameters::EParamObjectPropCode));
- if ((KObjectHandle == KMTPHandleAll) ||
- (KObjectHandle == KMTPHandleAllRootLevel))
+ const TUint KDepth(params1.Request().Uint32(TMTPTypeRequest::ERequestParameter5));
+ if ( KDepth==0 )
{
- // All objects or all root level objects.
- if (KObjectFormatCode == KMTPFormatsAll)
+ if ((KObjectHandle == KMTPHandleAll) ||
+ (KObjectHandle == KMTPHandleAllRootLevel))
{
SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
}
- else
+ else if (KObjectHandle != KMTPHandleNone)
{
- SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
- }
+ if( (KObjectFormatCode == EMTPFormatCodeAssociation) && (KObjectFormatSubCode == EMTPAssociationTypeGenericFolder) )
+ {
+ if ( params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework )
+ {
+ SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams);
+ }
+ else
+ {
+ SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+ SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+ }
+ }
+ else
+ {
+ SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
+ }
+ }
}
- else if (KObjectHandle != KMTPHandleNone)
+ else
{
- if( (KObjectFormatCode == EMTPFormatCodeAssociation) && (KObjectFormatSubCode == EMTPAssociationTypeGenericFolder) )
- {
- if ( params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework )
- {
- SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams);
- }
- else
- {
- SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
- SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
- }
- }
- else
- {
- SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams);
- }
- }
+ SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams);
+ }
-
- if (KObjectPropCode != KMTPObjectPropCodeAll)
- {
- SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes);
- }
}
__FLOG(_L8("GetRoutingSubTypesGetObjectPropListRequestL, Exit"));
}
--- a/obex/obexprotocol/obexusbtransport/src/usbconn.cpp Fri Feb 19 23:40:44 2010 +0200
+++ b/obex/obexprotocol/obexusbtransport/src/usbconn.cpp Fri Mar 12 15:46:41 2010 +0200
@@ -1056,6 +1056,15 @@
maxSize = maxPacketSize;
}
dataifc2().iEndpointData[KTransmitEndpoint - 1].iSize = maxSize;
+
+ // Allocate dma if requested and the device support resource allocation scheme version 2
+ // for resource allocation scheme version1, refer to AllocateDma()
+ if (iRequestDmaOnInEndpoint &&
+ ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0))
+ {
+ dataifc2().iEndpointData[KTransmitEndpoint - 1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA;
+ }
+
foundIn = ETrue;
}
else if (!foundOut && (caps->iTypesAndDir & KBulkOutFlags) == KBulkOutFlags)
@@ -1068,6 +1077,15 @@
maxSize = maxPacketSize;
}
dataifc2().iEndpointData[KReceiveEndpoint - 1].iSize = maxSize;
+
+ //Allocate dma here if requested and the device support resource allocation scheme version 2
+ // for resource allocation scheme version1, refer to AllocateDma()
+ if (iRequestDmaOnOutEndpoint &&
+ ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0))
+ {
+ dataifc2().iEndpointData[KReceiveEndpoint - 1].iFeatureWord1 |= KUsbcEndpointInfoFeatureWord1_DMA;
+ }
+
foundOut = ETrue;
}
}
@@ -1155,6 +1173,14 @@
{
LOG_FUNC
+ TUsbDeviceCaps dCaps;
+ iUsb.DeviceCaps(dCaps);
+ if ((dCaps().iFeatureWord1 & KUsbDevCapsFeatureWord1_EndpointResourceAllocV2) != 0)
+ {
+ // for resource allocation version2, refer to CObexUsbHandler::RegInterfacesL()
+ return;
+ }
+
if (iRequestDmaOnInEndpoint)
{
TInt err = iUsb.AllocateEndpointResource(KTransmitEndpoint, EUsbcEndpointResourceDMA);