13 * |
13 * |
14 * Description: These classes implement dps states. |
14 * Description: These classes implement dps states. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <e32debug.h> |
|
19 #include "dpsstate.h" |
18 #include "dpsstate.h" |
20 #include "dpsstatemachine.h" |
19 #include "dpsstatemachine.h" |
21 #include "dpstransaction.h" |
20 #include "dpstransaction.h" |
22 #include "dpsscriptreceiver.h" |
21 #include "dpsscriptreceiver.h" |
23 #include <pictbridge.h> |
22 #include <pictbridge.h> |
24 |
23 #include "OstTraceDefinitions.h" |
25 #ifdef _DEBUG |
24 #ifdef OST_TRACE_COMPILER_IN_USE |
26 # define IF_DEBUG(t) {RDebug::t;} |
25 #include "dpsstateTraces.h" |
27 #else |
|
28 # define IF_DEBUG(t) |
|
29 #endif |
26 #endif |
|
27 |
30 |
28 |
31 // --------------------------------------------------------------------------- |
29 // --------------------------------------------------------------------------- |
32 // |
30 // |
33 // --------------------------------------------------------------------------- |
31 // --------------------------------------------------------------------------- |
34 // |
32 // |
39 // |
37 // |
40 // --------------------------------------------------------------------------- |
38 // --------------------------------------------------------------------------- |
41 // |
39 // |
42 void TDpsIdleState::ScriptSentNotifyL(TBool /*aReply*/) |
40 void TDpsIdleState::ScriptSentNotifyL(TBool /*aReply*/) |
43 { |
41 { |
44 IF_DEBUG(Print(_L("TDpsIdleState::ScriptSentNotify"))); |
42 OstTraceFunctionEntry0( TDPSIDLESTATE_SCRIPTSENTNOTIFYL_ENTRY ); |
|
43 OstTraceFunctionExit0( TDPSIDLESTATE_SCRIPTSENTNOTIFYL_EXIT ); |
45 } |
44 } |
46 |
45 |
47 // --------------------------------------------------------------------------- |
46 // --------------------------------------------------------------------------- |
48 // |
47 // |
49 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
50 // |
49 // |
51 void TDpsIdleState::ScriptReceivedNotifyL(TBool aReply) |
50 void TDpsIdleState::ScriptReceivedNotifyL(TBool aReply) |
52 { |
51 { |
53 if (!aReply) |
52 if (!aReply) |
54 { |
53 { |
55 IF_DEBUG(Print(_L("TDpsIdleState::ScriptReceived request got"))); |
54 OstTrace0( TRACE_NORMAL, TDPSIDLESTATE_SCRIPTRECEIVEDNOTIFYL, "request got" ); |
56 iStateMachine->Trader()->ParseScriptL(aReply); |
55 iStateMachine->Trader()->ParseScriptL(aReply); |
57 iStateMachine->SetState(iStateMachine->SendingRepState()); |
56 iStateMachine->SetState(iStateMachine->SendingRepState()); |
58 } |
57 } |
59 else |
58 else |
60 { |
59 { |
61 IF_DEBUG(Print(_L( |
60 OstTrace0( TRACE_NORMAL, DUP1_TDPSIDLESTATE_SCRIPTRECEIVEDNOTIFYL, "should not get reply!!!" ); |
62 "TDpsIdleState::ScriptReceived should not get reply!!!"))); |
|
63 } |
61 } |
64 } |
62 } |
65 |
63 |
66 // --------------------------------------------------------------------------- |
64 // --------------------------------------------------------------------------- |
67 // |
65 // |
68 // --------------------------------------------------------------------------- |
66 // --------------------------------------------------------------------------- |
69 // |
67 // |
70 void TDpsIdleState::Error(TInt aErr) |
68 void TDpsIdleState::Error(TInt aErr) |
71 { |
69 { |
72 IF_DEBUG(Print(_L("TDpsIdleState::Error %d"), aErr)); |
70 OstTrace1( TRACE_NORMAL, TDPSIDLESTATE_ERROR, "Error %d", aErr ); |
73 if ((aErr != KErrCancel) && (aErr != KErrNotReady)) |
71 if ((aErr != KErrCancel) && (aErr != KErrNotReady)) |
74 { |
72 { |
75 iStateMachine->Trader()->HandleHostRequestError(aErr); |
73 iStateMachine->Trader()->HandleHostRequestError(aErr); |
76 iStateMachine->SetState(iStateMachine->SendingRepState()); |
74 iStateMachine->SetState(iStateMachine->SendingRepState()); |
77 } |
75 } |
91 // |
89 // |
92 void TDpsSendingReqState::ScriptSentNotifyL(TBool aReply) |
90 void TDpsSendingReqState::ScriptSentNotifyL(TBool aReply) |
93 { |
91 { |
94 if (!aReply) |
92 if (!aReply) |
95 { |
93 { |
96 IF_DEBUG(Print(_L("TDpsSendingReqState::ScriptSent request"))); |
94 OstTrace0( TRACE_NORMAL, TDPSSENDINGREQSTATE_SCRIPTSENTNOTIFYL, " request" ); |
97 iStateMachine->SetState(iStateMachine->WaitingRepState()); |
95 iStateMachine->SetState(iStateMachine->WaitingRepState()); |
98 } |
96 } |
99 else |
97 else |
100 { |
98 { |
101 IF_DEBUG(Print(_L( |
99 OstTrace0( TRACE_NORMAL, DUP1_TDPSSENDINGREQSTATE_SCRIPTSENTNOTIFYL, " should not get reply!!" ); |
102 "TDpsSendingReqState::ScriptSent should not get reply!!"))); |
|
103 } |
100 } |
104 } |
101 } |
105 |
102 |
106 // --------------------------------------------------------------------------- |
103 // --------------------------------------------------------------------------- |
107 // |
104 // |
108 // --------------------------------------------------------------------------- |
105 // --------------------------------------------------------------------------- |
109 // |
106 // |
110 void TDpsSendingReqState::ScriptReceivedNotifyL(TBool /*aReply*/) |
107 void TDpsSendingReqState::ScriptReceivedNotifyL(TBool /*aReply*/) |
111 { |
108 { |
112 IF_DEBUG(Print(_L("TDpsSendingReqState::ScriptReceived"))); |
109 OstTrace0( TRACE_NORMAL, TDPSSENDINGREQSTATE_SCRIPTRECEIVEDNOTIFYL, "**should not reply to the request/reply from host" ); |
113 IF_DEBUG(Print(_L("**should not reply to the request/reply from host"))); |
|
114 } |
110 } |
115 |
111 |
116 // --------------------------------------------------------------------------- |
112 // --------------------------------------------------------------------------- |
117 // |
113 // |
118 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
137 // |
133 // |
138 // --------------------------------------------------------------------------- |
134 // --------------------------------------------------------------------------- |
139 // |
135 // |
140 void TDpsWaitingRepState::ScriptSentNotifyL(TBool /*aReply*/) |
136 void TDpsWaitingRepState::ScriptSentNotifyL(TBool /*aReply*/) |
141 { |
137 { |
142 IF_DEBUG(Print(_L("TDpsWaitingRepState::ScriptSent"))); |
138 OstTraceFunctionEntry0( TDPSWAITINGREPSTATE_SCRIPTSENTNOTIFYL_ENTRY ); |
|
139 OstTraceFunctionExit0( TDPSWAITINGREPSTATE_SCRIPTSENTNOTIFYL_EXIT ); |
143 } |
140 } |
144 |
141 |
145 // --------------------------------------------------------------------------- |
142 // --------------------------------------------------------------------------- |
146 // |
143 // |
147 // --------------------------------------------------------------------------- |
144 // --------------------------------------------------------------------------- |
148 // |
145 // |
149 void TDpsWaitingRepState::ScriptReceivedNotifyL(TBool aReply) |
146 void TDpsWaitingRepState::ScriptReceivedNotifyL(TBool aReply) |
150 { |
147 { |
151 if (aReply) |
148 if (aReply) |
152 { |
149 { |
153 IF_DEBUG(Print(_L("WaitingRepState reply"))) |
150 OstTrace0( TRACE_NORMAL, TDPSWAITINGREPSTATE_SCRIPTRECEIVEDNOTIFYL, "WaitingRepState reply" ); |
154 |
151 |
155 iStateMachine->Trader()->ParseScriptL(aReply); |
152 iStateMachine->Trader()->ParseScriptL(aReply); |
156 User::RequestComplete( |
153 User::RequestComplete( |
157 iStateMachine->DpsEngine()->OperationRequest(), KErrNone); |
154 iStateMachine->DpsEngine()->OperationRequest(), KErrNone); |
158 iStateMachine->Initialize(); |
155 iStateMachine->Initialize(); |
159 } |
156 } |
160 else |
157 else |
161 { |
158 { |
162 IF_DEBUG(Print(_L("WaitingRepState should not get request"))); |
159 OstTrace0( TRACE_NORMAL, DUP1_TDPSWAITINGREPSTATE_SCRIPTRECEIVEDNOTIFYL, "WaitingRepState should not get request" ); |
163 // collision happened, we do nothing because the host will |
160 // collision happened, we do nothing because the host will |
164 // eventually handle this by sending the correct response. but we need |
161 // eventually handle this by sending the correct response. but we need |
165 // to subscribe for the event again. |
162 // to subscribe for the event again. |
166 iStateMachine->ScriptReceiver()->WaitForReceive(); |
163 iStateMachine->ScriptReceiver()->WaitForReceive(); |
167 } |
164 } |
192 // |
189 // |
193 void TDpsSendingRepState::ScriptSentNotifyL(TBool aReply) |
190 void TDpsSendingRepState::ScriptSentNotifyL(TBool aReply) |
194 { |
191 { |
195 if (aReply) |
192 if (aReply) |
196 { |
193 { |
197 IF_DEBUG(Print(_L("TDpsSendingRepState::ScriptSent reply"))); |
194 OstTrace0( TRACE_NORMAL, TDPSSENDINGREPSTATE_SCRIPTSENTNOTIFYL, "reply" ); |
198 if (KErrNone == iStateMachine->CurError()) |
195 if (KErrNone == iStateMachine->CurError()) |
199 { |
196 { |
200 // this is the normal situation, inform the client |
197 // this is the normal situation, inform the client |
201 User::RequestComplete(iStateMachine->DpsEngine()->EventRequest(), |
198 User::RequestComplete(iStateMachine->DpsEngine()->EventRequest(), |
202 KErrNone); |
199 KErrNone); |
209 } |
206 } |
210 iStateMachine->Initialize(); |
207 iStateMachine->Initialize(); |
211 } |
208 } |
212 else |
209 else |
213 { |
210 { |
214 IF_DEBUG(Print(_L( |
211 OstTrace0( TRACE_NORMAL, DUP1_TDPSSENDINGREPSTATE_SCRIPTSENTNOTIFYL, "shoul not get request!!!" ); |
215 "TDpsSendingRepState::ScriptSent shoul not get request!!!"))); |
|
216 } |
212 } |
217 } |
213 } |
218 |
214 |
219 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
220 // |
216 // |
221 // --------------------------------------------------------------------------- |
217 // --------------------------------------------------------------------------- |
222 // |
218 // |
223 void TDpsSendingRepState::ScriptReceivedNotifyL(TBool /*aReply*/) |
219 void TDpsSendingRepState::ScriptReceivedNotifyL(TBool /*aReply*/) |
224 { |
220 { |
225 IF_DEBUG(Print(_L("TDpsSendingRepState::ScriptReceived"))); |
221 OstTraceFunctionEntry0( TDPSSENDINGREPSTATE_SCRIPTRECEIVEDNOTIFYL_ENTRY ); |
|
222 OstTraceFunctionExit0( TDPSSENDINGREPSTATE_SCRIPTRECEIVEDNOTIFYL_EXIT ); |
226 } |
223 } |
227 |
224 |
228 // --------------------------------------------------------------------------- |
225 // --------------------------------------------------------------------------- |
229 // |
226 // |
230 // --------------------------------------------------------------------------- |
227 // --------------------------------------------------------------------------- |