Fixed the coding rule 00/53900/1
authorSunghyun Kwon <sh0701.kwon@samsung.com>
Thu, 10 Dec 2015 06:00:10 +0000 (15:00 +0900)
committerSunghyun Kwon <sh0701.kwon@samsung.com>
Thu, 10 Dec 2015 06:00:10 +0000 (15:00 +0900)
Change-Id: Iea47f36f60b6f0471b09fc44aa9fc6a17aeeeedb

59 files changed:
email-api/email-api-account.c
email-api/email-api-etc.c
email-api/email-api-init.c
email-api/email-api-mail.c
email-api/email-api-mailbox.c
email-api/email-api-network.c
email-api/email-api-rule.c
email-api/email-api-smime.c
email-common-use/email-convert.c
email-common-use/email-utilities.c
email-common-use/tpl.c
email-core/email-core-account.c
email-core/email-core-alarm.c
email-core/email-core-auto-download.c
email-core/email-core-cynara.c
email-core/email-core-event.c
email-core/email-core-global.c
email-core/email-core-gmime.c
email-core/email-core-imap-idle.c
email-core/email-core-imap-mailbox.c
email-core/email-core-key-manager.c
email-core/email-core-mail.c
email-core/email-core-mailbox-sync.c
email-core/email-core-mailbox.c
email-core/email-core-mime.c
email-core/email-core-mm-callbacks.c
email-core/email-core-pgp.c
email-core/email-core-signal.c
email-core/email-core-smime.c
email-core/email-core-smtp.c
email-core/email-core-task-manager.c
email-core/email-core-tasks.c
email-core/email-core-timer.c
email-core/email-core-utils.c
email-core/email-device/email-device.c
email-core/email-network/email-network.c
email-core/email-storage/email-storage.c
email-daemon/email-daemon-account.c
email-daemon/email-daemon-auto-poll.c
email-daemon/email-daemon-emn.c
email-daemon/email-daemon-etc.c
email-daemon/email-daemon-event.c
email-daemon/email-daemon-init.c
email-daemon/email-daemon-mail.c
email-daemon/email-daemon-mailbox.c
email-daemon/main.c
email-ipc/email-activation/email-dbus-activation.c
email-ipc/email-ipc-api.c
email-ipc/email-ipc-api/email-ipc-api-info.c
email-ipc/email-ipc-api/email-ipc-param-list.c
email-ipc/email-ipc-proxy.c
email-ipc/email-ipc-stub.c
email-ipc/email-proxy/email-proxy-main.c
email-ipc/email-proxy/email-proxy-socket.c
email-ipc/email-socket/email-ipc-socket.c
email-ipc/email-stub/email-stub-main.c
email-ipc/email-stub/email-stub-socket.c
email-ipc/email-stub/email-stub-task-manager.c
email-ipc/email-stub/email-stub-task.c

index 648e17f..1c63a46 100755 (executable)
@@ -43,7 +43,7 @@
 /* API - Adds the Email Account */
 EXPORT_API int email_add_account(email_account_t* account)
 {
-       EM_DEBUG_API_BEGIN ("account[%p]", account);
+       EM_DEBUG_API_BEGIN("account[%p]", account);
        int size = 0;
        int err = EMAIL_ERROR_NONE;
        int ret_from_ipc = EMAIL_ERROR_NONE;
@@ -51,8 +51,8 @@ EXPORT_API int email_add_account(email_account_t* account)
        char* local_account_stream = NULL;
        HIPC_API hAPI = NULL;
 
-       if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
-               account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL)  {
+       if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL ||
+               account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -105,8 +105,7 @@ EXPORT_API int email_add_account(email_account_t* account)
 
        if (err == EMAIL_ERROR_NONE) {
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &account->account_id);
-       }
-       else {  /*  get error code */
+       } else {        /*  get error code */
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
        }
 
@@ -117,14 +116,13 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
-
 EXPORT_API int email_free_account(email_account_t** account_list, int count)
 {
-       EM_DEBUG_FUNC_BEGIN ("account_list[%p] count[%d]", account_list, count); /* use only debugging */
+       EM_DEBUG_FUNC_BEGIN("account_list[%p] count[%d]", account_list, count); /* use only debugging */
 
        /*  default variable */
        int err = EMAIL_ERROR_NONE;
@@ -161,7 +159,7 @@ EXPORT_API int email_free_account(email_account_t** account_list, int count)
        }
 
 FINISH_OFF:
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
@@ -169,7 +167,7 @@ FINISH_OFF:
 /* API - Delete  the Email Account */
 EXPORT_API int email_delete_account(int account_id)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d]", account_id);
+       EM_DEBUG_API_BEGIN("account_id[%d]", account_id);
 
        int ret = 0;
        int err = EMAIL_ERROR_NONE;
@@ -185,39 +183,39 @@ EXPORT_API int email_delete_account(int account_id)
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter account_id  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
-       if(ret != EMAIL_ERROR_NONE) {   /*  get error code */
+       if (ret != EMAIL_ERROR_NONE) {  /*  get error code */
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
        }
 
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("ret[%d] err[%d]", ret, err);
+       EM_DEBUG_API_END("ret[%d] err[%d]", ret, err);
        return err;
 }
 
 /* API - Update  the Email Account */
 EXPORT_API int email_update_account(int account_id, email_account_t* new_account)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] new_account[%p]", account_id, new_account);
+       EM_DEBUG_API_BEGIN("account_id[%d] new_account[%p]", account_id, new_account);
 
        int size = 0;
        int err = EMAIL_ERROR_NONE;
        int with_validation = false;
        char* new_account_stream = NULL;
 
-       if ( account_id <= 0 || !new_account )  { /*prevent 23138*/
+       if (account_id <= 0 || !new_account)  { /*prevent 23138*/
                EM_DEBUG_EXCEPTION("account_id[%d], new_account[%p], with_validation[%d]", account_id, new_account, with_validation);
                return  EMAIL_ERROR_INVALID_PARAM;
        }
@@ -227,7 +225,7 @@ EXPORT_API int email_update_account(int account_id, email_account_t* new_account
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed ");
                goto FINISH_OFF;
        }
@@ -235,18 +233,18 @@ EXPORT_API int email_update_account(int account_id, email_account_t* new_account
        /* new_account */
        new_account_stream = em_convert_account_to_byte_stream(new_account, &size);
        EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
-       if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
+       if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter new_account failed ");
                goto FINISH_OFF;
        }
 
        /* with_validation */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter with_validation failed ");
                goto FINISH_OFF;
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
@@ -258,14 +256,14 @@ FINISH_OFF:
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 /* API - Update  the Email Account */
 EXPORT_API int email_update_account_with_validation(int account_id, email_account_t* new_account)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] new_account[%p]", account_id, new_account);
+       EM_DEBUG_API_BEGIN("account_id[%d] new_account[%p]", account_id, new_account);
 
        int size = 0;
        int err = EMAIL_ERROR_NONE;
@@ -283,7 +281,7 @@ EXPORT_API int email_update_account_with_validation(int account_id, email_accoun
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter account_id  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
@@ -291,18 +289,18 @@ EXPORT_API int email_update_account_with_validation(int account_id, email_accoun
        /* new_account */
        new_account_stream = em_convert_account_to_byte_stream(new_account, &size);
        EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
-       if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
+       if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
                EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter new_account  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* with_validation */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
                EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter with_validation  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("email_update_account--emipc_execute_proxy_api failed ");
                /* Prevent defect 18624 */
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
@@ -313,7 +311,7 @@ EXPORT_API int email_update_account_with_validation(int account_id, email_accoun
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -321,7 +319,7 @@ EXPORT_API int email_update_account_with_validation(int account_id, email_accoun
 /* API - Get the account Information based on the account ID */
 EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t** account)
 {
-       EM_DEBUG_FUNC_BEGIN ("account_id[%d] pulloption[%d]", account_id, pulloption);
+       EM_DEBUG_FUNC_BEGIN("account_id[%d] pulloption[%d]", account_id, pulloption);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        emstorage_account_tbl_t *account_tbl = NULL;
@@ -369,13 +367,13 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_account_list(email_account_t** account_list, int* count)
 {
-       EM_DEBUG_FUNC_BEGIN ();
+       EM_DEBUG_FUNC_BEGIN();
 
        int err = EMAIL_ERROR_NONE, i = 0;
     char *multi_user_name = NULL;
@@ -395,34 +393,34 @@ EXPORT_API int email_get_account_list(email_account_t** account_list, int* count
                goto FINISH_OFF;
        }
 
-       if(temp_account_tbl && (*count) > 0) {
+       if (temp_account_tbl && (*count) > 0) {
                *account_list = em_malloc(sizeof(email_account_t) * (*count));
-               if(!*account_list) {
+               if (!*account_list) {
                        EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                memset((void*)*account_list, 0, sizeof(email_account_t) * (*count));
-               for(i = 0; i < (*count); i++)
+               for (i = 0; i < (*count); i++)
                        em_convert_account_tbl_to_account(temp_account_tbl + i, (*account_list) + i);
        }
 
 FINISH_OFF:
 
-       if(temp_account_tbl)
+       if (temp_account_tbl)
                emstorage_free_account(&temp_account_tbl, (*count), NULL);
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_validate_account(int account_id, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] handle[%p]", account_id, handle);
+       EM_DEBUG_API_BEGIN("account_id[%d] handle[%p]", account_id, handle);
 
        int ret = 0;
        int err = EMAIL_ERROR_NONE;
@@ -437,12 +435,12 @@ EXPORT_API int email_validate_account(int account_id, int *handle)
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
@@ -450,27 +448,27 @@ EXPORT_API int email_validate_account(int account_id, int *handle)
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); /*  return  */
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); /*  error code */
 
-       if(handle)
+       if (handle)
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), handle);
 
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_validate_account_ex(email_account_t* account, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("account[%p]", account);
+       EM_DEBUG_API_BEGIN("account[%p]", account);
        char* local_account_stream = NULL;
        int ret = -1;
        int size = 0;
        int err = EMAIL_ERROR_NONE;
 
-       if (account == NULL || account->user_email_address == NULL || 
-               account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
+       if (account == NULL || account->user_email_address == NULL ||
+               account->incoming_server_user_name == NULL || account->incoming_server_address == NULL ||
                account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL)  {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
@@ -482,19 +480,19 @@ EXPORT_API int email_validate_account_ex(email_account_t* account, int *handle)
 
        local_account_stream = em_convert_account_to_byte_stream(account, &size);
        EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMAIL_ERROR_NULL_VALUE);
-       if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
+       if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
-       if(ret == EMAIL_ERROR_NONE) {
-               if(handle)
+       if (ret == EMAIL_ERROR_NONE) {
+               if (handle)
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
        } else {
                /*  get error code */
@@ -504,13 +502,13 @@ EXPORT_API int email_validate_account_ex(email_account_t* account, int *handle)
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_add_account_with_validation(email_account_t* account, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("account[%p]", account);
+       EM_DEBUG_API_BEGIN("account[%p]", account);
        char* local_account_stream = NULL;
        int ret = -1;
        int size = 0;
@@ -518,7 +516,7 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int *
     char *multi_user_name = NULL;
        HIPC_API hAPI = NULL;
 
-       if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
+       if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL ||
                account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL)  {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
@@ -529,7 +527,7 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int *
         return err;
     }
 
-       if(emstorage_check_duplicated_account(multi_user_name, account, true, &err) == false) {
+       if (emstorage_check_duplicated_account(multi_user_name, account, true, &err) == false) {
                EM_DEBUG_EXCEPTION("emstorage_check_duplicated_account failed (%d) ", err);
                goto FINISH_OFF;
        }
@@ -549,21 +547,21 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int *
                goto FINISH_OFF;
        }
 
-       if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
+       if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter  failed ");
                err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
                err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
-       if(ret == EMAIL_ERROR_NONE) {
-               if(handle)
+       if (ret == EMAIL_ERROR_NONE) {
+               if (handle)
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
        } else {
                /*  get error code */
@@ -571,7 +569,7 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int *
        }
 
 FINISH_OFF:
-       
+
        if (hAPI) {
                emipc_destroy_email_api(hAPI);
                hAPI = NULL;
@@ -579,14 +577,14 @@ FINISH_OFF:
 
        EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name)
 {
-       EM_DEBUG_API_BEGIN ("file_name[%p]", file_name);
+       EM_DEBUG_API_BEGIN("file_name[%p]", file_name);
 
        int ret = 0;
        int err = EMAIL_ERROR_NONE;
@@ -638,13 +636,13 @@ FINISH_OFF:
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name)
 {
-       EM_DEBUG_API_BEGIN ("file_name[%p]", file_name);
+       EM_DEBUG_API_BEGIN("file_name[%p]", file_name);
        int ret = 0;
        int err = EMAIL_ERROR_NONE;
 
@@ -674,13 +672,13 @@ EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_password_length_of_account(int account_id, email_get_password_length_type password_type, int *password_length)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] password_length[%p]", account_id, password_length);
+       EM_DEBUG_API_BEGIN("account_id[%d] password_length[%p]", account_id, password_length);
        int ret = 0;
        int err = EMAIL_ERROR_NONE;
 
@@ -695,18 +693,18 @@ EXPORT_API int email_get_password_length_of_account(int account_id, email_get_pa
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* password type */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&password_type, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&password_type, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
@@ -718,13 +716,13 @@ EXPORT_API int email_get_password_length_of_account(int account_id, email_get_pa
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("*password_length[%d]", *password_length);
+       EM_DEBUG_API_END("*password_length[%d]", *password_length);
        return err;
 }
 
 EXPORT_API int email_update_notification_bar(int account_id, int total_mail_count, int unread_mail_count, int input_from_eas)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] total_mail_count[%d] unread_mail_count[%d]", account_id, total_mail_count, unread_mail_count);
+       EM_DEBUG_API_BEGIN("account_id[%d] total_mail_count[%d] unread_mail_count[%d]", account_id, total_mail_count, unread_mail_count);
        int err = EMAIL_ERROR_NONE;
 
        if (account_id == 0)  {
@@ -738,31 +736,31 @@ EXPORT_API int email_update_notification_bar(int account_id, int total_mail_coun
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* total_mail_count */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&total_mail_count, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&total_mail_count, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* unread_mail_count */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&unread_mail_count, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&unread_mail_count, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* input_from_eas */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
@@ -771,13 +769,13 @@ EXPORT_API int email_update_notification_bar(int account_id, int total_mail_coun
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("ret[%d]", err);
+       EM_DEBUG_API_END("ret[%d]", err);
        return err;
 }
 
 EXPORT_API int email_clear_all_notification_bar()
 {
-    EM_DEBUG_API_BEGIN ();
+    EM_DEBUG_API_BEGIN();
        int err = EMAIL_ERROR_NONE;
        int account_id = ALL_ACCOUNT;
 
@@ -786,12 +784,12 @@ EXPORT_API int email_clear_all_notification_bar()
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
@@ -800,17 +798,17 @@ EXPORT_API int email_clear_all_notification_bar()
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("ret[%d]", err);
+       EM_DEBUG_API_END("ret[%d]", err);
        return err;
 }
 
 EXPORT_API int email_clear_notification_bar(int account_id)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
        int err = EMAIL_ERROR_NONE;
 
        if (account_id < ALL_ACCOUNT) {
-               EM_DEBUG_EXCEPTION ("EMAIL_ERROR_INVALID_PARAM");
+               EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
@@ -819,12 +817,12 @@ EXPORT_API int email_clear_notification_bar(int account_id)
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id  failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
@@ -833,20 +831,20 @@ EXPORT_API int email_clear_notification_bar(int account_id)
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("ret[%d]", err);
+       EM_DEBUG_API_END("ret[%d]", err);
        return err;
 }
 
 EXPORT_API int email_save_default_account_id(int input_account_id)
 {
-       EM_DEBUG_API_BEGIN ("input_account_id [%d]", input_account_id);
+       EM_DEBUG_API_BEGIN("input_account_id [%d]", input_account_id);
        int err = EMAIL_ERROR_NONE;
 
        if (input_account_id < ALL_ACCOUNT) {
-               EM_DEBUG_EXCEPTION ("EMAIL_ERROR_INVALID_PARAM");
+               EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
-       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID);
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
@@ -865,13 +863,13 @@ EXPORT_API int email_save_default_account_id(int input_account_id)
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("ret[%d]", err);
+       EM_DEBUG_API_END("ret[%d]", err);
        return err;
 }
 
 EXPORT_API int email_load_default_account_id(int *output_account_id)
 {
-       EM_DEBUG_FUNC_BEGIN ("output_account_id[%p]", output_account_id);
+       EM_DEBUG_FUNC_BEGIN("output_account_id[%p]", output_account_id);
 
        int err = EMAIL_ERROR_NONE;
        int account_id = 0;
@@ -887,16 +885,16 @@ EXPORT_API int email_load_default_account_id(int *output_account_id)
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-       
+
        if (err == EMAIL_ERROR_NONE) {
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &account_id);
        }
-       
+
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
        *output_account_id = account_id;
 
-       EM_DEBUG_FUNC_END ("ret[%d]", err);
+       EM_DEBUG_FUNC_END("ret[%d]", err);
        return err;
 }
index 8b046c2..c86640e 100755 (executable)
@@ -40,7 +40,7 @@
 
 EXPORT_API int email_show_user_message(int id, email_action_t action, int error_code)
 {
-       EM_DEBUG_API_BEGIN ("id[%d] action[%d] error_code[%d]", id, action, error_code);
+       EM_DEBUG_API_BEGIN("id[%d] action[%d] error_code[%d]", id, action, error_code);
        int err = EMAIL_ERROR_NONE;
 
        if (id < 0 || action < 0) {
@@ -78,32 +78,32 @@ EXPORT_API int email_show_user_message(int id, email_action_t action, int error_
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
-EXPORT_API int email_parse_mime_file(char *eml_file_path, email_mail_data_t **output_mail_data, 
+EXPORT_API int email_parse_mime_file(char *eml_file_path, email_mail_data_t **output_mail_data,
                                                                        email_attachment_data_t **output_attachment_data, int *output_attachment_count)
 {
-       EM_DEBUG_API_BEGIN ("eml_file_path[%p] output_mail_data[%p] output_attachment_data[%p]", 
+       EM_DEBUG_API_BEGIN("eml_file_path[%p] output_mail_data[%p] output_attachment_data[%p]",
                                                eml_file_path, output_mail_data, output_attachment_data);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(eml_file_path, EMAIL_ERROR_INVALID_PARAM);
 
-       if (!emcore_parse_mime_file_to_mail(eml_file_path, output_mail_data, output_attachment_data, 
+       if (!emcore_parse_mime_file_to_mail(eml_file_path, output_mail_data, output_attachment_data,
                                                                                output_attachment_count, &err) || !*output_mail_data)
                EM_DEBUG_EXCEPTION("emcore_parse_mime_file_to_mail failed [%d]", err);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
-EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data, 
-                                                                       email_attachment_data_t *input_attachment_data, 
+EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data,
+                                                                       email_attachment_data_t *input_attachment_data,
                                                                        int input_attachment_count, char **output_file_path)
 {
-       EM_DEBUG_API_BEGIN ("input_mail_data[%p] input_attachment_data[%p] input_attachment_count[%d]", 
+       EM_DEBUG_API_BEGIN("input_mail_data[%p] input_attachment_data[%p] input_attachment_count[%d]",
                                                input_mail_data, input_attachment_data, input_attachment_count);
 
        int err = EMAIL_ERROR_NONE;
@@ -133,7 +133,7 @@ EXPORT_API int email_write_mime_file(email_mail_data_t *input_mail_data,
                goto FINISH_OFF;
        }
 
-       if (!emcore_make_rfc822_file(NULL, input_mail_data, input_attachment_data, input_attachment_count, false, 
+       if (!emcore_make_rfc822_file(NULL, input_mail_data, input_attachment_data, input_attachment_count, false,
                                                                output_file_path,  &err)) {
                EM_DEBUG_EXCEPTION("emcore_make_rfc822_file failed : [%d]", err);
        }
@@ -143,13 +143,13 @@ FINISH_OFF:
        if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_delete_parsed_data(email_mail_data_t *input_mail_data)
 {
-       EM_DEBUG_API_BEGIN ("mail_data[%p]", input_mail_data);
+       EM_DEBUG_API_BEGIN("mail_data[%p]", input_mail_data);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
 
@@ -165,32 +165,32 @@ EXPORT_API int email_delete_parsed_data(email_mail_data_t *input_mail_data)
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mime_entity(char *mime_path, char **mime_entity)
 {
-       EM_DEBUG_API_BEGIN ("mime_path[%p]", mime_path);
+       EM_DEBUG_API_BEGIN("mime_path[%p]", mime_path);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(mime_path, EMAIL_ERROR_INVALID_PARAM);
 
-       if (!emcore_get_mime_entity(mime_path, mime_entity, &err)) 
+       if (!emcore_get_mime_entity(mime_path, mime_entity, &err))
                EM_DEBUG_EXCEPTION("emcore_get_mime_entity failed [%d]", err);
 
-       EM_DEBUG_API_END ();
+       EM_DEBUG_API_END();
        return err;
 }
 
 EXPORT_API int email_verify_email_address(char *input_email_address)
 {
-       EM_DEBUG_API_BEGIN ("input_email_address[%p]", input_email_address);
+       EM_DEBUG_API_BEGIN("input_email_address[%p]", input_email_address);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(input_email_address, EMAIL_ERROR_INVALID_PARAM);
 
-       if ((err = em_verify_email_address (input_email_address)) != EMAIL_ERROR_NONE)
+       if ((err = em_verify_email_address(input_email_address)) != EMAIL_ERROR_NONE)
                EM_DEBUG_EXCEPTION("em_verify_email_address failed [%d]", err);
 
        EM_DEBUG_API_END("err [%d]", err);
@@ -199,7 +199,7 @@ EXPORT_API int email_verify_email_address(char *input_email_address)
 
 EXPORT_API int email_convert_mutf7_to_utf8(const char *mutf7_str, char **utf8_str)
 {
-       EM_DEBUG_API_BEGIN ("mutf7_str[%p]", mutf7_str);
+       EM_DEBUG_API_BEGIN("mutf7_str[%p]", mutf7_str);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(mutf7_str, EMAIL_ERROR_INVALID_PARAM);
@@ -216,6 +216,6 @@ EXPORT_API int email_convert_mutf7_to_utf8(const char *mutf7_str, char **utf8_st
 
        emcore_gmime_shutdown();
 
-       EM_DEBUG_API_END ("ret[%d]", err);
+       EM_DEBUG_API_END("ret[%d]", err);
        return err;
 }
index 2adb5fb..bd16579 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
  * This file contains the data structures and interfaces needed for application,
  * to interact with email-service.
  * @file               email-api-init.c
- * @brief              This file contains the data structures and interfaces of Email FW intialization related Functionality provided by 
- *                     email-service . 
+ * @brief              This file contains the data structures and interfaces of Email FW intialization related Functionality provided by
+ *                     email-service .
  */
+
 #include "string.h"
 #include "email-convert.h"
 #include "email-storage.h"
@@ -44,8 +44,8 @@
 
 EXPORT_API int email_open_db(void)
 {
-       EM_DEBUG_API_BEGIN ();
-       int error  = EMAIL_ERROR_NONE;
+       EM_DEBUG_API_BEGIN();
+       int error = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
 
     if ((error = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -58,14 +58,14 @@ EXPORT_API int email_open_db(void)
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("error[%d]", error);
-       return error;   
+       EM_DEBUG_API_END("error[%d]", error);
+       return error;
 }
 
 EXPORT_API int email_close_db(void)
 {
-       EM_DEBUG_API_BEGIN ();
-       int error  = EMAIL_ERROR_NONE;
+       EM_DEBUG_API_BEGIN();
+       int error = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
 
     if ((error = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -73,28 +73,28 @@ EXPORT_API int email_close_db(void)
         return error;
     }
 
-       if (!emstorage_db_close(multi_user_name, &error)) 
+       if (!emstorage_db_close(multi_user_name, &error))
                EM_DEBUG_EXCEPTION("emstorage_db_close failed [%d]", error);
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("error[%d]", error);
-       return error;   
+       EM_DEBUG_API_END("error[%d]", error);
+       return error;
 }
 
 
 EXPORT_API int email_service_begin(void)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
        int ret = -1;
 
        signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */
-       
+
        ret = emipc_initialize_proxy();
 
        emcore_init_task_handler_array();
 
-       EM_DEBUG_API_END ("err[%d]", ret);
+       EM_DEBUG_API_END("err[%d]", ret);
        return ret;
 }
 
@@ -102,18 +102,18 @@ extern GCancellable *cancel;
 
 EXPORT_API int email_service_end(void)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
        int ret = -1;
 
        if (cancel) {
-               g_cancellable_cancel (cancel);
+               g_cancellable_cancel(cancel);
                while (cancel) usleep(1000000);
        }
 
        ret = emipc_finalize_proxy();
 
-       EM_DEBUG_API_END ("err[%d]", ret);
-       
+       EM_DEBUG_API_END("err[%d]", ret);
+
        return ret;
 }
 
@@ -122,8 +122,8 @@ EXPORT_API int email_service_end(void)
 
 EXPORT_API int email_init_storage(void)
 {
-       EM_DEBUG_API_BEGIN ();
-       int error  = EMAIL_ERROR_NONE;
+       EM_DEBUG_API_BEGIN();
+       int error = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
 
     if ((error = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -137,29 +137,29 @@ EXPORT_API int email_init_storage(void)
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("error[%d]", error);
+       EM_DEBUG_API_END("error[%d]", error);
        return error;
 }
 
 EXPORT_API int email_ping_service(void)
 {
-       EM_DEBUG_API_BEGIN ();
-       int error  = EMAIL_ERROR_NONE;
+       EM_DEBUG_API_BEGIN();
+       int error = EMAIL_ERROR_NONE;
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_PING_SERVICE);
 
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
-               
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &error);
-       
+
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", error);
+       EM_DEBUG_API_END("err[%d]", error);
        return error;
 }
index 29f6af7..c80bbc4 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -26,8 +26,8 @@
  * This file contains the data structures and interfaces needed for application,
  * to interact with email-service.
  * @file               email-api-mail.c
- * @brief              This file contains the data structures and interfaces of Message related Functionality provided by 
- *                     email-service . 
+ * @brief              This file contains the data structures and interfaces of Message related Functionality provided by
+ *                     email-service .
  */
 
 #include <stdlib.h>
 
 EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas)
 {
-       EM_DEBUG_API_BEGIN ("input_mail_data[%p] input_attachment_data_list[%p] input_attachment_count[%d] input_meeting_request[%p] input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
+       EM_DEBUG_API_BEGIN("input_mail_data[%p] input_attachment_data_list[%p] input_attachment_count[%d] input_meeting_request[%p] input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
 
        EM_IF_NULL_RETURN_VALUE(input_mail_data,               EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id,   EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_id,   EMAIL_ERROR_INVALID_PARAM);
 
-       if(input_attachment_count > 0 && !input_attachment_data_list) {
+       if (input_attachment_count > 0 && !input_attachment_data_list) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -82,31 +82,31 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
         goto FINISH_OFF;
     }
 
-       if(input_from_eas == 0) { /* native emails */
+       if (input_from_eas == 0) { /* native emails */
                if ((input_mail_data->smime_type != EMAIL_SMIME_NONE) && (input_mail_data->mailbox_type != EMAIL_MAILBOX_TYPE_DRAFT)) {
                        if (!emcore_make_rfc822_file(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, true, &rfc822_file, &err)) {
                                EM_DEBUG_EXCEPTION("emcore_make_rfc822_file failed [%d]", err);
                                goto FINISH_OFF;
                        }
-               
+
                        input_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(emcore_set_mime_entity(rfc822_file));
-                       
+
                        emstorage_delete_file(rfc822_file, NULL);
-                       EM_SAFE_FREE(rfc822_file);      
+                       EM_SAFE_FREE(rfc822_file);
                }
 
                hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAIL);
 
-               if(!hAPI) {
+               if (!hAPI) {
                        EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-                       err = EMAIL_ERROR_NULL_VALUE;           
+                       err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
                /* email_mail_data_t */
                mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size);
 
-               if(!mail_data_stream) {
+               if (!mail_data_stream) {
                        EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
@@ -114,21 +114,21 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
 
                if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size))
                        EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed");
-               
+
                /* email_attachment_data_t */
                attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size);
 
-               if((size > 0) && !emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
+               if ((size > 0) && !emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
                        EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                /*  email_meeting_request_t */
-               if ( input_mail_data->meeting_request_status != EMAIL_MAIL_TYPE_NORMAL ) {
+               if (input_mail_data->meeting_request_status != EMAIL_MAIL_TYPE_NORMAL) {
                        meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size);
 
-                       if(!meeting_request_stream) {
+                       if (!meeting_request_stream) {
                                EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed");
                                err = EMAIL_ERROR_NULL_VALUE;
                                goto FINISH_OFF;
@@ -142,7 +142,7 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
                emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int));
 
                /* Execute API */
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                        goto FINISH_OFF;
@@ -151,7 +151,7 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
                /* get result from service */
                if ((ret_nth_value = (int*)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 0))) {
                        err = *ret_nth_value;
-                       
+
                        if (err == EMAIL_ERROR_NONE) {
                                if ((ret_nth_value = (int *)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 1))) {
                                        input_mail_data->mail_id = *ret_nth_value;
@@ -159,7 +159,7 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
                                        err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                                        goto FINISH_OFF;
                                }
-                               
+
                                if ((ret_nth_value = (int *)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 2))) {
                                        input_mail_data->thread_id = *ret_nth_value;
                                } else {
@@ -173,7 +173,7 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
                }
        } else { /* take care of mails from eas */
                err = emcore_add_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas, false);
-               if(err != EMAIL_ERROR_NONE) {
+               if (err != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -181,18 +181,18 @@ EXPORT_API int email_add_mail(email_mail_data_t *input_mail_data, email_attachme
 
 FINISH_OFF:
 
-       if(hAPI) 
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id)
 {
-       EM_DEBUG_API_BEGIN ("input_read_mail_id[%d] output_receipt_mail_id[%p]", input_read_mail_id, output_receipt_mail_id);
+       EM_DEBUG_API_BEGIN("input_read_mail_id[%d] output_receipt_mail_id[%p]", input_read_mail_id, output_receipt_mail_id);
 
        EM_IF_NULL_RETURN_VALUE(output_receipt_mail_id, EMAIL_ERROR_INVALID_PARAM);
 
@@ -201,13 +201,13 @@ EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receip
 
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_read_mail_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_read_mail_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("Add Param mail body Fail");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
@@ -216,7 +216,7 @@ EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receip
 
        EM_DEBUG_LOG("err [%d]", err);
 
-       if(err == EMAIL_ERROR_NONE) {
+       if (err == EMAIL_ERROR_NONE) {
                /* Get receipt mail id */
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_receipt_mail_id);
                EM_DEBUG_LOG("output_receipt_mail_id [%d]", *output_receipt_mail_id);
@@ -226,7 +226,7 @@ EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receip
 
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -242,7 +242,7 @@ EXPORT_API int email_create_db_full()
        int i = 0;
        FILE *body_file = NULL;
 
-       if ( (err = email_open_db()) != EMAIL_ERROR_NONE) {
+       if ((err = email_open_db()) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("email_open_db failed [%d]", err);
                return err;
        }
@@ -264,41 +264,40 @@ EXPORT_API int email_create_db_full()
 
        fflush(body_file);
 
-       mail_table_data.subject = (char*) em_malloc(50); 
+       mail_table_data.subject = (char*) em_malloc(50);
        mail_table_data.full_address_from = strdup("<dummy_from@nowhere.com>");
        mail_table_data.full_address_to = strdup("<dummy_to@nowhere.com>");
        mail_table_data.account_id = account_id;
        mail_table_data.file_path_plain = strdup(TMP_BODY_PATH);
        mail_table_data.body_download_status = 1;
 
-       if(err = email_get_mailbox_list_ex(1, -1, 0, &mailbox_list, &mailbox_count)) < EMAIL_ERROR_NONE) {
+       if ((err = email_get_mailbox_list_ex(1, -1, 0, &mailbox_list, &mailbox_count)) < EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("email_get_mailbox_list_ex failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       for(mailbox_index = 0; mailbox_index < mailbox_count; mailbox_index++) {
-               mail_slot_size= mailbox_list[mailbox_index].mail_slot_size;
-               for(mail_index = 0; mail_index < mail_slot_size; mail_index++) {
-                       sprintf(mail_table_data.subject, "Subject #%d",mail_index);
+       for (mailbox_index = 0; mailbox_index < mailbox_count; mailbox_index++) {
+               mail_slot_size = mailbox_list[mailbox_index].mail_slot_size;
+               for (mail_index = 0; mail_index < mail_slot_size; mail_index++) {
+                       sprintf(mail_table_data.subject, "Subject #%d", mail_index);
                        mail_table_data.mailbox_id   = mailbox_list[mailbox_index].mailbox_id;
                        mail_table_data.mailbox_type = mailbox_list[mailbox_index].mailbox_type;
 
-                       if( !emstorage_add_mail(NULL, &mail_table_data, 1, true, &err))  {
-                               EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]",err);
-               
+                       if (!emstorage_add_mail(NULL, &mail_table_data, 1, true, &err))  {
+                               EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]", err);
                                goto FINISH_OFF;
                        }
                }
        }
 
 FINISH_OFF:
-       if ( (err = email_close_db()) != EMAIL_ERROR_NONE) {
+       if ((err = email_close_db()) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("email_close_db failed [%d]", err);
-       }       
+       }
 
-       if(body_file) fclose(body_file); /*prevent 39446*/
-       
-       if(mailbox_list)
+       if (body_file) fclose(body_file); /*prevent 39446*/
+
+       if (mailbox_list)
                email_free_mailbox(&mailbox_list, mailbox_count);
 
        EM_SAFE_FREE(mail_table_data.subject);
@@ -311,12 +310,12 @@ FINISH_OFF:
 
 EXPORT_API int email_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas)
 {
-       EM_DEBUG_API_BEGIN ("input_mail_data[%p] input_attachment_data_list[%p] input_attachment_count[%d] input_meeting_request[%p] input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
+       EM_DEBUG_API_BEGIN("input_mail_data[%p] input_attachment_data_list[%p] input_attachment_count[%d] input_meeting_request[%p] input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
 
        EM_IF_NULL_RETURN_VALUE(input_mail_data,               EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id,   EMAIL_ERROR_INVALID_PARAM);
 
-       if(input_attachment_count > 0 && !input_attachment_data_list) {
+       if (input_attachment_count > 0 && !input_attachment_data_list) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -328,31 +327,31 @@ EXPORT_API int email_update_mail(email_mail_data_t *input_mail_data, email_attac
        char     *meeting_request_stream = NULL;
 
        HIPC_API  hAPI = NULL;
-       
-       if(input_from_eas == 0) {
-               hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_MAIL);  
 
-               if(!hAPI) {
+       if (input_from_eas == 0) {
+               hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_MAIL);
+
+               if (!hAPI) {
                        EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-                       err = EMAIL_ERROR_NULL_VALUE;           
+                       err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
                /* email_mail_data_t */
                mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, &size);
 
-               if(!mail_data_stream) {
+               if (!mail_data_stream) {
                        EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
-               
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) {
+
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter for head failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
-               
+
                /* email_attachment_data_t */
                attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size);
                if ((size > 0) && !emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
@@ -365,13 +364,13 @@ EXPORT_API int email_update_mail(email_mail_data_t *input_mail_data, email_attac
                if (input_mail_data->meeting_request_status != EMAIL_MAIL_TYPE_NORMAL) {
                        meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size);
 
-                       if(!meeting_request_stream) {
+                       if (!meeting_request_stream) {
                                EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed");
                                err = EMAIL_ERROR_NULL_VALUE;
                                goto FINISH_OFF;
                        }
 
-                       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) {
+                       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) {
                                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -379,58 +378,57 @@ EXPORT_API int email_update_mail(email_mail_data_t *input_mail_data, email_attac
                }
 
                /* input_from_eas */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                /* Execute API */
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                        goto FINISH_OFF;
                }
 
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-               
-               if(err == EMAIL_ERROR_NONE) {
+
+               if (err == EMAIL_ERROR_NONE) {
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &input_mail_data->mail_id);
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &input_mail_data->thread_id);
                }
-       } 
-       else {
-               if( (err = emcore_update_mail(NULL, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
+       } else {
+               if ((err = emcore_update_mail(NULL, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
                        goto FINISH_OFF;
                }
        }
 
 FINISH_OFF:
-       if(hAPI) 
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
        EM_SAFE_FREE(mail_data_stream);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_update_mail_attribute(int input_account_id, int *input_mail_id_array, int input_mail_id_count, email_mail_attribute_type input_attribute_type, email_mail_attribute_value_t input_value)
 {
-       EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mail_id_array[%p] input_mail_id_count[%d] input_attribute_type[%d]", input_account_id, input_mail_id_array, input_mail_id_count, input_attribute_type);
+       EM_DEBUG_API_BEGIN("input_account_id[%d] input_mail_id_array[%p] input_mail_id_count[%d] input_attribute_type[%d]", input_account_id, input_mail_id_array, input_mail_id_count, input_attribute_type);
 
        int err = EMAIL_ERROR_NONE;
        task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE task_parameter;
        email_mail_attribute_value_type value_type;
 
-       if(input_mail_id_count <= 0 || input_mail_id_array == NULL) {
+       if (input_mail_id_count <= 0 || input_mail_id_array == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if((err = emcore_get_mail_attribute_value_type(input_attribute_type, &value_type)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_mail_attribute_value_type(input_attribute_type, &value_type)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_mail_attribute_value_type failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -441,49 +439,49 @@ EXPORT_API int email_update_mail_attribute(int input_account_id, int *input_mail
        task_parameter.attribute_type = input_attribute_type;
        task_parameter.value          = input_value;
 
-       if(value_type == EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING)
+       if (value_type == EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING)
                task_parameter.value_length = EM_SAFE_STRLEN(input_value.string_type_value);
        else
                task_parameter.value_length = 4;
 
-       if((err = emipc_execute_proxy_task(EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE, &task_parameter)) != EMAIL_ERROR_NONE) {
+       if ((err = emipc_execute_proxy_task(EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE, &task_parameter)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
                goto FINISH_OFF;
        }
 
 FINISH_OFF:
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_clear_mail_data()
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
        int err = EMAIL_ERROR_NONE;
-       
-       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_DATA);  
+
+       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_DATA);
 
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
-       
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Fail");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-       
-       if(hAPI)
+
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int email_count_mail(email_list_filter_t *input_filter_list, int input_filter_count, int *output_total_mail_count, int *output_unseen_mail_count)
 {
-       EM_DEBUG_API_BEGIN ("input_filter_list[%p] input_filter_count[%d] output_total_mail_count[%p] output_unseen_mail_count[%p]", input_filter_list, input_filter_count, output_total_mail_count, output_unseen_mail_count);
-       
+       EM_DEBUG_API_BEGIN("input_filter_list[%p] input_filter_count[%d] output_total_mail_count[%p] output_unseen_mail_count[%p]", input_filter_list, input_filter_count, output_total_mail_count, output_unseen_mail_count);
+
        int total_count = 0;
        int unread = 0;
        int err = EMAIL_ERROR_NONE;
@@ -516,21 +514,21 @@ EXPORT_API int email_count_mail(email_list_filter_t *input_filter_list, int inpu
 FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
-       EM_SAFE_FREE (conditional_clause_string); /* detected by valgrind */
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_SAFE_FREE(conditional_clause_string); /* detected by valgrind */
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int email_delete_mail(int input_mailbox_id, int *input_mail_ids, int input_num, int input_from_server)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_mail_ids[%p] input_num[%d] input_from_server[%d]", input_mailbox_id, input_mail_ids, input_num, input_from_server);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_mail_ids[%p] input_num[%d] input_from_server[%d]", input_mailbox_id, input_mail_ids, input_num, input_from_server);
 
        int err = EMAIL_ERROR_NONE;
        HIPC_API hAPI = NULL;
 
        EM_IF_NULL_RETURN_VALUE(input_mail_ids, EMAIL_ERROR_INVALID_PARAM);
-       
+
        if (input_mailbox_id <= 0) {
                EM_DEBUG_EXCEPTION("input_mailbox_id = %d", input_mailbox_id);
                err = EMAIL_ERROR_INVALID_PARAM;
@@ -539,215 +537,215 @@ EXPORT_API int email_delete_mail(int input_mailbox_id, int *input_mail_ids, int
 
        if (input_num <= 0) {
                EM_DEBUG_EXCEPTION("input_num = %d", input_num);
-               err = EMAIL_ERROR_INVALID_PARAM;                
+               err = EMAIL_ERROR_INVALID_PARAM;
                return err;
        }
 
        hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAIL);
-       
-       if(!hAPI) {
+
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
        /* mailbox id*/
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Number of mail_ids */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_num, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_num, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* set of mail_ids */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)input_mail_ids, input_num * sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)input_mail_ids, input_num * sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* from-server */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_server, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_server, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;   
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int email_delete_all_mails_in_mailbox(int input_mailbox_id, int input_from_server)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_from_server[%d]", input_mailbox_id, input_from_server);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_from_server[%d]", input_mailbox_id, input_from_server);
 
        int err = EMAIL_ERROR_NONE;
        HIPC_API hAPI = NULL;
-       
-       if(input_mailbox_id <= 0) {
+
+       if (input_mailbox_id <= 0) {
                EM_DEBUG_EXCEPTION("input_mailbox_id = %d", input_mailbox_id);
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
        }
-       
+
        hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ALL_MAIL);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
-       
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
+
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_server, sizeof(int))){
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_server, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;           
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
-       
-       emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int),&err );
+
+       emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
 
-       if(hAPI)        
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
-       
-       EM_DEBUG_API_END ("err[%d]", err);
+
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_add_attachment(int mail_id, email_attachment_data_t* attachment)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d] attachment[%p]", mail_id, attachment);
+       EM_DEBUG_API_BEGIN("mail_id[%d] attachment[%p]", mail_id, attachment);
        int err = EMAIL_ERROR_NONE;
        char *attchment_stream = NULL;
        int size = 0;
        HIPC_API hAPI = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(attachment, EMAIL_ERROR_INVALID_PARAM);
-       
+
        hAPI = emipc_create_email_api(_EMAIL_API_ADD_ATTACHMENT);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
        /* mail_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Attachment */
        attchment_stream = em_convert_attachment_data_to_byte_stream(attachment, 1, &size);
 
-       if(!attchment_stream) {
+       if (!attchment_stream) {
                EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attchment_stream, size)){
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, attchment_stream, size)) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;           
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-       
-       if(EMAIL_ERROR_NONE == err) {
+
+       if (EMAIL_ERROR_NONE == err) {
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &attachment->attachment_id);
        }
 
 FINISH_OFF:
        EM_SAFE_FREE(attchment_stream);
-       
-       if(hAPI)
+
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
-       
-       EM_DEBUG_API_END ("err[%d]", err);
+
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
  }
 
 
 EXPORT_API int email_delete_attachment(int attachment_id)
 {
-       EM_DEBUG_API_BEGIN ("attachment_id[%d]", attachment_id);
+       EM_DEBUG_API_BEGIN("attachment_id[%d]", attachment_id);
        int err = EMAIL_ERROR_NONE;
        HIPC_API hAPI = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(attachment_id, EMAIL_ERROR_INVALID_PARAM);
-       
+
        hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ATTACHMENT);
-       
-       if(!hAPI) {
+
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
        /* attachment_index */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&attachment_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&attachment_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;           
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -757,12 +755,12 @@ FINISH_OFF:
 
 EXPORT_API int email_query_mails(char *conditional_clause_string, email_mail_data_t** mail_list,  int *result_count)
 {
-       EM_DEBUG_API_BEGIN ("conditional_clause_string[%s] mail_list[%p] result_count[%p]", conditional_clause_string, mail_list, result_count);
+       EM_DEBUG_API_BEGIN("conditional_clause_string[%s] mail_list[%p] result_count[%p]", conditional_clause_string, mail_list, result_count);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        emstorage_mail_tbl_t *result_mail_tbl = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMAIL_ERROR_INVALID_PARAM);
 
@@ -776,29 +774,29 @@ EXPORT_API int email_query_mails(char *conditional_clause_string, email_mail_dat
                goto FINISH_OFF;
        }
 
-       if(!em_convert_mail_tbl_to_mail_data(result_mail_tbl, *result_count, mail_list, &err)) {
+       if (!em_convert_mail_tbl_to_mail_data(result_mail_tbl, *result_count, mail_list, &err)) {
                EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
                goto FINISH_OFF;
        }
 
-FINISH_OFF:    
+FINISH_OFF:
 
-       if(result_mail_tbl && !emstorage_free_mail(&result_mail_tbl, *result_count, NULL))
+       if (result_mail_tbl && !emstorage_free_mail(&result_mail_tbl, *result_count, NULL))
                EM_DEBUG_EXCEPTION("emstorage_free_mail failed");
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_query_mail_list(char *input_conditional_clause_string, email_mail_list_item_t** output_mail_list,  int *output_result_count)
 {
-       EM_DEBUG_API_BEGIN ("input_conditional_clause_string[%s] output_mail_list[%p] output_result_count[%p]", input_conditional_clause_string, output_mail_list, output_result_count);
+       EM_DEBUG_API_BEGIN("input_conditional_clause_string[%s] output_mail_list[%p] output_result_count[%p]", input_conditional_clause_string, output_mail_list, output_result_count);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(input_conditional_clause_string, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(output_result_count, EMAIL_ERROR_INVALID_PARAM);
 
@@ -812,10 +810,10 @@ EXPORT_API int email_query_mail_list(char *input_conditional_clause_string, emai
                goto FINISH_OFF;
        }
 
-FINISH_OFF:    
+FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err [%d]", err);
+       EM_DEBUG_API_END("err [%d]", err);
        return err;
 }
 
@@ -825,8 +823,8 @@ FINISH_OFF:
     -----------------------------------------------------------*/
 EXPORT_API int email_get_attachment_data(int attachment_id, email_attachment_data_t** attachment)
 {
-       EM_DEBUG_API_BEGIN ("attachment_id[%d] attachment[%p]", attachment_id, attachment);
-       
+       EM_DEBUG_API_BEGIN("attachment_id[%d] attachment[%p]", attachment_id, attachment);
+
        int err = EMAIL_ERROR_NONE;
        int nSize = 0;
        int attachment_count = 0;
@@ -836,45 +834,45 @@ EXPORT_API int email_get_attachment_data(int attachment_id, email_attachment_dat
        EM_IF_NULL_RETURN_VALUE(attachment_id, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(attachment, EMAIL_ERROR_INVALID_PARAM);
 
-       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_ATTACHMENT);
 
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* attachment_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&attachment_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&attachment_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;           
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
-       if(EMAIL_ERROR_NONE == err) {
+       if (EMAIL_ERROR_NONE == err) {
                nSize = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1);
-               if(nSize > 0) {
+               if (nSize > 0) {
                        attchment_stream = (char*)em_malloc(nSize+1);
 
-                       if(!attchment_stream) {
+                       if (!attchment_stream) {
                                EM_DEBUG_EXCEPTION("em_malloc failed");
-                               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+                               err = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
-                       }       
-               
+                       }
+
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, nSize, attchment_stream);
                        em_convert_byte_stream_to_attachment_data(attchment_stream, nSize, &attachment_data, &attachment_count);
                }
-               
-               if(!attachment_data) {
+
+               if (!attachment_data) {
                        EM_DEBUG_EXCEPTION("EMAIL_ERROR_NULL_VALUE");
-                       err = EMAIL_ERROR_NULL_VALUE;           
+                       err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
@@ -884,17 +882,17 @@ EXPORT_API int email_get_attachment_data(int attachment_id, email_attachment_dat
 FINISH_OFF:
        EM_SAFE_FREE(attchment_stream);
 
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_get_attachment_data_list(int input_mail_id, email_attachment_data_t **output_attachment_data, int *output_attachment_count)
 {
-       EM_DEBUG_API_BEGIN ("input_mail_id[%d] output_attachment_data[%p] output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count);
+       EM_DEBUG_API_BEGIN("input_mail_id[%d] output_attachment_data[%p] output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count);
        int   err             = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
 
@@ -903,30 +901,30 @@ EXPORT_API int email_get_attachment_data_list(int input_mail_id, email_attachmen
         return err;
     }
 
-       if((err = emcore_get_attachment_data_list(multi_user_name, input_mail_id, output_attachment_data, output_attachment_count)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_attachment_data_list(multi_user_name, input_mail_id, output_attachment_data, output_attachment_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
        }
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_free_attachment_data(email_attachment_data_t **attachment_data_list, int attachment_data_count)
 {
-       EM_DEBUG_FUNC_BEGIN ("attachment_data_list[%p] attachment_data_count[%d]", attachment_data_list, attachment_data_count);        
-       
+       EM_DEBUG_FUNC_BEGIN("attachment_data_list[%p] attachment_data_count[%d]", attachment_data_list, attachment_data_count);
+
        int err = EMAIL_ERROR_NONE;
 
        emcore_free_attachment_data(attachment_data_list, attachment_data_count, &err);
-       
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mail_list_ex(email_list_filter_t *input_filter_list, int input_filter_count, email_list_sorting_rule_t *input_sorting_rule_list, int input_sorting_rule_count, int input_start_index, int input_limit_count, email_mail_list_item_t** output_mail_list, int *output_result_count)
 {
-       EM_DEBUG_FUNC_BEGIN ("input_filter_list[%p] input_filter_count[%d] input_sorting_rule_list[%p] input_sorting_rule_count[%d] input_start_index[%d] input_limit_count[%d] output_mail_list[%p] output_result_count[%p]", input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, output_mail_list, output_result_count);
+       EM_DEBUG_FUNC_BEGIN("input_filter_list[%p] input_filter_count[%d] input_sorting_rule_list[%p] input_sorting_rule_count[%d] input_start_index[%d] input_limit_count[%d] output_mail_list[%p] output_result_count[%p]", input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, output_mail_list, output_result_count);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -940,14 +938,14 @@ EXPORT_API int email_get_mail_list_ex(email_list_filter_t *input_filter_list, in
         goto FINISH_OFF;
     }
 
-       if(err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, input_filter_list, input_filter_count, input_sorting_rule_list, input_sorting_rule_count, input_start_index, input_limit_count, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG_DEV ("conditional_clause_string[%s].", conditional_clause_string);
+       EM_DEBUG_LOG_DEV("conditional_clause_string[%s].", conditional_clause_string);
 
-       if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, output_mail_list, output_result_count, &err)) {
+       if (!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, output_mail_list, output_result_count, &err)) {
                if (err != EMAIL_ERROR_MAIL_NOT_FOUND) /* there is no mail and it is definitely common */
                        EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", err);
                goto FINISH_OFF;
@@ -958,33 +956,33 @@ FINISH_OFF:
        EM_SAFE_FREE(conditional_clause_string);
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_free_list_filter(email_list_filter_t **input_filter_list, int input_filter_count)
 {
-       EM_DEBUG_FUNC_BEGIN ("input_filter_list[%p] input_filter_count[%d]", input_filter_list, input_filter_count);
+       EM_DEBUG_FUNC_BEGIN("input_filter_list[%p] input_filter_count[%d]", input_filter_list, input_filter_count);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(input_filter_list, EMAIL_ERROR_INVALID_PARAM);
 
        err = emstorage_free_list_filter(input_filter_list, input_filter_count);
 
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mails(int account_id , int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_data_t** mail_list,  int* result_count)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] mailbox_id[%d] thread_id[%d]", account_id, mailbox_id, thread_id);
+       EM_DEBUG_API_BEGIN("account_id[%d] mailbox_id[%d] thread_id[%d]", account_id, mailbox_id, thread_id);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        emstorage_mail_tbl_t *mail_tbl_list = NULL;
        EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM);
 
-       ifaccount_id < ALL_ACCOUNT) {
+       if (account_id < ALL_ACCOUNT) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM ;
                goto FINISH_OFF;
@@ -1000,32 +998,32 @@ EXPORT_API int email_get_mails(int account_id , int mailbox_id, int thread_id, i
                goto FINISH_OFF;
        }
 
-       if(!em_convert_mail_tbl_to_mail_data(mail_tbl_list, *result_count, mail_list, &err)) {
+       if (!em_convert_mail_tbl_to_mail_data(mail_tbl_list, *result_count, mail_list, &err)) {
                EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
                goto FINISH_OFF;
        }
 
-FINISH_OFF:    
+FINISH_OFF:
 
-       if(mail_tbl_list && !emstorage_free_mail(&mail_tbl_list, *result_count, NULL))
+       if (mail_tbl_list && !emstorage_free_mail(&mail_tbl_list, *result_count, NULL))
                EM_DEBUG_EXCEPTION("emstorage_free_mail failed");
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mail_list(int account_id , int mailbox_id, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, email_mail_list_item_t** mail_list,  int* result_count)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] mailbox_id[%d] thread_id[%d]", account_id, mailbox_id, thread_id);
+       EM_DEBUG_API_BEGIN("account_id[%d] mailbox_id[%d] thread_id[%d]", account_id, mailbox_id, thread_id);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM);
 
-       ifaccount_id < ALL_ACCOUNT) {
+       if (account_id < ALL_ACCOUNT) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -1040,26 +1038,26 @@ EXPORT_API int email_get_mail_list(int account_id , int mailbox_id, int thread_i
                goto FINISH_OFF;
        }
 
-FINISH_OFF:    
+FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mail_by_address(int account_id , int mailbox_id, email_email_address_list_t* addr_list,
                                                                        int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, email_mail_list_item_t** mail_list,  int* result_count)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] mailbox_id[%d]", account_id, mailbox_id);
+       EM_DEBUG_API_BEGIN("account_id[%d] mailbox_id[%d]", account_id, mailbox_id);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        email_mail_list_item_t* mail_list_item = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(mail_list, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(result_count, EMAIL_ERROR_INVALID_PARAM);
 
-       ifaccount_id < ALL_ACCOUNT) {
+       if (account_id < ALL_ACCOUNT) {
                EM_DEBUG_EXCEPTION("Invalid account id param");
                err = EMAIL_ERROR_INVALID_PARAM ;
                return err;
@@ -1081,17 +1079,17 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, email_mail_data_t** thread_info)
 {
-       EM_DEBUG_API_BEGIN ("thread_id[%d]", thread_id);
+       EM_DEBUG_API_BEGIN("thread_id[%d]", thread_id);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        emstorage_mail_tbl_t *mail_table_data = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(thread_info, EMAIL_ERROR_INVALID_PARAM);
 
     if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -1104,30 +1102,30 @@ EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, email_ma
                goto FINISH_OFF;
        }
 
-       if(!em_convert_mail_tbl_to_mail_data(mail_table_data, 1, thread_info, &err)) {
+       if (!em_convert_mail_tbl_to_mail_data(mail_table_data, 1, thread_info, &err)) {
                EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
                goto FINISH_OFF;
        }
 
-FINISH_OFF:    
+FINISH_OFF:
 
-       if(mail_table_data && !emstorage_free_mail(&mail_table_data, 1, NULL))
+       if (mail_table_data && !emstorage_free_mail(&mail_table_data, 1, NULL))
                EM_DEBUG_EXCEPTION("emstorage_free_mail failed");
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_thread_information_ex(int thread_id, email_mail_list_item_t** thread_info)
 {
-       EM_DEBUG_API_BEGIN ("thread_id[%d]", thread_id);
+       EM_DEBUG_API_BEGIN("thread_id[%d]", thread_id);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        emstorage_mail_tbl_t *mail_table_data = NULL;
        email_mail_list_item_t *temp_thread_info = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(thread_info, EMAIL_ERROR_INVALID_PARAM);
 
     if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -1142,7 +1140,7 @@ EXPORT_API int email_get_thread_information_ex(int thread_id, email_mail_list_it
 
        temp_thread_info = em_malloc(sizeof(email_mail_list_item_t));
 
-       if(!temp_thread_info) {
+       if (!temp_thread_info) {
                EM_DEBUG_EXCEPTION("em_malloc failed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -1172,20 +1170,20 @@ EXPORT_API int email_get_thread_information_ex(int thread_id, email_mail_list_it
 
        *thread_info = temp_thread_info;
 
-FINISH_OFF:    
+FINISH_OFF:
 
-       if(mail_table_data)
+       if (mail_table_data)
                emstorage_free_mail(&mail_table_data, 1, NULL);
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mail_data(int input_mail_id, email_mail_data_t **output_mail_data)
 {
-       EM_DEBUG_API_BEGIN ("input_mail_id[%d]", input_mail_id);
+       EM_DEBUG_API_BEGIN("input_mail_id[%d]", input_mail_id);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
 
@@ -1194,12 +1192,12 @@ EXPORT_API int email_get_mail_data(int input_mail_id, email_mail_data_t **output
         return err;
     }
 
-       if ( ((err = emcore_get_mail_data(multi_user_name, input_mail_id, output_mail_data)) != EMAIL_ERROR_NONE) || !output_mail_data) 
-               EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);    
-       
+       if (((err = emcore_get_mail_data(multi_user_name, input_mail_id, output_mail_data)) != EMAIL_ERROR_NONE) || !output_mail_data)
+               EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
+
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);      
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -1210,88 +1208,88 @@ EXPORT_API int email_get_mail_data(int input_mail_id, email_mail_data_t **output
 
 EXPORT_API int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver)
 {
-       EM_DEBUG_API_BEGIN ("mail_ids[%p] num[%d] seen_flag[%d] on_server[%d]", mail_ids, num, seen_flag, onserver);
-       EM_DEBUG_API_END ("EMAIL_ERROR_NOT_IMPLEMENTED");
+       EM_DEBUG_API_BEGIN("mail_ids[%p] num[%d] seen_flag[%d] on_server[%d]", mail_ids, num, seen_flag, onserver);
+       EM_DEBUG_API_END("EMAIL_ERROR_NOT_IMPLEMENTED");
        return EMAIL_ERROR_NOT_IMPLEMENTED;
 }
 
 EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, email_flags_field_type field_type, int value, int onserver)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] mail_ids[%p] num[%d] field_type[%d] seen_flag[%d] on_server[%d]", account_id, mail_ids, num, field_type, value, onserver);
-       
+       EM_DEBUG_API_BEGIN("account_id[%d] mail_ids[%p] num[%d] field_type[%d] seen_flag[%d] on_server[%d]", account_id, mail_ids, num, field_type, value, onserver);
+
        int err = EMAIL_ERROR_NONE;
 
-               
+
        EM_IF_NULL_RETURN_VALUE(mail_ids, EMAIL_ERROR_INVALID_PARAM);
        if (account_id == 0 || num <= 0 || (onserver != 0 && onserver != 1)) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
-               return EMAIL_ERROR_INVALID_PARAM;                       
+               return EMAIL_ERROR_INVALID_PARAM;
        }
-       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_FLAGS_FIELD);
-       
-       if(!hAPI) {
+
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
-       
+
        /* account_id*/
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Number of mail_ids */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* set of mail_ids */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* field_type */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&field_type, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&field_type, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* value */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&value, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&value, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* onserver  */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;   
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -1301,18 +1299,18 @@ FINISH_OFF:
     -----------------------------------------------------------*/
 EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, int input_target_mailbox_id)
 {
-       EM_DEBUG_API_BEGIN ("mail_ids[%p] num[%d] input_target_mailbox_id[%d]",  mail_ids, num, input_target_mailbox_id);
-       
+       EM_DEBUG_API_BEGIN("mail_ids[%p] num[%d] input_target_mailbox_id[%d]",  mail_ids, num, input_target_mailbox_id);
+
        int err = EMAIL_ERROR_NONE;
        HIPC_API hAPI = NULL;
 
-       if(input_target_mailbox_id <= 0) {
+       if (input_target_mailbox_id <= 0) {
                EM_DEBUG_EXCEPTION("input_target_mailbox_id is invalid parameter");
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
        }
        EM_IF_NULL_RETURN_VALUE(mail_ids, EMAIL_ERROR_INVALID_PARAM);
-       
+
        if (num <= 0)  {
                EM_DEBUG_LOG("num = %d", num);
                err = EMAIL_ERROR_INVALID_PARAM;
@@ -1321,111 +1319,111 @@ EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, int input_targ
 
        hAPI = emipc_create_email_api(_EMAIL_API_MOVE_MAIL);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
-       
+
        /* Number of mail_ids */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* set of mail_ids */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* input_target_mailbox_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_target_mailbox_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_target_mailbox_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;           
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
-FINISH_OFF:            
-       if(hAPI)
+FINISH_OFF:
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int  email_move_all_mails_to_mailbox(int input_source_mailbox_id, int input_target_mailbox_id)
 {
-       EM_DEBUG_API_BEGIN ("input_source_mailbox_id[%d] input_target_mailbox_id[%d]", input_source_mailbox_id, input_target_mailbox_id);
-       
+       EM_DEBUG_API_BEGIN("input_source_mailbox_id[%d] input_target_mailbox_id[%d]", input_source_mailbox_id, input_target_mailbox_id);
+
        int err = EMAIL_ERROR_NONE;
        HIPC_API hAPI = NULL;
-       
-       if(input_source_mailbox_id <= 0 || input_target_mailbox_id <= 0) {
+
+       if (input_source_mailbox_id <= 0 || input_target_mailbox_id <= 0) {
                EM_DEBUG_EXCEPTION("mailbox_id is invalid parameter");
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
        }
-       
+
        hAPI = emipc_create_email_api(_EMAIL_API_MOVE_ALL_MAIL);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
-       
+
        /* input_source_mailbox_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_source_mailbox_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_source_mailbox_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* input_target_mailbox_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_target_mailbox_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_target_mailbox_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;           
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
-       
-       EM_DEBUG_API_END ("err[%d]", err);
+
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_move_mails_to_mailbox_of_another_account(int input_source_mailbox_id, int *input_mail_id_array, int input_mail_id_count, int input_target_mailbox_id, int *output_task_id)
 {
-       EM_DEBUG_API_BEGIN ("input_source_mailbox_id[%d] input_mail_id_array[%p] input_mail_id_count[%d] input_target_mailbox_id[%d] output_task_id[%p]",  input_source_mailbox_id, input_mail_id_array, input_mail_id_count, input_target_mailbox_id, output_task_id);
+       EM_DEBUG_API_BEGIN("input_source_mailbox_id[%d] input_mail_id_array[%p] input_mail_id_count[%d] input_target_mailbox_id[%d] output_task_id[%p]",  input_source_mailbox_id, input_mail_id_array, input_mail_id_count, input_target_mailbox_id, output_task_id);
 
        int err = EMAIL_ERROR_NONE;
        task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT task_parameter;
 
-       if(input_source_mailbox_id <= 0 || input_target_mailbox_id <= 0 || input_mail_id_array == NULL || input_mail_id_count == 0) {
+       if (input_source_mailbox_id <= 0 || input_target_mailbox_id <= 0 || input_mail_id_array == NULL || input_mail_id_count == 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
@@ -1436,26 +1434,26 @@ EXPORT_API int email_move_mails_to_mailbox_of_another_account(int input_source_m
        task_parameter.mail_id_count     = input_mail_id_count;
        task_parameter.target_mailbox_id = input_target_mailbox_id;
 
-       if((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, &task_parameter)) != EMAIL_ERROR_NONE) {
+       if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, &task_parameter)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
                goto FINISH_OFF;
        }
 
 FINISH_OFF:
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
+
 EXPORT_API int email_free_mail_data(email_mail_data_t** mail_list, int count)
 {
-       EM_DEBUG_FUNC_BEGIN ("mail_list[%p] count[%d]", mail_list, count);
+       EM_DEBUG_FUNC_BEGIN("mail_list[%p] count[%d]", mail_list, count);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(mail_list, EMAIL_ERROR_INVALID_PARAM);
 
        emcore_free_mail_data_list(mail_list, count);
-       EM_DEBUG_FUNC_END ("err[%d]", err);     
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
@@ -1464,21 +1462,21 @@ EXPORT_API int email_free_mail_data(email_mail_data_t** mail_list, int count)
 
 EXPORT_API int email_cancel_sending_mail(int mail_id)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d]", mail_id);
+       EM_DEBUG_API_BEGIN("mail_id[%d]", mail_id);
        EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM);
-       
+
        int err = EMAIL_ERROR_NONE;
        int account_id = 0;
     char *multi_user_name = NULL;
        email_mail_data_t* mail_data = NULL;
        email_account_server_t account_server_type;
        HIPC_API hAPI = NULL;
-       
+
     if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
         EM_DEBUG_EXCEPTION("emipc_get_container_name error : [%d]", err);
         goto FINISH_OFF;
     }
-       
+
        if (((err = emcore_get_mail_data(multi_user_name, mail_id, &mail_data)) != EMAIL_ERROR_NONE) || mail_data == NULL)  {
                EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
                goto FINISH_OFF;
@@ -1487,17 +1485,17 @@ EXPORT_API int email_cancel_sending_mail(int mail_id)
        account_id = mail_data->account_id;
 
        /*  check account bind type and branch off  */
-       if ( em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                int as_handle;
                ASNotiData as_noti_data;
 
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
@@ -1509,38 +1507,36 @@ EXPORT_API int email_cancel_sending_mail(int mail_id)
                as_noti_data.cancel_sending_mail.account_id      = account_id;
                as_noti_data.cancel_sending_mail.multi_user_name = EM_SAFE_STRDUP(multi_user_name);
 
-               if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_SENDING_MAIL, &as_noti_data) == false) {
+               if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_SENDING_MAIL, &as_noti_data) == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
-       }
-       else {
-
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL_CANCEL_JOB);
 
-               if(!hAPI) {
+               if (!hAPI) {
                        EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
                /* Account_id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                /* Mail ID */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
-       
+
                /* Execute API */
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                        goto FINISH_OFF;
@@ -1550,80 +1546,79 @@ EXPORT_API int email_cancel_sending_mail(int mail_id)
        }
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       if(mail_data)
+       if (mail_data)
                emcore_free_mail_data_list(&mail_data, 1);
 
        EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_retry_sending_mail(int mail_id, int timeout_in_sec)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d]",mail_id);
-       
-       int err = EMAIL_ERROR_NONE;
+       EM_DEBUG_API_BEGIN("mail_id[%d]", mail_id);
 
+       int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(mail_id, EMAIL_ERROR_INVALID_PARAM);
-       if( timeout_in_sec < 0 )  {
+       if (timeout_in_sec < 0)  {
                EM_DEBUG_EXCEPTION("Invalid timeout_in_sec");
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
        }
-       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_RETRY);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
        /* Mail ID */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* timeout */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(timeout_in_sec), sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(timeout_in_sec), sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;   
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_get_max_mail_count(int *Count)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
        int err = EMAIL_ERROR_NONE;
        EM_IF_NULL_RETURN_VALUE(Count, EMAIL_ERROR_INVALID_PARAM);
        *Count = emstorage_get_max_mail_count();
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -1632,24 +1627,26 @@ EXPORT_API int email_get_max_mail_count(int *Count)
 /* for setting application,disk usage of email in KB */
 EXPORT_API int email_get_disk_space_usage(unsigned long *total_size)
 {
-       EM_DEBUG_API_BEGIN ("total_size[%p]", total_size);
+       EM_DEBUG_API_BEGIN("total_size[%p]", total_size);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(total_size, EMAIL_ERROR_INVALID_PARAM);
 
-       if (!emstorage_mail_get_total_diskspace_usage(total_size,true,&err))  {
+       if (!emstorage_mail_get_total_diskspace_usage(total_size, true, &err))  {
                EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage failed [%d]", err);
 
                goto FINISH_OFF;
        }
-FINISH_OFF :   
-       EM_DEBUG_API_END ("err[%d]", err);
+
+FINISH_OFF:
+
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_address_info_list(int mail_id, email_address_info_list_t** address_info_list)
 {
-       EM_DEBUG_FUNC_BEGIN ("mail_id[%d] address_info_list[%p]", mail_id, address_info_list);
+       EM_DEBUG_FUNC_BEGIN("mail_id[%d] address_info_list[%p]", mail_id, address_info_list);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -1657,7 +1654,7 @@ EXPORT_API int email_get_address_info_list(int mail_id, email_address_info_list_
        email_address_info_list_t *temp_address_info_list = NULL;
 
        EM_IF_NULL_RETURN_VALUE(address_info_list, EMAIL_ERROR_INVALID_PARAM);
-       ifmail_id <= 0) {
+       if (mail_id <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM ;
                return err;
@@ -1684,26 +1681,26 @@ FINISH_OFF:
                emstorage_free_address_info_list(&temp_address_info_list);
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_free_address_info_list(email_address_info_list_t **address_info_list)
 {
-       EM_DEBUG_FUNC_BEGIN ("address_info_list[%p]", address_info_list);
+       EM_DEBUG_FUNC_BEGIN("address_info_list[%p]", address_info_list);
 
        int err = EMAIL_ERROR_NONE;
 
-       if ( (err = emstorage_free_address_info_list(address_info_list)) != EMAIL_ERROR_NONE ) {
+       if ((err = emstorage_free_address_info_list(address_info_list)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("address_info_list[%p] free failed.", address_info_list);
        }
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_query_meeting_request(char *input_conditional_clause_string, email_meeting_request_t **output_meeting_req, int *output_count)
 {
-       EM_DEBUG_API_BEGIN ("input_conditional_clause_string[%s] output_meeting_req[%p] output_count[%p]", input_conditional_clause_string, output_meeting_req, output_count);
+       EM_DEBUG_API_BEGIN("input_conditional_clause_string[%s] output_meeting_req[%p] output_count[%p]", input_conditional_clause_string, output_meeting_req, output_count);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
 
@@ -1721,13 +1718,13 @@ EXPORT_API int email_query_meeting_request(char *input_conditional_clause_string
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_meeting_request(int mail_id, email_meeting_request_t **meeting_req)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d] meeting_req[%p]", mail_id, meeting_req);
+       EM_DEBUG_API_BEGIN("mail_id[%d] meeting_req[%p]", mail_id, meeting_req);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -1757,85 +1754,85 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_free_meeting_request(email_meeting_request_t** meeting_req, int count)
 {
-       EM_DEBUG_FUNC_BEGIN ("meeting_req[%p] count[%d]", meeting_req, count);
-       if( !meeting_req || !*meeting_req ) {
+       EM_DEBUG_FUNC_BEGIN("meeting_req[%p] count[%d]", meeting_req, count);
+       if (!meeting_req || !*meeting_req) {
                EM_DEBUG_EXCEPTION("NULL PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
        int i = 0;
        email_meeting_request_t *cur = *meeting_req;
-       for ( ; i < count ; i++ )
+       for (; i < count ; i++)
                emstorage_free_meeting_request(cur + i);
 
        EM_SAFE_FREE(*meeting_req);
 
-       EM_DEBUG_FUNC_END ();
+       EM_DEBUG_FUNC_END();
        return EMAIL_ERROR_NONE;
 }
 
 EXPORT_API int email_move_thread_to_mailbox(int thread_id, int target_mailbox_id, int move_always_flag)
 {
-       EM_DEBUG_API_BEGIN ("thread_id[%d] target_mailbox_id[%d] move_always_flag[%d]", thread_id, target_mailbox_id, move_always_flag);
+       EM_DEBUG_API_BEGIN("thread_id[%d] target_mailbox_id[%d] move_always_flag[%d]", thread_id, target_mailbox_id, move_always_flag);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(target_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
-       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MOVE_THREAD_TO_MAILBOX);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
        /* thread_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* target mailbox information */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&target_mailbox_id, sizeof(int))){
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&target_mailbox_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
        }
 
        /* move_always_flag */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&move_always_flag, sizeof(int))){
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&move_always_flag, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;   
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag)
 {
-       EM_DEBUG_API_BEGIN ("thread_id[%d] delete_always_flag[%d]", thread_id, delete_always_flag);
+       EM_DEBUG_API_BEGIN("thread_id[%d] delete_always_flag[%d]", thread_id, delete_always_flag);
        int err = EMAIL_ERROR_NONE;
 
        if (thread_id <= 0) {
@@ -1846,47 +1843,47 @@ EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag)
 
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_THREAD);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
        /* thread_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* delete_always_flag */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&delete_always_flag, sizeof(int))){
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&delete_always_flag, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;   
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
 
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server)
 {
-       EM_DEBUG_API_BEGIN ("thread_id[%d] seen_flag[%d] on_server[%d]", thread_id, seen_flag, on_server);
+       EM_DEBUG_API_BEGIN("thread_id[%d] seen_flag[%d] on_server[%d]", thread_id, seen_flag, on_server);
        int err = EMAIL_ERROR_NONE;
 
        if (thread_id <= 0) {
@@ -1897,52 +1894,52 @@ EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, in
 
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
-               err = EMAIL_ERROR_NULL_VALUE;           
+               err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
        /* thread_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* seen_flag */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&seen_flag, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&seen_flag, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* on_server */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&on_server, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&on_server, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-               err = EMAIL_ERROR_OUT_OF_MEMORY;                
+               err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
-       
+
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
-               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;   
+               err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int input_on_server, int *output_handle)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
        int err = EMAIL_ERROR_NONE;
        int return_value = 0;
     char *multi_user_name = NULL;
@@ -1954,7 +1951,7 @@ EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int inp
         goto FINISH_OFF;
     }
 
-       if(err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl_data)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl_data)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -1964,15 +1961,15 @@ EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int inp
 
        memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
 
-       if ( em_get_account_server_type_by_account_id(multi_user_name, mailbox_tbl_data->account_id, &account_server_type, true, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, mailbox_tbl_data->account_id, &account_server_type, true, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server == true) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_on_server == true) {
                int as_handle = 0;
 
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        goto FINISH_OFF;
                }
@@ -1986,41 +1983,39 @@ EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int inp
 
                return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED, &as_noti_data);
 
-               if ( return_value == false ) {
+               if (return_value == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
 
-               if(output_handle)
+               if (output_handle)
                        *output_handle = as_handle;
-       }
-       else
-       {
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_EXPUNGE_MAILS_DELETED_FLAGGED);
 
-               if(!hAPI) {
+               if (!hAPI) {
                        EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
                /* input_mailbox_id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                /* input_on_server */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_on_server, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_on_server, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                /* Execute API */
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                        goto FINISH_OFF;
@@ -2028,22 +2023,22 @@ EXPORT_API int email_expunge_mails_deleted_flagged(int input_mailbox_id, int inp
 
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
                if (err == EMAIL_ERROR_NONE) {
-                       if(output_handle)
+                       if (output_handle)
                                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle);
                }
        }
 
 FINISH_OFF:
 
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       if(mailbox_tbl_data) {
+       if (mailbox_tbl_data) {
                emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL);
        }
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
index e9c8681..fb979ba 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
  * This file contains the data structures and interfaces needed for application,
  * to interact with email-service.
  * @file               email_api_mailbox.c
- * @brief              This file contains the data structures and interfaces of mailbox related Functionality provided by 
- *                     email-service . 
+ * @brief              This file contains the data structures and interfaces of mailbox related Functionality provided by
+ *                     email-service .
  */
+
 #include "string.h"
 #include "email-convert.h"
 #include "email-storage.h"
@@ -43,7 +43,7 @@
 
 EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
 
        int size = 0;
        int err = EMAIL_ERROR_NONE;
@@ -61,18 +61,18 @@ EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, in
     }
 
        memset(&as_noti_data, 0x00, sizeof(ASNotiData));
-       
+
        /*  check account bind type and branch off  */
-       if ( em_get_account_server_type_by_account_id(multi_user_name, new_mailbox->account_id, &account_server_type, false, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, new_mailbox->account_id, &account_server_type, false, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && on_server) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC && on_server) {
                int as_handle;
 
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
@@ -95,8 +95,7 @@ EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, in
 
                if (handle)
                        *handle = as_handle;
-       }
-       else {
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAILBOX);
 
                EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
@@ -122,7 +121,7 @@ EXPORT_API int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, in
                }
 
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-       
+
                if (handle) {
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
                        EM_DEBUG_LOG(" >>>>> Handle [%d]", *handle);
@@ -139,13 +138,13 @@ FINISH_OFF:
        EM_SAFE_FREE(local_mailbox_stream);
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, int input_on_server, int *output_handle)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_mailbox_name[%p] input_mailbox_alias[%p] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_on_server, output_handle);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_mailbox_name[%p] input_mailbox_alias[%p] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_on_server, output_handle);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -202,31 +201,30 @@ EXPORT_API int email_rename_mailbox(int input_mailbox_id, char *input_mailbox_na
 
                if (output_handle)
                        *output_handle = as_handle;
-       }
-       else {
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_RENAME_MAILBOX);
 
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_id failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, EM_SAFE_STRLEN(input_mailbox_name)+1 )) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, EM_SAFE_STRLEN(input_mailbox_name)+1)) {
                        EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_path failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_alias, EM_SAFE_STRLEN(input_mailbox_alias)+1 )) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_alias, EM_SAFE_STRLEN(input_mailbox_alias)+1)) {
                        EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_alias failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_on_server, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
                }
@@ -243,13 +241,13 @@ FINISH_OFF:
                emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_rename_mailbox_ex(int input_mailbox_id, char *input_mailbox_name, char *input_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_on_server, int *output_handle)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_mailbox_name[%p] input_mailbox_alias[%p] input_eas_data[%p] input_eas_data_length[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_eas_data, input_eas_data_length, input_on_server, output_handle);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_mailbox_name[%p] input_mailbox_alias[%p] input_eas_data[%p] input_eas_data_length[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_mailbox_name, input_mailbox_alias, input_eas_data, input_eas_data_length, input_on_server, output_handle);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -306,8 +304,7 @@ EXPORT_API int email_rename_mailbox_ex(int input_mailbox_id, char *input_mailbox
 
                if (output_handle)
                        *output_handle = as_handle;
-       }
-       else {
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_RENAME_MAILBOX_EX);
 
                if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_mailbox_id, sizeof(int))) {
@@ -315,17 +312,17 @@ EXPORT_API int email_rename_mailbox_ex(int input_mailbox_id, char *input_mailbox
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, EM_SAFE_STRLEN(input_mailbox_name)+1 )) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_name, EM_SAFE_STRLEN(input_mailbox_name)+1)) {
                        EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_path failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_alias, EM_SAFE_STRLEN(input_mailbox_alias)+1 )) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_mailbox_alias, EM_SAFE_STRLEN(input_mailbox_alias)+1)) {
                        EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_mailbox_alias failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_eas_data, input_eas_data_length )) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, input_eas_data, input_eas_data_length)) {
                        EM_DEBUG_EXCEPTION(" emipc_add_parameter for input_eas_data failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
@@ -352,7 +349,7 @@ FINISH_OFF:
                emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -361,15 +358,15 @@ FINISH_OFF:
 
 EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, int *output_handle)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
-       
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_on_server[%d] output_handle[%p]", input_mailbox_id, input_on_server, output_handle);
+
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        email_account_server_t account_server_type;
        emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
        HIPC_API hAPI = NULL;
        ASNotiData as_noti_data;
-       
+
        EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
 
     if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -412,8 +409,7 @@ EXPORT_API int email_delete_mailbox(int input_mailbox_id, int input_on_server, i
 
                if (output_handle)
                        *output_handle = as_handle;
-       }
-       else {
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAILBOX);
 
                EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
@@ -450,17 +446,17 @@ FINISH_OFF:
        }
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
-EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array, 
-                                                                               int input_mailbox_id_count, int input_on_server, 
+EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_id_array,
+                                                                               int input_mailbox_id_count, int input_on_server,
                                                                                int *output_handle)
 {
-       EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id_array[%p] "
+       EM_DEBUG_API_BEGIN("input_account_id[%d] input_mailbox_id_array[%p] "
                                                "input_mailbox_id_count[%d] input_on_server[%d] "
-                                               "output_handle[%p]", input_mailbox_id_array, input_mailbox_id_array, 
+                                               "output_handle[%p]", input_mailbox_id_array, input_mailbox_id_array,
                                                input_mailbox_id_count, input_on_server, output_handle);
 
        int err = EMAIL_ERROR_NONE;
@@ -480,10 +476,10 @@ EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_
     }
 
        /*  check account bind type and branch off  */
-       if (em_get_account_server_type_by_account_id(multi_user_name, 
-                                                                                                       input_account_id, 
-                                                                                                       &account_server_type, 
-                                                                                                       false, 
+       if (em_get_account_server_type_by_account_id(multi_user_name,
+                                                                                                       input_account_id,
+                                                                                                       &account_server_type,
+                                                                                                       false,
                                                                                                        &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
@@ -516,14 +512,13 @@ EXPORT_API int email_delete_mailbox_ex(int input_account_id, int *input_mailbox_
 
                if (output_handle)
                        *output_handle = as_handle;
-       }
-       else {
+       } else {
                task_parameter.account_id        = input_account_id;
                task_parameter.mailbox_id_array  = input_mailbox_id_array;
                task_parameter.mailbox_id_count  = input_mailbox_id_count;
                task_parameter.on_server         = input_on_server;
 
-               if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, 
+               if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX,
                                                                                        &task_parameter)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
                        goto FINISH_OFF;
@@ -534,13 +529,13 @@ FINISH_OFF:
 
        EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e input_mailbox_type)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_mailbox_type[%d]", input_mailbox_id, input_mailbox_type);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_mailbox_type[%d]", input_mailbox_id, input_mailbox_type);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
@@ -569,13 +564,13 @@ EXPORT_API int email_set_mailbox_type(int input_mailbox_id, email_mailbox_type_e
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_set_local_mailbox(int input_mailbox_id, int input_is_local_mailbox)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d] input_is_local_mailbox[%d]", input_mailbox_id, input_is_local_mailbox);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d] input_is_local_mailbox[%d]", input_mailbox_id, input_is_local_mailbox);
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(input_mailbox_id, EMAIL_ERROR_INVALID_PARAM);
@@ -604,13 +599,13 @@ EXPORT_API int email_set_local_mailbox(int input_mailbox_id, int input_is_local_
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_sync_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
        int mailbox_count = 0;
        int err = EMAIL_ERROR_NONE ;
        int i = 0;
@@ -631,41 +626,41 @@ EXPORT_API int email_get_sync_mailbox_list(int account_id, email_mailbox_t** mai
                goto FINISH_OFF;
        } else
                err = EMAIL_ERROR_NONE;
-       
+
        if (mailbox_count > 0)  {
                if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count)))  {
                        EM_DEBUG_EXCEPTION("malloc failed...");
-                       err= EMAIL_ERROR_OUT_OF_MEMORY;
+                       err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
                for (i = 0; i < mailbox_count; i++)
                        em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
        } else
                *mailbox_list = NULL;
-       
+
        *count = mailbox_count;
-       
+
 FINISH_OFF:
 
        if (mailbox_tbl_list != NULL)
                emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, email_mailbox_t** mailbox_list, int* count)
 {
-       EM_DEBUG_API_BEGIN ();  
+       EM_DEBUG_API_BEGIN();
 
        int mailbox_count = 0;
-       emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL; 
-       int err =EMAIL_ERROR_NONE;
+       emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
+       int err = EMAIL_ERROR_NONE;
        int i;
     char *multi_user_name = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(mailbox_list, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
@@ -680,11 +675,11 @@ EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, ema
                goto FINISH_OFF;
        } else
                err = EMAIL_ERROR_NONE;
-       
+
        if (mailbox_count > 0)  {
                if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count)))  {
                        EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
-                       err= EMAIL_ERROR_OUT_OF_MEMORY;
+                       err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
@@ -692,7 +687,7 @@ EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, ema
                        em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
        } else
                *mailbox_list = NULL;
-       
+
        *count = mailbox_count;
 
 FINISH_OFF:
@@ -702,17 +697,17 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err [%d]", err);
+       EM_DEBUG_API_END("err [%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, email_mailbox_t** mailbox_list, int* count)
 {
-       EM_DEBUG_FUNC_BEGIN (); 
+       EM_DEBUG_FUNC_BEGIN();
 
        int mailbox_count = 0;
-       emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL; 
-       int err =EMAIL_ERROR_NONE;
+       emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
+       int err = EMAIL_ERROR_NONE;
        int i;
     char *multi_user_name = NULL;
 
@@ -738,17 +733,16 @@ EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type,
        if (mailbox_count > 0)  {
                if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count)))  {
                        EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
-                       err= EMAIL_ERROR_OUT_OF_MEMORY;
+                       err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
-               for (i = 0; i < mailbox_count; i++) 
+               for (i = 0; i < mailbox_count; i++)
                        em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
-       }
-       else
+       } else
                *mailbox_list = NULL;
 
-       if ( count )    
+       if (count)
                *count = mailbox_count;
 
 FINISH_OFF:
@@ -758,13 +752,13 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mailbox_list_by_keyword(int account_id, char *keyword, email_mailbox_t** mailbox_list, int* count)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
 
        int mailbox_count = 0;
        emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
@@ -788,7 +782,7 @@ EXPORT_API int email_get_mailbox_list_by_keyword(int account_id, char *keyword,
        if (mailbox_count > 0) {
                if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * mailbox_count))) {
                        EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
-                       err= EMAIL_ERROR_OUT_OF_MEMORY;
+                       err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
@@ -807,20 +801,20 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type,  email_mailbox_t** mailbox)
 {
-       EM_DEBUG_FUNC_BEGIN ();
-       
+       EM_DEBUG_FUNC_BEGIN();
+
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        email_mailbox_t* curr_mailbox = NULL;
        emstorage_mailbox_tbl_t* local_mailbox = NULL;
 
-       EM_IF_NULL_RETURN_VALUE(mailbox, EMAIL_ERROR_INVALID_PARAM);    
+       EM_IF_NULL_RETURN_VALUE(mailbox, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM)  ;
 
     if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -849,7 +843,7 @@ EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_t
                em_convert_mailbox_tbl_to_mailbox(local_mailbox, curr_mailbox);
        }
 
-       *mailbox = curr_mailbox;        
+       *mailbox = curr_mailbox;
 
 FINISH_OFF:
 
@@ -858,13 +852,13 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_mailbox_by_mailbox_id(int input_mailbox_id, email_mailbox_t** output_mailbox)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -903,13 +897,13 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_set_mail_slot_size(int account_id, int mailbox_id, int new_slot_size)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] mailbox_id[%d] new_slot_size[%d]", account_id, mailbox_id, new_slot_size);
+       EM_DEBUG_API_BEGIN("account_id[%d] mailbox_id[%d] new_slot_size[%d]", account_id, mailbox_id, new_slot_size);
 
        int err = EMAIL_ERROR_NONE;
 
@@ -917,8 +911,8 @@ EXPORT_API int email_set_mail_slot_size(int account_id, int mailbox_id, int new_
                EM_DEBUG_EXCEPTION("new_slot_size should be greater than 0 or should be equal to 0");
                return EMAIL_ERROR_INVALID_PARAM;
        }
-       
-       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAIL_SLOT_SIZE);  
+
+       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAIL_SLOT_SIZE);
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        if (hAPI) {
@@ -940,26 +934,26 @@ EXPORT_API int email_set_mail_slot_size(int account_id, int mailbox_id, int new_
                if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
-               } 
-       
+               }
+
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
                EM_DEBUG_LOG("email_set_mail_slot_size error VALUE [%d]", err);
                /*prevent 23139*/
-/*             if(handle) {
+/*             if (handle) {
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
                        EM_DEBUG_LOG("email_set_mail_slot_size handle VALUE [%d]", handle);
                } */
                emipc_destroy_email_api(hAPI);
                hAPI = NULL;
-               
+
        }
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id)
 {
-       EM_DEBUG_API_BEGIN ("input_mailbox_id[%d]", input_mailbox_id);
+       EM_DEBUG_API_BEGIN("input_mailbox_id[%d]", input_mailbox_id);
 
        int err = EMAIL_ERROR_NONE;
 
@@ -977,21 +971,21 @@ EXPORT_API int email_stamp_sync_time_of_mailbox(int input_mailbox_id)
                if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
-               } 
-       
+               }
+
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
                EM_DEBUG_LOG("email_stamp_sync_time_of_mailbox error VALUE [%d]", err);
                emipc_destroy_email_api(hAPI);
                hAPI = NULL;
        }
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_free_mailbox(email_mailbox_t** mailbox_list, int count)
 {
-       EM_DEBUG_FUNC_BEGIN ("mailbox_list[%p] count[%d]", mailbox_list, count);
+       EM_DEBUG_FUNC_BEGIN("mailbox_list[%p] count[%d]", mailbox_list, count);
        int err = EMAIL_ERROR_NONE;
 
        if (count <= 0 || !mailbox_list || !*mailbox_list) {
@@ -1013,7 +1007,7 @@ EXPORT_API int email_free_mailbox(email_mailbox_t** mailbox_list, int count)
        *mailbox_list = NULL;
 
 FINISH_OFF:
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 
 }
index 08ef234..8f27238 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
  * This file contains the data structures and interfaces needed for application,
  * to interact with email-service.
  * @file               email-api-network.c
- * @brief              This file contains the data structures and interfaces of Network related Functionality provided by 
- *                     email-service . 
+ * @brief              This file contains the data structures and interfaces of Network related Functionality provided by
+ *                     email-service .
  */
+
 #include "string.h"
 #include "email-convert.h"
 #include "email-api-mailbox.h"
@@ -42,8 +42,8 @@
 
 EXPORT_API int email_send_mail(int mail_id, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d] handle[%p]", mail_id, handle);
-       
+       EM_DEBUG_API_BEGIN("mail_id[%d] handle[%p]", mail_id, handle);
+
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        emstorage_mail_tbl_t* mail_table_data = NULL;
@@ -56,19 +56,19 @@ EXPORT_API int email_send_mail(int mail_id, int *handle)
         goto FINISH_OFF;
     }
 
-       if(mail_id <= 0) {
+       if (mail_id <= 0) {
                EM_DEBUG_EXCEPTION("mail_id is not valid");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
                EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
                goto FINISH_OFF;
        }
 
        if (mail_table_data->account_id <= 0) {
-               EM_DEBUG_EXCEPTION ("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ]  ", mail_table_data->account_id);
+               EM_DEBUG_EXCEPTION("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ]  ", mail_table_data->account_id);
                emstorage_free_mail(&mail_table_data, 1, NULL);
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -78,52 +78,51 @@ EXPORT_API int email_send_mail(int mail_id, int *handle)
        memset(&as_noti_data, 0x00, sizeof(ASNotiData));
 
        /*  check account bind type and branch off  */
-       if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                int as_handle;
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
-               
+
                /*  noti to active sync */
                as_noti_data.send_mail.handle          = as_handle;
                as_noti_data.send_mail.account_id      = mail_table_data->account_id;
                as_noti_data.send_mail.mail_id         = mail_id;
         as_noti_data.send_mail.multi_user_name = multi_user_name;
 
-               if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL, &as_noti_data) == false) {
+               if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL, &as_noti_data) == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
 
-               if(handle)
+               if (handle)
                        *handle = as_handle;
-       }
-       else {
-               hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL);    
+       } else {
+               hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL);
 
-               if (!hAPI ) {
-                       EM_DEBUG_EXCEPTION ("INVALID PARAM: hAPI NULL ");
+               if (!hAPI) {
+                       EM_DEBUG_EXCEPTION("INVALID PARAM: hAPI NULL ");
                        emstorage_free_mail(&mail_table_data, 1, NULL);
                        return EMAIL_ERROR_NULL_VALUE;
                }
 
                /* mail_id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))){
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("email_send_mail--Add Param mail_id failed");
                        emstorage_free_mail(&mail_table_data, 1, NULL);
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("email_send_mail--emipc_execute_proxy_api failed  ");
                        emstorage_free_mail(&mail_table_data, 1, NULL);
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_CRASH);
@@ -131,7 +130,7 @@ EXPORT_API int email_send_mail(int mail_id, int *handle)
 
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
                if (err == EMAIL_ERROR_NONE) {
-                       if(handle)
+                       if (handle)
                                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
                }
        }
@@ -144,13 +143,13 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);  
-       return err;     
+       EM_DEBUG_API_END("err[%d]", err);
+       return err;
 }
 
 EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int input_mail_id, int *output_handle)
 {
-       EM_DEBUG_API_BEGIN ("input_mail_id[%d] output_handle[%p]", input_mail_id, output_handle);
+       EM_DEBUG_API_BEGIN("input_mail_id[%d] output_handle[%p]", input_mail_id, output_handle);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -164,19 +163,19 @@ EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int
         goto FINISH_OFF;
     }
 
-       if(input_mail_id <= 0) {
+       if (input_mail_id <= 0) {
                EM_DEBUG_EXCEPTION("mail_id is not valid");
-               err= EMAIL_ERROR_INVALID_PARAM;
+               err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if(!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
+       if (!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
                EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
                goto FINISH_OFF;
        }
 
        if (mail_table_data->account_id <= 0) {
-               EM_DEBUG_EXCEPTION ("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ]  ", mail_table_data->account_id);
+               EM_DEBUG_EXCEPTION("EM_IF_ACCOUNT_ID_NULL: Account ID [ %d ]  ", mail_table_data->account_id);
                emstorage_free_mail(&mail_table_data, 1, NULL);
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -184,19 +183,19 @@ EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int
        EM_DEBUG_LOG("mail_table_data->account_id[%d], mail_table_data->mailbox_id[%d]", mail_table_data->account_id, mail_table_data->mailbox_id);
 
        /*  check account bind type and branch off  */
-       if ( em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                int as_handle;
                ASNotiData as_noti_data;
 
                memset(&as_noti_data, 0x00, sizeof(ASNotiData));
 
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
@@ -208,19 +207,18 @@ EXPORT_API int email_send_mail_with_downloading_attachment_of_original_mail(int
                as_noti_data.send_mail_with_downloading_attachment_of_original_mail.account_id      = mail_table_data->account_id;
                as_noti_data.send_mail_with_downloading_attachment_of_original_mail.multi_user_name = multi_user_name;
 
-               if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL_WITH_DOWNLOADING_OF_ORIGINAL_MAIL, &as_noti_data) == false) {
+               if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL_WITH_DOWNLOADING_OF_ORIGINAL_MAIL, &as_noti_data) == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
 
-               if(output_handle)
+               if (output_handle)
                        *output_handle = as_handle;
-       }
-       else {
+       } else {
                task_parameter.mail_id        = input_mail_id;
 
-               if((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, &task_parameter)) != EMAIL_ERROR_NONE) {
+               if ((err = emipc_execute_proxy_task(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, &task_parameter)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -234,13 +232,13 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_schedule_sending_mail(int input_mail_id, time_t input_scheduled_time)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d] input_time[%d]", input_mail_id, input_scheduled_time);
+       EM_DEBUG_API_BEGIN("mail_id[%d] input_time[%d]", input_mail_id, input_scheduled_time);
 
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
@@ -254,31 +252,31 @@ EXPORT_API int email_schedule_sending_mail(int input_mail_id, time_t input_sched
         goto FINISH_OFF;
     }
 
-       if(input_mail_id <= 0) {
+       if (input_mail_id <= 0) {
                EM_DEBUG_EXCEPTION("mail_id is not valid");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if(!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
+       if (!emstorage_get_mail_by_id(multi_user_name, input_mail_id, &mail_table_data, true, &err) || !mail_table_data) {
                EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
                goto FINISH_OFF;
        }
 
        /*  check account bind type and branch off  */
-       if ( em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, mail_table_data->account_id, &account_server_type, false, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                int as_handle;
                ASNotiData as_noti_data;
 
                memset(&as_noti_data, 0x00, sizeof(ASNotiData));
 
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
@@ -291,17 +289,16 @@ EXPORT_API int email_schedule_sending_mail(int input_mail_id, time_t input_sched
                as_noti_data.schedule_sending_mail.scheduled_time  = input_scheduled_time;
         as_noti_data.schedule_sending_mail.multi_user_name = multi_user_name;
 
-               if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SCHEDULE_SENDING_MAIL, &as_noti_data) == false) {
+               if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SCHEDULE_SENDING_MAIL, &as_noti_data) == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
-       }
-       else {
+       } else {
                task_parameter.mail_id         = input_mail_id;
                task_parameter.scheduled_time  = input_scheduled_time;
 
-               if((err = emipc_execute_proxy_task(EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL, &task_parameter)) != EMAIL_ERROR_NONE) {
+               if ((err = emipc_execute_proxy_task(EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL, &task_parameter)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("execute_proxy_task failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -315,54 +312,54 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_send_saved(int account_id, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] handle[%p]", account_id, handle);
-       
+       EM_DEBUG_API_BEGIN("account_id[%d] handle[%p]", account_id, handle);
+
        char* pOptionStream = NULL;
        int err = EMAIL_ERROR_NONE;
-       
+
        EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_ACCOUNT_ID_NULL(account_id, EMAIL_ERROR_INVALID_PARAM);
-       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_SAVED);
 
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
-       
+
        /* Account ID */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(account_id), sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(account_id), sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* Execute API */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                EM_SAFE_FREE(pOptionStream);
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
 
-       emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);        
+       emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
        emipc_destroy_email_api(hAPI);
-       
+
        hAPI = NULL;
        EM_SAFE_FREE(pOptionStream);
 
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id[%d] handle[%p]", input_account_id, input_mailbox_id, handle);
-       int err = EMAIL_ERROR_NONE;     
+       EM_DEBUG_API_BEGIN("input_account_id[%d] input_mailbox_id[%d] handle[%p]", input_account_id, input_mailbox_id, handle);
+       int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        /* int total_count = 0; */
-       
+
        EM_IF_ACCOUNT_ID_NULL(input_account_id, EMAIL_ERROR_INVALID_PARAM);
 
        email_account_server_t account_server_type;
@@ -381,13 +378,13 @@ EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                int as_handle;
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        goto FINISH_OFF;
                }
-               
+
                /*  noti to active sync */
                as_noti_data.sync_header.handle          = as_handle;
                as_noti_data.sync_header.account_id      = input_account_id;
@@ -404,38 +401,37 @@ EXPORT_API int email_sync_header(int input_account_id, int input_mailbox_id, int
                if (handle)
                        *handle = as_handle;
 
-       }
-       else {
-               hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);  
+       } else {
+               hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
 
                EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
                /* input_account_id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_account_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_account_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                /* input_mailbox_id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
                }
-                       
-               emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);        
+
+               emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
                if (err != EMAIL_ERROR_NONE)
                        goto FINISH_OFF;
 
-               if(handle)
-                       emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);      
+               if (handle)
+                       emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
        }
 
 FINISH_OFF:
@@ -445,16 +441,16 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int email_sync_header_for_all_account(int *handle)
 {
-       EM_DEBUG_API_BEGIN ("handle[%p]", handle);
+       EM_DEBUG_API_BEGIN("handle[%p]", handle);
     char *multi_user_name = NULL;
-       int err = EMAIL_ERROR_NONE;     
+       int err = EMAIL_ERROR_NONE;
        HIPC_API hAPI = NULL;
        int return_handle;
        ASNotiData as_noti_data;
@@ -469,31 +465,31 @@ EXPORT_API int email_sync_header_for_all_account(int *handle)
         goto FINISH_OFF;
     }
 
-       hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);  
+       hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
 
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* input_account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_account_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        /* input_account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_mailbox_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                EM_SAFE_FREE(multi_user_name);
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
-               
-        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);       
+
+        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
         if (err != EMAIL_ERROR_NONE)
                 goto FINISH_OFF;
@@ -508,17 +504,17 @@ EXPORT_API int email_sync_header_for_all_account(int *handle)
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < account_count; i++) {
-               if ( account_tbl_array[i].incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       for (i = 0; i < account_count; i++) {
+               if (account_tbl_array[i].incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                        /*  use returned handle value for a active sync handle */
                        /* int as_handle; */
                        /*
-                       if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+                       if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                                EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                                goto FINISH_OFF;
                        }
                        */
-                       
+
                        /*  noti to active sync */
                        as_noti_data.sync_header.handle          = return_handle;
                        as_noti_data.sync_header.account_id      = account_tbl_array[i].account_id;
@@ -526,15 +522,15 @@ EXPORT_API int email_sync_header_for_all_account(int *handle)
                        as_noti_data.sync_header.mailbox_id      = 0;
             as_noti_data.sync_header.multi_user_name = multi_user_name;
 
-                       if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
+                       if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
                                EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                                goto FINISH_OFF;
                        }
                }
        }
-        
-        if(handle)
+
+        if (handle)
                *handle = return_handle;
 
 FINISH_OFF:
@@ -542,17 +538,17 @@ FINISH_OFF:
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       if ( account_tbl_array )
+       if (account_tbl_array)
                emstorage_free_account(&account_tbl_array, account_count, NULL);
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d] with_attachment[%d]", mail_id, with_attachment);
+       EM_DEBUG_API_BEGIN("mail_id[%d] with_attachment[%d]", mail_id, with_attachment);
        int err = EMAIL_ERROR_NONE;
        emstorage_mail_tbl_t* mail_table_data = NULL;
        int account_id = 0;
@@ -568,13 +564,13 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
 
        memset(&as_noti_data, 0x00, sizeof(ASNotiData));
 
-       if(mail_id <= 0) {
+       if (mail_id <= 0) {
                EM_DEBUG_EXCEPTION("mail_id is not valid");
-               err= EMAIL_ERROR_INVALID_PARAM;
+               err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data ) {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
                EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
                goto FINISH_OFF;
        }
@@ -585,20 +581,20 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
        }
 
        account_id = mail_table_data->account_id;
-               
+
        /*  2010/02/12 ch715.lee : check account bind type and branch off  */
-       if ( em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                int as_handle;
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        goto FINISH_OFF;
                }
-               
+
                /*  noti to active sync */
                as_noti_data.download_body.handle          = as_handle;
                as_noti_data.download_body.account_id      = account_id;
@@ -606,13 +602,13 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
                as_noti_data.download_body.with_attachment = with_attachment;
         as_noti_data.download_body.multi_user_name = multi_user_name;
 
-               if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, &as_noti_data) == false) {
+               if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, &as_noti_data) == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
 
-               if(handle)
+               if (handle)
                        *handle = as_handle;
        } else {
                hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_BODY);
@@ -620,32 +616,32 @@ EXPORT_API int email_download_body(int mail_id, int with_attachment, int *handle
                EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
                /* Account Id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
                /* Mail Id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
                /* with_attachment */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_attachment, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_attachment, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
-               
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
                }
-                       
-                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);       
-                if (err != EMAIL_ERROR_NONE)           
+
+                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+                if (err != EMAIL_ERROR_NONE)
                         goto FINISH_OFF;
-                
-                if(handle)     {
+
+                if (handle)    {
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
                        EM_DEBUG_LOG("RETURN VALUE : %d  handle %d", err, *handle);
                 }
@@ -655,13 +651,13 @@ FINISH_OFF:
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       if(mail_table_data) {
+       if (mail_table_data) {
                emstorage_free_mail(&mail_table_data, 1, &err);
        }
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
@@ -671,7 +667,7 @@ FINISH_OFF:
 
 EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d] nth[%d] handle[%p]", mail_id, nth, handle);
+       EM_DEBUG_API_BEGIN("mail_id[%d] nth[%d] handle[%p]", mail_id, nth, handle);
        int err = EMAIL_ERROR_NONE;
        emstorage_mail_tbl_t* mail_table_data = NULL;
        int account_id = 0;
@@ -687,13 +683,13 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
 
        memset(&as_noti_data, 0x00, sizeof(ASNotiData));
 
-       if(mail_id <= 0) {
+       if (mail_id <= 0) {
                EM_DEBUG_EXCEPTION("mail_id is not valid");
-               err= EMAIL_ERROR_INVALID_PARAM;
+               err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data ) {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err) || !mail_table_data) {
                EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
                goto FINISH_OFF;
        }
@@ -705,18 +701,18 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
 
        account_id = mail_table_data->account_id;
 
-       if ( em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, true, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                goto FINISH_OFF;
        }
 
-       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                int as_handle;
-               if ( em_get_handle_for_activesync(&as_handle, &err) == false ) {
+               if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed[%d].", err);
                        goto FINISH_OFF;
                }
-               
+
                /*  noti to active sync */
                as_noti_data.download_attachment.handle           = as_handle;
                as_noti_data.download_attachment.account_id       = account_id;
@@ -724,13 +720,13 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
                as_noti_data.download_attachment.attachment_order = nth;
         as_noti_data.download_attachment.multi_user_name  = multi_user_name;
 
-               if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, &as_noti_data) == false) {
+               if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, &as_noti_data) == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
 
-               if(handle)
+               if (handle)
                        *handle = as_handle;
        } else {
                hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_ATTACHMENT);
@@ -738,57 +734,57 @@ EXPORT_API int email_download_attachment(int mail_id, int nth, int *handle)
                EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
                /* Account Id */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
                /* Mail ID */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
                /* nth */
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(nth), sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &(nth), sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                }
 
                /* Execute API */
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
                }
 
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-               if (err != EMAIL_ERROR_NONE)            
+               if (err != EMAIL_ERROR_NONE)
                        goto FINISH_OFF;
-                
-               if(handle)
+
+               if (handle)
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
-               
+
        }
-       
+
 FINISH_OFF:
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       if(mail_table_data) {
+       if (mail_table_data) {
                emstorage_free_mail(&mail_table_data, 1, &err);
        }
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
-       
+
 }
 
 
 EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_cancelation_type input_cancel_type)
 {
-       EM_DEBUG_API_BEGIN ("input_account_id[%d] input_handle[%d] input_cancel_type[%d]", input_account_id, input_handle, input_cancel_type);
+       EM_DEBUG_API_BEGIN("input_account_id[%d] input_handle[%d] input_cancel_type[%d]", input_account_id, input_handle, input_cancel_type);
        int err = EMAIL_ERROR_NONE;
        email_account_server_t account_server_type;
        HIPC_API hAPI = NULL;
@@ -797,7 +793,7 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
        int i, account_count = 0;
     char *multi_user_name = NULL;
 
-       if(input_account_id < 0)
+       if (input_account_id < 0)
                return EMAIL_ERROR_INVALID_PARAM;
 
     if ((err = emipc_get_user_name(&multi_user_name)) != EMAIL_ERROR_NONE) {
@@ -805,7 +801,7 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
         goto FINISH_OFF;
     }
 
-       if ( input_account_id == ALL_ACCOUNT ) {
+       if (input_account_id == ALL_ACCOUNT) {
                /*  this means that job is executed with all account */
                /*  Get all accounts for sending notification to active sync engine. */
                if (!emstorage_get_account_list(multi_user_name, &account_count, &account_list , true, false, &err)) {
@@ -813,20 +809,20 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
                        goto FINISH_OFF;
                }
 
-               for(i = 0; i < account_count; i++) {
-                       if ( em_get_account_server_type_by_account_id(multi_user_name, account_list[i].account_id, &account_server_type, true, &err) == false ) {
+               for (i = 0; i < account_count; i++) {
+                       if (em_get_account_server_type_by_account_id(multi_user_name, account_list[i].account_id, &account_server_type, true, &err) == false) {
                                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                                goto FINISH_OFF;
                        }
 
-                       if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+                       if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                                memset(&as_noti_data, 0x00, sizeof(ASNotiData));
                                as_noti_data.cancel_job.account_id      = account_list[i].account_id;
                                as_noti_data.cancel_job.handle          = input_handle;
                                as_noti_data.cancel_job.cancel_type     = input_cancel_type;
                 as_noti_data.cancel_job.multi_user_name = multi_user_name;
 
-                               if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
+                               if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
                                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                                        goto FINISH_OFF;
@@ -838,25 +834,25 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
                hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB);
 
                if (!hAPI) {
-                       EM_DEBUG_EXCEPTION ("INVALID PARAM: hAPI NULL ");
+                       EM_DEBUG_EXCEPTION("INVALID PARAM: hAPI NULL ");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) {         /*  input_account_id == 0 */
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) {                /*  input_account_id == 0 */
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
                }
 
                /* Execute API */
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                        goto FINISH_OFF;
@@ -865,20 +861,19 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
                emipc_destroy_email_api(hAPI);
                hAPI = NULL;
-       }
-       else {
-               if ( em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false ) {
+       } else {
+               if (em_get_account_server_type_by_account_id(multi_user_name, input_account_id, &account_server_type, true, &err) == false) {
                        EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                        goto FINISH_OFF;
                }
 
-               if ( account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+               if (account_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                        memset(&as_noti_data, 0x00, sizeof(ASNotiData));
                        as_noti_data.cancel_job.account_id      = input_account_id;
                        as_noti_data.cancel_job.handle          = input_handle;
             as_noti_data.cancel_job.multi_user_name = multi_user_name;
 
-                       if ( em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
+                       if (em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
                                EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                                goto FINISH_OFF;
@@ -888,18 +883,18 @@ EXPORT_API int email_cancel_job(int input_account_id, int input_handle, email_ca
 
                        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
-                       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) {
+                       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_account_id, sizeof(int))) {
                                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
                                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                        }
 
-                       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) {
+                       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_handle, sizeof(int))) {
                                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
                        }
 
                        /* Execute API */
-                       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+                       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
                        }
@@ -916,7 +911,7 @@ FINISH_OFF:
                emstorage_free_account(&account_list, account_count, NULL);
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -924,35 +919,35 @@ FINISH_OFF:
 
 EXPORT_API int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status)
 {
-       EM_DEBUG_API_BEGIN ("action[%d] account_id[%d] mail_id[%d] status[%p]", action, account_id, mail_id, status);
+       EM_DEBUG_API_BEGIN("action[%d] account_id[%d] mail_id[%d] status[%p]", action, account_id, mail_id, status);
        int err = EMAIL_ERROR_NOT_SUPPORTED;
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving)
 {
-       EM_DEBUG_API_BEGIN ("on_sending[%p] on_receiving[%p]", on_sending, on_receiving);
+       EM_DEBUG_API_BEGIN("on_sending[%p] on_receiving[%p]", on_sending, on_receiving);
        int err = EMAIL_ERROR_NOT_SUPPORTED;
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_task_information(email_task_information_t **output_task_information, int *output_task_information_count)
 {
-       EM_DEBUG_API_BEGIN ("output_task_information[%p] output_task_information_count[%p]", output_task_information, output_task_information_count);
+       EM_DEBUG_API_BEGIN("output_task_information[%p] output_task_information_count[%p]", output_task_information, output_task_information_count);
        int err = EMAIL_ERROR_NONE;
        int task_information_stream_length = 0;
        HIPC_API hAPI = NULL;
        char *task_information_stream = NULL;
 
-       if(output_task_information == NULL || output_task_information_count == NULL) {
+       if (output_task_information == NULL || output_task_information_count == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
-       if((hAPI = emipc_create_email_api(_EMAIL_API_GET_TASK_INFORMATION)) == NULL) {
+       if ((hAPI = emipc_create_email_api(_EMAIL_API_GET_TASK_INFORMATION)) == NULL) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
                err = EMAIL_ERROR_IPC_CRASH;
                goto FINISH_OFF;
@@ -965,12 +960,12 @@ EXPORT_API int email_get_task_information(email_task_information_t **output_task
        }
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
 
-       if(EMAIL_ERROR_NONE == err) {
+       if (EMAIL_ERROR_NONE == err) {
                task_information_stream_length = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1);
-               if(task_information_stream_length > 0) {
+               if (task_information_stream_length > 0) {
                        task_information_stream = (char*)em_malloc(task_information_stream_length + 1);
 
-                       if(!task_information_stream) {
+                       if (!task_information_stream) {
                                EM_DEBUG_EXCEPTION("em_malloc failed");
                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -981,7 +976,7 @@ EXPORT_API int email_get_task_information(email_task_information_t **output_task
                        EM_SAFE_FREE(task_information_stream); /*prevent 18951*/
                }
 
-               if(!output_task_information) {
+               if (!output_task_information) {
                        EM_DEBUG_EXCEPTION("EMAIL_ERROR_NULL_VALUE");
                        err = EMAIL_ERROR_NULL_VALUE;
                        goto FINISH_OFF;
@@ -992,57 +987,57 @@ EXPORT_API int email_get_task_information(email_task_information_t **output_task
             err = EMAIL_ERROR_NONE;
 
 FINISH_OFF:
-       if(hAPI)
+       if (hAPI)
                emipc_destroy_email_api(hAPI);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_sync_imap_mailbox_list(int account_id, int *handle)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
 
        int err = EMAIL_ERROR_NONE;
 
-       if(account_id <= 0) {
+       if (account_id <= 0) {
                EM_DEBUG_EXCEPTION("invalid parameters");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
-       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_IMAP_MAILBOX_LIST);       
+       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_IMAP_MAILBOX_LIST);
 
        /* account_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
                EM_DEBUG_LOG("emipc_add_parameter failed  ");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
-       if(!emipc_execute_proxy_api(hAPI))  {
+       if (!emipc_execute_proxy_api(hAPI))  {
                EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
 
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-       if(handle)
+       if (handle)
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
 
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
 
-       EM_DEBUG_API_END ("err[%d]", err);  
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
-EXPORT_API int email_search_mail_on_server(int input_account_id, 
-                                                                               int input_mailbox_id, 
-                                                                               email_search_filter_t *input_search_filter_list, 
-                                                                               int input_search_filter_count, 
+EXPORT_API int email_search_mail_on_server(int input_account_id,
+                                                                               int input_mailbox_id,
+                                                                               email_search_filter_t *input_search_filter_list,
+                                                                               int input_search_filter_count,
                                                                                int *output_handle)
 {
-       EM_DEBUG_API_BEGIN ("input_account_id[%d] input_mailbox_id[%d] input_search_filter_list[%p] "
-                                               "input_search_filter_count[%d] output_handle[%p]", 
-                                               input_account_id, input_mailbox_id, input_search_filter_list, 
+       EM_DEBUG_API_BEGIN("input_account_id[%d] input_mailbox_id[%d] input_search_filter_list[%p] "
+                                               "input_search_filter_count[%d] output_handle[%p]",
+                                               input_account_id, input_mailbox_id, input_search_filter_list,
                                                input_search_filter_count, output_handle);
 
        int       err = EMAIL_ERROR_NONE;
@@ -1065,10 +1060,10 @@ EXPORT_API int email_search_mail_on_server(int input_account_id,
 
        memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
 
-       if (em_get_account_server_type_by_account_id(multi_user_name, 
-                                                                                               input_account_id, 
-                                                                                               &account_server_type, 
-                                                                                               true, 
+       if (em_get_account_server_type_by_account_id(multi_user_name,
+                                                                                               input_account_id,
+                                                                                               &account_server_type,
+                                                                                               true,
                                                                                                &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                goto FINISH_OFF;
@@ -1100,9 +1095,7 @@ EXPORT_API int email_search_mail_on_server(int input_account_id,
 
                if (output_handle)
                        *output_handle = as_handle;
-       }
-       else
-       {
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_SEARCH_MAIL_ON_SERVER);
 
                EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
@@ -1113,20 +1106,20 @@ EXPORT_API int email_search_mail_on_server(int input_account_id,
                        goto FINISH_OFF;
                }
 
-               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_mailbox_id, sizeof(int))){
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_mailbox_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
                        err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                        goto FINISH_OFF;
                }
 
-               stream_for_search_filter_list = em_convert_search_filter_to_byte_stream(input_search_filter_list, 
-                                                                                                                                                               input_search_filter_count, 
+               stream_for_search_filter_list = em_convert_search_filter_to_byte_stream(input_search_filter_list,
+                                                                                                                                                               input_search_filter_count,
                                                                                                                                                                &stream_size_for_search_filter_list);
 
                EM_PROXY_IF_NULL_RETURN_VALUE(stream_for_search_filter_list, hAPI, EMAIL_ERROR_NULL_VALUE);
 
-               if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, 
-                                                                               stream_for_search_filter_list, 
+               if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN,
+                                                                               stream_for_search_filter_list,
                                                                                stream_size_for_search_filter_list)) { /*prevent 18950*/
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
                        err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
@@ -1145,24 +1138,24 @@ EXPORT_API int email_search_mail_on_server(int input_account_id,
                        goto FINISH_OFF;
                }
 
-               if(output_handle)
+               if (output_handle)
                        emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle);
        }
 
 FINISH_OFF:
-       if(hAPI) {
+       if (hAPI) {
                emipc_destroy_email_api(hAPI);
                hAPI = NULL;
        }
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id)
 {
-       EM_DEBUG_API_BEGIN ("input_account_id[%d]", input_account_id);
+       EM_DEBUG_API_BEGIN("input_account_id[%d]", input_account_id);
 
        int       err = EMAIL_ERROR_NONE;
        int       return_value = 0;
@@ -1180,10 +1173,10 @@ EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id)
 
        memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
 
-       if (em_get_account_server_type_by_account_id(multi_user_name, 
-                                                                                               input_account_id, 
-                                                                                               &account_server_type, 
-                                                                                               true, 
+       if (em_get_account_server_type_by_account_id(multi_user_name,
+                                                                                               input_account_id,
+                                                                                               &account_server_type,
+                                                                                               true,
                                                                                                &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                goto FINISH_OFF;
@@ -1202,32 +1195,30 @@ EXPORT_API int email_clear_result_of_search_mail_on_server(int input_account_id)
                as_noti_data.clear_result_of_search_mail_on_server.account_id          = input_account_id;
                as_noti_data.clear_result_of_search_mail_on_server.multi_user_name     = multi_user_name;
 
-               return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER, 
+               return_value = em_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER,
                                                                                                                                        &as_noti_data);
                if (return_value == false) {
                        EM_DEBUG_EXCEPTION("em_send_notification_to_active_sync_engine failed.");
                        err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
                        goto FINISH_OFF;
                }
-       }
-       else {
+       } else {
                hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER);
 
                EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
-               if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
+               if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
                        err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                        goto FINISH_OFF;
                }
 
-               if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+               if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                        EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
                }
 
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-
                if (err != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("_EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER failed [%d]", err);
                        goto FINISH_OFF;
@@ -1241,13 +1232,13 @@ FINISH_OFF:
        }
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d] handle[%p]", account_id, handle);
+       EM_DEBUG_API_BEGIN("account_id[%d] handle[%p]", account_id, handle);
        int err = EMAIL_ERROR_NONE;
     char *multi_user_name = NULL;
        email_account_server_t account_server_type;
@@ -1255,7 +1246,7 @@ EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
 
        if (account_id <= 0) {
                EM_DEBUG_EXCEPTION("account_id is not valid");
-               err= EMAIL_ERROR_INVALID_PARAM;
+               err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
@@ -1264,7 +1255,7 @@ EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
         goto FINISH_OFF;
     }
 
-       if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false ) {
+       if (em_get_account_server_type_by_account_id(multi_user_name, account_id, &account_server_type, false, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_account_server_type_by_account_id failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -1272,8 +1263,8 @@ EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
        if (account_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                hAPI = emipc_create_email_api(_EMAIL_API_QUERY_SMTP_MAIL_SIZE_LIMIT);
 
-               if (!hAPI ) {
-                       EM_DEBUG_EXCEPTION ("INVALID PARAM: hAPI NULL");
+               if (!hAPI) {
+                       EM_DEBUG_EXCEPTION("INVALID PARAM: hAPI NULL");
                        return EMAIL_ERROR_NULL_VALUE;
                }
 
@@ -1290,7 +1281,7 @@ EXPORT_API int email_query_smtp_mail_size_limit(int account_id, int *handle)
 
                emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
                if (err == EMAIL_ERROR_NONE) {
-                       if(handle)
+                       if (handle)
                                emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
                }
        }
@@ -1300,6 +1291,6 @@ FINISH_OFF:
        hAPI = (HIPC_API)NULL;
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
index 4bd92c0..373d1a7 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -26,8 +26,8 @@
  * This file contains the data structures and interfaces needed for application,
  * to interact with email-service.
  * @file               email-api-rule.c
- * @brief              This file contains the data structures and interfaces of Rule related Functionality provided by 
- *                     email-service . 
+ * @brief              This file contains the data structures and interfaces of Rule related Functionality provided by
+ *                     email-service .
  */
 
 #include "string.h"
@@ -39,7 +39,7 @@
 
 EXPORT_API int email_get_rule(int filter_id, email_rule_t** filtering_set)
 {
-       EM_DEBUG_API_BEGIN ("filter_id[%d] filtering_set[%p]", filter_id, filtering_set);
+       EM_DEBUG_API_BEGIN("filter_id[%d] filtering_set[%p]", filter_id, filtering_set);
 
        int err = 0;
     char *multi_user_name = NULL;
@@ -62,19 +62,19 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 
 EXPORT_API int email_get_rule_list(email_rule_t** filtering_set, int* count)
 {
-       EM_DEBUG_API_BEGIN ();
-       
+       EM_DEBUG_API_BEGIN();
+
        int err = EMAIL_ERROR_NONE;
        int is_completed = 0;
     char *multi_user_name = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
 
@@ -95,20 +95,20 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 
 }
 
 EXPORT_API int email_add_rule(email_rule_t* filtering_set)
 {
-       EM_DEBUG_API_BEGIN ("filtering_set[%p]", filtering_set);
-       
+       EM_DEBUG_API_BEGIN("filtering_set[%p]", filtering_set);
+
        int size = 0;
        int *ret_nth_param = NULL;
        int err = EMAIL_ERROR_NONE;
        char* stream = NULL;
-       
+
        EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM);
 
        if (filtering_set->account_id < 0 || filtering_set->target_mailbox_id < 0) {
@@ -118,22 +118,22 @@ EXPORT_API int email_add_rule(email_rule_t* filtering_set)
        }
 
        /* make rule info */
-       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_RULE);    
+       HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_RULE);
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        stream = em_convert_rule_to_byte_stream(filtering_set, &size);
        EM_PROXY_IF_NULL_RETURN_VALUE(stream, hAPI, EMAIL_ERROR_NULL_VALUE);
-       if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, stream, size)) {
+       if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, stream, size)) {
                EM_DEBUG_EXCEPTION("Add Param Failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        /* pass rule info */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
-       
+
        /* get reult form service */
        if ((ret_nth_param = (int*)emipc_get_nth_parameter_data(hAPI, ePARAMETER_OUT, 0))) {
                err = *ret_nth_param;
@@ -150,52 +150,52 @@ EXPORT_API int email_add_rule(email_rule_t* filtering_set)
 
        emipc_destroy_email_api(hAPI);
        hAPI = NULL;
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_update_rule(int filter_id, email_rule_t* new_set)
 {
-       EM_DEBUG_API_BEGIN ("filter_id[%d] new_set[%p]", filter_id, new_set);
-       
+       EM_DEBUG_API_BEGIN("filter_id[%d] new_set[%p]", filter_id, new_set);
+
        int size = 0;
        char* stream =  NULL;
        int err = EMAIL_ERROR_NONE;
 
        EM_IF_NULL_RETURN_VALUE(filter_id, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(new_set, EMAIL_ERROR_INVALID_PARAM);
-       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_RULE);
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        /* make filter info */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("Add Param filter_id Failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
 
        stream = em_convert_rule_to_byte_stream(new_set, &size);
-       if(NULL == stream) {
+       if (NULL == stream) {
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
-       if(!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, stream, size)){
+       if (!emipc_add_dynamic_parameter(hAPI, ePARAMETER_IN, stream, size)) {
                EM_DEBUG_EXCEPTION("Add Param new_set Failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
-       
+
        /* request update rule with filter info */
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
 
        /* get result */
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-               
+
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -204,83 +204,83 @@ EXPORT_API int email_update_rule(int filter_id, email_rule_t* new_set)
 
 EXPORT_API int email_delete_rule(int filter_id)
 {
-       EM_DEBUG_API_BEGIN ("filter_id[%d]", filter_id);
-       
+       EM_DEBUG_API_BEGIN("filter_id[%d]", filter_id);
+
        int err = EMAIL_ERROR_NONE;
-               
+
        EM_IF_NULL_RETURN_VALUE(filter_id, EMAIL_ERROR_INVALID_PARAM);
-                       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_RULE);
-       
+
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
-       
+
        /* filter_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
-               
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
-       
+
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
-EXPORT_API int email_free_rule (email_rule_t** filtering_set, int count)
+EXPORT_API int email_free_rule(email_rule_t** filtering_set, int count)
 {
-       EM_DEBUG_FUNC_BEGIN ();
-       int err = EMAIL_ERROR_NONE, i;  
+       EM_DEBUG_FUNC_BEGIN();
+       int err = EMAIL_ERROR_NONE, i;
 
        EM_IF_NULL_RETURN_VALUE(filtering_set, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM);
-       
+
        if (count > 0)  {
                email_rule_t* p = *filtering_set;
-               
+
                for (i = 0; i < count; i++)
                        emcore_free_rule(p + i);
-               
+
                EM_SAFE_FREE(p);
                *filtering_set = NULL;
        }
-       
-       EM_DEBUG_FUNC_END ("err[%d]", err);
+
+       EM_DEBUG_FUNC_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_apply_rule(int filter_id)
 {
-       EM_DEBUG_API_BEGIN ("filter_id[%d]", filter_id);
-       
+       EM_DEBUG_API_BEGIN("filter_id[%d]", filter_id);
+
        int err = EMAIL_ERROR_NONE;
-               
+
        EM_IF_NULL_RETURN_VALUE(filter_id, EMAIL_ERROR_INVALID_PARAM);
-                       
+
        HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_APPLY_RULE);
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
-       
+
        /* filter_id */
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_NULL_VALUE);
        }
-               
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE);
        }
-       
+
        emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
        emipc_destroy_email_api(hAPI);
 
        hAPI = NULL;
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
index 70d85ee..1b52e2f 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -27,7 +27,7 @@
  * to interact with Email Engine.
  * @file               email-api-smime.c
  * @brief              This file contains the data structures and interfaces of SMIME related Functionality provided by
- *                     Email Engine . 
+ *                     Email Engine .
  */
 
 #include "string.h"
 #include "email-core-signal.h"
 #include "email-ipc.h"
 
-EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data, 
-                                                                               email_attachment_data_t **output_attachment_data, 
+EXPORT_API int email_get_decrypt_message(int mail_id, email_mail_data_t **output_mail_data,
+                                                                               email_attachment_data_t **output_attachment_data,
                                                                                int *output_attachment_count, int *verify)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d]", mail_id);
+       EM_DEBUG_API_BEGIN("mail_id[%d]", mail_id);
        int err = EMAIL_ERROR_NONE;
        int p_output_attachment_count = 0;
     int i = 0;
@@ -162,19 +162,19 @@ FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
-EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data, 
-                                                                                       email_attachment_data_t *input_attachment_data, 
+EXPORT_API int email_get_decrypt_message_ex(email_mail_data_t *input_mail_data,
+                                                                                       email_attachment_data_t *input_attachment_data,
                                                                                        int input_attachment_count,
-                                            email_mail_data_t **output_mail_data, 
-                                                                                       email_attachment_data_t **output_attachment_data, 
+                                            email_mail_data_t **output_mail_data,
+                                                                                       email_attachment_data_t **output_attachment_data,
                                                                                        int *output_attachment_count,
                                                                                        int *verify)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
        int err = EMAIL_ERROR_NONE;
     int i = 0;
        char *decrypt_filepath = NULL;
@@ -267,13 +267,13 @@ FINISH_OFF:
        if (p_account_tbl)
                emstorage_free_account(&p_account_tbl, 1, NULL);
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_verify_signature(int mail_id, int *verify)
 {
-       EM_DEBUG_API_BEGIN ("mail_id[%d]", mail_id);
+       EM_DEBUG_API_BEGIN("mail_id[%d]", mail_id);
 
        if (mail_id <= 0) {
                EM_DEBUG_EXCEPTION("Invalid parameter");
@@ -318,13 +318,13 @@ FINISH_OFF:
        if (verify != NULL)
                *verify = p_verify;
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_verify_signature_ex(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data, int input_attachment_count, int *verify)
 {
-       EM_DEBUG_API_BEGIN ();
+       EM_DEBUG_API_BEGIN();
 
        if (!input_mail_data || !input_attachment_data || input_attachment_count <= 0) {
                EM_DEBUG_EXCEPTION("Invalid parameter");
@@ -347,11 +347,11 @@ EXPORT_API int email_verify_signature_ex(email_mail_data_t *input_mail_data, ema
 
        if (input_mail_data->smime_type == EMAIL_SMIME_SIGNED) {
                emcore_init_openssl_library();
-               if (!emcore_verify_signature(input_attachment_data[count].attachment_path, input_mail_data->file_path_mime_entity, verify, &err)) 
+               if (!emcore_verify_signature(input_attachment_data[count].attachment_path, input_mail_data->file_path_mime_entity, verify, &err))
                        EM_DEBUG_EXCEPTION("emcore_verify_signature failed : [%d]", err);
 
                emcore_clean_openssl_library();
-       } else if(input_mail_data->smime_type == EMAIL_PGP_SIGNED) {
+       } else if (input_mail_data->smime_type == EMAIL_PGP_SIGNED) {
                if ((err = emcore_pgp_get_verify_signature(input_attachment_data[count].attachment_path, input_mail_data->file_path_mime_entity, input_mail_data->digest_type, verify)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_EXCEPTION("emcore_pgp_get_verify_siganture failed : [%d]", err);
        } else {
@@ -360,7 +360,7 @@ EXPORT_API int email_verify_signature_ex(email_mail_data_t *input_mail_data, ema
        }
 
 
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
@@ -375,7 +375,7 @@ EXPORT_API int email_check_ocsp_status(char *email_address, char *response_url,
        HIPC_API hAPI = NULL;
 
        hAPI = emipc_create_email_api(_EMAIL_API_CHECK_OCSP_STATUS);
-       
+
        EM_IF_NULL_RETURN_VALUE(hAPI, EMAIL_ERROR_NULL_VALUE);
 
        if (!emipc_add_parameter(hAPI, ePARAMETER_IN, email_address, EM_SAFE_STRLEN(email_address)+1)) {
@@ -402,9 +402,9 @@ EXPORT_API int email_check_ocsp_status(char *email_address, char *response_url,
 */
 EXPORT_API int email_validate_certificate(int account_id, char *email_address, unsigned *handle)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d]", account_id);
+       EM_DEBUG_API_BEGIN("account_id[%d]", account_id);
        EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d] email_address[%s] handle[%p]", account_id, email_address, handle);
-       
+
        EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(email_address, EMAIL_ERROR_INVALID_PARAM);
 
@@ -436,7 +436,7 @@ EXPORT_API int email_validate_certificate(int account_id, char *email_address, u
        if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_handle_for_activesync_failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
-               goto FINISH_OFF;                
+               goto FINISH_OFF;
        }
 
        as_noti_data.validate_certificate.handle = as_handle;
@@ -456,15 +456,15 @@ EXPORT_API int email_validate_certificate(int account_id, char *email_address, u
 FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
 
 EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address, unsigned *handle)
 {
-       EM_DEBUG_API_BEGIN ("account_id[%d]", account_id);
+       EM_DEBUG_API_BEGIN("account_id[%d]", account_id);
        EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d] email_address[%s] handle[%p]", account_id, email_address, handle);
-       
+
        EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM);
        EM_IF_NULL_RETURN_VALUE(email_address, EMAIL_ERROR_INVALID_PARAM);
 
@@ -496,7 +496,7 @@ EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address,
        if (em_get_handle_for_activesync(&as_handle, &err) == false) {
                EM_DEBUG_EXCEPTION("em_get_handle_for_activesync_failed[%d]", err);
                err = EMAIL_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
-               goto FINISH_OFF;                
+               goto FINISH_OFF;
        }
 
        as_noti_data.get_resolve_recipients.handle          = as_handle;
@@ -516,6 +516,6 @@ EXPORT_API int email_get_resolve_recipients(int account_id, char *email_address,
 FINISH_OFF:
 
     EM_SAFE_FREE(multi_user_name);
-       EM_DEBUG_API_END ("err[%d]", err);
+       EM_DEBUG_API_END("err[%d]", err);
        return err;
 }
index 35c582d..d12ca65 100755 (executable)
@@ -12,7 +12,7 @@
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
+* distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
@@ -219,7 +219,7 @@ INTERNAL_FUNC int em_convert_mailbox_to_mailbox_tbl(email_mailbox_t *mailbox, em
        mailbox_tbl->deleted_flag               = mailbox->deleted_flag;
        mailbox_tbl->eas_data_length            = mailbox->eas_data_length;
 
-       if ((mailbox->eas_data_length>0) && mailbox->eas_data) {
+       if ((mailbox->eas_data_length > 0) && mailbox->eas_data) {
                if ((mailbox_tbl->eas_data = em_malloc(mailbox->eas_data_length)) == NULL) {
                        EM_DEBUG_EXCEPTION("em_malloc failed");
                        return 0; /*prevent 53448*/
@@ -251,7 +251,7 @@ INTERNAL_FUNC int em_convert_mailbox_tbl_to_mailbox(emstorage_mailbox_tbl_t *mai
        mailbox->deleted_flag               = mailbox_tbl->deleted_flag;
        mailbox->eas_data_length            = mailbox_tbl->eas_data_length;
 
-       if ((mailbox_tbl->eas_data_length >0) && mailbox_tbl->eas_data) {
+       if ((mailbox_tbl->eas_data_length > 0) && mailbox_tbl->eas_data) {
                if ((mailbox->eas_data = em_malloc(mailbox_tbl->eas_data_length)) == NULL) {
                        EM_DEBUG_EXCEPTION("em_malloc failed");
                        return 0; /*prevent 53445*/
@@ -278,13 +278,13 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_ta
 
        temp_mail_data = em_malloc(sizeof(email_mail_data_t) * item_count);
 
-       if(!temp_mail_data) {
+       if (!temp_mail_data) {
                EM_DEBUG_EXCEPTION("em_malloc failed");
                err_code = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < item_count; i++) {
+       for (i = 0; i < item_count; i++) {
                temp_mail_data[i].mail_id                 = mail_table_data[i].mail_id;
                temp_mail_data[i].account_id              = mail_table_data[i].account_id;
                temp_mail_data[i].mailbox_id              = mail_table_data[i].mailbox_id;
@@ -338,8 +338,8 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_ta
                temp_mail_data[i].replied_time            = mail_table_data[i].replied_time;
                temp_mail_data[i].forwarded_time          = mail_table_data[i].forwarded_time;
                temp_mail_data[i].eas_data_length         = mail_table_data[i].eas_data_length;
-               if(mail_table_data[i].eas_data_length && mail_table_data[i].eas_data) {
-                       if((temp_mail_data[i].eas_data = em_malloc(mail_table_data[i].eas_data_length)) == NULL) {
+               if (mail_table_data[i].eas_data_length && mail_table_data[i].eas_data) {
+                       if ((temp_mail_data[i].eas_data = em_malloc(mail_table_data[i].eas_data_length)) == NULL) {
                                EM_DEBUG_EXCEPTION("em_malloc failed");
                                err_code = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -355,11 +355,11 @@ INTERNAL_FUNC int em_convert_mail_tbl_to_mail_data(emstorage_mail_tbl_t *mail_ta
        ret = true;
 FINISH_OFF:
 
-       if(ret == false && temp_mail_data) {
+       if (ret == false && temp_mail_data) {
                emcore_free_mail_data_list(&temp_mail_data, item_count);
        }
 
-       if(error)
+       if (error)
                *error = err_code;
 
        EM_DEBUG_FUNC_END();
@@ -380,13 +380,13 @@ INTERNAL_FUNC int   em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_dat
 
        temp_mail_tbl = em_malloc(sizeof(emstorage_mail_tbl_t) * item_count);
 
-       if(!temp_mail_tbl) {
+       if (!temp_mail_tbl) {
                EM_DEBUG_EXCEPTION("em_malloc failed");
                err_code = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < item_count; i++) {
+       for (i = 0; i < item_count; i++) {
                temp_mail_tbl[i].mail_id                 = mail_data[i].mail_id;
                temp_mail_tbl[i].account_id              = mail_data[i].account_id;
                temp_mail_tbl[i].mailbox_id              = mail_data[i].mailbox_id;
@@ -440,8 +440,8 @@ INTERNAL_FUNC int   em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_dat
                temp_mail_tbl[i].replied_time            = mail_data[i].replied_time;
                temp_mail_tbl[i].forwarded_time          = mail_data[i].forwarded_time;
                temp_mail_tbl[i].eas_data_length         = mail_data[i].eas_data_length;
-               if(mail_data[i].eas_data_length && mail_data[i].eas_data) {
-                       if((temp_mail_tbl[i].eas_data = em_malloc(mail_data[i].eas_data_length)) == NULL) {
+               if (mail_data[i].eas_data_length && mail_data[i].eas_data) {
+                       if ((temp_mail_tbl[i].eas_data = em_malloc(mail_data[i].eas_data_length)) == NULL) {
                                EM_DEBUG_EXCEPTION("em_malloc failed");
                                err_code = EMAIL_ERROR_OUT_OF_MEMORY;
                                /*prevent 44357*/
@@ -462,7 +462,7 @@ INTERNAL_FUNC int   em_convert_mail_data_to_mail_tbl(email_mail_data_t *mail_dat
        ret = true;
 FINISH_OFF:
 
-       if(error)
+       if (error)
                *error = err_code;
 
        EM_DEBUG_FUNC_END();
@@ -529,11 +529,11 @@ INTERNAL_FUNC int em_convert_time_t_to_string(time_t *input_time, char **output_
 
        temp_time_info = localtime(input_time);
 
-       if(!temp_time_info) {
+       if (!temp_time_info) {
                EM_DEBUG_EXCEPTION("localtime failed.");
                return EMAIL_ERROR_SYSTEM_FAILURE;
        }
-       SNPRINTF(temp_buffer, sizeof(temp_buffer), "%04d%02d%02d%02d%02d%02d",
+       SNPRINTF(temp_buffer, sizeof(temp_buffer), "%04d%02d%02d%02d%02d%02d", 
                temp_time_info->tm_year + 1970, temp_time_info->tm_mon, temp_time_info->tm_mday, temp_time_info->tm_hour, temp_time_info->tm_min, temp_time_info->tm_sec);
 
        *output_datetime_string = EM_SAFE_STRDUP(temp_buffer);
@@ -547,8 +547,8 @@ static char* append_sized_data_to_stream(char *stream, int *stream_len, char *sr
        /* EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_length [%p], input_sized_data [%p], input_data_size [%d]", input_stream, input_output_stream_length, input_sized_data, input_data_size); */
        char *new_stream = NULL;
 
-       if!stream_len || src_len == 0 || src == NULL || (stream != NULL && *stream_len == 0) ||
-                       (stream == NULL && *stream_len != 0) ) {
+       if (!stream_len || src_len == 0 || src == NULL || (stream != NULL && *stream_len == 0) ||
+                       (stream == NULL && *stream_len != 0)) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return NULL;
        }
@@ -558,12 +558,12 @@ static char* append_sized_data_to_stream(char *stream, int *stream_len, char *sr
        /*TODO: don't increase stream buffer incrementally when appending new data */
        new_stream = (char*)em_malloc(old_stream_len + src_len);
 
-       if(!new_stream) {
+       if (!new_stream) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                return NULL;
        }
 
-       if(stream != NULL)
+       if (stream != NULL)
                memcpy(new_stream, stream, old_stream_len);
 
        memcpy(new_stream + old_stream_len, src, src_len);
@@ -582,8 +582,8 @@ static char* append_string_to_stream(char *input_stream, int *input_output_strea
        char *new_stream = NULL;
        int   data_length = 0;
 
-       if!input_output_stream_length || (input_stream != NULL && *input_output_stream_length == 0) ||
-               (input_stream == NULL && *input_output_stream_length != 0) ) {
+       if (!input_output_stream_length || (input_stream != NULL && *input_output_stream_length == 0) ||
+               (input_stream == NULL && *input_output_stream_length != 0)) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return NULL;
        }
@@ -594,19 +594,19 @@ static char* append_string_to_stream(char *input_stream, int *input_output_strea
 
        new_stream = (char*)em_malloc(source_stream_length + data_length + sizeof(int));
 
-       if(!new_stream) {
+       if (!new_stream) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                return NULL;
        }
 
-       if(input_stream != NULL)
+       if (input_stream != NULL)
                memcpy(new_stream, input_stream, source_stream_length);
 
        /* write string length */
        memcpy(new_stream + source_stream_length, (char*)&data_length, sizeof(int));
 
        /* write string */
-       if(input_source_string)
+       if (input_source_string)
                memcpy(new_stream + source_stream_length + sizeof(int), input_source_string, data_length);
 
        /* for example, "abc" is written to stream buffer with "3abc" */
@@ -622,7 +622,7 @@ static int fetch_sized_data_from_stream(char *input_stream, int *input_output_st
        /* EM_DEBUG_FUNC_BEGIN("input_stream [%p], input_output_stream_offset [%p] input_data_size [%d], output_data[%p]", input_stream, input_output_stream_offset, input_data_size, output_data); */
        int stream_offset = 0;
 
-       if!input_stream || !input_output_stream_offset || !input_data_size || !output_data) {
+       if (!input_stream || !input_output_stream_offset || !input_data_size || !output_data) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -646,7 +646,7 @@ static int fetch_string_from_stream(char *input_stream, int *input_output_stream
        int stream_offset = 0;
        char *result_string = NULL;
 
-       if!input_stream || !input_output_stream_offset || !output_string) {
+       if (!input_stream || !input_output_stream_offset || !output_string) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -659,15 +659,15 @@ static int fetch_string_from_stream(char *input_stream, int *input_output_stream
 
        /*      EM_DEBUG_LOG("string_length [%d]", string_length);      */
 
-       if(string_length != 0) {
+       if (string_length != 0) {
                result_string = (char*)em_malloc(string_length + 1);
-               if(result_string) {
+               if (result_string) {
                        memcpy(result_string, input_stream + stream_offset, string_length);
                        stream_offset += string_length;
                }
        }
        /*
-       if(result_string)
+       if (result_string)
                EM_DEBUG_LOG("result_string [%s]", result_string);
        */
 
@@ -682,7 +682,7 @@ static int fetch_string_from_stream(char *input_stream, int *input_output_stream
 #define EMAIL_ACCOUNT_FMT      "S(" "isiii" "isiis" "sssis" "issii" "iiiii" "iiiis" "issii" "i"\
                                                        "$(" "iiiii" "iisii" "iisii" "iiis" ")" "iiiii" "isiis" "i" ")" "B"
 
-/* For converting fmt : to distinguish between 64bit or 32bit */
+/* For converting fmt: to distinguish between 64bit or 32bit */
 static char *convert_format(char *fmt)
 {
        EM_DEBUG_FUNC_BEGIN();
@@ -741,7 +741,7 @@ static char *convert_format(char *fmt)
                                        /* 64bit */
                                        strncat(converted_fmt, "I", 1);
                                } else {
-                                       EM_DEBUG_LOG("size : [%d]", size);
+                                       EM_DEBUG_LOG("size: [%d]", size);
                                }
 
                                break;
@@ -767,8 +767,8 @@ static char *convert_format(char *fmt)
         c++;
     }
 
-       EM_DEBUG_LOG("original fmt  : [%s]", fmt);
-       EM_DEBUG_LOG("converted_fmt : [%s]", converted_fmt);
+       EM_DEBUG_LOG("original fmt: [%s]", fmt);
+       EM_DEBUG_LOG("converted_fmt: [%s]", converted_fmt);
 
        ret = true;
 
@@ -916,7 +916,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_
        }
 
        tn = tpl_map(converted_fmt, mail_data, &tb);
-       if(!tn) {
+       if (!tn) {
                EM_SAFE_FREE(converted_fmt);
                EM_DEBUG_EXCEPTION("tpl_map failed");
                return;
@@ -926,15 +926,14 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mail_data(char *stream, int stream_
        tpl_load(tn, TPL_MEM, stream, stream_len);
        tpl_unpack(tn, 0);
 
-       if(mail_data->eas_data_length <= 0 || tb.addr == NULL) {
+       if (mail_data->eas_data_length <= 0 || tb.addr == NULL) {
                EM_DEBUG_LOG("No eas data. eas_data_length[%d] addr[%p]", mail_data->eas_data_length, tb.addr);
-       }
-       else {
+       } else {
                EM_DEBUG_LOG("eas_data_length[%d] addr[%p]", mail_data->eas_data_length, tb.addr);
                mail_data->eas_data = tb.addr;
        }
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        EM_DEBUG_FUNC_END();
@@ -969,8 +968,8 @@ INTERNAL_FUNC char* em_convert_attachment_data_to_byte_stream(email_attachment_d
        EM_SAFE_FREE(converted_fmt);
 
        /* if attachment_count is zero, for loop is skipped */
-       int i=0;
-       for( ; (i < attachment_count) && (attachment+i) ; i++ ) {
+       int i = 0;
+       for (; (i < attachment_count) && (attachment+i) ; i++) {
                memcpy(&cur, attachment + i, sizeof(email_attachment_data_t));
                tpl_pack(tn, 1);
        }
@@ -1020,7 +1019,7 @@ INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int s
        /* so, make list and get list count in the first phase, */
        /* and then copy list to var array after allocating memory */
 
-       int num_element = tpl_Alen (tn, 1);
+       int num_element = tpl_Alen(tn, 1);
        email_attachment_data_t *attached = NULL;
        if (num_element > 0)
                attached = (email_attachment_data_t*) em_malloc(sizeof(email_attachment_data_t)*num_element);
@@ -1028,16 +1027,16 @@ INTERNAL_FUNC void em_convert_byte_stream_to_attachment_data(char *stream, int s
        int i = 0;
        while (tpl_unpack(tn, 1) > 0) {
                if (!(attached+i)) {
-                       EM_DEBUG_EXCEPTION ("num element mismatched [%d] vs [%d]", num_element, i);
+                       EM_DEBUG_EXCEPTION("num element mismatched [%d] vs [%d]", num_element, i);
                        num_element = i;
                        break;
                }
                email_attachment_data_t* pdata = attached+i;
                memcpy(pdata, &cur, sizeof(email_attachment_data_t)); /* copy unpacked data to list item */
-               pdata->attachment_name          = EM_SAFE_STRDUP(cur.attachment_name);
-               pdata->attachment_path          = EM_SAFE_STRDUP(cur.attachment_path);
+               pdata->attachment_name           = EM_SAFE_STRDUP(cur.attachment_name);
+               pdata->attachment_path           = EM_SAFE_STRDUP(cur.attachment_path);
                pdata->content_id               = EM_SAFE_STRDUP(cur.content_id);
-               pdata->attachment_mime_type     = EM_SAFE_STRDUP(cur.attachment_mime_type);
+               pdata->attachment_mime_type      = EM_SAFE_STRDUP(cur.attachment_mime_type);
                EM_SAFE_FREE(cur.attachment_name);
                EM_SAFE_FREE(cur.attachment_path);
                EM_SAFE_FREE(cur.content_id);
@@ -1090,7 +1089,7 @@ INTERNAL_FUNC char* em_convert_mailbox_to_byte_stream(email_mailbox_t *mailbox_d
        size_t len = 0;
        tpl_dump(tn, TPL_MEM, &buf, &len);
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        *stream_len = len;
@@ -1126,15 +1125,14 @@ INTERNAL_FUNC void em_convert_byte_stream_to_mailbox(char *stream, int stream_le
        tpl_load(tn, TPL_MEM, stream, stream_len);
        tpl_unpack(tn, 0);
 
-       if(mailbox_data->eas_data_length <= 0 || tb.addr == NULL) {
+       if (mailbox_data->eas_data_length <= 0 || tb.addr == NULL) {
                EM_DEBUG_LOG("No eas data. eas_data_length[%d] addr[%p]", mailbox_data->eas_data_length, tb.addr);
-       }
-       else {
+       } else {
                EM_DEBUG_LOG("eas_data_length[%d] addr[%p]", mailbox_data->eas_data_length, tb.addr);
                mailbox_data->eas_data = tb.addr;
        }
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        EM_DEBUG_FUNC_END("deserialized len %d", stream_len);
@@ -1293,19 +1291,19 @@ INTERNAL_FUNC char* em_convert_meeting_req_to_byte_stream(email_meeting_request_
                return NULL;
        }
 
-       tn = tpl_map(converted_fmt,
-                                               &meeting_req->mail_id,
-                                               &meeting_req->meeting_response,
-                                               &tb[0],
-                                               &tb[1],
-                                               &meeting_req->location,
-                                               &meeting_req->global_object_id,
-                                               &meeting_req->time_zone.offset_from_GMT,
-                                               meeting_req->time_zone.standard_name, 32,
-                                               &tb[2],
-                                               &meeting_req->time_zone.standard_bias,
-                                               meeting_req->time_zone.daylight_name, 32,
-                                               &tb[3],
+       tn = tpl_map(converted_fmt, 
+                                               &meeting_req->mail_id, 
+                                               &meeting_req->meeting_response, 
+                                               &tb[0], 
+                                               &tb[1], 
+                                               &meeting_req->location, 
+                                               &meeting_req->global_object_id, 
+                                               &meeting_req->time_zone.offset_from_GMT, 
+                                               meeting_req->time_zone.standard_name, 32, 
+                                               &tb[2], 
+                                               &meeting_req->time_zone.standard_bias, 
+                                               meeting_req->time_zone.daylight_name, 32, 
+                                               &tb[3], 
                                                &meeting_req->time_zone.daylight_bias
                                );
        if (!tn) {
@@ -1351,19 +1349,19 @@ INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char *stream, int strea
                return;
        }
 
-       tn = tpl_map(converted_fmt,
-                                               &meeting_req->mail_id,
-                                               &meeting_req->meeting_response,
-                                               &tb[0],
-                                               &tb[1],
-                                               &meeting_req->location,
-                                               &meeting_req->global_object_id,
-                                               &meeting_req->time_zone.offset_from_GMT,
-                                               meeting_req->time_zone.standard_name, 32,
-                                               &tb[2],
-                                               &meeting_req->time_zone.standard_bias,
-                                               meeting_req->time_zone.daylight_name, 32,
-                                               &tb[3],
+       tn = tpl_map(converted_fmt, 
+                                               &meeting_req->mail_id, 
+                                               &meeting_req->meeting_response, 
+                                               &tb[0], 
+                                               &tb[1], 
+                                               &meeting_req->location, 
+                                               &meeting_req->global_object_id, 
+                                               &meeting_req->time_zone.offset_from_GMT, 
+                                               meeting_req->time_zone.standard_name, 32, 
+                                               &tb[2], 
+                                               &meeting_req->time_zone.standard_bias, 
+                                               meeting_req->time_zone.daylight_name, 32, 
+                                               &tb[3], 
                                                &meeting_req->time_zone.daylight_bias
                                );
        if (!tn) {
@@ -1382,14 +1380,14 @@ INTERNAL_FUNC void em_convert_byte_stream_to_meeting_req(char *stream, int strea
        memcpy(&meeting_req->time_zone.standard_time_start_date, tb[2].addr, sizeof(struct tm));
        memcpy(&meeting_req->time_zone.daylight_time_start_date, tb[3].addr, sizeof(struct tm));
 
-       int i=0;
-       for(i=0; i< 4 ; i++)
+       int i = 0;
+       for (i = 0; i < 4; i++)
                EM_SAFE_FREE(tb[i].addr);
 
        EM_DEBUG_FUNC_END();
 }
 
-INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_t *input_search_filter_list,
+INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_t *input_search_filter_list, 
                                                                        int input_search_filter_count, int *output_stream_size)
 {
        EM_DEBUG_FUNC_BEGIN("input_search_filter_list [%p] input_search_filter_count [%d]", input_search_filter_list, input_search_filter_count);
@@ -1402,47 +1400,47 @@ INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_
 
        result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_search_filter_count), sizeof(int));
 
-       fori = 0; i < input_search_filter_count; i++) {
+       for (i = 0; i < input_search_filter_count; i++) {
                result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_search_filter_list[i].search_filter_type), sizeof(int));
-               switch(input_search_filter_list[i].search_filter_type) {
-                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO       :
-                       case EMAIL_SEARCH_FILTER_TYPE_UID              :
-                       case EMAIL_SEARCH_FILTER_TYPE_ALL              :
-                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER      :
-                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER     :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED   :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW        :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED    :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD        :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT      :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED     :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT     :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN       :
-                       case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY  :
+               switch (input_search_filter_list[i].search_filter_type) {
+                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO:
+                       case EMAIL_SEARCH_FILTER_TYPE_UID:
+                       case EMAIL_SEARCH_FILTER_TYPE_ALL:
+                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER:
+                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN:
+                       case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY:
                                result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_search_filter_list[i].search_filter_key_value.integer_type_key_value), sizeof(int));
                                break;
 
-                       case EMAIL_SEARCH_FILTER_TYPE_BCC              :
-                       case EMAIL_SEARCH_FILTER_TYPE_BODY             :
-                       case EMAIL_SEARCH_FILTER_TYPE_CC               :
-                       case EMAIL_SEARCH_FILTER_TYPE_FROM             :
-                       case EMAIL_SEARCH_FILTER_TYPE_KEYWORD          :
-                       case EMAIL_SEARCH_FILTER_TYPE_TEXT             :
-                       case EMAIL_SEARCH_FILTER_TYPE_SUBJECT          :
-                       case EMAIL_SEARCH_FILTER_TYPE_TO               :
-                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID       :
-                       case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME  :
-                       case EMAIL_SEARCH_FILTER_TYPE_CHARSET          :
-                       case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED     :
+                       case EMAIL_SEARCH_FILTER_TYPE_BCC:
+                       case EMAIL_SEARCH_FILTER_TYPE_BODY:
+                       case EMAIL_SEARCH_FILTER_TYPE_CC:
+                       case EMAIL_SEARCH_FILTER_TYPE_FROM:
+                       case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:
+                       case EMAIL_SEARCH_FILTER_TYPE_TEXT:
+                       case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:
+                       case EMAIL_SEARCH_FILTER_TYPE_TO:
+                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:
+                       case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:
+                       case EMAIL_SEARCH_FILTER_TYPE_CHARSET:
+                       case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:
                                result_stream = append_string_to_stream(result_stream, &stream_size, input_search_filter_list[i].search_filter_key_value.string_type_key_value);
                                break;
 
-                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
-                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON     :
-                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE  :
+                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE:
+                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON:
+                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE:
                                result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_search_filter_list[i].search_filter_key_value.time_type_key_value), sizeof(time_t));
                                break;
-                       default :
+                       default:
                                EM_DEBUG_EXCEPTION("Invalid filter type [%d]", input_search_filter_list[i].search_filter_type);
                                break;
                }
@@ -1454,7 +1452,7 @@ INTERNAL_FUNC char* em_convert_search_filter_to_byte_stream(email_search_filter_
        return result_stream;
 }
 
-INTERNAL_FUNC void em_convert_byte_stream_to_search_filter(char *input_stream,
+INTERNAL_FUNC void em_convert_byte_stream_to_search_filter(char *input_stream, 
                                email_search_filter_t **output_search_filter_list, int *output_search_filter_count)
 {
        EM_DEBUG_FUNC_BEGIN("input_stream [%p] output_search_filter_list [%p] output_search_filter_count [%p]", input_stream, output_search_filter_list, output_search_filter_count);
@@ -1470,61 +1468,61 @@ INTERNAL_FUNC void em_convert_byte_stream_to_search_filter(char *input_stream,
 
        fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(local_search_filter_count));
 
-       if(local_search_filter_count == 0) {
+       if (local_search_filter_count == 0) {
                EM_DEBUG_EXCEPTION("local_search_filter_count is 0.");
                goto FINISH_OFF;
        }
 
        local_search_filter = em_malloc(sizeof(email_search_filter_t) * local_search_filter_count);
 
-       if(local_search_filter == NULL) {
+       if (local_search_filter == NULL) {
                EM_DEBUG_EXCEPTION("em_malloc for local_search_filter failed");
                goto FINISH_OFF;
        }
 
        *output_search_filter_count = local_search_filter_count;
 
-       fori = 0; i < local_search_filter_count; i++) {
+       for (i = 0; i < local_search_filter_count; i++) {
                fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(local_search_filter[i].search_filter_type));
-               switch(local_search_filter[i].search_filter_type) {
-                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO       :
-                       case EMAIL_SEARCH_FILTER_TYPE_UID              :
-                       case EMAIL_SEARCH_FILTER_TYPE_ALL              :
-                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER      :
-                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER     :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED   :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW        :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED    :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD        :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT      :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED     :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT     :
-                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN       :
-                       case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY  :
+               switch (local_search_filter[i].search_filter_type) {
+                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO:
+                       case EMAIL_SEARCH_FILTER_TYPE_UID:
+                       case EMAIL_SEARCH_FILTER_TYPE_ALL:
+                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER:
+                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT:
+                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN:
+                       case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY:
                                fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(int), (char*)&(local_search_filter[i].search_filter_key_value.integer_type_key_value));
                                break;
 
-                       case EMAIL_SEARCH_FILTER_TYPE_BCC              :
-                       case EMAIL_SEARCH_FILTER_TYPE_BODY             :
-                       case EMAIL_SEARCH_FILTER_TYPE_CC               :
-                       case EMAIL_SEARCH_FILTER_TYPE_FROM             :
-                       case EMAIL_SEARCH_FILTER_TYPE_KEYWORD          :
-                       case EMAIL_SEARCH_FILTER_TYPE_TEXT             :
-                       case EMAIL_SEARCH_FILTER_TYPE_SUBJECT          :
-                       case EMAIL_SEARCH_FILTER_TYPE_TO               :
-                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID       :
-                       case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME  :
-                       case EMAIL_SEARCH_FILTER_TYPE_CHARSET          :
-                       case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED     :
+                       case EMAIL_SEARCH_FILTER_TYPE_BCC:
+                       case EMAIL_SEARCH_FILTER_TYPE_BODY:
+                       case EMAIL_SEARCH_FILTER_TYPE_CC:
+                       case EMAIL_SEARCH_FILTER_TYPE_FROM:
+                       case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:
+                       case EMAIL_SEARCH_FILTER_TYPE_TEXT:
+                       case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:
+                       case EMAIL_SEARCH_FILTER_TYPE_TO:
+                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:
+                       case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:
+                       case EMAIL_SEARCH_FILTER_TYPE_CHARSET:
+                       case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:
                                fetch_string_from_stream(input_stream, &stream_offset, &(local_search_filter[i].search_filter_key_value.string_type_key_value));
                                break;
 
-                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
-                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON     :
-                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE  :
+                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE:
+                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON:
+                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE:
                                fetch_sized_data_from_stream(input_stream, &stream_offset, sizeof(time_t), (char*)&(local_search_filter[i].search_filter_key_value.time_type_key_value));
                                break;
-                       default :
+                       default:
                                EM_DEBUG_EXCEPTION("Invalid filter type [%d]", local_search_filter[i].search_filter_type);
                                break;
                }
@@ -1556,7 +1554,7 @@ INTERNAL_FUNC char* em_convert_task_information_to_byte_stream(email_task_inform
                return NULL;
        }
 
-       for( ; i < input_task_information_count ; i++ ) {
+       for (; i < input_task_information_count ; i++) {
                memcpy(&cur, input_task_information + i, sizeof(email_task_information_t));
                tpl_pack(tn, 1);
        }
@@ -1589,14 +1587,14 @@ INTERNAL_FUNC void em_convert_byte_stream_to_task_information(char *input_stream
                return;
        }
        tpl_load(tn, TPL_MEM, input_stream, input_stream_len);
-       int num_element = tpl_Alen (tn, 1);
+       int num_element = tpl_Alen(tn, 1);
        email_task_information_t* deserialized = NULL;
        if (num_element > 0)
                deserialized = (email_task_information_t*) em_malloc(sizeof(email_task_information_t)*num_element);
 
-       whiletpl_unpack(tn, 1) > 0) {
+       while (tpl_unpack(tn, 1) > 0) {
                if (!(deserialized+i)) {
-                       EM_DEBUG_EXCEPTION ("num element mismatched [%d] vs [%d]", num_element, i);
+                       EM_DEBUG_EXCEPTION("num element mismatched [%d] vs [%d]", num_element, i);
                        num_element = i;
                        break;
                }
index 5d0906c..96cfb9c 100755 (executable)
@@ -48,7 +48,7 @@ INTERNAL_FUNC void* em_malloc(int len)
 {
        /* EM_DEBUG_LOG("Memory allocation size[%d] bytes", len); */
        if (len <= 0) {
-               EM_DEBUG_LOG ("len should be positive.[%d]", len);
+               EM_DEBUG_LOG("len should be positive.[%d]", len);
                return NULL;
        }
 
@@ -68,11 +68,11 @@ INTERNAL_FUNC void* em_memdup(void* src, int len)
 {
        /* EM_DEBUG_LOG("Memory allocation size[%d] bytes", len); */
        if (len <= 0) {
-               EM_DEBUG_LOG ("len should be positive.[%d]", len);
+               EM_DEBUG_LOG("len should be positive.[%d]", len);
                return NULL;
        }
 
-       void *p = calloc(1,len);
+       void *p = calloc(1, len);
        if (!p) {
                EM_DEBUG_EXCEPTION("malloc failed");
                return NULL;
@@ -115,9 +115,9 @@ INTERNAL_FUNC char *em_trim_right(char *str)
        /* EM_DEBUG_FUNC_BEGIN() */
        if (!str) return NULL;
 
-       p = str+EM_SAFE_STRLEN(str)-1;
+       p = str + EM_SAFE_STRLEN(str) - 1;
        while ((p >= str) && (*p == ' ' || *p == '\t' || *p == LF || *p == CR))
-               *p --= '\0';
+               *p-- = '\0';
 
        if (p < str)
                return NULL;
@@ -151,12 +151,10 @@ INTERNAL_FUNC int em_upper_path(char *path)
        for (; i < len; i++) {
                if (path[i] == '&' || path[i] == 5) {
                        is_utf7 = 1;
-               }
-               else {
+               } else {
                        if (is_utf7) {
                                if (path[i] == '-') is_utf7 = 0;
-                       }
-                       else {
+                       } else {
                                path[i] = toupper(path[i]);
                        }
                }
@@ -338,7 +336,7 @@ INTERNAL_FUNC char* em_replace_string(char *source_string, char *old_string, cha
                return NULL;
        }
 
-       buffer_length   = EM_SAFE_STRLEN(source_string) + 1024;
+       buffer_length    = EM_SAFE_STRLEN(source_string) + 1024;
        result_buffer  = (char *)em_malloc(buffer_length);
 
        if (!result_buffer) {
@@ -450,13 +448,13 @@ INTERNAL_FUNC int em_get_file_name_from_file_path(char *input_source_file_path,
        end_pos_of_file_path = input_source_file_path + pos_on_string;
        end_pos_of_file_name = end_pos_of_file_path;
 
-       while(pos_on_string >= 0 && input_source_file_path[pos_on_string] != '/') {
+       while (pos_on_string >= 0 && input_source_file_path[pos_on_string] != '/') {
                pos_on_string--;
        }
 
        pos_on_string++;
 
-       if(pos_on_string >= 0) {
+       if (pos_on_string >= 0) {
                start_pos_of_file_name = input_source_file_path + pos_on_string;
                file_name_length       = end_pos_of_file_name - start_pos_of_file_name + 1;
                memcpy(file_name_string, start_pos_of_file_name, file_name_length);
@@ -495,9 +493,9 @@ INTERNAL_FUNC int em_get_file_name_and_extension_from_file_path(char *input_sour
        end_pos_of_file_path = input_source_file_path + pos_on_string;
        end_pos_of_file_name = end_pos_of_file_path;
 
-       while(pos_on_string >= 0 && input_source_file_path[pos_on_string] != '/') {
-               if(input_source_file_path[pos_on_string] == '.') {
-                       if(dot_pos_of_file_path == NULL) {
+       while (pos_on_string >= 0 && input_source_file_path[pos_on_string] != '/') {
+               if (input_source_file_path[pos_on_string] == '.') {
+                       if (dot_pos_of_file_path == NULL) {
                                end_pos_of_file_name = input_source_file_path + pos_on_string;
                                dot_pos_of_file_path = end_pos_of_file_name;
                        }
@@ -507,13 +505,13 @@ INTERNAL_FUNC int em_get_file_name_and_extension_from_file_path(char *input_sour
 
        pos_on_string++;
 
-       if(pos_on_string >= 0) {
+       if (pos_on_string >= 0) {
                start_pos_of_file_name = input_source_file_path + pos_on_string;
                file_name_length       = end_pos_of_file_name - start_pos_of_file_name;
                memcpy(file_name_string, start_pos_of_file_name, file_name_length);
        }
 
-       if(dot_pos_of_file_path != NULL) {
+       if (dot_pos_of_file_path != NULL) {
                extention_length       = (end_pos_of_file_path + 1) - (dot_pos_of_file_path + 1);
                memcpy(extension_string, dot_pos_of_file_path + 1, extention_length);
        }
@@ -542,7 +540,7 @@ INTERNAL_FUNC char *em_get_extension_from_file_path(char *source_file_path, int
 
        pos_on_string = EM_SAFE_STRLEN(source_file_path) - 1;
 
-       while(pos_on_string >= 0 && source_file_path[pos_on_string] != '.') {
+       while (pos_on_string >= 0 && source_file_path[pos_on_string] != '.') {
                pos_on_string--;
        }
 
@@ -648,20 +646,20 @@ INTERNAL_FUNC int em_get_encoding_type_from_file_path(const char *input_file_pat
 
        enf_of_string = pos_of_filename = EM_SAFE_STRLEN(input_file_path);
 
-       while(pos_of_filename > 0 && input_file_path[pos_of_filename--] != '/') {
-               if(input_file_path[pos_of_filename] == '.')
+       while (pos_of_filename > 0 && input_file_path[pos_of_filename--] != '/') {
+               if (input_file_path[pos_of_filename] == '.')
                        pos_of_dot = pos_of_filename;
        }
 
-       if(pos_of_filename != 0)
+       if (pos_of_filename != 0)
                pos_of_filename += 2;
 
-       if(pos_of_dot != 0 && pos_of_dot > pos_of_filename)
+       if (pos_of_dot != 0 && pos_of_dot > pos_of_filename)
                result_string_length = pos_of_dot - pos_of_filename;
        else
                result_string_length = enf_of_string - pos_of_filename;
 
-       if( !(result_encoding_type = em_malloc(sizeof(char) * (result_string_length + 1))) ) {
+       if (!(result_encoding_type = em_malloc(sizeof(char) * (result_string_length + 1)))) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                err  = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -690,9 +688,9 @@ INTERNAL_FUNC int em_get_content_type_from_extension_string(const char *extensio
                goto FINISH_OFF;
        }
 
-       while(image_extension[i]) {
+       while (image_extension[i]) {
                EM_DEBUG_LOG("image_extension[%d] [%s]", i, image_extension[i]);
-               if(strcasecmp(image_extension[i], extension_string) == 0) {
+               if (strcasecmp(image_extension[i], extension_string) == 0) {
                        break;
                }
                i++;
@@ -730,10 +728,10 @@ FINISH_OFF:
        return result_content_type;
 }
 
-#define EMAIL_ATOM                             "([^]()<>@,;:\\\".[\x20\x01-\x1f\x7f])+"  // x20: space,
+#define EMAIL_ATOM                             "([^]()<>@, ;:\\\".[\x20\x01-\x1f\x7f])+"  // x20: space,
 #define EMAIL_QTEXT                            "[^\"\\\x0d]" /* " \ CR */
 #define EMAIL_DTEXT                            "[^][\\\x0d]" /* [ ] \ CR */
-#define EMAIL_QUOTED_PAIR                      "([\\].)" // first char :\ second char : anything (.)
+#define EMAIL_QUOTED_PAIR                      "([\\].)" // first char:\ second char: anything (.)
 #define EMAIL_QUOTED_STRING                    "[\"](" EMAIL_QTEXT "|" EMAIL_QUOTED_PAIR ")*[\"]"
 #define EMAIL_WORD                             "(" EMAIL_ATOM "|" EMAIL_QUOTED_STRING ")"
 #define EMAIL_PHRASE                           "(" EMAIL_ATOM "|" EMAIL_QUOTED_STRING ")"
@@ -746,7 +744,7 @@ FINISH_OFF:
 #define EMAIL_ADDR_SPEC                        "(" EMAIL_LOCAL_PART "@" EMAIL_DOMAIN ")"
 
 #define EMAIL_MAILBOX                          "("EMAIL_ADDR_SPEC "|" EMAIL_PHRASE "[[:space:]]*" "<" EMAIL_ADDR_SPEC ">|<" EMAIL_ADDR_SPEC ">)"
-#define EMAIL_ADDRESS                          "^([:blank:]*" EMAIL_MAILBOX "[,;[:blank:]]*([,;][,;[:blank:]]*" EMAIL_MAILBOX "[,;[:blank:]]*)*)$"
+#define EMAIL_ADDRESS                          "^([:blank:]*" EMAIL_MAILBOX "[, ;[:blank:]]*([, ;][, ;[:blank:]]*" EMAIL_MAILBOX "[, ;[:blank:]]*)*)$"
 
 
 static int em_verify_email_address_by_using_regex(char *address)
@@ -760,35 +758,35 @@ static int em_verify_email_address_by_using_regex(char *address)
        int alias_len = 0;
        regmatch_t *pmatch = NULL;
 
-       if(!address || EM_SAFE_STRLEN(address) == 0) {
+       if (!address || EM_SAFE_STRLEN(address) == 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
        reg_rule = EMAIL_ADDRESS;
 
-       if (regcomp (&alias_list_regex, reg_rule, REG_ICASE | REG_EXTENDED) != 0) {
+       if (regcomp(&alias_list_regex, reg_rule, REG_ICASE | REG_EXTENDED) != 0) {
                EM_DEBUG_EXCEPTION("email alias regex unrecognized");
                error = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
        }
 
        alias_len = EM_SAFE_STRLEN(address) + 1;
-       pmatch = (regmatch_t *) em_malloc (alias_len * sizeof (regmatch_t));
+       pmatch = (regmatch_t *)em_malloc(alias_len * sizeof(regmatch_t));
        if (!pmatch) {
                EM_DEBUG_EXCEPTION("em_malloc error");
                goto FINISH_OFF;
        }
 
-       if (regexec (&alias_list_regex, address, alias_len, pmatch, 0) == REG_NOMATCH) {
-               EM_DEBUG_LOG_SEC("failed :[%s]", address);
+       if (regexec(&alias_list_regex, address, alias_len, pmatch, 0) == REG_NOMATCH) {
+               EM_DEBUG_LOG_SEC("failed:[%s]", address);
                error = EMAIL_ERROR_INVALID_ADDRESS;
                goto FINISH_OFF;
        }
 
 FINISH_OFF:
        regfree(&alias_list_regex);
-       EM_SAFE_FREE (pmatch);
+       EM_SAFE_FREE(pmatch);
 
        EM_DEBUG_FUNC_END("err [%d]", error);
        return error;
@@ -921,7 +919,7 @@ INTERNAL_FUNC int em_verify_email_address(char *address)
 
        EM_DEBUG_LOG("LC_ALL[%s]" , result_locale);
 
-       if ( EM_SAFE_STRCMP(result_locale, "or_IN.UTF-8") == 0)
+       if (EM_SAFE_STRCMP(result_locale, "or_IN.UTF-8") == 0)
                error = em_verify_email_address_without_regex(address);
        else
                error = em_verify_email_address_by_using_regex(address);
@@ -930,7 +928,7 @@ INTERNAL_FUNC int em_verify_email_address(char *address)
        return error;
 }
 
-INTERNAL_FUNC int em_verify_email_address_of_mail_data (email_mail_data_t *mail_data)
+INTERNAL_FUNC int em_verify_email_address_of_mail_data(email_mail_data_t *mail_data)
 {
        EM_DEBUG_FUNC_BEGIN("mail_data[%p]", mail_data);
        char *address_array[4] = { mail_data->full_address_from, mail_data->full_address_to, mail_data->full_address_cc, mail_data->full_address_bcc};
@@ -939,7 +937,7 @@ INTERNAL_FUNC int em_verify_email_address_of_mail_data (email_mail_data_t *mail_
        /* check for email_address validation */
        for (i = 0; i < 4; i++) {
                if (address_array[i] && address_array[i][0] != 0) {
-                       err = em_verify_email_address (address_array[i]);
+                       err = em_verify_email_address(address_array[i]);
                        if (err != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION_SEC("em_verify_email_address error[%d] idx[%d] addr[%s]", err, i, address_array[i]);
                                goto FINISH_OFF;
@@ -954,13 +952,13 @@ FINISH_OFF:
 INTERNAL_FUNC int em_verify_email_address_of_mail_tbl(emstorage_mail_tbl_t *input_mail_tbl)
 {
        EM_DEBUG_FUNC_BEGIN("input_mail_tbl[%p]", input_mail_tbl);
-       char *address_array[4] = { input_mail_tbl->full_address_to, input_mail_tbl->full_address_cc, input_mail_tbl->full_address_bcc, input_mail_tbl->full_address_from};
+       char *address_array[4] = {input_mail_tbl->full_address_to, input_mail_tbl->full_address_cc, input_mail_tbl->full_address_bcc, input_mail_tbl->full_address_from};
        int  err = EMAIL_ERROR_NONE, i;
 
        /* check for email_address validation */
        for (i = 0; i < 4; i++) {
                if (address_array[i] && address_array[i][0] != 0) {
-                       if ((err = em_verify_email_address (address_array[i])) != EMAIL_ERROR_NONE) {
+                       if ((err = em_verify_email_address(address_array[i])) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION_SEC("em_verify_email_address error[%d] idx[%d] addr[%s]", err, i, address_array[i]);
                                goto FINISH_OFF;
                        }
@@ -991,23 +989,21 @@ INTERNAL_FUNC int em_find_tag_for_thread_view(char *subject, int *result)
        }
 
        em_upper_string(copy_of_subject);
-       EM_DEBUG_LOG_SEC("em_upper_string result : %s\n", copy_of_subject);
+       EM_DEBUG_LOG_SEC("em_upper_string result: %s\n", copy_of_subject);
 
        if (strstr(copy_of_subject, "RE:") == NULL) {
                if (strstr(copy_of_subject, "FWD:") == NULL) {
                        if (strstr(copy_of_subject, "FW:") != NULL)
                                *result = TRUE;
-               }
-               else
+               } else
                        *result = TRUE;
-       }
-       else
+       } else
                *result = TRUE;
 
 FINISH_OFF:
        EM_SAFE_FREE(copy_of_subject);
 
-       EM_DEBUG_FUNC_END("result : %d", *result);
+       EM_DEBUG_FUNC_END("result: %d", *result);
 
        return error_code;
 }
@@ -1037,7 +1033,7 @@ INTERNAL_FUNC int em_find_pos_stripped_subject_for_thread_view(char *subject, ch
        result = g_strrstr(curpos, ": ");
        if (result != NULL) {
                curpos = result + 2;
-               EM_DEBUG_LOG("result : %s", curpos);
+               EM_DEBUG_LOG("result: %s", curpos);
        }
 
        gap = curpos - copy_of_subject;
@@ -1102,8 +1098,7 @@ INTERNAL_FUNC int em_decode_base64(unsigned char *enc_text, unsigned long enc_le
     content = rfc822_base64(text, size, dec_len);
     if (content)
         *dec_text = (char *)content;
-    else
-    {
+    else {
         err = EMAIL_ERROR_UNKNOWN;
         ret = false;
     }
@@ -1119,34 +1114,34 @@ INTERNAL_FUNC int em_get_account_server_type_by_account_id(char *multi_user_name
        EM_DEBUG_FUNC_BEGIN();
        emstorage_account_tbl_t *account_tbl_data = NULL;
        int ret = false;
-       int err= EMAIL_ERROR_NONE;
+       int err = EMAIL_ERROR_NONE;
 
-       if (account_server_type == NULL ) {
+       if (account_server_type == NULL) {
                EM_DEBUG_EXCEPTION("account_server_type is NULL");
                err = EMAIL_ERROR_INVALID_PARAM;
                ret = false;
                goto FINISH_OFF;
        }
 
-       if!emstorage_get_account_by_id(multi_user_name, account_id, WITHOUT_OPTION, &account_tbl_data, false, &err)) {
-               EM_DEBUG_EXCEPTION ("emstorage_get_account_by_id failed [%d] ", err);
+       if (!emstorage_get_account_by_id(multi_user_name, account_id, WITHOUT_OPTION, &account_tbl_data, false, &err)) {
+               EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d] ", err);
                ret = false;
                goto FINISH_OFF;
        }
 
-       if ( flag == false )  { /*  sending server */
+       if (flag == false)  {   /*  sending server */
                *account_server_type = account_tbl_data->outgoing_server_type;
-       } else if ( flag == true ) {    /*  receiving server */
+       } else if (flag == true) {      /*  receiving server */
                *account_server_type = account_tbl_data->incoming_server_type;
        }
 
        ret = true;
 
 FINISH_OFF:
-       if ( account_tbl_data != NULL ) {
+       if (account_tbl_data != NULL) {
                emstorage_free_account(&account_tbl_data, 1, NULL);
        }
-       if ( error != NULL ) {
+       if (error != NULL) {
                *error = err;
        }
 
@@ -1168,28 +1163,28 @@ INTERNAL_FUNC int em_get_handle_for_activesync(int *handle, int *error)
        int ret = false;
        int err = EMAIL_ERROR_NONE;
 
-       if ( handle == NULL ) {
-               EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed : handle is NULL");
+       if (handle == NULL) {
+               EM_DEBUG_EXCEPTION("em_get_handle_for_activesync failed: handle is NULL");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if ( vconf_get_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, &next_handle)  != 0 ) {
+       if (vconf_get_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, &next_handle)  != 0) {
                EM_DEBUG_EXCEPTION("vconf_get_int failed");
-               if ( next_handle != 0 ) {
+               if (next_handle != 0) {
                        err = EMAIL_ERROR_GCONF_FAILURE;
                        goto FINISH_OFF;
                }
        }
 
-       EM_DEBUG_LOG(">>>>>> VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE : get lastest handle[%d]", next_handle);
+       EM_DEBUG_LOG(">>>>>> VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE: get lastest handle[%d]", next_handle);
 
        /*  set the value of the handle for active sync */
        next_handle--;
-       if ( next_handle < ACTIVE_SYNC_HANDLE_BOUNDARY ) {
+       if (next_handle < ACTIVE_SYNC_HANDLE_BOUNDARY) {
                next_handle = ACTIVE_SYNC_HANDLE_INIT_VALUE;
        }
-       if ( vconf_set_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, next_handle) != 0) {
+       if (vconf_set_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, next_handle) != 0) {
                EM_DEBUG_EXCEPTION("vconf_set_int failed");
                err = EMAIL_ERROR_GCONF_FAILURE;
                goto FINISH_OFF;
@@ -1199,7 +1194,7 @@ INTERNAL_FUNC int em_get_handle_for_activesync(int *handle, int *error)
        EM_DEBUG_LOG(">>>>>> return next handle[%d]", *handle);
 
 FINISH_OFF:
-       if ( error != NULL ) {
+       if (error != NULL) {
                *error = err;
        }
 
@@ -1214,55 +1209,55 @@ email_thread_handle_t* em_thread_create(void *(*thread_exit)(void*), void *arg)
 {
        pthread_mutex_lock(&g_mu);
 
-       email_thread_handle_t* thd_handle = (email_thread_handle_t*) calloc (1,sizeof (email_thread_handle_t));
+       email_thread_handle_t* thd_handle = (email_thread_handle_t*) calloc(1, sizeof(email_thread_handle_t));
        if (!thd_handle) {
-               EM_DEBUG_EXCEPTION ("out of memory");
+               EM_DEBUG_EXCEPTION("out of memory");
                goto FINISH_OFF;
        }
 
-       thd_handle->q = g_queue_new ();
+       thd_handle->q = g_queue_new();
        if (!thd_handle->q) {
-               EM_DEBUG_EXCEPTION ("g_queue_new failed");
+               EM_DEBUG_EXCEPTION("g_queue_new failed");
                goto FINISH_OFF;
        }
-       g_queue_init (thd_handle->q);
+       g_queue_init(thd_handle->q);
 
-       int ret = pthread_mutex_init (&thd_handle->mu, NULL);
+       int ret = pthread_mutex_init(&thd_handle->mu, NULL);
        if (ret == -1) {
-               EM_DEBUG_EXCEPTION ("pthread_mutex_init failed [%d]", errno);
+               EM_DEBUG_EXCEPTION("pthread_mutex_init failed [%d]", errno);
                goto FINISH_OFF;
        }
 
-       ret = pthread_cond_init (&thd_handle->cond, NULL);
+       ret = pthread_cond_init(&thd_handle->cond, NULL);
        if (ret == -1) {
-               EM_DEBUG_EXCEPTION ("pthread_cond_init failed [%d]", errno);
+               EM_DEBUG_EXCEPTION("pthread_cond_init failed [%d]", errno);
                goto FINISH_OFF;
        }
 
        thd_handle->thread_exit     = thread_exit;
        thd_handle->thread_exit_arg = arg;
 
-       pthread_mutex_unlock (&g_mu);
+       pthread_mutex_unlock(&g_mu);
        return thd_handle;
 
 FINISH_OFF:
-       pthread_mutex_unlock (&g_mu);
-       em_thread_destroy (thd_handle);
+       pthread_mutex_unlock(&g_mu);
+       em_thread_destroy(thd_handle);
        return NULL;
 }
 
-void em_thread_destroy (email_thread_handle_t* thd_handle)
+void em_thread_destroy(email_thread_handle_t* thd_handle)
 {
        if (!thd_handle) return;
 
-       if (!g_queue_is_empty (thd_handle->q)) {
-               EM_DEBUG_EXCEPTION ("delete q item routine here");
+       if (!g_queue_is_empty(thd_handle->q)) {
+               EM_DEBUG_EXCEPTION("delete q item routine here");
        }
 
-       pthread_mutex_destroy (&thd_handle->mu);
-       pthread_cond_destroy (&thd_handle->cond);
+       pthread_mutex_destroy(&thd_handle->mu);
+       pthread_cond_destroy(&thd_handle->cond);
 
-       EM_SAFE_FREE (thd_handle);
+       EM_SAFE_FREE(thd_handle);
 }
 
 typedef struct {
@@ -1272,10 +1267,10 @@ typedef struct {
        email_thread_handle_t *thd_handle;
 } worker_handle_t;
 
-static void* worker_func (void* arg)
+static void *worker_func(void* arg)
 {
        if (!arg) {
-               EM_DEBUG_EXCEPTION ("PARAMETER NULL");
+               EM_DEBUG_EXCEPTION("PARAMETER NULL");
                return NULL;
        }
        /* first task is passed by arg */
@@ -1283,7 +1278,7 @@ static void* worker_func (void* arg)
        email_thread_handle_t *thd_handle = warg->thd_handle;
 
        if (!thd_handle) {
-               EM_DEBUG_EXCEPTION ("PARAMETER NULL");
+               EM_DEBUG_EXCEPTION("PARAMETER NULL");
                return NULL;
        }
 
@@ -1294,33 +1289,33 @@ static void* worker_func (void* arg)
                        (warg->thread_func) (warg->arg);
                if (warg->destroy)
                        (warg->destroy) (warg->arg);
-               EM_SAFE_FREE (warg);
+               EM_SAFE_FREE(warg);
 
                /* if there is a pending job */
-               pthread_mutex_lock (&thd_handle->mu);
-               warg = g_queue_pop_head (thd_handle->q);
+               pthread_mutex_lock(&thd_handle->mu);
+               warg = g_queue_pop_head(thd_handle->q);
                if (!warg) {
                        thd_handle->running = 0;
-                       pthread_mutex_unlock (&thd_handle->mu);
+                       pthread_mutex_unlock(&thd_handle->mu);
                        (thd_handle->thread_exit) (thd_handle->thread_exit_arg);
                        return NULL;
                }
-               pthread_mutex_unlock (&thd_handle->mu);
+               pthread_mutex_unlock(&thd_handle->mu);
        } while (1);
 
        return NULL;
 }
 
-void em_thread_run (email_thread_handle_t *thd_handle, void *(*thread_func)(void*), void *(*destroy)(void*), void* arg)
+void em_thread_run(email_thread_handle_t *thd_handle, void *(*thread_func)(void*), void *(*destroy)(void*), void* arg)
 {
-       if(!thd_handle || !thread_func) {
-               EM_DEBUG_EXCEPTION ("invalid param");
+       if (!thd_handle || !thread_func) {
+               EM_DEBUG_EXCEPTION("invalid param");
                return;
        }
 
-       worker_handle_t *worker_handle = (worker_handle_t*) calloc (1, sizeof (worker_handle_t));
+       worker_handle_t *worker_handle = (worker_handle_t *)calloc(1, sizeof(worker_handle_t));
        if (!worker_handle) {
-               EM_DEBUG_EXCEPTION ("out of memory");
+               EM_DEBUG_EXCEPTION("out of memory");
                return;
        }
        worker_handle->thread_func = thread_func;
@@ -1328,34 +1323,33 @@ void em_thread_run (email_thread_handle_t *thd_handle, void *(*thread_func)(void
        worker_handle->arg  = arg;
        worker_handle->thd_handle = thd_handle;
 
-       pthread_mutex_lock (&thd_handle->mu);
+       pthread_mutex_lock(&thd_handle->mu);
 
        /* adding task to queue */
        if (thd_handle->running) {
-               g_queue_push_tail (thd_handle->q, worker_handle);
-       }
-       else {
+               g_queue_push_tail(thd_handle->q, worker_handle);
+       } else {
                thd_handle->running = 1;
                pthread_t tid = 0;
-               int err = pthread_create (&tid, NULL, worker_func, worker_handle);
-               if (err < 0 )
-                       EM_DEBUG_EXCEPTION ("pthread_create failed [%d]", errno);
+               int err = pthread_create(&tid, NULL, worker_func, worker_handle);
+               if (err < 0)
+                       EM_DEBUG_EXCEPTION("pthread_create failed [%d]", errno);
                thd_handle->tid = tid;
        }
-       pthread_mutex_unlock (&thd_handle->mu);
+       pthread_mutex_unlock(&thd_handle->mu);
 }
 
-void em_thread_join (email_thread_handle_t *thd_handle)
+void em_thread_join(email_thread_handle_t *thd_handle)
 {
-       int err = pthread_join (thd_handle->tid, NULL);
+       int err = pthread_join(thd_handle->tid, NULL);
        if (err < 0) {
-               EM_DEBUG_EXCEPTION ("pthread_join failed [%d]", errno);
+               EM_DEBUG_EXCEPTION("pthread_join failed [%d]", errno);
        }
 }
 
 INTERNAL_FUNC int em_fopen(const char *filename, const char *mode, FILE **fp)
 {
-       EM_DEBUG_FUNC_BEGIN("filename : [%s]", filename);
+       EM_DEBUG_FUNC_BEGIN("filename: [%s]", filename);
 
        int err = EMAIL_ERROR_NONE;
 
@@ -1370,7 +1364,7 @@ INTERNAL_FUNC int em_fopen(const char *filename, const char *mode, FILE **fp)
 
        temp_fp = fopen(filename, mode);
        if (temp_fp == NULL) {
-               EM_DEBUG_EXCEPTION("fopen failed : [%s][%d]", EM_STRERROR(errno_buf), errno);
+               EM_DEBUG_EXCEPTION("fopen failed: [%s][%d]", EM_STRERROR(errno_buf), errno);
                if (errno == EACCES || errno == EPERM)
                        err = EMAIL_ERROR_PERMISSION_DENIED;
                else if (errno == ENOSPC)
@@ -1390,7 +1384,7 @@ INTERNAL_FUNC int em_fopen(const char *filename, const char *mode, FILE **fp)
 
 INTERNAL_FUNC int em_open(const char *filename, int oflags, mode_t mode, int *handle)
 {
-       EM_DEBUG_FUNC_BEGIN("filename : [%s]", filename);
+       EM_DEBUG_FUNC_BEGIN("filename: [%s]", filename);
        int err = EMAIL_ERROR_NONE;
 
        if (!filename) {
@@ -1408,7 +1402,7 @@ INTERNAL_FUNC int em_open(const char *filename, int oflags, mode_t mode, int *ha
                temp_handle = open(filename, oflags);
 
        if (temp_handle < 0) {
-               EM_DEBUG_EXCEPTION("open failed : [%s][%d]", EM_STRERROR(errno_buf), errno);
+               EM_DEBUG_EXCEPTION("open failed: [%s][%d]", EM_STRERROR(errno_buf), errno);
                if (errno == EACCES || errno == EPERM)
                        err = EMAIL_ERROR_PERMISSION_DENIED;
                else if (errno == ENOSPC)
index 981278f..0ea7c84 100644 (file)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2005-2010, Troy D. Hanson     http://tpl.sourceforge.net
+Copyright (c) 2005-2010, Troy D. Hanson     http:://tpl.sourceforge.net
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #define TPL_VERSION 1.5
 
-static const char id[]="$Id: tpl.c 192 2009-04-24 10:35:30Z thanson $";
+static const char id[] = "$Id : tpl.c 192 2009-04-24 10:35:30Z thanson $";
 
 
 #include <stdlib.h>  /* malloc */
@@ -35,7 +35,7 @@ static const char id[]="$Id: tpl.c 192 2009-04-24 10:35:30Z thanson $";
 #include <unistd.h>     /* for ftruncate */
 #else
 #include <io.h>
-#define ftruncate(x,y) _chsize(x,y)
+#define ftruncate(x, y) _chsize(x, y)
 #endif
 #include <sys/types.h>  /* for 'open' */
 #include <sys/stat.h>   /* for 'open' */
@@ -54,7 +54,7 @@ typedef unsigned __int64 uint64_t;
 #endif
 
 
-#if ( defined __CYGWIN__ || defined __MINGW32__ || defined _WIN32 )
+#if (defined __CYGWIN__ || defined __MINGW32__ || defined _WIN32)
 #include "win/mman.h"   /* mmap */
 #else
 #include <sys/mman.h>   /* mmap */
@@ -68,7 +68,7 @@ typedef unsigned __int64 uint64_t;
 #define TPL_MAGIC "tpl"
 
 /* macro to add a structure to a doubly-linked list */
-#define DL_ADD(head,add)                                        \
+#define DL_ADD(head, add)                                        \
     do {                                                        \
         if (head) {                                             \
             (add)->prev = (head)->prev;                         \
@@ -76,7 +76,7 @@ typedef unsigned __int64 uint64_t;
             (head)->prev = (add);                               \
             (add)->next = NULL;                                 \
         } else {                                                \
-            (head)=(add);                                       \
+            (head) = (add);                                       \
             (head)->prev = (head);                              \
             (head)->next = NULL;                                \
         }                                                       \
@@ -126,14 +126,14 @@ typedef unsigned __int64 uint64_t;
 /* access to A(...) nodes by index */
 typedef struct tpl_pidx {
     struct tpl_node *node;
-    struct tpl_pidx *next,*prev;
+    struct tpl_pidx *next, *prev;
 } tpl_pidx;
 
 /* A(...) node datum */
 typedef struct tpl_atyp {
     uint32_t num;    /* num elements */
     size_t sz;       /* size of each backbone's datum */
-    struct tpl_backbone *bb,*bbtail;
+    struct tpl_backbone *bb, *bbtail;
     void *cur;
 } tpl_atyp;
 
@@ -180,7 +180,7 @@ static void *tpl_extend_backbone(tpl_node *n);
 static char *tpl_fmt(tpl_node *r);
 static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv);
 static size_t tpl_ser_osz(tpl_node *n);
-static void tpl_free_atyp(tpl_node *n,tpl_atyp *atyp);
+static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp);
 static int tpl_dump_to_mem(tpl_node *r, void *addr, size_t sz);
 static int tpl_mmap_file(char *filename, tpl_mmap_rec *map_rec);
 static int tpl_mmap_output_file(char *filename, size_t sz, void **text_out);
@@ -191,8 +191,8 @@ static void tpl_fatal(char *fmt, ...);
 static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen);
 static int tpl_unpackA0(tpl_node *r);
 static int tpl_oops(const char *fmt, ...);
-static int tpl_gather_mem( char *buf, size_t len, tpl_gather_t **gs, tpl_gather_cb *cb, void *data);
-static int tpl_gather_nonblocking( int fd, tpl_gather_t **gs, tpl_gather_cb *cb, void *data);
+static int tpl_gather_mem(char *buf, size_t len, tpl_gather_t **gs, tpl_gather_cb *cb, void *data);
+static int tpl_gather_nonblocking(int fd, tpl_gather_t **gs, tpl_gather_cb *cb, void *data);
 static int tpl_gather_blocking(int fd, void **img, size_t *sz);
 static tpl_node *tpl_map_va(char *fmt, va_list ap);
 
@@ -250,11 +250,12 @@ static const struct tpl_type_t tpl_types[] = {
 };
 
 /* default error-reporting function. Just writes to stderr. */
-static int tpl_oops(const char *fmt, ...) {
+static int tpl_oops(const char *fmt, ...)
+{
        char buf[256];
     va_list ap;
-    va_start(ap,fmt);
-/*    vfprintf(stderr,fmt,ap); */
+    va_start(ap, fmt);
+/*    vfprintf(stderr, fmt, ap); */
        snprintf(buf, sizeof(buf)-1, fmt, ap);
        EM_DEBUG_EXCEPTION("%s", buf);
     va_end(ap);
@@ -262,18 +263,19 @@ static int tpl_oops(const char *fmt, ...) {
 }
 
 
-static tpl_node *tpl_node_new(tpl_node *parent) {
+static tpl_node *tpl_node_new(tpl_node *parent)
+{
     tpl_node *n;
-    if ((n=tpl_hook.malloc(sizeof(tpl_node))) == NULL) {
+    if ((n = tpl_hook.malloc(sizeof(tpl_node))) == NULL) {
         fatal_oom();
     }
-    n->addr=NULL;
-    n->data=NULL;
-    n->num=1;
-    n->ser_osz=0;
-    n->children=NULL;
-    n->next=NULL;
-    n->parent=parent;
+    n->addr = NULL;
+    n->data = NULL;
+    n->num = 1;
+    n->ser_osz = 0;
+    n->children = NULL;
+    n->next = NULL;
+    n->parent = parent;
     return n;
 }
 
@@ -285,7 +287,8 @@ static tpl_node *tpl_node_new(tpl_node *parent) {
  * on Sparc, and apparently on 64 bit x86. We use a helper structure
  * to detect whether double is aligned in this compilation environment.
  */
-char *calc_field_addr(tpl_node *parent, int type,char *struct_addr, int ordinal) {
+char *calc_field_addr(tpl_node *parent, int type, char *struct_addr, int ordinal)
+{
     tpl_node *prev;
     int offset;
     int align_sz;
@@ -294,7 +297,7 @@ char *calc_field_addr(tpl_node *parent, int type,char *struct_addr, int ordinal)
 
     /* generate enough padding so field addr is divisible by it's align_sz. 4, 8, etc */
     prev = parent->children->prev;
-    switch(type) {
+    switch (type) {
       case TPL_TYPE_DOUBLE:
         align_sz = sizeof(struct tpl_double_alignment_detector) > 12 ? 8 : 4;
         break;
@@ -306,52 +309,54 @@ char *calc_field_addr(tpl_node *parent, int type,char *struct_addr, int ordinal)
         align_sz = tpl_types[type].sz;
         break;
     }
-       EM_DEBUG_LOG("prev->addr : [%p], struct_addr : [%p]", prev->addr, struct_addr);
+       EM_DEBUG_LOG("prev->addr: [%p], struct_addr: [%p]", prev->addr, struct_addr);
     offset = ((uintptr_t)prev->addr - (uintptr_t)struct_addr)
             + (tpl_types[prev->type].sz * prev->num);
-       EM_DEBUG_LOG("offset : [%d], align_sz : [%d]", offset, align_sz);
+       EM_DEBUG_LOG("offset: [%d], align_sz: [%d]", offset, align_sz);
     offset = (offset + align_sz - 1) / align_sz * align_sz;
-       EM_DEBUG_LOG("Real offset : [%d]", offset);
+       EM_DEBUG_LOG("Real offset: [%d]", offset);
     return struct_addr + offset;
 }
 
-TPL_API tpl_node *tpl_map(char *fmt,...) {
+TPL_API tpl_node *tpl_map(char *fmt, ...)
+{
   va_list ap;
   tpl_node *tn;
 
-  va_start(ap,fmt);
+  va_start(ap, fmt);
   tn = tpl_map_va(fmt, ap);
   va_end(ap);
   return tn;
 }
 
-static tpl_node *tpl_map_va(char *fmt, va_list ap) {
-    int lparen_level=0,expect_lparen=0,t=0,in_structure=0,ordinal=0;
-    int in_nested_structure=0;
-    char *c, *peek, *struct_addr=NULL, *struct_next;
-    tpl_node *root,*parent,*n=NULL,*preceding,*iter_start_node=NULL,
-             *struct_widest_node=NULL, *np; tpl_pidx *pidx;
+static tpl_node *tpl_map_va(char *fmt, va_list ap)
+{
+    int lparen_level = 0, expect_lparen = 0, t = 0, in_structure = 0, ordinal = 0;
+    int in_nested_structure = 0;
+    char *c, *peek, *struct_addr = NULL, *struct_next;
+    tpl_node *root, *parent, *n = NULL, *preceding, *iter_start_node = NULL,
+             *struct_widest_node = NULL, *np; tpl_pidx *pidx;
     tpl_pound_data *pd;
     int *fxlens, num_fxlens, pound_num, pound_prod, applies_to_struct;
     int contig_fxlens[10]; /* temp space for contiguous fxlens */
     int num_contig_fxlens, i, j;
-    ptrdiff_t inter_elt_len=0; /* padded element length of contiguous structs in array */
+    ptrdiff_t inter_elt_len = 0; /* padded element length of contiguous structs in array */
 
 
     root = tpl_node_new(NULL);
     root->type = TPL_TYPE_ROOT;
     root->data = (tpl_root_data*)tpl_hook.malloc(sizeof(tpl_root_data));
     if (!root->data) fatal_oom();
-    memset((tpl_root_data*)root->data,0,sizeof(tpl_root_data));
+    memset((tpl_root_data*)root->data, 0, sizeof(tpl_root_data));
 
     /* set up root nodes special ser_osz to reflect overhead of preamble */
     root->ser_osz =  sizeof(uint32_t); /* tpl leading length */
     root->ser_osz += EM_SAFE_STRLEN(fmt) + 1;  /* fmt + NUL-terminator */
     root->ser_osz += 4;                /* 'tpl' magic prefix + flags byte */
 
-    parent=root;
+    parent = root;
 
-    c=fmt;
+    c = fmt;
     while (*c != '\0') {
         switch (*c) {
             case 'c':
@@ -362,14 +367,14 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
             case 'I':
             case 'U':
             case 'f':
-                if      (*c=='c') t=TPL_TYPE_BYTE;
-                else if (*c=='i') t=TPL_TYPE_INT32;
-                else if (*c=='u') t=TPL_TYPE_UINT32;
-                else if (*c=='j') t=TPL_TYPE_INT16;
-                else if (*c=='v') t=TPL_TYPE_UINT16;
-                else if (*c=='I') t=TPL_TYPE_INT64;
-                else if (*c=='U') t=TPL_TYPE_UINT64;
-                else if (*c=='f') t=TPL_TYPE_DOUBLE;
+                if      (*c == 'c') t = TPL_TYPE_BYTE;
+                else if (*c == 'i') t = TPL_TYPE_INT32;
+                else if (*c == 'u') t = TPL_TYPE_UINT32;
+                else if (*c == 'j') t = TPL_TYPE_INT16;
+                else if (*c == 'v') t = TPL_TYPE_UINT16;
+                else if (*c == 'I') t = TPL_TYPE_INT64;
+                else if (*c == 'U') t = TPL_TYPE_UINT64;
+                else if (*c == 'f') t = TPL_TYPE_DOUBLE;
 
                 if (expect_lparen) goto fail;
                 n = tpl_node_new(parent);
@@ -383,13 +388,13 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                     if (tpl_types[n->type].sz > tpl_types[struct_widest_node->type].sz) {
                       struct_widest_node = n;
                     }
-                    n->addr = calc_field_addr(parent,n->type,struct_addr,ordinal++);
-                } else n->addr = (void*)va_arg(ap,void*);
+                    n->addr = calc_field_addr(parent, n->type, struct_addr, ordinal++);
+                } else n->addr = (void*)va_arg(ap, void*);
                 n->data = tpl_hook.malloc(tpl_types[t].sz);
                 if (!n->data) fatal_oom();
                 if (n->parent->type == TPL_TYPE_ARY)
                     ((tpl_atyp*)(n->parent->data))->sz += tpl_types[t].sz;
-                DL_ADD(parent->children,n);
+                DL_ADD(parent->children, n);
                 break;
             case 's':
                 if (expect_lparen) goto fail;
@@ -403,14 +408,14 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                     if (tpl_types[n->type].sz > tpl_types[struct_widest_node->type].sz) {
                       struct_widest_node = n;
                     }
-                    n->addr = calc_field_addr(parent,n->type,struct_addr,ordinal++);
-                } else n->addr = (void*)va_arg(ap,void*);
+                    n->addr = calc_field_addr(parent, n->type, struct_addr, ordinal++);
+                } else n->addr = (void*)va_arg(ap, void*);
                 n->data = tpl_hook.malloc(sizeof(char*));
                 if (!n->data) fatal_oom();
                 *(char**)(n->data) = NULL;
                 if (n->parent->type == TPL_TYPE_ARY)
                     ((tpl_atyp*)(n->parent->data))->sz += sizeof(void*);
-                DL_ADD(parent->children,n);
+                DL_ADD(parent->children, n);
                 break;
             case '#':
                 /* apply a 'num' to preceding atom */
@@ -423,12 +428,12 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                         t == TPL_TYPE_UINT32 || t == TPL_TYPE_DOUBLE ||
                         t == TPL_TYPE_UINT64 || t == TPL_TYPE_INT64 ||
                         t == TPL_TYPE_UINT16 || t == TPL_TYPE_INT16 ||
-                        t == TPL_TYPE_STR )) goto fail;
+                        t == TPL_TYPE_STR)) goto fail;
                 }
                 /* count up how many contiguous # and form their product */
-                pound_prod=1;
-                num_contig_fxlens=0;
-                for(peek=c; *peek == '#'; peek++) {
+                pound_prod = 1;
+                num_contig_fxlens = 0;
+                for (peek = c; *peek == '#'; peek++) {
                   pound_num = va_arg(ap, int);
                   if (pound_num < 1) {
                     tpl_hook.fatal("non-positive iteration count %d\n", pound_num);
@@ -452,9 +457,9 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                   pd->inter_elt_len = inter_elt_len;
                   pd->iter_start_node = iter_start_node;
                   pd->iternum = 0;
-                  DL_ADD(parent->children,n);
+                  DL_ADD(parent->children, n);
                   /* multiply the 'num' and data space on each atom in the structure */
-                  for(np = iter_start_node; np != n; np = np->next) {
+                  for (np = iter_start_node; np != n; np = np->next) {
                     if (n->parent->type == TPL_TYPE_ARY) {
                       ((tpl_atyp*)(n->parent->data))->sz +=
                          tpl_types[np->type].sz * (np->num * (n->num - 1));
@@ -469,7 +474,7 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                   preceding->data = tpl_hook.realloc(preceding->data,
                       tpl_types[t].sz * preceding->num);
                   if (!preceding->data) fatal_oom();
-                  memset(preceding->data,0,tpl_types[t].sz * preceding->num);
+                  memset(preceding->data, 0, tpl_types[t].sz * preceding->num);
                   if (n->parent->type == TPL_TYPE_ARY) {
                       ((tpl_atyp*)(n->parent->data))->sz += tpl_types[t].sz *
                                                             (preceding->num-1);
@@ -484,7 +489,7 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                 fxlens = tpl_hook.realloc(fxlens, sizeof(int) * num_fxlens);
                 if (!fxlens) fatal_oom();
                 ((tpl_root_data*)root->data)->fxlens = fxlens;
-                for(i=0; i < num_contig_fxlens; i++) fxlens[j++] = contig_fxlens[i];
+                for (i = 0; i < num_contig_fxlens; i++) fxlens[j++] = contig_fxlens[i];
 
                 break;
             case 'B':
@@ -492,26 +497,26 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                 if (in_structure) goto fail;
                 n = tpl_node_new(parent);
                 n->type = TPL_TYPE_BIN;
-                n->addr = (tpl_bin*)va_arg(ap,void*);
+                n->addr = (tpl_bin*)va_arg(ap, void*);
                 n->data = tpl_hook.malloc(sizeof(tpl_bin*));
                 if (!n->data) fatal_oom();
                 *((tpl_bin**)n->data) = NULL;
                 if (n->parent->type == TPL_TYPE_ARY)
                     ((tpl_atyp*)(n->parent->data))->sz += sizeof(tpl_bin);
-                DL_ADD(parent->children,n);
+                DL_ADD(parent->children, n);
                 break;
             case 'A':
                 if (in_structure) goto fail;
                 n = tpl_node_new(parent);
                 n->type = TPL_TYPE_ARY;
-                DL_ADD(parent->children,n);
+                DL_ADD(parent->children, n);
                 parent = n;
-                expect_lparen=1;
+                expect_lparen = 1;
                 pidx = (tpl_pidx*)tpl_hook.malloc(sizeof(tpl_pidx));
                 if (!pidx) fatal_oom();
                 pidx->node = n;
                 pidx->next = NULL;
-                DL_ADD(((tpl_root_data*)(root->data))->pidx,pidx);
+                DL_ADD(((tpl_root_data*)(root->data))->pidx, pidx);
                 /* set up the A's tpl_atyp */
                 n->data = (tpl_atyp*)tpl_hook.malloc(sizeof(tpl_atyp));
                 if (!n->data) fatal_oom();
@@ -525,14 +530,14 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                 break;
             case 'S':
                 if (in_structure) goto fail;
-                expect_lparen=1;
-                ordinal=1;  /* index upcoming atoms in S(..) */
-                in_structure=1+lparen_level; /* so we can tell where S fmt ends */
-                struct_addr = (char*)va_arg(ap,void*);
+                expect_lparen = 1;
+                ordinal = 1;  /* index upcoming atoms in S(..) */
+                in_structure = 1+lparen_level; /* so we can tell where S fmt ends */
+                struct_addr = (char*)va_arg(ap, void*);
                 break;
             case '$': /* nested structure */
                 if (!in_structure) goto fail;
-                expect_lparen=1;
+                expect_lparen = 1;
                 in_nested_structure++;
                 break;
             case ')':
@@ -545,13 +550,12 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
                   struct_next = calc_field_addr(parent, struct_widest_node->type,
                                                 struct_addr, ordinal++);
                   inter_elt_len = struct_next - struct_addr;
-                  in_structure=0;
-                }
-                else parent = parent->parent; /* rparen ends A() type, not S() type */
+                  in_structure = 0;
+                } else parent = parent->parent; /* rparen ends A() type, not S() type */
                 break;
             case '(':
                 if (!expect_lparen) goto fail;
-                expect_lparen=0;
+                expect_lparen = 0;
                 lparen_level++;
                 break;
             default:
@@ -566,7 +570,7 @@ static tpl_node *tpl_map_va(char *fmt, va_list ap) {
     ((tpl_root_data*)(root->data))->fmt = tpl_hook.malloc(EM_SAFE_STRLEN(fmt)+1);
     if (((tpl_root_data*)(root->data))->fmt == NULL)
         fatal_oom();
-    memcpy(((tpl_root_data*)(root->data))->fmt,fmt,EM_SAFE_STRLEN(fmt)+1);
+    memcpy(((tpl_root_data*)(root->data))->fmt, fmt, EM_SAFE_STRLEN(fmt)+1);
 
     return root;
 
@@ -576,9 +580,9 @@ fail:
     return NULL;
 }
 
-static int tpl_unmap_file( tpl_mmap_rec *mr) {
-
-    if ( munmap( mr->text, mr->text_sz ) == -1 ) {
+static int tpl_unmap_file(tpl_mmap_rec *mr)
+{
+    if (munmap(mr->text, mr->text_sz) == -1) {
         tpl_hook.oops("Failed to munmap: %s\n", strerror(errno));
     }
     close(mr->fd);
@@ -587,44 +591,45 @@ static int tpl_unmap_file( tpl_mmap_rec *mr) {
     return 0;
 }
 
-static void tpl_free_keep_map(tpl_node *r) {
+static void tpl_free_keep_map(tpl_node *r)
+{
     int mmap_bits = (TPL_RDONLY|TPL_FILE);
     int ufree_bits = (TPL_MEM|TPL_UFREE);
-    tpl_node *nxtc,*c;
-    int find_next_node=0,looking,i;
+    tpl_node *nxtc, *c;
+    int find_next_node = 0, looking, i;
     size_t sz;
 
     /* For mmap'd files, or for 'ufree' memory images , do appropriate release */
     if ((((tpl_root_data*)(r->data))->flags & mmap_bits) == mmap_bits) {
-        tpl_unmap_file( &((tpl_root_data*)(r->data))->mmap);
+        tpl_unmap_file(&((tpl_root_data*)(r->data))->mmap);
     } else if ((((tpl_root_data*)(r->data))->flags & ufree_bits) == ufree_bits) {
-        tpl_hook.free( ((tpl_root_data*)(r->data))->mmap.text );
+        tpl_hook.free(((tpl_root_data*)(r->data))->mmap.text);
     }
 
     c = r->children;
     if (c) {
-        while(c->type != TPL_TYPE_ROOT) {    /* loop until we come back to root node */
+        while (c->type != TPL_TYPE_ROOT) {    /* loop until we come back to root node */
             switch (c->type) {
                 case TPL_TYPE_BIN:
                     /* free any binary buffer hanging from tpl_bin */
-                    if ( *((tpl_bin**)(c->data)) ) {
-                        if ( (*((tpl_bin**)(c->data)))->addr ) {
-                            tpl_hook.free( (*((tpl_bin**)(c->data)))->addr );
+                    if (*((tpl_bin**)(c->data))) {
+                        if ((*((tpl_bin**)(c->data)))->addr) {
+                            tpl_hook.free((*((tpl_bin**)(c->data)))->addr);
                         }
                         *((tpl_bin**)c->data) = NULL; /* reset tpl_bin */
                     }
-                    find_next_node=1;
+                    find_next_node = 1;
                     break;
                 case TPL_TYPE_STR:
                     /* free any packed (copied) string */
-                    for(i=0; i < c->num; i++) {
+                    for (i = 0; i < c->num; i++) {
                       char *str = ((char**)c->data)[i];
                       if (str) {
                         tpl_hook.free(str);
                         ((char**)c->data)[i] = NULL;
                       }
                     }
-                    find_next_node=1;
+                    find_next_node = 1;
                     break;
                 case TPL_TYPE_INT32:
                 case TPL_TYPE_UINT32:
@@ -635,13 +640,13 @@ static void tpl_free_keep_map(tpl_node *r) {
                 case TPL_TYPE_INT16:
                 case TPL_TYPE_UINT16:
                 case TPL_TYPE_POUND:
-                    find_next_node=1;
+                    find_next_node = 1;
                     break;
                 case TPL_TYPE_ARY:
                     c->ser_osz = 0; /* zero out the serialization output size */
 
                     sz = ((tpl_atyp*)(c->data))->sz;  /* save sz to use below */
-                    tpl_free_atyp(c,c->data);
+                    tpl_free_atyp(c, c->data);
 
                     /* make new atyp */
                     c->data = (tpl_atyp*)tpl_hook.malloc(sizeof(tpl_atyp));
@@ -660,18 +665,18 @@ static void tpl_free_keep_map(tpl_node *r) {
             }
 
             if (find_next_node) {
-                find_next_node=0;
-                looking=1;
-                while(looking) {
+                find_next_node = 0;
+                looking = 1;
+                while (looking) {
                     if (c->next) {
-                        nxtc=c->next;
-                        c=nxtc;
-                        looking=0;
+                        nxtc = c->next;
+                        c = nxtc;
+                        looking = 0;
                     } else {
                         if (c->type == TPL_TYPE_ROOT) break; /* root node */
                         else {
-                            nxtc=c->parent;
-                            c=nxtc;
+                            nxtc = c->parent;
+                            c = nxtc;
                         }
                     }
                 }
@@ -682,38 +687,39 @@ static void tpl_free_keep_map(tpl_node *r) {
     ((tpl_root_data*)(r->data))->flags = 0;  /* reset flags */
 }
 
-TPL_API void tpl_free(tpl_node *r) {
+TPL_API void tpl_free(tpl_node *r)
+{
     int mmap_bits = (TPL_RDONLY|TPL_FILE);
     int ufree_bits = (TPL_MEM|TPL_UFREE);
-    tpl_node *nxtc,*c;
-    int find_next_node=0,looking,i;
-    tpl_pidx *pidx,*pidx_nxt;
+    tpl_node *nxtc, *c;
+    int find_next_node = 0, looking, i;
+    tpl_pidx *pidx, *pidx_nxt;
 
     /* For mmap'd files, or for 'ufree' memory images , do appropriate release */
     if ((((tpl_root_data*)(r->data))->flags & mmap_bits) == mmap_bits) {
-        tpl_unmap_file( &((tpl_root_data*)(r->data))->mmap);
+        tpl_unmap_file(&((tpl_root_data*)(r->data))->mmap);
     } else if ((((tpl_root_data*)(r->data))->flags & ufree_bits) == ufree_bits) {
-        tpl_hook.free( ((tpl_root_data*)(r->data))->mmap.text );
+        tpl_hook.free(((tpl_root_data*)(r->data))->mmap.text);
     }
 
     c = r->children;
     if (c) {
-        while(c->type != TPL_TYPE_ROOT) {    /* loop until we come back to root node */
+        while (c->type != TPL_TYPE_ROOT) {    /* loop until we come back to root node */
             switch (c->type) {
                 case TPL_TYPE_BIN:
                     /* free any binary buffer hanging from tpl_bin */
-                    if ( *((tpl_bin**)(c->data)) ) {
-                        if ( (*((tpl_bin**)(c->data)))->sz != 0 ) {
-                            tpl_hook.free( (*((tpl_bin**)(c->data)))->addr );
+                    if (*((tpl_bin**)(c->data))) {
+                        if ((*((tpl_bin**)(c->data)))->sz != 0) {
+                            tpl_hook.free((*((tpl_bin**)(c->data)))->addr);
                         }
                         tpl_hook.free(*((tpl_bin**)c->data)); /* free tpl_bin */
                     }
                     tpl_hook.free(c->data);  /* free tpl_bin* */
-                    find_next_node=1;
+                    find_next_node = 1;
                     break;
                 case TPL_TYPE_STR:
                     /* free any packed (copied) string */
-                    for(i=0; i < c->num; i++) {
+                    for (i = 0; i < c->num; i++) {
                       char *str = ((char**)c->data)[i];
                       if (str) {
                         tpl_hook.free(str);
@@ -721,7 +727,7 @@ TPL_API void tpl_free(tpl_node *r) {
                       }
                     }
                     tpl_hook.free(c->data);
-                    find_next_node=1;
+                    find_next_node = 1;
                     break;
                 case TPL_TYPE_INT32:
                 case TPL_TYPE_UINT32:
@@ -733,12 +739,12 @@ TPL_API void tpl_free(tpl_node *r) {
                 case TPL_TYPE_UINT16:
                 case TPL_TYPE_POUND:
                     tpl_hook.free(c->data);
-                    find_next_node=1;
+                    find_next_node = 1;
                     break;
                 case TPL_TYPE_ARY:
-                    tpl_free_atyp(c,c->data);
+                    tpl_free_atyp(c, c->data);
                     if (c->children) c = c->children; /* normal case */
-                    else find_next_node=1; /* edge case, handle bad format A() */
+                    else find_next_node = 1; /* edge case, handle bad format A() */
                     break;
                 default:
                     tpl_hook.fatal("unsupported format character\n");
@@ -746,20 +752,20 @@ TPL_API void tpl_free(tpl_node *r) {
             }
 
             if (find_next_node) {
-                find_next_node=0;
-                looking=1;
-                while(looking) {
+                find_next_node = 0;
+                looking = 1;
+                while (looking) {
                     if (c->next) {
-                        nxtc=c->next;
+                        nxtc = c->next;
                         tpl_hook.free(c);
-                        c=nxtc;
-                        looking=0;
+                        c = nxtc;
+                        looking = 0;
                     } else {
                         if (c->type == TPL_TYPE_ROOT) break; /* root node */
                         else {
-                            nxtc=c->parent;
+                            nxtc = c->parent;
                             tpl_hook.free(c);
-                            c=nxtc;
+                            c = nxtc;
                         }
                     }
                 }
@@ -768,7 +774,7 @@ TPL_API void tpl_free(tpl_node *r) {
     }
 
     /* free root */
-    for(pidx=((tpl_root_data*)(r->data))->pidx; pidx; pidx=pidx_nxt) {
+    for (pidx = ((tpl_root_data*)(r->data))->pidx; pidx; pidx = pidx_nxt) {
         pidx_nxt = pidx->next;
         tpl_hook.free(pidx);
     }
@@ -782,31 +788,34 @@ TPL_API void tpl_free(tpl_node *r) {
 
 
 /* Find the i'th packable ('A' node) */
-static tpl_node *tpl_find_i(tpl_node *n, int i) {
-    int j=0;
+static tpl_node *tpl_find_i(tpl_node *n, int i)
+{
+    int j = 0;
     tpl_pidx *pidx;
     if (n->type != TPL_TYPE_ROOT) return NULL;
     if (i == 0) return n;  /* packable 0 is root */
-    for(pidx=((tpl_root_data*)(n->data))->pidx; pidx; pidx=pidx->next) {
+    for (pidx = ((tpl_root_data*)(n->data))->pidx; pidx; pidx = pidx->next) {
         if (++j == i) return pidx->node;
     }
     return NULL;
 }
 
-static void *tpl_cpv(void *datav, void *data, size_t sz) {
-    if (sz>0) memcpy(datav,data,sz);
+static void *tpl_cpv(void *datav, void *data, size_t sz)
+{
+    if (sz > 0) memcpy(datav, data, sz);
     return (void*)((uintptr_t)datav + sz);
 }
 
-static void *tpl_extend_backbone(tpl_node *n) {
+static void *tpl_extend_backbone(tpl_node *n)
+{
     tpl_backbone *bb;
     bb = (tpl_backbone*)tpl_hook.malloc(sizeof(tpl_backbone) +
-      ((tpl_atyp*)(n->data))->sz );  /* datum hangs on coattails of bb */
+      ((tpl_atyp*)(n->data))->sz);  /* datum hangs on coattails of bb */
     if (!bb) fatal_oom();
 #if __STDC_VERSION__ < 199901
     bb->data = (char*)((uintptr_t)bb + sizeof(tpl_backbone));
 #endif
-    memset(bb->data,0,((tpl_atyp*)(n->data))->sz);
+    memset(bb->data, 0, ((tpl_atyp*)(n->data))->sz);
     bb->next = NULL;
     /* Add the new backbone to the tail, also setting head if necessary  */
     if (((tpl_atyp*)(n->data))->bb == NULL) {
@@ -822,12 +831,14 @@ static void *tpl_extend_backbone(tpl_node *n) {
 }
 
 /* Get the format string corresponding to a given tpl (root node) */
-static char *tpl_fmt(tpl_node *r) {
+static char *tpl_fmt(tpl_node *r)
+{
     return ((tpl_root_data*)(r->data))->fmt;
 }
 
 /* Get the fmt # lengths as a contiguous buffer of ints (length num_fxlens) */
-static int *tpl_fxlens(tpl_node *r, int *num_fxlens) {
+static int *tpl_fxlens(tpl_node *r, int *num_fxlens)
+{
     *num_fxlens = ((tpl_root_data*)(r->data))->num_fxlens;
     return ((tpl_root_data*)(r->data))->fxlens;
 }
@@ -836,7 +847,8 @@ static int *tpl_fxlens(tpl_node *r, int *num_fxlens) {
  * already been set up with the proper space. The backbone is walked
  * which was obtained from the tpl_atyp header passed in.
  */
-static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv) {
+static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv)
+{
     tpl_backbone *bb;
     tpl_node *c;
     void *datav;
@@ -849,11 +861,11 @@ static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv) {
     size_t itermax;
 
     /* handle 'A' nodes */
-    dv = tpl_cpv(dv,&at->num,sizeof(uint32_t));  /* array len */
-    for(bb=at->bb; bb; bb=bb->next) {
+    dv = tpl_cpv(dv, &at->num, sizeof(uint32_t));  /* array len */
+    for (bb = at->bb; bb; bb = bb->next) {
         datav = bb->data;
-        c=n->children;
-        while(c) {
+        c = n->children;
+        while (c) {
             switch (c->type) {
                 case TPL_TYPE_BYTE:
                 case TPL_TYPE_DOUBLE:
@@ -863,30 +875,30 @@ static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv) {
                 case TPL_TYPE_UINT64:
                 case TPL_TYPE_INT16:
                 case TPL_TYPE_UINT16:
-                    dv = tpl_cpv(dv,datav,tpl_types[c->type].sz * c->num);
+                    dv = tpl_cpv(dv, datav, tpl_types[c->type].sz * c->num);
                     datav = (void*)((uintptr_t)datav + tpl_types[c->type].sz * c->num);
                     break;
                 case TPL_TYPE_BIN:
                     /* dump the buffer length followed by the buffer */
-                    memcpy(&binp,datav,sizeof(tpl_bin*)); /* cp to aligned */
+                    memcpy(&binp, datav, sizeof(tpl_bin*)); /* cp to aligned */
                     slen = binp->sz;
-                    dv = tpl_cpv(dv,&slen,sizeof(uint32_t));
-                    dv = tpl_cpv(dv,binp->addr,slen);
+                    dv = tpl_cpv(dv, &slen, sizeof(uint32_t));
+                    dv = tpl_cpv(dv, binp->addr, slen);
                     datav = (void*)((uintptr_t)datav + sizeof(tpl_bin*));
                     break;
                 case TPL_TYPE_STR:
                     /* dump the string length followed by the string */
-                    for(i=0; i < c->num; i++) {
-                      memcpy(&strp,datav,sizeof(char*)); /* cp to aligned */
+                    for (i = 0; i < c->num; i++) {
+                      memcpy(&strp, datav, sizeof(char*)); /* cp to aligned */
                       slen = strp ? (EM_SAFE_STRLEN(strp)+1) : 0;
-                      dv = tpl_cpv(dv,&slen,sizeof(uint32_t));
-                      if (slen > 1) dv = tpl_cpv(dv,strp,slen-1);
+                      dv = tpl_cpv(dv, &slen, sizeof(uint32_t));
+                      if (slen > 1) dv = tpl_cpv(dv, strp, slen-1);
                       datav = (void*)((uintptr_t)datav + sizeof(char*));
                     }
                     break;
                 case TPL_TYPE_ARY:
-                    memcpy(&atypp,datav,sizeof(tpl_atyp*)); /* cp to aligned */
-                    dv = tpl_dump_atyp(c,atypp,dv);
+                    memcpy(&atypp, datav, sizeof(tpl_atyp*)); /* cp to aligned */
+                    dv = tpl_dump_atyp(c, atypp, dv);
                     datav = (void*)((uintptr_t)datav + sizeof(void*));
                     break;
                 case TPL_TYPE_POUND:
@@ -904,14 +916,15 @@ static void *tpl_dump_atyp(tpl_node *n, tpl_atyp* at, void *dv) {
                     tpl_hook.fatal("unsupported format character\n");
                     break;
             }
-            c=c->next;
+            c = c->next;
         }
     }
     return dv;
 }
 
 /* figure the serialization output size needed for tpl whose root is n*/
-static size_t tpl_ser_osz(tpl_node *n) {
+static size_t tpl_ser_osz(tpl_node *n)
+{
     tpl_node *c, *np;
     size_t sz, itermax;
     tpl_bin *binp;
@@ -925,7 +938,7 @@ static size_t tpl_ser_osz(tpl_node *n) {
     }
 
     sz = n->ser_osz;    /* start with fixed overhead, already stored */
-    c=n->children;
+    c = n->children;
     while (c) {
         switch (c->type) {
             case TPL_TYPE_BYTE:
@@ -940,13 +953,13 @@ static size_t tpl_ser_osz(tpl_node *n) {
                 break;
             case TPL_TYPE_BIN:
                 sz += sizeof(uint32_t);  /* binary buf len */
-                memcpy(&binp,c->data,sizeof(tpl_bin*)); /* cp to aligned */
+                memcpy(&binp, c->data, sizeof(tpl_bin*)); /* cp to aligned */
                 sz += binp->sz;
                 break;
             case TPL_TYPE_STR:
-                for(i=0; i < c->num; i++) {
+                for (i = 0; i < c->num; i++) {
                   sz += sizeof(uint32_t);  /* string len */
-                  memcpy(&strp,&((char**)c->data)[i],sizeof(char*)); /* cp to aligned */
+                  memcpy(&strp, &((char**)c->data)[i], sizeof(char*)); /* cp to aligned */
                   sz += strp ? EM_SAFE_STRLEN(strp) : 0;
                 }
                 break;
@@ -959,7 +972,7 @@ static size_t tpl_ser_osz(tpl_node *n) {
                 itermax = c->num;
                 pd = (tpl_pound_data*)c->data;
                 if (++(pd->iternum) < itermax) {
-                  for(np=pd->iter_start_node; np != c; np = np->next) {
+                  for (np = pd->iter_start_node; np != c; np = np->next) {
                      np->data = (char*)(np->data) +
                                 (tpl_types[np->type].sz * np->num);
                   }
@@ -967,7 +980,7 @@ static size_t tpl_ser_osz(tpl_node *n) {
                   continue;
                 } else { /* loop complete. */
                   pd->iternum = 0;
-                  for(np=pd->iter_start_node; np != c; np = np->next) {
+                  for (np = pd->iter_start_node; np != c; np = np->next) {
                      np->data = (char*)(np->data) - ((itermax-1) *
                                                      tpl_types[np->type].sz *
                                                      np->num);
@@ -978,18 +991,19 @@ static size_t tpl_ser_osz(tpl_node *n) {
                 tpl_hook.fatal("unsupported format character\n");
                 break;
         }
-        c=c->next;
+        c = c->next;
     }
     return sz;
 }
 
 
-TPL_API int tpl_dump(tpl_node *r, int mode, ...) {
+TPL_API int tpl_dump(tpl_node *r, int mode, ...)
+{
     va_list ap;
     char *filename, *bufv;
-    void **addr_out,*buf, *pa_addr;
-    int fd,rc=0;
-    size_t sz,*sz_out, pa_sz;
+    void **addr_out, *buf, *pa_addr;
+    int fd, rc = 0;
+    size_t sz, *sz_out, pa_sz;
 
     if (((tpl_root_data*)(r->data))->flags & TPL_RDONLY) {  /* unusual */
         tpl_hook.oops("error: tpl_dump called for a loaded tpl\n");
@@ -998,14 +1012,14 @@ TPL_API int tpl_dump(tpl_node *r, int mode, ...) {
 
     sz = tpl_ser_osz(r); /* compute the size needed to serialize  */
 
-    va_start(ap,mode);
+    va_start(ap, mode);
     if (mode & TPL_FILE) {
-        filename = va_arg(ap,char*);
+        filename = va_arg(ap, char*);
         fd = tpl_mmap_output_file(filename, sz, &buf);
         if (fd == -1) rc = -1;
         else {
-            rc = tpl_dump_to_mem(r,buf,sz);
-            if (msync(buf,sz,MS_SYNC) == -1) {
+            rc = tpl_dump_to_mem(r, buf, sz);
+            if (msync(buf, sz, MS_SYNC) == -1) {
                 tpl_hook.oops("msync failed on fd %d: %s\n", fd, strerror(errno));
             }
             if (munmap(buf, sz) == -1) {
@@ -1015,11 +1029,11 @@ TPL_API int tpl_dump(tpl_node *r, int mode, ...) {
         }
     } else if (mode & TPL_FD) {
         fd = va_arg(ap, int);
-        if ( (buf = tpl_hook.malloc(sz)) == NULL) fatal_oom();
-        tpl_dump_to_mem(r,buf,sz);
+        if ((buf = tpl_hook.malloc(sz)) == NULL) fatal_oom();
+        tpl_dump_to_mem(r, buf, sz);
         bufv = buf;
         do {
-            rc = write(fd,bufv,sz);
+            rc = write(fd, bufv, sz);
             if (rc > 0) {
                 sz -= rc;
                 bufv += rc;
@@ -1042,21 +1056,21 @@ TPL_API int tpl_dump(tpl_node *r, int mode, ...) {
               va_end(ap);
               return -1;
           }
-          rc=tpl_dump_to_mem(r,pa_addr,sz);
+          rc = tpl_dump_to_mem(r, pa_addr, sz);
         } else { /* we allocate */
           addr_out = (void**)va_arg(ap, void*);
           sz_out = va_arg(ap, size_t*);
-          if ( (buf = tpl_hook.malloc(sz)) == NULL) fatal_oom();
+          if ((buf = tpl_hook.malloc(sz)) == NULL) fatal_oom();
           *sz_out = sz;
           *addr_out = buf;
-          rc=tpl_dump_to_mem(r,buf,sz);
+          rc = tpl_dump_to_mem(r, buf, sz);
         }
     } else if (mode & TPL_GETSIZE) {
         sz_out = va_arg(ap, size_t*);
         *sz_out = sz;
     } else {
         tpl_hook.oops("unsupported tpl_dump mode %d\n", mode);
-        rc=-1;
+        rc = -1;
     }
     va_end(ap);
     return rc;
@@ -1066,11 +1080,12 @@ TPL_API int tpl_dump(tpl_node *r, int mode, ...) {
  * adequate size to hold the serialized tpl. The sz parameter must be
  * the result of tpl_ser_osz(r).
  */
-static int tpl_dump_to_mem(tpl_node *r,void *addr,size_t sz) {
+static int tpl_dump_to_mem(tpl_node *r, void *addr, size_t sz)
+{
     uint32_t slen, sz32;
     int *fxlens, num_fxlens, i;
     void *dv;
-    char *fmt,flags;
+    char *fmt, flags;
     tpl_node *c, *np;
     tpl_pound_data *pd;
     size_t itermax;
@@ -1078,16 +1093,16 @@ static int tpl_dump_to_mem(tpl_node *r,void *addr,size_t sz) {
     fmt = tpl_fmt(r);
     flags = 0;
     if (tpl_cpu_bigendian()) flags |= TPL_FL_BIGENDIAN;
-    if (strchr(fmt,'s')) flags |= TPL_FL_NULLSTRINGS;
+    if (strchr(fmt, 's')) flags |= TPL_FL_NULLSTRINGS;
     sz32 = sz;
 
     dv = addr;
-    dv = tpl_cpv(dv,TPL_MAGIC,3);         /* copy tpl magic prefix */
-    dv = tpl_cpv(dv,&flags,1);            /* copy flags byte */
-    dv = tpl_cpv(dv,&sz32,sizeof(uint32_t));/* overall length (inclusive) */
-    dv = tpl_cpv(dv,fmt,EM_SAFE_STRLEN(fmt)+1);   /* copy format with NUL-term */
-    fxlens = tpl_fxlens(r,&num_fxlens);
-    dv = tpl_cpv(dv,fxlens,num_fxlens*sizeof(uint32_t));/* fmt # lengths */
+    dv = tpl_cpv(dv, TPL_MAGIC, 3);         /* copy tpl magic prefix */
+    dv = tpl_cpv(dv, &flags, 1);            /* copy flags byte */
+    dv = tpl_cpv(dv, &sz32, sizeof(uint32_t));/* overall length (inclusive) */
+    dv = tpl_cpv(dv, fmt, EM_SAFE_STRLEN(fmt)+1);   /* copy format with NUL-term */
+    fxlens = tpl_fxlens(r, &num_fxlens);
+    dv = tpl_cpv(dv, fxlens, num_fxlens*sizeof(uint32_t));/* fmt # lengths */
 
     /* serialize the tpl content, iterating over direct children of root */
     c = r->children;
@@ -1101,23 +1116,23 @@ static int tpl_dump_to_mem(tpl_node *r,void *addr,size_t sz) {
             case TPL_TYPE_UINT64:
             case TPL_TYPE_INT16:
             case TPL_TYPE_UINT16:
-                dv = tpl_cpv(dv,c->data,tpl_types[c->type].sz * c->num);
+                dv = tpl_cpv(dv, c->data, tpl_types[c->type].sz * c->num);
                 break;
             case TPL_TYPE_BIN:
                 slen = (*(tpl_bin**)(c->data))->sz;
-                dv = tpl_cpv(dv,&slen,sizeof(uint32_t));  /* buffer len */
-                dv = tpl_cpv(dv,(*(tpl_bin**)(c->data))->addr,slen); /* buf */
+                dv = tpl_cpv(dv, &slen, sizeof(uint32_t));  /* buffer len */
+                dv = tpl_cpv(dv, (*(tpl_bin**)(c->data))->addr, slen); /* buf */
                 break;
             case TPL_TYPE_STR:
-                for(i=0; i < c->num; i++) {
+                for (i = 0; i < c->num; i++) {
                   char *str = ((char**)c->data)[i];
                   slen = str ? EM_SAFE_STRLEN(str)+1 : 0;
-                  dv = tpl_cpv(dv,&slen,sizeof(uint32_t));  /* string len */
-                  if (slen>1) dv = tpl_cpv(dv,str,slen-1); /*string*/
+                  dv = tpl_cpv(dv, &slen, sizeof(uint32_t));  /* string len */
+                  if (slen > 1) dv = tpl_cpv(dv, str, slen-1); /*string*/
                 }
                 break;
             case TPL_TYPE_ARY:
-                dv = tpl_dump_atyp(c,(tpl_atyp*)c->data,dv);
+                dv = tpl_dump_atyp(c, (tpl_atyp*)c->data, dv);
                 break;
             case TPL_TYPE_POUND:
                  pd = (tpl_pound_data*)c->data;
@@ -1125,7 +1140,7 @@ static int tpl_dump_to_mem(tpl_node *r,void *addr,size_t sz) {
                  if (++(pd->iternum) < itermax) {
 
                    /* in start or midst of loop. advance data pointers. */
-                   for(np=pd->iter_start_node; np != c; np = np->next) {
+                   for (np = pd->iter_start_node; np != c; np = np->next) {
                      np->data = (char*)(np->data) +
                                 (tpl_types[np->type].sz * np->num);
                    }
@@ -1137,7 +1152,7 @@ static int tpl_dump_to_mem(tpl_node *r,void *addr,size_t sz) {
 
                    /* reset iteration index and addr/data pointers. */
                    pd->iternum = 0;
-                   for(np=pd->iter_start_node; np != c; np = np->next) {
+                   for (np = pd->iter_start_node; np != c; np = np->next) {
                      np->data = (char*)(np->data) - ((itermax-1) *
                                                      tpl_types[np->type].sz *
                                                      np->num);
@@ -1155,7 +1170,8 @@ static int tpl_dump_to_mem(tpl_node *r,void *addr,size_t sz) {
     return 0;
 }
 
-static int tpl_cpu_bigendian() {
+static int tpl_cpu_bigendian()
+{
    unsigned i = 1;
    char *c;
    c = (char*)&i;
@@ -1171,9 +1187,10 @@ static int tpl_cpu_bigendian() {
  * should exactly match the buffer size (bufsz) and the internal
  * recorded size (intlsz)
  */
-static int tpl_sanity(tpl_node *r, int excess_ok) {
+static int tpl_sanity(tpl_node *r, int excess_ok)
+{
     uint32_t intlsz;
-    int found_nul=0,rc, octothorpes=0, num_fxlens, *fxlens, flen;
+    int found_nul = 0, rc, octothorpes = 0, num_fxlens, *fxlens, flen;
     void *d, *dv;
     char intlflags, *fmt, c, *mapfmt;
     size_t bufsz, serlen;
@@ -1182,11 +1199,11 @@ static int tpl_sanity(tpl_node *r, int excess_ok) {
     bufsz = ((tpl_root_data*)(r->data))->mmap.text_sz;
 
     dv = d;
-    if (bufsz < (4 + sizeof(uint32_t) + 1)) return ERR_NOT_MINSIZE; /* min sz: magic+flags+len+nul */
-    if (memcmp(dv,TPL_MAGIC, 3) != 0) return ERR_MAGIC_MISMATCH; /* missing tpl magic prefix */
+    if (bufsz < (4 + sizeof(uint32_t) + 1)) return ERR_NOT_MINSIZE; /* min sz : magic+flags+len+nul */
+    if (memcmp(dv, TPL_MAGIC, 3) != 0) return ERR_MAGIC_MISMATCH; /* missing tpl magic prefix */
     if (tpl_needs_endian_swap(dv)) ((tpl_root_data*)(r->data))->flags |= TPL_XENDIAN;
     dv = (void*)((uintptr_t)dv + 3);
-    memcpy(&intlflags,dv,sizeof(char));  /* extract flags */
+    memcpy(&intlflags, dv, sizeof(char));  /* extract flags */
     if (intlflags & ~TPL_SUPPORTED_BITFLAGS) return ERR_UNSUPPORTED_FLAGS;
     /* TPL1.3 stores strings with a "length+1" prefix to discern NULL strings from
        empty strings from non-empty strings; TPL1.2 only handled the latter two.
@@ -1195,7 +1212,7 @@ static int tpl_sanity(tpl_node *r, int excess_ok) {
       ((tpl_root_data*)(r->data))->flags |= TPL_OLD_STRING_FMT;
     }
     dv = (void*)((uintptr_t)dv + 1);
-    memcpy(&intlsz,dv,sizeof(uint32_t));  /* extract internal size */
+    memcpy(&intlsz, dv, sizeof(uint32_t));  /* extract internal size */
     if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) tpl_byteswap(&intlsz, sizeof(uint32_t));
     if (!excess_ok && (intlsz != bufsz)) return ERR_INCONSISTENT_SZ;  /* inconsisent buffer/internal size */
     dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
@@ -1203,27 +1220,26 @@ static int tpl_sanity(tpl_node *r, int excess_ok) {
     /* dv points to the start of the format string. Look for nul w/in buf sz */
     fmt = (char*)dv;
     while ((uintptr_t)dv-(uintptr_t)d < bufsz && !found_nul) {
-        if ( (c = *(char*)dv) != '\0') {
-            if (strchr(tpl_fmt_chars,c) == NULL)
+        if ((c = *(char*)dv) != '\0') {
+            if (strchr(tpl_fmt_chars, c) == NULL)
                return ERR_FMT_INVALID;  /* invalid char in format string */
-            if ( (c = *(char*)dv) == '#') octothorpes++;
+            if ((c = *(char*)dv) == '#') octothorpes++;
             dv = (void*)((uintptr_t)dv + 1);
-        }
-        else found_nul = 1;
+        } else found_nul = 1;
     }
     if (!found_nul) return ERR_FMT_MISSING_NUL;  /* runaway format string */
     dv = (void*)((uintptr_t)dv + 1);   /* advance to octothorpe lengths buffer */
 
     /* compare the map format to the format of this tpl image */
     mapfmt = tpl_fmt(r);
-    rc = strcmp(mapfmt,fmt);
+    rc = strcmp(mapfmt, fmt);
     if (rc != 0) return ERR_FMT_MISMATCH;
 
     /* compare octothorpe lengths in image to the mapped values */
     if ((((uintptr_t)dv + (octothorpes * 4)) - (uintptr_t)d) > bufsz) return ERR_INCONSISTENT_SZ4;
-    fxlens = tpl_fxlens(r,&num_fxlens);  /* mapped fxlens */
-    while(num_fxlens--) {
-        memcpy(&flen,dv,sizeof(uint32_t)); /* stored flen */
+    fxlens = tpl_fxlens(r, &num_fxlens);  /* mapped fxlens */
+    while (num_fxlens--) {
+        memcpy(&flen, dv, sizeof(uint32_t)); /* stored flen */
         if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) tpl_byteswap(&flen, sizeof(uint32_t));
         if (flen != *fxlens) return ERR_FLEN_MISMATCH;
         dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
@@ -1231,7 +1247,7 @@ static int tpl_sanity(tpl_node *r, int excess_ok) {
     }
 
     /* dv now points to beginning of data */
-    rc = tpl_serlen(r,r,dv,&serlen);  /* get computed serlen of data part */
+    rc = tpl_serlen(r, r, dv, &serlen);  /* get computed serlen of data part */
     if (rc == -1) return ERR_INCONSISTENT_SZ2; /* internal inconsistency in tpl image */
     serlen += ((uintptr_t)dv - (uintptr_t)d);   /* add back serlen of preamble part */
     if (excess_ok && (bufsz < serlen)) return ERR_INCONSISTENT_SZ3;
@@ -1239,11 +1255,12 @@ static int tpl_sanity(tpl_node *r, int excess_ok) {
     return 0;
 }
 
-static void *tpl_find_data_start(void *d) {
-    int octothorpes=0;
+static void *tpl_find_data_start(void *d)
+{
+    int octothorpes = 0;
     d = (void*)((uintptr_t)d + 4); /* skip TPL_MAGIC and flags byte */
     d = (void*)((uintptr_t)d + 4); /* skip int32 overall len */
-    while(*(char*)d != '\0') {
+    while (*(char*)d != '\0') {
         if (*(char*)d == '#') octothorpes++;
         d = (void*)((uintptr_t)d + 1);
     }
@@ -1252,7 +1269,8 @@ static void *tpl_find_data_start(void *d) {
     return d;
 }
 
-static int tpl_needs_endian_swap(void *d) {
+static int tpl_needs_endian_swap(void *d)
+{
     char *c;
     int cpu_is_bigendian;
     c = (char*)d;
@@ -1260,34 +1278,36 @@ static int tpl_needs_endian_swap(void *d) {
     return ((c[3] & TPL_FL_BIGENDIAN) == cpu_is_bigendian) ? 0 : 1;
 }
 
-static size_t tpl_size_for(char c) {
+static size_t tpl_size_for(char c)
+{
   int i;
-  for(i=0; i < sizeof(tpl_types)/sizeof(tpl_types[0]); i++) {
+  for (i = 0; i < sizeof(tpl_types)/sizeof(tpl_types[0]); i++) {
     if (tpl_types[i].c == c) return tpl_types[i].sz;
   }
   return 0;
 }
 
-TPL_API char* tpl_peek(int mode, ...) {
+TPL_API char* tpl_peek(int mode, ...)
+{
     va_list ap;
-    int xendian=0,found_nul=0,old_string_format=0;
-    char *filename=NULL, *datapeek_f=NULL, *datapeek_c, *datapeek_s;
-    void *addr=NULL, *dv, *datapeek_p=NULL;
-    size_t sz=0, fmt_len, first_atom, num_fxlens=0;
+    int xendian = 0, found_nul = 0, old_string_format = 0;
+    char *filename = NULL, *datapeek_f = NULL, *datapeek_c, *datapeek_s;
+    void *addr = NULL, *dv, *datapeek_p = NULL;
+    size_t sz = 0, fmt_len, first_atom, num_fxlens = 0;
     uint32_t datapeek_ssz, datapeek_csz, datapeek_flen;
-    tpl_mmap_rec mr = {0,NULL,0};
-    char *fmt,*fmt_cpy=NULL,c;
-    uint32_t intlsz, **fxlens=NULL, *num_fxlens_out=NULL, *fxlensv;
+    tpl_mmap_rec mr = {0, NULL, 0};
+    char *fmt, *fmt_cpy = NULL, c;
+    uint32_t intlsz, **fxlens = NULL, *num_fxlens_out = NULL, *fxlensv;
 
-    va_start(ap,mode);
+    va_start(ap, mode);
     if ((mode & TPL_FXLENS) && (mode & TPL_DATAPEEK)) {
         tpl_hook.oops("TPL_FXLENS and TPL_DATAPEEK mutually exclusive\n");
         goto fail;
     }
-    if (mode & TPL_FILE) filename = va_arg(ap,char *);
+    if (mode & TPL_FILE) filename = va_arg(ap, char *);
     else if (mode & TPL_MEM) {
-        addr = va_arg(ap,void *);
-        sz = va_arg(ap,size_t);
+        addr = va_arg(ap, void *);
+        sz = va_arg(ap, size_t);
     } else {
         tpl_hook.oops("unsupported tpl_peek mode %d\n", mode);
         goto fail;
@@ -1296,8 +1316,8 @@ TPL_API char* tpl_peek(int mode, ...) {
         datapeek_f = va_arg(ap, char*);
     }
     if (mode & TPL_FXLENS) {
-        num_fxlens_out = va_arg(ap,uint32_t *);
-        fxlens = va_arg(ap,uint32_t **);
+        num_fxlens_out = va_arg(ap, uint32_t *);
+        fxlens = va_arg(ap, uint32_t **);
         *num_fxlens_out = 0;
         *fxlens = NULL;
     }
@@ -1313,11 +1333,11 @@ TPL_API char* tpl_peek(int mode, ...) {
 
     dv = addr;
     if (sz < (4 + sizeof(uint32_t) + 1)) goto fail; /* min sz */
-    if (memcmp(dv,TPL_MAGIC, 3) != 0) goto fail; /* missing tpl magic prefix */
-    if (tpl_needs_endian_swap(dv)) xendian=1;
-    if ((((char*)dv)[3] & TPL_FL_NULLSTRINGS)==0) old_string_format=1;
+    if (memcmp(dv, TPL_MAGIC, 3) != 0) goto fail; /* missing tpl magic prefix */
+    if (tpl_needs_endian_swap(dv)) xendian = 1;
+    if ((((char*)dv)[3] & TPL_FL_NULLSTRINGS) == 0) old_string_format = 1;
     dv = (void*)((uintptr_t)dv + 4);
-    memcpy(&intlsz,dv,sizeof(uint32_t));  /* extract internal size */
+    memcpy(&intlsz, dv, sizeof(uint32_t));  /* extract internal size */
     if (xendian) tpl_byteswap(&intlsz, sizeof(uint32_t));
     if (intlsz != sz) goto fail;  /* inconsisent buffer/internal size */
     dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
@@ -1325,7 +1345,7 @@ TPL_API char* tpl_peek(int mode, ...) {
     /* dv points to the start of the format string. Look for nul w/in buf sz */
     fmt = (char*)dv;
     while ((uintptr_t)dv-(uintptr_t)addr < sz && !found_nul) {
-        if ( (c = *(char*)dv) == '\0') {
+        if ((c = *(char*)dv) == '\0') {
             found_nul = 1;
         } else if (c == '#') {
           num_fxlens++;
@@ -1351,8 +1371,8 @@ TPL_API char* tpl_peek(int mode, ...) {
       if (*fxlens == NULL) tpl_hook.fatal("out of memory");
       *num_fxlens_out = num_fxlens;
       fxlensv = *fxlens;
-      while(num_fxlens--) {
-          memcpy(fxlensv,dv,sizeof(uint32_t));
+      while (num_fxlens--) {
+          memcpy(fxlensv, dv, sizeof(uint32_t));
           if (xendian) tpl_byteswap(fxlensv, sizeof(uint32_t));
           dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
           fxlensv++;
@@ -1370,7 +1390,7 @@ TPL_API char* tpl_peek(int mode, ...) {
          goto fail;
        }
 
-       if (strncmp( &fmt[first_atom], datapeek_f, datapeek_flen) != 0) {
+       if (strncmp(&fmt[first_atom], datapeek_f, datapeek_flen) != 0) {
          tpl_hook.oops("TPL_DATAPEEK format mismatches tpl iamge\n");
          tpl_hook.free(fmt_cpy); fmt_cpy = NULL; /* fail */
          goto fail;
@@ -1378,7 +1398,7 @@ TPL_API char* tpl_peek(int mode, ...) {
 
        /* advance to data start, then copy out requested elements */
        dv = (void*)((uintptr_t)dv +  (num_fxlens * sizeof(uint32_t)));
-       for(datapeek_c = datapeek_f; *datapeek_c != '\0'; datapeek_c++) {
+       for (datapeek_c = datapeek_f; *datapeek_c != '\0'; datapeek_c++) {
          datapeek_p = va_arg(ap, void*);
          if (*datapeek_c == 's') {  /* special handling for strings */
            if ((uintptr_t)dv-(uintptr_t)addr + sizeof(uint32_t) > sz) {
@@ -1386,7 +1406,7 @@ TPL_API char* tpl_peek(int mode, ...) {
              tpl_hook.free(fmt_cpy); fmt_cpy = NULL; /* fail */
              goto fail;
            }
-           memcpy(&datapeek_ssz,dv,sizeof(uint32_t)); /* get slen */
+           memcpy(&datapeek_ssz, dv, sizeof(uint32_t)); /* get slen */
            if (xendian) tpl_byteswap(&datapeek_ssz, sizeof(uint32_t));
            if (old_string_format) datapeek_ssz++;
            dv = (void*)((uintptr_t)dv + sizeof(uint32_t)); /* adv. to str */
@@ -1420,45 +1440,46 @@ TPL_API char* tpl_peek(int mode, ...) {
 
 fail:
     va_end(ap);
-    if ((mode & TPL_FILE) && mr.text != NULL) tpl_unmap_file( &mr );
+    if ((mode & TPL_FILE) && mr.text != NULL) tpl_unmap_file(&mr);
     return fmt_cpy;
 }
 
 /* tpl_jot(TPL_FILE, "file.tpl", "si", &s, &i); */
 /* tpl_jot(TPL_MEM, &buf, &sz, "si", &s, &i); */
 /* tpl_jot(TPL_FD, fd, "si", &s, &i); */
-TPL_API int tpl_jot(int mode, ...) {
+TPL_API int tpl_jot(int mode, ...)
+{
     va_list ap;
     char *filename, *fmt;
     size_t *sz;
-    int fd, rc=0;
+    int fd, rc = 0;
     void **buf;
     tpl_node *tn;
 
-    va_start(ap,mode);
+    va_start(ap, mode);
     if (mode & TPL_FILE) {
-      filename = va_arg(ap,char*);
-      fmt = va_arg(ap,char*);
+      filename = va_arg(ap, char*);
+      fmt = va_arg(ap, char*);
       tn = tpl_map_va(fmt, ap);
-      if (tn == NULL) { rc=-1; goto fail;}
+      if (tn == NULL) {rc = -1; goto fail; }
       tpl_pack(tn, 0);
       rc = tpl_dump(tn, TPL_FILE, filename);
       tpl_free(tn);
     } else if (mode & TPL_MEM) {
-      buf = va_arg(ap,void*);
-      sz = va_arg(ap,size_t*);
-      fmt = va_arg(ap,char*);
-      tn = tpl_map_va(fmt,ap);
-      if (tn == NULL) { rc=-1; goto fail;}
-      tpl_pack(tn,0);
+      buf = va_arg(ap, void*);
+      sz = va_arg(ap, size_t*);
+      fmt = va_arg(ap, char*);
+      tn = tpl_map_va(fmt, ap);
+      if (tn == NULL) {rc = -1; goto fail; }
+      tpl_pack(tn, 0);
       rc = tpl_dump(tn, TPL_MEM, buf, sz);
       tpl_free(tn);
     } else if (mode & TPL_FD) {
-      fd = va_arg(ap,int);
-      fmt = va_arg(ap,char*);
-      tn = tpl_map_va(fmt,ap);
-      if (tn == NULL) { rc=-1; goto fail;}
-      tpl_pack(tn,0);
+      fd = va_arg(ap, int);
+      fmt = va_arg(ap, char*);
+      tn = tpl_map_va(fmt, ap);
+      if (tn == NULL) {rc = -1; goto fail; }
+      tpl_pack(tn, 0);
       rc = tpl_dump(tn, TPL_FD, fd);
       tpl_free(tn);
     } else {
@@ -1470,20 +1491,21 @@ fail:
     return rc;
 }
 
-TPL_API int tpl_load(tpl_node *r, int mode, ...) {
+TPL_API int tpl_load(tpl_node *r, int mode, ...)
+{
     va_list ap;
-    int rc=0,fd=0;
-    char *filename=NULL;
+    int rc = 0, fd = 0;
+    char *filename = NULL;
     void *addr;
     size_t sz;
 
-    va_start(ap,mode);
-    if (mode & TPL_FILE) filename = va_arg(ap,char *);
+    va_start(ap, mode);
+    if (mode & TPL_FILE) filename = va_arg(ap, char *);
     else if (mode & TPL_MEM) {
-        addr = va_arg(ap,void *);
-        sz = va_arg(ap,size_t);
+        addr = va_arg(ap, void *);
+        sz = va_arg(ap, size_t);
     } else if (mode & TPL_FD) {
-        fd = va_arg(ap,int);
+        fd = va_arg(ap, int);
     } else {
         tpl_hook.oops("unsupported tpl_load mode %d\n", mode);
         va_end(ap);
@@ -1504,7 +1526,7 @@ TPL_API int tpl_load(tpl_node *r, int mode, ...) {
             tpl_hook.oops("tpl_load failed for file %s\n", filename);
             return -1;
         }
-        if ( (rc = tpl_sanity(r, (mode & TPL_EXCESS_OK))) != 0) {
+        if ((rc = tpl_sanity(r, (mode & TPL_EXCESS_OK))) != 0) {
             if (rc == ERR_FMT_MISMATCH) {
                 tpl_hook.oops("%s: format signature mismatch\n", filename);
             } else if (rc == ERR_FLEN_MISMATCH) {
@@ -1512,14 +1534,14 @@ TPL_API int tpl_load(tpl_node *r, int mode, ...) {
             } else {
                 tpl_hook.oops("%s: not a valid tpl file\n", filename);
             }
-            tpl_unmap_file( &((tpl_root_data*)(r->data))->mmap );
+            tpl_unmap_file(&((tpl_root_data*)(r->data))->mmap);
             return -1;
         }
         ((tpl_root_data*)(r->data))->flags = (TPL_FILE | TPL_RDONLY);
     } else if (mode & TPL_MEM) {
         ((tpl_root_data*)(r->data))->mmap.text = addr;
         ((tpl_root_data*)(r->data))->mmap.text_sz = sz;
-        if ( (rc = tpl_sanity(r, (mode & TPL_EXCESS_OK))) != 0) {
+        if ((rc = tpl_sanity(r, (mode & TPL_EXCESS_OK))) != 0) {
             if (rc == ERR_FMT_MISMATCH) {
                 tpl_hook.oops("format signature mismatch\n");
             } else {
@@ -1531,7 +1553,7 @@ TPL_API int tpl_load(tpl_node *r, int mode, ...) {
         if (mode & TPL_UFREE) ((tpl_root_data*)(r->data))->flags |= TPL_UFREE;
     } else if (mode & TPL_FD) {
         /* if fd read succeeds, resulting mem img is used for load */
-        if (tpl_gather(TPL_GATHER_BLOCKING,fd,&addr,&sz) > 0) {
+        if (tpl_gather(TPL_GATHER_BLOCKING, fd, &addr, &sz) > 0) {
             return tpl_load(r, TPL_MEM|TPL_UFREE, addr, sz);
         } else return -1;
     } else {
@@ -1545,10 +1567,11 @@ TPL_API int tpl_load(tpl_node *r, int mode, ...) {
     return 0;
 }
 
-TPL_API int tpl_Alen(tpl_node *r, int i) {
+TPL_API int tpl_Alen(tpl_node *r, int i)
+{
     tpl_node *n;
 
-    n = tpl_find_i(r,i);
+    n = tpl_find_i(r, i);
     if (n == NULL) {
         tpl_hook.oops("invalid index %d to tpl_unpack\n", i);
         return -1;
@@ -1557,8 +1580,9 @@ TPL_API int tpl_Alen(tpl_node *r, int i) {
     return ((tpl_atyp*)(n->data))->num;
 }
 
-static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp) {
-    tpl_backbone *bb,*bbnxt;
+static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp)
+{
+    tpl_backbone *bb, *bbnxt;
     tpl_node *c;
     void *dv;
     tpl_bin *binp;
@@ -1572,7 +1596,7 @@ static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp) {
     while (bb) {
         bbnxt = bb->next;
         dv = bb->data;
-        c=n->children;
+        c = n->children;
         while (c) {
             switch (c->type) {
                 case TPL_TYPE_BYTE:
@@ -1586,14 +1610,14 @@ static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp) {
                     dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz*c->num);
                     break;
                 case TPL_TYPE_BIN:
-                    memcpy(&binp,dv,sizeof(tpl_bin*)); /* cp to aligned */
-                    if (binp->addr) tpl_hook.free( binp->addr ); /* free buf */
+                    memcpy(&binp, dv, sizeof(tpl_bin*)); /* cp to aligned */
+                    if (binp->addr) tpl_hook.free(binp->addr); /* free buf */
                     tpl_hook.free(binp);  /* free tpl_bin */
                     dv = (void*)((uintptr_t)dv + sizeof(tpl_bin*));
                     break;
                 case TPL_TYPE_STR:
-                    for(i=0; i < c->num; i++) {
-                      memcpy(&strp,dv,sizeof(char*)); /* cp to aligned */
+                    for (i = 0; i < c->num; i++) {
+                      memcpy(&strp, dv, sizeof(char*)); /* cp to aligned */
                       if (strp) tpl_hook.free(strp); /* free string */
                       dv = (void*)((uintptr_t)dv + sizeof(char*));
                     }
@@ -1610,15 +1634,15 @@ static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp) {
                     }
                     break;
                 case TPL_TYPE_ARY:
-                    memcpy(&atypp,dv,sizeof(tpl_atyp*)); /* cp to aligned */
-                    tpl_free_atyp(c,atypp);  /* free atyp */
+                    memcpy(&atypp, dv, sizeof(tpl_atyp*)); /* cp to aligned */
+                    tpl_free_atyp(c, atypp);  /* free atyp */
                     dv = (void*)((uintptr_t)dv + sizeof(void*));
                     break;
                 default:
                     tpl_hook.fatal("unsupported format character\n");
                     break;
             }
-            c=c->next;
+            c = c->next;
         }
         tpl_hook.free(bb);
         bb = bbnxt;
@@ -1629,11 +1653,12 @@ static void tpl_free_atyp(tpl_node *n, tpl_atyp *atyp) {
 /* determine (by walking) byte length of serialized r/A node at address dv
  * returns 0 on success, or -1 if the tpl isn't trustworthy (fails consistency)
  */
-static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
+static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen)
+{
     uint32_t slen;
-    int num = 0,fidx;
+    int num = 0, fidx;
     tpl_node *c;
-    size_t len=0, alen, buf_past, itermax;
+    size_t len = 0, alen, buf_past, itermax;
     tpl_pound_data *pd;
 
     buf_past = ((uintptr_t)((tpl_root_data*)(r->data))->mmap.text +
@@ -1642,7 +1667,7 @@ static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
     if (n->type == TPL_TYPE_ROOT) num = 1;
     else if (n->type == TPL_TYPE_ARY) {
         if ((uintptr_t)dv + sizeof(uint32_t) > buf_past) return -1;
-        memcpy(&num,dv,sizeof(uint32_t));
+        memcpy(&num, dv, sizeof(uint32_t));
         if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
              tpl_byteswap(&num, sizeof(uint32_t));
         dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
@@ -1650,7 +1675,7 @@ static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
     } else tpl_hook.fatal("internal error in tpl_serlen\n");
 
     while (num-- > 0) {
-        c=n->children;
+        c = n->children;
         while (c) {
             switch (c->type) {
                 case TPL_TYPE_BYTE:
@@ -1661,7 +1686,7 @@ static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
                 case TPL_TYPE_UINT64:
                 case TPL_TYPE_INT16:
                 case TPL_TYPE_UINT16:
-                    for(fidx=0; fidx < c->num; fidx++) {  /* octothorpe support */
+                    for (fidx = 0; fidx < c->num; fidx++) {  /* octothorpe support */
                         if ((uintptr_t)dv + tpl_types[c->type].sz > buf_past) return -1;
                         dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz);
                         len += tpl_types[c->type].sz;
@@ -1670,7 +1695,7 @@ static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
                 case TPL_TYPE_BIN:
                     len += sizeof(uint32_t);
                     if ((uintptr_t)dv + sizeof(uint32_t) > buf_past) return -1;
-                    memcpy(&slen,dv,sizeof(uint32_t));
+                    memcpy(&slen, dv, sizeof(uint32_t));
                     if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                         tpl_byteswap(&slen, sizeof(uint32_t));
                     len += slen;
@@ -1679,14 +1704,14 @@ static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
                     dv = (void*)((uintptr_t)dv + slen);
                     break;
                 case TPL_TYPE_STR:
-                    for(fidx=0; fidx < c->num; fidx++) {  /* octothorpe support */
+                    for (fidx = 0; fidx < c->num; fidx++) {  /* octothorpe support */
                       len += sizeof(uint32_t);
                       if ((uintptr_t)dv + sizeof(uint32_t) > buf_past) return -1;
-                      memcpy(&slen,dv,sizeof(uint32_t));
+                      memcpy(&slen, dv, sizeof(uint32_t));
                       if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                           tpl_byteswap(&slen, sizeof(uint32_t));
                       if (!(((tpl_root_data*)(r->data))->flags & TPL_OLD_STRING_FMT))
-                         slen = (slen>1) ? (slen-1) : 0;
+                         slen = (slen > 1) ? (slen-1) : 0;
                       len += slen;
                       dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
                       if ((uintptr_t)dv + slen > buf_past) return -1;
@@ -1694,7 +1719,7 @@ static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
                     }
                     break;
                 case TPL_TYPE_ARY:
-                    if ( tpl_serlen(r,c,dv, &alen) == -1) return -1;
+                    if (tpl_serlen(r, c, dv, &alen) == -1) return -1;
                     dv = (void*)((uintptr_t)dv + alen);
                     len += alen;
                     break;
@@ -1713,26 +1738,27 @@ static int tpl_serlen(tpl_node *r, tpl_node *n, void *dv, size_t *serlen) {
                     tpl_hook.fatal("unsupported format character\n");
                     break;
             }
-            c=c->next;
+            c = c->next;
         }
     }
     *serlen = len;
     return 0;
 }
 
-static int tpl_mmap_output_file(char *filename, size_t sz, void **text_out) {
+static int tpl_mmap_output_file(char *filename, size_t sz, void **text_out)
+{
     void *text;
-    int fd,perms;
+    int fd, perms;
 
 #ifndef _WIN32
     perms = S_IRUSR|S_IWUSR|S_IWGRP|S_IRGRP|S_IROTH;  /* ug+w o+r */
-    fd=open(filename,O_CREAT|O_TRUNC|O_RDWR,perms);
+    fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, perms);
 #else
        perms = _S_IWRITE;
-    fd=_open(filename,_O_CREAT|_O_TRUNC|_O_RDWR,perms);
+    fd = _open(filename, _O_CREAT|_O_TRUNC|_O_RDWR, perms);
 #endif
 
-    if ( fd == -1 ) {
+    if (fd == -1) {
         tpl_hook.oops("Couldn't open file %s: %s\n", filename, strerror(errno));
         return -1;
     }
@@ -1743,9 +1769,9 @@ static int tpl_mmap_output_file(char *filename, size_t sz, void **text_out) {
         close(fd);
         return -1;
     }
-    if (ftruncate(fd,sz) == -1) {
+    if (ftruncate(fd, sz) == -1) {
         tpl_hook.oops("ftruncate failed: %s\n", strerror(errno));
-        munmap( text, sz );
+        munmap(text, sz);
         close(fd);
         return -1;
     }
@@ -1753,15 +1779,16 @@ static int tpl_mmap_output_file(char *filename, size_t sz, void **text_out) {
     return fd;
 }
 
-static int tpl_mmap_file(char *filename, tpl_mmap_rec *mr) {
+static int tpl_mmap_file(char *filename, tpl_mmap_rec *mr)
+{
     struct stat stat_buf;
 
-    if ( (mr->fd = open(filename, O_RDONLY)) == -1 ) {
+    if ((mr->fd = open(filename, O_RDONLY)) == -1) {
         tpl_hook.oops("Couldn't open file %s: %s\n", filename, strerror(errno));
         return -1;
     }
 
-    if ( fstat(mr->fd, &stat_buf) == -1) {
+    if (fstat(mr->fd, &stat_buf) == -1) {
         close(mr->fd);
         tpl_hook.oops("Couldn't stat file %s: %s\n", filename, strerror(errno));
         return -1;
@@ -1778,9 +1805,10 @@ static int tpl_mmap_file(char *filename, tpl_mmap_rec *mr) {
     return 0;
 }
 
-TPL_API int tpl_pack(tpl_node *r, int i) {
+TPL_API int tpl_pack(tpl_node *r, int i)
+{
     tpl_node *n, *child, *np;
-    void *datav=NULL;
+    void *datav = NULL;
     size_t sz, itermax;
     uint32_t slen;
     char *str;
@@ -1788,7 +1816,7 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
     tpl_pound_data *pd;
     int fidx;
 
-    n = tpl_find_i(r,i);
+    n = tpl_find_i(r, i);
     if (n == NULL) {
         tpl_hook.oops("invalid index %d to tpl_pack\n", i);
         return -1;
@@ -1803,8 +1831,8 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
 
     if (n->type == TPL_TYPE_ARY) datav = tpl_extend_backbone(n);
     child = n->children;
-    while(child) {
-        switch(child->type) {
+    while (child) {
+        switch (child->type) {
             case TPL_TYPE_BYTE:
             case TPL_TYPE_DOUBLE:
             case TPL_TYPE_INT32:
@@ -1814,17 +1842,17 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
             case TPL_TYPE_INT16:
             case TPL_TYPE_UINT16:
                 /* no need to use fidx iteration here; we can copy multiple values in one memcpy */
-                memcpy(child->data,child->addr,tpl_types[child->type].sz * child->num);
-                if (datav) datav = tpl_cpv(datav,child->data,tpl_types[child->type].sz * child->num);
+                memcpy(child->data, child->addr, tpl_types[child->type].sz * child->num);
+                if (datav) datav = tpl_cpv(datav, child->data, tpl_types[child->type].sz * child->num);
                 if (n->type == TPL_TYPE_ARY) n->ser_osz += tpl_types[child->type].sz * child->num;
                 break;
             case TPL_TYPE_BIN:
                 /* copy the buffer to be packed */
                 slen = ((tpl_bin*)child->addr)->sz;
-                if (slen >0) {
+                if (slen > 0) {
                     str = tpl_hook.malloc(slen);
                     if (!str) fatal_oom();
-                    memcpy(str,((tpl_bin*)child->addr)->addr,slen);
+                    memcpy(str, ((tpl_bin*)child->addr)->addr, slen);
                 } else str = NULL;
                 /* and make a tpl_bin to point to it */
                 bin = tpl_hook.malloc(sizeof(tpl_bin));
@@ -1834,11 +1862,11 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
                 /* now pack its pointer, first deep freeing any pre-existing bin */
                 if (*(tpl_bin**)(child->data) != NULL) {
                     if ((*(tpl_bin**)(child->data))->sz != 0) {
-                            tpl_hook.free( (*(tpl_bin**)(child->data))->addr );
+                            tpl_hook.free((*(tpl_bin**)(child->data))->addr);
                     }
                     tpl_hook.free(*(tpl_bin**)(child->data));
                 }
-                memcpy(child->data,&bin,sizeof(tpl_bin*));
+                memcpy(child->data, &bin, sizeof(tpl_bin*));
                 if (datav) {
                     datav = tpl_cpv(datav, &bin, sizeof(tpl_bin*));
                     *(tpl_bin**)(child->data) = NULL;
@@ -1849,7 +1877,7 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
                 }
                 break;
             case TPL_TYPE_STR:
-                for(fidx=0; fidx < child->num; fidx++) {
+                for (fidx = 0; fidx < child->num; fidx++) {
                   /* copy the string to be packed. slen includes \0. this
                      block also works if the string pointer is NULL. */
                   char *caddr = ((char**)child->addr)[fidx];
@@ -1858,7 +1886,7 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
                   if (slen) {
                     str = tpl_hook.malloc(slen);
                     if (!str) fatal_oom();
-                    memcpy(str,caddr,slen); /* include \0 */
+                    memcpy(str, caddr, slen); /* include \0 */
                   } else {
                     str = NULL;
                   }
@@ -1866,14 +1894,14 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
                   if (*cdata != NULL) {
                       tpl_hook.free(*cdata);
                   }
-                  memcpy(cdata,&str,sizeof(char*));
+                  memcpy(cdata, &str, sizeof(char*));
                   if (datav) {
                       datav = tpl_cpv(datav, &str, sizeof(char*));
                       *cdata = NULL;
                   }
                   if (n->type == TPL_TYPE_ARY) {
                       n->ser_osz += sizeof(uint32_t); /* string len word */
-                      if (slen>1) n->ser_osz += slen-1;/* string (without nul) */
+                      if (slen > 1) n->ser_osz += slen-1;/* string (without nul) */
                   }
                 }
                 break;
@@ -1911,7 +1939,7 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
                  if (++(pd->iternum) < itermax) {
 
                    /* in start or midst of loop. advance addr/data pointers. */
-                   for(np=pd->iter_start_node; np != child; np = np->next) {
+                   for (np = pd->iter_start_node; np != child; np = np->next) {
                      np->data = (char*)(np->data) +
                           (tpl_types[np->type].sz * np->num);
                      np->addr = (char*)(np->addr) + pd->inter_elt_len;
@@ -1924,7 +1952,7 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
 
                    /* reset iteration index and addr/data pointers. */
                    pd->iternum = 0;
-                   for(np=pd->iter_start_node; np != child; np = np->next) {
+                   for (np = pd->iter_start_node; np != child; np = np->next) {
                      np->data = (char*)(np->data) - ((itermax-1) *
                                                       tpl_types[np->type].sz *
                                                       np->num);
@@ -1937,34 +1965,35 @@ TPL_API int tpl_pack(tpl_node *r, int i) {
                 tpl_hook.fatal("unsupported format character\n");
                 break;
         }
-        child=child->next;
+        child = child->next;
     }
     return 0;
 }
 
-TPL_API int tpl_unpack(tpl_node *r, int i) {
+TPL_API int tpl_unpack(tpl_node *r, int i)
+{
     tpl_node *n, *c, *np;
     uint32_t slen;
-    int rc=1, fidx;
+    int rc = 1, fidx;
     char *str;
-    void *dv=NULL, *caddr;
+    void *dv = NULL, *caddr;
     size_t A_bytes, itermax;
     tpl_pound_data *pd;
     void *img;
     size_t sz;
 
 
-    /* handle unusual case of tpl_pack,tpl_unpack without an
+    /* handle unusual case of tpl_pack, tpl_unpack without an
      * intervening tpl_dump. do a dump/load implicitly. */
     if (((tpl_root_data*)(r->data))->flags & TPL_WRONLY) {
-        if (tpl_dump(r,TPL_MEM,&img,&sz) != 0) return -1;
-        if (tpl_load(r,TPL_MEM|TPL_UFREE,img,sz) != 0) {
+        if (tpl_dump(r, TPL_MEM, &img, &sz) != 0) return -1;
+        if (tpl_load(r, TPL_MEM|TPL_UFREE, img, sz) != 0) {
             tpl_hook.free(img);
             return -1;
         };
     }
 
-    n = tpl_find_i(r,i);
+    n = tpl_find_i(r, i);
     if (n == NULL) {
         tpl_hook.oops("invalid index %d to tpl_unpack\n", i);
         return -1;
@@ -1972,7 +2001,7 @@ TPL_API int tpl_unpack(tpl_node *r, int i) {
 
     /* either root node or an A node */
     if (n->type == TPL_TYPE_ROOT) {
-        dv = tpl_find_data_start( ((tpl_root_data*)(n->data))->mmap.text );
+        dv = tpl_find_data_start(((tpl_root_data*)(n->data))->mmap.text);
     } else if (n->type == TPL_TYPE_ARY) {
         if (((tpl_atyp*)(n->data))->num <= 0) return 0; /* array consumed */
         else rc = ((tpl_atyp*)(n->data))->num--;
@@ -1993,9 +2022,9 @@ TPL_API int tpl_unpack(tpl_node *r, int i) {
             case TPL_TYPE_UINT16:
                 /* unpack elements of cross-endian octothorpic array individually */
                 if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN) {
-                    for(fidx=0; fidx < c->num; fidx++) {
+                    for (fidx = 0; fidx < c->num; fidx++) {
                         caddr = (void*)((uintptr_t)c->addr + (fidx * tpl_types[c->type].sz));
-                        memcpy(caddr,dv,tpl_types[c->type].sz);
+                        memcpy(caddr, dv, tpl_types[c->type].sz);
                         tpl_byteswap(caddr, tpl_types[c->type].sz);
                         dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz);
                     }
@@ -2006,22 +2035,22 @@ TPL_API int tpl_unpack(tpl_node *r, int i) {
                 }
                 break;
             case TPL_TYPE_BIN:
-                memcpy(&slen,dv,sizeof(uint32_t));
+                memcpy(&slen, dv, sizeof(uint32_t));
                 if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                     tpl_byteswap(&slen, sizeof(uint32_t));
                 if (slen > 0) {
                     str = (char*)tpl_hook.malloc(slen);
                     if (!str) fatal_oom();
-                } else str=NULL;
+                } else str = NULL;
                 dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
-                if (slen>0) memcpy(str,dv,slen);
-                memcpy(&(((tpl_bin*)c->addr)->addr),&str,sizeof(void*));
-                memcpy(&(((tpl_bin*)c->addr)->sz),&slen,sizeof(uint32_t));
+                if (slen > 0) memcpy(str, dv, slen);
+                memcpy(&(((tpl_bin*)c->addr)->addr), &str, sizeof(void*));
+                memcpy(&(((tpl_bin*)c->addr)->sz), &slen, sizeof(uint32_t));
                 dv = (void*)((uintptr_t)dv + slen);
                 break;
             case TPL_TYPE_STR:
-                for(fidx=0; fidx < c->num; fidx++) {
-                  memcpy(&slen,dv,sizeof(uint32_t));
+                for (fidx = 0; fidx < c->num; fidx++) {
+                  memcpy(&slen, dv, sizeof(uint32_t));
                   if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                       tpl_byteswap(&slen, sizeof(uint32_t));
                   if (((tpl_root_data*)(r->data))->flags & TPL_OLD_STRING_FMT)
@@ -2030,11 +2059,11 @@ TPL_API int tpl_unpack(tpl_node *r, int i) {
                   if (slen) {  /* slen includes \0 */
                     str = (char*)tpl_hook.malloc(slen);
                     if (!str) fatal_oom();
-                    if (slen>1) memcpy(str,dv,slen-1);
+                    if (slen > 1) memcpy(str, dv, slen-1);
                     str[slen-1] = '\0'; /* nul terminate */
                     dv = (void*)((uintptr_t)dv + slen-1);
-                  } else str=NULL;
-                  memcpy(&((char**)c->addr)[fidx],&str,sizeof(char*));
+                  } else str = NULL;
+                  memcpy(&((char**)c->addr)[fidx], &str, sizeof(char*));
                 }
                 break;
             case TPL_TYPE_POUND:
@@ -2043,7 +2072,7 @@ TPL_API int tpl_unpack(tpl_node *r, int i) {
                 itermax = c->num;
                 if (++(pd->iternum) < itermax) {
                   /* in start or midst of loop. advance addr/data pointers. */
-                  for(np=pd->iter_start_node; np != c; np = np->next) {
+                  for (np = pd->iter_start_node; np != c; np = np->next) {
                     np->addr = (char*)(np->addr) + pd->inter_elt_len;
                   }
                   /* do next iteration */
@@ -2054,16 +2083,16 @@ TPL_API int tpl_unpack(tpl_node *r, int i) {
 
                   /* reset iteration index and addr/data pointers. */
                   pd->iternum = 0;
-                  for(np=pd->iter_start_node; np != c; np = np->next) {
+                  for (np = pd->iter_start_node; np != c; np = np->next) {
                     np->addr = (char*)(np->addr) - ((itermax-1) * pd->inter_elt_len);
                   }
 
                 }
                 break;
             case TPL_TYPE_ARY:
-                if (tpl_serlen(r,c,dv, &A_bytes) == -1)
+                if (tpl_serlen(r, c, dv, &A_bytes) == -1)
                     tpl_hook.fatal("internal error in unpack\n");
-                memcpy( &((tpl_atyp*)(c->data))->num, dv, sizeof(uint32_t));
+                memcpy(&((tpl_atyp*)(c->data))->num, dv, sizeof(uint32_t));
                 if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                     tpl_byteswap(&((tpl_atyp*)(c->data))->num, sizeof(uint32_t));
                 ((tpl_atyp*)(c->data))->cur = (void*)((uintptr_t)dv+sizeof(uint32_t));
@@ -2081,18 +2110,19 @@ TPL_API int tpl_unpack(tpl_node *r, int i) {
 }
 
 /* Specialized function that unpacks only the root's A nodes, after tpl_load  */
-static int tpl_unpackA0(tpl_node *r) {
+static int tpl_unpackA0(tpl_node *r)
+{
     tpl_node *n, *c;
     uint32_t slen;
-    int rc=1,fidx,i;
+    int rc = 1, fidx, i;
     void *dv;
     size_t A_bytes, itermax;
     tpl_pound_data *pd;
 
     n = r;
-    dv = tpl_find_data_start( ((tpl_root_data*)(r->data))->mmap.text);
+    dv = tpl_find_data_start(((tpl_root_data*)(r->data))->mmap.text);
 
-    c=n->children;
+    c = n->children;
     while (c)  {
         switch (c->type) {
             case TPL_TYPE_BYTE:
@@ -2103,26 +2133,26 @@ static int tpl_unpackA0(tpl_node *r) {
             case TPL_TYPE_UINT64:
             case TPL_TYPE_INT16:
             case TPL_TYPE_UINT16:
-                for(fidx=0;fidx < c->num; fidx++) {
+                for (fidx = 0; fidx < c->num; fidx++) {
                     dv = (void*)((uintptr_t)dv + tpl_types[c->type].sz);
                 }
                 break;
             case TPL_TYPE_BIN:
-                memcpy(&slen,dv,sizeof(uint32_t));
+                memcpy(&slen, dv, sizeof(uint32_t));
                 if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                     tpl_byteswap(&slen, sizeof(uint32_t));
                 dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
                 dv = (void*)((uintptr_t)dv + slen);
                 break;
             case TPL_TYPE_STR:
-                for(i=0; i<c->num; i++) {
-                  memcpy(&slen,dv,sizeof(uint32_t));
+                for (i = 0; i < c->num; i++) {
+                  memcpy(&slen, dv, sizeof(uint32_t));
                   if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                       tpl_byteswap(&slen, sizeof(uint32_t));
                   if (((tpl_root_data*)(r->data))->flags & TPL_OLD_STRING_FMT)
                     slen += 1;
                   dv = (void*)((uintptr_t)dv + sizeof(uint32_t));
-                  if (slen>1) dv = (void*)((uintptr_t)dv + slen-1);
+                  if (slen > 1) dv = (void*)((uintptr_t)dv + slen-1);
                 }
                 break;
             case TPL_TYPE_POUND:
@@ -2137,9 +2167,9 @@ static int tpl_unpackA0(tpl_node *r) {
                 }
                 break;
             case TPL_TYPE_ARY:
-                if ( tpl_serlen(r,c,dv, &A_bytes) == -1)
+                if (tpl_serlen(r, c, dv, &A_bytes) == -1)
                     tpl_hook.fatal("internal error in unpackA0\n");
-                memcpy( &((tpl_atyp*)(c->data))->num, dv, sizeof(uint32_t));
+                memcpy(&((tpl_atyp*)(c->data))->num, dv, sizeof(uint32_t));
                 if (((tpl_root_data*)(r->data))->flags & TPL_XENDIAN)
                     tpl_byteswap(&((tpl_atyp*)(c->data))->num, sizeof(uint32_t));
                 ((tpl_atyp*)(c->data))->cur = (void*)((uintptr_t)dv+sizeof(uint32_t));
@@ -2149,28 +2179,30 @@ static int tpl_unpackA0(tpl_node *r) {
                 tpl_hook.fatal("unsupported format character\n");
                 break;
         }
-        c=c->next;
+        c = c->next;
     }
     return rc;
 }
 
 /* In-place byte order swapping of a word of length "len" bytes */
-static void tpl_byteswap(void *word, int len) {
+static void tpl_byteswap(void *word, int len)
+{
     int i;
     char c, *w;
     w = (char*)word;
-    for(i=0; i<len/2; i++) {
+    for (i = 0; i < len/2; i++) {
         c = w[i];
         w[i] = w[len-1-i];
         w[len-1-i] = c;
     }
 }
 
-static void tpl_fatal(char *fmt, ...) {
+static void tpl_fatal(char *fmt, ...)
+{
     va_list ap;
     char exit_msg[100];
 
-    va_start(ap,fmt);
+    va_start(ap, fmt);
     vsnprintf(exit_msg, 100, fmt, ap);
     va_end(ap);
 
@@ -2178,39 +2210,40 @@ static void tpl_fatal(char *fmt, ...) {
     exit(-1);
 }
 
-TPL_API int tpl_gather(int mode, ...) {
+TPL_API int tpl_gather(int mode, ...)
+{
     va_list ap;
-    int fd,rc=0;
-    size_t *szp,sz;
-    void **img,*addr,*data;
+    int fd, rc = 0;
+    size_t *szp, sz;
+    void **img, *addr, *data;
     tpl_gather_t **gs;
     tpl_gather_cb *cb;
 
-    va_start(ap,mode);
+    va_start(ap, mode);
     switch (mode) {
         case TPL_GATHER_BLOCKING:
-            fd = va_arg(ap,int);
-            img = va_arg(ap,void*);
-            szp = va_arg(ap,size_t*);
-            rc = tpl_gather_blocking(fd,img,szp);
+            fd = va_arg(ap, int);
+            img = va_arg(ap, void*);
+            szp = va_arg(ap, size_t*);
+            rc = tpl_gather_blocking(fd, img, szp);
             break;
         case TPL_GATHER_NONBLOCKING:
-            fd = va_arg(ap,int);
-            gs = (tpl_gather_t**)va_arg(ap,void*);
-            cb = (tpl_gather_cb*)va_arg(ap,tpl_gather_cb*);
-            data = va_arg(ap,void*);
-            rc = tpl_gather_nonblocking(fd,gs,cb,data);
+            fd = va_arg(ap, int);
+            gs = (tpl_gather_t**)va_arg(ap, void*);
+            cb = (tpl_gather_cb*)va_arg(ap, tpl_gather_cb*);
+            data = va_arg(ap, void*);
+            rc = tpl_gather_nonblocking(fd, gs, cb, data);
             break;
         case TPL_GATHER_MEM:
-            addr = va_arg(ap,void*);
-            sz = va_arg(ap,size_t);
-            gs = (tpl_gather_t**)va_arg(ap,void*);
-            cb = (tpl_gather_cb*)va_arg(ap,tpl_gather_cb*);
-            data = va_arg(ap,void*);
-            rc = tpl_gather_mem(addr,sz,gs,cb,data);
+            addr = va_arg(ap, void*);
+            sz = va_arg(ap, size_t);
+            gs = (tpl_gather_t**)va_arg(ap, void*);
+            cb = (tpl_gather_cb*)va_arg(ap, tpl_gather_cb*);
+            data = va_arg(ap, void*);
+            rc = tpl_gather_mem(addr, sz, gs, cb, data);
             break;
         default:
-            tpl_hook.fatal("unsupported tpl_gather mode %d\n",mode);
+            tpl_hook.fatal("unsupported tpl_gather mode %d\n", mode);
             break;
     }
     va_end(ap);
@@ -2222,17 +2255,18 @@ TPL_API int tpl_gather(int mode, ...) {
  * This is intended as a blocking call i.e. for use with a blocking fd.
  * It can be given a non-blocking fd, but the read spins if we have to wait.
  */
-static int tpl_gather_blocking(int fd, void **img, size_t *sz) {
+static int tpl_gather_blocking(int fd, void **img, size_t *sz)
+{
     char preamble[8];
-    int i=0, rc;
+    int i = 0, rc;
     uint32_t tpllen;
 
     do {
-        rc = read(fd,&preamble[i],8-i);
-        i += (rc>0) ? rc : 0;
-    } while ((rc==-1 && (errno==EINTR||errno==EAGAIN)) || (rc>0 && i<8));
+        rc = read(fd, &preamble[i], 8-i);
+        i += (rc > 0) ? rc : 0;
+    } while ((rc == -1 && (errno == EINTR || errno == EAGAIN)) || (rc > 0 && i < 8));
 
-    if (rc<0) {
+    if (rc < 0) {
         tpl_hook.oops("tpl_gather_fd_blocking failed: %s\n", strerror(errno));
         return -1;
     } else if (rc == 0) {
@@ -2244,8 +2278,8 @@ static int tpl_gather_blocking(int fd, void **img, size_t *sz) {
     }
 
     if (preamble[0] == 't' && preamble[1] == 'p' && preamble[2] == 'l') {
-        memcpy(&tpllen,&preamble[4],4);
-        if (tpl_needs_endian_swap(preamble)) tpl_byteswap(&tpllen,4);
+        memcpy(&tpllen, &preamble[4], 4);
+        if (tpl_needs_endian_swap(preamble)) tpl_byteswap(&tpllen, 4);
     } else {
         tpl_hook.oops("tpl_gather_fd_blocking: non-tpl input\n");
         return -1;
@@ -2261,18 +2295,18 @@ static int tpl_gather_blocking(int fd, void **img, size_t *sz) {
         return -2;
     }
     *sz = tpllen;
-    if ( (*img = tpl_hook.malloc(tpllen)) == NULL) {
+    if ((*img = tpl_hook.malloc(tpllen)) == NULL) {
         fatal_oom();
     }
 
-    memcpy(*img,preamble,8);  /* copy preamble to output buffer */
-    i=8;
+    memcpy(*img, preamble, 8);  /* copy preamble to output buffer */
+    i = 8;
     do {
-        rc = read(fd,&((*(char**)img)[i]),tpllen-i);
-        i += (rc>0) ? rc : 0;
-    } while ((rc==-1 && (errno==EINTR||errno==EAGAIN)) || (rc>0 && i<tpllen));
+        rc = read(fd, &((*(char**)img)[i]), tpllen-i);
+        i += (rc > 0) ? rc : 0;
+    } while ((rc == -1 && (errno == EINTR || errno == EAGAIN)) || (rc > 0 && i < tpllen));
 
-    if (rc<0) {
+    if (rc < 0) {
         tpl_hook.oops("tpl_gather_fd_blocking failed: %s\n", strerror(errno));
         tpl_hook.free(*img);
         return -1;
@@ -2291,14 +2325,15 @@ static int tpl_gather_blocking(int fd, void **img, size_t *sz) {
 
 /* Used by select()-driven apps which want to gather tpl images piecemeal */
 /* the file descriptor must be non-blocking for this functino to work. */
-static int tpl_gather_nonblocking( int fd, tpl_gather_t **gs, tpl_gather_cb *cb, void *data) {
+static int tpl_gather_nonblocking(int fd, tpl_gather_t **gs, tpl_gather_cb *cb, void *data)
+{
     char buf[TPL_GATHER_BUFLEN], *img, *tpl;
-    int rc, keep_looping, cbrc=0;
+    int rc, keep_looping, cbrc = 0;
     size_t catlen;
     uint32_t tpllen;
 
     while (1) {
-        rc = read(fd,buf,TPL_GATHER_BUFLEN);
+        rc = read(fd, buf, TPL_GATHER_BUFLEN);
         if (rc == -1) {
             if (errno == EINTR) continue;  /* got signal during read, ignore */
             if (errno == EAGAIN) return 1; /* nothing to read right now */
@@ -2325,14 +2360,14 @@ static int tpl_gather_nonblocking( int fd, tpl_gather_t **gs, tpl_gather_cb *cb,
                 catlen = (*gs)->len + rc;
                 if (tpl_hook.gather_max > 0 &&
                     catlen > tpl_hook.gather_max) {
-                    tpl_hook.free( (*gs)->img );
-                    tpl_hook.free( (*gs) );
+                    tpl_hook.free((*gs)->img);
+                    tpl_hook.free((*gs));
                     *gs = NULL;
                     tpl_hook.oops("tpl exceeds max length %d\n",
                         tpl_hook.gather_max);
                     return -2;              /* error, caller should close fd */
                 }
-                if ( (img = tpl_hook.realloc((*gs)->img, catlen)) == NULL) {
+                if ((img = tpl_hook.realloc((*gs)->img, catlen)) == NULL) {
                     fatal_oom();
                 }
                 memcpy(img + (*gs)->len, buf, rc);
@@ -2353,14 +2388,14 @@ static int tpl_gather_nonblocking( int fd, tpl_gather_t **gs, tpl_gather_cb *cb,
                     *gs = NULL;
                     return -3; /* error, caller should close fd */
                 }
-                memcpy(&tpllen,&tpl[4],4);
-                if (tpl_needs_endian_swap(tpl)) tpl_byteswap(&tpllen,4);
+                memcpy(&tpllen, &tpl[4], 4);
+                if (tpl_needs_endian_swap(tpl)) tpl_byteswap(&tpllen, 4);
                 if (tpl+tpllen <= img+catlen) {
-                    cbrc = (cb)(tpl,tpllen,data);  /* invoke cb for tpl image */
+                    cbrc = (cb)(tpl, tpllen, data);  /* invoke cb for tpl image */
                     tpl += tpllen;                 /* point to next tpl image */
                     if (cbrc < 0) keep_looping = 0;
                     else keep_looping = (tpl+8 < img+catlen) ? 1 : 0;
-                } else keep_looping=0;
+                } else keep_looping = 0;
             }
             /* check if app callback requested closure of tpl source */
             if (cbrc < 0) {
@@ -2372,22 +2407,22 @@ static int tpl_gather_nonblocking( int fd, tpl_gather_t **gs, tpl_gather_cb *cb,
             }
             /* store any leftover, partial tpl fragment for next read */
             if (tpl == img && img != buf) {
-                /* consumed nothing from img!=buf */
-                if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) {
+                /* consumed nothing from img!= buf */
+                if ((*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL) {
                     fatal_oom();
                 }
                 (*gs)->img = tpl;
                 (*gs)->len = catlen;
             } else if (tpl < img+catlen) {
-                /* consumed 1+ tpl(s) from img!=buf or 0 from img==buf */
-                if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) {
+                /* consumed 1+ tpl(s) from img!= buf or 0 from img == buf */
+                if ((*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL) {
                     fatal_oom();
                 }
-                if ( ((*gs)->img = tpl_hook.malloc(img+catlen - tpl)) == NULL ) {
+                if (((*gs)->img = tpl_hook.malloc(img+catlen - tpl)) == NULL) {
                     fatal_oom();
                 }
                 (*gs)->len = img+catlen - tpl;
-                memcpy( (*gs)->img, tpl, img+catlen - tpl);
+                memcpy((*gs)->img, tpl, img+catlen - tpl);
                 /* free partially consumed concat buffer if used */
                 if (img != buf) tpl_hook.free(img);
             } else {                        /* tpl(s) fully consumed */
@@ -2399,9 +2434,10 @@ static int tpl_gather_nonblocking( int fd, tpl_gather_t **gs, tpl_gather_cb *cb,
 }
 
 /* gather tpl piecemeal from memory buffer (not fd) e.g., from a lower-level api */
-static int tpl_gather_mem( char *buf, size_t len, tpl_gather_t **gs, tpl_gather_cb *cb, void *data) {
+static int tpl_gather_mem(char *buf, size_t len, tpl_gather_t **gs, tpl_gather_cb *cb, void *data)
+{
     char *img, *tpl;
-    int keep_looping, cbrc=0;
+    int keep_looping, cbrc = 0;
     size_t catlen;
     uint32_t tpllen;
 
@@ -2410,14 +2446,14 @@ static int tpl_gather_mem( char *buf, size_t len, tpl_gather_t **gs, tpl_gather_
         catlen = (*gs)->len + len;
         if (tpl_hook.gather_max > 0 &&
             catlen > tpl_hook.gather_max) {
-            tpl_hook.free( (*gs)->img );
-            tpl_hook.free( (*gs) );
+            tpl_hook.free((*gs)->img);
+            tpl_hook.free((*gs));
             *gs = NULL;
             tpl_hook.oops("tpl exceeds max length %d\n",
                 tpl_hook.gather_max);
             return -2;              /* error, caller should stop accepting input from source*/
         }
-        if ( (img = tpl_hook.realloc((*gs)->img, catlen)) == NULL) {
+        if ((img = tpl_hook.realloc((*gs)->img, catlen)) == NULL) {
             fatal_oom();
         }
         memcpy(img + (*gs)->len, buf, len);
@@ -2438,14 +2474,14 @@ static int tpl_gather_mem( char *buf, size_t len, tpl_gather_t **gs, tpl_gather_
             *gs = NULL;
             return -3; /* error, caller should stop accepting input from source*/
         }
-        memcpy(&tpllen,&tpl[4],4);
-        if (tpl_needs_endian_swap(tpl)) tpl_byteswap(&tpllen,4);
+        memcpy(&tpllen, &tpl[4], 4);
+        if (tpl_needs_endian_swap(tpl)) tpl_byteswap(&tpllen, 4);
         if (tpl+tpllen <= img+catlen) {
-            cbrc = (cb)(tpl,tpllen,data);  /* invoke cb for tpl image */
+            cbrc = (cb)(tpl, tpllen, data);  /* invoke cb for tpl image */
             tpl += tpllen;               /* point to next tpl image */
             if (cbrc < 0) keep_looping = 0;
             else keep_looping = (tpl+8 < img+catlen) ? 1 : 0;
-        } else keep_looping=0;
+        } else keep_looping = 0;
     }
     /* check if app callback requested closure of tpl source */
     if (cbrc < 0) {
@@ -2457,22 +2493,22 @@ static int tpl_gather_mem( char *buf, size_t len, tpl_gather_t **gs, tpl_gather_
     }
     /* store any leftover, partial tpl fragment for next read */
     if (tpl == img && img != buf) {
-        /* consumed nothing from img!=buf */
-        if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) {
+        /* consumed nothing from img!= buf */
+        if ((*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL) {
             fatal_oom();
         }
         (*gs)->img = tpl;
         (*gs)->len = catlen;
     } else if (tpl < img+catlen) {
-        /* consumed 1+ tpl(s) from img!=buf or 0 from img==buf */
-        if ( (*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL ) {
+        /* consumed 1+ tpl(s) from img!= buf or 0 from img == buf */
+        if ((*gs = tpl_hook.malloc(sizeof(tpl_gather_t))) == NULL) {
             fatal_oom();
         }
-        if ( ((*gs)->img = tpl_hook.malloc(img+catlen - tpl)) == NULL ) {
+        if (((*gs)->img = tpl_hook.malloc(img+catlen - tpl)) == NULL) {
             fatal_oom();
         }
         (*gs)->len = img+catlen - tpl;
-        memcpy( (*gs)->img, tpl, img+catlen - tpl);
+        memcpy((*gs)->img, tpl, img+catlen - tpl);
         /* free partially consumed concat buffer if used */
         if (img != buf) tpl_hook.free(img);
     } else {                        /* tpl(s) fully consumed */
index b7aa06e..0b5838b 100755 (executable)
@@ -61,8 +61,7 @@
 #include "account.h"
 #include "account-types.h"
 
-char *g_default_mbox_alias[MAILBOX_COUNT] =
-{
+char *g_default_mbox_alias[MAILBOX_COUNT] = {
        EMAIL_INBOX_DISPLAY_NAME,
        EMAIL_DRAFTBOX_DISPLAY_NAME,
        EMAIL_OUTBOX_DISPLAY_NAME,
@@ -71,8 +70,7 @@ char *g_default_mbox_alias[MAILBOX_COUNT] =
        EMAIL_SPAMBOX_DISPLAY_NAME,
 };
 
-char *g_default_mbox_name[MAILBOX_COUNT]  =
-{
+char *g_default_mbox_name[MAILBOX_COUNT] = {
        EMAIL_INBOX_NAME,
        EMAIL_DRAFTBOX_NAME,
        EMAIL_OUTBOX_NAME,
@@ -81,8 +79,7 @@ char *g_default_mbox_name[MAILBOX_COUNT]  =
        EMAIL_SPAMBOX_NAME,
 };
 
-email_mailbox_type_e g_default_mbox_type[MAILBOX_COUNT] =
-{
+email_mailbox_type_e g_default_mbox_type[MAILBOX_COUNT] = {
        EMAIL_MAILBOX_TYPE_INBOX,
        EMAIL_MAILBOX_TYPE_DRAFT,
        EMAIL_MAILBOX_TYPE_OUTBOX,
@@ -98,7 +95,7 @@ INTERNAL_FUNC email_account_t* emcore_get_account_reference(char *multi_user_nam
         email_account_t *result_account = NULL;
         emstorage_account_tbl_t *p_result_account = NULL;
 
-        if (account_id < 0){
+        if (account_id < 0) {
                   emcore_get_account_from_unvalidated_account_list(account_id, &result_account);
                   return result_account;
         } else if (account_id > 0) {
@@ -116,7 +113,7 @@ INTERNAL_FUNC email_account_t* emcore_get_account_reference(char *multi_user_nam
 
                        result_account = (email_account_t *)em_malloc(sizeof(email_account_t));
                        if (result_account == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                return NULL;
                        }
 
@@ -146,7 +143,7 @@ INTERNAL_FUNC int emcore_get_account_reference_list(char *multi_user_name, email
     if (account_count > 0) {
         account_list = em_malloc(sizeof(email_account_t) * (account_count));
         if (account_list == NULL) {
-            EM_DEBUG_EXCEPTION("em_malloc failed");
+            EM_DEBUG_EXCEPTION("em_mallocfailed");
             err = EMAIL_ERROR_OUT_OF_MEMORY;
             goto FINISH_OFF;
         }
@@ -209,7 +206,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_nam
        SENDSTREAM *stream = NULL;
        MAILSTREAM *tmp_stream = NULL;
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        if (!emnetwork_check_network_status(&err)) {
                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
@@ -217,7 +214,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_nam
        }
        EM_DEBUG_LOG("Network available");
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        if (!emcore_get_empty_session(&session)) {
                EM_DEBUG_EXCEPTION("emcore_get_empty_session failed...");
@@ -228,7 +225,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_nam
        /* validate connection for pop3/imap */
        EM_DEBUG_LOG("Validate connection for POP3/IMAP4");
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        if (!emcore_connect_to_remote_mailbox_with_account_info(multi_user_name,
                                                                                                                        account,
@@ -252,7 +249,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_nam
        /* validate connection for SMTP */
        EM_DEBUG_LOG("Validate connection for SMTP server");
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        if (!emcore_connect_to_remote_mailbox_with_account_info(multi_user_name,
                                                                                                                        account,
@@ -266,7 +263,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_nam
 
 #if 0
                if (account->outgoing_server_secure_connection == 0x01) /*  0x01 == SSL */ {
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                        EM_DEBUG_LOG("Retry with TLS");
                        account->outgoing_server_secure_connection = 0x02;      /*  0x02 == TLS */
@@ -283,9 +280,8 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_nam
                                goto FINISH_OFF;
                        }
 
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
-               }
-               else {
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
+               } else {
                        err = EMAIL_ERROR_VALIDATE_ACCOUNT_OF_SMTP;
                        goto FINISH_OFF;
                }
@@ -302,7 +298,7 @@ INTERNAL_FUNC int emcore_validate_account_with_account_info(char *multi_user_nam
 
        int dummy = 0;
        if (!emcore_check_event_thread_status(&dummy, event_handle)) {
-               EM_DEBUG_LOG ("canceled event: [%d]", dummy);
+               EM_DEBUG_LOG("canceled event: [%d]", dummy);
                if (event_type == EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT || event_type == EMAIL_EVENT_VALIDATE_ACCOUNT_EX) {
                        if (!emcore_delete_account(multi_user_name, account->account_id, false, NULL))
                                EM_DEBUG_EXCEPTION("emdaemon_delete_account failed [%d]", account->account_id);
@@ -335,7 +331,7 @@ FINISH_OFF:
                smtp_close(stream);
 
        if (tmp_stream)
-               tmp_stream = mail_close (tmp_stream);
+               tmp_stream = mail_close(tmp_stream);
 
        if (err_code != NULL)
                *err_code = err;
@@ -396,21 +392,19 @@ INTERNAL_FUNC int emcore_delete_account(char *multi_user_name, int account_id, i
        int shmid = 0;
        int *del_account_id = NULL;
 
-       EM_DEBUG_LOG ("begin account_id [%d]", account_id);
+       EM_DEBUG_LOG("begin account_id [%d]", account_id);
        /* worker thread is single instance, so multiple accounts cant be deleted concurrently */
-       if ((shmid = shmget (del_account_key, sizeof (int), IPC_CREAT | 0666)) != -1) {
+       if ((shmid = shmget(del_account_key, sizeof(int), IPC_CREAT | 0666)) != -1) {
                /* attaching the segment to the current process space */
-               if ((del_account_id = (int*) shmat (shmid, NULL, 0)) != (int*) -1) {
+               if ((del_account_id = (int*) shmat(shmid, NULL, 0)) != (int*) -1) {
                        /* write it */
                        *del_account_id = account_id;
-                       EM_DEBUG_LOG ("recorded account_id [%d]", *del_account_id);
-               }
-               else
-                       EM_DEBUG_EXCEPTION ("shmget error[%d]", errno);
+                       EM_DEBUG_LOG("recorded account_id [%d]", *del_account_id);
+               } else
+                       EM_DEBUG_EXCEPTION("shmget error[%d]", errno);
 
-       }
-       else
-               EM_DEBUG_EXCEPTION ("shmget error[%d]", errno);
+       } else
+               EM_DEBUG_EXCEPTION("shmget error[%d]", errno);
 
        /*  default variabl */
        int ret = false;
@@ -503,7 +497,7 @@ INTERNAL_FUNC int emcore_delete_account(char *multi_user_name, int account_id, i
        }
 
        if (!emstorage_delete_account(multi_user_name, account_id, false, &err)) {
-               if(err != EMAIL_ERROR_SYSTEM_FAILURE) {
+               if (err != EMAIL_ERROR_SYSTEM_FAILURE) {
                        EM_DEBUG_EXCEPTION("emstorage_delete_account failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -521,7 +515,7 @@ INTERNAL_FUNC int emcore_delete_account(char *multi_user_name, int account_id, i
 
        /*  delete all mailboxes */
        if (!emstorage_delete_mailbox(multi_user_name, account_id, -1, 0, false, &err)) {
-               if(err != EMAIL_ERROR_MAILBOX_NOT_FOUND) {
+               if (err != EMAIL_ERROR_MAILBOX_NOT_FOUND) {
                        EM_DEBUG_EXCEPTION("emstorage_delete_mailbox failed - %d", err);
                        goto FINISH_OFF;
                }
@@ -544,15 +538,14 @@ FINISH_OFF:
                        err = EMAIL_ERROR_DB_FAILURE;
                        ret = false;
                }
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_DELETE, account_id, 0, NULL, 0))
-                       EM_DEBUG_EXCEPTION (" emcore_notify_storage_event[ NOTI_ACCOUNT_DELETE] : Notification Failed >>> ");
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_DELETE, account_id, 0, NULL, 0))
+                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event[ NOTI_ACCOUNT_DELETE] : Notification Failed >>> ");
 
-       }
-       else {  /*  ROLLBACK TRANSACTION; */
+       } else {        /*  ROLLBACK TRANSACTION; */
                if (!before_tr_begin && emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
                        err = EMAIL_ERROR_DB_FAILURE;
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_DELETE_FAIL, account_id, err, NULL, 0))
-                       EM_DEBUG_EXCEPTION (" emcore_notify_storage_event[ NOTI_ACCOUNT_DELETE] : Notification Failed >>> ");
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_DELETE_FAIL, account_id, err, NULL, 0))
+                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event[ NOTI_ACCOUNT_DELETE] : Notification Failed >>> ");
        }
 
        if (err_code)
@@ -560,7 +553,7 @@ FINISH_OFF:
 
        /* del the segment */
        if (shmid != -1) {
-               shmctl (shmid, IPC_RMID, NULL);
+               shmctl(shmid, IPC_RMID, NULL);
        }
 
        EM_DEBUG_FUNC_END();
@@ -610,7 +603,7 @@ INTERNAL_FUNC int emcore_create_account(char *multi_user_name, email_account_t *
        /* check for email address validation */
        EM_DEBUG_LOG_SEC("account->user_email_address[%s]", account->user_email_address);
        if (account->user_email_address) {
-               if ((err = em_verify_email_address (account->user_email_address)) != EMAIL_ERROR_NONE) {
+               if ((err = em_verify_email_address(account->user_email_address)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("em_verify_email_address error [%d]", err);
                        goto FINISH_OFF;
                }
@@ -636,7 +629,7 @@ INTERNAL_FUNC int emcore_create_account(char *multi_user_name, email_account_t *
                        }
 
                        error_code = account_create(&account_handle);
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("account_create failed [%d]", error_code);
                                err = error_code;
                                if (join_zone) emcore_unset_join_zone(join_zone);
@@ -644,44 +637,44 @@ INTERNAL_FUNC int emcore_create_account(char *multi_user_name, email_account_t *
                        }
 
                        error_code = account_set_user_name(account_handle, account->incoming_server_user_name);
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_LOG("account_set_user_name failed [%d]", error_code);
                        }
 
                        error_code = account_set_domain_name(account_handle, account->account_name);
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_LOG("account_set_domain_name failed [%d]", error_code);
                        }
 
                        error_code = account_set_email_address(account_handle,  account->user_email_address);
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_LOG("account_set_email_address failed [%d]", error_code);
                        }
 
                        error_code = account_set_source(account_handle, "SLP EMAIL");
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_LOG("account_set_source failed [%d]", error_code);
                        }
 
                        error_code = account_set_package_name(account_handle, "email-setting-efl");
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_LOG("account_set_package_name failed [%d]", error_code);
                        }
 
                        /* account_set_capability(account_handle , ACCOUNT_CAPABILITY_EMAIL, ACCOUNT_CAPABILITY_ENABLED); OLD API */
                        error_code = account_set_capability(account_handle , ACCOUNT_SUPPORTS_CAPABILITY_EMAIL , ACCOUNT_CAPABILITY_ENABLED);
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_LOG("account_set_capability failed [%d]", error_code);
                        }
 
                        error_code = account_set_sync_support(account_handle, ACCOUNT_SYNC_STATUS_IDLE); /* This means "The account is supporting 'sync' and initialized as idle status" */
-                       if(error_code != ACCOUNT_ERROR_NONE) {
+                       if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_LOG("account_set_sync_support failed [%d]", error_code);
                        }
 
                        if (account->logo_icon_path) {
                                error_code = account_set_icon_path(account_handle, account->logo_icon_path);
-                               if(error_code != ACCOUNT_ERROR_NONE) {
+                               if (error_code != ACCOUNT_ERROR_NONE) {
                                        EM_DEBUG_LOG("account_set_icon_path failed [%d]", error_code);
                                }
                        }
@@ -689,8 +682,7 @@ INTERNAL_FUNC int emcore_create_account(char *multi_user_name, email_account_t *
                        error_code = account_insert_to_db(account_handle, &account_svc_id);
                        if (error_code != ACCOUNT_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("account_insert_to_db failed [%d]", error_code);
-                       }
-                       else {
+                       } else {
                                account->account_svc_id = account_svc_id;
                                EM_DEBUG_LOG("account_insert_to_db succeed");
                        }
@@ -810,7 +802,7 @@ INTERNAL_FUNC void emcore_free_option(email_option_t *option)
 
 INTERNAL_FUNC void emcore_free_account(email_account_t *account)
 {
-       if(!account) return;
+       if (!account) return;
 
        EM_SAFE_FREE(account->account_name);
        EM_SAFE_FREE(account->logo_icon_path);
@@ -861,16 +853,16 @@ INTERNAL_FUNC void emcore_duplicate_account(const email_account_t *account, emai
 {
        EM_DEBUG_FUNC_BEGIN("account[%p]", account);
 
-       if(!account || !account_dup) { /*prevent 40514*/
+       if (!account || !account_dup) { /*prevent 40514*/
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
-               if(err_code) *err_code = EMAIL_ERROR_INVALID_PARAM;
+               if (err_code) *err_code = EMAIL_ERROR_INVALID_PARAM;
                return;
        }
 
        *account_dup = em_malloc(sizeof(email_account_t));
-       if(!*account_dup) { /*prevent 40514*/
+       if (!*account_dup) { /*prevent 40514*/
                EM_DEBUG_EXCEPTION("malloc failed...");
-               if(err_code) *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
+               if (err_code) *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
                return;
        }
 
@@ -906,8 +898,7 @@ static int append_data_into_buffer(char **target_buffer, int *target_buffer_lent
                memcpy(*target_buffer + (*target_buffer_lenth), input_data, input_data_length);
                *target_buffer_lenth += input_data_length;
                EM_DEBUG_LOG("*target_buffer_lenth [%d] input_data_length [%d]", *target_buffer_lenth, input_data_length);
-       }
-       else {
+       } else {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                local_error_code = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -950,8 +941,7 @@ static int emcore_write_account_into_buffer(char **target_buffer, int *target_bu
                        }
                        EM_DEBUG_LOG("append_data_into_buffer succeed for byte_stream");
                }
-       }
-       else {
+       } else {
                EM_DEBUG_EXCEPTION("em_convert_account_tbl_to_account failed");
                local_error_code = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
@@ -1007,8 +997,7 @@ INTERNAL_FUNC int emcore_backup_accounts(char *multi_user_name, const char *file
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_ACCOUNT_NOT_FOUND");
                local_error_code = EMAIL_ERROR_ACCOUNT_NOT_FOUND;
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                target_buffer = em_malloc(sizeof(int));
                if (!target_buffer)  {
                        EM_DEBUG_EXCEPTION("malloc failed");
@@ -1042,7 +1031,7 @@ INTERNAL_FUNC int emcore_backup_accounts(char *multi_user_name, const char *file
        ret_code = true;
 FINISH_OFF:
 
-       EM_SAFE_CLOSE (fd);
+       EM_SAFE_CLOSE(fd);
        EM_SAFE_FREE(target_buffer);
 
        if (account_list)
@@ -1068,8 +1057,8 @@ INTERNAL_FUNC int emcore_restore_accounts(char *multi_user_name, const char *fil
 
        ssm_file_info_t sfi;
 
-       if (!emcore_notify_storage_event (NOTI_ACCOUNT_RESTORE_START, 0, 0, NULL, 0))
-               EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_ACCOUNT_RESTORE_START] failed");
+       if (!emcore_notify_storage_event(NOTI_ACCOUNT_RESTORE_START, 0, 0, NULL, 0))
+               EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_RESTORE_START] failed");
 
        if (!file_path) {
                err = EMAIL_ERROR_INVALID_PARAM;
@@ -1087,7 +1076,7 @@ INTERNAL_FUNC int emcore_restore_accounts(char *multi_user_name, const char *fil
                        }
                }
 
-               if(account_list) {
+               if (account_list) {
                        emcore_free_account_list(&account_list, account_count, NULL);
                        account_list = NULL;
                }
@@ -1102,7 +1091,7 @@ INTERNAL_FUNC int emcore_restore_accounts(char *multi_user_name, const char *fil
        buffer_length = sfi.originSize;
        EM_DEBUG_LOG("account buffer_length[%d]", buffer_length);
        if ((encrypt_buffer = (char *)em_malloc(buffer_length + 1)) == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1169,19 +1158,18 @@ INTERNAL_FUNC int emcore_restore_accounts(char *multi_user_name, const char *fil
 
 FINISH_OFF:
 #ifdef FEATURE_SSS_ENABLE
-       EM_SAFE_CLOSE (fd);
+       EM_SAFE_CLOSE(fd);
 #endif
 
        if (err == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_RESTORE_FINISH, 0, 0, NULL, err))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_ACCOUNT_RESTORE_FINISH] failed");
-       }
-       else {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_RESTORE_FAIL, 0, 0, NULL, err))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_ACCOUNT_RESTORE_FAIL] failed");
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_RESTORE_FINISH, 0, 0, NULL, err))
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_RESTORE_FINISH] failed");
+       } else {
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_RESTORE_FAIL, 0, 0, NULL, err))
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_RESTORE_FAIL] failed");
        }
 
-       if(account_list) {
+       if (account_list) {
                emcore_free_account_list(&account_list, account_count, NULL);
                account_list = NULL;
        }
@@ -1223,11 +1211,11 @@ static int _recover_from_invalid_default_account_id(char *multi_user_name, int *
                goto FINISH_OFF;
        }
 
-       if(!emstorage_get_account_list(multi_user_name, &account_count, &result_account_list, false, false, &ret_code) || !result_account_list) {
+       if (!emstorage_get_account_list(multi_user_name, &account_count, &result_account_list, false, false, &ret_code) || !result_account_list) {
                if (ret_code == EMAIL_ERROR_ACCOUNT_NOT_FOUND)
-                       EM_DEBUG_LOG ("no account found");
+                       EM_DEBUG_LOG("no account found");
                else
-                       EM_DEBUG_EXCEPTION ("emstorage_get_account_list() failed [%d]", ret_code);
+                       EM_DEBUG_EXCEPTION("emstorage_get_account_list() failed [%d]", ret_code);
                *output_account_id = 0;
                goto FINISH_OFF;
        }
@@ -1236,7 +1224,7 @@ static int _recover_from_invalid_default_account_id(char *multi_user_name, int *
                *output_account_id = result_account_list[0].account_id;
        }
 
-       EM_DEBUG_LOG_DEV ("output_account_id [%d]", *output_account_id);
+       EM_DEBUG_LOG_DEV("output_account_id [%d]", *output_account_id);
 
 FINISH_OFF:
 
@@ -1270,20 +1258,19 @@ INTERNAL_FUNC int emcore_load_default_account_id(char *multi_user_name, int *out
        if (*output_account_id != 0) {
                if (!emstorage_get_account_by_id(multi_user_name, *output_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &result_account, false, &ret_code)) {
                        if (ret_code == EMAIL_ERROR_ACCOUNT_NOT_FOUND) {
-                               EM_DEBUG_LOG ("no account found account_id[%d]", *output_account_id);
+                               EM_DEBUG_LOG("no account found account_id[%d]", *output_account_id);
                                *output_account_id = 0;
-                       }
-                       else {
-                               EM_DEBUG_EXCEPTION ("emstorage_get_account_by_id() failed account_id[%d] err[%d]", *output_account_id, ret_code);
+                       } else {
+                               EM_DEBUG_EXCEPTION("emstorage_get_account_by_id() failed account_id[%d] err[%d]", *output_account_id, ret_code);
                                goto FINISH_OFF;
                        }
                }
        }
 
        if (*output_account_id == 0) {
-               if ((ret_code = _recover_from_invalid_default_account_id (multi_user_name, output_account_id)) != EMAIL_ERROR_NONE) {
+               if ((ret_code = _recover_from_invalid_default_account_id(multi_user_name, output_account_id)) != EMAIL_ERROR_NONE) {
                        if (ret_code == EMAIL_ERROR_ACCOUNT_NOT_FOUND)
-                               EM_DEBUG_LOG ("no account found");
+                               EM_DEBUG_LOG("no account found");
                        else
                                EM_DEBUG_EXCEPTION("_recover_from_invalid_default_account() failed [%d]", ret_code);
                        *output_account_id = 0;
@@ -1313,9 +1300,9 @@ INTERNAL_FUNC int emcore_recover_from_secured_storage_failure(char *multi_user_n
        }
 
        for (i = 0; i < account_count; i++) {
-               if(!emstorage_get_account_by_id(multi_user_name, temp_account_tbl_list[i].account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_PASSWORD, &temp_account_tbl, true, &err)) {
-                       if(err == EMAIL_ERROR_SECURED_STORAGE_FAILURE) {
-                               if(!emcore_delete_account(multi_user_name, temp_account_tbl_list[i].account_id, true, &err)) {
+               if (!emstorage_get_account_by_id(multi_user_name, temp_account_tbl_list[i].account_id, EMAIL_ACC_GET_OPT_DEFAULT | EMAIL_ACC_GET_OPT_PASSWORD, &temp_account_tbl, true, &err)) {
+                       if (err == EMAIL_ERROR_SECURED_STORAGE_FAILURE) {
+                               if (!emcore_delete_account(multi_user_name, temp_account_tbl_list[i].account_id, true, &err)) {
                                        EM_DEBUG_EXCEPTION("emcore_delete_account failed [%d]", err);
                                        goto FINISH_OFF;
                                }
@@ -1358,7 +1345,7 @@ INTERNAL_FUNC int emcore_update_sync_status_of_account(char *multi_user_name, in
 
                if (input_set_operator == SET_TYPE_SET)
                        err_from_account_svc = account_update_sync_status_by_id(account_tbl_data->account_svc_id, ACCOUNT_SYNC_STATUS_RUNNING);
-               else if(input_set_operator == SET_TYPE_MINUS)
+               else if (input_set_operator == SET_TYPE_MINUS)
                        err_from_account_svc = account_update_sync_status_by_id(account_tbl_data->account_svc_id, ACCOUNT_SYNC_STATUS_IDLE);
 
                EM_DEBUG_LOG("account_update_sync_status_by_id returns [%d] by id[%d]", err_from_account_svc, account_tbl_data->account_svc_id);
@@ -1401,8 +1388,7 @@ size_t emcore_curl_write_callback(char* data, size_t size, size_t nmemb, void* t
        if (*result_string == NULL) {
                EM_DEBUG_LOG("received_length[%d]", received_length);
                *result_string = em_malloc(received_length + 1);
-       }
-       else {
+       } else {
                int new_buffer_length = 0;
                last_pos = EM_SAFE_STRLEN(*result_string);
                new_buffer_length = last_pos + received_length + 1;
@@ -1438,7 +1424,7 @@ static int emcore_get_xoauth2_access_token(char *input_refresh_token, char **out
        long response_code;
        double speed_upload, total_time, download_size;
 
-       if(input_refresh_token == NULL || output_access_token == NULL) {
+       if (input_refresh_token == NULL || output_access_token == NULL) {
                EM_DEBUG_EXCEPTION("curl_easy_init() failed");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -1495,8 +1481,8 @@ static int emcore_get_xoauth2_access_token(char *input_refresh_token, char **out
                goto FINISH_OFF;
        }
 
-       if(strstr(result_string, "error")) {
-               if(strstr(result_string, "\"invalid_grant\""))
+       if (strstr(result_string, "error")) {
+               if (strstr(result_string, "\"invalid_grant\""))
                        err = EMAIL_ERROR_XOAUTH_INVALID_GRANT;
                else
                        err = EMAIL_ERROR_XOAUTH_BAD_REQUEST;
@@ -1505,7 +1491,7 @@ static int emcore_get_xoauth2_access_token(char *input_refresh_token, char **out
 
        pos = strstr(result_string, "\"access_token\" : \"");
 
-       if(!pos) {
+       if (!pos) {
                err = EMAIL_ERROR_XOAUTH_BAD_REQUEST;
                goto FINISH_OFF;
        }
@@ -1514,10 +1500,10 @@ static int emcore_get_xoauth2_access_token(char *input_refresh_token, char **out
 
        access_token = strtok_r(pos, "\"", &savepos);
 
-       if(access_token) {
+       if (access_token) {
                *output_access_token = EM_SAFE_STRDUP(access_token);
 
-               if(*output_access_token == NULL) {
+               if (*output_access_token == NULL) {
                        EM_DEBUG_EXCEPTION("strdup failed");
                        err = EMAIL_ERROR_SYSTEM_FAILURE;
                        goto FINISH_OFF;
@@ -1551,14 +1537,14 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(char *multi_user_name, int
 
 
        ref_account = emcore_get_account_reference(multi_user_name, input_account_id, true);
-       if(ref_account == NULL) {
+       if (ref_account == NULL) {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference() failed");
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
        }
 
        access_token = EM_SAFE_STRDUP(strtok_r(ref_account->incoming_server_password, "\001", &saveptr));
-       if(access_token == NULL) {
+       if (access_token == NULL) {
                EM_DEBUG_EXCEPTION("invalid token string.");
                err = EMAIL_ERROR_XOAUTH_BAD_REQUEST;
                goto FINISH_OFF;
@@ -1568,7 +1554,7 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(char *multi_user_name, int
 
        refresh_token = EM_SAFE_STRDUP(strtok_r(NULL, "\001", &saveptr));
 
-       if(refresh_token == NULL) {
+       if (refresh_token == NULL) {
                EM_DEBUG_EXCEPTION("invalid token string.");
                err = EMAIL_ERROR_XOAUTH_BAD_REQUEST;
                goto FINISH_OFF;
@@ -1576,7 +1562,7 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(char *multi_user_name, int
 
        EM_DEBUG_LOG_SEC("refresh_token [%s]", refresh_token);
 
-       if((err = emcore_get_xoauth2_access_token(refresh_token, &new_access_token)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_xoauth2_access_token(refresh_token, &new_access_token)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_xoauth2_access_token() failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1584,7 +1570,7 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(char *multi_user_name, int
        new_password_string_length = EM_SAFE_STRLEN(new_access_token) + EM_SAFE_STRLEN(refresh_token) + 2;
 
        new_password_string = em_malloc(new_password_string_length);
-       if(new_password_string == NULL) {
+       if (new_password_string == NULL) {
                EM_DEBUG_EXCEPTION("em_malloc() failed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -1592,7 +1578,7 @@ INTERNAL_FUNC int emcore_refresh_xoauth2_access_token(char *multi_user_name, int
 
        SNPRINTF(new_password_string, new_password_string_length, "%s\001%s", new_access_token, refresh_token);
 
-       if((err = emstorage_update_account_password(multi_user_name, input_account_id, new_password_string, new_password_string)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_update_account_password(multi_user_name, input_account_id, new_password_string, new_password_string)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_update_account_password() failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1604,7 +1590,7 @@ FINISH_OFF:
        EM_SAFE_FREE(new_access_token);
        EM_SAFE_FREE(new_password_string);
 
-       if(ref_account) {
+       if (ref_account) {
                emcore_free_account(ref_account);
                EM_SAFE_FREE(ref_account);
        }
index fffd7d6..c18be90 100755 (executable)
@@ -69,16 +69,16 @@ INTERNAL_FUNC int emcore_get_alarm_data_by_alarm_id(alarm_id_t input_alarm_id, e
 
        ENTER_CRITICAL_SECTION(alarm_data_lock);
        index = g_list_first(alarm_data_list);
-       while(index) {
+       while (index) {
                alarm_data = index->data;
-               if(alarm_data->alarm_id == input_alarm_id) {
+               if (alarm_data->alarm_id == input_alarm_id) {
                        break;
                }
                index = g_list_next(index);
        }
        LEAVE_CRITICAL_SECTION(alarm_data_lock);
 
-       if(alarm_data)
+       if (alarm_data)
                *output_alarm_data = alarm_data;
        else
                err = EMAIL_ERROR_ALARM_DATA_NOT_FOUND;
@@ -106,9 +106,9 @@ INTERNAL_FUNC int emcore_get_alarm_data_by_reference_id(email_alarm_class_t inpu
 
        index = g_list_first(alarm_data_list);
 
-       while(index) {
+       while (index) {
                alarm_data = index->data;
-               if(alarm_data->class_id == input_class_id && alarm_data->reference_id == input_reference_id) {
+               if (alarm_data->class_id == input_class_id && alarm_data->reference_id == input_reference_id) {
                        EM_DEBUG_LOG("found");
                        break;
                }
@@ -117,7 +117,7 @@ INTERNAL_FUNC int emcore_get_alarm_data_by_reference_id(email_alarm_class_t inpu
 
        LEAVE_CRITICAL_SECTION(alarm_data_lock);
 
-       if(index)
+       if (index)
                *output_alarm_data = alarm_data;
        else
                err = EMAIL_ERROR_ALARM_DATA_NOT_FOUND;
@@ -137,9 +137,9 @@ INTERNAL_FUNC int emcore_check_alarm_by_class_id(email_alarm_class_t input_class
 
        ENTER_CRITICAL_SECTION(alarm_data_lock);
        index = g_list_first(alarm_data_list);
-       while(index) {
+       while (index) {
                alarm_data = index->data;
-               if(alarm_data->class_id == input_class_id) {
+               if (alarm_data->class_id == input_class_id) {
                        EM_DEBUG_LOG("found");
                        break;
                }
@@ -147,7 +147,7 @@ INTERNAL_FUNC int emcore_check_alarm_by_class_id(email_alarm_class_t input_class
        }
        LEAVE_CRITICAL_SECTION(alarm_data_lock);
 
-       if(!index)
+       if (!index)
                err = EMAIL_ERROR_ALARM_DATA_NOT_FOUND;
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -174,7 +174,7 @@ static int emcore_add_alarm_data_to_alarm_data_list(char *multi_user_name,
 
        alarm_data = em_malloc(sizeof(email_alarm_data_t));
 
-       if(alarm_data == NULL) {
+       if (alarm_data == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -208,7 +208,7 @@ static int emcore_remove_alarm(email_alarm_data_t *input_alarm_data)
        ENTER_CRITICAL_SECTION(alarm_data_lock);
        EM_DEBUG_LOG("alarm_id [%d]", input_alarm_data->alarm_id);
        if ((ret = alarmmgr_remove_alarm(input_alarm_data->alarm_id)) != ALARMMGR_RESULT_SUCCESS) {
-               EM_DEBUG_EXCEPTION ("alarmmgr_remove_alarm failed [%d]", ret);
+               EM_DEBUG_EXCEPTION("alarmmgr_remove_alarm failed [%d]", ret);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
        }
        EM_SAFE_FREE(input_alarm_data->multi_user_name);
@@ -223,21 +223,21 @@ INTERNAL_FUNC int emcore_delete_alram_data_from_alarm_data_list(email_alarm_data
        EM_DEBUG_FUNC_BEGIN("input_alarm_data [%p]", input_alarm_data);
        int err = EMAIL_ERROR_NONE;
 
-       if (input_alarm_data == NULL ) {
-               EM_DEBUG_EXCEPTION ("EMAIL_ERROR_INVALID_PARAM");
+       if (input_alarm_data == NULL) {
+               EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
        if ((err = emcore_remove_alarm(input_alarm_data)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_EXCEPTION ("emcore_remove_alarm failed [%d]", err);
+               EM_DEBUG_EXCEPTION("emcore_remove_alarm failed [%d]", err);
        }
 
        ENTER_CRITICAL_SECTION(alarm_data_lock);
        alarm_data_list = g_list_remove_all(alarm_data_list, input_alarm_data);
 
        if (g_list_length(alarm_data_list) == 0) {
-               g_list_free (alarm_data_list);
+               g_list_free(alarm_data_list);
                alarm_data_list = NULL;
        }
        LEAVE_CRITICAL_SECTION(alarm_data_lock);
@@ -255,12 +255,12 @@ INTERNAL_FUNC int emcore_delete_alram_data_by_reference_id(email_alarm_class_t i
        email_alarm_data_t *alarm_data = NULL;
 
        if ((err = emcore_get_alarm_data_by_reference_id(input_class_id, input_reference_id, &alarm_data)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_LOG ("emcore_get_alarm_data_by_reference_id return [%d]", err);
+               EM_DEBUG_LOG("emcore_get_alarm_data_by_reference_id return [%d]", err);
                goto FINISH_OFF;
        }
 
        if ((err = emcore_delete_alram_data_from_alarm_data_list(alarm_data)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_LOG ("emcore_delete_alram_data_from_alarm_data_list return [%d]", err);
+               EM_DEBUG_LOG("emcore_delete_alram_data_from_alarm_data_list return [%d]", err);
        }
 
 FINISH_OFF:
@@ -297,7 +297,7 @@ INTERNAL_FUNC int emcore_add_alarm(char *multi_user_name,
                                                                        ALARM_REPEAT_MODE_ONCE,
                                                                        EMAIL_ALARM_DESTINATION,
                                                                        &alarm_id)) != ALARMMGR_RESULT_SUCCESS) {
-               EM_DEBUG_EXCEPTION("alarmmgr_add_alarm failed [%d]",ret);
+               EM_DEBUG_EXCEPTION("alarmmgr_add_alarm failed [%d]", ret);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
        }
index 397f3b4..156ec89 100755 (executable)
@@ -222,7 +222,7 @@ INTERNAL_FUNC int emcore_retrieve_auto_download_event(email_event_auto_download
                head_event = (email_event_auto_download *)g_queue_peek_head(g_auto_download_que);
                if (!head_event) {
                        error = EMAIL_ERROR_EVENT_QUEUE_EMPTY;
-                       EM_DEBUG_LOG_DEV ("QUEUE is empty");
+                       EM_DEBUG_LOG_DEV("QUEUE is empty");
                        break;
                }
 
@@ -315,7 +315,7 @@ INTERNAL_FUNC int emcore_clear_auto_download_queue(void)
 
        ENTER_RECURSIVE_CRITICAL_SECTION(_auto_download_queue_lock);
 
-       q_length = g_auto_download_que? g_queue_get_length (g_auto_download_que): 0;
+       q_length = g_auto_download_que ? g_queue_get_length(g_auto_download_que) : 0;
 
        for (i = 0; i < q_length; i++) {
                pop_elm = (email_event_auto_download *)g_queue_peek_nth(g_auto_download_que, i);
@@ -498,8 +498,7 @@ CHECK_CONTINUE:
                        SLEEP_CONDITION_VARIABLE(_auto_downalod_available_signal, *_auto_download_queue_lock);
                        EM_DEBUG_LOG("Wake up by _auto_downalod_available_signal");
                        LEAVE_RECURSIVE_CRITICAL_SECTION(_auto_download_queue_lock);
-               }
-               else {
+               } else {
                        LEAVE_RECURSIVE_CRITICAL_SECTION(_auto_download_queue_lock);
                        EM_DEBUG_LOG_DEV(">>>>>>>>>>>>>>> Got auto download event_data !!! <<<<<<<<<<<<<<<");
                        int state1 = 0, state2 = 0, state3 = 0, wifi_status = 0;
@@ -582,12 +581,10 @@ CHECK_CONTINUE:
                                                                                                                true,
                                                                                                                &err) || !mail) {
                                EM_DEBUG_EXCEPTION("emstorage_get_mail_data_by_servermailid failed : [%d]", err);
-                       }
-                       else {
+                       } else {
                                if (mail->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) {
                                        EM_DEBUG_LOG("fully downloaded mail");
-                               }
-                               else {
+                               } else {
                                        EM_DEBUG_LOG("#####AUTO DOWNLOAD BODY: ACCOUNT_ID[%d] MAILBOX_ID[%d] MAIL_ID[%d] UID[%d] ACTIVITY[%d]#####",
                                                        event_data->account_id, event_data->mailbox_id,
                                                        event_data->mail_id, event_data->server_mail_id, event_data->activity_id);
@@ -615,7 +612,7 @@ CHECK_CONTINUE:
                                                                                                                                event_data->mail_id,
                                                                                                                                true,
                                                                                                                                &attachment_list,
-                                                                                                                               &attachment_count)) != EMAIL_ERROR_NONE ) {
+                                                                                                                               &attachment_count)) != EMAIL_ERROR_NONE) {
                                                EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                                        } else {
                                                for (i = 0; i < attachment_count; i++) {
@@ -678,8 +675,7 @@ POP_HEAD:
                        LEAVE_RECURSIVE_CRITICAL_SECTION(_auto_download_queue_lock);
                        if (!started_event) {
                                EM_DEBUG_EXCEPTION("Failed to g_queue_pop_head");
-                       }
-                       else {
+                       } else {
                                EM_SAFE_FREE(started_event->multi_user_name);
                                EM_SAFE_FREE(started_event);
                        }
@@ -725,7 +721,7 @@ INTERNAL_FUNC int emcore_insert_auto_download_job(char *multi_user_name,
        ad_event = (email_event_auto_download *)em_malloc(sizeof(email_event_auto_download));
 
        if (!ad_event) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -740,8 +736,7 @@ INTERNAL_FUNC int emcore_insert_auto_download_job(char *multi_user_name,
        if (!emcore_insert_auto_download_activity(ad_event, &(ad_event->activity_id), &err)) {
                EM_DEBUG_EXCEPTION("Inserting auto download activity failed with error[%d]", err);
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                ret = true;
 
                if (!auto_download_on) {
@@ -750,8 +745,7 @@ INTERNAL_FUNC int emcore_insert_auto_download_job(char *multi_user_name,
 
                if (emcore_is_auto_download_queue_full()) {
                        EM_DEBUG_LOG("Activity inserted only in DB .. Queue is Full");
-               }
-               else {
+               } else {
                        ad_event->status = EMAIL_EVENT_STATUS_DIRECT;
 
                        if (!emcore_insert_auto_download_event(ad_event, &err)) {
@@ -845,8 +839,7 @@ INTERNAL_FUNC int emcore_delete_auto_download_activity(char *multi_user_name, in
        if (!emstorage_delete_auto_download_activity(multi_user_name, account_id, mail_id, activity_id, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_delete_auto_download_activity failed [%d]", err);
                goto FINISH_OFF;
-       }
-       else if (err == EMAIL_ERROR_DATA_NOT_FOUND)
+       } else if (err == EMAIL_ERROR_DATA_NOT_FOUND)
                err = EMAIL_ERROR_NONE;
 
        ret = true;
index 879f5de..3e64298 100755 (executable)
@@ -57,7 +57,7 @@ INTERNAL_FUNC int emcore_init_cynara()
        ENTER_CRITICAL_SECTION(cynara_mutex);
        cynara_info = (cynara_info_t *)em_malloc(sizeof(cynara_info));
        if (cynara_info == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
index c35bc88..b964385 100755 (executable)
@@ -113,8 +113,7 @@ INTERNAL_FUNC email_event_t *sync_failed_event_data = NULL;
 /*-----------------------------------------------------------------------------
  * Unused
  *---------------------------------------------------------------------------*/
-typedef struct EVENT_CALLBACK_ELEM
-{
+typedef struct EVENT_CALLBACK_ELEM {
        email_event_callback callback;
        void *event_data;
        struct EVENT_CALLBACK_ELEM *next;
@@ -147,7 +146,7 @@ static void fail_status_notify(email_event_t *event_data, int error)
        EM_DEBUG_FUNC_BEGIN();
        int account_id, mail_id;
 
-       if(!event_data) {
+       if (!event_data) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return;
        }
@@ -290,7 +289,8 @@ int emcore_register_event_callback(email_action_t action, email_event_callback c
 
        ret = true;
 
-EXIT :
+EXIT:
+
        LEAVE_RECURSIVE_CRITICAL_SECTION(_event_callback_table_lock);
        EM_DEBUG_FUNC_END();
        return ret;
@@ -407,8 +407,7 @@ INTERNAL_FUNC int emcore_insert_event(email_event_t *event_data, int *handle, in
                        g_queue_push_tail(g_event_que, event_data);
                        WAKE_CONDITION_VARIABLE(_event_available_signal);
                        ret = true;
-               }
-               else {
+               } else {
                        EM_DEBUG_EXCEPTION("event queue is full...");
                        error = EMAIL_ERROR_EVENT_QUEUE_FULL;
                        ret = false;
@@ -447,14 +446,13 @@ INTERNAL_FUNC int emcore_insert_event(email_event_t *event_data, int *handle, in
                {
                        int is_local_activity_event_inserted = false;
                        emcore_partial_body_thd_local_activity_sync(multi_user_name,
-                                                                                                                &is_local_activity_event_inserted, 
+                                                                                                                &is_local_activity_event_inserted,
                                                                                                                 &error);
                        if (error != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("emcore_partial_body_thd_local_activity_sync failed [%d]", error);
-                       }
-                       else {
+                       } else {
                                if (true == is_local_activity_event_inserted)
-                                       emcore_pb_thd_set_local_activity_continue (false);
+                                       emcore_pb_thd_set_local_activity_continue(false);
                        }
                }
 #endif
@@ -497,7 +495,7 @@ INTERNAL_FUNC int emcore_retrieve_event(email_event_t **event_data, int *err_cod
                head_event = (email_event_t *)g_queue_peek_head(g_event_que);
                if (!head_event) {
                        error = EMAIL_ERROR_EVENT_QUEUE_EMPTY;
-                       EM_DEBUG_LOG_DEV ("QUEUE is empty");
+                       EM_DEBUG_LOG_DEV("QUEUE is empty");
                        break;
                }
                if (head_event->status != EMAIL_EVENT_STATUS_WAIT) {
@@ -546,8 +544,7 @@ INTERNAL_FUNC int emcore_is_event_queue_empty(void)
        EM_DEBUG_LOG("Q Length : [%d]", q_length);
        if (q_length > 0) {
                ret = false;
-       }
-       else {
+       } else {
                EM_DEBUG_LOG("event que is empty");
                ret = true;
        }
@@ -568,8 +565,7 @@ INTERNAL_FUNC int emcore_is_send_event_queue_empty(void)
        EM_DEBUG_LOG("Q Length : [%d]", q_length);
        if (q_length > 0) {
                ret = false;
-       }
-       else {
+       } else {
                EM_DEBUG_LOG("send event que is empty");
                ret = true;
        }
@@ -579,7 +575,7 @@ INTERNAL_FUNC int emcore_is_send_event_queue_empty(void)
 }
 
 
-INTERNAL_FUNC void emcore_get_sync_fail_event_data(email_event_t **event_data) 
+INTERNAL_FUNC void emcore_get_sync_fail_event_data(email_event_t **event_data)
 {
        if (!sync_failed_event_data) {
                EM_DEBUG_EXCEPTION("sync_failed_event_data is NULL");
@@ -590,7 +586,7 @@ INTERNAL_FUNC void emcore_get_sync_fail_event_data(email_event_t **event_data)
 
        new_event = em_malloc(sizeof(email_event_t));
        if (new_event == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                return;
        }
 
@@ -678,17 +674,17 @@ INTERNAL_FUNC int emcore_retrieve_send_event(email_event_t **event_data, int *er
        email_event_t *head_event = NULL;
 
        /* g_queue_get_length is aborted when param is null */
-       q_length = g_send_event_que? g_queue_get_length (g_send_event_que): 0; /*prevent 35141*/
+       q_length = g_send_event_que ? g_queue_get_length(g_send_event_que) : 0; /*prevent 35141*/
 
        EM_DEBUG_LOG("SEND Q Length : [%d]", q_length);
 
        if (!q_length) {
                error = EMAIL_ERROR_EVENT_QUEUE_EMPTY;
-               EM_DEBUG_LOG_DEV("SEND QUEUE is empty"); 
+               EM_DEBUG_LOG_DEV("SEND QUEUE is empty");
                goto FINISH_OFF;
        }
 
-       while(1) {
+       while (1) {
                head_event = (email_event_t *)g_queue_peek_head(g_send_event_que);
                if (!head_event) {
                        error = EMAIL_ERROR_EVENT_QUEUE_EMPTY;
@@ -904,19 +900,19 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code)
                                case EMAIL_EVENT_SEND_MAIL_SAVED:
                                        EM_DEBUG_LOG("EMAIL_EVENT_SEND_MAIL or EMAIL_EVENT_SEND_MAIL_SAVED");
                                        if (!emcore_notify_network_event(NOTI_SEND_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SEND_CANCEL] Failed >>>>");
                                        break;
 
                                case EMAIL_EVENT_DOWNLOAD_BODY:
                                        EM_DEBUG_LOG("EMAIL_EVENT_DOWNLOAD_BODY");
                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_BODY_CANCEL] Failed >>>>");
                                        break;
 
                                case EMAIL_EVENT_DOWNLOAD_ATTACHMENT:
                                        EM_DEBUG_LOG("EMAIL_EVENT_DOWNLOAD_ATTACHMENT");
                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_CANCEL, found_elm->event_param_data_4, NULL , found_elm->event_param_data_5, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_ATTACH_CANCEL] Failed >>>>");
                                        break;
 
                                case EMAIL_EVENT_SYNC_HEADER:
@@ -929,7 +925,7 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code)
                                case EMAIL_EVENT_VALIDATE_ACCOUNT:
                                        EM_DEBUG_LOG("validate account waiting: cancel account id[%d]", found_elm->account_id);
                                        if (!emcore_notify_network_event(NOTI_VALIDATE_ACCOUNT_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>>");
                                        break;
 
                                case EMAIL_EVENT_DELETE_MAIL:
@@ -957,14 +953,12 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code)
                        } else {
                                EM_DEBUG_LOG("Failed to g_queue_pop_nth [%d] element", i);
                        }
-               }
-               else {
+               } else {
                        switch (found_elm->type) {
-
                                case EMAIL_EVENT_SYNC_HEADER:
                                        EM_DEBUG_LOG("EMAIL_EVENT_SYNC_HEADER");
                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_CANCEL] Failed >>>>");
                                        if ((err = emcore_update_sync_status_of_account(found_elm->multi_user_name, found_elm->account_id, SET_TYPE_MINUS, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
                                                EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
                                        break;
@@ -972,7 +966,7 @@ INTERNAL_FUNC int emcore_cancel_thread(int handle, void *arg, int *err_code)
                                case EMAIL_EVENT_DOWNLOAD_ATTACHMENT:
                                        EM_DEBUG_LOG("EMAIL_EVENT_DOWNLOAD_ATTACHMENT");
                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_CANCEL, found_elm->event_param_data_4, NULL , found_elm->event_param_data_5, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_ATTACH_CANCEL] Failed >>>>");
                                        break;
 
                                default:
@@ -1006,7 +1000,7 @@ INTERNAL_FUNC int emcore_cancel_all_thread(int *err_code)
        ENTER_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
 
        /* g_queue_get_length is aborted when param is null */
-       q_length = g_event_que? g_queue_get_length (g_event_que): 0; /*prevent 35142 */
+       q_length = g_event_que ? g_queue_get_length(g_event_que) : 0; /*prevent 35142 */
 
        for (i = 0; i < q_length; i++) {
                pop_elm = (email_event_t *)g_queue_peek_nth(g_event_que, i);
@@ -1021,13 +1015,13 @@ INTERNAL_FUNC int emcore_cancel_all_thread(int *err_code)
                                case EMAIL_EVENT_SEND_MAIL_SAVED:
                                        EM_DEBUG_LOG("EMAIL_EVENT_SEND_MAIL or EMAIL_EVENT_SEND_MAIL_SAVED");
                                        if (!emcore_notify_network_event(NOTI_SEND_CANCEL, pop_elm->account_id, NULL , pop_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SEND_CANCEL] Failed >>>>");
                                        break;
 
                                case EMAIL_EVENT_DOWNLOAD_BODY:
                                        EM_DEBUG_LOG("EMAIL_EVENT_DOWNLOAD_BODY");
                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_CANCEL, pop_elm->account_id, NULL , pop_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SEND_CANCEL] Failed >>>>");
                                        break;
 
                                case EMAIL_EVENT_SYNC_HEADER:
@@ -1041,7 +1035,7 @@ INTERNAL_FUNC int emcore_cancel_all_thread(int *err_code)
                                case EMAIL_EVENT_VALIDATE_ACCOUNT:
                                        EM_DEBUG_LOG("validate account waiting: cancel account id[%d]", pop_elm->account_id);
                                        if (!emcore_notify_network_event(NOTI_VALIDATE_ACCOUNT_CANCEL, pop_elm->account_id, NULL , pop_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>>");
                                        break;
 
                                case EMAIL_EVENT_DELETE_MAIL:
@@ -1071,8 +1065,7 @@ INTERNAL_FUNC int emcore_cancel_all_thread(int *err_code)
                        if (g_event_que)
                                q_length = g_queue_get_length(g_event_que);
 
-               }
-               else {
+               } else {
                        if (pop_elm) pop_elm->status = EMAIL_EVENT_STATUS_CANCELED;
                }
        }
@@ -1136,7 +1129,7 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(char *multi_user_name,
 
        for (i = 0; i < q_length; i++) {
                found_elm = (email_event_t *)g_queue_peek_nth(g_event_que, i);
-               if (found_elm && (found_elm->account_id == account_id || found_elm->account_id == ALL_ACCOUNT) && 
+               if (found_elm && (found_elm->account_id == account_id || found_elm->account_id == ALL_ACCOUNT) &&
                        ((!found_elm->multi_user_name && !multi_user_name) || (
                                (multi_user_name) && !EM_SAFE_STRCASECMP(found_elm->multi_user_name, multi_user_name)))) {
                        EM_DEBUG_LOG("Found Queue element[%d]", i);
@@ -1149,16 +1142,16 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(char *multi_user_name,
                                        case EMAIL_EVENT_SEND_MAIL:
                                        case EMAIL_EVENT_SEND_MAIL_SAVED:
                                                EM_DEBUG_LOG("EMAIL_EVENT_SEND_MAIL or EMAIL_EVENT_SEND_MAIL_SAVED");
-                                               if (!emcore_notify_network_event(NOTI_SEND_CANCEL, found_elm->account_id, NULL , 
+                                               if (!emcore_notify_network_event(NOTI_SEND_CANCEL, found_elm->account_id, NULL ,
                                                                                                                found_elm->event_param_data_4, error_code))
-                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>>");
+                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SEND_CANCEL] Failed >>>>");
                                                break;
 
                                        case EMAIL_EVENT_DOWNLOAD_BODY:
                                                EM_DEBUG_LOG("EMAIL_EVENT_DOWNLOAD_BODY");
-                                               if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_CANCEL, found_elm->account_id, NULL, 
+                                               if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_CANCEL, found_elm->account_id, NULL,
                                                                                                                found_elm->event_param_data_4, error_code))
-                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SEND_CANCEL] Failed >>>>");
+                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SEND_CANCEL] Failed >>>>");
                                                break;
 
                                        case EMAIL_EVENT_SYNC_HEADER:
@@ -1172,7 +1165,7 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(char *multi_user_name,
                                        case EMAIL_EVENT_VALIDATE_ACCOUNT:
                                                EM_DEBUG_LOG("validate account waiting: cancel account id[%d]", found_elm->account_id);
                                                if (!emcore_notify_network_event(NOTI_VALIDATE_ACCOUNT_CANCEL, found_elm->account_id, NULL , found_elm->event_param_data_4, error_code))
-                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>>");
+                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>>");
                                                break;
 
                                        case EMAIL_EVENT_DELETE_MAIL:
@@ -1204,8 +1197,7 @@ INTERNAL_FUNC int emcore_cancel_all_threads_of_an_account(char *multi_user_name,
                                if (g_event_que)
                                        q_length = g_queue_get_length(g_event_que);
 
-                       }
-                       else {
+                       } else {
                                found_elm->status = EMAIL_EVENT_STATUS_CANCELED;
                        }
                }
@@ -1254,7 +1246,7 @@ INTERNAL_FUNC int emcore_cancel_send_mail_thread(int handle, void *arg, int *err
                                case EMAIL_EVENT_SEND_MAIL_SAVED:
                                        found_elm->status = EMAIL_EVENT_STATUS_CANCELED;
                                        if (!emcore_notify_network_event(NOTI_SEND_CANCEL, found_elm->account_id, NULL, found_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEND_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEND_CANCEL] Failed >>>>");
                                        break;
                                default:
                                        break;
@@ -1310,7 +1302,7 @@ INTERNAL_FUNC int emcore_cancel_all_send_mail_thread(int *err_code)
                                case EMAIL_EVENT_SEND_MAIL_SAVED:
                                        pop_elm->status = EMAIL_EVENT_STATUS_CANCELED;
                                        if (!emcore_notify_network_event(NOTI_SEND_CANCEL, pop_elm->account_id, NULL, pop_elm->event_param_data_4, err))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEND_CANCEL] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEND_CANCEL] Failed >>>>");
                                        break;
                                default:
                                        break;
@@ -1394,10 +1386,10 @@ FINISH_OFF:
 INTERNAL_FUNC int emcore_free_event(email_event_t *event_data)
 {
        EM_DEBUG_FUNC_BEGIN("event_data [%p]", event_data);
-       if(!event_data) 
+       if (!event_data)
                return EMAIL_ERROR_INVALID_PARAM;
 
-       switch(event_data->type) {
+       switch (event_data->type) {
                case EMAIL_EVENT_SYNC_IMAP_MAILBOX:
                        EM_SAFE_FREE(event_data->event_param_data_3);
                        break;
@@ -1472,7 +1464,7 @@ INTERNAL_FUNC int emcore_free_event(email_event_t *event_data)
                                int input_attachment_count = event_data->event_param_data_4;
                                emcore_free_mail_data_list(&input_mail_data, 1);
                                emcore_free_attachment_data(&input_attachment_data_list, input_attachment_count, NULL);
-                               emstorage_free_meeting_request(input_meeting_request);                          
+                               emstorage_free_meeting_request(input_meeting_request);
                        }
                        break;
 
@@ -1493,20 +1485,20 @@ INTERNAL_FUNC int emcore_free_event(email_event_t *event_data)
                                email_search_filter_t *search_filter = (email_search_filter_t *)event_data->event_param_data_1;
 
                                if (event_data->event_param_data_1) {
-                                       for(i = 0; i < search_filter_count; i++) {
-                                               switch(search_filter[i].search_filter_type) {
-                                               case EMAIL_SEARCH_FILTER_TYPE_BCC              :
-                                               case EMAIL_SEARCH_FILTER_TYPE_BODY             :
-                                               case EMAIL_SEARCH_FILTER_TYPE_CC               :
-                                               case EMAIL_SEARCH_FILTER_TYPE_FROM             :
-                                               case EMAIL_SEARCH_FILTER_TYPE_KEYWORD          :
-                                               case EMAIL_SEARCH_FILTER_TYPE_TEXT             :
-                                               case EMAIL_SEARCH_FILTER_TYPE_SUBJECT          :
-                                               case EMAIL_SEARCH_FILTER_TYPE_TO               :
-                                               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID       :
-                                               case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME  :
-                                               case EMAIL_SEARCH_FILTER_TYPE_CHARSET          :
-                                               case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED     :
+                                       for (i = 0; i < search_filter_count; i++) {
+                                               switch (search_filter[i].search_filter_type) {
+                                               case EMAIL_SEARCH_FILTER_TYPE_BCC:
+                                               case EMAIL_SEARCH_FILTER_TYPE_BODY:
+                                               case EMAIL_SEARCH_FILTER_TYPE_CC:
+                                               case EMAIL_SEARCH_FILTER_TYPE_FROM:
+                                               case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:
+                                               case EMAIL_SEARCH_FILTER_TYPE_TEXT:
+                                               case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:
+                                               case EMAIL_SEARCH_FILTER_TYPE_TO:
+                                               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:
+                                               case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:
+                                               case EMAIL_SEARCH_FILTER_TYPE_CHARSET:
+                                               case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:
                                                        EM_SAFE_FREE(search_filter[i].search_filter_key_value.string_type_key_value);
                                                        break;
                                                default:
@@ -1540,8 +1532,8 @@ INTERNAL_FUNC int emcore_free_event(email_event_t *event_data)
                break;
 #endif /* __FEATURE_LOCAL_ACTIVITY__ */
 
-               default : /*free function is not implemented*/
-                       EM_DEBUG_EXCEPTION("event %d is NOT freed, possibly memory leaks", event_data->type);   
+               default: /*free function is not implemented*/
+                       EM_DEBUG_EXCEPTION("event %d is NOT freed, possibly memory leaks", event_data->type);
        }
 
        EM_SAFE_FREE(event_data->multi_user_name);
@@ -1569,10 +1561,9 @@ static int emcore_get_new_handle(void)
        if (i < EVENT_QUEUE_MAX) {
                ret_handle = i+1;
                EM_DEBUG_LOG("New handle [%d]", ret_handle);
-       }
-       else {
+       } else {
                ret_handle = 0;
-               EM_DEBUG_EXCEPTION ("there is no available handle");
+               EM_DEBUG_EXCEPTION("there is no available handle");
        }
 
        EM_DEBUG_FUNC_END();
@@ -1598,8 +1589,7 @@ static int emcore_get_new_send_handle(void)
        if (i < EVENT_QUEUE_MAX) {
                ret_handle = i+1;
                EM_DEBUG_LOG("New send handle [%d]", ret_handle);
-       }
-       else {
+       } else {
                ret_handle = 0;
                EM_DEBUG_LOG("there is no available send handle");
        }
@@ -1747,8 +1737,7 @@ INTERNAL_FUNC int emcore_clear_partial_body_thd_event_que(int *err_code)
 
        if (true == g_partial_body_thd_queue_empty) {
                EM_DEBUG_LOG(" Partial Body Thread Event Queue Already empty ");
-       }
-       else {
+       } else {
                for (i = 0; i < TOTAL_PARTIAL_BODY_EVENTS; ++i) {
                        if (g_partial_body_thd_event_que[i].event_type) {
                                if (false == emcore_free_partial_body_thd_event(g_partial_body_thd_event_que + i, &error))                                       {
@@ -1834,7 +1823,7 @@ static int emcore_copy_partial_body_thd_event(email_event_partial_body_thd *src,
        dest->activity_type = src->activity_type;
        dest->event_type = src->event_type;
        dest->multi_user_name = EM_SAFE_STRDUP(src->multi_user_name);
-       
+
 
        ret = true;
 
@@ -1879,8 +1868,8 @@ INTERNAL_FUNC int emcore_free_partial_body_thd_event(email_event_partial_body_th
        return true;
 }
 
-INTERNAL_FUNC int emcore_insert_partial_body_thread_event (
-                              email_event_partial_body_thd *partial_body_thd_event, 
+INTERNAL_FUNC int emcore_insert_partial_body_thread_event(
+                              email_event_partial_body_thd *partial_body_thd_event,
                               int                          *error_code)
 {
        EM_DEBUG_FUNC_BEGIN();
@@ -1906,7 +1895,7 @@ INTERNAL_FUNC int emcore_insert_partial_body_thread_event (
        index = g_partial_body_thd_next_event_idx;
        for (count = 0; count < TOTAL_PARTIAL_BODY_EVENTS; count++) {
                /*Found empty Cell*/
-               if (g_partial_body_thd_event_que[index].event_type == EMAIL_EVENT_NONE) {               
+               if (g_partial_body_thd_event_que[index].event_type == EMAIL_EVENT_NONE) {
                        empty_cell_index = index;
                        break;
                }
@@ -1915,13 +1904,12 @@ INTERNAL_FUNC int emcore_insert_partial_body_thread_event (
        }
 
        if (empty_cell_index != -1) {
-               emcore_copy_partial_body_thd_event (partial_body_thd_event, 
-                                 g_partial_body_thd_event_que + empty_cell_index, 
+               emcore_copy_partial_body_thd_event(partial_body_thd_event,
+                                 g_partial_body_thd_event_que + empty_cell_index,
                                  &error);
                if (error != EMAIL_ERROR_NONE) {
                        EM_DEBUG_LOG("emcore_copy_partial_body_thd_event failed [%d]", error);
-               }
-               else {
+               } else {
                        g_partial_body_thd_queue_empty = false;
                        if (count == (TOTAL_PARTIAL_BODY_EVENTS - 1)) {
                                /*This is the last event_data inserted in queue after its insertion, queue is full */
@@ -1930,8 +1918,7 @@ INTERNAL_FUNC int emcore_insert_partial_body_thread_event (
                        WAKE_CONDITION_VARIABLE(_partial_body_thd_cond);
                        ret = true;
                }
-       }
-       else {
+       } else {
                EM_DEBUG_LOG("partial body thread event_data queue is full ");
                error = EMAIL_ERROR_EVENT_QUEUE_FULL;
 
@@ -1969,8 +1956,7 @@ INTERNAL_FUNC int emcore_retrieve_partial_body_thread_event(email_event_partial_
                error = EMAIL_ERROR_EVENT_QUEUE_EMPTY;
                g_partial_body_thd_queue_empty = true;
                g_partial_body_thd_queue_full = false;
-       }
-       else {
+       } else {
                /*Copy the event_data from queue to return it and free the event_data in queue */
                if (false == emcore_copy_partial_body_thd_event(g_partial_body_thd_event_que + index, partial_body_thd_event, &error))
                        EM_DEBUG_EXCEPTION("emcore_copy_partial_body_thd_event failed [%d]", error);
@@ -2017,11 +2003,11 @@ static int emcore_partial_body_bulk_flush(char *multi_user_name, int *error_code
        MAILSTREAM *stream = NULL;
        void *tmp_stream = NULL;
 
-       if (!emcore_connect_to_remote_mailbox(multi_user_name, 
-                                                                                       g_partial_body_bulk_dwd_que[0].account_id, 
-                                                                                       g_partial_body_bulk_dwd_que[0].mailbox_id, 
+       if (!emcore_connect_to_remote_mailbox(multi_user_name,
+                                                                                       g_partial_body_bulk_dwd_que[0].account_id,
+                                                                                       g_partial_body_bulk_dwd_que[0].mailbox_id,
                                                                                        true,
-                                                                                       (void **)&tmp_stream, 
+                                                                                       (void **)&tmp_stream,
                                                                                        &error) || (NULL == tmp_stream)) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", error);
                goto FINISH_OFF;
@@ -2029,7 +2015,7 @@ static int emcore_partial_body_bulk_flush(char *multi_user_name, int *error_code
        stream = (MAILSTREAM *)tmp_stream;
 
        /*  Call bulk download here */
-       if (false == emcore_download_bulk_partial_mail_body (stream, g_partial_body_bulk_dwd_que, g_partial_body_bulk_dwd_next_event_idx, &error)) {
+       if (false == emcore_download_bulk_partial_mail_body(stream, g_partial_body_bulk_dwd_que, g_partial_body_bulk_dwd_next_event_idx, &error)) {
                EM_DEBUG_EXCEPTION(" emcore_download_bulk_partial_mail_body failed.. [%d]", error);
                goto FINISH_OFF;
        }
@@ -2037,7 +2023,7 @@ static int emcore_partial_body_bulk_flush(char *multi_user_name, int *error_code
        ret = true;
 FINISH_OFF:
 
-       stream = mail_close (stream);
+       stream = mail_close(stream);
 
        g_partial_body_bulk_dwd_next_event_idx = 0;
        g_partial_body_bulk_dwd_queue_empty = true;
@@ -2054,7 +2040,7 @@ FINISH_OFF:
 
 
 /* Function to pass UID list and Data for bulk partial body download [santosh.br@samsung.com]/[h.gahlaut@samsung.com] */
-INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_thd *pbd_event, int *error_code)
+INTERNAL_FUNC int emcore_mail_partial_body_download(email_event_partial_body_thd *pbd_event, int *error_code)
 {
        EM_DEBUG_FUNC_BEGIN();
        int error = EMAIL_ERROR_NONE;
@@ -2088,8 +2074,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
                                        goto FINISH_OFF;
                                }
                        }
-               }
-               else  {
+               } else  {
                        EM_DEBUG_LOG("Event is not for the same mailbox and same account as the already present events in download que");
                        EM_DEBUG_LOG("Flush the current que if not empty");
                        EM_DEBUG_LOG("g_partial_body_bulk_dwd_queue_empty [%d]", g_partial_body_bulk_dwd_queue_empty);
@@ -2101,7 +2086,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
                        }
                }
                /*Add the event_data to the download que array */
-               if (false == emcore_copy_partial_body_thd_event (pbd_event, 
+               if (false == emcore_copy_partial_body_thd_event(pbd_event,
                                  g_partial_body_bulk_dwd_que+(g_partial_body_bulk_dwd_next_event_idx), &error))
                        EM_DEBUG_EXCEPTION("\t Partial Body thread emcore_copy_partial_body_thd_event failed - %d", error);
                else {
@@ -2109,9 +2094,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
                        g_partial_body_bulk_dwd_next_event_idx++;
                        EM_DEBUG_LOG("g_partial_body_bulk_dwd_next_event_idx [%d]", g_partial_body_bulk_dwd_next_event_idx);
                }
-       }
-       else if (pbd_event->activity_type) {
-
+       } else if (pbd_event->activity_type) {
                int account_count = 0;
 
                EM_DEBUG_LOG("Event is coming from local activity.");
@@ -2134,14 +2117,14 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
                                int k = 0;
                                int activity_count = 0;
 
-                               if (!emcore_connect_to_remote_mailbox(pbd_event->multi_user_name, 
-                                                                                                               account_list[m], 
-                                                                                                               mailbox_list[i], 
+                               if (!emcore_connect_to_remote_mailbox(pbd_event->multi_user_name,
+                                                                                                               account_list[m],
+                                                                                                               mailbox_list[i],
                                                                                                                true,
-                                                                                                               (void **)&stream, 
+                                                                                                               (void **)&stream,
                                                                                                                &error)) {
                                        EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", error);
-                                       stream = mail_close (stream);
+                                       stream = mail_close(stream);
                                        goto FINISH_OFF;
                                }
 
@@ -2154,7 +2137,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
                                        continue;
                                }
                                */
-                               if (activity_count>0 && activity_data_list) {
+                               if (activity_count > 0 && activity_data_list) {
                                        int temp_error = EMAIL_ERROR_NONE;
                                        int j = 0;
                                        int iter = 0;
@@ -2203,7 +2186,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
                                                goto FINISH_OFF;                /* Stop Local Activity Sync */
                                        }
                                }
-                               stream = mail_close (stream);
+                               stream = mail_close(stream);
                        }
                }
 
@@ -2211,8 +2194,7 @@ INTERNAL_FUNC int emcore_mail_partial_body_download (email_event_partial_body_th
                local activity continue variable should be set to false. */
 
                emcore_pb_thd_set_local_activity_continue(false);
-       }
-       else /* Event-type is 0 which means Event is to flush the que when no more events are present in g_partial_body_thd_event_que */ {
+       } else /* Event-type is 0 which means Event is to flush the que when no more events are present in g_partial_body_thd_event_que */ {
                /*Check if events have arrived in g_partial_body_thd_event_que */
                if (false == emcore_is_partial_body_thd_que_empty()) {
                        EM_DEBUG_LOG("emcore_is_partial_body_thd_que_empty retured true");
@@ -2232,7 +2214,7 @@ FINISH_OFF:
 
        EM_SAFE_FREE(mailbox_list);
        EM_SAFE_FREE(account_list);
-       stream = mail_close (stream);
+       stream = mail_close(stream);
 
        if (error_code)
                *error_code = error;
index a65d04c..66301d9 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -25,9 +25,9 @@
  * File :  email-core-global.c
  * Desc :  Mail Engine Global
  *
- * Auth :  Kyuho Jo 
+ * Auth :  Kyuho Jo
  *
- * History : 
+ * History :
  *    2010.08.25  :  created
  *****************************************************************************/
 #include <stdio.h>
@@ -42,7 +42,7 @@
 static email_account_list_t *g_unvalidated_account_list = NULL;
 static pthread_mutex_t _unvalidated_account_lock = PTHREAD_MUTEX_INITIALIZER;
 
-extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) __THROW __nonnull ((1));
+extern int pthread_mutexattr_settype(pthread_mutexattr_t *__attr, int __kind) __THROW __nonnull((1));
 
 INTERNAL_FUNC int emcore_get_account_from_unvalidated_account_list(int input_unvalidated_account_id, email_account_t **oupput_account)
 {
@@ -50,7 +50,7 @@ INTERNAL_FUNC int emcore_get_account_from_unvalidated_account_list(int input_unv
        email_account_list_t *account_node = NULL;
        int err = EMAIL_ERROR_NONE;
 
-       if(oupput_account == NULL) {
+       if (oupput_account == NULL) {
                err = EMAIL_ERROR_INVALID_PARAM;
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                goto FINISH_OFF;
@@ -60,8 +60,8 @@ INTERNAL_FUNC int emcore_get_account_from_unvalidated_account_list(int input_unv
 
        ENTER_CRITICAL_SECTION(_unvalidated_account_lock);
        account_node = g_unvalidated_account_list;
-       while(account_node) {
-               if(account_node->account->account_id == input_unvalidated_account_id) {
+       while (account_node) {
+               if (account_node->account->account_id == input_unvalidated_account_id) {
                        emcore_duplicate_account(account_node->account, oupput_account, NULL);
                        break;
                }
@@ -69,7 +69,7 @@ INTERNAL_FUNC int emcore_get_account_from_unvalidated_account_list(int input_unv
        }
        LEAVE_CRITICAL_SECTION(_unvalidated_account_lock);
 
-       if(*oupput_account == NULL)
+       if (*oupput_account == NULL)
                err = EMAIL_ERROR_DATA_NOT_FOUND;
 
 FINISH_OFF:
@@ -85,7 +85,7 @@ INTERNAL_FUNC int emcore_add_account_to_unvalidated_account_list(email_account_t
        int new_account_id = -1;
        int err = EMAIL_ERROR_NONE;
 
-       if(input_new_account == NULL) {
+       if (input_new_account == NULL) {
                err = EMAIL_ERROR_INVALID_PARAM;
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                goto FINISH_OFF;
@@ -93,7 +93,7 @@ INTERNAL_FUNC int emcore_add_account_to_unvalidated_account_list(email_account_t
 
        new_account_node = em_malloc(sizeof(email_account_list_t));
 
-       if(new_account_node == NULL) {
+       if (new_account_node == NULL) {
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                goto FINISH_OFF;
@@ -105,8 +105,8 @@ INTERNAL_FUNC int emcore_add_account_to_unvalidated_account_list(email_account_t
        ENTER_CRITICAL_SECTION(_unvalidated_account_lock);
        account_node = &g_unvalidated_account_list;
 
-       while(*account_node) {
-               if((*account_node)->account->account_id < new_account_id) {
+       while (*account_node) {
+               if ((*account_node)->account->account_id < new_account_id) {
                        new_account_id = (*account_node)->account->account_id - 1;
                }
                account_node = &((*account_node)->next);
@@ -131,10 +131,10 @@ INTERNAL_FUNC int emcore_delete_account_from_unvalidated_account_list(int input_
        ENTER_CRITICAL_SECTION(_unvalidated_account_lock);
        account_node = g_unvalidated_account_list;
 
-       while(account_node) {
-               if(account_node->account->account_id == input_account_id) {
+       while (account_node) {
+               if (account_node->account->account_id == input_account_id) {
                        found_account = account_node->account;
-                       if(prev_node)
+                       if (prev_node)
                                prev_node->next = account_node->next;
                        else
                                g_unvalidated_account_list = account_node->next;
@@ -144,7 +144,7 @@ INTERNAL_FUNC int emcore_delete_account_from_unvalidated_account_list(int input_
                account_node = account_node->next;
        }
 
-       if(found_account) {
+       if (found_account) {
                emcore_free_account(found_account);
                EM_SAFE_FREE(found_account);
                EM_SAFE_FREE(account_node);
index c5d167a..be4a739 100755 (executable)
@@ -117,7 +117,7 @@ INTERNAL_FUNC int emcore_gmime_imap_parse_mime_partial(char *rfc822header_str, c
 
        EM_SAFE_FREE(fulltext);
 
-       if (message) g_object_unref (message);
+       if (message) g_object_unref(message);
 
        EM_DEBUG_FUNC_END();
        return true;
@@ -167,9 +167,9 @@ INTERNAL_FUNC int emcore_gmime_pop3_parse_mime(char *eml_path, struct _m_content
 
        g_mime_message_foreach(message, emcore_gmime_pop3_parse_foreach_cb, (gpointer)cnt_info);
 
-       EM_SAFE_CLOSE (fd);
+       EM_SAFE_CLOSE(fd);
 
-       if (message) g_object_unref (message);
+       if (message) g_object_unref(message);
 
        EM_DEBUG_FUNC_END();
        return true;
@@ -222,9 +222,9 @@ INTERNAL_FUNC int emcore_gmime_eml_parse_mime(char *eml_path,
 
        g_mime_message_foreach(message, emcore_gmime_eml_parse_foreach_cb, (gpointer)cnt_info);
 
-       EM_SAFE_CLOSE (fd);
+       EM_SAFE_CLOSE(fd);
 
-       if (message) g_object_unref (message);
+       if (message) g_object_unref(message);
 
        EM_DEBUG_FUNC_END();
        return true;
@@ -324,7 +324,7 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -347,7 +347,7 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
                        }
                        EM_SAFE_FREE(utf8_text);
 
-                       if(msg_ctype_type && msg_ctype_subtype) {
+                       if (msg_ctype_type && msg_ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", msg_ctype_type, msg_ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -457,7 +457,7 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
 
 
                GMimeContentEncoding enc = g_mime_part_get_content_encoding(leaf_part);
-               switch(enc) {
+               switch (enc) {
                case GMIME_CONTENT_ENCODING_DEFAULT:
                        EM_DEBUG_LOG("Encoding:ENCODING_DEFAULT");
                        break;
@@ -587,19 +587,17 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
                        if (content_disposition_type == ATTACHMENT) {
                                EM_DEBUG_LOG("ATTACHMENT");
                                temp_file = cnt_info->file;
-                       }
-                       else if (content_disposition_type == INLINE_ATTACHMENT) {
+                       } else if (content_disposition_type == INLINE_ATTACHMENT) {
                                EM_DEBUG_LOG("INLINE ATTACHMENT");
                                temp_file = cnt_info->inline_file;
-                       }
-                       else {
+                       } else {
                                EM_DEBUG_EXCEPTION("Invalid content_disposition_type");
                                goto FINISH_OFF;
                        }
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -657,7 +655,7 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
                                g_free(file_content); /* prevent 39110 */
                        }
 
-                       if(ctype_type && ctype_subtype) {
+                       if (ctype_type && ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", ctype_type, ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -684,8 +682,7 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject
                                } else {
                                        cnt_info->inline_file = file;
                                }
-                       }
-                       else
+                       } else
                                temp_file->next = file;
                }
 
@@ -853,7 +850,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
 
                file = em_malloc(sizeof(struct attachment_info));
                if (file == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed...");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed...");
                        goto FINISH_OFF;
                }
 
@@ -876,7 +873,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
                }
                EM_SAFE_FREE(utf8_text);
 
-               if(msg_ctype_type && msg_ctype_subtype) {
+               if (msg_ctype_type && msg_ctype_subtype) {
                        char mime_type_buffer[128] = {0,};
                        snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", msg_ctype_type, msg_ctype_subtype);
                        file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -900,7 +897,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
 
                temp_cnt_info = (struct _m_content_info *)em_malloc(sizeof(struct _m_content_info));
                if (temp_cnt_info == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed...");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed...");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -1020,7 +1017,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
 
 
                GMimeContentEncoding enc = g_mime_part_get_content_encoding(leaf_part);
-               switch(enc) {
+               switch (enc) {
                case GMIME_CONTENT_ENCODING_DEFAULT:
                        EM_DEBUG_LOG("Encoding:ENCODING_DEFAULT");
                        break;
@@ -1180,19 +1177,17 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
                        if (content_disposition_type == ATTACHMENT) {
                                EM_DEBUG_LOG("ATTACHMENT");
                                temp_file = cnt_info->file;
-                       }
-                       else if (content_disposition_type == INLINE_ATTACHMENT) {
+                       } else if (content_disposition_type == INLINE_ATTACHMENT) {
                                EM_DEBUG_LOG("INLINE ATTACHMENT");
                                temp_file = cnt_info->inline_file;
-                       }
-                       else {
+                       } else {
                                EM_DEBUG_EXCEPTION("Invalid content_disposition_type");
                                goto FINISH_OFF;
                        }
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -1219,7 +1214,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
                        /* check inline name duplication */
                        if (content_disposition_type == INLINE_ATTACHMENT) {
                                if (emcore_gmime_check_filename_duplication(file->name, cnt_info)) {
-                                       char *modified_name= NULL;
+                                       char *modified_name = NULL;
                                        modified_name = emcore_gmime_get_modified_filename_in_duplication(file->name);
                                        EM_SAFE_FREE(file->name);
                                        file->name = modified_name;
@@ -1267,7 +1262,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
                                g_free(encoding_file_name);
                        }
 
-                       if(ctype_type && ctype_subtype) {
+                       if (ctype_type && ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", ctype_type, ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -1295,8 +1290,7 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject *
                                } else {
                                        cnt_info->inline_file = file;
                                }
-                       }
-                       else
+                       } else
                                temp_file->next = file;
                }
 
@@ -1377,7 +1371,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -1400,7 +1394,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
                        }
                        EM_SAFE_FREE(utf8_text);
 
-                       if(msg_ctype_type && msg_ctype_subtype) {
+                       if (msg_ctype_type && msg_ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", msg_ctype_type, msg_ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -1562,7 +1556,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
                if (content_disposition_type != ATTACHMENT) {
                        /*Content*/
                        GMimeContentEncoding enc = g_mime_part_get_content_encoding(leaf_part);
-                       switch(enc) {
+                       switch (enc) {
                        case GMIME_CONTENT_ENCODING_DEFAULT:
                                EM_DEBUG_LOG("Encoding:ENCODING_DEFAULT");
                                break;
@@ -1672,7 +1666,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -1686,7 +1680,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
                                char *tmp_ptr = file->name;
                                int tmp_len = EM_SAFE_STRLEN(file->name);
                                int tmpi = 0;
-                               for (tmpi=0; tmpi<tmp_len; tmpi++) {
+                               for (tmpi = 0; tmpi < tmp_len; tmpi++) {
                                        if (*(tmp_ptr+tmpi) == '/') {
                                                *(tmp_ptr+tmpi) = '_';
                                        }
@@ -1735,7 +1729,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
                        }
                        g_free(file_content); /* prevent 39110 */
 
-                       if(ctype_type && ctype_subtype) {
+                       if (ctype_type && ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", ctype_type, ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -1746,8 +1740,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
                        if (download_status == EMAIL_PART_DOWNLOAD_STATUS_FULLY_DOWNLOADED) {
                                file->save_status = 1;
                                file->size = real_size;
-                       }
-                       else
+                       } else
                                file->save_status = 0;
 
                        while (temp_file && temp_file->next)
@@ -1766,7 +1759,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -1789,7 +1782,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime
                        }
                        EM_SAFE_FREE(utf8_text);
 
-                       if(ctype_type && ctype_subtype) {
+                       if (ctype_type && ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", ctype_type, ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -1896,7 +1889,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -1919,7 +1912,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
                        }
                        EM_SAFE_FREE(utf8_text);
 
-                       if(msg_ctype_type && msg_ctype_subtype) {
+                       if (msg_ctype_type && msg_ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", msg_ctype_type, msg_ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -2061,7 +2054,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
                EM_DEBUG_LOG_SEC("Temporary Content Path[%s]", content_path);
 
                GMimeContentEncoding enc = g_mime_part_get_content_encoding(leaf_part);
-               switch(enc) {
+               switch (enc) {
                case GMIME_CONTENT_ENCODING_DEFAULT:
                        EM_DEBUG_LOG("Encoding:ENCODING_DEFAULT");
                        break;
@@ -2112,9 +2105,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
                        g_mime_data_wrapper_write_to_stream(data, out_stream);
                        if (out_stream) g_object_unref(out_stream);
                        emcore_get_file_size(content_path, &real_size, NULL);
-               }
-               else
-               {
+               } else {
                        int fd = 0;
                        fd = open(content_path, O_WRONLY|O_CREAT, 0644);
                        if (fd < 0) {
@@ -2186,7 +2177,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -2200,7 +2191,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
                                char *tmp_ptr = file->name;
                                int tmp_len = EM_SAFE_STRLEN(file->name);
                                int tmpi = 0;
-                               for (tmpi=0; tmpi<tmp_len; tmpi++) {
+                               for (tmpi = 0; tmpi < tmp_len; tmpi++) {
                                        if (*(tmp_ptr+tmpi) == '/') {
                                                *(tmp_ptr+tmpi) = '_';
                                        }
@@ -2220,7 +2211,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
                        EM_SAFE_FREE(utf8_text);
 
                        /* check inline name duplication */
-                       char *modified_name= NULL;
+                       char *modified_name = NULL;
                        if (emcore_gmime_check_filename_duplication(file->name, cnt_info)) {
                                modified_name = emcore_gmime_get_modified_filename_in_duplication(file->name);
                                EM_SAFE_FREE(file->name);
@@ -2250,7 +2241,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
                        }
                        g_free(file_content); /* prevent 39110 */
 
-                       if(ctype_type && ctype_subtype) {
+                       if (ctype_type && ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", ctype_type, ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -2276,7 +2267,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
 
                        file = em_malloc(sizeof(struct attachment_info));
                        if (file == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                goto FINISH_OFF;
                        }
 
@@ -2299,7 +2290,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent,
                        }
                        EM_SAFE_FREE(utf8_text);
 
-                       if(ctype_type && ctype_subtype) {
+                       if (ctype_type && ctype_subtype) {
                                char mime_type_buffer[128] = {0,};
                                snprintf(mime_type_buffer, sizeof(mime_type_buffer), "%s/%s", ctype_type, ctype_subtype);
                                file->attachment_mime_type = g_strdup(mime_type_buffer);
@@ -2559,8 +2550,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_bodystructure_foreach_cb(GMimeObject
                                        EM_DEBUG_LOG("TEXT/PLAIN");
                                        cnt_info->text.plain_charset = g_strdup(ctype_charset);
                                        cnt_info->text.plain = tmp_file;
-                               }
-                               else if (ctype_subtype && g_ascii_strcasecmp(ctype_subtype, "html") == 0) {
+                               } else if (ctype_subtype && g_ascii_strcasecmp(ctype_subtype, "html") == 0) {
                                        EM_DEBUG_LOG("TEXT/HTML");
                                        cnt_info->text.html_charset = g_strdup(ctype_charset);
                                        cnt_info->text.html = tmp_file;
@@ -2637,8 +2627,7 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
                                EM_SAFE_FREE(cnt_info->sections);
                                cnt_info->sections = tmp_str;
                        }
-               }
-               else {
+               } else {
                        cnt_info->sections = EM_SAFE_STRDUP(sections);
                }
 
@@ -2781,8 +2770,7 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
 
                        if (cnt_info->grab_type != (GRAB_TYPE_TEXT|GRAB_TYPE_ATTACHMENT))
                                goto FINISH_OFF;
-               }
-               else {
+               } else {
                        snprintf(sections, sizeof(sections), "BODY.PEEK[%s.MIME] BODY.PEEK[%s]", ctype_section, ctype_section);
 
                        if (cnt_info->sections) {
@@ -2798,8 +2786,7 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent
                                        EM_SAFE_FREE(cnt_info->sections);
                                        cnt_info->sections = tmp_str;
                                }
-                       }
-                       else {
+                       } else {
                                cnt_info->sections = EM_SAFE_STRDUP(sections);
                        }
 
@@ -3101,7 +3088,7 @@ INTERNAL_FUNC void emcore_gmime_get_mime_entity_cb(GMimeObject *parent, GMimeObj
        EM_DEBUG_FUNC_END();
 }
 
-INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
+INTERNAL_FUNC void emcore_gmime_construct_multipart(GMimeMultipart *multipart,
                                                                                                        BODY *body,
                                                                                                        const char *spec,
                                                                                                        int *total_mail_size)
@@ -3123,7 +3110,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
                return;
        }
 
-       subspec = g_alloca (strlen(spec) + 14);
+       subspec = g_alloca(strlen(spec) + 14);
        id = g_stpcpy(subspec, spec);
        *id++ = '.';
 
@@ -3133,7 +3120,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
        /* checkout boundary */
        if (body->parameter) {
                PARAMETER *param = body->parameter;
-               while(param) {
+               while (param) {
                        EM_DEBUG_LOG("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
                        param = param->next;
                }
@@ -3142,7 +3129,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
        part = body->nested.part;
 
        while (part != NULL) {
-               sprintf (id, "%d", i++);
+               sprintf(id, "%d", i++);
 
                if (EM_SAFE_STRLEN(subspec) > 2)
                        section = EM_SAFE_STRDUP(subspec+2);
@@ -3202,7 +3189,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
                        if (part->body.encoding <= 5) {
                                EM_DEBUG_LOG("Content Encoding: %s", body_encodings[part->body.encoding]);
                                GMimeContentEncoding encoding = GMIME_CONTENT_ENCODING_DEFAULT;
-                               switch(part->body.encoding) {
+                               switch (part->body.encoding) {
                                case ENC7BIT:
                                        encoding = GMIME_CONTENT_ENCODING_7BIT;
                                        break;
@@ -3256,7 +3243,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
                /* content type */
                if (part->body.parameter) {
                        PARAMETER *param = part->body.parameter;
-                       while(param) {
+                       while (param) {
                            EM_DEBUG_LOG("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
                                if (param->attribute || param->value)
                                        g_mime_object_set_content_type_parameter(subpart, param->attribute, param->value);
@@ -3275,7 +3262,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
 
                if (part->body.disposition.parameter) {
                        PARAMETER *param = part->body.disposition.parameter;
-                       while(param) {
+                       while (param) {
                            EM_DEBUG_LOG_SEC("Content-Disposition Parameter: attribute[%s], value[%s]", param->attribute, param->value);
                                if (param->attribute || param->value)
                                        g_mime_object_set_content_disposition_parameter(subpart, param->attribute, param->value);
@@ -3302,10 +3289,10 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
                        EM_SAFE_FREE(cid);
                }
 
-               g_mime_multipart_add (multipart, subpart);
+               g_mime_multipart_add(multipart, subpart);
 
                if (subpart) {
-                       g_object_unref (subpart);
+                       g_object_unref(subpart);
                        subpart = NULL;
                }
 
@@ -3317,7 +3304,7 @@ INTERNAL_FUNC void emcore_gmime_construct_multipart (GMimeMultipart *multipart,
        EM_DEBUG_FUNC_END();
 }
 
-INTERNAL_FUNC void emcore_gmime_construct_part (GMimePart *part,
+INTERNAL_FUNC void emcore_gmime_construct_part(GMimePart *part,
                                                                                                BODY *body,
                                                                                                const char *spec,
                                                                                                int *total_mail_size)
@@ -3364,7 +3351,7 @@ INTERNAL_FUNC void emcore_gmime_construct_part (GMimePart *part,
        if (body->encoding <= 5) {
                EM_DEBUG_LOG("Content Encoding: %s", body_encodings[body->encoding]);
                GMimeContentEncoding encoding = GMIME_CONTENT_ENCODING_DEFAULT;
-               switch(body->encoding) {
+               switch (body->encoding) {
                case ENC7BIT:
                        encoding = GMIME_CONTENT_ENCODING_7BIT;
                        break;
@@ -3411,7 +3398,7 @@ INTERNAL_FUNC void emcore_gmime_construct_part (GMimePart *part,
        /* content type */
        if (body->parameter) {
                PARAMETER *param = body->parameter;
-               while(param) {
+               while (param) {
                        EM_DEBUG_LOG("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
                        if (param->attribute || param->value)
                                g_mime_object_set_content_type_parameter(part_object, param->attribute, param->value);
@@ -3445,7 +3432,7 @@ INTERNAL_FUNC void emcore_gmime_construct_part (GMimePart *part,
 
        if (body->disposition.parameter) {
                PARAMETER *param = body->disposition.parameter;
-               while(param) {
+               while (param) {
                        EM_DEBUG_LOG("Content-Disposition Parameter: attribute[%s], value[%s]", param->attribute, param->value);
                        if (param->attribute || param->value)
                                g_mime_object_set_content_disposition_parameter(part_object, param->attribute, param->value);
@@ -3502,7 +3489,7 @@ INTERNAL_FUNC int emcore_gmime_construct_mime_part_with_bodystructure(BODY *mbod
                int boundary_ok = 0;
                if (mbody->parameter) {
                        PARAMETER *param = mbody->parameter;
-                       while(param) {
+                       while (param) {
                                if (g_ascii_strcasecmp(param->attribute, "boundary") == 0 && param->value)
                                        boundary_ok = 1;
                                param = param->next;
@@ -3530,15 +3517,14 @@ INTERNAL_FUNC int emcore_gmime_construct_mime_part_with_bodystructure(BODY *mbod
 
                if (mbody->parameter) {
                        PARAMETER *param = mbody->parameter;
-                       while(param) {
+                       while (param) {
                                EM_DEBUG_LOG("Content-Type Parameter: attribute[%s], value[%s]", param->attribute, param->value);
                                if (param->attribute || param->value)
                                        g_mime_object_set_content_type_parameter(mime_part, param->attribute, param->value);
                                param = param->next;
                        }
                }
-       }
-       else {
+       } else {
                char *type = g_ascii_strdown(body_types[mbody->type], -1);
                char *subtype = g_ascii_strdown(mbody->subtype, -1);
                singlepart = g_mime_part_new_with_type(type, subtype);
@@ -3609,13 +3595,11 @@ INTERNAL_FUNC int emcore_gmime_get_body_sections_from_message(GMimeMessage *mess
                                snprintf(t, sizeof(t), "BODY.PEEK[%s] ", part_path);
                                if (EM_SAFE_STRLEN(sections) + EM_SAFE_STRLEN(t) < sizeof(sections) - 1) {
                                        strcat(sections, t);
-                               }
-                               else {
+                               } else {
                                        EM_DEBUG_EXCEPTION("Too many body parts. IMAP command may cross 2000bytes.");
                                        goto FINISH_OFF;
                                }
-                       }
-                       else if (cnt_info->grab_type == GRAB_TYPE_TEXT) {
+                       } else if (cnt_info->grab_type == GRAB_TYPE_TEXT) {
                                if (disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) {
                                        EM_DEBUG_LOG("ATTACHMENT");
                                } else {
@@ -3623,8 +3607,7 @@ INTERNAL_FUNC int emcore_gmime_get_body_sections_from_message(GMimeMessage *mess
                                        snprintf(t, sizeof(t), "BODY.PEEK[%s] ", part_path);
                                        if (EM_SAFE_STRLEN(sections) + EM_SAFE_STRLEN(t) < sizeof(sections) - 1) {
                                                strcat(sections, t);
-                                       }
-                                       else {
+                                       } else {
                                                EM_DEBUG_EXCEPTION("Too many body parts. IMAP command may cross 2000bytes.");
                                                goto FINISH_OFF;
                                        }
@@ -3719,8 +3702,7 @@ INTERNAL_FUNC int emcore_gmime_get_attachment_section_from_message(GMimeMessage
                                        snprintf(t, sizeof(t), "%s", part_path);
                                        if (EM_SAFE_STRLEN(sections) + EM_SAFE_STRLEN(t) < sizeof(sections) - 1) {
                                                strcat(sections, t);
-                                       }
-                                       else {
+                                       } else {
                                                EM_DEBUG_EXCEPTION("Too many body parts. IMAP command may cross 2000bytes.");
                                                goto FINISH_OFF;
                                        }
@@ -3958,7 +3940,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                        }
 
                        if (!(search_info = em_malloc(sizeof(search_section)))) { /* prevent */
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
                        }
@@ -4002,7 +3984,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                g_mime_object_set_content_type_parameter(mime_object, "tmp_content_path", buf);
 
                                if (event_handle > 0)
-                                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                                if (cnt_info->grab_type == GRAB_TYPE_TEXT) {
                                        if (cnt_info->total_body_size > body_size) {
@@ -4013,16 +3995,15 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                                                                                                        buf,
                                                                                                                        cnt_info->total_body_size,
                                                                                                                        0))
-                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
+                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event[ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
                                                }
 
                                                download_interval =  cnt_info->total_body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
                                                download_total_size = cnt_info->total_body_size;
-                                       }
-                                       else {
+                                       } else {
                                                if (!auto_download) {
                                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, buf, body_size, 0))
-                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
+                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event[ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
                                                }
 
                                                download_interval =  body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
@@ -4037,7 +4018,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                                                                                                buf,
                                                                                                                cnt_info->total_mail_size,
                                                                                                                0))
-                                                       EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
+                                                       EM_DEBUG_EXCEPTION(" emcore_notify_network_event[ NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
                                        }
 
                                        download_interval =  cnt_info->total_mail_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
@@ -4063,17 +4044,15 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
 
                                                entity_part = g_mime_parser_construct_part(entity_parser);
                                                if (entity_parser) g_object_unref(entity_parser);
-                                       }
-                                       else if (GMIME_IS_PART(mime_object) && mime_part) {
+                                       } else if (GMIME_IS_PART(mime_object) && mime_part) {
                                                content_stream = g_mime_stream_mem_new_with_buffer((const char *)encoded,
                                                                                                                                                        EM_SAFE_STRLEN(encoded));
                                                //parser = g_mime_parser_new_with_stream(content_stream);
                                                content = g_mime_data_wrapper_new_with_stream(content_stream, mime_part->encoding);
-                                               if (content_stream) g_object_unref (content_stream);
+                                               if (content_stream) g_object_unref(content_stream);
                                                g_mime_part_set_content_object(mime_part, content);
                                                if (content) g_object_unref(content);
-                                       }
-                                       else if (GMIME_IS_MESSAGE_PART(mime_object) && mime_message_part) {
+                                       } else if (GMIME_IS_MESSAGE_PART(mime_object) && mime_message_part) {
                                                FILE *fp = NULL;
                                                int encoded_len = EM_SAFE_STRLEN((char *)encoded);
 
@@ -4110,11 +4089,10 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                        if (cnt_info->grab_type == GRAB_TYPE_TEXT && !auto_download) {
                                                if (cnt_info->total_body_size > body_size) {
                                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, buf, download_total_size, downloaded_size))
-                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_MULTIPART_BODY] Failed >>>>");
-                                               }
-                                               else {
+                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event[NOTI_DOWNLOAD_MULTIPART_BODY] Failed >>>>");
+                                               } else {
                                                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, buf, download_total_size, downloaded_size))
-                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_BODY_START] Failed >>>>");
+                                                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event[NOTI_DOWNLOAD_BODY_START] Failed >>>>");
                                                }
                                        }
                                } else {
@@ -4130,13 +4108,13 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                                x = sizeof(encoded)-1;
 
                                        memset(test_buffer, 0x00, sizeof(test_buffer));
-                                       while (remain_body_size && (total <body_size)) {
+                                       while (remain_body_size && (total < body_size)) {
 
                                                memset(test_buffer, 0x00, sizeof(test_buffer));
                                                while ((total != body_size) && remain_body_size && ((EM_SAFE_STRLEN((char *)test_buffer) + x) < sizeof(test_buffer))) {
                                                        memset(encoded, 0x00, sizeof(encoded));
 
-                                                       if (net_getbuffer (imaplocal->netstream, (long)x, (char *)encoded) <= 0) {
+                                                       if (net_getbuffer(imaplocal->netstream, (long)x, (char *)encoded) <= 0) {
                                                                EM_DEBUG_EXCEPTION("net_getbuffer failed...");
                                                                err = EMAIL_ERROR_NO_RESPONSE;
                                                                goto FINISH_OFF;
@@ -4176,10 +4154,10 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                                                if (!auto_download) {
                                                                        if (cnt_info->total_body_size > body_size) {
                                                                                if (!emcore_notify_network_event(NOTI_DOWNLOAD_MULTIPART_BODY, mail_id, buf, download_total_size, downloaded_size))
-                                                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_MULTIPART_BODY] Failed >>>>");
+                                                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_DOWNLOAD_MULTIPART_BODY] Failed >>>>");
                                                                        } else {
                                                                                if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, buf, download_total_size, downloaded_size))
-                                                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_BODY_START] Failed >>>>");
+                                                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_DOWNLOAD_BODY_START] Failed >>>>");
                                                                        }
                                                                }
                                                        }
@@ -4198,7 +4176,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                                        if (encoded_len > 0 && fwrite(test_buffer, encoded_len, 1, fp) == 0) {
                                                                EM_DEBUG_EXCEPTION("Error Occured while writing. fwrite(\"%s\") failed", test_buffer);
                                                                err = EMAIL_ERROR_SYSTEM_FAILURE;
-                                                               fclose (fp); /* prevent */
+                                                               fclose(fp); /* prevent */
                                                                goto FINISH_OFF;
                                                        }
 
@@ -4219,7 +4197,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                                        if (encoded_len > 0 && fwrite(test_buffer, encoded_len, 1, fp) == 0) {
                                                                EM_DEBUG_EXCEPTION("Error Occured while writing. fwrite(\"%s\") failed", test_buffer);
                                                                err = EMAIL_ERROR_SYSTEM_FAILURE;
-                                                               fclose (fp); /* prevent */
+                                                               fclose(fp); /* prevent */
                                                                goto FINISH_OFF;
                                                        }
 
@@ -4243,8 +4221,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
 
                                                entity_part = g_mime_parser_construct_part(entity_parser);
                                                if (entity_parser) g_object_unref(entity_parser);
-                                       }
-                                       else if (GMIME_IS_PART(mime_object) && mime_part) {
+                                       } else if (GMIME_IS_PART(mime_object) && mime_part) {
                                                err = em_open(buf, O_RDONLY, 0, &fd);
                                                if (err != EMAIL_ERROR_NONE) {
                                                        EM_DEBUG_EXCEPTION("holder open failed : holder is a filename that will be saved.");
@@ -4254,7 +4231,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
                                                content_stream = g_mime_stream_fs_new(fd);
                                                //parser = g_mime_parser_new_with_stream(content_stream);
                                                content = g_mime_data_wrapper_new_with_stream(content_stream, mime_part->encoding);
-                                               if (content_stream) g_object_unref (content_stream);
+                                               if (content_stream) g_object_unref(content_stream);
                                                g_mime_part_set_content_object(mime_part, content);
                                                if (content) g_object_unref(content);
                                        }
@@ -4310,21 +4287,18 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_body_sections(MAILSTREAM *stream, int
 
                        if (buf) g_remove(buf);
                        EM_SAFE_FREE(buf);
-               }
-               else if ((tag_position = g_strrstr(response, tag))) /*  end of response */ {
+               } else if ((tag_position = g_strrstr(response, tag))) /*  end of response */ {
                        if (!strncmp(tag_position + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
                                EM_SAFE_FREE(response);
-                       }
-                       else {          /* 'NO' or 'BAD */
+                       } else {                /* 'NO' or 'BAD */
                                err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;
                                goto FINISH_OFF;
                        }
                        break;
-               }
-               else if (!strcmp(response, ")")) {
+               } else if (!strcmp(response, ")")) {
                }
 
-               EM_SAFE_FREE (response);
+               EM_SAFE_FREE(response);
        }
 
        if (signed_message) {
@@ -4597,7 +4571,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
                        }
 
                        if (!(search_info = em_malloc(sizeof(search_section)))) { /* prevent */
-                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
                        }
@@ -4632,7 +4606,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
                        EM_DEBUG_LOG("Attachment number [%d]", nth);
                        if (!auto_download) {
                                if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, tmp_file, nth, 0))
-                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
+                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
                        }
 
                        download_noti_interval = body_size * DOWNLOAD_NOTI_INTERVAL_PERCENT / 100;
@@ -4661,7 +4635,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
                                        EM_SAFE_FREE(response);
                                        break;
                                }
-                       } while(1);
+                       } while (1);
 
                        preline_len = EM_SAFE_STRLEN(new_response);
                        EM_DEBUG_LOG("preline_len : %d", preline_len);
@@ -4680,12 +4654,11 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
                                        content_stream = g_mime_stream_mem_new_with_buffer((const char *)tmp_str, EM_SAFE_STRLEN(tmp_str));
                                        //parser = g_mime_parser_new_with_stream(content_stream);
                                        content = g_mime_data_wrapper_new_with_stream(content_stream, mime_part->encoding);
-                                       if (content_stream) g_object_unref (content_stream);
+                                       if (content_stream) g_object_unref(content_stream);
                                        g_mime_part_set_content_object(mime_part, content);
                                        if (content) g_object_unref(content);
                                        EM_SAFE_FREE(tmp_str);
-                               }
-                               else if (GMIME_IS_MESSAGE_PART(mime_object) && mime_message_part) {
+                               } else if (GMIME_IS_MESSAGE_PART(mime_object) && mime_message_part) {
                                        FILE *fp = NULL;
                                        int response_len = 0;
                                        char *tmp_str = NULL;
@@ -4736,11 +4709,10 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
 
                                        if (!auto_download) {
                                                if (download_total_size && !emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, tmp_file, nth, download_progress))
-                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
+                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
                                        }
                                }
-                       }
-                       else if ((body_size < DOWNLOAD_MAX_BUFFER_SIZE) && (body_size - preline_len - nskip*2 < DOWNLOAD_MAX_BUFFER_SIZE)) {
+                       } else if ((body_size < DOWNLOAD_MAX_BUFFER_SIZE) && (body_size - preline_len - nskip*2 < DOWNLOAD_MAX_BUFFER_SIZE)) {
                                memset(encoded, 0x00, sizeof(encoded));
                                if (net_getbuffer(imaplocal->netstream, body_size - preline_len - nskip*2, (char *)encoded) <= 0) {
                                        EM_DEBUG_EXCEPTION("net_getbuffer failed...");
@@ -4758,11 +4730,10 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
                                        content_stream = g_mime_stream_mem_new_with_buffer((const char *)encoded, EM_SAFE_STRLEN(encoded));
                                        //parser = g_mime_parser_new_with_stream(content_stream);
                                        content = g_mime_data_wrapper_new_with_stream(content_stream, mime_part->encoding);
-                                       if (content_stream) g_object_unref (content_stream);
+                                       if (content_stream) g_object_unref(content_stream);
                                        g_mime_part_set_content_object(mime_part, content);
                                        if (content) g_object_unref(content);
-                               }
-                               else if (GMIME_IS_MESSAGE_PART(mime_object) && mime_message_part) {
+                               } else if (GMIME_IS_MESSAGE_PART(mime_object) && mime_message_part) {
                                        FILE *fp = NULL;
                                        int encoded_len = EM_SAFE_STRLEN((char *)encoded);
 
@@ -4801,11 +4772,10 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
 
                                        if (!auto_download) {
                                                if (download_total_size && !emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, tmp_file, nth, download_progress))
-                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
+                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
                                        }
                                }
-                       }
-                       else {
+                       } else {
                                int remain_body_size = body_size - preline_len - nskip*2;
                                int x = 0;
                                int nsize = 0;
@@ -4833,7 +4803,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
 
                                        while (remain_body_size > 0 && (total < body_size) && ((EM_SAFE_STRLEN((char *)test_buffer) + x) < sizeof(test_buffer))) {
                                                if (event_handle > 0)
-                                                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                                                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                                                memset(encoded, 0x00, sizeof(encoded));
 
@@ -4870,7 +4840,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
 
                                                        if (!auto_download) {
                                                                if (download_total_size && !emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, tmp_file, nth, download_progress))
-                                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
+                                                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
                                                        }
                                                }
                                        }
@@ -4931,15 +4901,14 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
                                        content_stream = g_mime_stream_fs_new(fd);
                                        //parser = g_mime_parser_new_with_stream(content_stream);
                                        content = g_mime_data_wrapper_new_with_stream(content_stream, mime_part->encoding);
-                                       if (content_stream) g_object_unref (content_stream);
+                                       if (content_stream) g_object_unref(content_stream);
                                        g_mime_part_set_content_object(mime_part, content);
                                        if (content) g_object_unref(content);
                                }
                        }
 
                        EM_SAFE_FREE(tmp_file);
-               }
-               else if ((tag_position = g_strrstr(response, tag))) /*  end of response */ {
+               } else if ((tag_position = g_strrstr(response, tag))) /*  end of response */ {
                        if (!strncmp(tag_position + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
                                EM_SAFE_FREE(response);
                        } else  {               /* 'NO' or 'BAD */
@@ -4947,8 +4916,7 @@ INTERNAL_FUNC int emcore_gmime_fetch_imap_attachment_section(MAILSTREAM *stream,
                                goto FINISH_OFF;
                        }
                        break;
-               }
-               else if (!strcmp(response, ")")) {
+               } else if (!strcmp(response, ")")) {
                        /*  The end of response which contains body information */
                }
        }       /*  while (imaplocal->netstream)  */
@@ -4959,7 +4927,7 @@ FINISH_OFF:
 
        EM_SAFE_FREE(tmp_file);
        EM_SAFE_FREE(response);
-       EM_SAFE_FREE (new_response);
+       EM_SAFE_FREE(new_response);
 
        if (search_info) {
                EM_SAFE_FREE(search_info->section);
@@ -4995,7 +4963,7 @@ INTERNAL_FUNC int emcore_gmime_check_filename_duplication(char *source_filename,
 
        while (cur_attachment_info) {
 
-               if(g_strcmp0(source_filename, cur_attachment_info->name) == 0) {
+               if (g_strcmp0(source_filename, cur_attachment_info->name) == 0) {
                        ret = TRUE;
                        break;
                }
index edce282..f0713a5 100755 (executable)
@@ -181,7 +181,7 @@ static int emcore_imap_idle_insert_sync_event(char *multi_user_name,
 
        event_data = em_malloc(sizeof(email_event_t));
        if (event_data == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -233,13 +233,13 @@ static int emcore_parse_imap_idle_response(char *multi_user_name,
 
        imap_local = input_mailstream->local;
 
-       if (!imap_local){
+       if (!imap_local) {
                EM_DEBUG_EXCEPTION("imap_local is NULL");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       while (imap_local->netstream){
+       while (imap_local->netstream) {
                p = net_getline(imap_local->netstream);
                if (p && !strncmp(p, "*", 1)) {
                        EM_DEBUG_LOG("p is [%s]", p);
@@ -248,25 +248,21 @@ static int emcore_parse_imap_idle_response(char *multi_user_name,
                                EM_SAFE_FREE(p);
                                err = EMAIL_ERROR_IMAP4_IDLE_FAILURE;
                                goto FINISH_OFF;
-                       }
-                       else  {
+                       } else {
                                if (strstr(p, "EXIST") != NULL) {
                                        if (!emcore_imap_idle_insert_sync_event(multi_user_name, input_account_id, input_mailbox_id, &err))
                                                EM_DEBUG_EXCEPTION_SEC("Syncing mailbox[%d] failed with err_code [%d]", input_mailbox_id, err);
-                               }
-                               else
+                               } else
                                        EM_DEBUG_LOG("Skipped this message");
                                EM_SAFE_FREE(p);
                                break;
                        }
-               }
-               else if (p && (!strncmp(p, "+", 1))) {
+               } else if (p && (!strncmp(p, "+", 1))) {
                        /* Bad response from server */
                        EM_DEBUG_LOG("p is [%s]", p);
                        EM_SAFE_FREE(p);
                        break;
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG("In else part");
                        break;
                }
@@ -330,11 +326,10 @@ static int emcore_connect_and_idle_on_mailbox(char *multi_user_name,
        net_stream = imap_local->netstream;
 
        /* check if ssl option is enabled on this account - shasikala.p */
-       if (input_account->incoming_server_secure_connection){
+       if (input_account->incoming_server_secure_connection) {
                SSLSTREAM *ssl_stream = net_stream->stream;
                tcp_stream = ssl_stream->tcpstream;
-       }
-       else
+       } else
                tcp_stream = net_stream->stream;
 
        /* Get Socket ID */
@@ -351,7 +346,7 @@ static int emcore_connect_and_idle_on_mailbox(char *multi_user_name,
        }
 
        /* Get the response for IDLE command */
-       while (imap_local->netstream){
+       while (imap_local->netstream) {
                p = net_getline(imap_local->netstream);
 
                EM_DEBUG_LOG("p =[%s]", p);
@@ -359,12 +354,10 @@ static int emcore_connect_and_idle_on_mailbox(char *multi_user_name,
                if (p && !strncmp(p, "+", 1)) {
                        EM_DEBUG_LOG("OK. Go.");
                        break;
-               }
-               else if (p && !strncmp(p, "*", 1)) {
+               } else if (p && !strncmp(p, "*", 1)) {
                        EM_SAFE_FREE(p);
                        continue;
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG("Unsuspected response.");
                        err = EMAIL_ERROR_IMAP4_IDLE_FAILURE;
                        break;
@@ -394,9 +387,8 @@ FINISH_OFF:
 //             *output_mailstream     = mail_stream;
                *output_socket_fd      = socket_fd;
                *input_connection_list = imap_idle_connection_list;
-       }
-       else if (mail_stream)
-               mail_stream = mail_close (mail_stream);
+       } else if (mail_stream)
+               mail_stream = mail_close(mail_stream);
 
        emcore_clear_session(session);
 
@@ -459,7 +451,7 @@ static int emcore_refresh_alarm_for_imap_idle(char *multi_user_name)
                                                                        0,
                                                                        emcore_imap_idle_cb,
                                                                        NULL)) != EMAIL_ERROR_NONE) {
-                       EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
+                       EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]", err);
                }
        }
 
@@ -578,7 +570,7 @@ void* emcore_imap_idle_worker(void* thread_user_data)
                                        }
                                }
 
-                               if(account_ref_list)
+                               if (account_ref_list)
                                        emcore_free_account_list(&account_ref_list, account_count, NULL);
 
                                EM_DEBUG_LOG(" Delete old an alarm and add an alarm to refresh connections every 29min");
@@ -644,7 +636,7 @@ void* emcore_imap_idle_worker(void* thread_user_data)
                                                }
                                        }
 
-                                       if(account_ref_list)
+                                       if (account_ref_list)
                                                emcore_free_account_list(&account_ref_list, account_count, NULL);
 
                                        EM_DEBUG_LOG(" Delete old an alarm and add an alarm to refresh connections every 29min");
@@ -665,7 +657,7 @@ void* emcore_imap_idle_worker(void* thread_user_data)
                event_num = epoll_wait(epoll_fd, events, MAX_EPOLL_EVENT, -1);
                EM_DEBUG_LOG("epoll_wait returns [%d]", event_num);
 
-               if (event_num > 0)  {
+               if (event_num > 0) {
                        EM_DEBUG_LOG(">>>> Data coming from socket or pipe ");
                        for (j = 0; j < event_num; j++) {
                                int event_fd = events[j].data.fd;
@@ -679,8 +671,7 @@ void* emcore_imap_idle_worker(void* thread_user_data)
                                                refresh_connection_flag = 1;
                                                continue;
                                        }
-                               }
-                               else {
+                               } else {
                                        if ((err = emcore_get_connection_info_by_socket_fd(imap_idle_connection_list,
                                                                                                                                                event_fd,
                                                                                                                                                &connection_info)) != EMAIL_ERROR_NONE) {
@@ -696,7 +687,7 @@ void* emcore_imap_idle_worker(void* thread_user_data)
                                                                                                                        connection_info->socket_fd)) != EMAIL_ERROR_NONE) {
                                                EM_DEBUG_EXCEPTION("emcore_parse_imap_idle_response failed. [%d] ", err);
                                                refresh_connection_flag = 1;
-//                                             mail_stream = mail_close (mail_stream);
+//                                             mail_stream = mail_close(mail_stream);
                                                continue;
                                        }
                                }
@@ -754,7 +745,7 @@ INTERNAL_FUNC int emcore_refresh_imap_idle_thread()
        int err = EMAIL_ERROR_NONE;
        int signal = 1;
 
-       write(imap_idle_pipe_fd[1], (char*) &signal, sizeof (signal));
+       write(imap_idle_pipe_fd[1], (char *)&signal, sizeof(signal));
 
        EM_DEBUG_FUNC_END("err [%d]", err);
        return err;
index 2dbe405..d7c6e95 100755 (executable)
@@ -53,7 +53,7 @@
 #include "email-debug-log.h"
 
 INTERNAL_FUNC int emcore_get_default_mail_slot_count(char *multi_user_name, int input_account_id, int *output_count)
-{      
+{
        EM_DEBUG_FUNC_BEGIN("input_account_id [%d] output_count[%p]", input_account_id, output_count);
 
        int err = EMAIL_ERROR_NONE;
@@ -84,8 +84,8 @@ FINISH_OFF:
 }
 
 
-INTERNAL_FUNC int emcore_remove_overflowed_mails(char *multi_user_name, 
-                                                                                                       emstorage_mailbox_tbl_t *input_mailbox_tbl, 
+INTERNAL_FUNC int emcore_remove_overflowed_mails(char *multi_user_name,
+                                                                                                       emstorage_mailbox_tbl_t *input_mailbox_tbl,
                                                                                                        int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("input_mailbox_tbl[%p], err_code[%p]", input_mailbox_tbl, err_code);
@@ -111,32 +111,31 @@ INTERNAL_FUNC int emcore_remove_overflowed_mails(char *multi_user_name,
                }
        }
 
-       if (!emstorage_get_overflowed_mail_id_list(multi_user_name, 
-                                                                                               input_mailbox_tbl->account_id, 
-                                                                                               input_mailbox_tbl->mailbox_id, 
-                                                                                               input_mailbox_tbl->mail_slot_size, 
-                                                                                               &mail_id_list, 
-                                                                                               &mail_id_list_count, 
-                                                                                               false, 
+       if (!emstorage_get_overflowed_mail_id_list(multi_user_name,
+                                                                                               input_mailbox_tbl->account_id,
+                                                                                               input_mailbox_tbl->mailbox_id,
+                                                                                               input_mailbox_tbl->mail_slot_size,
+                                                                                               &mail_id_list,
+                                                                                               &mail_id_list_count,
+                                                                                               false,
                                                                                                &err)) {
                if (err == EMAIL_ERROR_MAIL_NOT_FOUND) {
                        EM_DEBUG_LOG_SEC("There are enough slot in input_mailbox_tbl [%s]", input_mailbox_tbl->mailbox_name);
                        err = EMAIL_ERROR_NONE;
                        ret = true;
-               }
-               else
+               } else
                        EM_DEBUG_EXCEPTION("emstorage_get_overflowed_mail_id_list failed [%d]", err);
 
                goto FINISH_OFF;
        }
 
        if (mail_id_list) {
-               if (!emcore_delete_mails_from_local_storage(multi_user_name, 
+               if (!emcore_delete_mails_from_local_storage(multi_user_name,
                                                                                                        input_mailbox_tbl->account_id,
-                                                                                                       mail_id_list, 
-                                                                                                       mail_id_list_count, 
-                                                                                                       EMAIL_DELETE_LOCALLY, 
-                                                                                                       EMAIL_DELETED_BY_COMMAND, 
+                                                                                                       mail_id_list,
+                                                                                                       mail_id_list_count,
+                                                                                                       EMAIL_DELETE_LOCALLY,
+                                                                                                       EMAIL_DELETED_BY_COMMAND,
                                                                                                        &err)) {
                        EM_DEBUG_EXCEPTION("emcore_delete_mail failed [%d]", err);
                        goto FINISH_OFF;
@@ -180,26 +179,25 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(char *multi_user_name, int account_i
                        EM_DEBUG_LOG("ActiveSync account didn't support mail slot");
                        ret = true;
                        goto FINISH_OFF;
-               }
-               else if (!account_ref) {
+               } else if (!account_ref) {
                        EM_DEBUG_EXCEPTION("emcore_get_account_reference failed");
                        goto FINISH_OFF;
                }
+
                if (mailbox_id == 0) {
-                       if ( (err = emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
+                       if ((err = emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("emstorage_set_field_of_accounts_with_integer_value failed [%d]", err);
                                goto FINISH_OFF;
                        }
                }
-       }
-       else {
+       } else {
                if (mailbox_id == 0) {
-                       if ( !emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_list, false, false, &err)) {
+                       if (!emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_list, false, false, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
                                goto FINISH_OFF;
                        }
-                       for ( i = 0; i < account_count; i++) {
-                               if ( (err = emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_tbl_list[i].account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
+                       for (i = 0; i < account_count; i++) {
+                               if ((err = emstorage_set_field_of_accounts_with_integer_value(multi_user_name, account_tbl_list[i].account_id, "default_mail_slot_size", new_slot_size, true)) != EMAIL_ERROR_NONE) {
                                        EM_DEBUG_EXCEPTION("emstorage_set_field_of_accounts_with_integer_value failed [%d]", err);
                                        goto FINISH_OFF;
                                }
@@ -216,23 +214,21 @@ INTERNAL_FUNC int emcore_set_mail_slot_size(char *multi_user_name, int account_i
                mailbox_count = 1;
                if (new_slot_size > 0) {
                        mailbox_tbl_list = em_malloc(sizeof(emstorage_mailbox_tbl_t) * mailbox_count);
-                       if(!mailbox_tbl_list) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                       if (!mailbox_tbl_list) {
+                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                goto FINISH_OFF;
                        }
                        mailbox_tbl_list->account_id = account_id;
                        mailbox_tbl_list->mailbox_id = mailbox_id;
                        mailbox_tbl_list->mail_slot_size = new_slot_size;
-               }
-               else   {        /*  read information from DB */
+               } else {        /*  read information from DB */
                        if ((err = emstorage_get_mailbox_by_id(multi_user_name, mailbox_id, &mailbox_tbl_list)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
                                goto FINISH_OFF;
                        }
 
                }
-       }
-       else {
+       } else {
                if (!emstorage_get_mailbox_list(multi_user_name, account_id, EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
                        goto FINISH_OFF;
@@ -289,7 +285,7 @@ static int emcore_get_mailbox_connection_path(char *multi_user_name, int account
        *path = em_malloc(path_len);/* EM_SAFE_STRLEN(ref_account->incoming_server_address) + */
                                                                /* (mailbox_name ? EM_SAFE_STRLEN(mailbox_name) : 0) + 20); */
        if (!*path) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -337,11 +333,11 @@ FINISH_OFF:
        return 1;
 }
 
-static void emcore_find_mailbox_diff_between_local_and_remote (email_internal_mailbox_t *remote_box_list,
+static void emcore_find_mailbox_diff_between_local_and_remote(email_internal_mailbox_t *remote_box_list,
                                                int remote_box_count, emstorage_mailbox_tbl_t *local_box_list, int local_box_count,
                                                GList** remote_box_only, GList** local_box_only)
 {
-       if ( !remote_box_only || !local_box_only ) {
+       if (!remote_box_only || !local_box_only) {
                return ;
        }
        int i = 0;
@@ -350,43 +346,43 @@ static void emcore_find_mailbox_diff_between_local_and_remote (email_internal_ma
        GList *remote_p    = NULL;
        GList *local_p     = NULL;
 
-       EM_DEBUG_LOG ("remote_box_count[%d] local_box_count[%d]", remote_box_count, local_box_count);
+       EM_DEBUG_LOG("remote_box_count[%d] local_box_count[%d]", remote_box_count, local_box_count);
 
        if (local_box_count == 0) {
-               for (i=0 ; i<remote_box_count ; i++) {
-                       *remote_box_only = g_list_prepend (*remote_box_only, remote_box_list+i);
+               for (i = 0; i < remote_box_count; i++) {
+                       *remote_box_only = g_list_prepend(*remote_box_only, remote_box_list+i);
                        *local_box_only = NULL;
                }
                return;
        }
 
-       for (i=0; i<remote_box_count; i++)
-               remote_head = g_list_prepend (remote_head, remote_box_list+i);
+       for (i = 0; i < remote_box_count; i++)
+               remote_head = g_list_prepend(remote_head, remote_box_list+i);
 
-       for (i=0; i<local_box_count; i++)
-               local_head = g_list_prepend (local_head, local_box_list+i);
+       for (i = 0; i < local_box_count; i++)
+               local_head = g_list_prepend(local_head, local_box_list+i);
 
        int matched = false;
-       for (remote_p = remote_head; remote_p ; remote_p = g_list_next (remote_p)) {
+       for (remote_p = remote_head; remote_p; remote_p = g_list_next(remote_p)) {
                matched = false ; /* initialized not matched for each iteration */
-               email_internal_mailbox_t *remote_box = (email_internal_mailbox_t *) g_list_nth_data (remote_p, 0);
-               EM_DEBUG_LOG_DEV ("remote [%s]",  remote_box->mailbox_name );
+               email_internal_mailbox_t *remote_box = (email_internal_mailbox_t *)g_list_nth_data(remote_p, 0);
+               EM_DEBUG_LOG_DEV("remote [%s]",  remote_box->mailbox_name);
                /* find matching mailbox in local box */
                for (local_p = local_head; local_p ; local_p = g_list_next(local_p)) {
-                       emstorage_mailbox_tbl_t *local_box = (emstorage_mailbox_tbl_t *) g_list_nth_data (local_p, 0);
+                       emstorage_mailbox_tbl_t *local_box = (emstorage_mailbox_tbl_t *)g_list_nth_data(local_p, 0);
                        /* if match found */
-                       EM_DEBUG_LOG_DEV ("vs local [%s]", local_box->mailbox_name);
-                       if (!EM_SAFE_STRCMP (remote_box->mailbox_name, local_box->mailbox_name)) {
+                       EM_DEBUG_LOG_DEV("vs local [%s]", local_box->mailbox_name);
+                       if (!EM_SAFE_STRCMP(remote_box->mailbox_name, local_box->mailbox_name)) {
                                /* It is unnecessary to compare the matched box in the next iteration, so remove it from local_box*/
-                               local_head = g_list_delete_link (local_head, local_p);
+                               local_head = g_list_delete_link(local_head, local_p);
                                matched = true;
                                break;
                        }
                }
                /* if matching not found, add it to remote box */
                if (matched == false) {
-                       EM_DEBUG_LOG ("New box: name[%s] alias[%s]", remote_box->mailbox_name, remote_box->alias);
-                       *remote_box_only = g_list_prepend (*remote_box_only, remote_box);
+                       EM_DEBUG_LOG("New box: name[%s] alias[%s]", remote_box->mailbox_name, remote_box->alias);
+                       *remote_box_only = g_list_prepend(*remote_box_only, remote_box);
                }
        }
 
@@ -417,15 +413,15 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
        int   inbox_added = 0;
 
        if (!emcore_notify_network_event(NOTI_SYNC_IMAP_MAILBOX_LIST_START, account_id, 0, event_handle, 0))
-               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SYNC_IMAP_MAILBOX_LIST_START] Failed >>>> ");
+               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SYNC_IMAP_MAILBOX_LIST_START] Failed >>>> ");
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        if (!emnetwork_check_network_status(&err)) {
                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
                goto FINISH_OFF;
        }
-       
+
        ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
        if (!ref_account)  {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - %d", account_id);
@@ -434,7 +430,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
        }
 
        /* if not imap4 mail, return */
-       if ( ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
+       if (ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
                EM_DEBUG_EXCEPTION("unsupported account...");
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -448,14 +444,14 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
        }
 
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        stream = NULL;
-       if (!emcore_connect_to_remote_mailbox(multi_user_name, 
-                                                                                       account_id, 
-                                                                                       0, 
+       if (!emcore_connect_to_remote_mailbox(multi_user_name,
+                                                                                       account_id,
+                                                                                       0,
                                                                                        true,
-                                                                                       (void **)&tmp_stream, 
+                                                                                       (void **)&tmp_stream,
                                                                                        &err) || !tmp_stream)  {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed - %d", err);
 
@@ -470,7 +466,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
 
        stream = (MAILSTREAM *)tmp_stream;
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        /*  download mailbox list */
        if (!emcore_download_mailbox_list(stream, mailbox_name, &mailbox_list, &count, &err))  {
@@ -479,43 +475,41 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
        }
 
        /* get all mailboxes which is previously synced */
-       if (!emstorage_get_mailbox_list (multi_user_name, account_id, EMAIL_MAILBOX_FROM_SERVER, EMAIL_MAILBOX_SORT_BY_NAME_ASC,\
+       if (!emstorage_get_mailbox_list(multi_user_name, account_id, EMAIL_MAILBOX_FROM_SERVER, EMAIL_MAILBOX_SORT_BY_NAME_ASC,\
                                                         &local_mailbox_count, &local_mailbox_list, 1, &err)) {
                if (err != EMAIL_ERROR_MAILBOX_NOT_FOUND) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_list error [%d]", err);
-               }
-               else
-                       EM_DEBUG_LOG ("mailbox not found");
+               } else
+                       EM_DEBUG_LOG("mailbox not found");
        }
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
-       emcore_find_mailbox_diff_between_local_and_remote (mailbox_list, count, local_mailbox_list, local_mailbox_count,
+       emcore_find_mailbox_diff_between_local_and_remote(mailbox_list, count, local_mailbox_list, local_mailbox_count,
                                                                                        &remote_box_only, &local_box_only);
 
        /* for remote_box_only, add new mailbox to DB */
        GList *p = remote_box_only;
-       for (; p; p = g_list_next (p)) {
-               email_internal_mailbox_t *new_mailbox = (email_internal_mailbox_t *) g_list_nth_data (p, 0);
+       for (; p; p = g_list_next(p)) {
+               email_internal_mailbox_t *new_mailbox = (email_internal_mailbox_t *)g_list_nth_data(p, 0);
 
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                if (!new_mailbox->mailbox_name) {
                        continue;
                }
 
-               /* EM_DEBUG_LOG_SEC ("mailbox name [%s]", new_mailbox->mailbox_name); */
+               /* EM_DEBUG_LOG_SEC("mailbox name [%s]", new_mailbox->mailbox_name); */
                new_mailbox->mail_slot_size = ref_account->default_mail_slot_size;
 
                if (new_mailbox->mailbox_type == EMAIL_MAILBOX_TYPE_NONE)
-                       emcore_bind_mailbox_type (new_mailbox);
+                       emcore_bind_mailbox_type(new_mailbox);
 
                if (new_mailbox->mailbox_type <= EMAIL_MAILBOX_TYPE_ALL_EMAILS) {       /* if result mailbox type is duplicated,  */
                        if (mailbox_type_list[new_mailbox->mailbox_type] != -1) {
-                               EM_DEBUG_LOG_SEC ("Mailbox type [%d] of [%s] is duplicated", new_mailbox->mailbox_type, new_mailbox->mailbox_name);
+                               EM_DEBUG_LOG_SEC("Mailbox type [%d] of [%s] is duplicated", new_mailbox->mailbox_type, new_mailbox->mailbox_name);
                                new_mailbox->mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED; /* ignore latest one  */
-                       }
-                       else
+                       } else
                                mailbox_type_list[new_mailbox->mailbox_type] = 1;
                }
 
@@ -532,37 +526,37 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
 
                /* Get the Alias Name after Parsing the Full mailbox Path */
                if (new_mailbox->alias == NULL)
-                       new_mailbox->alias = emcore_get_alias_of_mailbox ((const char *)new_mailbox->mailbox_name);
+                       new_mailbox->alias = emcore_get_alias_of_mailbox((const char *)new_mailbox->mailbox_name);
 
                if (new_mailbox->alias) {
                        mailbox_tbl.alias = new_mailbox->alias;
                        mailbox_tbl.modifiable_yn = 1;
                        mailbox_tbl.total_mail_count_on_server = 0;
 
-                       if (!emstorage_add_mailbox (multi_user_name, &mailbox_tbl, true, &err)) {
-                               EM_DEBUG_EXCEPTION ("emstorage_add_mailbox error [%d]", err);
+                       if (!emstorage_add_mailbox(multi_user_name, &mailbox_tbl, true, &err)) {
+                               EM_DEBUG_EXCEPTION("emstorage_add_mailbox error [%d]", err);
                                goto FINISH_OFF;
                        }
 
                        if (mailbox_tbl.mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)
                                inbox_added = 1;
-                       EM_DEBUG_LOG_SEC ("MAILBOX ADDED: mailbox_name [%s] alias [%s] mailbox_type [%d]", new_mailbox->mailbox_name,\
+                       EM_DEBUG_LOG_SEC("MAILBOX ADDED: mailbox_name [%s] alias [%s] mailbox_type [%d]", new_mailbox->mailbox_name,\
                                                                new_mailbox->alias, mailbox_tbl.mailbox_type);
                }
        }
 
        /* delete all local boxes and mails */
        p = local_box_only;
-       for (; p; p = g_list_next (p)) {
-               emstorage_mailbox_tbl_t *del_box = (emstorage_mailbox_tbl_t *) g_list_nth_data (p, 0);
+       for (; p; p = g_list_next(p)) {
+               emstorage_mailbox_tbl_t *del_box = (emstorage_mailbox_tbl_t *)g_list_nth_data(p, 0);
 
-               if (!emstorage_delete_mail_by_mailbox (multi_user_name, del_box, 1, &err)) {
-                       EM_DEBUG_EXCEPTION ("emstorage_delete_mail_by_mailbox error [%d] account_id [%d] mailbox_name [%s]",\
+               if (!emstorage_delete_mail_by_mailbox(multi_user_name, del_box, 1, &err)) {
+                       EM_DEBUG_EXCEPTION("emstorage_delete_mail_by_mailbox error [%d] account_id [%d] mailbox_name [%s]",\
                                                        err, del_box->account_id, del_box->mailbox_name);
                }
 
-               if (!emstorage_delete_mailbox (multi_user_name, del_box->account_id, EMAIL_MAILBOX_FROM_SERVER, del_box->mailbox_id, 1, &err)) {
-                       EM_DEBUG_EXCEPTION ("emstorage_delete_mailbox error [%d] account_id [%d] mailbox_name [%s]",\
+               if (!emstorage_delete_mailbox(multi_user_name, del_box->account_id, EMAIL_MAILBOX_FROM_SERVER, del_box->mailbox_id, 1, &err)) {
+                       EM_DEBUG_EXCEPTION("emstorage_delete_mailbox error [%d] account_id [%d] mailbox_name [%s]",\
                                                        err, del_box->account_id, del_box->mailbox_name);
                }
 
@@ -571,7 +565,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
                        EM_DEBUG_EXCEPTION("emstorage_delete_auto_download_activity_by_mailbox failed");
 #endif
 
-               EM_DEBUG_LOG_SEC ("MAILBOX REMOVED: mailbox_name[%s] mailbox_id[%d]", del_box->mailbox_name, del_box->mailbox_id);
+               EM_DEBUG_LOG_SEC("MAILBOX REMOVED: mailbox_name[%s] mailbox_id[%d]", del_box->mailbox_name, del_box->mailbox_id);
        }
 
        for (counter = EMAIL_MAILBOX_TYPE_INBOX; counter <= EMAIL_MAILBOX_TYPE_OUTBOX; counter++) {
@@ -580,8 +574,8 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
                        emstorage_mailbox_tbl_t mailbox_tbl;
                        emstorage_mailbox_tbl_t *result_mailbox_tbl = NULL;
 
-                       if(emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, counter, &result_mailbox_tbl, true, &err2)) {
-                               if(result_mailbox_tbl) {
+                       if (emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, counter, &result_mailbox_tbl, true, &err2)) {
+                               if (result_mailbox_tbl) {
                                        emstorage_free_mailbox(&result_mailbox_tbl, 1, NULL);
                                        continue;
                                }
@@ -646,7 +640,7 @@ INTERNAL_FUNC int emcore_sync_mailbox_list(char *multi_user_name, int account_id
        if (inbox_added)
                emcore_refresh_imap_idle_thread();
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        for (i = 0; i < count; i++)
                mailbox_list[i].account_id = account_id;
@@ -657,11 +651,10 @@ FINISH_OFF:
 
        if (err == EMAIL_ERROR_NONE) {
                if (!emcore_notify_network_event(NOTI_SYNC_IMAP_MAILBOX_LIST_FINISH, account_id, 0, event_handle, err))
-                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SYNC_IMAP_MAILBOX_LIST_FINISH] Failed >>>> ");
-       }
-       else {
+                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SYNC_IMAP_MAILBOX_LIST_FINISH] Failed >>>> ");
+       } else {
                if (!emcore_notify_network_event(NOTI_SYNC_IMAP_MAILBOX_LIST_FAIL, account_id, 0, event_handle, err))
-                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_SYNC_IMAP_MAILBOX_LIST_FAIL] Failed >>>> ");
+                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_SYNC_IMAP_MAILBOX_LIST_FAIL] Failed >>>> ");
        }
        EM_SAFE_FREE(mailbox_name_for_mailbox_type);
        EM_SAFE_FREE(mbox_path);
@@ -672,19 +665,19 @@ FINISH_OFF:
        }
 
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
        if (mailbox_list)
-               emcore_free_internal_mailbox (&mailbox_list, count, NULL);
+               emcore_free_internal_mailbox(&mailbox_list, count, NULL);
 
        if (local_mailbox_list)
-               emstorage_free_mailbox (&local_mailbox_list, local_mailbox_count, NULL);
+               emstorage_free_mailbox(&local_mailbox_list, local_mailbox_count, NULL);
 
        if (local_box_only)
-               g_list_free (local_box_only);
+               g_list_free(local_box_only);
 
        if (remote_box_only)
-               g_list_free (remote_box_only);
+               g_list_free(remote_box_only);
 
        if (err_code != NULL)
                *err_code = err;
@@ -724,8 +717,7 @@ int emcore_download_mailbox_list(void *mail_stream,
                                *(++s) = '\0';
                        strcat(reference, mailbox_name);
                }
-       }
-       else
+       } else
                reference = EM_SAFE_STRDUP(stream->original_mailbox);
 
        pattern        = "*";
@@ -733,7 +725,7 @@ int emcore_download_mailbox_list(void *mail_stream,
 
        /*  imap command : tag LIST reference * */
        /*  see callback function mm_list */
-       mail_list (stream, reference, pattern);
+       mail_list(stream, reference, pattern);
 
        stream->sparep = NULL;
 
@@ -780,11 +772,11 @@ INTERNAL_FUNC int emcore_create_imap_mailbox(char *multi_user_name, email_mailbo
 
        /* connect mail server */
        stream = NULL;
-       if (!emcore_connect_to_remote_mailbox(multi_user_name, 
-                                                                                       mailbox->account_id, 
-                                                                                       0, 
+       if (!emcore_connect_to_remote_mailbox(multi_user_name,
+                                                                                       mailbox->account_id,
+                                                                                       0,
                                                                                        true,
-                                                                                       (void **)&tmp_stream, 
+                                                                                       (void **)&tmp_stream,
                                                                                        &err)) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                goto FINISH_OFF;
@@ -822,17 +814,16 @@ INTERNAL_FUNC int emcore_create_imap_mailbox(char *multi_user_name, email_mailbo
 
 FINISH_OFF:
        if (stream) {
-               stream = mail_close (stream);
+               stream = mail_close(stream);
        }
 
        EM_SAFE_FREE(long_enc_path);
 
        if (mailbox) {
                if (err == EMAIL_ERROR_NONE) {
-                       if (!emcore_notify_network_event (NOTI_ADD_MAILBOX_FINISH, mailbox->account_id, mailbox->mailbox_name, 0, 0))
+                       if (!emcore_notify_network_event(NOTI_ADD_MAILBOX_FINISH, mailbox->account_id, mailbox->mailbox_name, 0, 0))
                                EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_ADD_MAILBOX_FINISH] failed");
-               }
-               else if (!emcore_notify_network_event (NOTI_ADD_MAILBOX_FAIL, mailbox->account_id, mailbox->mailbox_name, 0, err))
+               } else if (!emcore_notify_network_event(NOTI_ADD_MAILBOX_FAIL, mailbox->account_id, mailbox->mailbox_name, 0, err))
                        EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_ADD_MAILBOX_FAIL] failed");
        }
 
@@ -865,7 +856,7 @@ INTERNAL_FUNC int emcore_delete_imap_mailbox(char *multi_user_name, int input_ma
        int err = EMAIL_ERROR_NONE;
        emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
 
-       if(!emcore_notify_network_event(NOTI_DELETE_MAILBOX_START, input_mailbox_id, 0, 0, 0))
+       if (!emcore_notify_network_event(NOTI_DELETE_MAILBOX_START, input_mailbox_id, 0, 0, 0))
                EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_DELETE_MAILBOX_START] failed");
 
        if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
@@ -881,11 +872,11 @@ INTERNAL_FUNC int emcore_delete_imap_mailbox(char *multi_user_name, int input_ma
        }
 
        /* connect mail server */
-       if (!emcore_connect_to_remote_mailbox(multi_user_name, 
-                                                                                       mailbox_tbl->account_id, 
-                                                                                       0, 
+       if (!emcore_connect_to_remote_mailbox(multi_user_name,
+                                                                                       mailbox_tbl->account_id,
+                                                                                       0,
                                                                                        true,
-                                                                                       (void **)&tmp_stream, 
+                                                                                       (void **)&tmp_stream,
                                                                                        &err)) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                goto FINISH_OFF;
@@ -912,7 +903,7 @@ INTERNAL_FUNC int emcore_delete_imap_mailbox(char *multi_user_name, int input_ma
 
 FINISH_OFF:
        if (stream) {
-               stream = mail_close (stream);
+               stream = mail_close(stream);
        }
 
        if (ref_account) {
@@ -926,10 +917,9 @@ FINISH_OFF:
                emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
 
        if (err == EMAIL_ERROR_NONE) {
-               if(!emcore_notify_network_event(NOTI_DELETE_MAILBOX_FINISH, input_mailbox_id, 0, 0, 0))
+               if (!emcore_notify_network_event(NOTI_DELETE_MAILBOX_FINISH, input_mailbox_id, 0, 0, 0))
                        EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_ADD_MAILBOX_FINISH] failed");
-       }
-       else if (!emcore_notify_network_event(NOTI_DELETE_MAILBOX_FAIL, input_mailbox_id, 0, 0, err))
+       } else if (!emcore_notify_network_event(NOTI_DELETE_MAILBOX_FAIL, input_mailbox_id, 0, 0, err))
                EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_ADD_MAILBOX_FAIL] failed");
 
        if (err_code)
@@ -964,11 +954,11 @@ INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(char *multi_user_name, in
 
        /* connect mail server */
        stream = NULL;
-       if (!emcore_connect_to_remote_mailbox(multi_user_name, 
-                                                                                       input_account_id, 
-                                                                                       0, 
+       if (!emcore_connect_to_remote_mailbox(multi_user_name,
+                                                                                       input_account_id,
+                                                                                       0,
                                                                                        true,
-                                                                                       (void **)&tmp_stream, 
+                                                                                       (void **)&tmp_stream,
                                                                                        &err)) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed. [%d]", err);
                goto FINISH_OFF;
@@ -996,11 +986,10 @@ INTERNAL_FUNC int emcore_rename_mailbox_on_imap_server(char *multi_user_name, in
 
 FINISH_OFF:
 
-       if (err  == EMAIL_ERROR_NONE) {
-               if(!emcore_notify_network_event(NOTI_RENAME_MAILBOX_FINISH, input_mailbox_id, input_new_mailbox_path, handle_to_be_published, 0))
+       if (err == EMAIL_ERROR_NONE) {
+               if (!emcore_notify_network_event(NOTI_RENAME_MAILBOX_FINISH, input_mailbox_id, input_new_mailbox_path, handle_to_be_published, 0))
                        EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_RENAME_MAILBOX_FINISH] failed");
-       }
-       else {
+       } else {
                if (!emcore_notify_network_event(NOTI_RENAME_MAILBOX_FAIL, input_mailbox_id, input_new_mailbox_path, handle_to_be_published, 0))
                        EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_RENAME_MAILBOX_FAIL] failed");
        }
@@ -1013,7 +1002,7 @@ FINISH_OFF:
        }
 
        if (stream) {
-               stream = mail_close (stream);
+               stream = mail_close(stream);
        }
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -1073,11 +1062,11 @@ INTERNAL_FUNC int emcore_get_quota_root(int input_mailbox_id, email_quota_resour
        }
 
        /* connect mail server */
-       if (!emcore_connect_to_remote_mailbox(multi_user_name, 
-                                                                                       mailbox_tbl->account_id, 
-                                                                                       0, 
+       if (!emcore_connect_to_remote_mailbox(multi_user_name,
+                                                                                       mailbox_tbl->account_id,
+                                                                                       0,
                                                                                        true,
-                                                                                       (void **)&stream, 
+                                                                                       (void **)&stream,
                                                                                        &err)) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                goto FINISH_OFF;
@@ -1113,11 +1102,11 @@ INTERNAL_FUNC int emcore_get_quota(int input_mailbox_id, char *input_quota_root,
        }
 
        /* connect mail server */
-       if (!emcore_connect_to_remote_mailbox(multi_user_name, 
-                                                                                       mailbox_tbl->account_id, 
-                                                                                       0, 
+       if (!emcore_connect_to_remote_mailbox(multi_user_name,
+                                                                                       mailbox_tbl->account_id,
+                                                                                       0,
                                                                                        true,
-                                                                                       (void **)&stream, 
+                                                                                       (void **)&stream,
                                                                                        &err)) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                goto FINISH_OFF;
index 183a6ba..d79e19e 100644 (file)
@@ -65,7 +65,7 @@ INTERNAL_FUNC int emcore_add_password_in_key_manager(char *data_name, char *stor
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
        }
-       
+
 //     alias = add_shared_owner_prefix(data_name);
        alias = g_strdup(data_name);
        EM_DEBUG_LOG("alias : [%s]", alias);
@@ -108,7 +108,7 @@ INTERNAL_FUNC int emcore_get_password_in_key_manager(char *data_name, char **sto
                return err;
        }
 
-//     alias = add_shared_owner_prefix(data_name); 
+//     alias = add_shared_owner_prefix(data_name);
        alias = g_strdup(data_name);
        EM_DEBUG_LOG("alias : [%s]", alias);
 
@@ -119,8 +119,8 @@ INTERNAL_FUNC int emcore_get_password_in_key_manager(char *data_name, char **sto
                goto FINISH_OFF;
        }
 
-//     EM_DEBUG_LOG("stored_data : [%s]", email_data->data);
-//     EM_DEBUG_LOG("stored_data length : [%d]", email_data->size);
+       EM_DEBUG_LOG_DEV("stored_data : [%s]", email_data->data);
+       EM_DEBUG_LOG_DEV("stored_data length : [%d]", email_data->size);
 
 FINISH_OFF:
 
@@ -151,7 +151,7 @@ INTERNAL_FUNC int emcore_remove_password_in_key_manager(char *data_name)
                return err;
        }
 
-//     alias = add_shared_owner_prefix(data_name);  
+//     alias = add_shared_owner_prefix(data_name);
        alias = g_strdup(data_name);
        EM_DEBUG_LOG("alias : [%s]", alias);
 
@@ -169,8 +169,8 @@ FINISH_OFF:
        return err;
 }
 
-INTERNAL_FUNC int emcore_get_certificate_in_key_manager(char *alias, char *password, 
-                                                                                                               const unsigned char **cert_data, 
+INTERNAL_FUNC int emcore_get_certificate_in_key_manager(char *alias, char *password,
+                                                                                                               const unsigned char **cert_data,
                                                                                                                int *cert_size)
 {
        EM_DEBUG_FUNC_BEGIN();
@@ -199,7 +199,7 @@ INTERNAL_FUNC int emcore_get_certificate_in_key_manager(char *alias, char *passw
 
        p_cert_data = em_malloc(output_cert->cert_size + 1);
        if (p_cert_data == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
index fa270b7..4c1d906 100755 (executable)
@@ -96,7 +96,7 @@ int _imap4_download_noti_interval_value = 0;
 static int emcore_delete_mails_from_pop3_server(char *multi_user_name, email_account_t *input_account, int input_mail_ids[], int input_mail_id_count);
 static int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, int *downloded_size, int *total_body_size, int *err_code);
 
-extern long pop3_send (MAILSTREAM *stream, char *command, char *args);
+extern long pop3_send(MAILSTREAM *stream, char *command, char *args);
 
 
 #ifdef FEATURE_CORE_DEBUG
@@ -191,10 +191,10 @@ void _print_body(BODY *body, int recursive)
                EM_DEBUG_LOG("body->md5[%s]", body->md5);
                EM_DEBUG_LOG("body->sparep[%p]", body->sparep);
 
-               if (recursive)  {
+               if (recursive) {
                        PART *part = body->nested.part;
 
-                       while (part != NULL)  {
+                       while (part != NULL) {
                                _print_body(&(part->body), recursive);
                                part = part->next;
                        }
@@ -216,7 +216,7 @@ static int pop3_mail_delete(MAILSTREAM *stream, int msgno, int *err_code)
        char cmd[64];
        char *p = NULL;
 
-       if (!stream)  {
+       if (!stream) {
                EM_DEBUG_EXCEPTION("stream[%p]", stream);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -333,13 +333,13 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l
        EM_DEBUG_LOG("Count of mails copied [%d]", count);
        old_server_uid = em_malloc(count * sizeof(unsigned long));
        if (old_server_uid == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed : EMAIL_ERROR_OUT_OF_MEMORY");
+               EM_DEBUG_EXCEPTION("em_mallocfailed : EMAIL_ERROR_OUT_OF_MEMORY");
                return;
        }
 
        new_server_uid = em_malloc(count * sizeof(unsigned long));
        if (new_server_uid == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed : EMAIL_ERROR_OUT_OF_MEMORY");
+               EM_DEBUG_EXCEPTION("em_mallocfailed : EMAIL_ERROR_OUT_OF_MEMORY");
                EM_SAFE_FREE(old_server_uid);
                return;
        }
@@ -395,7 +395,7 @@ static void emcore_mail_copyuid_ex(MAILSTREAM *stream, char *mailbox, unsigned l
        }
 
 #ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
-       if (!emstorage_get_mailbox_by_name(g_multi_user_name, g_copyuid_account_id, -1, mailbox, &mailbox_tbl, false, &err))  {
+       if (!emstorage_get_mailbox_by_name(g_multi_user_name, g_copyuid_account_id, -1, mailbox, &mailbox_tbl, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d", err);
        }
 #endif
@@ -516,12 +516,12 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(char *multi_user_name,
                /*  Here about 90 bytes are required for fixed keywords in the query-> SELECT local_uid, server_uid from mail_read_mail_uid_tbl where local_uid in (....) ORDER by server_uid  */
                /*  So length of comma separated strings which will be filled in (.....) in above query can be maximum QUERY_SIZE - 90  */
 
-               if (false == emcore_form_comma_separated_strings(mail_ids, num, QUERY_SIZE - 90, &string_list, &string_count, &err_code))   {
+               if (false == emcore_form_comma_separated_strings(mail_ids, num, QUERY_SIZE - 90, &string_list, &string_count, &err_code))  {
                        EM_DEBUG_EXCEPTION("emcore_form_comma_separated_strings failed [%d]", err_code);
                        goto FINISH_OFF;
                }
 
-               if ( (err_code = emstorage_get_mailbox_by_id(multi_user_name, dest_mailbox_id, &dest_mailbox)) != EMAIL_ERROR_NONE || !dest_mailbox) {
+               if ((err_code = emstorage_get_mailbox_by_id(multi_user_name, dest_mailbox_id, &dest_mailbox)) != EMAIL_ERROR_NONE || !dest_mailbox) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err_code);
                        goto FINISH_OFF;
                }
@@ -554,13 +554,11 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(char *multi_user_name,
                                        EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_ex :   Mail cannot be moved failed");
                                        EM_DEBUG_EXCEPTION("Mail MOVE failed ");
                                        goto FINISH_OFF;
-                               }
-                               else if (!mail_expunge_full(stream, uid_range_node->uid_range, EX_UID)) {
+                               } else if (!mail_expunge_full(stream, uid_range_node->uid_range, EX_UID)) {
                                        EM_DEBUG_EXCEPTION("emcore_move_mail_on_server_ex :   Mail cannot be expunged after move. failed!");
                                                EM_DEBUG_EXCEPTION("Mail Expunge after move failed ");
                                                  goto FINISH_OFF;
-                               }
-                               else {
+                               } else {
                                        EM_DEBUG_LOG("Mail MOVE SUCCESS ");
                                }
 
@@ -574,8 +572,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(char *multi_user_name,
                        id_set_count = 0;
                }
 
-       }
-       else {
+       } else {
                EM_DEBUG_EXCEPTION(">>>> STREAM DATA IS NULL >>> ");
                goto FINISH_OFF;
        }
@@ -586,7 +583,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_ex(char *multi_user_name,
 FINISH_OFF:
        emcore_free_comma_separated_strings(&string_list, &string_count); /*prevent 17958*/
 
-       stream = mail_close (stream);
+       stream = mail_close(stream);
 
        if (ref_account) {
                emcore_free_account(ref_account);
@@ -596,7 +593,7 @@ FINISH_OFF:
 #ifdef __FEATURE_LOCAL_ACTIVITY__
        if (ret || ref_account->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) /* Delete local activity for POP3 mails and successful move operation in IMAP */ {
                emstorage_activity_tbl_t new_activity;
-               for (i = 0; i<num ; i++) {
+               for (i = 0; i < num; i++) {
                        memset(&new_activity, 0x00, sizeof(emstorage_activity_tbl_t));
                        new_activity.activity_type = ACTIVITY_MOVEMAIL;
                        new_activity.account_id    = account_id;
@@ -712,7 +709,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
                        /*  Remove comma from end of uid_range  */
                        uid_range_node->uid_range[EM_SAFE_STRLEN(uid_range_node->uid_range) - 1] = '\0';
 
-                       if (!(imaplocal = stream->local) || !imaplocal->netstream)  {
+                       if (!(imaplocal = stream->local) || !imaplocal->netstream) {
                                EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected...");
 
                                err = EMAIL_ERROR_CONNECTION_BROKEN;
@@ -729,7 +726,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
 
 
                        /* send command  :  set deleted flag */
-                       if (!net_sout(imaplocal->netstream, cmd, (int)EM_SAFE_STRLEN(cmd)))  {
+                       if (!net_sout(imaplocal->netstream, cmd, (int)EM_SAFE_STRLEN(cmd))) {
                                EM_DEBUG_EXCEPTION("net_sout failed...");
 
                                err = EMAIL_ERROR_CONNECTION_BROKEN;            /* EMAIL_ERROR_UNKNOWN */
@@ -737,7 +734,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
                        }
 
 
-                       while (imaplocal->netstream)  {
+                       while (imaplocal->netstream) {
                                /* receive response */
                                if (!(p = net_getline(imaplocal->netstream))) {
                                        EM_DEBUG_EXCEPTION("net_getline failed...");
@@ -751,7 +748,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
 
                                /* To confirm - Commented out as FETCH response does not contain the tag - may be a problem for common stream in email-service*/
                                /* Success case - delete all local activity and entry from mail_read_mail_uid_tbl
-                               if (strstr(p, "FETCH") != NULL)  {
+                               if (strstr(p, "FETCH") != NULL) {
                                        EM_DEBUG_LOG(" FETCH Response recieved ");
                                        delete_success = true;
                                        EM_SAFE_FREE(p);
@@ -760,14 +757,13 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
                                */
 
 
-                               if (!strncmp(p, tag, EM_SAFE_STRLEN(tag)))  {
-                                       if (!strncmp(p + EM_SAFE_STRLEN(tag) + 1, "OK", 2))  {
+                               if (!strncmp(p, tag, EM_SAFE_STRLEN(tag))) {
+                                       if (!strncmp(p + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
                                                /*Error scenario delete all local activity and entry from mail_read_mail_uid_tbl */
                                                EM_DEBUG_LOG(" OK Response recieved ");
                                                EM_SAFE_FREE(p);
                                                break;
-                                       }
-                                       else  {
+                                       } else {
                                                /*  'NO' or 'BAD' */
                                                err = EMAIL_ERROR_IMAP4_STORE_FAILURE;          /* EMAIL_ERROR_INVALID_RESPONSE; */
                                                goto FINISH_OFF;
@@ -788,14 +784,14 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
                                EM_DEBUG_LOG("[IMAP4] >>> %s", cmd);
 
                                /* send command  :   EXPUNGE */
-                               if (!net_sout(imaplocal->netstream, cmd, (int)EM_SAFE_STRLEN(cmd)))  {
+                               if (!net_sout(imaplocal->netstream, cmd, (int)EM_SAFE_STRLEN(cmd))) {
                                        EM_DEBUG_EXCEPTION("net_sout failed...");
 
                                        err = EMAIL_ERROR_CONNECTION_BROKEN;
                                        goto FINISH_OFF;
                                }
 
-                               while (imaplocal->netstream)  {
+                               while (imaplocal->netstream) {
                                        /* receive response */
                                        if (!(p = net_getline(imaplocal->netstream))) {
                                                EM_DEBUG_EXCEPTION("net_getline failed...");
@@ -806,25 +802,25 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
 
                                        EM_DEBUG_LOG("[IMAP4] <<< %s", p);
 
-                                       if (!strncmp(p, tag, EM_SAFE_STRLEN(tag)))  {
-                                               if (!strncmp(p + EM_SAFE_STRLEN(tag) + 1, "OK", 2))  {
+                                       if (!strncmp(p, tag, EM_SAFE_STRLEN(tag))) {
+                                               if (!strncmp(p + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
 #ifdef __FEATURE_LOCAL_ACTIVITY__
                                                        int index = 0;
                                                        emstorage_mail_tbl_t **mail = NULL;
 
                                                        mail = (emstorage_mail_tbl_t **) em_malloc(num * sizeof(emstorage_mail_tbl_t *));
                                                        if (!mail) {
-                                                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                                                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                                                err = EMAIL_ERROR_UNKNOWN;
                                                                goto FINISH_OFF;
                                                        }
 
                                                        if (delete_success) {
                                                                for (index = 0 ; index < num; index++) {
-                                                                       if (!emstorage_get_downloaded_mail(multi_user_name, mail_ids[index], &mail[index], false, &err))  {
+                                                                       if (!emstorage_get_downloaded_mail(multi_user_name, mail_ids[index], &mail[index], false, &err)) {
                                                                                EM_DEBUG_LOG("emstorage_get_uid_by_mail_id failed [%d]", err);
 
-                                                                               if (err == EMAIL_ERROR_MAIL_NOT_FOUND)  {
+                                                                               if (err == EMAIL_ERROR_MAIL_NOT_FOUND) {
                                                                                        EM_DEBUG_LOG("EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER  : ");
                                                                                        continue;
                                                                                }
@@ -839,7 +835,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
                                                                                                                                                                        mail[index]->mailbox_name,
                                                                                                                                                                        mail[index]->server_mail_id,
                                                                                                                                                                        true,
-                                                                                                                                                                       &err))  {
+                                                                                                                                                                       &err)) {
                                                                                                EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
                                                                                        }
                                                                                }
@@ -850,8 +846,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
                                                                                if (from_server == EMAIL_DELETE_FOR_SEND_THREAD) {
                                                                                        new_activity.activity_type = ACTIVITY_DELETEMAIL_SEND;
                                                                                        EM_DEBUG_LOG("from_server == EMAIL_DELETE_FOR_SEND_THREAD ");
-                                                                               }
-                                                                               else {
+                                                                               } else {
                                                                                        new_activity.activity_type      = ACTIVITY_DELETEMAIL;
                                                                                }
 
@@ -863,8 +858,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
                                                                                if (!emcore_delete_activity(&new_activity, &err)) {
                                                                                        EM_DEBUG_EXCEPTION(" emcore_delete_activity  failed  - %d ", err);
                                                                                }
-                                                                       }
-                                                                       else {
+                                                                       } else {
                                                                                /* Fix for crash seen while deleting Outbox mails which are moved to Trash. Outbox mails do not have server mail id and are not updated in mail_read_mail_uid_tbl.
                                                                                  * So there is no need of deleting entry in mail_read_mail_uid_tbl. However local activity has to be deleted.
                                                                                */
@@ -895,8 +889,7 @@ int emcore_delete_mails_from_imap4_server(char *multi_user_name,
 #endif
        EM_SAFE_FREE(p);
                                                        break;
-                                               }
-                                               else  {         /*  'NO' or 'BAD' */
+                                               } else {                /*  'NO' or 'BAD' */
                                                        err = EMAIL_ERROR_IMAP4_EXPUNGE_FAILURE;                /* EMAIL_ERROR_INVALID_RESPONSE; */
                                                        goto FINISH_OFF;
                                                }
@@ -922,7 +915,7 @@ FINISH_OFF:
        EM_SAFE_FREE(id_set); /*prevent 17954*/
 
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
        emcore_free_comma_separated_strings(&string_list, &string_count);
 
@@ -965,8 +958,7 @@ INTERNAL_FUNC int emcore_imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_
 
        if (cmd_type == IMAP4_CMD_EXPUNGE) {
                SNPRINTF(cmd, sizeof(cmd), "%s EXPUNGE\015\012", tag);
-       }
-       else if (cmd_type == IMAP4_CMD_NOOP) {
+       } else if (cmd_type == IMAP4_CMD_NOOP) {
                SNPRINTF(cmd, sizeof(cmd), "%s NOOP\015\012", tag);
        }
 
@@ -998,12 +990,10 @@ INTERNAL_FUNC int emcore_imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_
                        if (!strncmp(p + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
                                EM_SAFE_FREE(p);
                                break;
-                       }
-                       else {          /*  'NO' or 'BAD' */
+                       } else {                /*  'NO' or 'BAD' */
                                if (cmd_type == IMAP4_CMD_EXPUNGE) {
                                        err = EMAIL_ERROR_IMAP4_EXPUNGE_FAILURE;                /* EMAIL_ERROR_INVALID_RESPONSE; */
-                               }
-                               else if (cmd_type == IMAP4_CMD_NOOP) {
+                               } else if (cmd_type == IMAP4_CMD_NOOP) {
                                        err = EMAIL_ERROR_IMAP4_NOOP_FAILURE;
                                }
                                goto FINISH_OFF;
@@ -1119,7 +1109,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
        int contact_name_buffer_size = 0;
        char *contact_name = NULL;
 
-       if (!contact_info)  {
+       if (!contact_info) {
                EM_DEBUG_EXCEPTION("contact_info[%p]", contact_info);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -1129,8 +1119,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                full_address = "";
                address_length = 0;
                temp_emailaddr = NULL;
-       }
-       else {
+       } else {
                address_length = 2 * EM_SAFE_STRLEN(full_address);
                temp_emailaddr = (char  *)calloc(1, address_length);
        }
@@ -1146,8 +1135,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
        g_strfreev(tokens);
 
        /*  ';' -> ',' */
-       while (p && p[i] != '\0')
-       {
+       while (p && p[i] != '\0') {
                if (p[i] == ';')
                        p[i] = ',';
                i++;
@@ -1174,16 +1162,16 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                goto FINISH_OFF;
        }
 
-       while (addr != NULL)  {
+       while (addr != NULL) {
                if (addr->mailbox && addr->host) {
-                       if (!strncmp(addr->mailbox , "UNEXPECTED_DATA_AFTER_ADDRESS", strlen("UNEXPECTED_DATA_AFTER_ADDRESS")) || !strncmp(addr->mailbox , "INVALID_ADDRESS", strlen("INVALID_ADDRESS")) || !strncmp(addr->host , ".SYNTAX-ERROR.", strlen(".SYNTAX-ERROR.")))
-               {
+                       if (!strncmp(addr->mailbox, "UNEXPECTED_DATA_AFTER_ADDRESS", strlen("UNEXPECTED_DATA_AFTER_ADDRESS")) ||
+                               !strncmp(addr->mailbox, "INVALID_ADDRESS", strlen("INVALID_ADDRESS")) ||
+                               !strncmp(addr->host, ".SYNTAX-ERROR.", strlen(".SYNTAX-ERROR."))) {
                                EM_DEBUG_LOG("Invalid address ");
                                addr = addr->next;
                                continue;
                        }
-               }
-               else  {
+               } else {
                        EM_DEBUG_LOG("Error in parsing..! ");
                        addr = addr->next;
                        continue;
@@ -1198,9 +1186,9 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                is_searched = false;
                EM_DEBUG_LOG(" >>>>> emcore_get_mail_contact_info - 10");
 
-               err = emcore_get_mail_display_name (multi_user_name, email_address,
+               err = emcore_get_mail_display_name(multi_user_name, email_address,
                                             &contact_display_name_from_contact_info);
-               if ( err == EMAIL_ERROR_NONE) {
+               if (err == EMAIL_ERROR_NONE) {
                        contact_display_name = contact_display_name_from_contact_info;
 
                        EM_DEBUG_LOG_SEC(">>> contact_name[%s]", contact_display_name);
@@ -1225,8 +1213,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                                /* snprintf(temp_string, sizeof(temp_string), "%c%d%c%s <%s>%c", start_text_ascii, contact_index, start_text_ascii, contact_display_name, email_address, end_text_ascii); */
                                if (addr->next == NULL) {
                                        snprintf(temp_string, sizeof(temp_string), "\"%s\" <%s>", contact_display_name, email_address);
-                               }
-                               else {
+                               } else {
                                        snprintf(temp_string, sizeof(temp_string), "\"%s\" <%s>, ", contact_display_name, email_address);
                                }
 
@@ -1248,8 +1235,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                                contact_name_len += contact_display_name_len;
                                EM_DEBUG_LOG_SEC("new contact_name >>>>> %s ", contact_name);
                        }
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG("emcore_get_mail_display_name - Not found contact record(if err is 203) or error [%d]", err);
                }
 
@@ -1265,8 +1251,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                        g_strfreev(tokens);
                        /* contact_info->contact_name = EM_SAFE_STRDUP(addr->personal); */
                        alias = addr->personal;
-               }
-               else {
+               } else {
                        /* alias = addr->mailbox ? addr->mailbox  :  ""; */
                        alias = email_address;
                }
@@ -1286,8 +1271,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                                /* snprintf(temp_string, sizeof(temp_string), "%c%d%c%s <%s>%c", start_text_ascii, contact_index, start_text_ascii, contact_display_name, email_address, end_text_ascii); */
                                if (addr->next == NULL) {
                                        snprintf(temp_string, sizeof(temp_string), "\"%s\" <%s>", contact_display_name, email_address);
-                               }
-                               else {
+                               } else {
                                        snprintf(temp_string, sizeof(temp_string), "\"%s\" <%s>, ", contact_display_name, email_address);
                                }
                                EM_DEBUG_LOG_SEC("temp_string[%s]", temp_string);
@@ -1320,8 +1304,7 @@ int emcore_get_mail_contact_info_with_update(char *multi_user_name, email_mail_c
                                if (addr->next != NULL)
                                        EM_SAFE_STRCAT(temp_emailaddr, ", ");
                                EM_DEBUG_LOG_SEC(">>>> TEMP EMail Address [ %s ] ", temp_emailaddr);
-                       }
-                       else {  /*  save only the first address information - 09-SEP-2010 */
+                       } else {        /*  save only the first address information - 09-SEP-2010 */
                                if (is_saved == 0) {
                                        is_saved = 1;
                                        /* snprintf(temp_emailaddr, 400, "%s", contact_info->email_address); */
@@ -1372,7 +1355,7 @@ int emcore_free_contact_info(email_mail_contact_info_t *contact_info, int *err_c
        int ret = false;
        int err = EMAIL_ERROR_NONE;
 
-       if (!contact_info)  {
+       if (!contact_info) {
                EM_DEBUG_EXCEPTION("contact_info[%p]", contact_info);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -1416,31 +1399,31 @@ int emcore_sync_contact_info(char *multi_user_name, int mail_id, int *err_code)
        memset(&contact_info_cc, 0x00, sizeof(email_mail_contact_info_t));
        memset(&contact_info_bcc, 0x00, sizeof(email_mail_contact_info_t));
 
-       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail)  {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
                EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
                goto FINISH_OFF;
        }
 
        if (mail->full_address_from != NULL) {
-               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_from, mail->full_address_from, mail_id, &err))  {
+               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_from, mail->full_address_from, mail_id, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
                }
        }
 
-       if (mail->full_address_to != NULL)  {
-               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_to, mail->full_address_to, mail_id, &err))  {
+       if (mail->full_address_to != NULL) {
+               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_to, mail->full_address_to, mail_id, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
                }
        }
 
-       if (mail->full_address_cc != NULL)  {
-               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_cc, mail->full_address_cc, mail_id, &err))  {
+       if (mail->full_address_cc != NULL) {
+               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_cc, mail->full_address_cc, mail_id, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
                }
        }
 
-       if (mail->full_address_bcc != NULL)  {
-               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_bcc, mail->full_address_bcc, mail_id, &err))  {
+       if (mail->full_address_bcc != NULL) {
+               if (!emcore_get_mail_contact_info_with_update(multi_user_name, &contact_info_bcc, mail->full_address_bcc, mail_id, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info failed [%d]", err);
                }
        }
@@ -1454,20 +1437,18 @@ int emcore_sync_contact_info(char *multi_user_name, int mail_id, int *err_code)
                mail->email_address_recipient = contact_info_to.email_address;
                contact_info_to.contact_name = NULL;
                contact_info_to.email_address = NULL;
-       }
-       else if (mail->full_address_cc != NULL) {
+       } else if (mail->full_address_cc != NULL) {
                mail->email_address_recipient = contact_info_cc.email_address;
                contact_info_cc.contact_name = NULL;
                contact_info_cc.email_address = NULL;
-       }
-       else if (mail->full_address_bcc != NULL) {
+       } else if (mail->full_address_bcc != NULL) {
                mail->email_address_recipient = contact_info_bcc.email_address;
                contact_info_bcc.contact_name  = NULL;
                contact_info_bcc.email_address = NULL;
        }
 
        /*  Update DB */
-       if (!emstorage_change_mail_field(multi_user_name, mail_id, UPDATE_ALL_CONTACT_INFO, mail, false, &err))  {
+       if (!emstorage_change_mail_field(multi_user_name, mail_id, UPDATE_ALL_CONTACT_INFO, mail, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1525,7 +1506,7 @@ static int emcore_sync_address_info(char *multi_user_name, email_address_type_t
        g_strfreev(tokens);
 
        /*  ';' -> ',' */
-       while (p && p[i] != '\0')  {
+       while (p && p[i] != '\0') {
                if (p[i] == ';')
                        p[i] = ',';
                i++;
@@ -1535,22 +1516,21 @@ static int emcore_sync_address_info(char *multi_user_name, email_address_type_t
 
        EM_SAFE_FREE(p);
 
-       if (!addr)  {
+       if (!addr) {
                EM_DEBUG_EXCEPTION("rfc822_parse_adrlist failed...");
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
        /*  Get a contact name */
-       while (addr != NULL)  {
+       while (addr != NULL) {
                if (addr->mailbox && addr->host) {
                        if (!strcmp(addr->mailbox , "UNEXPECTED_DATA_AFTER_ADDRESS") || !strcmp(addr->mailbox , "INVALID_ADDRESS") || !strcmp(addr->host , ".SYNTAX-ERROR.")) {
                                EM_DEBUG_LOG("Invalid address ");
                                addr = addr->next;
                                continue;
                        }
-               }
-               else  {
+               } else {
                        EM_DEBUG_LOG("Error in parsing..! ");
                        addr = addr->next;
                        continue;
@@ -1573,13 +1553,12 @@ static int emcore_sync_address_info(char *multi_user_name, email_address_type_t
                EM_DEBUG_LOG_SEC("Search a contact  :  address[%s]", email_address);
 
                is_search = false;
-               error = emcore_get_mail_display_name (multi_user_name, email_address,
+               error = emcore_get_mail_display_name(multi_user_name, email_address,
                                             &contact_display_name_from_contact_info);
                if (error == EMAIL_ERROR_NONE) {
                        EM_DEBUG_LOG_SEC(">>> contact display name[%s]", contact_display_name_from_contact_info);
                        is_search = true;
-               }
-               else if (error != EMAIL_ERROR_DATA_NOT_FOUND)
+               } else if (error != EMAIL_ERROR_DATA_NOT_FOUND)
                        EM_DEBUG_EXCEPTION("emcore_get_mail_display_name - Not found contact record(if err is -203) or error [%d]", error);
 
                if (is_search == true) {
@@ -1587,8 +1566,7 @@ static int emcore_sync_address_info(char *multi_user_name, email_address_type_t
                        p_address_info->storage_type = -1;
                        p_address_info->display_name = contact_display_name_from_contact_info;
                        EM_DEBUG_LOG_SEC("display_name from contact[%s]", p_address_info->display_name);
-               }
-               else {
+               } else {
                        /*  if contact doesn't exist, use alias or email address as display name */
                        if (addr->personal != NULL) {
                                /*  "%2C" -> ',' */
@@ -1600,8 +1578,7 @@ static int emcore_sync_address_info(char *multi_user_name, email_address_type_t
 
                                g_strfreev(tokens);
                                alias = addr->personal;
-                       }
-                       else {
+                       } else {
                                alias = NULL;
                        }
                        p_address_info->contact_id = -1;
@@ -1623,11 +1600,11 @@ static int emcore_sync_address_info(char *multi_user_name, email_address_type_t
                *address_info_list = g_list_append(*address_info_list, p_address_info);
                p_address_info = NULL;
 
-               EM_DEBUG_LOG_DEV ("after append");
+               EM_DEBUG_LOG_DEV("after append");
 
                alias = NULL;
 
-               EM_DEBUG_LOG_DEV ("next address[%p]", addr->next);
+               EM_DEBUG_LOG_DEV("next address[%p]", addr->next);
 
                /*  next address */
                addr = addr->next;
@@ -1730,7 +1707,7 @@ INTERNAL_FUNC GList *emcore_get_recipients_list(char *multi_user_name, GList *ol
                EM_DEBUG_LOG_SEC("Search a contact : address[%s]", email_address);
 
                err = emcore_get_mail_display_name(multi_user_name, email_address, &display_name);
-               if ( err == EMAIL_ERROR_NONE) {
+               if (err == EMAIL_ERROR_NONE) {
                        EM_DEBUG_LOG_SEC(">>> contact display name[%s]", display_name);
                        is_search = true;
                } else {
@@ -1879,7 +1856,7 @@ INTERNAL_FUNC int emcore_get_mail_data(char *multi_user_name, int input_mail_id,
        char            conditional_clause_string[QUERY_SIZE] = { 0, };
        emstorage_mail_tbl_t *result_mail_tbl = NULL;
 
-       if (input_mail_id == 0 || !output_mail_data)  {
+       if (input_mail_id == 0 || !output_mail_data) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -1887,12 +1864,12 @@ INTERNAL_FUNC int emcore_get_mail_data(char *multi_user_name, int input_mail_id,
 
        SNPRINTF(conditional_clause_string, QUERY_SIZE, "WHERE mail_id = %d", input_mail_id);
 
-       if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause_string, true, &result_mail_tbl, &result_mail_count, &error)) {
+       if (!emstorage_query_mail_tbl(multi_user_name, conditional_clause_string, true, &result_mail_tbl, &result_mail_count, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl falied [%d]", error);
                goto FINISH_OFF;
        }
 
-       if(!em_convert_mail_tbl_to_mail_data(result_mail_tbl, 1, output_mail_data, &error)) {
+       if (!em_convert_mail_tbl_to_mail_data(result_mail_tbl, 1, output_mail_data, &error)) {
                EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data falied [%d]", error);
                goto FINISH_OFF;
        }
@@ -1930,7 +1907,7 @@ INTERNAL_FUNC int emcore_get_attachment_info(char *multi_user_name, int attachme
 {
        EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], err_code[%p]", attachment_id, attachment, err_code);
 
-       if (attachment == NULL || attachment_id == 0)  {
+       if (attachment == NULL || attachment_id == 0) {
                EM_DEBUG_EXCEPTION("attachment_id[%d], attachment[%p]", attachment_id, attachment);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -1942,13 +1919,13 @@ INTERNAL_FUNC int emcore_get_attachment_info(char *multi_user_name, int attachme
        emstorage_attachment_tbl_t *attachment_tbl = NULL;
 
        /* get attachment from attachment tbl */
-       if (!emstorage_get_attachment(multi_user_name, attachment_id, &attachment_tbl, true, &err) || !attachment_tbl)  {
+       if (!emstorage_get_attachment(multi_user_name, attachment_id, &attachment_tbl, true, &err) || !attachment_tbl) {
                EM_DEBUG_EXCEPTION("emstorage_get_attachment failed [%d]", err);
                goto FINISH_OFF;
        }
 
        *attachment = em_malloc(sizeof(email_attachment_data_t));
-       if (!*attachment)  {
+       if (!*attachment) {
                EM_DEBUG_EXCEPTION("malloc failed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -1990,7 +1967,7 @@ INTERNAL_FUNC int emcore_get_attachment_data_list(char *multi_user_name, int inp
 {
        EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], output_attachment_data[%p], output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count);
 
-       if (input_mail_id == 0|| output_attachment_data == NULL || output_attachment_count == NULL)  {
+       if (input_mail_id == 0 || output_attachment_data == NULL || output_attachment_count == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -2002,23 +1979,23 @@ INTERNAL_FUNC int emcore_get_attachment_data_list(char *multi_user_name, int inp
        email_attachment_data_t     *temp_attachment_data = NULL;
 
        /* get attachment from attachment tbl */
-       if ( (err = emstorage_get_attachment_list(multi_user_name, input_mail_id, true, &attachment_tbl_list, &attachment_tbl_count)) != EMAIL_ERROR_NONE ){
+       if ((err = emstorage_get_attachment_list(multi_user_name, input_mail_id, true, &attachment_tbl_list, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       if (attachment_tbl_count)  {
+       if (attachment_tbl_count) {
                EM_DEBUG_LOG("attachment count %d", attachment_tbl_count);
 
                *output_attachment_data = em_malloc(sizeof(email_attachment_data_t) * attachment_tbl_count);
 
-               if(*output_attachment_data == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+               if (*output_attachment_data == NULL) {
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
-               for (i = 0; i < attachment_tbl_count; i++)  {
+               for (i = 0; i < attachment_tbl_count; i++) {
                        temp_attachment_data = (*output_attachment_data) + i;
 
                        temp_attachment_data->attachment_id         = attachment_tbl_list[i].attachment_id;
@@ -2090,7 +2067,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
        GMimeMessage *message = NULL;
 
        if (cancellable)
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        /*  get mail from mail table. */
        if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
@@ -2105,12 +2082,11 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
        }
 
        if (nth == 0) { /* download all attachments, nth starts from 1, not zero */
-               if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &attachment_list, &attachment_count)) != EMAIL_ERROR_NONE ) {
+               if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &attachment_list, &attachment_count)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                        goto FINISH_OFF;
                }
-       }
-       else {  /* download only nth attachment */
+       } else {        /* download only nth attachment */
                attachment_count = 1;
                if (!emstorage_get_attachment_nth(multi_user_name, mail_id, nth, &attachment_list, true, &err) || !attachment_list) {
                        EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
@@ -2119,7 +2095,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
        }
 
        if (cancellable)
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        account_id = mail->account_id;
        server_uid = EM_SAFE_STRDUP(mail->server_mail_id);
@@ -2128,7 +2104,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
        if (attachment_count == 1 && attachment_list) {
                if (!auto_download) {
                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_START, mail_id, attachment_list[0].attachment_name, nth, 0))
-                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
+                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_ATTACH_START] Failed >>>>");
                }
        }
 
@@ -2141,16 +2117,15 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
                                                                                                (void **)&tmp_stream,
                                                                                                &err) || !tmp_stream) {
                        EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
-                       if(err == EMAIL_ERROR_NO_SUCH_HOST)
+                       if (err == EMAIL_ERROR_NO_SUCH_HOST)
                                err = EMAIL_ERROR_CONNECTION_FAILURE;
                        goto FINISH_OFF;
                }
 
                stream = (MAILSTREAM *)tmp_stream;
-       }
-       else {
+       } else {
                MAILSTREAM **mstream = NULL;
-               mstream = emcore_get_recv_stream (multi_user_name, account_id, server_mbox_id, &err);
+               mstream = emcore_get_recv_stream(multi_user_name, account_id, server_mbox_id, &err);
 
                if (!mstream) {
                        EM_DEBUG_EXCEPTION("emcore_get_recv_stream failed [%d]", err);
@@ -2170,7 +2145,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
                        current_attachment_no = nth;    /*  attachment no */
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                /*free cnt_info before reusing*/
                if (cnt_info) {
@@ -2191,9 +2166,9 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
                mail_parameters(stream, SET_FREEBODYSPAREP, emcore_free_body_sparep);
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
-               msg_no = server_uid? atoi(server_uid): 0;
+               msg_no = server_uid ? atoi(server_uid) : 0;
 
                /*  get body structure. */
                /*  don't free mbody because mbody is freed in closing mail_stream. */
@@ -2203,7 +2178,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
                }
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                if (!emcore_gmime_construct_mime_part_with_bodystructure(mbody, &message, "1", NULL)) {
                        EM_DEBUG_EXCEPTION("emcore_gmime_construct_mime_part_with_bodystructure failed");
@@ -2235,7 +2210,7 @@ INTERNAL_FUNC int emcore_gmime_download_attachment(char *multi_user_name, int ma
                }
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                /* select target attachment information. */
                for (ai = cnt_info->file ; ai; ai = ai->next) {
@@ -2386,7 +2361,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
                return false;
        }
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        only_body_download = false;
 
@@ -2396,12 +2371,11 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
                /*  download all attachments, nth starts from 1, not zero */
                /*  get attachment list from db */
                attachment_count_to_be_downloaded = EMAIL_ATTACHMENT_MAX_COUNT;
-               if ( (err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &attachment_list, &attachment_count_to_be_downloaded)) != EMAIL_ERROR_NONE || !attachment_list){
+               if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &attachment_list, &attachment_count_to_be_downloaded)) != EMAIL_ERROR_NONE || !attachment_list) {
                        EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                        goto FINISH_OFF;
                }
-       }
-       else {  /*  download only nth attachment */
+       } else {        /*  download only nth attachment */
                attachment_count_to_be_downloaded = 1;
                if (!emstorage_get_attachment_nth(multi_user_name, mail_id, attachment_no, &attachment_list, true, &err) || !attachment_list) {
                        EM_DEBUG_EXCEPTION("emstorage_get_attachment_nth failed [%d]", err);
@@ -2410,7 +2384,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
        }
 
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        /*  get mail from mail table. */
        if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
@@ -2420,7 +2394,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
 
        /* if (!mail->server_mail_yn || !mail->text_download_yn) {*/ /*  faizan.h@samsung.com */
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        account_id = mail->account_id;
        s_uid = EM_SAFE_STRDUP(mail->server_mail_id); mail->server_mail_id = NULL;
@@ -2443,7 +2417,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
 
        stream = (MAILSTREAM *)tmp_stream;
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        for (i = 0; i < attachment_count_to_be_downloaded; i++) {
                EM_DEBUG_LOG(" >>>>>> Attachment Downloading [%d / %d] start", i+1, attachment_count_to_be_downloaded);
@@ -2452,13 +2426,12 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
                if (attachment_no == 0) {
                        /*  download all attachments, nth starts from 1, not zero */
                        current_attachment_no = i + 1;          /*  attachment no */
-               }
-               else {
+               } else {
                        /*  download only nth attachment */
                        current_attachment_no = attachment_no;          /*  attachment no */
                }
 
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                _imap4_received_body_size = 0;
                _imap4_last_notified_body_size = 0;
@@ -2480,7 +2453,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
 
                EM_DEBUG_LOG("uid [%d]", uid);
 
-               if (!imap_mail_write_body_to_file(stream, account_id, mail_id, attachment_no, savefile, uid , attachment->section, attachment->encoding, &dec_len, NULL, &err)) {
+               if (!imap_mail_write_body_to_file(stream, account_id, mail_id, attachment_no, savefile, uid, attachment->section, attachment->encoding, &dec_len, NULL, &err)) {
                        EM_DEBUG_EXCEPTION("imap_mail_write_body_to_file failed [%d]", err);
                        if (err_code != NULL)
                                *err_code = err;
@@ -2488,7 +2461,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
                }
 
 #ifdef SUPPORT_EXTERNAL_MEMORY
-               iActualSize = emcore_get_actual_mail_size (cnt_info->text.plain , cnt_info->text.html, cnt_info->file , &err);
+               iActualSize = emcore_get_actual_mail_size(cnt_info->text.plain, cnt_info->text.html, cnt_info->file, &err);
                if (!emstorage_mail_check_free_space(iActualSize, &bIs_full, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_mail_check_free_space failed [%d]", err);
                        goto FINISH_OFF;
@@ -2530,7 +2503,7 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
                        goto FINISH_OFF;
                }
 
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                EM_DEBUG_LOG(" >>>>>> Attachment Downloading [%d / %d] completed", i+1, attachment_count_to_be_downloaded);
        }
@@ -2541,8 +2514,8 @@ INTERNAL_FUNC int emcore_download_attachment_bulk(int account_id, int mail_id, i
 
        EM_SAFE_FREE(savefile);
 
-       if (stream)  {
-               stream = mail_close (stream);
+       if (stream) {
+               stream = mail_close(stream);
        }
 
        if (attachment_list)
@@ -2627,10 +2600,10 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
        }
 
        if (cancellable)
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        /* looking for mail by mail_id in DB*/
-       if (!emstorage_get_mail_by_id (multi_user_name, mail_id, &mail, true, &err) || !mail) {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
                EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -2639,9 +2612,9 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
        if (mail->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED) {
                /* after entering viewer, the mail has been just downloaded */
                if (!auto_download) {
-                       if (!emcore_notify_network_event (NOTI_DOWNLOAD_BODY_START, mail_id,
+                       if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id,
                                        "dummy-file", mail->mail_size, 0))
-                               EM_DEBUG_EXCEPTION ("emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] error >>>>");
+                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[ NOTI_DOWNLOAD_BODY_START] error >>>>");
                        else
                                EM_DEBUG_LOG("NOTI_DOWNLOAD_BODY_START notified (%d / %d)", 0, mail->mail_size);
                }
@@ -2649,8 +2622,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                err = EMAIL_ERROR_NONE; //EMAIL_ERROR_MAIL_IS_ALREADY_DOWNLOADED;
                ret = TRUE;
                goto FINISH_OFF;
-       }
-       else if (!mail->body_download_status)
+       } else if (!mail->body_download_status)
                need_update_attachment = 1;
 
        s_uid = EM_SAFE_STRDUP(mail->server_mail_id);
@@ -2662,7 +2634,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
        }
 
        if (cancellable)
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        /*  open mail server. */
        if (!mail_stream) {
@@ -2673,7 +2645,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                                                                                                mail->mailbox_id,
                                                                                                true,
                                                                                                (void **)&tmp_stream,
-                                                                                               &err) || !tmp_stream)  {
+                                                                                               &err) || !tmp_stream) {
                        EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2681,22 +2653,21 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
 #endif
 
                MAILSTREAM **mstream = NULL;
-               mstream = emcore_get_recv_stream (multi_user_name, account_id, mail->mailbox_id, &err);
+               mstream = emcore_get_recv_stream(multi_user_name, account_id, mail->mailbox_id, &err);
 
                if (!mstream) {
                        EM_DEBUG_EXCEPTION("emcore_get_recv_stream failed [%d]", err);
                        goto FINISH_OFF;
                }
                stream = (MAILSTREAM *)*mstream;
-       }
-       else
+       } else
                stream = (MAILSTREAM *)mail_stream;
 
        if (cancellable)
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -2715,7 +2686,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                mailbox.account_id = account_id;
 
                /* download all uids from server. */
-               if (!emcore_download_uid_all (multi_user_name, stream, &mailbox, &uid_list, NULL, NULL, 0, EM_CORE_GET_UIDS_FOR_NO_DELETE, &err)) {
+               if (!emcore_download_uid_all(multi_user_name, stream, &mailbox, &uid_list, NULL, NULL, 0, EM_CORE_GET_UIDS_FOR_NO_DELETE, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_download_uid_all failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2728,7 +2699,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                }
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                _pop3_received_body_size = 0;
                _pop3_total_body_size = 0;
@@ -2745,16 +2716,16 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
 
                if (!auto_download) {
                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, mail_id, "dummy-file", _pop3_total_body_size, 0))
-                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_BODY_START] failed >>>> ");
+                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event[ NOTI_DOWNLOAD_BODY_START] failed >>>> ");
                        else
                                EM_DEBUG_LOG("NOTI_DOWNLOAD_BODY_START notified (%d / %d)", 0, _pop3_total_body_size);
                }
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                tmp_path = emcore_mime_get_save_file_name(&err);
-               EM_DEBUG_LOG ("tmp_path[%s]", tmp_path);
+               EM_DEBUG_LOG("tmp_path[%s]", tmp_path);
 
                err = em_open(tmp_path, O_WRONLY | O_CREAT, 0644, &fd);
                if (err != EMAIL_ERROR_NONE) {
@@ -2771,7 +2742,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                        if (cancellable) {
                                int type = 0;
                                if (!emcore_check_event_thread_status(&type, event_handle)) {
-                                       EM_DEBUG_LOG ("CANCELED EVENT: type [%d]", type);
+                                       EM_DEBUG_LOG("CANCELED EVENT: type [%d]", type);
                                        err = EMAIL_ERROR_CANCELLED;
                                        EM_SAFE_CLOSE(fd);
                                        g_remove(tmp_path);
@@ -2788,7 +2759,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                EM_SAFE_FREE(tmp_path);
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                if (limited_size != NO_LIMITATION && limited_size < pop3_total_body_size) {
                        mail->body_download_status = (mail->body_download_status & ~0x00000003) | EMAIL_BODY_DOWNLOAD_STATUS_PARTIALLY_DOWNLOADED;
@@ -2806,21 +2777,21 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                else
                        cnt_info->grab_type = GRAB_TYPE_TEXT;
 
-               int uid = s_uid? atoi(s_uid):0;
+               int uid = s_uid ? atoi(s_uid) : 0;
 
                /*  set sparep(member of BODY) memory free function  */
                mail_parameters(stream, SET_FREEBODYSPAREP, emcore_free_body_sparep);
 
                /*  get body strucutre. */
                /*  don't free mbody because mbody is freed in closing mail_stream. */
-               if (emcore_get_body_structure(stream, uid, &mbody, &err) < 0 || (mbody == NULL))  {
+               if (emcore_get_body_structure(stream, uid, &mbody, &err) < 0 || (mbody == NULL)) {
                        EM_DEBUG_EXCEPTION("emcore_get_body_structure failed [%d]", err);
                        err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
                        goto FINISH_OFF;
                }
 
                if (cancellable)
-                       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+                       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                /* construct GMimeMessage from bodystructure*/
                if (!emcore_gmime_construct_mime_part_with_bodystructure(mbody, &message1, "1", &total_mail_size)) {
@@ -2901,7 +2872,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
         memset(move_buf, 0x00, sizeof(move_buf));
         memset(path_buf, 0x00, sizeof(path_buf));
 
-               if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err))  {
+               if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2928,7 +2899,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
         memset(move_buf, 0x00, sizeof(move_buf));
         memset(path_buf, 0x00, sizeof(path_buf));
 
-               if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err))  {
+               if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2936,12 +2907,10 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                if (cnt_info->text.html_charset != NULL) {
                        memcpy(html_body, cnt_info->text.html_charset, EM_SAFE_STRLEN(cnt_info->text.html_charset));
                        strcat(html_body, HTML_EXTENSION_STRING);
-               }
-               else if (cnt_info->text.plain_charset != NULL) {
+               } else if (cnt_info->text.plain_charset != NULL) {
                        memcpy(html_body, cnt_info->text.plain_charset, EM_SAFE_STRLEN(cnt_info->text.plain_charset));
                        strcat(html_body, HTML_EXTENSION_STRING);
-               }
-               else {
+               } else {
                        memcpy(html_body, "UTF-8.htm", strlen("UTF-8.htm"));
                }
 
@@ -2981,7 +2950,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
        }
 
        /* Update local_preview_text */
-       if ((err = emcore_get_preview_text_from_file (multi_user_name,
+       if ((err = emcore_get_preview_text_from_file(multi_user_name,
                                                     mail->file_path_plain,
                                                     mail->file_path_html,
                                                     MAX_PREVIEW_TEXT_LENGTH,
@@ -2990,7 +2959,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
        }
 
        if (cancellable)
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        attachment.account_id             = mail->account_id;
        attachment.mail_id                = mail->mail_id;
@@ -3099,12 +3068,12 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                                                emstorage_free_attachment(&attch_info, 1, NULL);
 
                                        /*  delete all created files. */
-                                       if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err))  {
+                                       if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err)) {
                                                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                                                goto FINISH_OFF;
                                        }
 
-                                       if (!emstorage_delete_dir(move_buf, &err))  {
+                                       if (!emstorage_delete_dir(move_buf, &err)) {
                                                EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err);
                                                goto FINISH_OFF;
                                        }
@@ -3115,8 +3084,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                                        goto FINISH_OFF;
                                }
                        }
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG("Attachment info already exists...!");
                        /* Update attachment size */
                        EM_DEBUG_LOG("attachment_size [%d], ai->size [%d]", attch_info->attachment_size, ai->size);
@@ -3181,12 +3149,12 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
         memset(move_buf, 0x00, sizeof(move_buf));
         memset(path_buf, 0x00, sizeof(path_buf));
 
-               if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err))  {
+               if (!emstorage_create_dir(multi_user_name, account_id, mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
 
-               if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, attachment.attachment_name, move_buf, path_buf, sizeof(path_buf), &err))  {
+               if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, attachment.attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -3224,7 +3192,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                                                emstorage_free_attachment(&attch_info, 1, NULL);
 
                                        /*  delete all created files. */
-                                       if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err))  {
+                                       if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err)) {
                                                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                                                goto FINISH_OFF;
                                        }
@@ -3239,8 +3207,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
                                        goto FINISH_OFF;
                                }
                        }
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG("Attachment info already exists...!");
                        /* Update attachment size */
                        EM_DEBUG_LOG("attachment_size [%d], ai->size [%d]", attch_info->attachment_size, ai->size);
@@ -3276,7 +3243,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
        mail->inline_content_count = local_inline_content_count;
 
        /* change mail's information. */
-       if (!emstorage_change_mail_field(multi_user_name, mail_id, APPEND_BODY, mail, false, &err))  {
+       if (!emstorage_change_mail_field(multi_user_name, mail_id, APPEND_BODY, mail, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
                emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL); /*  ROLLBACK TRANSACTION; */
                goto FINISH_OFF;
@@ -3320,7 +3287,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
 
                SNPRINTF(delmsg, sizeof(delmsg), "%d", msg_no);
 
-               if (!ref_account->keep_mails_on_pop_server_after_download)  {
+               if (!ref_account->keep_mails_on_pop_server_after_download) {
                        if (!emcore_delete_mails_from_pop3_server(multi_user_name, &mbox, delmsg, &err))
                                EM_DEBUG_EXCEPTION("emcore_delete_mails_from_pop3_server failed [%d]", err);
                }
@@ -3328,7 +3295,7 @@ INTERNAL_FUNC int emcore_gmime_download_body_sections(char *multi_user_name,
        }
 
        if (cancellable)
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        ret = TRUE;
 
@@ -3342,7 +3309,7 @@ FINISH_OFF:
 #if 0
        /* note that local stream should be freed here*/
        if (mail_stream == NULL && stream != NULL) {
-               stream = mail_close (stream);
+               stream = mail_close(stream);
        }
 #endif
 
@@ -3429,7 +3396,7 @@ static int emcore_delete_mails_from_remote_server(char *multi_user_name,
        int bulk_flag = false;
 #endif
 
-       if (!(account = emcore_get_account_reference(multi_user_name, input_account_id, false)))  {
+       if (!(account = emcore_get_account_reference(multi_user_name, input_account_id, false))) {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_account_id);
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -3445,7 +3412,7 @@ static int emcore_delete_mails_from_remote_server(char *multi_user_name,
        /* Sending Notification */
        noti_param_string = em_malloc(sizeof(char) * 10 * input_mail_id_count);
        if (!noti_param_string) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -3458,7 +3425,7 @@ static int emcore_delete_mails_from_remote_server(char *multi_user_name,
        }
 
        if (!emcore_notify_network_event(NOTI_DELETE_MAIL_START, input_account_id, noti_param_string, 0, 0))
-               EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [ NOTI_DELETE_MAIL_START ] >>>> ");
+               EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [ NOTI_DELETE_MAIL_START ] >>>> ");
 
        if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
                if (!bulk_flag && !emcore_delete_mails_from_imap4_server(multi_user_name,
@@ -3472,12 +3439,11 @@ static int emcore_delete_mails_from_remote_server(char *multi_user_name,
                        if (err == EMAIL_ERROR_IMAP4_STORE_FAILURE)
                                err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
                        goto FINISH_OFF;
-               }
-               else {
+               } else {
                        bulk_flag = true;
 
 #ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
-                       for(i = 0; i < input_mail_id_count; i++) {
+                       for (i = 0; i < input_mail_id_count; i++) {
                                if (!emcore_delete_auto_download_activity(multi_user_name,
                                                                                                                        input_account_id,
                                                                                                                        input_mail_ids[i],
@@ -3488,15 +3454,14 @@ static int emcore_delete_mails_from_remote_server(char *multi_user_name,
                        }
 #endif
                }
-       }
-       else if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
-               if (!emcore_delete_mails_from_pop3_server(multi_user_name, account, input_mail_ids, input_mail_id_count))  {
+       } else if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
+               if (!emcore_delete_mails_from_pop3_server(multi_user_name, account, input_mail_ids, input_mail_id_count)) {
                        EM_DEBUG_EXCEPTION("emcore_delete_mails_from_pop3_server falied [%d]", err);
                        goto FINISH_OFF;
                }
 #ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
                else {
-                       for(i = 0; i < input_mail_id_count; i++) {
+                       for (i = 0; i < input_mail_id_count; i++) {
                                if (!emcore_delete_auto_download_activity(multi_user_name,
                                                                                                                        input_account_id,
                                                                                                                        input_mail_ids[i],
@@ -3516,8 +3481,7 @@ static int emcore_delete_mails_from_remote_server(char *multi_user_name,
                        if (from_server == EMAIL_DELETE_FOR_SEND_THREAD) {
                                new_activity.activity_type = ACTIVITY_DELETEMAIL_SEND;
                                EM_DEBUG_LOG("from_server == EMAIL_DELETE_FOR_SEND_THREAD ");
-                       }
-                       else {
+                       } else {
                                new_activity.activity_type      = ACTIVITY_DELETEMAIL;
                        }
 
@@ -3537,7 +3501,7 @@ static int emcore_delete_mails_from_remote_server(char *multi_user_name,
                                                                                                        mail->server_mailbox_name,
                                                                                                        mail->server_mail_id,
                                                                                                        true,
-                                                                                                       &err))  {
+                                                                                                       &err)) {
                                EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
                        }
                }
@@ -3576,11 +3540,10 @@ FINISH_OFF:
 
        if (err == EMAIL_ERROR_NONE) {
                if (!emcore_notify_network_event(NOTI_DELETE_MAIL_FINISH,  input_account_id, noti_param_string, 0, 0))
-                       EM_DEBUG_EXCEPTION(" emcore_notify_network_event failed [ NOTI_DELETE_MAIL_FINISH ] >>>> ");
-       }
-       else {
+                       EM_DEBUG_EXCEPTION(" emcore_notify_network_eventfailed [ NOTI_DELETE_MAIL_FINISH ] >>>> ");
+       } else {
                if (!emcore_notify_network_event(NOTI_DELETE_MAIL_FAIL,  input_account_id, noti_param_string, 0, 0))
-                       EM_DEBUG_EXCEPTION(" emcore_notify_network_event failed [ NOTI_DELETE_MAIL_FAIL ] >>>> ");
+                       EM_DEBUG_EXCEPTION(" emcore_notify_network_eventfailed [ NOTI_DELETE_MAIL_FAIL ] >>>> ");
        }
 
        if (mail_tbl_data)
@@ -3615,14 +3578,14 @@ int emcore_delete_mail(char *multi_user_name,
        int err = EMAIL_ERROR_NONE;
        email_account_t *account = NULL;
 
-       if (!account_id || !mail_ids || !num)  {
+       if (!account_id || !mail_ids || !num) {
                EM_DEBUG_EXCEPTION("account_id[%d], mail_ids[%p], num[%d], from_server[%d]",
                                                        account_id, mail_ids, num, from_server);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if (!(account = emcore_get_account_reference(multi_user_name, account_id, false)))  {
+       if (!(account = emcore_get_account_reference(multi_user_name, account_id, false))) {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -3640,8 +3603,7 @@ int emcore_delete_mail(char *multi_user_name,
                                                                                                noti_param_2,
                                                                                                err_code);
                emcore_display_unread_in_badge(multi_user_name);
-       }
-       else {   /* Delete mails from server*/
+       } else {   /* Delete mails from server*/
                emcore_delete_mails_from_remote_server(multi_user_name,
                                                                                                account_id,
                                                                                                mailbox_id,
@@ -3672,47 +3634,47 @@ FINISH_OFF:
 
 email_thread_handle_t *del_thd = NULL;
 
-static void* del_dir (void* arg)
+static void* del_dir(void* arg)
 {
        char* buf = (char*) arg;
        int err = EMAIL_ERROR_NONE;
-       if (!emstorage_delete_dir (buf, &err))  {
-               EM_DEBUG_EXCEPTION ("emstorage_delete_dir failed [%d]", err);
+       if (!emstorage_delete_dir(buf, &err)) {
+               EM_DEBUG_EXCEPTION("emstorage_delete_dir failed [%d]", err);
        }
        return NULL;
 }
 
-static void* free_buf (void* arg)
+static void* free_buf(void* arg)
 {
-       EM_SAFE_FREE (arg);
+       EM_SAFE_FREE(arg);
        return NULL;
 }
 
 int pipefd[2] = {0}; /* defined in main.c */
 pthread_mutex_t mu_del_account = PTHREAD_MUTEX_INITIALIZER;
 
-static void* del_exit (void* arg)
+static void* del_exit(void* arg)
 {
-       emcore_send_signal_for_del_account (EMAIL_SIGNAL_FILE_DELETED);
-       EM_DEBUG_LOG ("publish all file deleted");
+       emcore_send_signal_for_del_account(EMAIL_SIGNAL_FILE_DELETED);
+       EM_DEBUG_LOG("publish all file deleted");
        return NULL;
 }
 
-INTERNAL_FUNC int *emcore_init_pipe_for_del_account ()
+INTERNAL_FUNC int *emcore_init_pipe_for_del_account()
 {
        int err = pipe(pipefd);
-       if (err<0) {
-               EM_DEBUG_EXCEPTION ("pipe error [%d]", errno);
+       if (err < 0) {
+               EM_DEBUG_EXCEPTION("pipe error [%d]", errno);
                return NULL;
        }
        return pipefd;
 }
 
-INTERNAL_FUNC void emcore_send_signal_for_del_account (int signal)
+INTERNAL_FUNC void emcore_send_signal_for_del_account(int signal)
 {
-       pthread_mutex_lock (&mu_del_account);
-       write(pipefd[1], (char*) &signal, sizeof (signal));
-       pthread_mutex_unlock (&mu_del_account);
+       pthread_mutex_lock(&mu_del_account);
+       write(pipefd[1], (char *)&signal, sizeof(signal));
+       pthread_mutex_unlock(&mu_del_account);
 }
 
 int emcore_delete_all_mails_of_acount(char *multi_user_name, int input_account_id)
@@ -3724,46 +3686,46 @@ int emcore_delete_all_mails_of_acount(char *multi_user_name, int input_account_i
     char path_buf[512] = {0};
 
        /* emstorage_delete_mail_by_account is available only locally */
-       if (!emstorage_delete_mail_by_account(multi_user_name, input_account_id, false, &err))  {
-               if(err != EMAIL_ERROR_MAIL_NOT_FOUND) {
+       if (!emstorage_delete_mail_by_account(multi_user_name, input_account_id, false, &err)) {
+               if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
                        EM_DEBUG_EXCEPTION("emstorage_delete_mail_by_account failed [%d]", err);
                        goto FINISH_OFF;
                }
        }
 
-       if (!emstorage_delete_attachment_all_on_db(multi_user_name, input_account_id, NULL, false, &err))  {
-               if(err != EMAIL_ERROR_MAIL_NOT_FOUND) {
+       if (!emstorage_delete_attachment_all_on_db(multi_user_name, input_account_id, NULL, false, &err)) {
+               if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
                        EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err);
                        goto FINISH_OFF;
                }
        }
 
        /*  delete mail contents from filesystem */
-       move_buf = em_malloc (512);
+       move_buf = em_malloc(512);
        if (!move_buf) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                goto FINISH_OFF;
        }
 
-       if (!emstorage_get_save_name(multi_user_name, input_account_id, 0, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err))  {
+       if (!emstorage_get_save_name(multi_user_name, input_account_id, 0, 0, NULL, move_buf, path_buf, sizeof(path_buf), &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                goto FINISH_OFF;
        }
 
        if (!del_thd)
-               del_thd = em_thread_create (del_exit, NULL);
+               del_thd = em_thread_create(del_exit, NULL);
 
-       em_thread_run (del_thd, del_dir, free_buf, move_buf);
+       em_thread_run(del_thd, del_dir, free_buf, move_buf);
 
        /*  delete meeting request */
-       if (!emstorage_delete_meeting_request(multi_user_name, input_account_id, 0, 0, false, &err))  {
+       if (!emstorage_delete_meeting_request(multi_user_name, input_account_id, 0, 0, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_delete_attachment_all_on_db failed [%d]", err);
                goto FINISH_OFF;
        }
 
 FINISH_OFF:
 
-       EM_DEBUG_FUNC_END("err [%d]",err);
+       EM_DEBUG_FUNC_END("err [%d]", err);
        return err;
 }
 
@@ -3883,7 +3845,7 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(char *multi_user_name,
        /* Sending Notification */
        noti_param_string = em_malloc(sizeof(char) * 10 * num);
        if (!noti_param_string) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -3896,10 +3858,10 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(char *multi_user_name,
        }
 
        if (!emcore_notify_storage_event(NOTI_MAIL_DELETE, account_id, noti_param_1, noti_param_string, noti_param_2))
-               EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [ NOTI_MAIL_DELETE_FINISH ] >>>> ");
+               EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [ NOTI_MAIL_DELETE_FINISH ] >>>> ");
 
        /* Updating Thread informations */
-       for(i = 0; i < num; i++) {
+       for (i = 0; i < num; i++) {
                if (result_mail_list[i].thread_id != 0) {
                        if (!emstorage_update_latest_thread_mail(multi_user_name,
                                                                                                                account_id,
@@ -3924,9 +3886,9 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(char *multi_user_name,
                                                                        noti_param_1,
                                                                        noti_param_string,
                                                                        noti_param_2))
-               EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [ NOTI_MAIL_DELETE_FINISH ] >>>> ");
+               EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [ NOTI_MAIL_DELETE_FINISH ] >>>> ");
 
-       for(i = 0; i < num; i++) {
+       for (i = 0; i < num; i++) {
                /* Deleting attachments */
                if (!emstorage_delete_all_attachments_of_mail(multi_user_name, result_mail_list[i].mail_id, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_delete_all_attachments_of_mail failed [%d]", err);
@@ -3982,7 +3944,7 @@ INTERNAL_FUNC int emcore_delete_mails_from_local_storage(char *multi_user_name,
        }
 
 #ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
-       for(i = 0; i < num; i++) {
+       for (i = 0; i < num; i++) {
                if (!emcore_delete_auto_download_activity(multi_user_name, account_id, mail_ids[i], 0, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_delete_auto_download_activity failed [%d]", err);
                }
@@ -3999,7 +3961,7 @@ FINISH_OFF:
                                                                                noti_param_1,
                                                                                noti_param_string,
                                                                                noti_param_2))
-                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [ NOTI_MAIL_DELETE_FAIL ] >>>> ");
+                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [ NOTI_MAIL_DELETE_FAIL ] >>>> ");
        }
 
        EM_SAFE_FREE(noti_param_string);
@@ -4032,28 +3994,27 @@ static int emcore_delete_mails_from_pop3_server(char *multi_user_name, email_acc
                goto FINISH_OFF;
        }
 
-       for (i = 0; i < input_mail_id_count; i++)  {
+       for (i = 0; i < input_mail_id_count; i++) {
                /*several threads calls this function. don't use this statement */
                /* FINISH_OFF_IF_CANCELED; */
 
                mail_id = input_mail_ids[i];
 
-               if (!emstorage_get_downloaded_mail(multi_user_name, mail_id, &mail_tbl_data, false, &err) || !mail_tbl_data)  {
+               if (!emstorage_get_downloaded_mail(multi_user_name, mail_id, &mail_tbl_data, false, &err) || !mail_tbl_data) {
                        EM_DEBUG_EXCEPTION("emstorage_get_downloaded_mail failed [%d]", err);
                        if (err == EMAIL_ERROR_MAIL_NOT_FOUND) {        /* not server mail */
                                continue;
-                       }
-                       else
+                       } else
                                goto FINISH_OFF;
                }
 
-               if (stream == NULL)  {
+               if (stream == NULL) {
                        if (!emcore_connect_to_remote_mailbox(multi_user_name,
                                                                                                        input_account->account_id,
                                                                                                        0,
                                                                                                        true,
                                                                                                        (void **)&stream,
-                                                                                                       &err))  {
+                                                                                                       &err)) {
                                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -4068,7 +4029,7 @@ static int emcore_delete_mails_from_pop3_server(char *multi_user_name, email_acc
                        mailbox_data.user_data = NULL;
                }
 
-               if (!emcore_get_mail_msgno_by_uid(input_account, &mailbox_data, mail_tbl_data->server_mail_id, &msgno, &err))  {
+               if (!emcore_get_mail_msgno_by_uid(input_account, &mailbox_data, mail_tbl_data->server_mail_id, &msgno, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_get_mail_msgno_by_uid faild [%d]", err);
                        if (err == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER)
                                goto NOT_FOUND_ON_SERVER;
@@ -4093,7 +4054,7 @@ static int emcore_delete_mails_from_pop3_server(char *multi_user_name, email_acc
                                                                                                &err))
                        EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
 
-NOT_FOUND_ON_SERVER :
+NOT_FOUND_ON_SERVER:
 
                if (mail_tbl_data != NULL)
                        emstorage_free_mail(&mail_tbl_data, 1, NULL);
@@ -4104,8 +4065,8 @@ FINISH_OFF:
        if (mail_tbl_data != NULL)
                emstorage_free_mail(&mail_tbl_data, 1, NULL);
 
-       if (stream)  {
-               stream = mail_close (stream);
+       if (stream) {
+               stream = mail_close(stream);
        }
 
        if (mailbox_data.user_data != NULL) {
@@ -4126,7 +4087,7 @@ INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(email_account_t *account, email_i
 
        emcore_uid_list *uid_list = NULL;
 
-       if (!account || !mailbox || !uid || !msgno)  {
+       if (!account || !mailbox || !uid || !msgno) {
                EM_DEBUG_EXCEPTION_SEC("account[%p], mailbox[%p], uid[%s], msgno[%p]", account, mailbox, uid, msgno);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -4134,15 +4095,14 @@ INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(email_account_t *account, email_i
 
        uid_list = mailbox->user_data;
 
-       if (uid_list == NULL)  {
-               if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3)  {
-                       if (!pop3_mailbox_get_uids(mailbox->mail_stream, &uid_list, &err))  {
+       if (uid_list == NULL) {
+               if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
+                       if (!pop3_mailbox_get_uids(mailbox->mail_stream, &uid_list, &err)) {
                                EM_DEBUG_EXCEPTION("pop3_mailbox_get_uids failed [%d]", err);
                                goto FINISH_OFF;
                        }
-               }
-               else  {         /*  EMAIL_SERVER_TYPE_IMAP4 */
-                       if (!imap4_mailbox_get_uids(mailbox->mail_stream, NULL, &uid_list, &err))  {
+               } else {                /*  EMAIL_SERVER_TYPE_IMAP4 */
+                       if (!imap4_mailbox_get_uids(mailbox->mail_stream, NULL, &uid_list, &err)) {
                                EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -4150,8 +4110,8 @@ INTERNAL_FUNC int emcore_get_mail_msgno_by_uid(email_account_t *account, email_i
                mailbox->user_data = uid_list;
        }
 
-       while (uid_list)  {
-               if (!strcmp(uid_list->uid, uid))  {
+       while (uid_list) {
+               if (!strcmp(uid_list->uid, uid)) {
                        *msgno = uid_list->msgno;
                        EM_DEBUG_LOG("uid_list->msgno[%d]", uid_list->msgno);
                        ret = true;
@@ -4170,7 +4130,7 @@ FINISH_OFF:
        if (uid_list != NULL)
                emcore_free_uids(uid_list, NULL);
        /*  mailbox->user_data and uid_list both point to same memory address, So when uid_list  is freed then just set  */
-       /*  mailbox->user_data to NULL and dont use EM_SAFE_FREE, it will crash  : ) */
+       /*  mailbox->user_data to NULL and dont use EM_SAFE_FREE, it will crash  :) */
        if (mailbox)
        mailbox->user_data = NULL;
        EM_DEBUG_FUNC_END();
@@ -4204,7 +4164,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(char *
        filter_list = em_malloc(sizeof(email_list_filter_t) * filter_count);
 
        if (filter_list == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -4222,7 +4182,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(char *
        filter_list[2].list_filter_item.rule.target_attribute             = EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD;
        filter_list[2].list_filter_item.rule.key_value.integer_type_value = 1;
 
-       if ( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -4251,10 +4211,10 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_local_storage(char *
 
 FINISH_OFF:
 
-       if(mailbox_tbl)
+       if (mailbox_tbl)
                emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
 
-       if(filter_list)
+       if (filter_list)
                emstorage_free_list_filter(&filter_list, filter_count);
 
        EM_SAFE_FREE(conditional_clause_string);
@@ -4273,7 +4233,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(char *
        int *result_mail_id_list = NULL;
        int  result_count = 0;
 
-       if ( input_mailbox_id <= 0) {
+       if (input_mailbox_id <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err =  EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -4284,7 +4244,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(char *
        filter_list = em_malloc(sizeof(email_list_filter_t) * filter_count);
 
        if (filter_list == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -4302,7 +4262,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(char *
        filter_list[2].list_filter_item.rule.target_attribute             = EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD;
        filter_list[2].list_filter_item.rule.key_value.integer_type_value = 1;
 
-       if ( (err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -4329,7 +4289,7 @@ INTERNAL_FUNC int emcore_expunge_mails_deleted_flagged_from_remote_server(char *
 
 FINISH_OFF:
 
-       if(filter_list)
+       if (filter_list)
                emstorage_free_list_filter(&filter_list, filter_count);
 
        EM_SAFE_FREE(result_mail_id_list);
@@ -4354,7 +4314,7 @@ INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, emai
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%d], attachment[%p], err_code[%p]", mail_id, attachment, err_code);
 
-       if (attachment == NULL)  {
+       if (attachment == NULL) {
                EM_DEBUG_EXCEPTION("mail_id[%d], attachment[%p]", mail_id, attachment);
                if (err_code)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -4366,7 +4326,7 @@ INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, emai
        int attachment_id = 0;
        int before_tr_begin = 0;
 
-       if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data)  {
+       if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
                EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err);
                goto FINISH_OFF2;
        }
@@ -4395,33 +4355,33 @@ INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, emai
                goto FINISH_OFF;
        }
 
-       if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err))  {
+       if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
                goto FINISH_OFF;
        }
 
        attachment->attachment_id = attachment_tbl.attachment_id;
 
-       if (attachment->attachment_path)  {
+       if (attachment->attachment_path) {
                char move_buf[512] = {0};
                char path_buf[512] = {0};
 
                if (!attachment->inline_content_status) {
-                       if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_tbl.attachment_id, &err))  {
+                       if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_tbl.attachment_id, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                                goto FINISH_OFF;
                        }
                        attachment_id = attachment_tbl.attachment_id;
                }
 
-               if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, attachment_id, attachment->attachment_name, move_buf, path_buf, sizeof(path_buf), &err))  {
+               if (!emstorage_get_save_name(multi_user_name, account_id, mail_id, attachment_id, attachment->attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        goto FINISH_OFF;
                }
 
            attachment_tbl.attachment_path = path_buf;
 
-               if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err))  {
+               if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4432,7 +4392,7 @@ INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, emai
                }
 
                if (attachment->save_status) {
-                       if (!emstorage_move_file(attachment->attachment_path, move_buf, false, &err))  {
+                       if (!emstorage_move_file(attachment->attachment_path, move_buf, false, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -4440,7 +4400,7 @@ INTERNAL_FUNC int emcore_add_attachment(char *multi_user_name, int mail_id, emai
 
                /* Here only filename is being updated. Since first add is being done there will not be any old files.
                    So no need to check for old files in this update case */
-               if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err))  {
+               if (!emstorage_change_attachment_field(multi_user_name, mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4457,8 +4417,7 @@ FINISH_OFF:
                        err = EMAIL_ERROR_DB_FAILURE;
                        ret = false;
                }
-       }
-       else {  /*  ROLLBACK TRANSACTION; */
+       } else {        /*  ROLLBACK TRANSACTION; */
                if (!before_tr_begin && emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
                        err = EMAIL_ERROR_DB_FAILURE;
        }
@@ -4489,12 +4448,12 @@ INTERNAL_FUNC int emcore_add_attachment_data(char *multi_user_name, int input_ma
        emstorage_mail_tbl_t *mail_table_data = NULL;
        emstorage_attachment_tbl_t attachment_tbl  = { 0 };
 
-       if (input_attachment_data == NULL)  {
+       if (input_attachment_data == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
-       if (!emstorage_get_mail_field_by_id(multi_user_name, input_mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data)  {
+       if (!emstorage_get_mail_field_by_id(multi_user_name, input_mail_id, RETRIEVE_SUMMARY, &mail_table_data, true, &err) || !mail_table_data) {
                EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id failed [%d]", err);
                before_tr_begin = 1;
                goto FINISH_OFF;
@@ -4519,30 +4478,30 @@ INTERNAL_FUNC int emcore_add_attachment_data(char *multi_user_name, int input_ma
                goto FINISH_OFF;
        }
 
-       if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err))  {
+       if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
                goto FINISH_OFF;
        }
 
        input_attachment_data->attachment_id = attachment_tbl.attachment_id;
 
-       if (input_attachment_data->attachment_path)  {
+       if (input_attachment_data->attachment_path) {
                if (!input_attachment_data->inline_content_status) {
-                       if (!emstorage_create_dir(multi_user_name, mail_table_data->account_id, input_mail_id, attachment_tbl.attachment_id, &err))  {
+                       if (!emstorage_create_dir(multi_user_name, mail_table_data->account_id, input_mail_id, attachment_tbl.attachment_id, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                                goto FINISH_OFF;
                        }
                        attachment_id = attachment_tbl.attachment_id;
                }
 
-               if (!emstorage_get_save_name(multi_user_name, mail_table_data->account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, move_buf, path_buf, sizeof(path_buf), &err))  {
+               if (!emstorage_get_save_name(multi_user_name, mail_table_data->account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        goto FINISH_OFF;
                }
 
                attachment_tbl.attachment_path = path_buf;
 
-               if (!emstorage_change_attachment_field(multi_user_name, input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err))  {
+               if (!emstorage_change_attachment_field(multi_user_name, input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4553,7 +4512,7 @@ INTERNAL_FUNC int emcore_add_attachment_data(char *multi_user_name, int input_ma
                }
 
                if (input_attachment_data->save_status) {
-                       if (!emstorage_copy_file(input_attachment_data->attachment_path, move_buf, false, &err))  {
+                       if (!emstorage_copy_file(input_attachment_data->attachment_path, move_buf, false, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -4561,7 +4520,7 @@ INTERNAL_FUNC int emcore_add_attachment_data(char *multi_user_name, int input_ma
 
                /* Here only filename is being updated. Since first add is being done there will not be any old files.
                        So no need to check for old files in this update case */
-               if (!emstorage_change_attachment_field(multi_user_name, input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err))  {
+               if (!emstorage_change_attachment_field(multi_user_name, input_mail_id, UPDATE_SAVENAME, &attachment_tbl, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_change_attachment_field failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4605,7 +4564,7 @@ int emcore_delete_mail_attachment(char *multi_user_name, int attachment_id, int
 {
        EM_DEBUG_FUNC_BEGIN("attachment_id[%d], err_code[%p]", attachment_id, err_code);
 
-       if (attachment_id == 0)  {
+       if (attachment_id == 0) {
                EM_DEBUG_EXCEPTION("attachment_id[%d]", attachment_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -4624,13 +4583,13 @@ int emcore_delete_mail_attachment(char *multi_user_name, int attachment_id, int
        }
 
        /*  BEGIN TRANSACTION; */
-       if(!emstorage_begin_transaction(multi_user_name, NULL, NULL, &error)) {
+       if (!emstorage_begin_transaction(multi_user_name, NULL, NULL, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_begin_transaction failed [%d]", error);
                before_tr_begin = 1;
                goto FINISH_OFF;
        }
 
-       if (!emstorage_delete_attachment_on_db(multi_user_name, attachment_id, false, &error))  {
+       if (!emstorage_delete_attachment_on_db(multi_user_name, attachment_id, false, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_delete_attachment_on_db failed [%d]", error);
                if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
                        error = EMAIL_ERROR_DB_FAILURE;
@@ -4686,7 +4645,7 @@ static int emcore_mail_update_attachment_data(char *multi_user_name, int input_m
        emstorage_attachment_tbl_t *existing_attachment_info = NULL;
        emstorage_attachment_tbl_t  attachment_tbl = { 0 };
 
-       if (input_attachment_data == NULL)  {
+       if (input_attachment_data == NULL) {
                EM_DEBUG_EXCEPTION("Invalid Parameter");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -4711,14 +4670,14 @@ static int emcore_mail_update_attachment_data(char *multi_user_name, int input_m
        attachment_tbl.content_id                       = input_attachment_data->content_id;
 
        if (!input_attachment_data->inline_content_status) {
-               if (!emstorage_create_dir(multi_user_name, attachment_tbl.account_id, input_mail_id, attachment_tbl.attachment_id, &err))  {
+               if (!emstorage_create_dir(multi_user_name, attachment_tbl.account_id, input_mail_id, attachment_tbl.attachment_id, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
                attachment_id = attachment_tbl.attachment_id;
        }
 
-       if (!emstorage_get_save_name(multi_user_name, attachment_tbl.account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, move_buf, path_buf, sizeof(path_buf), &err))  {
+       if (!emstorage_get_save_name(multi_user_name, attachment_tbl.account_id, input_mail_id, attachment_id, input_attachment_data->attachment_name, move_buf, path_buf, sizeof(path_buf), &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -4727,12 +4686,11 @@ static int emcore_mail_update_attachment_data(char *multi_user_name, int input_m
 
        EM_DEBUG_LOG_SEC("downloaded [%d], savename [%s], attachment_path [%s]", input_attachment_data->save_status, input_attachment_data->attachment_path, existing_attachment_info->attachment_path);
        if (input_attachment_data->save_status && EM_SAFE_STRCMP(input_attachment_data->attachment_path, existing_attachment_info->attachment_path) != 0) {
-               if (!emstorage_move_file(input_attachment_data->attachment_path, move_buf, false ,&err))  {
+               if (!emstorage_move_file(input_attachment_data->attachment_path, move_buf, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
                        goto FINISH_OFF;
                }
-       }
-       else
+       } else
                EM_DEBUG_LOG("no need to move");
 
        EM_SAFE_FREE(input_attachment_data->attachment_path);
@@ -4743,7 +4701,7 @@ static int emcore_mail_update_attachment_data(char *multi_user_name, int input_m
                goto FINISH_OFF;
        }
 
-       if (!emstorage_update_attachment(multi_user_name, &attachment_tbl, false, &err))  {
+       if (!emstorage_update_attachment(multi_user_name, &attachment_tbl, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_update_attachment failed [%d]", err);
        }
 
@@ -4783,7 +4741,7 @@ static int emcore_mail_compare_filename_of_attachment_data(char *multi_user_name
        if (input_attachment_b_data->attachment_path && (stat(input_attachment_b_data->attachment_path, &st_buf) == 0)) {
                linkpath = em_malloc(st_buf.st_size + 1);
                if (linkpath == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        goto FINISH_OFF;
                }
 
@@ -4807,9 +4765,9 @@ static int emcore_mail_compare_filename_of_attachment_data(char *multi_user_name
 
        if (!emstorage_get_attachment(multi_user_name, input_attachment_a_id, &attachment_a_tbl, 1, &err)) {
                if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND)
-                       EM_DEBUG_LOG ("no attachment found");
+                       EM_DEBUG_LOG("no attachment found");
                else
-                       EM_DEBUG_EXCEPTION ("emstorage_get_attachment failed [%d]", err);
+                       EM_DEBUG_EXCEPTION("emstorage_get_attachment failed [%d]", err);
 
                *result = 1; /* matching attachment file is not found */
 
@@ -4863,19 +4821,19 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
     char real_path[512];
     char real_file_path[512];
 
-       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail)  {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
                EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
 
                goto FINISH_OFF;
        }
 
-       if ( (err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &atch_list, &count)) != EMAIL_ERROR_NONE ){
+       if ((err = emstorage_get_attachment_list(multi_user_name, mail_id, true, &atch_list, &count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                goto FINISH_OFF;
        }
 
        /*  get increased uid. */
-       if (!emstorage_increase_mail_id(multi_user_name, &mail->mail_id, true, &err))  {
+       if (!emstorage_increase_mail_id(multi_user_name, &mail->mail_id, true, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_increase_mail_id failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -4891,8 +4849,8 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
        }
 
        /*  copy mail body(text) file */
-       if (mail->file_path_plain)  {
-               if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, &err))  {
+       if (mail->file_path_plain) {
+               if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4905,7 +4863,7 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
         memset(real_file_path, 0x00, sizeof(real_file_path));
         SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_plain);
 
-               if (!emstorage_get_save_name(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, filename, real_path, virtual_path, sizeof(virtual_path), &err))  {
+               if (!emstorage_get_save_name(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, filename, real_path, virtual_path, sizeof(virtual_path), &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        g_free(filename);
                        goto FINISH_OFF;
@@ -4913,7 +4871,7 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
 
                g_free(filename);
 
-               if (!emstorage_copy_file(real_file_path, real_path, false, &err))  {
+               if (!emstorage_copy_file(real_file_path, real_path, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4923,8 +4881,8 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
        }
 
        /*  copy mail body(html) file */
-       if (mail->file_path_html)  {
-               if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, &err))  {
+       if (mail->file_path_html) {
+               if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
 
                        goto FINISH_OFF;
@@ -4946,7 +4904,7 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
                                     real_path,
                                     virtual_path,
                                     sizeof(virtual_path),
-                                    &err))  {
+                                    &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        g_free(filename);
                        goto FINISH_OFF;
@@ -4954,7 +4912,7 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
 
                g_free(filename);
 
-               if (!emstorage_copy_file(real_file_path, real_path, false, &err))  {
+               if (!emstorage_copy_file(real_file_path, real_path, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4975,14 +4933,14 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
        mail->mailbox_id   = dst_mailbox->mailbox_id;
        mail->mailbox_type = dst_mailbox->mailbox_type;
 
-       if (!emstorage_add_mail(multi_user_name, mail, 0, false, &err))  {
+       if (!emstorage_add_mail(multi_user_name, mail, 0, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]", err);
 
-               if (mail->file_path_plain)  {
+               if (mail->file_path_plain) {
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_plain);
 
-                       if (!emstorage_delete_file(mail->file_path_plain, &err))  {
+                       if (!emstorage_delete_file(mail->file_path_plain, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
                                emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                                goto FINISH_OFF;
@@ -4993,7 +4951,7 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_html);
 
-                       if (!emstorage_delete_file(real_file_path, &err))  {
+                       if (!emstorage_delete_file(real_file_path, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
                                emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                                goto FINISH_OFF;
@@ -5007,9 +4965,9 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
        }
 
        /*  copy attachment file */
-       for (i = 0; i<count; i++)  {
-               if (atch_list[i].attachment_path)  {
-                       if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, i+1, &err))  {
+       for (i = 0; i < count; i++) {
+               if (atch_list[i].attachment_path) {
+                       if (!emstorage_create_dir(multi_user_name, dst_mailbox->account_id, mail->mail_id, i+1, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                                break;
                        }
@@ -5033,7 +4991,7 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
                                break;
                        }
 
-                       if (!emstorage_copy_file(real_file_path, real_path, false, &err))  {
+                       if (!emstorage_copy_file(real_file_path, real_path, false, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
                                break;
                        }
@@ -5046,20 +5004,20 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
                atch_list[i].mail_id = mail->mail_id;
                atch_list[i].mailbox_id = mail->mailbox_id;
 
-               if (!emstorage_add_attachment(multi_user_name, &atch_list[i], 0, false, &err))  {
+               if (!emstorage_add_attachment(multi_user_name, &atch_list[i], 0, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
                        break;
                }
        }
 
        /*  in case error happened, delete copied file. */
-       if (i && i != count)  {
-               for (;i >= 0; i--)  {
-                       if (atch_list[i].attachment_path)  {
+       if (i && i != count) {
+               for (; i >= 0; i--) {
+                       if (atch_list[i].attachment_path) {
                 memset(real_file_path, 0x00, sizeof(real_file_path));
                 SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, atch_list[i].attachment_path);
 
-                               if (!emstorage_delete_file(real_file_path, &err))  {
+                               if (!emstorage_delete_file(real_file_path, &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
                                        emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                                        goto FINISH_OFF;
@@ -5067,22 +5025,22 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
                        }
                }
 
-               if (mail->file_path_plain)  {
+               if (mail->file_path_plain) {
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_plain);
 
-                       if (!emstorage_delete_file(real_file_path, &err))  {
+                       if (!emstorage_delete_file(real_file_path, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
                                emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                                goto FINISH_OFF;
                        }
                }
 
-        if (mail->file_path_html)  {
+        if (mail->file_path_html) {
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail->file_path_html);
 
-                       if (!emstorage_delete_file(real_file_path, &err))  {
+                       if (!emstorage_delete_file(real_file_path, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_delete_file failed [%d]", err);
                                emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                                goto FINISH_OFF;
@@ -5125,7 +5083,7 @@ INTERNAL_FUNC int emcore_mail_copy(char *multi_user_name, int mail_id, email_mai
                goto FINISH_OFF;
        }
 
-       if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, dst_mailbox->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err))  {
+       if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, dst_mailbox->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -5164,7 +5122,7 @@ FINISH_OFF:
  *    succeed  :  1
  *    fail  :  0
  */
-INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int mail_ids_count, int dst_mailbox_id, int noti_param_1, int noti_param_2 ,int *err_code)
+INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int mail_ids_count, int dst_mailbox_id, int noti_param_1, int noti_param_2int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("mail_ids[%p], mail_ids_count[%d], dst_mailbox_id[%d], noti_param [%d], err_code[%p]", mail_ids, mail_ids_count, dst_mailbox_id, noti_param_1, err_code);
 
@@ -5292,7 +5250,7 @@ INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int ma
        EM_DEBUG_LOG("num : [%d], param string : [%s]", mail_ids_count , parameter_string);
 
        if (!emcore_notify_storage_event(NOTI_MAIL_MOVE, account_id, noti_param_1, parameter_string, noti_param_2))
-               EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [NOTI_MAIL_MOVE] >>>> ");
+               EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [NOTI_MAIL_MOVE] >>>> ");
 
 
        for (i = 0; i < mail_ids_count; i++) {
@@ -5364,7 +5322,7 @@ INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int ma
        }
 
        if (!emcore_notify_storage_event(NOTI_MAIL_MOVE_FINISH, account_id, noti_param_1, parameter_string, noti_param_2))
-               EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [NOTI_MAIL_MOVE_FINISH] >>>> ");
+               EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [NOTI_MAIL_MOVE_FINISH] >>>> ");
 
        emcore_display_unread_in_badge(multi_user_name);
 
@@ -5373,7 +5331,7 @@ INTERNAL_FUNC int emcore_move_mail(char *multi_user_name, int mail_ids[], int ma
 FINISH_OFF:
        if (ret == false) {
                if (!emcore_notify_storage_event(NOTI_MAIL_MOVE_FAIL, account_id, noti_param_1, parameter_string, noti_param_2))
-                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [ NOTI_MAIL_MOVE_FAIL ] >>>> ");
+                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [ NOTI_MAIL_MOVE_FAIL ] >>>> ");
        }
 
        emstorage_free_mail(&p_mail_data, 1, NULL);
@@ -5403,7 +5361,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_
        mail_id = mail_ids[0];
 
        ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
-       if (!ref_account)  {
+       if (!ref_account) {
                EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed  :  get account reference[%d]", account_id);
                *error_code = EMAIL_ERROR_INVALID_ACCOUNT;
                ret = 0;
@@ -5417,17 +5375,16 @@ INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_
                goto FINISH_OFF;
        }
 
-       for (i = 0; i < num; i++)  {
+       for (i = 0; i < num; i++) {
                mail_id = mail_ids[i];
 
-               if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, false, &err_code) || !mail)  {
+               if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, false, &err_code) || !mail) {
                        EM_DEBUG_EXCEPTION("emstorage_get_uid_by_mail_id  :  emstorage_get_downloaded_mail failed [%d]", err_code);
                        mail = NULL;
-                       if (err_code == EMAIL_ERROR_MAIL_NOT_FOUND)  {  /*  not server mail */
+                       if (err_code == EMAIL_ERROR_MAIL_NOT_FOUND)   /*  not server mail */
                                /* err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER; */
                                /* continue; */
-                       }
-                       else {
+                       } else {
                                *error_code = err_code;
                        }
 
@@ -5442,7 +5399,6 @@ INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_
                                                                                                (void **)&stream,
                                                                                                &err_code))             /* faizan.h@samsung.com mail_move_fix_07042009 */ {
                        EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed :  Mailbox open[%d]", err_code);
-
                        ret = 0;
                        goto FINISH_OFF;
                }
@@ -5457,8 +5413,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_
                                if (!mail_copy_full(stream, mail->server_mail_id, dest_mailbox, CP_UID | CP_MOVE)) {
                                        EM_DEBUG_EXCEPTION("emcore_move_mail_on_server :   Mail cannot be moved failed");
                                        ret = 0;
-                               }
-                               else {
+                               } else {
                                        /*  send EXPUNGE command */
                                        if (!emcore_imap4_send_command(stream, IMAP4_CMD_EXPUNGE, &err_code)) {
                                                EM_DEBUG_EXCEPTION("imap4_send_command failed [%d]", err_code);
@@ -5473,14 +5428,12 @@ INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_
                                                goto FINISH_OFF;
                                        }
                                }
-                       }
-                       else {
+                       } else {
                                EM_DEBUG_EXCEPTION(">>>> Server MAIL ID IS NULL >>>> ");
                                ret = 0;
                                goto FINISH_OFF;
                        }
-               }
-               else {
+               } else {
                        EM_DEBUG_EXCEPTION(">>>> STREAM DATA IS NULL >>> ");
                        ret = 0;
                        goto FINISH_OFF;
@@ -5489,7 +5442,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server(char *multi_user_name, int account_
 
 FINISH_OFF:
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
        if (ref_account) {
                emcore_free_account(ref_account);
@@ -5521,8 +5474,7 @@ INTERNAL_FUNC int emcore_move_mail_on_server_by_server_mail_id(void *mail_stream
        if (!mail_copy_full((MAILSTREAM*)mail_stream, server_mail_id, dest_mailbox_name, CP_UID | CP_MOVE)) {
                EM_DEBUG_EXCEPTION("emcore_move_mail_on_server :   Mail cannot be moved failed");
                err_code = EMAIL_ERROR_IMAP4_COPY_FAILURE;
-       }
-       else {
+       } else {
                /*  send EXPUNGE command */
                if (!emcore_imap4_send_command((MAILSTREAM*)mail_stream, IMAP4_CMD_EXPUNGE, &err_code)) {
                        EM_DEBUG_EXCEPTION("imap4_send_command failed [%d]", err_code);
@@ -5548,20 +5500,20 @@ static int emcore_copy_mail_to_another_account_on_local_storeage(char *multi_use
        email_mail_data_t       *mail_data = NULL;
        email_attachment_data_t *attachment_data = NULL;
 
-       if ( input_source_mailbox == NULL || input_target_mailbox == NULL || input_mail_id <= 0 || output_mail_id == NULL) {
+       if (input_source_mailbox == NULL || input_target_mailbox == NULL || input_mail_id <= 0 || output_mail_id == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if((err = emcore_get_mail_data(multi_user_name, input_mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_mail_data(multi_user_name, input_mail_id, &mail_data)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
                err = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
        }
 
        /* Check download status */
-       if(!(mail_data->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED)) {
+       if (!(mail_data->body_download_status & EMAIL_BODY_DOWNLOAD_STATUS_FULLY_DOWNLOADED)) {
                /* If not downloaded, download fully */
                if (!emcore_gmime_download_body_sections(multi_user_name,
                                        NULL,
@@ -5579,7 +5531,7 @@ static int emcore_copy_mail_to_another_account_on_local_storeage(char *multi_use
        }
 
        /* Get attachments */
-       if((err = emcore_get_attachment_data_list(multi_user_name, input_mail_id, &attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_attachment_data_list(multi_user_name, input_mail_id, &attachment_data, &attachment_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -5591,7 +5543,7 @@ static int emcore_copy_mail_to_another_account_on_local_storeage(char *multi_use
        mail_data->thread_id         = 0;
        mail_data->thread_item_count = 0;
 
-       if((err = emcore_add_mail(multi_user_name, mail_data, attachment_data, attachment_count, NULL, false, true)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_add_mail(multi_user_name, mail_data, attachment_data, attachment_count, NULL, false, true)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -5601,7 +5553,7 @@ static int emcore_copy_mail_to_another_account_on_local_storeage(char *multi_use
 FINISH_OFF:
        if (mail_data) {
                emcore_free_mail_data(mail_data);
-               EM_SAFE_FREE (mail_data); /* prevent 34648 */
+               EM_SAFE_FREE(mail_data); /* prevent 34648 */
        }
 
        if (attachment_data)
@@ -5622,12 +5574,12 @@ INTERNAL_FUNC int emcore_move_mail_to_another_account(char *multi_user_name, int
        email_account_t *source_account_ref = NULL;
        email_account_t *target_account_ref = NULL;
 
-       if((err = emstorage_get_mailbox_by_id(multi_user_name, input_source_mailbox_id, &source_mailbox)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_source_mailbox_id, &source_mailbox)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed for source_mailbox [%d]", err);
                goto FINISH_OFF;
        }
 
-       if((err = emstorage_get_mailbox_by_id(multi_user_name, input_target_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_target_mailbox_id, &target_mailbox)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed for target_mailbox [%d]", err);
                goto FINISH_OFF;
        }
@@ -5640,7 +5592,7 @@ INTERNAL_FUNC int emcore_move_mail_to_another_account(char *multi_user_name, int
 
        source_account_ref = emcore_get_account_reference(multi_user_name, source_mailbox->account_id, false);
 
-       if(source_account_ref == NULL || source_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
+       if (source_account_ref == NULL || source_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                EM_DEBUG_EXCEPTION("Invalid account");
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -5648,25 +5600,25 @@ INTERNAL_FUNC int emcore_move_mail_to_another_account(char *multi_user_name, int
 
        target_account_ref = emcore_get_account_reference(multi_user_name, target_mailbox->account_id, false);
 
-       if(target_account_ref == NULL || target_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
+       if (target_account_ref == NULL || target_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                EM_DEBUG_EXCEPTION("Invalid account");
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
        }
 
 
-       if((err = emcore_copy_mail_to_another_account_on_local_storeage(multi_user_name, input_mail_id, source_mailbox, target_mailbox, input_task_id, &moved_mail_id)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_copy_mail_to_another_account_on_local_storeage(multi_user_name, input_mail_id, source_mailbox, target_mailbox, input_task_id, &moved_mail_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_copy_mail_to_another_account_on_local_storeage failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       if(!emcore_set_flags_field(multi_user_name, source_mailbox->account_id, &input_mail_id, 1, EMAIL_FLAGS_DELETED_FIELD, 1 , &err)) {
+       if (!emcore_set_flags_field(multi_user_name, source_mailbox->account_id, &input_mail_id, 1, EMAIL_FLAGS_DELETED_FIELD, 1 , &err)) {
                EM_DEBUG_EXCEPTION("emcore_set_flags_field failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       if(target_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
-               if((err = emcore_sync_mail_from_client_to_server(multi_user_name, moved_mail_id)) != EMAIL_ERROR_NONE) {
+       if (target_account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+               if ((err = emcore_sync_mail_from_client_to_server(multi_user_name, moved_mail_id)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_sync_mail_from_client_to_server failed [%d]", err);
 
                        /* if append is failed, restore source mail and delete copied mail. */
@@ -5739,7 +5691,7 @@ INTERNAL_FUNC int emcore_save_mail_file(char *multi_user_name, int account_id, i
                goto FINISH_OFF;
        }
 
-       if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_id, &err))  {
+       if (!emstorage_create_dir(multi_user_name, account_id, mail_id, attachment_id, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -5757,8 +5709,8 @@ INTERNAL_FUNC int emcore_save_mail_file(char *multi_user_name, int account_id, i
                goto FINISH_OFF;
        }
 
-       if (strcmp(src_file_path, full_path) != 0)  {
-               if (!emstorage_copy_file(src_file_path, full_path, false, &err))  {
+       if (strcmp(src_file_path, full_path) != 0) {
+               if (!emstorage_copy_file(src_file_path, full_path, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_copy_file failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -5800,7 +5752,7 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
     char                   real_file_path[MAX_PATH]    = {0};
 
        if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) ||
-               (!input_attachment_count &&input_attachment_data_list)) {
+               (!input_attachment_count && input_attachment_data_list)) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF2;
@@ -5816,36 +5768,36 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                prefix_path = strdup("");
        }
 
-       if(input_from_eas == 0) {
-               if (input_mail_data->file_path_plain)  {
+       if (input_from_eas == 0) {
+               if (input_mail_data->file_path_plain) {
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_plain);
 
-                       if (stat(real_file_path, &st_buf) < 0)  {
+                       if (stat(real_file_path, &st_buf) < 0) {
                                EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_plain, stat(\"%s\") failed...", input_mail_data->file_path_plain);
                                err = EMAIL_ERROR_FILE_NOT_FOUND;
                                goto FINISH_OFF2;
                        }
                }
 
-               if (input_mail_data->file_path_html)  {
+               if (input_mail_data->file_path_html) {
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_html);
 
-                       if (stat(real_file_path, &st_buf) < 0)  {
+                       if (stat(real_file_path, &st_buf) < 0) {
                                EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_html, stat(\"%s\") failed...", input_mail_data->file_path_html);
                                err = EMAIL_ERROR_FILE_NOT_FOUND;
                                goto FINISH_OFF2;
                        }
                }
 
-               if (input_attachment_count && input_attachment_data_list)  {
-                       for (i = 0; i < input_attachment_count; i++)  {
+               if (input_attachment_count && input_attachment_data_list) {
+                       for (i = 0; i < input_attachment_count; i++) {
                                if (input_attachment_data_list[i].save_status) {
                     memset(real_file_path, 0x00, sizeof(real_file_path));
                     SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_attachment_data_list[i].attachment_path);
 
-                                       if (!input_attachment_data_list[i].attachment_path || stat(real_file_path, &st_buf) < 0)  {
+                                       if (!input_attachment_data_list[i].attachment_path || stat(real_file_path, &st_buf) < 0) {
                                                EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_attachment_data_list[i].attachment_path);
                                                err = EMAIL_ERROR_FILE_NOT_FOUND;
                                                goto FINISH_OFF2;
@@ -5855,13 +5807,13 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                }
        }
 
-       if(input_mail_data->mail_size == 0) {
+       if (input_mail_data->mail_size == 0) {
                 emcore_calc_mail_size(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, &(input_mail_data->mail_size));
        }
 
-       if (input_mail_data->file_path_plain)  {
+       if (input_mail_data->file_path_plain) {
                /* Save plain text body. */
-               if ( (err = em_get_file_name_from_file_path(input_mail_data->file_path_plain, &body_text_file_name)) != EMAIL_ERROR_NONE) {
+               if ((err = em_get_file_name_from_file_path(input_mail_data->file_path_plain, &body_text_file_name)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
                        err = EMAIL_ERROR_INVALID_FILE_PATH;
                        goto FINISH_OFF2;
@@ -5883,10 +5835,10 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                input_mail_data->file_path_plain = EM_SAFE_STRDUP(virtual_path);
        }
 
-       if (input_mail_data->file_path_html)  {
+       if (input_mail_data->file_path_html) {
                /*  Save HTML text body. */
                EM_SAFE_FREE(body_text_file_name);
-               if ( (err = em_get_file_name_from_file_path(input_mail_data->file_path_html, &body_text_file_name)) != EMAIL_ERROR_NONE) {
+               if ((err = em_get_file_name_from_file_path(input_mail_data->file_path_html, &body_text_file_name)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
                        err = EMAIL_ERROR_INVALID_FILE_PATH;
                        goto FINISH_OFF2;
@@ -5908,7 +5860,7 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                input_mail_data->file_path_html = EM_SAFE_STRDUP(virtual_path);
        }
 
-       if (input_mail_data->file_path_mime_entity)  {
+       if (input_mail_data->file_path_mime_entity) {
                /*  Save mime entity. */
                if (!emcore_save_mail_file(multi_user_name,
                                     input_mail_data->account_id,
@@ -5926,7 +5878,7 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                input_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(virtual_path);
        }
 
-       if (input_attachment_data_list && input_attachment_count)  {
+       if (input_attachment_data_list && input_attachment_count) {
                int i = 0;
                int j = 0;
                int compare_result = 1;
@@ -5936,42 +5888,42 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                        EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed : [%d]", err);
                }
 
-               temp_attachment_id_array = em_malloc (sizeof(int) * input_attachment_count);
+               temp_attachment_id_array = em_malloc(sizeof(int) * input_attachment_count);
                if (temp_attachment_id_array == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF2;
                }
 
-               for(i = 0; i < input_attachment_count; i++) {
+               for (i = 0; i < input_attachment_count; i++) {
                        temp_attachment_data = input_attachment_data_list + i;
-                       if ( (err = emcore_mail_compare_filename_of_attachment_data(multi_user_name, input_mail_data->mail_id, \
+                       if ((err = emcore_mail_compare_filename_of_attachment_data(multi_user_name, input_mail_data->mail_id, \
                                temp_attachment_data->attachment_id, temp_attachment_data, &compare_result)) != EMAIL_ERROR_NONE) {
                                if (err == EMAIL_ERROR_ATTACHMENT_NOT_FOUND)
-                                       EM_DEBUG_LOG ("no attachment found");
+                                       EM_DEBUG_LOG("no attachment found");
                                else
-                                       EM_DEBUG_EXCEPTION ("emcore_mail_compare_filename_of_attachment_data failed [%d]", err);
+                                       EM_DEBUG_EXCEPTION("emcore_mail_compare_filename_of_attachment_data failed [%d]", err);
                        }
 
                        switch (compare_result) {
-                       case 0 :
+                       case 0:
                                EM_DEBUG_LOG("file name and attachment id are same, update exising attachment");
-                               if (!emcore_mail_update_attachment_data(multi_user_name, input_mail_data->mail_id, temp_attachment_data))  {
+                               if (!emcore_mail_update_attachment_data(multi_user_name, input_mail_data->mail_id, temp_attachment_data)) {
                                        EM_DEBUG_EXCEPTION("emcore_mail_update_attachment_data failed [%d]", err);
                                        goto FINISH_OFF2;
                                }
                                temp_attachment_id_array[i] = temp_attachment_data->attachment_id;
                                break;
-                       case 1 :
+                       case 1:
                                EM_DEBUG_LOG("save names are different");
-                               if ( (err = emcore_add_attachment_data(multi_user_name, input_mail_data->mail_id, temp_attachment_data)) != EMAIL_ERROR_NONE)  {
+                               if ((err = emcore_add_attachment_data(multi_user_name, input_mail_data->mail_id, temp_attachment_data)) != EMAIL_ERROR_NONE) {
                                        EM_DEBUG_EXCEPTION("emcore_add_attachment failed [%d]", err);
                                        goto FINISH_OFF2;
                                }
 
                                temp_attachment_id_array[i] = temp_attachment_data->attachment_id;
                                break;
-                       case 2 :
+                       case 2:
                                EM_DEBUG_LOG("No chagned the attachment info");
                                temp_attachment_id_array[i] = temp_attachment_data->attachment_id;
                                break;
@@ -6006,12 +5958,12 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                        }
 
                        switch (compare_result) {
-                       case 0 : /* Delete the attachment on db and file */
+                       case 0: /* Delete the attachment on db and file */
                                if (!emcore_delete_mail_attachment(multi_user_name, temp_attachment_data->attachment_id, &err)) {
                                        EM_DEBUG_EXCEPTION("emcore_delete_mail_attachment failed [%d]", err);
                                }
                                break;
-                       case 2 : /* Delete the attachment on db */
+                       case 2: /* Delete the attachment on db */
                                if (!emstorage_delete_attachment_on_db(multi_user_name, temp_attachment_data->attachment_id, true, &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_delete_attachment_on_db failed : [%d]", err);
                                }
@@ -6034,7 +5986,7 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
 
        EM_DEBUG_LOG("preview_text[%p]", input_mail_data->preview_text);
        if (input_mail_data->preview_text == NULL) {
-               if ( (err =emcore_get_preview_text_from_file(multi_user_name,
+               if ((err = emcore_get_preview_text_from_file(multi_user_name,
                                                     input_mail_data->file_path_plain,
                                                     input_mail_data->file_path_html,
                                                     MAX_PREVIEW_TEXT_LENGTH,
@@ -6045,7 +5997,7 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                }
        }
 
-       if(!em_convert_mail_data_to_mail_tbl(input_mail_data, 1, &converted_mail_tbl_data,  &err)) {
+       if (!em_convert_mail_data_to_mail_tbl(input_mail_data, 1, &converted_mail_tbl_data,  &err)) {
                EM_DEBUG_EXCEPTION("em_convert_mail_data_to_mail_tbl failed[%d]", err);
                goto FINISH_OFF2;
        }
@@ -6107,16 +6059,15 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
                        }
 
                        if (original_mail)      {
-                               if (!emstorage_add_meeting_request(multi_user_name, input_mail_data->account_id, original_mail->mailbox_id, input_meeting_request, false, &err))  {
+                               if (!emstorage_add_meeting_request(multi_user_name, input_mail_data->account_id, original_mail->mailbox_id, input_meeting_request, false, &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_add_meeting_request failed [%d]", err);
                                        emstorage_free_mail(&original_mail, 1, NULL);
                                        goto FINISH_OFF;
                                }
                                        emstorage_free_mail(&original_mail, 1, NULL);
                        }
-               }
-               else {  /*  update */
-                       if (!emstorage_update_meeting_request(multi_user_name, input_meeting_request, false, &err))  {
+               } else {        /*  update */
+                       if (!emstorage_update_meeting_request(multi_user_name, input_meeting_request, false, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_update_meeting_request failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -6124,6 +6075,7 @@ INTERNAL_FUNC int emcore_update_mail(char *multi_user_name, email_mail_data_t *i
        }
 
 FINISH_OFF:
+
        if (err == EMAIL_ERROR_NONE) {
                /*  COMMIT TRANSACTION; */
                if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
@@ -6132,10 +6084,9 @@ FINISH_OFF:
 
                SNPRINTF(mailbox_id_param_string, 10, "%d", input_mail_data->mailbox_id);
 
-               if (!emcore_notify_storage_event(NOTI_MAIL_UPDATE, input_mail_data->account_id, input_mail_data->mail_id, mailbox_id_param_string, input_mail_data->meeting_request_status?UPDATE_MEETING:UPDATE_MAIL))
-                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [NOTI_MAIL_UPDATE] ");
-       }
-       else {
+               if (!emcore_notify_storage_event(NOTI_MAIL_UPDATE, input_mail_data->account_id, input_mail_data->mail_id, mailbox_id_param_string, input_mail_data->meeting_request_status ? UPDATE_MEETING : UPDATE_MAIL))
+                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [NOTI_MAIL_UPDATE] ");
+       } else {
                /*  ROLLBACK TRANSACTION; */
                if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false)
                        err = EMAIL_ERROR_DB_FAILURE;
@@ -6150,12 +6101,12 @@ FINISH_OFF2:
        if (ori_attachment_data_list)
                emcore_free_attachment_data(&ori_attachment_data_list, ori_attachment_count, NULL);
 
-       if(meeting_req) {
+       if (meeting_req) {
                emstorage_free_meeting_request(meeting_req);
                EM_SAFE_FREE(meeting_req);
        }
 
-       if(converted_mail_tbl_data)
+       if (converted_mail_tbl_data)
                emstorage_free_mail(&converted_mail_tbl_data, 1, NULL);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -6173,7 +6124,7 @@ INTERNAL_FUNC int emcore_set_flags_field(char *multi_user_name, int account_id,
                , "flags_deleted_field", "flags_flagged_field", "flags_answered_field"
                , "flags_recent_field", "flags_draft_field", "flags_forwarded_field" };
 
-       if(field_type < 0 || field_type >= EMAIL_FLAGS_FIELD_COUNT || mail_ids == NULL || num <= 0 || account_id == 0) {
+       if (field_type < 0 || field_type >= EMAIL_FLAGS_FIELD_COUNT || mail_ids == NULL || num <= 0 || account_id == 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto  FINISH_OFF;
@@ -6209,7 +6160,7 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in
        char *response = NULL;
        POP3LOCAL *pop3local;
 
-       if (!stream || !result_total_body_size)  {
+       if (!stream || !result_total_body_size) {
                EM_DEBUG_EXCEPTION("stream[%p], total_body_size[%p]", stream, msgno, result_total_body_size);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -6217,7 +6168,7 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in
 
        pop3local = (POP3LOCAL *)(((MAILSTREAM *)stream)->local);
 
-       if (!pop3local  || !pop3local->netstream)  {
+       if (!pop3local  || !pop3local->netstream) {
                err = EMAIL_ERROR_INVALID_STREAM;
                goto FINISH_OFF;
        }
@@ -6231,9 +6182,8 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in
 
 
        /*  send command  :  LIST [msgno] - to get the size of the mail */
-       if (!net_sout(pop3local->netstream, command, (int)EM_SAFE_STRLEN(command)))  {
+       if (!net_sout(pop3local->netstream, command, (int)EM_SAFE_STRLEN(command))) {
                EM_DEBUG_EXCEPTION("net_sout failed...");
-
                err = EMAIL_ERROR_INVALID_RESPONSE;
                goto FINISH_OFF;
        }
@@ -6248,15 +6198,15 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in
                if (response)
                        EM_DEBUG_LOG("[POP3] <<< %s", response);
 
-               if (*response == '.')  {
+               if (*response == '.') {
                        EM_SAFE_FREE(response);
                        break;
                }
 
-               if (*response == '+')  {                /*  "+ OK" */
+               if (*response == '+') {         /*  "+ OK" */
                        char *p = NULL;
 
-                       if (!(p = strchr(response + strlen("+OK "), ' ')))  {
+                       if (!(p = strchr(response + strlen("+OK "), ' '))) {
                                err = EMAIL_ERROR_INVALID_RESPONSE;
                                goto FINISH_OFF;
                        }
@@ -6268,12 +6218,10 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in
                                *result_total_body_size = total_body_size;
                                break;
                        }
-               }
-               else if (*response == '-')  {   /*  "- ERR" */
+               } else if (*response == '-') {  /*  "- ERR" */
                        err = EMAIL_ERROR_INVALID_RESPONSE;
                        goto FINISH_OFF;
-               }
-               else  {
+               } else {
                        err = EMAIL_ERROR_INVALID_RESPONSE;
                        goto FINISH_OFF;
                }
@@ -6286,20 +6234,19 @@ int emcore_mail_cmd_read_mail_pop3(void *stream, int msgno, int limited_size, in
        if (limited_size && total_body_size > limited_size) {
                int count_of_line = limited_size / 80;
                SNPRINTF(command, sizeof(command), "TOP %d %d", msgno, count_of_line);
-       }
-       else
+       } else
                SNPRINTF(command, sizeof(command), "RETR %d", msgno);
 
        EM_DEBUG_LOG("[POP3] >>> %s", command);
 
        emcore_set_network_error(EMAIL_ERROR_NONE);             /*  set current network error as EMAIL_ERROR_NONE before network operation */
        /*  get mail from mail server */
-       if (!pop3_send((MAILSTREAM *)stream, command, NULL))  {
+       if (!pop3_send((MAILSTREAM *)stream, command, NULL)) {
                EM_DEBUG_EXCEPTION("pop3_send failed...");
 
                email_session_t *session = NULL;
 
-               if (!emcore_get_current_session(&session))  {
+               if (!emcore_get_current_session(&session)) {
                        EM_DEBUG_EXCEPTION("emcore_get_current_session failed...");
                        err = EMAIL_ERROR_SESSION_NOT_FOUND;
                        goto FINISH_OFF;
@@ -6329,7 +6276,7 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_i
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%p], err_code[%p]", mail_id, err_code);
 
-       if (mail_id < 1)  {
+       if (mail_id < 1) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -6347,22 +6294,22 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_i
        char clear_flags[100] = { 0, };
        char tmp[100] = { 0, };
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
-       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail)  {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
                EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
                goto FINISH_OFF;
        }
 
        account_id = mail->account_id;
 
-       if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false)))   {
+       if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false)))  {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
        }
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        /*  open mail server. */
        if (!emcore_connect_to_remote_mailbox(multi_user_name,
@@ -6370,24 +6317,24 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_i
                                                                                        mail->mailbox_id,
                                                                                        true,
                                                                                        (void **)&stream,
-                                                                                       &err) || !stream)  {
+                                                                                       &err) || !stream) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        mailbox.mailbox_id = mail->mailbox_id;
        mailbox.account_id = account_id;
        mailbox.mail_stream = stream;
 
        /*  download all uids from server. */
-       if (!emcore_get_mail_msgno_by_uid(ref_account, &mailbox, mail->server_mail_id, &msgno, &err))  {
+       if (!emcore_get_mail_msgno_by_uid(ref_account, &mailbox, mail->server_mail_id, &msgno, &err)) {
                EM_DEBUG_EXCEPTION("emcore_get_mail_msgno_by_uid failed message_no  :  %d ", err);
                goto FINISH_OFF;
        }
 
-       sprintf (tmp, "%d", msgno);
+       sprintf(tmp, "%d", msgno);
 
        if (mail->flags_seen_field)
                sprintf(set_flags, "\\Seen");
@@ -6409,13 +6356,13 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_i
        else
                sprintf(clear_flags, "%s $Forwarded", clear_flags);
 
-       if (EM_SAFE_STRLEN(set_flags) > 0)  {
+       if (EM_SAFE_STRLEN(set_flags) > 0) {
                EM_DEBUG_LOG(">>>> Calling mail_setflag [%s] ", set_flags);
                mail_flag(stream, tmp, set_flags, ST_SET | ST_SILENT);
                EM_DEBUG_LOG(">>>> End mail_setflag ");
        }
 
-       if (EM_SAFE_STRLEN(clear_flags) > 0)  {
+       if (EM_SAFE_STRLEN(clear_flags) > 0) {
                EM_DEBUG_LOG(">>>> Calling mail_clearflag [%s]", clear_flags);
                mail_clearflag(stream, tmp, clear_flags);
                EM_DEBUG_LOG(">>>> End mail_clearflag ");
@@ -6424,7 +6371,7 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_i
        if (mail->lock_status) {
                memset(set_flags, 0x00, 100);
                sprintf(set_flags, "Sticky");
-               if (EM_SAFE_STRLEN(set_flags) > 0)  {
+               if (EM_SAFE_STRLEN(set_flags) > 0) {
                        EM_DEBUG_LOG(">>>> Calling mail_setflag [%s]", set_flags);
                        mail_flag(stream, tmp, set_flags, ST_SET | ST_SILENT);
                        EM_DEBUG_LOG(">>>> End mail_setflag ");
@@ -6433,14 +6380,14 @@ INTERNAL_FUNC int emcore_sync_flag_with_server(char *multi_user_name, int mail_i
 
        EM_DEBUG_LOG(">>>> Returning from emcore_sync_flag_with_server ");
 
-       FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+       FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
        ret = true;
 
 FINISH_OFF:
 
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
        if (mail)
                emstorage_free_mail(&mail, 1, NULL);
@@ -6460,7 +6407,7 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int m
 {
        EM_DEBUG_FUNC_BEGIN("mail_ids[%p], err_code[%p]", mail_ids[0], err_code);
 
-       if (mail_ids[0] < 1)  {
+       if (mail_ids[0] < 1) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -6484,7 +6431,7 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int m
 
        mail_id = mail_ids[0];
 
-       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail)  {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
                EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -6503,7 +6450,7 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int m
                                                                                        mail->mailbox_id,
                                                                                        true,
                                                                                        (void **)&stream,
-                                                                                       &err) || !stream)  {
+                                                                                       &err) || !stream) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -6512,26 +6459,26 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int m
        mailbox.account_id = account_id;
        mailbox.mail_stream = stream;
 
-       for (i = 0; i < num; i++)  {
+       for (i = 0; i < num; i++) {
                mail_id = mail_ids[i];
 
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
-               if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail)  {
+               if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
                        goto FINISH_OFF;
                }
 
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                /*  download message number from server. */
-               if (!emcore_get_mail_msgno_by_uid(ref_account, &mailbox, mail->server_mail_id, &msgno, &err))  {
+               if (!emcore_get_mail_msgno_by_uid(ref_account, &mailbox, mail->server_mail_id, &msgno, &err)) {
                        EM_DEBUG_LOG("emcore_get_mail_msgno_by_uid failed message_no  :  %d ", err);
                        goto FINISH_OFF;
                }
 
                memset(tmp, 0x00, 100);
-               sprintf (tmp, "%d", msgno);
+               sprintf(tmp, "%d", msgno);
 
                memset(set_flags, 0x00, 100);
                memset(clear_flags, 0x00, 100);
@@ -6542,12 +6489,11 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int m
                        sprintf(clear_flags, "\\Seen");
                EM_DEBUG_LOG("new_flag.seen :  %s ", set_flags);
 
-               if (EM_SAFE_STRLEN(set_flags) > 0)  {
+               if (EM_SAFE_STRLEN(set_flags) > 0) {
                        EM_DEBUG_LOG(">>>> Calling mail_setflag ");
                        mail_flag(stream, tmp, set_flags, ST_SET | ST_SILENT);
                        EM_DEBUG_LOG(">>>> End mail_setflag ");
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG(">>>> Calling mail_clearflag ");
                        mail_clearflag(stream, tmp, clear_flags);
                        EM_DEBUG_LOG(">>>> End mail_clearflag ");
@@ -6555,14 +6501,14 @@ INTERNAL_FUNC int emcore_sync_seen_flag_with_server(char *multi_user_name, int m
 
                EM_DEBUG_LOG(">>>> Returning from emcore_sync_flag_with_server ");
 
-               FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+               FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
        }
        ret = true;
 
 FINISH_OFF:
 
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
        if (mail)
                emstorage_free_mail(&mail, 1, NULL);
 
@@ -6588,7 +6534,7 @@ INTERNAL_FUNC void emcore_free_mail_data_list(email_mail_data_t **mail_list, int
        int i;
 
        for (i = 0; i < count; i++)
-               emcore_free_mail_data( p+i);
+               emcore_free_mail_data(p+i);
 
        EM_SAFE_FREE(*mail_list);
 
@@ -6633,7 +6579,7 @@ INTERNAL_FUNC int emcore_free_attachment_data(email_attachment_data_t **attachme
 {
        EM_DEBUG_FUNC_BEGIN("attachment_data_list[%p], attachment_data_count [%d], err_code[%p]", attachment_data_list, attachment_data_count, err_code);
 
-       if (!attachment_data_list || !*attachment_data_list)  {
+       if (!attachment_data_list || !*attachment_data_list) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -6651,7 +6597,7 @@ INTERNAL_FUNC int emcore_free_attachment_data(email_attachment_data_t **attachme
 
        EM_SAFE_FREE(p); *attachment_data_list = NULL;
 
-       if(err_code)
+       if (err_code)
                *err_code = EMAIL_ERROR_NONE;
 
        EM_DEBUG_FUNC_END();
@@ -6683,7 +6629,7 @@ INTERNAL_FUNC int emcore_delete_pbd_activity(char *multi_user_name, int account_
                goto FINISH_OFF;
        }
 
-       if (!emstorage_delete_pbd_activity(multi_user_name, account_id, mail_id, activity_id, false, &err))  {
+       if (!emstorage_delete_pbd_activity(multi_user_name, account_id, mail_id, activity_id, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_delete_pbd_activity failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -6728,7 +6674,7 @@ INTERNAL_FUNC int emcore_insert_pbd_activity(email_event_partial_body_thd *local
                goto FINISH_OFF;
        }
 
-       if (!emstorage_add_pbd_activity(local_activity->multi_user_name, local_activity, activity_id, false, &err))  {
+       if (!emstorage_add_pbd_activity(local_activity->multi_user_name, local_activity, activity_id, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_add_pbd_activity failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -6763,7 +6709,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int
 {
        EM_DEBUG_FUNC_BEGIN("mail_ids [%p], num [%d], field_type [%d], value [%d], err_code [%p]", mail_ids, num, field_type, value, err_code);
 
-       if (NULL == mail_ids || num <= 0 || field_type < 0 || field_type >= EMAIL_FLAGS_FIELD_COUNT)  {
+       if (NULL == mail_ids || num <= 0 || field_type < 0 || field_type >= EMAIL_FLAGS_FIELD_COUNT) {
                        EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                if (err_code != NULL) {
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -6804,7 +6750,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int
        account_id = mail[0].account_id;
 
        temp_account = emcore_get_account_reference(multi_user_name, account_id, false);
-       if (!temp_account)   {
+       if (!temp_account)  {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -6821,7 +6767,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int
                                                                                        mail->mailbox_id,
                                                                                        true,
                                                                                        (void **)&stream,
-                                                                                       &err) || !stream)  {
+                                                                                       &err) || !stream) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -6836,7 +6782,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int
        /* Here about 90 bytes are required for fixed keywords in the query-> SELECT local_uid, s_uid from mail_read_mail_uid_tbl where local_uid in (....) ORDER by s_uid */
        /* So length of comma separated strings which will be filled in (.....) in above query can be maximum QUERY_SIZE - 90 */
 
-       if (false == emcore_form_comma_separated_strings(mail_ids, num, QUERY_SIZE - 90, &string_list, &string_count, &err))   {
+       if (false == emcore_form_comma_separated_strings(mail_ids, num, QUERY_SIZE - 90, &string_list, &string_count, &err))  {
                EM_DEBUG_EXCEPTION("emcore_form_comma_separated_strings failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -6879,7 +6825,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int
 
                        /* send command */
 
-                       if (!(imaplocal = stream->local) || !imaplocal->netstream)  {
+                       if (!(imaplocal = stream->local) || !imaplocal->netstream) {
                                EM_DEBUG_EXCEPTION("invalid IMAP4 stream detected...");
 
                                err = EMAIL_ERROR_UNKNOWN;
@@ -6895,7 +6841,7 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int
                        /* Receive Response */
 
                        while (imaplocal->netstream) {
-                               if (!(p = net_getline(imaplocal->netstream)))  {
+                               if (!(p = net_getline(imaplocal->netstream))) {
                                        EM_DEBUG_EXCEPTION("net_getline failed...");
 
                                        err = EMAIL_ERROR_INVALID_RESPONSE;
@@ -6904,13 +6850,12 @@ INTERNAL_FUNC int emcore_sync_flags_field_with_server(char *multi_user_name, int
 
                                EM_DEBUG_LOG("[IMAP4 Response ] %s", p);
 
-                               if (!strncmp(p, tag, EM_SAFE_STRLEN(tag)))  {
-                                       if (!strncmp(p + EM_SAFE_STRLEN(tag) + 1, "OK", 2))  {
+                               if (!strncmp(p, tag, EM_SAFE_STRLEN(tag))) {
+                                       if (!strncmp(p + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
                                                /*Delete all local activities */
                                                EM_SAFE_FREE(p);
                                                break;
-                                       }
-                                       else  {
+                                       } else {
                                                /* 'NO' or 'BAD' */
                                                err = EMAIL_ERROR_IMAP4_STORE_FAILURE;
                                                EM_SAFE_FREE(p);
@@ -6940,7 +6885,7 @@ FINISH_OFF:
 #ifdef __FEATURE_LOCAL_ACTIVITY__
        if (ret) {
                emstorage_activity_tbl_t new_activity;
-               for (i = 0; i<num ; i++) {
+               for (i = 0; i < num; i++) {
                        memset(&new_activity, 0x00, sizeof(emstorage_activity_tbl_t));
                        new_activity.activity_type = ACTIVITY_MODIFYSEENFLAG;
                        new_activity.account_id    = account_id;
@@ -6964,7 +6909,7 @@ FINISH_OFF:
                emcore_free_uid_range_set(&uid_range_set);
 
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
        if (temp_account) {
                emcore_free_account(temp_account);
@@ -7012,7 +6957,7 @@ static int emcore_mail_move_by_filter_rule(char *multi_user_name, int account_id
                parameter_string = em_malloc(sizeof(char) * parameter_string_length);
                if (parameter_string == NULL) {
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
-                       EM_DEBUG_EXCEPTION("em_malloc failed for parameter_string");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed for parameter_string");
                        goto FINISH_OFF;
                }
 
@@ -7030,10 +6975,10 @@ static int emcore_mail_move_by_filter_rule(char *multi_user_name, int account_id
 
                if (filter_info->type == EMAIL_PRIORITY_SENDER) {
                        if (!emcore_notify_storage_event(NOTI_RULE_APPLY, account_id, filter_info->rule_id, parameter_string, 0))
-                               EM_DEBUG_EXCEPTION("emcore_notify_storage_event failed [ NOTI_MAIL_MOVE ] >>>> ");
+                               EM_DEBUG_EXCEPTION("emcore_notify_storage_eventfailed [ NOTI_MAIL_MOVE ] >>>> ");
                } else {
                        if (!emcore_notify_storage_event(NOTI_MAIL_MOVE, account_id, 0, parameter_string, 0))
-                               EM_DEBUG_EXCEPTION("emcore_notify_storage_event failed [ NOTI_MAIL_MOVE ] >>>> ");
+                               EM_DEBUG_EXCEPTION("emcore_notify_storage_eventfailed [ NOTI_MAIL_MOVE ] >>>> ");
                }
        }
 
@@ -7094,14 +7039,14 @@ INTERNAL_FUNC int emcore_mail_filter_by_rule(char *multi_user_name, email_rule_t
        emstorage_mailbox_tbl_t *spam_mailbox = NULL;
        emstorage_account_tbl_t *account_tbl_t_list = NULL, *account_tbl_t = NULL;
 
-       if (!filter_info)  {
+       if (!filter_info) {
                EM_DEBUG_EXCEPTION("filter_info[%p]", filter_info);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
        switch (filter_info->faction) {
-       case EMAIL_FILTER_MOVE :
+       case EMAIL_FILTER_MOVE:
                if (filter_info->type != EMAIL_PRIORITY_SENDER)
                        break;
 
@@ -7110,7 +7055,7 @@ INTERNAL_FUNC int emcore_mail_filter_by_rule(char *multi_user_name, email_rule_t
                        goto FINISH_OFF;
                }
                break;
-       case EMAIL_FILTER_BLOCK :
+       case EMAIL_FILTER_BLOCK:
                if (!emstorage_get_account_list(multi_user_name, &account_count, &account_tbl_t_list, false, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
                        goto FINISH_OFF;
@@ -7132,7 +7077,7 @@ INTERNAL_FUNC int emcore_mail_filter_by_rule(char *multi_user_name, email_rule_t
 
                }
                break;
-       case EMAIL_FILTER_DELETE :
+       case EMAIL_FILTER_DELETE:
        default:
                EM_DEBUG_LOG("filter_faction : [%d]", filter_info->faction);
                break;
@@ -7173,17 +7118,17 @@ INTERNAL_FUNC int emcore_add_rule(char *multi_user_name, email_rule_t *filter_in
        }
 
        switch (filter_info->faction) {
-       case EMAIL_FILTER_MOVE :
+       case EMAIL_FILTER_MOVE:
                if (filter_info->account_id < 0) {
                        EM_DEBUG_EXCEPTION("Invalid Param : target_mailbox_id[%d], account_id[%d]", filter_info->target_mailbox_id, filter_info->account_id);
                        err = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
                }
                break;
-       case EMAIL_FILTER_BLOCK :
+       case EMAIL_FILTER_BLOCK:
                filter_info->account_id = ALL_ACCOUNT;
                break;
-       case EMAIL_FILTER_DELETE :
+       case EMAIL_FILTER_DELETE:
        default:
                EM_DEBUG_LOG("filter_faction : [%d]", filter_info->faction);
                break;
@@ -7196,8 +7141,8 @@ INTERNAL_FUNC int emcore_add_rule(char *multi_user_name, email_rule_t *filter_in
 
        EM_DEBUG_LOG("filter_id : [%d]", filter_info->filter_id);
 
-       if (!emcore_notify_storage_event (NOTI_RULE_ADD, filter_info->account_id, filter_info->filter_id, NULL, 0))
-               EM_DEBUG_EXCEPTION ("emcore_notify_storage_event failed [NOTI_RULE_ADD]");
+       if (!emcore_notify_storage_event(NOTI_RULE_ADD, filter_info->account_id, filter_info->filter_id, NULL, 0))
+               EM_DEBUG_EXCEPTION("emcore_notify_storage_eventfailed [NOTI_RULE_ADD]");
 
 FINISH_OFF:
 
@@ -7240,7 +7185,7 @@ INTERNAL_FUNC int emcore_update_rule(char *multi_user_name, int filter_id, email
             parameter_string = em_malloc(sizeof(char) * parameter_string_length);
             if (parameter_string == NULL) {
                     err = EMAIL_ERROR_OUT_OF_MEMORY;
-                    EM_DEBUG_EXCEPTION("em_malloc failed for parameter_string");
+                    EM_DEBUG_EXCEPTION("em_mallocfailed for parameter_string");
                     goto FINISH_OFF;
             }
 
@@ -7263,7 +7208,7 @@ INTERNAL_FUNC int emcore_update_rule(char *multi_user_name, int filter_id, email
     }
 
     if (!emcore_notify_storage_event(NOTI_RULE_UPDATE, filter_info->account_id, filter_info->filter_id, parameter_string, 0))
-        EM_DEBUG_EXCEPTION("emcore_notify_storage_event failed [NOTI_RULE_UPDATE]");
+        EM_DEBUG_EXCEPTION("emcore_notify_storage_eventfailed [NOTI_RULE_UPDATE]");
 
 FINISH_OFF:
 
@@ -7290,7 +7235,7 @@ INTERNAL_FUNC int emcore_delete_rule(char *multi_user_name, int filter_id)
 
        emstorage_rule_tbl_t *filter_info = NULL;
 
-       if (filter_id <= 0)  {
+       if (filter_id <= 0) {
                EM_DEBUG_EXCEPTION(" fliter_id[%d]", filter_id);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -7311,7 +7256,7 @@ INTERNAL_FUNC int emcore_delete_rule(char *multi_user_name, int filter_id)
                parameter_string = em_malloc(sizeof(char) * parameter_string_length);
                if (parameter_string == NULL) {
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
-                       EM_DEBUG_EXCEPTION("em_malloc failed for parameter_string");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed for parameter_string");
                        goto FINISH_OFF;
                }
 
@@ -7333,8 +7278,8 @@ INTERNAL_FUNC int emcore_delete_rule(char *multi_user_name, int filter_id)
                goto FINISH_OFF;
        }
 
-       if (!emcore_notify_storage_event (NOTI_RULE_DELETE, 0, filter_id, parameter_string, 0))
-               EM_DEBUG_EXCEPTION ("emcore_notify_storage_event failed [NOTI_RULE_DELETE]");
+       if (!emcore_notify_storage_event(NOTI_RULE_DELETE, 0, filter_id, parameter_string, 0))
+               EM_DEBUG_EXCEPTION("emcore_notify_storage_eventfailed [NOTI_RULE_DELETE]");
 
 FINISH_OFF:
 
@@ -7481,7 +7426,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        if (search_filter[i].search_filter_key_value.integer_type_key_value == 0) {
                                temp_or_program = mail_newsearchor();
                                if (temp_or_program == NULL) {
-                                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                                        goto FINISH_OFF;
                                }
@@ -7523,7 +7468,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7534,7 +7479,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_BCC :
+               case EMAIL_SEARCH_FILTER_TYPE_BCC:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7550,7 +7495,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
+               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE:
                        EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
 
                        err = emcore_make_date_string_for_search(search_filter[i].search_filter_key_value.time_type_key_value,
@@ -7570,7 +7515,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_BODY :
+               case EMAIL_SEARCH_FILTER_TYPE_BODY:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7583,7 +7528,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_CC :
+               case EMAIL_SEARCH_FILTER_TYPE_CC:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7599,7 +7544,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7610,7 +7555,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7621,7 +7566,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FROM :
+               case EMAIL_SEARCH_FILTER_TYPE_FROM:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7637,7 +7582,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
+               case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7670,7 +7615,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON :
+               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON:
                        EM_DEBUG_LOG("time_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.time_type_key_value);
 
@@ -7691,7 +7636,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7700,7 +7645,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7711,7 +7656,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE :
+               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE:
                        EM_DEBUG_LOG("time_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.time_type_key_value);
 
@@ -7732,7 +7677,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
+               case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:
                        EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7748,7 +7693,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_TEXT :
+               case EMAIL_SEARCH_FILTER_TYPE_TEXT:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7761,7 +7706,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_TO :
+               case EMAIL_SEARCH_FILTER_TYPE_TO:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7777,7 +7722,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY :
+               case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7793,7 +7738,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER :
+               case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7801,7 +7746,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER :
+               case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7809,7 +7754,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
 
@@ -7820,7 +7765,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
 
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+               case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:
                    EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7844,13 +7789,13 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
-               case EMAIL_SEARCH_FILTER_TYPE_UID :
+               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO:
+               case EMAIL_SEARCH_FILTER_TYPE_UID:
                        EM_DEBUG_LOG("integer_type_key_value [%d]",
                                                        search_filter[i].search_filter_key_value.integer_type_key_value);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
+               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:
                        EM_DEBUG_LOG("string_type_key_value [%s]",
                                                        search_filter[i].search_filter_key_value.string_type_key_value);
 
@@ -7866,7 +7811,7 @@ static int create_searchpgm_from_filter_string(email_search_filter_t *search_fil
                        EM_SAFE_FREE(temp_string);
                        break;
 
-               default :
+               default:
                        EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", search_filter);
                        err = EMAIL_ERROR_INVALID_PARAM;
                        break;
@@ -7930,7 +7875,7 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        }
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        if (search_filter[i].search_filter_key_value.integer_type_key_value)
                                SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "ANSWERED ");
@@ -7939,14 +7884,14 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_BCC :
+               case EMAIL_SEARCH_FILTER_TYPE_BCC:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BCC \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
+               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE:
                        EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
                        emcore_make_date_string_for_search(search_filter[i].search_filter_key_value.time_type_key_value,
                                                                                                &time_string);
@@ -7955,21 +7900,21 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        EM_SAFE_FREE(time_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_BODY :
+               case EMAIL_SEARCH_FILTER_TYPE_BODY:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "BODY \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_CC :
+               case EMAIL_SEARCH_FILTER_TYPE_CC:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "CC \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        if (search_filter[i].search_filter_key_value.integer_type_key_value)
                                SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "DELETED ");
@@ -7979,7 +7924,7 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        if (search_filter[i].search_filter_key_value.integer_type_key_value)
                                SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FLAGGED ");
@@ -7989,14 +7934,14 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FROM :
+               case EMAIL_SEARCH_FILTER_TYPE_FROM:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "FROM \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
+               case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "KEYWORD \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
@@ -8020,7 +7965,7 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON :
+               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON:
                        EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
                        emcore_make_date_string_for_search(search_filter[i].search_filter_key_value.time_type_key_value,
                                                                                                &time_string);
@@ -8029,14 +7974,14 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        EM_SAFE_FREE(time_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        if (search_filter[i].search_filter_key_value.integer_type_key_value)
                                SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "RECENT ");
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        if (search_filter[i].search_filter_key_value.integer_type_key_value)
                                SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SEEN ");
@@ -8046,7 +7991,7 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE :
+               case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE:
                        EM_DEBUG_LOG("time_type_key_value [%d]", search_filter[i].search_filter_key_value.time_type_key_value);
                        emcore_make_date_string_for_search(search_filter[i].search_filter_key_value.time_type_key_value,
                                                                                                &time_string);
@@ -8055,46 +8000,46 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        EM_SAFE_FREE(time_string);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
+               case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:
                        EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "SUBJECT \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_TEXT :
+               case EMAIL_SEARCH_FILTER_TYPE_TEXT:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TEXT \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_TO :
+               case EMAIL_SEARCH_FILTER_TYPE_TO:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "TO \"%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY :
+               case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "HEADER x-priority %d ", search_filter[i].search_filter_key_value.integer_type_key_value);
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER :
+               case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER :
+               case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT :
+               case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME :
+               case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:
                    EM_DEBUG_LOG_SEC("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        SNPRINTF(temp_criteria, STRING_LENGTH_FOR_DISPLAY, "X-GM-RAW \"has:attachment filename:%s\" ",
                                                search_filter[i].search_filter_key_value.string_type_key_value);
@@ -8114,16 +8059,16 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
                        strncat(filter_string, temp_criteria, STRING_LENGTH_FOR_DISPLAY);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
-               case EMAIL_SEARCH_FILTER_TYPE_UID :
+               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO:
+               case EMAIL_SEARCH_FILTER_TYPE_UID:
                        EM_DEBUG_LOG("integer_type_key_value [%d]", search_filter[i].search_filter_key_value.integer_type_key_value);
                        break;
 
-               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
+               case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:
                        EM_DEBUG_LOG("string_type_key_value [%s]", search_filter[i].search_filter_key_value.string_type_key_value);
                        break;
 
-               default :
+               default:
                        EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", search_filter);
                        err = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
@@ -8136,7 +8081,7 @@ static int get_search_filter_string(email_search_filter_t *search_filter, int se
 
 FINISH_OFF:
 
-       if(output_filter_string)
+       if (output_filter_string)
                *output_filter_string = EM_SAFE_STRDUP(filter_string);
 
        EM_DEBUG_FUNC_END();
@@ -8215,22 +8160,20 @@ int emcore_search_mail_and_uids(MAILSTREAM *stream, email_search_filter_t *input
 
                if (!strncmp(response, tag, EM_SAFE_STRLEN(tag))) {
                        if (!strncmp(response + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
-                               EM_SAFE_FREE (response);
+                               EM_SAFE_FREE(response);
                                break;
-                       }
-                       else {  /*  'NO' or 'BAD' */
+                       } else {        /*  'NO' or 'BAD' */
                                err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;              /* EMAIL_ERROR_INVALID_RESPONSE; */
                                goto FINISH_OFF;
                        }
                }
 
-               if ((p = strstr(response, " SEARCH "))){
+               if ((p = strstr(response, " SEARCH "))) {
                        *p = '\0'; p  += strlen(" SEARCH ");
 
                        result = strtok(p, delims);
 
-                       while (result  != NULL)
-                       {
+                       while (result  != NULL) {
                                EM_DEBUG_LOG("UID VALUE DEEP is [%s]", result);
 
                                if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
@@ -8250,12 +8193,10 @@ int emcore_search_mail_and_uids(MAILSTREAM *stream, email_search_filter_t *input
 
                        EM_SAFE_FREE(response);
                        continue;
-               }
-               else if ((p = strstr(response, " SEARCH"))){
+               } else if ((p = strstr(response, " SEARCH"))) {
                        /* there is no mail */
                        continue;
-               }
-               else {
+               } else {
                        err = EMAIL_ERROR_INVALID_RESPONSE;
                        goto FINISH_OFF;
                }
@@ -8273,7 +8214,7 @@ int emcore_search_mail_and_uids(MAILSTREAM *stream, email_search_filter_t *input
                EM_DEBUG_LOG("uid_range_string [%s] ", uid_range_string);
 
                /* Get uids with flags */
-               if(!imap4_mailbox_get_uids(stream, uid_range_string, output_uid_list, &err)) {
+               if (!imap4_mailbox_get_uids(stream, uid_range_string, output_uid_list, &err)) {
                        EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -8287,9 +8228,9 @@ FINISH_OFF:
        if (uid_list_for_listing)
                emcore_free_uids(uid_list_for_listing, NULL);
 
-       EM_SAFE_FREE (response);
-       EM_SAFE_FREE (uid_range_string);
-       EM_SAFE_FREE (search_filter_string);
+       EM_SAFE_FREE(response);
+       EM_SAFE_FREE(uid_range_string);
+       EM_SAFE_FREE(search_filter_string);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
        return err;
@@ -8380,7 +8321,7 @@ INTERNAL_FUNC int emcore_search_on_server_ex(char *multi_user_name,
 
                uid_elem = em_malloc(sizeof(emcore_uid_list));
                if (uid_elem == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -8416,7 +8357,7 @@ INTERNAL_FUNC int emcore_search_on_server_ex(char *multi_user_name,
        /* Create the mailbox information for adding */
        search_mailbox = em_malloc(sizeof(emstorage_mailbox_tbl_t));
        if (search_mailbox == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -8486,7 +8427,7 @@ INTERNAL_FUNC int emcore_search_on_server_ex(char *multi_user_name,
                }
 
                if (!emcore_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_string, thread_id)) {
-                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_MAIL_ADD] failed");
                }
 
                if (new_mail_tbl_data) {
@@ -8603,7 +8544,7 @@ INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id,
 
        search_mailbox = em_malloc(sizeof(emstorage_mailbox_tbl_t));
        if (search_mailbox == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -8662,7 +8603,7 @@ INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id,
                }
 
                if (!emcore_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id)) {
-                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_MAIL_ADD] failed");
                }
 
                if (new_mail_tbl_data) {
@@ -8676,7 +8617,7 @@ INTERNAL_FUNC int emcore_search_on_server(char *multi_user_name, int account_id,
 FINISH_OFF:
 
        if (stream)
-               mail_close (stream);
+               mail_close(stream);
 
        if (uid_list)
                emcore_free_uids(uid_list, NULL);
index 736fe57..ee3d89c 100755 (executable)
 static int g_current_sync_account_id = 0;
 static char g_append_uid_rsp[129]; /* added for getting server response  */
 
-extern void imap_parse_body_structure (MAILSTREAM *stream, BODY *body, unsigned char **txtptr, IMAPPARSEDREPLY *reply);
+extern void imap_parse_body_structure(MAILSTREAM *stream, BODY *body, unsigned char **txtptr, IMAPPARSEDREPLY *reply);
 
 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
 static void emcore_free_email_partial_buffer(email_partial_buffer **partial_buffer, int item_count);
-static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size, int item_count);
+static email_partial_buffer *emcore_get_response_from_server(NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size, int item_count);
 #endif
 
 #ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
@@ -155,12 +155,10 @@ int pop3_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *er
                }
 
                *size = atoi(p + 1);
-       }
-       else if (*response == '-') {            /*  "- ERR" */
+       } else if (*response == '-') {          /*  "- ERR" */
                err = EMAIL_ERROR_POP3_LIST_FAILURE;
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                err = EMAIL_ERROR_INVALID_RESPONSE;
                goto FINISH_OFF;
        }
@@ -230,13 +228,11 @@ int imap4_mail_calc_rfc822_size(MAILSTREAM *stream, int msgno, int *size, int *e
                        if (!strncmp(response + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
                                EM_SAFE_FREE(response);
                                break;
-                       }
-                       else {          /*  'NO' or 'BAD' */
+                       } else {                /*  'NO' or 'BAD' */
                                err = EMAIL_ERROR_IMAP4_FETCH_SIZE_FAILURE;             /* EMAIL_ERROR_INVALID_RESPONSE; */
                                goto FINISH_OFF;
                        }
-               }
-               else {          /*  untagged response */
+               } else {                /*  untagged response */
                        if (*response == '*') {
                                if (!(t = strstr(response, "FETCH (RFC822.SIZE "))) {
                                        EM_SAFE_FREE(response);
@@ -333,12 +329,12 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e
                }
 
                if (*response == '+') {         /*  "+OK" */
-                       EM_SAFE_FREE (response);
+                       EM_SAFE_FREE(response);
                        continue;
                }
 
                if (*response == '.') {
-                       EM_SAFE_FREE (response);
+                       EM_SAFE_FREE(response);
                        break;
                }
 
@@ -358,13 +354,12 @@ int pop3_mailbox_get_uids(MAILSTREAM *stream, emcore_uid_list** uid_list, int *e
                                uid_elem->next = *uid_list;             /*  prepend new data to table */
 
                        *uid_list = uid_elem;
-               }
-               else {
+               } else {
                        err = EMAIL_ERROR_INVALID_RESPONSE;
                        goto FINISH_OFF;
                }
 
-               EM_SAFE_FREE (response);
+               EM_SAFE_FREE(response);
        }
 
        ret = true;
@@ -390,7 +385,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
        int command_length = 0;
        IMAPLOCAL *imaplocal = NULL;
        char tag[16];
-       char *command= NULL;
+       char *command = NULL;
        char *response = NULL;
        emcore_uid_list *uid_elem = NULL;
 
@@ -406,7 +401,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
                goto FINISH_OFF;
        }
 
-       if (stream->nmsgs == 0){
+       if (stream->nmsgs == 0) {
                err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
                goto FINISH_OFF;
        }
@@ -414,7 +409,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
        command_length = sizeof(char) * (EM_SAFE_STRLEN(input_target_uid_string) + sizeof(tag) + 100);
        command = em_malloc(command_length);
        if (command == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -462,10 +457,9 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
 
                if (!strncmp(response, tag, EM_SAFE_STRLEN(tag))) {
                        if (!strncmp(response + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
-                               EM_SAFE_FREE (response);
+                               EM_SAFE_FREE(response);
                                break;
-                       }
-                       else {          /*  'NO' or 'BAD' */
+                       } else {                /*  'NO' or 'BAD' */
                                err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;              /* EMAIL_ERROR_INVALID_RESPONSE; */
                                goto FINISH_OFF;
                        }
@@ -503,7 +497,7 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
                                        *s = '\0';
 
                                        if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
-                                               EM_DEBUG_EXCEPTION("em_malloc failed...");
+                                               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                                goto FINISH_OFF;
                                        }
@@ -520,14 +514,12 @@ int imap4_mailbox_get_uids(MAILSTREAM *stream, char *input_target_uid_string, em
                                                uid_elem->next = *uid_list;             /*  prepend new data to list */
 
                                        *uid_list = uid_elem;
-                               }
-                               else {
+                               } else {
                                        err = EMAIL_ERROR_INVALID_RESPONSE;
                                        goto FINISH_OFF;
                                }
                        }
-               }
-               else {
+               } else {
                        err = EMAIL_ERROR_INVALID_RESPONSE;
                        goto FINISH_OFF;
                }
@@ -630,10 +622,9 @@ int emcore_get_uids_order_by_datetime_from_imap_server(MAILSTREAM *stream, int c
 
                        if (!strncmp(response, tag, EM_SAFE_STRLEN(tag))) {
                                if (!strncmp(response + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
-                                       EM_SAFE_FREE (response);
+                                       EM_SAFE_FREE(response);
                                        break;
-                               }
-                               else {  /*  'NO' or 'BAD' */
+                               } else {        /*  'NO' or 'BAD' */
                                        err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;              /* EMAIL_ERROR_INVALID_RESPONSE; */
                                        goto FINISH_OFF;
                                }
@@ -644,8 +635,7 @@ int emcore_get_uids_order_by_datetime_from_imap_server(MAILSTREAM *stream, int c
 
                                result = strtok(p, delims);
 
-                               while (result  != NULL)
-                               {
+                               while (result  != NULL) {
                                        EM_DEBUG_LOG_DEV("UID VALUE DEEP is [%s]", result);
 
                                        if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
@@ -665,12 +655,10 @@ int emcore_get_uids_order_by_datetime_from_imap_server(MAILSTREAM *stream, int c
 
                                EM_SAFE_FREE(response);
                                continue;
-                       }
-                       else if ((p = strstr(response, " SEARCH"))){
+                       } else if ((p = strstr(response, " SEARCH"))) {
                                /* there is no mail */
                                continue;
-                       }
-                       else {
+                       } else {
                                err = EMAIL_ERROR_INVALID_RESPONSE;
                                goto FINISH_OFF;
                        }
@@ -689,7 +677,7 @@ int emcore_get_uids_order_by_datetime_from_imap_server(MAILSTREAM *stream, int c
        EM_DEBUG_LOG("uid_range_string [%s] ", uid_range_string);
 
        /* Get uids with flags */
-       if(!imap4_mailbox_get_uids(stream, uid_range_string, output_uid_list, &err)) {
+       if (!imap4_mailbox_get_uids(stream, uid_range_string, output_uid_list, &err)) {
                EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -699,8 +687,8 @@ FINISH_OFF:
        if (uid_list_for_listing)
                emcore_free_uids(uid_list_for_listing, NULL);
 
-       EM_SAFE_FREE (response);
-        EM_SAFE_FREE (uid_range_string);
+       EM_SAFE_FREE(response);
+        EM_SAFE_FREE(uid_range_string);
 
        EM_PROFILE_END(emcore_get_uids_order_by_datetime_from_imap_server);
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -747,7 +735,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui
 
        EM_DEBUG_LOG("RawTime Info [%lu]", RawTime);
 
-       timeinfo = localtime (&RawTime);
+       timeinfo = localtime(&RawTime);
        if (timeinfo == NULL) {
                EM_DEBUG_EXCEPTION("localtime failed");
                err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -759,7 +747,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui
        week_before_RawTime = RawTime - 604800;
 
        /* Reading the current timeinfo */
-       timeinfo = localtime (&week_before_RawTime);
+       timeinfo = localtime(&week_before_RawTime);
        if (timeinfo == NULL) {
                EM_DEBUG_EXCEPTION("localtime failed");
                err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -772,7 +760,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui
 
        mon = __em_get_month_in_string(timeinfo->tm_mon);
 
-       if (mon){
+       if (mon) {
                snprintf(date_string, 16, "%d-%s-%04d", timeinfo->tm_mday, mon, 1900 + timeinfo->tm_year);
                EM_DEBUG_LOG("DATE IS [ %s ] ", date_string);
                EM_SAFE_FREE(mon);
@@ -812,22 +800,20 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui
 
                if (!strncmp(response, tag, EM_SAFE_STRLEN(tag))) {
                        if (!strncmp(response + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
-                               EM_SAFE_FREE (response);
+                               EM_SAFE_FREE(response);
                                break;
-                       }
-                       else {  /*  'NO' or 'BAD' */
+                       } else {        /*  'NO' or 'BAD' */
                                err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;              /* EMAIL_ERROR_INVALID_RESPONSE; */
                                goto FINISH_OFF;
                        }
                }
 
-               if ((p = strstr(response, " SEARCH "))){
+               if ((p = strstr(response, " SEARCH "))) {
                    *p = '\0'; p  += strlen(" SEARCH ");
 
                    result = strtok(p, delims);
 
-                   while (result  != NULL)
-                   {
+                   while (result  != NULL) {
                                EM_DEBUG_LOG("UID VALUE DEEP is [%s]", result);
 
                                if (!(uid_elem = em_malloc(sizeof(emcore_uid_list)))) {
@@ -846,8 +832,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui
 
                        EM_SAFE_FREE(response);
                    return 1;
-               }
-               else {
+               } else {
                        err = EMAIL_ERROR_INVALID_RESPONSE;
                        goto FINISH_OFF;
                }
@@ -857,7 +842,7 @@ int imap4_mailbox_get_uids_by_timestamp(MAILSTREAM *stream, emcore_uid_list** ui
        ret = true;
 
 FINISH_OFF:
-       EM_SAFE_FREE (response);
+       EM_SAFE_FREE(response);
 
        if (err_code  != NULL)
                *err_code = err;
@@ -890,7 +875,7 @@ static int emcore_parse_header(char *rfc822_header, char **subject, char **from,
        memset(buf, 0x00, PARSE_BUFFER_LENGTH);
 
        for (len = EM_SAFE_STRLEN(rfc822_header), i = 0, j = 0; i < len; i++) {
-               if (rfc822_header[i] == CR && rfc822_header[i+1] == LF){
+               if (rfc822_header[i] == CR && rfc822_header[i+1] == LF) {
                        if (j + 3 < PARSE_BUFFER_LENGTH) /* '3' include CR LF NULL */
                                strncpy(buf + j, CRLF_STRING, PARSE_BUFFER_LENGTH - (j + 2)); /* '3' include CR LF */
                        else
@@ -915,7 +900,7 @@ static int emcore_parse_header(char *rfc822_header, char **subject, char **from,
                        if ((buf[0] == 'X' || buf[0] == 'x') && (buf[2] == 'P' || buf[2] == 'p') && (buf[9] == 'Y' || buf[9] == 'y')) {
                                em_upper_string(buf);
                                size_t len_2 = EM_SAFE_STRLEN(buf);
-                               if (len_2 >= 12){
+                               if (len_2 >= 12) {
                                        buf[len_2 - 2] = '\0';
                                        *priority = atoi(buf + 11);
                                        memset(buf, 0x00, PARSE_BUFFER_LENGTH);
@@ -1039,11 +1024,10 @@ static int emcore_get_mail_extra_info(MAILSTREAM *stream, int msgno, char **subj
        EM_PROFILE_BEGIN(MaiFetchHeader);
 #ifdef __FEATURE_HEADER_OPTIMIZATION__
        /* Check if header already available in cache */
-       if (stream && stream->cache && stream->cache[msgno-1]->private.msg.header.text.data){
+       if (stream && stream->cache && stream->cache[msgno-1]->private.msg.header.text.data) {
 
                rfc822_header = (char *) stream->cache[msgno-1]->private.msg.header.text.data;
-       }
-       else{
+       } else {
                EM_DEBUG_LOG("I couldn't find the header. I'll fetch the header from server again.");
                if (stream)
                        rfc822_header = mail_fetch_header(stream, msgno, NULL, NULL, &len, FT_PEEK);
@@ -1211,20 +1195,18 @@ static int emcore_get_uids_to_download(char *multi_user_name,
                        EM_DEBUG_EXCEPTION("pop3_mailbox_get_uids failed - %d", err);
                        goto FINISH_OFF;
                }
-       }
-       else {  /*  EMAIL_SERVER_TYPE_IMAP4 */
+       } else {        /*  EMAIL_SERVER_TYPE_IMAP4 */
                EM_DEBUG_LOG("nmsgs[%d]", ((MAILSTREAM *)stream)->nmsgs);
                if ((limit_count < ((MAILSTREAM *)stream)->nmsgs)) {
                        if ((err = emcore_get_uids_order_by_datetime_from_imap_server(stream,
                                                                                                                                                        limit_count,
-                                                                                                                                                       uid_list)) != EMAIL_ERROR_NONE ) {
+                                                                                                                                                       uid_list)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("emcore_get_uids_order_by_datetime_from_imap_server failed [%d]", err);
                                if (err  != EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER)
                                        goto FINISH_OFF;
                        }
-               }
-               else {
-                       if(!imap4_mailbox_get_uids(stream, NULL, uid_list, &err)) {
+               } else {
+                       if (!imap4_mailbox_get_uids(stream, NULL, uid_list, &err)) {
                                EM_DEBUG_EXCEPTION("imap4_mailbox_get_uids failed [%d]", err);
                                if (err  != EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER)
                                        goto FINISH_OFF;
@@ -1298,11 +1280,10 @@ static int emcore_get_uids_to_download(char *multi_user_name,
 
                if ((account->retrieval_mode & EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (uid_elem->flag.seen != 0)) {
                        /*  already seen */
-                       EM_SAFE_FREE (uid_elem->uid);
-                       EM_SAFE_FREE (uid_elem->internaldate);
-                       EM_SAFE_FREE (uid_elem);
-               }
-               else {
+                       EM_SAFE_FREE(uid_elem->uid);
+                       EM_SAFE_FREE(uid_elem->internaldate);
+                       EM_SAFE_FREE(uid_elem);
+               } else {
                        int to_be_downloaded = 1;
 
                        if (limit_count > 0 && uid_count >= limit_count) {
@@ -1322,7 +1303,7 @@ static int emcore_get_uids_to_download(char *multi_user_name,
                                                                   so it should not be downloaded, just check seen flag */
                                                                if (downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen ||
                                                                                downloaded_uids[i - 1].flags_flagged_field != uid_elem->flag.flagged) {
-                                                                       if(downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen) {
+                                                                       if (downloaded_uids[i - 1].flags_seen_field != uid_elem->flag.seen) {
                                                                                downloaded_uids[i - 1].sync_status = EMAIL_SYNC_STATUS_FLAG_CHANGED;
                                                                                downloaded_uids[i - 1].flags_seen_field = uid_elem->flag.seen;
                                                                        }
@@ -1398,8 +1379,8 @@ static int emcore_get_uids_to_download(char *multi_user_name,
                                }
                                uid_to_be_downloaded_count++;
                        } else {
-                               EM_SAFE_FREE (uid_elem->uid);
-                               EM_SAFE_FREE (uid_elem);
+                               EM_SAFE_FREE(uid_elem->uid);
+                               EM_SAFE_FREE(uid_elem);
                        }
                        uid_count++;
                }
@@ -1418,10 +1399,10 @@ static int emcore_get_uids_to_download(char *multi_user_name,
                                                                                                                input_mailbox_tbl->mailbox_id,
                                                                                                                &mail,
                                                                                                                true,
-                                                                                                               &err)){
+                                                                                                               &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_maildata_by_servermailid for uid[%s] Failed [%d] \n ",
                                                                        downloaded_uids[i].server_uid, err);
-                               if (err == EMAIL_ERROR_MAIL_NOT_FOUND){
+                               if (err == EMAIL_ERROR_MAIL_NOT_FOUND) {
                                        continue;
                                }
                        }
@@ -1440,8 +1421,7 @@ static int emcore_get_uids_to_download(char *multi_user_name,
 
                        /* Update badge count */
                        emcore_display_unread_in_badge(multi_user_name);
-               }
-               else if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
+               } else if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
                        /* set seen flag of downloaded mail */
                        if (downloaded_uids[i].sync_status == EMAIL_SYNC_STATUS_FLAG_CHANGED) {
                                if (!emcore_set_flags_field(multi_user_name,
@@ -1462,8 +1442,7 @@ static int emcore_get_uids_to_download(char *multi_user_name,
                                                                                        downloaded_uids[i].flags_seen_field,
                                                                                        &err)) {
                                        EM_DEBUG_EXCEPTION("emcore_set_flags_field failed [%d]", err);
-                               }
-                               else
+                               } else
                                        emcore_display_unread_in_badge(multi_user_name);
                        }
                }
@@ -1480,7 +1459,7 @@ static int emcore_get_uids_to_download(char *multi_user_name,
        ret = true;
 
 FINISH_OFF:
-       if (ret == false){
+       if (ret == false) {
                if (head_uid_elem)
                        emcore_free_uids(head_uid_elem, NULL);
        }
@@ -1661,7 +1640,7 @@ INTERNAL_FUNC int emcore_add_mail_to_mailbox(char *multi_user_name,
        if (err != EMAIL_ERROR_NONE)
                EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed.");
 
-       if (thread_id == -1){
+       if (thread_id == -1) {
                input_new_mail_tbl_data->thread_id = input_new_mail_tbl_data->mail_id;
                input_new_mail_tbl_data->thread_item_count = thread_item_count = 1;
        } else {
@@ -1770,7 +1749,7 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub
        char *p_input_full_address_from = NULL;
        ADDRESS *addr = NULL;
 
-       if (!input_full_address_from ) { /*input_subject could be null*/
+       if (!input_full_address_from) { /*input_subject could be null*/
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                return ret; /*prevent 54914*/
@@ -1780,7 +1759,7 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub
 
        rfc822_parse_adrlist(&addr, p_input_full_address_from, NULL);
 
-       if(addr) {
+       if (addr) {
                EM_DEBUG_LOG_SEC("rule : full_address_from[%s], addr->mailbox[%s], addr->host[%s]", p_input_full_address_from, addr->mailbox, addr->host);
 
                if (addr->mailbox)
@@ -1790,21 +1769,19 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub
                        len  += 2;
 
                if (!(from_address = em_malloc(len))) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed...");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed...");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
                SNPRINTF(from_address, len, "%s@%s", addr->mailbox, addr->host);
-       }
-       else  {
+       } else {
                EM_DEBUG_EXCEPTION("rfc822_parse_adrlist failed.");
                err = EMAIL_ERROR_INVALID_ADDRESS;
                goto FINISH_OFF;
        }
 
        for (i = 0; i < rule_count ; i++) {
-
                EM_DEBUG_LOG("rule[%d]: rule_id[%d], flag1[%d], action_type[%d]", i, rule[i].rule_id, rule[i].flag1, rule[i].action_type);
 
                if (!rule[i].flag1) { /*flag1 means "OFF(0)/ON(1)"*/
@@ -1812,18 +1789,17 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub
                }
 
                switch (rule[i].action_type) {
-               case EMAIL_FILTER_DELETE :
+               case EMAIL_FILTER_DELETE:
                        EM_DEBUG_LOG("Not support action type");
                        break;
 
-               case EMAIL_FILTER_BLOCK :
+               case EMAIL_FILTER_BLOCK:
                        if (rule[i].type == EMAIL_FILTER_SUBJECT) {
                                if (input_subject && rule[i].value) {
                                        if (RULE_TYPE_INCLUDES == rule[i].flag2) {
                                                if (strcasestr(input_subject, rule[i].value))
                                                        *blocked = true;
-                                       }
-                                       else if (RULE_TYPE_EXACTLY == rule[i].flag2) {
+                                       } else if (RULE_TYPE_EXACTLY == rule[i].flag2) {
                                                if (!strcasecmp(input_subject, rule[i].value))
                                                        *blocked = true;
                                        }
@@ -1835,8 +1811,7 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub
                                        if (RULE_TYPE_INCLUDES == rule[i].flag2) {
                                                if (strcasestr(from_address, rule[i].value2))
                                                        *blocked = true;
-                                       }
-                                       else if (RULE_TYPE_EXACTLY == rule[i].flag2) {
+                                       } else if (RULE_TYPE_EXACTLY == rule[i].flag2) {
                                                if (!strcasecmp(from_address, rule[i].value2))
                                                        *blocked = true;
                                        }
@@ -1861,8 +1836,7 @@ int emcore_check_rule(const char *input_full_address_from, const char *input_sub
                                if (RULE_TYPE_INCLUDES == rule[i].flag2) {
                                        if (strcasestr(from_address, rule[i].value2))
                                                *priority_sender = 1;
-                               }
-                               else if (RULE_TYPE_EXACTLY == rule[i].flag2) {
+                               } else if (RULE_TYPE_EXACTLY == rule[i].flag2) {
                                        if (!strcasecmp(from_address, rule[i].value2))
                                                *priority_sender = 1;
                                }
@@ -1933,7 +1907,7 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(char *multi_user_name,
        }
 
        if (!(temp_mail_tbl_data = em_malloc(sizeof(emstorage_mail_tbl_t)))) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1979,7 +1953,7 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(char *multi_user_name,
                char *charset = NULL;
                char *charset_end = NULL;
                char *charset_start = NULL;
-               if(g_str_has_prefix(input_envelope->subject, "=?")) {
+               if (g_str_has_prefix(input_envelope->subject, "=?")) {
                        charset_start = input_envelope->subject + 2;
                        charset_end = strstr(charset_start, "?");
                        if (charset_end) {
@@ -2047,19 +2021,16 @@ INTERNAL_FUNC int emcore_make_mail_tbl_data_from_envelope(char *multi_user_name,
 
        memset((void*)&temp_time_info, 0,  sizeof(struct tm));
 
-
-
-       zone_hour = mail_cache_element->zhours * (mail_cache_element->zoccident?-1:1);
+       zone_hour = mail_cache_element->zhours * (mail_cache_element->zoccident ? -1 : 1);
 
        temp_time_info.tm_sec  = mail_cache_element->seconds;
        temp_time_info.tm_min  = mail_cache_element->minutes + mail_cache_element->zminutes;
        temp_time_info.tm_hour = mail_cache_element->hours - zone_hour;
 
-       if(temp_time_info.tm_hour < 0) {
+       if (temp_time_info.tm_hour < 0) {
                temp_time_info.tm_mday = mail_cache_element->day - 1;
                temp_time_info.tm_hour += 24;
-       }
-       else
+       } else
                temp_time_info.tm_mday = mail_cache_element->day;
 
        temp_time_info.tm_mon  = mail_cache_element->month - 1;
@@ -2113,7 +2084,7 @@ FINISH_OFF:
        return ret;
 }
 
-INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
+INTERNAL_FUNC int emcore_sync_header(char *multi_user_name,
                                        emstorage_mailbox_tbl_t *input_mailbox_tbl,
                                        void **stream,
                                        emcore_uid_list **input_uid_list,
@@ -2130,7 +2101,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                                                        input_mailbox_tbl, input_uid_list, err_code);
 
        if (!stream) {
-               EM_DEBUG_EXCEPTION ("NULL stream");
+               EM_DEBUG_EXCEPTION("NULL stream");
                if (err_code)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -2177,12 +2148,11 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
        if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 && input_mailbox_tbl->local_yn == 1) {
                /* mailbox recovery starts */
                if (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) {
-                       if (!emcore_sync_mailbox_list (multi_user_name, account_id, "", event_handle, &err)) {
+                       if (!emcore_sync_mailbox_list(multi_user_name, account_id, "", event_handle, &err)) {
                                EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list error [%d] account_id [%d]", err, account_id);
                                goto FINISH_OFF;
                        }
-               }
-               else {
+               } else {
                        EM_DEBUG_EXCEPTION("because mailbox_name[%s] mailbox_type[%d] of account[%d] is "
                                                                "a local box, it cant be synced",
                                                                input_mailbox_tbl->mailbox_name, input_mailbox_tbl->mailbox_type, account_id);
@@ -2197,7 +2167,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
 #ifdef __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__
        int err_from_vconf = 0;
 
-       if ((err_from_vconf = vconf_set_int(VCONFKEY_EMAIL_SYNC_STATE, 1)) != 0 ) {
+       if ((err_from_vconf = vconf_set_int(VCONFKEY_EMAIL_SYNC_STATE, 1)) != 0) {
                EM_DEBUG_EXCEPTION("vconf_set_int failed (sync state) [%d]", err_from_vconf);
        }
 #endif /* __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__ */
@@ -2241,7 +2211,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                                                                                                input_mailbox_tbl->mailbox_id,
                                                                                                ((MAILSTREAM *)*stream)->nmsgs,
                                                                                                1,
-                                                                                               &err)){
+                                                                                               &err)) {
                EM_DEBUG_EXCEPTION("emstorage_update_mailbox_total_count failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -2267,8 +2237,8 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                                                                &rule,
                                                                true,
                                                                &err) || !rule) {
-                       if ( err != EMAIL_ERROR_FILTER_NOT_FOUND )
-                               EM_DEBUG_EXCEPTION ("emstorage_get_rule error [%d]", err);
+                       if (err != EMAIL_ERROR_FILTER_NOT_FOUND)
+                               EM_DEBUG_EXCEPTION("emstorage_get_rule error [%d]", err);
                }
        }
 
@@ -2289,7 +2259,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
        if (cancellable)
                FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
-       if (input_uid_list && *input_uid_list){
+       if (input_uid_list && *input_uid_list) {
                emcore_free_uids(*input_uid_list, NULL);
                *input_uid_list = uid_list;
        }
@@ -2313,11 +2283,10 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                        FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
 
                uid_elem = uid_list;
-               if (*stream && uid_elem){
+               if (*stream && uid_elem) {
                        EM_DEBUG_LOG("msgno : %d", uid_elem->msgno);
                        ((MAILSTREAM *)*stream)->nmsgs = uid_elem->msgno;
-               }
-               else{
+               } else {
                        EM_DEBUG_LOG("Uid List Null");
                }
                EM_DEBUG_LOG("Calling ... mail_fetch_fast. uid_range [%s]", uid_range);
@@ -2328,7 +2297,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
 
        /*  h.gahlaut@samsung.com :  Clear the event queue of partial body download thread before starting fetching new headers  */
 #ifndef __FEATURE_PARTIAL_BODY_FOR_POP3__
-       if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4){
+       if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) {
 #endif /*  __FEATURE_PARTIAL_BODY_FOR_POP3__ */
                /*  Partial body download feature is only for IMAP accounts  */
                if (false == emcore_clear_partial_body_thd_event_que(&err))
@@ -2338,22 +2307,21 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
 #endif /*  __FEATURE_PARTIAL_BODY_FOR_POP3__ */
        while (uid_elem) {
                EM_PROFILE_BEGIN(emCoreSyncHeaderEachMail);
-               EM_DEBUG_LOG("mail_fetchstructure_full  :  uid_elem->msgno[%d]", uid_elem->msgno);
+               EM_DEBUG_LOG("mail_fetchstructure_full :  uid_elem->msgno[%d]", uid_elem->msgno);
 
                env = NULL;
 
                if (uid_elem->msgno > ((MAILSTREAM *)*stream)->nmsgs) {
-                       EM_DEBUG_LOG ("WARN: msgno[%d] can't be greater than nmsgs[%d].",
+                       EM_DEBUG_LOG("WARN: msgno[%d] can't be greater than nmsgs[%d].",
                                        uid_elem->msgno, ((MAILSTREAM *)*stream)->nmsgs);
-               }
-               else{
+               } else {
 #ifdef __FEATURE_HEADER_OPTIMIZATION__
                        if (account_ref->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) /* Fetch env from cache in case of IMAP */
-                               env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 0);
+                               env = mail_fetchstructure_full(*stream, uid_elem->msgno, NULL, FT_PEEK, 0);
                        else /* Fetch header from network in case of POP */
-                               env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK, 1);
+                               env = mail_fetchstructure_full(*stream, uid_elem->msgno, NULL, FT_PEEK, 1);
 #else
-                       env = mail_fetchstructure_full (*stream, uid_elem->msgno, NULL, FT_PEEK);
+                       env = mail_fetchstructure_full(*stream, uid_elem->msgno, NULL, FT_PEEK);
 #endif
                }
 
@@ -2365,7 +2333,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                        int blocked = false;
                        int priority_sender = false;
 
-                       if (!emcore_make_mail_tbl_data_from_envelope (multi_user_name, account_id, *stream, env, uid_elem,
+                       if (!emcore_make_mail_tbl_data_from_envelope(multi_user_name, account_id, *stream, env, uid_elem,
                                                                                                                         &new_mail_tbl_data, &err) || !new_mail_tbl_data) {
                                EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_envelope failed [%d]", err);
                                goto CONTINUE_NEXT;
@@ -2413,7 +2381,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
 
                        if (priority_sender) {
                                new_mail_tbl_data->tag_id = PRIORITY_SENDER_TAG_ID;
-                               vip_total ++;
+                               vip_total++;
                        }
 
                        if (blocked && (input_mailbox_tbl->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
@@ -2427,8 +2395,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                                                                                                                        &err)) {
                                                EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
                                        }
-                               }
-                               else
+                               } else
                                        blocked = 0;
                        }
 
@@ -2519,8 +2486,8 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                                SNPRINTF(mailbox_id_param_string, 10, "%d", input_mailbox_tbl->mailbox_id);
                        }
 
-                       if (!emcore_notify_storage_event (NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id))
-                               EM_DEBUG_EXCEPTION ("emcore_notify_storage_event [NOTI_MAIL_ADD] failed");
+                       if (!emcore_notify_storage_event(NOTI_MAIL_ADD, account_id, mail_id, mailbox_id_param_string, thread_id))
+                               EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_MAIL_ADD] failed");
 
 #ifdef __FEATURE_BLOCKING_MODE__
                        /* Check the blocking mode */
@@ -2528,19 +2495,19 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
 
                        blocking_mode = emcore_get_blocking_mode_status();
                        if (!blocking_mode) {
-                               if ((err = emcore_check_blocking_mode (multi_user_name, new_mail_tbl_data->email_address_sender,
+                               if ((err = emcore_check_blocking_mode(multi_user_name, new_mail_tbl_data->email_address_sender,
                                                                                                                                                        &blocking_mode)) != EMAIL_ERROR_NONE) {
-                                       EM_DEBUG_EXCEPTION ("emcore_check_blocking_mode failed : [%d]", err);
+                                       EM_DEBUG_EXCEPTION("emcore_check_blocking_mode failed : [%d]", err);
                                }
 
                                if (blocking_mode)
-                                       emcore_set_blocking_mode_status (blocking_mode);
+                                       emcore_set_blocking_mode_status(blocking_mode);
                        }
 #endif /* __FEATURE_BLOCKING_MODE__ */
 
                        /* Set contact log */
                        switch (input_mailbox_tbl->mailbox_type) {
-                       case EMAIL_MAILBOX_TYPE_INBOX :
+                       case EMAIL_MAILBOX_TYPE_INBOX:
                                if ((err = emcore_set_received_contacts_log(multi_user_name, new_mail_tbl_data)) != EMAIL_ERROR_NONE) {
                                        EM_DEBUG_EXCEPTION("emcore_set_received_contacts_log failed : [%d]", err);
                                }
@@ -2564,7 +2531,7 @@ INTERNAL_FUNC int emcore_sync_header (char *multi_user_name,
                }
 
 CONTINUE_NEXT:
-               if (new_mail_tbl_data){
+               if (new_mail_tbl_data) {
                        emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
                        new_mail_tbl_data = NULL;
                }
@@ -2602,7 +2569,7 @@ FINISH_OFF:
                emstorage_stamp_last_sync_time_of_mailbox(multi_user_name, input_mailbox_tbl->mailbox_id, 1);
 
 #ifdef __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__
-       if ((err_from_vconf = vconf_set_int(VCONFKEY_EMAIL_SYNC_STATE, 0)) != 0 ) {
+       if ((err_from_vconf = vconf_set_int(VCONFKEY_EMAIL_SYNC_STATE, 0)) != 0) {
                EM_DEBUG_EXCEPTION("vconf_set_int failed (sync state) [%d]", err_from_vconf);
        }
 #endif /* __FEATURE_SUPPORT_SYNC_STATE_ON_NOTI_BAR__ */
@@ -2610,7 +2577,7 @@ FINISH_OFF:
        if (new_mail_tbl_data)
                emstorage_free_mail(&new_mail_tbl_data, 1, NULL);
 
-       if (uid_list != NULL){
+       if (uid_list != NULL) {
                emcore_free_uids(uid_list, NULL);
                /*  uid_list point to the same memory with input_mailbox_tbl->user_data.  */
                /*  input_mailbox_tbl->user_data should be set NULL if uid_list is freed */
@@ -2620,7 +2587,7 @@ FINISH_OFF:
 
        EM_SAFE_FREE(uid_range);
 
-       if(destination_mailbox)
+       if (destination_mailbox)
                emstorage_free_mailbox(&destination_mailbox, 1, NULL);
 
        if (rule  != NULL)
@@ -2643,7 +2610,7 @@ emcore_uid_list *__ReverseList(emcore_uid_list *uid_list)
        result = NULL;
        current = uid_list;
 
-       while (current != NULL){
+       while (current != NULL) {
                temp = current->next;
                current->next = result;
                result = current;
@@ -2690,15 +2657,14 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
                                                                                                mailbox->mailbox_id,
                                                                                                true,
                                                                                                (void **)&tmp_stream,
-                                                                                               &err)){
+                                                                                               &err)) {
                        EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed...");
 
                        goto FINISH_OFF;
                }
 
                stream = (MAILSTREAM *)tmp_stream;
-       }
-       else
+       } else
                stream = mail_stream;
 
        if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {              /*  POP3 */
@@ -2743,7 +2709,7 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
 
                        /*  replied success "+OK" */
                        if (*p == '+') {
-                               EM_SAFE_FREE (p);
+                               EM_SAFE_FREE(p);
                                continue;
                        }
 
@@ -2790,17 +2756,15 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
                                        fetch_data_p = fetch_data_p->next;
 
                                fetch_data_p->next = uid_elem;
-                       }
-                       else
+                       } else
                                *uid_list = uid_elem;
 
                        if (total)
                                ++(*total);
 
-                       EM_SAFE_FREE (p);
+                       EM_SAFE_FREE(p);
                }
-       }
-       else {          /*  IMAP */
+       } else {                /*  IMAP */
                IMAPLOCAL *imaplocal = NULL;
                char tag[16];
                char *s = NULL;
@@ -2840,13 +2804,13 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
                        /*  check that reply is reply to our command */
                        /*  format  :  "* 9 FETCH (UID 68)" */
                        if (!strstr(p, "FETCH (FLAGS")) {
-                               EM_SAFE_FREE (p);
+                               EM_SAFE_FREE(p);
                                continue;
                        }
 
                        if (for_delete == EM_CORE_GET_UIDS_FOR_NO_DELETE) {
                                if ((ref_account->retrieval_mode & EMAIL_IMAP4_RETRIEVAL_MODE_NEW) && (strstr(p, "\\Seen"))) {
-                                       EM_SAFE_FREE (p);
+                                       EM_SAFE_FREE(p);
                                        continue;
                                }
                        }
@@ -2891,8 +2855,7 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
                                }
 
                                *t = '\0';
-                       }
-                       else {
+                       } else {
                                err = EMAIL_ERROR_INVALID_RESPONSE;
                                goto FINISH_OFF;
                        }
@@ -2905,8 +2868,8 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
                                int i;
                                for (i = 0; i < count; ++i) {
                                        if (uid_elem->uid && !strcmp(uid_elem->uid, downloaded_uids[i].server_uid)) {
-                                               EM_SAFE_FREE (uid_elem->uid);
-                                               EM_SAFE_FREE (uid_elem);
+                                               EM_SAFE_FREE(uid_elem->uid);
+                                               EM_SAFE_FREE(uid_elem);
                                                break;
                                        }
                                }
@@ -2920,8 +2883,7 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
                                                fetch_data_p = fetch_data_p->next;
 
                                        fetch_data_p->next = uid_elem;
-                               }
-                               else {
+                               } else {
                                        *uid_list = uid_elem;
                                }
 
@@ -2929,7 +2891,7 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
                                        ++(*total);
                        }
 
-                       EM_SAFE_FREE (p);
+                       EM_SAFE_FREE(p);
                }
        }
 
@@ -2937,12 +2899,12 @@ int emcore_download_uid_all(char *multi_user_name, MAILSTREAM *mail_stream, emai
 
 FINISH_OFF:
        if (uid_elem && ret == false)
-               EM_SAFE_FREE (uid_elem);
+               EM_SAFE_FREE(uid_elem);
 
-       EM_SAFE_FREE (p);
+       EM_SAFE_FREE(p);
 
        if (!mail_stream && stream) {
-               stream = mail_close (stream);
+               stream = mail_close(stream);
        }
 
        if (ref_account) {
@@ -3002,8 +2964,7 @@ int emcore_download_imap_msgno(char *multi_user_name, email_internal_mailbox_t *
                }
 
                stream = (MAILSTREAM *)tmp_stream;
-       }
-       else
+       } else
                stream = mailbox->mail_stream;
 
        if (!stream || !(imaplocal = stream->local) || !imaplocal->netstream) {
@@ -3037,14 +2998,14 @@ int emcore_download_imap_msgno(char *multi_user_name, email_internal_mailbox_t *
                /*  check that reply is reply to our command */
                /*  format :  "* SEARCH 68", if not found, "* SEARCH" */
                if (!strstr(p, "SEARCH ") || (p[9] < '0' || p[9] > '9')) {
-                       EM_SAFE_FREE (p);
+                       EM_SAFE_FREE(p);
                        continue;
                }
 
                if (msgno)
                        *msgno = atoi(p+9);
 
-               EM_SAFE_FREE (p);
+               EM_SAFE_FREE(p);
 
                ret = true;
        }
@@ -3053,10 +3014,10 @@ int emcore_download_imap_msgno(char *multi_user_name, email_internal_mailbox_t *
                err = EMAIL_ERROR_MAIL_NOT_FOUND;
 
 FINISH_OFF:
-       EM_SAFE_FREE (p);
+       EM_SAFE_FREE(p);
 
        if (mailbox && !mailbox->mail_stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
 
        if (ref_account) {
@@ -3116,7 +3077,7 @@ int emcore_get_uid(emcore_uid_list *uid_list, int msgno, char **uid, int *err_co
 
        int ret = false, err = EMAIL_ERROR_NONE;
 
-       if (!uid || msgno <= 0 || !uid_list){
+       if (!uid || msgno <= 0 || !uid_list) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -3166,9 +3127,9 @@ int emcore_free_uids(emcore_uid_list *uid_list, int *err_code)
        while (uid_list) {
                p = uid_list;
                uid_list = uid_list->next;
-               EM_SAFE_FREE (p->uid);
-               EM_SAFE_FREE (p->internaldate);
-               EM_SAFE_FREE (p);
+               EM_SAFE_FREE(p->uid);
+               EM_SAFE_FREE(p->internaldate);
+               EM_SAFE_FREE(p);
        }
 
        ret = true;
@@ -3205,7 +3166,7 @@ INTERNAL_FUNC char *emcore_guess_charset(char *multi_user_name, char *source_str
        source_text.size = EM_SAFE_STRLEN(source_string);
        result_charset   = (CHARSET*)utf8_infercharset(&source_text);
 
-       if(result_charset) {
+       if (result_charset) {
                return EM_SAFE_STRDUP(result_charset->name);
        }
 
@@ -3224,24 +3185,24 @@ INTERNAL_FUNC char *emcore_guess_charset(char *multi_user_name, char *source_str
        }
 
        detector = ucsdet_open(&err);
-       if(U_FAILURE(err))
+       if (U_FAILURE(err))
                EM_DEBUG_LOG("ucsdet_open failed");
 
        ucsdet_setText(detector, source_string, EM_SAFE_STRLEN(source_string), &err);
-       if(U_FAILURE(err))
+       if (U_FAILURE(err))
                EM_DEBUG_LOG("ucsdet_setText failed");
 
        match = ucsdet_detectAll(detector, &count, &err);
-       if(U_FAILURE(err))
+       if (U_FAILURE(err))
                EM_DEBUG_LOG("ucsdet_detectAll failed");
 
        for (i = 0 ; i < count ; i++) {
                confidence = ucsdet_getConfidence(match[i], &err);
-               if(U_FAILURE(err))
+               if (U_FAILURE(err))
                        EM_DEBUG_LOG("ucsdet_getConfidence failed");
 
                charset = ucsdet_getName(match[i], &err);
-               if(U_FAILURE(err))
+               if (U_FAILURE(err))
                        EM_DEBUG_LOG("ucsdet_getName failed");
 
                if (most_confidence < confidence) {
@@ -3318,7 +3279,7 @@ INTERNAL_FUNC int emcore_sync_mail_by_message_id(char *multi_user_name,
                                                                                        mailbox_id,
                                                                                        false,
                                                                                        (void **)&stream,
-                                                                                       &err)){
+                                                                                       &err)) {
            EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed :  Mailbox open[%d]", err);
            goto FINISH_OFF;
        }
@@ -3368,7 +3329,7 @@ INTERNAL_FUNC int emcore_sync_mail_by_message_id(char *multi_user_name,
 
                if (!strncmp(response, tag, EM_SAFE_STRLEN(tag))) {
                        if (!strncmp(response + EM_SAFE_STRLEN(tag) + 1, "OK", 2)) {
-                               EM_SAFE_FREE (response);
+                               EM_SAFE_FREE(response);
                                break;
                        } else {        /*  'NO' or 'BAD' */
                                err = EMAIL_ERROR_IMAP4_FETCH_UID_FAILURE;              /* EMAIL_ERROR_INVALID_RESPONSE; */
@@ -3376,14 +3337,14 @@ INTERNAL_FUNC int emcore_sync_mail_by_message_id(char *multi_user_name,
                        }
                }
 
-               if ((p = strstr(response, " SEARCH "))){
+               if ((p = strstr(response, " SEARCH "))) {
                        *p = '\0'; p  += strlen(" SEARCH ");
 
                        server_uid = g_strdup(p);
 
                        EM_SAFE_FREE(response);
                        continue;
-               } else if ((p = strstr(response, " SEARCH"))){
+               } else if ((p = strstr(response, " SEARCH"))) {
                        /* there is no mail */
                        continue;
                } else {
@@ -3457,7 +3418,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
        }
 
        account_ref = emcore_get_account_reference(multi_user_name, mail_table_data->account_id, false);
-       if(account_ref == NULL || account_ref->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
+       if (account_ref == NULL || account_ref->incoming_server_type != EMAIL_SERVER_TYPE_IMAP4) {
                EM_DEBUG_EXCEPTION("This account doesn't support sync");
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -3470,7 +3431,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
 
        EM_DEBUG_LOG("mailbox_id [%d]", mail_table_data->mailbox_id);
 
-       if ((err = emstorage_get_mailbox_by_id(multi_user_name, mail_table_data->mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl){
+       if ((err = emstorage_get_mailbox_by_id(multi_user_name, mail_table_data->mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE || !mailbox_tbl) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -3491,7 +3452,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
            goto FINISH_OFF;
        }
 
-       if (!emcore_make_rfc822_file_from_mail(multi_user_name, mail_table_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fname, NULL, &err)){
+       if (!emcore_make_rfc822_file_from_mail(multi_user_name, mail_table_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fname, NULL, &err)) {
            EM_DEBUG_EXCEPTION(" emcore_make_rfc822_file_from_mail failed [%d]", err);
            goto FINISH_OFF;
        }
@@ -3513,7 +3474,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
        rewind(fp);
 
        /* get file length */
-       if(fseek(fp, 0, SEEK_END) != 0 || (len = ftell(fp)) == -1) {
+       if (fseek(fp, 0, SEEK_END) != 0 || (len = ftell(fp)) == -1) {
                EM_DEBUG_EXCEPTION("fseek or ftell failed");
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
@@ -3529,7 +3490,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
                                                                                        0,
                                                                                        true,
                                                                                        (void **)&stream,
-                                                                                       &err)){
+                                                                                       &err)) {
            EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed :  Mailbox open[%d]", err);
            goto FINISH_OFF;
        }
@@ -3554,7 +3515,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
        int data_size = 0;
        int sent_size = 0;
 
-       if (mail_table_data->flags_seen_field){
+       if (mail_table_data->flags_seen_field) {
                if (!mail_append_command(stream, long_enc_path, set_flags, NULL, &str)) {
                        EM_DEBUG_EXCEPTION("mail_append  failed -");
                        err = EMAIL_ERROR_IMAP4_APPEND_FAILURE;
@@ -3594,8 +3555,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
                        err = EMAIL_ERROR_IMAP4_APPEND_FAILURE;
                        goto FINISH_OFF;
                }
-       }
-       else{
+       } else {
                if (!mail_append_command(stream, long_enc_path, NULL, NULL, &str)) {
                        EM_DEBUG_EXCEPTION("mail_append  failed -");
                        err = EMAIL_ERROR_IMAP4_APPEND_FAILURE;
@@ -3665,7 +3625,7 @@ INTERNAL_FUNC int emcore_sync_mail_from_client_to_server(char *multi_user_name,
 FINISH_OFF:
 
 #ifdef __FEATURE_LOCAL_ACTIVITY__
-       if (ret){
+       if (ret) {
                emstorage_activity_tbl_t new_activity;
                memset(&new_activity, 0x00, sizeof(emstorage_activity_tbl_t));
                new_activity.activity_type = ACTIVITY_SAVEMAIL;
@@ -3675,7 +3635,7 @@ FINISH_OFF:
                new_activity.server_mailid = NULL;
                new_activity.src_mbox      = NULL;
 
-               if (!emcore_delete_activity(&new_activity, &err)){
+               if (!emcore_delete_activity(&new_activity, &err)) {
                        EM_DEBUG_EXCEPTION(">>>>>>Local Activity [ACTIVITY_SAVEMAIL] [%d] ", err);
                }
        }
@@ -3710,7 +3670,7 @@ FINISH_OFF:
        }
 
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
        return err;
@@ -3732,7 +3692,7 @@ INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream,
        email_account_t *account_ref = NULL;
        email_event_partial_body_thd pbd_event = {0, };
 
-       if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || 0 == input_maibox_id){
+       if (account_id < FIRST_ACCOUNT_ID || mail_id < 0 || NULL == uid || 0 == input_maibox_id) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -3770,12 +3730,11 @@ INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream,
        EM_DEBUG_LOG("pbd_event.account_id[%d], pbd_event.mail_id[%d], pbd_event.server_mail_id [%d]",
                                        pbd_event.account_id, pbd_event.mail_id , pbd_event.server_mail_id);
 
-       if (!emcore_insert_pbd_activity(&pbd_event, &pbd_event.activity_id, &err)){
+       if (!emcore_insert_pbd_activity(&pbd_event, &pbd_event.activity_id, &err)) {
                EM_DEBUG_EXCEPTION("Inserting Partial Body Download activity failed with error[%d]", err);
                goto FINISH_OFF;
-       }
-       else{
-               if (false == emcore_is_partial_body_thd_que_full()){
+       } else {
+               if (false == emcore_is_partial_body_thd_que_full()) {
                        /* h.gahaut :  Before inserting the event into event queue activity_type should be made 0
                        Because partial body thread differentiates events coming from DB and event queue
                        on the basis of activity_type and event_type fields */
@@ -3783,7 +3742,7 @@ INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream,
                        pbd_event.activity_type = 0;
                        pbd_event.event_type = EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD;
 
-                       if (!emcore_insert_partial_body_thread_event(&pbd_event, &err)){
+                       if (!emcore_insert_partial_body_thread_event(&pbd_event, &err)) {
                                EM_DEBUG_EXCEPTION("Inserting Partial body thread event failed with error[%d]", err);
                                goto FINISH_OFF;
                        }
@@ -3791,8 +3750,7 @@ INTERNAL_FUNC int emcore_initiate_pbd(char *multi_user_name, MAILSTREAM *stream,
                        /*h.gahlaut :  Partial body thread has created a copy of event for itself so this local event should be freed here*/
                        if (!emcore_free_partial_body_thd_event(&pbd_event, &err))
                                EM_DEBUG_EXCEPTION("Freeing Partial body thread event failed with error[%d]", err);
-               }
-               else{
+               } else {
                        EM_DEBUG_LOG(" Activity inserted only in DB .. Queue is Full");
                }
        }
@@ -3953,11 +3911,9 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
        EM_DEBUG_LOG("Start of emcore_get_section_for_partial_download, item_count = %d ", item_count);
 
        /* For constructing UID list which is having 10 UID or less at a time */
-       for (j = 0, stSectionNo = pbd_event; (stSectionNo  != NULL && j < item_count); j++)
-       {
+       for (j = 0, stSectionNo = pbd_event; (stSectionNo != NULL && j < item_count); j++) {
                /* delete log before uploading master branch. it is flooding */
-
-               if (i32_index >= UID_RANGE_STRING_LENGTH){
+               if (i32_index >= UID_RANGE_STRING_LENGTH) {
                        EM_DEBUG_EXCEPTION("String length exceeded its limitation!");
                        goto FINISH_OFF;
                }
@@ -3987,7 +3943,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
        imap_response = emcore_get_response_from_server(imaplocal->netstream,
                        imap_tag, &reply_from_server, input_download_size, item_count);
 
-       if (!imap_response || !reply_from_server ) {
+       if (!imap_response || !reply_from_server) {
                EM_DEBUG_EXCEPTION(" Invalid response from emcore_get_response_from_server");
                goto FINISH_OFF;
        }
@@ -3998,7 +3954,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                total_attachment_size = 0;
                attachment_num = 0;
 
-               if(!(imap_response[i].bodystructure) || imap_response[i].bodystructure_len <= 0) continue;
+               if (!(imap_response[i].bodystructure) || imap_response[i].bodystructure_len <= 0) continue;
 
                /* Search the account id of pbd_event */
                for (temp_count = 0; temp_count <= item_count && pbd_event[temp_count].server_mail_id != imap_response[i].uid_no; temp_count++)
@@ -4048,7 +4004,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                EM_SAFE_FREE(fulltext);
 
                if (!(cnt_info = em_malloc(sizeof(struct _m_content_info)))) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed...");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed...");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -4092,7 +4048,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                }
 
                /* message1 is multipart? */
-               if (GMIME_IS_MULTIPART (message1->mime_part)) {
+               if (GMIME_IS_MULTIPART(message1->mime_part)) {
 
                        /* Fill up mime part of message1 using bodystructure info */
                        emcore_gmime_construct_multipart((GMimeMultipart *)message1->mime_part, body, "1", &total_mail_size);
@@ -4209,7 +4165,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                        g_mime_message_foreach(message1, emcore_gmime_imap_parse_foreach_cb, (gpointer)cnt_info);
 
 
-               } else if (GMIME_IS_PART (message1->mime_part)) {
+               } else if (GMIME_IS_PART(message1->mime_part)) {
                        GMimeDataWrapper *content = NULL;
                        GMimePart *single_part = GMIME_PART(message1->mime_part);
 
@@ -4219,7 +4175,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                        stream1 = g_mime_stream_mem_new_with_buffer(imap_response[i].bodytext, imap_response[i].bodytext_len);
                        //parser1 = g_mime_parser_new_with_stream(stream1);
                        content = g_mime_data_wrapper_new_with_stream(stream1, single_part->encoding);
-                       if (stream1) g_object_unref (stream1);
+                       if (stream1) g_object_unref(stream1);
 
                        g_mime_part_set_content_object(single_part, content);
                        if (content) g_object_unref(content);
@@ -4344,8 +4300,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                        if (!emstorage_move_file(cnt_info->text.plain, move_buf, false, &err))  {
                                EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
                                mail->file_path_plain = NULL;
-                       }
-                       else
+                       } else
                                mail->file_path_plain = EM_SAFE_STRDUP(path_buf);
                        EM_DEBUG_LOG_SEC("mail->file_path_plain [%s]", mail->file_path_plain);
                }
@@ -4389,8 +4344,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                        if (!emstorage_move_file(cnt_info->text.html, move_buf, false, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
                                mail->file_path_html = NULL;
-                       }
-                       else
+                       } else
                                mail->file_path_html = EM_SAFE_STRDUP(path_buf);
                        g_free(charset_html_text);
                }
@@ -4483,8 +4437,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                                                                                                                        &err))
                                                                EM_DEBUG_EXCEPTION("emstorage_add_attachment failed - %d", err);
                                                }
-                                       }
-                                       else {
+                                       } else {
                                                if (temp_file->save)
                                                        g_remove(temp_file->save);
                                        }
@@ -4506,7 +4459,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                EM_DEBUG_LOG("mail_id [%d] body_download_status [%d]", mail->mail_id, mail->body_download_status);
 
                /* Get preview text */
-               if ( (err = emcore_get_preview_text_from_file(pbd_event[temp_count].multi_user_name,
+               if ((err = emcore_get_preview_text_from_file(pbd_event[temp_count].multi_user_name,
                                                         mail->file_path_plain,
                                                         mail->file_path_html,
                                                         MAX_PREVIEW_TEXT_LENGTH,
@@ -4566,7 +4519,7 @@ static int emcore_gmime_download_imap_partial_mail_body(MAILSTREAM *stream, int
                                                                                                pbd_event[temp_count].account_id,
                                                                                                pbd_event[temp_count].mail_id,
                                                                                                pbd_event[temp_count].activity_id,
-                                                                                               &err)){
+                                                                                               &err)) {
                        EM_DEBUG_EXCEPTION("emcore_delete_pbd_activity failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4582,7 +4535,7 @@ FINISH_OFF:
        if (true != ret)
                EM_DEBUG_EXCEPTION("Failed download for the uid list %s", command);
 
-       if(reply_from_server) {
+       if (reply_from_server) {
                EM_SAFE_FREE(reply_from_server->key);
                EM_SAFE_FREE(reply_from_server->line);
                EM_SAFE_FREE(reply_from_server->tag);
@@ -4660,7 +4613,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body_for_pop3(MAILSTREAM *st
                        goto FINISH_OFF;
                }
 
-               if (false == emcore_delete_pbd_activity(pbd_event[i].multi_user_name, pbd_event[i].account_id, pbd_event[i].mail_id, pbd_event[i].activity_id, &err)){
+               if (false == emcore_delete_pbd_activity(pbd_event[i].multi_user_name, pbd_event[i].account_id, pbd_event[i].mail_id, pbd_event[i].activity_id, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_delete_pbd_activity failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -4696,7 +4649,7 @@ INTERNAL_FUNC int emcore_download_bulk_partial_mail_body(MAILSTREAM *stream, ema
 
        auto_download_size = (pbd_account_tbl->auto_download_size < 4096) ? 4096 : pbd_account_tbl->auto_download_size;
 
-       switch (pbd_account_tbl->incoming_server_type){
+       switch (pbd_account_tbl->incoming_server_type) {
                case EMAIL_SERVER_TYPE_IMAP4:
                        ret = emcore_gmime_download_imap_partial_mail_body(stream, auto_download_size, pbd_event, item_count, &err);
                        break;
@@ -4743,7 +4696,7 @@ static void emcore_free_email_partial_buffer(email_partial_buffer **partial_buff
        EM_DEBUG_FUNC_END();
 }
 
-static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size, int item_count)
+static email_partial_buffer *emcore_get_response_from_server(NETSTREAM *nstream, char *tag, IMAPPARSEDREPLY **reply, int input_download_size, int item_count)
 {
        EM_DEBUG_FUNC_BEGIN();
 
@@ -4772,7 +4725,7 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
 
        server_response = (email_partial_buffer *)em_malloc(sizeof(email_partial_buffer) * item_count);
        if (NULL == server_response) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                return NIL;
        }
 
@@ -4801,7 +4754,7 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
                                server_response[count].rfc822header_len = rfc822header_size;
                                server_response[count].rfc822header = em_malloc(server_response[count].rfc822header_len + 1);
                                if (server_response[count].rfc822header == NULL) {
-                                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                                        goto FINISH_OFF;
                                }
 
@@ -4831,7 +4784,7 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
                                server_response[count].bodystructure_len = p_bodystructure_end - p_bodystructure;
                                server_response[count].bodystructure = em_malloc(server_response[count].bodystructure_len + 1);
                                if (server_response[count].bodystructure == NULL) {
-                                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                                        goto FINISH_OFF;
                                }
                                SNPRINTF(server_response[count].bodystructure, server_response[count].bodystructure_len, "%s", p_bodystructure);
@@ -4849,7 +4802,7 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
                                server_response[count].bodytext_len = (body_size > input_download_size) ? input_download_size : body_size;
                                server_response[count].bodytext = em_malloc(server_response[count].bodytext_len + 1);
                                if (server_response[count].bodytext == NULL) {
-                                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                                        goto FINISH_OFF;
                                }
 
@@ -4875,12 +4828,12 @@ static email_partial_buffer *emcore_get_response_from_server (NETSTREAM *nstream
                /* get tag and result */
                if (strncmp(cur_line, tag, EM_SAFE_STRLEN(tag)) == 0) {
                        ret_reply = em_malloc(sizeof(IMAPPARSEDREPLY));
-                       if (!ret_reply){
-                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                       if (!ret_reply) {
+                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                goto FINISH_OFF;
                        }
 
-                       if(reply)
+                       if (reply)
                                *reply = ret_reply;
 
                        if (strncmp(cur_line + EM_SAFE_STRLEN(tag) + 1, "OK", 2) == 0) {
@@ -4909,7 +4862,7 @@ FINISH_OFF:
        EM_SAFE_FREE(cur_line);
        EM_SAFE_FREE(full_line);
 
-       if (!ret || count != item_count ) {
+       if (!ret || count != item_count) {
                EM_DEBUG_EXCEPTION("emcore_get_response_from_server may be failed ret[%d] count[%d]", ret, count);
                emcore_free_email_partial_buffer(&server_response, item_count);
        }
index e4b9dab..2098dbf 100755 (executable)
@@ -66,7 +66,7 @@ int emcore_imap4_send_command(MAILSTREAM *stream, imap4_cmd_t cmd_type, int *err
 int emcore_pop3_send_command(MAILSTREAM *stream, pop3_cmd_t cmd_type, int *err_code);
 
 /* thread local variable for stream reuse */
-__thread GListg_recv_stream_list = NULL;
+__thread GList *g_recv_stream_list = NULL;
 typedef struct {
        int account_id;
        int mailbox_id;
@@ -102,8 +102,8 @@ email_connection_info_t* emcore_get_connection_info_by_account_id(int account_id
        EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id);
        email_connection_info_t *connection_info = g_connection_info_list;
 
-       while(connection_info) {
-               if(connection_info->account_id == account_id)
+       while (connection_info) {
+               if (connection_info->account_id == account_id)
                        break;
                connection_info = connection_info->next;
        }
@@ -117,26 +117,25 @@ int emcore_append_connection_info(email_connection_info_t *new_connection_info)
        EM_DEBUG_FUNC_BEGIN("new_connection_info [%p]", new_connection_info);
        email_connection_info_t *connection_info = g_connection_info_list;
 
-       if(!new_connection_info) {
+       if (!new_connection_info) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
-       if(emcore_get_connection_info_by_account_id(new_connection_info->account_id)) {
+       if (emcore_get_connection_info_by_account_id(new_connection_info->account_id)) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_ALREADY_EXISTS");
                return EMAIL_ERROR_ALREADY_EXISTS;
        }
 
-       if(connection_info) {
-               while(connection_info) {
-                       if(connection_info->next == NULL) {
+       if (connection_info) {
+               while (connection_info) {
+                       if (connection_info->next == NULL) {
                                connection_info->next = new_connection_info;
                                new_connection_info->next = NULL;
                        }
                        connection_info = connection_info->next;
                }
-       }
-       else {
+       } else {
                new_connection_info->next = NULL;
                g_connection_info_list = new_connection_info;
        }
@@ -150,12 +149,11 @@ INTERNAL_FUNC int emcore_remove_connection_info(int account_id)
        EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id);
        email_connection_info_t *connection_info = g_connection_info_list, *prev_connection_info = NULL;
 
-       while(connection_info) {
-               if(connection_info->account_id == account_id) {
-                       if(prev_connection_info) {
+       while (connection_info) {
+               if (connection_info->account_id == account_id) {
+                       if (prev_connection_info) {
                                prev_connection_info->next = connection_info->next;
-                       }
-                       else {
+                       } else {
                                g_connection_info_list = connection_info->next;
                        }
                        EM_SAFE_FREE(connection_info);
@@ -172,45 +170,45 @@ INTERNAL_FUNC int emcore_remove_connection_info(int account_id)
 #endif /* __FEATURE_KEEP_CONNECTION__ */
 
 
-INTERNAL_FUNC void emcore_close_recv_stream_list (void)
+INTERNAL_FUNC void emcore_close_recv_stream_list(void)
 {
        EM_DEBUG_FUNC_BEGIN();
-       GListcur = g_recv_stream_list;
-       email_recv_stream_list_tdata = NULL;
+       GList *cur = g_recv_stream_list;
+       email_recv_stream_list_t *data = NULL;
 
-       while(cur) {
+       while (cur) {
                data = cur->data;
-               if(data) *(data->mail_stream) = mail_close (*(data->mail_stream));
-               g_recv_stream_list = g_list_delete_link (g_recv_stream_list, cur);
-               g_free (data);
+               if (data) *(data->mail_stream) = mail_close(*(data->mail_stream));
+               g_recv_stream_list = g_list_delete_link(g_recv_stream_list, cur);
+               g_free(data);
                cur = g_recv_stream_list;
        }
 
        EM_DEBUG_FUNC_END();
 }
 
-INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (char *multi_user_name, int account_id, int mailbox_id, int *error)
+INTERNAL_FUNC MAILSTREAM **emcore_get_recv_stream(char *multi_user_name, int account_id, int mailbox_id, int *error)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
-       GListcur = g_recv_stream_list;
-       email_recv_stream_list_tdata = NULL;
-       MAILSTREAM** ret = NULL;
+       GList *cur = g_recv_stream_list;
+       email_recv_stream_list_t *data = NULL;
+       MAILSTREAM **ret = NULL;
        int err = EMAIL_ERROR_NONE;
        email_account_t *ref_account = NULL;
 
-       if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false)))   {
+       if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
        }
 
-       for ( ; cur; cur = g_list_next(cur)) {
+       for (; cur; cur = g_list_next(cur)) {
                data = cur->data;
                if (data->account_id == account_id && data->mailbox_id == mailbox_id) {
                        if (data->mail_stream == NULL || *(data->mail_stream) == NULL) {
-                               EM_DEBUG_LOG ("mail_stream was closed before");
-                               g_recv_stream_list = g_list_delete_link (g_recv_stream_list, cur);
-                               g_free (data);
+                               EM_DEBUG_LOG("mail_stream was closed before");
+                               g_recv_stream_list = g_list_delete_link(g_recv_stream_list, cur);
+                               g_free(data);
                                break;
                        }
 
@@ -218,31 +216,28 @@ INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (char *multi_user_name, int ac
                                /*  send NOOP command */
                                if (!emcore_imap4_send_command(*(data->mail_stream), IMAP4_CMD_NOOP, &err)) {
                                        EM_DEBUG_LOG("imap4_send_command failed [%d]", err);
-                                       EM_DEBUG_LOG ("mail_stream is not reusable");
-                                       *(data->mail_stream) = mail_close (*(data->mail_stream));
-                                       g_recv_stream_list = g_list_delete_link (g_recv_stream_list, cur);
-                                       g_free (data);
+                                       EM_DEBUG_LOG("mail_stream is not reusable");
+                                       *(data->mail_stream) = mail_close(*(data->mail_stream));
+                                       g_recv_stream_list = g_list_delete_link(g_recv_stream_list, cur);
+                                       g_free(data);
                                        break;
-                               }
-                               else {
-                                       EM_DEBUG_LOG ("reusable mail_stream found");
+                               } else {
+                                       EM_DEBUG_LOG("reusable mail_stream found");
                                        emcore_free_account(ref_account); /* prevent */
                                        EM_SAFE_FREE(ref_account);
                                        return data->mail_stream;
                                }
-                       }
-                       else if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
+                       } else if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) {
                                /*  send NOOP command */
                                if (!emcore_pop3_send_command(*(data->mail_stream), POP3_CMD_NOOP, &err)) {
                                        EM_DEBUG_LOG("emcore_pop3_send_command failed [%d]", err);
-                                       EM_DEBUG_LOG ("mail_stream is not reusable");
-                                       *(data->mail_stream) = mail_close (*(data->mail_stream));
-                                       g_recv_stream_list = g_list_delete_link (g_recv_stream_list, cur);
-                                       g_free (data);
+                                       EM_DEBUG_LOG("mail_stream is not reusable");
+                                       *(data->mail_stream) = mail_close(*(data->mail_stream));
+                                       g_recv_stream_list = g_list_delete_link(g_recv_stream_list, cur);
+                                       g_free(data);
                                        break;
-                               }
-                               else {
-                                       EM_DEBUG_LOG ("reusable mail_stream found");
+                               } else {
+                                       EM_DEBUG_LOG("reusable mail_stream found");
                                        emcore_free_account(ref_account); /* prevent */
                                        EM_SAFE_FREE(ref_account);
                                        return data->mail_stream;
@@ -251,9 +246,9 @@ INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (char *multi_user_name, int ac
                }
        }
 
-       ret = em_malloc (sizeof(MAILSTREAM*));
+       ret = em_malloc(sizeof(MAILSTREAM*));
        if (!ret) {
-               EM_DEBUG_EXCEPTION("em_malloc error");
+               EM_DEBUG_EXCEPTION("em_mallocerror");
                goto FINISH_OFF;
        }
 
@@ -268,10 +263,10 @@ INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (char *multi_user_name, int ac
                goto FINISH_OFF;
        }
 
-       email_recv_stream_list_t *node = em_malloc (sizeof(email_recv_stream_list_t));
+       email_recv_stream_list_t *node = em_malloc(sizeof(email_recv_stream_list_t));
        if (!node) {
-               EM_DEBUG_EXCEPTION ("em_malloc error");
-               *ret = mail_close (*ret);
+               EM_DEBUG_EXCEPTION("em_mallocerror");
+               *ret = mail_close(*ret);
                EM_SAFE_FREE(ret);
                goto FINISH_OFF;
        }
@@ -280,7 +275,7 @@ INTERNAL_FUNC MAILSTREAM** emcore_get_recv_stream (char *multi_user_name, int ac
        node->mailbox_id = mailbox_id;
        node->mail_stream = ret;
 
-       g_recv_stream_list = g_list_prepend (g_recv_stream_list, node);
+       g_recv_stream_list = g_list_prepend(g_recv_stream_list, node);
 
 FINISH_OFF:
 
@@ -307,7 +302,7 @@ INTERNAL_FUNC int emcore_get_mailbox_list(char *multi_user_name, int account_id,
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], p_count[%p], err_code[%p]",
                                                        account_id, mailbox_list, p_count, err_code);
 
-       if (account_id <= 0 || !mailbox_list || !p_count)  {
+       if (account_id <= 0 || !mailbox_list || !p_count) {
                EM_DEBUG_EXCEPTION("PARAM Failed account_id[%d], mailbox_list[%p], p_count[%p]",
                                                        account_id, mailbox_list, p_count);
                if (err_code != NULL)
@@ -330,13 +325,13 @@ INTERNAL_FUNC int emcore_get_mailbox_list(char *multi_user_name, int account_id,
 
        if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id,
                                                                        EMAIL_MAILBOX_ALL, EMAIL_MAILBOX_SORT_BY_NAME_ASC,
-                                                                       &count, &local_mailbox_list, true, &error))  {
+                                                                       &count, &local_mailbox_list, true, &error)) {
                EM_DEBUG_EXCEPTION(" emstorage_get_mailbox failed - %d", error);
                goto FINISH_OFF;
        }
 
-       if (count > 0)  {
-               if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * count)))  {
+       if (count > 0) {
+               if (!(*mailbox_list = em_malloc(sizeof(email_mailbox_t) * count))) {
                        EM_DEBUG_EXCEPTION(" mailloc failed...");
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -344,14 +339,13 @@ INTERNAL_FUNC int emcore_get_mailbox_list(char *multi_user_name, int account_id,
 
                memset(*mailbox_list, 0x00, (sizeof(email_mailbox_t) * count));
 
-               for (i = 0; i < count; i++)  {
+               for (i = 0; i < count; i++) {
                        em_convert_mailbox_tbl_to_mailbox(local_mailbox_list + i, (*mailbox_list) + i);
                }
-       }
-       else
+       } else
                mailbox_list = NULL;
 
-       * p_count = count;
+       *p_count = count;
 
        ret = true;
 
@@ -378,7 +372,7 @@ int emcore_get_mailbox_list_to_be_sync(char *multi_user_name, int account_id, em
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], p_count[%p], err_code[%p]", account_id, mailbox_list, p_count, err_code);
 
-       if (account_id <= 0 || !mailbox_list || !p_count)  {
+       if (account_id <= 0 || !mailbox_list || !p_count) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_list[%p], p_count[%p]", account_id, mailbox_list, p_count);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -401,13 +395,13 @@ int emcore_get_mailbox_list_to_be_sync(char *multi_user_name, int account_id, em
 
        if (!emstorage_get_mailbox_list(multi_user_name, ref_account->account_id, 0,
                                                                        EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &count,
-                                                                       &mailbox_tbl_list, true, &error))  {
+                                                                       &mailbox_tbl_list, true, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed - %d", error);
                goto FINISH_OFF;
        }
 
-       if (count > 0)  {
-               if (!(tmp_mailbox_list = em_malloc(sizeof(email_mailbox_t) * count)))  {
+       if (count > 0) {
+               if (!(tmp_mailbox_list = em_malloc(sizeof(email_mailbox_t) * count))) {
                        EM_DEBUG_EXCEPTION("malloc failed...");
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -415,11 +409,10 @@ int emcore_get_mailbox_list_to_be_sync(char *multi_user_name, int account_id, em
 
                memset(tmp_mailbox_list, 0x00, (sizeof(email_mailbox_t) * count));
 
-               for (i = 0; i < count; i++)  {
+               for (i = 0; i < count; i++) {
                        em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, tmp_mailbox_list + i);
                }
-       }
-       else
+       } else
                tmp_mailbox_list = NULL;
        *p_count = count;
        ret = true;
@@ -449,13 +442,13 @@ INTERNAL_FUNC int emcore_get_mail_count(char *multi_user_name, email_mailbox_t *
        int ret = false;
        int err = EMAIL_ERROR_NONE;
 
-       if (!mailbox)  {
+       if (!mailbox) {
                EM_DEBUG_EXCEPTION(" mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if (!emstorage_get_mail_count(multi_user_name, mailbox->account_id, mailbox->mailbox_id, total, unseen, true, &err))  {
+       if (!emstorage_get_mail_count(multi_user_name, mailbox->account_id, mailbox->mailbox_id, total, unseen, true, &err)) {
                EM_DEBUG_EXCEPTION(" emstorage_get_mail_count failed - %d", err);
                goto FINISH_OFF;
        }
@@ -482,7 +475,7 @@ INTERNAL_FUNC int emcore_create_mailbox(char *multi_user_name, email_mailbox_t *
        int incomming_server_type = 0;
        int mail_slot_size = 25;
 
-       if (new_mailbox == NULL || new_mailbox->mailbox_name == NULL)  {
+       if (new_mailbox == NULL || new_mailbox->mailbox_name == NULL) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -490,8 +483,7 @@ INTERNAL_FUNC int emcore_create_mailbox(char *multi_user_name, email_mailbox_t *
        if (server_type > 0 && slot_size > 0) {
                incomming_server_type = server_type;
                mail_slot_size = slot_size;
-       }
-       else {
+       } else {
                account_ref = emcore_get_account_reference(multi_user_name, new_mailbox->account_id, false);
                if (!account_ref) {
                        EM_DEBUG_EXCEPTION("Invalid account_id [%d]", new_mailbox->account_id);
@@ -524,14 +516,13 @@ INTERNAL_FUNC int emcore_create_mailbox(char *multi_user_name, email_mailbox_t *
                if (!emcore_create_imap_mailbox(multi_user_name, new_mailbox, &err)) {
                        EM_DEBUG_EXCEPTION("Creating a mailbox on server failed.");
                        goto FINISH_OFF;
-               }
-               else
+               } else
                        EM_DEBUG_LOG("Creating a mailbox on server succeeded.");
        }
 
        local_mailbox = em_malloc(sizeof(emstorage_mailbox_tbl_t)); /*prevent 60604*/
 
-       if(local_mailbox == NULL) {
+       if (local_mailbox == NULL) {
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -540,7 +531,7 @@ INTERNAL_FUNC int emcore_create_mailbox(char *multi_user_name, email_mailbox_t *
 
        local_mailbox->mail_slot_size = mail_slot_size;
 
-       if (!emstorage_add_mailbox(multi_user_name, local_mailbox, true, &err))  {
+       if (!emstorage_add_mailbox(multi_user_name, local_mailbox, true, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_add_mailbox failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -550,7 +541,7 @@ INTERNAL_FUNC int emcore_create_mailbox(char *multi_user_name, email_mailbox_t *
 
 FINISH_OFF:
 
-       if(local_mailbox)
+       if (local_mailbox)
                emstorage_free_mailbox(&local_mailbox, 1, NULL);
 
        if (err_code)
@@ -570,7 +561,7 @@ INTERNAL_FUNC int emcore_delete_mailbox(char *multi_user_name, int input_mailbox
        emstorage_mailbox_tbl_t *target_mailbox = NULL;
        emstorage_mailbox_tbl_t *target_mailbox_array = NULL;
 
-       if (input_mailbox_id <= 0)  {
+       if (input_mailbox_id <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -584,9 +575,9 @@ INTERNAL_FUNC int emcore_delete_mailbox(char *multi_user_name, int input_mailbox
        old_mailbox_name = g_strdup(target_mailbox->mailbox_name);
 
 #ifdef __FEATURE_DELETE_MAILBOX_RECURSIVELY__
-       if(input_recursive) {
+       if (input_recursive) {
                /* Getting children mailbox list */
-               if(!emstorage_get_child_mailbox_list(multi_user_name,
+               if (!emstorage_get_child_mailbox_list(multi_user_name,
                                                                                        target_mailbox->account_id,
                                                                                        target_mailbox->mailbox_name,
                                                                                        &mailbox_count,
@@ -601,8 +592,7 @@ INTERNAL_FUNC int emcore_delete_mailbox(char *multi_user_name, int input_mailbox
                        emstorage_free_mailbox(&target_mailbox, 1, NULL);
 
                target_mailbox = NULL;
-       }
-       else
+       } else
 #endif /* __FEATURE_DELETE_MAILBOX_RECURSIVELY__ */
        {
                target_mailbox_array = target_mailbox;
@@ -625,8 +615,7 @@ INTERNAL_FUNC int emcore_delete_mailbox(char *multi_user_name, int input_mailbox
                        if  (!emcore_delete_imap_mailbox(multi_user_name, target_mailbox_array[i].mailbox_id, &err)) {
                                EM_DEBUG_EXCEPTION("Delete the mailbox in server : failed [%d]", err);
                                goto FINISH_OFF;
-                       }
-                       else
+                       } else
                                EM_DEBUG_LOG("Delete the mailbox in server : success");
                }
 
@@ -635,14 +624,14 @@ INTERNAL_FUNC int emcore_delete_mailbox(char *multi_user_name, int input_mailbox
                                                                                                target_mailbox_array[i].mailbox_id,
                                                                                                0,
                                                                                                false,
-                                                                                               &err))  {
+                                                                                               &err)) {
                        if (err != EMAIL_ERROR_MAIL_NOT_FOUND) {
                                EM_DEBUG_EXCEPTION("emcore_delete_all_mails_of_mailbox failed [%d]", err);
                                goto FINISH_OFF;
                        }
                }
 
-               if (!emstorage_delete_mailbox(multi_user_name, target_mailbox_array[i].account_id, -1, target_mailbox_array[i].mailbox_id, true, &err))  {
+               if (!emstorage_delete_mailbox(multi_user_name, target_mailbox_array[i].account_id, -1, target_mailbox_array[i].mailbox_id, true, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_delete_mailbox failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -669,19 +658,19 @@ INTERNAL_FUNC int emcore_delete_mailbox_ex(char *multi_user_name, int input_acco
        int err = EMAIL_ERROR_NONE;
        int i = 0;
 
-       if(input_account_id == 0 || input_mailbox_id_count <= 0 || input_mailbox_id_array == NULL) {
+       if (input_account_id == 0 || input_mailbox_id_count <= 0 || input_mailbox_id_array == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if((err = emstorage_set_field_of_mailbox_with_integer_value(multi_user_name, input_account_id, input_mailbox_id_array, input_mailbox_id_count, "deleted_flag", 1, true)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_set_field_of_mailbox_with_integer_value(multi_user_name, input_account_id, input_mailbox_id_array, input_mailbox_id_count, "deleted_flag", 1, true)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_set_field_of_mailbox_with_integer_value failed[%d]", err);
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < input_mailbox_id_count; i++) {
-               if((err = emcore_delete_mailbox(multi_user_name, input_mailbox_id_array[i] , input_on_server, input_recursive)) != EMAIL_ERROR_NONE) {
+       for (i = 0; i < input_mailbox_id_count; i++) {
+               if ((err = emcore_delete_mailbox(multi_user_name, input_mailbox_id_array[i] , input_on_server, input_recursive)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_delete_mailbox failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -754,7 +743,7 @@ INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
        char *enc_mailbox_name = NULL;
        char *new_mailbox_name = NULL;
 
-       if (input_mailbox_id == 0 || input_new_mailbox_name == NULL || input_new_mailbox_alias == NULL)  {
+       if (input_mailbox_id == 0 || input_new_mailbox_name == NULL || input_new_mailbox_alias == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -775,8 +764,7 @@ INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
        old_mailbox_name = EM_SAFE_STRDUP(target_mailbox->mailbox_name);
        new_mailbox_name = EM_SAFE_STRDUP(input_new_mailbox_name);
 
-       if(account_ref->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC)
-       {
+       if (account_ref->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                if (!emcore_get_encoded_mailbox_name(new_mailbox_name, &enc_mailbox_name, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_get_encoded_mailbox_name failed [%d]", err);
                        goto FINISH_OFF;
@@ -796,15 +784,14 @@ INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
                                                                                                                handle_to_be_published)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_rename_mailbox_on_imap_server failed [%d]", err);
                        goto FINISH_OFF;
-               }
-               else
+               } else
                        EM_DEBUG_LOG("Rename the mailbox on server : success");
        }
 
 #ifdef __FEATURE_RENAME_MAILBOX_RECURSIVELY__
-       if(account_ref->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_recursive) {
+       if (account_ref->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC && input_recursive) {
                /* Getting children mailbox list */
-               if(!emstorage_get_child_mailbox_list(multi_user_name,
+               if (!emstorage_get_child_mailbox_list(multi_user_name,
                                                                                        target_mailbox->account_id,
                                                                                        target_mailbox->mailbox_name,
                                                                                        &mailbox_count,
@@ -818,8 +805,7 @@ INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
                if (target_mailbox)
                        emstorage_free_mailbox(&target_mailbox, 1, NULL);
                target_mailbox = NULL;
-       }
-       else
+       } else
 #endif /* __FEATURE_RENAME_MAILBOX_RECURSIVELY__ */
        {
                target_mailbox_array = target_mailbox;
@@ -828,7 +814,7 @@ INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
        }
 
        /* Rename mailboxes */
-       for(i = 0; i < mailbox_count ; i++) {
+       for (i = 0; i < mailbox_count ; i++) {
                EM_DEBUG_LOG_SEC("Rename mailbox_id [%d], mailbox_name [%s], old_mailbox_name [%s]",
                                                        target_mailbox_array[i].mailbox_id,
                                                        target_mailbox_array[i].mailbox_name,
@@ -852,8 +838,7 @@ INTERNAL_FUNC int emcore_rename_mailbox(char *multi_user_name,
                                EM_DEBUG_EXCEPTION("emstorage_rename_mailbox failed [%d]", err);
                                goto FINISH_OFF;
                        }
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG_SEC("target_mailbox_array[i].mailbox_name[%s] "
                                                         "old_mailbox_name[%s] "
                                                         "new_mailbox_name [%s]",
@@ -946,11 +931,10 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi
 
        if (connection_info && reusable) {
                if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) {
-                       if(connection_info->receiving_server_stream_status == EMAIL_STREAM_STATUS_CONNECTED)
+                       if (connection_info->receiving_server_stream_status == EMAIL_STREAM_STATUS_CONNECTED)
                                *result_stream = connection_info->receiving_server_stream;
-               }
-               else {
-                       if(connection_info->sending_server_stream_status == EMAIL_STREAM_STATUS_CONNECTED)
+               } else {
+                       if (connection_info->sending_server_stream_status == EMAIL_STREAM_STATUS_CONNECTED)
                                *result_stream = connection_info->sending_server_stream;
                }
        }
@@ -968,11 +952,11 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi
        } else if (input_mailbox_id == 0) {
                mailbox_name = NULL;
        } else {
-               if ((error = emstorage_get_mailbox_by_id (multi_user_name, input_mailbox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
+               if ((error = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox)) != EMAIL_ERROR_NONE || !mailbox) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", error);
                        goto FINISH_OFF;
                }
-               mailbox_name = EM_SAFE_STRDUP (mailbox->mailbox_name);
+               mailbox_name = EM_SAFE_STRDUP(mailbox->mailbox_name);
        }
 
        if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) {
@@ -999,7 +983,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi
 
                        if (account->account_id > 0 && (session->network == EMAIL_ERROR_XOAUTH_BAD_REQUEST ||
                                session->network == EMAIL_ERROR_XOAUTH_INVALID_UNAUTHORIZED)) {
-                               error = emcore_refresh_xoauth2_access_token (multi_user_name, account->account_id);
+                               error = emcore_refresh_xoauth2_access_token(multi_user_name, account->account_id);
 
                                if (error != EMAIL_ERROR_NONE) {
                                        EM_DEBUG_EXCEPTION("emcore_refresh_xoauth2_access_token failed. [%d]", error);
@@ -1012,7 +996,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi
                                                                                        session->error, session->network);
                                                }
                                                connection_retry_count++;
-                                               EM_DEBUG_LOG ("connection_retry_count [%d]", connection_retry_count);
+                                               EM_DEBUG_LOG("connection_retry_count [%d]", connection_retry_count);
                                        }
                                }
                        } else if ((session->error == EMAIL_ERROR_TLS_SSL_FAILURE ||
@@ -1074,8 +1058,8 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi
 
                        host_list[0] = mbox_path;
 
-                       if (!(*result_stream = smtp_open (host_list, 1))) {
-                               EM_DEBUG_EXCEPTION_SEC("smtp_open error : outgoing_server_secure_connection[%d] "
+                       if (!(*result_stream = smtp_open(host_list, 1))) {
+                               EM_DEBUG_EXCEPTION_SEC("smtp_openerror : outgoing_server_secure_connection[%d] "
                                                                           "session->error[%d] session->network[%d]",
                                                                                  account->outgoing_server_secure_connection,
                                                                                  session->error, session->network);
@@ -1086,7 +1070,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox_with_account_info(char *multi
 
                                        error = emcore_refresh_xoauth2_access_token(multi_user_name, account->account_id);
                                        if (error != EMAIL_ERROR_NONE) {
-                                               EM_DEBUG_EXCEPTION ("emcore_refresh_xoauth2_access_token failed. [%d]", error);
+                                               EM_DEBUG_EXCEPTION("emcore_refresh_xoauth2_access_token failed. [%d]", error);
                                                if ((session->error == EMAIL_ERROR_UNKNOWN) || (session->error == EMAIL_ERROR_NONE))
                                                        session->error = EMAIL_ERROR_CONNECTION_FAILURE;
                                                error = session->error;
@@ -1117,23 +1101,22 @@ FINISH_OFF:
 
 #ifdef __FEATURE_KEEP_CONNECTION__
        if (ret == true) {
-               if(!connection_info) {
+               if (!connection_info) {
                        connection_info = em_malloc(sizeof(email_connection_info_t));
                        connection_info->account_id = account->account_id;
-                       if(!connection_info)
-                               EM_DEBUG_EXCEPTION("em_malloc for connection_info failed.");
+                       if (!connection_info)
+                               EM_DEBUG_EXCEPTION("em_mallocfor connection_info failed.");
                        else
                                emcore_append_connection_info(connection_info);
                }
 
-               if(connection_info) {
+               if (connection_info) {
                        /* connection_info->account_id = account->account_id; */
                        if (is_connection_for == _SERVICE_THREAD_TYPE_RECEIVING) {
-                               connection_info->receiving_server_stream      = *result_stream;
+                               connection_info->receiving_server_stream = *result_stream;
                                connection_info->receiving_server_stream_status = EMAIL_STREAM_STATUS_CONNECTED;
-                       }
-                       else {
-                               connection_info->sending_server_stream        = *result_stream;
+                       } else {
+                               connection_info->sending_server_stream = *result_stream;
                                connection_info->sending_server_stream_status = EMAIL_STREAM_STATUS_CONNECTED;
                        }
                }
@@ -1158,10 +1141,10 @@ FINISH_OFF:
 
 /*h.gahlaut@samsung.com :  20-oct-2010*/
 /*Precaution :  When Reuse Stream feature is enabled then stream should only be closed using emcore_close_mailbox from email-service code.
-mail_close should not be used directly from anywhere in code.
-emcore_close_mailbox uses mail_close inside it.
+mail_closeshould not be used directly from anywhere in code.
+emcore_close_mailbox uses mail_closeinside it.
 
-mail_close is only used in emcore_connect_to_remote_mailbox and emcore_reset_streams as an exception to above rule*/
+mail_closeis only used in emcore_connect_to_remote_mailbox and emcore_reset_streams as an exception to above rule*/
 
 INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name,
                                                                                                        int account_id,
@@ -1210,7 +1193,7 @@ INTERNAL_FUNC void emcore_close_mailbox_receiving_stream()
        EM_DEBUG_FUNC_BEGIN("recv_thread_run [%d]", recv_thread_run);
        if (!recv_thread_run) {
                ENTER_CRITICAL_SECTION(_close_stream_lock);
-               g_receiving_thd_stream = mail_close (g_receiving_thd_stream);
+               g_receiving_thd_stream = mail_close(g_receiving_thd_stream);
                prev_acc_id_recv_thd = 0;
                LEAVE_CRITICAL_SECTION(_close_stream_lock);
        }
@@ -1222,7 +1205,7 @@ INTERNAL_FUNC void emcore_close_mailbox_partial_body_stream()
        EM_DEBUG_FUNC_BEGIN();
        if (false == emcore_get_pbd_thd_state()) {
                EM_DEBUG_LOG("emcore_get_pbd_thd_state returned false");
-               g_partial_body_thd_stream = mail_close (g_partial_body_thd_stream);
+               g_partial_body_thd_stream = mail_close(g_partial_body_thd_stream);
                prev_acc_id_pb_thd = 0;
        }
        EM_DEBUG_FUNC_END();
@@ -1261,7 +1244,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name,
        email_account_t *ref_account = NULL;
 
        ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
-       if (!ref_account)  {
+       if (!ref_account) {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed - account id[%d]", account_id);
                error = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -1304,8 +1287,7 @@ INTERNAL_FUNC int emcore_connect_to_remote_mailbox(char *multi_user_name,
                                }
                        }
                }
-       }
-       else if (ret == EMAIL_ERROR_NONE && ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4
+       } else if (ret == EMAIL_ERROR_NONE && ref_account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4
                        && input_mailbox_id != EMAIL_CONNECT_FOR_SENDING) {
                IMAPCAP *capability = NULL;
                /* check capability changes */
@@ -1345,7 +1327,7 @@ INTERNAL_FUNC int emcore_close_mailbox(int account_id, void *mail_stream)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_stream[%p]", account_id, mail_stream);
 
-       if (!mail_stream)  {
+       if (!mail_stream) {
                return false;
        }
 
@@ -1354,11 +1336,9 @@ INTERNAL_FUNC int emcore_close_mailbox(int account_id, void *mail_stream)
 
        if (thread_id == (thread_t)emcore_get_receiving_thd_id()) {
                /*  Receiving thread - Dont' Free Reuse feature enabled  */
-       }
-       else if (thread_id == (thread_t)emcore_get_partial_body_thd_id()) {
+       } else if (thread_id == (thread_t)emcore_get_partial_body_thd_id()) {
                /*  Partial Body Download thread - Dont' Free Reuse feature enabled  */
-       }
-       else {
+       } else {
                /*  Some other thread so free stream */
                if (g_receiving_thd_stream != mail_stream && g_partial_body_thd_stream != mail_stream)
                        mail_close((MAILSTREAM *)mail_stream);
@@ -1374,7 +1354,7 @@ INTERNAL_FUNC void emcore_free_mailbox_list(email_mailbox_t **mailbox_list, int
 {
        EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d]", mailbox_list, count);
 
-       if (count <= 0 || !mailbox_list || !*mailbox_list)  {
+       if (count <= 0 || !mailbox_list || !*mailbox_list) {
                EM_DEBUG_EXCEPTION("INVALID_PARAM: mailbox_list[%p], count[%d]", mailbox_list, count);
                return;
        }
@@ -1414,8 +1394,8 @@ INTERNAL_FUNC int emcore_free_internal_mailbox(email_internal_mailbox_t **mailbo
        int ret = false;
        int err = EMAIL_ERROR_NONE;
 
-       if (count > 0)  {
-               if (!mailbox_list || !*mailbox_list)  {
+       if (count > 0) {
+               if (!mailbox_list || !*mailbox_list) {
                        EM_DEBUG_EXCEPTION(" mailbox_list[%p], count[%d]", mailbox_list, count);
 
                        err = EMAIL_ERROR_INVALID_PARAM;
@@ -1426,12 +1406,12 @@ INTERNAL_FUNC int emcore_free_internal_mailbox(email_internal_mailbox_t **mailbo
                int i;
 
                /* EM_DEBUG_LOG("before loop"); */
-               for (i = 0; i < count; i++)  {
+               for (i = 0; i < count; i++) {
                        EM_SAFE_FREE(p[i].mailbox_name);
                        EM_SAFE_FREE(p[i].alias);
                }
                /* EM_DEBUG_LOG("p [%p]", p); */
-               EM_SAFE_FREE (p);
+               EM_SAFE_FREE(p);
                *mailbox_list = NULL;
        }
 
@@ -1485,7 +1465,7 @@ INTERNAL_FUNC int  emcore_send_mail_event(email_mailbox_t *mailbox, int mail_id
 
        event_data = em_malloc(sizeof(email_event_t));
        if (event_data == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1496,7 +1476,7 @@ INTERNAL_FUNC int  emcore_send_mail_event(email_mailbox_t *mailbox, int mail_id
        event_data->event_param_data_1 = NULL;
        event_data->event_param_data_5 = mailbox->mailbox_id;
 
-       if (!emcore_insert_event_for_sending_mails(event_data, &handle, &err))  {
+       if (!emcore_insert_event_for_sending_mails(event_data, &handle, &err)) {
                EM_DEBUG_LOG(" emcore_insert_event failed - %d", err);
                goto FINISH_OFF;
        }
@@ -1543,14 +1523,12 @@ INTERNAL_FUNC int emcore_partial_body_thd_local_activity_sync(char *multi_user_n
                if (false == emcore_insert_partial_body_thread_event(&pbd_event, &error)) {
                        EM_DEBUG_LOG(" emcore_insert_partial_body_thread_event failed [%d]", error);
                        goto FINISH_OFF;
-               }
-               else {
+               } else {
                        /*Not checking for NULL here because is_event_inserted is never NULL. */
                        *is_event_inserted = true;
                }
 
-       }
-       else {
+       } else {
                *is_event_inserted = false;
        }
 
@@ -1579,8 +1557,7 @@ INTERNAL_FUNC int emcore_get_mailbox_by_type(char *multi_user_name, int account_
 
        if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, mailbox_type, &mail_box_tbl_spam, false, &err)) {
                EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed - %d", err);
-       }
-       else {
+       } else {
                if (mail_box_tbl_spam) {
                        result_mailbox->mailbox_type = mail_box_tbl_spam->mailbox_type;
                        result_mailbox->mailbox_name = EM_SAFE_STRDUP(mail_box_tbl_spam->mailbox_name);
@@ -1596,6 +1573,7 @@ INTERNAL_FUNC int emcore_get_mailbox_by_type(char *multi_user_name, int account_
 FINISH_OFF:
        if (err_code)
                *err_code = err;
+
        EM_DEBUG_FUNC_END();
        return ret;
 }
@@ -1633,7 +1611,7 @@ INTERNAL_FUNC int emcore_local_activity_sync(int account_id, int *err_code)
                event_data = em_malloc(sizeof(email_event_t));
                event_data->type = EMAIL_EVENT_LOCAL_ACTIVITY;
                event_data->account_id  = account_id;
-               if (!emcore_insert_event(event_data, &handle, &err))  {
+               if (!emcore_insert_event(event_data, &handle, &err)) {
                        EM_DEBUG_LOG(" emcore_insert_event failed - %d", err);
                        goto FINISH_OFF;
                }
@@ -1689,7 +1667,7 @@ INTERNAL_FUNC int emcore_save_local_activity_sync(int account_id, int *err_code)
        if (activity_count > 0) {
                event_data = em_malloc(sizeof(email_event_t));
                if (!event_data) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
index b86a4fd..75caa99 100755 (executable)
@@ -129,7 +129,7 @@ void emcore_mime_free_part(struct _m_part *part);
 void emcore_mime_free_part_body(struct _m_body *body);
 void emcore_mime_free_mime(struct _m_mesg *mmsg);
 
-extern long pop3_reply (MAILSTREAM *stream);
+extern long pop3_reply(MAILSTREAM *stream);
 /* ------------------------------------------------------------------------------------------------- */
 
 char *em_get_escaped_str(const char *str)
@@ -189,7 +189,7 @@ char *em_split_file_path(char *str)
        buf_length = EM_SAFE_STRLEN(str) + 1024;
        buf = em_malloc(buf_length);
        if (buf == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                EM_SAFE_FREE(temp_str);
                return NULL;
        }
@@ -204,7 +204,7 @@ char *em_split_file_path(char *str)
 
        temp_cid_data = em_malloc((temp_cid-temp_str)+1);
        if (temp_cid_data == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                EM_SAFE_FREE(buf);
                return temp_str;
        }
@@ -228,8 +228,7 @@ char *em_split_file_path(char *str)
                                snprintf(buf+EM_SAFE_STRLEN(buf), buf_length - EM_SAFE_STRLEN(buf), "%s\"", content_id);
                        else
                                snprintf(buf+EM_SAFE_STRLEN(buf), buf_length - EM_SAFE_STRLEN(buf), "%s%s", content_id, ".jpeg\"");
-               }
-               else {
+               } else {
                        EM_DEBUG_EXCEPTION(">>>> File Path Doesnot contain end line for CID ");
                        EM_SAFE_FREE(buf);
                        EM_SAFE_FREE(temp_cid_data);
@@ -259,7 +258,7 @@ INTERNAL_FUNC int emcore_decode_body_text(char *enc_buf, int enc_len, int enc_ty
        /*  too many called */
        *dec_len = enc_len;
 
-       switch (enc_type)  {
+       switch (enc_type) {
                case ENCQUOTEDPRINTABLE:
 
                        content = rfc822_qprint((unsigned char *)enc_buf, (unsigned long)enc_len, (unsigned long *)dec_len);
@@ -278,11 +277,11 @@ INTERNAL_FUNC int emcore_decode_body_text(char *enc_buf, int enc_len, int enc_ty
                        break;
        }
 
-       if (content)  {
+       if (content) {
                if (enc_len < *dec_len) {
                        EM_DEBUG_EXCEPTION("Decoded length is too big to store it");
                        EM_SAFE_FREE(content);
-                       if(err_code) *err_code = EMAIL_ERROR_INVALID_DATA;
+                       if (err_code) *err_code = EMAIL_ERROR_INVALID_DATA;
                        return EMAIL_ERROR_INVALID_DATA;
                }
                memcpy(enc_buf, content, *dec_len);
@@ -291,7 +290,7 @@ INTERNAL_FUNC int emcore_decode_body_text(char *enc_buf, int enc_len, int enc_ty
        }
        EM_DEBUG_FUNC_END();
 
-       if(err_code) *err_code = EMAIL_ERROR_NONE;
+       if (err_code) *err_code = EMAIL_ERROR_NONE;
        return EMAIL_ERROR_NONE;
 }
 
@@ -315,7 +314,7 @@ char *emcore_mime_get_save_file_name(int *err_code)
 /*  get a line from file pointer */
 char *emcore_get_line_from_file(void *stream, char *buf, int size, int *err_code)
 {
-       if (!fgets(buf, size, (FILE *)stream))  {
+       if (!fgets(buf, size, (FILE *)stream)) {
                if (feof((FILE *)stream)) {
                        *err_code = EMAIL_ERROR_NO_MORE_DATA;
                        return NULL;
@@ -332,7 +331,7 @@ char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err
        EM_DEBUG_FUNC_BEGIN("stream[%p], buf[%p]", stream, buf);
        POP3LOCAL *p_pop3local = NULL;
 
-       if (!stream || !buf)  {
+       if (!stream || !buf) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -342,18 +341,18 @@ char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err
        memset(buf, 0x00, size);
 
        p_pop3local = (POP3LOCAL *)(((MAILSTREAM *)stream)->local);
-       if (!p_pop3local)  {
+       if (!p_pop3local) {
                EM_DEBUG_EXCEPTION("stream->local[%p]", p_pop3local);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return NULL;
        }
 
-       if (!pop3_reply((MAILSTREAM *)stream))  { /*  if TRUE, check response */
+       if (!pop3_reply((MAILSTREAM *)stream)) { /*  if TRUE, check response */
                EM_DEBUG_LOG_DEV("p_pop3local->response 1[%s]", p_pop3local->response);
                if (p_pop3local->response) {
-                       if (*p_pop3local->response == '.' && EM_SAFE_STRLEN(p_pop3local->response) == 1)  {
-                               EM_SAFE_FREE (p_pop3local->response);
+                       if (*p_pop3local->response == '.' && EM_SAFE_STRLEN(p_pop3local->response) == 1) {
+                               EM_SAFE_FREE(p_pop3local->response);
                                if (err_code != NULL)
                                        *err_code = EMAIL_ERROR_NO_MORE_DATA;
                                EM_DEBUG_FUNC_END("end of response");
@@ -363,19 +362,18 @@ char *emcore_mime_get_line_from_sock(void *stream, char *buf, int size, int *err
                        strncpy(buf, p_pop3local->response, size-1);
                        strncat(buf, CRLF_STRING, size-(EM_SAFE_STRLEN(buf) + 1));
 
-                       EM_SAFE_FREE (p_pop3local->response);
+                       EM_SAFE_FREE(p_pop3local->response);
                        goto FINISH_OFF;
                }
        }
 
        EM_DEBUG_LOG_DEV("p_pop3local->response 2[%s]", p_pop3local->response);
-       if (p_pop3local->response)
-       {
+       if (p_pop3local->response) {
                /*  if response isn't NULL, check whether this response start with '+' */
                /*  if the first character is '+', return error because this response is normal data */
                strncpy(buf, p_pop3local->response, size-1);
                strncat(buf, CRLF_STRING, size-(EM_SAFE_STRLEN(buf)+1));
-               EM_SAFE_FREE (p_pop3local->response);
+               EM_SAFE_FREE(p_pop3local->response);
                goto FINISH_OFF;
        } else {
                EM_DEBUG_EXCEPTION("p_pop3local->response is null. network error... ");
@@ -407,7 +405,7 @@ FINISH_OFF:
 
                if (received_percentage > last_notified_percentage + 5) {
                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_BODY_START, _pop3_receiving_mail_id, "dummy-file", _pop3_total_body_size, _pop3_received_body_size))
-                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
+                               EM_DEBUG_EXCEPTION(" emcore_notify_network_event[NOTI_DOWNLOAD_BODY_START] Failed >>>> ");
                        else
                                EM_DEBUG_LOG("NOTI_DOWNLOAD_BODY_START notified (%d / %d)", _pop3_received_body_size, _pop3_total_body_size);
                        _pop3_last_notified_body_size = _pop3_received_body_size;
@@ -423,9 +421,9 @@ void emcore_mime_free_param(struct _parameter *param)
        EM_DEBUG_FUNC_BEGIN();
        while (p) {
                t = p->next;
-               EM_SAFE_FREE (p->name);
-               EM_SAFE_FREE (p->value);
-               EM_SAFE_FREE (p);
+               EM_SAFE_FREE(p->name);
+               EM_SAFE_FREE(p->value);
+               EM_SAFE_FREE(p);
                p = t;
        }
        EM_DEBUG_FUNC_END();
@@ -435,18 +433,18 @@ void emcore_mime_free_part_header(struct _m_part_header *header)
 {
        EM_DEBUG_FUNC_BEGIN();
        if (!header) return ;
-       EM_SAFE_FREE (header->type);
+       EM_SAFE_FREE(header->type);
        if (header->parameter) emcore_mime_free_param(header->parameter);
-       EM_SAFE_FREE (header->subtype);
-       EM_SAFE_FREE (header->encoding);
-       EM_SAFE_FREE (header->desc);
-       EM_SAFE_FREE (header->disp_type);
-       EM_SAFE_FREE (header->content_id);
-       EM_SAFE_FREE (header->content_location);
-       EM_SAFE_FREE (header->priority);
-       EM_SAFE_FREE (header->ms_priority);
+       EM_SAFE_FREE(header->subtype);
+       EM_SAFE_FREE(header->encoding);
+       EM_SAFE_FREE(header->desc);
+       EM_SAFE_FREE(header->disp_type);
+       EM_SAFE_FREE(header->content_id);
+       EM_SAFE_FREE(header->content_location);
+       EM_SAFE_FREE(header->priority);
+       EM_SAFE_FREE(header->ms_priority);
        if (header->disp_parameter) emcore_mime_free_param(header->disp_parameter);
-       EM_SAFE_FREE (header);
+       EM_SAFE_FREE(header);
        EM_DEBUG_FUNC_END();
 }
 
@@ -454,9 +452,9 @@ void emcore_mime_free_message_header(struct _m_mesg_header *header)
 {
        EM_DEBUG_FUNC_BEGIN();
        if (!header) return ;
-       EM_SAFE_FREE (header->version);
+       EM_SAFE_FREE(header->version);
        if (header->part_header) emcore_mime_free_part_header(header->part_header);
-       EM_SAFE_FREE (header);
+       EM_SAFE_FREE(header);
        EM_DEBUG_FUNC_END();
 }
 
@@ -464,17 +462,17 @@ void emcore_mime_free_rfc822_header(struct _rfc822header *header)
 {
        EM_DEBUG_FUNC_BEGIN();
        if (!header) return ;
-       EM_SAFE_FREE (header->return_path);
-       EM_SAFE_FREE (header->received);
-       EM_SAFE_FREE (header->reply_to);
-       EM_SAFE_FREE (header->date);
-       EM_SAFE_FREE (header->from);
-       EM_SAFE_FREE (header->subject);
-       EM_SAFE_FREE (header->sender);
-       EM_SAFE_FREE (header->to);
-       EM_SAFE_FREE (header->cc);
-       EM_SAFE_FREE (header->bcc);
-       EM_SAFE_FREE (header);
+       EM_SAFE_FREE(header->return_path);
+       EM_SAFE_FREE(header->received);
+       EM_SAFE_FREE(header->reply_to);
+       EM_SAFE_FREE(header->date);
+       EM_SAFE_FREE(header->from);
+       EM_SAFE_FREE(header->subject);
+       EM_SAFE_FREE(header->sender);
+       EM_SAFE_FREE(header->to);
+       EM_SAFE_FREE(header->cc);
+       EM_SAFE_FREE(header->bcc);
+       EM_SAFE_FREE(header);
        EM_DEBUG_FUNC_END();
 }
 
@@ -486,7 +484,7 @@ void emcore_mime_free_part_body(struct _m_body *body)
        EM_SAFE_FREE(body->text);
        if (body->nested.body) emcore_mime_free_part_body(body->nested.body);
        if (body->nested.next) emcore_mime_free_part(body->nested.next);
-       EM_SAFE_FREE (body);
+       EM_SAFE_FREE(body);
        EM_DEBUG_FUNC_END();
 }
 
@@ -496,7 +494,7 @@ void emcore_mime_free_part(struct _m_part *part)
        if (!part) return ;
        if (part->body) emcore_mime_free_part_body(part->body);
        if (part->next) emcore_mime_free_part(part->next);
-       EM_SAFE_FREE (part);
+       EM_SAFE_FREE(part);
        EM_DEBUG_FUNC_END();
 }
 
@@ -510,7 +508,7 @@ void emcore_mime_free_mime(struct _m_mesg *mmsg)
        if (mmsg->nested.body) emcore_mime_free_part_body(mmsg->nested.body);
        if (mmsg->nested.next) emcore_mime_free_part(mmsg->nested.next);
        EM_SAFE_FREE(mmsg->text);
-       EM_SAFE_FREE (mmsg);
+       EM_SAFE_FREE(mmsg);
        EM_DEBUG_FUNC_END();
 }
 
@@ -561,7 +559,7 @@ INTERNAL_FUNC int emcore_get_content_type_from_mime_string(char *input_mime_stri
        char *temp_content_type_start = NULL;
        char *temp_content_type_end = NULL;
 
-       if(input_mime_string == NULL || output_content_type == NULL) {
+       if (input_mime_string == NULL || output_content_type == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -574,25 +572,23 @@ INTERNAL_FUNC int emcore_get_content_type_from_mime_string(char *input_mime_stri
 
        temp_content_type_start = strcasestr(temp_mime_header_string, CONTENT_TYPE_STRING_IN_MIME_HEAEDER);
 
-       if(temp_content_type_start == NULL) {
+       if (temp_content_type_start == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_DATA");
                err = EMAIL_ERROR_INVALID_DATA;
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                temp_content_type_start += EM_SAFE_STRLEN(CONTENT_TYPE_STRING_IN_MIME_HEAEDER);
                temp_content_type_end = temp_content_type_start;
 
-               while(temp_content_type_end && temp_content_type_end < (temp_mime_header_string + temp_mime_header_string_length) && *temp_content_type_end != ';')
+               while (temp_content_type_end && temp_content_type_end < (temp_mime_header_string + temp_mime_header_string_length) && *temp_content_type_end != ';')
                        temp_content_type_end++;
 
-               if(temp_content_type_end && *temp_content_type_end == ';') {
-                       if(temp_content_type_end - temp_content_type_start < 256) {
+               if (temp_content_type_end && *temp_content_type_end == ';') {
+                       if (temp_content_type_end - temp_content_type_start < 256) {
                                memcpy(result_content_type, temp_content_type_start, temp_content_type_end - temp_content_type_start);
                                EM_DEBUG_LOG_SEC("result_content_type [%s]", result_content_type);
                                *output_content_type = EM_SAFE_STRDUP(em_trim_left(result_content_type));
-                       }
-                       else {
+                       } else {
                                EM_DEBUG_EXCEPTION("temp_content_type_end - temp_content_type_start [%d]", temp_content_type_end - temp_content_type_start);
                                err = EMAIL_ERROR_DATA_TOO_LONG;
                                goto FINISH_OFF;
@@ -610,7 +606,7 @@ INTERNAL_FUNC int emcore_get_utf8_address(char **dest, ADDRESS *address, int *er
 {
        EM_DEBUG_FUNC_BEGIN("dest[%p], address[%p], err_code[%p]", dest, address, err_code);
 
-       if (!dest || !address)  {
+       if (!dest || !address) {
                EM_DEBUG_EXCEPTION("dest[%p], address[%p]", dest, address);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -625,9 +621,9 @@ INTERNAL_FUNC int emcore_get_utf8_address(char **dest, ADDRESS *address, int *er
        gchar *temp = NULL;
        char *nickname = NULL;
 
-       while (address)  {
-               if (address->personal)  {
-                       if (!(nickname = emcore_gmime_get_decoding_text(address->personal)))  {
+       while (address) {
+               if (address->personal) {
+                       if (!(nickname = emcore_gmime_get_decoding_text(address->personal))) {
                                EM_DEBUG_EXCEPTION("emcore_gmime_get_decoding_text failed - %d", err);
                                goto FINISH_OFF;
                        }
@@ -636,14 +632,13 @@ INTERNAL_FUNC int emcore_get_utf8_address(char **dest, ADDRESS *address, int *er
                                char *tmp_nickname = nickname;
                                nickname = em_get_escaped_str(tmp_nickname);
                                EM_SAFE_FREE(tmp_nickname);
-                               utf8_address = g_strdup_printf("\"%s\" <%s%s%s>", nickname, address->mailbox ? address->mailbox : "", address->host ? "@": "", address->host ? address->host : "");
+                               utf8_address = g_strdup_printf("\"%s\" <%s%s%s>", nickname, address->mailbox ? address->mailbox : "", address->host ? "@" : "", address->host ? address->host : "");
                        } else {
                                utf8_address = g_strdup_printf("<%s%s%s>", address->mailbox ? address->mailbox : "", address->host ? "@" : "", address->host ? address->host : "");
                        }
 
                        EM_SAFE_FREE(nickname);
-               }
-               else {
+               } else {
                        if (address->mailbox || address->host)
                                utf8_address = g_strdup_printf("<%s%s%s>", address->mailbox ? address->mailbox : "", address->host ? "@" : "", address->host ? address->host : "");
                }
@@ -651,12 +646,11 @@ INTERNAL_FUNC int emcore_get_utf8_address(char **dest, ADDRESS *address, int *er
                EM_DEBUG_LOG_DEV("utf8_address[%s]", utf8_address);
 
                if (utf8_address) {
-                       if ((concatenated != NULL))  {
+                       if ((concatenated != NULL)) {
                                temp = concatenated;
                                concatenated = g_strdup_printf("%s; %s", temp, utf8_address);
                                g_free(temp);
-                       }
-                       else
+                       } else
                                concatenated = g_strdup(utf8_address);
                }
 
@@ -684,7 +678,7 @@ INTERNAL_FUNC int emcore_get_content_type_from_mail_bodystruct(BODY *input_body,
        int   err = EMAIL_ERROR_NONE;
        char  subtype_string[SUBTYPE_STRING_LENGTH] = { 0 , };
 
-       if(input_body == NULL || output_content_type == NULL || input_buffer_length == 0) {
+       if (input_body == NULL || output_content_type == NULL || input_buffer_length == 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -693,32 +687,32 @@ INTERNAL_FUNC int emcore_get_content_type_from_mail_bodystruct(BODY *input_body,
        EM_SAFE_STRNCPY(subtype_string, input_body->subtype, SUBTYPE_STRING_LENGTH-1); /* prevent 21983 */
        em_lower_string(subtype_string);
 
-       switch(input_body->type) {
-               case TYPETEXT :
+       switch (input_body->type) {
+               case TYPETEXT:
                        SNPRINTF(output_content_type, input_buffer_length, "text/%s", subtype_string);
                        break;
-               case TYPEMULTIPART :
+               case TYPEMULTIPART:
                        SNPRINTF(output_content_type, input_buffer_length, "multipart/%s", subtype_string);
                        break;
-               case TYPEMESSAGE :
+               case TYPEMESSAGE:
                        SNPRINTF(output_content_type, input_buffer_length, "message/%s", subtype_string);
                        break;
-               case TYPEAPPLICATION :
+               case TYPEAPPLICATION:
                        SNPRINTF(output_content_type, input_buffer_length, "application/%s", subtype_string);
                        break;
-               case TYPEAUDIO :
+               case TYPEAUDIO:
                        SNPRINTF(output_content_type, input_buffer_length, "audio/%s", subtype_string);
                        break;
-               case TYPEIMAGE :
+               case TYPEIMAGE:
                        SNPRINTF(output_content_type, input_buffer_length, "image/%s", subtype_string);
                        break;
-               case TYPEVIDEO :
+               case TYPEVIDEO:
                        SNPRINTF(output_content_type, input_buffer_length, "video/%s", subtype_string);
                        break;
-               case TYPEMODEL :
+               case TYPEMODEL:
                        SNPRINTF(output_content_type, input_buffer_length, "model/%s", subtype_string);
                        break;
-               case TYPEOTHER :
+               case TYPEOTHER:
                        SNPRINTF(output_content_type, input_buffer_length, "other/%s", subtype_string);
                        break;
                default:
@@ -743,7 +737,7 @@ INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param
        char *decoded_value = NULL, *result_value = NULL;
        int ret = false, err = EMAIL_ERROR_NONE;
 
-       if(!output_value) {
+       if (!output_value) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -751,30 +745,27 @@ INTERNAL_FUNC int emcore_get_attribute_value_of_body_part(PARAMETER *input_param
 
        memset(output_value, 0, output_buffer_length);
 
-       while (temp_param)  {
-               if (!strcasecmp(temp_param->attribute, atribute_name))  {
+       while (temp_param) {
+               if (!strcasecmp(temp_param->attribute, atribute_name)) {
                        if (temp_param->value) {
                                if (with_rfc2047_text) {
                                        decoded_value = emcore_gmime_get_decoding_text(temp_param->value);
                                        result_value = EM_SAFE_STRDUP(decoded_value);
                                        EM_SAFE_FREE(decoded_value);
-                               }
-                               else
+                               } else
                                        result_value = g_strdup(temp_param->value);
-                       }
-                       else {
+                       } else {
                                EM_DEBUG_EXCEPTION("EMAIL_ERROR_DATA_NOT_FOUND");
                                err = EMAIL_ERROR_DATA_NOT_FOUND;
                                goto FINISH_OFF;
                        }
 
-                       if(result_value) {
-                               if(output_buffer_length > EM_SAFE_STRLEN(result_value)) {
+                       if (result_value) {
+                               if (output_buffer_length > EM_SAFE_STRLEN(result_value)) {
                                        strncpy(output_value, result_value, output_buffer_length);
                                        output_value[EM_SAFE_STRLEN(result_value)] = NULL_CHAR;
                                        ret = true;
-                               }
-                               else {
+                               } else {
                                        EM_DEBUG_EXCEPTION("buffer is too short");
                                        err = EMAIL_ERROR_DATA_TOO_LONG;
                                        goto FINISH_OFF;
@@ -790,7 +781,7 @@ FINISH_OFF:
        EM_SAFE_FREE(decoded_value);
        EM_SAFE_FREE(result_value);
 
-       if(err_code)
+       if (err_code)
                *err_code = err;
 
        EM_DEBUG_FUNC_END("ret [%d]", ret);
@@ -831,7 +822,7 @@ INTERNAL_FUNC int emcore_set_fetch_body_section(BODY *body, int enable_inline_li
 {
        EM_DEBUG_FUNC_BEGIN("body[%p], err_code[%p]", body, err_code);
 
-       if (!body)  {
+       if (!body) {
                EM_DEBUG_EXCEPTION("body [%p]", body);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -866,19 +857,17 @@ int emcore_set_fetch_part_section(BODY *body, char *section_pfx, int section_sub
        char section[64] = {0x00, };
 
        /* multipart doesn't have a row to itself */
-       if (body->type == TYPEMULTIPART)  {
+       if (body->type == TYPEMULTIPART) {
                /* if not first time, extend prefix */
                if (section_pfx) {
                        SNPRINTF(section, sizeof(section), "%s%d.", section_pfx, ++section_subno);
-               }
-               else {
+               } else {
                        section[0] = '\0';
                }
 
                for (section_subno = 0, part = body->nested.part; part; part = part->next)
                        emcore_set_fetch_part_section(&part->body, section, section_subno++, enable_inline_list, total_mail_size, total_body_size, err_code);
-       }
-       else  {
+       } else {
                if (!section_pfx) /* dummy prefix if top level */
                        section_pfx = "";
 
@@ -894,8 +883,7 @@ int emcore_set_fetch_part_section(BODY *body, char *section_pfx, int section_sub
                                g_inline_list[g_inline_count] = body;
                                g_inline_count++;
                                temp = NULL;
-                       }
-                       else {
+                       } else {
                                EM_DEBUG_EXCEPTION("realloc fails");
                        }
 
@@ -915,17 +903,15 @@ int emcore_set_fetch_part_section(BODY *body, char *section_pfx, int section_sub
                }
 
                /* encapsulated message ? */
-               if ((body->type == TYPEMESSAGE) && !strcasecmp(body->subtype, "RFC822") && (body = ((MESSAGE *)body->nested.msg)->body))  {
+               if ((body->type == TYPEMESSAGE) && !strcasecmp(body->subtype, "RFC822") && (body = ((MESSAGE *)body->nested.msg)->body)) {
                        if (body->type == TYPEMULTIPART) {
                                section[0] = '\0';
                                emcore_set_fetch_part_section(body, section, section_subno-1, enable_inline_list, total_mail_size, total_body_size, err_code);
-                       }
-                       else  {         /*  build encapsulation prefi */
+                       } else {                /*  build encapsulation prefi */
                                SNPRINTF(section, sizeof(section), "%s%d.", section_pfx, section_subno);
                                emcore_set_fetch_part_section(body, section, 0, enable_inline_list, total_mail_size, total_body_size, err_code);
                        }
-               }
-               else  {
+               } else {
                        /* set body section */
                        if (body)
                                body->sparep = cpystr(section);
@@ -984,7 +970,7 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s
        /* Set the priority */
        if (mmsg->rfc822header) {
                if (mmsg->rfc822header->priority) {
-                       switch(atoi(mmsg->rfc822header->priority)) {
+                       switch (atoi(mmsg->rfc822header->priority)) {
                        case 1:
                                dst_mail_data->priority = EMAIL_MAIL_PRIORITY_HIGH;
                                break;
@@ -1008,7 +994,7 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s
                }
        } else if (mmsg->nested.body) {
                if (mmsg->nested.body->part_header->priority) {
-                       switch(atoi(mmsg->nested.body->part_header->priority)) {
+                       switch (atoi(mmsg->nested.body->part_header->priority)) {
                        case 1:
                                dst_mail_data->priority = EMAIL_MAIL_PRIORITY_HIGH;
                                break;
@@ -1138,11 +1124,11 @@ static int emcore_make_mail_data_from_m_mesg(email_mail_data_t *dst_mail_data, s
         return err;
 }
 
-INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg, 
-                                                                                                       struct _m_content_info *cnt_info, 
-                                                                                                       email_mail_data_t **output_mail_data, 
-                                                                                                       email_attachment_data_t **output_attachment_data, 
-                                                                                                       int *output_attachment_count, 
+INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
+                                                                                                       struct _m_content_info *cnt_info,
+                                                                                                       email_mail_data_t **output_mail_data,
+                                                                                                       email_attachment_data_t **output_attachment_data,
+                                                                                                       int *output_attachment_count,
                                                                                                        int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN();
@@ -1176,7 +1162,7 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
 
        p_mail_data = (email_mail_data_t *)em_malloc(sizeof(email_mail_data_t));
        if (p_mail_data == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1201,8 +1187,8 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
                        goto FINISH_OFF;
                }
 
-               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0, 
-                                                                       cnt_info->text.plain_charset ? cnt_info->text.plain_charset : UNKNOWN_CHARSET_PLAIN_TEXT_FILE, 
+               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0,
+                                                                       cnt_info->text.plain_charset ? cnt_info->text.plain_charset : UNKNOWN_CHARSET_PLAIN_TEXT_FILE,
                                                                        move_buf, path_buf, sizeof(path_buf), &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        goto FINISH_OFF;
@@ -1221,7 +1207,7 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
         memset(move_buf, 0x00, sizeof(move_buf));
         memset(path_buf, 0x00, sizeof(path_buf));
 
-               if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err))  {
+               if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -1232,14 +1218,14 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
                        strcpy(html_body, UNKNOWN_CHARSET_HTML_TEXT_FILE);
                }
 
-               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 
-                                                                       0, html_body, move_buf, path_buf, 
-                                                                       sizeof(path_buf), &err))  {
+               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id,
+                                                                       0, html_body, move_buf, path_buf,
+                                                                       sizeof(path_buf), &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        goto FINISH_OFF;
                }
 
-               if (!emstorage_move_file(cnt_info->text.html, move_buf, false, &err))  {
+               if (!emstorage_move_file(cnt_info->text.html, move_buf, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -1252,7 +1238,7 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
                memset(move_buf, 0x00, sizeof(move_buf));
                memset(path_buf, 0x00, sizeof(path_buf));
 
-               if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err))  {
+               if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -1272,10 +1258,10 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
                p_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(path_buf);
        }
 
-       if ((err = emcore_get_preview_text_from_file(multi_user_name, 
-                                                p_mail_data->file_path_plain, 
-                                                p_mail_data->file_path_html, 
-                                                MAX_PREVIEW_TEXT_LENGTH, 
+       if ((err = emcore_get_preview_text_from_file(multi_user_name,
+                                                p_mail_data->file_path_plain,
+                                                p_mail_data->file_path_html,
+                                                MAX_PREVIEW_TEXT_LENGTH,
                                                 &p_mail_data->preview_text)) != EMAIL_ERROR_NONE)
                EM_DEBUG_EXCEPTION("emcore_get_preview_text_from_file error [%d]", err);
 
@@ -1290,7 +1276,7 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
        if (attachment_num > 0) {
                attachment = (email_attachment_data_t *)em_malloc(sizeof(email_attachment_data_t) * attachment_num);
                if (attachment == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -1324,19 +1310,19 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
                                        goto FINISH_OFF;
                                }
 
-                               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 
-                                                                                       i + 1, attachment[i].attachment_name, move_buf, 
-                                                                                       path_buf, sizeof(path_buf), &err))  {
+                               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id,
+                                                                                       i + 1, attachment[i].attachment_name, move_buf,
+                                                                                       path_buf, sizeof(path_buf), &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                                        goto FINISH_OFF;
                                }
 
-                               if (!emstorage_move_file(ai->save, move_buf, false, &err))  {
+                               if (!emstorage_move_file(ai->save, move_buf, false, &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
 
                                        /*  delete all created files. */
-                                       if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 
-                                                                                               0, NULL, move_buf, path_buf, 
+                                       if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id,
+                                                                                               0, NULL, move_buf, path_buf,
                                                                                                sizeof(path_buf), NULL)) {
                                                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed...");
                                                /* goto FINISH_OFF; */
@@ -1382,23 +1368,23 @@ INTERNAL_FUNC int emcore_make_mail_data_from_mime_data(struct _m_mesg *mmsg,
                 memset(move_buf, 0x00, sizeof(move_buf));
                 memset(path_buf, 0x00, sizeof(path_buf));
 
-                               if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err))  {
+                               if (!emstorage_create_dir(multi_user_name, EML_FOLDER, eml_mail_id, 0, &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                                        goto FINISH_OFF;
                                }
 
-                               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0, 
-                                                                                       attachment[i].attachment_name, move_buf, path_buf, 
-                                                                                       sizeof(path_buf), &err))  {
+                               if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0,
+                                                                                       attachment[i].attachment_name, move_buf, path_buf,
+                                                                                       sizeof(path_buf), &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                                        goto FINISH_OFF;
                                }
 
-                               if (!emstorage_move_file(ai->save, move_buf, false, &err))  {
+                               if (!emstorage_move_file(ai->save, move_buf, false, &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
 
                                        /*  delete all created files. */
-                                       if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0, 
+                                       if (!emstorage_get_save_name(multi_user_name, EML_FOLDER, eml_mail_id, 0,
                                                                                                NULL, move_buf, path_buf, sizeof(path_buf), NULL)) {
                                                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed...");
                                                /* goto FINISH_OFF; */
@@ -1459,10 +1445,10 @@ FINISH_OFF:
        return ret;
 }
 
-INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path, 
-                                                                                               email_mail_data_t **output_mail_data, 
-                                                                                               email_attachment_data_t **output_attachment_data, 
-                                                                                               int *output_attachment_count, 
+INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path,
+                                                                                               email_mail_data_t **output_mail_data,
+                                                                                               email_attachment_data_t **output_attachment_data,
+                                                                                               int *output_attachment_count,
                                                                                                int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("eml_file_path : [%s], output_mail_data : [%p]", eml_file_path, output_mail_data);
@@ -1482,7 +1468,7 @@ INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path,
 
        cnt_info = (struct _m_content_info *)em_malloc(sizeof(struct _m_content_info));
        if (cnt_info == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1491,14 +1477,14 @@ INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path,
 
        mmsg = (struct _m_mesg *)em_malloc(sizeof(struct _m_mesg));
        if (mmsg == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        mmsg->rfc822header = (struct _rfc822header *)em_malloc(sizeof(struct _rfc822header));
        if (mmsg->rfc822header == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1511,11 +1497,11 @@ INTERNAL_FUNC int emcore_parse_mime_file_to_mail(char *eml_file_path,
                goto FINISH_OFF;
        }
 
-       if (!emcore_make_mail_data_from_mime_data(mmsg, 
-                                                                                       cnt_info, 
-                                                                                       output_mail_data, 
-                                                                                       output_attachment_data, 
-                                                                                       output_attachment_count, 
+       if (!emcore_make_mail_data_from_mime_data(mmsg,
+                                                                                       cnt_info,
+                                                                                       output_mail_data,
+                                                                                       output_attachment_data,
+                                                                                       output_attachment_count,
                                                                                        &err)) {
                emcore_gmime_shutdown();
                EM_DEBUG_EXCEPTION("emcore_make_mail_tbl_data_from_mime failed : [%d]", err);
@@ -1639,7 +1625,7 @@ INTERNAL_FUNC int emcore_get_mime_entity(char *mime_path, char **output_path, in
        ret = true;
 
 FINISH_OFF:
-       
+
        EM_SAFE_CLOSE(fd);
 
        if (err_code)
index 8990b9f..eb78dea 100755 (executable)
@@ -121,7 +121,7 @@ INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, lon
        }
 
        /* convert directory delimiter to '/' */
-       for (s = enc_path;*s;s++)
+       for (s = enc_path; *s; s++)
                if (*s == (char)delimiter)
                        *s = '/';
 
@@ -129,26 +129,26 @@ INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, lon
        memset(p + count, 0x00, sizeof(email_internal_mailbox_t));
 
 #ifdef __FEATURE_XLIST_SUPPORT__
-       if(attributes & LATT_XLIST_INBOX)
+       if (attributes & LATT_XLIST_INBOX)
                p[count].mailbox_type = EMAIL_MAILBOX_TYPE_INBOX;
-       else if(attributes & LATT_XLIST_ALL)
+       else if (attributes & LATT_XLIST_ALL)
                p[count].mailbox_type = EMAIL_MAILBOX_TYPE_ALL_EMAILS;
-       else if(attributes & LATT_XLIST_DRAFTS)
+       else if (attributes & LATT_XLIST_DRAFTS)
                p[count].mailbox_type = EMAIL_MAILBOX_TYPE_DRAFT;
-       else if(attributes & LATT_XLIST_SENT)
+       else if (attributes & LATT_XLIST_SENT)
                p[count].mailbox_type = EMAIL_MAILBOX_TYPE_SENTBOX;
-       else if(attributes & LATT_XLIST_JUNK)
+       else if (attributes & LATT_XLIST_JUNK)
                p[count].mailbox_type = EMAIL_MAILBOX_TYPE_SPAMBOX;
-       else if(attributes & LATT_XLIST_FLAGGED)
+       else if (attributes & LATT_XLIST_FLAGGED)
                p[count].mailbox_type = EMAIL_MAILBOX_TYPE_USER_DEFINED;                //EMAIL_MAILBOX_TYPE_FLAGGED; P141122-00523 sync starred folder as Inbox sync
-       else if(attributes & LATT_XLIST_TRASH)
+       else if (attributes & LATT_XLIST_TRASH)
                p[count].mailbox_type = EMAIL_MAILBOX_TYPE_TRASH;
 #endif /* __FEATURE_XLIST_SUPPORT__ */
 
-       if(attributes & LATT_NOSELECT)
+       if (attributes & LATT_NOSELECT)
                p[count].no_select    = true;
 
-       if(p[count].mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) /* For exception handling of Gmail inbox*/
+       if (p[count].mailbox_type == EMAIL_MAILBOX_TYPE_INBOX) /* For exception handling of Gmail inbox*/
                p[count].mailbox_name  = cpystr("INBOX");
        else
                p[count].mailbox_name  = cpystr(enc_path);
@@ -167,7 +167,7 @@ INTERNAL_FUNC void mm_list(MAILSTREAM *stream, int delimiter, char *mailbox, lon
                tmp = tmp+5;
                for (s = tmp; *s != '/' &&  *s != '}' && *s != '\0'; s++);
                *s = '\0';
-               if(strlen(tmp) > 0)
+               if (strlen(tmp) > 0)
                        p[count].account_id = atoi(tmp);
        }
        EM_DEBUG_LOG("mm_list account_id %d ", p[count].account_id);
@@ -249,20 +249,18 @@ INTERNAL_FUNC void mm_login(NETMBX *mb, char *user, char *pwd, long trial)
 
        EM_DEBUG_LOG("incoming_server_authentication_method [%d]", ref_account->incoming_server_authentication_method);
 
-       if(ref_account->incoming_server_authentication_method == EMAIL_AUTHENTICATION_METHOD_XOAUTH2) {
+       if (ref_account->incoming_server_authentication_method == EMAIL_AUTHENTICATION_METHOD_XOAUTH2) {
                token = strtok_r(ref_account->incoming_server_password, "\001", &save_ptr);
                EM_DEBUG_LOG_SEC("token [%s]", token);
                password = EM_SAFE_STRDUP(token);
-       }
-       else {
+       } else {
                password = EM_SAFE_STRDUP(ref_account->incoming_server_password);
        }
 
-       if(EM_SAFE_STRLEN(username) > 0 && EM_SAFE_STRLEN(password) > 0) {
+       if (EM_SAFE_STRLEN(username) > 0 && EM_SAFE_STRLEN(password) > 0) {
                strcpy(user, username);
                strcpy(pwd, password);
-       }
-       else
+       } else
                EM_DEBUG_EXCEPTION("User Information is NULL || EM_SAFE_STRLEN is 0 ");
 
 FINISH_OFF:
@@ -297,7 +295,7 @@ INTERNAL_FUNC void mm_log(char *string, long errflg)
                        break;
 
                case WARN:
-                       EM_DEBUG_EXCEPTION ("IMAP_TOOLKIT_LOG WARN [%s]", string);
+                       EM_DEBUG_EXCEPTION("IMAP_TOOLKIT_LOG WARN [%s]", string);
                        break;
 
                case PARSE:
@@ -461,7 +459,7 @@ INTERNAL_FUNC void mm_get_error(char *string, int *err_code)
 }
 
 #ifdef __FEATURE_SUPPORT_IMAP_ID__
-INTERNAL_FUNC void mm_imap_id (char **id_string)
+INTERNAL_FUNC void mm_imap_id(char **id_string)
 {
        EM_DEBUG_FUNC_BEGIN("id_string [%p]", id_string);
 
@@ -482,7 +480,7 @@ INTERNAL_FUNC void mm_imap_id (char **id_string)
        tag_length = EM_SAFE_STRLEN(tag_string);
        result_string = EM_SAFE_STRDUP(tag_string);
 
-       if(result_string == NULL) {
+       if (result_string == NULL) {
                EM_DEBUG_EXCEPTION("malloc failed");
                goto FINISH_OFF;
        }
index 17afa56..70ebd4f 100644 (file)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 
 static char *passphrase = NULL;
 
-static gboolean request_passwd(GMimeCryptoContext *ctx, const char *user_id, 
-                                                               const char *prompt_ctx, gboolean reprompt, 
+static gboolean request_passwd(GMimeCryptoContext *ctx, const char *user_id,
+                                                               const char *prompt_ctx, gboolean reprompt,
                                                                GMimeStream *response, GError **err)
 {
        EM_DEBUG_FUNC_BEGIN();
        EM_DEBUG_LOG("passpharse : [%s]", passphrase);
-        if (g_mime_stream_write_string (response, passphrase) == -1 ||
-            g_mime_stream_write (response, "\n", 1) == -1) {
-                g_set_error (err, GMIME_ERROR, errno, "%s", g_strerror (errno));
+        if (g_mime_stream_write_string(response, passphrase) == -1 ||
+            g_mime_stream_write(response, "\n", 1) == -1) {
+                g_set_error(err, GMIME_ERROR, errno, "%s", g_strerror(errno));
                 return false;
         }
 
@@ -127,7 +127,8 @@ static int emcore_pgp_get_gmime_digest_algo(email_digest_type digest_type)
        return gmime_digest_algo;
 }
 
-static int get_stack_of_recipients(char *recipients, GPtrArray **output_recipients_array) {
+static int get_stack_of_recipients(char *recipients, GPtrArray **output_recipients_array)
+{
        EM_DEBUG_FUNC_BEGIN();
        int err                       = EMAIL_ERROR_NONE;
        char *temp_key                = NULL;
@@ -146,9 +147,9 @@ static int get_stack_of_recipients(char *recipients, GPtrArray **output_recipien
        keys = EM_SAFE_STRDUP(recipients);
        strings = g_strsplit(keys, ",", -1);
 
-       for (ptr = strings; *ptr; ptr++){
+       for (ptr = strings; *ptr; ptr++) {
                temp_key = NULL;
-               temp_key = g_strdup_printf("0x%s",*(ptr));
+               temp_key = g_strdup_printf("0x%s", *(ptr));
                g_ptr_array_add(p_recipients_array, temp_key);
          }
 
@@ -157,7 +158,7 @@ FINISH_OFF:
        EM_SAFE_FREE(keys);
        if (err != EMAIL_ERROR_NONE)
                g_ptr_array_free(p_recipients_array, true);
-       else 
+       else
                *output_recipients_array = p_recipients_array;
 
        EM_DEBUG_FUNC_END();
@@ -172,25 +173,25 @@ static GMimeSignatureStatus get_signature_status(GMimeSignatureList *signatures)
 
        GMimeSignature *sig = NULL;
        GMimeSignatureStatus status = GMIME_SIGNATURE_STATUS_GOOD;
+
        if (!signatures || signatures->array->len == 0)
                return GMIME_SIGNATURE_STATUS_ERROR;
+
        for (i = 0; i < g_mime_signature_list_length(signatures); i++) {
                sig = g_mime_signature_list_get_signature(signatures, i);
                if (sig) status = MAX(status, sig->status);
-       }   
+       }
 
        EM_DEBUG_FUNC_END();
 
        return status;
 }
 
-INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate, 
-                                                                                               char *password, 
-                                                                                               char *mime_entity, 
-                                                                                               char *user_id, 
-                                                                                               email_digest_type digest_type, 
+INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate,
+                                                                                               char *password,
+                                                                                               char *mime_entity,
+                                                                                               char *user_id,
+                                                                                               email_digest_type digest_type,
                                                                                                char **file_path)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("Certificate path : [%s], mime_entity : [%s]", certificate, mime_entity);
@@ -239,7 +240,7 @@ INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate,
        }
 
        ctx = g_mime_gpg_context_new(request_passwd, "/usr/bin/gpg");
-       g_mime_gpg_context_set_always_trust ((GMimeGpgContext *)ctx, true);
+       g_mime_gpg_context_set_always_trust((GMimeGpgContext *)ctx, true);
 
        /* Initialized the input stream (clear text stream) */
        EM_DEBUG_LOG("mime_entity : [%s]", mime_entity);
@@ -260,11 +261,11 @@ INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate,
        p_digest_type = emcore_pgp_get_gmime_digest_algo(digest_type);
 
        /* Set the signed message */
-       if ((g_mime_crypto_context_sign(ctx, 
-                                                                       user_id, 
-                                                                       p_digest_type, 
-                                                                       clear_text, 
-                                                                       signed_text, 
+       if ((g_mime_crypto_context_sign(ctx,
+                                                                       user_id,
+                                                                       p_digest_type,
+                                                                       clear_text,
+                                                                       signed_text,
                                                                        &g_err) < 0) && (g_err != NULL)) {
                EM_DEBUG_EXCEPTION("g_mime_crypto_context_sign failed : [%s]", g_err->message);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -293,7 +294,7 @@ FINISH_OFF:
        if (file_path)
                *file_path = EM_SAFE_STRDUP(temp_pgp_filepath);
 
-       return err;     
+       return err;
 #else /* __FEATURE_SECURE_PGP__ */
 
        return EMAIL_ERROR_NOT_SUPPORTED;
@@ -301,12 +302,12 @@ FINISH_OFF:
 #endif
 }
 
-INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list, 
+INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list,
                                                                                                        char *certificate,
                                                                                                        char *password,
-                                                                                                       char *mime_entity, 
-                                                                                                       char *user_id, 
-                                                                                                       email_digest_type digest_type, 
+                                                                                                       char *mime_entity,
+                                                                                                       char *user_id,
+                                                                                                       email_digest_type digest_type,
                                                                                                        char **file_path)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("Certificate path : [%s], mime_entity : [%s]", certificate, mime_entity);
@@ -354,7 +355,7 @@ INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list,
        }
 
        ctx = g_mime_gpg_context_new(request_passwd, "/usr/bin/gpg");
-       g_mime_gpg_context_set_always_trust ((GMimeGpgContext *)ctx, true);
+       g_mime_gpg_context_set_always_trust((GMimeGpgContext *)ctx, true);
 
        /* Initialized the input stream (clear text stream) */
        EM_DEBUG_LOG("mime_entity : [%s]", mime_entity);
@@ -381,13 +382,13 @@ INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list,
        }
 
        /* Set the signed message */
-       if ((g_mime_crypto_context_encrypt(ctx, 
-                                                                               false, 
-                                                                               user_id, 
-                                                                               p_digest_type, 
-                                                                               recipients, 
-                                                                               clear_text, 
-                                                                               encrypted_text, 
+       if ((g_mime_crypto_context_encrypt(ctx,
+                                                                               false,
+                                                                               user_id,
+                                                                               p_digest_type,
+                                                                               recipients,
+                                                                               clear_text,
+                                                                               encrypted_text,
                                                                                &g_err) < 0) && (g_err != NULL)) {
                EM_DEBUG_EXCEPTION("NO signature : g_mime_crypto_context_encrypt failed : [%s]", g_err->message);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -418,7 +419,7 @@ FINISH_OFF:
        if (file_path)
                *file_path = EM_SAFE_STRDUP(temp_pgp_filepath);
 
-       return err;     
+       return err;
 #else /* __FEATURE_SECURE_PGP__ */
 
        return EMAIL_ERROR_NOT_SUPPORTED;
@@ -427,12 +428,12 @@ FINISH_OFF:
 
 }
 
-INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_list, 
-                                                                                                                               char *certificate, 
-                                                                                                                               char *password, 
-                                                                                                                               char *mime_entity, 
-                                                                                                                               char *user_id, 
-                                                                                                                               email_digest_type digest_type, 
+INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_list,
+                                                                                                                               char *certificate,
+                                                                                                                               char *password,
+                                                                                                                               char *mime_entity,
+                                                                                                                               char *user_id,
+                                                                                                                               email_digest_type digest_type,
                                                                                                                                char **file_path)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("mime_entity : [%s]", mime_entity);
@@ -482,7 +483,7 @@ INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_li
        }
 
        ctx = g_mime_gpg_context_new(request_passwd, "/usr/bin/gpg");
-       g_mime_gpg_context_set_always_trust ((GMimeGpgContext *)ctx, true);
+       g_mime_gpg_context_set_always_trust((GMimeGpgContext *)ctx, true);
 
        /* Initialized the input stream (clear text stream) */
        EM_DEBUG_LOG("mime_entity : [%s]", mime_entity);
@@ -509,13 +510,13 @@ INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_li
        }
 
        /* Set the signed message */
-       if ((g_mime_crypto_context_encrypt(ctx, 
-                                                                               true, 
-                                                                               user_id, 
-                                                                               p_digest_type, 
-                                                                               recipients, 
-                                                                               clear_text, 
-                                                                               encrypted_text, 
+       if ((g_mime_crypto_context_encrypt(ctx,
+                                                                               true,
+                                                                               user_id,
+                                                                               p_digest_type,
+                                                                               recipients,
+                                                                               clear_text,
+                                                                               encrypted_text,
                                                                                &g_err) < 0) && (g_err != NULL)) {
                EM_DEBUG_EXCEPTION("Signature : g_mime_crypto_context_encrypt failed : [%s]", g_err->message);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -546,7 +547,7 @@ FINISH_OFF:
        if (file_path)
                *file_path = EM_SAFE_STRDUP(temp_pgp_filepath);
 
-       return err;     
+       return err;
 #else /* __FEATURE_SECURE_PGP__ */
 
        return EMAIL_ERROR_NOT_SUPPORTED;
@@ -555,9 +556,9 @@ FINISH_OFF:
 
 }
 
-INTERNAL_FUNC int emcore_pgp_get_verify_signature(char *signature_path, 
-                                                                                                       char *mime_entity, 
-                                                                                                       email_digest_type digest_type, 
+INTERNAL_FUNC int emcore_pgp_get_verify_signature(char *signature_path,
+                                                                                                       char *mime_entity,
+                                                                                                       email_digest_type digest_type,
                                                                                                        int *verify)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("signature path : [%s], mime_entity : [%s]", signature_path, mime_entity);
@@ -588,7 +589,7 @@ INTERNAL_FUNC int emcore_pgp_get_verify_signature(char *signature_path,
        g_mime_init(0);
 
        ctx = g_mime_gpg_context_new(request_passwd, "/usr/bin/gpg");
-       g_mime_gpg_context_set_always_trust ((GMimeGpgContext *)ctx, true);
+       g_mime_gpg_context_set_always_trust((GMimeGpgContext *)ctx, true);
 
        /* Initialized the input stream (clear text stream) */
        EM_DEBUG_LOG("mime_entity : [%s]", mime_entity);
@@ -612,7 +613,7 @@ INTERNAL_FUNC int emcore_pgp_get_verify_signature(char *signature_path,
                EM_DEBUG_EXCEPTION("em_open failed : [%s] [%d]", signature_path, err);
                goto FINISH_OFF;
        }
-       
+
        signed_text = g_mime_stream_fs_new(signed_fd);
        if (g_mime_stream_reset(signed_text) == -1) {
                EM_DEBUG_EXCEPTION("g_mime_stream_reset signed_text failed");
@@ -663,7 +664,7 @@ FINISH_OFF:
        if (verify)
                *verify = p_verify;
 
-       return err;     
+       return err;
 #else /* __FEATURE_SECURE_PGP__ */
 
        return EMAIL_ERROR_NOT_SUPPORTED;
@@ -672,10 +673,10 @@ FINISH_OFF:
 
 }
 
-INTERNAL_FUNC int emcore_pgp_get_decrypted_message(char *encrypted_message, 
-                                                                                                       char *password, 
-                                                                                                       int sign, 
-                                                                                                       char **decrypted_file, 
+INTERNAL_FUNC int emcore_pgp_get_decrypted_message(char *encrypted_message,
+                                                                                                       char *password,
+                                                                                                       int sign,
+                                                                                                       char **decrypted_file,
                                                                                                        int *verify)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("Encrypted message : [%s], password : [%s]", encrypted_message, password);
@@ -709,7 +710,7 @@ INTERNAL_FUNC int emcore_pgp_get_decrypted_message(char *encrypted_message,
 
        /* Initialized the context */
        ctx = g_mime_gpg_context_new(request_passwd, "/usr/bin/gpg");
-       g_mime_gpg_context_set_always_trust ((GMimeGpgContext *)ctx, true);
+       g_mime_gpg_context_set_always_trust((GMimeGpgContext *)ctx, true);
 
        /* Initialized the input stream (clear text stream) */
        err = em_open(encrypted_message, O_RDONLY, 0, &encrypted_fd);
@@ -783,11 +784,11 @@ FINISH_OFF:
 
        if (verify)
                *verify = p_verify;
-       
+
        if (decrypted_file)
                *decrypted_file = EM_SAFE_STRDUP(temp_decrypt_filepath);
 
-       return err;     
+       return err;
 #else /* __FEATURE_SECURE_PGP__ */
 
        return EMAIL_ERROR_NOT_SUPPORTED;
index b9756b2..2f3bcaf 100755 (executable)
@@ -42,8 +42,7 @@
 \r
 static pthread_mutex_t _dbus_noti_lock = PTHREAD_MUTEX_INITIALIZER;\r
 \r
-typedef enum\r
-{\r
+typedef enum {\r
        _NOTI_TYPE_STORAGE         = 0,\r
        _NOTI_TYPE_NETWORK         = 1,\r
        _NOTI_TYPE_RESPONSE_TO_API = 2,\r
@@ -74,12 +73,12 @@ static int emcore_send_signal(enotitype_t notiType, int subType, int data1, int
 \r
        ENTER_CRITICAL_SECTION(_dbus_noti_lock);\r
 \r
-       dbus_error_init (&dbus_error);\r
+       dbus_error_init(&dbus_error);\r
        connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);\r
 \r
-       if (dbus_error_is_set (&dbus_error)) {\r
-               EM_DEBUG_EXCEPTION ("dbus_bus_get failed: [%s]", dbus_error.message);\r
-               dbus_error_free (&dbus_error);\r
+       if (dbus_error_is_set(&dbus_error)) {\r
+               EM_DEBUG_EXCEPTION("dbus_bus_get failed: [%s]", dbus_error.message);\r
+               dbus_error_free(&dbus_error);\r
                goto FINISH_OFF;\r
        }\r
 \r
@@ -100,8 +99,7 @@ static int emcore_send_signal(enotitype_t notiType, int subType, int data1, int
                else\r
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID);\r
                dbus_message_append_args(signal, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID);\r
-       }\r
-       else if (notiType == _NOTI_TYPE_NETWORK) {\r
+       } else if (notiType == _NOTI_TYPE_NETWORK) {\r
                signal = dbus_message_new_signal("/User/Email/NetworkStatus", EMAIL_NETOWRK_CHANGE_NOTI, "email");\r
 \r
                if (signal == NULL) {\r
@@ -119,8 +117,7 @@ static int emcore_send_signal(enotitype_t notiType, int subType, int data1, int
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID);\r
                dbus_message_append_args(signal, DBUS_TYPE_INT32, &data2, DBUS_TYPE_INVALID);\r
                dbus_message_append_args(signal, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID);\r
-       }\r
-       else if (notiType == _NOTI_TYPE_RESPONSE_TO_API) {\r
+       } else if (notiType == _NOTI_TYPE_RESPONSE_TO_API) {\r
                signal = dbus_message_new_signal("/User/Email/ResponseToAPI", EMAIL_RESPONSE_TO_API_NOTI, "email");\r
 \r
                if (signal == NULL) {\r
@@ -133,18 +130,16 @@ static int emcore_send_signal(enotitype_t notiType, int subType, int data1, int
                dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID);\r
                dbus_message_append_args(signal, DBUS_TYPE_INT32, &data1, DBUS_TYPE_INVALID);\r
                dbus_message_append_args(signal, DBUS_TYPE_INT32, &data2, DBUS_TYPE_INVALID);\r
-       }\r
-       else {\r
+       } else {\r
                EM_DEBUG_EXCEPTION("Wrong notification type [%d]", notiType);\r
                error = EMAIL_ERROR_IPC_CRASH;\r
                goto FINISH_OFF;\r
        }\r
 \r
        if (!dbus_connection_send(connection, signal, &error)) {\r
-               EM_DEBUG_EXCEPTION ("dbus_connection_send failed [%d]", error);\r
-       }\r
-       else {\r
-               EM_DEBUG_LOG_DEV ("dbus_connection_send done");\r
+               EM_DEBUG_EXCEPTION("dbus_connection_send failed [%d]", error);\r
+       } else {\r
+               EM_DEBUG_LOG_DEV("dbus_connection_send done");\r
                ret = 1;\r
        }\r
 \r
@@ -177,11 +172,11 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
        ENTER_CRITICAL_SECTION(_dbus_noti_lock);\r
 \r
-       dbus_error_init (&dbus_error);\r
+       dbus_error_init(&dbus_error);\r
        connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);\r
-       if (dbus_error_is_set (&dbus_error)) {\r
+       if (dbus_error_is_set(&dbus_error)) {\r
                EM_DEBUG_EXCEPTION("dbus_bus_get failed: [%s]", dbus_error.message);\r
-               dbus_error_free (&dbus_error);\r
+               dbus_error_free(&dbus_error);\r
                ret = false;\r
                goto FINISH_OFF;\r
        }\r
@@ -189,7 +184,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
        signal = dbus_message_new_signal("/User/Email/ActiveSync", EMAIL_ACTIVE_SYNC_NOTI, "email");\r
 \r
        dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID);\r
-       switch ( subType ) {\r
+       switch (subType) {\r
                case ACTIVE_SYNC_NOTI_SEND_MAIL:\r
                        EM_DEBUG_LOG("handle:[%d]", data->send_mail.handle);\r
                        EM_DEBUG_LOG("account_id:[%d]", data->send_mail.account_id);\r
@@ -215,9 +210,9 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
                        EM_DEBUG_LOG("account_id:[%d]", data->sync_header.account_id);\r
                        EM_DEBUG_LOG("mailbox_id:[%d]", data->sync_header.mailbox_id);\r
 \r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.handle ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.account_id ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.mailbox_id ), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.handle), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.account_id), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.mailbox_id), DBUS_TYPE_INVALID);\r
                        if (data->sync_header.multi_user_name)\r
                                dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->sync_header.multi_user_name), DBUS_TYPE_INVALID);\r
                        else\r
@@ -230,10 +225,10 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
                        EM_DEBUG_LOG("mail_id:[%d]", data->download_body.mail_id);\r
                        EM_DEBUG_LOG("with_attachment:[%d]", data->download_body.with_attachment);\r
 \r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.handle  ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.account_id  ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.mail_id ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.with_attachment  ), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.handle), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.account_id), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.mail_id), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.with_attachment), DBUS_TYPE_INVALID);\r
                        if (data->download_body.multi_user_name)\r
                                dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_body.multi_user_name), DBUS_TYPE_INVALID);\r
                        else\r
@@ -244,13 +239,13 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
                        break;\r
                case ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT:\r
                        EM_DEBUG_LOG("handle:[%d]", data->download_attachment.handle);\r
-                       EM_DEBUG_LOG("account_id:[%d]", data->download_attachment.account_id );\r
+                       EM_DEBUG_LOG("account_id:[%d]", data->download_attachment.account_id);\r
                        EM_DEBUG_LOG("mail_id:[%d]", data->download_attachment.mail_id);\r
-                       EM_DEBUG_LOG("with_attachment:[%d]", data->download_attachment.attachment_order );\r
+                       EM_DEBUG_LOG("with_attachment:[%d]", data->download_attachment.attachment_order);\r
 \r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.handle  ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.account_id  ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.mail_id ), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.handle), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.account_id), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.mail_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.attachment_order), DBUS_TYPE_INVALID);\r
                        if (data->download_attachment.multi_user_name)\r
                                dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_attachment.multi_user_name), DBUS_TYPE_INVALID);\r
@@ -264,13 +259,13 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
                        break;\r
 \r
                case ACTIVE_SYNC_NOTI_CANCEL_JOB:\r
-                       EM_DEBUG_LOG("account_id:[%d]",       data->cancel_job.account_id );\r
+                       EM_DEBUG_LOG("account_id:[%d]",       data->cancel_job.account_id);\r
                        EM_DEBUG_LOG("handle to cancel:[%d]", data->cancel_job.handle);\r
                        EM_DEBUG_LOG("cancel_type:[%d]",      data->cancel_job.cancel_type);\r
 \r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.account_id  ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.handle  ), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.cancel_type  ), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.account_id), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.handle), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.cancel_type), DBUS_TYPE_INVALID);\r
                        if (data->cancel_job.multi_user_name)\r
                                dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->cancel_job.multi_user_name), DBUS_TYPE_INVALID);\r
                        else\r
@@ -279,55 +274,55 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
                        break;\r
 \r
                case ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER:\r
-                       EM_DEBUG_LOG("account_id:[%d]",          data->search_mail_on_server.account_id );\r
-                       EM_DEBUG_LOG("mailbox_id:[%d]",        data->search_mail_on_server.mailbox_id );\r
-                       EM_DEBUG_LOG("search_filter_count:[%d]", data->search_mail_on_server.search_filter_count );\r
+                       EM_DEBUG_LOG("account_id:[%d]",          data->search_mail_on_server.account_id);\r
+                       EM_DEBUG_LOG("mailbox_id:[%d]",        data->search_mail_on_server.mailbox_id);\r
+                       EM_DEBUG_LOG("search_filter_count:[%d]", data->search_mail_on_server.search_filter_count);\r
                        EM_DEBUG_LOG("handle to cancel:[%d]",    data->search_mail_on_server.handle);\r
 \r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.mailbox_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->search_mail_on_server.search_filter_count), DBUS_TYPE_INVALID);\r
-                       for(i = 0; i < data->search_mail_on_server.search_filter_count; i++) {\r
+                       for (i = 0; i < data->search_mail_on_server.search_filter_count; i++) {\r
                                dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->search_mail_on_server.search_filter_list[i].search_filter_type), DBUS_TYPE_INVALID);\r
-                               switch(data->search_mail_on_server.search_filter_list[i].search_filter_type) {\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO       :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_UID              :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_ALL              :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER      :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER     :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED   :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW        :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED    :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD        :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT      :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED     :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT     :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN       :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY  :\r
+                               switch (data->search_mail_on_server.search_filter_list[i].search_filter_type) {\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_UID:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_ALL:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_NEW:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_OLD:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_HEADER_PRIORITY:\r
                                                dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.integer_type_key_value), DBUS_TYPE_INVALID);\r
                                                break;\r
 \r
-                                       case EMAIL_SEARCH_FILTER_TYPE_BCC              :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_BODY             :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_CC               :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_FROM             :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_KEYWORD          :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_TEXT             :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_SUBJECT          :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_TO               :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID       :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME  :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_CHARSET          :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED     :\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_BCC:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_BODY:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_CC:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_FROM:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_KEYWORD:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_TEXT:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_SUBJECT:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_TO:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_ATTACHMENT_NAME:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_CHARSET:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_USER_DEFINED:\r
                                                dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.string_type_key_value), DBUS_TYPE_INVALID);\r
                                                break;\r
 \r
-                                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON     :\r
-                                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE  :\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON:\r
+                                       case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE:\r
                                                dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value), DBUS_TYPE_INVALID);\r
                                                break;\r
-                                       default :\r
+                                       default:\r
                                                EM_DEBUG_EXCEPTION("Invalid filter type [%d]", data->search_mail_on_server.search_filter_list[i].search_filter_type);\r
                                                break;\r
                                }\r
@@ -340,8 +335,8 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER :\r
-                       EM_DEBUG_LOG("account_id:[%d]",          data->clear_result_of_search_mail_on_server.account_id );\r
+               case ACTIVE_SYNC_NOTI_CLEAR_RESULT_OF_SEARCH_ON_SERVER:\r
+                       EM_DEBUG_LOG("account_id:[%d]",          data->clear_result_of_search_mail_on_server.account_id);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID);\r
                        if (data->search_mail_on_server.multi_user_name)\r
                                dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.multi_user_name), DBUS_TYPE_INVALID);\r
@@ -350,7 +345,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED :\r
+               case ACTIVE_SYNC_NOTI_EXPUNGE_MAILS_DELETED_FLAGGED:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.mailbox_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->expunge_mails_deleted_flagged.on_server), DBUS_TYPE_INVALID);\r
@@ -362,7 +357,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_RESOLVE_RECIPIENT :\r
+               case ACTIVE_SYNC_NOTI_RESOLVE_RECIPIENT:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->get_resolve_recipients.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->get_resolve_recipients.email_address), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->get_resolve_recipients.handle), DBUS_TYPE_INVALID);\r
@@ -373,7 +368,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_VALIDATE_CERTIFICATE :\r
+               case ACTIVE_SYNC_NOTI_VALIDATE_CERTIFICATE:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->validate_certificate.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->validate_certificate.email_address), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->validate_certificate.handle), DBUS_TYPE_INVALID);\r
@@ -384,13 +379,13 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_ADD_MAILBOX :\r
+               case ACTIVE_SYNC_NOTI_ADD_MAILBOX:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->add_mailbox.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.mailbox_path), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.mailbox_alias), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->add_mailbox.handle), DBUS_TYPE_INVALID);\r
                        /* eas is not ready to use void array and length */\r
-                       dbus_message_append_args (signal, DBUS_TYPE_STRING, &(data->add_mailbox.eas_data), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->add_mailbox.eas_data), DBUS_TYPE_INVALID);\r
 /*                     dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->add_mailbox.eas_data_length), DBUS_TYPE_INVALID);\r
                        if (data->add_mailbox.eas_data_length > 0) {\r
                                dbus_message_append_args (signal, DBUS_TYPE_ARRAY,  DBUS_TYPE_INT32, &(data->add_mailbox.eas_data),\\r
@@ -403,14 +398,14 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_RENAME_MAILBOX :\r
+               case ACTIVE_SYNC_NOTI_RENAME_MAILBOX:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->rename_mailbox.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->rename_mailbox.mailbox_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.mailbox_name), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.mailbox_alias), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->rename_mailbox.handle), DBUS_TYPE_INVALID);\r
                        /* eas is not ready to use void array and length */\r
-                       dbus_message_append_args (signal, DBUS_TYPE_STRING, &(data->rename_mailbox.eas_data), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->rename_mailbox.eas_data), DBUS_TYPE_INVALID);\r
 /*                     dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->rename_mailbox.eas_data_length), DBUS_TYPE_INVALID);\r
                        if (data->rename_mailbox.eas_data_length > 0) {\r
                                dbus_message_append_args (signal, DBUS_TYPE_ARRAY,  DBUS_TYPE_INT32, &(data->rename_mailbox.eas_data),\\r
@@ -423,7 +418,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_DELETE_MAILBOX :\r
+               case ACTIVE_SYNC_NOTI_DELETE_MAILBOX:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->delete_mailbox.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->delete_mailbox.mailbox_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->delete_mailbox.handle), DBUS_TYPE_INVALID);\r
@@ -434,10 +429,10 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                        break;\r
 \r
-               case ACTIVE_SYNC_NOTI_DELETE_MAILBOX_EX :\r
+               case ACTIVE_SYNC_NOTI_DELETE_MAILBOX_EX:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->delete_mailbox_ex.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->delete_mailbox_ex.mailbox_id_count), DBUS_TYPE_INVALID);\r
-                       for(i = 0; i <data->delete_mailbox_ex.mailbox_id_count; i++)\r
+                       for (i = 0; i < data->delete_mailbox_ex.mailbox_id_count; i++)\r
                                dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->delete_mailbox_ex.mailbox_id_array[i]), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32,  &(data->delete_mailbox_ex.handle), DBUS_TYPE_INVALID);\r
                        if (data->delete_mailbox_ex.multi_user_name)\r
@@ -472,7 +467,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
                case ACTIVE_SYNC_NOTI_CANCEL_SENDING_MAIL:\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.handle), DBUS_TYPE_INVALID);\r
-                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.account_id  ), DBUS_TYPE_INVALID);\r
+                       dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.account_id), DBUS_TYPE_INVALID);\r
                        dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_sending_mail.mail_id), DBUS_TYPE_INVALID);\r
                        if (data->cancel_sending_mail.multi_user_name)\r
                                dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->cancel_sending_mail.multi_user_name), DBUS_TYPE_INVALID);\r
@@ -487,8 +482,8 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
                        goto FINISH_OFF;\r
        }\r
 \r
-       if (!dbus_connection_send (connection, signal, &error)) {\r
-               EM_DEBUG_EXCEPTION ("dbus_connection_send failed [%d]", error);\r
+       if (!dbus_connection_send(connection, signal, &error)) {\r
+               EM_DEBUG_EXCEPTION("dbus_connection_send failed [%d]", error);\r
                ret = false;\r
        }\r
 \r
@@ -496,7 +491,7 @@ INTERNAL_FUNC int em_send_notification_to_active_sync_engine(int subType, ASNoti
 \r
 FINISH_OFF:\r
 \r
-       if(signal)\r
+       if (signal)\r
                dbus_message_unref(signal);\r
 \r
        LEAVE_CRITICAL_SECTION(_dbus_noti_lock);\r
@@ -534,11 +529,11 @@ INTERNAL_FUNC int emcore_send_task_status_signal(email_task_type_t input_task_ty
 \r
        ENTER_CRITICAL_SECTION(_dbus_noti_lock);\r
 \r
-       dbus_error_init (&dbus_error);\r
+       dbus_error_init(&dbus_error);\r
        connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);\r
-       if (dbus_error_is_set (&dbus_error)) {\r
+       if (dbus_error_is_set(&dbus_error)) {\r
                EM_DEBUG_EXCEPTION("dbus_bus_get failed: [%s]", dbus_error.message);\r
-               dbus_error_free (&dbus_error);\r
+               dbus_error_free(&dbus_error);\r
                err = EMAIL_ERROR_IPC_CONNECTION_FAILURE;\r
                goto FINISH_OFF;\r
        }\r
@@ -561,8 +556,7 @@ INTERNAL_FUNC int emcore_send_task_status_signal(email_task_type_t input_task_ty
        if (!dbus_connection_send(connection, signal, &error)) {\r
                EM_DEBUG_EXCEPTION("dbus_connection_send failed: [%d]", error);\r
                err = EMAIL_ERROR_IPC_CONNECTION_FAILURE;\r
-       }\r
-       else {\r
+       } else {\r
                EM_DEBUG_LOG("dbus_connection_send done");\r
        }\r
 \r
index 82e397b..e6776f5 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -59,7 +59,7 @@
 static const EVP_MD *emcore_get_digest_algorithm(email_digest_type digest_type)
 {
        const EVP_MD *digest_algo = NULL;
-       
+
        switch (digest_type) {
        case DIGEST_TYPE_MD5:
                digest_algo = EVP_md5();
@@ -79,45 +79,45 @@ static const EVP_CIPHER *emcore_get_cipher_algorithm(email_cipher_type cipher_ty
        const EVP_CIPHER *cipher = NULL;
 
        switch (cipher_type) {
-       case CIPHER_TYPE_RC2_128 :
+       case CIPHER_TYPE_RC2_128:
                cipher = EVP_rc2_cbc();
                break;
-       case CIPHER_TYPE_RC2_64 :
+       case CIPHER_TYPE_RC2_64:
                cipher = EVP_rc2_64_cbc();
                break;
-       case CIPHER_TYPE_DES3 :
+       case CIPHER_TYPE_DES3:
                cipher = EVP_des_ede3_cbc();
                break;
-       case CIPHER_TYPE_DES :
+       case CIPHER_TYPE_DES:
                cipher = EVP_des_cbc();
                break;
 #ifdef __FEATURE_USE_MORE_CIPHER_TYPE__
-       case CIPHER_TYPE_SEED :
+       case CIPHER_TYPE_SEED:
                cipher = EVP_seed_cbc();
                break;
-       case CIPHER_TYPE_AES128 :
+       case CIPHER_TYPE_AES128:
                cipher = EVP_aes_128_cbc();
                break;
-       case CIPHER_TYPE_AES192 :
+       case CIPHER_TYPE_AES192:
                cipher = EVP_aes_192_cbc();
                break;
-       case CIPHER_TYPE_AES256 :
+       case CIPHER_TYPE_AES256:
                cipher = EVP_aes_256_cbc();
                break;
-#ifndef OPENSSL_NO_CAMELLIA            
-       case CIPHER_TYPE_CAMELLIA128 :
+#ifndef OPENSSL_NO_CAMELLIA
+       case CIPHER_TYPE_CAMELLIA128:
                cipher = EVP_camellia_128_cbc();
                break;
-       case CIPHER_TYPE_CAMELLIA192 :
+       case CIPHER_TYPE_CAMELLIA192:
                cipher = EVP_camellia_192_cbc();
                break;
-       case CIPHER_TYPE_CAMELLIA256 :
+       case CIPHER_TYPE_CAMELLIA256:
                cipher = EVP_camellia_256_cbc();
                break;
 #endif
 #endif
-       case CIPHER_TYPE_RC2_40 :
-       default :
+       case CIPHER_TYPE_RC2_40:
+       default:
                cipher = EVP_rc2_40_cbc();
                break;
        }
@@ -125,15 +125,15 @@ static const EVP_CIPHER *emcore_get_cipher_algorithm(email_cipher_type cipher_ty
        return cipher;
 }
 
-static int get_x509_stack_of_recipient_certs(char *multi_user_name, 
-                                                                                       char *recipients, 
-                                                                                       STACK_OF(X509) **output_recipient_certs, 
+static int get_x509_stack_of_recipient_certs(char *multi_user_name,
+                                                                                       char *recipients,
+                                                                                       STACK_OF(X509) **output_recipient_certs,
                                                                                        int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("recipients : [%s], STACK_OF(X509) : [%p]", recipients, output_recipient_certs);
 
        int err = EMAIL_ERROR_NONE;
-       int ret = false;        
+       int ret = false;
        int i = 0, j = 0;
        int cert_size = 0;
        char *temp_recipients = NULL;
@@ -161,7 +161,7 @@ static int get_x509_stack_of_recipient_certs(char *multi_user_name,
        rfc822_parse_adrlist(&token_address, temp_recipients, NULL);
 
        while (token_address) {
-               EM_DEBUG_LOG_SEC("email_address_mailbox : [%s], email_address_host : [%s]", token_address->mailbox, 
+               EM_DEBUG_LOG_SEC("email_address_mailbox : [%s], email_address_host : [%s]", token_address->mailbox,
                                                                                                                                                                        token_address->host);
                /* Plan : Certificate load to using key-manager */
                err = emcore_get_certificate_in_key_manager(token_address->host, NULL, &in_cert, &cert_size);
@@ -181,7 +181,7 @@ static int get_x509_stack_of_recipient_certs(char *multi_user_name,
                        err = EMAIL_ERROR_SYSTEM_FAILURE;
                        goto FINISH_OFF;
                }
-               
+
                x509_cert = NULL;
                token_address = token_address->next;
        }
@@ -214,12 +214,12 @@ FINISH_OFF:
 
 /* Opaque signed and encrypted method */
 /*
-static PKCS7 *opaque_signed_and_encrypt(STACK_OF(X509) *recipients_cert, 
-                                                                               X509 *signer, 
-                                                                               EVP_PKEY *private_key, 
-                                                                               BIO *mime_entity, 
-                                                                               const EVP_CIPHER *cipher, 
-                                                                               const EVP_MD *md, 
+static PKCS7 *opaque_signed_and_encrypt(STACK_OF(X509) *recipients_cert,
+                                                                               X509 *signer,
+                                                                               EVP_PKEY *private_key,
+                                                                               BIO *mime_entity,
+                                                                               const EVP_CIPHER *cipher,
+                                                                               const EVP_MD *md,
                                                                                int flags)
 {
        EM_DEBUG_FUNC_BEGIN();
@@ -232,7 +232,7 @@ static PKCS7 *opaque_signed_and_encrypt(STACK_OF(X509) *recipients_cert,
                EM_DEBUG_EXCEPTION("PKCS7 malloc failed");
                return NULL;
        }
-       
+
        if (!PKCS7_set_type(pkcs7, NID_pkcs7_signedAndEnveloped)) {
                EM_DEBUG_EXCEPTION("Set type failed");
                goto FINISH_OFF;
@@ -266,7 +266,7 @@ static PKCS7 *opaque_signed_and_encrypt(STACK_OF(X509) *recipients_cert,
 
        if (PKCS7_final(pkcs7, mime_entity, flags))
                return pkcs7;
-       
+
 FINISH_OFF:
        BIO_free_all(p7bio);
        PKCS7_free(pkcs7);
@@ -274,10 +274,10 @@ FINISH_OFF:
 }
 */
 
-INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate, 
-                                                                                               char *mime_entity, 
-                                                                                               email_digest_type digest_type, 
-                                                                                               char **file_path, 
+INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate,
+                                                                                               char *mime_entity,
+                                                                                               email_digest_type digest_type,
+                                                                                               char **file_path,
                                                                                                int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("certificate path : [%s], mime_entity : [%s]", certificate, mime_entity);
@@ -322,7 +322,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate,
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        /* Get the digest algorithm */
        digest = emcore_get_digest_algorithm(digest_type);
 
@@ -370,11 +370,11 @@ FINISH_OFF:
        return ret;
 }
 
-INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *multi_user_name, 
-                                                                                                       char *recipient_list, 
-                                                                                                       char *mime_entity, 
-                                                                                                       email_cipher_type cipher_type, 
-                                                                                                       char **file_path, 
+INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *multi_user_name,
+                                                                                                       char *recipient_list,
+                                                                                                       char *mime_entity,
+                                                                                                       email_cipher_type cipher_type,
+                                                                                                       char **file_path,
                                                                                                        int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("certificate path : [%p], mime_entity : [%p]", recipient_list, mime_entity);
@@ -410,10 +410,10 @@ INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *multi_user_name,
                EM_DEBUG_EXCEPTION("Cannot open file[%s]", mime_entity);
                goto FINISH_OFF;
        }
-       
+
        /* Get cipher algorithm */
        cipher = emcore_get_cipher_algorithm(cipher_type);
-       
+
        encrypt_message = PKCS7_encrypt(recipient_certs, bio_mime_entity, cipher, flags);
        if (encrypt_message == NULL) {
                unsigned long error = ERR_get_error();
@@ -452,13 +452,13 @@ FINISH_OFF:
        return ret;
 }
 
-INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_name, 
-                                                                                                                       char *recipient_list, 
-                                                                                                                       char *certificate, 
-                                                                                                                       char *mime_entity, 
-                                                                                                                       email_cipher_type cipher_type, 
-                                                                                                                       email_digest_type digest_type, 
-                                                                                                                       char **file_path, 
+INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_name,
+                                                                                                                       char *recipient_list,
+                                                                                                                       char *certificate,
+                                                                                                                       char *mime_entity,
+                                                                                                                       email_cipher_type cipher_type,
+                                                                                                                       email_digest_type digest_type,
+                                                                                                                       char **file_path,
                                                                                                                        int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("certificate path : [%s], mime_entity : [%s]", recipient_list, mime_entity);
@@ -514,7 +514,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_n
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        /* 4. Get the digest algorithm */
        digest = emcore_get_digest_algorithm(digest_type);
 
@@ -537,7 +537,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_n
                goto FINISH_OFF;
        }
 
-       if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity, 
+       if (!SMIME_write_PKCS7(bio_signed_message, signed_message, bio_mime_entity,
                                                flags | SMIME_OLDMIME | SMIME_CRLFEOL)) {
                unsigned long error = ERR_get_error();
                EM_DEBUG_EXCEPTION("SMIME_write_PKCS7 error : [%ld][%s]", error, ERR_error_string(error, NULL));
@@ -556,10 +556,10 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_n
 
        /* 2. Get cipher algorithm */
        cipher = emcore_get_cipher_algorithm(cipher_type);
-       
+
        flags = PKCS7_BINARY;
 
-       /* 3. Encrypt the signing message */    
+       /* 3. Encrypt the signing message */
        bio_signed_message = BIO_new_file(temp_mime_entity_path, READMODE);
        if (!bio_signed_message) {
                EM_DEBUG_EXCEPTION_SEC("Cannot open output file %s", temp_mime_entity_path);
@@ -574,7 +574,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_n
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
        }
-       
+
        /* 4. Write the encrypt message in file */
        if (!i2d_PKCS7_bio_stream(smime_attachment, encrypt_message, bio_mime_entity, flags)) {
                unsigned long error = ERR_get_error();
@@ -612,9 +612,9 @@ FINISH_OFF:
        return ret;
 }
 
-INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message, 
-                                                                                                       char *certificate, 
-                                                                                                       char **decrypt_message, 
+INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message,
+                                                                                                       char *certificate,
+                                                                                                       char **decrypt_message,
                                                                                                        int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("encrypt_file : [%s], certificate : [%s]", encrypt_message, certificate);
@@ -713,7 +713,7 @@ INTERNAL_FUNC int emcore_smime_verify_signed_message(char *signed_message, char
                EM_DEBUG_EXCEPTION("Initialize x509_store failed");
                goto FINISH_OFF;
        }
-       
+
        lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
        if (lookup == NULL) {
                EM_DEBUG_EXCEPTION("Initialize lookup store failed");
@@ -734,7 +734,7 @@ INTERNAL_FUNC int emcore_smime_verify_signed_message(char *signed_message, char
                EM_DEBUG_EXCEPTION("X509_STORE_add_lookup failed");
                goto FINISH_OFF;
        }
-       
+
        if (ca_path) {
                if (!X509_LOOKUP_add_dir(lookup, ca_path, X509_FILETYPE_PEM)) {
                        EM_DEBUG_EXCEPTION("CA path load failed");
@@ -743,9 +743,9 @@ INTERNAL_FUNC int emcore_smime_verify_signed_message(char *signed_message, char
        } else {
                X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
        }
-       
+
        temp_verify = PKCS7_verify(p7, NULL, store, content, NULL, 0);
-       if (temp_verify) 
+       if (temp_verify)
                EM_DEBUG_LOG("Verification Successful\n");
 
        ret = true;
@@ -755,7 +755,7 @@ FINISH_OFF:
                X509_STORE_free(store);
        if (p7)
                PKCS7_free(p7);
-       
+
        if (indata)
                BIO_free(indata);
 
@@ -767,17 +767,17 @@ FINISH_OFF:
 }
 */
 
-INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name, 
-                                                                                                               emstorage_account_tbl_t *account_tbl_item, 
-                                                                                                               email_mail_data_t *input_mail_data, 
-                                                                                                               email_attachment_data_t *input_attachment_data_list, 
-                                                                                                               int input_attachment_count, 
-                                                                                                               email_mail_data_t **output_mail_data, 
-                                                                                                               email_attachment_data_t **output_attachment_data_list, 
+INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
+                                                                                                               emstorage_account_tbl_t *account_tbl_item,
+                                                                                                               email_mail_data_t *input_mail_data,
+                                                                                                               email_attachment_data_t *input_attachment_data_list,
+                                                                                                               int input_attachment_count,
+                                                                                                               email_mail_data_t **output_mail_data,
+                                                                                                               email_attachment_data_t **output_attachment_data_list,
                                                                                                                int *output_attachment_count)
 {
-       EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list [%p], input_attachment_count [%d], output_mail_data [%p], output_attachment_data_list [%p]", 
-                                               input_mail_data, input_attachment_data_list, input_attachment_count, 
+       EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list [%p], input_attachment_count [%d], output_mail_data [%p], output_attachment_data_list [%p]",
+                                               input_mail_data, input_attachment_data_list, input_attachment_count,
                                                output_mail_data, output_attachment_data_list);
 
        int i = 0;
@@ -792,29 +792,29 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
        email_attachment_data_t *new_attachment_list = NULL;
 
        /* Validating parameters */
-       if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_id) 
-               || !output_attachment_count || !output_mail_data || !output_attachment_data_list ) { /*prevent#53051*/
+       if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_id)
+               || !output_attachment_count || !output_mail_data || !output_attachment_data_list) { /*prevent#53051*/
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
        }
 
        smime_type = input_mail_data->smime_type;
-       if (!smime_type) 
+       if (!smime_type)
                smime_type = account_tbl_item->smime_type;
 
        /* Signed and Encrypt the message */
        switch (smime_type) {
        case EMAIL_SMIME_SIGNED:                        /* Clear signed message */
-               if (!emcore_smime_set_signed_message(account_tbl_item->certificate_path, 
-                                                                                       input_mail_data->file_path_mime_entity, 
-                                                                                       account_tbl_item->digest_type, 
-                                                                                       &smime_file_path, 
+               if (!emcore_smime_set_signed_message(account_tbl_item->certificate_path,
+                                                                                       input_mail_data->file_path_mime_entity,
+                                                                                       account_tbl_item->digest_type,
+                                                                                       &smime_file_path,
                                                                                        &err)) {
                        EM_DEBUG_EXCEPTION("em_core_smime_set_clear_signed_message is failed : [%d]", err);
                        goto FINISH_OFF;
                }
-       
+
                EM_DEBUG_LOG_SEC("smime_file_path : %s", smime_file_path);
                name = strrchr(smime_file_path, '/');
 
@@ -827,16 +827,16 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
                break;
 
        case EMAIL_SMIME_ENCRYPTED:                     /* Encryption message */
-               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";", 
+               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
                                                                                         input_mail_data->full_address_to, ";",
                                                                                         input_mail_data->full_address_cc, ";",
                                                                                         input_mail_data->full_address_bcc, NULL);
 
-               if (!emcore_smime_set_encrypt_message(multi_user_name, 
-                                                                                       other_certificate_list, 
-                                                                                       input_mail_data->file_path_mime_entity, 
-                                                                                       account_tbl_item->cipher_type, 
-                                                                                       &smime_file_path, 
+               if (!emcore_smime_set_encrypt_message(multi_user_name,
+                                                                                       other_certificate_list,
+                                                                                       input_mail_data->file_path_mime_entity,
+                                                                                       account_tbl_item->cipher_type,
+                                                                                       &smime_file_path,
                                                                                        &err)) {
                        EM_DEBUG_EXCEPTION("emcore_smime_set_encrypt_message is failed : [%d]", err);
                        goto FINISH_OFF;
@@ -854,18 +854,18 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
                break;
 
        case EMAIL_SMIME_SIGNED_AND_ENCRYPTED:                  /* Signed and Encryption message */
-               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";", 
+               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
                                                                                         input_mail_data->full_address_to, ";",
                                                                                         input_mail_data->full_address_cc, ";",
                                                                                         input_mail_data->full_address_bcc, NULL);
 
-               if (!emcore_smime_set_signed_and_encrypt_message(multi_user_name, 
-                                                                                                               other_certificate_list, 
-                                                                                                               account_tbl_item->certificate_path, 
-                                                                                                               input_mail_data->file_path_mime_entity, 
-                                                                                                               account_tbl_item->cipher_type, 
-                                                                                                               account_tbl_item->digest_type, 
-                                                                                                               &smime_file_path, 
+               if (!emcore_smime_set_signed_and_encrypt_message(multi_user_name,
+                                                                                                               other_certificate_list,
+                                                                                                               account_tbl_item->certificate_path,
+                                                                                                               input_mail_data->file_path_mime_entity,
+                                                                                                               account_tbl_item->cipher_type,
+                                                                                                               account_tbl_item->digest_type,
+                                                                                                               &smime_file_path,
                                                                                                                &err)) {
                        EM_DEBUG_EXCEPTION("em_core_smime_set_signed_and_encrypt_message is failed : [%d]", err);
                        goto FINISH_OFF;
@@ -883,16 +883,16 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
                break;
 
        case EMAIL_PGP_SIGNED:
-               if ((err = emcore_pgp_set_signed_message(NULL, 
-                                                                                               input_mail_data->pgp_password, 
-                                                                                               input_mail_data->file_path_mime_entity, 
+               if ((err = emcore_pgp_set_signed_message(NULL,
+                                                                                               input_mail_data->pgp_password,
+                                                                                               input_mail_data->file_path_mime_entity,
                                                                                                input_mail_data->key_id,
-                                                                                               account_tbl_item->digest_type, 
+                                                                                               account_tbl_item->digest_type,
                                                                                                &smime_file_path)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_pgp_set_signed_message is failed : [%d]", err);
                        goto FINISH_OFF;
                }
-       
+
                EM_DEBUG_LOG_SEC("smime_file_path : %s", smime_file_path);
                name = strrchr(smime_file_path, '/');
 
@@ -906,18 +906,18 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
 
        case EMAIL_PGP_ENCRYPTED:
 /*
-               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";", 
+               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
                                                                                         input_mail_data->full_address_to, ";",
                                                                                         input_mail_data->full_address_cc, ";",
                                                                                         input_mail_data->full_address_bcc, NULL);
 */
                other_certificate_list = g_strdup(input_mail_data->key_list);
-               if ((err = emcore_pgp_set_encrypted_message(other_certificate_list, 
-                                                                                                       NULL, 
-                                                                                                       input_mail_data->pgp_password, 
-                                                                                                       input_mail_data->file_path_mime_entity, 
-                                                                                                       account_tbl_item->user_email_address, 
-                                                                                                       input_mail_data->digest_type, 
+               if ((err = emcore_pgp_set_encrypted_message(other_certificate_list,
+                                                                                                       NULL,
+                                                                                                       input_mail_data->pgp_password,
+                                                                                                       input_mail_data->file_path_mime_entity,
+                                                                                                       account_tbl_item->user_email_address,
+                                                                                                       input_mail_data->digest_type,
                                                                                                        &smime_file_path)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_pgp_set_encrypted_message failed : [%d]", err);
                        goto FINISH_OFF;
@@ -935,18 +935,18 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
 
        case EMAIL_PGP_SIGNED_AND_ENCRYPTED:
 /*
-               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";", 
+               other_certificate_list = g_strconcat(input_mail_data->full_address_from, ";",
                                                                                         input_mail_data->full_address_to, ";",
                                                                                         input_mail_data->full_address_cc, ";",
                                                                                         input_mail_data->full_address_bcc, NULL);
 */
                other_certificate_list = g_strdup(input_mail_data->key_list);
-               if ((err = emcore_pgp_set_signed_and_encrypted_message(other_certificate_list, 
-                                                                                                                       NULL, 
-                                                                                                                       input_mail_data->pgp_password, 
-                                                                                                                       input_mail_data->file_path_mime_entity, 
+               if ((err = emcore_pgp_set_signed_and_encrypted_message(other_certificate_list,
+                                                                                                                       NULL,
+                                                                                                                       input_mail_data->pgp_password,
+                                                                                                                       input_mail_data->file_path_mime_entity,
                                                                                                                        input_mail_data->key_id,
-                                                                                                                       input_mail_data->digest_type, 
+                                                                                                                       input_mail_data->digest_type,
                                                                                                                        &smime_file_path)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_pgp_set_signed_and_encrypted_message failed : [%d]", err);
                        goto FINISH_OFF;
@@ -978,7 +978,7 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
 
        new_attachment_list = (email_attachment_data_t *)em_malloc(sizeof(email_attachment_data_t) * attachment_count);
        if (new_attachment_list == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1016,13 +1016,13 @@ INTERNAL_FUNC int emcore_convert_mail_data_to_smime_data(char *multi_user_name,
        input_mail_data->smime_type = smime_type;
        input_mail_data->digest_type = account_tbl_item->digest_type;
 
-FINISH_OFF:    
+FINISH_OFF:
 
        EM_SAFE_FREE(other_certificate_list);
        EM_SAFE_FREE(smime_file_path);
 
        *output_attachment_count = attachment_count;
-       
+
        *output_attachment_data_list = new_attachment_list;
 
        *output_mail_data = input_mail_data;
@@ -1033,7 +1033,7 @@ FINISH_OFF:
     EM_SAFE_FREE(new_attachment_data.content_id);
 
     EM_DEBUG_LOG("err : [%d]", err);
-       return err;                             
+       return err;
 }
 
 INTERNAL_FUNC void emcore_init_openssl_library()
index d718c11..aedc1ca 100755 (executable)
@@ -227,7 +227,7 @@ FINISH_OFF:
        return result_string;
 }
 
-static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
+static int emcore_write_body(BODY *body, BODY *root_body, FILE *fp)
 {
        EM_DEBUG_FUNC_BEGIN("fp[%d]", fp);
        char *file_path = NULL;
@@ -247,7 +247,7 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
        char *full_buf = NULL;
 
        file_path = body->sparep;
-       if (!file_path || EM_SAFE_STRLEN (file_path) == 0) {
+       if (!file_path || EM_SAFE_STRLEN(file_path) == 0) {
                EM_DEBUG_LOG("There is no file path");
                switch (body->encoding) {
                        case 0:
@@ -269,13 +269,13 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
        }
 
        if (body->type == TYPETEXT && body->subtype && toupper(body->subtype[0]) == 'H') {
-               EM_DEBUG_LOG ("HTML Part");
+               EM_DEBUG_LOG("HTML Part");
 
                struct stat st_buf;
                unsigned int byte_read = 0;
 
-               if (stat (file_path, &st_buf) < 0) {
-                       EM_DEBUG_EXCEPTION ("stat [%s] error [%d]", file_path, errno);
+               if (stat(file_path, &st_buf) < 0) {
+                       EM_DEBUG_EXCEPTION("stat [%s] error [%d]", file_path, errno);
                        error = EMAIL_ERROR_FILE ;
                        goto FINISH_OFF;
                }
@@ -286,23 +286,23 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
                        goto FINISH_OFF;
                }
 
-               if (S_ISREG (st_buf.st_mode) && st_buf.st_size == 0) {
-                       EM_DEBUG_LOG ("file_path[%s] is empty size", file_path);
+               if (S_ISREG(st_buf.st_mode) && st_buf.st_size == 0) {
+                       EM_DEBUG_LOG("file_path[%s] is empty size", file_path);
                        error = EMAIL_ERROR_FILE ;
                        goto FINISH_OFF;
                }
 
-               if (!(full_buf = (char*) em_malloc (sizeof (char) * (st_buf.st_size + 1)))) {
-                       EM_DEBUG_EXCEPTION ("em_malloc failed");
+               if (!(full_buf = (char*) em_malloc(sizeof(char) * (st_buf.st_size + 1)))) {
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
 
-               byte_read = fread (full_buf, sizeof(char), st_buf.st_size, fp_html);
+               byte_read = fread(full_buf, sizeof(char), st_buf.st_size, fp_html);
 
                if (byte_read <= 0) {
-                       EM_SAFE_FREE (full_buf);
-                       if (ferror (fp_html)) {
+                       EM_SAFE_FREE(full_buf);
+                       if (ferror(fp_html)) {
                                EM_DEBUG_EXCEPTION("fread [%s] error [%d]", file_path, errno);
                                error = EMAIL_ERROR_FILE ;
                                goto FINISH_OFF;
@@ -322,20 +322,20 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
                                        EM_DEBUG_LOG_DEV("replaced_string : %s", replaced_string);
                                        EM_DEBUG_LOG_DEV("==================================================");
 
-                                       if (!emcore_get_temp_file_name (&tmp_file_path, &error))  {
-                                               EM_DEBUG_EXCEPTION (" em_core_get_temp_file_name failed[%d]", error);
+                                       if (!emcore_get_temp_file_name(&tmp_file_path, &error)) {
+                                               EM_DEBUG_EXCEPTION(" em_core_get_temp_file_name failed[%d]", error);
                                                goto FINISH_OFF;
                                        }
                                        EM_DEBUG_LOG_DEV("tmp file path : %s", tmp_file_path);
 
                                        error = em_fopen(tmp_file_path, "w", &fp_write);
                                        if (error != EMAIL_ERROR_NONE) {
-                                               EM_DEBUG_EXCEPTION_SEC ("em_fopen [%s] error [%d]", tmp_file_path, error);
+                                               EM_DEBUG_EXCEPTION_SEC("em_fopen [%s] error [%d]", tmp_file_path, error);
                                                goto FINISH_OFF;
                                        }
 
-                                       if (fseek (fp_write, 0, SEEK_SET) < 0) {
-                                               EM_DEBUG_EXCEPTION("fseek failed : error [%d]", errno);
+                                       if (fseek(fp_write, 0, SEEK_SET) < 0) {
+                                               EM_DEBUG_EXCEPTION("fseekfailed : error [%d]", errno);
                                                error = EMAIL_ERROR_FILE;
                                                goto FINISH_OFF;
                                        }
@@ -363,15 +363,15 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
        }
 
        while (1) {
-               EM_SAFE_FREE (p);
+               EM_SAFE_FREE(p);
                memset(&buf, 0x00, RFC822_STRING_BUFFER_SIZE + 1);
                nread = read(fd, buf, (body->encoding == ENCBASE64 ? 57 : RFC822_READ_BLOCK_SIZE - 2));
 
-               if (nread == 0)  {
+               if (nread == 0) {
                        EM_DEBUG_LOG_DEV("Can't read anymore : nread[%d]", nread);
                        break;
                } else if (nread < 0) {
-                       EM_DEBUG_EXCEPTION ("read [%s] error [%d]", file_path, errno);
+                       EM_DEBUG_EXCEPTION("read [%s] error [%d]", file_path, errno);
                        error = EMAIL_ERROR_FILE;
                        break;
                }
@@ -379,9 +379,9 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
                len = nread;
 
                /* EM_DEBUG_LOG("body->encoding[%d]", body->encoding); */
-               switch (body->encoding)  {
+               switch (body->encoding) {
                        case ENCQUOTEDPRINTABLE:
-                               p = (char *) rfc822_8bit ((unsigned char *)buf, (unsigned long)nread, (unsigned long *)&len);
+                               p = (char *)rfc822_8bit((unsigned char *)buf, (unsigned long)nread, (unsigned long *)&len);
                                break;
                        case ENCBASE64:
                                tmp_p = g_base64_encode((guchar *)buf, (gsize)nread);
@@ -403,10 +403,10 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
                        p = g_strconcat(".", buf, NULL);
                }
 
-               len = EM_SAFE_STRLEN((p?p:buf));
-               EM_DEBUG_LOG_DEV("line[%s]", (p?p:buf));
+               len = EM_SAFE_STRLEN((p ? p : buf));
+               EM_DEBUG_LOG_DEV("line[%s]", (p ? p : buf));
 
-               nwrite = fprintf (fp, "%s", (p?p:buf));
+               nwrite = fprintf(fp, "%s", (p ? p : buf));
                if (nwrite != len) {
                        EM_DEBUG_EXCEPTION("fprintf error: nwrite[%d] len[%d] error[%d]", nwrite, len, errno);
                        error = EMAIL_ERROR_FILE ;
@@ -420,18 +420,18 @@ static int emcore_write_body (BODY *body, BODY *root_body, FILE *fp)
 FINISH_OFF: /* prevent 34226 */
 
        /* cleanup local vars */
-       EM_SAFE_FREE (body->sparep);
-       EM_SAFE_CLOSE (fd); /*prevent 34498*/
-       EM_SAFE_FREE (p);
+       EM_SAFE_FREE(body->sparep);
+       EM_SAFE_CLOSE(fd); /*prevent 34498*/
+       EM_SAFE_FREE(p);
        if (tmp_file_path)
                g_remove(tmp_file_path);
        EM_SAFE_FREE(tmp_file_path);
        if (fp_html)
-               fclose (fp_html);
+               fclose(fp_html);
        if (fp_write)
-               fclose (fp_write);
+               fclose(fp_write);
        EM_SAFE_FREE(full_buf);
-       EM_SAFE_FREE (replaced_string);
+       EM_SAFE_FREE(replaced_string);
        EM_DEBUG_FUNC_END();
        return error;
 }
@@ -445,27 +445,27 @@ static int emcore_write_rfc822_body(BODY *body, BODY *root_body, FILE *fp, int *
        char *p = NULL, *bndry = NULL, buf[SENDBUFLEN];
        int error = EMAIL_ERROR_NONE;
 
-       switch (body->type)  {
+       switch (body->type) {
                case TYPEMULTIPART:
                        EM_DEBUG_LOG_DEV("body->type = TYPEMULTIPART");
 
                        part = body->nested.part;
 
-                       for (param = body->parameter; param; param = param->next)  {
+                       for (param = body->parameter; param; param = param->next) {
                                if (strcasecmp(param->attribute, "BOUNDARY") == 0) {
                                        bndry = param->value;
                                        break;
                                }
                        }
 
-                       do  {
+                       do {
                                p = buf; p[0] = '\0';
 
                                rfc822_write_body_header(&p, &part->body);
 
                                fprintf(fp, CRLF_STRING"--%s"CRLF_STRING, bndry);
                                if (body->subtype && (body->subtype[0] == 'S' || body->subtype[0] == 's')) {
-                                       if ((error = emcore_write_body (body, root_body, fp)) != EMAIL_ERROR_NONE) {
+                                       if ((error = emcore_write_body(body, root_body, fp)) != EMAIL_ERROR_NONE) {
                                                EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
                                                return false;
                                        }
@@ -484,7 +484,7 @@ static int emcore_write_rfc822_body(BODY *body, BODY *root_body, FILE *fp, int *
                        EM_DEBUG_LOG_DEV("body->type is not TYPEMULTIPART");
 
                        fprintf(fp, CRLF_STRING);
-                       if ((error = emcore_write_body (body, root_body, fp)) != EMAIL_ERROR_NONE) {
+                       if ((error = emcore_write_body(body, root_body, fp)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("emcore_write_body failed : [%d]", error);
                                return false;
                        }
@@ -495,7 +495,7 @@ static int emcore_write_rfc822_body(BODY *body, BODY *root_body, FILE *fp, int *
        return true;
 }
 
-static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t input_priority,
+static int emcore_write_rfc822(ENVELOPE *env, BODY *body, email_mail_priority_t input_priority,
                                                      email_mail_report_t input_report_flag, char **data)
 {
        EM_DEBUG_FUNC_BEGIN("env[%p], body[%p], data[%p]", env, body, data);
@@ -510,7 +510,7 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
        int  address_count = 0;
        ADDRESS *index = NULL;
 
-       if (!env || !data)  {
+       if (!env || !data) {
                EM_DEBUG_EXCEPTION("Invalid Parameters");
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -521,13 +521,13 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
        rfc822_encode_body_7bit(env, body); /*  if contents.text.data isn't NULL, the data will be encoded. */
 
        index = env->to;
-       while(index) {
+       while (index) {
                address_count++;
                index = index->next;
        }
 
        index = env->cc;
-       while(index) {
+       while (index) {
                address_count++;
                index = index->next;
        }
@@ -538,7 +538,7 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
 
        EM_DEBUG_LOG("header_buffer_lenth [%d]", header_buffer_lenth);
 
-       if (!(header_buffer = em_malloc(header_buffer_lenth)))  {
+       if (!(header_buffer = em_malloc(header_buffer_lenth))) {
                EM_DEBUG_EXCEPTION(" malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -557,7 +557,7 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
        {
                gchar **tokens = g_strsplit(header_buffer, "CHARSET=X-UNKNOWN", 2);
 
-               if (g_strv_length(tokens) > 1)  {
+               if (g_strv_length(tokens) > 1) {
                        gchar *charset;
 
                        if (body->sparep) {
@@ -570,8 +570,7 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
 
                                SNPRINTF(header_buffer, header_buffer_lenth, "%sCHARSET=%s%s", tokens[0], charset, tokens[1]);
                                g_free(charset);
-                       }
-                       else
+                       } else
                                EM_DEBUG_EXCEPTION("body->sparep is NULL");
                }
 
@@ -592,10 +591,10 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
        if (EM_SAFE_STRLEN(header_buffer) > 2)
                *(header_buffer + EM_SAFE_STRLEN(header_buffer) - 2) = '\0';
 
-       if (input_report_flag)  {
+       if (input_report_flag) {
                char string_buf[512] = {0x00, };
 
-               if(input_report_flag & EMAIL_MAIL_REPORT_DSN) {
+               if (input_report_flag & EMAIL_MAIL_REPORT_DSN) {
                        /*  DSN (delivery status) */
                        /*  change content-type */
                        /*  Content-Type: multipart/report; */
@@ -603,14 +602,14 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
                        /*              boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */
                }
 
-               if(input_report_flag & EMAIL_MAIL_REPORT_MDN) {
+               if (input_report_flag & EMAIL_MAIL_REPORT_MDN) {
                        /*  MDN (read receipt) */
                        /*  Content-Type: multipart/report; */
                        /*              report-type= disposition-notification; */
                        /*              boundary="----=_NextPart_000_004F_01C76EFF.54275C50" */
                }
 
-               if(input_report_flag & EMAIL_MAIL_REQUEST_MDN) {
+               if (input_report_flag & EMAIL_MAIL_REQUEST_MDN) {
                        /*  require read status */
                        rfc822_address(string_buf, env->from);
                        if (EM_SAFE_STRLEN(string_buf))
@@ -618,10 +617,10 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
                }
        }
 
-       if (input_priority > 0)  {              /*  priority (1:high 3:normal 5:low) */
+       if (input_priority > 0)               /*  priority (1:high 3:normal 5:low) */
                SNPRINTF(header_buffer + EM_SAFE_STRLEN(header_buffer), header_buffer_lenth-(EM_SAFE_STRLEN(header_buffer)), "X-Priority: %d"CRLF_STRING, input_priority);
 
-               switch (input_priority)  {
+               switch (input_priority) {
                        case EMAIL_MAIL_PRIORITY_HIGH:
                                SNPRINTF(header_buffer + EM_SAFE_STRLEN(header_buffer), header_buffer_lenth-(EM_SAFE_STRLEN(header_buffer)), "X-MSMail-Priority: High"CRLF_STRING);
                                break;
@@ -638,9 +637,8 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
        if (data && EM_SAFE_STRLEN(*data) > 0) {
                fname = EM_SAFE_STRDUP(*data);
                file_exist = 1;
-       }
-       else {
-               if (!emcore_get_temp_file_name(&fname, &error))  {
+       } else {
+               if (!emcore_get_temp_file_name(&fname, &error)) {
                        EM_DEBUG_EXCEPTION(" emcore_get_temp_file_name failed[%d]", error);
                        goto FINISH_OFF;
                }
@@ -654,8 +652,8 @@ static int emcore_write_rfc822 (ENVELOPE *env, BODY *body, email_mail_priority_t
 
        fprintf(fp, "%s", header_buffer);
 
-       if (body)  {
-               if (!emcore_write_rfc822_body(body, body, fp, &error))  {
+       if (body) {
+               if (!emcore_write_rfc822_body(body, body, fp, &error)) {
                        EM_DEBUG_EXCEPTION("emcore_write_rfc822_body failed[%d]", error);
                        goto FINISH_OFF;
                }
@@ -672,8 +670,7 @@ FINISH_OFF:
        if (error == EMAIL_ERROR_NONE) {
                if (!file_exist)
                        *data = EM_SAFE_STRDUP(fname);
-       }
-       else if (fname != NULL) {
+       } else if (fname != NULL) {
                remove(fname);
        }
 
@@ -694,19 +691,19 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
        int *del_account_id = NULL;
        /* get the segment.*/
 
-       if ((shmid = shmget (del_account_key, sizeof (int), 0666)) != -1) {
+       if ((shmid = shmget(del_account_key, sizeof(int), 0666)) != -1) {
                /* attach the segment to current process space */
-               if ((del_account_id = (int*) shmat (shmid, NULL, 0)) != (int*) -1) {
+               if ((del_account_id = (int *)shmat(shmid, NULL, 0)) != (int *)-1) {
                        /* compare two account ids */
-                       EM_DEBUG_LOG ("del_id[%d] account_id[%d]",*del_account_id, input_mail_data->account_id);
+                       EM_DEBUG_LOG("del_id[%d] account_id[%d]", *del_account_id, input_mail_data->account_id);
                        if (*del_account_id == input_mail_data->account_id) {
-                               EM_DEBUG_LOG ("SKIP adding mail: the account is being deleted");
+                               EM_DEBUG_LOG("SKIP adding mail: the account is being deleted");
                                return EMAIL_ERROR_ACCOUNT_NOT_FOUND;
                        }
                }
        }
-       EM_DEBUG_LOG ("read del_id, account_id [%d]", (del_account_id? *del_account_id:-100),input_mail_data->account_id);
 
+       EM_DEBUG_LOG("read del_id, account_id [%d]", (del_account_id ? *del_account_id : -100), input_mail_data->account_id);
 
        int err = EMAIL_ERROR_NONE;
        int attachment_id = 0, thread_id = -1, thread_item_count = 0, latest_mail_id_in_thread = -1;
@@ -740,7 +737,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 #endif
 
        /* Validating parameters */
-       if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_id))  {
+       if (!input_mail_data || !(input_mail_data->account_id) || !(input_mail_data->mailbox_id)) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -799,12 +796,12 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
        if (input_from_eas == 0 &&
                        !(input_mail_data->message_class & EMAIL_MESSAGE_CLASS_SMART_REPLY) &&
-                       !(input_mail_data->message_class & EMAIL_MESSAGE_CLASS_SMART_FORWARD) ) {
-               if (mail_data->file_path_plain)  {
+                       !(input_mail_data->message_class & EMAIL_MESSAGE_CLASS_SMART_FORWARD)) {
+               if (mail_data->file_path_plain) {
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail_data->file_path_plain);
 
-                       if (stat(real_file_path, &st_buf) < 0)  {
+                       if (stat(real_file_path, &st_buf) < 0) {
                                EM_DEBUG_EXCEPTION_SEC("mail_data->file_path_plain, stat(\"%s\") failed...", mail_data->file_path_plain);
                                EM_DEBUG_EXCEPTION("%s", EM_STRERROR(errno_buf));
                                err = EMAIL_ERROR_INVALID_MAIL;
@@ -812,25 +809,25 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                        }
                }
 
-               if (mail_data->file_path_html)  {
+               if (mail_data->file_path_html) {
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, mail_data->file_path_html);
 
-                       if (stat(real_file_path, &st_buf) < 0)  {
+                       if (stat(real_file_path, &st_buf) < 0) {
                                EM_DEBUG_EXCEPTION_SEC("mail_data->file_path_html, stat(\"%s\") failed...", mail_data->file_path_html);
-                               EM_DEBUG_EXCEPTION("%s", EM_STRERROR(errno_buf) );
+                               EM_DEBUG_EXCEPTION("%s", EM_STRERROR(errno_buf));
                                err = EMAIL_ERROR_INVALID_MAIL;
                                goto FINISH_OFF;
                        }
                }
 
-               if (attachment_count && attachment_data_list)  {
-                       for (i = 0; i < attachment_count; i++)  {
+               if (attachment_count && attachment_data_list) {
+                       for (i = 0; i < attachment_count; i++) {
                                if (attachment_data_list[i].save_status) {
                     memset(real_file_path, 0x00, sizeof(real_file_path));
                     SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, attachment_data_list[i].attachment_path);
 
-                                       if (!attachment_data_list[i].attachment_path || stat(real_file_path, &st_buf) < 0)  {
+                                       if (!attachment_data_list[i].attachment_path || stat(real_file_path, &st_buf) < 0) {
                                                EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", attachment_data_list[i].attachment_path);
                                                err = EMAIL_ERROR_INVALID_ATTACHMENT;
                                                goto FINISH_OFF;
@@ -843,34 +840,33 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                        input_mail_data->full_address_from = EM_SAFE_STRDUP(account_tbl_item->user_email_address);
 
                /* check for email_address validation */
-               if ((err = em_verify_email_address_of_mail_data (mail_data)) != EMAIL_ERROR_NONE) {
+               if ((err = em_verify_email_address_of_mail_data(mail_data)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("em_verify_email_address_of_mail_data failed [%d]", err);
                        goto FINISH_OFF;
                }
 
-               if (mail_data->report_status & EMAIL_MAIL_REPORT_MDN)  {
+               if (mail_data->report_status & EMAIL_MAIL_REPORT_MDN) {
                        /* check read-report mail */
-                       if(!mail_data->full_address_to) { /* A report mail should have 'to' address */
+                       if (!mail_data->full_address_to) { /* A report mail should have 'to' address */
                                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                                err = EMAIL_ERROR_INVALID_PARAM;
                                goto FINISH_OFF;
                        }
                        /* Create report mail body */
                        /*
-                       if (!emcore_make_rfc822_file_from_mail(multi_user_name, mail_src, NULL, NULL, NULL, &err))  {
+                       if (!emcore_make_rfc822_file_from_mail(multi_user_name, mail_src, NULL, NULL, NULL, &err)) {
                                EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail failed [%d]", err);
                                goto FINISH_OFF;
                        }
                        */
                }
-       }
-       else {  /*  For Spam handling */
+       } else {        /*  For Spam handling */
                email_option_t *opt = &account_tbl_item->options;
                EM_DEBUG_LOG_SEC("block_address [%d], block_subject [%d]", opt->block_address, opt->block_subject);
 
         /* For eas moving from spambox to other mailbox */
         if (mail_data->save_status != EMAIL_MAIL_STATUS_SAVED) {
-            if (opt->block_address || opt->block_subject)  {
+            if (opt->block_address || opt->block_subject) {
                 int is_completed = false;
                 int type = 0;
 
@@ -891,7 +887,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
                 if (blocked && (mail_data->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)) {
                     EM_DEBUG_LOG("mail[%d] added to spambox", mail_data->mail_id);
-                    if (!emstorage_get_mailbox_id_by_mailbox_type(multi_user_name, mail_data->account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &mailbox_id_spam, false, &err))  {
+                    if (!emstorage_get_mailbox_id_by_mailbox_type(multi_user_name, mail_data->account_id, EMAIL_MAILBOX_TYPE_SPAMBOX, &mailbox_id_spam, false, &err)) {
                         EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
                         mailbox_id_spam = 0;
                     }
@@ -915,13 +911,13 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
        EM_DEBUG_LOG("mail_data->mail_size [%d]", mail_data->mail_size);
 
-       if(mail_data->mail_size == 0)
+       if (mail_data->mail_size == 0)
                emcore_calc_mail_size(multi_user_name, mail_data, attachment_data_list, attachment_count, &(mail_data->mail_size)); /*  Getting file size before file moved.  */
 
        EM_DEBUG_LOG("input_from_eas [%d] mail_data->body_download_status [%d]", input_from_eas, mail_data->body_download_status);
 
-       if (input_from_eas == 0|| mail_data->body_download_status) {
-               if (!emstorage_create_dir(multi_user_name, mail_data->account_id, mail_data->mail_id, 0, &err))  {
+       if (input_from_eas == 0 || mail_data->body_download_status) {
+               if (!emstorage_create_dir(multi_user_name, mail_data->account_id, mail_data->mail_id, 0, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -935,7 +931,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                        EM_DEBUG_LOG_SEC("mail_data->file_path_plain [%s]", mail_data->file_path_plain);
                        /* EM_SAFE_STRNCPY(body_text_file_name, "UTF-8", MAX_PATH); */
 
-                       if ( (err = em_get_file_name_from_file_path(real_file_path, &body_text_file_name)) != EMAIL_ERROR_NONE) {
+                       if ((err = em_get_file_name_from_file_path(real_file_path, &body_text_file_name)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
                                err = EMAIL_ERROR_INVALID_FILE_PATH;
                                goto FINISH_OFF;
@@ -950,7 +946,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
                        if (!emstorage_get_save_name(multi_user_name, mail_data->account_id, mail_data->mail_id,
                                                                                0, body_text_file_name, name_buf, path_buf,
-                                                                               sizeof(path_buf), &err))  {
+                                                                               sizeof(path_buf), &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -977,7 +973,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
                        EM_SAFE_FREE(body_text_file_name);
 
-                       if ( (err = em_get_file_name_from_file_path(real_file_path, &body_text_file_name)) != EMAIL_ERROR_NONE) {
+                       if ((err = em_get_file_name_from_file_path(real_file_path, &body_text_file_name)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("em_get_file_name_from_file_path failed [%d]", err);
                                err = EMAIL_ERROR_INVALID_FILE_PATH;
                                goto FINISH_OFF;
@@ -991,12 +987,12 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
                        if (!emstorage_get_save_name(multi_user_name, mail_data->account_id, mail_data->mail_id,
                                                                                0, body_text_file_name, name_buf, path_buf,
-                                                                               sizeof(path_buf), &err))  {
+                                                                               sizeof(path_buf), &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                                goto FINISH_OFF;
                        }
 
-                       if (!emstorage_move_file(real_file_path, name_buf, input_from_eas, &err))  {
+                       if (!emstorage_move_file(real_file_path, name_buf, input_from_eas, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_move_file failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -1033,7 +1029,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                mail_data->file_path_mime_entity = EM_SAFE_STRDUP(path_buf);
        }
 
-       if (!mail_data->date_time)  {
+       if (!mail_data->date_time) {
                /* time isn't set */
                mail_data->date_time = time(NULL);
        }
@@ -1047,12 +1043,12 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
        mail_data->mailbox_id           = mailbox_id_target;
        mail_data->mailbox_type         = mailbox_tbl->mailbox_type;
        mail_data->server_mail_status   = !input_from_eas;
-       if(mail_data->save_status == EMAIL_MAIL_STATUS_NONE)
+       if (mail_data->save_status == EMAIL_MAIL_STATUS_NONE)
                mail_data->save_status      = EMAIL_MAIL_STATUS_SAVED;
 
        /*  Getting attachment count */
        for (i = 0; i < attachment_count; i++) {
-               if (attachment_data_list[i].inline_content_status== 1)
+               if (attachment_data_list[i].inline_content_status == 1)
                        local_inline_content_count++;
                else
                        local_attachment_count++;
@@ -1066,7 +1062,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
        EM_DEBUG_LOG("preview_text[%p]", mail_data->preview_text);
        if (mail_data->preview_text == NULL) {
-               if ( (err = emcore_get_preview_text_from_file(multi_user_name,
+               if ((err = emcore_get_preview_text_from_file(multi_user_name,
                                                     mail_data->file_path_plain,
                                                     mail_data->file_path_html,
                                                     MAX_PREVIEW_TEXT_LENGTH,
@@ -1089,20 +1085,18 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
        emcore_fill_address_information_of_mail_tbl(multi_user_name, converted_mail_tbl);
 
        /* Fill thread id */
-       if(mail_data->thread_id == 0) {
+       if (mail_data->thread_id == 0) {
                if (emstorage_get_thread_id_of_thread_mails(multi_user_name, converted_mail_tbl, &thread_id, &latest_mail_id_in_thread, &thread_item_count) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG(" emstorage_get_thread_id_of_thread_mails is failed");
 
                if (thread_id == -1) {
                        converted_mail_tbl->thread_id         = mail_data->mail_id;
                        converted_mail_tbl->thread_item_count = thread_item_count = 1;
-               }
-               else  {
+               } else {
                        converted_mail_tbl->thread_id         = thread_id;
                        thread_item_count++;
                }
-       }
-       else {
+       } else {
                thread_item_count                         = 2;
        }
 
@@ -1115,7 +1109,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
        }
 
        /*  insert mail to mail table */
-       if (!emstorage_add_mail(multi_user_name, converted_mail_tbl, 0, false, &err))  {
+       if (!emstorage_add_mail(multi_user_name, converted_mail_tbl, 0, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]", err);
                /*  ROLLBACK TRANSACTION; */
                emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
@@ -1157,7 +1151,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
         SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, attachment_data_list[i].attachment_path);
 
                if (attachment_data_list[i].attachment_size == 0) {
-                       if(attachment_data_list[i].attachment_path && stat(real_file_path, &st_buf) < 0)
+                       if (attachment_data_list[i].attachment_path && stat(real_file_path, &st_buf) < 0)
                                attachment_data_list[i].attachment_size = st_buf.st_size;
                }
 
@@ -1169,7 +1163,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                        }
                }
 
-               if (!emstorage_create_dir(multi_user_name, mail_data->account_id, mail_data->mail_id, attachment_data_list[i].inline_content_status ? 0  :  attachment_id, &err))  {
+               if (!emstorage_create_dir(multi_user_name, mail_data->account_id, mail_data->mail_id, attachment_data_list[i].inline_content_status ? 0  :  attachment_id, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_create_dir failed [%d]", err);
                        emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                        goto FINISH_OFF;
@@ -1182,7 +1176,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                                         name_buf,
                                         path_buf,
                                         sizeof(path_buf),
-                                        &err))  {
+                                        &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_save_name failed [%d]", err);
                        emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                        goto FINISH_OFF;
@@ -1217,7 +1211,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                attachment_tbl.attachment_mime_type             = attachment_data_list[i].attachment_mime_type;
                attachment_tbl.content_id                       = attachment_data_list[i].content_id;
 
-               if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err))  {
+               if (!emstorage_add_attachment(multi_user_name, &attachment_tbl, 0, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_add_attachment failed [%d]", err);
                        emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                        goto FINISH_OFF;
@@ -1248,7 +1242,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                EM_DEBUG_LOG("This mail has the meeting request");
                input_meeting_request->mail_id = mail_data->mail_id;
 
-               if (!emstorage_add_meeting_request(multi_user_name, mail_data->account_id, mailbox_tbl->mailbox_id, input_meeting_request, false, &err))  {
+               if (!emstorage_add_meeting_request(multi_user_name, mail_data->account_id, mailbox_tbl->mailbox_id, input_meeting_request, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_add_meeting_request failed [%d]", err);
                        emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL);
                        goto FINISH_OFF;
@@ -1262,7 +1256,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
 
        SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl->mailbox_id);
        if (!emcore_notify_storage_event(NOTI_MAIL_ADD, converted_mail_tbl->account_id, converted_mail_tbl->mail_id, mailbox_id_param_string, thread_id))
-               EM_DEBUG_LOG("emcore_notify_storage_event [NOTI_MAIL_ADD] failed.");
+               EM_DEBUG_LOG("emcore_notify_storage_event[NOTI_MAIL_ADD] failed.");
 
        if (account_tbl_item->incoming_server_type != EMAIL_SERVER_TYPE_ACTIVE_SYNC && !move_flag) {
                if (!emcore_remove_overflowed_mails(multi_user_name, mailbox_tbl, &err)) {
@@ -1273,7 +1267,7 @@ INTERNAL_FUNC int emcore_add_mail(char *multi_user_name, email_mail_data_t *inpu
                }
        }
 
-       if ( input_from_eas && (mail_data->flags_seen_field == 0)) {
+       if (input_from_eas && (mail_data->flags_seen_field == 0)) {
 //                             && mail_data->mailbox_type != EMAIL_MAILBOX_TYPE_TRASH
 //                             && mail_data->mailbox_type != EMAIL_MAILBOX_TYPE_SPAMBOX) {
                if ((err = emcore_update_sync_status_of_account(multi_user_name, mail_data->account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING | SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE)
@@ -1320,15 +1314,15 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
        emstorage_mailbox_tbl_t *mailbox_tbl = NULL;
        BODY                    *root_body = NULL;
 
-       if(err = emcore_get_mail_data(multi_user_name, input_read_mail_id, &read_mail_data)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_mail_data(multi_user_name, input_read_mail_id, &read_mail_data)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
                goto FINISH_OFF;
        }
 
        receipt_mail_data = em_malloc(sizeof(email_mail_data_t));
 
-       if (!receipt_mail_data)  {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+       if (!receipt_mail_data) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1338,10 +1332,10 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
        receipt_mail_data->full_address_to = EM_SAFE_STRDUP(read_mail_data->full_address_from);
        receipt_mail_data->message_id      = EM_SAFE_STRDUP(read_mail_data->message_id);
 
-       if (read_mail_data->subject)  {
+       if (read_mail_data->subject) {
                receipt_mail_data->subject = em_malloc(EM_SAFE_STRLEN(read_mail_data->subject) + 7);
-               if (!(receipt_mail_data->subject))  {
-                       EM_DEBUG_EXCEPTION("em_malloc failed...");
+               if (!(receipt_mail_data->subject)) {
+                       EM_DEBUG_EXCEPTION("em_mallocfailed...");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -1349,7 +1343,7 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
                SNPRINTF(receipt_mail_data->subject, EM_SAFE_STRLEN(read_mail_data->subject) + 7,  "Read: %s", read_mail_data->subject);
        }
 
-       if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, receipt_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_tbl, true, &err))  {
+       if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, receipt_mail_data->account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_tbl, true, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1367,14 +1361,14 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
                goto FINISH_OFF;
        }
 
-       if ( (err = emcore_make_envelope_from_mail(multi_user_name, receipt_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_make_envelope_from_mail(multi_user_name, receipt_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_make_envelope_from_mail failed [%d]", err);
                goto FINISH_OFF;
        }
 
        envelope->references = EM_SAFE_STRDUP(read_mail_data->message_id);
 
-       if (!emcore_get_report_mail_body(multi_user_name, envelope, &root_body, &err))  {
+       if (!emcore_get_report_mail_body(multi_user_name, envelope, &root_body, &err)) {
                EM_DEBUG_EXCEPTION("emcore_get_report_mail_body failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1391,8 +1385,8 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
        attachment_count                    = 1;
 
        attachment_data = em_malloc(sizeof(email_attachment_data_t));
-       if (!attachment_data)  {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+       if (!attachment_data) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -1400,7 +1394,7 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
        attachment_data->save_status     = 1;
        attachment_data->attachment_path = EM_SAFE_STRDUP(root_body->nested.part->next->body.sparep);
 
-       if (!emcore_get_file_name(attachment_data->attachment_path, &p, &err))  {
+       if (!emcore_get_file_name(attachment_data->attachment_path, &p, &err)) {
                EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1408,7 +1402,7 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
        attachment_data->attachment_name = cpystr(p);
        */
 
-       if ( (err = emcore_add_mail(multi_user_name, receipt_mail_data, attachment_data, attachment_count, NULL, 0, false)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_add_mail(multi_user_name, receipt_mail_data, attachment_data, attachment_count, NULL, 0, false)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1416,23 +1410,23 @@ INTERNAL_FUNC int emcore_add_read_receipt(char *multi_user_name, int input_read_
        *output_receipt_mail_id = receipt_mail_data->mail_id;
 
 FINISH_OFF:
-       if(receipt_mail_data) {
+       if (receipt_mail_data) {
                EM_SAFE_FREE(receipt_mail_data->full_address_to);
                EM_SAFE_FREE(receipt_mail_data->message_id);
                EM_SAFE_FREE(receipt_mail_data->subject);
                EM_SAFE_FREE(receipt_mail_data);
        }
 
-       if(mailbox_tbl)
+       if (mailbox_tbl)
                emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
 
-       if(read_mail_data)
+       if (read_mail_data)
                emcore_free_mail_data_list(&read_mail_data, 1);
 
-       if(attachment_data)
+       if (attachment_data)
                emcore_free_attachment_data(&attachment_data, 1, NULL);
 
-       if(receipt_mail_tbl_data)
+       if (receipt_mail_tbl_data)
                emstorage_free_mail(&receipt_mail_tbl_data, 1, NULL);
 
     if (root_body)
@@ -1456,7 +1450,7 @@ INTERNAL_FUNC int emcore_add_meeting_request(char *multi_user_name, int account_
                goto FINISH_OFF;
        }
 
-       if (!emstorage_add_meeting_request(multi_user_name, account_id, input_mailbox_id, meeting_req, 1, &err))  {
+       if (!emstorage_add_meeting_request(multi_user_name, account_id, input_mailbox_id, meeting_req, 1, &err)) {
                EM_DEBUG_EXCEPTION(" emstorage_add_meeting_request failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1548,17 +1542,17 @@ FINISH_OFF:
 #endif /* __FEATURE_KEEP_CONNECTION__ */
 
        if (mail_stream)
-               mail_stream = mail_close (mail_stream);
+               mail_stream = mail_close(mail_stream);
 
        if (stls)
                mail_parameters(NULL, SET_SSLSTART, (void  *)stls);
 
        if (ret == true) {
                if (!emcore_notify_network_event(NOTI_QUERY_SMTP_MAIL_SIZE_LIMIT_FINISH, account_id, NULL, mail_size_limit, handle))
-                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_QUERY_SMTP_MAIL_SIZE_LIMIT_FINISH] Failed");
+                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_QUERY_SMTP_MAIL_SIZE_LIMIT_FINISH] Failed");
        } else {
                if (!emcore_notify_network_event(NOTI_QUERY_SMTP_MAIL_SIZE_LIMIT_FAIL, account_id, NULL, handle, err))
-                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_QUERY_SMTP_MAIL_SIZE_LIMIT_FAIL] Failed");
+                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_QUERY_SMTP_MAIL_SIZE_LIMIT_FAIL] Failed");
        }
 
        if (err_code != NULL)
@@ -1569,7 +1563,7 @@ FINISH_OFF:
 }
 
 /* thread local variable for reuse */
-__thread GListg_send_stream_list = NULL;
+__thread GList *g_send_stream_list = NULL;
 typedef struct {
        int account_id;
        SENDSTREAM **send_stream;
@@ -1578,17 +1572,17 @@ typedef struct {
 /*
 stmp stream should be closed when threads exit, otherwise memory leaks
 */
-INTERNAL_FUNC void emcore_close_smtp_stream_list ()
+INTERNAL_FUNC void emcore_close_smtp_stream_list()
 {
        EM_DEBUG_FUNC_BEGIN();
-       GListcur = g_send_stream_list;
-       email_send_stream_list_tdata = NULL;
+       GList *cur = g_send_stream_list;
+       email_send_stream_list_t *data = NULL;
 
        while (cur) {
                data = cur->data;
-               if (data) *(data->send_stream) = smtp_close (*(data->send_stream));
-               g_send_stream_list = g_list_delete_link (g_send_stream_list, cur);
-               g_free (data);
+               if (data) *(data->send_stream) = smtp_close(*(data->send_stream));
+               g_send_stream_list = g_list_delete_link(g_send_stream_list, cur);
+               g_free(data);
                cur = g_send_stream_list;
        }
 
@@ -1599,42 +1593,41 @@ INTERNAL_FUNC void emcore_close_smtp_stream_list ()
 if threads exit after calling the function, emcore_close_smtp_stream_list should be called.
 Otherwise, memory leaks
 */
-INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (char *multi_user_name, int account_id, int *error)
+INTERNAL_FUNC SENDSTREAM **emcore_get_smtp_stream(char *multi_user_name, int account_id, int *error)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
-       GListcur = g_send_stream_list;
-       email_send_stream_list_tdata = NULL;
-       SENDSTREAM** ret = NULL;
+       GList *cur = g_send_stream_list;
+       email_send_stream_list_t *data = NULL;
+       SENDSTREAM **ret = NULL;
        int err = EMAIL_ERROR_NONE;
 
-       for ( ; cur ; cur = g_list_next(cur) ) {
+       for (; cur ; cur = g_list_next(cur)) {
                data = cur->data;
                if (data->account_id == account_id) {
                        if (data->send_stream == NULL || *(data->send_stream) == NULL) {
-                               EM_DEBUG_LOG ("smtp_stream was closed before");
-                               g_send_stream_list = g_list_delete_link (g_send_stream_list, cur);
-                               g_free (data);
+                               EM_DEBUG_LOG("smtp_stream was closed before");
+                               g_send_stream_list = g_list_delete_link(g_send_stream_list, cur);
+                               g_free(data);
                                break;
                        }
 
-                       int reply = smtp_send ( *(data->send_stream), "NOOP", NULL);
+                       int reply = smtp_send(*(data->send_stream), "NOOP", NULL);
                        if (reply/100 == 2) { /* 2xx means a success */
-                               EM_DEBUG_LOG ("reusable smtp_stream found");
+                               EM_DEBUG_LOG("reusable smtp_stream found");
                                return data->send_stream;
-                       }
-                       else {
-                               EM_DEBUG_LOG ("smtp_stream is not reusable");
-                               *(data->send_stream) = smtp_close (*(data->send_stream));
-                               g_send_stream_list = g_list_delete_link (g_send_stream_list, cur);
-                               g_free (data->send_stream);
+                       } else {
+                               EM_DEBUG_LOG("smtp_stream is not reusable");
+                               *(data->send_stream) = smtp_close(*(data->send_stream));
+                               g_send_stream_list = g_list_delete_link(g_send_stream_list, cur);
+                               g_free(data->send_stream);
                                break;
                        }
                }
        }
 
-       ret = em_malloc (sizeof(SENDSTREAM*));
+       ret = em_malloc(sizeof(SENDSTREAM*));
        if (!ret) {
-               EM_DEBUG_EXCEPTION("em_malloc error");
+               EM_DEBUG_EXCEPTION("em_mallocerror");
                goto FINISH_OFF;
        }
 
@@ -1643,17 +1636,17 @@ INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (char *multi_user_name, int ac
                                                                                        EMAIL_CONNECT_FOR_SENDING,
                                                                                        true,
                                                                                        (void **)ret,
-                                                                                       &err))  {
+                                                                                       &err)) {
                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
 
                EM_SAFE_FREE(ret);
                goto FINISH_OFF;
        }
 
-       email_send_stream_list_t *node = em_malloc (sizeof(email_send_stream_list_t));
+       email_send_stream_list_t *node = em_malloc(sizeof(email_send_stream_list_t));
        if (!node) {
-               EM_DEBUG_EXCEPTION ("em_malloc error");
-               *ret = smtp_close (*ret);
+               EM_DEBUG_EXCEPTION("em_mallocerror");
+               *ret = smtp_close(*ret);
                EM_SAFE_FREE(ret);
                goto FINISH_OFF;
        }
@@ -1661,7 +1654,7 @@ INTERNAL_FUNC SENDSTREAM** emcore_get_smtp_stream (char *multi_user_name, int ac
        node->account_id = account_id;
        node->send_stream = ret;
 
-       g_send_stream_list = g_list_prepend (g_send_stream_list, node);
+       g_send_stream_list = g_list_prepend(g_send_stream_list, node);
 
 FINISH_OFF:
 
@@ -1706,7 +1699,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
        char *server_uid = NULL;
        MAILSTREAM *mail_stream = NULL;
 
-       if (!mail_id)  {
+       if (!mail_id) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -1741,8 +1734,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                err = EMAIL_ERROR_NO_RECIPIENT;
                EM_DEBUG_EXCEPTION("No Recipient information [%d]", err);
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                if ((err = em_verify_email_address_of_mail_tbl(mail_tbl_data)) != EMAIL_ERROR_NONE) {
                        err = EMAIL_ERROR_INVALID_ADDRESS;
                        EM_DEBUG_EXCEPTION("em_verify_email_address_of_mail_tbl failed [%d]", err);
@@ -1762,7 +1754,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
        int i = 0;
        EM_VALIDATION_SYSTEM_LOG("INFO", mail_id, "Email Send Start, %s -> %s, success", mail_tbl_data->full_address_from, mail_tbl_data->full_address_to);
        for (i = 0; i < attachment_tbl_count; i++) {
-               if(attachment_tbl_data)
+               if (attachment_tbl_data)
                        EM_VALIDATION_SYSTEM_LOG("FILE", mail_id, "[%s], %d", attachment_tbl_data[i].attachment_path, attachment_tbl_data[i].attachment_size);
        }
 #endif /* __FEATURE_SUPPORT_VALIDATION_SYSTEM__ */
@@ -1775,14 +1767,14 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                goto FINISH_OFF;
        }
 
-       if (!envelope || (!envelope->to && !envelope->cc && !envelope->bcc))  {
+       if (!envelope || (!envelope->to && !envelope->cc && !envelope->bcc)) {
                EM_DEBUG_EXCEPTION(" no recipients found...");
                err = EMAIL_ERROR_NO_RECIPIENT;
                goto FINISH_OFF;
        }
 
        /*  if there is no security option, unset security. */
-       if (!ref_account->outgoing_server_secure_connection)  {
+       if (!ref_account->outgoing_server_secure_connection) {
                stls = (sslstart_t)mail_parameters(NULL, GET_SSLSTART, NULL);
                mail_parameters(NULL, SET_SSLSTART, NULL);
        }
@@ -1793,13 +1785,13 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                goto FINISH_OFF;
        }
 
-       if (ref_account->pop_before_smtp != FALSE)  {
+       if (ref_account->pop_before_smtp != FALSE) {
                if (!emcore_connect_to_remote_mailbox(multi_user_name,
                                                                                                account_id,
                                                                                                0,
                                                                                                true,
                                                                                                (void **)&mail_stream,
-                                                                                               &err))  {
+                                                                                               &err)) {
                        EM_DEBUG_EXCEPTION(" POP before SMTP Authentication failed [%d]", err);
                        if (err == EMAIL_ERROR_CONNECTION_BROKEN)
                                err = EMAIL_ERROR_CANCELLED;
@@ -1807,7 +1799,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                }
        }
 
-       if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_DRAFT, &local_mailbox, false, &err))  {
+       if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_DRAFT, &local_mailbox, false, &err)) {
                EM_DEBUG_EXCEPTION(" emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1819,7 +1811,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                goto FINISH_OFF;
        }
 
-       send_stream = emcore_get_smtp_stream (multi_user_name, account_id, &err);
+       send_stream = emcore_get_smtp_stream(multi_user_name, account_id, &err);
        if (!send_stream) {
                EM_DEBUG_EXCEPTION(" emcore_get_smtp_stream failed [%d]", err);
                if (err == EMAIL_ERROR_CONNECTION_BROKEN)
@@ -1833,7 +1825,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                                                                                        EMAIL_CONNECT_FOR_SENDING,
                                                                                        true,
                                                                                        (void **)&tmp_stream,
-                                                                                       &err))  {
+                                                                                       &err)) {
                EM_DEBUG_EXCEPTION(" emcore_connect_to_remote_mailbox failed [%d]", err);
 
                if (err == EMAIL_ERROR_CONNECTION_BROKEN)
@@ -1866,7 +1858,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
        EM_DEBUG_LOG("opt->req_delivery_receipt [%d]", opt->req_delivery_receipt);
        EM_DEBUG_LOG("mail_tbl_data->report_status [%d]", mail_tbl_data->report_status);
 
-       if (opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON || (mail_tbl_data->report_status & EMAIL_MAIL_REQUEST_DSN))  {
+       if (opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON || (mail_tbl_data->report_status & EMAIL_MAIL_REQUEST_DSN)) {
                EM_DEBUG_LOG("DSN is required.");
                (*send_stream)->protocol.esmtp.dsn.want = 1;
                (*send_stream)->protocol.esmtp.dsn.full = 0;
@@ -1888,7 +1880,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                        err = EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE;
 
 #ifndef __FEATURE_MOVE_TO_OUTBOX_FIRST__
-               if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, false, &err))  {
+               if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &local_mailbox, false, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -1908,13 +1900,13 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
        sent_flag = 1;
 
        /*  sent mail is moved to 'SENT' box or deleted. */
-       if (opt->keep_local_copy)  {
+       if (opt->keep_local_copy) {
                if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name,
                                                                                                        account_id,
                                                                                                        EMAIL_MAILBOX_TYPE_SENTBOX,
                                                                                                        &local_mailbox,
                                                                                                        true,
-                                                                                                       &err))  {
+                                                                                                       &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -1947,8 +1939,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
 
                        if (!emcore_move_mail_on_server(multi_user_name, dest_mbox.account_id, dst_mailbox_id, &mail_id, 1, dest_mbox.name, &err)) {
                                EM_DEBUG_EXCEPTION(" emcore_move_mail_on_server falied [%d]", err);
-                       }
-                       else {
+                       } else {
                                /* Remove ACTIVITY_SAVEMAIL activity */
                                new_activity.activity_id  =  activityid;
                                new_activity.activity_type = ACTIVITY_SAVEMAIL;
@@ -1975,7 +1966,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                                                                                                                EMAIL_MAILBOX_TYPE_OUTBOX,
                                                                                                                &src_mailbox,
                                                                                                                true,
-                                                                                                               &err))  {
+                                                                                                               &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -1989,7 +1980,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
                                if (!emcore_sync_header (multi_user_name, local_mailbox, &local_stream, NULL, NULL, NULL, NULL, NULL, 0, -1, &err)) {
                                        EM_DEBUG_EXCEPTION("emcore_sync_header failed");
                                }
-                               mail_close (local_stream);
+                               mail_close(local_stream);
                                if (!emstorage_get_maildata_by_servermailid(multi_user_name,
                                                                                                                        "0",
                                                                                                                        local_mailbox->mailbox_id,
@@ -2034,7 +2025,7 @@ INTERNAL_FUNC int emcore_send_mail(char *multi_user_name, int mail_id, int *err_
 
                                                        downloaded_mail = em_malloc(sizeof(emstorage_read_mail_uid_tbl_t));
                                                        if (downloaded_mail == NULL) {
-                                                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                                                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                                                goto FINISH_OFF;
                                                        }
@@ -2125,13 +2116,12 @@ FINISH_OFF:
                emcore_show_user_message(multi_user_name, mail_id, EMAIL_ACTION_SEND_MAIL, err);
        }
 
-       if (ret == false && err != EMAIL_ERROR_INVALID_PARAM && mail_tbl_data)  {
+       if (ret == false && err != EMAIL_ERROR_INVALID_PARAM && mail_tbl_data) {
                if (err != EMAIL_ERROR_CANCELLED) {
                        mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SEND_FAILURE;
                        if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", mail_tbl_data->save_status, true, &err2))
                                EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err2);
-               }
-               else {
+               } else {
                        if (EMAIL_MAIL_STATUS_SEND_CANCELED == mail_tbl_data->save_status)
                                EM_DEBUG_LOG("EMAIL_MAIL_STATUS_SEND_CANCELED Already set for ");
                        else {
@@ -2165,7 +2155,7 @@ FINISH_OFF:
                emstorage_free_read_mail_uid(&downloaded_mail, 1, NULL);
 
        if (mail_stream)
-               mail_stream = mail_close (mail_stream);
+               mail_stream = mail_close(mail_stream);
 
        if (stls)
                mail_parameters(NULL, SET_SSLSTART, (void  *)stls);
@@ -2179,7 +2169,7 @@ FINISH_OFF:
        if (fpath) {
                EM_DEBUG_LOG_SEC("REMOVE TEMP FILE  :  %s", fpath);
                remove(fpath);
-               EM_SAFE_FREE (fpath);
+               EM_SAFE_FREE(fpath);
        }
 
        if (local_mailbox)
@@ -2187,23 +2177,22 @@ FINISH_OFF:
 
        if (ret == true) {
                if (!emcore_notify_network_event(NOTI_SEND_FINISH, account_id, NULL, mail_id, 0))
-                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEND_FINISH] Failed");
+                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEND_FINISH] Failed");
 #ifdef __FEATURE_SUPPORT_VALIDATION_SYSTEM__
-               if(mail_tbl_data)
+               if (mail_tbl_data)
                        EM_VALIDATION_SYSTEM_LOG("INFO", mail_id, "Email Send End, %s -> %s, success", mail_tbl_data->full_address_from, mail_tbl_data->full_address_to);
 #endif
-       }
-       else {
+       } else {
                if (!emcore_notify_network_event(NOTI_SEND_FAIL, account_id, NULL, mail_id, err))
-                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEND_FAIL] Failed");
+                       EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEND_FAIL] Failed");
 #ifdef __FEATURE_SUPPORT_VALIDATION_SYSTEM__
-               if(mail_tbl_data)
+               if (mail_tbl_data)
                        EM_VALIDATION_SYSTEM_LOG("INFO", mail_id, "Email Send End, %s -> %s, failed", mail_tbl_data->full_address_from, mail_tbl_data->full_address_to);
 #endif
 
                if (err != EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE) {
                        /* Add alarm for next sending mails */
-                       if(err2 = emcore_create_alarm_for_auto_resend(multi_user_name, AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
+                       if ((err2 = emcore_create_alarm_for_auto_resend(multi_user_name, AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
                                if (err2 != EMAIL_ERROR_MAIL_NOT_FOUND)
                                        EM_DEBUG_EXCEPTION("emcore_create_alarm_for_auto_resend failed [%d]", err2);
                        }
@@ -2246,14 +2235,14 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
        emstorage_mailbox_tbl_t* local_mailbox = NULL;
        int dst_mailbox_id = 0;
 
-       if (!account_id || !input_mailbox_name)  {
+       if (!account_id || !input_mailbox_name) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
 
-       if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false)))  {
+       if (!(ref_account = emcore_get_account_reference(multi_user_name, account_id, false))) {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
                err = EMAIL_ERROR_INVALID_ACCOUNT;
                goto FINISH_OFF;
@@ -2275,7 +2264,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
        }
 
        /*  search mail. */
-       if (!emstorage_mail_search_start(multi_user_name, NULL, account_id, local_mailbox->mailbox_id, 0, &handle, &total, true, &err))  {
+       if (!emstorage_mail_search_start(multi_user_name, NULL, account_id, local_mailbox->mailbox_id, 0, &handle, &total, true, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_mail_search_start failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -2288,7 +2277,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
        }
 
        for (i = 0; i < total ; i++) {
-               if (!emstorage_mail_search_result(handle, RETRIEVE_ID, (void **)&mail_ids[i], true, &err))  {
+               if (!emstorage_mail_search_result(handle, RETRIEVE_ID, (void **)&mail_ids[i], true, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_mail_search_result failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2303,7 +2292,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
 
        mail_send_notify(EMAIL_SEND_PREPARE, 0, 0, account_id, mail_ids[total], err);
 
-       if(local_mailbox)
+       if (local_mailbox)
                emstorage_free_mailbox(&local_mailbox, 1, NULL);
 
        for (i = 0; i < total; i++) {
@@ -2316,20 +2305,20 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                }
 
                /* Skip the mail canceled */
-               if (searched_mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SEND_CANCELED)  {
+               if (searched_mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SEND_CANCELED) {
                        EM_DEBUG_EXCEPTION("The mail was canceled. [%d]", mail_ids[i]);
                        emstorage_free_mail(&searched_mail_tbl_data, 1, &err);
                        searched_mail_tbl_data = NULL;
                        continue;
                }
 
-               if ( (err = emstorage_get_attachment_list(multi_user_name, mail_ids[i], false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
+               if ((err = emstorage_get_attachment_list(multi_user_name, mail_ids[i], false, &attachment_tbl_data, &attachment_tbl_count)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                        goto FINISH_OFF;
                }
 
                /* check for email_address validation */
-               if ( (err = em_verify_email_address_of_mail_tbl(searched_mail_tbl_data)) != EMAIL_ERROR_NONE ) {
+               if ((err = em_verify_email_address_of_mail_tbl(searched_mail_tbl_data)) != EMAIL_ERROR_NONE) {
                        err = EMAIL_ERROR_INVALID_ADDRESS;
                        EM_DEBUG_EXCEPTION("em_verify_email_address_of_mail_tbl failed [%d]", err);
                        goto FINISH_OFF;
@@ -2337,7 +2326,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
 
                searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING;
 
-               if (!emcore_make_rfc822_file_from_mail(multi_user_name, searched_mail_tbl_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fpath, opt, &err))  {
+               if (!emcore_make_rfc822_file_from_mail(multi_user_name, searched_mail_tbl_data, attachment_tbl_data, attachment_tbl_count, &envelope, &fpath, opt, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_make_rfc822_file_from_mail falied [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2359,7 +2348,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                                                                                                        EMAIL_CONNECT_FOR_SENDING,
                                                                                                        true,
                                                                                                        &tmp_stream,
-                                                                                                       &err) || !tmp_stream)  {
+                                                                                                       &err) || !tmp_stream) {
                                EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
 
                                if (err == EMAIL_ERROR_CONNECTION_BROKEN)
@@ -2377,7 +2366,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                        mail_send_notify(EMAIL_SEND_CONNECTION_SUCCEED, 0, 0, account_id, mail_ids[i], err);
 
                        /*  reqest of delivery status. */
-                       if (opt && opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON)  {
+                       if (opt && opt->req_delivery_receipt == EMAIL_OPTION_REQ_DELIVERY_RECEIPT_ON) {
                                stream->protocol.esmtp.dsn.want = 1;
                                stream->protocol.esmtp.dsn.full = 0;
                                stream->protocol.esmtp.dsn.notify.failure = 1;
@@ -2390,13 +2379,13 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                searched_mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SENDING;
 
                /*  update mail status to sending. */
-               if (!emstorage_change_mail_field(multi_user_name, mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err))  {
+               if (!emstorage_change_mail_field(multi_user_name, mail_ids[i], UPDATE_EXTRA_FLAG, searched_mail_tbl_data, true, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
 
                        goto FINISH_OFF;
                }
 
-               if (!emcore_send_mail_smtp(multi_user_name, stream, envelope, fpath, account_id, mail_ids[i], &err))  {
+               if (!emcore_send_mail_smtp(multi_user_name, stream, envelope, fpath, account_id, mail_ids[i], &err)) {
                        EM_DEBUG_EXCEPTION("emcore_send_mail_smtp failed [%d]", err);
                        if (err == SMTP_RESPONSE_EXCEED_SIZE_LIMIT) err = EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE;
 
@@ -2411,7 +2400,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                                                                                                                EMAIL_MAILBOX_TYPE_OUTBOX,
                                                                                                                &local_mailbox,
                                                                                                                false,
-                                                                                                               &err))  {
+                                                                                                               &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -2419,7 +2408,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
 
                        emcore_move_mail(multi_user_name, &mail_ids[i], 1, dst_mailbox_id, EMAIL_MOVED_AFTER_SENDING, 0, NULL);
 
-                       if(local_mailbox)
+                       if (local_mailbox)
                                emstorage_free_mailbox(&local_mailbox, 1, NULL);
 
                        goto FINISH_OFF;
@@ -2433,7 +2422,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                                                                                        UPDATE_EXTRA_FLAG,
                                                                                        searched_mail_tbl_data,
                                                                                        true,
-                                                                                       &err))  {
+                                                                                       &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2445,7 +2434,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                                                                                                                EMAIL_MAILBOX_TYPE_SENTBOX,
                                                                                                                &local_mailbox,
                                                                                                                false,
-                                                                                                               &err))  {
+                                                                                                               &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -2460,7 +2449,7 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                                                                        &err))
                                EM_DEBUG_EXCEPTION("emcore_mail_move falied [%d]", err);
 
-                       if(local_mailbox)
+                       if (local_mailbox)
                                emstorage_free_mailbox(&local_mailbox, 1, NULL);
                } else {
                        if (!emcore_delete_mail(multi_user_name,
@@ -2485,12 +2474,12 @@ INTERNAL_FUNC int emcore_send_saved_mail(char *multi_user_name, int account_id,
                        searched_mail_tbl_data = NULL;
                }
 
-               if(attachment_tbl_data)
+               if (attachment_tbl_data)
                        emstorage_free_attachment(&attachment_tbl_data, attachment_tbl_count, NULL);
 
                mail_free_envelope(&envelope); envelope = NULL;
 
-               if (fpath)  {
+               if (fpath) {
                        remove(fpath);
                        EM_SAFE_FREE(fpath);
                }
@@ -2515,7 +2504,7 @@ FINISH_OFF:
        if (envelope)
                mail_free_envelope(&envelope);
 
-       if (handle)  {
+       if (handle) {
                if (!emstorage_mail_search_end(handle, true, &err2))
                        EM_DEBUG_EXCEPTION("emstorage_mail_search_end failed [%d]", err2);
        }
@@ -2523,22 +2512,22 @@ FINISH_OFF:
        if (searched_mail_tbl_data)
                emstorage_free_mail(&searched_mail_tbl_data, 1, NULL);
 
-       if(attachment_tbl_data)
+       if (attachment_tbl_data)
                emstorage_free_attachment(&attachment_tbl_data, attachment_tbl_count, NULL);
 
-       if (fpath)  {
+       if (fpath) {
                remove(fpath);
                EM_SAFE_FREE(fpath);
        }
 
-       if(local_mailbox)
+       if (local_mailbox)
                emstorage_free_mailbox(&local_mailbox, 1, NULL);
 
        if (ret == true) {
                mail_send_notify(EMAIL_SEND_FINISH, 0, 0, account_id, mail_ids[total], err);
                emcore_show_user_message(multi_user_name, account_id, EMAIL_ACTION_SEND_MAIL, err);
        } else {
-               if(mail_ids) /* prevent 34385 */
+               if (mail_ids) /* prevent 34385 */
                        mail_send_notify(status, 0, 0, account_id, mail_ids[total], err);
                emcore_show_user_message(multi_user_name, account_id, EMAIL_ACTION_SEND_MAIL, err);
        }
@@ -2594,14 +2583,13 @@ static int emcore_send_mail_smtp(char *multi_user_name,
        if (ref_account->user_email_address == NULL) {
                EM_DEBUG_LOG("ref_account->user_email_address is null!!");
                SNPRINTF(buf, sizeof(buf), "FROM:<%s@%s>", env->from->mailbox, env->from->host);
-       }
-       else
+       } else
                SNPRINTF(buf, sizeof(buf), "FROM:<%s>", ref_account->user_email_address);
 
        /*  set DSN for ESMTP */
        if (stream->protocol.esmtp.ok) {
                if (stream->protocol.esmtp.eightbit.ok && stream->protocol.esmtp.eightbit.want)
-                       strncat (buf, " BODY=8BITMIME", sizeof(buf)-(EM_SAFE_STRLEN(buf)+1));
+                       strncat(buf, " BODY=8BITMIME", sizeof(buf)-(EM_SAFE_STRLEN(buf)+1));
 
                EM_DEBUG_LOG("stream->protocol.esmtp.dsn.ok [%d]", stream->protocol.esmtp.dsn.ok);
 
@@ -2611,10 +2599,9 @@ static int emcore_send_mail_smtp(char *multi_user_name,
                                        sizeof(buf)-EM_SAFE_STRLEN(buf)-1);
 
                        if (stream->protocol.esmtp.dsn.envid)
-                               SNPRINTF (buf + EM_SAFE_STRLEN (buf), sizeof(buf)-(EM_SAFE_STRLEN(buf)),
+                               SNPRINTF(buf + EM_SAFE_STRLEN(buf), sizeof(buf)-(EM_SAFE_STRLEN(buf)),
                                                        " ENVID=%.100s", stream->protocol.esmtp.dsn.envid);
-               }
-               else
+               } else
                        EM_DEBUG_LOG("stream->protocol.esmtp.dsn.want is not required or DSN is not supported");
        }
 
@@ -2634,7 +2621,7 @@ static int emcore_send_mail_smtp(char *multi_user_name,
                case SMTP_RESPONSE_OK:
                        break;
 
-               case SMTP_RESPONSE_WANT_AUTH  :
+               case SMTP_RESPONSE_WANT_AUTH:
                case SMTP_RESPONSE_WANT_AUTH2:
                        EM_DEBUG_EXCEPTION("SMTP error : authentication required...");
                        err = EMAIL_ERROR_AUTH_REQUIRED;
@@ -2700,7 +2687,7 @@ static int emcore_send_mail_smtp(char *multi_user_name,
 
                switch (stream->replycode) {
                        case SMTP_RESPONSE_UNAVAIL:
-                       case SMTP_RESPONSE_WANT_AUTH  :
+                       case SMTP_RESPONSE_WANT_AUTH:
                        case SMTP_RESPONSE_WANT_AUTH2:
                                err = EMAIL_ERROR_AUTH_REQUIRED;
                                break;
@@ -2772,7 +2759,7 @@ static int emcore_send_mail_smtp(char *multi_user_name,
                                dataSize = allocSize;
 
                        memset(data, 0x0, dataSize+1);
-                       read_size = fread(data, sizeof (char), dataSize, fp);
+                       read_size = fread(data, sizeof(char), dataSize, fp);
 
                        if (read_size != dataSize) {
                                /* read fail. */
@@ -2788,13 +2775,12 @@ static int emcore_send_mail_smtp(char *multi_user_name,
                                EM_DEBUG_EXCEPTION("Failed to send the data ");
                                err = EMAIL_ERROR_SMTP_SEND_FAILURE;
                                goto FINISH_OFF;
-                       }
-                       else {
+                       } else {
                                sent_percent = (int) ((double)sent / (double)total_fixed * 100.0);
                                if (last_sent_percent + 5 <= sent_percent) {
                                        double progress = (double)sent / (double)total_fixed;
                                        if (!emcore_notify_network_event(NOTI_SEND_START, account_id, NULL, mail_id, sent_percent))
-                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_SEND_START] Failed >>>>");
+                                               EM_DEBUG_EXCEPTION("emcore_notify_network_event[NOTI_SEND_START] Failed >>>>");
                                        last_sent_percent = sent_percent;
 
                                        emcore_update_notification_for_send(account_id, mail_id, progress);
@@ -2825,7 +2811,7 @@ static int emcore_send_mail_smtp(char *multi_user_name,
                        if (last_sent_percent + 5 <= sent_percent) {
                                /* Disabled Temporary
                                if (!emcore_notify_network_event(NOTI_SEND_START, account_id, NULL, mail_id, sent_percent))
-                                       EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_SEND_START] Failed >>>>");
+                                       EM_DEBUG_EXCEPTION(" emcore_notify_network_event[NOTI_SEND_START] Failed >>>>");
                                */
                                last_sent_percent = sent_percent;
                        }
@@ -2913,12 +2899,12 @@ char *emcore_generate_content_id_string(const char *hostname, int *err)
 }
 
 
-/* ------ attach_part ----------------------------------------------------- */
+/* ------ attach_part----------------------------------------------------- */
 /*  data  :  if filename NULL, content data. */
 /*             else absolute path of file to be attached. */
 /*  data_len  :  length of data. if filename not NULL, ignored. */
 /*  file_name :  attahcment name. */
-static int attach_part (BODY *body, const unsigned char *data, int data_len,
+static int attach_part(BODY *body, const unsigned char *data, int data_len,
                                    char *filename, char *content_sub_type, int is_inline, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN_SEC("body[%p], data[%s], data_len[%d], filename[%s], content_sub_type[%s], err_code[%p]", body, data, data_len, filename, content_sub_type, err_code);
@@ -2927,7 +2913,7 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
        int        error = EMAIL_ERROR_NONE;
        int        has_special_character = 0;
        int        base64_file_name_length = 0;
-       int        i= 0;
+       int        i = 0;
        int        mail_type = EMAIL_SMIME_NONE;
        gsize      bytes_read;
        gsize      bytes_written;
@@ -2944,16 +2930,16 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
        GError    *glib_error = NULL;
        CHARSET   *result_charset = NULL;
 
-       if (!body)  {
+       if (!body) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if (body->nested.part)  {
+       if (body->nested.part) {
                last_part = body->nested.part;
 
-               if (last_part != NULL)  {
+               if (last_part != NULL) {
                        while (last_part->next)
                                last_part = last_part->next;
                }
@@ -2961,7 +2947,7 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
 
        /*  PART */
        part = mail_newbody_part();
-       if (part == NULL)  {
+       if (part == NULL) {
                EM_DEBUG_EXCEPTION("mail_newbody_part failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -2984,35 +2970,34 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
        /* part->body.contents.text.data = content_data; */
        /* part->body.contents.text.size = data_len; */
 
-       if (filename)  {   /*  attachment */
+       if (filename) {   /*  attachment */
                source_text.data = (unsigned char*)filename;
                source_text.size = EM_SAFE_STRLEN(filename);
 
                result_charset   = (CHARSET*)utf8_infercharset(&source_text);
 
-               if(result_charset) {
+               if (result_charset) {
                        EM_DEBUG_LOG_SEC("return_charset->name [%s]", result_charset->name);
-                       encoded_file_name = (char*)g_convert (filename, -1, "UTF-8", result_charset->name, &bytes_read, &bytes_written, &glib_error);
-               }
-               else {
+                       encoded_file_name = (char*)g_convert(filename, -1, "UTF-8", result_charset->name, &bytes_read, &bytes_written, &glib_error);
+               } else {
                        i = 0;
-                       while(filename[i]) {
-                               if(filename[i++] & 0x80) {
+                       while (filename[i]) {
+                               if (filename[i++] & 0x80) {
                                        has_special_character = 1;
                                        break;
                                }
                        }
                        EM_DEBUG_LOG("has_special_character [%d]", has_special_character);
-                       if(has_special_character)
-                               encoded_file_name = (char*)g_convert (filename, -1, "UTF-8", "EUC-KR", &bytes_read, &bytes_written, &glib_error);
+                       if (has_special_character)
+                               encoded_file_name = (char*)g_convert(filename, -1, "UTF-8", "EUC-KR", &bytes_read, &bytes_written, &glib_error);
                }
 
                EM_DEBUG_LOG_SEC("encoded_file_name [%s]", encoded_file_name);
 
-               if(encoded_file_name == NULL)
+               if (encoded_file_name == NULL)
                        encoded_file_name = strdup(filename);
 
-               if(!em_encode_base64(encoded_file_name, EM_SAFE_STRLEN(encoded_file_name), &base64_file_name, (unsigned long*)&base64_file_name_length, &error)) {
+               if (!em_encode_base64(encoded_file_name, EM_SAFE_STRLEN(encoded_file_name), &base64_file_name, (unsigned long*)&base64_file_name_length, &error)) {
                        EM_DEBUG_EXCEPTION("em_encode_base64 failed. error [%d]", error);
                        goto FINISH_OFF;
                }
@@ -3021,11 +3006,11 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
 
                EM_DEBUG_LOG("base64_file_name_length [%d]", base64_file_name_length);
 
-               if(result_file_name) {
+               if (result_file_name) {
                        EM_SAFE_FREE(encoded_file_name);
                        encoded_file_name = em_malloc(EM_SAFE_STRLEN(result_file_name) + 15);
-                       if(!encoded_file_name) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed.");
+                       if (!encoded_file_name) {
+                               EM_DEBUG_EXCEPTION("em_mallocfailed.");
                                goto FINISH_OFF;
                        }
                        snprintf(encoded_file_name, EM_SAFE_STRLEN(result_file_name) + 15, "=?UTF-8?B?%s?=", result_file_name);
@@ -3035,7 +3020,7 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
                extension = em_get_extension_from_file_path(filename, NULL);
 
                part->body.type = em_get_content_type_from_extension_string(extension, NULL);
-               if(part->body.type == TYPEIMAGE) {
+               if (part->body.type == TYPEIMAGE) {
                        part->body.subtype = strdup(extension);
                        part->body.encoding = ENCBINARY;
                } else if (part->body.type == TYPEPKCS7_SIGN) {
@@ -3081,7 +3066,7 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
                /*  BODY PARAMETER */
                /*  another parameter or get parameter-list from this   function-parameter */
                param = mail_newbody_parameter();
-               if (param == NULL)  {
+               if (param == NULL) {
                        EM_DEBUG_EXCEPTION("mail_newbody_parameter failed...");
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -3103,7 +3088,7 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
 
                /*  DISPOSITION PARAMETER */
                param = mail_newbody_parameter();
-               if (param == NULL)  {
+               if (param == NULL) {
                        EM_DEBUG_EXCEPTION("mail_newbody_parameter failed...");
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -3117,8 +3102,7 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
 
                if (is_inline)
                        last_part->body.disposition.type = strdup("inline");
-       }
-       else  {
+       } else {
                if (content_sub_type && !strcasecmp(content_sub_type, "pgp-encrypted"))
                        mail_type = EMAIL_PGP_ENCRYPTED;
 
@@ -3133,20 +3117,20 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
                                part->body.sparep = NULL;
 
 
-                       if (!content_sub_type)  {
+                       if (!content_sub_type) {
                                /* Plain text body */
                                part->body.encoding = ENC8BIT;
                                part->body.subtype = cpystr("plain");
                                last_param = part->body.parameter;
 
-                               if (last_param != NULL)  {
+                               if (last_param != NULL) {
                                        while (last_param->next)
                                                last_param = last_param->next;
                                }
 
                                param = mail_newbody_parameter();
 
-                               if (param == NULL)  {
+                               if (param == NULL) {
                                        EM_DEBUG_EXCEPTION("mail_newbody_parameter failed...");
                                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                                        goto FINISH_OFF;
@@ -3159,11 +3143,10 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
                                        if (extract_charset_plain != NULL && extract_charset_plain[0] != '\0')
                                                param->value = cpystr(extract_charset_plain);
                                        g_free(extract_charset_plain);
-                               }
-                               else
+                               } else
                                        param->value = cpystr("UTF-8");
 
-                               if(!param->value)
+                               if (!param->value)
                                        param->value = cpystr("UTF-8");
 
                                param->next = NULL;
@@ -3172,22 +3155,21 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
                                        last_param->next = param;
                                else
                                        part->body.parameter = param;
-                       }
-                       else {
+                       } else {
                                /* HTML text body */
                                part->body.encoding = ENC8BIT;
                                part->body.subtype  = cpystr(content_sub_type);
 
                                last_param = part->body.parameter;
 
-                               if (last_param != NULL)  {
+                               if (last_param != NULL) {
                                        while (last_param->next)
                                                last_param = last_param->next;
                                }
 
                                param = mail_newbody_parameter();
 
-                               if (param == NULL)  {
+                               if (param == NULL) {
                                        EM_DEBUG_EXCEPTION("mail_newbody_parameter failed...");
                                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                                        goto FINISH_OFF;
@@ -3205,12 +3187,11 @@ static int attach_part (BODY *body, const unsigned char *data, int data_len,
                                                }
                                        }
 
-                                       if(!param->value)
+                                       if (!param->value)
                                                param->value = cpystr("UTF-8");
 
                                        EM_SAFE_FREE(extract_charset);
-                               }
-                               else
+                               } else
                                        param->value = cpystr("UTF-8");
                                param->next = NULL;
 
@@ -3262,16 +3243,16 @@ static PART *attach_multipart_with_sub_type(BODY *parent_body, char *sub_type, i
        PART *tail_part_cur = NULL;
        PART *new_part = NULL;
 
-       if (!parent_body || !sub_type)  {
+       if (!parent_body || !sub_type) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if (parent_body->nested.part)  {
+       if (parent_body->nested.part) {
                tail_part_cur = parent_body->nested.part;
 
-               if (tail_part_cur != NULL)  {
+               if (tail_part_cur != NULL) {
                        while (tail_part_cur->next)
                                tail_part_cur = tail_part_cur->next;
                }
@@ -3279,7 +3260,7 @@ static PART *attach_multipart_with_sub_type(BODY *parent_body, char *sub_type, i
 
        new_part = mail_newbody_part();
 
-       if (new_part == NULL)  {
+       if (new_part == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -3337,8 +3318,8 @@ static int attach_attachment_to_body(char *multi_user_name, BODY **multipart_bod
        frame_body->size.bytes = 0;
 
        /*  insert original text_body to frame_body.. */
-       if (!attach_part(frame_body, text_body->sparep, 0, NULL, NULL, false, &error))  {
-               EM_DEBUG_EXCEPTION(" attach_part failed [%d]", error);
+       if (!attach_part(frame_body, text_body->sparep, 0, NULL, NULL, false, &error)) {
+               EM_DEBUG_EXCEPTION(" attach_partfailed [%d]", error);
                goto FINISH_OFF;
        }
 
@@ -3357,7 +3338,7 @@ static int attach_attachment_to_body(char *multi_user_name, BODY **multipart_bod
                prefix_path = strdup("");
        }
 
-       for(i = 0; i < input_attachment_tbl_count; i++) {
+       for (i = 0; i < input_attachment_tbl_count; i++) {
                temp_attachment_tbl = input_attachment_tbl + i;
 
                EM_DEBUG_LOG("insert files - attachment id[%d]", temp_attachment_tbl->attachment_id);
@@ -3365,18 +3346,17 @@ static int attach_attachment_to_body(char *multi_user_name, BODY **multipart_bod
         memset(real_file_path, 0x00, sizeof(real_file_path));
         SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, temp_attachment_tbl->attachment_path);
 
-               if (stat(temp_attachment_tbl->attachment_path, &st_buf) == 0)  {
-                       if (!temp_attachment_tbl->attachment_name)  {
-                               if (!emcore_get_file_name(real_file_path, &name, &error))  {
+               if (stat(temp_attachment_tbl->attachment_path, &st_buf) == 0) {
+                       if (!temp_attachment_tbl->attachment_name) {
+                               if (!emcore_get_file_name(real_file_path, &name, &error)) {
                                        EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", error);
                                        goto FINISH_OFF;
                                }
-                       }
-                       else
+                       } else
                                name = temp_attachment_tbl->attachment_name;
 
-                       if (!attach_part(frame_body, (unsigned char *)real_file_path, 0, name, NULL, false, &error))  {
-                               EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                       if (!attach_part(frame_body, (unsigned char *)real_file_path, 0, name, NULL, false, &error)) {
+                               EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                goto FINISH_OFF;
                        }
                }
@@ -3403,7 +3383,7 @@ static char *emcore_encode_rfc2047_text(char *utf8_text, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("utf8_text[%s], err_code[%p]", utf8_text, err_code);
 
-       if (utf8_text == NULL)  {
+       if (utf8_text == NULL) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return NULL;
@@ -3413,12 +3393,10 @@ static char *emcore_encode_rfc2047_text(char *utf8_text, int *err_code)
 
        EM_DEBUG_FUNC_END();
 
-
        if (len > 0) {
                return emcore_gmime_get_encoding_to_utf8(utf8_text);
 //              return g_strdup(utf8_text);    /* emoji handle */
-        }
-       else
+       } else
                return strdup("");
 }
 
@@ -3426,8 +3404,8 @@ static void emcore_encode_rfc2047_address(ADDRESS *address, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("address[%p], err_code[%p]", address, err_code);
 
-       while (address)  {
-               if (address->personal)  {
+       while (address) {
+               if (address->personal) {
                        char *rfc2047_personal = emcore_encode_rfc2047_text(address->personal, err_code);
                        EM_SAFE_FREE(address->personal);
                        address->personal = rfc2047_personal;
@@ -3450,19 +3428,19 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
        ENVELOPE *envelope                = NULL;
        email_account_t *ref_account      = NULL;
 
-       if (!input_mail_tbl_data || !output_envelope)  {
+       if (!input_mail_tbl_data || !output_envelope) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                error = EMAIL_ERROR_INVALID_PARAM;
                return error; /* prevent 32729 */
        }
 
-       if ( (input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0 && !input_mail_tbl_data->body_download_status) {
+       if ((input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0 && !input_mail_tbl_data->body_download_status) {
                EM_DEBUG_EXCEPTION("input_mail_tbl_data->body_download_status[%p]", input_mail_tbl_data->body_download_status);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if (!(envelope = mail_newenvelope()))  {
+       if (!(envelope = mail_newenvelope())) {
                EM_DEBUG_EXCEPTION("mail_newenvelope failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -3470,18 +3448,18 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
 
        is_incomplete = input_mail_tbl_data->flags_draft_field || (input_mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SENDING);
 
-       if (is_incomplete && (input_mail_tbl_data->account_id > 0))  {
+       if (is_incomplete && (input_mail_tbl_data->account_id > 0)) {
                ref_account = emcore_get_account_reference(multi_user_name, input_mail_tbl_data->account_id, false);
-               if (!ref_account)  {
+               if (!ref_account) {
                        EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", input_mail_tbl_data->account_id);
                        error = EMAIL_ERROR_INVALID_ACCOUNT;
                        goto FINISH_OFF;
                }
 
-               if (ref_account->user_email_address && ref_account->user_email_address[0] != '\0')  {
+               if (ref_account->user_email_address && ref_account->user_email_address[0] != '\0') {
                        char *p = cpystr(ref_account->user_email_address);
 
-                       if (p == NULL)  {
+                       if (p == NULL) {
                                EM_DEBUG_EXCEPTION("cpystr failed...");
                                error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -3496,8 +3474,7 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
                                rfc822_parse_adrlist(&envelope->from, temp_address_string, NULL);
                                EM_SAFE_FREE(temp_address_string);
                                temp_address_string = NULL ;
-                       }
-                       else
+                       } else
                                envelope->from = rfc822_parse_mailbox(&p, NULL);
 
                        EM_SAFE_FREE(p);
@@ -3505,8 +3482,7 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
                                EM_DEBUG_EXCEPTION("rfc822_parse_mailbox failed...");
                                error = EMAIL_ERROR_INVALID_ADDRESS;
                                goto FINISH_OFF;
-                       }
-                       else  {
+                       } else {
                                if (envelope->from->personal == NULL) {
                                        if (ref_account->options.display_name_from && ref_account->options.display_name_from[0] != '\0')
                                                envelope->from->personal = cpystr(ref_account->options.display_name_from);
@@ -3518,10 +3494,10 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
                        }
                }
 
-               if (ref_account->return_address && ref_account->return_address[0] != '\0')  {
+               if (ref_account->return_address && ref_account->return_address[0] != '\0') {
                        char *p = cpystr(ref_account->return_address);
 
-                       if (p == NULL)  {
+                       if (p == NULL) {
                                EM_DEBUG_EXCEPTION("cpystr failed...");
                                error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -3529,10 +3505,9 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
                        envelope->return_path = rfc822_parse_mailbox(&p, NULL);
                        EM_SAFE_FREE(p);
                }
-       }
-       else  {
+       } else {
 /*
-               if (input_mail_tbl_data->full_address_from == NULL)  {
+               if (input_mail_tbl_data->full_address_from == NULL) {
                        EM_DEBUG_EXCEPTION("input_mail_tbl_data->full_address_from[%p]", input_mail_tbl_data->full_address_from);
                        error = EMAIL_ERROR_INVALID_MAIL;
                        goto FINISH_OFF;
@@ -3540,15 +3515,15 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
 */
                int i, j;
 
-               if (input_mail_tbl_data->full_address_from)  {
-                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_from); i < j; i++)  {
+               if (input_mail_tbl_data->full_address_from) {
+                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_from); i < j; i++) {
                                if (input_mail_tbl_data->full_address_from[i] == ';')
                                        input_mail_tbl_data->full_address_from[i] = ',';
                        }
                }
 
-               if (input_mail_tbl_data->full_address_return)  {
-                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_return); i < j; i++)  {
+               if (input_mail_tbl_data->full_address_return) {
+                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_return); i < j; i++) {
                                if (input_mail_tbl_data->full_address_return[i] == ';')
                                        input_mail_tbl_data->full_address_return[i] = ',';
                        }
@@ -3571,22 +3546,22 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
        {
                int i, j;
 
-               if (input_mail_tbl_data->full_address_to)  {
-                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_to); i < j; i++)  {
+               if (input_mail_tbl_data->full_address_to) {
+                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_to); i < j; i++) {
                                if (input_mail_tbl_data->full_address_to[i] == ';')
                                        input_mail_tbl_data->full_address_to[i] = ',';
                        }
                }
 
-               if (input_mail_tbl_data->full_address_cc)  {
-                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_cc); i < j; i++)  {
+               if (input_mail_tbl_data->full_address_cc) {
+                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_cc); i < j; i++) {
                                if (input_mail_tbl_data->full_address_cc[i] == ';')
                                        input_mail_tbl_data->full_address_cc[i] = ',';
                        }
                }
 
-               if (input_mail_tbl_data->full_address_bcc)  {
-                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_bcc); i < j; i++)  {
+               if (input_mail_tbl_data->full_address_bcc) {
+                       for (i = 0, j = EM_SAFE_STRLEN(input_mail_tbl_data->full_address_bcc); i < j; i++) {
                                if (input_mail_tbl_data->full_address_bcc[i] == ';')
                                        input_mail_tbl_data->full_address_bcc[i] = ',';
                        }
@@ -3633,7 +3608,7 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
 
        EM_DEBUG_LOG("rfc822_date : [%s]", rfc822_date_string);
 
-       if (!is_incomplete)  {
+       if (!is_incomplete) {
                char  localtime_string[DATE_STR_LENGTH] = { 0, };
                time_t tn     = time(0);
                struct tm *t  = gmtime(&tn);
@@ -3672,8 +3647,7 @@ static int emcore_make_envelope_from_mail(char *multi_user_name, emstorage_mail_
                /* append last 5byes("+0900") */
                g_strlcat(localtime_string, strchr(rfc822_date_string, '+'), DATE_STR_LENGTH);
                envelope->date = (unsigned char *)cpystr((const char *)localtime_string);
-       }
-       else {
+       } else {
                envelope->date = (unsigned char *)cpystr((const char *)rfc822_date_string);
        }
 
@@ -3704,51 +3678,51 @@ static char *emcore_get_digest_string(int digest_type, int mime_type)
        char p_digest_string[100] = {0, };
 
        switch (mime_type) {
-       case EMAIL_SMIME_SIGNED :
-       case EMAIL_SMIME_ENCRYPTED :
-       case EMAIL_SMIME_SIGNED_AND_ENCRYPTED :
+       case EMAIL_SMIME_SIGNED:
+       case EMAIL_SMIME_ENCRYPTED:
+       case EMAIL_SMIME_SIGNED_AND_ENCRYPTED:
                memset(p_digest_string, 0x00, sizeof(p_digest_string));
                break;
-       case EMAIL_PGP_SIGNED :
-       case EMAIL_PGP_ENCRYPTED :
-       case EMAIL_PGP_SIGNED_AND_ENCRYPTED :
+       case EMAIL_PGP_SIGNED:
+       case EMAIL_PGP_ENCRYPTED:
+       case EMAIL_PGP_SIGNED_AND_ENCRYPTED:
                memset(p_digest_string, 0x00, sizeof(p_digest_string));
                strcpy(p_digest_string, "pgp-");
                break;
        }
 
        switch (digest_type) {
-       case DIGEST_TYPE_SHA1 :
+       case DIGEST_TYPE_SHA1:
                strcat(p_digest_string, "sha1");
                break;
-       case DIGEST_TYPE_MD5 :
+       case DIGEST_TYPE_MD5:
                strcat(p_digest_string, "md5");
                break;
-       case DIGEST_TYPE_RIPEMD160 :
+       case DIGEST_TYPE_RIPEMD160:
                strcat(p_digest_string, "ripemd160");
                break;
-       case DIGEST_TYPE_MD2 :
+       case DIGEST_TYPE_MD2:
                strcat(p_digest_string, "md2");
                break;
-       case DIGEST_TYPE_TIGER192 :
+       case DIGEST_TYPE_TIGER192:
                strcat(p_digest_string, "tiger192");
                break;
-       case DIGEST_TYPE_HAVAL5160 :
+       case DIGEST_TYPE_HAVAL5160:
                strcat(p_digest_string, "haval5160");
                break;
-       case DIGEST_TYPE_SHA256 :
+       case DIGEST_TYPE_SHA256:
                strcat(p_digest_string, "sha256");
                break;
-       case DIGEST_TYPE_SHA384 :
+       case DIGEST_TYPE_SHA384:
                strcat(p_digest_string, "sha384");
                break;
-       case DIGEST_TYPE_SHA512 :
+       case DIGEST_TYPE_SHA512:
                strcat(p_digest_string, "sha512");
                break;
-       case DIGEST_TYPE_SHA224 :
+       case DIGEST_TYPE_SHA224:
                strcat(p_digest_string, "sha224");
                break;
-       case DIGEST_TYPE_MD4 :
+       case DIGEST_TYPE_MD4:
                strcat(p_digest_string, "md4");
                break;
        }
@@ -3785,19 +3759,19 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
        char *prefix_path = NULL;
        char real_file_path[MAX_PATH] = {0};
 
-       if (!input_mail_tbl_data)  {
+       if (!input_mail_tbl_data) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if ( (input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0 && !input_mail_tbl_data->body_download_status) {
+       if ((input_mail_tbl_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0 && !input_mail_tbl_data->body_download_status) {
                EM_DEBUG_EXCEPTION("input_mail_tbl_data->body_download_status[%p]", input_mail_tbl_data->body_download_status);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if ( (error = emcore_make_envelope_from_mail(multi_user_name, input_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
+       if ((error = emcore_make_envelope_from_mail(multi_user_name, input_mail_tbl_data, &envelope)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_make_envelope_from_mail failed [%d]", error);
                goto FINISH_OFF;
        }
@@ -3808,7 +3782,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
        EM_DEBUG_LOG("input_mail_tbl_data->body->attachment_num[%d]", input_mail_tbl_data->attachment_count);
 
        root_body = mail_newbody();
-       if (root_body == NULL)  {
+       if (root_body == NULL) {
                EM_DEBUG_EXCEPTION("mail_newbody failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -3929,7 +3903,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
 
                                text_body = &(part_for_alternative->body);
                                if (!attach_part(text_body, (unsigned char *)real_file_path, 0, NULL, "plain", false, &error)) {
-                                       EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                                       EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                        goto FINISH_OFF;
                                }
                        }
@@ -3941,13 +3915,12 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
                 SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_html);
 
                                html_body = &(part_for_alternative->body);
-                               if (!attach_part (html_body, (unsigned char *)real_file_path, 0, NULL, "html", false, &error)) {
-                                       EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                               if (!attach_part(html_body, (unsigned char *)real_file_path, 0, NULL, "html", false, &error)) {
+                                       EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                        goto FINISH_OFF;
                                }
                        }
-               }
-               else if (input_mail_tbl_data->smime_type == EMAIL_SMIME_NONE &&
+               } else if (input_mail_tbl_data->smime_type == EMAIL_SMIME_NONE &&
                                           (input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html)) {
                        if (input_mail_tbl_data->file_path_plain && EM_SAFE_STRLEN(input_mail_tbl_data->file_path_plain) > 0) {
                                EM_DEBUG_LOG_SEC("file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
@@ -3955,8 +3928,8 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
                 memset(real_file_path, 0x00, sizeof(real_file_path));
                 SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_plain);
 
-                               if (!attach_part (root_body, (unsigned char *)real_file_path, 0, NULL, "plain", false, &error)) {
-                                       EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                               if (!attach_part(root_body, (unsigned char *)real_file_path, 0, NULL, "plain", false, &error)) {
+                                       EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                        goto FINISH_OFF;
                                }
                        }
@@ -3978,13 +3951,13 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
                                if (part_for_related) {
                                        if (!attach_part(&(part_for_related->body), (unsigned char *)real_file_path, 0,
                                                                                          NULL, "html", false, &error)) {
-                                               EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                                               EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                                goto FINISH_OFF;
                                        }
                                } else {
-                                       if (!attach_part (root_body, (unsigned char *)real_file_path, 0,
+                                       if (!attach_part(root_body, (unsigned char *)real_file_path, 0,
                                                                                          NULL, "html", false, &error)) {
-                                               EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                                               EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                                goto FINISH_OFF;
                                        }
                                }
@@ -4001,8 +3974,8 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
                } else if (input_mail_tbl_data->smime_type == EMAIL_PGP_ENCRYPTED || input_mail_tbl_data->smime_type == EMAIL_PGP_SIGNED_AND_ENCRYPTED) {
                        if (input_mail_tbl_data->file_path_plain && EM_SAFE_STRLEN(input_mail_tbl_data->file_path_plain) > 0) {
                                EM_DEBUG_LOG_SEC("file_path_plain[%s]", input_mail_tbl_data->file_path_plain);
-                               if (!attach_part (root_body, NULL, 0, NULL, "pgp-encrypted", false, &error)) {
-                                       EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                               if (!attach_part(root_body, NULL, 0, NULL, "pgp-encrypted", false, &error)) {
+                                       EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                        goto FINISH_OFF;
                                }
                        }
@@ -4015,18 +3988,17 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
                        char *name = NULL;
                        BODY *body_to_attach = NULL;
 
-                       for(i = 0; i < input_attachment_count; i++) {
+                       for (i = 0; i < input_attachment_count; i++) {
                                temp_attachment_tbl = input_attachment_tbl + i;
 
                                EM_DEBUG_LOG_SEC("attachment_name[%s], attachment_path[%s]", temp_attachment_tbl->attachment_name, temp_attachment_tbl->attachment_path);
 
-                               if (!temp_attachment_tbl->attachment_name)  {
-                                       if (!emcore_get_file_name(temp_attachment_tbl->attachment_path, &name, &error))  {
+                               if (!temp_attachment_tbl->attachment_name) {
+                                       if (!emcore_get_file_name(temp_attachment_tbl->attachment_path, &name, &error)) {
                                                EM_DEBUG_EXCEPTION("emcore_get_file_name failed [%d]", error);
                                                continue;
                                        }
-                               }
-                               else
+                               } else
                                        name = temp_attachment_tbl->attachment_name;
 
                                EM_DEBUG_LOG_SEC("name[%s]", name);
@@ -4045,16 +4017,14 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
                                                name,
                                                temp_attachment_tbl->attachment_mime_type,
                                                temp_attachment_tbl->attachment_inline_content_status,
-                                               &error))
-                               {
-                                       EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                                               &error)) {
+                                       EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                        continue;
                                }
                        }
                }
                text_body = NULL;
-       }
-       else if (input_mail_tbl_data->file_path_plain && input_mail_tbl_data->file_path_html) {
+       } else if (input_mail_tbl_data->file_path_plain && input_mail_tbl_data->file_path_html) {
                /* Handle the Multipart/alternative */
                root_body->type    = TYPEMULTIPART;
                root_body->subtype = strdup("ALTERNATIVE");
@@ -4074,7 +4044,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_plain);
 
                        if (!attach_part(root_body, (unsigned char *)real_file_path, 0, NULL, "plain", false, &error)) {
-                               EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                               EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                goto FINISH_OFF;
                        }
                }
@@ -4085,13 +4055,12 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
             memset(real_file_path, 0x00, sizeof(real_file_path));
             SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_tbl_data->file_path_html);
 
-                       if (!attach_part (root_body, (unsigned char *)real_file_path, 0, NULL, "html", false, &error)) {
-                               EM_DEBUG_EXCEPTION("attach_part failed [%d]", error);
+                       if (!attach_part(root_body, (unsigned char *)real_file_path, 0, NULL, "html", false, &error)) {
+                               EM_DEBUG_EXCEPTION("attach_partfailed [%d]", error);
                                goto FINISH_OFF;
                        }
                }
-       }
-       else {
+       } else {
                root_body->type = TYPETEXT;
                root_body->encoding = ENC8BIT;
                if (input_mail_tbl_data->file_path_plain || input_mail_tbl_data->file_path_html) {
@@ -4123,10 +4092,10 @@ INTERNAL_FUNC int emcore_make_rfc822_file_from_mail(char *multi_user_name, emsto
                envelope->references = cpystr(input_mail_tbl_data->message_id);
        }
 
-       if (file_path)  {
+       if (file_path) {
                EM_DEBUG_LOG("write rfc822 : file_path[%p]", file_path);
 
-               if ((error = emcore_write_rfc822 (envelope, root_body, input_mail_tbl_data->priority,
+               if ((error = emcore_write_rfc822(envelope, root_body, input_mail_tbl_data->priority,
                                                     input_mail_tbl_data->report_status, file_path)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_write_rfc822 failed [%d]", error);
                        goto FINISH_OFF;
@@ -4183,7 +4152,7 @@ INTERNAL_FUNC int emcore_make_rfc822_file(char *multi_user_name, email_mail_data
        if (input_attachment_count > 0) {
                modified_attachment_data = em_malloc(sizeof(emstorage_attachment_tbl_t) * input_attachment_count);
                if (modified_attachment_data == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -4252,19 +4221,19 @@ static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope
        char buf[512] = {0x00, };
        int sz = 0;
 
-       if (!envelope || !multipart_body)  {
+       if (!envelope || !multipart_body) {
                EM_DEBUG_EXCEPTION(" envelope[%p], mulitpart_body[%p]", envelope, multipart_body);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if (!(text_body = mail_newbody()))  {
+       if (!(text_body = mail_newbody())) {
                EM_DEBUG_EXCEPTION(" mail_newbody failed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       if (!emcore_get_temp_file_name(&fname, &err))  {
+       if (!emcore_get_temp_file_name(&fname, &err)) {
                EM_DEBUG_EXCEPTION(" emcore_get_temp_file_name failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -4275,7 +4244,7 @@ static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope
                goto FINISH_OFF;
        }
 
-       if (!envelope->from || !envelope->from->mailbox || !envelope->from->host)  {
+       if (!envelope->from || !envelope->from->mailbox || !envelope->from->host) {
                if (!envelope->from)
                        EM_DEBUG_EXCEPTION(" envelope->from[%p]", envelope->from);
                else
@@ -4297,7 +4266,7 @@ static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope
 
        fclose(fp); fp = NULL;
 
-       if (!emcore_get_file_size(fname, &sz, &err))  {
+       if (!emcore_get_file_size(fname, &sz, &err)) {
                EM_DEBUG_EXCEPTION(" emcore_get_file_size failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -4307,7 +4276,7 @@ static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope
        text_body->sparep = EM_SAFE_STRDUP(fname);
        text_body->size.bytes = (unsigned long)sz;
 
-       if (!emcore_get_temp_file_name(&fname, &err))  {
+       if (!emcore_get_temp_file_name(&fname, &err)) {
                EM_DEBUG_EXCEPTION(" emcore_get_temp_file_name failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -4318,7 +4287,7 @@ static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope
                goto FINISH_OFF;
        }
 
-       if (!envelope->references)  {
+       if (!envelope->references) {
                EM_DEBUG_EXCEPTION(" envelope->references[%p]", envelope->references);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -4332,19 +4301,19 @@ static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope
 
     temp_attachment_tbl = (emstorage_attachment_tbl_t *)em_malloc(sizeof(emstorage_attachment_tbl_t));
     if (temp_attachment_tbl == NULL) {
-        EM_DEBUG_EXCEPTION("em_malloc failed");
+        EM_DEBUG_EXCEPTION("em_mallocfailed");
         err = EMAIL_ERROR_OUT_OF_MEMORY;
         goto FINISH_OFF;
     }
 
        temp_attachment_tbl->attachment_path = EM_SAFE_STRDUP(fname);
 
-       if (!emcore_get_file_size(fname, &temp_attachment_tbl->attachment_size, &err))  {
+       if (!emcore_get_file_size(fname, &temp_attachment_tbl->attachment_size, &err)) {
                EM_DEBUG_EXCEPTION(" emcore_get_file_size failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       if (!attach_attachment_to_body(multi_user_name, &m_body, text_body, temp_attachment_tbl, 1, &err))  {
+       if (!attach_attachment_to_body(multi_user_name, &m_body, text_body, temp_attachment_tbl, 1, &err)) {
                EM_DEBUG_EXCEPTION(" attach_attachment_to_body failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -4358,7 +4327,7 @@ static int emcore_get_report_mail_body(char *multi_user_name, ENVELOPE *envelope
 
        /*  set report-type parameter in content-type */
        param = em_malloc(sizeof(PARAMETER));
-       if (!param)  {
+       if (!param) {
                EM_DEBUG_EXCEPTION(" malloc failed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -4436,7 +4405,7 @@ INTERNAL_FUNC int emcore_get_body_buff(char *file_path, char **buff)
        struct stat stbuf;
        if (stat(file_path, &stbuf) == 0 && stbuf.st_size > 0) {
                EM_DEBUG_LOG(" File Size [ %d ] ", stbuf.st_size);
-               read_buff = calloc((stbuf.st_size+ 1), sizeof(char));
+               read_buff = calloc((stbuf.st_size + 1), sizeof(char));
                if (read_buff == NULL) {
                        EM_DEBUG_EXCEPTION("calloc failed");
                        goto FINISH_OFF;
@@ -4475,30 +4444,30 @@ static int emcore_copy_attachment_from_original_mail(char *multi_user_name, int
        emstorage_attachment_tbl_t *target_mail_attachment_array = NULL;
        emstorage_attachment_tbl_t *target_attach = NULL;
 
-       if((err = emstorage_get_attachment_list(multi_user_name, input_original_mail_id, false, &original_mail_attachment_array, &original_mail_attachment_count)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_get_attachment_list(multi_user_name, input_original_mail_id, false, &original_mail_attachment_array, &original_mail_attachment_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       if((err = emstorage_get_attachment_list(multi_user_name, input_target_mail_id, false, &target_mail_attachment_array, &target_mail_attachment_count)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_get_attachment_list(multi_user_name, input_target_mail_id, false, &target_mail_attachment_array, &target_mail_attachment_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_attachment_list failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < original_mail_attachment_count; i++) {
-               for(j = 0; j < target_mail_attachment_count; j++) {
-                       if(strcmp(original_mail_attachment_array[i].attachment_name, target_mail_attachment_array[j].attachment_name) == 0 ) {
+       for (i = 0; i < original_mail_attachment_count; i++) {
+               for (j = 0; j < target_mail_attachment_count; j++) {
+                       if (strcmp(original_mail_attachment_array[i].attachment_name, target_mail_attachment_array[j].attachment_name) == 0) {
                                target_attach = target_mail_attachment_array + j;
 
                                /* If attachment is inline content, fild path should not include attachment id */
-                               if(target_attach->attachment_inline_content_status == 1)
+                               if (target_attach->attachment_inline_content_status == 1)
                                        attachment_id = 0;
                                else
                                        attachment_id = target_attach->attachment_id;
 
                                EM_DEBUG_LOG("attachment_inline_content_status [%d] attachment_id[%d]", target_attach->attachment_inline_content_status, attachment_id);
 
-                               if(!emcore_save_mail_file(multi_user_name,
+                               if (!emcore_save_mail_file(multi_user_name,
                                             target_attach->account_id,
                                             target_attach->mail_id,
                                             attachment_id,
@@ -4515,7 +4484,7 @@ static int emcore_copy_attachment_from_original_mail(char *multi_user_name, int
                                target_attach->attachment_path = EM_SAFE_STRDUP(virtual_file_path);
                                target_attach->attachment_save_status = 1;
 
-                               if(!emstorage_update_attachment(multi_user_name, target_attach, false, &err)) {
+                               if (!emstorage_update_attachment(multi_user_name, target_attach, false, &err)) {
                                        EM_DEBUG_EXCEPTION("emstorage_update_attachment failed [%d]", err);
                                        goto FINISH_OFF;
                                }
@@ -4528,9 +4497,9 @@ static int emcore_copy_attachment_from_original_mail(char *multi_user_name, int
        }
 
 FINISH_OFF:
-       if(original_mail_attachment_array)
+       if (original_mail_attachment_array)
                emstorage_free_attachment(&original_mail_attachment_array, original_mail_attachment_count, NULL);
-       if(target_mail_attachment_array)
+       if (target_mail_attachment_array)
                emstorage_free_attachment(&target_mail_attachment_array, target_mail_attachment_count, NULL);
 
 
@@ -4550,35 +4519,35 @@ INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(
        email_attachment_data_t *attachment_array = NULL;
 
        /* Get mail data */
-       if((err = emcore_get_mail_data(multi_user_name, input_mail_id, &mail_to_be_sent)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_mail_data(multi_user_name, input_mail_id, &mail_to_be_sent)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       if(mail_to_be_sent->reference_mail_id <= 0) {
+       if (mail_to_be_sent->reference_mail_id <= 0) {
                err = EMAIL_ERROR_INVALID_REFERENCE_MAIL;
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_REFERENCE_MAIL");
                goto FINISH_OFF;
        }
 
        /* Get original mail data */
-       if((err = emcore_get_mail_data(multi_user_name, mail_to_be_sent->reference_mail_id, &original_mail)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_mail_data(multi_user_name, mail_to_be_sent->reference_mail_id, &original_mail)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
                goto FINISH_OFF;
        }
 
        /* Check necessity of download */
-       if((err = emcore_get_attachment_data_list(multi_user_name, original_mail->mail_id, &attachment_array, &attachment_count)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_get_attachment_data_list(multi_user_name, original_mail->mail_id, &attachment_array, &attachment_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
                goto FINISH_OFF;
        }
 
        /* If need be, download attachments */
-       for(i = 0; i < attachment_count; i++) {
-               if(attachment_array[i].save_status != 1) {
+       for (i = 0; i < attachment_count; i++) {
+               if (attachment_array[i].save_status != 1) {
                        /* this function is not run by event thread,
                        so cancellable should be set to 0*/
-                       if(!emcore_gmime_download_attachment(multi_user_name, original_mail->mail_id, i + 1, 0, -1, 0, &err)) {
+                       if (!emcore_gmime_download_attachment(multi_user_name, original_mail->mail_id, i + 1, 0, -1, 0, &err)) {
                                EM_DEBUG_EXCEPTION("emcore_gmime_download_attachment failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -4586,27 +4555,27 @@ INTERNAL_FUNC int emcore_send_mail_with_downloading_attachment_of_original_mail(
        }
 
        /* Copy attachment to the mail to be sent */
-       if((err = emcore_copy_attachment_from_original_mail(multi_user_name, original_mail->mail_id, mail_to_be_sent->mail_id)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_copy_attachment_from_original_mail(multi_user_name, original_mail->mail_id, mail_to_be_sent->mail_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_copy_attachment_from_original failed [%d]", err);
                goto FINISH_OFF;
        }
 
        /* Send the mail */
-       if(!emcore_send_mail(multi_user_name, mail_to_be_sent->mail_id, &err)) {
+       if (!emcore_send_mail(multi_user_name, mail_to_be_sent->mail_id, &err)) {
                EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err);
                goto FINISH_OFF;
        }
 FINISH_OFF:
 
-       if(attachment_array)
+       if (attachment_array)
                emcore_free_attachment_data(&attachment_array, attachment_count, NULL);
 
-       if(mail_to_be_sent) {
+       if (mail_to_be_sent) {
                emcore_free_mail_data(mail_to_be_sent);
                EM_SAFE_FREE(mail_to_be_sent);
        }
 
-       if(original_mail) {
+       if (original_mail) {
                emcore_free_mail_data(original_mail);
                EM_SAFE_FREE(original_mail);
        }
@@ -4701,7 +4670,7 @@ static int emcore_sending_alarm_cb(email_alarm_data_t *alarm_data, void *user_pa
 
        event_data = em_malloc(sizeof(email_event_t));
        if (event_data == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -4845,34 +4814,34 @@ static int emcore_auto_resend_cb(email_alarm_data_t *alarm_data, void *user_para
        sorting_rule_list[1].target_attribute                              = EMAIL_MAIL_ATTRIBUTE_MAIL_ID;
        sorting_rule_list[1].sort_order                                    = EMAIL_SORT_ORDER_ASCEND;
 
-       if(err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
                goto FINISH_OFF;
        }
 
        EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
 
-       if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
+       if (!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
                EM_DEBUG_LOG("There is no mails to be sent [%d]", err);
                goto FINISH_OFF;
        }
 
        /* Send mails in loop */
 
-       for(i = 0; i < result_mail_count; i++) {
-               if(!emcore_send_mail(multi_user_name, result_mail_list[i].mail_id, &err)) {
+       for (i = 0; i < result_mail_count; i++) {
+               if (!emcore_send_mail(multi_user_name, result_mail_list[i].mail_id, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_send_mail failed [%d]", err);
                }
 
-               if(attribute_field_name) {
-                       if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, result_mail_list[i].account_id, &(result_mail_list[i].mail_id), 1, attribute_field_name, result_mail_list[i].remaining_resend_times - 1, true, &err)) {
+               if (attribute_field_name) {
+                       if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, result_mail_list[i].account_id, &(result_mail_list[i].mail_id), 1, attribute_field_name, result_mail_list[i].remaining_resend_times - 1, true, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
                        }
                }
        }
 
 FINISH_OFF:
-       EM_SAFE_FREE (conditional_clause_string); /* detected by valgrind */
+       EM_SAFE_FREE(conditional_clause_string); /* detected by valgrind */
        EM_SAFE_FREE(result_mail_list);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -4893,14 +4862,14 @@ INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(char *multi_user_name, int
        int sorting_rule_count = 2;
        int result_mail_count = 0;
 
-       if(input_alarm_interval_in_second <= 0) {
+       if (input_alarm_interval_in_second <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
        /* Check whether the alarm is already existing */
-       if(emcore_check_alarm_by_class_id(EMAIL_ALARM_CLASS_AUTO_RESEND) == EMAIL_ERROR_NONE) {
+       if (emcore_check_alarm_by_class_id(EMAIL_ALARM_CLASS_AUTO_RESEND) == EMAIL_ERROR_NONE) {
                /* already exist */
                err = EMAIL_ERROR_ALREADY_EXISTS;
                goto FINISH_OFF;
@@ -4937,29 +4906,29 @@ INTERNAL_FUNC int emcore_create_alarm_for_auto_resend(char *multi_user_name, int
        sorting_rule_list[1].target_attribute                              = EMAIL_MAIL_ATTRIBUTE_MAIL_ID;
        sorting_rule_list[1].sort_order                                    = EMAIL_SORT_ORDER_ASCEND;
 
-       if(err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, sorting_rule_list, sorting_rule_count, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
                goto FINISH_OFF;
        }
 
        EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
 
-       if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
+       if (!emstorage_query_mail_list(multi_user_name, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
                if (err == EMAIL_ERROR_MAIL_NOT_FOUND)
-                       EM_DEBUG_LOG ("no mail found");
+                       EM_DEBUG_LOG("no mail found");
                else
                        EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", err);
                goto FINISH_OFF;
        }
 
-       if(result_mail_count > 0) {
+       if (result_mail_count > 0) {
                /* Add alarm */
                time(&current_time);
 
                trigger_at_time = current_time + input_alarm_interval_in_second;
 
                if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_AUTO_RESEND, 0, emcore_auto_resend_cb, NULL)) != EMAIL_ERROR_NONE) {
-                       EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
+                       EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]", err);
                        goto FINISH_OFF;
                }
        }
index bf0e57b..c7ef50e 100755 (executable)
@@ -68,7 +68,7 @@ static int emcore_initialize_async_task_handler(email_task_t *input_task)
        EM_DEBUG_FUNC_BEGIN("input_task [%p]", input_task);
        int err = EMAIL_ERROR_NONE;
 
-       if(input_task == NULL) {
+       if (input_task == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -81,7 +81,7 @@ static int emcore_initialize_async_task_handler(email_task_t *input_task)
                        , THREAD_SELF());
 
        /* send notification for 'task start */
-       if(err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_send_task_status_signal failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -94,34 +94,34 @@ FINISH_OFF:
 
 static int emcore_finalize_async_task_handler(email_task_t *input_task, int input_error_code)
 {
-       EM_DEBUG_FUNC_BEGIN("input_task [%p] input_error_code [%d]",input_task ,input_error_code);
+       EM_DEBUG_FUNC_BEGIN("input_task [%p] input_error_code [%d]", input_task, input_error_code);
        int err = EMAIL_ERROR_NONE;
        email_task_status_type_t task_status = EMAIL_TASK_STATUS_FINISHED;
 
-       if(input_task == NULL) {
+       if (input_task == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if(input_error_code != EMAIL_ERROR_NONE) {
+       if (input_error_code != EMAIL_ERROR_NONE) {
                task_status = EMAIL_TASK_STATUS_FAILED;
        }
 
        /* remove task from task table */
-       if(err = emcore_remove_task_from_task_table(NULL, input_task->task_id)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_remove_task_from_task_table(NULL, input_task->task_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_remove_task_from_active_task_pool failed [%d]", err);
                goto FINISH_OFF;
        }
 
        /* remove task id from active task id array */
-       if(err = emcore_remove_task_from_active_task_pool(input_task->task_id)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_remove_task_from_active_task_pool(input_task->task_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_remove_task_from_active_task_pool failed [%d]", err);
                goto FINISH_OFF;
        }
 
        /* send signal for 'task finish or failure */
-       if(err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, task_status, input_error_code, 0)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_send_task_status_signal(input_task->task_type, input_task->task_id, task_status, input_error_code, 0)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_send_task_status_signal failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -143,7 +143,7 @@ INTERNAL_FUNC void* emcore_default_async_task_handler(void *input_param)
        email_task_handler_t *task_handler = NULL;
        void *decoded_task_parameter = NULL;
 
-       if((err = emcore_initialize_async_task_handler(task)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_initialize_async_task_handler(task)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_initialize_async_task_handler failed. [%d]", err);
                goto FINISH_OFF;
        }
@@ -151,12 +151,11 @@ INTERNAL_FUNC void* emcore_default_async_task_handler(void *input_param)
        /* create a thread to do this task */
        if ((err = emcore_get_task_handler_reference(task->task_type, &task_handler)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_LOG("emcore_get_task_handler_reference returns [%d]", err);
-       }
-       else {
+       } else {
                /* Decode parameter */
-               emcore_decode_task_parameter(task->task_type, 
-                                                                       task->task_parameter, 
-                                                                       task->task_parameter_length, 
+               emcore_decode_task_parameter(task->task_type,
+                                                                       task->task_parameter,
+                                                                       task->task_parameter_length,
                                                                        &decoded_task_parameter);
 
                task_handler->task_handler_function(decoded_task_parameter);
@@ -184,9 +183,9 @@ INTERNAL_FUNC int emcore_default_sync_task_handler(void *intput_param)
                EM_DEBUG_LOG("emcore_get_task_handler_reference returns [%d]", err);
        } else {
                /* Decode parameter */
-               emcore_decode_task_parameter(task->task_type, 
-                                                                       task->task_parameter, 
-                                                                       task->task_parameter_length, 
+               emcore_decode_task_parameter(task->task_type,
+                                                                       task->task_parameter,
+                                                                       task->task_parameter_length,
                                                                        &decoded_task_parameter);
 
                return_err = (int *)task_handler->task_handler_function(decoded_task_parameter);
@@ -205,14 +204,14 @@ INTERNAL_FUNC int emcore_default_sync_task_handler(void *intput_param)
 int                   _task_handler_array_size;
 email_task_handler_t **_task_handler_array;
 
-static int emcore_register_task_handler(email_task_type_t input_task_type, 
-                                                                               void* (*input_task_handler)(void *), 
-                                                                               int (*input_task_parameter_encoder)(void*,char**,int*), 
-                                                                               int (*input_task_parameter_decoder)(char*,int,void**))
+static int emcore_register_task_handler(email_task_type_t input_task_type,
+                                                                               void* (*input_task_handler)(void *),
+                                                                               int (*input_task_parameter_encoder)(void*, char**, int*),
+                                                                               int (*input_task_parameter_decoder)(char*, int, void**))
 {
        EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_handler [%p] "
-                                               "input_task_parameter_encoder [%p] input_task_parameter_decoder [%p]", 
-                                               input_task_type, input_task_handler, 
+                                               "input_task_parameter_encoder [%p] input_task_parameter_decoder [%p]",
+                                               input_task_type, input_task_handler,
                                                input_task_parameter_encoder, input_task_parameter_decoder);
 
        int err = EMAIL_ERROR_NONE;
@@ -235,8 +234,7 @@ static int emcore_register_task_handler(email_task_type_t input_task_type,
 
        if (_task_handler_array) {
                _task_handler_array = realloc(_task_handler_array, sizeof(email_task_handler_t*) * _task_handler_array_size);
-       }
-       else {
+       } else {
                _task_handler_array = malloc(sizeof(email_task_handler_t*) * _task_handler_array_size);
        }
 
@@ -279,11 +277,11 @@ INTERNAL_FUNC int emcore_free_task_handler_array()
 
        int i = 0;
 
-       for(i = 0; i < _task_handler_array_size; i++) {
-               EM_SAFE_FREE (_task_handler_array[i]);
+       for (i = 0; i < _task_handler_array_size; i++) {
+               EM_SAFE_FREE(_task_handler_array[i]);
        }
 
-       EM_SAFE_FREE (_task_handler_array);
+       EM_SAFE_FREE(_task_handler_array);
        _task_handler_array_size = 0;
 
        EM_DEBUG_FUNC_END();
@@ -371,8 +369,8 @@ INTERNAL_FUNC int  emcore_decode_task_parameter(email_task_type_t input_task_typ
 
        task_parameter_decoder = task_handler->task_parameter_decoder;
 
-       if ((err = task_parameter_decoder(input_byte_stream, 
-                                                                       input_stream_size, 
+       if ((err = task_parameter_decoder(input_byte_stream,
+                                                                       input_stream_size,
                                                                        output_task_parameter_struct)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("task_parameter_decoder failed [%d]", err);
                goto FINISH_OFF;
@@ -389,10 +387,10 @@ int emcore_fetch_task_from_task_pool(email_task_t **output_task)
        int err = EMAIL_ERROR_NONE;
        int output_task_count;
 
-       if ((err = emstorage_query_task(NULL, 
-                                                                       "WHERE task_status == 1", 
-                                                                       "ORDER BY date_time ASC, task_priority ASC LIMIT 0, 1", 
-                                                                       output_task, 
+       if ((err = emstorage_query_task(NULL,
+                                                                       "WHERE task_status == 1",
+                                                                       "ORDER BY date_time ASC, task_priority ASC LIMIT 0, 1",
+                                                                       output_task,
                                                                        &output_task_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_query_task failed [%d]", err);
                goto FINISH_OFF;
@@ -432,8 +430,8 @@ static int emcore_remove_task_from_active_task_pool(int input_task_id)
        int i = 0;
 
        ENTER_CRITICAL_SECTION(_active_task_pool_lock);
-       for(i = 0; i < MAX_ACTIVE_TASK; i++) {
-               if(_active_task_pool[i].task_id == input_task_id) {
+       for (i = 0; i < MAX_ACTIVE_TASK; i++) {
+               if (_active_task_pool[i].task_id == input_task_id) {
                        _active_task_pool[i].task_id    = 0;
                        _active_task_pool[i].task_type  = 0;
                        _active_task_pool[i].thread_id  = 0;
@@ -442,7 +440,7 @@ static int emcore_remove_task_from_active_task_pool(int input_task_id)
        }
        LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
 
-       if(i >= MAX_ACTIVE_TASK) {
+       if (i >= MAX_ACTIVE_TASK) {
                EM_DEBUG_LOG("couldn't find proper task in active task pool [%d]", input_task_id);
                err = EMAIL_ERROR_TASK_NOT_FOUND;
        }
@@ -463,14 +461,14 @@ INTERNAL_FUNC int emcore_get_active_task_by_thread_id(thread_t input_thread_id,
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < MAX_ACTIVE_TASK; i++) {
-               if(_active_task_pool[i].thread_id == input_thread_id) {
+       for (i = 0; i < MAX_ACTIVE_TASK; i++) {
+               if (_active_task_pool[i].thread_id == input_thread_id) {
                        *output_active_task = _active_task_pool + i;
                        break;
                }
        }
 
-       if(i >= MAX_ACTIVE_TASK) {
+       if (i >= MAX_ACTIVE_TASK) {
                EM_DEBUG_LOG("couldn't find proper task in active task pool [%d]", input_thread_id);
                err = EMAIL_ERROR_TASK_NOT_FOUND;
        }
@@ -495,23 +493,22 @@ static int emcore_find_available_slot_in_active_task_pool(int *result_index)
        }
 
        ENTER_CRITICAL_SECTION(_active_task_pool_lock);
-       for(i = 0; i < MAX_ACTIVE_TASK; i++) {
-               if(_active_task_pool[i].task_id == 0) {
+       for (i = 0; i < MAX_ACTIVE_TASK; i++) {
+               if (_active_task_pool[i].task_id == 0) {
                        break;
                }
        }
 
-       if(i >= MAX_ACTIVE_TASK) {
+       if (i >= MAX_ACTIVE_TASK) {
                EM_DEBUG_EXCEPTION("There is no available task slot");
                err = EMAIL_NO_AVAILABLE_TASK_SLOT;
-       }
-       else {
+       } else {
                _active_task_pool[i].task_id = -1;
                *result_index = i;
        }
        LEAVE_CRITICAL_SECTION(_active_task_pool_lock);
 
-FINISH_OFF :
+FINISH_OFF:
        EM_DEBUG_FUNC_END("err [%d]", err);
        return err;
 }
@@ -527,11 +524,11 @@ void* thread_func_task_manager_loop(void *arg)
        /* while loop */
        while (_task_manager_loop_availability) {
                /* fetch task from DB */
-               if((err = emcore_fetch_task_from_task_pool(&new_task)) == EMAIL_ERROR_NONE) &&
-                       ((err = emcore_find_available_slot_in_active_task_pool(&available_slot_index)) == EMAIL_ERROR_NONE)     ) {
+               if (((err = emcore_fetch_task_from_task_pool(&new_task)) == EMAIL_ERROR_NONE) &&
+                       ((err = emcore_find_available_slot_in_active_task_pool(&available_slot_index)) == EMAIL_ERROR_NONE)) {
 
                        /* update task status as STARTED */
-                       if((err = emcore_update_task_status_on_task_table(NULL, new_task->task_id, EMAIL_TASK_STATUS_STARTED)) != EMAIL_ERROR_NONE) {
+                       if ((err = emcore_update_task_status_on_task_table(NULL, new_task->task_id, EMAIL_TASK_STATUS_STARTED)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("emcore_update_task_status_on_task_table failed [%d]", err);
                        }
                        new_task->active_task_id = available_slot_index;
@@ -543,8 +540,7 @@ void* thread_func_task_manager_loop(void *arg)
                        /* new_task and task_parameter will be free in task handler. */
                        EM_SAFE_FREE(new_task->task_parameter);
                        EM_SAFE_FREE(new_task);
-               }
-               else {
+               } else {
                        /* If there is no task or no available slot, sleep until someone wake you up. */
                        /* Wake up case 1 : by emcore_add_task_to_task_table */
                        /* Wake up case 2 : when some task terminated */
@@ -584,7 +580,8 @@ INTERNAL_FUNC int emcore_start_task_manager_loop()
         goto FINISH_OFF;
     }
 
-FINISH_OFF :
+FINISH_OFF:
+
        EM_DEBUG_FUNC_END("err [%d]", err);
     return err;
 }
@@ -620,7 +617,7 @@ INTERNAL_FUNC int emcore_stop_task_manager_loop()
 
        /* Free _active_task_pool */
 
-       //FINISH_OFF :
+       //FINISH_OFF:
 
        EM_DEBUG_FUNC_END("err [%d]", err);
        return err;
@@ -631,7 +628,7 @@ INTERNAL_FUNC int emcore_add_task_to_task_table(char *multi_user_name, email_tas
        EM_DEBUG_FUNC_BEGIN("input_task_type [%d] input_task_priority [%d] input_task_parameter [%p] input_task_parameter_length [%d] output_task_id [%p]", input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, output_task_id);
        int err = EMAIL_ERROR_NONE;
 
-       if((err = emstorage_add_task(multi_user_name, input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, false, output_task_id)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_add_task(multi_user_name, input_task_type, input_task_priority, input_task_parameter, input_task_parameter_length, false, output_task_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_add_task failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -650,7 +647,7 @@ INTERNAL_FUNC int emcore_remove_task_from_task_table(char *multi_user_name, int
        EM_DEBUG_FUNC_BEGIN("input_task_id [%d]", input_task_id);
        int err = EMAIL_ERROR_NONE;
 
-       if((err = emstorage_delete_task(multi_user_name, input_task_id, true)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_delete_task(multi_user_name, input_task_id, true)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_delete_task failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -665,7 +662,7 @@ static int emcore_update_task_status_on_task_table(char *multi_user_name, int in
        EM_DEBUG_FUNC_BEGIN("input_task_id [%d] task_status [%d]", input_task_id, task_status);
        int err = EMAIL_ERROR_NONE;
 
-       if((err = emstorage_update_task_status(multi_user_name, input_task_id, task_status, true)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_update_task_status(multi_user_name, input_task_id, task_status, true)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_update_task_status failed [%d]", err);
                goto FINISH_OFF;
        }
index ca7a67e..aaff6e4 100755 (executable)
@@ -123,10 +123,9 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAI
 
        tpl_load(tn, TPL_MEM, input_byte_stream, input_stream_size);
        tpl_unpack(tn, 0);
-       if(task_parameter->mail_id_count <= 0 || tb.addr == NULL) {
+       if (task_parameter->mail_id_count <= 0 || tb.addr == NULL) {
                EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]", task_parameter->mail_id_count, tb.addr);
-       }
-       else {
+       } else {
                task_parameter->mail_id_array = tb.addr;
        }
 
@@ -134,7 +133,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAI
 
 FINISH_OFF:
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -150,14 +149,14 @@ INTERNAL_FUNC void* task_handler_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTH
        int task_id = THREAD_SELF();
        task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT *task_param = input_param;
 
-       for(i = 0; i < task_param->mail_id_count; i++) {
-               if((err = emcore_move_mail_to_another_account(task_param->multi_user_name, task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
+       for (i = 0; i < task_param->mail_id_count; i++) {
+               if ((err = emcore_move_mail_to_another_account(task_param->multi_user_name, task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_move_mail_to_another_account failed [%d]", err);
                        goto FINISH_OFF;
                }
 
                /* Send progress signal */
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_IN_PROGRESS, i, task_param->mail_id_count)) != EMAIL_ERROR_NONE)
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_IN_PROGRESS, i, task_param->mail_id_count)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
        }
 
@@ -231,7 +230,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX
        }
 
        task_parameter = em_malloc(sizeof(task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX));
-       if(task_parameter == NULL) {
+       if (task_parameter == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -251,10 +250,9 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX
 
        tpl_load(tn, TPL_MEM, input_byte_stream, input_stream_size);
        tpl_unpack(tn, 0);
-       if(task_parameter->mailbox_id_count <= 0 || tb.addr == NULL) {
+       if (task_parameter->mailbox_id_count <= 0 || tb.addr == NULL) {
                EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]", task_parameter->mailbox_id_count, tb.addr);
-       }
-       else {
+       } else {
                task_parameter->mailbox_id_array = tb.addr;
        }
 
@@ -262,7 +260,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX
 
 FINISH_OFF:
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -350,7 +348,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DO
 
 FINISH_OFF:
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -416,7 +414,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_M
        }
 
        task_parameter = em_malloc(sizeof(task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL));
-       if(task_parameter == NULL) {
+       if (task_parameter == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -438,7 +436,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_M
 
 FINISH_OFF:
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -453,8 +451,8 @@ INTERNAL_FUNC void* task_handler_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL(void *inp
        int *return_err = NULL;
        task_parameter_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL *task_param = input_param;
 
-       if ((err = emcore_schedule_sending_mail(task_param->multi_user_name, 
-                                                                                       task_param->mail_id, 
+       if ((err = emcore_schedule_sending_mail(task_param->multi_user_name,
+                                                                                       task_param->mail_id,
                                                                                        task_param->scheduled_time)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_schedule_sending_mail [%d]", err);
                err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -463,7 +461,7 @@ INTERNAL_FUNC void* task_handler_EMAIL_SYNC_TASK_SCHEDULE_SENDING_MAIL(void *inp
 
        return_err = em_malloc(sizeof(int));
        if (return_err == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -522,24 +520,24 @@ INTERNAL_FUNC int email_encode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(v
        tb_mail_id_array.sz   = sizeof(int) * task_parameter->mail_id_count;
        tb_mail_id_array.addr = task_parameter->mail_id_array;
 
-       switch(attribute_value_type) {
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER :
+       switch (attribute_value_type) {
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER:
                        task_parameter->value_length = 4;
                        tb_value.sz                  = task_parameter->value_length;
                        tb_value.addr                = &task_parameter->value.integer_type_value;
                        break;
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING :
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING:
                        task_parameter->value_length = EM_SAFE_STRLEN(task_parameter->value.string_type_value);
                        tb_value.sz                  = task_parameter->value_length;
                        tb_value.addr                = task_parameter->value.string_type_value;
                        break;
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME :
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME:
                        task_parameter->value_length = 4;
                        tb_value.sz                  = task_parameter->value_length;
                        tb_value.addr                = &task_parameter->value.datetime_type_value;
                        break;
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE :
-               default :
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE:
+               default:
                        EM_DEBUG_EXCEPTION("invalid attribute value type [%d]", attribute_value_type);
                        err = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
@@ -553,12 +551,12 @@ INTERNAL_FUNC int email_encode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(v
 
 FINISH_OFF:
 
-       if(tn)
+       if (tn)
                tpl_free(tn);
 
        if (err != EMAIL_ERROR_NONE) {
                EM_SAFE_FREE(result_data);
-                       
+
                if (task_parameter) {
                        EM_SAFE_FREE(task_parameter->multi_user_name);
                        EM_SAFE_FREE(task_parameter->mail_id_array);
@@ -570,11 +568,11 @@ FINISH_OFF:
        return err;
 }
 
-INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(char *input_byte_stream, 
-                                                                                                                                                       int input_stream_size, 
+INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(char *input_byte_stream,
+                                                                                                                                                       int input_stream_size,
                                                                                                                                                        void **output_task_parameter_struct)
 {
-       EM_DEBUG_FUNC_BEGIN("input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]", 
+       EM_DEBUG_FUNC_BEGIN("input_byte_stream [%p] input_stream_size [%d] output_task_parameter_struct [%p]",
                                                input_byte_stream, input_stream_size, output_task_parameter_struct);
        int err = EMAIL_ERROR_NONE;
        tpl_node *tn = NULL;
@@ -590,7 +588,7 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(c
        }
 
        task_parameter = em_malloc(sizeof(task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE));
-       if(task_parameter == NULL) {
+       if (task_parameter == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -612,39 +610,38 @@ INTERNAL_FUNC int email_decode_task_parameter_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(c
        tpl_load(tn, TPL_MEM, input_byte_stream, input_stream_size);
        tpl_unpack(tn, 0);
 
-       if(task_parameter->mail_id_count <= 0 || tb_mail_id_array.addr == NULL) {
-               EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]", 
+       if (task_parameter->mail_id_count <= 0 || tb_mail_id_array.addr == NULL) {
+               EM_DEBUG_LOG("No mail id list. mail_id_count[%d] addr[%p]",
                                                task_parameter->mail_id_count, tb_mail_id_array.addr);
-       }
-       else {
+       } else {
                task_parameter->mail_id_array = tb_mail_id_array.addr;
        }
 
-       if(tb_value.addr) {
-               if ((err = emcore_get_mail_attribute_value_type(task_parameter->attribute_type, 
+       if (tb_value.addr) {
+               if ((err = emcore_get_mail_attribute_value_type(task_parameter->attribute_type,
                                                                                                                &attribute_value_type)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_get_mail_attribute_value_type failed [%d]", err);
                        goto FINISH_OFF;
                }
 
-               switch(attribute_value_type) {
-                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER :
+               switch (attribute_value_type) {
+                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER:
                                memcpy(&task_parameter->value.integer_type_value, tb_value.addr, tb_value.sz);
                                break;
-                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING :
+                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING:
                                task_parameter->value.string_type_value = em_malloc(tb_value.sz + 1);
-                               if(task_parameter->value.string_type_value == NULL) {
+                               if (task_parameter->value.string_type_value == NULL) {
                                        EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                                        goto FINISH_OFF;
                                }
                                memcpy(&task_parameter->value.string_type_value, tb_value.addr, tb_value.sz);
                                break;
-                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME :
+                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME:
                                memcpy(&task_parameter->value.datetime_type_value, tb_value.addr, tb_value.sz);
                                break;
-                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE :
-                       default :
+                       case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE:
+                       default:
                                EM_DEBUG_EXCEPTION("invalid attribute value type [%d]", attribute_value_type);
                                err = EMAIL_ERROR_INVALID_PARAM;
                                goto FINISH_OFF;
@@ -674,7 +671,7 @@ INTERNAL_FUNC void *task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_pa
 {
        EM_DEBUG_FUNC_BEGIN("input_param [%p]", input_param);
        if (!input_param) { /*prevent 43681*/
-               EM_DEBUG_EXCEPTION("NULL parameter");           
+               EM_DEBUG_EXCEPTION("NULL parameter");
                return NULL;
        }
 
@@ -690,45 +687,45 @@ INTERNAL_FUNC void *task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_pa
                goto FINISH_OFF;
        }
 
-       if ((err = emcore_get_mail_attribute_value_type(task_param->attribute_type, 
+       if ((err = emcore_get_mail_attribute_value_type(task_param->attribute_type,
                                                                                                        &attribute_value_type)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_get_mail_attribute_value_type failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       switch(attribute_value_type) {
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER :
-                       if (!emstorage_set_field_of_mails_with_integer_value(task_param->multi_user_name, 
-                                                                                                                               task_param->account_id, 
-                                                                                                                               task_param->mail_id_array, 
-                                                                                                                               task_param->mail_id_count, 
-                                                                                                                               field_name, 
-                                                                                                                               task_param->value.integer_type_value, 
-                                                                                                                               true, 
+       switch (attribute_value_type) {
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER:
+                       if (!emstorage_set_field_of_mails_with_integer_value(task_param->multi_user_name,
+                                                                                                                               task_param->account_id,
+                                                                                                                               task_param->mail_id_array,
+                                                                                                                               task_param->mail_id_count,
+                                                                                                                               field_name,
+                                                                                                                               task_param->value.integer_type_value,
+                                                                                                                               true,
                                                                                                                                &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
                                goto FINISH_OFF;
                        }
                        break;
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING :
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING:
                        err = EMAIL_ERROR_NOT_SUPPORTED;
                        EM_DEBUG_LOG("EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING is not supported");
                        break;
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME :
-                       if (!emstorage_set_field_of_mails_with_integer_value(task_param->multi_user_name, 
-                                                                                                                               task_param->account_id, 
-                                                                                                                               task_param->mail_id_array, 
-                                                                                                                               task_param->mail_id_count, 
-                                                                                                                               field_name, 
-                                                                                                                               task_param->value.datetime_type_value, 
-                                                                                                                               true, 
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME:
+                       if (!emstorage_set_field_of_mails_with_integer_value(task_param->multi_user_name,
+                                                                                                                               task_param->account_id,
+                                                                                                                               task_param->mail_id_array,
+                                                                                                                               task_param->mail_id_count,
+                                                                                                                               field_name,
+                                                                                                                               task_param->value.datetime_type_value,
+                                                                                                                               true,
                                                                                                                                &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
                                goto FINISH_OFF;
                        }
                        break;
-               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE :
-               default :
+               case EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE:
+               default:
                        EM_DEBUG_LOG("EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_NONE or default");
                        err = EMAIL_ERROR_INVALID_PARAM;
                        break;
@@ -736,7 +733,7 @@ INTERNAL_FUNC void *task_handler_EMAIL_SYNC_TASK_UPDATE_ATTRIBUTE(void *input_pa
 
        return_err = em_malloc(sizeof(int));
        if (return_err == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -751,10 +748,10 @@ FINISH_OFF:
                EM_SAFE_FREE(task_param->value.string_type_value);
        }
 
-       EM_SAFE_FREE (task_param);
+       EM_SAFE_FREE(task_param);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
-       
+
        return (void *)return_err;
 }
 /*-------------------------------------------------------------------------------------------*/
index d6943aa..bb1cc96 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 #include "email-debug-log.h"
 
 
-typedef struct
-{
+typedef struct {
        EMAIL_TIMER_CALLBACK user_callback_function;
        void *callback_user_data;
        int time_id;
-}em_timer_callback_data;
+} em_timer_callback_data;
 
 
 INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData)
@@ -52,8 +51,7 @@ INTERNAL_FUNC int emcore_timer_ex_callback(void *a_pData)
 #endif
 
        em_timer_callback_data *pTimerData = (em_timer_callback_data *)a_pData;
-       if (pTimerData != NULL)
-       {
+       if (pTimerData != NULL) {
                EMAIL_TIMER_CALLBACK pfn_UserCB = pTimerData->user_callback_function;
                pUserData = pTimerData->callback_user_data;
                if (pUserData)
index f1cf6e7..737d662 100755 (executable)
@@ -192,8 +192,7 @@ INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
                                break;
                        }
                }
-       }
-       else {
+       } else {
                result_mailbox_name = (char *)utf8_from_mutf7((unsigned char *)mailbox_name);
                EM_DEBUG_LOG_SEC("result_mailbox_name[%s]", result_mailbox_name);
                if (result_mailbox_name == NULL)
@@ -275,14 +274,12 @@ int emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_
                if (account->incoming_server_requires_apop) {
                        strncat(p, "/apop", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
                }
-       }
-       else  {         /*  smtp */
+       } else  {               /*  smtp */
                long_enc_path_len = EM_SAFE_STRLEN(account->outgoing_server_address) + 64;
 
                *long_enc_path = em_malloc(EM_SAFE_STRLEN(account->outgoing_server_address) + 64);
                if (!*long_enc_path) {
                        EM_DEBUG_EXCEPTION("\t malloc failed...\n");
-
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -315,8 +312,7 @@ int emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_
                if (account->outgoing_server_secure_connection & 0x01) {
                        strncat(p, "/ssl/force_tls_v1_0", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
                        /* strcat(p, "/tryssl"); */
-               }
-               else if (account->outgoing_server_secure_connection & 0x02)
+               } else if (account->outgoing_server_secure_connection & 0x02)
                        strncat(p, "/tls/force_tls_v1_0", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
                else
                        strncat(p, "/notls", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
@@ -329,7 +325,7 @@ int emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_
 #endif
 
        /* Authentication method */
-       switch(authentication_method) {
+       switch (authentication_method) {
        case EMAIL_AUTHENTICATION_METHOD_DEFAULT:
                strncat(p, "/needauth", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
                break;
@@ -349,7 +345,7 @@ int emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_
                }
        }
 
-       if(*long_enc_path)
+       if (*long_enc_path)
            EM_DEBUG_LOG_SEC("long_enc_path [%s]", *long_enc_path);
 
        ret = true;
@@ -420,7 +416,7 @@ int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code)
        int ret = true;
 
        last_slash = rindex(name, '/');
-       last_word = (last_slash)? last_slash+1 : name;
+       last_word = (last_slash) ? last_slash+1 : name;
        if (!last_word) {
                EM_DEBUG_EXCEPTION("Wrong mailbox [%s]", name);
                err = EMAIL_ERROR_INVALID_PARAM;
@@ -429,7 +425,7 @@ int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code)
        }
 
        /* convert the last mailbox folder to utf7 char */
-       last_enc_word = (char*)utf8_to_mutf7 ((unsigned char*)last_word);
+       last_enc_word = (char*)utf8_to_mutf7((unsigned char*)last_word);
        if (!last_enc_word) {
                EM_DEBUG_EXCEPTION("utf8_to_mutf7 failed");
                err = EMAIL_ERROR_INVALID_PARAM;
@@ -444,14 +440,13 @@ int emcore_get_encoded_mailbox_name(char *name, char **enc_name, int *err_code)
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG_SEC("UTF-7 [%s](%d)->[%s](%d)",last_word, strlen(last_word), last_enc_word, strlen(last_enc_word));
+       EM_DEBUG_LOG_SEC("UTF-7 [%s](%d)->[%s](%d)", last_word, strlen(last_word), last_enc_word, strlen(last_enc_word));
 
        /* if last word of mailbox name is UTF-8, replace it */
        /* it is not a subfolder */
        if (!last_slash) {
                ret_enc_name = strdup(last_enc_word);
-       }
-       else { /* it is a subfolder */
+       } else { /* it is a subfolder */
                /*temprarily NULL assigned*/
                *last_slash = '\0';
                int len = strlen(name) + 1 + strlen(last_enc_word); /* including '/' */
@@ -767,7 +762,7 @@ INTERNAL_FUNC int emcore_clear_session(email_session_t *session)
        EM_DEBUG_FUNC_BEGIN();
 
        if (session)
-               memset (session, 0x00, sizeof(email_session_t));
+               memset(session, 0x00, sizeof(email_session_t));
 
        EM_DEBUG_FUNC_END();
        return true;
@@ -815,13 +810,13 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int acco
                }
        }
 
-       EM_DEBUG_LOG_DEV ("rule count [%d]", rule_count);
+       EM_DEBUG_LOG_DEV("rule count [%d]", rule_count);
 
        /* Make query for searching unread mail */
        filter_count = 3;   /* unseen field requires one filter, "flags_seen_field = 0"
                                and "deleted_flag = 0" */
 
-       if (rule_count > 0 )
+       if (rule_count > 0)
                filter_count += (rule_count * 2) + 2; /* one rule requires two filters,"A" "OR", plus two more operator "(" and ")" */
 
 
@@ -834,7 +829,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int acco
 
        filter_list = em_malloc(sizeof(email_list_filter_t) * filter_count);
        if (filter_list == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -842,7 +837,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int acco
        int k = 0;
 
        /* priority sender only, convert one rule to two filters which is composed of from_address and or/and */
-       /* example: ( from_A OR from_B ) AND ... */
+       /* example: (from_A OR from_B) AND ... */
        if (rule_count > 0) {
                /* first, add left parenthesis to from address clause, "(" */
                filter_list[0].list_filter_item_type                   = EMAIL_LIST_FILTER_ITEM_OPERATOR;
@@ -917,7 +912,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int acco
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG_DEV ("conditional_clause_string[%s]", conditional_clause_string);
+       EM_DEBUG_LOG_DEV("conditional_clause_string[%s]", conditional_clause_string);
 
        /* Search the mail of priority sender in DB */
        if ((err = emstorage_query_mail_count(multi_user_name, conditional_clause_string, true, &total_count, &unread_count)) != EMAIL_ERROR_NONE) {
@@ -963,7 +958,7 @@ INTERNAL_FUNC int emcore_display_badge_count(char *multi_user_name, int count)
                goto FINISH_OFF;
        }
 
-       if((badge_err = badge_is_existing("org.tizen.email", &exist)) != BADGE_ERROR_NONE) {
+       if ((badge_err = badge_is_existing("org.tizen.email", &exist)) != BADGE_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("badge_is_existing failed [%d]", badge_err);
                err = EMAIL_ERROR_BADGE_API_FAILED;
                goto FINISH_OFF;
@@ -971,14 +966,14 @@ INTERNAL_FUNC int emcore_display_badge_count(char *multi_user_name, int count)
 
        if (!exist) {
                /* create badge */
-               if((badge_err = badge_create("org.tizen.email", "/usr/bin/email-service")) != BADGE_ERROR_NONE) {
+               if ((badge_err = badge_create("org.tizen.email", "/usr/bin/email-service")) != BADGE_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("badge_create failed [%d]", badge_err);
                        err = EMAIL_ERROR_BADGE_API_FAILED;
                        goto FINISH_OFF;
                }
        }
 
-       if((badge_err = badge_set_count("org.tizen.email", count)) != BADGE_ERROR_NONE) {
+       if ((badge_err = badge_set_count("org.tizen.email", count)) != BADGE_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("badge_set_count failed [%d]", badge_err);
                if (badge_err != BADGE_ERROR_SERVICE_NOT_READY) {
                        err = EMAIL_ERROR_BADGE_API_FAILED;
@@ -1049,7 +1044,7 @@ static int emcore_layout_multi_noti(notification_h noti, int unread_mail, char *
                goto FINISH_OFF;
        }
 
-       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New emails", dgettext(NATIVE_EMAIL_DOMAIN,"IDS_EMAIL_MBODY_NEW_EMAILS_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
+       noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New emails", dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_MBODY_NEW_EMAILS_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_TITLE failed");
                goto FINISH_OFF;
@@ -1115,7 +1110,7 @@ static int emcore_layout_single_noti(notification_h noti, char *account_name, in
        }
 
        if (ids)
-               noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Email", dgettext(NATIVE_EMAIL_DOMAIN,"IDS_ST_HEADER_EMAIL"), NOTIFICATION_VARIABLE_TYPE_NONE);
+               noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Email", dgettext(NATIVE_EMAIL_DOMAIN, "IDS_ST_HEADER_EMAIL"), NOTIFICATION_VARIABLE_TYPE_NONE);
        else
                noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, display_sender, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
@@ -1143,7 +1138,7 @@ static int emcore_layout_single_noti(notification_h noti, char *account_name, in
        if (display_status)
                noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
        else
-               noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, "New email", dgettext(NATIVE_EMAIL_DOMAIN,"IDS_EMAIL_TPOP_NEW_EMAIL_RECEIVED_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
+               noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, "New email", dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_NEW_EMAIL_RECEIVED_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
 
        if (noti_err != NOTIFICATION_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_INFO_1 failed");
@@ -1233,14 +1228,11 @@ static int emcore_get_alert_type(int vibrate_status)
                                alert_type = EMAIL_ALERT_TYPE_MELODY;
                        else
                                alert_type = EMAIL_ALERT_TYPE_NONE;
-               }
-               else if (global_sound_status && email_vibe_status) {
+               } else if (global_sound_status && email_vibe_status) {
                        alert_type = EMAIL_ALERT_TYPE_MELODY_AND_VIB;
-               }
-               else if (global_sound_status) {
+               } else if (global_sound_status) {
                        alert_type = EMAIL_ALERT_TYPE_MELODY;
-               }
-               else if (global_vibe_status) {
+               } else if (global_vibe_status) {
                        alert_type = EMAIL_ALERT_TYPE_VIB;
                }
        }
@@ -1336,7 +1328,7 @@ FINISH_OFF:
 
 INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display)
 {
-       EM_DEBUG_FUNC_BEGIN("account_id[%d] mail_id[%d] unread_mail_count[%d] input_play_alert_tone[%d]", account_id, mail_id, unread_mail_count, input_play_alert_tone );
+       EM_DEBUG_FUNC_BEGIN("account_id[%d] mail_id[%d] unread_mail_count[%d] input_play_alert_tone[%d]", account_id, mail_id, unread_mail_count, input_play_alert_tone);
        int err = EMAIL_ERROR_NONE;
 #ifdef __FEATURE_NOTIFICATION_ENABLE__
        int i = 0;
@@ -1397,10 +1389,10 @@ INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id,
        }
 
        noti = notification_load(NULL, private_id);
-       if(noti == NULL) {
+       if (noti == NULL) {
                EM_DEBUG_EXCEPTION("notification_load failed");
                noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
-               if(noti == NULL) {
+               if (noti == NULL) {
                        EM_DEBUG_EXCEPTION("notification_new failed");
                        err = EMAIL_ERROR_SYSTEM_FAILURE;
                        goto FINISH_OFF;
@@ -1439,7 +1431,7 @@ INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id,
                }
 
                if ((alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_MELODY) && EM_SAFE_STRLEN(alert_tone_path)) {
-                       if(strcmp(alert_tone_path, "silent") == 0) {
+                       if (strcmp(alert_tone_path, "silent") == 0) {
                                if ((noti_err = notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL)) != NOTIFICATION_ERROR_NONE) {
                                        EM_DEBUG_EXCEPTION("notification_set_sound failed [%d]", noti_err);
                                        err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -1532,7 +1524,7 @@ INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id,
                    unseen = EMAIL_NOTI_MAX_MAIL_ID;
                value = (char **)em_malloc(unseen * sizeof(char *));
                if (value == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
                }
@@ -1631,7 +1623,7 @@ FINISH_OFF:
 
 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)
 {
-       EM_DEBUG_FUNC_BEGIN("account_id: %d, mail_id: %d, action:%d", account_id, mail_id, action );
+       EM_DEBUG_FUNC_BEGIN("account_id: %d, mail_id: %d, action:%d", account_id, mail_id, action);
        int err = EMAIL_ERROR_NONE;
 #ifdef __FEATURE_NOTIFICATION_ENABLE__
        int private_id = 0;
@@ -1668,7 +1660,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);
        if (g_sending_noti_handle) {
-               if((noti_err = notification_free(g_sending_noti_handle)) != NOTIFICATION_ERROR_NONE)
+               if ((noti_err = notification_free(g_sending_noti_handle)) != NOTIFICATION_ERROR_NONE)
                        err = EMAIL_ERROR_NOTI;
                g_sending_noti_handle = NULL;
        }
@@ -1725,7 +1717,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int ac
        }
 
        switch (action) {
-       case EMAIL_ACTION_SEND_MAIL :
+       case EMAIL_ACTION_SEND_MAIL:
 /*
                setlocale(LC_MESSAGES, vconf_get_str(VCONFKEY_LANGSET));
                bindtextdomain("sys_string", "/usr/share/locale");
@@ -1735,7 +1727,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int ac
                bindtextdomain(NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale");
                textdomain(NATIVE_EMAIL_DOMAIN);
 
-               switch(sending_error) {
+               switch (sending_error) {
                case EMAIL_ERROR_NONE:
                        dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_EMAIL_SENT");
                        break;
@@ -1851,7 +1843,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int ac
 
                break;
 
-       case EMAIL_ACTION_SENDING_MAIL :
+       case EMAIL_ACTION_SENDING_MAIL:
 
                if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("notification_set_text_domain failed [%d]", noti_err);
@@ -1909,9 +1901,10 @@ INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int ac
 
                break;
 
-       default :
-               if ((noti_err = notification_free (noti)) != NOTIFICATION_ERROR_NONE) {
-                       EM_DEBUG_EXCEPTION ("notification_free error [%d]", noti_err);
+       default:
+
+               if ((noti_err = notification_free(noti)) != NOTIFICATION_ERROR_NONE) {
+                       EM_DEBUG_EXCEPTION("notification_free error [%d]", noti_err);
                        err = EMAIL_ERROR_NOTI;
                }
 
@@ -1996,7 +1989,7 @@ INTERNAL_FUNC int emcore_show_user_message(char *multi_user_name, int id, email_
                        return false;
                }
 
-               EM_DEBUG_LOG ("smtp_stream : sent_end");
+               EM_DEBUG_LOG("smtp_stream : sent_end");
                if (emcore_add_notification_for_send(multi_user_name, mail_table_data->account_id, id, action, error, display) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_notification_set error");
                        goto FINISH_OFF;
@@ -2051,8 +2044,7 @@ INTERNAL_FUNC int emcore_is_storage_full()
                EM_DEBUG_EXCEPTION("ret_from_storage_lib [%d]", ret_from_storage_lib);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                unsigned long i_free = (stat_result.f_bsize*stat_result.f_bavail) / (1024 * 1024);
                if (i_free < EMAIL_LIMITATION_FREE_SPACE) {
                        EM_DEBUG_EXCEPTION("total[%lf] avail[%lf]", (double)stat_result.f_frsize*stat_result.f_blocks, (double)stat_result.f_bsize*stat_result.f_bavail);
@@ -2077,7 +2069,7 @@ int emcore_calc_mail_size(char *multi_user_name, email_mail_data_t *input_mail_d
     char                   *prefix_path = NULL;
     char                   real_file_path[255] = {0};
 
-       if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) || (!input_attachment_count &&input_attachment_data_list) || !output_size)  {
+       if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) || (!input_attachment_count && input_attachment_data_list) || !output_size)  {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -2120,7 +2112,7 @@ int emcore_calc_mail_size(char *multi_user_name, email_mail_data_t *input_mail_d
                mail_size += st_buf.st_size;
        }
 
-       for(i = 0; i < input_attachment_count; i++)  {
+       for (i = 0; i < input_attachment_count; i++)  {
         memset(real_file_path, 0x00, sizeof(real_file_path));
         SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_attachment_data_list[i].attachment_path);
 
@@ -2158,7 +2150,7 @@ char *emcore_get_alias_of_mailbox(const char *mailbox_path)
        mailbox = g_strdup(mailbox_path);
        token_list = g_strsplit_set(mailbox, "/\\", -1);
 
-       if(token_list == NULL) {
+       if (token_list == NULL) {
                EM_DEBUG_LOG("g_strsplit_set failed.");
         if (mailbox)
             g_free(mailbox);
@@ -2270,8 +2262,7 @@ void emcore_fill_address_information_of_mail_tbl(char *multi_user_name, emstorag
        if (emcore_get_first_address(mail_data->full_address_from, &first_alias, &first_address) == true) {
                if (first_alias == NULL) {
                        mail_data->alias_sender = EM_SAFE_STRDUP(first_address);
-               }
-               else {
+               } else {
                        mail_data->alias_sender = first_alias;
                        first_alias = NULL;
                }
@@ -2339,7 +2330,7 @@ static struct email_attribute_info _mail_attribute_info_array[] = {
                {EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME, "mailbox_name", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
                {EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE, "mailbox_type", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
                {EMAIL_MAIL_ATTRIBUTE_SUBJECT, "subject", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
-               {EMAIL_MAIL_ATTRIBUTE_DATE_TIME, "date_time",EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
+               {EMAIL_MAIL_ATTRIBUTE_DATE_TIME, "date_time", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
                {EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_STATUS, "server_mail_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
                {EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME, "server_mailbox_name", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
                {EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID, "server_mail_id", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
@@ -2351,45 +2342,45 @@ static struct email_attribute_info _mail_attribute_info_array[] = {
                {EMAIL_MAIL_ATTRIBUTE_BCC, "full_address_bcc", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
                {EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS, "body_download_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
                {EMAIL_MAIL_ATTRIBUTE_MAIL_SIZE, "mail_size", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN, "file_path_plain",EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
-               {EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML,"file_path_html", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
-               {EMAIL_MAIL_ATTRIBUTE_FILE_SIZE,"file_size", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD,"flags_seen_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD,"flags_deleted_field",EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER },
-               {EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD,"flags_flagged_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD,"flags_answered_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD,"flags_recent_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD,"flags_draft_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD,"flags_forwarded_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_DRM_STATUS,"drm_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_PRIORITY,"priority", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS,"save_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS,"lock_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS,"report_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT,"attachment_count", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT,"inline_content_count", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_THREAD_ID,"thread_id", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT,"thread_item_count", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT,"preview_text", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
-               {EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS,"meeting_request_status", },
-               {EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS,"message_class", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE,"digest_type", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE,"smime_type", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_SCHEDULED_SENDING_TIME,"scheduled_sending_time", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
-               {EMAIL_MAIL_ATTRIBUTE_REMAINING_RESEND_TIMES,"remaining_resend_times", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_TAG_ID,"tag_id", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_REPLIED_TIME,"replied_time", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
-               {EMAIL_MAIL_ATTRIBUTE_FORWARDED_TIME,"forwarded_time", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
-               {EMAIL_MAIL_ATTRIBUTE_RECIPIENT_ADDRESS,"email_recipient_address", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
-               {EMAIL_MAIL_ATTRIBUTE_EAS_DATA_LENGTH_TYPE,"eas_data_length", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
-               {EMAIL_MAIL_ATTRIBUTE_EAS_DATA_TYPE,"eas_data", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_BINARY}
+               {EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN, "file_path_plain", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
+               {EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML, "file_path_html", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
+               {EMAIL_MAIL_ATTRIBUTE_FILE_SIZE, "file_size", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD, "flags_seen_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD, "flags_deleted_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER },
+               {EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD, "flags_flagged_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD, "flags_answered_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD, "flags_recent_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD, "flags_draft_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD, "flags_forwarded_field", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_DRM_STATUS, "drm_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_PRIORITY, "priority", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS, "save_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS, "lock_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS, "report_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT, "attachment_count", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT, "inline_content_count", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_THREAD_ID, "thread_id", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT, "thread_item_count", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT, "preview_text", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
+               {EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS, "meeting_request_status", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS, "message_class", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE, "digest_type", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE, "smime_type", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_SCHEDULED_SENDING_TIME, "scheduled_sending_time", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
+               {EMAIL_MAIL_ATTRIBUTE_REMAINING_RESEND_TIMES, "remaining_resend_times", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_TAG_ID, "tag_id", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_REPLIED_TIME, "replied_time", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
+               {EMAIL_MAIL_ATTRIBUTE_FORWARDED_TIME, "forwarded_time", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_TIME},
+               {EMAIL_MAIL_ATTRIBUTE_RECIPIENT_ADDRESS, "email_recipient_address", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_STRING},
+               {EMAIL_MAIL_ATTRIBUTE_EAS_DATA_LENGTH_TYPE, "eas_data_length", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_INTEGER},
+               {EMAIL_MAIL_ATTRIBUTE_EAS_DATA_TYPE, "eas_data", EMAIL_MAIL_ATTRIBUTE_VALUE_TYPE_BINARY}
 };
 
 INTERNAL_FUNC char* emcore_get_mail_field_name_by_attribute_type(email_mail_attribute_type input_attribute_type)
 {
        EM_DEBUG_FUNC_BEGIN("input_attribute_type [%d]", input_attribute_type);
 
-       if(input_attribute_type > EMAIL_MAIL_ATTRIBUTE_EAS_DATA_TYPE || input_attribute_type < 0) {
+       if (input_attribute_type > EMAIL_MAIL_ATTRIBUTE_EAS_DATA_TYPE || input_attribute_type < 0) {
                EM_DEBUG_EXCEPTION("Invalid input_attribute_type [%d]", input_attribute_type);
                return NULL;
        }
@@ -2404,7 +2395,7 @@ INTERNAL_FUNC int emcore_get_attribute_type_by_mail_field_name(char *input_mail_
        int i = 0;
        int err = EMAIL_ERROR_DATA_NOT_FOUND;
 
-       if(!input_mail_field_name || !output_mail_attribute_type) {
+       if (!input_mail_field_name || !output_mail_attribute_type) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -2434,8 +2425,8 @@ INTERNAL_FUNC int emcore_get_mail_attribute_value_type(email_mail_attribute_type
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < EMAIL_MAIL_ATTRIBUTE_END; i++) {
-               if(input_attribute_type == _mail_attribute_info_array[i].attribute_type) {
+       for (i = 0; i < EMAIL_MAIL_ATTRIBUTE_END; i++) {
+               if (input_attribute_type == _mail_attribute_info_array[i].attribute_type) {
                        value_type = _mail_attribute_info_array[i].attribute_value_type;
                        break;
                }
@@ -2538,7 +2529,7 @@ int emcore_strip_mail_body_from_file(char *multi_user_name, emstorage_mail_tbl_t
                }
 
                if (!(buf = (char*)em_malloc(sizeof(char)*(st_buf.st_size + 1)))) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        goto FINISH_OFF;
                }
 
@@ -2560,7 +2551,7 @@ int emcore_strip_mail_body_from_file(char *multi_user_name, emstorage_mail_tbl_t
 
        if (buf) {
                em_trim_left(buf);
-               if(encoding_type && strcasecmp(encoding_type, "UTF-8") != 0) {
+               if (encoding_type && strcasecmp(encoding_type, "UTF-8") != 0) {
                        EM_DEBUG_LOG("encoding_type [%s]", encoding_type);
 
                        if (strcasecmp(encoding_type, "ks_c_5601-1987") == 0 ||
@@ -2572,7 +2563,7 @@ int emcore_strip_mail_body_from_file(char *multi_user_name, emstorage_mail_tbl_t
 
                        utf8_encoded_string = (char*)g_convert(buf, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
 
-                       if(utf8_encoded_string == NULL) {
+                       if (utf8_encoded_string == NULL) {
                                if (!g_error_matches(glib_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) {
                            EM_SAFE_FREE(*stripped_text);
                                        *stripped_text = EM_SAFE_STRDUP(buf);
@@ -2660,7 +2651,7 @@ int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_p
         memset(real_file_path, 0x00, sizeof(real_file_path));
         SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_html_path);
 
-               if(err = em_get_encoding_type_from_file_path(input_html_path, &encoding_type)) != EMAIL_ERROR_NONE) {
+               if ((err = em_get_encoding_type_from_file_path(input_html_path, &encoding_type)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2678,7 +2669,7 @@ int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_p
         SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_plain_path);
 
                /*  get preview text from plain text file */
-               if(err = em_get_encoding_type_from_file_path(input_plain_path, &encoding_type)) != EMAIL_ERROR_NONE) {
+               if ((err = em_get_encoding_type_from_file_path(input_plain_path, &encoding_type)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -2703,13 +2694,13 @@ int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_p
                }
 
                if (!(local_preview_text = (char*)em_malloc(sizeof(char) * local_preview_buffer_length))) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        goto FINISH_OFF;
                }
 
                byte_read = fread(local_preview_text, sizeof(char), local_preview_buffer_length - 1, fp_plain);
 
-               if(byte_read <=0) { /*prevent 26249*/
+               if (byte_read <= 0) { /*prevent 26249*/
                        EM_SAFE_FREE(local_preview_text);
                        err = EMAIL_ERROR_NULL_VALUE;
                        if (ferror(fp_plain)) {
@@ -2724,7 +2715,7 @@ int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_p
 
                em_trim_left(local_preview_text);
 
-               if(encoding_type && strcasecmp(encoding_type, "UTF-8") != 0) {
+               if (encoding_type && strcasecmp(encoding_type, "UTF-8") != 0) {
                        EM_DEBUG_LOG("encoding_type [%s]", encoding_type);
 
                        if (strcasecmp(encoding_type, "ks_c_5601-1987") == 0 ||
@@ -2736,8 +2727,8 @@ int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_p
 
                        utf8_encoded_string = (char *)g_convert(local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
 
-                       if(utf8_encoded_string == NULL) {
-                               if (!g_error_matches (glib_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) {
+                       if (utf8_encoded_string == NULL) {
+                               if (!g_error_matches(glib_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) {
                                        goto FINISH_OFF;
                                }
                                EM_DEBUG_LOG("Extract the preview text, again");
@@ -2797,8 +2788,7 @@ INTERNAL_FUNC int emcore_add_transaction_info(int mail_id, int handle , int *err
        if (!pTransinfo) {
                pTransinfo = pTemp ;
                g_transaction_info_list = pTransinfo ;
-       }
-       else {
+       } else {
                while (pTransinfo->next)
                        pTransinfo = pTransinfo->next;
                pTransinfo->next = pTemp;
@@ -2833,15 +2823,14 @@ INTERNAL_FUNC int emcore_get_handle_by_mailId_from_transaction_info(int mail_id,
                        ret = true;
                        EM_DEBUG_LOG("*pHandle[%d]", *pHandle);
                        break;
-               }
-               else
+               } else
                        pTransinfo = pTransinfo->next ;
-       }while (pTransinfo);
+       } while (pTransinfo);
        EM_DEBUG_FUNC_END();
        return ret;
 }
 
-INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id )
+INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id)
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%d]", mail_id);
 
@@ -2863,21 +2852,19 @@ INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id )
                        if (!pTemp) {
                                EM_SAFE_FREE(pTransinfo) ;
                                g_transaction_info_list = NULL;
-                       }
-                       else {
+                       } else {
                                pTransinfo->mail_id = pTransinfo->next->mail_id;
-                               pTransinfo->handle = pTransinfo->next->handle ;
+                               pTransinfo->handle = pTransinfo->next->handle;
                                pTransinfo->next = pTransinfo->next->next;
 
                                EM_SAFE_FREE(pTemp);
                        }
                        break;
-               }
-               else {
+               } else {
                        pTransinfo = pTransinfo->next ;
                }
 
-       }while (pTransinfo);
+       } while (pTransinfo);
        EM_DEBUG_FUNC_END();
        return true;
 }
@@ -2885,7 +2872,7 @@ INTERNAL_FUNC int emcore_delete_transaction_info_by_mailId(int mail_id )
 
 #include <regex.h>
 
-INTERNAL_FUNC int reg_replace (char *input_source_text, char *input_old_pattern_string, char *input_new_string)
+INTERNAL_FUNC int reg_replace(char *input_source_text, char *input_old_pattern_string, char *input_new_string)
 {
        int         error_code = EMAIL_ERROR_NONE;
        char       *pos = NULL;
@@ -2893,7 +2880,7 @@ INTERNAL_FUNC int reg_replace (char *input_source_text, char *input_old_pattern_
        regmatch_t *pmatch = NULL;
        regex_t     reg_pattern;
 
-       if(!input_source_text || !input_old_pattern_string || !input_new_string) {
+       if (!input_source_text || !input_old_pattern_string || !input_new_string) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                error_code = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -2910,15 +2897,15 @@ INTERNAL_FUNC int reg_replace (char *input_source_text, char *input_old_pattern_
 
        EM_DEBUG_LOG("nmatch [%d]", nmatch);
 
-       if(nmatch < 1) {
+       if (nmatch < 1) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_DATA");
                error_code = EMAIL_ERROR_INVALID_DATA;
                goto FINISH_OFF;
        }
 
-       pmatch = (regmatch_t*)em_malloc(sizeof(regmatch_t) * nmatch);
+       pmatch = (regmatch_t *)em_malloc(sizeof(regmatch_t) * nmatch);
 
-       if(pmatch == NULL) {
+       if (pmatch == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                error_code = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -2932,29 +2919,28 @@ INTERNAL_FUNC int reg_replace (char *input_source_text, char *input_old_pattern_
 
                        EM_DEBUG_LOG("so [%d], n [%d]", so, n);
 
-                       if (so < 0 || EM_SAFE_STRLEN (input_new_string) + n - 1 > source_text_length)
+                       if (so < 0 || EM_SAFE_STRLEN(input_new_string) + n - 1 > source_text_length)
                                break;
 
-                       memmove (pos + n, pos + 2, EM_SAFE_STRLEN (pos) - 1);
-                       memmove (pos, input_source_text + so, n);
+                       memmove(pos + n, pos + 2, EM_SAFE_STRLEN(pos) - 1);
+                       memmove(pos, input_source_text + so, n);
                        pos = pos + n - 2;
                }
        }
 
-       for (pos = input_source_text; !regexec (&reg_pattern, pos, 1, pmatch, 0);) {
+       for (pos = input_source_text; !regexec(&reg_pattern, pos, 1, pmatch, 0); ) {
                n = pmatch[0].rm_eo - pmatch[0].rm_so;
                pos += pmatch[0].rm_so;
-
-               memmove (pos + EM_SAFE_STRLEN (input_new_string), pos + n, EM_SAFE_STRLEN (pos) - n + 1);
-               memmove (pos, input_new_string, EM_SAFE_STRLEN (input_new_string));
-               pos += EM_SAFE_STRLEN (input_new_string);
+               memmove(pos + EM_SAFE_STRLEN(input_new_string), pos + n, EM_SAFE_STRLEN(pos) - n + 1);
+               memmove(pos, input_new_string, EM_SAFE_STRLEN(input_new_string));
+               pos += EM_SAFE_STRLEN(input_new_string);
                n_count++;
        }
 
 FINISH_OFF:
 
        EM_SAFE_FREE(pmatch);
-       regfree (&reg_pattern);
+       regfree(&reg_pattern);
 
        EM_DEBUG_FUNC_END("error_code [%d]", error_code);
        return error_code;
@@ -3071,7 +3057,8 @@ FINISH_OFF:
        return;
 }
 
-static void emcore_default_xml_error_handler(void *ctx, const char *msg, ...) {
+static void emcore_default_xml_error_handler(void *ctx, const char *msg, ...)
+{
        EM_DEBUG_EXCEPTION("htmlReadFile failed");
 }
 
@@ -3167,7 +3154,7 @@ INTERNAL_FUNC int emcore_send_noti_for_new_mail(int account_id, char *mailbox_na
 
        if (emcore_notify_network_event(NOTI_DOWNLOAD_NEW_MAIL, account_id, param_string, 0, 0) == 0) { /*  failed */
                error_code = EMAIL_ERROR_UNKNOWN;
-               EM_DEBUG_EXCEPTION("emcore_notify_network_event is failed");
+               EM_DEBUG_EXCEPTION("emcore_notify_network_eventis failed");
                goto FINISH_OFF;
        }
 
@@ -3185,14 +3172,14 @@ int convert_app_err_to_email_err(int app_error)
 {
        int err = EMAIL_ERROR_NONE;
 
-       switch(app_error) {
-       case APP_CONTROL_ERROR_NONE :
+       switch (app_error) {
+       case APP_CONTROL_ERROR_NONE:
                err = EMAIL_ERROR_NONE;
                break;
-       case APP_CONTROL_ERROR_INVALID_PARAMETER :
+       case APP_CONTROL_ERROR_INVALID_PARAMETER:
                err = EMAIL_ERROR_INVALID_PARAM;
                break;
-       case APP_CONTROL_ERROR_OUT_OF_MEMORY :
+       case APP_CONTROL_ERROR_OUT_OF_MEMORY:
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                break;
        default:
@@ -3287,12 +3274,12 @@ INTERNAL_FUNC int emcore_clear_notifications(char *multi_user_name, int account_
        int error_code = EMAIL_ERROR_NONE;
 
        if (account_id == ALL_ACCOUNT) {
-               if(!emstorage_get_account_list(multi_user_name, &account_count, &account_list, true, false, &error_code)) {
+               if (!emstorage_get_account_list(multi_user_name, &account_count, &account_list, true, false, &error_code)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_account_list failed");
                        goto FINISH_OFF;
                }
 
-               for(i = 0; i < account_count; i++) {
+               for (i = 0; i < account_count; i++) {
                        error_code = emcore_delete_notification_by_account(multi_user_name, account_list[i].account_id, true);
                        if (error_code != EMAIL_ERROR_NONE)
                                EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
@@ -3310,7 +3297,7 @@ INTERNAL_FUNC int emcore_clear_notifications(char *multi_user_name, int account_
 
 FINISH_OFF:
 
-       if(account_count) {
+       if (account_count) {
                emstorage_free_account(&account_list, account_count, NULL);
        }
 
@@ -3411,16 +3398,14 @@ INTERNAL_FUNC int emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id
                                goto FINISH_OFF;
                        }
                        break;
-               }
-               else {
+               } else {
                        /* More server mail id are present in id_set. Find out if first:last_uid is to be formed or only first_uid will be subset string */
                        do {
                                current_uid = id_set[i].server_mail_id;
                                if (current_uid == (last_uid + 1)) {
                                        last_uid = current_uid;
                                        ++i;
-                               }
-                               else {
+                               } else {
                                        memset(subset_string, 0x00, max_subset_string_size);
                                        if (first_uid != last_uid)      /* Form subset string by first_uid:last_uid */
                                                SNPRINTF(subset_string, max_subset_string_size, "%lu:%lu", first_uid, last_uid);
@@ -3443,7 +3428,6 @@ INTERNAL_FUNC int emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id
 
                        if (last_uid == current_uid) {
                                /* Case 1 */
-
                                memset(subset_string, 0x00, max_subset_string_size);
                                SNPRINTF(subset_string, max_subset_string_size, "%lu:%lu", first_uid, last_uid);
 
@@ -3451,11 +3435,9 @@ INTERNAL_FUNC int emcore_convert_to_uid_range_set(email_id_set_t *id_set, int id
                                        EM_DEBUG_EXCEPTION("emcore_append_subset_string_to_uid_range failed");
                                        goto FINISH_OFF;
                                }
-                       }
-                       else {
+                       } else {
                                /* Case 2: Do Nothing */
                        }
-
                }
        } while (i < id_set_count);
 
@@ -3494,14 +3476,14 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_rang
                /*This happens only once when list  creation starts. Head Node is allocated */
                current_node = (email_uid_range_set *)em_malloc(sizeof(email_uid_range_set));
                if (NULL == current_node) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        return false;
                }
 
                current_node->uid_range = (char *)em_malloc(range_len);
 
                if (NULL == current_node->uid_range) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        EM_SAFE_FREE(current_node);
                        return false;
                }
@@ -3514,8 +3496,7 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_rang
 
                (*current_node_adr) = current_node;
 
-       }
-       else {
+       } else {
                /* Apart from first call to this function flow will always come here */
                current_node = (*current_node_adr);
                int len_sub_string = EM_SAFE_STRLEN(subset_string);
@@ -3524,8 +3505,7 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_rang
                if ((len_sub_string + 1 + 1) <= space_left_in_buffer)   /* 1 for comma + 1 for ending null character */ {
                        SNPRINTF(current_node->uid_range + EM_SAFE_STRLEN(current_node->uid_range), space_left_in_buffer, "%s,", subset_string);
                        current_node->highest_uid = huid;
-               }
-               else {
+               } else {
                        /* No more space left in uid_range string.If continued on it, it will exceeded max size of range_len */
                        /* Allocate new node in Uid Range set */
                        email_uid_range_set *new_node = NULL;
@@ -3533,7 +3513,7 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_rang
                        new_node = (email_uid_range_set *)em_malloc(sizeof(email_uid_range_set));
 
                        if (NULL == new_node) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                return false;
                        }
 
@@ -3542,7 +3522,7 @@ int emcore_append_subset_string_to_uid_range(char *subset_string, email_uid_rang
                        new_node->uid_range =  (char *)em_malloc(range_len);
 
                        if (NULL == new_node->uid_range) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                EM_SAFE_FREE(new_node);
                                return false;
                        }
@@ -3623,15 +3603,15 @@ INTERNAL_FUNC int emcore_form_comma_separated_strings(int numbers[], int num_cou
        char **string_list = NULL;
        int num_of_strings = 0;
        int i = 0;
-       int j =0;
+       int j = 0;
        char num[MAX_INTEGER_LENGTH + 1] = {0, };
        int num_len = 0;
        int space_in_buffer = 0;
        int len_of_string_formed = 0;
 
-       if (NULL == numbers || num_count <= 0 || \
-               max_string_len < (MAX_INTEGER_LENGTH + 2)|| NULL == strings || NULL == string_count)                    /*  32767, is the highest integer possible in string.This requires 7 bytes of storage in character type array (1 byte for ending NULL and 1 byte for ending comma) so max_string_len should not be less than worst case possible.  */ {
-               EM_DEBUG_EXCEPTION("Invalid Parameter numbers[%p] num_count [%d] max_string_len [%d] strings [%p] string_count[%p]", \
+       if (NULL == numbers || num_count <= 0 ||
+               max_string_len < (MAX_INTEGER_LENGTH + 2) || NULL == strings || NULL == string_count)                   /*  32767, is the highest integer possible in string.This requires 7 bytes of storage in character type array (1 byte for ending NULL and 1 byte for ending comma) so max_string_len should not be less than worst case possible.  */ {
+               EM_DEBUG_EXCEPTION("Invalid Parameter numbers[%p] num_count [%d] max_string_len [%d] strings [%p] string_count[%p]",
                        numbers, num_count, max_string_len, strings, string_count);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -3642,21 +3622,21 @@ INTERNAL_FUNC int emcore_form_comma_separated_strings(int numbers[], int num_cou
        string_list = em_malloc(sizeof(char *));
 
        if (NULL == string_list) {
-               EM_DEBUG_EXCEPTION("em_malloc failed ");
+               EM_DEBUG_EXCEPTION("em_mallocfailed ");
                goto FINISH_OFF;
        }
 
        string_list[num_of_strings] = em_malloc(max_string_len);
 
        if (NULL == string_list[num_of_strings]) {
-               EM_DEBUG_EXCEPTION("em_malloc failed ");
+               EM_DEBUG_EXCEPTION("em_mallocfailed ");
                goto FINISH_OFF;
        }
 
        ++num_of_strings;
        space_in_buffer = max_string_len;
 
-       for (j = 0; j < num_count;++j) {
+       for (j = 0; j < num_count; ++j) {
                memset(num, 0x00, MAX_INTEGER_LENGTH + 1);
                SNPRINTF(num, MAX_INTEGER_LENGTH + 1, "%d", numbers[j]);
 
@@ -3668,8 +3648,7 @@ INTERNAL_FUNC int emcore_form_comma_separated_strings(int numbers[], int num_cou
 
                if (space_in_buffer >= (num_len+1+1))                   /*  1 for comma and 1 for ending NULL */ {
                        SNPRINTF(string_list[num_of_strings - 1] + len_of_string_formed, max_string_len, "%d,", numbers[j]);
-               }
-               else {  /*  Removing comma at end of string  */
+               } else {        /*  Removing comma at end of string  */
                        string_list[num_of_strings - 1][len_of_string_formed-1] = '\0';
                        char **temp = NULL;
                        temp = (char **)realloc(string_list, sizeof(char *) * (num_of_strings + 1));    /*  Allocate new buffer to store a pointer to a new string */
@@ -3686,7 +3665,7 @@ INTERNAL_FUNC int emcore_form_comma_separated_strings(int numbers[], int num_cou
                        string_list[num_of_strings] = em_malloc(max_string_len);/*  Allocate new buffer to store the string */
 
                        if (NULL == string_list[num_of_strings]) {
-                               EM_DEBUG_EXCEPTION(" em_malloc failed ");
+                               EM_DEBUG_EXCEPTION(" em_mallocfailed ");
                                goto FINISH_OFF;
                        }
                        ++num_of_strings;
@@ -3705,7 +3684,7 @@ FINISH_OFF:
                emcore_free_comma_separated_strings(&string_list, &num_of_strings);
 
        if (true == ret) {
-               for (i = 0; i < num_of_strings;++i)
+               for (i = 0; i < num_of_strings; ++i)
                        EM_DEBUG_LOG("%s", string_list[i]);
                *strings = string_list;
                *string_count = num_of_strings;
@@ -3786,8 +3765,7 @@ int emcore_make_attachment_file_name_with_extension(char *source_file_name, char
                        strcat(attachment_file_name, ".");
                        strcat(attachment_file_name, sub_type);
                        EM_DEBUG_LOG_SEC("attachment_file_name with extension[%s] ", attachment_file_name);
-               }
-               else
+               } else
                        EM_DEBUG_LOG("UnKnown Extesnsion");
 
        }
@@ -3869,10 +3847,8 @@ INTERNAL_FUNC int emcore_get_next_activity_id(int *activity_id, int *err_code)
        int ret = false;
        int err = EMAIL_ERROR_NONE;
 
-       if (NULL == activity_id)
-       {
+       if (NULL == activity_id) {
                EM_DEBUG_EXCEPTION("\t activity_id[%p]", activity_id);
-
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -3948,7 +3924,7 @@ INTERNAL_FUNC int emcore_search_string_from_file(char *file_path, char *search_s
 
        buf = em_malloc(file_size + 1);
        if (buf == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -3965,7 +3941,7 @@ INTERNAL_FUNC int emcore_search_string_from_file(char *file_path, char *search_s
                if (new_string) {
                        cid_string = em_malloc(strlen(search_string) + strlen("cid:") + 1);
                        if (cid_string == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
                        }
@@ -3995,8 +3971,8 @@ INTERNAL_FUNC int emcore_search_string_from_file(char *file_path, char *search_s
        }
 
 FINISH_OFF:
-       if(!p_result)
-               EM_DEBUG_LOG("Search string[%s] not found",search_string);
+       if (!p_result)
+               EM_DEBUG_LOG("Search string[%s] not found", search_string);
 
        *result = p_result;
 
@@ -4042,7 +4018,7 @@ INTERNAL_FUNC int emcore_load_query_from_file(char *file_path, char ***query_arr
 
        buf = em_malloc(file_size + 1);
        if (buf == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -4107,13 +4083,13 @@ static int emcore_get_next_peak_start_time(emstorage_account_tbl_t *input_accoun
        int start_min  = 0;
        struct tm *time_info;
 
-       if(output_time == NULL) {
+       if (output_time == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       time_info = localtime (&input_current_time);
+       time_info = localtime(&input_current_time);
        if (time_info == NULL) {
                EM_DEBUG_EXCEPTION("localtime failed");
                err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -4132,7 +4108,7 @@ static int emcore_get_next_peak_start_time(emstorage_account_tbl_t *input_accoun
                start_hour = input_account_ref->peak_start_time / 100;
                start_min  = input_account_ref->peak_start_time % 100;
                if (start_hour < time_info->tm_hour || (start_hour == time_info->tm_hour && start_min < time_info->tm_min)) {
-                       if(wday == EMAIL_PEAK_DAYS_SATDAY)
+                       if (wday == EMAIL_PEAK_DAYS_SATDAY)
                                wday = EMAIL_PEAK_DAYS_SUNDAY;
                        else
                                wday = wday << 1;
@@ -4141,9 +4117,9 @@ static int emcore_get_next_peak_start_time(emstorage_account_tbl_t *input_accoun
 
        }
 
-       while (!(wday & input_account_ref->peak_days) && day_count < 7){
+       while (!(wday & input_account_ref->peak_days) && day_count < 7) {
                EM_DEBUG_LOG("wday[%d] day_count[%d]", wday, day_count);
-               if(wday == EMAIL_PEAK_DAYS_SATDAY)
+               if (wday == EMAIL_PEAK_DAYS_SATDAY)
                        wday = EMAIL_PEAK_DAYS_SUNDAY;
                else
                        wday = wday << 1;
@@ -4181,7 +4157,7 @@ static int emcore_check_time_in_peak_schedule(emstorage_account_tbl_t *input_acc
        int end_hour = 0;
        int end_min  = 0;
 
-       if(input_account_ref == NULL || output_result == NULL) {
+       if (input_account_ref == NULL || output_result == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -4200,7 +4176,7 @@ static int emcore_check_time_in_peak_schedule(emstorage_account_tbl_t *input_acc
 
        EM_DEBUG_LOG("wday [%d]", wday);
 
-       if(wday & input_account_ref->peak_days) {
+       if (wday & input_account_ref->peak_days) {
                start_hour = input_account_ref->peak_start_time / 100;
                start_min  = input_account_ref->peak_start_time % 100;
 
@@ -4209,12 +4185,11 @@ static int emcore_check_time_in_peak_schedule(emstorage_account_tbl_t *input_acc
 
                EM_DEBUG_LOG("start_hour[%d] start_min[%d] end_hour[%d] end_min[%d]", start_hour, start_min, end_hour, end_min);
 
-               if(start_hour <= time_info->tm_hour && time_info->tm_hour <= end_hour) {
-                       if(time_info->tm_hour == end_hour) {
-                               if(time_info->tm_min < end_min)
+               if (start_hour <= time_info->tm_hour && time_info->tm_hour <= end_hour) {
+                       if (time_info->tm_hour == end_hour) {
+                               if (time_info->tm_min < end_min)
                                        result = 1;
-                       }
-                       else
+                       } else
                                result = 1;
                }
        }
@@ -4240,7 +4215,7 @@ INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input
 
        emstorage_get_account_by_id(multi_user_name, input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account, true, &err);
        if (account == NULL) {
-               EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]",err);
+               EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
                goto FINISH_OFF;
        }
 
@@ -4248,29 +4223,28 @@ INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input
                /* peak schedule disabled */
                if (account->check_interval > 0)
                        result_time = input_current_time + (account->check_interval * 60);
-       }
-       else if(account->peak_days > 0) {
+       } else if (account->peak_days > 0) {
                /* peak schedule enabled */
 
                /* if current time is in peak schedule */
                emcore_check_time_in_peak_schedule(account, input_current_time, &is_time_in_peak_schedule);
                EM_DEBUG_LOG("is_time_in_peak_schedule [%d]", is_time_in_peak_schedule);
-               if(is_time_in_peak_schedule) {
+               if (is_time_in_peak_schedule) {
                        /* if next time to sync is in peak schedule? */
                        next_time = input_current_time + (account->peak_interval * 60);
 
                        emcore_check_time_in_peak_schedule(account, next_time, &is_time_in_peak_schedule);
-                       if(is_time_in_peak_schedule) {
+                       if (is_time_in_peak_schedule) {
                                /* create an alarm to sync in peak schedule*/
                                result_time = next_time;
                        }
                }
 
-               if(result_time == 0) {
+               if (result_time == 0) {
                        /* if current time is not in peak schedule */
-                       if(next_time == 0)  {
+                       if (next_time == 0)  {
                                /* if normal sync schedule is set */
-                               if(account->check_interval) {
+                               if (account->check_interval) {
                                        next_time = input_current_time + (account->check_interval * 60);
                                }
                        }
@@ -4280,7 +4254,7 @@ INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input
                        EM_DEBUG_LOG("next_peak_start_time : %s", ctime(&next_peak_start_time));
 
                        /* if next time to sync is closer than next peak schedule start? */
-                       if(next_time && (next_time < next_peak_start_time)) {
+                       if (next_time && (next_time < next_peak_start_time)) {
                                /* create an alarm to sync in check_interval */
                                result_time = next_time;
                        }
@@ -4296,7 +4270,7 @@ INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input
 
 
 FINISH_OFF:
-       if(account) {
+       if (account) {
                emstorage_free_account(&account, 1, NULL);
        }
 
@@ -4309,22 +4283,22 @@ static int convert_contact_err_to_email_err(int contact_err)
        int err = EMAIL_ERROR_NONE;
 
        switch (contact_err) {
-       case CONTACTS_ERROR_NONE :
+       case CONTACTS_ERROR_NONE:
                err = EMAIL_ERROR_NONE;
                break;
-       case CONTACTS_ERROR_OUT_OF_MEMORY :
+       case CONTACTS_ERROR_OUT_OF_MEMORY:
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                break;
-       case CONTACTS_ERROR_INVALID_PARAMETER :
+       case CONTACTS_ERROR_INVALID_PARAMETER:
                err = EMAIL_ERROR_INVALID_PARAM;
                break;
-       case CONTACTS_ERROR_NO_DATA :
+       case CONTACTS_ERROR_NO_DATA:
                err = EMAIL_ERROR_DATA_NOT_FOUND;
                break;
-       case CONTACTS_ERROR_DB :
+       case CONTACTS_ERROR_DB:
                err = EMAIL_ERROR_DB_FAILURE;
                break;
-       case CONTACTS_ERROR_IPC :
+       case CONTACTS_ERROR_IPC:
                err = EMAIL_ERROR_IPC_CONNECTION_FAILURE;
                break;
        case CONTACTS_ERROR_SYSTEM:
@@ -4476,7 +4450,7 @@ int emcore_search_contact_info_by_address(char *multi_user_name, const char *con
 
        if ((contact_err = contacts_list_get_current_record_p(list, contacts_record)) != CONTACTS_ERROR_NONE) {
                if (contact_err != CONTACTS_ERROR_NO_DATA) /* no matching record found */
-                       EM_DEBUG_EXCEPTION ("contacts_list_get_current_record_p failed [%d]", contact_err);
+                       EM_DEBUG_EXCEPTION("contacts_list_get_current_record_p failed [%d]", contact_err);
                goto FINISH_OFF;
        }
 
@@ -4506,10 +4480,10 @@ typedef struct {
        email_action_t action;
 } set_contacts_log_internal_t;
 
-gboolean emcore_set_contacts_log_internal (void* arg)
+gboolean emcore_set_contacts_log_internal(void* arg)
 {
        if (!arg) {
-               EM_DEBUG_EXCEPTION ("no contact data to add");
+               EM_DEBUG_EXCEPTION("no contact data to add");
                return FALSE;
        }
        set_contacts_log_internal_t* tmp = (set_contacts_log_internal_t*) arg;
@@ -4566,13 +4540,13 @@ gboolean emcore_set_contacts_log_internal (void* arg)
        }
 
        switch (action) {
-       case EMAIL_ACTION_SEND_MAIL :
+       case EMAIL_ACTION_SEND_MAIL:
                action_type = CONTACTS_PLOG_TYPE_EMAIL_SENT;
                break;
-       case EMAIL_ACTION_SYNC_HEADER :
+       case EMAIL_ACTION_SYNC_HEADER:
                action_type = CONTACTS_PLOG_TYPE_EMAIL_RECEIVED;
                break;
-       default :
+       default:
                EM_DEBUG_EXCEPTION("Unknown action type");
                goto FINISH_OFF;
        }
@@ -4603,7 +4577,7 @@ gboolean emcore_set_contacts_log_internal (void* arg)
 
        /* Insert the record in DB */
        if ((contacts_error = contacts_db_insert_record(phone_record, NULL)) != CONTACTS_ERROR_NONE) {
-               EM_DEBUG_EXCEPTION("contacts_db_insert_record failed [%d]",contacts_error );
+               EM_DEBUG_EXCEPTION("contacts_db_insert_record failed [%d]", contacts_error);
                goto FINISH_OFF;
        }
 
@@ -4618,15 +4592,15 @@ FINISH_OFF:
        if (join_zone)
                emcore_unset_join_zone(join_zone);
 
-       EM_SAFE_FREE (email_address);
-       EM_SAFE_FREE (subject);
-       EM_SAFE_FREE (tmp);
+       EM_SAFE_FREE(email_address);
+       EM_SAFE_FREE(subject);
+       EM_SAFE_FREE(tmp);
 
        EM_DEBUG_FUNC_END("contact err [%d]", convert_contact_err_to_email_err(contacts_error));
        return FALSE;
 }
 
-int emcore_set_contacts_log (char *multi_user_name,
+int emcore_set_contacts_log(char *multi_user_name,
                                 int   account_id,
                                 char *email_address,
                                 char *subject,
@@ -4634,21 +4608,21 @@ int emcore_set_contacts_log (char *multi_user_name,
                                 email_action_t action)
 {
        /* arg shall be destroyed in emcore_set_contacts_log_internal */
-       set_contacts_log_internal_t *arg = em_malloc (sizeof(set_contacts_log_internal_t));
+       set_contacts_log_internal_t *arg = em_malloc(sizeof(set_contacts_log_internal_t));
        if (!arg) {
-               EM_DEBUG_EXCEPTION ("em_malloc error");
+               EM_DEBUG_EXCEPTION("em_mallocerror");
                return EMAIL_ERROR_OUT_OF_MEMORY;
        }
 
        /* deep copy */
        arg->account_id      = account_id;
-       arg->email_address   = EM_SAFE_STRDUP (email_address);
-       arg->subject         = EM_SAFE_STRDUP (subject);
+       arg->email_address   = EM_SAFE_STRDUP(email_address);
+       arg->subject         = EM_SAFE_STRDUP(subject);
        arg->date_time       = date_time;
        arg->action          = action;
-    arg->multi_user_name = EM_SAFE_STRDUP (multi_user_name);
+    arg->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
 
-       g_main_context_invoke (NULL, emcore_set_contacts_log_internal, arg);
+       g_main_context_invoke(NULL, emcore_set_contacts_log_internal, arg);
 
        return EMAIL_ERROR_NONE;
 }
@@ -4667,7 +4641,7 @@ INTERNAL_FUNC int emcore_set_sent_contacts_log(char *multi_user_name, emstorage_
        for (i = 0; i < 3; i++) {
                if (address_array[i] && address_array[i][0] != 0) {
                        rfc822_parse_adrlist(&addr, address_array[i], NULL);
-                       for (p_addr = addr ; p_addr ;p_addr = p_addr->next) {
+                       for (p_addr = addr; p_addr; p_addr = p_addr->next) {
                                SNPRINTF(email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", addr->mailbox, addr->host);
                                if ((err = emcore_set_contacts_log(multi_user_name,
                                                     input_mail_data->account_id,
@@ -4715,8 +4689,7 @@ INTERNAL_FUNC int emcore_set_received_contacts_log(char *multi_user_name, emstor
        return err;
 }
 
-typedef struct _contacts_delete_data
-{
+typedef struct _contacts_delete_data {
     int account_id;
     char *multi_user_name;
 } contacts_delete_data;
@@ -4759,22 +4732,22 @@ INTERNAL_FUNC int emcore_delete_contacts_log(char *multi_user_name, int account_
 
     data = (contacts_delete_data *)em_malloc(sizeof(contacts_delete_data));
     if (data == NULL) {
-        EM_DEBUG_EXCEPTION("em_malloc failed");
+        EM_DEBUG_EXCEPTION("em_mallocfailed");
         return EMAIL_ERROR_OUT_OF_MEMORY;
     }
 
     data->account_id = account_id;
     data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
 
-       g_main_context_invoke (NULL, emcore_delete_contacts_log_internal, (void*) data);
+       g_main_context_invoke(NULL, emcore_delete_contacts_log_internal, (void*) data);
 
        return EMAIL_ERROR_NONE;
 }
 
-INTERNAL_FUNC int emcore_get_mail_display_name (char *multi_user_name, char *email_address, char **contact_display_name)
+INTERNAL_FUNC int emcore_get_mail_display_name(char *multi_user_name, char *email_address, char **contact_display_name)
 {
        if (!email_address || !contact_display_name) {
-               EM_DEBUG_EXCEPTION ("NULL_PARAM email_address[%p] contact_display_name[%p]",
+               EM_DEBUG_EXCEPTION("NULL_PARAM email_address[%p] contact_display_name[%p]",
                                                 email_address, contact_display_name);
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -4787,7 +4760,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *multi_user_name, char *ema
        g_type_init();
 #endif
 
-       GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+       GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
                                    G_DBUS_PROXY_FLAGS_NONE,
                                    NULL,
                                    EMAIL_SERVICE_NAME,
@@ -4796,15 +4769,15 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *multi_user_name, char *ema
                                    NULL,
                                    &gerror);
        if (!bproxy) {
-               EM_DEBUG_EXCEPTION ("g_dbus_proxy_new_for_bus_sync error [%s]",
+               EM_DEBUG_EXCEPTION("g_dbus_proxy_new_for_bus_sync error [%s]",
                                  gerror->message);
                ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                goto FINISH_OFF;
        }
 
-       result = g_dbus_proxy_call_sync (bproxy,
+       result = g_dbus_proxy_call_sync(bproxy,
                                       "GetDisplayName",
-                                      g_variant_new ("(ss)", email_address, multi_user_name),
+                                      g_variant_new("(ss)", email_address, multi_user_name),
                                       G_DBUS_CALL_FLAGS_NONE,
                                       -1,
                                       NULL,
@@ -4812,32 +4785,33 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *multi_user_name, char *ema
 
 
        if (!result) {
-               EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'GetDisplayName' error [%s]",
+               EM_DEBUG_EXCEPTION("g_dbus_proxy_call_sync 'GetDisplayName' error [%s]",
                                  gerror->message);
                ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                goto FINISH_OFF;
        }
 
-       g_variant_get (result, "(si)", contact_display_name, &ret);
+       g_variant_get(result, "(si)", contact_display_name, &ret);
 
        /* replace "" to NULL */
-       if (!g_strcmp0 (*contact_display_name, ""))
-               EM_SAFE_FREE (*contact_display_name);
+       if (!g_strcmp0(*contact_display_name, ""))
+               EM_SAFE_FREE(*contact_display_name);
 
-       g_variant_unref (result);
+       g_variant_unref(result);
 
 FINISH_OFF:
-       EM_DEBUG_LOG ("ret [%d]\n", ret);
+       EM_DEBUG_LOG("ret [%d]\n", ret);
        if (bproxy)
-               g_object_unref (bproxy);
+               g_object_unref(bproxy);
+
        if (gerror)
-               g_error_free (gerror);
+               g_error_free(gerror);
 
        return ret;
 }
 
 
-INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *multi_user_name,
+INTERNAL_FUNC int emcore_get_mail_display_name_internal(char *multi_user_name,
                                                         char *email_address,
                                                         char **contact_display_name)
 {
@@ -4988,10 +4962,10 @@ INTERNAL_FUNC void emcore_set_blocking_mode_status(int blocking_mode)
        blocking_mode_status = blocking_mode;
 }
 
-INTERNAL_FUNC int emcore_check_blocking_mode (char *multi_user_name, char *sender_address, int *blocking_status)
+INTERNAL_FUNC int emcore_check_blocking_mode(char *multi_user_name, char *sender_address, int *blocking_status)
 {
-       if ( !sender_address || !blocking_status ) {
-               EM_DEBUG_EXCEPTION ("NULL_PARAM sender_address[%p] blocking_status[%p]",
+       if (!sender_address || !blocking_status) {
+               EM_DEBUG_EXCEPTION("NULL_PARAM sender_address[%p] blocking_status[%p]",
                                                    sender_address, blocking_status);
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -5005,7 +4979,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *multi_user_name, char *sende
        g_type_init();
 #endif
 
-       GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+       GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
                                    G_DBUS_PROXY_FLAGS_NONE,
                                    NULL,
                                    EMAIL_SERVICE_NAME,
@@ -5014,15 +4988,15 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *multi_user_name, char *sende
                                    NULL,
                                    &gerror);
        if (!bproxy) {
-               EM_DEBUG_EXCEPTION ("g_dbus_proxy_new_for_bus_sync error [%s]",
+               EM_DEBUG_EXCEPTION("g_dbus_proxy_new_for_bus_sync error [%s]",
                                  gerror->message);
                ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                goto FINISH_OFF;
        }
 
-       result = g_dbus_proxy_call_sync (bproxy,
+       result = g_dbus_proxy_call_sync(bproxy,
                                       "CheckBlockingMode",
-                                      g_variant_new ("(ss)", sender_address, multi_user_name),
+                                      g_variant_new("(ss)", sender_address, multi_user_name),
                                       G_DBUS_CALL_FLAGS_NONE,
                                       -1,
                                       NULL,
@@ -5030,26 +5004,27 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *multi_user_name, char *sende
 
 
        if (!result) {
-               EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'CheckBlockingMode' error [%s]",
+               EM_DEBUG_EXCEPTION("g_dbus_proxy_call_sync 'CheckBlockingMode' error [%s]",
                                  gerror->message);
                ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                goto FINISH_OFF;
        }
 
-       g_variant_get (result, "(ii)", blocking_status, &ret);
-       g_variant_unref (result);
+       g_variant_get(result, "(ii)", blocking_status, &ret);
+       g_variant_unref(result);
 
 FINISH_OFF:
 
        if (bproxy)
-               g_object_unref (bproxy);
+               g_object_unref(bproxy);
+
        if (gerror)
-               g_error_free (gerror);
+               g_error_free(gerror);
 
        return ret;
 }
 
-INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, char *sender_address, int *blocking_status)
+INTERNAL_FUNC int emcore_check_blocking_mode_internal(char *multi_user_name, char *sender_address, int *blocking_status)
 {
        EM_DEBUG_FUNC_BEGIN();
        int err = EMAIL_ERROR_NONE;
@@ -5078,11 +5053,12 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, ch
        }
 */
        switch (allowed_contact_type) {
-       case ALLOWED_CONTACT_TYPE_NONE :
+       case ALLOWED_CONTACT_TYPE_NONE:
                EM_DEBUG_LOG("allowed_contact_type is none : bloacking all(notification)");
                *blocking_status = true;
                break;
-       case ALLOWED_CONTACT_TYPE_ALL :
+
+       case ALLOWED_CONTACT_TYPE_ALL:
                EM_DEBUG_LOG("allowed_contact_type is ALL");
                /* Search the allowed contact type in contact DB */
                if ((contact_error = emcore_search_contact_info_by_address(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
@@ -5099,7 +5075,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, ch
                *blocking_status = false;
                break;
 
-       case ALLOWED_CONTACT_TYPE_FAVORITES :
+       case ALLOWED_CONTACT_TYPE_FAVORITES:
                if ((contact_error = emcore_search_contact_info(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, _contacts_person_email.is_favorite, true, 1, &record)) != CONTACTS_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_search_contact_info failed : [%d]", contact_error);
                        goto FINISH_OFF;
@@ -5113,7 +5089,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, ch
                *blocking_status = false;
                break;
 
-       case ALLOWED_CONTACT_TYPE_CUSTOM :
+       case ALLOWED_CONTACT_TYPE_CUSTOM:
                person_id_string = vconf_get_str(VCONFKEY_SETAPPL_BLOCKINGMODE_ALLOWED_CONTACT_LIST);
                if (person_id_string == NULL) {
                        EM_DEBUG_LOG("Custom allowed contact type is NULL");
@@ -5152,7 +5128,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, ch
                err = EMAIL_ERROR_INVALID_PARAM;
        }
 
-FINISH_OFF :
+FINISH_OFF:
 
 /*
        contacts_disconnect_on_thread();
@@ -5243,13 +5219,13 @@ INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents,
                goto FINISH_OFF;
        }
 
-       err = em_open(filename, O_RDONLY, 0 ,&fd);
+       err = em_open(filename, O_RDONLY, 0&fd);
        if (err != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("em_open error [%s][%d]", filename, err);
                goto FINISH_OFF;
        }
 
-       if (fstat (fd, &stat_buf) < 0) {
+       if (fstat(fd, &stat_buf) < 0) {
                EM_DEBUG_EXCEPTION("fstat failed for fd [%d]", fd);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
@@ -5270,7 +5246,7 @@ INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents,
 
                while (bytes_read < size) {
                        ssize_t rd_size = 0;
-                       rd_size = read (fd, buf + bytes_read, size - bytes_read);
+                       rd_size = read(fd, buf + bytes_read, size - bytes_read);
 
                        if (rd_size < 0) {
                                if (errno != EINTR) {
@@ -5278,8 +5254,7 @@ INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents,
                                        err = EMAIL_ERROR_SYSTEM_FAILURE;
                                        goto FINISH_OFF;
                                }
-                       }
-                       else if (rd_size == 0)
+                       } else if (rd_size == 0)
                                break;
                        else
                                bytes_read += rd_size;
@@ -5292,7 +5267,7 @@ INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents,
 
                *contents = buf;
        }
-       EM_SAFE_CLOSE (fd); /* prevent 39093 */
+       EM_SAFE_CLOSE(fd); /* prevent 39093 */
 
        EM_DEBUG_FUNC_END();
        return err;
@@ -5300,8 +5275,8 @@ INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents,
 FINISH_OFF:
 
        EM_SAFE_FREE(buf);
-       EM_SAFE_CLOSE (fd); /* prevent 39093 */
-       EM_DEBUG_FUNC_END ();
+       EM_SAFE_CLOSE(fd); /* prevent 39093 */
+       EM_DEBUG_FUNC_END();
 
        return err;
 }
@@ -5323,7 +5298,7 @@ INTERNAL_FUNC int emcore_set_content_to_file(const char *contents, char *dest_pa
 
        tmp_path = emcore_mime_get_save_file_name(&err);
        if (!tmp_path) { /* prevent 39114 */
-               EM_DEBUG_EXCEPTION ("tmp_path NULL");
+               EM_DEBUG_EXCEPTION("tmp_path NULL");
                goto FINISH_OFF;
        }
 
@@ -5334,7 +5309,7 @@ INTERNAL_FUNC int emcore_set_content_to_file(const char *contents, char *dest_pa
        }
 
        errno = 0;
-       while(length > 0 && contents && errno == 0) {
+       while (length > 0 && contents && errno == 0) {
                byte_written = write(fd, (void *)contents, length);
                if (byte_written < 0) {
                        /* interrupted by a signal */
@@ -5353,7 +5328,7 @@ INTERNAL_FUNC int emcore_set_content_to_file(const char *contents, char *dest_pa
        }
 
        errno = 0;
-       if (fsync(fd) != 0){
+       if (fsync(fd) != 0) {
                EM_DEBUG_EXCEPTION("fsync failed: %s", EM_STRERROR(errno_buf));
                err = EMAIL_ERROR_SYSTEM_FAILURE;
        }
@@ -5368,7 +5343,7 @@ INTERNAL_FUNC int emcore_set_content_to_file(const char *contents, char *dest_pa
 FINISH_OFF:
 
        EM_SAFE_FREE(tmp_path);
-       EM_SAFE_CLOSE (fd); /* prevent 39114, 39136*/
+       EM_SAFE_CLOSE(fd); /* prevent 39114, 39136*/
        EM_DEBUG_FUNC_END();
        return err;
 }
@@ -5397,7 +5372,7 @@ INTERNAL_FUNC int emcore_unescape_from_url(char *input_url, char **output_url)
        char *result_string = NULL;
        CURL *curl = NULL;
 
-       if (input_url == NULL|| output_url == NULL) {
+       if (input_url == NULL || output_url == NULL) {
                err = EMAIL_ERROR_INVALID_PARAM;
                EM_DEBUG_EXCEPTION("Invalid parameter");
                goto FINISH_OFF;
@@ -5417,7 +5392,7 @@ FINISH_OFF:
        if (result_string)
                curl_free(result_string);
 
-       if(curl)
+       if (curl)
                curl_easy_cleanup(curl);
 
        EM_DEBUG_FUNC_END("err[%d]", err);
@@ -5430,7 +5405,7 @@ INTERNAL_FUNC char *__em_get_month_in_string(int month)
 
        char *mon = NULL;
 
-       switch (month){
+       switch (month) {
            case 0:
                        mon = strdup("jan");
                break;
@@ -5499,7 +5474,7 @@ INTERNAL_FUNC int emcore_make_date_string_for_search(time_t input_time, char **o
 
        if (output_date_string)
                *output_date_string = temp_date_string;
-       else 
+       else
                EM_SAFE_FREE(temp_date_string);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -5525,7 +5500,7 @@ INTERNAL_FUNC int emcore_make_uid_range_string(emcore_uid_list *uid_list, int to
 
        EM_DEBUG_LOG("memory allocation for uid_range [%d, %d]", msg_count, uid_range_size);
        uid_range = malloc(sizeof(char) * uid_range_size);
-       if (uid_range == NULL){
+       if (uid_range == NULL) {
                EM_DEBUG_EXCEPTION("memory allocation for uid_range failed");
                err  = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -5533,31 +5508,29 @@ INTERNAL_FUNC int emcore_make_uid_range_string(emcore_uid_list *uid_list, int to
 
        uid_list_prev = uid_list_fast;
 
-       if (uid_list_fast->next == NULL){
+       if (uid_list_fast->next == NULL) {
                /* Single list entry */
                snprintf(uid_range, uid_range_size, "%d", atoi(uid_list_fast->uid));
                EM_DEBUG_LOG("uid_range [%d]", uid_range);
-       }
-       else{
+       } else {
                /* forming range of uids to be passed */
-               while (uid_list_fast  != NULL){
+               while (uid_list_fast  != NULL) {
                        /* uid_list_fast = uid_list_fast->next; */
 
-                       if ((uid_list_fast->next != NULL) && (((atoi(uid_list_prev->uid)) - (atoi(uid_list_fast->next->uid))) == 1)){
+                       if ((uid_list_fast->next != NULL) && (((atoi(uid_list_prev->uid)) - (atoi(uid_list_fast->next->uid))) == 1)) {
                                index += snprintf(uid_range+index, uid_range_size, "%d", atoi(uid_list_prev->uid));
 
                                uid_list_fast = uid_list_fast->next;
                                uid_list_prev = uid_list_fast;
 
                                /* to make UID range string "abc, XX : YY" */
-                               while (uid_list_fast  != NULL){
+                               while (uid_list_fast  != NULL) {
                                        if (uid_list_fast->next == NULL)
                                                break;
-                                       if (((atoi(uid_list_prev->uid)) - (atoi(uid_list_fast->next->uid))) == 1){
+                                       if (((atoi(uid_list_prev->uid)) - (atoi(uid_list_fast->next->uid))) == 1) {
                                                uid_list_fast = uid_list_fast->next;
                                                uid_list_prev = uid_list_fast;
-                                       }
-                                       else
+                                       } else
                                                break;
                                }
                                if ((uid_list_fast  != NULL) && (uid_list_fast->next  != NULL))
@@ -5567,8 +5540,7 @@ INTERNAL_FUNC int emcore_make_uid_range_string(emcore_uid_list *uid_list, int to
 
                                uid_list_fast = uid_list_fast->next;
                                uid_list_prev = uid_list_fast;
-                       }
-                       else{
+                       } else {
                                if (uid_list_fast->next  != NULL)
                                        index  += snprintf(uid_range+index, uid_range_size, "%d,", atoi(uid_list_prev->uid));
                                else
index 85d6a79..50966a6 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -41,7 +41,7 @@ INTERNAL_FUNC int emdevice_set_sleep_on_off(email_stay_awake_flag_owner_t input_
 
        stay_awake_flag[input_flag_owner] = !input_allow_to_sleep;
 
-       if(input_allow_to_sleep == 1) {
+       if (input_allow_to_sleep == 1) {
                int i = 0;
                int allowed_to_sleep = 1;
 
@@ -56,12 +56,10 @@ INTERNAL_FUNC int emdevice_set_sleep_on_off(email_stay_awake_flag_owner_t input_
                        /* allowed to sleep */
                        result_from_pm_api = device_power_release_lock(POWER_LOCK_CPU);
                        EM_DEBUG_LOG("display_unlock_state() returns [%d]", result_from_pm_api);
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG("other worker[%d] is working on", i);
                }
-       }
-       else {
+       } else {
                /* Stay awake */
                result_from_pm_api = device_power_request_lock(POWER_LOCK_CPU, 0);
                EM_DEBUG_LOG("display_lock_state() returns [%d]", result_from_pm_api);
index ce47151..7152bdb 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -41,7 +41,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
-#include <email-storage.h> 
+#include <email-storage.h>
 #include <vconf.h>
 #include "glib.h"
 
@@ -50,7 +50,7 @@
 #include "c-client.h"
 #include "email-debug-log.h"
 #include "email-types.h"
-#include "email-core-utils.h" 
+#include "email-core-utils.h"
 #include "email-core-mailbox.h"
 
 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
@@ -81,7 +81,7 @@ static int  _get_sim_status(int *sim_status)
        EM_DEBUG_FUNC_BEGIN();
        int value;
 
-       if(!sim_status) {
+       if (!sim_status) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -103,7 +103,7 @@ static int _get_flight_mode(int *flight_mode)
        EM_DEBUG_FUNC_BEGIN();
        int value;
 
-       if(!flight_mode) {
+       if (!flight_mode) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -128,7 +128,7 @@ INTERNAL_FUNC int emnetwork_get_wifi_status(int *wifi_status)
 
        int value;
 
-       if(!wifi_status) {
+       if (!wifi_status) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -165,7 +165,7 @@ INTERNAL_FUNC int emnetwork_check_network_status(int *err_code)
                if (flight_mode) {
                        EM_DEBUG_LOG("Flight mode enable");
                        err = EMAIL_ERROR_FLIGHT_MODE_ENABLE;
-                       goto FINISH_OFF;                        
+                       goto FINISH_OFF;
                }
 
                if ((err = emnetwork_get_wifi_status(&wifi_status)) != EMAIL_ERROR_NONE) {
@@ -176,7 +176,7 @@ INTERNAL_FUNC int emnetwork_check_network_status(int *err_code)
                if (wifi_status == 0) {
                        EM_DEBUG_LOG("Furthermore, WIFI is off");
 
-                       if ( (err = _get_sim_status(&sim_status)) != EMAIL_ERROR_NONE) {
+                       if ((err = _get_sim_status(&sim_status)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("_get_sim_status failed [%d]", err);
                                goto FINISH_OFF;
                        }
@@ -196,7 +196,7 @@ INTERNAL_FUNC int emnetwork_check_network_status(int *err_code)
        EM_DEBUG_LOG("Data Network Mode is ON");
        ret = true;
 
-FINISH_OFF: 
+FINISH_OFF:
 
        emcore_set_network_error(err);
 
@@ -214,7 +214,7 @@ INTERNAL_FUNC int emnetwork_get_roaming_status(int *output_roaming_status)
 
        int value;
 
-       if(!output_roaming_status) {
+       if (!output_roaming_status) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -225,7 +225,7 @@ INTERNAL_FUNC int emnetwork_get_roaming_status(int *output_roaming_status)
        }
 
        /* VCONFKEY_TELEPHONY_SVC_ROAM or VCONFKEY_TELEPHONY_SVC_ROAM_OFF */
-       if(value == VCONFKEY_TELEPHONY_SVC_ROAM_ON)
+       if (value == VCONFKEY_TELEPHONY_SVC_ROAM_ON)
                *output_roaming_status = 1;
        else
                *output_roaming_status = 0;
@@ -267,8 +267,7 @@ INTERNAL_FUNC long tcp_getbuffer_lnx(TCPSTREAM *stream, unsigned long size, char
                if (stream->ictr >= size) {
                        memcpy(p, stream->iptr, size);
                        copy_sz = size;
-               }
-               else {
+               } else {
                        memcpy(p, stream->iptr, stream->ictr);
                        copy_sz = stream->ictr;
                }
@@ -281,8 +280,7 @@ INTERNAL_FUNC long tcp_getbuffer_lnx(TCPSTREAM *stream, unsigned long size, char
                        *p = '\0';
                        return 1;
                }
-       }
-       else {
+       } else {
                nleave = size;
        }
 
@@ -297,8 +295,7 @@ INTERNAL_FUNC long tcp_getbuffer_lnx(TCPSTREAM *stream, unsigned long size, char
                        EM_DEBUG_EXCEPTION("select error[%d]\n", errno);
                        tcp_abort(stream);
                        return 0;
-               }
-               else if (!sret) {
+               } else if (!sret) {
                        if (max_timeout >= 5) {
                                EM_DEBUG_EXCEPTION("max select timeout %d", max_timeout);
                                emcore_set_network_error(EMAIL_ERROR_NO_RESPONSE);
@@ -353,8 +350,7 @@ INTERNAL_FUNC long tcp_sout_lnx(TCPSTREAM *stream, char *string, unsigned long s
                        EM_DEBUG_LOG("select error[%d]", errno);
                        tcp_abort(stream);
                        return 0;
-               }
-               else if (!sret) {
+               } else if (!sret) {
                        if (max_timeout >= 50) {
                                EM_DEBUG_EXCEPTION("max select timeout %d", max_timeout);
                                emcore_set_network_error(EMAIL_ERROR_NO_RESPONSE);
index d2b15bc..8181b02 100755 (executable)
 
 /*  this define is used for query to change data (delete, insert, update) */
 #define EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction_flag, error_code) \
-       do {\
-               if (transaction_flag) {\
-                       if (emstorage_begin_transaction(multi_user_name, NULL, NULL, &error_code) == false) {\
-                               EM_DEBUG_EXCEPTION("emstorage_begin_transaction error [%d]", error_code);\
-                               goto FINISH_OFF;\
-                       }\
-               }\
-       } while(0)
+       do { \
+               if (transaction_flag) { \
+                       if (emstorage_begin_transaction(multi_user_name, NULL, NULL, &error_code) == false) { \
+                               EM_DEBUG_EXCEPTION("emstorage_begin_transaction error [%d]", error_code); \
+                               goto FINISH_OFF; \
+                       } \
+               } \
+       } while (0)
 
 /*  this define is used for query to change data (delete, insert, update) */
 #define EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction_flag, result_code, error_code) \
-       do {\
-               if (transaction_flag) {\
-                       if (result_code == true) {\
-                               if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {\
-                                       EM_DEBUG_EXCEPTION("emstorage_commit_transaction error");\
-                                       error_code = EMAIL_ERROR_DB_FAILURE;\
-                                       result_code = false;\
-                               }\
-                       }\
-                       else {\
-                               if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false) {\
-                                       EM_DEBUG_EXCEPTION("emstorage_rollback_transaction error");\
-                                       error_code = EMAIL_ERROR_DB_FAILURE;\
-                               }\
-                       }\
-               }\
-       } while(0)
+       do { \
+               if (transaction_flag) { \
+                       if (result_code == true) { \
+                               if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) { \
+                                       EM_DEBUG_EXCEPTION("emstorage_commit_transaction error"); \
+                                       error_code = EMAIL_ERROR_DB_FAILURE; \
+                                       result_code = false; \
+                               } \
+                       } \
+                       else { \
+                               if (emstorage_rollback_transaction(multi_user_name, NULL, NULL, NULL) == false) { \
+                                       EM_DEBUG_EXCEPTION("emstorage_rollback_transaction error"); \
+                                       error_code = EMAIL_ERROR_DB_FAILURE; \
+                               } \
+                       } \
+               } \
+       } while (0)
 
 /*  this define is used for query to read (select) */
 #define EMSTORAGE_START_READ_TRANSACTION(transaction_flag) \
-       if (transaction_flag)\
-       {\
+       if (transaction_flag) { \
                /*_timedlock_shm_mutex(mapped_for_db_lock, 2);*/\
        }
 
 /*  this define is used for query to read (select) */
 #define EMSTORAGE_FINISH_READ_TRANSACTION(transaction_flag) \
-       if (transaction_flag)\
-       {\
+       if (transaction_flag) { \
                /*_unlockshm_mutex(mapped_for_db_lock);*/\
        }
 
@@ -197,8 +195,7 @@ static pthread_mutex_t _ss_handle_lock = PTHREAD_MUTEX_INITIALIZER;
 
 #ifdef _MULTIPLE_DB_HANDLE
 
-typedef struct
-{
+typedef struct {
     char *user_name;
        pthread_t       thread_id;
        sqlite3 *db_handle;
@@ -284,10 +281,8 @@ int emstorage_remove_db_handle()
        EM_DEBUG_FUNC_BEGIN();
        int i, error_code = EMAIL_ERROR_MAX_EXCEEDED;
        ENTER_CRITICAL_SECTION(_db_handle_lock);
-       for (i = 0; i < MAX_DB_CLIENT; i++)
-       {
-               if (_db_handle_list[i].thread_id == THREAD_SELF())
-               {
+       for (i = 0; i < MAX_DB_CLIENT; i++) {
+               if (_db_handle_list[i].thread_id == THREAD_SELF()) {
                        _db_handle_list[i].thread_id = 0;
                        _db_handle_list[i].db_handle = NULL;
             EM_SAFE_FREE(_db_handle_list[i].user_name);
@@ -312,8 +307,7 @@ int emstorage_reset_db_handle_list()
        int i;
 
        ENTER_CRITICAL_SECTION(_db_handle_lock);
-       for (i = 0; i < MAX_DB_CLIENT; i++)
-       {
+       for (i = 0; i < MAX_DB_CLIENT; i++) {
                _db_handle_list[i].thread_id = 0;
                _db_handle_list[i].db_handle = NULL;
         EM_SAFE_FREE(_db_handle_list[i].user_name);
@@ -344,8 +338,7 @@ sqlite3 *emstorage_get_db_connection()
 
 /* ------------------------------------------------------------------------------ */
 /*  Mutex using shared memory */
-typedef struct
-{
+typedef struct {
        pthread_mutex_t mutex;
        int data;
 } mmapped_t;
@@ -364,7 +357,7 @@ int              shm_fd_for_generating_mail_id = 0;
                _timedlock_shm_mutex(mapped_for_db_lock, 2);\
                return_value = function_call;\
                _unlockshm_mutex(mapped_for_db_lock);\
-       } while(0)
+       } while (0)
 
 #else /*  __FEATURE_USE_SHARED_MUTEX_FOR_PROTECTED_FUNC_CALL__ */
 #define EMSTORAGE_PROTECTED_FUNC_CALL(function_call, return_value) \
@@ -379,19 +372,19 @@ static int emstorage_exec_query_by_prepare_v2(sqlite3 *local_db_handle, char *qu
        DB_STMT db_statement = NULL;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, query_string, EM_SAFE_STRLEN(query_string), &db_statement, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_prepare failed [%d] [%s]", rc, query_string));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(db_statement), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
        ("sqlite3_step failed [%d] [%s]", rc, query_string));
 
-FINISH_OFF :
+FINISH_OFF:
 
-       if (db_statement != NULL)  {
+       if (db_statement != NULL) {
                rc = sqlite3_finalize(db_statement);
                if (rc != SQLITE_OK) {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -404,12 +397,12 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name)
        EM_DEBUG_FUNC_BEGIN("shm_file_name [%p]", shm_file_name);
        char errno_buf[ERRNO_BUF_SIZE] = {0};
 
-       if(!shm_file_name) {
+       if (!shm_file_name) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
-       int fd = shm_open (shm_file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); /*  note: permission is not working */
+       int fd = shm_open(shm_file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); /*  note: permission is not working */
        if (fd < 0) {
                EM_DEBUG_EXCEPTION("shm_open errno [%d] [%s]", errno, EM_STRERROR(errno_buf));
                return EMAIL_ERROR_SYSTEM_FAILURE;
@@ -425,7 +418,7 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name)
        mmapped_t *m = (mmapped_t *)mmap(NULL, sizeof(mmapped_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
        if (m == MAP_FAILED) {
                EM_DEBUG_EXCEPTION("mmap errno [%d]", errno);
-               EM_SAFE_CLOSE (fd);
+               EM_SAFE_CLOSE(fd);
                return EMAIL_ERROR_SYSTEM_FAILURE;
        }
 
@@ -441,7 +434,7 @@ INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name)
     pthread_mutex_destroy(&(m->mutex));
     munmap(m, sizeof(mmapped_t));
 
-       EM_SAFE_CLOSE (fd);
+       EM_SAFE_CLOSE(fd);
        EM_DEBUG_FUNC_END();
        return EMAIL_ERROR_NONE;
 }
@@ -451,7 +444,7 @@ int emstorage_shm_file_destroy(const char *shm_file_name)
        EM_DEBUG_FUNC_BEGIN("shm_file_name [%p]", shm_file_name);
        char errno_buf[ERRNO_BUF_SIZE] = {0};
 
-       if(!shm_file_name) {
+       if (!shm_file_name) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -467,7 +460,7 @@ int _initialize_shm_mutex(const char *shm_file_name, int *param_shm_fd, mmapped_
        EM_DEBUG_FUNC_BEGIN("shm_file_name [%p] param_shm_fd [%p], param_mapped [%p]", shm_file_name, param_shm_fd, param_mapped);
        char errno_buf[ERRNO_BUF_SIZE] = {0};
 
-       if(!shm_file_name || !param_shm_fd || !param_mapped) {
+       if (!shm_file_name || !param_shm_fd || !param_mapped) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -515,7 +508,7 @@ int _timedlock_shm_mutex(mmapped_t *param_mapped, int sec)
 {
        EM_DEBUG_FUNC_BEGIN("param_mapped [%p], sec [%d]", param_mapped, sec);
 
-       if(!param_mapped) {
+       if (!param_mapped) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -530,8 +523,7 @@ int _timedlock_shm_mutex(mmapped_t *param_mapped, int sec)
        if (err == EOWNERDEAD) {
                err = pthread_mutex_consistent(&(param_mapped->mutex));
                EM_DEBUG_EXCEPTION("Previous owner is dead with lock. Fix mutex : %s", EM_STRERROR(errno_buf));
-       }
-       else if (err != 0) {
+       } else if (err != 0) {
                EM_DEBUG_EXCEPTION("ERROR : %s", EM_STRERROR(errno_buf));
                return err;
        }
@@ -563,24 +555,21 @@ typedef struct {
        unsigned int data_flag;
 } email_db_object_t;
 
-static const email_db_object_t _g_db_tables[] =
-{
+static const email_db_object_t _g_db_tables[] = {
        { "mail_read_mail_uid_tbl", 1},
        { "mail_tbl", 1},
        { "mail_attachment_tbl", 1},
        { NULL,  0},
 };
 
-static const email_db_object_t _g_db_indexes[] =
-{
+static const email_db_object_t _g_db_indexes[] = {
        { "mail_read_mail_uid_idx1", 1},
        { "mail_idx1", 1},
        { "mail_attachment_idx1", 1},
        { NULL,  1},
 };
 
-enum
-{
+enum {
        CREATE_TABLE_MAIL_ACCOUNT_TBL,
        CREATE_TABLE_MAIL_BOX_TBL,
        CREATE_TABLE_MAIL_READ_MAIL_UID_TBL,
@@ -625,15 +614,13 @@ enum
        CREATE_TABLE_MAX,
 };
 
-enum
-{
+enum {
        DATA1_IDX_IN_MAIL_ACTIVITY_TBL = 0,
        TRANSTYPE_IDX_IN_MAIL_ACTIVITY_TBL,
        FLAG_IDX_IN_MAIL_ACTIVITY_TBL,
 };
 
-enum
-{
+enum {
        CERTFICATE_BIND_TYPE_IDX_IN_MAIL_CERTIFICATE_TBL = 0,
        ISSUE_YEAR_IDX_IN_MAIL_CERTIFICATE_TBL,
        ISSUE_MONTH_IDX_IN_MAIL_CERTIFICATE_TBL,
@@ -647,14 +634,12 @@ enum
        FILE_PATH_IDX_IN_MAIL_CERTIFICATE_TBL,
 };
 
-enum
-{
+enum {
        TO_RECIPIENT = 0,
        CC_RECIPIENT,
        BCC_RECIPIENT,
 };
-enum
-{
+enum {
        ACCOUNT_ID_IDX_IN_MAIL_BOX_TBL = 0,
        LOCAL_YN_IDX_IN_MAIL_BOX_TBL,
        MAILBOX_NAME_IDX_IN_MAIL_BOX_TBL,
@@ -667,8 +652,7 @@ enum
        MAIL_SLOT_SIZE_IDX_IN_MAIL_BOX_TBL,
 };
 
-enum
-{
+enum {
        ACCOUNT_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL = 0,
        LOCAL_MAILBOX_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL,
        MAILBOX_NAME_IDX_IN_MAIL_READ_MAIL_UID_TBL,
@@ -682,8 +666,7 @@ enum
 };
 
 #ifdef __FEATURE_BODY_SEARCH__
-enum
-{
+enum {
        MAIL_ID_IDX_IN_MAIL_TEXT_TBL = 0,
        ACCOUNT_ID_IDX_IN_MAIL_TEXT_TBL,
        MAILBOX_ID_IDX_IN_MAIL_TEXT_TBL,
@@ -692,8 +675,7 @@ enum
 };
 #endif
 
-enum
-{
+enum {
        ACCOUNT_ID_IDX_IN_MAIL_RULE_TBL = 0,
        RULE_ID_IDX_IN_MAIL_RULE_TBL,
        FILTER_NAME_IDX_IN_MAIL_RULE_TBL,
@@ -706,8 +688,7 @@ enum
        FLAG2_IDX_IN_MAIL_RULE_TBL,
 };
 
-enum
-{
+enum {
        MAIL_ID_IDX_IN_MAIL_TBL = 0,
        ACCOUNT_ID_IDX_IN_MAIL_TBL,
        MAILBOX_ID_IDX_IN_MAIL_TBL,
@@ -767,8 +748,7 @@ enum
        FIELD_COUNT_OF_MAIL_TBL,  /* End of mail_tbl */
 };
 
-enum
-{
+enum {
        ATTACHMENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL = 0,
        ATTACHMENT_NAME_IDX_IN_MAIL_ATTACHMENT_TBL,
        ATTACHMENT_PATH_IDX_IN_MAIL_ATTACHMENT_TBL,
@@ -807,8 +787,7 @@ enum {
 };
 
 #ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
-enum
-{
+enum {
        ACTIVITY_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL = 0,
        STATUS_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL,
        ACCOUNT_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL,
@@ -1085,7 +1064,7 @@ int _field_count_of_table[CREATE_TABLE_MAX] = { 0, };
 
 static int _get_table_field_data_char(char  **table, char *buf, int index)
 {
-       if ((table == NULL) || (buf == NULL) || (index < 0))  {
+       if ((table == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION("table[%p], buf[%p], index[%d]", table, buf, index);
                return false;
        }
@@ -1103,7 +1082,7 @@ static int _get_table_field_data_char(char  **table, char *buf, int index)
 
 static int _get_table_field_data_int(char  **table, int *buf, int index)
 {
-       if ((table == NULL) || (buf == NULL) || (index < 0))  {
+       if ((table == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION("table[%p], buf[%p], index[%d]", table, buf, index);
                return false;
        }
@@ -1121,7 +1100,7 @@ static int _get_table_field_data_int(char  **table, int *buf, int index)
 
 static int _get_table_field_data_time_t(char  **table, time_t *buf, int index)
 {
-       if ((table == NULL) || (buf == NULL) || (index < 0))  {
+       if ((table == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION("table[%p], buf[%p], index[%d]", table, buf, index);
                return false;
        }
@@ -1141,7 +1120,7 @@ static int _get_table_field_data_string(char **table, char **buf, int ucs2, int
 {
        int ret = false;
 
-       if ((table == NULL) || (buf == NULL) || (index < 0))  {
+       if ((table == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION("table[%p], buf[%p], index[%d]", table, buf, index);
                return false;
        }
@@ -1152,15 +1131,14 @@ static int _get_table_field_data_string(char **table, char **buf, int ucs2, int
                *buf = NULL;
        else {
                sLen = EM_SAFE_STRLEN(pTemp);
-               if(sLen) {
+               if (sLen) {
                        *buf = (char *) em_malloc(sLen + 1);
                        if (*buf == NULL) {
                                EM_DEBUG_EXCEPTION("malloc is failed");
                                goto FINISH_OFF;
                        }
                        strncpy(*buf, pTemp, sLen);
-               }
-               else
+               } else
                        *buf = NULL;
        }
 #ifdef _PRINT_STORAGE_LOG_
@@ -1177,7 +1155,7 @@ FINISH_OFF:
 
 static int _get_table_field_data_string_without_allocation(char **table, char *buf, int buffer_size, int ucs2, int index)
 {
-       if ((table == NULL) || (buf == NULL) || (index < 0))  {
+       if ((table == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION(" table[%p], buf[%p], index[%d]", table, buf, index);
                        return false;
        }
@@ -1202,7 +1180,7 @@ static int _get_table_field_data_string_without_allocation(char **table, char *b
 
 static int _get_table_field_data_blob(char **table, void **buffer, int buffer_size, int index)
 {
-       if ((table == NULL) || (buffer == NULL) || (index < 0))  {
+       if ((table == NULL) || (buffer == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION(" table[%p], buffer[%p], buffer_size [%d], index[%d]", table, buffer, buffer_size, index);
                return false;
        }
@@ -1213,7 +1191,7 @@ static int _get_table_field_data_blob(char **table, void **buffer, int buffer_si
                buffer = NULL;
        else {
                *buffer = malloc(buffer_size);
-               if(*buffer == NULL) {
+               if (*buffer == NULL) {
                        EM_DEBUG_EXCEPTION("allocation failed.");
                        return false;
                }
@@ -1232,7 +1210,7 @@ static int _get_table_field_data_blob(char **table, void **buffer, int buffer_si
 
 static int _get_stmt_field_data_char(DB_STMT hStmt, char *buf, int index)
 {
-       if ((hStmt == NULL) || (buf == NULL) || (index < 0))  {
+       if ((hStmt == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION("buf[%p], index[%d]", buf, index);
                return false;
        }
@@ -1252,7 +1230,7 @@ static int _get_stmt_field_data_char(DB_STMT hStmt, char *buf, int index)
 
 static int _get_stmt_field_data_int(DB_STMT hStmt, int *buf, int index)
 {
-       if ((hStmt == NULL) || (buf == NULL) || (index < 0))  {
+       if ((hStmt == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION("buf[%p], index[%d]", buf, index);
                return false;
        }
@@ -1272,7 +1250,7 @@ static int _get_stmt_field_data_int(DB_STMT hStmt, int *buf, int index)
 
 static int _get_stmt_field_data_time_t(DB_STMT hStmt, time_t *buf, int index)
 {
-       if ((hStmt == NULL) || (buf == NULL) || (index < 0))  {
+       if ((hStmt == NULL) || (buf == NULL) || (index < 0)) {
                EM_DEBUG_EXCEPTION("buf[%p], index[%d]", buf, index);
                return false;
        }
@@ -1291,7 +1269,7 @@ static int _get_stmt_field_data_time_t(DB_STMT hStmt, time_t *buf, int index)
 
 static int _get_stmt_field_data_string(DB_STMT hStmt, char **buf, int ucs2, int index)
 {
-       if (!hStmt || !buf || (index < 0))  { /*prevent 39619*/
+       if (!hStmt || !buf || (index < 0)) { /*prevent 39619*/
                EM_DEBUG_EXCEPTION("hStmt[%d], buf[%p], index[%d]", hStmt, buf, index);
                return false;
        }
@@ -1306,13 +1284,12 @@ static int _get_stmt_field_data_string(DB_STMT hStmt, char **buf, int ucs2, int
        if (sLen > 0) {
                *buf = (char *) em_malloc(sLen + 1);
                if (*buf == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        return false;
                }
 
                strncpy(*buf, (char *)sqlite3_column_text(hStmt, index), sLen);
-       }
-       else
+       } else
                *buf = NULL;
 
 #ifdef _PRINT_STORAGE_LOG_
@@ -1327,7 +1304,7 @@ static int _get_stmt_field_data_string(DB_STMT hStmt, char **buf, int ucs2, int
 
 static void _get_stmt_field_data_blob(DB_STMT hStmt, void **buf, int index)
 {
-       if( !hStmt || !buf || (index < 0))  { /*prevent 39618*/
+       if (!hStmt || !buf || (index < 0)) { /*prevent 39618*/
                EM_DEBUG_EXCEPTION("hStmt[%d], buf[%p], index[%d]", hStmt, buf, index);
                return;
        }
@@ -1342,20 +1319,19 @@ static void _get_stmt_field_data_blob(DB_STMT hStmt, void **buf, int index)
        if (sLen > 0) {
                *buf = (char *) em_malloc(sLen);
                if (*buf == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        return;
                }
 
                memcpy(*buf, (void *)sqlite3_column_blob(hStmt, index), sLen);
-       }
-       else
+       } else
                *buf = NULL;
 
 }
 
 static int _get_stmt_field_data_string_without_allocation(DB_STMT hStmt, char *buf, int buffer_size, int ucs2, int index)
 {
-       if (!hStmt || !buf || (index < 0))  { /*prevent 39620*/
+       if (!hStmt || !buf || (index < 0)) { /*prevent 39620*/
                EM_DEBUG_EXCEPTION("hStmt[%d], buf[%p], buffer_size[%d], index[%d]", hStmt, buf, buffer_size, index);
                return false;
        }
@@ -1370,8 +1346,7 @@ static int _get_stmt_field_data_string_without_allocation(DB_STMT hStmt, char *b
        if (sLen > 0) {
                memset(buf, 0, buffer_size);
                strncpy(buf, (char *)sqlite3_column_text(hStmt, index), buffer_size - 1);
-       }
-       else
+       } else
                strcpy(buf, "");
 
 #ifdef _PRINT_STORAGE_LOG_
@@ -1390,7 +1365,7 @@ static int _bind_stmt_field_data_char(DB_STMT hStmt, int index, char value)
 
        int ret = sqlite3_bind_int(hStmt, index+1, (int)value);
 
-       if (ret != SQLITE_OK)  {
+       if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_int fail - %d", ret);
                return false;
        }
@@ -1407,7 +1382,7 @@ static int _bind_stmt_field_data_int(DB_STMT hStmt, int index, int value)
 
        int ret = sqlite3_bind_int(hStmt, index+1, value);
 
-       if (ret != SQLITE_OK)  {
+       if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_int fail - %d", ret);
                return false;
        }
@@ -1424,7 +1399,7 @@ static int _bind_stmt_field_data_time_t(DB_STMT hStmt, int index, time_t value)
 
        int ret = sqlite3_bind_int(hStmt, index+1, (int)value);
 
-       if (ret != SQLITE_OK)  {
+       if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_int fail - %d", ret);
                return false;
        }
@@ -1449,7 +1424,7 @@ static int _bind_stmt_field_data_string(DB_STMT hStmt, int index, char *value, i
        else
                ret = sqlite3_bind_text(hStmt, index+1, "", -1, NULL);
 
-       if (ret != SQLITE_OK)  {
+       if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_text fail [%d]", ret);
                return false;
        }
@@ -1483,7 +1458,7 @@ static int _bind_stmt_field_data_nstring(DB_STMT hStmt, int index, char *value,
                else {
                        char *buf = (char*)em_malloc(sizeof(char) * (max_len));
                        if (buf == NULL) {
-                               EM_DEBUG_EXCEPTION("em_malloc failed");
+                               EM_DEBUG_EXCEPTION("em_mallocfailed");
                                return false;
                        }
                        snprintf(buf, max_len-1, "%s", value);
@@ -1492,7 +1467,7 @@ static int _bind_stmt_field_data_nstring(DB_STMT hStmt, int index, char *value,
        } else
                ret = sqlite3_bind_text(hStmt, index+1, "", -1, NULL);
 
-       if (ret != SQLITE_OK)  {
+       if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_text fail [%d]", ret);
                return false;
        }
@@ -1512,12 +1487,12 @@ static int _bind_stmt_field_data_blob(DB_STMT hStmt, int index, void *blob, int
 #endif
 
        int ret = 0;
-       if (blob_size>0)
+       if (blob_size > 0)
                ret = sqlite3_bind_blob(hStmt, index+1, blob, blob_size, SQLITE_STATIC);
        else
                ret = sqlite3_bind_null(hStmt, index+1);
 
-       if (ret != SQLITE_OK)  {
+       if (ret != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("sqlite3_bind_blob fail [%d]", ret);
                return false;
        }
@@ -1534,12 +1509,12 @@ static int _delete_temp_file(const char *path)
 
        char buf[1024] = {0x00, };
 
-       if ((dp = opendir(path)) == NULL)  {
+       if ((dp = opendir(path)) == NULL) {
                EM_DEBUG_EXCEPTION("opendir(\"%s\") failed...", path);
                return false;
        }
 
-       while ((entry = readdir(dp)) != NULL)  {
+       while ((entry = readdir(dp)) != NULL) {
                SNPRINTF(buf, sizeof(buf), "%s/%s", path, entry->d_name);
                remove(buf);
        }
@@ -1553,8 +1528,8 @@ char *cpy_str(char *src)
 {
        char *p = NULL;
 
-       if (src)  {
-               if (!(p = em_malloc((int)EM_SAFE_STRLEN(src) + 1)))  {
+       if (src) {
+               if (!(p = em_malloc((int)EM_SAFE_STRLEN(src) + 1))) {
                        EM_DEBUG_EXCEPTION("mailoc failed...");
                        return NULL;
                }
@@ -1751,10 +1726,10 @@ int _xsystem(const char *argv[])
        pid = fork();
 
        switch (pid) {
-               case -1 :
+               case -1:
                        perror("fork failed");
                        return -1;
-               case 0 :
+               case 0:
                        if (execvp(argv[0], (char *const *)argv) == -1) {
                                perror("execute init db script");
                                _exit(-1);
@@ -1849,7 +1824,7 @@ INTERNAL_FUNC int em_db_open(char *db_file_path, sqlite3 **sqlite_handle, int *e
 
        EM_DEBUG_LOG_DEV("*sqlite_handle[%p]", *sqlite_handle);
 
-       if (*sqlite_handle)  { /*prevent 33351*/
+       if (*sqlite_handle) { /*prevent 33351*/
                EM_DEBUG_LOG_DEV(">>>>> DB Already Opened......");
                if (err_code != NULL)
                        *err_code = error;
@@ -1890,8 +1865,7 @@ INTERNAL_FUNC int em_db_open(char *db_file_path, sqlite3 **sqlite_handle, int *e
                                *sqlite_handle = NULL;
                                goto FINISH_OFF; /*prevent 33351*/
                        }
-               }
-               else
+               } else
                        goto FINISH_OFF;
        }
 
@@ -1937,7 +1911,7 @@ INTERNAL_FUNC sqlite3* emstorage_db_open(char *multi_user_name, int *err_code)
 
        _db_handle = emstorage_get_db_handle(multi_user_name);
 
-       if_db_handle == NULL) {
+       if (_db_handle == NULL) {
                char *output_file_path = NULL;
         char temp_file_path[MAX_PATH] = {0};
 
@@ -2081,7 +2055,7 @@ static int emstorage_get_field_count_from_create_table_query(char *input_create_
        int field_count = 0;
        char *pos = NULL;
 
-       if(input_create_table_query == NULL || output_field_count == NULL) {
+       if (input_create_table_query == NULL || output_field_count == NULL) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -2090,11 +2064,11 @@ static int emstorage_get_field_count_from_create_table_query(char *input_create_
 
        do {
                field_count++;
-               if(pos == NULL || *pos == (char)0)
+               if (pos == NULL || *pos == (char)0)
                        break;
                pos += 1;
                pos = strchr(pos, ',');
-       } while(pos);
+       } while (pos);
 
        *output_field_count = field_count;
 
@@ -2113,7 +2087,7 @@ INTERNAL_FUNC int emstorage_initialize_field_count()
        int query_len = 0;
        char **create_table_query = NULL;
 
-       if(_field_count_of_table[CREATE_TABLE_MAIL_ACCOUNT_TBL] != 0) {
+       if (_field_count_of_table[CREATE_TABLE_MAIL_ACCOUNT_TBL] != 0) {
                err = EMAIL_ERROR_ALREADY_INITIALIZED;
                goto FINISH_OFF;
        }
@@ -2214,9 +2188,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_account_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_ACCOUNT_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_ACCOUNT_TBL], rc, sqlite3_errmsg(local_db_handle)));
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_ACCOUNT_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
 
        sqlite3_free_table(result);
@@ -2253,9 +2227,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_box_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                rc = sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_BOX_TBL], NULL, NULL, NULL);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_BOX_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
        sqlite3_free_table(result);
@@ -2292,9 +2266,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_read_mail_uid_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_READ_MAIL_UID_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_READ_MAIL_UID_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
        sqlite3_free_table(result);
@@ -2323,9 +2297,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_rule_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_RULE_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_RULE_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
        sqlite3_free_table(result);
@@ -2378,9 +2352,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
                /*  just one time call */
 /*             EFTSInitFTSIndex(FTS_EMAIL_IDX); */
        } /*  mail_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
        sqlite3_free_table(result);
@@ -2416,9 +2390,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_attachment_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_ATTACHMENT_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_ATTACHMENT_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
        sqlite3_free_table(result);
@@ -2448,9 +2422,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_rule_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_PARTIAL_BODY_ACTIVITY_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_PARTIAL_BODY_ACTIVITY_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
        sqlite3_free_table(result);
@@ -2487,9 +2461,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_contact_sync_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_MEETING_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_MEETING_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
        sqlite3_free_table(result);
@@ -2519,10 +2493,10 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
                } /*  mail_rule_tbl */
-               else if (type == EMAIL_CREATE_DB_CHECK)  {
+               else if (type == EMAIL_CREATE_DB_CHECK) {
                        rc = sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL], NULL, NULL, NULL);
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL], NULL, NULL, NULL), rc);
-                       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_LOCAL_ACTIVITY_TBL], rc, sqlite3_errmsg(local_db_handle)));
                }
                sqlite3_free_table(result);
@@ -2549,9 +2523,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_contact_sync_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_CERTIFICATE_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_CERTIFICATE_TBL], rc, sqlite3_errmsg(local_db_handle)));
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_CERTIFICATE_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
 
        sqlite3_free_table(result);
@@ -2584,9 +2558,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_task_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_TASK_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_TASK_TBL], rc, sqlite3_errmsg(local_db_handle)));
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_TASK_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
 
        sqlite3_free_table(result);
@@ -2613,9 +2587,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_text_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_TEXT_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_TEXT_TBL], rc, sqlite3_errmsg(local_db_handle)));
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_TEXT_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
 
        sqlite3_free_table(result);
@@ -2644,9 +2618,9 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
        } /*  mail_auto_download_activity_tbl */
-       else if (type == EMAIL_CREATE_DB_CHECK)  {
+       else if (type == EMAIL_CREATE_DB_CHECK) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, g_test_query[CREATE_TABLE_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL], NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL], rc, sqlite3_errmsg(local_db_handle)));
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("SQL(%s) exec fail:%d -%s", g_test_query[CREATE_TABLE_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL], rc, sqlite3_errmsg(local_db_handle)));
        }
 
        sqlite3_free_table(result);
@@ -2658,12 +2632,11 @@ INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create
 
 FINISH_OFF:
 
-       if(result) sqlite3_free_table(result);
+       if (result) sqlite3_free_table(result);
 
        if (ret == true) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
-       }
-       else {
+       } else {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "rollback", NULL, NULL, NULL), rc);
        }
 
@@ -2705,7 +2678,7 @@ INTERNAL_FUNC int emstorage_query_mail_count(char *multi_user_name, const char *
        query_size = EM_SAFE_STRLEN(input_conditional_clause) + QUERY_SIZE;
        sql_query_string = em_malloc(query_size);
        if (sql_query_string == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -2717,22 +2690,22 @@ INTERNAL_FUNC int emstorage_query_mail_count(char *multi_user_name, const char *
        SNPRINTF(sql_query_string, query_size, "SELECT COUNT(*) FROM mail_tbl");
        EM_SAFE_STRCAT(sql_query_string, (char*)input_conditional_clause);
 
-       if (output_total_mail_count)  {
+       if (output_total_mail_count) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_prepare failed [%d] [%s]", rc, sql_query_string));
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step failed [%d] [%s]", rc, sql_query_string));
                _get_stmt_field_data_int(hStmt, output_total_mail_count, 0);
        }
 
-       if (output_unseen_mail_count)  {
+       if (output_unseen_mail_count) {
                EM_SAFE_STRCAT(sql_query_string, " AND flags_seen_field = 0 ");
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                        ("sqlite3_get_table failed [%d] [%s]", rc, sql_query_string));
 
                *output_unseen_mail_count = atoi(result[1]);
@@ -2741,10 +2714,10 @@ INTERNAL_FUNC int emstorage_query_mail_count(char *multi_user_name, const char *
 
 FINISH_OFF:
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -2780,7 +2753,7 @@ INTERNAL_FUNC int emstorage_query_mail_id_list(char *multi_user_name, const char
        query_size = strlen(input_conditional_clause) + strlen("SELECT mail_id FROM mail_tbl ") + 10;  // 10 is extra space
        sql_query_string = em_malloc(query_size);
        if (sql_query_string == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -2795,7 +2768,7 @@ INTERNAL_FUNC int emstorage_query_mail_id_list(char *multi_user_name, const char
 
        /* Performing query */
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        col_index = 1;
@@ -2827,14 +2800,14 @@ INTERNAL_FUNC int emstorage_query_mail_id_list(char *multi_user_name, const char
 
 FINISH_OFF:
 
-       if(result)
+       if (result)
                sqlite3_free_table(result);
 
        EMSTORAGE_FINISH_READ_TRANSACTION(input_transaction);
 
        EM_SAFE_FREE(sql_query_string);
 
-       if(error != EMAIL_ERROR_NONE)
+       if (error != EMAIL_ERROR_NONE)
                EM_SAFE_FREE(result_mail_id_list);
 
        EM_DEBUG_FUNC_END("error [%d]", error);
@@ -2846,7 +2819,7 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
        EM_DEBUG_FUNC_BEGIN();
        EM_PROFILE_BEGIN(emstorage_query_mail_list_func);
 
-       int i = 0, count = 0, rc = -1, to_get_count = (result_mail_list)?0:1;
+       int i = 0, count = 0, rc = -1, to_get_count = (result_mail_list) ? 0 : 1;
        int sql_query_string_length = 0;
        int local_inline_content_count = 0, local_attachment_count = 0;
        int cur_query = 0, base_count = 0, col_index;
@@ -2874,11 +2847,11 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
 
        sql_query_string_length = EM_SAFE_STRLEN(select_query_form) + EM_SAFE_STRLEN(target_field) + EM_SAFE_STRLEN(conditional_clause);
 
-       if(sql_query_string_length)
+       if (sql_query_string_length)
                sql_query_string = em_malloc(sql_query_string_length);
 
-       if(sql_query_string == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+       if (sql_query_string == NULL) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -2887,7 +2860,7 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
 
        strncat(sql_query_string, conditional_clause, sql_query_string_length - cur_query);
 
-       EM_DEBUG_LOG_DEV ("query[%s]", sql_query_string);
+       EM_DEBUG_LOG_DEV("query[%s]", sql_query_string);
 
        /*  performing query */
        EM_PROFILE_BEGIN(emstorage_query_mail_list_performing_query);
@@ -2898,7 +2871,7 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
 
        if (!base_count)
                base_count = ({
-                               int i=0;
+                               int i = 0;
                                char *tmp = NULL;
                                for (tmp = field_all; tmp && *(tmp + 1); tmp = index(tmp + 1, ',')) i++ ;
                                i;
@@ -2911,23 +2884,22 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
        if (to_get_count) {
                /*  to get count */
                if (!count) {
-                       EM_DEBUG_LOG_DEV ("No mail found...");
+                       EM_DEBUG_LOG_DEV("No mail found...");
                        ret = false;
-                       error= EMAIL_ERROR_MAIL_NOT_FOUND;
+                       error = EMAIL_ERROR_MAIL_NOT_FOUND;
                        goto FINISH_OFF;
                }
-               EM_DEBUG_LOG_DEV ("There are [%d] mails.", count);
-       }
-       else {
+               EM_DEBUG_LOG_DEV("There are [%d] mails.", count);
+       } else {
                /*  to get mail list */
                if (!count) {
-                       EM_DEBUG_LOG_DEV ("No mail found...");
+                       EM_DEBUG_LOG_DEV("No mail found...");
                        ret = false;
-                       error= EMAIL_ERROR_MAIL_NOT_FOUND;
+                       error = EMAIL_ERROR_MAIL_NOT_FOUND;
                        goto FINISH_OFF;
                }
 
-               EM_DEBUG_LOG_DEV ("There are [%d] mails.", count);
+               EM_DEBUG_LOG_DEV("There are [%d] mails.", count);
                if (!(mail_list_item_from_tbl = (email_mail_list_item_t*)em_malloc(sizeof(email_mail_list_item_t) * count))) {
                        EM_DEBUG_EXCEPTION("malloc for mail_list_item_from_tbl failed...");
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -2935,7 +2907,7 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
                }
 
                EM_PROFILE_BEGIN(emstorage_query_mail_list_loop);
-               EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN START >> ");
+               EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN START >> ");
                for (i = 0; i < count; i++) {
                        _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].mail_id), col_index++);
                        _get_table_field_data_int(result, &(mail_list_item_from_tbl[i].account_id), col_index++);
@@ -2973,7 +2945,7 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
                        _get_table_field_data_int(result, (int*)&(mail_list_item_from_tbl[i].eas_data_length), col_index++);
                        _get_table_field_data_blob(result, (void**)&(mail_list_item_from_tbl[i].eas_data), mail_list_item_from_tbl[i].eas_data_length, col_index++);
 
-                       mail_list_item_from_tbl[i].attachment_count = (local_attachment_count > 0) ? 1:0;
+                       mail_list_item_from_tbl[i].attachment_count = (local_attachment_count > 0) ? 1 : 0;
                }
                EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN END [count : %d] >> ", count);
                EM_PROFILE_END(emstorage_query_mail_list_loop);
@@ -2984,18 +2956,17 @@ INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *c
 FINISH_OFF:
        EM_DEBUG_LOG("MAIL_COUNT [%d]", count);
 
-       if(result)
+       if (result)
                sqlite3_free_table(result);
 
        if (to_get_count)
                *result_count = count;
        else {
-               if (ret == true)  {
+               if (ret == true) {
                        if (result_mail_list)
                                *result_mail_list = mail_list_item_from_tbl;
                        *result_count = count;
-               }
-               else
+               } else
                        EM_SAFE_FREE(mail_list_item_from_tbl);
        }
 
@@ -3036,16 +3007,16 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(char *multi_user_name, const char *co
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_tbl %s", conditional_clause);
 
-       EM_DEBUG_LOG_DEV ("Query[%s]", sql_query_string);
+       EM_DEBUG_LOG_DEV("Query[%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("sqlite3_get_table failed [%d] [%s]", rc, sql_query_string));
 
        if (!count) {
                EM_DEBUG_LOG("No mail found...");
                ret = false;
-               error= EMAIL_ERROR_MAIL_NOT_FOUND;
+               error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
        }
 
@@ -3056,19 +3027,19 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(char *multi_user_name, const char *co
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN START >> ");
+       EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN START >> ");
        for (i = 0; i < count; i++) {
-               _get_table_field_data_int   (result, &(p_data_tbl[i].mail_id), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].account_id), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].mailbox_id), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].mailbox_type), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].mail_id), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_id), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_type), col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].subject), 1, col_index++);
                _get_table_field_data_time_t (result, &(p_data_tbl[i].date_time), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].server_mail_status), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].server_mail_status), col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].server_mailbox_name), 0, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].server_mail_id), 0, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].message_id), 0, col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].reference_mail_id), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].reference_mail_id), col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].full_address_from), 1, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].full_address_reply), 1, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].full_address_to), 1, col_index++);
@@ -3079,11 +3050,11 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(char *multi_user_name, const char *co
                _get_table_field_data_string(result, &(p_data_tbl[i].email_address_recipient), 1, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].alias_sender), 1, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].alias_recipient), 1, col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].body_download_status), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].body_download_status), col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].file_path_plain), 0, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].file_path_html), 0, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].file_path_mime_entity), 0, col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].mail_size), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].mail_size), col_index++);
                _get_table_field_data_char  (result, &(p_data_tbl[i].flags_seen_field), col_index++);
                _get_table_field_data_char  (result, &(p_data_tbl[i].flags_deleted_field), col_index++);
                _get_table_field_data_char  (result, &(p_data_tbl[i].flags_flagged_field), col_index++);
@@ -3091,42 +3062,41 @@ INTERNAL_FUNC int emstorage_query_mail_tbl(char *multi_user_name, const char *co
                _get_table_field_data_char  (result, &(p_data_tbl[i].flags_recent_field), col_index++);
                _get_table_field_data_char  (result, &(p_data_tbl[i].flags_draft_field), col_index++);
                _get_table_field_data_char  (result, &(p_data_tbl[i].flags_forwarded_field), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].DRM_status), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].priority), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].save_status), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].lock_status), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].report_status), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].attachment_count), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].inline_content_count), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].thread_id), col_index++);
-               _get_table_field_data_int   (result, &(p_data_tbl[i].thread_item_count), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].DRM_status), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].priority), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].save_status), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].lock_status), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].report_status), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].attachment_count), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].inline_content_count), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].thread_id), col_index++);
+               _get_table_field_data_int(result, &(p_data_tbl[i].thread_item_count), col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].preview_text), 1, col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].meeting_request_status), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].message_class), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].digest_type), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].smime_type), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].scheduled_sending_time), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].remaining_resend_times), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].tag_id), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].replied_time), col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].forwarded_time), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].meeting_request_status), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].message_class), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].digest_type), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].smime_type), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].scheduled_sending_time), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].remaining_resend_times), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].tag_id), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].replied_time), col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].forwarded_time), col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].default_charset), 0, col_index++);
-               _get_table_field_data_int   (result, (int*)&(p_data_tbl[i].eas_data_length), col_index++);
-               _get_table_field_data_blob  (result, (void**)&(p_data_tbl[i].eas_data), p_data_tbl[i].eas_data_length, col_index++);
+               _get_table_field_data_int(result, (int*)&(p_data_tbl[i].eas_data_length), col_index++);
+               _get_table_field_data_blob(result, (void**)&(p_data_tbl[i].eas_data), p_data_tbl[i].eas_data_length, col_index++);
                _get_table_field_data_string(result, &(p_data_tbl[i].user_name), 0, col_index++);
        }
 
        ret = true;
 
 FINISH_OFF:
-       if(result)
+       if (result)
                sqlite3_free_table(result);
 
-       if (ret)  {
+       if (ret) {
                *result_mail_tbl = p_data_tbl;
                *result_count = count;
-       }
-       else {
+       } else {
                *result_mail_tbl = NULL;
                *result_count = 0;
        }
@@ -3178,7 +3148,7 @@ INTERNAL_FUNC int emstorage_query_mail_text_tbl(char *multi_user_name, const cha
        if (!count) {
                EM_DEBUG_LOG("No mail found...");
                ret = false;
-               error= EMAIL_ERROR_MAIL_NOT_FOUND;
+               error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
        }
 
@@ -3189,7 +3159,7 @@ INTERNAL_FUNC int emstorage_query_mail_text_tbl(char *multi_user_name, const cha
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN START >>");
+       EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN START >>");
        for (i = 0; i < count; i++) {
                _get_table_field_data_int(result, &(p_data_tbl[i].mail_id), col_index++);
                _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++);
@@ -3200,14 +3170,13 @@ INTERNAL_FUNC int emstorage_query_mail_text_tbl(char *multi_user_name, const cha
        ret = true;
 
 FINISH_OFF:
-       if(result)
+       if (result)
                sqlite3_free_table(result);
 
        if (ret == true) {
                *result_mail_text_tbl = p_data_tbl;
                *result_count = count;
-       }
-       else
+       } else
                EM_SAFE_FREE(p_data_tbl);
 
        EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
@@ -3244,8 +3213,7 @@ INTERNAL_FUNC int emstorage_query_mailbox_tbl(char *multi_user_name, const char
        if (input_get_mail_count == 0) {        /* without mail count */
                col_index = 15;
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s FROM mail_box_tbl AS MBT %s %s", fields, input_conditional_clause, input_ordering_clause);
-       }
-       else {  /* with read count and total count */
+       } else {        /* with read count and total count */
                col_index = 17;
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT %s, total, read  FROM mail_box_tbl AS MBT LEFT OUTER JOIN (SELECT mailbox_id, count(mail_id) AS total, SUM(flags_seen_field) AS read FROM mail_tbl WHERE flags_deleted_field = 0 GROUP BY mailbox_id) AS MT ON MBT.mailbox_id = MT.mailbox_id %s %s", fields, input_conditional_clause, input_ordering_clause);
        }
@@ -3253,24 +3221,24 @@ INTERNAL_FUNC int emstorage_query_mailbox_tbl(char *multi_user_name, const char
        EM_DEBUG_LOG_DEV("query[%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("sqlite3_get_table failed [%d] [%s]", rc, sql_query_string))
 
        EM_DEBUG_LOG_DEV("result count [%d]", count);
 
-       if(count == 0) {
-               EM_DEBUG_LOG_SEC ("Can't find mailbox query[%s]", sql_query_string);
+       if (count == 0) {
+               EM_DEBUG_LOG_SEC("Can't find mailbox query[%s]", sql_query_string);
                error = EMAIL_ERROR_MAILBOX_NOT_FOUND;
                goto FINISH_OFF;
        }
 
        if ((p_data_tbl = (emstorage_mailbox_tbl_t*)em_malloc(sizeof(emstorage_mailbox_tbl_t) * count)) == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                _get_table_field_data_int(result, &(p_data_tbl[i].mailbox_id), col_index++);
                _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++);
                _get_table_field_data_int(result, &(p_data_tbl[i].local_yn), col_index++);
@@ -3300,7 +3268,7 @@ FINISH_OFF:
        if (result)
                sqlite3_free_table(result);
 
-       if (error == EMAIL_ERROR_NONE)  {
+       if (error == EMAIL_ERROR_NONE) {
                *output_mailbox_list = p_data_tbl;
                *output_mailbox_count = count;
                EM_DEBUG_LOG("Mailbox Count [%d]", count);
@@ -3325,8 +3293,8 @@ INTERNAL_FUNC int emstorage_check_duplicated_account(char *multi_user_name, emai
        char sql_query_string[QUERY_SIZE] = {0, };
        sqlite3 *local_db_handle = NULL;
 
-       if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL||
-               account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL)  {
+       if (account == NULL || account->user_email_address == NULL || account->incoming_server_user_name == NULL || account->incoming_server_address == NULL ||
+               account->outgoing_server_user_name == NULL || account->outgoing_server_address == NULL) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -3352,7 +3320,7 @@ INTERNAL_FUNC int emstorage_check_duplicated_account(char *multi_user_name, emai
        );
        EM_DEBUG_LOG_SEC("Query[%s]", sql_query_string);
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        count = atoi(result[1]);
@@ -3363,8 +3331,7 @@ INTERNAL_FUNC int emstorage_check_duplicated_account(char *multi_user_name, emai
        if (count == 0) {       /*  not duplicated account */
                ret = true;
                EM_DEBUG_LOG_SEC("NOT duplicated account: user_email_address[%s]", account->user_email_address);
-       }
-       else {  /*  duplicated account */
+       } else {        /*  duplicated account */
                ret = false;
                EM_DEBUG_LOG_SEC("The same account already exists. Duplicated account: user_email_address[%s]", account->user_email_address);
                error = EMAIL_ERROR_ALREADY_EXISTS;
@@ -3386,7 +3353,7 @@ INTERNAL_FUNC int emstorage_get_account_count(char *multi_user_name, int *count,
 {
        EM_DEBUG_FUNC_BEGIN();
 
-       if (!count)  {
+       if (!count) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -3403,14 +3370,14 @@ INTERNAL_FUNC int emstorage_get_account_count(char *multi_user_name, int *count,
        EMSTORAGE_START_READ_TRANSACTION(transaction);
        SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_account_tbl");
        EM_DEBUG_LOG_SEC("SQL STMT [%s]", sql_query_string);
-       EMSTORAGE_PROTECTED_FUNC_CALL (sqlite3_prepare_v2 (local_db_handle, sql_query_string,
-                                                          EM_SAFE_STRLEN (sql_query_string), &hStmt, NULL), rc);
+       EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string,
+                                                          EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG("Before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        *count = sqlite3_column_int(hStmt, 0);
@@ -3419,11 +3386,11 @@ INTERNAL_FUNC int emstorage_get_account_count(char *multi_user_name, int *count,
 
 FINISH_OFF:
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               hStmt=NULL;
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               hStmt = NULL;
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -3452,7 +3419,7 @@ INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_
        sqlite3 *local_db_handle = NULL;
        DB_STMT hStmt = NULL;
 
-       if (!select_num || !account_list)  {
+       if (!select_num || !account_list) {
                EM_DEBUG_EXCEPTION("select_num[%p], account_list[%p]", select_num, account_list);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -3464,7 +3431,7 @@ INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
        count = atoi(result[1]);
@@ -3556,14 +3523,14 @@ INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
-       EM_DEBUG_LOG_DEV ("After sqlite3_prepare_v2 hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_LOG_DEV("After sqlite3_prepare_v2 hStmt = %p", hStmt);
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       if (rc == SQLITE_DONE)  {
+       if (rc == SQLITE_DONE) {
                EM_DEBUG_EXCEPTION("no account found...");
 
                error = EMAIL_ERROR_ACCOUNT_NOT_FOUND;
@@ -3572,13 +3539,13 @@ INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_
                goto FINISH_OFF;
        }
 
-       if (!(p_data_tbl = (emstorage_account_tbl_t*)malloc(sizeof(emstorage_account_tbl_t) * count)))  {
+       if (!(p_data_tbl = (emstorage_account_tbl_t*)malloc(sizeof(emstorage_account_tbl_t) * count))) {
                EM_DEBUG_EXCEPTION("malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
        memset(p_data_tbl, 0x00, sizeof(emstorage_account_tbl_t) * count);
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                /*  get recordset */
                field_index = 0;
                _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl[i].account_id), field_index++);
@@ -3658,25 +3625,25 @@ INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_
                        EM_SAFE_FREE(p_data_tbl[i].outgoing_server_password);
 
                        /*  get password file name */
-                       error = _get_password_file_name (multi_user_name, p_data_tbl[i].account_id,
+                       error = _get_password_file_name(multi_user_name, p_data_tbl[i].account_id,
                                                    recv_password_file_name,
                                                    send_password_file_name);
-                       if (error != EMAIL_ERROR_NONE){
+                       if (error != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("_get_password_file_name error [%d]", error);
                                error = EMAIL_ERROR_SECURED_STORAGE_FAILURE;
                                goto FINISH_OFF;
                        }
 
                        /*  read password from secure storage */
-                       error = _read_password_from_secure_storage (recv_password_file_name,
+                       error = _read_password_from_secure_storage(recv_password_file_name,
                                           &(p_data_tbl[i].incoming_server_password));
-                       if (error < 0 ) {
+                       if (error < 0) {
                                EM_DEBUG_EXCEPTION("_read_password_from_secure_storage()[%s] error [%d]",
                                                     recv_password_file_name, error);
                                error = EMAIL_ERROR_SECURED_STORAGE_FAILURE;
                                goto FINISH_OFF;
                        }
-                       error = _read_password_from_secure_storage (send_password_file_name,
+                       error = _read_password_from_secure_storage(send_password_file_name,
                                           &(p_data_tbl[i].outgoing_server_password));
                        if (error < 0) {
                                EM_DEBUG_EXCEPTION("_read_password_from_secure_storage()[%s]  error [%d]",
@@ -3688,25 +3655,24 @@ INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
                EM_DEBUG_LOG_DEV("after sqlite3_step(), i = %d, rc = %d.", i,  rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
        }
 
        ret = true;
 
 FINISH_OFF:
-       if (ret == true)  {
+       if (ret == true) {
                *account_list = p_data_tbl;
                *select_num = count;
                EM_DEBUG_LOG_DEV("COUNT : %d", count);
-       }
-       else if (p_data_tbl != NULL)
+       } else if (p_data_tbl != NULL)
                emstorage_free_account(&p_data_tbl, count, NULL);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
                hStmt = NULL;
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -3787,43 +3753,40 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, int m
 
        /*  where clause */
        if (account_id != ALL_ACCOUNT) {
-               cur_clause += (conditional_clause_count++ == 0)?
-                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE account_id = %d", account_id):
+               cur_clause += (conditional_clause_count++ == 0) ?
+                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE account_id = %d", account_id) :
                        SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND account_id = %d", account_id);
        }
 
        if (mailbox_id > 0) {
-               cur_clause += (conditional_clause_count++ == 0)?
-                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE mailbox_id = %d", mailbox_id):
+               cur_clause += (conditional_clause_count++ == 0) ?
+                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE mailbox_id = %d", mailbox_id) :
                        SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND mailbox_id = %d", mailbox_id);
        }
 
        if (thread_id > 0) {
-               cur_clause += (conditional_clause_count++ == 0)?
-                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE thread_id = %d ", thread_id):
+               cur_clause += (conditional_clause_count++ == 0) ?
+                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE thread_id = %d ", thread_id) :
                        SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND thread_id = %d ", thread_id);
-       }
-       else if (thread_id == EMAIL_LIST_TYPE_THREAD)   {
-               cur_clause += (conditional_clause_count++ == 0)?
-                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE thread_item_count > 0"):
+       } else if (thread_id == EMAIL_LIST_TYPE_THREAD) {
+               cur_clause += (conditional_clause_count++ == 0) ?
+                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE thread_item_count > 0") :
                        SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND thread_item_count > 0");
-       }
-       else if (thread_id == EMAIL_LIST_TYPE_LOCAL) {
-               cur_clause += (conditional_clause_count++ == 0)?
-                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE server_mail_status = 0"):
+       } else if (thread_id == EMAIL_LIST_TYPE_LOCAL) {
+               cur_clause += (conditional_clause_count++ == 0) ?
+                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE server_mail_status = 0") :
                        SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND server_mail_status = 0");
-       }
-       else if (thread_id == EMAIL_LIST_TYPE_UNREAD) {
-               cur_clause += (conditional_clause_count++ == 0)?
-                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE flags_seen_field == 0"):
+       } else if (thread_id == EMAIL_LIST_TYPE_UNREAD) {
+               cur_clause += (conditional_clause_count++ == 0) ?
+                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE flags_seen_field == 0") :
                        SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND flags_seen_field == 0");
        }
 
        /*  EM_DEBUG_LOG("where clause added [%s]", conditional_clause_string); */
        if (addr_list && addr_list->address_count > 0) {
                if (!addr_list->address_type) {
-                       cur_clause += (conditional_clause_count++ == 0)?
-                               SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE email_address_sender IN(\"%s\"", addr_list->address_list[0]):
+                       cur_clause += (conditional_clause_count++ == 0) ?
+                               SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE email_address_sender IN(\"%s\"", addr_list->address_list[0]) :
                                SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND email_address_sender IN(\"%s\"", addr_list->address_list[0]);
 
                        for (i = 1; i < addr_list->address_count; i++)
@@ -3831,8 +3794,8 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, int m
 
                        cur_clause += SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, ")");
                } else {
-                       cur_clause += (conditional_clause_count++ == 0)?
-                               SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE full_address_to IN(\"%s\") or full_address_cc IN(\"%s\"", addr_list->address_list[0], addr_list->address_list[0]):
+                       cur_clause += (conditional_clause_count++ == 0) ?
+                               SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE full_address_to IN(\"%s\") or full_address_cc IN(\"%s\"", addr_list->address_list[0], addr_list->address_list[0]) :
                                SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND full_address_to IN(\"%s\") or full_address_cc IN(\"%s\"", addr_list->address_list[0], addr_list->address_list[0]);
 
                        for (i = 1; i < addr_list->address_count; i++)
@@ -3843,8 +3806,8 @@ static int _write_conditional_clause_for_getting_mail_list(int account_id, int m
        }
 
        if (input_except_delete_flagged_mails) {
-               cur_clause += (conditional_clause_count++ == 0)?
-                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE flags_deleted_field = 0"):
+               cur_clause += (conditional_clause_count++ == 0) ?
+                       SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " WHERE flags_deleted_field = 0") :
                        SNPRINTF_OFFSET(conditional_clause_string, cur_clause, buffer_size - cur_clause, " AND flags_deleted_field = 0");
        }
 
@@ -3940,7 +3903,7 @@ INTERNAL_FUNC int emstorage_get_mail_list(char *multi_user_name, int account_id,
 
        EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
 
-       if(!emstorage_query_mail_list(multi_user_name, conditional_clause_string, transaction, mail_list, result_count, &error)) {
+       if (!emstorage_query_mail_list(multi_user_name, conditional_clause_string, transaction, mail_list, result_count, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", error);
                goto FINISH_OFF;
        }
@@ -3985,7 +3948,7 @@ INTERNAL_FUNC int emstorage_get_mails(char *multi_user_name, int account_id, int
 
        EM_DEBUG_LOG("conditional_clause_string [%s]", conditional_clause_string);
 
-       if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause_string, transaction, &p_data_tbl, &count,  &error)) {
+       if (!emstorage_query_mail_tbl(multi_user_name, conditional_clause_string, transaction, &p_data_tbl, &count,  &error)) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl failed [%d]", error);
                goto FINISH_OFF;
        }
@@ -3993,12 +3956,12 @@ INTERNAL_FUNC int emstorage_get_mails(char *multi_user_name, int account_id, int
        ret = true;
 
 FINISH_OFF:
+
        if (ret == true) {
                *mail_list = p_data_tbl;
                *result_count = count;
                EM_DEBUG_LOG("COUNT : %d", count);
-       }
-       else if (p_data_tbl != NULL)
+       } else if (p_data_tbl != NULL)
                emstorage_free_mail(&p_data_tbl, count, NULL);
 
        if (err_code != NULL)
@@ -4041,7 +4004,7 @@ INTERNAL_FUNC int emstorage_get_searched_mail_list(char *multi_user_name, int ac
 
        EM_DEBUG_LOG("conditional_clause[%s]", conditional_clause);
 
-       if(!emstorage_query_mail_list(multi_user_name, conditional_clause, transaction, mail_list, result_count, &error)) {
+       if (!emstorage_query_mail_list(multi_user_name, conditional_clause, transaction, mail_list, result_count, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", error);
                goto FINISH_OFF;
        }
@@ -4066,7 +4029,7 @@ static int _get_password_file_name(char *multi_user_name, int account_id, char *
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
 
-       if (account_id <= 0 || !recv_password_file_name || !send_password_file_name)  {
+       if (account_id <= 0 || !recv_password_file_name || !send_password_file_name) {
                EM_DEBUG_EXCEPTION("Invalid parameter");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -4112,7 +4075,7 @@ INTERNAL_FUNC int emstorage_get_account_by_id(char *multi_user_name, int account
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], pulloption[%d], account[%p], transaction[%d], err_code[%p]", account_id, pulloption, account, transaction, err_code);
 
-       if (!account)  {
+       if (!account) {
                EM_DEBUG_EXCEPTION("account_id[%d], account[%p]", account_id, account);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -4225,21 +4188,21 @@ INTERNAL_FUNC int emstorage_get_account_by_id(char *multi_user_name, int account
 
        /*  execute a sql and count rows */
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
-       if (rc == SQLITE_DONE)  {
+       if (rc == SQLITE_DONE) {
                EM_DEBUG_EXCEPTION("no matched account found...");
                error = EMAIL_ERROR_ACCOUNT_NOT_FOUND;
                goto FINISH_OFF;
        }
 
        /*  Assign query result to structure */
-       if (!(p_data_tbl = (emstorage_account_tbl_t *)malloc(sizeof(emstorage_account_tbl_t) * 1)))  {
+       if (!(p_data_tbl = (emstorage_account_tbl_t *)malloc(sizeof(emstorage_account_tbl_t) * 1))) {
                EM_DEBUG_EXCEPTION("malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -4303,14 +4266,14 @@ INTERNAL_FUNC int emstorage_get_account_by_id(char *multi_user_name, int account
                        goto FINISH_OFF;
                }
 
-               EM_DEBUG_LOG_DEV ("recv_password_file_name[%s], password[%s]", recv_password_file_name,  p_data_tbl->incoming_server_password);
+               EM_DEBUG_LOG_DEV("recv_password_file_name[%s], password[%s]", recv_password_file_name,  p_data_tbl->incoming_server_password);
 
                if (p_data_tbl->outgoing_server_use_same_authenticator == 0) {
                        if ((error = _read_password_from_secure_storage(send_password_file_name, &(p_data_tbl->outgoing_server_password))) < 0) {
                                EM_DEBUG_EXCEPTION(" _read_password_from_secure_storage failed [%d]", error);
                                goto FINISH_OFF;
                        }
-                       EM_DEBUG_LOG_DEV ("send_password_file_name[%s], password[%s]", send_password_file_name,  p_data_tbl->outgoing_server_password);
+                       EM_DEBUG_LOG_DEV("send_password_file_name[%s], password[%s]", send_password_file_name,  p_data_tbl->outgoing_server_password);
                }
        }
 
@@ -4353,9 +4316,9 @@ FINISH_OFF:
                if (p_data_tbl)
                        emstorage_free_account((emstorage_account_tbl_t **)&p_data_tbl, 1, NULL);
        }
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -4374,7 +4337,7 @@ INTERNAL_FUNC int emstorage_get_password_length_of_account(char *multi_user_name
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], password_length[%p], err_code[%p]", account_id, password_length, err_code);
 
-       if (account_id <= 0 || password_length == NULL)  {
+       if (account_id <= 0 || password_length == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -4436,7 +4399,7 @@ INTERNAL_FUNC int emstorage_update_account_password(char *multi_user_name, int i
        char recv_password_file_name[MAX_PW_FILE_NAME_LENGTH];
        char send_password_file_name[MAX_PW_FILE_NAME_LENGTH];
 
-       if(input_incoming_server_password == NULL && input_outgoing_server_password == NULL) {
+       if (input_incoming_server_password == NULL && input_outgoing_server_password == NULL) {
                EM_DEBUG_EXCEPTION_SEC("Invalid param");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -4492,7 +4455,7 @@ INTERNAL_FUNC int emstorage_update_account(char *multi_user_name, int account_id
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], account[%p], transaction[%d], err_code[%p]", account_id, account_tbl, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || !account_tbl)  {
+       if (account_id < FIRST_ACCOUNT_ID || !account_tbl) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -4580,7 +4543,7 @@ INTERNAL_FUNC int emstorage_update_account(char *multi_user_name, int account_id
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG("After sqlite3_prepare hStmt = %p", hStmt);
        EM_DEBUG_LOG_SEC("SQL[%s]", sql_query_string);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_prepare fail:(%d) %s", rc, sqlite3_errmsg(local_db_handle)));
 
        int i = 0;
@@ -4652,21 +4615,21 @@ INTERNAL_FUNC int emstorage_update_account(char *multi_user_name, int account_id
        _bind_stmt_field_data_int(hStmt, i++, account_id);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        /*  validate account existence */
        rc = sqlite3_changes(local_db_handle);
        if (rc == 0) {
-               EM_DEBUG_EXCEPTION ("no matched account found...");
+               EM_DEBUG_EXCEPTION("no matched account found...");
                error = EMAIL_ERROR_ACCOUNT_NOT_FOUND;
                goto FINISH_OFF;
        }
 
        if (account_tbl->incoming_server_password || account_tbl->outgoing_server_password) {
-               if((error = emstorage_update_account_password(multi_user_name, account_id, account_tbl->incoming_server_password, account_tbl->outgoing_server_password)) != EMAIL_ERROR_NONE) {
+               if ((error = emstorage_update_account_password(multi_user_name, account_id, account_tbl->incoming_server_password, account_tbl->outgoing_server_password)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emstorage_update_account_password failed [%d]", error);
                        goto FINISH_OFF;
                }
@@ -4677,16 +4640,16 @@ INTERNAL_FUNC int emstorage_update_account(char *multi_user_name, int account_id
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
 
        if (error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_UPDATE, account_tbl->account_id, 0, NULL, 0))
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_UPDATE, account_tbl->account_id, 0, NULL, 0))
                        EM_DEBUG_EXCEPTION(" emcore_notify_storage_event[ NOTI_ACCOUNT_UPDATE] : Notification Failed >>> ");
        }
 
@@ -4735,18 +4698,18 @@ FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, result, error);
 
        if (error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_UPDATE, account_id, 0, field_name, value))
-                       EM_DEBUG_EXCEPTION_SEC("emcore_notify_storage_event failed : NOTI_ACCOUNT_UPDATE [%s,%d]", field_name, value);
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_UPDATE, account_id, 0, field_name, value))
+                       EM_DEBUG_EXCEPTION_SEC("emcore_notify_storage_eventfailed : NOTI_ACCOUNT_UPDATE [%s,%d]", field_name, value);
        }
        EM_DEBUG_FUNC_END("error [%d]", error);
        return error;
 }
 
-INTERNAL_FUNC int emstorage_get_sync_status_of_account(char *multi_user_name, int account_id, int *result_sync_status,int *err_code)
+INTERNAL_FUNC int emstorage_get_sync_status_of_account(char *multi_user_name, int account_id, int *result_sync_status, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], result_sync_status [%p], err_code[%p]", account_id, result_sync_status, err_code);
 
-       if(!result_sync_status) {
+       if (!result_sync_status) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -4758,13 +4721,13 @@ INTERNAL_FUNC int emstorage_get_sync_status_of_account(char *multi_user_name, in
        char **result = NULL;
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
 
-       if(account_id)
+       if (account_id)
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT sync_status FROM mail_account_tbl WHERE account_id = %d", account_id);
        else
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT sync_status FROM mail_account_tbl");
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        if (!count) {
@@ -4776,7 +4739,7 @@ INTERNAL_FUNC int emstorage_get_sync_status_of_account(char *multi_user_name, in
        col_index = 1;
        *result_sync_status = 0;
 
-       for(i = 0; i < count; i++) {
+       for (i = 0; i < count; i++) {
                _get_table_field_data_int(result, &sync_status, col_index++);
                *result_sync_status |= sync_status;
        }
@@ -4805,18 +4768,18 @@ INTERNAL_FUNC int emstorage_update_sync_status_of_account(char *multi_user_name,
        char sql_query_string[QUERY_SIZE] = {0, };
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
 
-       if(set_operator != SET_TYPE_SET && account_id) {
-               if(!emstorage_get_sync_status_of_account(multi_user_name, account_id, &result_sync_status, &error)) {
+       if (set_operator != SET_TYPE_SET && account_id) {
+               if (!emstorage_get_sync_status_of_account(multi_user_name, account_id, &result_sync_status, &error)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_sync_status_of_account failed [%d]", error);
                        if (err_code != NULL)
                                *err_code = error;
                        return false;
                }
-               switch(set_operator) {
-                       case SET_TYPE_UNION :
+               switch (set_operator) {
+                       case SET_TYPE_UNION:
                                set_value = result_sync_status | set_value;
                                break;
-                       case SET_TYPE_MINUS :
+                       case SET_TYPE_MINUS:
                                set_value = result_sync_status & (~set_value);
                                break;
                        default:
@@ -4829,7 +4792,7 @@ INTERNAL_FUNC int emstorage_update_sync_status_of_account(char *multi_user_name,
 
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
 
-       if(account_id)
+       if (account_id)
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_account_tbl SET sync_status = %d WHERE account_id = %d", set_value, account_id);
        else
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_account_tbl SET sync_status = %d WHERE incoming_server_type <> 5", set_value);
@@ -4856,7 +4819,7 @@ FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
        if (error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_UPDATE_SYNC_STATUS, account_id, set_value, NULL, 0))
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_UPDATE_SYNC_STATUS, account_id, set_value, NULL, 0))
                        EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_UPDATE_SYNC_STATUS] : Notification failed");
        }
 
@@ -4871,7 +4834,7 @@ INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account
 {
        EM_DEBUG_FUNC_BEGIN("account[%p], transaction[%d], err_code[%p]", account_tbl, transaction, err_code);
 
-       if (!account_tbl)  {
+       if (!account_tbl) {
                EM_DEBUG_EXCEPTION("account[%p], transaction[%d], err_code[%p]", account_tbl, transaction, err_code);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -4896,7 +4859,7 @@ INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account
        char **result = NULL;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, &row_count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
        if (NULL == result[1]) rc = 1;
@@ -4999,7 +4962,7 @@ INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account
                ") ");
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        i = 0;
@@ -5074,9 +5037,9 @@ INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
 
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle)));
 
 
@@ -5099,16 +5062,16 @@ INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
 
        if (error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_ADD, account_tbl->account_id, 0, NULL, 0))
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_ADD, account_tbl->account_id, 0, NULL, 0))
                        EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_ADD] : Notification failed");
        }
 
@@ -5123,7 +5086,7 @@ INTERNAL_FUNC int emstorage_delete_account(char *multi_user_name, int account_id
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], transaction[%d], err_code[%p]", account_id, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID)  {
+       if (account_id < FIRST_ACCOUNT_ID) {
                EM_DEBUG_EXCEPTION(" account_id[%d]", account_id);
 
                if (err_code != NULL)
@@ -5160,7 +5123,7 @@ INTERNAL_FUNC int emstorage_delete_account(char *multi_user_name, int account_id
 
        /*  validate account existence */
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_EXCEPTION(" no matched account found...");
                error = EMAIL_ERROR_ACCOUNT_NOT_FOUND;
                goto FINISH_OFF;
@@ -5199,8 +5162,8 @@ INTERNAL_FUNC int emstorage_free_account(emstorage_account_tbl_t** account_list,
        int ret = false;
        int error = EMAIL_ERROR_NONE;
 
-       if (count > 0)  {
-               if (!account_list || !*account_list)  {
+       if (count > 0) {
+               if (!account_list || !*account_list) {
                        EM_DEBUG_EXCEPTION("account_list[%p], count[%d]", account_list, count);
                        error = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
@@ -5209,7 +5172,7 @@ INTERNAL_FUNC int emstorage_free_account(emstorage_account_tbl_t** account_list,
                emstorage_account_tbl_t* p = *account_list;
                int i = 0;
 
-               for (; i < count; i++)  {
+               for (; i < count; i++) {
                        EM_SAFE_FREE(p[i].account_name);
                        EM_SAFE_FREE(p[i].incoming_server_address);
                        EM_SAFE_FREE(p[i].user_email_address);
@@ -5248,7 +5211,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_count(char *multi_user_name, int account
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], count[%p], transaction[%d], err_code[%p]", account_id, local_yn, count, transaction, err_code);
 
-       if ((account_id < FIRST_ACCOUNT_ID) || (count == NULL))  {
+       if ((account_id < FIRST_ACCOUNT_ID) || (count == NULL)) {
                EM_DEBUG_EXCEPTION(" account_list[%d], local_yn[%d], count[%p]", account_id, local_yn, count);
 
                if (err_code != NULL)
@@ -5268,7 +5231,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_count(char *multi_user_name, int account
        char **result;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -5309,8 +5272,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_list(char *multi_user_name, int account_
        if (account_id == ALL_ACCOUNT) {
                if (local_yn == EMAIL_MAILBOX_FROM_SERVER || local_yn == EMAIL_MAILBOX_FROM_LOCAL)
                        SNPRINTF(conditional_clause_string + EM_SAFE_STRLEN(conditional_clause_string), sizeof(conditional_clause_string)-(EM_SAFE_STRLEN(conditional_clause_string)+1), " WHERE local_yn = %d ", local_yn);
-       }
-       else {
+       } else {
                SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d  ", account_id);
                if (local_yn == EMAIL_MAILBOX_FROM_SERVER || local_yn == EMAIL_MAILBOX_FROM_LOCAL)
                        SNPRINTF(conditional_clause_string + EM_SAFE_STRLEN(conditional_clause_string), sizeof(conditional_clause_string)-(EM_SAFE_STRLEN(conditional_clause_string)+1), " AND local_yn = %d ", local_yn);
@@ -5319,26 +5281,26 @@ INTERNAL_FUNC int emstorage_get_mailbox_list(char *multi_user_name, int account_
        EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string);
 
        switch (sort_type) {
-               case EMAIL_MAILBOX_SORT_BY_NAME_ASC :
+               case EMAIL_MAILBOX_SORT_BY_NAME_ASC:
                        SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_name ASC");
                        break;
 
-               case EMAIL_MAILBOX_SORT_BY_NAME_DSC :
+               case EMAIL_MAILBOX_SORT_BY_NAME_DSC:
                        SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_name DESC");
                        break;
 
-               case EMAIL_MAILBOX_SORT_BY_TYPE_ASC :
+               case EMAIL_MAILBOX_SORT_BY_TYPE_ASC:
                        SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_type ASC");
                        break;
 
-               case EMAIL_MAILBOX_SORT_BY_TYPE_DSC :
+               case EMAIL_MAILBOX_SORT_BY_TYPE_DSC:
                        SNPRINTF(ordering_clause_string, QUERY_SIZE, " ORDER BY mailbox_type DEC");
                        break;
        }
 
        EM_DEBUG_LOG("ordering_clause_string[%s]", ordering_clause_string);
 
-       if(error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, ordering_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+       if ((error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, ordering_clause_string, 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
                goto FINISH_OFF;
        }
@@ -5379,8 +5341,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_list_ex(char *multi_user_name, int accou
                if (where_clause_count == 0) {
                        SNPRINTF(conditional_clause_string + EM_SAFE_STRLEN(conditional_clause_string), sizeof(conditional_clause_string)-(EM_SAFE_STRLEN(conditional_clause_string)+1), " WHERE ");
                        SNPRINTF(conditional_clause_string + EM_SAFE_STRLEN(conditional_clause_string), sizeof(conditional_clause_string)-(EM_SAFE_STRLEN(conditional_clause_string)+1), " account_id = %d ", account_id);
-               }
-               else
+               } else
                        SNPRINTF(conditional_clause_string + EM_SAFE_STRLEN(conditional_clause_string), sizeof(conditional_clause_string)-(EM_SAFE_STRLEN(conditional_clause_string)+1), " AND account_id = %d ", account_id);
        }
 
@@ -5415,7 +5376,7 @@ INTERNAL_FUNC int emstorage_get_child_mailbox_list(char *multi_user_name, int ac
        int error = EMAIL_ERROR_NONE;
        char conditional_clause_string[QUERY_SIZE] = {0, };
 
-       if (account_id < FIRST_ACCOUNT_ID || !select_num || !mailbox_list || !parent_mailbox_name)  {
+       if (account_id < FIRST_ACCOUNT_ID || !select_num || !mailbox_list || !parent_mailbox_name) {
                EM_DEBUG_EXCEPTION("account_id[%d], parent_mailbox_name[%p], select_num[%p], mailbox_list[%p]", account_id, parent_mailbox_name, select_num, mailbox_list);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -5425,7 +5386,7 @@ INTERNAL_FUNC int emstorage_get_child_mailbox_list(char *multi_user_name, int ac
        sqlite3_snprintf(sizeof(conditional_clause_string), conditional_clause_string, "WHERE account_id = %d  AND UPPER(mailbox_name) LIKE UPPER('%q%%')", account_id, parent_mailbox_name);
        EM_DEBUG_LOG("conditional_clause_string[%s]", conditional_clause_string);
 
-       if(error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, " ORDER BY mailbox_name DESC ", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+       if ((error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, " ORDER BY mailbox_name DESC ", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
                goto FINISH_OFF;
        }
@@ -5444,7 +5405,7 @@ FINISH_OFF:
 INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(char *multi_user_name, int account_id, int local_yn, int *select_num, emstorage_mailbox_tbl_t** mailbox_list, int transaction, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], select_num[%p], mailbox_list[%p], transaction[%d], err_code[%p]", account_id, local_yn, select_num, mailbox_list, transaction, err_code);
-       if (account_id < FIRST_ACCOUNT_ID || !select_num || !mailbox_list)  {
+       if (account_id < FIRST_ACCOUNT_ID || !select_num || !mailbox_list) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
 
                if (err_code != NULL)
@@ -5460,7 +5421,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(char *multi_user_name,
        SNPRINTF(conditional_clause_string, sizeof(conditional_clause_string), "WHERE account_id = %d AND modifiable_yn = 0", account_id);
        EM_DEBUG_LOG("conditional_clause_string [%s]", conditional_clause_string);
 
-       if(error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, " ORDER BY mailbox_name", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
+       if ((error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, " ORDER BY mailbox_name", 0, transaction, mailbox_list, select_num)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
                goto FINISH_OFF;
        }
@@ -5486,7 +5447,7 @@ INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(char *multi_user_nam
        char     sql_query_string[QUERY_SIZE] = {0, };
        sqlite3 *local_db_handle = NULL;
 
-       if (!input_mailbox_id )  {
+       if (!input_mailbox_id) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -5512,7 +5473,7 @@ INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(char *multi_user_nam
 
 FINISH_OFF:
 
-       if(error == EMAIL_ERROR_NONE)
+       if (error == EMAIL_ERROR_NONE)
                result_code = true;
 
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, input_transaction, result_code, error);
@@ -5526,7 +5487,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_name(char *multi_user_name, int accou
        EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], local_yn[%d], mailbox_name[%s], result_mailbox[%p], transaction[%d], err_code[%p]", account_id, local_yn, mailbox_name, result_mailbox, transaction, err_code);
        EM_PROFILE_BEGIN(profile_emstorage_get_mailbox_by_name);
 
-       if (account_id < FIRST_ACCOUNT_ID || !mailbox_name || !result_mailbox)  {
+       if (account_id < FIRST_ACCOUNT_ID || !mailbox_name || !result_mailbox) {
                EM_DEBUG_EXCEPTION_SEC(" account_id[%d], local_yn[%d], mailbox_name[%s], result_mailbox[%p]", account_id, local_yn, mailbox_name, result_mailbox);
 
                if (err_code != NULL)
@@ -5539,8 +5500,8 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_name(char *multi_user_name, int accou
        int result_count = 0;
        char conditional_clause_string[QUERY_SIZE] = {0, };
 
-       if(strcmp(mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) == 0) {
-               if (!(*result_mailbox = (emstorage_mailbox_tbl_t*)em_malloc(sizeof(emstorage_mailbox_tbl_t))))  {
+       if (strcmp(mailbox_name, EMAIL_SEARCH_RESULT_MAILBOX_NAME) == 0) {
+               if (!(*result_mailbox = (emstorage_mailbox_tbl_t*)em_malloc(sizeof(emstorage_mailbox_tbl_t)))) {
                        EM_DEBUG_EXCEPTION("malloc failed...");
                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -5558,9 +5519,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_name(char *multi_user_name, int accou
                (*result_mailbox)->has_archived_mails         = 0;
                (*result_mailbox)->mail_slot_size             = 0x0FFFFFFF;
                (*result_mailbox)->no_select                  = 0;
-       }
-       else {
-
+       } else {
                if (local_yn == -1)
                        sqlite3_snprintf(sizeof(conditional_clause_string), conditional_clause_string, "WHERE account_id = %d AND mailbox_name = '%q'", account_id, mailbox_name);
                else
@@ -5568,7 +5527,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_name(char *multi_user_name, int accou
 
                EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
 
-               if(error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", 0, transaction, result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+               if ((error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", 0, transaction, result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl failed [%d]", error);
                        goto FINISH_OFF;
                }
@@ -5608,7 +5567,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(char *multi_user_name, i
 
        EM_DEBUG_LOG("conditional_clause_string = [%s]", conditional_clause_string);
 
-       if(error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", true, false, &result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
+       if ((error = emstorage_query_mailbox_tbl(multi_user_name, conditional_clause_string, "", true, false, &result_mailbox, &result_count)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_query_mailbox_tbl error [%d]", error);
                goto FINISH_OFF;
        }
@@ -5630,7 +5589,7 @@ INTERNAL_FUNC int emstorage_get_mailbox_by_id(char *multi_user_name, int input_m
 {
        EM_DEBUG_FUNC_BEGIN("input_mailbox_id[%d], output_mailbox[%p]", input_mailbox_id, output_mailbox);
 
-       if (input_mailbox_id <= 0 || !output_mailbox)  {
+       if (input_mailbox_id <= 0 || !output_mailbox) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM: input_mailbox_id[%d] output_mailbox[%p]", input_mailbox_id, output_mailbox);
                return  EMAIL_ERROR_INVALID_PARAM;
        }
@@ -5700,7 +5659,7 @@ FINISH_OFF:
 INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, int *mailbox_id, int transaction, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_type[%d], mailbox_id[%p], transaction[%d], err_code[%p]", account_id, mailbox_type, mailbox_id, transaction, err_code);
-       if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_id)  {
+       if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_id) {
                EM_DEBUG_EXCEPTION("account_id[%d], mailbox_type[%d], mailbox_id[%p]", account_id, mailbox_type, mailbox_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -5732,12 +5691,12 @@ INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(char *multi_user_name
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (rc == SQLITE_DONE) {
@@ -5752,10 +5711,10 @@ INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(char *multi_user_name
 
 FINISH_OFF:
        EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -5770,7 +5729,7 @@ FINISH_OFF:
 INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, char **mailbox_name, int transaction, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_type[%d], mailbox_name[%p], transaction[%d], err_code[%p]", account_id, mailbox_type, mailbox_name, transaction, err_code);
-       if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_name)  {
+       if (account_id < FIRST_ACCOUNT_ID || (mailbox_type < EMAIL_MAILBOX_TYPE_INBOX || mailbox_type > EMAIL_MAILBOX_TYPE_ALL_EMAILS) || !mailbox_name) {
                EM_DEBUG_EXCEPTION("account_id[%d], mailbox_type[%d], mailbox_name[%p]", account_id, mailbox_type, mailbox_name);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -5802,12 +5761,12 @@ INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(char *multi_user_na
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (rc == SQLITE_DONE) {
@@ -5821,10 +5780,10 @@ INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(char *multi_user_na
        ret = true;
 
 FINISH_OFF:
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -5905,7 +5864,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_total_count(char *multi_user_name,
        int error = EMAIL_ERROR_NONE;
        char sql_query_string[QUERY_SIZE] = {0, };
 
-       if (account_id <= 0 || input_mailbox_id <= 0)  {
+       if (account_id <= 0 || input_mailbox_id <= 0) {
                EM_DEBUG_EXCEPTION("account_id[%d], input_mailbox_id[%d]", account_id, input_mailbox_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -5951,7 +5910,7 @@ INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], input_mailbox_id[%d], result_mailbox[%p], transaction[%d], err_code[%p]", account_id, local_yn, input_mailbox_id, result_mailbox, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || input_mailbox_id <= 0 || !result_mailbox)  {
+       if (account_id < FIRST_ACCOUNT_ID || input_mailbox_id <= 0 || !result_mailbox) {
                EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], input_mailbox_id[%d], result_mailbox[%p]", account_id, local_yn, input_mailbox_id, result_mailbox);
 
                if (err_code != NULL)
@@ -5986,8 +5945,7 @@ INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id
                        , account_id
                        , local_yn
                        , input_mailbox_id);
-       }
-       else {
+       } else {
                SNPRINTF(sql_query_string, sizeof(sql_query_string),
                        "UPDATE mail_box_tbl SET"
                        "  mailbox_id = ?"
@@ -6007,7 +5965,7 @@ INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        _bind_stmt_field_data_int(hStmt, i++, result_mailbox->mailbox_id);
@@ -6021,9 +5979,9 @@ INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        ret = true;
@@ -6031,10 +5989,10 @@ INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -6050,7 +6008,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int accou
 {
        EM_DEBUG_FUNC_BEGIN_SEC("account_id[%d], local_yn[%d], input_mailbox_id[%d], new_mailbox_type[%d], transaction[%d], err_code[%p]", account_id, local_yn, input_mailbox_id, new_mailbox_type, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID)  {
+       if (account_id < FIRST_ACCOUNT_ID) {
                EM_DEBUG_EXCEPTION_SEC(" account_id[%d], local_yn[%d], input_mailbox_id[%d]", account_id, local_yn, input_mailbox_id);
 
                if (err_code != NULL)
@@ -6082,8 +6040,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int accou
                        , account_id
                        , local_yn
                        , input_mailbox_id);
-       }
-       else {
+       } else {
                SNPRINTF(sql_query_string, sizeof(sql_query_string)-1,
                        "UPDATE mail_box_tbl SET"
                        " mailbox_type = ?"
@@ -6097,7 +6054,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int accou
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt_box_tbl, NULL), rc);
 
-       if(SQLITE_OK != rc) {
+       if (SQLITE_OK != rc) {
                EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle));
                error = EMAIL_ERROR_DB_FAILURE;
                goto FINISH_OFF;
@@ -6108,13 +6065,13 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int accou
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt_box_tbl), rc);
 
-       if(rc == SQLITE_FULL) {
+       if (rc == SQLITE_FULL) {
                EM_DEBUG_EXCEPTION("sqlite3_step fail:%d", rc);
                error   = EMAIL_ERROR_MAIL_MEMORY_FULL;
                goto FINISH_OFF;
        }
 
-       if(rc != SQLITE_ROW && rc != SQLITE_DONE) {
+       if (rc != SQLITE_ROW && rc != SQLITE_DONE) {
                EM_DEBUG_EXCEPTION("sqlite3_step fail:%d", rc);
                error = EMAIL_ERROR_DB_FAILURE;
                goto FINISH_OFF;
@@ -6134,7 +6091,7 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int accou
        EM_DEBUG_LOG_SEC("SQL[%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt_mail_tbl, NULL), rc);
-       if(SQLITE_OK != rc) {
+       if (SQLITE_OK != rc) {
                EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle));
                error = EMAIL_ERROR_DB_FAILURE;
                goto FINISH_OFF;
@@ -6143,13 +6100,13 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int accou
        _bind_stmt_field_data_int(hStmt_mail_tbl, i++, new_mailbox_type);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt_mail_tbl), rc);
-       if(rc == SQLITE_FULL) {
+       if (rc == SQLITE_FULL) {
                EM_DEBUG_EXCEPTION("sqlite3_step fail:%d", rc);
                error = EMAIL_ERROR_MAIL_MEMORY_FULL;
                goto FINISH_OFF;
        }
 
-       if(rc != SQLITE_ROW && rc != SQLITE_DONE){
+       if (rc != SQLITE_ROW && rc != SQLITE_DONE) {
                EM_DEBUG_EXCEPTION("sqlite3_step fail:%d", rc);
                error = EMAIL_ERROR_DB_FAILURE;
                goto FINISH_OFF;
@@ -6160,18 +6117,18 @@ INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int accou
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt_box_tbl != NULL)  {
+       if (hStmt_box_tbl != NULL) {
                rc = sqlite3_finalize(hStmt_box_tbl);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
 
-       if (hStmt_mail_tbl != NULL)  {
+       if (hStmt_mail_tbl != NULL) {
                rc = sqlite3_finalize(hStmt_mail_tbl);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -6191,7 +6148,7 @@ INTERNAL_FUNC int emstorage_set_local_mailbox(char *multi_user_name, int input_m
        int error = EMAIL_ERROR_NONE;
        char sql_query_string[QUERY_SIZE] = {0, };
 
-       if (input_mailbox_id < 0)  {
+       if (input_mailbox_id < 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -6215,21 +6172,21 @@ INTERNAL_FUNC int emstorage_set_local_mailbox(char *multi_user_name, int input_m
        EM_DEBUG_LOG_SEC("SQL(%s)", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        _bind_stmt_field_data_int(hStmt, i++, input_is_local_mailbox);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 /*
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
                hStmt = NULL;
@@ -6240,10 +6197,10 @@ INTERNAL_FUNC int emstorage_set_local_mailbox(char *multi_user_name, int input_m
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -6277,23 +6234,23 @@ INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(char *multi_
 
        mailbox_id_string_buffer = em_malloc(mailbox_id_string_buffer_length);
 
-       if(!mailbox_id_string_buffer) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+       if (!mailbox_id_string_buffer) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < input_mailbox_id_count; i++)
+       for (i = 0; i < input_mailbox_id_count; i++)
                cur_mailbox_id_string += SNPRINTF_OFFSET(mailbox_id_string_buffer, cur_mailbox_id_string, mailbox_id_string_buffer_length, "%d,", input_mailbox_id_array[i]);
 
-       if(EM_SAFE_STRLEN(mailbox_id_string_buffer) > 1)
+       if (EM_SAFE_STRLEN(mailbox_id_string_buffer) > 1)
                mailbox_id_string_buffer[EM_SAFE_STRLEN(mailbox_id_string_buffer) - 1] = NULL_CHAR;
 
        /* Generating notification parameter string */
        parameter_string = em_malloc(mailbox_id_string_buffer_length + EM_SAFE_STRLEN(input_field_name) + 2);
 
-       if(!parameter_string) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+       if (!parameter_string) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -6322,8 +6279,8 @@ FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, result, err);
 
        if (err == EMAIL_ERROR_NONE && parameter_string) {
-               if (!emcore_notify_storage_event (NOTI_MAILBOX_FIELD_UPDATE, input_account_id, 0, parameter_string, input_value))
-                       EM_DEBUG_EXCEPTION_SEC ("emcore_notify_storage_event failed : NOTI_MAILBOX_FIELD_UPDATE [%s,%d]",
+               if (!emcore_notify_storage_event(NOTI_MAILBOX_FIELD_UPDATE, input_account_id, 0, parameter_string, input_value))
+                       EM_DEBUG_EXCEPTION_SEC("emcore_notify_storage_eventfailed : NOTI_MAILBOX_FIELD_UPDATE [%s,%d]",
                                                                                          input_field_name, input_value);
        }
 
@@ -6338,7 +6295,7 @@ INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox
 {
        EM_DEBUG_FUNC_BEGIN("mailbox_tbl[%p], transaction[%d], err_code[%p]", mailbox_tbl, transaction, err_code);
 
-       if (!mailbox_tbl)  {
+       if (!mailbox_tbl) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -6356,7 +6313,7 @@ INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox
        EM_SAFE_STRCPY(sql_query_string, "SELECT max(rowid) FROM mail_box_tbl;");
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        time(&current_time);
@@ -6373,7 +6330,7 @@ INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_box_tbl VALUES "
-               "( ?"    /* mailbox_id */
+               "(?"    /* mailbox_id */
                ", ?"    /* account_id */
                ", ?"    /* local_yn */
                ", ?"    /* mailbox_name */
@@ -6392,8 +6349,8 @@ INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_LOG_DEV ("After sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_LOG_DEV("After sqlite3_prepare hStmt = %p", hStmt);
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        int col_index = 0;
@@ -6416,25 +6373,25 @@ INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%dn", rc));
 
        ret = true;
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
 
        if (error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_MAILBOX_ADD, mailbox_tbl->account_id, mailbox_tbl->mailbox_id,
+               if (!emcore_notify_storage_event(NOTI_MAILBOX_ADD, mailbox_tbl->account_id, mailbox_tbl->mailbox_id,
                                                                   mailbox_tbl->mailbox_name, mailbox_tbl->mailbox_type))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event[ NOTI_MAILBOX_ADD] : Notification Failed");
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event[ NOTI_MAILBOX_ADD] : Notification Failed");
        }
 
        if (err_code != NULL)
@@ -6448,7 +6405,7 @@ INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(char *multi_user_name,
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], modifiable_yn[%d], err_code[%p]", account_id, modifiable_yn, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID)  {
+       if (account_id < FIRST_ACCOUNT_ID) {
 
                EM_DEBUG_EXCEPTION("account_id[%d]", account_id);
 
@@ -6493,7 +6450,7 @@ INTERNAL_FUNC int emstorage_delete_mailbox(char *multi_user_name, int account_id
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], local_yn[%d], input_mailbox_id[%d], transaction[%d], err_code[%p]", account_id, local_yn, input_mailbox_id, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID)  {
+       if (account_id < FIRST_ACCOUNT_ID) {
                EM_DEBUG_EXCEPTION(" account_id[%d], local_yn[%d], input_mailbox_id[%d]", account_id, local_yn, input_mailbox_id);
 
                if (err_code != NULL)
@@ -6512,8 +6469,8 @@ INTERNAL_FUNC int emstorage_delete_mailbox(char *multi_user_name, int account_id
        else
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "DELETE FROM mail_box_tbl WHERE account_id = %d AND local_yn = %d ", account_id, local_yn);
 
-       if (input_mailbox_id > 0)  {            /* 0 means all mailbox */
-               SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(1+ EM_SAFE_STRLEN(sql_query_string)), "AND mailbox_id = %d", input_mailbox_id);
+       if (input_mailbox_id > 0)             /* 0 means all mailbox */
+               SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(1 + EM_SAFE_STRLEN(sql_query_string)), "AND mailbox_id = %d", input_mailbox_id);
        }
 
        EM_DEBUG_LOG_SEC("mailbox sql_query_string [%s]", sql_query_string);
@@ -6524,7 +6481,7 @@ INTERNAL_FUNC int emstorage_delete_mailbox(char *multi_user_name, int account_id
        }
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_EXCEPTION(" no (matched) mailbox_name found...");
                error = EMAIL_ERROR_MAILBOX_NOT_FOUND;
                ret = true;
@@ -6535,9 +6492,9 @@ FINISH_OFF:
 
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if(error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_MAILBOX_DELETE, account_id, input_mailbox_id, NULL, 0))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event[ NOTI_MAILBOX_ADD] : Notification Failed");
+       if (error == EMAIL_ERROR_NONE) {
+               if (!emcore_notify_storage_event(NOTI_MAILBOX_DELETE, account_id, input_mailbox_id, NULL, 0))
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_event[ NOTI_MAILBOX_ADD] : Notification Failed");
        }
 
        if (err_code != NULL)
@@ -6554,8 +6511,8 @@ INTERNAL_FUNC int emstorage_free_mailbox(emstorage_mailbox_tbl_t** mailbox_list,
        int ret = false;
        int error = EMAIL_ERROR_NONE;
 
-       if (count > 0)  {
-               if (!mailbox_list || !*mailbox_list)  {
+       if (count > 0) {
+               if (!mailbox_list || !*mailbox_list) {
                        EM_DEBUG_EXCEPTION(" mailbox_list[%p], count[%d]", mailbox_list, count);
 
                        error = EMAIL_ERROR_INVALID_PARAM;
@@ -6588,7 +6545,7 @@ INTERNAL_FUNC int emstorage_get_count_read_mail_uid(char *multi_user_name, int a
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], count[%p], transaction[%d], err_code[%p]", account_id, mailbox_name , count,  transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || !mailbox_name || !count)  {
+       if (account_id < FIRST_ACCOUNT_ID || !mailbox_name || !count) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_name[%p], count[%p], exist[%p]", account_id, mailbox_name, count);
 
                if (err_code != NULL)
@@ -6618,7 +6575,7 @@ INTERNAL_FUNC int emstorage_get_count_read_mail_uid(char *multi_user_name, int a
        char **result;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -6642,7 +6599,7 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(char *multi_user_name, int accou
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], uid[%p], exist[%p], transaction[%d], err_code[%p]", account_id, mailbox_name , uid, exist, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || !uid || !exist)  {
+       if (account_id < FIRST_ACCOUNT_ID || !uid || !exist) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_name[%p], uid[%p], exist[%p]", account_id, mailbox_name , uid, exist);
 
                if (err_code != NULL)
@@ -6660,7 +6617,7 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(char *multi_user_name, int accou
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
-       if (mailbox_name)  {
+       if (mailbox_name) {
                if (strstr(mailbox_name, "'")) {
                        replaced_mailbox_name = em_replace_all_string(mailbox_name, "'", "''");
                } else {
@@ -6668,15 +6625,14 @@ INTERNAL_FUNC int emstorage_check_read_mail_uid(char *multi_user_name, int accou
                }
 
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_read_mail_uid_tbl WHERE account_id = %d AND mailbox_name = '%s' AND server_uid = '%s' ", account_id, replaced_mailbox_name, uid);
-       }
-       else  {
+       } else {
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_read_mail_uid_tbl WHERE account_id = %d AND server_uid = '%s' ", account_id, uid);
        }
 
        char **result = NULL;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *exist = atoi(result[1]);
@@ -6725,12 +6681,12 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail(char *multi_user_name, int mail_
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt);
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        *mail = (emstorage_mail_tbl_t*)malloc(sizeof(emstorage_mail_tbl_t));
@@ -6756,10 +6712,10 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail(char *multi_user_name, int mail_
 
 FINISH_OFF:
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -6777,7 +6733,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(char *multi_user_name, int accou
 {
        EM_PROFILE_BEGIN(emStorageGetDownloadList);
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], read_mail_uid[%p], count[%p], transaction[%d], err_code[%p]", account_id, mailbox_id, read_mail_uid, count, transaction, err_code);
-       if (account_id < FIRST_ACCOUNT_ID || !read_mail_uid || !count)  {
+       if (account_id < FIRST_ACCOUNT_ID || !read_mail_uid || !count) {
                EM_DEBUG_EXCEPTION_SEC(" account_id[%d], mailbox_id[%s], read_mail_uid[%p], count[%p]", account_id, mailbox_id, read_mail_uid, count);
 
                if (err_code != NULL)
@@ -6808,39 +6764,39 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(char *multi_user_name, int accou
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        char **result;
        /*  rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, count, NULL, NULL); */
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        sqlite3_free_table(result);
-       if (*count == 0)  {
+       if (*count == 0) {
                EM_DEBUG_LOG("No mail found in mail_read_mail_uid_tbl");
                ret = true;
                goto FINISH_OFF;
        }
 
 
-       if (!(p_data_tbl = (emstorage_read_mail_uid_tbl_t*)malloc(sizeof(emstorage_read_mail_uid_tbl_t) * *count)))  {
+       if (!(p_data_tbl = (emstorage_read_mail_uid_tbl_t*)malloc(sizeof(emstorage_read_mail_uid_tbl_t) * *count))) {
                EM_DEBUG_EXCEPTION(" malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       memset(p_data_tbl, 0x00, sizeof(emstorage_read_mail_uid_tbl_t)* *count);
+       memset(p_data_tbl, 0x00, sizeof(emstorage_read_mail_uid_tbl_t)*(*count));
 
-       for (i = 0; i < *count; ++i)  {
+       for (i = 0; i < *count; ++i) {
                _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].account_id), ACCOUNT_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL);
-               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].mailbox_id),LOCAL_MAILBOX_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].mailbox_id), LOCAL_MAILBOX_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL);
                _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].mailbox_name), 0, MAILBOX_NAME_IDX_IN_MAIL_READ_MAIL_UID_TBL);
                _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].local_uid), LOCAL_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL);
                _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].server_uid), 0, SERVER_UID_IDX_IN_MAIL_READ_MAIL_UID_TBL);
@@ -6849,7 +6805,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_list(char *multi_user_name, int accou
                _get_stmt_field_data_char(hStmt, &(p_data_tbl[i].flags_flagged_field), FLAGS_FLAGGED_FIELD_IDX_IN_MAIL_READ_MAIL_UID_TBL);
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
        }
 
@@ -6861,10 +6817,10 @@ FINISH_OFF:
        else if (p_data_tbl)
                emstorage_free_read_mail_uid(&p_data_tbl, *count, NULL);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -6883,7 +6839,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail_size(char *multi_user_name, int
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%p], locacal_uid[%d], mailbox_name[%p], uid[%p], mail_size[%p], transaction[%d], err_code[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, mail_size, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || !mail_size)  {
+       if (account_id < FIRST_ACCOUNT_ID || !mail_size) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_id[%p], locacal_uid[%d], mailbox_name[%p], uid[%p], mail_size[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, mail_size);
 
                if (err_code != NULL)
@@ -6917,8 +6873,7 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail_size(char *multi_user_name, int
                        "AND mailbox_name = '%s' "
                        "AND server_uid = '%s'",
                        account_id, mailbox_id, local_uid, replaced_mailbox_name, uid);
-       }
-       else {
+       } else {
                SNPRINTF(sql_query_string, sizeof(sql_query_string),
                        "SELECT IFNULL(MAX(data1), 0) FROM mail_read_mail_uid_tbl "
                        "WHERE account_id = %d "
@@ -6930,12 +6885,12 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail_size(char *multi_user_name, int
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (rc == SQLITE_DONE) {
@@ -6951,10 +6906,10 @@ INTERNAL_FUNC int emstorage_get_downloaded_mail_size(char *multi_user_name, int
 FINISH_OFF:
        EM_SAFE_FREE(replaced_mailbox_name);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -6972,7 +6927,7 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage
 {
        EM_DEBUG_FUNC_BEGIN("read_mail_uid[%p], transaction[%d], err_code[%p]", read_mail_uid, transaction, err_code);
 
-       if (!read_mail_uid)  {
+       if (!read_mail_uid) {
                EM_DEBUG_EXCEPTION("read_mail_uid[%p]", read_mail_uid);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -6992,16 +6947,16 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
-       if (NULL==result[1]) rc = 1;
+       if (NULL == result[1]) rc = 1;
        else rc = atoi(result[1])+1;
        sqlite3_free_table(result);
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_read_mail_uid_tbl VALUES "
-               "( ?"  /* account_id */
+               "(?"  /* account_id */
                ", ?"  /* mailbox_id */
                ", ?"  /* mailbox_name */
                ", ?"  /* local_uid */
@@ -7010,11 +6965,11 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage
                ", ?"  /* sync_status */
                ", ?"  /* flags_seen_field */
                ", ?"  /* flags_flagged_field */
-               ", ? )");
+               ", ?)");
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc2);
-       if (rc2 != SQLITE_OK)  {
+       if (rc2 != SQLITE_OK) {
                EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt);
                EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle));
 
@@ -7024,7 +6979,7 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage
 
        EM_DEBUG_LOG("account_id[%d] mailbox_id[%d] local_uid [%d]"
                    "server_uid[%s] rfc822_size[%d] rc[%d]",
-         read_mail_uid->account_id, read_mail_uid->mailbox_id,read_mail_uid->local_uid,
+         read_mail_uid->account_id, read_mail_uid->mailbox_id, read_mail_uid->local_uid,
          read_mail_uid->server_uid, read_mail_uid->rfc822_size, rc);
 
        _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_READ_MAIL_UID_TBL, read_mail_uid->account_id);
@@ -7039,9 +6994,9 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail[%d] [%s]", rc, sqlite3_errmsg(local_db_handle)));
 
 
@@ -7049,10 +7004,10 @@ INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7094,13 +7049,13 @@ INTERNAL_FUNC int emstorage_add_mail_text(char *multi_user_name, emstorage_mail_
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_text_tbl VALUES "
-               "( ?"
+               "(?"
                ", ?"
                ", ?"
-               ", ? )");
+               ", ?)");
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc2);
-       if (rc2 != SQLITE_OK)  {
+       if (rc2 != SQLITE_OK) {
                EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt);
                EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc2, sqlite3_errmsg(local_db_handle));
 
@@ -7108,9 +7063,9 @@ INTERNAL_FUNC int emstorage_add_mail_text(char *multi_user_name, emstorage_mail_
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG ("mail_id[%d] account_id[%d] mailbox_id[%d]", mail_text->mail_id,
+       EM_DEBUG_LOG("mail_id[%d] account_id[%d] mailbox_id[%d]", mail_text->mail_id,
                                        mail_text->account_id, mail_text->mailbox_id);
-       EM_DEBUG_LOG_DEV ("body_text VALUE [%s] ", mail_text->body_text);
+       EM_DEBUG_LOG_DEV("body_text VALUE [%s] ", mail_text->body_text);
 
        _bind_stmt_field_data_int(hStmt, MAIL_ID_IDX_IN_MAIL_TEXT_TBL, mail_text->mail_id);
        _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_TEXT_TBL, mail_text->account_id);
@@ -7129,8 +7084,8 @@ FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
        if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7147,7 +7102,7 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(char *multi_user_name, int acco
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_id[%d], local_uid[%d], mailbox_name[%p], uid[%p], read_mail_uid[%p], transaction[%d], err_code[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, read_mail_uid, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || !read_mail_uid)  {
+       if (account_id < FIRST_ACCOUNT_ID || !read_mail_uid) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mailbox_id[%d], local_uid[%d], mailbox_name[%p], uid[%p], read_mail_uid[%p]", account_id, mailbox_id, local_uid, mailbox_name, uid, read_mail_uid);
 
                if (err_code != NULL)
@@ -7183,7 +7138,7 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(char *multi_user_name, int acco
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
@@ -7205,17 +7160,17 @@ INTERNAL_FUNC int emstorage_change_read_mail_uid(char *multi_user_name, int acco
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        ret = true;
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7239,7 +7194,7 @@ INTERNAL_FUNC int emstorage_remove_downloaded_mail(char *multi_user_name,
                                                        "uid[%s], transaction[%d], err_code[%p]",
                                                        account_id, mailbox_id, mailbox_name, uid, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID)  {
+       if (account_id < FIRST_ACCOUNT_ID) {
                EM_DEBUG_EXCEPTION_SEC(" account_id[%d], mailbox_name[%s], uid[%s]", account_id, mailbox_name, uid);
 
                if (err_code != NULL)
@@ -7309,8 +7264,8 @@ INTERNAL_FUNC int emstorage_free_read_mail_uid(emstorage_read_mail_uid_tbl_t** r
        int ret = false;
        int error = EMAIL_ERROR_NONE;
 
-       if (count > 0)  {
-               if (!read_mail_uid || !*read_mail_uid)  {
+       if (count > 0) {
+               if (!read_mail_uid || !*read_mail_uid) {
                        EM_DEBUG_EXCEPTION(" read_mail_uid[%p], count[%d]", read_mail_uid, count);
 
                        error = EMAIL_ERROR_INVALID_PARAM;
@@ -7320,7 +7275,7 @@ INTERNAL_FUNC int emstorage_free_read_mail_uid(emstorage_read_mail_uid_tbl_t** r
                emstorage_read_mail_uid_tbl_t* p = *read_mail_uid;
                int i;
 
-               for (i = 0; i < count; i++)  {
+               for (i = 0; i < count; i++) {
                        EM_SAFE_FREE(p[i].mailbox_name);
                        EM_SAFE_FREE(p[i].server_uid);
                }
@@ -7365,7 +7320,7 @@ INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(char *multi_user_name,
        char **result;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -7422,24 +7377,24 @@ INTERNAL_FUNC int emstorage_get_rule(char *multi_user_name, int account_id, int
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 /*     EM_DEBUG_LOG("sqlite3_prepare hStmt = %p", hStmt); */
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        char **result;
        /*  rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL); */
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        sqlite3_free_table(result);
 
-       if (count == 0)  {
-               EM_DEBUG_LOG_DEV ("No matching rule found...");
+       if (count == 0) {
+               EM_DEBUG_LOG_DEV("No matching rule found...");
                ret = true;
                error = EMAIL_ERROR_FILTER_NOT_FOUND; /*there is no matched rule*/
                goto FINISH_OFF;
@@ -7455,7 +7410,7 @@ INTERNAL_FUNC int emstorage_get_rule(char *multi_user_name, int account_id, int
 
        memset(p_data_tbl, 0x00, sizeof(emstorage_rule_tbl_t) * count);
 
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].account_id), ACCOUNT_ID_IDX_IN_MAIL_RULE_TBL);
                _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].rule_id), RULE_ID_IDX_IN_MAIL_RULE_TBL);
                _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].filter_name), 0, FILTER_NAME_IDX_IN_MAIL_RULE_TBL);
@@ -7468,7 +7423,7 @@ INTERNAL_FUNC int emstorage_get_rule(char *multi_user_name, int account_id, int
                _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].flag2), FLAG2_IDX_IN_MAIL_RULE_TBL);
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
        }
 
@@ -7478,17 +7433,16 @@ FINISH_OFF:
 
        EM_DEBUG_LOG("[%d] rules found.", count);
 
-       if (ret == true)  {
+       if (ret == true) {
                *rule_list = p_data_tbl;
                *select_num = count;
-       }
-       else if (p_data_tbl != NULL)
+       } else if (p_data_tbl != NULL)
                emstorage_free_rule(&p_data_tbl, count, NULL); /* CID FIX */
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7531,21 +7485,21 @@ INTERNAL_FUNC int emstorage_get_rule_by_id(char *multi_user_name, int rule_id, e
        SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_rule_tbl WHERE rule_id = %d", rule_id);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
-       if (rc == SQLITE_DONE)  {
+       if (rc == SQLITE_DONE) {
                EM_DEBUG_EXCEPTION(" no matched rule found...");
                error = EMAIL_ERROR_FILTER_NOT_FOUND;
                goto FINISH_OFF;
        }
 
-       if (!(p_data_tbl = (emstorage_rule_tbl_t*)malloc(sizeof(emstorage_rule_tbl_t))))  {
+       if (!(p_data_tbl = (emstorage_rule_tbl_t*)malloc(sizeof(emstorage_rule_tbl_t)))) {
                EM_DEBUG_EXCEPTION(" malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -7570,10 +7524,10 @@ FINISH_OFF:
        if (ret == true)
                *rule = p_data_tbl;
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7625,7 +7579,7 @@ INTERNAL_FUNC int emstorage_change_rule(char *multi_user_name, int rule_id, emst
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG(" Before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        int i = 0;
@@ -7643,17 +7597,17 @@ INTERNAL_FUNC int emstorage_change_rule(char *multi_user_name, int rule_id, emst
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        ret = true;
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7685,7 +7639,7 @@ INTERNAL_FUNC int emstorage_find_rule(char *multi_user_name, emstorage_rule_tbl_
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
-       switch(rule->action_type) {
+       switch (rule->action_type) {
        case EMAIL_FILTER_MOVE:
                if (rule->type == EMAIL_PRIORITY_SENDER) {
                        sqlite3_snprintf(sizeof(sql_query_string), sql_query_string,
@@ -7719,11 +7673,11 @@ INTERNAL_FUNC int emstorage_find_rule(char *multi_user_name, emstorage_rule_tbl_
        }
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF;},
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF;},
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (rc == SQLITE_DONE) {
@@ -7738,7 +7692,7 @@ FINISH_OFF:
        if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
                if (rc != SQLITE_OK) {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7777,10 +7731,10 @@ INTERNAL_FUNC int emstorage_add_rule(char *multi_user_name, emstorage_rule_tbl_t
        sql = "SELECT max(rowid) FROM mail_rule_tbl;";
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
-       if (NULL==result[1])
+       if (NULL == result[1])
                rc = 1;
        else
                rc = atoi(result[1])+1;
@@ -7791,7 +7745,7 @@ INTERNAL_FUNC int emstorage_add_rule(char *multi_user_name, emstorage_rule_tbl_t
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_rule_tbl VALUES "
-               "( ?"           /*  account id */
+               "(?"            /*  account id */
                ", ?"           /*  rule_id */
                ", ?"           /*  filter_name */
                ", ?"           /*  type */
@@ -7803,7 +7757,7 @@ INTERNAL_FUNC int emstorage_add_rule(char *multi_user_name, emstorage_rule_tbl_t
                ", ?)");        /*  flag2 */
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc_2);
-       if (rc_2 != SQLITE_OK)  {
+       if (rc_2 != SQLITE_OK) {
                EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc_2, sqlite3_errmsg(local_db_handle));
                error = EMAIL_ERROR_DB_FAILURE;
                goto FINISH_OFF;
@@ -7821,17 +7775,17 @@ INTERNAL_FUNC int emstorage_add_rule(char *multi_user_name, emstorage_rule_tbl_t
        _bind_stmt_field_data_int(hStmt, FLAG2_IDX_IN_MAIL_RULE_TBL, rule->flag2);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        ret = true;
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
                if (rc != SQLITE_OK) {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -7942,22 +7896,21 @@ INTERNAL_FUNC int emstorage_get_mail_count(char *multi_user_name, int account_id
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
-       if (total)  {
+       if (total) {
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_tbl");
 
-               if (account_id != ALL_ACCOUNT)  {
+               if (account_id != ALL_ACCOUNT) {
                        SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " WHERE account_id = %d", account_id);
                        if (mailbox_id)
                                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " AND mailbox_id = %d", mailbox_id);
-               }
-               else if (mailbox_id)
+               } else if (mailbox_id)
                        SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " WHERE mailbox_id = %d", mailbox_id);
 
 #ifdef USE_GET_RECORD_COUNT_API
                char **result;
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF2; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF2; },
                        ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                *total = atoi(result[1]);
@@ -7965,17 +7918,17 @@ INTERNAL_FUNC int emstorage_get_mail_count(char *multi_user_name, int account_id
 #else
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF2; },
+               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF2; },
                        ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF2; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF2; },
                        ("sqlite3_step fail:%d", rc));
                _get_stmt_field_data_int(hStmt, total, 0);
 #endif         /*  USE_GET_RECORD_COUNT_API */
        }
 
-       if (unseen)  {
+       if (unseen) {
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_tbl WHERE flags_seen_field = 0");               /*  fSEEN = 0x01 */
 
                if (account_id != ALL_ACCOUNT)
@@ -7983,13 +7936,12 @@ INTERNAL_FUNC int emstorage_get_mail_count(char *multi_user_name, int account_id
 
                if (mailbox_id) {
                        SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " AND mailbox_id = %d", mailbox_id);
-               }
-               else
+               } else
                        SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " AND mailbox_type NOT IN (3, 5)");
 
                char **result;
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                        ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                *unseen = atoi(result[1]);
@@ -8002,10 +7954,10 @@ FINISH_OFF:
 FINISH_OFF2:
 
 #ifndef USE_PREPARED_QUERY_
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -8026,7 +7978,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%d], type[%d], mail[%p], transaction[%d], err_code[%p]", mail_id, type, mail, transaction, err_code);
 
-       if (mail_id <= 0 || !mail)  {
+       if (mail_id <= 0 || !mail) {
                EM_DEBUG_EXCEPTION("mail_id[%d], mail[%p]", mail_id, mail);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -8036,7 +7988,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail
        int col_index = 0;
        emstorage_mail_tbl_t* p_data_tbl = (emstorage_mail_tbl_t*)malloc(sizeof(emstorage_mail_tbl_t));
 
-       if (p_data_tbl == NULL)  {
+       if (p_data_tbl == NULL) {
                EM_DEBUG_EXCEPTION("malloc failed...");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -8053,7 +8005,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
-       switch (type)  {
+       switch (type) {
                case RETRIEVE_SUMMARY:
                        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                                "SELECT account_id, "
@@ -8098,7 +8050,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail
                                "FROM mail_tbl WHERE mail_id = %d", mail_id);
                        break;
 
-               default :
+               default:
                        EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM : type [%d]", type);
                        error = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
@@ -8107,20 +8059,20 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail
        EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
-       if (rc == SQLITE_DONE)  {
+       if (rc == SQLITE_DONE) {
                EM_DEBUG_LOG("no matched mail found...");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
        }
-       switch (type)  {
+       switch (type) {
                case RETRIEVE_SUMMARY:
                        _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_id), col_index++);
                        _get_stmt_field_data_int(hStmt, &(p_data_tbl->mail_id), col_index++);
@@ -8166,10 +8118,10 @@ FINISH_OFF:
        else if (p_data_tbl != NULL)
                emstorage_free_mail(&p_data_tbl,  1, NULL);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -8197,7 +8149,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_
        emstorage_mail_tbl_t* p_data_tbl = NULL;
        sqlite3 *local_db_handle = NULL;
 
-       if (number_of_mails <= 0 || !mail_ids)  {
+       if (number_of_mails <= 0 || !mail_ids) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -8209,7 +8161,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_
        query_string_length = (sizeof(char) * 8 * number_of_mails) + 512;
        sql_query_string = (char*)em_malloc(query_string_length);
 
-       if (p_data_tbl == NULL || sql_query_string == NULL)  {
+       if (p_data_tbl == NULL || sql_query_string == NULL) {
                EM_DEBUG_EXCEPTION("malloc failed...");
 
                EM_SAFE_FREE(p_data_tbl);
@@ -8274,13 +8226,13 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_
                        field_count = 5;
                        break;
 
-               default :
+               default:
                        EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM : type [%d]", type);
                        error = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
        }
 
-       for(i = 0; i < number_of_mails; i++)
+       for (i = 0; i < number_of_mails; i++)
                cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, query_string_length, "%d,", mail_ids[i]);
        sql_query_string[EM_SAFE_STRLEN(sql_query_string) - 1] = ')';
 
@@ -8293,7 +8245,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_
                goto FINISH_OFF;
        }
 
-       if (rc == SQLITE_DONE)  {
+       if (rc == SQLITE_DONE) {
                EM_DEBUG_LOG("no matched mail found...");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
@@ -8301,7 +8253,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_
 
        EM_DEBUG_LOG("item_count [%d]", item_count);
 
-       if(number_of_mails != item_count) {
+       if (number_of_mails != item_count) {
                EM_DEBUG_EXCEPTION("Can't find all emails");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
@@ -8309,7 +8261,7 @@ INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_
 
        col_index = field_count;
 
-       for(i = 0; i < item_count; i++) {
+       for (i = 0; i < item_count; i++)        {
                switch (type) {
                        case RETRIEVE_SUMMARY:
                                _get_table_field_data_int(result, &(p_data_tbl[i].account_id), col_index++);
@@ -8391,7 +8343,7 @@ INTERNAL_FUNC int emstorage_get_mail_by_id(char *multi_user_name, int mail_id, e
        SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE mail_id = %d", mail_id);
        EM_DEBUG_LOG_SEC("query = [%s]", conditional_clause);
 
-       if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
+       if (!emstorage_query_mail_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl [%d]", error);
                goto FINISH_OFF;
        }
@@ -8432,7 +8384,7 @@ INTERNAL_FUNC int emstorage_get_mail_text_by_id(char *multi_user_name, int mail_
        SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE mail_id = %d", mail_id);
        EM_DEBUG_LOG_SEC("query = [%s]", conditional_clause);
 
-       if(!emstorage_query_mail_text_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
+       if (!emstorage_query_mail_text_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl [%d]", error);
                goto FINISH_OFF;
        }
@@ -8468,7 +8420,7 @@ INTERNAL_FUNC int emstorage_mail_search_start(char *multi_user_name,
                                                search, account_id, mailbox_id, sorting, search_handle,
                                                searched, transaction, err_code);
 
-       if (!search_handle || !searched)  {
+       if (!search_handle || !searched) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -8488,32 +8440,28 @@ INTERNAL_FUNC int emstorage_mail_search_start(char *multi_user_name,
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_tbl");
 
-       if (account_id != ALL_ACCOUNT)  {
+       if (account_id != ALL_ACCOUNT) {
                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " WHERE account_id = %d", account_id);
                and = true;
        }
 
-       if (mailbox_id)  {
+       if (mailbox_id) {
                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " %s mailbox_id = %d", and ? "AND" : "WHERE", mailbox_id);
                and = true;
        }
 
-       while (p)  {
-
+       while (p) {
                if (p->key_type) {
                        if (!strncmp(p->key_type, "subject", strlen("subject"))) {
                                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " %s subject LIKE '%%%%%s%%%%'", and ? "AND" : "WHERE", p->key_value);
                                and = true;
-                       }
-                       else if (!strncmp(p->key_type, "full_address_from", strlen("full_address_from"))) {
+                       } else if (!strncmp(p->key_type, "full_address_from", strlen("full_address_from"))) {
                                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " %s full_address_from LIKE '%%%%%s%%%%'", and ? "AND" : "WHERE", p->key_value);
                                and = true;
-                       }
-                       else if (!strncmp(p->key_type, "full_address_to", strlen("full_address_to"))) {
+                       } else if (!strncmp(p->key_type, "full_address_to", strlen("full_address_to"))) {
                                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " %s full_address_to LIKE '%%%%%s%%%%'", and ? "AND" : "WHERE", p->key_value);
                                and = true;
-                       }
-                       else if (!strncmp(p->key_type, "email_address", strlen("email_address"))) {
+                       } else if (!strncmp(p->key_type, "email_address", strlen("email_address"))) {
                                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1), " %s email_address_sender = '%s' OR email_address_recipient = '%s'", and ? "AND" : "WHERE", p->key_value, p->key_value);
                                and = true;
                        }
@@ -8528,18 +8476,18 @@ INTERNAL_FUNC int emstorage_mail_search_start(char *multi_user_name,
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        char **result;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &mail_count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        sqlite3_free_table(result);
@@ -8547,16 +8495,15 @@ INTERNAL_FUNC int emstorage_mail_search_start(char *multi_user_name,
        ret = true;
 
 FINISH_OFF:
-       if (ret == true)  {
+       if (ret == true) {
                *search_handle = hStmt;
                *searched = mail_count;
                EM_DEBUG_LOG("mail_count [%d]", mail_count);
-       }
-       else  {
-               if (hStmt != NULL)  {
+       } else {
+               if (hStmt != NULL) {
                        rc = sqlite3_finalize(hStmt);
-                       if (rc != SQLITE_OK)  {
-                               EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+                       if (rc != SQLITE_OK) {
+                               EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                                error = EMAIL_ERROR_DB_FAILURE;
                        }
                }
@@ -8588,7 +8535,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_
        int rc, ret = false;
        int error = EMAIL_ERROR_NONE;
 
-       switch (type)  {
+       switch (type) {
                case RETRIEVE_ID:
                        _get_stmt_field_data_int(hStmt, (int *)data, MAIL_ID_IDX_IN_MAIL_TBL);
                        break;
@@ -8596,42 +8543,42 @@ INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_
                case RETRIEVE_ENVELOPE:
                case RETRIEVE_ALL:
                        if (!(p_data_tbl = em_malloc(sizeof(emstorage_mail_tbl_t)))) {
-                               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+                               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                                error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
                        }
 
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->mail_id), MAIL_ID_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->account_id), ACCOUNT_ID_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->mail_size), MAIL_SIZE_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->mail_id), MAIL_ID_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_id), ACCOUNT_ID_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->mail_size), MAIL_SIZE_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mail_id), 0, SERVER_MAIL_ID_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->full_address_from), 1, FULL_ADDRESS_FROM_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->full_address_to), 1, FULL_ADDRESS_TO_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->subject), 1, SUBJECT_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->body_download_status), BODY_DOWNLOAD_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->body_download_status), BODY_DOWNLOAD_STATUS_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_plain), 0, FILE_PATH_PLAIN_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_html), 0, FILE_PATH_HTML_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->file_path_mime_entity), 0, FILE_PATH_HTML_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_time_t(hStmt, &(p_data_tbl->date_time), DATETIME_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_char  (hStmt, &(p_data_tbl->flags_seen_field), FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->DRM_status), DRM_STATUS_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->priority), PRIORITY_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->save_status), SAVE_STATUS_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->lock_status), LOCK_STATUS_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->report_status), REPORT_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_char(hStmt, &(p_data_tbl->flags_seen_field), FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->DRM_status), DRM_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->priority), PRIORITY_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->save_status), SAVE_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->lock_status), LOCK_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->report_status), REPORT_STATUS_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->preview_text), 1, PREVIEW_TEXT_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->meeting_request_status), MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->message_class), MESSAGE_CLASS_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->digest_type), DIGEST_TYPE_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->smime_type), SMIME_TYPE_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->scheduled_sending_time), SCHEDULED_SENDING_TIME_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->remaining_resend_times), SCHEDULED_SENDING_TIME_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->tag_id), TAG_ID_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->eas_data_length), EAS_DATA_LENGTH_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_blob   (hStmt, (void**)&(p_data_tbl->eas_data), EAS_DATA_IDX_IN_MAIL_TBL);
-
-                       if (type == RETRIEVE_ALL)  {
-                               _get_stmt_field_data_int   (hStmt, &(p_data_tbl->server_mail_status), SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->meeting_request_status), MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->message_class), MESSAGE_CLASS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->digest_type), DIGEST_TYPE_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->smime_type), SMIME_TYPE_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->scheduled_sending_time), SCHEDULED_SENDING_TIME_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->remaining_resend_times), SCHEDULED_SENDING_TIME_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->tag_id), TAG_ID_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->eas_data_length), EAS_DATA_LENGTH_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_blob(hStmt, (void**)&(p_data_tbl->eas_data), EAS_DATA_IDX_IN_MAIL_TBL);
+
+                       if (type == RETRIEVE_ALL) {
+                               _get_stmt_field_data_int(hStmt, &(p_data_tbl->server_mail_status), SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL);
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mailbox_name), 0, SERVER_MAILBOX_NAME_IDX_IN_MAIL_TBL);
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->full_address_reply), 1, FULL_ADDRESS_REPLY_IDX_IN_MAIL_TBL);
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->full_address_cc), 1, FULL_ADDRESS_CC_IDX_IN_MAIL_TBL);
@@ -8640,25 +8587,23 @@ INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->message_id), 0, MESSAGE_ID_IDX_IN_MAIL_TBL);
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->email_address_sender), 1, EMAIL_ADDRESS_SENDER_IDX_IN_MAIL_TBL);
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->email_address_recipient), 1, EMAIL_ADDRESS_RECIPIENT_IDX_IN_MAIL_TBL);
-                               _get_stmt_field_data_int   (hStmt, &(p_data_tbl->attachment_count), ATTACHMENT_COUNT_IDX_IN_MAIL_TBL);
+                               _get_stmt_field_data_int(hStmt, &(p_data_tbl->attachment_count), ATTACHMENT_COUNT_IDX_IN_MAIL_TBL);
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->preview_text), 1, PREVIEW_TEXT_IDX_IN_MAIL_TBL);
-                               _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->replied_time), REPLIED_TIME_IDX_IN_MAIL_TBL);
-                               _get_stmt_field_data_int   (hStmt, (int*)&(p_data_tbl->forwarded_time), FORWARDED_TIME_IDX_IN_MAIL_TBL);
+                               _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->replied_time), REPLIED_TIME_IDX_IN_MAIL_TBL);
+                               _get_stmt_field_data_int(hStmt, (int*)&(p_data_tbl->forwarded_time), FORWARDED_TIME_IDX_IN_MAIL_TBL);
                                _get_stmt_field_data_string(hStmt, &(p_data_tbl->default_charset), 0, DEFAULT_CHARSET_IDX_IN_MAIL_TBL);
                        }
 
-                       if (p_data_tbl->body_download_status)  {
+                       if (p_data_tbl->body_download_status) {
                                struct stat buf;
 
-                               if (p_data_tbl->file_path_html)  {
+                               if (p_data_tbl->file_path_html) {
                                        if (stat(p_data_tbl->file_path_html, &buf) == -1)
                                                p_data_tbl->body_download_status = 0;
-                               }
-                               else if (p_data_tbl->file_path_plain)  {
+                               } else if (p_data_tbl->file_path_plain) {
                                        if (stat(p_data_tbl->file_path_plain, &buf) == -1)
                                                p_data_tbl->body_download_status = 0;
-                               }
-                               else
+                               } else
                                        p_data_tbl->body_download_status = 0;
                        }
 
@@ -8666,7 +8611,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_
                        break;
 
                case RETRIEVE_SUMMARY:
-                       if (!(p_data_tbl = malloc(sizeof(emstorage_mail_tbl_t))))  {
+                       if (!(p_data_tbl = malloc(sizeof(emstorage_mail_tbl_t)))) {
                                EM_DEBUG_EXCEPTION(" malloc failed...");
 
                                error = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -8675,9 +8620,9 @@ INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_
 
                        memset(p_data_tbl, 0x00, sizeof(emstorage_mail_tbl_t));
 
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->mail_id), MAIL_ID_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->account_id), ACCOUNT_ID_IDX_IN_MAIL_TBL);
-                       _get_stmt_field_data_int   (hStmt, &(p_data_tbl->server_mail_status), SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->mail_id), MAIL_ID_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->account_id), ACCOUNT_ID_IDX_IN_MAIL_TBL);
+                       _get_stmt_field_data_int(hStmt, &(p_data_tbl->server_mail_status), SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mailbox_name), 0, SERVER_MAILBOX_NAME_IDX_IN_MAIL_TBL);
                        _get_stmt_field_data_string(hStmt, &(p_data_tbl->server_mail_id), 0, SERVER_MAIL_ID_IDX_IN_MAIL_TBL);
 
@@ -8685,7 +8630,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_
                        break;
 
                case RETRIEVE_ADDRESS:
-                       if (!(p_data_tbl = malloc(sizeof(emstorage_mail_tbl_t))))  {
+                       if (!(p_data_tbl = malloc(sizeof(emstorage_mail_tbl_t)))) {
                                EM_DEBUG_EXCEPTION(" malloc failed...");
                                error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -8703,7 +8648,7 @@ INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle, emstorage_
        }
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        ret = true;
@@ -8727,7 +8672,7 @@ INTERNAL_FUNC int emstorage_mail_search_end(DB_STMT search_handle, int transacti
        int error = EMAIL_ERROR_NONE;
        int rc, ret = false;
 
-       if (search_handle == 0)  {
+       if (search_handle == 0) {
                EM_DEBUG_EXCEPTION(" search_handle[%d]", search_handle);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -8736,8 +8681,8 @@ INTERNAL_FUNC int emstorage_mail_search_end(DB_STMT search_handle, int transacti
        DB_STMT hStmt = search_handle;
 
        rc = sqlite3_finalize(hStmt);
-       if (rc != SQLITE_OK)  {
-               EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+       if (rc != SQLITE_OK) {
+               EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                error = EMAIL_ERROR_DB_FAILURE;
        }
 
@@ -8826,17 +8771,17 @@ INTERNAL_FUNC int emstorage_change_mail(char *multi_user_name, int mail_id, emst
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
-       _bind_stmt_field_data_int   (hStmt, i++, mail->mail_id);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->account_id);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->mailbox_id);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->mail_size);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->server_mail_status);
+       _bind_stmt_field_data_int(hStmt, i++, mail->mail_id);
+       _bind_stmt_field_data_int(hStmt, i++, mail->account_id);
+       _bind_stmt_field_data_int(hStmt, i++, mail->mailbox_id);
+       _bind_stmt_field_data_int(hStmt, i++, mail->mail_size);
+       _bind_stmt_field_data_int(hStmt, i++, mail->server_mail_status);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->server_mailbox_name, 0, SERVER_MAILBOX_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->server_mail_id, 0, SERVER_MAIL_ID_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->reference_mail_id);
+       _bind_stmt_field_data_int(hStmt, i++, mail->reference_mail_id);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_from, 1, FROM_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_reply, 1, REPLY_TO_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_to, 1, TO_LEN_IN_MAIL_TBL);
@@ -8844,41 +8789,41 @@ INTERNAL_FUNC int emstorage_change_mail(char *multi_user_name, int mail_id, emst
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_bcc, 1, BCC_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->full_address_return, 1, RETURN_PATH_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->subject, 1, SUBJECT_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->body_download_status);
+       _bind_stmt_field_data_int(hStmt, i++, mail->body_download_status);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->date_time);
-       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_seen_field);
-       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_deleted_field);
-       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_flagged_field);
-       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_answered_field);
-       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_recent_field);
-       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_draft_field);
-       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_forwarded_field);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->DRM_status);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->priority);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->save_status);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->lock_status);
+       _bind_stmt_field_data_int(hStmt, i++, mail->date_time);
+       _bind_stmt_field_data_char(hStmt, i++, mail->flags_seen_field);
+       _bind_stmt_field_data_char(hStmt, i++, mail->flags_deleted_field);
+       _bind_stmt_field_data_char(hStmt, i++, mail->flags_flagged_field);
+       _bind_stmt_field_data_char(hStmt, i++, mail->flags_answered_field);
+       _bind_stmt_field_data_char(hStmt, i++, mail->flags_recent_field);
+       _bind_stmt_field_data_char(hStmt, i++, mail->flags_draft_field);
+       _bind_stmt_field_data_char(hStmt, i++, mail->flags_forwarded_field);
+       _bind_stmt_field_data_int(hStmt, i++, mail->DRM_status);
+       _bind_stmt_field_data_int(hStmt, i++, mail->priority);
+       _bind_stmt_field_data_int(hStmt, i++, mail->save_status);
+       _bind_stmt_field_data_int(hStmt, i++, mail->lock_status);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->message_id, 0, MESSAGE_ID_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->report_status);
+       _bind_stmt_field_data_int(hStmt, i++, mail->report_status);
        _bind_stmt_field_data_nstring(hStmt, i++, (char *)mail->preview_text, 1, PREVIEWBODY_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->smime_type);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->scheduled_sending_time);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->remaining_resend_times);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->tag_id);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->replied_time);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->forwarded_time);
+       _bind_stmt_field_data_int(hStmt, i++, mail->smime_type);
+       _bind_stmt_field_data_int(hStmt, i++, mail->scheduled_sending_time);
+       _bind_stmt_field_data_int(hStmt, i++, mail->remaining_resend_times);
+       _bind_stmt_field_data_int(hStmt, i++, mail->tag_id);
+       _bind_stmt_field_data_int(hStmt, i++, mail->replied_time);
+       _bind_stmt_field_data_int(hStmt, i++, mail->forwarded_time);
        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->default_charset, 0, TEXT_2_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, i++, mail->eas_data_length);
-       _bind_stmt_field_data_blob  (hStmt, i++, (void*)mail->eas_data, mail->eas_data_length);
+       _bind_stmt_field_data_int(hStmt, i++, mail->eas_data_length);
+       _bind_stmt_field_data_blob(hStmt, i++, (void*)mail->eas_data, mail->eas_data_length);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_LOG(" no matched mail found...");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
@@ -8888,19 +8833,19 @@ INTERNAL_FUNC int emstorage_change_mail(char *multi_user_name, int mail_id, emst
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
 
 
-       if(error == EMAIL_ERROR_NONE && mail) {
+       if (error == EMAIL_ERROR_NONE && mail) {
                SNPRINTF(mailbox_id_param_string, 10, "%d", mail->mailbox_id);
-               if (!emcore_notify_storage_event (NOTI_MAIL_UPDATE, mail->account_id, mail->mail_id, mailbox_id_param_string, 0))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event failed [NOTI_MAIL_UPDATE]");
+               if (!emcore_notify_storage_event(NOTI_MAIL_UPDATE, mail->account_id, mail->mail_id, mailbox_id_param_string, 0))
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_eventfailed [NOTI_MAIL_UPDATE]");
        }
 
        if (err_code != NULL)
@@ -8977,7 +8922,7 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(char *multi_us
                return false;
        }
 
-       if(error = emcore_get_attribute_type_by_mail_field_name(field_name, &target_mail_attribute_type)) != EMAIL_ERROR_NONE) {
+       if ((error = emcore_get_attribute_type_by_mail_field_name(field_name, &target_mail_attribute_type)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorageemcore_get_attribute_type_by_mail_field_name failed [%d]", error);
                if (err_code != NULL)
                        *err_code = error;
@@ -8989,28 +8934,28 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(char *multi_us
 
        mail_id_string_buffer = em_malloc(mail_id_string_buffer_length);
 
-       if(!mail_id_string_buffer) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+       if (!mail_id_string_buffer) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
                return false;
        }
 
-       for(i = 0; i < mail_ids_count; i++)
+       for (i = 0; i < mail_ids_count; i++)
                cur_mail_id_string += SNPRINTF_OFFSET(mail_id_string_buffer, cur_mail_id_string, mail_id_string_buffer_length, "%d,", mail_ids[i]);
 
-       if(EM_SAFE_STRLEN(mail_id_string_buffer) > 1)
+       if (EM_SAFE_STRLEN(mail_id_string_buffer) > 1)
                mail_id_string_buffer[EM_SAFE_STRLEN(mail_id_string_buffer) - 1] = NULL_CHAR;
 
        /* Generating notification parameter string */
        parameter_string_length = mail_id_string_buffer_length + EM_SAFE_STRLEN(field_name) + 2;
        parameter_string = em_malloc(parameter_string_length);
 
-       if(!parameter_string) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+       if (!parameter_string) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_OUT_OF_MEMORY;
-               EM_SAFE_FREE (mail_id_string_buffer);
+               EM_SAFE_FREE(mail_id_string_buffer);
                return false;
        }
 
@@ -9019,14 +8964,14 @@ INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(char *multi_us
 
        sql_query_string = em_malloc(query_size);
        if (sql_query_string == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
        /* Write query string */
        SNPRINTF(sql_query_string, query_size, "UPDATE mail_tbl SET %s = %d WHERE mail_id in (%s) AND account_id = %d", field_name, value, mail_id_string_buffer, account_id);
 
-       EM_DEBUG_LOG_DEV ("sql_query_string [%s]", sql_query_string);
+       EM_DEBUG_LOG_DEV("sql_query_string [%s]", sql_query_string);
 
        /* Execute query */
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
@@ -9045,8 +8990,8 @@ FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
        if (error == EMAIL_ERROR_NONE && parameter_string) {
-               if (!emcore_notify_storage_event (NOTI_MAIL_FIELD_UPDATE, account_id, target_mail_attribute_type, parameter_string, value))
-                       EM_DEBUG_EXCEPTION_SEC ("emcore_notify_storage_event failed : NOTI_MAIL_FIELD_UPDATE [%s,%d]", field_name, value);
+               if (!emcore_notify_storage_event(NOTI_MAIL_FIELD_UPDATE, account_id, target_mail_attribute_type, parameter_string, value))
+                       EM_DEBUG_EXCEPTION_SEC("emcore_notify_storage_eventfailed : NOTI_MAIL_FIELD_UPDATE [%s,%d]", field_name, value);
        }
 
        EM_SAFE_FREE(mail_id_string_buffer);
@@ -9100,11 +9045,11 @@ INTERNAL_FUNC int emstorage_change_mail_text_field(char *multi_user_name, int ma
 
        if (hStmt != NULL) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF;}, ("sqlite3_step fail:%d", rc));
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF;}, ("sqlite3_step fail:%d", rc));
+               EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc));
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc));
 
                rc = sqlite3_changes(local_db_handle);
-               if (rc == 0)  {
+               if (rc == 0) {
                        EM_DEBUG_LOG(" no matched mail found...");
                        error = EMAIL_ERROR_MAIL_NOT_FOUND;
                        goto FINISH_OFF;
@@ -9119,7 +9064,7 @@ FINISH_OFF:
        if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
                if (rc != SQLITE_OK) {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
                hStmt = NULL;
@@ -9148,7 +9093,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
        char mailbox_id_param_string[10] = {0,};
        sqlite3 *local_db_handle = NULL;
 
-       if (mail_id <= 0 || !mail)  {
+       if (mail_id <= 0 || !mail) {
                EM_DEBUG_EXCEPTION(" mail_id[%d], type[%d], mail[%p]", mail_id, type, mail);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -9186,7 +9131,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                         i = 0;
 
@@ -9231,7 +9176,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
 
                                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                        ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                                i = 0;
@@ -9265,7 +9210,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                        break;
@@ -9289,7 +9234,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                        break;
 
@@ -9304,7 +9249,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                        break;
 
@@ -9356,8 +9301,8 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_LOG_DEV (" before sqlite3_prepare hStmt = %p", hStmt);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_LOG_DEV(" before sqlite3_prepare hStmt = %p", hStmt);
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                        i = 0;
                        _bind_stmt_field_data_string(hStmt, i++, (char*)mail->full_address_from, 1, FROM_LEN_IN_MAIL_TBL);
@@ -9369,40 +9314,40 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
                        _bind_stmt_field_data_string(hStmt, i++, (char*)mail->subject, 1, SUBJECT_LEN_IN_MAIL_TBL);
                        _bind_stmt_field_data_string(hStmt, i++, (char*)mail->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL);
                        _bind_stmt_field_data_time_t(hStmt, i++, mail->date_time);
-                       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_seen_field);
-                       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_deleted_field);
-                       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_flagged_field);
-                       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_answered_field);
-                       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_recent_field);
-                       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_draft_field);
-                       _bind_stmt_field_data_char  (hStmt, i++, mail->flags_forwarded_field);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->priority);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->save_status);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->lock_status);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->report_status);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->DRM_status);
+                       _bind_stmt_field_data_char(hStmt, i++, mail->flags_seen_field);
+                       _bind_stmt_field_data_char(hStmt, i++, mail->flags_deleted_field);
+                       _bind_stmt_field_data_char(hStmt, i++, mail->flags_flagged_field);
+                       _bind_stmt_field_data_char(hStmt, i++, mail->flags_answered_field);
+                       _bind_stmt_field_data_char(hStmt, i++, mail->flags_recent_field);
+                       _bind_stmt_field_data_char(hStmt, i++, mail->flags_draft_field);
+                       _bind_stmt_field_data_char(hStmt, i++, mail->flags_forwarded_field);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->priority);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->save_status);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->lock_status);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->report_status);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->DRM_status);
                        _bind_stmt_field_data_string(hStmt, i++, (char*)mail->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL);
                        _bind_stmt_field_data_string(hStmt, i++, (char*)mail->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->mail_size);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->mail_size);
                        _bind_stmt_field_data_nstring(hStmt, i++, (char*)mail->preview_text, 1, PREVIEWBODY_LEN_IN_MAIL_TBL);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->body_download_status);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->attachment_count);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->inline_content_count);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->meeting_request_status);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->message_class);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->digest_type);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->smime_type);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->scheduled_sending_time);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->remaining_resend_times);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->tag_id);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->replied_time);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->forwarded_time);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->body_download_status);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->attachment_count);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->inline_content_count);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->meeting_request_status);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->message_class);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->digest_type);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->smime_type);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->scheduled_sending_time);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->remaining_resend_times);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->tag_id);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->replied_time);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->forwarded_time);
                        _bind_stmt_field_data_string(hStmt, i++, (char*)mail->default_charset, 0, TEXT_2_LEN_IN_MAIL_TBL);
-                       _bind_stmt_field_data_int   (hStmt, i++, mail->eas_data_length);
-                       _bind_stmt_field_data_blob  (hStmt, i++, (void*)mail->eas_data, mail->eas_data_length);
+                       _bind_stmt_field_data_int(hStmt, i++, mail->eas_data_length);
+                       _bind_stmt_field_data_blob(hStmt, i++, (void*)mail->eas_data, mail->eas_data_length);
                        break;
 
-               case UPDATE_DATETIME:  {
+               case UPDATE_DATETIME: {
                        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                                "UPDATE mail_tbl SET"
                                " date_time = '%ld'"
@@ -9411,7 +9356,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
                                , mail_id);
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                        break;
                }
@@ -9427,7 +9372,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
                        hStmt = NULL;
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                        i = 0;
                        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->email_address_sender, 1, FROM_EMAIL_ADDRESS_LEN_IN_MAIL_TBL);
@@ -9444,7 +9389,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
                        hStmt = NULL;
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                        i = 0;
                        _bind_stmt_field_data_string(hStmt, i++, (char *)mail->email_address_recipient, 1, TO_EMAIL_ADDRESS_LEN_IN_MAIL_TBL);
@@ -9462,7 +9407,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
                                hStmt = NULL;
 
                                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                        ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                                i = 0;
                                _bind_stmt_field_data_string(hStmt, i++, (char *)mail->email_address_sender, 1, FROM_EMAIL_ADDRESS_LEN_IN_MAIL_TBL);
@@ -9489,7 +9434,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                         i = 0;
 
@@ -9518,7 +9463,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
                        EM_DEBUG_LOG(" before sqlite3_prepare hStmt = %p", hStmt);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                        i = 0;
                        _bind_stmt_field_data_string(hStmt, i++, (char*)mail->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL);
@@ -9533,15 +9478,15 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
                        goto FINISH_OFF;
        }
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
                rc = sqlite3_changes(local_db_handle);
-               if (rc == 0)  {
+               if (rc == 0) {
                        EM_DEBUG_LOG(" no matched mail found...");
                        error = EMAIL_ERROR_MAIL_NOT_FOUND;
                        goto FINISH_OFF;
@@ -9551,7 +9496,7 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
        if (mail->account_id == 0) {
                emstorage_mail_tbl_t* mail_for_account_tbl = NULL;
                if (!emstorage_get_mail_field_by_id(multi_user_name, mail_id, RETRIEVE_ACCOUNT, &mail_for_account_tbl, true, &error) || !mail_for_account_tbl) {
-                       EM_DEBUG_EXCEPTION ("emstorage_get_mail_field_by_id error [%d]", error);
+                       EM_DEBUG_EXCEPTION("emstorage_get_mail_field_by_id error [%d]", error);
                        goto FINISH_OFF;
                }
                mail->account_id = mail_for_account_tbl->account_id;
@@ -9564,27 +9509,27 @@ INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
                hStmt = NULL;
        }
+
        if (error == EMAIL_ERROR_NONE &&  move_flag != 1 && transaction) {
                if (!emstorage_get_mailbox_id_by_mailbox_type(multi_user_name, mail->account_id, EMAIL_MAILBOX_TYPE_SENTBOX, &mailbox_id, false, &error))
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_id_by_mailbox_type error [%d]", error);
 
                if (mail->mailbox_id == mailbox_id) {
                        SNPRINTF(mailbox_id_param_string, 10, "%d", mail->mailbox_id);
-                       if (!emcore_notify_storage_event (NOTI_MAIL_UPDATE, mail->account_id, mail_id, mailbox_id_param_string, type))
-                               EM_DEBUG_EXCEPTION ("emcore_notify_storage_event error [ NOTI_MAIL_UPDATE ] >>>> ");
-               }
-               else {
+                       if (!emcore_notify_storage_event(NOTI_MAIL_UPDATE, mail->account_id, mail_id, mailbox_id_param_string, type))
+                               EM_DEBUG_EXCEPTION("emcore_notify_storage_eventerror [ NOTI_MAIL_UPDATE ] >>>> ");
+               } else {
                        /* h.gahlaut@samsung.com: Jan 10, 2011 Publishing noti to refresh outbox when email sending status changes */
-                       if (!emcore_notify_storage_event (NOTI_MAIL_UPDATE, mail->account_id, mail_id, NULL, type))
-                               EM_DEBUG_EXCEPTION (" emcore_notify_storage_event error [ NOTI_MAIL_UPDATE ]");
+                       if (!emcore_notify_storage_event(NOTI_MAIL_UPDATE, mail->account_id, mail_id, NULL, type))
+                               EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventerror [ NOTI_MAIL_UPDATE ]");
                }
        }
 
@@ -9617,7 +9562,7 @@ INTERNAL_FUNC int emstorage_increase_mail_id(char *multi_user_name, int *mail_id
         local_db_handle = emstorage_get_db_connection(multi_user_name);
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                        ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
                if (NULL == result[1])
                        rc = 1;
@@ -9655,7 +9600,7 @@ INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t
        EM_PROFILE_BEGIN(profile_emstorage_add_mail);
        EM_DEBUG_FUNC_BEGIN("mail_tbl_data[%p], get_id[%d], transaction[%d], err_code[%p]", mail_tbl_data, get_id, transaction, err_code);
 
-       if (!mail_tbl_data)  {
+       if (!mail_tbl_data) {
                EM_DEBUG_EXCEPTION("mail_tbl_data[%p], get_id[%d]", mail_tbl_data, get_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -9671,16 +9616,16 @@ INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t
 
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
 
-       if (get_id)  {
+       if (get_id) {
                /*  increase unique id */
                char *sql = "SELECT max(rowid) FROM mail_tbl;";
                char **result;
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-/*             EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+/*             EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                        ("SQL[%s] sqlite3_get_table fail[%d] [%s]", sql, rc, sqlite3_errmsg(local_db_handle))); */
                if (rc != SQLITE_OK) {
-                       EM_DEBUG_EXCEPTION ("SQL[%s] sqlite3_get_table fail[%d] [%s]", sql, rc, sqlite3_errmsg(local_db_handle));
+                       EM_DEBUG_EXCEPTION("SQL[%s] sqlite3_get_table fail[%d] [%s]", sql, rc, sqlite3_errmsg(local_db_handle));
                        error = EMAIL_ERROR_DB_FAILURE;
                        sqlite3_free_table(result);
                        goto FINISH_OFF;
@@ -9702,7 +9647,7 @@ INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_tbl VALUES "
-               "( ?" /*  mail_id */
+               "(?" /*  mail_id */
                ", ?" /*  account_id */
                ", ?" /*  mailbox_id */
                ", ?" /*  mailbox_type */
@@ -9777,25 +9722,25 @@ INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t
                                                    NULL),
                                     rc);
        if (rc != SQLITE_OK) {
-               EM_DEBUG_EXCEPTION ("sqlite3_prepare error [%d] [%s] SQL(%s) ",
+               EM_DEBUG_EXCEPTION("sqlite3_prepare error [%d] [%s] SQL(%s) ",
                              rc, sql_query_string, sqlite3_errmsg(local_db_handle));
                error = EMAIL_ERROR_DB_FAILURE;
                goto FINISH_OFF;
        }
 
-       _bind_stmt_field_data_int   (hStmt, MAIL_ID_IDX_IN_MAIL_TBL, mail_tbl_data->mail_id);
-       _bind_stmt_field_data_int   (hStmt, ACCOUNT_ID_IDX_IN_MAIL_TBL, mail_tbl_data->account_id);
-       _bind_stmt_field_data_int   (hStmt, MAILBOX_ID_IDX_IN_MAIL_TBL, mail_tbl_data->mailbox_id);
-       _bind_stmt_field_data_int   (hStmt, MAILBOX_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->mailbox_type);
+       _bind_stmt_field_data_int(hStmt, MAIL_ID_IDX_IN_MAIL_TBL, mail_tbl_data->mail_id);
+       _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_TBL, mail_tbl_data->account_id);
+       _bind_stmt_field_data_int(hStmt, MAILBOX_ID_IDX_IN_MAIL_TBL, mail_tbl_data->mailbox_id);
+       _bind_stmt_field_data_int(hStmt, MAILBOX_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->mailbox_type);
        _bind_stmt_field_data_string(hStmt, SUBJECT_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->subject, 1, SUBJECT_LEN_IN_MAIL_TBL);
 
-       _bind_stmt_field_data_int   (hStmt, DATETIME_IDX_IN_MAIL_TBL, mail_tbl_data->date_time);
-       _bind_stmt_field_data_int   (hStmt, SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->server_mail_status);
+       _bind_stmt_field_data_int(hStmt, DATETIME_IDX_IN_MAIL_TBL, mail_tbl_data->date_time);
+       _bind_stmt_field_data_int(hStmt, SERVER_MAIL_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->server_mail_status);
        _bind_stmt_field_data_string(hStmt, SERVER_MAILBOX_NAME_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->server_mailbox_name, 0, SERVER_MAILBOX_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, SERVER_MAIL_ID_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->server_mail_id, 0, SERVER_MAIL_ID_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, MESSAGE_ID_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->message_id, 0, MESSAGE_ID_LEN_IN_MAIL_TBL);
 
-       _bind_stmt_field_data_int   (hStmt, REFERENCE_ID_IDX_IN_MAIL_TBL, mail_tbl_data->reference_mail_id);
+       _bind_stmt_field_data_int(hStmt, REFERENCE_ID_IDX_IN_MAIL_TBL, mail_tbl_data->reference_mail_id);
        _bind_stmt_field_data_string(hStmt, FULL_ADDRESS_FROM_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->full_address_from, 1, FROM_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, FULL_ADDRESS_REPLY_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->full_address_reply, 1, REPLY_TO_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, FULL_ADDRESS_TO_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->full_address_to, 1, TO_LEN_IN_MAIL_TBL);
@@ -9808,56 +9753,56 @@ INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t
        _bind_stmt_field_data_string(hStmt, ALIAS_SENDER_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->alias_sender, 1, FROM_CONTACT_NAME_LEN_IN_MAIL_TBL);
 
        _bind_stmt_field_data_string(hStmt, ALIAS_RECIPIENT_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->alias_recipient, 1, FROM_CONTACT_NAME_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, BODY_DOWNLOAD_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->body_download_status);
+       _bind_stmt_field_data_int(hStmt, BODY_DOWNLOAD_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->body_download_status);
        _bind_stmt_field_data_string(hStmt, FILE_PATH_PLAIN_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->file_path_plain, 0, TEXT_1_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, FILE_PATH_HTML_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->file_path_html, 0, TEXT_2_LEN_IN_MAIL_TBL);
        _bind_stmt_field_data_string(hStmt, FILE_PATH_MIME_ENTITY_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->file_path_mime_entity, 0, MIME_ENTITY_LEN_IN_MAIL_TBL);
 
-       _bind_stmt_field_data_int   (hStmt, MAIL_SIZE_IDX_IN_MAIL_TBL, mail_tbl_data->mail_size);
-       _bind_stmt_field_data_int   (hStmt, FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_seen_field);
-       _bind_stmt_field_data_int   (hStmt, FLAGS_DELETED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_deleted_field);
-       _bind_stmt_field_data_int   (hStmt, FLAGS_FLAGGED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_flagged_field);
-       _bind_stmt_field_data_int   (hStmt, FLAGS_ANSWERED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_answered_field);
-
-       _bind_stmt_field_data_int   (hStmt, FLAGS_RECENT_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_recent_field);
-       _bind_stmt_field_data_int   (hStmt, FLAGS_DRAFT_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_draft_field);
-       _bind_stmt_field_data_int   (hStmt, FLAGS_FORWARDED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_forwarded_field);
-       _bind_stmt_field_data_int   (hStmt, DRM_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->DRM_status);
-       _bind_stmt_field_data_int   (hStmt, PRIORITY_IDX_IN_MAIL_TBL, mail_tbl_data->priority);
-
-       _bind_stmt_field_data_int   (hStmt, SAVE_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->save_status);
-       _bind_stmt_field_data_int   (hStmt, LOCK_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->lock_status);
-       _bind_stmt_field_data_int   (hStmt, REPORT_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->report_status);
-       _bind_stmt_field_data_int   (hStmt, ATTACHMENT_COUNT_IDX_IN_MAIL_TBL, mail_tbl_data->attachment_count);
-       _bind_stmt_field_data_int   (hStmt, INLINE_CONTENT_COUNT_IDX_IN_MAIL_TBL, mail_tbl_data->inline_content_count);
-
-       _bind_stmt_field_data_int   (hStmt, THREAD_ID_IDX_IN_MAIL_TBL, mail_tbl_data->thread_id);
-       _bind_stmt_field_data_int   (hStmt, THREAD_ITEM_COUNT_IDX_IN_MAIL_TBL, mail_tbl_data->thread_item_count);
+       _bind_stmt_field_data_int(hStmt, MAIL_SIZE_IDX_IN_MAIL_TBL, mail_tbl_data->mail_size);
+       _bind_stmt_field_data_int(hStmt, FLAGS_SEEN_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_seen_field);
+       _bind_stmt_field_data_int(hStmt, FLAGS_DELETED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_deleted_field);
+       _bind_stmt_field_data_int(hStmt, FLAGS_FLAGGED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_flagged_field);
+       _bind_stmt_field_data_int(hStmt, FLAGS_ANSWERED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_answered_field);
+
+       _bind_stmt_field_data_int(hStmt, FLAGS_RECENT_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_recent_field);
+       _bind_stmt_field_data_int(hStmt, FLAGS_DRAFT_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_draft_field);
+       _bind_stmt_field_data_int(hStmt, FLAGS_FORWARDED_FIELD_IDX_IN_MAIL_TBL, mail_tbl_data->flags_forwarded_field);
+       _bind_stmt_field_data_int(hStmt, DRM_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->DRM_status);
+       _bind_stmt_field_data_int(hStmt, PRIORITY_IDX_IN_MAIL_TBL, mail_tbl_data->priority);
+
+       _bind_stmt_field_data_int(hStmt, SAVE_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->save_status);
+       _bind_stmt_field_data_int(hStmt, LOCK_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->lock_status);
+       _bind_stmt_field_data_int(hStmt, REPORT_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->report_status);
+       _bind_stmt_field_data_int(hStmt, ATTACHMENT_COUNT_IDX_IN_MAIL_TBL, mail_tbl_data->attachment_count);
+       _bind_stmt_field_data_int(hStmt, INLINE_CONTENT_COUNT_IDX_IN_MAIL_TBL, mail_tbl_data->inline_content_count);
+
+       _bind_stmt_field_data_int(hStmt, THREAD_ID_IDX_IN_MAIL_TBL, mail_tbl_data->thread_id);
+       _bind_stmt_field_data_int(hStmt, THREAD_ITEM_COUNT_IDX_IN_MAIL_TBL, mail_tbl_data->thread_item_count);
        _bind_stmt_field_data_nstring(hStmt, PREVIEW_TEXT_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->preview_text, 1, PREVIEWBODY_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->meeting_request_status);
-       _bind_stmt_field_data_int   (hStmt, MESSAGE_CLASS_IDX_IN_MAIL_TBL, mail_tbl_data->message_class);
+       _bind_stmt_field_data_int(hStmt, MEETING_REQUEST_STATUS_IDX_IN_MAIL_TBL, mail_tbl_data->meeting_request_status);
+       _bind_stmt_field_data_int(hStmt, MESSAGE_CLASS_IDX_IN_MAIL_TBL, mail_tbl_data->message_class);
 
-       _bind_stmt_field_data_int   (hStmt, DIGEST_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->digest_type);
-       _bind_stmt_field_data_int   (hStmt, SMIME_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->smime_type);
-       _bind_stmt_field_data_int   (hStmt, SCHEDULED_SENDING_TIME_IDX_IN_MAIL_TBL, mail_tbl_data->scheduled_sending_time);
-       _bind_stmt_field_data_int   (hStmt, REMAINING_RESEND_TIMES_IDX_IN_MAIL_TBL, mail_tbl_data->remaining_resend_times);
-       _bind_stmt_field_data_int   (hStmt, TAG_ID_IDX_IN_MAIL_TBL, mail_tbl_data->tag_id);
+       _bind_stmt_field_data_int(hStmt, DIGEST_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->digest_type);
+       _bind_stmt_field_data_int(hStmt, SMIME_TYPE_IDX_IN_MAIL_TBL, mail_tbl_data->smime_type);
+       _bind_stmt_field_data_int(hStmt, SCHEDULED_SENDING_TIME_IDX_IN_MAIL_TBL, mail_tbl_data->scheduled_sending_time);
+       _bind_stmt_field_data_int(hStmt, REMAINING_RESEND_TIMES_IDX_IN_MAIL_TBL, mail_tbl_data->remaining_resend_times);
+       _bind_stmt_field_data_int(hStmt, TAG_ID_IDX_IN_MAIL_TBL, mail_tbl_data->tag_id);
 
-       _bind_stmt_field_data_int   (hStmt, REPLIED_TIME_IDX_IN_MAIL_TBL, mail_tbl_data->replied_time);
-       _bind_stmt_field_data_int   (hStmt, FORWARDED_TIME_IDX_IN_MAIL_TBL, mail_tbl_data->forwarded_time);
+       _bind_stmt_field_data_int(hStmt, REPLIED_TIME_IDX_IN_MAIL_TBL, mail_tbl_data->replied_time);
+       _bind_stmt_field_data_int(hStmt, FORWARDED_TIME_IDX_IN_MAIL_TBL, mail_tbl_data->forwarded_time);
        _bind_stmt_field_data_string(hStmt, DEFAULT_CHARSET_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->default_charset, 0, TEXT_2_LEN_IN_MAIL_TBL);
-       _bind_stmt_field_data_int   (hStmt, EAS_DATA_LENGTH_IDX_IN_MAIL_TBL, mail_tbl_data->eas_data_length);
-       _bind_stmt_field_data_blob  (hStmt, EAS_DATA_IDX_IN_MAIL_TBL, (void*)mail_tbl_data->eas_data, mail_tbl_data->eas_data_length);
+       _bind_stmt_field_data_int(hStmt, EAS_DATA_LENGTH_IDX_IN_MAIL_TBL, mail_tbl_data->eas_data_length);
+       _bind_stmt_field_data_blob(hStmt, EAS_DATA_IDX_IN_MAIL_TBL, (void*)mail_tbl_data->eas_data, mail_tbl_data->eas_data_length);
        _bind_stmt_field_data_string(hStmt, USER_NAME_IDX_IN_MAIL_TBL, (char*)mail_tbl_data->user_name, 0, TEXT_2_LEN_IN_MAIL_TBL);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
        if (rc == SQLITE_FULL) {
-               EM_DEBUG_EXCEPTION ("sqlite3_step error [%d]", rc);
+               EM_DEBUG_EXCEPTION("sqlite3_step error [%d]", rc);
                error = EMAIL_ERROR_MAIL_MEMORY_FULL;
                goto FINISH_OFF;
        }
        if (rc != SQLITE_ROW && rc != SQLITE_DONE) {
-               EM_DEBUG_EXCEPTION ("sqlite3_step error [%d]", rc);
+               EM_DEBUG_EXCEPTION("sqlite3_step error [%d]", rc);
                error = EMAIL_ERROR_DB_FAILURE;
                goto FINISH_OFF;
        }
@@ -9866,10 +9811,10 @@ INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -9926,18 +9871,18 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(char *multi_user_name, int
        conditional_clause_len =  (sizeof(char) * 8 * number_of_mails) + 512;
        conditional_clause = em_malloc(conditional_clause_len);
        if (conditional_clause == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
        cur_conditional_clause = SNPRINTF(conditional_clause, conditional_clause_len, "WHERE mail_id in (");
 
-       for(i = 0; i < number_of_mails; i++)
+       for (i = 0; i < number_of_mails; i++)
                cur_conditional_clause += SNPRINTF_OFFSET(conditional_clause, cur_conditional_clause, conditional_clause_len, "%d,", mail_ids[i]);
 
        /* prevent 34415 */
        char *last_comma = rindex(conditional_clause, ',');
-       if(last_comma) *last_comma = ')'; /* replace , with ) */
+       if (last_comma) *last_comma = ')'; /* replace , with) */
 
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
 
@@ -9945,7 +9890,7 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(char *multi_user_name, int
 
        sql_query_string = em_malloc(conditional_clause_len);
        if (sql_query_string == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -9994,12 +9939,12 @@ INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(char *multi_user_name, int
        memset(conditional_clause, 0x00, conditional_clause_len);
        cur_conditional_clause = SNPRINTF(conditional_clause, conditional_clause_len, "WHERE local_uid in (");
 
-       for(i = 0; i < number_of_mails; i++)
+       for (i = 0; i < number_of_mails; i++)
                cur_conditional_clause += SNPRINTF_OFFSET(conditional_clause, cur_conditional_clause, conditional_clause_len, "%d,", mail_ids[i]);
 
        /* prevent 34415 */
        last_comma = rindex(conditional_clause, ',');
-       if(last_comma) *last_comma = ')'; /* replace , with ) */
+       if (last_comma) *last_comma = ')'; /* replace , with) */
 
        memset(sql_query_string, 0x00, conditional_clause_len);
        SNPRINTF(sql_query_string, conditional_clause_len, "UPDATE mail_read_mail_uid_tbl SET mailbox_name = '%s', mailbox_id = %d, account_id = %d %s", target_mailbox_name, input_mailbox_id, target_account_id, conditional_clause);
@@ -10030,7 +9975,7 @@ INTERNAL_FUNC int emstorage_delete_mail(char *multi_user_name, int mail_id, int
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%d], transaction[%d], err_code[%p]", mail_id, transaction, err_code);
 
-       if (!mail_id)  {
+       if (!mail_id) {
                EM_DEBUG_EXCEPTION("mail_id[%d]", mail_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -10087,19 +10032,19 @@ INTERNAL_FUNC int emstorage_delete_multiple_mails(char *multi_user_name, int mai
        query_size = (sizeof(char) * 8 * number_of_mails) + 512;
        sql_query_string =  em_malloc(query_size);
        if (sql_query_string == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
        cur_sql_query_string = SNPRINTF(sql_query_string, query_size, "DELETE FROM mail_tbl WHERE mail_id in (");
 
-       for(i = 0; i < number_of_mails; i++)
+       for (i = 0; i < number_of_mails; i++)
                cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, query_size, "%d,", mail_ids[i]);
 
        /* prevent 34414 */
        char *last_comma = rindex(sql_query_string, ',');
-       if (last_comma != NULL) *last_comma = ')'; /* replace , with ) */
+       if (last_comma != NULL) *last_comma = ')'; /* replace , with) */
 
        EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
        error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -10112,11 +10057,11 @@ INTERNAL_FUNC int emstorage_delete_multiple_mails(char *multi_user_name, int mai
        /* delete mail_text from mail_text_tbl */
        cur_sql_query_string = SNPRINTF(sql_query_string, query_size, "DELETE FROM mail_text_tbl WHERE mail_id in (");
 
-       for(i = 0; i < number_of_mails; i++)
+       for (i = 0; i < number_of_mails; i++)
                cur_sql_query_string += SNPRINTF_OFFSET(sql_query_string, cur_sql_query_string, query_size, "%d,", mail_ids[i]);
 
        last_comma = rindex(sql_query_string, ',');
-       *last_comma = ')'; /* replace , with ) */
+       *last_comma = ')'; /* replace , with) */
 
        EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
        error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -10143,7 +10088,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(char *multi_user_name, int ac
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], transaction[%d], err_code[%p]", account_id, transaction, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID)  {
+       if (account_id < FIRST_ACCOUNT_ID) {
                EM_DEBUG_EXCEPTION("account_id[%d]", account_id);
 
                if (err_code != NULL)
@@ -10167,7 +10112,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(char *multi_user_name, int ac
        }
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_LOG(" no mail found...");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
        }
@@ -10182,7 +10127,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_account(char *multi_user_name, int ac
        }
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_LOG("No mail found...");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
        }
@@ -10210,8 +10155,8 @@ FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
        if (error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_MAIL_DELETE_WITH_ACCOUNT, account_id, 0 , NULL, 0))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event Failed [ NOTI_MAIL_DELETE_ALL ]");
+               if (!emcore_notify_storage_event(NOTI_MAIL_DELETE_WITH_ACCOUNT, account_id, 0 , NULL, 0))
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_eventFailed [ NOTI_MAIL_DELETE_ALL ]");
        }
 
        if (err_code != NULL)
@@ -10225,7 +10170,7 @@ INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(char *multi_user_name, emstor
 {
        EM_DEBUG_FUNC_BEGIN("mailbox[%p], transaction[%d], err_code[%p]", mailbox, transaction, err_code);
 
-       if (mailbox == NULL)  {
+       if (mailbox == NULL) {
                EM_DEBUG_EXCEPTION("mailbox [%p]", mailbox);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -10291,7 +10236,7 @@ FINISH_OFF:
 
        if (error == EMAIL_ERROR_NONE) {
                if (!emcore_notify_storage_event(NOTI_MAIL_DELETE_ALL, mailbox->account_id, mailbox->mailbox_id , mailbox->mailbox_name, 0))
-                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event Failed [ NOTI_MAIL_DELETE_ALL ] >>>> ");
+                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventFailed [ NOTI_MAIL_DELETE_ALL ] >>>> ");
        }
 
        if (err_code != NULL)
@@ -10305,8 +10250,8 @@ INTERNAL_FUNC int emstorage_free_mail(emstorage_mail_tbl_t** mail_list, int coun
 {
        EM_DEBUG_FUNC_BEGIN("mail_list[%p], count[%d], err_code[%p]", mail_list, count, err_code);
 
-       if (count > 0)  {
-               if ((mail_list == NULL) || (*mail_list == NULL))  {
+       if (count > 0) {
+               if ((mail_list == NULL) || (*mail_list == NULL)) {
                        EM_DEBUG_EXCEPTION("mail_ilst[%p], count[%d]", mail_list, count);
 
                        if (err_code)
@@ -10379,7 +10324,7 @@ INTERNAL_FUNC int emstorage_get_attachment_count(char *multi_user_name, int mail
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%d], count[%p], transaction[%d], err_code[%p]", mail_id, count, transaction, err_code);
 
-       if (mail_id <= 0 || !count)  {
+       if (mail_id <= 0 || !count) {
                EM_DEBUG_EXCEPTION("mail_id[%d], count[%p]", mail_id, count);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -10398,7 +10343,7 @@ INTERNAL_FUNC int emstorage_get_attachment_count(char *multi_user_name, int mail
        char **result;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -10420,7 +10365,7 @@ INTERNAL_FUNC int emstorage_get_attachment_list(char *multi_user_name, int input
 {
        EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], input_transaction[%d], output_attachment_list[%p], output_attachment_count[%p]", input_mail_id, input_transaction, output_attachment_list, output_attachment_count);
 
-       if (input_mail_id <= 0 || !output_attachment_list || !output_attachment_count)  {
+       if (input_mail_id <= 0 || !output_attachment_list || !output_attachment_count) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -10437,21 +10382,21 @@ INTERNAL_FUNC int emstorage_get_attachment_list(char *multi_user_name, int input
        EMSTORAGE_START_READ_TRANSACTION(input_transaction);
        SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT COUNT(*) FROM mail_attachment_tbl WHERE mail_id = %d", input_mail_id);
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *output_attachment_count = atoi(result[1]);
        sqlite3_free_table(result);
 
-       if(*output_attachment_count == 0) {
+       if (*output_attachment_count == 0) {
                error = EMAIL_ERROR_NONE;
                goto FINISH_OFF;
        }
 
        p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * (*output_attachment_count));
 
-       if (!p_data_tbl)  {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+       if (!p_data_tbl) {
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -10460,34 +10405,34 @@ INTERNAL_FUNC int emstorage_get_attachment_list(char *multi_user_name, int input
        EM_DEBUG_LOG_SEC("sql_query_string [%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },   ("sqlite3_step fail:%d", rc));
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },  ("sqlite3_step fail:%d", rc));
 
-       if (rc == SQLITE_DONE)  {
+       if (rc == SQLITE_DONE) {
                EM_DEBUG_EXCEPTION("no matched attachment found...");
                error = EMAIL_ERROR_ATTACHMENT_NOT_FOUND;
                goto FINISH_OFF;
        }
-       for (i = 0; i < *output_attachment_count; i++)  {
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].attachment_id), ATTACHMENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
+       for (i = 0; i < *output_attachment_count; i++) {
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].attachment_id), ATTACHMENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
                _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].attachment_name), 0, ATTACHMENT_NAME_IDX_IN_MAIL_ATTACHMENT_TBL);
                _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].attachment_path), 0, ATTACHMENT_PATH_IDX_IN_MAIL_ATTACHMENT_TBL);
                _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].content_id), 0, CONTENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].attachment_size), ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].mail_id), MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].account_id), ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].mailbox_id), MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].attachment_save_status), ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].attachment_drm_type), ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].attachment_drm_method), ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL);
-               _get_stmt_field_data_int   (hStmt, &(p_data_tbl[i].attachment_inline_content_status), ATTACHMENT_INLINE_CONTENT_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].attachment_size), ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].mail_id), MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].account_id), ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].mailbox_id), MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].attachment_save_status), ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].attachment_drm_type), ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].attachment_drm_method), ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL);
+               _get_stmt_field_data_int(hStmt, &(p_data_tbl[i].attachment_inline_content_status), ATTACHMENT_INLINE_CONTENT_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL);
                _get_stmt_field_data_string(hStmt, &(p_data_tbl[i].attachment_mime_type), 0, ATTACHMENT_MIME_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL);
                EM_DEBUG_LOG("attachment[%d].attachment_id : %d", i, p_data_tbl[i].attachment_id);
                EM_DEBUG_LOG("attachment_mime_type : %s", p_data_tbl[i].attachment_mime_type);
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc));
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; }, ("sqlite3_step fail:%d", rc));
        }
 
 FINISH_OFF:
@@ -10499,8 +10444,8 @@ FINISH_OFF:
 
        if (hStmt) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+               if (rc != SQLITE_OK) {
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                        if (*output_attachment_list)
                                emstorage_free_attachment(output_attachment_list, *output_attachment_count, NULL); /* prevent */
@@ -10517,7 +10462,7 @@ INTERNAL_FUNC int emstorage_get_attachment(char *multi_user_name, int attachment
 {
        EM_DEBUG_FUNC_BEGIN("attachment_id[%d], attachment[%p], transaction[%d], err_code[%p]", attachment_id, attachment, transaction, err_code);
 
-       if (attachment_id <= 0 || !attachment)  {
+       if (attachment_id <= 0 || !attachment) {
                EM_DEBUG_EXCEPTION("attachment_id[%d], attachment[%p]", attachment_id, attachment);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -10537,23 +10482,23 @@ INTERNAL_FUNC int emstorage_get_attachment(char *multi_user_name, int attachment
        sqlite3_stmt* hStmt = NULL;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_LOG_DEV (" before sqlite3_prepare hStmt = %p", hStmt);
+       EM_DEBUG_LOG_DEV(" before sqlite3_prepare hStmt = %p", hStmt);
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_prepare failed [%d] [%s]", rc, sql_query_string));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step failed [%d] [%s]", rc, sql_query_string));
 
-       if (rc == SQLITE_DONE)  {
-               EM_DEBUG_LOG ("no matched attachment found...");
+       if (rc == SQLITE_DONE) {
+               EM_DEBUG_LOG("no matched attachment found...");
                error = EMAIL_ERROR_ATTACHMENT_NOT_FOUND;
                goto FINISH_OFF;
        }
 
-       if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1)))  {
+       if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1))) {
                EM_DEBUG_EXCEPTION("malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -10584,9 +10529,9 @@ FINISH_OFF:
        if (ret == true)
                *attachment = p_data_tbl;
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize failed [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -10605,7 +10550,7 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(char *multi_user_name, int mail_i
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%d], nth[%d], attachment_tbl[%p], transaction[%d], err_code[%p]", mail_id, nth, attachment_tbl, transaction, err_code);
 
-       if (mail_id <= 0 || nth <= 0 || !attachment_tbl)  {
+       if (mail_id <= 0 || nth <= 0 || !attachment_tbl) {
                EM_DEBUG_EXCEPTION(" mail_id[%d], nth[%d], attachment[%p]", mail_id, nth, attachment_tbl);
 
                if (err_code != NULL)
@@ -10628,21 +10573,21 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(char *multi_user_name, int mail_i
        DB_STMT hStmt = NULL;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
-       if (rc == SQLITE_DONE)  {
+       if (rc == SQLITE_DONE) {
                EM_DEBUG_EXCEPTION("no matched attachment found: mail_id[%d] nth[%d]", mail_id, nth);
                error = EMAIL_ERROR_ATTACHMENT_NOT_FOUND;
                goto FINISH_OFF;
        }
 
-       if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1)))  {
+       if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1))) {
                EM_DEBUG_EXCEPTION(" malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -10668,7 +10613,7 @@ INTERNAL_FUNC int emstorage_get_attachment_nth(char *multi_user_name, int mail_i
 #ifdef __ATTACHMENT_OPTI__
                p_data_tbl->encoding = sqlite3_column_int(hStmt, ENCODING_IDX_IN_MAIL_ATTACHMENT_TBL);
                if ((p = (char *)sqlite3_column_text(hStmt, SECTION_IDX_IN_MAIL_ATTACHMENT_TBL)) && (int)EM_SAFE_STRLEN(p))
-                       p_data_tbl->section= cpy_str(p);
+                       p_data_tbl->section = cpy_str(p);
 #endif
        ret = true;
 
@@ -10676,9 +10621,9 @@ FINISH_OFF:
        if (ret == true)
                *attachment_tbl = p_data_tbl;
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -10697,7 +10642,7 @@ INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *multi_user_n
 {
        EM_DEBUG_FUNC_BEGIN("attachment_path[%p], attachment[%p], transaction[%d], err_code[%p]", attachment_path, attachment, transaction, err_code);
 
-       if (attachment_path == NULL || !attachment)  {
+       if (attachment_path == NULL || !attachment) {
                EM_DEBUG_EXCEPTION("attachment_path[%p], attachment[%p]", attachment_path, attachment);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -10717,23 +10662,23 @@ INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *multi_user_n
        sqlite3_stmt* hStmt = NULL;
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_LOG_DEV ("before sqlite3_prepare hStmt = %p", hStmt);
+       EM_DEBUG_LOG_DEV("before sqlite3_prepare hStmt = %p", hStmt);
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_prepare failed [%d] [%s]", rc, sql_query_string));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step failed [%d] [%s]", rc, sql_query_string));
 
-       if (rc == SQLITE_DONE)  {
-               EM_DEBUG_LOG ("no matched attachment found...");
+       if (rc == SQLITE_DONE) {
+               EM_DEBUG_LOG("no matched attachment found...");
                error = EMAIL_ERROR_ATTACHMENT_NOT_FOUND;
                goto FINISH_OFF;
        }
 
-       if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1)))  {
+       if (!(p_data_tbl = (emstorage_attachment_tbl_t*)em_malloc(sizeof(emstorage_attachment_tbl_t) * 1))) {
                EM_DEBUG_EXCEPTION("malloc failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -10764,9 +10709,9 @@ FINISH_OFF:
        if (ret == true)
                *attachment = p_data_tbl;
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize failed [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -10785,7 +10730,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int m
 {
        EM_DEBUG_FUNC_BEGIN("mail_id[%d], type[%d], attachment[%p], transaction[%d], err_code[%p]", mail_id, type, attachment, transaction, err_code);
 
-       if (mail_id <= 0 || !attachment)  {
+       if (mail_id <= 0 || !attachment) {
                EM_DEBUG_EXCEPTION(" mail_id[%d], type[%d], attachment[%p]", mail_id, type, attachment);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -10803,10 +10748,10 @@ INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int m
 
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
 
-       switch (type)  {
+       switch (type) {
                case UPDATE_MAILBOX:
                                EM_DEBUG_LOG("UPDATE_MAILBOX");
-                       if (!attachment->mailbox_id)  {
+                       if (!attachment->mailbox_id) {
                                EM_DEBUG_EXCEPTION(" attachment->mailbox_id[%d]", attachment->mailbox_id);
                                error = EMAIL_ERROR_INVALID_PARAM;
                                goto FINISH_OFF;
@@ -10816,7 +10761,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int m
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
                        EM_DEBUG_LOG(" Before sqlite3_prepare hStmt = %p", hStmt);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                        _bind_stmt_field_data_int(hStmt, i++, attachment->mailbox_id);
@@ -10824,7 +10769,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int m
 
                case UPDATE_SAVENAME:
                        EM_DEBUG_LOG("UPDATE_SAVENAME");
-                       if (!attachment->attachment_path)  {
+                       if (!attachment->attachment_path) {
                                EM_DEBUG_EXCEPTION(" attachment->attachment_path[%p]", attachment->attachment_path);
                                error = EMAIL_ERROR_INVALID_PARAM;
                                goto FINISH_OFF;
@@ -10843,7 +10788,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int m
 
                        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
                        EM_DEBUG_LOG(" Before sqlite3_prepare hStmt = %p", hStmt);
-                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+                       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                        _bind_stmt_field_data_int(hStmt, i++, attachment->attachment_size);
@@ -10859,7 +10804,7 @@ INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int m
        EM_DEBUG_LOG_SEC("query = [%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
        ret = true;
 
@@ -10867,9 +10812,9 @@ FINISH_OFF:
 
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -10897,7 +10842,7 @@ INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mail
        DB_STMT hStmt = NULL;
        emstorage_mailbox_tbl_t *old_mailbox_data = NULL;
 
-       if (input_mailbox_id <= 0 || !input_new_mailbox_name || !input_new_mailbox_alias)  {
+       if (input_mailbox_id <= 0 || !input_new_mailbox_name || !input_new_mailbox_alias) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -10918,8 +10863,8 @@ INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mail
 
        if ((error = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &old_mailbox_data)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", error);
-               EM_SAFE_FREE (replaced_mailbox_name);
-               EM_SAFE_FREE (replaced_alias);
+               EM_SAFE_FREE(replaced_mailbox_name);
+               EM_SAFE_FREE(replaced_alias);
                return error;
        }
 
@@ -10933,7 +10878,7 @@ INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mail
 
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, input_transaction, error);
 
-       if(input_eas_data && input_eas_data_length > 0) {
+       if (input_eas_data && input_eas_data_length > 0) {
                SNPRINTF(sql_query_string, sizeof(sql_query_string),
                        "UPDATE mail_box_tbl SET"
                        " mailbox_name = ?"
@@ -10944,16 +10889,15 @@ INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mail
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
-               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
-               _bind_stmt_field_data_string(hStmt, field_idx++ , input_new_mailbox_name, 0, ATTACHMENT_NAME_LEN_IN_MAIL_ATTACHMENT_TBL);
-               _bind_stmt_field_data_string(hStmt, field_idx++ , input_new_mailbox_alias, 0, ATTACHMENT_PATH_LEN_IN_MAIL_ATTACHMENT_TBL);
-               _bind_stmt_field_data_blob  (hStmt, field_idx++ , input_eas_data, input_eas_data_length);
-               _bind_stmt_field_data_int   (hStmt, field_idx++ , input_eas_data_length);
-               _bind_stmt_field_data_int   (hStmt, field_idx++ , input_mailbox_id);
-       }
-       else {
+               _bind_stmt_field_data_string(hStmt, field_idx++, input_new_mailbox_name, 0, ATTACHMENT_NAME_LEN_IN_MAIL_ATTACHMENT_TBL);
+               _bind_stmt_field_data_string(hStmt, field_idx++, input_new_mailbox_alias, 0, ATTACHMENT_PATH_LEN_IN_MAIL_ATTACHMENT_TBL);
+               _bind_stmt_field_data_blob(hStmt, field_idx++, input_eas_data, input_eas_data_length);
+               _bind_stmt_field_data_int(hStmt, field_idx++, input_eas_data_length);
+               _bind_stmt_field_data_int(hStmt, field_idx++, input_mailbox_id);
+       } else {
                SNPRINTF(sql_query_string, sizeof(sql_query_string),
                                "UPDATE mail_box_tbl SET"
                                " mailbox_name = ?"
@@ -10962,19 +10906,19 @@ INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mail
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
-               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
                _bind_stmt_field_data_string(hStmt, field_idx++ , input_new_mailbox_name, 0, ATTACHMENT_NAME_LEN_IN_MAIL_ATTACHMENT_TBL);
                _bind_stmt_field_data_string(hStmt, field_idx++ , input_new_mailbox_alias, 0, ATTACHMENT_PATH_LEN_IN_MAIL_ATTACHMENT_TBL);
-               _bind_stmt_field_data_int   (hStmt, field_idx++ , input_mailbox_id);
+               _bind_stmt_field_data_int(hStmt, field_idx++ , input_mailbox_id);
        }
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (sqlite3_changes(local_db_handle) == 0)
@@ -10985,12 +10929,11 @@ INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mail
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, input_transaction, ret, error);
        if (error == EMAIL_ERROR_NONE) {
-               if (!emcore_notify_storage_event (NOTI_MAILBOX_RENAME, account_id, input_mailbox_id, input_new_mailbox_name, 0))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event Failed [ NOTI_MAILBOX_RENAME ] >>>> ");
-       }
-       else {
-               if (!emcore_notify_storage_event (NOTI_MAILBOX_RENAME_FAIL, account_id, input_mailbox_id, input_new_mailbox_name, error))
-                       EM_DEBUG_EXCEPTION ("emcore_notify_storage_event Failed [ NOTI_MAILBOX_RENAME_FAIL ] >>>> ");
+               if (!emcore_notify_storage_event(NOTI_MAILBOX_RENAME, account_id, input_mailbox_id, input_new_mailbox_name, 0))
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_eventFailed [ NOTI_MAILBOX_RENAME ] >>>> ");
+       } else {
+               if (!emcore_notify_storage_event(NOTI_MAILBOX_RENAME_FAIL, account_id, input_mailbox_id, input_new_mailbox_name, error))
+                       EM_DEBUG_EXCEPTION("emcore_notify_storage_eventFailed [ NOTI_MAILBOX_RENAME_FAIL ] >>>> ");
        }
 
        EM_SAFE_FREE(replaced_mailbox_name);
@@ -10999,9 +10942,9 @@ FINISH_OFF:
        if (old_mailbox_data)
                emstorage_free_mailbox(&old_mailbox_data, 1, NULL);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -11019,7 +10962,7 @@ INTERNAL_FUNC int emstorage_get_new_attachment_no(char *multi_user_name, int *at
        char *sql = "SELECT max(rowid) FROM mail_attachment_tbl;";
        char **result;
 
-       if (!attachment_no)  {
+       if (!attachment_no) {
                EM_DEBUG_EXCEPTION("Invalid attachment");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -11032,7 +10975,7 @@ INTERNAL_FUNC int emstorage_get_new_attachment_no(char *multi_user_name, int *at
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
        if (NULL == result[1])
@@ -11068,7 +11011,7 @@ INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_atta
        DB_STMT hStmt = NULL;
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
 
-       if (!attachment_tbl)  {
+       if (!attachment_tbl) {
                EM_DEBUG_EXCEPTION("attachment_tbl[%p], iscopy[%d]", attachment_tbl, iscopy);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -11080,10 +11023,10 @@ INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_atta
        sql = "SELECT max(rowid) FROM mail_attachment_tbl;";
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
-       if (NULL==result[1]) rc = 1;
+       if (NULL == result[1]) rc = 1;
        else rc = atoi(result[1]) + 1;
        sqlite3_free_table(result);
 
@@ -11091,7 +11034,7 @@ INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_atta
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_attachment_tbl VALUES "
-               "( ?"   /* attachment_id */
+               "(?"    /* attachment_id */
                ", ?"   /* attachment_name */
                ", ?"   /* attachment_path */
                ", ?"   /* content_id */
@@ -11112,21 +11055,21 @@ INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_atta
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
-       _bind_stmt_field_data_int   (hStmt, ATTACHMENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_id);
+       _bind_stmt_field_data_int(hStmt, ATTACHMENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_id);
        _bind_stmt_field_data_string(hStmt, ATTACHMENT_NAME_IDX_IN_MAIL_ATTACHMENT_TBL, (char*)attachment_tbl->attachment_name, 0, ATTACHMENT_NAME_LEN_IN_MAIL_ATTACHMENT_TBL);
        _bind_stmt_field_data_string(hStmt, ATTACHMENT_PATH_IDX_IN_MAIL_ATTACHMENT_TBL, (char*)attachment_tbl->attachment_path, 0, ATTACHMENT_PATH_LEN_IN_MAIL_ATTACHMENT_TBL);
        _bind_stmt_field_data_string(hStmt, CONTENT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, (char*)attachment_tbl->content_id, 0, CONTENT_ID_LEN_IN_MAIL_ATTACHMENT_TBL);
-       _bind_stmt_field_data_int   (hStmt, ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_size);
-       _bind_stmt_field_data_int   (hStmt, MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->mail_id);
-       _bind_stmt_field_data_int   (hStmt, ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->account_id);
-       _bind_stmt_field_data_int   (hStmt, MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->mailbox_id);
-       _bind_stmt_field_data_int   (hStmt, ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_save_status);
-       _bind_stmt_field_data_int   (hStmt, ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_drm_type);
-       _bind_stmt_field_data_int   (hStmt, ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_drm_method);
-       _bind_stmt_field_data_int   (hStmt, ATTACHMENT_INLINE_CONTENT_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_inline_content_status);
+       _bind_stmt_field_data_int(hStmt, ATTACHMENT_SIZE_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_size);
+       _bind_stmt_field_data_int(hStmt, MAIL_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->mail_id);
+       _bind_stmt_field_data_int(hStmt, ACCOUNT_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->account_id);
+       _bind_stmt_field_data_int(hStmt, MAILBOX_ID_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->mailbox_id);
+       _bind_stmt_field_data_int(hStmt, ATTACHMENT_SAVE_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_save_status);
+       _bind_stmt_field_data_int(hStmt, ATTACHMENT_DRM_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_drm_type);
+       _bind_stmt_field_data_int(hStmt, ATTACHMENT_DRM_METHOD_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_drm_method);
+       _bind_stmt_field_data_int(hStmt, ATTACHMENT_INLINE_CONTENT_STATUS_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->attachment_inline_content_status);
        _bind_stmt_field_data_string(hStmt, ATTACHMENT_MIME_TYPE_IDX_IN_MAIL_ATTACHMENT_TBL, (char*)attachment_tbl->attachment_mime_type, 0, ATTACHMENT_MIME_TYPE_LEN_IN_MAIL_ATTACHMENT_TBL);
 #ifdef __ATTACHMENT_OPTI__
        _bind_stmt_field_data_int(hStmt, ENCODING_IDX_IN_MAIL_ATTACHMENT_TBL, attachment_tbl->encoding);
@@ -11135,13 +11078,13 @@ INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_atta
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_LOG(" no matched mail found...");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
@@ -11152,9 +11095,9 @@ INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_atta
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -11176,7 +11119,7 @@ INTERNAL_FUNC int emstorage_update_attachment(char *multi_user_name, emstorage_a
        DB_STMT hStmt = NULL;
        char sql_query_string[QUERY_SIZE] = {0, };
 
-       if (!attachment_tbl)  {
+       if (!attachment_tbl) {
                EM_DEBUG_EXCEPTION(" attachment_tbl[%p] ", attachment_tbl);
                if (err_code)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -11206,32 +11149,32 @@ INTERNAL_FUNC int emstorage_update_attachment(char *multi_user_name, emstorage_a
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        _bind_stmt_field_data_string(hStmt, field_idx++ , (char*)attachment_tbl->attachment_name, 0, ATTACHMENT_NAME_LEN_IN_MAIL_ATTACHMENT_TBL);
        _bind_stmt_field_data_string(hStmt, field_idx++ , (char*)attachment_tbl->attachment_path, 0, ATTACHMENT_PATH_LEN_IN_MAIL_ATTACHMENT_TBL);
        _bind_stmt_field_data_string(hStmt, field_idx++ , (char*)attachment_tbl->content_id, 0, CONTENT_ID_LEN_IN_MAIL_ATTACHMENT_TBL);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->attachment_size);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->mail_id);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->account_id);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->mailbox_id);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->attachment_save_status);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->attachment_drm_type);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->attachment_drm_method);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->attachment_inline_content_status);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->attachment_size);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->mail_id);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->account_id);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->mailbox_id);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->attachment_save_status);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->attachment_drm_type);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->attachment_drm_method);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->attachment_inline_content_status);
        _bind_stmt_field_data_string(hStmt, field_idx++ , (char*)attachment_tbl->attachment_mime_type, 0, ATTACHMENT_MIME_TYPE_LEN_IN_MAIL_ATTACHMENT_TBL);
-       _bind_stmt_field_data_int   (hStmt, field_idx++ , attachment_tbl->attachment_id);
+       _bind_stmt_field_data_int(hStmt, field_idx++ , attachment_tbl->attachment_id);
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_FULL == rc), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_LOG(" no matched mail found...");
                error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
@@ -11241,9 +11184,9 @@ INTERNAL_FUNC int emstorage_update_attachment(char *multi_user_name, emstorage_a
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -11260,7 +11203,7 @@ INTERNAL_FUNC int emstorage_delete_attachment_on_db(char *multi_user_name, int a
 {
        EM_DEBUG_FUNC_BEGIN("attachment_id[%d], transaction[%d], err_code[%p]", attachment_id, transaction, err_code);
 
-       if (attachment_id < 0)  {
+       if (attachment_id < 0) {
                EM_DEBUG_EXCEPTION("attachment_id[%d]", attachment_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -11302,7 +11245,7 @@ INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(char *multi_user_name
        char sql_query_string[QUERY_SIZE] = {0, };
        sqlite3 *local_db_handle = NULL;
 
-       if (mail_id <= 0)  {
+       if (mail_id <= 0) {
                EM_DEBUG_EXCEPTION("mail_id[%d]", mail_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -11382,8 +11325,8 @@ INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t** attachm
 {
        EM_DEBUG_FUNC_BEGIN("attachment_tbl_list[%p], count[%d], err_code[%p]", attachment_tbl_list, count, err_code);
 
-       if (count > 0)  {
-               if ((attachment_tbl_list == NULL) || (*attachment_tbl_list == NULL))  {
+       if (count > 0) {
+               if ((attachment_tbl_list == NULL) || (*attachment_tbl_list == NULL)) {
                        EM_DEBUG_LOG("Nothing to free: attachment_tbl_list[%p], count[%d]", attachment_tbl_list, count);
                        if (err_code != NULL)
                                *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -11393,7 +11336,7 @@ INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t** attachm
                emstorage_attachment_tbl_t* p = *attachment_tbl_list;
                int i;
 
-               for (i = 0; i < count; i++)  {
+               for (i = 0; i < count; i++) {
                        EM_SAFE_FREE(p[i].attachment_name);
                        EM_SAFE_FREE(p[i].attachment_path);
                        EM_SAFE_FREE(p[i].content_id);
@@ -11480,7 +11423,7 @@ INTERNAL_FUNC int emstorage_is_mailbox_full(char *multi_user_name, int account_i
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox[%p], result[%p], err_code[%p]", account_id, mailbox, result, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || !mailbox || !result)  {
+       if (account_id < FIRST_ACCOUNT_ID || !mailbox || !result) {
                if (mailbox)
                        EM_DEBUG_EXCEPTION("Invalid Parameter. accoun_id[%d], mailbox[%p]", account_id, mailbox);
 
@@ -11543,8 +11486,8 @@ INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transacti
        chmod(MAILTEMP, 0777);
 
        /*  first clear index. */
-       while (indexes->object_name)  {
-               if (indexes->data_flag)  {
+       while (indexes->object_name) {
+               if (indexes->data_flag) {
                        SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP index %s", indexes->object_name);
                        error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
                        if (error != EMAIL_ERROR_NONE) {
@@ -11555,8 +11498,8 @@ INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transacti
                indexes++;
        }
 
-       while (tables->object_name)  {
-               if (tables->data_flag)  {
+       while (tables->object_name) {
+               if (tables->data_flag) {
                        SNPRINTF(sql_query_string, sizeof(sql_query_string), "DROP table %s", tables->object_name);
                        error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
                        if (error != EMAIL_ERROR_NONE) {
@@ -11612,11 +11555,11 @@ INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id,
        int ret = false;
        int error = EMAIL_ERROR_NONE;
        char *dir_name = NULL;
-       char create_dir[1024]={0};
+       char create_dir[1024] = {0};
        char *temp_file = NULL;
        char *prefix_path = NULL;
 
-       if (!move_buf || !path_buf || account_id < FIRST_ACCOUNT_ID || mail_id < 0 || atch_id < 0)  {
+       if (!move_buf || !path_buf || account_id < FIRST_ACCOUNT_ID || mail_id < 0 || atch_id < 0) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d], atch_id[%d], fname[%p], move_buf[%p], path_buf[%p]", account_id, mail_id, atch_id, fname, move_buf, path_buf);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -11723,7 +11666,7 @@ INTERNAL_FUNC int emstorage_get_dele_name(char *multi_user_name, int account_id,
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], atch_id[%d], fname[%p], name_buf[%p], err_code[%p]", account_id, mail_id, atch_id, fname, name_buf, err_code);
 
-       if (!name_buf || account_id < FIRST_ACCOUNT_ID)  {
+       if (!name_buf || account_id < FIRST_ACCOUNT_ID) {
                EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d], atch_id[%d], fname[%p], name_buf[%p]", account_id, mail_id, atch_id, fname, name_buf);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -11772,7 +11715,7 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
                prefix_path = strdup("");
        }
 
-       if (account_id >= FIRST_ACCOUNT_ID)  {
+       if (account_id >= FIRST_ACCOUNT_ID) {
                SNPRINTF(buf, sizeof(buf), "%s%s%s%s%d", prefix_path,
                                                                                                DIR_SEPERATOR,
                                                                                                MAILHOME,
@@ -11780,18 +11723,17 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
                                                                                                account_id);
 
                if (stat(buf, &sbuf) == 0) {
-                       if ((sbuf.st_mode & S_IFMT) != S_IFDIR)  {
+                       if ((sbuf.st_mode & S_IFMT) != S_IFDIR) {
                                EM_DEBUG_EXCEPTION(" a object which isn't directory aleady exists");
                                error = EMAIL_ERROR_SYSTEM_FAILURE;
                                goto FINISH_OFF;
                        }
-               }
-               else  {
+               } else {
                        if (mkdir(buf, DIRECTORY_PERMISSION) != 0) {
                                EM_DEBUG_EXCEPTION(" mkdir failed [%s]", buf);
                                EM_DEBUG_EXCEPTION("mkdir failed: %s", EM_STRERROR(errno_buf));
                                error = EMAIL_ERROR_SYSTEM_FAILURE;
-                               if(errno == 28)
+                               if (errno == 28)
                                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
                        }
@@ -11802,10 +11744,10 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
                }
        }
 
-       if (mail_id > 0)  {
+       if (mail_id > 0) {
                int space_left_in_buffer = sizeof(buf) - EM_SAFE_STRLEN(buf);
 
-               if (account_id < FIRST_ACCOUNT_ID)  {
+               if (account_id < FIRST_ACCOUNT_ID) {
                        EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d], atch_id[%d]", account_id, mail_id, atch_id);
                        error = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
@@ -11820,18 +11762,17 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
                SNPRINTF(buf+EM_SAFE_STRLEN(buf), space_left_in_buffer, "%s%d", DIR_SEPERATOR, mail_id);
 
                if (stat(buf, &sbuf) == 0) {
-                       if ((sbuf.st_mode & S_IFMT) != S_IFDIR)  {
+                       if ((sbuf.st_mode & S_IFMT) != S_IFDIR) {
                                EM_DEBUG_EXCEPTION(" a object which isn't directory aleady exists");
                                error = EMAIL_ERROR_SYSTEM_FAILURE;
                                goto FINISH_OFF;
                        }
-               }
-               else  {
+               } else {
                        if (mkdir(buf, DIRECTORY_PERMISSION) != 0) {
                                EM_DEBUG_EXCEPTION("mkdir failed [%s]", buf);
                                EM_DEBUG_EXCEPTION("mkdir failed [%d][%s]", errno, EM_STRERROR(errno_buf));
                                error = EMAIL_ERROR_SYSTEM_FAILURE;
-                               if(errno == 28)
+                               if (errno == 28)
                                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
                        }
@@ -11842,10 +11783,9 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
                }
        }
 
-       if (atch_id > 0)  {
-               if (account_id < FIRST_ACCOUNT_ID || mail_id <= 0)  {
+       if (atch_id > 0) {
+               if (account_id < FIRST_ACCOUNT_ID || mail_id <= 0) {
                        EM_DEBUG_EXCEPTION(" account_id[%d], mail_id[%d], atch_id[%d]", account_id, mail_id, atch_id);
-
                        error = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
                }
@@ -11853,18 +11793,16 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
                SNPRINTF(buf+EM_SAFE_STRLEN(buf), sizeof(buf)-(EM_SAFE_STRLEN(buf)+1), "%s%d", DIR_SEPERATOR, atch_id);
 
                if (stat(buf, &sbuf) == 0) {
-                       if ((sbuf.st_mode & S_IFMT) != S_IFDIR)  {
+                       if ((sbuf.st_mode & S_IFMT) != S_IFDIR) {
                                EM_DEBUG_EXCEPTION(" a object which isn't directory aleady exists");
-
                                error = EMAIL_ERROR_SYSTEM_FAILURE;
                                goto FINISH_OFF;
                        }
-               }
-               else  {
+               } else {
                        if (mkdir(buf, DIRECTORY_PERMISSION) != 0) {
                                EM_DEBUG_EXCEPTION(" mkdir failed [%s]", buf);
                                error = EMAIL_ERROR_SYSTEM_FAILURE;
-                               if(errno == 28)
+                               if (errno == 28)
                                        error = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
                        }
@@ -11903,7 +11841,7 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s
        char buf[FILE_MAX_BUFFER_SIZE] = {0};
        char errno_buf[ERRNO_BUF_SIZE] = {0};
 
-       if (!src_file || !dst_file)  {
+       if (!src_file || !dst_file) {
                EM_DEBUG_EXCEPTION("src_file[%p], dst_file[%p]", src_file, dst_file);
 
                error = EMAIL_ERROR_INVALID_PARAM;
@@ -11932,7 +11870,7 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s
        memset(buf, 0x00, FILE_MAX_BUFFER_SIZE);
 
        while ((nread = read(fp_src, buf, FILE_MAX_BUFFER_SIZE)) > 0) {
-               if (nread > 0 && nread <= FILE_MAX_BUFFER_SIZE)  {
+               if (nread > 0 && nread <= FILE_MAX_BUFFER_SIZE) {
                        EM_DEBUG_LOG("Nread Value [%d]", nread);
                        char *buf_ptr;
                        ssize_t byte_written = 0;
@@ -11940,7 +11878,7 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s
                        buf_ptr = buf;
                        errno = 0;
 
-                       while(remain_byte > 0 && buf_ptr && errno == 0) {
+                       while (remain_byte > 0 && buf_ptr && errno == 0) {
                                byte_written = write(fp_dst, buf_ptr, remain_byte);
 
                                if (byte_written < 0) {
@@ -11966,14 +11904,14 @@ INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_s
        ret = true;
 
 FINISH_OFF:
-       EM_SAFE_CLOSE (fp_src);
+       EM_SAFE_CLOSE(fp_src);
 
-       if (fp_dst >=0) { /*prevent 24474*/
+       if (fp_dst >= 0) { /*prevent 24474*/
                if (sync_status) {
                        EM_DEBUG_LOG("Before fsync");
                        fsync(fp_dst);
                }
-               close (fp_dst);
+               close(fp_dst);
        }
 
        if (nread < 0 || error == EMAIL_ERROR_UNKNOWN)
@@ -12020,7 +11958,7 @@ static int _get_temp_file_name(char **filename, int *err_code)
        SNPRINTF(tempname, sizeof(tempname), "%s%c%d", MAILTEMP, '/', rand());
 
        char *p = EM_SAFE_STRDUP(tempname);
-       if (p == NULL)  {
+       if (p == NULL) {
                EM_DEBUG_EXCEPTION(" strdup failed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -12085,7 +12023,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in
        }
 
        if ((nread = fread(buf, 1, buf_size, fp_src)) > 0) {
-               if (nread > 0 && nread <= buf_size)  {
+               if (nread > 0 && nread <= buf_size) {
                        EM_DEBUG_LOG(">>>> Nread Value [ %d ] ", nread);
 
                        /**
@@ -12108,8 +12046,9 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in
 
                        if (match_str == NULL) {
                                EM_DEBUG_LOG(">>>>emstorage_add_content_type 3 ");
-                               if (fp_src !=NULL) {
-                                       fclose(fp_src);fp_src = NULL;
+                               if (fp_src != NULL) {
+                                       fclose(fp_src);
+                                       fp_src = NULL;
                                }
                                data_count_to_written = EM_SAFE_STRLEN(low_char_set)+strlen(CONTENT_DATA)+1; /*prevent 34359*/
                                buf1 = (char *)calloc(1, data_count_to_written);
@@ -12148,8 +12087,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in
                                                        EM_DEBUG_EXCEPTION(" Error Occured while writing Old data : [%d ] bytes written ", nwritten);
                                                        error = EMAIL_ERROR_SYSTEM_FAILURE;
                                                        goto FINISH_OFF;
-                                               }
-                                               else {
+                                               } else {
                                                        EM_DEBUG_LOG(">>>> OLD data appended [ %d ] ", nwritten);
 
                                                        if (!emstorage_move_file(temp_file_name, file_path, false, &err)) {
@@ -12158,8 +12096,7 @@ INTERNAL_FUNC int emstorage_add_content_type(char *file_path, char *char_set, in
                                                        }
                                                }
 
-                                       }
-                                       else {
+                                       } else {
                                                EM_DEBUG_EXCEPTION(" Error Occured while writing New data : [%d ] bytes written ", nwritten);
                                                error = EMAIL_ERROR_SYSTEM_FAILURE;
                                                goto FINISH_OFF;
@@ -12186,8 +12123,10 @@ FINISH_OFF:
                fclose(fp_dest);
                fp_dest = NULL;
        }
+
        if (err_code)
                *err_code = error;
+
        EM_DEBUG_FUNC_END("ret [%d]", ret);
        return ret;
 
@@ -12201,7 +12140,7 @@ INTERNAL_FUNC int emstorage_move_file(char *src_file, char *dst_file, int sync_s
        int error = EMAIL_ERROR_NONE;
        char errno_buf[ERRNO_BUF_SIZE] = {0};
 
-       if (src_file == NULL || dst_file == NULL)  {
+       if (src_file == NULL || dst_file == NULL) {
                EM_DEBUG_EXCEPTION("src_file[%p], dst_file[%p]", src_file, dst_file);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -12211,8 +12150,8 @@ INTERNAL_FUNC int emstorage_move_file(char *src_file, char *dst_file, int sync_s
 
        if (strcmp(src_file, dst_file) != 0) {
                if (rename(src_file, dst_file) != 0) {
-                       /* EM_DEBUG_EXCEPTION("%s", strerror(errno) ); */
-                       if (errno == EXDEV)  {  /* oldpath and newpath are not on the same mounted file system.  (Linux permits a file system to be mounted at multiple points,  but  rename() */
+                       /* EM_DEBUG_EXCEPTION("%s", strerror(errno)); */
+                       if (errno == EXDEV)   /* oldpath and newpath are not on the same mounted file system.  (Linux permits a file system to be mounted at multiple points,  but  rename() */
                                /*  does not work across different mount points, even if the same file system is mounted on both.)       */
                                EM_DEBUG_LOG("oldpath and newpath are not on the same mounted file system.");
                                if (!emstorage_copy_file(src_file, dst_file, sync_status, &error)) {
@@ -12221,10 +12160,8 @@ INTERNAL_FUNC int emstorage_move_file(char *src_file, char *dst_file, int sync_s
                                }
                                remove(src_file);
                                EM_DEBUG_LOG("src[%s] removed", src_file);
-
-                       }
-                       else  {
-                               if (errno == ENOENT)  {
+                       } else {
+                               if (errno == ENOENT) {
                                        struct stat temp_file_stat;
                                        if (stat(src_file, &temp_file_stat) < 0) {
                                                EM_DEBUG_EXCEPTION("no src file found [%s] : %s", src_file, EM_STRERROR(errno_buf));
@@ -12234,17 +12171,14 @@ INTERNAL_FUNC int emstorage_move_file(char *src_file, char *dst_file, int sync_s
 
                                        error = EMAIL_ERROR_FILE_NOT_FOUND;
                                        goto FINISH_OFF;
-
-                               }
-                               else  {
+                               } else {
                                        EM_DEBUG_EXCEPTION("rename failed: %s", EM_STRERROR(errno_buf));
                                        error = EMAIL_ERROR_SYSTEM_FAILURE;
                                        goto FINISH_OFF;
                                }
                        }
                }
-       }
-       else {
+       } else {
                EM_DEBUG_LOG("src[%s] = dst[%s]", src_file, dst_file);
        }
 
@@ -12278,8 +12212,7 @@ INTERNAL_FUNC int emstorage_delete_file(char *src_file, int *err_code)
 
                        error = EMAIL_ERROR_SYSTEM_FAILURE;
                        goto FINISH_OFF;
-               }
-               else {
+               } else {
                        EM_DEBUG_EXCEPTION(" no file found...");
 
                        error = EMAIL_ERROR_FILE_NOT_FOUND;
@@ -12318,14 +12251,13 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code)
 
        dirp = opendir(src_dir);
 
-       if (dirp == NULL)  {
-               if (errno == ENOENT)  {
+       if (dirp == NULL) {
+               if (errno == ENOENT) {
                        EM_DEBUG_EXCEPTION("directory[%s] does not exist...", src_dir);
                        if (err_code != NULL)
                                *err_code = EMAIL_ERROR_SYSTEM_FAILURE;
                        return true;
-               }
-               else  {
+               } else {
                        EM_DEBUG_EXCEPTION("opendir failed [%s] [%d]", src_dir, errno);
                        if (err_code != NULL)
                                *err_code = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -12333,7 +12265,7 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code)
                }
        }
 
-       while ((dp=readdir(dirp)))  {
+       while ((dp = readdir(dirp))) {
                if (strncmp(dp->d_name, ".", 1) == 0 || strncmp(dp->d_name, "..", 2) == 0) /* prevent 34360 */
                        continue;
 
@@ -12341,7 +12273,7 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code)
 
                if (lstat(buf, &sbuf) == 0 || stat(buf, &sbuf) == 0) {
                        /*  check directory */
-                       if ((sbuf.st_mode & S_IFMT) == S_IFDIR)  {      /*  directory */
+                       if ((sbuf.st_mode & S_IFMT) == S_IFDIR)       /*  directory */
                                /*  recursive call */
                                if (!emstorage_delete_dir(buf, &error)) {
                                        closedir(dirp);
@@ -12349,9 +12281,8 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code)
                                                *err_code = error;
                                        return false;
                                }
-                       }
-                       else  { /*  file */
-                               if (remove(buf) < 0)  {
+                       } else {        /*  file */
+                               if (remove(buf) < 0) {
                                        EM_DEBUG_EXCEPTION("remove failed [%s] [%d]", buf, errno);
                                        closedir(dirp);
                                        if (err_code != NULL)
@@ -12359,18 +12290,17 @@ INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code)
                                        return false;
                                }
                        }
-               }
-               else
+               } else
                        EM_DEBUG_EXCEPTION("content does not exist...");
        }
 
        closedir(dirp);
 
-       EM_DEBUG_LOG_DEV ("remove direcotory [%s]", src_dir);
+       EM_DEBUG_LOG_DEV("remove direcotory [%s]", src_dir);
 
        /* EM_DEBUG_FUNC_BEGIN(); */
 
-       if (remove(src_dir) < 0)  {
+       if (remove(src_dir) < 0) {
                EM_DEBUG_EXCEPTION("remove failed [%s] [%d]", src_dir, errno);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -12461,7 +12391,7 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid(char *multi_user_name, int mail
        char sql_query_string[QUERY_SIZE] = {0, };
        int transaction = true;
 
-       if (!mail_id || !new_server_uid || !mbox_name)  {
+       if (!mail_id || !new_server_uid || !mbox_name) {
                EM_DEBUG_EXCEPTION("Invalid parameters");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -12538,7 +12468,7 @@ int emstorage_get_unread_mailid(char *multi_user_name, int account_id, int vip_m
 {
        EM_DEBUG_FUNC_BEGIN();
 
-       if ((!mail_ids) ||(account_id <= 0 &&  account_id != -1)) {
+       if ((!mail_ids) || (account_id <= 0 &&  account_id != -1)) {
                EM_DEBUG_EXCEPTION(" mail_id[%p], account_id[%d] ", mail_ids, account_id);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -12579,21 +12509,21 @@ int emstorage_get_unread_mailid(char *multi_user_name, int account_id, int vip_m
        EM_DEBUG_LOG_SEC("query: [%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EM_DEBUG_LOG("Count : %d", count);
 
-       if (count == 0)  {
+       if (count == 0) {
                EM_DEBUG_EXCEPTION("no Mails found...");
                ret = false;
-               error= EMAIL_ERROR_MAIL_NOT_FOUND;
+               error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
        }
 
        p_mail_ids = em_malloc(count * sizeof(int));
        if (p_mail_ids == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -12657,12 +12587,12 @@ int setting_system_command(const char *command)
                execve("/bin/sh", argv, environ);
                abort();
        }
-       do{
+
+       do {
                if (waitpid(pid, &status, 0) == -1) {
                        if (errno != EINTR)
                                return -1;
-               }
-               else {
+               } else {
                        return status;
                }
        } while (1);
@@ -12716,7 +12646,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_
 
        line_from_file = fgets(line, sizeof(line), fp);
 
-       if(line_from_file == NULL) {
+       if (line_from_file == NULL) {
                EM_DEBUG_EXCEPTION("fgets failed");
                error = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
@@ -12744,12 +12674,12 @@ FINISH_OFF:
        else
                *total_usage = 0;
 
-       if(fp) fclose(fp); /* prevent 32730 */
+       if (fp) fclose(fp); /* prevent 32730 */
 
        EM_DEBUG_FUNC_END("ret [%d]", ret);
        return ret;
 }
-#define MAILHOME_UTF8    tzplatform_mkpath(TZ_USER_DATA,"email/.email_data/7/348/UTF-8")
+#define MAILHOME_UTF8    tzplatform_mkpath(TZ_USER_DATA, "email/.email_data/7/348/UTF-8")
 
 INTERNAL_FUNC int emstorage_test(char *multi_user_name, int mail_id, int account_id, char *full_address_to, char *full_address_cc, char *full_address_bcc, int *err_code)
 {
@@ -12761,7 +12691,7 @@ INTERNAL_FUNC int emstorage_test(char *multi_user_name, int mail_id, int account
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_tbl VALUES "
-               "( ?" /*  mail_id */
+               "(?" /*  mail_id */
                ", ?" /*  account_id */
                ", ?" /*  mail_size */
                ", ?" /*  server_mail_status */
@@ -12823,7 +12753,7 @@ INTERNAL_FUNC int emstorage_test(char *multi_user_name, int mail_id, int account
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        _bind_stmt_field_data_int(hStmt, MAIL_ID_IDX_IN_MAIL_TBL, mail_id);
@@ -12882,17 +12812,17 @@ INTERNAL_FUNC int emstorage_test(char *multi_user_name, int mail_id, int account
        _bind_stmt_field_data_blob(hStmt, EAS_DATA_IDX_IN_MAIL_TBL, NULL, 0);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
        ret = true;
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -13017,7 +12947,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name,
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL),
                                                                        rc);
 
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err_code = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err_code = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EM_DEBUG_LOG("Result rows count : %d", count);
@@ -13160,7 +13090,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(char *multi_user_name, in
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL), rc);
 
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err_code = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err_code = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EM_DEBUG_LOG("Result rows count : %d", count);
@@ -13168,7 +13098,7 @@ INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(char *multi_user_name, in
        if (count == 0)
                result_thread_id = -1;
        else {
-               _get_table_field_data_int   (result, &result_thread_id, 1);
+               _get_table_field_data_int(result, &result_thread_id, 1);
        }
 
 FINISH_OFF:
@@ -13203,12 +13133,12 @@ INTERNAL_FUNC int emstorage_get_thread_information(char *multi_user_name, int th
        SNPRINTF(conditional_clause, QUERY_SIZE, "WHERE thread_id = %d AND thread_item_count > 0", thread_id);
        EM_DEBUG_LOG("conditional_clause [%s]", conditional_clause);
 
-       if(!emstorage_query_mail_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
+       if (!emstorage_query_mail_tbl(multi_user_name, conditional_clause, transaction, &p_data_tbl, &count, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_tbl failed [%d]", error);
                goto FINISH_OFF;
        }
 
-       if(p_data_tbl)
+       if (p_data_tbl)
                EM_DEBUG_LOG("thread_id : %d, thread_item_count : %d", p_data_tbl[0].thread_id, p_data_tbl[0].thread_item_count);
 
        ret = true;
@@ -13231,7 +13161,7 @@ INTERNAL_FUNC int emstorage_get_sender_list(char *multi_user_name, int account_i
        EM_DEBUG_FUNC_BEGIN_SEC("account_id [%d], mailbox_id [%d], search_type [%d], search_value [%p], sorting [%d], sender_list[%p], sender_count[%p] err_code[%p]"
                , account_id , mailbox_id , search_type , search_value , sorting , sender_list, sender_count, err_code);
 
-       if ((!sender_list) ||(!sender_count)) {
+       if ((!sender_list) || (!sender_count)) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -13304,13 +13234,13 @@ INTERNAL_FUNC int emstorage_get_sender_list(char *multi_user_name, int account_i
        EM_DEBUG_LOG_SEC("query[%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EM_DEBUG_LOG("Count of Sender [%d]", count);
 
        if (!(p_sender_list = (email_sender_list_t*)em_malloc(sizeof(email_sender_list_t) * count))) {
-               EM_DEBUG_EXCEPTION("em_malloc failed...");
+               EM_DEBUG_EXCEPTION("em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -13318,7 +13248,7 @@ INTERNAL_FUNC int emstorage_get_sender_list(char *multi_user_name, int account_i
        col_index = 4;
 
        EM_DEBUG_LOG(">>>> DATA ASSIGN START >>");
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                _get_table_field_data_string(result, &(p_sender_list[i].address), 1, col_index++);
                _get_table_field_data_string(result, &(p_sender_list[i].display_name), 1, col_index++);
                _get_table_field_data_int(result, &(p_sender_list[i].total_count), col_index++);
@@ -13333,7 +13263,7 @@ INTERNAL_FUNC int emstorage_get_sender_list(char *multi_user_name, int account_i
        ret = true;
 
 FINISH_OFF:
-       if (ret == true)  {
+       if (ret == true) {
                *sender_list = p_sender_list;
                *sender_count = count;
                EM_DEBUG_LOG(">>>> COUNT : %d >>", count);
@@ -13353,8 +13283,8 @@ INTERNAL_FUNC int emstorage_free_sender_list(email_sender_list_t **sender_list,
 
        int err = EMAIL_ERROR_NONE;
 
-       if (count > 0)  {
-               if (!sender_list || !*sender_list)  {
+       if (count > 0) {
+               if (!sender_list || !*sender_list) {
                        EM_DEBUG_EXCEPTION("sender_list[%p], count[%d]", sender_list, count);
                        err = EMAIL_ERROR_INVALID_PARAM;
                        return err;
@@ -13363,7 +13293,7 @@ INTERNAL_FUNC int emstorage_free_sender_list(email_sender_list_t **sender_list,
                email_sender_list_t* p = *sender_list;
                int i = 0;
 
-               for (; i < count; i++)  {
+               for (; i < count; i++) {
                        EM_SAFE_FREE(p[i].address);
                        EM_SAFE_FREE(p[i].display_name);
                }
@@ -13386,7 +13316,7 @@ INTERNAL_FUNC int emstorage_free_address_info_list(email_address_info_list_t **a
        GList *node = NULL;
        int i = 0;
 
-       if (!address_info_list || !*address_info_list)  {
+       if (!address_info_list || !*address_info_list) {
                EM_DEBUG_EXCEPTION("address_info_list[%p]", address_info_list);
                err = EMAIL_ERROR_INVALID_PARAM;
                return err;
@@ -13454,7 +13384,7 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(char *multi_user_name, email_event_
        memset(sql_query_string, 0x00, sizeof(sql_query_string));
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_partial_body_activity_tbl VALUES "
-               "( "
+               "("
                "? "  /* Account ID */
                ",?"  /* Local Mail ID */
                ",?"  /* Server mail ID */
@@ -13471,10 +13401,10 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(char *multi_user_name, email_event_
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
 
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
-       if (NULL==result[1]) rc = 1;
+       if (NULL == result[1]) rc = 1;
        else rc = atoi(result[1])+1;
        sqlite3_free_table(result);
        result = NULL;
@@ -13489,7 +13419,7 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(char *multi_user_name, email_event_
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
@@ -13505,9 +13435,9 @@ INTERNAL_FUNC int emstorage_add_pbd_activity(char *multi_user_name, email_event_
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
 
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle)));
 
        ret = true;
@@ -13534,7 +13464,7 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(char *multi_user_name, int acco
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_list[%p], count[%p] err_code[%p]", account_id, mailbox_list, count, err_code);
 
-       if (account_id < FIRST_ACCOUNT_ID || NULL == mailbox_list || *mailbox_list == NULL|| NULL == count) {
+       if (account_id < FIRST_ACCOUNT_ID || NULL == mailbox_list || *mailbox_list == NULL || NULL == count) {
                EM_DEBUG_EXCEPTION("account_id[%d], mailbox_list[%p], count[%p] err_code[%p]", account_id, mailbox_list, count, err_code);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -13557,7 +13487,7 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(char *multi_user_name, int acco
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -13582,17 +13512,17 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(char *multi_user_name, int acco
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        mbox_list = (int *)em_malloc(sizeof(int) * (*count));
        if (NULL == mbox_list) {
-               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -13603,7 +13533,7 @@ INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(char *multi_user_name, int acco
                _get_stmt_field_data_int(hStmt, mbox_list + i, 0);
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
                /* EM_DEBUG_LOG("In emstorage_get_pdb_mailbox_list() loop, After sqlite3_step(), , i = %d, rc = %d.", i,  rc); */
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
                EM_DEBUG_LOG("mbox_list %d", mbox_list[i]);
        }
@@ -13657,7 +13587,7 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(char *multi_user_name, int **ac
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -13682,16 +13612,16 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(char *multi_user_name, int **ac
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
        EM_DEBUG_LOG("Before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (NULL == (result_account_list = (int *)em_malloc(sizeof(int) * (*count)))) {
-               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -13702,7 +13632,7 @@ INTERNAL_FUNC int emstorage_get_pbd_account_list(char *multi_user_name, int **ac
                _get_stmt_field_data_int(hStmt, result_account_list + i, 0);
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
                EM_DEBUG_LOG("account id -> %d", result_account_list[i]);
        }
@@ -13761,7 +13691,7 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(char *multi_user_name, int acc
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -13786,12 +13716,12 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(char *multi_user_name, int acc
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
        EM_DEBUG_LOG(" Bbefore sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (!(event_list = (email_event_partial_body_thd*)em_malloc(sizeof(email_event_partial_body_thd) * (*count)))) {
@@ -13802,7 +13732,7 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(char *multi_user_name, int acc
        }
        memset(event_list, 0x00, sizeof(email_event_partial_body_thd) * (*count));
 
-       for (i=0; i < (*count); i++) {
+       for (i = 0; i < (*count); i++) {
                _get_stmt_field_data_int(hStmt, &(event_list[i].account_id), ACCOUNT_IDX_MAIL_PARTIAL_BODY_ACTIVITY_TBL);
                _get_stmt_field_data_int(hStmt, &(event_list[i].mail_id), MAIL_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL);
                _get_stmt_field_data_int(hStmt, (int *)&(event_list[i].server_mail_id), SERVER_MAIL_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL);
@@ -13814,7 +13744,7 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_data(char *multi_user_name, int acc
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
                /* EM_DEBUG_LOG("In emstorage_get_pbd_activity_data() loop, After sqlite3_step(), , i = %d, rc = %d.", i,  rc); */
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
 
                event_list[i].event_type = 0;
@@ -13826,7 +13756,7 @@ FINISH_OFF:
        if (true == ret)
          *event_start = event_list;
        else {
-               for (i=0; i < (*count); i++)
+               for (i = 0; i < (*count); i++)
                        emcore_free_partial_body_thd_event(event_list, NULL);
                EM_SAFE_FREE(event_list); /*prevent 54559*/
                *event_start = NULL;
@@ -13886,7 +13816,7 @@ INTERNAL_FUNC int emstorage_delete_pbd_activity(char *multi_user_name, int accou
 
        /*  validate activity existence */
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_EXCEPTION("No matching activity found");
                error = EMAIL_ERROR_DATA_NOT_FOUND;
                ret = true;
@@ -13934,12 +13864,12 @@ INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(char *multi_user_name
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG("before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        _get_stmt_field_data_int(hStmt, activity_count, 0);
@@ -13952,7 +13882,7 @@ FINISH_OFF:
 
        if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               hStmt=NULL;
+               hStmt = NULL;
                if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
@@ -13994,12 +13924,12 @@ INTERNAL_FUNC int emstorage_get_pbd_activity_count(char *multi_user_name, int *a
        EM_DEBUG_LOG_DEV(" Query [%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_LOG_DEV ("  before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_LOG_DEV("  before sqlite3_prepare hStmt = %p", hStmt);
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        _get_stmt_field_data_int(hStmt, activity_count, 0);
@@ -14013,7 +13943,7 @@ FINISH_OFF:
 
        if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               hStmt=NULL;
+               hStmt = NULL;
                if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
@@ -14090,7 +14020,7 @@ INTERNAL_FUNC int emstorage_update_pbd_activity(char *multi_user_name, char *old
 
        int transaction = true;
 
-       if (!old_server_uid || !new_server_uid || !mbox_name)  {
+       if (!old_server_uid || !new_server_uid || !mbox_name) {
                EM_DEBUG_EXCEPTION("Invalid parameters");
                error = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -14137,7 +14067,7 @@ INTERNAL_FUNC int emstorage_create_file(char *data_string, size_t file_size, cha
        FILE* fp_dst = NULL;
        char errno_buf[ERRNO_BUF_SIZE] = {0};
 
-       if (!data_string || !dst_file_name)  {
+       if (!data_string || !dst_file_name) {
                EM_DEBUG_LOG("data_string[%p], dst_file_name[%p]", data_string, dst_file_name);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -14184,7 +14114,7 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *multi_user_
 
        int transaction = true;
 
-       if (!old_server_uid || !new_server_uid || !mbox_name)  {
+       if (!old_server_uid || !new_server_uid || !mbox_name) {
                EM_DEBUG_EXCEPTION("Invalid parameters");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -14208,8 +14138,7 @@ INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *multi_user_
        }
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)
-       {
+       if (rc == 0) {
                EM_DEBUG_EXCEPTION("No matching found in mail_partial_body_activity_tbl");
                error = EMAIL_ERROR_DATA_NOT_FOUND;
                goto FINISH_OFF;
@@ -14284,7 +14213,7 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *multi_user_name,
 
        /*  rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL); */
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result);
                                                goto FINISH_OFF; },     ("SQL(%s) sqlite3_get_table fail:%d -%s",
                                                sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
@@ -14296,8 +14225,8 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *multi_user_name,
                goto FINISH_OFF;
        }
 
-       if (NULL == (p_id_set = (email_id_set_t*)em_malloc(sizeof(email_id_set_t) * count)))  {
-               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+       if (NULL == (p_id_set = (email_id_set_t*)em_malloc(sizeof(email_id_set_t) * count))) {
+               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -14306,7 +14235,7 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *multi_user_name,
 
        EM_PROFILE_BEGIN(EmStorageGetIdSetFromMailIds_Loop);
        EM_DEBUG_LOG(">>>> DATA ASSIGN START");
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                _get_table_field_data_int(result, &(p_id_set[i].mail_id), col_index++);
                _get_table_field_data_string(result, &server_mail_id, 1, col_index++);
                if (server_mail_id) {
@@ -14324,12 +14253,11 @@ INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *multi_user_name,
 
 FINISH_OFF:
 
-       if (ret == true)  {
+       if (ret == true) {
                *idset = p_id_set;
                *id_set_count = count;
                EM_DEBUG_LOG(" idset[%p] id_set_count [%d]", *idset, *id_set_count);
-       }
-       else
+       } else
                EM_SAFE_FREE(p_id_set);
 
 
@@ -14494,7 +14422,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco
 
        /*  rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL); */
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EM_DEBUG_LOG("Count of mails [%d]", count);
@@ -14515,7 +14443,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco
                memset(sql_query_string, 0x00, QUERY_SIZE);
                if (reset) {
                        switch (rule->action_type) {
-                       case EMAIL_FILTER_MOVE :
+                       case EMAIL_FILTER_MOVE:
                                SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET tag_id = 0 ");
                                break;
                        case EMAIL_FILTER_BLOCK:
@@ -14526,10 +14454,10 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco
                        }
                } else {
                        switch (rule->action_type) {
-                       case EMAIL_FILTER_MOVE :
+                       case EMAIL_FILTER_MOVE:
                                SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET tag_id = %d ", tag_id);
                                break;
-                       case EMAIL_FILTER_BLOCK :
+                       case EMAIL_FILTER_BLOCK:
                                SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET mailbox_id = %d, mailbox_type = %d ", dest_mailbox_id, dest_mailbox_type);
                                break;
                        default:
@@ -14539,7 +14467,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco
                        }
                }
                /* prevent 34361 */
-               if(strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE)
+               if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE)
                        strcat(sql_query_string, where_pararaph);
 
                error = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -14553,7 +14481,7 @@ INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int acco
                if (rule->action_type == EMAIL_FILTER_BLOCK) {
                        memset(sql_query_string, 0x00, QUERY_SIZE);
                        SNPRINTF(sql_query_string, QUERY_SIZE, "UPDATE mail_text_tbl SET mailbox_id = %d ", dest_mailbox_id);
-                       if(strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE)
+                       if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE)
                                strcat(sql_query_string, where_pararaph);
 
                        EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
@@ -14696,7 +14624,7 @@ INTERNAL_FUNC int emstorage_add_meeting_request(char *multi_user_name, int accou
 
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_meeting_tbl VALUES "
-               "( ?"           /*  mail_id */
+               "(?"            /*  mail_id */
                ", ?"           /*  account_id */
                ", ?"           /*  mailbox_id */
                ", ?"           /*  meeting_response */
@@ -14711,10 +14639,10 @@ INTERNAL_FUNC int emstorage_add_meeting_request(char *multi_user_name, int accou
                ", ?"           /*  daylight_name */
                ", ?"           /*  daylight_time_start_date */
                ", ?"           /*  daylight_bias */
-               " )");
+               ")");
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       if (rc != SQLITE_OK)  {
+       if (rc != SQLITE_OK) {
                EM_DEBUG_LOG(" before sqlite3_prepare hStmt = %p", hStmt);
                EM_DEBUG_EXCEPTION("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle));
 
@@ -14766,18 +14694,18 @@ INTERNAL_FUNC int emstorage_add_meeting_request(char *multi_user_name, int accou
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        ret = true;
 
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -14824,7 +14752,7 @@ INTERNAL_FUNC int emstorage_query_meeting_request(char *multi_user_name, const c
        EM_DEBUG_LOG_SEC("Query [%s]", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        if (!count) {
@@ -14866,15 +14794,14 @@ INTERNAL_FUNC int emstorage_query_meeting_request(char *multi_user_name, const c
 
 
 FINISH_OFF:
-       if(result)
+       if (result)
                sqlite3_free_table(result);
 
-       if (err == EMAIL_ERROR_NONE)  {
+       if (err == EMAIL_ERROR_NONE) {
                if (p_temp_meeting_req)
                        *output_meeting_req = p_temp_meeting_req;
                *output_result_count = count;
-       }
-       else
+       } else
                EM_SAFE_FREE(p_temp_meeting_req);
 
        EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
@@ -14900,7 +14827,7 @@ INTERNAL_FUNC int emstorage_get_meeting_request(char *multi_user_name, int mail_
        SNPRINTF(conditional_clause, QUERY_SIZE, " WHERE mail_id = %d", mail_id);
        EM_DEBUG_LOG("conditional_clause [%s]", conditional_clause);
 
-       if((error = emstorage_query_meeting_request(multi_user_name, conditional_clause, meeting_req, &count, transaction)) != EMAIL_ERROR_NONE) {
+       if ((error = emstorage_query_meeting_request(multi_user_name, conditional_clause, meeting_req, &count, transaction)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_query_meeting_request failed. [%d]", error);
                goto FINISH_OFF;
        }
@@ -14974,7 +14901,7 @@ INTERNAL_FUNC int emstorage_update_meeting_request(char *multi_user_name, email_
        EM_DEBUG_LOG_SEC("SQL(%s)", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 /*
        EM_DEBUG_LOG_SEC(">>>>> meeting_req->mail_id[%d]", meeting_req->mail_id);
@@ -15012,7 +14939,7 @@ INTERNAL_FUNC int emstorage_update_meeting_request(char *multi_user_name, email_
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
        ret = true;
 
@@ -15020,9 +14947,9 @@ INTERNAL_FUNC int emstorage_update_meeting_request(char *multi_user_name, email_
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -15092,7 +15019,7 @@ INTERNAL_FUNC void emstorage_free_meeting_request(email_meeting_request_t *meeti
 {
        EM_DEBUG_FUNC_BEGIN();
 
-       if (!meeting_req ) return;
+       if (!meeting_req) return;
 
        EM_SAFE_FREE(meeting_req->location);
        EM_SAFE_FREE(meeting_req->global_object_id);
@@ -15127,13 +15054,13 @@ INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(char *multi_user_name, i
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_mail_id_count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        if (!result_mail_id_count) {
                EM_DEBUG_LOG("No mail found...");
                ret = false;
-               error= EMAIL_ERROR_MAIL_NOT_FOUND;
+               error = EMAIL_ERROR_MAIL_NOT_FOUND;
                goto FINISH_OFF;
        }
 
@@ -15161,11 +15088,10 @@ FINISH_OFF:
        if (result)
                sqlite3_free_table(result);
 
-       if (ret == true)  {
+       if (ret == true) {
                *mail_id_list = result_mail_id_list;
                *mail_id_count = result_mail_id_count;
-       }
-       else
+       } else
                EM_SAFE_FREE(result_mail_id_list);
 
        EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
@@ -15202,13 +15128,13 @@ INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(char *multi_user_name, int
 
        /*  rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL); */
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        if (!result_count) {
                EM_DEBUG_LOG("No mail found...");
                ret = false;
-               err= EMAIL_ERROR_MAIL_NOT_FOUND;
+               err = EMAIL_ERROR_MAIL_NOT_FOUND;
                /* sqlite3_free_table(result); */
                goto FINISH_OFF;
        }
@@ -15266,7 +15192,7 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name,
 
                /*  rc = sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL); */
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &result_count, 0, NULL), rc);
-               EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                        ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
                EM_DEBUG_LOG("result_count[%d]", result_count);
                if (result_count == 0) {
@@ -15316,8 +15242,6 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name,
                                EM_DEBUG_EXCEPTION("emstorage_exec_query_by_prepare_v2 failed:[%d]", err);
                                goto FINISH_OFF;
                }
-
-
        } else {
                memset(sql_query_string, 0, QUERY_SIZE);
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "UPDATE mail_tbl SET thread_item_count = %d WHERE account_id = %d AND mail_id = %d ", thread_item_count, account_id, latest_mail_id);
@@ -15333,29 +15257,25 @@ INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name,
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, err);
 
-       if (thread_id != latest_mail_id)
-       {
-               if(err == EMAIL_ERROR_NONE)
-               {
+       if (thread_id != latest_mail_id) {
+               if (err == EMAIL_ERROR_NONE) {
                        EM_DEBUG_LOG("noti_type[%d]", noti_type);
 
                        if (latest_mail_id > 0 && thread_id > 0 && noti_type > 0) {
                                char mailbox_id_str[25] = {0,};
                                snprintf(mailbox_id_str, sizeof(mailbox_id_str), "%d", mailbox_id);
                                if (!emcore_notify_storage_event(noti_type, thread_id, latest_mail_id, mailbox_id_str, account_id))
-                                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [NOTI_THREAD_ID_CHANGED] >>>> ");
+                                       EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [NOTI_THREAD_ID_CHANGED] >>>> ");
 
                                if (updated_thread_id) *updated_thread_id = latest_mail_id;
                        }
                }
-       }else if(thread_item_count >= 0)
-       {
-               if(err == EMAIL_ERROR_NONE)
-               {
+       } else if (thread_item_count >= 0) {
+               if (err == EMAIL_ERROR_NONE) {
                        char parameter_string[500] = {0,};
                        SNPRINTF(parameter_string, sizeof(parameter_string), "%s%c%d", "thread_item_count", 0x01, latest_mail_id);
                        if (!emcore_notify_storage_event(NOTI_MAIL_FIELD_UPDATE, account_id, EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT, parameter_string, thread_item_count))
-                               EM_DEBUG_EXCEPTION(" emcore_notify_storage_event failed [NOTI_MAIL_FIELD_UPDATE] >>>> ");
+                               EM_DEBUG_EXCEPTION(" emcore_notify_storage_eventfailed [NOTI_MAIL_FIELD_UPDATE] >>>> ");
                }
        }
 
@@ -15448,7 +15368,7 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EM_DEBUG_LOG_SEC(">>>> SQL STMT [ %s ] ", sql_query_string);
@@ -15464,9 +15384,9 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
 
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle)));
 
        ret = true;
@@ -15474,9 +15394,9 @@ INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t* local_activit
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
@@ -15524,8 +15444,7 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora
 
        if (activityid == ALL_ACTIVITIES) {
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_local_activity_tbl WHERE account_id = %d order by activity_id", account_id);
-       }
-       else {
+       } else {
                SNPRINTF(sql_query_string, sizeof(sql_query_string), "SELECT * FROM mail_local_activity_tbl WHERE account_id = %d AND activity_id = %d ", account_id, activityid);
        }
 
@@ -15534,19 +15453,19 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        col_index = 7;
 
        if (!(p_activity_tbl = (emstorage_activity_tbl_t*)em_malloc(sizeof(emstorage_activity_tbl_t) * count))) {
-               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
 
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                EM_DEBUG_LOG("result[%d] - %s ", col_index, result[col_index]);
                if (result[col_index])
                        p_activity_tbl[i].activity_id = atoi(result[col_index++]);
@@ -15565,19 +15484,19 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora
 
 
                EM_DEBUG_LOG("result[%d] - %s ", col_index, result[col_index]);
-               if (result[col_index] && EM_SAFE_STRLEN(result[col_index])>0)
+               if (result[col_index] && EM_SAFE_STRLEN(result[col_index]) > 0)
                        p_activity_tbl[i].server_mailid = EM_SAFE_STRDUP(result[col_index++]);
                else
                        col_index++;
 
                EM_DEBUG_LOG("result[%d] - %s ", col_index, result[col_index]);
-               if (result[col_index] && EM_SAFE_STRLEN(result[col_index])>0)
+               if (result[col_index] && EM_SAFE_STRLEN(result[col_index]) > 0)
                        p_activity_tbl[i].src_mbox = EM_SAFE_STRDUP(result[col_index++]);
                else
                        col_index++;
 
                EM_DEBUG_LOG("result[%d] - %s ", col_index, result[col_index]);
-               if (result[col_index] && EM_SAFE_STRLEN(result[col_index])>0)
+               if (result[col_index] && EM_SAFE_STRLEN(result[col_index]) > 0)
                        p_activity_tbl[i].dest_mbox = EM_SAFE_STRDUP(result[col_index++]);
                else
                        col_index++;
@@ -15590,14 +15509,14 @@ INTERNAL_FUNC int emstorage_get_activity(int account_id, int activityid, emstora
        ret = true;
 
 FINISH_OFF:
+
        EMSTORAGE_FINISH_READ_TRANSACTION(transaction);
 
-       if (ret == true)  {
+       if (ret == true) {
                *activity_list = p_activity_tbl;
                *select_num = count;
                EM_DEBUG_LOG(">>>> COUNT : %d >> ", count);
-       }
-       else if (p_activity_tbl != NULL) {
+       } else if (p_activity_tbl != NULL) {
                emstorage_free_local_activity(&p_activity_tbl, count, NULL);
        }
 
@@ -15635,10 +15554,10 @@ INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code
        sql = "SELECT max(rowid) FROM mail_local_activity_tbl;";
 
        /*  rc = sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL); n EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc); */
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
-       if (NULL==result[1])
+       if (NULL == result[1])
                rc = 1;
        else
                rc = atoi(result[1])+1;
@@ -15667,7 +15586,7 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(char *multi_user_name, int acco
 
        EM_DEBUG_LOG(" account_id[%d], activity_id_list[%p], activity_id_count[%p] err_code[%p]", account_id,  activity_id_list, activity_id_count, err_code);
 
-       if (account_id <= 0|| NULL == activity_id_list || NULL == activity_id_count ||lowest_activity_type <=0 || highest_activity_type <= 0)  {
+       if (account_id <= 0 || NULL == activity_id_list || NULL == activity_id_count || lowest_activity_type <= 0 || highest_activity_type <= 0) {
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
                return false;
@@ -15691,7 +15610,7 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(char *multi_user_name, int acco
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        col_index = 1;
@@ -15699,12 +15618,12 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(char *multi_user_name, int acco
        EM_DEBUG_LOG(" Activity COUNT : %d ... ", count);
 
        if (NULL == (activity_ids = (int *)em_malloc(sizeof(int) * count))) {
-               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                activity_ids[i] = atoi(result[col_index]);
                col_index++;
                EM_DEBUG_LOG("activity_id %d", activity_ids[i]);
@@ -15715,12 +15634,10 @@ INTERNAL_FUNC int emstorage_get_activity_id_list(char *multi_user_name, int acco
 FINISH_OFF:
 
 
-       if (ret == true)  {
+       if (ret == true) {
                *activity_id_count = count;
                *activity_id_list = activity_ids;
-
-       }
-       else if (activity_ids != NULL) /* Prevent defect - 216566 */
+       } else if (activity_ids != NULL) /* Prevent defect - 216566 */
                EM_SAFE_FREE(activity_ids);
 
 
@@ -15745,13 +15662,12 @@ INTERNAL_FUNC int emstorage_free_activity_id_list(int *activity_id_list, int *er
        if (NULL == activity_id_list) {
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
-       }
-       else {
-               EM_SAFE_FREE (activity_id_list);
+       } else {
+               EM_SAFE_FREE(activity_id_list);
        }
 
 
-       ret= true;
+       ret = true;
 
        FINISH_OFF:
 
@@ -15775,7 +15691,7 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
 
        EM_DEBUG_LOG(" local_activity[%p] ", local_activity);
 
-       if (!local_activity)  {
+       if (!local_activity) {
                EM_DEBUG_EXCEPTION(" local_activity[%p] ", local_activity);
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_INVALID_PARAM;
@@ -15805,7 +15721,7 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
 
        if (local_activity->server_mailid) {
                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1),
-               " %s %s server_mailid = '%s' ", query_where? "": "WHERE", query_and? "AND":"", local_activity->server_mailid);
+               " %s %s server_mailid = '%s' ", query_where ? "" : "WHERE", query_and ? "AND" : "", local_activity->server_mailid);
                query_and = 1;
                query_where = 1;
        }
@@ -15815,7 +15731,7 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
                EM_DEBUG_LOG(">>>> MAIL ID [ %d ] , ACTIVITY TYPE [%d ]", local_activity->mail_id, local_activity->activity_type);
 
                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1),
-               " %s %s mail_id = %d  ", query_where? "": "WHERE", query_and? "AND":"", local_activity->mail_id);
+               " %s %s mail_id = %d  ", query_where ? "" : "WHERE", query_and ? "AND" : "", local_activity->mail_id);
 
                query_and = 1;
                query_where = 1;
@@ -15824,12 +15740,12 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
 
        if (local_activity->activity_type > 0) {
                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1),
-               " %s %s activity_type = %d ", query_where? "": "WHERE", query_and? "AND" : "" , local_activity->activity_type);
+               " %s %s activity_type = %d ", query_where ? "" : "WHERE", query_and ? "AND" : "" , local_activity->activity_type);
        }
 
        if (local_activity->activity_id > 0) {
                SNPRINTF(sql_query_string + EM_SAFE_STRLEN(sql_query_string), sizeof(sql_query_string)-(EM_SAFE_STRLEN(sql_query_string)+1),
-               " %s %s activity_id = %d ", query_where? "": "WHERE", query_and? "AND" : "" , local_activity->activity_id);
+               " %s %s activity_id = %d ", query_where ? "" : "WHERE", query_and ? "AND" : "" , local_activity->activity_id);
 
        }
 
@@ -15841,7 +15757,7 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
        }
 
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_EXCEPTION(" no (matched) mailbox_name found...");
                err = EMAIL_ERROR_MAILBOX_NOT_FOUND;
        }
@@ -15851,10 +15767,10 @@ INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t* loca
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, transaction, ret, error);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
                if (rc != SQLITE_OK) {
-                       EM_DEBUG_EXCEPTION ("sqlite3_finalize error [%d]", rc);
+                       EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
                }
        }
@@ -15888,13 +15804,13 @@ INTERNAL_FUNC int emstorage_free_local_activity(emstorage_activity_tbl_t **local
                emstorage_activity_tbl_t* p = *local_activity_list;
                int i = 0;
                if (p) {
-                       for (; i < count; i++)  {
-                               EM_SAFE_FREE (p[i].dest_mbox);
-                               EM_SAFE_FREE (p[i].src_mbox);
-                               EM_SAFE_FREE (p[i].server_mailid);
+                       for (; i < count; i++) {
+                               EM_SAFE_FREE(p[i].dest_mbox);
+                               EM_SAFE_FREE(p[i].src_mbox);
+                               EM_SAFE_FREE(p[i].server_mailid);
                        }
 
-                       EM_SAFE_FREE (p);
+                       EM_SAFE_FREE(p);
                        *local_activity_list = NULL;
                }
        }
@@ -15902,6 +15818,7 @@ INTERNAL_FUNC int emstorage_free_local_activity(emstorage_activity_tbl_t **local
        ret = true;
 
 FINISH_OFF:
+
        if (err_code != NULL)
                *err_code = error;
 
@@ -15912,7 +15829,7 @@ FINISH_OFF:
 #endif /* __FEATURE_LOCAL_ACTIVITY__ */
 
 
-static int _get_key_value_string_for_list_filter_rule(email_list_filter_rule_t *input_list_filter_rule,char **output_key_value_string)
+static int _get_key_value_string_for_list_filter_rule(email_list_filter_rule_t *input_list_filter_rule, char **output_key_value_string)
 {
        EM_DEBUG_FUNC_BEGIN("input_list_filter_rule [%p], output_key_value_string [%p]", input_list_filter_rule, output_key_value_string);
 
@@ -15921,60 +15838,60 @@ static int _get_key_value_string_for_list_filter_rule(email_list_filter_rule_t *
        char *temp_key_value_1 = NULL;
        char *temp_key_value_2 = NULL;
 
-       if(input_list_filter_rule == NULL || output_key_value_string == NULL) {
+       if (input_list_filter_rule == NULL || output_key_value_string == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
-       switch(input_list_filter_rule->target_attribute) {
-       case EMAIL_MAIL_ATTRIBUTE_MAIL_ID                 :
-       case EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID              :
-       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_ID              :
-       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE            :
-       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_STATUS      :
-       case EMAIL_MAIL_ATTRIBUTE_REFERENCE_MAIL_ID       :
-       case EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS    :
-       case EMAIL_MAIL_ATTRIBUTE_MAIL_SIZE               :
-       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN         :
-       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML          :
-       case EMAIL_MAIL_ATTRIBUTE_FILE_SIZE               :
-       case EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD        :
-       case EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD     :
-       case EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD     :
-       case EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD    :
-       case EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD      :
-       case EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD       :
-       case EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD   :
-       case EMAIL_MAIL_ATTRIBUTE_DRM_STATUS              :
-       case EMAIL_MAIL_ATTRIBUTE_PRIORITY                :
-       case EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS             :
-       case EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS             :
-       case EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS           :
-       case EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT        :
-       case EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT    :
-       case EMAIL_MAIL_ATTRIBUTE_THREAD_ID               :
-       case EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT       :
-       case EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS  :
-       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS           :
-       case EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE             :
-       case EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE              :
-       case EMAIL_MAIL_ATTRIBUTE_REMAINING_RESEND_TIMES  :
-       case EMAIL_MAIL_ATTRIBUTE_TAG_ID                  :
-       case EMAIL_MAIL_ATTRIBUTE_EAS_DATA_LENGTH_TYPE    :
+       switch (input_list_filter_rule->target_attribute) {
+       case EMAIL_MAIL_ATTRIBUTE_MAIL_ID:
+       case EMAIL_MAIL_ATTRIBUTE_ACCOUNT_ID:
+       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_ID:
+       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_TYPE:
+       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_STATUS:
+       case EMAIL_MAIL_ATTRIBUTE_REFERENCE_MAIL_ID:
+       case EMAIL_MAIL_ATTRIBUTE_BODY_DOWNLOAD_STATUS:
+       case EMAIL_MAIL_ATTRIBUTE_MAIL_SIZE:
+       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN:
+       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML:
+       case EMAIL_MAIL_ATTRIBUTE_FILE_SIZE:
+       case EMAIL_MAIL_ATTRIBUTE_FLAGS_SEEN_FIELD:
+       case EMAIL_MAIL_ATTRIBUTE_FLAGS_DELETED_FIELD:
+       case EMAIL_MAIL_ATTRIBUTE_FLAGS_FLAGGED_FIELD:
+       case EMAIL_MAIL_ATTRIBUTE_FLAGS_ANSWERED_FIELD:
+       case EMAIL_MAIL_ATTRIBUTE_FLAGS_RECENT_FIELD:
+       case EMAIL_MAIL_ATTRIBUTE_FLAGS_DRAFT_FIELD:
+       case EMAIL_MAIL_ATTRIBUTE_FLAGS_FORWARDED_FIELD:
+       case EMAIL_MAIL_ATTRIBUTE_DRM_STATUS:
+       case EMAIL_MAIL_ATTRIBUTE_PRIORITY:
+       case EMAIL_MAIL_ATTRIBUTE_SAVE_STATUS:
+       case EMAIL_MAIL_ATTRIBUTE_LOCK_STATUS:
+       case EMAIL_MAIL_ATTRIBUTE_REPORT_STATUS:
+       case EMAIL_MAIL_ATTRIBUTE_ATTACHMENT_COUNT:
+       case EMAIL_MAIL_ATTRIBUTE_INLINE_CONTENT_COUNT:
+       case EMAIL_MAIL_ATTRIBUTE_THREAD_ID:
+       case EMAIL_MAIL_ATTRIBUTE_THREAD_ITEM_COUNT:
+       case EMAIL_MAIL_ATTRIBUTE_MEETING_REQUEST_STATUS:
+       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_CLASS:
+       case EMAIL_MAIL_ATTRIBUTE_DIGEST_TYPE:
+       case EMAIL_MAIL_ATTRIBUTE_SMIME_TYPE:
+       case EMAIL_MAIL_ATTRIBUTE_REMAINING_RESEND_TIMES:
+       case EMAIL_MAIL_ATTRIBUTE_TAG_ID:
+       case EMAIL_MAIL_ATTRIBUTE_EAS_DATA_LENGTH_TYPE:
                SNPRINTF(key_value_string, QUERY_SIZE, "%d", input_list_filter_rule->key_value.integer_type_value);
                break;
 
-       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME            :
-       case EMAIL_MAIL_ATTRIBUTE_SUBJECT                 :
-       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME     :
-       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID          :
-       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID              :
-       case EMAIL_MAIL_ATTRIBUTE_FROM                    :
-       case EMAIL_MAIL_ATTRIBUTE_TO                      :
-       case EMAIL_MAIL_ATTRIBUTE_CC                      :
-       case EMAIL_MAIL_ATTRIBUTE_BCC                     :
-       case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT            :
-               if(input_list_filter_rule->key_value.string_type_value == NULL) {
+       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME:
+       case EMAIL_MAIL_ATTRIBUTE_SUBJECT:
+       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME:
+       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID:
+       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID:
+       case EMAIL_MAIL_ATTRIBUTE_FROM:
+       case EMAIL_MAIL_ATTRIBUTE_TO:
+       case EMAIL_MAIL_ATTRIBUTE_CC:
+       case EMAIL_MAIL_ATTRIBUTE_BCC:
+       case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT:
+               if (input_list_filter_rule->key_value.string_type_value == NULL) {
                        EM_DEBUG_EXCEPTION("Invalid string_type_value [%p]", input_list_filter_rule->key_value.string_type_value);
                        ret = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
@@ -15985,26 +15902,26 @@ static int _get_key_value_string_for_list_filter_rule(email_list_filter_rule_t *
                temp_key_value_2 = em_replace_all_string(temp_key_value_1, "_", "\\_");
                temp_key_value_1 = em_replace_all_string(temp_key_value_2, "%", "\\%");
 
-               if(input_list_filter_rule->rule_type == EMAIL_LIST_FILTER_RULE_INCLUDE)
+               if (input_list_filter_rule->rule_type == EMAIL_LIST_FILTER_RULE_INCLUDE)
                        SNPRINTF(key_value_string, QUERY_SIZE, "\'%%%s%%\'", temp_key_value_1);
                else
                        SNPRINTF(key_value_string, QUERY_SIZE, "\'%s\'", temp_key_value_1);
                break;
 
-       case EMAIL_MAIL_ATTRIBUTE_DATE_TIME               :
-       case EMAIL_MAIL_ATTRIBUTE_SCHEDULED_SENDING_TIME  :
-       case EMAIL_MAIL_ATTRIBUTE_REPLIED_TIME            :
-       case EMAIL_MAIL_ATTRIBUTE_FORWARDED_TIME          :
+       case EMAIL_MAIL_ATTRIBUTE_DATE_TIME:
+       case EMAIL_MAIL_ATTRIBUTE_SCHEDULED_SENDING_TIME:
+       case EMAIL_MAIL_ATTRIBUTE_REPLIED_TIME:
+       case EMAIL_MAIL_ATTRIBUTE_FORWARDED_TIME:
                SNPRINTF(key_value_string, QUERY_SIZE, "%d", (int)input_list_filter_rule->key_value.datetime_type_value);
                break;
 
-       default :
+       default:
                ret = EMAIL_ERROR_INVALID_PARAM;
                EM_DEBUG_EXCEPTION("Invalid target_attribute [%d]", input_list_filter_rule->target_attribute);
                break;
        }
 
-       if(ret == EMAIL_ERROR_NONE && EM_SAFE_STRLEN(key_value_string) > 0) {
+       if (ret == EMAIL_ERROR_NONE && EM_SAFE_STRLEN(key_value_string) > 0) {
                *output_key_value_string = strdup(key_value_string);
        }
 
@@ -16048,19 +15965,19 @@ static int _make_filter_rule_string(email_list_filter_rule_t *input_list_filter_
        char *temp_field_name_string = NULL;
        char *temp_key_value_string = NULL;
 
-       if(input_list_filter_rule == NULL || output_string == NULL) {
+       if (input_list_filter_rule == NULL || output_string == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return  EMAIL_ERROR_INVALID_PARAM;
        }
 
        temp_field_name_string = emcore_get_mail_field_name_by_attribute_type(input_list_filter_rule->target_attribute);
 
-       if(temp_field_name_string == NULL) {
+       if (temp_field_name_string == NULL) {
                EM_DEBUG_EXCEPTION("Invalid target_attribute [%d]", input_list_filter_rule->target_attribute);
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
-       if_get_key_value_string_for_list_filter_rule(input_list_filter_rule, &temp_key_value_string) != EMAIL_ERROR_NONE || temp_key_value_string == NULL) {
+       if (_get_key_value_string_for_list_filter_rule(input_list_filter_rule, &temp_key_value_string) != EMAIL_ERROR_NONE || temp_key_value_string == NULL) {
                EM_DEBUG_EXCEPTION("_get_key_value_string_for_list_filter_rule failed");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -16068,30 +15985,30 @@ static int _make_filter_rule_string(email_list_filter_rule_t *input_list_filter_
        length_field_name = EM_SAFE_STRLEN(temp_field_name_string);
        length_value      = EM_SAFE_STRLEN(temp_key_value_string);
 
-       switch(input_list_filter_rule->target_attribute) {
-       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME            :
-       case EMAIL_MAIL_ATTRIBUTE_SUBJECT                 :
-       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME     :
-       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID          :
-       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID              :
-       case EMAIL_MAIL_ATTRIBUTE_FROM                    :
-       case EMAIL_MAIL_ATTRIBUTE_TO                      :
-       case EMAIL_MAIL_ATTRIBUTE_CC                      :
-       case EMAIL_MAIL_ATTRIBUTE_BCC                     :
-       case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT            :
+       switch (input_list_filter_rule->target_attribute) {
+       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME:
+       case EMAIL_MAIL_ATTRIBUTE_SUBJECT:
+       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME:
+       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID:
+       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID:
+       case EMAIL_MAIL_ATTRIBUTE_FROM:
+       case EMAIL_MAIL_ATTRIBUTE_TO:
+       case EMAIL_MAIL_ATTRIBUTE_CC:
+       case EMAIL_MAIL_ATTRIBUTE_BCC:
+       case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT:
                is_alpha = 1;
                break;
-       default :
+       default:
                is_alpha = 0;
                break;
        }
 
-       if(is_alpha == 1 && input_list_filter_rule->case_sensitivity == false) {
+       if (is_alpha == 1 && input_list_filter_rule->case_sensitivity == false) {
                length_field_name += strlen("UPPER() ");
                length_value      += strlen("UPPER() ");
                mod_field_name_string = em_malloc(sizeof(char) * length_field_name);
                if (mod_field_name_string == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        EM_SAFE_FREE(temp_field_name_string);
                        ret = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -16099,7 +16016,7 @@ static int _make_filter_rule_string(email_list_filter_rule_t *input_list_filter_
 
                mod_value_string = em_malloc(sizeof(char) * length_value);
                if (mod_value_string == NULL) {
-                       EM_DEBUG_EXCEPTION("em_malloc failed");
+                       EM_DEBUG_EXCEPTION("em_mallocfailed");
                        EM_SAFE_FREE(temp_field_name_string);
                        ret = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -16108,41 +16025,40 @@ static int _make_filter_rule_string(email_list_filter_rule_t *input_list_filter_
                SNPRINTF(mod_field_name_string, length_field_name, "UPPER(%s)", temp_field_name_string);
                SNPRINTF(mod_value_string,      length_value, "UPPER(%s)", temp_key_value_string);
                EM_SAFE_FREE(temp_key_value_string);
-       }
-       else {
+       } else {
                mod_field_name_string = strdup(temp_field_name_string);
                mod_value_string      = temp_key_value_string;
        }
 
        switch (input_list_filter_rule->rule_type) {
-       case EMAIL_LIST_FILTER_RULE_EQUAL     :
+       case EMAIL_LIST_FILTER_RULE_EQUAL:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s = %s ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_NOT_EQUAL :
+       case EMAIL_LIST_FILTER_RULE_NOT_EQUAL:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s != %s ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_LESS_THAN :
+       case EMAIL_LIST_FILTER_RULE_LESS_THAN:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s < %s ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_GREATER_THAN :
+       case EMAIL_LIST_FILTER_RULE_GREATER_THAN:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s > %s ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_LESS_THAN_OR_EQUAL :
+       case EMAIL_LIST_FILTER_RULE_LESS_THAN_OR_EQUAL:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s <= %s ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_GREATER_THAN_OR_EQUAL :
+       case EMAIL_LIST_FILTER_RULE_GREATER_THAN_OR_EQUAL:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s >= %s ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_INCLUDE   :
+       case EMAIL_LIST_FILTER_RULE_INCLUDE:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s LIKE %s ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_IN        :
+       case EMAIL_LIST_FILTER_RULE_IN:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s IN (%s) ", mod_field_name_string, mod_value_string);
                break;
-       case EMAIL_LIST_FILTER_RULE_NOT_IN    :
+       case EMAIL_LIST_FILTER_RULE_NOT_IN:
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s NOT IN (%s) ", mod_field_name_string, mod_value_string);
                break;
-       default :
+       default:
                EM_DEBUG_EXCEPTION("Invalid rule_type [%d]", input_list_filter_rule->rule_type);
                ret = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -16177,7 +16093,7 @@ static int _make_filter_attach_rule_string(char *multi_user_name, email_list_fil
        sqlite3 *local_db_handle = NULL;
        int *mail_ids = NULL;
 
-       if(input_list_filter_rule == NULL || output_string == NULL) {
+       if (input_list_filter_rule == NULL || output_string == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return  EMAIL_ERROR_INVALID_PARAM;
        }
@@ -16195,7 +16111,7 @@ static int _make_filter_attach_rule_string(char *multi_user_name, email_list_fil
                SNPRINTF(result_rule_string, QUERY_SIZE, "WHERE %s MATCH \'%s\' ", field_name_string, key_value_string);
                break;
 
-       default :
+       default:
                EM_DEBUG_EXCEPTION("Invalid rule_type [%d]", input_list_filter_rule->rule_type);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -16207,19 +16123,19 @@ static int _make_filter_attach_rule_string(char *multi_user_name, email_list_fil
        SNPRINTF(sql_query_string, QUERY_SIZE, "SELECT mail_id FROM mail_attachment_tbl %s", result_rule_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF;},
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        col_index = 1;
 
        if (!count) {
                EM_DEBUG_LOG("No mail found...");
-               error= EMAIL_ERROR_MAIL_NOT_FOUND;
-               *output_string = strdup("mail_id IN ( ) ");
+               error = EMAIL_ERROR_MAIL_NOT_FOUND;
+               *output_string = strdup("mail_id IN () ");
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN START >>");
+       EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN START >>");
        int i = 0;
        if (!(mail_ids = (int *)em_malloc(sizeof(int) * count))) {
                EM_DEBUG_EXCEPTION("malloc for mail_ids failed...");
@@ -16229,30 +16145,30 @@ static int _make_filter_attach_rule_string(char *multi_user_name, email_list_fil
 
        for (i = 0; i < count; i++) {
                _get_table_field_data_int(result, &(mail_ids[i]), col_index++);
-               EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN [mail_id : %d] >>", mail_ids[i]);
+               EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN [mail_id : %d] >>", mail_ids[i]);
        }
 
-       EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN END [count : %d] >>", count);
+       EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN END [count : %d] >>", count);
        sqlite3_free_table(result);
        EMSTORAGE_FINISH_READ_TRANSACTION(true);
 
 //     sqlite3_db_release_memory(local_db_handle);
 
 
-       query_size = (10 * count) + strlen("mail_id IN ( )  ");
+       query_size = (10 * count) + strlen("mail_id IN ()  ");
 
        sql_query_string2 = em_malloc(query_size);
        if (sql_query_string2 == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "mail_id IN ( ");
+       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "mail_id IN (");
        for (i = 0; i < count-1; i++) {
                cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "%d, ", mail_ids[i]);
        }
-       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "%d ) ", mail_ids[count-1]);
+       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "%d) ", mail_ids[count-1]);
 
        *output_string = strdup(sql_query_string2);
 FINISH_OFF:
@@ -16281,7 +16197,7 @@ static int _make_filter_fts_rule_string(char *multi_user_name, email_list_filter
        sqlite3 *local_db_handle = NULL;
        int *mail_ids = NULL;
 
-       if(input_list_filter_rule == NULL || output_string == NULL) {
+       if (input_list_filter_rule == NULL || output_string == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return  EMAIL_ERROR_INVALID_PARAM;
        }
@@ -16299,7 +16215,7 @@ static int _make_filter_fts_rule_string(char *multi_user_name, email_list_filter
                SNPRINTF(result_rule_string, QUERY_SIZE, "WHERE %s MATCH \'%s\' ", field_name_string, key_value_string);
                break;
 
-       default :
+       default:
                EM_DEBUG_EXCEPTION("Invalid rule_type [%d]", input_list_filter_rule->rule_type);
                error = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -16311,19 +16227,19 @@ static int _make_filter_fts_rule_string(char *multi_user_name, email_list_filter
        SNPRINTF(sql_query_string, QUERY_SIZE, "SELECT mail_id FROM mail_text_tbl %s", result_rule_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF;},
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        col_index = 1;
 
        if (!count) {
                EM_DEBUG_LOG("No mail found...");
-               error= EMAIL_ERROR_MAIL_NOT_FOUND;
-               *output_string = strdup("mail_id IN ( ) ");
+               error = EMAIL_ERROR_MAIL_NOT_FOUND;
+               *output_string = strdup("mail_id IN () ");
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN START >>");
+       EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN START >>");
        int i = 0;
 
        if (!(mail_ids = (int *)em_malloc(sizeof(int) * count))) {
@@ -16334,29 +16250,29 @@ static int _make_filter_fts_rule_string(char *multi_user_name, email_list_filter
 
        for (i = 0; i < count; i++) {
                _get_table_field_data_int(result, &(mail_ids[i]), col_index++);
-               EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN [mail_id : %d] >>", mail_ids[i]);
+               EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN [mail_id : %d] >>", mail_ids[i]);
        }
 
-       EM_DEBUG_LOG_DEV (">>>> DATA ASSIGN END [count : %d] >>", count);
+       EM_DEBUG_LOG_DEV(">>>> DATA ASSIGN END [count : %d] >>", count);
        sqlite3_free_table(result);
        EMSTORAGE_FINISH_READ_TRANSACTION(true);
 
 //     sqlite3_db_release_memory(local_db_handle);
 
 
-       query_size = (10 * count) + strlen("mail_id IN ( )  ");
+       query_size = (10 * count) + strlen("mail_id IN ()  ");
        sql_query_string2 = em_malloc(query_size);
        if (sql_query_string2 == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
        int cur_query = 0;
-       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "mail_id IN ( ");
+       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "mail_id IN (");
        for (i = 0; i < count-1; i++) {
                cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "%d, ", mail_ids[i]);
        }
-       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "%d ) ", mail_ids[count-1]);
+       cur_query += SNPRINTF_OFFSET(sql_query_string2, cur_query, query_size, "%d) ", mail_ids[count-1]);
 
        *output_string = strdup(sql_query_string2);
 
@@ -16368,7 +16284,8 @@ FINISH_OFF:
        return error;
 }
 
-static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rule_t *input_sorting_rule, char **output_string) {
+static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rule_t *input_sorting_rule, char **output_string)
+{
        EM_DEBUG_FUNC_BEGIN("input_sorting_rule [%p], output_string [%p]", input_sorting_rule, output_string);
 
        char  result_rule_string[QUERY_SIZE] = { 0 , };
@@ -16382,30 +16299,29 @@ static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rul
        char *tmp_str2 = NULL;
        char query_per_account[QUERY_SIZE] = { 0 , };
 
-       if(input_sorting_rule->force_boolean_check) {
+       if (input_sorting_rule->force_boolean_check) {
                SNPRINTF(result_rule_string, QUERY_SIZE, "%s = 0 ", emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute));
-       }
-       else
+       } else
                EM_SAFE_STRCPY(result_rule_string, emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute));
 
        switch (input_sorting_rule->sort_order) {
-               case EMAIL_SORT_ORDER_ASCEND :
+               case EMAIL_SORT_ORDER_ASCEND:
                        EM_SAFE_STRCAT(result_rule_string, " ASC ");
                        break;
 
-               case EMAIL_SORT_ORDER_DESCEND :
+               case EMAIL_SORT_ORDER_DESCEND:
                        EM_SAFE_STRCAT(result_rule_string, " DESC ");
                        break;
 
-               case EMAIL_SORT_ORDER_NOCASE_ASCEND :
+               case EMAIL_SORT_ORDER_NOCASE_ASCEND:
                        EM_SAFE_STRCAT(result_rule_string, " COLLATE NOCASE ASC ");
                        break;
 
-               case EMAIL_SORT_ORDER_NOCASE_DESCEND :
+               case EMAIL_SORT_ORDER_NOCASE_DESCEND:
                        EM_SAFE_STRCAT(result_rule_string, " COLLATE NOCASE DESC ");
                        break;
 
-               case EMAIL_SORT_ORDER_TO_CCBCC :
+               case EMAIL_SORT_ORDER_TO_CCBCC:
                        memset(result_rule_string, 0, QUERY_SIZE);
                        if (input_sorting_rule->key_value.string_type_value)
                                sqlite3_snprintf(QUERY_SIZE, result_rule_string,
@@ -16413,7 +16329,7 @@ static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rul
                                                input_sorting_rule->key_value.string_type_value);
                        break;
 
-               case EMAIL_SORT_ORDER_TO_CC_BCC :
+               case EMAIL_SORT_ORDER_TO_CC_BCC:
                        memset(result_rule_string, 0, QUERY_SIZE);
                        if (input_sorting_rule->key_value.string_type_value)
                                sqlite3_snprintf(QUERY_SIZE, result_rule_string,
@@ -16421,7 +16337,7 @@ static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rul
                                                input_sorting_rule->key_value.string_type_value, input_sorting_rule->key_value.string_type_value);
                        break;
 
-               case EMAIL_SORT_ORDER_TO_CCBCC_ALL :
+               case EMAIL_SORT_ORDER_TO_CCBCC_ALL:
                        if (!emstorage_get_account_list(multi_user_name, &count, &account_tbl_array, true, false, NULL)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_account_list failed");
                                goto FINISH_OFF;
@@ -16461,7 +16377,7 @@ static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rul
                                emstorage_free_account(&account_tbl_array, count, NULL);
                        break;
 
-               case EMAIL_SORT_ORDER_LOCALIZE_ASCEND :
+               case EMAIL_SORT_ORDER_LOCALIZE_ASCEND:
                        memset(result_rule_string, 0, QUERY_SIZE);
                        sqlite3_snprintf(QUERY_SIZE, result_rule_string,
                                " CASE WHEN %s GLOB \'[][~`!@#$%%^&*()_-+=|\\{}:;<>,.?/ ]*\' THEN 1 ELSE 2 END ASC, %s COLLATE NOCASE ASC ",
@@ -16469,7 +16385,7 @@ static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rul
                                emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute));
                        break;
 
-               case EMAIL_SORT_ORDER_LOCALIZE_DESCEND :
+               case EMAIL_SORT_ORDER_LOCALIZE_DESCEND:
                        memset(result_rule_string, 0, QUERY_SIZE);
                        sqlite3_snprintf(QUERY_SIZE, result_rule_string,
                                " CASE WHEN %s GLOB \'[][~`!@#$%%^&*()_-+=|\\{}:;<>,.?/ ]*\' THEN 1 ELSE 2 END DESC, %s COLLATE NOCASE DESC ",
@@ -16477,7 +16393,7 @@ static int _make_order_rule_string(char *multi_user_name, email_list_sorting_rul
                                emcore_get_mail_field_name_by_attribute_type(input_sorting_rule->target_attribute));
                        break;
 
-               default :
+               default:
                        EM_DEBUG_EXCEPTION("Invalid sort_order [%d]", input_sorting_rule->sort_order);
                        ret = EMAIL_ERROR_INVALID_PARAM;
                        goto FINISH_OFF;
@@ -16501,7 +16417,7 @@ INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char
        char *conditional_clause_string = NULL;
        char *result_string_for_a_item = NULL;
 
-       if ( (input_filter_count > 0 && !input_filter_list) || (input_sorting_rule_count > 0 && !input_sorting_rule_list) || output_conditional_clause == NULL) {
+       if ((input_filter_count > 0 && !input_filter_list) || (input_sorting_rule_count > 0 && !input_sorting_rule_list) || output_conditional_clause == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -16512,58 +16428,58 @@ INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char
                return EMAIL_ERROR_OUT_OF_MEMORY;
        }
 
-       if(input_filter_count > 0) {
+       if (input_filter_count > 0) {
                query_size = QUERY_SIZE;
-               strcpy(conditional_clause_string,  " WHERE ");
+               strcpy(conditional_clause_string, " WHERE ");
 
-               for ( i = 0; i < input_filter_count; i++) {
+               for (i = 0; i < input_filter_count; i++) {
                        switch (input_filter_list[i].list_filter_item_type) {
-                       case EMAIL_LIST_FILTER_ITEM_RULE :
+                       case EMAIL_LIST_FILTER_ITEM_RULE:
                                EM_DEBUG_LOG_DEV("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_RULE", i);
                                _make_filter_rule_string(&(input_filter_list[i].list_filter_item.rule), &result_string_for_a_item);
                                break;
 
-                       case EMAIL_LIST_FILTER_ITEM_RULE_FTS :
+                       case EMAIL_LIST_FILTER_ITEM_RULE_FTS:
                                EM_DEBUG_LOG_DEV("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_RULE_FTS", i);
                                _make_filter_fts_rule_string(multi_user_name, &(input_filter_list[i].list_filter_item.rule_fts), &result_string_for_a_item);
                                break;
 
-                       case EMAIL_LIST_FILTER_ITEM_RULE_ATTACH :
+                       case EMAIL_LIST_FILTER_ITEM_RULE_ATTACH:
                                EM_DEBUG_LOG_DEV("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_RULE_ATTACH", i);
                                _make_filter_attach_rule_string(multi_user_name, &(input_filter_list[i].list_filter_item.rule_attach), &result_string_for_a_item);
                                break;
 
-                       case EMAIL_LIST_FILTER_ITEM_OPERATOR :
+                       case EMAIL_LIST_FILTER_ITEM_OPERATOR:
                                EM_DEBUG_LOG_DEV("[%d]list_filter_item_type is EMAIL_LIST_FILTER_ITEM_OPERATOR", i);
-                               switch(input_filter_list[i].list_filter_item.operator_type) {
-                               case EMAIL_LIST_FILTER_OPERATOR_AND :
+                               switch (input_filter_list[i].list_filter_item.operator_type) {
+                               case EMAIL_LIST_FILTER_OPERATOR_AND:
                                        result_string_for_a_item = strdup("AND ");
                                        break;
-                               case EMAIL_LIST_FILTER_OPERATOR_OR :
+                               case EMAIL_LIST_FILTER_OPERATOR_OR:
                                        result_string_for_a_item = strdup("OR ");
                                        break;
-                               case EMAIL_LIST_FILTER_OPERATOR_LEFT_PARENTHESIS :
+                               case EMAIL_LIST_FILTER_OPERATOR_LEFT_PARENTHESIS:
                                        result_string_for_a_item = strdup(" (");
                                        break;
-                               case EMAIL_LIST_FILTER_OPERATOR_RIGHT_PARENTHESIS :
+                               case EMAIL_LIST_FILTER_OPERATOR_RIGHT_PARENTHESIS:
                                        result_string_for_a_item = strdup(") ");
                                        break;
                                }
                                break;
 
-                       default :
+                       default:
                                EM_DEBUG_EXCEPTION("Invalid list_filter_item_type [%d]", input_filter_list[i].list_filter_item_type);
                                ret = EMAIL_ERROR_INVALID_PARAM;
                                goto FINISH_OFF;
                        }
 
-                       if(result_string_for_a_item == NULL) {
+                       if (result_string_for_a_item == NULL) {
                                EM_DEBUG_EXCEPTION("result_string_for_a_item is null");
                                ret = EMAIL_ERROR_INVALID_PARAM;
                                goto FINISH_OFF;
                        }
 
-                       if(strlen(conditional_clause_string) + EM_SAFE_STRLEN(result_string_for_a_item) >= query_size) { /* prevent 34364 */
+                       if (strlen(conditional_clause_string) + EM_SAFE_STRLEN(result_string_for_a_item) >= query_size) { /* prevent 34364 */
                                EM_DEBUG_LOG("QUERY is too long");
                                new_query_size = EM_SAFE_STRLEN(result_string_for_a_item) + EM_SAFE_STRLEN(conditional_clause_string) + QUERY_SIZE;
                                conditional_clause_string = realloc(conditional_clause_string, new_query_size);
@@ -16581,15 +16497,15 @@ INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char
                }
        }
 
-       if(input_sorting_rule_count > 0) {
+       if (input_sorting_rule_count > 0) {
                strcat(conditional_clause_string, "ORDER BY ");
 
-               for ( i = 0; i < input_sorting_rule_count; i++) {
-                       if(ret = _make_order_rule_string(multi_user_name, &input_sorting_rule_list[i], &result_string_for_a_item)) != EMAIL_ERROR_NONE) {
+               for (i = 0; i < input_sorting_rule_count; i++) {
+                       if ((ret = _make_order_rule_string(multi_user_name, &input_sorting_rule_list[i], &result_string_for_a_item)) != EMAIL_ERROR_NONE) {
                                EM_DEBUG_EXCEPTION("_make_order_rule_string failed. [%d]", ret);
                                goto FINISH_OFF;
                        }
-                       if(i > 0)
+                       if (i > 0)
                                strcat(conditional_clause_string, ", ");
                        strcat(conditional_clause_string, result_string_for_a_item);
                        EM_SAFE_FREE(result_string_for_a_item);
@@ -16620,41 +16536,39 @@ INTERNAL_FUNC int emstorage_free_list_filter(email_list_filter_t **input_filter_
 
        EM_IF_NULL_RETURN_VALUE(input_filter_list, EMAIL_ERROR_INVALID_PARAM);
 
-       for ( i = 0; i < input_filter_count; i++) {
+       for (i = 0; i < input_filter_count; i++) {
                temp_filter_list = (*input_filter_list) + i;
                if (!temp_filter_list) {
                        continue;
                }
 
-               if(temp_filter_list->list_filter_item_type == EMAIL_LIST_FILTER_ITEM_RULE) {
-                       switch(temp_filter_list->list_filter_item.rule.target_attribute) {
-                       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME :
-                       case EMAIL_MAIL_ATTRIBUTE_SUBJECT :
-                       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME :
-                       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID :
-                       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID :
-                       case EMAIL_MAIL_ATTRIBUTE_FROM :
-                       case EMAIL_MAIL_ATTRIBUTE_TO :
-                       case EMAIL_MAIL_ATTRIBUTE_CC :
-                       case EMAIL_MAIL_ATTRIBUTE_BCC :
-                       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN :
-                       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML :
-                       case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT :
+               if (temp_filter_list->list_filter_item_type == EMAIL_LIST_FILTER_ITEM_RULE) {
+                       switch (temp_filter_list->list_filter_item.rule.target_attribute) {
+                       case EMAIL_MAIL_ATTRIBUTE_MAILBOX_NAME:
+                       case EMAIL_MAIL_ATTRIBUTE_SUBJECT:
+                       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAILBOX_NAME:
+                       case EMAIL_MAIL_ATTRIBUTE_SERVER_MAIL_ID:
+                       case EMAIL_MAIL_ATTRIBUTE_MESSAGE_ID:
+                       case EMAIL_MAIL_ATTRIBUTE_FROM:
+                       case EMAIL_MAIL_ATTRIBUTE_TO:
+                       case EMAIL_MAIL_ATTRIBUTE_CC:
+                       case EMAIL_MAIL_ATTRIBUTE_BCC:
+                       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_PLAIN:
+                       case EMAIL_MAIL_ATTRIBUTE_FILE_PATH_HTML:
+                       case EMAIL_MAIL_ATTRIBUTE_PREVIEW_TEXT:
                                EM_SAFE_FREE(temp_filter_list->list_filter_item.rule.key_value.string_type_value);
                                break;
-                       default :
+                       default:
                                break;
                        }
-               }
-               else if(temp_filter_list->list_filter_item_type == EMAIL_LIST_FILTER_ITEM_RULE_FTS && temp_filter_list->list_filter_item.rule_fts.target_attribute == EMAIL_MAIL_TEXT_ATTRIBUTE_FULL_TEXT) {
+               } else if (temp_filter_list->list_filter_item_type == EMAIL_LIST_FILTER_ITEM_RULE_FTS && temp_filter_list->list_filter_item.rule_fts.target_attribute == EMAIL_MAIL_TEXT_ATTRIBUTE_FULL_TEXT) {
                                EM_SAFE_FREE(temp_filter_list->list_filter_item.rule_fts.key_value.string_type_value);
-               }
-               else if(temp_filter_list->list_filter_item_type == EMAIL_LIST_FILTER_ITEM_RULE_ATTACH && temp_filter_list->list_filter_item.rule_attach.target_attribute == EMAIL_MAIL_ATTACH_ATTRIBUTE_ATTACHMENT_NAME) {
+               } else if (temp_filter_list->list_filter_item_type == EMAIL_LIST_FILTER_ITEM_RULE_ATTACH && temp_filter_list->list_filter_item.rule_attach.target_attribute == EMAIL_MAIL_ATTACH_ATTRIBUTE_ATTACHMENT_NAME) {
                                EM_SAFE_FREE(temp_filter_list->list_filter_item.rule_attach.key_value.string_type_value);
                }
        }
 
-       EM_SAFE_FREE (*input_filter_list);
+       EM_SAFE_FREE(*input_filter_list);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
        return err;
@@ -16675,7 +16589,7 @@ INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t in
        char *sql = "SELECT max(rowid) FROM mail_task_tbl;";
        char **result = NULL;
 
-       if (input_task_parameter == NULL || output_task_id == NULL)  {
+       if (input_task_parameter == NULL || output_task_id == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -16684,7 +16598,7 @@ INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t in
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, input_transaction, err);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
        if (NULL == result[1])
@@ -16710,7 +16624,7 @@ INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t in
                ") ");
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EM_DEBUG_LOG_SEC(">>>> SQL STMT [%s] ", sql_query_string);
@@ -16726,9 +16640,9 @@ INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t in
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
 
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {err = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {err = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle)));
 
        ret = (err == EMAIL_ERROR_NONE);
@@ -16736,9 +16650,9 @@ INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t in
 FINISH_OFF:
        EMSTORAGE_FINISH_WRITE_TRANSACTION(multi_user_name, input_transaction, ret, err);
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        err = EMAIL_ERROR_DB_FAILURE;
                }
@@ -16757,7 +16671,7 @@ INTERNAL_FUNC int emstorage_delete_task(char *multi_user_name, int task_id, int
 
        sqlite3 *local_db_handle = NULL;
 
-       if (task_id < 0)  {
+       if (task_id < 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
@@ -16843,7 +16757,7 @@ INTERNAL_FUNC int emstorage_query_task(char *multi_user_name,
        EM_DEBUG_LOG_SEC("emstorage_query_mail_list : query[%s].", sql_query_string);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {err = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        count = atoi(result[1]);
@@ -16864,11 +16778,11 @@ INTERNAL_FUNC int emstorage_query_task(char *multi_user_name,
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
        EM_DEBUG_LOG("After sqlite3_prepare_v2 hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (rc == SQLITE_DONE) {
@@ -16884,7 +16798,7 @@ INTERNAL_FUNC int emstorage_query_task(char *multi_user_name,
                goto FINISH_OFF;
        }
 
-       for (i = 0; i < count; i++)  {
+       for (i = 0; i < count; i++) {
                /*  get recordset */
                field_index = 0;
 
@@ -16897,13 +16811,13 @@ INTERNAL_FUNC int emstorage_query_task(char *multi_user_name,
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
                EM_DEBUG_LOG("after sqlite3_step(), i = %d, rc = %d.", i,  rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {err = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {err = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
        }
 
 FINISH_OFF:
 
-       if (err == EMAIL_ERROR_NONE)  {
+       if (err == EMAIL_ERROR_NONE) {
                if (output_task_list)
                        *output_task_list = task_item_from_tbl;
                *output_task_count = count;
@@ -16916,10 +16830,10 @@ FINISH_OFF:
                }
        }
 
-       if (hStmt != NULL)  {
+       if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
                hStmt = NULL;
-               if (rc != SQLITE_OK)  {
+               if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        err = EMAIL_ERROR_DB_FAILURE;
                }
@@ -16954,7 +16868,7 @@ INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *mult
        where_pararaph_length = EM_SAFE_STRLEN(message_id) + 100;
        where_pararaph = em_malloc(sizeof(char) * where_pararaph_length);
        if (where_pararaph == NULL) {
-               EM_DEBUG_EXCEPTION("em_malloc failed");
+               EM_DEBUG_EXCEPTION("em_mallocfailed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -16970,7 +16884,7 @@ INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *mult
        EM_DEBUG_LOG_SEC("query[%s]", sql_query_string);
 
         EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, &count, 0, NULL), rc);
-        EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+        EM_DEBUG_DB_EXEC((SQLITE_OK != rc && -1 != rc), {err = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                 ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
@@ -16983,7 +16897,7 @@ INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *mult
                memset(sql_query_string, 0x00, QUERY_SIZE);
                sqlite3_snprintf(sizeof(sql_query_string), sql_query_string, "UPDATE mail_tbl set server_mail_id = '%q'", server_uid);
 
-                if(strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE)
+                if (strlen(sql_query_string) + strlen(where_pararaph) < QUERY_SIZE)
                         strcat(sql_query_string, where_pararaph);
 
                err = emstorage_exec_query_by_prepare_v2(local_db_handle, sql_query_string);
@@ -17038,7 +16952,7 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(char *multi_user_name, em
        memset(sql_query_string, 0x00, sizeof(sql_query_string));
        SNPRINTF(sql_query_string, sizeof(sql_query_string),
                "INSERT INTO mail_auto_download_activity_tbl VALUES "
-               "( "
+               "("
                "? "  /* Activity ID */
                ",?"  /* Status */
                ",?"  /* Account ID */
@@ -17054,10 +16968,10 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(char *multi_user_name, em
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
 
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
-       if (NULL==result[1]) rc = 1;
+       if (NULL == result[1]) rc = 1;
        else rc = atoi(result[1])+1;
        sqlite3_free_table(result);
        result = NULL;
@@ -17072,7 +16986,7 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(char *multi_user_name, em
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
@@ -17087,9 +17001,9 @@ INTERNAL_FUNC int emstorage_add_auto_download_activity(char *multi_user_name, em
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
 
-       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc == SQLITE_FULL), {error = EMAIL_ERROR_MAIL_MEMORY_FULL; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d, errmsg = %s.", rc, sqlite3_errmsg(local_db_handle)));
 
        ret = true;
@@ -17148,7 +17062,7 @@ INTERNAL_FUNC int emstorage_delete_auto_download_activity(char *multi_user_name,
 
        /*  validate activity existence */
        rc = sqlite3_changes(local_db_handle);
-       if (rc == 0)  {
+       if (rc == 0) {
                EM_DEBUG_EXCEPTION("No matching activity found");
                error = EMAIL_ERROR_DATA_NOT_FOUND;
                ret = true;
@@ -17297,7 +17211,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity(char *multi_user_name, in
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -17322,12 +17236,12 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity(char *multi_user_name, in
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
        EM_DEBUG_LOG(" Bbefore sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (!(event_list = (email_event_auto_download *)em_malloc(sizeof(email_event_auto_download)*(*count)))) {
@@ -17337,7 +17251,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity(char *multi_user_name, in
                goto FINISH_OFF;
        }
 
-       for (i=0; i < (*count); i++) {
+       for (i = 0; i < (*count); i++) {
                _get_stmt_field_data_int(hStmt, &(event_list[i].activity_id), ACTIVITY_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL);
                _get_stmt_field_data_int(hStmt, &(event_list[i].status), STATUS_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL);
                _get_stmt_field_data_int(hStmt, &(event_list[i].account_id), ACCOUNT_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL);
@@ -17346,7 +17260,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity(char *multi_user_name, in
                _get_stmt_field_data_int(hStmt, &(event_list[i].mailbox_id), MAILBOX_ID_IDX_MAIL_AUTO_DOWNLOAD_ACTIVITY_TBL);
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF;},
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
        }
 
@@ -17408,13 +17322,13 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity_count(char *multi_user_na
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
-       EM_DEBUG_LOG_DEV ("before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF;},
+       EM_DEBUG_LOG_DEV("before sqlite3_prepare hStmt = %p", hStmt);
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF;},
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        _get_stmt_field_data_int(hStmt, activity_count, 0);
@@ -17427,7 +17341,7 @@ FINISH_OFF:
 
        if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               hStmt=NULL;
+               hStmt = NULL;
                if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
@@ -17467,7 +17381,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_account_list(char *multi_user_name
        EMSTORAGE_START_READ_TRANSACTION(transaction);
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -17492,16 +17406,16 @@ INTERNAL_FUNC int emstorage_get_auto_download_account_list(char *multi_user_name
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
        EM_DEBUG_LOG("Before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF;},
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        if (NULL == (result_account_list = (int *)em_malloc(sizeof(int)*(*count)))) {
-               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -17510,7 +17424,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_account_list(char *multi_user_name
                _get_stmt_field_data_int(hStmt, result_account_list + i, 0);
 
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
                EM_DEBUG_LOG("account id -> %d", result_account_list[i]);
        }
@@ -17569,7 +17483,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(char *multi_user_name
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_get_table(local_db_handle, sql_query_string, &result, NULL, NULL, NULL), rc);
-       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE;sqlite3_free_table(result);goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC(SQLITE_OK != rc, {error = EMAIL_ERROR_DB_FAILURE; sqlite3_free_table(result); goto FINISH_OFF; },
                ("SQL(%s) sqlite3_get_table fail:%d -%s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        *count = atoi(result[1]);
@@ -17593,17 +17507,17 @@ INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(char *multi_user_name
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
 
 
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        mbox_list = (int *)em_malloc(sizeof(int)*(*count)); /* prevent */
        if (mbox_list == NULL) {
-               EM_DEBUG_EXCEPTION(" em_malloc failed...");
+               EM_DEBUG_EXCEPTION(" em_mallocfailed...");
                error = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
@@ -17612,7 +17526,7 @@ INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(char *multi_user_name
                _get_stmt_field_data_int(hStmt, mbox_list + i, 0);
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
 
-               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+               EM_DEBUG_DB_EXEC((rc != SQLITE_ROW && rc != SQLITE_DONE), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                        ("sqlite3_step fail:%d", rc));
                EM_DEBUG_LOG("mbox_list %d", mbox_list[i]);
        }
@@ -17670,11 +17584,11 @@ INTERNAL_FUNC int emstorage_get_auto_download_activity_count_by_mailbox(char *mu
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_prepare_v2(local_db_handle, sql_query_string, EM_SAFE_STRLEN(sql_query_string), &hStmt, NULL), rc);
        EM_DEBUG_LOG("before sqlite3_prepare hStmt = %p", hStmt);
-       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((SQLITE_OK != rc), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("SQL(%s) sqlite3_prepare fail:(%d) %s", sql_query_string, rc, sqlite3_errmsg(local_db_handle)));
 
        EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_step(hStmt), rc);
-       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE;goto FINISH_OFF; },
+       EM_DEBUG_DB_EXEC((rc != SQLITE_ROW), {error = EMAIL_ERROR_DB_FAILURE; goto FINISH_OFF; },
                ("sqlite3_step fail:%d", rc));
 
        _get_stmt_field_data_int(hStmt, activity_count, 0);
@@ -17687,7 +17601,7 @@ FINISH_OFF:
 
        if (hStmt != NULL) {
                rc = sqlite3_finalize(hStmt);
-               hStmt=NULL;
+               hStmt = NULL;
                if (rc != SQLITE_OK) {
                        EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
                        error = EMAIL_ERROR_DB_FAILURE;
@@ -17776,7 +17690,7 @@ static int get_column_information_from_table_callback(void *arg1, int argc, char
        GList *new_list = *((GList**)arg1);
        email_column_info_t *column_info_item = NULL;
 
-       for (i = 0; i < argc; ++i)  {
+       for (i = 0; i < argc; ++i) {
                /* EM_DEBUG_LOG("%s = %s", input_column_name[i], argv[i]); */
                if (EM_SAFE_STRCMP(input_column_name[i], "name") == 0) {
                        if (column_name)
@@ -17784,8 +17698,7 @@ static int get_column_information_from_table_callback(void *arg1, int argc, char
 
                        column_name = EM_SAFE_STRDUP(argv[i]);
                        validated = 1;
-               }
-               else if (EM_SAFE_STRCMP(input_column_name[i], "type") == 0) {
+               } else if (EM_SAFE_STRCMP(input_column_name[i], "type") == 0) {
                        if (column_type)
                                EM_SAFE_FREE(column_type);
 
@@ -17797,7 +17710,7 @@ static int get_column_information_from_table_callback(void *arg1, int argc, char
                EM_DEBUG_LOG("column_name[%s] column_type[%s]", column_name, column_type);
                column_info_item = em_malloc(sizeof(email_column_info_t));
         if (column_info_item == NULL) {
-            EM_DEBUG_EXCEPTION("em_malloc failed");
+            EM_DEBUG_EXCEPTION("em_mallocfailed");
             goto FINISH_OFF;
         }
 
@@ -17873,8 +17786,7 @@ FINISH_OFF:
 
        if (error == EMAIL_ERROR_NONE) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
-       }
-       else {
+       } else {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "rollback", NULL, NULL, NULL), rc);
        }
 
@@ -17906,8 +17818,7 @@ FINISH_OFF:
 
        if (error == EMAIL_ERROR_NONE) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
-       }
-       else {
+       } else {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "rollback", NULL, NULL, NULL), rc);
        }
 
@@ -17939,8 +17850,7 @@ FINISH_OFF:
 
        if (error == EMAIL_ERROR_NONE) {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "END;", NULL, NULL, NULL), rc);
-       }
-       else {
+       } else {
                EMSTORAGE_PROTECTED_FUNC_CALL(sqlite3_exec(local_db_handle, "rollback", NULL, NULL, NULL), rc);
        }
 
@@ -18044,8 +17954,7 @@ INTERNAL_FUNC int emstorage_update_db_table_schema(char *multi_user_name)
                        }
 
                        emstorage_drop_table(multi_user_name, table_names[i][1]);
-               }
-               else
+               } else
                        EM_DEBUG_LOG("Skipped");
        }
 
@@ -18061,7 +17970,7 @@ FINISH_OFF:
        }
 
        found_data = g_list_first(column_list_of_old_table);
-       while(found_data != NULL) {
+       while (found_data != NULL) {
                p_column_info = (email_column_info_t *)found_data->data;
                EM_SAFE_FREE(p_column_info->column_name);
                EM_SAFE_FREE(p_column_info->column_type);
@@ -18072,7 +17981,7 @@ FINISH_OFF:
        g_list_free(column_list_of_old_table);
 
        found_data = g_list_first(column_list_of_new_table);
-       while(found_data != NULL) {
+       while (found_data != NULL) {
                p_column_info = (email_column_info_t *)found_data->data;
                EM_SAFE_FREE(p_column_info->column_name);
                EM_SAFE_FREE(p_column_info->column_type);
index 8d803b2..11cfec5 100755 (executable)
@@ -116,7 +116,7 @@ INTERNAL_FUNC int emdaemon_delete_account(char *multi_user_name, int account_id,
 
 static email_account_t* duplicate_account(email_account_t *src)
 {
-       if(!src) {
+       if (!src) {
                EM_DEBUG_EXCEPTION("INVALID_PARAM");
                return NULL;
        }
@@ -144,7 +144,7 @@ static email_account_t* duplicate_account(email_account_t *src)
        dst->options.display_name_from = EM_SAFE_STRDUP(src->options.display_name_from);
        dst->options.signature         = EM_SAFE_STRDUP(src->options.signature);
        dst->user_data                = (void*) em_malloc(src->user_data_length);
-       if( !dst->user_data ) {
+       if (!dst->user_data) {
                EM_DEBUG_EXCEPTION("em_malloc failed");
                emcore_free_account(dst);
                EM_SAFE_FREE(dst);
@@ -266,7 +266,7 @@ INTERNAL_FUNC int emdaemon_validate_account_and_create(char *multi_user_name, em
        email_event_t *event_data = NULL;
 
        event_data = em_malloc(sizeof(email_event_t));
-       if(!event_data) { /*prevent 53093*/
+       if (!event_data) { /*prevent 53093*/
                EM_DEBUG_EXCEPTION("em_malloc failed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -317,13 +317,13 @@ INTERNAL_FUNC int emdaemon_update_account(char *multi_user_name, int account_id,
                goto FINISH_OFF;
        }
 
-       if((old_account_info = emcore_get_account_reference(multi_user_name, account_id, true)) == NULL) {
+       if ((old_account_info = emcore_get_account_reference(multi_user_name, account_id, true)) == NULL) {
                EM_DEBUG_EXCEPTION("emcore_get_account_reference failed ");
                goto FINISH_OFF;
        }
 
-       if(new_account->user_email_address) {
-               if ((err = em_verify_email_address (new_account->user_email_address)) != EMAIL_ERROR_NONE) {
+       if (new_account->user_email_address) {
+               if ((err = em_verify_email_address(new_account->user_email_address)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("em_verify_email_address error [%d]", err);
                        goto FINISH_OFF;
                }
@@ -338,7 +338,7 @@ INTERNAL_FUNC int emdaemon_update_account(char *multi_user_name, int account_id,
        }
 
        new_account_tbl = em_malloc(sizeof(emstorage_account_tbl_t));
-       if(!new_account_tbl) {
+       if (!new_account_tbl) {
                EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -363,11 +363,11 @@ INTERNAL_FUNC int emdaemon_update_account(char *multi_user_name, int account_id,
 
 
 #ifdef __FEATURE_AUTO_POLLING__
-       if(change_in_auto_polling_option) {
-               if(!emdaemon_remove_polling_alarm(account_id))
+       if (change_in_auto_polling_option) {
+               if (!emdaemon_remove_polling_alarm(account_id))
                        EM_DEBUG_LOG("emdaemon_remove_polling_alarm failed");
 
-               if(!emdaemon_add_polling_alarm(multi_user_name, account_id))
+               if (!emdaemon_add_polling_alarm(multi_user_name, account_id))
                        EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm failed");
 
 #ifdef __FEATURE_IMAP_IDLE__
@@ -380,7 +380,7 @@ INTERNAL_FUNC int emdaemon_update_account(char *multi_user_name, int account_id,
 
 FINISH_OFF:
 
-       if(new_account_tbl)
+       if (new_account_tbl)
                emstorage_free_account(&new_account_tbl, 1, NULL);
 
        if (old_account_info) {
@@ -395,7 +395,7 @@ FINISH_OFF:
        return ret;
 }
 
-INTERNAL_FUNC int emdaemon_validate_account_and_update(char *multi_user_name, int old_account_id, email_account_t* new_account_info, int *handle,int *err_code)
+INTERNAL_FUNC int emdaemon_validate_account_and_update(char *multi_user_name, int old_account_id, email_account_t *new_account_info, int *handle, int *err_code)
 {
        EM_DEBUG_FUNC_BEGIN("account[%d], new_account_info[%p], handle[%p], err_code[%p]", old_account_id, new_account_info, handle, err_code);
 
@@ -492,7 +492,7 @@ INTERNAL_FUNC int emdaemon_get_account(char *multi_user_name, int account_id, in
        ret = true;
 
 FINISH_OFF:
-       if(account_tbl)
+       if (account_tbl)
                emstorage_free_account(&account_tbl, 1, NULL);
        if (err_code)
                *err_code = err;
@@ -519,21 +519,21 @@ INTERNAL_FUNC int emdaemon_get_account_list(char *multi_user_name, email_account
                goto FINISH_OFF;
        }
 
-       if(account_tbl_array && (*count) > 0) {
+       if (account_tbl_array && (*count) > 0) {
                *account_list = (email_account_t*)em_malloc(sizeof(email_account_t) * (*count));
-               if(!*account_list) {
+               if (!*account_list) {
                        EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
                        goto FINISH_OFF;
                }
 
-               for(i = 0 ; i < (*count); i++)
+               for (i = 0 ; i < (*count); i++)
                        em_convert_account_tbl_to_account(account_tbl_array + i, (*account_list) + i);
        }
 
        ret = true;
 
 FINISH_OFF:
-       if(account_tbl_array)
+       if (account_tbl_array)
                emstorage_free_account(&account_tbl_array, (*count), NULL);
 
        if (err_code != NULL)
@@ -819,7 +819,7 @@ INTERNAL_FUNC int emdaemon_insert_accountinfo_to_contact(email_account_t* accoun
 {
        EM_DEBUG_FUNC_BEGIN();
 
-       if(!account)
+       if (!account)
                return false;
 
        int ret = false;
@@ -831,7 +831,7 @@ INTERNAL_FUNC int emdaemon_update_accountinfo_to_contact(email_account_t* old_ac
 {
        EM_DEBUG_FUNC_BEGIN();
 
-       if(!old_account || !new_account)
+       if (!old_account || !new_account)
                return false;
 
        int ret = false;
index 5ab6884..dd6e593 100755 (executable)
@@ -51,18 +51,18 @@ INTERNAL_FUNC int emdaemon_add_polling_alarm(char *multi_user_name, int input_ac
        EM_DEBUG_FUNC_BEGIN("input_account_id[%d]", input_account_id);
        int err = EMAIL_ERROR_NONE;
 
-       if(input_account_id <= 0) {
+       if (input_account_id <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if((err = emdaemon_check_auto_polling_started(input_account_id)) != EMAIL_ERROR_ALARM_DATA_NOT_FOUND) {
+       if ((err = emdaemon_check_auto_polling_started(input_account_id)) != EMAIL_ERROR_ALARM_DATA_NOT_FOUND) {
                EM_DEBUG_EXCEPTION("polling alarm is already exist");
                goto FINISH_OFF;
        }
 
-       if((err = _emdaemon_create_alarm_for_auto_polling(multi_user_name, input_account_id)) != EMAIL_ERROR_NONE) {
+       if ((err = _emdaemon_create_alarm_for_auto_polling(multi_user_name, input_account_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("_emdaemon_create_alarm_for_auto_polling failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -78,8 +78,8 @@ INTERNAL_FUNC int emdaemon_remove_polling_alarm(int account_id)
        int err = EMAIL_ERROR_NONE;
 
        /* delete from list */
-       if((err = emcore_delete_alram_data_by_reference_id(EMAIL_ALARM_CLASS_AUTO_POLLING, account_id)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_LOG ("emcore_delete_alram_data_by_reference_id return [%d]", err);
+       if ((err = emcore_delete_alram_data_by_reference_id(EMAIL_ALARM_CLASS_AUTO_POLLING, account_id)) != EMAIL_ERROR_NONE) {
+               EM_DEBUG_LOG("emcore_delete_alram_data_by_reference_id return [%d]", err);
        }
 
        EM_DEBUG_FUNC_END("err[%d]", err);
@@ -92,8 +92,8 @@ INTERNAL_FUNC int emdaemon_check_auto_polling_started(int account_id)
        int err = EMAIL_ERROR_NONE;
        email_alarm_data_t *alarm_data = NULL;
 
-       if((err = emcore_get_alarm_data_by_reference_id(EMAIL_ALARM_CLASS_AUTO_POLLING, account_id, &alarm_data)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_LOG ("emcore_get_alarm_data_by_reference_id error [%d]", err);
+       if ((err = emcore_get_alarm_data_by_reference_id(EMAIL_ALARM_CLASS_AUTO_POLLING, account_id, &alarm_data)) != EMAIL_ERROR_NONE) {
+               EM_DEBUG_LOG("emcore_get_alarm_data_by_reference_id error [%d]", err);
                goto FINISH_OFF;
        }
 
@@ -117,13 +117,12 @@ INTERNAL_FUNC int emdaemon_alarm_polling_cb(email_alarm_data_t *alarm_data, void
        int wifi_status = 0;
        email_account_t *ref_account = NULL;
 
-       if(!_emdaemon_get_polling_account_and_timeinterval(alarm_data, &account_id, &timer_interval)) {
+       if (!_emdaemon_get_polling_account_and_timeinterval(alarm_data, &account_id, &timer_interval)) {
                EM_DEBUG_EXCEPTION("email_get_polling_account failed");
                return false;
        }
 
-       EM_DEBUG_LOG("target account_id [%d]",account_id);
-
+       EM_DEBUG_LOG("target account_id [%d]", account_id);
        /* create alarm, for polling */
        if ((err = _emdaemon_create_alarm_for_auto_polling(alarm_data->multi_user_name, account_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("_emdaemon_create_alarm_for_auto_polling failed [%d]", err);
@@ -158,20 +157,20 @@ INTERNAL_FUNC int emdaemon_alarm_polling_cb(email_alarm_data_t *alarm_data, void
                goto FINISH_OFF;
        }
 
-       if (!emstorage_get_mailbox_id_by_mailbox_type(alarm_data->multi_user_name, account_id,EMAIL_MAILBOX_TYPE_INBOX, &mailbox_id, false, &err))  {
+       if (!emstorage_get_mailbox_id_by_mailbox_type(alarm_data->multi_user_name, account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_id, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
                goto FINISH_OFF;
        }
 
-       if (!emdaemon_sync_header(alarm_data->multi_user_name, account_id, mailbox_id, &handle, &err))  {
+       if (!emdaemon_sync_header(alarm_data->multi_user_name, account_id, mailbox_id, &handle, &err)) {
                EM_DEBUG_EXCEPTION("emdaemon_sync_header falied [%d]", err);
                goto FINISH_OFF;
        }
 
        ret = true;
-FINISH_OFF :
+FINISH_OFF:
 
-       if(ref_account) {
+       if (ref_account) {
                emcore_free_account(ref_account);
                EM_SAFE_FREE(ref_account);
        }
@@ -187,7 +186,7 @@ static int _emdaemon_get_polling_account_and_timeinterval(email_alarm_data_t *al
        int err = EMAIL_ERROR_NONE;
        email_account_t *account = NULL;
 
-       if(!alarm_data || !account_id) {
+       if (!alarm_data || !account_id) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -195,7 +194,7 @@ static int _emdaemon_get_polling_account_and_timeinterval(email_alarm_data_t *al
 
        account = emcore_get_account_reference(alarm_data->multi_user_name, alarm_data->reference_id, false);
        if (account == NULL) {
-               EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]",err);
+               EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", err);
                goto FINISH_OFF;
        }
 
@@ -219,7 +218,7 @@ static int _emdaemon_create_alarm_for_auto_polling(char *multi_user_name, int in
        time_t trigger_at_time;
        time_t current_time;
 
-       if(input_account_id <= 0) {
+       if (input_account_id <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -228,15 +227,14 @@ static int _emdaemon_create_alarm_for_auto_polling(char *multi_user_name, int in
        time(&current_time);
 
        if ((err = emcore_calc_next_time_to_sync(multi_user_name, input_account_id, current_time, &trigger_at_time)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
+               EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]", err);
                goto FINISH_OFF;
        }
 
        if (trigger_at_time == 0) {
                EM_DEBUG_LOG("trigger_at_time is 0. It means auto polling is disabled");
-       }
-       else if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_AUTO_POLLING, input_account_id, emdaemon_alarm_polling_cb, NULL)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]",err);
+       } else if ((err = emcore_add_alarm(multi_user_name, trigger_at_time, EMAIL_ALARM_CLASS_AUTO_POLLING, input_account_id, emdaemon_alarm_polling_cb, NULL)) != EMAIL_ERROR_NONE) {
+               EM_DEBUG_EXCEPTION("emcore_add_alarm failed [%d]", err);
                goto FINISH_OFF;
        }
 
index d6af25a..998477f 100755 (executable)
@@ -107,8 +107,7 @@ static void _cb_parser_start_element(void* ctx, WBXMLTag* element, WBXMLAttribut
        if (empty) {
                EM_DEBUG_LOG_SEC("/>");
                strcat((char *)p, "/>");
-       }
-       else {
+       } else {
                EM_DEBUG_LOG_SEC(">");
                strcat((char *)p, ">");
        }
@@ -129,7 +128,7 @@ static void _cb_parser_characters(void* ctx, WB_UTINY* ch, WB_ULONG start, WB_UL
        EM_DEBUG_FUNC_END();
 }
 
-static int _get_addr_from_element(unsigned char* elm,int* type, unsigned char** incoming_server_user_name, unsigned char** host_addr, unsigned char** mbox_name, unsigned char** auth_type)
+static int _get_addr_from_element(unsigned char *elm, int *type, unsigned char **incoming_server_user_name, unsigned char **host_addr, unsigned char **mbox_name, unsigned char **auth_type)
 {
        EM_DEBUG_FUNC_BEGIN();
 
@@ -178,8 +177,7 @@ static int _get_addr_from_element(unsigned char* elm,int* type, unsigned char**
                        *s = '\0';
                        if (user || *(p - 3) == '/') {
                                if (strncmp((char *)p, "AUTH=", 5) == 0) auth = (unsigned char*)EM_SAFE_STRDUP((char *)p + 5);
-                       }
-                       else
+                       } else
                                user = (unsigned char*)EM_SAFE_STRDUP((char *)p);
                        p = s + 1;
                }
@@ -204,8 +202,7 @@ static int _get_addr_from_element(unsigned char* elm,int* type, unsigned char**
                        *s = '\0';
                        if (user || *(p - 3) == '/') {
                                if (strncmp((char *)p, "AUTH=", 5) == 0) auth = (unsigned char*)EM_SAFE_STRDUP((char *)p + 5);
-                       }
-                       else
+                       } else
                                user = (unsigned char*)EM_SAFE_STRDUP((char *)p);
                        p = s + 1;
                }
@@ -226,7 +223,7 @@ static int _get_addr_from_element(unsigned char* elm,int* type, unsigned char**
                        *(s - 1) = '\0';
 
                if (EM_SAFE_STRLEN((char *)p))
-                       mailbox =(unsigned char*) EM_SAFE_STRDUP((char *)p);
+                       mailbox = (unsigned char *)EM_SAFE_STRDUP((char *)p);
                break;
 
        case 'h': /*  not supported */
@@ -390,8 +387,7 @@ static int _get_emn_account(unsigned char *input_wbxml, int input_wbxml_length,
                EM_DEBUG_EXCEPTION("Parsing failed at %u - Token %x - %s", err_idx, wbxml[err_idx], wbxml_errors_string(ret));
                err = EMAIL_ERROR_XML_PARSER_FAILURE;
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                EM_DEBUG_LOG("Parsing OK !");
        }
 
@@ -421,9 +417,9 @@ static int _get_emn_account(unsigned char *input_wbxml, int input_wbxml_length,
        EM_DEBUG_LOG("host_addr = [%s]", (char *)host_addr ? (char*)host_addr : "NIL");
        EM_DEBUG_LOG_SEC("mbox_name = [%s]", (char *)mbox_name ? (char*)mbox_name : "NIL");
        EM_DEBUG_LOG("auth_type = [%s]", (char *)auth_type ? (char*)auth_type : "NIL");
-       EM_DEBUG_LOG("time_stamp= [%s]", (char *)time_stamp? (char*)time_stamp: "NIL");
+       EM_DEBUG_LOG("time_stamp= [%s]", (char *)time_stamp ? (char*)time_stamp : "NIL");
 
-       if(incoming_server_user_name && host_addr)
+       if (incoming_server_user_name && host_addr)
                SNPRINTF((char*)email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", incoming_server_user_name, host_addr);
 
        if (!emdaemon_get_account_list(NULL, &accounts, &count, &err)) {
@@ -436,7 +432,7 @@ static int _get_emn_account(unsigned char *input_wbxml, int input_wbxml_length,
                char* temp_account_name = NULL;
                char *s = NULL;
                /*      EM_DEBUG_LOG(">>>> Account Information UserName [ %s ] Email Addr [ %s], Account ID [ %d] >>> ",accounts[i].incoming_server_user_name,accounts[i].user_email_address, accounts[i].account_id); */
-               temp_account_name =(char*) EM_SAFE_STRDUP((char *)accounts[i].incoming_server_user_name);
+               temp_account_name = (char *)EM_SAFE_STRDUP((char *)accounts[i].incoming_server_user_name);
 
                if ((s = (char*)strchr((char *)temp_account_name, '@')))  {
                        *s = '\0';
@@ -528,8 +524,7 @@ static int emdaemon_handle_emn_notification(unsigned char* wbxml_b64, int input_
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d", err);
                        goto FINISH_OFF;
                }
-       }
-       else {
+       } else {
                if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account.account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl, false, &err))  {
                        EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d", err);
                        goto FINISH_OFF;
@@ -560,7 +555,7 @@ void oma_emn_push_cb(msg_handle_t input_handle, const char *input_push_header, c
        EM_DEBUG_LOG("input_push_body [%s]", input_push_body);
        EM_DEBUG_LOG("input_push_body_lenth [%d]", input_push_body_lenth);
 
-       if((err = emdaemon_handle_emn_notification((unsigned char*)input_push_body, input_push_body_lenth)) != EMAIL_ERROR_NONE) {
+       if ((err = emdaemon_handle_emn_notification((unsigned char*)input_push_body, input_push_body_lenth)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emdaemon_handle_emn_notification failed [%d]", err);
        }
 
@@ -577,7 +572,7 @@ static int emdaemon_register_wap_push_callback(msg_handle_t *input_msg_handle, c
        char *pkg_name = "org.tizen.email";
        bool bLaunch = false;
 
-       if(input_msg_handle == NULL || input_app_id == NULL) {
+       if (input_msg_handle == NULL || input_app_id == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -585,7 +580,7 @@ static int emdaemon_register_wap_push_callback(msg_handle_t *input_msg_handle, c
 
        msg_struct = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO);
 
-       if(msg_struct == NULL) {
+       if (msg_struct == NULL) {
                EM_DEBUG_EXCEPTION("msg_create_struct() failed [%d]", msg_err);
                err = EMAIL_ERROR_INPROPER_RESPONSE_FROM_MSG_SERVICE;
                goto FINISH_OFF;
@@ -606,7 +601,7 @@ static int emdaemon_register_wap_push_callback(msg_handle_t *input_msg_handle, c
 
  FINISH_OFF:
 
-       if(msg_struct)
+       if (msg_struct)
                msg_release_struct(&msg_struct);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
index 63a626d..2fd40f5 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -72,18 +72,18 @@ int emdaemon_unregister_event_callback(email_action_t action, email_event_callba
 INTERNAL_FUNC int emdaemon_cancel_job(int account_id, int handle, int* err_code)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%d], err_code[%p]", account_id, handle, err_code);
-       
+
        int ret = false;
        int err = EMAIL_ERROR_NONE;
-       
-       
+
+
        if (!emcore_cancel_thread(handle, NULL, &err))  {
                EM_DEBUG_EXCEPTION("emcore_cancel_thread failed [%d]", err);
                goto FINISH_OFF;
        }
-       
+
        ret = true;
-       
+
 FINISH_OFF:
        if (err_code != NULL)
                *err_code = err;
@@ -95,11 +95,11 @@ FINISH_OFF:
 INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id, int* err_code)
 {
        EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_id[%d], err_code[%p]", account_id, mail_id, err_code);
-       
+
        int ret = false;
-       int err = EMAIL_ERROR_NONE;     
+       int err = EMAIL_ERROR_NONE;
        int handle = 0;
-       
+
        if (account_id <= 0)  {
                EM_DEBUG_EXCEPTION("account_id[%d], mail_id[%d]", account_id, mail_id);
                err = EMAIL_ERROR_INVALID_PARAM;
@@ -111,10 +111,10 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id,
        /* Removed below code, as it is causing struck in composer */
 #if 0
        /*      h.gahlaut@samsung.com: Moved this code from email_cancel_sending_mail API to email-service engine
-               since this code has update DB operation which is failing in context of email application process 
+               since this code has update DB operation which is failing in context of email application process
                with an sqlite error -> sqlite3_step fail:8 */
-               
-       /*      which means #define SQLITE_READONLY   8 */  /* Attempt to write a readonly database */ 
+
+       /*      which means #define SQLITE_READONLY   8 */  /* Attempt to write a readonly database */
        emstorage_mail_tbl_t *mail_tbl_data = NULL;
 
        if (!emstorage_get_mail_by_id(mail_id, &mail_tbl_data, false, &err))  {
@@ -126,12 +126,11 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id,
                if (mail_tbl_data->save_status == EMAIL_MAIL_STATUS_SEND_CANCELED) {
                        EM_DEBUG_EXCEPTION(">>>> EMAIL_MAIL_STATUS_SEND_CANCELED Already set for Mail ID [ %d ]", mail_id);
                        goto FINISH_OFF;
-               }
-               else {                  
+               } else {
                        mail_tbl_data->save_status = EMAIL_MAIL_STATUS_SEND_CANCELED;
 
-                       if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, mail_tbl_data->account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_CANCELED, true, &err)) {
-                               EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]",err);
+                       if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, mail_tbl_data->account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_CANCELED, true, &err)) {
+                               EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value failed [%d]", err);
                                goto FINISH_OFF;
                        }
                }
@@ -141,12 +140,12 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id,
 #endif
 
        if ((err = emcore_delete_alram_data_by_reference_id(EMAIL_ALARM_CLASS_SCHEDULED_SENDING, mail_id)) != EMAIL_ERROR_NONE) {
-               EM_DEBUG_LOG("emcore_delete_alram_data_by_reference_id failed [%d]",err);
+               EM_DEBUG_LOG("emcore_delete_alram_data_by_reference_id failed [%d]", err);
        }
 
 #endif
 
-       if(!emcore_get_handle_by_mailId_from_transaction_info(mail_id , &handle)) {
+       if (!emcore_get_handle_by_mailId_from_transaction_info(mail_id , &handle)) {
                EM_DEBUG_EXCEPTION("emcore_get_handle_by_mailId_from_transaction_info failed for mail_id[%d]", mail_id);
                ret = true;
                goto FINISH_OFF;
@@ -155,41 +154,41 @@ INTERNAL_FUNC int emdaemon_cancel_sending_mail_job(int account_id, int mail_id,
        if (!emcore_cancel_send_mail_thread(handle, NULL, &err)) {
                EM_DEBUG_EXCEPTION("emcore_cancel_send_mail_thread failed [%d]", err);
        }
-       
-       if(!emcore_delete_transaction_info_by_mailId(mail_id))
+
+       if (!emcore_delete_transaction_info_by_mailId(mail_id))
                EM_DEBUG_EXCEPTION("emcore_delete_transaction_info_by_mailId failed for mail_id[%d]", mail_id);
-       
+
        ret = true;
-       
+
 FINISH_OFF:
-       if(err_code != NULL)
+       if (err_code != NULL)
                *err_code = err;
 #if 0
 #ifdef __FEATURE_PROGRESS_IN_OUTBOX__
-       if(!emstorage_free_mail(&mail_tbl_data, 1, &err))
-               EM_DEBUG_EXCEPTION("emcore_free_mail Failed [%d ]", err);       
+       if (!emstorage_free_mail(&mail_tbl_data, 1, &err))
+               EM_DEBUG_EXCEPTION("emcore_free_mail Failed [%d ]", err);
 #endif
 #endif
        EM_DEBUG_FUNC_END();
        return ret;
-}      
-
-INTERNAL_FUNC int emdaemon_search_mail_on_server(char *multi_user_name, 
-                                                                                               int input_account_id, 
-                                                                                               int input_mailbox_id, 
-                                                                                               email_search_filter_t *input_search_filter, 
-                                                                                               int input_search_filter_count, 
-                                                                                               unsigned int *output_handle, 
+}
+
+INTERNAL_FUNC int emdaemon_search_mail_on_server(char *multi_user_name,
+                                                                                               int input_account_id,
+                                                                                               int input_mailbox_id,
+                                                                                               email_search_filter_t *input_search_filter,
+                                                                                               int input_search_filter_count,
+                                                                                               unsigned int *output_handle,
                                                                                                int *err_code)
 {
-       EM_DEBUG_FUNC_BEGIN("input_account_id [%d], mailbox_id [%d], input_search_filter [%p], " 
-                                               "input_search_filter_count [%d], output_handle [%p]", 
-                                               input_account_id, input_mailbox_id, input_search_filter, 
+       EM_DEBUG_FUNC_BEGIN("input_account_id [%d], mailbox_id [%d], input_search_filter [%p], "
+                                               "input_search_filter_count [%d], output_handle [%p]",
+                                               input_account_id, input_mailbox_id, input_search_filter,
                                                input_search_filter_count, output_handle);
        int error = EMAIL_ERROR_NONE;
        int ret = false;
        email_event_t *event_data = NULL;
-       
+
        if (input_mailbox_id == 0 || input_account_id < 0) {
                EM_DEBUG_EXCEPTION("Invalid parameter");
                error = EMAIL_ERROR_INVALID_PARAM;
@@ -274,28 +273,28 @@ INTERNAL_FUNC int emdaemon_reschedule_sending_mail()
        filter_list[6].list_filter_item.operator_type                      = EMAIL_LIST_FILTER_OPERATOR_RIGHT_PARENTHESIS;
 
        /* Get scheduled mail list */
-       if(err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_rule_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
                goto FINISH_OFF;
        }
 
        EM_DEBUG_LOG("conditional_clause_string[%s].", conditional_clause_string);
 
-       if(!emstorage_query_mail_list(NULL, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
+       if (!emstorage_query_mail_list(NULL, conditional_clause_string, true, &result_mail_list, &result_mail_count, &err) && !result_mail_list) {
                EM_DEBUG_EXCEPTION("emstorage_query_mail_list [%d]", err);
                goto FINISH_OFF;
        }
 
        /* Add alarm for scheduled mail */
-       for(i = 0; i < result_mail_count; i++) {
-               if((err = emcore_schedule_sending_mail(multi_user_name, result_mail_list[i].mail_id, result_mail_list[i].scheduled_sending_time)) != EMAIL_ERROR_NONE) {
+       for (i = 0; i < result_mail_count; i++) {
+               if ((err = emcore_schedule_sending_mail(multi_user_name, result_mail_list[i].mail_id, result_mail_list[i].scheduled_sending_time)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_schedule_sending_mail failed [%d]", err);
                        goto FINISH_OFF;
                }
        }
 
 FINISH_OFF:
-       EM_SAFE_FREE (conditional_clause_string); /* detected by valgrind */
+       EM_SAFE_FREE(conditional_clause_string); /* detected by valgrind */
        EM_SAFE_FREE(result_mail_list);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
@@ -306,15 +305,14 @@ FINISH_OFF:
 INTERNAL_FUNC int emdaemon_clear_all_mail_data(char *multi_user_name, int* err_code)
 {
        EM_DEBUG_FUNC_BEGIN();
-       
+
        int ret = false;
        int error = EMAIL_ERROR_NONE;
-       
+
        if (emdaemon_initialize(multi_user_name, &error)) {
                if (!emstorage_clear_mail_data(multi_user_name, true, &error))
                        EM_DEBUG_EXCEPTION("emstorage_clear_mail_data failed [%d]", error);
-       }
-       else {
+       } else {
                EM_DEBUG_EXCEPTION("emdaemon_initialize failed [%d]", error);
                if (err_code)
                        *err_code = error;
@@ -325,11 +323,11 @@ INTERNAL_FUNC int emdaemon_clear_all_mail_data(char *multi_user_name, int* err_c
 
        ret = true;
 
-       if (!emstorage_create_table(multi_user_name, EMAIL_CREATE_DB_NORMAL, &error)) 
+       if (!emstorage_create_table(multi_user_name, EMAIL_CREATE_DB_NORMAL, &error))
                EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error);
-       
+
        emdaemon_finalize(&error);
-       
+
        if (err_code)
                *err_code = error;
        EM_DEBUG_FUNC_END();
@@ -363,7 +361,7 @@ INTERNAL_FUNC int emdaemon_check_smack_rule(int app_sockfd, char *file_path)
                }
        }
 
-       if(!have_smack) {
+       if (!have_smack) {
                EM_DEBUG_LOG("smack is disabled");
                result = true;
                goto FINISH_OFF;
@@ -377,7 +375,7 @@ INTERNAL_FUNC int emdaemon_check_smack_rule(int app_sockfd, char *file_path)
                result = false;
                goto FINISH_OFF;
        }
-       
+
        real_file_path = realpath(file_path, NULL);
        if (!real_file_path) {
                EM_DEBUG_LOG("realpath failed [%d][%s]", errno, EM_STRERROR(errno_buf));
@@ -470,7 +468,7 @@ INTERNAL_FUNC int emdaemon_finalize_sync(char *multi_user_name, int account_id,
                        emcore_set_blocking_mode_status(false);
 #endif /* __FEATURE_BLOCKING_MODE__ */
 
-               
+
                        if ((err = emcore_update_sync_status_of_account(multi_user_name, account_id, SET_TYPE_MINUS, SYNC_STATUS_HAVE_NEW_MAILS)) != EMAIL_ERROR_NONE)
                                EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
                }
index bfa2a3a..a828524 100755 (executable)
@@ -142,8 +142,7 @@ void pthreads_locking_callback(int mode, int type, char *file, int line)
        if (mode & CRYPTO_LOCK) {
                pthread_mutex_lock(&(lock_cs[type]));
                lock_count[type]++;
-       }
-       else {
+       } else {
                pthread_mutex_unlock(&(lock_cs[type]));
        }
 }
@@ -163,7 +162,7 @@ INTERNAL_FUNC void emdaemon_setup_handler_for_open_ssl_multithread(void)
 
        for (i = 0; i < CRYPTO_num_locks(); i++) {
                lock_count[i] = 0;
-               pthread_mutex_init(&(lock_cs[i]),NULL);
+               pthread_mutex_init(&(lock_cs[i]), NULL);
        }
 
        CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
@@ -177,10 +176,9 @@ INTERNAL_FUNC void emdaemon_cleanup_handler_for_open_ssl_multithread(void)
        int i = 0;
 
        CRYPTO_set_locking_callback(NULL);
-       for (i = 0; i < CRYPTO_num_locks(); i++)
-       {
+       for (i = 0; i < CRYPTO_num_locks(); i++) {
                pthread_mutex_destroy(&(lock_cs[i]));
-               EM_DEBUG_LOG("%8ld:%s",lock_count[i], CRYPTO_get_lock_name(i));
+               EM_DEBUG_LOG("%8ld:%s", lock_count[i], CRYPTO_get_lock_name(i));
        }
        OPENSSL_free(lock_cs);
        OPENSSL_free(lock_count);
@@ -333,8 +331,7 @@ static void* worker_event_queue(void *arg)
                        SLEEP_CONDITION_VARIABLE(_event_available_signal, *_event_queue_lock);
                        EM_DEBUG_LOG("Wake up by _event_available_signal");
                        LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
-               }
-               else {
+               } else {
                        LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
                        EM_DEBUG_LOG_DEV(">>>>>>>>>>>>>>> Got event_data !!! <<<<<<<<<<<<<<<");
 
@@ -446,7 +443,7 @@ static void* worker_event_queue(void *arg)
                                                break;
 
                                        case EMAIL_EVENT_DELETE_MAILBOX:
-                                               err = event_handler_EMAIL_EVENT_DELETE_MAILBOX(event_data->multi_user_name, event_data->event_param_data_4, event_data->event_param_data_5, event_data->event_param_data_6,handle_to_be_published);
+                                               err = event_handler_EMAIL_EVENT_DELETE_MAILBOX(event_data->multi_user_name, event_data->event_param_data_4, event_data->event_param_data_5, event_data->event_param_data_6, handle_to_be_published);
                                                break;
 
                                        case EMAIL_EVENT_SAVE_MAIL:
@@ -572,8 +569,7 @@ FINISH_OFF:
                        LEAVE_RECURSIVE_CRITICAL_SECTION(_event_queue_lock);
                        if (!started_event) {
                                EM_DEBUG_EXCEPTION("Failed to g_queue_pop_head");
-                       }
-                       else {
+                       } else {
                                /* freed event_data : event_data is started event */
                                emcore_return_handle(started_event->handle);
                                emcore_free_event(started_event); /*detected by valgrind*/
@@ -590,7 +586,7 @@ FINISH_OFF:
        return SUCCESS;
 }
 
-static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int input_account_id, int input_mailbox_id,
+static int event_handler_EMAIL_EVENT_SYNC_HEADER(char *multi_user_name, int input_account_id, int input_mailbox_id,
                                                                        int handle_to_be_published, int *error)
 {
        EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_id [%d], handle_to_be_published [%d], error[%p]",
@@ -638,10 +634,10 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
                        goto FINISH_OFF;
                }
        }
-       if(mailbox_tbl_target)
+       if (mailbox_tbl_target)
                SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl_target->mailbox_id);
 
-       input_mailbox_id_str = (input_mailbox_id == 0)? NULL: mailbox_id_param_string;
+       input_mailbox_id_str = (input_mailbox_id == 0) ? NULL : mailbox_id_param_string;
 
 /*     if (!emcore_notify_network_event(NOTI_DOWNLOAD_START, input_account_id, input_mailbox_id_str, handle_to_be_published, 0))
                EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_START] Failed >>>> ");
@@ -654,27 +650,26 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
        }
 
        if (sync_type != EMAIL_SYNC_ALL_MAILBOX) {      /* Sync only particular mailbox */
-               EM_DEBUG_LOG_SEC ("sync start: account_id [%d] alias [%s]", input_account_id, mailbox_tbl_target->alias);
+               EM_DEBUG_LOG_SEC("sync start: account_id [%d] alias [%s]", input_account_id, mailbox_tbl_target->alias);
                if ((err = emcore_update_sync_status_of_account(multi_user_name,
                                                                                                                input_account_id,
                                                                                                                SET_TYPE_UNION,
                                                                                                                SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
 
-               if (!emcore_sync_header (multi_user_name, mailbox_tbl_target, (void**) &stream,
+               if (!emcore_sync_header(multi_user_name, mailbox_tbl_target, (void **)&stream,
                                                                   &uid_list, &mail_count, &unread, &vip_mail_count,
                                                                   &vip_unread, 1, handle_to_be_published, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_sync_header failed [%d]", err);
                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_FAIL, mailbox_tbl_target->account_id, mailbox_id_param_string, handle_to_be_published, err))
                                EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed >>>> ");
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG("emcore_sync_header succeeded [%d]", err);
                        if (!emcore_notify_network_event(NOTI_DOWNLOAD_FINISH, mailbox_tbl_target->account_id, mailbox_id_param_string, handle_to_be_published, 0))
                                EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_FINISH] Failed >>>> ");
                }
 
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 
                total_unread     += unread;
                vip_total_unread += vip_unread;
@@ -702,9 +697,8 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
 
                if (mailbox_tbl_target->mailbox_type == EMAIL_MAILBOX_TYPE_INBOX)
                        emcore_display_unread_in_badge(multi_user_name);
-       }
-       else /*  All Folder */ {
-               EM_DEBUG_LOG ("sync start for all mailbox: account_id [%d]", input_account_id);
+       } else /*  All Folder */ {
+               EM_DEBUG_LOG("sync start for all mailbox: account_id [%d]", input_account_id);
                /*  Sync of all mailbox */
 
                if (input_account_id == ALL_ACCOUNT) {
@@ -716,8 +710,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
                                        EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_DOWNLOAD_FAIL] Failed >>>> ");
                                goto FINISH_OFF;
                        }
-               }
-               else {
+               } else {
                        if ((err = emcore_update_sync_status_of_account(multi_user_name, input_account_id, SET_TYPE_UNION, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
                                EM_DEBUG_EXCEPTION("emcore_update_sync_status_of_account failed [%d]", err);
 
@@ -732,22 +725,22 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
 
                for (account_index = 0 ; account_index < account_count; account_index++) {
                        if (account_tbl_array[account_index].incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
-                               EM_DEBUG_LOG ("account[%d] is for ActiveSync. Skip  ", account_index);
+                               EM_DEBUG_LOG("account[%d] is for ActiveSync. Skip  ", account_index);
                                continue;
                        }
 
                        if (account_tbl_array[account_index].sync_disabled == 1) {
-                               EM_DEBUG_LOG ("account[%d] is sync-disabled. Skip  ", account_index);
+                               EM_DEBUG_LOG("account[%d] is sync-disabled. Skip  ", account_index);
                                continue;
                        }
 /* folder sync is also necessary */
-                       if (!emstorage_get_mailbox_list (multi_user_name, account_tbl_array[account_index].account_id, 0,
+                       if (!emstorage_get_mailbox_list(multi_user_name, account_tbl_array[account_index].account_id, 0,
                                   EMAIL_MAILBOX_SORT_BY_TYPE_ASC, &mailbox_count, &mailbox_tbl_list, true, &err) ||
                                                                                                   mailbox_count <= 0) {
-                               EM_DEBUG_EXCEPTION ("emstorage_get_mailbox error [%d]", err);
-                               if (!emcore_notify_network_event (NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id,
+                               EM_DEBUG_EXCEPTION("emstorage_get_mailbox error [%d]", err);
+                               if (!emcore_notify_network_event(NOTI_DOWNLOAD_FAIL, account_tbl_array[account_index].account_id,
                                                                      input_mailbox_id_str, handle_to_be_published, err))
-                                       EM_DEBUG_EXCEPTION ("emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] error >>>> ");
+                                       EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] error >>>> ");
                                continue;
                        }
 
@@ -763,7 +756,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
                                                                                                                mailbox_tbl_list[0].mailbox_id,
                                                                                                                true,
                                                                                                                (void **)&stream,
-                                                                                                               &err))  {
+                                                                                                               &err)) {
                                        EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox error [%d]", err);
                                        if (err == EMAIL_ERROR_LOGIN_FAILURE)
                                                EM_DEBUG_EXCEPTION("EMAIL_ERROR_LOGIN_FAILURE ");
@@ -772,33 +765,31 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
                                                EM_DEBUG_EXCEPTION(" emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed >>>> ");
                                        continue;
                                }
-                               EM_DEBUG_LOG ("emcore_connect_to_remote_mailbox returns [%d]", err);
-                       }
-                       else
-                               stream = mail_close (stream);
+                               EM_DEBUG_LOG("emcore_connect_to_remote_mailbox returns [%d]", err);
+                       } else
+                               stream = mail_close(stream);
 #endif
 
                        for (counter = 0; counter < mailbox_count; counter++) {
 
                                EM_DEBUG_LOG_SEC("mailbox_name [%s], mailbox_id [%d], mailbox_type [%d]", mailbox_tbl_list[counter].mailbox_name, mailbox_tbl_list[counter].mailbox_id, mailbox_tbl_list[counter].mailbox_type);
                                vip_unread = unread = mail_count = 0;
-                               if ( mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_ALL_EMAILS
+                               if (mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_ALL_EMAILS
                                        || mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_TRASH
                                        /*|| mailbox_tbl_list[counter].mailbox_type == EMAIL_MAILBOX_TYPE_SPAMBOX */) {
                                        EM_DEBUG_LOG("Skipped for all emails or trash");
                                        continue;
-                               }
-                               else if (!mailbox_tbl_list[counter].local_yn) {
+                               } else if (!mailbox_tbl_list[counter].local_yn) {
                                        EM_DEBUG_LOG_SEC("[%s] Syncing...", mailbox_tbl_list[counter].mailbox_name);
 #ifdef __FEATURE_KEEP_CONNECTION__
-                                       if (!emcore_sync_header (multi_user_name,
+                                       if (!emcore_sync_header(multi_user_name,
                                       (mailbox_tbl_list + counter),
                                       (void **)&stream,
                                       &uid_list,
                                       &mail_count,
                                       &unread, &vip_mail_count, &vip_unread, 1, handle_to_be_published, &err))
 #else /*  __FEATURE_KEEP_CONNECTION__ */
-                                       if (!emcore_sync_header (multi_user_name,
+                                       if (!emcore_sync_header(multi_user_name,
                                       (mailbox_tbl_list + counter),
                                       (void **)&stream,
                                       &uid_list,
@@ -806,17 +797,17 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
                                       &unread, &vip_mail_count, &vip_unread, 1, handle_to_be_published, &err))
 #endif /*  __FEATURE_KEEP_CONNECTION__ */
                                        {
-                                               EM_DEBUG_EXCEPTION_SEC ("emcore_sync_header for %s(mailbox_id = %d) failed [%d]",
+                                               EM_DEBUG_EXCEPTION_SEC("emcore_sync_header for %s(mailbox_id = %d) failed [%d]",
                                                        mailbox_tbl_list[counter].mailbox_name, mailbox_tbl_list[counter].mailbox_id, err);
 
 #ifndef __FEATURE_KEEP_CONNECTION__
                                                if (err == EMAIL_ERROR_CONNECTION_BROKEN || err == EMAIL_ERROR_NO_SUCH_HOST ||
                                                                                  err == EMAIL_ERROR_SOCKET_FAILURE)
-                                                       stream = mail_close (stream);
+                                                       stream = mail_close(stream);
 #endif /*  __FEATURE_KEEP_CONNECTION__ */
                                                memset(mailbox_id_param_string, 0, 10);
                                                SNPRINTF(mailbox_id_param_string, 10, "%d", mailbox_tbl_list[counter].mailbox_id);
-                                               if (!emcore_notify_network_event (NOTI_DOWNLOAD_FAIL,
+                                               if (!emcore_notify_network_event(NOTI_DOWNLOAD_FAIL,
                                                                            account_tbl_array[account_index].account_id,
                                                                            mailbox_id_param_string,
                                                                            handle_to_be_published, err))
@@ -857,7 +848,7 @@ static int event_handler_EMAIL_EVENT_SYNC_HEADER (char *multi_user_name, int inp
 
 #ifndef __FEATURE_KEEP_CONNECTION__
                        if (stream)
-                               stream = mail_close (stream);
+                               stream = mail_close(stream);
 #endif
                        if (mailbox_tbl_list) {
                                emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
@@ -873,12 +864,12 @@ FINISH_OFF:
 
 #ifndef __FEATURE_KEEP_CONNECTION__
        if (stream)
-               stream = mail_close (stream);
+               stream = mail_close(stream);
 #endif
        if (error)
                *error = err;
 
-       if(mailbox_tbl_target)
+       if (mailbox_tbl_target)
                emstorage_free_mailbox(&mailbox_tbl_target, 1, NULL);
 
        if (mailbox_tbl_list)
@@ -897,7 +888,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(char *multi_use
        int err, ret = false;
        char *imap_cap_string = NULL;
 
-       if(!account) {
+       if (!account) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -911,8 +902,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(char *multi_use
                if (!emcore_notify_network_event(NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL, account->account_id, NULL,  handle_to_be_published, err))
                        EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_FAIL] Failed >>>> ");
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                EM_DEBUG_LOG_SEC("incoming_server_address : %s", account->incoming_server_address);
 
                if (!emcore_validate_account_with_account_info(multi_user_name, account, EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT, &imap_cap_string, handle_to_be_published, &err)) {
@@ -923,11 +913,9 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(char *multi_use
                                if (!emcore_notify_network_event(NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL, account->account_id, NULL,  handle_to_be_published, err))
                                        EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL] Failed");
                                goto FINISH_OFF;
-                       }
-                       else
+                       } else
                                goto FINISH_OFF;
-               }
-               else {
+               } else {
                        emcore_delete_account_from_unvalidated_account_list(account->account_id);
 
                        if (emcore_create_account(multi_user_name, account, false, &err) == false) {
@@ -938,7 +926,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_CREATE_ACCOUNT(char *multi_use
                        EM_DEBUG_LOG("incoming_server_type [%d]", account->incoming_server_type);
 
                        if ((EMAIL_SERVER_TYPE_IMAP4 == account->incoming_server_type)) {
-                               if (!emcore_sync_mailbox_list(multi_user_name, account->account_id, "", handle_to_be_published, &err))  {
+                               if (!emcore_sync_mailbox_list(multi_user_name, account->account_id, "", handle_to_be_published, &err)) {
                                        EM_DEBUG_EXCEPTION("emcore_get_mailbox_list_to_be_sync failed [%d]", err);
                                        /*  delete account whose mailbox couldn't be obtained from server */
                                        emcore_delete_account(multi_user_name, account->account_id, false, NULL);
@@ -975,7 +963,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(char *multi_user_name,
        int err = EMAIL_ERROR_NONE;
        char *server_capability_string = NULL;
 
-       if(!input_account) {
+       if (!input_account) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -989,8 +977,7 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(char *multi_user_name,
                if (!emcore_notify_network_event(NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL, input_account->account_id, NULL, input_handle_to_be_published, err))
                        EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_FAIL] Failed >>>> ");
                goto FINISH_OFF;
-       }
-       else {
+       } else {
                EM_DEBUG_LOG_SEC("incoming_server_address : %s", input_account->incoming_server_address);
 
                if (!emcore_validate_account_with_account_info(multi_user_name, input_account, EMAIL_EVENT_VALIDATE_ACCOUNT_EX, &server_capability_string, input_handle_to_be_published, &err)) {
@@ -1003,11 +990,9 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT_EX(char *multi_user_name,
                                if (!emcore_notify_network_event(NOTI_VALIDATE_ACCOUNT_CANCEL, input_account->account_id, NULL, input_handle_to_be_published, err))
                                        EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed");
                                goto FINISH_OFF;
-                       }
-                       else
+                       } else
                                goto FINISH_OFF;
-               }
-               else {
+               } else {
                        emcore_delete_account_from_unvalidated_account_list(input_account->account_id);
 
                        EM_DEBUG_LOG("validating an account are succeeded for account id  [%d]  err [%d]", input_account->account_id, err);
@@ -1042,29 +1027,28 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(char *multi_use
                goto FINISH_OFF;
        }
 
-       if (!emnetwork_check_network_status(&err))  {
+       if (!emnetwork_check_network_status(&err)) {
                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
 
                if (!emcore_notify_network_event(NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FAIL, account_id, NULL,  handle_to_be_published, err))
                        EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FAIL] Failed >>>> ");
                goto FINISH_OFF;
-       }
-       else  {
+       } else {
                EM_DEBUG_LOG_SEC("incoming_server_address: (%s)", new_account_info->incoming_server_address);
 
                /* If the password fields are empty, fill the fields with password of old information*/
-               if((old_account_info = emcore_get_account_reference(multi_user_name, account_id, true)) == NULL) {
+               if ((old_account_info = emcore_get_account_reference(multi_user_name, account_id, true)) == NULL) {
                        EM_DEBUG_EXCEPTION("emcore_get_account_reference failed ");
                        goto FINISH_OFF;
                }
 
                EM_DEBUG_LOG_SEC("old_account_info->incoming_server_password [%s]", old_account_info->incoming_server_password);
 
-               if( EM_SAFE_STRLEN (new_account_info->incoming_server_password) == 0 ) {
+               if (EM_SAFE_STRLEN(new_account_info->incoming_server_password) == 0) {
                        EM_SAFE_FREE(new_account_info->incoming_server_password); /* be allocated but has zero length */
                        EM_DEBUG_LOG_SEC("old_account_info->incoming_server_password [%s]", old_account_info->incoming_server_password);
                        new_account_info->incoming_server_password = EM_SAFE_STRDUP(old_account_info->incoming_server_password);
-                       if(new_account_info->incoming_server_password == NULL) {
+                       if (new_account_info->incoming_server_password == NULL) {
                                EM_DEBUG_EXCEPTION("allocation for new_account_info->password failed");
                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -1073,11 +1057,11 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(char *multi_use
 
                EM_DEBUG_LOG_SEC("old_account_info->outgoing_server_password [%s]", old_account_info->outgoing_server_password);
 
-               if( EM_SAFE_STRLEN (new_account_info->outgoing_server_password) == 0 ) {
+               if (EM_SAFE_STRLEN(new_account_info->outgoing_server_password) == 0) {
                        EM_SAFE_FREE(new_account_info->outgoing_server_password);
-                       if(old_account_info->outgoing_server_password) {
+                       if (old_account_info->outgoing_server_password) {
                                new_account_info->outgoing_server_password = EM_SAFE_STRDUP(old_account_info->outgoing_server_password);
-                               if(new_account_info->outgoing_server_password == NULL) {
+                               if (new_account_info->outgoing_server_password == NULL) {
                                        EM_DEBUG_EXCEPTION("allocation for new_account_info->outgoing_server_password failed");
                                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                                        goto FINISH_OFF;
@@ -1086,12 +1070,12 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(char *multi_use
                }
 
                emcore_duplicate_account(new_account_info, &duplicated_account_info, &err);
-               if (err != EMAIL_ERROR_NONE ) {
+               if (err != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_duplicate_account failed [%d]", err);
                        goto FINISH_OFF;
                }
 
-               if((err = emcore_add_account_to_unvalidated_account_list(duplicated_account_info)) != EMAIL_ERROR_NONE) {
+               if ((err = emcore_add_account_to_unvalidated_account_list(duplicated_account_info)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_add_account_to_unvalidated_account_list failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -1103,12 +1087,10 @@ static int event_handler_EMAIL_EVENT_VALIDATE_AND_UPDATE_ACCOUNT(char *multi_use
                                if (!emcore_notify_network_event(NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL, account_id, NULL,  handle_to_be_published, err))
                                        EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL] Failed");
                                goto FINISH_OFF;
-                       }
-                       else {
+                       } else {
                                goto FINISH_OFF;
                        }
-               }
-               else {
+               } else {
                        if (!emstorage_get_account_by_id(multi_user_name, account_id, WITHOUT_OPTION, &old_account_tbl, true, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
                                /* goto FINISH_OFF; */
@@ -1208,7 +1190,7 @@ FINISH_OFF:
 }
 
 #ifdef __FEATURE_LOCAL_ACTIVITY__
-static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int account_id, int event,handle, int *error)
+static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int account_id, int event_handle, int *error)
 {
        EM_DEBUG_FUNC_BEGIN();
 
@@ -1225,16 +1207,15 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int a
        else {
                if (false == emstorage_get_activity_id_list(multi_user_name, account_id, &activity_id_list, &activity_id_count, ACTIVITY_DELETEMAIL, ACTIVITY_COPYMAIL, true, &err)) {
                        EM_DEBUG_EXCEPTION("emstorage_get_activity_id_list failed [%d]", err);
-               }
-               else {
+               } else {
                        for (i = 0; i < activity_id_count; ++i) {
                                if ((false == emstorage_get_activity(account_id , activity_id_list[i], &local_activity, &activity_chunk_count, true,  &err)) || (NULL == local_activity) || (0 == activity_chunk_count))
                                        EM_DEBUG_EXCEPTION(" emstorage_get_activity Failed [ %d] or local_activity is NULL [%p] or activity_chunk_count is 0[%d]", err, local_activity, activity_chunk_count);
                                else {
                                        EM_DEBUG_LOG("Found local activity type - %d", local_activity[0].activity_type);
                                        switch (local_activity[0].activity_type) {
-                                               case ACTIVITY_MODIFYFLAG:  {
-                                                       if (emcore_sync_flag_with_server(multi_user_name, local_activity[0].mail_id , &err))  {
+                                               case ACTIVITY_MODIFYFLAG: {
+                                                       if (emcore_sync_flag_with_server(multi_user_name, local_activity[0].mail_id , &err)) {
                                                                if (!emcore_delete_activity(&local_activity[0], &err))
                                                                        EM_DEBUG_EXCEPTION(">>>>>>Local Activity [ACTIVITY_MODIFYFLAG] [%d] ", err);
                                                        }
@@ -1244,7 +1225,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int a
                                                case ACTIVITY_DELETEMAIL:
                                                case ACTIVITY_MOVEMAIL:
                                                case ACTIVITY_MODIFYSEENFLAG:
-                                               case ACTIVITY_COPYMAIL:  {
+                                               case ACTIVITY_COPYMAIL: {
 
                                                        int j = 0, k = 0;
                                                        int total_mail_ids = activity_chunk_count;
@@ -1269,7 +1250,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int a
                                                                        mail_id_list[j] = local_activity[k].mail_id;
 
                                                                switch (local_activity[k-1].activity_type) {
-                                                                       case ACTIVITY_DELETEMAIL:  {
+                                                                       case ACTIVITY_DELETEMAIL: {
                                                                                if (!emcore_delete_mail(multi_user_name,
                                                                                                                                local_activity[k-1].account_id,
                                                                                                                                mail_id_list,
@@ -1282,7 +1263,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int a
                                                                        }
                                                                        break;
 
-                                                                       case ACTIVITY_MOVEMAIL:  {
+                                                                       case ACTIVITY_MOVEMAIL: {
                                                                                if (!emcore_move_mail_on_server_ex(multi_user_name,
                                                                                                                                                        local_activity[k-1].account_id ,
                                                                                                                                                    local_activity[k-1].src_mbox,
@@ -1294,7 +1275,7 @@ static int event_handler_EMAIL_EVENT_LOCAL_ACTIVITY(char *multi_user_name, int a
                                                                        }
                                                                        break;
 
-                                                                       case ACTIVITY_MODIFYSEENFLAG:  {
+                                                                       case ACTIVITY_MODIFYSEENFLAG: {
                                                                                int seen_flag = atoi(local_activity[0].src_mbox);
                                                                                if (!emcore_sync_seen_flag_with_server_ex(multi_user_name, mail_id_list, j , seen_flag , &err)) /* local_activity[0].src_mbox points to the seen flag */
                                                                                        EM_DEBUG_EXCEPTION("\t emcore_sync_seen_flag_with_server_ex failed - %d", err);
@@ -1348,7 +1329,7 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(char *multi_user_name, int ac
        memset(&mailbox, 0x00, sizeof(mailbox));
        mailbox.account_id = account_id;
 
-       if (!emnetwork_check_network_status(&err))  {
+       if (!emnetwork_check_network_status(&err)) {
                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
 
                emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, handle_to_be_published, err);
@@ -1356,7 +1337,7 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(char *multi_user_name, int ac
                emstorage_mail_tbl_t *mail = NULL;
                MAILSTREAM *tmp_stream = NULL;
 
-               if (!emstorage_get_mail_by_id (multi_user_name, mail_id, &mail, true, &err) || !mail) {
+               if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail, true, &err) || !mail) {
                        EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
                        emcore_notify_network_event(NOTI_DOWNLOAD_BODY_FAIL, mail_id, NULL, handle_to_be_published, err);
                        goto FINISH_OFF;
@@ -1367,9 +1348,9 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(char *multi_user_name, int ac
                                                                                                mail->mailbox_id,
                                                                                                true,
                                                                                                (void **)&tmp_stream,
-                                                                                               &err) || !tmp_stream)  {
+                                                                                               &err) || !tmp_stream) {
                        EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
-                       if(err == EMAIL_ERROR_NO_SUCH_HOST)
+                       if (err == EMAIL_ERROR_NO_SUCH_HOST)
                                err = EMAIL_ERROR_CONNECTION_FAILURE;
 
                        if (mail)
@@ -1385,7 +1366,7 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_BODY(char *multi_user_name, int ac
                        EM_DEBUG_EXCEPTION("emcore_gmime_download_body_sections failed - %d", err);
 
                if (tmp_stream) {
-                       tmp_stream = mail_close (tmp_stream);
+                       tmp_stream = mail_close(tmp_stream);
                }
 
                if (mail)
@@ -1409,17 +1390,14 @@ static int event_handler_EMAIL_EVENT_DOWNLOAD_ATTACHMENT(char *multi_user_name,
 
        EM_DEBUG_LOG("attachment_no is %d", attachment_no);
 
-       if (!emnetwork_check_network_status(&err))  {
+       if (!emnetwork_check_network_status(&err)) {
                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
                emcore_notify_network_event(NOTI_DOWNLOAD_ATTACH_FAIL, mail_id, NULL, attachment_no, err);
-       }
-       else  {
-
+       } else {
 #ifdef __ATTACHMENT_OPTI__
                if (!emcore_download_attachment_bulk(account_id, mail_id, attachment_no, handle_to_be_published, &err))
                        EM_DEBUG_EXCEPTION("\t emcore_download_attachment_bulk failed [%d]", err);
 #else
-
                if (!emcore_gmime_download_attachment(multi_user_name, mail_id, attachment_no, 1, handle_to_be_published, 0, &err))
                        EM_DEBUG_EXCEPTION("emcore_gmime_download_attachment failed [%d]", err);
 #endif
@@ -1474,14 +1452,12 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(char *multi_user_name, int
 
        int err = EMAIL_ERROR_NONE;
 
-       if (!emnetwork_check_network_status(&err))  {
+       if (!emnetwork_check_network_status(&err)) {
                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
 
                if (!emcore_notify_network_event(NOTI_VALIDATE_ACCOUNT_FAIL, account_id, NULL,  handle_to_be_published, err))
                        EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_FAIL] Failed >>>>");
-       }
-       else  {
-
+       } else {
                if (!emcore_validate_account(multi_user_name, account_id, handle_to_be_published, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_validate_account failed account id  :  %d  err :  %d", account_id, err);
 
@@ -1489,25 +1465,22 @@ static int event_handler_EMAIL_EVENT_VALIDATE_ACCOUNT(char *multi_user_name, int
                                EM_DEBUG_EXCEPTION("notify  :  NOTI_VALIDATE_ACCOUNT_CANCEL ");
                                if (!emcore_notify_network_event(NOTI_VALIDATE_ACCOUNT_CANCEL, account_id, NULL,  handle_to_be_published, err))
                                        EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_CANCEL] Failed >>>> ");
-                       }
-                       else {
+                       } else {
                                if (!emcore_notify_network_event(NOTI_VALIDATE_ACCOUNT_FAIL, account_id, NULL,  handle_to_be_published, err))
                                        EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_VALIDATE_ACCOUNT_FAIL] Failed >>>> ");
                        }
-               }
-               else {
+               } else {
                        email_account_t *account_ref = NULL;
                        account_ref = emcore_get_account_reference(multi_user_name, account_id, false);
 
                        if (account_ref) {
                                EM_DEBUG_LOG("account_ref->incoming_server_type[%d]", account_ref->incoming_server_type);
-                               if ( EMAIL_SERVER_TYPE_IMAP4 == account_ref->incoming_server_type ) {
-                                       int dummy=0;
+                               if (EMAIL_SERVER_TYPE_IMAP4 == account_ref->incoming_server_type) {
+                                       int dummy = 0;
                                        if (!emcore_check_event_thread_status(&dummy, handle_to_be_published)) {
                                                EM_DEBUG_LOG("canceled type [%d]", dummy);
                                                err = EMAIL_ERROR_CANCELLED;
-                                       }
-                                       else if (!emcore_sync_mailbox_list(multi_user_name, account_id, "", handle_to_be_published, &err))
+                                       } else if (!emcore_sync_mailbox_list(multi_user_name, account_id, "", handle_to_be_published, &err))
                                                EM_DEBUG_EXCEPTION("\t emcore_get_mailbox_list_to_be_sync falied - %d", err);
                                }
 
@@ -1535,7 +1508,7 @@ static int event_handler_EMAIL_EVENT_UPDATE_MAIL(char *multi_user_name, email_ma
        EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count[%d], input_meeting_request[%p], input_from_eas[%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
        int err = EMAIL_ERROR_NONE;
 /*
-       if ( (err = emcore_update_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE)
+       if ((err = emcore_update_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE)
                EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
 */
        EM_DEBUG_FUNC_END("err [%d", err);
@@ -1735,12 +1708,11 @@ static int event_hanlder_EMAIL_EVENT_SYNC_HEADER_OMA(char *multi_user_name, int
        EM_DEBUG_FUNC_BEGIN();
        int err = EMAIL_ERROR_NONE;
 
-       if (!emnetwork_check_network_status(&err))  {
+       if (!emnetwork_check_network_status(&err)) {
                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);
                if (!emcore_notify_network_event(NOTI_DOWNLOAD_FAIL, account_id, maibox_name,  0, err))
                        EM_DEBUG_EXCEPTION("emcore_notify_network_event [NOTI_DOWNLOAD_FAIL] Failed");
-       }
-       else  {
+       } else {
                EM_DEBUG_LOG("Sync of all mailbox");
                if (!emcore_sync_mailbox_list(multi_user_name, account_id, "", handle_to_be_published, &err))
                        EM_DEBUG_EXCEPTION("emcore_sync_mailbox_list failed [%d]", err);
@@ -1925,16 +1897,14 @@ static void* worker_send_event_queue(void *arg)
 
                                        if (false == emstorage_get_activity_id_list(event_data->account_id, &activity_id_list, &activity_id_count, ACTIVITY_SAVEMAIL, ACTIVITY_DELETEMAIL_SEND, true, &err)) {
                                                EM_DEBUG_EXCEPTION("emstorage_get_activity_id_list failed [%d]", err);
-                                       }
-                                       else {
+                                       } else {
                                                for (i = 0; i < activity_id_count; ++i) {
                                                        if ((false == emstorage_get_activity(event_data->account_id, activity_id_list[i], &local_activity, &activity_chunk_count, true,  &err)) || (NULL == local_activity) || (0 == activity_chunk_count)) {
                                                                EM_DEBUG_EXCEPTION(" emstorage_get_activity Failed [ %d] or local_activity is NULL [%p] or activity_chunk_count is 0[%d]", err, local_activity, activity_chunk_count);
-                                                       }
-                                                       else {
+                                                       } else {
                                                                EM_DEBUG_LOG("Found local activity type - %d", local_activity[0].activity_type);
                                                                switch (local_activity[0].activity_type) {
-                                                                       case ACTIVITY_SAVEMAIL:  {
+                                                                       case ACTIVITY_SAVEMAIL: {
                                                                                if (!emcore_sync_mail_from_client_to_server(event_data->multi_user_name, event_data->account_id, local_activity[0].mail_id, &err)) {
                                                                                        EM_DEBUG_EXCEPTION("emcore_sync_mail_from_client_to_server failed - %d ", err);
                                                                                }
@@ -1949,13 +1919,13 @@ static void* worker_send_event_queue(void *arg)
                                                                                                                                true,
                                                                                                                                EMAIL_DELETED_BY_COMMAND,
                                                                                                                                false,
-                                                                                                                               &err))  {
+                                                                                                                               &err)) {
                                                                                        EM_DEBUG_LOG("\t emcore_delete_mail failed - %d", err);
                                                                                }
                                                                        }
                                                                        break;
 
-                                                                       default:  {
+                                                                       default: {
                                                                                EM_DEBUG_LOG(">>>> No such Local Activity Handled by this thread [ %d ] >>> ", local_activity[0].activity_type);
                                                                        }
                                                                        break;
@@ -2020,7 +1990,7 @@ INTERNAL_FUNC int emdaemon_start_thread_for_downloading_partial_body(int *err_co
                g_partial_body_thd_event_que[i].mailbox_id = 0;
        }
 
-       if (g_partial_body_thd)  {
+       if (g_partial_body_thd) {
                EM_DEBUG_EXCEPTION("partial body thread is already running...");
                if (err_code != NULL)
                        *err_code = EMAIL_ERROR_UNKNOWN;
@@ -2073,7 +2043,7 @@ static gpointer partial_body_download_thread(gpointer data)
 
        /* Open connection with DB */
 
-       if (false == emstorage_open(NULL, &err))  {
+       if (false == emstorage_open(NULL, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_open failed [%d]", err);
                return false;
        }
@@ -2118,8 +2088,7 @@ static gpointer partial_body_download_thread(gpointer data)
 
                                        if (false == emcore_partial_body_thd_local_activity_sync(partial_body_thd_event.multi_user_name, &is_local_activity_event_inserted, &err)) {
                                                EM_DEBUG_EXCEPTION("emcore_partial_body_thd_local_activity_sync failed [%d]", err);
-                                       }
-                                       else {
+                                       } else {
                                                if (true == is_local_activity_event_inserted) {
                                                        emcore_pb_thd_set_local_activity_continue(false);
 
@@ -2176,9 +2145,7 @@ static gpointer partial_body_download_thread(gpointer data)
 
                                emcore_set_pbd_thd_state(true);
                        }
-
-               }
-               else {
+               } else {
                        EM_DEBUG_LOG(" Event Received from Partial Body Event Queue ");
 
                        /* Since all events are network operations dnet init and sleep control is
@@ -2186,21 +2153,20 @@ static gpointer partial_body_download_thread(gpointer data)
 
                        emdevice_set_sleep_on_off(STAY_AWAKE_FLAG_FOR_PARTIAL_BODY_WORKER, false, NULL);
 
-                       if (!emnetwork_check_network_status( &err))  {
+                       if (!emnetwork_check_network_status(&err)) {
                                EM_DEBUG_EXCEPTION("emnetwork_check_network_status failed [%d]", err);;
-                       }
-                       else {
+                       } else {
                                /*  Process events  */
                                EM_DEBUG_LOG("partial_body_thd_event.account_id[%d]", partial_body_thd_event.account_id);
 
                                switch (partial_body_thd_event.event_type) {
-                                       case EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD:  {
+                                       case EMAIL_EVENT_BULK_PARTIAL_BODY_DOWNLOAD: {
                                                if (false == emcore_mail_partial_body_download(&partial_body_thd_event, &err)) {
                                                        EM_DEBUG_EXCEPTION("emcore_mail_partial_body_download from event_data queue failed [%d]", err);
                                                }
                                                break;
                                        }
-                                       case EMAIL_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD:  {
+                                       case EMAIL_EVENT_LOCAL_ACTIVITY_SYNC_BULK_PBD: {
                                                partial_body_thd_event.event_type = 0;
 
                                                /* Both the checks below make sure that before starting local activity there is no new/pending event_data in
index cea37c3..ae4dfda 100755 (executable)
@@ -119,7 +119,7 @@ static int _emdaemon_load_email_core()
 
 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
        if (emdaemon_start_thread_for_downloading_partial_body(&err) < 0) {
-               EM_DEBUG_EXCEPTION("emcore_start_thread_for_downloading_partial_body failed [%d]",err);
+               EM_DEBUG_EXCEPTION("emcore_start_thread_for_downloading_partial_body failed [%d]", err);
                goto FINISH_OFF;
        }
 #endif
@@ -180,32 +180,31 @@ static void callback_for_SYNC_ALL_STATUS_from_account_svc(keynode_t *input_node,
                goto FINISH_OFF;
        }
 
-       if(input_node)
+       if (input_node)
                sync_start_toggle = vconf_keynode_get_int(input_node);
 
-       for(i = 0; i < account_count; i++) {
-               if(sync_start_toggle == 1) {
-                       if(!emstorage_get_mailbox_by_mailbox_type(NULL, account_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl_data, true, &err)) {
+       for (i = 0; i < account_count; i++) {
+               if (sync_start_toggle == 1) {
+                       if (!emstorage_get_mailbox_by_mailbox_type(NULL, account_list[i].account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_tbl_data, true, &err)) {
                                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type for [%d] failed [%d]", account_list[i].account_id, err);
                                continue;
                        }
 
-                       if(!emdaemon_sync_header(NULL, account_list[i].account_id, mailbox_tbl_data->mailbox_id, &handle, &err)) {
+                       if (!emdaemon_sync_header(NULL, account_list[i].account_id, mailbox_tbl_data->mailbox_id, &handle, &err)) {
                                EM_DEBUG_EXCEPTION("emdaemon_sync_header for [%d] failed [%d]", account_list[i].account_id, err);
                        }
 
                        emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL); /* prevent 27459: remove unnecessary if clause */
                        mailbox_tbl_data = NULL;
-               }
-               else {
+               } else {
                        emcore_cancel_all_threads_of_an_account(NULL, account_list[i].account_id);
                }
        }
 
 FINISH_OFF:
-       if(account_list)
+       if (account_list)
                emdaemon_free_account(&account_list, account_count, NULL);
-       if(mailbox_tbl_data)
+       if (mailbox_tbl_data)
                emstorage_free_mailbox(&mailbox_tbl_data, 1, NULL);
 
        EM_DEBUG_FUNC_END();
@@ -226,31 +225,30 @@ static void callback_for_AUTO_SYNC_STATUS_from_account_svc(keynode_t *input_node
                goto FINISH_OFF;
        }
 
-       if(input_node)
+       if (input_node)
                auto_sync_toggle = vconf_keynode_get_int(input_node);
 
-       for(i = 0; i < account_count; i++) {
+       for (i = 0; i < account_count; i++) {
                account_info = account_list + i;
 
-               if(auto_sync_toggle == 1) { /* on */
+               if (auto_sync_toggle == 1) { /* on */
                        /* start sync */
-                       if(account_info->check_interval < 0)
+                       if (account_info->check_interval < 0)
                                account_info->check_interval = ~account_info->check_interval + 1;
-               }
-               else { /* off */
+               } else { /* off */
                        /* terminate sync */
-                       if(account_info->check_interval > 0)
+                       if (account_info->check_interval > 0)
                                account_info->check_interval = ~account_info->check_interval + 1;
                }
 
-               if(!emdaemon_update_account(NULL, account_info->account_id, account_info, &err)) {
+               if (!emdaemon_update_account(NULL, account_info->account_id, account_info, &err)) {
                        EM_DEBUG_EXCEPTION("emdaemon_update_account failed [%d]", err);
                        goto FINISH_OFF;
                }
        }
 
 FINISH_OFF:
-       if(account_list)
+       if (account_list)
                emdaemon_free_account(&account_list, account_count, NULL);
 
        EM_DEBUG_FUNC_END();
@@ -279,7 +277,7 @@ static void callback_for_NETWORK_STATUS(connection_type_e new_conn_type, void *i
        switch (new_conn_type) {
                case CONNECTION_TYPE_WIFI:
                case CONNECTION_TYPE_CELLULAR:
-                       if(conn_type != new_conn_type) {
+                       if (conn_type != new_conn_type) {
                                EM_DEBUG_LOG("Network type changed from [%d] to [%d]", conn_type, new_conn_type);
                                emnetwork_set_network_status(new_conn_type);
                        }
@@ -315,7 +313,7 @@ static void callback_for_NETWORK_STATUS(connection_type_e new_conn_type, void *i
        for (i = 0; i < account_count ; i++) {
                account_info = account_list + i;
                /* check if inbox folder sync is finished */
-               if (!emstorage_get_mailbox_by_mailbox_type (multi_user_name, account_info->account_id, EMAIL_MAILBOX_TYPE_INBOX, &local_mailbox, false, &err)) {
+               if (!emstorage_get_mailbox_by_mailbox_type(multi_user_name, account_info->account_id, EMAIL_MAILBOX_TYPE_INBOX, &local_mailbox, false, &err)) {
                        if (err == EMAIL_ERROR_MAILBOX_NOT_FOUND) {
                                int handle = 0;
                                emdaemon_get_imap_mailbox_list(multi_user_name, account_info->account_id, "", &handle, &err);
@@ -385,8 +383,8 @@ static void callback_for_VCONFKEY_MSG_SERVER_READY(keynode_t *input_node, void *
 
        msg_server_ready = vconf_keynode_get_bool(input_node);
 
-       if(msg_server_ready) {
-               if(emdaemon_initialize_emn() != EMAIL_ERROR_NONE) {
+       if (msg_server_ready) {
+               if (emdaemon_initialize_emn() != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emdaemon_initialize_emn failed");
                }
        }
@@ -534,7 +532,7 @@ INTERNAL_FUNC int emdaemon_initialize(char *multi_user_name, int* err_code)
                }
 
 #ifdef __FEATURE_OMA_EMN__
-        if(emdaemon_initialize_emn() != EMAIL_ERROR_NONE) {
+        if (emdaemon_initialize_emn() != EMAIL_ERROR_NONE) {
             vconf_notify_key_changed(VCONFKEY_MSG_SERVER_READY, callback_for_VCONFKEY_MSG_SERVER_READY, NULL);
         }
 #endif
@@ -551,12 +549,12 @@ INTERNAL_FUNC int emdaemon_initialize(char *multi_user_name, int* err_code)
                EM_DEBUG_EXCEPTION("emstorage_update_db_table_schema failed [%d]", err);
 
        if (!emstorage_clean_save_status(multi_user_name, EMAIL_MAIL_STATUS_SAVED, &err))
-               EM_DEBUG_EXCEPTION("emstorage_check_mail_status Failed [%d]", err );
+               EM_DEBUG_EXCEPTION("emstorage_check_mail_status Failed [%d]", err);
 
 #ifdef __FEATURE_AUTO_RETRY_SEND__
-       if ((err = emcore_create_alarm_for_auto_resend (multi_user_name, AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_create_alarm_for_auto_resend(multi_user_name, AUTO_RESEND_INTERVAL)) != EMAIL_ERROR_NONE) {
                if (err == EMAIL_ERROR_MAIL_NOT_FOUND)
-                       EM_DEBUG_LOG ("no mail found");
+                       EM_DEBUG_LOG("no mail found");
                else
                        EM_DEBUG_EXCEPTION("emcore_create_alarm_for_auto_resend failed [%d]", err);
        }
@@ -590,8 +588,7 @@ INTERNAL_FUNC int emdaemon_initialize(char *multi_user_name, int* err_code)
 
                if (connection_set_type_changed_cb(conn, callback_for_NETWORK_STATUS, NULL) != CONNECTION_ERROR_NONE)
                        EM_DEBUG_EXCEPTION("connection_set_type_changed_cb failed");
-       }
-       else {
+       } else {
                EM_DEBUG_EXCEPTION("connection_create failed[%d]", error_from_connection);
        }
 
@@ -628,7 +625,7 @@ INTERNAL_FUNC int emdaemon_finalize(int* err_code)
        int ret = false;
        int err = EMAIL_ERROR_NONE;
 
-       if ( (err = _emdaemon_unload_email_core()) != EMAIL_ERROR_NONE) {
+       if ((err = _emdaemon_unload_email_core()) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("_emdaemon_unload_email_core failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -662,7 +659,7 @@ INTERNAL_FUNC int emdaemon_start_auto_polling(char *multi_user_name, int* err_co
        EM_DEBUG_FUNC_BEGIN();
 
        /*  default variable */
-       int ret = false, count = 0, i= 0;
+       int ret = false, count = 0, i = 0;
        int err = EMAIL_ERROR_NONE;
        emstorage_account_tbl_t* account_list = NULL;
 
@@ -674,8 +671,8 @@ INTERNAL_FUNC int emdaemon_start_auto_polling(char *multi_user_name, int* err_co
 
        for (i = 0; i < count; i++)  {
                /* start auto polling, if check_interval not zero */
-               if(account_list[i].check_interval > 0 || ((account_list[i].peak_days > 0) && account_list[i].peak_interval > 0)) {
-                       if(!emdaemon_add_polling_alarm(multi_user_name, account_list[i].account_id))
+               if (account_list[i].check_interval > 0 || ((account_list[i].peak_days > 0) && account_list[i].peak_interval > 0)) {
+                       if (!emdaemon_add_polling_alarm(multi_user_name, account_list[i].account_id))
                                EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm failed");
                }
        }
@@ -766,7 +763,7 @@ INTERNAL_FUNC int emdaemon_init_alarm_data_list()
        alarm_data_list = NULL;
 
        if ((ret = alarmmgr_init(EMAIL_ALARM_DESTINATION)) != ALARMMGR_RESULT_SUCCESS) {
-               EM_DEBUG_EXCEPTION("alarmmgr_init failed [%d]",ret);
+               EM_DEBUG_EXCEPTION("alarmmgr_init failed [%d]", ret);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
        }
index 9087caa..e5b9e60 100755 (executable)
@@ -74,13 +74,13 @@ INTERNAL_FUNC int emdaemon_send_mail(char *multi_user_name, int mail_id, int *ha
        email_account_t* ref_account = NULL;
        int dst_mailbox_id = 0;
 
-       if(mail_id <= 0) {
+       if (mail_id <= 0) {
                EM_DEBUG_EXCEPTION("mail_id is not valid");
-               err= EMAIL_ERROR_INVALID_PARAM;
+               err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if(!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err)) {
+       if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &mail_table_data, true, &err)) {
                EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
                goto FINISH_OFF;
        }
@@ -90,7 +90,7 @@ INTERNAL_FUNC int emdaemon_send_mail(char *multi_user_name, int mail_id, int *ha
                        EM_DEBUG_EXCEPTION(" mail_table_data->mailbox_id[%d], mail_table_data->account_id[%d]", mail_table_data->mailbox_id, mail_table_data->account_id);
                if (err_code)
                        *err_code = EMAIL_ERROR_INVALID_MAILBOX;
-               if(mail_table_data)
+               if (mail_table_data)
                        emstorage_free_mail(&mail_table_data, 1, &err);
                return false;
        }
@@ -129,8 +129,8 @@ INTERNAL_FUNC int emdaemon_send_mail(char *multi_user_name, int mail_id, int *ha
                EM_DEBUG_EXCEPTION(" emcore_notify_network_event [ NOTI_SEND_START] Failed >>>> ");
 
        /* set EMAIL_MAIL_STATUS_SEND_WAIT status */
-       if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_WAIT, true, &err)) {
-               EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value [%d]",err);
+       if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SEND_WAIT, true, &err)) {
+               EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value [%d]", err);
                goto FINISH_OFF;
        }
 
@@ -157,7 +157,7 @@ INTERNAL_FUNC int emdaemon_send_mail(char *multi_user_name, int mail_id, int *ha
                        g_save_local_activity_run = 1;
 #endif
 
-       if ( handle )
+       if (handle)
                *handle = result_handle;
 
        ret = true;
@@ -166,8 +166,8 @@ FINISH_OFF:
        if (ret == false) {
                EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
 
-               if(!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SAVED, true, &err))
-                       EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value [%d]",err);
+               if (!emstorage_set_field_of_mails_with_integer_value(multi_user_name, account_id, &mail_id, 1, "save_status", EMAIL_MAIL_STATUS_SAVED, true, &err))
+                       EM_DEBUG_EXCEPTION("emstorage_set_field_of_mails_with_integer_value [%d]", err);
 
                if (event_data) {
                        emcore_free_event(event_data);
@@ -180,16 +180,16 @@ FINISH_OFF:
                EM_SAFE_FREE(ref_account);
        }
 
-       if(!emcore_add_transaction_info(mail_id , result_handle , &err_2))
+       if (!emcore_add_transaction_info(mail_id , result_handle , &err_2))
                EM_DEBUG_EXCEPTION("emcore_add_transaction_info failed [%d]", err_2);
 
-       if(local_mailbox)
+       if (local_mailbox)
                emstorage_free_mailbox(&local_mailbox, 1, NULL);
 
        if (err_code != NULL)
                *err_code = err;
 
-       if(mail_table_data)
+       if (mail_table_data)
                emstorage_free_mail(&mail_table_data, 1, &err);
 
        EM_DEBUG_FUNC_END();
@@ -219,7 +219,7 @@ INTERNAL_FUNC int emdaemon_send_mail_saved(char *multi_user_name, int account_id
                goto FINISH_OFF;
        }
 
-       if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, account_id,EMAIL_MAILBOX_TYPE_OUTBOX,&mailbox_name, false, &err)) {
+       if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mailbox_name, false, &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -280,7 +280,7 @@ INTERNAL_FUNC int emdaemon_add_mail(char *multi_user_name,
        email_account_t *ref_account = NULL;
 
        if (!input_mail_data || input_mail_data->account_id <= 0 ||
-               ( ((input_mail_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0) && !input_mail_data->full_address_to))  {
+               (((input_mail_data->report_status & EMAIL_MAIL_REPORT_MDN) != 0) && !input_mail_data->full_address_to))  {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -347,8 +347,8 @@ INTERNAL_FUNC int emdaemon_add_meeting_request(char *multi_user_name, int accoun
        int ret = false;
        int err = EMAIL_ERROR_NONE;
 
-       if ( account_id <= 0 || !meeting_req || meeting_req->mail_id <= 0 )  {
-               if(meeting_req)
+       if (account_id <= 0 || !meeting_req || meeting_req->mail_id <= 0)  {
+               if (meeting_req)
                        EM_DEBUG_EXCEPTION("mail_id[%d]", meeting_req->mail_id);
 
                err = EMAIL_ERROR_INVALID_PARAM;
@@ -671,7 +671,7 @@ INTERNAL_FUNC int emdaemon_delete_mail(char *multi_user_name,
        }
 
        if (from_server == EMAIL_DELETE_LOCAL_AND_SERVER || from_server == EMAIL_DELETE_FROM_SERVER) {
-               if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) {
+               if ((event_data = em_malloc(sizeof(email_event_t))) == NULL) {
                        EM_DEBUG_EXCEPTION("em_malloc for event_data failed...");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                        goto FINISH_OFF;
@@ -814,7 +814,7 @@ int emdaemon_delete_mail_all(char *multi_user_name, int input_mailbox_id, int in
                emstorage_activity_tbl_t new_activity;
                int activityid = 0;
 
-               if (false == emcore_get_next_activity_id(&activityid,&err)) {
+               if (false == emcore_get_next_activity_id(&activityid, &err)) {
                        EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d ", err);
                }
 
@@ -1009,7 +1009,7 @@ INTERNAL_FUNC int emdaemon_move_mail_all_mails(char *multi_user_name, int src_ma
                goto FINISH_OFF;
        }
 
-       if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) {
+       if ((event_data = em_malloc(sizeof(email_event_t))) == NULL) {
                EM_DEBUG_EXCEPTION("em_malloc for event_data failed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -1049,10 +1049,10 @@ FINISH_OFF:
 #ifdef __FEATURE_LOCAL_ACTIVITY__
        int i = 0, activityid = 0;
 
-       if (false == emcore_get_next_activity_id(&activityid,&err))
+       if (false == emcore_get_next_activity_id(&activityid, &err))
                EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d ", err);
 
-       for (i =0; i < event_data.event_param_data_4; i++) {
+       for (i = 0; i < event_data.event_param_data_4; i++) {
                emstorage_activity_tbl_t        new_activity;
                new_activity.activity_id = activityid;
                new_activity.activity_type = ACTIVITY_MOVEMAIL;
@@ -1128,7 +1128,7 @@ FINISH_OFF2:
        if (mail_list)
                EM_SAFE_FREE(mail_list);
 
-       if (mails != NULL )
+       if (mails != NULL)
                EM_SAFE_FREE(mails);
 
        EM_DEBUG_FUNC_END("ret [%d]", ret);
@@ -1184,7 +1184,7 @@ INTERNAL_FUNC int emdaemon_move_mail(char *multi_user_name, int mail_ids[], int
 
        emstorage_free_mail(&mail_table_data, 1, NULL);
 
-       if ((event_data = em_malloc(sizeof(email_event_t)) ) == NULL) {
+       if ((event_data = em_malloc(sizeof(email_event_t))) == NULL) {
                EM_DEBUG_EXCEPTION("em_malloc for event_data failed...");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -1226,10 +1226,10 @@ FINISH_OFF:
 #ifdef __FEATURE_LOCAL_ACTIVITY__
        int i = 0, activityid = 0;
 
-       if (false == emcore_get_next_activity_id(&activityid,&err))
+       if (false == emcore_get_next_activity_id(&activityid, &err))
                EM_DEBUG_EXCEPTION(" emcore_get_next_activity_id Failed - %d ", err);
 
-       for (i =0; i < event_data.event_param_data_4; i++) {
+       for (i = 0; i < event_data.event_param_data_4; i++) {
                emstorage_activity_tbl_t        new_activity;
                new_activity.activity_id = activityid;
                new_activity.activity_type = ACTIVITY_MOVEMAIL;
@@ -1316,7 +1316,7 @@ INTERNAL_FUNC int emdaemon_set_flags_field(char *multi_user_name, int account_id
        email_event_t *event_data = NULL;
        int handle = 0;
 
-       if(account_id <= 0 || !mail_ids || num <= 0) {
+       if (account_id <= 0 || !mail_ids || num <= 0) {
                err = EMAIL_ERROR_INVALID_PARAM;
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                goto FINISH_OFF;
@@ -1415,13 +1415,13 @@ INTERNAL_FUNC int emdaemon_update_mail(char *multi_user_name, email_mail_data_t
                goto FINISH_OFF;
        }
 
-       if ( (err = emcore_update_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_update_mail(multi_user_name, input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
                goto FINISH_OFF;
        }
 
 #ifdef __FEATURE_SYNC_CLIENT_TO_SERVER__
-/*     if ( input_from_eas == 0) {
+/*     if (input_from_eas == 0) {
                event_data = em_malloc(sizeof(email_event_t));
                if (event_data == NULL) {
                        EM_DEBUG_EXCEPTION("em_malloc failed");
@@ -1503,12 +1503,11 @@ INTERNAL_FUNC int emdaemon_send_mail_retry(char *multi_user_name, int mail_id, i
        }
 
        if (timeout_in_sec == 0) {
-               if(!emdaemon_send_mail(multi_user_name, mail_id, NULL, &err)) {
+               if (!emdaemon_send_mail(multi_user_name, mail_id, NULL, &err)) {
                        EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
                        goto FINISH_OFF;
                }
-       }
-       else if (timeout_in_sec > 0) {
+       } else if (timeout_in_sec > 0) {
                retry_info = em_malloc(sizeof(email_retry_info));
                if (retry_info == NULL) {
                        EM_DEBUG_EXCEPTION("em_malloc failed");
@@ -1553,7 +1552,7 @@ INTERNAL_FUNC void _OnMailSendRetryTimerCB(void* data)
                goto FINISH_OFF;
        }
 
-       if(!emdaemon_send_mail(retry_info->multi_user_name, retry_info->mail_id, NULL, &err)) {
+       if (!emdaemon_send_mail(retry_info->multi_user_name, retry_info->mail_id, NULL, &err)) {
                EM_DEBUG_EXCEPTION("emdaemon_send_mail failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -1597,7 +1596,7 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(char *multi_user_name, in
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < result_count; i++) {
+       for (i = 0; i < result_count; i++) {
                mail_id_list[i] = mail_list[i].mail_id;
        }
        account_id = mail_list[0].account_id;
@@ -1608,15 +1607,15 @@ INTERNAL_FUNC int emdaemon_move_mail_thread_to_mailbox(char *multi_user_name, in
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < mailbox_count; i++) {
+       for (i = 0; i < mailbox_count; i++) {
                EM_DEBUG_LOG_SEC("%s %d", target_mailbox_list[i].mailbox_name, target_mailbox_id);
-               if(target_mailbox_list[i].mailbox_id == target_mailbox_id) {
+               if (target_mailbox_list[i].mailbox_id == target_mailbox_id) {
                        target_mailbox = (target_mailbox_list + i);
                        break;
                }
        }
 
-       if(!target_mailbox) {
+       if (!target_mailbox) {
                EM_DEBUG_EXCEPTION("couldn't find proper target mailbox.");
                goto FINISH_OFF;
        }
@@ -1679,7 +1678,7 @@ INTERNAL_FUNC int emdaemon_delete_mail_thread(char *multi_user_name, int thread_
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < result_count; i++) {
+       for (i = 0; i < result_count; i++) {
                mail_id_list[i] = mail_list[i].mail_id;
        }
 
@@ -1736,7 +1735,7 @@ INTERNAL_FUNC int emdaemon_modify_seen_flag_of_thread(char *multi_user_name, int
                goto FINISH_OFF;
        }
 
-       for(i = 0; i < result_count; i++) {
+       for (i = 0; i < result_count; i++) {
                mail_id_list[i] = mail_list[i].mail_id;
        }
 
@@ -1811,8 +1810,7 @@ INTERNAL_FUNC int emdaemon_expunge_mails_deleted_flagged(char *multi_user_name,
                        goto FINISH_OFF;
                }
                event_insert = true;
-       }
-       else
+       } else
 #endif
        {
                if ((err = emcore_expunge_mails_deleted_flagged_from_local_storage(multi_user_name,
@@ -1833,7 +1831,7 @@ FINISH_OFF:
                EM_SAFE_FREE(ref_account);
        }
 
-       if(mailbox_tbl)
+       if (mailbox_tbl)
                emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
 
        EM_DEBUG_FUNC_END("err [%d]", err);
index 78cb5dc..8754e03 100755 (executable)
@@ -61,7 +61,7 @@ INTERNAL_FUNC int emdaemon_get_imap_mailbox_list(char *multi_user_name,
        int err = EMAIL_ERROR_NONE;
        email_event_t *event_data = NULL;
 
-       if (account_id <= 0 ||!mailbox)  {
+       if (account_id <= 0 || !mailbox)  {
                EM_DEBUG_EXCEPTION("account_id[%d], mailbox[%p]", account_id, mailbox);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -209,7 +209,7 @@ INTERNAL_FUNC int emdaemon_add_mailbox(char *multi_user_name, email_mailbox_t* n
        }
 
        /*  on_server is allowed to be only 0 when server_type is EMAIL_SERVER_TYPE_ACTIVE_SYNC */
-       if ( ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC )
+       if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC)
                on_server = 0;
 
        if (on_server) {        /* async */
@@ -231,9 +231,9 @@ INTERNAL_FUNC int emdaemon_add_mailbox(char *multi_user_name, email_mailbox_t* n
                mailbox->mailbox_name  = EM_SAFE_STRDUP(new_mailbox->mailbox_name);
                mailbox->alias         = EM_SAFE_STRDUP(new_mailbox->alias);
 
-               if(new_mailbox->eas_data_length > 0 && new_mailbox->eas_data) {
+               if (new_mailbox->eas_data_length > 0 && new_mailbox->eas_data) {
                        mailbox->eas_data = em_malloc(new_mailbox->eas_data_length);
-                       if(mailbox->eas_data == NULL) {
+                       if (mailbox->eas_data == NULL) {
                                EM_DEBUG_EXCEPTION("em_malloc failed");
                                err = EMAIL_ERROR_OUT_OF_MEMORY;
                                goto FINISH_OFF;
@@ -247,7 +247,7 @@ INTERNAL_FUNC int emdaemon_add_mailbox(char *multi_user_name, email_mailbox_t* n
                event_data->event_param_data_4 = on_server;
                event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
 
-               if(!emcore_insert_event(event_data, (int*)handle, &err)) {
+               if (!emcore_insert_event(event_data, (int*)handle, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -294,7 +294,7 @@ INTERNAL_FUNC int emdaemon_set_mailbox_type(char *multi_user_name, int input_mai
                goto FINISH_OFF;
        }
 
-       if ( (err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
+       if ((err = emstorage_get_mailbox_by_id(multi_user_name, input_mailbox_id, &mailbox_tbl)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_id failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -327,7 +327,7 @@ INTERNAL_FUNC int emdaemon_set_local_mailbox(char *multi_user_name, int input_ma
                goto FINISH_OFF;
        }
 
-       if ( (err = emstorage_set_local_mailbox(multi_user_name, input_mailbox_id, input_is_local_mailbox, true)) != EMAIL_ERROR_NONE)  {
+       if ((err = emstorage_set_local_mailbox(multi_user_name, input_mailbox_id, input_is_local_mailbox, true)) != EMAIL_ERROR_NONE)  {
                EM_DEBUG_EXCEPTION("emstorage_set_local_mailbox failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -370,12 +370,12 @@ INTERNAL_FUNC int emdaemon_delete_mailbox(char *multi_user_name, int input_mailb
        }
 
        /*  on_server is allowed to be only 0 when server_type is EMAIL_SERVER_TYPE_ACTIVE_SYNC */
-       if ( ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                on_server = 0;
                recursive = 0;
        }
 
-       if ( on_server ) {      /*  async */
+       if (on_server) {        /*  async */
                event_data = em_malloc(sizeof(email_event_t));
                if (event_data == NULL) {
                        EM_DEBUG_EXCEPTION("em_malloc failed");
@@ -390,7 +390,7 @@ INTERNAL_FUNC int emdaemon_delete_mailbox(char *multi_user_name, int input_mailb
                event_data->event_param_data_6 = recursive;
                event_data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
 
-               if(!emcore_insert_event(event_data, (int*)handle, &err)) {
+               if (!emcore_insert_event(event_data, (int*)handle, &err)) {
                        EM_DEBUG_EXCEPTION("emcore_insert_event failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -490,7 +490,7 @@ INTERNAL_FUNC int emdaemon_sync_header(char *multi_user_name, int input_account_
                goto FINISH_OFF;
        }
 
-       if(input_account_id == ALL_ACCOUNT) {
+       if (input_account_id == ALL_ACCOUNT) {
                EM_DEBUG_LOG(">>>> emdaemon_sync_header for all account event_data.event_param_data_4 [%d]", event_data->event_param_data_4);
                event_data->type               = EMAIL_EVENT_SYNC_HEADER;
                event_data->account_id         = input_account_id;
@@ -526,7 +526,7 @@ INTERNAL_FUNC int emdaemon_sync_header(char *multi_user_name, int input_account_
        /* Due to fast response, event noti is moved here from worker_event_queue */
        char input_mailbox_id_str[10] = {0};
        snprintf(input_mailbox_id_str, 10, "%d ", input_mailbox_id);
-       if (!emcore_notify_network_event(NOTI_DOWNLOAD_START, input_account_id, ((input_mailbox_id==0)? NULL:input_mailbox_id_str), *handle, 0))
+       if (!emcore_notify_network_event(NOTI_DOWNLOAD_START, input_account_id, ((input_mailbox_id == 0) ? NULL : input_mailbox_id_str), *handle, 0))
                EM_DEBUG_EXCEPTION("emcore_notify_network_event [ NOTI_DOWNLOAD_START] Failed >>>> ");
 
 /*     if ((err = emcore_update_sync_status_of_account(multi_user_name, input_account_id, SET_TYPE_SET, SYNC_STATUS_SYNCING)) != EMAIL_ERROR_NONE)
@@ -562,7 +562,7 @@ INTERNAL_FUNC int emdaemon_set_mail_slot_size_of_mailbox(char *multi_user_name,
        int err = EMAIL_ERROR_NONE;
        email_event_t *event_data = NULL;
 
-       if(handle == NULL) {
+       if (handle == NULL) {
                EM_DEBUG_EXCEPTION("handle is required");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -611,7 +611,7 @@ INTERNAL_FUNC int emdaemon_rename_mailbox(char *multi_user_name, int input_mailb
        emstorage_mailbox_tbl_t *old_mailbox_data = NULL;
        email_event_t *event_data = NULL;
 
-       if(input_mailbox_id <= 0 || output_handle == NULL) {
+       if (input_mailbox_id <= 0 || output_handle == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
index f3b07af..d1ccc3e 100755 (executable)
@@ -83,7 +83,7 @@ void stb_create_account(HIPC_API a_hAPI)
 
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
        EM_DEBUG_LOG("size [%d]", buffer_size);
-       if(buffer_size <= 0)    {
+       if (buffer_size <= 0)   {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -96,7 +96,7 @@ void stb_create_account(HIPC_API a_hAPI)
        EM_DEBUG_LOG_SEC("Email Address - %s", account.user_email_address);
     EM_DEBUG_LOG("Multi user name - %s", account.user_name);
 
-       if(!emdaemon_create_account(multi_user_name, &account, &err)) {
+       if (!emdaemon_create_account(multi_user_name, &account, &err)) {
                EM_DEBUG_EXCEPTION("emdaemon_create_account fail ");
                goto FINISH_OFF;
        }
@@ -104,33 +104,33 @@ void stb_create_account(HIPC_API a_hAPI)
 
 #ifdef __FEATURE_AUTO_POLLING__
        /* start auto polling, if check_interval not zero */
-       if(account.check_interval > 0 || (account.peak_days > 0 && account.peak_interval > 0)) {
-               if(!emdaemon_add_polling_alarm(multi_user_name, account.account_id))
+       if (account.check_interval > 0 || (account.peak_days > 0 && account.peak_interval > 0)) {
+               if (!emdaemon_add_polling_alarm(multi_user_name, account.account_id))
                        EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[NOTI_ACCOUNT_ADD] : start auto poll failed >>> ");
        }
 #ifdef __FEATURE_IMAP_IDLE__
-       else if(account.check_interval == 0 || (account.peak_days > 0 && account.peak_interval == 0))
+       else if (account.check_interval == 0 || (account.peak_days > 0 && account.peak_interval == 0))
                emcore_refresh_imap_idle_thread();
 #endif /* __FEATURE_IMAP_IDLE__ */
 
 #endif
 
        local_result = 1;
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        EM_DEBUG_LOG("[3] APPID[%d], APIID [%d]", emipc_get_app_id(a_hAPI), emipc_get_api_id(a_hAPI));
        EM_DEBUG_LOG("account id[%d]", account.account_id);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(account.account_id), sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(account.account_id), sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
 FINISH_OFF:
 
-       if ( local_result == 0 ) {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (local_result == 0) {
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed : local_result ");
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed : err");
        }
        if (!emipc_execute_stub_api(a_hAPI))
@@ -141,10 +141,10 @@ FINISH_OFF:
        //emcore_init_account_reference();
 
        if (local_result == 1) {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_ADD_FINISH, account.account_id, 0, NULL, 0))
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_ADD_FINISH, account.account_id, 0, NULL, 0))
                        EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_ADD] : Notification failed");
        } else {
-               if (!emcore_notify_storage_event (NOTI_ACCOUNT_ADD_FAIL, account.account_id, 0, NULL, 0))
+               if (!emcore_notify_storage_event(NOTI_ACCOUNT_ADD_FAIL, account.account_id, 0, NULL, 0))
                        EM_DEBUG_EXCEPTION("emcore_notify_storage_event[NOTI_ACCOUNT_ADD] : Notification failed");
        }
 
@@ -174,12 +174,12 @@ void stb_delete_account(HIPC_API a_hAPI)
                err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
        }
-       
-       if(!emdaemon_delete_account(multi_user_name, account_id, &err)) {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+
+       if (!emdaemon_delete_account(multi_user_name, account_id, &err)) {
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                        EM_DEBUG_LOG("emipc_add_parameter failed ");
 
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
                if (!emipc_execute_stub_api(a_hAPI))
@@ -189,22 +189,22 @@ void stb_delete_account(HIPC_API a_hAPI)
 
 #ifdef __FEATURE_AUTO_POLLING__
        /* stop auto polling for this acount */
-       if(emdaemon_check_auto_polling_started(account_id)) {
-               if(!emdaemon_remove_polling_alarm(account_id))
+       if (emdaemon_check_auto_polling_started(account_id)) {
+               if (!emdaemon_remove_polling_alarm(account_id))
                        EM_DEBUG_EXCEPTION("emdaemon_remove_polling_alarm[ NOTI_ACCOUNT_DELETE] : remove auto poll failed >>> ");
        }
 #endif
        local_result = 1;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
 
        /* if file is not deleted, main thread kills the thread */
-       emcore_send_signal_for_del_account (EMAIL_SIGNAL_DB_DELETED);
-       EM_DEBUG_LOG ("publish db of account deleted");
+       emcore_send_signal_for_del_account(EMAIL_SIGNAL_DB_DELETED);
+       EM_DEBUG_LOG("publish db of account deleted");
 
 FINISH_OFF:
 
@@ -250,14 +250,13 @@ void stb_update_account(HIPC_API a_hAPI)
                goto FINISH_OFF;
        }
 
-       if(with_validation) {
-               if(!emdaemon_validate_account_and_update(multi_user_name, account_id, &new_account_info, &handle, &err)){
+       if (with_validation) {
+               if (!emdaemon_validate_account_and_update(multi_user_name, account_id, &new_account_info, &handle, &err)) {
                        EM_DEBUG_EXCEPTION("emdaemon_validate_account_and_update failed [%d]", err);
                        goto FINISH_OFF;
                }
-       }
-       else {
-               if(!emdaemon_update_account(multi_user_name, account_id, &new_account_info, &err)) {
+       } else {
+               if (!emdaemon_update_account(multi_user_name, account_id, &new_account_info, &err)) {
                        EM_DEBUG_EXCEPTION("emdaemon_update_account failed [%d]", err);
                        goto FINISH_OFF;
                }
@@ -266,7 +265,7 @@ void stb_update_account(HIPC_API a_hAPI)
 
 FINISH_OFF:
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -298,13 +297,13 @@ void stb_validate_account(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
        local_result = emdaemon_validate_account(multi_user_name, account_id, &handle, &err_code);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                EM_DEBUG_LOG("emipc_add_parameter failed ");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
         EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -320,7 +319,7 @@ void stb_get_account_list(HIPC_API a_hAPI)
        EM_DEBUG_FUNC_BEGIN();
 
        int local_result = 0;
-       int i= 0;
+       int i = 0;
        char* local_stream = NULL;
        email_account_t* account_list;
        int count;
@@ -334,28 +333,28 @@ void stb_get_account_list(HIPC_API a_hAPI)
         multi_user_name = NULL;
     }
 
-       if(emdaemon_get_account_list(multi_user_name, &account_list, &count, &err)) {
+       if (emdaemon_get_account_list(multi_user_name, &account_list, &count, &err)) {
                EM_DEBUG_LOG("emdaemon_get_account_list success");
                local_result = 1;
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
 
                EM_DEBUG_LOG("Count [%d]", count);
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter count failed ");
 
-               for(i=0; i<count; i++) {
+               for (i = 0; i < count; i++) {
                        EM_DEBUG_LOG_SEC("Name - %s", account_list[i].account_name);
 
                        local_stream = em_convert_account_to_byte_stream(account_list+i, &size);
 
                        if (!local_stream) {
-                               EM_DEBUG_EXCEPTION ("INVALID PARAM: local_stream NULL ");
+                               EM_DEBUG_EXCEPTION("INVALID PARAM: local_stream NULL ");
                                emcore_free_account_list(&account_list, count, NULL);
                                return;
                        }
 
-                       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, local_stream, size))
+                       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, local_stream, size))
                                EM_DEBUG_EXCEPTION("Add  Param mailbox failed  ");
 
                        size = 0;
@@ -369,9 +368,9 @@ void stb_get_account_list(HIPC_API a_hAPI)
 
        else {
                EM_DEBUG_LOG("emdaemon_get_account_list failed");
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed : err");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -403,13 +402,13 @@ void stb_sync_header(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &maibox_id);
        EM_DEBUG_LOG("account_id [%d] maibox_id [%d]", account_id, maibox_id);
 
-       if(!emdaemon_sync_header(multi_user_name, account_id, maibox_id, &handle, &err)) {
-               EM_DEBUG_EXCEPTION ("emdaemon_sync_header failed [%d]", err);
+       if (!emdaemon_sync_header(multi_user_name, account_id, maibox_id, &handle, &err)) {
+               EM_DEBUG_EXCEPTION("emdaemon_sync_header failed [%d]", err);
        }
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -453,10 +452,10 @@ void stb_download_body(HIPC_API a_hAPI)
 
 FINISH_OFF:
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
            EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -489,7 +488,7 @@ void stb_create_mailbox(HIPC_API a_hAPI)
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
        EM_DEBUG_LOG("size [%d]", buffer_size);
 
-       if(buffer_size <= 0) {
+       if (buffer_size <= 0) {
                EM_DEBUG_EXCEPTION("buffer_size(%d) should be greater than 0", buffer_size);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -511,11 +510,11 @@ FINISH_OFF:
        emcore_free_mailbox(&mailbox);
     EM_SAFE_FREE(multi_user_name);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &mailbox.mailbox_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &mailbox.mailbox_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 3");
 
        if (!emipc_execute_stub_api(a_hAPI)) {
@@ -553,12 +552,12 @@ void stb_delete_mailbox(HIPC_API a_hAPI)
 
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &on_server);
 
-       if(emdaemon_delete_mailbox(multi_user_name, input_mailbox_id, on_server, &handle, &err))
+       if (emdaemon_delete_mailbox(multi_user_name, input_mailbox_id, on_server, &handle, &err))
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -588,10 +587,10 @@ void stb_set_mailbox_type(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mailbox_type);
        EM_DEBUG_LOG("mailbox_type[%d]", mailbox_type);
 
-       if(err = emdaemon_set_mailbox_type(multi_user_name, mailbox_id, mailbox_type)) != EMAIL_ERROR_NONE)
+       if ((err = emdaemon_set_mailbox_type(multi_user_name, mailbox_id, mailbox_type)) != EMAIL_ERROR_NONE)
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -621,10 +620,10 @@ void stb_set_local_mailbox(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &is_local_mailbox);
        EM_DEBUG_LOG("is_local_mailbox[%d]", is_local_mailbox);
 
-       if(err = emdaemon_set_local_mailbox(multi_user_name, mailbox_id, is_local_mailbox)) != EMAIL_ERROR_NONE)
+       if ((err = emdaemon_set_local_mailbox(multi_user_name, mailbox_id, is_local_mailbox)) != EMAIL_ERROR_NONE)
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -652,7 +651,7 @@ void stb_stamp_sync_time_of_mailbox(HIPC_API a_hAPI)
 
        err = emstorage_stamp_last_sync_time_of_mailbox(multi_user_name, mailbox_id, 1);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -687,12 +686,12 @@ void stb_set_mail_slot_size_of_mailbox(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &mail_slot_size);
        EM_DEBUG_LOG("mail_slot_size[%d]", mail_slot_size);
 
-       if(emdaemon_set_mail_slot_size_of_mailbox(multi_user_name, account_id, mailbox_id, mail_slot_size, &handle, &err))
+       if (emdaemon_set_mail_slot_size_of_mailbox(multi_user_name, account_id, mailbox_id, mail_slot_size, &handle, &err))
                err = EMAIL_ERROR_NONE;
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -725,7 +724,7 @@ void stb_rename_mailbox(HIPC_API a_hAPI)
 
        buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1);
        EM_DEBUG_LOG("mailbox_path string size[%d]", buffer_size);
-       if(buffer_size > 0)       {
+       if (buffer_size > 0)      {
                mailbox_path = (char*)em_malloc(buffer_size);
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, mailbox_path);
                EM_DEBUG_LOG_SEC("mailbox_path [%s]", mailbox_path);
@@ -733,7 +732,7 @@ void stb_rename_mailbox(HIPC_API a_hAPI)
 
        buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2);
        EM_DEBUG_LOG("mailbox_alias string size[%d]", buffer_size);
-       if(buffer_size > 0)       {
+       if (buffer_size > 0)      {
                mailbox_alias = (char*)em_malloc(buffer_size);
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, mailbox_alias);
                EM_DEBUG_LOG_SEC("mailbox_alias [%s]", mailbox_alias);
@@ -746,10 +745,10 @@ void stb_rename_mailbox(HIPC_API a_hAPI)
                EM_DEBUG_EXCEPTION("emdaemon_rename_mailbox failed [%d]", err);
        }
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -787,7 +786,7 @@ void stb_rename_mailbox_ex(HIPC_API a_hAPI)
 
        buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1);
        EM_DEBUG_LOG("mailbox_path string size[%d]", buffer_size);
-       if(buffer_size > 0)       {
+       if (buffer_size > 0)      {
                mailbox_path = (char*)em_malloc(buffer_size);
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, buffer_size, mailbox_path);
                EM_DEBUG_LOG_SEC("mailbox_path [%s]", mailbox_path);
@@ -795,7 +794,7 @@ void stb_rename_mailbox_ex(HIPC_API a_hAPI)
 
        buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2);
        EM_DEBUG_LOG("mailbox_alias string size[%d]", buffer_size);
-       if(buffer_size > 0)       {
+       if (buffer_size > 0)      {
                mailbox_alias = (char*)em_malloc(buffer_size);
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, mailbox_alias);
                EM_DEBUG_LOG_SEC("mailbox_alias [%s]", mailbox_alias);
@@ -803,7 +802,7 @@ void stb_rename_mailbox_ex(HIPC_API a_hAPI)
 
        eas_data_length = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 3);
        EM_DEBUG_LOG("eas_data_length  size[%d]", eas_data_length);
-       if(eas_data_length > 0)   {
+       if (eas_data_length > 0)          {
                eas_data = (char*)em_malloc(eas_data_length);
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 3, eas_data_length, eas_data);
        }
@@ -815,10 +814,10 @@ void stb_rename_mailbox_ex(HIPC_API a_hAPI)
                EM_DEBUG_EXCEPTION("emdaemon_rename_mailbox failed [%d]", err);
        }
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 1");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed 2");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -851,17 +850,16 @@ void stb_send_mail(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &mail_id);
        EM_DEBUG_LOG("mail_id [%d]", mail_id);
 
-       if(emdaemon_send_mail(multi_user_name, mail_id, &handle, &err)) {
+       if (emdaemon_send_mail(multi_user_name, mail_id, &handle, &err)) {
                err = EMAIL_ERROR_NONE;
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
-       }
-       else {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       } else {
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -892,16 +890,16 @@ void stb_query_smtp_mail_size_limit(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
        EM_DEBUG_LOG("account_id [%d]", account_id);
 
-       if(emdaemon_query_smtp_mail_size_limit(multi_user_name, account_id, &handle, &err)) {
+       if (emdaemon_query_smtp_mail_size_limit(multi_user_name, account_id, &handle, &err)) {
                err = EMAIL_ERROR_NONE;
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
        } else {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -932,29 +930,29 @@ void stb_get_mailbox_list(HIPC_API a_hAPI)
 
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
 
-       if(emdaemon_get_mailbox_list(multi_user_name, account_id, &mailbox_list, &count, &err))
+       if (emdaemon_get_mailbox_list(multi_user_name, account_id, &mailbox_list, &count, &err))
                EM_DEBUG_LOG("emdaemon_get_mailbox_list - success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
-       if(EMAIL_ERROR_NONE == err) {
+       if (EMAIL_ERROR_NONE == err) {
                EM_DEBUG_LOG("Count [%d]", count);
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
-               for(counter=0; counter<count; counter++) {
+               for (counter = 0; counter < count; counter++) {
                        EM_DEBUG_LOG_SEC("Name - %s", mailbox_list[counter].mailbox_name);
 
                        local_stream = em_convert_mailbox_to_byte_stream(mailbox_list+counter, &size);
 
                        if (!local_stream) {
-                               EM_DEBUG_EXCEPTION ("INVALID PARAM: local_stream NULL ");
+                               EM_DEBUG_EXCEPTION("INVALID PARAM: local_stream NULL ");
                                emcore_free_mailbox_list(&mailbox_list, count);
                                return;
                        }
 
-                       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, local_stream, size))
+                       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, local_stream, size))
                                EM_DEBUG_EXCEPTION("Add  Param mailbox failed  ");
 
                        EM_SAFE_FREE(local_stream);
@@ -993,7 +991,7 @@ void stb_delete_all_mails(HIPC_API a_hAPI)
 
        emdaemon_delete_mail_all(multi_user_name, mailbox_id, from_server, NULL, &err);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -1040,7 +1038,7 @@ void stb_delete_mail(HIPC_API a_hAPI)
 
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, num * sizeof(int), mail_ids);
 
-       for(counter = 0; counter < num; counter++)
+       for (counter = 0; counter < num; counter++)
                EM_DEBUG_LOG("mail_ids [%d]", mail_ids[counter]);
 
        /* from_server */
@@ -1053,18 +1051,18 @@ void stb_delete_mail(HIPC_API a_hAPI)
                goto FINISH_OFF;
        }
 
-       emdaemon_delete_mail(multi_user_name, 
-                                                       mailbox_tbl->account_id, 
-                                                       mailbox_id, 
-                                                       mail_ids, 
-                                                       num, 
-                                                       from_server, 
-                                                       NULL, 
+       emdaemon_delete_mail(multi_user_name,
+                                                       mailbox_tbl->account_id,
+                                                       mailbox_id,
+                                                       mail_ids,
+                                                       num,
+                                                       from_server,
+                                                       NULL,
                                                        &err);
 
 FINISH_OFF:
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -1079,7 +1077,7 @@ FINISH_OFF:
        EM_DEBUG_FUNC_END();
 }
 
-void stb_clear_mail_data (HIPC_API a_hAPI)
+void stb_clear_mail_data(HIPC_API a_hAPI)
 {
        EM_DEBUG_FUNC_BEGIN();
        int err = EMAIL_ERROR_NONE;
@@ -1092,12 +1090,12 @@ void stb_clear_mail_data (HIPC_API a_hAPI)
         multi_user_name = NULL;
     }
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed : err");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
 
-       if(emdaemon_clear_all_mail_data(multi_user_name, &err)) {
+       if (emdaemon_clear_all_mail_data(multi_user_name, &err)) {
                EM_DEBUG_LOG(">>> stb_clear_mail_data Success [ %d]  >> ", err);
        }
 
@@ -1121,13 +1119,13 @@ void stb_add_rule(HIPC_API a_hAPI)
     }
 
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
-       if(buffer_size <= 0) {
+       if (buffer_size <= 0) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
        local_rule_stream = (char*)     emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0);
-       if(!local_rule_stream) {
+       if (!local_rule_stream) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -1139,7 +1137,7 @@ void stb_add_rule(HIPC_API a_hAPI)
 
 FINISH_OFF:
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
        if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &rule.filter_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
@@ -1160,7 +1158,7 @@ void stb_get_rule(HIPC_API a_hAPI)
        int err = EMAIL_ERROR_NONE;
        int filter_id = 0;
        email_rule_t* rule = NULL;
-       int size =0;
+       int size = 0;
        char* local_rule_stream = NULL;
     int nAPPID = emipc_get_app_id(a_hAPI);
     char *multi_user_name = NULL;
@@ -1208,7 +1206,7 @@ FINISH_OFF:
                free(rule);
        }
 
-       EM_SAFE_FREE(local_rule_stream);        
+       EM_SAFE_FREE(local_rule_stream);
     EM_SAFE_FREE(multi_user_name);
 
        EM_DEBUG_FUNC_END();
@@ -1234,23 +1232,23 @@ void stb_get_rule_list(HIPC_API a_hAPI)
 
        emdaemon_get_filter_list(multi_user_name, &filtering_list, &count, &err);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        /* insert rules if there exist rules*/
-       if( count > 0 ) {
+       if (count > 0) {
                EM_DEBUG_LOG("num of rules [%d]", count);
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &count, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
-               for(i=0; i<count; i++) {
+               for (i = 0; i < count; i++) {
                        EM_DEBUG_LOG("Value - %s", filtering_list[i].value);
 
                        local_stream = em_convert_rule_to_byte_stream(filtering_list+i, &size);
 
-                       if(!local_stream) break;
+                       if (!local_stream) break;
 
-                       if(!emipc_add_dynamic_parameter(a_hAPI, ePARAMETER_OUT, local_stream, size))
+                       if (!emipc_add_dynamic_parameter(a_hAPI, ePARAMETER_OUT, local_stream, size))
                                EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed  ");
 
                        size = 0;
@@ -1282,7 +1280,7 @@ void stb_find_rule(HIPC_API a_hAPI)
     }
 
        buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
-       if(buffer_size > 0)      {
+       if (buffer_size > 0)     {
                local_rule_stream = (char*)em_malloc(buffer_size);
                if (local_rule_stream == NULL) {
                        EM_DEBUG_EXCEPTION("Out of memory");
@@ -1304,7 +1302,7 @@ void stb_find_rule(HIPC_API a_hAPI)
 
 FINISH_OFF:
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -1343,12 +1341,12 @@ void stb_update_rule(HIPC_API a_hAPI)
        /* get rule */
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 1);
        EM_DEBUG_LOG("size [%d]", buffer_size);
-       if(buffer_size <= 0)  {
+       if (buffer_size <= 0)  {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
        rule_stream     = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 1);
-       if(!rule_stream) {
+       if (!rule_stream) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -1358,7 +1356,7 @@ void stb_update_rule(HIPC_API a_hAPI)
        emdaemon_update_filter(multi_user_name, filter_id, &rule, &err);
 
 FINISH_OFF:
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -1401,10 +1399,10 @@ void stb_move_all_mails(HIPC_API a_hAPI)
        else
                EM_DEBUG_LOG("dst_mailbox_id == 0");
 
-       if(emdaemon_move_mail_all_mails(multi_user_name, src_mailbox_id, dst_mailbox_id, &err))
+       if (emdaemon_move_mail_all_mails(multi_user_name, src_mailbox_id, dst_mailbox_id, &err))
                EM_DEBUG_LOG("emdaemon_move_mail_all_mails:Success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
        }
 
@@ -1446,7 +1444,7 @@ void stb_set_flags_field(HIPC_API a_hAPI)
        /* mail_id */
        mail_ids = em_malloc(sizeof(int) * num);
 
-       if(!mail_ids) {
+       if (!mail_ids) {
                EM_DEBUG_EXCEPTION("em_malloc failed ");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -1454,7 +1452,7 @@ void stb_set_flags_field(HIPC_API a_hAPI)
 
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, num * sizeof(int), mail_ids);
 
-       for(counter=0; counter < num; counter++)
+       for (counter = 0; counter < num; counter++)
                EM_DEBUG_LOG("mailids [%d]", mail_ids[counter]);
 
        /* field type */
@@ -1469,12 +1467,12 @@ void stb_set_flags_field(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 5, sizeof(int), &onserver);
        EM_DEBUG_LOG("onserver [%d]", onserver);
 
-       if(emdaemon_set_flags_field(multi_user_name, account_id, mail_ids, num, field_type, value, onserver, &err))
+       if (emdaemon_set_flags_field(multi_user_name, account_id, mail_ids, num, field_type, value, onserver, &err))
                EM_DEBUG_LOG("emdaemon_set_flags_field - success");
 
 FINISH_OFF:
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -1517,7 +1515,7 @@ void stb_add_mail(HIPC_API a_hAPI)
        EM_DEBUG_LOG("email_mail_data_t buffer_size[%d]", buffer_size);
 
        /* mail_data */
-       if(buffer_size > 0)      {
+       if (buffer_size > 0)     {
                char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
                em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data);
        }
@@ -1577,7 +1575,7 @@ void stb_add_mail(HIPC_API a_hAPI)
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
        EM_DEBUG_LOG("email_attachment_data_t buffer_size[%d]", buffer_size);
 
-       if(buffer_size > 0)      {
+       if (buffer_size > 0)     {
                char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index);
                em_convert_byte_stream_to_attachment_data(stream, buffer_size, &result_attachment_data, &result_attachment_data_count);
 
@@ -1585,7 +1583,7 @@ void stb_add_mail(HIPC_API a_hAPI)
                if (!result_attachment_data_count) {
                        EM_DEBUG_LOG("Not include attachment data");
                } else {
-                       if(!result_attachment_data) {
+                       if (!result_attachment_data) {
                                EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_attachment_data failed");
                                err = EMAIL_ERROR_ON_PARSING;
                                goto FINISH_OFF;
@@ -1610,12 +1608,12 @@ void stb_add_mail(HIPC_API a_hAPI)
 
        /* meeting request */
        EM_DEBUG_LOG("email_meeting_request_t");
-       if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
+       if (result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
                || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
                || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
                buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
 
-               if(buffer_size > 0) {
+               if (buffer_size > 0) {
                        char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
                        em_convert_byte_stream_to_meeting_req(stream, buffer_size, &result_meeting_request);
                }
@@ -1624,24 +1622,24 @@ void stb_add_mail(HIPC_API a_hAPI)
        EM_DEBUG_LOG("sync_server");
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, param_index++, sizeof(int), &sync_server);
 
-       if(err = emdaemon_add_mail(multi_user_name, &result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
+       if ((err = emdaemon_add_mail(multi_user_name, &result_mail_data, result_attachment_data, result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emdaemon_add_mail failed [%d]", err);
                goto FINISH_OFF;
        }
 
        local_result = 1;
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
 
 FINISH_OFF:
-       if ( local_result == 0 ) {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (local_result == 0) {
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
@@ -1651,7 +1649,7 @@ FINISH_OFF:
 
        emcore_free_mail_data(&result_mail_data);
 
-       if(result_attachment_data)
+       if (result_attachment_data)
                emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL);
 
        emstorage_free_meeting_request(&result_meeting_request);
@@ -1689,7 +1687,7 @@ void stb_update_mail(HIPC_API a_hAPI)
        EM_DEBUG_LOG("email_mail_data_t");
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
 
-       if(buffer_size > 0)      {
+       if (buffer_size > 0)     {
                char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
                em_convert_byte_stream_to_mail_data(stream, buffer_size, &result_mail_data);
        }
@@ -1740,7 +1738,7 @@ void stb_update_mail(HIPC_API a_hAPI)
        }
        /* check smack rule - END */
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
-       if(buffer_size > 0)      {
+       if (buffer_size > 0)     {
                char *stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index);
                em_convert_byte_stream_to_attachment_data(stream, buffer_size, &result_attachment_data, &result_attachment_data_count);
 
@@ -1748,7 +1746,7 @@ void stb_update_mail(HIPC_API a_hAPI)
                if (!result_attachment_data_count) {
                        EM_DEBUG_LOG("Not include attachment data");
                } else {
-                       if(!result_attachment_data) {
+                       if (!result_attachment_data) {
                                EM_DEBUG_EXCEPTION("em_convert_byte_stream_to_attachment_data failed");
                                err = EMAIL_ERROR_ON_PARSING;
                                goto FINISH_OFF;
@@ -1772,12 +1770,12 @@ void stb_update_mail(HIPC_API a_hAPI)
        }
 
        EM_DEBUG_LOG("email_meeting_request_t");
-       if ( result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
+       if (result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_REQUEST
                || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_RESPONSE
                || result_mail_data.meeting_request_status == EMAIL_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
                buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
 
-               if(buffer_size > 0) {
+               if (buffer_size > 0) {
                        char* stream = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
                        em_convert_byte_stream_to_meeting_req(stream, buffer_size, &result_meeting_request);
                }
@@ -1787,7 +1785,7 @@ void stb_update_mail(HIPC_API a_hAPI)
 
        temp_buffer = emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
 
-       if(!temp_buffer) {
+       if (!temp_buffer) {
                EM_DEBUG_EXCEPTION("emipc_get_nth_parameter_data[%d] failed", param_index - 1);
                err = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                goto FINISH_OFF;
@@ -1795,25 +1793,25 @@ void stb_update_mail(HIPC_API a_hAPI)
 
        sync_server = *temp_buffer;
 
-       if(err = emdaemon_update_mail(multi_user_name, &result_mail_data, result_attachment_data,
+       if ((err = emdaemon_update_mail(multi_user_name, &result_mail_data, result_attachment_data,
                        result_attachment_data_count, &result_meeting_request, sync_server)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emdaemon_update_mail failed [%d]", err);
                goto FINISH_OFF;
        }
 
        local_result = 1;
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.mail_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result_mail_data.thread_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
 
 FINISH_OFF:
-       if ( local_result == 0 ) {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (local_result == 0) {
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
@@ -1823,7 +1821,7 @@ FINISH_OFF:
 
        EM_SAFE_FREE(prefix_path);
 
-       if(result_attachment_data)
+       if (result_attachment_data)
                emcore_free_attachment_data(&result_attachment_data, result_attachment_data_count, NULL);
 
        emstorage_free_meeting_request(&result_meeting_request);
@@ -1856,10 +1854,10 @@ void stb_move_thread_to_mailbox(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &move_always_flag);
        EM_DEBUG_LOG("move_always_flag [%d]", move_always_flag);
 
-       if(emdaemon_move_mail_thread_to_mailbox(multi_user_name, thread_id, mailbox_id, move_always_flag, &err))
+       if (emdaemon_move_mail_thread_to_mailbox(multi_user_name, thread_id, mailbox_id, move_always_flag, &err))
                EM_DEBUG_LOG("emdaemon_move_mail_thread_to_mailbox success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
                EM_SAFE_FREE(target_mailbox_name);
                EM_SAFE_FREE(multi_user_name);
@@ -1899,10 +1897,10 @@ void stb_delete_thread(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &delete_always_flag);
        EM_DEBUG_LOG("delete_always_flag [%d]", delete_always_flag);
 
-       if(emdaemon_delete_mail_thread(multi_user_name, thread_id, delete_always_flag, &handle, &err))
+       if (emdaemon_delete_mail_thread(multi_user_name, thread_id, delete_always_flag, &handle, &err))
                EM_DEBUG_LOG("emdaemon_delete_mail_thread success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
                EM_SAFE_FREE(multi_user_name);
                return;
@@ -1942,10 +1940,10 @@ void stb_modify_seen_flag_of_thread(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &on_server);
        EM_DEBUG_LOG("on_server [%d]", on_server);
 
-       if(emdaemon_modify_seen_flag_of_thread(multi_user_name, thread_id, seen_flag, on_server, &handle, &err))
+       if (emdaemon_modify_seen_flag_of_thread(multi_user_name, thread_id, seen_flag, on_server, &handle, &err))
                EM_DEBUG_LOG("emdaemon_modify_seen_flag_of_thread success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
                EM_SAFE_FREE(multi_user_name);
                return;
@@ -1982,9 +1980,9 @@ void stb_expunge_mails_deleted_flagged(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), (void*)&on_server);
        EM_DEBUG_LOG("on_server [%d]", on_server);
 
-       if ((err = emdaemon_expunge_mails_deleted_flagged(multi_user_name, 
-                                                                                                               mailbox_id, 
-                                                                                                               on_server, 
+       if ((err = emdaemon_expunge_mails_deleted_flagged(multi_user_name,
+                                                                                                               mailbox_id,
+                                                                                                               on_server,
                                                                                                                &handle)) != EMAIL_ERROR_NONE)
                EM_DEBUG_LOG("emdaemon_expunge_mails_deleted_flagged success");
 
@@ -2024,7 +2022,7 @@ void stb_move_mail(HIPC_API a_hAPI)
        int mail_ids[num];
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, num * sizeof(int), mail_ids);
 
-       for(counter = 0; counter < num; counter++)
+       for (counter = 0; counter < num; counter++)
                EM_DEBUG_LOG("mailids [%d]", mail_ids[counter]);
 
        /* target_mailbox_id */
@@ -2036,10 +2034,10 @@ void stb_move_mail(HIPC_API a_hAPI)
        else
                EM_DEBUG_LOG("mailbox_id == 0");
 
-       if(emdaemon_move_mail(multi_user_name, mail_ids, num, mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, &err))
+       if (emdaemon_move_mail(multi_user_name, mail_ids, num, mailbox_id, EMAIL_MOVED_BY_COMMAND, 0, &err))
                EM_DEBUG_LOG("emdaemon_move_mail success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter fail");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2066,10 +2064,10 @@ void stb_delete_rule(HIPC_API a_hAPI)
        /* filter_id */
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id);
 
-       if(emdaemon_delete_filter(multi_user_name, filter_id, &err))
+       if (emdaemon_delete_filter(multi_user_name, filter_id, &err))
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2096,10 +2094,10 @@ void stb_apply_rule(HIPC_API a_hAPI)
        /* filter_id */
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &filter_id);
 
-       if(emdaemon_apply_filter(multi_user_name, filter_id, &err))
+       if (emdaemon_apply_filter(multi_user_name, filter_id, &err))
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2136,7 +2134,7 @@ void stb_add_attachment(HIPC_API a_hAPI)
        /* attachment */
        buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 1);
 
-       if(buffer_size > 0)      {
+       if (buffer_size > 0)     {
                attachment_stream = (char*)em_malloc(buffer_size);
                if (attachment_stream == NULL) {
                        EM_DEBUG_EXCEPTION("em_malloc failed");
@@ -2184,12 +2182,12 @@ void stb_add_attachment(HIPC_API a_hAPI)
 
 FINISH_OFF:
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
-       if(EMAIL_ERROR_NONE == err) {
+       if (EMAIL_ERROR_NONE == err) {
                EM_DEBUG_LOG("emdaemon_add_attachment -Success");
 
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(attachment->attachment_id), sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &(attachment->attachment_id), sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter attachment_id failed ");
        }
                if (!emipc_execute_stub_api(a_hAPI))
@@ -2223,21 +2221,21 @@ void stb_get_attachment(HIPC_API a_hAPI)
 
        emdaemon_get_attachment(multi_user_name, attachment_id, &attachment, &err);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
 
-       if(EMAIL_ERROR_NONE == err) {
+       if (EMAIL_ERROR_NONE == err) {
                EM_DEBUG_LOG("emdaemon_get_attachment - Success");
                /* attachment */
                attachment_stream = em_convert_attachment_data_to_byte_stream(attachment, 1, &size);
-               if(!attachment_stream) { /*prevent 26263*/
+               if (!attachment_stream) { /*prevent 26263*/
                        emcore_free_attachment_data(&attachment, 1, &err);
                        EM_SAFE_FREE(multi_user_name);
                        return;
                }
                EM_NULL_CHECK_FOR_VOID(attachment_stream);
 
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, attachment_stream, size))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, attachment_stream, size))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed  ");
        }
 
@@ -2270,12 +2268,12 @@ void stb_get_imap_mailbox_list(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
 
        /* need to check: why err value is changed? */
-       if(emdaemon_get_imap_mailbox_list(multi_user_name, account_id, "", &handle, &err))
+       if (emdaemon_get_imap_mailbox_list(multi_user_name, account_id, "", &handle, &err))
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_LOG("ipcAPI_AddParameter local_result failed ");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_LOG("ipcAPI_AddParameter local_result failed ");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_LOG("emipc_execute_stub_api failed  ");
@@ -2302,7 +2300,7 @@ void stb_delete_attachment(HIPC_API a_hAPI)
 
        emdaemon_delete_mail_attachment(multi_user_name, attachment_id, &err);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -2337,23 +2335,22 @@ void stb_download_attachment(HIPC_API a_hAPI)
        EM_DEBUG_LOG("nth");
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &nth);
 
-       if(emdaemon_download_attachment(multi_user_name, account_id, mail_id, nth, &handle, &err)) {
+       if (emdaemon_download_attachment(multi_user_name, account_id, mail_id, nth, &handle, &err)) {
                err = EMAIL_ERROR_NONE;
 
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
                EM_DEBUG_LOG(">>>>>>>>>> HANDLE = %d", handle);
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter handle failed ");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
-       }
-       else {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       } else {
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
                /* Download handle - 17-Apr-09 */
                EM_DEBUG_LOG(">>>>>>>>>> HANDLE = %d", handle);
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter handle failed ");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -2380,10 +2377,10 @@ void stb_mail_send_saved(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
 
        EM_DEBUG_LOG("calling emdaemon_send_mail_saved");
-       if(emdaemon_send_mail_saved(multi_user_name, account_id, NULL, &err))
+       if (emdaemon_send_mail_saved(multi_user_name, account_id, NULL, &err))
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2393,7 +2390,8 @@ void stb_mail_send_saved(HIPC_API a_hAPI)
        EM_DEBUG_FUNC_END();
 }
 
-void stb_add_read_receipt(HIPC_API a_hAPI){
+void stb_add_read_receipt(HIPC_API a_hAPI)
+{
        EM_DEBUG_FUNC_BEGIN();
        int read_mail_id = 0;
        int receipt_mail_id = 0;
@@ -2410,14 +2408,14 @@ void stb_add_read_receipt(HIPC_API a_hAPI){
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &read_mail_id);
        EM_DEBUG_LOG("read_mail_id [%d]", read_mail_id);
 
-       if( (err = emcore_add_read_receipt(multi_user_name, read_mail_id, &receipt_mail_id)) != EMAIL_ERROR_NONE )
+       if ((err = emcore_add_read_receipt(multi_user_name, read_mail_id, &receipt_mail_id)) != EMAIL_ERROR_NONE)
                EM_DEBUG_EXCEPTION("emcore_add_read_receipt failed [%d]", err);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (err == EMAIL_ERROR_NONE) {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &receipt_mail_id, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &receipt_mail_id, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
        }
 
@@ -2451,10 +2449,10 @@ void stb_retry_sending_mail(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &timeout_in_sec);
        EM_DEBUG_LOG("timeout_in_sec [%d]", timeout_in_sec);
 
-       if(emdaemon_send_mail_retry(multi_user_name, mail_id, timeout_in_sec,&err))
+       if (emdaemon_send_mail_retry(multi_user_name, mail_id, timeout_in_sec, &err))
                EM_DEBUG_LOG("emdaemon_get_mailbox_list - success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
     if (!emipc_execute_stub_api(a_hAPI))
@@ -2482,10 +2480,10 @@ void stb_cancel_job(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &handle);
        EM_DEBUG_LOG("account_id [%d] handle [%d]", account_id, handle);
 
-       if(emdaemon_cancel_job(account_id, handle, &err))
+       if (emdaemon_cancel_job(account_id, handle, &err))
                err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter local_result failed ");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
@@ -2516,10 +2514,10 @@ void stb_cancel_send_mail_job(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &mail_id);
        EM_DEBUG_LOG("mail_id [%d]", mail_id);
 
-       if(emdaemon_cancel_sending_mail_job(account_id,mail_id,&err))
+       if (emdaemon_cancel_sending_mail_job(account_id, mail_id, &err))
                EM_DEBUG_LOG("success");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2559,7 +2557,7 @@ void stb_search_mail_on_server(HIPC_API a_hAPI)
        /* search_filter_list */
        buffer_size = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 2);
 
-       if(buffer_size > 0)      {
+       if (buffer_size > 0)     {
                stream_for_search_filter_list = (char*)em_malloc(buffer_size);
                if (stream_for_search_filter_list == NULL) {
                        EM_DEBUG_EXCEPTION("out of memory");
@@ -2568,16 +2566,16 @@ void stb_search_mail_on_server(HIPC_API a_hAPI)
                }
 
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, buffer_size, stream_for_search_filter_list);
-               em_convert_byte_stream_to_search_filter(stream_for_search_filter_list, 
-                                                                                               &search_filter_list, 
+               em_convert_byte_stream_to_search_filter(stream_for_search_filter_list,
+                                                                                               &search_filter_list,
                                                                                                &search_filter_count);
                EM_SAFE_FREE(stream_for_search_filter_list);
        }
 
-       if (!emdaemon_search_mail_on_server(multi_user_name, account_id ,mailbox_id, 
-                                                                               search_filter_list, 
-                                                                               search_filter_count, 
-                                                                               &job_handle, 
+       if (!emdaemon_search_mail_on_server(multi_user_name, account_id, mailbox_id,
+                                                                               search_filter_list,
+                                                                               search_filter_count,
+                                                                               &job_handle,
                                                                                &err))
                EM_DEBUG_LOG("success");
 
@@ -2619,12 +2617,12 @@ void stb_clear_result_of_search_mail_on_server(HIPC_API a_hAPI)
 
        EM_DEBUG_LOG("account_id [%d]", account_id);
 
-       if (!emstorage_get_mailbox_by_name(multi_user_name, 
-                                                                               account_id, 
-                                                                               -1, 
-                                                                               EMAIL_SEARCH_RESULT_MAILBOX_NAME, 
-                                                                               &mailbox_tbl, 
-                                                                               false, 
+       if (!emstorage_get_mailbox_by_name(multi_user_name,
+                                                                               account_id,
+                                                                               -1,
+                                                                               EMAIL_SEARCH_RESULT_MAILBOX_NAME,
+                                                                               &mailbox_tbl,
+                                                                               false,
                                                                                &err)) {
                EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err);
                goto FINISH_OFF;
@@ -2646,12 +2644,12 @@ void stb_clear_result_of_search_mail_on_server(HIPC_API a_hAPI)
        }
 
        /* Remove the searched mails */
-       if (!emdaemon_delete_mail(multi_user_name, 
-                                                               account_id, 
+       if (!emdaemon_delete_mail(multi_user_name,
+                                                               account_id,
                                                                0,
-                                                               mail_id_list, 
-                                                               mail_id_count, 
-                                                               EMAIL_DELETE_LOCALLY, 
+                                                               mail_id_list,
+                                                               mail_id_count,
+                                                               EMAIL_DELETE_LOCALLY,
                                                                &handle,
                                                                &err)) {
                EM_DEBUG_EXCEPTION("emdaemon_delete_mail failed : [%d]", err);
@@ -2669,7 +2667,7 @@ FINISH_OFF:
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
 
-       if (mailbox_tbl) 
+       if (mailbox_tbl)
                emstorage_free_mailbox(&mailbox_tbl, 1, NULL);
 
        EM_SAFE_FREE(mail_id_list);
@@ -2703,13 +2701,13 @@ void stb_add_account_with_validation(HIPC_API a_hAPI)
        /* get account info */
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
        EM_DEBUG_LOG("size [%d]", buffer_size);
-       if(buffer_size <= 0) {
+       if (buffer_size <= 0) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       stream =(char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0);
-       if(!stream) {
+       stream = (char *)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0);
+       if (!stream) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
@@ -2745,7 +2743,7 @@ void stb_add_account_with_validation(HIPC_API a_hAPI)
 #ifdef __FEATURE_AUTO_POLLING__
        /*  start auto polling, if check_interval not zero */
        if (ref_check_interval > 0 || (ref_account->peak_days > 0 && ref_account->peak_interval > 0)) {
-               if(!emdaemon_add_polling_alarm(multi_user_name, ref_account_id))
+               if (!emdaemon_add_polling_alarm(multi_user_name, ref_account_id))
                        EM_DEBUG_EXCEPTION("emdaemon_add_polling_alarm[NOTI_ACCOUNT_ADD] : start auto poll failed >>> ");
        }
 #ifdef __FEATURE_IMAP_IDLE__
@@ -2765,10 +2763,10 @@ void stb_add_account_with_validation(HIPC_API a_hAPI)
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
 
 FINISH_OFF:
-       if ( local_result == 0 ) { /* there is an error */
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (local_result == 0) { /* there is an error */
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed : local_result ");
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed : err");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -2798,7 +2796,7 @@ void stb_backup_account(HIPC_API a_hAPI)
 
        /* file_path_length */
        file_path_length = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
-       if(file_path_length > 0) {
+       if (file_path_length > 0) {
                EM_DEBUG_LOG("file_path_length [%d]", file_path_length);
                file_path = em_malloc(file_path_length);
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, file_path_length, file_path);
@@ -2806,10 +2804,10 @@ void stb_backup_account(HIPC_API a_hAPI)
                local_result = emcore_backup_accounts(multi_user_name, (const char*)file_path, &err_code);
        }
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                EM_DEBUG_LOG("emipc_add_parameter failed ");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2837,7 +2835,7 @@ void stb_restore_account(HIPC_API a_hAPI)
 
        /* file_path_length */
        file_path_length = emipc_get_parameter_length(a_hAPI, ePARAMETER_IN, 0);
-       if(file_path_length > 0)  {
+       if (file_path_length > 0)  {
                EM_DEBUG_LOG("file_path_length [%d]", file_path_length);
                file_path = em_malloc(file_path_length);
                emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, file_path_length, file_path);
@@ -2847,12 +2845,12 @@ void stb_restore_account(HIPC_API a_hAPI)
        /* file_path could be NULL */
        err_code = emcore_restore_accounts(multi_user_name, (const char*)file_path);
 
-       result = (err_code == EMAIL_ERROR_NONE)?1:0;
+       result = (err_code == EMAIL_ERROR_NONE) ? 1 : 0;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &result, sizeof(int)))
                EM_DEBUG_LOG("emipc_add_parameter failed ");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2885,17 +2883,17 @@ void stb_get_password_length(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 1, sizeof(int), &password_type);
 
-       local_result = emstorage_get_password_length_of_account(multi_user_name, account_id, password_type, &password_length,&err_code);
+       local_result = emstorage_get_password_length_of_account(multi_user_name, account_id, password_type, &password_length, &err_code);
 
        EM_DEBUG_LOG("password_length [%d]", password_length);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                EM_DEBUG_LOG("emipc_add_parameter failed ");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err_code, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &password_length, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &password_length, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter result failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -2930,7 +2928,7 @@ void stb_get_task_information(HIPC_API a_hAPI)
        if (task_information_count) {
                task_information_stream = em_convert_task_information_to_byte_stream(task_information, task_information_count, &stream_length);
 
-               if((stream_length > 0) && !emipc_add_dynamic_parameter(a_hAPI, ePARAMETER_OUT, task_information_stream, stream_length)) {
+               if ((stream_length > 0) && !emipc_add_dynamic_parameter(a_hAPI, ePARAMETER_OUT, task_information_stream, stream_length)) {
                        EM_DEBUG_EXCEPTION("emipc_add_dynamic_parameter failed");
                        err = EMAIL_ERROR_OUT_OF_MEMORY;
                }
@@ -2939,7 +2937,7 @@ void stb_get_task_information(HIPC_API a_hAPI)
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed");
 
-       if(task_information) {
+       if (task_information) {
                EM_SAFE_FREE(task_information);
        }
 
@@ -3036,7 +3034,7 @@ void stb_ping_service(HIPC_API a_hAPI)
        EM_DEBUG_FUNC_BEGIN();
        int err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3075,11 +3073,11 @@ void stb_update_notification_bar_for_unread_mail(HIPC_API a_hAPI)
 
        emcore_display_unread_in_badge(multi_user_name);
 
-       if(!emdaemon_finalize_sync(multi_user_name, account_id, total_mail_count, unread_mail_count, 0, 0, input_from_eas, &err)) {
+       if (!emdaemon_finalize_sync(multi_user_name, account_id, total_mail_count, unread_mail_count, 0, 0, input_from_eas, &err)) {
                EM_DEBUG_EXCEPTION("emdaemon_finalize_sync failed [%d]", err);
        }
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3105,10 +3103,10 @@ void stb_clear_notification_bar(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 0, sizeof(int), &account_id);
        EM_DEBUG_LOG("account_id [%d]", account_id);
 
-       if((err = emcore_clear_notifications(multi_user_name, account_id)) != EMAIL_ERROR_NONE) 
+       if ((err = emcore_clear_notifications(multi_user_name, account_id)) != EMAIL_ERROR_NONE)
                EM_DEBUG_EXCEPTION("emdaemon_finalize_sync failed [%d]", err);
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3145,11 +3143,11 @@ void stb_show_user_message(HIPC_API a_hAPI)
        emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), &param_error);
        EM_DEBUG_LOG("param_error [%d]", param_error);
 
-       if(!emcore_show_user_message(multi_user_name, param_id, param_action, param_error)) {
+       if (!emcore_show_user_message(multi_user_name, param_id, param_action, param_error)) {
                EM_DEBUG_EXCEPTION("emcore_show_user_message failed");
        }
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3164,7 +3162,7 @@ void stb_write_mime_file(HIPC_API a_hAPI)
        EM_DEBUG_FUNC_BEGIN();
        int err = EMAIL_ERROR_NONE;
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3195,20 +3193,20 @@ void stb_validate_account_ex(HIPC_API a_hAPI)
        /* get account info */
        buffer_size = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, 0);
        EM_DEBUG_LOG("size [%d]", buffer_size);
-       if(buffer_size <= 0) {
+       if (buffer_size <= 0) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       stream =(char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0);
-       if(!stream) {
+       stream = (char *)emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, 0);
+       if (!stream) {
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
        account = em_malloc(sizeof(email_account_t));
 
-       if(account == NULL) {
+       if (account == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
@@ -3217,7 +3215,7 @@ void stb_validate_account_ex(HIPC_API a_hAPI)
        em_convert_byte_stream_to_account(stream, buffer_size, account);
     account->user_name = EM_SAFE_STRDUP(multi_user_name);
 
-       if((err = emcore_add_account_to_unvalidated_account_list(account)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_add_account_to_unvalidated_account_list(account)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_add_account_to_unvalidated_account_list failed [%d]", err);
                goto FINISH_OFF;
        }
@@ -3230,24 +3228,24 @@ void stb_validate_account_ex(HIPC_API a_hAPI)
        }
 
        /* ref_account will be removed by worker_event_queue() */
-       if((err = emdaemon_validate_account_ex(multi_user_name, ref_account, &handle)) != EMAIL_ERROR_NONE) {
+       if ((err = emdaemon_validate_account_ex(multi_user_name, ref_account, &handle)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emdaemon_validate_account_ex fail [%d]", err);
                goto FINISH_OFF;
        }
 
        local_result = 1;
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &handle, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
        if (!emipc_execute_stub_api(a_hAPI))
                EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
 
 FINISH_OFF:
-       if ( local_result == 0 ) { /* there is an error */
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
+       if (local_result == 0) { /* there is an error */
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &local_result, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed : local_result ");
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed : err");
                if (!emipc_execute_stub_api(a_hAPI))
                        EM_DEBUG_EXCEPTION("emipc_execute_stub_api failed  ");
@@ -3261,7 +3259,7 @@ void stb_handle_task(int task_type, HIPC_API a_hAPI)
 {
        EM_DEBUG_FUNC_BEGIN();
        int param_index = 0;
-       int is_async_task = (task_type > EMAIL_ASYNC_TASK_BOUNDARY_START)?1:0;
+       int is_async_task = (task_type > EMAIL_ASYNC_TASK_BOUNDARY_START) ? 1 : 0;
        int err = EMAIL_ERROR_NONE;
        int task_id = 0;
        int task_parameter_length = 0;
@@ -3272,23 +3270,22 @@ void stb_handle_task(int task_type, HIPC_API a_hAPI)
        EM_DEBUG_LOG("task_parameter_length [%d]", task_parameter_length);
 
        /* task_parameter */
-       if(task_parameter_length > 0)    {
+       if (task_parameter_length > 0)   {
                task_parameter = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
        }
 
-       if(is_async_task) {
+       if (is_async_task) {
                /* add async task */
-               if((err = emcore_add_task_to_task_table(NULL, 
-                                                                                               task_type, 
-                                                                                               EMAIL_TASK_PRIORITY_MID, 
-                                                                                               task_parameter, 
-                                                                                               task_parameter_length, 
+               if ((err = emcore_add_task_to_task_table(NULL,
+                                                                                               task_type,
+                                                                                               EMAIL_TASK_PRIORITY_MID,
+                                                                                               task_parameter,
+                                                                                               task_parameter_length,
                                                                                                &task_id)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_add_task_to_task_pool failed [%d]", err);
                        goto FINISH_OFF;
                }
-       }
-       else {
+       } else {
                /* do sync task */
                email_task_t sync_task;
 
@@ -3298,18 +3295,18 @@ void stb_handle_task(int task_type, HIPC_API a_hAPI)
                sync_task.task_parameter        = task_parameter;
                sync_task.task_parameter_length = task_parameter_length;
 
-               if((err = emcore_default_sync_task_handler(&sync_task)) != EMAIL_ERROR_NONE) {
+               if ((err = emcore_default_sync_task_handler(&sync_task)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_default_sync_task_handler failed [%d]", err);
                        goto FINISH_OFF;
                }
        }
 
 FINISH_OFF:
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
-       if(is_async_task) {
-               if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
+       if (is_async_task) {
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
        }
 
@@ -3329,28 +3326,27 @@ void* thread_func_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT(void
        task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT *task_param = input_param;
 
        /* Send start signal */
-       if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
+       if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
                EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
 
-       for(i = 0; i < task_param->mail_id_count; i++) {
-               if((err = emcore_move_mail_to_another_account(task_param->multi_user_name, task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
+       for (i = 0; i < task_param->mail_id_count; i++) {
+               if ((err = emcore_move_mail_to_another_account(task_param->multi_user_name, task_param->mail_id_array[i], task_param->source_mailbox_id, task_param->target_mailbox_id, task_id)) != EMAIL_ERROR_NONE) {
                        EM_DEBUG_EXCEPTION("emcore_move_mail_to_another_account failed [%d]", err);
                        goto FINISH_OFF;
                }
 
                /* Send progress signal */
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_IN_PROGRESS, i, task_param->mail_id_count)) != EMAIL_ERROR_NONE)
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_IN_PROGRESS, i, task_param->mail_id_count)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
        }
 
 FINISH_OFF:
        /* Send finish signal */
-       if(err == EMAIL_ERROR_NONE) {
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_FINISHED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
+       if (err == EMAIL_ERROR_NONE) {
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_FINISHED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
-       }
-       else {
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_FAILED, err, 0)) != EMAIL_ERROR_NONE)
+       } else {
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, task_id, EMAIL_TASK_STATUS_FAILED, err, 0)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
        }
 
@@ -3386,7 +3382,7 @@ void stb_move_mails_to_mailbox_of_another_account(HIPC_API a_hAPI)
        /* task_parameter_length */;
        task_parameter_length = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
 
-       if(task_parameter_length <= 0) {
+       if (task_parameter_length <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM : task_parameter_length [%d]", task_parameter_length);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -3395,7 +3391,7 @@ void stb_move_mails_to_mailbox_of_another_account(HIPC_API a_hAPI)
        /* task_parameter */
        task_parameter = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
 
-       if((err = email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT(task_parameter, task_parameter_length, (void**)&decoded_parameter)) != EMAIL_ERROR_NONE) {
+       if ((err = email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT(task_parameter, task_parameter_length, (void**)&decoded_parameter)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -3404,7 +3400,7 @@ void stb_move_mails_to_mailbox_of_another_account(HIPC_API a_hAPI)
 
        THREAD_CREATE(task_id, thread_func_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT, (void*)decoded_parameter, thread_error);
 
-       if(thread_error != 0) {
+       if (thread_error != 0) {
                EM_DEBUG_EXCEPTION("THREAD_CREATE failed [%d]", thread_error);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
@@ -3413,10 +3409,10 @@ void stb_move_mails_to_mailbox_of_another_account(HIPC_API a_hAPI)
        THREAD_DETACH(task_id);
 
 FINISH_OFF:
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3445,27 +3441,26 @@ void* thread_func_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX(void *input_param)
        }
 
        /*  on_server is allowed to be only 0 when server_type is EMAIL_SERVER_TYPE_ACTIVE_SYNC */
-       if ( ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC ) {
+       if (ref_account->incoming_server_type == EMAIL_SERVER_TYPE_ACTIVE_SYNC) {
                recursive = 0;
        }
 
        /* Send start signal */
-       if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
+       if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
                EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
 
-       if((err = emcore_delete_mailbox_ex(task_param->multi_user_name, task_param->account_id, task_param->mailbox_id_array, task_param->mailbox_id_count, task_param->on_server, recursive)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_delete_mailbox_ex(task_param->multi_user_name, task_param->account_id, task_param->mailbox_id_array, task_param->mailbox_id_count, task_param->on_server, recursive)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_delete_mailbox_ex failed[%d]", err);
                goto FINISH_OFF;
        }
 
 FINISH_OFF:
        /* Send finish signal */
-       if(err == EMAIL_ERROR_NONE) {
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, task_id, EMAIL_TASK_STATUS_FINISHED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
+       if (err == EMAIL_ERROR_NONE) {
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, task_id, EMAIL_TASK_STATUS_FINISHED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
-       }
-       else {
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, task_id, EMAIL_TASK_STATUS_FAILED, err, 0)) != EMAIL_ERROR_NONE)
+       } else {
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, task_id, EMAIL_TASK_STATUS_FAILED, err, 0)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
        }
 
@@ -3504,7 +3499,7 @@ void stb_delete_mailbox_ex(HIPC_API a_hAPI)
        /* task_parameter_length */;
        task_parameter_length = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
 
-       if(task_parameter_length <= 0) {
+       if (task_parameter_length <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM : task_parameter_length [%d]", task_parameter_length);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -3513,7 +3508,7 @@ void stb_delete_mailbox_ex(HIPC_API a_hAPI)
        /* task_parameter */
        task_parameter = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
 
-       if((err = email_decode_task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX(task_parameter, task_parameter_length, (void**)&decoded_parameter)) != EMAIL_ERROR_NONE) {
+       if ((err = email_decode_task_parameter_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX(task_parameter, task_parameter_length, (void**)&decoded_parameter)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -3522,7 +3517,7 @@ void stb_delete_mailbox_ex(HIPC_API a_hAPI)
 
        THREAD_CREATE(task_id, thread_func_EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX, (void*)decoded_parameter, thread_error);
 
-       if(thread_error != 0) {
+       if (thread_error != 0) {
                EM_DEBUG_EXCEPTION("THREAD_CREATE failed [%d]", thread_error);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
@@ -3531,10 +3526,10 @@ void stb_delete_mailbox_ex(HIPC_API a_hAPI)
        THREAD_DETACH(task_id);
 
 FINISH_OFF:
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3553,22 +3548,21 @@ void* thread_func_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIG
        task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL *task_param = input_param;
 
        /* Send start signal */
-       if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
+       if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, task_id, EMAIL_TASK_STATUS_STARTED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
                EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
 
-       if((err = emcore_send_mail_with_downloading_attachment_of_original_mail(task_param->multi_user_name, task_param->mail_id)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_send_mail_with_downloading_attachment_of_original_mail(task_param->multi_user_name, task_param->mail_id)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_send_mail_with_downloading_attachment_of_original_mail failed [%d]", err);
                goto FINISH_OFF;
        }
 
 FINISH_OFF:
        /* Send finish signal */
-       if(err == EMAIL_ERROR_NONE) {
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, task_id, EMAIL_TASK_STATUS_FINISHED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
+       if (err == EMAIL_ERROR_NONE) {
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, task_id, EMAIL_TASK_STATUS_FINISHED, EMAIL_ERROR_NONE, 0)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
-       }
-       else {
-               if((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, task_id, EMAIL_TASK_STATUS_FAILED, err, 0)) != EMAIL_ERROR_NONE)
+       } else {
+               if ((err_for_signal = emcore_send_task_status_signal(EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, task_id, EMAIL_TASK_STATUS_FAILED, err, 0)) != EMAIL_ERROR_NONE)
                        EM_DEBUG_LOG("emcore_send_task_status_signal failed [%d]", err_for_signal);
        }
 
@@ -3601,7 +3595,7 @@ void stb_send_mail_with_downloading_attachment_of_original_mail(HIPC_API a_hAPI)
        /* task_parameter_length */;
        task_parameter_length = emipc_get_nth_parameter_length(a_hAPI, ePARAMETER_IN, param_index);
 
-       if(task_parameter_length <= 0) {
+       if (task_parameter_length <= 0) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM : task_parameter_length [%d]", task_parameter_length);
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
@@ -3610,7 +3604,7 @@ void stb_send_mail_with_downloading_attachment_of_original_mail(HIPC_API a_hAPI)
        /* task_parameter */
        task_parameter = (char*) emipc_get_nth_parameter_data(a_hAPI, ePARAMETER_IN, param_index++);
 
-       if((err = email_decode_task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL(task_parameter, task_parameter_length, (void**)&decoded_parameter)) != EMAIL_ERROR_NONE) {
+       if ((err = email_decode_task_parameter_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL(task_parameter, task_parameter_length, (void**)&decoded_parameter)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("email_decode_task_parameter_EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT failed[%d]", err);
                goto FINISH_OFF;
        }
@@ -3619,7 +3613,7 @@ void stb_send_mail_with_downloading_attachment_of_original_mail(HIPC_API a_hAPI)
 
        THREAD_CREATE(task_id, thread_func_EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL, (void*)decoded_parameter, thread_error);
 
-       if(thread_error != 0) {
+       if (thread_error != 0) {
                EM_DEBUG_EXCEPTION("THREAD_CREATE failed [%d]", thread_error);
                err = EMAIL_ERROR_SYSTEM_FAILURE;
                goto FINISH_OFF;
@@ -3628,10 +3622,10 @@ void stb_send_mail_with_downloading_attachment_of_original_mail(HIPC_API a_hAPI)
        THREAD_DETACH(task_id);
 
 FINISH_OFF:
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
-       if(!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
+       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &task_id, sizeof(int)))
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (!emipc_execute_stub_api(a_hAPI))
@@ -3687,7 +3681,7 @@ void stb_load_default_account_id(HIPC_API a_hAPI)
        }
 
        err = emcore_load_default_account_id(multi_user_name, &account_id);
-       if (err != EMAIL_ERROR_NONE) { 
+       if (err != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_save_default_account_id failed [%d]", err);
        }
 
@@ -3695,7 +3689,7 @@ void stb_load_default_account_id(HIPC_API a_hAPI)
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
        if (err == EMAIL_ERROR_NONE) {
-               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &account_id, sizeof(int))) 
+               if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &account_id, sizeof(int)))
                        EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
        }
 
@@ -3719,16 +3713,16 @@ void stb_get_user_name(HIPC_API a_hAPI)
     EM_DEBUG_LOG("Peer PID : [%d]", pid);
 
     if (pid > 0) {
-        if ((err = emcore_get_user_name(pid, &user_name)) != EMAIL_ERROR_NONE) 
+        if ((err = emcore_get_user_name(pid, &user_name)) != EMAIL_ERROR_NONE)
             EM_DEBUG_EXCEPTION("emcore_get_user_info failed : [%d]", err);
 
         EM_DEBUG_LOG("Domain name : [%s]", user_name);
 
-        if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int))) 
+        if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, &err, sizeof(int)))
                 EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
 
                if (user_name) {
-                       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, user_name, EM_SAFE_STRLEN(user_name) + 1)) 
+                       if (!emipc_add_parameter(a_hAPI, ePARAMETER_OUT, user_name, EM_SAFE_STRLEN(user_name) + 1))
                                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                }
     }
@@ -3761,7 +3755,7 @@ void stb_API_mapper(HIPC_API a_hAPI)
                return;
        }
 
-       switch(nAPIID) {
+       switch (nAPIID) {
                case _EMAIL_API_ADD_ACCOUNT:
                        stb_create_account(a_hAPI);
                        break;
@@ -3819,7 +3813,7 @@ void stb_API_mapper(HIPC_API a_hAPI)
                        break;
 
                case _EMAIL_API_CLEAR_DATA:
-                       stb_clear_mail_data (a_hAPI);
+                       stb_clear_mail_data(a_hAPI);
                        break;
 
                case _EMAIL_API_DELETE_ALL_MAIL:
@@ -3942,23 +3936,23 @@ void stb_API_mapper(HIPC_API a_hAPI)
                        stb_retry_sending_mail(a_hAPI);
                        break;
 
-               case _EMAIL_API_VALIDATE_ACCOUNT :
+               case _EMAIL_API_VALIDATE_ACCOUNT:
                        stb_validate_account(a_hAPI);
                        break;
 
-               case _EMAIL_API_SEND_MAIL_CANCEL_JOB :
+               case _EMAIL_API_SEND_MAIL_CANCEL_JOB:
                        stb_cancel_send_mail_job(a_hAPI);
                        break;
 
-               case _EMAIL_API_SEARCH_MAIL_ON_SERVER :
+               case _EMAIL_API_SEARCH_MAIL_ON_SERVER:
                        stb_search_mail_on_server(a_hAPI);
                        break;
 
-               case _EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER :
+               case _EMAIL_API_CLEAR_RESULT_OF_SEARCH_MAIL_ON_SERVER:
                        stb_clear_result_of_search_mail_on_server(a_hAPI);
                        break;
 
-               case _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION :
+               case _EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION:
                        stb_add_account_with_validation(a_hAPI);
                        break;
 
@@ -3982,56 +3976,56 @@ void stb_API_mapper(HIPC_API a_hAPI)
                        stb_verify_signature(a_hAPI);
                        break;
 
-               case _EMAIL_API_PING_SERVICE :
+               case _EMAIL_API_PING_SERVICE:
                        stb_ping_service(a_hAPI);
                        break;
 
-               case _EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL :
+               case _EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL:
                        stb_update_notification_bar_for_unread_mail(a_hAPI);
                        break;
 
-               case _EMAIL_API_CLEAR_NOTIFICATION_BAR :
+               case _EMAIL_API_CLEAR_NOTIFICATION_BAR:
                        stb_clear_notification_bar(a_hAPI);
                        break;
 
-               case _EMAIL_API_SHOW_USER_MESSAGE :
+               case _EMAIL_API_SHOW_USER_MESSAGE:
                        stb_show_user_message(a_hAPI);
                        break;
 
-               case _EMAIL_API_WRITE_MIME_FILE :
+               case _EMAIL_API_WRITE_MIME_FILE:
                        stb_write_mime_file(a_hAPI);
                        break;
 
-               case _EMAIL_API_VALIDATE_ACCOUNT_EX :
+               case _EMAIL_API_VALIDATE_ACCOUNT_EX:
                        stb_validate_account_ex(a_hAPI);
                        break;
 
-               case EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT :
+               case EMAIL_ASYNC_TASK_MOVE_MAILS_TO_MAILBOX_OF_ANOTHER_ACCOUNT:
                        stb_move_mails_to_mailbox_of_another_account(a_hAPI);
                        break;
 
-               case EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX :
+               case EMAIL_ASYNC_TASK_DELETE_MAILBOX_EX:
                        stb_delete_mailbox_ex(a_hAPI);
                        break;
 
-               case EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL :
+               case EMAIL_ASYNC_TASK_SEND_MAIL_WITH_DOWNLOADING_ATTACHMENT_OF_ORIGINAL_MAIL:
                        stb_send_mail_with_downloading_attachment_of_original_mail(a_hAPI);
                        break;
 
-        case _EMAIL_API_GET_USER_NAME :
+        case _EMAIL_API_GET_USER_NAME:
             stb_get_user_name(a_hAPI);
             break;
 
-               case _EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID :
+               case _EMAIL_API_SAVE_DEFAULT_ACCOUNT_ID:
                        stb_save_default_account_id(a_hAPI);
                        break;
 
-               case _EMAIL_API_LOAD_DEFAULT_ACCOUNT_ID :
+               case _EMAIL_API_LOAD_DEFAULT_ACCOUNT_ID:
                        stb_load_default_account_id(a_hAPI);
                        break;
 
-               default :
-                       if(EMAIL_SYNC_TASK_BOUNDARY_START < nAPIID && nAPIID < EMAIL_ASYNC_TASK_BOUNDARY_END)
+               default:
+                       if (EMAIL_SYNC_TASK_BOUNDARY_START < nAPIID && nAPIID < EMAIL_ASYNC_TASK_BOUNDARY_END)
                                stb_handle_task(nAPIID, a_hAPI);
                        break;
        }
@@ -4095,7 +4089,7 @@ INTERNAL_FUNC int kill_daemon_if_no_account()
 
        if (total_account_count == 0) {
                EM_DEBUG_LOG("email-service is going to shutdown");
-               g_main_loop_quit (g_mainloop);
+               g_main_loop_quit(g_mainloop);
        }
 
 FINISH_OFF:
@@ -4128,21 +4122,20 @@ gboolean callback_for_shutdown(gpointer user_data)
        return FALSE;
 }
 
-gboolean callback_for_del_account (GIOChannel *ch, GIOCondition cond, gpointer data)
+gboolean callback_for_del_account(GIOChannel *ch, GIOCondition cond, gpointer data)
 {
        static int file_del = 0;
        static int db_del = 0;
        int event = 0;
        gsize len = 0;
-       g_io_channel_read_chars (ch, (gchar*) &event, sizeof (event), &len, NULL);
+       g_io_channel_read_chars(ch, (gchar*) &event, sizeof(event), &len, NULL);
 
-       if (event==EMAIL_SIGNAL_DB_DELETED) {
+       if (event == EMAIL_SIGNAL_DB_DELETED) {
                db_del = 1;
-       }
-       else if (event==EMAIL_SIGNAL_FILE_DELETED) {
+       } else if (event == EMAIL_SIGNAL_FILE_DELETED) {
                file_del = 1;
        }
-       EM_DEBUG_LOG ("callback_for_del_account called file_del[%d] db_del[%d]", file_del, db_del);
+       EM_DEBUG_LOG("callback_for_del_account called file_del[%d] db_del[%d]", file_del, db_del);
 
        /* if called twice, process termination begins.
           two threads should complete the delete task */
@@ -4157,62 +4150,56 @@ gboolean callback_for_del_account (GIOChannel *ch, GIOCondition cond, gpointer d
 static GDBusNodeInfo *introspection_data = NULL;
 extern gchar introspection_xml[];
 
-static void
-handle_method_call (GDBusConnection         *connection,
-                      const gchar           *sender,
-                      const gchar           *object_path,
-                      const gchar           *interface_name,
-                      const gchar           *method_name,
-                      GVariant              *parameters,
-                      GDBusMethodInvocation *invocation,
-                      gpointer               user_data)
+static void handle_method_call(GDBusConnection         *connection,
+                                                                 const gchar           *sender,
+                                                                 const gchar           *object_path,
+                                                                 const gchar           *interface_name,
+                                                                 const gchar           *method_name,
+                                                                 GVariant              *parameters,
+                                                                 GDBusMethodInvocation *invocation,
+                                                                 gpointer               user_data)
 {
        /* called by emipc_launch_email_service */
-       if (g_strcmp0 (method_name, "Launch") == 0) {
+       if (g_strcmp0(method_name, "Launch") == 0) {
                int caller_pid = 0;
-               g_variant_get (parameters, "(i)", &caller_pid);
-
+               g_variant_get(parameters, "(i)", &caller_pid);
                launch_pid = caller_pid;
-               g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", EMAIL_ERROR_NONE));
-               EM_DEBUG_LOG ("email-service launched by pid [%d]", caller_pid);
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", EMAIL_ERROR_NONE));
+               EM_DEBUG_LOG("email-service launched by pid [%d]", caller_pid);
+       } else if (g_strcmp0(method_name, "GetDisplayName") == 0) {
+               GVariant* ret = em_gdbus_get_display_name(parameters);
+               g_dbus_method_invocation_return_value(invocation, ret);
+       } else if (g_strcmp0(method_name, "CheckBlockingMode") == 0) {
+               GVariant* ret = em_gdbus_check_blocking_mode(parameters);
+               g_dbus_method_invocation_return_value(invocation, ret);
        }
 /*
-       else if (g_strcmp0 (method_name, "SetContactsLog") == 0) {
+       else if (g_strcmp0(method_name, "SetContactsLog") == 0) {
                GVariant* ret = em_gdbus_set_contact_log(parameters);
-               g_dbus_method_invocation_return_value (invocation, ret);
+               g_dbus_method_invocation_return_value(invocation, ret);
        }
-       else if (g_strcmp0 (method_name, "DeleteContactsLog") == 0) {
+       else if (g_strcmp0(method_name, "DeleteContactsLog") == 0) {
                GVariant* ret = em_gdbus_delete_contact_log(parameters);
-               g_dbus_method_invocation_return_value (invocation, ret);
+               g_dbus_method_invocation_return_value(invocation, ret);
        }
 */
-       else if (g_strcmp0 (method_name, "GetDisplayName") == 0) {
-               GVariant* ret = em_gdbus_get_display_name(parameters);
-               g_dbus_method_invocation_return_value (invocation, ret);
-       }
-       else if (g_strcmp0 (method_name, "CheckBlockingMode") == 0) {
-               GVariant* ret = em_gdbus_check_blocking_mode(parameters);
-               g_dbus_method_invocation_return_value (invocation, ret);
-       }
+
 }
 
-static const
-GDBusInterfaceVTable interface_vtable =
-{
+static const GDBusInterfaceVTable interface_vtable = {
        handle_method_call,
        NULL,
        NULL
 };
 
-static void
-on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data)
+static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
 {
-       EM_DEBUG_LOG ("on_bus_acquired begin");
+       EM_DEBUG_LOG("on_bus_acquired begin");
 
        guint reg_id;
        GError *error = NULL;
 
-       reg_id = g_dbus_connection_register_object (connection,
+       reg_id = g_dbus_connection_register_object(connection,
                                              EMAIL_SERVICE_PATH,
                                              introspection_data->interfaces[0],
                                              &interface_vtable,
@@ -4220,24 +4207,24 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d
                                              NULL,  /* user_data_free_func */
                                              &error); /* GError** */
        if (reg_id == 0) {
-               EM_DEBUG_EXCEPTION ("g_dbus_connection_register_object error[%s]",error->message);
-               g_error_free (error);
+               EM_DEBUG_EXCEPTION("g_dbus_connection_register_object error[%s]", error->message);
+               g_error_free(error);
        }
-       EM_DEBUG_LOG ("on_bus_acquired end [%d]", reg_id);
+       EM_DEBUG_LOG("on_bus_acquired end [%d]", reg_id);
 }
 
-static void on_name_acquired (GDBusConnection *connection,
+static void on_name_acquired(GDBusConnection *connection,
                                const gchar *name,
                                gpointer     user_data)
 {
-       EM_DEBUG_LOG ("on_name_acquired [%s]", name);
+       EM_DEBUG_LOG("on_name_acquired [%s]", name);
 }
 
-static void on_name_lost (GDBusConnection *connection,
+static void on_name_lost(GDBusConnection *connection,
                            const gchar *name,
                            gpointer     user_data)
 {
-       EM_DEBUG_EXCEPTION ("on_name_lost [%p] [%s]", connection, name);
+       EM_DEBUG_EXCEPTION("on_name_lost [%p] [%s]", connection, name);
 }
 
 INTERNAL_FUNC int main(int argc, char *argv[])
@@ -4251,8 +4238,8 @@ INTERNAL_FUNC int main(int argc, char *argv[])
     GList *node = NULL;
     GList *zone_name_list = NULL;
 
-#if !GLIB_CHECK_VERSION(2, 36, 0) 
-       g_type_init(); 
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+       g_type_init();
 #endif
 
     /* Init container for daemon */
@@ -4262,7 +4249,7 @@ INTERNAL_FUNC int main(int argc, char *argv[])
 
        ret = emipc_initialize_stub(stb_API_mapper);
 
-       if(ret == true)
+       if (ret == true)
                EM_DEBUG_LOG("ipcEmailStub_Initialize Success");
        else
                EM_DEBUG_EXCEPTION("ipcEmailStub_Initialize failed");
@@ -4302,27 +4289,27 @@ INTERNAL_FUNC int main(int argc, char *argv[])
        g_timeout_add(5000, callback_for_shutdown, NULL);
 
        /* pipe between main and del account thread */
-       int *pipefd = emcore_init_pipe_for_del_account ();
+       int *pipefd = emcore_init_pipe_for_del_account();
        /* main loop uses IO channel for listening an event */
        if (pipefd) {
-               GIOChannel *ch = g_io_channel_unix_new (pipefd[0]);
-               EM_DEBUG_LOG ("main pipe[%d][%d]", pipefd[0], pipefd[1]);
+               GIOChannel *ch = g_io_channel_unix_new(pipefd[0]);
+               EM_DEBUG_LOG("main pipe[%d][%d]", pipefd[0], pipefd[1]);
                /* non-blocking mode */
-               g_io_channel_set_flags (ch, g_io_channel_get_flags (ch) | G_IO_FLAG_NONBLOCK, NULL);
+               g_io_channel_set_flags(ch, g_io_channel_get_flags(ch) | G_IO_FLAG_NONBLOCK, NULL);
                /* main loop watches the IO, and call the cb when data is ready */
-               g_io_add_watch (ch, G_IO_IN, &callback_for_del_account, NULL);
+               g_io_add_watch(ch, G_IO_IN, &callback_for_del_account, NULL);
        }
 
        /* gdbus setup */
        GError *error = NULL;
-       introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, &error);
+       introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, &error);
        if (!introspection_data) {
                /* introspection_xml may be invalid */
-               EM_DEBUG_EXCEPTION ("g_dbus_node_info_new_for_xml error [%s]", error->message);
-               g_error_free (error);
+               EM_DEBUG_EXCEPTION("g_dbus_node_info_new_for_xml error [%s]", error->message);
+               g_error_free(error);
        }
 
-       owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
+       owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
                                 EMAIL_SERVICE_NAME,
                                 G_BUS_NAME_OWNER_FLAGS_NONE,
                                 on_bus_acquired,
@@ -4331,9 +4318,9 @@ INTERNAL_FUNC int main(int argc, char *argv[])
                                 NULL,
                                 NULL);
        if (!owner_id) {
-               EM_DEBUG_EXCEPTION ("g_bus_own_name error");
+               EM_DEBUG_EXCEPTION("g_bus_own_name error");
        }
-       EM_DEBUG_LOG ("owner_id [%d]", owner_id);
+       EM_DEBUG_LOG("owner_id [%d]", owner_id);
 
        mainloop = g_main_loop_new(NULL, 0);
        g_mainloop = mainloop;
@@ -4341,7 +4328,7 @@ INTERNAL_FUNC int main(int argc, char *argv[])
        g_main_loop_run(mainloop);
 
        /* Clean up resources */
-       g_bus_unown_name (owner_id);
+       g_bus_unown_name(owner_id);
        g_main_loop_unref(mainloop);
        g_mainloop = NULL;
 
@@ -4351,7 +4338,7 @@ FINISH_OFF:
        emdaemon_finalize(NULL);
        emcore_gmime_shutdown();
 
-       EM_DEBUG_LOG ("Goodbye, world");
+       EM_DEBUG_LOG("Goodbye, world");
        EM_DEBUG_FUNC_END();
        exit(44); /* exit with exit code 44 to prevent restarting */
        return 0;
index 29fc3c1..15c8916 100755 (executable)
@@ -74,7 +74,7 @@ static gboolean on_timer_proxy_new(gpointer userdata)
        GCancellable *proxy_cancel = (GCancellable *)userdata;
 
        if (proxy_cancel) {
-               if (!g_cancellable_is_cancelled (proxy_cancel))
+               if (!g_cancellable_is_cancelled(proxy_cancel))
                        g_cancellable_cancel(proxy_cancel);
        }
 
@@ -89,113 +89,113 @@ EXPORT_API int emipc_launch_email_service()
        int ret = EMAIL_ERROR_NONE;
        guint timer_tag = 0;
 
-#if !GLIB_CHECK_VERSION(2, 36, 0) 
-       g_type_init(); 
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+       g_type_init();
 #endif
 
        GCancellable *proxy_cancel = g_cancellable_new();
        timer_tag = g_timeout_add(5000, on_timer_proxy_new, proxy_cancel);
-       GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, 
-                                   G_DBUS_PROXY_FLAGS_NONE, 
-                                   NULL, 
+       GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
+                                   G_DBUS_PROXY_FLAGS_NONE,
+                                   NULL,
                                    EMAIL_SERVICE_NAME,
                                    EMAIL_SERVICE_PATH,
-                                   EMAIL_SERVICE_NAME, 
+                                   EMAIL_SERVICE_NAME,
                                    proxy_cancel,
                                    &gerror);
 
        g_source_remove(timer_tag);
 
        if (!bproxy) {
-               EM_DEBUG_EXCEPTION ("g_dbus_proxy_new_for_bus_sync error [%s]", 
+               EM_DEBUG_EXCEPTION("g_dbus_proxy_new_for_bus_sync error [%s]",
                                  gerror->message);
                ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                goto FINISH_OFF;
        }
 
-       GVariant *result = g_dbus_proxy_call_sync (bproxy, 
-                        "Launch", 
-                        g_variant_new ("(i)", getpid()), 
-                        G_DBUS_CALL_FLAGS_NONE, 
+       GVariant *result = g_dbus_proxy_call_sync(bproxy,
+                        "Launch",
+                        g_variant_new("(i)", getpid()),
+                        G_DBUS_CALL_FLAGS_NONE,
                         5000,  /* msec, 5s*/
-                        NULL, 
+                        NULL,
                         &gerror);
 
 
        if (!result) {
-               EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'Launch' error [%s]", 
+               EM_DEBUG_EXCEPTION("g_dbus_proxy_call_sync 'Launch' error [%s]",
                                  gerror->message);
                ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
                goto FINISH_OFF;
        }
 
-       g_variant_get (result, "(i)", &ret);
+       g_variant_get(result, "(i)", &ret);
 
 FINISH_OFF:
-       EM_DEBUG_LOG ("ret [%d]\n", ret);
+       EM_DEBUG_LOG("ret [%d]\n", ret);
        if (bproxy)
-               g_object_unref (bproxy);
+               g_object_unref(bproxy);
 
        if (proxy_cancel)
                g_object_unref(proxy_cancel);
 
        if (gerror)
-               g_error_free (gerror);
+               g_error_free(gerror);
 
        return ret;
 }
 
-void cancellable_connect_cb ()
+void cancellable_connect_cb()
 {
-       EM_DEBUG_LOG ("Cancellable is now canceled");
+       EM_DEBUG_LOG("Cancellable is now canceled");
 }
 
 EXPORT_API GCancellable *cancel = NULL;
 
-GVariant* em_gdbus_get_display_name (GVariant *parameters)
+GVariant* em_gdbus_get_display_name(GVariant *parameters)
 {
        char *email_address        = NULL;
        char *multi_user_name      = NULL;
        char *contact_display_name = NULL;
 
-       g_variant_get (parameters, "(ss)", &email_address, &multi_user_name);
+       g_variant_get(parameters, "(ss)", &email_address, &multi_user_name);
 
        /* replace "" to NULL */
-       if (!g_strcmp0(email_address,""))
-               EM_SAFE_FREE (email_address);
+       if (!g_strcmp0(email_address, ""))
+               EM_SAFE_FREE(email_address);
 
-       int err = emcore_get_mail_display_name_internal (multi_user_name, email_address, &contact_display_name);
+       int err = emcore_get_mail_display_name_internal(multi_user_name, email_address, &contact_display_name);
 
        /* make return_val */
        if (!contact_display_name) {
                contact_display_name = strdup("");
        }
-       GVariant* ret = g_variant_new ("(si)", contact_display_name, err);
+       GVariant* ret = g_variant_new("(si)", contact_display_name, err);
 
        /* clean-up */
-       EM_SAFE_FREE (email_address);
-       EM_SAFE_FREE (contact_display_name);
+       EM_SAFE_FREE(email_address);
+       EM_SAFE_FREE(contact_display_name);
 
        return ret;
 }
 
-GVariant* em_gdbus_check_blocking_mode (GVariant *parameters)
+GVariant* em_gdbus_check_blocking_mode(GVariant *parameters)
 {
        char *sender_address = NULL;
        char *multi_user_name = NULL;
        int blocking_mode = 0;
        int err = EMAIL_ERROR_NONE;
 
-       g_variant_get (parameters, "(ss)", &sender_address, &multi_user_name);
+       g_variant_get(parameters, "(ss)", &sender_address, &multi_user_name);
 #ifdef __FEATURE_BLOCKING_MODE__
-       err = emcore_check_blocking_mode_internal (multi_user_name, sender_address, &blocking_mode);
+       err = emcore_check_blocking_mode_internal(multi_user_name, sender_address, &blocking_mode);
 #endif /* __FEATURE_BLOCKING_MODE__ */
        /* make return_val */
-       GVariant* ret = g_variant_new ("(ii)", blocking_mode, err);
+       GVariant* ret = g_variant_new("(ii)", blocking_mode, err);
 
        /* clean-up string */
-       EM_SAFE_FREE (sender_address);
-       EM_SAFE_FREE (multi_user_name);
+       EM_SAFE_FREE(sender_address);
+       EM_SAFE_FREE(multi_user_name);
 
        return ret;
 }
index 57f480f..588b9a6 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -46,7 +46,7 @@ EXPORT_API HIPC_API emipc_create_email_api(long api_id)
        EM_DEBUG_FUNC_BEGIN();
 
        emipc_email_api_info *api_info = (emipc_email_api_info *)calloc(1, sizeof(emipc_email_api_info));
-       if(api_info == NULL) {
+       if (api_info == NULL) {
                EM_DEBUG_EXCEPTION("calloc failed");
                return NULL;
        }
@@ -111,7 +111,7 @@ EXPORT_API bool emipc_add_parameter(HIPC_API api, EPARAMETER_DIRECTION direction
 EXPORT_API bool emipc_add_dynamic_parameter(HIPC_API api, EPARAMETER_DIRECTION direction, void *data, int data_length)
 {
        EM_DEBUG_FUNC_BEGIN("data_length[%d]", data_length);
-       
+
        emipc_param_list *parameters = emipc_get_api_parameters(api, direction);
        if (!parameters) {
                EM_DEBUG_EXCEPTION("emipc_get_api_parameters failed");
@@ -216,32 +216,32 @@ EXPORT_API int emipc_execute_proxy_task(email_task_type_t input_task_type, void
        char *task_parameter_stream = NULL;
        HIPC_API hAPI = NULL;
 
-       if(input_task_parameter == NULL) {
+       if (input_task_parameter == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                err = EMAIL_ERROR_INVALID_PARAM;
                goto FINISH_OFF;
        }
 
-       if((err = emcore_encode_task_parameter(input_task_type, input_task_parameter, &task_parameter_stream, &task_parameter_length)) != EMAIL_ERROR_NONE) {
+       if ((err = emcore_encode_task_parameter(input_task_type, input_task_parameter, &task_parameter_stream, &task_parameter_length)) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emcore_encode_task_parameter failed [%d]", err);
                goto FINISH_OFF;
        }
 
        hAPI = emipc_create_email_api(input_task_type);
 
-       if(!hAPI) {
+       if (!hAPI) {
                EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
                err = EMAIL_ERROR_NULL_VALUE;
                goto FINISH_OFF;
        }
 
-       if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)task_parameter_stream, task_parameter_length)) {
+       if (!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)task_parameter_stream, task_parameter_length)) {
                EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
                err = EMAIL_ERROR_OUT_OF_MEMORY;
                goto FINISH_OFF;
        }
 
-       if(emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
+       if (emipc_execute_proxy_api(hAPI) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
                err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
                goto FINISH_OFF;
@@ -278,14 +278,14 @@ EXPORT_API int emipc_get_user_name(char **output_user_name)
     char *user_name = NULL;
 
     HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_USER_NAME);
-    if(!emipc_execute_proxy_api(hAPI))  {
+    if (!emipc_execute_proxy_api(hAPI))  {
         EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed");
         err = EMAIL_ERROR_IPC_SOCKET_FAILURE;
         goto FINISH_OFF;
     }
 
     emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
-    if (err != EMAIL_ERROR_NONE) 
+    if (err != EMAIL_ERROR_NONE)
         goto FINISH_OFF;
 
     buffer_size = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1);
@@ -301,7 +301,7 @@ FINISH_OFF:
 
     EM_SAFE_FREE(user_name);
 
-    if (hAPI) 
+    if (hAPI)
         emipc_destroy_email_api(hAPI);
 
 #endif /* __FEATURE_CONTAINER_ENABLE__ */
index 5d4a52e..a4e0be4 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -35,7 +35,7 @@
 EXPORT_API bool emipc_deserialize_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction, void *stream)
 {
        EM_DEBUG_FUNC_BEGIN("emipc_email_api_info : [%p], direction : [%d]", api_info, direction);
-       
+
        if (!api_info || !stream) {
                EM_DEBUG_EXCEPTION("Invalid parameter.");
                return false;
@@ -60,7 +60,7 @@ EXPORT_API unsigned char *emipc_serialize_api_info(emipc_email_api_info *api_inf
 {
        EM_DEBUG_FUNC_BEGIN();
        unsigned char *stream = NULL;
-       
+
        if (!api_info) {
                EM_DEBUG_EXCEPTION("Invalid parameter.");
                return stream;
@@ -88,12 +88,12 @@ EXPORT_API unsigned char *emipc_serialize_api_info(emipc_email_api_info *api_inf
 EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info, EPARAMETER_DIRECTION direction)
 {
        EM_DEBUG_FUNC_BEGIN("emipc_email_api_info : [%p], direction : [%d]", api_info, direction);
-       
+
        if (!api_info) {
                EM_DEBUG_EXCEPTION("INVALID_PARAM");
                return NULL;
        }
-       
+
        if (api_info->params[direction] == NULL) {
                api_info->params[direction] = emipc_create_param_list();
                if (api_info->params[direction] == NULL) {
@@ -107,11 +107,11 @@ EXPORT_API void *emipc_get_parameters_of_api_info(emipc_email_api_info *api_info
 
 EXPORT_API void emipc_free_api_info(emipc_email_api_info *api_info)
 {
-       if (!api_info) 
+       if (!api_info)
                return;
 
-       emipc_destroy_param_list (api_info->params[ePARAMETER_IN]);
-       emipc_destroy_param_list (api_info->params[ePARAMETER_OUT]);
+       emipc_destroy_param_list(api_info->params[ePARAMETER_IN]);
+       emipc_destroy_param_list(api_info->params[ePARAMETER_OUT]);
 }
 
 
index 70b3c98..7cf7c23 100755 (executable)
@@ -129,11 +129,11 @@ EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_lis
        EM_DEBUG_FUNC_BEGIN("param_list [%p] stream_length [%p]", param_list, stream_length);
 
        if (!param_list) {
-               EM_DEBUG_LOG ("no data to be serialized");
+               EM_DEBUG_LOG("no data to be serialized");
                return NULL;
        }
 
-       EM_SAFE_FREE (param_list->byte_stream);
+       EM_SAFE_FREE(param_list->byte_stream);
 
        int stream_len = emipc_sum_param_list_length(param_list);
        if (stream_len <= 0) {
@@ -148,7 +148,7 @@ EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_lis
        }
 
        int pos = sizeof(int) * eSTREAM_COUNT;
-       if (pos + (int)sizeof(param_list->param_count) > stream_len ) {
+       if (pos + (int)sizeof(param_list->param_count) > stream_len) {
                EM_DEBUG_EXCEPTION("%d > stream_len", pos + sizeof(param_list->param_count));
                EM_SAFE_FREE(param_list->byte_stream);
                goto FINISH_OFF;
@@ -163,7 +163,7 @@ EXPORT_API unsigned char *emipc_serialize_param_list(emipc_param_list *param_lis
        /* stream format */
        /* | param1 length | (param1 data) | param2 length | (param2 data) | ... |*/
        /* if param is 0 long, the param data is omitted */
-       for(index=0; index<param_list->param_count; index++) {
+       for (index = 0; index < param_list->param_count; index++) {
                length = emipc_get_length(param_list->params[index]);
                if (length < 0) {
                        EM_DEBUG_EXCEPTION("index = %d, length = %d", index, length);
index fff5db6..c8a6a07 100755 (executable)
@@ -34,7 +34,7 @@
 #include "email-storage.h"
 #include "email-core-task-manager.h"
 
-EXPORT_API int emipc_initialize_proxy ()
+EXPORT_API int emipc_initialize_proxy()
 {
        EM_DEBUG_FUNC_BEGIN();
 
@@ -68,17 +68,17 @@ EXPORT_API int emipc_execute_proxy_api(HIPC_API api)
        int err = EMAIL_ERROR_NONE;
        emipc_email_api_info *api_info = (emipc_email_api_info *)api;
 
-       EM_DEBUG_LOG_DEV ("API [%p]", api_info);
+       EM_DEBUG_LOG_DEV("API [%p]", api_info);
 
-       if(api_info == NULL) {
+       if (api_info == NULL) {
                EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
        EM_DEBUG_LOG_SEC("Request: API_ID[%s][0x%x] RES_ID[%d] APP_ID[%d]",\
-                                          EM_APIID_TO_STR(api_info->api_id), 
+                                          EM_APIID_TO_STR(api_info->api_id),
                                           api_info->api_id,
-                                          api_info->response_id, 
+                                          api_info->response_id,
                                           api_info->app_id);
 
        ret = emipc_execute_api_of_proxy_main(api_info);
@@ -89,8 +89,8 @@ EXPORT_API int emipc_execute_proxy_api(HIPC_API api)
                EM_DEBUG_LOG("Launch email-service daemon");
                err = emipc_initialize_proxy();
                if (err != EMAIL_ERROR_NONE) {
-                       EM_DEBUG_EXCEPTION ("emipc_initialize_proxy [%d]", err);
-                       goto FINISH_OFF;                        
+                       EM_DEBUG_EXCEPTION("emipc_initialize_proxy [%d]", err);
+                       goto FINISH_OFF;
                }
 
                err = emipc_execute_api_of_proxy_main(api_info);
index b3c130e..fc6a581 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -41,11 +41,11 @@ EXPORT_API bool emipc_finalize_stub()
 
 EXPORT_API bool emipc_execute_stub_api(HIPC_API api)
 {
-       EM_DEBUG_LOG_DEV ("ipcEmailStub_ExecuteAPI [%x]", api);
+       EM_DEBUG_LOG_DEV("ipcEmailStub_ExecuteAPI [%x]", api);
        emipc_email_api_info *api_info = (emipc_email_api_info *)api;
        if (api_info == NULL)
                return false;
 
        return emipc_execute_api_stub_to_proxy(api_info);
-}    
+}
 
index fcba8d1..0e74dd9 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -45,18 +45,18 @@ EXPORT_API int emipc_initialize_proxy_main()
                EM_DEBUG_LOG("Socket already initialized");
                return err;
        }
-       
+
        if ((err = emipc_start_proxy_socket()) != EMAIL_ERROR_NONE) {
                EM_DEBUG_EXCEPTION("Socket start failed");
                if (err == EMAIL_ERROR_PERMISSION_DENIED)
                        return err;
-               
+
                return EMAIL_ERROR_IPC_CONNECTION_FAILURE;
        }
-       
+
        EM_DEBUG_LOG("Socket ID : %d", emipc_get_proxy_socket_id());
        EM_DEBUG_FUNC_END();
-       return err; 
+       return err;
 }
 
 EXPORT_API int emipc_finalize_proxy_main()
@@ -74,7 +74,7 @@ EXPORT_API int emipc_finalize_proxy_main()
 EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info)
 {
        EM_DEBUG_FUNC_BEGIN("api_info [%p]", api_info);
-       
+
        int ret;
        unsigned char *in_stream = NULL;
        int length = 0;
@@ -88,7 +88,7 @@ EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info)
 
        in_stream = emipc_serialize_api_info(api_info, ePARAMETER_IN, &length);
 
-       if( !in_stream ) {
+       if (!in_stream) {
                EM_DEBUG_EXCEPTION("NULL stream");
                return false;
        }
@@ -100,23 +100,23 @@ EXPORT_API bool emipc_execute_api_of_proxy_main(emipc_email_api_info *api_info)
        if (sending_bytes > 0) {
 #ifdef IPCLIB_STREAM_TRACE_ON
                int index = 0;
-               for (index=0;index<length;index++) 
+               for (index = 0; index < length; index++)
                        EM_DEBUG_LOG("in_stream[index] : [%x]", in_stream[index]);
 #endif
                char *ipc_buf = NULL;
 
                ret = emipc_recv_proxy_socket(&ipc_buf);
-       
+
                EM_DEBUG_LOG("Recv length : %d", ret);
 
                if (ret > 0)
                        result = emipc_deserialize_api_info(api_info, ePARAMETER_OUT, ipc_buf);
                else
-                       result = false; 
+                       result = false;
 
                EM_SAFE_FREE(ipc_buf);
        }
-       
+
        EM_DEBUG_FUNC_END("result [%d]", result);
-       return result;          
+       return result;
 }
index 584fdff..e9e0ebe 100755 (executable)
@@ -66,7 +66,7 @@ EXPORT_API int emipc_start_proxy_socket()
        }
 
        thread_socket_t* cur = (thread_socket_t*) em_malloc(sizeof(thread_socket_t));
-       if(!cur) {
+       if (!cur) {
                EM_DEBUG_EXCEPTION("em_malloc failed");
                return false;
        }
@@ -92,7 +92,7 @@ EXPORT_API bool emipc_end_proxy_socket()
        ENTER_CRITICAL_SECTION(proxy_mutex);
        GList *cur = socket_head;
        while (cur) {
-               thread_socket_t* cur_socket = g_list_nth_data(cur,0);
+               thread_socket_t* cur_socket = g_list_nth_data(cur, 0);
 
                /* close the socket of current thread */
                if (tid == cur_socket->tid) {
@@ -120,11 +120,11 @@ EXPORT_API bool emipc_end_all_proxy_sockets()
 
        ENTER_CRITICAL_SECTION(proxy_mutex);
        GList *cur = socket_head;
-       while( cur ) {
-               thread_socket_t* cur_socket = g_list_nth_data(cur,0);
+       while (cur) {
+               thread_socket_t* cur_socket = g_list_nth_data(cur, 0);
 
                /* close all sockets of the pid */
-               if( pid == cur_socket->pid ) {
+               if (pid == cur_socket->pid) {
                        emipc_close_email_socket(&cur_socket->socket_fd);
                        EM_SAFE_FREE(cur_socket);
                        GList *del = cur;
@@ -178,9 +178,9 @@ EXPORT_API int emipc_get_proxy_socket_id()
        ENTER_CRITICAL_SECTION(proxy_mutex);
        GList *cur = socket_head;
        /* need to acquire lock */
-       for( ; cur ; cur = g_list_next(cur) ) {
-               thread_socket_t* cur_socket = g_list_nth_data(cur,0);
-               if( pthread_equal(tid, cur_socket->tid) ) {
+       for ( ; cur ; cur = g_list_next(cur)) {
+               thread_socket_t* cur_socket = g_list_nth_data(cur, 0);
+               if (pthread_equal(tid, cur_socket->tid)) {
                        socket_fd = cur_socket->socket_fd;
                        break;
                }
@@ -196,7 +196,7 @@ EXPORT_API int emipc_get_proxy_socket_id()
 
 #define MAX_PROXY_EPOLL_EVENT 100
 
-static bool wait_for_reply (int fd)
+static bool wait_for_reply(int fd)
 {
        if (fd < 0) {
                EM_DEBUG_EXCEPTION("Invalid file description : [%d]", fd);
@@ -213,13 +213,12 @@ static bool wait_for_reply (int fd)
        tv.tv_sec  = 20; /* should be tuned */
        tv.tv_usec = 0;
 
-       EM_DEBUG_LOG_DEV ("wait for response [%d]", fd);
+       EM_DEBUG_LOG_DEV("wait for response [%d]", fd);
        err = select(fd + 1, &fds, NULL, NULL, &tv);
        if (err == -1) {
                EM_DEBUG_EXCEPTION("[IPCLib] select error[%d] fd[%d]", errno, fd);
                return false;
-       }
-       else if (err == 0) {
+       } else if (err == 0) {
                EM_DEBUG_EXCEPTION("[IPCLib] select timeout fd[%d]", fd);
                return false;
        }
@@ -263,7 +262,7 @@ static bool wait_for_reply (int fd)
                        if (proxy_ev_events[i].events & EPOLLIN) {
                                EM_DEBUG_LOG("Received event to stub");
                                ret = true;
-                       } 
+                       }
                }
        }
 
index dd24d3b..085e4c8 100755 (executable)
@@ -63,7 +63,7 @@ EXPORT_API bool emipc_init_email_socket(int *fd)
 EXPORT_API void emipc_close_email_socket(int* fd)
 {
        EM_DEBUG_LOG("fd %d removal done", *fd);
-       EM_SAFE_CLOSE (*fd);
+       EM_SAFE_CLOSE(*fd);
 }
 
 /* returns positive write length,
@@ -77,7 +77,7 @@ static int emipc_writen(int fd, const char *buf, int len)
        while (length > 0) {
                passed_len = send(fd, (const void *)buf, length, MSG_NOSIGNAL);
                if (passed_len == -1) {
-                       EM_DEBUG_EXCEPTION ("send error [%d]", errno);
+                       EM_DEBUG_EXCEPTION("send error [%d]", errno);
                        if (errno == EINTR) continue;
                        else if (errno == EPIPE) return 0; /* connection closed */
                        else return passed_len; /* -1 */
@@ -106,7 +106,7 @@ EXPORT_API int emipc_send_email_socket(int fd, unsigned char *buf, int len)
 
        int write_len = emipc_writen(fd, (char*) buf, len);
        if (write_len == 0) /* connection closed */
-               return 0; 
+               return 0;
        if (write_len != len) {
                EM_DEBUG_LOG("WARNING: buf_size [%d] != write_len[%d]", len, write_len);
                return EMAIL_ERROR_IPC_SOCKET_FAILURE;
@@ -153,7 +153,7 @@ EXPORT_API int emipc_recv_email_socket(int fd, char **buf)
        int read_len = 0;
        /* read the size of message. note that ioctl is non-blocking */
        if (ioctl(fd, FIONREAD, &read_len)) {
-               EM_DEBUG_EXCEPTION ("ioctl failed: %s", EM_STRERROR(errno_buf));
+               EM_DEBUG_EXCEPTION("ioctl failed: %s", EM_STRERROR(errno_buf));
                return EMAIL_ERROR_IPC_SOCKET_FAILURE;
        }
        /* when server or client closed socket */
@@ -172,7 +172,7 @@ EXPORT_API int emipc_recv_email_socket(int fd, char **buf)
        EM_DEBUG_LOG_DEV("[IPC Socket] Receiving [%d] bytes", read_len);
        int len = emipc_readn(fd, *buf, read_len);
        if (len == 0) /* connection closed */
-               return 0; 
+               return 0;
        if (read_len != len) {
                EM_SAFE_FREE(*buf);
                EM_DEBUG_LOG("WARNING: buf_size [%d] != read_len[%d]", read_len, len);
@@ -190,7 +190,7 @@ EXPORT_API int emipc_accept_email_socket(int fd)
        char errno_buf[ERRNO_BUF_SIZE] = {0};
 
        if (fd == -1) {
-               EM_DEBUG_EXCEPTION ("Server_socket is not yet initialized");
+               EM_DEBUG_EXCEPTION("Server_socket is not yet initialized");
                return EMAIL_ERROR_INVALID_PARAM;
        }
 
@@ -198,7 +198,7 @@ EXPORT_API int emipc_accept_email_socket(int fd)
        int remote_len = sizeof(remote);
        int client_fd = accept(fd, (struct sockaddr *)&remote, (socklen_t*) &remote_len);
        if (client_fd == -1) {
-               EM_DEBUG_EXCEPTION ("accept failed [%s][%d]", EM_STRERROR(errno_buf), errno);
+               EM_DEBUG_EXCEPTION("accept failed [%s][%d]", EM_STRERROR(errno_buf), errno);
                return EMAIL_ERROR_IPC_SOCKET_FAILURE;
        }
 
@@ -222,7 +222,7 @@ EXPORT_API int emipc_open_email_socket(int fd, const char *path)
        if (strcmp(path, ipc_socket_path) == 0 &&
                sd_listen_fds(1) == 1 &&
                sd_is_socket_unix(SD_LISTEN_FDS_START, SOCK_SEQPACKET, -1, ipc_socket_path, 0) > 0) {
-               EM_SAFE_CLOSE (fd);
+               EM_SAFE_CLOSE(fd);
                sock_fd = SD_LISTEN_FDS_START + 0;
                EM_SAFE_FREE(ipc_socket_path);
                return sock_fd;
@@ -231,12 +231,12 @@ EXPORT_API int emipc_open_email_socket(int fd, const char *path)
        EM_SAFE_FREE(ipc_socket_path);
 
        if (!path || EM_SAFE_STRLEN(path) > 108) {
-               EM_DEBUG_EXCEPTION ("Path is null");
+               EM_DEBUG_EXCEPTION("Path is null");
                return EMAIL_ERROR_IPC_SOCKET_FAILURE;
        }
 
        if (fd <= 0) {
-               EM_DEBUG_EXCEPTION ("Socket not created %d", fd);
+               EM_DEBUG_EXCEPTION("Socket not created %d", fd);
                return EMAIL_ERROR_IPC_SOCKET_FAILURE;
        }
 
@@ -297,18 +297,18 @@ EXPORT_API int emipc_connect_email_socket(int fd)
        memset(&server, 0, sizeof(server));
        server.sun_family = AF_UNIX;
        strcpy(server.sun_path, ipc_socket_path);
-       
+
        EM_SAFE_FREE(ipc_socket_path);
 
        if (connect(fd, (struct sockaddr *)&server, sizeof(server)) < 0) {
-               EM_DEBUG_EXCEPTION ("connect failed: [%s][errno=%d][fd=%d]", EM_STRERROR(errno_buf), errno, fd);
+               EM_DEBUG_EXCEPTION("connect failed: [%s][errno=%d][fd=%d]", EM_STRERROR(errno_buf), errno, fd);
 
                p_errno = errno;
-               if (p_errno == EACCES || p_errno == EPERM) 
+               if (p_errno == EACCES || p_errno == EPERM)
                        err = EMAIL_ERROR_PERMISSION_DENIED;
-               else 
+               else
                        err = EMAIL_ERROR_SYSTEM_FAILURE;
-               
+
                return err;
        }
 
index 64e62ff..1a9f727 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -64,10 +64,10 @@ EXPORT_API bool emipc_finalize_stub_main()
                emipc_end_stub_socket();
                stub_socket = false;
        }
-       
+
        if (this_fn_api_mapper)
                this_fn_api_mapper = NULL;
-               
+
        EM_DEBUG_FUNC_END();
        return true;
 }
@@ -79,7 +79,7 @@ EXPORT_API bool emipc_execute_api_proxy_to_stub(emipc_email_api_info *api_info)
                EM_DEBUG_EXCEPTION("Invalid Param");
                return false;
        }
-       
+
        if (this_fn_api_mapper) {
                this_fn_api_mapper(api_info);
        }
@@ -92,20 +92,20 @@ EXPORT_API bool emipc_execute_api_stub_to_proxy(emipc_email_api_info *api_info)
 {
        EM_DEBUG_FUNC_BEGIN("api_info [%p]", api_info);
        EM_IF_NULL_RETURN_VALUE(api_info, false);
-       EM_DEBUG_LOG_SEC ("Response: API_ID [%s][0x%x], RES_ID [%d], APP_ID [%d]",\
-                                            EM_APIID_TO_STR(api_info->api_id), 
-                                            api_info->api_id, 
-                                            api_info->response_id, 
+       EM_DEBUG_LOG_SEC("Response: API_ID [%s][0x%x], RES_ID [%d], APP_ID [%d]",\
+                                            EM_APIID_TO_STR(api_info->api_id),
+                                            api_info->api_id,
+                                            api_info->response_id,
                                             api_info->app_id);
-       
+
        unsigned char *stream = NULL;
        int stream_length = 0;
-       
+
        stream = emipc_serialize_api_info(api_info, ePARAMETER_OUT, &stream_length);
        EM_DEBUG_LOG("Stub => Proxy Sending %dB", stream_length);
 
        emipc_send_stub_socket(api_info->response_id, stream, stream_length);
-       
+
 #ifdef IPCLIB_STREAM_TRACE_ON
        int index = 0;
        for (index = 0; index < stream_length; index++)
index cae9d30..484f696 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -79,7 +79,7 @@ EXPORT_API bool emipc_start_stub_socket_thread()
        EM_DEBUG_LOG("[IPCLib] emipc_email_stub_socket_thread start");
        if (stub_socket_thread)
                return true;
-               
+
        pthread_attr_t thread_attr;
        pthread_attr_init(&thread_attr);
        pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
@@ -124,7 +124,7 @@ EXPORT_API void emipc_wait_for_ipc_request()
        EM_DEBUG_LOG("ipc_socket_path : [%s]", ipc_socket_path);
 
        emipc_open_email_socket(stub_socket, ipc_socket_path);
-       
+
        EM_SAFE_FREE(ipc_socket_path);
 
        epfd = epoll_create(MAX_EPOLL_EVENT);
@@ -136,35 +136,34 @@ EXPORT_API void emipc_wait_for_ipc_request()
 
        ev.events = EPOLLIN;
        ev.data.fd = stub_socket;
-       
+
        if (epoll_ctl(epfd, EPOLL_CTL_ADD, stub_socket, &ev) == -1) {
                EM_DEBUG_EXCEPTION("epoll_ctl error [%d]", errno);
-               EM_DEBUG_CRITICAL_EXCEPTION("epoll_ctl error [%d]", errno);     
+               EM_DEBUG_CRITICAL_EXCEPTION("epoll_ctl error [%d]", errno);
        }
        while (!stop_thread) {
                int i = 0;
 
                event_num = epoll_wait(epfd, events, MAX_EPOLL_EVENT, -1);
-               
+
                if (stop_thread) {
-                       EM_DEBUG_LOG ("IPC hanlder thread is going to be shut down");
+                       EM_DEBUG_LOG("IPC hanlder thread is going to be shut down");
                        break;
                }
 
                if (event_num == -1) {
-                       if (errno != EINTR ) {
+                       if (errno != EINTR) {
                                EM_DEBUG_EXCEPTION("epoll_wait error [%d]", errno);
                                EM_DEBUG_CRITICAL_EXCEPTION("epoll_wait error [%d]", errno);
                        }
-               }
-               else {
+               } else {
                        for (i = 0; i < event_num; i++) {
                                int event_fd = events[i].data.fd;
 
                                if (event_fd == stub_socket) { /*  if it is socket connection request */
-                                       int cfd = emipc_accept_email_socket (stub_socket);
+                                       int cfd = emipc_accept_email_socket(stub_socket);
                                        if (cfd < 0) {
-                                               EM_DEBUG_EXCEPTION ("emipc_accept_email_socket error [%d]", cfd);
+                                               EM_DEBUG_EXCEPTION("emipc_accept_email_socket error [%d]", cfd);
                                                /* EM_DEBUG_CRITICAL_EXCEPTION ("accept failed: %s[%d]", EM_STRERROR(errno_buf), errno);*/
                                                continue;
                                        }
@@ -175,14 +174,13 @@ EXPORT_API void emipc_wait_for_ipc_request()
                                                /*EM_DEBUG_CRITICAL_EXCEPTION("epoll_ctl failed:%s[%d]", EM_STRERROR(errno_buf), errno);*/
                                                continue;
                                        }
-                               } 
-                               else {
+                               } else {
                                        int recv_len;
                                        char *sz_buf = NULL;
-                                       
+
                                        recv_len = emipc_recv_email_socket(event_fd, &sz_buf);
-                                       
-                                       if(recv_len > 0) {
+
+                                       if (recv_len > 0) {
                                                EM_DEBUG_LOG("[IPCLib]Stub Socket Recv [Socket ID = %d], [recv_len = %d]", event_fd, recv_len);
 
                                                /* IPC request stream is at least 16byte */
@@ -194,52 +192,49 @@ EXPORT_API void emipc_wait_for_ipc_request()
                                                                        EM_DEBUG_EXCEPTION("epoll_ctl error [%d]", errno);
                                                                        EM_DEBUG_CRITICAL_EXCEPTION("epoll_ctl error [%d]", errno);
                                                                }
-                                                               EM_SAFE_CLOSE (event_fd);
+                                                               EM_SAFE_CLOSE(event_fd);
                                                        }
-                                               } 
-                                               else
+                                               } else
                                                        EM_DEBUG_LOG("[IPCLib] Stream size is less than default size");
-                                       } 
-                                       else if( recv_len == 0 ) { /* client shut down connection */
+                                       } else if (recv_len == 0) { /* client shut down connection */
                                                EM_DEBUG_LOG("[IPCLib] Client closed connection [%d]", event_fd);
                                                if (epoll_ctl(epfd, EPOLL_CTL_DEL, event_fd, events) == -1) {
                                                        EM_DEBUG_EXCEPTION("epoll_ctl error [%d]", errno);
                                                        EM_DEBUG_CRITICAL_EXCEPTION("epoll_ctl error [%d]", errno);
                                                }
-                                               emipc_close_fd_in_task_queue (event_fd);
-                                               EM_SAFE_CLOSE (event_fd);
-                                       } 
-                                       else { /* read errs */
-                                               EM_DEBUG_EXCEPTION ("[IPCLib] read err[%d] fd[%d]", recv_len, event_fd);
+                                               emipc_close_fd_in_task_queue(event_fd);
+                                               EM_SAFE_CLOSE(event_fd);
+                                       } else { /* read errs */
+                                               EM_DEBUG_EXCEPTION("[IPCLib] read err[%d] fd[%d]", recv_len, event_fd);
                                                if (epoll_ctl(epfd, EPOLL_CTL_DEL, event_fd, events) == -1) {
                                                        EM_DEBUG_EXCEPTION("epoll_ctl error [%d]", errno);
                                                        EM_DEBUG_CRITICAL_EXCEPTION("epoll_ctl error [%d]", errno);
                                                }
-                                               emipc_close_fd_in_task_queue (event_fd);
-                                               EM_SAFE_CLOSE (event_fd);
+                                               emipc_close_fd_in_task_queue(event_fd);
+                                               EM_SAFE_CLOSE(event_fd);
                                        }
                                        EM_SAFE_FREE(sz_buf);
                                }
                        }
                }
-       }       
-       emipc_end_all_proxy_sockets ();
+       }
+       emipc_end_all_proxy_sockets();
        emipc_close_email_socket(&stub_socket);
-       EM_DEBUG_LOG ("IPC hanlder thread is shut down");
+       EM_DEBUG_LOG("IPC hanlder thread is shut down");
 }
 
 EXPORT_API bool emipc_end_stub_socket()
 {
-       EM_DEBUG_FUNC_BEGIN ();
-       
+       EM_DEBUG_FUNC_BEGIN();
+
        /* stop IPC handler thread */
        emipc_stop_stub_socket_thread();
        stub_socket_thread = 0;
 
        /* stop task thread */
-       emipc_stop_task_thread ();
+       emipc_stop_task_thread();
 
-       EM_DEBUG_FUNC_END ();           
+       EM_DEBUG_FUNC_END();
        return true;
 }
 
@@ -253,7 +248,7 @@ EXPORT_API int emipc_send_stub_socket(int sock_fd, void *data, int len)
        }
 
        if (sending_bytes <= 0) {
-               EM_DEBUG_EXCEPTION ("emipc_send_email_socket error [%d] fd [%d]", sending_bytes, sock_fd);
+               EM_DEBUG_EXCEPTION("emipc_send_email_socket error [%d] fd [%d]", sending_bytes, sock_fd);
        }
 
        EM_DEBUG_FUNC_END("sending_bytes = %d", sending_bytes);
index 9acb3ce..f55fa60 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -53,7 +53,7 @@ EXPORT_API bool emipc_start_task_thread()
 
        if (pthread_create(&task_thread, NULL, &emipc_do_task_thread, NULL) != 0) {
                EM_DEBUG_EXCEPTION("Worker thread creation failed: [%d]", errno);
-               return false;   
+               return false;
        }
 
        return true;
@@ -81,7 +81,7 @@ EXPORT_API bool emipc_stop_task_thread()
 EXPORT_API void *emipc_do_task_thread()
 {
        EM_DEBUG_FUNC_BEGIN();
-       
+
        emipc_email_task *task = NULL;
 
        while (!stop_flag) {
@@ -90,9 +90,9 @@ EXPORT_API void *emipc_do_task_thread()
 /*                     EM_DEBUG_LOG("Blocked until new task arrives %p.", &ipc_task_cond); */
                        SLEEP_CONDITION_VARIABLE(ipc_task_cond, ipc_task_mutex);
                }
-               
+
                if (stop_flag) {
-                       EM_DEBUG_LOG ("task thread is going to be shut down");
+                       EM_DEBUG_LOG("task thread is going to be shut down");
                        break;
                }
 
@@ -103,15 +103,15 @@ EXPORT_API void *emipc_do_task_thread()
                        emipc_run_task(task);
 
                        ENTER_CRITICAL_SECTION(ipc_task_mutex);
-                       task = (emipc_email_task *)g_queue_pop_head(task_queue); 
+                       task = (emipc_email_task *)g_queue_pop_head(task_queue);
                        LEAVE_CRITICAL_SECTION(ipc_task_mutex);
 
                        emipc_free_email_task(task);
                        EM_SAFE_FREE(task);
                }
        }
-       
-       return NULL;                    
+
+       return NULL;
 }
 
 /* code for ipc handler */
@@ -131,14 +131,14 @@ EXPORT_API int emipc_create_task(unsigned char *task_stream, int response_channe
                        EM_SAFE_FREE(task);
                        return err;
                }
-               
-               EM_DEBUG_LOG_DEV ("[IPCLib] ======================================================");
-               EM_DEBUG_LOG_SEC ("[IPCLib] Register new task: API_ID[%s][0x%x] RES_ID[%d] APP_ID[%d]", 
+
+               EM_DEBUG_LOG_DEV("[IPCLib] ======================================================");
+               EM_DEBUG_LOG_SEC("[IPCLib] Register new task: API_ID[%s][0x%x] RES_ID[%d] APP_ID[%d]",
                                            EM_APIID_TO_STR(task->api_info->api_id),
                                            task->api_info->api_id,
                                            task->api_info->response_id,
                                            task->api_info->app_id);
-               EM_DEBUG_LOG_DEV ("[IPCLib] ======================================================");
+               EM_DEBUG_LOG_DEV("[IPCLib] ======================================================");
 
         struct ucred uc;
         socklen_t uc_len = sizeof(uc);
@@ -157,7 +157,7 @@ EXPORT_API int emipc_create_task(unsigned char *task_stream, int response_channe
 
                ENTER_CRITICAL_SECTION(ipc_task_mutex);
                g_queue_push_tail(task_queue, (void *)task);
-               
+
                WAKE_CONDITION_VARIABLE(ipc_task_cond);
                LEAVE_CRITICAL_SECTION(ipc_task_mutex);
        }
@@ -165,12 +165,12 @@ EXPORT_API int emipc_create_task(unsigned char *task_stream, int response_channe
 }
 
 
-EXPORT_API void emipc_close_fd_in_task_queue (int fd)
+EXPORT_API void emipc_close_fd_in_task_queue(int fd)
 {
        emipc_email_task *task = NULL;
        int i = 0;
        ENTER_CRITICAL_SECTION(ipc_task_mutex);
-       while ( (task = g_queue_peek_nth (task_queue, i++)) ) {
+       while ((task = g_queue_peek_nth(task_queue, i++))) {
                if (task->api_info->response_id == fd) {
                        task->api_info->response_id = -1;
                }
index 6c5d0a0..36065c5 100755 (executable)
@@ -4,7 +4,7 @@
 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
-* 
+*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -35,7 +35,7 @@
 EXPORT_API void emipc_free_email_task(emipc_email_task *task)
 {
        EM_DEBUG_FUNC_BEGIN("task [%p]", task);
-       
+
        if (!task) {
                EM_DEBUG_EXCEPTION("Invalid parameter.");
                return;
@@ -55,7 +55,7 @@ EXPORT_API bool emipc_parse_stream_email_task(emipc_email_task *task, void *stre
                return false;
        }
        memset(task->api_info, 0x00, sizeof(emipc_email_api_info));
-       
+
        if (task->api_info) {
                if (!emipc_deserialize_api_info(task->api_info, ePARAMETER_IN, stream)) {
                        EM_DEBUG_EXCEPTION("emipc_deserialize_api_info failed");
@@ -83,14 +83,14 @@ EXPORT_API bool emipc_run_task(emipc_email_task *task)
        int app_id = task->api_info->app_id;
        int res_id = task->api_info->response_id;
 
-       EM_DEBUG_LOG_SEC("[IPCLib] Processing task: API_ID[%s][0x%x] RES_ID[%d] APP_ID[%d] ", 
-                                   EM_APIID_TO_STR (api_id), api_id, res_id, app_id);
+       EM_DEBUG_LOG_SEC("[IPCLib] Processing task: API_ID[%s][0x%x] RES_ID[%d] APP_ID[%d] ",
+                                   EM_APIID_TO_STR(api_id), api_id, res_id, app_id);
 
        if (!emipc_execute_api_proxy_to_stub(task->api_info)) {
                EM_DEBUG_EXCEPTION("emipc_execute_api_proxy_to_stub failed");
                return false;
        }
-       
+
        return true;
 }