25 |
25 |
26 #include "cmtpstoragemgr.h" |
26 #include "cmtpstoragemgr.h" |
27 #include "cmtpdeleteobject.h" |
27 #include "cmtpdeleteobject.h" |
28 #include "mtpdpconst.h" |
28 #include "mtpdpconst.h" |
29 #include "mtpdppanic.h" |
29 #include "mtpdppanic.h" |
|
30 #include "OstTraceDefinitions.h" |
|
31 #ifdef OST_TRACE_COMPILER_IN_USE |
|
32 #include "cmtpdeleteobjectTraces.h" |
|
33 #endif |
|
34 |
30 |
35 |
31 |
36 |
32 // Class constants. |
37 // Class constants. |
33 __FLOG_STMT(_LIT8(KComponent,"DeleteObject");) |
|
34 |
38 |
35 /** |
39 /** |
36 Verification data for the DeleteObject request |
40 Verification data for the DeleteObject request |
37 */ |
41 */ |
38 const TMTPRequestElementInfo KMTPDeleteObjectPolicy[] = |
42 const TMTPRequestElementInfo KMTPDeleteObjectPolicy[] = |
66 return self; |
70 return self; |
67 } |
71 } |
68 |
72 |
69 void CMTPDeleteObject::ConstructL() |
73 void CMTPDeleteObject::ConstructL() |
70 { |
74 { |
71 __FLOG_OPEN(KMTPSubsystem, KComponent); |
75 OstTraceFunctionEntry0( CMTPDELETEOBJECT_CONSTRUCTL_ENTRY ); |
72 __FLOG(_L8("ConstructL - Entry")); |
|
73 iSingletons.OpenL(); |
76 iSingletons.OpenL(); |
74 __FLOG(_L8("ConstructL - Exit")); |
77 OstTraceFunctionExit0( CMTPDELETEOBJECT_CONSTRUCTL_EXIT ); |
75 } |
78 } |
76 |
79 |
77 /** |
80 /** |
78 Destructor |
81 Destructor |
79 */ |
82 */ |
80 EXPORT_C CMTPDeleteObject::~CMTPDeleteObject() |
83 EXPORT_C CMTPDeleteObject::~CMTPDeleteObject() |
81 { |
84 { |
82 __FLOG(_L8("~CMTPDeleteObject - Entry")); |
85 OstTraceFunctionEntry0( CMTPDELETEOBJECT_CMTPDELETEOBJECT_DES_ENTRY ); |
83 iSingletons.Close(); |
86 iSingletons.Close(); |
84 __FLOG(_L8("~CMTPDeleteObject - Exit")); |
87 OstTraceFunctionExit0( CMTPDELETEOBJECT_CMTPDELETEOBJECT_DES_EXIT ); |
85 __FLOG_CLOSE; |
|
86 } |
88 } |
87 |
89 |
88 /** |
90 /** |
89 Verify the request |
91 Verify the request |
90 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes |
92 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes |
91 */ |
93 */ |
92 |
94 |
93 |
95 |
94 TMTPResponseCode CMTPDeleteObject::CheckRequestL() |
96 TMTPResponseCode CMTPDeleteObject::CheckRequestL() |
95 { |
97 { |
96 __FLOG(_L8("CheckRequestL - Entry")); |
98 OstTraceFunctionEntry0( CMTPDELETEOBJECT_CHECKREQUESTL_ENTRY ); |
97 TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL(); |
99 TMTPResponseCode result = CMTPRequestProcessor::CheckRequestL(); |
98 const TUint32 KObjectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
100 const TUint32 KObjectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
99 if ((EMTPRespCodeOK == result) && (IsStoreReadOnlyL(KObjectHandle)) ) |
101 if ((EMTPRespCodeOK == result) && (IsStoreReadOnlyL(KObjectHandle)) ) |
100 { |
102 { |
101 result = EMTPRespCodeStoreReadOnly; |
103 result = EMTPRespCodeStoreReadOnly; |
102 } |
104 } |
103 |
105 |
104 __FLOG(_L8("CheckRequestL - Exit")); |
106 OstTraceFunctionExit0( CMTPDELETEOBJECT_CHECKREQUESTL_EXIT ); |
105 return result; |
107 return result; |
106 } |
108 } |
107 |
109 |
108 void CMTPDeleteObject::DeleteFolderOrFileL(CMTPObjectMetaData* aMeta) |
110 void CMTPDeleteObject::DeleteFolderOrFileL(CMTPObjectMetaData* aMeta) |
109 { |
111 { |
110 __ASSERT_DEBUG(aMeta, Panic(EMTPDpObjectNull)); |
112 __ASSERT_DEBUG(aMeta, Panic(EMTPDpObjectNull)); |
111 if (IsFolderObject(*aMeta)) |
113 if (IsFolderObject(*aMeta)) |
112 { |
114 { |
113 __FLOG( _L8("Delete the folder itself which is empty ") ); |
115 OstTrace0( TRACE_NORMAL, CMTPDELETEOBJECT_DELETEFOLDERORFILEL, "Delete the folder itself which is empty " ); |
114 DeleteFolderL(aMeta); |
116 DeleteFolderL(aMeta); |
115 } |
117 } |
116 else |
118 else |
117 { |
119 { |
118 __FLOG(_L8("Going to delete a file.")); |
120 OstTrace0( TRACE_NORMAL, DUP1_CMTPDELETEOBJECT_DELETEFOLDERORFILEL, "Going to delete a file." ); |
119 DeleteFileL(aMeta); |
121 DeleteFileL(aMeta); |
120 } |
122 } |
121 ProcessFinalPhaseL(); |
123 ProcessFinalPhaseL(); |
122 } |
124 } |
123 |
125 |
174 /** |
176 /** |
175 DeleteObject request handler |
177 DeleteObject request handler |
176 */ |
178 */ |
177 void CMTPDeleteObject::ServiceL() |
179 void CMTPDeleteObject::ServiceL() |
178 { |
180 { |
179 __FLOG(_L8("ServiceL - Entry")); |
181 OstTraceFunctionEntry0( CMTPDELETEOBJECT_SERVICEL_ENTRY ); |
180 const TUint32 KHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); |
182 const TUint32 KHandle(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); |
181 iObjectWritePotected = EFalse; |
183 iObjectWritePotected = EFalse; |
182 iSuccessDeletion = EFalse; |
184 iSuccessDeletion = EFalse; |
183 |
185 |
184 CMTPObjectMetaData* meta = NULL; |
186 CMTPObjectMetaData* meta = NULL; |
185 meta = iRequestChecker->GetObjectInfo(KHandle); |
187 meta = iRequestChecker->GetObjectInfo(KHandle); |
186 __ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull)); |
188 __ASSERT_DEBUG(meta, Panic(EMTPDpObjectNull)); |
187 __FLOG_VA((_L8("meta->Uint(CMTPObjectMetaData::EDataProviderId) is %d"), meta->Uint(CMTPObjectMetaData::EDataProviderId))); |
189 OstTrace1( TRACE_NORMAL, CMTPDELETEOBJECT_SERVICEL, |
188 __FLOG_VA((_L8("iFramework.DataProviderId() is %d"), iFramework.DataProviderId())); |
190 "meta->Uint(CMTPObjectMetaData::EDataProviderId) is %d", meta->Uint(CMTPObjectMetaData::EDataProviderId)); |
189 |
191 OstTrace1( TRACE_NORMAL, DUP1_CMTPDELETEOBJECT_SERVICEL, "iFramework.DataProviderId() is %d", iFramework.DataProviderId() ); |
|
192 |
190 if ( meta != NULL && meta->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId()) |
193 if ( meta != NULL && meta->Uint(CMTPObjectMetaData::EDataProviderId) == iFramework.DataProviderId()) |
191 { |
194 { |
192 DeleteFolderOrFileL(meta); |
195 DeleteFolderOrFileL(meta); |
193 } |
196 } |
194 else |
197 else |
195 { |
198 { |
196 SendResponseL(EMTPRespCodeInvalidObjectHandle); |
199 SendResponseL(EMTPRespCodeInvalidObjectHandle); |
197 } |
200 } |
198 |
201 |
199 __FLOG(_L8("ServiceL - Exit")); |
202 OstTraceFunctionExit0( CMTPDELETEOBJECT_SERVICEL_EXIT ); |
200 } |
203 } |
201 |
204 |
202 /** |
205 /** |
203 Signal to the initiator that the deletion operation has finished with or without error |
206 Signal to the initiator that the deletion operation has finished with or without error |
204 */ |
207 */ |
205 void CMTPDeleteObject::ProcessFinalPhaseL() |
208 void CMTPDeleteObject::ProcessFinalPhaseL() |
206 { |
209 { |
207 __FLOG(_L8("ProcessFinalPhaseL - Entry")); |
210 OstTraceFunctionEntry0( CMTPDELETEOBJECT_PROCESSFINALPHASEL_ENTRY ); |
208 TMTPResponseCode rsp = EMTPRespCodeOK; |
211 TMTPResponseCode rsp = EMTPRespCodeOK; |
209 if ( iObjectWritePotected ) |
212 if ( iObjectWritePotected ) |
210 { |
213 { |
211 rsp = EMTPRespCodeObjectWriteProtected; |
214 rsp = EMTPRespCodeObjectWriteProtected; |
212 } |
215 } |
213 else if ( !iSuccessDeletion ) |
216 else if ( !iSuccessDeletion ) |
214 { |
217 { |
215 rsp = EMTPRespCodeAccessDenied; |
218 rsp = EMTPRespCodeAccessDenied; |
216 } |
219 } |
217 SendResponseL(rsp); |
220 SendResponseL(rsp); |
218 __FLOG(_L8("ProcessFinalPhaseL - Exit")); |
221 OstTraceFunctionExit0( CMTPDELETEOBJECT_PROCESSFINALPHASEL_EXIT ); |
219 } |
222 } |
220 |
223 |
221 /** |
224 /** |
222 Indicates if the specified object is a generic folder association. |
225 Indicates if the specified object is a generic folder association. |
223 @param aObject The object meta-data. |
226 @param aObject The object meta-data. |
234 Check whether the store on which the object resides is read only. |
237 Check whether the store on which the object resides is read only. |
235 @return ETrue if the store is read only, EFalse if read-write |
238 @return ETrue if the store is read only, EFalse if read-write |
236 */ |
239 */ |
237 TBool CMTPDeleteObject::IsStoreReadOnlyL(TUint32 aObjectHandle) |
240 TBool CMTPDeleteObject::IsStoreReadOnlyL(TUint32 aObjectHandle) |
238 { |
241 { |
239 __FLOG(_L8("IsStoreReadOnlyL - Entry")); |
242 OstTraceFunctionEntry0( CMTPDELETEOBJECT_ISSTOREREADONLYL_ENTRY ); |
240 TBool result(EFalse); |
243 TBool result(EFalse); |
241 CMTPObjectMetaData *info(CMTPObjectMetaData::NewLC()); |
244 CMTPObjectMetaData *info(CMTPObjectMetaData::NewLC()); |
242 if (iFramework.ObjectMgr().ObjectL(aObjectHandle, *info)) |
245 if (iFramework.ObjectMgr().ObjectL(aObjectHandle, *info)) |
243 { |
246 { |
244 result = !iSingletons.StorageMgr().IsReadWriteStorage(info->Uint(CMTPObjectMetaData::EStorageId)); |
247 result = !iSingletons.StorageMgr().IsReadWriteStorage(info->Uint(CMTPObjectMetaData::EStorageId)); |
245 } |
248 } |
246 CleanupStack::PopAndDestroy(info); |
249 CleanupStack::PopAndDestroy(info); |
247 __FLOG(_L8("IsStoreReadOnlyL - Exit")); |
250 OstTraceFunctionExit0( CMTPDELETEOBJECT_ISSTOREREADONLYL_EXIT ); |
248 return result; |
251 return result; |
249 } |
252 } |
250 |
253 |
251 |
254 |
252 |
255 |