1 /* |
|
2 * Copyright (c) 2004 - 2006 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: Class for initializing the engine gradually. |
|
15 * Active object initializes one "subsystem" on each |
|
16 * round. In case of failure timer is started and |
|
17 * retrial is done after time-out. Uninitialization |
|
18 * is done is one shot. |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CVTENGINITIALIZER_H |
|
25 #define CVTENGINITIALIZER_H |
|
26 |
|
27 // INCLUDES |
|
28 #include "MVtEngSettingObserver.h" |
|
29 #include <e32base.h> |
|
30 #include <mvtprotocolhandler.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CVtEngHandlerContainer; |
|
34 class CVtEngOperation; |
|
35 |
|
36 |
|
37 /** |
|
38 * Engine initializer. |
|
39 * |
|
40 * @lib videoteleng |
|
41 * @since 2.6 |
|
42 */ |
|
43 NONSHARABLE_CLASS( CVtEngInitializer ) : |
|
44 public CActive, |
|
45 public MVtEngSettingObserver |
|
46 { |
|
47 public: // Constructors and destructor |
|
48 |
|
49 static CVtEngInitializer* NewL( CVtEngHandlerContainer& aHandlers ); |
|
50 |
|
51 /** |
|
52 * Destructor. |
|
53 */ |
|
54 virtual ~CVtEngInitializer(); |
|
55 |
|
56 public: // new functions |
|
57 |
|
58 /** |
|
59 * Starts initialization process. |
|
60 */ |
|
61 void InitializeL( CVtEngOperation& aCallback ); |
|
62 |
|
63 /** |
|
64 * Cancels initialiation |
|
65 * @return ETrue if CActive::Cancel was called |
|
66 */ |
|
67 TBool CancelInit(); |
|
68 |
|
69 /** |
|
70 * Uninitializes engine. |
|
71 */ |
|
72 void Uninitialize( CVtEngOperation& aCallback ); |
|
73 |
|
74 /** |
|
75 * Gets GetSessionCommand ownership after initialization. |
|
76 * @return CSessionCommand interface. |
|
77 */ |
|
78 MVtSessionCommand* GetSessionCommand(); |
|
79 |
|
80 /** |
|
81 * Returns if engine is initialized. |
|
82 * @return ETrue if initialized |
|
83 */ |
|
84 TBool Initialized() const; |
|
85 |
|
86 /** |
|
87 * Creates handler for DTMF sending. |
|
88 * @param aH324Config H324 configure interface |
|
89 */ |
|
90 void CreateDtmfHandlerL( MVtH324ConfigCommand* aH324Config ); |
|
91 |
|
92 /** |
|
93 * Gets pointer to comms. Still owns the comms. |
|
94 * @return Pointer to comms. |
|
95 */ |
|
96 MCommServer* GetVtComms(); |
|
97 |
|
98 private: // from CActive |
|
99 |
|
100 /** |
|
101 * performs one initialization step. |
|
102 */ |
|
103 void RunL(); |
|
104 |
|
105 /** |
|
106 * Cancels initialization process. |
|
107 */ |
|
108 void DoCancel(); |
|
109 |
|
110 /** |
|
111 * Handles error in the process. |
|
112 * @return always returns KErrNone |
|
113 */ |
|
114 TInt RunError( TInt aError ); |
|
115 |
|
116 public: // from MVtEngSettingObserver |
|
117 virtual void HandleSettingChangedL( |
|
118 CVtEngSettings::TSettingId aId, |
|
119 const TDesC& aValue ); |
|
120 |
|
121 |
|
122 private: // Constructors |
|
123 |
|
124 /** |
|
125 * c++ constructor |
|
126 */ |
|
127 CVtEngInitializer( CVtEngHandlerContainer& aHandlers ); |
|
128 |
|
129 /** |
|
130 * |
|
131 */ |
|
132 void ConstructL(); |
|
133 |
|
134 private: |
|
135 |
|
136 enum TProcess |
|
137 { |
|
138 // Go to next step |
|
139 EContinue, |
|
140 // Reset engine |
|
141 EReset, |
|
142 // Retry current step when failed. |
|
143 ERetry |
|
144 }; |
|
145 |
|
146 private: // new functions |
|
147 |
|
148 /** |
|
149 * Reads bit reversal information from locally variated flags. |
|
150 * @return ETrue if reversed. |
|
151 */ |
|
152 TBool BitReversalUsed(); |
|
153 |
|
154 /** |
|
155 * Proceeds to next step or starts retrial of |
|
156 * previously failed step. |
|
157 */ |
|
158 void ContinueOrRetry( const TProcess aOperation ); |
|
159 |
|
160 /** |
|
161 * Notifies observer on initialization completion. |
|
162 */ |
|
163 void Notify( const TInt aResult ); |
|
164 |
|
165 /** |
|
166 * Callback for retrial timer. |
|
167 */ |
|
168 static TInt HandleTimer( TAny* aAny ); |
|
169 |
|
170 /** |
|
171 * Handles retrial timer expiration. |
|
172 */ |
|
173 void DoHandleTimer(); |
|
174 |
|
175 TBool ActivateAndSignal( TInt aSignalValue ); |
|
176 |
|
177 private: |
|
178 |
|
179 |
|
180 /** |
|
181 * Initialization steps |
|
182 */ |
|
183 enum TVtEngInitializationSteps |
|
184 { |
|
185 EInitNone, |
|
186 EInitSession, |
|
187 EInitMedia, |
|
188 EInitProto, |
|
189 EInitDataportCompleted, |
|
190 EInitComplete, |
|
191 EResetMedia, |
|
192 EResetMediaPhase2 |
|
193 }; |
|
194 |
|
195 /** |
|
196 * Dataport information handling flags. |
|
197 */ |
|
198 enum TVtEngDataportInformationFlags |
|
199 { |
|
200 EDataportListened = 0x01, |
|
201 EDataportReceived = 0x02 |
|
202 }; |
|
203 |
|
204 private: |
|
205 |
|
206 // handler container |
|
207 CVtEngHandlerContainer& iHandlers; |
|
208 |
|
209 // Current (un)initialization step |
|
210 TInt iStep; |
|
211 |
|
212 // Operation to be notified on completion |
|
213 CVtEngOperation* iCallback; |
|
214 |
|
215 // Retrial count |
|
216 TInt iRetrials; |
|
217 |
|
218 // Retrial timer |
|
219 CPeriodic* iTimer; |
|
220 |
|
221 // Protocol Session Engine |
|
222 MVtSessionCommand* iSessionCommand; |
|
223 |
|
224 // Protocol Comms Server |
|
225 MCommServer* iComms; |
|
226 |
|
227 // Has subscription been made for dataport name. |
|
228 TInt iDataportHandled; |
|
229 |
|
230 // If MediaHandler has taken ownership of 2-way, this is true, |
|
231 // otherwise false. |
|
232 TBool iOwnershipInMH; |
|
233 |
|
234 }; |
|
235 |
|
236 |
|
237 #endif // CVTENGINITIALIZER_H |
|
238 |
|
239 // End of File |
|