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