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-thread-main.h"
20 PMSG_THREAD_DATA g_data = NULL;
22 PMSG_THREAD_DATA msg_ui_thread_get_data(void)
30 msg_handle_t msg_ui_thread_get_data_handle(void)
33 return g_data->msgHandle;
38 Elm_Genlist_Item_Class* msg_ui_thread_get_itc_type(ThreadItcType type)
43 if (type == THREAD_ITC_EMPTY)
44 return &g_data->itc_empty;
45 else if (type == THREAD_ITC_SEARCH)
46 return &g_data->itc_search;
47 else if (type == THREAD_ITC_BLANK)
48 return &g_data->itc_blank;
49 else if (type == THREAD_ITC_POPUP)
50 return &g_data->itc_popup;
51 else if (type == THREAD_ITC_DATE)
52 return &g_data->itc_date;
58 /* Launching Time Check */
59 static void __main_layout_flush_post_cb(void *data, Evas *e, void *event_info)
61 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_FLUSH_POST, __main_layout_flush_post_cb);
64 void *msg_ui_thread_init_thread_data(struct appdata *ad)
66 PMSG_THREAD_DATA pData = NULL;
68 pData = (PMSG_THREAD_DATA)calloc(1, sizeof(MSG_THREAD_DATA));
71 D_MSG("calloc error");
74 bzero(pData, sizeof(MSG_THREAD_DATA));
78 pData->msgHandle = ad->msgHandle;
79 pData->win_main = ad->win_main;
80 pData->conform = ad->conform;
81 pData->th = elm_theme_new();
82 elm_theme_ref_set(pData->th, NULL);
83 elm_theme_extension_add(pData->th, MSG_THREAD_THEME);
85 msg_ui_thread_common_style_set(pData);
86 msg_ui_thread_reg_msg_cb_func(pData);
87 msg_ui_thread_get_locale(pData);
88 msg_ui_thread_get_time_format(pData);
89 pData->time_12h_ptn = msg_common_get_date_best_pattern(pData->locale, MSG_UI_TIME_PATTERN_12H);
90 pData->time_24h_ptn = msg_common_get_date_best_pattern(pData->locale, MSG_UI_TIME_PATTERN_24H);
91 pData->date_ptn_default = msg_common_get_date_best_pattern(pData->locale, MSG_UI_DATE_PATTERN_DEFAULT);
92 pData->date_ptn_year = msg_common_get_date_best_pattern(pData->locale, MSG_UI_DATE_PATTERN_YEAR);
94 /* Register callback to apply time change. */
95 if (vconf_notify_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, msg_ui_thread_timezone_change_cb, (void *)pData) < 0) {
96 D_EMSG("Fail to register vconf CB with [%s]", VCONFKEY_SYSTEM_TIME_CHANGED);
102 void msg_ui_thread_deinit_thread_data(void *data)
107 PMSG_THREAD_DATA pData = data;
110 for (i = MSG_THREAD_LIST_MAX_COUNT-1; i >= 0; i--) {
111 if (pData->list_data[i] != NULL) {
112 msg_ui_thread_destroy_thread_list_data(pData->list_data[i]);
116 if (pData->split_data) {
117 msg_ui_thread_destroy_split_data(pData->split_data);
120 if (pData->date_ptn_default) {
121 free(pData->date_ptn_default);
122 pData->date_ptn_default = NULL;
125 if (pData->date_ptn_year) {
126 free(pData->date_ptn_year);
127 pData->date_ptn_year = NULL;
130 if (pData->time_12h_ptn) {
131 free(pData->time_12h_ptn);
132 pData->time_12h_ptn = NULL;
135 if (pData->time_24h_ptn) {
136 free(pData->time_24h_ptn);
137 pData->time_24h_ptn = NULL;
141 elm_theme_extension_del(pData->th, MSG_THREAD_THEME);
142 elm_theme_free(pData->th);
146 if (vconf_ignore_key_changed(VCONFKEY_SYSTEM_TIME_CHANGED, msg_ui_thread_timezone_change_cb) < 0) {
147 D_EMSG("Fail to remove vconf CB with [%s]", VCONFKEY_SYSTEM_TIME_CHANGED);
151 PMSG_THREAD_LIST_DATA msg_ui_thread_create_thread_list_data(ThreadMsgListType list_type, ThreadMsgListAppDataType app_data_type)
154 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
155 PMSG_THREAD_LIST_DATA pListData = (PMSG_THREAD_LIST_DATA)calloc(1, sizeof(MSG_THREAD_LIST_DATA));
158 D_MSG("calloc error");
161 bzero(pListData, sizeof(MSG_THREAD_LIST_DATA));
163 pListData->view_mode = THREAD_NORMAL_VIEW;
164 pListData->list_type = list_type;
165 pListData->app_data_type = app_data_type;
166 pListData->search_mode = THREAD_SEARCH_OFF;
167 pListData->job_popup_end = NULL;
168 pListData->action_type = THREAD_ACTION_NONE;
169 pListData->include_protected_msg = false;
171 for (i = 0; i < MSG_THREAD_LIST_MAX_COUNT; i++) {
172 if (pData->list_data[i] == NULL) {
173 pData->list_data[i] = pListData;
180 PMSG_THREAD_SPLIT_DATA msg_ui_thread_create_split_data(void)
182 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
183 PMSG_THREAD_SPLIT_DATA pSplitData = (PMSG_THREAD_SPLIT_DATA)calloc(1, sizeof(MSG_THREAD_SPLIT_DATA));
186 D_MSG("calloc error");
189 bzero(pSplitData, sizeof(MSG_THREAD_SPLIT_DATA));
190 pData->split_data = pSplitData;
195 void msg_ui_thread_destroy_thread_list_data(PMSG_THREAD_LIST_DATA pListData)
199 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
204 if (pListData->multi_action_thread) {
205 if (ecore_thread_cancel(pListData->multi_action_thread) == EINA_FALSE) {
206 D_MSG("ecore_thread_cancel is done.");
208 D_MSG("ecore_thread_cancel is failed.");
210 pListData->multi_action_thread = NULL;
214 if(pListData->job_popup_end) {
215 if (ecore_job_del(pListData->job_popup_end))
216 D_MSG("ecore_job_del is done.");
217 pListData->job_popup_end = NULL;
220 for (i = 0; i < CONTROLBAR_ITEM_MAX; i++) {
221 if (pListData->toolbar_btn[i]) {
222 evas_object_del(pListData->toolbar_btn[i]);
223 pListData->toolbar_btn[i] = NULL;
227 evas_object_del(pListData->back_btn);
228 pListData->back_btn = NULL;
230 for (i = MSG_THREAD_LIST_MAX_COUNT-1; i >= 0; i--) {
231 if (pData->list_data[i] != NULL && pData->list_data[i] == pListData) {
233 pData->list_data[i] = NULL;
235 for (j = i; j < MSG_THREAD_LIST_MAX_COUNT-2; j++) {
236 pData->list_data[j] = pData->list_data[j+1];
237 pData->list_data[j+1] = NULL;
244 void msg_ui_thread_destroy_split_data(PMSG_THREAD_SPLIT_DATA pSplitData)
247 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
252 evas_object_hide(pSplitData->content_ly);
253 evas_object_del(pSplitData->content_ly);
254 pSplitData->content_ly = NULL;
257 pData->split_data = NULL;
260 PMSG_THREAD_LIST_DATA msg_ui_thread_get_default_list(void)
262 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
263 PMSG_THREAD_LIST_DATA pListData = NULL;
269 for (i = 0; i < MSG_THREAD_LIST_MAX_COUNT; i++) {
270 if (pData->list_data[i] != NULL && pData->list_data[i]->list_type == THREAD_NORMAL_LIST_TYPE) {
271 pListData = pData->list_data[i];
279 PMSG_THREAD_LIST_DATA msg_ui_thread_get_current_list(void)
281 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
282 PMSG_THREAD_LIST_DATA pListData = NULL;
288 for (i = MSG_THREAD_LIST_MAX_COUNT-1; i >= 0; i--) {
289 if (pData->list_data[i] != NULL) {
290 pListData = pData->list_data[i];
298 PMSG_THREAD_LIST_DATA msg_ui_thread_get_prev_list(PMSG_THREAD_LIST_DATA pListData)
300 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
301 PMSG_THREAD_LIST_DATA pPrevList = NULL;
304 for (i = MSG_THREAD_LIST_MAX_COUNT-1; i > 0; i--) {
305 if (pData->list_data[i] == pListData) {
306 pPrevList = pData->list_data[i-1];
314 Evas_Object *msg_ui_thread_create_layout_main(PMSG_THREAD_DATA pData)
316 MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
317 MSG_UI_RETVM_IF(MSG_UI_LEVEL_ERR, pData == NULL || pData->win_main == NULL, NULL, "pData is NULL");
322 bg = elm_bg_add(pData->win_main);
323 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
324 evas_object_show(bg);
326 layout = elm_layout_add(pData->conform);
327 MSG_UI_RETVM_IF(MSG_UI_LEVEL_ERR, layout == NULL, NULL, "Failed elm_layout_add.\n");
329 elm_layout_theme_set(layout, "layout", "application", "default");
330 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
331 elm_win_resize_object_add(pData->win_main, bg);
332 elm_object_part_content_set(layout, "elm.swallow.bg", bg);
333 evas_object_show(layout);
335 evas_event_callback_add(evas_object_evas_get(layout), EVAS_CALLBACK_RENDER_FLUSH_POST, __main_layout_flush_post_cb, NULL);
337 pData->panes = elm_panes_add(layout);
338 elm_panes_fixed_set(pData->panes, EINA_FALSE);
339 evas_object_size_hint_weight_set(pData->panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
340 evas_object_size_hint_align_set(pData->panes, EVAS_HINT_FILL, EVAS_HINT_FILL);
341 evas_object_show(pData->panes);
343 evas_object_smart_callback_add(pData->panes, "press", msg_ui_thread_panes_handler_press_cb, pData);
344 evas_object_smart_callback_add(pData->panes, "unpress", msg_ui_thread_panes_handler_unpress_cb, pData);
346 elm_object_part_content_set(layout, "elm.swallow.content", pData->panes);
348 pData->layout_main = elm_layout_add(pData->panes);
349 MSG_UI_RETVM_IF(MSG_UI_LEVEL_ERR, pData->layout_main == NULL, NULL, "Failed elm_layout_add.\n");
351 elm_layout_theme_set(pData->layout_main, "layout", "application", "noindicator");
352 evas_object_size_hint_weight_set(pData->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
353 elm_object_part_content_set(pData->panes, "left", pData->layout_main);
354 evas_object_show(pData->layout_main);
356 pData->navi_frame = elm_naviframe_add(pData->layout_main);
357 elm_object_part_content_set(pData->layout_main, "elm.swallow.content", pData->navi_frame);
358 evas_object_show(pData->navi_frame);
360 MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
365 void msg_ui_thread_load_thread_view(void *data, service_h service)
370 PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)data;
371 PMSG_THREAD_LIST_DATA pListData = NULL;
373 pListData = msg_ui_thread_create_thread_list_data(THREAD_NORMAL_LIST_TYPE, THREAD_LIST_APP_DATA_THREAD);
374 msg_ui_thread_fullview_launch(pData, pListData);
375 msg_ui_thread_list_load(pListData, TRUE);
377 if (pData->isRotate == true) {
378 PMSG_THREAD_SPLIT_DATA pSplitData = NULL;
379 pSplitData = msg_ui_thread_create_split_data();
380 msg_ui_thread_splitview_launch(pData, pSplitData);
383 /* Search mode from live-box */
384 char *key_type = NULL;
386 service_get_extra_data(service, MSG_BUNDLE_KEY_TYPE, &key_type);
387 if (g_strcmp0(key_type, MSG_BUNDLE_VALUE_SEARCH_MODE) == 0) {
388 if (pListData->searchbar)
389 elm_object_focus_set(pListData->searchbar, EINA_TRUE);
393 void msg_ui_thread_load_message_box(int list_type)
397 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
398 PMSG_THREAD_LIST_DATA pListData = NULL;
400 pListData = msg_ui_thread_create_thread_list_data(list_type, THREAD_LIST_APP_DATA_MSG);
401 msg_ui_thread_fullview_launch(pData, pListData);
402 msg_ui_thread_msg_list_load(pListData, list_type);
404 if (pData->isRotate == true) {
405 PMSG_THREAD_SPLIT_DATA pSplitData = NULL;
406 msg_ui_thread_destroy_split_data(pData->split_data);
407 pSplitData = msg_ui_thread_create_split_data();
408 msg_ui_thread_splitview_launch(pData, pSplitData);
410 edje_object_signal_emit(_EDJ(pListData->content_ly), "hide_searchbar", "sel_all");
411 elm_object_part_content_unset(pListData->content_ly, "sel_all");
412 evas_object_hide(pListData->searchbar);
418 void msg_ui_thread_fullview_launch(PMSG_THREAD_DATA pData, PMSG_THREAD_LIST_DATA pListData)
420 char label[DEF_BUF_LEN_S+1] = {0,};
422 MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
423 MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !pData || !pListData, "pData or pListData is NULL");
425 pListData->content_ly = msg_ui_thread_create_content_layout(pData->navi_frame);
426 pListData->noc_ly = msg_ui_thread_create_nocontent_layout(pData->navi_frame);
428 pListData->searchbar = msg_ui_thread_create_searchbar_layout(pListData->content_ly, pListData);
429 if (pData->isRotate == true)
430 elm_object_part_content_set(pListData->content_ly, "sel_all", pListData->searchbar);
432 pListData->genlist = msg_ui_thread_create_genlist(pListData->content_ly, pListData);
433 elm_object_part_content_set(pListData->content_ly, "thread_list", pListData->genlist);
434 //evas_object_data_set(pListData->genlist, "pData", pListData);
436 if (msg_ui_thread_get_prev_list(pListData) == NULL)
437 elm_win_conformant_set(pData->win_main, 1);
439 pListData->back_btn = elm_button_add(pData->navi_frame);
440 elm_object_style_set(pListData->back_btn, "naviframe/back_btn/default");
441 evas_object_smart_callback_add(pListData->back_btn, "clicked", msg_ui_thread_back_btn_clicked_cb, (void *)pListData);
443 msg_ui_thread_get_title_text(pListData, label, DEF_BUF_LEN_S);
444 pListData->nf_it = elm_naviframe_item_push(pData->navi_frame, label, pListData->back_btn, NULL, pListData->content_ly, NULL);
445 msg_ui_thread_set_navi_toolbar_item(pListData);
447 MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
450 void msg_ui_thread_splitview_launch(PMSG_THREAD_DATA pData, PMSG_THREAD_SPLIT_DATA pSplitData)
453 MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, !pData || !pSplitData, "pData or pSplitData is NULL");
455 PMSG_THREAD_LIST_DATA pListData = msg_ui_thread_get_current_list();
456 char label[DEF_BUF_LEN_S+1] = {0,};
458 if (!pSplitData->content_ly)
459 pSplitData->content_ly= elm_layout_add(pData->panes);
460 elm_layout_theme_set(pSplitData->content_ly, "layout", "application", "noindicator");
461 evas_object_size_hint_weight_set(pSplitData->content_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
462 evas_object_size_hint_align_set(pSplitData->content_ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
464 if (!pSplitData->navi_frame)
465 pSplitData->navi_frame= elm_naviframe_add(pSplitData->content_ly);
466 elm_object_part_content_set(pSplitData->content_ly, "elm.swallow.content", pSplitData->navi_frame);
468 if (!pSplitData->noc_ly)
469 pSplitData->noc_ly= msg_ui_thread_create_nocontent_layout(pSplitData->navi_frame);
470 elm_object_part_content_set(pSplitData->content_ly, "thread_list", pSplitData->noc_ly);
471 evas_object_show(pSplitData->noc_ly);
473 /*Push content to navi frame*/
474 if (!pSplitData->back_btn)
475 pSplitData->back_btn = elm_button_add(pSplitData->navi_frame);
476 elm_object_style_set(pSplitData->back_btn, "naviframe/back_btn/default");
477 evas_object_smart_callback_add(pSplitData->back_btn, "clicked", msg_ui_thread_back_btn_clicked_cb, (void *)pListData);
478 evas_object_show(pSplitData->back_btn);
480 if (!pSplitData->nf_it)
481 pSplitData->nf_it = elm_naviframe_item_push(pSplitData->navi_frame, NULL, NULL, NULL, pSplitData->noc_ly, "empty");
483 /* create navi title layout */
484 if (!pSplitData->title_layout)
485 pSplitData->title_layout = elm_layout_add(pSplitData->navi_frame);
486 elm_layout_file_set(pSplitData->title_layout, MSG_COMMON_EDJ, "title");
487 evas_object_size_hint_weight_set(pSplitData->title_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
488 evas_object_size_hint_align_set(pSplitData->title_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
489 evas_object_show(pSplitData->title_layout);
491 msg_ui_thread_get_title_text(pListData, label, DEF_BUF_LEN_S);
492 elm_object_part_text_set(pSplitData->title_layout, "title_text", label);
493 elm_object_item_part_content_set(pSplitData->nf_it, "title", pSplitData->title_layout);
495 /*Create composer button*/
496 if (pListData->list_type == THREAD_NORMAL_LIST_TYPE) {
497 if (!pSplitData->composer_btn)
498 pSplitData->composer_btn = elm_button_add(pSplitData->navi_frame);
499 elm_object_style_set(pSplitData->composer_btn, "naviframe/title_icon");
501 Evas_Object *icon = elm_icon_add(pSplitData->composer_btn);
502 elm_image_file_set(icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_COMPOSE);
503 elm_image_resizable_set(icon, 1, 1);
504 evas_object_image_smooth_scale_set(icon, 0);
505 elm_object_content_set(pSplitData->composer_btn, icon);
507 evas_object_smart_callback_add(pSplitData->composer_btn, "clicked", msg_ui_thread_ctlbar_compose_cb, (void *)pListData);
508 evas_object_show(pSplitData->composer_btn);
510 elm_object_part_content_set(pSplitData->title_layout, "compose_btn", pSplitData->composer_btn);
512 elm_object_part_content_set(pSplitData->title_layout, "prev_btn", pSplitData->back_btn);
514 elm_object_part_content_set(pData->panes, "right", pSplitData->content_ly);
515 evas_object_show(pSplitData->content_ly);
520 Evas_Object *msg_ui_thread_create_searchbar_layout(Evas_Object *parent, PMSG_THREAD_LIST_DATA pListData)
522 MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
527 Evas_Object *layout = NULL;
528 layout = elm_layout_add(parent);
529 elm_layout_theme_set(layout, "layout", "searchbar", "cancel_button");
530 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
531 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
533 Evas_Object *entry = NULL;
534 entry = elm_entry_add(layout);
535 elm_entry_scrollable_set(entry, EINA_TRUE);
536 elm_entry_single_line_set(entry, EINA_TRUE);
537 elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
539 elm_object_part_content_set(layout, "elm.swallow.content", entry);
540 elm_object_part_text_set(layout, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_SEARCH"));
542 Evas_Object *cancel_button = NULL;
543 cancel_button = elm_button_add(layout);
544 elm_object_part_content_set(layout, "button_cancel", cancel_button);
545 elm_object_style_set(cancel_button, "searchbar/default");
546 elm_object_text_set(cancel_button, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
548 static Elm_Entry_Filter_Limit_Size limit_filter_data;
550 limit_filter_data.max_char_count = 0;
551 limit_filter_data.max_byte_count = DEF_MAX_MSG_TEXT_LEN;
552 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
554 evas_object_smart_callback_add(entry, "focused", msg_ui_thread_searchbar_entry_focus_cb, (void *)pListData);
555 evas_object_smart_callback_add(entry, "unfocused", msg_ui_thread_searchbar_entry_unfocus_cb, (void *)pListData);
556 evas_object_smart_callback_add(cancel_button, "clicked", msg_ui_thread_searchbar_cancel_click_cb, (void *)pListData);
557 elm_object_signal_callback_add(layout, "elm,eraser,clicked", "elm", msg_ui_thread_searchbar_eraser_clicked_cb, (void *)pListData);
559 evas_object_show(layout);
561 MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
566 Evas_Object *msg_ui_thread_create_genlist(Evas_Object *parent, PMSG_THREAD_LIST_DATA pListData)
573 Evas_Object *genlist = NULL;
575 genlist = elm_genlist_add(parent);
576 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
578 evas_object_smart_callback_add(genlist, "drag,start,right", msg_ui_thread_gl_mode_right, (void *)pListData);
579 evas_object_smart_callback_add(genlist, "drag,start,left", msg_ui_thread_gl_mode_left, (void *)pListData);
581 /** "3text.tb" style is only supported COMPRESS MODE */
582 /** "3text.1icon" and "1text" are suported COMPRESS MODE also */
583 elm_genlist_mode_set(genlist, ELM_LIST_SCROLL);
584 msg_ui_thread_genlist_style_set(pListData);
591 Evas_Object *msg_ui_thread_create_content_layout(Evas_Object *parent)
593 MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
597 layout = elm_layout_add(parent);
598 elm_layout_file_set(layout, MSG_THREAD_THEME, "thread_content");
599 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
600 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
602 MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
607 Evas_Object *msg_ui_thread_create_nocontent_layout(Evas_Object *parent)
609 MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
611 Evas_Object *noc_layout = NULL;
613 noc_layout = elm_layout_add(parent);
614 elm_layout_theme_set(noc_layout, "layout", "nocontents", "text");
615 elm_object_part_text_set(noc_layout, "elm.text", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_NOMESSAGES"));
617 MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
622 void msg_ui_thread_reg_msg_cb_func(PMSG_THREAD_DATA pData)
624 MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
625 MSG_UI_RETM_IF(MSG_UI_LEVEL_ERR, pData == NULL, "PMSG_THREAD_DATA is NULL");
627 msg_reg_storage_change_callback(pData->msgHandle, &msg_ui_thread_storage_change_cb, pData);
629 MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
632 void msg_ui_thread_reset_thread_view(void *data, service_h service)
639 PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)data;
642 if (pData->detail_layout) {
643 if (pData->isRotate == true)
644 elm_naviframe_item_pop(pData->split_data->navi_frame);
646 elm_naviframe_item_pop(pData->navi_frame);
647 pData->detail_layout = NULL;
650 for (i = MSG_THREAD_LIST_MAX_COUNT-1; i >= 0; i--) {
651 if (pData->list_data[i] != NULL && pData->list_data[i]->list_type != THREAD_NORMAL_LIST_TYPE) {
652 if (pData->list_data[i]->loaded_ug) {
653 ug_destroy(pData->list_data[i]->loaded_ug);
654 pData->list_data[i]->loaded_ug = NULL;
656 elm_naviframe_item_pop(pData->navi_frame);
657 elm_genlist_clear(pData->list_data[i]->genlist);
658 msg_ui_thread_destroy_thread_list_data(pData->list_data[i]);
662 PMSG_THREAD_LIST_DATA pListData = NULL;
664 pListData = msg_ui_thread_get_default_list();
665 if (pListData == NULL)
668 if (pListData->view_mode == THREAD_EDIT_VIEW)
669 msg_ui_thread_show_normal_mode(pListData);
671 msg_ui_thread_cancel_search_mode(pListData);
673 if (pData->isRotate == true) {
674 msg_ui_thread_destroy_split_data(pData->split_data);
675 msg_ui_thread_split_view_show(pData);
677 msg_ui_thread_split_view_hide(pData);
680 pListData->sel_gen_item = NULL;
681 pListData->sel_thread_id = 0;
682 pListData->sel_msg_id = 0;
683 pListData->view_mode = THREAD_NORMAL_VIEW;
685 msg_ui_thread_list_load(pListData, FALSE);
690 void msg_ui_thread_set_navi_toolbar_item(PMSG_THREAD_LIST_DATA pListData)
692 MSG_UI_ENTER(MSG_UI_LEVEL_DEBUG);
697 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
699 Evas_Object *btn = NULL;
700 Evas_Object *btn2 = NULL;
703 for (i = 0; i < CONTROLBAR_ITEM_MAX; i++) {
704 if (pListData->toolbar_btn[i])
705 evas_object_del(pListData->toolbar_btn[i]);
707 elm_object_item_part_content_unset(pListData->nf_it, "toolbar_button1");
708 elm_object_item_part_content_unset(pListData->nf_it, "toolbar_button2");
709 elm_object_item_part_content_unset(pListData->nf_it, "toolbar_more_btn");
711 if (pListData->search_mode == THREAD_SEARCH_ON)
714 if (!pListData->search_btn) {
715 pListData->search_btn = elm_button_add(pData->navi_frame);
716 elm_object_style_set(pListData->search_btn, "naviframe/title_icon");
718 Evas_Object *icon = elm_icon_add(pListData->search_btn);
719 elm_image_file_set(icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_SEARCH);
720 elm_image_resizable_set(icon, 1, 1);
721 evas_object_image_smooth_scale_set(icon, 0);
722 elm_object_content_set(pListData->search_btn, icon);
723 evas_object_smart_callback_add(pListData->search_btn, "clicked", msg_ui_thread_search_btn_clicked_cb, (void *)pListData);
726 if (pListData->view_mode == THREAD_EDIT_VIEW) {
727 btn = elm_button_add(pData->navi_frame);
728 elm_object_style_set(btn, "naviframe/toolbar/default");
729 elm_object_text_set(btn, dgettext("sys_string", "IDS_COM_SK_DELETE"));
730 evas_object_smart_callback_add(btn, "clicked", msg_ui_thread_ctlbar_multi_action_cb, pListData);
731 elm_object_item_part_content_set(pListData->nf_it, "toolbar_button1", btn);
732 pListData->toolbar_btn[CONTROLBAR_ITEM_1] = btn;
734 switch (pListData->list_type) {
735 case THREAD_SIM_LIST_TYPE:
736 case THREAD_SPAM_LIST_TYPE:
737 btn2 = elm_button_add(pData->navi_frame);
738 elm_object_style_set(btn, "naviframe/toolbar/left");
739 elm_object_style_set(btn2, "naviframe/toolbar/right");
740 evas_object_smart_callback_add(btn2, "clicked", msg_ui_thread_ctlbar_multi_action_cb, pListData);
741 elm_object_item_part_content_set(pListData->nf_it, "toolbar_button2", btn2);
743 pListData->toolbar_btn[CONTROLBAR_ITEM_2] = btn2;
745 if (pListData->list_type == THREAD_SIM_LIST_TYPE)
746 elm_object_text_set(btn2, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_COPY_TO_PHONE"));
747 else if (pListData->list_type == THREAD_SPAM_LIST_TYPE)
748 elm_object_text_set(btn2, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_SK_RESTORE"));
751 case THREAD_CBMSG_LIST_TYPE:
756 if (pListData->check_cnt <= 0) {
757 elm_object_disabled_set(btn, EINA_TRUE);
759 elm_object_disabled_set(btn2, EINA_TRUE);
762 evas_object_hide(pListData->search_btn);
763 elm_object_item_part_content_unset(pListData->nf_it, "title_right_btn");
765 btn = elm_button_add(pData->navi_frame);
766 elm_object_style_set(btn, "naviframe/toolbar/default");
767 elm_object_item_part_content_set(pListData->nf_it, "toolbar_button1", btn);
768 pListData->toolbar_btn[CONTROLBAR_ITEM_1] = btn;
770 switch (pListData->list_type) {
771 case THREAD_CBMSG_LIST_TYPE:
772 elm_object_text_set(btn, dgettext("sys_string", "IDS_COM_SK_DELETE"));
773 evas_object_smart_callback_add(btn, "clicked", msg_ui_thread_ctlbar_checkbox_cb, pListData);
775 if (pListData->item_cnt <= 0)
776 elm_object_disabled_set(btn, EINA_TRUE);
779 case THREAD_SIM_LIST_TYPE:
780 elm_object_text_set(btn, dgettext("sys_string", "IDS_COM_SK_EDIT"));
781 evas_object_smart_callback_add(btn, "clicked", msg_ui_thread_ctlbar_checkbox_cb, pListData);
783 if (pListData->item_cnt <= 0)
784 elm_object_disabled_set(btn, EINA_TRUE);
787 case THREAD_NORMAL_LIST_TYPE:
788 elm_object_text_set(btn, dgettext("sys_string", "IDS_COM_SK3_COMPOSE"));
789 evas_object_smart_callback_add(btn, "clicked", msg_ui_thread_ctlbar_compose_cb, pListData);
791 Evas_Object *btn3 = elm_button_add(pData->navi_frame);
792 elm_object_style_set(btn3, "naviframe/more/default");
793 evas_object_smart_callback_add(btn3, "clicked", msg_ui_thread_ctlbar_message_box_cb, pListData);
794 elm_object_item_part_content_set(pListData->nf_it, "toolbar_more_btn", btn3);
795 pListData->toolbar_btn[CONTROLBAR_ITEM_3] = btn3;
799 case THREAD_SPAM_LIST_TYPE:
800 elm_object_text_set(btn, dgettext("sys_string", "IDS_COM_SK_EDIT"));
801 evas_object_smart_callback_add(btn, "clicked", msg_ui_thread_ctlbar_checkbox_cb, pListData);
803 btn2 = elm_button_add(pData->navi_frame);
804 elm_object_style_set(btn, "naviframe/toolbar/left");
805 elm_object_style_set(btn2, "naviframe/toolbar/right");
806 elm_object_text_set(btn2, dgettext("sys_string", "IDS_COM_BODY_SETTINGS"));
807 evas_object_smart_callback_add(btn2, "clicked", msg_ui_thread_ctlbar_spam_setting_cb, pListData);
808 elm_object_item_part_content_set(pListData->nf_it, "toolbar_button2", btn2);
809 pListData->toolbar_btn[CONTROLBAR_ITEM_2] = btn2;
811 if (pListData->item_cnt <=0)
812 elm_object_disabled_set(btn, EINA_TRUE);
816 D_MSG("[ERROR] invalid viewmode");
820 Evas_Object *search_icon = elm_object_content_get(pListData->search_btn);
821 if (pListData->item_cnt > 0)
822 elm_image_file_set(search_icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_SEARCH);
824 elm_image_file_set(search_icon, MSG_IMAGES_EDJ, MSG_UI_THREAD_LIST_TITLE_ICON_SEARCH_DIM);
826 if (pListData->search_mode == THREAD_SEARCH_OFF && msg_ui_thread_rotation_get() == false) {
827 elm_object_item_part_content_set(pListData->nf_it, "title_right_btn", pListData->search_btn);
829 evas_object_hide(pListData->search_btn);
830 elm_object_item_part_content_unset(pListData->nf_it, "title_right_btn");
834 MSG_UI_LEAVE(MSG_UI_LEVEL_DEBUG);
837 void msg_ui_thread_show_toolbar(PMSG_THREAD_LIST_DATA pListData)
844 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
846 if (!pListData->back_btn) {
847 pListData->back_btn = elm_button_add(pData->navi_frame);
848 evas_object_smart_callback_add(pListData->back_btn, "clicked", msg_ui_thread_back_btn_clicked_cb, (void *)pListData);
849 elm_object_style_set(pListData->back_btn, "naviframe/back_btn/default");
850 elm_object_item_part_content_set(pListData->nf_it, "prev_btn", pListData->back_btn);
852 elm_object_item_part_content_set(pListData->nf_it, "prev_btn", pListData->back_btn);
854 msg_ui_thread_set_navi_toolbar_item(pListData);
855 elm_object_item_signal_emit(pListData->nf_it, "elm,state,toolbar,open", "");
860 void msg_ui_thread_hide_toolbar(PMSG_THREAD_LIST_DATA pListData, bool bDeleteBtn)
870 if (pListData->back_btn) {
871 evas_object_del(pListData->back_btn);
872 pListData->back_btn = NULL;
875 for (i = 0; i < CONTROLBAR_ITEM_MAX; i++) {
876 if (pListData->toolbar_btn[i]) {
877 evas_object_del(pListData->toolbar_btn[i]);
878 pListData->toolbar_btn[i] = NULL;
882 elm_object_item_part_content_unset(pListData->nf_it, "prev_btn");
883 elm_object_item_part_content_unset(pListData->nf_it, "toolbar_button1");
884 elm_object_item_part_content_unset(pListData->nf_it, "toolbar_button2");
885 elm_object_item_part_content_unset(pListData->nf_it, "toolbar_more_btn");
887 elm_object_item_signal_emit(pListData->nf_it, "elm,state,toolbar,close", "");
891 void msg_ui_thread_rotation_set(void *data, int rot)
893 PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)data;
898 if (pData->handlerIsPressed)
899 evas_event_feed_mouse_up(evas_object_evas_get(pData->panes), 1, EVAS_BUTTON_NONE, 0, NULL);
901 if (rot == THREAD_ROTATE_ANGLE_LANDSCAPE || rot == THREAD_ROTATE_ANGLE_LANDSCAPE_UPSIDEDOWN) {
902 pData->isRotate = true;
903 msg_ui_thread_split_view_show(pData);
905 pData->isRotate = false;
906 msg_ui_thread_split_view_hide(pData);
910 bool msg_ui_thread_rotation_get(void)
912 PMSG_THREAD_DATA pData = msg_ui_thread_get_data();
917 return pData->isRotate;
920 void msg_ui_thread_lang_changed(void *data)
922 PMSG_THREAD_DATA pData = (PMSG_THREAD_DATA)data;
923 PMSG_THREAD_LIST_DATA pListData = NULL;
929 for (i = 0; i < MSG_THREAD_LIST_MAX_COUNT; i++) {
930 if (pData->list_data[i] != NULL) {
931 char label[DEF_BUF_LEN_S+1] = {0,};
933 pListData = pData->list_data[i];
935 elm_genlist_realized_items_update(pListData->genlist);
936 elm_object_part_text_set(pListData->noc_ly, "elm.text", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_NOMESSAGES"));
937 elm_object_part_text_set(pListData->searchbar, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_SEARCH"));
939 if (pListData->popup) {
940 evas_object_del(pListData->popup);
941 pListData->popup = NULL;
944 msg_ui_thread_get_title_text(pListData, label, DEF_BUF_LEN_S);
945 elm_object_item_text_set(pListData->nf_it, label);
946 msg_ui_thread_set_navi_toolbar_item(pListData);
950 if (pData->split_data) {
951 char label[DEF_BUF_LEN_S+1] = {0,};
952 pListData = msg_ui_thread_get_current_list();
954 msg_ui_thread_get_title_text(pListData, label, DEF_BUF_LEN_S);
955 elm_object_part_text_set(pData->split_data->title_layout, "title_text", label);
956 elm_object_part_text_set(pData->split_data->noc_ly, "elm.text", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_NOMESSAGES"));
960 void msg_ui_thread_split_view_show(PMSG_THREAD_DATA pData)
964 PMSG_THREAD_LIST_DATA pListData = msg_ui_thread_get_current_list();
966 if (pListData && pListData->view_mode == THREAD_NORMAL_VIEW) {
967 elm_panes_content_left_size_set(pData->panes, 0.4);
968 elm_object_signal_emit(pData->panes, "elm,panes,pair", "");
971 if (pListData->item_cnt > 0) {
972 edje_object_signal_emit(_EDJ(pListData->content_ly), "show_searchbar", "sel_all");
973 evas_object_show(pListData->searchbar);
974 elm_object_part_content_set(pListData->content_ly, "sel_all", pListData->searchbar);
977 elm_naviframe_item_title_visible_set(pListData->nf_it, EINA_FALSE);
978 msg_ui_thread_hide_toolbar(pListData, true);
979 if (pListData->search_btn) {
980 evas_object_hide(pListData->search_btn);
981 elm_object_item_part_content_unset(pListData->nf_it, "title_right_btn");
984 elm_object_part_content_set(pData->panes, "left", pData->layout_main);
985 evas_object_show(pData->layout_main);
986 Evas_Object * layout = msg_ui_get_composer_ug_viewer_layout();
988 elm_object_part_content_set(pData->panes, "right", layout);
989 evas_object_show(layout);
990 if (pData->split_data)
991 msg_ui_thread_destroy_split_data(pData->split_data);
993 if (!pData->split_data) {
994 msg_ui_thread_create_split_data();
995 msg_ui_thread_splitview_launch(pData, pData->split_data);
998 if (pData->detail_layout) {
999 elm_object_item_del(elm_naviframe_top_item_get(pData->navi_frame));
1000 pData->detail_layout = NULL;
1001 if (pListData->sel_gen_item > 0)
1002 msg_ui_thread_launch_msg_detail_view(pListData, elm_object_item_data_get(pListData->sel_gen_item));
1009 void msg_ui_thread_split_view_hide(PMSG_THREAD_DATA pData)
1013 PMSG_THREAD_LIST_DATA pListData = msg_ui_thread_get_current_list();
1015 if (pListData && pListData->view_mode == THREAD_NORMAL_VIEW) {
1016 elm_object_part_content_set(pData->panes, "left", pData->layout_main);
1017 elm_panes_content_left_size_set(pData->panes, 1.0);
1018 if (pData->split_data) {
1019 elm_object_part_content_unset(pData->panes, "right");
1020 msg_ui_thread_destroy_split_data(pData->split_data);
1023 if (pListData->search_mode == THREAD_SEARCH_OFF) {
1024 edje_object_signal_emit(_EDJ(pListData->content_ly), "hide_searchbar", "sel_all");
1025 elm_object_part_content_unset(pListData->content_ly, "sel_all");
1026 evas_object_hide(pListData->searchbar);
1027 msg_ui_thread_show_toolbar(pListData);
1029 Evas_Object *entry = NULL;
1030 entry = elm_object_part_content_get(pListData->searchbar, "elm.swallow.content");
1031 if (entry && elm_object_focus_get(entry) == EINA_FALSE)
1032 msg_ui_thread_show_toolbar(pListData);
1035 elm_naviframe_item_title_visible_set(pListData->nf_it, EINA_TRUE);
1037 Evas_Object * layout = msg_ui_get_composer_ug_viewer_layout();
1039 elm_object_part_content_set(pData->panes, "right", layout);
1040 elm_panes_content_left_size_set(pData->panes, 0.0);
1041 evas_object_hide(pData->layout_main);
1042 } else if (pData->detail_layout) {
1043 pData->detail_layout = NULL;
1044 if (pListData->sel_gen_item > 0)
1045 msg_ui_thread_launch_msg_detail_view(pListData, elm_object_item_data_get(pListData->sel_gen_item));
1048 elm_object_signal_emit(pData->panes, "elm,panes,unpair", "");