📄 mmigprs.c
字号:
/**************************************************************
history:
data modifaction
04/08/02 zy Mobile Innovation make gprs enable
*****************************************************************/
#define ENTITY_MFW
/* SH - switch for tracing*/
#define TRACE_MMIGPRS
/* includes */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#if defined (NEW_FRAME)
#include "typedefs.h"
#include "vsi.h"
#include "pei.h"
#include "custom.h"
#include "gsm.h"
#else
#include "stddefs.h"
#include "custom.h"
#include "gsm.h"
#include "vsi.h"
#endif
#include "mfw_sys.h"
#include "p_sim.h"
#include "cus_aci.h"
#include "mfw_mfw.h"
#include "mfw_win.h"
#include "mfw_kbd.h"
#include "mfw_edt.h"
#include "mfw_lng.h"
#include "mfw_tim.h"
#include "mfw_icn.h"
#include "mfw_mnu.h"
#include "mfw_phb.h"
#include "mfw_cm.h"
#include "mfw_sim.h"
#include "mfw_nm.h"
#include "mfw_sat.h"
#include "mfw_ss.h" /*for convert*/
#include "mfw_phb.h"
#include "ksd.h"
#include "psa.h"
#include "mfw_sms.h"
#include "mfw_cphs.h"
#include "mfw_sat.h"
#include "aci_cmh.h" /* include types declared in ACI */
#include "gaci_cmh.h" /* include types declared in GACI */
#include "mfw_gprs.h"
#include "dspl.h"
#include "MmiGprs.h"
#include "MmiBookShared.h"
#include "MmiIcons.h" // Including this header allows us to access the global icon status, for the GPRS icon.
#include "MmiSmsBroadcast.h" // Including this to get the info_screen function
#include "MmiEditor.h" // Need this for counter display
#include "MmiBookUtils.h"
#include "MmiBookMenuWindow.h" // So we can use bookMenuStart() to create our own menus
/* SPR#1574 - SH - Required to send status to WAP */
#ifdef MMI_WAP_ENABLED
#include "AUIWapExt.h"
#endif
#define ULONG_SIZE_IN_DECIMAL 10 // Max no. of decimal digits a ULONG can have
#define KILOBYTE 1024 // No of bytes in a kilobyte, used for data counter calculation.
#define PLEASEWAIT_TIMEOUT 35000 // Time for "please wait" window to time out
#define TRACE_MMIGPRS 1 //zy make mmigprs trace enable 04/08/02
#ifdef TRACE_MMIGPRS
static char debug[50];
#endif
/* Counter types */
enum
{
MMI_GPRS_COUNTER_UPLINK,
MMI_GPRS_COUNTER_DOWNLINK
};
/* GPRS data */
typedef struct
{
T_MFW_HDR *gprsHandle; // Provide a handle to the GPRS information.
T_GPRS_CID cid; // The context id. Starts at 1 then increments.
MfwHnd gprsPleaseWait_win; // Handle for the Please Wait window
MfwHnd gprsEdit_win; // Handle for editor window
MfwHnd menu_win; // Handler for menu windows
char *counterstring; // String for counter digits
ULONG uplink_counter; // Value of uplink counter
ULONG downlink_counter; // Value of downlink counter
USHORT counter_type; // TRUE if uplink counter has been requested
T_CGSMS_SERVICE SMSService; // Type of SMS service
BOOL display; // Whether to display "OK" windows or not
}
T_MMI_GPRS_DATA;
static T_MMI_GPRS_DATA *mmi_gprs=NULL;
/*******************************************************************************
LOCAL FUNCTION PROTOTYPES
*******************************************************************************/
//static T_MFW_HND mmiPleaseWait(T_MFW_HND parent_win, USHORT TextId1, USHORT TextId2);
static void mmiPleaseWaitCb(T_MFW_HND win, UBYTE identifier, UBYTE reason);
static void mmiPleaseWaitDestroy();
static void mmiGprsShowCounter(T_MFW_HND win, USHORT identifier);
static void mmiGprsDestroyCounter(); /* SPR#1875 - SH */
static char * mmiGprsUpdateCounter(T_MFW_HND win, USHORT identifier);
static void mmiGprsShowCounterCb(T_MFW_HND win, USHORT identifier, USHORT reason);
/*******************************************************************************
$Function: mmiGprsInit
$Description: Initialise GPRS
$Returns: Handler for MFW GPRS events.
$Arguments: None.
*******************************************************************************/
void mmiGprsInit(void)
{
#ifdef TRACE_MMIGPRS
TRACE_FUNCTION("mmiGprsInit()");
#endif
gprs_init();
// Allocate memory for mmi data
mmi_gprs = (T_MMI_GPRS_DATA *)ALLOC_MEMORY(sizeof(T_MMI_GPRS_DATA));
memset(mmi_gprs, 0, sizeof(T_MMI_GPRS_DATA));
mmi_gprs->gprsHandle = gprs_create(0, E_MFW_GPRS_ALL_EVENTS, (MfwCb)GPRSMfwCb);
mmi_gprs->cid = GPRS_CID_OMITTED;
mmi_gprs->uplink_counter = 0;
mmi_gprs->downlink_counter = 0;
mmi_gprs->SMSService = CGSMS_SERVICE_OMITTED;
mmi_gprs->display = FALSE;
return;
}
/*******************************************************************************
$Function: mmiGprsExit
$Description: Exit GPRS
$Returns: None.
$Arguments: None.
*******************************************************************************/
void mmiGprsExit(void)
{
#ifdef TRACE_MMIGPRS
TRACE_FUNCTION("mmiGprsExit()");
#endif
/* Delete any remaining please wait window (just in case!)*/
mmiPleaseWaitDestroy();
/* Delete the MFW module */
if (mmi_gprs->gprsHandle)
gprs_delete(mmi_gprs->gprsHandle);
/* Delete MMI data */
FREE_MEMORY((void *)mmi_gprs, sizeof(T_MMI_GPRS_DATA));
gprs_exit();
return;
}
/*******************************************************************************
$Function: mmiGprsStatus
$Description: Return status of GPRS.
$Returns: GPRS_OFF, GPRS_NOT_ATTACHED, GPRS_ATTACHED
$Arguments: None.
*******************************************************************************/
int mmiGprsStatus(void)
{
T_MFW_GPRS *gprs;
static int previous_result = -1;
int result;
#ifdef TRACE_MMIGPRS
TRACE_FUNCTION("mmiGprsStatus()");
#endif
/* SPR#1575 - SH - Restructured so it only has one exit point.
* Keeps track of last status value. If status has changed since last update,
* informs WAP.
* Default state is GPRS OFF */
iconsDeleteState(iconIdGPRSOn);
iconsDeleteState(iconIdGPRSAttached);//zy add: Del GPRS Attached Icon state
result = GPRS_OFF;
/* Check if searching or attached */
if (mmi_gprs)
{
if (mmi_gprs->gprsHandle)
{
gprs = mmi_gprs->gprsHandle->data;
if (gprs)
{
gprs->data.regState = gprs_status();
#ifdef TRACE_MMIGPRS
TRACE_EVENT_P1("mmiGprsStatus: regState = %d", gprs->data.regState);
#endif
if (gprs->data.regState==CGREG_STAT_SEARCHING)
{
result = GPRS_SEARCHING;
}
/* SPR739 - SH - Check regState rather than attached to find GPRS status */
/*....if (gprs->data.attached)...............zy test gprs. change for gprs icon in idle win 04/08/02....................................*/
else if (gprs->data.regState==CGREG_STAT_REG_HOME || gprs->data.regState==CGREG_STAT_REG_ROAM)
{TRACE_EVENT("gprs->data.attached");
iconsSetState(iconIdGPRSAttached);//zy set iconGprsAttached state on
result = GPRS_ATTACHED;
}
}
}
}
/*...............................end of zy change for gprs icon 04/08/02....................................*/
#ifdef MMI_WAP_ENABLED
if (result!=previous_result)
{
AUI_wap_gprs_status(result);
}
#endif
previous_result = result;
return result;
}
/*******************************************************************************
$Function: mmiPleaseWaitWindow
$Description: Creates a "Please Wait" message that will hang around until an "OK" or
"Error" message is received by GPRSMfwCb
$Returns: GPRS_OFF, GPRS_NOT_ATTACHED, GPRS_ATTACHED
$Arguments: parent_win - the parent window
TextId1 - the first text string to be shown
TextId2 - the second text string to be shown
*******************************************************************************/
T_MFW_HND mmiPleaseWaitWindow(T_MFW_HND parent_win, USHORT TextId1, USHORT TextId2,USHORT displayflag)
{
T_DISPLAY_DATA display_info;
TRACE_FUNCTION("mmiPleaseWaitWindow()");
/* Delete any previous window */
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
}
mmi_gprs->display = TRUE; // Allow OK and Fail messages to appear.
dialog_info_init(&display_info);
display_info.TextString = NULL;
display_info.SoftKeyStrings = FALSE;
display_info.LeftSoftKey = NULL;
display_info.RightSoftKey = TxtCancel;
display_info.Time = PLEASEWAIT_TIMEOUT;
display_info.KeyEvents = KEY_HUP | KEY_RIGHT;
display_info.TextId = TextId1;
display_info.TextId2 = TextId2;
display_info.TextString2 = NULL;
display_info.Callback = (T_VOID_FUNC)mmiPleaseWaitWindowCb;
display_info.iconindex =REMIND_WAITTING;
mmi_gprs->menu_win = parent_win; // Store parent window
if(displayflag)//if now is autoattach
return 0;
return info_dialog(parent_win,&display_info); //information screen
}
/*******************************************************************************
$Function: mmiPleaseWaitCb
$Description: Please wait window callback function.
$Returns: None
$Arguments: win - the parent window
identifier - not used
reason - the reason for the callback
*******************************************************************************/
void mmiPleaseWaitWindowCb(T_MFW_HND win, UBYTE identifier, UBYTE reason)
{
TRACE_FUNCTION("mmiPleaseWaitWindowCb()");
#ifdef TRACE_MMIGPRS
sprintf(debug, "mmiPleaseWaitWindowCb: reason = %d",reason);
TRACE_EVENT(debug);
#endif
switch(reason)
{
case INFO_TIMEOUT:
SEND_EVENT(win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
info_screen(mmi_gprs->menu_win, NULL,TxtTimedOut , NULL,REMIND_FAILURE);
break;
case INFO_KCD_HUP:
case INFO_KCD_RIGHT:
SEND_EVENT(win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
break;
}
}
/*******************************************************************************
$Function: mmiPleaseWaitDestroy
$Description: Check to see if the "Please Wait" window is present, and destroys it
if so.
$Returns: None.
$Arguments: None.
*******************************************************************************/
static void mmiPleaseWaitDestroy()
{
TRACE_FUNCTION("mmiPleaseWaitCb()");
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
}
return;
}
/*******************************************************************************
$Function: GPRSMfwCb
$Description: Callback function for MFW GPRS events.
$Returns:
$Arguments: Event number and generic parameter.
*******************************************************************************/
int GPRSMfwCb(T_MFW_EVENT event, void* para)
{
T_MFW_HND win = mfwParent( mfw_header());
T_MFW_GPRS_DATA *gprs_data = (T_MFW_GPRS_DATA *)para; // Structure that stores data from mfw
USHORT textId;
int iconindex;
TRACE_FUNCTION("GPRSMfwCb()");
switch(event)
{
case E_MFW_GPRS_S_CNTXT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_CNTXT");
#endif
break;
case E_MFW_GPRS_S_ATT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_ATT");
#endif
mmiGprsStatus();
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
}
mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win, TxtGPRS, TxtConnecting,FlashSettingData.gprsattachmode);
break;
case E_MFW_GPRS_S_ACT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_ACT");
#endif
break;
case E_MFW_GPRS_R_ACT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_ACT");
#endif
break;
case E_MFW_GPRS_S_DATA:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_DATA");
#endif
break;
case E_MFW_GPRS_R_DATA:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_DATA");
#endif
break;
case E_MFW_GPRS_S_QOS:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_QOS");
#endif
break;
case E_MFW_GPRS_R_QOS:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_QOS");
#endif
break;
case E_MFW_GPRS_S_QOS_MIN:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_QOS_MIN");
#endif
break;
case E_MFW_GPRS_S_CLASS:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_CLASS");
#endif
break;
case E_MFW_GPRS_S_PDPADDR:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_PDPADDR");
#endif
break;
case E_MFW_GPRS_S_AUTORESP:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_REG");
#endif
break;
case E_MFW_GPRS_S_ANS:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_AUTORESP");
#endif
break;
case E_MFW_GPRS_R_ANS:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_ANS");
#endif
break;
case E_MFW_GPRS_S_EREP:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_EREPG");
#endif
break;
case E_MFW_GPRS_R_EREP_RJ:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_EREP_RJ");
#endif
break;
case E_MFW_GPRS_R_EREP_ATT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_EREP_ATT");
#endif
/* Attach status has changed, display message as appropriate */
if (mmi_gprs->display)
{
/* Delete please wait window */
mmiPleaseWaitDestroy();
if (gprs_data->attached)
{
textId = TxtAttached;
iconindex=REMIND_SUCCEED;
}
else
{
textId = TxtNotAttached;
iconindex=REMIND_SUCCEED;
}
info_screen(win, TxtGPRS, textId, NULL,iconindex);
mmi_gprs->display = FALSE;
}
mmiGprsStatus();
break;
case E_MFW_GPRS_R_EREP_ACT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_EREP_ACT");
#endif
break;
case E_MFW_GPRS_R_EREP_DEACT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_EREP_DEACT");
#endif
break;
case E_MFW_GPRS_R_EREP_CLASS:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_EREP_CLASS");
#endif
break;
case E_MFW_GPRS_R_REG:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_R_REG");
TRACE_EVENT_P1("regState: %d", gprs_data->regState);
#endif
if (mmi_gprs->display)
{
textId = TxtError;
iconindex=REMIND_FAILURE;
switch (gprs_data->regState)
{
case CGREG_STAT_REG_HOME:
case CGREG_STAT_REG_ROAM:
textId = TxtAttached;
iconindex=REMIND_SUCCEED;
#ifdef MMI_HOMEZONE_ENABLED
/* SPR759 - SH - cell reselection for homezone */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -