16 /** |
16 /** |
17 @internalComponent |
17 @internalComponent |
18 */ |
18 */ |
19 |
19 |
20 #include "cptpipcommandhandler.h" |
20 #include "cptpipcommandhandler.h" |
|
21 #include "OstTraceDefinitions.h" |
|
22 #ifdef OST_TRACE_COMPILER_IN_USE |
|
23 #include "cptpipcommandhandlerTraces.h" |
|
24 #endif |
|
25 |
21 |
26 |
22 const TUint32 KPTPIPHeaderSize = 8; |
27 const TUint32 KPTPIPHeaderSize = 8; |
23 const TUint32 KPTPIPDataHeaderSize = 12; |
28 const TUint32 KPTPIPDataHeaderSize = 12; |
24 |
|
25 __FLOG_STMT(_LIT8(KComponent,"CCommandHandler");) |
|
26 |
29 |
27 /** |
30 /** |
28 Creates the channel for commands. The base class constructl is called. |
31 Creates the channel for commands. The base class constructl is called. |
29 */ |
32 */ |
30 CPTPIPCommandHandler* CPTPIPCommandHandler::NewL(CPTPIPConnection& aConnection) |
33 CPTPIPCommandHandler* CPTPIPCommandHandler::NewL(CPTPIPConnection& aConnection) |
31 { |
34 { |
|
35 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_NEWL_ENTRY ); |
32 |
36 |
33 CPTPIPCommandHandler* self = new(ELeave) CPTPIPCommandHandler(aConnection); |
37 CPTPIPCommandHandler* self = new(ELeave) CPTPIPCommandHandler(aConnection); |
34 CleanupStack::PushL(self); |
38 CleanupStack::PushL(self); |
35 #ifdef __FLOG_ACTIVE |
|
36 self->ConstructL(KComponent); |
|
37 #else |
|
38 self->ConstructL(); |
39 self->ConstructL(); |
39 #endif |
|
40 CleanupStack::Pop(); |
40 CleanupStack::Pop(); |
|
41 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_NEWL_EXIT ); |
41 return self; |
42 return self; |
42 } |
43 } |
43 |
44 |
44 /** |
45 /** |
45 Desctructor |
46 Desctructor |
46 */ |
47 */ |
47 CPTPIPCommandHandler::~CPTPIPCommandHandler() |
48 CPTPIPCommandHandler::~CPTPIPCommandHandler() |
48 { |
49 { |
49 __FLOG(_L8("Destructor - Entry")); |
50 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_CPTPIPCOMMANDHANDLER_ENTRY ); |
50 __FLOG(_L8("Destructor - Exit")); |
51 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_CPTPIPCOMMANDHANDLER_EXIT ); |
51 } |
52 } |
52 |
53 |
53 /** |
54 /** |
54 Constructor |
55 Constructor |
55 */ |
56 */ |
56 CPTPIPCommandHandler::CPTPIPCommandHandler(CPTPIPConnection& aConnection): |
57 CPTPIPCommandHandler::CPTPIPCommandHandler(CPTPIPConnection& aConnection): |
57 CPTPIPSocketHandlerBase(aConnection, CActive::EPriorityStandard) |
58 CPTPIPSocketHandlerBase(aConnection, CActive::EPriorityStandard) |
58 |
59 |
59 { |
60 { |
|
61 OstTraceFunctionEntry0( DUP1_CPTPIPCOMMANDHANDLER_CPTPIPCOMMANDHANDLER_ENTRY ); |
|
62 OstTraceFunctionExit0( DUP1_CPTPIPCOMMANDHANDLER_CPTPIPCOMMANDHANDLER_EXIT ); |
60 } |
63 } |
61 |
64 |
62 /** |
65 /** |
63 Initiates the sending of the command data. The base class implements the handling |
66 Initiates the sending of the command data. The base class implements the handling |
64 of the socket to send the actual data. |
67 of the socket to send the actual data. |
66 @param aTransactionId The id of the current ongoing transaction. |
69 @param aTransactionId The id of the current ongoing transaction. |
67 @leave One of the system wide error codes, if a processing failure occurs. |
70 @leave One of the system wide error codes, if a processing failure occurs. |
68 */ |
71 */ |
69 void CPTPIPCommandHandler::SendCommandDataL(const MMTPType& aRtoIData, TUint32 aTransactionId) |
72 void CPTPIPCommandHandler::SendCommandDataL(const MMTPType& aRtoIData, TUint32 aTransactionId) |
70 { |
73 { |
71 __FLOG(_L8("SendCommandDataL - Entry")); |
74 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_SENDCOMMANDDATAL_ENTRY ); |
72 SendDataL(aRtoIData, aTransactionId); |
75 SendDataL(aRtoIData, aTransactionId); |
73 __FLOG(_L8("SendCommandDataL - Exit")); |
76 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_SENDCOMMANDDATAL_EXIT ); |
74 } |
77 } |
75 |
78 |
76 /** |
79 /** |
77 Initiates the sending of the command data. The base class implements the handling |
80 Initiates the sending of the command data. The base class implements the handling |
78 of the socket to send the actual data. |
81 of the socket to send the actual data. |
80 @param aTransactionId The id of the current ongoing transaction. |
83 @param aTransactionId The id of the current ongoing transaction. |
81 @leave One of the system wide error codes, if a processing failure occurs. |
84 @leave One of the system wide error codes, if a processing failure occurs. |
82 */ |
85 */ |
83 void CPTPIPCommandHandler::SendCommandL(const MMTPType& aResponse) |
86 void CPTPIPCommandHandler::SendCommandL(const MMTPType& aResponse) |
84 { |
87 { |
85 __FLOG(_L8("SendCommandDataL - Entry")); |
88 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_SENDCOMMANDL_ENTRY ); |
86 SendDataL(aResponse, 0); |
89 SendDataL(aResponse, 0); |
87 __FLOG(_L8("SendCommandDataL - Exit")); |
90 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_SENDCOMMANDL_EXIT ); |
88 } |
91 } |
89 |
92 |
90 /** |
93 /** |
91 Signals the completion of sending data over the socket, which was started by |
94 Signals the completion of sending data over the socket, which was started by |
92 SendCommandDataL. Its called by the base sockethandler and in turn informs the |
95 SendCommandDataL. Its called by the base sockethandler and in turn informs the |
94 @param aError - The error if any returned by the sockethandler. (KErrNone if no errors) |
97 @param aError - The error if any returned by the sockethandler. (KErrNone if no errors) |
95 @param aSource - The buffer of data which had been given by the framework to send to initiator. |
98 @param aSource - The buffer of data which had been given by the framework to send to initiator. |
96 */ |
99 */ |
97 void CPTPIPCommandHandler::SendDataCompleteL(TInt aError, const MMTPType& aSource) |
100 void CPTPIPCommandHandler::SendDataCompleteL(TInt aError, const MMTPType& aSource) |
98 { |
101 { |
99 __FLOG(_L8("SendDataCompleteL - Entry")); |
102 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_SENDDATACOMPLETEL_ENTRY ); |
100 Connection().SendCommandChannelCompleteL(aError, aSource); |
103 Connection().SendCommandChannelCompleteL(aError, aSource); |
101 __FLOG(_L8("SendDataCompleteL - Exit")); |
104 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_SENDDATACOMPLETEL_EXIT ); |
102 } |
105 } |
103 |
106 |
104 |
107 |
105 /** |
108 /** |
106 Initiates the receiving of the info on the command channel, used for both commands |
109 Initiates the receiving of the info on the command channel, used for both commands |
108 @param aData The buffer given by the framework in which the command request will be received from the initiator |
111 @param aData The buffer given by the framework in which the command request will be received from the initiator |
109 @leave One of the system wide error codes, if a processing failure occurs. |
112 @leave One of the system wide error codes, if a processing failure occurs. |
110 */ |
113 */ |
111 void CPTPIPCommandHandler::ReceiveCommandRequestL(MMTPType& aRequest) |
114 void CPTPIPCommandHandler::ReceiveCommandRequestL(MMTPType& aRequest) |
112 { |
115 { |
113 __FLOG(_L8("ReceiveCommandDataL - Entry")); |
116 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_RECEIVECOMMANDREQUESTL_ENTRY ); |
114 ReceiveDataL(aRequest); |
117 ReceiveDataL(aRequest); |
115 __FLOG(_L8("ReceiveCommandDataL - Exit")); |
118 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_RECEIVECOMMANDREQUESTL_EXIT ); |
116 } |
119 } |
117 |
120 |
118 /** |
121 /** |
119 Initiates the receiving of the info on the command channel, used for both commands |
122 Initiates the receiving of the info on the command channel, used for both commands |
120 and data. |
123 and data. |
121 @param aItoRData The buffer given by the framework in which the command data will be received from the initiator |
124 @param aItoRData The buffer given by the framework in which the command data will be received from the initiator |
122 @leave One of the system wide error codes, if a processing failure occurs. |
125 @leave One of the system wide error codes, if a processing failure occurs. |
123 */ |
126 */ |
124 void CPTPIPCommandHandler::ReceiveCommandDataL(MMTPType& aItoRData) |
127 void CPTPIPCommandHandler::ReceiveCommandDataL(MMTPType& aItoRData) |
125 { |
128 { |
126 __FLOG(_L8("ReceiveCommandDataL - Entry")); |
129 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_RECEIVECOMMANDDATAL_ENTRY ); |
127 ReceiveDataL(aItoRData); |
130 ReceiveDataL(aItoRData); |
128 __FLOG(_L8("ReceiveCommandDataL - Exit")); |
131 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_RECEIVECOMMANDDATAL_EXIT ); |
129 } |
132 } |
130 |
133 |
131 |
134 |
132 /** |
135 /** |
133 Marks the completion of receiving data over the command socket, which was started |
136 Marks the completion of receiving data over the command socket, which was started |
135 @param aError - The error if any returned by the sockethandler. (KErrNone if no errors) |
138 @param aError - The error if any returned by the sockethandler. (KErrNone if no errors) |
136 @param aSink - The buffer in which data received from the initiator is returned to the framework |
139 @param aSink - The buffer in which data received from the initiator is returned to the framework |
137 */ |
140 */ |
138 void CPTPIPCommandHandler::ReceiveDataCompleteL(TInt aError, MMTPType& aSink) |
141 void CPTPIPCommandHandler::ReceiveDataCompleteL(TInt aError, MMTPType& aSink) |
139 { |
142 { |
140 __FLOG(_L8("ReceiveDataCompleteL - Entry")); |
143 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_RECEIVEDATACOMPLETEL_ENTRY ); |
141 |
|
142 Connection().ReceiveCommandChannelCompleteL(aError, aSink); |
144 Connection().ReceiveCommandChannelCompleteL(aError, aSink); |
143 __FLOG(_L8("ReceiveDataCompleteL - Exit")); |
145 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_RECEIVEDATACOMPLETEL_EXIT ); |
144 } |
146 } |
145 |
147 |
146 /** |
148 /** |
147 Validates if the current payload in the container is the correct type to hold the |
149 Validates if the current payload in the container is the correct type to hold the |
148 data that is coming in. |
150 data that is coming in. |
152 |
154 |
153 @return type The ptpip packet type, like request, cancel etc |
155 @return type The ptpip packet type, like request, cancel etc |
154 */ |
156 */ |
155 TInt CPTPIPCommandHandler::ParsePTPIPHeaderL() |
157 TInt CPTPIPCommandHandler::ParsePTPIPHeaderL() |
156 { |
158 { |
157 __FLOG(_L8("ValidateAndSetPayload - Entry")); |
159 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_PARSEPTPIPHEADERL_ENTRY ); |
158 TUint32 type = 0; |
160 TUint32 type = 0; |
159 |
161 |
160 // If this is a request or event, then the first chunk will have 8 bytes |
162 // If this is a request or event, then the first chunk will have 8 bytes |
161 if (KPTPIPHeaderSize == iReceiveChunkData.MaxLength()) |
163 if (KPTPIPHeaderSize == iReceiveChunkData.MaxLength()) |
162 { |
164 { |
166 // if this is a data header, then the first chunk will have 12 bytes. |
168 // if this is a data header, then the first chunk will have 12 bytes. |
167 else if (KPTPIPDataHeaderSize == iReceiveChunkData.MaxLength()) |
169 else if (KPTPIPDataHeaderSize == iReceiveChunkData.MaxLength()) |
168 { |
170 { |
169 iPTPPacketLength = Connection().DataContainer()->Uint32L(CPTPIPDataContainer::EPacketLength); |
171 iPTPPacketLength = Connection().DataContainer()->Uint32L(CPTPIPDataContainer::EPacketLength); |
170 type = Connection().ValidateDataPacketL(); |
172 type = Connection().ValidateDataPacketL(); |
171 } |
173 } |
172 __FLOG(_L8("ValidateAndSetPayload - Exit")); |
174 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_PARSEPTPIPHEADERL_EXIT ); |
173 return type; |
175 return type; |
174 |
176 |
175 } |
177 } |
176 |
178 |
177 /** |
179 /** |
178 * This function is implemented in the event handler class for |
180 * This function is implemented in the event handler class for |
179 * handling the sending of the init acknowledgement. |
181 * handling the sending of the init acknowledgement. |
180 */ |
182 */ |
181 TBool CPTPIPCommandHandler::HandleInitAck() |
183 TBool CPTPIPCommandHandler::HandleInitAck() |
182 { |
184 { |
|
185 OstTraceFunctionEntry0( CPTPIPCOMMANDHANDLER_HANDLEINITACK_ENTRY ); |
|
186 OstTraceFunctionExit0( CPTPIPCOMMANDHANDLER_HANDLEINITACK_EXIT ); |
183 return EFalse; |
187 return EFalse; |
184 } |
188 } |