|
1 /* |
|
2 * Copyright (c) 2009 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: Implementation of CCDSYDOSServerRequestManager class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CDSYDOSServerRequestManager.h" |
|
21 #include "CDSYMessageBufferItem.h" |
|
22 #include "CDSYMessage.h" |
|
23 #include "CDSYController.h" |
|
24 #include "CDSYMessageIDs.h" |
|
25 #include "commondsy_debug.h" |
|
26 |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // CONSTANTS |
|
31 // MACROS |
|
32 // LOCAL CONSTANTS AND MACROS |
|
33 // MODULE DATA STRUCTURES |
|
34 // LOCAL FUNCTION PROTOTYPES |
|
35 // FORWARD DECLARATIONS |
|
36 |
|
37 |
|
38 // ============================= LOCAL FUNCTIONS =============================== |
|
39 |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CCDSYDOSServerRequestManager::CCDSYDOSServerRequestManager |
|
46 // ----------------------------------------------------------------------------- |
|
47 CCDSYDOSServerRequestManager::CCDSYDOSServerRequestManager( CCDSYController& aCDSYController ) |
|
48 : iCDSYController( aCDSYController ) |
|
49 , iLDSYFind( ETrue ) |
|
50 { |
|
51 COM_TRACE_1( "CDSY - CCDSYDOSServerRequestManager::CCDSYDOSServerRequestManager(0x%x)", &aCDSYController ); |
|
52 |
|
53 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::CCDSYDOSServerRequestManager - return void" ); |
|
54 } |
|
55 |
|
56 |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CCDSYDOSServerRequestManager::~CCDSYDOSServerRequestManager |
|
60 // ----------------------------------------------------------------------------- |
|
61 CCDSYDOSServerRequestManager::~CCDSYDOSServerRequestManager() |
|
62 { |
|
63 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::~CCDSYDOSServerRequestManager()" ); |
|
64 |
|
65 #ifndef RD_STARTUP_CHANGE |
|
66 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgGetStartupReasonReturn, this ); |
|
67 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgInitiateDSYStartupReturn, this ); |
|
68 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgExecuteSelfTestReturn, this ); |
|
69 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgGetSoftwareResetReasonReturn, this ); |
|
70 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgSetSoftwareResetReasonReturn, this ); |
|
71 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgIndicatePowerOnReturn, this ); |
|
72 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgSwitchOffPowerReturn, this ); |
|
73 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgGetSoftwareResetStatusReturn, this ); |
|
74 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgExecuteSoftwareResetReturn, this ); |
|
75 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgSendStartupSyncReturn, this ); |
|
76 |
|
77 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgExecuteDeepRfsReturn, this ); |
|
78 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgExecuteNormalRfsReturn, this ); |
|
79 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgCheckTimeValidityReturn, this ); |
|
80 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgSetWakeupAlarmReturn, this ); |
|
81 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgCancelWakeupAlarmReturn, this ); |
|
82 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgSendShutdownSyncReturn, this ); |
|
83 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgSetDomesticOSStatusReturn, this ); |
|
84 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgSetOfflineStatusReturn, this ); |
|
85 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgGetOfflineStatusReturn, this ); |
|
86 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgGetPreferredLanguageReturn, this ); |
|
87 |
|
88 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgGenerateGripEventReturn, this ); |
|
89 #endif //RD_STARTUP_CHANGE |
|
90 iCDSYController.UnregisterServiceLogic( KCDSYMsgGroup, KCDSYMsgInitializeExtensionReturn, this ); |
|
91 |
|
92 iMessages.ResetAndDestroy(); |
|
93 |
|
94 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::~CCDSYDOSServerRequestManager - return void" ); |
|
95 } |
|
96 |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CCDSYDOSServerRequestManager::ConstructL |
|
101 // ----------------------------------------------------------------------------- |
|
102 void CCDSYDOSServerRequestManager::ConstructL() |
|
103 { |
|
104 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::ConstructL()" ); |
|
105 |
|
106 #ifndef RD_STARTUP_CHANGE |
|
107 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgGetStartupReasonReturn, this ); |
|
108 |
|
109 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgInitiateDSYStartupReturn, this ); |
|
110 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgExecuteSelfTestReturn, this ); |
|
111 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgGetSoftwareResetReasonReturn, this ); |
|
112 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgSetSoftwareResetReasonReturn, this ); |
|
113 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgIndicatePowerOnReturn, this ); |
|
114 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgSwitchOffPowerReturn, this ); |
|
115 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgGetSoftwareResetStatusReturn, this ); |
|
116 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgExecuteSoftwareResetReturn, this ); |
|
117 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgSendStartupSyncReturn, this ); |
|
118 |
|
119 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgExecuteDeepRfsReturn, this ); |
|
120 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgExecuteNormalRfsReturn, this ); |
|
121 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgCheckTimeValidityReturn, this ); |
|
122 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgSetWakeupAlarmReturn, this ); |
|
123 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgCancelWakeupAlarmReturn, this ); |
|
124 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgSendShutdownSyncReturn, this ); |
|
125 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgSetDomesticOSStatusReturn, this ); |
|
126 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgSetOfflineStatusReturn, this ); |
|
127 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgGetOfflineStatusReturn, this ); |
|
128 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgGetPreferredLanguageReturn, this ); |
|
129 |
|
130 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgGenerateGripEventReturn, this ); |
|
131 |
|
132 #endif // RD_STARTUP_CHANGE |
|
133 iCDSYController.RegisterServiceLogicL( KCDSYMsgGroup, KCDSYMsgInitializeExtensionReturn, this ); |
|
134 |
|
135 |
|
136 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::ConstructL - return void" ); |
|
137 } |
|
138 |
|
139 |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CCDSYDOSServerRequestManager::NewL |
|
143 // ----------------------------------------------------------------------------- |
|
144 CCDSYDOSServerRequestManager* CCDSYDOSServerRequestManager::NewL( CCDSYController& aCDSYController ) |
|
145 { |
|
146 COM_TRACE_1( "CDSY - CCDSYDOSServerRequestManager::NewL(0x%x)", &aCDSYController ); |
|
147 |
|
148 CCDSYDOSServerRequestManager* requestManager = new ( ELeave ) CCDSYDOSServerRequestManager( aCDSYController ); |
|
149 CleanupStack::PushL( requestManager ); |
|
150 requestManager->ConstructL(); |
|
151 CleanupStack::Pop( requestManager ); |
|
152 |
|
153 COM_TRACE_1( "CDSY - CCDSYDOSServerRequestManager::NewL - return 0x%x", requestManager ); |
|
154 return requestManager; |
|
155 } |
|
156 |
|
157 |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CCDSYDOSServerRequestManager::ProcessMessageL |
|
161 // ----------------------------------------------------------------------------- |
|
162 void CCDSYDOSServerRequestManager::ProcessMessageL( TCDSYMessage& aCDSYMessage ) |
|
163 { |
|
164 COM_TRACE_1( "CDSY - CCDSYDOSServerRequestManager::ProcessMessageL(0x%x)", &aCDSYMessage ); |
|
165 |
|
166 TUint32 count = 0; |
|
167 TBool asyncMessage = EFalse; |
|
168 for ( TInt i = 0; i < iMessages.Count(); i++ ) |
|
169 { |
|
170 // Check the transaction ID's |
|
171 if ( ( iMessages[i] )->TransactionID() == aCDSYMessage.TransactionID() ) |
|
172 { |
|
173 // The asyncMessage check is performed before ProcessResponseL |
|
174 // is called because ProcessResponseL might clear the async flag |
|
175 asyncMessage = iMessages[i]->IsAsyncMessage(); |
|
176 ( iMessages[i] )->ProcessResponseL( aCDSYMessage ); |
|
177 count++; |
|
178 // Delete the message from the message list |
|
179 if ( asyncMessage ) |
|
180 { |
|
181 delete iMessages[i]; |
|
182 iMessages.Remove( i ); |
|
183 i--; |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 TRACE_ASSERT( count == 1 ); |
|
189 |
|
190 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::ProcessMessageL - return void" ); |
|
191 } |
|
192 |
|
193 |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CCDSYDOSServerRequestManager::SendMessageL |
|
197 // ----------------------------------------------------------------------------- |
|
198 void CCDSYDOSServerRequestManager::SendMessageL( TCDSYMessage& aCDSYMessage ) |
|
199 { |
|
200 COM_TRACE_1( "CDSY - CCDSYDOSServerRequestManager::SendMessageL(0x%x)", &aCDSYMessage ); |
|
201 |
|
202 aCDSYMessage.SetTransactionID( iCDSYController.GetNewTransactionID() ); |
|
203 CCDSYMessageBufferItem* messageBufferItem = CCDSYMessageBufferItem::NewL( iCDSYController, *this, aCDSYMessage ); |
|
204 |
|
205 TUint32 count = 0; |
|
206 |
|
207 #ifdef _DEBUG |
|
208 |
|
209 // Check that same transaction id is not in the buffer. |
|
210 for ( TInt j = 0; j < iMessages.Count(); j++ ) |
|
211 { |
|
212 if ( ( iMessages[j] )->TransactionID() == aCDSYMessage.TransactionID() ) |
|
213 { |
|
214 count++; |
|
215 TRACE_ASSERT( count == 0 ); |
|
216 } |
|
217 } |
|
218 |
|
219 #endif //#ifdef _DEBUG |
|
220 |
|
221 TInt err = iMessages.Append( messageBufferItem ); |
|
222 if ( err != KErrNone ) |
|
223 { |
|
224 TRACE_ASSERT_ALWAYS; |
|
225 delete messageBufferItem; |
|
226 User::Leave( err ); |
|
227 } |
|
228 |
|
229 TRAP( err, messageBufferItem->SendMessageL() ); |
|
230 |
|
231 count = 0; |
|
232 // Remove the message from the list. |
|
233 for ( TInt i = 0; i < iMessages.Count(); i++ ) |
|
234 { |
|
235 if ( ( iMessages[i] )->TransactionID() == aCDSYMessage.TransactionID() ) |
|
236 { |
|
237 delete iMessages[i]; |
|
238 iMessages.Remove( i ); |
|
239 i--; |
|
240 count++; |
|
241 } |
|
242 } |
|
243 TRACE_ASSERT( count <= 1 ); |
|
244 |
|
245 User::LeaveIfError( err ); |
|
246 |
|
247 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::SendMessageL - return void" ); |
|
248 } |
|
249 |
|
250 |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CCDSYDOSServerRequestManager::SendMessageL |
|
254 // ----------------------------------------------------------------------------- |
|
255 void CCDSYDOSServerRequestManager::SendMessageL( TCDSYMessage& aCDSYMessage, RMessagePtr2 aMessage ) |
|
256 { |
|
257 COM_TRACE_2( "CDSY - CCDSYDOSServerRequestManager::SendMessageL(0x%x, 0x%x)", &aCDSYMessage, &aMessage ); |
|
258 |
|
259 aCDSYMessage.SetTransactionID( iCDSYController.GetNewTransactionID() ); |
|
260 CCDSYMessageBufferItem* messageBufferItem = CCDSYMessageBufferItem::NewL( iCDSYController, *this, aCDSYMessage, aMessage ); |
|
261 |
|
262 TUint32 count = 0; |
|
263 |
|
264 #ifdef _DEBUG |
|
265 |
|
266 // Check that same transaction id is not in the buffer. |
|
267 for ( TInt j = 0; j < iMessages.Count(); j++ ) |
|
268 { |
|
269 if ( ( iMessages[j] )->TransactionID() == aCDSYMessage.TransactionID() ) |
|
270 { |
|
271 count++; |
|
272 TRACE_ASSERT( count == 0 ); |
|
273 } |
|
274 } |
|
275 |
|
276 #endif //#ifdef _DEBUG |
|
277 |
|
278 TInt err = iMessages.Append( messageBufferItem ); |
|
279 if ( err != KErrNone ) |
|
280 { |
|
281 TRACE_ASSERT_ALWAYS; |
|
282 delete messageBufferItem; |
|
283 User::Leave( err ); |
|
284 } |
|
285 |
|
286 |
|
287 TRAP( err, messageBufferItem->SendMessageL() ); |
|
288 |
|
289 if ( err != KErrNone ) |
|
290 { |
|
291 // Remove the message from the list. |
|
292 count = 0; |
|
293 for ( TInt i = 0; i < iMessages.Count(); i++ ) |
|
294 { |
|
295 if ( ( iMessages[i] )->TransactionID() == aCDSYMessage.TransactionID() ) |
|
296 { |
|
297 delete iMessages[i]; |
|
298 iMessages.Remove( i ); |
|
299 i--; |
|
300 count++; |
|
301 } |
|
302 } |
|
303 TRACE_ASSERT( count <= 1 ); |
|
304 } |
|
305 |
|
306 User::LeaveIfError( err ); |
|
307 |
|
308 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::SendMessageL - return void" ); |
|
309 } |
|
310 |
|
311 |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CCDSYDOSServerRequestManager::Cancel |
|
315 // ----------------------------------------------------------------------------- |
|
316 void CCDSYDOSServerRequestManager::Cancel( TUint32 aTransactionID, TInt aReason ) |
|
317 { |
|
318 COM_TRACE_2( "CDSY - CCDSYDOSServerRequestManager::Cancel(0x%x, 0x%x)", aTransactionID, aReason ); |
|
319 |
|
320 for ( TInt i = 0; i < iMessages.Count(); i++ ) |
|
321 { |
|
322 if ( ( iMessages[i] )->TransactionID() == aTransactionID ) |
|
323 { |
|
324 iMessages[i]->CancelAsyncCommand( aReason ); |
|
325 delete iMessages[i]; |
|
326 iMessages.Remove( i ); |
|
327 i = iMessages.Count(); |
|
328 } |
|
329 } |
|
330 |
|
331 COM_TRACE_( "CDSY - CCDSYDOSServerRequestManager::Cancel - return void" ); |
|
332 } |
|
333 |
|
334 |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CCDSYDOSServerRequestManager::ExpireMessageL |
|
338 // ----------------------------------------------------------------------------- |
|
339 void CCDSYDOSServerRequestManager::ExpireMessageL( TCDSYMessage& /*aCDSYMessage*/ ) |
|
340 { |
|
341 } |
|
342 |