📄 phb_handler_delete.c
字号:
control_block->actual_count,
control_block->src_id,
control_block);
return;
}
}
/* error */
else
{
phb_delete_err_handler(NULL, control_block);
return;
}
}
/* error */
else
{
phb_delete_err_handler(NULL, control_block);
return;
}
}
else
{
kal_trace(TRACE_ERROR, ERROR_PHB_STATE);
phb_delete_confirm(PHB_ERRNO_NOT_READY, control_block->actual_count, control_block->src_id, control_block);
return;
}
}
else
{
/* Delete confirmed */
if (control_block->proc_stage == DELETE_CONTINUE)
{
/* Piggyback is not required. */
#ifdef __PHB_SORT_ENABLE__
if (control_block->total_piggyback < 1)
#else
if (control_block->total_piggyback < 1 || control_block->type == PHB_PHONEBOOK)
#endif
{
phb_delete_confirm(
PHB_ERRNO_SUCCESS,
control_block->actual_count,
control_block->src_id,
control_block);
}
/* Piggyback is required */
else
{
/* Now we have to transform the state to a *FAKE* read state. */
control_block->total = control_block->total_piggyback;
/**
* Weird error happened. Anyway, the entry is already written
* successfully.
*/
if (phb_se_is_in_range(control_block->type, control_block->index, &control_block->total) == KAL_FALSE)
{
phb_delete_confirm(
PHB_ERRNO_SUCCESS,
control_block->actual_count,
control_block->src_id,
control_block);
return;
}
/* If any critial error occured. read_err_handler will handle it. */
if (phb_read_fake(control_block, NULL) == KAL_FALSE)
{
return;
}
/* Finally, faking complete....Now continue reading */
phb_read_continue(NULL, control_block);
return;
}
}
/* error */
else
{
phb_delete_err_handler(NULL, control_block);
return;
}
}
} /* end of phb_delete_handler */
/*****************************************************************************
* FUNCTION
* phb_delete_err_handler
* DESCRIPTION
* This is phb_delete_err_handler function of PHB module.
* PARAMETERS
* ilm_ptr [IN] The primitives
* control_block [?]
* RETURNS
* void
*****************************************************************************/
static void phb_delete_err_handler(ilm_struct *ilm_ptr, control_block_type *control_block)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_DELETE_ERR);
/**
* Shall we try to recover/continue handling,
* or just reject the request in processing?
* Currently, the latter is adpoted.
*/
phb_delete_confirm(PHB_ERRNO_FAIL, control_block->actual_count, control_block->src_id, control_block);
/*
* if (ilm_ptr != NULL)
* (*phb_ptr->control_block.controller)(ilm_ptr);
*/
} /* end of phb_delete_err_handler function */
/*****************************************************************************
* FUNCTION
* phb_delete_continue
* DESCRIPTION
* This is phb_delete_continue function of PHB module.
*
* Since only exactly one entry can be written at a time, this function just issues write
* request if it's time to begin write prepared data, or give control back to controller.
* PARAMETERS
* ilm_ptr [IN] The primitives
* control_block [?]
* RETURNS
* void
*****************************************************************************/
static void phb_delete_continue(ilm_struct *ilm_ptr, control_block_type *control_block)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_DELETE_CONT);
/* It's time to write prepared dat */
if (ilm_ptr == NULL)
{
/*
* If it is a MSISDN record, need to retrieve data first to see if it uses a extension 1 record.
* * So issue IO read here before issue IO delete
*/
if (control_block->type == PHB_MSISDN)
{
phb_issue_IO_read(control_block);
}
else
{
phb_issue_IO_delete(control_block);
}
}
/* Write confirmed. Give control back to contoller */
else
{
/*
* For 1 to 1 mapping
* For MSISDN, read the record from SIM first to see if it uses extension 1 record
* and then issue IO delete command here.
*/
if (control_block->type == PHB_MSISDN)
{
/* Free control buffer for SIM read. The data is not needed later. */
if (control_block->data != NULL)
{
free_ctrl_buffer(control_block->data);
control_block->data = NULL;
}
/*
* Use "candidate" variable in control block to check if this is first time receive MSISDN read confirm.
* If first time come in, issue delete command to delete MSISDN record here.
*/
if (control_block->candidate == 0)
{
control_block->candidate = 1;
phb_issue_IO_delete(control_block);
return;
}
else /* control_block->candidate == 1, after phb_issue_IO_delete() command. */
{
kal_uint8 ext_index = (kal_uint8) PHB_INVALID_VALUE;
++control_block->index;
/*
* Makr extension record to free if MSISDN uses extension record.
* No need to mark primary_ID free because MSISDN status does not keep in phb.
*/
ext_index = control_block->seg_record_index;
if (ext_index > 0 && ext_index != (kal_uint8) PHB_INVALID_VALUE)
{
phb_data_desc_mark_free(
phb_data_desc_get_desc_by_ID(control_block->secondary_ID),
ext_index,
KAL_TRUE);
}
}
control_block->seg_record_index = 0;
}
else
{
kal_uint8 ext_index = (kal_uint8) PHB_INVALID_VALUE;
control_block->candidate = control_block->index;
/* First we have to sync the deleted entry into search engine */
/* The deleted index is in control_block->index */
if (control_block->type == PHB_PHONEBOOK && control_block->storage == PHB_SIM)
{
ext_index = phb_se_ext_index_find(control_block->record_index, control_block->type);
/* delete entry in ext_index_table */
phb_se_ext_index_delete(control_block->record_index, control_block->type);
}
phb_se_delete(control_block->type, (kal_uint16) (control_block->index - 1), &ext_index);
/* Delete complete, mark it as FREE */
phb_data_desc_mark_free(
phb_data_desc_get_desc_by_ID(control_block->primary_ID),
control_block->record_index,
KAL_TRUE);
if (ext_index > 0 && ext_index != (kal_uint8) PHB_INVALID_VALUE)
{
phb_data_desc_mark_free(phb_data_desc_get_desc_by_ID(control_block->secondary_ID), ext_index, KAL_TRUE);
}
#ifdef __PHB_USIM_SUPPORT__
if (control_block->type == PHB_PHONEBOOK && control_block->storage == PHB_SIM && is_usim_type())
{
kal_uint16 iap_index = 0;
ext_index = phb_se_ext_index_find(control_block->record_index, PHB_ANRA);
/* Delete complete, mark it as FREE */
if (ext_index > 0 && ext_index != (kal_uint8) PHB_INVALID_VALUE)
{
/* delete entry in ext_index_table */
phb_se_ext_index_delete(control_block->record_index, PHB_ANRA);
phb_data_desc_mark_free(
phb_data_desc_get_desc_by_ID(control_block->secondary_ID),
ext_index,
KAL_TRUE);
}
ext_index = phb_se_ext_index_find(control_block->record_index, PHB_ANRB);
/* Delete complete, mark it as FREE */
if (ext_index > 0 && ext_index != (kal_uint8) PHB_INVALID_VALUE)
{
/* delete entry in ext_index_table */
phb_se_ext_index_delete(control_block->record_index, PHB_ANRB);
phb_data_desc_mark_free(
phb_data_desc_get_desc_by_ID(control_block->secondary_ID),
ext_index,
KAL_TRUE);
}
ext_index = phb_se_ext_index_find(control_block->record_index, PHB_ANRC);
/* Delete complete, mark it as FREE */
if (ext_index > 0 && ext_index != (kal_uint8) PHB_INVALID_VALUE)
{
/* delete entry in ext_index_table */
phb_se_ext_index_delete(control_block->record_index, PHB_ANRC);
phb_data_desc_mark_free(
phb_data_desc_get_desc_by_ID(control_block->secondary_ID),
ext_index,
KAL_TRUE);
}
if (phb_ptr->email_type == 2)
{
iap_index = phb_se_iap_index_find(control_block->record_index, DATA_DESC_EMAIL);
if (iap_index > 0 && iap_index != (kal_uint8) PHB_INVALID_VALUE)
{
/* delete entry in iap_index_table */
phb_se_iap_index_delete(control_block->record_index, DATA_DESC_EMAIL);
/* Since data is deleted, that record must be marked */
phb_data_desc_mark_free(DATA_DESC_EMAIL, iap_index, KAL_TRUE);
}
}
}
#endif /* __PHB_USIM_SUPPORT__ */
}
++control_block->actual_count;
/* Delete complete, now return control back to controller */
if (control_block->actual_count >= control_block->total)
{
(*control_block->controller) (NULL, control_block);
}
/**
* Still others to delete
* Since index, total is in ensured to be in range, tested in handler(), it is uncessary
* to test it here.
*/
else if (control_block->index != (kal_uint16) PHB_INVALID_VALUE)
{
/**
* Index should NOT be decremented!!
* Because entries will be shift into the deleted index!!
*/
/* amanda add */
if (control_block->type == PHB_PHONEBOOK)
{
#ifdef __PHB_SORT_ENABLE__
control_block->index = phb_se_get_index_by_storage(control_block->storage);
#else
control_block->index = phb_delete_find_next_deleted(control_block->storage);
#endif
/* no more to delete */
if (control_block->index == (kal_uint16) PHB_INVALID_VALUE)
{
(*control_block->controller) (NULL, control_block);
return;
}
}
/* set storage, record_index, primary_ID, and secondary_ID */
if (phb_se_set_control_block(
control_block,
OP_DELETE,
PHB_STORAGE_NONE,
(kal_uint16) PHB_INVALID_VALUE) == KAL_FALSE)
{
phb_delete_err_handler(NULL, control_block);
return;
}
control_block->length = phb_data_desc_get_record_size(phb_data_desc_get_desc_by_ID(control_block->primary_ID));
phb_issue_IO_delete(control_block);
}
/* error */
else
{
phb_delete_err_handler(NULL, control_block);
return;
}
}
} /* end of phb_delete_continue */
/*****************************************************************************
* FUNCTION
* phb_delete_confirm
* DESCRIPTION
* This is phb_delete_confirm function of PHB module.
* PARAMETERS
* result [IN]
* actual_count [IN]
* src_id [IN]
* control_block [?]
* ilm_ptr(?) [IN] The primitives
* RETURNS
* void
*****************************************************************************/
static void phb_delete_confirm(
phb_errno_enum result,
kal_uint16 actual_count,
kal_uint8 src_id,
control_block_type *control_block)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -