FreeCalypso > hg > fc-magnetite
comparison src/aci2/aci/cmh_phbf.c @ 3:93999a60b835
src/aci2, src/condat2: import of g23m/condat source pieces from TCS211
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2016 00:29:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2:c41a534f33c6 | 3:93999a60b835 |
---|---|
1 /* | |
2 +----------------------------------------------------------------------------- | |
3 | Project : GSM-PS (6147) | |
4 | Modul : CMH_PHBF | |
5 +----------------------------------------------------------------------------- | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +----------------------------------------------------------------------------- | |
17 | Purpose : This module defines the functions used by the command | |
18 | handler for the phonebook management. | |
19 +----------------------------------------------------------------------------- | |
20 */ | |
21 | |
22 #ifndef CMH_PHBF_C | |
23 #define CMH_PHBF_C | |
24 #endif | |
25 | |
26 #include "aci_all.h" | |
27 /*==== INCLUDES ===================================================*/ | |
28 #include "aci_cmh.h" | |
29 #include "ati_cmd.h" | |
30 #include "aci_cmd.h" | |
31 | |
32 #ifdef FAX_AND_DATA | |
33 #include "aci_fd.h" | |
34 #endif /* of #ifdef FAX_AND_DATA */ | |
35 | |
36 #include "aci.h" | |
37 #include "psa.h" | |
38 #include "phb.h" | |
39 #include "cmh.h" | |
40 #include "cmh_phb.h" | |
41 | |
42 /*==== CONSTANTS ==================================================*/ | |
43 | |
44 #define PHB_CMH_INVALID_TAG_ENTRY 0xFF /* fill up a tag */ | |
45 #define PHB_CMH_INVALID_BCD_ENTRY 0xF /* fill up a BCD number */ | |
46 | |
47 #define PHB_CMH_YEAR_INVLD (255) /* invalid year */ | |
48 #define PHB_CMH_MONTH_INVLD (255) /* invalid month */ | |
49 #define PHB_CMH_DAY_INVLD (255) /* invalid day */ | |
50 #define PHB_CMH_HOUR_INVLD (255) /* invalid hour */ | |
51 #define PHB_CMH_MINUTE_INVLD (255) /* invalid minute */ | |
52 #define PHB_CMH_SECOND_INVLD (255) /* invalid second */ | |
53 | |
54 /*==== TYPES ======================================================*/ | |
55 | |
56 /*==== EXPORT =====================================================*/ | |
57 | |
58 /*==== VARIABLES ==================================================*/ | |
59 | |
60 /*==== FUNCTIONS ==================================================*/ | |
61 /* | |
62 +-------------------------------------------------------------------+ | |
63 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
64 | STATE : code ROUTINE : cmhPHB_rplcIntnl | | |
65 +-------------------------------------------------------------------+ | |
66 | |
67 PURPOSE : | |
68 */ | |
69 GLOBAL BOOL cmhPHB_rplcIntnl ( CHAR* inNumber, | |
70 CHAR* outNumber, | |
71 UBYTE inCnt ) | |
72 { | |
73 USHORT inIdx = 0; | |
74 USHORT outIdx = 0; | |
75 UBYTE actCnt = 0; | |
76 BOOL international = FALSE; | |
77 | |
78 while ( inNumber[inIdx] NEQ '\0' ) | |
79 { | |
80 /* | |
81 *--------------------------------------------------------------- | |
82 * international indicator "+" | |
83 *--------------------------------------------------------------- | |
84 */ | |
85 if ( inNumber[inIdx] EQ '+' AND | |
86 inNumber[inIdx-1] EQ '*' ) | |
87 { | |
88 if ( actCnt EQ inCnt OR inCnt EQ 0xFF ) | |
89 { | |
90 international = TRUE; | |
91 } | |
92 else | |
93 { | |
94 outNumber[outIdx++] = inNumber[inIdx]; | |
95 } | |
96 } | |
97 /* PATCH LE 12.05.00 | |
98 * 00 is used in china as national number | |
99 * checked against competitor phone | |
100 * now ACI has the same behaviour | |
101 */ | |
102 /* | |
103 *--------------------------------------------------------------- | |
104 * international indicator "00" | |
105 *--------------------------------------------------------------- | |
106 */ | |
107 /* else if ( inNumber[inIdx+1] EQ '0' AND | |
108 inNumber[inIdx] EQ '0' AND | |
109 inNumber[inIdx-1] EQ '*' ) | |
110 { | |
111 if ( actCnt EQ inCnt OR inCnt EQ 0xFF ) | |
112 { | |
113 international = TRUE; | |
114 inIdx++; | |
115 } | |
116 else | |
117 { | |
118 outNumber[outIdx++] = inNumber[inIdx++]; | |
119 outNumber[outIdx++] = inNumber[inIdx]; | |
120 } | |
121 } */ | |
122 /* END PATCH LE 12.05.00 */ | |
123 /* | |
124 *--------------------------------------------------------------- | |
125 * national indicator | |
126 *--------------------------------------------------------------- | |
127 */ | |
128 else | |
129 { | |
130 if ( inNumber[inIdx] EQ '*' ) | |
131 { | |
132 actCnt++; | |
133 } | |
134 | |
135 outNumber[outIdx++] = inNumber[inIdx]; | |
136 } | |
137 | |
138 inIdx++; | |
139 } | |
140 | |
141 outNumber[outIdx] = '\0'; | |
142 | |
143 return international; | |
144 } | |
145 | |
146 /* | |
147 +-------------------------------------------------------------------+ | |
148 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
149 | STATE : code ROUTINE : cmhPHB_cvtPhbType | | |
150 +-------------------------------------------------------------------+ | |
151 | |
152 PURPOSE : This function is used to convert the type of phonebook | |
153 used by ACI to the type of phonebook used by phonebook | |
154 management. | |
155 */ | |
156 GLOBAL BOOL cmhPHB_cvtPhbType ( T_ACI_PB_STOR inMem, T_PHB_TYPE* outMem ) | |
157 { | |
158 switch ( inMem ) | |
159 { | |
160 case ( PB_STOR_Fd ): *outMem = FDN; break; | |
161 case ( PB_STOR_Ld ): *outMem = LDN; break; | |
162 case ( PB_STOR_Ed ): *outMem = ECC; break; | |
163 case ( PB_STOR_Ad ): *outMem = ADN; break; | |
164 case ( PB_STOR_Bd ): *outMem = BDN; break; | |
165 case ( PB_STOR_Lr ): *outMem = LRN; break; | |
166 case ( PB_STOR_Sd ): *outMem = SDN; break; | |
167 case ( PB_STOR_Lm ): *outMem = LMN; break; | |
168 case ( PB_STOR_Ud ): *outMem = UPN; break; | |
169 | |
170 case ( PB_STOR_Af ): /* Not supported anymore */ | |
171 default: | |
172 return ( FALSE ); | |
173 } | |
174 | |
175 return ( TRUE ); | |
176 } | |
177 | |
178 /* | |
179 +-------------------------------------------------------------------+ | |
180 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
181 | STATE : code ROUTINE : cmhPHB_cvtPhbPsaType | | |
182 +-------------------------------------------------------------------+ | |
183 | |
184 PURPOSE : This function is used to convert the type of phonebook | |
185 used by phonebook management to the type of phonebook | |
186 used by ACI. | |
187 */ | |
188 GLOBAL BOOL cmhPHB_cvtPhbPsaType ( T_PHB_TYPE inMem, T_ACI_PB_STOR* outMem ) | |
189 { | |
190 switch ( inMem ) | |
191 { | |
192 case ( FDN ): *outMem = PB_STOR_Fd; break; | |
193 case ( LDN ): *outMem = PB_STOR_Ld; break; | |
194 case ( ECC ): *outMem = PB_STOR_Ed; break; | |
195 case ( ADN ): *outMem = PB_STOR_Ad; break; | |
196 case ( BDN ): *outMem = PB_STOR_Bd; break; | |
197 case ( LRN ): *outMem = PB_STOR_Lr; break; | |
198 case ( SDN ): *outMem = PB_STOR_Sd; break; | |
199 case ( LMN ): *outMem = PB_STOR_Lm; break; | |
200 case ( UPN ): *outMem = PB_STOR_Ud; break; | |
201 | |
202 default: | |
203 *outMem = PB_STOR_NotPresent; | |
204 return ( FALSE ); | |
205 } | |
206 | |
207 return ( TRUE ); | |
208 } | |
209 | |
210 /* | |
211 +--------------------------------------------------------------------+ | |
212 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
213 | STATE : code ROUTINE : cmhPHB_toaMrg | | |
214 +--------------------------------------------------------------------+ | |
215 | |
216 PURPOSE : This function is used to build the type of address octet | |
217 from T_ACI_TOA structure. | |
218 */ | |
219 GLOBAL void cmhPHB_toaMrg ( T_ACI_TOA* type, UBYTE* octet ) | |
220 { | |
221 *octet = ( ( ( type -> ton << 4 ) & 0xF0 ) + ( type -> npi & 0x0F ) ) | 0x80; | |
222 } | |
223 | |
224 /* | |
225 +--------------------------------------------------------------------+ | |
226 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
227 | STATE : code ROUTINE : cmhPHB_toaDmrg | | |
228 +--------------------------------------------------------------------+ | |
229 | |
230 PURPOSE : This function is used to build the T_ACI_TOA structure | |
231 from the type of address octet. | |
232 */ | |
233 GLOBAL void cmhPHB_toaDmrg ( UBYTE octet, T_ACI_TOA* type ) | |
234 { | |
235 if ( octet EQ 0xFF ) | |
236 { | |
237 type -> ton = TON_NotPresent; | |
238 type -> npi = NPI_NotPresent; | |
239 } | |
240 else | |
241 { | |
242 type -> ton = ( octet & 0x70 ) >> 4; | |
243 type -> npi = octet & 0x0F; | |
244 } | |
245 } | |
246 | |
247 /* | |
248 +--------------------------------------------------------------------+ | |
249 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
250 | STATE : code ROUTINE : cmhPHB_getAdrStr | | |
251 +--------------------------------------------------------------------+ | |
252 | |
253 PURPOSE : This function is used to convert the phone number | |
254 in BCD to the phone number as a string. | |
255 | |
256 BCD Note: Two digits are stored in one byte. | |
257 | |
258 +-------+-------+-------+-------+ | |
259 BCD: | 1 - 0 | 3 - 2 | F - 4 | F - F | | |
260 +-------+-------+-------+-------+ | |
261 | |
262 STRING: "01234" | |
263 | |
264 */ | |
265 GLOBAL CHAR cmhPHB_convertBCD2char( UBYTE bcd ) | |
266 { | |
267 switch ( bcd ) | |
268 { | |
269 case 0: | |
270 case 1: | |
271 case 2: | |
272 case 3: | |
273 case 4: | |
274 case 5: | |
275 case 6: | |
276 case 7: | |
277 case 8: | |
278 case 9: | |
279 return (bcd + '0'); | |
280 | |
281 case 0x0a: | |
282 return ('*'); | |
283 | |
284 case 0x0b: | |
285 return ('#'); | |
286 | |
287 case 0x0c: | |
288 return (PHB_DIAL_PAUSE); /* 'P' */ | |
289 | |
290 case 0x0d: | |
291 return (PHB_DIAL_WAIT); /* 'W' */ | |
292 | |
293 case 0x0e: | |
294 return (PHB_EXP_DIGIT); /* 'E' */ | |
295 | |
296 default: | |
297 return ('\0'); | |
298 } | |
299 } | |
300 | |
301 GLOBAL UBYTE cmhPHB_getAdrStr ( CHAR* pStr, | |
302 UBYTE maxIdx, | |
303 const UBYTE* pBcd, | |
304 UBYTE numDigits ) | |
305 { | |
306 BOOL highNibble = FALSE; | |
307 | |
308 UBYTE bcdIdx = 0; | |
309 UBYTE strIdx = 0; | |
310 | |
311 UBYTE bcd; | |
312 char digit; | |
313 BOOL ignore_next = FALSE; | |
314 | |
315 while ( bcdIdx < numDigits AND strIdx < maxIdx ) | |
316 { | |
317 if ( highNibble ) | |
318 { | |
319 bcd = ( pBcd[bcdIdx] & 0xF0 ) >> 4; | |
320 bcdIdx++; | |
321 } | |
322 else | |
323 { | |
324 bcd = pBcd[bcdIdx] & 0x0F; | |
325 } | |
326 | |
327 highNibble = ! highNibble; | |
328 | |
329 if(bcd EQ PHB_CMH_INVALID_BCD_ENTRY) | |
330 { | |
331 break; | |
332 } | |
333 | |
334 digit = cmhPHB_convertBCD2char( bcd ); | |
335 if (ignore_next EQ TRUE) | |
336 { | |
337 ; /* skip the digit following on an extension flag since we do not support it */ | |
338 ignore_next = FALSE; /* reset flag */ | |
339 } | |
340 else if (digit EQ PHB_EXP_DIGIT) | |
341 { | |
342 ignore_next = TRUE; /* we currently do not support Expansion Digit so skip next digit */ | |
343 } | |
344 else | |
345 { | |
346 pStr[strIdx++] = cmhPHB_convertBCD2char( bcd ); /* normal and supported digit */ | |
347 } | |
348 | |
349 } | |
350 | |
351 pStr[strIdx] = '\0'; | |
352 return ( strIdx ); | |
353 } | |
354 | |
355 /* | |
356 +--------------------------------------------------------------------+ | |
357 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
358 | STATE : code ROUTINE : cmhPHB_getAdrBcd | | |
359 +--------------------------------------------------------------------+ | |
360 | |
361 PURPOSE : This function is used to convert the phone number | |
362 as a string to the phone number in BCD. | |
363 | |
364 STRING: "01234" | |
365 | |
366 BCD Note: Two digits are stored in one byte. | |
367 | |
368 +-------+-------+-------+-------+ | |
369 BCD: | 1 - 0 | 3 - 2 | F - 4 | F - F | | |
370 +-------+-------+-------+-------+ | |
371 */ | |
372 GLOBAL void cmhPHB_getAdrBcd ( UBYTE* pBcd, | |
373 UBYTE* pNumDigits, | |
374 UBYTE maxDigits, | |
375 CHAR* pStr ) | |
376 { | |
377 BOOL highNibble = FALSE; | |
378 | |
379 UBYTE bcdIdx = 0; | |
380 UBYTE strIdx; | |
381 SHORT restLen; | |
382 | |
383 UBYTE bcd; | |
384 | |
385 for(strIdx = 0; bcdIdx < maxDigits AND pStr[strIdx] NEQ '\0'; strIdx++) | |
386 { | |
387 switch ( pStr[strIdx] ) | |
388 { | |
389 case '0': | |
390 case '1': | |
391 case '2': | |
392 case '3': | |
393 case '4': | |
394 case '5': | |
395 case '6': | |
396 case '7': | |
397 case '8': | |
398 case '9': | |
399 bcd = pStr[strIdx] - '0'; | |
400 break; | |
401 | |
402 case '*': | |
403 bcd = 0x0a; | |
404 break; | |
405 | |
406 case '#': | |
407 bcd = 0x0b; | |
408 break; | |
409 | |
410 case 'p': | |
411 case 'P': | |
412 bcd = 0x0c; | |
413 break; | |
414 | |
415 case 'w': | |
416 case 'W': | |
417 bcd = 0x0d; | |
418 break; | |
419 | |
420 case 'E': | |
421 bcd = 0x0e; | |
422 break; | |
423 | |
424 default: | |
425 continue; | |
426 } | |
427 | |
428 if ( highNibble ) | |
429 { | |
430 pBcd[bcdIdx] += ( bcd << 4 ); | |
431 bcdIdx++; | |
432 } | |
433 else | |
434 | |
435 pBcd[bcdIdx] = bcd; | |
436 | |
437 highNibble = ! highNibble; | |
438 } | |
439 | |
440 /* | |
441 *----------------------------------------------------------------- | |
442 * The last byte of the phone number is filled up with 'F' if | |
443 * necessary | |
444 *----------------------------------------------------------------- | |
445 */ | |
446 if ( highNibble ) | |
447 { | |
448 pBcd[bcdIdx] += ( PHB_CMH_INVALID_BCD_ENTRY << 4 ); | |
449 bcdIdx++; | |
450 } | |
451 | |
452 *pNumDigits = bcdIdx; | |
453 | |
454 /* | |
455 *----------------------------------------------------------------- | |
456 * The rest of the phone number is filled up with 'FF' | |
457 *----------------------------------------------------------------- | |
458 */ | |
459 restLen = maxDigits - bcdIdx; | |
460 if ( restLen > 0 ) | |
461 memset ( &pBcd[bcdIdx], | |
462 (PHB_CMH_INVALID_BCD_ENTRY << 4) + PHB_CMH_INVALID_BCD_ENTRY, | |
463 restLen ); | |
464 } | |
465 | |
466 /* | |
467 +--------------------------------------------------------------------+ | |
468 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
469 | STATE : code ROUTINE : cmhPHB_cpyRecEntr | | |
470 +--------------------------------------------------------------------+ | |
471 | |
472 PURPOSE : This function is used to copy the relevant data from the | |
473 T_PHB_RECORD structure to the T_ACI_PB_ENTR structure. | |
474 */ | |
475 GLOBAL void cmhPHB_cpyRecEntr ( T_ACI_PB_ENTR* entry, | |
476 #ifdef TI_PS_FFS_PHB | |
477 T_PHB_TYPE book, | |
478 #endif | |
479 const T_PHB_RECORD* record ) | |
480 { | |
481 #ifdef TI_PS_FFS_PHB | |
482 entry -> index = record->phy_recno; | |
483 #else | |
484 entry -> index = ( SHORT ) record -> index; | |
485 #endif | |
486 | |
487 cmhPHB_getAdrStr ( entry -> number, | |
488 MAX_PHB_NUM_LEN - 1, | |
489 record -> number, | |
490 record -> len ); | |
491 | |
492 cmhPHB_toaDmrg ( record -> ton_npi, &entry -> type ); | |
493 | |
494 cmhPHB_getMfwTagNt ( record -> tag, record -> tag_len, | |
495 entry -> text.data, &entry -> text.len ); | |
496 | |
497 entry -> text.cs = CS_Sim; | |
498 | |
499 #ifdef TI_PS_FFS_PHB | |
500 cmhPHB_cvtPhbPsaType ( book, &entry -> book ); | |
501 #else | |
502 cmhPHB_cvtPhbPsaType ( record -> book, &entry -> book ); | |
503 #endif | |
504 | |
505 cmhPHB_cpyPhbDateTime ( record, &entry -> dateTime ); | |
506 } | |
507 | |
508 /* | |
509 +--------------------------------------------------------------------+ | |
510 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
511 | STATE : code ROUTINE : cmhPHB_invldEntr | | |
512 +--------------------------------------------------------------------+ | |
513 | |
514 PURPOSE : This function is used to invalidate the elements of | |
515 a T_ACI_PB_ENTR structure. | |
516 */ | |
517 GLOBAL void cmhPHB_invldEntr ( T_ACI_PB_ENTR* entry ) | |
518 { | |
519 entry -> index = ACI_NumParmNotPresent; | |
520 entry -> number[0] = '\0'; | |
521 entry -> type.ton = TON_Unknown; | |
522 entry -> type.npi = NPI_IsdnTelephony; | |
523 entry -> text.len = 0; | |
524 entry -> book = PB_STOR_NotPresent; | |
525 | |
526 cmhPHB_invldCmhDateTime ( &entry -> dateTime); | |
527 } | |
528 | |
529 /* | |
530 +--------------------------------------------------------------------+ | |
531 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
532 | STATE : code ROUTINE : cmhPHB_getTagNt | | |
533 +--------------------------------------------------------------------+ | |
534 | |
535 PURPOSE : This function converts the actual tag in the format used | |
536 when storing it on the SIM into a null terminated string. | |
537 */ | |
538 GLOBAL void cmhPHB_getTagNt ( UBYTE* inTag, | |
539 UBYTE maxInLen, | |
540 CHAR* outTag, | |
541 UBYTE maxOutLen ) | |
542 { | |
543 UBYTE i = 0; | |
544 | |
545 while ( i < maxOutLen - 1 AND i < maxInLen AND | |
546 inTag[i] NEQ PHB_CMH_INVALID_TAG_ENTRY ) | |
547 { | |
548 /* | |
549 *----------------------------------------------------------------- | |
550 * Convert from default GSM to internal GSM alphabet | |
551 *----------------------------------------------------------------- | |
552 */ | |
553 outTag[i] = ( CHAR ) inTag[i] | 0x80; | |
554 i++; | |
555 } | |
556 | |
557 outTag[i] = '\0'; | |
558 } | |
559 | |
560 /* | |
561 +--------------------------------------------------------------------+ | |
562 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
563 | STATE : code ROUTINE : cmhPHB_getMfwTagNt | | |
564 +--------------------------------------------------------------------+ | |
565 | |
566 PURPOSE : This function copy the actual tag . | |
567 */ | |
568 GLOBAL void cmhPHB_getMfwTagNt ( const UBYTE* inTag, | |
569 UBYTE maxInLen, | |
570 UBYTE* outTag, | |
571 UBYTE* maxOutLen ) | |
572 { | |
573 UBYTE i = 0; | |
574 UBYTE len; | |
575 | |
576 if(maxInLen EQ 0) | |
577 { | |
578 memset(outTag, 0, MAX_ALPHA_LEN); /* we need to set out tag to 0 to prevent to be recognized by UCS2 decoder */ | |
579 *maxOutLen = 0; | |
580 return; | |
581 } | |
582 | |
583 len = pb_get_entry_len(inTag, maxInLen); | |
584 | |
585 if (len >= MAX_ALPHA_LEN) | |
586 { | |
587 len = MAX_ALPHA_LEN; | |
588 } | |
589 | |
590 memcpy(outTag, inTag, len); | |
591 *maxOutLen = len; | |
592 } | |
593 | |
594 /* | |
595 +--------------------------------------------------------------------+ | |
596 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
597 | STATE : code ROUTINE : cmhPHB_getTagSim | | |
598 +--------------------------------------------------------------------+ | |
599 | |
600 PURPOSE : This function converts the actual tag as a null | |
601 terminated string in the format used when storing it on | |
602 the SIM. | |
603 */ | |
604 GLOBAL void cmhPHB_getTagSim ( T_ACI_PB_TEXT *inTag, | |
605 UBYTE *outTag, | |
606 UBYTE maxOutLen ) | |
607 { | |
608 UBYTE inLen = inTag->len; | |
609 UBYTE i = MINIMUM ( maxOutLen, inLen); | |
610 SHORT restLen = maxOutLen - inLen; | |
611 UBYTE j; | |
612 | |
613 /* | |
614 *----------------------------------------------------------------- | |
615 * Convert from internal GSM to default GSM alphabet | |
616 *----------------------------------------------------------------- | |
617 */ | |
618 for ( j = 0; j < i; j++ ) | |
619 outTag[j] = inTag->data[j] & 0x7F; | |
620 | |
621 if ( restLen > 0 ) | |
622 memset ( &outTag[i], PHB_CMH_INVALID_TAG_ENTRY, restLen); | |
623 } | |
624 | |
625 /* | |
626 +--------------------------------------------------------------------+ | |
627 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
628 | STATE : code ROUTINE : cmhPHB_getMfwTagSim | | |
629 +--------------------------------------------------------------------+ | |
630 | |
631 PURPOSE : This function converts the actual tag string in the | |
632 format used when storing it on the SIM. | |
633 */ | |
634 GLOBAL void cmhPHB_getMfwTagSim ( T_ACI_PB_TEXT* inTag, | |
635 UBYTE* outTag, | |
636 UBYTE* outTagLen, | |
637 UBYTE maxOutLen ) | |
638 { | |
639 UBYTE i = MINIMUM ( maxOutLen, inTag->len); | |
640 SHORT restLen = maxOutLen - inTag->len; | |
641 UBYTE j; | |
642 | |
643 /* | |
644 *----------------------------------------------------------------- | |
645 * Convert from internal GSM to default GSM alphabet | |
646 *----------------------------------------------------------------- | |
647 */ | |
648 for ( j = 0; j < i; j++ ) | |
649 outTag[j] = inTag->data[j]; | |
650 | |
651 *outTagLen = i; | |
652 | |
653 if ( restLen > 0 ) | |
654 memset ( &outTag[i], PHB_CMH_INVALID_TAG_ENTRY, restLen); | |
655 } | |
656 | |
657 /* | |
658 +-------------------------------------------------------------------+ | |
659 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
660 | STATE : code ROUTINE : cmhPHB_invldPhbDateTime | | |
661 +-------------------------------------------------------------------+ | |
662 | |
663 PURPOSE : This function is used to invalidate the date and time | |
664 of a phonebook entry. | |
665 */ | |
666 GLOBAL void cmhPHB_invldPhbDateTime ( T_PHB_RECORD* record ) | |
667 { | |
668 #ifdef TI_PS_FFS_PHB | |
669 record->v_time = FALSE; | |
670 | |
671 /* Backward compatibility. Setting v_time to FALSE would be sufficient */ | |
672 record->time.year = PHB_CMH_YEAR_INVLD; | |
673 record->time.month = PHB_CMH_MONTH_INVLD; | |
674 record->time.day = PHB_CMH_DAY_INVLD; | |
675 record->time.hour = PHB_CMH_HOUR_INVLD; | |
676 record->time.minute = PHB_CMH_MINUTE_INVLD; | |
677 record->time.second = PHB_CMH_SECOND_INVLD; | |
678 #else | |
679 record -> year = PHB_CMH_YEAR_INVLD; | |
680 record -> month = PHB_CMH_MONTH_INVLD; | |
681 record -> day = PHB_CMH_DAY_INVLD; | |
682 record -> hour = PHB_CMH_HOUR_INVLD; | |
683 record -> minute = PHB_CMH_MINUTE_INVLD; | |
684 record -> second = PHB_CMH_SECOND_INVLD; | |
685 #endif | |
686 } | |
687 | |
688 /* | |
689 +-------------------------------------------------------------------+ | |
690 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
691 | STATE : code ROUTINE : cmhPHB_invldCmhDateTime | | |
692 +-------------------------------------------------------------------+ | |
693 | |
694 PURPOSE : This function is used to invalidate the date and time | |
695 of a phonebook entry. | |
696 */ | |
697 GLOBAL void cmhPHB_invldCmhDateTime ( T_ACI_VP_ABS* dateTime ) | |
698 { | |
699 dateTime -> year [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
700 dateTime -> year [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
701 dateTime -> month [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
702 dateTime -> month [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
703 dateTime -> day [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
704 dateTime -> day [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
705 dateTime -> hour [0] = PHB_CMH_INVALID_BCD_ENTRY; | |
706 dateTime -> hour [1] = PHB_CMH_INVALID_BCD_ENTRY; | |
707 dateTime -> minute[0] = PHB_CMH_INVALID_BCD_ENTRY; | |
708 dateTime -> minute[1] = PHB_CMH_INVALID_BCD_ENTRY; | |
709 dateTime -> second[0] = PHB_CMH_INVALID_BCD_ENTRY; | |
710 dateTime -> second[1] = PHB_CMH_INVALID_BCD_ENTRY; | |
711 } | |
712 | |
713 /* | |
714 +-------------------------------------------------------------------+ | |
715 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
716 | STATE : code ROUTINE : cmhPHB_cpyCmhDateTime | | |
717 +-------------------------------------------------------------------+ | |
718 | |
719 PURPOSE : This function is used to convert the date and time used | |
720 within the command handler to the format used in the | |
721 phonebook management. | |
722 */ | |
723 GLOBAL void cmhPHB_cpyCmhDateTime ( const T_ACI_VP_ABS* dateTime, | |
724 T_PHB_RECORD* record ) | |
725 { | |
726 #ifdef TI_PS_FFS_PHB | |
727 record->time.year = (UBYTE)(dateTime -> year [0] << 4) + | |
728 dateTime -> year [1]; | |
729 record->time.month = (UBYTE)(dateTime -> month [0] << 4) + | |
730 dateTime -> month [1]; | |
731 record->time.day = (UBYTE)(dateTime -> day [0] << 4) + | |
732 dateTime -> day [1]; | |
733 record->time.hour = (UBYTE)(dateTime -> hour [0] << 4) + | |
734 dateTime -> hour [1]; | |
735 record->time.minute = (UBYTE)(dateTime -> minute[0] << 4) + | |
736 dateTime -> minute[1]; | |
737 record->time.second = (UBYTE)(dateTime -> second[0] << 4) + | |
738 dateTime -> second[1]; | |
739 record->v_time = (record->time.year NEQ 0xff); | |
740 #else | |
741 record -> year = (UBYTE)(dateTime -> year [0] << 4) + | |
742 dateTime -> year [1]; | |
743 record -> month = (UBYTE)(dateTime -> month [0] << 4) + | |
744 dateTime -> month [1]; | |
745 record -> day = (UBYTE)(dateTime -> day [0] << 4) + | |
746 dateTime -> day [1]; | |
747 record -> hour = (UBYTE)(dateTime -> hour [0] << 4) + | |
748 dateTime -> hour [1]; | |
749 record -> minute = (UBYTE)(dateTime -> minute[0] << 4) + | |
750 dateTime -> minute[1]; | |
751 record -> second = (UBYTE)(dateTime -> second[0] << 4) + | |
752 dateTime -> second[1]; | |
753 #endif | |
754 } | |
755 | |
756 /* | |
757 +-------------------------------------------------------------------+ | |
758 | PROJECT : GSM-PS (6147) MODULE : CMH_PHBF | | |
759 | STATE : code ROUTINE : cmhPHB_cpyPhbDateTime | | |
760 +-------------------------------------------------------------------+ | |
761 | |
762 PURPOSE : This function is used to convert the date and time used | |
763 within the phonebook management to the format used in | |
764 the command handler. | |
765 */ | |
766 GLOBAL void cmhPHB_cpyPhbDateTime ( const T_PHB_RECORD* record, | |
767 T_ACI_VP_ABS* dateTime ) | |
768 { | |
769 #ifdef TI_PS_FFS_PHB | |
770 dateTime -> year [0] = ( record->time.year ) >> 4; | |
771 dateTime -> year [1] = record->time.year & 0x0F; | |
772 dateTime -> month [0] = ( record->time.month ) >> 4; | |
773 dateTime -> month [1] = record->time.month & 0x0F; | |
774 dateTime -> day [0] = ( record->time.day ) >> 4; | |
775 dateTime -> day [1] = record->time.day & 0x0F; | |
776 dateTime -> hour [0] = ( record->time.hour ) >> 4; | |
777 dateTime -> hour [1] = record->time.hour & 0x0F; | |
778 dateTime -> minute[0] = ( record->time.minute ) >> 4; | |
779 dateTime -> minute[1] = record->time.minute & 0x0F; | |
780 dateTime -> second[0] = ( record->time.second ) >> 4; | |
781 dateTime -> second[1] = record->time.second & 0x0F; | |
782 #else | |
783 dateTime -> year [0] = ( record -> year ) >> 4; | |
784 dateTime -> year [1] = record -> year & 0x0F; | |
785 dateTime -> month [0] = ( record -> month ) >> 4; | |
786 dateTime -> month [1] = record -> month & 0x0F; | |
787 dateTime -> day [0] = ( record -> day ) >> 4; | |
788 dateTime -> day [1] = record -> day & 0x0F; | |
789 dateTime -> hour [0] = ( record -> hour ) >> 4; | |
790 dateTime -> hour [1] = record -> hour & 0x0F; | |
791 dateTime -> minute[0] = ( record -> minute ) >> 4; | |
792 dateTime -> minute[1] = record -> minute & 0x0F; | |
793 dateTime -> second[0] = ( record -> second ) >> 4; | |
794 dateTime -> second[1] = record -> second & 0x0F; | |
795 #endif | |
796 } | |
797 | |
798 /*==== EOF ========================================================*/ | |
799 |