📄 mmigprs.c
字号:
homezoneUpdate(gprs_data->lac, gprs_data->ci);
#endif
break;
case CGREG_STAT_NOT_REG: /* not registered, no searching */
case CGREG_STAT_REG_DEN:
textId = TxtNotAttached;
iconindex=REMIND_SUCCEED;
#ifdef MMI_HOMEZONE_ENABLED
/* SPR759 - SH - cell reselection for homezone */
homezoneUpdate(0,0);
#endif
break;
case CGREG_STAT_SEARCHING: /* not registered, searching */
textId = TxtSearching;
iconindex=REMIND_NORECORD;
#ifdef MMI_HOMEZONE_ENABLED
/* SPR759 - SH - cell reselection for homezone */
homezoneUpdate(0, 0);
#endif
break;
}
}
if (mmi_gprs->display)
info_screen(win, TxtGPRS, textId, NULL,iconindex);
mmi_gprs->display = FALSE;
mmiGprsStatus();
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
}
break;
case E_MFW_GPRS_S_SMSSERV:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_S_SMSSERV");
#endif
/* First display "GPRS Changed" */
if (mmi_gprs->display)
info_screen(win, TxtGPRS, TxtChanged, NULL,REMIND_SUCCEED);
mmi_gprs->display = FALSE;
mmiGprsStatus();
/* Now destroy the "Please Wait" window underneath */
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
}
break;
case E_MFW_GPRS_OK:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_OK");
#endif
break;
case E_MFW_GPRS_ERROR:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_ERROR");
#endif
// First display "GPRS Error"
if (mmi_gprs->display)
info_screen(win, TxtGPRS, TxtFailed, NULL,REMIND_FAILURE);
mmi_gprs->display = FALSE;
mmiGprsStatus();
// Now destroy the "Please Wait" window underneath
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
}
break;
case E_MFW_GPRS_CONNECT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_CONNECT");
#endif
/* Display "CONNECTED" window */
//mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win,TxtGPRS, TxtConnecting);
//info_screen(win, TxtGPRS, TxtConnected, NULL);
mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win,TxtGPRS, TxtConnecting,FlashSettingData.gprsattachmode);
mmiGprsStatus();
// Now destroy any "Please Wait" window underneath
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
}
break;
case E_MFW_GPRS_ERR_CONNECT:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_ERR_CONNECT");
#endif
// First display "GPRS No Answer"
if (mmi_gprs->display)
info_screen(win, TxtGPRS, TxtNoAnswer, NULL,REMIND_FAILURE);
mmi_gprs->display = FALSE;
mmiGprsStatus();
// Now destroy the "Please Wait" window underneath
if (mmi_gprs->gprsPleaseWait_win)
{
SEND_EVENT(mmi_gprs->gprsPleaseWait_win, DIALOG_DESTROY, NULL, NULL);
mmi_gprs->gprsPleaseWait_win = NULL;
}
break;
case E_MFW_GPRS_COUNTER:
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSMfwCb: E_MFW_GPRS_COUNTER");
#endif
/* SPR#1875 - SH - Now add values returned from ACI
* to total counter */
mmi_gprs->uplink_counter += (ULONG)(gprs_data->counter.octets_uplink);
mmi_gprs->downlink_counter += (ULONG)(gprs_data->counter.octets_downlink);
TRACE_EVENT("mmi_gprs->uplink_counter");
TraceInt((int) mmi_gprs->uplink_counter);
TRACE_EVENT("mmi_gprs->downlink_counter");
TraceInt((int) mmi_gprs->uplink_counter);
/* Only display counter if user has requested it */
if (mmi_gprs->display)
{
mmi_gprs->display = FALSE;
mmiGprsStatus();
/* Delete please wait window */
mmiPleaseWaitDestroy();
mmiGprsShowCounter(win, mmi_gprs->counter_type);
}
break;
default:
#ifdef TRACE_MMIGPRS
sprintf(debug, "GPRSMfwCb: event = %d", event);
TRACE_EVENT(debug);
#endif
break;
}
if (idleIsFocussed())
{
iconsShow(); // Update idle screen icons to show any change in GPRS status
}
else
{
mmiGprsStatus(); // iconsShow calls mmiGprsStatus; if we don't call that, call this on its own
}
return TRUE;
}
/*******************************************************************************
$Function: GPRSAttach
$Description: Attempts an attach to the GPRS network.
$Returns:
$Arguments: Standard menu option parameters
*******************************************************************************/
int GPRSAttach(MfwMnu* m, MfwMnuItem* i)
{
T_MFW_HND win = mfw_parent(mfw_header());
int gprsStatus;
TRACE_FUNCTION("GPRSAttach()");
if (!mmi_gprs->gprsHandle)
{
mmi_gprs->gprsHandle = gprs_create(0, E_MFW_GPRS_ALL_EVENTS, (MfwCb)GPRSMfwCb);
mmi_gprs->cid = GPRS_CID_OMITTED; // Set CID to 0; on increment will become 1.
// If we've set the SMS service while unattached, change it now
if (mmi_gprs->SMSService != CGSMS_SERVICE_OMITTED)
gprs_setServiceSMS(mmi_gprs->SMSService);
}
gprsStatus = mmiGprsStatus();
/*zy move 11/26 for Gprs is must attach again avoid no network lose the gprsStatus
if (gprsStatus==(int)GPRS_ATTACHED)
{
info_screen(win, TxtAlreadyAttached, NULL, NULL);
return;
}
*/
mmi_gprs->display = TRUE;
if (gprs_attach(CGATT_STATE_ATTACHED)==MFW_RES_OK)
{
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSAttach executing, awaiting confirmation.");
#endif
if(!FlashSettingData.gprsattachmode)
mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win, NULL,TxtPleaseWait ,FlashSettingData.gprsattachmode);
else
//mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win, TxtAttachMode, TxtAttachMode,FlashSettingData.gprsattachmode);
info_screen(win, TxtAttachMode,TxtAutomatic, NULL,REMIND_NORECORD);
}
else
{
if (gprsStatus==(int)GPRS_ATTACHED)
{
info_screen(win,NULL ,TxtAlreadyAttached , NULL,REMIND_NORECORD);
TRACE_EVENT("GPRS already attached.");
return;
}
info_screen(win, TxtNull ,TxtFailed, NULL,REMIND_FAILURE);
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSAttach failed.");
#endif
}
return;
}
/*******************************************************************************
$Function: GPRSAttach
$Description: Attempts an attach to the GPRS network.
$Returns:
$Arguments: Standard menu option parameters
*******************************************************************************/
int GPRSAutoAttach()
{
int gprsStatus;
TRACE_FUNCTION("GPRSAttach()");
if (!mmi_gprs->gprsHandle)
{
mmi_gprs->gprsHandle = gprs_create(0, E_MFW_GPRS_ALL_EVENTS, (MfwCb)GPRSMfwCb);
mmi_gprs->cid = GPRS_CID_OMITTED; // Set CID to 0; on increment will become 1.
// If we've set the SMS service while unattached, change it now
if (mmi_gprs->SMSService != CGSMS_SERVICE_OMITTED)
gprs_setServiceSMS(mmi_gprs->SMSService);
}
mmi_gprs->display = FALSE;
gprs_attach(CGATT_STATE_ATTACHED);
gprsStatus = mmiGprsStatus();
return gprsStatus;
}
/*******************************************************************************
$Function: GPRSDetach
$Description: Attempts a detach from the GPRS network.
$Returns:
$Arguments: Standard menu option parameters
*******************************************************************************/
int GPRSDetach(MfwMnu* m, MfwMnuItem* i)
{
T_MFW_HND win = mfw_parent(mfw_header());
int gprsStatus;
TRACE_FUNCTION("GPRSDetach()");
// Check to make sure gprs handle exists
if (!mmi_gprs->gprsHandle)
{
TRACE_EVENT("zy:detach 1:");
info_screen(win,NULL ,TxtNotAttached , NULL,REMIND_SUCCEED);
return;
}
gprsStatus = mmiGprsStatus();
if (gprsStatus==(int)GPRS_OFF)
{
TRACE_EVENT("zy:detach 2:");
info_screen(win,NULL ,TxtNotAttached , NULL,REMIND_SUCCEED);
return;
}
if (gprsStatus==(int)GPRS_SEARCHING)
{
TRACE_EVENT("zy:detach 3:");
info_screen(win, TxtGPRS, TxtNotAvailable, NULL,REMIND_FAILURE);
return;
}
// Try to detach
mmi_gprs->display = TRUE;
if (gprs_attach(CGATT_STATE_DETACHED)==MFW_RES_OK)
{
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSDetach executing, awaiting confirmation.");
#endif
if(!FlashSettingData.gprsattachmode)
mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win, TxtPleaseWait, NULL,FlashSettingData.gprsattachmode);
else
//mmi_gprs->gprsPleaseWait_win = mmiPleaseWaitWindow(win, TxtAttachMode, TxtAttachMode,FlashSettingData.gprsattachmode);
info_screen(win, TxtAttachMode,TxtAutomatic, NULL,REMIND_NORECORD);
}
else
{
#ifdef TRACE_MMIGPRS
TRACE_EVENT("GPRSDetach failed.");
#endif
info_screen(win,TxtNull ,TxtFailed , NULL,REMIND_FAILURE);
}
return;
}
/*******************************************************************************
$Function: mmiGprsShowCounter
$Description: Generic counter displaying function
$Returns:
$Arguments: Standard menu option parameters
*******************************************************************************/
void mmiGprsShowCounter(T_MFW_HND win, USHORT identifier)
{
T_EDITOR_DATA editor_data;
T_MFW_GPRS *gprs;
USHORT titleId;
TRACE_FUNCTION("mmiGprsShowCounter()");
// Make sure GPRS handle exists before we try to read one of its fields...
editor_data.TextString = NULL;
editor_data.LeftSoftKey = TxtSoftOK;
editor_data.RightSoftKey = TxtReset;
editor_data.AlternateLeftSoftKey = NULL;
editor_data.Callback = (T_EDIT_CB)mmiGprsShowCounterCb;
editor_data.Identifier = identifier;
editor_data.hide = FALSE;
editor_data.mode = READ_ONLY_MODE;
editor_data.timeout = FOREVER;
editor_data.min_enter = 0;
editor_data.destroyEditor = FALSE;
editor_data.editor_attr.win.px = 0;
editor_data.editor_attr.win.py = 20;//wufei modified 0912
editor_data.editor_attr.win.sx = 84;
editor_data.editor_attr.win.sy = 36;//wufei modified 0912
editor_data.editor_attr.fgColor = 0;
editor_data.editor_attr.font = 0;
editor_data.editor_attr.mode = edtCurNone;
editor_data.editor_attr.controls = 0;
editor_data.editor_attr.size = ULONG_SIZE_IN_DECIMAL;
switch(identifier)
{
case MMI_GPRS_COUNTER_UPLINK:
editor_data.TextId = TxtOutgoingDataNew;
break;
case MMI_GPRS_COUNTER_DOWNLINK:
editor_data.TextId = TxtIncomingData; //hu binhao 2002-12-23 for 3125
break;
default:
editor_data.TextId = TxtNull;
break;
}
mmi_gprs->counterstring = (char *)ALLOC_MEMORY(ULONG_SIZE_IN_DECIMAL);
editor_data.editor_attr.text = mmi_gprs->counterstring;
TRACE_EVENT(mmi_gprs->counterstring);
mmiGprsUpdateCounter(win, identifier);
TRACE_EVENT(mmi_gprs->counterstring);
/* create the dialog handler */
mmi_gprs->gprsEdit_win = editor_start(win, &editor_data); /* start the editor */
return;
}
/*******************************************************************************
$Function: mmiGprsDestroyCounter
$Description: Destroy counter display
SPR#1875 - SH - Added
$Returns: None
$Arguments: None
*******************************************************************************/
static void mmiGprsDestroyCounter()
{
if (mmi_gprs->gprsEdit_win)
{
editor_destroy(mmi_gprs->gprsEdit_win);
FREE_MEMORY((void *)mmi_gprs->counterstring, ULONG_SIZE_IN_DECIMAL);
mmi_gprs->counterstring = NULL;
mmi_gprs->gprsEdit_win = NULL;
}
return;
}
/*******************************************************************************
$Function: mmiGprsUpdateCounter
$Description: Change text string for the counter we've just changed
$Returns:
$Arguments: identifier - the type of counter we're updating
*******************************************************************************/
char * mmiGprsUpdateCounter(T_MFW_HND win, USHORT identifier)
{
T_MFW_GPRS *gprs;
ULONG counter;
ULONG initcounter;
TRACE_FUNCTION("mmiGprsUpdateCounter()");
/* Make sure GPRS handle exists before we try to read one of its fields... */
counter = 0;
initcounter =0;
if (mmi_gprs->gprsHandle)
gprs = ((T_MFW_HDR *) mmi_gprs->gprsHandle)->data;
else
gprs = NULL;
switch(identifier)
{
case MMI_GPRS_COUNTER_UPLINK:
initcounter = mmi_gprs->uplink_counter;
/*2003-04-16 hubh make it add*/
counter = initcounter+FlashDCTbData.GPRSOUTCOUNTER;
TRACE_EVENT("uplink_counter");
TraceInt((int) counter);
break;
case MMI_GPRS_COUNTER_DOWNLINK:
initcounter = mmi_gprs->downlink_counter;
/*2003-04-16 hubh make it add*/
counter = initcounter+FlashDCTbData.GPRSINCOUNTER;
TRACE_EVENT("downlink_counter");
TraceInt((int) counter);
break;
}
flash_DCTbwrite();//hubh 2003-04-16
if (counter<1024)
{
sprintf(mmi_gprs->counterstring, "%d bytes",counter); // Counter is <1K, display bytes
}
else
{
counter = counter/KILOBYTE;
if (counter<1024)
sprintf(mmi_gprs->counterstring, "%dKB",counter); // Counter is <1M, display Kbytes
else
{
counter = counter/KILOBYTE;
sprintf(mmi_gprs->counterstring, "%dMB",counter); // Display Mbytes
}
}
return mmi_gprs->counterstring;
}
/*******************************************************************************
$Function: mmiGprsShowCounterCb
$Description: Change text string for the counter we've just changed
$Returns: nothing.
$Arguments: win - the editor window
identifier - the type of counter we're updating
reason - the event that caused the callback
*******************************************************************************/
void mmiGprsShowCounterCb(T_MFW_HND win, USHORT identifier, USHORT reason)
{
T_MFW_GPRS *gprs;
T_DISPLAY_DATA display_info;//wufei add 0912
TRACE_FUNCTION("mmiGprsShowCounterCb()");
#ifdef TRACE_MMIGPRS
sprintf(debug, "mmiGprsShowCounterCb: reason = %d",reason);
TRACE_EVENT(debug);
#endif
if (mmi_gprs->gprsHandle)
gprs = ((T_MFW_HDR *) mmi_gprs->gprsHandle)->data;
switch(reason)
{
// Press hangup key or select OK
case INFO_KCD_LEFT:
case INFO_KCD_HUP:
mmiGprsDestroyCounter();
break;
// Select "reset"
case INFO_KCD_RIGHT:
mmiGprsDestroyCounter();
if (mmi_gprs->gprsHandle)
{
if (identifier==MMI_GPRS_COUNTER_UPLINK)
{
mmi_gprs->uplink_counter = 0;
FlashDCTbData.GPRSOUTCOUNTER=0;
}
else
{
mmi_gprs->downlink_counter = 0;
FlashDCTbData.GPRSINCOUNTER=0; /*2003-04-16 hubh make it add*/
}
flash_DCTbwrite();
mmiGprsShowCounter(win, identifier);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -