comparison g23m/condat/ms/src/bmi/MmiBookCallListWindow.c @ 0:509db1a7b7b8

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