comparison src/ui/bmi/mmiBookCallListWindow.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: MmiBookCallListWindow.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 call list window handling for the phone book.
26
27 ********************************************************************************
28 $History: MmiBookCallListWindow.c
29 Feb 22, 2007 OMAPS00115777 a0393213(R.Prabakar)
30 Description : Details of any Missed call number shows Invalid information
31 Fix : Data was not initialized properly. Now it's initialized properly and
32 the fix done as part of CRR 22638 reverted back as it isn't clean
33
34 July 21,2006 REF:DR OMAPS00085695 x0047075
35 Description:Fail to delete the correct entry in LDN, LRN and LMN with Locosto.
36 Solution:After deleting any entry in the LDN,LRN,LMN book,we highlight the first entry as the
37 current selected entry.
38
39 Apr 05, 2006 REF: OMAPS00073906 a0393213 (Prabakar R)
40 Bug : Phone will crash when check the Missed calls list and press the direction key
41 Fix : unnecessary function calls are removed
42
43 Aug 24, 2004 REF: CRR 22638 xrashmic
44 Bug: E-Sample switches off when you attempt to look at details of a number
45 in call list.
46 Fix: Storing the data in a global variable to be used later.
47
48
49 25/10/00 Original Condat(UK) BMI version.
50
51 $End
52
53 *******************************************************************************/
54
55
56
57
58 /*******************************************************************************
59
60 Include Files
61
62 *******************************************************************************/
63 #define ENTITY_MFW
64
65 /* includes */
66 #include <string.h>
67 #include <stdio.h>
68 #include <stdlib.h>
69
70 #if defined (NEW_FRAME)
71
72 #include "typedefs.h"
73 #include "vsi.h"
74 #include "pei.h"
75 #include "custom.h"
76 #include "gsm.h"
77
78 #else
79
80 #include "STDDEFS.H"
81 #include "custom.h"
82 #include "gsm.h"
83 #include "vsi.h"
84
85 #endif
86
87 #include "mfw_sys.h"
88
89 #include "mfw_mfw.h"
90 #include "mfw_win.h"
91 #include "mfw_kbd.h"
92 #include "mfw_lng.h"
93 /* SPR#1428 - SH - New Editor changes */
94 #ifndef NEW_EDITOR
95 #include "mfw_edt.h"
96 #endif
97 #include "mfw_icn.h"
98 #include "mfw_mnu.h"
99 #include "mfw_tim.h"
100
101 #include "mfw_sim.h"
102 #include "mfw_cm.h"
103 #include "mfw_nm.h"
104 #include "mfw_phb.h"
105 #include "mfw_mme.h"
106 #include "mfw_sat.h"
107 #include "mfw_sms.h"
108
109 #include "dspl.h"
110
111 #include "ksd.h"
112 #include "psa.h"
113
114 #include "MmiMain.h"
115 #include "MmiBookController.h"
116 #include "MmiDummy.h"
117 #include "MmiDialogs.h"
118 #include "MmiLists.h"
119
120
121
122 #include "MmiMenu.h"
123 #include "mmiCall.h"
124 #include "Mmiicons.h"
125 #include "MmiIdle.h"
126
127 #include "MmiSoftKeys.h"
128 #include "MmiSounds.h"
129 #include "MmiIdle.h"
130 #include "MmiNetwork.h"
131 #include "mmiSat_i.h"
132 #include "MmiAoc.h"
133
134 #include "gdi.h"
135 #include "audio.h"
136
137 #include "cus_aci.h"
138 #include "MmiTimers.h"
139
140 #include "MmiBookShared.h"
141
142
143
144 /*******************************************************************************
145
146 Local Data Structure Definitions
147
148 *******************************************************************************/
149
150 #define NO_FAILURE (-1)
151 int idCounter = 0;
152 static char missedCalls[40];
153 char calls[10];
154
155
156 /*******************************************************************************
157
158 Private Methods
159
160 *******************************************************************************/
161
162
163 /*******************************************************************************
164
165 $Function: bookCallListSetupEntries
166
167 $Description: Populates the call list display with the current values
168
169 $Returns: None
170
171 $Arguments: Current, pointer to the entry in question
172
173 *******************************************************************************/
174
175 static void bookCallListSetupEntries( tMmiPhbData *Current )
176 {
177 T_MFW_PHB_ENTRY p_pEntry;
178 int index;
179
180 /* search the phone book(s)
181 */
182 for ( index = 0; index < Current->list.num_entries; index++ )
183 {
184 //GW Copy name text (for NO_ASCII set/clear) and length
185 //GW but only if there is an entry!
186 if ( bookFindNameInPhonebook( (const char *) Current->entry[ index ].number, &p_pEntry ) )
187 bookCopyPhbName(&Current->entry[ index ], &p_pEntry, PHONEBOOK_ITEM_LENGTH/*SPR2123*/);
188 }
189 }
190
191
192
193
194 /*******************************************************************************
195
196 $Function: bookCallListDialog
197
198 $Description: Dialog functino for the phone book call list window
199
200 $Returns: None
201
202 $Arguments: win, window handle
203 event, event to be handled
204 value, not used
205 parameter, not used
206
207 *******************************************************************************/
208
209 static void bookCallListDialog( T_MFW_HND win, USHORT event, SHORT value, void *parameter )
210 {
211 T_MFW_WIN *win_data = ((T_MFW_HDR *) win)->data;
212 tBookStandard *data = (tBookStandard *)win_data->user;
213 tMmiPhbData *Current = &data->phbk->current;
214 MfwMnu *mnu;
215
216 int Failure;
217 TRACE_FUNCTION ("bookCallListDialog()");
218 TRACE_EVENT ("jgg-bookCallListDialog()");
219
220 /* Handle the dialog events
221 */
222 switch (event)
223 {
224 case CALLS_LIST_INIT:
225 {
226 /* Initialise message
227 */
228 //July 21,2006 REF:DR OMAPS00085695 x0047075
229 //Fix: After deleting an entry in the phonebook,we make First entry as the current selected entry .
230 Current->selectedName = 0;
231 data->phbk->current.index = 1;
232 data->phbk->current.status.book = (int)parameter;
233
234 /* If we are currently loading the phone book we can't go any
235 further, so indicate a failure condition
236 */
237 Failure = ( phb_get_mode() == PHB_LOADING ) ? TxtPleaseWait : NO_FAILURE;
238
239 /* grab the current status of the phone book, and
240 check that it's okay
241 */
242 if ( Failure == NO_FAILURE )
243 {
244 bookGetCurrentStatus( &data->phbk->current.status );
245
246 /* Issue 2538, MZ 25/09/03 Only read the number of used records from the Service Table
247 when initialising the calls list. */
248
249 Failure = ( bookFindName(data->phbk->current.status.used_entries, &data->phbk->current ) != MFW_PHB_OK )
250 ? TxtReadError : NO_FAILURE;
251 }
252
253 /* Check for an empty list
254 */
255 if ( Failure == NO_FAILURE )
256 Failure = ( data->phbk->current.index == 0 ) ? TxtEmptyList : NO_FAILURE;
257
258 /* api patch 03-04-02
259 */
260 if ((Failure != NO_FAILURE) && (idCounter > 0))
261 Failure = NO_FAILURE;
262
263 /* If everything is okay we can try to find the name in the
264 phone book, otherwise Failure will contain an error message
265 */
266 if ( Failure == NO_FAILURE )
267 {
268 bookCallListSetupEntries( &data->phbk->current );
269 //July 21,2006 REF:DR OMAPS00085695 x0047075
270 // Fix: After deleting an entry in the phonebook,we make First entry as the Current selected entry.
271 mnu = (MfwMnu *) mfwControl( data->menu );
272 mnu->lCursor[mnu->level] = Current->selectedName;
273 winShow( data->win );
274 }
275 else
276 {
277 /* If we get to here and the failure flag isn't NO_FAILURE then
278 it'll be set to the id of the message we need to present, so
279 show the information dialog and destroy the call list window
280 */
281 bookShowInformation( data->phbk->win, Failure, NULL, NULL );
282 bookCallListDestroy( data->win );
283 }
284 }
285 break;
286 case SEARCH_SCROLL_UP:
287 {
288 /* Scroll up
289 */
290
291 if(( Current->selectedName == 1) && (Current->status.used_entries == 1))
292 Current->selectedName = Current->selectedName;
293
294 else if ( ( Current->index == 1 ) && ( Current->selectedName == Current->missedCallsOffset ) )
295 {
296 if ( (Current->status.used_entries + Current->missedCallsOffset) < MAX_SEARCH_CALL_LIST )
297 Current->selectedName = Current->status.used_entries -1;
298 else
299 Current->selectedName = MAX_SEARCH_CALL_LIST - 1;
300 Current->index = Current->status.used_entries + Current->missedCallsOffset - Current->selectedName;
301 }
302 else
303 {
304 if(Current->selectedName == Current->missedCallsOffset)
305 {
306 if(Current->index == 1 + Current->missedCallsOffset)
307 Current->selectedName = Current->missedCallsOffset;
308 Current->index--;
309 }
310 else
311 Current->selectedName--;
312 }
313 mnu = (MfwMnu *) mfwControl( data->menu );
314 mnu->lCursor[mnu->level] = Current->selectedName;
315
316 //Apr 05, 2006 REF: OMAPS00073906 a0393213 (Prabakar R)
317 //Bug : Phone will crash when check the Missed calls list and press the direction key
318 //Fix : unnecessary function calls(bookFindName and bookCallListSetupEntries) are removed
319 }
320 break;
321
322 case SEARCH_SCROLL_DOWN:
323 {
324 /* Scroll Down
325 */
326
327 if ( ( Current->index + Current->selectedName ) == Current->status.used_entries + Current->missedCallsOffset)
328 {
329 Current->index = 1;
330 Current->selectedName = 0 + Current->missedCallsOffset;
331 }
332 else
333 {
334 if ( Current->selectedName == MAX_SEARCH_CALL_LIST - 1 )
335 Current->index++;
336 else
337 Current->selectedName++;
338 }
339 mnu = (MfwMnu *) mfwControl( data->menu );
340 mnu->lCursor[mnu->level] = Current->selectedName;
341
342 //Apr 05, 2006 REF: OMAPS00073906 a0393213 (Prabakar R)
343 //Bug : Phone will crash when check the Missed calls list and press the direction key
344 //Fix : unnecessary function calls(bookFindName and bookCallListSetupEntries) are removed
345 }
346 break;
347
348 default:
349 {
350
351 /* No need to deal with any other events
352 */
353 }
354 break;
355 }
356 }
357
358
359 /*******************************************************************************
360
361 $Function: bookCallListWinCB
362
363 $Description: Window Event Handler
364
365 $Returns: MFW_EVENT_CONSUMED if event handled, otherwise MFW_EVENT_PASSED
366
367 $Arguments: standard window event handler, e, event, w, window handle
368
369 *******************************************************************************/
370
371 static int bookCallListWinCB( MfwEvt e, MfwWin *w )
372 {
373 tBookStandard *data = (tBookStandard *)w->user;
374 tMmiPhbData *Current = &data->phbk->current;
375 char *ptr;
376 // MfwMnu *mnu; // RAVI
377 int index, i;
378 // int Withheld; // RAVI
379
380 /* x0045876, 14-Aug-2006 (WR - "missedOutput" was set but never used) */
381 /*int displayStart, missedOutput; */
382 int displayStart;
383
384
385 TRACE_FUNCTION("bookCallListWinCB");
386
387 /* x0045876, 14-Aug-2006 (WR - "missedOutput" was set but never used) */
388 /* missedOutput = FALSE; */
389
390 /* api introduction to display withheld numbers in recent calls list
391 03-04-02
392 */
393 switch( e )
394 {
395 case MfwWinVisible:
396 {
397 /* Handle the window visible event, show default screen,
398 populate the call list menu and put up default soft keys
399 */
400 TRACE_EVENT_P1("<<<<idCounter Value is %d", idCounter);
401 MmiBookShowDefault();
402
403 if(idCounter > 0)
404 {
405 /* x0045876, 14-Aug-2006 (WR - "missedOutput" was set but never used) */
406 /* missedOutput = TRUE; */
407
408 displayStart = 1;
409 strcpy(missedCalls,MmiRsrcGetText(TxtUnknown));
410 strcat(missedCalls,": ");
411 sprintf(calls,"%d",idCounter);
412 strcat(missedCalls,calls);
413 data->phbk->current.missedCallsOffset = 1;
414 strcpy( (char*)MmiBookCallList( 0 ), (char*)missedCalls);
415 }
416 else
417 displayStart = 0;
418
419 index = 0;
420
421 for ( i = displayStart; i < NAME_LIST_SIZE; i++ )
422 {
423 #ifdef NO_ASCIIZ
424 if ( data->phbk->current.entry[index].name.len > 0 )
425 ptr = (char *) data->phbk->current.entry[index].name.data;
426 else if(strlen((char *) data->phbk->current.entry[index].number) > 0)
427 ptr = (char *) data->phbk->current.entry[index].number;
428 else
429 ptr = "";
430
431 #else
432 if ( strlen( (char *) data->phbk->current.entry[index].name ) > 0 )
433 ptr = (char *) data->phbk->current.entry[index].name;
434 else if (strlen((char *) data->phbk->current.entry[index].number) > 0)
435 ptr = (char *) data->phbk->current.entry[index].number;
436 else
437 ptr = "";
438 #endif
439
440 strcpy( (char*)MmiBookCallList( i ), ptr);
441 TRACE_FUNCTION((char*)MmiBookCallList( i ));
442 index ++;
443 strcpy( (char*)MmiBookCallList( index ), (char*)ptr);
444 TRACE_EVENT((char*)MmiBookCallList( index ));
445 }
446
447 mnuUnhide(data->menu);
448
449
450 if((idCounter > 0) && (Current->status.used_entries == 0))
451 displaySoftKeys( TxtNull, TxtSoftBack );
452 else if((idCounter > 0) && (Current->status.used_entries > 0))
453 displaySoftKeys( TxtSoftOptions, TxtSoftBack );
454 else
455 displaySoftKeys( TxtSoftOptions, TxtSoftBack );
456 }
457 break;
458
459 default:
460 {
461 /* If it's not a window visible event we ignore it and
462 pass it back up the tree to be handled
463 */
464 return MFW_EVENT_PASSED;
465 }
466 // break; // RAVI
467 }
468
469 return MFW_EVENT_CONSUMED;
470 }
471
472
473 /*******************************************************************************
474
475 $Function: bookCallListKbdCB
476
477 $Description: Keyboard event handler
478
479 $Returns: MFW_EVENT_CONSUMED always
480
481 $Arguments: e, event, k, keyboard handle
482
483 *******************************************************************************/
484
485 static int bookCallListKbdCB( MfwEvt e, MfwKbd *k )
486 {
487 T_MFW_HND win = mfwParent( mfw_header() );
488 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
489 tBookStandard *data = (tBookStandard *) win_data->user;
490 tMmiPhbData *Current = &data->phbk->current;
491
492
493 /* Handle the events provided by the key
494 */
495 switch (k->code)
496 {
497 case KCD_MNUUP:
498 {
499 SEND_EVENT( data->win, SEARCH_SCROLL_UP, 0, 0 );
500 winShow(win);
501 }
502 break;
503
504 case KCD_MNUDOWN:
505 {
506 SEND_EVENT( data->win, SEARCH_SCROLL_DOWN, 0, 0 );
507 winShow(win);
508 }
509 break;
510 case KCD_RIGHT:
511 bookPhonebookDestroy( data->phbk->win );
512 break;
513 case KCD_CALL:
514 {
515 /* selected to call the number
516 */
517 mnuHide( data->menu );
518 callNumber( data->phbk->current.entry[data->phbk->current.selectedName - data->phbk->current.missedCallsOffset].number );
519 bookPhonebookDestroy( data->phbk->win );
520 }
521 break;
522
523 case KCD_MNUSELECT:
524 case KCD_LEFT:
525 {
526 /* Selected the options menu so display them
527 */
528 if(Current->status.used_entries > 0)
529 data->phbk->menu_call_options_win = bookMenuStart( data->phbk->win, bookRepRedOptionsMenuAttributes(),0 );
530 else
531 break;
532 }
533 break;
534
535 case KCD_HUP:
536 {
537 /* Selected to get out of here, so destroy the window
538 */
539 bookCallListDestroy( data->win );
540 }
541 break;
542
543 default:
544 {
545 /* No other handling required here
546 */
547 }
548 break;
549 }
550
551 /* Always consume the event
552 */
553 return MFW_EVENT_CONSUMED;
554 }
555
556
557 /*******************************************************************************
558
559 $Function: bookCallListKbdLongCB
560
561 $Description: Keyboard Long Press event handler
562
563 $Returns: MFW_EVENT_CONSUMED always
564
565 $Arguments: e, event, k, keyboard handle
566
567 *******************************************************************************/
568
569 static int bookCallListKbdLongCB( MfwEvt e, MfwKbd *k )
570 {
571 T_MFW_HND win = mfwParent( mfw_header() );
572 T_MFW_WIN *win_data = ((T_MFW_HDR *)win)->data;
573 tBookStandard *data = (tBookStandard *) win_data->user;
574
575 /* hand a long clear event only
576 */
577 if ( ( e & KEY_CLEAR ) && ( e & KEY_LONG ) )
578 bookCallListDestroy( data->win );
579
580 return MFW_EVENT_CONSUMED;
581 }
582
583
584
585
586 /*******************************************************************************
587
588 $Function: bookCallListCreate
589
590 $Description: Create the call list window
591
592 $Returns: Handle of the window, or NULL if there is an error
593
594 $Arguments: parent, handle of the parent window
595
596 *******************************************************************************/
597
598 static T_MFW_HND bookCallListCreate( MfwHnd parent )
599 {
600 T_MFW_WIN *parent_win_data = ( (T_MFW_HDR *) parent )->data;
601 T_phbk *phbk = (T_phbk *)parent_win_data->user;
602 T_MFW_WIN *win_data;
603 tBookStandard *data;
604 MfwMnu *mnu;
605
606 TRACE_FUNCTION ("bookCallListCreate()");
607
608 /* allocate memory for our control block
609 */
610 if ( ( data = (tBookStandard *) ALLOC_MEMORY( sizeof( tBookStandard ) ) ) == NULL )
611 return NULL;
612
613 /* Create the window if we can
614 */
615 if ( ( data->win = win_create( parent, 0, E_WIN_VISIBLE, (T_MFW_CB) bookCallListWinCB ) ) == NULL )
616 {
617 FREE_MEMORY( (void *)data, sizeof( tBookStandard ) );
618 return NULL;
619 }
620 /*SPR 2123, MC allocate memory for phonebook list*/
621 if (create_mmi_phonebook_names_list() == NULL)
622 return NULL;
623 /* Okay, we have created the control block and the window, so
624 we now need to configure the dialog and data pointers
625 */
626 data->mmi_control.dialog = (T_DIALOG_FUNC) bookCallListDialog;
627 data->mmi_control.data = data;
628 win_data = ((T_MFW_HDR *)data->win)->data;
629 win_data->user = (void *) data;
630 data->phbk = phbk;
631 data->phbk->root_win = data->win;
632 data->phbk->calls_list_win = data->win;
633 data->parent_win = parent;
634
635 /* create keyboards and menus for our window
636 */
637 data->kbd = kbdCreate( data->win, KEY_ALL, (MfwCb) bookCallListKbdCB );
638 data->kbd_long = kbdCreate( data->win, KEY_ALL | KEY_LONG, (MfwCb) bookCallListKbdLongCB );
639 data->menu = mnuCreate( data->win, (MfwMnuAttr *)MmiBookMenuDetailsList(), 0, 0 );
640
641 mnu = (MfwMnu *) mfwControl( data->menu );
642
643 /* api 19-04-02 - path to move cursor down one
644 in missed calls list. */
645
646 if(idCounter > 0)
647 mnu->lCursor[mnu->level] = 1;
648 else
649 mnu->lCursor[mnu->level] = 0;
650
651 mnuScrollMode(data->menu,0);
652
653 /* allow the window and menu to be created
654 */
655 mnuUnhide(data->menu);
656 winShow(data->win);
657
658 /* And return the handle of the newly created window
659 */
660 return data->win;
661 }
662
663
664 /*******************************************************************************
665
666 Public Methods
667
668 *******************************************************************************/
669
670 /*******************************************************************************
671
672 $Function: bookCallListStart
673
674 $Description: Entry point for the call list window
675
676 $Returns: Handle of window
677
678 $Arguments: parent, handle of parent window
679
680 *******************************************************************************/
681
682 T_MFW_HND bookCallListStart( MfwHnd parent,int parameter )
683 {
684 T_MFW_HND win;
685
686 /* create and initialise the window
687 */
688 if ( ( win = bookCallListCreate( parent ) ) != NULL )
689 SEND_EVENT( win, CALLS_LIST_INIT, 0, (void*)parameter );
690
691 /* return the handle, or NULL if we have had an error
692 */
693 return win;
694 }
695
696
697 /*******************************************************************************
698
699 $Function: bookCallListDestroy
700
701 $Description: destroys the call list window
702
703 $Returns: None
704
705 $Arguments: window, the window to be killed
706
707 *******************************************************************************/
708
709 void bookCallListDestroy( MfwHnd window )
710 {
711 T_MFW_WIN *win = ((T_MFW_HDR *)window)->data;
712 tBookStandard *data = (tBookStandard *)win->user;
713
714 TRACE_FUNCTION ("bookCallListDestroy()");
715 /* Remove the Withheld counter from the list
716 */
717 idCounter = 0;
718 memset (missedCalls, '\0', 40);
719 memset(calls, '\0', 10);
720
721 /* Only actually do something if the data pointer is valid
722 */
723 if ( ! data )
724 return;
725
726
727 /* If we are the root window then we need to deal with the
728 phonebook destruction
729 */
730 if ( data->phbk->root_win == window )
731 bookPhonebookDestroy(data->phbk->win);
732 else
733 {
734 /* delete our window and free the allocated memory
735 */
736 data->phbk->calls_list_win = 0;
737 winDelete ( data->win );
738 FREE_MEMORY( (void *)data, sizeof( tBookStandard ) );
739 }
740 /*SPR2123, MC deallocate memory for phonebook list*/
741 destroy_mmi_phonebook_names_list(MmiBookMenuDetailsList());
742 }
743
744
745
746 /*******************************************************************************
747
748 End of File
749
750 *******************************************************************************/
751