apply changed EFL api of thread
[apps/home/message-app.git] / thread / src / msg-ui-thread-util.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
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
7  *
8  *    http://floralicense.org/license
9  *
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.
15  */
16
17 #include "msg-ui-thread-main.h"
18 #include "appsvc.h"
19 #include <status.h>
20
21 static void __msg_ui_thread_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv);
22 static void __msg_ui_thread_ug_destroy_cb(ui_gadget_h ug, void *priv);
23 static Evas_Object *__msg_ui_thread_create_msg_detail_layout(Evas_Object* parent);
24 static void __msg_ui_thread_create_msg_detail_content(Evas_Object *parent, void *data, int msg_id);
25 static void __msg_ui_thread_popup_response_cb(void *data, Evas_Object *obj, void *event_info);
26 static void __msg_ui_thread_action_popup_ok_clicked_cb(void *data, Evas_Object *obj, void *event_info);
27 static void __msg_ui_thread_action_popup_cancel_clicked_cb(void *data, Evas_Object *obj, void *event_info);
28 static void __msg_ui_thread_action_popup_checked_cb(void *data, Evas_Object *obj, void *event_info);
29 static void __msg_ui_thread_addr_select_popup_gl_sel(void *data, Evas_Object *obj, void *event_info);
30 static void __msg_ui_thread_addr_select_popup_destroy(void *data);
31 static void __msg_ui_thread_addr_select_popup_close_clicked_cb(void *data, Evas_Object *obj, void *event_info);
32 static void __msg_ui_thread_addr_select_popup_gl_del(void *data, Evas_Object *obj);
33 static char *__msg_ui_thread_addr_select_popup_gl_text_get(void *data, Evas_Object *obj, const char *part);
34
35
36 int msg_ui_thread_launch_voice_call(const char *call_num)
37 {
38         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
39
40         int ret = -1; /* negative values are error value */
41         service_h svc_handle;
42
43         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
44                 D_EMSG("service_create() is failed !!");
45         } else {
46                 char telnum[255] = {0,};
47                 service_set_operation(svc_handle, APPSVC_OPERATION_CALL);
48                 snprintf(telnum, sizeof(telnum), "tel:%s", call_num);    /* Number to make a call */
49                 service_set_uri(svc_handle, telnum);
50                 ret = service_send_launch_request(svc_handle, NULL, NULL);
51
52                 service_destroy(svc_handle);
53         }
54
55         MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
56
57         return ret;
58 }
59
60 void msg_ui_thread_launch_video_call(const char *call_num)
61 {
62         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
63         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !call_num);
64
65         service_h svc_handle = NULL;
66         char tel_num[DEF_BUF_LEN] = {0,};
67         char contact_id[DEF_BUF_LEN_D] = {0,};
68
69         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
70                 D_EMSG("service_create() is failed !!");
71         } else {
72                 service_set_operation(svc_handle, "http://tizen.org/appcontrol/operation/vt");
73
74                 if (call_num) {
75                         snprintf(tel_num, sizeof(tel_num), "tel:%s", call_num);
76                         service_set_uri(svc_handle, tel_num);
77                 }
78                 snprintf(contact_id, sizeof(contact_id), "%d", -1);
79                 service_add_extra_data(svc_handle, "ctindex", contact_id);
80
81                 service_send_launch_request(svc_handle, NULL, NULL);
82                 service_destroy(svc_handle);
83         }
84
85         MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
86 }
87
88 void msg_ui_thread_launch_spam_setting(PMSG_THREAD_LIST_DATA pListData)
89 {
90         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
91         MSG_UI_RET_IF(MSG_UI_LEVEL_ASSERT, pListData == NULL);
92
93         pListData->cbs.layout_cb = __msg_ui_thread_ug_layout_cb;
94         pListData->cbs.result_cb = NULL;
95         pListData->cbs.destroy_cb = __msg_ui_thread_ug_destroy_cb;
96         pListData->cbs.priv = (void *)pListData;
97
98         service_h svc_handle = NULL;
99         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
100                 D_EMSG("service_create() is failed !!");
101         } else {
102                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_TYPE, MSG_BUNDLE_VALUE_SPAM_SETTING);
103                 pListData->loaded_ug = ug_create(NULL, MSG_SETTING_UG_NAME, UG_MODE_FULLVIEW, svc_handle, &pListData->cbs);
104                 service_destroy(svc_handle);
105         }
106 }
107
108 void msg_ui_thread_launch_viewer_ug(PMSG_THREAD_LIST_DATA pListData, int nMsgId)
109 {
110         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
111         MSG_UI_RET_IF(MSG_UI_LEVEL_ASSERT, pListData == NULL);
112
113         pListData->cbs.layout_cb = __msg_ui_thread_ug_layout_cb;
114         pListData->cbs.result_cb = NULL;
115         pListData->cbs.destroy_cb = __msg_ui_thread_ug_destroy_cb;
116         pListData->cbs.priv = (void *)pListData;
117
118         service_h svc_handle = NULL;
119         char msgid[10] = {0,};
120         if (service_create(&svc_handle) < 0 || svc_handle == NULL) {
121                 D_EMSG("service_create() is failed !!");
122         } else {
123                 snprintf(msgid, sizeof(msgid), "%d", nMsgId);
124                 service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_MSG_ID, msgid);
125
126                 if (pListData->loaded_ug) {
127                         ug_send_message(pListData->loaded_ug, svc_handle);
128                 } else {
129                         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_MESSAGE_BOX, MSG_BUNDLE_VALUE_MSGBOX_PROTECTED);
130                         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_INDICATOR_MODE, MSG_BUNDLE_VALUE_NO_INDICATOR);
131                         pListData->loaded_ug = ug_create(NULL, MSG_VIEWER_UG_NAME, UG_MODE_FULLVIEW, svc_handle, &pListData->cbs);
132                 }
133                 service_destroy(svc_handle);
134         }
135
136         if (!pListData->loaded_ug) {
137                 msg_ui_thread_show_notify(pListData, "Unable to open message");
138                 return;
139         }
140
141         D_LEAVE;
142         return;
143 }
144
145 static void __msg_ui_thread_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
146 {
147         D_ENTER;
148
149         if (!ug || !priv)
150                 return;
151
152         Evas_Object *base, *win;
153
154         base = ug_get_layout(ug);
155         if (!base){
156                 ug_destroy(ug);
157                 return;
158         }
159
160         win = ug_get_window();
161
162         switch (mode) {
163                 case UG_MODE_FULLVIEW:
164                         evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
165                         elm_win_resize_object_add(win, base);
166                         evas_object_show(base);
167                         break;
168                 case UG_MODE_FRAMEVIEW:
169                 default:
170                         break;
171         }
172 }
173
174 static void __msg_ui_thread_ug_destroy_cb(ui_gadget_h ug, void *priv)
175 {
176         D_ENTER;
177         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !ug || !priv);
178
179         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)priv;
180         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
181
182         if (ug == pListData->loaded_ug) {
183                 ug_destroy(ug);
184                 pListData->loaded_ug = NULL;
185
186                 if (pData->isRotate == false) {
187                         elm_object_part_content_set(pData->panes, "left", pData->layout_main);
188                         elm_object_part_content_unset(pData->panes, "right");
189                         elm_panes_content_left_size_set(pData->panes, 1.0);
190                 } else {
191                         char label[DEF_BUF_LEN_S+1] = {0,};
192
193                         if (!pData->split_data) {
194                                 msg_ui_thread_create_split_data();
195                                 msg_ui_thread_splitview_launch(pData, pData->split_data);
196                         }
197                         msg_ui_thread_get_title_text(pListData, label, DEF_BUF_LEN_S);
198
199                         if (pData->split_data)
200                                 elm_object_part_text_set(pData->split_data->title_layout, "title_text", label);
201                 }
202         }
203
204         if (pListData->search_mode == THREAD_SEARCH_ON)
205                 elm_object_focus_set(pListData->searchbar, EINA_TRUE);
206
207         if (pListData->sel_msg_id) {
208                 msg_ui_thread_list_msg_item_update(pListData, pListData->sel_msg_id);
209
210                 pListData->sel_gen_item = NULL;
211                 pListData->sel_msg_id = 0;
212         }
213 }
214
215 void msg_ui_thread_launch_msg_detail_view(PMSG_THREAD_LIST_DATA pListData, PMSG_APP_THREAD_MSG_DATA_S item_data)
216 {
217         D_ENTER;
218
219         if (!pListData || !item_data) {
220                 D_EMSG("[ERROR] pListData or item_data is NULL");
221                 return;
222         }
223
224         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
225         Evas_Object *detail_layout = NULL;
226         Evas_Object *navi_frame = NULL;
227
228         if (pData->isRotate == true)
229                 navi_frame = pData->split_data->navi_frame;
230         else
231                 navi_frame = pData->navi_frame;
232
233         if (pData->detail_layout) {
234                 msg_ui_thread_update_msg_detail_view(item_data);
235                 return;
236         }
237
238         // create layout
239         detail_layout = __msg_ui_thread_create_msg_detail_layout(navi_frame);
240
241         // create content layout
242         Evas_Object *scroller = NULL;
243         Evas_Object *entry = NULL;
244
245         /** create scroller */
246         scroller = elm_scroller_add(detail_layout);
247         elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
248         elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
249         evas_object_show(scroller);
250
251         /** create entry */
252         entry = elm_entry_add(scroller);
253         evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.0);
254         evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
255         elm_entry_editable_set(entry, EINA_FALSE);
256         elm_object_content_set(scroller, entry);
257         evas_object_show(entry);
258
259         __msg_ui_thread_create_msg_detail_content(entry, pData, item_data->msg_id);
260         elm_object_part_content_set(detail_layout, "elm.swallow.content", scroller);
261
262         //push navi item
263         Elm_Object_Item *nf_it = NULL;
264         char title[DEF_BUF_LEN+1] = {0,};
265         char str_name[DEF_BUF_LEN+1] = {0,};
266         char temp[DEF_BUF_LEN+1] = {0,};
267         int i = 0;
268
269         for (i = 0; i < item_data->addr_cnt; i++) {
270                 if (item_data->addr_info[i]->contact_id > 0 && item_data->addr_info[i]->display_name[0] != '\0') {
271                         snprintf(str_name, sizeof(str_name), "%s", item_data->addr_info[i]->display_name);
272                 } else {
273                         if (item_data->addr_info[i]->address[0] != '\0')
274                                 snprintf(str_name, sizeof(str_name), "%s", item_data->addr_info[i]->address);
275                         else
276                                 snprintf(str_name, sizeof(str_name), dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"));
277                 }
278
279                 snprintf(temp, sizeof(temp), "%s", title);
280
281                 if (*temp)
282                         snprintf(title, sizeof(title), "%s, %s", temp, str_name);
283                 else
284                         snprintf(title, sizeof(title), "%s", str_name);
285         }
286
287         if (pData->isRotate == true) {
288                 Evas_Object *back_btn = NULL;
289                 Evas_Object *title_layout = NULL;
290
291                 back_btn = elm_button_add(navi_frame);
292                 elm_object_style_set(back_btn, "naviframe/title/icon/previous");
293                 evas_object_smart_callback_add(back_btn, "clicked", msg_ui_thread_back_btn_clicked_cb, (void *)pListData);
294                 evas_object_show(back_btn);
295
296                 title_layout = elm_layout_add(navi_frame);
297                 elm_layout_file_set(title_layout, MSG_COMMON_EDJ, "title");
298                 evas_object_size_hint_weight_set(title_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
299                 evas_object_size_hint_align_set(title_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
300                 evas_object_show(title_layout);
301
302                 nf_it = elm_naviframe_item_push(navi_frame, NULL, NULL, NULL, detail_layout, "empty");
303
304                 elm_object_part_text_set(title_layout, "title_text", title);
305                 elm_object_item_part_content_set(nf_it, "title", title_layout);
306                 elm_object_part_content_set(title_layout, "prev_btn", back_btn);
307
308                 elm_object_item_part_content_unset(nf_it, "prev_btn");
309                 elm_object_item_signal_emit(nf_it, "elm,state,toolbar,close", "");
310         } else {
311                 Evas_Object *back_btn = NULL;
312
313                 back_btn = elm_button_add(navi_frame);
314                 elm_object_style_set(back_btn, "naviframe/back_btn/default");
315                 evas_object_smart_callback_add(back_btn, "clicked", msg_ui_thread_back_btn_clicked_cb, (void *)pListData);
316
317                 nf_it = elm_naviframe_item_push(navi_frame, title, back_btn, NULL, detail_layout, NULL);
318         }
319         pData->detail_layout = detail_layout;
320         pData->detail_nf_it = nf_it;
321
322         D_LEAVE;
323 }
324
325 void msg_ui_thread_update_msg_detail_view(PMSG_APP_THREAD_MSG_DATA_S item_data)
326 {
327         D_ENTER;
328
329         MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !item_data, "item_data is NULL");
330
331         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
332         Evas_Object *title_layout = NULL;
333         Evas_Object *scroller = NULL;
334         Evas_Object *entry = NULL;
335
336         //push navi item
337         char title[DEF_BUF_LEN+1] = {0,};
338         char str_name[DEF_BUF_LEN+1] = {0,};
339         char temp[DEF_BUF_LEN+1] = {0,};
340         int i = 0;
341
342         for (i = 0; i < item_data->addr_cnt; i++) {
343                 if (item_data->addr_info[i]->contact_id > 0 && item_data->addr_info[i]->display_name[0] != '\0') {
344                         snprintf(str_name, sizeof(str_name), "%s", item_data->addr_info[i]->display_name);
345                 } else {
346                         if (item_data->addr_info[i]->address[0] != '\0')
347                                 snprintf(str_name, sizeof(str_name), "%s", item_data->addr_info[i]->address);
348                         else
349                                 snprintf(str_name, sizeof(str_name), dgettext("sys_string", "IDS_COM_BODY_UNKNOWN"));
350                 }
351
352                 snprintf(temp, sizeof(temp), "%s", title);
353
354                 if (*temp)
355                         snprintf(title, sizeof(title), "%s, %s", temp, str_name);
356                 else
357                         snprintf(title, sizeof(title), "%s", str_name);
358         }
359
360         title_layout = elm_object_item_part_content_get(pData->detail_nf_it, "title");
361         if (title_layout)
362                 elm_object_part_text_set(title_layout, "title_text", title);
363
364         scroller = elm_object_part_content_get(pData->detail_layout, "elm.swallow.content");
365         MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !scroller, "scroller is NULL");
366
367         entry = elm_object_content_get(scroller);
368         MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !entry, "entry is NULL");
369
370         __msg_ui_thread_create_msg_detail_content(entry, pData, item_data->msg_id);
371
372         D_LEAVE;
373 }
374
375 static Evas_Object *__msg_ui_thread_create_msg_detail_layout(Evas_Object* parent)
376 {
377         D_ENTER;
378
379         Evas_Object *layout = NULL;
380
381         layout = elm_layout_add(parent);
382
383         elm_layout_theme_set(layout, "layout", "application", "noindicator");
384         elm_layout_file_set(layout, MSG_THREAD_THEME, "thread_detail_layout");
385         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
386         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
387
388         return layout;
389 }
390
391 static void __msg_ui_thread_create_msg_detail_content(Evas_Object *parent, void *data, int msg_id)
392 {
393         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
394         MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !data, "data is NULL");
395
396         PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)data;
397         char buf[MAX_MSG_TEXT_LEN+1] = {0, };
398         char *str = NULL;
399         msg_error_t err =  MSG_SUCCESS;
400         int msgSize = 0;
401
402         msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
403         if (msgInfo == NULL) {
404                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_create_struct(MSG_STRUCT_MESSAGE_INFO) is failed!");
405                 return;
406         }
407
408         msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
409         if (sendOpt == NULL) {
410                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_create_struct(MSG_STRUCT_SENDOPT) is failed!");
411                 msg_release_struct(&msgInfo);
412                 return;
413         }
414
415         err = msg_get_message(pData->msgHandle, (msg_message_id_t)msg_id, msgInfo, sendOpt);
416         if (err != MSG_SUCCESS) {
417                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_message() is failed : err = %d", err);
418                 msg_release_struct(&msgInfo);
419                 msg_release_struct(&sendOpt);
420                 return;
421         }
422
423         msg_get_int_value(msgInfo, MSG_MESSAGE_DATA_SIZE_INT, &msgSize);
424         if (msgSize > 0) {
425                 int msgType = 0;
426                 msg_get_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, &msgType);
427
428                 if (msgType == MSG_TYPE_MMS_NOTI) {
429                         char subject[DEF_BUF_LEN_S+1] = {0,};
430
431                         msg_get_str_value(msgInfo, MSG_MESSAGE_SUBJECT_STR, subject, DEF_BUF_LEN_S);
432                         if (strlen(subject) > 0) {
433                                 snprintf(buf, sizeof(buf), "%s", subject);
434                         } else {
435                                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_str_value(MSG_MESSAGE_SUBJECT_STR) is failed !!");
436                                 snprintf(buf, sizeof(buf), "Message subject is empty !!");
437                         }
438                 } else {
439                         char msgText[msgSize + 1];
440                         memset(msgText, 0, msgSize + 1);
441
442                         msg_get_str_value(msgInfo, MSG_MESSAGE_SMS_DATA_STR, msgText, msgSize);
443                         if (strlen(msgText) > 0) {
444                                 snprintf(buf, sizeof(buf), "%s", msgText);
445                         } else {
446                                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_str_value(MSG_MESSAGE_SMS_DATA_STR) is failed !!");
447                                 snprintf(buf, sizeof(buf), "Message is empty !!");
448                         }
449                 }
450         } else
451                 snprintf(buf, sizeof(buf), "Message is empty !!");
452
453         buf[MAX_MSG_TEXT_LEN] = '\n';
454         str = elm_entry_utf8_to_markup(buf);
455         elm_object_text_set(parent, str);
456
457         if (str != NULL) {
458                 free(str);
459                 str = NULL;
460         }
461
462         msg_release_struct(&msgInfo);
463         msg_release_struct(&sendOpt);
464
465         return;
466 }
467
468 void msg_ui_thread_get_time_format(PMSG_THREAD_DATA pData)
469 {
470         int timeformat = msg_common_get_timeformat();
471
472         if (timeformat == MSG_TIME_FORMAT_UNKNOWN)
473                 pData->time_fmt = MSG_TIME_FORMAT_12H;
474         else
475                 pData->time_fmt = timeformat;
476
477         D_MSG("%s", pData->time_fmt == MSG_TIME_FORMAT_24H ? "TIME FORMAT = 24h" : "TIME FORMAT = 12h");
478 }
479
480 void msg_ui_thread_get_locale(PMSG_THREAD_DATA pData)
481 {
482         const char *locale;
483
484         locale = msg_common_get_default_locale();
485
486         if (locale) {
487                 strncpy(pData->locale, locale, sizeof(pData->locale)-1);
488         }
489
490         D_MSG("Locale = %s", pData->locale);
491 }
492
493 void msg_ui_thread_get_bubble_data(PMSG_APP_THREAD_DATA_S item_data, service_h svc_handle)
494 {
495         MSG_UI_ENTER();
496         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !item_data || !svc_handle);
497
498         char buf[DEF_BUF_LEN_S] = {'0',};
499         char buf_contact[DEF_BUF_LEN_S] = {'0',};
500
501         snprintf(buf, DEF_BUF_LEN_S, "%d", item_data->thread_id);
502         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_ID, buf);
503         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_THREAD_NAME, item_data->thread_name);
504         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_CONTACT_ID, buf_contact);
505         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_INDICATOR_MODE, MSG_BUNDLE_VALUE_NO_INDICATOR);
506
507         MSG_UI_LEAVE();
508 }
509
510 void msg_ui_thread_get_composer_data(int msg_id, service_h svc_handle)
511 {
512         MSG_UI_ENTER();
513         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !svc_handle);
514
515         char buf[DEF_BUF_LEN_S+1] = {0,};
516
517         snprintf(buf, DEF_BUF_LEN_S, "%d", msg_id);
518         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_MSG_ID, buf);
519         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_MODE, MSG_BUNDLE_VALUE_EDIT);
520         service_add_extra_data(svc_handle, MSG_BUNDLE_KEY_FROM, MSG_BUNDLE_VALUE_INTERNAL);
521
522         MSG_UI_LEAVE();
523 }
524
525 void msg_ui_thread_cancel_edit_mode(PMSG_THREAD_LIST_DATA pListData)
526 {
527         D_ENTER;
528         Elm_Object_Item *it;
529
530         elm_check_state_set(pListData->sel_all_box, EINA_FALSE);
531
532         it = elm_genlist_first_item_get(pListData->genlist);
533         while (it) {
534                 if (elm_genlist_item_parent_get(it) == NULL) {
535                         it = elm_genlist_item_next_get(it);
536                         continue;
537                 }
538
539                 if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD) {
540                         PMSG_APP_THREAD_DATA_S item_data = NULL;
541
542                         item_data = (PMSG_APP_THREAD_DATA_S)elm_object_item_data_get(it);
543                         if (item_data)
544                                 item_data->is_check = EINA_FALSE;
545                 } else {
546                         PMSG_APP_THREAD_MSG_DATA_S item_data = NULL;
547
548                         item_data = (PMSG_APP_THREAD_MSG_DATA_S)elm_object_item_data_get(it);
549                         if (item_data)
550                                 item_data->is_check = EINA_FALSE;
551                 }
552
553                 it = elm_genlist_item_next_get(it);
554         }
555
556         pListData->chk_list = eina_list_free(pListData->chk_list);
557
558         elm_object_part_content_unset(pListData->content_ly, "sel_all");
559         evas_object_hide(pListData->sel_all_ly);
560         elm_object_part_content_set(pListData->content_ly, "sel_all", pListData->searchbar);
561         if (msg_ui_thread_rotation_get() == false)
562                 edje_object_signal_emit(_EDJ(pListData->content_ly), "hide_searchbar", "sel_all");
563         else
564                 edje_object_signal_emit(_EDJ(pListData->content_ly), "show_searchbar", "sel_all");
565
566         elm_genlist_decorate_mode_set(pListData->genlist, EINA_FALSE);
567         elm_genlist_select_mode_set(pListData->genlist, ELM_OBJECT_SELECT_MODE_DEFAULT);
568
569         pListData->view_mode = THREAD_NORMAL_VIEW;
570 }
571
572 void msg_ui_thread_show_normal_mode(PMSG_THREAD_LIST_DATA pListData)
573 {
574         D_ENTER;
575
576         if (pListData->view_mode == THREAD_EDIT_VIEW)
577                 msg_ui_thread_cancel_edit_mode(pListData);
578
579         if (pListData->selectioninfo_layout) {
580                 evas_object_del(pListData->selectioninfo_layout);
581                 pListData->selectioninfo_layout = NULL;
582         }
583
584         if (pListData->select_info) {
585                 evas_object_del(pListData->select_info);
586                 pListData->select_info = NULL;
587         }
588
589         msg_ui_thread_set_navi_toolbar_item(pListData);
590
591         if (pListData->list_type == THREAD_NORMAL_LIST_TYPE)
592                 elm_object_item_text_set(pListData->nf_it, dgettext("sys_string", "IDS_COM_BODY_MESSAGES"));
593         else if (pListData->list_type == THREAD_SPAM_LIST_TYPE)
594                 elm_object_item_text_set(pListData->nf_it, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SPAM_MESSAGES"));
595         else if (pListData->list_type == THREAD_SIM_LIST_TYPE)
596                 elm_object_item_text_set(pListData->nf_it, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SIM_CARD_MESSAGES"));
597         else if (pListData->list_type == THREAD_CBMSG_LIST_TYPE)
598                 elm_object_item_text_set(pListData->nf_it, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_CB_MESSAGES"));
599
600         if (msg_ui_thread_rotation_get() == false) {
601                 edje_object_signal_emit(_EDJ(pListData->content_ly), "hide_searchbar", "sel_all");
602                 elm_object_part_content_unset(pListData->content_ly, "sel_all");
603                 evas_object_hide(pListData->searchbar);
604
605                 elm_naviframe_item_title_visible_set(pListData->nf_it, EINA_TRUE);
606                 msg_ui_thread_show_toolbar(pListData);
607         } else {
608                 elm_naviframe_item_title_visible_set(pListData->nf_it, EINA_FALSE);
609                 msg_ui_thread_hide_toolbar(pListData, true);
610         }
611
612         D_LEAVE;
613 }
614
615 void msg_ui_thread_select_item_by_thread_id(PMSG_THREAD_LIST_DATA pListData, int thread_id)
616 {
617         if (thread_id <= 0)
618                 return;
619
620         Elm_Object_Item *gen_item = NULL;
621
622         gen_item = elm_genlist_first_item_get(pListData->genlist);
623
624         while (gen_item) {
625                 if (elm_genlist_item_parent_get(gen_item) == NULL) {
626                         gen_item = elm_genlist_item_next_get(gen_item);
627                         continue;
628                 }
629
630                 PMSG_APP_THREAD_DATA_S item_data = (PMSG_APP_THREAD_DATA_S)elm_object_item_data_get(gen_item);
631                 if (thread_id == item_data->thread_id) {
632                         pListData->sel_gen_item = gen_item;
633                         break;
634                 }
635
636                 gen_item = elm_genlist_item_next_get(gen_item);
637         }
638
639         elm_genlist_item_show(gen_item, ELM_GENLIST_ITEM_SCROLLTO_TOP);
640 }
641
642 void msg_ui_thread_select_item_by_msg_id(PMSG_THREAD_LIST_DATA pListData, int msg_id)
643 {
644         if (msg_id <= 0)
645                 return;
646
647         Elm_Object_Item *gen_item = NULL;
648         gen_item = elm_genlist_first_item_get(pListData->genlist);
649
650         while (gen_item) {
651                 if (elm_genlist_item_parent_get(gen_item) == NULL) {
652                         gen_item = elm_genlist_item_next_get(gen_item);
653                         continue;
654                 }
655
656                 PMSG_APP_THREAD_MSG_DATA_S item_data = (PMSG_APP_THREAD_MSG_DATA_S)elm_object_item_data_get(gen_item);
657                 if (msg_id == item_data->msg_id) {
658                         pListData->sel_gen_item = gen_item;
659                         break;
660                 }
661
662                 gen_item = elm_genlist_item_next_get(gen_item);
663         }
664
665         elm_genlist_item_show(gen_item, ELM_GENLIST_ITEM_SCROLLTO_TOP);
666 }
667
668 void msg_ui_thread_show_notify(PMSG_THREAD_LIST_DATA pListData, const char *msg)
669 {
670         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
671         MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, !pListData);
672
673         Evas_Object *popup;
674         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
675
676         popup = elm_popup_add(pData->win_main);
677
678         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
679         elm_object_text_set(popup, msg);
680
681         evas_object_smart_callback_add(popup, "timeout", __msg_ui_thread_popup_response_cb, pListData);
682         elm_popup_timeout_set(popup, 0.8);
683         evas_object_show(popup);
684
685         pListData->popup = popup;
686 }
687
688 static void __msg_ui_thread_popup_response_cb(void *data, Evas_Object *obj, void *event_info)
689 {
690         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
691         MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, !data);
692
693         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data;
694
695         if ((int)event_info != 5 && obj) {
696                 evas_object_del(obj);
697                 pListData->popup = NULL;
698         }
699
700         MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
701 }
702
703 void msg_ui_thread_show_action_popup(PMSG_THREAD_LIST_DATA pListData, int actionType, const char *msg)
704 {
705         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
706
707         MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, !pListData);
708
709         Evas_Object *popup;
710         Evas_Object *btn_ok;
711         Evas_Object *btn_cancel;
712         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
713
714         popup = elm_popup_add(pData->win_main);
715
716         btn_ok = elm_button_add(popup);
717         elm_object_style_set(btn_ok, "popup_button/default");
718         elm_object_text_set(btn_ok, dgettext("sys_string", "IDS_COM_SK_OK"));
719         elm_object_part_content_set(popup, "button1", btn_ok);
720         evas_object_smart_callback_add(btn_ok, "clicked", __msg_ui_thread_action_popup_ok_clicked_cb, pListData);
721
722         btn_cancel = elm_button_add(popup);
723         elm_object_style_set(btn_cancel, "popup_button/default");
724         elm_object_text_set(btn_cancel, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
725         elm_object_part_content_set(popup, "button2", btn_cancel);
726         evas_object_smart_callback_add(btn_cancel, "clicked", __msg_ui_thread_action_popup_cancel_clicked_cb, pListData);
727
728         if (actionType == THREAD_ACTION_DELETE) {
729                 bool bProtect = false;
730                 Eina_List *list;
731                 void* item_data = NULL;
732                 msg_error_t err =  MSG_SUCCESS;
733
734                 msg_struct_t threadInfo = msg_create_struct(MSG_STRUCT_THREAD_INFO);
735                 msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
736                 msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
737
738                 if (pListData->view_mode == THREAD_EDIT_VIEW) {
739                         EINA_LIST_FOREACH(pListData->chk_list, list, item_data) {
740                                 if (item_data) {
741                                         if (pListData->list_type == THREAD_NORMAL_LIST_TYPE) {
742                                                 PMSG_APP_THREAD_DATA_S data = (PMSG_APP_THREAD_DATA_S)item_data;
743
744                                                 err = msg_get_thread(msg_ui_thread_get_data_handle(), data->thread_id, threadInfo);
745                                                 if (err != MSG_SUCCESS) {
746                                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_thread() is failed : err = %d", err);
747                                                         break;
748                                                 }
749                                                 msg_get_bool_value(threadInfo, MSG_THREAD_PROTECTED_BOOL, &bProtect);
750                                                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "bProtect = %d", bProtect);
751                                         } else {
752                                                 PMSG_APP_THREAD_MSG_DATA_S data = (PMSG_APP_THREAD_MSG_DATA_S)item_data;
753
754                                                 err = msg_get_message(msg_ui_thread_get_data_handle(), (msg_message_id_t)data->msg_id, msgInfo, sendOpt);
755                                                 if (err != MSG_SUCCESS) {
756                                                         MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "msg_get_message() is failed : err = %d", err);
757                                                         break;
758                                                 }
759                                                 msg_get_bool_value(msgInfo, MSG_MESSAGE_PROTECTED_BOOL, &bProtect);
760                                         }
761
762                                         if (bProtect == true)
763                                                 break;
764                                 }
765                         }
766                 } else {
767                         Elm_Object_Item* it_sweep = NULL;
768                         it_sweep = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist);
769                         item_data = elm_object_item_data_get(it_sweep);
770
771                         if (pListData->list_type == THREAD_NORMAL_LIST_TYPE) {
772                                 PMSG_APP_THREAD_DATA_S data = (PMSG_APP_THREAD_DATA_S)item_data;
773
774                                 err = msg_get_thread(msg_ui_thread_get_data_handle(), data->thread_id, threadInfo);
775                                 if (err == MSG_SUCCESS)
776                                         msg_get_bool_value(threadInfo, MSG_THREAD_PROTECTED_BOOL, &bProtect);
777
778                                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "bProtect = %d", bProtect);
779                         } else {
780                                 PMSG_APP_THREAD_MSG_DATA_S data = (PMSG_APP_THREAD_MSG_DATA_S)item_data;
781
782                                 err = msg_get_message(msg_ui_thread_get_data_handle(), (msg_message_id_t)data->msg_id, msgInfo, sendOpt);
783                                 if (err == MSG_SUCCESS)
784                                         msg_get_bool_value(msgInfo, MSG_MESSAGE_PROTECTED_BOOL, &bProtect);
785                         }
786                 }
787                 msg_release_struct(&threadInfo);
788                 msg_release_struct(&msgInfo);
789                 msg_release_struct(&sendOpt);
790
791                 if (bProtect == true) {
792                         Evas_Object *check;
793                         Evas_Object *label_text;
794                         Evas_Object *layout;
795
796                         label_text = elm_label_add(popup);
797                         elm_layout_file_set(label_text, MSG_COMMON_EDJ, "popup_with_checkbox");
798                         elm_object_text_set(label_text, msg);
799                         evas_object_size_hint_weight_set(label_text, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
800                         evas_object_size_hint_align_set(label_text, EVAS_HINT_FILL, EVAS_HINT_FILL);
801                         evas_object_show(label_text);
802
803                         layout = elm_layout_add(popup);
804                         elm_layout_file_set(layout, MSG_COMMON_EDJ, "popup_with_checkbox");
805                         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
806
807                         check = elm_check_add(popup);
808                         evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
809                         evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
810                         evas_object_smart_callback_add(check, "changed", __msg_ui_thread_action_popup_checked_cb, pListData);
811                         evas_object_show(check);
812
813                         elm_object_part_text_set(layout, "elm.text", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_INCLUDE_PROTECTED_MESSAGE"));
814                         elm_object_part_content_set(layout, "elm.swallow.check", check);
815                         elm_object_part_content_set(layout, "elm.swallow.content", label_text);
816                         evas_object_show(layout);
817                         elm_object_content_set(popup, layout);
818                 } else {
819                         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
820                         elm_object_text_set(popup, msg);
821                 }
822         } else {
823                 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
824                 elm_object_text_set(popup, msg);
825         }
826
827         evas_object_data_set(popup, MSG_THREAD_POPUP_DATA, MSG_THREAD_DEL_CONFIRM);
828         evas_object_show(popup);
829
830         pListData->popup = popup;
831         pListData->action_type = actionType;
832 }
833
834 static void __msg_ui_thread_action_popup_ok_clicked_cb(void *data, Evas_Object *obj, void *event_info)
835 {
836         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
837
838         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data;
839         char address[DEF_THREAD_ADDR_LEN+1] = {0,};
840         bool remove_it = false;
841         bool remove_ug = false;
842         void *addr_data = NULL;
843
844         msg_error_t err =  MSG_SUCCESS;
845         Elm_Object_Item *it = NULL;
846
847         if (pListData->popup) {
848                 evas_object_del(pListData->popup);
849                 pListData->popup = NULL;
850         }
851
852         if (pListData->view_mode == THREAD_EDIT_VIEW) {
853                 pListData->popup = msg_ui_thread_show_notify_with_progressbar(pListData, pListData->check_cnt);
854                 pListData->multi_action_thread = ecore_thread_feedback_run(msg_ui_thread_multi_action_thread_fn, msg_ui_thread_multi_action_thread_feedback_fn, NULL, NULL, (void *)pListData, EINA_TRUE);
855         } else {
856                 it = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist);
857                 if (!it)
858                         goto __UNABLE_TO_DELETE;
859
860                 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
861                 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
862
863                 if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD) {
864                         PMSG_APP_THREAD_DATA_S item_data = elm_object_item_data_get(it);
865                         if (!item_data)
866                                 goto __UNABLE_TO_DELETE;
867
868                         if (pListData->action_type == THREAD_ACTION_DELETE) {
869                                 err = msg_delete_thread_message_list(msg_ui_thread_get_data_handle(), item_data->thread_id, pListData->include_protected_msg);
870                                 MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "pListData->include_protected_msg = %d", pListData->include_protected_msg);
871                                 remove_it = true;
872
873                                 if (pListData->sel_thread_id == item_data->thread_id)
874                                         remove_ug = true;
875
876                                 pListData->include_protected_msg = false;
877                         } else if (pListData->action_type == THREAD_ACTION_BLOCK) {
878                                 msg_struct_list_s addrList;
879
880                                 memset(&addrList, 0x00, sizeof(msg_struct_list_s));
881                                 msg_get_address_list(msg_ui_thread_get_data_handle(), item_data->thread_id, &addrList);
882
883                                 char strNumber[DEF_THREAD_ADDR_LEN + 1] = {0,};
884
885                                 msg_get_str_value(addrList.msg_struct_info[0], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, DEF_THREAD_ADDR_LEN);
886                                 strncpy(address, strNumber, DEF_THREAD_ADDR_LEN);
887
888                                 if (msg_common_add_block_number(msg_ui_thread_get_data_handle(), address) != MSG_SUCCESS){
889                                         msg_release_list_struct(&addrList);
890                                         goto __UNABLE_TO_DELETE;
891                                 }
892                                 addr_data = &address;
893                                 msg_release_list_struct(&addrList);
894                         }
895                 } else {
896                         PMSG_APP_THREAD_MSG_DATA_S item_data = elm_object_item_data_get(it);
897                         if (!item_data)
898                                 goto __UNABLE_TO_DELETE;
899
900                         msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO);
901                         msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT);
902
903                         err = msg_get_message(msg_ui_thread_get_data_handle(), (msg_message_id_t)item_data->msg_id, msgInfo, sendOpt);
904                         if (err != MSG_SUCCESS) {
905                                 msg_release_struct(&msgInfo);
906                                 msg_release_struct(&sendOpt);
907                                 return;
908                         }
909
910                         if (pListData->action_type == THREAD_ACTION_DELETE) {
911                                 bool bProtect = false;
912
913                                 msg_get_bool_value(msgInfo, MSG_MESSAGE_PROTECTED_BOOL, &bProtect);
914                                 if (pListData->include_protected_msg == false && bProtect == true) {
915                                         msg_release_struct(&msgInfo);
916                                         msg_release_struct(&sendOpt);
917                                         goto __UNABLE_TO_DELETE;
918                                 }
919                                 err = msg_delete_message(msg_ui_thread_get_data_handle(), item_data->msg_id);
920                                 remove_it = true;
921
922                                 if (pListData->sel_msg_id == item_data->msg_id)
923                                         remove_ug = true;
924                         } else if (pListData->action_type == THREAD_ACTION_BLOCK) {
925                                 char strNumber[DEF_THREAD_ADDR_LEN + 1] = {0,};
926                                 msg_struct_list_s *addr_list = NULL;
927
928                                 msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&addr_list);
929                                 msg_get_str_value(addr_list->msg_struct_info[0], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, DEF_THREAD_ADDR_LEN);
930                                 strncpy(address, strNumber, DEF_THREAD_ADDR_LEN);
931
932                                 if (msg_common_add_block_number(msg_ui_thread_get_data_handle(), address) != MSG_SUCCESS) {
933                                         msg_release_struct(&msgInfo);
934                                         msg_release_struct(&sendOpt);
935                                         goto __UNABLE_TO_DELETE;
936                                 }
937                                 addr_data = &address;
938                         } else if (pListData->action_type == THREAD_ACTION_RESTORE) {
939                                 err = msg_move_msg_to_folder(msg_ui_thread_get_data_handle(), item_data->msg_id, MSG_INBOX_ID);
940                                 remove_it = true;
941                                 if (pListData->sel_msg_id == item_data->msg_id)
942                                         remove_ug = true;
943                         }
944
945                         msg_release_struct(&msgInfo);
946                         msg_release_struct(&sendOpt);
947                 }
948
949                 if (err != MSG_SUCCESS)
950                         goto __UNABLE_TO_DELETE;
951
952                 msg_ui_thread_show_action_finish_info(pListData, pListData->action_type, addr_data);
953
954                 if (remove_it == true) {
955                         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
956
957                         if (pData->isRotate == true && remove_ug == true) {
958                                 if (pListData->loaded_ug) {
959                                         ug_destroy(pListData->loaded_ug);
960                                         pListData->loaded_ug = NULL;
961                                         pListData->sel_gen_item = NULL;
962                                         pListData->sel_msg_id = 0;
963                                 } else if (pData->detail_layout) {
964                                         elm_naviframe_item_pop(pData->split_data->navi_frame);
965                                         pData->detail_layout = NULL;
966                                         pListData->sel_gen_item = NULL;
967                                         pListData->sel_msg_id = 0;
968                                 } else {
969                                         msg_ui_destroy_composer_ug();
970                                 }
971
972                                 if (!pData->split_data) {
973                                         msg_ui_thread_create_split_data();
974                                         msg_ui_thread_splitview_launch(pData, pData->split_data);
975                                 }
976                                 if (pData->split_data) {
977                                         char label[DEF_BUF_LEN_S+1] = {0,};
978
979                                         msg_ui_thread_get_title_text(pListData, label, DEF_BUF_LEN_S);
980                                         elm_object_part_text_set(pData->split_data->title_layout, "title_text", label);
981                                 }
982                         }
983
984                         Elm_Object_Item *it_dateline = NULL;
985                         PMSG_APP_THREAD_DATELINE_DATA_S dateline_data = NULL;
986
987                         it_dateline = elm_genlist_item_parent_get((Elm_Object_Item *)it);
988                         if (it_dateline) {
989                                 dateline_data = elm_object_item_data_get(it_dateline);
990
991                                 if (dateline_data) {
992                                         MSG_UI_DEBUG(MSG_UI_LEVEL_DEBUG, "subitem_cnt : %d", dateline_data->subitem_cnt);
993                                         dateline_data->subitem_cnt--;
994                                         if (dateline_data->subitem_cnt == 0)
995                                                 elm_object_item_del((Elm_Object_Item *)it_dateline);
996                                 }
997                         }
998                         elm_object_item_del((Elm_Object_Item *)it);
999                         pListData->item_cnt--;
1000
1001                         if (pListData->item_cnt == 0) {
1002                                 if (pListData->app_data_type == THREAD_LIST_APP_DATA_THREAD)
1003                                         msg_ui_thread_list_load(pListData, FALSE);
1004                                 else
1005                                         msg_ui_thread_msg_list_load(pListData, pListData->list_type);
1006                         }
1007                 }
1008
1009                 pListData->include_protected_msg = false;
1010                 pListData->action_type = THREAD_ACTION_NONE;
1011         }
1012
1013         return;
1014
1015 __UNABLE_TO_DELETE:
1016
1017         pListData->include_protected_msg = false;
1018         pListData->action_type = THREAD_ACTION_NONE;
1019         msg_ui_thread_show_notify(pListData, dgettext("sys_string", "IDS_COM_POP_UNABLE_TO_DELETE"));
1020         return;
1021 }
1022
1023 static void __msg_ui_thread_action_popup_cancel_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1024 {
1025         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
1026         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data;
1027         bool show_info = false;
1028         Elm_Object_Item *it = NULL;
1029
1030
1031         it = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist);
1032
1033         if (it) {
1034                 elm_genlist_item_decorate_mode_set(it, "slide", EINA_FALSE);
1035                 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DEFAULT);
1036         }
1037
1038         if (pListData->view_mode == THREAD_EDIT_VIEW) {
1039                 if (pListData->multi_action_thread) {
1040                         if (ecore_thread_cancel(pListData->multi_action_thread) == EINA_FALSE) {
1041                                 D_MSG("ecore_thread_cancel is done.");
1042                                 pListData->multi_action_thread = NULL;
1043                         } else {
1044                                 D_MSG("ecore_thread_cancel is failed.");
1045                                 return;
1046                         }
1047                         show_info = true;
1048                 }
1049
1050                 if (pListData->popup) {
1051                         evas_object_del(pListData->popup);
1052                         pListData->popup = NULL;
1053                 }
1054
1055                 if (show_info == true)
1056                         msg_ui_thread_show_action_finish_info(pListData, pListData->action_type, NULL);
1057                 msg_ui_thread_show_normal_mode(pListData);
1058
1059                 if (pListData->list_type == THREAD_NORMAL_LIST_TYPE)
1060                         msg_ui_thread_list_load(pListData, FALSE);
1061                 else
1062                         msg_ui_thread_msg_list_load(pListData, pListData->list_type);
1063         } else {
1064                 if (pListData->popup) {
1065                         evas_object_del(pListData->popup);
1066                         pListData->popup = NULL;
1067                 }
1068         }
1069
1070         pListData->action_type = THREAD_ACTION_NONE;
1071         pListData->include_protected_msg = false;
1072 }
1073
1074 static void __msg_ui_thread_action_popup_checked_cb(void *data, Evas_Object *obj, void *event_info)
1075 {
1076         MSG_UI_ENTER();
1077
1078         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data;
1079         bool is_check = pListData->include_protected_msg;
1080
1081         if (is_check)
1082                 pListData->include_protected_msg = false;
1083         else
1084                 pListData->include_protected_msg = true;
1085
1086         MSG_UI_LEAVE();
1087 }
1088
1089 Evas_Object* msg_ui_thread_show_notify_with_progressbar(PMSG_THREAD_LIST_DATA pListData, int count)
1090 {
1091         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
1092
1093         MSG_UI_RETV_IF(MSG_UI_LEVEL_DEBUG, !pListData, NULL);
1094
1095         char buf[DEF_BUF_LEN_S] = {0,};
1096         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
1097         Evas_Object *popup = NULL;
1098         Evas_Object *progressbar = NULL;
1099         Evas_Object  *box = NULL;
1100         Evas_Object  *label = NULL;
1101         Evas_Object  *btn_cancel = NULL;
1102
1103         popup = elm_popup_add(pData->win_main);
1104
1105         label = elm_label_add(popup);
1106
1107         if (pListData->action_type == THREAD_ACTION_DELETE)
1108                 snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_POP_DELETING"));
1109         else if (pListData->action_type == THREAD_ACTION_RESTORE)
1110                 snprintf(buf, sizeof(buf), "%s", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_RESTORING_ING"));
1111         else if (pListData->action_type == THREAD_ACTION_COPY_TO_PHONE)
1112                 snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_POP_COPYING_ING"));
1113
1114         elm_object_text_set(label, buf);
1115 // ToDo: Check More
1116 //      elm_label_text_align_set(label, "center");
1117         evas_object_show(label);
1118
1119         progressbar = elm_progressbar_add(popup);
1120         elm_object_style_set(progressbar, "list_progress");
1121         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
1122         evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1123         elm_progressbar_value_set(progressbar, 0.0);
1124         evas_object_show(progressbar);
1125
1126         box = elm_box_add(popup);
1127         elm_box_pack_end(box, label);
1128         elm_box_pack_end(box, progressbar);
1129         evas_object_show(box);
1130
1131         elm_object_content_set(popup, box);
1132
1133         btn_cancel = elm_button_add(popup);
1134         elm_object_style_set(btn_cancel, "popup_button/default");
1135         elm_object_text_set(btn_cancel, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
1136         elm_object_part_content_set(popup, "button1", btn_cancel);
1137         evas_object_smart_callback_add(btn_cancel, "clicked", __msg_ui_thread_action_popup_cancel_clicked_cb, pListData);
1138
1139         evas_object_show(popup);
1140
1141         pListData->progressbar = progressbar;
1142
1143         return popup;
1144 }
1145
1146 void msg_ui_thread_show_select_info(PMSG_THREAD_LIST_DATA pListData)
1147 {
1148         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
1149         MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, !pListData);
1150
1151         if (!pListData->select_info) {
1152                 pListData->select_info = elm_notify_add(pListData->content_ly);
1153                 elm_notify_align_set(pListData->select_info, ELM_NOTIFY_ALIGN_FILL, 1.0);
1154
1155                 pListData->selectioninfo_layout = elm_layout_add(pListData->content_ly);
1156                 elm_layout_theme_set(pListData->selectioninfo_layout, "standard", "selectioninfo", "center_text");
1157                 elm_object_content_set(pListData->select_info, pListData->selectioninfo_layout);
1158         }
1159
1160         if (pListData->check_cnt == 0) {
1161                 evas_object_hide(pListData->select_info);
1162                 elm_object_disabled_set(pListData->toolbar_btn[CONTROLBAR_ITEM_1], EINA_TRUE);
1163                 elm_object_disabled_set(pListData->toolbar_btn[CONTROLBAR_ITEM_2], EINA_TRUE);
1164         } else {
1165                 char text[DEF_BUF_LEN_S] =  {'0',};
1166
1167                 snprintf(text, sizeof(text), "%s (%d)", dgettext(MESSAGE_PKGNAME, "IDS_MSGC_POP_SPACE_SELECTED"), pListData->check_cnt);
1168                 edje_object_part_text_set(_EDJ(pListData->selectioninfo_layout), "elm.text", text);
1169                 evas_object_show(pListData->select_info);
1170
1171                 elm_object_disabled_set(pListData->toolbar_btn[CONTROLBAR_ITEM_1], EINA_FALSE);
1172                 if (pListData->toolbar_btn[CONTROLBAR_ITEM_2] != NULL)
1173                         elm_object_disabled_set(pListData->toolbar_btn[CONTROLBAR_ITEM_2], EINA_FALSE);
1174         }
1175 }
1176
1177 void msg_ui_thread_show_action_finish_info(PMSG_THREAD_LIST_DATA pListData, int actionType, void *pData)
1178 {
1179         MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
1180         MSG_UI_RET_IF(MSG_UI_LEVEL_DEBUG, !pListData);
1181
1182         switch (actionType) {
1183                 case THREAD_ACTION_DELETE:
1184                         status_message_post(dgettext("sys_string", "IDS_COM_POP_DELETED"));
1185                         break;
1186                 case THREAD_ACTION_RESTORE:
1187                         status_message_post(dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_RESTORED"));
1188                         break;
1189                 case THREAD_ACTION_COPY_TO_PHONE:
1190                         status_message_post(dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_MESSAGE_COPIED_FROM_SIM_CARD"));
1191                         break;
1192                 case THREAD_ACTION_BLOCK:
1193                         {
1194                                 char *address = pData;
1195                                 char *szbuf = dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_PS_BLOCKED");
1196                                 char *text = g_strdup_printf(szbuf, address);
1197
1198                                 status_message_post(text);
1199                                 free(text);
1200                         }
1201                         break;
1202                 case THREAD_ACTION_UNBLOCK:
1203                         {
1204                                 char *address = pData;
1205                                 char *szbuf = dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_PS_UNBLOCKED");
1206                                 char *text = g_strdup_printf(szbuf, address);
1207
1208                                 status_message_post(text);
1209                                 free(text);
1210                         }
1211                         break;
1212                 default:
1213                         break;
1214         }
1215 }
1216
1217 void msg_ui_thread_addr_select_popup(PMSG_THREAD_LIST_DATA pListData, const char *title, msg_struct_list_s *addrList)
1218 {
1219         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !pListData || !title);
1220
1221         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
1222         Evas_Object *popup = NULL;
1223         Evas_Object *genlist = NULL;
1224         int i = 0;
1225         char *popup_title = NULL;
1226         int list_cnt = 0;
1227
1228         /** create popup */
1229         popup = elm_popup_add(pData->win_main);
1230         if (!popup) {
1231                 D_EMSG("elm_popup_add returns NULL");
1232                 return;
1233         }
1234         elm_object_style_set(popup, "min_menustyle");
1235         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1236
1237         /** close button */
1238         Evas_Object * btn1 = elm_button_add(popup);
1239         elm_object_style_set(btn1, "popup_button/default");
1240         elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_BODY_CLOSE"));
1241         evas_object_smart_callback_add(btn1, "clicked", __msg_ui_thread_addr_select_popup_close_clicked_cb, pListData);
1242         elm_object_part_content_set(popup, "button1", btn1);
1243
1244         /** create menu genlist */
1245         genlist = elm_genlist_add(popup);
1246         if (!genlist) {
1247                 D_EMSG("elm_genlist_add failed");
1248                 return;
1249         }
1250         evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1251         evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1252
1253         popup_title = (char *) calloc(1, strlen(title) + 1);
1254         if (strlen(title) > 0)
1255                 strncpy(popup_title, title, sizeof(char)* strlen(title));
1256
1257         evas_object_data_set(genlist, "title", popup_title);
1258         memset(&pData->itc_popup, 0x00, sizeof(Elm_Genlist_Item_Class));
1259
1260         pData->itc_popup.item_style = "1text";
1261         pData->itc_popup.func.text_get = __msg_ui_thread_addr_select_popup_gl_text_get;
1262         pData->itc_popup.func.content_get = NULL;
1263         pData->itc_popup.func.state_get = NULL;
1264         pData->itc_popup.func.del = __msg_ui_thread_addr_select_popup_gl_del;
1265
1266         /** append addresses to genlist */
1267         for (i = 0; i < addrList->nCount; i++) {
1268                 PMSG_APP_THREAD_ADDR_INFO_S addr_info = NULL;
1269                 char strNumber[DEF_THREAD_ADDR_LEN+1] = {0,};
1270                 char strName[DEF_THREAD_NAME_LEN+1] = {0,};
1271                 int contact_id = 0;
1272                 bool isBlock = false;
1273
1274                 addr_info = (PMSG_APP_THREAD_ADDR_INFO_S) calloc(1, sizeof(MSG_APP_THREAD_ADDR_INFO_S));
1275
1276                 msg_get_str_value(addrList->msg_struct_info[i], MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, strNumber, DEF_THREAD_ADDR_LEN);
1277                 msg_get_str_value(addrList->msg_struct_info[i], MSG_ADDRESS_INFO_DISPLAYNAME_STR, strName, DEF_THREAD_NAME_LEN);
1278                 msg_get_int_value(addrList->msg_struct_info[i], MSG_ADDRESS_INFO_CONTACT_ID_INT, &contact_id);
1279
1280                 bzero(addr_info->display_name, sizeof(addr_info->display_name));
1281                 if (strlen(strName) > 0)
1282                         strncpy(addr_info->display_name, strName, DEF_THREAD_NAME_LEN);
1283
1284                 bzero(addr_info->address, sizeof(addr_info->address));
1285                 if (strlen(strNumber) > 0)
1286                         strncpy(addr_info->address, strNumber, DEF_THREAD_NAME_LEN);
1287
1288                 addr_info->contact_id = contact_id;
1289
1290                 msg_common_check_block_number(msg_ui_thread_get_data_handle(), addr_info->address, &isBlock);
1291
1292                 if (strncmp(title, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_BLOCK"), strlen(title)) == 0 && isBlock == true) {
1293                         free(addr_info);
1294                         continue;
1295                 } else if (strncmp(title, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_UNBLOCK"), strlen(title)) == 0 && isBlock == false) {
1296                         free(addr_info);
1297                         continue;
1298                 }
1299
1300                 elm_genlist_item_append(genlist, &pData->itc_popup, addr_info, NULL, ELM_GENLIST_ITEM_NONE, __msg_ui_thread_addr_select_popup_gl_sel, pListData);
1301                 list_cnt++;
1302         }
1303
1304         if (list_cnt > MSG_THREAD_LIST_ADDR_POPUP_MAX_CNT)
1305                 list_cnt = MSG_THREAD_LIST_ADDR_POPUP_MAX_CNT;
1306
1307         elm_object_part_text_set(popup, "title,text", dgettext(MESSAGE_PKGNAME, "IDS_MSG_HEADER_SELECT_RECIPIENT"));
1308
1309         Evas_Object *box = elm_box_add(popup);
1310         evas_object_size_hint_min_set(box, 0, MSG_THREAD_LIST_ADDR_POPUP_ITEM_HEIGHT * elm_config_scale_get() * list_cnt);
1311         evas_object_show(genlist);
1312         elm_box_pack_end(box, genlist);
1313         elm_object_content_set(popup, box);
1314         evas_object_show(popup);
1315
1316         pListData->popup = popup;
1317 }
1318
1319 static char *__msg_ui_thread_addr_select_popup_gl_text_get(void *data, Evas_Object *obj, const char *part)
1320 {
1321         D_ENTER;
1322         PMSG_APP_THREAD_ADDR_INFO_S addr_info = (PMSG_APP_THREAD_ADDR_INFO_S)data;
1323         MSG_UI_RETV_IF(MSG_UI_LEVEL_ERR, !data, NULL);
1324
1325         if (addr_info->contact_id > 0 && strlen(addr_info->display_name) > 0) {
1326                 return strdup(addr_info->display_name);
1327         } else {
1328                 if (strlen(addr_info->address) > 0)
1329                         return strdup(addr_info->address);
1330                 else
1331                         return strdup(dgettext("sys_string","IDS_COM_BODY_UNKNOWN"));
1332         }
1333 }
1334
1335 static void __msg_ui_thread_addr_select_popup_gl_del(void *data, Evas_Object *obj)
1336 {
1337         D_ENTER;
1338
1339         PMSG_APP_THREAD_ADDR_INFO_S del_data = (PMSG_APP_THREAD_ADDR_INFO_S)data;
1340         if (del_data) {
1341                 free(del_data);
1342                 del_data = NULL;
1343         }
1344 }
1345
1346 static void __msg_ui_thread_addr_select_popup_close_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1347 {
1348         D_ENTER;
1349         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data);
1350
1351         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data;
1352         char *title = (char *)evas_object_data_get(obj, "title");
1353
1354         if (title != NULL)
1355                 free(title);
1356
1357         if (pListData->popup) {
1358                 evas_object_del(pListData->popup);
1359                 pListData->popup = NULL;
1360         }
1361 }
1362
1363 void __msg_ui_thread_addr_select_popup_gl_sel(void *data, Evas_Object *obj, void *event_info)
1364 {
1365         D_ENTER;
1366         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !data || !obj || !event_info);
1367
1368         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data;
1369         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1370         PMSG_APP_THREAD_ADDR_INFO_S addr_info = (PMSG_APP_THREAD_ADDR_INFO_S)elm_object_item_data_get(item);
1371         char *title = (char *)evas_object_data_get(obj, "title");
1372
1373         if (!title) {
1374                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] title is NULL");
1375                 return;
1376         }
1377
1378         if (strncmp(title, dgettext("sys_string", "IDS_COM_BODY_CALL"), strlen(title)) == 0) {
1379                 msg_ui_thread_launch_voice_call(addr_info->address);
1380         } else if (strncmp(title, dgettext("sys_string", "IDS_COM_BODY_VIDEO_CALL"), strlen(title)) == 0) {
1381                 msg_ui_thread_launch_video_call(addr_info->address);
1382         } else if (strncmp(title, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_BLOCK"), strlen(title)) == 0) {
1383                 if (msg_common_add_block_number(msg_ui_thread_get_data_handle(), addr_info->address) == MSG_SUCCESS)
1384                         msg_ui_thread_show_action_finish_info(pListData, THREAD_ACTION_BLOCK, addr_info->address);
1385         } else if (strncmp(title, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_UNBLOCK"), strlen(title)) == 0) {
1386                 if (msg_common_delete_block_number(msg_ui_thread_get_data_handle(), addr_info->address) == MSG_SUCCESS)
1387                         msg_ui_thread_show_action_finish_info(pListData, THREAD_ACTION_UNBLOCK, addr_info->address);
1388         } else {
1389                 MSG_UI_DEBUG(MSG_UI_LEVEL_ERR, "[ERROR] invalid title");
1390         }
1391
1392         free(title);
1393
1394         if (pListData->job_popup_end)
1395                 ecore_job_del(pListData->job_popup_end);
1396
1397         pListData->job_popup_end = ecore_job_add(__msg_ui_thread_addr_select_popup_destroy, pListData);
1398 }
1399
1400 static void __msg_ui_thread_addr_select_popup_destroy(void *data)
1401 {
1402         D_ENTER;
1403         PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)data;
1404
1405         if (pListData && pListData->popup) {
1406                 evas_object_del(pListData->popup);
1407                 pListData->popup = NULL;
1408         }
1409 }
1410
1411 void msg_ui_thread_set_app_state(int app_state)
1412 {
1413         D_ENTER;
1414
1415         if (app_state <= MSG_UI_STATE_NONE || app_state >= MSG_UI_STATE_MAX)
1416                 return;
1417
1418         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
1419
1420         if (!pData)
1421                 return;
1422
1423         if (app_state == MSG_UI_STATE_PAUSE) {
1424                 PMSG_THREAD_LIST_DATA pListData = msg_ui_thread_get_current_list();
1425
1426                 if (pListData) {
1427                         Elm_Object_Item* it_sweep = NULL;
1428
1429                         it_sweep = (Elm_Object_Item *)elm_genlist_decorated_item_get(pListData->genlist);
1430                         if (it_sweep) {
1431                                 elm_genlist_item_decorate_mode_set(it_sweep, "slide", EINA_FALSE);
1432                                 elm_genlist_item_select_mode_set(it_sweep, ELM_OBJECT_SELECT_MODE_DEFAULT);
1433                         }
1434                 }
1435         }
1436
1437         pData->app_state = app_state;
1438         D_LEAVE;
1439 }
1440
1441 int msg_ui_thread_get_app_state(PMSG_THREAD_DATA pData)
1442 {
1443         if (!pData)
1444                 return MSG_UI_STATE_NONE;
1445
1446         return pData->app_state;
1447 }
1448
1449 void msg_ui_thread_cancel_search_mode(PMSG_THREAD_LIST_DATA pListData)
1450 {
1451         if (pListData == NULL || pListData->search_mode == THREAD_SEARCH_OFF)
1452                 return;
1453
1454         pListData->search_mode = THREAD_SEARCH_OFF;
1455         elm_genlist_mode_set(pListData->genlist, ELM_LIST_SCROLL);
1456
1457         if (pListData->search_timer) {
1458                 ecore_timer_del(pListData->search_timer);
1459                 pListData->search_timer = NULL;
1460         }
1461
1462         Evas_Object *entry = NULL;
1463
1464         elm_object_signal_emit(pListData->searchbar, "elm,state,guidetext,show", "elm");
1465         entry = elm_object_part_content_get(pListData->searchbar, "elm.swallow.content");
1466         elm_object_text_set(entry, "");
1467         elm_object_signal_emit(pListData->searchbar, "cancel,out", "");
1468
1469         if (msg_ui_thread_rotation_get() == false) {
1470                 evas_object_show(pListData->search_btn);
1471                 elm_object_item_part_content_set(pListData->nf_it, "title_right_btn", pListData->search_btn);
1472
1473                 edje_object_signal_emit(_EDJ(pListData->content_ly), "hide_searchbar", "sel_all");
1474                 elm_object_part_content_unset(pListData->content_ly, "sel_all");
1475                 evas_object_hide(pListData->searchbar);
1476
1477                 msg_ui_thread_show_toolbar(pListData);
1478         }
1479
1480         if (pListData->list_type== THREAD_NORMAL_LIST_TYPE)
1481                 msg_ui_thread_list_load(pListData, FALSE);
1482         else
1483                 msg_ui_thread_msg_list_load(pListData, pListData->list_type);
1484 }
1485
1486 void msg_ui_thread_button_disabled_set(PMSG_THREAD_LIST_DATA pListData, Eina_Bool disabled, int controlbar_btn)
1487 {
1488         MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !pListData);
1489
1490         if (disabled == EINA_TRUE) {
1491                 if (pListData->view_mode == THREAD_NORMAL_VIEW) {
1492                         if (pListData->toolbar_btn[controlbar_btn])
1493                                 elm_object_disabled_set(pListData->toolbar_btn[controlbar_btn], EINA_TRUE);
1494
1495                         if (msg_ui_thread_rotation_get() == true) {
1496                                 edje_object_signal_emit(_EDJ(pListData->content_ly), "hide_searchbar", "sel_all");
1497                                 elm_object_part_content_unset(pListData->content_ly, "sel_all");
1498                                 evas_object_hide(pListData->searchbar);
1499                         } else {
1500                                 if (pListData->search_btn) {
1501                                         Evas_Object *search_icon = elm_object_content_get(pListData->search_btn);
1502                                         elm_image_file_set(search_icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_SEARCH_DIM);
1503                                 }
1504                         }
1505                 }
1506         } else {
1507                 if (pListData->view_mode == THREAD_NORMAL_VIEW) {
1508                         if (pListData->toolbar_btn[controlbar_btn])
1509                                 elm_object_disabled_set(pListData->toolbar_btn[controlbar_btn], EINA_FALSE);
1510
1511                         if (msg_ui_thread_rotation_get() == true) {
1512                                 edje_object_signal_emit(_EDJ(pListData->content_ly), "show_searchbar", "sel_all");
1513                                 evas_object_show(pListData->searchbar);
1514                                 elm_object_part_content_set(pListData->content_ly, "sel_all", pListData->searchbar);
1515                         } else {
1516                                 if (pListData->search_btn) {
1517                                         Evas_Object *search_icon = elm_object_content_get(pListData->search_btn);
1518                                         elm_image_file_set(search_icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_SEARCH);
1519                                 }
1520                         }
1521                 }
1522         }
1523 }
1524
1525 void msg_ui_thread_get_title_text(PMSG_THREAD_LIST_DATA pListData, char *label, int label_len)
1526 {
1527         MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !label || !pListData, "label or pListData is NULL");
1528
1529         if (pListData) {
1530                 switch (pListData->list_type) {
1531                 case THREAD_NORMAL_LIST_TYPE:
1532                         strncpy(label, dgettext("sys_string", "IDS_COM_BODY_MESSAGES"), sizeof(char)*label_len);
1533                         break;
1534                 case THREAD_SPAM_LIST_TYPE:
1535                         strncpy(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SPAM_MESSAGES"), sizeof(char)*label_len);
1536                         break;
1537                 case THREAD_SIM_LIST_TYPE:
1538                         strncpy(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_SIM_CARD_MESSAGES"), sizeof(char)*label_len);
1539                         break;
1540                 case THREAD_CBMSG_LIST_TYPE:
1541                         strncpy(label, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_CB_MESSAGES"), sizeof(char)*label_len);
1542                         break;
1543                 default:
1544                         D_MSG("[ERROR] invalid viewmode");
1545                         return;
1546                 }
1547         } else {
1548                 strncpy(label, dgettext("sys_string", "IDS_COM_BODY_MESSAGES"), sizeof(char)*label_len);
1549         }
1550 }
1551
1552
1553 const char *msg_ui_thread_make_search_result_string(const char *string, char *searchword, bool *result)
1554 {
1555         char pstr[DEF_BUF_LEN + 1] = {0,};
1556         static char return_string[DEF_BUF_LEN + 1] = { 0, };
1557         int word_len = 0;
1558         int search_len = 0;
1559         int i = 0;
1560         bool found = false;
1561         gchar* markup_text_start;
1562         gchar* markup_text_end;
1563         gchar* markup_text;
1564
1565         if (!searchword) return string;
1566
1567         if (g_utf8_validate(string,-1,NULL)) {
1568
1569                 strncpy(pstr, string, DEF_BUF_LEN);
1570
1571                 word_len = strlen(pstr);
1572                 search_len = strlen(searchword);
1573
1574                 for (i = 0; i < word_len; i++) {
1575                         if (!strncasecmp(searchword, &pstr[i], search_len)) {
1576                                 found = true;
1577                                 break;
1578                         }
1579                 }
1580
1581                 *result = found;
1582                 memset(return_string, 0x00, DEF_BUF_LEN);
1583
1584                 if (found) {
1585                         if (i == 0) {
1586                                 markup_text =  g_markup_escape_text(&pstr[i], search_len);
1587                                 markup_text_end = g_markup_escape_text(&pstr[search_len], word_len-search_len);
1588                                 snprintf(return_string,
1589                                                         DEF_BUF_LEN,
1590                                                         "<match>%s</match>%s",
1591                                                         (char*)markup_text,
1592                                                         (char*)markup_text_end);
1593                                 g_free(markup_text);
1594                                 g_free(markup_text_end);
1595                         } else {
1596                                 markup_text_start = g_markup_escape_text(&pstr[0], i);
1597                                 markup_text =  g_markup_escape_text(&pstr[i], search_len);
1598                                 markup_text_end =  g_markup_escape_text(&pstr[i+search_len], word_len-(i+search_len));
1599                                 snprintf(return_string,
1600                                                         DEF_BUF_LEN,
1601                                                         "%s<match>%s</match>%s",
1602                                                         (char*)markup_text_start,
1603                                                         (char*)markup_text,
1604                                                         (char*)markup_text_end);
1605                                 g_free(markup_text_start);
1606                                 g_free(markup_text);
1607                                 g_free(markup_text_end);
1608                         }
1609                 } else {
1610                         snprintf(return_string, DEF_BUF_LEN, "%s", pstr);
1611                 }
1612         }
1613
1614         return return_string;
1615 }
1616
1617
1618 void msg_ui_thread_make_time_string(time_t *msg_t, char *buf, int buf_len)
1619 {
1620         PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
1621
1622         char *time_str = NULL;
1623
1624         if (pData->time_fmt == MSG_TIME_FORMAT_24H) {
1625                 time_str = msg_common_get_formatted_date(pData->locale, pData->time_24h_ptn, msg_t);
1626                 snprintf(buf, buf_len, " %s ", time_str);
1627         } else { /* MSG_TIME_FORMAT_12H */
1628                 time_str = msg_common_get_formatted_date(pData->locale, pData->time_12h_ptn, msg_t);
1629                 snprintf(buf, buf_len, " %s ", time_str);
1630         }
1631
1632         if (time_str)
1633                 free(time_str);
1634 }