comparison src/ui3/bmi/mmiAoc.c @ 421:6a4d9f47793e

src/ui3/bmi: file renames to make the case consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:28:53 +0000
parents src/ui3/bmi/MmiAoc.c@e8ddbb0837ed
children
comparison
equal deleted inserted replaced
420:e8ddbb0837ed 421:6a4d9f47793e
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: Advice of Charge
15 $File: MmiVoiceMemo.c
16 $Revision: 1.0
17
18 $Author: Condat(UK)
19 $Date: 09/04/01
20
21 ********************************************************************************
22
23 Description:
24
25 This provides the start code for the MMI
26
27 ********************************************************************************
28 $History: MmiAoc.c
29 May 26, 2006 ER: OMAPS00079607 x0012849 :Jagannatha M
30 Description: CPHS: Display 'charge/Timers' menu based on AOC ( Advice of charge )
31 Solution:Made the following changes
32 1. Based on the value of Aoc_flag it will be decided to disply 'charge/Timers' menu or not.
33
34 June 16, 2005 REF: CRR 31267 x0021334
35 Description: Handset ignore the initializtion of the PIN1/PIN2
36 Fix: Cheking is done to ascertain if PIN1/PIN2 are initialised. If not, appropriate
37 message is displayed to the user.
38
39 09/04/01 Original Condat(UK) BMI version.
40 May 25, 2004 REF: CRR MMI-SPR-17588 NISHIKANT KULKARNI
41 Issue description: On the SIM EF(ACMMax) is defined as 0xFFFFFF, so it should be possible to
42 enter 16777215, but only 999999 is accepted.
43 Solution: MAX_ENTER_LIMIT changed from 7 to 9. A check is done to verify that the entered
44 ACMmax value is less that 0xFFFFFF. Otherwise "Not Allowed" message is displayed.
45
46 $End
47
48 *******************************************************************************/
49
50
51
52
53 /*******************************************************************************
54
55 Include files
56
57 *******************************************************************************/
58
59 #define ENTITY_MFW
60
61 /* includes */
62 #include <string.h>
63 #include <stdio.h>
64 #include <stdlib.h>
65
66 #if defined (NEW_FRAME)
67
68 #include "typedefs.h"
69 #include "vsi.h"
70 #include "pei.h"
71 #include "custom.h"
72 #include "gsm.h"
73
74 #else
75
76 #include "STDDEFS.H"
77 #include "custom.h"
78 #include "gsm.h"
79 #include "vsi.h"
80
81 #endif
82 #include "mfw_sys.h"
83
84 #include "cus_aci.h"
85
86 #include "mfw_mfw.h"
87 #include "mfw_win.h"
88 #include "mfw_kbd.h"
89 /* SPR#1428 - SH - New Editor changes */
90 #ifndef NEW_EDITOR
91 #include "mfw_edt.h"
92 #endif
93 #include "mfw_lng.h"
94 #include "mfw_tim.h"
95 #include "mfw_icn.h"
96 #include "mfw_mnu.h"
97 #include "mfw_phb.h"
98 #include "mfw_cm.h"
99 #include "mfw_sim.h"
100 #include "mfw_nm.h"
101 #include "mfw_sat.h"
102 #include "mfw_ss.h" /*for convert*/
103 #include "mfw_phb.h"
104 #include "ksd.h"
105 #include "psa.h"
106 #include "mfw_sms.h"
107 #include "mfw_cphs.h"
108 #include "mfw_sat.h"
109
110 #include "dspl.h"
111
112
113 #include "MmiMmi.h"
114 #include "MmiDummy.h"
115 #include "MmiDialogs.h"
116 /* SPR#1428 - SH - New Editor changes */
117 #ifdef NEW_EDITOR
118 #include "ATBCommon.h"
119 #include "ATBDisplay.h"
120 #include "ATBEditor.h"
121 #include "AUIEditor.h"
122 #else /* NEW_EDITOR */
123 #include "MmiEditor.h"
124 #endif /* NEW_EDITOR */
125 #include "MmiLists.h"
126 #include "MmiIdle.h"
127 #include "MmiSoftKeys.h"
128 #include "Mmiicons.h"
129 #include "MmiMenu.h"
130 #include "MmiMain.h"
131 #include "MmiStart.h"
132 #include "MmiPins.h"
133
134 #include "mmiColours.h"
135
136 // June 16, 2005 REF: CRR 31267 x0021334
137 // Added this BOOL variable to keep track of PIN2 requests.
138 BOOL pin2Flag = FALSE;
139
140
141 /*******************************************************************************
142 Local Data
143
144 *******************************************************************************/
145 #define PIN_REQUEST_FOR_RATE 700
146 #define SERVICES_ENTER_CURRENCY 701
147 #define SERVICES_ONE_UNIT 702
148 #define SERVICES_RATE_CHANGED 703
149 #define SERVICES_CREDIT_REMAINING 704
150 #define PIN_REQUEST_FOR_LIMIT_CHANGE 705
151 #define PIN_REQUEST_FOR_LIMIT_CANCEL 706
152 #define SERVICES_LIMIT_VIEW 707
153 #define SERVICES_LIMIT_CHANGE 708
154 #define SERVICES_LIMIT_CANCEL 709
155 #define SERVICES_LIMIT_CHANGED 710
156 #define SERVICES_LAST_CHARGE 711
157 #define SERVICES_TOTAL_CHARGE 712
158 #define SERVICES_RESET_CHARGE 713
159 #define SERVICES_CHARGE_CHANGED 714
160 #define SERVICES_OUT_OF_RANGE 715
161 #define SERVICES_AOC_NOT_SUPPORTED 716
162 #define PIN_REQUEST_FOR_RESET_CHARGE 717
163
164 /* May 25, 2004 REF: CRR MMI-SPR-17588 NISHIKANT KULKARNI
165 MAX_ENTER_LIMIT changed from 7 to 9 to accept "Limit" values till 16777215 (0xFFFFFF)
166 Previously, with MAX_ENTER_LIMIT set to 7, maximum 999999 could be entered as limit.
167 Effectively, the limit is MAX_ENTER_LIMIT - 1. The last character used for string termination.
168 Also, the maximum value that can be entered (0xFFFFFF) is # defined to MAX_ENTER_VALUE
169 */
170 /* Max. Enter of Character */
171 #define MAX_ENTER_LIMIT 9 // xnkulkar SPR-17588
172 #define MAX_ENTER_CURRENCY 4
173 #define MAX_ENTER_UNIT 6
174 #define MAX_ENTER_VALUE 0xFFFFFF // xnkulkar SPR-17588
175 /* */
176
177
178
179 typedef struct
180 {
181 T_MMI_CONTROL mmi_control;
182 T_MFW_HND service_win; /* MFW win handler */
183 T_MFW_CM_AOC_INFO aocInfo;
184 USHORT Identifier;
185 char edt_Buf[30]; /* Editor buffer */
186 } T_SERVICES;
187
188
189
190
191 LONG acm_last_call = 0; //accumulated call meter from the last call
192 //later the value should save and read again from PCM
193
194 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
195 #ifdef FF_CPHS
196 static UBYTE Aoc_flag = FALSE;
197 #endif
198
199 /*******************************************************************************
200 Local prototypes
201
202 *******************************************************************************/
203 T_MFW_HND service_Init (T_MFW_HND parent_window);
204 void service_Exit (T_MFW_HND own_window);
205 T_MFW_HND service_create (T_MFW_HND parent_window);
206 void service_destroy (T_MFW_HND own_window);
207 static int service_win_cb (T_MFW_EVENT event, T_MFW_WIN * win);
208 void service_dialog_cb (T_MFW_HND win, USHORT identifier, UBYTE reason);
209 void service (T_MFW_HND win, USHORT event, SHORT value, void * parameter);
210 /* SPR#1428 - SH - New Editor changes */
211 #ifdef NEW_EDITOR
212 void service_loadEditDefault (T_AUI_EDITOR_DATA *editor_data);
213 #else /* NEW_EDITOR */
214 void service_loadEditDefault (T_EDITOR_DATA *editor_data);
215 #endif /* NEW_EDITOR */
216 void service_calc_balance (T_MFW_HND win,char* line);
217 void service_calculate (T_MFW_HND win, char* line, long value);
218 USHORT service_check_pin_for_aoc (void);
219 //ADDED BY RAVI-29-11-2005
220 extern T_MFW_HND AUI_calc_Start(T_MFW_HND parent, T_AUI_EDITOR_DATA *editor_data);
221 // END RAVI
222
223 /*******************************************************************************
224 Functions
225
226 *******************************************************************************/
227
228 /*******************************************************************************
229
230 $Function: aoc_credit_remaining
231
232 $Description:
233
234 $Returns:
235
236 $Arguments:
237
238 *******************************************************************************/
239
240 int aoc_credit_remaining (MfwMnu* m, MfwMnuItem* i)
241 {
242 T_MFW_HND win = mfw_parent(mfw_header());
243
244 TRACE_FUNCTION("aoc_credit_remaining");
245
246 // create new dynamic dialog for the AOC
247 SEND_EVENT (service_Init (win), SERVICES_CREDIT_REMAINING, 0, 0);
248
249
250 return 0;
251 }
252
253
254
255 /*******************************************************************************
256
257 $Function: aoc_charge_rate
258
259 $Description: A security code editing screen is opened and Pin 2 requested.
260 Once entered successfully, an alpha. editor is opened with the
261 title "Enter currency".Once entered, an numeric editor is opened
262 with the title "Enter price p. unit". When the user has finished
263 entry the information screen " Rate changed" is displayed for
264 3 second and the phone returns to the previous sub-menu
265 $Returns:
266
267 $Arguments:
268
269 *******************************************************************************/
270
271
272 int aoc_charge_rate (MfwMnu* m, MfwMnuItem* i)
273 {
274 T_MFW_HND win = mfw_parent(mfw_header());
275
276 TRACE_FUNCTION("aoc_charge_rate");
277
278 switch (service_check_pin_for_aoc ())
279 {
280 case MFW_SIM_PIN2_REQ:
281 // June 16, 2005 REF: CRR 31267 x0021334
282 pin2Flag = TRUE;
283 // create new dynamic dialog for the AOC
284 SEND_EVENT (service_Init (win), PIN_REQUEST_FOR_RATE, 0, 0);
285 break;
286
287 case MFW_SIM_PIN_REQ:
288 case MFW_SIM_NO_PIN:
289 //pin 1 or no pin required, open now the editor for entering the currency
290 SEND_EVENT (service_Init (win), SERVICES_ENTER_CURRENCY, 0, 0);
291 break;
292
293 }
294
295 return 0;
296 }
297
298
299
300 /*******************************************************************************
301
302 $Function: aoc_view_limit
303
304 $Description:
305
306 $Returns:
307
308 $Arguments:
309
310 *******************************************************************************/
311
312
313 int aoc_view_limit (MfwMnu* m, MfwMnuItem* i)
314 {
315 T_MFW_HND win = mfw_parent(mfw_header());
316
317 TRACE_FUNCTION("aoc_view_limit");/*SPR2500*/
318
319
320 // create new dynamic dialog for the AOC
321 SEND_EVENT (service_Init (win), SERVICES_LIMIT_VIEW, 0, 0);
322
323 return 0;
324 }
325
326
327 /*******************************************************************************
328
329 $Function: aoc_change_limit
330
331 $Description:
332
333 $Returns:
334
335 $Arguments:
336
337 *******************************************************************************/
338
339
340 int aoc_change_limit (MfwMnu* m, MfwMnuItem* i)
341 {
342 T_MFW_HND win = mfw_parent(mfw_header());
343
344 TRACE_FUNCTION("aoc_change_limit");
345
346 /*SPR#1904 - DS - Added call to service_check_pin_for_aoc() to check if
347 *PIN2 entry is required.
348 */
349 switch (service_check_pin_for_aoc ())
350 {
351 case MFW_SIM_PIN2_REQ:
352 // June 16, 2005 REF: CRR 31267 x0021334
353 pin2Flag = TRUE;
354 // create new dynamic dialog for the AOC
355 SEND_EVENT (service_Init (win), PIN_REQUEST_FOR_LIMIT_CHANGE, 0, 0);
356 break;
357
358 case MFW_SIM_PIN_REQ:
359 case MFW_SIM_NO_PIN:
360 //pin 1 or no pin required, open now the editor for entering the currency
361 SEND_EVENT (service_Init (win), SERVICES_LIMIT_CHANGE, 0, 0);
362 break;
363
364 }
365
366 return 0;
367 }
368
369
370 /*******************************************************************************
371
372 $Function: aoc_cancel_limit
373
374 $Description:
375
376 $Returns:
377
378 $Arguments:
379
380 *******************************************************************************/
381
382
383 int aoc_cancel_limit (MfwMnu* m, MfwMnuItem* i)
384 {
385 T_MFW_HND win = mfw_parent(mfw_header());
386
387 TRACE_FUNCTION("aoc_charge_rate");
388
389 /*SPR#1904 - DS - Added call to service_check_pin_for_aoc() to check if
390 *PIN2 entry is required.
391 */
392 switch (service_check_pin_for_aoc ())
393 {
394 case MFW_SIM_PIN2_REQ:
395 // June 16, 2005 REF: CRR 31267 x0021334
396 pin2Flag = TRUE;
397 // create new dynamic dialog for the AOC
398 SEND_EVENT (service_Init (win), PIN_REQUEST_FOR_LIMIT_CANCEL, 0, 0);
399 break;
400
401 case MFW_SIM_PIN_REQ:
402 case MFW_SIM_NO_PIN:
403 //pin 1 or no pin required, open now the editor for entering the currency
404 SEND_EVENT (service_Init (win), SERVICES_LIMIT_CANCEL, 0, 0);
405 break;
406
407 }
408
409 return 0;
410 }
411
412 /*******************************************************************************
413
414 $Function: aoc_last_charge
415
416 $Description: Dispays the charge for the last call in the currency or in units
417 if no currency information has been entered
418
419 $Returns:
420
421 $Arguments:
422
423 *******************************************************************************/
424
425
426 int aoc_last_charge (MfwMnu* m, MfwMnuItem* i)
427 {
428 T_MFW_HND win = mfw_parent(mfw_header());
429
430 TRACE_FUNCTION("aoc_last_charge"); /*SPR2500*/
431
432 // create new dynamic dialog for the AOC
433 SEND_EVENT (service_Init (win), SERVICES_LAST_CHARGE, 0, 0);
434
435
436 return 0;
437 }
438
439 /*******************************************************************************
440
441 $Function: aoc_total_charge
442
443 $Description: Displays the charge for all calls since the chage counter was last reset
444
445 $Returns:
446
447 $Arguments:
448
449 *******************************************************************************/
450
451
452 int aoc_total_charge (MfwMnu* m, MfwMnuItem* i)
453 {
454 T_MFW_HND win = mfw_parent(mfw_header());
455
456 TRACE_FUNCTION("aoc_total_charge");/*SPR2500*/
457
458
459 // create new dynamic dialog for the AOC
460 SEND_EVENT (service_Init (win), SERVICES_TOTAL_CHARGE, 0, 0);
461
462
463 return 0;
464 }
465 /*******************************************************************************
466
467 $Function: aoc_reset_charge
468
469 $Description: Resets the charge counter for all calls
470
471 $Returns:
472
473 $Arguments:
474
475 *******************************************************************************/
476
477
478 int aoc_reset_charge (MfwMnu* m, MfwMnuItem* i)
479 {
480 T_MFW_HND win = mfw_parent(mfw_header());
481
482 TRACE_FUNCTION("aoc_reset_charge");/*SPR2500*/
483
484
485 switch (service_check_pin_for_aoc ())
486 {
487 case MFW_SIM_PIN2_REQ:
488 // June 16, 2005 REF: CRR 31267 x0021334
489 pin2Flag = TRUE;
490 // create new dynamic dialog for the AOC
491 SEND_EVENT (service_Init (win), PIN_REQUEST_FOR_RESET_CHARGE, 0, 0);
492 break;
493
494 case MFW_SIM_PIN_REQ:
495 case MFW_SIM_NO_PIN:
496 //pin 1 or no pin required, open now the editor for entering the currency
497 SEND_EVENT (service_Init (win), SERVICES_RESET_CHARGE, 0, 0);
498
499 break;
500 }
501
502 return 0;
503 }
504
505
506
507
508
509
510 /*******************************************************************************
511
512 $Function: service_Init
513
514 $Description:
515
516 $Returns:
517
518 $Arguments:
519
520 *******************************************************************************/
521 T_MFW_HND service_Init (T_MFW_HND parent_window)
522 {
523 return (service_create (parent_window));
524 }
525
526
527 /*******************************************************************************
528
529 $Function: service_Exit
530
531 $Description:
532
533 $Returns:
534
535 $Arguments:
536
537 *******************************************************************************/
538 void service_Exit (T_MFW_HND own_window)
539 {
540
541 T_MFW_WIN * win_data = ((T_MFW_HDR *)own_window)->data;
542 T_SERVICES * data = (T_SERVICES *)win_data->user;
543
544 TRACE_FUNCTION("service_Exit");
545 /*SPR 2500, check valid window pointer before destruction*/
546 if ((own_window) &&
547 (win_data) &&
548 (data) &&
549 (data->service_win))
550 {
551 service_destroy (data->service_win);
552 }
553 else
554 {
555 TRACE_ERROR("service_Exit : Invalid Pointer passed");
556 }
557
558 return;
559
560 }
561
562 /*******************************************************************************
563
564 $Function: service_create
565
566 $Description:
567
568 $Returns:
569
570 $Arguments:
571
572 *******************************************************************************/
573 T_MFW_HND service_create (T_MFW_HND parent_window)
574 {
575 T_SERVICES * data = (T_SERVICES *)ALLOC_MEMORY (sizeof (T_SERVICES));
576 T_MFW_WIN * win;
577
578
579 TRACE_FUNCTION ("service_create()");
580
581 data->service_win = win_create (parent_window, 0, 0, (T_MFW_CB)service_win_cb);
582
583 if (data->service_win EQ 0)
584 return 0;
585
586 /*
587 * Create window handler
588 */
589 data->mmi_control.dialog = (T_DIALOG_FUNC)service;
590 data->mmi_control.data = data;
591 win = ((T_MFW_HDR *)data->service_win)->data;
592 win->user = (void *) data;
593
594
595 winShow(data->service_win);
596 /*
597 * return window handle
598 */
599 return data->service_win;
600 }
601
602 /*******************************************************************************
603
604 $Function: service_destroy
605
606 $Description:
607
608 $Returns:
609
610 $Arguments:
611
612 *******************************************************************************/
613 void service_destroy (T_MFW_HND own_window)
614 {
615 T_MFW_WIN * win;
616 T_SERVICES * data;
617
618 TRACE_FUNCTION ("service_destroy()");
619
620 if (own_window)
621 {
622 win = ((T_MFW_HDR *)own_window)->data;
623 data = (T_SERVICES *)win->user;
624
625 if (data)
626 {
627
628 /*
629 * Delete WIN handler
630 */
631 win_delete (data->service_win);
632 data->service_win = 0;
633
634 FREE_MEMORY ((void *)data, sizeof (T_SERVICES));
635
636 }
637 }
638 }
639 /*******************************************************************************
640
641 $Function: service_win_cb
642
643 $Description:
644
645 $Returns:
646
647 $Arguments:
648
649 *******************************************************************************/
650 static int service_win_cb (T_MFW_EVENT event, T_MFW_WIN * win)
651 {
652 /*
653 * Top Window has no output
654 */
655 return 1;
656 }
657
658 /*******************************************************************************
659
660 $Function: service_dialog_cb
661
662 $Description:
663
664 $Returns:
665
666 $Arguments:
667
668 *******************************************************************************/
669 void service_dialog_cb(T_MFW_HND win, USHORT identifier, UBYTE reason)
670 {
671 TRACE_FUNCTION ("service_dialog_cb()");
672
673 switch (reason)
674 {
675 case INFO_KCD_LEFT:
676 /* no break; */
677 case INFO_TIMEOUT:
678 /* no break; */
679 case INFO_KCD_HUP:
680 /* no break; */
681 case INFO_KCD_RIGHT:
682 /* no break; */
683 case INFO_KCD_CLEAR:
684
685 TRACE_EVENT_P1("identifier: %d", identifier);
686
687 if (identifier EQ SERVICES_OUT_OF_RANGE)
688 {
689 TRACE_EVENT ("SERVICES_OUT_OF_RANGE");
690 SEND_EVENT (win, SERVICES_ONE_UNIT, 0, 0);
691 }
692 else
693 {
694 TRACE_EVENT (" destroy ");
695 service_Exit(win);
696 }
697 break;
698 }
699 }
700
701 /*******************************************************************************
702
703 $Function: service_editor_cb
704
705 $Description:
706
707 $Returns:
708
709 $Arguments:
710
711 *******************************************************************************/
712
713 static void service_editor_cb (T_MFW_HND win, USHORT Identifier, SHORT reason)
714 {
715 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
716 T_SERVICES * data = (T_SERVICES *)win_data->user;
717
718
719 UBYTE PWD[16], i;
720 int result;
721
722 TRACE_FUNCTION ("service_editor_cb()");
723 /*SPR 2500, check pointers valid*/
724 if ((!win) ||
725 (!win_data) ||
726 (!data))
727 {
728 TRACE_ERROR("service_editor_cb : Invalid Pointer passed");
729 return;
730 }
731
732 if ((!win) ||
733 (!win_data) ||
734 (!data))
735 {
736 TRACE_ERROR("service_editor_cb : Invalid Pointer passed");
737 return;
738 }
739
740 memset(PWD, 0x00, 16);
741
742 switch (reason)
743 {
744 case INFO_KCD_LEFT:
745 switch (Identifier)
746 {
747 case SERVICES_ENTER_CURRENCY:
748 TRACE_EVENT ("SERVICES_ENTER_CURRENCY");
749 TRACE_EVENT ("pressed left");
750
751
752 // clear old current currency before overwrite it
753 memset(data->aocInfo.cur, 0x80, sizeof(data->aocInfo.cur));
754
755 if(strlen(data->edt_Buf) NEQ 0)
756 {
757 memcpy(data->aocInfo.cur, data->edt_Buf, MAX_ENTER_CURRENCY);
758 }
759
760 //termination from ASCII to GSM default
761 for (i=0; i< MAX_ENTER_CURRENCY-1; i++)
762 {
763 if (data->aocInfo.cur[i] EQ '\0')
764 data->aocInfo.cur[i] = 0x80;
765 }
766
767
768 // open the next editor for entering the price per unit
769 SEND_EVENT (win, SERVICES_ONE_UNIT, 0, 0);
770 break;
771
772 case SERVICES_ONE_UNIT:
773 TRACE_EVENT ("SERVICES_ONE_UNIT");
774 TRACE_EVENT ("pressed left");
775
776 // clear old current ppu before overwrite it
777 memset(data->aocInfo.ppu, '\0', sizeof(data->aocInfo.ppu));
778
779 if(strlen(data->edt_Buf) NEQ 0)
780 {
781 memcpy(data->aocInfo.ppu, data->edt_Buf, strlen(data->edt_Buf));
782 }
783
784
785 // Password not necessary, Pin2 scenario done
786 memset(PWD, 0x00, 16);
787
788 // write cur and ppu in AOC
789 result = cm_set_aoc_value(CM_AOC_PUCT, &data->aocInfo, PWD);
790
791
792 TRACE_EVENT_P1("PPU : %s", data->aocInfo.ppu);
793 TRACE_EVENT_P1("CUR : %s", data->aocInfo.cur);
794 TRACE_EVENT_P1("result : %d", result);
795
796 if(result EQ CM_OK)
797 {
798 SEND_EVENT (win, SERVICES_RATE_CHANGED, 0, 0);
799 }
800 else
801 {
802 SEND_EVENT (win, SERVICES_OUT_OF_RANGE, 0, 0);
803 }
804
805 break;
806
807 case SERVICES_LIMIT_CHANGE:
808
809 // string => long
810 data->aocInfo.acm_max = atol(data->edt_Buf);
811
812 // Password not necessary, Pin2 scenario done
813 memset(PWD, 0x00, 16);
814
815 // May 25, 2004 REF: CRR MMI-SPR-17588 NISHIKANT KULKARNI
816
817 // If the ACMmax value entered by the user is more than 16777215 (0xFFFFFF),
818 // display a "Not Allowed" message.
819 if(data->aocInfo.acm_max > MAX_ENTER_VALUE)
820 {
821 // Send event to display a "Not Allowed" message.
822 SEND_EVENT (win, SERVICES_AOC_NOT_SUPPORTED, 0, 0);
823 }
824
825 // Else set the ACMmax value in AoC.
826 else
827 {
828 result = cm_set_aoc_value(CM_AOC_ACMMAX, &data->aocInfo, PWD); /* save ACMmax in AOC */
829
830 TRACE_EVENT_P1("%ld", data->aocInfo.acm_max);
831 TRACE_EVENT_P1("result of set aoc %d", result);
832
833 // Send event to display a "Limit Changed" message.
834 SEND_EVENT (win, SERVICES_LIMIT_CHANGED, 0, 0);
835 }
836
837 break;
838 case SERVICES_RESET_CHARGE:
839 /* MC 12/04/02: Changed ACMMAX to ACM (should fix "broken" SIM problem)*/
840
841 result = cm_set_aoc_value(CM_AOC_ACM, &data->aocInfo, PWD); /* save ACMmax in AOC */
842
843 }
844 break;
845
846 case INFO_KCD_RIGHT:
847 case INFO_KCD_CLEAR:
848
849 TRACE_EVENT ("INFO_KCD_RIGHT pressed");
850
851 switch (Identifier)
852 {
853
854 case SERVICES_LIMIT_CHANGE:
855 case SERVICES_ENTER_CURRENCY:
856
857 //go back to the previous screen
858 service_Exit (win);
859 break;
860 case SERVICES_ONE_UNIT:
861
862 //go back to the previous screen
863 SEND_EVENT (win, SERVICES_ENTER_CURRENCY, 0, 0);
864 break;
865
866
867 default:
868 break;
869 }
870 default:
871 break;
872 }
873 }
874
875
876 /*******************************************************************************
877
878 $Function: createAOCDialog
879
880 $Description: Creates a dialog from 4 input parameters
881
882 $Returns:
883
884 $Arguments:
885
886 *******************************************************************************/
887 static void createAOCDialog( T_MFW_HND win, USHORT txtId1, USHORT txtId2, char *str2, USHORT event )
888 {
889 T_DISPLAY_DATA display_info;
890
891 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtNull, txtId1, txtId2, COLOUR_AOC);
892 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)service_dialog_cb, THREE_SECS, KEY_CLEAR | KEY_RIGHT | KEY_LEFT );
893 display_info.Identifier = event;
894 display_info.TextString2 = str2;
895 info_dialog (win, &display_info);
896 }
897 /*******************************************************************************
898
899 $Function: service
900
901 $Description:
902
903 $Returns:
904
905 $Arguments:
906
907 *******************************************************************************/
908 void service (T_MFW_HND win, USHORT event, SHORT value, void * parameter)
909 {
910 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
911 T_SERVICES * data = (T_SERVICES *)win_data->user;
912
913 /* CQ13428 - NDH - Use dynamically allocated memory to prevent MMI Stack Overflow */
914 #ifdef NEW_EDITOR
915 /* SPR#1428 - SH - New Editor data */
916 T_AUI_EDITOR_DATA *editor_data = (T_AUI_EDITOR_DATA *)ALLOC_MEMORY (sizeof (T_AUI_EDITOR_DATA));
917 #else
918 T_EDITOR_DATA *editor_data = (T_EDITOR_DATA *)ALLOC_MEMORY (sizeof (T_EDITOR_DATA));
919 #endif
920 // T_MFW_SIM_PIN_STATUS status; // RAVI
921
922 UBYTE i, result;
923 UBYTE PWD[16];
924 static char line[MAX_LINE];
925
926 TRACE_FUNCTION("service()");
927
928 if (!editor_data)
929 {
930 TRACE_ERROR("service : Failed to allocate memory for the Editor Data");
931 return;
932 }
933 if ((!win) ||
934 (!win_data) ||
935 (!data))
936 {
937 TRACE_ERROR("service : Invalid Pointer passed");
938 /* CQ13428 - NDH - Use dynamically allocated memory to prevent MMI Stack Overflow */
939 #ifdef NEW_EDITOR
940 FREE_MEMORY((void *)editor_data, sizeof (T_AUI_EDITOR_DATA));
941 #else
942 FREE_MEMORY((void *)editor_data, sizeof (T_EDITOR_DATA));
943 #endif
944 return;
945 }
946
947 memset(PWD, 0x00, 16);
948 switch (event)
949 {
950
951 case SERVICES_CREDIT_REMAINING:
952
953 memset(line,'\0',sizeof(line));
954
955 //Get the ACM MAX
956 cm_get_aoc_value(CM_AOC_ACMMAX,&data->aocInfo);
957
958 //Get ACM
959 cm_get_aoc_value(CM_AOC_ACM,&data->aocInfo);
960
961 //Get currency and price per unit
962 cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo);
963
964
965 TRACE_EVENT_P1("ACMMAX: %ld", data->aocInfo.acm_max);
966 TRACE_EVENT_P1("ACM: %ld", data->aocInfo.acm);
967 TRACE_EVENT_P1("PPU:%s", data->aocInfo.ppu);
968 TRACE_EVENT_P1("CUR:%s", data->aocInfo.cur);
969
970
971 if ((data->aocInfo.acm_max NEQ '\0') && (data->aocInfo.acm NEQ '\0'))
972 {
973 /* special case: It is not possible to have ACM > ACMMAX */
974 /* this case the mobile has to disconnect */
975 if(data->aocInfo.acm > data->aocInfo.acm_max)
976 {
977 strcpy(line, "????");
978 }
979 else
980 {
981 /* calculate the credit with ACMAX and PPU */
982 TRACE_EVENT ("CREDIT :ACMMAX !=0 and PPU !=0");
983 service_calc_balance (win,(char*)line);
984
985 }
986 }
987 if ((data->aocInfo.acm_max EQ '\0') && (data->aocInfo.acm NEQ '\0'))
988 {
989 /* calculate the cost with ACM and PPU */
990 TRACE_EVENT ("CREDIT :ACMMAX ==0 and PPU !=0");
991 service_calculate (win, (char*)line, data->aocInfo.acm);
992
993 }
994 if ((data->aocInfo.acm_max EQ '\0') && (data->aocInfo.acm NEQ '\0') )
995 {
996 /* show only ACM */
997 TRACE_EVENT ("CREDIT :ACMMAX ==0 and PPU ==0");
998 sprintf(line, "%ld", data->aocInfo.acm); /* */
999 }
1000 if ((data->aocInfo.acm_max NEQ '\0') && (data->aocInfo.acm NEQ '\0'))
1001 {
1002 /* show only ACMAX */
1003 TRACE_EVENT ("CREDIT :ACMMAX !=0 and PPU ==0");
1004 sprintf(line, "%ld", data->aocInfo.acm_max - data->aocInfo.acm); /* */
1005 }
1006
1007 if (data->aocInfo.acm EQ '\0')
1008 strcpy ((char *)line, "0");
1009
1010 //from ASCII to GSM default
1011 for (i=0; i< MAX_LINE; i++)
1012 {
1013 if (line[i] EQ (char)0x80 OR line[i] EQ (char)0xFF ) /* x0039928 - Lint warning fix */
1014 line[i] = '\0';
1015 }
1016
1017
1018 if (data->aocInfo.acm_max EQ 0)
1019 {
1020 createAOCDialog( win, TxtCost, TxtNull, line, event);
1021 }
1022 else
1023 {
1024 createAOCDialog( win, TxtBalance, TxtNull, line, event);
1025 }
1026 break;
1027
1028
1029
1030
1031 case PIN_REQUEST_FOR_RATE:
1032 //save the status
1033 data->Identifier = SERVICES_ENTER_CURRENCY;
1034
1035 //PIN2 is requested to change the Rate
1036 pin2_check (data->service_win);
1037
1038 break;
1039
1040 case PIN_REQUEST_FOR_LIMIT_CHANGE:
1041
1042 //PIN2 is requested to change the Rate
1043 pin2_check (data->service_win);
1044
1045 //save the status
1046 data->Identifier = SERVICES_LIMIT_CHANGE;
1047 break;
1048
1049 case PIN_REQUEST_FOR_LIMIT_CANCEL:
1050
1051 //PIN2 is requested to change the Rate
1052 pin2_check (data->service_win);
1053
1054 //save the status
1055 data->Identifier = SERVICES_LIMIT_CANCEL;
1056 break;
1057
1058 case PIN_REQUEST_FOR_RESET_CHARGE:
1059 //save the status
1060 data->Identifier = SERVICES_RESET_CHARGE;
1061
1062 //PIN2 is requested to change the Rate
1063 pin2_check (data->service_win);
1064
1065 break;
1066
1067
1068 //it calls from MMI PINS
1069 case PIN2_OK:
1070 TRACE_EVENT("PIN2_OK");
1071
1072 switch (data->Identifier)
1073 {
1074 case SERVICES_ENTER_CURRENCY:
1075
1076 //pin was ok, open now the editor for entering the currency
1077 SEND_EVENT (win, data->Identifier, 0, 0);
1078 break;
1079 case SERVICES_LIMIT_CHANGE:
1080
1081 //pin was ok, open now the editor for entering the currency
1082 SEND_EVENT (win, data->Identifier, 0, 0);
1083 break;
1084 case SERVICES_LIMIT_CANCEL:
1085
1086 //pin was ok, open now the editor for entering the currency
1087 SEND_EVENT (win, data->Identifier, 0, 0);
1088 break;
1089 case SERVICES_RESET_CHARGE:
1090
1091 //pin was ok, open now the editor for entering the currency
1092 SEND_EVENT (win, data->Identifier, 0, 0);
1093 break;
1094
1095
1096
1097 }
1098 break;
1099
1100 case PIN2_ABORT:
1101 createAOCDialog( win, TxtFailed, TxtNull, line, event );
1102 break;
1103
1104 case SERVICES_ENTER_CURRENCY:
1105
1106
1107 //save the status
1108 data->Identifier = SERVICES_ENTER_CURRENCY;
1109
1110
1111 //PUCT (currency and price per unit) is requested
1112 result = cm_get_aoc_value(CM_AOC_PUCT, &data->aocInfo);
1113
1114 TRACE_EVENT_P1("result %d", result);
1115
1116 //fill up editor-sttribut with default
1117 service_loadEditDefault (editor_data);
1118
1119 //clear the editor-buffer
1120 memset(data->edt_Buf,'\0',sizeof(data->edt_Buf));
1121
1122 // let to show the current currency, before the user change it */
1123 memcpy(data->edt_Buf, data->aocInfo.cur, MAX_ENTER_CURRENCY);
1124
1125
1126 for (i=0; i< MAX_ENTER_CURRENCY-1; i++)
1127 {
1128 if (data->edt_Buf[i] EQ (char)0x80 OR data->edt_Buf[i] EQ (char)0xFF )
1129 data->edt_Buf[i] = '\0';
1130 }
1131
1132 /* SPR#1428 - SH - New Editor changes */
1133
1134 #ifdef NEW_EDITOR
1135 AUI_edit_SetBuffer(editor_data, ATB_DCS_ASCII, (UBYTE *)data->edt_Buf, MAX_ENTER_CURRENCY);
1136 AUI_edit_SetTextStr(editor_data, TxtSoftOK, TxtDelete, TxtEnterCurrency, NULL);
1137 AUI_edit_SetEvents(editor_data, data->Identifier, TRUE, FOREVER, (T_AUI_EDIT_CB)service_editor_cb);
1138 AUI_edit_SetMode(editor_data, ED_MODE_ALPHA, ED_CURSOR_BAR);
1139
1140 AUI_edit_Start(data->service_win, editor_data);
1141 #else /* NEW_EDITOR */
1142 editor_data->editor_attr.text = data->edt_Buf; /* buffer to be edited */
1143 editor_data->editor_attr.size = MAX_ENTER_CURRENCY;/* limit to 3 letters */
1144 editor_data->LeftSoftKey = TxtSoftOK;
1145 editor_data->RightSoftKey = TxtDelete;
1146 editor_data->TextId = TxtEnterCurrency;
1147 editor_data->Identifier = data->Identifier;
1148 editor_data->mode = ALPHA_MODE;
1149 editor_data->AlternateLeftSoftKey = TxtNull;
1150 editor_data->min_enter = 1;
1151
1152 /* create the dialog handler */
1153 editor_start(data->service_win, editor_data); /* start the editor */
1154 #endif /* NEW_EDITOR */
1155 break;
1156
1157
1158
1159 case SERVICES_ONE_UNIT:
1160
1161 //save the status
1162 data->Identifier = SERVICES_ONE_UNIT;
1163
1164 //fill up editor-sttribut with default
1165 service_loadEditDefault (editor_data);
1166
1167 //clear the editor-buffer
1168 memset(data->edt_Buf,'\0',sizeof(data->edt_Buf));
1169
1170 /* let to show the current price per unit, before the user change it */
1171 memcpy(data->edt_Buf, data->aocInfo.ppu, sizeof(data->aocInfo.ppu));
1172
1173 for (i=0; i< MAX_ENTER_UNIT-1; i++)
1174 {
1175 if (data->edt_Buf[i] EQ (char)0x80 OR data->edt_Buf[i] EQ (char)0xFF )
1176 data->edt_Buf[i] = '\0';
1177 }
1178
1179 /* SPR#1428 - SH - New Editor changes */
1180 #ifdef NEW_EDITOR
1181 AUI_edit_SetBuffer(editor_data, ATB_DCS_ASCII, (UBYTE *)data->edt_Buf, MAX_ENTER_UNIT);
1182 AUI_edit_SetTextStr(editor_data, TxtSoftOK, TxtDelete, Txt1Unit, NULL);
1183 AUI_edit_SetEvents(editor_data, data->Identifier, TRUE, FOREVER, (T_AUI_EDIT_CB)service_editor_cb);
1184 AUI_edit_SetMode(editor_data, 0, ED_CURSOR_BAR);
1185
1186 AUI_calc_Start(data->service_win, editor_data);
1187 #else /* NEW_EDITOR */
1188 editor_data->editor_attr.text = data->edt_Buf; /* buffer to be edited */
1189 editor_data->editor_attr.size = MAX_ENTER_UNIT;/* limit to 5 numerics */
1190 editor_data->LeftSoftKey = TxtSoftOK;
1191 editor_data->RightSoftKey = TxtDelete;
1192 editor_data->TextId = Txt1Unit;
1193 editor_data->Identifier = data->Identifier;
1194 editor_data->mode = CALC_MODE;
1195 editor_data->AlternateLeftSoftKey = TxtNull;
1196 editor_data->min_enter = 1;
1197
1198 /* create the dialog handler */
1199 editor_start(data->service_win, editor_data); /* start the editor */
1200 #endif /* NEW_EDITOR */
1201 break;
1202
1203
1204 case SERVICES_RATE_CHANGED:
1205 createAOCDialog( win, TxtRate, TxtChanged, NULL, event);
1206 break;
1207
1208 case SERVICES_LIMIT_VIEW:
1209
1210 memset(line,'\0',sizeof(line));
1211
1212 cm_get_aoc_value(CM_AOC_ACMMAX,&data->aocInfo); /* Get the ACM MAX */
1213 cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
1214
1215 TRACE_EVENT_P1("ACMMAX: %ld", data->aocInfo.acm_max);
1216 TRACE_EVENT_P1("ACM: %ld", data->aocInfo.acm);
1217 TRACE_EVENT_P1("PPU:%s", data->aocInfo.ppu);
1218 TRACE_EVENT_P1("CUR:%s", data->aocInfo.cur);
1219
1220 if((strlen((char*)data->aocInfo.ppu) EQ 0) && data->aocInfo.acm_max NEQ '\0')
1221 {
1222 sprintf(line, "%ld", data->aocInfo.acm_max); /* Show only ACMmax */
1223 TRACE_EVENT ("get only :ACMMAX ; PPU ==0 and ACMMAX!=0");
1224 }
1225 if((strlen((char*)data->aocInfo.ppu) NEQ 0) && data->aocInfo.acm_max NEQ '\0')
1226 {
1227 service_calculate (win, (char*)line, data->aocInfo.acm_max);
1228
1229 TRACE_EVENT ("calculate ACMMAX * PPU; PPU !=0 and ACMMAX!=0");
1230 }
1231
1232 for (i=0; i< MAX_LINE; i++)
1233 {
1234 if (line[i] EQ (char)0x80 OR line[i] EQ (char)0xFF )
1235 line[i] = '\0';
1236 }
1237
1238 if(data->aocInfo.acm_max NEQ '\0')
1239 {
1240 createAOCDialog( win, TxtLimitEq, TxtNull, line, event);
1241 }
1242 else
1243 {
1244 createAOCDialog( win, TxtNo, TxtLimit, NULL, event);
1245 }
1246
1247 /*
1248 * Call Info Screen
1249 */
1250
1251 break;
1252
1253 case SERVICES_LIMIT_CHANGE:
1254
1255 //fill up editor-sttribut with default
1256 service_loadEditDefault (editor_data);
1257
1258 //clear the editor-buffer
1259 memset(data->edt_Buf,'\0',sizeof(data->edt_Buf));
1260
1261 data->Identifier = SERVICES_LIMIT_CHANGE; /*SPR 2500*/
1262
1263
1264 data->Identifier = SERVICES_LIMIT_CHANGE;
1265
1266 /* SPR#1428 - SH - New Editor changes */
1267 #ifdef NEW_EDITOR
1268
1269 AUI_edit_SetBuffer(editor_data, ATB_DCS_ASCII, (UBYTE *)data->edt_Buf, MAX_ENTER_LIMIT);
1270 AUI_edit_SetTextStr(editor_data, TxtSoftOK, TxtDelete, TxtEnterLimit, NULL);
1271 AUI_edit_SetEvents(editor_data, data->Identifier, TRUE, FOREVER, (T_AUI_EDIT_CB)service_editor_cb);
1272 AUI_edit_SetMode(editor_data, 0, ED_CURSOR_BAR);
1273
1274 AUI_calc_Start(data->service_win, editor_data);
1275 #else /* NEW_EDITOR */
1276 editor_data->editor_attr.text = data->edt_Buf; /* buffer to be edited */
1277 editor_data->editor_attr.size = MAX_ENTER_LIMIT; /* limit to 6 terms of units */
1278 editor_data->LeftSoftKey = TxtSoftOK;
1279 editor_data->RightSoftKey = TxtDelete;
1280 editor_data->TextId = TxtEnterLimit;
1281 editor_data->Identifier = data->Identifier;
1282 editor_data->mode = CALC_MODE;
1283 editor_data->AlternateLeftSoftKey = TxtNull;
1284 editor_data->min_enter = 1;
1285
1286 /* create the dialog handler */
1287 editor_start(data->service_win, editor_data); /* start the editor */
1288 #endif /* NEW_EDITOR */
1289
1290 break;
1291 case SERVICES_LIMIT_CANCEL:
1292
1293 // clear the limit
1294 data->aocInfo.acm_max = 0;
1295
1296 // Password not necessary, Pin2 scenario done
1297 memset(PWD, 0x00, 16);
1298
1299 cm_set_aoc_value(CM_AOC_ACMMAX, &data->aocInfo, PWD); /* save ACMmax in AOC */
1300
1301 TRACE_EVENT_P1("%ld", data->aocInfo.acm_max);
1302
1303 SEND_EVENT (win, SERVICES_LIMIT_CHANGED, 0, 0);
1304
1305 break;
1306
1307 case SERVICES_LIMIT_CHANGED:
1308 createAOCDialog( win, TxtLimit, TxtChanged, NULL, event);
1309
1310 break;
1311
1312 case SERVICES_LAST_CHARGE:
1313
1314 cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
1315 cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
1316
1317 if ( strlen((char*)data->aocInfo.ppu) EQ 0 )
1318 {
1319 TRACE_EVENT ("get only :ACM ; PPU ==0 and ACM!=0");
1320
1321 /* show only the units ACM from last call */
1322 sprintf(line, "%ld", acm_last_call);
1323 }
1324 else
1325 {
1326 TRACE_EVENT ("get only :ACM ; PPU !=0 and ACM!=0");
1327
1328 /* add currency */
1329 sprintf(line, "%ld %s", acm_last_call, data->aocInfo.cur);
1330 }
1331
1332 if (acm_last_call EQ '\0')
1333 strcpy ((char *)line, "0");
1334
1335 createAOCDialog( win, TxtLastCharge, TxtNull, line, event);
1336 break;
1337
1338 case SERVICES_TOTAL_CHARGE:
1339
1340 memset(line,'\0',sizeof(line));
1341
1342 cm_get_aoc_value(CM_AOC_ACM,&data->aocInfo); /* Get the ACM */
1343 cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
1344
1345
1346 /* nm test only set the default */
1347
1348 TRACE_EVENT_P1("ACM: %ld", data->aocInfo.acm);
1349 TRACE_EVENT_P1("PPU:%s", data->aocInfo.ppu);
1350 TRACE_EVENT_P1("CUR:%s", data->aocInfo.cur);
1351
1352
1353 if((strlen((char*)data->aocInfo.ppu) EQ 0) && data->aocInfo.acm NEQ '\0')
1354 {
1355 //show only the units ACM
1356 sprintf(line, "%ld", data->aocInfo.acm);
1357 TRACE_EVENT ("get only :ACM ; PPU ==0 and ACM!=0");
1358
1359 }
1360 if((strlen((char*)data->aocInfo.ppu) NEQ 0) && data->aocInfo.acm NEQ '\0')
1361 {
1362
1363 /* Ref bug omaps00076109 */
1364 #ifdef NEPTUNE_BOARD
1365 sprintf(line, "%ld %s", data->aocInfo.acm, data->aocInfo.cur);
1366 #else
1367 service_calculate (win, (char*)line, data->aocInfo.acm);
1368 #endif
1369
1370 TRACE_EVENT ("calculate ACM * PPU; PPU !=0 and ACM!=0");
1371 }
1372
1373 if (data->aocInfo.acm EQ '\0')
1374 strcpy ((char *)line, "0");
1375
1376 createAOCDialog( win, TxtTotalCharge, TxtNull, line, event);
1377
1378 break;
1379
1380 case SERVICES_RESET_CHARGE:
1381
1382 // clear the charge counter for all calls
1383 data->aocInfo.acm = 0;
1384 acm_last_call = 0;
1385
1386 (void)cm_set_aoc_value(CM_AOC_ACM, &data->aocInfo, PWD); /* save ACM in AOC */
1387
1388 TRACE_EVENT_P1("%ld", data->aocInfo.acm);
1389
1390 SEND_EVENT (win, SERVICES_CHARGE_CHANGED, 0, 0);
1391
1392 break;
1393
1394 case SERVICES_CHARGE_CHANGED:
1395 createAOCDialog( win, TxtResetCharge, TxtNull, NULL, event);
1396 break;
1397 case SERVICES_OUT_OF_RANGE:
1398
1399 TRACE_EVENT("SERVICES_OUT_OF_RANGE");
1400 createAOCDialog( win, TxtOutofRange, TxtNull, NULL, event);
1401 break;
1402
1403 case SERVICES_AOC_NOT_SUPPORTED:
1404 TRACE_EVENT("SERVICES_NOT_ALLOWED");
1405 createAOCDialog( win, TxtNotAllowed, TxtNull, NULL, event);
1406 break;
1407
1408
1409 }
1410
1411 /* CQ13428 - NDH - Use dynamically allocated memory to prevent MMI Stack Overflow */
1412 #ifdef NEW_EDITOR
1413 FREE_MEMORY((void *)editor_data, sizeof (T_AUI_EDITOR_DATA));
1414 #else
1415 FREE_MEMORY((void *)editor_data, sizeof (T_EDITOR_DATA));
1416 #endif
1417 return;
1418 }
1419
1420
1421 /*******************************************************************************
1422
1423 $Function: service_loadEditDefault
1424
1425 $Description: fill up editor-sttribut with default
1426
1427 $Returns:
1428
1429 $Arguments:
1430
1431 *******************************************************************************/
1432 #ifdef NEW_EDITOR
1433 /* SPR#1428 - SH - New Editor changes */
1434 void service_loadEditDefault (T_AUI_EDITOR_DATA *editor_data)
1435 {
1436 TRACE_FUNCTION ("service_loadEditDefault()");
1437
1438 AUI_edit_SetDefault(editor_data);
1439 AUI_edit_SetDisplay(editor_data, ZONE_FULL_SK_TITLE, COLOUR_EDITOR, EDITOR_FONT);
1440 AUI_edit_SetEvents(editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)service_editor_cb);
1441 AUI_edit_SetTextStr(editor_data, TxtSoftSelect, TxtSoftBack, TxtNull, NULL);
1442 AUI_edit_SetMode(editor_data, 0, ED_CURSOR_UNDERLINE);
1443 AUI_edit_SetAltTextStr(editor_data, 1, TxtNull, FALSE, TxtNull);
1444 return;
1445 }
1446 #else /* NEW_EDITOR */
1447 void service_loadEditDefault (T_EDITOR_DATA *editor_data)
1448 {
1449 TRACE_FUNCTION ("service_loadEditDefault()");
1450
1451 editor_attr_init(&editor_data->editor_attr, ZONE_SMALL_EDITOR, edtCurBar1, NULL, NULL, 0, COLOUR_EDITOR);
1452 editor_data->editor_attr.font = 0;
1453
1454 editor_data_init( editor_data, (T_EDIT_CB)service_editor_cb, TxtSoftSelect, TxtSoftBack, TxtNull, 1, DIGITS_MODE, FOREVER);
1455 editor_data->hide = FALSE;
1456 editor_data->destroyEditor = TRUE;
1457 editor_data->AlternateLeftSoftKey = TxtNull;
1458 }
1459 #endif /* NEW_EDITOR */
1460
1461 /*******************************************************************************
1462
1463 $Function: service_calc_balance
1464
1465 $Description: Calculate the Credit remaining
1466
1467 $Returns:
1468
1469 $Arguments:
1470
1471 *******************************************************************************/
1472 void service_calc_balance (T_MFW_HND win,char* line)
1473 {
1474 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1475 T_SERVICES * data = (T_SERVICES *)win_data->user;
1476
1477
1478 char line2[MAX_LINE];
1479 char *pdest,*src,*dst,*POINT;
1480 LONG result;
1481 int ch = '.';
1482 UBYTE counter=0;
1483 if ((!win) ||
1484 (!win_data) ||
1485 (!data))
1486 {
1487 TRACE_ERROR("service_calc_balance : Invalid Pointer passed");
1488 return;
1489 }
1490
1491 /*SPR 2500, chack validity of pointers before continuing*/
1492 if ((!win) ||
1493 (!win_data) ||
1494 (!data))
1495 {
1496 TRACE_ERROR("service_calc_balance : Invalid Pointer passed");
1497 return;
1498 }
1499
1500 memset(line2,'\0',sizeof(line2));
1501
1502 cm_get_aoc_value(CM_AOC_ACMMAX,&data->aocInfo); /* Get the ACM MAX */
1503 cm_get_aoc_value(CM_AOC_ACM,&data->aocInfo); /* Get ACM */
1504 cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
1505
1506
1507
1508 /* Search for '.' */
1509 pdest =(char *) strchr((char*) data->aocInfo.ppu, ch );
1510
1511 if( pdest EQ NULL ) /* '.' not founded */
1512 {
1513 result = atol((char*)data->aocInfo.ppu ); /* STRING => LONG */
1514 result= result *(data->aocInfo.acm_max - data->aocInfo.acm); /* (ACMmax-ACM) * PPU */
1515 sprintf(line, "%ld %s", result,data->aocInfo.cur); /* LONG => STRING */
1516 }
1517 else /* '.' found */
1518 {
1519 /*
1520 * '.' found, *pdest EQ '.'
1521 */
1522 counter = strlen(pdest + 1); /* store the decimal place */
1523
1524 src = (char*)data->aocInfo.ppu;
1525 dst = line;
1526 do /* remove the '.' */
1527 {
1528 if (*src NEQ '.')
1529 {
1530 *dst++ = *src;
1531 }
1532 } while (*src++ NEQ '\0');
1533 /* STRING => LONG */
1534 result= (atol(line))*(data->aocInfo.acm_max - data->aocInfo.acm); /* (ACMmax - ACM) * PPU */
1535 sprintf(line, "%ld", result); /* LONG => STRING */
1536
1537 if(strlen(line) < counter)
1538 {
1539 src = line;
1540 dst = line2;
1541 *dst++ = '0';
1542 *dst++ = '.';
1543 counter = counter - strlen(line);
1544 do /* fill up with '0' */
1545 {
1546 *dst++ = '0';
1547 } while (--counter NEQ 0);
1548
1549 memcpy (dst,src,sizeof(src));
1550 sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
1551 return;
1552 }
1553 src = line;
1554 dst = line2;
1555 POINT= src + strlen(src) - counter;
1556 do /* set the '.' */
1557 {
1558 if (src EQ POINT)
1559 {
1560 *dst++ = '.';
1561 }
1562 *dst++ = *src++;
1563
1564 } while (*src NEQ '\0');
1565
1566 if (line2[0] EQ '.')
1567 sprintf(line, "0%s %s", line2,data->aocInfo.cur); /* add the currency */
1568
1569 if (line2[0] NEQ '.')
1570 sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
1571
1572 }
1573 return;
1574 }
1575
1576
1577 /*******************************************************************************
1578
1579 $Function: service_calculate
1580
1581 $Description: Calculate the value with price per unit and currency.
1582
1583 "value * PPU" @ currency
1584
1585 $Returns:
1586
1587 $Arguments:
1588
1589 *******************************************************************************/
1590
1591
1592 void service_calculate (T_MFW_HND win, char* line, long value)
1593 {
1594 T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
1595 T_SERVICES * data = (T_SERVICES *)win_data->user;
1596
1597 char line2[MAX_LINE];
1598 char *pdest,*src,*dst,*POINT;
1599 LONG result;
1600 int ch = '.';
1601 UBYTE counter=0;
1602
1603 /*SPR2500, check validity of pinters before continuing*/
1604 if ((!win) ||
1605 (!win_data) ||
1606 (!data))
1607 {
1608 TRACE_ERROR("service_calculate : Invalid Pointer passed");
1609 return;
1610 }
1611
1612 memset(line2,'\0',sizeof(line2));
1613
1614 cm_get_aoc_value(CM_AOC_ACM,&data->aocInfo); /* Get ACM */
1615 cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
1616
1617
1618 /* Search for '.' */
1619 pdest =(char *) strchr((char*) data->aocInfo.ppu, ch );
1620 if( pdest EQ NULL ) /* '.' not founded */
1621 {
1622 result = atol((char*)data->aocInfo.ppu ); /* STRING => LONG */
1623 result= result * value; /* value * PPU */
1624 sprintf(line, "%ld %s", result,data->aocInfo.cur); /* LONG => STRING */
1625 }
1626 else /* '.' found */
1627 {
1628 /*
1629 * '.' found, *pdest EQ '.'
1630 */
1631 counter = strlen(pdest + 1); /* store the decimal place */
1632
1633 src = (char*)data->aocInfo.ppu;
1634 dst = line;
1635 do /* remove the '.' */
1636 {
1637 if (*src NEQ '.')
1638 {
1639 *dst++ = *src;
1640 }
1641 } while (*src++ NEQ '\0');
1642
1643 /* STRING => LONG */
1644 result= atol(line) * value; /* value * PPU */
1645 sprintf(line, "%ld", result); /* LONG => STRING */
1646
1647 if(strlen(line) < counter)
1648 {
1649 src = line;
1650 dst = line2;
1651 *dst++ = '0';
1652 *dst++ = '.';
1653 counter = counter - strlen(line);
1654 do /* fill up with '0' */
1655 {
1656 *dst++ = '0';
1657 } while (--counter NEQ 0);
1658
1659 memcpy (dst,src,sizeof(src));
1660 sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
1661 return;
1662 }
1663 src = line;
1664 dst = line2;
1665 POINT= src + strlen(src) - counter;
1666 do /* set the '.' */
1667 {
1668 if (src EQ POINT)
1669 {
1670 *dst++ = '.';
1671 }
1672 *dst++ = *src++;
1673
1674 } while (*src NEQ '\0');
1675
1676 if (line2[0] EQ '.')
1677 sprintf(line, "0%s %s", line2,data->aocInfo.cur); /* add the currency */
1678
1679 if (line2[0] NEQ '.')
1680 sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
1681
1682 }
1683 return;
1684 }
1685
1686 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
1687 #ifdef FF_CPHS
1688 /*******************************************************************************
1689
1690 $Function: setAOCflag
1691
1692 $Description: set the value to Aoc_flag variable
1693
1694 $Returns:
1695
1696 $Arguments: TRUE or FALSE
1697
1698 *******************************************************************************/
1699 void setAOCflag(UBYTE aocValue)
1700 {
1701 Aoc_flag = aocValue;
1702 }
1703
1704
1705 /*******************************************************************************
1706
1707 $Function: getAOCflag
1708
1709 $Description: Rturns the value of variable Aoc_flag.
1710
1711 $Returns: value of Aoc_flag.
1712
1713 $Arguments:
1714
1715 *******************************************************************************/
1716 UBYTE getAOCflag(void)
1717 {
1718 return Aoc_flag;
1719 }
1720 #endif
1721
1722
1723 /*******************************************************************************
1724
1725 $Function: service_check_pin_for_aoc
1726
1727 $Description: this function check the PIN 2 requirement & availability of AOC
1728
1729 $Returns:
1730
1731 $Arguments:
1732
1733 *******************************************************************************/
1734 USHORT service_check_pin_for_aoc (void)
1735 {
1736 T_MFW_AOC_ACCESS access;
1737
1738 /* check PIN 2 requirement & availability of AOC */
1739 sim_configuration (NULL, NULL, NULL, NULL, NULL, &access);
1740
1741 TRACE_EVENT_P3("acm:%d acmmax:%d,puct:%d", access.access_acm,access.access_acmmax,access.access_puct);
1742 #ifdef FF_CPHS
1743 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
1744 //The 'Charge/Timers' menu should be displayed if CPHS is not supported.
1745 if (CphsPresent() != TRUE)
1746 {
1747 TRACE_EVENT("CPHS is not present in this SIM");
1748 setAOCflag(TRUE);
1749 }
1750 TRACE_EVENT_P1("Values: Aoc_flag = %d - 1 Indicates AOC is set in the CSP", getAOCflag());
1751 TRACE_EVENT_P1("status : cphs_status = %d ", CphsPresent());
1752 #endif
1753
1754 if (access.access_acm EQ MFW_SIM_PIN2 &&
1755 access.access_acmmax EQ MFW_SIM_PIN2 &&
1756 access.access_puct EQ MFW_SIM_PIN2)
1757 {
1758 TRACE_EVENT("PIN 2 required");
1759 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
1760 #ifdef FF_CPHS
1761 if (getAOCflag())
1762 return MFW_SIM_PIN2_REQ;
1763 else
1764 return MFW_SIM_NO_AOC;
1765 #else
1766 return MFW_SIM_PIN2_REQ;
1767 #endif
1768 }
1769 else if (access.access_acm EQ MFW_SIM_PIN1 &&
1770 access.access_acmmax EQ MFW_SIM_PIN1 &&
1771 access.access_puct EQ MFW_SIM_PIN1)
1772 {
1773 TRACE_EVENT("PIN 1 required");
1774 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
1775 #ifdef FF_CPHS
1776 if (getAOCflag())
1777 return MFW_SIM_PIN_REQ;
1778 else
1779 return MFW_SIM_NO_AOC;
1780 #else
1781 return MFW_SIM_PIN_REQ;
1782 #endif
1783 }
1784 else if (access.access_acm EQ MFW_SIM_NO_PIN &&
1785 access.access_acmmax EQ MFW_SIM_NO_PIN &&
1786 access.access_puct EQ MFW_SIM_NO_PIN)
1787 {
1788 TRACE_EVENT("No PIN required");
1789 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
1790 #ifdef FF_CPHS
1791 if (getAOCflag())
1792 return MFW_SIM_NO_PIN;
1793 else
1794 return MFW_SIM_NO_AOC;
1795 #else
1796 return MFW_SIM_NO_PIN;
1797 #endif
1798 }
1799 else if (access.access_acm EQ MFW_SIM_UNKNOWN &&
1800 access.access_acmmax EQ MFW_SIM_UNKNOWN &&
1801 access.access_puct EQ MFW_SIM_UNKNOWN)
1802 {
1803 TRACE_EVENT("AOC not supported");
1804 return MFW_SIM_FAILURE;
1805 }
1806 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
1807 #ifdef FF_CPHS
1808 else
1809 {
1810 TRACE_EVENT("AOC Else part");
1811 if (getAOCflag())
1812 return MFW_SIM_NO_PIN;
1813 else
1814 return MFW_SIM_NO_AOC;
1815 }
1816 #endif
1817
1818 }
1819
1820 /*******************************************************************************
1821
1822 $Function: service_check_aoc
1823
1824 $Description: If there is no support for AOC on SIM card
1825 the item "Charge Timers" will not Appear on the menulist
1826
1827 $Returns:
1828
1829 $Arguments:
1830
1831 *******************************************************************************/
1832 USHORT service_check_aoc (struct MfwMnuTag *m, struct MfwMnuAttrTag *ma, struct MfwMnuItemTag *mi)
1833 {
1834 TRACE_FUNCTION("service_check_aoc");
1835
1836 switch (service_check_pin_for_aoc ())
1837 {
1838 case MFW_SIM_PIN2_REQ:
1839 case MFW_SIM_PIN_REQ:
1840 case MFW_SIM_NO_PIN:
1841 TRACE_EVENT("AOC item visible");
1842 return 0;
1843 /*break;*/
1844
1845 case MFW_SIM_FAILURE:
1846 //x0012849: Jagannatha 26 May, 2006 ER: OMAPS00079607 -Support AOC in CPHS
1847 #ifdef FF_CPHS
1848 case MFW_SIM_NO_AOC:
1849 TRACE_EVENT("service_check_aoc - AOC item not visible");
1850 #endif
1851 return 1;
1852 /*break;*/
1853 }
1854 return 1;
1855 }
1856
1857