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