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

initial import: leo2moko-r1
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 01 Jun 2015 03:24:05 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 /*******************************************************************************
2
3 CONDAT (UK)
4
5 ********************************************************************************
6
7 This software product is the property of Condat (UK) Ltd and may not be
8 disclosed to any third party without the express permission of the owner.
9
10 ********************************************************************************
11
12 $Project name:
13 $Project code:
14 $Module:
15 $File: MmiGprs.c
16 $Revision:
17
18 $Author: Condat(UK)
19 $Date:
20
21 ********************************************************************************
22
23 Description:
24 GPRS handling for MMI.
25
26
27 ********************************************************************************
28
29 $History: MmiGprs.c
30
31 Feb 24, 2006 REF:DR OMAPS00068976 x0035544
32 Description: GPRS attach icon - MMI follow up issue of OMAPS00051034
33 solution: a Check is added for the idle mode display and querry the GPRS status of
34 network registration and update the GPRS state and attach icon display accordingly.
35
36 15/05/2003 - SPR#1983 - SH - Updated to latest from 1.6.3 version.
37
38 Dec 02, 2005 REF: DR OMAPS00048551 x0039928
39 Description: MMI Cloud displays ""GPRS Detached"" in place
40 of ""GPRS Not Attached"" when unable to attach..
41 Solution: A condition is added to check if the request is for attach and then display
42 "GPRS Not Attached" in case it fails.
43
44 Dec 01, 2005 REF: DR OMAPS00048530 x0039928
45 Description: After the GPRS detach the MMI shows it is attached.
46 Solution: A check is made to display "GPRS Attached" only when an GPRS attach is
47 requested but not when GPRS detach is request.
48
49 Jun 14, 2005 REF: MMI-FIX-30439 x0018858
50 Description: The homezone/cityzone tags were not being displayed properly.
51 Solution: Modified to save the tags properly in caches and also made the
52 appropriate modifications to update the same properly during mobility.
53
54 $End
55
56 *******************************************************************************/
57
58 #define ENTITY_MFW
59
60 /* Switch for tracing*/
61 #define TRACE_MMIGPRS
62
63 #ifdef TRACE_MMIGPRS
64 #define trace(x) TRACE_EVENT(x)
65 #define tracefunction(x) TRACE_FUNCTION(x)
66 #define trace_P1(x,a) TRACE_EVENT_P1(x,a)
67 #define trace_P2(x,a,b) TRACE_EVENT_P2(x,a,b)
68 #define trace_P3(x,a,b,c) TRACE_EVENT_P3(x,a,b,c)
69 #define trace_P4(x,a,b,c,d) TRACE_EVENT_P4(x,a,b,c,d)
70 #define trace_P5(x,a,b,c,d,e) TRACE_EVENT_P5(x,a,b,c,d,e)
71 #define trace_P6(x,a,b,c,d,e,f) TRACE_EVENT_P6(x,a,b,c,d,e,f)
72 #else
73 #define trace(x) /* */
74 #define tracefunction(x) /* */
75 #define trace_P1(x,a) /* */
76 #define trace_P2(x,a,b) /* */
77 #define trace_P3(x,a,b,c) /* */
78 #define trace_P4(x,a,b,c,d) /* */
79 #define trace_P5(x,a,b,c,d,e) /* */
80 #define trace_P6(x,a,b,c,d,e,f) /* */
81 #endif
82
83 #include <string.h>
84 #include <stdio.h>
85 #include <stdlib.h>
86
87 #if defined (NEW_FRAME)
88
89 #include "typedefs.h"
90 #include "vsi.h"
91 #include "pei.h"
92 #include "custom.h"
93 #include "gsm.h"
94
95 #else
96
97 #include "STDDEFS.H"
98 #include "custom.h"
99 #include "gsm.h"
100 #include "vsi.h"
101
102 #endif
103 #include "mfw_sys.h"
104
105 #include "cus_aci.h"
106
107 #include "mfw_mfw.h"
108 #include "mfw_win.h"
109 #include "mfw_kbd.h"
110 /* New Editor changes */
111 #ifndef NEW_EDITOR
112 #include "mfw_edt.h"
113 #endif
114 #include "mfw_lng.h"
115 #include "mfw_tim.h"
116 #include "mfw_icn.h"
117 #include "mfw_mnu.h"
118 #include "mfw_phb.h"
119 #include "mfw_cm.h"
120 #include "mfw_sim.h"
121 #include "mfw_nm.h"
122 #include "mfw_sat.h"
123 #include "mfw_ss.h" /*for convert*/
124 #include "mfw_phb.h"
125 #include "ksd.h"
126 #include "psa.h"
127 #include "mfw_sms.h"
128 #include "mfw_cphs.h"
129 #include "mfw_sat.h"
130 #include "message.h"
131 #include "prim.h"
132 #include "aci_cmh.h" /* include types declared in ACI */
133 #include "gaci_cmh.h" /* include types declared in GACI */
134
135 #ifdef FF_2TO1_PS
136 #include "aci_all.h"
137 #include "ati_cmd.h"
138 #include "aci_cmd.h"
139 #include "aci.h"
140 #include "dti_conn_mng.h"
141 #include "dti_cntrl_mng.h"
142 #include "gaci.h" /* include types declared in GACI */
143 #endif
144
145 #include "mfw_gprs.h"
146 #include "dspl.h"
147
148 #include "MmiGprs.h"
149 #include "MmiBookShared.h"
150
151 #include "Mmiicons.h" /* Including this header allows us to access the global icon status, for the GPRS icon.*/
152 #include "mmiSmsBroadcast.h" /* Including this to get the info_screen function */
153 /* New Editor changes. Need editor for counter display */
154 #ifdef NEW_EDITOR
155 #include "ATBCommon.h"
156 #include "ATBDisplay.h"
157 #include "ATBEditor.h"
158 #include "AUIEditor.h"
159 #else
160 #include "MmiEditor.h"
161 #endif
162 #include "MmiBookUtils.h"
163 #include "MmiBookMenuWindow.h" /* So we can use bookMenuStart() to create our own menus */
164
165 #include "mmiColours.h"
166
167 static T_MMI_GPRS_DATA *gprs_data=NULL;
168
169 /*******************************************************************************
170
171 $Function: GPRS_Data
172
173 $Description: Initialise GPRS
174
175 $Returns: Handler for MFW GPRS events.
176
177 $Arguments: None.
178
179 *******************************************************************************/
180
181 T_MMI_GPRS_DATA *GPRS_Data(void)
182 {
183 if (gprs_data==NULL)
184 {
185 TRACE_EVENT("***ERROR*** MMI GPRS not initialised properly");
186 }
187
188 return gprs_data;
189 }
190
191 /*******************************************************************************
192
193 $Function: GPRS_Init
194
195 $Description: Initialise GPRS
196
197 $Returns: Handler for MFW GPRS events.
198
199 $Arguments: None.
200
201 *******************************************************************************/
202
203 void GPRS_Init(void)
204 {
205 T_MMI_GPRS_DATA *data;
206
207 tracefunction("GPRS_Init()");
208
209 gprs_init();
210
211 /* Allocate memory for mmi data */
212 data = (T_MMI_GPRS_DATA *)ALLOC_MEMORY(sizeof(T_MMI_GPRS_DATA));
213 gprs_data = data;
214 memset(data, 0, sizeof(T_MMI_GPRS_DATA));
215
216 data->mfw_gprs = gprs_create(0, E_MFW_GPRS_ALL_EVENTS, (MfwCb)GPRS_MfwCb);
217 data->cid = GPRS_CID_OMITTED;
218 data->uplink_counter = 0;
219 data->downlink_counter = 0;
220 data->sms_service = SMS_SERVICE_OMITTED;
221 data->display = FALSE;
222 data->notify_win = NULL;
223 data->callback = NULL;
224 data->reg_status = GPRS_OFF;
225
226 return;
227 }
228
229
230 /*******************************************************************************
231
232 $Function: GPRS_SetCallback
233
234 $Description: Specify a callback function, where GPRS connection information will
235 be sent, or NULL to switch off notification.
236
237 $Returns: None.
238
239 $Arguments: win - window handler, or NULL
240 callback - callback function, or NULL
241
242 *******************************************************************************/
243
244 void GPRS_SetCallback(T_MFW_HND win, T_GPRS_CB callback)
245 {
246 T_MMI_GPRS_DATA *data = GPRS_Data();
247
248 tracefunction("GPRS_SetCallback()");
249
250 if (!data)
251 {
252 return;
253 }
254
255 data->notify_win = win;
256 data->callback = callback;
257
258 return;
259 }
260
261
262 /*******************************************************************************
263
264 $Function: GPRS_Exit
265
266 $Description: Exit GPRS
267
268 $Returns: None.
269
270 $Arguments: None.
271
272 *******************************************************************************/
273
274 void GPRS_Exit(void)
275 {
276 T_MMI_GPRS_DATA *data = GPRS_Data();
277
278 tracefunction("GPRS_Exit()");
279
280 if (data)
281 {
282 /* Delete any remaining please wait window (just in case!)*/
283 GPRS_PleaseWaitDestroy();
284
285 /* Delete the MFW module */
286 if (data->mfw_gprs)
287 {
288 gprs_delete(data->mfw_gprs);
289 }
290
291 /* Delete MMI data */
292 FREE_MEMORY((void *)data, sizeof(T_MMI_GPRS_DATA));
293 gprs_data = NULL;
294 }
295
296 gprs_exit();
297 return;
298 }
299
300
301 /*******************************************************************************
302
303 $Function: GPRS_Status
304
305 $Description: Return status of GPRS.
306
307 $Returns: GPRS_OFF, GPRS_NOT_ATTACHED, GPRS_ATTACHED
308
309 $Arguments: None.
310
311 *******************************************************************************/
312
313 int GPRS_Status(void)
314 {
315 T_MMI_GPRS_DATA *data = GPRS_Data();
316 T_MFW_GPRS *gprs;
317 int result;
318
319 tracefunction("GPRS_Status()");
320
321 if (!data)
322 {
323 return GPRS_OFF;
324 }
325
326 /* Keeps track of last status value, so we only need to call callback when a change occurs.
327 * Default state is GPRS OFF */
328
329 iconsDeleteState(iconIdGPRSOn);
330 result = GPRS_OFF;
331
332 /* Check if searching or attached */
333
334 if (data->mfw_gprs)
335 {
336 gprs = ((T_MFW_HDR *)data->mfw_gprs)->data;
337 //x0035544 Feb 23, 2006 DR:OMAPS00068976
338 /* Check for the idle mode and querry the status of network registration
339 *and update the GPRS state and attach icon display accordingly */
340 if (gprs && (idleIsFocussed() ||data->menu_win == NULL) )
341 {
342 gprs->data.Reg_state.p_reg_State = p_gprs_status();
343
344 trace_P1("GPRS_Status: p_regState = %d", gprs->data.Reg_state.p_reg_State);
345
346 if (gprs->data.Reg_state.p_reg_State ==P_CGREG_STAT_SEARCHING)
347 {
348 result = GPRS_SEARCHING;
349 }
350
351 /* Check regState rather than attached to find GPRS status */
352
353 else if (gprs->data.Reg_state.p_reg_State == P_CGREG_STAT_REG_HOME ||
354 gprs->data.Reg_state.p_reg_State == P_CGREG_STAT_REG_ROAM )
355 {
356 iconsSetState(iconIdGPRSOn);
357 result = GPRS_ATTACHED;
358 }
359 else if(gprs->data.Reg_state.p_reg_State == P_CGREG_STAT_NO_CELL ||
360 gprs->data.Reg_state.p_reg_State == P_CGREG_STAT_LIMITED ||
361 gprs->data.Reg_state.p_reg_State == P_CGREG_STAT_UNKN ||
362 gprs->data.Reg_state.p_reg_State == P_CGREG_STAT_REG_DEN ||
363 gprs->data.Reg_state.p_reg_State == P_CGREG_STAT_NOT_REG)
364 {
365 iconsDeleteState(iconIdGPRSOn );
366 result = GPRS_ERROR;
367 }
368
369 }
370 else if (gprs )
371 {
372 //x0035544 Feb 23, 2006 DR:OMAPS00068976
373 gprs->data.Reg_state.regState = gprs_status();
374
375 trace_P1("GPRS_Status: regState = %d", gprs->data.Reg_state.regState);
376 //x0035544 Feb 23, 2006 DR:OMAPS00068976
377 if (gprs->data.Reg_state.regState==CGREG_STAT_SEARCHING)
378 {
379 result = GPRS_SEARCHING;
380 }
381
382 /* Check regState rather than attached to find GPRS status */
383 //x0035544 Feb 23, 2006 DR:OMAPS00068976
384 else if (gprs->data.Reg_state.regState==CGREG_STAT_REG_HOME || gprs->data.Reg_state.regState ==CGREG_STAT_REG_ROAM)
385 {
386 iconsSetState(iconIdGPRSOn);
387 result = GPRS_ATTACHED;
388 }
389 }
390 }
391
392 /* If status has changed, notify */
393 if (data->callback!=NULL && result!=data->reg_status)
394 {
395 data->callback(result);
396 }
397
398 data->reg_status = result;
399
400 return result;
401 }
402
403 /*******************************************************************************
404
405 $Function: GPRS_ResultScreen
406
407 $Description: Displays a result and returns GPRS to idle status
408
409 $Returns: None.
410
411 $Arguments: parent_win - the parent window
412 TextId1 - the first text string to be shown
413 TextId2 - the second text string to be shown
414
415 [afo 03/10/03] Moved function to an earlier location in the file and changed
416 the return type to void. We were taking liberties with C which we
417 got away with using the TI compiler but which Visual C flagged as
418 an error.
419
420 We seem to be a bit slack on function scope and return values in
421 some cases in this file.
422
423 *******************************************************************************/
424
425 static void GPRS_ResultScreen(T_MFW_HND parent_win, USHORT TextId1, USHORT TextId2)
426 {
427 T_MMI_GPRS_DATA *data = GPRS_Data();
428
429 tracefunction("GPRS_ResultScreen()");
430
431 if (!data)
432 {
433 return;
434 }
435
436 GPRS_PleaseWaitDestroy();
437
438 info_screen(parent_win, TextId1, TextId2, NULL);
439
440 data->display = FALSE;
441
442 return;
443 }
444
445 /*******************************************************************************
446
447 $Function: GPRS_Attach
448
449 $Description: Attempts an attach to the GPRS network.
450
451 $Returns: MMI_GPRS_STATUS_ATTACHING or MMI_GPRS_STATUS_IDLE
452
453 $Arguments: win - Parent window - if this is provided, status dialogues will be shown
454
455 *******************************************************************************/
456
457 int GPRS_Attach(T_MFW_HND win)
458 {
459 T_MMI_GPRS_DATA *data = GPRS_Data();
460
461 tracefunction("GPRS_Attach()");
462
463 if (!data)
464 {
465 return;
466 }
467
468 data->status = MMI_GPRS_STATUS_ATTACHING;
469
470 if (win)
471 {
472 GPRS_PleaseWait(win, TxtPleaseWait, NULL);
473 }
474
475 /* Perform the attach */
476
477 if (gprs_attach(CGATT_STATE_ATTACHED)==MFW_RES_OK)
478 {
479 trace("GPRSAttach executing, awaiting confirmation.");
480 }
481 else
482 {
483 /* Show result */
484 if (win)
485 {
486 GPRS_ResultScreen(win, TxtFailed, TxtNull);
487 }
488 data->status = MMI_GPRS_STATUS_IDLE;
489 }
490
491 return data->status;
492 }
493
494
495 /*******************************************************************************
496
497 $Function: GPRS_Detach
498
499 $Description: Detach from the GPRS network.
500
501 $Returns: MMI_GPRS_STATUS_DETACHING or MMI_GPRS_STATUS_IDLE
502
503 $Arguments: None
504
505 *******************************************************************************/
506
507 int GPRS_Detach(T_MFW_HND win)
508 {
509 T_MMI_GPRS_DATA *data = GPRS_Data();
510
511 tracefunction("GPRS_Detach()");
512
513 if (!data)
514 {
515 return;
516 }
517
518 data->status = MMI_GPRS_STATUS_DETACHING;
519
520 if (win)
521 {
522 GPRS_PleaseWait(win, TxtPleaseWait, NULL);
523 }
524
525 if (gprs_attach(CGATT_STATE_DETACHED)==MFW_RES_OK)
526 {
527 trace("GPRSDetach executing, awaiting confirmation.");
528 }
529 else
530 {
531 if (win)
532 {
533 GPRS_ResultScreen(win, TxtFailed, TxtNull);
534 }
535 data->status = MMI_GPRS_STATUS_IDLE;
536 }
537
538 return data->status;
539 }
540
541
542 /*******************************************************************************
543
544 $Function: GPRS_ContextDefine
545
546 $Description: Define a PDP context
547
548 $Returns: TRUE if successful, FALSE otherwise
549
550 $Arguments: cid - Context ID
551 IPAddress - IP address of context
552 APN - Access Point Name of context
553
554 *******************************************************************************/
555 #ifdef FF_2TO1_PS
556 int GPRS_ContextDefine(SHORT cid, char *IPAddress, char *APN)
557 {
558 static T_PDP_CONTEXT context;
559
560 strcpy(context.pdp_apn, APN);
561 strcpy(context.pdp_type, "IP");
562 strcpy((char*)context.pdp_addr.ip_address.ipv4_addr.a4, (char*)IPAddress);
563
564 context.pdp_addr.ctrl_ip_address = NAS_is_ipv4;
565 context.d_comp = CGDCONT_D_COMP_OMITTED;
566 context.h_comp = CGDCONT_H_COMP_OMITTED;
567 // memset(&context.qos,0,sizeof(T_PS_qos));
568 // memset(&context.min_qos,0,sizeof(T_PS_qos));
569
570 if (gprs_definePDPContext(cid, &context)!=MFW_RES_OK)
571 {
572 return FALSE;
573 }
574
575 return TRUE;
576 }
577 #else
578 int GPRS_ContextDefine(SHORT cid, char *IPAddress, char *APN)
579 {
580 static T_GPRS_CONT_REC context;
581
582 strcpy(context.apn, APN);
583 strcpy(context.pdp_type, "IP");
584 strcpy(context.pdp_addr, IPAddress);
585 context.d_comp = CGDCONT_D_COMP_OMITTED;
586 context.h_comp = CGDCONT_H_COMP_OMITTED;
587 memset(&context.qos,0,sizeof(T_QOS));
588 memset(&context.min_qos,0,sizeof(T_QOS));
589
590 if (gprs_definePDPContext(cid, &context)!=MFW_RES_OK)
591 {
592 return FALSE;
593 }
594
595 return TRUE;
596 }
597 #endif
598
599
600 /*******************************************************************************
601
602 $Function: GPRS_ContextActivate
603
604 $Description: Activates a PDP context
605
606 $Returns: TRUE if successful, FALSE otherwise
607
608 $Arguments: cid - Context ID
609
610 *******************************************************************************/
611
612 int GPRS_ContextActivate(SHORT cid)
613 {
614 SHORT cids[2];
615
616 tracefunction("GPRS_ContextActivate()");
617
618 cids[0] = cid;
619 cids[1] = 0;
620
621 if (gprs_contextActivation(CGACT_STATE_ACTIVATED, cids)==MFW_RES_OK)
622 {
623 trace("GPRS_ContextActivate: Failed.");
624 return FALSE;
625 }
626
627 trace("GPRS_ContextActivate: Executing, awaiting confirmation.");
628 return TRUE;
629 }
630
631
632 /*******************************************************************************
633
634 $Function: GPRS_ContextDeactivate
635
636 $Description: Dectivates a PDP context
637
638 $Returns: TRUE if successful, FALSE otherwise
639
640 $Arguments: cid - Context ID
641
642 *******************************************************************************/
643
644 int GPRS_ContextDeactivate(SHORT cid)
645 {
646 SHORT cids[2];
647
648 tracefunction("GPRS_ContextDeactivate()");
649
650 cids[0] = cid;
651 cids[1] = 0;
652
653 if (gprs_contextActivation(CGACT_STATE_DEACTIVATED, cids)==MFW_RES_OK)
654 {
655 trace("GPRS_ContextDeactivate: Failed.");
656 return FALSE;
657 }
658
659 trace("GPRS_ContextDeactivate: Executing, awaiting confirmation.");
660 return TRUE;
661 }
662
663
664 /*******************************************************************************
665
666 $Function: GPRS_SetQOS
667
668 $Description: Set quality of service
669
670 $Returns: TRUE if succeeded, FALSE if failed
671
672 $Arguments: cid - context ID
673 preced...etc. - quality of service parameters
674
675 *******************************************************************************/
676
677 #ifdef FF_2TO1_PS
678 int GPRS_SetQOS(SHORT cid, UBYTE preced, UBYTE delay, UBYTE relclass, UBYTE peak, UBYTE mean)
679 {
680 T_PS_qos QOS;
681
682 tracefunction("GPRS_SetQOS()");
683
684 QOS.qos_r97.preced = preced;
685 QOS.qos_r97.delay = delay;
686 QOS.qos_r97.relclass = relclass;
687 QOS.qos_r97.peak = peak;
688 QOS.qos_r97.mean = mean;
689
690 if (gprs_setQOS(cid, &QOS)!=MFW_RES_OK)
691 {
692 trace("GPRS_MenuSetQOS: Failed");
693 return FALSE;
694 }
695
696 trace("GPRS_MenuSetQOS: OK");
697
698 return TRUE;
699 }
700 #else
701 int GPRS_SetQOS(SHORT cid, UBYTE preced, UBYTE delay, UBYTE relclass, UBYTE peak, UBYTE mean)
702 {
703 T_QOS QOS;
704
705 tracefunction("GPRS_SetQOS()");
706
707 QOS.preced = preced;
708 QOS.delay = delay;
709 QOS.relclass = relclass;
710 QOS.peak = peak;
711 QOS.mean = mean;
712
713 if (gprs_setQOS(cid, &QOS)!=MFW_RES_OK)
714 {
715 trace("GPRS_MenuSetQOS: Failed");
716 return FALSE;
717 }
718
719 trace("GPRS_MenuSetQOS: OK");
720
721 return TRUE;
722 }
723 #endif
724
725 /*******************************************************************************
726
727 $Function: GPRS_SetMinQOS
728
729 $Description: Set minimum quality of service
730
731 $Returns: TRUE if succeeded, FALSE if failed
732
733 $Arguments: cid - context ID
734 preced...etc. - quality of service parameters
735
736 *******************************************************************************/
737
738 #ifdef FF_2TO1_PS
739 int GPRS_SetMinQOS(SHORT cid, UBYTE preced, UBYTE delay, UBYTE relclass, UBYTE peak, UBYTE mean)
740 {
741 T_PS_qos QOS;
742
743 tracefunction("GPRS_SetMinQOS()");
744
745 QOS.qos_r97.preced = preced;
746 QOS.qos_r97.delay = delay;
747 QOS.qos_r97.relclass = relclass;
748 QOS.qos_r97.peak = peak;
749 QOS.qos_r97.mean = mean;
750
751 if (gprs_setQOSMin(cid, &QOS)!=MFW_RES_OK)
752 {
753 trace("GPRS_MenuSetMinQOS: Failed");
754 return FALSE;
755 }
756
757 trace("GPRS_MenuSetMinQOS: OK");
758
759 return TRUE;
760 }
761 #else
762 int GPRS_SetMinQOS(SHORT cid, UBYTE preced, UBYTE delay, UBYTE relclass, UBYTE peak, UBYTE mean)
763 {
764 T_QOS QOS;
765
766 tracefunction("GPRS_SetMinQOS()");
767
768 QOS.preced = preced;
769 QOS.delay = delay;
770 QOS.relclass = relclass;
771 QOS.peak = peak;
772 QOS.mean = mean;
773
774 if (gprs_setQOSMin(cid, &QOS)!=MFW_RES_OK)
775 {
776 trace("GPRS_MenuSetMinQOS: Failed");
777 return FALSE;
778 }
779
780 trace("GPRS_MenuSetMinQOS: OK");
781
782 return TRUE;
783 }
784 #endif
785
786 /*******************************************************************************
787
788 $Function: GPRS_SmsService
789
790 $Description: Return SMS Service type
791
792 $Returns: SMS_SERVICE_xxx
793
794 $Arguments: None.
795
796 *******************************************************************************/
797
798 UBYTE GPRS_SmsService(void)
799 {
800 T_MMI_GPRS_DATA *data = GPRS_Data();
801
802 tracefunction("GPRS_SmsService");
803
804 if (!data)
805 {
806 return SMS_SERVICE_OMITTED;
807 }
808
809 return data->sms_service;
810 }
811
812
813 /*******************************************************************************
814
815 $Function: GPRS_SetSmsService
816
817 $Description: Set SMS Service type
818
819 $Returns: TRUE if set proceeded OK
820
821 $Arguments: None.
822
823 *******************************************************************************/
824
825 UBYTE GPRS_SetSmsService(UBYTE service)
826 {
827 T_MMI_GPRS_DATA *data = GPRS_Data();
828 T_CGSMS_SERVICE ACISmsService;
829 UBYTE old_service = 0; // RAVI - Assignment - 29-11-2005
830
831 tracefunction("GPRS_SetSmsService");
832 trace_P1("Service: %d", service);
833
834 switch(service)
835 {
836 case SMS_SERVICE_GPRS:
837 ACISmsService = CGSMS_SERVICE_GPRS;
838 break;
839 case SMS_SERVICE_CS:
840 ACISmsService = CGSMS_SERVICE_CS;
841 break;
842 case SMS_SERVICE_GPRS_PREF:
843 ACISmsService = CGSMS_SERVICE_GPRS_PREFERRED;
844 break;
845 case SMS_SERVICE_CS_PREF:
846 ACISmsService = CGSMS_SERVICE_CS_PREFERRED;
847 break;
848 default:
849 ACISmsService = CGSMS_SERVICE_CS;
850 break;
851 }
852
853 if (data)
854 {
855 old_service = data->sms_service;
856 data->sms_service = service;
857 }
858
859 if (gprs_setServiceSMS(ACISmsService) != MFW_RES_OK)
860 {
861 trace("gprs_setServiceSMS failed");
862 /* Failed - set service back to old value */
863 if (data)
864 {
865 data->sms_service = old_service;
866 }
867 return FALSE;
868 }
869
870 return TRUE;
871 }
872
873
874 /*******************************************************************************
875
876 $Function: GPRS_MfwCb
877
878 $Description: Callback function for MFW GPRS events.
879
880 $Returns:
881
882 $Arguments: Event number and generic parameter.
883
884 *******************************************************************************/
885
886 static int GPRS_MfwCb(T_MFW_EVENT event, void* para)
887 {
888
889 T_MMI_GPRS_DATA *data = GPRS_Data();
890 T_MFW_HND win = mfwParent( mfw_header());
891 T_MFW_GPRS_DATA *gprs_data = (T_MFW_GPRS_DATA *)para; // Structure that stores data from mfw
892 USHORT textId;
893 int result;
894
895 tracefunction("GPRS_MfwCb()");
896
897 if (!data)
898 {
899 return FALSE; // RAVI
900 }
901
902 /* Result of GPRS_NOTHING will not be sent */
903
904 result = GPRS_NOTHING;
905
906 /* Find GPRS status */
907
908 if (idleIsFocussed())
909 {
910 /* Update idle screen icons to show any change in GPRS status */
911 iconsShow();
912 }
913 else
914 {
915 /* iconsShow calls GPRS_Status; if we don't call that, call this on its own */
916 GPRS_Status();
917 }
918
919 switch(event)
920 {
921 case E_MFW_GPRS_S_CNTXT:
922 trace("GPRS_MfwCb: E_MFW_GPRS_S_CNTXT");
923 break;
924
925 case E_MFW_GPRS_S_ATT:
926 trace("GPRS_MfwCb: E_MFW_GPRS_S_ATT");
927
928 // Dec 01, 2005 REF: DR OMAPS00048530 x0039928
929 // Fix : Set the current status to attaching or detaching depending on the request.
930 if (data->reg_status!= GPRS_ATTACHED)
931 data->status = MMI_GPRS_STATUS_ATTACHING;
932 else
933 data->status = MMI_GPRS_STATUS_DETACHING;
934
935 if (data->display)
936 {
937 if (data->reg_status!= GPRS_ATTACHED)
938 {
939 /* Previous please wait will be destroyed and this new message shown */
940 GPRS_PleaseWait(win, TxtGPRS, TxtAttaching);
941 }
942 else
943 {
944 /* MZ cq10952 Info string */
945 GPRS_PleaseWait(win, TxtGPRS, TxtDetaching);
946 }
947 }
948 break;
949
950 case E_MFW_GPRS_S_ACT:
951 trace("GPRS_MfwCb: E_MFW_GPRS_S_ACT");
952
953 /* Notify of context activation */
954 result = GPRS_CONTEXT_ACTIVATE;
955 break;
956
957 case E_MFW_GPRS_R_ACT:
958 trace("GPRS_MfwCb: E_MFW_GPRS_R_ACT");
959
960 /* Notify of context activation */
961 result = GPRS_CONTEXT_ACTIVATE;
962 break;
963
964 case E_MFW_GPRS_S_DATA:
965 trace("GPRS_MfwCb: E_MFW_GPRS_S_DATA");
966 break;
967
968 case E_MFW_GPRS_R_DATA:
969 trace("GPRS_MfwCb: E_MFW_GPRS_R_DATA");
970 break;
971
972 case E_MFW_GPRS_S_QOS:
973 trace("GPRS_MfwCb: E_MFW_GPRS_S_QOS");
974 break;
975
976 case E_MFW_GPRS_R_QOS:
977 trace("GPRS_MfwCb: E_MFW_GPRS_R_QOS");
978 break;
979
980 case E_MFW_GPRS_S_QOS_MIN:
981 trace("GPRS_MfwCb: E_MFW_GPRS_S_QOS_MIN");
982 break;
983
984 case E_MFW_GPRS_S_CLASS:
985 trace("GPRS_MfwCb: E_MFW_GPRS_S_CLASS");
986 break;
987
988 case E_MFW_GPRS_S_PDPADDR:
989 trace("GPRS_MfwCb: E_MFW_GPRS_S_PDPADDR");
990 break;
991
992 case E_MFW_GPRS_S_AUTORESP:
993 trace("GPRS_MfwCb: E_MFW_GPRS_S_AUTORESP");
994 break;
995
996 case E_MFW_GPRS_S_ANS:
997 trace("GPRS_MfwCb: E_MFW_GPRS_S_ANS");
998 break;
999
1000 case E_MFW_GPRS_R_ANS:
1001 trace("GPRS_MfwCb: E_MFW_GPRS_R_ANS");
1002 break;
1003
1004 case E_MFW_GPRS_S_EREP:
1005 trace("GPRS_MfwCb: E_MFW_GPRS_S_EREPG");
1006 break;
1007
1008 case E_MFW_GPRS_R_EREP_RJ:
1009 trace("GPRS_MfwCb: E_MFW_GPRS_R_EREP_RJ");
1010
1011 /* Notify of context deactivation */
1012
1013 result = GPRS_CONTEXT_DEACTIVATE;
1014 break;
1015
1016 case E_MFW_GPRS_R_EREP_ATT:
1017 trace("GPRS_MfwCb: E_MFW_GPRS_R_EREP_ATT");
1018
1019 /* Attach status has changed, display message as appropriate */
1020
1021 if (data->display)
1022 {
1023 if (data->reg_status==GPRS_ATTACHED)
1024 textId = TxtAttached;
1025 else
1026 textId = TxtNotAttached;
1027
1028 /* Show result */
1029 GPRS_ResultScreen(win, TxtGPRS, textId);
1030 }
1031 data->status = MMI_GPRS_STATUS_IDLE;
1032
1033 break;
1034
1035 case E_MFW_GPRS_R_EREP_ACT:
1036 trace("GPRS_MfwCb: E_MFW_GPRS_R_EREP_ACT");
1037
1038 /* Notify of context activation */
1039 result = GPRS_CONTEXT_ACTIVATE;
1040 break;
1041
1042 case E_MFW_GPRS_R_EREP_DEACT:
1043 trace("GPRS_MfwCb: E_MFW_GPRS_R_EREP_DEACT");
1044
1045 /* Notify of context deactivation */
1046 result = GPRS_CONTEXT_DEACTIVATE;
1047 break;
1048
1049 case E_MFW_GPRS_R_EREP_CLASS:
1050 trace("GPRS_MfwCb: E_MFW_GPRS_R_EREP_CLASS");
1051 break;
1052
1053 case E_MFW_GPRS_R_REG:
1054 trace("GPRS_MfwCb: E_MFW_GPRS_R_REG");
1055 //x0035544 Feb 23, 2006 DR:OMAPS00068976
1056 trace_P1("regState: %d", gprs_data->Reg_state.p_reg_State);
1057
1058 switch (data->reg_status)
1059 {
1060 case GPRS_ATTACHED:
1061 #ifdef MMI_HOMEZONE_ENABLED
1062 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858
1063 //begin 30439
1064 /* Cell reselection for homezone */
1065 homezoneUpdate(gprs_data->lac, gprs_data->ci, 0);
1066 //end 30439
1067 #endif
1068 // Dec 01, 2005 REF: DR OMAPS00048530 x0039928
1069 // Fix : Display GPRS attached only if the request is for attaching.
1070 if(data->status == MMI_GPRS_STATUS_ATTACHING)
1071 {
1072 /* Show result */
1073 if (data->display)
1074 {
1075 GPRS_ResultScreen(win, TxtGPRS, TxtAttached);
1076 }
1077 }
1078 data->status = MMI_GPRS_STATUS_IDLE;
1079 break;
1080
1081 case GPRS_OFF:
1082 #ifdef MMI_HOMEZONE_ENABLED
1083 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858
1084 //begin 30439
1085 /* Cell reselection for homezone */
1086 homezoneUpdate(0,0,0);
1087 //end 30439
1088 #endif
1089 // Dec 02, 2005 REF: DR OMAPS00048551 x0039928
1090 // Fix : Display GPRS not attached if gprs attach fails
1091 // and the current status is attaching.
1092 if(data->status == MMI_GPRS_STATUS_ATTACHING)
1093 {
1094 /* Show result */
1095 if (data->display)
1096 {
1097 GPRS_ResultScreen(win, TxtGPRS, TxtNotAttached);
1098 }
1099 }
1100 else
1101 {
1102 /* Show result */
1103 if (data->display)
1104 {
1105 GPRS_ResultScreen(win, TxtGPRS, TxtDetached);
1106 }
1107 }
1108 data->status = MMI_GPRS_STATUS_IDLE;
1109 break;
1110
1111 case GPRS_SEARCHING: /* not registered, searching */
1112 #ifdef MMI_HOMEZONE_ENABLED
1113 //Jun 14, 2005 REF: MMI-FIX-30439 x0018858
1114 //begin 30439
1115 /* Cell reselection for homezone */
1116 homezoneUpdate(0, 0, 0);
1117 //end 30439
1118 #endif
1119 data->status = MMI_GPRS_STATUS_ATTACHING;
1120 if (data->display)
1121 {
1122 GPRS_PleaseWait(win, TxtGPRS, TxtSearching); /* SPR#1986 */
1123 }
1124 break;
1125
1126 default:
1127 data->status = MMI_GPRS_STATUS_IDLE;
1128 /* Show result */
1129 if (data->display)
1130 {
1131 GPRS_ResultScreen(win, TxtGPRS, TxtError);
1132 }
1133 break;
1134 }
1135
1136 break;
1137
1138 case E_MFW_GPRS_S_SMSSERV:
1139 trace("GPRS_MfwCb: E_MFW_GPRS_S_SMSSERV");
1140 trace_P1("Service: %d", data->sms_service);
1141
1142 data->status = MMI_GPRS_STATUS_IDLE;
1143
1144 /* Display "Using <service>" */
1145
1146 if (data->display)
1147 {
1148 USHORT TxtId2, TxtId1 = TxtUsing;
1149 switch(data->sms_service)
1150 {
1151 case SMS_SERVICE_GPRS: /* GPRS */
1152 TxtId2 = TxtGPRS;
1153 break;
1154 case SMS_SERVICE_CS: /* circuit switched */
1155 TxtId2 = TxtCSD;
1156 break;
1157 case SMS_SERVICE_GPRS_PREF: /* GPRS preferred */
1158 TxtId2 = TxtGPRSPreferred;
1159 break;
1160 case SMS_SERVICE_CS_PREF: /* circuit switched preferred */
1161 TxtId2 = TxtCSDPreferred;
1162 break;
1163 default: /* Shouldn't happen, but... */
1164 TxtId1 = TxtFailed;
1165 TxtId2 = TxtNull;
1166 break;
1167 }
1168
1169 /* Show result */
1170 GPRS_ResultScreen(win, TxtId1, TxtId2);
1171 }
1172 break;
1173
1174 case E_MFW_GPRS_OK:
1175 trace("GPRS_MfwCb: E_MFW_GPRS_OK");
1176 break;
1177
1178 case E_MFW_GPRS_ERROR:
1179 trace("GPRS_MfwCb: E_MFW_GPRS_ERROR");
1180
1181 data->status = MMI_GPRS_STATUS_IDLE;
1182
1183 /* Display "GPRS Error" */
1184
1185 if (data->display)
1186 {
1187 /* Delete please wait window */
1188 GPRS_PleaseWaitDestroy();
1189
1190 /* Show result */
1191 GPRS_ResultScreen(win, TxtGPRS, TxtFailed);
1192 }
1193
1194 /* Notify of error */
1195 result = GPRS_ERROR;
1196 break;
1197
1198 case E_MFW_GPRS_CONNECT:
1199 trace("GPRS_MfwCb: E_MFW_GPRS_CONNECT");
1200
1201 data->status = MMI_GPRS_STATUS_IDLE;
1202
1203 if (data->display)
1204 {
1205 /* Delete please wait window */
1206 GPRS_PleaseWaitDestroy();
1207
1208 /* Display "CONNECTED" window */
1209 info_screen(win, TxtGPRS, TxtConnected, NULL);
1210 }
1211 break;
1212
1213 case E_MFW_GPRS_ERR_CONNECT:
1214 trace("GPRS_MfwCb: E_MFW_GPRS_ERR_CONNECT");
1215
1216 data->status = MMI_GPRS_STATUS_IDLE;
1217
1218 /* Display "GPRS No Answer" */
1219 if (data->display)
1220 {
1221 /* Show result */
1222 GPRS_ResultScreen(win, TxtGPRS, TxtNoAnswer);
1223 }
1224 break;
1225
1226 case E_MFW_GPRS_COUNTER:
1227 trace("GPRS_MfwCb: E_MFW_GPRS_COUNTER");
1228
1229 /* Add values returned from ACI
1230 * to total counter */
1231
1232 data->uplink_counter += (ULONG)(gprs_data->counter.octets_uplink);
1233 data->downlink_counter += (ULONG)(gprs_data->counter.octets_downlink);
1234
1235 /* Only display counter if user has requested it */
1236
1237 if (data->display)
1238 {
1239 data->display = FALSE;
1240 /* Delete please wait window */
1241 GPRS_PleaseWaitDestroy();
1242
1243 GPRS_ShowCounter(win);
1244 }
1245 break;
1246
1247 default:
1248 trace_P1("GPRS_MfwCb: event = %d", event);
1249 break;
1250 }
1251
1252 /* Send a notification if appropriate */
1253
1254 if (data->callback!=NULL && result!=GPRS_NOTHING)
1255 {
1256 data->callback(result);
1257 }
1258
1259 return TRUE;
1260 }
1261
1262
1263 /*******************************************************************************
1264
1265 $Function: GPRS_MenuAttach
1266
1267 $Description: Attempts an attach to the GPRS network.
1268
1269 $Returns: TRUE if proceeding, FALSE if failed
1270
1271 $Arguments: Standard menu option parameters
1272
1273 *******************************************************************************/
1274
1275 int GPRS_MenuAttach(MfwMnu* m, MfwMnuItem* i)
1276 {
1277 T_MMI_GPRS_DATA *data = GPRS_Data();
1278 T_MFW_HND win = mfw_parent(mfw_header());
1279 // int gprsStatus; // RAVI
1280
1281 tracefunction("GPRS_MenuAttach()");
1282
1283 if (!data)
1284 {
1285 return FALSE;
1286 }
1287
1288 if (!data->mfw_gprs)
1289 {
1290 data->mfw_gprs = gprs_create(0, E_MFW_GPRS_ALL_EVENTS, (MfwCb)GPRS_MfwCb);
1291 /* Set CID to 0; on increment will become 1. */
1292 data->cid = GPRS_CID_OMITTED;
1293 }
1294
1295 if (data->reg_status==(int)GPRS_ATTACHED)
1296 {
1297 /* Show result */
1298 GPRS_ResultScreen(win, TxtAlreadyAttached, TxtAttached);
1299 return FALSE;
1300 }
1301
1302 GPRS_Attach(win);
1303
1304 return TRUE;
1305 }
1306
1307
1308 /*******************************************************************************
1309
1310 $Function: GPRS_MenuDetach
1311
1312 $Description: Attempts a detach from the GPRS network.
1313
1314 $Returns: TRUE if proceeding, FALSE if failed
1315
1316 $Arguments: Standard menu option parameters
1317
1318 *******************************************************************************/
1319
1320 int GPRS_MenuDetach(MfwMnu* m, MfwMnuItem* i)
1321 {
1322 T_MMI_GPRS_DATA *data = GPRS_Data();
1323 T_MFW_HND win = mfw_parent(mfw_header());
1324 // int gprsStatus; // RAVI
1325
1326 tracefunction("GPRS_MenuDetach()");
1327
1328 if (!data)
1329 {
1330 return FALSE;
1331 }
1332
1333 /* Check to make sure gprs handle exists */
1334
1335 if (!data->mfw_gprs)
1336 {
1337 /* Show result */
1338 GPRS_ResultScreen(win, TxtNotAttached, TxtNull);
1339 return FALSE;
1340 }
1341
1342 if (data->reg_status==(int)GPRS_OFF)
1343 {
1344 GPRS_ResultScreen(win, TxtNotAttached, TxtNull);
1345 return FALSE;
1346 }
1347
1348 if (data->reg_status==(int)GPRS_SEARCHING)
1349 {
1350 GPRS_ResultScreen(win, TxtGPRS, TxtNotAvailable);
1351 return FALSE;
1352 }
1353
1354 /* Try to detach */
1355
1356 GPRS_Detach(win);
1357
1358 return TRUE;
1359 }
1360
1361
1362 /*******************************************************************************
1363
1364 $Function: GPRS_MenuIncomingDataCount
1365
1366 $Description: Show data counter for last incoming call
1367
1368 $Returns: TRUE if proceeding, FALSE if failed
1369
1370 $Arguments: Standard menu option parameters
1371
1372 *******************************************************************************/
1373
1374 int GPRS_MenuIncomingDataCount(MfwMnu* m, MfwMnuItem* i)
1375 {
1376 T_MMI_GPRS_DATA *data = GPRS_Data();
1377 T_MFW_HND win = mfw_parent(mfw_header());
1378 T_MFW_RES result;
1379
1380 tracefunction("GPRS_MenuIncomingDataCount()");
1381
1382 if (!data)
1383 {
1384 return FALSE;
1385 }
1386
1387 data->counter_type = MMI_GPRS_COUNTER_DOWNLINK; /* SPR#1875 - SH - Now DOWNLINK */
1388 data->display = TRUE;
1389 data->status = MMI_GPRS_STATUS_DATA_COUNTER;
1390 GPRS_PleaseWait(win, TxtPleaseWait, NULL); /* SPR#1986 */
1391
1392 /* If a data call is in progress, counter is now reset every
1393 * time we check it - MMI keeps track of total.
1394 * If a data call is not in progress, display current total from MMI */
1395
1396 result = gprs_counter(TRUE);
1397
1398 switch(result)
1399 {
1400 /* Waiting for rAT_PercentSNCNT callback, don't update display yet */
1401
1402 case MFW_RES_OK:
1403 trace("gprs_counter executing, awaiting confirmation.");
1404 break;
1405
1406 /* We're not connected - display current total */
1407
1408 case MfwResDone:
1409 GPRS_PleaseWaitDestroy();
1410 data->display = FALSE;
1411 GPRS_ShowCounter(win);
1412 break;
1413
1414 /* Error has occurred */
1415
1416 default:
1417 GPRS_PleaseWaitDestroy();
1418 data->display = FALSE;
1419 info_screen(win, TxtGPRS,TxtError, NULL);
1420 break;
1421 }
1422
1423 return TRUE;
1424 }
1425
1426
1427 /*******************************************************************************
1428
1429 $Function: GPRS_MenuOutgoingDataCount
1430
1431 $Description: Show data counter for last incoming call
1432
1433 $Returns: TRUE if proceeding, FALSE if failed
1434
1435 $Arguments: Standard menu option parameters
1436
1437 *******************************************************************************/
1438
1439 int GPRS_MenuOutgoingDataCount(MfwMnu* m, MfwMnuItem* i)
1440 {
1441 T_MMI_GPRS_DATA *data = GPRS_Data();
1442 T_MFW_HND win = mfw_parent(mfw_header());
1443 T_MFW_RES result;
1444
1445 tracefunction("GPRS_MenuOutgoingDataCount()");
1446
1447 if (!data)
1448 {
1449 return FALSE;
1450 }
1451
1452 data->counter_type = MMI_GPRS_COUNTER_UPLINK; /* SPR#1875 - SH - Now UPLINK */
1453 data->display = TRUE;
1454 data->status = MMI_GPRS_STATUS_DATA_COUNTER;
1455 GPRS_PleaseWait(win, TxtPleaseWait, NULL); /* SPR#1986 */
1456
1457 /* If a data call is in progress, counter is now reset every
1458 * time we check it - MMI keeps track of total.
1459 * If a data call is not in progress, display current total from MMI */
1460
1461 result = gprs_counter(TRUE);
1462
1463 switch(result)
1464 {
1465 /* Waiting for rAT_PercentSNCNT callback, don't update display yet */
1466
1467 case MFW_RES_OK:
1468 trace("gprs_counter executing, awaiting confirmation.");
1469 break;
1470
1471 /* We're not connected - display current total */
1472
1473 case MfwResDone:
1474 GPRS_PleaseWaitDestroy();
1475 data->display = FALSE;
1476 GPRS_ShowCounter(win);
1477 break;
1478
1479 /* Error has occurred */
1480
1481 default:
1482 GPRS_PleaseWaitDestroy();
1483 data->display = FALSE;
1484 info_screen(win, TxtGPRS,TxtError, NULL);
1485 break;
1486 }
1487
1488 return TRUE;
1489 }
1490
1491
1492
1493 /*******************************************************************************
1494
1495 $Function: GPRS_MenuSelectSms
1496
1497 $Description: Sets cursor position for this menu based on the current settings
1498
1499 $Returns: TRUE if proceeding, FALSE if failed
1500
1501 $Arguments: menu - pointer to the current menu
1502 item - pointer to the current menu item
1503
1504 *******************************************************************************/
1505
1506 int GPRS_MenuSelectSms(MfwMnu* menu, MfwMnuItem* item)
1507 {
1508 T_MMI_GPRS_DATA *data = GPRS_Data();
1509 T_MFW_HND win = mfwParent( mfw_header()); /* GPRS menu window */
1510 // T_MFW_GPRS *gprs; // RAVI
1511
1512 tracefunction("GPRS_MenuSelectSms()");
1513
1514 if (!data)
1515 {
1516 return FALSE;
1517 }
1518
1519 data->menu_win = bookMenuStart(win, SMSServiceAttributes(), 0);
1520
1521 SEND_EVENT(data->menu_win, DEFAULT_OPTION, NULL, &data->sms_service); // Add our own callback
1522
1523 return TRUE;
1524 }
1525
1526
1527 /*******************************************************************************
1528
1529 $Function: GPRS_MenuSelectSms_set
1530
1531 $Description: Send SMS by GPRS/CSD
1532
1533 $Returns: TRUE if proceeding, FALSE if failed
1534
1535 $Arguments: menu - pointer to the current menu
1536 item - pointer to the current menu item
1537
1538 *******************************************************************************/
1539
1540 int GPRS_MenuSelectSms_set(MfwMnu* menu, MfwMnuItem* item)
1541 {
1542 T_MMI_GPRS_DATA *data = GPRS_Data();
1543 T_MFW_HND win = mfwParent( mfw_header()); /* GPRS menu window */
1544
1545 tracefunction("GPRS_MenuSelectSms_set()");
1546 trace_P1("Menu level: %d", menu->lCursor[menu->level]);
1547
1548 if (!data)
1549 {
1550 return FALSE;
1551 }
1552
1553 if (!data->mfw_gprs)
1554 {
1555 TRACE_EVENT("** No MFW gprs **");
1556 return FALSE;
1557 }
1558
1559 data->display = TRUE;
1560
1561 if(!GPRS_SetSmsService(menu->lCursor[menu->level]))
1562 {
1563 info_screen(win, TxtFailed, NULL, NULL);
1564 }
1565
1566 return TRUE;
1567 }
1568
1569
1570 /*******************************************************************************
1571
1572 $Function: GPRS_PleaseWait
1573
1574 $Description: Creates a "Please Wait" message that will hang around until an "OK" or
1575 "Error" message is received by GPRS_MfwCb
1576
1577 $Returns: Pointer to the created window
1578
1579 $Arguments: parent_win - the parent window
1580 TextId1 - the first text string to be shown
1581 TextId2 - the second text string to be shown
1582
1583 *******************************************************************************/
1584
1585 static T_MFW_HND GPRS_PleaseWait(T_MFW_HND parent_win, USHORT TextId1, USHORT TextId2)
1586 {
1587 T_MMI_GPRS_DATA *data = GPRS_Data();
1588 T_DISPLAY_DATA display_info;
1589
1590 tracefunction("GPRS_PleaseWait()");
1591
1592 if (!data)
1593 {
1594 return NULL;
1595 }
1596
1597 /* Delete any previous window */
1598 GPRS_PleaseWaitDestroy();
1599
1600 dlg_initDisplayData_TextId( &display_info, TxtNull, TxtCancel, TextId1, TextId2, COLOUR_STATUS);
1601 dlg_initDisplayData_events( &display_info, (T_VOID_FUNC)GPRS_PleaseWaitCb, PLEASEWAIT_TIMEOUT, KEY_HUP | KEY_RIGHT );
1602
1603 data->display = TRUE; /* Allow OK and Fail messages to appear. */
1604 data->menu_win = parent_win; /* Store parent window */
1605
1606 /* Show information screen, storing window pointer */
1607 data->pleasewait_win = info_dialog(parent_win,&display_info);
1608
1609 return data->pleasewait_win;
1610 }
1611
1612
1613 /*******************************************************************************
1614
1615 $Function: GPRS_PleaseWaitCb
1616
1617 $Description: Please wait window callback function.
1618
1619 $Returns: None
1620
1621 $Arguments: win - the parent window
1622 identifier - not used
1623 reason - the reason for the callback
1624
1625 *******************************************************************************/
1626
1627 static void GPRS_PleaseWaitCb(T_MFW_HND win, UBYTE identifier, UBYTE reason)
1628 {
1629 T_MMI_GPRS_DATA *data = GPRS_Data();
1630
1631 tracefunction("GPRS_PleaseWaitCb()");
1632
1633 if (!data)
1634 {
1635 return;
1636 }
1637
1638 /* Dialog already destroyed by this point */
1639
1640 data->pleasewait_win = NULL;
1641
1642 switch(reason)
1643 {
1644 case INFO_TIMEOUT:
1645
1646 /* Delete window */
1647
1648 info_screen(data->menu_win, TxtTimedOut, NULL, NULL);
1649 data->status = MMI_GPRS_STATUS_IDLE;
1650 break;
1651
1652 case INFO_KCD_HUP:
1653 case INFO_KCD_RIGHT:
1654
1655 /*Cancel current operation */
1656
1657 switch(data->status)
1658 {
1659 case MMI_GPRS_STATUS_ATTACHING:
1660 case MMI_GPRS_STATUS_DETACHING:
1661 gprs_attach_abort();
1662 data->status = MMI_GPRS_STATUS_IDLE;
1663 data->display = FALSE;
1664 break;
1665 case MMI_GPRS_STATUS_DATA_COUNTER:
1666 gprs_counter_abort();
1667 data->status = MMI_GPRS_STATUS_IDLE;
1668 data->display = FALSE;
1669 break;
1670 }
1671 break;
1672 }
1673
1674 return;
1675 }
1676
1677
1678 /*******************************************************************************
1679
1680 $Function: GPRS_PleaseWaitDestroy
1681
1682 $Description: Check to see if the "Please Wait" window is present, and destroys it
1683 if so.
1684
1685 $Returns: None.
1686
1687 $Arguments: None.
1688
1689 *******************************************************************************/
1690
1691 static void GPRS_PleaseWaitDestroy(void)
1692 {
1693 T_MMI_GPRS_DATA *data = GPRS_Data();
1694
1695 tracefunction("GPRS_PleaseWaitDestroy()");
1696
1697 if (!data)
1698 {
1699 return;
1700 }
1701
1702 if (data->pleasewait_win)
1703 {
1704 SEND_EVENT(data->pleasewait_win, DIALOG_DESTROY, NULL, NULL);
1705 data->pleasewait_win = NULL;
1706 }
1707
1708 return;
1709 }
1710
1711
1712 /*******************************************************************************
1713
1714 $Function: GPRS_ShowCounter
1715
1716 $Description: Generic counter displaying function
1717
1718 $Returns:
1719
1720 $Arguments: Standard menu option parameters
1721
1722 *******************************************************************************/
1723
1724 static void GPRS_ShowCounter(T_MFW_HND win)
1725 {
1726 T_MMI_GPRS_DATA *data = GPRS_Data();
1727 #ifdef NEW_EDITOR
1728 T_AUI_EDITOR_DATA editor_data;
1729 #else
1730 T_EDITOR_DATA editor_data;
1731 #endif
1732 // T_MFW_GPRS *gprs; // RAVI
1733 USHORT titleId;
1734
1735 tracefunction("GPRS_ShowCounter()");
1736
1737 if (!data)
1738 {
1739 return;
1740 }
1741
1742 /* Destroy old editor if it exists */
1743
1744 if (data->edit_win)
1745 {
1746 GPRS_DestroyCounter();
1747 }
1748
1749 /* Set appropriate title string (corrected) */
1750
1751 switch(data->counter_type)
1752 {
1753 case MMI_GPRS_COUNTER_DOWNLINK:
1754 titleId = TxtIncomingData;
1755 break;
1756
1757 case MMI_GPRS_COUNTER_UPLINK:
1758 titleId = TxtOutgoingData;
1759 break;
1760
1761 default:
1762 titleId = TxtNull;
1763 break;
1764 }
1765
1766 data->counterstring = (char *)ALLOC_MEMORY(ULONG_SIZE_IN_DECIMAL);
1767 GPRS_UpdateCounter();
1768
1769 /* New Editor */
1770 #ifdef NEW_EDITOR
1771 AUI_edit_SetDefault(&editor_data);
1772 AUI_edit_SetDisplay(&editor_data, ZONE_FULL_SK_TITLE, COLOUR_EDITOR_XX, EDITOR_FONT);
1773 AUI_edit_SetEvents(&editor_data, data->counter_type, FALSE, FOREVER, (T_AUI_EDIT_CB)GPRS_ShowCounterCb);
1774 AUI_edit_SetTextStr(&editor_data, TxtReset, TxtSoftBack, titleId, NULL);
1775 AUI_edit_SetMode(&editor_data, ED_MODE_READONLY, ED_CURSOR_NONE);
1776 AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)data->counterstring, ULONG_SIZE_IN_DECIMAL);
1777
1778 data->edit_win = AUI_edit_Start(win, &editor_data);
1779 #else /* NEW_EDITOR */
1780 editor_data.TextString = NULL;
1781 editor_data.LeftSoftKey = TxtSoftOK;
1782 editor_data.RightSoftKey = TxtReset;
1783 editor_data.AlternateLeftSoftKey = NULL;
1784 editor_data.Callback = (T_EDIT_CB)GPRS_ShowCounterCb;
1785 editor_data.Identifier = data->counter_type;
1786 editor_data.hide = FALSE;
1787 editor_data.mode = READ_ONLY_MODE;
1788 editor_data.timeout = FOREVER;
1789 editor_data.min_enter = 0;
1790 editor_data.destroyEditor = FALSE;
1791 editor_data.editor_attr.win.px = 0;
1792 editor_data.editor_attr.win.py = Mmi_layout_line(1)+4;
1793 editor_data.editor_attr.win.sx = SCREEN_SIZE_X;
1794 editor_data.editor_attr.win.sy = Mmi_layout_line(2)+4;
1795 editor_data.editor_attr.edtCol = COLOUR_EDITOR_XX;
1796 editor_data.editor_attr.font = 0;
1797 editor_data.editor_attr.mode = edtCurNone;
1798 editor_data.editor_attr.controls = 0;
1799 editor_data.editor_attr.size = ULONG_SIZE_IN_DECIMAL;
1800 editor_data.TextId = titleId;
1801
1802 editor_data.editor_attr.text = data->counterstring;
1803
1804 /* Create the dialog handler */
1805
1806 data->edit_win = editor_start(win, &editor_data); /* start the editor */
1807 #endif /* NEW_EDITOR */
1808
1809 return;
1810 }
1811
1812
1813 /*******************************************************************************
1814
1815 $Function: GPRS_ShowCounterCb
1816
1817 $Description: Change text string for the counter we've just changed
1818
1819 $Returns: nothing.
1820
1821 $Arguments: win - the editor window
1822 identifier - the type of counter we're updating
1823 reason - the event that caused the callback
1824
1825 *******************************************************************************/
1826
1827 static void GPRS_ShowCounterCb(T_MFW_HND win, USHORT identifier, USHORT reason)
1828 {
1829 T_MMI_GPRS_DATA *data = GPRS_Data();
1830 T_DISPLAY_DATA display_info;
1831
1832 tracefunction("GPRS_ShowCounterCb()");
1833
1834 if (!data)
1835 {
1836 return;
1837 }
1838
1839 switch(reason)
1840 {
1841 /* Prompt whether to reset */
1842
1843 case INFO_KCD_LEFT:
1844 dlg_initDisplayData_TextId(&display_info, TxtCancel, TxtReset, TxtDataCounterReset, TxtNull, COLOUR_STATUS);
1845 dlg_initDisplayData_events(&display_info, (T_VOID_FUNC) GPRS_ResetCounter, TEN_SECS, KEY_HUP|KEY_CLEAR|KEY_LEFT|KEY_RIGHT );
1846
1847 info_dialog(win, &display_info);
1848 break;
1849
1850 /* Press hangup key or select OK
1851 * Calls GPRS_DestroyCounter to destroy window */
1852 case INFO_KCD_RIGHT:
1853 case INFO_KCD_HUP:
1854 GPRS_DestroyCounter();
1855 break;
1856 }
1857
1858 return;
1859 }
1860
1861
1862 /*******************************************************************************
1863
1864 $Function: GPRS_ResetCounter
1865
1866 $Description: Callback from dialogue prompting whether to reset the data counter
1867
1868 $Returns: None
1869
1870 $Arguments: Standard callback parameters
1871
1872 *******************************************************************************/
1873
1874 static void GPRS_ResetCounter(T_MFW_HND win, UBYTE identifier, UBYTE reason)
1875 {
1876 T_MMI_GPRS_DATA *data = GPRS_Data();
1877
1878 tracefunction("GPRS_ResetCounter()");
1879
1880 if (!data)
1881 {
1882 return;
1883 }
1884
1885 switch(reason)
1886 {
1887 /* RSK - Reset counter */
1888
1889 case INFO_KCD_RIGHT:
1890 if (data->counter_type==MMI_GPRS_COUNTER_UPLINK)
1891 {
1892 data->uplink_counter = 0;
1893 }
1894 else
1895 {
1896 data->downlink_counter = 0;
1897 }
1898
1899 GPRS_ShowCounter(win);
1900 break;
1901
1902 /* LSK or HUP - cancel without resetting */
1903
1904 case INFO_KCD_LEFT:
1905 case INFO_KCD_HUP:
1906 break;
1907 }
1908
1909 return;
1910 }
1911
1912
1913 /*******************************************************************************
1914
1915 $Function: GPRS_DestroyCounter
1916
1917 $Description: Destroy counter display
1918
1919 $Returns: None
1920
1921 $Arguments: None
1922
1923 *******************************************************************************/
1924
1925 static void GPRS_DestroyCounter()
1926 {
1927 T_MMI_GPRS_DATA *data = GPRS_Data();
1928
1929 tracefunction("GPRS_DestroyCounter()");
1930
1931 if (!data)
1932 {
1933 return;
1934 }
1935
1936 if (data->edit_win)
1937 {
1938
1939 /* New Editor */
1940
1941 #ifdef NEW_EDITOR
1942 AUI_edit_Destroy(data->edit_win);
1943 #else
1944 editor_destroy(data->edit_win);
1945 #endif
1946 FREE_MEMORY((void *)data->counterstring, ULONG_SIZE_IN_DECIMAL);
1947 data->counterstring = NULL;
1948 data->edit_win = NULL;
1949 }
1950
1951 return;
1952 }
1953
1954 /*******************************************************************************
1955
1956 $Function: GPRS_UpdateCounter
1957
1958 $Description: Change text string for the counter we've just changed
1959
1960 $Returns: None
1961
1962 $Arguments: None
1963
1964 *******************************************************************************/
1965
1966 static void GPRS_UpdateCounter(void)
1967 {
1968 T_MMI_GPRS_DATA *data = GPRS_Data();
1969 ULONG counter;
1970
1971 tracefunction("GPRS_UpdateCounter()");
1972
1973 if (!data)
1974 {
1975 return;
1976 }
1977
1978 counter = 0;
1979
1980 switch(data->counter_type)
1981 {
1982 case MMI_GPRS_COUNTER_UPLINK:
1983 counter = data->uplink_counter;
1984 break;
1985
1986 case MMI_GPRS_COUNTER_DOWNLINK:
1987 counter = data->downlink_counter;
1988 break;
1989 }
1990
1991 if (counter<1024)
1992 {
1993 sprintf(data->counterstring, "%d bytes",counter); // Counter is <1K, display bytes
1994 }
1995 else
1996 {
1997 counter = counter/KILOBYTE;
1998 if (counter<1024)
1999 sprintf(data->counterstring, "%dKB",counter); // Counter is <1M, display Kbytes
2000 else
2001 {
2002 counter = counter/KILOBYTE;
2003 sprintf(data->counterstring, "%dMB",counter); // Display Mbytes
2004 }
2005 }
2006
2007 return;
2008 }
2009