|
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 : CSatNotifyLanguageNotification.cpp |
|
15 // Part of : Common SIM ATK TSY / commonsimatktsy |
|
16 // Language 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 "CSatNotifyLanguageNotification.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 |
|
34 // forwarding req. |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CSatNotifyLanguageNotification::NewL |
|
38 // Two-phased constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CSatNotifyLanguageNotification* CSatNotifyLanguageNotification::NewL |
|
42 ( |
|
43 CSatNotificationsTsy* aNotificationsTsy |
|
44 ) |
|
45 { |
|
46 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::NewL"); |
|
47 CSatNotifyLanguageNotification* const satNotifyLanguageNotification = |
|
48 new ( ELeave ) CSatNotifyLanguageNotification( aNotificationsTsy ); |
|
49 CleanupStack::PushL( satNotifyLanguageNotification ); |
|
50 satNotifyLanguageNotification->ConstructL(); |
|
51 CleanupStack::Pop( satNotifyLanguageNotification ); |
|
52 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::NewL, end of method"); |
|
53 return satNotifyLanguageNotification; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CSatNotifyLanguageNotification::CSatNotifyLanguageNotification |
|
58 // Destructor |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CSatNotifyLanguageNotification::~CSatNotifyLanguageNotification |
|
62 ( |
|
63 // None |
|
64 ) |
|
65 { |
|
66 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::\ |
|
67 ~CSatNotifyLanguageNotification"); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CSatNotifyLanguageNotification::CSatNotifyLanguageNotification |
|
72 // Default C++ constructor |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CSatNotifyLanguageNotification::CSatNotifyLanguageNotification |
|
76 ( |
|
77 CSatNotificationsTsy* aNotificationsTsy |
|
78 ) : iNotificationsTsy ( aNotificationsTsy ) |
|
79 { |
|
80 // None |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CSatNotifyLanguageNotification::ConstructL |
|
85 // Symbian 2nd phase constructor |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CSatNotifyLanguageNotification::ConstructL |
|
89 ( |
|
90 // None |
|
91 ) |
|
92 { |
|
93 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::ConstructL"); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CSatNotifyLanguageNotification::Notify |
|
98 // Save the request handle type for notification requested by ETel server |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 TInt CSatNotifyLanguageNotification::Notify |
|
102 ( |
|
103 const TTsyReqHandle aTsyReqHandle, |
|
104 const TDataPackage& aPackage |
|
105 ) |
|
106 { |
|
107 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::Notify"); |
|
108 // Save data pointer to client side for completion |
|
109 iLanguageNotificationV2Pckg = reinterpret_cast<RSat:: |
|
110 TLanguageNotificationV2Pckg*>( aPackage.Des1n() ); |
|
111 // Save the request handle |
|
112 iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, |
|
113 CSatTsy::ESatNotifyLanguageNotificationPCmdReqType ); |
|
114 // Check if requested notification is already pending |
|
115 iNotificationsTsy->NotifySatReadyForNotification( KLanguageNotification ); |
|
116 |
|
117 return KErrNone; |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CSatNotifyLanguageNotification::CancelNotification |
|
124 // This method cancels an outstanding asynchronous |
|
125 // NotifyLanguageNotification request. |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 TInt CSatNotifyLanguageNotification::CancelNotification |
|
129 ( |
|
130 const TTsyReqHandle aTsyReqHandle |
|
131 ) |
|
132 { |
|
133 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::CancelNotification"); |
|
134 // Reset the request handle |
|
135 iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( |
|
136 CSatTsy::ESatNotifyLanguageNotificationPCmdReqType ); |
|
137 // Reset the data pointer |
|
138 iLanguageNotificationV2Pckg = NULL; |
|
139 // Complete the request with KErrCancel |
|
140 iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel ); |
|
141 |
|
142 return KErrNone; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CSatNotifyLanguageNotification::CompleteNotifyL |
|
147 // This method completes an outstanding asynchronous |
|
148 // LanguageNotification request. |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 TInt CSatNotifyLanguageNotification::CompleteNotifyL |
|
152 ( |
|
153 CSatDataPackage* aDataPackage, |
|
154 TInt aErrorCode |
|
155 ) |
|
156 { |
|
157 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::CompleteNotifyL"); |
|
158 |
|
159 TInt returnValue( KErrNone ); |
|
160 TInt ret( KErrNone ); |
|
161 TBuf<1> additionalInfo; |
|
162 |
|
163 // Unpack parameters |
|
164 TPtrC8* data; |
|
165 aDataPackage->UnPackData( &data ); |
|
166 |
|
167 // Reset req handle. Returns the deleted req handle |
|
168 TTsyReqHandle reqHandle = |
|
169 iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( |
|
170 CSatTsy::ESatNotifyLanguageNotificationPCmdReqType ); |
|
171 // Get ber tlv |
|
172 CBerTlv berTlv; |
|
173 berTlv.SetData( *data ); |
|
174 // Get command details tlv |
|
175 CTlv commandDetails; |
|
176 berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag ); |
|
177 // Store command details tlv |
|
178 iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( |
|
179 commandDetails.Data() ); |
|
180 |
|
181 TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) ); |
|
182 |
|
183 // In case the request was ongoing, continue.. |
|
184 if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
185 { |
|
186 // Complete right away if error has occured, otherwise continue.. |
|
187 if ( KErrNone == aErrorCode ) |
|
188 { |
|
189 RSat::TLanguageNotificationV2& languageNotificationV2 = |
|
190 ( *iLanguageNotificationV2Pckg )(); |
|
191 // Transaction id |
|
192 languageNotificationV2.SetPCmdNumber( pCmdNumber ); |
|
193 |
|
194 // Initialisate |
|
195 languageNotificationV2.iNotificationType = |
|
196 RSat::ENotificationTypeNotSet; |
|
197 |
|
198 // Get command qualifier |
|
199 TUint8 cmdQualifier(commandDetails.GetShortInfo( |
|
200 ETLV_CommandQualifier ) ); |
|
201 |
|
202 if ( !cmdQualifier ) |
|
203 { |
|
204 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::\ |
|
205 CompleteNotifyL, No specific language used"); |
|
206 // No specific language used |
|
207 languageNotificationV2.iNotificationType = |
|
208 RSat::ENonSpecificLangNotification; |
|
209 } |
|
210 else if ( KSpecificLanguage == cmdQualifier ) |
|
211 { |
|
212 // Currently used language |
|
213 languageNotificationV2.iNotificationType = |
|
214 RSat::ESpecificLangNotification; |
|
215 } |
|
216 else |
|
217 { |
|
218 // None. |
|
219 } |
|
220 |
|
221 CTlv language; |
|
222 returnValue = berTlv.TlvByTagValue( &language, KTlvLanguageTag ); |
|
223 |
|
224 // If the Language tag is found |
|
225 if ( KErrNone == returnValue ) |
|
226 { |
|
227 languageNotificationV2.iLanguage = language.GetLongInfo( |
|
228 ETLV_Language ); |
|
229 } |
|
230 }// End of if( KErrNone == aErrorCode ) |
|
231 else |
|
232 { |
|
233 ret = aErrorCode; |
|
234 } |
|
235 |
|
236 iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret ); |
|
237 }// End of if( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
238 else |
|
239 { |
|
240 TFLOGSTRING("CSAT: CSatNotifyLanguageNotification::CompleteNotifyL,\ |
|
241 Request not ongoing"); |
|
242 additionalInfo.Zero(); |
|
243 additionalInfo.Append( KNoCause ); |
|
244 CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd, |
|
245 additionalInfo ); |
|
246 } |
|
247 return ret; |
|
248 } |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // CSatNotifyLanguageNotification::TerminalResponseL |
|
252 // Called by ETel server, passes terminal response to SIM card |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 TInt CSatNotifyLanguageNotification::TerminalResponseL |
|
256 ( |
|
257 TDes8* aRsp |
|
258 ) |
|
259 { |
|
260 TFLOGSTRING("CSAT:CSatNotifyLanguageNotification::TerminalResponseL"); |
|
261 TInt ret( KErrNone ); |
|
262 TBuf<1> additionalInfo; |
|
263 additionalInfo.FillZ(1); |
|
264 |
|
265 RSat::TLanguageNotificationRspV2Pckg* aRspPckg = |
|
266 reinterpret_cast<RSat::TLanguageNotificationRspV2Pckg*>( aRsp ); |
|
267 RSat::TLanguageNotificationRspV2& rspV1 = ( *aRspPckg ) (); |
|
268 |
|
269 TUint8 pCmdNumber( rspV1.PCmdNumber() ); |
|
270 |
|
271 CreateTerminalRespL( pCmdNumber, RSat::KSuccess, additionalInfo ); |
|
272 |
|
273 return ret; |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CSatNotifyLanguageNotification::CreateTerminalRespL |
|
278 // Constructs LanguageNotification specific part of terminal response and calls |
|
279 // DOS to send the actual message. |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TInt CSatNotifyLanguageNotification::CreateTerminalRespL |
|
283 ( |
|
284 TUint8 aPCmdNumber, |
|
285 TUint8 aGeneralResult, |
|
286 TDesC16& aAdditionalInfo |
|
287 ) |
|
288 { |
|
289 TFLOGSTRING("CSAT:CSatNotifyLanguageNotification::CreateTerminalRespL"); |
|
290 TTlv tlvSpecificData; |
|
291 // Create General Result TLV here |
|
292 tlvSpecificData.AddTag( KTlvResultTag ); |
|
293 // General result |
|
294 tlvSpecificData.AddByte( aGeneralResult ); |
|
295 |
|
296 if ( RSat::KSuccess != aGeneralResult ) |
|
297 { |
|
298 tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] ); |
|
299 } |
|
300 |
|
301 // Prepare data |
|
302 iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber; |
|
303 TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag(); |
|
304 // Pack data |
|
305 CSatDataPackage dataPackage; |
|
306 dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data ); |
|
307 |
|
308 // Forward request to the DOS |
|
309 return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( |
|
310 ESatTerminalRsp, &dataPackage ); |
|
311 } |
|
312 |
|
313 // End of file |