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