|
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 : CSatNotifyDisplayText.cpp |
|
15 // Part of : Common SIM ATK TSY / commonsimatktsy |
|
16 // Display text 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 "CSatNotifyDisplayText.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 // ----------------------------------------------------------------------------- |
|
37 // CSatNotifyDisplayText::CSatNotifyDisplayText |
|
38 // Constructor |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CSatNotifyDisplayText* CSatNotifyDisplayText::NewL |
|
42 ( |
|
43 CSatNotificationsTsy* aNotificationsTsy |
|
44 ) |
|
45 { |
|
46 TFLOGSTRING("CSAT: CSatNotifyDisplayText::NewL"); |
|
47 CSatNotifyDisplayText* const satNotifyDisplayText = |
|
48 new ( ELeave ) CSatNotifyDisplayText( aNotificationsTsy ); |
|
49 CleanupStack::PushL( satNotifyDisplayText ); |
|
50 satNotifyDisplayText->ConstructL(); |
|
51 CleanupStack::Pop( satNotifyDisplayText ); |
|
52 TFLOGSTRING("CSAT: CSatNotifyDisplayText::NewL, end of method"); |
|
53 return satNotifyDisplayText; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CSatNotifyDisplayText::~CSatNotifyDisplayText |
|
58 // Destructor |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CSatNotifyDisplayText::~CSatNotifyDisplayText() |
|
62 { |
|
63 TFLOGSTRING("CSAT: CSatNotifyDisplayText::~CSatNotifyDisplayText"); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSatNotifyDisplayText::CSatNotifyDisplayText |
|
68 // Constructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CSatNotifyDisplayText::CSatNotifyDisplayText |
|
72 ( |
|
73 CSatNotificationsTsy* aNotificationsTsy |
|
74 ):iNotificationsTsy( aNotificationsTsy ) |
|
75 { |
|
76 // None |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CSatNotifyDisplayText::ConstructL |
|
81 // Symbian 2nd phase constructor. Initialises internal attributes. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CSatNotifyDisplayText::ConstructL |
|
85 ( |
|
86 void |
|
87 ) |
|
88 { |
|
89 TFLOGSTRING("CSAT: CSatNotifyDisplayText::ConstructL"); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CSatNotifyDisplayText::Notify |
|
94 // This request allows a client to be notified of a DISPLAY TEXT proactive |
|
95 // command |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 TInt CSatNotifyDisplayText::Notify |
|
99 ( |
|
100 const TTsyReqHandle aTsyReqHandle, |
|
101 const TDataPackage& aPackage |
|
102 ) |
|
103 { |
|
104 TFLOGSTRING("CSAT: CSatNotifyDisplayText::Notify"); |
|
105 // Save data pointer to client side for completion |
|
106 iDisplayTextV2Pckg = reinterpret_cast<RSat::TDisplayTextV2Pckg*>( |
|
107 aPackage.Des1n() ); |
|
108 // Save the request handle |
|
109 iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, |
|
110 CSatTsy::ESatNotifyDisplayTextPCmdReqType ); |
|
111 // Check if requested notification is already pending |
|
112 iNotificationsTsy->NotifySatReadyForNotification( KDisplayText ); |
|
113 return KErrNone; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CSatNotifyDisplayText::CancelNotification |
|
118 // This method cancels an outstanding asynchronous |
|
119 // NotifyDisplayText request. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TInt CSatNotifyDisplayText::CancelNotification |
|
123 ( |
|
124 const TTsyReqHandle aTsyReqHandle |
|
125 ) |
|
126 { |
|
127 TFLOGSTRING("CSAT: CSatNotifyDisplayText::CancelNotification"); |
|
128 // Reset the request handle |
|
129 TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> |
|
130 ResetTsyReqHandle( CSatTsy::ESatNotifyDisplayTextPCmdReqType ); |
|
131 // Reset the data pointer |
|
132 iDisplayTextV2Pckg = NULL; |
|
133 // Complete the request with KErrCancel |
|
134 iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel ); |
|
135 return KErrNone; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CSatNotifyDisplayText::CompleteNotifyL |
|
140 // This method completes an outstanding asynchronous |
|
141 // NotifyDisplayText request. |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 TInt CSatNotifyDisplayText::CompleteNotifyL |
|
145 ( |
|
146 CSatDataPackage* aDataPackage, |
|
147 TInt aErrorCode |
|
148 ) |
|
149 { |
|
150 TFLOGSTRING("CSAT: CSatNotifyDisplayText::CompleteNotifyL"); |
|
151 TInt ret( KErrNone ); |
|
152 |
|
153 // Unpack parameters |
|
154 TPtrC8* data; |
|
155 aDataPackage->UnPackData( &data ); |
|
156 TFLOGSTRING2("CSAT: CSatNotifyDisplayText::CompleteNotifyL, dataLength: \ |
|
157 %d", data->Length()); |
|
158 // Reset req handle. Returns the deleted req handle |
|
159 TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> |
|
160 ResetTsyReqHandle( |
|
161 CSatTsy::ESatNotifyDisplayTextPCmdReqType ); |
|
162 |
|
163 // Get ber tlv |
|
164 CBerTlv berTlv; |
|
165 berTlv.SetData( *data ); |
|
166 // Get command details tlv |
|
167 CTlv commandDetails; |
|
168 berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag ); |
|
169 // Store command details tlv |
|
170 iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( |
|
171 commandDetails.Data() ); |
|
172 // Get command qualifier |
|
173 TUint8 cmdQualifier( commandDetails.GetShortInfo( |
|
174 ETLV_CommandQualifier ) ); |
|
175 |
|
176 TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) ); |
|
177 |
|
178 // In case the request was ongoing, continue.. |
|
179 if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
180 { |
|
181 // Complete right away if error has occured, otherwise continue.. |
|
182 if ( KErrNone == aErrorCode ) |
|
183 { |
|
184 // Let's fill the display text structure |
|
185 RSat::TDisplayTextV2& displayTextV2 = ( *iDisplayTextV2Pckg )(); |
|
186 |
|
187 // Store command number |
|
188 displayTextV2.SetPCmdNumber( pCmdNumber ); |
|
189 |
|
190 // Priority scheme |
|
191 if ( KPriorityMask & cmdQualifier ) |
|
192 { |
|
193 // Display priority high |
|
194 displayTextV2.iPriority = RSat::EHighPriority; |
|
195 } |
|
196 else |
|
197 { |
|
198 // Display priority normal |
|
199 displayTextV2.iPriority = RSat::ENormalPriority; |
|
200 } |
|
201 |
|
202 // Clearing scheme |
|
203 if ( KMessageClearMask & cmdQualifier) |
|
204 { |
|
205 // Wait for user to clear the message |
|
206 displayTextV2.iClearScreenTrigger = RSat::EUserClear; |
|
207 } |
|
208 else |
|
209 { |
|
210 // Clear message after a delay |
|
211 displayTextV2.iClearScreenTrigger = RSat::EClearAfterDelay; |
|
212 } |
|
213 |
|
214 CTlv immediateResponse; |
|
215 TInt returnValue( berTlv.TlvByTagValue( |
|
216 &immediateResponse, KTlvImmediateResponseTag ) ); |
|
217 |
|
218 // Immediate response |
|
219 if ( KErrNotFound != returnValue ) |
|
220 { |
|
221 // Respond immediately |
|
222 displayTextV2.iImmediateRsp = RSat::EImmediateRsp; |
|
223 } |
|
224 else |
|
225 { |
|
226 // Do not respond immediately |
|
227 displayTextV2.iImmediateRsp = RSat::ENoImmediateRsp; |
|
228 } |
|
229 |
|
230 // Text to display |
|
231 displayTextV2.iText.Zero(); |
|
232 |
|
233 CTlv textString; |
|
234 returnValue = berTlv.TlvByTagValue( &textString, |
|
235 KTlvTextStringTag ); |
|
236 |
|
237 if ( KErrNone == returnValue ) |
|
238 { |
|
239 // Text string tag is found, now |
|
240 // check if the text string is null. |
|
241 if ( textString.GetLength() ) |
|
242 { |
|
243 // Convert and set text |
|
244 TSatUtility::SetText( textString, displayTextV2.iText ); |
|
245 } |
|
246 // Text string is a null data object. |
|
247 // Return terminal response immediately. |
|
248 else |
|
249 { |
|
250 TFLOGSTRING("CSAT: CSatNotifyDisplayText::CompleteNotifyL,\ |
|
251 Text string empty"); |
|
252 CreateTerminalRespL( pCmdNumber, |
|
253 RSat::KCmdDataNotUnderstood, KNullDesC16 ); |
|
254 // Indicate Client that response was corrupted |
|
255 ret = KErrCorrupt; |
|
256 } |
|
257 } |
|
258 else |
|
259 { |
|
260 TFLOGSTRING("CSAT: CSatNotifyDisplayText::CompleteNotifyL,\ |
|
261 Test string missing"); |
|
262 CreateTerminalRespL( |
|
263 pCmdNumber, RSat::KErrorRequiredValuesMissing, |
|
264 KNullDesC16 ); |
|
265 // Indicate Client that response was corrupted |
|
266 ret = KErrCorrupt; |
|
267 } |
|
268 |
|
269 // Duration,( optional ) see 3GPP TS 31.111 |
|
270 TSatUtility::FillDurationStructure( |
|
271 berTlv, displayTextV2.iDuration ); |
|
272 |
|
273 // Iconid (optional) |
|
274 TSatUtility::FillIconStructure( |
|
275 berTlv, displayTextV2.iIconId ); |
|
276 |
|
277 } // End of if ( KErrNone == aErrorCode ) |
|
278 else |
|
279 { |
|
280 ret = aErrorCode; |
|
281 } |
|
282 |
|
283 iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret ); |
|
284 |
|
285 } // End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
286 else |
|
287 { |
|
288 TFLOGSTRING("CSAT: CSatNotifyDisplayText::CompleteNotifyL,\ |
|
289 Request not ongoing"); |
|
290 TBuf16<1> additionalInfo; |
|
291 // Request not on, returning response immediately |
|
292 additionalInfo.Append( RSat::KNoSpecificMeProblem ); |
|
293 CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd, |
|
294 additionalInfo ); |
|
295 } |
|
296 |
|
297 return ret; |
|
298 } |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CSatNotifyDisplayText::TerminalResponseL |
|
301 // Called by ETel server, passes terminal response to DOS |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 TInt CSatNotifyDisplayText::TerminalResponseL |
|
305 ( |
|
306 TDes8* aRsp |
|
307 ) |
|
308 { |
|
309 TFLOGSTRING("CSAT: CSatNotifyDisplayText::TerminalResponseL"); |
|
310 |
|
311 TInt ret( KErrNone ); |
|
312 TBuf16<1> additionalInfo; |
|
313 |
|
314 RSat::TDisplayTextRspV1Pckg* aRspPckg = |
|
315 reinterpret_cast<RSat::TDisplayTextRspV1Pckg*>( aRsp ); |
|
316 RSat::TDisplayTextRspV1& rspV1 = ( *aRspPckg ) (); |
|
317 |
|
318 // Get Proactive command number |
|
319 TUint8 pCmdNumber( rspV1.PCmdNumber() ); |
|
320 |
|
321 // Check that general result value is valid |
|
322 if ( ( RSat::KSuccess != rspV1.iGeneralResult ) |
|
323 && ( RSat::KSuccessRequestedIconNotDisplayed != rspV1.iGeneralResult ) |
|
324 && ( RSat::KPSessionTerminatedByUser != rspV1.iGeneralResult ) |
|
325 && ( RSat::KBackwardModeRequestedByUser != rspV1.iGeneralResult ) |
|
326 && ( RSat::KNoResponseFromUser != rspV1.iGeneralResult ) |
|
327 && ( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) |
|
328 && ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult ) |
|
329 ) |
|
330 { |
|
331 TFLOGSTRING("CSAT: CSatNotifyDisplayText::TerminalResponseL,\ |
|
332 Invalid General Result"); |
|
333 // Invalid general result |
|
334 ret = KErrCorrupt; |
|
335 } |
|
336 |
|
337 // If there is ME (Mobile Equipment) error, additional info is needed |
|
338 if ( ( RSat::KMeProblem == rspV1.iInfoType ) ) |
|
339 { |
|
340 // Check the length of additional info |
|
341 if ( rspV1.iAdditionalInfo.Length() != 0 ) |
|
342 { |
|
343 additionalInfo.Append( rspV1.iAdditionalInfo[0] ); |
|
344 } |
|
345 else |
|
346 { |
|
347 TFLOGSTRING("CSAT: CSatNotifyDisplayText::TerminalResponseL,\ |
|
348 Invalid Additional Info"); |
|
349 // Invalid additional info field |
|
350 ret = KErrCorrupt; |
|
351 } |
|
352 } |
|
353 |
|
354 CreateTerminalRespL( pCmdNumber, static_cast< TUint8 >( |
|
355 rspV1.iGeneralResult ), additionalInfo ); |
|
356 |
|
357 return ret; |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CSatNotifyDisplayText::CreateTerminalRespL |
|
362 // Constructs DisplayText specific part of terminal response and calls |
|
363 // DOS to send the actual message. |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 TInt CSatNotifyDisplayText::CreateTerminalRespL |
|
367 ( |
|
368 TUint8 aPCmdNumber, |
|
369 TUint8 aGeneralResult, |
|
370 const TDesC16& aAdditionalInfo |
|
371 ) |
|
372 { |
|
373 TFLOGSTRING("CSAT: CSatNotifyDisplayText::CreateTerminalRespL"); |
|
374 TTlv tlvSpecificData; |
|
375 // Create General Result TLV here |
|
376 tlvSpecificData.AddTag( KTlvResultTag ); |
|
377 // General result |
|
378 tlvSpecificData.AddByte( aGeneralResult ); |
|
379 |
|
380 if ( KMeCurrentlyUnableToProcessCommand == aGeneralResult ) |
|
381 { |
|
382 if ( aAdditionalInfo.Length() > 0 ) |
|
383 { |
|
384 tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[0] ) ); |
|
385 } |
|
386 } |
|
387 |
|
388 // Prepare data |
|
389 iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber; |
|
390 TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag(); |
|
391 // Pack data |
|
392 CSatDataPackage dataPackage; |
|
393 dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data ); |
|
394 // Forward request to the DOS |
|
395 return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( |
|
396 ESatTerminalRsp, &dataPackage ); |
|
397 } |
|
398 |
|
399 // End of file |
|
400 |