|
1 /* |
|
2 * Copyright (c) 2004 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: This file contains the header file of the CCbsMessage class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCBSMESSAGE_H |
|
21 #define CCBSMESSAGE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <etelmm.h> |
|
25 #include "CbsReceiverTypes.h" |
|
26 #include "CbsCommon.h" |
|
27 #include "CbsMcnCommon.h" |
|
28 |
|
29 // CONSTANTS |
|
30 // If this constant is set to iPLMN.iMCC, iPLMN does not contain network info |
|
31 _LIT( KRecMessageNoNetworkInfo, "-1" ); |
|
32 |
|
33 /// Defines association element (ISO639-code, language) |
|
34 struct TCbsIso639ToLangMapElement |
|
35 { |
|
36 const TLitC< 3 > iCode; |
|
37 const TCbsDbLanguage iLang; |
|
38 |
|
39 TCbsIso639ToLangMapElement::TCbsIso639ToLangMapElement( |
|
40 const TLitC< 3 > aCode, |
|
41 TCbsDbLanguage aLang ) |
|
42 :iCode( aCode ), |
|
43 iLang( aLang ) { } |
|
44 }; |
|
45 |
|
46 // ISO639 codes defining recognized languages |
|
47 _LIT( KIso639Danish, "DA" ); |
|
48 _LIT( KIso639German, "DE" ); |
|
49 _LIT( KIso639Greek, "EL" ); |
|
50 _LIT( KIso639English, "EN" ); |
|
51 _LIT( KIso639Spanish, "ES" ); |
|
52 _LIT( KIso639Finnish, "FI" ); |
|
53 _LIT( KIso639French, "FR" ); |
|
54 _LIT( KIso639Italian, "IT" ); |
|
55 _LIT( KIso639Dutch, "NL" ); |
|
56 _LIT( KIso639Norwegian, "NO" ); |
|
57 _LIT( KIso639Portuguese, "PT" ); |
|
58 _LIT( KIso639Swedish, "SV" ); |
|
59 _LIT( KIso639Turkish, "TR" ); |
|
60 _LIT( KIso639Hungarian, "HU" ); |
|
61 _LIT( KIso639Polish, "PL" ); |
|
62 _LIT( KIso639Czech, "CS" ); |
|
63 _LIT( KIso639Hebrew, "HE" ); |
|
64 _LIT( KIso639Arabic, "AR" ); |
|
65 _LIT( KIso639Russian, "RU" ); |
|
66 _LIT( KIso639Icelandic, "IS" ); |
|
67 // Amount of languages that are mapped to ISO639 codes. |
|
68 const TInt KNumberOfLanguageMappings = 20; |
|
69 |
|
70 // CB message header size in bytes. |
|
71 const TInt KHeaderLength = 6; |
|
72 |
|
73 // Offset in CB message to index header in characters. |
|
74 const TInt KIndexHeaderPosition = 0; |
|
75 |
|
76 // Index header length in characters (e.g., "EI1<cr><lf>") |
|
77 const TInt KIndexHeaderLength = 5; // including trailing <cr><lf> |
|
78 |
|
79 // Offset to language indication, if applicable |
|
80 const TInt KLanguageIndicationPosition = 0; |
|
81 |
|
82 // Fixed length of language indication preceding message body |
|
83 const TInt KLanguageIndicationLength = 3; |
|
84 |
|
85 // Fixed length of language indication without trailing CR. |
|
86 const TInt KLanguageIndicationLengthWithoutCR = 2; |
|
87 |
|
88 // Geographical scope of CB message: cell wide / immediate display |
|
89 const TInt KGeographicalScopeCellImmediate = 0x00; |
|
90 |
|
91 // Geographical scope of CB message: operator wide / normal display |
|
92 const TInt KGeographicalScopePLMNNormal = 0x01; |
|
93 |
|
94 // Geographical scope of CB message: location area wide / normal display |
|
95 const TInt KGeographicalScopeLACNormal = 0x02; |
|
96 |
|
97 // Geographical scope of CB message: cell wide / normal display |
|
98 const TInt KGeographicalScopeCellNormal = 0x03; |
|
99 |
|
100 // Message code of an index message. |
|
101 const TUint16 KIndexMessageCode = 0x02AA; // 1010101010b |
|
102 |
|
103 const TUint8 KPageParameterSingle = 0x11; // this page: 1, total pages: 1 |
|
104 |
|
105 // ETSI DCS specification |
|
106 const TUint8 DCS_MASK_GENERAL_DATA_CODING_INDICATION = 0xcc; |
|
107 const TUint8 DCS_MASK_MESSAGE_HANDLING = 0xf4; |
|
108 const TUint8 DCS_MASK_LANGUAGE_INDICATION_PRECEDES = 0xff; |
|
109 const TUint8 DCS_GDCI_8BIT = 0x44; |
|
110 const TUint8 DCS_GDCI_UCS2 = 0x48; |
|
111 const TUint8 DCS_DCMH_8BIT = 0xf4; |
|
112 const TUint8 DCS_MPLI_UCS2 = 0x11; |
|
113 const TUint16 KMessageCodeMask = 0x3FF0; |
|
114 const TUint8 DCS_MASK_UDH = 0x9c; |
|
115 const TUint8 DCS_UDH_8BIT = 0x94; |
|
116 |
|
117 const TUint8 DCS_MASK_CLASS0 = 0xd3; |
|
118 const TUint8 DCS_CLASS0 = 0x50; |
|
119 |
|
120 // Message identifier value indicating that the message contains |
|
121 // a base station identity. |
|
122 const TUint16 KCbsBaseStationId = 50; |
|
123 |
|
124 // Information on Data Coding Scheme values. |
|
125 // Refer to ETSI GSM 03.38 for details. |
|
126 enum |
|
127 { |
|
128 // Bits 4-7 0000: Language specified with bits 0-3, default alphabet. |
|
129 ECbsRecLanguageGerman = 0, |
|
130 ECbsRecLanguageEnglish = 1, |
|
131 ECbsRecLanguageItalian = 2, |
|
132 ECbsRecLanguageFrench = 3, |
|
133 ECbsRecLanguageSpanish = 4, |
|
134 ECbsRecLanguageDutch = 5, |
|
135 ECbsRecLanguageSwedish = 6, |
|
136 ECbsRecLanguageDanish = 7, |
|
137 ECbsRecLanguagePortuguese = 8, |
|
138 ECbsRecLanguageFinnish = 9, |
|
139 ECbsRecLanguageNorwegian = 10, |
|
140 ECbsRecLanguageGreek = 11, |
|
141 ECbsRecLanguageTurkish = 12, |
|
142 ECbsRecLanguageHungarian = 13, |
|
143 ECbsRecLanguagePolish = 14, |
|
144 ECbsRecLanguageUnspecified = 15, |
|
145 // Bits 4-7 0001: Message preceded by language indication, |
|
146 // default or UCS2 alphabet. |
|
147 ECbsRecDCSDefaultMsgPrecededByLanguage = 16, |
|
148 ECbsRecDCSUCS2MsgPrecededByLanguage = 17, |
|
149 // Bits 4-7 0010: Czech language, reservations for European languages |
|
150 // using the default alphabet. |
|
151 ECbsRecLanguageCzech = 32, |
|
152 ECbsRecLanguageHebrew = 33, |
|
153 ECbsRecLanguageArabic = 34, |
|
154 ECbsRecLanguageRussian = 35, |
|
155 ECbsRecLanguageIcelandic = 36, |
|
156 // Bits 4-7 0011: Reserved for European languages using the default |
|
157 // alphabet, with unspecified handling at the MS. |
|
158 // Max value of language enum, this MUST remain as last |
|
159 ECbsRecLanguageMax = 100 |
|
160 }; |
|
161 |
|
162 // Message types, GSM, WCDMA, Livecast |
|
163 enum TCbsMessageType |
|
164 { |
|
165 ECbsMessageGsm, |
|
166 ECbsMessageWcdma, |
|
167 ECbsMessageLivecast, |
|
168 ECbsMessageTypeUnspecified |
|
169 }; |
|
170 |
|
171 |
|
172 // CLASS DECLARATION |
|
173 |
|
174 /** |
|
175 * CCbsMessage is the base class for GSM anf WCDMA message classes. |
|
176 * |
|
177 */ |
|
178 class CCbsMessage : public CBase |
|
179 { |
|
180 public: |
|
181 |
|
182 /** |
|
183 * Virtual destructor |
|
184 */ |
|
185 virtual ~CCbsMessage(); |
|
186 |
|
187 public: |
|
188 /** |
|
189 * Returns the type of the message (only in WCDMA) |
|
190 * |
|
191 * @return Type of this message |
|
192 */ |
|
193 virtual TInt MessageType() const = 0; |
|
194 |
|
195 /** |
|
196 * Returns ETrue, if this message is a child subindex message. |
|
197 * |
|
198 * Child subindex messages have message code 1010101010b and |
|
199 * message identifier other than 0. |
|
200 * |
|
201 * @return ETrue, if the message is child subindex |
|
202 */ |
|
203 virtual TBool IsChildSubindex() const; |
|
204 |
|
205 /** |
|
206 * Returns ETrue, if this message is a livecast message. |
|
207 * |
|
208 * |
|
209 * @return ETrue, if the message is livecast message |
|
210 */ |
|
211 |
|
212 TBool IsLivecastMessage() const; |
|
213 |
|
214 /** |
|
215 * Returns the message code of the message. |
|
216 * |
|
217 * @return Message Code. |
|
218 */ |
|
219 TCbsRecMessageCode MessageCode() const; |
|
220 |
|
221 /** |
|
222 * Returns the update number of the message. |
|
223 * |
|
224 * @return Update Number. |
|
225 */ |
|
226 TCbsRecUpdateNumber UpdateNumber() const; |
|
227 |
|
228 /** |
|
229 * Returns the alphabet set of this message. |
|
230 * |
|
231 * Possible values are: |
|
232 * |
|
233 * ECbsRecAlphabetDefault 7-bit GSM encoding |
|
234 * ECbsRecAlphabet8bit 8-bit data, unknown encoding |
|
235 * ECbsRecAlphabetUCS2 16-bit, UCS-2 encoding |
|
236 * ECbsRecAlphabetUnspecified Unknown encoding |
|
237 * |
|
238 * @return Alphabet |
|
239 */ |
|
240 TCbsRecAlphabet Alphabet() const; |
|
241 |
|
242 /** |
|
243 * Appends another message's content to this message's content. |
|
244 * |
|
245 * @param aMsg Message that is appended |
|
246 * to this msg. |
|
247 */ |
|
248 void AppendContent( const TDesC& aMsg ); |
|
249 |
|
250 /** |
|
251 * Appends another 8-bit message's content to this message's content. |
|
252 * |
|
253 * @param aMsg Message that is appended |
|
254 * to this msg. |
|
255 */ |
|
256 void AppendContent8( const TDesC8& aMsg ); |
|
257 |
|
258 /** |
|
259 * Returns identifier of the cell in which the phone was when this |
|
260 * message was received. |
|
261 * |
|
262 * @return Cell identifier |
|
263 */ |
|
264 TUint CellId() const; |
|
265 |
|
266 /** |
|
267 * Returns a pointer descriptor to the Unicode contents of the |
|
268 * message. |
|
269 * |
|
270 * Panics if 16-bit presentation is not prepared. |
|
271 * |
|
272 * @return Pointer descriptor to the contents of |
|
273 * the message. |
|
274 */ |
|
275 const TDesC& Contents() const; |
|
276 |
|
277 /** |
|
278 * Returns a pointer descriptor to 8-bit descriptor representation |
|
279 * of the message body. Panics if 8-bit representation |
|
280 * is not prepared. |
|
281 * |
|
282 * @return Pointer descriptor to the 8-bit |
|
283 * representation of this message's body. |
|
284 */ |
|
285 const TDesC8& Contents8() const; |
|
286 |
|
287 /** |
|
288 * Returns the Data Coding Scheme of this message page. |
|
289 * |
|
290 * Refer to GSM specification 03.38 for details on DCS. |
|
291 * |
|
292 * @return Data Coding Scheme. |
|
293 */ |
|
294 TCbsRecDCS DCS() const; |
|
295 |
|
296 /** |
|
297 * Returns the geographical scope of the message. |
|
298 * |
|
299 * @return Geographical scope. |
|
300 */ |
|
301 TCbsRecGeographicalScope GeographicalScope() const; |
|
302 |
|
303 /** |
|
304 * On return, aNetworkId contains identity of the network |
|
305 * in which the phone was when this message was received. |
|
306 * |
|
307 * @param aNetworkInfo Returns: Operator information |
|
308 */ |
|
309 void GetPLMN( RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo ) const; |
|
310 |
|
311 /** |
|
312 * Returns ETrue, if this message is a Class 0 message according |
|
313 * to ETSI GSM specification 03.38. |
|
314 */ |
|
315 TBool IsClass0() const; |
|
316 |
|
317 /** |
|
318 * Returns ETrue, if the message is compressed. |
|
319 * |
|
320 * @return ETrue, if the message is compressed. |
|
321 */ |
|
322 TBool IsCompressed() const; |
|
323 |
|
324 /** |
|
325 * Returns boolean value indicating if this is the index message. |
|
326 * |
|
327 * Index messages have message code 1010101010b. |
|
328 * |
|
329 * Refer to GSM specifications to for details. |
|
330 * |
|
331 * @return Boolean value indicating if this is |
|
332 * an index message. |
|
333 */ |
|
334 TBool IsIndexMessage() const; |
|
335 |
|
336 /** |
|
337 * Returns the key of the message (serial number). |
|
338 * |
|
339 * Refer to GSM specifications for details. |
|
340 * |
|
341 * @return Key of the message. |
|
342 */ |
|
343 TCbsDbMessageKey Key() const; |
|
344 |
|
345 /** |
|
346 * Returns the LAC (Location Area Code) of the area where the phone |
|
347 * was when this message was received. |
|
348 * |
|
349 * @return Location area code |
|
350 */ |
|
351 TUint LAC() const; |
|
352 |
|
353 /** |
|
354 * Returns the language in which the message is written. |
|
355 * |
|
356 * Function will panic, if the language has not been resolved |
|
357 * with ResolveLanguage(). |
|
358 * |
|
359 * @return The language of the message. |
|
360 */ |
|
361 TCbsDbLanguage Language() const; |
|
362 |
|
363 /** |
|
364 * Determines and returns the language of this message |
|
365 * based on first two characters of message content. |
|
366 * Assumes that the message content contains language |
|
367 * indication and that the content has been decoded |
|
368 * into UCS-2 representation. |
|
369 * |
|
370 * @returns Language of the message |
|
371 */ |
|
372 TCbsDbLanguage LanguagePrecedingMessage() const; |
|
373 |
|
374 /** |
|
375 * Determines and returns the language of this message |
|
376 * based on DCS value. Assumes that the same DCS value |
|
377 * indicates, that the language can be determined in this |
|
378 * way (and not from message content). |
|
379 * |
|
380 * @returns Language of the message |
|
381 */ |
|
382 TCbsDbLanguage LanguageWithDefaultAlphabet() const; |
|
383 |
|
384 /** |
|
385 * Returns the 16-bit representation of the message |
|
386 * contents. |
|
387 * |
|
388 * @returns Message contents |
|
389 */ |
|
390 HBufC* Message() const; |
|
391 |
|
392 /** |
|
393 * Returns the 8-bit representation of the message |
|
394 * contents. |
|
395 * |
|
396 * @returns Message contents |
|
397 */ |
|
398 HBufC8* Message8() const; |
|
399 |
|
400 /** |
|
401 * Returns the message class of the message. |
|
402 * |
|
403 * @return Message Class. |
|
404 */ |
|
405 TInt MessageClass() const; |
|
406 |
|
407 /** |
|
408 * Returns ECbsRecLanguageIndicationBody, if message's content is |
|
409 * preceded by language indication (see GSM 03.38). |
|
410 * |
|
411 * Return values: |
|
412 * ECbsRecLanguageIndicationHeader Language indicated by the message |
|
413 * header DCS value |
|
414 * ECbsRecLanguageIndicationBody Language indicated by |
|
415 * a two-character prefix in message |
|
416 * body. |
|
417 * |
|
418 * @return Indication location. |
|
419 */ |
|
420 TCbsRecLanguageIndication MessagePrecededByLanguageIndication() const; |
|
421 |
|
422 /** |
|
423 * Returns the network mode (GSM/WCDMA) of this message page. |
|
424 * |
|
425 * @return Network in which this message was |
|
426 * received (GSM/WCDMA). |
|
427 */ |
|
428 TCbsNetworkMode NetworkMode() const; |
|
429 |
|
430 /** |
|
431 * Returns the page parameter of this message page. |
|
432 * |
|
433 * Total and this page -fields can be accessed with |
|
434 * methods TotalPages() and ThisPage(). |
|
435 * |
|
436 * @return Page Parameter. |
|
437 */ |
|
438 TCbsRecPageParameter PageParameter() const; |
|
439 |
|
440 /** |
|
441 * Frees the memory allocated for 8-bit representation of message |
|
442 * content. |
|
443 */ |
|
444 void ReleaseEightBitRepresentation(); |
|
445 |
|
446 /** |
|
447 * Removes any index header prefix from the message body. |
|
448 * |
|
449 * This method assumes that the index header is contained in the |
|
450 * first line of message body. This line, including trailing <cr><lf> |
|
451 * is removed. |
|
452 * |
|
453 * Index header prefix is assumed to contain "EIn<cr><lf>", where n |
|
454 * specifies the version number this index message claims to |
|
455 * follow and <cr><lf> is a carriage return + line feed. |
|
456 * |
|
457 * It is also assumed that any language indication prefix has |
|
458 * already been removed prior to this operation. |
|
459 * |
|
460 * Message must be in UCS-2 representation. |
|
461 * |
|
462 * Leave reasons: |
|
463 * KErrUnderflow Message is too short to contain index header. |
|
464 */ |
|
465 void RemoveIndexHeaderL(); |
|
466 |
|
467 /** |
|
468 * Removes language indication field from the message body. |
|
469 * |
|
470 * Presence of an indication is verified with the DCS value |
|
471 * according to ETSI specifications. Message is assumed to |
|
472 * contain valid indication, i.e., three bytes preceding the message |
|
473 * body specifying the language code. |
|
474 * |
|
475 * The correctness of this operation is not checked. If the |
|
476 * indication is invalid, the message body is likely to either have |
|
477 * a couple of characters too many or few. |
|
478 * |
|
479 * Message is assumed to be decoded into UCS-2. |
|
480 * |
|
481 * Leave reasons: |
|
482 * KErrUnderflow Message is too short to contain language indication. |
|
483 */ |
|
484 void RemoveLanguageIndicationFromBodyL(); |
|
485 |
|
486 /** |
|
487 * Returns ETrue, if this message requires to be displayed |
|
488 * immediately. |
|
489 * |
|
490 * The CB message has to be displayed immediately |
|
491 * if either it is flagged as a Class 0 message (see GSM 03.38) |
|
492 * or has a geographical scope of the type "Immediate" |
|
493 * (see GSM 03.41). |
|
494 * |
|
495 * This function always returns EFalse for Base station ID messages |
|
496 * (message identifier = 50). |
|
497 * |
|
498 * @return Immediate display indication. |
|
499 */ |
|
500 TBool RequiresImmediateDisplay() const; |
|
501 |
|
502 /** |
|
503 * Increases the space allocated for message content. |
|
504 * |
|
505 * @param aLength New number of characters in msg |
|
506 * content. |
|
507 */ |
|
508 void ReserveContentSizeL( TInt aLength ); |
|
509 |
|
510 /** |
|
511 * Increases the space allocated for 8-bit message content. |
|
512 * |
|
513 * @param aLength New number of characters in msg |
|
514 * content. |
|
515 */ |
|
516 void ReserveContentSize8L( TInt aLength ); |
|
517 |
|
518 /** |
|
519 * Determines language of this message so that calls to Language() |
|
520 * will return the correct value. |
|
521 * |
|
522 * Language information may be determined from Data Coding Scheme |
|
523 * of message header or from the first characters in message body. |
|
524 * For the latter to succeed, the message has to be decoded into |
|
525 * UCS-2. |
|
526 */ |
|
527 void ResolveLanguage(); |
|
528 |
|
529 /** |
|
530 * Sets the network information of this message. |
|
531 * |
|
532 * @param aNetworkInfo Network information |
|
533 * @param aArea Area information |
|
534 */ |
|
535 void SetNetworkInfo( |
|
536 const RMobilePhone::TMobilePhoneNetworkInfoV1& aNetworkInfo, |
|
537 const RMobilePhone::TMobilePhoneLocationAreaV1& aArea ); |
|
538 |
|
539 /** |
|
540 * Returns the page number of this page in the message page sequence, |
|
541 * |
|
542 * @return Page number of this page. |
|
543 */ |
|
544 virtual TUint ThisPage() const = 0; |
|
545 |
|
546 /** |
|
547 * Returns the topic number to which the message belongs. |
|
548 * (Message Identifier) |
|
549 * |
|
550 * @return The number of the topic |
|
551 */ |
|
552 TCbsDbTopicNumber TopicNumber() const; |
|
553 |
|
554 /** |
|
555 * Returns the total number of pages in this page's message. |
|
556 * |
|
557 * @return Total number of pages in this message |
|
558 */ |
|
559 virtual TUint TotalPages() const = 0; |
|
560 |
|
561 protected: |
|
562 CCbsMessage(); |
|
563 |
|
564 protected: |
|
565 // Data Coding Scheme (language, encoding, compression) |
|
566 TCbsRecDCS iDCS; |
|
567 |
|
568 // Own: contents of the message page in 16-bit representation |
|
569 HBufC* iMessage; |
|
570 |
|
571 // Own: contents of the message page in 8-bit representation |
|
572 HBufC8* iMessage8; |
|
573 |
|
574 // Serial Number (GS, Message Code, Update Number) |
|
575 TUint16 iSerialNumber; |
|
576 |
|
577 // Message Identifier (Topic number) |
|
578 TUint16 iMessageIdentifier; |
|
579 |
|
580 // Page Parameter (this page, total pages) |
|
581 TCbsRecPageParameter iPageParameter; |
|
582 |
|
583 // Total number of pages |
|
584 TInt iTotalNumberOfPages; |
|
585 |
|
586 // Location area information |
|
587 RMobilePhone::TMobilePhoneLocationAreaV1 iLocationArea; |
|
588 |
|
589 // Network information |
|
590 RMobilePhone::TMobilePhoneNetworkInfoV1 iNetworkInfo; |
|
591 |
|
592 // Language of this message |
|
593 TCbsDbLanguage iLanguage; |
|
594 |
|
595 // Network in which current message was received |
|
596 TCbsNetworkMode iNetworkMode; |
|
597 }; |
|
598 |
|
599 #endif // CCBSMESSAGE_H |
|
600 |
|
601 // End of File |
|
602 |
|
603 |