30
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
/**
|
|
17 |
@file
|
|
18 |
@internalTechnology
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include <elements/mm_states.h>
|
|
22 |
#include <ss_internal_activities.h>
|
|
23 |
|
|
24 |
#ifndef SYMBIAN_ACTIVITYTEST
|
|
25 |
#define SYMBIAN_ACTIVITYTEST
|
|
26 |
|
|
27 |
namespace CancelTestBindToActivity
|
|
28 |
{
|
|
29 |
DECLARE_NODEACTIVITY(CancelBindTo)
|
|
30 |
}
|
|
31 |
|
|
32 |
class CActivityCancelTest : public MeshMachine::CNodeRetryActivity
|
|
33 |
|
|
34 |
/**
|
|
35 |
@internalTechnology
|
|
36 |
*/
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
//TODO
|
|
40 |
enum {ECancelTestActivity = ESock::ECFActivityBuildStack };
|
|
41 |
static MeshMachine::CNodeActivityBase* NewL(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode)
|
|
42 |
{
|
|
43 |
CActivityCancelTest* self = new (ELeave) CActivityCancelTest(aActivitySig, aNode);
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
class TProgressiveMutex
|
|
48 |
{
|
|
49 |
public:
|
|
50 |
static TBool IsBlocked(MeshMachine::TNodeContextBase& aContext)
|
|
51 |
{
|
|
52 |
return static_cast<CActivityCancelTest&>(*aContext.iNodeActivity).ProgressiveMutex();
|
|
53 |
}
|
|
54 |
};
|
|
55 |
|
|
56 |
void NextLoop()
|
|
57 |
{
|
|
58 |
iMaxLoopCount++;
|
|
59 |
iCurrentLoopCount = 0;
|
|
60 |
}
|
|
61 |
|
|
62 |
TBool ProgressiveMutex()
|
|
63 |
{
|
|
64 |
return ++iCurrentLoopCount <= iMaxLoopCount;
|
|
65 |
}
|
|
66 |
|
|
67 |
protected:
|
|
68 |
CActivityCancelTest(const MeshMachine::TNodeActivity& aActivitySig, MeshMachine::AMMNodeBase& aNode)
|
|
69 |
: CNodeRetryActivity(aActivitySig, aNode)
|
|
70 |
{
|
|
71 |
}
|
|
72 |
|
|
73 |
void StoreRequestL(const Messages::TSignatureBase& aRequest);
|
|
74 |
const Messages::TSignatureBase& StoredRequest()
|
|
75 |
{
|
|
76 |
return *reinterpret_cast<const Messages::TSignatureBase*>(iStoredRequest.Ptr());
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
private:
|
|
81 |
TBuf8<__Align8(Messages::TSignalBase::KMaxInlineMessageSize + Messages::TSignalBase::KMaxUnstoredOverhead)> iStoredRequest;
|
|
82 |
TInt iMaxLoopCount;
|
|
83 |
TInt iCurrentLoopCount;
|
|
84 |
|
|
85 |
public:
|
|
86 |
typedef MeshMachine::TContext TContext;
|
|
87 |
|
|
88 |
template<typename TMESSAGE>
|
|
89 |
class TAwaitingMessageState : public MeshMachine::TState<TContext>
|
|
90 |
{
|
|
91 |
public:
|
|
92 |
NETSM_TPL_DECLARE_CTR(TAwaitingMessageState, NetStateMachine::MState, TContext)
|
|
93 |
|
|
94 |
explicit TAwaitingMessageState(TContext& aContext) :
|
|
95 |
MeshMachine::TState<TContext>(aContext) {}
|
|
96 |
|
|
97 |
virtual TBool Accept()
|
|
98 |
{
|
|
99 |
#ifdef __GCCXML__
|
|
100 |
return EFalse;
|
|
101 |
#else
|
|
102 |
if (Messages::address_cast<const Messages::TNodeCtxId>(iContext.iSender).NodeCtx() != CActivityCancelTest::ECancelTestActivity)
|
|
103 |
{
|
|
104 |
Messages::TNodeSignal& msg = this->iContext.iMessage; //Arm compiler is getting confused otherwise
|
|
105 |
return msg.IsMessage<TMESSAGE>();
|
|
106 |
}
|
|
107 |
#endif
|
|
108 |
return EFalse;
|
|
109 |
}
|
|
110 |
};
|
|
111 |
|
|
112 |
DECLARE_SMELEMENT_HEADER( TNoTagForwardOrActiveTagBackward, MeshMachine::TStateFork<TContext>, NetStateMachine::MStateFork, TContext )
|
|
113 |
virtual TInt TransitionTag();
|
|
114 |
DECLARE_SMELEMENT_FOOTER( TNoTagForwardOrActiveTagBackward )
|
|
115 |
|
|
116 |
DECLARE_SMELEMENT_HEADER( TBeginTest, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
|
|
117 |
virtual void DoL();
|
|
118 |
DECLARE_SMELEMENT_FOOTER( TBeginTest )
|
|
119 |
|
|
120 |
DECLARE_SMELEMENT_HEADER( TBeginLoop, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
|
|
121 |
virtual void DoL();
|
|
122 |
DECLARE_SMELEMENT_FOOTER( TBeginLoop )
|
|
123 |
|
|
124 |
DECLARE_SMELEMENT_HEADER( TCancel, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
|
|
125 |
virtual void DoL();
|
|
126 |
DECLARE_SMELEMENT_FOOTER( TCancel )
|
|
127 |
|
|
128 |
DECLARE_SMELEMENT_HEADER( TEndTest, MeshMachine::TStateTransition<TContext>, NetStateMachine::MStateTransition, TContext )
|
|
129 |
virtual void DoL();
|
|
130 |
DECLARE_SMELEMENT_FOOTER( TEndTest )
|
|
131 |
|
|
132 |
DECLARE_SERIALIZABLE_TRANSITION(
|
|
133 |
TProgressiveCancel,
|
|
134 |
TProgressiveMutex,
|
|
135 |
TCancel
|
|
136 |
)
|
|
137 |
};
|
|
138 |
|
|
139 |
|
|
140 |
#endif //SYMBIAN_ACTIVITYTEST
|
|
141 |
|
|
142 |
|