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: This class implements the dps state machine.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "dpsstatemachine.h"
|
|
20 |
#include "dpsscriptreceiver.h"
|
|
21 |
#include "dpsscriptsender.h"
|
|
22 |
#include "dpstransaction.h"
|
|
23 |
#include "dpsconst.h"
|
|
24 |
#include "pictbridge.h"
|
|
25 |
#include "dpsparam.h"
|
|
26 |
#include "dpsoperation.h"
|
49
|
27 |
#include "OstTraceDefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "dpsstatemachineTraces.h"
|
29
|
30 |
#endif
|
|
31 |
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CDpsStateMachine* CDpsStateMachine::NewL(CDpsEngine* aEngine)
|
|
37 |
{
|
|
38 |
CDpsStateMachine* self = new(ELeave) CDpsStateMachine(aEngine);
|
|
39 |
CleanupStack::PushL(self);
|
|
40 |
self->ConstructL();
|
|
41 |
CleanupStack::Pop();
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CDpsStateMachine::~CDpsStateMachine()
|
|
50 |
{
|
49
|
51 |
OstTraceFunctionEntry0( CDPSSTATEMACHINE_CDPSSTATEMACHINE_DES_ENTRY );
|
29
|
52 |
delete iTrader;
|
|
53 |
iTrader = NULL;
|
|
54 |
delete iScriptReceiver;
|
|
55 |
iScriptReceiver = NULL;
|
|
56 |
delete iScriptSender;
|
|
57 |
iScriptSender = NULL;
|
|
58 |
|
|
59 |
delete iIdleState; iIdleState = NULL;
|
|
60 |
delete iSendingReqState; iSendingReqState = NULL;
|
|
61 |
delete iWaitingRepState; iWaitingRepState = NULL;
|
|
62 |
delete iSendingRepState; iSendingRepState = NULL;
|
49
|
63 |
OstTraceFunctionExit0( CDPSSTATEMACHINE_CDPSSTATEMACHINE_DES_EXIT );
|
29
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CDpsStateMachine::CDpsStateMachine(CDpsEngine* aEngine) :
|
|
71 |
iEngine(aEngine),iOperation(EDpsOpEmpty), iEvent(EDpsEvtEmpty),
|
|
72 |
iCurError(KErrNone)
|
|
73 |
{
|
49
|
74 |
OstTraceFunctionEntry0( DUP1_CDPSSTATEMACHINE_CDPSSTATEMACHINE_CONS_ENTRY );
|
|
75 |
|
|
76 |
OstTraceFunctionExit0( DUP1_CDPSSTATEMACHINE_CDPSSTATEMACHINE_CONS_EXIT );
|
29
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void CDpsStateMachine::ConstructL()
|
|
84 |
{
|
49
|
85 |
OstTraceFunctionEntry0( CDPSSTATEMACHINE_CONSTRUCTL_ENTRY );
|
29
|
86 |
iIdleState = new(ELeave) TDpsIdleState(this);
|
|
87 |
iSendingReqState = new(ELeave) TDpsSendingReqState(this);
|
|
88 |
iWaitingRepState = new(ELeave) TDpsWaitingRepState(this);
|
|
89 |
iSendingRepState = new(ELeave) TDpsSendingRepState(this);
|
|
90 |
iCurState = iIdleState;
|
|
91 |
iTrader = CDpsTransaction::NewL(this);
|
|
92 |
iScriptReceiver = CDpsScriptReceiver::NewL(this);
|
|
93 |
iScriptSender = CDpsScriptSender::NewL(this);
|
49
|
94 |
OstTraceFunctionExit0( CDPSSTATEMACHINE_CONSTRUCTL_EXIT );
|
29
|
95 |
}
|
|
96 |
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
void CDpsStateMachine::StartTransactionL(TMDpsOperation* aRequest)
|
|
102 |
{
|
49
|
103 |
OstTraceFunctionEntry0( CDPSSTATEMACHINE_STARTTRANSACTIONL_ENTRY );
|
29
|
104 |
iMOperation = aRequest;
|
|
105 |
iOperation = (TDpsOperation)iMOperation->iOperation;
|
|
106 |
iTrader->CreateRequestL(aRequest);
|
|
107 |
iCurState = iSendingReqState;
|
49
|
108 |
OstTraceFunctionExit0( CDPSSTATEMACHINE_STARTTRANSACTIONL_EXIT );
|
29
|
109 |
}
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CDpsStateMachine::Initialize()
|
|
116 |
{
|
49
|
117 |
OstTraceFunctionEntry0( CDPSSTATEMACHINE_INITIALIZE_ENTRY );
|
29
|
118 |
iOperation = EDpsOpEmpty;
|
|
119 |
iEvent = EDpsEvtEmpty;
|
|
120 |
iCurError = KErrNone;
|
|
121 |
if (CurState() != IdleState())
|
|
122 |
{
|
|
123 |
SetState(IdleState());
|
49
|
124 |
}
|
|
125 |
OstTraceFunctionExit0( CDPSSTATEMACHINE_INITIALIZE_EXIT );
|
29
|
126 |
}
|