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