📄 mfw_phb.c
字号:
T_ACI_TOA_NPI phb_ncvtNpi(T_MFW_PHB_TON npi)
{
switch (npi)
{
case MFW_NPI_ISDN: return NPI_IsdnTelephony;
case MFW_NPI_DATA: return NPI_Data;
case MFW_NPI_TELEX: return NPI_Telex;
case MFW_NPI_PRIVATE: return NPI_Private;
case MFW_NPI_NATIONAL: return NPI_National;
case MFW_NPI_M_ERMES: return NPI_ERMES;
case MFW_NPI_M_CTS: return NPI_CTS;
default: return NPI_Unknown;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
| STATE : code ROUTINE: phb_cvtService |
+--------------------------------------------------------------------+
PURPOSE : This function is used to convert the service related to
the phone number used by ACI to the service related to
the phone numberused by MFW.
*/
T_MFW_PHB_SERVICE phb_cvtService(T_ACI_CNUM_SERV service)
{
switch (service)
{
case CNUM_SERV_Asynch: return SERVICE_ASYNCH;
case CNUM_SERV_Synch: return SERVICE_SYNCH;
case CNUM_SERV_PadAsynch: return SERVICE_PAD_ASYNCH;
case CNUM_SERV_PacketSynch: return SERVICE_PACKET_SYNCH;
case CNUM_SERV_Voice: return SERVICE_VOICE;
case CNUM_SERV_Fax: return SERVICE_FAX;
default: return SERVICE_UNKNOWN;
}
}
/*
+--------------------------------------------------------------------+
| PROJECT: MMI-Framework (8417) MODULE: MFW_PHB |
| STATE : code ROUTINE: phb_init |
+--------------------------------------------------------------------+
PURPOSE :
*/
void phb_init()
{
TRACE_FUNCTION ("phb_init()");
return;
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_read_entries |
+--------------------------------------------------------------------+
PURPOSE : Read phonebook entries
*/
T_MFW phb_read_entries(UBYTE book,
UBYTE index,
UBYTE mode,
UBYTE num_entries,
T_MFW_PHB_LIST *entries)
{
SHORT start_ind;
SHORT stop_ind;
SHORT last_ind;
UBYTE rcd_num;
UBYTE sr_type;
SHORT i;
UBYTE x;
TRACE_FUNCTION ("phb_read_entries()");
TRACE_EVENT_P4("book%d index%d mode%d num%d", book, index, mode, num_entries);
/* SPR#1112 - SH - Internal phonebook */
#ifdef INT_PHONEBOOK
if (book EQ PHB_IPB)
{
return GI_pb_ReadRecList(mode, index, num_entries, entries);
}
#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_ADN_FDN
AND book NEQ PHB_UPN)
return MFW_PHB_FAIL;
if ((book EQ PHB_LRN
OR book EQ PHB_LDN
OR book EQ PHB_LMN)
AND (mode EQ MFW_PHB_NUMBER
OR mode EQ MFW_PHB_ALPHA))
return MFW_PHB_FAIL;
if (book EQ PHB_ECC
AND (mode EQ MFW_PHB_NUMBER
OR mode EQ MFW_PHB_ALPHA))
return MFW_PHB_FAIL;
if ((book EQ PHB_ADN_FDN)
AND (mode EQ MFW_PHB_INDEX))
return MFW_PHB_FAIL;
/* check index */
if (index <= 0)
return MFW_PHB_FAIL;
switch (mode)
{
case MFW_PHB_INDEX:
sr_type = SR_TYP_Index;
break;
case MFW_PHB_NUMBER:
sr_type = SR_TYP_Number;
break;
case MFW_PHB_ALPHA:
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;
/* Read entries */
entries->book = book;
rcd_num = 0;
start_ind = index;
stop_ind = index + (num_entries - 1);
while (num_entries > 0)
{
for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
pb_list[i].index = -1;
if (cmhPHB_PlusCPBR(CMD_SRC_LCL,
sr_type,
start_ind,
stop_ind,
&last_ind,
pb_list) EQ AT_CMPL)
{
x = 0;
for (i=start_ind; i<=last_ind; i++)
{
if (pb_list[x].index <= 0)
break;
memset(&entries->entry[rcd_num].date, 0, sizeof(entries->entry[rcd_num].date));
memset(&entries->entry[rcd_num].time, 0, sizeof(entries->entry[rcd_num].time));
if (book EQ PHB_LRN
OR book EQ PHB_LDN
OR book EQ PHB_LMN)
{
memcpy(entries->entry[rcd_num].date.year, pb_list[x].dateTime.year, PHB_MAX_DIGITS);
memcpy(entries->entry[rcd_num].date.month, pb_list[x].dateTime.month, PHB_MAX_DIGITS);
memcpy(entries->entry[rcd_num].date.day, pb_list[x].dateTime.day, PHB_MAX_DIGITS);
memcpy(entries->entry[rcd_num].time.hour, pb_list[x].dateTime.hour, PHB_MAX_DIGITS);
memcpy(entries->entry[rcd_num].time.minute, pb_list[x].dateTime.minute, PHB_MAX_DIGITS);
memcpy(entries->entry[rcd_num].time.second, pb_list[x].dateTime.second, PHB_MAX_DIGITS);
memcpy(&entries->entry[rcd_num].line, &pb_list[x].line, sizeof(UBYTE));
}
entries->entry[rcd_num].book = phb_decodePhbType (pb_list[x].book);
entries->entry[rcd_num].index = (UBYTE)pb_list[x].index;
// PATCH MAK 29/09/00. Put in because long number were overwriting the index therefore they were unable to be deleted
strncpy((char *)entries->entry[rcd_num].number, (char *)pb_list[x].number, (PHB_MAX_LEN-1));
// END PATCH MAK 29/09/00
#ifdef NO_ASCIIZ
memcpy(entries->entry[rcd_num].name.data, pb_list[x].text.data, pb_list[x].text.len);
entries->entry[rcd_num].name.len = pb_list[x].text.len;
#else
if (entries->entry[rcd_num].name[0] == 0x80 || entries->entry[rcd_num].name[0] == 0x00)
{ /*MC, SPR 1257 PHB_MAX_LEN is 41 when phonebook extension on, ACI only stores 21 char*/
memcpy(entries->entry[rcd_num].name, pb_list[x].text.data, /*PHB_MAX_LEN*/MAX_ALPHA_LEN);
}
else
phb_Alpha2Gsm(&pb_list[x].text, entries->entry[rcd_num].name);
#endif
entries->entry[rcd_num].ton = phb_cvtTon(pb_list[x].type.ton);
entries->entry[rcd_num].npi = phb_cvtNpi(pb_list[x].type.npi);
rcd_num++;
x++;
}
if (num_entries <= PHB_MAX_ENTRY_NUM OR pb_list[x].index EQ -1)
num_entries = 0;
else
num_entries -= PHB_MAX_ENTRY_NUM;
start_ind = last_ind + 1;
}
else
return MFW_PHB_FAIL;
}
if (rcd_num)
{
entries->result = MFW_ENTRY_EXIST;
entries->num_entries = rcd_num;
}
else
{
entries->result = MFW_NO_ENTRY;
}
return MFW_PHB_OK;
}
/* SPR#1727 - DS - Merged updated version from 1.6 branch. */
/* Test that the last 6 digits match.
If there are less than 6 numbers - its probably not a phone number.
GW- For emergency calls check a full exact match for the full (but short) length
*/
int numbersMatch(char * num1, char* num2)
{
int j;
int len1,len2;
int nDigits = 6;
len1 = strlen(num1);
len2 = strlen(num2);
//If the strings are the same size, test up to 6 characters.
if (len1 == len2)
nDigits = len1;
//Test at least 2 digits and at most 6.
if ((nDigits >6 ) || (nDigits<2))
nDigits = 6;
//Is either string too short ?
if ((len1 < nDigits) || (len2 < nDigits))
return (0);
//Check last 'nDigit' characters
for (j=0;j<nDigits;j++)
{
if (num1[len1-j] != num2[len2-j])
return (0);
}
return (1);
}
/*
+--------------------------------------------------------------------+
| PROJECT : MMI-Framework (8417) MODULE : MFW_PHB |
| STATE : code ROUTINE : phb_find_entries |
+--------------------------------------------------------------------+
PURPOSE : Find phonebook entries
*/
#ifdef NO_ASCIIZ
T_MFW phb_find_entries(UBYTE book,
UBYTE *index,
UBYTE mode,
UBYTE num_entries,
T_MFW_PHB_TEXT *search_pattern,
T_MFW_PHB_LIST *entries)
{
UBYTE found;
UBYTE i;
UBYTE rcd_num;
UBYTE search_mode;
UBYTE sr_type;
UBYTE sum;
T_ACI_PB_TEXT findText;
char dbg[80];
TRACE_FUNCTION ("phb_find_entries()");
/* SPR#1112 - SH - Internal phonebook */
#ifdef INT_PHONEBOOK
if (book EQ PHB_IPB)
{
return GI_pb_Find(mode, index, num_entries, search_pattern, entries);
}
#endif
if (book NEQ 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_ADN_FDN
AND book NEQ PHB_UPN)
return MFW_PHB_FAIL;
if ((book EQ PHB_ADN_FDN)
AND (mode EQ MFW_PHB_INDEX))
return MFW_PHB_FAIL;
switch (mode)
{
case MFW_PHB_INDEX:
sr_type = SR_TYP_Index;
break;
case MFW_PHB_NUMBER:
sr_type = SR_TYP_Number;
break;
case MFW_PHB_ALPHA:
if (!search_pattern->len)
return PHB_FAIL;
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;
TRACE_FUNCTION ("phb_find_entries()-got phonebook");
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;
if (mode EQ MFW_PHB_ALPHA)
{
findText.len = MINIMUM(search_pattern->len, MAX_ALPHA_LEN);
memcpy(findText.data, search_pattern->data, findText.len);
}
else
{
findText.len = MINIMUM(search_pattern->len, MAX_PHB_NUM_LEN-1); //GW -SPR#762
strncpy((char *)findText.data, (char *)search_pattern->data, 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)
{
sprintf(dbg,"findText data:%s, len:%d, type:%d m:%d i:%d f:%d",
findText.data, findText.len, (int)sr_type, (int)search_mode, (int)(*index), (int)found );
TRACE_FUNCTION (dbg);
for (i=0; i<PHB_MAX_ENTRY_NUM; i++)
{
if ((pb_list[i].index != -1) && (rcd_num < sum))
{
TRACE_FUNCTION ("phb_find_entries()-found entry");
sprintf(dbg,"number: found:'%s' search:'%s'",(char*)pb_list[i].number,(char*)search_pattern->data);
TRACE_FUNCTION (dbg);
if (numbersMatch((char*)pb_list[i].number,(char*)search_pattern->data))
{
TRACE_FUNCTION ("phb_find_entries()-numbers match");
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);
memcpy(entries->entry[rcd_num].name.data, pb_list[i].text.data, pb_list[i].text.len);
entries->entry[rcd_num].name.len = pb_list[i].text.len;
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;
}
#else
T_MFW phb_find_entries(UBYTE book,
UBYTE *index,
UBYTE mode,
UBYTE num_entries,
CHAR *search_pattern,
T_MFW_PHB_LIST *entries)
{
UBYTE found;
UBYTE i;
UBYTE rcd_num;
UBYTE search_mode;
UBYTE sr_type;
UBYTE sum;
T_ACI_PB_TEXT findText;
TRACE_FUNCTION ("phb_find_entries()");
if (book NEQ 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_ADN_FDN
AND book NEQ PHB_UPN)
return MFW_PHB_FAIL;
if ((book EQ PHB_ADN_FDN)
AND (mode EQ MFW_PHB_INDEX))
return MFW_PHB_FAIL;
switch (mode)
{
case MFW_PHB_INDEX:
sr_type = SR_TYP_Index;
break;
case MFW_PHB_NUMBER:
sr_type = SR_TYP_Number;
break;
case MFW_PHB_ALPHA:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -