fix TDIS-1849 issue : Protected message delete scenario
authorLee jaeyoung <jy4710.lee@samsung.com>
Thu, 7 Feb 2013 07:03:13 +0000 (16:03 +0900)
committerLee jaeyoung <jy4710.lee@samsung.com>
Thu, 7 Feb 2013 07:03:13 +0000 (16:03 +0900)
composer/src/bubble/msg-ui-composer-bubble-callback.c
composer/src/bubble/msg-ui-composer-bubble-list.c
composer/src/bubble/msg-ui-composer-bubble-util.c

index 657a0de..181e82a 100755 (executable)
@@ -197,16 +197,12 @@ static void _del_thread_feedback_fn(void *data, Ecore_Thread *thread, void *msg_
        MSG_UI_RET_IF(MSG_UI_LEVEL_ERR, !thread || !data || !msg_data);
 
        PMSG_BUBBLE_DATA pData = (PMSG_BUBBLE_DATA)data;
-       char buf[DEF_BUF_LEN_S] = {0,};
        int *ret = msg_data;
 
        D_MSG("Delete message return value =[%d]", *ret);
        if (*ret == MSG_SUCCESS) {
-               if (pData->progressbar) {
-                       snprintf(buf, sizeof(buf), "%d/%d %s", pData->del_index + 1, pData->check_cnt, dgettext("sys_string", "IDS_COM_POP_DELETED"));
-                       elm_object_text_set(pData->progresslabel, buf);
+               if (pData->progressbar)
                        elm_progressbar_value_set(pData->progressbar, (double) (pData->del_index + 1) / pData->check_cnt);
-               }
        } else if (*ret == BUBBLE_RETURN_DELETE_CANCEL) {
                if (pData->del_cancel == true) {
                        _delete_finish(pData);
@@ -283,7 +279,7 @@ static void _del_all_item(PMSG_BUBBLE_DATA pData)
 
        msg_error_t err = MSG_SUCCESS;
 
-       err = msg_delete_thread_message_list(pData->msgHandle, pData->threadId, false);
+       err = msg_delete_thread_message_list(pData->msgHandle, pData->threadId, true);
 
        if (err == MSG_SUCCESS) {
                pData->bubble_count = 0;
@@ -1227,6 +1223,112 @@ void msg_ui_bubble_ctlbar_unblock_cb(void *data, Evas_Object *obj, void *event_i
        msg_ui_bubble_close_title_menu_genlist(pData);
 }
 
+static void __msg_ui_bubble_popup_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       PMSG_BUBBLE_DATA pData = (PMSG_BUBBLE_DATA)data;
+       MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)pData->callback_data;
+       Evas_Object *check = NULL;
+       Eina_Bool include_protected = EINA_FALSE;
+       PMSG_APP_CONV_DATA_S item_data = NULL;
+
+       if (pData->popup) {
+               if (obj == elm_object_part_content_get(pData->popup, "button1")) {
+                       // delete
+                       check = (Evas_Object *)evas_object_data_get(pData->popup, "check");
+                       if (check)
+                               include_protected = elm_check_state_get(check);
+
+                       bool isDraft = msg_ui_composer_common_is_send_possible(cd);
+
+                       if (pData->sel_all_checked && isDraft == false && (!check || include_protected == EINA_TRUE)) {
+                               pData->bubble_count = 0;
+                               _del_all_item(pData);
+                       } else {
+                               if (!include_protected) {
+                                       int i = pData->check_cnt;
+                                       for (; i > 0; i--) {
+                                               item_data = eina_list_nth(pData->chk_list, i-1);
+                                               if (item_data && item_data->bProtected) {
+                                                       pData->chk_list = eina_list_remove(pData->chk_list, item_data);
+                                                       pData->check_cnt--;
+                                               }
+                                       }
+                               }
+                               evas_object_del(pData->popup);
+                               pData->popup = NULL;
+
+                               pData->popup = msg_ui_bubble_show_notify_with_progressbar(pData, pData->check_cnt);
+                               pData->del_thread = ecore_thread_feedback_run(_del_thread_fn, _del_thread_feedback_fn, NULL, NULL, (void *)pData, EINA_TRUE);
+                       }
+               } else {
+                       evas_object_del(pData->popup);
+                       pData->popup = NULL;
+               }
+       }
+}
+
+
+static Evas_Object *__msg_ui_bubble_delete_confirm_popup(PMSG_BUBBLE_DATA pData)
+{
+       D_ENTER;
+       MSG_COMPOSER_VIEW_DATA_S *cd = (MSG_COMPOSER_VIEW_DATA_S *)pData->callback_data;
+
+       Evas_Object *popup = NULL;
+       Evas_Object *layout = NULL;
+       Evas_Object *check = NULL;
+       Evas_Object *ok_btn = NULL;
+       Evas_Object *cancel_btn = NULL;
+       Eina_List *l = NULL;
+       bool is_protected_msg = false;
+       PMSG_APP_CONV_DATA_S item_data = NULL;
+
+       popup = elm_popup_add(cd->main_window);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       elm_object_part_text_set(popup, "title,text", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_DELETE_Q"));
+
+       layout = elm_layout_add(popup);
+       elm_layout_file_set(layout, MSG_COMMON_EDJ, "popup_with_checkbox");
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
+
+       EINA_LIST_FOREACH(pData->chk_list, l, item_data) {
+               if (item_data && item_data->bProtected) {
+                       is_protected_msg = true;
+                       break;
+               }
+       }
+       if (is_protected_msg) {
+               check = elm_check_add(popup);
+               evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+               elm_object_part_content_set(layout, "elm.swallow.check", check);
+               evas_object_show(check);
+
+               elm_object_part_text_set(layout, "elm.text", dgettext(MESSAGE_PKGNAME, "IDS_MSGF_POP_INCLUDE_PROTECTED_MESSAGE"));
+               evas_object_data_set(popup, "check", check);
+       }
+
+       evas_object_show(layout);
+       elm_object_content_set(popup, layout);
+
+       ok_btn = elm_button_add(popup);
+       elm_object_style_set(ok_btn, "popup_button/default");
+       elm_object_text_set(ok_btn, dgettext("sys_string", "IDS_COM_SK_DELETE"));
+       elm_object_part_content_set(popup, "button1", ok_btn);
+       evas_object_smart_callback_add(ok_btn, "clicked", __msg_ui_bubble_popup_button_clicked_cb, pData);
+
+       cancel_btn = elm_button_add(popup);
+       elm_object_style_set(cancel_btn, "popup_button/default");
+       elm_object_text_set(cancel_btn, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
+       elm_object_part_content_set(popup, "button2", cancel_btn);
+       evas_object_smart_callback_add(cancel_btn, "clicked", __msg_ui_bubble_popup_button_clicked_cb, pData);
+
+       evas_object_show(popup);
+
+       return popup;
+}
+
+
 void msg_ui_bubble_ctlbar_delete_cb(void *data, Evas_Object *obj, void *event_info)
 {
        D_ENTER;
@@ -1241,16 +1343,7 @@ void msg_ui_bubble_ctlbar_delete_cb(void *data, Evas_Object *obj, void *event_in
                pData->popup = NULL;
        }
 
-       bool isDraft = msg_ui_composer_common_is_send_possible(cd);
-
-       if (pData->sel_all_checked && isDraft == false) {
-               pData->bubble_count = 0;
-               _del_all_item(pData);
-       } else {
-               pData->popup = msg_ui_bubble_show_notify_with_progressbar(pData, pData->check_cnt);
-               pData->del_thread = ecore_thread_feedback_run(_del_thread_fn, _del_thread_feedback_fn, NULL, NULL, (void *)pData, EINA_TRUE);
-       }
-
+       pData->popup = __msg_ui_bubble_delete_confirm_popup(pData);
 }
 
 void msg_ui_bubble_ctlbar_cancel_cb(void *data, Evas_Object *obj, void *event_info)
index a4bfba8..80bb82a 100755 (executable)
@@ -631,7 +631,7 @@ static void __msg_delete_ok_clicked_cb(void *data, Evas_Object *obj, void *event
 
        if (bubble_data->bubble_count == 1 && isDraft == false) {
                bubble_data->bubble_count = 0;
-               err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId, false);
+               err = msg_delete_thread_message_list(bubble_data->msgHandle, bubble_data->threadId, true);
        } else {
                msg_id = conv_data->msgId;
                err = msg_delete_message(bubble_data->msgHandle, msg_id);
@@ -669,7 +669,11 @@ static void __msg_delete_clicked_cb(void *data, Evas_Object *obj, void *event_in
 
        Evas_Object *popup = elm_popup_add(cd->main_window);
        evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_object_text_set(popup, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_DELETE_Q"));
+
+       if (conv_data->bProtected)
+               elm_object_text_set(popup, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_BODY_DELETE_THIS_PROTECTED_MESSAGE_Q"));
+       else
+               elm_object_text_set(popup, dgettext(MESSAGE_PKGNAME, "IDS_MSGF_OPT_DELETE_Q"));
 
        Evas_Object *btn_ok = elm_button_add(popup);
        elm_object_style_set(btn_ok, "popup_button/default");
index ebe4817..8b82b2d 100755 (executable)
@@ -177,7 +177,7 @@ Evas_Object* msg_ui_bubble_show_notify_with_progressbar(PMSG_BUBBLE_DATA pData,
        popup = elm_popup_add(cd->main_window);
 
        label = elm_label_add(popup);
-       snprintf(buf, sizeof(buf), "0/%d %s", count, dgettext("sys_string", "IDS_COM_POP_DELETED"));
+       snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_POP_DELETING"));
        elm_object_text_set(label, buf);
        evas_object_show(label);
 
@@ -253,7 +253,7 @@ void msg_ui_bubble_show_deleted_info(PMSG_BUBBLE_DATA pData)
                pData->select_info = NULL;
        }
 
-       status_message_post(dgettext("sys_string", "IDS_COM_POP_DELETED"));
+       msg_ui_bubble_status_message_post(pData, dgettext("sys_string", "IDS_COM_POP_DELETED"));
 
        bool isDraft = msg_ui_composer_common_is_send_possible((MSG_COMPOSER_VIEW_DATA_S *)pData->callback_data);