return region_order;
}
-int msg_ui_composer_body_entry_char_count(void *data, const unsigned char *body_ucs2_text, int ucs2_len, int *char_count)
+int msg_ui_composer_body_entry_char_count(void *data, const char *text, int *char_count, int *page_size)
{
D_ENTER;
+ D_MSG_RETVM_IF(data == NULL, -1, "param is NULL");
+ D_MSG_RETVM_IF(text == NULL, -1, "param is NULL");
+ D_MSG_RETVM_IF(char_count == NULL, -1, "param is NULL");
+ D_MSG_RETVM_IF(page_size == NULL, -1, "param is NULL");
+
+ MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
+ unsigned int text_size = 0;
+ unsigned int segment_size = 0;
+ int encoded_mode = 0;
+ int ret = MSG_SUCCESS;
+ COMPOSER_CHAR_ENCODE_E encode = COMPOSER_CHAR_ENCODE_MAX;
+
+ ret = msg_util_calculate_text_length(text, cd->encode_mode, &text_size, &segment_size, (msg_encode_type_t *)&encoded_mode);
+ D_MSG("encode_mode = %d, text_size = %d, segment_size = %d encoded_mode = %d", cd->encode_mode, text_size, segment_size, encoded_mode);
+
+ if (ret != MSG_SUCCESS) {
+ D_EMSG("msg_calculate_text_length is failed ret = %d", ret);
+ } else {
+ switch (cd->encode_mode) {
+ case MSG_ENCODE_GSM7BIT:
+ *char_count = (int)text_size;
+ *page_size = (int)segment_size;
- if (!data || !body_ucs2_text) {
- MSG_UI_DEBUG(MSG_UI_LEVEL_ASSERT, "[ASSERT] parameter is NULL POINTER !!!!");
- return -1;
- }
-
- int src_len = ucs2_len;
- int count = 0;
- int dst_char_encode = COMPOSER_CHAR_ENCODE_MAX;
- int i = 0;
-
- unsigned char upperByte, lowerByte;
- unsigned short eachChar;
-
- for(i=0; i<src_len; i++) {
-
- bool is_def_table = false;
- bool is_ext_table = false;
-
- upperByte = body_ucs2_text[i++];
- lowerByte = body_ucs2_text[i];
+ if (encoded_mode == MSG_ENCODE_GSM7BIT_ABNORMAL)
+ encode = COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL;
+ else
+ encode = COMPOSER_CHAR_ENCODE_GSM7;
- eachChar = (upperByte << 8) & 0xFF00;
- eachChar = eachChar | lowerByte;
+ break;
- /* in the UTF8, "Enter (Line Feed)" expressed as a "PS"
- but in the UNICODE_GSM7 pair table, "Enter" expressed as a "LF (0x0a)"
- so we need to change PS (0x2029_UNICODE) to LF (0x000A_GSM7)
- */
- if (eachChar == 0x2029) {/*PS*/
- eachChar = 0x000A; /* change LF*/
- }
+ case MSG_ENCODE_UCS2:
+ *char_count = (int)text_size;
+ *page_size = (int)segment_size;
+ encode = COMPOSER_CHAR_ENCODE_UNICODE;
- int j=0;
+ break;
- /* found char on default table*/
- for(j=0; j<(sizeof(g_GSM7BitToUCS2)/sizeof(short)); j++) {
- if (eachChar == g_GSM7BitToUCS2[j]) {
- count++;
- is_def_table = true;
- break;
- }
- }
+ case MSG_ENCODE_AUTO:
+ *char_count = (int)text_size;
+ *page_size = (int)segment_size;
- /* found char on default ext table*/
- if (is_def_table == false) {
- for(j=0; j<(sizeof(g_GSM7BitExtToUCS2)/sizeof(short)); j++) {
- if (eachChar == g_GSM7BitExtToUCS2[j] && eachChar != 0x0020) {
- count += 2;
- is_ext_table = true;
- break;
- }
- }
- }
+ if (encoded_mode == MSG_ENCODE_GSM7BIT)
+ encode = COMPOSER_CHAR_ENCODE_GSM7;
+ else
+ encode = COMPOSER_CHAR_ENCODE_UNICODE;
- if (is_def_table || is_ext_table) {
- dst_char_encode = COMPOSER_CHAR_ENCODE_GSM7;
- continue;
- } else {
- dst_char_encode = COMPOSER_CHAR_ENCODE_UNICODE;
break;
+
+ default:
+ D_EMSG("unsupported encode mode %d", cd->encode_mode);
}
- }
- if (dst_char_encode == COMPOSER_CHAR_ENCODE_GSM7 || dst_char_encode == COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL) {
- MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] dst_char_encode is COMPOSER_CHAR_ENCODE_GSM7");
- // gsm7 char set
- *char_count = count;
- } else {
- // unicode char set
- MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "[DEBUG] dst_char_encode = COMPOSER_CHAR_ENCODE_UNICODE");
- *char_count = ucs2_len / 2;
}
-
D_LEAVE;
- return dst_char_encode;
+ return encode;
}
void msg_ui_composer_body_info_area_update(MSG_COMPOSER_VIEW_DATA_S *cd)
int char_encode = page_data->text_info.encode;
int char_count = page_data->text_info.char_count;
+ int page_size = page_data->text_info.page_size;
int cms_page = 0;
int cms_max_count = 0;
int max_count = 0;
return;
}
- if (char_encode == COMPOSER_CHAR_ENCODE_UNICODE) {
- if (char_count > COMPOSER_SMS_UNICODE_MAX_LEN) {
- cms_page = char_count / COMPOSER_CMS_UNICODE_MAX_LEN;
+ if (char_encode == COMPOSER_CHAR_ENCODE_UNICODE ||
+ char_encode == COMPOSER_CHAR_ENCODE_GSM7 ||
+ char_encode == COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL) {
+ if (char_count > page_size) {
+ cms_page = char_count / page_size;
- if (!(char_count % COMPOSER_CMS_UNICODE_MAX_LEN))
+ if (!(char_count % page_size))
--cms_page;
if ((cms_page+1) >= cd->cms_max_page)
- max_count = COMPOSER_CMS_UNICODE_MAX_LEN * cd->cms_max_page;
+ max_count = page_size * cd->cms_max_page;
else
- max_count = COMPOSER_CMS_UNICODE_MAX_LEN * (cms_page+1);
+ max_count = page_size * (cms_page+1);
} else {
- max_count = COMPOSER_SMS_UNICODE_MAX_LEN;
+ max_count = page_size;
}
- cms_max_count = COMPOSER_CMS_UNICODE_MAX_LEN * cd->cms_max_page;
- } else if (char_encode == COMPOSER_CHAR_ENCODE_GSM7 || char_encode == COMPOSER_CHAR_ENCODE_GSM7_ABNORMAL) {
- if (char_count > COMPOSER_SMS_GSM7_MAX_LEN) {
- cms_page = char_count / COMPOSER_CMS_GSM7_MAX_LEN;
-
- if (!(char_count % COMPOSER_CMS_GSM7_MAX_LEN))
- --cms_page;
-
- if ((cms_page+1) >= cd->cms_max_page)
- max_count = COMPOSER_CMS_GSM7_MAX_LEN * cd->cms_max_page;
- else
- max_count = COMPOSER_CMS_GSM7_MAX_LEN * (cms_page+1);
- } else {
- max_count = COMPOSER_SMS_GSM7_MAX_LEN;
- }
- cms_max_count = COMPOSER_CMS_GSM7_MAX_LEN * cd->cms_max_page;
+ cms_max_count = page_size * cd->cms_max_page;
} else {
D_EMSG("Unknown character encode");
return;
remaining_count = max_count - char_count;
+ if (char_encode == COMPOSER_CHAR_ENCODE_UNICODE)
+ remaining_count /= 2;
+
snprintf(count_str, sizeof(count_str), "%d/%d", remaining_count, cms_page+1);
if (cd->ly_body_h >= COMPOSER_ENOUGH_TEXT_RENDERING_BODY_HEIGHT)