#include <regex.h>
#include <pthread.h>
#include <notification.h>
-#include <notification_type.h>
#include <notification_internal.h>
#include <notification_text_domain.h>
#include <badge.h>
#endif /* __FEATURE_USE_DRM_API__ */
#include <storage.h>
#include <bundle.h>
+#include <bundle_internal.h>
#include <curl/curl.h>
#include <contacts.h>
#include <contacts_internal.h>
app_control_add_extra_data(service, "MAIL_ID", buf);
snprintf(buf, sizeof(buf), "%d", p_mail_data->mailbox_id);
app_control_add_extra_data(service, "MAILBOX_ID", buf);
+ snprintf(buf, sizeof(buf), "%s", __NOTI_NEW_MAIL_SINGLE);
+ app_control_add_extra_data(service, "NOTI_TYPE", buf);
app_control_set_app_id(service, NATIVE_EMAIL_APPLICATION_PKG);
app_control_to_bundle(service, &b);
app_control_add_extra_data(service, "RUN_TYPE", buf);
snprintf(buf, sizeof(buf), "%d", account_id);
app_control_add_extra_data(service, "ACCOUNT_ID", buf);
+ snprintf(buf, sizeof(buf), "%s", __NOTI_NEW_MAIL_MULTI);
+ app_control_add_extra_data(service, "NOTI_TYPE", buf);
if (unseen > EMAIL_NOTI_MAX_MAIL_ID)
unseen = EMAIL_NOTI_MAX_MAIL_ID;
}
/* Delete the previous noti */
- emcore_delete_notification_by_account(multi_user_name, account_id, true);
+ 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;
app_control_add_extra_data(service, "MAIL_ID", buf);
snprintf(buf, sizeof(buf), "%d", p_mail_data->mailbox_id);
app_control_add_extra_data(service, "MAILBOX_ID", buf);
+ snprintf(buf, sizeof(buf), "%d", sending_error);
+ app_control_add_extra_data(service, "SENDING_ERROR", buf);
+ if (sending_error == EMAIL_ERROR_NONE) {
+ if (action == EMAIL_ACTION_SEND_MAIL)
+ snprintf(buf, sizeof(buf), "%s", __NOTI_SENT);
+ else if (action == EMAIL_ACTION_SENDING_MAIL)
+ snprintf(buf, sizeof(buf), "%s", __NOTI_SENDING);
+ } else {
+ snprintf(buf, sizeof(buf), "%s", __NOTI_SENT_FAIL);
+ }
+ app_control_add_extra_data(service, "NOTI_TYPE", buf);
app_control_set_app_id(service, NATIVE_EMAIL_APPLICATION_PKG);
app_control_to_bundle(service, &b);
goto FINISH_OFF;
}
- for (i = 0; i < account_count; i++) {
- error_code = emcore_delete_notification_by_account(multi_user_name, account_list[i].account_id, true);
+ for(i = 0; i < account_count; i++) {
+ error_code = emcore_delete_notification_by_account(multi_user_name, account_list[i].account_id, true, 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, true);
+ error_code = emcore_delete_notification_by_account(multi_user_name, account_id, true, false);
if (error_code != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
}
#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)
+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)
{
- EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id);
+ 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);
int error_code = EMAIL_ERROR_NONE;
- int private_id = 0;
- char vconf_private_id[MAX_PATH] = {0, };
- SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
- if (vconf_get_int(vconf_private_id, &private_id) != 0) {
- EM_DEBUG_EXCEPTION("vconf_get_int failed");
- }
#ifdef __FEATURE_NOTIFICATION_ENABLE__
notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
+ notification_h noti = NULL;
+ notification_h noti_to_be_deleted = NULL;
+ notification_list_h noti_list = NULL;
+ notification_list_h head_noti_list = NULL;
+ bundle *noti_args = NULL;
- if ((noti_err = notification_delete_by_priv_id(NATIVE_EMAIL_APPLICATION_PKG, NOTIFICATION_TYPE_NOTI, private_id)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_delete_by_priv_id failed [%d]", noti_err);
+ noti_err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, ¬i_list);
+ if (noti_err != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_get_list failed: [%d]", noti_err);
error_code = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
}
- if (with_noti_tray) {
- if ((noti_err = notification_delete_by_priv_id(NATIVE_EMAIL_APPLICATION_PKG, NOTIFICATION_TYPE_ONGOING, private_id)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_delete_by_priv_id failed [%d]", noti_err);
- error_code = EMAIL_ERROR_NOTI;
+ while (noti_list != NULL) {
+ noti = notification_list_get_data(noti_list);
+ noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, ¬i_args);
+ if (!noti_args) {
+ noti_err = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_MULTI_LAUNCH, NULL, ¬i_args);
+ if (!noti_args) {
+ noti_list = notification_list_get_next(noti_list);
+ continue;
+ }
+ }
+
+ const char *account_id_str = bundle_get_val(noti_args, "ACCOUNT_ID");
+ const char *noti_type_str = bundle_get_val(noti_args, "NOTI_TYPE");
+ if (!account_id_str || !noti_type_str) {
+ noti_list = notification_list_get_next(noti_list);
+ continue;
+ }
+ EM_DEBUG_LOG("account_id_str: [%s]", account_id_str);
+ 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) ||
+ !g_strcmp0(noti_type_str, __NOTI_NEW_MAIL_MULTI) ||
+ !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)) {
+ // 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);
+ }
+ }
+ }
+
+ if (noti_to_be_deleted) {
+ noti_list = notification_list_remove(noti_list, noti_to_be_deleted);
+ notification_delete(noti_to_be_deleted);
+ noti_to_be_deleted = NULL;
+ // maintain head pointer for free
+ head_noti_list = notification_list_get_head(head_noti_list);
+ } else {
+ // maintain head pointer for free
+ head_noti_list = notification_list_get_head(head_noti_list);
+ noti_list = notification_list_get_next(noti_list);
}
+ noti_args = NULL;
}
+
+FINISH_OFF:
+ if (head_noti_list)
+ notification_free_list(head_noti_list);
#endif /* __FEATURE_NOTIFICATION_ENABLE__ */
EM_DEBUG_FUNC_END();
return error_code;