0
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2009 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 |
// INCLUDE FILES
|
|
21 |
#include "tssparser.h" // class definition file
|
|
22 |
#include "tsylogger.h"
|
|
23 |
#include "osttracedefinitions.h"
|
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
25 |
#include "tssparsertraces.h"
|
|
26 |
#endif
|
|
27 |
// for TSY logging
|
|
28 |
|
|
29 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
30 |
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
// TSsParser::TSsParser()
|
|
33 |
// C++ default constructor can NOT contain any code, that
|
|
34 |
// might leave.
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
TSsParser::TSsParser()
|
|
38 |
{
|
|
39 |
TFLOGSTRING( "TSY: TSsParser::TSsParser" );
|
|
40 |
OstTrace0( TRACE_NORMAL, TSSPARSER_TSSPARSER, "TSsParser::TSsParser" );
|
|
41 |
iSsOperation = SS_OPERATION_UNDEFINED;
|
|
42 |
iServiceCode = SS_UNKNOWN_SERVICE;
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
// TSsParser::Parse
|
|
48 |
// Parses a SS string
|
|
49 |
// (other items were commented in a header).
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
TInt TSsParser::Parse( const TDesC& aServiceString )
|
|
53 |
{
|
|
54 |
TFLOGSTRING2( "TSY: TSsParser::Parse, servicestring: %S", &aServiceString );
|
|
55 |
OstTraceExt1( TRACE_NORMAL, TSSPARSER_PARSE, "TSsParser::Parse;aServiceString=%S", aServiceString );
|
|
56 |
|
|
57 |
TInt error( KErrNone );
|
|
58 |
|
|
59 |
// at first check that service string is not too long
|
|
60 |
if( MAX_LENGTH_OF_SERVICE_STRING < aServiceString.Length( ) ||
|
|
61 |
0 >= aServiceString.Length( ) )
|
|
62 |
{
|
|
63 |
TFLOGSTRING( "TSY: TSsParser::Parse, error: service string too long or does not exist!" );
|
|
64 |
OstTrace0( TRACE_NORMAL, DUP1_TSSPARSER_PARSE, "TSsParser::Parse, error: service string too long or does not exist!" );
|
|
65 |
error = KErrArgument;
|
|
66 |
}
|
|
67 |
|
|
68 |
else
|
|
69 |
{
|
|
70 |
// copy service string to member variable for parsing
|
|
71 |
iServiceString.Set( aServiceString );
|
|
72 |
// operation type: activation, deactivation, interrogation,
|
|
73 |
// registration or erasure
|
|
74 |
error = ExtractSsOperation( );
|
|
75 |
}
|
|
76 |
|
|
77 |
// If operation was parsed successfully, extract service code
|
|
78 |
if( KErrNone == error )
|
|
79 |
{
|
|
80 |
TPtrC tempBuffer;
|
|
81 |
ExtractPart( tempBuffer );
|
|
82 |
// convert service code to integer
|
|
83 |
iServiceCode = GetInt( tempBuffer );
|
|
84 |
TFLOGSTRING2( "TSY: TSsParser::Parse, service code: %d", iServiceCode );
|
|
85 |
OstTraceExt1( TRACE_NORMAL, DUP2_TSSPARSER_PARSE, "TSsParser::Parse;iServiceCode=%hu", iServiceCode );
|
|
86 |
|
|
87 |
if( SS_UNKNOWN_SERVICE == iServiceCode )
|
|
88 |
{
|
|
89 |
error = KErrArgument;
|
|
90 |
TFLOGSTRING( "TSY: TSsParser::Parse, error: illegal sevice code!" );
|
|
91 |
OstTrace0( TRACE_NORMAL, DUP3_TSSPARSER_PARSE, "TSsParser::Parse, error: illegal sevice code!" );
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
// service code was parsed successfully, extract supplementary infos a,b,c
|
|
96 |
if( KErrNone == error )
|
|
97 |
{
|
|
98 |
TPtrC tempSiBuffer[MAX_NUM_OF_SUPPLEMENTARY_INFOS];
|
|
99 |
TInt i( 0 );
|
|
100 |
TCharacter character( ECharacterIllegal );
|
|
101 |
// 3 supplementary info fields may exists, separated by '*'
|
|
102 |
// and ended by '#'.
|
|
103 |
// possible combinations for supplementary info:
|
|
104 |
// *SIA*SIB*SIC#, *SIA*SIB#, *SIA**SIC#, *SIA#, **SIB*SIC#,
|
|
105 |
// **SIB#, ***SIC#, # (from 3GPP TS 22.030)
|
|
106 |
for( i = 0; i <= MAX_NUM_OF_SUPPLEMENTARY_INFOS; i++ )
|
|
107 |
{
|
|
108 |
character = ExtractSeparator( );
|
|
109 |
if( ECharacterSeparator == character &&
|
|
110 |
i < MAX_NUM_OF_SUPPLEMENTARY_INFOS ) // last mark can't be '*'
|
|
111 |
{
|
|
112 |
ExtractPart( tempSiBuffer[i] );
|
|
113 |
}
|
|
114 |
else if( ECharacterEndMark == character
|
|
115 |
&& !iServiceString.Length() )
|
|
116 |
{
|
|
117 |
// this was the end of string, and there's no more to be parsed
|
|
118 |
break;
|
|
119 |
}
|
|
120 |
else
|
|
121 |
{
|
|
122 |
error = KErrArgument;
|
|
123 |
TFLOGSTRING( "TSY: TSsParser::Parse, error: illegal end mark!" );
|
|
124 |
OstTrace0( TRACE_NORMAL, DUP4_TSSPARSER_PARSE, "TSsParser::Parse, error: illegal end mark!" );
|
|
125 |
break;
|
|
126 |
}
|
|
127 |
}
|
|
128 |
iSupplementaryInfoA.Set( tempSiBuffer[0] );
|
|
129 |
iSupplementaryInfoB.Set( tempSiBuffer[1] );
|
|
130 |
iSupplementaryInfoC.Set( tempSiBuffer[2] );
|
|
131 |
}
|
|
132 |
|
|
133 |
TFLOGSTRING2( "TSY: TSsParser::Parse, SS code: %d", iSsOperation );
|
|
134 |
OstTraceExt1( TRACE_NORMAL, DUP5_TSSPARSER_PARSE, "TSsParser::Parse;iSsOperation=%hhu", iSsOperation );
|
|
135 |
TFLOGSTRING2( "TSY: TSsParser::Parse, SS code: %d", iServiceCode );
|
|
136 |
OstTraceExt1( TRACE_NORMAL, DUP6_TSSPARSER_PARSE, "TSsParser::Parse;iServiceCode=%hu", iServiceCode );
|
|
137 |
TFLOGSTRING2( "TSY: TSsParser::Parse, SS info A: %S", &iSupplementaryInfoA );
|
|
138 |
OstTraceExt1( TRACE_NORMAL, DUP7_TSSPARSER_PARSE, "TSsParser::Parse;iSupplementaryInfoA=%S", iSupplementaryInfoA );
|
|
139 |
TFLOGSTRING2( "TSY: TSsParser::Parse, SS info B: %S", &iSupplementaryInfoB );
|
|
140 |
OstTraceExt1( TRACE_NORMAL, DUP8_TSSPARSER_PARSE, "TSsParser::Parse;iSupplementaryInfoB=%S", iSupplementaryInfoB );
|
|
141 |
TFLOGSTRING2( "TSY: TSsParser::Parse, SS info C: %S", &iSupplementaryInfoC );
|
|
142 |
OstTraceExt1( TRACE_NORMAL, DUP9_TSSPARSER_PARSE, "TSsParser::Parse;iSupplementaryInfoC=%S", iSupplementaryInfoC );
|
|
143 |
TFLOGSTRING2( "TSY: TSsParser::Parse, SS string left: %S", &iServiceString );
|
|
144 |
OstTraceExt1( TRACE_NORMAL, DUP10_TSSPARSER_PARSE, "TSsParser::Parse;iServiceString=%S", iServiceString );
|
|
145 |
|
|
146 |
return error;
|
|
147 |
}
|
|
148 |
|
|
149 |
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
// TSsParser::GetSsOperation
|
|
152 |
// Gets ss operation type
|
|
153 |
// (other items were commented in a header).
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
void TSsParser::GetSsOperation( TUint8& aSsOperation ) const
|
|
157 |
{
|
|
158 |
TFLOGSTRING( "TSY: TSsParser::GetSsOperation" );
|
|
159 |
OstTrace0( TRACE_NORMAL, TSSPARSER_GETSSOPERATION, "TSsParser::GetSsOperation" );
|
|
160 |
aSsOperation = iSsOperation;
|
|
161 |
}
|
|
162 |
|
|
163 |
|
|
164 |
// -----------------------------------------------------------------------------
|
|
165 |
// TSsParser::GetServiceCode
|
|
166 |
// Gets ss code
|
|
167 |
// (other items were commented in a header).
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
void TSsParser::GetServiceCode( TUint16& aServiceCode ) const
|
|
171 |
{
|
|
172 |
TFLOGSTRING("TSY: TSsParser::GetServiceCode" );
|
|
173 |
OstTrace0( TRACE_NORMAL, TSSPARSER_GETSERVICECODE, "TSsParser::GetServiceCode" );
|
|
174 |
aServiceCode = iServiceCode;
|
|
175 |
}
|
|
176 |
|
|
177 |
|
|
178 |
// -----------------------------------------------------------------------------
|
|
179 |
// TSsParser::GetServiceInfo
|
|
180 |
// Gets SS infos a,b and c. If does not exist, empty descriptor is returned
|
|
181 |
// (other items were commented in a header).
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
void TSsParser::GetServiceInfo(
|
|
185 |
TPtrC& aSupplementaryInfoA,
|
|
186 |
TPtrC& aSupplementaryInfoB,
|
|
187 |
TPtrC& aSupplementaryInfoC ) const
|
|
188 |
{
|
|
189 |
TFLOGSTRING( "TSY: TSsParser::GetServiceInfo" );
|
|
190 |
OstTrace0( TRACE_NORMAL, TSSPARSER_GETSERVICEINFO, "TSsParser::GetServiceInfo" );
|
|
191 |
aSupplementaryInfoA.Set( iSupplementaryInfoA );
|
|
192 |
aSupplementaryInfoB.Set( iSupplementaryInfoB );
|
|
193 |
aSupplementaryInfoC.Set( iSupplementaryInfoC );
|
|
194 |
}
|
|
195 |
|
|
196 |
|
|
197 |
// -----------------------------------------------------------------------------
|
|
198 |
// TSsParser::ExtractSsOperation
|
|
199 |
// Parses operation type ( 1 or 2 first elements from service string )
|
|
200 |
// (other items were commented in a header).
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
//
|
|
203 |
TUint8 TSsParser::ExtractSsOperation( )
|
|
204 |
{
|
|
205 |
TFLOGSTRING( "TSY: TSsParser::ExtractSsOperation" );
|
|
206 |
OstTrace0( TRACE_NORMAL, TSSPARSER_EXTRACTSSOPERATION, "TSsParser::ExtractSsOperation" );
|
|
207 |
TInt error( KErrNone );
|
|
208 |
|
|
209 |
// SS operation is one or two first characters in the service string
|
|
210 |
if( iServiceString.Left( 2 ) == KSsOperationErasure )
|
|
211 |
{
|
|
212 |
iSsOperation = SS_ERASURE; // unregister and deactivate
|
|
213 |
iServiceString.Set( iServiceString.Mid( 2 ) ); // extract remaining part
|
|
214 |
TFLOGSTRING2( "TSY: TSsParser::ExtractSsOperation, SS operation: erasure (%d)", iSsOperation );
|
|
215 |
OstTraceExt1( TRACE_NORMAL, DUP1_TSSPARSER_EXTRACTSSOPERATION, "TSsParser::ExtractSsOperation;SS operation: erasure (%hhu)", iSsOperation );
|
|
216 |
}
|
|
217 |
else if( iServiceString.Left( 2 ) == KSsOperationInterrogation )
|
|
218 |
{
|
|
219 |
iSsOperation = SS_INTERROGATION; // check status
|
|
220 |
iServiceString.Set( iServiceString.Mid ( 2 ) );
|
|
221 |
TFLOGSTRING2( "TSY: TSsParser::ExtractSsOperation, SS operation: interrogation (%d)", iSsOperation );
|
|
222 |
OstTraceExt1( TRACE_NORMAL, DUP2_TSSPARSER_EXTRACTSSOPERATION, "TSsParser::ExtractSsOperation;SS operation: interrogation (%hhu)", iSsOperation );
|
|
223 |
}
|
|
224 |
else if( iServiceString.Left( 2 ) == KSsOperationRegistration )
|
|
225 |
{
|
|
226 |
iSsOperation = SS_REGISTRATION; // register and activate
|
|
227 |
iServiceString.Set( iServiceString.Mid( 2 ) );
|
|
228 |
TFLOGSTRING2( "TSY: TSsParser::ExtractSsOperation, SS operation: registration (%d)", iSsOperation );
|
|
229 |
OstTraceExt1( TRACE_NORMAL, DUP3_TSSPARSER_EXTRACTSSOPERATION, "TSsParser::ExtractSsOperation;SS operation: registration (%hhu)", iSsOperation );
|
|
230 |
}
|
|
231 |
else if( iServiceString.Left( 1 ) == KSsOperationActivation )
|
|
232 |
{
|
|
233 |
iSsOperation = SS_ACTIVATION; // activate
|
|
234 |
iServiceString.Set( iServiceString.Mid( 1 ) );
|
|
235 |
TFLOGSTRING2( "TSY: TSsParser::ExtractSsOperation, SS operation: activation (%d)", iSsOperation );
|
|
236 |
OstTraceExt1( TRACE_NORMAL, DUP4_TSSPARSER_EXTRACTSSOPERATION, "TSsParser::ExtractSsOperation;SS operation: activation (%hhu)", iSsOperation );
|
|
237 |
}
|
|
238 |
else if( iServiceString.Left( 1 ) == KSsOperationDeactivation )
|
|
239 |
{
|
|
240 |
iSsOperation = SS_DEACTIVATION; // unregister
|
|
241 |
iServiceString.Set( iServiceString.Mid( 1 ) );
|
|
242 |
TFLOGSTRING2( "TSY: TSsParser::ExtractSsOperation, SS operation: deactivation (%d)", iSsOperation );
|
|
243 |
OstTraceExt1( TRACE_NORMAL, DUP5_TSSPARSER_EXTRACTSSOPERATION, "TSsParser::ExtractSsOperation;SS operation: deactivation (%hhu)", iSsOperation );
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
iSsOperation = SS_OPERATION_UNDEFINED;
|
|
248 |
TFLOGSTRING2( "TSY: TSsParser::ExtractSsOperation, SS operation: undefined (%d)", iSsOperation );
|
|
249 |
OstTraceExt1( TRACE_NORMAL, DUP6_TSSPARSER_EXTRACTSSOPERATION, "TSsParser::ExtractSsOperation;SS operation: undefined (%hhu)", iSsOperation );
|
|
250 |
error = KErrArgument;
|
|
251 |
}
|
|
252 |
|
|
253 |
return error;
|
|
254 |
}
|
|
255 |
|
|
256 |
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
// TSsParser::ExtractPart
|
|
259 |
// Extras individual parts from service string
|
|
260 |
// (other items were commented in a header).
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void TSsParser::ExtractPart( TPtrC& aPart )
|
|
264 |
{
|
|
265 |
TFLOGSTRING( "TSY: TSsParser::ExtractPart" );
|
|
266 |
OstTrace0( TRACE_NORMAL, TSSPARSER_EXTRACTPART, "TSsParser::ExtractPart" );
|
|
267 |
TUint i( 0 );
|
|
268 |
// service code and supplementary info ends to '*' or '#'
|
|
269 |
// if there is no data to be extracted, empty buffer is returned.
|
|
270 |
while( i < iServiceString.Length( ) &&
|
|
271 |
iServiceString[i] != '*' &&
|
|
272 |
iServiceString[i] != '#' )
|
|
273 |
{
|
|
274 |
i++;
|
|
275 |
}
|
|
276 |
// extracted part is returned as reference variable
|
|
277 |
aPart.Set( iServiceString.Left( i ) );
|
|
278 |
TFLOGSTRING2( "TSY: TSsParser::ExtractPart, extracted string: %S", &aPart );
|
|
279 |
OstTraceExt1( TRACE_NORMAL, DUP1_TSSPARSER_EXTRACTPART, "TSsParser::ExtractPart;aPart=%S", aPart );
|
|
280 |
// set remaining part of service string
|
|
281 |
iServiceString.Set( iServiceString.Mid( i ) );
|
|
282 |
}
|
|
283 |
|
|
284 |
|
|
285 |
// -----------------------------------------------------------------------------
|
|
286 |
// TSsParser::ExtractSeparator
|
|
287 |
// Extracts separator marks from service string
|
|
288 |
// (other items were commented in a header).
|
|
289 |
// -----------------------------------------------------------------------------
|
|
290 |
//
|
|
291 |
TCharacter TSsParser::ExtractSeparator( )
|
|
292 |
{
|
|
293 |
TFLOGSTRING( "TSY: TSsParser::ExtractSeparator" );
|
|
294 |
OstTrace0( TRACE_NORMAL, TSSPARSER_EXTRACTSEPARATOR, "TSsParser::ExtractSeparator" );
|
|
295 |
TCharacter mark( ECharacterIllegal );
|
|
296 |
// There should be at least the end mark '#' left in string
|
|
297 |
if( iServiceString.Length() > 0 )
|
|
298 |
{
|
|
299 |
if( '#' == iServiceString[0] )
|
|
300 |
{
|
|
301 |
TFLOGSTRING( "TSY: TSsParser::ExtractSeparator: end mark '#'" );
|
|
302 |
OstTrace0( TRACE_NORMAL, DUP1_TSSPARSER_EXTRACTSEPARATOR, "TSsParser::ExtractSeparator, end mark '#'" );
|
|
303 |
mark = ECharacterEndMark;
|
|
304 |
}
|
|
305 |
else if( '*' == iServiceString[0] )
|
|
306 |
{
|
|
307 |
TFLOGSTRING( "TSY: TSsParser::ExtractSeparator: separator mark '*'" );
|
|
308 |
OstTrace0( TRACE_NORMAL, DUP2_TSSPARSER_EXTRACTSEPARATOR, "TSsParser::ExtractSeparator, separator mark '*'" );
|
|
309 |
mark = ECharacterSeparator;
|
|
310 |
}
|
|
311 |
// no else
|
|
312 |
iServiceString.Set( iServiceString.Mid( 1 ) );
|
|
313 |
}
|
|
314 |
else // end mark was missing
|
|
315 |
{
|
|
316 |
TFLOGSTRING( "TSY: TSsParser::ExtractSeparator: illegal ss string, no end mark!" );
|
|
317 |
OstTrace0( TRACE_NORMAL, DUP3_TSSPARSER_EXTRACTSEPARATOR, "TSsParser::ExtractSeparator, illegal ss string, no end mark!" );
|
|
318 |
}
|
|
319 |
return mark;
|
|
320 |
}
|
|
321 |
|
|
322 |
|
|
323 |
// -----------------------------------------------------------------------------
|
|
324 |
// TSsParser::GetInt
|
|
325 |
// Convert descriptor to integer
|
|
326 |
// (other items were commented in a header).
|
|
327 |
// -----------------------------------------------------------------------------
|
|
328 |
//
|
|
329 |
TInt TSsParser::GetInt( const TDesC& aString )
|
|
330 |
{
|
|
331 |
TFLOGSTRING( "TSY: TSsParser::GetInt" );
|
|
332 |
OstTrace0( TRACE_NORMAL, TSSPARSER_GETINT, "TSsParser::GetInt" );
|
|
333 |
TInt code;
|
|
334 |
|
|
335 |
if( TLex( aString ).Val( code ) != KErrNone)
|
|
336 |
{
|
|
337 |
code = SS_ALL_TELE_AND_BEARER;
|
|
338 |
}
|
|
339 |
|
|
340 |
return code;
|
|
341 |
}
|
|
342 |
|
|
343 |
|
|
344 |
// End of File
|