/* 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;
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;
}
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);
}
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;
}
FINISH_OFF:
- EM_DEBUG_FUNC_END ("err[%d]", err);
+ EM_DEBUG_FUNC_END("err[%d]", err);
return err;
}
/* 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;
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;
}
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;
}
/* 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);
}
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;
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);
}
/* 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);
emipc_destroy_email_api(hAPI);
hAPI = NULL;
- EM_DEBUG_API_END ("err[%d]", err);
+ EM_DEBUG_API_END("err[%d]", err);
return err;
}
/* 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;
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;
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;
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); /* 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;
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 */
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;
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;
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;
}
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 */
}
FINISH_OFF:
-
+
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_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;
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;
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;
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);
}
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) {
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);
}
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;
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_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;
}
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_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);
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;
}
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;
}
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) {
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;
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);
}
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;
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);
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);
emcore_gmime_shutdown();
- EM_DEBUG_API_END ("ret[%d]", err);
+ EM_DEBUG_API_END("ret[%d]", err);
return err;
}
* 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"
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) {
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) {
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;
}
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;
}
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) {
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;
}
* 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-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;
}
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;
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;
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;
/* 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;
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 {
}
} 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;
}
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);
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);
}
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);
hAPI = NULL;
- EM_DEBUG_API_END ("err[%d]", err);
+ EM_DEBUG_API_END("err[%d]", err);
return err;
}
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;
}
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);
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;
}
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)) {
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;
}
/* 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;
}
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;
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;
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;
}
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);
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);
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_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;
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;
}
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;
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;
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;
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);
- if( account_id < ALL_ACCOUNT) {
+ if (account_id < ALL_ACCOUNT) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM ;
goto FINISH_OFF;
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);
- if( account_id < ALL_ACCOUNT) {
+ if (account_id < ALL_ACCOUNT) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
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);
- if( account_id < ALL_ACCOUNT) {
+ if (account_id < ALL_ACCOUNT) {
EM_DEBUG_EXCEPTION("Invalid account id param");
err = EMAIL_ERROR_INVALID_PARAM ;
return 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_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) {
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) {
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;
*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;
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;
}
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;
}
-----------------------------------------------------------*/
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;
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;
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;
}
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;
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;
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;
}
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;
}
/* 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;
email_address_info_list_t *temp_address_info_list = NULL;
EM_IF_NULL_RETURN_VALUE(address_info_list, EMAIL_ERROR_INVALID_PARAM);
- if( mail_id <= 0) {
+ if (mail_id <= 0) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
err = EMAIL_ERROR_INVALID_PARAM ;
return err;
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;
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;
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) {
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) {
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;
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;
}
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;
}
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;
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;
}
* 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"
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;
}
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;
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);
}
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);
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;
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);
}
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;
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))) {
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);
}
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_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) {
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);
}
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;
}
/* 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;
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;
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);
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);
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;
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);
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;
}
em_convert_mailbox_tbl_to_mailbox(mailbox_tbl_list + i, (*mailbox_list) + i);
} else
*mailbox_list = NULL;
-
+
*count = mailbox_count;
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;
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:
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;
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;
}
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) {
em_convert_mailbox_tbl_to_mailbox(local_mailbox, curr_mailbox);
}
- *mailbox = curr_mailbox;
+ *mailbox = curr_mailbox;
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;
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;
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) {
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;
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) {
*mailbox_list = NULL;
FINISH_OFF:
- EM_DEBUG_FUNC_END ("err[%d]", err);
+ EM_DEBUG_FUNC_END("err[%d]", err);
return err;
}
* 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"
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;
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;
}
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);
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);
}
}
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;
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;
}
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;
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;
}
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;
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;
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;
}
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;
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;
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:
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;
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;
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;
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:
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;
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;
}
}
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;
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);
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);
}
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_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;
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;
}
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;
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);
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;
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) {
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)) {
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;
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;
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;
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);
}
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;
}
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;
}
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;
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;
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;
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;
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);
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;
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;
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;
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;
}
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;
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;
}
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;
}
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;
}
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);
}
}
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;
}
* 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-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"
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;
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);
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) {
}
/* 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;
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;
}
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;
}
* 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
* 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;
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;
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");
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");
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 {
}
- EM_DEBUG_API_END ("err[%d]", err);
+ EM_DEBUG_API_END("err[%d]", err);
return err;
}
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)) {
*/
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);
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;
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);
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;
FINISH_OFF:
EM_SAFE_FREE(multi_user_name);
- EM_DEBUG_API_END ("err[%d]", err);
+ EM_DEBUG_API_END("err[%d]", err);
return err;
}
* 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.
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*/
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*/
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;
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;
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();
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;
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*/
ret = true;
FINISH_OFF:
- if(error)
+ if (error)
*error = err_code;
EM_DEBUG_FUNC_END();
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);
/* 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;
}
/*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);
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;
}
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" */
/* 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;
}
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;
}
/* 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);
*/
#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();
/* 64bit */
strncat(converted_fmt, "I", 1);
} else {
- EM_DEBUG_LOG("size : [%d]", size);
+ EM_DEBUG_LOG("size: [%d]", size);
}
break;
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;
}
tn = tpl_map(converted_fmt, mail_data, &tb);
- if(!tn) {
+ if (!tn) {
EM_SAFE_FREE(converted_fmt);
EM_DEBUG_EXCEPTION("tpl_map failed");
return;
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();
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);
}
/* 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);
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);
size_t len = 0;
tpl_dump(tn, TPL_MEM, &buf, &len);
- if(tn)
+ if (tn)
tpl_free(tn);
*stream_len = len;
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);
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) {
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) {
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);
result_stream = append_sized_data_to_stream(result_stream, &stream_size, (char*)&(input_search_filter_count), sizeof(int));
- for( i = 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;
}
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);
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;
- for( i = 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;
}
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);
}
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);
- while( tpl_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;
}
{
/* 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;
}
{
/* 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;
/* 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;
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]);
}
}
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) {
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);
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;
}
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);
}
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--;
}
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;
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++;
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 ")"
#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)
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;
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);
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};
/* 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;
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;
}
}
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;
}
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;
content = rfc822_base64(text, size, dec_len);
if (content)
*dec_text = (char *)content;
- else
- {
+ else {
err = EMAIL_ERROR_UNKNOWN;
ret = false;
}
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;
}
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;
EM_DEBUG_LOG(">>>>>> return next handle[%d]", *handle);
FINISH_OFF:
- if ( error != NULL ) {
+ if (error != NULL) {
*error = err;
}
{
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 {
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 */
email_thread_handle_t *thd_handle = warg->thd_handle;
if (!thd_handle) {
- EM_DEBUG_EXCEPTION ("PARAMETER NULL");
+ EM_DEBUG_EXCEPTION("PARAMETER NULL");
return NULL;
}
(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;
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;
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)
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) {
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)
/*
-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
#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 */
#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' */
#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 */
#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; \
(head)->prev = (add); \
(add)->next = NULL; \
} else { \
- (head)=(add); \
+ (head) = (add); \
(head)->prev = (head); \
(head)->next = NULL; \
} \
/* 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;
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);
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);
};
/* 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);
}
-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;
}
* 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;
/* 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;
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':
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);
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;
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 */
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);
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));
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);
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':
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();
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 ')':
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:
((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;
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);
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:
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));
}
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;
}
}
}
((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);
}
}
tpl_hook.free(c->data);
- find_next_node=1;
+ find_next_node = 1;
break;
case TPL_TYPE_INT32:
case TPL_TYPE_UINT32:
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");
}
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;
}
}
}
}
/* 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);
}
/* 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) {
}
/* 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;
}
* 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;
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:
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:
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;
}
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:
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;
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);
}
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);
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");
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) {
}
} 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;
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;
* 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;
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;
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;
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);
}
/* 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);
return 0;
}
-static int tpl_cpu_bigendian() {
+static int tpl_cpu_bigendian()
+{
unsigned i = 1;
char *c;
c = (char*)&i;
* 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;
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.
((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));
/* 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));
}
/* 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;
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);
}
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;
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;
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;
}
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));
/* 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++;
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++;
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;
/* 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) {
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 */
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 {
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);
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) {
} 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 {
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 {
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;
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;
while (bb) {
bbnxt = bb->next;
dv = bb->data;
- c=n->children;
+ c = n->children;
while (c) {
switch (c->type) {
case TPL_TYPE_BYTE:
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*));
}
}
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;
/* 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 +
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));
} 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:
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;
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;
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;
}
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;
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;
}
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;
}
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;
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;
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;
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:
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));
/* 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;
}
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];
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;
}
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;
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;
/* 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);
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;
/* 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--;
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);
}
}
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)
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:
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 */
/* 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));
}
/* 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:
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:
}
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));
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);
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);
* 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) {
}
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;
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;
/* 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 */
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);
*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) {
}
/* 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 */
}
/* 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;
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);
*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) {
}
/* 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 */
#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,
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,
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,
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) {
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;
}
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;
}
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);
}
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...");
/* 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,
/* 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,
#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 */
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;
}
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);
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;
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;
}
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;
}
/* 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;
}
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)
/* del the segment */
if (shmid != -1) {
- shmctl (shmid, IPC_RMID, NULL);
+ shmctl(shmid, IPC_RMID, NULL);
}
EM_DEBUG_FUNC_END();
/* 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;
}
}
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);
}
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);
}
}
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");
}
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);
{
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;
}
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;
}
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;
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");
ret_code = true;
FINISH_OFF:
- EM_SAFE_CLOSE (fd);
+ EM_SAFE_CLOSE(fd);
EM_SAFE_FREE(target_buffer);
if (account_list)
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;
}
}
- if(account_list) {
+ if (account_list) {
emcore_free_account_list(&account_list, account_count, NULL);
account_list = NULL;
}
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;
}
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;
}
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;
}
*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:
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;
}
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;
}
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);
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;
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;
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;
pos = strstr(result_string, "\"access_token\" : \"");
- if(!pos) {
+ if (!pos) {
err = EMAIL_ERROR_XOAUTH_BAD_REQUEST;
goto FINISH_OFF;
}
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;
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;
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;
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;
}
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;
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;
}
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);
}
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;
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;
}
LEAVE_CRITICAL_SECTION(alarm_data_lock);
- if(index)
+ if (index)
*output_alarm_data = alarm_data;
else
err = EMAIL_ERROR_ALARM_DATA_NOT_FOUND;
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;
}
}
LEAVE_CRITICAL_SECTION(alarm_data_lock);
- if(!index)
+ if (!index)
err = EMAIL_ERROR_ALARM_DATA_NOT_FOUND;
EM_DEBUG_FUNC_END("err [%d]", err);
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;
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);
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);
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:
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;
}
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;
}
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);
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;
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);
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++) {
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);
}
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;
}
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) {
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)) {
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;
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;
}
/*-----------------------------------------------------------------------------
* Unused
*---------------------------------------------------------------------------*/
-typedef struct EVENT_CALLBACK_ELEM
-{
+typedef struct EVENT_CALLBACK_ELEM {
email_event_callback callback;
void *event_data;
struct EVENT_CALLBACK_ELEM *next;
EM_DEBUG_FUNC_BEGIN();
int account_id, mail_id;
- if(!event_data) {
+ if (!event_data) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return;
}
ret = true;
-EXIT :
+EXIT:
+
LEAVE_RECURSIVE_CRITICAL_SECTION(_event_callback_table_lock);
EM_DEBUG_FUNC_END();
return ret;
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;
{
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
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) {
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;
}
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;
}
}
-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");
new_event = em_malloc(sizeof(email_event_t));
if (new_event == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed");
+ EM_DEBUG_EXCEPTION("em_mallocfailed");
return;
}
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;
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:
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:
} 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;
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:
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);
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:
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:
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;
}
}
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);
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:
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:
if (g_event_que)
q_length = g_queue_get_length(g_event_que);
- }
- else {
+ } else {
found_elm->status = EMAIL_EVENT_STATUS_CANCELED;
}
}
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;
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;
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;
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;
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:
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);
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();
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");
}
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)) {
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;
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();
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;
}
}
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 */
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;
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);
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;
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;
}
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;
/* 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;
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);
}
}
/*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 {
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.");
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;
}
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;
goto FINISH_OFF; /* Stop Local Activity Sync */
}
}
- stream = mail_close (stream);
+ stream = mail_close(stream);
}
}
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");
EM_SAFE_FREE(mailbox_list);
EM_SAFE_FREE(account_list);
- stream = mail_close (stream);
+ stream = mail_close(stream);
if (error_code)
*error_code = error;
* 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
* File : email-core-global.c
* Desc : Mail Engine Global
*
- * Auth : Kyuho Jo
+ * Auth : Kyuho Jo
*
- * History :
+ * History :
* 2010.08.25 : created
*****************************************************************************/
#include <stdio.h>
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)
{
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;
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;
}
}
LEAVE_CRITICAL_SECTION(_unvalidated_account_lock);
- if(*oupput_account == NULL)
+ if (*oupput_account == NULL)
err = EMAIL_ERROR_DATA_NOT_FOUND;
FINISH_OFF:
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;
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;
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);
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;
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);
EM_SAFE_FREE(fulltext);
- if (message) g_object_unref (message);
+ if (message) g_object_unref(message);
EM_DEBUG_FUNC_END();
return true;
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;
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;
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
}
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);
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;
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;
}
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);
} else {
cnt_info->inline_file = file;
}
- }
- else
+ } else
temp_file->next = file;
}
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
}
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);
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;
}
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;
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;
}
/* 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;
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);
} else {
cnt_info->inline_file = file;
}
- }
- else
+ } else
temp_file->next = file;
}
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
}
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);
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;
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
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) = '_';
}
}
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);
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)
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
}
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);
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
}
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);
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;
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) {
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
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) = '_';
}
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);
}
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);
file = em_malloc(sizeof(struct attachment_info));
if (file == NULL) {
- EM_DEBUG_EXCEPTION("em_malloc failed...");
+ EM_DEBUG_EXCEPTION("em_mallocfailed...");
goto FINISH_OFF;
}
}
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);
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;
EM_SAFE_FREE(cnt_info->sections);
cnt_info->sections = tmp_str;
}
- }
- else {
+ } else {
cnt_info->sections = EM_SAFE_STRDUP(sections);
}
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) {
EM_SAFE_FREE(cnt_info->sections);
cnt_info->sections = tmp_str;
}
- }
- else {
+ } else {
cnt_info->sections = EM_SAFE_STRDUP(sections);
}
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)
return;
}
- subspec = g_alloca (strlen(spec) + 14);
+ subspec = g_alloca(strlen(spec) + 14);
id = g_stpcpy(subspec, spec);
*id++ = '.';
/* 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;
}
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);
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;
/* 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);
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);
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;
}
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)
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;
/* 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);
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);
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;
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);
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 {
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;
}
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;
}
}
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;
}
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) {
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;
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;
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);
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 {
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;
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 >>>>");
}
}
}
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;
}
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;
}
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.");
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);
}
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) {
}
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;
}
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;
EM_SAFE_FREE(response);
break;
}
- } while(1);
+ } while (1);
preline_len = EM_SAFE_STRLEN(new_response);
EM_DEBUG_LOG("preline_len : %d", preline_len);
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;
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...");
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);
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;
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));
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 >>>>");
}
}
}
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 */
goto FINISH_OFF;
}
break;
- }
- else if (!strcmp(response, ")")) {
+ } else if (!strcmp(response, ")")) {
/* The end of response which contains body information */
}
} /* while (imaplocal->netstream) */
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);
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;
}
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;
}
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);
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;
}
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 */
}
/* 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);
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;
// *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);
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);
}
}
}
}
- 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");
}
}
- 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");
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;
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) {
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;
}
}
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;
#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;
}
-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);
}
}
- 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;
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;
}
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;
*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;
}
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;
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);
}
}
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);
}
/* 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;
}
- 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);
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)) {
}
/* 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;
}
/* 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);
}
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++) {
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;
}
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;
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);
}
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;
*(++s) = '\0';
strcat(reference, mailbox_name);
}
- }
- else
+ } else
reference = EM_SAFE_STRDUP(stream->original_mailbox);
pattern = "*";
/* imap command : tag LIST reference * */
/* see callback function mm_list */
- mail_list (stream, reference, pattern);
+ mail_list(stream, reference, pattern);
stream->sparep = NULL;
/* 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;
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");
}
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) {
}
/* 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;
FINISH_OFF:
if (stream) {
- stream = mail_close (stream);
+ stream = mail_close(stream);
}
if (ref_account) {
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)
/* 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;
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");
}
}
if (stream) {
- stream = mail_close (stream);
+ stream = mail_close(stream);
}
EM_DEBUG_FUNC_END("err [%d]", err);
}
/* 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;
}
/* 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;
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);
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);
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:
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);
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();
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;
}
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
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;
}
char cmd[64];
char *p = NULL;
- if (!stream) {
+ if (!stream) {
EM_DEBUG_EXCEPTION("stream[%p]", stream);
err = EMAIL_ERROR_INVALID_PARAM;
goto FINISH_OFF;
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;
}
}
#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
/* 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;
}
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 ");
}
id_set_count = 0;
}
- }
- else {
+ } else {
EM_DEBUG_EXCEPTION(">>>> STREAM DATA IS NULL >>> ");
goto FINISH_OFF;
}
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);
#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;
/* 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;
/* 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 */
}
- while (imaplocal->netstream) {
+ while (imaplocal->netstream) {
/* receive response */
if (!(p = net_getline(imaplocal->netstream))) {
EM_DEBUG_EXCEPTION("net_getline failed...");
/* 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);
*/
- 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;
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...");
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;
}
mail[index]->mailbox_name,
mail[index]->server_mail_id,
true,
- &err)) {
+ &err)) {
EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
}
}
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;
}
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.
*/
#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;
}
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);
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);
}
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;
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;
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);
}
g_strfreev(tokens);
/* ';' -> ',' */
- while (p && p[i] != '\0')
- {
+ while (p && p[i] != '\0') {
if (p[i] == ';')
p[i] = ',';
i++;
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;
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);
/* 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);
}
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);
}
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;
}
/* 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);
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); */
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;
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);
}
}
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;
}
g_strfreev(tokens);
/* ';' -> ',' */
- while (p && p[i] != '\0') {
+ while (p && p[i] != '\0') {
if (p[i] == ';')
p[i] = ',';
i++;
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;
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) {
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" -> ',' */
g_strfreev(tokens);
alias = addr->personal;
- }
- else {
+ } else {
alias = NULL;
}
p_address_info->contact_id = -1;
*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;
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 {
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;
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;
}
{
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;
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;
{
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;
}
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;
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) {
}
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);
}
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);
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 >>>>");
}
}
(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);
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) {
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. */
}
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");
}
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) {
return false;
}
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
only_body_download = false;
/* 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);
}
- 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) {
/* 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;
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);
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;
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;
}
#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;
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);
}
EM_SAFE_FREE(savefile);
- if (stream) {
- stream = mail_close (stream);
+ if (stream) {
+ stream = mail_close(stream);
}
if (attachment_list)
}
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;
}
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);
}
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);
}
if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
/* open mail server. */
if (!mail_stream) {
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;
}
#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;
}
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;
}
}
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;
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) {
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);
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;
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)) {
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;
}
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 (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"));
}
}
/* 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,
}
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;
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;
}
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);
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;
}
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;
}
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);
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;
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);
}
}
if (cancellable)
- FINISH_OFF_IF_EVENT_CANCELED (err, event_handle);
+ FINISH_OFF_IF_EVENT_CANCELED(err, event_handle);
ret = TRUE;
#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
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;
/* 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;
}
}
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,
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],
}
#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],
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;
}
mail->server_mailbox_name,
mail->server_mail_id,
true,
- &err)) {
+ &err)) {
EM_DEBUG_LOG("emstorage_remove_downloaded_mail falied [%d]", err);
}
}
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)
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;
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,
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)
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;
}
/* 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;
}
}
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,
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);
}
#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);
}
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);
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;
}
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;
&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);
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) {
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;
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;
}
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;
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();
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;
}
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;
}
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);
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;
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;
}
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;
}
FINISH_OFF:
- if(filter_list)
+ if (filter_list)
emstorage_free_list_filter(&filter_list, filter_count);
EM_SAFE_FREE(result_mail_id_list);
{
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;
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;
}
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;
}
}
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;
}
/* 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;
}
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;
}
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;
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;
}
}
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;
}
/* 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;
}
{
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;
}
/* 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;
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;
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;
}
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);
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);
}
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;
}
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 */
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;
}
}
/* 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;
}
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;
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;
}
}
/* 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;
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;
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;
}
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;
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;
}
/* 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;
}
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;
}
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;
}
}
- 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;
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;
}
* 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_2, int *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);
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++) {
}
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);
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);
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;
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;
}
(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;
}
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);
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;
FINISH_OFF:
if (stream)
- stream = mail_close (stream);
+ stream = mail_close(stream);
if (ref_account) {
emcore_free_account(ref_account);
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);
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,
}
/* 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;
}
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;
}
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)
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;
}
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;
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. */
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;
}
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;
}
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;
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;
}
}
- 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;
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;
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,
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;
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;
}
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);
}
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,
}
}
- 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;
}
}
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;
}
}
FINISH_OFF:
+
if (err == EMAIL_ERROR_NONE) {
/* COMMIT TRANSACTION; */
if (emstorage_commit_transaction(multi_user_name, NULL, NULL, NULL) == false) {
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;
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);
, "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;
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;
pop3local = (POP3LOCAL *)(((MAILSTREAM *)stream)->local);
- if (!pop3local || !pop3local->netstream) {
+ if (!pop3local || !pop3local->netstream) {
err = EMAIL_ERROR_INVALID_STREAM;
goto FINISH_OFF;
}
/* 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;
}
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;
}
*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;
}
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;
{
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;
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,
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");
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 ");
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 ");
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);
{
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;
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;
}
mail->mailbox_id,
true,
(void **)&stream,
- &err) || !stream) {
+ &err) || !stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
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);
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 ");
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);
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);
{
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;
EM_SAFE_FREE(p); *attachment_data_list = NULL;
- if(err_code)
+ if (err_code)
*err_code = EMAIL_ERROR_NONE;
EM_DEBUG_FUNC_END();
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;
}
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;
}
{
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;
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;
mail->mailbox_id,
true,
(void **)&stream,
- &err) || !stream) {
+ &err) || !stream) {
EM_DEBUG_EXCEPTION("emcore_connect_to_remote_mailbox failed [%d]", err);
goto FINISH_OFF;
}
/* 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;
}
/* 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;
/* 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;
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);
#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;
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);
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;
}
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 ] >>>> ");
}
}
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;
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;
}
break;
- case EMAIL_FILTER_DELETE :
+ case EMAIL_FILTER_DELETE:
default:
EM_DEBUG_LOG("filter_faction : [%d]", filter_info->faction);
break;
}
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;
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:
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;
}
}
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:
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;
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;
}
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:
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;
}
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);
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);
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,
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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("string_type_key_value [%s]",
search_filter[i].search_filter_key_value.string_type_key_value);
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);
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;
}
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 ");
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);
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 ");
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 ");
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);
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);
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 ");
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);
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);
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;
FINISH_OFF:
- if(output_filter_string)
+ if (output_filter_string)
*output_filter_string = EM_SAFE_STRDUP(filter_string);
EM_DEBUG_FUNC_END();
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)))) {
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;
}
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;
}
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;
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;
}
/* 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;
}
}
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) {
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;
}
}
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) {
FINISH_OFF:
if (stream)
- mail_close (stream);
+ mail_close(stream);
if (uid_list)
emcore_free_uids(uid_list, NULL);
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__
}
*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;
}
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);
}
if (*response == '+') { /* "+OK" */
- EM_SAFE_FREE (response);
+ EM_SAFE_FREE(response);
continue;
}
if (*response == '.') {
- EM_SAFE_FREE (response);
+ EM_SAFE_FREE(response);
break;
}
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;
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;
goto FINISH_OFF;
}
- if (stream->nmsgs == 0){
+ if (stream->nmsgs == 0) {
err = EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER;
goto FINISH_OFF;
}
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;
}
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;
}
*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;
}
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;
}
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;
}
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)))) {
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;
}
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;
}
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);
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;
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;
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);
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)))) {
EM_SAFE_FREE(response);
return 1;
- }
- else {
+ } else {
err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
ret = true;
FINISH_OFF:
- EM_SAFE_FREE (response);
+ EM_SAFE_FREE(response);
if (err_code != NULL)
*err_code = err;
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
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);
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);
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;
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) {
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;
}
}
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++;
}
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;
}
}
/* 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,
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);
}
}
ret = true;
FINISH_OFF:
- if (ret == false){
+ if (ret == false) {
if (head_uid_elem)
emcore_free_uids(head_uid_elem, NULL);
}
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 {
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*/
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)
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)"*/
}
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;
}
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;
}
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;
}
}
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;
}
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) {
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;
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,
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;
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);
#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__ */
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;
}
&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);
}
}
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;
}
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);
/* 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))
#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
}
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;
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)) {
&err)) {
EM_DEBUG_LOG("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
}
- }
- else
+ } else
blocked = 0;
}
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 */
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);
}
}
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;
}
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__ */
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 */
EM_SAFE_FREE(uid_range);
- if(destination_mailbox)
+ if (destination_mailbox)
emstorage_free_mailbox(&destination_mailbox, 1, NULL);
if (rule != NULL)
result = NULL;
current = uid_list;
- while (current != NULL){
+ while (current != NULL) {
temp = current->next;
current->next = result;
result = current;
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 */
/* replied success "+OK" */
if (*p == '+') {
- EM_SAFE_FREE (p);
+ EM_SAFE_FREE(p);
continue;
}
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;
/* 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;
}
}
}
*t = '\0';
- }
- else {
+ } else {
err = EMAIL_ERROR_INVALID_RESPONSE;
goto FINISH_OFF;
}
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;
}
}
fetch_data_p = fetch_data_p->next;
fetch_data_p->next = uid_elem;
- }
- else {
+ } else {
*uid_list = uid_elem;
}
++(*total);
}
- EM_SAFE_FREE (p);
+ EM_SAFE_FREE(p);
}
}
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) {
}
stream = (MAILSTREAM *)tmp_stream;
- }
- else
+ } else
stream = mailbox->mail_stream;
if (!stream || !(imaplocal = stream->local) || !imaplocal->netstream) {
/* 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;
}
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) {
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;
}
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;
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);
}
}
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) {
mailbox_id,
false,
(void **)&stream,
- &err)){
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : Mailbox open[%d]", err);
goto FINISH_OFF;
}
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; */
}
}
- 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 {
}
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;
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;
}
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;
}
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;
0,
true,
(void **)&stream,
- &err)){
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_move_mail_on_server failed : Mailbox open[%d]", err);
goto FINISH_OFF;
}
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;
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;
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;
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);
}
}
}
if (stream)
- stream = mail_close (stream);
+ stream = mail_close(stream);
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
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;
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 */
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;
}
/*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");
}
}
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;
}
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;
}
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++)
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;
}
}
/* 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);
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);
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);
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);
}
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);
}
&err))
EM_DEBUG_EXCEPTION("emstorage_add_attachment failed - %d", err);
}
- }
- else {
+ } else {
if (temp_file->save)
g_remove(temp_file->save);
}
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,
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;
}
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);
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;
}
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;
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();
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;
}
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;
}
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);
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;
}
/* 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) {
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);
}
int emcore_pop3_send_command(MAILSTREAM *stream, pop3_cmd_t cmd_type, int *err_code);
/* thread local variable for stream reuse */
-__thread GList* g_recv_stream_list = NULL;
+__thread GList *g_recv_stream_list = NULL;
typedef struct {
int account_id;
int mailbox_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;
}
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;
}
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);
#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();
- GList* cur = g_recv_stream_list;
- email_recv_stream_list_t* data = 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);
- GList* cur = g_recv_stream_list;
- email_recv_stream_list_t* data = 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;
}
/* 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;
}
}
- 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;
}
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;
}
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:
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)
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;
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;
{
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;
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;
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;
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;
}
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;
}
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);
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;
}
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;
}
FINISH_OFF:
- if(local_mailbox)
+ if (local_mailbox)
emstorage_free_mailbox(&local_mailbox, 1, NULL);
if (err_code)
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;
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,
emstorage_free_mailbox(&target_mailbox, 1, NULL);
target_mailbox = NULL;
- }
- else
+ } else
#endif /* __FEATURE_DELETE_MAILBOX_RECURSIVELY__ */
{
target_mailbox_array = target_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");
}
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;
}
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;
}
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;
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;
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,
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;
}
/* 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,
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]",
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;
}
}
} 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) {
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);
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 ||
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);
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;
#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;
}
}
/*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,
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);
}
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();
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;
}
}
}
- }
- 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 */
{
EM_DEBUG_FUNC_BEGIN("account_id[%d], mail_stream[%p]", account_id, mail_stream);
- if (!mail_stream) {
+ if (!mail_stream) {
return false;
}
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);
{
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;
}
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;
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;
}
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;
}
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;
}
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;
}
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);
FINISH_OFF:
if (err_code)
*err_code = err;
+
EM_DEBUG_FUNC_END();
return ret;
}
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;
}
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;
}
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)
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;
}
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;
}
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);
/* 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);
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);
}
EM_DEBUG_FUNC_END();
- if(err_code) *err_code = EMAIL_ERROR_NONE;
+ if (err_code) *err_code = EMAIL_ERROR_NONE;
return EMAIL_ERROR_NONE;
}
/* 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;
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;
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");
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... ");
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;
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();
{
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();
}
{
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();
}
{
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();
}
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();
}
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();
}
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();
}
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;
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;
{
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;
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;
}
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 : "");
}
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);
}
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;
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:
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;
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;
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);
{
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;
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 = "";
g_inline_list[g_inline_count] = body;
g_inline_count++;
temp = NULL;
- }
- else {
+ } else {
EM_DEBUG_EXCEPTION("realloc fails");
}
}
/* 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);
/* 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;
}
} 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;
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();
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;
}
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;
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;
}
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;
}
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;
}
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);
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;
}
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; */
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; */
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);
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;
}
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;
}
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);
ret = true;
FINISH_OFF:
-
+
EM_SAFE_CLOSE(fd);
if (err_code)
}
/* convert directory delimiter to '/' */
- for (s = enc_path;*s;s++)
+ for (s = enc_path; *s; s++)
if (*s == (char)delimiter)
*s = '/';
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);
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);
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:
break;
case WARN:
- EM_DEBUG_EXCEPTION ("IMAP_TOOLKIT_LOG WARN [%s]", string);
+ EM_DEBUG_EXCEPTION("IMAP_TOOLKIT_LOG WARN [%s]", string);
break;
case PARSE:
}
#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);
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;
}
* 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;
}
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;
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);
}
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();
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);
}
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);
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;
if (file_path)
*file_path = EM_SAFE_STRDUP(temp_pgp_filepath);
- return err;
+ return err;
#else /* __FEATURE_SECURE_PGP__ */
return EMAIL_ERROR_NOT_SUPPORTED;
#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);
}
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);
}
/* 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;
if (file_path)
*file_path = EM_SAFE_STRDUP(temp_pgp_filepath);
- return err;
+ return err;
#else /* __FEATURE_SECURE_PGP__ */
return EMAIL_ERROR_NOT_SUPPORTED;
}
-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);
}
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);
}
/* 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;
if (file_path)
*file_path = EM_SAFE_STRDUP(temp_pgp_filepath);
- return err;
+ return err;
#else /* __FEATURE_SECURE_PGP__ */
return EMAIL_ERROR_NOT_SUPPORTED;
}
-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);
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);
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");
if (verify)
*verify = p_verify;
- return err;
+ return err;
#else /* __FEATURE_SECURE_PGP__ */
return EMAIL_ERROR_NOT_SUPPORTED;
}
-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);
/* 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);
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;
\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
\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
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
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
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
\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
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
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
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
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
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
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
\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
\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
\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
\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
\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
\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
\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
\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
\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
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
\r
FINISH_OFF:\r
\r
- if(signal)\r
+ if (signal)\r
dbus_message_unref(signal);\r
\r
LEAVE_CRITICAL_SECTION(_dbus_noti_lock);\r
\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
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
* 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 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();
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;
}
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;
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);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
-
+
x509_cert = NULL;
token_address = token_address->next;
}
/* 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();
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;
if (PKCS7_final(pkcs7, mime_entity, flags))
return pkcs7;
-
+
FINISH_OFF:
BIO_free_all(p7bio);
PKCS7_free(pkcs7);
}
*/
-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);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
-
+
/* Get the digest algorithm */
digest = emcore_get_digest_algorithm(digest_type);
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);
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();
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);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
-
+
/* 4. Get the digest algorithm */
digest = emcore_get_digest_algorithm(digest_type);
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));
/* 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);
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();
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);
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");
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");
} 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;
X509_STORE_free(store);
if (p7)
PKCS7_free(p7);
-
+
if (indata)
BIO_free(indata);
}
*/
-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;
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, '/');
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;
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;
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, '/');
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;
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;
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;
}
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;
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()
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;
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:
}
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;
}
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;
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;
}
}
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;
}
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);
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 ;
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;
}
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;
}
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;
}
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);
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;
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;
}
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;
{
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) {
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");
}
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; */
/* 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))
}
}
- 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;
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;
}
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;
}
if (error == EMAIL_ERROR_NONE) {
if (!file_exist)
*data = EM_SAFE_STRDUP(fname);
- }
- else if (fname != NULL) {
+ } else if (fname != NULL) {
remove(fname);
}
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;
#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;
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;
}
}
- 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;
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;
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;
}
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;
}
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;
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;
}
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;
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;
}
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);
}
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++;
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,
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;
}
}
/* 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);
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;
}
}
}
- 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;
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;
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;
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;
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)) {
}
}
- 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)
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
*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)
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;
}
#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)
}
/* thread local variable for reuse */
-__thread GList* g_send_stream_list = NULL;
+__thread GList *g_send_stream_list = NULL;
typedef struct {
int account_id;
SENDSTREAM **send_stream;
/*
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();
- GList* cur = g_send_stream_list;
- email_send_stream_list_t* data = 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;
}
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);
- GList* cur = g_send_stream_list;
- email_send_stream_list_t* data = 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;
}
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;
}
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:
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;
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);
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__ */
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);
}
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;
}
}
- 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;
}
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)
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)
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;
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;
}
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;
}
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;
EMAIL_MAILBOX_TYPE_OUTBOX,
&src_mailbox,
true,
- &err)) {
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
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,
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;
}
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 {
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);
if (fpath) {
EM_DEBUG_LOG_SEC("REMOVE TEMP FILE : %s", fpath);
remove(fpath);
- EM_SAFE_FREE (fpath);
+ EM_SAFE_FREE(fpath);
}
if (local_mailbox)
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);
}
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;
}
/* 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;
}
}
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;
}
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++) {
}
/* 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;
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;
}
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)
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;
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;
EMAIL_MAILBOX_TYPE_OUTBOX,
&local_mailbox,
false,
- &err)) {
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
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;
UPDATE_EXTRA_FLAG,
searched_mail_tbl_data,
true,
- &err)) {
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_change_mail_field failed [%d]", err);
goto FINISH_OFF;
}
EMAIL_MAILBOX_TYPE_SENTBOX,
&local_mailbox,
false,
- &err)) {
+ &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
&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,
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);
}
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);
}
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);
}
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);
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");
}
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;
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;
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. */
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);
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;
}
}
-/* ------ 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);
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;
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;
}
/* 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;
/* 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;
}
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);
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) {
/* 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;
/* 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;
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;
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;
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;
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;
}
}
- 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;
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;
}
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;
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;
}
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);
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;
}
}
{
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;
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("");
}
{
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;
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;
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;
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);
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);
}
}
- 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;
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;
*/
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] = ',';
}
{
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] = ',';
}
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);
/* 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);
}
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;
}
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;
}
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;
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;
}
}
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);
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;
}
}
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;
}
}
} 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;
}
}
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);
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");
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;
}
}
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) {
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;
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;
}
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;
}
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
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;
}
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;
}
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;
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;
}
/* 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;
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;
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,
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;
}
}
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);
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;
}
}
/* 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);
}
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;
}
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);
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;
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(¤t_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;
}
}
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;
, 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;
}
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;
}
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;
}
/* 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);
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);
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;
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);
}
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();
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;
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;
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;
}
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;
}
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;
}
}
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;
}
/* 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;
/* 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 */
goto FINISH_OFF;
}
-FINISH_OFF :
+FINISH_OFF:
+
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
/* Free _active_task_pool */
- //FINISH_OFF :
+ //FINISH_OFF:
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
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;
}
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;
}
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;
}
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;
}
FINISH_OFF:
- if(tn)
+ if (tn)
tpl_free(tn);
EM_DEBUG_FUNC_END("err [%d]", err);
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);
}
}
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;
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;
}
FINISH_OFF:
- if(tn)
+ if (tn)
tpl_free(tn);
EM_DEBUG_FUNC_END("err [%d]", err);
FINISH_OFF:
- if(tn)
+ if (tn)
tpl_free(tn);
EM_DEBUG_FUNC_END("err [%d]", err);
}
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;
FINISH_OFF:
- if(tn)
+ if (tn)
tpl_free(tn);
EM_DEBUG_FUNC_END("err [%d]", err);
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;
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;
}
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;
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);
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;
}
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;
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;
{
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;
}
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;
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;
}
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;
}
/*-------------------------------------------------------------------------------------------*/
* 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)
#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)
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)
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;
}
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));
#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;
}
}
- if(*long_enc_path)
+ if (*long_enc_path)
EM_DEBUG_LOG_SEC("long_enc_path [%s]", *long_enc_path);
ret = true;
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;
}
/* 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;
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 '/' */
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;
}
}
- 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 ")" */
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;
}
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;
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) {
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;
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;
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;
}
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);
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");
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;
}
}
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;
}
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;
}
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;
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;
}
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;
/* 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;
}
}
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");
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;
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);
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;
}
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;
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);
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;
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);
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);
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;
}
{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},
{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;
}
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;
}
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;
}
}
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;
}
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 ||
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);
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;
}
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;
}
}
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)) {
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 ||
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");
if (!pTransinfo) {
pTransinfo = pTemp ;
g_transaction_info_list = pTransinfo ;
- }
- else {
+ } else {
while (pTransinfo->next)
pTransinfo = pTransinfo->next;
pTransinfo->next = pTemp;
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);
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;
}
#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;
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;
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;
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 (®_pattern, pos, 1, pmatch, 0);) {
+ for (pos = input_source_text; !regexec(®_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 (®_pattern);
+ regfree(®_pattern);
EM_DEBUG_FUNC_END("error_code [%d]", error_code);
return error_code;
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");
}
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;
}
{
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:
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");
FINISH_OFF:
- if(account_count) {
+ if (account_count) {
emstorage_free_account(&account_list, account_count, NULL);
}
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);
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);
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);
/*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;
}
(*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);
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;
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;
}
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;
}
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;
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]);
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 */
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;
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;
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");
}
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;
}
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;
}
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;
}
}
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;
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;
}
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;
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;
}
- 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;
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;
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;
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;
}
}
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;
}
/* 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);
}
}
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;
}
FINISH_OFF:
- if(account) {
+ if (account) {
emstorage_free_account(&account, 1, NULL);
}
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:
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;
}
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;
}
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;
}
/* 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;
}
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,
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;
}
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,
return err;
}
-typedef struct _contacts_delete_data
-{
+typedef struct _contacts_delete_data {
int account_id;
char *multi_user_name;
} contacts_delete_data;
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;
}
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,
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,
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)
{
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;
}
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,
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,
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;
}
*/
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) {
*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;
*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");
err = EMAIL_ERROR_INVALID_PARAM;
}
-FINISH_OFF :
+FINISH_OFF:
/*
contacts_disconnect_on_thread();
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;
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) {
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- }
- else if (rd_size == 0)
+ } else if (rd_size == 0)
break;
else
bytes_read += rd_size;
*contents = buf;
}
- EM_SAFE_CLOSE (fd); /* prevent 39093 */
+ EM_SAFE_CLOSE(fd); /* prevent 39093 */
EM_DEBUG_FUNC_END();
return err;
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;
}
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;
}
}
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 */
}
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;
}
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;
}
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;
if (result_string)
curl_free(result_string);
- if(curl)
+ if (curl)
curl_easy_cleanup(curl);
EM_DEBUG_FUNC_END("err[%d]", err);
char *mon = NULL;
- switch (month){
+ switch (month) {
case 0:
mon = strdup("jan");
break;
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);
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;
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))
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
* 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
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;
/* 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);
* 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 <string.h>
#include <unistd.h>
#include <errno.h>
-#include <email-storage.h>
+#include <email-storage.h>
#include <vconf.h>
#include "glib.h"
#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__
EM_DEBUG_FUNC_BEGIN();
int value;
- if(!sim_status) {
+ if (!sim_status) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
EM_DEBUG_FUNC_BEGIN();
int value;
- if(!flight_mode) {
+ if (!flight_mode) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
int value;
- if(!wifi_status) {
+ if (!wifi_status) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
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) {
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;
}
EM_DEBUG_LOG("Data Network Mode is ON");
ret = true;
-FINISH_OFF:
+FINISH_OFF:
emcore_set_network_error(err);
int value;
- if(!output_roaming_status) {
+ if (!output_roaming_status) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
return EMAIL_ERROR_INVALID_PARAM;
}
}
/* 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;
if (stream->ictr >= size) {
memcpy(p, stream->iptr, size);
copy_sz = size;
- }
- else {
+ } else {
memcpy(p, stream->iptr, stream->ictr);
copy_sz = stream->ictr;
}
*p = '\0';
return 1;
}
- }
- else {
+ } else {
nleave = size;
}
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);
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);
/* 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);*/\
}
#ifdef _MULTIPLE_DB_HANDLE
-typedef struct
-{
+typedef struct {
char *user_name;
pthread_t thread_id;
sqlite3 *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);
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);
/* ------------------------------------------------------------------------------ */
/* Mutex using shared memory */
-typedef struct
-{
+typedef struct {
pthread_mutex_t mutex;
int data;
} mmapped_t;
_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) \
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;
}
}
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;
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;
}
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;
}
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;
}
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;
}
{
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;
}
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;
}
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,
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,
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,
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,
};
#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,
};
#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,
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,
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,
};
#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,
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;
}
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;
}
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;
}
{
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;
}
*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_
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;
}
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;
}
buffer = NULL;
else {
*buffer = malloc(buffer_size);
- if(*buffer == NULL) {
+ if (*buffer == NULL) {
EM_DEBUG_EXCEPTION("allocation failed.");
return false;
}
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;
}
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;
}
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;
}
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;
}
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_
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;
}
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;
}
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_
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;
}
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;
}
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;
}
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;
}
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);
} 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;
}
#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;
}
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);
}
{
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;
}
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);
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;
*sqlite_handle = NULL;
goto FINISH_OFF; /*prevent 33351*/
}
- }
- else
+ } else
goto FINISH_OFF;
}
_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};
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;
}
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;
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;
}
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);
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);
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);
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);
/* 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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
}
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;
}
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]);
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;
}
}
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;
}
/* 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;
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);
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;
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;
}
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);
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;
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;
}
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++);
_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);
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);
}
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;
}
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++);
_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++);
_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;
}
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;
}
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++);
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);
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);
}
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++);
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);
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;
);
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]);
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;
{
EM_DEBUG_FUNC_BEGIN();
- if (!count) {
+ if (!count) {
if (err_code != NULL)
*err_code = EMAIL_ERROR_INVALID_PARAM;
return false;
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);
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;
}
}
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;
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]);
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;
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++);
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]",
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;
}
/* 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++)
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++)
}
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");
}
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;
}
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;
}
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)
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;
}
{
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;
}
{
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;
/* 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;
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);
}
}
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;
}
{
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;
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;
{
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;
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;
_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;
}
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 >>> ");
}
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;
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) {
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;
}
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:
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);
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");
}
{
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;
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;
") ");
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;
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)));
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");
}
{
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)
/* 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;
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;
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);
{
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)
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]);
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);
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;
}
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);
}
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;
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;
}
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)
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;
}
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;
}
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);
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)
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;
(*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
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;
}
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;
}
{
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;
}
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;
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) {
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;
}
}
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;
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) {
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;
}
}
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;
{
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)
, account_id
, local_yn
, input_mailbox_id);
- }
- else {
+ } else {
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"UPDATE mail_box_tbl SET"
" mailbox_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);
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) {
- 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;
}
}
{
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)
, 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 = ?"
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;
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;
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;
_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;
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;
}
}
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;
}
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;
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;
}
}
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;
}
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);
}
{
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;
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(¤t_time);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_box_tbl VALUES "
- "( ?" /* mailbox_id */
+ "(?" /* mailbox_id */
", ?" /* account_id */
", ?" /* local_yn */
", ?" /* mailbox_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_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;
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)
{
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);
{
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)
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);
}
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;
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)
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;
{
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)
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]);
{
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)
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 {
}
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]);
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));
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;
}
}
{
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)
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);
_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));
}
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;
}
}
{
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)
"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 "
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) {
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;
}
}
{
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;
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 */
", ?" /* 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));
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);
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)));
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;
}
}
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));
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);
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;
}
}
{
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)
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));
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;
}
}
"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)
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;
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);
}
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]);
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;
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);
_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));
}
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;
}
}
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;
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;
}
}
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;
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;
}
}
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,
}
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 (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;
}
}
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;
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_rule_tbl VALUES "
- "( ?" /* account id */
+ "(?" /* account id */
", ?" /* rule_id */
", ?" /* filter_name */
", ?" /* type */
", ?)"); /* 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;
_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;
}
}
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]);
#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)
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]);
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;
}
}
{
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;
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;
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, "
"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;
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++);
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;
}
}
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;
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);
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] = ')';
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;
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;
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++);
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;
}
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;
}
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");
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;
}
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);
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;
}
}
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;
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);
_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;
}
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;
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);
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;
}
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;
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;
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;
}
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);
_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;
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)
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;
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;
}
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);
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);
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;
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;
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;
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;
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;
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;
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;
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;
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);
_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'"
, 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;
}
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);
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);
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);
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;
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);
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;
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;
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 ]");
}
}
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;
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;
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;
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_tbl VALUES "
- "( ?" /* mail_id */
+ "(?" /* mail_id */
", ?" /* account_id */
", ?" /* mailbox_id */
", ?" /* mailbox_type */
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);
_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;
}
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;
}
}
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);
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;
}
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);
{
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;
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);
/* 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);
{
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)
}
rc = sqlite3_changes(local_db_handle);
- if (rc == 0) {
+ if (rc == 0) {
EM_DEBUG_LOG(" no mail found...");
error = EMAIL_ERROR_MAIL_NOT_FOUND;
}
}
rc = sqlite3_changes(local_db_handle);
- if (rc == 0) {
+ if (rc == 0) {
EM_DEBUG_LOG("No mail found...");
error = EMAIL_ERROR_MAIL_NOT_FOUND;
}
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)
{
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;
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)
{
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)
{
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;
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]);
{
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;
}
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;
}
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:
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 */
{
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;
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;
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;
}
{
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)
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;
#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;
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;
}
{
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;
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;
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;
}
{
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;
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;
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);
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;
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);
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;
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;
}
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;
}
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;
}
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 = ?"
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 = ?"
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)
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);
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;
}
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;
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])
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;
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);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_attachment_tbl VALUES "
- "( ?" /* attachment_id */
+ "(?" /* attachment_id */
", ?" /* attachment_name */
", ?" /* attachment_path */
", ?" /* content_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, 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);
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;
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;
}
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;
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;
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;
}
{
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;
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;
{
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;
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);
{
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);
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) {
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) {
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;
{
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;
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,
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;
}
}
}
- 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;
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;
}
}
}
- 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;
}
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;
}
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;
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;
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) {
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)
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;
}
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);
/**
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);
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)) {
}
}
- }
- else {
+ } else {
EM_DEBUG_EXCEPTION(" Error Occured while writing New data : [%d ] bytes written ", nwritten);
error = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
fclose(fp_dest);
fp_dest = NULL;
}
+
if (err_code)
*err_code = error;
+
EM_DEBUG_FUNC_END("ret [%d]", ret);
return ret;
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;
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)) {
}
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));
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);
}
error = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
- }
- else {
+ } else {
EM_DEBUG_EXCEPTION(" no file found...");
error = EMAIL_ERROR_FILE_NOT_FOUND;
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;
}
}
- while ((dp=readdir(dirp))) {
+ while ((dp = readdir(dirp))) {
if (strncmp(dp->d_name, ".", 1) == 0 || strncmp(dp->d_name, "..", 2) == 0) /* prevent 34360 */
continue;
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);
*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)
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;
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;
{
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;
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;
}
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);
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;
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)
{
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_tbl VALUES "
- "( ?" /* mail_id */
+ "(?" /* mail_id */
", ?" /* account_id */
", ?" /* mail_size */
", ?" /* server_mail_status */
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);
_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;
}
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);
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);
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:
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;
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;
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;
}
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++);
ret = true;
FINISH_OFF:
- if (ret == true) {
+ if (ret == true) {
*sender_list = p_sender_list;
*sender_count = count;
EM_DEBUG_LOG(">>>> COUNT : %d >>", count);
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;
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);
}
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;
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 */
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;
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_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;
{
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;
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]);
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;
}
_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]);
}
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]);
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;
}
_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]);
}
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]);
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)))) {
}
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);
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;
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;
/* 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;
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);
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;
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);
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;
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;
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;
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;
}
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;
/* 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)));
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;
}
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) {
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);
/* 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);
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:
}
} 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:
}
}
/* 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);
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);
SNPRINTF(sql_query_string, sizeof(sql_query_string),
"INSERT INTO mail_meeting_tbl VALUES "
- "( ?" /* mail_id */
+ "(?" /* mail_id */
", ?" /* account_id */
", ?" /* mailbox_id */
", ?" /* meeting_response */
", ?" /* 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));
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;
}
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) {
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);
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;
}
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);
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) {
+ if (rc != SQLITE_OK) {
EM_DEBUG_EXCEPTION("sqlite3_finalize error [%d]", rc);
error = EMAIL_ERROR_DB_FAILURE;
}
{
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);
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;
}
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);
/* 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;
}
/* 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) {
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);
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] >>>> ");
}
}
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);
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;
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;
}
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);
}
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++]);
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++;
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);
}
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;
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;
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;
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]);
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);
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:
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;
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;
}
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;
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);
}
}
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;
}
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;
}
}
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;
}
}
ret = true;
FINISH_OFF:
+
if (err_code != NULL)
*err_code = error;
#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);
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;
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);
}
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;
}
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;
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;
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;
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;
}
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;
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...");
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:
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;
}
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;
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))) {
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);
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 , };
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,
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,
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;
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 ",
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 ",
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;
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;
}
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);
}
}
- 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);
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;
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;
}
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])
") ");
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);
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);
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;
}
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;
}
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]);
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) {
goto FINISH_OFF;
}
- for (i = 0; i < count; i++) {
+ for (i = 0; i < count; i++) {
/* get recordset */
field_index = 0;
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;
}
}
- 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;
}
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;
}
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)));
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);
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 */
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;
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_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;
/* 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;
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]);
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)))) {
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);
_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));
}
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);
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;
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]);
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;
}
_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]);
}
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]);
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;
}
_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]);
}
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);
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;
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)
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);
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;
}
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);
}
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);
}
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);
}
}
emstorage_drop_table(multi_user_name, table_names[i][1]);
- }
- else
+ } else
EM_DEBUG_LOG("Skipped");
}
}
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);
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);
static email_account_t* duplicate_account(email_account_t *src)
{
- if(!src) {
+ if (!src) {
EM_DEBUG_EXCEPTION("INVALID_PARAM");
return NULL;
}
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);
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;
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;
}
}
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;
}
#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__
FINISH_OFF:
- if(new_account_tbl)
+ if (new_account_tbl)
emstorage_free_account(&new_account_tbl, 1, NULL);
if (old_account_info) {
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);
ret = true;
FINISH_OFF:
- if(account_tbl)
+ if (account_tbl)
emstorage_free_account(&account_tbl, 1, NULL);
if (err_code)
*err_code = err;
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)
{
EM_DEBUG_FUNC_BEGIN();
- if(!account)
+ if (!account)
return false;
int ret = false;
{
EM_DEBUG_FUNC_BEGIN();
- if(!old_account || !new_account)
+ if (!old_account || !new_account)
return false;
int ret = false;
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;
}
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);
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;
}
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);
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);
}
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;
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;
}
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;
time(¤t_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;
}
if (empty) {
EM_DEBUG_LOG_SEC("/>");
strcat((char *)p, "/>");
- }
- else {
+ } else {
EM_DEBUG_LOG_SEC(">");
strcat((char *)p, ">");
}
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();
*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;
}
*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;
}
*(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 */
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 !");
}
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)) {
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';
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;
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);
}
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;
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;
FINISH_OFF:
- if(msg_struct)
+ if (msg_struct)
msg_release_struct(&msg_struct);
EM_DEBUG_FUNC_END("err [%d]", err);
* 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
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;
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;
/* 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)) {
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;
}
}
#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;
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;
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);
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;
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();
}
}
- if(!have_smack) {
+ if (!have_smack) {
EM_DEBUG_LOG("smack is disabled");
result = true;
goto FINISH_OFF;
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));
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);
}
if (mode & CRYPTO_LOCK) {
pthread_mutex_lock(&(lock_cs[type]));
lock_count[type]++;
- }
- else {
+ } else {
pthread_mutex_unlock(&(lock_cs[type]));
}
}
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);
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);
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 !!! <<<<<<<<<<<<<<<");
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:
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*/
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]",
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 >>>> ");
}
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;
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) {
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);
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;
}
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 ");
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,
&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))
#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);
#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)
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;
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)) {
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) {
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);
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;
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)) {
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);
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;
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;
}
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;
}
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; */
}
#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();
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);
}
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;
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,
}
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,
}
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);
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);
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;
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)
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)
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
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);
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);
}
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);
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);
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);
}
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;
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;
/* 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;
}
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);
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
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
#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
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();
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();
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);
}
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);
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");
}
}
}
#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
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);
}
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);
}
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;
}
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;
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");
}
}
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;
}
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;
}
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;
}
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;
}
g_save_local_activity_run = 1;
#endif
- if ( handle )
+ if (handle)
*handle = result_handle;
ret = true;
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);
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();
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;
}
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;
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;
}
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;
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);
}
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;
#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;
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);
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;
#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;
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;
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");
}
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");
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;
}
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;
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;
}
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;
}
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;
}
goto FINISH_OFF;
}
event_insert = true;
- }
- else
+ } else
#endif
{
if ((err = emcore_expunge_mails_deleted_flagged_from_local_storage(multi_user_name,
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);
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;
}
/* 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 */
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;
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;
}
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;
}
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;
}
}
/* 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");
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;
}
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;
/* 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)
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;
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;
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;
}
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;
}
#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))
//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");
}
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))
#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:
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;
}
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))
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))
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;
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;
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 ");
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 ");
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))
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;
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)) {
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))
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))
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))
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))
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))
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);
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);
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))
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);
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);
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);
}
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))
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 ");
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 ");
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);
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 ");
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 */
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))
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;
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);
}
}
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;
}
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 ");
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;
free(rule);
}
- EM_SAFE_FREE(local_rule_stream);
+ EM_SAFE_FREE(local_rule_stream);
EM_SAFE_FREE(multi_user_name);
EM_DEBUG_FUNC_END();
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;
}
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");
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))
/* 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;
}
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))
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 ");
}
/* 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;
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 */
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))
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);
}
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);
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;
/* 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);
}
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");
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);
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);
}
}
/* 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);
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;
}
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);
}
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;
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");
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);
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);
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;
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;
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");
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 */
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))
/* 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))
/* 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))
/* 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");
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))
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 ");
}
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 ");
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 ");
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 ");
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))
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;
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 ");
}
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))
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");
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))
/* 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");
}
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");
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;
}
/* 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);
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);
/* 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;
}
#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__
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 ");
/* 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);
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))
/* 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);
/* 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))
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))
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;
}
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);
}
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))
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))
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))
emipc_get_parameter(a_hAPI, ePARAMETER_IN, 2, sizeof(int), ¶m_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))
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))
/* 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;
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;
}
}
/* 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 ");
{
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;
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;
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");
}
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);
}
/* 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;
/* 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;
}
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;
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))
}
/* 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);
}
/* 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;
/* 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;
}
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;
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))
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);
}
/* 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;
/* 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;
}
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;
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))
}
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);
}
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");
}
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");
}
}
return;
}
- switch(nAPIID) {
+ switch (nAPIID) {
case _EMAIL_API_ADD_ACCOUNT:
stb_create_account(a_hAPI);
break;
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:
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;
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;
}
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:
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 */
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,
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[])
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 */
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");
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,
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;
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;
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;
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);
}
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;
}
* 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
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;
}
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");
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;
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);
EM_SAFE_FREE(user_name);
- if (hAPI)
+ if (hAPI)
emipc_destroy_email_api(hAPI);
#endif /* __FEATURE_CONTAINER_ENABLE__ */
* 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
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;
{
EM_DEBUG_FUNC_BEGIN();
unsigned char *stream = NULL;
-
+
if (!api_info) {
EM_DEBUG_EXCEPTION("Invalid parameter.");
return stream;
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) {
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]);
}
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) {
}
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;
/* 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);
#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();
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);
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);
* 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
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);
-}
+}
* 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
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()
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;
in_stream = emipc_serialize_api_info(api_info, ePARAMETER_IN, &length);
- if( !in_stream ) {
+ if (!in_stream) {
EM_DEBUG_EXCEPTION("NULL stream");
return false;
}
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;
}
}
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;
}
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) {
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;
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;
}
#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);
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;
}
if (proxy_ev_events[i].events & EPOLLIN) {
EM_DEBUG_LOG("Received event to stub");
ret = true;
- }
+ }
}
}
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,
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 */
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;
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 */
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);
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;
}
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;
}
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;
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;
}
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;
}
* 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
emipc_end_stub_socket();
stub_socket = false;
}
-
+
if (this_fn_api_mapper)
this_fn_api_mapper = NULL;
-
+
EM_DEBUG_FUNC_END();
return true;
}
EM_DEBUG_EXCEPTION("Invalid Param");
return false;
}
-
+
if (this_fn_api_mapper) {
this_fn_api_mapper(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++)
* 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
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);
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);
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;
}
/*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 */
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;
}
}
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);
* 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
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;
EXPORT_API void *emipc_do_task_thread()
{
EM_DEBUG_FUNC_BEGIN();
-
+
emipc_email_task *task = NULL;
while (!stop_flag) {
/* 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;
}
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 */
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);
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);
}
}
-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;
}
* 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
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;
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");
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;
}