0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include "satutil.h" // sat utility class
|
|
23 |
#include "ber_tlv.h" // ber-tlv classes
|
|
24 |
|
|
25 |
#include <ctsy/serviceapi/cmmsmsutility.h> // ton/npi constants
|
|
26 |
#include "tsylogger.h" // for logging
|
|
27 |
#include <tisi.h> // isi message
|
|
28 |
#include "osttracedefinitions.h"
|
|
29 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
30 |
#include "satutiltraces.h"
|
|
31 |
#endif
|
|
32 |
|
|
33 |
|
|
34 |
// CONSTANTS
|
|
35 |
|
|
36 |
// Transaction id numbers
|
|
37 |
const TUint KSatTransIdMaxCountPlusOne = 255;
|
|
38 |
const TUint8 KTransactionIdMinNumber = 0xC0;
|
|
39 |
|
|
40 |
// Masking
|
|
41 |
const TUint8 KPacked7BitTextMask = 0x0C;
|
|
42 |
|
|
43 |
// Shifting
|
|
44 |
const TUint8 KCrShiftedOneBitToLeft = 0x1A;
|
|
45 |
const TUint8 KSiftedSixTimes = 0x06;
|
|
46 |
const TUint8 KCarriageReturn = 0x0D;
|
|
47 |
|
|
48 |
// Extended table
|
|
49 |
const TUint8 KExtendedTable = 0x1B;
|
|
50 |
|
|
51 |
|
|
52 |
// MODULE DATA STRUCTURES
|
|
53 |
|
|
54 |
// Bcd->ascii translation table
|
|
55 |
static const TUint8 KAscii[16] =
|
|
56 |
{
|
|
57 |
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
58 |
'8', '9', '*', '#', 'p', 'w', '.', 0
|
|
59 |
};
|
|
60 |
|
|
61 |
// GSM 7-bit ->unicode translation table
|
|
62 |
// See 3GPP TS 23.038
|
|
63 |
static const TUint16 KUnicode[128] =
|
|
64 |
{
|
|
65 |
0x0040, 0x00A3, 0x0024, 0x00A5, 0x00E8, 0x00E9, 0x00F9, 0x00EC,
|
|
66 |
0x00F2, 0x00E7, 0x000A, 0x00D8, 0x00F8, 0x000D, 0x00C5, 0x00E5,
|
|
67 |
0x0394, 0x005F, 0x03A6, 0x0393, 0x039B, 0x03A9, 0x03A0, 0x03A8,
|
|
68 |
0x03A3, 0x0398, 0x039E, 0x00A0, 0x00C6, 0x00E6, 0x00DF, 0x00C9,
|
|
69 |
0x0020, 0x0021, 0x0022, 0x0023, 0x00A4, 0x0025, 0x0026, 0x0027,
|
|
70 |
0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
|
|
71 |
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
|
72 |
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
|
|
73 |
0x00A1, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
|
74 |
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
|
|
75 |
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
|
76 |
0x0058, 0x0059, 0x005A, 0x00C4, 0x00D6, 0x00D1, 0x00DC, 0x00A7,
|
|
77 |
0x00BF, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
|
78 |
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
|
|
79 |
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
|
80 |
0x0078, 0x0079, 0x007A, 0x00E4, 0x00F6, 0x00F1, 0x00FC, 0x00E0
|
|
81 |
};
|
|
82 |
|
|
83 |
|
|
84 |
// ==================== MEMBER FUNCTIONS ====================================
|
|
85 |
|
|
86 |
// -----------------------------------------------------------------------------
|
|
87 |
// TTransIdMessage::TTransIdMessage
|
|
88 |
// C++ default constructor can NOT contain any code, that
|
|
89 |
// might leave.
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
TTransIdMessage::TTransIdMessage() : iTransNum(KTransactionIdMinNumber)
|
|
93 |
{
|
|
94 |
OstTrace0( TRACE_NORMAL, TTRANSIDMESSAGE_TTRANSIDMESSAGE, "TTransIdMessage::TTransIdMessage" );
|
|
95 |
}
|
|
96 |
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
// TTransIdMessage::GetTransactionId
|
|
99 |
// Gets a new transactionID
|
|
100 |
// -----------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
TUint8 TTransIdMessage::GetTransactionId()
|
|
103 |
{
|
|
104 |
OstTrace0( TRACE_NORMAL, TTRANSIDMESSAGE_GETTRANSACTIONID, "TTransIdMessage::GetTransactionId" );
|
|
105 |
TFLOGSTRING("TSY: TTransIdMessage::GetTransactionId");
|
|
106 |
// 0xff and 0x00 are
|
|
107 |
// not valid transaction id's and will not be generated. This is done
|
|
108 |
// to avoid generating transaction ids that are used in terminal resp
|
|
109 |
iTransNum++;
|
|
110 |
if ( KSatTransIdMaxCountPlusOne == iTransNum )
|
|
111 |
{
|
|
112 |
iTransNum = KTransactionIdMinNumber;
|
|
113 |
}
|
|
114 |
return iTransNum;
|
|
115 |
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
// TSatUtility::GetTonAndNpi
|
|
120 |
// Map TON and NPI to RSat TON and NPI values
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void TSatUtility::GetTonAndNpi
|
|
124 |
(
|
|
125 |
TInt aTonAndNpi, // TON and NPI
|
|
126 |
RSat::TTypeOfNumber* aTon, // Type of number
|
|
127 |
RSat::TNumberingPlan* aNpi // Number plan identification
|
|
128 |
)
|
|
129 |
{
|
|
130 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_GETTONANDNPI, "TSatUtility::GetTonAndNpi: RSat" );
|
|
131 |
TFLOGSTRING("TSY: TSatUtility::GetTonAndNpi: RSat");
|
|
132 |
|
|
133 |
TInt ton( ( aTonAndNpi >> 4 ) & KTONMask );
|
|
134 |
|
|
135 |
switch ( ton )
|
|
136 |
{
|
|
137 |
case KTonUnknown:
|
|
138 |
*aTon = RSat::EUnknownNumber;
|
|
139 |
break;
|
|
140 |
case KInternationalNumber:
|
|
141 |
*aTon = RSat::EInternationalNumber;
|
|
142 |
break;
|
|
143 |
case KNationalNumber:
|
|
144 |
*aTon = RSat::ENationalNumber;
|
|
145 |
break;
|
|
146 |
case KNetworkSpecificNumber:
|
|
147 |
*aTon = RSat::ENetworkSpecificNumber;
|
|
148 |
break;
|
|
149 |
case KSubscriberNumber:
|
|
150 |
*aTon = RSat::EDedicatedNumber;
|
|
151 |
break;
|
|
152 |
case KAlphanumeric:
|
|
153 |
*aTon = RSat::EAlphanumericNumber;
|
|
154 |
break;
|
|
155 |
case KAbbreviatedNumber:
|
|
156 |
*aTon = RSat::EAbbreviatedNumber;
|
|
157 |
break;
|
|
158 |
default:
|
|
159 |
*aTon = RSat::ETypeOfNumberNotSet;
|
|
160 |
break;
|
|
161 |
}
|
|
162 |
|
|
163 |
// Numbering plan
|
|
164 |
TInt npi( aTonAndNpi & KNPIMask );
|
|
165 |
|
|
166 |
switch ( npi )
|
|
167 |
{
|
|
168 |
case KNpiUnknown:
|
|
169 |
*aNpi = RSat::EUnknownNumberingPlan;
|
|
170 |
break;
|
|
171 |
case KIsdnTelephoneNumPlan:
|
|
172 |
*aNpi = RSat::EIsdnNumberPlan;
|
|
173 |
break;
|
|
174 |
case KDataNumPlan:
|
|
175 |
*aNpi = RSat::EDataNumberPlan;
|
|
176 |
break;
|
|
177 |
case KTelexNumPlan:
|
|
178 |
*aNpi = RSat::ETelexNumberPlan;
|
|
179 |
break;
|
|
180 |
case KNationalNumPlan:
|
|
181 |
*aNpi = RSat::ENationalNumberPlan;
|
|
182 |
break;
|
|
183 |
case KPrivateNumPlan:
|
|
184 |
*aNpi = RSat::EPrivateNumberPlan;
|
|
185 |
break;
|
|
186 |
case KServiceCentreSpecificPlan1:
|
|
187 |
*aNpi = RSat::EServiceCentreSpecificPlan1;
|
|
188 |
break;
|
|
189 |
case KServiceCentreSpecificPlan2:
|
|
190 |
*aNpi = RSat::EServiceCentreSpecificPlan2;
|
|
191 |
break;
|
|
192 |
case KErmesNumPlan:
|
|
193 |
*aNpi = RSat::EERMESNumberPlan;
|
|
194 |
break;
|
|
195 |
default:
|
|
196 |
*aNpi = RSat::ENumberingPlanNotSet;
|
|
197 |
break;
|
|
198 |
}
|
|
199 |
}
|
|
200 |
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
// TSatUtility::GetTonAndNpi
|
|
203 |
// Map TON and NPI to Etel MM TON and NPI values
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
void TSatUtility::GetTonAndNpi
|
|
207 |
(
|
|
208 |
TInt aTonAndNpi,
|
|
209 |
RMobilePhone::TMobileTON& aTon,
|
|
210 |
RMobilePhone::TMobileNPI& aNpi
|
|
211 |
)
|
|
212 |
{
|
|
213 |
OstTrace0( TRACE_NORMAL, DUP1_TSATUTILITY_GETTONANDNPI, "TSatUtility::GetTonAndNpi: Etel MM" );
|
|
214 |
TFLOGSTRING("TSY: TSatUtility::GetTonAndNpi: Etel MM");
|
|
215 |
|
|
216 |
TInt ton( ( aTonAndNpi >> 4 ) & KTONMask );
|
|
217 |
|
|
218 |
switch ( ton )
|
|
219 |
{
|
|
220 |
case KInternationalNumber:
|
|
221 |
aTon = RMobilePhone::EInternationalNumber;
|
|
222 |
break;
|
|
223 |
case KNationalNumber:
|
|
224 |
aTon = RMobilePhone::ENationalNumber;
|
|
225 |
break;
|
|
226 |
case KNetworkSpecificNumber:
|
|
227 |
aTon = RMobilePhone::ENetworkSpecificNumber;
|
|
228 |
break;
|
|
229 |
case KSubscriberNumber:
|
|
230 |
aTon = RMobilePhone::ESubscriberNumber;
|
|
231 |
break;
|
|
232 |
case KAlphanumeric:
|
|
233 |
aTon = RMobilePhone::EAlphanumericNumber;
|
|
234 |
break;
|
|
235 |
case KAbbreviatedNumber:
|
|
236 |
aTon = RMobilePhone::EAbbreviatedNumber;
|
|
237 |
break;
|
|
238 |
case KTonUnknown:
|
|
239 |
default:
|
|
240 |
aTon = RMobilePhone::EUnknownNumber;
|
|
241 |
break;
|
|
242 |
}
|
|
243 |
|
|
244 |
// Numbering plan
|
|
245 |
TInt npi( aTonAndNpi & KNPIMask );
|
|
246 |
|
|
247 |
switch ( npi )
|
|
248 |
{
|
|
249 |
case KIsdnTelephoneNumPlan:
|
|
250 |
aNpi = RMobilePhone::EIsdnNumberPlan;
|
|
251 |
break;
|
|
252 |
case KDataNumPlan:
|
|
253 |
aNpi = RMobilePhone::EDataNumberPlan;
|
|
254 |
break;
|
|
255 |
case KTelexNumPlan:
|
|
256 |
aNpi = RMobilePhone::ETelexNumberPlan;
|
|
257 |
break;
|
|
258 |
case KNationalNumPlan:
|
|
259 |
aNpi = RMobilePhone::ENationalNumberPlan;
|
|
260 |
break;
|
|
261 |
case KPrivateNumPlan:
|
|
262 |
aNpi = RMobilePhone::EPrivateNumberPlan;
|
|
263 |
break;
|
|
264 |
case KServiceCentreSpecificPlan1:
|
|
265 |
aNpi = RMobilePhone::EServiceCentreSpecificPlan1;
|
|
266 |
break;
|
|
267 |
case KServiceCentreSpecificPlan2:
|
|
268 |
aNpi = RMobilePhone::EServiceCentreSpecificPlan2;
|
|
269 |
break;
|
|
270 |
case KErmesNumPlan:
|
|
271 |
aNpi = RMobilePhone::EERMESNumberPlan;
|
|
272 |
break;
|
|
273 |
case KNpiUnknown:
|
|
274 |
default:
|
|
275 |
aNpi = RMobilePhone::EUnknownNumberingPlan;
|
|
276 |
break;
|
|
277 |
}
|
|
278 |
}
|
|
279 |
|
|
280 |
// -----------------------------------------------------------------------------
|
|
281 |
// TSatUtility::Packed7to8Unpacked
|
|
282 |
// Converts 7-bit packed string to 8-bit unpacked format.
|
|
283 |
// -----------------------------------------------------------------------------
|
|
284 |
//
|
|
285 |
void TSatUtility::Packed7to8Unpacked
|
|
286 |
(
|
|
287 |
TPtrC8 aString, //7-bit packed string
|
|
288 |
TDes8& aOutput //8-bit unpacked string
|
|
289 |
)
|
|
290 |
{
|
|
291 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_PACKED7TO8UNPACKED, "TSatUtility::Packed7to8Unpacked" );
|
|
292 |
TFLOGSTRING("TSY: TSatUtility::Packed7to8Unpacked");
|
|
293 |
|
|
294 |
// The string is in packed GSM default alphabet format.
|
|
295 |
// Converted to 8-bit format
|
|
296 |
TUint8 maskRightPartOfCurrentByte( 0x7F );
|
|
297 |
TUint8 shiftLeft( 0 );
|
|
298 |
TUint8 leftPartFromPreviousByte( 0 );
|
|
299 |
aOutput.Zero();
|
|
300 |
for ( TInt i = 0; i < aString.Length(); i++ )
|
|
301 |
{
|
|
302 |
TUint8 leftPartOfCurrentChar = ( aString[i] & maskRightPartOfCurrentByte )
|
|
303 |
<< shiftLeft;
|
|
304 |
|
|
305 |
// append the character in the output text string
|
|
306 |
aOutput.Append( leftPartOfCurrentChar | leftPartFromPreviousByte );
|
|
307 |
// updates
|
|
308 |
if ( KSiftedSixTimes == shiftLeft)
|
|
309 |
{
|
|
310 |
// After 6 shifts, the character is in bit7..bit1, therefore it has to
|
|
311 |
// be shifted one bit to the right.
|
|
312 |
TUint8 character = aString[i] >> 1;
|
|
313 |
|
|
314 |
// Check if this is the end character of USSD string 0x0D
|
|
315 |
TBool lastCharacter( ( i + 1 ) == aString.Length() );
|
|
316 |
if ( !lastCharacter || KCarriageReturn != character )
|
|
317 |
{
|
|
318 |
// Continue unpacking
|
|
319 |
aOutput.Append( character );
|
|
320 |
// Restart
|
|
321 |
leftPartFromPreviousByte = 0;
|
|
322 |
shiftLeft=0;
|
|
323 |
maskRightPartOfCurrentByte = 0x7F;
|
|
324 |
}
|
|
325 |
}
|
|
326 |
else
|
|
327 |
{
|
|
328 |
leftPartFromPreviousByte = (aString[i]) >> (7-shiftLeft);
|
|
329 |
maskRightPartOfCurrentByte = maskRightPartOfCurrentByte>>1;
|
|
330 |
shiftLeft++;
|
|
331 |
}
|
|
332 |
}
|
|
333 |
}
|
|
334 |
|
|
335 |
// -----------------------------------------------------------------------------
|
|
336 |
// TSatUtility::UCSToPacket7
|
|
337 |
// Converts UCS2 string to 7-bit packed format
|
|
338 |
// -----------------------------------------------------------------------------
|
|
339 |
//
|
|
340 |
void TSatUtility::UCSToPacket7
|
|
341 |
(
|
|
342 |
TPtrC aString, //UCS2 string
|
|
343 |
TDes8& aOutput //7-bit packed format output string
|
|
344 |
)
|
|
345 |
{
|
|
346 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_UCSTOPACKET7, "TSatUtility::UCSToPacket7" );
|
|
347 |
TFLOGSTRING("TSY: TSatUtility::UCSToPacket7");
|
|
348 |
|
|
349 |
TBuf8<255> string;
|
|
350 |
TSatUtility::ConvertUnicode16ToSms7( string, aString );
|
|
351 |
|
|
352 |
TUint8 move( 0 );
|
|
353 |
TInt i( 0 );
|
|
354 |
for ( i = 0; i < string.Length(); i += 1 )
|
|
355 |
{
|
|
356 |
// get first character
|
|
357 |
TUint8 char1 = TUint8( string[i] >> move );
|
|
358 |
TUint8 char2;
|
|
359 |
|
|
360 |
if ( ( i + 1 ) < string.Length() )
|
|
361 |
{
|
|
362 |
// get next character
|
|
363 |
char2 = TUint8( string[i + 1] << ( 7 - move ) );
|
|
364 |
}
|
|
365 |
else
|
|
366 |
{
|
|
367 |
// no more characters
|
|
368 |
char2 = 0;
|
|
369 |
}
|
|
370 |
// append packed character
|
|
371 |
aOutput.Append( TUint8( char1 | char2 ) );
|
|
372 |
|
|
373 |
if ( ( 6 == move ) && char2 )
|
|
374 |
{
|
|
375 |
i++;
|
|
376 |
move = 0;
|
|
377 |
}
|
|
378 |
else
|
|
379 |
{
|
|
380 |
move++;
|
|
381 |
}
|
|
382 |
|
|
383 |
}
|
|
384 |
if ( !( ( string.Length() + 1 ) % 8 ) )
|
|
385 |
{
|
|
386 |
// If the total number of characters in the text string equals (8n-1)
|
|
387 |
// where n=1,2,3 etc. then there are 7 spare bits at the end of the
|
|
388 |
// message. To avoid the situation where the receiving entity confuses
|
|
389 |
// 7 binary zero pad bits as the @ character, the carriage return
|
|
390 |
// (i.e. <CR>) character shall be used for padding in this situation,
|
|
391 |
// as defined in TS 23.038.
|
|
392 |
aOutput[ aOutput.Length() - 1 ] =
|
|
393 |
TUint8( aOutput[ aOutput.Length() - 1 ] | KCrShiftedOneBitToLeft );
|
|
394 |
}
|
|
395 |
}
|
|
396 |
|
|
397 |
// -----------------------------------------------------------------------------
|
|
398 |
// TSatUtility::BCDToAscii
|
|
399 |
// Converts BCD string to ASCII format
|
|
400 |
// -----------------------------------------------------------------------------
|
|
401 |
//
|
|
402 |
void TSatUtility::BCDToAscii
|
|
403 |
(
|
|
404 |
TPtrC8 aString, //BCD string
|
|
405 |
TDes8& aOutput //Ascii format output string
|
|
406 |
)
|
|
407 |
{
|
|
408 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_BCDTOASCII, "TSatUtility::BCDToAscii" );
|
|
409 |
TFLOGSTRING("TSY: TSatUtility::BCDToAscii");
|
|
410 |
|
|
411 |
// Convert Abbreviated dialling numbers format back to ASCII format.
|
|
412 |
// See 3GPP TS 11.11, EFadn
|
|
413 |
aOutput.Zero();
|
|
414 |
TInt len( aString.Length() );
|
|
415 |
TInt outputMaxLength( aOutput.MaxLength() );
|
|
416 |
|
|
417 |
for ( TInt i=0; ( i < len ) && ( aOutput.Length()
|
|
418 |
< outputMaxLength ); i++ )
|
|
419 |
{
|
|
420 |
// two bcd string chars are coded in one byte,
|
|
421 |
// 1st char is in low nibble and 2nd is in high nibble
|
|
422 |
// if the high nibble doesn't contain a char it's value is 0xf
|
|
423 |
TUint8 byte = aString[i];
|
|
424 |
aOutput.Append( KAscii[byte & 0xf] );
|
|
425 |
if ( 0xf0 != ( byte & 0xf0 )
|
|
426 |
&& ( aOutput.Length() < outputMaxLength ) )
|
|
427 |
{
|
|
428 |
aOutput.Append( KAscii[byte >> 4] );
|
|
429 |
}
|
|
430 |
}
|
|
431 |
|
|
432 |
if ( aOutput.Length() == outputMaxLength )
|
|
433 |
{
|
|
434 |
OstTrace0( TRACE_NORMAL, DUP1_TSATUTILITY_BCDTOASCII, "TSatUtility::BCDToAscii, probably dropped characters" );
|
|
435 |
OstTraceExt2( TRACE_NORMAL, DUP2_TSATUTILITY_BCDTOASCII, "Input buffer length: %d, possible characters: %d", len, len * 2 );
|
|
436 |
OstTraceExt2( TRACE_NORMAL, DUP3_TSATUTILITY_BCDTOASCII, "Converted characters: %d, dropped: %d", aOutput.Length(), ( len * 2 ) - aOutput.Length() );
|
|
437 |
|
|
438 |
TFLOGSTRING("TSY: TSatUtility::BCDToAscii, \
|
|
439 |
probably dropped characters");
|
|
440 |
TFLOGSTRING3("TSY: Input buffer length: %d, possible characters: %d",
|
|
441 |
len, len * 2 );
|
|
442 |
TFLOGSTRING3("TSY: Converted characters: %d, dropped: %d",
|
|
443 |
aOutput.Length(), ( len * 2 ) - aOutput.Length() );
|
|
444 |
}
|
|
445 |
}
|
|
446 |
|
|
447 |
|
|
448 |
// -----------------------------------------------------------------------------
|
|
449 |
// TSatUtility::RemoveExpansionDigit
|
|
450 |
// Expansion digit '.' from phone number string.
|
|
451 |
// Used in SetUpCall proactive command.
|
|
452 |
// -----------------------------------------------------------------------------
|
|
453 |
//
|
|
454 |
void TSatUtility::RemoveExpansionDigit
|
|
455 |
(
|
|
456 |
TDes8& aPhoneNumber // Number to be converted
|
|
457 |
)
|
|
458 |
|
|
459 |
{
|
|
460 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_REMOVEEXPANSIONDIGIT, "TSatUtility::RemoveExpansionDigit" );
|
|
461 |
TFLOGSTRING("TSY: TSatUtility::RemoveExpansionDigit");
|
|
462 |
|
|
463 |
TInt pos( 0 );
|
|
464 |
|
|
465 |
// Search and delete until no more '.'-characters found
|
|
466 |
while ( KErrNotFound != ( pos = aPhoneNumber.Locate( '.' ) ) )
|
|
467 |
{
|
|
468 |
aPhoneNumber.Delete( pos, 1 );
|
|
469 |
}
|
|
470 |
}
|
|
471 |
|
|
472 |
|
|
473 |
// -----------------------------------------------------------------------------
|
|
474 |
// TSatUtility::AsciiToBCD
|
|
475 |
// Convert ASCII string to binary coded decimal, invalid
|
|
476 |
// characters are dropped and will not be part of bcd string.
|
|
477 |
// -----------------------------------------------------------------------------
|
|
478 |
//
|
|
479 |
void TSatUtility::AsciiToBCD
|
|
480 |
(
|
|
481 |
const TDesC8& aString, //unicode string
|
|
482 |
TDes8& aOutput //binary code decimal output string
|
|
483 |
)
|
|
484 |
{
|
|
485 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_ASCIITOBCD, "TSatUtility::AsciiToBCD" );
|
|
486 |
TFLOGSTRING("TSY: TSatUtility::AsciiToBCD");
|
|
487 |
|
|
488 |
TInt i;
|
|
489 |
TInt outLen( 0 );
|
|
490 |
aOutput.Zero();
|
|
491 |
for ( i = 0; i < aString.Length(); i++ )
|
|
492 |
{
|
|
493 |
// encode as BCD
|
|
494 |
TUint8 bcd;
|
|
495 |
switch ( aString[i] )
|
|
496 |
// do ascii to bcd mapping
|
|
497 |
// See 3GPP TS 11.11, EFadn
|
|
498 |
{
|
|
499 |
case '0': bcd = 0x0; break;
|
|
500 |
case '1': bcd = 0x1; break;
|
|
501 |
case '2': bcd = 0x2; break;
|
|
502 |
case '3': bcd = 0x3; break;
|
|
503 |
case '4': bcd = 0x4; break;
|
|
504 |
case '5': bcd = 0x5; break;
|
|
505 |
case '6': bcd = 0x6; break;
|
|
506 |
case '7': bcd = 0x7; break;
|
|
507 |
case '8': bcd = 0x8; break;
|
|
508 |
case '9': bcd = 0x9; break;
|
|
509 |
case '*': bcd = 0xa; break;
|
|
510 |
case '#': bcd = 0xb; break;
|
|
511 |
case 'p': bcd = 0xc; break; // DTMF
|
|
512 |
case 'w': bcd = 0xd; break; // wild
|
|
513 |
case '.': bcd = 0xe; break; // RFU
|
|
514 |
default: bcd = 0xf; // should never be part of number
|
|
515 |
TFLOGSTRING3("TSY: TSatUtility::AsciiToBCD -- dropped character %d at i=%d", TInt(aString[i]), i );
|
|
516 |
OstTraceExt2( TRACE_NORMAL, DUP1_TSATUTILITY_ASCIITOBCD, "TSatUtility::AsciiToBCD -- dropped character %d at i=%d", TInt(aString[i]), i );
|
|
517 |
|
|
518 |
break;
|
|
519 |
}
|
|
520 |
|
|
521 |
// add only valid bcd characters...
|
|
522 |
if ( 0xf != bcd )
|
|
523 |
{
|
|
524 |
if( aOutput.MaxLength() >= aOutput.Length()+1 )
|
|
525 |
{
|
|
526 |
// store to string
|
|
527 |
if ( 0 == ( outLen%2 ) )
|
|
528 |
{
|
|
529 |
aOutput.Append( bcd );
|
|
530 |
}
|
|
531 |
else
|
|
532 |
{
|
|
533 |
aOutput[outLen/2] |= ( bcd<<4 );
|
|
534 |
}
|
|
535 |
}
|
|
536 |
outLen++;
|
|
537 |
}
|
|
538 |
} // for
|
|
539 |
|
|
540 |
// if odd number of digits add endmark
|
|
541 |
if (0 != ( outLen%2 ))
|
|
542 |
{
|
|
543 |
aOutput[outLen/2] |= 0xf0;
|
|
544 |
}
|
|
545 |
}
|
|
546 |
|
|
547 |
// -----------------------------------------------------------------------------
|
|
548 |
// TSatUtility::SetAlphaId
|
|
549 |
// Set Alpha identifier as a Unicode text string
|
|
550 |
// and according to the alphabet used
|
|
551 |
// -----------------------------------------------------------------------------
|
|
552 |
//
|
|
553 |
void TSatUtility::SetAlphaId
|
|
554 |
(
|
|
555 |
TPtrC8 aRawData, //data
|
|
556 |
TDes& aAlphaId //alpha id
|
|
557 |
)
|
|
558 |
{
|
|
559 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_SETALPHAID, "TSatUtility::SetAlphaId" );
|
|
560 |
TFLOGSTRING("TSY: TSatUtility::SetAlphaId");
|
|
561 |
|
|
562 |
if( aRawData.Length())
|
|
563 |
{
|
|
564 |
if ( ( KUCS2ArabicCoding == aRawData[0] )
|
|
565 |
|| ( KUCS2GreekCoding == aRawData[0] )
|
|
566 |
|| ( KUCS2TurkishCoding == aRawData[0] ) )
|
|
567 |
{
|
|
568 |
ConvertAlphaFieldsToUnicode( aRawData, aAlphaId );
|
|
569 |
}
|
|
570 |
else
|
|
571 |
{
|
|
572 |
// 8-bit
|
|
573 |
TBuf8<RSat::KAlphaIdMaxSize> rawData8;
|
|
574 |
rawData8.Copy( aRawData );
|
|
575 |
ConvertSms7ToUnicode16( aAlphaId, rawData8 );
|
|
576 |
}
|
|
577 |
}
|
|
578 |
else
|
|
579 |
{
|
|
580 |
TFLOGSTRING("TSY: TSatUtility::SetAlphaId, RawData NULL");
|
|
581 |
OstTrace0( TRACE_NORMAL, DUP1_TSATUTILITY_SETALPHAID, "TSatUtility::SetAlphaId, RawData NULL" );
|
|
582 |
|
|
583 |
}
|
|
584 |
}
|
|
585 |
|
|
586 |
// -----------------------------------------------------------------------------
|
|
587 |
// TSatUtility::ConvertToSemiOctet
|
|
588 |
// Convert integer to BCD format. Only two last digits is used.
|
|
589 |
// Example TInt 2004 -> 0x40.
|
|
590 |
// -----------------------------------------------------------------------------
|
|
591 |
//
|
|
592 |
TUint8 TSatUtility::ConvertToSemiOctet
|
|
593 |
(
|
|
594 |
TInt aTime //time
|
|
595 |
)
|
|
596 |
{
|
|
597 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_CONVERTTOSEMIOCTET, "TSatUtility::ConvertToSemiOctet" );
|
|
598 |
TFLOGSTRING("TSY: TSatUtility::ConvertToSemiOctet");
|
|
599 |
|
|
600 |
// Converting given time to meet the TP-Service-Centre-Time-Stamp format in
|
|
601 |
// 3GPP TS 23.040.
|
|
602 |
|
|
603 |
TInt msd( ( aTime / 10 ) % 10 ); // most significant decimal
|
|
604 |
TInt lsd( ( aTime % 10 ) ); // least significant decimal
|
|
605 |
|
|
606 |
return TUint8( ( lsd << 4 ) | ( msd ) );
|
|
607 |
|
|
608 |
}
|
|
609 |
|
|
610 |
// -----------------------------------------------------------------------------
|
|
611 |
// TSatUtility::ConvertSms7ToUnicode16
|
|
612 |
// Convert a text from SMS alphabet to Unicode format.
|
|
613 |
// -----------------------------------------------------------------------------
|
|
614 |
//
|
|
615 |
void TSatUtility::ConvertSms7ToUnicode16
|
|
616 |
(
|
|
617 |
TDes16& aOutput, //unicode format string
|
|
618 |
TDesC8& aInput //input
|
|
619 |
)
|
|
620 |
{
|
|
621 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_CONVERTSMS7TOUNICODE16, "TSatUtility::ConvertSms7ToUnicode16" );
|
|
622 |
TFLOGSTRING( "TSY: TSatUtility::ConvertSms7ToUnicode16" );
|
|
623 |
|
|
624 |
TInt i( 0 );
|
|
625 |
TInt outputMaxLength = aOutput.MaxLength();
|
|
626 |
TInt inputLength = aInput.Length();
|
|
627 |
|
|
628 |
for( i = 0; i < inputLength && outputMaxLength > aOutput.Length(); i++ )
|
|
629 |
{
|
|
630 |
TUint8 character( aInput[i] );
|
|
631 |
|
|
632 |
// This code is an escape to an extension of the 7 bit default alphabet
|
|
633 |
// table.
|
|
634 |
if ( KExtendedTable == character && ( i + 1 != inputLength ) )
|
|
635 |
{
|
|
636 |
// extension table
|
|
637 |
switch ( aInput[i+1] )
|
|
638 |
{
|
|
639 |
case 0x28: // {
|
|
640 |
{
|
|
641 |
aOutput.Append( static_cast<TUint16>( 0x7B ) );
|
|
642 |
break;
|
|
643 |
}
|
|
644 |
case 0x29: // }
|
|
645 |
{
|
|
646 |
aOutput.Append( static_cast<TUint16>( 0x7D ) );
|
|
647 |
break;
|
|
648 |
}
|
|
649 |
case 0x3C: // [
|
|
650 |
{
|
|
651 |
aOutput.Append( static_cast<TUint16>( 0x5B ) );
|
|
652 |
break;
|
|
653 |
}
|
|
654 |
case 0x3E: // ]
|
|
655 |
{
|
|
656 |
aOutput.Append( static_cast<TUint16>( 0x5D ) );
|
|
657 |
break;
|
|
658 |
}
|
|
659 |
case 0x3D: // ~
|
|
660 |
{
|
|
661 |
aOutput.Append( static_cast<TUint16>( 0x7E ) );
|
|
662 |
break;
|
|
663 |
}
|
|
664 |
case 0x2F: /* \ */
|
|
665 |
{
|
|
666 |
aOutput.Append( static_cast<TUint16>( 0x5C ) );
|
|
667 |
break;
|
|
668 |
}
|
|
669 |
case 0x14: // ^
|
|
670 |
{
|
|
671 |
aOutput.Append( static_cast<TUint16>( 0x5E ) );
|
|
672 |
break;
|
|
673 |
}
|
|
674 |
case 0x65: // euro 0x20AC
|
|
675 |
{
|
|
676 |
aOutput.Append( static_cast<TUint16>( 0x20AC ) );
|
|
677 |
break;
|
|
678 |
}
|
|
679 |
case 0x40: // |
|
|
680 |
{
|
|
681 |
aOutput.Append( static_cast<TUint16>( 0x7C ) );
|
|
682 |
break;
|
|
683 |
}
|
|
684 |
case 0x0A: // Form feed
|
|
685 |
{
|
|
686 |
aOutput.Append( static_cast<TUint16>( 0x0C ) );
|
|
687 |
break;
|
|
688 |
}
|
|
689 |
case 0x1B: // Escape to yet another table.
|
|
690 |
{
|
|
691 |
// 3GPP TS 23.038 V6.1.0:
|
|
692 |
// "space until another extension table is defined"
|
|
693 |
aOutput.Append( static_cast<TUint16>( 0x20 ) );
|
|
694 |
break;
|
|
695 |
}
|
|
696 |
default:
|
|
697 |
{
|
|
698 |
// 3GPP TS 23.038 V6.1.0: "In the event that an MS receives
|
|
699 |
// a code where a symbol is not represented in the above
|
|
700 |
// table then the MS shall display the character shown in
|
|
701 |
// the main GSM 7 bit default alphabet table"
|
|
702 |
|
|
703 |
// Check that bit 8 is set to '0'
|
|
704 |
if ( 0x7F >= aInput[i+1] )
|
|
705 |
{
|
|
706 |
// Character is in normal 7-bit table.
|
|
707 |
aOutput.Append( KUnicode[ aInput[i+1] ] );
|
|
708 |
}
|
|
709 |
else
|
|
710 |
{
|
|
711 |
TFLOGSTRING("TSY: TSatUtility::ConvertSms7ToUnicode16, \
|
|
712 |
Character not valid.");
|
|
713 |
OstTrace0( TRACE_NORMAL, DUP1_TSATUTILITY_CONVERTSMS7TOUNICODE16, "TSatUtility::ConvertSms7ToUnicode16, Character not valid." );
|
|
714 |
|
|
715 |
}
|
|
716 |
break;
|
|
717 |
}
|
|
718 |
}
|
|
719 |
// Characters in extension table takes two bytes
|
|
720 |
i++;
|
|
721 |
}
|
|
722 |
// Check that bit 8 is set to '0'
|
|
723 |
else if ( 0x7F >= character )
|
|
724 |
{
|
|
725 |
// Character is in normal 7-bit table.
|
|
726 |
aOutput.Append( KUnicode[ character ] );
|
|
727 |
}
|
|
728 |
else
|
|
729 |
{
|
|
730 |
TFLOGSTRING("TSY: TSatUtility::ConvertSms7ToUnicode16, \
|
|
731 |
Character not valid.");
|
|
732 |
OstTrace0( TRACE_NORMAL, DUP2_TSATUTILITY_CONVERTSMS7TOUNICODE16, "TSatUtility::ConvertSms7ToUnicode16, Character not valid." );
|
|
733 |
|
|
734 |
}
|
|
735 |
}
|
|
736 |
}
|
|
737 |
|
|
738 |
// -----------------------------------------------------------------------------
|
|
739 |
// TSatUtility::ConvertUnicode16ToSms7
|
|
740 |
// Converts unicode16 string to sms 7
|
|
741 |
// -----------------------------------------------------------------------------
|
|
742 |
//
|
|
743 |
void TSatUtility::ConvertUnicode16ToSms7
|
|
744 |
(
|
|
745 |
TDes8& aOutput, // sms 7 string
|
|
746 |
TDesC16& aInput // unicode 16
|
|
747 |
)
|
|
748 |
{
|
|
749 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_CONVERTUNICODE16TOSMS7, "TSatUtility::ConvertUnicode16ToSms7" );
|
|
750 |
TFLOGSTRING("TSY: TSatUtility::ConvertUnicode16ToSms7");
|
|
751 |
|
|
752 |
// A hash table would be useful here instead of switch/case
|
|
753 |
TInt i( 0 );
|
|
754 |
for( i = 0; i < aInput.Length(); i++ )
|
|
755 |
{
|
|
756 |
switch ( aInput[i] )
|
|
757 |
{
|
|
758 |
case 0x0040:
|
|
759 |
aOutput.Append( 0x00 ); /* @ */
|
|
760 |
break;
|
|
761 |
case 0x00A3:
|
|
762 |
aOutput.Append( 0x01 ); /* £ */
|
|
763 |
break;
|
|
764 |
case 0x0024:
|
|
765 |
aOutput.Append( 0x02 ); /* $ */
|
|
766 |
break;
|
|
767 |
case 0x00A5:
|
|
768 |
aOutput.Append( 0x03 ); /* ¥ */
|
|
769 |
break;
|
|
770 |
case 0x00E8:
|
|
771 |
aOutput.Append( 0x04 ); /* è */
|
|
772 |
break;
|
|
773 |
case 0x00E9:
|
|
774 |
aOutput.Append( 0x05 ); /* é */
|
|
775 |
break;
|
|
776 |
case 0x00F9:
|
|
777 |
aOutput.Append( 0x06 ); /* ù */
|
|
778 |
break;
|
|
779 |
case 0x00EC:
|
|
780 |
aOutput.Append( 0x07 ); /* ì */
|
|
781 |
break;
|
|
782 |
case 0x00F2:
|
|
783 |
aOutput.Append( 0x08 ); /* ò */
|
|
784 |
break;
|
|
785 |
case 0x00E7:
|
|
786 |
case 0x00C7:
|
|
787 |
aOutput.Append( 0x09 ); /* Ç */
|
|
788 |
break;
|
|
789 |
case 0x000A:
|
|
790 |
aOutput.Append( 0x0A ); /* LF */
|
|
791 |
break;
|
|
792 |
case 0x00D8:
|
|
793 |
aOutput.Append( 0x0B ); /* Ø */
|
|
794 |
break;
|
|
795 |
case 0x00F8:
|
|
796 |
aOutput.Append( 0x0C ); /* ø */
|
|
797 |
break;
|
|
798 |
case 0x21B5:
|
|
799 |
case 0x000D:
|
|
800 |
case 0x2029: //PARAGRAPH SEPARATOR
|
|
801 |
aOutput.Append( 0x0D ); /* CR */
|
|
802 |
break;
|
|
803 |
case 0x00C5:
|
|
804 |
aOutput.Append( 0x0E ); /* Å */
|
|
805 |
break;
|
|
806 |
case 0x00E5:
|
|
807 |
aOutput.Append( 0x0F ); /* å */
|
|
808 |
break;
|
|
809 |
case 0x0394:
|
|
810 |
aOutput.Append( 0x10 ); /* Greek: DELTA */
|
|
811 |
break;
|
|
812 |
case 0x005F:
|
|
813 |
aOutput.Append( 0x11 ); /* _ */
|
|
814 |
break;
|
|
815 |
case 0x03A6:
|
|
816 |
aOutput.Append( 0x12 ); /* Greek: PHI */
|
|
817 |
break;
|
|
818 |
case 0x0393:
|
|
819 |
aOutput.Append( 0x13 ); /* Greek: GAMMA */
|
|
820 |
break;
|
|
821 |
case 0x039B:
|
|
822 |
aOutput.Append( 0x14 ); /* Greek: LAMDA */
|
|
823 |
break;
|
|
824 |
case 0x03A9:
|
|
825 |
aOutput.Append( 0x15 ); /* Greek: OMEGA */
|
|
826 |
break;
|
|
827 |
case 0x03A0:
|
|
828 |
aOutput.Append( 0x16 ); /* Greek: PI */
|
|
829 |
break;
|
|
830 |
case 0x03A8:
|
|
831 |
aOutput.Append( 0x17 ); /* Greek: PSI */
|
|
832 |
break;
|
|
833 |
case 0x03A3:
|
|
834 |
aOutput.Append( 0x18 ); /* Greek: SIGMA */
|
|
835 |
break;
|
|
836 |
case 0x0398:
|
|
837 |
aOutput.Append( 0x19 ); /* Greek: THETA */
|
|
838 |
break;
|
|
839 |
case 0x039E:
|
|
840 |
aOutput.Append( 0x1A ); /* Greek: XI */
|
|
841 |
break;
|
|
842 |
/*0x1B Extension code */
|
|
843 |
case 0x00C6:
|
|
844 |
aOutput.Append( 0x1C ); /* Æ */
|
|
845 |
break;
|
|
846 |
case 0x00E6:
|
|
847 |
aOutput.Append( 0x1D ); /* æ */
|
|
848 |
break;
|
|
849 |
case 0x00DF:
|
|
850 |
aOutput.Append( 0x1E ); /* beta */
|
|
851 |
break;
|
|
852 |
case 0x00C9:
|
|
853 |
aOutput.Append( 0x1F ); /* É */
|
|
854 |
break;
|
|
855 |
/*0x20 SPACE */
|
|
856 |
/*0x21 - 0x23: Unicode and GSM sets are similar */
|
|
857 |
case 0x00A4:
|
|
858 |
aOutput.Append( 0x24 );
|
|
859 |
break;
|
|
860 |
/*0x25 - 0x3F: Unicode and GSM sets are similar */
|
|
861 |
case 0x00A1:
|
|
862 |
aOutput.Append( 0x40 ); /* ¡ */
|
|
863 |
break;
|
|
864 |
/*0x41 - 0x5A: A..Z */
|
|
865 |
case 0x00C4:
|
|
866 |
aOutput.Append( 0x5B); /* Ä */
|
|
867 |
break;
|
|
868 |
case 0x00D6:
|
|
869 |
aOutput.Append( 0x5C ); /* Ö */
|
|
870 |
break;
|
|
871 |
case 0x00D1:
|
|
872 |
aOutput.Append( 0x5D ); /* Ñ */
|
|
873 |
break;
|
|
874 |
case 0x00DC:
|
|
875 |
aOutput.Append( 0x5E ); /* Ü */
|
|
876 |
break;
|
|
877 |
case 0x00A7:
|
|
878 |
aOutput.Append( 0x5F ); /* § */
|
|
879 |
break;
|
|
880 |
case 0x00BF:
|
|
881 |
aOutput.Append( 0x60 ); /* ¿ */
|
|
882 |
break;
|
|
883 |
/*0x61 - 0x7A: a..z */
|
|
884 |
case 0x00E4:
|
|
885 |
aOutput.Append( 0x7B ); /* ä */
|
|
886 |
break;
|
|
887 |
case 0x00F6:
|
|
888 |
aOutput.Append( 0x7C ); /* ö */
|
|
889 |
break;
|
|
890 |
case 0x00F1:
|
|
891 |
aOutput.Append( 0x7D ); /* ñ */
|
|
892 |
break;
|
|
893 |
case 0x00FC:
|
|
894 |
aOutput.Append( 0x7E ); /* ü */
|
|
895 |
break;
|
|
896 |
case 0x00E0:
|
|
897 |
aOutput.Append( 0x7F ); /* à */
|
|
898 |
break;
|
|
899 |
/*The characters in the list below can be found from 8bit Unicode set
|
|
900 |
but not from GSM character set. Part of them are changed to spaces,
|
|
901 |
part of them to the 'nearest' equivalent (by removing the acute/grave/
|
|
902 |
tilde/etc. marks.*/
|
|
903 |
case 0x00A2: /* Unicode: ¢ */
|
|
904 |
aOutput.Append( 0x63 ); /* GSM: c */
|
|
905 |
break;
|
|
906 |
case 0x00DE: /* Unicode: Latin capital thorn */
|
|
907 |
case 0x00FE: /* Unicode: Latin small thorn */
|
|
908 |
case 0x00F0: /* Unicode: Latin small eth */
|
|
909 |
case 0x00F7: /* Unicode: Unicode: ÷ */
|
|
910 |
case 0x0060: /* Unicode: ' */
|
|
911 |
case 0x007F: /* Unicode: DEL */
|
|
912 |
aOutput.Append( 0x20 ); /* GSM: using SPACE */
|
|
913 |
break;
|
|
914 |
case 0x00C0: /* Unicode: À */
|
|
915 |
case 0x00C1: /* Unicode: Á */
|
|
916 |
case 0x00C2: /* Unicode: Â */
|
|
917 |
case 0x00C3: /* Unicode: Ã */
|
|
918 |
aOutput.Append( 0x41 ); /* GSM: A */
|
|
919 |
break;
|
|
920 |
case 0x00C8: /* Unicode: È */
|
|
921 |
case 0x00CA: /* Unicode: Ê */
|
|
922 |
case 0x00CB: /* Unicode: Ë */
|
|
923 |
aOutput.Append( 0x45 ); /* GSM: E */
|
|
924 |
break;
|
|
925 |
case 0x00CC: /* Unicode: Ì */
|
|
926 |
case 0x00CD: /* Unicode: Í */
|
|
927 |
case 0x00CE: /* Unicode: Î */
|
|
928 |
case 0x00CF: /* Unicode: Ï */
|
|
929 |
aOutput.Append( 0x49 ); /* GSM: I */
|
|
930 |
break;
|
|
931 |
case 0x00D0: /* Unicode: D with line */
|
|
932 |
aOutput.Append( 0x44 ); /* GSM: D */
|
|
933 |
break;
|
|
934 |
case 0x00D2: /* Unicode: Ò */
|
|
935 |
case 0x00D3: /* Unicode: Ó */
|
|
936 |
case 0x00D4: /* Unicode: Ô */
|
|
937 |
case 0x00D5: /* Unicode: Õ */
|
|
938 |
aOutput.Append( 0x4F ); /* GSM: O */
|
|
939 |
break;
|
|
940 |
case 0x00D7: /* Unicode: x (multiplication)*/
|
|
941 |
aOutput.Append( 0x78 ); /* GSM: x */
|
|
942 |
break;
|
|
943 |
case 0x00D9: /* Unicode: Ù */
|
|
944 |
case 0x00DA: /* Unicode: Ú */
|
|
945 |
case 0x00DB: /* Unicode: Û */
|
|
946 |
aOutput.Append( 0x55 ); /* GSM: U */
|
|
947 |
break;
|
|
948 |
case 0x00DD: /* Unicode: Ý */
|
|
949 |
aOutput.Append( 0x59 ); /* GSM: Y */
|
|
950 |
break;
|
|
951 |
case 0x00E1: /* Unicode: á */
|
|
952 |
case 0x00E2: /* Unicode: â */
|
|
953 |
case 0x00E3: /* Unicode: ã */
|
|
954 |
aOutput.Append( 0x61 ); /* GSM: a */
|
|
955 |
break;
|
|
956 |
case 0x00EA: /* Unicode: ê */
|
|
957 |
case 0x00EB: /* Unicode: ë */
|
|
958 |
aOutput.Append( 0x65 ); /* GSM: e */
|
|
959 |
break;
|
|
960 |
case 0x00ED: /* Unicode: í */
|
|
961 |
case 0x00EE: /* Unicode: î */
|
|
962 |
case 0x00EF: /* Unicode: ï */
|
|
963 |
aOutput.Append( 0x69 ); /* GSM: i */
|
|
964 |
break;
|
|
965 |
case 0x00F3: /* Unicode: ó */
|
|
966 |
case 0x00F4: /* Unicode: ô */
|
|
967 |
case 0x00F5: /* Unicode: õ */
|
|
968 |
aOutput.Append( 0x6F ); /* GSM: o */
|
|
969 |
break;
|
|
970 |
case 0x00FA: /* Unicode: ú */
|
|
971 |
case 0x00FB: /* Unicode: û */
|
|
972 |
aOutput.Append( 0x75 ); /* GSM: u */
|
|
973 |
break;
|
|
974 |
case 0x00FD: /* Unicode: ý */
|
|
975 |
case 0x00FF: /* Unicode: ÿ */
|
|
976 |
aOutput.Append( 0x79 ); /* GSM: y */
|
|
977 |
break;
|
|
978 |
// Conversion table GSM 7-Bit Extension to Unicode
|
|
979 |
// See 3GPP TS 23.038
|
|
980 |
case 0x007B:
|
|
981 |
aOutput.Append( 0x1B ); // Extension table
|
|
982 |
aOutput.Append( 0x28 ); /* { */
|
|
983 |
break;
|
|
984 |
case 0x007D:
|
|
985 |
aOutput.Append( 0x1B ); // Extension table
|
|
986 |
aOutput.Append( 0x29 ); /* } */
|
|
987 |
break;
|
|
988 |
case 0x005B:
|
|
989 |
aOutput.Append( 0x1B ); // Extension table
|
|
990 |
aOutput.Append( 0x3C ); /* [ */
|
|
991 |
break;
|
|
992 |
case 0x007E:
|
|
993 |
aOutput.Append( 0x1B ); // Extension table
|
|
994 |
aOutput.Append( 0x3D ); /* ~ */
|
|
995 |
break;
|
|
996 |
case 0x005D:
|
|
997 |
aOutput.Append( 0x1B ); // Extension table
|
|
998 |
aOutput.Append( 0x3E ); /* ] */
|
|
999 |
break;
|
|
1000 |
case 0x005C:
|
|
1001 |
aOutput.Append( 0x1B ); // Extension table
|
|
1002 |
aOutput.Append( 0x2F ); /* \ */
|
|
1003 |
break;
|
|
1004 |
case 0x005E:
|
|
1005 |
aOutput.Append( 0x1B ); // Extension table
|
|
1006 |
aOutput.Append( 0x14 ); /* ^ */
|
|
1007 |
break;
|
|
1008 |
case 0x007C:
|
|
1009 |
aOutput.Append( 0x1B ); // Extension table
|
|
1010 |
aOutput.Append( 0x40 ); /* | */
|
|
1011 |
break;
|
|
1012 |
case 0x20AC:
|
|
1013 |
aOutput.Append( 0x1B ); // Extension table
|
|
1014 |
aOutput.Append( 0x65 ); /* Euro currency symbol */
|
|
1015 |
break;
|
|
1016 |
case 0x000C:
|
|
1017 |
aOutput.Append( 0x1B ); // Extension table
|
|
1018 |
aOutput.Append( 0x0A ); /* Form feed */
|
|
1019 |
break;
|
|
1020 |
default:
|
|
1021 |
// Similar values in Unicode and GSM sets
|
|
1022 |
aOutput.Append( TUint8 ( aInput[i] & 0x00FF ) );
|
|
1023 |
break;
|
|
1024 |
}
|
|
1025 |
}
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
// -----------------------------------------------------------------------------
|
|
1029 |
// TSatUtility::FillDurationStructure
|
|
1030 |
// Fill in a TDuration structure
|
|
1031 |
// -----------------------------------------------------------------------------
|
|
1032 |
//
|
|
1033 |
void TSatUtility::FillDurationStructure
|
|
1034 |
(
|
|
1035 |
CBerTlv& aBerTlv, // Tlv containing duration data
|
|
1036 |
RSat::TDuration& aTDuration // duration structure
|
|
1037 |
)
|
|
1038 |
{
|
|
1039 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_FILLDURATIONSTRUCTURE, "TSatUtility::FillDurationStructure" );
|
|
1040 |
TFLOGSTRING("TSY: TSatUtility::FillDurationStructure");
|
|
1041 |
|
|
1042 |
CTlv duration;
|
|
1043 |
aTDuration.iTimeUnit = RSat::ENoDurationAvailable;
|
|
1044 |
TInt returnValue(
|
|
1045 |
aBerTlv.TlvByTagValue( &duration, KTlvDurationTag ) );
|
|
1046 |
if ( KErrNotFound != returnValue )
|
|
1047 |
{
|
|
1048 |
TUint8 durationTimeUnit = duration.GetShortInfo( ETLV_TimeUnit );
|
|
1049 |
switch ( durationTimeUnit )
|
|
1050 |
{
|
|
1051 |
case KMinutes:
|
|
1052 |
{
|
|
1053 |
// Minutes
|
|
1054 |
aTDuration.iTimeUnit = RSat::EMinutes;
|
|
1055 |
break;
|
|
1056 |
}
|
|
1057 |
case KSeconds:
|
|
1058 |
{
|
|
1059 |
// Seconds
|
|
1060 |
aTDuration.iTimeUnit = RSat::ESeconds;
|
|
1061 |
break;
|
|
1062 |
}
|
|
1063 |
case KTenthsOfSeconds:
|
|
1064 |
{
|
|
1065 |
// Tenths of seconds
|
|
1066 |
aTDuration.iTimeUnit = RSat::ETenthsOfSeconds;
|
|
1067 |
break;
|
|
1068 |
}
|
|
1069 |
default:
|
|
1070 |
{
|
|
1071 |
aTDuration.iTimeUnit = RSat::ETimeUnitNotSet;
|
|
1072 |
}
|
|
1073 |
}
|
|
1074 |
// Time interval
|
|
1075 |
aTDuration.iNumOfUnits = duration.GetShortInfo( ETLV_TimeInteval );
|
|
1076 |
}
|
|
1077 |
}
|
|
1078 |
|
|
1079 |
// -----------------------------------------------------------------------------
|
|
1080 |
// TSatUtility::FillIconStructure
|
|
1081 |
// Fill in a TIconId structure
|
|
1082 |
// -----------------------------------------------------------------------------
|
|
1083 |
//
|
|
1084 |
void TSatUtility::FillIconStructure
|
|
1085 |
(
|
|
1086 |
CBerTlv& aBerTlv, //tlv data containing icon address data
|
|
1087 |
RSat::TIconId& aTIconId, //icon id structure
|
|
1088 |
TInt aItemNmb //item number
|
|
1089 |
)
|
|
1090 |
{
|
|
1091 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_FILLICONSTRUCTURE, "TSatUtility::FillIconStructure" );
|
|
1092 |
TFLOGSTRING("TSY: TSatUtility::FillIconStructure");
|
|
1093 |
|
|
1094 |
CTlv iconId;
|
|
1095 |
aTIconId.iQualifier = RSat::ENoIconId;
|
|
1096 |
TInt returnValue( aBerTlv.TlvByTagValue( &iconId,
|
|
1097 |
KTlvIconIdentifierTag,
|
|
1098 |
aItemNmb ) );
|
|
1099 |
if ( KErrNotFound != returnValue )
|
|
1100 |
{
|
|
1101 |
TUint8 iconQualifier = iconId.GetShortInfo( ETLV_IconQualifier );
|
|
1102 |
aTIconId.iIdentifier = iconId.GetShortInfo( ETLV_IconIdentifier );
|
|
1103 |
// The icon qualifier indicates to the ME how the icon is to be used.
|
|
1104 |
if ( iconQualifier )
|
|
1105 |
{
|
|
1106 |
aTIconId.iQualifier = RSat::ENotSelfExplanatory;
|
|
1107 |
}
|
|
1108 |
else
|
|
1109 |
{
|
|
1110 |
aTIconId.iQualifier = RSat::ESelfExplanatory;
|
|
1111 |
}
|
|
1112 |
}
|
|
1113 |
}
|
|
1114 |
|
|
1115 |
// -----------------------------------------------------------------------------
|
|
1116 |
// TSatUtility::Sw1Sw2Check
|
|
1117 |
// Checks status word 1 and status word 2 bytes coming from Sim server
|
|
1118 |
// -----------------------------------------------------------------------------
|
|
1119 |
//
|
|
1120 |
TInt8 TSatUtility::Sw1Sw2Check
|
|
1121 |
(
|
|
1122 |
TUint8 aSw1, //status word 1
|
|
1123 |
TUint8 aSw2 //status word 2
|
|
1124 |
)
|
|
1125 |
{
|
|
1126 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_SW1SW2CHECK, "TSatUtility::Sw1Sw2Check" );
|
|
1127 |
TFLOGSTRING("TSY: TSatUtility::Sw1Sw2Check");
|
|
1128 |
|
|
1129 |
//These are the ok responses ( for envelope )
|
|
1130 |
//-90 00 normal ending of the command
|
|
1131 |
//-91 XX normal ending of the command with extra information from the
|
|
1132 |
// proactive SIM containing a command for ME length XX of response data
|
|
1133 |
//-9E XX length XX of the response data given in case of a SIM data
|
|
1134 |
// download error
|
|
1135 |
//-9F XX length XX of the response data
|
|
1136 |
//This is the busy response
|
|
1137 |
//-93 00 SAT is busy. Command cannot be executed at present, further
|
|
1138 |
// normal commands are allowed
|
|
1139 |
//This is the memory status
|
|
1140 |
//-92 0X command succesful but after using and internal update retry
|
|
1141 |
// routine x times
|
|
1142 |
//-92 40 memory problem
|
|
1143 |
//Application independent errors
|
|
1144 |
//-67 XX incorrect parameter P3
|
|
1145 |
//-6B XX incorrect parameter P1 or P2
|
|
1146 |
//-6E XX wrong instruction class given in the command
|
|
1147 |
//-6F XX technical problem with no diagnostic given.
|
|
1148 |
//Also possible
|
|
1149 |
//-94 02 P1 or P2 is caused by the addressed record being out of range
|
|
1150 |
|
|
1151 |
TInt8 ret( KError );
|
|
1152 |
switch ( aSw1 )
|
|
1153 |
{
|
|
1154 |
case 0x90:
|
|
1155 |
{
|
|
1156 |
if ( 0x00 != aSw2 )
|
|
1157 |
{
|
|
1158 |
ret = KError;
|
|
1159 |
}
|
|
1160 |
else
|
|
1161 |
{
|
|
1162 |
// This means that feature is allowed.
|
|
1163 |
ret = KAllowed;
|
|
1164 |
}
|
|
1165 |
break;
|
|
1166 |
}
|
|
1167 |
//This might not be possible ( no sub blocks and
|
|
1168 |
//sw1 = 91, 9E or 9F )
|
|
1169 |
case 0x91:
|
|
1170 |
ret = KAllowed;
|
|
1171 |
break;
|
|
1172 |
case 0x9E: // SIM Data Download error
|
|
1173 |
case 0x62: // USIM Data Download error
|
|
1174 |
case 0x63: // USIM Data Download error
|
|
1175 |
ret = KError;
|
|
1176 |
break;
|
|
1177 |
case 0x9F:
|
|
1178 |
ret = KAllowed;
|
|
1179 |
break;
|
|
1180 |
case 0x92:
|
|
1181 |
{
|
|
1182 |
if ( 0x40 == aSw2 )
|
|
1183 |
{
|
|
1184 |
ret = KError;
|
|
1185 |
}
|
|
1186 |
else if ( 0 == (aSw2&0xF0) )
|
|
1187 |
{
|
|
1188 |
// retry command
|
|
1189 |
ret = KAllowed;
|
|
1190 |
}
|
|
1191 |
else
|
|
1192 |
{
|
|
1193 |
ret = KError;
|
|
1194 |
}
|
|
1195 |
break;
|
|
1196 |
}
|
|
1197 |
//There is no "busy" alternative among possible
|
|
1198 |
//general results. Therefore this is set to KError.
|
|
1199 |
case 0x93:
|
|
1200 |
case 0x67:
|
|
1201 |
case 0x6B:
|
|
1202 |
case 0x6E:
|
|
1203 |
case 0x6F:
|
|
1204 |
case 0x94:
|
|
1205 |
default:
|
|
1206 |
{
|
|
1207 |
ret = KError;
|
|
1208 |
break;
|
|
1209 |
}
|
|
1210 |
}
|
|
1211 |
|
|
1212 |
return ret;
|
|
1213 |
}
|
|
1214 |
|
|
1215 |
// -----------------------------------------------------------------------------
|
|
1216 |
// TSatUtility::SetText
|
|
1217 |
// Set Text string as a Unicode text string
|
|
1218 |
// and according to the alphabet used
|
|
1219 |
// -----------------------------------------------------------------------------
|
|
1220 |
//
|
|
1221 |
void TSatUtility::SetText
|
|
1222 |
(
|
|
1223 |
CTlv& aTextString, // text string
|
|
1224 |
TDes& aText // unicode output text string
|
|
1225 |
)
|
|
1226 |
{
|
|
1227 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_SETTEXT, "TSatUtility::SetText" );
|
|
1228 |
TFLOGSTRING("TSY: TSatUtility::SetText");
|
|
1229 |
|
|
1230 |
if ( aTextString.GetLength() )
|
|
1231 |
{
|
|
1232 |
TPtrC8 sourceString;
|
|
1233 |
|
|
1234 |
sourceString.Set( aTextString.GetData( ETLV_TextString ) );
|
|
1235 |
|
|
1236 |
TBuf8<KTextBufferMaxSize> string( sourceString );
|
|
1237 |
// SMS default alphabet DCS
|
|
1238 |
if ( !( aTextString.GetShortInfo( ETLV_DataCodingScheme )
|
|
1239 |
& KPacked7BitTextMask ) )
|
|
1240 |
{
|
|
1241 |
// Unpack
|
|
1242 |
Packed7to8Unpacked( sourceString, string );
|
|
1243 |
|
|
1244 |
if ( aText.MaxLength() < string.Length() )
|
|
1245 |
{
|
|
1246 |
string.SetLength( aText.MaxLength() );
|
|
1247 |
}
|
|
1248 |
|
|
1249 |
// Convert to unicode format
|
|
1250 |
ConvertSms7ToUnicode16( aText, string );
|
|
1251 |
}
|
|
1252 |
// UCS2 DCS
|
|
1253 |
else if ( aTextString.GetShortInfo( ETLV_DataCodingScheme )
|
|
1254 |
& KUCS2DCS )
|
|
1255 |
{
|
|
1256 |
TIsiUtility::CopyFromBigEndian( sourceString, aText );
|
|
1257 |
}
|
|
1258 |
// 8-bit DCS
|
|
1259 |
else if ( aTextString.GetShortInfo( ETLV_DataCodingScheme )
|
|
1260 |
& K8BitDCS )
|
|
1261 |
{
|
|
1262 |
// 8-bit string to 16-bit string
|
|
1263 |
ConvertSms7ToUnicode16( aText, string );
|
|
1264 |
}
|
|
1265 |
else // Reserved cases: SMS default alphabet
|
|
1266 |
{
|
|
1267 |
// Unpack
|
|
1268 |
Packed7to8Unpacked( sourceString, string );
|
|
1269 |
|
|
1270 |
if ( aText.MaxLength() < string.Length() )
|
|
1271 |
{
|
|
1272 |
string.SetLength( aText.MaxLength() );
|
|
1273 |
}
|
|
1274 |
// Convert to unicode format
|
|
1275 |
ConvertSms7ToUnicode16( aText, string );
|
|
1276 |
}
|
|
1277 |
}
|
|
1278 |
else
|
|
1279 |
{
|
|
1280 |
TFLOGSTRING("TSY: TSatUtility::SetText, text string length not valid");
|
|
1281 |
OstTrace0( TRACE_NORMAL, DUP1_TSATUTILITY_SETTEXT, "TSatUtility::SetText, text string length not valid" );
|
|
1282 |
|
|
1283 |
}
|
|
1284 |
}
|
|
1285 |
|
|
1286 |
// -----------------------------------------------------------------------------
|
|
1287 |
// TSatUtility::ConvertAlphaFieldsToUnicode
|
|
1288 |
// Convert Alpha fields format to Unicode format
|
|
1289 |
// -----------------------------------------------------------------------------
|
|
1290 |
//
|
|
1291 |
void TSatUtility::ConvertAlphaFieldsToUnicode
|
|
1292 |
(
|
|
1293 |
TDesC8& aSource,
|
|
1294 |
TDes& aText
|
|
1295 |
)
|
|
1296 |
{
|
|
1297 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_CONVERTALPHAFIELDSTOUNICODE, "TSatUtility::ConvertAlphaFieldsToUnicode" );
|
|
1298 |
TFLOGSTRING("TSY: TSatUtility::ConvertAlphaFieldsToUnicode");
|
|
1299 |
|
|
1300 |
// ArabicCoding, GreekCoding and TurkishCoding have different coding
|
|
1301 |
// methods. There is a tag for each type of alphabet (resp. 80, 81 or 82)
|
|
1302 |
// before the text, and there are base pointers used for expanding 1 byte
|
|
1303 |
// to 2 bytes as required by UCS2
|
|
1304 |
// Ref: 3GPP TS 11.11, Annex B
|
|
1305 |
|
|
1306 |
// Base pointer is a "half-page" in the UCS2 code space
|
|
1307 |
TUint16 basePointer( 0 );
|
|
1308 |
// Offset
|
|
1309 |
TInt x( 0 );
|
|
1310 |
|
|
1311 |
// needed in case of GreekCoding and TurkishCoding to check
|
|
1312 |
// that character amount is not bigger than and actual length of
|
|
1313 |
// the item string.
|
|
1314 |
TInt maxCharAmount( 0 );
|
|
1315 |
|
|
1316 |
TInt ret( KErrNone );
|
|
1317 |
|
|
1318 |
if( aSource.Length() )
|
|
1319 |
{
|
|
1320 |
switch ( aSource[0] )
|
|
1321 |
{
|
|
1322 |
case KUCS2ArabicCoding:
|
|
1323 |
{
|
|
1324 |
// Copy everything after tag byte
|
|
1325 |
TIsiUtility::CopyFromBigEndian
|
|
1326 |
( aSource.Mid( 1, aSource.Length() - 1 ), aText );
|
|
1327 |
//Check if any text present
|
|
1328 |
if ( aText.Length() )
|
|
1329 |
{
|
|
1330 |
// Remove padding bytes if any
|
|
1331 |
if ( 0xFFFF == aText[ aText.Length() - 1 ] )
|
|
1332 |
{
|
|
1333 |
aText.SetLength( aText.Length() - 1 );
|
|
1334 |
}
|
|
1335 |
}
|
|
1336 |
// No expanding needed, already in unicode format.
|
|
1337 |
ret = KErrNotFound;
|
|
1338 |
break;
|
|
1339 |
}
|
|
1340 |
case KUCS2GreekCoding:
|
|
1341 |
{
|
|
1342 |
// Characters starts at position 3
|
|
1343 |
x = 3;
|
|
1344 |
|
|
1345 |
// max character amount is total item string len decremented by 3
|
|
1346 |
// because of 3 first bytes are coding indicator (1 byte),
|
|
1347 |
// character amount (1 byte) and base pointer (1 byte).
|
|
1348 |
maxCharAmount = aSource.Length() - 3;
|
|
1349 |
|
|
1350 |
// Base pointer is given in one byte
|
|
1351 |
// and needs to be sifted 7-bit to left to get correct base pointer
|
|
1352 |
basePointer = TUint16( aSource[2] << 7 ) ;
|
|
1353 |
break;
|
|
1354 |
}
|
|
1355 |
case KUCS2TurkishCoding:
|
|
1356 |
{
|
|
1357 |
// Characters starts at position 4
|
|
1358 |
x = 4;
|
|
1359 |
|
|
1360 |
// max character amount is total item string len decremented by 4
|
|
1361 |
// because of 4 first bytes are coding indicator (1 byte),
|
|
1362 |
// character amount (1 byte) and base pointer (2 bytes).
|
|
1363 |
maxCharAmount = aSource.Length() - 4;
|
|
1364 |
|
|
1365 |
// Base pointer is two bytes, 16-bit
|
|
1366 |
GetWord( basePointer, aSource, 2 );
|
|
1367 |
break;
|
|
1368 |
}
|
|
1369 |
default:
|
|
1370 |
// do nothing
|
|
1371 |
break;
|
|
1372 |
}
|
|
1373 |
}
|
|
1374 |
else
|
|
1375 |
{
|
|
1376 |
TFLOGSTRING("TSY: TSatUtility::ConvertAlphaFieldsToUnicode, Source length NULL ");
|
|
1377 |
OstTrace0( TRACE_NORMAL, DUP1_TSATUTILITY_CONVERTALPHAFIELDSTOUNICODE, "TSatUtility::ConvertAlphaFieldsToUnicode, Source length NULL" );
|
|
1378 |
|
|
1379 |
}
|
|
1380 |
|
|
1381 |
if ( KErrNone == ret && 2 < aSource.Length())
|
|
1382 |
{
|
|
1383 |
// The second octet contains a value indicating the number of
|
|
1384 |
// characters in the string. (Not in the case of Arabic string)
|
|
1385 |
TInt length( aSource[1] );
|
|
1386 |
|
|
1387 |
// let's check that character amount inside item string is not
|
|
1388 |
// bigger than total len of item string
|
|
1389 |
if( maxCharAmount < length )
|
|
1390 |
{
|
|
1391 |
TFLOGSTRING3("TSY: TSatUtility::ConvertAlphaFieldsToUnicode, incorrect char amount: max char amount: %d actual len: %d ", maxCharAmount, length);
|
|
1392 |
OstTraceExt2( TRACE_NORMAL, DUP3_TSATUTILITY_CONVERTALPHAFIELDSTOUNICODE, "TSatUtility::ConvertAlphaFieldsToUnicode, incorrect char amount: max char amount: %d actual len: %d", maxCharAmount, length );
|
|
1393 |
length = maxCharAmount;
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
// Expanding 1 byte format to 2 bytes
|
|
1397 |
while ( length )
|
|
1398 |
{
|
|
1399 |
// If bit 8 of the octet is set to zero, the remaining 7 bits of
|
|
1400 |
// the octet contain a GSM Default Alphabet character, whereas if
|
|
1401 |
// bit 8 of the octet is set to one, the remaining seven bits are
|
|
1402 |
// an offset value added to the base pointer defined in octets
|
|
1403 |
// three and four, and the resultant 16 bit value is a UCS2 code
|
|
1404 |
// point, and defines a UCS2 character.
|
|
1405 |
if ( 0x7F <= aSource[x] )
|
|
1406 |
{
|
|
1407 |
// Append base pointer and offset
|
|
1408 |
aText.Append( basePointer + ( aSource[x] & 0x7F ) );
|
|
1409 |
}
|
|
1410 |
else
|
|
1411 |
{
|
|
1412 |
// GSM default alphabet.
|
|
1413 |
TBuf<1> dest16bit;
|
|
1414 |
TBuf8<1> src7bit;
|
|
1415 |
// Get character
|
|
1416 |
src7bit.Append( aSource[x] );
|
|
1417 |
// Convert GSM default alphabet character to unicode
|
|
1418 |
ConvertSms7ToUnicode16( dest16bit, src7bit );
|
|
1419 |
// Append converted character to output string
|
|
1420 |
aText.Append( dest16bit );
|
|
1421 |
}
|
|
1422 |
x++;
|
|
1423 |
length--;
|
|
1424 |
}
|
|
1425 |
}
|
|
1426 |
else
|
|
1427 |
{
|
|
1428 |
TFLOGSTRING("TSY: TSatUtility::ConvertAlphaFieldsToUnicode, No expanding needed ");
|
|
1429 |
OstTrace0( TRACE_NORMAL, DUP2_TSATUTILITY_CONVERTALPHAFIELDSTOUNICODE, "TSatUtility::ConvertAlphaFieldsToUnicode, No expanding needed" );
|
|
1430 |
|
|
1431 |
}
|
|
1432 |
}
|
|
1433 |
|
|
1434 |
// -----------------------------------------------------------------------------
|
|
1435 |
// TSatUtility::DecodeDcsCbs
|
|
1436 |
// Finds whether the data coding scheme, coded in CBS format,
|
|
1437 |
// is 7-bit, 8-bit or 16-bit. Converts the input DCS from CBS format to SMS
|
|
1438 |
// format. Reference: 3gpp ts 23.038
|
|
1439 |
// -----------------------------------------------------------------------------
|
|
1440 |
//
|
|
1441 |
TSmsDcs TSatUtility::DecodeCbsDcs
|
|
1442 |
(
|
|
1443 |
const TUint8 aDcs
|
|
1444 |
)
|
|
1445 |
{
|
|
1446 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_DECODECBSDCS, "TSatUtility::DecodeCbsDcs" );
|
|
1447 |
TFLOGSTRING("TSY: TSatUtility::DecodeCbsDcs");
|
|
1448 |
|
|
1449 |
// Coding group: 4 left most significant bits
|
|
1450 |
TUint8 codingGroup = (aDcs&0xF0)>>4;
|
|
1451 |
// lower quartet: 4 right most significant bits
|
|
1452 |
TUint8 lowQuartet = (aDcs&0x0F);
|
|
1453 |
// character set: bit 2 and 3, in [bit7...bit0]
|
|
1454 |
TUint8 characterSet = (aDcs&0x0C)>>2;
|
|
1455 |
// Initialize output to Unknown or Reserved
|
|
1456 |
TSmsDcs decodedDcs( ESmsUnknownOrReservedDcs );
|
|
1457 |
// Switch according to the coding group
|
|
1458 |
switch ( codingGroup )
|
|
1459 |
{
|
|
1460 |
// language specified, usually in 7-bit
|
|
1461 |
// b0000 or b0010 or b0011
|
|
1462 |
case 0x00:
|
|
1463 |
case 0x02:
|
|
1464 |
case 0x03:
|
|
1465 |
{
|
|
1466 |
// 7-bit alphabet
|
|
1467 |
decodedDcs = ESms7BitDcs;
|
|
1468 |
break;
|
|
1469 |
}
|
|
1470 |
// b0001
|
|
1471 |
// message preceded by language indication
|
|
1472 |
case 0x01:
|
|
1473 |
{
|
|
1474 |
|
|
1475 |
if ( 0x00 == lowQuartet )
|
|
1476 |
{
|
|
1477 |
decodedDcs = ESms7BitDcs;
|
|
1478 |
}
|
|
1479 |
else if ( 0x01 == lowQuartet )
|
|
1480 |
{
|
|
1481 |
decodedDcs = ESms16BitDcs;
|
|
1482 |
}
|
|
1483 |
break;
|
|
1484 |
}
|
|
1485 |
// General data coding indication
|
|
1486 |
// b01xx or b1001
|
|
1487 |
case 0x04:
|
|
1488 |
case 0x05:
|
|
1489 |
case 0x06:
|
|
1490 |
case 0x07:
|
|
1491 |
case 0x09:
|
|
1492 |
{
|
|
1493 |
// The character set determines the alphabet/compression
|
|
1494 |
if ( 0x00 == characterSet )
|
|
1495 |
{
|
|
1496 |
decodedDcs = ESms7BitDcs;
|
|
1497 |
}
|
|
1498 |
else if ( 0x01 == characterSet )
|
|
1499 |
{
|
|
1500 |
decodedDcs = ESms8BitDcs;
|
|
1501 |
}
|
|
1502 |
else if ( 0x02 == characterSet )
|
|
1503 |
{
|
|
1504 |
decodedDcs = ESms16BitDcs;
|
|
1505 |
}
|
|
1506 |
break;
|
|
1507 |
}
|
|
1508 |
// Data coding / Message handling
|
|
1509 |
// either 8-bit or 7-bit
|
|
1510 |
case 0x0F:
|
|
1511 |
{
|
|
1512 |
// only bit 2 informs about the
|
|
1513 |
// character set.
|
|
1514 |
if ( 0x04 & aDcs )
|
|
1515 |
{
|
|
1516 |
decodedDcs = ESms8BitDcs;
|
|
1517 |
}
|
|
1518 |
else
|
|
1519 |
{
|
|
1520 |
decodedDcs = ESms7BitDcs;
|
|
1521 |
}
|
|
1522 |
break;
|
|
1523 |
}
|
|
1524 |
default:
|
|
1525 |
{
|
|
1526 |
// the DCS value is reserved.
|
|
1527 |
break;
|
|
1528 |
}
|
|
1529 |
}
|
|
1530 |
return decodedDcs;
|
|
1531 |
}
|
|
1532 |
|
|
1533 |
// -----------------------------------------------------------------------------
|
|
1534 |
// TSatUtility::GetWord
|
|
1535 |
// Copies unsigned 16-bit word from source descriptor from location pointed
|
|
1536 |
// by index
|
|
1537 |
// -----------------------------------------------------------------------------
|
|
1538 |
//
|
|
1539 |
void TSatUtility::GetWord
|
|
1540 |
(
|
|
1541 |
TUint16& aTarget, //Target
|
|
1542 |
TDesC8& aSource, //Source
|
|
1543 |
TInt aIndex //Index
|
|
1544 |
)
|
|
1545 |
{
|
|
1546 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_GETWORD, "TSatUtility::GetWord" );
|
|
1547 |
if ( aIndex + 1 < aSource.Length() )
|
|
1548 |
{
|
|
1549 |
aTarget = TUint16( aSource[aIndex] << 8 );
|
|
1550 |
aTarget = TUint16( aTarget | aSource[aIndex + 1] );
|
|
1551 |
}
|
|
1552 |
}
|
|
1553 |
|
|
1554 |
// -----------------------------------------------------------------------------
|
|
1555 |
// TSatUtility::AppendWord
|
|
1556 |
// Copies unsigned 16-bit word to source descriptor
|
|
1557 |
// -----------------------------------------------------------------------------
|
|
1558 |
//
|
|
1559 |
void TSatUtility::AppendWord
|
|
1560 |
(
|
|
1561 |
TUint16 aWord, //Source word
|
|
1562 |
TDes8& aTarget //Target
|
|
1563 |
)
|
|
1564 |
{
|
|
1565 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_APPENDWORD, "TSatUtility::AppendWord" );
|
|
1566 |
if ( aTarget.MaxLength() >= aTarget.Length() + 2 )
|
|
1567 |
{
|
|
1568 |
aTarget.Append( TUint8( aWord >> 8 ) );
|
|
1569 |
aTarget.Append( TUint8( aWord & 0xff ) );
|
|
1570 |
}
|
|
1571 |
}
|
|
1572 |
|
|
1573 |
// -----------------------------------------------------------------------------
|
|
1574 |
// TSatUtility::SetUserLoginAndUserPassword
|
|
1575 |
// Set Text string User Login and User Password data
|
|
1576 |
// -----------------------------------------------------------------------------
|
|
1577 |
//
|
|
1578 |
void TSatUtility::SetUserLoginAndUserPassword
|
|
1579 |
(
|
|
1580 |
CBerTlv& aBerTlv,
|
|
1581 |
RSat::TTextString& aUserLogin,
|
|
1582 |
RSat::TTextString& aUserPassword
|
|
1583 |
)
|
|
1584 |
{
|
|
1585 |
OstTrace0( TRACE_NORMAL, TSATUTILITY_SETUSERLOGINANDUSERPASSWORD, "TSatUtility::SetUserLoginAndUserPassword" );
|
|
1586 |
TFLOGSTRING("TSY: TSatUtility::SetUserLoginAndUserPassword");
|
|
1587 |
|
|
1588 |
// Text string - User Login ( Optional )
|
|
1589 |
CTlv textStringUL;
|
|
1590 |
TInt returnValue( aBerTlv.TlvByTagValue( &textStringUL,
|
|
1591 |
KTlvTextStringTag ) );
|
|
1592 |
// If User Login present
|
|
1593 |
if ( KErrNone == returnValue )
|
|
1594 |
{
|
|
1595 |
TFLOGSTRING("TSY: TSatUtility::SetUserLoginAndUserPassword - User Login");
|
|
1596 |
OstTrace0( TRACE_NORMAL, DUP1_TSATUTILITY_SETUSERLOGINANDUSERPASSWORD, "TSatUtility::SetUserLoginAndUserPassword - User Login" );
|
|
1597 |
|
|
1598 |
// Convert and set text
|
|
1599 |
TSatUtility::SetText( textStringUL, aUserLogin );
|
|
1600 |
}
|
|
1601 |
|
|
1602 |
// Text string - User Password ( Optional )
|
|
1603 |
CTlv textStringUP;
|
|
1604 |
returnValue = aBerTlv.TlvByTagValue( &textStringUP,
|
|
1605 |
KTlvTextStringTag, 1 );
|
|
1606 |
// If User Password present
|
|
1607 |
if ( KErrNone == returnValue )
|
|
1608 |
{
|
|
1609 |
TFLOGSTRING("TSY: TSatUtility::SetUserLoginAndUserPassword - User Password");
|
|
1610 |
OstTrace0( TRACE_NORMAL, DUP2_TSATUTILITY_SETUSERLOGINANDUSERPASSWORD, "TSatUtility::SetUserLoginAndUserPassword - User Password" );
|
|
1611 |
|
|
1612 |
// Convert and set text
|
|
1613 |
TSatUtility::SetText( textStringUP, aUserPassword );
|
|
1614 |
}
|
|
1615 |
}
|
|
1616 |
|
|
1617 |
|
|
1618 |
// End of file
|