23 #include <mtp/mtpdatatypeconstants.h> |
23 #include <mtp/mtpdatatypeconstants.h> |
24 |
24 |
25 #include "cmtpsvcsetreferences.h" |
25 #include "cmtpsvcsetreferences.h" |
26 #include "mmtpservicedataprovider.h" |
26 #include "mmtpservicedataprovider.h" |
27 #include "mmtpsvcobjecthandler.h" |
27 #include "mmtpsvcobjecthandler.h" |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "cmtpsvcsetreferencesTraces.h" |
|
31 #endif |
28 |
32 |
29 __FLOG_STMT(_LIT8(KComponent,"SvcSetRef");) |
|
30 |
33 |
31 EXPORT_C MMTPRequestProcessor* CMTPSvcSetReferences::NewL(MMTPDataProviderFramework& aFramework, |
34 EXPORT_C MMTPRequestProcessor* CMTPSvcSetReferences::NewL(MMTPDataProviderFramework& aFramework, |
32 MMTPConnection& aConnection, |
35 MMTPConnection& aConnection, |
33 MMTPServiceDataProvider& aDataProvider) |
36 MMTPServiceDataProvider& aDataProvider) |
34 { |
37 { |
36 return self; |
39 return self; |
37 } |
40 } |
38 |
41 |
39 EXPORT_C CMTPSvcSetReferences::~CMTPSvcSetReferences() |
42 EXPORT_C CMTPSvcSetReferences::~CMTPSvcSetReferences() |
40 { |
43 { |
41 __FLOG(_L8("~CMTPSvcGetReferences - Entry")); |
44 OstTraceFunctionEntry0( CMTPSVCSETREFERENCES_CMTPSVCSETREFERENCES_DES_ENTRY ); |
42 delete iReferences; |
45 delete iReferences; |
43 delete iReceivedObjectMetaData; |
46 delete iReceivedObjectMetaData; |
44 __FLOG(_L8("~CMTPSvcGetReferences - Exit")); |
47 OstTraceFunctionExit0( CMTPSVCSETREFERENCES_CMTPSVCSETREFERENCES_DES_EXIT ); |
45 __FLOG_CLOSE; |
|
46 } |
48 } |
47 |
49 |
48 /** |
50 /** |
49 Standard c++ constructor |
51 Standard c++ constructor |
50 */ |
52 */ |
52 MMTPConnection& aConnection, |
54 MMTPConnection& aConnection, |
53 MMTPServiceDataProvider& aDataProvider) : |
55 MMTPServiceDataProvider& aDataProvider) : |
54 CMTPRequestProcessor(aFramework, aConnection, 0, NULL), |
56 CMTPRequestProcessor(aFramework, aConnection, 0, NULL), |
55 iDataProvider(aDataProvider) |
57 iDataProvider(aDataProvider) |
56 { |
58 { |
57 __FLOG_OPEN(KMTPSubsystem, KComponent); |
59 OstTraceFunctionEntry0( CMTPSVCSETREFERENCES_CMTPSVCSETREFERENCES_CONS_ENTRY ); |
58 __FLOG(_L8("Constructed")); |
60 OstTraceFunctionExit0( CMTPSVCSETREFERENCES_CMTPSVCSETREFERENCES_CONS_EXIT ); |
59 } |
61 } |
60 |
62 |
61 /** |
63 /** |
62 SetReferences request handler |
64 SetReferences request handler |
63 start receiving reference data from the initiator |
65 start receiving reference data from the initiator |
64 */ |
66 */ |
65 void CMTPSvcSetReferences::ServiceL() |
67 void CMTPSvcSetReferences::ServiceL() |
66 { |
68 { |
67 __FLOG(_L8("ServiceL - Entry")); |
69 OstTraceFunctionEntry0( CMTPSVCSETREFERENCES_SERVICEL_ENTRY ); |
68 delete iReferences; |
70 delete iReferences; |
69 iReferences = NULL; |
71 iReferences = NULL; |
70 iReferences = CMTPTypeArray::NewL(EMTPTypeAUINT32); |
72 iReferences = CMTPTypeArray::NewL(EMTPTypeAUINT32); |
71 ReceiveDataL(*iReferences); |
73 ReceiveDataL(*iReferences); |
72 __FLOG(_L8("ServiceL - Exit")); |
74 OstTraceFunctionExit0( CMTPSVCSETREFERENCES_SERVICEL_EXIT ); |
73 } |
75 } |
74 |
76 |
75 TBool CMTPSvcSetReferences::DoHandleResponsePhaseL() |
77 TBool CMTPSvcSetReferences::DoHandleResponsePhaseL() |
76 { |
78 { |
77 __FLOG(_L8("DoHandleResponsePhaseL - Entry")); |
79 OstTraceFunctionEntry0( CMTPSVCSETREFERENCES_DOHANDLERESPONSEPHASEL_ENTRY ); |
78 if(!VerifyReferenceHandlesL()) |
80 if(!VerifyReferenceHandlesL()) |
79 { |
81 { |
80 SendResponseL(EMTPRespCodeInvalidObjectReference); |
82 SendResponseL(EMTPRespCodeInvalidObjectReference); |
81 } |
83 } |
82 else |
84 else |
84 TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode); |
86 TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode); |
85 TMTPResponseCode responseCode = EMTPRespCodeOK; |
87 TMTPResponseCode responseCode = EMTPRespCodeOK; |
86 responseCode = (iDataProvider.ObjectHandler(formatCode))->SetObjectReferenceL(*iReceivedObjectMetaData, *iReferences); |
88 responseCode = (iDataProvider.ObjectHandler(formatCode))->SetObjectReferenceL(*iReceivedObjectMetaData, *iReferences); |
87 SendResponseL(responseCode); |
89 SendResponseL(responseCode); |
88 } |
90 } |
89 __FLOG(_L8("DoHandleResponsePhaseL - Exit")); |
91 OstTraceFunctionExit0( CMTPSVCSETREFERENCES_DOHANDLERESPONSEPHASEL_EXIT ); |
90 return EFalse; |
92 return EFalse; |
91 } |
93 } |
92 |
94 |
93 TBool CMTPSvcSetReferences::HasDataphase() const |
95 TBool CMTPSvcSetReferences::HasDataphase() const |
94 { |
96 { |
|
97 OstTraceFunctionEntry0( CMTPSVCSETREFERENCES_HASDATAPHASE_ENTRY ); |
|
98 OstTraceFunctionExit0( CMTPSVCSETREFERENCES_HASDATAPHASE_EXIT ); |
95 return ETrue; |
99 return ETrue; |
96 } |
100 } |
97 |
101 |
98 TBool CMTPSvcSetReferences::VerifyReferenceHandlesL() const |
102 TBool CMTPSvcSetReferences::VerifyReferenceHandlesL() const |
99 { |
103 { |
100 __FLOG(_L8("VerifyReferenceHandlesL - Entry")); |
104 OstTraceFunctionEntry0( CMTPSVCSETREFERENCES_VERIFYREFERENCEHANDLESL_ENTRY ); |
101 __ASSERT_DEBUG(iReferences, User::Invariant()); |
105 __ASSERT_DEBUG(iReferences, User::Invariant()); |
102 TBool result = ETrue; |
106 TBool result = ETrue; |
103 TInt count = iReferences->NumElements(); |
107 TInt count = iReferences->NumElements(); |
104 CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); |
108 CMTPObjectMetaData* object = CMTPObjectMetaData::NewLC(); |
105 MMTPObjectMgr& objectMgr = iFramework.ObjectMgr(); |
109 MMTPObjectMgr& objectMgr = iFramework.ObjectMgr(); |
112 result = EFalse; |
116 result = EFalse; |
113 break; |
117 break; |
114 } |
118 } |
115 } |
119 } |
116 CleanupStack::PopAndDestroy(object); |
120 CleanupStack::PopAndDestroy(object); |
117 __FLOG(_L8("VerifyReferenceHandlesL - Exit")); |
121 OstTraceFunctionExit0( CMTPSVCSETREFERENCES_VERIFYREFERENCEHANDLESL_EXIT ); |
118 return result; |
122 return result; |
119 } |
123 } |
120 |
124 |
121 TMTPResponseCode CMTPSvcSetReferences::CheckRequestL() |
125 TMTPResponseCode CMTPSvcSetReferences::CheckRequestL() |
122 { |
126 { |
123 __FLOG(_L8("CheckRequestL - Entry")); |
127 OstTraceFunctionEntry0( CMTPSVCSETREFERENCES_CHECKREQUESTL_ENTRY ); |
124 |
128 |
125 TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); |
129 TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); |
126 if (EMTPRespCodeOK == responseCode) |
130 if (EMTPRespCodeOK == responseCode) |
127 { |
131 { |
128 TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
132 TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
134 { |
138 { |
135 // Check whether the owner of this object is correct data provider |
139 // Check whether the owner of this object is correct data provider |
136 if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId()) |
140 if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId()) |
137 { |
141 { |
138 responseCode = EMTPRespCodeInvalidObjectHandle; |
142 responseCode = EMTPRespCodeInvalidObjectHandle; |
139 __FLOG(_L8("CheckRequestL - DataProviderId dismatch")); |
143 OstTrace0( TRACE_WARNING, DUP1_CMTPSVCSETREFERENCES_CHECKREQUESTL, "CheckRequestL - DataProviderId dismatch" ); |
140 } |
144 } |
141 else |
145 else |
142 { |
146 { |
143 // Check format code |
147 // Check format code |
144 TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode); |
148 TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode); |