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