diff options
Diffstat (limited to 'email-ipc/email-ipc-api.c')
-rwxr-xr-x | email-ipc/email-ipc-api.c | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/email-ipc/email-ipc-api.c b/email-ipc/email-ipc-api.c index c2d527f..695c4db 100755 --- a/email-ipc/email-ipc-api.c +++ b/email-ipc/email-ipc-api.c @@ -70,7 +70,7 @@ EXPORT_API void emipc_destroy_email_api(HIPC_API api) EXPORT_API long emipc_get_api_id(HIPC_API api) { EM_DEBUG_FUNC_BEGIN(); - emipc_email_api_info *api_info = (emipc_email_api_info*)api; + emipc_email_api_info *api_info = (emipc_email_api_info *)api; EM_DEBUG_FUNC_END("api_id [%d]", api_info->api_id); return api_info->api_id; } @@ -79,6 +79,7 @@ EXPORT_API long emipc_get_app_id(HIPC_API api) { EM_DEBUG_FUNC_BEGIN(); emipc_email_api_info *api_info = (emipc_email_api_info *)api; + EM_DEBUG_FUNC_END("app_id [%d]", api_info->app_id); return api_info->app_id; } @@ -128,14 +129,12 @@ EXPORT_API int emipc_get_parameter(HIPC_API input_api_handle, EPARAMETER_DIRECTI } parameters = emipc_get_api_parameters(input_api_handle, input_parameter_direction); - if (parameters == NULL) { EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE"); return EMAIL_ERROR_IPC_PROTOCOL_FAILURE; } local_buffer = emipc_get_param_of_param_list(parameters, input_parameter_index); - if (local_buffer == NULL) { EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE"); return EMAIL_ERROR_IPC_PROTOCOL_FAILURE; @@ -160,14 +159,12 @@ EXPORT_API void* emipc_get_nth_parameter_data(HIPC_API api_handle, EPARAMETER_DI void *buf = NULL; parameters = emipc_get_api_parameters(api_handle, direction); - if (parameters == NULL) { EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE"); return NULL; } buf = emipc_get_param_of_param_list(parameters, param_index); - if (!buf) { EM_DEBUG_EXCEPTION("EMAIL_ERROR_IPC_PROTOCOL_FAILURE"); return NULL; @@ -183,7 +180,7 @@ EXPORT_API int emipc_get_parameter_length(HIPC_API api, EPARAMETER_DIRECTION dir EM_DEBUG_FUNC_BEGIN(); emipc_param_list *parameters = emipc_get_api_parameters(api, direction); if (parameters) { - EM_DEBUG_FUNC_END("Suceeded"); + EM_DEBUG_LOG("Suceeded"); return emipc_get_param_len_of_param_list(parameters, parameter_index); } EM_DEBUG_FUNC_END("Failed"); @@ -195,7 +192,7 @@ EXPORT_API int emipc_get_nth_parameter_length(HIPC_API api, EPARAMETER_DIRECTION EM_DEBUG_FUNC_BEGIN(); emipc_param_list *parameters = emipc_get_api_parameters(api, direction); if (parameters) { - EM_DEBUG_FUNC_END("Suceeded"); + EM_DEBUG_LOG("Suceeded"); return emipc_get_param_len_of_param_list(parameters, parameter_index); } EM_DEBUG_FUNC_END("Failed"); @@ -244,11 +241,60 @@ EXPORT_API int emipc_execute_proxy_task(email_task_type_t input_task_type, void emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err); - FINISH_OFF: - if(hAPI) +FINISH_OFF: + + EM_SAFE_FREE(task_parameter_stream); + + if (hAPI) emipc_destroy_email_api(hAPI); EM_DEBUG_FUNC_END("err [%d]", err); return err; } +EXPORT_API int emipc_get_user_name(char **output_user_name) +{ + EM_DEBUG_FUNC_BEGIN(); + + int err = EMAIL_ERROR_NONE; + + if (!output_user_name) { + EM_DEBUG_EXCEPTION("Invalid parameter"); + err = EMAIL_ERROR_INVALID_PARAM; + return err; + } + + int buffer_size = 0; + char *user_name = NULL; + + HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_USER_NAME); + 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) + goto FINISH_OFF; + + buffer_size = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1); + if (buffer_size > 0) { + user_name = (char *)malloc(buffer_size); + emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, buffer_size, user_name); + EM_DEBUG_LOG("Name : [%s]", user_name); + } + +FINISH_OFF: + + *output_user_name = EM_SAFE_STRDUP(user_name); + + EM_SAFE_FREE(user_name); + + if (hAPI) + emipc_destroy_email_api(hAPI); + + EM_DEBUG_FUNC_END(); + + return err; +} |