|
1 /* |
|
2 * Copyright (c) 2002-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: Handles all the Ussd sessions. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPHSRVUSSDMANAGER_H |
|
19 #define CPHSRVUSSDMANAGER_H |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include <etelmm.h> // ETel |
|
24 #include "PhCltClientServer.h" |
|
25 #include "MPhSrvUssdNetworkObserver.h" |
|
26 #include "MPhSrvUssdReplyTimerObserver.h" |
|
27 #include <badesca.h> |
|
28 |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class RFs; |
|
32 class CPhSrvResourceManager; |
|
33 class CPhSrvUssdSendHandler; |
|
34 class CPhSrvUssdReceiveHandler; |
|
35 class CPhSrvUssdReplyTimer; |
|
36 class MPhSrvPhoneInterface; |
|
37 class MPhSrvUssdMessageSentObserver; |
|
38 class CAknGlobalMsgQuery; |
|
39 class CPhSrvUssdSessionCancelWaiter; |
|
40 class CPhSrvUssdNotifyNWRelease; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * Handles all the Ussd sessions. |
|
46 * |
|
47 * @since 1.0 |
|
48 */ |
|
49 class CPhSrvUssdManager : |
|
50 public CActive, |
|
51 public MPhSrvUssdNetworkObserver, |
|
52 public MPhSrvUssdReplyTimerObserver |
|
53 { |
|
54 public: // Constructors and destructor |
|
55 |
|
56 /** |
|
57 * C++ constructor. |
|
58 * |
|
59 * @param aFsSession The file session. |
|
60 * @param aResourceManager The resource manager. |
|
61 */ |
|
62 CPhSrvUssdManager( |
|
63 RFs& aFsSession, |
|
64 CPhSrvResourceManager& aResourceManager |
|
65 ); |
|
66 |
|
67 /** |
|
68 * C++ destructor. |
|
69 */ |
|
70 ~CPhSrvUssdManager(); |
|
71 |
|
72 /** |
|
73 * Symbian OS second phase constructor |
|
74 * |
|
75 * @param aPhoneInterface The phone interfaces. |
|
76 */ |
|
77 void ConstructL( MPhSrvPhoneInterface& aPhoneInterface ); |
|
78 |
|
79 |
|
80 public: // New functions |
|
81 |
|
82 /** |
|
83 * Send the USSD message. |
|
84 * |
|
85 * @param aMsgData The USSD message to be sent. |
|
86 * @param aMsgAttribute The USSD message attributes. |
|
87 * @param aObserver Observer for sent event. |
|
88 */ |
|
89 void SendUssdL( |
|
90 const TDesC8& aMsgData, |
|
91 RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute, |
|
92 MPhSrvUssdMessageSentObserver& aObserver ); |
|
93 |
|
94 /** |
|
95 * Cancel sending the USSD. |
|
96 */ |
|
97 void SendUssdCancel(); |
|
98 |
|
99 |
|
100 /** |
|
101 * These are called when status of Ussd application changes. |
|
102 * |
|
103 * @return 0 if editor should not be cleared. |
|
104 */ |
|
105 void InformUssdApplicationStarting(); |
|
106 void InformUssdApplicationTerminatingL( const RMessage2& aMessage ); |
|
107 TInt InformUssdApplicationToForeground(); |
|
108 void InformUssdApplicationToBackground(); |
|
109 |
|
110 /** |
|
111 * Starts the editor. |
|
112 */ |
|
113 void RequestStartEditingL(); |
|
114 |
|
115 /** |
|
116 * SAT starts. |
|
117 * |
|
118 * @param aSatMessage Message to be comleted when session ends. |
|
119 */ |
|
120 void InformStartSAT( const RMessage2& aSatMessage ); |
|
121 |
|
122 /** |
|
123 * SAT ends. |
|
124 */ |
|
125 void InformStopSAT(); |
|
126 |
|
127 /** |
|
128 * Completes SAT request if it's ongoing. |
|
129 * |
|
130 * @param aReceiveString If session end with a string it is passed |
|
131 * as a paramter. |
|
132 * @param aError Completion code. |
|
133 * @return The error code of the SAT request. |
|
134 */ |
|
135 void CompleteSatL( |
|
136 TDesC* aReceiveString, |
|
137 TInt aError ); |
|
138 |
|
139 protected: // From base classes |
|
140 |
|
141 /** |
|
142 * @see MPhSrvUssdNetworkObserver |
|
143 */ |
|
144 void UssdNetworkObserverHandleSendEventL( TInt aError ); |
|
145 |
|
146 /** |
|
147 * @see MPhSrvUssdNetworkObserver |
|
148 */ |
|
149 void UssdNetworkObserverHandleReceivedEventL( |
|
150 const TDes8& aMsgData, |
|
151 const RMobileUssdMessaging::TMobileUssdAttributesV1& |
|
152 aMsgAttributes, |
|
153 TInt aError ); |
|
154 |
|
155 void UssdNetworkObserverHandleNotifyNWReleaseL( |
|
156 const RMobilePhone::TMobilePhoneSendSSRequestV3 & aReturnResult, |
|
157 TInt aError ); |
|
158 |
|
159 /** |
|
160 * @see MPhSrvUssdReplyTimerObserver |
|
161 */ |
|
162 void UssdReplyTimerObserverHandleExpiredL( TInt aError ); |
|
163 |
|
164 /* |
|
165 * @see CActive |
|
166 */ |
|
167 void RunL(); |
|
168 |
|
169 /* |
|
170 * @see CActive |
|
171 */ |
|
172 void DoCancel(); |
|
173 |
|
174 /* |
|
175 * @see CActive |
|
176 */ |
|
177 TInt RunError( TInt aError ); |
|
178 |
|
179 |
|
180 |
|
181 private: // New functions |
|
182 |
|
183 CPhSrvUssdSendHandler& SendHandlerL(); |
|
184 |
|
185 void ShowErrorNoteL( TInt aError ); |
|
186 |
|
187 void DecodeL( |
|
188 const TDesC8& aSrc, |
|
189 TDes& aDes, |
|
190 TUint8 aDcs ); |
|
191 |
|
192 void FindFirstCarriageReturnL( |
|
193 const TDesC8& aBuffer , |
|
194 TUint& aSkipChars , |
|
195 TUint& aStartBit ); |
|
196 |
|
197 /** Display the "Done" note */ |
|
198 void ShowDoneNoteL(); |
|
199 |
|
200 /** Check is the ussd app running |
|
201 * @return app running or not |
|
202 */ |
|
203 TBool UssdAppTaskExistsL(); |
|
204 |
|
205 // If the notification array is empty, close the session. |
|
206 void TryCloseSession(); |
|
207 |
|
208 // Close the session; clear state etc. |
|
209 void CloseSession(); |
|
210 |
|
211 /** Second stage handler for received messages |
|
212 */ |
|
213 void UssdHandleReceivedEventL( |
|
214 const TDes8& aMsgData, |
|
215 const RMobileUssdMessaging::TMobileUssdAttributesV1& |
|
216 aMsgAttributes); |
|
217 // Restart the reply timer |
|
218 void RestartReplyTimerL(); |
|
219 |
|
220 /** Is the reply timer up and running? */ |
|
221 TBool NetworkWaitingForAnAnswer(); |
|
222 |
|
223 // Set timer and activate it if there are notifications available |
|
224 void SetActiveIfPendingNotificationsExist(); |
|
225 |
|
226 // Launch the global message query (used from RunL) |
|
227 void LaunchGlobalMessageQueryL(); |
|
228 |
|
229 // Send an MO ACK message if any such are pending |
|
230 void ProcessMoAcksL(); |
|
231 |
|
232 // Trigger an asynchronous call to call ProcessMoAcksL later |
|
233 void AsyncProcessMoAcks(); |
|
234 |
|
235 // The static callback function for AsyncProcessMoAcks |
|
236 static TInt MoAckCallback(TAny *); |
|
237 |
|
238 /** |
|
239 * Return boolean value that states whether or not |
|
240 * indicated feature is supported or not. |
|
241 * |
|
242 * @since 2.1 |
|
243 * @param aFeatureId The feature that is inspected |
|
244 * (see values from Telephony_Variant.hrh) |
|
245 * @return ETrue if the feature is supported, EFalse otherwise. |
|
246 */ |
|
247 TBool IsTelephonyFeatureSupported( const TInt aFeatureId ); |
|
248 |
|
249 /** |
|
250 * Play USSD tone. |
|
251 * |
|
252 * @since 2.1 |
|
253 * @return KErrNone if successful, otherwise Symbian error code. |
|
254 */ |
|
255 TInt PlayUssdTone(); |
|
256 |
|
257 /** |
|
258 * Returns telephony variant read-only data. |
|
259 * |
|
260 * @since 2.1 |
|
261 * @return Error code. |
|
262 */ |
|
263 TInt GetTelephonyVariantData(); |
|
264 |
|
265 /** |
|
266 * Send the MO acknowledgement. |
|
267 * |
|
268 * @since 2.6 |
|
269 */ |
|
270 void SendMoAcknowledgementL(); |
|
271 |
|
272 /** |
|
273 * Return boolean value that states whether notes are shown or not |
|
274 * |
|
275 * @since 3.0 |
|
276 */ |
|
277 TBool ShowNotesL(); |
|
278 |
|
279 /** |
|
280 * Check notify message array |
|
281 * |
|
282 * @since 3.1 |
|
283 */ |
|
284 void CheckArray( ); |
|
285 |
|
286 /** |
|
287 * Clears notify message array |
|
288 * |
|
289 * @since 3.1 |
|
290 */ |
|
291 void ClearArrayL(); |
|
292 |
|
293 /** |
|
294 * Returns notify message count |
|
295 * |
|
296 * @since 3.1 |
|
297 */ |
|
298 TInt NotifyCount(); |
|
299 |
|
300 |
|
301 /** |
|
302 * Updates Notify Message |
|
303 * |
|
304 * @since 3.1 |
|
305 */ |
|
306 void UpdateNotifyMessage(); |
|
307 |
|
308 /** |
|
309 * Turn lights on |
|
310 * |
|
311 * @since 3.1 |
|
312 */ |
|
313 void TurnLightsOn(); |
|
314 |
|
315 private: // Data |
|
316 |
|
317 // The file session reference. |
|
318 RFs& iFsSession; |
|
319 |
|
320 // The resource manager reference. |
|
321 CPhSrvResourceManager& iResourceManager; |
|
322 |
|
323 // The USSD functionality in lower level (TSY). |
|
324 RMobileUssdMessaging iMobileUssdMessaging; |
|
325 |
|
326 // The observer waiting message sent notification. |
|
327 MPhSrvUssdMessageSentObserver* iObserver; |
|
328 |
|
329 // The send operation handler. |
|
330 CPhSrvUssdSendHandler* iUssdSendHandler; |
|
331 |
|
332 // The receive operation handler. |
|
333 CPhSrvUssdReceiveHandler* iUssdReceiveHandler; |
|
334 |
|
335 // The network release notifier. |
|
336 CPhSrvUssdNotifyNWRelease* iUssdNotifyNWRelease; |
|
337 |
|
338 // The reply timer. |
|
339 CPhSrvUssdReplyTimer* iUssdReplyTimer; |
|
340 |
|
341 // The buffer for received message. |
|
342 TBuf< KPhCltUssdMax8BitCharacters > iReceivedMessage; |
|
343 |
|
344 // The message query for showing USSD operation queries. |
|
345 CAknGlobalMsgQuery* iGlobalMsgQuery; |
|
346 |
|
347 // Is editor emptied. |
|
348 TBool iEmptyEditor; |
|
349 |
|
350 // Will the editor be started. |
|
351 TBool iStartEditor; |
|
352 |
|
353 // The timer. |
|
354 RTimer iTimer; |
|
355 |
|
356 // Is there pending SAT message. |
|
357 TBool iHavePendingSatMessagePointer; |
|
358 |
|
359 // The pending SAT message. |
|
360 RMessage2 iPendingSatMessagePointer; |
|
361 |
|
362 // Reference to phone interfaces. |
|
363 MPhSrvPhoneInterface* iPhoneInterface; |
|
364 |
|
365 // The used DCS in the SAT message |
|
366 TUint iDCS; |
|
367 |
|
368 // Softkeys in Global MessageQuery. |
|
369 TInt iSoftkeys; |
|
370 |
|
371 // Global MessageQuery launching indicator. |
|
372 TBool iLaunchGMQ; |
|
373 |
|
374 // Local Telephony variant read-only data. |
|
375 TInt iVariantReadOnlyValues; |
|
376 |
|
377 // The message query header text. |
|
378 HBufC* iMeQuHeaderText; |
|
379 |
|
380 // The buffer for received decoded message. |
|
381 TBuf< KPhCltUssdMax8BitCharacters > iDecodedMessage; |
|
382 |
|
383 // If ETrue, then the last received USSD message was EUssdMtNotify. |
|
384 TBool iNotifyMessage; |
|
385 |
|
386 //NotifyNetWorkRelease return result |
|
387 RMobilePhone::TMobilePhoneSendSSRequestV3 iReturnResult; |
|
388 |
|
389 //NotifyNetWorkRelease return result |
|
390 RMobilePhone::TMobilePhoneSendSSRequestV3Pckg iReturnResultPckg; |
|
391 |
|
392 // Array for notify messages |
|
393 CDesCArray* iNotifyArray; |
|
394 |
|
395 //Sending Release status |
|
396 TBool iSendRelease; |
|
397 |
|
398 // Notify array reset status |
|
399 TBool iClearArray; |
|
400 |
|
401 // Sat cancel status |
|
402 TBool iSatCanceled; |
|
403 |
|
404 // Show Done note |
|
405 TBool iShowDone; |
|
406 |
|
407 // Checks if received message type is Reply |
|
408 TBool iMsgTypeReply; |
|
409 |
|
410 // Has the transaction been closed or not |
|
411 TBool iNetworkReleased; |
|
412 |
|
413 // Is the current send operation an MO ACK message or not |
|
414 TBool iSendingAck; |
|
415 |
|
416 // Number of MO ACK messages pending to be sent. Normally max 2. |
|
417 TInt iAcksToBeSent; |
|
418 |
|
419 // An asynchronous callback for sending MO ACK messages |
|
420 CAsyncCallBack* iMoAckCallback; |
|
421 }; |
|
422 |
|
423 #endif // CPHSRVUSSDMANAGER_H |
|
424 |
|
425 |
|
426 // End of File |