comparison src/aci2/bmi/mmiBookSearchWindow.c @ 120:3c2acfa1a72f

src/aci2/bmi: file renames to make filename case consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 07 Oct 2016 03:46:05 +0000
parents src/aci2/bmi/MmiBookSearchWindow.c@93999a60b835
children
comparison
equal deleted inserted replaced
119:b92a33c204b6 120:3c2acfa1a72f
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: MmiSearchWindow.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description:
24
25 This module provides the phone book search window functionality for the
26 phone book module of the basic MMI
27
28 ********************************************************************************
29 $History: MmiSearchWindow.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 CRR: 25302 - xpradipg 10 Nov 2004
36 Description: Should be able to select the number fro the phonebook while
37 sending MMS/EMS.
38 Solution: The new feature to select the number from phonebook while sending
39 MMS/EMS is added
40
41 Oct 26, 2004 REF: CRR 25354 xkundadu
42 Description: Phonebook: After entering precise name to search and then
43 trying to delete using RSK, first character is not deleted
44 Fix: If only one character is present in the editor and delete key is pressed,
45 delete the editor buffer and update the editor view.
46
47 Aug 16, 2004 REF: CRR 24323 Deepa M.D
48 Bug:Clenup of sprintf used for tracing
49 Fix:Replace the char buf[]; sprintf (buf, "...", ...); TRACE_EVENT (buf); statements by TRACE_EVENT_PX
50
51 25/10/00 Original Condat(UK) BMI version.
52 20/02/02 Reinstated editor when in Chinese language by removing
53 "if not Chinese" conditions SPR 1742
54
55 $End
56
57 *******************************************************************************/
58
59
60 /*******************************************************************************
61
62 Include Files
63
64 *******************************************************************************/
65 #define ENTITY_MFW
66
67 /* includes */
68 #include <string.h>
69 #include <stdio.h>
70 #include <stdlib.h>
71
72 #if defined (NEW_FRAME)
73
74 #include "typedefs.h"
75 #include "vsi.h"
76 #include "pei.h"
77 #include "custom.h"
78 #include "gsm.h"
79
80 #else
81
82 #include "STDDEFS.H"
83 #include "custom.h"
84 #include "gsm.h"
85 #include "vsi.h"
86
87 #endif
88
89 #include "mfw_sys.h"
90
91 #include "mfw_mfw.h"
92 #include "mfw_win.h"
93 #include "mfw_kbd.h"
94 #include "mfw_lng.h"
95 /* SPR#1428 - SH - New Editor changes */
96 #ifndef NEW_EDITOR
97 #include "mfw_edt.h"
98 #endif
99 #include "mfw_icn.h"
100 #include "mfw_mnu.h"
101 #include "mfw_tim.h"
102
103 #include "mfw_sim.h"
104 #include "mfw_cm.h"
105 #include "mfw_nm.h"
106 #include "mfw_phb.h"
107 #include "mfw_mme.h"
108 #include "mfw_sat.h"
109 #include "mfw_sms.h"
110 #include "mfw_cnvt.h" //mfw_Gsm2SIMStr prototype
111
112 #include "dspl.h"
113
114 #include "ksd.h"
115 #include "psa.h"
116
117 #include "MmiMain.h"
118 #include "MmiBookController.h"
119 #include "MmiDummy.h"
120 #include "MmiDialogs.h"
121 #include "MmiLists.h"
122
123
124
125 #include "MmiMenu.h"
126 #include "mmiCall.h"
127 #include "Mmiicons.h"
128 #include "MmiIdle.h"
129
130 #include "MmiSoftKeys.h"
131 #include "MmiSounds.h"
132 #include "MmiIdle.h"
133 #include "MmiNetwork.h"
134 #include "mmiSat_i.h"
135 #include "MmiAoc.h"
136
137 #include "gdi.h"
138 #include "audio.h"
139
140 #include "cus_aci.h"
141 #include "mfw_ffs.h"
142 #include "MmiTimers.h"
143
144
145 #include "MmiBookShared.h"
146 #include "mmiSmsMenu.h"
147 #include "mmismssend.h"
148 #include "MmiLists.h"
149 #include "mmiSmsRead.h"
150 /* SPR#1428 - SH - New Editor changes */
151 #ifdef NEW_EDITOR
152 #include "ATBCommon.h"
153 #include "ATBDisplay.h"
154 #include "ATBEditor.h"
155 #include "AUIEditor.h"
156 #include "AUITextEntry.h"
157
158 #endif
159
160 typedef struct
161 {
162 T_MMI_CONTROL mmi_control;
163 T_MFW_HND chinese_search_win; /* MFW win handler */
164 T_MFW_HND parent;
165 ListMenuData * menu_list_data;
166 } T_CHINESE_SEARCH_INFO;
167 #include "mmiColours.h"
168
169 //CRR: 25302 - xpradipg 10 Nov 2004
170 //extern MmsSend_PHBK_exec_cb(T_MFW_HND win, USHORT event, void *parameter);
171
172
173 /*******************************************************************************
174
175 Private Methods
176
177 *******************************************************************************/
178 //#define TIME_TRACE_EVENT TRACE_EVENT
179 #ifndef TIME_TRACE_EVENT
180 #define TIME_TRACE_EVENT
181 #endif
182
183 /*******************************************************************************
184
185 $Function: bookSearchDialog
186
187 $Description: dialog handler for the search window functionality
188
189 $Returns: None
190
191 $Arguments: win, window handle
192 event, event to be handled
193 value, not used
194 parameter, not used
195
196 *******************************************************************************/
197
198 void bookSearchDialog( T_MFW_HND win, USHORT event, SHORT value, void *parameter )
199 {
200 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
201 tBookStandard *data = (tBookStandard *) win_data->user;
202 tMmiPhbData *Current = &data->phbk->current;
203 MfwMnu *mnu;
204 //Jan 22, 2006 REF: OMAPS00061930 x0039928
205 // Fix : Add a local variable search_string
206 char search_string[MAX_ALPHA_LEN];
207
208 TRACE_FUNCTION( "bookSearchDialog()" );
209
210 switch( event )
211 {
212 case SEARCH_INIT:
213 {
214 /* No initialisation required
215 */
216 }
217 break;
218
219 case SEARCH_SCROLL_UP:
220 { /*MC SPR 1541, flag to show whether we've scrolled off-screen and need to
221 update the portion of the list displayed*/
222 BOOL get_new_screen = FALSE;
223
224
225 /* Scroll up
226 */
227 if ( ( Current->index == 1 ) && ( Current->selectedName == 0 ) )
228 {
229 if ( Current->status.used_entries < MAX_SEARCH_NAME )
230 Current->selectedName = Current->status.used_entries - 1;
231 else
232 { Current->selectedName = MAX_SEARCH_NAME - 1;
233 /*SPR 1541, we're scrolling up from the first item in the list and are to go to
234 the end*/
235 get_new_screen = TRUE;
236 }
237 Current->index = Current->status.used_entries - Current->selectedName;
238
239 }
240 else
241 {
242 if (Current->selectedName == 0)
243 { Current->index--;
244 /*SPR 1541, we've just come off the top of the screen*/
245 get_new_screen = TRUE;
246 }
247 else
248 Current->selectedName--;
249 }
250
251 mnu = (MfwMnu *) mfwControl( data->menu );
252 mnu->lCursor[mnu->level] = Current->selectedName;
253
254 /*SPR 1541, only update the list if flag set*/
255 if (get_new_screen == TRUE)
256 bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
257 }
258 break;
259
260 case SEARCH_SCROLL_DOWN:
261 { /*MC SPR 1541, flag to show whether we've scrolled off-screen and need to
262 update the portion of the list displayed*/
263 BOOL get_new_screen = FALSE;
264
265 /* Scroll Down
266 */
267 if ( ( Current->index + Current->selectedName ) == Current->status.used_entries )
268 {
269 Current->index = 1;
270 Current->selectedName = 0;
271 /*SPR 1541, we've come off the end of the list and are to go back to
272 the beginning*/
273 get_new_screen = TRUE;
274 }
275 else
276 {
277 if ( Current->selectedName == MAX_SEARCH_NAME - 1 )
278 { Current->index++;
279 /*SPR 1541, we've just come off the bottom of the screen*/
280 get_new_screen = TRUE;
281 }
282 else
283 Current->selectedName++;
284 }
285
286 mnu = (MfwMnu *) mfwControl( data->menu );
287 mnu->lCursor[mnu->level] = Current->selectedName;
288 /*SPR 1541, only update the list if flag set*/
289 if (get_new_screen == TRUE)
290 bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
291 }
292 break;
293
294 case SEARCH_STRING:
295 {
296 {
297 //Jan 22, 2006 REF: OMAPS00061930 x0039928
298 //Fix : Copy the number to be searched into the search_string variable and give a search for it
299 if ( value == TRUE)
300 strcpy(search_string,(char*)data->phbk->edt_buf_name);
301 else
302 strcpy(search_string,(char*)data->edtBuf);
303
304 /* Find name
305 */
306 Current->index = Current->index + Current->selectedName;
307 if ( bookSearchName( search_string, MAX_SEARCH_NAME, Current ) == MFW_PHB_OK )
308 {
309 if ( Current->index > ( Current->status.used_entries + 1 - MAX_SEARCH_NAME ) )
310 {
311 if ( Current->status.used_entries > MAX_SEARCH_NAME )
312 {
313 Current->selectedName = Current->index - Current->status.used_entries + MAX_SEARCH_NAME - 1;
314 Current->index = Current->index - Current->selectedName;
315 }
316 else
317 {
318 Current->selectedName = Current->index - 1;
319 Current->index=1;
320 }
321
322 /* go find the name
323 */
324
325 bookFindName(MAX_SEARCH_NAME,&data->phbk->current);
326 }
327 else
328 {
329 Current->selectedName =0;
330
331 }
332
333 /* update the menu */
334 /* SPR881 - SH - Move name find to below */
335 }
336 else
337 {/*SPR 2233, if no name found, go to beginning of list*/
338 Current->index = 1;
339 Current->selectedName = 0;
340 }
341
342 /* update the menu
343 */
344 /* SPR881 - SH - is necessary even when BookSearchName, above, fails */
345
346 mnu = (MfwMnu *) mfwControl( data->menu );
347 mnu->lCursor[mnu->level] = Current->selectedName;
348 TRACE_EVENT_P1("Current->selectedName: %d", Current->selectedName);
349 /* go find the name
350 */
351 bookFindName(MAX_SEARCH_NAME,&data->phbk->current);
352 }
353 }
354 break;
355
356 case SEARCH_UPDATE:
357 {
358 /* Update, actually an initialisation/reset phase
359 */
360 Current->index = 1;
361 Current->selectedName = 0;
362
363 {
364 memset( data->edtBuf, '\0', sizeof( data->edtBuf ) );
365 /* SPR#1428 - SH - New Editor changes */
366 #ifdef NEW_EDITOR
367 ATB_edit_Reset( data->editor );
368 #else /* NEW_EDITOR */
369 edtReset( data->edt );
370 #endif /* NEW_EDITOR */
371 SEND_EVENT( win, SEARCH_STRING, 0, 0 );
372 }
373 }
374 break;
375
376 /* SPR#1428 - SH - New Editor: Add this to allow redraw of
377 * window on request. */
378
379 #ifdef NEW_EDITOR
380 case SEARCH_REDRAW:
381 /*SPR 2104, TRACE seems to fix timing probs :/ */
382 TRACE_EVENT("UPDATE SEARCH REDRAW");
383 SEND_EVENT(data->win, SEARCH_STRING, 0, 0);
384 win_show(data->win);
385 break;
386 #endif /* NEW_EDITOR */
387
388 default:
389 {
390 /*
391 */
392 }
393 break;
394 }
395 }
396
397
398
399
400
401
402 /*******************************************************************************
403
404 $Function: bookSearchWindowCB
405
406 $Description: Window call back function
407
408 $Returns: MFW_EVENT_CONSUMED, or MFW_EVENT_PASSED
409
410 $Arguments: e, event, w, window handle
411
412 *******************************************************************************/
413
414 static int bookSearchWindowCB( MfwEvt e, MfwWin *w )
415 {
416 tBookStandard *data = (tBookStandard *) w->user;
417 tMmiPhbData *Current = &data->phbk->current;
418 int index;
419 char *pchr;
420 char pchr2[PHB_MAX_LEN*2 +4];/*mc, SPR 1442*/
421 TRACE_FUNCTION( "bookSearchWindowCB()" );
422
423 // May 3, 2004 REF: CRR MMI-SPR-18555 Rashmi C N(Sasken)
424 // When FDN is disabled we need to display only ADN entries in the phonebook menu.
425 // We just use the preset PHB_ADN as the current book.
426 //if(data->phbk->current.status.book == PHB_ADN)
427 // data->phbk->current.status.book = PHB_ADN_FDN;
428
429
430 /* Deal with the visible event
431 */
432 switch (e)
433 {
434 case MfwWinVisible:
435 {
436 /* Deal with the window visible event
437 */
438 MmiBookShowDefault();
439
440 {
441 /* SPR#1428 - SH - New Editor changes */
442 #ifdef NEW_EDITOR
443 ATB_edit_Show( data->editor );
444 #else /* NEW_EDITOR */
445 edtShow( data->edt );
446 #endif /* NEW_EDITOR */
447 }
448
449 /* SPR#1428 - SH - New Editor: Only update the list if we're not in multi-tap */
450 #ifdef NEW_EDITOR
451 if (!data->editor->multitap)
452 {
453 #endif /* NEW_EDITOR */
454
455 for ( index = 0; index < MAX_SEARCH_NAME; index++ )
456 {
457 TIME_TRACE_EVENT( "bookSearchWindowCB()-loopstart" );
458
459 pchr = (char *) MmiBookCallList( index );
460
461 memset( pchr, '\0', NAME_SCREEN_MAX );
462
463 /* SPR#1428 - SH - remove extraneous call to edtShow*/
464 /*SPR 2123, using new macro PHONEBOOK_ITEM_LENGTH*/
465 #ifdef NO_ASCIIZ
466 /*if current language chinese*/
467 if (Mmi_getCurrentLanguage() == CHINESE_LANGUAGE)
468 { /*SPR 2653, this check should be here too*/
469 if (!Current->list.entry == NULL)
470 { if ( Current->entry[ index ].name.len NEQ 0) //if name not empty
471 {
472 if (Current->entry[ index ].name.data[0] != 0x80)//if not unicode
473 {/*we have to convert to unicode*/
474 pchr2[0]= 0x80;/*SPR 1442, add unicode tag*/
475 pchr2[1]= 0x7f;
476 /*SPR2175, use new function*/
477 ATB_convert_String((char*)Current->entry[ index ].name.data, MFW_ASCII,
478 (UBYTE)strlen((char*)Current->entry[ index ].name.data), &pchr2[2], MFW_DCS_UCS2, PHONEBOOK_ITEM_LENGTH-2, FALSE);
479 /*SPR 1442 and now truncate the string*/
480 resources_truncate_to_screen_width((char *) pchr2, Current->entry[ index ].name.len*2+2, pchr,PHONEBOOK_ITEM_LENGTH , SCREEN_SIZE_X, TRUE);
481 }
482 else /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
483 {
484 /*SPR 1442 truncate the string*/
485 resources_truncate_to_screen_width((char *) Current->entry[index].name.data, Current->entry[index].name.len, pchr, MAX_ALPHA_LEN, SCREEN_SIZE_X, TRUE);
486 }
487 }
488 else /*we convert number string into unicode*/
489 { pchr2[0]= 0x80;/*SPR 1442, add unicode tag*/
490 pchr2[1]= 0x7f;
491 /*SPR 2175, use new function*/
492 ATB_convert_String((char*)Current->entry[ index ].number, MFW_ASCII,
493 (UBYTE)strlen((char*)Current->entry[ index ].number), &pchr2[2], MFW_DCS_UCS2, PHONEBOOK_ITEM_LENGTH-2, FALSE);
494 /*SPR 1442 and now truncate the string*/
495 resources_truncate_to_screen_width((char *) pchr2, strlen((char*)Current->entry[ index ].number)*2+2, pchr,PHONEBOOK_ITEM_LENGTH, SCREEN_SIZE_X, TRUE);
496 }
497 }
498
499 }
500
501 else
502 { /*if current language a latin language*/
503 /*SPR 2653, removed consitional compilation, this check applies whether we're in simulation mode or target hardware*/
504 // EF check for null pointer first
505 if (!Current->list.entry == NULL)
506 /*SPR 2104, don't need this test*/
507
508 if ( Current->entry[ index ].name.len NEQ 0&&Current->entry[ index ].name.data[0] != 0x80/*mc*/) //Should check to see if null name
509 { /*mc, SPR 1442, replaced old truncation function with new one*/
510 resources_truncate_to_screen_width((char *) Current->entry[index].name.data, Current->entry[index].name.len, pchr, PHONEBOOK_ITEM_LENGTH, SCREEN_SIZE_X, FALSE);
511 }
512 else
513 {/*mc, SPR 1442, replaced old truncation function with new one*/
514 resources_truncate_to_screen_width((char *) Current->entry[index].number, strlen((char*)Current->entry[index].number), pchr, PHONEBOOK_ITEM_LENGTH, SCREEN_SIZE_X,FALSE);
515 }
516
517 #else
518 if ( Current->entry[ index ].name[ 0 ] != NULL) //Should check to see if null name
519 { /*mc, SPR 1442, replaced old truncation function with new one*/
520 resources_truncate_to_screen_width((char *) Current->entry[index].name, 0, pchr, PHONEBOOK_ITEM_LENGTH, SCREEN_SIZE_X, FALSE);
521 }
522 else
523 { /*mc, SPR 1442, replaced old truncation function with new one*/
524 resources_truncate_to_screen_width((char *) Current->entry[index].number, strlen((char*)Current->entry[index].number), pchr, PHONEBOOK_ITEM_LENGTH, SCREEN_SIZE_X,FALSE);
525 }
526 /*SPR 2123 end*/
527 #endif
528 #ifdef NO_ASCIIZ/*MC SPR 975, opening bracket only exists when NO_ASCIIZ defined*/
529 }
530 #endif
531 }
532
533 TIME_TRACE_EVENT( "bookSearchWindowCB()-end of loop" );
534 mnuShow(data->menu);
535 /* SPR#1428 - SH - End of condition to check if we're in multi-tap */
536 #ifdef NEW_EDITOR
537 }
538 #endif
539
540 /* special case if invoked from SMS or using SDN book
541 */
542 if ( ( data->phbk->fromSMS )||
543 ( data->phbk->fromSMSSC ) || /* SPR#1428 - SH - New event for service centre editor */
544 ( data->phbk->fromDivert ) ||
545 ( data->phbk->fromDeflect )||
546 //CRR: 25302 - xpradipg 10 Nov 2004
547 //check if it was invoked from MMS/EMS
548 ( data->phbk->fromMmsEms)||
549 ( Current->status.book == PHB_SDN ) )
550 {
551 //displaySoftKeys( TxtSoftSelect, TxtSoftBack );
552 // Jun 07, 2004 REF: CRR MMI-SPR-12818 Rashmi C N(Sasken)
553 // when the editor is empty, we need to display BACK softkey
554 // Delete softkey is displayed when it contains some characters
555 if (data->editor_attr.text.len==0)
556 {
557 displaySoftKeys( TxtSoftSelect, TxtSoftBack );
558 }
559 else
560 {
561 displaySoftKeys( TxtSoftSelect, TxtDelete );
562 }
563 }
564 else
565 {
566 //displaySoftKeys( TxtSoftOptions, TxtSoftBack );
567 // Jun 07, 2004 REF: CRR MMI-SPR-12818 Rashmi C N(Sasken)
568 // when the editor is empty, we need to display BACK softkey
569 // Delete softkey is displayed when it contains some characters
570 if (data->editor_attr.text.len==0)
571 {
572 displaySoftKeys( TxtSoftOptions, TxtSoftBack );
573 }
574 else
575 {
576 displaySoftKeys( TxtSoftOptions, TxtDelete );
577 }
578 }
579
580 }
581 TIME_TRACE_EVENT( "bookSearchWindowCB()-sk display end" );
582 break;
583
584 default:
585 {
586 /* default is to pass event back for further handling
587 */
588 return MFW_EVENT_PASSED;
589 }
590 // break; // RAVI
591
592 }
593
594 /* consume the event
595 */
596 return MFW_EVENT_CONSUMED;
597 }
598
599
600
601
602
603
604
605
606 /*******************************************************************************
607
608 $Function: bookSearchKbdCB
609
610 $Description: Keyboard handler
611
612 $Returns: MFW_EVENT_CONSUMED always
613
614 $Arguments: e, event, k, key handle
615
616 *******************************************************************************/
617
618 static int bookSearchKbdCB( MfwEvt e, MfwKbd *k )
619 {
620 T_MFW_HND win = mfwParent( mfw_header() );
621 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
622 tBookStandard *data = (tBookStandard *) win_data->user;
623 tMmiPhbData *Current = &data->phbk->current;
624
625 TRACE_FUNCTION ("bookSearchKbdCB()");
626
627 /* SPR#1428 - SH - New editor doesn't require editActivate */
628 #ifndef NEW_EDITOR
629 /* Set our editor active if it isn't already
630 */
631 if ( activeEditor() != data->edt )
632 editActivate( data->edt, TRUE);
633 #endif
634
635 /* Deal with the key and event combinatino
636 */
637
638
639 switch( k->code )
640 {
641 case KCD_MNUUP:
642 {
643 /* scroll up
644 */
645 SEND_EVENT( data->win, SEARCH_SCROLL_UP, 0, 0 );
646 winShow( data->win );
647 }
648 break;
649
650 case KCD_MNUDOWN:
651 {
652 /* scroll down
653 */
654 SEND_EVENT( data->win, SEARCH_SCROLL_DOWN, 0, 0 );
655 winShow( data->win );
656 }
657 break;
658
659
660
661 case KCD_CALL:
662 if ( data->phbk->fromSMS )
663 SEND_EVENT( data->phbk->parent_win, SMS_PHBK_NUMBER, PHBK_ID,
664 (UBYTE *) Current->entry[ Current->selectedName ].number );
665 else if ( data->phbk->fromSMSSC )
666 SEND_EVENT( data->phbk->parent_win, SMSSC_PHBK_NUMBER, PHBK_ID,
667 (UBYTE *) Current->entry[ Current->selectedName ].number );
668 else
669 { if (data->phbk->fromDeflect /*SPR 1392, select number don't call it*/ )
670 SEND_EVENT( data->phbk->parent_win, DEFLECT_PHBK_NUMBER, PHBK_ID,
671 (UBYTE *) Current->entry[ Current->selectedName ].number );
672 else
673 callNumber( Current->entry[ Current->selectedName ].number );
674 }
675 bookPhonebookDestroy(data->phbk->win);
676 break;
677 /* JVJ #1743 Right key deletes the characters, HUP destroys the window */
678 #ifdef NEW_EDITOR
679 case KCD_HUP:
680 #else /* NEW_EDITOR */
681 case KCD_HUP:
682 #endif /* NEW_EDITOR */
683 {
684 if ( data->phbk->fromSMS ){ /* Send empty string so that ptr can be set 0*/
685 SEND_EVENT( data->phbk->parent_win, SMS_PHBK_NUMBER, PHBK_ID,
686 "" );
687 bookPhonebookDestroy(data->phbk->win);
688 }
689 else if ( data->phbk->fromSMSSC ){
690 SEND_EVENT( data->phbk->parent_win, SMSSC_PHBK_NUMBER, PHBK_ID,
691 NULL );
692 bookPhonebookDestroy(data->phbk->win);
693 }
694 /* Marcus (mk): Issue 1010: 2002-08-22: Start */
695 else if (data->phbk->fromDivert)
696 {
697 bookPhonebookDestroy(data->phbk->win);
698 }
699 else if (data->phbk->fromDeflect)/*MC SPR 1392*/
700 { /*Send empty string so that pointer to this window can be set to 0*/
701 SEND_EVENT( data->phbk->parent_win, DEFLECT_PHBK_NUMBER, PHBK_ID,"");
702 bookPhonebookDestroy(data->phbk->win);
703 }
704 //CRR: 25302 - xpradipg 10 Nov 2004
705 //also handle if invoked by MMS/EMS
706 else if ( data->phbk->fromMmsEms )
707 { /* Send empty string so that ptr can be set 0*/
708 SEND_EVENT( data->phbk->parent_win, MMS_EMS_PHBK_NUMBER, PHBK_ID,"" );
709 bookPhonebookDestroy(data->phbk->win);
710 }
711 /* Marcus (mk): Issue 1010: 2002-08-22: End */
712 else
713 bookSearchDestroy(data->win);
714
715 }
716 break;
717
718 case KCD_MNUSELECT:
719 case KCD_LEFT:
720
721 {
722 /* if in SMS send the event to it
723 */
724 if ( data->phbk->fromSMS )
725 { SEND_EVENT( data->phbk->parent_win, SMS_PHBK_NUMBER, PHBK_ID /*MZ 6/2/01 */,
726 (UBYTE *) Current->entry[ Current->selectedName ].number );
727 bookPhonebookDestroy(data->phbk->win);
728 }
729 else if ( data->phbk->fromSMSSC )
730 { SEND_EVENT( data->phbk->parent_win, SMSSC_PHBK_NUMBER, PHBK_ID /*MZ 6/2/01 */,
731 (UBYTE *) Current->entry[ Current->selectedName ].number );
732 bookPhonebookDestroy(data->phbk->win);
733 }
734 else if(data->phbk->fromDivert ) //MZ 26/02/01 check for divert If in Divert send event.
735 {
736 SEND_EVENT( data->phbk->parent_win, DIVERT_PHBK_NUMBER, PHBK_ID /*MZ 28/2/01 */,
737 (UBYTE *) Current->entry[ Current->selectedName ].number );
738 bookPhonebookDestroy(data->phbk->win);
739 }
740 else if(data->phbk->fromDeflect ) /*SPR 1392*/
741 {
742 TRACE_EVENT_P1("<< API deflection no. = %s", (char*) Current->entry[ Current->selectedName ].number);
743 SEND_EVENT( data->phbk->parent_win, DEFLECT_PHBK_NUMBER, PHBK_ID,
744 (UBYTE *) Current->entry[ Current->selectedName ].number );
745 bookPhonebookDestroy(data->phbk->win);
746 }
747 //CRR: 25302 - xpradipg 10 Nov 2004
748 //send the number to the MMS/EMS window
749 else if(data->phbk->fromMmsEms)
750 {
751 TRACE_EVENT_P1("the value if win from MMS is %x",data->phbk->parent_win);
752 SEND_EVENT( data->phbk->parent_win, MMS_EMS_PHBK_NUMBER,PHBK_ID,(void *) Current->entry[ Current->selectedName ].number );
753 bookPhonebookDestroy(data->phbk->win);
754 }
755 else
756 /* Start a new options menu
757 */
758 /*check for UPN SPR 1327*/
759 if (Current->status.book != PHB_UPN)
760 data->phbk->menu_options_win = bookMenuStart( data->phbk->win, bookNameMenuAttributes(),0);
761 else
762 data->phbk->menu_options_win = bookMenuStart( data->phbk->win, bookUPNMenuAttributes(),0);
763 }
764 break;
765
766 /* JVJ #1743 Right key deletes search character*/
767 #ifdef NEW_EDITOR
768 case KCD_RIGHT:
769 #else /* NEW_EDITOR */
770 case KCD_HUP:
771 #endif /* NEW_EDITOR */
772 {
773
774
775
776 /* If we have any characters in the buffer, step back, otherwise
777 destroy the window
778 */
779
780 if ( data->edtBuf[0])
781 {
782
783 // Oct 26, 2004 REF: CRR 25354 xkundadu
784 // Description: Phonebook: After entering precise name to search and then
785 // trying to delete using RSK, first character is not deleted.
786 // Fix: If only one character is present in the editor and delete key is
787 // pressed, delete the editor buffer and update the editor view.
788
789 // Find out the length of the buffer.
790 if(strlen((char*)data->edtBuf) == 1)
791 {
792 //If only one character is present, delete and set the buffer
793 //to NULL.
794 data->edtBuf[0] = '\0';
795 data->editor_attr.text.len = 0;
796 //Move the cursor accordingly.
797 ATB_edit_MoveCursor(data->editor, ctrlLeft, TRUE);
798 data->editor->update = ED_UPDATE_TRIVIAL;
799 SEND_EVENT( data->win, SEARCH_STRING, 0, 0);
800 //Update the window.
801 winShow( data->win );
802 break;
803 }
804
805 /* SPR#1428 - SH - New Editor changes */
806 #ifdef NEW_EDITOR
807 /* SPR#2174 - SH - If multitap is in progress, delete current character
808 * rather than previous character */
809
810 if (data->editor->multitap)
811 {
812 AUI_entry_StopMultitap(data->entry_data); /* Cancel multitap */
813 ATB_edit_DeleteRight(data->editor, TRUE); /* SPR#2342 - SH */
814 }
815 else
816 {
817 ATB_edit_DeleteLeft(data->editor, TRUE); /* SPR#2342 - SH */
818 }
819 #else /* NEW_EDITOR */
820 edtChar( data->edt,ecBack );
821 #endif /* NEW_EDITOR */
822
823 SEND_EVENT( data->win, SEARCH_STRING, 0, 0 );
824 winShow( data->win );
825 }
826 else
827 {
828 /*API - 12/08/03 - CQ11268 - Add this so the phonebbok is destoryed on right key press*/
829 if ( data->phbk->fromSMS )
830 { /* Send empty string so that ptr can be set 0*/
831 bookPhonebookDestroy(data->phbk->win);
832 }
833 else if ( data->phbk->fromSMSSC )
834 {
835 bookPhonebookDestroy(data->phbk->win);
836 }
837 /* Marcus (mk): Issue 1010: 2002-08-22: Start */
838 else if (data->phbk->fromDivert)
839 {
840 bookPhonebookDestroy(data->phbk->win);
841 }
842 else if (data->phbk->fromDeflect)/*MC SPR 1392*/
843 { /*Send empty string so that pointer to this window can be set to 0*/
844 bookPhonebookDestroy(data->phbk->win);
845 }
846 //CRR: 25302 - xpradipg 10 Nov 2004
847 //Handle if invoked from MMS/EMS
848 else if(data->phbk->fromMmsEms)
849 {
850 bookPhonebookDestroy(data->phbk->win);
851 }
852 /* Marcus (mk): Issue 1010: 2002-08-22: End */
853 else
854 bookSearchDestroy(data->win);
855 /*API - 12/08/03 - CQ11268 - END*/
856 }
857 }
858 break;
859
860 case KCD_HASH:
861 {
862
863 {
864 /* SPR#1428 - SH - New Editor changes */
865 #ifdef NEW_EDITOR
866 ATB_edit_DeleteLeft( data->editor, TRUE); /* SPR#2342 - SH */
867 #else /* NEW_EDITOR */
868 edtChar( data->edt,ecBack );
869 #endif /* NEW_EDITOR */
870 }
871
872 /*NM, p016
873 even updating when deleting characters
874 */
875 SEND_EVENT( data->win, SEARCH_STRING, 0, 0 );
876 winShow( data->win );
877 }
878 break;
879
880 default:
881 {
882
883 {
884 /* SPR#1428 - SH - New Editor changes */
885 #ifdef NEW_EDITOR
886 AUI_entry_EventKey( data->entry_data, e, k );
887
888 /* send the search event to ourselves,
889 * but only when a character is finished in multi-tap
890 */
891 if (!data->editor->multitap)
892 {
893 SEND_EVENT( data->win, SEARCH_STRING, 0, 0 );
894 }
895 #else /* NEW_EDITOR */
896 editEventKey( e, k );
897 /* send the search event to ourselves,
898 */
899 SEND_EVENT( data->win, SEARCH_STRING, 0, 0 );
900 #endif /* NEW_EDITOR */
901 winShow( data->win );
902 }
903 }
904 break;
905
906 }
907
908 /* always consume the event
909 */
910 return MFW_EVENT_CONSUMED;
911 }
912
913
914
915
916
917
918
919 /*******************************************************************************
920
921 $Function: bookSearchKbdLongCB
922
923 $Description: long keypress event handler, handles long clear event only
924
925 $Returns: MFW_EVENT_CONSUMED always
926
927 $Arguments: e, event, k, key handle
928
929 *******************************************************************************/
930
931 static int bookSearchKbdLongCB( MfwEvt e, MfwKbd *k )
932 {
933 T_MFW_HND win = mfwParent( mfw_header() );
934 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
935 tBookStandard *data = (tBookStandard *) win_data->user;
936
937 TRACE_FUNCTION ("bookSearchKbdLongCB()");
938
939 /* deal with the clear event
940 */
941 if ( ( e & KEY_CLEAR ) && ( e & KEY_LONG ) )
942 {
943 bookSearchDestroy( win );
944 data->phbk->search_win = 0;
945 }
946
947 /* consume the event
948 */
949 return MFW_EVENT_CONSUMED;
950 }
951
952 //Jan 22, 2006 REF: OMAPS00061930 x0039928
953 // Fix : Add a temporary timer handle for future reference.
954 T_MFW_HND PhbSearchTim;
955
956 /*******************************************************************************
957
958 $Function: bookSearchTimCB
959
960 $Description: Callback function for the Phonebook timer.
961
962 $Returns: None
963
964 $Arguments: window handle event, timer control block
965
966 *******************************************************************************/
967
968 static int bookSearchTimCB (MfwEvt event, MfwTim *timer)
969 {
970 T_MFW_HND win = mfwParent( mfw_header() );
971 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
972 tBookStandard *data = (tBookStandard *) win_data->user;
973 tMmiPhbData *Current = &data->phbk->current;
974
975 TRACE_FUNCTION ("bookSearchTimCB()");
976
977 SEND_EVENT( data->win, SEARCH_STRING, 1, 0);
978 winShow( data->win );
979 }
980
981
982 /*******************************************************************************
983
984 $Function: bookSearchCreate
985
986 $Description: Create the search window
987
988 $Returns: handle of window or NULL if error
989
990 $Arguments: parent, handle of parent window
991
992 *******************************************************************************/
993
994 static T_MFW_HND bookSearchCreate( MfwHnd parent )
995 {
996 T_MFW_WIN *parent_win_data = ( (T_MFW_HDR *) parent )->data;
997 T_phbk *phbk = (T_phbk *)parent_win_data->user;
998 T_MFW_WIN *win_data;
999 tBookStandard *data;
1000 // int i; // RAVI
1001 // char debug[50]; // RAVI
1002
1003 TRACE_FUNCTION ("bookSearchCreate()");
1004
1005 /* allocate memory for our control block
1006 */
1007 if ( ( data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) ) ) == NULL )
1008 return NULL;
1009
1010 /*SPR 2123, MC allocate memory for phonebook list*/
1011 if (create_mmi_phonebook_names_list() == NULL)
1012 return NULL;
1013
1014 /* Create the window if we can
1015 */
1016 if ( ( data->win = win_create( parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookSearchWindowCB ) ) == NULL )
1017 {
1018 FREE_MEMORY( (void *) data, sizeof( tBookStandard ) );
1019 return NULL;
1020 }
1021
1022 /* Okay, we have created the control block and the window, so
1023 we now need to configure the dialog and data pointers
1024 */
1025 data->mmi_control.dialog = (T_DIALOG_FUNC) bookSearchDialog;
1026 data->mmi_control.data = data;
1027 win_data = ((T_MFW_HDR *)data->win)->data;
1028 win_data->user = (void *) data;
1029 data->phbk = phbk;
1030 data->parent_win = parent;
1031
1032 /* create keyboards and menus for our window
1033 */
1034 data->kbd = kbdCreate( data->win, KEY_ALL, (MfwCb) bookSearchKbdCB );
1035 data->kbd_long = kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookSearchKbdLongCB );
1036 //Jan 22, 2006 REF: OMAPS00061930 x0039928
1037 // Fix: Create a timer and assign to PhbSearchTim
1038 data->tim = timCreate(data->win, 1000, (MfwCb)bookSearchTimCB);
1039 data->menu = mnuCreate( data->win,MmiBookMenuDetailsList() , 0, 0 );
1040 PhbSearchTim = data->tim;
1041 mnuLang (data->menu,0);
1042
1043 /* 1945 MZ Initialise the edtBuf */
1044 memset(data->edtBuf,'\0', STANDARD_EDITOR_SIZE );
1045
1046 {
1047
1048 /* SPR#1428 - SH - New Editor changes */
1049 #ifdef NEW_EDITOR
1050 /*SPR 2233, make sure editor only displays lower-case chars*/
1051 AUI_edit_SetAttr(&data->editor_attr, BOOKSEARCH_EDITOR, COLOUR_EDITOR_XX,EDITOR_FONT,
1052 ED_MODE_ALPHA | ED_MODE_FORMATTED, ED_CURSOR_BAR, ATB_DCS_ASCII, (UBYTE*) data->edtBuf, MAX_SEARCH_CHAR);
1053 data->editor_attr.FormatString = "*a";
1054 data->editor = ATB_edit_Create( &data->editor_attr, 0 );
1055 data->entry_data = AUI_entry_Create(data->win, data->editor, SEARCH_REDRAW);
1056 /*SPR2233 end*/
1057 ATB_edit_Init(data->editor);
1058 #else /* NEW_EDITOR */
1059 bookSetEditAttributes(BOOKSEARCH_EDITOR, COLOUR_EDITOR_XX, 0, edtCurBar1, 0,
1060 (char *) data->edtBuf, MAX_SEARCH_CHAR, &data->attr );
1061 data->edt = edtCreate( data->win, &data->attr, 0, 0 );
1062 #endif /* NEW_EDITOR */
1063 }
1064
1065
1066 /* allow the window and menu to be created
1067 */
1068 mnuUnhide(data->menu);
1069 winShow(data->win);
1070
1071 /* And return the handle of the newly created window
1072 */
1073 return data->win;
1074 }
1075
1076
1077
1078 /*******************************************************************************
1079
1080 Public Methods
1081
1082 *******************************************************************************/
1083
1084
1085
1086
1087 /*******************************************************************************
1088
1089 $Function: bookSearchStart
1090
1091 $Description: Starts the search window
1092
1093 $Returns: handle of newly created window, or NULL if error
1094
1095 $Arguments: parent, handle of parent window
1096
1097 *******************************************************************************/
1098
1099 T_MFW_HND bookSearchStart( MfwHnd parent )
1100 {
1101 T_MFW_HND win;
1102 T_MFW_WIN *win_data;
1103 tBookStandard *data;
1104 MfwMnu *mnu;
1105 tMmiPhbData *Current;
1106
1107 /* if the phone book is still loading, we can't do anything
1108 with it, so return a NULL, after showing an information
1109 dialog
1110 */
1111 if ( phb_get_mode() == PHB_LOADING )
1112 {
1113 bookShowInformation( idle_get_window(), TxtPleaseWait ,NULL, NULL );
1114 return NULL;
1115 }
1116
1117 /* try to create the window
1118 */
1119 if ( ( win = bookSearchCreate( parent ) ) == NULL )
1120 return NULL;
1121
1122 /* having created the window, we now need to initialise it to
1123 sensible data
1124 */
1125 win_data = ( (T_MFW_HDR *) win)->data;
1126 data = (tBookStandard *) win_data->user;
1127 Current = &data->phbk->current;
1128
1129 /* establish the status of the phone book
1130 */
1131 if ( ( Current->status.book != PHB_UPN ) && ( Current->status.book != PHB_SDN ) )
1132 Current->status.book = bookActiveBook(READ);
1133 bookGetCurrentStatus( &Current->status );
1134
1135 /* try to establish if we have information in the phone book
1136 */
1137 Current->index = 1;
1138 Current->selectedName = 0;
1139 bookFindName( MAX_SEARCH_NAME, Current );
1140
1141 if ( ! Current->index )
1142 {
1143 bookSearchDestroy( win );
1144 bookShowInformation( idle_get_window(), TxtEmptyList, NULL, NULL );
1145 return NULL;
1146 }
1147
1148 /* clear the edit buffer prior to displaying the editor and menus
1149 */
1150
1151
1152 memset( data->edtBuf, '\0', sizeof( data->edtBuf ) );
1153 /* SPR#1428 - SH - New Editor: don't need editActivate */
1154 #ifndef NEW_EDITOR
1155 editActivate( data->edt, true );
1156 #endif /* NEW_EDITOR */
1157
1158 mnu = (MfwMnu *) mfwControl( data->menu );
1159 mnu->lCursor[mnu->level] = Current->selectedName;
1160 winShow(data->win);
1161
1162 /* return the handle to the newly created window
1163 */
1164 return win;
1165 }
1166
1167
1168
1169
1170 /*******************************************************************************
1171
1172 $Function: bookSearchDestroy
1173
1174 $Description: Destroy the search window
1175
1176 $Returns: None
1177
1178 $Arguments: Window, handle of the window to be destroyed
1179
1180 *******************************************************************************/
1181
1182 void bookSearchDestroy( MfwHnd window )
1183 {
1184 T_MFW_WIN *win = ((T_MFW_HDR *) window)->data;
1185 tBookStandard *data = (tBookStandard *) win->user;
1186
1187 TRACE_FUNCTION( "bookSearchDestroy()" );
1188
1189 /* Only destroy if the data is valid
1190 */
1191 if ( data )
1192 {
1193 /* SPR#1428 - SH - New Editor changes */
1194 #ifdef NEW_EDITOR
1195 /* Editor now not automatically destroyed by winDelete,
1196 * so destroy it here. */
1197 if (data->entry_data)
1198 {
1199 AUI_entry_Destroy(data->entry_data);
1200 data->entry_data = 0;
1201 }
1202 if (data->editor)
1203 {
1204 ATB_edit_Destroy(data->editor);
1205 data->editor = 0;
1206 }
1207 #endif /* NEW_EDITOR */
1208
1209 /* If we're the root window we destroy using it's function
1210 */
1211 if ( data->phbk->root_win == window )
1212 {
1213 bookPhonebookDestroy( data->phbk->win );
1214 return;
1215 }
1216
1217 /* delete ourself
1218 */
1219 data->phbk->search_win = 0;
1220 winDelete( data->win );
1221 FREE_MEMORY( (void *) data, sizeof( tBookStandard ) );
1222 }
1223 /*SPR2123, MC deallocate memory for phonebook list*/
1224 destroy_mmi_phonebook_names_list(MmiBookMenuDetailsList());
1225 }
1226
1227
1228
1229
1230
1231
1232
1233 /*******************************************************************************
1234
1235 $Function: bookSearchName
1236
1237 $Description: locate a requested name in the phone book
1238
1239 $Returns: status of the findName routine
1240
1241 $Arguments: pattern, to be searched for
1242 number, of elements to limit the search to
1243 current, pointer to a buffer to store the results
1244
1245 *******************************************************************************/
1246
1247 UBYTE bookSearchName (char *pattern,UBYTE number,tMmiPhbData *current)
1248 {
1249 UBYTE ret;
1250 #ifdef NO_ASCIIZ
1251 T_MFW_PHB_TEXT l_name;
1252 #else
1253 UBYTE l_name[PHB_MAX_LEN];
1254 #endif
1255 // UBYTE len; // RAVI
1256 int i;
1257
1258 TRACE_FUNCTION( "bookSearchName()" );
1259
1260 /* if using UPN phone book, return status of findname
1261 */
1262 if ( current->status.book == PHB_UPN )
1263 return ret = current->result = bookFindName( MAX_SEARCH_NAME, current );
1264
1265 /* otherwise we need to be a little bit more clever with this
1266 */
1267 memset( current->entry, 0, MAX_SEARCH_CALL_LIST * sizeof( T_MFW_PHB_ENTRY ) );
1268 bookGetCurrentStatus( &current->status );
1269
1270 current->list.entry = current->entry;
1271 current->list.num_entries = number;
1272
1273 /* convert from GSM characters
1274 */
1275 #ifdef NO_ASCIIZ
1276
1277 memset( l_name.data, 0, PHB_MAX_LEN );
1278 mfw_Gsm2SIMStr( MFW_DCS_7bits, (UBYTE *) pattern, PHB_MAX_LEN, l_name.data, &l_name.len );
1279 #else
1280 memset( l_name, 0, PHB_MAX_LEN );
1281 mfw_Gsm2SIMStr( MFW_DCS_7bits, (UBYTE *) pattern, PHB_MAX_LEN, l_name, &len );
1282 #endif
1283 /* perform a search to locate a match with this criteria
1284 */
1285 if ( strlen(pattern) != 0 )
1286 {
1287 #ifdef WIN32
1288 #ifndef NO_ASCIIZ
1289 /***************************Go-lite Optimization changes Start***********************/
1290 //Aug 16, 2004 REF: CRR 24323 Deepa M.D
1291 TRACE_EVENT_P1("Search str: %s", l_name.data);
1292 /***************************Go-lite Optimization changes end***********************/
1293 ret = phb_find_entries( current->status.book, &current->index, MFW_PHB_ALPHA, number, (UBYTE *) l_name, len, &current->list );
1294 #endif
1295 #else
1296 //not WIN32
1297
1298 #ifdef NO_ASCIIZ
1299 ret = phb_find_entries( current->status.book, &current->index, MFW_PHB_ALPHA, number, &l_name, &current->list );
1300 #else
1301 ret = phb_find_entries( current->status.book, &current->index, MFW_PHB_ALPHA, number, (char *) l_name, &current->list );
1302 #endif //NO_ASCIIZ
1303
1304 #endif //WIN32
1305 }
1306 else
1307 {
1308 /* we don't have any name information, so start at the beginning
1309 */
1310 current->index = 1;
1311 current->selectedName = 0;
1312 bookFindName( MAX_SEARCH_NAME, current );
1313 }
1314
1315 /* check for match
1316 */
1317 if ( ( current->list.num_entries < MAX_SEARCH_NAME )
1318 || ( current->list.result == MFW_NO_ENTRY ) || ( ret == PHB_FAIL ) )
1319 {
1320 /* no, then try to find again
1321 */
1322 ret = bookFindName( MAX_SEARCH_NAME, current );
1323 }
1324 else
1325 {
1326 for ( i = 0; i < number; i++ )
1327 #ifdef NO_ASCIIZ
1328 {
1329 /* convert from Sim to GSM and then copy to output buffer
1330 */
1331 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
1332 /*MC SPR 2175, using new function to convert name string*/
1333 if (current->entry[i].name.dcs == MFW_DCS_8bits && current->entry[i].name.data[0] != 0x80)
1334 { ATB_convert_String((char*)current->entry[i].name.data, MFW_DCS_8bits, current->entry[i].name.len, (char*)l_name.data, MFW_ASCII, MAX_ALPHA_LEN, FALSE);
1335 memcpy( current->entry[i].name.data, l_name.data, MAX_ALPHA_LEN );
1336 current->entry[i].name.len = l_name.len;
1337 current->entry[i].name.dcs = MFW_ASCII;
1338 }
1339 }
1340 #else
1341 /* convert from GSM to Alpha characters
1342 */
1343 bookGsm2Alpha( (UBYTE *) current->entry[i].name );
1344 #endif
1345 }
1346
1347 /* return the status, and store it as part of current as well
1348 */
1349 TRACE_EVENT_P1("BookSearchName returns: %d", ret);
1350 return current->result = ret;
1351 }
1352
1353
1354
1355 /*******************************************************************************
1356
1357 End of File
1358
1359 *******************************************************************************/
1360