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