comparison src/ui3/mfw/mfw_phb.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_phb.c $|
4 | $Author:: Vo $Revision:: 1 $|
5 | CREATED: 7.1.99 $Modtime:: 12.01.00 11:19 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : MFW_PHB
10
11 PURPOSE : This modul contains phonebook management functions.
12
13 HISTORY:
14
15 June 05, 2007 DR:OMAPS00133241 x0061560(sateeshg)
16 Description:ASTEC29607,SIM:The sim card should not return 9240 still.
17 Solution :New enum MFW_PHB_EXCT been sent while the command AT_EXCT is in progress
18
19 Nov 03, 2006 DR:OMAPS00097209 a0393213(R.Prabakar)
20 API Needed for Maximum Length Of Each Phonebook Category In SIM
21 Solution: The interface of pb_read_sizes() changed. While calling the function it should be taken care of.
22
23 Aug 18, 2006 ER: OMAPS00089840 x0039928
24 Description: Changes to be made in MMI for the functionality "Delete all" ADN entries
25 Solution: A new menu item "Delete All" is added in the phone book menu
26 to delete all the sim entries
27
28 July 17, 2006 DR: OMAPS00082792 x0039928
29 Description:Changes to be done in MMI for Move all entries from SIM to FFS (Defect 76492)
30 Solution: Added condition to check for AT_EXCT return for sAT_PlusCPBW
31
32 Oct 27, 2005 REF: OMAPS 48881 b-nekkare
33 Description: PhoneBook: The modify option under phonebook doesn't
34 work as expected.
35 Solution: In case of SIM storage,deleted the previous 2nd comparision
36 with TON as then it would be TRUE if the previous saved
37 number had a preceding'+'. So currently only checking for
38 '+' to figure out the TON.
39
40
41 Apr 14, 2005 REF: CRR 29991 xpradipg
42 Description: Optimisation 5: Remove the static allocation and use dynamic
43 allocation/ deallocation for pb_list and black_list
44 Solution: The static definition is removed and replaced with the dynamic
45 allocation
46
47
48 March 1 ,2004 REF: CRR 27832 x0012852
49 Bug:SIM PIN2 related Actions are displying wrong Error Response.
50 Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
51 */
52 #define ENTITY_MFW
53
54 #include <string.h>
55 #include <stdio.h>
56 #include <stdlib.h>
57
58 #if defined (NEW_FRAME)
59
60 #include "typedefs.h"
61 #include "vsi.h"
62 #include "pei.h"
63 #include "custom.h"
64 #include "gsm.h"
65
66 #else
67
68 #include "STDDEFS.H"
69 #include "custom.h"
70 #include "gsm.h"
71 #include "vsi.h"
72
73 #endif
74
75
76 #include "mfw_mfw.h"
77 #include "mfw_phb.h"
78 #include "mfw_phbi.h"
79 #include "mfw_cm.h"
80 #include "mfw_cmi.h"
81
82 #include "mfw_nm.h"
83 #include "mfw_sim.h"
84 #include "mfw_sima.h"
85 #include "mfw_nmi.h"
86 #include "mfw_simi.h"
87 #include "mfw_sms.h"
88 #include "mfw_smsi.h"
89 #include "mfw_win.h"
90
91 #include "ksd.h"
92 #include "psa.h"
93
94 #if defined (FAX_AND_DATA)
95 #include "aci_fd.h"
96 #endif
97
98 #include "message.h"
99 #include "prim.h"
100 #include "aci_cmh.h"
101
102 #include "cmh.h"
103 #include "phb.h"
104 #include "cmh_phb.h"
105
106 #include "mfw_ss.h"
107 #include "mfw_ssi.h"
108 #include "mfw_win.h"
109
110 #include "gdi.h"
111
112 #ifndef PCM_2_FFS
113 #include "pcm.h"
114 #include "mfw_ffs.h"
115 #endif
116
117
118 /* SPR#1112 - SH - Required for internal phonebook */
119 #ifdef INT_PHONEBOOK
120 #include "ATBPbGI.h"
121 #endif
122
123 /*************** MACRO definition ***********************************/
124 // Apr 14, 2005 REF: CRR 29991 xpradipg
125 // MACRO to allocate and deallocate memory for pb_list
126 #ifdef FF_MMI_OPTIM
127 #define PB_LIST_ALLOC(ptr,size) \
128 ptr = (T_ACI_PB_ENTR*)mfwAlloc(size);\
129 if (NULL == ptr)\
130 return MFW_PHB_FAIL;
131 #define PB_LIST_DEALLOC(ptr,size)\
132 if(ptr)\
133 mfwFree((U8*)ptr, size);
134 #define PB_LIST_SIZE (sizeof(T_ACI_PB_ENTR)*PHB_MAX_ENTRY_NUM)
135
136 #else
137 #define PB_LIST_ALLOC(ptr, size)
138 #define PB_LIST_DEALLOC(ptr, size)
139 #endif
140 /********* current define *******************************************/
141 // Apr 14, 2005 REF: CRR 29991 xpradipg
142 // remove the static allocation
143 #ifndef FF_MMI_OPTIM
144 static T_ACI_PB_ENTR pb_list[PHB_MAX_ENTRY_NUM];
145 #endif
146 #ifdef TI_PS_FFS_PHB
147 static T_ACI_PB_STAT pb_stat;
148 #endif
149 static T_MFW_UPN_LIST upn_list;
150 static UBYTE cnt; /* count of user personal numbers */
151
152 EXTERN MfwHdr * current_mfw_elem;
153
154 // Aug 18, 2006 ER: OMAPS00089840 x0039928
155 extern BOOL DeleteAll_flag;
156
157 //Added by Muthu Raja For PCM Replacement
158 #ifdef PCM_2_FFS
159 #define PSPDF_UPN_ID "/PCM/UPN" /* User Personal Numbers */
160 #endif
161
162
163 /*
164 +--------------------------------------------------------------------+
165 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
166 | STATE : code ROUTINE: phb_create |
167 +--------------------------------------------------------------------+
168
169
170 PURPOSE : create event for phonebook management
171 */
172
173 T_MFW_HND phb_create(T_MFW_HND hWin, T_MFW_EVENT event, T_MFW_CB cbfunc)
174 {
175 T_MFW_HDR *hdr;
176 T_MFW_PHB *phb_para;
177 MfwHdr *insert_status =0;
178
179 TRACE_FUNCTION ("phb_create()");
180
181 hdr = (T_MFW_HDR *) mfwAlloc(sizeof (T_MFW_HDR));
182 phb_para = (T_MFW_PHB *) mfwAlloc(sizeof (T_MFW_PHB));
183
184 if (!hdr OR !phb_para)
185 {
186 TRACE_ERROR("ERROR: phb_create() Mem Alloc Failed.");
187
188 if(hdr)
189 mfwFree((U8*)hdr,sizeof(MfwHdr));
190 if(phb_para)
191 mfwFree((U8*)phb_para,sizeof(T_MFW_PHB));
192
193 return FALSE;
194 }
195
196 /*
197 * initialisation of the handler
198 */
199 phb_para->emask = event;
200 phb_para->handler = cbfunc;
201
202 hdr->data = phb_para; /* store parameter in node */
203 hdr->type = MFW_TYP_PHB; /* store type of event handler */
204
205 /*
206 * installation of the handler
207 */
208 insert_status = mfwInsert((T_MFW_HDR *)hWin, hdr);
209 if(!insert_status)
210 {
211 TRACE_ERROR("ERROR: phb_create() Failed to Install Handler. ");
212 mfwFree((U8*)hdr,sizeof(MfwHdr));
213 mfwFree((U8*)phb_para ,sizeof(T_MFW_PHB));
214 return 0;
215 }
216 return insert_status;
217 }
218
219
220 /*
221 +---------------------------------------------------------------------+
222 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
223 | STATE : code ROUTINE: phb_delete |
224 +---------------------------------------------------------------------+
225
226
227 PURPOSE : delete a event for phonebook management
228
229 */
230
231 T_MFW_RES phb_delete(T_MFW_HND h)
232 {
233 TRACE_FUNCTION ("phb_delete()");
234
235 if (!h OR !((T_MFW_HDR *)h)->data)
236 return MFW_RES_ILL_HND;
237
238 if (!mfwRemove((T_MFW_HDR *)h))
239 return MFW_RES_ILL_HND;
240
241 mfwFree((U8 *)(((T_MFW_HDR *) h)->data),sizeof(T_MFW_PHB));
242 mfwFree((U8 *)h,sizeof(T_MFW_HDR));
243
244 return MFW_RES_OK;
245 }
246
247
248 /*
249 +---------------------------------------------------------------------+
250 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
251 | STATE : code ROUTINE: phb_signal |
252 +---------------------------------------------------------------------+
253
254 PURPOSE : send a event signal.
255
256 */
257
258 void phb_signal(T_MFW_EVENT event, void * para)
259 {/*MC, SPR 1389, we have to enable the display whenever
260 we send an event up to the MMI*/
261 UBYTE temp = dspl_Enable(0);
262
263 TRACE_FUNCTION ("phb_signal()");
264 if (mfwSignallingMethod EQ 0)
265 {
266 /*
267 * focus is on a window
268 */
269 if (mfwFocus)
270 /*
271 * send event to phonebook management
272 * handler if available
273 */
274 if (phb_sign_exec (mfwFocus, event, para))
275 { dspl_Enable(temp);/*MC, SPR 1389*/
276 return;
277 }
278
279 /*
280 * acutal focussed window is not available
281 * or has no phonebook management handler,
282 * then search all nodes from the root.
283 */
284 if (mfwRoot)
285 phb_sign_exec (mfwRoot, event, para);
286 }
287 else
288 {
289 MfwHdr * h = 0;
290
291 /*
292 * Focus set, then start here
293 */
294 if (mfwFocus)
295 h = mfwFocus;
296 /*
297 * Focus not set, then start root
298 */
299 if (!h)
300 h = mfwRoot;
301
302 /*
303 * No elements available, return
304 */
305
306 while (h)
307
308
309 {
310 /*
311 * Signal consumed, then return
312 */
313 if (phb_sign_exec (h, event, para))
314 { dspl_Enable(temp);/*MC, SPR 1389*/
315 return;
316 }
317
318 /*
319 * All windows tried inclusive root
320 */
321 if (h == mfwRoot)
322 { dspl_Enable(temp);/*MC, SPR 1389*/
323 return;
324 }
325
326 /*
327 * get parent window
328 */
329 h = mfwParent(mfwParent(h));
330 if(h)
331 h = ((MfwWin * )(h->data))->elems;
332 }
333 phb_sign_exec (mfwRoot, event, para);
334 }
335 dspl_Enable(temp);/*MC, SPR 1389*/
336
337 }
338
339 /*
340 +---------------------------------------------------------------------+
341 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
342 | STATE : code ROUTINE: phb_sign_exec |
343 +---------------------------------------------------------------------+
344
345
346 PURPOSE : Send a signal if PHB management handler.
347
348 */
349
350 BOOL phb_sign_exec (T_MFW_HDR * cur_elem, T_MFW_EVENT event, T_MFW_PHB_PARA * para)
351 {
352 TRACE_FUNCTION ("phb_sign_exec()");
353
354 while (cur_elem)
355 {
356 /*
357 * event handler is available
358 */
359 if (cur_elem->type EQ MFW_TYP_PHB)
360 {
361 T_MFW_PHB * phb_data;
362 /*
363 * handler is PHB management handler
364 */
365 phb_data = (T_MFW_PHB *)cur_elem->data;
366 if (phb_data->emask & event)
367 {
368 /*
369 * event is expected by the call back function
370 */
371 phb_data->event = event;
372 switch (event)
373 {
374 case E_PHB_STATUS:
375 memcpy (&phb_data->para.phb_status, para, sizeof (T_MFW_PHB_STATUS));
376 break;
377 case E_PHB_UPN_LIST:
378 memcpy (&phb_data->para.upn_list, para, sizeof (T_MFW_UPN_LIST));
379 break;
380 /* SPR#1112 - SH - Add these events */
381 case E_PHB_READY:
382 break;
383 case E_PHB_BUSY:
384 break;
385 }
386
387 /*
388 * if call back defined, call it
389 */
390 if (phb_data->handler)
391 {
392 // PATCH LE 06.06.00
393 // store current mfw elem
394 current_mfw_elem = cur_elem;
395 // END PATCH LE 06.06.00
396
397 if ((*(phb_data->handler)) (phb_data->event, (void *)&phb_data->para))
398 return TRUE;
399 }
400 }
401 }
402 cur_elem = cur_elem->next;
403 }
404 return FALSE;
405 }
406
407
408 /*
409 +-------------------------------------------------------------------+
410 | PROJECT : GSM-PS (6147) MODULE : MFW_PHB |
411 | STATE : code ROUTINE : phb_codePhbType |
412 +-------------------------------------------------------------------+
413 PURPOSE : This function is used to convert the type of phonebook
414 used by MFW to the type of phonebook used by ACI.
415 */
416 /*a0393213 warnings removal-argument type changed from T_PHB_TYPE*/
417 LOCAL T_ACI_PB_STOR phb_codePhbType ( T_MFW_PHB_TYPE inMem )
418 {
419 switch ( inMem )
420 {
421 case ( PHB_FDN ): return PB_STOR_Fd;
422 case ( PHB_LDN ): return PB_STOR_Ld;
423 case ( PHB_ECC ): return PB_STOR_Ed;
424 case ( PHB_ADN ): return PB_STOR_Ad;
425 case ( PHB_BDN ): return PB_STOR_Bd;
426 case ( PHB_LRN ): return PB_STOR_Lr;
427 case ( PHB_SDN ): return PB_STOR_Sd;
428 case ( PHB_LMN ): return PB_STOR_Lm;
429 case ( PHB_ADN_FDN ): return PB_STOR_Af;
430 case ( PHB_UPN ): return PB_STOR_Ud;
431 default: return PB_STOR_NotPresent;
432 }
433 }
434
435
436 /*
437 +-------------------------------------------------------------------+
438 | PROJECT : GSM-PS (6147) MODULE : MFW_PHB |
439 | STATE : code ROUTINE : phb_decodePhbType |
440 +-------------------------------------------------------------------+
441 PURPOSE : This function is used to convert the type of phonebook
442 used by MFW to the type of phonebook used by ACI.
443 */
444 /*a0393213 warnings removal-return type changed from T_PHB_TYPE*/
445 LOCAL T_MFW_PHB_TYPE phb_decodePhbType ( T_ACI_PB_STOR inMem )
446 {
447 switch ( inMem )
448 {
449 case ( PB_STOR_Fd ): return PHB_FDN;
450 case ( PB_STOR_Ld ): return PHB_LDN;
451 case ( PB_STOR_Ed ): return PHB_ECC;
452 case ( PB_STOR_Ad ): return PHB_ADN;
453 case ( PB_STOR_Bd ): return PHB_BDN;
454 case ( PB_STOR_Lr ): return PHB_LRN;
455 case ( PB_STOR_Sd ): return PHB_SDN;
456 case ( PB_STOR_Lm ): return PHB_LMN;
457 case ( PB_STOR_Af ): return PHB_ADN_FDN;
458 case ( PB_STOR_Ud ): return PHB_UPN;
459 default: return PHB_NONE;
460 }
461 }
462
463
464 /*
465 +--------------------------------------------------------------------+
466 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
467 | STATE : code ROUTINE: phb_cvtTon |
468 +--------------------------------------------------------------------+
469
470
471 PURPOSE : This function is used to convert the type of number
472 used by ACI to the type of number used by MFW.
473
474 */
475
476 T_MFW_PHB_TON phb_cvtTon(T_ACI_TOA_TON ton)
477 {
478 switch (ton)
479 {
480 case TON_NotPresent:
481 case TON_Unknown: return MFW_TON_UNKNOWN;
482 case TON_International: return MFW_TON_INTERNATIONAL;
483 case TON_National: return MFW_TON_NATIONAL;
484 case TON_NetSpecific: return MFW_TON_NET_SPECIFIC;
485 case TON_DedAccess: return MFW_TON_DED_ACCESS;
486 case TON_Alphanumeric: return MFW_TON_ALPHA_NUMERIC;
487 case TON_Abbreviated: return MFW_TON_ABBREVIATED;
488 case TON_Extended: return MFW_TON_EXTENDED;
489 default: return (T_MFW_PHB_TON)ton;
490 }
491 }
492
493
494 /*
495 +--------------------------------------------------------------------+
496 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
497 | STATE : code ROUTINE: phb_ncvtTon |
498 +--------------------------------------------------------------------+
499
500
501 PURPOSE : This function is used to convert the type of number
502 used by MFW to the type of number used by ACI.
503
504 */
505
506 T_ACI_TOA_TON phb_ncvtTon(T_MFW_PHB_TON ton)
507 {
508 switch (ton)
509 {
510 case MFW_TON_INTERNATIONAL: return TON_International;
511 case MFW_TON_NATIONAL: return TON_National;
512 case MFW_TON_NET_SPECIFIC: return TON_NetSpecific;
513 case MFW_TON_DED_ACCESS: return TON_DedAccess;
514 case MFW_TON_ALPHA_NUMERIC: return TON_Alphanumeric;
515 case MFW_TON_ABBREVIATED: return TON_Abbreviated;
516 case MFW_TON_EXTENDED: return TON_Extended;
517 default: return TON_Unknown;
518 }
519 }
520
521 /*
522 +--------------------------------------------------------------------+
523 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
524 | STATE : code ROUTINE: phb_cvtNpi |
525 +--------------------------------------------------------------------+
526
527
528 PURPOSE : This function is used to convert the numbering plan
529 identifier used by ACI to the numbering plan identifier
530 used by MFW.
531
532 */
533 /*a0393213 compiler warnings removal - changed the return type from T_MFW_PHB_TON to T_MFW_PHB_NPI*/
534 T_MFW_PHB_NPI phb_cvtNpi(T_ACI_TOA_NPI npi)
535 {
536 switch (npi)
537 {
538 case NPI_NotPresent:
539 case NPI_Unknown: return MFW_NPI_UNKNOWN;
540 case NPI_IsdnTelephony: return MFW_NPI_ISDN;
541 case NPI_Data: return MFW_NPI_DATA;
542 case NPI_Telex: return MFW_NPI_TELEX;
543 case NPI_Private: return MFW_NPI_PRIVATE;
544 case NPI_National: return MFW_NPI_NATIONAL;
545 #ifdef FF_2TO1_PS
546 case NPI_Ermes: return MFW_NPI_M_ERMES;
547 case NPI_Cts: return MFW_NPI_M_CTS;
548 #else
549 case NPI_ERMES: return MFW_NPI_M_ERMES;
550 case NPI_CTS: return MFW_NPI_M_CTS;
551 #endif
552 default: return MFW_NPI_UNKNOWN;/*a0393213 warnings removal-npi changed to MFW_NPI_UNKNOWN*/
553 }
554 }
555
556
557 /*
558 +--------------------------------------------------------------------+
559 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
560 | STATE : code ROUTINE: phb_ncvtNpi |
561 +--------------------------------------------------------------------+
562
563
564 PURPOSE : This function is used to convert the numbering plan
565 identifier used by MFW to the numbering plan identifier
566 used by ACI.
567
568 */
569 /*a0393213 compiler warnings removal - changed the argument from T_MFW_PHB_TON to T_MFW_PHB_NPI*/
570 T_ACI_TOA_NPI phb_ncvtNpi(T_MFW_PHB_NPI npi)
571 {
572 switch (npi)
573 {
574 case MFW_NPI_ISDN: return NPI_IsdnTelephony;
575 case MFW_NPI_DATA: return NPI_Data;
576 case MFW_NPI_TELEX: return NPI_Telex;
577 case MFW_NPI_PRIVATE: return NPI_Private;
578 case MFW_NPI_NATIONAL: return NPI_National;
579 #ifdef FF_2TO1_PS
580 case MFW_NPI_M_ERMES: return NPI_Ermes;
581 case MFW_NPI_M_CTS: return NPI_Cts;
582 #else
583 case MFW_NPI_M_ERMES: return NPI_ERMES;
584 case MFW_NPI_M_CTS: return NPI_CTS;
585 #endif
586 default: return NPI_Unknown;
587 }
588 }
589
590 /*
591 +--------------------------------------------------------------------+
592 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
593 | STATE : code ROUTINE: phb_cvtService |
594 +--------------------------------------------------------------------+
595
596
597 PURPOSE : This function is used to convert the service related to
598 the phone number used by ACI to the service related to
599 the phone numberused by MFW.
600
601 */
602
603 T_MFW_PHB_SERVICE phb_cvtService(T_ACI_CNUM_SERV service)
604 {
605 switch (service)
606 {
607 case CNUM_SERV_Asynch: return SERVICE_ASYNCH;
608 case CNUM_SERV_Synch: return SERVICE_SYNCH;
609 case CNUM_SERV_PadAsynch: return SERVICE_PAD_ASYNCH;
610 case CNUM_SERV_PacketSynch: return SERVICE_PACKET_SYNCH;
611 case CNUM_SERV_Voice: return SERVICE_VOICE;
612 case CNUM_SERV_Fax: return SERVICE_FAX;
613 default: return SERVICE_UNKNOWN;
614 }
615 }
616
617
618 /*
619 +--------------------------------------------------------------------+
620 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
621 | STATE : code ROUTINE: phb_init |
622 +--------------------------------------------------------------------+
623
624
625 PURPOSE :
626
627 */
628
629 void phb_init()
630 {
631 TRACE_FUNCTION ("phb_init()");
632
633 return;
634 }
635
636 /*
637 +--------------------------------------------------------------------+
638 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
639 | STATE : code ROUTINE : phb_read_entries |
640 +--------------------------------------------------------------------+
641
642 PURPOSE : Read phonebook entries
643
644 */
645 T_MFW phb_read_entries(UBYTE book,
646 UBYTE index,
647 UBYTE mode,
648 UBYTE num_entries,
649 T_MFW_PHB_LIST *entries)
650 {
651 SHORT start_ind;
652 SHORT stop_ind;
653 SHORT last_ind;
654 UBYTE rcd_num;
655 T_ACI_SR_TYP sr_type; /*a0393213 warnings removal-type of sr_type changed from UBYTE*/
656 SHORT i;
657 UBYTE x;
658 // Apr 14, 2005 REF: CRR 29991 xpradipg
659 // Define the local pointer since it occupies close to 650 bytes
660 #ifdef FF_MMI_OPTIM
661 T_ACI_PB_ENTR *pb_list;
662 #endif
663 TRACE_FUNCTION ("phb_read_entries()");
664 TRACE_EVENT_P4("book%d index%d mode%d num%d", book, index, mode, num_entries);
665
666 /* SPR#1112 - SH - Internal phonebook */
667 #ifdef INT_PHONEBOOK
668 if (book EQ PHB_IPB)
669 {
670 return GI_pb_ReadRecList(mode, index, num_entries, entries);
671 }
672 #endif
673
674 /* check type of phonebook */
675 if (book NEQ PHB_ECC
676 AND book NEQ PHB_ADN
677 AND book NEQ PHB_FDN
678 AND book NEQ PHB_BDN
679 AND book NEQ PHB_SDN
680 AND book NEQ PHB_LRN
681 AND book NEQ PHB_LDN
682 AND book NEQ PHB_LMN
683 AND book NEQ PHB_ADN_FDN
684 AND book NEQ PHB_UPN)
685 return MFW_PHB_FAIL;
686
687 if ((book EQ PHB_LRN
688 OR book EQ PHB_LDN
689 OR book EQ PHB_LMN)
690 AND (mode EQ MFW_PHB_NUMBER
691 OR mode EQ MFW_PHB_ALPHA))
692 return MFW_PHB_FAIL;
693
694 if (book EQ PHB_ECC
695 AND (mode EQ MFW_PHB_NUMBER
696 OR mode EQ MFW_PHB_ALPHA))
697 return MFW_PHB_FAIL;
698
699 if ((book EQ PHB_ADN_FDN)
700 AND (mode EQ MFW_PHB_INDEX))
701 return MFW_PHB_FAIL;
702
703 /* check index */
704 if (index <= 0)
705 return MFW_PHB_FAIL;
706
707 switch (mode)
708 {
709 case MFW_PHB_INDEX:
710 sr_type = SR_TYP_Index;
711 break;
712
713 case MFW_PHB_NUMBER:
714 sr_type = SR_TYP_Number;
715 break;
716
717 case MFW_PHB_ALPHA:
718 sr_type = SR_TYP_Name;
719 break;
720
721 case MFW_PHB_PHYSICAL:
722 sr_type = SR_TYP_Physical;
723 break;
724
725 default:
726 return MFW_PHB_FAIL;
727 }
728
729 /* select phonebook */
730 if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ((T_MFW_PHB_TYPE) book ), NULL) NEQ AT_CMPL)
731 return MFW_PHB_FAIL;
732
733 // March 1 ,2004 REF: CRR 27832 x0012852
734 // Bug:SIM PIN2 related Actions are displying wrong Error Response.
735 // Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
736
737 /* Read entries */
738 entries->book = book;
739 rcd_num = 0;
740 start_ind = index;
741 stop_ind = index + (num_entries - 1);
742 // Apr 14, 2005 REF: CRR 29991 xpradipg
743 // dynamic allocation
744 PB_LIST_ALLOC(pb_list,PB_LIST_SIZE);
745 while (num_entries > 0)
746 {
747 for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
748 pb_list[i].index = -1;
749
750 if (cmhPHB_PlusCPBR(CMD_SRC_LCL,
751 sr_type,
752 start_ind,
753 stop_ind,
754 &last_ind,
755 pb_list) EQ AT_CMPL)
756 {
757 x = 0;
758 for (i=start_ind; i<=last_ind; i++)
759 {
760 if (pb_list[x].index <= 0)
761 break;
762
763 memset(&entries->entry[rcd_num].date, 0, sizeof(entries->entry[rcd_num].date));
764 memset(&entries->entry[rcd_num].time, 0, sizeof(entries->entry[rcd_num].time));
765 if (book EQ PHB_LRN
766 OR book EQ PHB_LDN
767 OR book EQ PHB_LMN)
768 {
769 memcpy(entries->entry[rcd_num].date.year, pb_list[x].dateTime.year, PHB_MAX_DIGITS);
770 memcpy(entries->entry[rcd_num].date.month, pb_list[x].dateTime.month, PHB_MAX_DIGITS);
771 memcpy(entries->entry[rcd_num].date.day, pb_list[x].dateTime.day, PHB_MAX_DIGITS);
772 memcpy(entries->entry[rcd_num].time.hour, pb_list[x].dateTime.hour, PHB_MAX_DIGITS);
773 memcpy(entries->entry[rcd_num].time.minute, pb_list[x].dateTime.minute, PHB_MAX_DIGITS);
774 memcpy(entries->entry[rcd_num].time.second, pb_list[x].dateTime.second, PHB_MAX_DIGITS);
775 memcpy(&entries->entry[rcd_num].line, &pb_list[x].line, sizeof(UBYTE));
776 }
777 entries->entry[rcd_num].book = phb_decodePhbType (pb_list[x].book);
778 entries->entry[rcd_num].index = (UBYTE)pb_list[x].index;
779
780
781 // PATCH MAK 29/09/00. Put in because long number were overwriting the index therefore they were unable to be deleted
782 strncpy((char *)entries->entry[rcd_num].number, (char *)pb_list[x].number, (PHB_MAX_LEN-1));
783 // END PATCH MAK 29/09/00
784
785
786 #ifdef NO_ASCIIZ
787 memcpy(entries->entry[rcd_num].name.data, pb_list[x].text.data, pb_list[x].text.len);
788 entries->entry[rcd_num].name.len = pb_list[x].text.len;
789 #else
790 if (entries->entry[rcd_num].name[0] == 0x80 || entries->entry[rcd_num].name[0] == 0x00)
791 { /*MC, SPR 1257 PHB_MAX_LEN is 41 when phonebook extension on, ACI only stores 21 char*/
792 memcpy(entries->entry[rcd_num].name, pb_list[x].text.data, /*PHB_MAX_LEN*/MAX_ALPHA_LEN);
793 }
794 else
795 phb_Alpha2Gsm(&pb_list[x].text, entries->entry[rcd_num].name);
796 #endif
797 entries->entry[rcd_num].ton = phb_cvtTon(pb_list[x].type.ton);
798 entries->entry[rcd_num].npi = phb_cvtNpi(pb_list[x].type.npi);
799 rcd_num++;
800 x++;
801 }
802
803 if (num_entries <= PHB_MAX_ENTRY_NUM OR pb_list[x].index EQ -1)
804 num_entries = 0;
805 else
806 num_entries -= PHB_MAX_ENTRY_NUM;
807
808 start_ind = last_ind + 1;
809 }
810
811 else
812 {
813 // Apr 14, 2005 REF: CRR 29991 xpradipg
814 // deallocate memory before returning
815 PB_LIST_DEALLOC(pb_list,PB_LIST_SIZE);
816 return MFW_PHB_FAIL;
817 }
818 }
819
820 if (rcd_num)
821 {
822 entries->result = MFW_ENTRY_EXIST;
823 entries->num_entries = rcd_num;
824 }
825 else
826 {
827 entries->result = MFW_NO_ENTRY;
828 }
829 // Apr 14, 2005 REF: CRR 29991 xpradipg
830 // deallocate memory
831 PB_LIST_DEALLOC(pb_list,PB_LIST_SIZE);
832 return MFW_PHB_OK;
833 }
834
835
836
837 /* SPR#1727 - DS - Merged updated version from 1.6 branch. */
838
839 /* Test that the last 6 digits match.
840 If there are less than 6 numbers - its probably not a phone number.
841 GW- For emergency calls check a full exact match for the full (but short) length
842 */
843 int numbersMatch(char * num1, char* num2)
844 {
845 int j;
846 int len1,len2;
847 int nDigits = 6;
848 len1 = strlen(num1);
849 len2 = strlen(num2);
850
851 //If the strings are the same size, test up to 6 characters.
852 if (len1 == len2)
853 nDigits = len1;
854
855 //Test at least 2 digits and at most 6.
856 if ((nDigits >6 ) || (nDigits<2))
857 nDigits = 6;
858
859 //Is either string too short ?
860 if ((len1 < nDigits) || (len2 < nDigits))
861 return (0);
862
863 //Check last 'nDigit' characters
864 for (j=0;j<nDigits;j++)
865 {
866 if (num1[len1-j] != num2[len2-j])
867 return (0);
868 }
869 return (1);
870 }
871
872 /*
873 +--------------------------------------------------------------------+
874 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
875 | STATE : code ROUTINE : phb_find_entries |
876 +--------------------------------------------------------------------+
877
878 PURPOSE : Find phonebook entries
879
880 */
881
882 #ifdef NO_ASCIIZ
883 T_MFW phb_find_entries(UBYTE book,
884 SHORT *index,
885 UBYTE mode,
886 SHORT num_entries,
887 T_MFW_PHB_TEXT *search_pattern,
888 T_MFW_PHB_LIST *entries)
889 {
890 // ADDED BY RAVI - ACI CHANGES - 5-10-2005
891 #if (defined(FF_2TO1_PS) && BOARD != 61)
892 UBYTE found;
893 #else
894 SHORT found;
895 #endif
896 // END ADDITION - RAVI - 5-10-2005
897 UBYTE i;
898 SHORT rcd_num;
899 T_ACI_CPBF_MOD search_mode;/*a0393213 warnings removal-type of search_mode changed from UBYTE*/
900 T_ACI_SR_TYP sr_type;/*a0393213 warnings removal-type of sr_type changed from UBYTE*/
901 UBYTE sum;
902 T_ACI_PB_TEXT findText;
903 /*SPR2102, removed dbg variable*/
904 // Apr 14, 2005 REF: CRR 29991 xpradipg
905 // local pointer definition
906 #ifdef FF_MMI_OPTIM
907 T_ACI_PB_ENTR *pb_list;
908 #endif
909 TRACE_FUNCTION ("phb_find_entries()");
910
911 /* SPR#1112 - SH - Internal phonebook */
912 #ifdef INT_PHONEBOOK
913 if (book EQ PHB_IPB)
914 {
915 return GI_pb_Find(mode, (UBYTE *)index, num_entries, search_pattern, entries);
916 }
917 #endif
918
919 if (book NEQ ECC
920 AND book NEQ PHB_ADN
921 AND book NEQ PHB_FDN
922 AND book NEQ PHB_BDN
923 AND book NEQ PHB_SDN
924 AND book NEQ PHB_ADN_FDN
925 AND book NEQ PHB_UPN)
926 return MFW_PHB_FAIL;
927
928 if ((book EQ PHB_ADN_FDN)
929 AND (mode EQ MFW_PHB_INDEX))
930 return MFW_PHB_FAIL;
931
932 switch (mode)
933 {
934 case MFW_PHB_INDEX:
935 sr_type = SR_TYP_Index;
936 break;
937
938 case MFW_PHB_NUMBER:
939 sr_type = SR_TYP_Number;
940 break;
941
942 case MFW_PHB_ALPHA:
943 if (!search_pattern->len)
944 return PHB_FAIL;
945 sr_type = SR_TYP_Name;
946 break;
947
948 case MFW_PHB_PHYSICAL:
949 sr_type = SR_TYP_Physical;
950 break;
951
952 default:
953 return MFW_PHB_FAIL;
954 }
955
956 /* select phonebook */
957 if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ((T_MFW_PHB_TYPE) book ), NULL) NEQ AT_CMPL)
958 return MFW_PHB_FAIL;
959
960 // March 1 ,2004 REF: CRR 27832 x0012852
961 // Bug:SIM PIN2 related Actions are displying wrong Error Response.
962 // Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
963
964
965 TRACE_FUNCTION ("phb_find_entries()-got phonebook");
966
967 entries->book = book;
968 rcd_num = 0;
969 sum = num_entries;
970 search_mode = CPBF_MOD_NewSearch;
971 // Apr 14, 2005 REF: CRR 29991 xpradipg
972 // allocate memory
973 PB_LIST_ALLOC(pb_list, PB_LIST_SIZE);
974 while (num_entries > 0)
975 {
976 for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
977 pb_list[i].index = -1;
978
979 if (mode EQ MFW_PHB_ALPHA)
980 {
981 findText.len = MINIMUM(search_pattern->len, MAX_ALPHA_LEN);
982 memcpy(findText.data, search_pattern->data, findText.len);
983 }
984 else
985 {
986 findText.len = MINIMUM(search_pattern->len, MAX_PHB_NUM_LEN-1); //GW -SPR#762
987 strncpy((char *)findText.data, (char *)search_pattern->data, findText.len);
988 findText.data[findText.len] = '\0';
989 }
990 findText.cs = CS_Sim;
991 if (cmhPHB_PlusCPBF(CMD_SRC_LCL,
992 &findText,
993 sr_type,
994 search_mode,
995 /*ADDED BY RAVI - ACI CHANGES - 5-10-2005*/
996 #if (defined(FF_2TO1_PS) && BOARD != 61)
997 (UBYTE *)index,
998 #else
999 index,
1000 #endif
1001 /*END ADDITION - RAVI - 5-10-2005*/
1002 &found,
1003 pb_list) EQ AT_CMPL)
1004 {
1005 /*SPR 2102, removed traces which were causing a crash for long phone numbers*/
1006 for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
1007 {
1008 if ((pb_list[i].index != -1) && (rcd_num < sum))
1009 {
1010 TRACE_FUNCTION ("phb_find_entries()-found entry");
1011 /*SPR 2102, removed traces which were causing a crash for long phone numbers*/
1012
1013 if (numbersMatch((char*)pb_list[i].number,(char*)search_pattern->data))
1014 {
1015 TRACE_FUNCTION ("phb_find_entries()-numbers match");
1016 entries->entry[rcd_num].book = phb_decodePhbType (pb_list[i].book);
1017 entries->entry[rcd_num].index = (UBYTE)pb_list[i].index;
1018 strcpy((char *)entries->entry[rcd_num].number, (char *)pb_list[i].number);
1019 memcpy(entries->entry[rcd_num].name.data, pb_list[i].text.data, pb_list[i].text.len);
1020 entries->entry[rcd_num].name.len = pb_list[i].text.len;
1021 entries->entry[i].ton = phb_cvtTon(pb_list[rcd_num].type.ton);
1022 entries->entry[i].npi = phb_cvtNpi(pb_list[rcd_num].type.npi);
1023 rcd_num++;
1024 }
1025 }
1026 else
1027 break;
1028 }
1029
1030 if (num_entries <= PHB_MAX_ENTRY_NUM)
1031 num_entries = 0;
1032 else
1033 num_entries = num_entries - PHB_MAX_ENTRY_NUM;
1034
1035 if (search_mode EQ CPBF_MOD_NewSearch)
1036 {
1037 #ifdef FF_2TO1_PS
1038 entries->num_entries = (U16)found;
1039 #else
1040 entries->num_entries = found;
1041 #endif
1042 search_mode = CPBF_MOD_NextSearch;
1043 }
1044 }
1045 else
1046 break;
1047 }
1048
1049 if (rcd_num)
1050 {
1051 entries->result = MFW_ENTRY_EXIST;
1052 }
1053 else
1054 {
1055 entries->result = MFW_NO_ENTRY;
1056
1057 }
1058
1059 /*SPR#1727 - DS - Use rcd_num variable from the for loop (that added entries to the entry structure) to set the number of entries.
1060 * "found" variable should not be used because it may be corrupted by the ACI and set to a false value if there
1061 * are no matching entries in the phoneook.
1062 */
1063 entries->num_entries = rcd_num;
1064 // Apr 14, 2005 REF: CRR 29991 xpradipg
1065 // deallocate memory
1066 PB_LIST_DEALLOC(pb_list,PB_LIST_SIZE);
1067 return MFW_PHB_OK;
1068 }
1069
1070 #else
1071 T_MFW phb_find_entries(UBYTE book,
1072 SHORT *index,
1073 UBYTE mode,
1074 SHORT num_entries,
1075 CHAR *search_pattern,
1076 T_MFW_PHB_LIST *entries)
1077 {
1078 // ADDED BY RAVI - ACI CHANGES - 5-10-2005
1079 #if (defined(FF_2TO1_PS) && BOARD != 61)
1080 UBYTE found;
1081 #else
1082 SHORT found;
1083 #endif
1084 // END ADDITION - RAVI-5-10-2005
1085 UBYTE i;
1086 UBYTE rcd_num;
1087 UBYTE search_mode;
1088 UBYTE sr_type;
1089 UBYTE sum;
1090 T_ACI_PB_TEXT findText;
1091
1092 TRACE_FUNCTION ("phb_find_entries()");
1093
1094 if (book NEQ ECC
1095 AND book NEQ PHB_ADN
1096 AND book NEQ PHB_FDN
1097 AND book NEQ PHB_BDN
1098 AND book NEQ PHB_SDN
1099 AND book NEQ PHB_ADN_FDN
1100 AND book NEQ PHB_UPN)
1101 return MFW_PHB_FAIL;
1102
1103 if ((book EQ PHB_ADN_FDN)
1104 AND (mode EQ MFW_PHB_INDEX))
1105 return MFW_PHB_FAIL;
1106
1107 switch (mode)
1108 {
1109 case MFW_PHB_INDEX:
1110 sr_type = SR_TYP_Index;
1111 break;
1112
1113 case MFW_PHB_NUMBER:
1114 sr_type = SR_TYP_Number;
1115 break;
1116
1117 case MFW_PHB_ALPHA:
1118 sr_type = SR_TYP_Name;
1119 break;
1120
1121 case MFW_PHB_PHYSICAL:
1122 sr_type = SR_TYP_Physical;
1123 break;
1124
1125 default:
1126 return MFW_PHB_FAIL;
1127 }
1128
1129 /* select phonebook */
1130 if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ( (T_MFW_PHB_TYPE)book ), NULL) NEQ AT_CMPL)
1131 return MFW_PHB_FAIL;
1132
1133 // March 1 ,2004 REF: CRR 27832 x0012852
1134 // Bug:SIM PIN2 related Actions are displying wrong Error Response.
1135 // Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
1136
1137 entries->book = book;
1138 rcd_num = 0;
1139 sum = num_entries;
1140 search_mode = CPBF_MOD_NewSearch;
1141
1142 while (num_entries > 0)
1143 {
1144 for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
1145 pb_list[i].index = -1;
1146
1147 findText.len = MINIMUM(strlen(search_pattern), PHB_MAX_LEN-1); //GW -SPR#762 - was MAX_ALPHA_LEN-1);
1148 strncpy((char *)findText.data, search_pattern, findText.len);
1149 findText.data[findText.len] = '\0';
1150 findText.cs = CS_Sim;
1151
1152 if (cmhPHB_PlusCPBF(CMD_SRC_LCL,
1153 &findText,
1154 sr_type,
1155 search_mode,
1156 /*ADDED BY RAVI - ACI CHANGES - 5-10-2005 */
1157 #if (defined(FF_2TO1_PS) && BOARD != 61)
1158 (UBYTE *)index,
1159 #else
1160 index,
1161 #endif
1162 /*END ADDITION - RAVI - 5-10-2005 */
1163 &found,
1164 pb_list) EQ AT_CMPL)
1165 {
1166 for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
1167 {
1168 if (pb_list[i].index NEQ -1 AND rcd_num < sum)
1169 {
1170 entries->entry[rcd_num].book = phb_decodePhbType (pb_list[i].book);
1171 entries->entry[rcd_num].index = (UBYTE)pb_list[i].index;
1172 strcpy((char *)entries->entry[rcd_num].number, (char *)pb_list[i].number);
1173 phb_Alpha2Gsm(&pb_list[i].text, entries->entry[rcd_num].name);
1174 entries->entry[i].ton = phb_cvtTon(pb_list[rcd_num].type.ton);
1175 entries->entry[i].npi = phb_cvtNpi(pb_list[rcd_num].type.npi);
1176 rcd_num++;
1177 }
1178 else
1179 break;
1180 }
1181
1182 if (num_entries <= PHB_MAX_ENTRY_NUM)
1183 num_entries = 0;
1184 else
1185 num_entries = num_entries - PHB_MAX_ENTRY_NUM;
1186
1187 if (search_mode EQ CPBF_MOD_NewSearch)
1188 {
1189 #ifdef FF_2TO1_PS
1190 entries->num_entries = (U16)found;
1191 #else
1192 entries->num_entries = found;
1193 #endif
1194 search_mode = CPBF_MOD_NextSearch;
1195 }
1196 }
1197 else
1198 break;
1199 }
1200
1201 if (rcd_num)
1202 entries->result = MFW_ENTRY_EXIST;
1203 else
1204 entries->result = MFW_NO_ENTRY;
1205
1206 /*SPR#1727 - DS - Use rcd_num variable from the for loop (that added entries to the entry structure) to set the number of entries.
1207 * "found" variable should not be used because it may be corrupted by the ACI and set to a false value if there
1208 * are no matching entries in the phoneook.
1209 */
1210 entries->num_entries = rcd_num;
1211
1212 return MFW_PHB_OK;
1213 }
1214 #endif
1215
1216 /*
1217 +--------------------------------------------------------------------+
1218 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1219 | STATE : code ROUTINE : phb_store_entry |
1220 +--------------------------------------------------------------------+
1221
1222 PURPOSE : Store phonebook entry
1223
1224 */
1225
1226 T_MFW phb_store_entry(UBYTE book,
1227 T_MFW_PHB_ENTRY *entry,
1228 T_MFW_PHB_STATUS *status)
1229 {
1230 // ADDED BY RAVI - ACI CHANGES - 5-10-2005
1231 #if (defined(FF_2TO1_PS) && BOARD != 61)
1232 UBYTE used;
1233 UBYTE total;
1234 UBYTE avail;
1235 #else
1236 SHORT used;
1237 SHORT total;
1238 SHORT avail;
1239 #endif
1240 // END ADDITION - RAVI - 5-10-2005
1241 #ifdef TI_PS_FFS_PHB
1242 UBYTE nlength;
1243 #endif
1244 SHORT used_ext;
1245 SHORT total_ext;
1246 UBYTE tlength;
1247 #ifndef TI_PS_FFS_PHB
1248 UBYTE service;
1249 #endif
1250 T_ACI_VP_ABS dt;
1251 T_ACI_PB_TEXT text;
1252 T_ACI_TOA toa;
1253 T_ACI_RETURN phb_result;
1254
1255 //jgg
1256 TRACE_EVENT("jgg-phb_store_entry");
1257 //jgg
1258
1259 /* SPR#1112 - SH - Internal phonebook */
1260 #ifdef INT_PHONEBOOK
1261 if (book EQ PHB_IPB)
1262 {
1263 T_MFW ret;
1264 ret = GI_pb_WriteRec(entry);
1265 GI_pb_Info(status);
1266 return ret;
1267 }
1268 #endif
1269
1270 /* check type of phonebook */
1271 if (book NEQ PHB_ECC
1272 AND book NEQ PHB_ADN
1273 AND book NEQ PHB_FDN
1274 AND book NEQ PHB_BDN
1275 AND book NEQ PHB_SDN
1276 AND book NEQ PHB_LRN
1277 AND book NEQ PHB_LDN
1278 AND book NEQ PHB_LMN
1279 AND book NEQ PHB_UPN)
1280 return MFW_PHB_FAIL;
1281
1282 /* select phonebook */
1283 if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ((T_MFW_PHB_TYPE) book ), NULL) NEQ AT_CMPL)
1284 return MFW_PHB_FAIL;
1285
1286 // March 1 ,2004 REF: CRR 27832 x0012852
1287 // Bug:SIM PIN2 related Actions are displying wrong Error Response.
1288 // Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
1289
1290 memset(&dt, 0, sizeof(T_ACI_VP_ABS));
1291 if (book EQ PHB_LDN
1292 OR book EQ PHB_LRN
1293 OR book EQ PHB_LMN)
1294 {
1295 memcpy(dt.year, entry->date.year, PHB_MAX_DIGITS);
1296 memcpy(dt.month, entry->date.month, PHB_MAX_DIGITS);
1297 memcpy(dt.day, entry->date.day, PHB_MAX_DIGITS);
1298 memcpy(dt.hour, entry->time.hour, PHB_MAX_DIGITS);
1299 memcpy(dt.minute, entry->time.minute, PHB_MAX_DIGITS);
1300 memcpy(dt.second, entry->time.second, PHB_MAX_DIGITS);
1301 }
1302
1303 // Oct 27, 2005 REF: OMAPS 48881 b-nekkare
1304 if (entry->number[0] EQ '+' )
1305 toa.ton=TON_International;
1306 else
1307 toa.ton=TON_Unknown;
1308
1309 toa.npi=NPI_IsdnTelephony;
1310
1311 #ifdef NO_ASCIIZ
1312 text.len = entry->name.len;
1313 memcpy(text.data, entry->name.data, text.len);
1314 text.cs = CS_Sim;
1315 #else
1316 phb_Gsm2Alpha(entry->name, &text);
1317 #endif
1318 // July 17, 2006 DR: OMAPS00082792 x0039928
1319 phb_result = sAT_PlusCPBW(CMD_SRC_LCL,
1320 (SHORT)(entry->index EQ 0 ? ACI_NumParmNotPresent : entry->index),
1321 (char *)entry->number,
1322 &toa,
1323 &text,
1324 &dt);
1325 switch(phb_result)
1326 {
1327 case AT_CMPL:
1328 #if !defined(TI_PS_FFS_PHB)
1329 pb_read_status(book, &service, &total, &used, &tlength, &avail,&used_ext, &total_ext);
1330 #else
1331 (void)pb_read_sizes ((T_PHB_TYPE)book, &total, &used, &nlength, &tlength, /*a0393213 warnings removal-explicit typecasting done*/
1332 &used_ext, &total_ext); /*a0393213 OMAPS00097209 - interface of pb_read_sizes has been changed in ACI side*/
1333 avail = total - used;
1334 #endif
1335
1336 status->book = book;
1337 status->tag_len = tlength;
1338 #ifdef FF_2TO1_PS
1339 status->max_entries = (U16)total;
1340 status->used_entries = (U16)used;
1341 status->avail_entries = (U16)avail;
1342 #else
1343 status->max_entries = total;
1344 status->used_entries = used;
1345 status->avail_entries = avail;
1346 #endif
1347 //x0061560 Date May17,07 (sateeshg) OMAPS00133241
1348 return MFW_PHB_OK;
1349 case AT_EXCT:
1350 #ifndef TI_PS_FFS_PHB // Flushing not necessary with FFS based SIM PHB
1351 if (book EQ PHB_LDN
1352 OR book EQ PHB_LRN
1353 OR book EQ PHB_LMN)
1354 {
1355
1356 pb_write_eeprom();
1357 }
1358 #endif
1359
1360 //x0061560 Date May16,07 (sateeshg) OMAPS00133241
1361 return MFW_PHB_EXCT;
1362
1363 default:
1364 return MFW_PHB_FAIL;
1365 }
1366 }
1367
1368 /*
1369 +--------------------------------------------------------------------+
1370 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1371 | STATE : code ROUTINE : phb_delete_entry |
1372 +--------------------------------------------------------------------+
1373
1374 PURPOSE : Delete phonebook entry
1375
1376 */
1377
1378 T_MFW phb_delete_entry(UBYTE book, UBYTE index, T_MFW_PHB_STATUS *status)
1379 {
1380 // ADDED BY RAVI - ACI CHANGES - 5-10-2005
1381 #if (defined(FF_2TO1_PS) && BOARD != 61)
1382 UBYTE used;
1383 UBYTE total;
1384 UBYTE avail;
1385 #else
1386 SHORT used;
1387 SHORT total;
1388 SHORT avail;
1389 #endif
1390 // END ADDITION BY RAVI - 5-10-2005
1391 #ifdef TI_PS_FFS_PHB
1392 UBYTE nlength;
1393 #endif
1394 SHORT used_ext;
1395 SHORT total_ext;
1396 UBYTE tlength;
1397 #ifndef TI_PS_FFS_PHB
1398 UBYTE service;
1399 #endif
1400 T_ACI_VP_ABS dt;
1401 T_ACI_RETURN phb_result;
1402
1403 TRACE_FUNCTION("phb_delete_entry()");
1404
1405 /* SPR#1112 - SH - Internal phonebook */
1406 #ifdef INT_PHONEBOOK
1407 if (book EQ PHB_IPB)
1408 {
1409 T_MFW ret;
1410
1411 ret = GI_pb_DeleteRec(index);
1412 GI_pb_Info(status);
1413
1414 return ret;
1415 }
1416 #endif
1417
1418 /* check type of phonebook */
1419 if (book NEQ PHB_ECC
1420 AND book NEQ PHB_LDN
1421 AND book NEQ PHB_LRN
1422 AND book NEQ PHB_LMN
1423 AND book NEQ PHB_ADN
1424 AND book NEQ PHB_FDN
1425 AND book NEQ PHB_BDN
1426 AND book NEQ PHB_SDN
1427 AND book NEQ PHB_UPN)
1428 return MFW_PHB_FAIL;
1429
1430 /* select phonebook */
1431 if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ( (T_MFW_PHB_TYPE)book ), NULL) NEQ AT_CMPL)
1432 return MFW_PHB_FAIL;
1433
1434 // March 1 ,2004 REF: CRR 27832 x0012852
1435 // Bug:SIM PIN2 related Actions are displying wrong Error Response.
1436 // Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
1437
1438
1439 memset(&dt, 0, sizeof(T_ACI_VP_ABS));
1440
1441 //July 17, 2006 DR: OMAPS00082792 x0039928
1442 phb_result = sAT_PlusCPBW(CMD_SRC_LCL, index, NULL, NULL, NULL, &dt);
1443
1444 switch(phb_result)
1445 {
1446 case AT_CMPL:
1447 #if !defined(TI_PS_FFS_PHB)
1448 pb_read_status(book, &service, &total, &used, &tlength, &avail,&used_ext, &total_ext);
1449 #else
1450 (void)pb_read_sizes ((T_PHB_TYPE)book, &total, &used, &nlength, &tlength, /*a0393213 warnings removal-explicit typecasting done*/
1451 &used_ext, &total_ext); /*a0393213 OMAPS00097209 - interface of pb_read_sizes has been changed in ACI side*/
1452 avail = total - used;
1453 #endif
1454
1455 status->book = book;
1456 status->tag_len = tlength;
1457 #ifdef FF_2TO1_PS
1458 status->max_entries = (U16)total;
1459 status->used_entries = (U16)used;
1460 status->avail_entries = (U16)avail;
1461 #else
1462 status->max_entries = total;
1463 status->used_entries = used;
1464 status->avail_entries = avail;
1465 #endif
1466 case AT_EXCT:
1467 return MFW_PHB_OK;
1468 default:
1469 return MFW_PHB_FAIL;
1470 }
1471 }
1472
1473
1474
1475 /*
1476 +--------------------------------------------------------------------+
1477 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1478 | STATE : code ROUTINE : phb_set_mode |
1479 +--------------------------------------------------------------------+
1480
1481 PURPOSE : Set the unrestricted/restricted mode for FDN or BDN
1482
1483 */
1484
1485 T_MFW phb_set_mode(UBYTE book, UBYTE *passwd)
1486 {
1487 if (book EQ PHB_FDN)
1488 {
1489 /*a0393213 warnings removal - CLCK_FAC_Fd changed to FAC_Fd after ACI enum changes*/
1490 if (ss_set_clck(FAC_Fd, CLCK_MOD_Lock,
1491 (char *)passwd, CLASS_VceDatFaxSms, MFW_PHB) != MFW_SS_OK)
1492 {
1493 return MFW_PHB_FAIL;
1494 }
1495 }
1496 if (book EQ PHB_ADN)
1497 {
1498 /*a0393213 warnings removal - CLCK_FAC_Fd changed to FAC_Fd after ACI enum changes*/
1499 if (ss_set_clck(FAC_Fd, CLCK_MOD_Unlock,
1500 (char *)passwd, CLASS_VceDatFaxSms, MFW_PHB) != MFW_SS_OK)
1501 {
1502 return MFW_PHB_FAIL;
1503 }
1504 }
1505 return MFW_PHB_OK;
1506 }
1507
1508
1509 /*
1510 +--------------------------------------------------------------------+
1511 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1512 | STATE : code ROUTINE : phb_ok_clck |
1513 +--------------------------------------------------------------------+
1514
1515 PURPOSE : successful switch for FDN
1516
1517 */
1518
1519 void phb_ok_clck()
1520 {
1521 T_MFW_PHB_STATUS status;
1522
1523 memset(&status, 0, sizeof(T_MFW_PHB_STATUS));
1524 status.book = FDN;
1525 phb_get_status(&status);
1526 phb_signal(E_PHB_STATUS, &status);
1527 }
1528
1529
1530 /*
1531 +--------------------------------------------------------------------+
1532 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1533 | STATE : code ROUTINE : phb_error_clck |
1534 +--------------------------------------------------------------------+
1535
1536 PURPOSE : unsuccessful switch for FDN or BDN
1537
1538 */
1539
1540 void phb_error_clck()
1541 {
1542 phb_signal(E_PHB_ERROR, 0);
1543 }
1544
1545
1546 /*
1547 +--------------------------------------------------------------------+
1548 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1549 | STATE : code ROUTINE : phb_check_number |
1550 +--------------------------------------------------------------------+
1551
1552 PURPOSE : Check number against the restrictions for FDN or BDN
1553
1554 */
1555
1556 T_MFW phb_check_number(UBYTE *number)
1557 {
1558 #if (defined(FF_2TO1_PS))
1559 UBYTE found;
1560 UBYTE index;
1561 T_PHB_RECORD entry;
1562 T_ACI_PB_TEXT text;
1563 #endif
1564 UBYTE toa;
1565 T_ACI_TOA ton_npi;
1566 int i;
1567 int len = strlen((char *)number);
1568
1569 /* Search for '+' digit */
1570 for (i = 0; (i < len) && (number[i] != '+'); i++);
1571
1572 /* '+' has been found */
1573 if (i != len)
1574 {
1575 ton_npi.ton = TON_International;
1576
1577 /* Move characters of the input string to suppress the '+' */
1578 for (i++; i < len; i++)
1579 number[i-1] = number[i];
1580 number[i-1] = '\0';
1581 }
1582 else
1583 ton_npi.ton = TON_Unknown;
1584
1585 ton_npi.npi = NPI_IsdnTelephony;
1586 cmhPHB_toaMrg ( &ton_npi, &toa );
1587
1588 /* --->>>--- */
1589 #if defined(FF_2TO1_PS)
1590 if (pb_check_fdn(FDN, number, &found, &entry, toa) NEQ PHB_OK)
1591 return MFW_PHB_FAIL;
1592 if (found)
1593 return PHB_FDN;
1594
1595 #else
1596 /* The old pb_check_fdn() either delivered PHB_OK and found == 1 or
1597 * PHB_FAIL and found == 0. Other combintations were not possibe,
1598 * especially PHB_OK and found == 0. Some unreachable / dead code here.
1599 * Found on g23m S621 by HM 21-Sep-2005 */
1600 if (pb_check_fdn(toa, number) NEQ PHB_OK)
1601 return MFW_PHB_FAIL;
1602 return PHB_FDN;
1603 #endif /* else, #if defined(FF_2TO1_PS) */
1604 /* ---<<<--- */
1605
1606 #if defined(FF_2TO1_PS)
1607 {
1608 T_ACI_PB_ENTR *pb_list;
1609 if (sAT_PlusCPBS(CMD_SRC_LCL, PB_STOR_Bd, NULL) NEQ AT_CMPL)
1610 return MFW_PHB_FAIL;
1611
1612
1613 // March 1 ,2004 REF: CRR 27832 x0012852 SELIM
1614 // Bug:SIM PIN2 related Actions are displying wrong Error Response.
1615 // Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
1616
1617 text.len = MINIMUM(strlen((char *)number), PHB_MAX_LEN-1); //GW -SPR#762 - was MAX_ALPHA_LEN-1);
1618 strncpy((char *)text.data, (char *)number, text.len);
1619 text.data[text.len] = '\0';
1620 text.cs = CS_Sim;
1621 // Apr 14, 2005 REF: CRR 29991 xpradipg
1622 // allocate memory
1623 PB_LIST_ALLOC(pb_list, PB_LIST_SIZE);
1624 if (cmhPHB_PlusCPBF(CMD_SRC_LCL,
1625 &text,
1626 SR_TYP_Number,
1627 CPBF_MOD_NewSearch, &index,
1628 &found, pb_list) NEQ AT_CMPL)
1629 {
1630 // Apr 14, 2005 REF: CRR 29991 xpradipg
1631 // deallocate memory
1632 PB_LIST_DEALLOC(pb_list, PB_LIST_SIZE);
1633 return MFW_PHB_FAIL;
1634 }
1635 if (found)
1636 {
1637 // Apr 14, 2005 REF: CRR 29991 xpradipg
1638 // deallocate memory
1639 PB_LIST_DEALLOC(pb_list, PB_LIST_SIZE);
1640 return PHB_BDN;
1641 }
1642 // Apr 14, 2005 REF: CRR 29991 xpradipg
1643 // deallocat memory
1644 PB_LIST_DEALLOC(pb_list, PB_LIST_SIZE);
1645 return PHB_OK;
1646 }
1647 #endif
1648
1649 }
1650
1651
1652 /*
1653 +--------------------------------------------------------------------+
1654 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1655 | STATE : code ROUTINE : phb_get_status |
1656 +--------------------------------------------------------------------+
1657
1658 PURPOSE : Check number against the restrictions for FDN or BDN
1659
1660 */
1661
1662 T_MFW phb_get_status(T_MFW_PHB_STATUS *status)
1663 {
1664 // ADDED BY RAVI - ACI CHANGES - 5-10-2005
1665 #if (defined(FF_2TO1_PS) && BOARD != 61)
1666 UBYTE used;
1667 UBYTE total;
1668 UBYTE avail;
1669 #else
1670 SHORT used;
1671 SHORT total;
1672 SHORT avail;
1673 #endif
1674
1675 // END ADDITION BY RAVI - 5-10-2005
1676 T_PHB_TYPE type;/*a0393213 warnings removal-data type of 'type' changed from UBYTE*/
1677 #ifdef TI_PS_FFS_PHB
1678 UBYTE num_len;
1679 #endif
1680 SHORT used_ext;
1681 SHORT total_ext;
1682 #ifndef TI_PS_FFS_PHB
1683 UBYTE service;
1684 #endif
1685 UBYTE tag_len;
1686
1687 TRACE_FUNCTION("phb_get_status()");
1688
1689 /* SPR#1112 - SH - Internal phonebook */
1690 #ifdef INT_PHONEBOOK
1691 if (status->book EQ PHB_IPB)
1692 {
1693 GI_pb_Info(status);
1694 return MFW_PHB_OK;
1695 }
1696 #endif
1697
1698 switch (status->book)
1699 {
1700 case PHB_ECC:
1701 type = ECC;
1702 break;
1703 case PHB_ADN:
1704 type = ADN;
1705 break;
1706 case PHB_FDN:
1707 type = FDN;
1708 break;
1709 #ifndef TI_PS_FFS_PHB
1710 case PHB_ADN_FDN:
1711 type = ADN_FDN;
1712 break;
1713 #endif
1714 case PHB_BDN:
1715 type = BDN;
1716 break;
1717 case PHB_SDN:
1718 type = SDN;
1719 break;
1720 case PHB_LRN:
1721 type = LRN;
1722 break;
1723 case PHB_LDN:
1724 type = LDN;
1725 break;
1726 case PHB_LMN:
1727 type = LMN;
1728 break;
1729 case PHB_UPN:
1730 type = UPN;
1731 break;
1732 default:
1733 return MFW_PHB_FAIL;
1734 }
1735
1736 #if !defined(TI_PS_FFS_PHB)
1737 if (pb_read_status(type, &service, &total, &used,
1738 &tag_len, &avail,&used_ext, &total_ext) == PHB_FAIL)
1739 return MFW_PHB_FAIL;
1740 #else
1741 if (pb_read_sizes (type, &total, &used, &num_len, &tag_len,
1742 &used_ext, &total_ext) == PHB_FAIL) /*a0393213 OMAPS00097209 - interface of pb_read_sizes has been changed in ACI side*/
1743 return MFW_PHB_FAIL;
1744 avail = total - used;
1745 #endif
1746
1747 status->tag_len = tag_len;
1748 #ifdef FF_2TO1_PS
1749 status->max_entries = (U16)total;
1750 status->used_entries = (U16)used;
1751 status->avail_entries = (U16)avail;
1752 #else
1753 status->max_entries = total;
1754 status->used_entries = used;
1755 status->avail_entries = avail;
1756 #endif
1757 return MFW_PHB_OK;
1758 }
1759
1760
1761 /*
1762 +--------------------------------------------------------------------+
1763 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1764 | STATE : code ROUTINE : phb_get_mode |
1765 +--------------------------------------------------------------------+
1766
1767 PURPOSE : Request the status of FDN
1768
1769 */
1770
1771 int phb_get_mode(void)
1772 {
1773 T_ACI_CLSSTAT clsStat;
1774
1775 #ifdef TI_PS_FFS_PHB
1776 if (pb_stat == PB_STAT_Busy)
1777 return PHB_LOADING;
1778
1779 if (pb_stat != PB_STAT_Ready)
1780 return MFW_PHB_FAIL;
1781 #else
1782 UBYTE stat;
1783
1784 pb_status_req(&stat);
1785 if (stat == PHB_BUSY)
1786 return PHB_LOADING;
1787
1788 if (stat != PHB_READY)
1789 return MFW_PHB_FAIL;
1790 #endif
1791 /*a0393213 warnings removal - CLCK_FAC_Fd changed to FAC_Fd after ACI enum changes*/
1792 if (qAT_PlusCLCK(CMD_SRC_LCL, FAC_Fd,
1793 CLASS_NotPresent, &clsStat) EQ AT_CMPL)
1794 {
1795 switch (clsStat.status)
1796 {
1797 case STATUS_NotActive:
1798 return PHB_UNRESTRICTED;
1799
1800 case STATUS_Active:
1801 return PHB_RESTRICTED;
1802
1803 case STATUS_NotPresent:
1804 return PHB_NOT_ALLOCATED;
1805 }
1806 }
1807 return MFW_PHB_FAIL;
1808 }
1809
1810
1811 /*
1812 +--------------------------------------------------------------------+
1813 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1814 | STATE : code ROUTINE : phb_delete_book |
1815 +--------------------------------------------------------------------+
1816
1817 PURPOSE :
1818
1819 */
1820
1821 T_MFW phb_delete_book(UBYTE book)
1822 {
1823 T_MFW_PHB_STATUS status;
1824 T_MFW_PHB_ENTRY entry;
1825 T_MFW_PHB_LIST entries;
1826 T_MFW_PHB_RETURN v_returnedStatus = MFW_PHB_OK;
1827 T_PHB_RETURN phb_return;
1828
1829 TRACE_FUNCTION("phb_delete_book()");
1830
1831 if (book == PHB_ADN OR
1832 book == PHB_FDN OR
1833 book == PHB_BDN OR
1834 book == PHB_SDN OR
1835 book == PHB_UPN)
1836
1837 {
1838 #ifdef TI_PS_FFS_PHB
1839 /*
1840 * When we're returning MFW_PHB_OK and the book is a SIM book
1841 * normally we're not really finished with the operation here
1842 * as the synchronization to the SIM is still ongoing.
1843 */
1844 phb_return = pb_del_book((T_PHB_TYPE)book);/*a0393213 warnings removal-explicit typecasting done*/
1845 if ((phb_return EQ PHB_OK) OR (phb_return EQ PHB_EXCT))
1846 #else
1847 if (pb_delete_book(book) == PHB_OK)
1848 #endif
1849 return MFW_PHB_OK;
1850 else
1851 return MFW_PHB_FAIL;
1852 }
1853
1854 entries.entry = &entry;
1855 status.book = book;
1856 phb_get_status(&status);
1857
1858 /*
1859 * PATCH CDB 12 04 2000 : This function has been modified to store the RAM copy of the
1860 * LDN/LMN/LRN phonebook in E2PROM. As we had returns in the middle of the function,
1861 * we have to make a record of each possible returned value of the various function,
1862 * then return it. At the end, we return the copied returned value.
1863 */
1864 while (status.used_entries)
1865 {
1866 if (phb_read_entries(book, 1, MFW_PHB_INDEX, 1, &entries) != MFW_PHB_OK)
1867 {
1868 v_returnedStatus = MFW_PHB_FAIL;
1869 break;
1870 }
1871
1872 if (!entries.num_entries)
1873 {
1874 v_returnedStatus = MFW_PHB_OK;
1875 break;
1876 }
1877
1878 if (phb_delete_entry(book, entries.entry->index, &status)!= MFW_PHB_OK)
1879 {
1880 v_returnedStatus = MFW_PHB_FAIL;
1881 break;
1882 }
1883 }
1884
1885 #ifndef TI_PS_FFS_PHB // Flushing not necessary with FFS based SIM PHB
1886 if ((book EQ PHB_LDN) OR (book EQ PHB_LRN) OR (book EQ PHB_LMN))
1887 {
1888 // Don't forget to store it in the E2PROM !!!
1889 pb_write_eeprom();
1890 }
1891 #endif
1892
1893 /*
1894 * end of beautiful patch
1895 */
1896 return (v_returnedStatus);
1897 }
1898
1899
1900 /*
1901 +--------------------------------------------------------------------+
1902 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1903 | STATE : code ROUTINE : phb_set_auto_off |
1904 +--------------------------------------------------------------------+
1905
1906 PURPOSE :
1907
1908 */
1909
1910 T_MFW phb_set_auto_off(UBYTE mode)
1911 {
1912 if (mode == PHB_AUTO_ON)
1913 {
1914 if (sAT_PercentPBCF(CMD_SRC_LCL, PBCF_LDN_Enable,
1915 PBCF_LRN_Enable, PBCF_LMN_Enable) NEQ AT_CMPL)
1916 return MFW_PHB_FAIL;
1917 return MFW_PHB_OK;
1918 }
1919 if (mode == PHB_AUTO_OFF)
1920 {
1921 if (sAT_PercentPBCF(CMD_SRC_LCL, PBCF_LDN_Disable,
1922 PBCF_LRN_Disable, PBCF_LMN_Disable) != AT_CMPL)
1923 return MFW_PHB_FAIL;
1924 return MFW_PHB_OK;
1925 }
1926 return MFW_PHB_FAIL; /*a0393213 compiler warnings removal - added return statement*/
1927 }
1928
1929
1930 /*
1931 +--------------------------------------------------------------------+
1932 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1933 | STATE : code ROUTINE : phb_get_auto_off |
1934 +--------------------------------------------------------------------+
1935
1936 PURPOSE :
1937
1938 */
1939
1940 T_MFW phb_get_auto_off(UBYTE *mode)
1941 {
1942 T_ACI_PBCF_LDN ldn;
1943 T_ACI_PBCF_LRN lrn;
1944 T_ACI_PBCF_LMN lmn;
1945 if (qAT_PercentPBCF(CMD_SRC_LCL, &ldn, &lrn, &lmn) != AT_CMPL)
1946 return MFW_PHB_FAIL;
1947
1948 switch (ldn)
1949 {
1950 case PBCF_LDN_Disable:
1951 *mode = PHB_AUTO_OFF;
1952 return MFW_PHB_OK;
1953 case PBCF_LDN_Enable:
1954 *mode = PHB_AUTO_ON;
1955 return MFW_PHB_OK;
1956 default:
1957 return MFW_PHB_FAIL;
1958 }
1959 }
1960
1961
1962 /*
1963 +--------------------------------------------------------------------+
1964 | PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
1965 | STATE : code ROUTINE : phb_switch_entry |
1966 +--------------------------------------------------------------------+
1967
1968 PURPOSE : switch one entry between ADN and FDN
1969
1970 */
1971
1972 T_MFW_PHB_RETURN phb_switch_entry (T_MFW_PHB_ENTRY *entry, UBYTE *passwd)
1973 {
1974 T_MFW_PHB_STATUS status;
1975 SHORT pn1Cnt = -1;
1976 SHORT pn2Cnt = -1;
1977 SHORT pk1Cnt = -1;
1978 SHORT pk2Cnt = -1;
1979 T_ACI_PVRF_STAT ps1 = PVRF_STAT_NotPresent;
1980 T_ACI_PVRF_STAT ps2 = PVRF_STAT_NotPresent;
1981 // UBYTE avail = 0; // RAVI
1982 UBYTE index;
1983
1984 qAT_PercentPVRF(CMD_SRC_LCL, &pn1Cnt,
1985 &pn2Cnt, &pk1Cnt, &pk2Cnt, &ps1, &ps2);
1986 if (ps2 != PVRF_STAT_NotRequired)
1987 {
1988 if (pn2Cnt < 3)
1989 return MFW_PHB_PIN2_REQ;
1990 else
1991 return MFW_PHB_PUK2_REQ;
1992 }
1993
1994 index = entry->index;
1995 entry->index = 0;
1996
1997 switch (entry->book)
1998 {
1999 case PHB_FDN:
2000 if (phb_store_entry (PHB_ADN, entry, &status) == MFW_PHB_OK)
2001 {
2002 phb_delete_entry (PHB_FDN, index, &status);
2003 return MFW_PHB_OK;
2004 }
2005 break;
2006 case PHB_ADN:
2007 if (phb_store_entry (PHB_FDN, entry, &status) == MFW_PHB_OK)
2008 {
2009 phb_delete_entry (PHB_ADN, index, &status);
2010 return MFW_PHB_OK;
2011 }
2012 break;
2013 default:
2014 break;
2015 }
2016 return (MFW_PHB_FAIL);
2017 }
2018
2019
2020 /*
2021 +--------------------------------------------------------------------+
2022 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
2023 | STATE : code ROUTINE: phb_read_upn_eeprom |
2024 +--------------------------------------------------------------------+
2025
2026
2027 PURPOSE : Read user personal numbers from EEPROM
2028
2029 */
2030
2031 void phb_read_upn_eeprom(void)
2032 {
2033
2034 #ifdef PCM_2_FFS
2035 T_PSPDF_UPN efupn;
2036 #else
2037 EF_UPN efupn;
2038 #endif
2039
2040 USHORT max_rcd;
2041 T_ACI_TOA type;
2042 UBYTE version;
2043 UBYTE i;
2044
2045 TRACE_FUNCTION("phb_read_upn_eeprom()");
2046
2047 /* Added to remove warning Aug - 11 */
2048 i = 0;
2049
2050 if (upn_list.count)
2051 {
2052 phb_signal(E_PHB_UPN_LIST, &upn_list);
2053 return;
2054 }
2055
2056 #ifdef PCM_2_FFS
2057 if (ffs_ReadRecord((UBYTE *)PSPDF_UPN_ID, (UBYTE *)&efupn,
2058 sizeof( T_PSPDF_UPN ) , (USHORT)(i+1), 1 ) == sizeof( T_PSPDF_UPN ) )
2059 #else
2060 pcm_ReadRecord((UBYTE *)EF_UPN_ID,
2061 1,
2062 SIZE_EF_UPN,
2063 (UBYTE *)&efupn,
2064 &version,
2065 &max_rcd);
2066
2067 #endif
2068 for (i=0; i<max_rcd; i++)
2069 {
2070 #ifdef PCM_2_FFS
2071 if (ffs_ReadRecord((UBYTE *)PSPDF_UPN_ID, (UBYTE *)&efupn,
2072 sizeof( T_PSPDF_UPN ) , (USHORT)(i+1), 1 ) == sizeof( T_PSPDF_UPN ) )
2073 #else
2074 if (pcm_ReadRecord((UBYTE *)EF_UPN_ID,
2075 (USHORT)(i+1),
2076 SIZE_EF_UPN,
2077 (UBYTE *)&efupn,
2078 &version,
2079 &max_rcd) == DRV_OK)
2080 #endif
2081
2082 {
2083 if (efupn.usrNum[0] NEQ 0xff)
2084 {
2085 /* copy record */
2086 #ifdef NO_ASCIIZ
2087 /*MC, SPR1257 name strings should use MAX_ALPHA_LEN*/
2088 cmhPHB_getTagNt (efupn.alphId,
2089 10, /* alpha length is 10 bytes in eeprom */
2090 (CHAR *)upn_list.upn[cnt].name.data,
2091 /*PHB_MAX_LEN*/MAX_ALPHA_LEN);
2092 #else
2093 /*MC, SPR1257 name strings should use MAX_ALPHA_LEN*/
2094 cmhPHB_getTagNt (efupn.alphId,
2095 10, /* alpha length is 10 bytes in eeprom */
2096 (CHAR *)upn_list.upn[cnt].name,
2097 /*PHB_MAX_LEN*/MAX_ALPHA_LEN);
2098 #endif
2099 cmhPHB_getAdrStr ((CHAR *)upn_list.upn[cnt].number,
2100 PHB_MAX_LEN - 1,
2101 efupn.usrNum,
2102 efupn.len);
2103
2104 cmhPHB_toaDmrg (efupn.numTp, &type);
2105 upn_list.upn[cnt].ton = phb_cvtTon(type.ton);
2106 upn_list.upn[cnt].npi = (T_MFW_PHB_NPI)phb_cvtNpi(type.npi);
2107 /* ccp */
2108 /* ext1 */
2109 cnt++;
2110 upn_list.count++;
2111 }
2112 }
2113 }
2114 phb_signal(E_PHB_UPN_LIST, &upn_list);
2115 }
2116
2117
2118 /*
2119 +--------------------------------------------------------------------+
2120 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
2121 | STATE : code ROUTINE: phb_get_upn |
2122 +--------------------------------------------------------------------+
2123
2124
2125 PURPOSE : Request user personal numbers
2126
2127 */
2128
2129 void phb_get_upn(void)
2130 {
2131 /*a0393213 compiler warnings removal - removed variables phb_entry, phb_list*/
2132
2133 T_MFW_PHB_STATUS status;
2134 int i;
2135 SHORT start_ind;
2136 SHORT stop_ind;
2137 SHORT last_ind;
2138 // Apr 14, 2005 REF: CRR 29991 xpradipg
2139 // local pointer definition
2140 #ifdef FF_MMI_OPTIM
2141 T_ACI_PB_ENTR *pb_list;
2142 #endif
2143
2144 TRACE_FUNCTION("phb_get_upn()");
2145
2146
2147
2148 memset(&status, 0, sizeof(status));
2149 status.book = PHB_UPN;
2150 phb_get_status(&status);
2151
2152 upn_list.count = 0;
2153 /* select phonebook */
2154 if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ( PHB_UPN ), NULL) NEQ AT_CMPL)
2155
2156 // March 1 ,2004 REF: CRR 27832 x0012852
2157 // Bug:SIM PIN2 related Actions are displying wrong Error Response.
2158 // Fix:MFW calls sAT_PlusCPBS() with third parameter as NULL.
2159
2160 phb_signal(E_PHB_UPN_LIST, &upn_list);
2161
2162 start_ind = 1;
2163 stop_ind = 1;
2164 upn_list.count = 0;
2165 // Apr 14, 2005 REF: CRR 29991 xpradipg
2166 // allocate memory
2167 #ifdef FF_MMI_OPTIM
2168 pb_list = (T_ACI_PB_ENTR*)mfwAlloc(PB_LIST_SIZE);
2169 if(NULL == pb_list)
2170 return;
2171 #endif
2172 for (i=0; i<status.used_entries; i++)
2173 {
2174
2175 if (cmhPHB_PlusCPBR(CMD_SRC_LCL,
2176 SR_TYP_Index,
2177 start_ind,
2178 stop_ind,
2179 &last_ind,
2180 pb_list) EQ AT_CMPL)
2181 {
2182 if (pb_list[0].index <= 0)
2183 break;
2184
2185 strcpy((char *)upn_list.upn[i].number, (char *)pb_list[0].number);
2186 #ifdef NO_ASCIIZ
2187 memcpy(upn_list.upn[i].name.data, pb_list[0].text.data, pb_list[0].text.len);
2188 upn_list.upn[i].name.len = pb_list[0].text.len;
2189 #else
2190 phb_Alpha2Gsm(&pb_list[0].text, upn_list.upn[i].name);
2191 #endif
2192 upn_list.upn[i].ton = phb_cvtTon(pb_list[0].type.ton);
2193 upn_list.upn[i].npi = (T_MFW_PHB_NPI)phb_cvtNpi(pb_list[0].type.npi);
2194 start_ind++;
2195 stop_ind++;
2196 upn_list.count++;
2197 }
2198 }
2199
2200 phb_signal(E_PHB_UPN_LIST, &upn_list);
2201 // Apr 14, 2005 REF: CRR 29991 xpradipg
2202 // deallocate the memory
2203 PB_LIST_DEALLOC(pb_list, PB_LIST_SIZE);
2204 }
2205
2206 /*
2207 +--------------------------------------------------------------------+
2208 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
2209 | STATE : code ROUTINE: phb_save_upn |
2210 +--------------------------------------------------------------------+
2211
2212
2213 PURPOSE : Save user personal numbers in EEPROM
2214
2215 */
2216
2217 T_MFW phb_save_upn(T_MFW_UPN *upn)
2218 {
2219 T_MFW_PHB_ENTRY entry;
2220 T_MFW_PHB_STATUS status;
2221
2222 entry.book = PHB_UPN;
2223 #ifdef NO_ASCIIZ
2224 memcpy(entry.name.data, upn->name.data, upn->name.len);
2225 entry.name.len = upn->name.len;
2226 #endif
2227 strcpy((char *)entry.number, (char *)upn->number);
2228 // PATCH LE 12.05.00
2229 // store upn ever on first location
2230 // zero searches for a free record, which is not
2231 // available and then the operation fails !
2232
2233 // old code entry.index = 0;
2234 entry.index = 1;
2235 // END PATCH LE 12.05.00
2236 entry.ton = MFW_TON_UNKNOWN;
2237 entry.npi = MFW_NPI_UNKNOWN;
2238
2239 if (phb_store_entry(PHB_UPN, &entry, &status) EQ MFW_PHB_OK)
2240 return MFW_PHB_OK;
2241 return MFW_PHB_FAIL;
2242 }
2243
2244 /*
2245 +--------------------------------------------------------------------+
2246 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
2247 | STATE : code ROUTINE: phb_Alpha2Gsm |
2248 +--------------------------------------------------------------------+
2249
2250
2251 PURPOSE : convert alpha to GSM string (set bit 7 to 1)
2252
2253 */
2254
2255 void phb_Alpha2Gsm(T_ACI_PB_TEXT *text, UBYTE *alpha)
2256 {
2257 int i;
2258
2259 for (i=0; i<text->len; i++)
2260 {
2261 if(i == (PHB_MAX_LEN - 1))
2262 break;
2263 alpha[i] = text->data[i] | 0x80;
2264 }
2265 alpha[i] = '\0';
2266 }
2267
2268 /*
2269 +--------------------------------------------------------------------+
2270 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
2271 | STATE : code ROUTINE: phb_Gsm2Alpha |
2272 +--------------------------------------------------------------------+
2273
2274
2275 PURPOSE : convert zero-terminated GSM string to "data + len"
2276 (set bit 7 to 0)
2277
2278 */
2279
2280 void phb_Gsm2Alpha(UBYTE *alpha, T_ACI_PB_TEXT *text)
2281 {
2282 int i;
2283
2284 text->len = strlen((char *)alpha);
2285 for ( i = 0; i < text->len; i++ )
2286 alpha[i] = alpha[i] & 0x7F;
2287 memcpy(text->data, alpha, text->len);
2288 text->data[text->len] = '\0';
2289 text->cs = CS_Sim;
2290 }
2291
2292 /*
2293 +--------------------------------------------------------------------+
2294 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
2295 | STATE : code ROUTINE: rAT_phb_status |
2296 +--------------------------------------------------------------------+
2297
2298
2299 PURPOSE : reading phonebook from SIM card is ready.
2300
2301 */
2302 void rAT_phb_status (T_ACI_PB_STAT status)
2303 {
2304 TRACE_FUNCTION("rAT_phb_status()");
2305 #ifdef TI_PS_FFS_PHB
2306 pb_stat = status;
2307
2308 switch (status)
2309 {
2310 case PB_STAT_Ready:
2311 sms_phbReady_ind();
2312 // Aug 18, 2006 ER: OMAPS00089840 x0039928
2313 // Fix : Send PHB READY signal to MMI only if the status indication is for DeleteAll
2314 if(DeleteAll_flag)
2315 phb_signal(E_PHB_READY,0);
2316 break;
2317
2318 case PB_STAT_Busy:
2319 case PB_STAT_Blocked:
2320 default:
2321 phb_signal(E_PHB_BUSY, 0);
2322 break;
2323 }
2324 #else
2325 if (status EQ PB_STAT_Ready)
2326 {
2327 sms_phbReady_ind();
2328 // Aug 18, 2006 ER: OMAPS00089840 x0039928
2329 // Fix : Send PHB READY signal to MMI only if the status indication is for DeleteAll
2330 if(DeleteAll_flag)
2331 phb_signal(E_PHB_READY,0);
2332 }
2333 if (status EQ PB_STAT_Blocked)
2334 phb_signal(E_PHB_BUSY, 0);
2335 #endif
2336 }
2337
2338
2339 /*
2340 +--------------------------------------------------------------------+
2341 | PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
2342 | STATE : code ROUTINE: phb_exit |
2343 +--------------------------------------------------------------------+
2344
2345
2346 PURPOSE :
2347
2348 */
2349
2350 void phb_exit(void)
2351 {
2352 TRACE_FUNCTION ("phb_exit()");
2353 }