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 int attach_count = msg_ui_composer_get_attach_count(cd);
287 if (attach_count > 1)
288 msg_ui_composer_contract_attach_list(cd);
290 if(msg_ui_composer_popup_exist(cd) == EINA_TRUE) {
291 msg_ui_composer_popup_focus(cd);
298 void msg_ui_recipient_mbe_item_clicked_cb(void *data, Evas_Object *obj, void *event_info)
301 MSG_COMPOSER_VIEW_DATA_S *cd = data;
302 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
304 RECIPIENT_S *rd = cd->recipient;
305 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
307 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
308 D_MSG_RETM_IF(item == NULL, "Selected Object Item is NULL");
310 RECIPIENT_ITEM_S *r_item;
312 r_item = elm_object_item_data_get(item);
313 if (r_item == NULL) {
314 D_MSG("There are no item data");
318 rd->sel_r_item = r_item;
319 rd->sel_mbe_item = item;
320 msg_ui_composer_last_focused_entry_set(cd, rd->mbe);
321 msg_ui_composer_recipient_select_popup_create(cd);
326 Eina_Bool msg_ui_recipient_mbe_item_verify_cb(Evas_Object *obj, const char *item_label, const void *item_data, const void *data)
329 D_MSG_RETVM_IF(item_label == NULL, EINA_FALSE, "item_label is NULL");
331 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
332 D_MSG_RETVM_IF(cd == NULL, EINA_FALSE, "Composer Data is NULL");
334 RECIPIENT_S *rd = cd->recipient;
335 D_MSG_RETVM_IF(rd == NULL, EINA_FALSE, "Recipient Data is NULL");
337 RECIPIENT_ITEM_S *r_item = NULL;
339 if (cd->state == COMPOSER_STATE_TYPE_PAUSE)
342 msg_ui_composer_recipient_addr_type_set(rd, COMPOSER_RECP_ADDR_NONE);
344 /*Check recipient count*/
345 int r_count = msg_ui_composer_recipient_count_get(rd);
346 if (r_count >= COMPOSER_RECIPIENT_COUNT_MAX) {
347 D_EMSG("recipient is over max count %d ", COMPOSER_RECIPIENT_COUNT_MAX);
348 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
349 msg_ui_composer_recipient_entry_text_set(rd, "");
354 D_MSG("This is a checked item before append");
358 if (msg_ui_composer_recipient_duplicate_check(cd->recipient, item_label) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
359 D_EMSG("Input recipient is duplication");
360 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_DUP_RECP);
361 msg_ui_composer_recipient_entry_text_set(rd, "");
365 r_item = msg_ui_composer_recipient_item_make_by_string(item_label);
369 if (r_item->type == COMPOSER_RECP_ADDR_INVALID) {
370 D_EMSG("recipient is invalid recipient");
371 msg_ui_composer_recipient_addr_type_set(rd, COMPOSER_RECP_ADDR_INVALID);
373 if (rd->notify_popup_idler) {
374 ecore_idler_del(rd->notify_popup_idler);
375 rd->notify_popup_idler = NULL;
377 rd->notify_popup_idler = ecore_idler_add(msg_ui_composer_recipient_show_invalid_address_popup, cd);
388 void msg_ui_recipient_mbe_item_added_cb(void *data, Evas_Object *obj, void *event_info)
391 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;;
392 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
394 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
395 D_MSG_RETM_IF(item == NULL, "Mbe item is NULL");
397 RECIPIENT_ITEM_S *recipient_item = NULL;
399 if (elm_object_item_data_get(item) == NULL) {
400 char *bt_label = elm_entry_markup_to_utf8(elm_object_item_text_get(item));
402 recipient_item = msg_ui_composer_recipient_item_make_by_string(bt_label);
403 if (recipient_item) {
404 elm_object_item_text_set(item, recipient_item->display_name);
405 elm_object_item_data_set(item, recipient_item);
407 elm_object_item_del(item);
412 D_EMSG("button label is null");
415 recipient_item = elm_object_item_data_get(item);
416 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);
419 if (recipient_item) {
420 if (recipient_item->type == COMPOSER_RECP_ADDR_VALID_NUMBER || recipient_item->type == COMPOSER_RECP_ADDR_VALID_EMAIL) {
421 msg_ui_composer_message_type_check_and_change(cd);
423 D_EMSG("Invalid recipient added!!");
426 D_EMSG("No recipient item");
430 void msg_ui_recipient_mbe_item_deleted_cb(void *data, Evas_Object *obj, void *event_info)
433 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;;
434 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
436 RECIPIENT_ITEM_S *recipient_item = elm_object_item_data_get(event_info);
437 D_MSG_RETM_IF(recipient_item == NULL,"reicpient item is NULL");
439 D_MSG("===== START of recipient_item free =====");
440 D_MSG("recipient_item index [%d]", recipient_item->index);
441 D_MSG("recipient_item recipient [%s]", recipient_item->recipient);
442 D_MSG("recipient_item display_name [%s]", recipient_item->display_name);
443 D_MSG("===== END of recipient_item free =====");
444 g_free(recipient_item);
446 msg_ui_composer_message_type_check_and_change(cd);
450 static Eina_Bool __move_to_scroll_end(void *data)
453 RECIPIENT_S *rd = (RECIPIENT_S *)data;
454 D_MSG_RETVM_IF(rd == NULL, EINA_FALSE, "recipient data is NULL");
456 rd->scroll_down_idler = NULL;
461 evas_render(evas_object_evas_get(rd->bx_main));
463 elm_scroller_region_get(rd->sc, NULL, NULL, &scr_w, &scr_h);
464 D_PRINT("scroller region w = %d, h = %d ", scr_w, scr_h);
466 evas_object_geometry_get(rd->mbe, NULL, NULL, NULL, &box_h);
467 D_PRINT("mbe geometry h = %d ", box_h);
469 elm_scroller_region_show(rd->sc, 0, box_h - scr_h, scr_w, scr_h);
470 D_PRINT("scroller region show x = %d, y = %d, w = %d, h = %d ", 0, box_h - scr_h, scr_w, scr_h);
476 void msg_ui_recipient_mbe_expanded_cb(void *data, Evas_Object *obj, void *event_info)
479 RECIPIENT_S *rd = (RECIPIENT_S *)data;
480 D_MSG_RETM_IF(rd == NULL, "recipient data is NULL");
482 if (rd->scroll_down_idler) {
483 ecore_idler_del(rd->scroll_down_idler);
484 rd->scroll_down_idler = NULL;
487 int r_count = msg_ui_composer_recipient_count_get(rd);
489 rd->scroll_down_idler = ecore_idler_add(__move_to_scroll_end, rd);
494 void msg_ui_recipient_mbe_contracted_cb(void *data, Evas_Object *obj, void *event_info)
497 RECIPIENT_S *rd = (RECIPIENT_S *)data;
498 D_MSG_RETM_IF(rd == NULL, "recipient data is NULL");
500 if (rd->scroll_down_idler) {
501 ecore_idler_del(rd->scroll_down_idler);
502 rd->scroll_down_idler = NULL;
508 void msg_ui_recipient_mbe_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
511 D_MSG_RETM_IF(obj == NULL,"Mbe object is NULL point");
513 RECIPIENT_ITEM_S *r_item;
514 Elm_Object_Item *mbe_item = elm_multibuttonentry_first_item_get(obj);
516 D_MSG("===== START of mbe_items free =====");
518 r_item = elm_object_item_data_get(mbe_item);
520 D_MSG("===== START of r_item free =====");
521 D_MSG("r_item index [%d]", r_item->index);
522 D_MSG("r_item recipient [%s]", r_item->recipient);
523 D_MSG("r_item display_name [%s]", r_item->display_name);
524 D_MSG("===== END of r_item free =====");
528 mbe_item = elm_multibuttonentry_item_next_get(mbe_item);
530 D_MSG("===== END of mbe_items free =====");
535 static void __msg_ui_recipient_process_delimiter_char(void *data, char *full_str, char **text, int type)
539 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
540 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
541 D_MSG_RETM_IF(full_str == NULL, "param is NULL");
543 RECIPIENT_S *rd = cd->recipient;
544 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
546 int full_str_len = strlen(full_str);
547 bool is_required_parsing = false;
549 if (full_str_len < 1) {
550 D_EMSG("full_str_len is %d", full_str_len);
554 if (type == RECIPIENT_PARSING_TYPE_ENTER_KEY) { /*enter key case*/
555 is_required_parsing = true;
557 /* check last character is either ',' or ';' */
558 if (full_str[full_str_len - 1] == ',' || full_str[full_str_len - 1] == ';') {
559 D_MSG("full_str [%s]", full_str);
561 /* remove last ',' or ';' */
562 full_str[full_str_len - 1] = '\0';
565 is_required_parsing = true;
569 if (is_required_parsing) {
570 /* parse full str with delimeter , ; */
571 gchar **split_str = NULL;
572 split_str = g_strsplit_set(full_str, ",;", -1);
575 int count = g_strv_length(split_str);
577 MSG_BOOL is_added = FALSE;
578 MSG_BOOL is_count_max = FALSE;
579 MSG_BOOL *is_used_list = NULL;
581 D_MSG("splitted string count = %d", count);
583 is_used_list = (MSG_BOOL *)calloc(count, sizeof(MSG_BOOL));
586 for (i = 0; i < count; i++) {
587 D_MSG("%dth string is [%s]", i+1, split_str[i]);
589 if (split_str[i] && strlen(split_str[i])) {
590 if (msg_ui_composer_recipient_vaild_check(split_str[i]) == EINA_TRUE) {
591 /*Check recipient count*/
592 int r_count = msg_ui_composer_recipient_count_get(rd);
593 if (r_count >= COMPOSER_RECIPIENT_COUNT_MAX) {
594 D_EMSG("recipient is over max count %d ", COMPOSER_RECIPIENT_COUNT_MAX);
597 is_used_list[i] = TRUE;
601 if (msg_ui_composer_recipient_duplicate_check(rd, split_str[i]) == COMPOSER_RETURN_RECIPIENT_DUPLICATE) {
602 D_EMSG("Input recipient is duplicated");
604 is_used_list[i] = TRUE;
608 if (msg_ui_composer_recipient_append(cd->recipient, split_str[i], 0) == COMPOSER_RETURN_SUCCESS) {
610 is_used_list[i] = TRUE;
617 msg_ui_composer_common_tickernoti(cd, COMPOSER_TICKERNOTI_COUNT_MAX);
619 /* re-assemble string */
621 char *re_assembled_str = NULL;
623 re_assembled_str = (char *)calloc(full_str_len + 1, sizeof(char));
625 if (re_assembled_str) {
626 for (i = 0; i < count - 1; i++) {
627 if (split_str[i] && strlen(split_str[i])) {
628 if (!is_used_list[i]) {
629 strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
630 strncat(re_assembled_str, ",", 1);
633 strncat(re_assembled_str, ",", 1);
636 /* append last parsted string */
637 if (split_str[i] && strlen(split_str[i])) {
638 if (!is_used_list[i])
639 strncat(re_assembled_str, split_str[i], strlen(split_str[i]));
642 /* remove ',' ';' of last position */
643 int str_len = strlen(re_assembled_str);
645 while (re_assembled_str[str_len - 1] == ',' || re_assembled_str[str_len - 1] == ';') {
646 re_assembled_str[str_len - 1] = '\0';
654 D_MSG("reassembeld str = [%s]", re_assembled_str);
655 /*set re-assembed str to text */
656 Evas_Object *entry = elm_multibuttonentry_entry_get(rd->mbe);
658 if (type == RECIPIENT_PARSING_TYPE_DELETE_CHAR ||
659 type == RECIPIENT_PARSING_TYPE_ENTER_KEY) { /* entry_changed_cb | enter key case */
660 elm_entry_entry_set(entry, re_assembled_str);
661 elm_entry_cursor_end_set(entry);
663 if (strlen(re_assembled_str)) {
664 rd->is_required_address_popup = true;
666 } else { /* entry_filter_cb */
667 elm_entry_entry_set(entry, "");
670 if (strlen(re_assembled_str)) {
671 rd->is_required_address_popup = true;
672 *text = strdup(re_assembled_str);
678 free(re_assembled_str);
680 D_EMSG("calloc is failed");
686 D_EMSG("calloc is failed");
689 g_strfreev(split_str);
691 D_EMSG("g_strsplit_set is failed");
696 void msg_ui_recipient_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
699 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
700 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
702 RECIPIENT_S *rd = cd->recipient;
703 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
706 static char saved_str[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX + 1] = { 0, };
708 /* show invalid address popup, after either inserting text(keypad, paste) or deleting text */
709 if (rd->is_required_address_popup) {
710 msg_ui_composer_recipient_addr_type_set(rd, COMPOSER_RECP_ADDR_INVALID);
712 if (rd->notify_popup_idler) {
713 ecore_idler_del(rd->notify_popup_idler);
714 rd->notify_popup_idler = NULL;
716 rd->notify_popup_idler = ecore_idler_add(msg_ui_composer_recipient_show_invalid_address_popup, cd);
718 rd->is_required_address_popup = false;
721 recipient_str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
722 if (recipient_str == NULL)
725 COMPOSER_RECP_ADDR_E addr_type = COMPOSER_RECP_ADDR_NONE;
727 if (recipient_str && strlen(recipient_str)) {
728 addr_type = msg_ui_composer_recipient_type_get(recipient_str);
730 int str_len = strlen(recipient_str);
733 /* remove ',' ';' character of last position, it is used for deleting character case */
734 if (recipient_str[str_len - 1] == ',' || recipient_str[str_len - 1] == ';') {
735 __msg_ui_recipient_process_delimiter_char(cd, recipient_str, NULL, RECIPIENT_PARSING_TYPE_DELETE_CHAR);
742 D_MSG("changed_str = %s", recipient_str);
743 D_MSG("saved_str = %s", saved_str);
745 msg_ui_composer_recipient_addr_type_set(rd, addr_type);
746 D_MSG("recipient is invalid recipient addr_type = %d", addr_type);
748 if (g_strcmp0(saved_str, recipient_str) == 0) {
749 D_MSG("It is same string before str(%s), current str(%s)", saved_str, recipient_str);
750 g_free(recipient_str);
754 strncpy(saved_str, recipient_str, sizeof(saved_str) - 1);
755 saved_str[COMPOSER_RECIPIENT_ADDRESS_VAL_LEN_MAX] = '\0';
757 if (strlen(recipient_str) > 0 ) {
758 msg_ui_composer_predictsearch_request(cd, recipient_str);
760 msg_ui_composer_predictsearch_clear(cd);
763 g_free(recipient_str);
767 void msg_ui_recipient_entry_activated_cb(void *data, Evas_Object *obj, void *event_info)
770 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
771 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
773 char *recipient_str = elm_entry_markup_to_utf8(elm_entry_entry_get(obj));
774 if (recipient_str == NULL)
777 __msg_ui_recipient_process_delimiter_char(cd, recipient_str, NULL, RECIPIENT_PARSING_TYPE_ENTER_KEY);
781 msg_ui_composer_body_focus_set(cd, 0);
786 void msg_ui_recipient_entry_filter_cb(void *data, Evas_Object *entry, char **text)
789 D_MSG_RETM_IF(text == NULL || *text == NULL, "New Text is NULL");
791 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)data;
792 D_MSG_RETM_IF(cd == NULL, "Composer Data is NULL");
794 RECIPIENT_S *rd = cd->recipient;
795 D_MSG_RETM_IF(rd == NULL, "Recipient Data is NULL");
797 const char *pre_str = NULL;
798 char *utf8_text = NULL;
799 gchar *full_str = NULL;
801 utf8_text = elm_entry_markup_to_utf8(*text);
803 /* get previous entered str */
804 pre_str = elm_entry_entry_get(entry);
808 full_str = g_strconcat(pre_str, utf8_text, NULL);
810 full_str = g_strdup(utf8_text);
813 __msg_ui_recipient_process_delimiter_char(data, full_str, text, RECIPIENT_PARSING_TYPE_ADD_CHAR);
816 D_EMSG("full_str is NULL");
825 void msg_ui_recipient_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
828 RECIPIENT_S *rd = (RECIPIENT_S *)data;
829 D_MSG_RETM_IF(rd == NULL, "rd is NULL");
830 D_MSG_RETM_IF(obj == NULL, "obj is NULL");
831 MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)rd->cd;
837 evas_object_geometry_get(obj, &x, &y, &w, &h);
838 D_MSG("recipient box x = %d, y = %d, w = %d, h = %d", x, y, w, h);
839 if (rd->recipient_h != h) {
842 if (cd->isclosed == false) { /* evas_object_resize makes bs during closing composer*/
843 Evas_Object *entry = elm_multibuttonentry_entry_get(rd->mbe);
844 int keypad_h = msg_ui_composer_get_keypad_height(entry);
846 msg_ui_composer_change_body_scroll_size(cd, keypad_h);