2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "msg-ui-composer-common.h"
19 #include "msg-ui-composer-util.h"
20 #include "msg-ui-composer-popup.h"
21 #include "msg-ui-composer-external.h"
22 #include "msg-ui-composer-predictsearch.h"
23 #include "msg-ui-composer-recipient.h"
24 #include "msg-ui-composer-recipient-callback.h"
25 #include "msg-ui-composer-attachment.h"
26 #include "msg-ui-composer-body.h"
27 #include "msg-ui-composer-main.h" /*for page duration, it should be removed if more option concept is changed*/
29 /*==================================================================================================
30 * FUNCTION IMPLEMENTATIONS
31 *==================================================================================================*/
32 /*change number popup cb*/
33 void msg_ui_recipient_change_number_popup_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
36 MSG_COMPOSER_VIEW_DATA_S *cd = data;
37 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
39 RECIPIENT_S *rd = cd->recipient;
40 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
42 MSGC_EVAS_OBJECT_DEL(rd->popup_change_number);
46 void msg_ui_recipient_change_number_popup_list_clicked_cb(void *data, Evas_Object *obj, void *event_info)
49 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
50 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
52 RECIPIENT_S *rd = cd->recipient;
53 D_MSG_RETM_IF(rd == NULL, "recipient data Data is NULL");
55 RECIPIENT_ITEM_S *r_item = evas_object_data_get(obj, "selected_item");;
56 D_MSG_RETM_IF(r_item == NULL, "Recipient Data is NULL");
58 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
59 elm_genlist_item_selected_set(item, EINA_FALSE);
61 CONTACT_ITEM_S *ct_item = (CONTACT_ITEM_S *)elm_object_item_data_get(item);
62 D_MSG_RETM_IF(ct_item == NULL, "ct_item is NULL");
64 if (g_strcmp0(r_item->recipient, ct_item->recipient) == 0) {
65 D_MSG("same recipient %s", ct_item->recipient);
66 MSGC_EVAS_OBJECT_DEL(rd->popup_change_number);
70 if (COMPOSER_RETURN_RECIPIENT_DUPLICATE == msg_ui_composer_recipient_duplicate_check(cd->recipient, ct_item->recipient)) {
71 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
73 memset(r_item->recipient, 0x00, sizeof(r_item->recipient));
74 strncpy(r_item->recipient, ct_item->recipient, sizeof(r_item->recipient) - 1);
75 r_item->type = msg_ui_composer_recipient_type_get(r_item->recipient);
76 msg_ui_composer_message_type_check_and_change(cd);
79 MSGC_EVAS_OBJECT_DEL(rd->popup_change_number);
83 static char *__contact_type_string_get(int type, int contact_type)
85 static char return_string[DEF_BUF_LEN + 1] = { 0, };
86 memset(return_string, 0, DEF_BUF_LEN + 1);
88 if (type == COMPOSER_ADDR_TYPE_NUMBER) {
89 switch (contact_type) {
90 case CONTACTS_NUMBER_TYPE_HOME:
91 strncpy(return_string, _SYSSTR("IDS_COM_BODY_HOME"), sizeof(return_string) - 1);
93 case CONTACTS_NUMBER_TYPE_WORK:
94 strncpy(return_string, _SYSSTR("IDS_COM_BODY_WORK"), sizeof(return_string) - 1);
96 case CONTACTS_NUMBER_TYPE_CELL:
97 strncpy(return_string, _SYSSTR("IDS_COM_BODY_MOBILE"), sizeof(return_string) - 1);
100 strncpy(return_string, _MSGSTR("IDS_MSGF_BODY_OTHER"), sizeof(return_string) - 1);
103 } else if (type == COMPOSER_ADDR_TYPE_EMAIL) {
104 switch (contact_type) {
105 case CONTACTS_EMAIL_TYPE_HOME:
106 strncpy(return_string, _SYSSTR("IDS_COM_BODY_HOME"), sizeof(return_string) - 1);
108 case CONTACTS_EMAIL_TYPE_WORK:
109 strncpy(return_string, _SYSSTR("IDS_COM_BODY_WORK"), sizeof(return_string) - 1);
112 strncpy(return_string, _MSGSTR("IDS_MSGF_BODY_OTHER"), sizeof(return_string) - 1);
116 D_EMSG("Invalid number type !!!");
117 strncpy(return_string, _MSGSTR("IDS_MSGF_BODY_OTHER"), sizeof(return_string) - 1);
120 return return_string;
123 char *msg_ui_recipient_change_number_gl_text_get(void *data, Evas_Object *obj, const char *part)
125 D_MSG_RETVM_IF(data == NULL, NULL, "data param is NULL");
126 CONTACT_ITEM_S *ct_item = (CONTACT_ITEM_S *)data;
128 if (!strcmp(part, "elm.text.1")) {
129 return strdup(ct_item->recipient);
131 return strdup(__contact_type_string_get(ct_item->type, ct_item->contact_type));
135 void msg_ui_recipient_change_number_gl_del(void *data, Evas_Object *obj)
137 D_MSG_RETM_IF(data == NULL, "RECIPIENT_ITEM_S data is NULL");
138 CONTACT_ITEM_S *ct_item = (CONTACT_ITEM_S *)data;
145 void msg_ui_recipient_select_popup_list_clicked_cb(void *data, Evas_Object *obj, void *event_info)
148 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
149 RECIPIENT_S *rd = cd->recipient;
150 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
152 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
153 elm_list_item_selected_set(item, EINA_FALSE);
155 elm_multibuttonentry_item_selected_set(rd->sel_mbe_item, EINA_FALSE);
157 char *label = (char *)elm_object_item_text_get(item);
159 if (cd->isAppControl) {
160 if (!strcmp(label, _SYSSTR("IDS_COM_OPT_DELETE"))) {
161 msg_ui_composer_recipient_selected_delete(cd);
162 } else if (!strcmp(label,_SYSSTR("IDS_COM_BODY_EDIT"))) {
163 msg_ui_composer_recipient_selected_edit(cd);
165 D_EMSG("Invalid list type!!");
168 if (!strcmp(label, _SYSSTR("IDS_COM_OPT_DELETE"))) {
169 msg_ui_composer_recipient_selected_delete(cd);
170 } else if (!strcmp(label,_SYSSTR("IDS_COM_BODY_EDIT"))) {
171 msg_ui_composer_recipient_selected_edit(cd);
172 } else if (!strcmp(label, _MSGSTR("IDS_MSGC_OPT_USE_OTHER_CONTACT_INFO_ABB"))) {
173 msg_ui_composer_recipient_create_change_number_popup(cd);
174 } else if (!strcmp(label, _MSGSTR("IDS_MSGC_OPT_VIEW_CONTACT"))) {
175 RECIPIENT_ITEM_S *r_item = msg_ui_composer_recipient_selected_item_data_get(cd);
176 msg_ui_composer_launch_contact_detail_ug(cd, r_item->index);
178 /* set focus to back_btn to resolve invalid focus tree issue */
179 elm_object_focus_set(cd->back_btn, EINA_TRUE);
180 } else if (!strcmp(label, _SYSSTR("IDS_COM_OPT_ADD_TO_CONTACTS"))) {
181 RECIPIENT_ITEM_S *r_item = msg_ui_composer_recipient_selected_item_data_get(cd);
182 int type = MSG_CT_UG_REQUEST_UPDATE_WITH_NUM;
184 if (IsVaildEmailAddress(r_item->recipient))
185 type = MSG_CT_UG_REQUEST_UPDATE_WITH_EMAIL;
187 msg_ui_composer_launch_contact_list_ug(cd, type, r_item->recipient);
189 /* set focus to back_btn to resolve invalid focus tree issue */
190 elm_object_focus_set(cd->back_btn, EINA_TRUE);
192 D_EMSG("Invalid list type!!");
196 rd->sel_r_item = NULL;
197 rd->sel_mbe_item = NULL;
198 MSGC_EVAS_OBJECT_DEL(rd->popup_selected);
203 void msg_ui_recipient_select_popup_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
206 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
207 RECIPIENT_S *rd = cd->recipient;
209 elm_multibuttonentry_item_selected_set(rd->sel_mbe_item, EINA_FALSE);
210 rd->sel_r_item = NULL;
211 rd->sel_mbe_item = NULL;
212 MSGC_EVAS_OBJECT_DEL(rd->popup_selected);
217 void msg_ui_recipient_contact_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
221 MSG_COMPOSER_VIEW_DATA_S *cd = data;
222 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
223 /*set focus to back_btn to resolve invalid focus tree issue regarding contact_btn show/hide*/
224 elm_object_focus_set(cd->back_btn, EINA_TRUE);
225 msg_ui_composer_external_call(cd, COMPOSER_EXT_TYPE_CONTACT_PHONEUI, NULL);
230 /* multibuttonentry cb */
231 void msg_ui_recipient_mbe_focused_cb(void *data, Evas_Object *obj, void *event_info)
234 MSG_COMPOSER_VIEW_DATA_S *cd = NULL;
235 RECIPIENT_S *rd = NULL;
236 PREDICTSEARCH_S *ps = NULL;
239 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
242 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
244 ps = cd->predictsearch;
245 D_MSG_RETM_IF(rd == NULL, "Predict Data is NULL");
247 msg_ui_composer_last_focused_entry_set(cd, obj);
248 /* it is added to prevent unfocused_cb of entry on mbe */
249 Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(obj);
250 elm_multibuttonentry_item_selected_set(item, EINA_FALSE);
252 elm_multibuttonentry_expanded_set(obj, EINA_TRUE);
254 if (!cd->isAppControl || !cd->isEmulator)
255 edje_object_signal_emit(_EDJ(rd->ly_to), "show.ct_button", "*");
260 void msg_ui_recipient_mbe_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
263 MSG_COMPOSER_VIEW_DATA_S *cd = data;
264 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
265 RECIPIENT_S *rd = cd->recipient;
267 /*If it exist Selected item popup, then it should not shrink mode set == 1*/
268 if (msg_ui_composer_popup_exist(cd) == EINA_TRUE)
271 elm_multibuttonentry_expanded_set(obj, EINA_FALSE);
273 if (!cd->isAppControl || !cd->isEmulator)
274 edje_object_signal_emit(_EDJ(rd->ly_to), "hide.ct_button", "*");
279 void msg_ui_recipient_mbe_clicked_cb(void *data, Evas_Object *obj, void *event_info)
282 MSG_COMPOSER_VIEW_DATA_S *cd = data;
283 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
285 /* reset hide_keypad_op */
286 cd->hide_keypad_op = false;
288 int attach_count = msg_ui_composer_get_attach_count(cd);
290 if (attach_count > 1)
291 msg_ui_composer_contract_attach_list(cd);
293 if(msg_ui_composer_popup_exist(cd) == EINA_TRUE) {
294 msg_ui_composer_popup_focus(cd);
301 void msg_ui_recipient_mbe_item_clicked_cb(void *data, Evas_Object *obj, void *event_info)
304 MSG_COMPOSER_VIEW_DATA_S *cd = data;
305 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
307 RECIPIENT_S *rd = cd->recipient;
308 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
310 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
311 D_MSG_RETM_IF(item == NULL, "Selected Object Item is NULL");
313 RECIPIENT_ITEM_S *r_item;
315 r_item = elm_object_item_data_get(item);
316 if (r_item == NULL) {
317 D_MSG("There are no item data");
321 rd->sel_r_item = r_item;
322 rd->sel_mbe_item = item;
323 msg_ui_composer_last_focused_entry_set(cd, rd->mbe);
324 msg_ui_composer_recipient_select_popup_create(cd);
329 Eina_Bool msg_ui_recipient_mbe_item_verify_cb(Evas_Object *obj, const char *item_label, const void *item_data, const void *data)
332 D_MSG_RETVM_IF(item_label == NULL, EINA_FALSE, "item_label is NULL");
334 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
335 D_MSG_RETVM_IF(cd == NULL, EINA_FALSE, "Composer Data is NULL");
337 RECIPIENT_S *rd = cd->recipient;
338 D_MSG_RETVM_IF(rd == NULL, EINA_FALSE, "Recipient Data is NULL");
340 RECIPIENT_ITEM_S *r_item = NULL;
342 if (cd->state == COMPOSER_STATE_TYPE_PAUSE)
345 msg_ui_composer_recipient_addr_type_set(rd, COMPOSER_RECP_ADDR_NONE);
347 /*Check recipient count*/
348 int r_count = msg_ui_composer_recipient_count_get(rd);
349 if (r_count >= COMPOSER_RECIPIENT_COUNT_MAX) {
350 D_EMSG("recipient is over max count %d ", COMPOSER_RECIPIENT_COUNT_MAX);
351 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
352 msg_ui_composer_recipient_entry_text_set(rd, "");
357 D_MSG("This is a checked item before append");
361 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, item_label) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
362 D_EMSG("Input recipient is duplication");
363 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
364 msg_ui_composer_recipient_entry_text_set(rd, "");
368 r_item = msg_ui_composer_recipient_item_make_by_string(item_label);
372 if (r_item->type == COMPOSER_RECP_ADDR_INVALID) {
373 D_EMSG("recipient is invalid recipient");
374 msg_ui_composer_recipient_addr_type_set(rd, COMPOSER_RECP_ADDR_INVALID);
376 if (rd->notify_popup_idler) {
377 ecore_idler_del(rd->notify_popup_idler);
378 rd->notify_popup_idler = NULL;
380 rd->notify_popup_idler = ecore_idler_add(msg_ui_composer_recipient_show_invalid_address_popup, cd);
391 void msg_ui_recipient_mbe_item_added_cb(void *data, Evas_Object *obj, void *event_info)
394 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;;
395 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
397 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
398 D_MSG_RETM_IF(item == NULL, "Mbe item is NULL");
400 RECIPIENT_ITEM_S *recipient_item = NULL;
402 if (elm_object_item_data_get(item) == NULL) {
403 char *bt_label = elm_entry_markup_to_utf8(elm_object_item_text_get(item));
405 recipient_item = msg_ui_composer_recipient_item_make_by_string(bt_label);
406 if (recipient_item) {
407 elm_object_item_text_set(item, recipient_item->display_name);
408 elm_object_item_data_set(item, recipient_item);
410 elm_object_item_del(item);
415 D_EMSG("button label is null");
418 recipient_item = elm_object_item_data_get(item);
419 D_MSG(" recipient_item index [%d], recipient_item recipient [%s], recipient_item display_name [%s], recipient_item->image_path [%s]", recipient_item->index, recipient_item->recipient, recipient_item->display_name, recipient_item->image_path);
422 if (recipient_item) {
423 if (recipient_item->type == COMPOSER_RECP_ADDR_VALID_NUMBER || recipient_item->type == COMPOSER_RECP_ADDR_VALID_EMAIL) {
424 msg_ui_composer_message_type_check_and_change(cd);
426 D_EMSG("Invalid recipient added!!");
429 D_EMSG("No recipient item");
433 void msg_ui_recipient_mbe_item_deleted_cb(void *data, Evas_Object *obj, void *event_info)
436 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;;
437 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
439 RECIPIENT_ITEM_S *recipient_item = elm_object_item_data_get(event_info);
440 D_MSG_RETM_IF(recipient_item == NULL,"reicpient item is NULL");
442 D_MSG("===== START of recipient_item free =====");
443 D_MSG("recipient_item index [%d]", recipient_item->index);
444 D_MSG("recipient_item recipient [%s]", recipient_item->recipient);
445 D_MSG("recipient_item display_name [%s]", recipient_item->display_name);
446 D_MSG("===== END of recipient_item free =====");
447 g_free(recipient_item);
449 msg_ui_composer_message_type_check_and_change(cd);
453 static Eina_Bool __move_to_scroll_end(void *data)
456 RECIPIENT_S *rd = (RECIPIENT_S *)data;
457 D_MSG_RETVM_IF(rd == NULL, EINA_FALSE, "recipient data is NULL");
459 rd->scroll_down_idler = NULL;
464 evas_render(evas_object_evas_get(rd->bx_main));
466 elm_scroller_region_get(rd->sc, NULL, NULL, &scr_w, &scr_h);
467 D_PRINT("scroller region w = %d, h = %d ", scr_w, scr_h);
469 evas_object_geometry_get(rd->mbe, NULL, NULL, NULL, &box_h);
470 D_PRINT("mbe geometry h = %d ", box_h);
472 elm_scroller_region_show(rd->sc, 0, box_h - scr_h, scr_w, scr_h);
473 D_PRINT("scroller region show x = %d, y = %d, w = %d, h = %d ", 0, box_h - scr_h, scr_w, scr_h);
479 void msg_ui_recipient_mbe_expanded_cb(void *data, Evas_Object *obj, void *event_info)
482 RECIPIENT_S *rd = (RECIPIENT_S *)data;
483 D_MSG_RETM_IF(rd == NULL, "recipient data is NULL");
485 if (rd->scroll_down_idler) {
486 ecore_idler_del(rd->scroll_down_idler);
487 rd->scroll_down_idler = NULL;
490 int r_count = msg_ui_composer_recipient_count_get(rd);
492 rd->scroll_down_idler = ecore_idler_add(__move_to_scroll_end, rd);
497 void msg_ui_recipient_mbe_contracted_cb(void *data, Evas_Object *obj, void *event_info)
500 RECIPIENT_S *rd = (RECIPIENT_S *)data;
501 D_MSG_RETM_IF(rd == NULL, "recipient data is NULL");
503 if (rd->scroll_down_idler) {
504 ecore_idler_del(rd->scroll_down_idler);
505 rd->scroll_down_idler = NULL;
511 void msg_ui_recipient_mbe_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
514 D_MSG_RETM_IF(obj == NULL,"Mbe object is NULL point");
516 RECIPIENT_ITEM_S *r_item;
517 Elm_Object_Item *mbe_item = elm_multibuttonentry_first_item_get(obj);
519 D_MSG("===== START of mbe_items free =====");
521 r_item = elm_object_item_data_get(mbe_item);
523 D_MSG("===== START of r_item free =====");
524 D_MSG("r_item index [%d]", r_item->index);
525 D_MSG("r_item recipient [%s]", r_item->recipient);
526 D_MSG("r_item display_name [%s]", r_item->display_name);
527 D_MSG("===== END of r_item free =====");
531 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
533 D_MSG("===== END of mbe_items free =====");
538 static void __msg_ui_recipient_process_delimiter_char(void *data, char *full_str, char **text, int type)
542 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
543 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
544 D_MSG_RETM_IF(full_str == NULL, "param is NULL");
546 RECIPIENT_S *rd = cd->recipient;
547 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
549 int full_str_len = strlen(full_str);
550 bool is_required_parsing = false;
552 if (full_str_len < 1) {
553 D_EMSG("full_str_len is %d", full_str_len);
557 if (type == RECIPIENT_PARSING_TYPE_ENTER_KEY) { /*enter key case*/
558 is_required_parsing = true;
560 /* check last character is either ',' or ';' */
561 if (full_str[full_str_len - 1] == ',' || full_str[full_str_len - 1] == ';') {
562 D_MSG("full_str [%s]", full_str);
564 /* remove last ',' or ';' */
565 full_str[full_str_len - 1] = '\0';
568 is_required_parsing = true;
572 if (is_required_parsing) {
573 /* parse full str with delimeter , ; */
574 gchar **split_str = NULL;
575 split_str = g_strsplit_set(full_str, ",;", -1);
578 int count = g_strv_length(split_str);
580 MSG_BOOL is_added = FALSE;
581 MSG_BOOL is_count_max = FALSE;
582 MSG_BOOL *is_used_list = NULL;
584 D_MSG("splitted string count = %d", count);
586 is_used_list = (MSG_BOOL *)calloc(count, sizeof(MSG_BOOL));
589 for (i = 0; i < count; i++) {
590 D_MSG("%dth string is [%s]", i+1, split_str[i]);
592 if (split_str[i] && strlen(split_str[i])) {
593 if (msg_ui_composer_recipient_vaild_check(split_str[i]) == EINA_TRUE) {
594 /*Check recipient count*/
595 int r_count = msg_ui_composer_recipient_count_get(rd);
596 if (r_count >= COMPOSER_RECIPIENT_COUNT_MAX) {
597 D_EMSG("recipient is over max count %d ", COMPOSER_RECIPIENT_COUNT_MAX);
600 is_used_list[i] = TRUE;
604 if (msg_ui_composer_recipient_duplicate_check(rd, split_str[i]) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
605 D_EMSG("Input recipient is duplicated");
607 is_used_list[i] = TRUE;
611 if (msg_ui_composer_recipient_append(cd->recipient, split_str[i], 0) == COMPOSER_RETURN_SUCCESS) {
613 is_used_list[i] = TRUE;
620 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
622 /* re-assemble string */
624 char *re_assembled_str = NULL;
626 re_assembled_str = (char *)calloc(full_str_len + 1, sizeof(char));
628 if (re_assembled_str) {
629 for (i = 0; i < count - 1; i++) {
630 if (split_str[i] && strlen(split_str[i])) {
631 if (!is_used_list[i]) {
632 strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
633 strncat(re_assembled_str, ",", 1);
636 strncat(re_assembled_str, ",", 1);
639 /* append last parsted string */
640 if (split_str[i] && strlen(split_str[i])) {
641 if (!is_used_list[i])
642 strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
645 /* remove ',' ';' of last position */
646 int str_len = strlen(re_assembled_str);
648 while (re_assembled_str[str_len - 1] == ',' || re_assembled_str[str_len - 1] == ';') {
649 re_assembled_str[str_len - 1] = '\0';
657 D_MSG("reassembeld str = [%s]", re_assembled_str);
658 /*set re-assembed str to text */
659 Evas_Object *entry = elm_multibuttonentry_entry_get(rd->mbe);
661 if (type == RECIPIENT_PARSING_TYPE_DELETE_CHAR ||
662 type == RECIPIENT_PARSING_TYPE_ENTER_KEY) { /* entry_changed_cb | enter key case */
663 elm_entry_entry_set(entry, re_assembled_str);
664 elm_entry_cursor_end_set(entry);
666 if (strlen(re_assembled_str)) {
667 rd->is_required_address_popup = true;
669 } else { /* entry_filter_cb */
670 elm_entry_entry_set(entry, "");
673 if (strlen(re_assembled_str)) {
674 rd->is_required_address_popup = true;
675 *text = strdup(re_assembled_str);
681 free(re_assembled_str);
683 D_EMSG("calloc is failed");
689 D_EMSG("calloc is failed");
692 g_strfreev(split_str);
694 D_EMSG("g_strsplit_set is failed");
699 void msg_ui_recipient_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
702 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
703 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
705 RECIPIENT_S *rd = cd->recipient;
706 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
709 static char saved_str[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX + 1] = { 0, };
711 /* show invalid address popup, after either inserting text(keypad, paste) or deleting text */
712 if (rd->is_required_address_popup) {
713 msg_ui_composer_recipient_addr_type_set(rd, COMPOSER_RECP_ADDR_INVALID);
715 if (rd->notify_popup_idler) {
716 ecore_idler_del(rd->notify_popup_idler);
717 rd->notify_popup_idler = NULL;
719 rd->notify_popup_idler = ecore_idler_add(msg_ui_composer_recipient_show_invalid_address_popup, cd);
721 rd->is_required_address_popup = false;
724 recipient_str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
725 if (recipient_str == NULL)
728 COMPOSER_RECP_ADDR_E addr_type = COMPOSER_RECP_ADDR_NONE;
730 if (recipient_str && strlen(recipient_str)) {
731 addr_type = msg_ui_composer_recipient_type_get(recipient_str);
733 int str_len = strlen(recipient_str);
736 /* remove ',' ';' character of last position, it is used for deleting character case */
737 if (recipient_str[str_len - 1] == ',' || recipient_str[str_len - 1] == ';') {
738 __msg_ui_recipient_process_delimiter_char(cd, recipient_str, NULL, RECIPIENT_PARSING_TYPE_DELETE_CHAR);
745 D_MSG("changed_str = %s", recipient_str);
746 D_MSG("saved_str = %s", saved_str);
748 msg_ui_composer_recipient_addr_type_set(rd, addr_type);
749 D_MSG("recipient is invalid recipient addr_type = %d", addr_type);
751 if (g_strcmp0(saved_str, recipient_str) == 0) {
752 D_MSG("It is same string before str(%s), current str(%s)", saved_str, recipient_str);
753 g_free(recipient_str);
757 strncpy(saved_str, recipient_str, sizeof(saved_str) - 1);
758 saved_str[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX] = '\0';
760 if (strlen(recipient_str) > 0 ) {
761 msg_ui_composer_predictsearch_request(cd, recipient_str);
763 msg_ui_composer_predictsearch_clear(cd);
766 g_free(recipient_str);
770 void msg_ui_recipient_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
773 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
774 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
776 char *recipient_str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
777 if (recipient_str == NULL)
780 __msg_ui_recipient_process_delimiter_char(cd, recipient_str, NULL, RECIPIENT_PARSING_TYPE_ENTER_KEY);
784 msg_ui_composer_body_focus_set(cd, 0);
789 void msg_ui_recipient_entry_filter_cb(void *data, Evas_Object *entry, char **text)
792 D_MSG_RETM_IF(text == NULL || *text == NULL, "New Text is NULL");
794 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
795 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
797 RECIPIENT_S *rd = cd->recipient;
798 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
800 const char *pre_str = NULL;
801 char *utf8_text = NULL;
802 gchar *full_str = NULL;
804 utf8_text = elm_entry_markup_to_utf8(*text);
806 /* get previous entered str */
807 pre_str = elm_entry_entry_get(entry);
811 full_str = g_strconcat(pre_str, utf8_text, NULL);
813 full_str = g_strdup(utf8_text);
816 __msg_ui_recipient_process_delimiter_char(data, full_str, text, RECIPIENT_PARSING_TYPE_ADD_CHAR);
819 D_EMSG("full_str is NULL");
828 void msg_ui_recipient_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
831 RECIPIENT_S *rd = (RECIPIENT_S *)data;
832 D_MSG_RETM_IF(rd == NULL, "rd is NULL");
833 D_MSG_RETM_IF(obj == NULL, "obj is NULL");
834 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)rd->cd;
840 evas_object_geometry_get(obj, &x, &y, &w, &h);
841 D_MSG("recipient box x = %d, y = %d, w = %d, h = %d", x, y, w, h);
842 if (rd->recipient_h != h) {
845 if (cd->isclosed == false) { /* evas_object_resize makes bs during closing composer*/
846 Evas_Object *entry = elm_multibuttonentry_entry_get(rd->mbe);
847 int keypad_h = msg_ui_composer_get_keypad_height(entry);
849 msg_ui_composer_change_body_scroll_size(cd, keypad_h);