|
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 : CSatNotifyGetChannelStatus.cpp |
|
15 // Part of : Common SIM ATK TSY / commonsimatktsy |
|
16 // Get channel status 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 "CSatNotifyGetChannelStatus.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 // CSatNotifyGetChannelStatus::NewL |
|
37 // Two-phased constructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CSatNotifyGetChannelStatus* CSatNotifyGetChannelStatus::NewL |
|
41 ( |
|
42 CSatNotificationsTsy* aNotificationsTsy |
|
43 ) |
|
44 { |
|
45 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::NewL"); |
|
46 CSatNotifyGetChannelStatus* const satNotifyGetChannelStatus = |
|
47 new ( ELeave ) CSatNotifyGetChannelStatus( aNotificationsTsy ); |
|
48 CleanupStack::PushL( satNotifyGetChannelStatus ); |
|
49 satNotifyGetChannelStatus->ConstructL(); |
|
50 CleanupStack::Pop( satNotifyGetChannelStatus ); |
|
51 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::NewL, end of method"); |
|
52 return satNotifyGetChannelStatus; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSatNotifyGetChannelStatus::~CSatNotifyGetChannelStatus |
|
57 // Destructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CSatNotifyGetChannelStatus::~CSatNotifyGetChannelStatus |
|
61 ( |
|
62 // None |
|
63 ) |
|
64 { |
|
65 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::~CSatNotifyGetChannelStatus" |
|
66 ); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CSatNotifyGetChannelStatus::CSatNotifyGetChannelStatus |
|
71 // Default C++ constructor |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CSatNotifyGetChannelStatus::CSatNotifyGetChannelStatus |
|
75 ( |
|
76 CSatNotificationsTsy* aNotificationsTsy |
|
77 ) : iNotificationsTsy ( aNotificationsTsy ) |
|
78 { |
|
79 // None |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CSatNotifyGetChannelStatus::ConstructL |
|
84 // Symbian 2nd phase constructor |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CSatNotifyGetChannelStatus::ConstructL |
|
88 ( |
|
89 // None |
|
90 ) |
|
91 { |
|
92 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::ConstructL, does nothing"); |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CSatNotifyGetChannelStatus::Notify |
|
97 // This request allows a client to be notified of a GET CHANNEL STATUS proactive |
|
98 // command |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 TInt CSatNotifyGetChannelStatus::Notify |
|
102 ( |
|
103 const TTsyReqHandle aTsyReqHandle, |
|
104 const TDataPackage& aPackage |
|
105 ) |
|
106 { |
|
107 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::Notify"); |
|
108 // Save data pointers to client side for completion |
|
109 iGetChannelStatusRspV2Pckg = reinterpret_cast<RSat::TGetChannelStatusV2Pckg*>( |
|
110 aPackage.Des1n() ); |
|
111 // Save the request handle |
|
112 iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, |
|
113 CSatTsy::ESatNotifyGetChannelStatusPCmdReqType ); |
|
114 // Check if requested notification is already pending |
|
115 iNotificationsTsy->NotifySatReadyForNotification( KGetChannelStatus ); |
|
116 return KErrNone; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CSatNotifyGetChannelStatus::CancelNotification |
|
121 // This method cancels an outstanding asynchronous |
|
122 // NotifyGetChannelStatus request. |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 TInt CSatNotifyGetChannelStatus::CancelNotification |
|
126 ( |
|
127 const TTsyReqHandle aTsyReqHandle |
|
128 ) |
|
129 { |
|
130 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::CancelNotification"); |
|
131 // Reset the request handle |
|
132 TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> |
|
133 ResetTsyReqHandle( CSatTsy::ESatNotifyGetChannelStatusPCmdReqType ); |
|
134 // Reset the data pointers |
|
135 iGetChannelStatusRspV2Pckg = NULL; |
|
136 // Complete the request with KErrCancel |
|
137 iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel ); |
|
138 return KErrNone; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CSatNotifyGetChannelStatus::CompleteNotifyL |
|
143 // This method completes an outstanding asynchronous |
|
144 // NotifyGetChannelStatus request. |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CSatNotifyGetChannelStatus::CompleteNotifyL |
|
148 ( |
|
149 CSatDataPackage* aDataPackage, |
|
150 TInt aErrorCode |
|
151 ) |
|
152 { |
|
153 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::CompleteNotifyL"); |
|
154 |
|
155 TInt ret( KErrNone ); |
|
156 // Unpack parameters |
|
157 TPtrC8* data; |
|
158 aDataPackage->UnPackData( &data ); |
|
159 // Reset req handle. Returns the deleted req handle |
|
160 TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> |
|
161 ResetTsyReqHandle( CSatTsy::ESatNotifyGetChannelStatusPCmdReqType ); |
|
162 // Get ber tlv |
|
163 CBerTlv berTlv; |
|
164 berTlv.SetData( *data ); |
|
165 // Get command details tlv |
|
166 CTlv commandDetails; |
|
167 berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag ); |
|
168 // Store command details tlv |
|
169 iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( |
|
170 commandDetails.Data() ); |
|
171 |
|
172 TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) ); |
|
173 |
|
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 TFLOGSTRING2("CSAT: CSatNotifyGetChannelStatus::CompleteNotifyL\ |
|
181 aErrorCode: %d", aErrorCode ); |
|
182 // Fill the Get Channel status structure |
|
183 RSat::TGetChannelStatusV2& channelStatusV2 = |
|
184 ( *iGetChannelStatusRspV2Pckg )(); |
|
185 |
|
186 // Store transaction ID |
|
187 channelStatusV2.SetPCmdNumber( pCmdNumber ); |
|
188 } |
|
189 else |
|
190 { |
|
191 ret = aErrorCode; |
|
192 } |
|
193 iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret ); |
|
194 } |
|
195 else |
|
196 { |
|
197 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::CompleteNotifyL\ |
|
198 Request not ongoing"); |
|
199 // Request not on, returning response immediately |
|
200 TBuf16<1> additionalInfo; |
|
201 additionalInfo.Append( RSat::KNoSpecificMeProblem ); |
|
202 CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd, |
|
203 additionalInfo ); |
|
204 ret = KErrCorrupt; |
|
205 } |
|
206 |
|
207 return ret; |
|
208 |
|
209 } |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CSatNotifyGetChannelStatus::TerminalResponseL |
|
212 // Called by ETel server, passes terminal response to DOS |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TInt CSatNotifyGetChannelStatus::TerminalResponseL |
|
216 ( |
|
217 TDes8* aRsp |
|
218 ) |
|
219 { |
|
220 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::TerminalResponseL"); |
|
221 TInt ret( KErrNone ); |
|
222 |
|
223 TBuf16<RSat::KAdditionalInfoMaxSize> additionalInfo; |
|
224 |
|
225 RSat::TGetChannelStatusRspV2Pckg* aRspPckg = |
|
226 reinterpret_cast<RSat::TGetChannelStatusRspV2Pckg*>( aRsp ); |
|
227 RSat::TGetChannelStatusRspV2& rspV2 = ( *aRspPckg ) (); |
|
228 |
|
229 TUint8 pCmdNumber( rspV2.PCmdNumber() ); |
|
230 |
|
231 // Check that general result value is valid |
|
232 if ( ( RSat::KSuccess != rspV2.iGeneralResult ) |
|
233 && ( RSat::KPartialComprehension != rspV2.iGeneralResult ) |
|
234 && ( RSat::KMissingInformation != rspV2.iGeneralResult ) |
|
235 && ( RSat::KSuccessRequestedIconNotDisplayed != rspV2.iGeneralResult ) |
|
236 && ( RSat::KPSessionTerminatedByUser != rspV2.iGeneralResult ) |
|
237 && ( RSat::KMeUnableToProcessCmd != rspV2.iGeneralResult ) |
|
238 && ( RSat::KCmdBeyondMeCapabilities != rspV2.iGeneralResult ) |
|
239 && ( RSat::KCmdTypeNotUnderstood != rspV2.iGeneralResult ) |
|
240 && ( RSat::KCmdDataNotUnderstood != rspV2.iGeneralResult ) |
|
241 && ( RSat::KCmdNumberNotKnown != rspV2.iGeneralResult ) |
|
242 && ( RSat::KErrorRequiredValuesMissing != rspV2.iGeneralResult ) ) |
|
243 { |
|
244 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::TerminalResponseL,\ |
|
245 Invalid General Result"); |
|
246 // Invalid general result |
|
247 ret = KErrCorrupt; |
|
248 } |
|
249 |
|
250 if ( ( RSat::KChannelStatusInfo == rspV2.iInfoType ) |
|
251 || ( RSat::KMeProblem == rspV2.iInfoType ) ) |
|
252 { |
|
253 if ( !rspV2.iAdditionalInfo.Length() ) |
|
254 { |
|
255 TFLOGSTRING("CSAT: CSatNotifyGetChannelStatus::TerminalResponseL,\ |
|
256 Invalid Additional Info"); |
|
257 ret = KErrCorrupt; |
|
258 } |
|
259 else |
|
260 { |
|
261 additionalInfo.Copy(rspV2.iAdditionalInfo); |
|
262 } |
|
263 } |
|
264 |
|
265 TInt response =CreateTerminalRespL( pCmdNumber, ( TUint8 ) rspV2.iGeneralResult, |
|
266 additionalInfo ); |
|
267 |
|
268 if ( KErrNone == ret ) |
|
269 { |
|
270 ret = response; |
|
271 } |
|
272 |
|
273 return ret; |
|
274 |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CSatNotifyGetChannelStatus::CreateTerminalRespL |
|
279 // Constructs GetChannelStatus specific part of terminal response and calls |
|
280 // DOS to send the actual message. |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 TInt CSatNotifyGetChannelStatus::CreateTerminalRespL |
|
284 ( |
|
285 TUint8 aPCmdNumber, |
|
286 TUint8 aGeneralResult, |
|
287 const TDesC16& aAdditionalInfo |
|
288 ) |
|
289 { |
|
290 TFLOGSTRING("CSAT: CSatMessHandler::CreateTerminalRespL"); |
|
291 TTlv tlvSpecificData; |
|
292 // Append general result tag |
|
293 tlvSpecificData.AddTag( KTlvResultTag ); |
|
294 // Append general result |
|
295 tlvSpecificData.AddByte( aGeneralResult ); |
|
296 |
|
297 if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult ) |
|
298 || ( RSat::KNetworkUnableToProcessCmd == aGeneralResult ) |
|
299 || ( RSat::KInteractionWithCCPermanentError == aGeneralResult ) |
|
300 || ( RSat::KErrorRequiredValuesMissing == aGeneralResult ) |
|
301 || ( RSat::KBearerIndepProtocolError == aGeneralResult ) ) |
|
302 { |
|
303 // Unsuccessful result requires an additional info byte |
|
304 for ( TInt j = 0; j < aAdditionalInfo.Length(); j++ ) |
|
305 { |
|
306 tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[j] ) ); |
|
307 } |
|
308 } |
|
309 else if ( RSat::KSuccess == aGeneralResult ) |
|
310 { |
|
311 // Length check is carried out in |
|
312 // CSatNotifyGetChannelStatus::TerminalResponseL |
|
313 for ( TInt i = 1; i < aAdditionalInfo.Length(); i += 2 ) |
|
314 { |
|
315 tlvSpecificData.AddTag( KTlvChannelStatusTag ); |
|
316 tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[i - 1] ) ); |
|
317 tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[i] ) ); |
|
318 } |
|
319 } |
|
320 else |
|
321 { |
|
322 TFLOGSTRING("CSAT: CSatMessHandler::CreateTerminalRespL - \ |
|
323 mandatory channel status missing"); |
|
324 } |
|
325 |
|
326 // Prepare data |
|
327 iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber; |
|
328 TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag(); |
|
329 |
|
330 // Pack data |
|
331 CSatDataPackage dataPackage; |
|
332 dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data ); |
|
333 |
|
334 // Forward request to the DOS |
|
335 return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( |
|
336 ESatTerminalRsp, &dataPackage ); |
|
337 } |
|
338 |
|
339 // End of file |
|
340 |
|
341 |