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 : CSatNotifyCloseChannel.cpp
|
|
15 |
// Part of : Common SIM ATK TSY / commonsimatktsy
|
|
16 |
// Close channel 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 "CSatNotifyCloseChannel.h" // Class header
|
|
26 |
#include "CSatNotificationsTsy.h" // Tsy 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 |
// CSatNotifyCloseChannel::NewL
|
|
37 |
// Two-phased constructor.
|
|
38 |
// -----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CSatNotifyCloseChannel* CSatNotifyCloseChannel::NewL
|
|
41 |
(
|
|
42 |
CSatNotificationsTsy* aNotificationsTsy
|
|
43 |
)
|
|
44 |
{
|
|
45 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::NewL");
|
|
46 |
CSatNotifyCloseChannel* const satNotifyCloseChannel =
|
|
47 |
new ( ELeave ) CSatNotifyCloseChannel( aNotificationsTsy );
|
|
48 |
CleanupStack::PushL( satNotifyCloseChannel );
|
|
49 |
satNotifyCloseChannel->ConstructL();
|
|
50 |
CleanupStack::Pop( satNotifyCloseChannel );
|
|
51 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::NewL, end of method");
|
|
52 |
return satNotifyCloseChannel;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CSatNotifyCloseChannel::~CSatNotifyCloseChannel
|
|
57 |
// Destructor
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CSatNotifyCloseChannel::~CSatNotifyCloseChannel
|
|
61 |
(
|
|
62 |
// None
|
|
63 |
)
|
|
64 |
{
|
|
65 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::~CSatNotifyCloseChannel");
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
// CSatNotifyCloseChannel::CSatNotifyCloseChannel
|
|
70 |
// Default C++ constructor
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CSatNotifyCloseChannel::CSatNotifyCloseChannel
|
|
74 |
(
|
|
75 |
CSatNotificationsTsy* aNotificationsTsy
|
|
76 |
) : iNotificationsTsy ( aNotificationsTsy )
|
|
77 |
{
|
|
78 |
// None
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CSatNotifyCloseChannel::ConstructL
|
|
83 |
// Symbian 2nd phase constructor
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CSatNotifyCloseChannel::ConstructL
|
|
87 |
(
|
|
88 |
// None
|
|
89 |
)
|
|
90 |
{
|
|
91 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::~CSatNotifyCloseChannel, \
|
|
92 |
does nothing");
|
|
93 |
}
|
|
94 |
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
// CSatNotifyCloseChannel::Notify
|
|
97 |
// This request allows a client to be notified of a CLOSE CHANNEL proactive
|
|
98 |
// command
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
TInt CSatNotifyCloseChannel::Notify
|
|
102 |
(
|
|
103 |
const TTsyReqHandle aTsyReqHandle,
|
|
104 |
const TDataPackage& aPackage
|
|
105 |
)
|
|
106 |
{
|
|
107 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::Notify");
|
|
108 |
|
|
109 |
// Save data pointer to client side for completion
|
|
110 |
iCloseChannelRspV2Pckg = reinterpret_cast<RSat::TCloseChannelV2Pckg*>(
|
|
111 |
aPackage.Des1n() );
|
|
112 |
// Save the request handle
|
|
113 |
iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle,
|
|
114 |
CSatTsy::ESatNotifyCloseChannelPCmdReqType );
|
|
115 |
// Check if requested notification is already pending
|
|
116 |
iNotificationsTsy->NotifySatReadyForNotification( KCloseChannel );
|
|
117 |
|
|
118 |
return KErrNone;
|
|
119 |
}
|
|
120 |
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
// CSatNotifyCloseChannel::CancelNotification
|
|
123 |
// This method cancels an outstanding asynchronous
|
|
124 |
// NotifyCloseChannel request.
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
//
|
|
127 |
TInt CSatNotifyCloseChannel::CancelNotification
|
|
128 |
(
|
|
129 |
const TTsyReqHandle aTsyReqHandle
|
|
130 |
)
|
|
131 |
{
|
|
132 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CancelNotification");
|
|
133 |
// Reset the request handle
|
|
134 |
TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
|
|
135 |
ResetTsyReqHandle( CSatTsy::ESatNotifyCloseChannelPCmdReqType );
|
|
136 |
// Reset the data pointers
|
|
137 |
iCloseChannelRspV2Pckg = NULL;
|
|
138 |
// Complete the request with KErrCancel
|
|
139 |
iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
|
|
140 |
return KErrNone;
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// CSatNotifyCloseChannel::CompleteNotifyL
|
|
145 |
// This method completes an outstanding asynchronous
|
|
146 |
// NotifyCloseChannel request.
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
TInt CSatNotifyCloseChannel::CompleteNotifyL
|
|
150 |
(
|
|
151 |
CSatDataPackage* aDataPackage,
|
|
152 |
TInt aErrorCode
|
|
153 |
)
|
|
154 |
{
|
|
155 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CompleteNotifyL");
|
|
156 |
TInt ret( KErrNone );
|
|
157 |
// Unpack parameters
|
|
158 |
TPtrC8* data;
|
|
159 |
aDataPackage->UnPackData( &data );
|
|
160 |
// Reset req handle. Returns the deleted req handle
|
|
161 |
TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
|
|
162 |
ResetTsyReqHandle( CSatTsy::ESatNotifyCloseChannelPCmdReqType );
|
|
163 |
// Get ber tlv
|
|
164 |
CBerTlv berTlv;
|
|
165 |
berTlv.SetData( *data );
|
|
166 |
|
|
167 |
// Get command details tlv
|
|
168 |
CTlv commandDetails;
|
|
169 |
berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
|
|
170 |
|
|
171 |
// Store command details tlv
|
|
172 |
iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy(
|
|
173 |
commandDetails.Data() );
|
|
174 |
|
|
175 |
TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
|
|
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 Close Channel structure
|
|
183 |
RSat::TCloseChannelV2& closeChannelV2 =
|
|
184 |
( *iCloseChannelRspV2Pckg )();
|
|
185 |
|
|
186 |
// Store transaction ID
|
|
187 |
closeChannelV2.SetPCmdNumber( pCmdNumber );
|
|
188 |
|
|
189 |
// Store Channel Id
|
|
190 |
CTlv deviceIds;
|
|
191 |
TInt returnValue( berTlv.TlvByTagValue( &deviceIds,
|
|
192 |
KTlvDeviceIdentityTag ) );
|
|
193 |
if ( KErrNone == returnValue )
|
|
194 |
{
|
|
195 |
closeChannelV2.iDestination = (RSat::TDeviceId) deviceIds.
|
|
196 |
GetShortInfo( ETLV_DestinationDeviceIdentity );
|
|
197 |
|
|
198 |
// Alpha Id (Optional)
|
|
199 |
CTlv alphaIdentifier;
|
|
200 |
returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
|
|
201 |
KTlvAlphaIdentifierTag ) ;
|
|
202 |
closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
|
|
203 |
if ( KErrNotFound != returnValue )
|
|
204 |
{
|
|
205 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CompleteNotifyL\
|
|
206 |
Alpha ID present");
|
|
207 |
TUint16 alphaIdLength = alphaIdentifier.GetLength();
|
|
208 |
if ( alphaIdLength )
|
|
209 |
{
|
|
210 |
// Get the alpha id
|
|
211 |
TPtrC8 sourceString;
|
|
212 |
sourceString.Set(
|
|
213 |
alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
|
|
214 |
// convert and set the alpha id
|
|
215 |
TSatUtility::SetAlphaId( sourceString ,
|
|
216 |
closeChannelV2.iAlphaId.iAlphaId );
|
|
217 |
}
|
|
218 |
|
|
219 |
// Set Alpha ID status
|
|
220 |
if ( closeChannelV2.iAlphaId.iAlphaId.Length() )
|
|
221 |
{
|
|
222 |
closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
|
|
223 |
}
|
|
224 |
else
|
|
225 |
{
|
|
226 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CompleteNotifyL\
|
|
227 |
Alpha ID is NULL");
|
|
228 |
closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
// Icon Id (Optional)
|
|
233 |
TSatUtility::FillIconStructure( berTlv,
|
|
234 |
closeChannelV2.iIconId );
|
|
235 |
} // if ( KErrNone == returnValue )
|
|
236 |
else
|
|
237 |
{
|
|
238 |
// Required values missing
|
|
239 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CompleteNotifyL,\
|
|
240 |
required values missing (Device Identities)");
|
|
241 |
ret = KErrCorrupt;
|
|
242 |
CreateTerminalRespL( pCmdNumber, RSat::KErrorRequiredValuesMissing, KNullDesC16 );
|
|
243 |
}
|
|
244 |
} // if ( KErrNone == aErrorCode )
|
|
245 |
else
|
|
246 |
{
|
|
247 |
ret = aErrorCode;
|
|
248 |
}
|
|
249 |
// Complete request
|
|
250 |
iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
|
|
251 |
}
|
|
252 |
else
|
|
253 |
{
|
|
254 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CompleteNotifyL\
|
|
255 |
Request not ongoing");
|
|
256 |
// Request not on, returning response immediately
|
|
257 |
TBuf16<1> additionalInfo;
|
|
258 |
additionalInfo.Append ( RSat::KNoSpecificMeProblem );
|
|
259 |
CreateTerminalRespL( pCmdNumber,RSat::KMeUnableToProcessCmd,
|
|
260 |
additionalInfo );
|
|
261 |
ret = KErrCorrupt;
|
|
262 |
}
|
|
263 |
return ret;
|
|
264 |
}
|
|
265 |
|
|
266 |
// -----------------------------------------------------------------------------
|
|
267 |
// CSatNotifyCloseChannel::TerminalResponseL
|
|
268 |
// Called by ETel server, passes terminal response to DOS
|
|
269 |
// -----------------------------------------------------------------------------
|
|
270 |
//
|
|
271 |
TInt CSatNotifyCloseChannel::TerminalResponseL
|
|
272 |
(
|
|
273 |
TDes8* aRsp
|
|
274 |
)
|
|
275 |
{
|
|
276 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::TerminalResponseL");
|
|
277 |
TInt ret( KErrNone );
|
|
278 |
|
|
279 |
TBuf16<1> additionalInfo;
|
|
280 |
RSat::TCloseChannelRspV2Pckg* aRspPckg =
|
|
281 |
reinterpret_cast<RSat::TCloseChannelRspV2Pckg*>( aRsp );
|
|
282 |
RSat::TCloseChannelRspV2& rspV2 = ( *aRspPckg ) ();
|
|
283 |
|
|
284 |
TUint8 pCmdNumber( rspV2.PCmdNumber() );
|
|
285 |
|
|
286 |
// Check that general result value is valid
|
|
287 |
if ( ( RSat::KSuccess != rspV2.iGeneralResult )
|
|
288 |
&& ( RSat::KPartialComprehension != rspV2.iGeneralResult )
|
|
289 |
&& ( RSat::KMissingInformation != rspV2.iGeneralResult )
|
|
290 |
&& ( RSat::KSuccessRequestedIconNotDisplayed != rspV2.iGeneralResult )
|
|
291 |
&& ( RSat::KPSessionTerminatedByUser != rspV2.iGeneralResult )
|
|
292 |
&& ( RSat::KMeUnableToProcessCmd != rspV2.iGeneralResult )
|
|
293 |
&& ( RSat::KCmdBeyondMeCapabilities != rspV2.iGeneralResult )
|
|
294 |
&& ( RSat::KCmdTypeNotUnderstood != rspV2.iGeneralResult )
|
|
295 |
&& ( RSat::KCmdDataNotUnderstood != rspV2.iGeneralResult )
|
|
296 |
&& ( RSat::KCmdNumberNotKnown != rspV2.iGeneralResult )
|
|
297 |
&& ( RSat::KErrorRequiredValuesMissing != rspV2.iGeneralResult )
|
|
298 |
&& ( RSat::KBearerIndepProtocolError != rspV2.iGeneralResult )
|
|
299 |
&& ( RSat::KFramesError != rspV2.iGeneralResult ))
|
|
300 |
{
|
|
301 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::TerminalResponseL\
|
|
302 |
Invalid General Result");
|
|
303 |
// Invalid general result
|
|
304 |
ret = KErrCorrupt;
|
|
305 |
}
|
|
306 |
|
|
307 |
if ( RSat::KMeProblem == rspV2.iInfoType )
|
|
308 |
{
|
|
309 |
if ( rspV2.iAdditionalInfo.Length() )
|
|
310 |
{
|
|
311 |
additionalInfo.Append( rspV2.iAdditionalInfo[0] );
|
|
312 |
}
|
|
313 |
else
|
|
314 |
{
|
|
315 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::TerminalResponseL\
|
|
316 |
Invalid Additional Info");
|
|
317 |
ret = KErrCorrupt;
|
|
318 |
}
|
|
319 |
}
|
|
320 |
else if (RSat::KNoAdditionalInfo == rspV2.iInfoType )
|
|
321 |
{
|
|
322 |
// do nothing
|
|
323 |
}
|
|
324 |
else
|
|
325 |
{
|
|
326 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::TerminalResponseL\
|
|
327 |
Invalid Additional Info type");
|
|
328 |
ret = KErrCorrupt;
|
|
329 |
}
|
|
330 |
|
|
331 |
TInt response = CreateTerminalRespL( pCmdNumber, static_cast<TUint8>(
|
|
332 |
rspV2.iGeneralResult ), additionalInfo );
|
|
333 |
|
|
334 |
if ( KErrNone == ret )
|
|
335 |
ret = response;
|
|
336 |
|
|
337 |
return ret;
|
|
338 |
}
|
|
339 |
|
|
340 |
// -----------------------------------------------------------------------------
|
|
341 |
// CSatNotifyCloseChannel::CreateTerminalRespL
|
|
342 |
// Constructs Close channel specific part of terminal response and calls
|
|
343 |
// DOS to send the actual message.
|
|
344 |
// -----------------------------------------------------------------------------
|
|
345 |
//
|
|
346 |
TInt CSatNotifyCloseChannel::CreateTerminalRespL
|
|
347 |
(
|
|
348 |
TUint8 aPCmdNumber,
|
|
349 |
TUint8 aGeneralResult,
|
|
350 |
const TDesC16& aAdditionalInfo
|
|
351 |
)
|
|
352 |
{
|
|
353 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CreateTerminalRespL");
|
|
354 |
TTlv tlvSpecificData;
|
|
355 |
// Append general result tag
|
|
356 |
tlvSpecificData.AddTag( KTlvResultTag );
|
|
357 |
// Append general result
|
|
358 |
tlvSpecificData.AddByte( aGeneralResult );
|
|
359 |
|
|
360 |
if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult )
|
|
361 |
|| ( RSat::KNetworkUnableToProcessCmd == aGeneralResult )
|
|
362 |
|| ( RSat::KInteractionWithCCPermanentError == aGeneralResult )
|
|
363 |
|| ( RSat::KErrorRequiredValuesMissing == aGeneralResult )
|
|
364 |
|| ( RSat::KBearerIndepProtocolError == aGeneralResult )
|
|
365 |
|| ( RSat::KFramesError == aGeneralResult ))
|
|
366 |
{
|
|
367 |
// Unsuccessful result requires an additional info byte
|
|
368 |
for ( TInt i = 0; i < aAdditionalInfo.Length(); i++ )
|
|
369 |
{
|
|
370 |
TFLOGSTRING("CSAT: CSatNotifyCloseChannel::CreateTerminalRespL,\
|
|
371 |
Unsuccessful result");
|
|
372 |
tlvSpecificData.AddByte( static_cast<TUint8>(
|
|
373 |
aAdditionalInfo[i] ) );
|
|
374 |
}
|
|
375 |
}
|
|
376 |
|
|
377 |
// Prepare data
|
|
378 |
iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
|
|
379 |
TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
|
|
380 |
// Pack data
|
|
381 |
CSatDataPackage dataPackage;
|
|
382 |
dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
|
|
383 |
// Forward request to the DOS
|
|
384 |
return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL(
|
|
385 |
ESatTerminalRsp, &dataPackage );
|
|
386 |
}
|
|
387 |
|
|
388 |
// End of file
|
|
389 |
|