24
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Name : CSatNotifyPlayTone.cpp
|
|
15 |
// Part of : Common SIM ATK TSY / commonsimatktsy
|
|
16 |
// PlayTone notification functionality of Sat Tsy
|
|
17 |
// Version : 1.0
|
|
18 |
//
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
//INCLUDES
|
|
23 |
#include <satcs.h> // Etel SAT IPC definitions
|
|
24 |
#include "CSatTsy.h" // Tsy class header
|
|
25 |
#include "CSatNotifyPlayTone.h" // Tsy class header
|
|
26 |
#include "CSatNotificationsTsy.h" // Class header
|
|
27 |
#include "CBerTlv.h" // Ber Tlv data handling
|
|
28 |
#include "TTlv.h" // TTlv class
|
|
29 |
#include "CSatDataPackage.h" // Parameter packing
|
|
30 |
#include "TfLogger.h" // For TFLOGSTRING
|
|
31 |
#include "TSatUtility.h" // Utilities
|
|
32 |
#include "CSatTsyReqHandleStore.h" // Request handle class
|
|
33 |
#include "cmmmessagemanagerbase.h" // Message manager class for forwarding req.
|
|
34 |
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
// CSatNotifyGetInkey::NewL
|
|
37 |
// Two-phased constructor.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CSatNotifyPlayTone* CSatNotifyPlayTone::NewL
|
|
41 |
(
|
|
42 |
CSatNotificationsTsy* aNotificationsTsy
|
|
43 |
)
|
|
44 |
{
|
|
45 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::NewL");
|
|
46 |
CSatNotifyPlayTone* const satNotifyPlayTone =
|
|
47 |
new ( ELeave ) CSatNotifyPlayTone( aNotificationsTsy );
|
|
48 |
CleanupStack::PushL( satNotifyPlayTone );
|
|
49 |
satNotifyPlayTone->ConstructL();
|
|
50 |
CleanupStack::Pop( satNotifyPlayTone );
|
|
51 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::NewL, end of method");
|
|
52 |
return satNotifyPlayTone;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CSatNotifyPlayTone::~CSatNotifyPlayTone
|
|
57 |
// Destructor
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CSatNotifyPlayTone::~CSatNotifyPlayTone
|
|
61 |
(
|
|
62 |
// None
|
|
63 |
)
|
|
64 |
{
|
|
65 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::~CSatNotifyPlayTone");
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
// CSatNotifyPlayTone::CSatNotifyPlayTone
|
|
70 |
// Default C++ constructor
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CSatNotifyPlayTone::CSatNotifyPlayTone
|
|
74 |
(
|
|
75 |
CSatNotificationsTsy* aNotificationsTsy
|
|
76 |
) : iNotificationsTsy ( aNotificationsTsy )
|
|
77 |
{
|
|
78 |
// None
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CSatNotifyPlayTone::ConstructL
|
|
83 |
// Symbian 2nd phase constructor
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CSatNotifyPlayTone::ConstructL
|
|
87 |
(
|
|
88 |
// None
|
|
89 |
)
|
|
90 |
{
|
|
91 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::ConstructL, does nothing");
|
|
92 |
}
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// CSatNotifyPlayTone::Notify
|
|
96 |
// Save the request handle type for notification requested by ETel server
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
TInt CSatNotifyPlayTone::Notify
|
|
100 |
(
|
|
101 |
const TTsyReqHandle aTsyReqHandle,
|
|
102 |
const TDataPackage& aPackage
|
|
103 |
)
|
|
104 |
{
|
|
105 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::Notify");
|
|
106 |
// Save data pointer to client side for completion
|
|
107 |
iPlayToneV2Pckg = reinterpret_cast<RSat::TPlayToneV2Pckg*>(
|
|
108 |
aPackage.Des1n() );
|
|
109 |
// Save the request handle
|
|
110 |
iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle,
|
|
111 |
CSatTsy::ESatNotifyPlayTonePCmdReqType );
|
|
112 |
// Check if requested notification is already pending
|
|
113 |
iNotificationsTsy->NotifySatReadyForNotification( KPlayTone );
|
|
114 |
|
|
115 |
return KErrNone;
|
|
116 |
}
|
|
117 |
|
|
118 |
|
|
119 |
// -----------------------------------------------------------------------------
|
|
120 |
// CSatNotifyPlayTone::CancelNotification
|
|
121 |
// This method cancels an outstanding asynchronous
|
|
122 |
// NotifyPlayTone request.
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
TInt CSatNotifyPlayTone::CancelNotification
|
|
126 |
(
|
|
127 |
const TTsyReqHandle aTsyReqHandle
|
|
128 |
)
|
|
129 |
{
|
|
130 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::CancelNotification");
|
|
131 |
// Reset the request handle
|
|
132 |
iNotificationsTsy->iSatReqHandleStore->
|
|
133 |
ResetTsyReqHandle( CSatTsy::ESatNotifyPlayTonePCmdReqType );
|
|
134 |
iPlayToneV2Pckg = NULL;
|
|
135 |
iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
|
|
136 |
return KErrNone;
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
// CSatNotifyPlayTone::CompleteNotifyL
|
|
144 |
// Complete Sim Session End notification to the client
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
TInt CSatNotifyPlayTone::CompleteNotifyL
|
|
148 |
(
|
|
149 |
CSatDataPackage* aDataPackage,
|
|
150 |
TInt aErrorCode
|
|
151 |
)
|
|
152 |
{
|
|
153 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL");
|
|
154 |
TInt returnValue( KErrNone );
|
|
155 |
TInt ret( KErrNone );
|
|
156 |
|
|
157 |
// Unpack parameters
|
|
158 |
TPtrC8* data;
|
|
159 |
aDataPackage->UnPackData( &data );
|
|
160 |
TBuf<1>additionalInfo;
|
|
161 |
|
|
162 |
// Reset req handle. Returns the deleted req handle
|
|
163 |
TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle(
|
|
164 |
CSatTsy::ESatNotifyPlayTonePCmdReqType );
|
|
165 |
|
|
166 |
// Get ber tlv
|
|
167 |
CBerTlv berTlv;
|
|
168 |
berTlv.SetData( *data );
|
|
169 |
// Get command details tlv
|
|
170 |
CTlv commandDetails;
|
|
171 |
berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
|
|
172 |
iNotificationsTsy->iTerminalRespData.iCommandDetails.
|
|
173 |
Copy( commandDetails.Data() );
|
|
174 |
TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
|
|
175 |
|
|
176 |
// In case the request was ongoing, continue..
|
|
177 |
if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
|
|
178 |
{
|
|
179 |
// Complete right away if error has occured, otherwise continue..
|
|
180 |
if ( KErrNone == aErrorCode )
|
|
181 |
{
|
|
182 |
// Fill the Play Tone structure
|
|
183 |
RSat::TPlayToneV2& playToneV2 = ( *iPlayToneV2Pckg )();
|
|
184 |
|
|
185 |
playToneV2.SetPCmdNumber( pCmdNumber );
|
|
186 |
|
|
187 |
// Alpha ID string (optional)
|
|
188 |
CTlv alphaIdentifier;
|
|
189 |
returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
|
|
190 |
KTlvAlphaIdentifierTag );
|
|
191 |
|
|
192 |
if ( KErrNotFound != returnValue )
|
|
193 |
{
|
|
194 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
|
|
195 |
Alpha ID present");
|
|
196 |
TUint16 alphaIdLength = alphaIdentifier.GetLength();
|
|
197 |
if ( alphaIdLength )
|
|
198 |
{
|
|
199 |
// Get the alpha id
|
|
200 |
TPtrC8 sourceString;
|
|
201 |
sourceString.Set(
|
|
202 |
alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
|
|
203 |
// Convert and set the alpha id
|
|
204 |
TSatUtility::SetAlphaId( sourceString ,
|
|
205 |
playToneV2.iAlphaId.iAlphaId );
|
|
206 |
}
|
|
207 |
|
|
208 |
// Set Alpha ID status
|
|
209 |
if ( playToneV2.iAlphaId.iAlphaId.Length() )
|
|
210 |
{
|
|
211 |
playToneV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
|
|
212 |
}
|
|
213 |
else
|
|
214 |
{
|
|
215 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
|
|
216 |
Alpha ID is NULL");
|
|
217 |
playToneV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
|
|
218 |
}
|
|
219 |
}
|
|
220 |
|
|
221 |
// Tone selection (optional)
|
|
222 |
playToneV2.iTone = RSat::KToneNotSet;
|
|
223 |
CTlv tone;
|
|
224 |
returnValue = berTlv.TlvByTagValue( &tone, KTlvToneTag );
|
|
225 |
if ( KErrNotFound != returnValue )
|
|
226 |
{
|
|
227 |
playToneV2.iTone = ( RSat::TTone ) tone.GetShortInfo(
|
|
228 |
ETLV_Tone );
|
|
229 |
TFLOGSTRING2("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
|
|
230 |
Tone Selection: %d", playToneV2.iTone);
|
|
231 |
}
|
|
232 |
|
|
233 |
// Duration of the tone (optional)
|
|
234 |
TSatUtility::FillDurationStructure( berTlv,
|
|
235 |
playToneV2.iDuration );
|
|
236 |
|
|
237 |
// Icond Id (optional)
|
|
238 |
TSatUtility::FillIconStructure( berTlv,
|
|
239 |
playToneV2.iIconId );
|
|
240 |
|
|
241 |
}// End of if ( KErrNone == aErrorCode )
|
|
242 |
else
|
|
243 |
{
|
|
244 |
ret = aErrorCode;
|
|
245 |
}
|
|
246 |
|
|
247 |
iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
|
|
248 |
}// End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
|
|
249 |
else
|
|
250 |
{
|
|
251 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
|
|
252 |
Request not ongoing");
|
|
253 |
// Request not on, returning response immediately
|
|
254 |
additionalInfo.Zero();
|
|
255 |
additionalInfo.Append( KNoCause );
|
|
256 |
CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd,
|
|
257 |
additionalInfo );
|
|
258 |
}
|
|
259 |
|
|
260 |
return ret;
|
|
261 |
|
|
262 |
}
|
|
263 |
|
|
264 |
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// CSatNotifyPlayTone::TerminalResponseL
|
|
267 |
// Called by ETel server, passes terminal response to DOS
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
//
|
|
270 |
TInt CSatNotifyPlayTone::TerminalResponseL
|
|
271 |
(
|
|
272 |
TDes8* aRsp
|
|
273 |
)
|
|
274 |
{
|
|
275 |
TFLOGSTRING( "CSAT: CSatNotifyPlayTone::TerminalResponseL" );
|
|
276 |
|
|
277 |
TInt ret( KErrNone );
|
|
278 |
TBuf<1>additionalInfo;
|
|
279 |
additionalInfo.Append( 0 );
|
|
280 |
RSat::TPlayToneRspV1Pckg* aRspPckg =
|
|
281 |
reinterpret_cast<RSat::TPlayToneRspV1Pckg*>( aRsp );
|
|
282 |
RSat::TPlayToneRspV1& rspV1 = ( *aRspPckg ) ();
|
|
283 |
|
|
284 |
// Get Proactive command number
|
|
285 |
TUint8 pCmdNumber( rspV1.PCmdNumber() );
|
|
286 |
|
|
287 |
// Check that general result value is valid
|
|
288 |
// Note: When the phone is in silent mode, KMeUnableToProcessCmd
|
|
289 |
// is returned as a result, with no additional info.
|
|
290 |
if ( ( RSat::KSuccess != rspV1.iGeneralResult ) &&
|
|
291 |
( RSat::KPSessionTerminatedByUser != rspV1.iGeneralResult ) &&
|
|
292 |
( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) &&
|
|
293 |
( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult ) &&
|
|
294 |
( RSat::KCmdDataNotUnderstood != rspV1.iGeneralResult ) )
|
|
295 |
{
|
|
296 |
TFLOGSTRING( "CSAT: CSatNotifyPlayTone::TerminalResponseL,\
|
|
297 |
Invalid General Result" );
|
|
298 |
// Invalid general result
|
|
299 |
ret = KErrCorrupt;
|
|
300 |
}
|
|
301 |
|
|
302 |
// If there is ME (Mobile Equipment) error, additional info is needed
|
|
303 |
if ( ( RSat::KMeProblem == rspV1.iInfoType ) )
|
|
304 |
{
|
|
305 |
// Check the length of additional info
|
|
306 |
if ( 0 != rspV1.iAdditionalInfo.Length() )
|
|
307 |
{
|
|
308 |
additionalInfo.Zero();
|
|
309 |
additionalInfo.Append( rspV1.iAdditionalInfo[0] );
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{
|
|
313 |
TFLOGSTRING( "CSAT: CSatNotifyPlayTone::TerminalResponseL,\
|
|
314 |
Invalid Additional Info" );
|
|
315 |
// Invalid additional info field
|
|
316 |
ret = KErrCorrupt;
|
|
317 |
}
|
|
318 |
}
|
|
319 |
TFLOGSTRING2( "CSAT: CSatNotifyPlayTone::TerminalResponseL: \
|
|
320 |
AdditionalInfo: %s", &additionalInfo );
|
|
321 |
|
|
322 |
CreateTerminalRespL( pCmdNumber, static_cast< TUint8 >(
|
|
323 |
rspV1.iGeneralResult ), additionalInfo );
|
|
324 |
|
|
325 |
return ret;
|
|
326 |
}
|
|
327 |
|
|
328 |
// -----------------------------------------------------------------------------
|
|
329 |
// CSatNotifyPlayTone::CreateTerminalRespL
|
|
330 |
// Constructs PlayTone specific part of terminal response and calls
|
|
331 |
// DOS to send the actual message.
|
|
332 |
// -----------------------------------------------------------------------------
|
|
333 |
//
|
|
334 |
TInt CSatNotifyPlayTone::CreateTerminalRespL
|
|
335 |
(
|
|
336 |
TUint8 aPCmdNumber,
|
|
337 |
TUint8 aGeneralResult,
|
|
338 |
TDesC16& aAdditionalInfo
|
|
339 |
)
|
|
340 |
{
|
|
341 |
TFLOGSTRING("CSAT: CSatNotifyPlayTone::CreateTerminalRespL");
|
|
342 |
TTlv tlvSpecificData;
|
|
343 |
tlvSpecificData.AddTag( KTlvResultTag );
|
|
344 |
//General result
|
|
345 |
tlvSpecificData.AddByte( aGeneralResult );
|
|
346 |
|
|
347 |
if ( !( iNotificationsTsy->CommandPerformedSuccessfully(
|
|
348 |
aGeneralResult ) ) )
|
|
349 |
{
|
|
350 |
switch ( aGeneralResult )
|
|
351 |
{
|
|
352 |
// Cases in which additional info is not required
|
|
353 |
case RSat::KPSessionTerminatedByUser:
|
|
354 |
case RSat::KBackwardModeRequestedByUser:
|
|
355 |
case RSat::KNoResponseFromUser:
|
|
356 |
case RSat::KErrorRequiredValuesMissing:
|
|
357 |
case RSat::KHelpRequestedByUser:
|
|
358 |
case RSat::KCmdDataNotUnderstood:
|
|
359 |
{
|
|
360 |
break;
|
|
361 |
}
|
|
362 |
default:
|
|
363 |
{
|
|
364 |
tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] );
|
|
365 |
break;
|
|
366 |
}
|
|
367 |
}
|
|
368 |
}
|
|
369 |
// Prepare data
|
|
370 |
iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
|
|
371 |
TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
|
|
372 |
// Pack data
|
|
373 |
CSatDataPackage dataPackage;
|
|
374 |
dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
|
|
375 |
// Forward request to the DOS
|
|
376 |
return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL(
|
|
377 |
ESatTerminalRsp, &dataPackage );
|
|
378 |
}
|
|
379 |
|
|
380 |
// End of File
|