|
1 /* |
|
2 * Copyright (c) 2005 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: Base class for event contexts. Contains methods for |
|
15 * creating the state array and controlling current state. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef CMCEEVENTCONTEXT_H |
|
24 #define CMCEEVENTCONTEXT_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include "mcecomeventconstants.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CMceComEvent; |
|
32 class CMceEventStateBase; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Base class for event contexts. |
|
38 * |
|
39 * @lib |
|
40 * @since |
|
41 */ |
|
42 class CMceEventContext : public CBase |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 */ |
|
49 |
|
50 static CMceEventContext* NewL( CMceComEvent& aEvent ); |
|
51 |
|
52 /** |
|
53 * Destructor. |
|
54 */ |
|
55 ~CMceEventContext(); |
|
56 |
|
57 public: // New functions |
|
58 |
|
59 /** |
|
60 * Sets the current state for the context. |
|
61 * @since Series 60 3.0 |
|
62 * @param aEvent The event owning this context. |
|
63 * @param aNewEventState Index of the new state in the state array. |
|
64 * @return KErrNone if successfull, system wide error code otherwise. |
|
65 */ |
|
66 void SetCurrentStateL( CMceComEvent& aEvent, |
|
67 TMceEventStateIndex aNewEventState ); |
|
68 |
|
69 /** |
|
70 * Returns the current state of the context |
|
71 * @since Series 60 3.0 |
|
72 * @param None. |
|
73 * @return TMceEventStateIndex the current state, index to it. |
|
74 */ |
|
75 TMceEventStateIndex CurrentState(); |
|
76 |
|
77 /** |
|
78 * Applies the current state of the context for the client actions. |
|
79 * This causes a state transition to next state of the state machine. |
|
80 * The current state sets the next state. Leaves on error |
|
81 * @since Series 60 3.0 |
|
82 * @param aEvent The event this context belongs to. |
|
83 * @return None |
|
84 */ |
|
85 void ProcessEventL( CMceComEvent& aEvent ); |
|
86 |
|
87 /** |
|
88 * Applies the current state of the context for the received request. |
|
89 * This causes a state transition to next state of the state machine. |
|
90 * The current state sets the next state. Leaves on error. |
|
91 * @since Series 60 3.0 |
|
92 * @param aEvent The event this context belongs to. |
|
93 * @return None |
|
94 */ |
|
95 void ProcessRequestReceivedEventL(CMceComEvent& aEvent ); |
|
96 |
|
97 /** |
|
98 * Applies the current state of the context for the incoming response. |
|
99 * This causes a state transition to next state of the state machine. |
|
100 * The current state sets the next state. Leaves on error |
|
101 * @since Series 60 3.0 |
|
102 * @param aEvent The event this context belongs to. |
|
103 * @return None |
|
104 */ |
|
105 void ProcessIncomingResponseEventL( CMceComEvent& aEvent ); |
|
106 |
|
107 public: // Functions from base classes |
|
108 |
|
109 protected: // New functions |
|
110 |
|
111 /** |
|
112 * Creates the states belonging to this context |
|
113 * @since Series 60 3.0 |
|
114 * @param None |
|
115 * @return None |
|
116 */ |
|
117 void InitializeStateArrayL( CMceComEvent& aEvent ); |
|
118 |
|
119 /** |
|
120 * Checks if a state transition to a given state is accepted. |
|
121 * @since Series 60 3.0 |
|
122 * @param TMceEventStateIndex aStateIndex |
|
123 * @return TBool, boolean value, is the transition valid. |
|
124 */ |
|
125 TBool IsStateTransitionAccepted( TMceEventStateIndex aNewState ); |
|
126 |
|
127 /** |
|
128 * C++ default constructor. |
|
129 */ |
|
130 CMceEventContext(); |
|
131 |
|
132 /** |
|
133 * By default Symbian 2nd phase constructor is private. |
|
134 * Now it is protected. |
|
135 */ |
|
136 void ConstructL( CMceComEvent& aEvent ); |
|
137 |
|
138 TBool IsMoStateTransitionAccepted( TMceEventStateIndex aNewState ); |
|
139 |
|
140 TBool IsMtStateTransitionAccepted( TMceEventStateIndex aNewState ); |
|
141 |
|
142 private: |
|
143 |
|
144 void InitialSubscribeCommonStatesL(); |
|
145 |
|
146 void InitialReferCommonStatesL(); |
|
147 |
|
148 protected: // Data |
|
149 |
|
150 // State array |
|
151 RPointerArray< CMceEventStateBase >* iStates; |
|
152 |
|
153 private: // Data |
|
154 |
|
155 // Current state |
|
156 CMceEventStateBase* iCurrentState; |
|
157 |
|
158 // For testing |
|
159 friend class CMceSipEvent; |
|
160 friend class UT_CMceEventContext; |
|
161 friend class UT_CMceEventReferMtEstablishedState; |
|
162 |
|
163 }; |
|
164 |
|
165 #endif // CMCEEVENTCONTEXT_H |
|
166 |
|
167 // End of File |