PhoneBookOperateMass.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:158k
源码类别:
MTK
开发平台:
C/C++
- }
- flag = mmi_phb_op_increase_lookup_table(store_index, (S8*) localPtr->list[0].tel.number, NULL, NULL, NULL);
- if (flag)
- {
- mmi_phb_lookup_table_sort();
- }
- PhoneBook[store_index].alpha_id.name_length = localPtr->list[0].alpha_id.name_length;
- PhoneBook[store_index].alpha_id.name_dcs = localPtr->list[0].alpha_id.name_dcs;
- InputboxConvertGSMToDeviceEncoding(
- localPtr->list[0].alpha_id.name,
- PhoneBook[store_index].alpha_id.name,
- localPtr->list[0].alpha_id.name_length,
- (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH,
- localPtr->list[0].alpha_id.name_dcs,
- 0,
- 1);
- PhoneBook[store_index].tel.type = localPtr->list[0].tel.type;
- PhoneBook[store_index].tel.length = localPtr->list[0].tel.length;
- mmi_phb_convert_to_bcd(
- PhoneBook[store_index].tel.number,
- localPtr->list[0].tel.number,
- (MAX_PB_NUMBER_LENGTH + 1) / 2);
- /* Update is column exists flag. */
- PhoneBook[store_index].field = 0;
- if (strlen((S8*) localPtr->list[0].tel.number))
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_NUMBER;
- }
- /* Update Pinyin Cache for sort */
- #if defined(__MMI_PHB_PINYIN_SORT__)
- mmi_phb_util_make_pinyin_cache(store_index);
- #endif
- /* Insert name to name mapping table. */
- mmi_phb_sort_insert_name_index(store_index);
- /* Insert email to email mapping table */
- #if defined(__MMI_PHB_EMAIL_SORT__)
- #ifdef __MMI_PHB_USIM_FIELD__
- if (g_phb_email_sorted == 1)
- #else
- if ((localPtr->list[0].storage == MMI_NVRAM) && (g_phb_email_sorted == 1))
- #endif
- mmi_phb_sort_email_insert_index(store_index);
- #endif /* defined(__MMI_PHB_EMAIL_SORT__) */
- g_phb_cntx.refresh_list = MMI_PHB_ENTRY_REFRESH;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_at_cmd_delete
- * DESCRIPTION
- * Handles the phonebook update indication after an entry is deleted through AT command.
- * PARAMETERS
- * info [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_at_cmd_delete(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MSG_PHB_UPDATE_IND_STRUCT *localPtr;
- U16 deletedCnt = 0;
- U16 store_index;
- PHB_OPTIONAL_IDS_STRUCT *opt_ids;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- localPtr = (MSG_PHB_UPDATE_IND_STRUCT*) info;
- if (localPtr->list[0].storage == MMI_SIM)
- {
- store_index = localPtr->list[0].record_index + MAX_PB_PHONE_ENTRIES - 1; /* Storage Location in array. */
- }
- else /* MMI_NVRAM */
- {
- store_index = localPtr->list[0].record_index - 1;
- #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
- /* Delete image file in file folder */
- mmi_phb_read_optional_ids(store_index);
- opt_ids = (PHB_OPTIONAL_IDS_STRUCT*) g_phb_cntx.optional_ids;
- if (opt_ids->pictureTagID == 1)
- {
- mmi_phb_image_delete_by_index((U16) (store_index + 1));
- }
- #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */
- #if defined(__MMI_INCOMING_CALL_VIDEO__)
- mmi_phb_video_delete_by_index(store_index); /* Clear video field. */
- #endif
- /* Clear birthday field */
- #if defined(__MMI_PHB_BIRTHDAY_FIELD__) && defined(__MMI_BIRTHDAY_REMINDER__)
- mmi_phb_bday_delete_field(store_index);
- #endif
- /* Remove email entry from email sort mapping table */
- #if defined(__MMI_PHB_EMAIL_SORT__)
- if (g_phb_email_sorted == 1)
- {
- mmi_phb_sort_email_delete_index(store_index);
- }
- #endif /* defined(__MMI_PHB_EMAIL_SORT__) */
- }
- if (mmi_phb_util_check_entry_exist(store_index))
- {
- if (localPtr->list[0].storage == MMI_SIM)
- {
- g_phb_cntx.sim_used--;
- }
- else /* MMI_NVRAM */
- {
- g_phb_cntx.phone_used--;
- #ifdef __SYNCML_SUPPORT__
- mmi_syncml_phb_data_changed_notification(SYNCML_RECORD_DELETE, store_index);
- #endif
- }
- }
- /* Remove lookup table entry */
- deletedCnt = mmi_phb_op_clear_lookup_table_by_index(store_index);
- if (deletedCnt)
- {
- mmi_phb_lookup_table_sort();
- g_phb_cntx.lookup_table_count -= deletedCnt;
- }
- /* clear phonebook entry and remove from index */
- mmi_phb_op_delete_update_index(store_index);
- g_phb_cntx.refresh_list = MMI_PHB_ENTRY_REFRESH;
- mmi_phb_refresh_phb_list();
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_at_cmd_delete_all
- * DESCRIPTION
- * Handles the phonebook update indication after an all the entries of one storage
- * location is deleted through AT command
- * PARAMETERS
- * info [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_at_cmd_delete_all(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 storage;
- MSG_PHB_UPDATE_IND_STRUCT *localPtr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- localPtr = (MSG_PHB_UPDATE_IND_STRUCT*) info;
- if (localPtr->nvram_used == 0 && g_phb_cntx.phone_used != 0)
- {
- storage = MMI_NVRAM;
- mmi_phb_op_delete_all_update_optioal_id();
- }
- else
- {
- storage = MMI_SIM;
- }
- /* Clear all storage and clear up name index. */
- mmi_phb_op_delete_all_update_index(storage);
- mmi_phb_op_delete_all_update_lookup_table(storage);
- /* Remove email entry from email sort mapping table */
- #if defined(__MMI_PHB_EMAIL_SORT__)
- if ((storage == MMI_NVRAM) && (g_phb_email_sorted == 1))
- {
- mmi_phb_sort_email_delete_all_index();
- }
- #endif /* defined(__MMI_PHB_EMAIL_SORT__) */
- mmi_phb_refresh_phb_list();
- }
- #ifdef __MMI_VCARD__
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_vcard_req_writer_v21_to_file
- * DESCRIPTION
- * write select phonebook entry into vcard format into destination file.
- * PARAMETERS
- * path [IN] Destination path
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- S32 mmi_phb_vcard_req_writer_v21_to_file(S8 *path, U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 pError;
- S8 number_buff[(MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
- PHB_OPTIONAL_FIELDS_STRUCT phb_opt_fields;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Mobile Number */
- if (PhoneBook[store_index].tel.type == MMI_CSMCC_INTERNATIONAL_ADDR)
- {
- number_buff[0] = '+';
- mmi_phb_convert_to_digit((U8*) number_buff + 1, PhoneBook[store_index].tel.number, MAX_PB_NUMBER_LENGTH + 1);
- }
- else
- {
- mmi_phb_convert_to_digit((U8*) number_buff, PhoneBook[store_index].tel.number, MAX_PB_NUMBER_LENGTH + 1);
- }
- if (store_index < MAX_PB_PHONE_ENTRIES) /* In NVRAM */
- {
- #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
- S8 b_day[9]; /* Format: yyyymmdd */
- mmi_vcard_get_bday_to_buff(store_index, (S8*) b_day);
- #endif /* defined(__MMI_PHB_BIRTHDAY_FIELD__) */
- #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
- ReadRecord(
- NVRAM_EF_PHB_FIELDS_LID,
- (U16) (store_index + 1),
- (void*)&phb_opt_fields,
- OPTIONAL_FIELDS_RECORD_SIZE,
- &pError);
- #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- return mmi_vcard_writer_v21_to_file(path, (S8*) PhoneBook[store_index].alpha_id.name, (S8*) number_buff,
- #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
- (S8*) phb_opt_fields.homeNumber,
- (S8*) phb_opt_fields.officeNumber,
- (S8*) phb_opt_fields.faxNumber,
- (S8*) phb_opt_fields.emailAddress, (S8*) phb_opt_fields.companyName,
- #else /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- NULL, NULL, NULL, NULL, NULL,
- #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
- b_day,
- #else
- NULL,
- #endif
- NULL, NULL, NULL);
- }
- return mmi_vcard_writer_v21_to_file(
- path,
- (S8*) PhoneBook[store_index].alpha_id.name,
- (S8*) number_buff,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL);
- }
- #endif /* __MMI_VCARD__ */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_vcard_req_confirm
- * DESCRIPTION
- * After MMI update done, send back confirm message.
- * PARAMETERS
- * mode [IN]
- * req_result [IN]
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_vcard_req_confirm(U8 mode, BOOL req_result, U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_eq_vcard_res_req_struct *myMsgPtr;
- MYQUEUE Message;
- S32 result;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- myMsgPtr = (mmi_eq_vcard_res_req_struct*) OslConstructDataPtr(sizeof(mmi_eq_vcard_res_req_struct));
- #ifdef __MMI_VCARD__
- if (mode == 1) /* req_result value is FALSE at first */
- {
- if (mmi_phb_util_check_entry_exist(store_index))
- {
- S32 check_result = mmi_vobj_fs_check_folder();
- /* Create file path and folder. */
- if (check_result == FS_NO_ERROR)
- {
- mmi_phb_vcard_req_set_default_file((S8*) myMsgPtr->file_path);
- result = mmi_phb_vcard_req_writer_v21_to_file((S8*) myMsgPtr->file_path, store_index);
- if (result != VOBJ_ERR_NO_ERROR)
- {
- FS_Delete((U16*) myMsgPtr->file_path);
- }
- else
- {
- req_result = TRUE; /* only this case is true */
- }
- }
- }
- }
- #endif /* __MMI_VCARD__ */
- myMsgPtr->result = req_result;
- myMsgPtr->mode = mode;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- Message.oslMsgId = MSG_ID_MMI_EQ_VCARD_RES_REQ;
- Message.oslDataPtr = (oslParaType*) myMsgPtr;
- Message.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&Message);
- }
- #ifdef __MMI_VCARD__
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_vcard_clear_data_buffer
- * DESCRIPTION
- * Clears buffers used for adding/editing entry
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_vcard_clear_data_buffer(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memset(pbvCardHomeNumber, 0, ENCODING_LENGTH);
- memset(pbvCardCompanyName, 0, ENCODING_LENGTH);
- memset(pbvCardEmailAddress, 0, ENCODING_LENGTH);
- memset(pbvCardOfficeNumber, 0, ENCODING_LENGTH);
- memset(pbvCardFaxNumber, 0, ENCODING_LENGTH);
- #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
- pfnUnicodeStrcpy(pbvCardYear, (S8*) MMI_PHB_BDAY_YEAR_STR);
- pfnUnicodeStrcpy(pbvCardMon, (S8*) MMI_PHB_BDAY_MON_STR);
- pfnUnicodeStrcpy(pbvCardDay, (S8*) MMI_PHB_BDAY_DAY_STR);
- #endif /* defined(__MMI_PHB_BIRTHDAY_FIELD__) */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_vcard_req_set_default_file
- * DESCRIPTION
- *
- * PARAMETERS
- * path [?]
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_phb_vcard_req_set_default_file(S8 *path)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 *ascii_path;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ascii_path = OslMalloc(25);
- /* VOBJ_FILE_PATH */
- sprintf(ascii_path, "%c:\Received\~vcard_r.vcf", MMI_PUBLIC_DRV);
- AnsiiToUnicodeString(path, ascii_path);
- OslMfree(ascii_path);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_vcard_reader_parse_line
- * DESCRIPTION
- * Read one line to parse for each filed.
- * PARAMETERS
- * fh [IN] file handle ready to read and parse.
- * RETURNS
- * parse error cause
- *****************************************************************************/
- U8 mmi_phb_vcard_reader_parse_line(FS_HANDLE fh)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S8 inBuff[512]; /* same as VOBJ_READ_BUFF_LEN */
- U8 token;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* BEGIN:VCARD */
- if (mmi_vcard_uti_get_single_line(inBuff, fh) != 0)
- {
- if (mmi_vcard_reader_get_field(inBuff) != VCARD_FIELD_BEGIN)
- {
- return VCARD_BEGIN_ERROR;
- }
- else if (!mmi_vcard_reader_check_header(inBuff))
- {
- return VCARD_BEGIN_ERROR;
- }
- }
- else
- {
- return VCARD_PARSE_UNKNOW_ERROR;
- }
- /* PARSE EACH FIELD */
- while (mmi_vcard_uti_get_line(inBuff, fh) != 0)
- {
- token = mmi_vcard_reader_get_field(inBuff);
- switch (token)
- {
- case VCARD_FIELD_END:
- if (!mmi_vcard_reader_check_header(inBuff))
- {
- return VCARD_PARSE_UNKNOW_ERROR;
- }
- else
- {
- return VCARD_PARSE_NO_ERROR;
- }
- break;
- case VCARD_FIELD_PHOTO:
- return VCARD_PARSE_NO_ERROR;
- /* VERSION */
- case VCARD_FIELD_VERSION:
- if (!mmi_vcard_reader_check_version(inBuff))
- {
- return VCARD_VERSION_ERROR;
- }
- break;
- case VCARD_FIELD_N:
- /* mmi_vcard_reader_retrive_name(inBuff); */
- break;
- case VCARD_FIELD_TEL:
- mmi_vcard_reader_retrive_number(inBuff, NULL, pbvCardHomeNumber, pbvCardOfficeNumber, pbvCardFaxNumber);
- break;
- case VCARD_FIELD_EMAIL:
- mmi_vcard_reader_retrive_email(inBuff, pbvCardEmailAddress);
- break;
- case VCARD_FIELD_ORG:
- mmi_vcard_reader_retrive_org(inBuff, pbvCardCompanyName);
- break;
- #ifdef __MMI_PHB_BIRTHDAY_FIELD__
- case VCARD_FIELD_BDAY:
- mmi_vcard_reader_retrive_bday(inBuff, pbvCardYear, pbvCardMon, pbvCardDay, FALSE);
- break;
- #endif /* __MMI_PHB_BIRTHDAY_FIELD__ */
- #ifdef __MMI_PHB_INFO_FIELD__
- case VCARD_FIELD_TITLE:
- break;
- #endif /* __MMI_PHB_INFO_FIELD__ */
- default:
- break;
- }
- }
- return VCARD_PARSE_UNKNOW_ERROR;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_vcard_req_save_obj_to_phb
- * DESCRIPTION
- * save parsed vcard to phonebook after parsing.
- * PARAMETERS
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- BOOL mmi_phb_vcard_req_save_obj_to_phb(U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- PHB_OPTIONAL_FIELDS_STRUCT phb_opt_fields;
- S16 pError;
- U8 temp_number[MAX_PB_NUMBER_LENGTH + 1 + 1];
- U16 deletedCnt = 0;
- U8 flag = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (!g_phb_cntx.phb_ready || g_phb_cntx.processing) /* Phonebook not ready */
- {
- return FALSE;
- }
- #ifdef __SYNCML_SUPPORT__
- else if (mmi_syncml_is_phb_sync_now())
- {
- return FALSE;
- }
- #endif /* __SYNCML_SUPPORT__ */
- else if (store_index >= MAX_PB_PHONE_ENTRIES) /* only nvram data. */
- {
- return FALSE;
- }
- else if ((!mmi_phb_op_check_valid_number(pbvCardHomeNumber) || /* Number format not correct */
- !mmi_phb_op_check_valid_number(pbvCardOfficeNumber) || !mmi_phb_op_check_valid_number(pbvCardFaxNumber)))
- {
- return FALSE;
- }
- mmi_phb_convert_to_digit(temp_number, PhoneBook[store_index].tel.number, MAX_PB_NUMBER_LENGTH + 1);
- /* Clear lookup table first, add later if exists. */
- deletedCnt = mmi_phb_op_clear_lookup_table_by_index(store_index);
- UnicodeToAnsii((PS8) phb_opt_fields.homeNumber, pbvCardHomeNumber);
- pfnUnicodeStrcpy((PS8) phb_opt_fields.companyName, pbvCardCompanyName);
- UnicodeToAnsii((PS8) phb_opt_fields.emailAddress, pbvCardEmailAddress);
- UnicodeToAnsii((PS8) phb_opt_fields.officeNumber, pbvCardOfficeNumber);
- UnicodeToAnsii((PS8) phb_opt_fields.faxNumber, pbvCardFaxNumber);
- WriteRecord(
- NVRAM_EF_PHB_FIELDS_LID,
- (U16) (store_index + 1),
- (void*)&phb_opt_fields,
- OPTIONAL_FIELDS_RECORD_SIZE,
- &pError);
- #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
- flag = mmi_phb_op_increase_lookup_table(
- store_index,
- NULL,
- (S8*) phb_opt_fields.faxNumber,
- (S8*) phb_opt_fields.homeNumber,
- (S8*) phb_opt_fields.officeNumber);
- #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- flag += mmi_phb_op_increase_lookup_table(store_index, (S8*) temp_number, NULL, NULL, NULL);
- if (deletedCnt || flag)
- {
- mmi_phb_lookup_table_sort();
- g_phb_cntx.lookup_table_count -= deletedCnt;
- }
- /* Update is column exists flag. */
- #if defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
- mmi_phb_op_update_field_flag(store_index, (S8*) temp_number, NULL, NULL, NULL, NULL, FALSE);
- #else /* defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- mmi_phb_op_update_field_flag(
- store_index,
- (S8*) temp_number,
- (S8*) phb_opt_fields.homeNumber,
- (S8*) phb_opt_fields.officeNumber,
- (S8*) phb_opt_fields.faxNumber,
- (S8*) phb_opt_fields.emailAddress,
- FALSE);
- #endif /* defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- /* Save birthday field */
- #if defined(__MMI_PHB_BIRTHDAY_FIELD__)
- mmi_phb_bday_update_field(store_index, (S8*) pbvCardYear, (S8*) pbvCardMon, (S8*) pbvCardDay);
- #endif
- /* Update email sorting mapping table */
- #if defined(__MMI_PHB_EMAIL_SORT__)
- #ifdef __MMI_PHB_USIM_FIELD__
- if (g_phb_email_sorted == 1)
- #else
- if ((store_index < MAX_PB_PHONE_ENTRIES) && (g_phb_email_sorted == 1))
- #endif
- {
- mmi_phb_sort_email_delete_index(store_index);
- mmi_phb_sort_email_insert_index(store_index);
- }
- #endif /* defined(__MMI_PHB_EMAIL_SORT__) */
- return TRUE;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_save_vcard_req
- * DESCRIPTION
- *
- * PARAMETERS
- * path [?]
- * index [IN]
- * RETURNS
- *
- *****************************************************************************/
- BOOL mmi_phb_save_vcard_req(S8 *path, U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- FS_HANDLE fh;
- U8 error_code = VCARD_PARSE_UNKNOW_ERROR;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- fh = FS_Open((U16*) path, FS_READ_ONLY);
- if (fh > 0)
- {
- mmi_phb_vcard_clear_data_buffer(); /* Clear all phonebook vcard temp buffer before parsing */
- error_code = mmi_phb_vcard_reader_parse_line(fh);
- FS_Close(fh);
- }
- else
- {
- error_code = MMI_PHB_VCARD_OPEN_FILE_ERROR;
- }
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_save_vcard_req. error_code: %d>n",
- __FILE__, __LINE__, error_code));
- if (error_code == VCARD_PARSE_NO_ERROR)
- {
- return mmi_phb_vcard_req_save_obj_to_phb(index);
- }
- else
- {
- return FALSE;
- }
- }
- #endif /* __MMI_VCARD__ */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_vcard_req
- * DESCRIPTION
- * This function handles the read indication through AT commands
- * PARAMETERS
- * info [?]
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_phb_vcard_req(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_eq_vcard_req_ind_struct *localPtr;
- U16 index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_vcard_req.>n", __FILE__, __LINE__));
- localPtr = (mmi_eq_vcard_req_ind_struct*) info;
- index = localPtr->index;
- ASSERT(index >= 1) index--; /* 1-based */
- #ifdef __MMI_VCARD__
- if (localPtr->mode == 0 && mmi_phb_save_vcard_req((S8*) localPtr->file_path, index))
- {
- mmi_phb_vcard_req_confirm(localPtr->mode, TRUE, index);
- }
- else
- {
- mmi_phb_vcard_req_confirm(localPtr->mode, FALSE, index);
- }
- #else /* __MMI_VCARD__ */
- mmi_phb_vcard_req_confirm(localPtr->mode, FALSE, index);
- #endif /* __MMI_VCARD__ */
- }
- #define MMI_PHB_OPERATE_UTIL
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_mass_processing_abort
- * DESCRIPTION
- * abort function of processing screen. It will set up the abort flag.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_mass_processing_abort(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_phb_mass_op_abort = TRUE;
- mmi_phb_show_in_progress(STR_COPY_ALL_ABORTING, IMG_COPY_ALL_ABORTING);
- DeleteScreenIfPresent(SCR_COPY_ALL_PROGRESS);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_delete_all_update_index
- * DESCRIPTION
- * update name index after delete all.
- * PARAMETERS
- * storage [IN] Storage location
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_delete_all_update_index(U8 storage)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 pos, i;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < PhoneBookEntryCount; i++)
- {
- if ((storage == MMI_SIM && g_phb_name_index[i] >= MAX_PB_PHONE_ENTRIES) ||
- (storage == MMI_NVRAM && g_phb_name_index[i] < MAX_PB_PHONE_ENTRIES))
- {
- g_phb_name_index[i] = 0xffff;
- }
- }
- pos = 0;
- while (pos < PhoneBookEntryCount)
- {
- if (g_phb_name_index[pos] == 0xffff)
- {
- for (i = pos; i < PhoneBookEntryCount; i++)
- {
- g_phb_name_index[i] = g_phb_name_index[i + 1];
- }
- PhoneBookEntryCount--;
- }
- pos++;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_delete_all_update_lookup_table
- * DESCRIPTION
- * clear lookup table
- * PARAMETERS
- * storage [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_delete_all_update_lookup_table(U8 storage)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 k;
- U16 deletedCnt = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Remove lookup table entry */
- for (k = 0; k < g_phb_cntx.lookup_table_count; ++k)
- {
- if ((storage == MMI_SIM && LookUpTable[k].store_index >= MAX_PB_PHONE_ENTRIES) ||
- (storage == MMI_NVRAM && LookUpTable[k].store_index < MAX_PB_PHONE_ENTRIES))
- {
- LookUpTable[k].number = INVALID_NUMBER;
- ++deletedCnt;
- }
- }
- if (deletedCnt)
- {
- mmi_phb_lookup_table_sort();
- g_phb_cntx.lookup_table_count -= deletedCnt;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_delete_all_update_optioal_id
- * DESCRIPTION
- * Update optional id on NVRAM after delete all.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_delete_all_update_optioal_id(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 i, j;
- S16 pError;
- U8 optid_record, optid_index, current_record = 0;
- PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (i = 0; i < MAX_PB_PHONE_ENTRIES; i++)
- {
- /* If entry still exist, do not clear. */
- for (j = 0; j < PhoneBookEntryCount; j++)
- {
- if (i == g_phb_name_index[j])
- {
- continue;
- }
- }
- /* Get optional IDs record. */
- optid_record = (i / OPTIONAL_IDS_RECORD_TOTAL) + 1;
- optid_index = i - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
- if (optid_record != current_record)
- {
- ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- current_record = optid_record;
- }
- /* Clear image in file system */
- #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
- if (PhbOptIDs[optid_index].pictureTagID == 1)
- {
- mmi_phb_image_delete_by_index((U16) (i + 1));
- }
- #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_update_optional_field
- * DESCRIPTION
- * Saves optional fields of a Phone entry on NVRAM
- * PARAMETERS
- * store_index [IN]
- * storage [IN]
- * type [IN] if type 0 is for Java PIM, don't need copy opt IDs.
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_update_optional_field(U16 store_index, U8 storage, U8 type)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 pError;
- U8 optid_record;
- U8 optid_index;
- /* U8 grpIndex; */
- PHB_OPTIONAL_IDS_STRUCT tempIDs;
- PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /*
- * Update optional fields.
- */
- #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
- if (storage == MMI_NVRAM)
- {
- UnicodeToAnsii((PS8) PhoneBookOptionalFields.homeNumber, pbHomeNumber);
- pfnUnicodeStrcpy((PS8) PhoneBookOptionalFields.companyName, pbCompanyName);
- UnicodeToAnsii((PS8) PhoneBookOptionalFields.emailAddress, pbEmailAddress);
- UnicodeToAnsii((PS8) PhoneBookOptionalFields.officeNumber, pbOfficeNumber);
- UnicodeToAnsii((PS8) PhoneBookOptionalFields.faxNumber, pbFaxNumber);
- WriteRecord(
- NVRAM_EF_PHB_FIELDS_LID,
- (U16) (store_index + 1),
- (void*)&PhoneBookOptionalFields,
- OPTIONAL_FIELDS_RECORD_SIZE,
- &pError);
- }
- #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- #if defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC)
- if (type == 0)
- {
- return;
- }
- #endif /* defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC) */
- /*
- * Update optional selection field (id), and caller group counter
- */
- /* Read out related optional id record */
- optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
- optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
- ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- /* assign user selected optional id */
- #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
- if (g_phb_cntx.selected_pic_index == g_phb_cntx.total_image_id - 1)
- {
- tempIDs.pictureTagID = 1;
- }
- else
- #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */
- tempIDs.pictureTagID = g_phb_cntx.image_id_list[g_phb_cntx.selected_pic_index];
- tempIDs.callerGroupID = (U8) g_phb_cntx.selected_grp_index;
- tempIDs.ringToneID = g_phb_cntx.ring_tone_list[g_phb_cntx.selected_ring_index];
- #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__) /* Associate caller group in SIM card entry */
- if (storage == MMI_SIM)
- {
- tempIDs.pictureTagID = 0;
- tempIDs.ringToneID = 0;
- }
- #endif /* defined(__MMI_PHB_CALLERGROUP_IN_SIM__) */
- /* Update associate id and write it back */
- memcpy(&PhbOptIDs[optid_index], &tempIDs, sizeof(PHB_OPTIONAL_IDS_STRUCT));
- WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_read_optional_ids
- * DESCRIPTION
- * read one optional id for one entry
- * PARAMETERS
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_read_optional_ids(U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 optid_record;
- U8 optid_index;
- S16 pError;
- PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
- optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
- ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- memcpy(g_phb_cntx.optional_ids, &PhbOptIDs[optid_index], sizeof(PHB_OPTIONAL_IDS_STRUCT));
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_clear_optional_ids
- * DESCRIPTION
- * clear optional id field
- * PARAMETERS
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_clear_optional_ids(U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 optid_record;
- U8 optid_index;
- S16 pError;
- PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
- optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
- ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- memset(&PhbOptIDs[optid_index], 0, sizeof(PHB_OPTIONAL_IDS_STRUCT));
- WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_clear_optional_ids_for_sim
- * DESCRIPTION
- * clear optional id field
- * PARAMETERS
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- #if defined(__MMI_PHB_CALLERGROUP_IN_SIM__) /* Associate caller group in SIM card entry */
- void mmi_phb_clear_optional_ids_for_sim(U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 optid_record;
- U8 optid_index;
- S16 pError;
- PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- optid_record = (store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
- optid_index = store_index - (optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
- ReadRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- /* Clear Picture ID and Ring Tone ID for SIM because SIM does not have these fields. */
- PhbOptIDs[optid_index].pictureTagID = 0;
- PhbOptIDs[optid_index].ringToneID = 0;
- WriteRecord(NVRAM_EF_PHB_IDS_LID, optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- }
- #endif /* defined(__MMI_PHB_CALLERGROUP_IN_SIM__) */
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_copy_optional_ids
- * DESCRIPTION
- * copy optional id field and caller picture
- * PARAMETERS
- * dst_store_index [IN]
- * src_store_index [IN]
- * RETURNS
- *
- *****************************************************************************/
- BOOL mmi_phb_copy_optional_ids(U16 dst_store_index, U16 src_store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 src_optid_record, dst_optid_record;
- U8 optid_index;
- S16 pError;
- PHB_OPTIONAL_IDS_STRUCT PhbOptIDs[OPTIONAL_IDS_RECORD_TOTAL];
- PHB_OPTIONAL_IDS_STRUCT tempIDs;
- BOOL copy_image = TRUE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* Read Source ID first */
- src_optid_record = (src_store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
- optid_index = src_store_index - (src_optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
- ReadRecord(NVRAM_EF_PHB_IDS_LID, src_optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- /* Copy to temp buffer. */
- memcpy(&tempIDs, &PhbOptIDs[optid_index], sizeof(PHB_OPTIONAL_IDS_STRUCT));
- /* Read Destination ID */
- dst_optid_record = (dst_store_index / OPTIONAL_IDS_RECORD_TOTAL) + 1;
- optid_index = dst_store_index - (dst_optid_record - 1) * OPTIONAL_IDS_RECORD_TOTAL;
- if (dst_optid_record != src_optid_record)
- {
- ReadRecord(NVRAM_EF_PHB_IDS_LID, dst_optid_record, (void*)PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- }
- /* Copy from temp buffer. */
- memcpy(&PhbOptIDs[optid_index], &tempIDs, sizeof(PHB_OPTIONAL_IDS_STRUCT));
- #if defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__)
- if (dst_store_index < MAX_PB_PHONE_ENTRIES && src_store_index < MAX_PB_PHONE_ENTRIES) /* duplicate phone entry*/
- {
- /* Duplicate image in file system. */
- if (PhbOptIDs[optid_index].pictureTagID == 1)
- {
- copy_image = mmi_phb_image_duplicate_by_index((U16) (dst_store_index + 1), (U16) (src_store_index + 1));
- if (!copy_image)
- {
- PhbOptIDs[optid_index].pictureTagID = 0;
- }
- }
- }
- #endif /* defined(__MMI_FILE_MANAGER__) && !defined(__MMI_FILE_MANAGER_HIDE_MENU__) */
- /* Write Back To buffer */
- WriteRecord(NVRAM_EF_PHB_IDS_LID, dst_optid_record, PhbOptIDs, OPTIONAL_IDS_RECORD_SIZE, &pError);
- return copy_image;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_copy_number_without_parentheses
- * DESCRIPTION
- * prepare name and number by user input before send to L4
- * PARAMETERS
- * in_number [IN]
- * out_number [IN/OUT]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_copy_number_without_parentheses(S8 *in_number, S8 *out_number)
- {
- while (!((*in_number == 0) && (*(in_number + 1) == 0)))
- {
- if (*in_number != '(' && *in_number != ')' && *in_number != '-')
- {
- *out_number = *(in_number);
- *(out_number + 1) = *(in_number + 1);
- out_number += 2;
- }
- in_number += 2;
- }
- *out_number = 0;
- *(out_number + 1) = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_set_entry_prepare_name_number
- * DESCRIPTION
- * prepare name and number by user input before send to L4
- * PARAMETERS
- * dst_msg [?]
- * in_name [?]
- * in_num [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_set_entry_prepare_name_number(void *dst_msg, S8 *in_name, S8 *in_num)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- l4c_phb_entry_struct *phb_entry = (l4c_phb_entry_struct*) dst_msg;
- #if defined(__PHB_0x81_SUPPORT__)
- U8 length;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (dst_msg == NULL)
- {
- return;
- }
- if (in_num != NULL)
- {
- S8* valid_num = OslMalloc((MAX_PB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH);
- mmi_phb_copy_number_without_parentheses(in_num, valid_num);
- /* Prepate Number Data */
- if (in_num[0] == '+')
- {
- phb_entry->tel.type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
- phb_entry->tel.length = (U8) pfnUnicodeStrlen(valid_num + ENCODING_LENGTH); /* Exclude "+" */
- UnicodeToAnsii((PS8) phb_entry->tel.number, valid_num + ENCODING_LENGTH);
- }
- else
- {
- phb_entry->tel.type = MMI_CSMCC_DEFAULT_ADDR_TYPE; /* DEFAULT */
- phb_entry->tel.length = (U8) pfnUnicodeStrlen(valid_num);
- UnicodeToAnsii((PS8) phb_entry->tel.number, valid_num);
- }
- OslMfree(valid_num);
- }
- if (in_name != NULL)
- {
- /* Prepare Name Data */
- if (GetUCS2Flag(in_name))
- {
- #if defined(__PHB_0x81_SUPPORT__) /* Support maximum length of 0x81 UCS2 */
- if ((length = mmi_phb_convert_to_0x81((S8*) in_name, TRUE)) > 0)
- {
- phb_entry->alpha_id.name_dcs = 0x09;
- phb_entry->alpha_id.name_length = length;
- memcpy(phb_entry->alpha_id.name, in_name, length);
- memset(phb_entry->alpha_id.name + length, 0x00, 1);
- }
- else
- #endif /* defined(__PHB_0x81_SUPPORT__) */
- {
- phb_entry->alpha_id.name_dcs = MMI_PHB_UCS2;
- phb_entry->alpha_id.name_length = ((U8) pfnUnicodeStrlen(in_name)) * ENCODING_LENGTH;
- InputboxConvertDeviceEncodingToGSM(
- (PU8) in_name,
- phb_entry->alpha_id.name,
- MAX_PS_NAME_LENGTH,
- MMI_PHB_UCS2,
- 0,
- 1);
- }
- }
- else
- {
- phb_entry->alpha_id.name_dcs = MMI_PHB_ASCII;
- phb_entry->alpha_id.name_length = InputboxConvertDeviceEncodingToGSM(
- (PU8) in_name,
- phb_entry->alpha_id.name,
- MAX_PS_NAME_LENGTH,
- MMI_PHB_ASCII,
- 0,
- 1) - 1;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_set_entry_prepare_name_number_by_index
- * DESCRIPTION
- * prepare name and number by store index before send to L4
- * PARAMETERS
- * dst_msg [?]
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_set_entry_prepare_name_number_by_index(void *dst_msg, U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- l4c_phb_entry_struct *phb_entry = (l4c_phb_entry_struct*) dst_msg;
- #if defined(__PHB_0x81_SUPPORT__)
- U8 length;
- S8 *in_name = OslMalloc((MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH);
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- memcpy(in_name, PhoneBook[store_index].alpha_id.name, (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH);
- #endif /* defined(__PHB_0x81_SUPPORT__) */
- phb_entry->alpha_id.name_length = PhoneBook[store_index].alpha_id.name_length;
- phb_entry->alpha_id.name_dcs = PhoneBook[store_index].alpha_id.name_dcs;
- #if defined(__PHB_0x81_SUPPORT__) /* Support maximum length of 0x81 UCS2 */
- if ((PhoneBook[store_index].alpha_id.name_dcs == MMI_PHB_UCS2)
- && ((length = mmi_phb_convert_to_0x81(in_name, TRUE)) > 0))
- {
- phb_entry->alpha_id.name_dcs = 0x09;
- phb_entry->alpha_id.name_length = length;
- memcpy(phb_entry->alpha_id.name, in_name, length);
- memset(phb_entry->alpha_id.name + length, 0x00, 1);
- }
- else
- #endif /* defined(__PHB_0x81_SUPPORT__) */
- {
- InputboxConvertDeviceEncodingToGSM(
- PhoneBook[store_index].alpha_id.name,
- phb_entry->alpha_id.name,
- MAX_PS_NAME_LENGTH,
- PhoneBook[store_index].alpha_id.name_dcs,
- 0,
- 1);
- }
- phb_entry->tel.type = PhoneBook[store_index].tel.type;
- /* myMsgPtr->list.tel.length = PhoneBook[store_index].tel.length; */
- mmi_phb_convert_to_digit(phb_entry->tel.number, PhoneBook[store_index].tel.number, MAX_PB_NUMBER_LENGTH + 1);
- phb_entry->tel.length = strlen((S8*) phb_entry->tel.number);
- #if defined(__PHB_0x81_SUPPORT__)
- OslMfree(in_name);
- #endif
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_set_entry_rsp_name_number
- * DESCRIPTION
- * set name and number in the set entry response message.
- * PARAMETERS
- * rsp_msg [?]
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_set_entry_rsp_name_number(void *rsp_msg, U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- l4c_phb_entry_struct *localPtr;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- localPtr = (l4c_phb_entry_struct*) rsp_msg;
- PhoneBook[store_index].alpha_id.name_length = localPtr->alpha_id.name_length;
- PhoneBook[store_index].alpha_id.name_dcs = localPtr->alpha_id.name_dcs;
- InputboxConvertGSMToDeviceEncoding(
- localPtr->alpha_id.name,
- PhoneBook[store_index].alpha_id.name,
- localPtr->alpha_id.name_length,
- (MAX_PB_NAME_LENGTH + 1) * ENCODING_LENGTH,
- localPtr->alpha_id.name_dcs,
- 0,
- 1);
- #if defined(__PHB_0x81_SUPPORT__) /* Support maximum length of 0x81 UCS2 */
- if (PhoneBook[store_index].alpha_id.name_dcs == MMI_PHB_UCS2_81 ||
- PhoneBook[store_index].alpha_id.name_dcs == MMI_PHB_UCS2_82)
- {
- PhoneBook[store_index].alpha_id.name_dcs = MMI_PHB_UCS2;
- }
- #endif /* defined(__PHB_0x81_SUPPORT__) */
- PhoneBook[store_index].tel.type = localPtr->tel.type;
- PhoneBook[store_index].tel.length = localPtr->tel.length;
- mmi_phb_convert_to_bcd(PhoneBook[store_index].tel.number, localPtr->tel.number, (MAX_PB_NUMBER_LENGTH + 1) / 2);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_get_store_index_and_increase_counter
- * DESCRIPTION
- * Use storage and record_index to get phonebook store_index(store position in the array)
- * PARAMETERS
- * storage [IN]
- * record_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- U16 mmi_phb_op_get_store_index_and_increase_counter(U8 storage, U16 record_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 store_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (storage == MMI_SIM)
- {
- g_phb_cntx.sim_used++;
- store_index = record_index + MAX_PB_PHONE_ENTRIES - 1; /* Storage Location in array. */
- MMI_ASSERT((g_phb_cntx.sim_used <= g_phb_cntx.sim_total) && (store_index < MAX_PB_ENTRIES));
- }
- else
- {
- g_phb_cntx.phone_used++;
- store_index = record_index - 1; /* Storage Location in array. */
- MMI_ASSERT((g_phb_cntx.phone_used <= g_phb_cntx.phone_total) && (store_index < MAX_PB_PHONE_ENTRIES));
- }
- return store_index;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_clear_lookup_table_by_index
- * DESCRIPTION
- * clear one entry in number lookup table
- * PARAMETERS
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- U16 mmi_phb_op_clear_lookup_table_by_index(U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U16 deletedCnt = 0;
- U16 k;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- for (k = 0; k < g_phb_cntx.lookup_table_count; ++k)
- {
- if (LookUpTable[k].store_index == store_index)
- {
- LookUpTable[k].number = INVALID_NUMBER;
- deletedCnt++;
- }
- }
- return deletedCnt;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_increase_lookup_table
- * DESCRIPTION
- * add one entry into lookup table
- * PARAMETERS
- * store_index [IN]
- * number [?]
- * fax [?]
- * home [?]
- * office [?]
- * RETURNS
- * void
- *****************************************************************************/
- U8 mmi_phb_op_increase_lookup_table(U16 store_index, S8 *number, S8 *fax, S8 *home, S8 *office)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U32 temp;
- U8 flag = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (number != NULL)
- {
- temp = mmi_phb_util_convert_number_to_int((U8*) number);
- if (temp < INVALID_NUMBER && g_phb_cntx.lookup_table_count < MAX_LOOKUP_TABLE_COUNT)
- {
- flag = 1;
- LookUpTable[g_phb_cntx.lookup_table_count].store_index = store_index;
- LookUpTable[g_phb_cntx.lookup_table_count++].number = temp;
- }
- }
- if (fax != NULL)
- {
- temp = mmi_phb_util_convert_number_to_int((U8*) fax);
- if (temp < INVALID_NUMBER && g_phb_cntx.lookup_table_count < MAX_LOOKUP_TABLE_COUNT)
- {
- flag = 1;
- LookUpTable[g_phb_cntx.lookup_table_count].store_index = store_index;
- LookUpTable[g_phb_cntx.lookup_table_count++].number = temp;
- }
- }
- if (home != NULL)
- {
- temp = mmi_phb_util_convert_number_to_int((U8*) home);
- if (temp < INVALID_NUMBER && g_phb_cntx.lookup_table_count < MAX_LOOKUP_TABLE_COUNT)
- {
- flag = 1;
- LookUpTable[g_phb_cntx.lookup_table_count].store_index = store_index;
- LookUpTable[g_phb_cntx.lookup_table_count++].number = temp;
- }
- }
- if (office != NULL)
- {
- temp = mmi_phb_util_convert_number_to_int((U8*) office);
- if (temp < INVALID_NUMBER && g_phb_cntx.lookup_table_count < MAX_LOOKUP_TABLE_COUNT)
- {
- flag = 1;
- LookUpTable[g_phb_cntx.lookup_table_count].store_index = store_index;
- LookUpTable[g_phb_cntx.lookup_table_count++].number = temp;
- }
- }
- return flag;
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_update_field_flag
- * DESCRIPTION
- * update fileter flag of each entry.
- * PARAMETERS
- * store_index [IN]
- * number [?]
- * home [?]
- * office [?]
- * fax [?]
- * email [?]
- * is_new [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_update_field_flag(
- U16 store_index,
- S8 *number,
- S8 *home,
- S8 *office,
- S8 *fax,
- S8 *email,
- BOOL is_new)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* New record, clear first. */
- if (is_new)
- {
- PhoneBook[store_index].field = 0;
- }
- if (number != NULL)
- {
- if (strlen(number))
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_NUMBER;
- }
- else if (!is_new) /* Clear flag when the field is empty and the record is not a new record */
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_NUMBER;
- }
- }
- #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
- if (home != NULL)
- {
- if (strlen(home) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_HOME;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_HOME;
- }
- }
- if (office != NULL)
- {
- if (strlen(office) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_OFFICE;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_OFFICE;
- }
- }
- if (fax != NULL)
- {
- if (strlen(fax) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_FAX;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_FAX;
- }
- }
- if (email != NULL)
- {
- if (strlen(email) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_EMAIL;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_EMAIL;
- }
- }
- #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- }
- #ifdef __MMI_PHB_USIM_FIELD__
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_copy_all_to_usim_one_after_one_rsp
- * DESCRIPTION
- * copy all one entry set response.
- * PARAMETERS
- * info [?]
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_phb_op_copy_all_to_usim_one_after_one_rsp(void *info)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MSG_PHB_SET_USIM_ENRTY_RSP_STRUCT *localPtr;
- U8 copy_from, copy_to = 0;
- U16 store_index;
- U32 temp;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_op_copy_all_to_usim_one_after_one_rsp.>n",
- __FILE__, __LINE__));
- localPtr = (MSG_PHB_SET_USIM_ENRTY_RSP_STRUCT*) info;
- if (localPtr->result.flag == 0 /* OK */ )
- {
- g_phb_cntx.sim_used++;
- store_index = localPtr->list.record_index + MAX_PB_PHONE_ENTRIES - 1; /* Storage Location in array. */
- copy_to = MMI_SIM;
- copy_from = MMI_NVRAM;
- /* Populate Number Field */
- temp = mmi_phb_util_convert_number_to_int(localPtr->list.tel.number);
- if (temp < INVALID_NUMBER)
- {
- LookUpTable[g_phb_cntx.lookup_table_count].store_index = store_index;
- LookUpTable[g_phb_cntx.lookup_table_count++].number = temp;
- }
- /* Add result to Phonebook Storage */
- mmi_phb_op_set_entry_rsp_name_number(&localPtr->list, store_index);
- /* Update field flag */
- mmi_phb_op_set_entry_usim_fields(&PhoneBookOptionalFields, store_index);
- mmi_phb_op_update_usim_field_flag(
- store_index,
- (S8*) localPtr->list.tel.number,
- (S8*) PhoneBookOptionalFields.homeNumber,
- (S8*) PhoneBookOptionalFields.officeNumber,
- (S8*) PhoneBookOptionalFields.faxNumber,
- (S8*) PhoneBookOptionalFields.emailAddress,
- TRUE);
- mmi_phb_op_increase_lookup_table(
- store_index,
- NULL,
- (S8*) PhoneBookOptionalFields.faxNumber,
- (S8*) PhoneBookOptionalFields.homeNumber,
- (S8*) PhoneBookOptionalFields.officeNumber);
- #if defined(__MMI_PHB_PINYIN_SORT__) /* Make Pinyin cache for later sorting. */
- mmi_phb_util_make_pinyin_cache(store_index);
- #endif
- /* Append new entry in the end of sorted list. Sorting when copy all done. */
- g_phb_name_index[PhoneBookEntryCount] = store_index;
- PhoneBookEntryCount++;
- g_phb_mass_op_count++;
- /* Insert email to email mapping table, not like name field, it should sort here. */
- #if defined(__MMI_PHB_EMAIL_SORT__)
- if (g_phb_email_sorted == 1)
- {
- mmi_phb_sort_email_insert_index(store_index);
- }
- #endif /* defined(__MMI_PHB_EMAIL_SORT__) */
- if (g_phb_mass_op_abort)
- {
- g_phb_mass_op_success = FALSE;
- mmi_phb_op_copy_all_done();
- }
- else
- {
- if ((copy_to == MMI_SIM && g_phb_mass_op_count < g_phb_cntx.phone_used))
- {
- ++g_phb_mass_op_index;
- mmi_phb_op_copy_all_to_usim_one_after_one_req();
- }
- else
- {
- mmi_phb_op_copy_all_done();
- }
- }
- }
- else
- {
- g_phb_mass_op_success = FALSE;
- copy_from = MMI_NVRAM;
- /* Not copy fail due to capacity full. */
- if ((localPtr->result.cause != MMI_PHB_CAUSE_CAPACITY_EXCEEDED) &&
- ((copy_from == MMI_NVRAM && g_phb_mass_op_count < g_phb_cntx.phone_used)))
- {
- g_phb_mass_op_index++;
- mmi_phb_op_copy_all_to_usim_one_after_one_req();
- }
- else
- {
- mmi_phb_op_copy_all_done();
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_copy_all_to_usim_one_after_one_req
- * DESCRIPTION
- * Copy all one entry after one.
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_phb_op_copy_all_to_usim_one_after_one_req(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MSG_PHB_SET_USIM_ENRTY_REQ_STRUCT *myMsgPtr;
- MYQUEUE Message;
- U16 store_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G4_PHB, "File: [%s] Line: [%d] <<mmi_phb_op_copy_all_to_usim_one_after_one_req.>n",
- __FILE__, __LINE__));
- while ((g_phb_name_index[g_phb_mass_op_index] >= MAX_PB_PHONE_ENTRIES) && (g_phb_mass_op_index < PhoneBookEntryCount)) /* Not in NVRAM */
- {
- g_phb_mass_op_index++;
- }
- if (g_phb_mass_op_index >= PhoneBookEntryCount)
- {
- mmi_phb_op_copy_all_done();
- return;
- }
- store_index = g_phb_name_index[g_phb_mass_op_index];
- #if defined(__MMI_PHB_PINYIN_SORT__) /* Make Pinyin cache for later sorting. */
- mmi_phb_util_make_pinyin_cache(store_index);
- #endif
- myMsgPtr = (MSG_PHB_SET_USIM_ENRTY_REQ_STRUCT*) OslConstructDataPtr(sizeof(MSG_PHB_SET_USIM_ENRTY_REQ_STRUCT));
- myMsgPtr->type = MMI_PHB_PHONEBOOK;
- myMsgPtr->no_data = 1;
- myMsgPtr->list.index = 0xFFFF;
- myMsgPtr->list.record_index = 0xFFFF;
- myMsgPtr->list.storage = MMI_SIM;
- myMsgPtr->anra.record_index = 0xFFFF;
- myMsgPtr->anrb.record_index = 0xFFFF;
- myMsgPtr->anrc.record_index = 0xFFFF;
- myMsgPtr->email.adn_record_index = 0xFFFF;
- mmi_phb_op_set_entry_prepare_name_number_by_index(&myMsgPtr->list, store_index);
- mmi_phb_op_set_entry_prepare_usim_data_by_index(store_index);
- mmi_phb_op_set_entry_prepare_usim_data(
- myMsgPtr,
- pbNickName,
- pbHomeNumber,
- pbOfficeNumber,
- pbFaxNumber,
- pbEmailAddress);
- myMsgPtr->group_type = 0;
- // TODO: hidden info
- //myMsgPtr->hidden_info = ;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- Message.oslMsgId = PRT_PHB_WRITE_USIM_REQ;
- Message.oslDataPtr = (oslParaType*) myMsgPtr;
- Message.oslPeerBuffPtr = NULL;
- SetProtocolEventHandler(mmi_phb_op_copy_all_to_usim_one_after_one_rsp, PRT_PHB_WRITE_USIM_RSP);
- OslMsgSendExtQueue(&Message);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_set_entry_usim_fields
- * DESCRIPTION
- * set name and number in the set entry response message.
- * PARAMETERS
- * field_msg [?]
- * store_index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_set_entry_usim_fields(void *field_msg, U16 store_index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- PHB_OPTIONAL_FIELDS_STRUCT *localPtr = (PHB_OPTIONAL_FIELDS_STRUCT*) field_msg;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ASSERT(store_index >= MAX_PB_PHONE_ENTRIES);
- store_index -= MAX_PB_PHONE_ENTRIES;
- if (localPtr->homeNumber[0] == '+')
- {
- phb_anr[store_index][0].type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
- phb_anr[store_index][0].length =
- mmi_phb_convert_to_bcd(phb_anr[store_index][0].number, localPtr->homeNumber + 1, (MAX_PB_NUMBER_LENGTH + 1) / 2);
- }
- else
- {
- phb_anr[store_index][0].type = MMI_CSMCC_DEFAULT_ADDR_TYPE; /* DEFAULT */
- phb_anr[store_index][0].length =
- mmi_phb_convert_to_bcd(phb_anr[store_index][0].number, localPtr->homeNumber, (MAX_PB_NUMBER_LENGTH + 1) / 2);
- }
- if (localPtr->officeNumber[0] == '+')
- {
- phb_anr[store_index][1].type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
- phb_anr[store_index][1].length =
- mmi_phb_convert_to_bcd(phb_anr[store_index][1].number, localPtr->officeNumber + 1, (MAX_PB_NUMBER_LENGTH + 1) / 2);
- }
- else
- {
- phb_anr[store_index][1].type = MMI_CSMCC_DEFAULT_ADDR_TYPE; /* DEFAULT */
- phb_anr[store_index][1].length =
- mmi_phb_convert_to_bcd(phb_anr[store_index][1].number, localPtr->officeNumber, (MAX_PB_NUMBER_LENGTH + 1) / 2);
- }
- if (localPtr->faxNumber[0] == '+')
- {
- phb_anr[store_index][2].type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
- phb_anr[store_index][2].length =
- mmi_phb_convert_to_bcd(phb_anr[store_index][2].number, localPtr->faxNumber + 1, (MAX_PB_NUMBER_LENGTH + 1) / 2);
- }
- else
- {
- phb_anr[store_index][2].type = MMI_CSMCC_DEFAULT_ADDR_TYPE; /* DEFAULT */
- phb_anr[store_index][2].length =
- mmi_phb_convert_to_bcd(phb_anr[store_index][2].number, localPtr->faxNumber, (MAX_PB_NUMBER_LENGTH + 1) / 2);
- }
- UnicodeToAnsii((S8*) phb_email[store_index].email_address, (S8*) pbEmailAddress);
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_update_usim_field_flag
- * DESCRIPTION
- * update fileter flag of each entry.
- * PARAMETERS
- * store_index [IN]
- * number [?]
- * anra [?]
- * anrb [?]
- * anrc [?]
- * email [?]
- * is_new [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_update_usim_field_flag(
- U16 store_index,
- S8 *number,
- S8 *anra,
- S8 *anrb,
- S8 *anrc,
- S8 *email,
- BOOL is_new)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* New record, clear first. */
- if (is_new)
- {
- PhoneBook[store_index].field = 0;
- }
- if (number != NULL)
- {
- if (strlen(number))
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_NUMBER;
- }
- else if (!is_new) /* Clear flag when the field is empty and the record is not a new record */
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_NUMBER;
- }
- }
- if (anra != NULL)
- {
- if (strlen(anra) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_ANRA;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_ANRA;
- }
- }
- if (anrb != NULL)
- {
- if (strlen(anrb) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_ANRB;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_ANRB;
- }
- }
- if (anrc != NULL)
- {
- if (strlen(anrc) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_ANRC;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_ANRC;
- }
- }
- if (email != NULL)
- {
- if (strlen(email) > 0)
- {
- PhoneBook[store_index].field |= MMI_PHB_ENTRY_FIELD_EMAIL;
- }
- else if (!is_new)
- {
- PhoneBook[store_index].field &= ~MMI_PHB_ENTRY_FIELD_EMAIL;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_set_entry_prepare_usim_data_by_index
- * DESCRIPTION
- *
- * PARAMETERS
- * index [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_set_entry_prepare_usim_data_by_index(U16 index)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* memset(pbNumber, 0, ENCODING_LENGTH); */
- memset(pbHomeNumber, 0, ENCODING_LENGTH);
- memset(pbEmailAddress, 0, ENCODING_LENGTH);
- memset(pbOfficeNumber, 0, ENCODING_LENGTH);
- memset(pbFaxNumber, 0, ENCODING_LENGTH);
- memset(pbEmailAddress, 0, ENCODING_LENGTH);
- /* mmi_phb_convert_get_ucs2_number((S8*)pbNumber, index); */
- if (index < MAX_PB_PHONE_ENTRIES) /* from nvram */
- {
- #if !defined(__MMI_PHB_NO_OPTIONAL_FIELD__)
- S16 pError;
- ReadRecord(
- NVRAM_EF_PHB_FIELDS_LID,
- (U16) (index + 1),
- (void*)&PhoneBookOptionalFields,
- OPTIONAL_FIELDS_RECORD_SIZE,
- &pError);
- AnsiiToUnicodeString(pbHomeNumber, (PS8) PhoneBookOptionalFields.homeNumber);
- AnsiiToUnicodeString(pbEmailAddress, (PS8) PhoneBookOptionalFields.emailAddress);
- AnsiiToUnicodeString(pbOfficeNumber, (PS8) PhoneBookOptionalFields.officeNumber);
- AnsiiToUnicodeString(pbFaxNumber, (PS8) PhoneBookOptionalFields.faxNumber);
- #endif /* !defined(__MMI_PHB_NO_OPTIONAL_FIELD__) */
- }
- else
- {
- mmi_phb_convert_get_ucs2_anr((S8*) pbHomeNumber, (S8*) pbOfficeNumber, (S8*) pbFaxNumber, index);
- if (index >= MAX_PB_PHONE_ENTRIES)
- {
- AnsiiToUnicodeString((S8*) pbEmailAddress, (S8*) phb_email[index - MAX_PB_PHONE_ENTRIES].email_address);
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_set_entry_prepare_usim_data
- * DESCRIPTION
- * prepare usim fields (except name and number) by user input before send to L4
- * PARAMETERS
- * dst_msg [?]
- * in_name [?]
- * in_num [?]
- * in_numb [?]
- * in_numc [?]
- * in_email [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_set_entry_prepare_usim_data(
- void *dst_msg,
- S8 *in_name,
- S8 *in_num,
- S8 *in_numb,
- S8 *in_numc,
- S8 *in_email)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MSG_PHB_SET_USIM_ENRTY_REQ_STRUCT *myMsgPtr;
- #if defined(__PHB_0x81_SUPPORT__)
- U8 length;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- myMsgPtr = (MSG_PHB_SET_USIM_ENRTY_REQ_STRUCT*) dst_msg;
- if (dst_msg == NULL)
- {
- return;
- }
- if (in_name != NULL)
- {
- /* Prepare Second Name Data */
- if (GetUCS2Flag(in_name))
- {
- #if defined(__PHB_0x81_SUPPORT__) /* Support maximum length of 0x81 UCS2 */
- if ((length = mmi_phb_convert_to_0x81((S8*) in_name, TRUE)) > 0)
- {
- myMsgPtr->sne.name_dcs = 0x09;
- myMsgPtr->sne.name_length = length;
- memcpy(myMsgPtr->sne.name, in_name, length);
- memset(myMsgPtr->sne.name + length, 0x00, 1);
- }
- else
- #endif /* defined(__PHB_0x81_SUPPORT__) */
- {
- myMsgPtr->sne.name_dcs = MMI_PHB_UCS2;
- myMsgPtr->sne.name_length = ((U8) pfnUnicodeStrlen(in_name)) * ENCODING_LENGTH;
- InputboxConvertDeviceEncodingToGSM(
- (PU8) in_name,
- myMsgPtr->sne.name,
- MAX_PS_NAME_LENGTH,
- MMI_PHB_UCS2,
- 0,
- 1);
- }
- }
- else
- {
- myMsgPtr->sne.name_dcs = MMI_PHB_ASCII;
- myMsgPtr->sne.name_length = InputboxConvertDeviceEncodingToGSM(
- (PU8) in_name,
- myMsgPtr->sne.name,
- MAX_PS_NAME_LENGTH,
- MMI_PHB_ASCII,
- 0,
- 1) - 1;
- }
- }
- if (in_num != NULL)
- {
- /* Prepare Addtional Number A Data */
- if (in_num[0] == '+')
- {
- myMsgPtr->anra.tel_number.type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
- myMsgPtr->anra.tel_number.length = (U8) pfnUnicodeStrlen(in_num + ENCODING_LENGTH); /* Exclude "+" */
- UnicodeToAnsii((PS8) myMsgPtr->anra.tel_number.number, in_num + ENCODING_LENGTH);
- }
- else
- {
- myMsgPtr->anra.tel_number.type = MMI_CSMCC_DEFAULT_ADDR_TYPE; /* DEFAULT */
- myMsgPtr->anra.tel_number.length = (U8) pfnUnicodeStrlen(in_num);
- UnicodeToAnsii((PS8) myMsgPtr->anra.tel_number.number, in_num);
- }
- }
- if (in_numb != NULL)
- {
- /* Prepare Addtional Number B Data */
- if (in_num[0] == '+')
- {
- myMsgPtr->anrb.tel_number.type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
- myMsgPtr->anrb.tel_number.length = (U8) pfnUnicodeStrlen(in_numb + ENCODING_LENGTH); /* Exclude "+" */
- UnicodeToAnsii((PS8) myMsgPtr->anrb.tel_number.number, in_numb + ENCODING_LENGTH);
- }
- else
- {
- myMsgPtr->anrb.tel_number.type = MMI_CSMCC_DEFAULT_ADDR_TYPE; /* DEFAULT */
- myMsgPtr->anrb.tel_number.length = (U8) pfnUnicodeStrlen(in_numb);
- UnicodeToAnsii((PS8) myMsgPtr->anrb.tel_number.number, in_numb);
- }
- }
- if (in_numc != NULL)
- {
- /* Prepare Addtional Number C Data */
- if (in_num[0] == '+')
- {
- myMsgPtr->anrc.tel_number.type = MMI_CSMCC_INTERNATIONAL_ADDR; /* INTERNATIONAL */
- myMsgPtr->anrc.tel_number.length = (U8) pfnUnicodeStrlen(in_numc + ENCODING_LENGTH); /* Exclude "+" */
- UnicodeToAnsii((PS8) myMsgPtr->anrc.tel_number.number, in_numc + ENCODING_LENGTH);
- }
- else
- {
- myMsgPtr->anrc.tel_number.type = MMI_CSMCC_DEFAULT_ADDR_TYPE; /* DEFAULT */
- myMsgPtr->anrc.tel_number.length = (U8) pfnUnicodeStrlen(in_numc);
- UnicodeToAnsii((PS8) myMsgPtr->anrc.tel_number.number, in_numc);
- }
- }
- if (in_email != NULL)
- {
- /* Prepare email Data */
- myMsgPtr->email.email_length = InputboxConvertDeviceEncodingToGSM(
- (PU8) in_email,
- myMsgPtr->email.email_address,
- MAX_PB_EMAIL_LENGTH + 1,
- MMI_PHB_ASCII,
- 0,
- 1) - 1;
- myMsgPtr->email.adn_record_index = myMsgPtr->list.record_index;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_phb_op_set_option_data_by_usim_index
- * DESCRIPTION
- *
- * PARAMETERS
- * index [IN]
- * opt_fields [?]
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_phb_op_set_option_data_by_usim_index(U16 index, PHB_OPTIONAL_FIELDS_STRUCT *opt_fields)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (index >= MAX_PB_PHONE_ENTRIES)
- {
- mmi_phb_convert_get_ansii_anr(
- (S8*) opt_fields->homeNumber,
- (S8*) opt_fields->officeNumber,
- (S8*) opt_fields->faxNumber,
- index);
- memcpy(opt_fields->emailAddress, phb_email[index - MAX_PB_PHONE_ENTRIES].email_address, MAX_PB_EMAIL_LENGTH);
- }
- }
- #endif /* __MMI_PHB_USIM_FIELD__ */
- #endif /* _PHONEBOOKOPERATEMASS_C */