Merge "svace issues" into tizen accepted/tizen/unified/20190218.064124 submit/tizen/20190216.153104
authorrandeep singh <randeep.s@samsung.com>
Sat, 16 Feb 2019 15:30:50 +0000 (15:30 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Sat, 16 Feb 2019 15:30:50 +0000 (15:30 +0000)
email-core/email-core-account.c
email-core/email-core-dpm.c
email-core/email-core-gmime.c
email-core/email-core-mail.c
email-core/email-core-smtp.c
email-core/email-storage/email-storage.c
email-daemon/email-daemon-event.c
test/testapp-mail.c

index 711d166..3432446 100755 (executable)
@@ -509,7 +509,8 @@ INTERNAL_FUNC int emcore_delete_account(char *multi_user_name, int account_id, i
 
 #ifdef __FEATURE_KEEP_CONNECTION__
        /* emcore_reset_streams(); */
-       emcore_remove_connection_info(account_id);
+       if (emcore_remove_connection_info(account_id) != EMAIL_ERROR_NONE)
+               EM_DEBUG_EXCEPTION("emcore_remove_connection_info failed \n");
 #endif
 
        if ((err = emcore_delete_all_mails_of_acount(multi_user_name, account_id)) != EMAIL_ERROR_NONE) {
@@ -532,7 +533,8 @@ 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, true);
+       if (emcore_delete_notification_by_account(multi_user_name, account_id, true, true, true) != EMAIL_ERROR_NONE)
+               EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed \n");
 
        ret = true;
 
index 27f2760..ad9684d 100644 (file)
@@ -1,86 +1,87 @@
-#include "email-core-mail.h"\r
-#include "email-internal-types.h"\r
-#include "email-types.h"\r
-#include "email-debug-log.h"\r
-#include "email-core-dpm.h"\r
-\r
-static int g_dpm_policy_status = 0;\r
-\r
-\r
-#include <dpm/restriction.h>\r
-\r
-\r
-void on_restriction(const char* policy, const char* value, void* user_data)\r
-{\r
-       int is_allowed = strcmp(value, "allowed") == 0 ? 1 : 0;\r
-       /* true = 1;\r
-          false = 0; */\r
-\r
-       EM_DEBUG_LOG("dpm_cb_status : %d",  is_allowed);\r
-       g_dpm_policy_status = is_allowed;\r
-}\r
-\r
-static int callback_id;\r
-static device_policy_manager_h dpm;\r
-\r
-void emcore_dpm_instance_create()\r
-{\r
-\r
-\r
-       #ifdef TIZEN_FEATURE_EMAIL_DPM\r
-\r
-       EM_DEBUG_LOG("dpm_instance_create");\r
-       dpm = dpm_manager_create();\r
-       int allowed;\r
-       void *user_data = NULL;\r
-       int ret = dpm_restriction_get_popimap_email_state(dpm, &allowed);\r
-       if (ret != DPM_ERROR_NONE) {\r
-               EM_DEBUG_LOG("dpm_error : %d", ret);\r
-               //TODO add error routin\r
-       }\r
-\r
-               EM_DEBUG_LOG("dpm_policy  : %d", allowed);\r
-       if (allowed == false) {\r
-\r
-               /* OPERATION IS RESTRICTED */\r
-               g_dpm_policy_status = false;\r
-\r
-       } else if (allowed == true) {\r
-\r
-               /* OPERATION IS ALLOWED */\r
-               g_dpm_policy_status = true;\r
-\r
-       } else {\r
-               EM_DEBUG_LOG("dpm wrong status : %d", allowed);\r
-\r
-               //TODO add error routin\r
-       }\r
-\r
-       // Callback will be called when policy is changed\r
-       dpm_add_policy_changed_cb(dpm , "popimap_email", on_restriction, user_data, &callback_id);\r
-\r
-       #else\r
-\r
-       EM_DEBUG_LOG("dpm_off");\r
-\r
-       #endif /* TIZEN_FEATURE_EMAIL_DPM */\r
-\r
-}\r
-int emcore_get_dpm_status()\r
-{\r
-\r
-       EM_DEBUG_LOG("get_dpm_status()");\r
-       #ifdef TIZEN_FEATURE_EMAIL_DPM\r
-               return g_dpm_policy_status;\r
-       #else\r
-               return true;\r
-       #endif /* TIZEN_FEATURE_EMAIL_DPM */\r
-\r
-}\r
-\r
-void dpm_interface_destroy()\r
-{\r
-       dpm_remove_policy_changed_cb(dpm, callback_id);\r
-       dpm_manager_destroy(dpm);\r
-}\r
-\r
+#include "email-core-mail.h"
+#include "email-internal-types.h"
+#include "email-types.h"
+#include "email-debug-log.h"
+#include "email-core-dpm.h"
+
+static int g_dpm_policy_status = 0;
+
+
+#include <dpm/restriction.h>
+
+
+void on_restriction(const char* policy, const char* value, void* user_data)
+{
+       int is_allowed = strcmp(value, "allowed") == 0 ? 1 : 0;
+       /* true = 1;
+          false = 0; */
+
+       EM_DEBUG_LOG("dpm_cb_status : %d",  is_allowed);
+       g_dpm_policy_status = is_allowed;
+}
+
+static int callback_id;
+static device_policy_manager_h dpm;
+
+void emcore_dpm_instance_create()
+{
+
+
+       #ifdef TIZEN_FEATURE_EMAIL_DPM
+
+       EM_DEBUG_LOG("dpm_instance_create");
+       dpm = dpm_manager_create();
+       int allowed;
+       void *user_data = NULL;
+       int ret = dpm_restriction_get_popimap_email_state(dpm, &allowed);
+       if (ret != DPM_ERROR_NONE) {
+               EM_DEBUG_LOG("dpm_error : %d", ret);
+               //TODO add error routin
+       }
+
+               EM_DEBUG_LOG("dpm_policy  : %d", allowed);
+       if (allowed == false) {
+
+               /* OPERATION IS RESTRICTED */
+               g_dpm_policy_status = false;
+
+       } else if (allowed == true) {
+
+               /* OPERATION IS ALLOWED */
+               g_dpm_policy_status = true;
+
+       } else {
+               EM_DEBUG_LOG("dpm wrong status : %d", allowed);
+
+               //TODO add error routin
+       }
+
+       // Callback will be called when policy is changed
+       if (dpm_add_policy_changed_cb(dpm , "popimap_email", on_restriction, user_data, &callback_id) != 0)
+               EM_DEBUG_LOG("dpm_add_policy_changed_cb failed /n");
+
+       #else
+
+       EM_DEBUG_LOG("dpm_off");
+
+       #endif /* TIZEN_FEATURE_EMAIL_DPM */
+
+}
+int emcore_get_dpm_status()
+{
+
+       EM_DEBUG_LOG("get_dpm_status()");
+       #ifdef TIZEN_FEATURE_EMAIL_DPM
+               return g_dpm_policy_status;
+       #else
+               return true;
+       #endif /* TIZEN_FEATURE_EMAIL_DPM */
+
+}
+
+void dpm_interface_destroy()
+{
+       dpm_remove_policy_changed_cb(dpm, callback_id);
+       dpm_manager_destroy(dpm);
+}
+
index caa8b60..9c331a6 100755 (executable)
@@ -4300,7 +4300,10 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                if (disposition_header) g_object_unref(disposition_header);
                        }
 
-                       if (buf) g_remove(buf);
+                       if (buf) {
+                               if (g_remove(buf) != 0)
+                                       EM_DEBUG_LOG_DEV("Fail to Remove buffer \n");
+                       }
                        EM_SAFE_FREE(buf);
                } else if ((tag_position = g_strrstr(response, tag))) /*  end of response */ {
                        if (!strncmp(tag_position + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
index 1e67e69..9b00f85 100755 (executable)
@@ -2271,10 +2271,12 @@ FINISH_OFF:
 
        if (!auto_download) {
                if (ret == TRUE)
-                       emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FINISH, mail_id, NULL, nth, 0);
+                       if (emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FINISH, mail_id, NULL, nth, 0) != 1)
+                               EM_DEBUG_LOG(">>>>>>emcore_notify_network_event failed \n ");
                else {
                        if (err != EMAIL_ERROR_CANCELLED)
-                               emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, nth, err);
+                               if (emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, nth, err) != 1)
+                                       EM_DEBUG_LOG(">>>>>>emcore_notify_network_event failed \n ");
                }
        }
 
@@ -3335,9 +3337,11 @@ FINISH_OFF:
 
        if (!auto_download) {
                if (ret == TRUE)
-                       emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FINISH, mail_id, NULL, event_handle, 0);
+                       if (emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FINISH, mail_id, NULL, event_handle, 0) != 0)
+                               EM_DEBUG_LOG(">>>>> emcore_notify_network_event failed \n ");
                else
-                       emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, event_handle, err);
+                       if (emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, event_handle, err) != 0)
+                               EM_DEBUG_LOG(">>>>> emcore_notify_network_event failed \n ");
        }
 
        if (err_code != NULL)
index 321ba17..97d86be 100755 (executable)
@@ -425,8 +425,10 @@ FINISH_OFF: /* prevent 34226 */
        EM_SAFE_FREE(body->sparep);
        EM_SAFE_CLOSE(fd); /*prevent 34498*/
        EM_SAFE_FREE(p);
-       if (tmp_file_path)
-               g_remove(tmp_file_path);
+       if (tmp_file_path) {
+               if (g_remove(tmp_file_path) != 0)
+                       EM_DEBUG_EXCEPTION(" Fail to remove tmp_file_path \n");
+       }
        EM_SAFE_FREE(tmp_file_path);
        if (fp_html)
                fclose(fp_html);
@@ -673,7 +675,8 @@ FINISH_OFF:
                if (!file_exist)
                        *data = EM_SAFE_STRDUP(fname);
        } else if (fname != NULL) {
-               remove(fname);
+               if (remove(fname) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to remove fname \n");
        }
 
        EM_SAFE_FREE(fname);
index 4e5a764..83b4e80 100755 (executable)
@@ -1609,10 +1609,14 @@ static void *_emstorage_open_once(char *multi_user_name, int *err_code)
                _delete_temp_file(buf);
                EM_SAFE_FREE(prefix_path);
        } else {
-               mkdir(DATA_PATH, DIRECTORY_PERMISSION);
-               mkdir(EMAIL_PATH, DIRECTORY_PERMISSION);
-               mkdir(MAIL_HOME, DIRECTORY_PERMISSION);
-               mkdir(MAIL_TEMP, DIRECTORY_PERMISSION);
+               if (mkdir(DATA_PATH, DIRECTORY_PERMISSION) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+               if (mkdir(EMAIL_PATH, DIRECTORY_PERMISSION) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+               if (mkdir(MAIL_HOME, DIRECTORY_PERMISSION) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+               if (mkdir(MAIL_TEMP, DIRECTORY_PERMISSION) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to create the directory \n");
 
                _delete_temp_file(MAIL_TEMP);
        }
@@ -1838,9 +1842,12 @@ INTERNAL_FUNC int emstorage_init_db(char *multi_user_name)
                        email_uid = UID_DEFAULT;
 
 
-               chmod(EMAIL_SERVICE_DB_FILE_PATH, 0660);
-               chmod(EMAIL_SERVICE_DB_JOURNAL_FILE_PATH, 0660);
-               chmod(EMAIL_SQL_PATH, 0660);
+               if (chmod(EMAIL_SERVICE_DB_FILE_PATH, 0660) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to change the permission \n");
+               if (chmod(EMAIL_SERVICE_DB_JOURNAL_FILE_PATH, 0660) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to change the permission \n");
+               if (chmod(EMAIL_SQL_PATH, 0660) != 0)
+                       EM_DEBUG_EXCEPTION("Fail to change the permission \n");
 
                ret = chown(EMAIL_SERVICE_DB_FILE_PATH, email_uid, email_gid);
                if (0 != ret)
@@ -11522,9 +11529,12 @@ INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transacti
                goto FINISH_OFF;
        }
 
-       mkdir(MAIL_HOME, DIRECTORY_PERMISSION);
-       mkdir(MAIL_TEMP, DIRECTORY_PERMISSION);
-       chmod(MAIL_TEMP, 0777);
+       if (mkdir(MAIL_HOME, DIRECTORY_PERMISSION) != 0)
+               EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+       if (mkdir(MAIL_TEMP, DIRECTORY_PERMISSION) != 0)
+               EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+       if (chmod(MAIL_TEMP, 0777) != 0)
+               EM_DEBUG_EXCEPTION("Fail to change the permission \n");
 
        /*  first clear index. */
        while (indexes->object_name) {
@@ -11860,7 +11870,8 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
                        }
 
                        if (account_id == EML_FOLDER)
-                               chmod(buf, 0777);
+                               if (chmod(buf, 0777) != 0)
+                                       EM_DEBUG_EXCEPTION("Fail to change the permission \n");
                }
        }
 
@@ -11978,11 +11989,16 @@ INTERNAL_FUNC void emstorage_create_dir_if_delete()
 {
        EM_DEBUG_FUNC_BEGIN();
 
-       mkdir(DATA_PATH, DIRECTORY_PERMISSION);
-       mkdir(EMAIL_PATH, DIRECTORY_PERMISSION);
-       mkdir(MAIL_HOME, DIRECTORY_PERMISSION);
-       mkdir(MAIL_TEMP, DIRECTORY_PERMISSION);
-       chmod(MAIL_TEMP, 0777);
+       if (mkdir(DATA_PATH, DIRECTORY_PERMISSION) != 0)
+               EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+       if (mkdir(EMAIL_PATH, DIRECTORY_PERMISSION) != 0)
+               EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+       if (mkdir(MAIL_HOME, DIRECTORY_PERMISSION) != 0)
+               EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+       if (mkdir(MAIL_TEMP, DIRECTORY_PERMISSION) != 0)
+               EM_DEBUG_EXCEPTION("Fail to create the directory \n");
+       if (chmod(MAIL_TEMP, 0777) != 0)
+               EM_DEBUG_EXCEPTION("Fail to change the permission \n");
 
        EM_DEBUG_FUNC_END();
 }
index e8b190d..a7d9e70 100644 (file)
@@ -1369,8 +1369,8 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(char *multi_user_name, int ac
                        if (mail)
                                emstorage_free_mail(&mail, 1, NULL);
 
-                       emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, handle_to_be_published, err);
-
+                       if (emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, handle_to_be_published, err) != 0)
+                               EM_DEBUG_EXCEPTION(">>>>> emcore_notify_network_event failed \n ");
                        goto FINISH_OFF;
                }
 
@@ -1447,7 +1447,8 @@ static int event_handler_EMAIL_EVENT_SYNC_FLAGS_FIELD_TO_SERVER(char *multi_user
        /* So in event update again the DB field */
        if (err != EMAIL_ERROR_NONE) {
                /* If the emcore_sync_flags_field_with_server is failed, rollback the db */
-               emcore_set_flags_field(multi_user_name, account_id, mail_ids, num, field_type, value ? 0 : 1, NULL);
+               if (emcore_set_flags_field(multi_user_name, account_id, mail_ids, num, field_type, value ? 0 : 1, NULL) != 0)
+                       EM_DEBUG_EXCEPTION("emcore_set_flags_field failed \n");
        }
        if (error)
                *error = err;
index 8bb2b8f..3c2e084 100644 (file)
@@ -226,7 +226,8 @@ static gboolean testapp_test_add_mail(int *result_mail_id)
        if (0 >= scanf("%d", &mailbox_id))
                testapp_print("Invalid input. ");
 
-       email_get_mailbox_by_mailbox_id(mailbox_id, &mailbox_data);
+       if (email_get_mailbox_by_mailbox_id(mailbox_id, &mailbox_data) != EMAIL_ERROR_NONE)
+               testapp_print("email_get_mailbox_by_mailbox_id failed ");
 
        test_mail_data = malloc(sizeof(email_mail_data_t));
        memset(test_mail_data, 0x00, sizeof(email_mail_data_t));
@@ -368,7 +369,8 @@ static gboolean testapp_test_update_mail()
        if (0 >= scanf("%d", &mail_id))
                testapp_print("Invalid input. ");
 
-       email_get_mail_data(mail_id, &test_mail_data);
+       if (email_get_mail_data(mail_id, &test_mail_data) != EMAIL_ERROR_NONE)
+               testapp_print("email_get_mail_data Failed \n ");
 
        if (!test_mail_data) {
                testapp_print("email_get_mail_data() failed\n");
@@ -543,7 +545,8 @@ static gboolean testapp_test_mail_send(int *result_mail_id)
        testapp_add_mail_for_sending(&added_mail_id);
 
        if (added_mail_id) {
-               email_get_mail_data(added_mail_id, &result_mail_data);
+               if (email_get_mail_data(added_mail_id, &result_mail_data) != EMAIL_ERROR_NONE)
+                       testapp_print("email_get_mail_data Failed \n ");
 
                testapp_print("Calling email_send_mail...\n");