29
|
1 |
/*
|
|
2 |
* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: These classes implement dps states.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "dpsstate.h"
|
|
19 |
#include "dpsstatemachine.h"
|
|
20 |
#include "dpstransaction.h"
|
|
21 |
#include "dpsscriptreceiver.h"
|
|
22 |
#include <pictbridge.h>
|
49
|
23 |
#include "OstTraceDefinitions.h"
|
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
25 |
#include "dpsstateTraces.h"
|
29
|
26 |
#endif
|
49
|
27 |
|
29
|
28 |
|
|
29 |
// ---------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
TDpsIdleState::TDpsIdleState(CDpsStateMachine* aStateMachine) :
|
|
34 |
iStateMachine(aStateMachine) {}
|
|
35 |
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
void TDpsIdleState::ScriptSentNotifyL(TBool /*aReply*/)
|
|
41 |
{
|
49
|
42 |
OstTraceFunctionEntry0( TDPSIDLESTATE_SCRIPTSENTNOTIFYL_ENTRY );
|
|
43 |
OstTraceFunctionExit0( TDPSIDLESTATE_SCRIPTSENTNOTIFYL_EXIT );
|
29
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
void TDpsIdleState::ScriptReceivedNotifyL(TBool aReply)
|
|
51 |
{
|
|
52 |
if (!aReply)
|
|
53 |
{
|
49
|
54 |
OstTrace0( TRACE_NORMAL, TDPSIDLESTATE_SCRIPTRECEIVEDNOTIFYL, "request got" );
|
29
|
55 |
iStateMachine->Trader()->ParseScriptL(aReply);
|
|
56 |
iStateMachine->SetState(iStateMachine->SendingRepState());
|
|
57 |
}
|
|
58 |
else
|
|
59 |
{
|
49
|
60 |
OstTrace0( TRACE_NORMAL, DUP1_TDPSIDLESTATE_SCRIPTRECEIVEDNOTIFYL, "should not get reply!!!" );
|
29
|
61 |
}
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
void TDpsIdleState::Error(TInt aErr)
|
|
69 |
{
|
49
|
70 |
OstTrace1( TRACE_NORMAL, TDPSIDLESTATE_ERROR, "Error %d", aErr );
|
29
|
71 |
if ((aErr != KErrCancel) && (aErr != KErrNotReady))
|
|
72 |
{
|
|
73 |
iStateMachine->Trader()->HandleHostRequestError(aErr);
|
|
74 |
iStateMachine->SetState(iStateMachine->SendingRepState());
|
|
75 |
}
|
|
76 |
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
TDpsSendingReqState::TDpsSendingReqState(CDpsStateMachine* aStateMachine) :
|
|
84 |
iStateMachine(aStateMachine) {}
|
|
85 |
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void TDpsSendingReqState::ScriptSentNotifyL(TBool aReply)
|
|
91 |
{
|
|
92 |
if (!aReply)
|
|
93 |
{
|
49
|
94 |
OstTrace0( TRACE_NORMAL, TDPSSENDINGREQSTATE_SCRIPTSENTNOTIFYL, " request" );
|
29
|
95 |
iStateMachine->SetState(iStateMachine->WaitingRepState());
|
|
96 |
}
|
|
97 |
else
|
|
98 |
{
|
49
|
99 |
OstTrace0( TRACE_NORMAL, DUP1_TDPSSENDINGREQSTATE_SCRIPTSENTNOTIFYL, " should not get reply!!" );
|
29
|
100 |
}
|
|
101 |
}
|
|
102 |
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
// ---------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
void TDpsSendingReqState::ScriptReceivedNotifyL(TBool /*aReply*/)
|
|
108 |
{
|
49
|
109 |
OstTrace0( TRACE_NORMAL, TDPSSENDINGREQSTATE_SCRIPTRECEIVEDNOTIFYL, "**should not reply to the request/reply from host" );
|
29
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
void TDpsSendingReqState::Error(TInt aErr)
|
|
117 |
{
|
|
118 |
User::RequestComplete(iStateMachine->DpsEngine()->OperationRequest(),
|
|
119 |
aErr);
|
|
120 |
iStateMachine->Initialize();
|
|
121 |
return;
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
TDpsWaitingRepState::TDpsWaitingRepState(CDpsStateMachine* aStateMachine) :
|
|
129 |
iStateMachine(aStateMachine) {}
|
|
130 |
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
void TDpsWaitingRepState::ScriptSentNotifyL(TBool /*aReply*/)
|
|
137 |
{
|
49
|
138 |
OstTraceFunctionEntry0( TDPSWAITINGREPSTATE_SCRIPTSENTNOTIFYL_ENTRY );
|
|
139 |
OstTraceFunctionExit0( TDPSWAITINGREPSTATE_SCRIPTSENTNOTIFYL_EXIT );
|
29
|
140 |
}
|
|
141 |
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void TDpsWaitingRepState::ScriptReceivedNotifyL(TBool aReply)
|
|
147 |
{
|
|
148 |
if (aReply)
|
|
149 |
{
|
49
|
150 |
OstTrace0( TRACE_NORMAL, TDPSWAITINGREPSTATE_SCRIPTRECEIVEDNOTIFYL, "WaitingRepState reply" );
|
|
151 |
|
29
|
152 |
iStateMachine->Trader()->ParseScriptL(aReply);
|
|
153 |
User::RequestComplete(
|
|
154 |
iStateMachine->DpsEngine()->OperationRequest(), KErrNone);
|
|
155 |
iStateMachine->Initialize();
|
|
156 |
}
|
|
157 |
else
|
|
158 |
{
|
49
|
159 |
OstTrace0( TRACE_NORMAL, DUP1_TDPSWAITINGREPSTATE_SCRIPTRECEIVEDNOTIFYL, "WaitingRepState should not get request" );
|
29
|
160 |
// collision happened, we do nothing because the host will
|
|
161 |
// eventually handle this by sending the correct response. but we need
|
|
162 |
// to subscribe for the event again.
|
|
163 |
iStateMachine->ScriptReceiver()->WaitForReceive();
|
|
164 |
}
|
|
165 |
}
|
|
166 |
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
void TDpsWaitingRepState::Error(TInt aErr)
|
|
172 |
{
|
|
173 |
// this is not tested
|
|
174 |
User::RequestComplete(iStateMachine->DpsEngine()->OperationRequest(),
|
|
175 |
aErr);
|
|
176 |
iStateMachine->Initialize();
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
TDpsSendingRepState::TDpsSendingRepState(CDpsStateMachine* aStateMachine) :
|
|
184 |
iStateMachine(aStateMachine) {}
|
|
185 |
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
void TDpsSendingRepState::ScriptSentNotifyL(TBool aReply)
|
|
191 |
{
|
|
192 |
if (aReply)
|
|
193 |
{
|
49
|
194 |
OstTrace0( TRACE_NORMAL, TDPSSENDINGREPSTATE_SCRIPTSENTNOTIFYL, "reply" );
|
29
|
195 |
if (KErrNone == iStateMachine->CurError())
|
|
196 |
{
|
|
197 |
// this is the normal situation, inform the client
|
|
198 |
User::RequestComplete(iStateMachine->DpsEngine()->EventRequest(),
|
|
199 |
KErrNone);
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
// this is the error situation, do not inform the client. and
|
|
204 |
// we need to subscribe for the new event.
|
|
205 |
iStateMachine->ScriptReceiver()->WaitForReceive();
|
|
206 |
}
|
|
207 |
iStateMachine->Initialize();
|
|
208 |
}
|
|
209 |
else
|
|
210 |
{
|
49
|
211 |
OstTrace0( TRACE_NORMAL, DUP1_TDPSSENDINGREPSTATE_SCRIPTSENTNOTIFYL, "shoul not get request!!!" );
|
29
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
void TDpsSendingRepState::ScriptReceivedNotifyL(TBool /*aReply*/)
|
|
220 |
{
|
49
|
221 |
OstTraceFunctionEntry0( TDPSSENDINGREPSTATE_SCRIPTRECEIVEDNOTIFYL_ENTRY );
|
|
222 |
OstTraceFunctionExit0( TDPSSENDINGREPSTATE_SCRIPTRECEIVEDNOTIFYL_EXIT );
|
29
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
void TDpsSendingRepState::Error(TInt /*aErr*/)
|
|
230 |
{
|
|
231 |
return;
|
|
232 |
}
|