comparison src/aci2/bmi/mmiBookSDNWindow.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/MmiBookSDNWindow.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: MmiBookSDNWindow.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 service numbers window for the phone book
26
27 ********************************************************************************
28 $History: MmiBookSDNWindow.c
29
30 CRR: 25302 - xpradipg 10 Nov 2004
31 Description: Should be able to select the number fro the phonebook while
32 sending MMS/EMS.
33 Solution: The new feature to select the number from phonebook while sending
34 MMS/EMS is added
35 25/10/00 Original Condat(UK) BMI version.
36
37 $End
38
39 *******************************************************************************/
40
41
42
43
44 /*******************************************************************************
45
46 Include Files
47
48 *******************************************************************************/
49 #define ENTITY_MFW
50
51 /* includes */
52 #include <string.h>
53 #include <stdio.h>
54 #include <stdlib.h>
55
56 #if defined (NEW_FRAME)
57
58 #include "typedefs.h"
59 #include "vsi.h"
60 #include "pei.h"
61 #include "custom.h"
62 #include "gsm.h"
63
64 #else
65
66 #include "STDDEFS.H"
67 #include "custom.h"
68 #include "gsm.h"
69 #include "vsi.h"
70
71 #endif
72
73 #include "mfw_sys.h"
74
75 #include "mfw_mfw.h"
76 #include "mfw_win.h"
77 #include "mfw_kbd.h"
78 #include "mfw_lng.h"
79 /* SPR#1428 - SH - New Editor changes */
80 #ifndef NEW_EDITOR
81 #include "mfw_edt.h"
82 #endif
83 #include "mfw_icn.h"
84 #include "mfw_mnu.h"
85 #include "mfw_tim.h"
86
87 #include "mfw_sim.h"
88 #include "mfw_cm.h"
89 #include "mfw_nm.h"
90 #include "mfw_phb.h"
91 #include "mfw_mme.h"
92 #include "mfw_sat.h"
93 #include "mfw_sms.h"
94 #include "mfw_cnvt.h" //GW Added for 'mfw_SIM2GsmStr'
95
96 #include "dspl.h"
97
98 #include "ksd.h"
99 #include "psa.h"
100
101 #include "MmiMain.h"
102 #include "MmiBookController.h"
103 #include "MmiDummy.h"
104 #include "MmiDialogs.h"
105 #include "MmiLists.h"
106
107
108
109 #include "MmiMenu.h"
110 #include "mmiCall.h"
111 #include "Mmiicons.h"
112 #include "MmiIdle.h"
113
114 #include "MmiSoftKeys.h"
115 #include "MmiSounds.h"
116 #include "MmiIdle.h"
117 #include "MmiNetwork.h"
118 #include "mmiSat_i.h"
119 #include "MmiAoc.h"
120
121 #include "gdi.h"
122 #include "audio.h"
123
124 #include "cus_aci.h"
125 #include "mfw_ffs.h"
126 #include "MmiTimers.h"
127
128 #include "MmiBookShared.h"
129
130 #include "mmiColours.h"
131
132
133
134
135 /*******************************************************************************
136
137 Private methods
138
139 *******************************************************************************/
140
141 /*******************************************************************************
142
143 $Function: bookSDN
144
145 $Description: window dialog function
146
147 $Returns: none.
148
149 $Arguments: win, window handle
150 event, event to be handled
151 value, not used
152 parameter, not used
153
154 *******************************************************************************/
155
156 static void bookSDN( T_MFW_HND win, USHORT event, SHORT value, void * parameter )
157 {
158 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
159 tBookStandard *data = (tBookStandard *)win_data->user;
160 MfwMnu *mnu;
161 tMmiPhbData *my;
162
163 TRACE_FUNCTION ("bookSDN()");
164
165 /* Guard against bad incoming data
166 */
167 if ( ! data )
168 return;
169
170 /* Grab the current phonebook data element, we use this a lot
171 */
172 my = &data->phbk->current;
173
174 /* simple event handler, dealing with the messages we know about
175 */
176 switch (event)
177 {
178 case SEARCH_INIT:
179 {
180 /* Search initialise, no action required
181 */
182 }
183 break;
184
185 case SEARCH_SCROLL_UP:
186 {
187 /* Scroll up event we need to deal with correctly
188 */
189 if ( ( my->index==1 ) && ( my->selectedName == 0 ) )
190 {
191 /* select the correct boundary for the list
192 */
193 my->selectedName = my->status.used_entries;
194 if ( my->selectedName > MAX_SEARCH_NAME )
195 my->selectedName = MAX_SEARCH_NAME;
196
197 /* and subtract one cos we are dealing with an array starting
198 at zero
199 */
200 my->selectedName--;
201
202 /* and calculate the correct index value
203 */
204 my->index = my->status.used_entries - my->selectedName;
205
206 }
207 else
208 {
209 if ( my->selectedName == 0 )
210 my->index--;
211 else
212 my->selectedName--;
213 }
214
215 /* update menu structures
216 */
217 mnu = (MfwMnu *)mfwControl( data->menu );
218 mnu->lCursor[ mnu->level ] = my->selectedName;
219
220 /* and go find the name
221 */
222 bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
223 }
224 break;
225
226 case SEARCH_SCROLL_DOWN:
227 {
228 /* scroll down event is a bit easier than the scroll up
229 */
230 if ( (my->index + my->selectedName) == my->status.used_entries )
231 {
232 my->index = 1;
233 my->selectedName = 0;
234 }
235 else
236 {
237 if ( my->selectedName == (MAX_SEARCH_NAME - 1) )
238 my->index++;
239 else
240 my->selectedName++;
241 }
242
243 /* update menu structures
244 */
245 mnu = (MfwMnu *)mfwControl( data->menu );
246 mnu->lCursor[ mnu->level ] = my->selectedName;
247
248 /* and go find the name
249 */
250 bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
251 }
252 break;
253
254 case SEARCH_STRING:
255 {
256 /* search for the current element selected in our buffer
257 */
258 my->index = my->index + my->selectedName;
259
260 if ( bookSearchName( data->edtBuf, MAX_SEARCH_NAME, &data->phbk->current ) == MFW_PHB_OK )
261 {
262 if ( my->index > (my->status.used_entries - MAX_SEARCH_NAME + 1) )
263 {
264 /* need to reorganise a bit here
265 */
266 if ( my->status.used_entries > MAX_SEARCH_NAME )
267 {
268 my->selectedName = my->index - my->status.used_entries;
269 my->selectedName += MAX_SEARCH_NAME - 1;
270 my->index -= my->selectedName;
271 }
272 else
273 {
274 my->selectedName = my->index - 1;
275 my->index = 1;
276 }
277
278 /* find the appropriate name
279 */
280 bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
281 }
282 else
283 data->phbk->current.selectedName = 0;
284
285 /* update menu structures
286 */
287 mnu = (MfwMnu *)mfwControl(data->menu);
288 mnu->lCursor[mnu->level] = data->phbk->current.selectedName;
289 }
290 }
291 break;
292
293 case SEARCH_UPDATE:
294 {
295 /* Update search message
296 */
297 my->index = 1;
298 my->selectedName = 0;
299 memset( data->edtBuf, '\0', sizeof( data->edtBuf ) );
300 /* SPR#1428 - SH - New Editor changes */
301 #ifdef NEW_EDITOR
302 ATB_edit_Reset( data->editor );
303 #else /* NEW_EDITOR */
304 edtReset( data->edt );
305 #endif /* NEW_EDITOR */
306
307 /* deal with the new search using the method above
308 */
309 SEND_EVENT( win, SEARCH_STRING, 0, 0 );
310 }
311 break;
312
313 /* SPR#1428 - SH - New Editor: added event so we can
314 * prompt a redraw when required. */
315 #ifdef NEW_EDITOR
316 case SEARCH_REDRAW:
317 win_show(data->win);
318 break;
319 #endif
320
321 default:
322 {
323 /* no default handler, just ignore any other messages
324 */
325 }
326 break;
327
328 }
329
330 }
331
332
333
334
335 /*******************************************************************************
336
337 $Function: bookSDNWinCB
338
339 $Description: Window call back function
340
341 $Returns: status indicating if event handled or not
342
343 $Arguments: e, event, w, window handle
344
345 *******************************************************************************/
346
347 static int bookSDNWinCB( MfwEvt e, MfwWin *w )
348 {
349 tBookStandard *data = (tBookStandard *)w->user;
350
351 char *ElemPtr, *NumPtr;
352 int leftKey, rightKey, ElemSize, i, Position;
353
354 TRACE_FUNCTION ("phbk_sdn_win_cb()");
355
356 switch (e)
357 {
358 case MfwWinVisible:
359 {
360 /* Paint function, clear the screen and paint in each
361 of our controls
362 */
363 dspl_ClearAll();
364
365 /* SPR#1428 - SH - New Editor changes */
366 #ifdef NEW_EDITOR
367 ATB_edit_Show(data->editor);
368 #else /* NEW_EDITOR */
369 edtShow(data->edt);
370 #endif /* NEW_EDITOR */
371
372 /* Populate the names screen buffer
373 */
374 for (i=0;i<MAX_SEARCH_NAME;i++)
375 {
376 /* Grab info for this element
377 */
378 ElemPtr = MmiBookCallList(i);
379 ElemSize = MmiBookCallListSize(i);
380
381 /* Decide on whether to use number or name
382 */
383 #ifdef NO_ASCIIZ
384 NumPtr = (char*)data->phbk->current.entry[i].name.data;
385 #else
386 NumPtr = (char*)data->phbk->current.entry[i].name;
387 #endif
388
389 if ( *NumPtr == '\0' )
390 {
391 NumPtr = (char*)data->phbk->current.entry[i].number;
392 Position = POS_END;
393 }
394 else
395 Position = POS_BEGIN;
396
397 /* Clear the buffer, then fill it with the required value
398 */
399 memset( ElemPtr, '\0', ElemSize );
400 /*mc, SPR 1442, replaced old truncation function with new one*/
401 resources_truncate_to_screen_width(NumPtr, 0, ElemPtr, ElemSize,SCREEN_SIZE_X, FALSE);
402 }
403
404 /* Show the menu and stick up the find prompt
405 */
406 mnuUnhide(data->menu);
407 PROMPT( MmiBookMenuArea().px, Mmi_layout_line(SECOND_LAST_LINE_TOP), 0, TxtFind );
408
409 /* The softkeys are dependant on how we got here
410 */
411 //CRR: 25302 - xpradipg 10 Nov 2004
412 //check also if phonebook is invoked by MMS/EMS
413 if ( ( data->phbk->fromSMS ) || ( data->phbk->fromSMSSC )|| (data->phbk->fromMmsEms) ||( data->phbk->current.status.book == PHB_SDN ) )
414 {
415 leftKey = TxtSoftSelect;
416 rightKey = TxtSoftBack;
417 }
418 else
419 {
420 leftKey = TxtSoftCall;
421 rightKey = TxtSoftOptions;
422 }
423 displaySoftKeys( leftKey, rightKey );
424 }
425 break;
426
427 default:
428 {
429 /* Default handler, just return zero and let the next handler in the
430 chain deal with the event if required
431 */
432 return 0;
433 }
434 }
435
436 /* return non-zero status indicating we have dealt with the event
437 */
438 return MFW_EVENT_CONSUMED;
439 }
440
441
442
443
444 /*******************************************************************************
445
446 $Function: bookSDNKbdCB
447
448 $Description: Keyboard handler
449
450 $Returns: stats indicating if event handled or not
451 (Always MFW_EVENT_CONSUMED)
452
453 $Arguments: e, event, k, keyboard handle
454
455 *******************************************************************************/
456
457 static int bookSDNKbdCB( MfwEvt e, MfwKbd *k )
458 {
459 T_MFW_HND win = mfwParent(mfw_header());
460 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
461 tBookStandard *data = (tBookStandard *)win_data->user;
462 tBookMessageEvents MyEvent = SEARCH_STRING;
463 char *Number;
464
465 // int i = 0; // RAVI
466
467 TRACE_FUNCTION ("bookSDNKbdCB()");
468
469 /* SPR#1428 - SH - New Editor changes */
470 #ifdef NEW_EDITOR
471 AUI_entry_EventKey(data->entry_data, e, k);
472 #else /* NEW_EDITOR */
473 /* Make sure we have the correct editor enabled
474 * (unnecessary for NEW_EDITOR) */
475 if ( activeEditor() != data->edt )
476 editActivate( data->edt, TRUE );
477 editEventKey( e, k );
478 #endif /* NEW_EDITOR */
479
480 /* Handle the events we need to deal with here
481 */
482 switch (k->code)
483 {
484 case KCD_MNUUP:
485 {
486 /* Scroll up event, just mark our event as such and it'll
487 be dealt with in due course
488 */
489 MyEvent = SEARCH_SCROLL_UP;
490 }
491 break;
492
493 case KCD_MNUDOWN:
494 {
495 /* Scroll down event, just mark our event as such and it'll
496 be dealt with in due course
497 */
498 MyEvent = SEARCH_SCROLL_DOWN;
499 }
500 break;
501
502 case KCD_CALL:
503 case KCD_LEFT:
504 {
505 /* left key is a select, we either need to send the number
506 back to the parent window, or call it
507 */
508 Number = (char *) data->phbk->current.entry[ data->phbk->current.selectedName ].number;
509
510 if ( data->phbk->fromSMS )
511 SEND_EVENT( data->phbk->parent_win, SMS_PHBK_NUMBER, 0, (UBYTE *) Number );
512 if ( data->phbk->fromSMSSC )
513 SEND_EVENT( data->phbk->parent_win, SMSSC_PHBK_NUMBER, 0, (UBYTE *) Number );
514 else if(data->phbk->fromDivert )
515 SEND_EVENT( data->phbk->parent_win, DIVERT_PHBK_NUMBER, 0, (UBYTE *) Number );
516 else if(data->phbk->fromDeflect )/*SPR 1392, send event to call dialogue*/
517 SEND_EVENT( data->phbk->parent_win, DEFLECT_PHBK_NUMBER, 0, (UBYTE *) Number );
518 //CRR: 25302 - xpradipg 10 Nov 2004
519 //send even if invoked by MMS/EMS
520 else if(data->phbk->fromMmsEms)
521 SEND_EVENT( data->phbk->parent_win, MMS_EMS_PHBK_NUMBER, 0, (UBYTE *) Number );
522 else
523 callNumber( (UBYTE *) Number );
524
525 /* Having dealt with the number, we destroy our phone book
526 context and exit the handler early
527 */
528 bookPhonebookDestroy( data->phbk->win );
529 return MFW_EVENT_CONSUMED;
530 }
531 //break; // RAVI
532
533 case KCD_RIGHT:
534 {
535 /* Right key is a cancel
536 */
537 bookSDNDestroy( data->win );
538 data->phbk->search_win = 0;
539 return MFW_EVENT_CONSUMED;
540 }
541 // break; // RAVI
542
543 case KCD_HUP:
544 {
545 /* Clear key deletes the last character, or if none left will
546 take us out of here
547 */
548 if ( data->edtBuf[0] == '\0' )
549 {
550 bookSDNDestroy( data->win );
551 data->phbk->search_win = 0;
552 return MFW_EVENT_CONSUMED;
553 }
554 else
555 {
556 /* Delete last character entered
557 */
558 /* SPR#1428 - SH - New Editor changes */
559 #ifdef NEW_EDITOR
560 ATB_edit_DeleteLeft(data->editor, TRUE); /* SPR#2342 */
561 #else /* NEW_EDITOR */
562 edtChar( data->edt, ecBack );
563 #endif /* NEW_EDITOR */
564 }
565 }
566 break;
567
568 default:
569 {
570 /* No default processing required
571 */
572 }
573 break;
574 }
575
576 /* Initiate a new search based on the current settings, MyEvent
577 will have been set accordingly
578 */
579 SEND_EVENT( data->win, MyEvent, 0, 0 );
580 winShow( data->win );
581
582 /* And make sure no calling routines try to do anything with the
583 event we have just dealt with
584 */
585 return MFW_EVENT_CONSUMED;
586 }
587
588
589
590
591 /*******************************************************************************
592
593 $Function: bookSDNKeyLongCB
594
595 $Description: long keyboard event handler
596
597 $Returns: MFW_EVENT_CONSUMED always
598
599 $Arguments: e, event to handle, k, keyboard handle
600
601 *******************************************************************************/
602
603 static int bookSDNKeyLongCB( MfwEvt e, MfwKbd *k )
604 {
605 T_MFW_HND win = mfwParent(mfw_header());
606 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
607 tBookStandard *data = (tBookStandard *)win_data->user;
608
609 /* Just checks for clear and long being set, if so it will
610 destroy the window
611 */
612 if ( (e & KEY_CLEAR) && (e & KEY_LONG) )
613 {
614 bookSDNDestroy( win );
615 data->phbk->search_win = 0;
616 }
617
618 /* Force event consumed always, prevents default behaviour
619 kicking in
620 */
621 return MFW_EVENT_CONSUMED;
622 }
623
624
625
626
627 /*******************************************************************************
628
629 $Function: bookSDNCreate
630
631 $Description: Creates the Service numbers widow
632
633 $Returns: Window Handle, or NULL if unsuccessfull
634
635 $Arguments: Parent, handle of the parent window
636
637 *******************************************************************************/
638
639 static T_MFW_HND bookSDNCreate( MfwHnd parent )
640 {
641 T_MFW_WIN *win_data;
642 tBookStandard *data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) );
643 T_MFW_WIN *parent_win_data = ((T_MFW_HDR *)parent)->data;
644 T_phbk* phbk = (T_phbk *)parent_win_data->user;
645
646 TRACE_FUNCTION( "bookSDNCreate()" );
647
648 /* Create the window
649 */
650 if ( ( data->win = win_create (parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookSDNWinCB ) ) == NULL )
651 return NULL;
652
653 /*SPR 2123, MC allocate memory for phonebook list*/
654 if (create_mmi_phonebook_names_list() == NULL)
655 return NULL;
656
657 /* set up the basic window elements, dialog and user data pointers
658 */
659 data->mmi_control.dialog = (T_DIALOG_FUNC)bookSDN;
660 data->mmi_control.data = data;
661 win_data = ((T_MFW_HDR *)data->win)->data;
662 win_data->user = (void *)data;
663 data->parent_win = parent;
664
665 /* Create keyboard and menu handlers to be associated with
666 this window
667 */
668 data->kbd = kbdCreate( data->win, KEY_ALL, (MfwCb) bookSDNKbdCB );
669 data->kbd_long = kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookSDNKeyLongCB );
670 data->menu = mnuCreate( data->win, MmiBookMenuDetailsList(), 0, 0 );
671
672 /* Set basic edit attributes structure and create an editor
673 associated with these attributes
674 */
675 /* SPR#1428 - SH - New Editor changes */
676 #ifdef NEW_EDITOR
677 AUI_edit_SetAttr( &data->editor_attr, BOOKSDN_EDITOR, COLOUR_EDITOR_XX, EDITOR_FONT, ED_MODE_ALPHA, ED_CURSOR_BAR, ATB_DCS_ASCII, (UBYTE*) data->edtBuf, MAX_SEARCH_CHAR);
678 data->editor = ATB_edit_Create(&data->editor_attr,0);
679 data->entry_data = AUI_entry_Create(data->win, data->editor, SEARCH_REDRAW);
680 ATB_edit_Init(data->editor);
681 #else /* NEW_EDITOR */
682 bookSetEditAttributes( BOOKSDN_EDITOR, COLOUR_EDITOR_XX , 0, edtCurBar1, 0, (char*) data->edtBuf, MAX_SEARCH_CHAR, &data->attr );
683 data->edt = edtCreate( data->win, &data->attr, 0, 0 );
684 #endif /* NEW_EDITOR */
685
686 /* Show the menu
687 */
688 mnuUnhide(data->menu);
689
690 /* associate the phonebook handler
691 */
692 data->phbk = phbk;
693
694 /* and return the newly created window handle
695 */
696 return data->win;
697 }
698
699
700
701
702
703 /*******************************************************************************
704
705 Public methods
706
707 *******************************************************************************/
708
709 /*******************************************************************************
710
711 $Function: bookSDNStart
712
713 $Description: This is the entry point for the service numbers window handler
714
715 $Returns: handle of window we are creating
716
717 $Arguments: Parent, handle of the parent window
718
719 *******************************************************************************/
720
721 T_MFW_HND bookSDNStart( MfwHnd parent )
722 {
723 T_MFW_HND win;
724 T_MFW_WIN *win_data;
725 tBookStandard *data;
726 MfwMnu *mnu;
727
728 TRACE_FUNCTION( "bookSDNCreate()" );
729
730 /* We can't actually create the window if the phone book is
731 still loading, so we will deal with this up front
732 */
733 if ( phb_get_mode() == PHB_LOADING )
734 {
735 bookShowInformation( idle_get_window(), TxtPleaseWait ,NULL, NULL );
736 return NULL;
737 }
738
739 /* Create the basic window, dealing with errors here and just terminating
740 if we can't create the window correctly.
741 */
742 if ( ( win = bookSDNCreate( parent ) ) == NULL )
743 return NULL;
744
745 /* Okay, we have created the window, so set up our internal
746 working pointers and check if the current phone book has
747 some entries in it
748 */
749 win_data = ((T_MFW_HDR *) win)->data;
750 data = (tBookStandard *)win_data->user;
751 data->phbk->current.status.book = PHB_SDN;
752
753 /* we need to determine if there are any entries in the phone book
754 before we allow the service number windows to be displayed, we
755 do this by searching for an empty name
756 */
757 bookGetCurrentStatus( &data->phbk->current.status );
758 memset( data->edtBuf, '\0' , sizeof( data->edtBuf ) );
759 data->phbk->current.index = 1;
760 data->phbk->current.selectedName = 0;
761 bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
762
763 /* If the current index is still zero then we have been unable to
764 find an entry, in this case we need to shutdown the service
765 numbers window, since we can't do anything with it.
766 */
767 if ( data->phbk->current.index == 0 )
768 {
769 bookSDNDestroy( win );
770 data->phbk->search_win = 0;
771 bookShowInformation( idle_get_window(), TxtEmptyList ,NULL, NULL );
772 return 0;
773 }
774
775 /* We are still running, so set up the menu and edit structures
776 accordingly, and display the window
777 */
778 mnu = (MfwMnu *) mfwControl( data->menu );
779 mnu->lCursor[ mnu->level ] = data->phbk->current.selectedName;
780
781 /* SPR#1428 - SH - New Editor: editActivate no longer needed */
782 #ifndef NEW_EDITOR
783 editActivate( data->edt, 1 );
784 #endif
785 winShow( data->win );
786
787 /* return the pointer to the window
788 */
789 return win;
790 }
791
792
793
794 /*******************************************************************************
795
796 $Function: bookFindNameInSDNPhonebook
797
798 $Description: This routine performs the FindNameInPhoneBook functionality,
799 tuned to the particular requirements of the service numbers
800 phonebook.
801
802 $Returns: handle of window we are creating
803
804 $Arguments: Parent, handle of the parent window
805
806 *******************************************************************************/
807
808 int bookFindNameInSDNPhonebook( const char* p_pszNumber, T_MFW_PHB_ENTRY* p_pEntry )
809 {
810 T_MFW_PHB_LIST phb_list;
811 #ifdef NO_ASCIIZ
812 T_MFW_PHB_TEXT p_pszNumberText;
813 #endif
814 SHORT phb_index=0;
815 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
816 UBYTE l_name[MAX_ALPHA_LEN];
817 int status;
818 char bfr[80];
819 TRACE_FUNCTION("bookFindNameInSDNPhonebook()");
820
821 /* guard against dodgy input data
822 */
823 if( ( p_pszNumber == NULL ) || ( p_pEntry == NULL ) )
824 return 0;
825 if ( strlen(p_pszNumber) < 1)
826 return (0);
827 /* initialise the search structures
828 */
829 memset(p_pEntry, 0, sizeof(T_MFW_PHB_ENTRY));
830 memset(&phb_list, 0, sizeof(phb_list));
831 phb_list.entry = p_pEntry;
832 phb_list.num_entries = 1;
833 phb_list.book = PHB_SDN;
834
835 //GW Set up data structure for NO_ASCIIZ
836 #ifdef NO_ASCIIZ
837 p_pszNumberText.dcs = MFW_DCS_8bits;
838 p_pszNumberText.len = strlen(p_pszNumber);
839 strcpy((char*)p_pszNumberText.data, p_pszNumber);
840 #endif
841
842 /* see what we can find using the standard search routine for
843 any phone book, giving the service numbers book as a parameter
844 */
845
846 #ifdef NO_ASCIIZ
847 status = phb_find_entries( (UBYTE)PHB_SDN, &phb_index, (UBYTE)MFW_PHB_NUMBER, 1, &p_pszNumberText, &phb_list );
848 #else
849 status = phb_find_entries( PHB_SDN, &phb_index, MFW_PHB_NUMBER, 1, (char *) p_pszNumber, &phb_list );
850 #endif
851 sprintf(bfr,"len:%2d , name: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",p_pEntry->name.len);
852 memcpy(&bfr[16], p_pEntry->name.data, PHB_MAX_LEN);
853 TRACE_FUNCTION(bfr);
854 sprintf(bfr,"number:'%s'",p_pEntry->number);
855 TRACE_FUNCTION(bfr);
856
857 if (status != MFW_PHB_OK)
858 {
859 phb_list.result = MFW_NO_ENTRY;
860 TRACE_FUNCTION("bookFindNameInSDNPhonebook()- status error");
861 }
862
863 /* convert the returned data to manageable information
864 */
865
866 #ifdef NO_ASCIIZ
867 //GW Check that conversion returned a valid string
868 //GW Testing for 0 is stupid but since the macros PASSED and FAILED that are used by the procedure are not in the header (duh!) we can't use them.
869 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
870 if (mfw_SIM2GsmStr( p_pEntry->name.len, p_pEntry->name.data, MAX_ALPHA_LEN, l_name ) == 0)
871 memcpy(p_pEntry->name.data, l_name, MAX_ALPHA_LEN);
872
873 p_pEntry->name.data[0] = 0x00;
874
875 #else
876 bookGsm2Alpha( p_pEntry->name );
877
878 #endif
879
880 /* if we couldn't find any information, null out the return
881 structure, this will stop people who don't check the return
882 status from getting sensible information
883 */
884 if( phb_list.result != MFW_ENTRY_EXIST )
885 memset(p_pEntry, 0, sizeof(T_MFW_PHB_ENTRY));
886
887 /* return status depends on result of search
888 */
889 return ( phb_list.result == MFW_ENTRY_EXIST );
890 }
891
892
893
894
895
896
897 /*******************************************************************************
898
899 $Function: bookSDNDestroy
900
901 $Description: destroys the Service Numbers window
902
903 $Returns: none.
904
905 $Arguments: window, handle of the window to be destroyed
906
907 *******************************************************************************/
908
909 void bookSDNDestroy( MfwHnd window )
910 {
911 T_MFW_WIN *win = ((T_MFW_HDR *)window)->data;
912 tBookStandard *data = (tBookStandard *)win->user;
913
914 TRACE_FUNCTION( "bookSDNDestroy" );
915
916 /* Guard against bad incoming data
917 */
918 if ( ! data )
919 return;
920
921 /* SPR#1428 - SH - New Editor changes */
922 #ifdef NEW_EDITOR
923 /* Editor is no longer destroyed with winDelete,
924 * so destroy it here. */
925 if (data->editor)
926 {
927 ATB_edit_Destroy(data->editor);
928 data->editor = 0;
929 }
930 if (data->entry_data)
931 {
932 AUI_entry_Destroy(data->entry_data);
933 data->entry_data = 0;
934 }
935 #endif /* NEW_EDITOR */
936
937 /* Destroy the window using the appropriate method
938 */
939 if ( data->phbk->root_win == window )
940 bookPhonebookDestroy( data->phbk->win );
941 else
942 {
943 /* deleting the window, so make sure we free the memory
944 */
945 data->phbk->search_win = 0;
946 winDelete( data->win );
947 FREE_MEMORY( (void *)data, sizeof( tBookStandard ) );
948 }
949 /*SPR2123, MC deallocate memory for phonebook list*/
950 destroy_mmi_phonebook_names_list(MmiBookMenuDetailsList());
951 }
952
953
954 /*******************************************************************************
955
956 End of File
957
958 *******************************************************************************/
959