20 #include "cmtpparserrouter.h" |
20 #include "cmtpparserrouter.h" |
21 #include "mtpproxydppanic.h" |
21 #include "mtpproxydppanic.h" |
22 #include "cmtpobjectbrowser.h" |
22 #include "cmtpobjectbrowser.h" |
23 #include "mtpdppanic.h" |
23 #include "mtpdppanic.h" |
24 #include "cmtpobjectmgr.h" |
24 #include "cmtpobjectmgr.h" |
25 |
25 #include "OstTraceDefinitions.h" |
26 __FLOG_STMT( _LIT8( KComponent,"PrxyCopyObj" ); ) |
26 #ifdef OST_TRACE_COMPILER_IN_USE |
|
27 #include "cmtpcopyobjectTraces.h" |
|
28 #endif |
|
29 |
|
30 |
27 const TUint KInvalidDpId = 0xFF; |
31 const TUint KInvalidDpId = 0xFF; |
28 |
32 |
29 /** |
33 /** |
30 Verification data for the CopyObject request |
34 Verification data for the CopyObject request |
31 */ |
35 */ |
55 /** |
59 /** |
56 Destructor |
60 Destructor |
57 */ |
61 */ |
58 CMTPCopyObject::~CMTPCopyObject() |
62 CMTPCopyObject::~CMTPCopyObject() |
59 { |
63 { |
|
64 OstTraceFunctionEntry0( CMTPCOPYOBJECT_CMTPCOPYOBJECT_DES_ENTRY ); |
60 iSingletons.Close(); |
65 iSingletons.Close(); |
61 iTargetDps.Close(); |
66 iTargetDps.Close(); |
62 iNewHandleParentStack.Close(); |
67 iNewHandleParentStack.Close(); |
63 iHandleDepths.Close(); |
68 iHandleDepths.Close(); |
64 iHandles.Close(); |
69 iHandles.Close(); |
65 delete iObjBrowser; |
70 delete iObjBrowser; |
66 |
71 OstTraceFunctionExit0( CMTPCOPYOBJECT_CMTPCOPYOBJECT_DES_EXIT ); |
67 __FLOG( _L8("+/-Dtor") ); |
|
68 __FLOG_CLOSE; |
|
69 } |
72 } |
70 |
73 |
71 /** |
74 /** |
72 Constructor |
75 Constructor |
73 */ |
76 */ |
74 CMTPCopyObject::CMTPCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : |
77 CMTPCopyObject::CMTPCopyObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : |
75 CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPCopyObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPCopyObjectPolicy) |
78 CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPCopyObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPCopyObjectPolicy) |
76 { |
79 { |
77 __FLOG_OPEN( KMTPSubsystem, KComponent ); |
80 |
78 __FLOG( _L8("+/-Ctor") ); |
|
79 } |
81 } |
80 |
82 |
81 /** |
83 /** |
82 Second phase constructor. |
84 Second phase constructor. |
83 */ |
85 */ |
84 void CMTPCopyObject::ConstructL() |
86 void CMTPCopyObject::ConstructL() |
85 { |
87 { |
86 __FLOG( _L8("+ConstructL") ); |
88 OstTraceFunctionEntry0( CMTPCOPYOBJECT_CONSTRUCTL_ENTRY ); |
87 iSingletons.OpenL(); |
89 iSingletons.OpenL(); |
88 iOwnerDp = KInvalidDpId; |
90 iOwnerDp = KInvalidDpId; |
89 __FLOG( _L8("-ConstructL") ); |
91 OstTraceFunctionExit0( CMTPCOPYOBJECT_CONSTRUCTL_EXIT ); |
90 } |
92 } |
91 |
93 |
92 /** |
94 /** |
93 DeleteObject request handler |
95 DeleteObject request handler |
94 */ |
96 */ |
95 void CMTPCopyObject::ServiceL() |
97 void CMTPCopyObject::ServiceL() |
96 { |
98 { |
97 __FLOG( _L8("+ServiceL") ); |
99 OstTraceFunctionEntry0( CMTPCOPYOBJECT_SERVICEL_ENTRY ); |
98 iTargetDps.Reset(); |
100 iTargetDps.Reset(); |
99 CMTPParserRouter& router(iSingletons.Router()); |
101 CMTPParserRouter& router(iSingletons.Router()); |
100 CMTPParserRouter::TRoutingParameters params(Request(), iConnection); |
102 CMTPParserRouter::TRoutingParameters params(Request(), iConnection); |
101 router.ParseOperationRequestL(params); |
103 router.ParseOperationRequestL(params); |
102 router.RouteOperationRequestL(params, iTargetDps); |
104 router.RouteOperationRequestL(params, iTargetDps); |
103 |
105 |
104 BrowseHandlesL(); |
106 BrowseHandlesL(); |
105 |
107 |
106 __FLOG( _L8("-ServiceL") ); |
108 OstTraceFunctionExit0( CMTPCOPYOBJECT_SERVICEL_EXIT ); |
107 } |
109 } |
108 |
110 |
109 void CMTPCopyObject::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/) |
111 void CMTPCopyObject::ProxyReceiveDataL(MMTPType& /*aData*/, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& /*aStatus*/) |
110 { |
112 { |
111 Panic(EMTPWrongRequestPhase); |
113 Panic(EMTPWrongRequestPhase); |
120 void CMTPCopyObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus) |
122 void CMTPCopyObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TRequestStatus& aStatus) |
121 #else |
123 #else |
122 void CMTPCopyObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus) |
124 void CMTPCopyObject::ProxySendResponseL(const TMTPTypeResponse& aResponse, const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/, TRequestStatus& aStatus) |
123 #endif |
125 #endif |
124 { |
126 { |
125 __FLOG( _L8("+ProxySendResponseL") ); |
127 OstTraceFunctionEntry0( CMTPCOPYOBJECT_PROXYSENDRESPONSEL_ENTRY ); |
126 __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy)); |
128 __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy)); |
127 |
129 |
128 if ( aStatus == KErrNone ) |
130 if ( aStatus == KErrNone ) |
129 { |
131 { |
130 if ( iIsCopyingFolder ) |
132 if ( iIsCopyingFolder ) |
138 } |
140 } |
139 |
141 |
140 MMTPType::CopyL(aResponse, iResponse); |
142 MMTPType::CopyL(aResponse, iResponse); |
141 TRequestStatus* status = &aStatus; |
143 TRequestStatus* status = &aStatus; |
142 User::RequestComplete(status, KErrNone); |
144 User::RequestComplete(status, KErrNone); |
143 __FLOG( _L8("-ProxySendResponseL") ); |
145 OstTraceFunctionExit0( CMTPCOPYOBJECT_PROXYSENDRESPONSEL_EXIT ); |
144 } |
146 } |
145 |
147 |
146 #ifdef _DEBUG |
148 #ifdef _DEBUG |
147 void CMTPCopyObject::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
149 void CMTPCopyObject::ProxyTransactionCompleteL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
148 #else |
150 #else |
149 void CMTPCopyObject::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/) |
151 void CMTPCopyObject::ProxyTransactionCompleteL(const TMTPTypeRequest& /*aRequest*/, MMTPConnection& /*aConnection*/) |
150 #endif |
152 #endif |
151 { |
153 { |
152 __FLOG( _L8("+ProxyTransactionCompleteL") ); |
154 OstTraceFunctionEntry0( CMTPCOPYOBJECT_PROXYTRANSACTIONCOMPLETEL_ENTRY ); |
153 __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy)); |
155 __ASSERT_DEBUG(((&iCurrentRequest == &aRequest) && (&iConnection == &aConnection)), Panic(EMTPNotSameRequestProxy)); |
154 TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral); |
156 TInt err((iResponse.Uint16(TMTPTypeResponse::EResponseCode) == EMTPRespCodeOK) ? KErrNone : KErrGeneral); |
155 if (err == KErrNone) |
157 if (err == KErrNone) |
156 { |
158 { |
157 iCurrentHandle--; |
159 iCurrentHandle--; |
159 } |
161 } |
160 else |
162 else |
161 { |
163 { |
162 SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) ); |
164 SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) ); |
163 } |
165 } |
164 __FLOG( _L8("-ProxyTransactionCompleteL") ); |
166 OstTraceFunctionExit0( CMTPCOPYOBJECT_PROXYTRANSACTIONCOMPLETEL_EXIT ); |
165 } |
167 } |
166 |
168 |
167 void CMTPCopyObject::RunL() |
169 void CMTPCopyObject::RunL() |
168 { |
170 { |
169 __FLOG( _L8("+RunL") ); |
171 OstTraceFunctionEntry0( CMTPCOPYOBJECT_RUNL_ENTRY ); |
170 |
172 OstTrace1( TRACE_NORMAL, CMTPCOPYOBJECT_RUNL, "iStatus == %d", iStatus.Int() ); |
171 __FLOG_1( _L8("iStatus == %d"), iStatus.Int() ); |
173 |
172 |
|
173 if ( iStatus == KErrNone ) |
174 if ( iStatus == KErrNone ) |
174 { |
175 { |
175 NextObjectHandleL(); |
176 NextObjectHandleL(); |
176 if ( iOwnerDp != KInvalidDpId ) |
177 if ( iOwnerDp != KInvalidDpId ) |
177 { |
178 { |
236 CMTPObjectBrowser::TBrowseCallback callback = { CMTPCopyObject::OnBrowseObjectL, this }; |
237 CMTPObjectBrowser::TBrowseCallback callback = { CMTPCopyObject::OnBrowseObjectL, this }; |
237 TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); |
238 TUint32 handle = Request().Uint32( TMTPTypeRequest::ERequestParameter1 ); |
238 TUint32 newHandleParent = Request().Uint32( TMTPTypeRequest::ERequestParameter3 ); |
239 TUint32 newHandleParent = Request().Uint32( TMTPTypeRequest::ERequestParameter3 ); |
239 iNewHandleParentStack.AppendL( newHandleParent ); |
240 iNewHandleParentStack.AppendL( newHandleParent ); |
240 iObjBrowser->GoL( KMTPFormatsAll, handle, KMaxTUint32, callback ); |
241 iObjBrowser->GoL( KMTPFormatsAll, handle, KMaxTUint32, callback ); |
241 __FLOG_1( _L8("iHandles.Count() = %d"), iHandles.Count() ); |
242 OstTrace1( TRACE_NORMAL, CMTPCOPYOBJECT_BROWSEHANDLESL, "iHandles.Count() = %d", iHandles.Count() ); |
|
243 |
242 |
244 |
243 if ( iHandles.Count() > 0 ) |
245 if ( iHandles.Count() > 0 ) |
244 { |
246 { |
245 iCurrentHandle = iHandles.Count() - 1; |
247 iCurrentHandle = iHandles.Count() - 1; |
246 Schedule( KErrNone ); |
248 Schedule( KErrNone ); |
248 else |
250 else |
249 { |
251 { |
250 SendResponseL( EMTPRespCodeInvalidObjectHandle ); |
252 SendResponseL( EMTPRespCodeInvalidObjectHandle ); |
251 } |
253 } |
252 |
254 |
253 __FLOG( _L8("-BrowseHandlesL") ); |
255 OstTraceFunctionExit0( CMTPCOPYOBJECT_BROWSEHANDLESL_EXIT ); |
254 } |
256 } |
255 |
257 |
256 void CMTPCopyObject::NextObjectHandleL() |
258 void CMTPCopyObject::NextObjectHandleL() |
257 { |
259 { |
258 __FLOG( _L8("+NextObjectHandleL") ); |
260 OstTraceFunctionEntry0( CMTPCOPYOBJECT_NEXTOBJECTHANDLEL_ENTRY ); |
259 __ASSERT_DEBUG( ( iNewHandleParentStack.Count() > 0 ), User::Invariant() ); |
261 __ASSERT_DEBUG( ( iNewHandleParentStack.Count() > 0 ), User::Invariant() ); |
260 iOwnerDp = KInvalidDpId; |
262 iOwnerDp = KInvalidDpId; |
261 if ( iCurrentHandle >=0 ) |
263 if ( iCurrentHandle >=0 ) |
262 { |
264 { |
263 __FLOG_1( _L8("iCurrentHandle = %d"), iCurrentHandle ); |
265 OstTrace1( TRACE_NORMAL, CMTPCOPYOBJECT_NEXTOBJECTHANDLEL, "iCurrentHandle = %d", iCurrentHandle ); |
264 TUint32 handle = iHandles[iCurrentHandle]; |
266 TUint32 handle = iHandles[iCurrentHandle]; |
265 TUint32 depth = iHandleDepths[iCurrentHandle]; |
267 TUint32 depth = iHandleDepths[iCurrentHandle]; |
266 __FLOG_1( _L8("depth = %d"), depth ); |
268 OstTrace1( TRACE_NORMAL, DUP1_CMTPCOPYOBJECT_NEXTOBJECTHANDLEL, "depth = %d", depth ); |
267 if ( iCurrentHandle != ( iHandles.Count() - 1 ) ) |
269 if ( iCurrentHandle != ( iHandles.Count() - 1 ) ) |
268 { |
270 { |
269 TUint32 previousDepth = iHandleDepths[iCurrentHandle+1]; |
271 TUint32 previousDepth = iHandleDepths[iCurrentHandle+1]; |
270 __FLOG_1( _L8("previousDepth = %d"), previousDepth ); |
272 OstTrace1( TRACE_NORMAL, DUP2_CMTPCOPYOBJECT_NEXTOBJECTHANDLEL, "previousDepth = %d", previousDepth ); |
271 if ( depth < previousDepth ) |
273 if ( depth < previousDepth ) |
272 { |
274 { |
273 // Completed copying folder and all its sub-folder and files, pop all copied folders' handle which are not shallower than the current one. |
275 // Completed copying folder and all its sub-folder and files, pop all copied folders' handle which are not shallower than the current one. |
274 |
276 |
275 // Step 1: pop the previous handle itself if it is am empty folder |
277 // Step 1: pop the previous handle itself if it is am empty folder |
311 { |
313 { |
312 iResponse.SetUint32( TMTPTypeResponse::EResponseParameter1, iRespHandle ); |
314 iResponse.SetUint32( TMTPTypeResponse::EResponseParameter1, iRespHandle ); |
313 SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) ); |
315 SendResponseL( iResponse.Uint16( TMTPTypeResponse::EResponseCode ) ); |
314 } |
316 } |
315 |
317 |
316 __FLOG( _L8("-NextObjectHandleL") ); |
318 OstTraceFunctionExit0( CMTPCOPYOBJECT_NEXTOBJECTHANDLEL_EXIT ); |
317 } |
319 } |
318 |
320 |
319 void CMTPCopyObject::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth ) |
321 void CMTPCopyObject::OnBrowseObjectL( TAny* aSelf, TUint aHandle, TUint32 aCurDepth ) |
320 { |
322 { |
|
323 OstTraceFunctionEntry0( CMTPCOPYOBJECT_ONBROWSEOBJECTL_ENTRY ); |
321 CMTPCopyObject* self = reinterpret_cast< CMTPCopyObject* >( aSelf ); |
324 CMTPCopyObject* self = reinterpret_cast< CMTPCopyObject* >( aSelf ); |
322 if ( self->iTargetDps.Find(self->iSingletons.ObjectMgr().ObjectOwnerId(aHandle)) != KErrNotFound ) |
325 if ( self->iTargetDps.Find(self->iSingletons.ObjectMgr().ObjectOwnerId(aHandle)) != KErrNotFound ) |
323 { |
326 { |
324 self->iHandles.AppendL( aHandle ); |
327 self->iHandles.AppendL( aHandle ); |
325 self->iHandleDepths.AppendL( aCurDepth ); |
328 self->iHandleDepths.AppendL( aCurDepth ); |
326 } |
329 } |
327 } |
330 OstTraceFunctionExit0( CMTPCOPYOBJECT_ONBROWSEOBJECTL_EXIT ); |
328 |
331 } |
|
332 |