1 /* |
|
2 * Copyright (c) 2002-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 "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: It is responsible of parsing of GSM specified supplementary |
|
15 * service requests. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CPHONEGSMSSPARSER_H |
|
21 #define CPHONEGSMSSPARSER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "cphonegsmparserbase.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 /* |
|
30 * SUPPLEMENTARY SERVICE UIDS |
|
31 */ |
|
32 |
|
33 /* |
|
34 * Now follows uids for all supported supplementary services. |
|
35 */ |
|
36 const TUint32 KPhoneUidForwardingAll = |
|
37 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 0 ); |
|
38 const TUint32 KPhoneUidForwardingAllConditional = |
|
39 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 1 ); |
|
40 const TUint32 KPhoneUidForwardingUnconditional = |
|
41 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 2 ); |
|
42 const TUint32 KPhoneUidForwardingNoReply = |
|
43 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 3 ); |
|
44 const TUint32 KPhoneUidForwardingNotReachable = |
|
45 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 4 ); |
|
46 const TUint32 KPhoneUidForwardingBusy = |
|
47 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 5 ); |
|
48 const TUint32 KPhoneUidBarringAllOutgoingCalls = |
|
49 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 6 ); |
|
50 const TUint32 KPhoneUidBarringAllIncomingCalls = |
|
51 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 7 ); |
|
52 const TUint32 KPhoneUidBarringAllServices = |
|
53 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 8 ); |
|
54 const TUint32 KPhoneUidBarringAllOutgoingInternationalCalls = |
|
55 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 9 ); |
|
56 const TUint32 KPhoneUidBarringAllOutgoingInternationalCallsExceptHome = |
|
57 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 10 ); |
|
58 const TUint32 KPhoneUidBarringAllOutgoingServices = |
|
59 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 11 ); |
|
60 const TUint32 KPhoneUidBarringAllIncomingCallsWhenRoaming = |
|
61 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 12 ); |
|
62 const TUint32 KPhoneUidBarringAllIncomingServices = |
|
63 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 13 ); |
|
64 const TUint32 KPhoneUidWaiting = |
|
65 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 14 ); |
|
66 const TUint32 KPhoneUidCallingLineIdentificationPresentation = |
|
67 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 15 ); |
|
68 const TUint32 KPhoneUidCallingLineIdentificationRestriction = |
|
69 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 16 ); |
|
70 const TUint32 KPhoneUidConnectedLinePresentation = |
|
71 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 17 ); |
|
72 const TUint32 KPhoneUidConnectedLinePresentationRestriction = |
|
73 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 18 ); |
|
74 const TUint32 KPhoneUidPassword = |
|
75 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 19 ); |
|
76 const TUint32 KPhoneUidCallingNamePresentation = |
|
77 PHONE_MAKE_UID( KPhoneGsmUidSupplementaryService, 20 ); |
|
78 |
|
79 /** |
|
80 * It defines the maximum lenght of service code. |
|
81 */ |
|
82 const TInt KPhoneGsmSsServiceCodeMaxLength = 5; |
|
83 |
|
84 // CLASS DECLARATION |
|
85 |
|
86 /** |
|
87 * It is responsible of parsing GSM specified supplementary services that |
|
88 * are supported. |
|
89 * |
|
90 * @since 1.0 |
|
91 * @lib phoneparser.lib |
|
92 */ |
|
93 NONSHARABLE_CLASS( CPhoneGsmSsParser ) |
|
94 : public CPhoneGsmParserBase |
|
95 { |
|
96 public: // Types |
|
97 |
|
98 /** |
|
99 * Enumeration for different service types. |
|
100 */ |
|
101 enum TServiceType |
|
102 { |
|
103 EServiceActivation, |
|
104 EServiceDeactivation, |
|
105 EServiceInterrogation, |
|
106 EServiceRegistration, |
|
107 EServiceErasure |
|
108 }; |
|
109 |
|
110 /** |
|
111 * Enumeration for different syntax. |
|
112 * |
|
113 * ESyntaxNotAllowed |
|
114 * Not allowed. |
|
115 * |
|
116 * ESyntaxNoParameters |
|
117 * No parameters. |
|
118 * |
|
119 * SS_code# |
|
120 * |
|
121 * ESyntaxEmptyOrBasicCode |
|
122 * No parameters or empty and basic code. |
|
123 * |
|
124 * SS_code# or SS_code**BB# |
|
125 * |
|
126 * ESyntaxNumberOptBasicCodeOptTimer |
|
127 * Number parameter or number parameter and basic code or |
|
128 * number parameter and basic code and timer or number parameter |
|
129 * and timer. |
|
130 * |
|
131 * SS_code*NN# or SS_code*NN*BB# or SS_code*NN*BB*TT# or |
|
132 * SS_code*NN**TT# |
|
133 * |
|
134 * ESyntaxNumberOptBasicCode |
|
135 * Number parameter or number parameter and basic code. |
|
136 * |
|
137 * SS_code*NN# or SS_code*NN*BB# |
|
138 * |
|
139 * ESyntaxPasswordOptBasicCode |
|
140 * Password or password and basic code. |
|
141 * |
|
142 * SS_code*PPPP# or SS_code*PPPP*BB# |
|
143 * |
|
144 * ESyntaxOptGroupCodePasswordNewPasswordNewPassword |
|
145 * |
|
146 * Register group code and password and new password and |
|
147 * new password. Or same with empty register group. |
|
148 * |
|
149 * SS_code*xxx*PPPP*WWWW*WWWW# |
|
150 * SS_code**PPPP*WWWW*WWWW# |
|
151 * |
|
152 * ESyntaxEmptyOrBasicCode2 |
|
153 * Empty or Basic code |
|
154 * |
|
155 * SS_code# or SS_code*BB# |
|
156 */ |
|
157 enum TServiceSyntax |
|
158 { |
|
159 ESyntaxNotAllowed, |
|
160 ESyntaxNoParameters, |
|
161 ESyntaxEmptyOrBasicCode, |
|
162 ESyntaxNumberOptBasicCodeOptTimer, |
|
163 ESyntaxNumberOptBasicCode, |
|
164 ESyntaxPasswordOptBasicCode, |
|
165 ESyntaxOptGroupCodePasswordNewPasswordNewPassword, |
|
166 ESyntaxEmptyOrBasicCode2 |
|
167 }; |
|
168 |
|
169 public: // Constructors and destructor |
|
170 |
|
171 /** |
|
172 * Two-phased constructor. |
|
173 */ |
|
174 static CPhoneGsmSsParser* NewLC(); |
|
175 |
|
176 /** |
|
177 * Destructor. |
|
178 */ |
|
179 ~CPhoneGsmSsParser(); |
|
180 |
|
181 public: // New functions |
|
182 |
|
183 |
|
184 /** |
|
185 * Pack data to integer. |
|
186 * |
|
187 * @param aResult It will contain packed data. |
|
188 * @param aType type of service. |
|
189 * @param aSyntax syntax of service. |
|
190 */ |
|
191 static void PackData( |
|
192 TUint& aResult, |
|
193 TServiceType aType, |
|
194 TServiceSyntax aSyntax ); |
|
195 |
|
196 /** |
|
197 * Unpack data from integer. |
|
198 * |
|
199 * @param aData packed data. |
|
200 * @param aType type of service. |
|
201 * @param aSyntax syntax of service. |
|
202 */ |
|
203 static void UnpackData( |
|
204 TUint aData, |
|
205 TServiceType& aType, |
|
206 TServiceSyntax& aSyntax ); |
|
207 |
|
208 // from base class CPhoneGsmParserBase |
|
209 |
|
210 /** |
|
211 * From CPhoneGsmParserBase. |
|
212 * Parses ss strings. |
|
213 * |
|
214 * @param aString string to be parser. |
|
215 * @param aResult It will contain result. |
|
216 * @param aOptions It contains options. |
|
217 * @return ETrue iff string parsed successfully. |
|
218 */ |
|
219 TBool ParseL( |
|
220 const TDesC& aString, |
|
221 CPhoneGsmParserResult& aResult, |
|
222 CPhoneGsmOptionContainerBase& aOptions ); |
|
223 |
|
224 private: |
|
225 |
|
226 /** |
|
227 * C++ default constructor. |
|
228 */ |
|
229 CPhoneGsmSsParser(); |
|
230 |
|
231 /** |
|
232 * By default Symbian OS constructor is private. |
|
233 */ |
|
234 void ConstructL(); |
|
235 |
|
236 /** |
|
237 * Handle parameters. |
|
238 */ |
|
239 TBool HandleParametersL( |
|
240 TLex& aInput, |
|
241 CPhoneGsmParserResult& aResult, |
|
242 TServiceSyntax aSyntax ); |
|
243 |
|
244 /** |
|
245 * Handle "not allowed" syntax. |
|
246 */ |
|
247 TBool HandleNotAllowedL( |
|
248 TLex& aInput, |
|
249 CPhoneGsmParserResult& aResult ); |
|
250 |
|
251 /** |
|
252 * Handle "no more parameters" syntax. |
|
253 */ |
|
254 TBool HandleNoParametersL( |
|
255 TLex& aInput, |
|
256 CPhoneGsmParserResult& aResult ); |
|
257 |
|
258 /** |
|
259 * Handle "empty or basic code" syntax. |
|
260 */ |
|
261 TBool HandleEmptyOrBasicCodeL( |
|
262 TLex& aInput, |
|
263 CPhoneGsmParserResult& aResult ); |
|
264 |
|
265 /** |
|
266 * Handle "number optionally basic code and timer" syntax. |
|
267 */ |
|
268 TBool HandleNumberOptBasicCodeOptTimerL( |
|
269 TLex& aInput, |
|
270 CPhoneGsmParserResult& aResult ); |
|
271 |
|
272 /** |
|
273 * Handle "number optionally basic code" syntax. |
|
274 */ |
|
275 TBool HandleNumberOptBasicCodeL( |
|
276 TLex& aInput, |
|
277 CPhoneGsmParserResult& aResult ); |
|
278 |
|
279 /** |
|
280 * Handle "password optionally basic code" syntax. |
|
281 */ |
|
282 TBool HandlePasswordOptBasicCodeL( |
|
283 TLex& aInput, |
|
284 CPhoneGsmParserResult& aResult ); |
|
285 |
|
286 /** |
|
287 * Handle "optionally group code, then old password and new |
|
288 * password twice" syntax. |
|
289 */ |
|
290 TBool HandleOptGroupCodePasswordNewPasswordNewPasswordL( |
|
291 TLex& aInput, |
|
292 CPhoneGsmParserResult& aResult ); |
|
293 |
|
294 /** |
|
295 * Handle "empty or basic code" syntax. |
|
296 */ |
|
297 TBool HandleEmptyOrBasicCode2L( |
|
298 TLex& aInput, |
|
299 CPhoneGsmParserResult& aResult ); |
|
300 |
|
301 /** |
|
302 * Handle "empty parameter" syntax. |
|
303 */ |
|
304 TBool HandleEmptyParameterL( |
|
305 TLex& aInput, |
|
306 CPhoneGsmParserResult& aResult ); |
|
307 |
|
308 /** |
|
309 * Handle "basic code" syntax. |
|
310 */ |
|
311 TBool HandleBasicCodeL( |
|
312 TLex& aInput, |
|
313 CPhoneGsmParserResult& aResult ); |
|
314 |
|
315 /** |
|
316 * Handle "directory number" syntax. |
|
317 */ |
|
318 TBool HandleNumberL( |
|
319 TLex& aInput, |
|
320 CPhoneGsmParserResult& aResult ); |
|
321 |
|
322 /** |
|
323 * Handle "timer" syntax. |
|
324 */ |
|
325 TBool HandleTimerL( |
|
326 TLex& aInput, |
|
327 CPhoneGsmParserResult& aResult ); |
|
328 |
|
329 /** |
|
330 * Handle "password" syntax. |
|
331 */ |
|
332 TBool HandlePasswordL( |
|
333 TLex& aInput, |
|
334 CPhoneGsmParserResult& aResult ); |
|
335 |
|
336 /** |
|
337 * Handle "group code" syntax. |
|
338 */ |
|
339 TBool HandleGroupCodeL( |
|
340 TLex& aInput, |
|
341 CPhoneGsmParserResult& aResult ); |
|
342 |
|
343 /** |
|
344 * Check basic service code. |
|
345 */ |
|
346 TBool CheckBasicCode( const TDesC& aCode ); |
|
347 |
|
348 /** |
|
349 * Check 'no reply timer' |
|
350 */ |
|
351 TBool CheckTimer( const TDesC& aCode ); |
|
352 |
|
353 /** |
|
354 * Check password group code. |
|
355 */ |
|
356 TBool CheckGroupCode( const TDesC& aCode ); |
|
357 |
|
358 /** |
|
359 * Find string (starting from current position) that |
|
360 * contains characters from given string. |
|
361 * |
|
362 * (note that empty string may be returned). |
|
363 */ |
|
364 static TPtrC FindString( |
|
365 TLex& aInput, |
|
366 const TDesC& aAllowedCharacters ); |
|
367 |
|
368 /** |
|
369 * Add a new service. |
|
370 * |
|
371 * SHOULD ONLY BE USED DURING CONSTRUCTION. |
|
372 * |
|
373 * Panics if invalid service description is passed. |
|
374 * |
|
375 * @param aService It is service description. |
|
376 * @param aUid It is uid for the service. |
|
377 */ |
|
378 void AddL( const TDesC& aService, TUint aUid ); |
|
379 |
|
380 /** |
|
381 * Add a new service. |
|
382 * |
|
383 * SHOULD ONLY BE USED DURING CONSTRUCTION. |
|
384 */ |
|
385 void AddServiceL( |
|
386 const TDesC& aServiceCode, |
|
387 TServiceSyntax aActivation, |
|
388 TServiceSyntax aDeactivation, |
|
389 TServiceSyntax aInterrogation, |
|
390 TServiceSyntax aRegistration, |
|
391 TServiceSyntax aErasure, |
|
392 TUint aUid ); |
|
393 |
|
394 /** |
|
395 * Get next number as descriptor. |
|
396 * |
|
397 * ONLY TO BE USED DURING SERVICE DESCRIPTION PARSING. |
|
398 * |
|
399 * Panics if next character (not a space) does not start |
|
400 * a new number or the number is invalid. |
|
401 * |
|
402 * @param aLex It is lex. |
|
403 * @return Returns number. |
|
404 */ |
|
405 static TPtrC NextNumber( TLex& aLex ); |
|
406 |
|
407 /** |
|
408 * Get next number as value. |
|
409 * |
|
410 * ONLY TO BE USED DURING SERVICE DESCRIPTION PARSING. |
|
411 * |
|
412 * Panics if next character (not a space) does not start |
|
413 * a new number or the number is invalid. |
|
414 * |
|
415 * @param aLex It is lex. |
|
416 * @return Returns number as value. |
|
417 */ |
|
418 static TUint NextNumberAsValue( TLex& aLex ); |
|
419 |
|
420 /** |
|
421 * Converts to service syntax. |
|
422 * |
|
423 * @param aService It is numerical value of service syntax. |
|
424 * @return Returns service syntax corresponding to value. |
|
425 */ |
|
426 static TServiceSyntax ConvertToServiceSyntax( TUint aService ); |
|
427 |
|
428 private: // Data |
|
429 |
|
430 /** |
|
431 * It is type for service code. |
|
432 */ |
|
433 typedef TBuf< KPhoneGsmSsServiceCodeMaxLength > TServiceCode; |
|
434 |
|
435 /** |
|
436 * It defines structure containing information about a service. |
|
437 */ |
|
438 class TServiceInfo |
|
439 { |
|
440 public: |
|
441 TServiceCode iCode; |
|
442 TServiceSyntax iActivation; |
|
443 TServiceSyntax iDeactivation; |
|
444 TServiceSyntax iInterrogation; |
|
445 TServiceSyntax iRegistration; |
|
446 TServiceSyntax iErasure; |
|
447 TUint iUid; |
|
448 }; |
|
449 |
|
450 // Type for service code array. |
|
451 typedef CArrayFixFlat< TServiceInfo > CServiceArray; |
|
452 |
|
453 // Owned array of service codes. |
|
454 CServiceArray* iArray; |
|
455 |
|
456 }; |
|
457 |
|
458 #endif // CPHONEGSMSSPARSER_H |
|
459 |
|
460 // End of File |
|