new mail notification was removed after sending mail failed notification occurred 53/96553/1
authorSan Cho <san.cho@samsung.com>
Wed, 15 Jun 2016 01:55:13 +0000 (10:55 +0900)
committerintae, jeon <intae.jeon@samsung.com>
Wed, 9 Nov 2016 09:27:32 +0000 (18:27 +0900)
Change-Id: I8ca65c36ea87a906abd9721e835251371c120cc5
Signed-off-by: intae, jeon <intae.jeon@samsung.com>
email-core/email-core-account.c
email-core/email-core-utils.c
email-core/include/email-core-utils.h

index 74a164f..dac6d42 100755 (executable)
@@ -532,7 +532,7 @@ INTERNAL_FUNC int emcore_delete_account(char *multi_user_name, int account_id, i
        }
 
        emcore_display_unread_in_badge(multi_user_name);
-       emcore_delete_notification_by_account(multi_user_name, account_id, true, true);
+       emcore_delete_notification_by_account(multi_user_name, account_id, true, true, true);
 
        ret = true;
 
index ac10553..0d1bc43 100755 (executable)
@@ -1715,12 +1715,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int ac
        }
 
        /* Delete the previous noti */
-       emcore_delete_notification_by_account(multi_user_name, account_id, true, true);
-       if (g_sending_noti_handle) {
-               if ((noti_err = notification_free(g_sending_noti_handle)) != NOTIFICATION_ERROR_NONE)
-                       err = EMAIL_ERROR_NOTI;
-               g_sending_noti_handle = NULL;
-       }
+       emcore_delete_notification_by_account(multi_user_name, account_id, false, true, true);
 
        if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
@@ -1901,21 +1896,12 @@ INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int ac
                        goto FINISH_OFF;
                }
 
-               if ((noti_err = notification_insert(noti, &private_id)) != NOTIFICATION_ERROR_NONE) {
+               if ((noti_err = notification_insert(noti, NULL)) != NOTIFICATION_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
                        err = EMAIL_ERROR_NOTI;
                        goto FINISH_OFF;
                }
 
-               EM_DEBUG_LOG("Private_id = [%d]", private_id);
-
-               SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
-               if (vconf_set_int(vconf_private_id, private_id) != 0) {
-                       EM_DEBUG_EXCEPTION("vconf_set_int failed");
-                       err = EMAIL_ERROR_GCONF_FAILURE;
-                       goto FINISH_OFF;
-               }
-
                break;
 
        case EMAIL_ACTION_SENDING_MAIL:
@@ -1965,17 +1951,6 @@ INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int ac
                }
 
                g_sending_noti_handle = noti;
-#if 0
-               EM_DEBUG_LOG("Private_id = [%d]", private_id);
-
-               SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
-               if (vconf_set_int (vconf_private_id, private_id) != 0) {
-                       EM_DEBUG_EXCEPTION("vconf_set_int failed");
-                       err = EMAIL_ERROR_GCONF_FAILURE;
-                       goto FINISH_OFF;
-               }
-#endif
-
                break;
 
        default:
@@ -3346,12 +3321,12 @@ INTERNAL_FUNC int emcore_clear_notifications(char *multi_user_name, int account_
                }
 
                for(i = 0; i < account_count; i++) {
-                       error_code = emcore_delete_notification_by_account(multi_user_name, account_list[i].account_id, false, false);
+                       error_code = emcore_delete_notification_by_account(multi_user_name, account_list[i].account_id, true, false, false);
                        if (error_code != EMAIL_ERROR_NONE)
                                EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
                }
        } else {
-               error_code = emcore_delete_notification_by_account(multi_user_name, account_id, false, false);
+               error_code = emcore_delete_notification_by_account(multi_user_name, account_id, true, false, false);
                if (error_code != EMAIL_ERROR_NONE)
                        EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
        }
@@ -3372,10 +3347,10 @@ FINISH_OFF:
 }
 
 #define EAS_EXECUTABLE_PATH "/usr/bin/eas-engine"
-
-INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int with_noti_tray, int is_delete_sent_fail_noti)
+/* TODO this function will modify with bit flag */
+INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int is_delete_new_mail_noti, int is_delete_sending_noti, int is_delete_sent_fail_noti)
 {
-       EM_DEBUG_FUNC_BEGIN("account_id [%d], with_noti_tray [%d], is_delete_sent_fail_noti: [%d]", account_id, with_noti_tray, is_delete_sent_fail_noti);
+       EM_DEBUG_FUNC_BEGIN("account_id [%d], is_delete_new_mail_noti[%d], is_delete_sending_noti[%d], is_delete_sent_fail_noti: [%d]", account_id, is_delete_new_mail_noti, is_delete_sending_noti, is_delete_sent_fail_noti);
        int error_code = EMAIL_ERROR_NONE;
 
 #ifdef __FEATURE_NOTIFICATION_ENABLE__
@@ -3414,22 +3389,19 @@ INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, i
                EM_DEBUG_LOG("noti_type_str: [%s]", noti_type_str);
                // noti_type_str: NEW_MAIL_SINGLE, NEW_MAIL_MULTI, SENT, SENT_FAIL, SENDING
                if (account_id_str && (atoi(account_id_str) == account_id)) {
-                       if (!g_strcmp0(noti_type_str, __NOTI_NEW_MAIL_SINGLE) ||
+
+                       if (is_delete_new_mail_noti &&
+                    (!g_strcmp0(noti_type_str, __NOTI_NEW_MAIL_SINGLE) ||
                                        !g_strcmp0(noti_type_str, __NOTI_NEW_MAIL_MULTI) ||
-                                       !g_strcmp0(noti_type_str, __NOTI_SENT)) {
+                                       !g_strcmp0(noti_type_str, __NOTI_SENT))) {
                                // normal notification
                                noti_to_be_deleted = noti;
-                       } else if (with_noti_tray && !g_strcmp0(noti_type_str, __NOTI_SENDING)) {
+                       } else if (is_delete_sending_noti && !g_strcmp0(noti_type_str, __NOTI_SENDING)) {
                                // sending ongoing notification
                                noti_to_be_deleted = noti;
-                       } else if (!g_strcmp0(noti_type_str, __NOTI_SENT_FAIL)) {
-                               // sent failed notification
-                               if (is_delete_sent_fail_noti) {
-                                       noti_to_be_deleted = noti;
-                               } else {
-                                       const char *error_str = bundle_get_val(noti_args, "SENDING_ERROR");
-                                       EM_DEBUG_LOG("There is a notification for sending error, not clear this notification [%s].", error_str);
-                               }
+                               g_sending_noti_handle = NULL;
+                       } else if (is_delete_sent_fail_noti && !g_strcmp0(noti_type_str, __NOTI_SENT_FAIL)) {
+                               noti_to_be_deleted = noti;
                        }
                }
 
index ae4aa0e..c99190f 100755 (executable)
@@ -110,7 +110,7 @@ INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id,
 INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display);
 INTERNAL_FUNC void emcore_update_notification_for_send(int account_id, int mail_id, double progress);
 INTERNAL_FUNC int emcore_delete_notification_for_read_mail(int mail_id);
-INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int with_noti_tray, int is_delete_sent_fail_noti);
+INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int is_delete_new_mail_noti, int is_delete_sending_noti, int is_delete_sent_fail_noti);
 
 INTERNAL_FUNC int emcore_show_user_message(char *multi_user_name, int id, email_action_t action, int error);