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