comparison src/ui/bmi/mmiBookServices.c @ 3:67bfe9f274f6

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children c0052fe355d3
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
1 /*******************************************************************************
2
3 CONDAT (UK)
4
5 ********************************************************************************
6
7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name: Basic MMI
13 $Project code: BMI (6349)
14 $Module: PhoneBook
15 $File: MmiBookServices.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description:
24
25 This provides the implementation of service functions for use with the
26 phone book module
27
28 ********************************************************************************
29 $History: MmiBookServices.c
30
31 Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat)
32 Bug:PhoneBook: Wrong confirmation message in Phonebook storage when copying/moving a contact
33 after adding one or making a change
34 Fix: ACI shall not send rAT_OK for entry addition / entry change operations in Internal PHB
35 Hence, the "addname_flag" and "changename_flag" are immdtly reset incase of Internal PHB
36
37 June 22, 2006 REF: DRT OMAPS00081761 x0012849 : Jagannatha
38 Description:Handset crash when adding new entry with more then 20 digits to phonebook SIM card
39 Solution: Number editor will be restricted to 20 characters when EXT1 is not supported.
40
41 June 14, 2006 REF: OMAPS00079308 x0039928
42 Bug:Validation and Optimization of Memory consumption
43 Fix: Memory optimization is done in bookFindNameInSpecificPhonebook to save around 450 bytes of memory.
44
45 May 29, 2006 DR: OMAPS00079431 - xreddymn
46 Description: Name field is not limited to 14 bytes in case of SIM phonebook.
47 Solution: In bookInputStartNameEditor, limit the number of characters after
48 checking if SIM or ME phonebook is being used.
49
50 Jan 22, 2006 REF: OMAPS00061930 x0039928
51 Bug:PhoneBook -Change entry and view entry through Change option-failed
52 Fix: Phonebook is populated with phone numbers after some time and not immediately while saving the changed entries.
53
54 June 07, 2005 REF: CRR MMI-FIX-31545 x0021334
55 Issue description: SIM: wrong behavior when FDN is not allocated in SST
56 Solution: Before displaying the FDN options, a check is made if FDN is allocated. Only if
57 FDN is allocated, the options are displayed.
58
59 Sep 29, 2004 REF: CRR 25041 xvilliva
60 Bug: add new entry in the FDN , phone gets rebooted.
61 Fix: The bookMenuStart() is called with the window data->phbk->win,
62 similar to the function bookFDNMenu() to avoid crash. The menu
63 window thus created is stored, which will be deleted while
64 phonebook menu is destroyed.
65
66 Jul 29, 2004 REF: CRR 20888 Deepa M.D
67 Bug:Message received not showing with name, name stored in phonebook
68 Fix:Memset the structure(p_pszNumberText.data) to 0 and then memcpy.
69
70 Jul 28, 2004 REF: CRR:20887 xrashmic - SASKEN
71 Description: Current state of FDN not highlighted
72 Fix: Instead of showing the submenu directly we call this function
73 where we set the menu and also higlight the previously selected menu item
74
75 June 25, 2004 REF: CRR 21547 xvilliva
76 Bug: Taking blank entries in phonebook if select book is either SIM or Phone.
77 Fix: We check for presence of either phone number or name before add/modify.
78
79 Jun 23, 2004 REF: CRR MMI-SPR-21636 Rashmi C N(Sasken)
80 Description: The confirmation for deleting entry from address book was a timed confirmation
81 screen.
82 Solution: Now the time is set to 'FOREVER' from 'TEN_SECS'
83
84 Issue Number : SPR#12722 on 29/03/04 by Deepa M.D
85
86
87 25/10/00 Original Condat(UK) BMI version.
88
89 $End
90
91 *******************************************************************************/
92
93
94
95
96 /*******************************************************************************
97
98 Include Files
99
100 *******************************************************************************/
101 #define ENTITY_MFW
102
103 /* includes */
104 #include <string.h>
105 #include <stdio.h>
106 #include <stdlib.h>
107
108 #if defined (NEW_FRAME)
109
110 #include "typedefs.h"
111 #include "vsi.h"
112 #include "pei.h"
113 #include "custom.h"
114 #include "gsm.h"
115
116 #else
117
118 #include "STDDEFS.H"
119 #include "custom.h"
120 #include "gsm.h"
121 #include "vsi.h"
122
123 #endif
124
125 #include "mfw_sys.h"
126
127 #include "mfw_mfw.h"
128 #include "mfw_win.h"
129 #include "mfw_kbd.h"
130 #include "mfw_lng.h"
131 /* SPR#1428 - SH - New Editor changes */
132 #ifndef NEW_EDITOR
133 #include "mfw_edt.h"
134 #endif
135 #include "mfw_icn.h"
136 #include "mfw_mnu.h"
137 #include "mfw_tim.h"
138
139 #include "mfw_sim.h"
140 #include "mfw_cm.h"
141 #include "mfw_nm.h"
142 #include "mfw_phb.h"
143 #include "mfw_mme.h"
144 #include "mfw_sat.h"
145 #include "mfw_sms.h"
146 #include "mfw_cnvt.h" //GW Added for 'mfw_SIM2GsmStr'
147
148 #include "dspl.h"
149
150 #include "ksd.h"
151 #include "psa.h"
152 #include "psa_sim.h" // June 07, 2005 REF: CRR MMI-FIX-31545 x0021334
153
154 #include "MmiMain.h"
155 #include "MmiBookController.h"
156 #include "MmiDummy.h"
157 #include "MmiDialogs.h"
158 #include "MmiLists.h"
159
160
161
162 #include "MmiMenu.h"
163 #include "mmiCall.h"
164 #include "Mmiicons.h"
165 #include "MmiIdle.h"
166
167 #include "MmiSoftKeys.h"
168 #include "MmiSounds.h"
169 #include "MmiIdle.h"
170 #include "MmiNetwork.h"
171 #include "mmiSat_i.h"
172 #include "MmiAoc.h"
173
174 #include "gdi.h"
175 #include "audio.h"
176
177 #include "cus_aci.h"
178 #include "mfw_ffs.h"
179 #include "MmiTimers.h"
180
181 #include "MmiBookShared.h"
182 #include "MmiBookController.h"
183 #include "MmiDialogs.h"
184 #include "mmiColours.h"
185 #include "MmiBookMenuWindow.h"
186
187 /* SPR#1428 - SH - New Editor: Include needed for MmiBookInputWindow functions, see below*/
188 #ifdef NEW_EDITOR
189 #ifdef EASY_TEXT_ENABLED
190 #include "MmiChineseInput.h"
191 #endif
192 #endif
193 #include "psa_sim.h" // June 22, 2006 REF: DRT OMAPS00081761 x0012849
194
195 #define TRACE_PB_DEBUG
196
197 extern int menuFDN;
198 extern T_call call_data;
199
200 /*******************************************************************************
201
202 Private data elements
203
204 *******************************************************************************/
205
206 static MfwHnd phb;
207 /* SPR#1112 - SH - Internal phonebook flags */
208 #ifdef INT_PHONEBOOK
209 BOOL ipbBookSelected = FALSE;
210 BOOL ipbBookAvailable = FALSE;
211 #endif
212
213 // June 14, 2006 REF: OMAPS00079308 x0039928
214 // Fix: All optimized code is put under flag FF_MMI_PB_OPTIM
215 #ifdef FF_MMI_PB_OPTIM
216 # define PB_MAX_FIND_ENTRIES 1
217 #else
218 # define PB_MAX_FIND_ENTRIES 4
219 #endif
220
221 // Jul 28, 2004 REF: CRR:20887 xrashmic - SASKEN
222
223 #define FIRSTMENUITEM 0
224 #define SECONDMENUITEM 1
225 #define OLD_NUM_LENGTH 21 // June 22, 2006 REF: DRT OMAPS00081761 x0012849
226
227 /*******************************************************************************
228
229 Private methods
230
231 *******************************************************************************/
232
233 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- Start */
234
235 extern BOOL addname_flag;
236
237 extern BOOL changename_flag;
238
239 static void mmi_int_phb_store_change_completion();
240
241 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- End */
242
243
244 /*******************************************************************************
245
246 $Function: bookDeleteEntryCB
247
248 $Description: Delete the current entry from the phone book.
249 This routine is invoked as a callback from the confirmation
250 dialog and will perform the delete if the OK key has been
251 selected.
252
253 $Returns: None
254
255 $Arguments: win, handle of parent window,
256 id, of invocation,
257 reason, for invocation
258
259 *******************************************************************************/
260
261 static void bookDeleteEntryCB( T_MFW_HND win, USHORT id, UBYTE reason )
262 {
263 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
264 tBookStandard *data = (tBookStandard *) win_data->user;
265 T_phbk *Phbk = data->phbk;
266
267 TRACE_EVENT_P1("bookDeleteEntryCB index %d", Phbk->current.entry[Phbk->current.selectedName].index);
268
269 /* This call back is invoked from the delete entry dialog confirmation
270 screen, and will only respond to the left key (OK) being selected.
271 */
272 switch ( reason )
273 {
274 case INFO_KCD_LEFT:
275 {
276 if (( Phbk->current.status.book == PHB_UPN) ||
277 (Phbk->current.status.book == PHB_FDN ))
278 deleteFromFile( Phbk, Phbk->current.status.book );
279 else
280 deleteFromFile( Phbk, bookActiveBook(WRITE) );
281
282 /* retrieve he status of the book, and create a string for output
283 based on the status
284 */
285 bookShowInformation( Phbk->win, MmiBookCurrentText(), NULL,NULL );
286 SEND_EVENT(win, E_MNU_ESCAPE, NULL, NULL);
287 }
288 break;
289
290 default:
291 {
292 /* No action required
293 */
294 }
295 break;
296 }
297 }
298
299
300
301
302
303
304
305
306 /*******************************************************************************
307
308 Public Methods
309
310 *******************************************************************************/
311
312
313
314
315
316
317
318
319 /*******************************************************************************
320
321 $Function: bookInitialise
322
323 $Description: Initialise the phone book application
324
325 $Returns: none, side effect is to set up the static phone
326 book element
327
328 $Arguments: none
329
330 *******************************************************************************/
331
332 void bookInitialise( MfwHnd parent )
333 {
334 TRACE_FUNCTION( "bookInitialise()" );
335
336 /* SPR#1112 - SH - Added E_PHB_READY and E_PHB_BUSY */
337 phb = phb_create( 0, (MfwEvt) (E_PHB_UPN_LIST | E_PHB_ERROR | E_PHB_STATUS
338 | E_PHB_READY | E_PHB_BUSY), (MfwCb) bookEvent );
339
340 }
341
342 /* SPR#1112 - Initialise internal phonebook */
343 #ifdef INT_PHONEBOOK
344
345 /*******************************************************************************
346
347 $Function: bookInitInternal
348
349 $Description: Initialise the internal phone book application
350
351 $Returns: none, side effect is to set up the static phone
352 book element
353
354 $Arguments: none
355
356 *******************************************************************************/
357
358 void bookInitInternal( void )
359 {
360 UBYTE intphonebook;
361 T_MFW ret;
362
363 ret = GI_pb_GetPhonebook(&intphonebook);
364
365 if (ret==MFW_PHB_OK)
366 {
367 bookSetBookAvailable(TRUE);
368 GI_pb_Initialise();
369 if (intphonebook)
370 {
371 bookSetBookSelected(TRUE);
372 }
373 else
374 bookSetBookSelected(FALSE);
375 }
376 else
377 bookSetBookAvailable(FALSE);
378
379 return;
380 }
381
382
383 /*******************************************************************************
384
385 $Function: bookGetBookSelected
386
387 $Description: Is the internal phonebook selected?
388
389 $Returns: TRUE if internal phonebook is selected, FALSE otherwise
390
391 $Arguments: none
392
393 *******************************************************************************/
394
395 BOOL bookGetBookSelected()
396 {
397 return ipbBookSelected;
398 }
399
400
401 /*******************************************************************************
402
403 $Function: bookSetBookSelected
404
405 $Description: Select or deselect the internal phonebook
406
407 $Returns: None.
408
409 $Arguments: TRUE to select internal phonebook, FALSE to select SIM phonebook
410
411 *******************************************************************************/
412
413 void bookSetBookSelected(UBYTE bookSelected)
414 {
415 ipbBookSelected = bookSelected;
416
417 return;
418 }
419
420
421 /*******************************************************************************
422
423 $Function: bookGetBookAvailable
424
425 $Description: Is the internal phonebook available for use?
426
427 $Returns: TRUE if internal phonebook is available, FALSE otherwise
428
429 $Arguments: none
430
431 *******************************************************************************/
432
433 BOOL bookGetBookAvailable()
434 {
435 return ipbBookAvailable;
436 }
437
438
439 /*******************************************************************************
440
441 $Function: bookSetBookAvailable
442
443 $Description: Indicate whether or not the internal phonebook is available for use
444
445 $Returns: None.
446
447 $Arguments: TRUE to if internal phonebook is available, FALSE otherwise
448
449 *******************************************************************************/
450
451 void bookSetBookAvailable(UBYTE bookAvailable)
452 {
453 ipbBookAvailable = bookAvailable;
454
455 return;
456 }
457
458 #endif
459
460
461
462
463 /*******************************************************************************
464
465 $Function: bookExit
466
467 $Description: Exit the phone book application, this will delete the static
468 phone book element
469
470 $Returns: none
471
472 $Arguments: none
473
474 *******************************************************************************/
475
476 void bookExit( void )
477 {
478 TRACE_FUNCTION( "bookExit()" );
479 phb_delete( phb );
480 /* SPR#1112 - SH - Now redundant */
481 // bookDeletePhoneBook();
482
483 /* SPR#1112 - SH - Exit internal phonebook if activated */
484 #ifdef INT_PHONEBOOK
485 if (bookGetBookAvailable())
486 GI_pb_Exit();
487 #endif
488
489 return;
490 }
491
492
493
494
495
496
497
498
499 /*******************************************************************************
500
501 $Function: bookAddName
502
503 $Description: Adds a new number to the phone book
504
505 $Returns: tbd
506
507 $Arguments: tbd
508
509 *******************************************************************************/
510
511 void bookAddName( T_MFW_HND win, char *number )
512 {
513 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
514 tBookStandard *data = (tBookStandard *) win_data->user;
515 T_phbk *Phbk = (T_phbk *)data->phbk;
516
517 /* Populate the name and number records with the provided number
518 */
519
520
521 /*MC SPR 1257, name strings should use MAX_ALPHA_LEN*/
522 memset( Phbk->edt_buf_name, 0, MAX_ALPHA_LEN );
523 memcpy( Phbk->edt_buf_number, (char*)number, PHB_MAX_LEN );
524
525 /* Populate the input specifier structure and use it to
526 perform the next action, note when we return we start
527 adding a new name.
528 */
529 TRACE_EVENT ("bookAddName");
530 data->phbk->input_name_win = bookInputStartNameEditor(
531 data->win, (char*)Phbk->edt_buf_name );
532 }
533
534
535
536
537
538
539
540
541 /*******************************************************************************
542
543 $Function: bookShowInformation
544
545 $Description: general information dialog routine
546
547 $Returns: none
548
549 $Arguments: parent, window,
550 text, to be displayed,
551 cb_function, call back on completion of window
552
553 *******************************************************************************/
554
555 void bookShowInformation( MfwHnd parent, int txtId, char *text, T_VOID_FUNC cb_function )
556 {
557 T_DISPLAY_DATA display_info;
558
559 TRACE_FUNCTION( "bookShowInformation()" );
560
561 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, txtId, TxtNull, COLOUR_BOOK_POPUP);
562 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) cb_function, THREE_SECS, KEY_CLEAR );
563 display_info.TextString = text;
564
565 /* Call Info Screen
566 */
567 info_dialog( parent, &display_info );
568 }
569
570
571 /*******************************************************************************
572
573 $Function: bookShowInfoScreen
574
575 $Description: SPR1112 - SH - Show an info screen
576
577 $Returns: none
578
579 $Arguments: parent, window,
580 txtId1 - first line ID
581 txtId2 - second line ID
582 time - timeout for dialog
583
584 *******************************************************************************/
585
586 T_MFW_HND bookShowInfoScreen( MfwHnd parent, int txtId1, int txtId2, T_VOID_FUNC cb_function,
587 USHORT Identifier, ULONG Time)
588 {
589 T_DISPLAY_DATA display_info;
590
591 TRACE_FUNCTION( "bookShowInformation()" );
592
593 dlg_initDisplayData_TextId(&display_info, TxtNull, TxtNull, txtId1, txtId2, COLOUR_BOOK_POPUP);
594 dlg_initDisplayData_events(&display_info, (T_VOID_FUNC)cb_function, Time, KEY_CLEAR);
595
596 display_info.Identifier = Identifier;
597
598 /* Call Info Screen
599 */
600 return info_dialog( parent, &display_info );
601 }
602
603
604 /*******************************************************************************
605
606 $Function: bookFindIndexMatchPB
607
608 $Description: Locates the best match from a supplied list of phonebook entries
609
610 $Returns: 0 if error, 1 if successful
611
612 $Arguments: listPB, pointer to phonebook entries
613 numEntries, number of entries in listPB
614 srcNumberr, pointer to pattern to match
615
616 $History:
617 SPR#1727 - DS - Merged from 1.6 branch.
618
619 *******************************************************************************/
620 int bookFindIndexMatchPB(T_MFW_PHB_LIST* listPB, UBYTE numEntries, const char* srcNumber)
621 {
622 int indexMatch = -1;
623 int i = 0;
624 int j = 0;
625 int maxMatchChars = 0;
626 int count; /* Number of matching characters */
627 int lenNum;
628 int lenNumPB;
629 int firstNotMatch=0;
630
631
632
633
634 TRACE_FUNCTION("bookFindIndexMatchPB()");
635
636 #ifdef TRACE_PB_DEBUG
637 TRACE_EVENT_P1("numEntries to examine: %d", numEntries);
638 #endif /* TRACE_PB_DEBUG */
639
640 if ( (listPB == NULL) || (srcNumber == NULL) ) /* Invalid data */
641 {
642 TRACE_EVENT("Invalid data passed to findIndexMatchPB");
643 return (-1);
644 }
645
646 if (numEntries <= 0) /* Invalid number of entries */
647 {
648 TRACE_EVENT_P1("Invalid number of entries passed into findIndexMatchPB: %d", numEntries);
649 return (-1);
650 }
651
652 /* Calculate length of number */
653 lenNum = strlen(srcNumber);
654
655 #ifdef TRACE_PB_DEBUG
656 TRACE_EVENT_P1("Len of number: %d", lenNum);
657 #endif /* TRACE_PB_DEBUG */
658
659 /* Loop round number of entries */
660 for (i=0; i<numEntries; i++)
661 {
662 char* entryPB = (char*)listPB->entry[i].number;
663
664 /* Calculate length of number in PB entry */
665 lenNumPB = strlen(entryPB);
666
667 #ifdef TRACE_PB_DEBUG
668 TRACE_EVENT_P2("Len of PB number for entry %d: %d", i, lenNumPB);
669 #endif /* TRACE_PB_DEBUG */
670
671 /* Set count and loop-counter to 0 before comparing numbers */
672 count = 0;
673 j = 0;
674
675 /* Determine number of matching digits
676 * Exit loop if digits don't match or if reached end of either number buffer
677 */
678 while ( (!firstNotMatch) && !(j > lenNumPB) && !(j > lenNum) )
679 {
680 /* Compare digits */
681 if (srcNumber[lenNum-j] == entryPB[lenNumPB-j]) /* Matching character */
682 {
683 #ifdef TRACE_PB_DEBUG
684 TRACE_EVENT_P1("Found match at pos %d", j);
685 #endif /* TRACE_PB_DEBUG */
686 count = count + 1;
687 }
688 else
689 {
690 /* Digits don't match */
691 firstNotMatch=1;
692 }
693
694 /* Increment index to point at next set of digits */
695 j = j + 1;
696 }
697
698 /* If better match store count and index */
699 /* SPR#1727 - DS - Added numbersMatch() check */
700 if ( (count > maxMatchChars) && numbersMatch((char*)srcNumber, entryPB) )
701 {
702 #ifdef TRACE_PB_DEBUG
703 TRACE_EVENT_P2("Entry %d is better match. Matches %d chars", i, count);
704 #endif /* TRACE_PB_DEBUG */
705 maxMatchChars = count;
706 indexMatch = i;
707 }
708 }
709
710 /* Return index of best match */
711 return indexMatch;
712 }
713
714
715
716
717
718 /*******************************************************************************
719
720 $Function: bookFindNameInPhonebook
721
722 $Description: SPR#1112 - Modified function to search in alternate phonebook.
723 Locates the name in the current phonebook. If the current phonebook is
724 the internal phonebook and no result is found, the SIM phonebook is also
725 searched.
726
727 $Returns: 0 if error, 1 if successful
728
729 $Arguments: p_pszNumber, pointer to pattern to match, p_pEntry, pointer
730 to buffer into which to store result.
731
732 *******************************************************************************/
733 //GW-SPR#810-Simplified phonebook entry search based on 1.3.3 code.
734
735 int bookFindNameInPhonebook( const char *p_pszNumber, T_MFW_PHB_ENTRY *p_pEntry )
736 {
737 int result;
738
739 TRACE_FUNCTION( "bookFindNameInPhonebook()" );
740
741 if(p_pszNumber == 0 || p_pEntry == 0)
742 return (0);
743
744 if (strlen(p_pszNumber) < 1)
745 return (0);
746
747 result = bookFindNameInSpecificPhonebook(p_pszNumber, p_pEntry);
748
749 #ifdef INT_PHONEBOOK
750 /* If not found in internal phonebook, try SIM */
751
752 if (!result && bookGetBookAvailable() && bookGetBookSelected())
753 {
754 bookSetBookSelected(FALSE);
755 result = bookFindNameInSpecificPhonebook(p_pszNumber, p_pEntry);
756 bookSetBookSelected(TRUE);
757 }
758 #endif
759
760 return result;
761 }
762
763
764 /*******************************************************************************
765
766 $Function: bookFindNameInSpecificPhonebook
767
768 $Description: Locates the name in a specified phone book
769 SPR#1112 - SH - Separate this part of function, so we can call it twice
770 $Returns: 0 if error, 1 if successful
771
772 $Arguments: p_pszNumber, pointer to pattern to match, p_pEntry, pointer
773 to buffer into which to store result.
774
775 SPR#1727 - Modified to use bookFindIndexMatchPB.
776
777 *******************************************************************************/
778
779 int bookFindNameInSpecificPhonebook( const char *p_pszNumber, T_MFW_PHB_ENTRY *p_pEntry )
780 {
781 #ifdef NO_ASCIIZ
782 T_MFW_PHB_TEXT p_pszNumberText;
783 #endif
784
785 T_MFW_PHB_LIST phb_list; //, new_list; // RAVI
786
787 SHORT phb_index = 0;
788 UBYTE l_name[MAX_ALPHA_LEN];
789 // June 14, 2006 REF: OMAPS00079308 x0039928
790 // Fix: All optimized code is put under flag FF_MMI_PB_OPTIM
791 #ifndef FF_MMI_PB_OPTIM
792 T_MFW_PHB_ENTRY temp_pEntry[PB_MAX_FIND_ENTRIES];
793 #endif
794
795 /*MC SPR 1319*/
796 #ifdef EASY_TEXT_ENABLED
797 #ifndef FF_MMI_PB_OPTIM
798 char debug[MAX_ALPHA_LEN];
799 int k;
800 #endif
801 #endif
802 int indexMatch;
803 int ret;
804
805
806 if(p_pszNumber == 0 || p_pEntry == 0)
807 return (0);
808
809 if (strlen(p_pszNumber) < 1)
810 return (0);
811
812 memset( p_pEntry, 0, sizeof(T_MFW_PHB_ENTRY) );
813 memset( &phb_list, 0, sizeof(phb_list) );
814 #ifdef FF_MMI_PB_OPTIM
815 phb_list.entry = p_pEntry;
816 #else
817 phb_list.entry = temp_pEntry;
818 #endif
819 phb_list.num_entries = PB_MAX_FIND_ENTRIES;
820
821 /* Search phonebook for up to 4 entries with the last 6 digits matching number */
822
823 #ifdef NO_ASCIIZ
824 /* GW Set up data structure for NO_ASCIIZ */
825
826 p_pszNumberText.dcs = MFW_DCS_8bits;
827 p_pszNumberText.len = strlen(p_pszNumber);
828
829 // strcpy((char*)p_pszNumberText.data, p_pszNumber);
830 /* cq15688 copy number into the text info structure using memcpy() instead of strcpy()3/03/04 MZ */
831 //Jul 29, 2004 REF: CRR 20888 Deepa M.D
832 //First memset the structure and then memcpy.
833 memset(p_pszNumberText.data, 0, sizeof(p_pszNumberText.data));
834 memcpy( (char*)p_pszNumberText.data, p_pszNumber , p_pszNumberText.len );
835
836 ret = phb_find_entries(
837 bookActiveBook(READ), /* phonebook */
838 &phb_index, /* returns index in phb */
839 MFW_PHB_NUMBER, /* searching for number */
840 PB_MAX_FIND_ENTRIES, /* return max. four entry */
841 &p_pszNumberText, /* search this pattern */
842 &phb_list /* return structure */
843 );
844
845 #else
846 ret = phb_find_entries(
847 bookActiveBook(READ), /* phonebook */
848 &phb_index, /* returns index in phb */
849 MFW_PHB_NUMBER, /* searching for number */
850 PB_MAX_FIND_ENTRIES, /* return max. four entry */
851 (char *)p_pszNumber, /* search this pattern */
852 &phb_list /* return structure */
853 );
854 #endif //NO_ASCIIZ
855
856 //Check return from phb_find_entries
857 if (ret == MFW_PHB_FAIL)
858 {
859 return (0);
860 }
861
862
863 /* SPR#1727 - DS - Examine returned PB entries and find best match */
864 indexMatch = bookFindIndexMatchPB(&phb_list, phb_list.num_entries, p_pszNumber);
865
866 if (indexMatch == -1) /* No match found */
867 {
868 TRACE_EVENT("No match found in findIndexMatchPB !");
869 return (0);
870 }
871
872 #ifdef TRACE_PB_DEBUG
873 TRACE_EVENT_P1("Match found in findIndexMatchPB. Pb entry %d", indexMatch);
874 #endif /* TRACE_PB_DEBUG */
875
876
877 /* Copy matched phonebook entry details */
878 #ifndef FF_MMI_PB_OPTIM
879 memcpy( p_pEntry, &temp_pEntry[indexMatch] , sizeof(T_MFW_PHB_ENTRY) );
880 #endif
881
882 if (p_pEntry == NULL)
883 {
884 return (0);
885 }
886
887 /* Convert name into appropriate format */
888 #ifdef NO_ASCIIZ
889 /*MC SPR 1319*/
890 #ifdef EASY_TEXT_ENABLED
891 #ifndef FF_MMI_PB_OPTIM
892 for (k=0;k<p_pEntry->name.len; k++)
893 {
894 if (p_pEntry->name.data[k]==0 )
895 {
896 debug[k] = '0';
897 }
898 else
899 {
900 debug[k] = p_pEntry->name.data[k];
901 }
902 }
903 TRACE_EVENT_P1("BFNIP: %s ", debug);
904 #endif
905
906 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
907 if (p_pEntry->name.data[0] == 0x80) /* Unicode 0x80 style */
908 {
909 /*MC, removed var "actual_length*/
910 int i;
911 for (i=1; i<MAX_ALPHA_LEN; i+=1)
912 {
913 l_name[i+1] = p_pEntry->name.data[i];
914
915 }
916 l_name[0] = p_pEntry->name.data[0];
917 l_name[1] = MAX_ALPHA_LEN;
918
919 memcpy( p_pEntry->name.data, (char*)l_name, MAX_ALPHA_LEN );
920
921 if (p_pEntry->name.len%2 == 1)/*if length of string odd*/
922 {
923 p_pEntry->name.len++; /*MC we have to increase the length by one as we've shifted the string up*/
924 }
925
926 /*MC, ensure all the chars in the string after string length are 0*/
927 for (i=p_pEntry->name.len; i<MAX_ALPHA_LEN; i++)
928 {
929 p_pEntry->name.data[i]= 0;
930 }
931
932 #ifndef FF_MMI_PB_OPTIM
933 for (k=0;k<p_pEntry->name.len; k++)
934 {
935 if (p_pEntry->name.data[k]==0 )
936 {
937 debug[k] = '0';
938 }
939 else
940 {
941 debug[k] = p_pEntry->name.data[k];
942 }
943 }
944
945 TRACE_EVENT_P1("BNFIP conv: %s", debug);
946
947 sprintf(debug, "Length of phonebook entry:%d", p_pEntry->name.len);
948 #endif
949
950 }
951 else
952 #endif /* EASY_TEXT_ENABLED */
953 /* Marcus: Issue 963: 11/09/2002: Start */
954 {
955 /*
956 * bookGsm2Alpha requires ASCIIZ string - make sure it is.
957 * This also will help calling functions that may assume ASCIIZ.
958 */
959 if (sizeof(p_pEntry->name.data) > p_pEntry->name.len)
960 {
961 p_pEntry->name.data[p_pEntry->name.len] = '\0';
962 }
963 /*SPR2175, use new function to convert from GSM to ASCII*/
964 {
965
966 TRACE_EVENT_P1("Converting name from 8-bit to ASCII, dcs: %d", p_pEntry->name.dcs);
967 ATB_convert_String((char*)p_pEntry->name.data, MFW_DCS_8bits, p_pEntry->name.len, (char*)l_name, MFW_ASCII, MAX_ALPHA_LEN, FALSE);
968 p_pEntry->name.dcs = MFW_ASCII;
969 memcpy(p_pEntry->name.data, l_name, MAX_ALPHA_LEN);
970 }
971
972 }
973 /* Marcus: Issue 963: 11/09/2002: End */
974 /*MC end*/
975 #else
976 bookGsm2Alpha( (UBYTE *) p_pEntry->name );
977 #endif /* NO_ASCIIZ */
978
979 return (1);
980 }
981
982
983
984
985 /*******************************************************************************
986
987 $Function: bookFindNumberByPosition
988
989 $Description: locate a number given the index
990
991 $Returns: 0 if failure, 1 otherwise
992
993 $Arguments: index of the number to find, p_pentry, return structure
994
995 *******************************************************************************/
996
997 UBYTE bookFindNumberByPosition (UBYTE index,T_MFW_PHB_ENTRY* p_pEntry)
998 {
999 T_MFW_PHB_LIST phb_list;
1000 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
1001 UBYTE l_name[MAX_ALPHA_LEN];
1002
1003 TRACE_FUNCTION( "bookFindNumberByPosition()" );
1004
1005 /* only search if we have valid input information
1006 */
1007 if( index == 0 || p_pEntry == 0 )
1008 return 0;
1009
1010 /* Clear the output buffers
1011 */
1012 memset( p_pEntry, 0, sizeof( T_MFW_PHB_ENTRY ) );
1013 memset( &phb_list, 0, sizeof( phb_list ) );
1014
1015 /* searc for the selected entry
1016 */
1017 phb_list.entry = p_pEntry;
1018 phb_list.num_entries = 1;
1019 phb_read_entries( bookActiveBook(READ), index, MFW_PHB_INDEX, 1, &phb_list );
1020
1021 /* if we haven't found the entry return 0
1022 */
1023 if ( phb_list.result == MFW_ENTRY_EXIST )
1024 return 0;
1025
1026 /* otherwise copy the located information to the output structure
1027 */
1028 #ifdef NO_ASCIIZ
1029
1030 {
1031 #ifdef EASY_TEXT_ENABLED
1032 /*MC SPR 1257, name strings should use MAX_ALPHA_LEN*/
1033 int i;
1034 if (p_pEntry->name.data[0] == 0x80 ||p_pEntry->name.data[0]== 0x00)
1035 { for (i=1; i<MAX_ALPHA_LEN; i+=1)
1036 {
1037 l_name[i+1] = p_pEntry->name.data[i];
1038
1039 }
1040 l_name[0] = p_pEntry->name.data[0];
1041 l_name[1] = MAX_ALPHA_LEN;
1042
1043 memcpy( p_pEntry->name.data, (char*)l_name, MAX_ALPHA_LEN );
1044
1045 p_pEntry->name.len++;/* = actual_length;*/
1046
1047 }
1048 else
1049 #endif
1050
1051 /*SPR2175, use new function to convert from GSM to ASCII*/
1052 if (p_pEntry->name.dcs == MFW_DCS_8bits && p_pEntry->name.data[0] != 0x80)
1053 {
1054 ATB_convert_String((char*)p_pEntry->name.data, MFW_DCS_8bits, p_pEntry->name.len, (char*)l_name, MFW_ASCII, MAX_ALPHA_LEN, FALSE);
1055 p_pEntry->name.dcs = MFW_ASCII;
1056 memcpy(p_pEntry->name.data, l_name, MAX_ALPHA_LEN);
1057 }
1058 }
1059 #else
1060
1061 bookGsm2Alpha( (UBYTE *) p_pEntry->name );
1062
1063 #endif
1064
1065 /* successful return status
1066 */
1067 return 1;
1068
1069 }
1070
1071
1072
1073
1074
1075
1076
1077
1078 /*******************************************************************************
1079
1080 $Function: bookCallIndex
1081
1082 $Description: Calls the number in the physical index
1083
1084 $Returns: status from the phb_read_entries routine
1085
1086 $Arguments: index, of the number to call
1087
1088 *******************************************************************************/
1089
1090 int bookCallIndex( UBYTE index )
1091 {
1092 T_MFW_PHB_LIST phb_list;
1093 T_MFW_PHB_ENTRY entry;
1094 UBYTE status;
1095
1096 TRACE_FUNCTION( "bookCallIndex()" );
1097
1098 memset( &entry, 0, sizeof( T_MFW_PHB_ENTRY ) );
1099 memset( &phb_list, 0, sizeof( phb_list ) );
1100
1101 phb_list.entry = &entry;
1102 phb_list.num_entries = 1;
1103 if ( ( status = phb_read_entries( bookActiveBook(READ), index, MFW_PHB_PHYSICAL, 1, &phb_list ) ) == MFW_PHB_OK )
1104 callNumber( entry.number );
1105 return status;
1106 }
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118 /*******************************************************************************
1119
1120 $Function: bookGsm2Alpha
1121
1122 $Description: Convert a string from it's GSM to alpha characters
1123
1124 $Returns: none
1125
1126 $Arguments: alpha, pointer to string to be converted (Must be null
1127 terminated string)
1128
1129 *******************************************************************************/
1130
1131
1132 void bookGsm2Alpha( UBYTE *alpha )
1133 {
1134 int index;
1135 int length=0;
1136
1137 if (alpha != NULL)
1138 {
1139 length = strlen( (char *) alpha );
1140 }
1141 else
1142 {
1143 return;
1144 }
1145
1146 for ( index = 0; index < length; index++ )
1147 alpha[index] = alpha[index] & 0x7F;
1148 }
1149
1150
1151
1152
1153 /*******************************************************************************
1154
1155 $Function: bookActiveBook
1156
1157 $Description: Determine if the current active book is restricted or not
1158
1159 $Returns: PHB_FDN if restricted, PHB_ADN otherwise
1160
1161 $Arguments: None
1162
1163 *******************************************************************************/
1164
1165 UBYTE bookActiveBook( int process )
1166 {
1167 TRACE_FUNCTION( "bookActiveBook()" );
1168
1169 /* SPR#1112 - SH - Return internal phonebook ID when appropriate */
1170 // May 3, 2004 REF: CRR MMI-SPR-18555 Rashmi C N(Sasken)
1171 // To get FDN book, when FDN is disabled, but only when accessing from FDM menu and not while we are in active call
1172
1173 if(menuFDN && (call_data.calls.numCalls==0))
1174 {
1175 return PHB_FDN;
1176 }
1177
1178 #ifdef INT_PHONEBOOK
1179 if (bookGetBookAvailable() && bookGetBookSelected())
1180 return PHB_IPB;
1181 #endif
1182 // May 3, 2004 REF: CRR MMI-SPR-18555 Rashmi C N(Sasken)
1183 // When FDN is disabled we need to display only ADN entries in the phonebook menu.
1184 // We now return PHB_ADN instead of PHB_ADN_FDN.
1185
1186 if(process == READ)
1187 return ( phb_get_mode() == PHB_RESTRICTED ) ? PHB_FDN : PHB_ADN;
1188 else if(process == WRITE)
1189 return ( phb_get_mode() == PHB_RESTRICTED ) ? PHB_FDN : PHB_ADN;
1190 return PHB_NONE; /*a0393213 warnings removal-added return statement*/
1191 }
1192
1193
1194
1195 /*******************************************************************************
1196
1197 $Function: bookMemoryView
1198
1199 $Description: Display the memory status
1200
1201 $Returns: None
1202
1203 $Arguments: None
1204
1205 *******************************************************************************/
1206
1207 void bookMemoryView( void )
1208 {
1209 T_MFW_HND win = mfwParent( mfw_header() );
1210 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
1211 tBookStandard *data = (tBookStandard *) win_data->user;
1212 char Buffer[16];
1213 int TxtToShow;
1214
1215
1216 /* Determine which book we are currently using
1217 */
1218 data->phbk->current.status.book = bookActiveBook(READ);
1219
1220 /* retrieve he status of the book, and create a string for output
1221 based on the status
1222 */
1223 #if(BOARD!=61)
1224 Buffer[0] = '\0'; // OMAPS00042166 - RAVI /*a0393213 warnings removal-== changed to =*/
1225 #endif
1226 if ( bookGetCurrentStatus( &data->phbk->current.status ) == MFW_PHB_OK )
1227 {
1228 /* SPR#1112 - Internal phonebook - show the current selected phonebook*/
1229 #ifdef INT_PHONEBOOK
1230 if (bookGetBookAvailable() && bookGetBookSelected())
1231 TxtToShow = TxtPhone;
1232 else
1233 TxtToShow = TxtSIM;
1234 #else
1235 TxtToShow = TxtUsed;
1236 #endif
1237 sprintf( Buffer, "%d/%d",
1238 data->phbk->current.status.used_entries,
1239 data->phbk->current.status.max_entries );
1240 }
1241 else
1242 TxtToShow = TxtReadError;
1243
1244
1245 {
1246 T_DISPLAY_DATA display_info;
1247
1248 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtToShow, TxtNull , COLOUR_STATUS);
1249 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_CLEAR );
1250 display_info.TextString2 = Buffer;
1251
1252 /* Call Info Screen
1253 */
1254 info_dialog( win, &display_info );
1255 }
1256
1257 }
1258
1259
1260
1261
1262
1263
1264
1265
1266 /*******************************************************************************
1267
1268 $Function: bookDeleteEntry
1269
1270 $Description: Delete the current entry from the phone book.
1271 This routine doesn't actually perform the deletion, it
1272 sets up a confirmation dialog, where the call back function
1273 is used to perform the deletion (Refer above)
1274
1275 $Returns: None
1276
1277 $Arguments: None
1278
1279 *******************************************************************************/
1280
1281 void bookDeleteEntry( T_MFW_HND Window)
1282 {
1283 tBookDialogData Dialog;
1284
1285 /* Initialise the dialog control block with default information
1286 */
1287 dlg_initDisplayData_TextId( &Dialog, TxtSoftOK, TxtCancel, TxtPressOk, TxtDelete, COLOUR_STATUS);
1288
1289 // Jun 23, 2004 REF: CRR MMI-SPR-21636 Rashmi C N(Sasken)
1290 // Description: The confirmation for deleting entry from address book was a timed confirmation
1291 // screen.
1292 // Solution: Now the time is set to 'FOREVER' from 'TEN_SECS'
1293 dlg_initDisplayData_events( &Dialog, (T_VOID_FUNC)bookDeleteEntryCB, FOREVER, KEY_CLEAR | KEY_LEFT | KEY_RIGHT );
1294
1295 /* Show the dialog
1296 */
1297 info_dialog( Window, &Dialog );
1298 }
1299
1300 /*******************************************************************************
1301
1302 $Function: bookActivateFDN
1303
1304 $Description: information screen to tell user to activate FDN
1305
1306 $Returns: None
1307
1308 $Arguments: None
1309
1310 *******************************************************************************/
1311
1312 void bookActivateFDN( T_MFW_HND window )
1313 {
1314 tBookDialogData Dialog;
1315
1316 /* Initialise the dialog control block with default information
1317 */
1318 dlg_initDisplayData_TextId( &Dialog, TxtNull, TxtNull, TxtPlease, TxtActivateFDN, COLOUR_STATUS);
1319 dlg_initDisplayData_events( &Dialog, (T_VOID_FUNC)NULL, FOUR_SECS, KEY_CLEAR | KEY_LEFT | KEY_RIGHT );
1320
1321 /* Show the dialog
1322 */
1323 info_dialog( window, &Dialog );
1324 }
1325
1326 /* SPR#1428 - SH - New Editor: moved the following two functions
1327 * from MmiBookInputWindow.c, which is now a redundant file */
1328 #ifdef NEW_EDITOR
1329
1330 /*******************************************************************************
1331
1332 $Function: bookInputStartNumberEditor
1333
1334 $Description: Start the input handler using default properties
1335
1336 $Returns: Handle of newly created window, or NULL if failure
1337
1338 $Arguments: parent, parent window handle, buffer, input buffer
1339
1340 *******************************************************************************/
1341
1342 MfwHnd bookInputStartNumberEditor( MfwHnd parent, void *buffer )
1343 {
1344 T_AUI_EDITOR_DATA editor_data;
1345 U16 editor_num_length = NUMBER_LENGTH;;
1346 TRACE_FUNCTION ("bookInputStartNumberEditor()");
1347
1348 // June 22, 2006 REF: DRT OMAPS00081761 x0012849
1349 // Number length can be upto 41 when EXT1 is allocated and activated in SIM service table
1350 // 40 characters + 1 Null character
1351 switch(bookActiveBook(WRITE))
1352 {
1353 case PHB_ADN:
1354 TRACE_EVENT("ADN book is selcted");
1355 if (sim_serv_table_check(SRV_EXT1) == ALLOCATED_AND_ACTIVATED)
1356 {
1357 editor_num_length = NUMBER_LENGTH;
1358 TRACE_EVENT("SIM is EXT1 supported");
1359 }
1360 else
1361 {
1362 // June 22, 2006 REF: DRT OMAPS00081761 x0012849
1363 // When EXT1 is not supported Number can be upto 20 characters.
1364 editor_num_length = OLD_NUM_LENGTH;
1365 TRACE_EVENT("EXT1 is not supported for this SIM");
1366 }
1367 break;
1368
1369 case PHB_FDN:
1370 TRACE_EVENT("FDN book is selcted");
1371 // June 22, 2006 REF: DRT OMAPS00081761 x0012849
1372 //If EXT2 is present in service table then the FDN phone number can go upto 40 digits.
1373 if (sim_serv_table_check(SRV_EXT2) == ALLOCATED_AND_ACTIVATED)
1374 {
1375 editor_num_length = NUMBER_LENGTH;
1376 TRACE_EVENT("SIM is EXT2 supported");
1377 }
1378 else
1379 {
1380 // June 22, 2006 REF: DRT OMAPS00081761 x0012849
1381 // When EXT1 is not supported Number can be upto 20 characters.
1382 editor_num_length = OLD_NUM_LENGTH;
1383 TRACE_EVENT("EXT2 is not supported for this SIM");
1384 }
1385 break;
1386
1387 case PHB_IPB: // Internal phone book
1388 TRACE_EVENT("IPB - Internal phone book selected");
1389 editor_num_length = NUMBER_LENGTH;
1390 break;
1391 default:
1392 TRACE_EVENT("Selected phone book is other than ADN,FDN,IPB");
1393 editor_num_length = NUMBER_LENGTH;
1394 break;
1395 }
1396
1397 TRACE_EVENT_P1 ("Number length = %d ",editor_num_length);
1398 AUI_edit_SetDefault(&editor_data);
1399 AUI_edit_SetDisplay(&editor_data, NUMBER_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT);
1400 AUI_edit_SetEvents(&editor_data, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)bookAddNumberCB);
1401 // Change by Sasken ( Deepa M.d) on March 29th 2004
1402 // Issue Number : MMI-SPR-12722
1403 // Subject: Right softkey should be "Back" when the editor is empty
1404 // Bug : Right softkey should be "Back" when the editor is empty
1405 // Solution : Added alternative string for the right softkey tobe displayed when the editor is empty
1406
1407 AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterNumber, NULL);
1408 AUI_edit_SetAltTextStr(&editor_data, 0, NULL, TRUE, TxtSoftBack);
1409 // June 22, 2006 REF: DRT OMAPS00081761 x0012849
1410 // Changed the limit frommm NUMBER_LENGTH to editor_num_length.
1411 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, editor_num_length);
1412 AUI_edit_SetMode(&editor_data, 0, ED_CURSOR_UNDERLINE);
1413
1414 return AUI_edit_Start(parent, &editor_data);
1415 }
1416
1417
1418
1419 /*******************************************************************************
1420
1421 $Function: bookInputStartNameEditor
1422
1423 $Description: Start the input handler using default properties
1424
1425 $Returns: Handle of newly created window, or NULL if failure
1426
1427 $Arguments: parent, parent window handle, buffer, input buffer
1428
1429 *******************************************************************************/
1430
1431 MfwHnd bookInputStartNameEditor( MfwHnd parent, void *buffer )
1432 {
1433 T_MFW_WIN *win_data = ( (T_MFW_HDR *) parent )->data;
1434 tBookStandard *data = (tBookStandard *) win_data->user;
1435 T_phbk *Phbk = data->phbk;
1436 T_AUI_EDITOR_DATA editor_data;
1437 U16 editor_length;
1438
1439 TRACE_FUNCTION ("bookInputStartNameEditor()");
1440
1441 /* xreddymn OMAPS00079431 May-29-2006
1442 * Restrict the number of characters that the user can input for name
1443 * based on which phonebook is selected.
1444 */
1445 if(bookGetBookSelected() == TRUE)
1446 {
1447 /* For ME phonebook use MAX_ALPHA_LEN */
1448 editor_length = MAX_ALPHA_LEN;
1449 }
1450 else
1451 {
1452 /* For SIM phonebook, restrict length to 14 */
1453 editor_length = 15;
1454 }
1455
1456 /* Set up the default parameters for the input window */
1457
1458 #if defined(CHINESE_MMI) && defined(EASY_TEXT_ENABLED)
1459 /*MC, the chinese editor MUST have a unicode string as input*/
1460 /*MC , SPR 1242 merged in from b-sample build*/
1461 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
1462 {
1463 T_CHINESE_DATA chinese_data;
1464 chinese_data.TextString = (char*) Phbk->edt_buf_name;
1465 if (chinese_data.TextString[0]== 0)//if, empty string
1466 {
1467 chinese_data.TextString[0] = (char)0x80;//give string Unicode tag /*a0393213 lint warnings removal-typecast done*/
1468 chinese_data.TextString[1] = 0x7F;
1469 }
1470 else
1471 {
1472 if (chinese_data.TextString[0]!= (char)0x80)/*If ASCII string*//*a0393213 lint warnings removal-typecast done*/
1473 {
1474
1475 /*SPR 1752, if ASCII string, use a latin editor*/
1476 AUI_edit_SetDefault(&editor_data);
1477 AUI_edit_SetDisplay(&editor_data, NUMBER_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT);
1478 AUI_edit_SetEvents(&editor_data, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)bookAddNameCB);
1479 AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterName, NULL);
1480 /* xreddymn OMAPS00079431 May-29-2006: Length changes based on selected phonebook */
1481 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, editor_length);
1482 AUI_edit_SetMode(&editor_data, ED_MODE_ALPHA, ED_CURSOR_BAR);
1483
1484 return AUI_edit_Start(parent, &editor_data);
1485 }
1486 }
1487 /*MC end*/
1488 chinese_data.Callback = (T_AUI_EDIT_CB)bookAddNameCB;
1489 chinese_data.Identifier = INPUT_LEFT ;
1490 chinese_data.LeftSoftKey = TxtSave;
1491 chinese_data.DestroyEditor = TRUE;
1492 /* xreddymn OMAPS00079431 May-29-2006: Length changes based on selected phonebook */
1493 chinese_data.EditorSize = (USHORT)((editor_length-4)/2);//i.e.8
1494 return chinese_input(parent, &chinese_data);
1495 }
1496 else
1497 #endif /* CHINESE_MMI && EASY_TEXT_ENABLED */
1498 {
1499 AUI_edit_SetDefault(&editor_data);
1500 AUI_edit_SetDisplay(&editor_data, NUMBER_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT);
1501 AUI_edit_SetEvents(&editor_data, 0, FALSE, FOREVER, (T_AUI_EDIT_CB)bookAddNameCB);
1502 AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterName, NULL);
1503 /*SPR 1752*/
1504 #ifdef NO_ASCIIZ
1505 if (Phbk->edt_buf_name[0] ==0x80)
1506 /* xreddymn OMAPS00079431 May-29-2006: Length changes based on selected phonebook */
1507 AUI_edit_SetBuffer(&editor_data, ATB_DCS_UNICODE, &Phbk->edt_buf_name[2], editor_length/2 -2);
1508 else
1509 #endif
1510 /* xreddymn OMAPS00079431 May-29-2006: Length changes based on selected phonebook */
1511 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)buffer, editor_length);
1512 AUI_edit_SetMode(&editor_data, ED_MODE_ALPHA, ED_CURSOR_BAR);
1513
1514 return AUI_edit_Start(parent, &editor_data);
1515 }
1516 }
1517
1518
1519
1520 /*******************************************************************************
1521
1522 $Function: bookInputDestroy
1523
1524 $Description: Destroy Input Window
1525
1526 $Returns: None
1527
1528 $Arguments: Handle of window to be destroyed
1529
1530 *******************************************************************************/
1531
1532 void bookInputDestroy( MfwHnd window )
1533 {
1534 TRACE_FUNCTION ("bookInputDestroy()");
1535 /*MC SPR 1752, send destroy event to window*/
1536 SEND_EVENT( window, E_ED_DESTROY, 0, 0 );
1537
1538 }
1539
1540 extern T_MFW_HND PhbSearchTim;
1541 /*******************************************************************************
1542
1543 $Function: bookAddNameCB
1544
1545 $Description: default call back for name entry
1546
1547 $Returns: None
1548
1549 $Arguments: win, handle of parent window, reason, for invocation
1550
1551 *******************************************************************************/
1552
1553 void bookAddNameCB( T_MFW_HND win, USHORT Identifier, SHORT reason )
1554 {
1555
1556
1557 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
1558 tBookStandard *data = (tBookStandard *) win_data->user;
1559 T_phbk *Phbk = data->phbk;
1560
1561 TRACE_FUNCTION("bookAddNameCB");
1562
1563 switch (reason)
1564 {
1565 case INFO_KCD_LEFT:
1566 {
1567 /* Construct a new entry to be written to the phone book
1568 */
1569
1570 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
1571 if (Phbk->edt_buf_name[0] == 0x80 )//MC, if unicode
1572 { //MC, if empty string, remove 0x80 at beginning
1573 if (Phbk->edt_buf_name[2]==0x00 && Phbk->edt_buf_name[3] == 0x00)
1574 memset(Phbk->edt_buf_name, 0, MAX_ALPHA_LEN);
1575 }
1576
1577 // xvilliva SPR21547 We check for presence of either phone number or name.
1578 // We add or modify the entry and flash an alert correspondingly.
1579 if(strlen((char *) Phbk->edt_buf_number)>0 || strlen((char *)Phbk->edt_buf_name)>0)
1580 {
1581 /* Store in the current phone book
1582 */
1583 if ( Phbk->UpdateAction == CREATE_ENTRY )
1584 storeInFile( Phbk );
1585 else if ( Phbk->UpdateAction == MODIFY_EXISTING )
1586 changeInFile( Phbk );
1587 bookShowInformation( win, MmiBookCurrentText(), NULL,NULL );
1588
1589 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- Start */
1590 mmi_int_phb_store_change_completion();
1591 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- End */
1592
1593 }
1594 else
1595 bookShowInformation( win, TxtInvalidInput, NULL,NULL );
1596
1597 /* And shut down, clearing the number and name windows as we go
1598 */
1599 if ( Phbk->input_number_win )
1600 {
1601 AUI_edit_Destroy(Phbk->input_number_win);
1602 Phbk->input_number_win = 0;
1603 }
1604 /*SPR 1752, send destroy event rather than calling destroy function*/
1605 SEND_EVENT( Phbk->input_name_win, E_ED_DESTROY, 0, 0 );
1606 Phbk->input_name_win = 0;
1607
1608 // Jan 22, 2006 REF: OMAPS00061930 x0039928
1609 // Fix : Start the phonebook timer in case of trying to modify the existing entry
1610 if ( Phbk->UpdateAction == MODIFY_EXISTING )
1611 timStart(PhbSearchTim);
1612
1613 /*MC-- get rid of search window(and options menu), if just changed a chinese entry
1614 (prevent showing scrambled entry)*/
1615 if ( Phbk->UpdateAction == MODIFY_EXISTING && Mmi_getCurrentLanguage()==CHINESE_LANGUAGE)
1616 {
1617 bookMenuDestroy(Phbk->menu_options_win);
1618 Phbk->menu_options_win=0;
1619 bookSearchDestroy( Phbk->search_win);
1620 Phbk->search_win=0;
1621 }
1622 }
1623 break;
1624
1625 case INFO_KCD_RIGHT:
1626 case INFO_KCD_HUP:
1627 /* Both right and HUP can do the same task here
1628 */
1629 /*SPR 1752, send destroy event rather than calling destroy function*/
1630 SEND_EVENT( Phbk->input_name_win, E_ED_DESTROY, 0, 0 );
1631 Phbk->input_name_win = 0;
1632 break;
1633
1634 default:
1635 {
1636 /* otherwise no action to be performed
1637 */
1638 break;
1639 }
1640 }
1641 if (Phbk->root_win==Phbk->win) /*To destroy the phonebook when entering from idle*/
1642 bookPhonebookDestroy(Phbk->win);
1643 }
1644
1645
1646 /*******************************************************************************
1647
1648 $Function: bookAddNumberCB
1649
1650 $Description: Default call back for number entry
1651
1652 $Returns: None
1653
1654 $Arguments: win, parent window, reason, for call back
1655
1656 *******************************************************************************/
1657
1658 void bookAddNumberCB( T_MFW_HND win, USHORT Identifier, SHORT reason )
1659 {
1660 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
1661 tBookStandard *data = (tBookStandard *) win_data->user;
1662
1663 switch ( reason )
1664 {
1665 case INFO_KCD_LEFT:
1666 data->phbk->input_name_win = bookInputStartNameEditor( data->win, data->phbk->edt_buf_name );
1667 break;
1668
1669 case INFO_KCD_RIGHT:
1670 case INFO_KCD_HUP:
1671 /* Both right and HUP can do the same task here
1672 */
1673 AUI_edit_Destroy( data->phbk->input_number_win );
1674 data->phbk->input_number_win = 0;
1675 break;
1676
1677 default:
1678 /* otherwise no action to be performed
1679 */
1680 break;
1681 }
1682 }
1683
1684
1685 #else /* NEW EDITOR */
1686
1687
1688 /*******************************************************************************
1689
1690 $Function: bookAddNameCB
1691
1692 $Description: default call back for name entry
1693
1694 $Returns: None
1695
1696 $Arguments: win, handle of parent window, reason, for invocation
1697
1698 *******************************************************************************/
1699
1700 void bookAddNameCB( T_MFW_HND win, UBYTE reason )
1701 {
1702 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
1703 tBookStandard *data = (tBookStandard *) win_data->user;
1704 T_phbk *Phbk = data->phbk;
1705 TRACE_FUNCTION("bookAddNameCB");
1706 switch (reason)
1707 {
1708 case INPUT_LEFT:
1709 {
1710
1711 /* Construct a new entry to be written to the phone book
1712 */
1713 #ifdef NO_ASCIIZ
1714 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
1715 if (Phbk->edt_buf_name[0] == 0x80 )//MC, if unicode
1716 { //MC, if empty string, remove 0x80 at beginning
1717 if (Phbk->edt_buf_name[2]==0x00 && Phbk->edt_buf_name[3] == 0x00)
1718 memset(Phbk->edt_buf_name, 0, MAX_ALPHA_LEN);
1719 }
1720 #endif
1721
1722 /* Store in the current phone book
1723 */
1724 if ( Phbk->UpdateAction == CREATE_ENTRY )
1725 storeInFile( Phbk );
1726 else if ( Phbk->UpdateAction == MODIFY_EXISTING )
1727 changeInFile( Phbk );
1728
1729
1730 bookShowInformation( win, MmiBookCurrentText(), NULL,NULL );
1731
1732 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- Start */
1733 mmi_int_phb_store_change_completion();
1734 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- End */
1735
1736
1737 /* And shut down, clearing the number and name windows as we go
1738 */
1739 if ( Phbk->input_number_win )
1740 {
1741 SEND_EVENT( Phbk->input_number_win, INPUT_DESTROY, 0, 0 );
1742 Phbk->input_number_win = 0;
1743 }
1744
1745
1746 SEND_EVENT( Phbk->input_name_win, INPUT_DESTROY, 0, 0 );
1747 Phbk->input_name_win = 0;
1748
1749 #ifdef NO_ASCIIZ
1750 /*MC-- get rid of search window(and options menu), if just changed a chinese entry
1751 (prevent showing scrambled entry)*/
1752 if ( Phbk->UpdateAction == MODIFY_EXISTING &&Mmi_getCurrentLanguage()==CHINESE_LANGUAGE)
1753 { bookMenuDestroy(Phbk->menu_options_win);
1754 Phbk->menu_options_win=0;
1755 bookSearchDestroy( Phbk->search_win);
1756 Phbk->search_win=0;
1757
1758 }
1759 #endif
1760
1761
1762 }
1763 break;
1764
1765 case INPUT_RIGHT:
1766 case INPUT_CLEAR:
1767 {
1768 /* Both right and clear can do the same task here
1769 */
1770 SEND_EVENT( Phbk->input_name_win, INPUT_DESTROY, 0, 0 );
1771 Phbk->input_name_win = 0;
1772 }
1773 break;
1774
1775 default:
1776 {
1777 /* otherwise no action to be performed
1778 */
1779 break;
1780 }
1781 }
1782 if (Phbk->root_win==Phbk->win) /*To destroy the phonebook when entering from idle*/
1783 bookPhonebookDestroy(Phbk->win);
1784 }
1785
1786
1787 /*******************************************************************************
1788
1789 $Function: bookAddNumberCB
1790
1791 $Description: Default call back for number entry
1792
1793 $Returns: None
1794
1795 $Arguments: win, parent window, reason, for call back
1796
1797 *******************************************************************************/
1798
1799 void bookAddNumberCB( T_MFW_HND win, UBYTE reason )
1800 {
1801 T_MFW_WIN *win_data = ( (T_MFW_HDR *) win )->data;
1802 tBookStandard *data = (tBookStandard *) win_data->user;
1803
1804 switch ( reason )
1805 {
1806 case INPUT_LEFT:
1807 {
1808 data->phbk->input_name_win =
1809 bookInputStartNameEditor( data->win, data->phbk->edt_buf_name );
1810 }
1811 break;
1812
1813 case INPUT_RIGHT:
1814 case INPUT_CLEAR:
1815 {
1816 /* Both right and clear can do the same task here
1817 */
1818 SEND_EVENT( data->phbk->input_number_win, INPUT_DESTROY, 0, 0 );
1819 data->phbk->input_number_win = 0;
1820 }
1821 break;
1822
1823 default:
1824 {
1825 /* otherwise no action to be performed
1826 */
1827 break;
1828 }
1829 }
1830 }
1831
1832 #endif /* NEW_EDITOR */
1833 // May 3, 2004 REF: CRR MMI-SPR-18555 Rashmi C N(Sasken)
1834 // This is called when we exit the FDN Numbers menu. So unsetting the menuFDN flag here
1835
1836 void fdn_menu_cb(T_MFW_HND parent_win, UBYTE identifier, UBYTE reason)
1837 {
1838 TRACE_EVENT("fdn_menu_cb");
1839 menuFDN=0;
1840 }
1841
1842 // May 3, 2004 REF: CRR MMI-SPR-18555 Rashmi C N(Sasken)
1843 // This is called to display the FDN Numbers menu. The menuFDN flag is set here
1844
1845 int bookFDNMenu(MfwMnu* menu, MfwMnuItem* item)
1846 {
1847 T_MFW_HND win = mfw_parent(mfw_header());
1848 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
1849 tBookStandard *data = (tBookStandard *) win_data->user;
1850
1851
1852
1853 menuFDN=1;
1854 // Sep 29, 2004 REF: CRR 25041 xvilliva
1855 // The bookMenuStart() is called with the window data->phbk->win,
1856 // similar to the function bookFDNMenu() to avoid crash. The menu window
1857 // thus created is stored, which will be deleted while phonebook menu is
1858 // destroyed.
1859 data->phbk->menu_call_options_win_2 = bookMenuStart( data->phbk->win, bookNameMenuFDNAttributes(),0);
1860 SEND_EVENT(data->phbk->menu_call_options_win_2, ADD_CALLBACK, NULL, (void *)fdn_menu_cb);
1861
1862 return 0; /* to remove warning Aug - 11 */
1863 }
1864
1865 // Jul 28, 2004 REF: CRR:20887 xrashmic - SASKEN
1866 // Description: Current state of FDN not highlighted
1867 // Fix: Instead of showing the submenu directly we call this function
1868 // where we set the menu and also higlight the previously selected menu item
1869
1870 extern MfwMnuAttr *FDNMenu(void);
1871 void settingsFocusFDNCurSel(void)
1872 {
1873 UBYTE CurSel; //, state; // RAVI
1874
1875
1876
1877 T_MFW_HND win = mfw_parent(mfw_header());
1878 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
1879 tBookStandard *data = (tBookStandard *) win_data->user;
1880
1881 // Sep 29, 2004 REF: CRR 25041 xvilliva
1882 // The bookMenuStart() is called with the window data->phbk->win,
1883 // similar to the function bookFDNMenu() to avoid crash. The menu window
1884 // thus created is stored, which will be deleted while phonebook menu is
1885 // destroyed.
1886 data->phbk->menu_options_win_2= bookMenuStart(data->phbk->win, FDNMenu(), 0);
1887 CurSel = (phb_get_mode() == PHB_RESTRICTED)?FIRSTMENUITEM:SECONDMENUITEM;
1888 SEND_EVENT(data->phbk->menu_options_win_2, DEFAULT_OPTION, NULL, &CurSel);
1889 }
1890
1891 // June 07, 2005 REF: CRR MMI-FIX-31545 x0021334
1892 // Issue description: SIM: wrong behavior when FDN is not allocated in SST
1893 // Added this function to check if FDN is allocated
1894 void checkFDNSupport(void)
1895 {
1896 T_MFW_HND win = mfw_parent(mfw_header());
1897
1898
1899
1900 UBYTE serv_stat;
1901 T_DISPLAY_DATA display_info;
1902
1903 // Check in SIM service table if FDN is allocated. If not allocated, display this info dialog
1904 /* x0045876, 14-Aug-2006 (WR - "serv_stat" was set but never used) */
1905 serv_stat = sim_serv_table_check(SRV_FDN);
1906 /*if ((serv_stat = sim_serv_table_check(SRV_FDN)) EQ NO_ALLOCATED)*/
1907 if (serv_stat EQ NO_ALLOCATED)
1908 {
1909 dlg_initDisplayData_TextId(&display_info, TxtSoftOK, NULL, TxtNotSupported, TxtNull, COLOUR_STATUS);
1910 dlg_initDisplayData_events(&display_info, (T_VOID_FUNC)NULL, THREE_SECS, KEY_LEFT | KEY_RIGHT);
1911 info_dialog (win, &display_info);
1912 }
1913 else // Else show the FDN menu and set focus on current selection
1914 settingsFocusFDNCurSel();
1915 }
1916
1917 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- Start */
1918
1919 /*******************************************************************************
1920
1921 $Function: mmi_int_phb_store_change_completion
1922
1923 $Description: Reset all flags on adding / editing an Internal PHB Entry
1924
1925 $Returns: None
1926
1927 $Arguments: None
1928
1929 *******************************************************************************/
1930 static void mmi_int_phb_store_change_completion()
1931 {
1932 /* Reset the "add" and "change" flags only incase of Internal PHB */
1933 if ( bookGetBookSelected() == TRUE )
1934 {
1935 addname_flag = FALSE;
1936
1937 changename_flag = FALSE;
1938 }
1939
1940 return;
1941 }
1942
1943 /* Sep 20, 2006 REF: OMAPS00145786 x0080701 (Bharat) -- End */
1944
1945 /*******************************************************************************
1946
1947 End of File
1948
1949 *******************************************************************************/
1950