comparison src/ui3/bmi/mmiSatInfo.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
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
14 $Module: SMS
15 $File: mmiSatInfo.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 25/10/00
20
21 ********************************************************************************
22
23 Description:
24
25 Implementation of MMI SIM Application Toolkit (SAT)
26
27 ********************************************************************************
28
29 $History: mmiSatInfo.c
30
31 July 26, 2005 REF: SPR 29520 x0018858
32 Issue: 27.22.4.5 Proactive SIM Command: PLAY TONE fails
33 Solution: The window which used to come up "Please wait" was not getting destroyed.
34 Care has been taken to check this.
35
36 25/10/00 Original Condat(UK) BMI version.
37 21/02/03 removed all calls to function sat_add_unicode_tag_if_needed()
38 $End
39
40 *******************************************************************************/
41
42 #define ENTITY_MFW
43
44 /* includes */
45 #include <string.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48
49 #if defined (NEW_FRAME)
50
51 #include "typedefs.h"
52 #include "vsi.h"
53 #include "pei.h"
54 #include "custom.h"
55 #include "gsm.h"
56
57 #else
58
59 #include "STDDEFS.H"
60 #include "custom.h"
61 #include "gsm.h"
62 #include "vsi.h"
63
64 #endif
65 #include "mfw_sys.h"
66
67 #include "mfw_mfw.h"
68 #include "mfw_win.h"
69 #include "mfw_kbd.h"
70 /* SPR#1428 - SH - New Editor changes */
71 #ifndef NEW_EDITOR
72 #include "mfw_edt.h"
73 #endif
74 #include "mfw_lng.h"
75 #include "mfw_icn.h"
76 #include "mfw_phb.h"
77 #include "mfw_sim.h"
78 #include "mfw_nm.h"
79 #include "mfw_sms.h"
80 #include "mfw_mnu.h"
81 #include "mfw_sat.h"
82 #include "mfw_tim.h"
83
84 #include "dspl.h"
85
86 #include "MmiMmi.h"
87 #include "MmiDummy.h"
88 #include "MmiDialogs.h"
89 #include "MmiLists.h"
90
91 #include "MmiMain.h"
92 #include "MmiStart.h"
93 #include "MmiPins.h"
94 #include "MmiMenu.h"
95 #include "MmiSoftKeys.h"
96 #include "MmiSounds.h"
97 #include "mmiCall.h"
98
99 #include "gdi.h"
100 #include "audio.h"
101 #include "mmiSat_i.h"
102 /* SPR#1428 - SH - New Editor changes */
103 #ifdef NEW_EDITOR
104 #include "ATBCommon.h"
105 #include "ATBDisplay.h"
106 #include "ATBEditor.h"
107 #include "AUIEditor.h"
108 #else
109 #include "MmiEditor.h"
110 #endif
111 #include "cus_aci.h"
112 #include "prim.h"
113 #ifndef PCM_2_FFS
114 #include "pcm.h"
115 #endif
116
117
118 #include "mmiColours.h"
119
120 static int sat_play_tone_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc);
121 static void sat_info_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason);
122
123
124 /*********************************************************************
125 *
126 * SUB WINDOW SAT_PLAY_TONE
127 *
128 *********************************************************************/
129 /*
130 * Tone Definitions
131 */
132 #define SAT_TONE_DIAL 1
133 #define SAT_TONE_CALL_SUB_BUSY 2
134 #define SAT_TONE_CONGESTION 3
135 #define SAT_TONE_RADIO_PATH_ACK 4
136 #define SAT_TONE_RADIO_PATH_NOT 5
137 #define SAT_TONE_ERROR 6
138 #define SAT_TONE_CALL_WAITING 7
139 #define SAT_TONE_RINGING_TONE 8
140 #define SAT_TONE_GENERAL_BEEP 0x10
141 #define SAT_TONE_POSITIV_ACK 0x11
142 #define SAT_TONE_NEGATIV_ACK 0x12
143
144 typedef struct
145 {
146 T_MMI_CONTROL mmi_control;
147 T_MFW_HND parent_win;
148 T_MFW_HND win;
149 T_MFW_HND tim;
150 T_MFW_HND info;
151 T_SAT_CMD *sat_command; /* pointer to sat_command in parent */
152 T_MFW_HND kbd; /* sbh - keyboard handler, so window can be destroyed by user */
153 char *TextString;
154 UBYTE sound_id; /* sound to play */
155 UBYTE device_id; /* device to play sound on */
156 BYTE volume; /* volume to play */
157 } T_sat_play_tone;
158
159 typedef enum {
160 NOT_SUPPORTED,
161 SINGLE_TONE,
162 DURATION
163 } e_TONE_DURATION;
164
165
166 static e_TONE_DURATION sat_set_selected_sound (SatTone tone_tag, T_sat_play_tone * data);
167 static void sat_play_tone_destroy (T_MFW_HND own_window);
168 static void sat_play_tone_exec (T_MFW_HND win, USHORT event, SHORT value, T_SAT_CMD * sat_command);
169 static ULONG sat_calculate_time (UBYTE unit, UBYTE value);
170
171 /*******************************************************************************
172
173 $Function: sat_play_tone_create
174
175 $Description: Creation of an instance for the SAT PLAY TONE dialog. Window must
176 be available after reception of SAT command, only one instance.
177
178 $Returns: window handle
179
180 $Arguments: own_window - window handler
181
182 *******************************************************************************/
183
184 T_MFW_HND sat_play_tone_create (T_MFW_HND parent_window)
185 {
186 T_sat_play_tone * data = (T_sat_play_tone *)ALLOC_MEMORY (sizeof (T_sat_play_tone));
187 T_MFW_WIN * win;
188
189 data->win = win_create (parent_window, 0, E_WIN_VISIBLE, (T_MFW_CB)sat_win_cb); // c030 rsa
190
191 if (data->win EQ NULL)
192 return NULL;
193
194 /*
195 * Create window handler
196 */
197 data->mmi_control.dialog = (T_DIALOG_FUNC)sat_play_tone_exec;
198 data->mmi_control.data = data;
199 data->parent_win = parent_window;
200 win = ((T_MFW_HDR *)data->win)->data;
201 win->user = (MfwUserDataPtr)data;
202
203 data->kbd = kbdCreate( data->win, KEY_ALL, (T_MFW_CB) sat_kbd_cb); /* sbh - add keyboard handler */
204
205 /*
206 * return window handle
207 */
208 win_show(data->win);
209 return data->win;
210 }
211
212 /*******************************************************************************
213
214 $Function: sat_play_tone_destroy
215
216 $Description: Destroy the sat play tone dialog.
217
218
219 $Returns: none
220
221 $Arguments: own_window - window handler
222
223 *******************************************************************************/
224 static void sat_play_tone_destroy (T_MFW_HND own_window)
225 {
226 T_MFW_WIN * win_data = ((T_MFW_HDR *)own_window)->data;
227 T_sat_play_tone * data = (T_sat_play_tone *)win_data->user;
228
229 if (own_window == NULL)
230 {
231 TRACE_EVENT ("Error : sat_play_tone_destroy called with NULL Pointer");
232 return;
233 }
234
235 if (data)
236 {
237 /*
238 * Delete WIN Handler
239 */
240 win_delete (data->win);
241 /*
242 * Free Memory
243 */
244 sat_destroy_TEXT_ASCIIZ (data->TextString);
245 FREE_MEMORY ((U8 *)data, sizeof (T_sat_play_tone));
246 }
247 }
248
249 /*******************************************************************************
250
251 $Function: sat_play_tone_exec
252
253 $Description: Dialog function for sat_play_tone_exec window.
254
255 $Returns: none
256
257 $Arguments: win - window handler
258 event -window event
259 value - unique id
260 sat_command - Sat Command.
261
262 *******************************************************************************/
263 static void sat_play_tone_exec (T_MFW_HND win, USHORT event, SHORT value, T_SAT_CMD * sat_command)
264 {
265
266 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
267 T_sat_play_tone * data = (T_sat_play_tone *)win_data->user;
268
269 T_SAT_TXT * txt;
270 ULONG time = 0; /* x0039928 - Lint warning fix */
271 e_TONE_DURATION res;
272 T_SAT_RES sat_res;
273
274 T_DISPLAY_DATA display_info;
275
276 TRACE_FUNCTION ("sat_play_tone_exec()");
277
278 switch (event)
279 {
280 case SAT_PLAY_TONE:
281 TRACE_EVENT("SAT_PLAY_TONE");
282 data->sat_command = sat_command; /* save a pointer to the parameter for later use in callbacks */
283 data->info = NULL; /* NULL means no info running */
284 data->tim = NULL; /* NULL means no timer running */
285
286 /*
287 * --> Select the right Sound ID, if not supported: return
288 */
289
290 res = sat_set_selected_sound(sat_command->c.tone, data);
291
292 switch (res)
293 {
294 case NOT_SUPPORTED:
295 /* sound not supported */
296 TRACE_EVENT("SAT sound not supported");
297 sat_res[SAT_ERR_INDEX] = SAT_RES_IMPOSSIBLE;
298 sat_res[SAT_AI_INDEX] = SatResAiNoCause;
299 sat_done (sat_command, sat_res);
300 sat_play_tone_destroy (data->win);
301 return;
302 case SINGLE_TONE:
303 /* ignore duration for single tones */
304 TRACE_EVENT("SINGLE_TONE");
305 audio_PlaySoundID(data->device_id, data->sound_id , data->volume, AUDIO_PLAY_ONCE);
306 break;
307 case DURATION:
308 TRACE_EVENT("DURATION");
309 time = sat_calculate_time (sat_command->c.tone.durUnit, sat_command->c.tone.durValue);
310 if (time EQ 0)
311 {
312 /* use default tone duration */
313 audio_PlaySoundID(data->device_id, data->sound_id , data->volume, AUDIO_PLAY_ONCE);
314 res = SINGLE_TONE; /* overruled by default */
315 }
316 else
317 {
318 /* to be stopped by timer */
319 data->tim = tim_create (win, time, (T_MFW_CB)sat_play_tone_tim_cb);
320 tim_start (data->tim);
321 audio_PlaySoundID(data->device_id, data->sound_id , data->volume, AUDIO_PLAY_INFINITE);
322 }
323 break;
324 }
325
326 /*
327 * --> display alpha identifier (if any)
328 */
329 txt = &sat_command->c.tone.alpha;
330
331 /*SPR#2340 - DS - Handle cases where no alpha id and/or duration is present */
332
333 if (txt->len > 0) /* alpha id supplied in command */
334 {
335 int timer=0;
336
337 if (time EQ 0) /* no duration supplied, destroy info_dialog after timeout */
338 timer = TEN_SECS;
339 else /* duration supplied, info_dialog destroyed when audio timer expires */
340 timer = FOREVER;
341
342 data->TextString = sat_create_TEXT_ASCIIZ (txt);
343
344 //July 26, 2005 REF: SPR 29520 x0018858
345 //Function call modified to pass the string as a differant argument(initially 4th arg but now as the 5th arg).
346 dlg_initDisplayData_TextStr( &display_info, TxtNull, TxtCancel, NULL, data->TextString, COLOUR_STATUS);
347
348 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)sat_info_cb, timer, KEY_LEFT | KEY_RIGHT | KEY_HUP);
349 display_info.Identifier = event;
350 //July 26, 2005 REF: SPR 29520 x0018858
351 //wrapping enabled for the display.
352 display_info.WrapStrings=WRAP_STRING_2;
353
354 /*
355 * Call Info Screen
356 */
357 data->info = info_dialog (win, &display_info);
358 /* destroy when dialog times out */
359 display_info.TextString = data->TextString;
360 }
361 else if (txt->text EQ 0 && res NEQ SINGLE_TONE)
362 {
363 /* no alpha id supplied - show default text */
364 int timer=0;
365
366 if (time EQ 0) /* no duration supplied, destroy info_dialog after timeout */
367 timer = TEN_SECS;
368 else /* duration supplied, info_dialog destroyed when audio timer expires */
369 timer = FOREVER;
370
371 data->TextString = sat_create_TEXT_ASCIIZ (txt);
372 dlg_initDisplayData_TextStr( &display_info, TxtNull, TxtCancel, "Playing tone", NULL, COLOUR_STATUS);
373 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)sat_info_cb, timer, KEY_LEFT | KEY_RIGHT | KEY_HUP);
374 display_info.Identifier = event;
375 /*
376 * Call Info Screen
377 */
378 data->info = info_dialog (win, &display_info);
379 /* destroy when dialog times out */
380 display_info.TextString = data->TextString;
381 }
382 else if (res EQ SINGLE_TONE)
383 {
384 /* destroy immediately, if SINGLE_TONE and no info */
385 sat_res[SAT_ERR_INDEX] = SatResSuccess;
386 sat_res[SAT_AI_INDEX] = SatResAiNoCause;
387 sat_done (sat_command, sat_res);
388 sat_play_tone_destroy (win);
389 }
390 break;
391
392 /* sbh - all window types are being provided with this event to destroy the window */
393 case SAT_DESTROY_WINDOW:
394 TRACE_EVENT("SAT_DESTROY_WINDOW");
395 sat_play_tone_destroy (win);
396 break;
397 /* ...sbh */
398
399 default:
400 TRACE_EVENT ("sat_play_tone_exec() unexpected event");
401 break;
402 }
403 }
404
405 /*******************************************************************************
406
407 $Function: sat_play_tone_tim_cb
408
409 $Description: Callback function for the play tone timer.
410
411 $Returns: Execution status
412
413 $Arguments: event -window event
414 tc - timer info
415
416 *******************************************************************************/
417
418 static int sat_play_tone_tim_cb (T_MFW_EVENT event, T_MFW_TIM *tc)
419 {
420 T_MFW_HND win = mfw_parent (mfw_header());
421 T_MFW_WIN * win_data = ((T_MFW_HDR *)win)->data;
422 T_sat_play_tone * data = (T_sat_play_tone *)win_data->user;
423 T_SAT_RES sat_res;
424
425 if ((win EQ NULL) || (win_data EQ NULL) || (data EQ NULL))
426 return MFW_EVENT_CONSUMED; /* we have been interrupted by user action */
427
428 TRACE_FUNCTION("sat_play_tone_tim_cb()");
429
430 /* timer elapsed */
431
432 sat_res[SAT_ERR_INDEX] = SatResSuccess;
433 sat_res[SAT_AI_INDEX] = SatResAiNoCause;
434 sat_done (data->sat_command, sat_res);
435 data->sat_command = NULL; /* signal response issued to info */
436
437 /* the last one has to destroy the window */
438 data->tim = NULL; /* signal end of timer to info */
439
440 /* API/DSM - 04/09/03 - SPR2491 - Add a call to stop the play of the continuous AUDIO sound*/
441 audio_StopSoundbyID(data->device_id, data->sound_id);
442 /* API/DSM - 04/09/03 - SPR2491 - END */
443
444
445 /* SPR#2340 - DS - If timer has expired, destroy info_dialog if necessary */
446 if (data->info NEQ NULL)
447 {
448 /* timer has expired therefore destroy info dialog */
449 TRACE_EVENT("Destroy Play Tone dialog and data");
450 // July 26, 2005 REF: SPR 29520 x0018858
451 //The wndow displaying "Please wait was not getting destroyed.
452 //Destroyed the window and initialized to NULL.
453 //Begin 29520
454 //sat_play_tone_destroy(data->info);
455 dialog_info_destroy(data->info);
456 data->info = NULL;
457 //End 29520
458 }
459
460 if (data->info EQ NULL)
461 {
462 /* no info window or info window timed out: we are the last */
463 TRACE_EVENT("Destroy Play Tone win and data");
464 sat_play_tone_destroy (win);
465 }
466 return MFW_EVENT_CONSUMED;
467 }
468
469 /*******************************************************************************
470
471 $Function: sat_calculate_time
472
473 $Description: Calculate timeout value
474
475 $Returns: time out in ms
476
477 $Arguments: unit - number of units
478 value - unit value.
479
480 *******************************************************************************/
481 static ULONG sat_calculate_time (UBYTE unit, UBYTE value)
482 {
483 ULONG result = (ULONG)value;
484
485 TRACE_FUNCTION("sat_calculate_time()");
486
487 switch (unit)
488 {
489 case 0: // Minutes
490 result = result * 60 * 1000;
491 break;
492 case 1: // Seconds
493 result = result * 1000;
494 break;
495 case 2: // tenth of seconds
496 result = result * 100;
497 break;
498 }
499 TRACE_EVENT_P3("unit %d, value %d = result %d ms", unit, value, result);
500 return result;
501 }
502
503 /*******************************************************************************
504
505 $Function: sat_set_selected_sound
506
507 $Description: Choose the Sound IDīs, return appropriate duration and support info
508
509 $Returns: time out
510
511 $Arguments: tone_tag - tone name
512 data - tone info
513
514 *******************************************************************************/
515
516
517 static e_TONE_DURATION sat_set_selected_sound (SatTone tone_tag, T_sat_play_tone * data)
518
519 {
520 e_TONE_DURATION ret;
521
522 TRACE_FUNCTION("sat_set_selected_sound()");
523
524 /* SPR#2340 - DS - Removed code that set ret to NOT_SUPPORTED if durUnit equals zero (i.e. Minutes) */
525
526 /* SPR#2340 - DS - Corrected sound Ids. Use defns rather than magic no.s */
527
528 switch(tone_tag.tone)
529 {
530 case SAT_TONE_CALL_SUB_BUSY:
531 data->sound_id = TONES_BUSY /*17*/;
532 break;
533 case SAT_TONE_CONGESTION:
534 data->sound_id = TONES_CONGEST /*18*/;
535 break;
536 case SAT_TONE_RADIO_PATH_ACK:
537 case SAT_TONE_GENERAL_BEEP:
538 data->sound_id = TONES_ACK /*20*/;
539 break;
540 case SAT_TONE_RADIO_PATH_NOT:
541 data->sound_id = TONES_DROPPED /*19 - also call dropped*/;
542 break;
543 case SAT_TONE_DIAL:
544 case SAT_TONE_CALL_WAITING:
545 data->sound_id = TONES_CW /*21*/;
546 break;
547 case SAT_TONE_POSITIV_ACK:
548 case SAT_TONE_RINGING_TONE:
549 data->sound_id = TONES_RINGING_TONE /*0x27*/;
550 break;
551 case SAT_TONE_ERROR:
552 case SAT_TONE_NEGATIV_ACK:
553 data->sound_id = TONES_ERROR /*16*/;
554 break;
555 default:
556 /* Unknown tone value - default is 'general beep' */
557 data->sound_id = TONES_KEYBEEP /*0x26*/;
558 break;
559 }
560
561 ret = DURATION;
562
563 TRACE_EVENT_P2("tone %d, sound_id %x", tone_tag.tone, data->sound_id);
564
565 return ret;
566 }
567
568 /*******************************************************************************
569
570 $Function: sat_info_cb
571
572 $Description: Callback function information dialog.
573
574 $Returns: none
575
576 $Arguments: win - window
577 identifier - unique id
578 reason - event
579
580 *******************************************************************************/
581
582 static void sat_info_cb(T_MFW_HND win, UBYTE identifier, UBYTE reason)
583 {
584 /* PLAY TONE */
585 T_MFW_WIN * play_win_data = ((T_MFW_HDR *)win)->data;
586 T_sat_play_tone * play_data = (T_sat_play_tone *)play_win_data->user;
587 T_SAT_RES sat_res;
588
589 if (win EQ NULL)
590 return;
591
592 TRACE_FUNCTION("sat_info_cb()");
593
594 TRACE_EVENT_P2("identifier %d, reason %d", identifier, reason);
595
596 /*
597 * Who has initiated the information screen
598 */
599 switch (identifier)
600 {
601 case SAT_PLAY_TONE:
602 if ((play_win_data EQ NULL) || (play_data EQ NULL))
603 return; /* we have been interrupted by sat_play_tone_tim_cb() */
604
605 switch (reason)
606 {
607 case INFO_TIMEOUT:
608 if (play_data->tim NEQ NULL)
609 {
610 /* NOP on short info timeout && infinite:
611 * tone will be stopped and SUCCESS will be signalled by sat_play_tone_tim_cb()
612 */
613 play_data->info = NULL; /* signal the end of info to timer */
614 }
615 else
616 {
617 /* no timer (single tone) or timer timed out: we are the last */
618 if (play_data->sat_command NEQ NULL)
619 {
620 /* response not yet issued, i.e single tone with info */
621 sat_res[SAT_ERR_INDEX] = SatResSuccess;
622 sat_res[SAT_AI_INDEX] = SatResAiNoCause;
623 sat_done (play_data->sat_command, sat_res);
624 }
625
626 /* the last one has to destroy the window */
627 sat_play_tone_destroy (win);
628 }
629 break;
630 case INFO_KCD_LEFT:
631 case INFO_KCD_RIGHT:
632 case INFO_KCD_HUP: /*SPR#2340 - DS - Handle hangup keypress */
633 if (play_data->tim NEQ NULL)
634 {
635 /* timer has not yet elapsed, stop it */
636 tim_stop (play_data->tim);
637 }
638
639 /* API/DSM - 04/09/03 - SPR2491 - Add a call to stop the play of the continuous AUDIO sound*/
640 audio_StopSoundbyID(play_data->device_id, play_data->sound_id);
641 /* API/DSM - 04/09/03 - SPR2491 - END */
642
643 if (play_data->sat_command NEQ NULL)
644 {
645 /* response not yet issued */
646 sat_res[SAT_ERR_INDEX] = SAT_RES_USER_ABORT;
647 sat_res[SAT_AI_INDEX] = SatResAiNoCause;
648 sat_done (play_data->sat_command, sat_res);
649 }
650 sat_play_tone_destroy (win);
651 break;
652 }
653 break;
654
655 default:
656 TRACE_EVENT("sat_info_cb(): unexp. event");
657 break;
658 }
659 }