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

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children c0052fe355d3
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
1 /*******************************************************************************
2
3 CONDAT (UK)
4
5 ********************************************************************************
6
7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name: Basic MMI
13 $Project code: BMI (6349)
14 $Module: PhoneBook
15 $File: 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
353 /* x0045876, 14-Aug-2006 (WR - "Position" was set but never used) */
354 /* int leftKey, rightKey, ElemSize, i, Position; */
355 int leftKey, rightKey, ElemSize, i;
356
357 TRACE_FUNCTION ("phbk_sdn_win_cb()");
358
359 switch (e)
360 {
361 case MfwWinVisible:
362 {
363 /* Paint function, clear the screen and paint in each
364 of our controls
365 */
366 dspl_ClearAll();
367
368 /* SPR#1428 - SH - New Editor changes */
369 #ifdef NEW_EDITOR
370 ATB_edit_Show(data->editor);
371 #else /* NEW_EDITOR */
372 edtShow(data->edt);
373 #endif /* NEW_EDITOR */
374
375 /* Populate the names screen buffer
376 */
377 for (i=0;i<MAX_SEARCH_NAME;i++)
378 {
379 /* Grab info for this element
380 */
381 ElemPtr = MmiBookCallList(i);
382 ElemSize = MmiBookCallListSize(i);
383
384 /* Decide on whether to use number or name
385 */
386 #ifdef NO_ASCIIZ
387 NumPtr = (char*)data->phbk->current.entry[i].name.data;
388 #else
389 NumPtr = (char*)data->phbk->current.entry[i].name;
390 #endif
391
392 if ( *NumPtr == '\0' )
393 {
394 NumPtr = (char*)data->phbk->current.entry[i].number;
395 /* x0045876, 14-Aug-2006 (WR - "Position" was set but never used) */
396 /* Position = POS_END; */
397 }
398 /* BEGIN: x0045876, 14-Aug-2006 (WR - "Position" was set but never used) */
399 /*
400 else
401 Position = POS_BEGIN;
402 */
403 /* END: x0045876, 14-Aug-2006 (WR - "Position" was set but never used) */
404
405 /* Clear the buffer, then fill it with the required value
406 */
407 memset( ElemPtr, '\0', ElemSize );
408 /*mc, SPR 1442, replaced old truncation function with new one*/
409 resources_truncate_to_screen_width(NumPtr, 0, ElemPtr, ElemSize,SCREEN_SIZE_X, FALSE);
410 }
411
412 /* Show the menu and stick up the find prompt
413 */
414 mnuUnhide(data->menu);
415 PROMPT( MmiBookMenuArea().px, Mmi_layout_line(SECOND_LAST_LINE_TOP), 0, TxtFind );
416
417 /* The softkeys are dependant on how we got here
418 */
419 //CRR: 25302 - xpradipg 10 Nov 2004
420 //check also if phonebook is invoked by MMS/EMS
421 if ( ( data->phbk->fromSMS ) || ( data->phbk->fromSMSSC )|| (data->phbk->fromMmsEms) ||( data->phbk->current.status.book == PHB_SDN ) )
422 {
423 leftKey = TxtSoftSelect;
424 rightKey = TxtSoftBack;
425 }
426 else
427 {
428 leftKey = TxtSoftCall;
429 rightKey = TxtSoftOptions;
430 }
431 displaySoftKeys( leftKey, rightKey );
432 }
433 break;
434
435 default:
436 {
437 /* Default handler, just return zero and let the next handler in the
438 chain deal with the event if required
439 */
440 return 0;
441 }
442 }
443
444 /* return non-zero status indicating we have dealt with the event
445 */
446 return MFW_EVENT_CONSUMED;
447 }
448
449
450
451
452 /*******************************************************************************
453
454 $Function: bookSDNKbdCB
455
456 $Description: Keyboard handler
457
458 $Returns: stats indicating if event handled or not
459 (Always MFW_EVENT_CONSUMED)
460
461 $Arguments: e, event, k, keyboard handle
462
463 *******************************************************************************/
464
465 static int bookSDNKbdCB( MfwEvt e, MfwKbd *k )
466 {
467 T_MFW_HND win = mfwParent(mfw_header());
468 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
469 tBookStandard *data = (tBookStandard *)win_data->user;
470 tBookMessageEvents MyEvent = SEARCH_STRING;
471 char *Number;
472
473 // int i = 0; // RAVI
474
475 TRACE_FUNCTION ("bookSDNKbdCB()");
476
477 /* SPR#1428 - SH - New Editor changes */
478 #ifdef NEW_EDITOR
479 AUI_entry_EventKey(data->entry_data, e, k);
480 #else /* NEW_EDITOR */
481 /* Make sure we have the correct editor enabled
482 * (unnecessary for NEW_EDITOR) */
483 if ( activeEditor() != data->edt )
484 editActivate( data->edt, TRUE );
485 editEventKey( e, k );
486 #endif /* NEW_EDITOR */
487
488 /* Handle the events we need to deal with here
489 */
490 switch (k->code)
491 {
492 case KCD_MNUUP:
493 {
494 /* Scroll up event, just mark our event as such and it'll
495 be dealt with in due course
496 */
497 MyEvent = SEARCH_SCROLL_UP;
498 }
499 break;
500
501 case KCD_MNUDOWN:
502 {
503 /* Scroll down event, just mark our event as such and it'll
504 be dealt with in due course
505 */
506 MyEvent = SEARCH_SCROLL_DOWN;
507 }
508 break;
509
510 case KCD_CALL:
511 case KCD_LEFT:
512 {
513 /* left key is a select, we either need to send the number
514 back to the parent window, or call it
515 */
516 Number = (char *) data->phbk->current.entry[ data->phbk->current.selectedName ].number;
517
518 if ( data->phbk->fromSMS )
519 SEND_EVENT( data->phbk->parent_win, SMS_PHBK_NUMBER, 0, (UBYTE *) Number );
520 if ( data->phbk->fromSMSSC )
521 SEND_EVENT( data->phbk->parent_win, SMSSC_PHBK_NUMBER, 0, (UBYTE *) Number );
522 else if(data->phbk->fromDivert )
523 SEND_EVENT( data->phbk->parent_win, DIVERT_PHBK_NUMBER, 0, (UBYTE *) Number );
524 else if(data->phbk->fromDeflect )/*SPR 1392, send event to call dialogue*/
525 SEND_EVENT( data->phbk->parent_win, DEFLECT_PHBK_NUMBER, 0, (UBYTE *) Number );
526 //CRR: 25302 - xpradipg 10 Nov 2004
527 //send even if invoked by MMS/EMS
528 else if(data->phbk->fromMmsEms)
529 SEND_EVENT( data->phbk->parent_win, MMS_EMS_PHBK_NUMBER, 0, (UBYTE *) Number );
530 else
531 callNumber( (UBYTE *) Number );
532
533 /* Having dealt with the number, we destroy our phone book
534 context and exit the handler early
535 */
536 bookPhonebookDestroy( data->phbk->win );
537 return MFW_EVENT_CONSUMED;
538 }
539 //break; // RAVI
540
541 case KCD_RIGHT:
542 {
543 /* Right key is a cancel
544 */
545 bookSDNDestroy( data->win );
546 data->phbk->search_win = 0;
547 return MFW_EVENT_CONSUMED;
548 }
549 // break; // RAVI
550
551 case KCD_HUP:
552 {
553 /* Clear key deletes the last character, or if none left will
554 take us out of here
555 */
556 if ( data->edtBuf[0] == '\0' )
557 {
558 bookSDNDestroy( data->win );
559 data->phbk->search_win = 0;
560 return MFW_EVENT_CONSUMED;
561 }
562 else
563 {
564 /* Delete last character entered
565 */
566 /* SPR#1428 - SH - New Editor changes */
567 #ifdef NEW_EDITOR
568 ATB_edit_DeleteLeft(data->editor, TRUE); /* SPR#2342 */
569 #else /* NEW_EDITOR */
570 edtChar( data->edt, ecBack );
571 #endif /* NEW_EDITOR */
572 }
573 }
574 break;
575
576 default:
577 {
578 /* No default processing required
579 */
580 }
581 break;
582 }
583
584 /* Initiate a new search based on the current settings, MyEvent
585 will have been set accordingly
586 */
587 SEND_EVENT( data->win, MyEvent, 0, 0 );
588 winShow( data->win );
589
590 /* And make sure no calling routines try to do anything with the
591 event we have just dealt with
592 */
593 return MFW_EVENT_CONSUMED;
594 }
595
596
597
598
599 /*******************************************************************************
600
601 $Function: bookSDNKeyLongCB
602
603 $Description: long keyboard event handler
604
605 $Returns: MFW_EVENT_CONSUMED always
606
607 $Arguments: e, event to handle, k, keyboard handle
608
609 *******************************************************************************/
610
611 static int bookSDNKeyLongCB( MfwEvt e, MfwKbd *k )
612 {
613 T_MFW_HND win = mfwParent(mfw_header());
614 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
615 tBookStandard *data = (tBookStandard *)win_data->user;
616
617 /* Just checks for clear and long being set, if so it will
618 destroy the window
619 */
620 if ( (e & KEY_CLEAR) && (e & KEY_LONG) )
621 {
622 bookSDNDestroy( win );
623 data->phbk->search_win = 0;
624 }
625
626 /* Force event consumed always, prevents default behaviour
627 kicking in
628 */
629 return MFW_EVENT_CONSUMED;
630 }
631
632
633
634
635 /*******************************************************************************
636
637 $Function: bookSDNCreate
638
639 $Description: Creates the Service numbers widow
640
641 $Returns: Window Handle, or NULL if unsuccessfull
642
643 $Arguments: Parent, handle of the parent window
644
645 *******************************************************************************/
646
647 static T_MFW_HND bookSDNCreate( MfwHnd parent )
648 {
649 T_MFW_WIN *win_data;
650 tBookStandard *data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) );
651 T_MFW_WIN *parent_win_data = ((T_MFW_HDR *)parent)->data;
652 T_phbk* phbk = (T_phbk *)parent_win_data->user;
653
654 TRACE_FUNCTION( "bookSDNCreate()" );
655
656 /* Create the window
657 */
658 if ( ( data->win = win_create (parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookSDNWinCB ) ) == NULL )
659 return NULL;
660
661 /*SPR 2123, MC allocate memory for phonebook list*/
662 if (create_mmi_phonebook_names_list() == NULL)
663 return NULL;
664
665 /* set up the basic window elements, dialog and user data pointers
666 */
667 data->mmi_control.dialog = (T_DIALOG_FUNC)bookSDN;
668 data->mmi_control.data = data;
669 win_data = ((T_MFW_HDR *)data->win)->data;
670 win_data->user = (void *)data;
671 data->parent_win = parent;
672
673 /* Create keyboard and menu handlers to be associated with
674 this window
675 */
676 data->kbd = kbdCreate( data->win, KEY_ALL, (MfwCb) bookSDNKbdCB );
677 data->kbd_long = kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookSDNKeyLongCB );
678 data->menu = mnuCreate( data->win, MmiBookMenuDetailsList(), 0, 0 );
679
680 /* Set basic edit attributes structure and create an editor
681 associated with these attributes
682 */
683 /* SPR#1428 - SH - New Editor changes */
684 #ifdef NEW_EDITOR
685 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);
686 data->editor = ATB_edit_Create(&data->editor_attr,0);
687 data->entry_data = AUI_entry_Create(data->win, data->editor, SEARCH_REDRAW);
688 ATB_edit_Init(data->editor);
689 #else /* NEW_EDITOR */
690 bookSetEditAttributes( BOOKSDN_EDITOR, COLOUR_EDITOR_XX , 0, edtCurBar1, 0, (char*) data->edtBuf, MAX_SEARCH_CHAR, &data->attr );
691 data->edt = edtCreate( data->win, &data->attr, 0, 0 );
692 #endif /* NEW_EDITOR */
693
694 /* Show the menu
695 */
696 mnuUnhide(data->menu);
697
698 /* associate the phonebook handler
699 */
700 data->phbk = phbk;
701
702 /* and return the newly created window handle
703 */
704 return data->win;
705 }
706
707
708
709
710
711 /*******************************************************************************
712
713 Public methods
714
715 *******************************************************************************/
716
717 /*******************************************************************************
718
719 $Function: bookSDNStart
720
721 $Description: This is the entry point for the service numbers window handler
722
723 $Returns: handle of window we are creating
724
725 $Arguments: Parent, handle of the parent window
726
727 *******************************************************************************/
728
729 T_MFW_HND bookSDNStart( MfwHnd parent )
730 {
731 T_MFW_HND win;
732 T_MFW_WIN *win_data;
733 tBookStandard *data;
734 MfwMnu *mnu;
735
736 TRACE_FUNCTION( "bookSDNCreate()" );
737
738 /* We can't actually create the window if the phone book is
739 still loading, so we will deal with this up front
740 */
741 if ( phb_get_mode() == PHB_LOADING )
742 {
743 bookShowInformation( idle_get_window(), TxtPleaseWait ,NULL, NULL );
744 return NULL;
745 }
746
747 /* Create the basic window, dealing with errors here and just terminating
748 if we can't create the window correctly.
749 */
750 if ( ( win = bookSDNCreate( parent ) ) == NULL )
751 return NULL;
752
753 /* Okay, we have created the window, so set up our internal
754 working pointers and check if the current phone book has
755 some entries in it
756 */
757 win_data = ((T_MFW_HDR *) win)->data;
758 data = (tBookStandard *)win_data->user;
759 data->phbk->current.status.book = PHB_SDN;
760
761 /* we need to determine if there are any entries in the phone book
762 before we allow the service number windows to be displayed, we
763 do this by searching for an empty name
764 */
765 bookGetCurrentStatus( &data->phbk->current.status );
766 memset( data->edtBuf, '\0' , sizeof( data->edtBuf ) );
767 data->phbk->current.index = 1;
768 data->phbk->current.selectedName = 0;
769 bookFindName( MAX_SEARCH_NAME, &data->phbk->current );
770
771 /* If the current index is still zero then we have been unable to
772 find an entry, in this case we need to shutdown the service
773 numbers window, since we can't do anything with it.
774 */
775 if ( data->phbk->current.index == 0 )
776 {
777 bookSDNDestroy( win );
778 data->phbk->search_win = 0;
779 bookShowInformation( idle_get_window(), TxtEmptyList ,NULL, NULL );
780 return 0;
781 }
782
783 /* We are still running, so set up the menu and edit structures
784 accordingly, and display the window
785 */
786 mnu = (MfwMnu *) mfwControl( data->menu );
787 mnu->lCursor[ mnu->level ] = data->phbk->current.selectedName;
788
789 /* SPR#1428 - SH - New Editor: editActivate no longer needed */
790 #ifndef NEW_EDITOR
791 editActivate( data->edt, 1 );
792 #endif
793 winShow( data->win );
794
795 /* return the pointer to the window
796 */
797 return win;
798 }
799
800
801
802 /*******************************************************************************
803
804 $Function: bookFindNameInSDNPhonebook
805
806 $Description: This routine performs the FindNameInPhoneBook functionality,
807 tuned to the particular requirements of the service numbers
808 phonebook.
809
810 $Returns: handle of window we are creating
811
812 $Arguments: Parent, handle of the parent window
813
814 *******************************************************************************/
815
816 int bookFindNameInSDNPhonebook( const char* p_pszNumber, T_MFW_PHB_ENTRY* p_pEntry )
817 {
818 T_MFW_PHB_LIST phb_list;
819 #ifdef NO_ASCIIZ
820 T_MFW_PHB_TEXT p_pszNumberText;
821 #endif
822 SHORT phb_index=0;
823 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
824 UBYTE l_name[MAX_ALPHA_LEN];
825 int status;
826 char bfr[80];
827 TRACE_FUNCTION("bookFindNameInSDNPhonebook()");
828
829 /* guard against dodgy input data
830 */
831 if( ( p_pszNumber == NULL ) || ( p_pEntry == NULL ) )
832 return 0;
833 if ( strlen(p_pszNumber) < 1)
834 return (0);
835 /* initialise the search structures
836 */
837 memset(p_pEntry, 0, sizeof(T_MFW_PHB_ENTRY));
838 memset(&phb_list, 0, sizeof(phb_list));
839 phb_list.entry = p_pEntry;
840 phb_list.num_entries = 1;
841 phb_list.book = PHB_SDN;
842
843 //GW Set up data structure for NO_ASCIIZ
844 #ifdef NO_ASCIIZ
845 p_pszNumberText.dcs = MFW_DCS_8bits;
846 p_pszNumberText.len = strlen(p_pszNumber);
847 strcpy((char*)p_pszNumberText.data, p_pszNumber);
848 #endif
849
850 /* see what we can find using the standard search routine for
851 any phone book, giving the service numbers book as a parameter
852 */
853
854 #ifdef NO_ASCIIZ
855 status = phb_find_entries( (UBYTE)PHB_SDN, &phb_index, (UBYTE)MFW_PHB_NUMBER, 1, &p_pszNumberText, &phb_list );
856 #else
857 status = phb_find_entries( PHB_SDN, &phb_index, MFW_PHB_NUMBER, 1, (char *) p_pszNumber, &phb_list );
858 #endif
859 sprintf(bfr,"len:%2d , name: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",p_pEntry->name.len);
860 memcpy(&bfr[16], p_pEntry->name.data, PHB_MAX_LEN);
861 TRACE_FUNCTION(bfr);
862 sprintf(bfr,"number:'%s'",p_pEntry->number);
863 TRACE_FUNCTION(bfr);
864
865 if (status != MFW_PHB_OK)
866 {
867 phb_list.result = MFW_NO_ENTRY;
868 TRACE_FUNCTION("bookFindNameInSDNPhonebook()- status error");
869 }
870
871 /* convert the returned data to manageable information
872 */
873
874 #ifdef NO_ASCIIZ
875 //GW Check that conversion returned a valid string
876 //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.
877 /*MC SPR 1257, replacing PHB_MAX_LEN with MAX_ALPHA_LEN for name strings*/
878 if (mfw_SIM2GsmStr( p_pEntry->name.len, p_pEntry->name.data, MAX_ALPHA_LEN, l_name ) == 0)
879 memcpy(p_pEntry->name.data, l_name, MAX_ALPHA_LEN);
880
881 p_pEntry->name.data[0] = 0x00;
882
883 #else
884 bookGsm2Alpha( p_pEntry->name );
885
886 #endif
887
888 /* if we couldn't find any information, null out the return
889 structure, this will stop people who don't check the return
890 status from getting sensible information
891 */
892 if( phb_list.result != MFW_ENTRY_EXIST )
893 memset(p_pEntry, 0, sizeof(T_MFW_PHB_ENTRY));
894
895 /* return status depends on result of search
896 */
897 return ( phb_list.result == MFW_ENTRY_EXIST );
898 }
899
900
901
902
903
904
905 /*******************************************************************************
906
907 $Function: bookSDNDestroy
908
909 $Description: destroys the Service Numbers window
910
911 $Returns: none.
912
913 $Arguments: window, handle of the window to be destroyed
914
915 *******************************************************************************/
916
917 void bookSDNDestroy( MfwHnd window )
918 {
919 T_MFW_WIN *win = ((T_MFW_HDR *)window)->data;
920 tBookStandard *data = (tBookStandard *)win->user;
921
922 TRACE_FUNCTION( "bookSDNDestroy" );
923
924 /* Guard against bad incoming data
925 */
926 if ( ! data )
927 return;
928
929 /* SPR#1428 - SH - New Editor changes */
930 #ifdef NEW_EDITOR
931 /* Editor is no longer destroyed with winDelete,
932 * so destroy it here. */
933 if (data->editor)
934 {
935 ATB_edit_Destroy(data->editor);
936 data->editor = 0;
937 }
938 if (data->entry_data)
939 {
940 AUI_entry_Destroy(data->entry_data);
941 data->entry_data = 0;
942 }
943 #endif /* NEW_EDITOR */
944
945 /* Destroy the window using the appropriate method
946 */
947 if ( data->phbk->root_win == window )
948 bookPhonebookDestroy( data->phbk->win );
949 else
950 {
951 /* deleting the window, so make sure we free the memory
952 */
953 data->phbk->search_win = 0;
954 winDelete( data->win );
955 FREE_MEMORY( (void *)data, sizeof( tBookStandard ) );
956 }
957 /*SPR2123, MC deallocate memory for phonebook list*/
958 destroy_mmi_phonebook_names_list(MmiBookMenuDetailsList());
959 }
960
961
962 /*******************************************************************************
963
964 End of File
965
966 *******************************************************************************/
967