25 #include <mtp/cmtpobjectmetadata.h> |
25 #include <mtp/cmtpobjectmetadata.h> |
26 #include <mtp/tmtptypeuint32.h> |
26 #include <mtp/tmtptypeuint32.h> |
27 |
27 |
28 #include "cmtpimagedprenameobject.h" |
28 #include "cmtpimagedprenameobject.h" |
29 #include "cmtpimagedp.h" |
29 #include "cmtpimagedp.h" |
30 |
30 #include "OstTraceDefinitions.h" |
31 __FLOG_STMT(_LIT8(KComponent,"CMTPImageDpRenameObject");) |
31 #ifdef OST_TRACE_COMPILER_IN_USE |
|
32 #include "cmtpimagedprenameobjectTraces.h" |
|
33 #endif |
|
34 |
32 |
35 |
33 const TInt KMmMtpRArrayGranularity = 4; |
36 const TInt KMmMtpRArrayGranularity = 4; |
34 const TInt KUpdateThreshold = 30; |
37 const TInt KUpdateThreshold = 30; |
35 const TInt KMaxFileNameLength = 260; |
38 const TInt KMaxFileNameLength = 260; |
36 |
39 |
51 CMTPImageDpRenameObject::CMTPImageDpRenameObject(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider) : |
54 CMTPImageDpRenameObject::CMTPImageDpRenameObject(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider) : |
52 CActive(EPriorityStandard), |
55 CActive(EPriorityStandard), |
53 iFramework(aFramework), |
56 iFramework(aFramework), |
54 iDataProvider(aDataProvider), |
57 iDataProvider(aDataProvider), |
55 iObjectHandles(KMmMtpRArrayGranularity) |
58 iObjectHandles(KMmMtpRArrayGranularity) |
56 { |
59 { |
57 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
58 __FLOG(_L8("CMTPImageDpRenameObject::CMTPImageDpRenameObject")); |
|
59 } |
60 } |
60 |
61 |
61 // ----------------------------------------------------------------------------- |
62 // ----------------------------------------------------------------------------- |
62 // CMTPImageDpRenameObject::~CMTPImageDpRenameObject |
63 // CMTPImageDpRenameObject::~CMTPImageDpRenameObject |
63 // destructor |
64 // destructor |
64 // ----------------------------------------------------------------------------- |
65 // ----------------------------------------------------------------------------- |
65 // |
66 // |
66 CMTPImageDpRenameObject::~CMTPImageDpRenameObject() |
67 CMTPImageDpRenameObject::~CMTPImageDpRenameObject() |
67 { |
68 { |
68 __FLOG(_L8(">> ~CMTPImageDpRenameObject")); |
69 OstTraceFunctionEntry0( CMTPIMAGEDPRENAMEOBJECT_CMTPIMAGEDPRENAMEOBJECT_DES_ENTRY ); |
69 Cancel(); |
70 Cancel(); |
70 iObjectHandles.Close(); |
71 iObjectHandles.Close(); |
71 delete iObjectInfo; |
72 delete iObjectInfo; |
72 delete iParentObjectInfo; |
73 delete iParentObjectInfo; |
73 iNewFileName.Close(); |
74 iNewFileName.Close(); |
74 delete iRenameWaiter; |
75 delete iRenameWaiter; |
75 __FLOG(_L8("<< ~CMTPImageDpRenameObject")); |
76 OstTraceFunctionExit0( CMTPIMAGEDPRENAMEOBJECT_CMTPIMAGEDPRENAMEOBJECT_DES_EXIT ); |
76 __FLOG_CLOSE; |
|
77 } |
77 } |
78 |
78 |
79 // ----------------------------------------------------------------------------- |
79 // ----------------------------------------------------------------------------- |
80 // CMTPImageDpRenameObject::StartL |
80 // CMTPImageDpRenameObject::StartL |
81 // |
81 // |
82 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
83 // |
83 // |
84 void CMTPImageDpRenameObject::StartL(const TUint32 aParentHandle, const TDesC& /*aOldFolderName*/) |
84 void CMTPImageDpRenameObject::StartL(const TUint32 aParentHandle, const TDesC& /*aOldFolderName*/) |
85 { |
85 { |
86 __FLOG_VA((_L16(">> CMTPImageDpRenameObject::StartL aParentHandle(0x%x)"), aParentHandle)); |
86 OstTraceFunctionEntry0( CMTPIMAGEDPRENAMEOBJECT_STARTL_ENTRY ); |
|
87 OstTrace1( TRACE_NORMAL, CMTPIMAGEDPRENAMEOBJECT_STARTL, "aParentHandle(0x%x)", aParentHandle ); |
87 |
88 |
88 iObjectHandles.Reset(); |
89 iObjectHandles.Reset(); |
89 |
90 |
90 GenerateObjectHandleListL(aParentHandle); |
91 GenerateObjectHandleListL(aParentHandle); |
91 iCount = iObjectHandles.Count(); |
92 iCount = iObjectHandles.Count(); |
92 __FLOG_VA((_L8(">> CMTPImageDpRenameObject::StartL handle count = %u"), iCount)); |
93 OstTrace1( TRACE_NORMAL, DUP1_CMTPIMAGEDPRENAMEOBJECT_STARTL, "handle count = %u", iCount); |
|
94 |
93 if (iCount > 0) |
95 if (iCount > 0) |
94 { |
96 { |
95 iIndex = 0; |
97 iIndex = 0; |
96 |
98 |
97 TRequestStatus* status = &iStatus; |
99 TRequestStatus* status = &iStatus; |
120 // |
122 // |
121 // ----------------------------------------------------------------------------- |
123 // ----------------------------------------------------------------------------- |
122 // |
124 // |
123 void CMTPImageDpRenameObject::RunL() |
125 void CMTPImageDpRenameObject::RunL() |
124 { |
126 { |
125 __FLOG_VA((_L8(">> CMTPImageDpRenameObject::RunL iIndex = %d"), iIndex)); |
127 OstTraceFunctionEntry0( CMTPIMAGEDPRENAMEOBJECT_RUNL_ENTRY ); |
|
128 OstTrace1( TRACE_NORMAL, CMTPIMAGEDPRENAMEOBJECT_RUNL, "iIndex = %d", iIndex ); |
|
129 |
126 if (iIndex < iCount) |
130 if (iIndex < iCount) |
127 { |
131 { |
128 TInt threshold = KUpdateThreshold; |
132 TInt threshold = KUpdateThreshold; |
129 for (;iIndex < iCount && threshold > 0; ++iIndex, --threshold) |
133 for (;iIndex < iCount && threshold > 0; ++iIndex, --threshold) |
130 { |
134 { |
138 |
142 |
139 iNewFileName.Zero(); |
143 iNewFileName.Zero(); |
140 iNewFileName.Append(parentUri.DriveAndPath()); |
144 iNewFileName.Append(parentUri.DriveAndPath()); |
141 iNewFileName.Append(objectUri.NameAndExt()); |
145 iNewFileName.Append(objectUri.NameAndExt()); |
142 iNewFileName.Trim(); |
146 iNewFileName.Trim(); |
143 __FLOG_VA((_L16("New file name(%S)"), &iNewFileName)); |
147 OstTraceExt1( TRACE_NORMAL, DUP1_CMTPIMAGEDPRENAMEOBJECT_RUNL, "New file name(%S)", iNewFileName ); |
144 |
148 |
145 // update framework metadata DB |
149 // update framework metadata DB |
146 iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, iNewFileName); |
150 iObjectInfo->SetDesCL(CMTPObjectMetaData::ESuid, iNewFileName); |
147 iObjectInfo->SetUint(CMTPObjectMetaData::EObjectMetaDataUpdate, 1); |
151 iObjectInfo->SetUint(CMTPObjectMetaData::EObjectMetaDataUpdate, 1); |
148 iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo); |
152 iFramework.ObjectMgr().ModifyObjectL(*iObjectInfo); |
149 } |
153 } |
158 { |
162 { |
159 if(iRenameWaiter->IsStarted()) |
163 if(iRenameWaiter->IsStarted()) |
160 iRenameWaiter->AsyncStop(); |
164 iRenameWaiter->AsyncStop(); |
161 } |
165 } |
162 |
166 |
163 __FLOG(_L8("<< CMTPImageDpRenameObject::RunL")); |
167 OstTraceFunctionExit0( CMTPIMAGEDPRENAMEOBJECT_RUNL_EXIT ); |
164 } |
168 } |
165 |
169 |
166 // ----------------------------------------------------------------------------- |
170 // ----------------------------------------------------------------------------- |
167 // CMTPImageDpRenameObject::RunError |
171 // CMTPImageDpRenameObject::RunError |
168 // |
172 // |
169 // ----------------------------------------------------------------------------- |
173 // ----------------------------------------------------------------------------- |
170 // |
174 // |
171 TInt CMTPImageDpRenameObject::RunError( TInt aError ) |
175 TInt CMTPImageDpRenameObject::RunError( TInt aError ) |
172 { |
176 { |
173 if (aError != KErrNone) |
177 if (aError != KErrNone) |
174 __FLOG_VA((_L8(">> CMTPImageDpRenameObject::RunError with error %d"), aError)); |
178 OstTraceDef1(OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CMTPIMAGEDPRENAMEOBJECT_RUNERROR, |
175 |
179 "with error %d", aError ); |
|
180 |
176 return KErrNone; |
181 return KErrNone; |
177 } |
182 } |
178 |
183 |
179 // ----------------------------------------------------------------------------- |
184 // ----------------------------------------------------------------------------- |
180 // CMTPImageDpRenameObject::ConstructL |
185 // CMTPImageDpRenameObject::ConstructL |
181 // |
186 // |
182 // ----------------------------------------------------------------------------- |
187 // ----------------------------------------------------------------------------- |
183 // |
188 // |
184 void CMTPImageDpRenameObject::ConstructL() |
189 void CMTPImageDpRenameObject::ConstructL() |
185 { |
190 { |
186 __FLOG(_L8(">> CMTPImageDpRenameObject::ConstructL")); |
191 OstTraceFunctionEntry0( CMTPIMAGEDPRENAMEOBJECT_CONSTRUCTL_ENTRY ); |
187 CActiveScheduler::Add( this ); |
192 CActiveScheduler::Add( this ); |
188 |
193 |
189 iObjectInfo = CMTPObjectMetaData::NewL(); |
194 iObjectInfo = CMTPObjectMetaData::NewL(); |
190 iParentObjectInfo = CMTPObjectMetaData::NewL(); |
195 iParentObjectInfo = CMTPObjectMetaData::NewL(); |
191 iNewFileName.CreateL(KMaxFileNameLength); |
196 iNewFileName.CreateL(KMaxFileNameLength); |
192 iRenameWaiter = new( ELeave ) CActiveSchedulerWait; |
197 iRenameWaiter = new( ELeave ) CActiveSchedulerWait; |
193 __FLOG(_L8("<< CMTPImageDpRenameObject::ConstructL")); |
198 OstTraceFunctionExit0( CMTPIMAGEDPRENAMEOBJECT_CONSTRUCTL_EXIT ); |
194 } |
199 } |
195 |
200 |
196 // ----------------------------------------------------------------------------- |
201 // ----------------------------------------------------------------------------- |
197 // CMTPImageDpRenameObject::GenerateObjectHandleListL |
202 // CMTPImageDpRenameObject::GenerateObjectHandleListL |
198 // |
203 // |
199 // ----------------------------------------------------------------------------- |
204 // ----------------------------------------------------------------------------- |
200 // |
205 // |
201 void CMTPImageDpRenameObject::GenerateObjectHandleListL(TUint32 aParentHandle) |
206 void CMTPImageDpRenameObject::GenerateObjectHandleListL(TUint32 aParentHandle) |
202 { |
207 { |
203 __FLOG_VA((_L8(">> CMTPImageDpRenameObject::GenerateObjectHandleListL aParentHandle(0x%x)"), aParentHandle)); |
208 OstTraceFunctionEntry0( CMTPIMAGEDPRENAMEOBJECT_GENERATEOBJECTHANDLELISTL_ENTRY ); |
|
209 OstTrace1( TRACE_NORMAL, CMTPIMAGEDPRENAMEOBJECT_GENERATEOBJECTHANDLELISTL, "aParentHandle(0x%x)", aParentHandle ); |
|
210 |
204 RMTPObjectMgrQueryContext context; |
211 RMTPObjectMgrQueryContext context; |
205 RArray<TUint> handles; |
212 RArray<TUint> handles; |
206 CleanupClosePushL(context); // + context |
213 CleanupClosePushL(context); // + context |
207 CleanupClosePushL(handles); // + handles |
214 CleanupClosePushL(handles); // + handles |
208 |
215 |