📄 mfw_phb.c
字号:
sr_type = SR_TYP_Name;
break;
case MFW_PHB_PHYSICAL:
sr_type = SR_TYP_Physical;
break;
default:
return MFW_PHB_FAIL;
}
/* select phonebook */
if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ( book )) NEQ AT_CMPL)
return MFW_PHB_FAIL;
entries->book = book;
rcd_num = 0;
sum = num_entries;
search_mode = CPBF_MOD_NewSearch;
while (num_entries > 0)
{
for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
pb_list[i].index = -1;
findText.len = MINIMUM(strlen(search_pattern), PHB_MAX_LEN-1); //GW -SPR#762 - was MAX_ALPHA_LEN-1);
strncpy((char *)findText.data, search_pattern, findText.len);
findText.data[findText.len] = '\0';
findText.cs = CS_Sim;
if (cmhPHB_PlusCPBF(CMD_SRC_LCL,
&findText,
sr_type,
search_mode,
index,
&found,
pb_list) EQ AT_CMPL)
{
for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
{
if (pb_list[i].index NEQ -1 AND rcd_num < sum)
{
entries->entry[rcd_num].book = phb_decodePhbType (pb_list[i].book);
entries->entry[rcd_num].index = (UBYTE)pb_list[i].index;
strcpy((char *)entries->entry[rcd_num].number, (char *)pb_list[i].number);
phb_Alpha2Gsm(&pb_list[i].text, entries->entry[rcd_num].name);
entries->entry[i].ton = phb_cvtTon(pb_list[rcd_num].type.ton);
entries->entry[i].npi = phb_cvtNpi(pb_list[rcd_num].type.npi);
rcd_num++;
}
else
break;
}
if (num_entries <= PHB_MAX_ENTRY_NUM)
num_entries = 0;
else
num_entries = num_entries - PHB_MAX_ENTRY_NUM;
if (search_mode EQ CPBF_MOD_NewSearch)
{
entries->num_entries = found;
search_mode = CPBF_MOD_NextSearch;
}
}
else
break;
}
if (rcd_num)
entries->result = MFW_ENTRY_EXIST;
else
entries->result = MFW_NO_ENTRY;
/*SPR#1727 - DS - Use rcd_num variable from the for loop (that added entries to the entry structure) to set the number of entries.
* "found" variable should not be used because it may be corrupted by the ACI and set to a false value if there
* are no matching entries in the phoneook.
*/
entries->num_entries = rcd_num;
return MFW_PHB_OK;
}
#endif
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_store_entry |
+--------------------------------------------------------------------+
PURPOSE : Store phonebook entry
*/
T_MFW phb_store_entry(UBYTE book,
T_MFW_PHB_ENTRY *entry,
T_MFW_PHB_STATUS *status)
{
UBYTE used;
UBYTE total;
UBYTE tlength;
UBYTE avail;
UBYTE service;
T_ACI_VP_ABS dt;
char number[PHB_MAX_LEN+1];
T_ACI_PB_TEXT text;
//jgg
TRACE_EVENT("jgg-phb_store_entry");
//jgg
/* SPR#1112 - SH - Internal phonebook */
#ifdef INT_PHONEBOOK
if (book EQ PHB_IPB)
{
T_MFW ret;
ret = GI_pb_WriteRec(entry);
GI_pb_Info(status);
return ret;
}
#endif
/* check type of phonebook */
if (book NEQ PHB_ECC
AND book NEQ PHB_ADN
AND book NEQ PHB_FDN
AND book NEQ PHB_BDN
AND book NEQ PHB_SDN
AND book NEQ PHB_LRN
AND book NEQ PHB_LDN
AND book NEQ PHB_LMN
AND book NEQ PHB_UPN)
return MFW_PHB_FAIL;
/* select phonebook */
if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ( book )) NEQ AT_CMPL)
return MFW_PHB_FAIL;
memset(&dt, 0, sizeof(T_ACI_VP_ABS));
if (book EQ PHB_LDN
OR book EQ PHB_LRN
OR book EQ PHB_LMN)
{
memcpy(dt.year, entry->date.year, PHB_MAX_DIGITS);
memcpy(dt.month, entry->date.month, PHB_MAX_DIGITS);
memcpy(dt.day, entry->date.day, PHB_MAX_DIGITS);
memcpy(dt.hour, entry->time.hour, PHB_MAX_DIGITS);
memcpy(dt.minute, entry->time.minute, PHB_MAX_DIGITS);
memcpy(dt.second, entry->time.second, PHB_MAX_DIGITS);
}
memset(number, 0, sizeof(number));
if ((entry->ton == MFW_TON_INTERNATIONAL)
AND (entry->number[0] != '+')
)
strcpy(number, "+");
strcat(number, (CHAR *)entry->number);
#ifdef NO_ASCIIZ
text.len = entry->name.len;
memcpy(text.data, entry->name.data, text.len);
text.cs = CS_Sim;
#else
phb_Gsm2Alpha(entry->name, &text);
#endif
if (sAT_PlusCPBW(CMD_SRC_LCL,
(SHORT)(entry->index EQ 0 ? ACI_NumParmNotPresent : entry->index),
number,
NULL,
&text,
&dt) EQ AT_CMPL)
{
pb_read_status(book, &service, &total, &used, &tlength, &avail);
status->book = book;
status->max_entries = total;
status->used_entries = used;
status->tag_len = tlength;
status->avail_entries = avail;
}
else
return MFW_PHB_FAIL;
if (book EQ PHB_LDN
OR book EQ PHB_LRN
OR book EQ PHB_LMN)
{
pb_write_eeprom();
}
return MFW_PHB_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_delete_entry |
+--------------------------------------------------------------------+
PURPOSE : Delete phonebook entry
*/
T_MFW phb_delete_entry(UBYTE book, UBYTE index, T_MFW_PHB_STATUS *status)
{
UBYTE used;
UBYTE total;
UBYTE tlength;
UBYTE avail;
UBYTE service;
T_ACI_VP_ABS dt;
TRACE_FUNCTION("phb_delete_entry()");
/* SPR#1112 - SH - Internal phonebook */
#ifdef INT_PHONEBOOK
if (book EQ PHB_IPB)
{
T_MFW ret;
ret = GI_pb_DeleteRec(index);
GI_pb_Info(status);
return ret;
}
#endif
/* check type of phonebook */
if (book NEQ PHB_ECC
AND book NEQ PHB_LDN
AND book NEQ PHB_LRN
AND book NEQ PHB_LMN
AND book NEQ PHB_ADN
AND book NEQ PHB_FDN
AND book NEQ PHB_BDN
AND book NEQ PHB_SDN
AND book NEQ PHB_UPN)
return MFW_PHB_FAIL;
/* select phonebook */
if (sAT_PlusCPBS(CMD_SRC_LCL, phb_codePhbType ( book )) NEQ AT_CMPL)
return MFW_PHB_FAIL;
memset(&dt, 0, sizeof(T_ACI_VP_ABS));
if (sAT_PlusCPBW(CMD_SRC_LCL, index, NULL, NULL, NULL, &dt) EQ AT_CMPL)
{
pb_read_status(book, &service, &total, &used, &tlength, &avail);
status->book = book;
status->max_entries = total;
status->used_entries = used;
status->tag_len = tlength;
status->avail_entries = avail;
return MFW_PHB_OK;
}
else
return MFW_PHB_FAIL;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_set_mode |
+--------------------------------------------------------------------+
PURPOSE : Set the unrestricted/restricted mode for FDN or BDN
*/
T_MFW phb_set_mode(UBYTE book, UBYTE *passwd)
{
if (book == PHB_FDN)
{
if (ss_set_clck(CLCK_FAC_Fd, CLCK_MOD_Lock,
(char *)passwd, CLASS_Vce, MFW_PHB) != MFW_SS_OK)
return MFW_PHB_FAIL;
}
if (book == PHB_ADN)
{
if (ss_set_clck(CLCK_FAC_Fd, CLCK_MOD_Unlock,
(char *)passwd, CLASS_Vce, MFW_PHB) != MFW_SS_OK)
return MFW_PHB_FAIL;
}
return MFW_PHB_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_ok_clck |
+--------------------------------------------------------------------+
PURPOSE : successful switch for FDN
*/
void phb_ok_clck()
{
T_MFW_PHB_STATUS status;
memset(&status, 0, sizeof(T_MFW_PHB_STATUS));
status.book = FDN;
phb_get_status(&status);
phb_signal(E_PHB_STATUS, &status);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_error_clck |
+--------------------------------------------------------------------+
PURPOSE : unsuccessful switch for FDN or BDN
*/
void phb_error_clck()
{
phb_signal(E_PHB_ERROR, 0);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_check_number |
+--------------------------------------------------------------------+
PURPOSE : Check number against the restrictions for FDN or BDN
*/
T_MFW phb_check_number(UBYTE *number)
{
UBYTE found;
UBYTE index;
T_PHB_RECORD entry;
T_ACI_PB_TEXT text;
UBYTE toa;
T_ACI_TOA ton_npi;
int i;
int len = strlen((char *)number);
/* Search for '+' digit */
for (i = 0; (i < len) && (number[i] != '+'); i++);
/* '+' has been found */
if (i != len)
{
ton_npi.ton = TON_International;
/* Move characters of the input string to suppress the '+' */
for (i++; i < len; i++)
number[i-1] = number[i];
number[i-1] = '\0';
}
else
ton_npi.ton = TON_Unknown;
ton_npi.npi = NPI_IsdnTelephony;
cmhPHB_toaMrg ( &ton_npi, &toa );
if (pb_check_fdn(FDN, number, &found, &entry, toa) NEQ PHB_OK)
return MFW_PHB_FAIL;
if (found)
return PHB_FDN;
if (sAT_PlusCPBS(CMD_SRC_LCL, PB_STOR_Bd) NEQ AT_CMPL)
return MFW_PHB_FAIL;
text.len = MINIMUM(strlen((char *)number), PHB_MAX_LEN-1); //GW -SPR#762 - was MAX_ALPHA_LEN-1);
strncpy((char *)text.data, (char *)number, text.len);
text.data[text.len] = '\0';
text.cs = CS_Sim;
if (cmhPHB_PlusCPBF(CMD_SRC_LCL,
&text,
SR_TYP_Number,
CPBF_MOD_NewSearch, &index,
&found, pb_list) NEQ AT_CMPL)
return MFW_PHB_FAIL;
if (found)
return PHB_BDN;
return PHB_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_get_status |
+--------------------------------------------------------------------+
PURPOSE : Check number against the restrictions for FDN or BDN
*/
T_MFW phb_get_status(T_MFW_PHB_STATUS *status)
{
UBYTE type;
UBYTE service;
UBYTE used;
UBYTE total;
UBYTE tag_len;
UBYTE avail;
TRACE_FUNCTION("phb_get_status()");
/* SPR#1112 - SH - Internal phonebook */
#ifdef INT_PHONEBOOK
if (status->book EQ PHB_IPB)
{
GI_pb_Info(status);
return MFW_PHB_OK;
}
#endif
switch (status->book)
{
case PHB_ECC:
type = ECC;
break;
case PHB_ADN:
type = ADN;
break;
case PHB_FDN:
type = FDN;
break;
case PHB_ADN_FDN:
type = ADN_FDN;
break;
case PHB_BDN:
type = BDN;
break;
case PHB_SDN:
type = SDN;
break;
case PHB_LRN:
type = LRN;
break;
case PHB_LDN:
type = LDN;
break;
case PHB_LMN:
type = LMN;
break;
case PHB_UPN:
type = UPN;
break;
default:
return MFW_PHB_FAIL;
}
if (pb_read_status(type, &service, &total, &used,
&tag_len, &avail) == PHB_FAIL)
return MFW_PHB_FAIL;
status->max_entries = total;
status->used_entries = used;
status->tag_len = tag_len;
status->avail_entries = avail;
return MFW_PHB_OK;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_get_mode |
+--------------------------------------------------------------------+
PURPOSE : Request the status of FDN
*/
int phb_get_mode(void)
{
UBYTE stat;
T_ACI_CLSSTAT clsStat;
pb_status_req(&stat);
if (stat == PHB_BUSY)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -