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