D_LEAVE;
}
+static void __msg_ui_recipient_process_delimiter_char(void *data, char *full_str, char **text, int type)
+{
+ D_ENTER;
+
+ MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
+ D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
+ D_MSG_RETM_IF(full_str == NULL, "param is NULL");
+
+ RECIPIENT_S *rd = cd->recipient;
+ D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
+
+ int full_str_len = strlen(full_str);
+ bool is_required_parsing = false;
+
+ if (full_str_len < 1) {
+ D_EMSG("full_str_len is %d", full_str_len);
+ return;
+ }
+
+ if (type == RECIPIENT_PARSING_TYPE_ENTER_KEY) { /*enter key case*/
+ is_required_parsing = true;
+ } else {
+ /* check last character is either ',' or ';' */
+ if (full_str[full_str_len - 1] == ',' || full_str[full_str_len - 1] == ';') {
+ D_MSG("full_str [%s]", full_str);
+
+ /* remove last ',' or ';' */
+ full_str[full_str_len - 1] = '\0';
+ --full_str_len;
+
+ is_required_parsing = true;
+ }
+ }
+
+ if (is_required_parsing) {
+ /* parse full str with delimeter , ; */
+ gchar **split_str = NULL;
+ split_str = g_strsplit_set(full_str, ",;", -1);
+
+ if (split_str) {
+ int count = g_strv_length(split_str);
+ int i = 0;
+ MSG_BOOL is_added = FALSE;
+ MSG_BOOL is_count_max = FALSE;
+ MSG_BOOL *is_used_list = NULL;
+
+ D_MSG("splitted string count = %d", count);
+
+ is_used_list = (MSG_BOOL *)calloc(count, sizeof(MSG_BOOL));
+
+ if (is_used_list) {
+ for (i = 0; i < count; i++) {
+ D_MSG("%dth string is [%s]", i+1, split_str[i]);
+
+ if (split_str[i] && strlen(split_str[i])) {
+ if (msg_ui_composer_recipient_vaild_check(split_str[i]) == EINA_TRUE) {
+ /*Check recipient count*/
+ int r_count = msg_ui_composer_recipient_count_get(rd);
+ if (r_count >= COMPOSER_RECIPIENT_COUNT_MAX) {
+ D_EMSG("recipient is over max count %d ", COMPOSER_RECIPIENT_COUNT_MAX);
+ is_count_max = TRUE;
+ is_added = TRUE;
+ is_used_list[i] = TRUE;
+ continue;
+ }
+
+ if (msg_ui_composer_recipient_duplicate_check(rd, split_str[i]) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
+ D_EMSG("Input recipient is duplicated");
+ is_added = TRUE;
+ is_used_list[i] = TRUE;
+ continue;
+ }
+
+ if (msg_ui_composer_recipient_append(cd->recipient, split_str[i], 0) == COMPOSER_RETURN_SUCCESS) {
+ is_added = TRUE;
+ is_used_list[i] = TRUE;
+ }
+ }
+ }
+ }
+
+ if (is_count_max)
+ msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
+
+ /* re-assemble string */
+ if (is_added) {
+ char *re_assembled_str = NULL;
+
+ re_assembled_str = (char *)calloc(full_str_len + 1, sizeof(char));
+
+ if (re_assembled_str) {
+ for (i = 0; i < count - 1; i++) {
+ if (split_str[i] && strlen(split_str[i])) {
+ if (!is_used_list[i]) {
+ strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
+ strncat(re_assembled_str, ",", 1);
+ }
+ } else {
+ strncat(re_assembled_str, ",", 1);
+ }
+ }
+ /* append last parsted string */
+ if (split_str[i] && strlen(split_str[i])) {
+ if (!is_used_list[i])
+ strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
+ }
+
+ /* remove ',' ';' of last position */
+ int str_len = strlen(re_assembled_str);
+ if (str_len > 1) {
+ while (re_assembled_str[str_len - 1] == ',' || re_assembled_str[str_len - 1] == ';') {
+ re_assembled_str[str_len - 1] = '\0';
+ --str_len;
+
+ if (str_len == 0)
+ break;
+ }
+ }
+
+ D_MSG("reassembeld str = [%s]", re_assembled_str);
+ /*set re-assembed str to text */
+ Evas_Object *entry = elm_multibuttonentry_entry_get(rd->mbe);
+
+ if (type == RECIPIENT_PARSING_TYPE_DELETE_CHAR ||
+ type == RECIPIENT_PARSING_TYPE_ENTER_KEY) { /* entry_changed_cb | enter key case */
+ elm_entry_entry_set(entry, re_assembled_str);
+ elm_entry_cursor_end_set(entry);
+
+ if (strlen(re_assembled_str)) {
+ rd->is_required_address_popup = true;
+ }
+ } else { /* entry_filter_cb */
+ elm_entry_entry_set(entry, "");
+ free(*text);
+
+ if (strlen(re_assembled_str)) {
+ rd->is_required_address_popup = true;
+ *text = strdup(re_assembled_str);
+ } else {
+ *text = NULL;
+ }
+ }
+
+ free(re_assembled_str);
+ } else {
+ D_EMSG("calloc is failed");
+ }
+ }
+
+ free(is_used_list);
+ } else {
+ D_EMSG("calloc is failed");
+ }
+
+ g_strfreev(split_str);
+ } else {
+ D_EMSG("g_strsplit_set is failed");
+ }
+ }
+}
+
void msg_ui_recipient_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
D_ENTER;
return;
COMPOSER_RECP_ADDR_E addr_type = COMPOSER_RECP_ADDR_NONE;
+
if (recipient_str && strlen(recipient_str)) {
addr_type = msg_ui_composer_recipient_type_get(recipient_str);
- /* remove ',' ';' character of last position, it is used for deleting character case */
int str_len = strlen(recipient_str);
- if (str_len > 1) {
- bool is_removed_delimeter = false;
-
- while (recipient_str[str_len - 1] == ',' || recipient_str[str_len - 1] == ';') {
- D_MSG("remove , or ;");
- recipient_str[str_len - 1] = '\0';
- --str_len;
-
- is_removed_delimeter = true;
- if (str_len == 0)
- break;
- }
-
- if (is_removed_delimeter) {
- char *markup_str = NULL;
- markup_str = elm_entry_utf8_to_markup(recipient_str);
-
- if (markup_str) {
- D_MSG("remove string is set recipient_str = (%s)!!", recipient_str);
- elm_entry_entry_set(obj, markup_str);
- rd->is_required_address_popup = true;
-
- free(markup_str);
- free(recipient_str);
-
- return;
- }
+ if (str_len > 1) {
+ /* remove ',' ';' character of last position, it is used for deleting character case */
+ if (recipient_str[str_len - 1] == ',' || recipient_str[str_len - 1] == ';') {
+ __msg_ui_recipient_process_delimiter_char(cd, recipient_str, NULL, RECIPIENT_PARSING_TYPE_DELETE_CHAR);
+ free(recipient_str);
+ return;
}
}
}
+ D_MSG("changed_str = %s", recipient_str);
+ D_MSG("saved_str = %s", saved_str);
+
msg_ui_composer_recipient_addr_type_set(rd, addr_type);
D_MSG("recipient is invalid recipient addr_type = %d", addr_type);
- D_MSG("saved_str = %s", saved_str);
- D_MSG("recipient_str = %s", recipient_str);
-
if (g_strcmp0(saved_str, recipient_str) == 0) {
D_MSG("It is same string before str(%s), current str(%s)", saved_str, recipient_str);
g_free(recipient_str);
MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
- RECIPIENT_S *rd = cd->recipient;
- D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
-
- char *recipient_str = NULL;
- const char *entry_str = elm_entry_entry_get(obj);
-
- recipient_str = elm_entry_markup_to_utf8(entry_str);
-
- if (recipient_str == NULL) {
- D_EMSG("recipient_str is NULL");
+ char *recipient_str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
+ if (recipient_str == NULL)
return;
- }
- if (msg_ui_composer_recipient_vaild_check(recipient_str) == EINA_TRUE) {
- /*Check recipient count*/
- int r_count = msg_ui_composer_recipient_count_get(rd);
+ __msg_ui_recipient_process_delimiter_char(cd, recipient_str, NULL, RECIPIENT_PARSING_TYPE_ENTER_KEY);
- if (r_count >= COMPOSER_RECIPIENT_COUNT_MAX) {
- D_EMSG("recipient is over max count %d ", COMPOSER_RECIPIENT_COUNT_MAX);
- } else {
- if (msg_ui_composer_recipient_duplicate_check(rd, recipient_str) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
- D_EMSG("Input recipient is duplicated");
- } else {
- if (msg_ui_composer_recipient_append(cd->recipient, recipient_str, 0) != COMPOSER_RETURN_SUCCESS) {
- D_EMSG("recipient append is failed");
- }
- }
- }
+ free(recipient_str);
- msg_ui_composer_body_focus_set(cd, 0);
- }
+ msg_ui_composer_body_focus_set(cd, 0);
- free(recipient_str);
D_LEAVE;
}
const char *pre_str = NULL;
char *utf8_text = NULL;
gchar *full_str = NULL;
- gchar **split_str = NULL;
utf8_text = elm_entry_markup_to_utf8(*text);
if (utf8_text) {
full_str = g_strdup(utf8_text);
if (full_str) {
- int full_str_len = strlen(full_str);
-
- if (full_str_len < 1) {
- D_EMSG("full_str_len is %d", full_str_len);
- free(utf8_text);
- g_free(full_str);
- return;
- }
-
- /* check last character is either ',' or ';' */
- if (full_str[full_str_len - 1] == ',' || full_str[full_str_len - 1] == ';') {
- D_MSG("pre text [%s]", pre_str);
- D_MSG("new text [%s]", *text);
- D_MSG("full_str [%s]", full_str);
-
- /* remove last ',' or ';' */
- full_str[full_str_len - 1] = '\0';
- --full_str_len;
-
- /* parse full str with delimeter , ; */
- split_str = g_strsplit_set(full_str, ",;", -1);
-
- if (split_str) {
- int count = g_strv_length(split_str);
- int i = 0;
- MSG_BOOL is_added = FALSE;
- MSG_BOOL is_count_max = FALSE;
- MSG_BOOL *is_used_list = NULL;
-
- D_MSG("splitted string count = %d", count);
-
- is_used_list = (MSG_BOOL *)calloc(count, sizeof(MSG_BOOL));
-
- if (is_used_list) {
- for (i = 0; i < count; i++) {
- D_MSG("%dth string is [%s]", i, split_str[i]);
-
- if (split_str[i] && strlen(split_str[i])) {
- if (msg_ui_composer_recipient_vaild_check(split_str[i]) == EINA_TRUE) {
- /*Check recipient count*/
- int r_count = msg_ui_composer_recipient_count_get(rd);
- if (r_count >= COMPOSER_RECIPIENT_COUNT_MAX) {
- D_EMSG("recipient is over max count %d ", COMPOSER_RECIPIENT_COUNT_MAX);
- is_count_max = TRUE;
- is_added = TRUE;
- is_used_list[i] = TRUE;
- continue;
- }
-
- if (msg_ui_composer_recipient_duplicate_check(rd, split_str[i]) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
- D_EMSG("Input recipient is duplicated");
- is_added = TRUE;
- is_used_list[i] = TRUE;
- continue;
- }
-
- if (msg_ui_composer_recipient_append(cd->recipient, split_str[i], 0) == COMPOSER_RETURN_SUCCESS) {
- is_added = TRUE;
- is_used_list[i] = TRUE;
- }
- }
- }
- }
-
- if (is_count_max)
- msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
-
- /* re-assemble string */
- if (is_added) {
- char *re_assembled_str = NULL;
-
- re_assembled_str = (char *)calloc(full_str_len + 1, sizeof(char));
-
- if (re_assembled_str) {
- for (i = 0; i < count - 1; i++) {
- if (split_str[i] && strlen(split_str[i])) {
- if (!is_used_list[i]) {
- strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
- strncat(re_assembled_str, ",", 1);
- }
- } else {
- strncat(re_assembled_str, ",", 1);
- }
- }
- /* append last parsted string */
- if (split_str[i] && strlen(split_str[i])) {
- if (!is_used_list[i])
- strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
- }
-
- /* remove ',' ';' of last position */
- int str_len = strlen(re_assembled_str);
- if (str_len > 1) {
- while (re_assembled_str[str_len - 1] == ',' || re_assembled_str[str_len - 1] == ';') {
- re_assembled_str[str_len - 1] = '\0';
- --str_len;
-
- if (str_len == 0)
- break;
- }
- }
-
- D_MSG("reassembeld str = [%s]", re_assembled_str);
- /*set re-assembed str to text */
- Evas_Object *entry = elm_multibuttonentry_entry_get(rd->mbe);
- elm_entry_entry_set(entry, "");
-
- free(*text);
-
- if (strlen(re_assembled_str)) {
- rd->is_required_address_popup = true;
- *text = strdup(re_assembled_str);
- } else {
- *text = NULL;
- }
-
- free(re_assembled_str);
- } else {
- D_EMSG("calloc is failed");
- }
- }
-
- free(is_used_list);
- } else {
- D_EMSG("calloc is failed");
- }
-
- g_strfreev(split_str);
- } else {
- D_EMSG("g_strsplit_set is failed");
- }
- }
-
+ __msg_ui_recipient_process_delimiter_char(data, full_str, text, RECIPIENT_PARSING_TYPE_ADD_CHAR);
g_free(full_str);
-
} else {
D_EMSG("full_str is NULL");
}
free(utf8_text);
}
+
D_LEAVE;
}