📄 mmiaoc.c
字号:
cm_get_aoc_value(CM_AOC_ACMMAX,&data->aocInfo); /* Get the ACM MAX */
cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
sprintf(buf, "ACMMAX: %ld", data->aocInfo.acm_max);
TRACE_EVENT(buf);
sprintf(buf, "ACM: %ld", data->aocInfo.acm);
TRACE_EVENT(buf);
sprintf(buf, "PPU:%s", data->aocInfo.ppu);
TRACE_EVENT(buf);
sprintf(buf, "CUR:%s", data->aocInfo.cur);
TRACE_EVENT(buf);
if((strlen((char*)data->aocInfo.ppu) EQ 0) && data->aocInfo.acm_max NEQ '\0')
{
sprintf(line, "%ld", data->aocInfo.acm_max); /* Show only ACMmax */
TRACE_EVENT ("get only :ACMMAX ; PPU ==0 and ACMMAX!=0");
}
if((strlen((char*)data->aocInfo.ppu) NEQ 0) && data->aocInfo.acm_max NEQ '\0')
{
service_calculate (win, (char*)line, data->aocInfo.acm_max);
TRACE_EVENT ("calculate ACMMAX * PPU; PPU !=0 and ACMMAX!=0");
}
for (i=0; i< MAX_LINE; i++)
{
if (line[i] EQ 0x80 OR line[i] EQ 0xFF )
line[i] = '\0';
}
if(data->aocInfo.acm_max NEQ '\0')
{
createAOCDialog( win, TxtLimitEq, TxtNull, line, event);
}
else
{
createAOCDialog( win, TxtNo, TxtLimit, NULL, event);
}
/*
* Call Info Screen
*/
break;
case SERVICES_LIMIT_CHANGE:
//fill up editor-sttribut with default
service_loadEditDefault (&editor_data);
//clear the editor-buffer
memset(data->edt_Buf,'\0',sizeof(data->edt_Buf));
/* SPR#1428 - SH - New Editor changes */
#ifdef NEW_EDITOR
AUI_edit_SetBuffer(&editor_data, ATB_DCS_ASCII, (UBYTE *)data->edt_Buf, MAX_ENTER_LIMIT);
AUI_edit_SetTextStr(&editor_data, TxtSoftOK, TxtDelete, TxtEnterLimit, NULL);
AUI_edit_SetEvents(&editor_data, data->Identifier, TRUE, FOREVER, (T_AUI_EDIT_CB)service_editor_cb);
AUI_edit_SetMode(&editor_data, 0, ED_CURSOR_BAR);
AUI_calc_Start(data->service_win, &editor_data);
#else /* NEW_EDITOR */
editor_data.editor_attr.text = data->edt_Buf; /* buffer to be edited */
editor_data.editor_attr.size = MAX_ENTER_LIMIT; /* limit to 6 terms of units */
editor_data.LeftSoftKey = TxtSoftOK;
editor_data.RightSoftKey = TxtDelete;
editor_data.TextId = TxtEnterLimit;
editor_data.Identifier = data->Identifier;
editor_data.mode = CALC_MODE;
editor_data.AlternateLeftSoftKey = TxtNull;
editor_data.min_enter = 1;
/* create the dialog handler */
editor_start(data->service_win, &editor_data); /* start the editor */
#endif /* NEW_EDITOR */
break;
case SERVICES_LIMIT_CANCEL:
// clear the limit
data->aocInfo.acm_max = 0;
// Password not necessary, Pin2 scenario done
PWD='\0';
cm_set_aoc_value(CM_AOC_ACMMAX,&data->aocInfo, &PWD); /* save ACMmax in AOC */
sprintf(buf, "%ld", data->aocInfo.acm_max);
TRACE_EVENT(buf);
SEND_EVENT (win, SERVICES_LIMIT_CHANGED, 0, 0);
break;
case SERVICES_LIMIT_CHANGED:
createAOCDialog( win, TxtLimit, TxtChanged, NULL, event);
break;
case SERVICES_LAST_CHARGE:
cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
if ( strlen((char*)data->aocInfo.ppu) EQ 0 )
{
TRACE_EVENT ("get only :ACM ; PPU ==0 and ACM!=0");
//show only the units ACM from last call
sprintf(line, "%ld", acm_last_call);
}
else
{
TRACE_EVENT ("get only :ACM ; PPU !=0 and ACM!=0");
// add currency
sprintf(line, "%ld %s", acm_last_call, data->aocInfo.cur);
}
if (acm_last_call EQ '\0')
strcpy ((char *)line, "0");
createAOCDialog( win, TxtLastCharge, TxtNull, line, event);
break;
case SERVICES_TOTAL_CHARGE:
memset(line,'\0',sizeof(line));
cm_get_aoc_value(CM_AOC_ACM,&data->aocInfo); /* Get the ACM */
cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
/* nm test only set the default */
sprintf(buf, "ACM: %ld", data->aocInfo.acm);
TRACE_EVENT(buf);
sprintf(buf, "PPU:%s", data->aocInfo.ppu);
TRACE_EVENT(buf);
sprintf(buf, "CUR:%s", data->aocInfo.cur);
TRACE_EVENT(buf);
if((strlen((char*)data->aocInfo.ppu) EQ 0) && data->aocInfo.acm NEQ '\0')
{
//show only the units ACM
sprintf(line, "%ld", data->aocInfo.acm);
TRACE_EVENT ("get only :ACM ; PPU ==0 and ACM!=0");
}
if((strlen((char*)data->aocInfo.ppu) NEQ 0) && data->aocInfo.acm NEQ '\0')
{
service_calculate (win, (char*)line, data->aocInfo.acm);
TRACE_EVENT ("calculate ACM * PPU; PPU !=0 and ACM!=0");
}
if (data->aocInfo.acm EQ '\0')
strcpy ((char *)line, "0");
createAOCDialog( win, TxtTotalCharge, TxtNull, line, event);
break;
case SERVICES_RESET_CHARGE:
// clear the charge counter for all calls
data->aocInfo.acm = 0;
acm_last_call = 0;
cm_set_aoc_value(CM_AOC_ACM,&data->aocInfo, &PWD); /* save ACM in AOC */
sprintf(buf, "%ld", data->aocInfo.acm);
TRACE_EVENT(buf);
SEND_EVENT (win, SERVICES_CHARGE_CHANGED, 0, 0);
break;
case SERVICES_CHARGE_CHANGED:
createAOCDialog( win, TxtResetCharge, TxtNull, NULL, event);
break;
case SERVICES_OUT_OF_RANGE:
TRACE_EVENT("SERVICES_OUT_OF_RANGE");
createAOCDialog( win, TxtOutofRange, TxtNull, NULL, event);
break;
case SERVICES_AOC_NOT_SUPPORTED:
TRACE_EVENT("SERVICES_NOT_ALLOWED");
createAOCDialog( win, TxtNotAllowed, TxtNull, NULL, event);
break;
}
}
/*******************************************************************************
$Function: service_loadEditDefault
$Description: fill up editor-sttribut with default
$Returns:
$Arguments:
*******************************************************************************/
#ifdef NEW_EDITOR
/* SPR#1428 - SH - New Editor changes */
void service_loadEditDefault (T_AUI_EDITOR_DATA *editor_data)
{
TRACE_FUNCTION ("service_loadEditDefault()");
AUI_edit_SetDefault(editor_data);
AUI_edit_SetDisplay(editor_data, ZONE_SMALL_EDITOR, COLOUR_EDITOR, EDITOR_FONT);
AUI_edit_SetEvents(editor_data, 0, TRUE, FOREVER, (T_AUI_EDIT_CB)service_editor_cb);
AUI_edit_SetTextStr(editor_data, TxtSoftSelect, TxtSoftBack, TxtNull, NULL);
AUI_edit_SetMode(editor_data, 0, ED_CURSOR_UNDERLINE);
AUI_edit_SetAltTextStr(editor_data, 1, TxtNull, FALSE, TxtNull);
return;
}
#else /* NEW_EDITOR */
void service_loadEditDefault (T_EDITOR_DATA *editor_data)
{
TRACE_FUNCTION ("service_loadEditDefault()");
editor_attr_init(&editor_data->editor_attr, ZONE_SMALL_EDITOR, edtCurBar1, NULL, NULL, 0, COLOUR_EDITOR);
editor_data->editor_attr.font = 0;
editor_data_init( editor_data, (T_EDIT_CB)service_editor_cb, TxtSoftSelect, TxtSoftBack, TxtNull, 1, DIGITS_MODE, FOREVER);
editor_data->hide = FALSE;
editor_data->destroyEditor = TRUE;
editor_data->AlternateLeftSoftKey = TxtNull;
}
#endif /* NEW_EDITOR */
/*******************************************************************************
$Function: service_calc_balance
$Description: Calculate the Credit remaining
$Returns:
$Arguments:
*******************************************************************************/
void service_calc_balance (T_MFW_HND win,char* line)
{
T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
T_SERVICES * data = (T_SERVICES *)win_data->user;
char line2[MAX_LINE];
char *pdest,*src,*dst,*POINT;
LONG result;
int ch = '.';
UBYTE counter=0;
memset(line2,'\0',sizeof(line2));
cm_get_aoc_value(CM_AOC_ACMMAX,&data->aocInfo); /* Get the ACM MAX */
cm_get_aoc_value(CM_AOC_ACM,&data->aocInfo); /* Get ACM */
cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
/* Search for '.' */
pdest =(char *) strchr((char*) data->aocInfo.ppu, ch );
if( pdest EQ NULL ) /* '.' not founded */
{
result = atol((char*)data->aocInfo.ppu ); /* STRING => LONG */
result= result *(data->aocInfo.acm_max - data->aocInfo.acm); /* (ACMmax-ACM) * PPU */
sprintf(line, "%ld %s", result,data->aocInfo.cur); /* LONG => STRING */
}
else /* '.' found */
{
/*
* '.' found, *pdest EQ '.'
*/
counter = strlen(pdest + 1); /* store the decimal place */
src = (char*)data->aocInfo.ppu;
dst = line;
do /* remove the '.' */
{
if (*src NEQ '.')
{
*dst++ = *src;
}
} while (*src++ NEQ '\0');
/* STRING => LONG */
result= (atol(line))*(data->aocInfo.acm_max - data->aocInfo.acm); /* (ACMmax - ACM) * PPU */
sprintf(line, "%ld", result); /* LONG => STRING */
if(strlen(line) < counter)
{
src = line;
dst = line2;
*dst++ = '0';
*dst++ = '.';
counter = counter - strlen(line);
do /* fill up with '0' */
{
*dst++ = '0';
} while (--counter NEQ 0);
memcpy (dst,src,sizeof(src));
sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
return;
}
src = line;
dst = line2;
POINT= src + strlen(src) - counter;
do /* set the '.' */
{
if (src EQ POINT)
{
*dst++ = '.';
}
*dst++ = *src++;
} while (*src NEQ '\0');
if (line2[0] EQ '.')
sprintf(line, "0%s %s", line2,data->aocInfo.cur); /* add the currency */
if (line2[0] NEQ '.')
sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
}
return;
}
/*******************************************************************************
$Function: service_calculate
$Description: Calculate the value with price per unit and currency.
"value * PPU" @ currency
$Returns:
$Arguments:
*******************************************************************************/
void service_calculate (T_MFW_HND win, char* line, long value)
{
T_MFW_WIN * win_data = ((T_MFW_HDR *) win)->data;
T_SERVICES * data = (T_SERVICES *)win_data->user;
char line2[MAX_LINE];
char *pdest,*src,*dst,*POINT;
LONG result;
int ch = '.';
UBYTE counter=0;
memset(line2,'\0',sizeof(line2));
cm_get_aoc_value(CM_AOC_ACM,&data->aocInfo); /* Get ACM */
cm_get_aoc_value(CM_AOC_PUCT,&data->aocInfo); /* Get currency and price per unit */
/* Search for '.' */
pdest =(char *) strchr((char*) data->aocInfo.ppu, ch );
if( pdest EQ NULL ) /* '.' not founded */
{
result = atol((char*)data->aocInfo.ppu ); /* STRING => LONG */
result= result * value; /* value * PPU */
sprintf(line, "%ld %s", result,data->aocInfo.cur); /* LONG => STRING */
}
else /* '.' found */
{
/*
* '.' found, *pdest EQ '.'
*/
counter = strlen(pdest + 1); /* store the decimal place */
src = (char*)data->aocInfo.ppu;
dst = line;
do /* remove the '.' */
{
if (*src NEQ '.')
{
*dst++ = *src;
}
} while (*src++ NEQ '\0');
/* STRING => LONG */
result= atol(line) * value; /* value * PPU */
sprintf(line, "%ld", result); /* LONG => STRING */
if(strlen(line) < counter)
{
src = line;
dst = line2;
*dst++ = '0';
*dst++ = '.';
counter = counter - strlen(line);
do /* fill up with '0' */
{
*dst++ = '0';
} while (--counter NEQ 0);
memcpy (dst,src,sizeof(src));
sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
return;
}
src = line;
dst = line2;
POINT= src + strlen(src) - counter;
do /* set the '.' */
{
if (src EQ POINT)
{
*dst++ = '.';
}
*dst++ = *src++;
} while (*src NEQ '\0');
if (line2[0] EQ '.')
sprintf(line, "0%s %s", line2,data->aocInfo.cur); /* add the currency */
if (line2[0] NEQ '.')
sprintf(line, "%s %s", line2,data->aocInfo.cur); /* add the currency */
}
return;
}
/*******************************************************************************
$Function: service_check_pin_for_aoc
$Description: this function check the PIN 2 requirement & availability of AOC
$Returns:
$Arguments:
*******************************************************************************/
USHORT service_check_pin_for_aoc (void)
{
T_MFW_AOC_ACCESS access;
char buf[40];
/* check PIN 2 requirement & availability of AOC */
sim_configuration (NULL, NULL, NULL, NULL, NULL, &access);
sprintf(buf, "acm:%d acmmax:%d,puct:%d", access.access_acm,access.access_acmmax,access.access_puct);
TRACE_EVENT(buf);
if (access.access_acm EQ MFW_SIM_PIN2 &&
access.access_acmmax EQ MFW_SIM_PIN2 &&
access.access_puct EQ MFW_SIM_PIN2)
{
TRACE_EVENT("PIN 2 required")
return MFW_SIM_PIN2_REQ;
}
else if (access.access_acm EQ MFW_SIM_PIN1 &&
access.access_acmmax EQ MFW_SIM_PIN1 &&
access.access_puct EQ MFW_SIM_PIN1)
{
TRACE_EVENT("PIN 1 required")
return MFW_SIM_PIN_REQ;
}
else if (access.access_acm EQ MFW_SIM_NO_PIN &&
access.access_acmmax EQ MFW_SIM_NO_PIN &&
access.access_puct EQ MFW_SIM_NO_PIN)
{
TRACE_EVENT("no any PIN required")
return MFW_SIM_NO_PIN;
}
else if (access.access_acm EQ MFW_SIM_UNKNOWN &&
access.access_acmmax EQ MFW_SIM_UNKNOWN &&
access.access_puct EQ MFW_SIM_UNKNOWN)
{
TRACE_EVENT("AOC not supported")
return MFW_SIM_FAILURE;
}
}
/*******************************************************************************
$Function: service_check_aoc
$Description: If there is no support for AOC on SIM card
the item "Charge Timers" will not Appear on the menulist
$Returns:
$Arguments:
*******************************************************************************/
USHORT service_check_aoc (struct MfwMnuTag *m, struct MfwMnuAttrTag *ma, struct MfwMnuItemTag *mi)
{
TRACE_FUNCTION("service_check_aoc")
switch (service_check_pin_for_aoc ())
{
case MFW_SIM_PIN2_REQ:
case MFW_SIM_PIN_REQ:
case MFW_SIM_NO_PIN:
TRACE_EVENT("AOC item visible")
return 0;
break;
case MFW_SIM_FAILURE:
TRACE_EVENT("AOC item not visible")
return 1;
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -