diff options
author | Sunghyun Kwon <sh0701.kwon@samsung.com> | 2014-02-20 14:58:45 +0900 |
---|---|---|
committer | Sunghyun Kwon <sh0701.kwon@samsung.com> | 2014-02-20 14:58:45 +0900 |
commit | cc2e0476a3397d0f8f76960a119f240b4ad01699 (patch) | |
tree | b75c921ec1f8ba2e8b3019df5b6c228d58b6befa /email-api/email-api-account.c | |
parent | 7e2c216892ac4d1ae8b4ec838f61f6213099b6e8 (diff) | |
download | email-service-cc2e0476a3397d0f8f76960a119f240b4ad01699.tar.gz email-service-cc2e0476a3397d0f8f76960a119f240b4ad01699.tar.bz2 email-service-cc2e0476a3397d0f8f76960a119f240b4ad01699.zip |
Merge the email-service to version 2.2
Change-Id: I26816a6b43c134a80e64c6051f8e1205df672ff7
Signed-off-by: Sunghyun Kwon <sh0701.kwon@samsung.com>
Diffstat (limited to 'email-api/email-api-account.c')
-rwxr-xr-x | email-api/email-api-account.c | 150 |
1 files changed, 102 insertions, 48 deletions
diff --git a/email-api/email-api-account.c b/email-api/email-api-account.c index 5f88002..5bc0ebc 100755 --- a/email-api/email-api-account.c +++ b/email-api/email-api-account.c @@ -43,14 +43,15 @@ /* API - Adds the Email Account */ EXPORT_API int email_add_account(email_account_t* account) { - EM_DEBUG_FUNC_BEGIN("account[%p]", account); + EM_DEBUG_API_BEGIN ("account[%p]", account); char* local_account_stream = NULL; int size = 0; int err = EMAIL_ERROR_NONE; int ret_from_ipc = EMAIL_ERROR_NONE; HIPC_API hAPI = NULL; - if ( !account ) { + 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; } @@ -98,14 +99,14 @@ FINISH_OFF: if(hAPI) emipc_destroy_email_api(hAPI); - EM_DEBUG_FUNC_END("ERROR CODE [%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); + EM_DEBUG_FUNC_BEGIN ("account_list[%p] count[%d]", account_list, count); /* use only debugging */ /* default variable */ int err = EMAIL_ERROR_NONE; @@ -140,7 +141,7 @@ EXPORT_API int email_free_account(email_account_t** account_list, int count) } FINISH_OFF: - EM_DEBUG_FUNC_END("ERROR CODE [%d]", err); + EM_DEBUG_FUNC_END ("err[%d]", err); return err; } @@ -148,7 +149,7 @@ FINISH_OFF: /* API - Delete the Email Account */ EXPORT_API int email_delete_account(int account_id) { - EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id); + EM_DEBUG_API_BEGIN ("account_id[%d]", account_id); int ret = 0; int err = EMAIL_ERROR_NONE; @@ -181,14 +182,14 @@ EXPORT_API int email_delete_account(int account_id) emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%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_FUNC_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 ret = 0; int size = 0; @@ -241,14 +242,14 @@ FINISH_OFF: emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%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_with_validation(int account_id, email_account_t* new_account) { - EM_DEBUG_FUNC_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 ret = 0; int size = 0; @@ -300,7 +301,7 @@ EXPORT_API int email_update_account_with_validation(int account_id, email_accoun emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err); + EM_DEBUG_API_END ("ret[%d] err[%d]", ret, err); return err; } @@ -308,7 +309,7 @@ EXPORT_API int email_update_account_with_validation(int account_id, email_accoun /* API - Get the account Information based on the account ID */ EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t** account) { - EM_DEBUG_FUNC_BEGIN(); + EM_DEBUG_FUNC_BEGIN ("account_id[%d] pulloption[%d]", account_id, pulloption); int ret = 0; int err = EMAIL_ERROR_NONE; emstorage_account_tbl_t *account_tbl = NULL; @@ -316,17 +317,32 @@ EXPORT_API int email_get_account(int account_id, int pulloption, email_account_t EM_IF_NULL_RETURN_VALUE(account_id, EMAIL_ERROR_INVALID_PARAM); EM_IF_NULL_RETURN_VALUE(account, EMAIL_ERROR_INVALID_PARAM); +#ifdef __FEATURE_ACCESS_CONTROL__ + err = em_check_db_privilege_by_pid(getpid()); + if (err == EMAIL_ERROR_PERMISSION_DENIED) { + EM_DEBUG_LOG("permission denied"); + goto FINISH_OFF; + } +#endif + if (pulloption == GET_FULL_DATA) pulloption = EMAIL_ACC_GET_OPT_FULL_DATA; - if (pulloption & EMAIL_ACC_GET_OPT_PASSWORD) { - pulloption = pulloption & (~(EMAIL_ACC_GET_OPT_PASSWORD)); /* disable password -Can't obtain password by MAPI */ - EM_DEBUG_LOG("change pulloption : disable password"); - } - if (!emstorage_get_account_by_id(account_id, pulloption, &account_tbl, true, &err)) { - EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err); - goto FINISH_OFF; + if (err != EMAIL_ERROR_SECURED_STORAGE_FAILURE) { + EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err); + goto FINISH_OFF; + } + + if (pulloption & EMAIL_ACC_GET_OPT_PASSWORD) { + pulloption = pulloption & (~(EMAIL_ACC_GET_OPT_PASSWORD)); /* disable password -Can't obtain password by MAPI */ + EM_DEBUG_LOG("change pulloption : disable password"); + } + + if (!emstorage_get_account_by_id(account_id, pulloption, &account_tbl, true, &err)) { + EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err); + goto FINISH_OFF; + } } *account = em_malloc(sizeof(email_account_t)); @@ -344,13 +360,13 @@ FINISH_OFF: if (account_tbl) emstorage_free_account(&account_tbl, 1, NULL); - EM_DEBUG_FUNC_END(); + 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; emstorage_account_tbl_t *temp_account_tbl = NULL; @@ -358,6 +374,14 @@ EXPORT_API int email_get_account_list(email_account_t** account_list, int* count EM_IF_NULL_RETURN_VALUE(account_list, EMAIL_ERROR_INVALID_PARAM); EM_IF_NULL_RETURN_VALUE(count, EMAIL_ERROR_INVALID_PARAM); +#ifdef __FEATURE_ACCESS_CONTROL__ + err = em_check_db_privilege_by_pid(getpid()); + if (err == EMAIL_ERROR_PERMISSION_DENIED) { + EM_DEBUG_LOG("permission denied"); + goto FINISH_OFF; + } +#endif + if (!emstorage_get_account_list(count, &temp_account_tbl , true, false, &err)) { EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err); @@ -368,6 +392,7 @@ EXPORT_API int email_get_account_list(email_account_t** account_list, int* count *account_list = em_malloc(sizeof(email_account_t) * (*count)); 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)); @@ -380,14 +405,14 @@ FINISH_OFF: if(temp_account_tbl) emstorage_free_account(&temp_account_tbl, (*count), NULL); - 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_FUNC_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; @@ -421,20 +446,24 @@ EXPORT_API int email_validate_account(int account_id, int *handle) emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_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_FUNC_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; - EM_IF_NULL_RETURN_VALUE(account, false); + 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; + } /* create account information */ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VALIDATE_ACCOUNT_EX); @@ -464,19 +493,23 @@ EXPORT_API int email_validate_account_ex(email_account_t* account, int *handle) emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_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_FUNC_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; - EM_IF_NULL_RETURN_VALUE(account, false); + 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(emstorage_check_duplicated_account(account, true, &err) == false) { EM_DEBUG_EXCEPTION("emstorage_check_duplicated_account failed (%d) ", err); @@ -511,14 +544,15 @@ EXPORT_API int email_add_account_with_validation(email_account_t* account, int * emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_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_FUNC_BEGIN("file_name[%s]", file_name); + EM_DEBUG_API_BEGIN ("file_name[%p]", file_name); + int ret = 0; int err = EMAIL_ERROR_NONE; @@ -552,13 +586,13 @@ EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name) emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_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_FUNC_BEGIN("file_name[%s]", file_name); + EM_DEBUG_API_BEGIN ("file_name[%p]", file_name); int ret = 0; int err = EMAIL_ERROR_NONE; @@ -592,15 +626,16 @@ EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_END("err[%d]", err); + EM_DEBUG_API_END ("err[%d]", err); return err; } EXPORT_API int email_get_password_length_of_account(const int account_id, int *password_length) { - EM_DEBUG_FUNC_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; + int password_type = 1; if (account_id <= 0 || password_length == NULL) { EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); @@ -618,6 +653,12 @@ EXPORT_API int email_get_password_length_of_account(const int account_id, int *p 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))) { + 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) { EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed "); EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); @@ -630,13 +671,13 @@ EXPORT_API int email_get_password_length_of_account(const int account_id, int *p emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_END("*password_length[%d]", *password_length); + EM_DEBUG_API_END ("*password_length[%d]", *password_length); return err; } EXPORT_API int email_query_server_info(const char* domain_name, email_server_info_t **result_server_info) { - EM_DEBUG_FUNC_BEGIN("domain_name [%s], result_server_info [%p]", domain_name, result_server_info); + EM_DEBUG_API_BEGIN ("domain_name[%p] result_server_info[%p]", domain_name, result_server_info); int err = EMAIL_ERROR_NONE; if (!domain_name || !result_server_info) { @@ -647,14 +688,14 @@ EXPORT_API int email_query_server_info(const char* domain_name, email_server_inf err = emcore_query_server_info(domain_name, result_server_info); - EM_DEBUG_FUNC_END("err[%d]", err); + EM_DEBUG_API_END ("err[%d]", err); return err; } EXPORT_API int email_free_server_info(email_server_info_t **result_server_info) { - EM_DEBUG_FUNC_BEGIN("result_server_info [%p]", result_server_info); + EM_DEBUG_API_BEGIN ("result_server_info[%p]", result_server_info); int err = EMAIL_ERROR_NONE; if (!result_server_info) { @@ -665,14 +706,16 @@ EXPORT_API int email_free_server_info(email_server_info_t **result_server_info) err = emcore_free_server_info(result_server_info); - EM_DEBUG_FUNC_END("ret[%d]", err); + EM_DEBUG_API_END ("ret[%d]", err); return err; } EXPORT_API int email_update_notification_bar(int account_id) { - EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id); + EM_DEBUG_API_BEGIN("account_id [%d]", account_id); int err = EMAIL_ERROR_NONE; + int total_mail_count = 0; + int unread_mail_count = 0; if (account_id == 0) { EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM"); @@ -690,6 +733,17 @@ EXPORT_API int email_update_notification_bar(int account_id) 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))) { + 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))) { + 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) { EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed "); EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMAIL_ERROR_IPC_SOCKET_FAILURE); @@ -699,40 +753,40 @@ EXPORT_API int email_update_notification_bar(int account_id) emipc_destroy_email_api(hAPI); hAPI = NULL; - EM_DEBUG_FUNC_END("ret[%d]", err); + EM_DEBUG_API_END ("ret[%d]", err); return err; } EXPORT_API int email_clear_all_notification_bar() { - EM_DEBUG_FUNC_BEGIN(); + EM_DEBUG_FUNC_BEGIN (); int err = EMAIL_ERROR_NONE; err = emcore_clear_all_notifications(); - EM_DEBUG_FUNC_END("ret[%d]", err); + EM_DEBUG_FUNC_END ("ret[%d]", err); return err; } EXPORT_API int email_save_default_account_id(int input_account_id) { - EM_DEBUG_FUNC_BEGIN("input_account_id [%d]", input_account_id); + EM_DEBUG_API_BEGIN ("input_account_id [%d]", input_account_id); int err = EMAIL_ERROR_NONE; err = emcore_save_default_account_id(input_account_id); - EM_DEBUG_FUNC_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; err = emcore_load_default_account_id(output_account_id); - EM_DEBUG_FUNC_END("ret[%d]", err); + EM_DEBUG_FUNC_END ("ret[%d]", err); return err; } |