28 |
28 |
29 #include "mtpimagedpconst.h" |
29 #include "mtpimagedpconst.h" |
30 #include "mtpimagedputilits.h" |
30 #include "mtpimagedputilits.h" |
31 #include "cmtpimagedp.h" |
31 #include "cmtpimagedp.h" |
32 |
32 |
|
33 /* |
|
34 * The most significant bit represents whether the image object has been imported. |
|
35 * 0 means does not be imported |
|
36 * 1 means has been imported |
|
37 */ |
|
38 #define IMAGE_OBJECT_STATUS_BITMASK 0x8000 |
|
39 |
|
40 /** |
|
41 * The other left bits represent the thumbnail size of image object. |
|
42 * The type of EFormatSubCode column is UINT16, so these bits are enought for thumbnail size. |
|
43 * e.g. The image file of 57M bytes only has 2440 bytes of thumbnail. |
|
44 */ |
|
45 #define IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK 0x7fff |
|
46 |
33 TMTPResponseCode MTPImageDpUtilits::VerifyObjectHandleL(MMTPDataProviderFramework& aFramework, const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aMetaData) |
47 TMTPResponseCode MTPImageDpUtilits::VerifyObjectHandleL(MMTPDataProviderFramework& aFramework, const TMTPTypeUint32& aHandle, CMTPObjectMetaData& aMetaData) |
34 { |
48 { |
35 if (!aFramework.ObjectMgr().ObjectL(aHandle, aMetaData)) |
49 if (!aFramework.ObjectMgr().ObjectL(aHandle, aMetaData)) |
36 { |
50 { |
37 return EMTPRespCodeInvalidObjectHandle; |
51 return EMTPRespCodeInvalidObjectHandle; |
58 if(!parse.IsRoot()) |
72 if(!parse.IsRoot()) |
59 { |
73 { |
60 if (!aDataProvider.GetCacheParentHandle(parse.DriveAndPath(), parentHandle)) |
74 if (!aDataProvider.GetCacheParentHandle(parse.DriveAndPath(), parentHandle)) |
61 { |
75 { |
62 parentHandle = aFramework.ObjectMgr().HandleL(parse.DriveAndPath()); |
76 parentHandle = aFramework.ObjectMgr().HandleL(parse.DriveAndPath()); |
63 if (parentHandle == KMTPHandleNone) |
77 if (parentHandle != KMTPHandleNone) |
64 { |
78 { |
65 parentHandle = KMTPHandleNoParent; |
79 aDataProvider.SetCacheParentHandle(parse.DriveAndPath(), parentHandle); |
66 } |
|
67 else |
|
68 { |
|
69 aDataProvider.SetCacheParentHandle(parse.DriveAndPath(), parentHandle); |
|
70 } |
80 } |
71 } |
81 } |
72 } |
82 } |
73 |
83 |
74 return parentHandle; |
84 return parentHandle; |
75 } |
85 } |
76 |
86 |
77 void MTPImageDpUtilits::UpdateNewPicturesValue(CMTPImageDataProvider& aDataProvider, TInt aNewPics, TBool aSetRProperty) |
87 TBool MTPImageDpUtilits::IsNewPicture(const CMTPObjectMetaData& aMetadata) |
|
88 { |
|
89 /** |
|
90 * we use EFormatSubCode column to save sentinel whether this object has been imported by PC |
|
91 * |
|
92 */ |
|
93 return ((aMetadata.Uint(CMTPObjectMetaData::EFormatSubCode) & IMAGE_OBJECT_STATUS_BITMASK) == 0); |
|
94 } |
|
95 |
|
96 |
|
97 void MTPImageDpUtilits::UpdateObjectStatusToOldL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata) |
|
98 { |
|
99 TInt status = aMetadata.Uint(CMTPObjectMetaData::EFormatSubCode) | IMAGE_OBJECT_STATUS_BITMASK; |
|
100 aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, status); |
|
101 aFramework.ObjectMgr().ModifyObjectL(aMetadata); |
|
102 } |
|
103 |
|
104 TInt MTPImageDpUtilits::GetThumbnailSize(const CMTPObjectMetaData& aMetadata) |
78 { |
105 { |
79 TInt preNewPic = 0; |
106 /** |
80 aDataProvider.Repository().Get(ENewImagesCount, preNewPic); |
107 * query thumbnail size from EFormatSubCode column |
81 |
108 */ |
82 TInt newPics = aNewPics + preNewPic; |
109 return (aMetadata.Uint(CMTPObjectMetaData::EFormatSubCode) & IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK); |
83 aDataProvider.Repository().Set(ENewImagesCount, newPics); |
110 } |
84 |
111 |
85 TInt curValue = 0; |
112 void MTPImageDpUtilits::UpdateObjectThumbnailSizeL(MMTPDataProviderFramework& aFramework, CMTPObjectMetaData& aMetadata, TInt aThumbnailSize) |
86 RProperty::Get(TUid::Uid(KMTPServerUID), KMTPNewPicKey, curValue); |
113 { |
87 |
114 //check thumbnail size whether it is overflow |
88 if (aSetRProperty && curValue != newPics) |
115 if (aThumbnailSize <= IMAGE_OBJECT_THUMBNAIL_SIZE_BITMASK) |
89 { |
116 { |
90 RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPics); |
117 TBool newPic = MTPImageDpUtilits::IsNewPicture(aMetadata); |
|
118 if (newPic) |
|
119 { |
|
120 aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, aThumbnailSize); |
|
121 } |
|
122 else |
|
123 { |
|
124 aThumbnailSize |= IMAGE_OBJECT_STATUS_BITMASK; |
|
125 aMetadata.SetUint(CMTPObjectMetaData::EFormatSubCode, aThumbnailSize); |
|
126 } |
|
127 aFramework.ObjectMgr().ModifyObjectL(aMetadata); |
91 } |
128 } |
92 } |
129 } |