comparison src/aci2/bmi/mmiTimers.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/MmiTimers.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: MMI
15 $File: MmiTimers.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 22/02/01
20
21 ********************************************************************************
22
23 Description: This handles the storage of call times.
24
25
26 ********************************************************************************
27
28 $History: MmiTimers.c
29
30 25/10/00 Original Condat(UK) BMI version.
31 16/06/03 SPR#2142 - SH - Merged in MC's fix from 1.6 branch
32
33 $End
34
35 *******************************************************************************/
36 /*******************************************************************************
37
38 Include files
39
40 *******************************************************************************/
41 #define ENTITY_MFW
42
43 /* includes */
44 #include <string.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47
48 #if defined (NEW_FRAME)
49
50 #include "typedefs.h"
51 #include "vsi.h"
52 #include "pei.h"
53 #include "custom.h"
54 #include "gsm.h"
55
56 #else
57
58 #include "STDDEFS.H"
59 #include "custom.h"
60 #include "gsm.h"
61 #include "vsi.h"
62
63 #endif
64
65 #include "mfw_sys.h"
66 #include "prim.h"
67
68 #include "vsi.h"
69
70 #include "mfw_mfw.h"
71 #include "mfw_win.h"
72
73 #include "mfw_kbd.h"
74 /* SPR#1428 - SH - New Editor changes */
75 #ifndef NEW_EDITOR
76 #include "mfw_edt.h"
77 #endif
78 #include "mfw_lng.h"
79 #include "mfw_tim.h"
80 #include "mfw_icn.h"
81 #include "mfw_mnu.h"
82 #include "mfw_phb.h"
83 #include "mfw_cm.h"
84 #include "mfw_sim.h"
85 #include "mfw_nm.h"
86 #include "mfw_sat.h"
87 #include "mfw_phb.h"
88 #include "ksd.h"
89 #include "psa.h"
90 #include "mfw_sms.h"
91 #include "mfw_sat.h"
92
93 #include "dspl.h"
94
95 #include "gdi.h" //ES!!
96
97 #include "MmiMmi.h"
98 #include "MmiDummy.h"
99 #include "MmiDialogs.h"
100 #include "MmiLists.h"
101
102 #include "MmiSoftKeys.h"
103 #include "Mmiicons.h"
104 #include "MmiMenu.h"
105 #include "MmiMain.h"
106 #include "MmiIdle.h"
107 #include "MmiStart.h"
108 #include "MmiPins.h"
109 #include "MmiSounds.h"
110 #include "audio.h"
111 #include "cus_aci.h"
112
113 #include "MmiTimers.h"
114 #include "mfw_ffs.h"
115
116 #include "mmiColours.h"
117
118 /*******************************************************************************
119
120 Local Function Prototypes
121
122 *******************************************************************************/
123 /*SPR 2142 - removed timer_create() and timer_destroy() prototypes*/
124 unsigned long getLastCallDuration(void); // RAVI
125 void getTimerString(unsigned long time, char* timeString);
126 void setIncomingCallsDuration(long call_time);
127 unsigned long getIncomingCallsDuration( void );
128 void setOutgoingCallsDuration(long call_time);
129 unsigned long getOutgoingCallsDuration(void); // RAVI
130 static int timer_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
131 static int timer_reset_OK_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason);
132 void reset_timer_OK(T_MFW_HND parent, UBYTE Identifier);
133 void reset_timer(T_MFW_HND parent);
134
135 /*******************************************************************************
136
137 Local Data
138
139 *******************************************************************************/
140 static char timeString[30]; //static string for dialogs
141
142 UBYTE timer_type;/*SPR 2142 created global variable*/
143
144 /*******************************************************************************
145
146 Public Methods
147
148 *******************************************************************************/
149
150 /*******************************************************************************
151
152 $Function: setLastCallDuration
153
154 $Description: writes the duration of the last call to PCM and adds that duration to the
155 outgoing or incoming call total.
156
157 $Returns: none.
158
159 $Arguments: The call time and the call's direction (incoming or outgoing)
160
161 *******************************************************************************/
162 void setLastCallDuration(long call_time, T_MFW_CM_CALL_DIR call_direction)
163 {
164
165 TRACE_FUNCTION("setLastCallDuration()");
166
167 FFS_flashData.last_call_duration = call_time;
168
169
170
171 if (call_direction == MFW_CM_MTC)
172 setIncomingCallsDuration(call_time);
173 if (call_direction == MFW_CM_MOC)
174 setOutgoingCallsDuration(call_time);
175
176 return;
177 }
178
179 /*******************************************************************************
180
181 $Function: timerLastCall
182
183 $Description: handles user selction of "Last Call" in Call Timers Menu.
184 $Returns: status int
185
186 $Arguments: menu and menu item (neither used)
187
188 *******************************************************************************/
189 int timerLastCall(MfwMnu* m, MfwMnuItem* i)
190 { T_MFW_HND parent = mfwParent( mfw_header() );
191
192 T_DISPLAY_DATA display_info;
193
194
195 memset(timeString,'\0',sizeof(timeString));
196
197 timer_type = LAST_CALL;
198
199 TRACE_FUNCTION("timerLastCall()");
200 getTimerString((int)getLastCallDuration(), (char*)timeString);
201
202 dlg_initDisplayData_TextStr( &display_info, TxtSoftOK, TxtReset, timeString, NULL, COLOUR_STATUS_OKRESET);
203 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) timer_cb, SIX_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
204
205 /* Call Info Screen
206 */
207
208 info_dialog( parent, &display_info );
209
210
211 return MFW_EVENT_CONSUMED;
212
213 }
214
215 /*******************************************************************************
216
217 $Function: timerIncomingCalls
218
219 $Description: handles user selction of "Incoming Calls" in Call Timers Menu.
220 $Returns: status int
221
222 $Arguments: menu and menu item (neither used)
223
224 *******************************************************************************/
225 int timerIncomingCalls(MfwMnu* m, MfwMnuItem* i)
226 { T_MFW_HND parent = mfwParent( mfw_header() );
227 T_DISPLAY_DATA display_info;
228
229 //clear the editor-buffer before
230
231 timer_type = INCOMING_CALLS;
232 TRACE_FUNCTION("timerLastCall()");
233 getTimerString((int)getIncomingCallsDuration(), (char*)timeString);
234
235 dlg_initDisplayData_TextStr( &display_info, TxtSoftOK, TxtReset, timeString, NULL, COLOUR_STATUS_OKRESET);
236 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) timer_cb, SIX_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
237
238 /* Call Info Screen
239 */
240 info_dialog( parent, &display_info );
241
242
243 return MFW_EVENT_CONSUMED;
244
245 }
246
247 /*******************************************************************************
248
249 $Function: timerOutgoingCalls
250
251 $Description: handles user selction of "Outgoing Calls" in Call Timers Menu.
252 $Returns: status int
253
254 $Arguments: menu and menu item (neither used)
255
256 *******************************************************************************/
257 int timerOutgoingCalls(MfwMnu* m, MfwMnuItem* i)
258 { T_MFW_HND parent = mfwParent( mfw_header() );
259
260 T_DISPLAY_DATA display_info;
261
262 //clear the editor-buffer before
263 memset(timeString,'\0',sizeof(timeString));
264
265 timer_type = OUTGOING_CALLS;
266
267 TRACE_EVENT("timerLastCall()");
268 getTimerString((int)getOutgoingCallsDuration(), (char*)timeString);
269
270 dlg_initDisplayData_TextStr( &display_info, TxtSoftOK, TxtReset, timeString, NULL, COLOUR_STATUS_OKRESET);
271 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) timer_cb, SIX_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
272
273 /* Call Info Screen
274 */
275 info_dialog( parent, &display_info );
276
277
278 return MFW_EVENT_CONSUMED;
279
280 }
281
282
283
284
285
286 /*******************************************************************************
287
288 $Function: timer_cb
289
290 $Description: Callback func for the info display screen
291
292 $Returns: status int
293
294 $Arguments: Window, Identifier (which timer), Reason (which key pressed)
295
296 *******************************************************************************/
297 static int timer_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
298 {
299
300 switch (Reason)
301 {
302 case INFO_KCD_LEFT:
303
304 break;
305
306 case INFO_KCD_RIGHT:
307 reset_timer_OK(win, timer_type);
308 break;
309 }
310
311 return MFW_EVENT_CONSUMED;
312 }
313
314 /*******************************************************************************
315
316 $Function: setIncomingCallsDuration
317
318 $Description: Adds call time to Incoming Calls total
319 $Returns: none
320
321 $Arguments: call time
322
323 *******************************************************************************/
324
325 void setIncomingCallsDuration(long call_time)
326 {
327 TRACE_FUNCTION("setIncomingCallsDuration()");
328
329 //add call time to existing call time
330 call_time = call_time + getIncomingCallsDuration();
331 //save new value to flash
332 FFS_flashData.incoming_calls_duration = call_time;
333 flash_write();
334
335 return;
336 }
337
338 /*******************************************************************************
339
340 $Function: setOutgoingCalls
341
342 $Description: Adds call time to Outgoing Calls total
343 $Returns: none
344
345 $Arguments: call time
346
347 *******************************************************************************/
348 void setOutgoingCallsDuration(long call_time)
349 {
350
351 TRACE_FUNCTION("setOutgoingCallsDuration()");
352 //add call time to current total
353 call_time = call_time + getOutgoingCallsDuration();
354 FFS_flashData.outgoing_calls_duration = call_time;
355 //write to flash
356 flash_write();
357
358
359 return;
360
361 }
362
363
364 /*******************************************************************************
365
366 $Function: reset_timer_OK
367
368 $Description: displays "Are you sure you want to reset this timer" window
369 $Returns: none
370
371 $Arguments: parent window, identifier (which timer)
372
373 *******************************************************************************/
374 void reset_timer_OK(T_MFW_HND parent, UBYTE identifier)
375 {
376 T_DISPLAY_DATA display_info;
377
378
379 dlg_initDisplayData_TextId( &display_info, TxtSoftOK, TxtCancel, TxtPressOk, TxtReset, COLOUR_STATUS);
380 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) timer_reset_OK_cb, FOUR_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
381 display_info.Identifier = identifier;
382
383 info_dialog( parent, &display_info );
384 }
385
386
387 /*******************************************************************************
388
389 $Function: reset_timer_OK_cb
390
391 $Description: Callback function for "OK to Delete timer" window
392 $Returns: status int
393
394 $Arguments: window, identifier (which timer), Reason (which key pressed)
395
396 *******************************************************************************/
397 static int timer_reset_OK_cb(T_MFW_HND win, USHORT Identifier, USHORT Reason)
398 {
399
400 switch (Reason)
401 {
402 case INFO_KCD_LEFT:
403 {
404 switch (Identifier)
405 {
406 case LAST_CALL:
407 setLastCallDuration(0, MFW_CM_INV_DIR);
408 reset_timer(win);
409 /*SPR 2142, removed window destruction*/
410 break;
411 case INCOMING_CALLS:
412 resetIncomingCallsDuration();
413 reset_timer(win);
414 /*SPR 2142, removed window destruction*/
415 break;
416 case OUTGOING_CALLS:
417 resetOutgoingCallsDuration();
418 reset_timer(win);
419 /*SPR 2142, removed window destruction*/
420 break;
421 }
422 }
423 break;
424
425 case INFO_KCD_RIGHT:
426 {
427 /*SPR 2142, removed window destruction*/
428 }
429 break;
430 }
431
432 return MFW_EVENT_CONSUMED;
433 }
434
435
436 /*******************************************************************************
437
438 $Function: reset_timer
439
440 $Description: Dsiplays confirmation that timer has been reset.
441 $Returns: none
442
443 $Arguments: parent window
444
445 *******************************************************************************/
446 void reset_timer(T_MFW_HND parent)
447 {
448 T_DISPLAY_DATA display_info;
449
450 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, TxtTimerReset, TxtNull, COLOUR_STATUS);
451 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC) NULL, THREE_SECS, KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
452
453 info_dialog( parent, &display_info );
454 }
455
456 /*******************************************************************************
457
458 $Function: resetIncomingCallsDuration
459
460 $Description: Resets incoming call total to 0
461 $Returns: nothing
462
463 $Arguments: none
464
465 *******************************************************************************/
466 void resetIncomingCallsDuration( void )
467 {
468 TRACE_FUNCTION("resetIncomingCallsDuration()");
469 FFS_flashData.incoming_calls_duration =0;
470 flash_write();
471
472 }
473
474
475 /*******************************************************************************
476
477 $Function: resetOutgoingCallsDuration
478
479 $Description: Resets outgoing call total to 0
480 $Returns: nothing
481
482 $Arguments: none
483
484 *******************************************************************************/
485 void resetOutgoingCallsDuration( void )
486 {
487
488 TRACE_FUNCTION("resetOutgoingCallsDuration()");
489
490 FFS_flashData.outgoing_calls_duration = 0;
491 flash_write();
492
493 return;
494 }
495
496 /*******************************************************************************
497
498 $Function: getLastCallDuration
499
500 $Description: gets the length of the last call made/received from PCM storage
501 $Returns: length of call (long)
502
503 $Arguments: none
504
505 *******************************************************************************/
506 unsigned long getLastCallDuration()
507 {
508
509 return FFS_flashData.last_call_duration;;
510 }
511
512 /*******************************************************************************
513
514 $Function: getIncomingCallsDuration
515
516 $Description: gets the total length of incoming calls received from PCM storage
517 $Returns: length of calls (long)
518
519 $Arguments: none
520
521 *******************************************************************************/
522 unsigned long getIncomingCallsDuration()
523 {
524
525 return FFS_flashData.incoming_calls_duration;
526 }
527
528 /*******************************************************************************
529
530 $Function: getOutgoingCallsDuration
531
532 $Description: gets the total length of incoming calls received from PCM storage
533 $Returns: length of calls (long)
534
535 $Arguments: none
536
537 *******************************************************************************/
538 unsigned long getOutgoingCallsDuration()
539 {
540
541 return FFS_flashData.outgoing_calls_duration;
542 }
543
544
545 /*******************************************************************************
546
547 $Function: getTimerString
548
549 $Description: Converts a time in seconds into a string denoting hours, minutes and seconds
550
551 $Returns: none,
552
553 $Arguments: time pointer to string to store time
554
555 *******************************************************************************/
556 void getTimerString(unsigned long time, char* timeString)
557 {
558 // char* debug_buf; // RAVI
559 int hour,min,sec;
560 TRACE_FUNCTION("getTimerString()");
561 hour = time/3600;
562 min = (time-hour*3600)/60;
563 sec = (time-hour*3600-min*60);
564 //this prevents the time being too wide for the LCD display
565 if (hour > 999999)
566 hour = 999999;
567 sprintf(timeString,"%02d:%02d:%02d",hour,min,sec);
568
569 }
570